From 7a10901dc644831e0ca43f3d04f62da9a10b630f Mon Sep 17 00:00:00 2001 From: beeanyew Date: Sun, 1 Aug 2021 09:39:27 +0200 Subject: [PATCH] Experimental Chip speed hax --- emulator.c | 10 +++++++--- m68kcpu.h | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/emulator.c b/emulator.c index 1c56018..dbcdbfb 100644 --- a/emulator.c +++ b/emulator.c @@ -39,6 +39,8 @@ #define KEY_POLL_INTERVAL_MSEC 5000 +unsigned int ovl; + int kb_hook_enabled = 0; int mouse_hook_enabled = 0; int cpu_emulation_running = 1; @@ -192,6 +194,7 @@ noppers: void *cpu_task() { m68ki_cpu_core *state = &m68ki_cpu; + state->ovl = ovl; m68k_pulse_reset(state); cpu_loop: @@ -417,9 +420,6 @@ void stop_cpu_emulation(uint8_t disasm_cur) { do_disasm = 0; } -unsigned int ovl; -static volatile unsigned char maprom; - void sigint_handler(int sig_num) { //if (sig_num) { } //cpu_emulation_running = 0; @@ -652,6 +652,7 @@ void cpu_pulse_reset(void) { ps_pulse_reset(); ovl = 1; + m68ki_cpu.ovl = 1; for (int i = 0; i < 8; i++) { ipl_enabled[i] = 0; } @@ -914,10 +915,12 @@ static inline int32_t platform_write_check(uint8_t type, uint32_t addr, uint32_t case 0xEFFFFE: // VIA1? if (val & 0x10 && !ovl) { ovl = 1; + m68ki_cpu.ovl = 1; printf("[MAC] OVL on.\n"); handle_ovl_mappings_mac68k(cfg); } else if (ovl) { ovl = 0; + m68ki_cpu.ovl = 0; printf("[MAC] OVL off.\n"); handle_ovl_mappings_mac68k(cfg); } @@ -932,6 +935,7 @@ static inline int32_t platform_write_check(uint8_t type, uint32_t addr, uint32_t case CIAAPRA: if (ovl != (val & (1 << 0))) { ovl = (val & (1 << 0)); + m68ki_cpu.ovl = ovl; printf("OVL:%x\n", ovl); } return 0; diff --git a/m68kcpu.h b/m68kcpu.h index 0b18502..c19f585 100644 --- a/m68kcpu.h +++ b/m68kcpu.h @@ -44,6 +44,7 @@ extern "C" { #include #include +#include "gpio/ps_protocol.h" /* ======================================================================== */ /* ==================== ARCHITECTURE-DEPENDANT DEFINES ==================== */ @@ -1053,6 +1054,8 @@ typedef struct m68ki_cpu_core /* address translation caches */ + uint32 ovl; + unsigned char read_ranges; unsigned int read_addr[8]; unsigned int read_upper[8]; @@ -1181,6 +1184,12 @@ static inline uint m68ki_read_imm_16(m68ki_cpu_core *state) REG_PC += 2; return be16toh(((unsigned short *)(cache->offset + pc))[0]); } + + if (!state->ovl && pc < 0x200000) { + REG_PC += 2; + return ps_read_16(pc); + } + return m68ki_read_imm16_addr_slowpath(state, pc, cache); } @@ -1284,6 +1293,10 @@ static inline uint m68ki_read_8_fc(m68ki_cpu_core *state, uint address, uint fc) } } + if (!state->ovl && address < 0x200000) { + return ps_read_8(address); + } + return m68k_read_memory_8(ADDRESS_68K(address)); } @@ -1314,6 +1327,10 @@ static inline uint m68ki_read_16_fc(m68ki_cpu_core *state, uint address, uint fc } } + if (!state->ovl && address < 0x200000) { + return ps_read_16(address); + } + return m68k_read_memory_16(ADDRESS_68K(address)); } @@ -1344,6 +1361,10 @@ static inline uint m68ki_read_32_fc(m68ki_cpu_core *state, uint address, uint fc } } + if (!state->ovl && address < 0x200000) { + return ps_read_32(address); + } + return m68k_read_memory_32(ADDRESS_68K(address)); } @@ -1375,6 +1396,11 @@ static inline void m68ki_write_8_fc(m68ki_cpu_core *state, uint address, uint fc } } + if (!state->ovl && address < 0x200000) { + ps_write_8(address, value); + return; + } + m68k_write_memory_8(ADDRESS_68K(address), value); } @@ -1407,6 +1433,11 @@ static inline void m68ki_write_16_fc(m68ki_cpu_core *state, uint address, uint f } } + if (!state->ovl && address < 0x200000) { + ps_write_16(address, value); + return; + } + m68k_write_memory_16(ADDRESS_68K(address), value); } @@ -1439,6 +1470,11 @@ static inline void m68ki_write_32_fc(m68ki_cpu_core *state, uint address, uint f } } + if (!state->ovl && address < 0x200000) { + ps_write_32(address, value); + return; + } + m68k_write_memory_32(ADDRESS_68K(address), value); }