Advertisement
Dotsarecool

KatAM Practice Cart

Apr 12th, 2019
2,766
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ARM 4.45 KB | None | 0 0
  1. #define FILE_TO_PATCH "KatAM_J.gba"
  2.  
  3. #define INIT_CHOOSE_ABILITY 0x08FA0000
  4. #define CHOOSE_ABILITY 0x08FA1000
  5. #define CHOOSE_RETURN 0x08FA1200
  6. .text
  7. start:
  8. baseaddress = 0x08000000
  9. .global _start
  10. _start = baseaddress
  11.  
  12. @@@@@@@@@@@@@@@@@@@@@@@
  13. @ MACROS
  14. @@@@@@@@@@@@@@@@@@@@@@@
  15.  
  16. .macro patchat address
  17.         @copy bytes in file from current address to specified address
  18.         .incbin FILE_TO_PATCH, (. - start), (\address - baseaddress - (. - start))
  19. .endm
  20.  
  21. .macro load32 rx, value
  22.         eor \rx, \rx, \rx
  23.         add \rx, \rx, #((\value / 0x1000000) & 0xFF)
  24.         lsl \rx, \rx, #8
  25.         add \rx, \rx, #((\value / 0x10000) & 0xFF)
  26.         lsl \rx, \rx, #8
  27.         add \rx, \rx, #((\value / 0x100) & 0xFF)
  28.         lsl \rx, \rx, #8
  29.         add \rx, \rx, #(\value & 0xFF)
  30. .endm
  31.  
  32. .thumb
  33.  
  34. @@@@@@@@@@@@@@@@@@@@@@@
  35. @ HEX EDITS
  36. @@@@@@@@@@@@@@@@@@@@@@@
  37.  
  38. patchat 0x0803EAB6 @ begin with 99 lives cause why not
  39.     mov r0, #99
  40. patchat 0x0804A91E @ don't take damage
  41.     strb r2,[r1]
  42. patchat 0x0804F826 @ reset death quickly
  43.     mov r1, #0xEF
  44. patchat 0x0804F994 @ don't reset to normal kirby after death
  45.         add r0, r0, #0
  46. patchat 0x0804F9A2 @ don't reset to normal kirby after death
  47.         add r0, r0, #0
  48.         add r0, r0, #0
  49. patchat 0x0804FFAA @ don't lose lives
  50.     sub r0, r1, #0
  51.  
  52. @@@@@@@@@@@@@@@@@@@@@@@
  53. @ HIJACKS
  54. @@@@@@@@@@@@@@@@@@@@@@@
  55.  
  56. patchat 0x08056D8C @ R button
  57.     .word INIT_CHOOSE_ABILITY+1
  58. @patchat 0x08056F70 @ L button
  59. @   .word increment_ability+1
  60.    
  61. patchat 0x08087F6A @ don't reset to normal kirby after death
  62.     add r0, r0, #0
  63.     add r0, r0, #0
  64.  
  65.  
  66. patchat 0x08F9FFE0
  67.     .ascii "KatAM Practice Cart\x0F\0"
  68.    
  69. @@@@@@@@@@@@@@@@@@@@@@@
  70. @ CODE
  71. @@@@@@@@@@@@@@@@@@@@@@@
  72.  
  73. patchat INIT_CHOOSE_ABILITY
  74.     initChooseAbility:
  75.         push {r4-r7,r14}
  76.        
  77.         load32 r7, 0x02020FE3
  78.         ldrb r4, [r7,#0]
  79.         load32 r7, 0x02020FBD
  80.         strb r4, [r7,#0]
  81.        
  82.         load32 r7, 0x02020F58
  83.         load32 r4, (CHOOSE_ABILITY+1)
  84.         str r4, [r7,#0]
  85.        
  86.         pop {r4-r7}
  87.         pop {r0}
  88.         bx r0
  89.  
  90. patchat CHOOSE_ABILITY
  91.     ChooseAbility:
  92.         push {r4-r7,r14}
  93.        
  94.         @ bring up ability icon
  95.         load32 r7, 0x03003AD0
  96.         mov r4, #0x06
  97.         strb r4, [r7,#0]
  98.         sub r7, r7, #0x10
  99.         mov r4, #0x0C
  100.         strb r4, [r7,#0]
  101.        
  102.         @ restore ability (magic)
  103.         load32 r7, 0x02020EEF
  104.         mov r4, #0
  105.         strb r4, [r7,#0]
  106.  
  107.         load32 r7, 0x02020FFA @ buttons
  108.        
  109.         ldrb r4, [r7,#0]
  110.         cmp r4, #0x10 @ right
  111.         beq pressright
  112.         cmp r4, #0x20 @ left
  113.         beq pressleft
  114.         cmp r4, #0x04 @ select
  115.         beq pressselect
  116.         cmp r4, #0x01 @ A
  117.         bne done
  118.        
  119.     preparereturn:
  120.         load32 r7, 0x02020F58
  121.         load32 r4, 0x0805C591
  122.         str r4, [r7,#0]
  123.        
  124.         load32 r7, 0x0203AD20
  125.         mov r4, #0
  126.         str r4, [r7,#0]
  127.        
  128.         load32 r0, 0x02020EE0
  129.         load32 r5, 0x0806E465
  130.         load32 r6, (CHOOSE_RETURN+1)
  131.         mov r14, r6
  132.         push {r1-r3}
  133.         bx r5
  134.        
  135.     done:
  136.         pop {r4-r7}
  137.         pop {r0}
  138.         bx r0
  139.    
  140.     pressselect:
  141.         mov r4, #0
  142.         load32 r7, 0x02020FE0
  143.         strb r4, [r7,#0]
  144.         load32 r7, 0x03000514
  145.         strb r4, [r7,#0]
  146.         b preparereturn
  147.            
  148.     pressright:
  149.         load32 r7, 0x02020FBD
  150.         ldrb r4, [r7,#0]
  151.         add r4, r4, #1
  152.         cmp r4, #0x1B
  153.         bcc no_wrap_right
  154.         eor r4, r4, r4
  155.     no_wrap_right:
  156.         strb r4, [r7,#0]
  157.         b updategraphics
  158.        
  159.     pressleft:
  160.         load32 r7, 0x02020FBD
  161.         ldrb r4, [r7,#0]
  162.         cmp r4, #0x00
  163.         bne no_wrap_left
  164.         mov r4, #0x1A
  165.         strb r4, [r7,#0]
  166.         b updategraphics
  167.     no_wrap_left:
  168.         sub r4, r4, #1
  169.         strb r4, [r7,#0]
  170.         b updategraphics
  171.        
  172.     updategraphics:
  173.         ldrb r0, [r7,#0]
  174.         load32 r5, 0x08035DD5
  175.         load32 r6, (CHOOSE_RETURN+1)
  176.         mov r14, r6
  177.         push {r1-r3}
  178.         bx r5
  179.  
  180. patchat CHOOSE_RETURN
  181.     returnaddress:
  182.         pop {r1-r3}
  183.         b done
  184.        
  185.        
  186.    
  187. patchat 0x09000000
  188.  
  189. @@@@@@@@@@@@@@@@@@@@@@@
  190. @ NOTES
  191. @@@@@@@@@@@@@@@@@@@@@@@
  192.  
  193. @ 0x02020F58 = pointer to routine to run every frame
  194. @            - 0x0803FEDD - default, idle
  195. @            - 0x0805C591 - get an ability (update graphics)
  196. @            - 0x0805C331 - mix roulette
  197. @ 0x02020FBD = next ability
  198. @ 0x02020FE3 = current ability
  199. @ 0x02020FB8 = speed of mix roulette
  200. @ 0x02020EE4 = counter for roulette image
  201. @ 0x02020EE5 = current mix roulette image
  202. @ 0x02020EEF = set to 0x02 to kill ability after this room
  203. @ 0x03000514 = sprite lock if bit0 set
  204. @ 0x03003AC0 = timer for ability image
  205. @ 0x03003AD0 = ability image state
  206.  
  207.  
  208. @ press R to add one to ability:
  209. @       load32 r7, 0x02020FE3
  210. @
  211. @       ldrb r4, [r7,#0]
  212. @       sub r7, r7, #0x26 @ r7 := 02020FBD
  213. @       add r4, r4, #1
  214. @       cmp r4, #0x1B
  215. @       bcc save_ability
  216. @       eor r4, r4, r4
  217. @   save_ability:
  218. @       strb r4, [r7,#0]
  219. @
  220. @       sub r7, r7, #0x65 @ r7 := 02020F58
  221. @
  222. @       load32 r4, 0x0805C591
  223. @       str r4, [r7,#0]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement