Get number of clockticks till able to revive dead unit

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
BATTLE.BIN :  - Get number of clockticks till able to revive dead unit
------------------------------------------------------------------------------------------
Parameter : r4 = Unit Data pointer (Target)
Return : r2 = Nb of ClockTicks before end of death counter
         r2 = 0x7fffffff if not calculable
------------------------------------------------------------------------------------------
00199c88: 90860038 lbu r6,0x0038(r4)         |Unit Speed
00199c8c: 00000000 nop                       |
00199c90: 10c00010 beq r6,r0,0x00199cd4      #If Unit speed = 0 then  Exit and returns 0x7fffffff
00199c94: 3c027fff lui r2,0x7fff                 |
00199c98: 90820058 lbu r2,0x0058(r4)         |Unit Current Status set 1
00199c9c: 00000000 nop                       |
00199ca0: 30420020 andi r2,r2,0x0020         |
00199ca4: 1040000b beq r2,r0,0x00199cd4      #If Unit is has not dead status Exit and returns 0x7fffffff
00199ca8: 3c027fff lui r2,0x7fff                 |
00199cac: 9082005a lbu r2,0x005a(r4)         |Unit Current Status set 3
00199cb0: 00000000 nop                       |
00199cb4: 30420020 andi r2,r2,0x0020         |
00199cb8: 14400006 bne r2,r0,0x00199cd4      #If Dead Unit has reraise Exit and returns 0x7fffffff
00199cbc: 3c027fff lui r2,0x7fff                 |
00199cc0: 90830007 lbu r3,0x0007(r4)         |Unit Death counter
00199cc4: 340200ff ori r2,r0,0x00ff          |
00199cc8: 14620004 bne r3,r2,0x00199cdc      #If Unit death counter <> 0xff :  Go to get number of ticks section
00199ccc: 00602821 addu r5,r3,r0                 |Pass death counter on r5
00199cd0: 3c027fff lui r2,0x7fff             |
00199cd4: 08066746 j 0x00199d18              >>Else : If Unit death counter = 0xff Exit and returns 0x7fffffff
00199cd8: 3442ffff ori r2,r2,0xffff              |
                  Get number of Ticks (Dead unit- no reraise - valid speed - death counter <> 0xff)
00199cdc: 00051040 sll r2,r5,0x01                |Death counter (DC) * 2
00199ce0: 00451021 addu r2,r2,r5                 |DC * 3
00199ce4: 000210c0 sll r2,r2,0x03                |DC *24
00199ce8: 00451021 addu r2,r2,r5                 |DC *25
00199cec: 00022880 sll r5,r2,0x02                |DC *100
00199cf0: 90830039 lbu r3,0x0039(r4)             |Unit CT
00199cf4: 24a20064 addiu r2,r5,0x0064            |DC * 100 + 100
00199cf8: 00432823 subu r5,r2,r3                 |End of DC (practical)
00199cfc: 00a6001a div r5,r6                     |
00199d00: 00001812 mflo r3                       |End of DC / Speed
00199d04: 00001010 mfhi r2                       |Remainder CT
00199d08: 10400003 beq r2,r0,0x00199d18          #If remainder = 0x00  Exit and returns nb of clockticks before end of death counter
00199d0c: 00601021 addu r2,r3,r0                 |
00199d10: 24630001 addiu r3,r3,0x0001            |Add one turn to quotient
00199d14: 00601021 addu r2,r3,r0                 |If remainder <> 0x00 add one turn
00199d18: 03e00008 jr r31
00199d1c: 00000000 nop

Return locations

BATTLE.BIN
 0019b8a0: AI_Targeting_Matrix_Analysis_(0019b7b8)
 0019e7b4: AI_Ability_Use_Decisions