]> Shamusworld >> Repos - virtualjaguar/blobdiff - src/m68000/m68kinterface.c
2.0.2 release.
[virtualjaguar] / src / m68000 / m68kinterface.c
index 5292ca56fee82b9d31e45ca80be2cecce807cddb..132a91aa1fe708b5bf69e04bf5c0c00ea8280d41 100644 (file)
@@ -49,9 +49,9 @@ extern int irq_ack_handler(int);
 
 // Function prototypes...
 STATIC_INLINE void m68ki_check_interrupts(void);
-void m68ki_exception_interrupt(uint intLevel);
+void m68ki_exception_interrupt(uint32_t intLevel);
 STATIC_INLINE uint32_t m68ki_init_exception(void);
-STATIC_INLINE void m68ki_stack_frame_3word(uint pc, uint sr);
+STATIC_INLINE void m68ki_stack_frame_3word(uint32_t pc, uint32_t sr);
 unsigned long IllegalOpcode(uint32_t opcode);
 void BuildCPUFunctionTable(void);
 
@@ -80,6 +80,8 @@ cpuop_func * cpuFunctionTable[65536];
 void Dasm(uint32_t offset, uint32_t qt)
 {
 #ifdef CPU_DEBUG
+// back up a few instructions...
+//offset -= 100;
        static char buffer[2048];//, mem[64];
        int pc = offset, oldpc;
        uint32_t i;
@@ -100,6 +102,21 @@ void Dasm(uint32_t offset, uint32_t qt)
 #endif
 }
 
+#ifdef CPU_DEBUG
+void DumpRegisters(void)
+{
+       uint32_t i;
+
+       for(i=0; i<16; i++)
+       {
+               printf("%s%i: %08X ", (i < 8 ? "D" : "A"), i & 0x7, regs.regs[i]);
+
+               if ((i & 0x03) == 3)
+                       printf("\n");
+       }
+}
+#endif
+
 
 void m68k_set_cpu_type(unsigned int type)
 {
@@ -108,7 +125,7 @@ void m68k_set_cpu_type(unsigned int type)
 // Pulse the RESET line on the CPU
 void m68k_pulse_reset(void)
 {
-       static uint emulation_initialized = 0;
+       static uint32_t emulation_initialized = 0;
 
        // The first call to this function initializes the opcode handler jump table
        if (!emulation_initialized)
@@ -261,8 +278,40 @@ else if (regs.pc == 0x803422)
 
 if (inRoutine)
        instSeen++;
+#endif
+// AvP testing... (problem was: 32 bit addresses on 24 bit address cpu--FIXED)
+#if 0
+       static int go = 0;
+
+       if (regs.pc == 0x94BA)
+       {
+               go = 1;
+               printf("\n");
+       }
+
+       if (regs.pc == 0x94C6)
+               go = 0;
+
+//     if (regs.regs[10] == 0xFFFFFFFF && go)
+       if (go)
+       {
+//             printf("A2=-1, PC=%08X\n", regs.pc);
+//             go = 0;
+//             Dasm(regs.pc, 130);
+               Dasm(regs.pc, 1);
+               DumpRegisters();
+       }
+//94BA: 2468 0000                MOVEA.L       (A0,$0000) == $0002328A, A2
+//94BE: 200A                     MOVE.L        A2, D0
+//94C0: 6A02                     BPL.B $94C4
+//94C2: 2452                     MOVEA.L       (A2), A2                        ; <--- HERE
+//94C4: 4283                     CLR.L D3
 #endif
                uint32_t opcode = get_iword(0);
+//if ((opcode & 0xFFF8) == 0x31C0)
+//{
+//     printf("MOVE.W D%i, EA\n", opcode & 0x07);
+//}
                int32_t cycles = (int32_t)(*cpuFunctionTable[opcode])(opcode);
                regs.remainingCycles -= cycles;
 //printf("Executed opcode $%04X (%i cycles)...\n", opcode, cycles);
@@ -332,7 +381,7 @@ STATIC_INLINE void m68ki_check_interrupts(void)
 }
 
 // Service an interrupt request and start exception processing
-void m68ki_exception_interrupt(uint intLevel)
+void m68ki_exception_interrupt(uint32_t intLevel)
 {
 #if 0
        uint vector;
@@ -588,11 +637,14 @@ void BuildCPUFunctionTable(void)
        unsigned long opcode;
 
        // We're only using the "fast" 68000 emulation here, not the "compatible"
+       // ("fast" doesn't throw exceptions, so we're using "compatible" now :-P)
 #if 0
        const struct cputbl * tbl = (currprefs.cpu_compatible
                ? op_smalltbl_5_ff : op_smalltbl_4_ff);
 #else
-       const struct cputbl * tbl = op_smalltbl_4_ff;
+//let's try "compatible" and see what happens here...
+//     const struct cputbl * tbl = op_smalltbl_4_ff;
+       const struct cputbl * tbl = op_smalltbl_5_ff;
 #endif
 
 //     Log_Printf(LOG_DEBUG, "Building CPU function table (%d %d %d).\n",