--- np2/bios/bios1b.c 2004/01/22 08:40:30 1.12 +++ np2/bios/bios1b.c 2004/01/29 09:41:49 1.16 @@ -2,14 +2,13 @@ #include "cpucore.h" #include "pccore.h" #include "iocore.h" +#include "scsicmd.h" #include "bios.h" #include "biosmem.h" #include "sxsibios.h" #include "fddfile.h" #include "fdd_mtr.h" #include "sxsi.h" -#include "scsicmd.h" -#include "timing.h" enum { @@ -24,6 +23,20 @@ static UINT mtr_r = 0; // ---- FDD +static void 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; + } + } +} + void fddbios_equip(REG8 type, BOOL clear) { REG16 diskequip; @@ -32,10 +45,12 @@ void fddbios_equip(REG8 type, BOOL clear if (clear) { diskequip &= 0x0f00; } - if (type == DISKTYPE_2HD) { + if (type & 1) { + diskequip &= 0xfff0; diskequip |= 0x0003; } - if (type == DISKTYPE_2DD) { + else { + diskequip &= 0xf0ff; diskequip |= 0x0300; } SETBIOSMEM16(MEMW_DISK_EQUIP, diskequip); @@ -84,7 +99,7 @@ static BOOL biosfd_seek(REG8 track, BOOL return(SUCCESS); } -static UINT16 fdfmt_biospara(REG8 fmt, REG8 rpm) { // ver0.31 +static UINT16 fdfmt_biospara(REG8 type, REG8 rpm, REG8 fmt) { UINT seg; UINT off; @@ -94,7 +109,7 @@ static UINT16 fdfmt_biospara(REG8 fmt, R if (n >= 4) { n = 3; } - if (CTRL_FDMEDIA == DISKTYPE_2HD) { + if (type & 2) { seg = GETBIOSMEM16(MEMW_F2HD_P_SEG); off = GETBIOSMEM16(MEMW_F2HD_P_OFF); } @@ -117,14 +132,6 @@ static UINT16 fdfmt_biospara(REG8 fmt, R return(i286_memword_read(seg, off)); } -static void change_rpm(REG8 rpm) { // ver0.31 - - if (np2cfg.usefd144) { - fdc.rpm = rpm; - } -} - - enum { FDCBIOS_NORESULT, @@ -262,7 +269,7 @@ static void b0clr(void) { } #endif -static REG8 fdd_operate(REG8 type, BOOL ndensity, REG8 rpm) { // ver0.31 +static REG8 fdd_operate(REG8 type, REG8 rpm, BOOL ndensity) { REG8 ret_ah = 0x60; UINT16 size; @@ -279,29 +286,26 @@ static REG8 fdd_operate(REG8 type, BOOL mtr_c = 0xff; mtr_r = 0; - // とりあえずBIOSの時は無視する fdc.mf = 0xff; // ver0.29 // TRACE_("int 1Bh", CPU_AH); - change_rpm(rpm); // ver0.31 + setfdcmode(CPU_AL & 3, type, rpm); + if ((CPU_AH & 0x0f) != 0x0a) { fdc.crcn = 0; } if ((CPU_AH & 0x0f) != 0x03) { - CTRL_FDMEDIA = type; - switch(type) { - case DISKTYPE_2HD: - if (pic.pi[1].imr & PIC_INT42) { - return(0xd0); - } - break; - case DISKTYPE_2DD: - if (pic.pi[1].imr & PIC_INT41) { - return(0xd0); - } - break; + if (type & 2) { + if (pic.pi[1].imr & PIC_INT42) { + return(0x40); + } + } + else { + if (pic.pi[1].imr & PIC_INT41) { + return(0x40); + } } if (fdc.us != (CPU_AL & 0x03)) { fdc.us = CPU_AL & 0x03; @@ -359,7 +363,7 @@ static REG8 fdd_operate(REG8 type, BOOL } } biosfd_setchrn(); - para = fdfmt_biospara(0, rpm); + para = fdfmt_biospara(type, rpm, 0); if (!para) { ret_ah = 0xd0; break; @@ -448,7 +452,7 @@ static REG8 fdd_operate(REG8 type, BOOL } } biosfd_setchrn(); - para = fdfmt_biospara(0, rpm); + para = fdfmt_biospara(type, rpm, 0); if (!para) { ret_ah = 0xd0; break; @@ -513,7 +517,7 @@ static REG8 fdd_operate(REG8 type, BOOL } } biosfd_setchrn(); - para = fdfmt_biospara(0, rpm); + para = fdfmt_biospara(type, rpm, 0); if (!para) { ret_ah = 0xd0; break; @@ -634,7 +638,7 @@ static REG8 fdd_operate(REG8 type, BOOL } fdc.d = CPU_DL; fdc.N = CPU_CH; - para = fdfmt_biospara(1, rpm); + para = fdfmt_biospara(type, rpm, 1); if (!para) { ret_ah = 0xd0; break; @@ -646,6 +650,12 @@ static REG8 fdd_operate(REG8 type, BOOL i286_memstr_read(CPU_ES, pos, ID, 4); fdd_formating(ID); pos += 4; + if (ID[3] < 8) { + mtr_r += 128 << ID[3]; + } + else { + mtr_r += 128 << 8; + } } ret_ah = 0x00; break; @@ -659,14 +669,14 @@ static REG8 fdd_operate(REG8 type, BOOL // -------------------------------------------------------------------- BIOS -static UINT16 boot_fd1(REG8 rpm) { // ver0.31 +static UINT16 boot_fd1(REG8 type, REG8 rpm) { UINT remain; UINT size; UINT32 pos; UINT16 bootseg; - change_rpm(rpm); // ver0.31 + setfdcmode(fdc.us, type, rpm); if (biosfd_seek(0, 0)) { return(0); } @@ -717,36 +727,34 @@ static UINT16 boot_fd(REG8 drv, REG8 typ if (drv >= 4) { return(0); } - fdc.us = drv & 3; + fdc.us = drv; if (!fdd_diskready(fdc.us)) { return(0); } // 2HD if (type & 1) { - CTRL_FDMEDIA = DISKTYPE_2HD; // 1.25MB - bootseg = boot_fd1(0); + bootseg = boot_fd1(3, 0); if (bootseg) { mem[MEMB_DISK_BOOT] = (UINT8)(0x90 + drv); - fddbios_equip(DISKTYPE_2HD, TRUE); + fddbios_equip(3, TRUE); return(bootseg); } // 1.44MB - bootseg = boot_fd1(1); + bootseg = boot_fd1(3, 1); if (bootseg) { mem[MEMB_DISK_BOOT] = (UINT8)(0x30 + drv); - fddbios_equip(DISKTYPE_2HD, TRUE); + fddbios_equip(3, TRUE); return(bootseg); } } if (type & 2) { // ver0.29 // 2DD - CTRL_FDMEDIA = DISKTYPE_2DD; - bootseg = boot_fd1(0); + bootseg = boot_fd1(0, 0); if (bootseg) { mem[MEMB_DISK_BOOT] = (BYTE)(0x70 + drv); - fddbios_equip(DISKTYPE_2DD, TRUE); + fddbios_equip(0, TRUE); return(bootseg); } } @@ -884,34 +892,35 @@ void bios0x1b(void) { switch(CPU_AL & 0xf0) { case 0x90: - ret_ah = fdd_operate(DISKTYPE_2HD, 0, 0); + ret_ah = fdd_operate(3, 0, 0); break; case 0x30: case 0xb0: - ret_ah = fdd_operate(DISKTYPE_2HD, 0, 1); + ret_ah = fdd_operate(3, 1, 0); break; case 0x10: + ret_ah = fdd_operate(1, 0, 0); + break; + case 0x70: case 0xf0: - ret_ah = fdd_operate(DISKTYPE_2DD, 0, 0); + ret_ah = fdd_operate(0, 0, 0); break; case 0x50: - ret_ah = fdd_operate(DISKTYPE_2DD, 1, 0); + ret_ah = fdd_operate(0, 0, 1); break; case 0x00: case 0x80: -// ret_ah = sxsi_operate(BIOS1B_SASI); ret_ah = sasibios_operate(); break; #if defined(SUPPORT_SCSI) case 0x20: case 0xa0: -// ret_ah = sxsi_operate(BIOS1B_SCSI); ret_ah = scsibios_operate(); break; #endif