Store target coordinates, attack display types

From Final Fantasy Hacktics Wiki
(Redirected from Ability effect calculations)
Jump to navigation Jump to search
Parameters : r4 = used ability ID
             r5 = Acting unit misc data pointer
Returns nothing

Hard coded mechanics : 
 - Elemental gun displaying not showing rays based on Item ID (0x4a to 0x4c)
 - Ability Ball (Ninja), animation loaded for a raw offset of 0x189 * 3 (not based on ability ID) 
----------------------------------------------------------------------------------------------------
000736d4: 27bdff00 addiu r29,r29,-0x0100    |
000736d8: afb300f4 sw r19,0x00f4(r29)       |
000736dc: 00a09821 addu r19,r5,r0           |r19 = Acting unit misc data pointer
000736e0: afbf00fc sw r31,0x00fc(r29)       |
000736e4: afb400f8 sw r20,0x00f8(r29)       |
000736e8: afb200f0 sw r18,0x00f0(r29)       |
000736ec: afb100ec sw r17,0x00ec(r29)       |
000736f0: afb000e8 sw r16,0x00e8(r29)       |
000736f4: 9262018d lbu r2,0x018d(r19)       |Load Target counter
000736f8: a7a000b4 sh r0,0x00b4(r29)        |
000736fc: a7a20010 sh r2,0x0010(r29)        |Store Target counter on Stack 0x10
00073700: 92620004 lbu r2,0x0004(r19)       |Load Acting Unit Misc ID
00073704: 0080a021 addu r20,r4,r0           |r20 = Used Ability ID
00073708: a3a200b6 sb r2,0x00b6(r29)        |Store Acting unit misc ID on Stack 0xb6
0007370c: 926501a8 lbu r5,0x01a8(r19)       |Load Target X coordinate
00073710: 926601aa lbu r6,0x01aa(r19)       |Load Target elevation
00073714: 926701a9 lbu r7,0x01a9(r19)       |Load Target Y coordinate
00073718: 0c010ac7 jal 0x00042b1c           |-->Store Coordinates on r4 Store Target X on Stack 0xce,Elevation on Stack 0xd0, Y on Stack 0xd2
0007371c: 27a400ce addiu r4,r29,0x00ce      |r4 = Stack 0xce
00073720: 97a20010 lhu r2,0x0010(r29)       |Load Target counter
00073724: 00000000 nop                      |
00073728: 1040002a beq r2,r0,0x000737d4     #If There's at least one Target
0007372c: 2672018c addiu r18,r19,0x018c     |r18 = Misc Acting unit current action pointer
00073730: 10400038 beq r2,r0,0x00073814         #If There's no Target Branch After loop (never true..)
00073734: 00008021 addu r16,r0,r0               |Initialize counter 1
00073738: 00008821 addu r17,r0,r0               |Initialize unit offset on stack 
                                                @LOOP - through all targets  
0007373c: 02501021 addu r2,r18,r16                  |r2 = This iteration Misc current action data pointer
00073740: 90440002 lbu r4,0x0002(r2)                |r4 = Target ID (from Targets list) Misc 0x18e + counter
00073744: 0c01e9c9 jal 0x0007a724                   |-->Get_unit_misc_data_that_matches_r4_ID Returns r2 = This iteration Target misc data pointer
00073748: 00000000 nop                              |
0007374c: 27a30010 addiu r3,r29,0x0010              |r3 = Target counter stack pointer
00073750: 00712021 addu r4,r3,r17                   |r4 = This iteration Target stack pointer (offset is 0x0a per unit)
00073754: a4800004 sh r0,0x0004(r4)                 |Initialize data
00073758: 90430004 lbu r3,0x0004(r2)                |Load this iteration Target Misc ID
0007375c: 00000000 nop                              |
00073760: a0830006 sb r3,0x0006(r4)                 |Store misc ID on Stack This unit data 0x06
00073764: 8c430134 lw r3,0x0134(r2)                 |Load This iteration Target data pointer
00073768: 00000000 nop                              |
0007376c: 10600011 beq r3,r0,0x000737b4             #If pointer is valid /Else branch to next iteration (store 0x00 on stack)
00073770: 00000000 nop                                  |
00073774: 9062018d lbu r2,0x018d(r3)                    |Load Target current action critical hit flag
00073778: 00000000 nop                                  |
0007377c: 10400003 beq r2,r0,0x0007378c                 #If Target is receiving a critical Hit
00073780: 34020001 ori r2,r0,0x0001                         |r2 = 0x01
00073784: 0801cdee j 0x000737b8                             >>jump to next iteration
00073788: a0820007 sb r2,0x0007(r4)                         |Store display type = 01 - critical hit? This unit data 0x07
                                                        #Else : not a critical hit
0007378c: 9063018e lbu r3,0x018e(r3)                        |Load Target current action evade type
00073790: 34020009 ori r2,r0,0x0009                         |0x09 is reflected
00073794: 14620003 bne r3,r2,0x000737a4                     #If Target will use reflect
00073798: 34020002 ori r2,r0,0x0002                             |
0007379c: 0801cdee j 0x000737b8                                 >>jump to next iteration
000737a0: a0820007 sb r2,0x0007(r4)                             |store display type = 02 - reflected
                                                            #Else : not reflected
000737a4: 10600003 beq r3,r0,0x000737b4                         #If Attack is evaded
000737a8: 34020003 ori r2,r0,0x0003                                 |
000737ac: 0801cdee j 0x000737b8                                     >>jump to next iteration
000737b0: a0820007 sb r2,0x0007(r4)                                 |store display type = 03 - evaded
                                                                #Else : not evaded
000737b4: a0800007 sb r0,0x0007(r4)                                 |store display type = 00 - default
000737b8: 97a20010 lhu r2,0x0010(r29)               |Load Target counter
000737bc: 26100001 addiu r16,r16,0x0001             |Increase loop counter (+1)
000737c0: 0202102a slt r2,r16,r2                    |Check loop limit
000737c4: 1440ffdd bne r2,r0,0x0007373c         Λ loop while Counter < Target counter
000737c8: 2631000a addiu r17,r17,0x000a             |Unit stack offset (+0x0a)
000737cc: 0801ce06 j 0x00073818                 >>Jump after No target section
000737d0: 00008821 addu r17,r0,r0               |
                                            #Else : No Targets
000737d4: 9262019e lbu r2,0x019e(r19)           |Load animate on miss flag
000737d8: 00000000 nop                          |
000737dc: 1440000e bne r2,r0,0x00073818         #If Animate on miss is ON
000737e0: 00008821 addu r17,r0,r0                   |
000737e4: 34020001 ori r2,r0,0x0001                 |
000737e8: a7a20010 sh r2,0x0010(r29)                |Force Target counter to 1
000737ec: a7a20014 sh r2,0x0014(r29)                |Store 0x01 at Stack 0x14 store animate on miss flag?
000737f0: 926201a8 lbu r2,0x01a8(r19)               |Load X coordinate
000737f4: 00000000 nop                              |
000737f8: a7a20016 sh r2,0x0016(r29)                |Store X at Stack 0x16
000737fc: 926201a9 lbu r2,0x01a9(r19)               |Load Y coordinate
00073800: 00000000 nop                              |
00073804: a7a2001a sh r2,0x001a(r29)                |Store Y at Stack 0x1a
00073808: 926201aa lbu r2,0x01aa(r19)               |Load map level aka elevation
0007380c: 00000000 nop                              |
00073810: a7a20018 sh r2,0x0018(r29)                |Store elevation at Stack 0x18
00073814: 00008821 addu r17,r0,r0           |Initialize counter of non targeted unit
00073818: 00008021 addu r16,r0,r0           |Initialize loop counter
                                            @LOOP - Through all units and distribute them on Stack (targeted or not)
0007381c: 92620004 lbu r2,0x0004(r19)           |Load attacker misc ID
00073820: 00000000 nop                          |
00073824: 12020022 beq r16,r2,0x000738b0        #Branch if This iteration unit is attacker Attacker ID = 0x00
00073828: 00000000 nop                              |
0007382c: 0c01e9b9 jal 0x0007a6e4                   |-->Get_unit_misc_data_that_matches_r4_ID Returns r2 = This iteration Target misc data pointer
00073830: 3204ffff andi r4,r16,0xffff               |r4 = This iteration unit ID
00073834: 00403021 addu r6,r2,r0                    |r6 = This iteration Unit misc data pointer
00073838: 10c0001d beq r6,r0,0x000738b0             #If Misc data Pointer is invalid :  Branch to next iteration
0007383c: 00000000 nop                                  |
00073840: 8cc20134 lw r2,0x0134(r6)                 |r2 = This iteration Target data pointer
00073844: 00000000 nop                              |
00073848: 10400019 beq r2,r0,0x000738b0             #If Data pointer is invalid :  Branch to next iteration
0007384c: 00000000 nop                                  |
00073850: 92450001 lbu r5,0x0001(r18)               |Load Target hit counter
00073854: 00000000 nop                              |
00073858: 18a00010 blez r5,0x0007389c               #If There is at least one Target
0007385c: 00001821 addu r3,r0,r0                        |r3 = 0x00
00073860: 9044018a lbu r4,0x018a(r2)                    |This iteration Target raw ID
00073864: 02431021 addu r2,r18,r3                       |Pointer to Target List 
                                                        @LOOP - check if unit is on Target list
00073868: 90420002 lbu r2,0x0002(r2)                        |Load this iteration Target ID (from list)
0007386c: 00000000 nop                                      |
00073870: 10820005 beq r4,r2,0x00073888                     #If This Target = this iteration unit : Exit Loop
00073874: 00000000 nop                                          |
00073878: 24630001 addiu r3,r3,0x0001                       |loop counter + 1
0007387c: 0065102a slt r2,r3,r5                             |Check if end of list is reached
00073880: 1440fff9 bne r2,r0,0x00073868                 Λ loop until end of list
00073884: 02431021 addu r2,r18,r3                           |Increase Target list offset
00073888: 92420001 lbu r2,0x0001(r18)                   |Load Target counter
0007388c: 00000000 nop                                  |
00073890: 0062102a slt r2,r3,r2                         |r2 = 0x01 if End of Target list has not been reached = Unit is on the list
00073894: 14400006 bne r2,r0,0x000738b0                 #If Unit has not been spoted in the target list
00073898: 00000000 nop                                      |
0007389c: 27a200be addiu r2,r29,0x00be                      |r2 = Stack 0xbe pointer
000738a0: 00511021 addu r2,r2,r17                           |Stack 0xbe + Unit not on list counter
000738a4: 90c30004 lbu r3,0x0004(r6)                        |Load unit misc ID
000738a8: 26310001 addiu r17,r17,0x0001                     |Non target unit counter + 1
000738ac: a0430000 sb r3,0x0000(r2)                         |Store misc ID on stack
000738b0: 26100001 addiu r16,r16,0x0001         |Counter + 1
000738b4: 2a020010 slti r2,r16,0x0010           |Check loop limit
000738b8: 1440ffd8 bne r2,r0,0x0007381c     Λ loop through all units
000738bc: 00000000 nop                          |
000738c0: a3b10012 sb r17,0x0012(r29)       |Store Non Targeted unit counter on Stack 0x12
000738c4: 92420013 lbu r2,0x0013(r18)       |Load Math Skill flag (0x00 or 0x01)
000738c8: 00000000 nop                      |
000738cc: a3a20013 sb r2,0x0013(r29)        |Store Math skill flag on stack 0x13
000738d0: 9242001f lbu r2,0x001f(r18)       |load used weapon ID
000738d4: 00000000 nop                      |
000738d8: a7a200d6 sh r2,0x00d6(r29)        |Store used weapon ID on stack 0xd6
000738dc: 86420014 lh r2,0x0014(r18)        |load used ability iD
000738e0: 00000000 nop                      |
000738e4: 10400014 beq r2,r0,0x00073938     #If used Ability is 0x00 (Attack) branch to  No Animation prep section
000738e8: 00002021 addu r4,r0,r0            |r4 = 0x00
000738ec: 92420017 lbu r2,0x0017(r18)       |Load OnGoing Proc flag
000738f0: 00000000 nop                      |
000738f4: 14400010 bne r2,r0,0x00073938     #If Ongoing Ability proc : branch to  No Animation prep section
000738f8: 34020001 ori r2,r0,0x0001         |r2 = 0x01
000738fc: 3c038009 lui r3,0x8009            |
00073900: 8c636214 lw r3,0x6214(r3)         |Load Action phase
00073904: 00000000 nop                      |
00073908: 1462000b bne r3,r2,0x00073938     #If Action phase <> 0x01 (post action phase) : branch to  No Animation prep section
0007390c: 00000000 nop                      |
00073910: 9262013a lbu r2,0x013a(r19)       |load weapon ID
00073914: 00000000 nop                      |
00073918: 2442ffb6 addiu r2,r2,-0x004a      |
0007391c: 2c420002 sltiu r2,r2,0x0002       |Check if used weapon ID is Blaze Gun or Glacier gun
00073920: 14400005 bne r2,r0,0x00073938     #If using Blaze or Glacier gun : branch to  No Animation prep section
00073924: 3402004c ori r2,r0,0x004c         |
00073928: 9265013a lbu r5,0x013a(r19)       |load used weapon ID
0007392c: 00000000 nop                      |
00073930: 14a20003 bne r5,r2,0x00073940     #If using a blast Gun /Else avoid No animation section
00073934: 34020189 ori r2,r0,0x0189             |
    ----No Animation Prep section----
00073938: 0801ce68 j 0x000739a0                 >>Jump to Ability effect prep with r4 = 0x00 (no animation)
0007393c: 02802821 addu r5,r20,r0               |return ability ID
    ----Ninja Ball Section----
00073940: 1682000a bne r20,r2,0x0007396c    #If used Ability is Ninja Ball
00073944: 00141040 sll r2,r20,0x01          |Ability ID*2
00073948: 000510c0 sll r2,r5,0x03               |Weapon ID*8 (8 = size of weapon data)
0007394c: 3c018006 lui r1,0x8006                |
00073950: 00220821 addu r1,r1,r2                |8006 + weapon offset
00073954: 90223abe lbu r2,0x3abe(r1)            |load weapon element (0xEE) 0x80063ab8 + 0x06 + weapon offset
00073958: 3c048009 lui r4,0x8009                |
0007395c: 908442ab lbu r4,0x42ab(r4)            |load ball ability animation flag 1 (0xFF) 0x80093e10 + 3*0x189
00073960: 00021400 sll r2,r2,0x10               |r2 = 0xEE0000
00073964: 0801ce67 j 0x0007399c                 |
00073968: 00822025 or r4,r4,r2                  |r4 = 0xEE00FF
    ----Standard Ability section----
0007396c: 00541021 addu r2,r2,r20           |r2 = Ability ID*3 (3 = Ability Animation flags size)
00073970: 001418c0 sll r3,r20,0x03          |Ability ID*8
00073974: 00741823 subu r3,r3,r20           |Ability ID*7
00073978: 00031840 sll r3,r3,0x01           |Ability ID*14 (14 = Ability data 2 size) fbf7
0007397c: 3c018006 lui r1,0x8006            |
00073980: 00230821 addu r1,r1,r3            |
00073984: 9023fbf7 lbu r3,-0x0409(r1)       |Load Ability Element (0xEE) 0x8005fbf0 + 0x07 + Ability offset
00073988: 3c018009 lui r1,0x8009            |
0007398c: 00220821 addu r1,r1,r2            |
00073990: 90243e10 lbu r4,0x3e10(r1)        |Load Ability Animation flag 0x01 (0xFF)
00073994: 00031c00 sll r3,r3,0x10           |r3 = 0xEE0000
00073998: 00832025 or r4,r4,r3              |r4 = 0xEE00FF (Holds element and animation flag data)
    ----Go to Animation----
0007399c: 02802821 addu r5,r20,r0           |r5 = ability ID
000739a0: 0c06856d jal 0x001a15b4           |-->Ability_animation
000739a4: 27a60010 addiu r6,r29,0x0010      |r6 = Stack pointer 0x10
000739a8: 8fbf00fc lw r31,0x00fc(r29)       END
000739ac: 8fb400f8 lw r20,0x00f8(r29)
000739b0: 8fb300f4 lw r19,0x00f4(r29)
000739b4: 8fb200f0 lw r18,0x00f0(r29)
000739b8: 8fb100ec lw r17,0x00ec(r29)
000739bc: 8fb000e8 lw r16,0x00e8(r29)
000739c0: 27bd0100 addiu r29,r29,0x0100
000739c4: 03e00008 jr r31
000739c8: 00000000 nop


Return locations

Battle.bin
00073f9c: Set_damage_display_type_based_on_ability