From 902f4c4aa89896d9e8a2ba6f4099449c0ccab596 Mon Sep 17 00:00:00 2001 From: beeanyew Date: Sat, 20 Feb 2021 08:33:40 +0100 Subject: [PATCH] Update m68kconf.h, m68kcpu.c, and m68kcpu.h --- m68kconf.h | 2 +- m68kcpu.c | 18 ++++++++++++++++++ m68kcpu.h | 1 - 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/m68kconf.h b/m68kconf.h index bcfcb13..71c42c2 100644 --- a/m68kconf.h +++ b/m68kconf.h @@ -166,7 +166,7 @@ /* If ON, the CPU will emulate the 4-byte prefetch queue of a real 68000 */ -#define M68K_EMULATE_PREFETCH OPT_OFF +#define M68K_EMULATE_PREFETCH OPT_ON /* If ON, the CPU will generate address error exceptions if it tries to diff --git a/m68kcpu.c b/m68kcpu.c index ecdf4dd..f4d3f2c 100644 --- a/m68kcpu.c +++ b/m68kcpu.c @@ -976,7 +976,9 @@ int m68k_execute(int num_cycles) /* Main loop. Keep going until we run out of clock cycles */ do { +#ifdef M68K_BUSERR_THING int i; +#endif /* Set tracing accodring to T1. (T0 is done inside instruction) */ m68ki_trace_t1(); /* auto-disable (see m68kcpu.h) */ @@ -1175,9 +1177,25 @@ void m68k_set_context(void* src) /* Read data immediately following the PC */ inline unsigned int m68k_read_immediate_16(unsigned int address) { +#ifndef M68K_EMULATE_PREFETCH + for (int i = 0; i < read_ranges; i++) { + if(address >= read_addr[i] && address < read_upper[i]) { + return be16toh(((unsigned short *)(read_data[i] + (address - read_addr[i])))[0]); + } + } +#endif + return m68k_read_memory_16(address); } inline unsigned int m68k_read_immediate_32(unsigned int address) { +#ifndef M68K_EMULATE_PREFETCH + for (int i = 0; i < read_ranges; i++) { + if(address >= read_addr[i] && address < read_upper[i]) { + return be32toh(((unsigned int *)(read_data[i] + (address - read_addr[i])))[0]); + } + } +#endif + return m68k_read_memory_32(address); } diff --git a/m68kcpu.h b/m68kcpu.h index e1035c1..ab47308 100644 --- a/m68kcpu.h +++ b/m68kcpu.h @@ -1107,7 +1107,6 @@ static inline uint m68ki_read_imm_32(void) #if M68K_EMULATE_PREFETCH uint temp_val; - uint32_t address = ADDRESS_68K(CPU_PREF_ADDR); m68ki_set_fc(FLAG_S | FUNCTION_CODE_USER_PROGRAM); /* auto-disable (see m68kcpu.h) */ m68ki_check_address_error(REG_PC, MODE_READ, FLAG_S | FUNCTION_CODE_USER_PROGRAM); /* auto-disable (see m68kcpu.h) */ -- 2.39.2