Calculate Projected Action Effect

From Final Fantasy Hacktics Wiki
Revision as of 03:18, 23 September 2016 by Glain (talk | contribs) (Created page with " # ROUTINE: CALCULATE PROJECTED ACTION EFFECT # Parameters: # r4 = [Acting unit (in-battle data pointer)] # r5 = [Target unit (in-battle data po...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
#   ROUTINE: CALCULATE PROJECTED ACTION EFFECT
#       Parameters:
#           r4 = [Acting unit (in-battle data pointer)]
#           r5 = [Target unit (in-battle data pointer)]
#           r6 = [Current used action data (from misc unit data of Acting unit)]
#       Returns:
#           r2 = 0 (Always.)

0017f17c: 27bdffd0 addiu r29,r29,-0x0030
0017f180: afb30024 sw r19,0x0024(r29)
0017f184: 00809821 addu r19,r4,r0
0017f188: afb20020 sw r18,0x0020(r29)
0017f18c: 00a09021 addu r18,r5,r0
0017f190: afb1001c sw r17,0x001c(r29)
0017f194: 00c08821 addu r17,r6,r0
0017f198: afb00018 sw r16,0x0018(r29)
0017f19c: 2670016e addiu r16,r19,0x016e             
0017f1a0: 02002021 addu r4,r16,r0                   #   Parameter 1: Source pointer = [Acting unit's last used action data]
0017f1a4: 3c058019 lui r5,0x8019
0017f1a8: 24a53848 addiu r5,r5,0x3848               #   Parameter 2: Destination pointer = [Temp last used action data]
0017f1ac: afbf002c sw r31,0x002c(r29)
0017f1b0: 0c01788b jal 0x0005e22c                   #   ROUTINE: Copy Byte Data (20 Bytes)
0017f1b4: afb40028 sw r20,0x0028(r29)
0017f1b8: 02202021 addu r4,r17,r0                   #   Parameter 1: Source pointer = [Current used action data]
0017f1bc: 0c01788b jal 0x0005e22c                   #   ROUTINE: Copy Byte Data (20 Bytes)
0017f1c0: 02002821 addu r5,r16,r0                   #   Parameter 2: Destination pointer = [Acting unit's last used action data]
0017f1c4: 0c05f528 jal 0x0017d4a0                   #   ROUTINE: Store Global Action Variables
0017f1c8: 02602021 addu r4,r19,r0                   #   Parameter 1: Acting unit (in-battle data)
0017f1cc: 3c148019 lui r20,0x8019
0017f1d0: 8e94f5fc lw r20,-0x0a04(r20)              #   [Old action consideration status] = [Action consideration status]
0017f1d4: 3c028019 lui r2,0x8019
0017f1d8: 9042f7ec lbu r2,-0x0814(r2)               #   Used Ability Flags 1
0017f1dc: 34030002 ori r3,r0,0x0002
0017f1e0: 3c018019 lui r1,0x8019
0017f1e4: ac23f5fc sw r3,-0x0a04(r1)                #   Save action consideration status as checking projected effect (projected damage, status, etc.)
0017f1e8: 30420002 andi r2,r2,0x0002                #   Used Ability Auto-Target status
0017f1ec: 1440001c bne r2,r0,0x0017f260             #   If (Used Ability is not Auto-Target) {
0017f1f0: 02202021 addu r4,r17,r0                   #       Parameter 1: [Current used action data]
0017f1f4: 0c05f349 jal 0x0017cd24                   #       ROUTINE: [Target valid] = Map Calculations for Action
0017f1f8: 27a50010 addiu r5,r29,0x0010              #       Parameter 2: Output parameter: Used ability's Flags 3, or 0 if used ability isn't an action ability (Result never seems to be checked anyway.)
0017f1fc: 00408021 addu r16,r2,r0                   
0017f200: 2411ffff addiu r17,r0,0xffff
                                                    #       skipNextSection = false
0017f204: 1211000e beq r16,r17,0x0017f240           #       If ([Target valid]) {
0017f208: 00000000 nop
0017f20c: 0c060428 jal 0x001810a0                   #           ROUTINE: Map Location Calculation (Returns [Tile Number] = Z * 256 + Y * Max X + X, where Z = [Higher Elevation bit])
0017f210: 02402021 addu r4,r18,r0                   #           Parameter 1: Target unit (in-battle data)
0017f214: 000210c0 sll r2,r2,0x03                   #           Tile Number * 8
0017f218: 3c018019 lui r1,0x8019
0017f21c: 00220821 addu r1,r1,r2
0017f220: 9022f8d1 lbu r2,-0x072f(r1)               #           Load Tile byte 0x05 for this Tile Number
0017f224: 00000000 nop
0017f228: 000211c2 srl r2,r2,0x07                   #           Check Green Panel (Target in Range)
0017f22c: 14400002 bne r2,r0,0x0017f238             #           If (Not Green Panel (Target Not in Range)) {
0017f230: 00000000 nop
0017f234: 2410ffff addiu r16,r0,-0x0001             #               [Target valid] = false
                                                    #           }
                                                    #       }
0017f238: 16110009 bne r16,r17,0x0017f260           #       If (Not [Target valid]) {
0017f23c: 00000000 nop
                                                    #           
0017f240: 0c062f5d jal 0x0018bd74                   #           ROUTINE: Current Action Data Nulling (Initialize Action)
0017f244: 2644018c addiu r4,r18,0x018c              #           Parameter 1: Action (affecting Target)
0017f248: 3c048019 lui r4,0x8019
0017f24c: 24843848 addiu r4,r4,0x3848               #           Parameter 1: [Temp last used action data]
0017f250: 2665016e addiu r5,r19,0x016e              #           Parameter 2: [Acting unit's last used action data]
0017f254: a240018c sb r0,0x018c(r18)                #           Action Hit status = Miss
0017f258: 0805fca8 j 0x0017f2a0                     #           skipNextSection = true
0017f25c: a64001b6 sh r0,0x01b6(r18)                #           Action's Displayed [Hit %] = 0
                                                    #       }
                                                    #   }
                                                    #   if (Not (skipNextSection)) {
0017f260: 3c118019 lui r17,0x8019
0017f264: 8e31f5f0 lw r17,-0x0a10(r17)              #       [Old Type of Action] = [Type of Action]
0017f268: 2670016e addiu r16,r19,0x016e             #       [Acting unit's last used action data]
0017f26c: 3c018019 lui r1,0x8019
0017f270: a02038e9 sb r0,0x38e9(r1)                 #       [Defaults to Weapon Attack] = 0
0017f274: 3c018019 lui r1,0x8019
0017f278: ac20f5f0 sw r0,-0x0a10(r1)                #       [Type of Action] = 0 (pre-attack)
0017f27c: 9245018a lbu r5,0x018a(r18)               #       Parameter 2: Target's Unit ID (without "Unit Exists" check)
0017f280: 02002021 addu r4,r16,r0                   #       Parameter 1: [Acting unit's last used action data]
0017f284: 0c062cd3 jal 0x0018b34c                   #       ROUTINE: Execute Action Formula (Calculate Action Parameters)
0017f288: a640019a sh r0,0x019a(r18)                #       Action's [Reaction ID] = 0
0017f28c: 3c048019 lui r4,0x8019
0017f290: 24843848 addiu r4,r4,0x3848               #       Parameter 1: [Temp last used action data]
0017f294: 02002821 addu r5,r16,r0                   #       Parameter 2: [Acting unit's last used action data]
0017f298: 3c018019 lui r1,0x8019
0017f29c: ac31f5f0 sw r17,-0x0a10(r1)               #       [Type of Action] = [Old Type of Action] 
                                                    #   }
0017f2a0: 3c018019 lui r1,0x8019
0017f2a4: ac34f5fc sw r20,-0x0a04(r1)               #   [Action consideration status] = [Old action consideration status]
0017f2a8: 0c01788b jal 0x0005e22c                   #   ROUTINE: Copy Byte Data (20 Bytes)
0017f2ac: 00000000 nop
0017f2b0: 00001021 addu r2,r0,r0                    #   Return 0
0017f2b4: 8fbf002c lw r31,0x002c(r29)
0017f2b8: 8fb40028 lw r20,0x0028(r29)
0017f2bc: 8fb30024 lw r19,0x0024(r29)
0017f2c0: 8fb20020 lw r18,0x0020(r29)
0017f2c4: 8fb1001c lw r17,0x001c(r29)
0017f2c8: 8fb00018 lw r16,0x0018(r29)
0017f2cc: 27bd0030 addiu r29,r29,0x0030
0017f2d0: 03e00008 jr r31
0017f2d4: 00000000 nop