src/wd2010.c

changeset 116
21521e62007f
parent 115
da3d10af0711
child 122
b214cf455ff2
     1.1 diff -r da3d10af0711 -r 21521e62007f src/wd2010.c
     1.2 --- a/src/wd2010.c	Sat Nov 17 22:15:23 2012 +0000
     1.3 +++ b/src/wd2010.c	Sat Nov 17 22:26:53 2012 +0000
     1.4 @@ -102,6 +102,8 @@
     1.5  	ctx->cylinder_low_reg = 0;
     1.6  	ctx->cylinder_high_reg = 0;
     1.7  	ctx->sdh = 0;
     1.8 +	ctx->mcr2_hdsel3 = 0;
     1.9 +	ctx->mcr2_ddrive1 = 0;
    1.10  }
    1.11  
    1.12  void wd2010_done(WD2010_CTX *ctx)
    1.13 @@ -260,6 +262,17 @@
    1.14  
    1.15  	/*cpu_log_enabled = 1;*/
    1.16  
    1.17 +	if (addr == UNIXPC_REG_MCR2) {
    1.18 +		// The UNIX PC has an "MCR2" register with the following format:
    1.19 +		//   [ 7..2 ][1][0]
    1.20 +		//   Bits 7..2: Not used
    1.21 +		//   Bit 1:     DDRIVE1 (hard disk drive 1 select - not used?)
    1.22 +		//   Bit 0:     HDSEL3  (head-select bit 3)
    1.23 +		ctx->mcr2_hdsel3 = ((val & 1) == 1);
    1.24 +		ctx->mcr2_ddrive1 = ((val & 2) == 2);
    1.25 +		return;
    1.26 +	}
    1.27 +
    1.28  	switch (addr & 0x07) {
    1.29  		case WD2010_REG_WRITE_PRECOMP_CYLINDER:
    1.30  			break;
    1.31 @@ -313,7 +326,8 @@
    1.32  						ctx->irq = true;
    1.33  						break;
    1.34  					}
    1.35 -					ctx->head = ctx->sdh & 0x07;
    1.36 +					// The SDH register provides 3 head select bits; the 4th comes from MCR2.
    1.37 +					ctx->head = (ctx->sdh & 0x07) + (ctx->mcr2_hdsel3 ? 8 : 0);
    1.38  					ctx->sector = ctx->sector_number;
    1.39  
    1.40  					ctx->formatting = cmd == CMD_WRITE_FORMAT;