OSDN Git Service

[VM][V30][I386] Adjust halt sequence.WIP.
authorK.Ohta <whatisthis.sowhat@gmail.com>
Fri, 11 Oct 2019 19:23:21 +0000 (04:23 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Fri, 11 Oct 2019 19:23:21 +0000 (04:23 +0900)
source/src/vm/mame/emu/cpu/i386/i386.c
source/src/vm/mame/emu/cpu/i86/v30.c

index 1b29134..40d88bc 100644 (file)
@@ -78,6 +78,8 @@ static void pentium_smi(i386_state* cpustate);
 
 static void cpu_reset_generic(i386_state* cpustate)
 {
+       int busreq = cpustate->busreq;
+       int haltreq = cpustate->haltreq;
        switch(cpustate->cpu_type) {
        case N_CPU_TYPE_I386:
                CPU_RESET_CALL( i386 );
@@ -110,6 +112,8 @@ static void cpu_reset_generic(i386_state* cpustate)
                CPU_RESET_CALL( i386 );
                break;
        }
+       cpustate->busreq = busreq;
+       cpustate->haltreq = haltreq;
 }
 
 
@@ -3621,8 +3625,8 @@ static void i386_set_irq_line(i386_state *cpustate,int irqline, int state)
 {
        int first_cycles = cpustate->cycles;
        if (cpustate->haltreq != 0) {
-               cpustate->extra_cycles += first_cycles - cpustate->cycles;
-               cpustate->cycles = first_cycles;
+//             cpustate->extra_cycles += first_cycles - cpustate->cycles;
+//             cpustate->cycles = first_cycles;
                return;
        }
        if (state != CLEAR_LINE && cpustate->halted)
@@ -3743,7 +3747,12 @@ static CPU_EXECUTE( i386 )
                if (cycles == -1) {
                        int passed_cycles = max(1, cpustate->extra_cycles);
                        // this is main cpu, cpustate->cycles is not used
-                       cpustate->cycles += passed_cycles;
+                       cpustate->cycles -= passed_cycles;
+                       /* if busreq is raised, spin cpu while remained clock */
+                       if (cpustate->cycles > 0) {
+                               cpustate->cycles = 0;
+                       }
+//                     cpustate->cycles = 0;
                        cpustate->base_cycles = cpustate->cycles;
 
                        /* adjust for any interrupts that came in */
@@ -3777,13 +3786,10 @@ static CPU_EXECUTE( i386 )
                        return passed_cycles;
                }
        }
-       int ncycles;
        if (cycles == -1) {
                cpustate->cycles = 1;
-               ncycles = 1;
        } else {
                cpustate->cycles += cycles;
-               ncycles = cycles;
        }
        cpustate->base_cycles = cpustate->cycles;
 
@@ -3812,7 +3818,7 @@ static CPU_EXECUTE( i386 )
                                cpustate->debugger->exception_happened = true;
                                exception_caused = false;
                                exception_code = 0;
-                               printf("EXCEPTION HIT PC=%08X CODE=%X\n", exception_pc, exception_code);
+                               //printf("EXCEPTION HIT PC=%08X CODE=%X\n", exception_pc, exception_code);
                        }
                        cpustate->debugger->check_break_points(cpustate->pc);
                        if(cpustate->debugger->now_suspended) {
index a6ffd29..b1f0662 100644 (file)
@@ -355,23 +355,21 @@ CPU_EXECUTE( v30 )
                                cpustate->io = cpustate->io_stored;
                        }
                }
+               int passed_icount;
                if (icount == -1) {
-                       int passed_icount = max(1, cpustate->extra_cycles);
+                       passed_icount = max(1, cpustate->extra_cycles);
                        // this is main cpu, cpustate->icount is not used
                        cpustate->icount += passed_icount;
                        cpustate->extra_cycles = 0;
-//#ifdef USE_DEBUGGER
                        cpustate->total_icount += passed_icount;
-//#endif
-                       cpu_wait_v30(cpustate, passed_icount);
-                       return passed_icount;
+//                     cpu_wait_v30(cpustate, passed_icount);
                } else {
+#if 0
                        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;
@@ -380,10 +378,25 @@ CPU_EXECUTE( v30 )
                        cpustate->total_icount += base_icount - cpustate->icount;
 //#endif
                        cpu_wait_v30(cpustate, base_icount - cpustate->icount);
-                       cpustate->extra_cycles = 0;
                        return base_icount - cpustate->icount;
+#else
+                       int passed_icount = 0;
+                       if(icount > 0) {
+                               passed_icount = icount;
+                       }
+                       if(cpustate->extra_cycles > 0) {
+                               passed_icount += cpustate->extra_cycles;
+                       }
+                       cpustate->icount = 0;
+                       cpustate->extra_cycles = 0;
+                       cpustate->total_icount += passed_icount;
+//#endif
+//                     cpu_wait_v30(cpustate, passed_icount);
+#endif
                }
+               return passed_icount;
        }
+       // Not HALTED
        if (icount == -1) {
                cpustate->icount = 1;
        } else {
@@ -482,9 +495,10 @@ CPU_EXECUTE( v30 )
                cpustate->total_icount += cpustate->icount;
 //#endif
                cpustate->icount = 0;
+               return base_icount;
        }
-       cpu_wait_v30(cpustate, base_icount - cpustate->icount);
        int passed_icount = base_icount - cpustate->icount;
+       cpu_wait_v30(cpustate, passed_icount);
        cpustate->icount = 0;
        return passed_icount;
 }