Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- HACK_FILE:
- .align 2
- @ Hardware offset
- .long 0x08000000
- @ Hook BEGIN
- IFH_HOOK:
- .align 2
- .set IFH_HOOK_SIZE, IFH_HOOK_END - IFH_HOOK_ST
- @.org 0x080292EC
- .set IFH_HOOK_ORG, 0x080292EC
- .long IFH_HOOK_ORG
- @ TODO - Figure out alignment
- .long 0x00000000
- .long IFH_HOOK_SIZE
- .thumb
- IFH_HOOK_ST:
- @ The function ends with r4-r6 and r14 getting popped anyway, so there is
- @ no real need to push the lr this time.
- ldr r0, IFH_HOOK_LINK
- bx r0
- IFH_HOOK_LINK:
- .align 2
- .long IFH_HACK_ORG + 1
- IFH_HOOK_END:
- @ Hack BEGIN
- .align 2
- @.org 0x08D50000
- IFH_HACK:
- .set IFH_HACK_SIZE, IFH_HACK_END - IFH_HACK_ST
- .set IFH_HACK_ORG, 0x08D50000
- .long IFH_HACK_ORG
- .long 0x00000000
- .long IFH_HACK_SIZE
- .thumb
- IFH_HACK_ST:
- .macro IFH_CALL address
- bl \address - (IFH_HACK_ORG + (HACK_FILE - IFH_HACK_ST))
- .endm
- @ This is all missing.
- ldr r1, =0x0203A3D8
- mov r2, #0x4
- ldsh r0, [r1, r2]
- cmp r0, #0x7F
- ble M_CMP_DMG
- mov r0, #0x7F
- strh r0, [r1, #0x4]
- M_CMP_DMG:
- mov r2, #0x4
- ldsh r0, [r1, r2] @ Again?
- cmp r0, #0x0
- bge M_CMP_YDMG
- mov r0, #0x0
- strh r0, [r1, #0x4]
- M_CMP_YDMG:
- ldsh r0, [r1, r2] @ Here we go again.
- cmp r0, #0x0
- beq IFH_FUNC @ HACKY: The old function just jumped to the end.
- mov r1, r6
- add r1, #0x7C
- mov r0, #0x1 @ I am going to assume that this value is a boolean that
- strb r0, [r1, #0x0] @ determines if it is not going to play the 'tink' noise.
- @ Function begin.
- IFH_FUNC:
- push {r1-r3} @ R0 is clobbered upon return anyway.
- push {r5, r7}
- push {r4}
- ldsh r1, [r4, #0x4] @ If damage is 0 anyway, just return.
- cmp r1, #0x0
- ble CLEANUP
- ldr r0, WRITE_PTRS
- ldr r5, [r0, #0x0] @ r5 is the table offset.
- mov r7, #0x34 @ r7 is the size of one entry.
- ldr r3, [r0, #0x4] @ Prepare r3...
- ldr r3, [r3, #0x0] @ So we can set it as the table.
- mov r2, #0x0 @ r2 is our counting register.
- mov r4, r8 @ Prepare r4...
- ldr r1, [r4, #0x0] @ To load the enemy pointer.
- CHECK_LOOP:
- ldrb r0, [r3, r2] @ Load character from the loop.
- cmp r0, #0x0 @ Check for terminator.
- beq PASS
- mul r0, r0, r7
- add r0, r0, r5 @ Set up r0.
- cmp r0, r1
- beq PASS
- add r2, r2, #0x1
- b CHECK_LOOP @ Continue loop.
- PASS:
- cmp r0, #0x0 @ If r0 is anything but 0, we found something.
- bne TRUE
- FALSE:
- cmp r4, r8 @ HACK - Check if we are on enemy or player.
- beq CLEANUP
- b NEGATE
- TRUE:
- cmp r4, r8 @ If only I could do this only once...
- bne CLEANUP
- CONTINUE:
- mov r4, r6 @ Set up r4 for the player table.
- ldr r1, [r4, #0x0] @ r1 = attacking character
- ldr r3, [r0, #0x8] @ r3 = offset of attacking characters
- b CHECK_LOOP @ and back into the loop we go!
- NEGATE:
- pop {r4}
- mov r0, #0x0 @ Set damage to zero.
- strh r0, [r4, #0x4] @ Store it as damage.
- CLEANUP:
- @ FIXME: Cleanup is ugly.
- cmp r4, r7 @ If r4 is equal to r7 or r8, then we
- bne RETURN @ have not popped it to store negated
- cmp r4, r8 @ damage to memory yet.
- bne RETURN
- pop {r4}
- RETURN:
- @ NOTE: This ugly-looking bunch of pops are to ensure that the stack
- @ is purged properly. And then the last two are to mimic the original.
- pop {r5, r7}
- pop {r1-r3}
- pop {r4-r6}
- pop {r0}
- bx r0
- .align 2
- WRITE_PTRS:
- .set END_VAL, 0x0000
- @ Table value
- .long 0x08BDCE18
- @ HACKY
- .set ENEMY_VAL, IFH_HACK_ORG + (ENEMY_TABLE - IFH_HACK_ST)
- .long ENEMY_VAL
- .set ALLY_VAL, IFH_HACK_ORG + (ALLY_TABLE - IFH_HACK_ST)
- .long ALLY_VAL
- ENEMY_TABLE:
- @ Default values
- .byte 0x44
- .byte 0x00
- .short END_VAL
- ALLY_TABLE:
- .byte 0x14
- .byte 0x00
- .short END_VAL
- IFH_HACK_END:
Add Comment
Please, Sign In to add comment