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;
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];
}
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);
}
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);
}
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);
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);
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);
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;
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;
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;
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;
}
lightrec_map, ARRAY_SIZE(lightrec_map),
&lightrec_ops);
- fprintf(stderr, "M=0x%lx, P=0x%lx, R=0x%lx, H=0x%lx\n",
- (uintptr_t) psxM,
- (uintptr_t) psxP,
- (uintptr_t) psxR,
- (uintptr_t) psxH);
+ // fprintf(stderr, "M=0x%lx, P=0x%lx, R=0x%lx, H=0x%lx\n",
+ // (uintptr_t) psxM,
+ // (uintptr_t) psxP,
+ // (uintptr_t) psxR,
+ // (uintptr_t) psxH);
#ifndef _WIN32
signal(SIGPIPE, exit);
printf("\n");
}
+
+extern void intExecuteBlock();
+
static u32 old_cycle_counter;
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();
}
if ((psxRegs.cycle & ~0xfffffff) != old_cycle_counter) {
- printf("RAM usage: IR %u KiB, CODE %u KiB, "
+ SysDLog("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,
static void lightrec_plugin_clear(u32 addr, u32 size)
{
- /* size * 4: PCSX uses DMA units */
- lightrec_invalidate(lightrec_state, addr, size * 4);
+ if (addr == 0 && size == UINT32_MAX)
+ lightrec_invalidate_all(lightrec_state);
+ else
+ /* size * 4: PCSX uses DMA units */
+ lightrec_invalidate(lightrec_state, addr, size * 4);
+}
+
+#ifdef ICACHE_EMULATION
+static void lightrec_plugin_notify(int note, void *data)
+{
+ /*
+ To change once proper icache emulation is emulated
+ switch (note)
+ {
+ case R3000ACPU_NOTIFY_CACHE_UNISOLATED:
+ lightrec_plugin_clear(0, 0x200000/4);
+ break;
+ case R3000ACPU_NOTIFY_CACHE_ISOLATED:
+ // Sent from psxDma3().
+ case R3000ACPU_NOTIFY_DMA3_EXE_LOAD:
+ default:
+ break;
+ }*/
}
+#endif
static void lightrec_plugin_shutdown(void)
{
static void lightrec_plugin_reset(void)
{
-// Called in every frame (or every frame where input changes) when using runahead
-// lightrec_plugin_shutdown();
-// lightrec_plugin_init();
- lightrec_invalidate_all(lightrec_state);
+ lightrec_plugin_shutdown();
+ lightrec_plugin_init();
}
R3000Acpu psxRec =
lightrec_plugin_execute,
lightrec_plugin_execute_block,
lightrec_plugin_clear,
+#ifdef ICACHE_EMULATION
+ lightrec_plugin_notify,
+#endif
lightrec_plugin_shutdown,
};