OSDN Git Service

[VM][JX][MZ2800] Fix FTBFS with I8088.
authorK.Ohta <whatisthis.sowhat@gmail.com>
Mon, 2 Mar 2020 12:17:51 +0000 (21:17 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Mon, 2 Mar 2020 12:17:51 +0000 (21:17 +0900)
[VM][MZ6550] Fix FTBFS.

source/src/vm/event.cpp
source/src/vm/i86.cpp
source/src/vm/jx/CMakeLists.txt
source/src/vm/jx/i86.cpp
source/src/vm/jx/i86.h
source/src/vm/jx/jx.cpp
source/src/vm/jx/jx.h
source/src/vm/mame/emu/cpu/i86/i86.c
source/src/vm/mz2800/mz2800.cpp
source/src/vm/mz2800/mz2800.h
source/src/vm/mz5500/mz5500.h

index 9e05bd4..cd0ab8d 100644 (file)
 #endif
 
 #if defined(USE_CPU_I286)
-#if defined(_JX)
-#include "jx/i286.h"
-#else
 #include "i286.h"
 #endif
-#endif
 
 #if defined(USE_CPU_I386) || defined(USE_CPU_I486) || defined(USE_CPU_PENTIUM)
 #include "i386.h"
index 4c6d06f..aa87856 100644 (file)
@@ -204,7 +204,7 @@ int I86::run(int icount)
        case INTEL_8086:
                return CPU_EXECUTE_CALL(i8086);
        case INTEL_8088:
-               return CPU_EXECUTE_CALL(i8086);
+               return CPU_EXECUTE_CALL(i8088);
        case INTEL_80186:
                return CPU_EXECUTE_CALL(i80186);
        case NEC_V30:
index d0729bb..de91721 100644 (file)
@@ -8,7 +8,7 @@ set(BASIC_VM_FILES
           floppy.cpp
           keyboard.cpp
           speaker.cpp
-          
+          ./i86.cpp
           )
 
 add_library(vm_jx  ${BASIC_VM_FILES})
index affc91f..2df255a 100644 (file)
@@ -8,13 +8,13 @@
        [ i86 ]
 */
 
-#include "i86.h"
+#include "./i86.h"
 #ifdef USE_DEBUGGER
 #include "../debugger.h"
 #include "../i386_dasm.h"
 //#include "../v30_dasm.h"
 #endif
-
+namespace JX {
 /* ----------------------------------------------------------------------------
        MAME i286
 ---------------------------------------------------------------------------- */
@@ -195,7 +195,7 @@ int I86::run(int icount)
        if(cpustate->pc == 0xff17d) cpustate->pc = 0xff18f;
 #endif
 #ifdef KEYBOARD_HACK
-       if(cpustate->pc == 0xfa909) { cpustate->regs.b[BH] = read_port_byte(0xa1); cpustate->pc = 0xfa97c; }
+       if(cpustate->pc == 0xfa909) { cpustate->regs.b[BH] = read_port_byte(cpustate, 0xa1); cpustate->pc = 0xfa97c; }
        if(cpustate->pc == 0xff6e1) { cpustate->regs.b[AL] = 0x0d; cpustate->pc += 2; }
 #endif
 #endif
@@ -486,3 +486,4 @@ bool I86::process_state(FILEIO* state_fio, bool loading)
        return true;
 }
 
+}
index a2dc1aa..aa39a5d 100644 (file)
@@ -21,6 +21,7 @@
 class DEBUGGER;
 #endif
 
+namespace JX {
 //enum {
 //     INTEL_8086 = 0,
 //     INTEL_8088,
@@ -135,5 +136,5 @@ public:
 #endif
 //     int device_model;
 };
-
+}
 #endif
index 03f70d3..3ae6bc9 100644 (file)
@@ -18,7 +18,7 @@
 #include "../i8253.h"
 #include "../i8255.h"
 #include "../i8259.h"
-#include "../i86.h"
+#include "./i86.h"
 #include "../io.h"
 #include "../memory.h"
 #include "../noise.h"
@@ -35,7 +35,7 @@
 #include "keyboard.h"
 #include "speaker.h"
 
-using JX::I286;
+using JX::I86;
 using JX::DISPLAY;
 using JX::FLOPPY;
 using JX::KEYBOARD;
index 6fee825..a429f8e 100644 (file)
@@ -65,7 +65,6 @@ class I8251;
 class I8253;
 class I8255;
 class I8259;
-class I86;
 class IO;
 class MEMORY;
 class PCM1BIT;
@@ -73,6 +72,7 @@ class SN76489AN;
 class UPD765A;
 
 namespace JX {
+       class I86;
        class DISPLAY;
        class FLOPPY;
        class KEYBOARD;
@@ -91,7 +91,7 @@ protected:
        I8253* pit;
        I8255* pio;
        I8259* pic;
-       I86* cpu;
+       JX::I86* cpu;
        IO* io;
        MEMORY* mem;
        PCM1BIT* pcm;
index 10b215e..91dc4af 100644 (file)
@@ -485,6 +485,183 @@ CPU_EXECUTE( i8086 )
        return passed_icount;
 }
 
+CPU_EXECUTE( i8088 )
+{
+       if (cpustate->halted || cpustate->busreq || cpustate->haltreq)
+       {
+//#ifdef SINGLE_MODE_DMA
+               if(!cpustate->haltreq) {
+                       if(cpustate->dma != NULL) {
+                               cpustate->dma->do_dma();
+                       }
+               }
+//#endif
+               bool now_debugging = false;
+               if(cpustate->debugger != NULL) {
+                       now_debugging = cpustate->debugger->now_debugging;
+               }
+               if(now_debugging) {
+                       cpustate->debugger->check_break_points(cpustate->pc);
+                       if(cpustate->debugger->now_suspended) {
+                               cpustate->debugger->now_waiting = true;
+                               cpustate->emu->start_waiting_in_debugger();
+                               while(cpustate->debugger->now_debugging && cpustate->debugger->now_suspended) {
+                                       cpustate->emu->process_waiting_in_debugger();
+                               }
+                               cpustate->emu->finish_waiting_in_debugger();
+                               cpustate->debugger->now_waiting = false;
+                       }
+                       if(cpustate->debugger->now_debugging) {
+                               cpustate->program = cpustate->io = cpustate->debugger;
+                       } else {
+                               now_debugging = false;
+                       }
+                       if(now_debugging) {
+                               if(!cpustate->debugger->now_going) {
+                                       cpustate->debugger->now_suspended = true;
+                               }
+                               cpustate->program = cpustate->program_stored;
+                               cpustate->io = cpustate->io_stored;
+                       }
+               }
+               if (icount == -1) {
+                       int passed_icount = max(1, cpustate->extra_cycles);
+                       // this is main cpu, cpustate->icount is not used
+                       /*cpustate->icount = */cpustate->extra_cycles = 0;
+//#ifdef USE_DEBUGGER
+                       cpustate->total_icount += passed_icount;
+//#endif
+                       cpu_wait_i86(cpustate, passed_icount);
+                       return passed_icount;
+               } else {
+                       cpustate->icount += icount;
+                       int base_icount = cpustate->icount;
+
+                       /* adjust for any interrupts that came in */
+                       cpustate->icount -= cpustate->extra_cycles;
+                       cpustate->extra_cycles = 0;
+
+                       /* if busreq is raised, spin cpu while remained clock */
+                       if (cpustate->icount > 0) {
+                               cpustate->icount = 0;
+                       }
+//#ifdef USE_DEBUGGER
+                       cpustate->total_icount += base_icount - cpustate->icount;
+//#endif
+                       cpu_wait_i86(cpustate, base_icount - cpustate->icount);
+                       int passed_icount = base_icount - cpustate->icount;
+                       cpustate->icount = 0;
+                       return passed_icount;
+               }
+       }
+
+       if (icount == -1) {
+               cpustate->icount = 1;
+       } else {
+               cpustate->icount += icount;
+       }
+       int base_icount = cpustate->icount;
+
+       /* copy over the cycle counts if they're not correct */
+       if (timing.id != 8086)
+               timing = i8086_cycles;
+
+       /* adjust for any interrupts that came in */
+//#ifdef USE_DEBUGGER
+       cpustate->total_icount += cpustate->extra_cycles;
+//#endif
+       cpustate->icount -= cpustate->extra_cycles;
+       cpustate->extra_cycles = 0;
+
+       /* run until we're out */
+       while (cpustate->icount > 0 && !cpustate->busreq && !cpustate->haltreq)
+       {
+//#ifdef USE_DEBUGGER
+               bool now_debugging = false;
+               if(cpustate->debugger != NULL) {
+                       now_debugging = cpustate->debugger->now_debugging;
+               }
+               if(now_debugging) {
+                       cpustate->debugger->check_break_points(cpustate->pc);
+                       if(cpustate->debugger->now_suspended) {
+                               cpustate->debugger->now_waiting = true;
+                               cpustate->emu->start_waiting_in_debugger();
+                               while(cpustate->debugger->now_debugging && cpustate->debugger->now_suspended) {
+                                       cpustate->emu->process_waiting_in_debugger();
+                               }
+                               cpustate->emu->finish_waiting_in_debugger();
+                               cpustate->debugger->now_waiting = false;
+                       }
+                       if(cpustate->debugger->now_debugging) {
+                               cpustate->program = cpustate->io = cpustate->debugger;
+                       } else {
+                               now_debugging = false;
+                       }
+                       cpustate->debugger->add_cpu_trace(cpustate->pc);
+                       int first_icount = cpustate->icount;
+                       cpustate->seg_prefix = FALSE;
+                       cpustate->prevpc = cpustate->pc;
+                       cpustate->MF = 1; /* bit15 in flags is always 1 */
+                       TABLE86;
+                       cpustate->total_icount += first_icount - cpustate->icount;
+//#ifdef SINGLE_MODE_DMA
+                       if(!cpustate->haltreq) {
+                               if(cpustate->dma != NULL) {
+                                       cpustate->dma->do_dma();
+                               }
+                       }
+//#endif
+                       if(now_debugging) {
+                               if(!cpustate->debugger->now_going) {
+                                       cpustate->debugger->now_suspended = true;
+                               }
+                               cpustate->program = cpustate->program_stored;
+                               cpustate->io = cpustate->io_stored;
+                       }
+               } else {
+                       if(cpustate->debugger != NULL) {
+                               cpustate->debugger->add_cpu_trace(cpustate->pc);
+                       }
+                       int first_icount = cpustate->icount;
+//#endif
+                       cpustate->seg_prefix = FALSE;
+                       cpustate->prevpc = cpustate->pc;
+                       cpustate->MF = 1; /* bit15 in flags is always 1 */
+                       TABLE86;
+//#ifdef USE_DEBUGGER
+                       cpustate->total_icount += first_icount - cpustate->icount;
+//#endif
+//#ifdef SINGLE_MODE_DMA
+                       if(!cpustate->haltreq) {
+                               if(cpustate->dma != NULL) {
+                                       cpustate->dma->do_dma();
+                               }
+                       }
+//#endif
+//#ifdef USE_DEBUGGER
+               }
+//#endif
+               /* adjust for any interrupts that came in */
+//#ifdef USE_DEBUGGER
+               cpustate->total_icount += cpustate->extra_cycles;
+//#endif
+               cpustate->icount -= cpustate->extra_cycles;
+               cpustate->extra_cycles = 0;
+       }
+
+       /* if busreq is raised, spin cpu while remained clock */
+       if (cpustate->icount > 0 && (cpustate->busreq || cpustate->haltreq)) {
+//#ifdef USE_DEBUGGER
+               cpustate->total_icount += cpustate->icount;
+//#endif
+               cpustate->icount = 0;
+       }
+       cpu_wait_i86(cpustate, base_icount - cpustate->icount);
+       int passed_icount = base_icount - cpustate->icount;
+       cpustate->icount = 0;
+       return passed_icount;
+}
+
 #include "i86.h"
 
 #undef PREFIX
index 4ea63b4..65389ce 100644 (file)
@@ -74,7 +74,7 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu)
        event = new EVENT(this, emu);   // must be 2nd device
        dummy->set_device_name(_T("1st Dummy"));
 
-       cpu = new I80286(this, emu);
+       cpu = new I286(this, emu);
        pit = new I8253(this, emu);
        pio0 = new I8255(this, emu);
        pic = new I8259(this, emu);
index 96db6ae..1892706 100644 (file)
@@ -61,7 +61,7 @@ class EVENT;
 class I8253;
 class I8255;
 class I8259;
-class I80286;
+class I286;
 class IO;
 class MB8877;
 class NOT;
@@ -100,7 +100,7 @@ protected:
        I8253* pit;
        I8255* pio0;
        I8259* pic;
-       I80286* cpu;
+       I286* cpu;
        IO* io;
        MB8877* fdc;
        NOT* not_busy;
index a733da8..43b5012 100644 (file)
@@ -115,7 +115,7 @@ protected:
        I8237* dma;
        I8255* pio;
        I8259* pic;     // includes 2chips
-#if defined(HAS_I286)
+#if defined(_MZ6550)
        I286* cpu;
 #else
        I86* cpu;