Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;A very simple and minimal code handler for ARM9 addresses created for Mario Kart DS by Fishguy6564
- ;R0 = code list address
- ;R1 = address to write to
- ;R2 = instruction to write to address
- ;R3 = code handler terminator value
- .set codelist, 0x2001E54
- .set terminator, 0xDEADBEEF
- STMDB SP!, {R0-R3} ;PUSH
- LDR R0, =codelist ;R0 contains the address of the beginning of the code list
- LDR R3, =terminator ;R3 contains the expected code list terminator
- LOOP:
- LDR R1, [R0] ;Load the address to write to or terminator from the codelist into R1
- CMP R1, R3 ;Check if terminator is present
- BEQ END ;End iteration through code list if the entry was the code list terminator
- LDR R2, [R0, #4] ;Load value to be written from the code list into R2
- STR R2, [R1] ;Write value to the address
- ADD R0, R0, #8 ;Increase to the next entry in code list
- B LOOP ;Loop again
- END:
- LDMIA SP!, {R0-R3} ;POP
- BX LR
- [ARM9 Codehandler by Fishguy6564]
- 02039988 EAFF1D88
- E2000FB0 00000038
- E92D000F E59F0024
- E59F3024 E5901000
- E1510003 0A000003
- E5902004 E5812000
- E2800008 EAFFFFF8
- E8BD000F E12FFF1E
- 02001E54 DEADBEEF
- [Empty Code List]
- E2001E54 YYYYYYYY
- <-----Codes----->
- DEADBEEF 00000000
- Calculate in hex
- Y = (8 * code amount) + 4
- Example:
- [Code List With ARM9 Infinite Speed]
- E2001E54 00000014 <- Instructions are included on how we calculated 0x14
- 01002E98 E3500470 ;1 Code
- 01003E40 E3A02470 ;2 Codes
- DEADBEEF 00000000
- Total of two codes we want to use.
- Plug into the equation to calculate the Y value
- Y = (8 * 2) + 4
- Y = 20
- convert it to hex
- 20 = 0x14 in hex so..
- Y = 0x14 this is our value for Y
- Zero extend the calculated value, so YYYYYYYY = 00000014
- Note: Infinite speed was not made by me!
- Instructions on porting to other games:
- I've tried to make this source as clean and descriptive as possible by adding comments and assembly directives. To port this to another game, simply change the .set directive for the code list to an unused region in ram. From there, just hook this code to a base address that is in constant execution for best results. The content after the POP (LDMIA) may differ depending on where you hook to. Always remember to include a return branch at the end of your code, in this case, it was BX LR. Again, this may differ depending on where you hook it. This is my first ever DS code, so if you find any bugs then please feel free to report them :P
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement