]> git.sesse.net Git - pistorm/commitdiff
introducing CPU state parameter
authorRune Holm <rune.holm@gmail.com>
Sun, 20 Jun 2021 16:22:03 +0000 (18:22 +0200)
committerRune Holm <rune.holm@gmail.com>
Sun, 20 Jun 2021 19:54:05 +0000 (21:54 +0200)
emulator.c
m68k.h
m68k_in.c
m68kcpu.c
m68kcpu.h

index 8bf785588fed9cd8b153bd3b86035891afa71658..8ecc8f8c777bc313dd5e917db8371e7e8d836fff 100644 (file)
@@ -181,7 +181,8 @@ void *ipl_task(void *args) {
 }
 
 void *cpu_task() {
-  m68k_pulse_reset();
+       m68ki_cpu_core *state = &m68ki_cpu;
+       m68k_pulse_reset(state);
 
 cpu_loop:
   if (mouse_hook_enabled) {
@@ -197,14 +198,14 @@ cpu_loop:
     printf("%.8X (%.8X)]] %s\n", m68k_get_reg(NULL, M68K_REG_PC), (m68k_get_reg(NULL, M68K_REG_PC) & 0xFFFFFF), disasm_buf);
     if (do_disasm)
       do_disasm--;
-    m68k_execute(1);
+         m68k_execute(state, 1);
   }
   else {
     if (cpu_emulation_running) {
-      if (irq)
-        m68k_execute(5);
-      else
-        m68k_execute(loop_cycles);
+               if (irq)
+                       m68k_execute(state, 5);
+               else
+                       m68k_execute(state, loop_cycles);
     }
   }
 
@@ -626,6 +627,7 @@ switch_config:
 }
 
 void cpu_pulse_reset(void) {
+       m68ki_cpu_core *state = &m68ki_cpu;
   ps_pulse_reset();
   if (cfg->platform->handle_reset)
     cfg->platform->handle_reset(cfg);
@@ -635,7 +637,7 @@ void cpu_pulse_reset(void) {
   //m68k_write_memory_8(0xbfe201, 0x0001);  // AMIGA OVL
   //m68k_write_memory_8(0xbfe001, 0x0001);  // AMIGA OVL high (ROM@0x0)
 
-  m68k_pulse_reset();
+       m68k_pulse_reset(state);
 }
 
 int cpu_irq_ack(int level) {
diff --git a/m68k.h b/m68k.h
index ca91b14cb48d33d5e0468b8dea38cbf6ae3c63a5..bb8e68614bdd874426998eeea9977f558d8b05b5 100644 (file)
--- a/m68k.h
+++ b/m68k.h
@@ -52,6 +52,7 @@ extern "C" {
 #include MUSASHI_CNF
 #else
 #include "m68kconf.h"
+
 #endif
 
 /* ======================================================================== */
@@ -93,6 +94,7 @@ extern "C" {
  */
 #define M68K_INT_ACK_SPURIOUS      0xfffffffe
 
+struct m68ki_cpu_core;
 
 /* CPU types for use in m68k_set_cpu_type() */
 enum
@@ -327,10 +329,10 @@ void m68k_init(void);
  *       the CPU for the first time, the CPU will be set to
  *       M68K_CPU_TYPE_68000.
  */
-void m68k_pulse_reset(void);
+void m68k_pulse_reset(struct m68ki_cpu_core *state);
 
 /* execute num_cycles worth of instructions.  returns number of cycles used */
-int m68k_execute(int num_cycles);
+int m68k_execute(struct m68ki_cpu_core *state, int num_cycles);
 
 /* These functions let you read/write/modify the number of cycles left to run
  * while m68k_execute() is running.
index cb5190e4a06255a38d733120b7796d767cbd29ec..9b400a0ead4ea48903e0d8b9877dbe7a3779a1f7 100644 (file)
--- a/m68k_in.c
+++ b/m68k_in.c
@@ -7040,7 +7040,7 @@ M68KMAKE_OP(movec, 32, rc, .)
                                        }
 
                                        if (REG_CACR & (M68K_CACR_CI | M68K_CACR_CEI)) {
-                                               m68ki_ic_clear();
+                                               m68ki_ic_clear(state);
                                        }
                                        return;
                                }
index fb666093618135572d4ddcc914343e5e6bddd0b5..d30ad93c1341ae124b1c09771036170dae161ac1 100644 (file)
--- a/m68kcpu.c
+++ b/m68kcpu.c
@@ -958,7 +958,7 @@ uint m68k_get_address_mask() {
 
 /* Execute some instructions until we use up num_cycles clock cycles */
 /* ASG: removed per-instruction interrupt checks */
-int m68k_execute(int num_cycles)
+int m68k_execute(m68ki_cpu_core *state, int num_cycles)
 {
        /* eat up any reset cycles */
        if (RESET_CYCLES) {
@@ -1121,7 +1121,7 @@ void m68k_pulse_bus_error(void)
 }
 
 /* Pulse the RESET line on the CPU */
-void m68k_pulse_reset(void)
+void m68k_pulse_reset(m68ki_cpu_core *state)
 {
        /* Disable the PMMU/HMMU on reset, if any */
        m68ki_cpu.pmmu_enabled = 0;
@@ -1172,7 +1172,7 @@ void m68k_pulse_reset(void)
        if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE))
        {
                // clear instruction cache
-               m68ki_ic_clear();
+               m68ki_ic_clear(state);
        }
 }
 
index e93c3d4a04703f259e3dea05f8901ddcb0c3610a..cd4d07e251eca18f79a1d946313bdc0d4e8bfa3c 100644 (file)
--- a/m68kcpu.h
+++ b/m68kcpu.h
@@ -1099,7 +1099,7 @@ char* m68ki_disassemble_quick(unsigned int pc, unsigned int cpu_type);
 /* ---------------------------- Read Immediate ---------------------------- */
 
 // clear the instruction cache
-inline void m68ki_ic_clear()
+inline void m68ki_ic_clear(m68ki_cpu_core *state)
 {
        int i;
        for (i=0; i< M68K_IC_SIZE; i++) {