summaryrefslogtreecommitdiff
path: root/psp
diff options
context:
space:
mode:
authorDavid Guillen Fandos2021-05-05 02:20:00 +0200
committerDavid G. F2021-05-05 21:15:27 +0200
commit4fd456e1583a4c8686c8de87c2aeb1eb78125be1 (patch)
treea808a15f40df0f09226fc8e4a620b0f546b48729 /psp
parent52088a4d10af9a8c0e95b0eb168d4dfd0a13639f (diff)
downloadpicogpsp-4fd456e1583a4c8686c8de87c2aeb1eb78125be1.tar.gz
picogpsp-4fd456e1583a4c8686c8de87c2aeb1eb78125be1.tar.bz2
picogpsp-4fd456e1583a4c8686c8de87c2aeb1eb78125be1.zip
Adding Code Breaker cheat support
This works on both interpreter and dynarec. Tested in MIPS, ARM and x86, still needs some more testing, some edge cases can be buggy.
Diffstat (limited to 'psp')
-rw-r--r--psp/mips_emit.h7
-rw-r--r--psp/mips_stub.S13
2 files changed, 20 insertions, 0 deletions
diff --git a/psp/mips_emit.h b/psp/mips_emit.h
index 12685e8..174fee5 100644
--- a/psp/mips_emit.h
+++ b/psp/mips_emit.h
@@ -44,6 +44,7 @@ void mips_indirect_branch_dual(u32 address);
u32 execute_read_cpsr();
u32 execute_read_spsr();
void execute_swi(u32 pc);
+void mips_cheat_hook();
u32 execute_spsr_restore(u32 address);
void execute_store_cpsr(u32 new_cpsr, u32 store_mask);
@@ -2422,6 +2423,12 @@ u32 execute_store_cpsr_body(u32 _cpsr, u32 store_mask, u32 address)
generate_indirect_branch_cycle_update(dual); \
} \
+#define thumb_process_cheats() \
+ generate_function_call(mips_cheat_hook);
+
+#define arm_process_cheats() \
+ generate_function_call(mips_cheat_hook);
+
#ifdef TRACE_INSTRUCTIONS
void trace_instruction(u32 pc)
{
diff --git a/psp/mips_stub.S b/psp/mips_stub.S
index 08151db..786dc9e 100644
--- a/psp/mips_stub.S
+++ b/psp/mips_stub.S
@@ -44,6 +44,7 @@
.global init_emitter
.global mips_lookup_pc
.global smc_write
+.global mips_cheat_hook
.global write_io_epilogue
.global memory_map_read
@@ -256,6 +257,17 @@ mips_update_gba:
nop
+# Processes cheats whenever we hit the master PC
+mips_cheat_hook:
+ sw $ra, REG_SAVE2($16)
+ save_registers
+ cfncall process_cheats, 8
+ lw $ra, REG_SAVE2($16)
+ restore_registers
+ jr $ra
+ nop
+
+
# Loads the main context and returns to it.
# ARM regs must be saved before branching here
return_to_main:
@@ -649,6 +661,7 @@ fnptrs:
.long set_cpu_mode # 5
.long execute_spsr_restore_body # 6
.long execute_store_cpsr_body # 7
+ .long process_cheats # 8
#if !defined(HAVE_MMAP)