From: kub Date: Mon, 24 May 2021 21:10:03 +0000 (+0200) Subject: 68k, synchronize timing in fame and musashi (for debugging) X-Git-Tag: v2.00~521 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5e04c2f37fc7b19662ae426493a9efdd639d7093;p=picodrive.git 68k, synchronize timing in fame and musashi (for debugging) --- diff --git a/cpu/fame/famec_opcodes.h b/cpu/fame/famec_opcodes.h index d43a563a..ffb7c4ed 100644 --- a/cpu/fame/famec_opcodes.h +++ b/cpu/fame/famec_opcodes.h @@ -19318,6 +19318,7 @@ OPCODE(0x4E73) AREG(7) = ASP; ASP = res; } + CHECK_BRANCH_EXCEPTION(res) POST_IO ctx->execinfo &= ~(FM68K_EMULATE_GROUP_0|FM68K_EMULATE_TRACE|FM68K_DO_TRACE); CHECK_INT_TO_JUMP(20) diff --git a/cpu/musashi/m68k_in.c b/cpu/musashi/m68k_in.c index d1756a53..14c1347d 100644 --- a/cpu/musashi/m68k_in.c +++ b/cpu/musashi/m68k_in.c @@ -389,7 +389,7 @@ addi 32 . . 0000011010...... A+-DXWL... U U U U 20 20 4 4 addq 8 . d 0101...000000... .......... U U U U 4 4 2 2 addq 8 . . 0101...000...... A+-DXWL... U U U U 8 8 4 4 addq 16 . d 0101...001000... .......... U U U U 4 4 2 2 -addq 16 . a 0101...001001... .......... U U U U 4 4 2 2 +addq 16 . a 0101...001001... .......... U U U U 8 8 2 2 addq 16 . . 0101...001...... A+-DXWL... U U U U 8 8 4 4 addq 32 . d 0101...010000... .......... U U U U 8 8 2 2 addq 32 . a 0101...010001... .......... U U U U 8 8 2 2 diff --git a/cpu/musashi/m68kcpu.c b/cpu/musashi/m68kcpu.c index 38469f32..d729f2cf 100644 --- a/cpu/musashi/m68kcpu.c +++ b/cpu/musashi/m68kcpu.c @@ -43,7 +43,7 @@ extern void m68040_fpu_op1(void); /* ================================= DATA ================================= */ /* ======================================================================== */ -int m68ki_initial_cycles; +//int m68ki_initial_cycles; //int m68ki_remaining_cycles = 0; /* Number of clocks remaining */ uint m68ki_tracing = 0; uint m68ki_address_space; @@ -828,6 +828,10 @@ int m68k_execute(int num_cycles) m68ki_instruction_jump_table[REG_IR](); USE_CYCLES(CYC_INSTRUCTION[REG_IR]); // moving this up may cause a deadlock + /* ASG: update cycles */ + USE_CYCLES(CPU_INT_CYCLES); + CPU_INT_CYCLES = 0; + /* Trace m68k_exception, if necessary */ m68ki_exception_if_trace(); /* auto-disable (see m68kcpu.h) */ @@ -839,10 +843,6 @@ int m68k_execute(int num_cycles) /* set previous PC to current PC for the next entry into the loop */ REG_PPC = REG_PC; - /* ASG: update cycles */ - USE_CYCLES(CPU_INT_CYCLES); - CPU_INT_CYCLES = 0; - /* return how many clocks we used */ return m68ki_initial_cycles - GET_CYCLES(); } diff --git a/cpu/musashi/m68kcpu.h b/cpu/musashi/m68kcpu.h index 5eee2b21..6ab0ba0b 100644 --- a/cpu/musashi/m68kcpu.h +++ b/cpu/musashi/m68kcpu.h @@ -916,6 +916,7 @@ typedef struct void (*instr_hook_callback)(void); /* Called every instruction cycle prior to execution */ // notaz + sint cyc_initial_cycles; sint cyc_remaining_cycles; sint not_polling; } m68ki_cpu_core; @@ -923,6 +924,7 @@ typedef struct // notaz extern m68ki_cpu_core *m68ki_cpu_p; #define m68ki_cpu (*m68ki_cpu_p) +#define m68ki_initial_cycles m68ki_cpu_p->cyc_initial_cycles #define m68ki_remaining_cycles m68ki_cpu_p->cyc_remaining_cycles diff --git a/cpu/musashi/m68kmake.c b/cpu/musashi/m68kmake.c index a544a5c2..6dd57fca 100644 --- a/cpu/musashi/m68kmake.c +++ b/cpu/musashi/m68kmake.c @@ -641,6 +641,9 @@ int get_oper_cycles(opcode_struct* op, int ea_mode, int cpu_type) strcmp(op->name, "suba") == 0)) return op->cycles[cpu_type] + g_ea_cycle_table[ea_mode][cpu_type][size] + 2; + if(cpu_type == CPU_TYPE_000 && ea_mode == EA_MODE_I && op->size == 8 && strcmp(op->name, "btst") == 0) + return op->cycles[cpu_type] + g_ea_cycle_table[ea_mode][cpu_type][size] + 2; + if(strcmp(op->name, "jmp") == 0) return op->cycles[cpu_type] + g_jmp_cycle_table[ea_mode]; if(strcmp(op->name, "jsr") == 0) diff --git a/pico/pico_int.h b/pico/pico_int.h index 6a393fbf..f34320ea 100644 --- a/pico/pico_int.h +++ b/pico/pico_int.h @@ -102,16 +102,16 @@ extern m68ki_cpu_core PicoCpuMM68k, PicoCpuMS68k; #define SekSr m68k_get_reg(&PicoCpuMM68k, M68K_REG_SR) #define SekSrS68k m68k_get_reg(&PicoCpuMS68k, M68K_REG_SR) #define SekSetStop(x) { \ - if(x) { SET_CYCLES(0); PicoCpuMM68k.stopped=STOP_LEVEL_STOP; } \ + if(x) { PicoCpuMM68k.cyc_remaining_cycles = 0; PicoCpuMM68k.stopped=STOP_LEVEL_STOP; } \ else PicoCpuMM68k.stopped=0; \ } #define SekSetStopS68k(x) { \ - if(x) { SET_CYCLES(0); PicoCpuMS68k.stopped=STOP_LEVEL_STOP; } \ + if(x) { PicoCpuMS68k.cyc_remaining_cycles = 0; PicoCpuMS68k.stopped=STOP_LEVEL_STOP; } \ else PicoCpuMS68k.stopped=0; \ } #define SekIsStoppedM68k() (PicoCpuMM68k.stopped==STOP_LEVEL_STOP) #define SekIsStoppedS68k() (PicoCpuMS68k.stopped==STOP_LEVEL_STOP) -#define SekShouldInterrupt() (CPU_INT_LEVEL > FLAG_INT_MASK) +#define SekShouldInterrupt() (PicoCpuMM68k.int_level > PicoCpuMM68k.int_mask) #define SekNotPolling PicoCpuMM68k.not_polling #define SekNotPollingS68k PicoCpuMS68k.not_polling