|
|
| version 1.10, 2004/01/13 05:30:58 | version 1.11, 2004/01/22 01:10:03 |
|---|---|
| Line 4 | Line 4 |
| #include "iocore.h" | #include "iocore.h" |
| #include "bios.h" | #include "bios.h" |
| #include "biosmem.h" | #include "biosmem.h" |
| #include "sxsibios.h" | |
| #include "fddfile.h" | #include "fddfile.h" |
| #include "fdd_mtr.h" | #include "fdd_mtr.h" |
| #include "sxsi.h" | #include "sxsi.h" |
| #include "scsicmd.h" | |
| #include "timing.h" | |
| enum { | enum { |
| Line 15 enum { | Line 18 enum { |
| }; | }; |
| char fdmode = 0; | // static UINT8 fdmode = 0; |
| static BYTE work[65536]; | static BYTE work[65536]; |
| static BYTE mtr_c = 0; | static BYTE mtr_c = 0; |
| static UINT mtr_r = 0; | static UINT mtr_r = 0; |
| Line 23 static UINT mtr_r = 0; | Line 26 static UINT mtr_r = 0; |
| // ---- FDD | // ---- FDD |
| static void init_fdd_equip(void) { | void fddbios_equip(REG8 type, BOOL clear) { |
| UINT16 diskequip; | REG16 diskequip; |
| diskequip = GETBIOSMEM16(MEMW_DISK_EQUIP); | diskequip = GETBIOSMEM16(MEMW_DISK_EQUIP); |
| diskequip &= 0x0f00; | if (clear) { |
| diskequip |= (UINT16)(~fdmode) & 3; | diskequip &= 0x0f00; |
| diskequip |= (UINT16)fdmode << 12; | } |
| if (type == DISKTYPE_2HD) { | |
| diskequip |= 0x0003; | |
| } | |
| if (type == DISKTYPE_2DD) { | |
| diskequip |= 0x0300; | |
| } | |
| SETBIOSMEM16(MEMW_DISK_EQUIP, diskequip); | SETBIOSMEM16(MEMW_DISK_EQUIP, diskequip); |
| } | } |
| Line 396 static BYTE fdd_operate(BYTE type, BOOL | Line 405 static BYTE fdd_operate(BYTE type, BOOL |
| break; | break; |
| case 0x03: // 初期化 | case 0x03: // 初期化 |
| init_fdd_equip(); | fddbios_equip(type, FALSE); |
| ret_ah = 0x00; | ret_ah = 0x00; |
| break; | break; |
| Line 653 static BYTE fdd_operate(BYTE type, BOOL | Line 662 static BYTE fdd_operate(BYTE type, BOOL |
| static void init_sasi_equip(void) { | static void init_sasi_equip(void) { |
| UINT16 diskequip; | UINT16 diskequip; |
| UINT i; | UINT8 i; |
| UINT16 bit; | UINT16 bit; |
| SXSIDEV sxsi; | |
| diskequip = GETBIOSMEM16(MEMW_DISK_EQUIP); | diskequip = GETBIOSMEM16(MEMW_DISK_EQUIP); |
| diskequip &= 0xf0ff; | diskequip &= 0xf0ff; |
| for (i=0, bit=0x0100; i<2; i++, bit<<=1) { | for (i=0x00, bit=0x0100; i<0x02; i++, bit<<=1) { |
| if (sxsi_hd[i].fname[0]) { | sxsi = sxsi_getptr(i); |
| if ((sxsi) && (sxsi->fname[0])) { | |
| diskequip |= bit; | diskequip |= bit; |
| } | } |
| } | } |
| Line 668 static void init_sasi_equip(void) { | Line 679 static void init_sasi_equip(void) { |
| static void init_scsi_equip(void) { | static void init_scsi_equip(void) { |
| UINT i; | UINT8 i; |
| BYTE bit; | UINT8 bit; |
| SXSIDEV sxsi; | |
| UINT16 w; | UINT16 w; |
| mem[MEMB_DISK_EQUIPS] = 0; | mem[MEMB_DISK_EQUIPS] = 0; |
| ZeroMemory(&mem[0x00460], 0x20); | ZeroMemory(&mem[0x00460], 0x20); |
| for (i=0, bit=1; i<2; i++, bit<<=1) { | for (i=0, bit=1; i<4; i++, bit<<=1) { |
| if (sxsi_hd[i+2].fname[0]) { | sxsi = sxsi_getptr((REG8)(0x20 + i)); |
| if ((sxsi) && (sxsi->fname[0])) { | |
| mem[MEMB_DISK_EQUIPS] |= bit; | mem[MEMB_DISK_EQUIPS] |= bit; |
| mem[0x00460+i*4] = sxsi_hd[i+2].sectors; | mem[0x00460+i*4] = sxsi->sectors; |
| mem[0x00461+i*4] = sxsi_hd[i+2].surfaces; | mem[0x00461+i*4] = sxsi->surfaces; |
| switch(sxsi_hd[i+2].size) { | switch(sxsi->size) { |
| case 256: | case 256: |
| w = 0 << 12; | w = 0 << 12; |
| break; | break; |
| Line 692 static void init_scsi_equip(void) { | Line 705 static void init_scsi_equip(void) { |
| w = 2 << 12; | w = 2 << 12; |
| break; | break; |
| } | } |
| w |= sxsi_hd[i+2].tracks; | w |= 0xc000; |
| w |= sxsi->cylinders; | |
| SETBIOSMEM16(0x00462+i*4, w); | SETBIOSMEM16(0x00462+i*4, w); |
| } | } |
| } | } |
| Line 700 static void init_scsi_equip(void) { | Line 714 static void init_scsi_equip(void) { |
| static BYTE sxsi_pos(long *pos) { | static BYTE sxsi_pos(long *pos) { |
| SXSIHDD sxsi; | SXSIDEV sxsi; |
| int np2drv; | |
| *pos = 0; | *pos = 0; |
| np2drv = (CPU_AL & 0x20) >> 4; | sxsi = sxsi_getptr(CPU_AL); |
| if ((CPU_AL & 0x0f) >= 2) { | if (sxsi == NULL) { |
| return(0x60); | return(0x60); |
| } | } |
| np2drv |= (CPU_AL & 1); | |
| sxsi = &sxsi_hd[np2drv]; | |
| if (CPU_AL & 0x80) { | if (CPU_AL & 0x80) { |
| if ((CPU_DL >= sxsi->sectors) || | if ((CPU_DL >= sxsi->sectors) || |
| (CPU_DH >= sxsi->surfaces) || | (CPU_DH >= sxsi->surfaces) || |
| (CPU_CX >= sxsi->tracks)) { | (CPU_CX >= sxsi->cylinders)) { |
| return(0xd0); | return(0xd0); |
| } | } |
| (*pos) = ((CPU_CX * sxsi->surfaces) + CPU_DH) * sxsi->sectors | *pos = ((CPU_CX * sxsi->surfaces) + CPU_DH) * sxsi->sectors |
| + CPU_DL; | + CPU_DL; |
| } | } |
| else { | else { |
| Line 731 static BYTE sxsi_pos(long *pos) { | Line 742 static BYTE sxsi_pos(long *pos) { |
| return(0x00); | return(0x00); |
| } | } |
| static REG8 sxsidev_format(REG8 drv, SXSIDEV sxsi) { | |
| UINT count; | |
| REG8 ret; | |
| long trk; | |
| long trkmax; | |
| UINT8 sxsi_operate(UINT8 type) { | count = timing_getcount(); // 時間を止める |
| BYTE ret_ah = 0x00; | ret = 0; |
| BYTE drv; | trk = 0; |
| trkmax = sxsi->surfaces * sxsi->cylinders; | |
| while(trk < trkmax) { | |
| ret = sxsi_format(drv, trk * sxsi->sectors); | |
| if (ret) { | |
| break; | |
| } | |
| trk++; | |
| } | |
| timing_setcount(count); // 再開 | |
| return(ret); | |
| } | |
| REG8 sxsi_operate(REG8 type) { | |
| SXSIDEV sxsi; | |
| REG8 ret_ah; | |
| long pos; | long pos; |
| // int i; | |
| drv = (CPU_AL & 0x20) >> 4; | sxsi = sxsi_getptr(CPU_AL); |
| if ((CPU_AL & 0x0f) >= 2) { | if (sxsi == NULL) { |
| return(0x60); | return(0x60); |
| } | } |
| drv |= (CPU_AL & 1); | |
| ret_ah = 0x00; | |
| switch(CPU_AH & 0x0f) { | switch(CPU_AH & 0x0f) { |
| case 0x01: // ベリファイ | case 0x01: // ベリファイ |
| case 0x07: // リトラクト | case 0x07: // リトラクト |
| Line 752 UINT8 sxsi_operate(UINT8 type) { | Line 786 UINT8 sxsi_operate(UINT8 type) { |
| break; | break; |
| case 0x03: // イニシャライズ | case 0x03: // イニシャライズ |
| if (type == HDDTYPE_SASI) { | if (type == BIOS1B_SASI) { |
| init_sasi_equip(); | init_sasi_equip(); |
| } | } |
| else if (type == HDDTYPE_SCSI) { | else if (type == BIOS1B_SCSI) { |
| init_scsi_equip(); | init_scsi_equip(); |
| } | } |
| break; | break; |
| case 0x04: // センス | case 0x04: // センス |
| ret_ah = 0x00; | ret_ah = 0x00; |
| if ((CPU_AH == 0x04) && (type == HDDTYPE_SASI)) { | if ((CPU_AH == 0x04) && (type == BIOS1B_SASI)) { |
| ret_ah = 0x04; | ret_ah = 0x04; |
| } | } |
| else if ((CPU_AH == 0x44) && (type == HDDTYPE_SCSI)) { | else if ((CPU_AH == 0x44) && (type == BIOS1B_SCSI)) { |
| CPU_BX = 1; | CPU_BX = 1; |
| } | } |
| else if (CPU_AH == 0x84) { | else if (CPU_AH == 0x84) { |
| CPU_BX = sxsi_hd[drv].size; | CPU_BX = sxsi->size; |
| CPU_CX = sxsi_hd[drv].tracks; | CPU_CX = sxsi->cylinders; |
| CPU_DH = sxsi_hd[drv].surfaces; | CPU_DH = sxsi->surfaces; |
| CPU_DL = sxsi_hd[drv].sectors; | CPU_DL = sxsi->sectors; |
| } | } |
| break; | break; |
| Line 794 UINT8 sxsi_operate(UINT8 type) { | Line 828 UINT8 sxsi_operate(UINT8 type) { |
| } | } |
| break; | break; |
| case 0x0a: // セクタ長設定 | |
| if ((type == BIOS1B_SCSI) && | |
| (sxsi->size == (128 << (CPU_BH & 3)))) { | |
| ret_ah = 0x00; | |
| } | |
| else { | |
| ret_ah = 0x40; | |
| } | |
| break; | |
| case 0x0c: // 代替情報取得 | |
| if (type == BIOS1B_SCSI) { | |
| ret_ah = 0x00; | |
| CPU_CX = 0; | |
| } | |
| else { | |
| ret_ah = 0x40; | |
| } | |
| break; | |
| case 0x0d: // フォーマット | case 0x0d: // フォーマット |
| if (CPU_DL) { | if (CPU_AH & 0x80) { |
| ret_ah = 0x30; | ret_ah = sxsidev_format(CPU_AL, sxsi); |
| break; | |
| } | } |
| i286_memstr_read(CPU_ES, CPU_BP, work, CPU_BX); | else { |
| ret_ah = sxsi_pos(&pos); | if (CPU_DL) { |
| if (!ret_ah) { | ret_ah = 0x30; |
| ret_ah = sxsi_format(CPU_AL, pos); | break; |
| } | |
| i286_memstr_read(CPU_ES, CPU_BP, work, CPU_BX); | |
| ret_ah = sxsi_pos(&pos); | |
| if (!ret_ah) { | |
| ret_ah = sxsi_format(CPU_AL, pos); | |
| } | |
| } | } |
| break; | break; |
| Line 885 static UINT16 boot_fd(BYTE drv, BYTE typ | Line 944 static UINT16 boot_fd(BYTE drv, BYTE typ |
| // 1.25MB | // 1.25MB |
| bootseg = boot_fd1(0); | bootseg = boot_fd1(0); |
| if (bootseg) { | if (bootseg) { |
| mem[MEMB_DISK_BOOT] = (BYTE)(0x90+drv); | mem[MEMB_DISK_BOOT] = (UINT8)(0x90 + drv); |
| fddbios_equip(DISKTYPE_2HD, TRUE); | |
| return(bootseg); | return(bootseg); |
| } | } |
| // 1.44MB | // 1.44MB |
| bootseg = boot_fd1(1); | bootseg = boot_fd1(1); |
| if (bootseg) { | if (bootseg) { |
| mem[MEMB_DISK_BOOT] = (BYTE)(0x30+drv); | mem[MEMB_DISK_BOOT] = (UINT8)(0x30 + drv); |
| fddbios_equip(DISKTYPE_2HD, TRUE); | |
| return(bootseg); | return(bootseg); |
| } | } |
| } | } |
| Line 900 static UINT16 boot_fd(BYTE drv, BYTE typ | Line 961 static UINT16 boot_fd(BYTE drv, BYTE typ |
| CTRL_FDMEDIA = DISKTYPE_2DD; | CTRL_FDMEDIA = DISKTYPE_2DD; |
| bootseg = boot_fd1(0); | bootseg = boot_fd1(0); |
| if (bootseg) { | if (bootseg) { |
| mem[MEMB_DISK_BOOT] = (BYTE)(0x70+drv); | mem[MEMB_DISK_BOOT] = (BYTE)(0x70 + drv); |
| fdmode = 3; | fddbios_equip(DISKTYPE_2DD, TRUE); |
| return(bootseg); | return(bootseg); |
| } | } |
| } | } |
| return(0); | return(0); |
| } | } |
| static UINT16 boot_hd(BYTE drv) { // ver0.27 | static REG16 boot_hd(REG8 drv) { |
| BYTE ret; | BYTE ret; |
| Line 920 static UINT16 boot_hd(BYTE drv) { | Line 981 static UINT16 boot_hd(BYTE drv) { |
| return(0); | return(0); |
| } | } |
| UINT16 bootstrapload(void) { // ver0.27 | REG16 bootstrapload(void) { |
| BYTE i; | BYTE i; |
| UINT16 bootseg; | REG16 bootseg; |
| fdmode = 0; | // fdmode = 0; |
| bootseg = 0; | bootseg = 0; |
| switch(mem[MEMB_MSW5] & 0xf0) { // うぐぅ…本当はALレジスタの値から | switch(mem[MEMB_MSW5] & 0xf0) { // うぐぅ…本当はALレジスタの値から |
| case 0x00: // ノーマル | case 0x00: // ノーマル |
| break; | break; |
| case 0x20: // 640KB FDD | case 0x20: // 640KB FDD |
| for (i=0; (i<4) && (!bootseg); i++) { | for (i=0; (i<4) && (!bootseg); i++) { |
| if (fdd_diskready(i)) { | if (fdd_diskready(i)) { |
| Line 937 UINT16 bootstrapload(void) { // | Line 999 UINT16 bootstrapload(void) { // |
| } | } |
| } | } |
| break; | break; |
| case 0x40: // 1.2MB FDD | case 0x40: // 1.2MB FDD |
| for (i=0; (i<4) && (!bootseg); i++) { | for (i=0; (i<4) && (!bootseg); i++) { |
| if (fdd_diskready(i)) { | if (fdd_diskready(i)) { |
| Line 944 UINT16 bootstrapload(void) { // | Line 1007 UINT16 bootstrapload(void) { // |
| } | } |
| } | } |
| break; | break; |
| case 0x60: // MO | case 0x60: // MO |
| break; | break; |
| case 0xa0: // SASI 1 | case 0xa0: // SASI 1 |
| if (sxsi_hd[0].fname[0]) { | bootseg = boot_hd(0x80); |
| bootseg = boot_hd(0x80); | |
| } | |
| break; | break; |
| case 0xb0: // SASI 2 | case 0xb0: // SASI 2 |
| if (sxsi_hd[1].fname[0]) { | bootseg = boot_hd(0x81); |
| bootseg = boot_hd(0x81); | |
| } | |
| break; | break; |
| case 0xc0: // SCSI | case 0xc0: // SCSI |
| for (i=0; (i<2) && (!bootseg); i++) { | for (i=0; (i<4) && (!bootseg); i++) { |
| if (sxsi_hd[i+2].fname[0]) { | bootseg = boot_hd((REG8)(0xa0 + i)); |
| bootseg = boot_hd((BYTE)(0xa0 | i)); | |
| } | |
| } | } |
| break; | break; |
| default: // ROM | default: // ROM |
| return(0); | return(0); |
| } | } |
| Line 972 UINT16 bootstrapload(void) { // | Line 1034 UINT16 bootstrapload(void) { // |
| } | } |
| } | } |
| for (i=0; (i<2) && (!bootseg); i++) { | for (i=0; (i<2) && (!bootseg); i++) { |
| if (sxsi_hd[i].fname[0]) { | bootseg = boot_hd((REG8)(0x80 + i)); |
| bootseg = boot_hd((BYTE)(0x80 | i)); | |
| } | |
| } | } |
| for (i=0; (i<2) && (!bootseg); i++) { | for (i=0; (i<4) && (!bootseg); i++) { |
| if (sxsi_hd[i+2].fname[0]) { | bootseg = boot_hd((REG8)(0xa0 + i)); |
| bootseg = boot_hd((BYTE)(0xa0 | i)); | |
| } | |
| } | } |
| init_fdd_equip(); | // init_fdd_equip(); |
| init_sasi_equip(); | // init_sasi_equip(); |
| init_scsi_equip(); | // init_scsi_equip(); |
| return(bootseg); | return(bootseg); |
| } | } |
| Line 995 void bios0x1b(void) { | Line 1053 void bios0x1b(void) { |
| BYTE ret_ah; | BYTE ret_ah; |
| REG8 flag; | REG8 flag; |
| #if 0 // bypass to disk bios | #if defined(SUPPORT_SCSI) |
| if ((CPU_AL & 0xf0) == 0xc0) { | |
| TRACEOUT(("%.4x:%.4x AX=%.4x BX=%.4x CX=%.4x DX=%.4 ES=%.4x BP=%.4x", | |
| i286_memword_read(CPU_SS, CPU_SP+2), | |
| i286_memword_read(CPU_SS, CPU_SP), | |
| CPU_AX, CPU_BX, CPU_CX, CPU_DX, CPU_ES, CPU_BP)); | |
| scsicmd_bios(); | |
| return; | |
| } | |
| #endif | |
| #if 1 // bypass to disk bios | |
| { | |
| REG8 seg; | REG8 seg; |
| UINT sp; | UINT sp; |
| Line 1028 void bios0x1b(void) { | Line 1098 void bios0x1b(void) { |
| CPU_IP = 0x18; | CPU_IP = 0x18; |
| return; | return; |
| } | } |
| } | |
| #endif | #endif |
| switch(CPU_AL & 0xf0) { | switch(CPU_AL & 0xf0) { |
| Line 1052 void bios0x1b(void) { | Line 1123 void bios0x1b(void) { |
| case 0x00: | case 0x00: |
| case 0x80: | case 0x80: |
| ret_ah = sxsi_operate(HDDTYPE_SASI); | // ret_ah = sxsi_operate(BIOS1B_SASI); |
| ret_ah = sasibios_operate(); | |
| break; | break; |
| #if 0 | |
| #if defined(SUPPORT_SCSI) | |
| case 0x20: | case 0x20: |
| case 0xa0: | case 0xa0: |
| ret_ah = sxsi_operate(HDDTYPE_SCSI); | // ret_ah = sxsi_operate(BIOS1B_SCSI); |
| ret_ah = scsibios_operate(); | |
| break; | break; |
| #endif | #endif |
| Line 1078 void bios0x1b(void) { | Line 1152 void bios0x1b(void) { |
| } | } |
| } | } |
| #endif | #endif |
| #if 0 | #if 1 |
| TRACEOUT(("%04x:%04x AX=%04x BX=%04x %02x:%02x:%02x:%02x\n" \ | TRACEOUT(("%04x:%04x AX=%04x BX=%04x %02x:%02x:%02x:%02x\n" \ |
| "ES=%04x BP=%04x \nret=%02x", | "ES=%04x BP=%04x \nret=%02x", |
| i286_memword_read(CPU_SS, CPU_SP+2), | i286_memword_read(CPU_SS, CPU_SP+2), |