Check and Spread Movement One Tile Around

From Final Fantasy Hacktics Wiki
Revision as of 10:54, 3 June 2023 by Orkney (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
BATTLE.BIN : Check and Spread Movement One Tile Around
----------------------------------------------------------------
No Parameters
Returns Nothing

Check and Spread two Paths around an Origin Tile.
- From Tile's ground : 4 directions, staying at ground or from above Units
- From a Unit : 4 directions Staying above units, or walking/flying above units (thanks stepping stone..) 
--------------------------------------------------------------------------------------------------------------
00175ea0: 27bdffc8 addiu r29,r29,-0x0038    |
00175ea4: afb20028 sw r18,0x0028(r29)       |
00175ea8: 3c128019 lui r18,0x8019           |
00175eac: 8e52f4e4 lw r18,-0x0b1c(r18)      |Pointer to Scratch Pad (0x1f800180)
00175eb0: afbf0030 sw r31,0x0030(r29)       |
00175eb4: afb3002c sw r19,0x002c(r29)       |
00175eb8: afb10024 sw r17,0x0024(r29)       |
00175ebc: 0c05d56a jal 0x001755a8           |-->Transfer_Tiles_Height_Halves_and_Slope_in_Scratch_Pad
00175ec0: afb00020 sw r16,0x0020(r29)       |
00175ec4: 92420054 lbu r2,0x0054(r18)       |Loop counter (0x8  : 4 direction and 2 Type of Checks)  0x24 when stop riding
00175ec8: 00000000 nop                      |
00175ecc: 1840002d blez r2,0x00175f84       #If Invalid :   Exit routine
00175ed0: 00008821 addu r17,r0,r0           |Initialize spreading counter
00175ed4: 3c138019 lui r19,0x8019           |
00175ed8: 2673f500 addiu r19,r19,-0x0b00    |Table of Spreading routines
00175edc: 2a220004 slti r2,r17,0x0004       |0x1 if Counter < 4
                                            @LOOP - 8 times (each direction - From Tile  and From Above Unit)
00175ee0: 38420001 xori r2,r2,0x0001            |Tile Vs Unit Flag (4 times 0x00 and then 0x1)
00175ee4: a2420040 sb r2,0x0040(r18)            |Store Tile Vs Unit flag
00175ee8: 06210002 bgez r17,0x00175ef4          #If Counter < 0x00 ??
00175eec: 02201021 addu r2,r17,r0                   |
00175ef0: 26220003 addiu r2,r17,0x0003              |Counter + 3
00175ef4: 00021083 sra r2,r2,0x02               |Counter /4 (0 or 1)
00175ef8: 00021080 sll r2,r2,0x02               |0 or 4
00175efc: 02221023 subu r2,r17,r2               |Cycle between 0 and 3
00175f00: 00021080 sll r2,r2,0x02               |Word offset ( 0 to c)
00175f04: 00531021 addu r2,r2,r19               |This iteration Pointer in Table of Spreading routines
00175f08: 8c420000 lw r2,0x0000(r2)             |Load Routine Address (based on direction)
00175f0c: 00000000 nop                          |
00175f10: 0040f809 jalr r2,r31                  |-->Jal to spreading routine Set value at 3a 3c 44 45
00175f14: 00000000 nop                          |
00175f18: 0c05d57a jal 0x001755e8               |-->Set_spreading_Tile_X_and_Y_coordinates
00175f1c: 00000000 nop                          |
00175f20: 0c05d586 jal 0x00175618               |-->Check_Spreading_Tile_Coordinates Returns r2 if Tile is valid
00175f24: 00000000 nop                          |
00175f28: 14400011 bne r2,r0,0x00175f70         #If Spreading Tile is invalid : branch to  Next iteration
00175f2c: 00000000 nop                              |
00175f30: 0c05d59f jal 0x0017567c               |-->Set Origin Height data returns r2 = 0 or 4 (Grid AoE tile)
00175f34: 02202021 addu r4,r17,r0               |Send Counter
00175f38: 1440000d bne r2,r0,0x00175f70         #If Spreading Tile's AoE >=2 Else nothing to spread
00175f3c: 00000000 nop                              |
00175f40: 92420055 lbu r2,0x0055(r18)               |Load Spread Loop counter
00175f44: 00000000 nop                              |
00175f48: 18400009 blez r2,0x00175f70               #If Counter is Valid
00175f4c: 00008021 addu r16,r0,r0                       |Initialize Loop counter
00175f50: 02002021 addu r4,r16,r0                       |Counter (For Jal)
                                                        @LOOP - 4 Times (Tile Path, Above Unit Path  - High and Low elevation)
00175f54: 0c05d656 jal 0x00175958                           |-->Movement_routine Spread AoE - Set AoE in Grid 0x00, Enable Flag 0x01 in S-Pad 0x200, Decrease Movement left
00175f58: 00002821 addu r5,r0,r0                            |Send 0x00
00175f5c: 92420055 lbu r2,0x0055(r18)                       |Loop counter
00175f60: 26100001 addiu r16,r16,0x0001                     |Counter + 1
00175f64: 0202102a slt r2,r16,r2                            |
00175f68: 1440fffa bne r2,r0,0x00175f54                 Λ Loop - 4 Times (Both elevation - 1 time for Flag 0x10 / 1 time for Flag 0x28)
00175f6c: 02002021 addu r4,r16,r0                           |
00175f70: 92420054 lbu r2,0x0054(r18)           |Load Loop limit
00175f74: 26310001 addiu r17,r17,0x0001         |Counter +1
00175f78: 0222102a slt r2,r17,r2                |
00175f7c: 1440ffd8 bne r2,r0,0x00175ee0     Λ Loop 8 Times
00175f80: 2a220004 slti r2,r17,0x0004           |
00175f84: 8fbf0030 lw r31,0x0030(r29)       END
00175f88: 8fb3002c lw r19,0x002c(r29)
00175f8c: 8fb20028 lw r18,0x0028(r29)
00175f90: 8fb10024 lw r17,0x0024(r29)
00175f94: 8fb00020 lw r16,0x0020(r29)
00175f98: 27bd0038 addiu r29,r29,0x0038
00175f9c: 03e00008 jr r31
00175fa0: 00000000 nop

Notes

Table of Spreading routines - 8018f500 
   0x00 - 801754d0 Spread_Move_to_East_Preset
   0x04 - 801754f4 Spread_Move_to_North_Preset
   0x08 - 8017551c Spread_Move_to_West_Preset
   0x0c - 80175540 Spread_Move_to_South_Preset

Return Location

BATTLE.BIN
00174d0c: 00174b8c_-_00174df4 
001787ec: Calculate_Pathing