--- np2/bios/bios1b.c 2004/01/29 09:41:49 1.16 +++ np2/bios/bios1b.c 2004/03/31 19:23:37 1.26 @@ -17,24 +17,25 @@ enum { }; -static BYTE mtr_c = 0; -static UINT mtr_r = 0; - - // ---- FDD -static void setfdcmode(REG8 drv, REG8 type, REG8 rpm) { +static BOOL setfdcmode(REG8 drv, REG8 type, REG8 rpm) { - if (drv < 4) { - fdc.chgreg = type; - fdc.rpm[drv] = rpm; - if (type & 2) { - CTRL_FDMEDIA = DISKTYPE_2HD; - } - else { - CTRL_FDMEDIA = DISKTYPE_2DD; - } + if (drv >= 4) { + return(FAILURE); } + if ((rpm) && (!fdc.support144)) { + return(FAILURE); + } + fdc.chgreg = type; + fdc.rpm[drv] = rpm; + if (type & 2) { + CTRL_FDMEDIA = DISKTYPE_2HD; + } + else { + CTRL_FDMEDIA = DISKTYPE_2DD; + } + return(SUCCESS); } void fddbios_equip(REG8 type, BOOL clear) { @@ -47,11 +48,11 @@ void fddbios_equip(REG8 type, BOOL clear } if (type & 1) { diskequip &= 0xfff0; - diskequip |= 0x0003; + diskequip |= (fdc.equip & 0x0f); } else { - diskequip &= 0xf0ff; - diskequip |= 0x0300; + diskequip &= 0x0fff; + diskequip |= (fdc.equip & 0x0f) << 12; } SETBIOSMEM16(MEMW_DISK_EQUIP, diskequip); } @@ -92,7 +93,6 @@ static BOOL biosfd_seek(REG8 track, BOOL } } fdc.ncn = track; - mtr_c = track; if (fdd_seek()) { return(FAILURE); } @@ -121,7 +121,7 @@ static UINT16 fdfmt_biospara(REG8 type, off = 0x2361; // see bios.cpp } off += fdc.us * 2; - off = i286_memword_read(seg, off); + off = MEML_READ16(seg, off); off += n * 8; if (!(CPU_AH & 0x40)) { off += 4; @@ -129,7 +129,7 @@ static UINT16 fdfmt_biospara(REG8 type, if (fmt) { off += 2; } - return(i286_memword_read(seg, off)); + return(MEML_READ16(seg, off)); } @@ -160,6 +160,7 @@ static void fdd_int(int result) { case 0x0a: // READ ID case 0x0d: // フォーマット break; + default: return; } @@ -196,7 +197,17 @@ static void fdd_int(int result) { fdc.stat[fdc.us] |= FDCRLT_IC0 | FDCRLT_NW; fdcsend_error7(); break; + + default: + return; } + if (fdc.chgreg & 1) { + mem[0x0055e] &= ~(0x01 << fdc.us); + } + else { + mem[0x0055f] &= ~(0x10 << fdc.us); + } + CPU_IP = BIOSOFST_WAIT; } #if 1 @@ -282,8 +293,10 @@ static REG8 fdd_operate(REG8 type, REG8 BYTE hd; int result = FDCBIOS_NORESULT; UINT32 addr; + UINT8 mtr_c; + UINT mtr_r; - mtr_c = 0xff; + mtr_c = fdc.ncn; mtr_r = 0; // とりあえずBIOSの時は無視する @@ -291,7 +304,9 @@ static REG8 fdd_operate(REG8 type, REG8 // TRACE_("int 1Bh", CPU_AH); - setfdcmode(CPU_AL & 3, type, rpm); + if (setfdcmode((REG8)(CPU_AL & 3), type, rpm) != SUCCESS) { + return(0x40); + } if ((CPU_AH & 0x0f) != 0x0a) { fdc.crcn = 0; @@ -322,7 +337,7 @@ static REG8 fdd_operate(REG8 type, REG8 return(0x68); // 新センスは 両用ドライブ情報も } if (CPU_AH == 0xc4) { // ver0.31 - if (np2cfg.usefd144) { + if (fdc.support144) { return(0x6c); } return(0x68); @@ -433,8 +448,7 @@ static REG8 fdd_operate(REG8 type, REG8 } if (CPU_AH & 0x80) { // ver0.30 ret_ah |= 8; // 1MB/640KB両用ドライブ - if ((CPU_AH & 0x40) && - (np2cfg.usefd144)) { // ver0.31 + if ((CPU_AH & 0x40) && (fdc.support144)) { ret_ah |= 4; // 1.44対応ドライブ } } @@ -477,7 +491,7 @@ static REG8 fdd_operate(REG8 type, REG8 else { accesssize = size; } - i286_memx_read(addr, fdc.buf, accesssize); + MEML_READ(addr, fdc.buf, accesssize); if (fdd_write()) { break; } @@ -546,7 +560,7 @@ static REG8 fdd_operate(REG8 type, REG8 if (fdd_read()) { break; } - i286_memx_write(addr, fdc.buf, accesssize); + MEML_WRITE(addr, fdc.buf, accesssize); addr += accesssize; size -= accesssize; mtr_r += accesssize; // ver0.26 @@ -647,7 +661,7 @@ static REG8 fdd_operate(REG8 type, REG8 fdd_formatinit(); pos = CPU_BP; for (s=0; s> 4)]; if (seg) { - TRACEOUT(("call by %.4x:%.4x", - i286_memword_read(CPU_SS, CPU_SP+2), - i286_memword_read(CPU_SS, CPU_SP))); sp = CPU_SP; - i286_memword_write(CPU_SS, sp - 2, CPU_DS); - i286_memword_write(CPU_SS, sp - 4, CPU_SI); - i286_memword_write(CPU_SS, sp - 6, CPU_DI); - i286_memword_write(CPU_SS, sp - 8, CPU_ES); // +a - i286_memword_write(CPU_SS, sp - 10, CPU_BP); // +8 - i286_memword_write(CPU_SS, sp - 12, CPU_DX); // +6 - i286_memword_write(CPU_SS, sp - 14, CPU_CX); // +4 - i286_memword_write(CPU_SS, sp - 16, CPU_BX); // +2 - i286_memword_write(CPU_SS, sp - 18, CPU_AX); // +0 + MEML_WRITE16(CPU_SS, sp - 2, CPU_DS); + MEML_WRITE16(CPU_SS, sp - 4, CPU_SI); + MEML_WRITE16(CPU_SS, sp - 6, CPU_DI); + MEML_WRITE16(CPU_SS, sp - 8, CPU_ES); // +a + MEML_WRITE16(CPU_SS, sp - 10, CPU_BP); // +8 + MEML_WRITE16(CPU_SS, sp - 12, CPU_DX); // +6 + MEML_WRITE16(CPU_SS, sp - 14, CPU_CX); // +4 + MEML_WRITE16(CPU_SS, sp - 16, CPU_BX); // +2 + MEML_WRITE16(CPU_SS, sp - 18, CPU_AX); // +0 +#if 0 + TRACEOUT(("call by %.4x:%.4x", + MEML_READ16(CPU_SS, CPU_SP+2), + MEML_READ16(CPU_SS, CPU_SP))); TRACEOUT(("bypass to %.4x:0018", seg << 8)); TRACEOUT(("AX=%04x BX=%04x %02x:%02x:%02x:%02x ES=%04x BP=%04x", CPU_AX, CPU_BX, CPU_CL, CPU_DH, CPU_DL, CPU_CH, CPU_ES, CPU_BP)); +#endif sp -= 18; CPU_SP = sp; CPU_BP = sp; @@ -932,16 +951,16 @@ void bios0x1b(void) { #if 0 TRACEOUT(("%04x:%04x AX=%04x BX=%04x %02x:%02x:%02x:%02x\n" \ "ES=%04x BP=%04x \nret=%02x", - i286_memword_read(CPU_SS, CPU_SP+2), - i286_memword_read(CPU_SS, CPU_SP), + MEML_READ16(CPU_SS, CPU_SP+2), + MEML_READ16(CPU_SS, CPU_SP), CPU_AX, CPU_BX, CPU_CL, CPU_DH, CPU_DL, CPU_CH, CPU_ES, CPU_BP, ret_ah)); #endif CPU_AH = ret_ah; - flag = i286_membyte_read(CPU_SS, CPU_SP+4) & 0xfe; + flag = MEML_READ8(CPU_SS, CPU_SP+4) & 0xfe; if (ret_ah >= 0x20) { flag += 1; } - i286_membyte_write(CPU_SS, CPU_SP + 4, flag); + MEML_WRITE8(CPU_SS, CPU_SP + 4, flag); }