OSDN Git Service

[VM][FM7][MB8877][DISK] Workaround for RIGLAS/FM-7.
authorK.Ohta <whatisthis.sowhat@gmail.com>
Mon, 12 Sep 2016 20:19:13 +0000 (05:19 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Mon, 12 Sep 2016 20:19:13 +0000 (05:19 +0900)
Perhaps, below have side-effect, add special-disk to RIGLAS FM.
* Don't "NOT READY" even stopping motor.
* Transfer even stopping motor.
[EVENT] Remove logging on cancel event.

source/src/vm/disk.cpp
source/src/vm/disk.h
source/src/vm/event.cpp
source/src/vm/mb8877.cpp

index 35c220a..569e950 100644 (file)
@@ -422,6 +422,19 @@ void DISK::open(const _TCHAR* file_path, int bank)
                                                                0x4f, 0xa5, 0x42, 0x4c, 0x41, 0x44, 0x45, 0x20,
                                                                0x20, 0x20, 0x44, 0x49, 0x53, 0x4B, 0x20
                                                        };
+                                                       //RIGLAS/FM: $3E - $7D 
+                                                       static const uint8_t riglas_fm[] = {
+                                                                                                   0x0d, 0x56, /* $3e-$3f */
+                                                               0x44, 0x53, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, /* $40-$47 */
+                                                               0x43, 0x4d, 0x44, 0x00, 0x00, 0x02, 0x1b, 0x02, /* $48-$4f */
+                                                               0x1e, 0x00, 0x04, 0x00, 0x00, 0x03, 0x0d, 0x56, /* $50-$57 */
+                                                               0x43, 0x4f, 0x50, 0x59, 0x00, 0x00, 0x00, 0x00, /* $58-$5f */
+                                                               0x43, 0x4d, 0x44, 0x00, 0x00, 0x02, 0x1f, 0x03, /* $60-$67 */
+                                                               0x03, 0x00, 0x05, 0x00, 0x00, 0x03, 0x0d, 0x56, /* $68-$6f */
+                                                               0x44, 0x45, 0x4c, 0x45, 0x54, 0x45, 0x00, 0x00, /* $70-$77 */
+                                                               0x43, 0x4d, 0x44, 0x00, 0x00, 0x03              /* $78-$7d */
+                                                       };
+                                                       
                                                        if(memcmp((void *)(t + 0x58), psyoblade_ipl1, sizeof(psyoblade_ipl1)) == 0) {
                                                                is_special_disk = SPECIAL_DISK_FM77AV_PSYOBLADE;
                                                                this->out_debug_log("SPECIAL DISK: PSY-O-BLADE");
@@ -432,6 +445,10 @@ void DISK::open(const _TCHAR* file_path, int bank)
                                                                        this->out_debug_log("SPECIAL DISK: PSY-O-BLADE");
                                                                        break;
                                                                }
+                                                       } else if(memcmp((void *)(t + 0x3e + 0x10), riglas_fm, sizeof(riglas_fm)) == 0) {
+                                                               is_special_disk = SPECIAL_DISK_FM7_RIGLAS;
+                                                               this->out_debug_log("SPECIAL DISK: RIGLAS FM-7/77/AV");
+                                                               break;
                                                        }
                                                } else if(data_size.sd == 0x100 && t[0] == 0 && t[1] == 0 && t[2] == 3 && t[3] == 1) {
                                                        static const uint8_t taiyoufm1[] = {
@@ -468,40 +485,6 @@ void DISK::open(const _TCHAR* file_path, int bank)
                                                                break;
                                                        }
                                                }
-                                       } else if(data_size.sd == 0x100 && t[0] == 0 && t[1] == 0 && t[2] == 3 && t[3] == 1) {
-                                               static const uint8_t taiyoufm1[] = {
-                                                       0x10, 0xff, 0x04, 0x9f, 0x10, 0xce, 0xfc, 0xf4,
-                                                       0x37, 0x20, 0x34, 0x20, 0x37, 0x36, 0x34, 0x36, //7 4 7646
-                                                       0x37, 0x36, 0x34, 0x36, 0x37, 0x36, 0x34, 0x36, //76467646
-                                                       0x37, 0x36, 0x34, 0x36, 0x37, 0x36, 0x34, 0x36, //76467646
-                                                       0x37, 0x36, 0x34, 0x36, 0x37, 0x36, 0x34, 0x36, //76467646
-                                                       0x37, 0x36, 0x34, 0x36, 0x37, 0x36, 0x34, 0x36, //76467646
-                                                       0x37, 0x36, 0x34, 0x36, 0x37, 0x36, 0x34, 0x36, //76467646
-                                                       0x10, 0xfe, 0x04, 0x9f, 0x1c, 0xef, 0x86, 0xff,
-                                                       0xb7, 0xfc, 0xf8, 0x17, 0x03, 0x3d, 0x33, 0xc9,
-                                                       0xdb, 0x9c, 0x35, 0x04, 0x5a, 0x26, 0xa0, 0xfe,
-                                               };
-                                               if(memcmp((void *)(t + 0x70), taiyoufm1, sizeof(taiyoufm1)) == 0) {
-                                                       is_special_disk = SPECIAL_DISK_FM7_TAIYOU1;
-                                                               this->out_debug_log("SPECIAL DISK: TAIYOU NO SHINDEN Disk 1");
-                                                       break;
-                                               }
-                                       } else if(data_size.sd == 0x100 && t[0] == 0 && t[1] == 0 && t[2] == 2 && t[3] == 1) {
-                                               static const uint8_t taiyoufm2[] = {
-                                                       0x3d, 0x02, 0xa3, 0xd6, 0x01, 0xc7, 0x06, 0x86,
-                                                       0x07, 0x00, 0x00, 0xc7, 0x06, 0xd4, 0x01, 0x00,
-                                                       0x00, 0xb4, 0x19, 0xcd, 0x21, 0xfe, 0xc0, 0xa2,
-                                                       0xda, 0x01, 0x06, 0xb9, 0x10, 0x00, 0xbb, 0x40,
-                                                       0x00, 0x8e, 0xc3, 0xbb, 0x00, 0x00, 0xfe, 0x06,
-                                                       0xd9, 0x01, 0x26, 0x80, 0xbf, 0x6c, 0x02, 0x00,
-                                                       0x74, 0x03, 0x43, 0xe2, 0xf1, 0x07, 0xc6, 0x06,
-                                                       0xdb, 0x01, 0x00, 0xbb, 0x80, 0x00, 0x80, 0x3f,
-                                               };
-                                               if(memcmp((void *)(t + 0x00), taiyoufm2, sizeof(taiyoufm2)) == 0) {
-                                                       is_special_disk = SPECIAL_DISK_FM7_TAIYOU2;
-                                                       this->out_debug_log("SPECIAL DISK: TAIYOU NO SHINDEN Disk 1");
-                                                       break;
-                                               }
                                        }
                                        t += data_size.sd + 0x10;
                                }
index 6411181..1b28554 100644 (file)
@@ -45,6 +45,7 @@
 #define SPECIAL_DISK_FM7_TAIYOU1 14
 #define SPECIAL_DISK_FM7_TAIYOU2 15
 #define SPECIAL_DISK_FM7_XANADU2_D 16
+#define SPECIAL_DISK_FM7_RIGLAS 17
 
 // d88 constant
 #define DISK_BUFFER_SIZE       0x380000        // 3.5MB
index 7212de2..b6dba6c 100644 (file)
@@ -358,11 +358,6 @@ void EVENT::cancel_event(DEVICE* device, int register_id)
 #endif                 
                        return;
                }
-#ifdef _DEBUG_LOG              
-# if defined(_USE_QT)                  
-               if(device != NULL) csp_logger->output_event_log(device->this_device_id, CSP_LOG_INFO, _T("Canceling event was succeeded (id=%d  register_id=%d)"), device->this_device_id, register_id);
-# endif
-#endif
                if(event_handle->active) {
                        if(event_handle->prev != NULL) {
                                event_handle->prev->next = event_handle->next;
index 0152d99..dd06c82 100644 (file)
@@ -41,6 +41,7 @@
 #define EVENT_MULTI1           4
 #define EVENT_MULTI2           5
 #define EVENT_LOST             6
+#define EVENT_MOTOR 7
 
 #define DRIVE_MASK             (MAX_DRIVE - 1)
 
@@ -65,6 +66,7 @@ void MB8877::register_my_event(int event, double usec)
 
 void MB8877::register_seek_event()
 {
+
        cancel_my_event(EVENT_SEEK);
        if(fdc[drvreg].track == seektrk) {
                register_event(this, (EVENT_SEEK << 8) | (cmdtype & 0xff), 1, false, &register_id[EVENT_SEEK]);
@@ -153,6 +155,7 @@ void MB8877::reset()
 
 void MB8877::write_io8(uint32_t addr, uint32_t data)
 {
+       bool _stat;
        switch(addr & 3) {
        case 0:
                // command reg
@@ -200,7 +203,12 @@ void MB8877::write_io8(uint32_t addr, uint32_t data)
 #else
                datareg = data;
 #endif
-               if(motor_on && (status & FDC_ST_DRQ) && !now_search) {
+
+               _stat = ((status & FDC_ST_DRQ) && !now_search);
+               if(disk[drvreg]->is_special_disk != SPECIAL_DISK_FM7_RIGLAS) {
+                       _stat = (_stat && motor_on);
+               }
+               if(_stat) {
                        if(cmdtype == FDC_CMD_WR_SEC || cmdtype == FDC_CMD_WR_MSEC) {
                                // write or multisector write
                                if(fdc[drvreg].index < disk[drvreg]->sector_size.sd) {
@@ -349,7 +357,7 @@ write_id:
 uint32_t MB8877::read_io8(uint32_t addr)
 {
        uint32_t val;
-       
+       bool _stat;
        switch(addr & 3) {
        case 0:
                // status reg
@@ -358,7 +366,11 @@ uint32_t MB8877::read_io8(uint32_t addr)
                        val = FDC_ST_BUSY;
                } else {
                        // disk not inserted, motor stop
-                       if(!disk[drvreg]->inserted || !motor_on) {
+                       _stat = !disk[drvreg]->inserted;
+                       if(disk[drvreg]->is_special_disk != SPECIAL_DISK_FM7_RIGLAS) {
+                               _stat = (_stat || !motor_on);
+                       }
+                       if(_stat) {
                                status |= FDC_ST_NOTREADY;
                        } else {
                                status &= ~FDC_ST_NOTREADY;
@@ -393,9 +405,9 @@ uint32_t MB8877::read_io8(uint32_t addr)
                                status &= ~FDC_ST_BUSY;
 #ifdef MB8877_NO_BUSY_AFTER_SEEK
        #if defined(_FM7) || defined(_FM8) || defined(_FM77_VARIANTS) || defined(_FM77AV_VARIANTS)
-                       if(disk[0]->is_special_disk != SPECIAL_DISK_FM7_XANADU2_D) {
-                               val &= ~FDC_ST_BUSY;
-                       }
+                               if(disk[0]->is_special_disk != SPECIAL_DISK_FM7_XANADU2_D) {
+                                       val &= ~FDC_ST_BUSY;
+                               }
        #else                   
                                val &= ~FDC_ST_BUSY;
        #endif
@@ -417,6 +429,7 @@ uint32_t MB8877::read_io8(uint32_t addr)
                if(!(status & FDC_ST_BUSY)) {
                        set_irq(false);
                }
+
 #ifdef _FDC_DEBUG_LOG
                this->out_debug_log(_T("FDC\tSTATUS=%2x\n"), val);
 #endif
@@ -441,7 +454,12 @@ uint32_t MB8877::read_io8(uint32_t addr)
 #endif
        case 3:
                // data reg
-               if(motor_on && (status & FDC_ST_DRQ) && !now_search) {
+               _stat = ((status & FDC_ST_DRQ) && !now_search);
+               if(disk[drvreg]->is_special_disk != SPECIAL_DISK_FM7_RIGLAS) {
+                       _stat = (_stat && motor_on);
+               }
+               if(_stat) {
+               //if(motor_on && (status & FDC_ST_DRQ) && !now_search) {
                        if(cmdtype == FDC_CMD_RD_SEC || cmdtype == FDC_CMD_RD_MSEC) {
                                // read or multisector read
                                if(fdc[drvreg].index < disk[drvreg]->sector_size.sd) {
@@ -598,7 +616,6 @@ void MB8877::event_callback(int event_id, int err)
                }
                return;
        }
-       
        switch(event) {
        case EVENT_SEEK:
 #ifdef _FDC_DEBUG_LOG
@@ -754,6 +771,7 @@ void MB8877::event_callback(int event_id, int err)
 void MB8877::process_cmd()
 {
        set_irq(false);
+       set_drq(false);
        
 #ifdef HAS_MB89311
        // MB89311 mode commands
@@ -908,11 +926,22 @@ void MB8877::cmd_seek()
        cmdtype = FDC_CMD_TYPE1;
        status = FDC_ST_HEADENG | FDC_ST_BUSY;
        
-//     seektrk = (uint8_t)(fdc[drvreg].track + datareg - trkreg);
        seektrk = datareg;
-       seektrk = (seektrk > 83) ? 83 : (seektrk < 0) ? 0 : seektrk;
-       seekvct = !(datareg > trkreg);
-       
+       if(disk[drvreg]->media_type != MEDIA_TYPE_2D){
+               seektrk = (seektrk > 83) ? 83 : (seektrk < 0) ? 0 : seektrk;
+       } else {
+               seektrk = (seektrk > 41) ? 41 : (seektrk < 0) ? 0 : seektrk;
+       }               
+//     seekvct = !(datareg > trkreg);
+       seekvct = !(seektrk > fdc[drvreg].track);       
+       if(cmdreg & 4) {
+               // verify
+               if(trkreg != fdc[drvreg].track) {
+                       status |= FDC_ST_SEEKERR;
+                       trkreg = fdc[drvreg].track;
+               }
+       }
+       trkreg  = datareg;
        register_seek_event();
 }
 
@@ -933,9 +962,19 @@ void MB8877::cmd_stepin()
        status = FDC_ST_HEADENG | FDC_ST_BUSY;
        
        seektrk = fdc[drvreg].track + 1;
-       seektrk = (seektrk > 83) ? 83 : (seektrk < 0) ? 0 : seektrk;
+       if(disk[drvreg]->media_type != MEDIA_TYPE_2D){
+               seektrk = (seektrk > 83) ? 83 : (seektrk < 0) ? 0 : seektrk;
+       } else {
+               seektrk = (seektrk > 41) ? 41 : (seektrk < 0) ? 0 : seektrk;
+       }               
        seekvct = false;
-       
+       if(cmdreg & 4) {
+               // verify
+               if(trkreg != fdc[drvreg].track) {
+                       status |= FDC_ST_SEEKERR;
+                       //trkreg = fdc[drvreg].track;
+               }
+       }
        register_seek_event();
 }
 
@@ -946,9 +985,19 @@ void MB8877::cmd_stepout()
        status = FDC_ST_HEADENG | FDC_ST_BUSY;
        
        seektrk = fdc[drvreg].track - 1;
-       seektrk = (seektrk > 83) ? 83 : (seektrk < 0) ? 0 : seektrk;
+       if(disk[drvreg]->media_type != MEDIA_TYPE_2D){
+               seektrk = (seektrk > 83) ? 83 : (seektrk < 0) ? 0 : seektrk;
+       } else {
+               seektrk = (seektrk > 41) ? 41 : (seektrk < 0) ? 0 : seektrk;
+       }               
        seekvct = true;
-       
+       if(cmdreg & 4) {
+               // verify
+               if(trkreg != fdc[drvreg].track) {
+                       status |= FDC_ST_SEEKERR;
+                       //trkreg = fdc[drvreg].track;
+               }
+       }
        register_seek_event();
 }