diff options
Diffstat (limited to 'libpcsxcore/lightrec')
-rw-r--r-- | libpcsxcore/lightrec/plugin.c | 82 |
1 files changed, 50 insertions, 32 deletions
diff --git a/libpcsxcore/lightrec/plugin.c b/libpcsxcore/lightrec/plugin.c index 8c64c67..79bf021 100644 --- a/libpcsxcore/lightrec/plugin.c +++ b/libpcsxcore/lightrec/plugin.c @@ -42,6 +42,7 @@ static struct lightrec_state *lightrec_state; static char *name = "retroarch.exe"; static bool use_lightrec_interpreter; +static bool use_pcsx_interpreter; static bool lightrec_debug; static bool lightrec_very_debug; static u32 lightrec_begin_cycles; @@ -111,7 +112,7 @@ static void (*cp2_ops[])(struct psxCP2Regs *) = { static char cache_buf[64 * 1024]; -static u32 cop0_mfc(struct lightrec_state *state, u8 reg) +static u32 cop0_mfc(struct lightrec_state *state, u32 op, u8 reg) { return psxRegs.CP0.r[reg]; } @@ -124,12 +125,12 @@ static u32 cop2_mfc_cfc(struct lightrec_state *state, u8 reg, bool cfc) return MFC2(reg); } -static u32 cop2_mfc(struct lightrec_state *state, u8 reg) +static u32 cop2_mfc(struct lightrec_state *state, u32 op, u8 reg) { return cop2_mfc_cfc(state, reg, false); } -static u32 cop2_cfc(struct lightrec_state *state, u8 reg) +static u32 cop2_cfc(struct lightrec_state *state, u32 op, u8 reg) { return cop2_mfc_cfc(state, reg, true); } @@ -176,22 +177,22 @@ static void cop2_mtc_ctc(struct lightrec_state *state, MTC2(value, reg); } -static void cop0_mtc(struct lightrec_state *state, u8 reg, u32 value) +static void cop0_mtc(struct lightrec_state *state, u32 op, u8 reg, u32 value) { cop0_mtc_ctc(state, reg, value, false); } -static void cop0_ctc(struct lightrec_state *state, u8 reg, u32 value) +static void cop0_ctc(struct lightrec_state *state, u32 op, u8 reg, u32 value) { cop0_mtc_ctc(state, reg, value, true); } -static void cop2_mtc(struct lightrec_state *state, u8 reg, u32 value) +static void cop2_mtc(struct lightrec_state *state, u32 op, u8 reg, u32 value) { cop2_mtc_ctc(state, reg, value, false); } -static void cop2_ctc(struct lightrec_state *state, u8 reg, u32 value) +static void cop2_ctc(struct lightrec_state *state, u32 op, u8 reg, u32 value) { cop2_mtc_ctc(state, reg, value, true); } @@ -211,7 +212,8 @@ static void cop2_op(struct lightrec_state *state, u32 func) cp2_ops[func & 0x3f](&psxRegs.CP2); } -static void hw_write_byte(struct lightrec_state *state, u32 mem, u8 val) +static void hw_write_byte(struct lightrec_state *state, + u32 op, void *host, u32 mem, u8 val) { psxRegs.cycle = lightrec_current_cycle_count(state); @@ -221,7 +223,8 @@ static void hw_write_byte(struct lightrec_state *state, u32 mem, u8 val) lightrec_reset_cycle_count(state, psxRegs.cycle); } -static void hw_write_half(struct lightrec_state *state, u32 mem, u16 val) +static void hw_write_half(struct lightrec_state *state, + u32 op, void *host, u32 mem, u16 val) { psxRegs.cycle = lightrec_current_cycle_count(state); @@ -231,7 +234,8 @@ static void hw_write_half(struct lightrec_state *state, u32 mem, u16 val) lightrec_reset_cycle_count(state, psxRegs.cycle); } -static void hw_write_word(struct lightrec_state *state, u32 mem, u32 val) +static void hw_write_word(struct lightrec_state *state, + u32 op, void *host, u32 mem, u32 val) { psxRegs.cycle = lightrec_current_cycle_count(state); @@ -241,7 +245,7 @@ static void hw_write_word(struct lightrec_state *state, u32 mem, u32 val) lightrec_reset_cycle_count(state, psxRegs.cycle); } -static u8 hw_read_byte(struct lightrec_state *state, u32 mem) +static u8 hw_read_byte(struct lightrec_state *state, u32 op, void *host, u32 mem) { u8 val; @@ -254,7 +258,8 @@ static u8 hw_read_byte(struct lightrec_state *state, u32 mem) return val; } -static u16 hw_read_half(struct lightrec_state *state, u32 mem) +static u16 hw_read_half(struct lightrec_state *state, + u32 op, void *host, u32 mem) { u16 val; @@ -267,7 +272,8 @@ static u16 hw_read_half(struct lightrec_state *state, u32 mem) return val; } -static u32 hw_read_word(struct lightrec_state *state, u32 mem) +static u32 hw_read_word(struct lightrec_state *state, + u32 op, void *host, u32 mem) { u32 val; @@ -291,12 +297,14 @@ static struct lightrec_mem_map_ops hw_regs_ops = { static u32 cache_ctrl; -static void cache_ctrl_write_word(struct lightrec_state *state, u32 mem, u32 val) +static void cache_ctrl_write_word(struct lightrec_state *state, + u32 op, void *host, u32 mem, u32 val) { cache_ctrl = val; } -static u32 cache_ctrl_read_word(struct lightrec_state *state, u32 mem) +static u32 cache_ctrl_read_word(struct lightrec_state *state, + u32 op, void *host, u32 mem) { return cache_ctrl; } @@ -489,6 +497,9 @@ static void print_for_big_ass_debugger(void) printf("\n"); } + +extern void intExecuteBlock(); + static u32 old_cycle_counter; static void lightrec_plugin_execute_block(void) @@ -496,27 +507,33 @@ static void lightrec_plugin_execute_block(void) u32 old_pc = psxRegs.pc; u32 flags; - lightrec_reset_cycle_count(lightrec_state, psxRegs.cycle); - lightrec_restore_registers(lightrec_state, psxRegs.GPR.r); + if (use_pcsx_interpreter) { + intExecuteBlock(); + } else { + lightrec_reset_cycle_count(lightrec_state, psxRegs.cycle); + lightrec_restore_registers(lightrec_state, psxRegs.GPR.r); - if (use_lightrec_interpreter) - psxRegs.pc = lightrec_run_interpreter(lightrec_state, psxRegs.pc); - else - psxRegs.pc = lightrec_execute_one(lightrec_state, psxRegs.pc); + if (use_lightrec_interpreter) + psxRegs.pc = lightrec_run_interpreter(lightrec_state, + psxRegs.pc); + else + psxRegs.pc = lightrec_execute_one(lightrec_state, + psxRegs.pc); - psxRegs.cycle = lightrec_current_cycle_count(lightrec_state); + psxRegs.cycle = lightrec_current_cycle_count(lightrec_state); - lightrec_dump_registers(lightrec_state, psxRegs.GPR.r); - flags = lightrec_exit_flags(lightrec_state); + lightrec_dump_registers(lightrec_state, psxRegs.GPR.r); + flags = lightrec_exit_flags(lightrec_state); - if (flags & LIGHTREC_EXIT_SEGFAULT) { - fprintf(stderr, "Exiting at cycle 0x%08x\n", - psxRegs.cycle); - exit(1); - } + if (flags & LIGHTREC_EXIT_SEGFAULT) { + fprintf(stderr, "Exiting at cycle 0x%08x\n", + psxRegs.cycle); + exit(1); + } - if (flags & LIGHTREC_EXIT_SYSCALL) - psxException(0x20, 0); + if (flags & LIGHTREC_EXIT_SYSCALL) + psxException(0x20, 0); + } psxBranchTest(); @@ -532,8 +549,9 @@ static void lightrec_plugin_execute_block(void) } if ((psxRegs.cycle & ~0xfffffff) != old_cycle_counter) { - printf("RAM usage: IR %u KiB, CODE %u KiB, " + printf("RAM usage: Lightrec %u KiB, IR %u KiB, CODE %u KiB, " "MIPS %u KiB, TOTAL %u KiB, avg. IPI %f\n", + lightrec_get_mem_usage(MEM_FOR_LIGHTREC) / 1024, lightrec_get_mem_usage(MEM_FOR_IR) / 1024, lightrec_get_mem_usage(MEM_FOR_CODE) / 1024, lightrec_get_mem_usage(MEM_FOR_MIPS_CODE) / 1024, |