]> Shamusworld >> Repos - virtualjaguar/blobdiff - src/m68000/m68kinterface.c
Preparation for 2.1.0 release.
[virtualjaguar] / src / m68000 / m68kinterface.c
index c6e81021be9e833283dd4266d9f2dec4b4ed3ed7..bdaa0c4d7e2074774ab2616c6d6e6b6d56bbe472 100644 (file)
@@ -1,10 +1,10 @@
 //
 // m68kinterface.c: Code interface to the UAE 68000 core and support code
 //
-// by James L. Hammons
+// by James Hammons
 // (C) 2011 Underground Software
 //
-// JLH = James L. Hammons <jlhamm@acm.org>
+// JLH = James Hammons <jlhamm@acm.org>
 //
 // Who  When        What
 // ---  ----------  -------------------------------------------------------------
@@ -45,7 +45,7 @@ extern const struct cputbl op_smalltbl_4_ff[];        /* 68000 */
 extern const struct cputbl op_smalltbl_5_ff[]; /* 68000 slow but compatible.  */
 
 // Externs, supplied by the user...
-extern int irq_ack_handler(int);
+//extern int irq_ack_handler(int);
 
 // Function prototypes...
 STATIC_INLINE void m68ki_check_interrupts(void);
@@ -77,9 +77,13 @@ cpuop_func * cpuFunctionTable[65536];
 #endif
 
 #define CPU_DEBUG
+
+
 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;
@@ -101,10 +105,27 @@ void Dasm(uint32_t offset, uint32_t qt)
 }
 
 
+#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)
 {
 }
 
+
 // Pulse the RESET line on the CPU
 void m68k_pulse_reset(void)
 {
@@ -173,6 +194,7 @@ void m68k_pulse_reset(void)
 #endif
 }
 
+
 int m68k_execute(int num_cycles)
 {
 #if 0
@@ -261,6 +283,34 @@ 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)
@@ -297,6 +347,7 @@ if (inRoutine)
 #endif
 }
 
+
 /* ASG: rewrote so that the int_level is a mask of the IPL0/IPL1/IPL2 bits */
 void m68k_set_irq(unsigned int intLevel)
 {
@@ -323,6 +374,7 @@ void m68k_set_irq(unsigned int intLevel)
 #endif
 }
 
+
 // Check for interrupts
 STATIC_INLINE void m68ki_check_interrupts(void)
 {
@@ -335,6 +387,7 @@ STATIC_INLINE void m68ki_check_interrupts(void)
 #endif
 }
 
+
 // Service an interrupt request and start exception processing
 void m68ki_exception_interrupt(uint32_t intLevel)
 {
@@ -450,6 +503,7 @@ void m68ki_exception_interrupt(uint32_t intLevel)
 #endif
 }
 
+
 // Initiate exception processing
 STATIC_INLINE uint32_t m68ki_init_exception(void)
 {
@@ -473,6 +527,7 @@ STATIC_INLINE uint32_t m68ki_init_exception(void)
 #endif
 }
 
+
 // 3 word stack frame (68000 only)
 STATIC_INLINE void m68ki_stack_frame_3word(uint32_t pc, uint32_t sr)
 {
@@ -489,6 +544,7 @@ STATIC_INLINE void m68ki_stack_frame_3word(uint32_t pc, uint32_t sr)
 #endif
 }
 
+
 unsigned int m68k_get_reg(void * context, m68k_register_t reg)
 {
        if (reg <= M68K_REG_A7)
@@ -506,6 +562,7 @@ unsigned int m68k_get_reg(void * context, m68k_register_t reg)
        return 0;
 }
 
+
 void m68k_set_reg(m68k_register_t reg, unsigned int value)
 {
        if (reg <= M68K_REG_A7)
@@ -521,6 +578,7 @@ void m68k_set_reg(m68k_register_t reg, unsigned int value)
                regs.regs[15] = value;
 }
 
+
 //
 // Check if the instruction is a valid one
 //
@@ -534,6 +592,7 @@ unsigned int m68k_is_valid_instruction(unsigned int instruction, unsigned int cp
        return 1;
 }
 
+
 // Dummy functions, for now, until we prove the concept here. :-)
 
 // Temp, while we're using the Musashi disassembler...
@@ -549,6 +608,7 @@ int m68k_cycles_remaining(void) {}        /* Number of cycles left */
 void m68k_modify_timeslice(int cycles) {} /* Modify cycles left */
 //void m68k_end_timeslice(void) {}          /* End timeslice now */
 
+
 void m68k_end_timeslice(void)
 {
 #if 0