Advertisement
fishguy6564

[MKDS] ARM9 Code Handler

Dec 13th, 2018
1,905
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ARM 2.41 KB | None | 0 0
  1. ;A very simple and minimal code handler for ARM9 addresses created for Mario Kart DS by Fishguy6564
  2. ;R0 = code list address
  3. ;R1 = address to write to
  4. ;R2 = instruction to write to address
  5. ;R3 = code handler terminator value
  6.  
  7. .set codelist, 0x2001E54
  8. .set terminator, 0xDEADBEEF
  9.     STMDB       SP!, {R0-R3}    ;PUSH
  10.     LDR         R0, =codelist   ;R0 contains the address of the beginning of the code list
  11.     LDR         R3, =terminator ;R3 contains the expected code list terminator
  12. LOOP:
  13.     LDR         R1, [R0]        ;Load the address to write to or terminator from the codelist into R1
  14.     CMP         R1, R3          ;Check if terminator is present
  15.     BEQ         END             ;End iteration through code list if the entry was the code list terminator
  16.     LDR         R2, [R0, #4]    ;Load value to be written from the code list into R2
  17.     STR         R2, [R1]        ;Write value to the address
  18.     ADD         R0, R0, #8      ;Increase to the next entry in code list
  19.     B           LOOP            ;Loop again
  20. END:
  21.     LDMIA       SP!, {R0-R3}    ;POP
  22.     BX          LR
  23.  
  24. [ARM9 Codehandler by Fishguy6564]
  25. 02039988 EAFF1D88
  26. E2000FB0 00000038
  27. E92D000F E59F0024
  28. E59F3024 E5901000
  29. E1510003 0A000003
  30. E5902004 E5812000
  31. E2800008 EAFFFFF8
  32. E8BD000F E12FFF1E
  33. 02001E54 DEADBEEF
  34.  
  35. [Empty Code List]
  36. E2001E54 YYYYYYYY
  37. <-----Codes----->
  38. DEADBEEF 00000000
  39.  
  40. Calculate in hex
  41. Y = (8 * code amount) + 4
  42.  
  43. Example:
  44. [Code List With ARM9 Infinite Speed]
  45. E2001E54 00000014 <- Instructions are included on how we calculated 0x14
  46. 01002E98 E3500470 ;1 Code
  47. 01003E40 E3A02470 ;2 Codes
  48. DEADBEEF 00000000
  49.  
  50. Total of two codes we want to use.
  51. Plug into the equation to calculate the Y value
  52. Y = (8 * 2) + 4
  53. Y = 20
  54. convert it to hex
  55. 20 = 0x14 in hex so..
  56. Y = 0x14 this is our value for Y
  57. Zero extend the calculated value, so YYYYYYYY = 00000014
  58.  
  59. Note: Infinite speed was not made by me!
  60.  
  61. Instructions on porting to other games:
  62. 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