From: Rune Holm Date: Sun, 20 Jun 2021 16:22:03 +0000 (+0200) Subject: introducing CPU state parameter X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=14636790c638a4c24fd31054b35228a9138e98a9;p=pistorm introducing CPU state parameter --- diff --git a/emulator.c b/emulator.c index 8bf7855..8ecc8f8 100644 --- a/emulator.c +++ b/emulator.c @@ -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 ca91b14..bb8e686 100644 --- 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. diff --git a/m68k_in.c b/m68k_in.c index cb5190e..9b400a0 100644 --- 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; } diff --git a/m68kcpu.c b/m68kcpu.c index fb66609..d30ad93 100644 --- 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); } } diff --git a/m68kcpu.h b/m68kcpu.h index e93c3d4..cd4d07e 100644 --- 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++) {