00175fa4 - 00176160

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
BATTLE.BIN : Height Check to reach the Chocobo ? 
-------------------------------------------------------------------------------------------------------
Parameters : r4 - ID of Unit on Destination Tile
             r5 - Preset Value ? (Only seen 0x00 so far)

Uses Data from ScratchPad 0x1f800000 - 0x1f800080 - 0x1f800180
Runs a bunch of checks relative to height and size of acting unit and unit present on destination Tile
If All checks are Ok : Store Data in Tile Grid Table (80192dd8) 
 - Load Origin Tile Grid 0x00 (AoE of Move) And Substract (1+Preset Value)
 - Store the result in Destination Tile Grid 0x03 (80192dd8) - 
 Looks like the movement cost to reach the tile. (It's a guess for now)
---------------------------------------------------------------------------------------------------------
00175fa4: 00a05821 addu r11,r5,r0           |Preset value
00175fa8: 00802821 addu r5,r4,r0            |Unit ID (on Tile)
00175fac: 3c078019 lui r7,0x8019            |
00175fb0: 8ce7f4e4 lw r7,-0x0b1c(r7)        |Pointer to Scratch Pad ( 0x1f800180 )
00175fb4: 3c098019 lui r9,0x8019            |
00175fb8: 8d29f4e0 lw r9,-0x0b20(r9)        |Pointer to Scratch Pad ( 0x1f800000 )
00175fbc: 3c068019 lui r6,0x8019            |
00175fc0: 8cc6f4e8 lw r6,-0x0b18(r6)        |Poiter to Other units Scratchpad ( 0x1f800080 )
00175fc4: 90e20048 lbu r2,0x0048(r7)        |Origin Tile Exit Height / Acting Unit Height + Size
00175fc8: 9124001b lbu r4,0x001b(r9)        |Acting Unit Size
00175fcc: 90e30047 lbu r3,0x0047(r7)        |Destination Ceiling Distance
00175fd0: 00441021 addu r2,r2,r4            |Origin Tile Exit Height + Unit Size
00175fd4: 0062182a slt r3,r3,r2             |
00175fd8: 14600060 bne r3,r0,0x0017615c     #If Destination Ceiling is lower than Origin height + Unit Size  Exit routine
00175fdc: 25620001 addiu r2,r11,0x0001          |
00175fe0: 8ce40010 lw r4,0x0010(r7)         |Pointer to Origin Tile's Grid data
00175fe4: 00000000 nop                      |
00175fe8: 90830000 lbu r3,0x0000(r4)        |Load Aoe/Move
00175fec: 00000000 nop                      |
00175ff0: 00626023 subu r12,r3,r2           |Move - PV + 1
00175ff4: 318a00ff andi r10,r12,0x00ff      |
00175ff8: 11400058 beq r10,r0,0x0017615c    #If Movement left = 0   Exit routine
00175ffc: 00000000 nop                          |
00176000: 90820003 lbu r2,0x0003(r4)        |Grid 0x03
00176004: 00000000 nop                      |
00176008: 0142102b sltu r2,r10,r2           |
0017600c: 14400053 bne r2,r0,0x0017615c     #If Movement left < Tile's Grid 0x03   Exit routine Movement cost ?
00176010: 00000000 nop                          |
00176014: 90e20059 lbu r2,0x0059(r7)        |Destination Slope Type
00176018: 90e30045 lbu r3,0x0045(r7)        |Destination Entry Slope Mod
0017601c: 90e4004d lbu r4,0x004d(r7)        |Destination Height*2
00176020: 00621007 srav r2,r2,r3            |
00176024: 90e30057 lbu r3,0x0057(r7)        |Destination Halves
00176028: 30420003 andi r2,r2,0x0003        |Entry Slope Type
0017602c: 00620018 mult r3,r2               |
00176030: 30a200ff andi r2,r5,0x00ff        |
00176034: 000228c0 sll r5,r2,0x03           |
00176038: 00a22823 subu r5,r5,r2            |Unit ID * 7
0017603c: 00a62821 addu r5,r5,r6            |Pointer to Unit data in S-Pad 0x080
00176040: 8ce20004 lw r2,0x0004(r7)         |Pointer to Destination data (8018f8cc)
00176044: 90a80005 lbu r8,0x0005(r5)        |Destination Unit Height
00176048: 90430003 lbu r3,0x0003(r2)        |Destination Halves + depth
0017604c: 90a20004 lbu r2,0x0004(r5)        |Destination Unit Size
00176050: 00031942 srl r3,r3,0x05           |Depth only
00176054: 00031840 sll r3,r3,0x01           |Depth * 2
00176058: 01021021 addu r2,r8,r2            |Unit Height + Unit Size
0017605c: 00003012 mflo r6                  |Destination Entry Slope Height
00176060: 00862021 addu r4,r4,r6            |Destination Entry Height
00176064: 00832021 addu r4,r4,r3            |Destination Entry Height + Depth
00176068: 00401821 addu r3,r2,r0            |Unit Height + Unit Size
0017606c: 308200ff andi r2,r4,0x00ff        |
00176070: 0102102b sltu r2,r8,r2            |0x1 if Present Unit Tile's Height < Destination Entry Height + Depth * 2
00176074: 10400002 beq r2,r0,0x00176080     #If There is depth ?
00176078: 306300ff andi r3,r3,0x00ff            |
0017607c: 00804021 addu r8,r4,r0                |Present Unit height + depth
00176080: 01002821 addu r5,r8,r0            |Height or Height + depth 
00176084: 30a400ff andi r4,r5,0x00ff        |Height or Height + depth 
00176088: 0064102b sltu r2,r3,r4            |0x1 if Unit height + Size < Height +/- Depth 
0017608c: 14400033 bne r2,r0,0x0017615c     #If Unit is below water level  Exit routine
00176090: 00000000 nop                          |
00176094: 01404021 addu r8,r10,r0           |Movement left
00176098: 00603021 addu r6,r3,r0            |Unit Height + Unit Size
0017609c: 9123001b lbu r3,0x001b(r9)        |Acting Unit Size
001760a0: 90e20046 lbu r2,0x0046(r7)        |Origin ceiling height
001760a4: 00831821 addu r3,r4,r3            |Destination Unit Height + Acting Unit Size
001760a8: 0043102a slt r2,r2,r3             |
001760ac: 1440002b bne r2,r0,0x0017615c     #If Destination's Unit Height + Acting Unit Size < Origin Ceiling height  Exit routine
001760b0: 00000000 nop                          |
001760b4: 90e20047 lbu r2,0x0047(r7)        |Destination Ceiling height
001760b8: 00000000 nop                      |
001760bc: 0043102a slt r2,r2,r3             |
001760c0: 14400026 bne r2,r0,0x0017615c     #If Destination ceiling < Destination Unit height + Acting  Unit size' # Exit routine'
001760c4: 00000000 nop                          |
001760c8: 90e20048 lbu r2,0x0048(r7)        |Origin Exit Side Height
001760cc: 00000000 nop                      |
001760d0: 0044102b sltu r2,r2,r4            |
001760d4: 1040000c beq r2,r0,0x00176108     #If Origin Exit Height < Destination Height Move Up
001760d8: 00000000 nop                          |
001760dc: 1560001f bne r11,r0,0x0017615c        #if Preset Value is <> 0x00  Exit routine
001760e0: 00000000 nop                              |
001760e4: 90e20048 lbu r2,0x0048(r7)            |Origin Side Height
001760e8: 91230002 lbu r3,0x0002(r9)            |Acting Unit Jump
001760ec: 00a21023 subu r2,r5,r2                |Destination Height - Origin Height
001760f0: 304200ff andi r2,r2,0x00ff            |
001760f4: 0062182b sltu r3,r3,r2                |
001760f8: 14600018 bne r3,r0,0x0017615c         #If Acting Unit Jump is insufficient  Exit routine
001760fc: 00000000 nop                              |
00176100: 0805d849 j 0x00176124                 >>Avoid Move down section
00176104: 00000000 nop                              |
                                            Else : Origin Exit Height > Destination Height
00176108: 90e20048 lbu r2,0x0048(r7)            |Origin Side Height
0017610c: 91230002 lbu r3,0x0002(r9)            |Acting Unit Jump
00176110: 00451023 subu r2,r2,r5                |Origin Height - Destination Height
00176114: 304200ff andi r2,r2,0x00ff            |
00176118: 0062182b sltu r3,r3,r2                |
0017611c: 1460000a bne r3,r0,0x00176148         #If Jump is insufficient : Branch below to eventually try again
00176120: 00000000 nop                              |
00176124: 8ce3000c lw r3,0x000c(r7)         |Pointer to Destination grid data
00176128: 00000000 nop                      |
0017612c: 90620003 lbu r2,0x0003(r3)        |Grid 0x03
00176130: 00000000 nop                      |
00176134: 0048102b sltu r2,r2,r8            |1 if Grid 0x03 < 
00176138: 10400008 beq r2,r0,0x0017615c     #If Tile 0x03 > Movement left  Exit routine
0017613c: 00000000 nop                          |
00176140: 0805d857 j 0x0017615c             | Exit routine
00176144: a06c0003 sb r12,0x0003(r3)        |Store AoE/Move - (PV +1)
Climb down insufficient Jump
00176148: 24a50001 addiu r5,r5,0x0001           |Destination Height + 1
0017614c: 30a400ff andi r4,r5,0x00ff            |
00176150: 00c4102b sltu r2,r6,r4                |0x01 If Unit Height + Unit Size < Destination Height +1
00176154: 1040ffd1 beq r2,r0,0x0017609c         #If Destination Unit Height + Unit Size > Destination Height +1 branch backward to check heights Wtf
00176158: 00000000 nop                              |
0017615c: 03e00008 jr r31                   END
00176160: 00000000 nop

Return Locations

BATTLE.BIN
00175ad4: Movement_routine