Camtech075

Invincibility Flag hack

Feb 28th, 2012
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.64 KB | None | 0 0
  1. HACK_FILE:
  2.  
  3. .align 2
  4. @ Hardware offset
  5. .long 0x08000000
  6.  
  7. @ Hook BEGIN
  8.  
  9. IFH_HOOK:
  10. .align 2
  11. .set IFH_HOOK_SIZE, IFH_HOOK_END - IFH_HOOK_ST
  12. @.org 0x080292EC
  13. .set IFH_HOOK_ORG, 0x080292EC
  14. .long IFH_HOOK_ORG
  15. @ TODO - Figure out alignment
  16. .long 0x00000000
  17. .long IFH_HOOK_SIZE
  18.  
  19. .thumb
  20.  
  21. IFH_HOOK_ST:
  22. @ The function ends with r4-r6 and r14 getting popped anyway, so there is
  23. @ no real need to push the lr this time.
  24. ldr r0, IFH_HOOK_LINK
  25. bx r0
  26.  
  27. IFH_HOOK_LINK:
  28. .align 2
  29. .long IFH_HACK_ORG + 1
  30. IFH_HOOK_END:
  31.  
  32. @ Hack BEGIN
  33.  
  34. .align 2
  35. @.org 0x08D50000
  36.  
  37. IFH_HACK:
  38. .set IFH_HACK_SIZE, IFH_HACK_END - IFH_HACK_ST
  39. .set IFH_HACK_ORG, 0x08D50000
  40. .long IFH_HACK_ORG
  41. .long 0x00000000
  42. .long IFH_HACK_SIZE
  43.  
  44. .thumb
  45.  
  46. IFH_HACK_ST:
  47. .macro IFH_CALL address
  48. bl \address - (IFH_HACK_ORG + (HACK_FILE - IFH_HACK_ST))
  49. .endm
  50. @ This is all missing.
  51. ldr r1, =0x0203A3D8
  52. mov r2, #0x4
  53. ldsh r0, [r1, r2]
  54. cmp r0, #0x7F
  55. ble M_CMP_DMG
  56. mov r0, #0x7F
  57. strh r0, [r1, #0x4]
  58.  
  59. M_CMP_DMG:
  60. mov r2, #0x4
  61. ldsh r0, [r1, r2] @ Again?
  62. cmp r0, #0x0
  63. bge M_CMP_YDMG
  64. mov r0, #0x0
  65. strh r0, [r1, #0x4]
  66.  
  67. M_CMP_YDMG:
  68. ldsh r0, [r1, r2] @ Here we go again.
  69. cmp r0, #0x0
  70. beq IFH_FUNC @ HACKY: The old function just jumped to the end.
  71. mov r1, r6
  72. add r1, #0x7C
  73. mov r0, #0x1 @ I am going to assume that this value is a boolean that
  74. strb r0, [r1, #0x0] @ determines if it is not going to play the 'tink' noise.
  75.  
  76. @ Function begin.
  77. IFH_FUNC:
  78. push {r1-r3} @ R0 is clobbered upon return anyway.
  79. push {r5, r7}
  80. push {r4}
  81. ldsh r1, [r4, #0x4] @ If damage is 0 anyway, just return.
  82. cmp r1, #0x0
  83. ble CLEANUP
  84. ldr r0, WRITE_PTRS
  85. ldr r5, [r0, #0x0] @ r5 is the table offset.
  86. mov r7, #0x34 @ r7 is the size of one entry.
  87. ldr r3, [r0, #0x4] @ Prepare r3...
  88. ldr r3, [r3, #0x0] @ So we can set it as the table.
  89. mov r2, #0x0 @ r2 is our counting register.
  90. mov r4, r8 @ Prepare r4...
  91. ldr r1, [r4, #0x0] @ To load the enemy pointer.
  92.  
  93. CHECK_LOOP:
  94. ldrb r0, [r3, r2] @ Load character from the loop.
  95. cmp r0, #0x0 @ Check for terminator.
  96. beq PASS
  97. mul r0, r0, r7
  98. add r0, r0, r5 @ Set up r0.
  99. cmp r0, r1
  100. beq PASS
  101. add r2, r2, #0x1
  102. b CHECK_LOOP @ Continue loop.
  103.  
  104. PASS:
  105. cmp r0, #0x0 @ If r0 is anything but 0, we found something.
  106. bne TRUE
  107. FALSE:
  108. cmp r4, r8 @ HACK - Check if we are on enemy or player.
  109. beq CLEANUP
  110. b NEGATE
  111. TRUE:
  112. cmp r4, r8 @ If only I could do this only once...
  113. bne CLEANUP
  114.  
  115. CONTINUE:
  116. mov r4, r6 @ Set up r4 for the player table.
  117. ldr r1, [r4, #0x0] @ r1 = attacking character
  118. ldr r3, [r0, #0x8] @ r3 = offset of attacking characters
  119. b CHECK_LOOP @ and back into the loop we go!
  120.  
  121. NEGATE:
  122. pop {r4}
  123. mov r0, #0x0 @ Set damage to zero.
  124. strh r0, [r4, #0x4] @ Store it as damage.
  125.  
  126. CLEANUP:
  127. @ FIXME: Cleanup is ugly.
  128. cmp r4, r7 @ If r4 is equal to r7 or r8, then we
  129. bne RETURN @ have not popped it to store negated
  130. cmp r4, r8 @ damage to memory yet.
  131. bne RETURN
  132. pop {r4}
  133.  
  134. RETURN:
  135. @ NOTE: This ugly-looking bunch of pops are to ensure that the stack
  136. @ is purged properly. And then the last two are to mimic the original.
  137. pop {r5, r7}
  138. pop {r1-r3}
  139. pop {r4-r6}
  140. pop {r0}
  141. bx r0
  142.  
  143. .align 2
  144.  
  145. WRITE_PTRS:
  146. .set END_VAL, 0x0000
  147. @ Table value
  148. .long 0x08BDCE18
  149. @ HACKY
  150. .set ENEMY_VAL, IFH_HACK_ORG + (ENEMY_TABLE - IFH_HACK_ST)
  151. .long ENEMY_VAL
  152. .set ALLY_VAL, IFH_HACK_ORG + (ALLY_TABLE - IFH_HACK_ST)
  153. .long ALLY_VAL
  154.  
  155. ENEMY_TABLE:
  156. @ Default values
  157. .byte 0x44
  158. .byte 0x00
  159. .short END_VAL
  160.  
  161. ALLY_TABLE:
  162. .byte 0x14
  163. .byte 0x00
  164. .short END_VAL
  165. IFH_HACK_END:
Add Comment
Please, Sign In to add comment