diff options
author | David Guillen Fandos | 2021-05-05 02:20:00 +0200 |
---|---|---|
committer | David G. F | 2021-05-05 21:15:27 +0200 |
commit | 4fd456e1583a4c8686c8de87c2aeb1eb78125be1 (patch) | |
tree | a808a15f40df0f09226fc8e4a620b0f546b48729 /arm | |
parent | 52088a4d10af9a8c0e95b0eb168d4dfd0a13639f (diff) | |
download | picogpsp-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 'arm')
-rw-r--r-- | arm/arm_emit.h | 8 | ||||
-rw-r--r-- | arm/arm_stub.S | 16 |
2 files changed, 24 insertions, 0 deletions
diff --git a/arm/arm_emit.h b/arm/arm_emit.h index 1432617..4368a80 100644 --- a/arm/arm_emit.h +++ b/arm/arm_emit.h @@ -31,6 +31,8 @@ u32 prepare_store_reg(u32 scratch_reg, u32 reg_index); void generate_load_reg(u32 ireg, u32 reg_index); void complete_store_reg(u32 scratch_reg, u32 reg_index); void complete_store_reg_pc_no_flags(u32 scratch_reg, u32 reg_index); +void thumb_cheat_hook(); +void arm_cheat_hook(); u32 arm_update_gba_arm(u32 pc); u32 arm_update_gba_thumb(u32 pc); @@ -1876,6 +1878,12 @@ u32 execute_store_cpsr_body(u32 _cpsr, u32 store_mask, u32 address) generate_indirect_branch_cycle_update(dual_thumb); \ } \ +#define thumb_process_cheats() \ + generate_function_call(thumb_cheat_hook); + +#define arm_process_cheats() \ + generate_function_call(arm_cheat_hook); + #define thumb_swi() \ generate_swi_hle_handler(opcode & 0xFF, thumb); \ generate_function_call(execute_swi_thumb); \ diff --git a/arm/arm_stub.S b/arm/arm_stub.S index 944d36a..222bb21 100644 --- a/arm/arm_stub.S +++ b/arm/arm_stub.S @@ -288,6 +288,22 @@ arm_update_gba_builder(idle_arm, arm, add) arm_update_gba_builder(idle_thumb, thumb, add) +@ Cheat hooks for master function +@ This is called whenever PC == cheats-master-function +@ Just calls the C function to process cheats + +#define cheat_hook_builder(mode) ;\ +defsymbl(mode##_cheat_hook) ;\ + save_flags() ;\ + store_registers_##mode() ;\ + call_c_function(process_cheats) ;\ + load_registers_##mode() ;\ + restore_flags() ;\ + bx lr ;\ + +cheat_hook_builder(arm) +cheat_hook_builder(thumb) + @ These are b stubs for performing indirect branches. They are not @ linked to and don't return, instead they link elsewhere. |