Set Reachable Tile Flag

From Final Fantasy Hacktics Wiki
(Redirected from 00175288 - 001754cc)
Jump to navigation Jump to search
BATTLE.BIN : Set Reachable Tile Flag
------------------------------------------------------------------------------------------------------------
Parameters : Nothing
Returns  : Nothing
           
Loop Through each Tile and enable Flag 0x20 on Byte 0x05 from Tile's data (8018f8cc)
Increment a reachable Tile counter in S-Pad 0x180 (0x18)
------------------------------------------------------------------------------------------------------------
00175288: 27bdffd8 addiu r29,r29,-0x0028    |
0017528c: afb10014 sw r17,0x0014(r29)       |
00175290: 3c118019 lui r17,0x8019           |
00175294: 8e31f4e0 lw r17,-0x0b20(r17)      |Pointer to scratch pad 0x1f800000
00175298: afbf0020 sw r31,0x0020(r29)       |
0017529c: afb3001c sw r19,0x001c(r29)       |
001752a0: afb20018 sw r18,0x0018(r29)       |
001752a4: afb00010 sw r16,0x0010(r29)       |
001752a8: 92230008 lbu r3,0x0008(r17)       |Active Unit Y
001752ac: 92220018 lbu r2,0x0018(r17)       |Map Max X
001752b0: 00000000 nop                      |
001752b4: 00620018 mult r3,r2               |
001752b8: 3c128019 lui r18,0x8019           |
001752bc: 8e52f4e4 lw r18,-0x0b1c(r18)      |Pointer to Scratch Pad 0x1f800180
001752c0: 3c108019 lui r16,0x8019           |
001752c4: 8e10f4f0 lw r16,-0x0b10(r16)      |Pointer to Scratch Pad 0x1f800200 (dynamic)
001752c8: 92220009 lbu r2,0x0009(r17)       |Active Unit Elevation
001752cc: 92240007 lbu r4,0x0007(r17)       |Active Unit X
001752d0: 00021200 sll r2,r2,0x08           |Elevation offset (0 or 0x100)
001752d4: 00001812 mflo r3                  |
001752d8: 00431021 addu r2,r2,r3            |
001752dc: 0c05d37e jal 0x00174df8           |-->Disable_Tile_Flag_0x10_For_Dead_and_Jumping_Units Check all units
001752e0: 00449821 addu r19,r2,r4           |Active Unit Tile's ID  (Y*Max X) + X + Elevation offset
001752e4: 00004021 addu r8,r0,r0            |Initialize Tile counter
001752e8: 00004821 addu r9,r0,r0            |Initialize Tile offset (+ 0x5 each iteration)
                                            @LOOP 0x200 Times (Each Tile)
001752ec: 000818c0 sll r3,r8,0x03               |Tile ID * 8
001752f0: 3c028019 lui r2,0x8019                |
001752f4: 2442f8cc addiu r2,r2,-0x0734          |
001752f8: 00622021 addu r4,r3,r2                |Pointer : This iteration Tile's data ( 8018f8cc )
001752fc: 90820005 lbu r2,0x0005(r4)            |Load Tile 0x05
00175300: 00000000 nop                          |
00175304: 304200df andi r2,r2,0x00df            |
00175308: a0820005 sb r2,0x0005(r4)             |Disable flag 0x20 and store data back
0017530c: 3c028019 lui r2,0x8019                |
00175310: 24422dd8 addiu r2,r2,0x2dd8           |
00175314: 11130061 beq r8,r19,0x0017549c        #If This Tile is the Actve Unit tile : branch to   Next Tile iteration
00175318: 01222821 addu r5,r9,r2                |Pointer : This iteration Tile's Grid data ( 80192dd8 )
0017531c: 9223000e lbu r3,0x000e(r17)           |Load Unit Move Type
00175320: 34020001 ori r2,r0,0x0001             |
00175324: 14620006 bne r3,r2,0x00175340         #If Unit is not Teleporting
00175328: 00000000 nop                              |
0017532c: 92020000 lbu r2,0x0000(r16)               |Load Tile's flag (S-Pad 0x200)
00175330: 00000000 nop                              |
00175334: 30420020 andi r2,r2,0x0020                |
00175338: 14400050 bne r2,r0,0x0017547c             #If Tile's 0x20 Flag is ON : branch to  Reachable Tile section
0017533c: 00000000 nop                                  |
00175340: 90a20003 lbu r2,0x0003(r5)            |Load Grid 0x03
00175344: 00000000 nop                          |
00175348: 10400005 beq r2,r0,0x00175360         #If Grid [0x03] <> 0x00  (Move cost from acting unit)
0017534c: 00000000 nop                              |
00175350: 92220016 lbu r2,0x0016(r17)               |Can Ride Flag Human not frog/chicken/charm
00175354: 00000000 nop                              |
00175358: 14400048 bne r2,r0,0x0017547c             #If Unit can ride : branch to  Reachable Tile section
0017535c: 00000000 nop                                  |
00175360: 90870003 lbu r7,0x0003(r4)            |Tile's Halves + Depth
00175364: 00000000 nop                          |
00175368: 30e3001f andi r3,r7,0x001f            |Halves only
0017536c: 28620003 slti r2,r3,0x0003            |
00175370: 14400006 bne r2,r0,0x0017538c         #If Halve >= 0x3
00175374: 00000000 nop                              |
00175378: 92020000 lbu r2,0x0000(r16)               |Load Tile's flags (S-Pad 0x200)
0017537c: 00000000 nop                              |
00175380: 30420002 andi r2,r2,0x0002                |
00175384: 14400045 bne r2,r0,0x0017549c             #If [0x02] is ON : branch to  Next Tile iteration
00175388: 00000000 nop                                  |
0017538c: 90a20000 lbu r2,0x0000(r5)            |Load Grid 0x00 (AoE)
00175390: 00000000 nop                          |
00175394: 10400041 beq r2,r0,0x0017549c         #If AoE = 0x00 : Branch to  Next Tile iteration
00175398: 28620004 slti r2,r3,0x0004                |
0017539c: 1040003f beq r2,r0,0x0017549c         #if Halves > 0x03 : Branch to  Next Tile iteration
001753a0: 00000000 nop                              |
001753a4: 90860006 lbu r6,0x0006(r4)            |Load Tile's 0x06
001753a8: 00000000 nop                          |
001753ac: 30c20080 andi r2,r6,0x0080            |
001753b0: 1440003a bne r2,r0,0x0017549c         #If Tile's 0x06 flag 0x80 is ON : Branch to  Next Tile iteration
001753b4: 00000000 nop                              |
001753b8: 90820000 lbu r2,0x0000(r4)            |Load Tile's Type
001753bc: 00000000 nop                          |
001753c0: 3045003f andi r5,r2,0x003f            |r5 = Tile's Type
001753c4: 3402001c ori r2,r0,0x001c             |
001753c8: 10a20034 beq r5,r2,0x0017549c         #If Tile's Type is Obstacle : Branch to  Next Tile iteration
001753cc: 00000000 nop                              |
001753d0: 90820003 lbu r2,0x0003(r4)            |Load Tile's Halves + Depth
001753d4: 00000000 nop                          |
001753d8: 304300e0 andi r3,r2,0x00e0            |
001753dc: 10600005 beq r3,r0,0x001753f4         #If Tile has depth
001753e0: 34020060 ori r2,r0,0x0060                 |
001753e4: 92220014 lbu r2,0x0014(r17)               |Load Unit Can enter Water flag
001753e8: 00000000 nop                              |
001753ec: 1440002b bne r2,r0,0x0017549c             #If Unit cannot enter water : branch to  Next Tile iteration
001753f0: 34020060 ori r2,r0,0x0060                     |
001753f4: 14620005 bne r3,r2,0x0017540c         #If Depth =  3
001753f8: 00071142 srl r2,r7,0x05               |Depth only (1 to 4)
001753fc: 92220012 lbu r2,0x0012(r17)               |Load Unit's Walk on/in/under water flag
00175400: 00000000 nop                              |
00175404: 14400025 bne r2,r0,0x0017549c             #If Unit cannot move in/on water : branch to   Next Tile iteration
00175408: 00071142 srl r2,r7,0x05                       |
0017540c: 28420004 slti r2,r2,0x0004            |
00175410: 14400005 bne r2,r0,0x00175428         #If Depth >= 4
00175414: 34020012 ori r2,r0,0x0012             |r2 = 0x12
00175418: 92220013 lbu r2,0x0013(r17)               |Load Unit's Walk on/in water flag (0 if ok)
0017541c: 00000000 nop                              |
00175420: 1440001e bne r2,r0,0x0017549c             #If Unit cannot walk on/in water : branch to   Next Tile iteration
00175424: 34020012 ori r2,r0,0x0012                     |
00175428: 14a20005 bne r5,r2,0x00175440         #if Tile's Type is Lava
0017542c: 30c20002 andi r2,r6,0x0002            |Check [Cannot Target]
00175430: 92220025 lbu r2,0x0025(r17)               |Load Unit's Float/move on lava flag
00175434: 00000000 nop                              |
00175438: 10400018 beq r2,r0,0x0017549c             #If cannot pass lava : branch to  Next Tile iteration
0017543c: 30c20002 andi r2,r6,0x0002                    |
00175440: 14400016 bne r2,r0,0x0017549c         #If Tile has [Cannot Target] flag : branch to   Next Tile iteration
00175444: 00000000 nop                              |
00175448: 92030000 lbu r3,0x0000(r16)           |Load Tile's flags (S-Pad 0x200)
0017544c: 00000000 nop                          |
00175450: 30620010 andi r2,r3,0x0010            |Check flag [0x10]
00175454: 10400011 beq r2,r0,0x0017549c         #If Flag 0x10 is OFF : branch to   Next Tile iteration
00175458: 30620004 andi r2,r3,0x0004                |
0017545c: 10400007 beq r2,r0,0x0017547c         #If There's a Unit on Tile
00175460: 30620020 andi r2,r3,0x0020                |
00175464: 1040000d beq r2,r0,0x0017549c             #If Flag 0x20 is OFF : branch to   Next Tile iteration  (Chocobo check behind this flag)
00175468: 00000000 nop                                  |
0017546c: 92220016 lbu r2,0x0016(r17)                   |Load Can Ride Flag  Human not frog/chicken/charm
00175470: 00000000 nop                                  |
00175474: 10400009 beq r2,r0,0x0017549c                 #If cannot ride  : branch to   Next Tile iteration
00175478: 00000000 nop                                      |

---- Flag Tile as reachable ----
0017547c: 96420018 lhu r2,0x0018(r18)                   |Load Reachable Tile counter
00175480: 00000000 nop                                  |
00175484: 24420001 addiu r2,r2,0x0001                   |
00175488: a6420018 sh r2,0x0018(r18)                    |Store counter + 1
0017548c: 90820005 lbu r2,0x0005(r4)                    |Load Tile's 0x05
00175490: 00000000 nop                                  |
00175494: 34420020 ori r2,r2,0x0020                     |
00175498: a0820005 sb r2,0x0005(r4)                     |Enable flag 0x20 on Tile data byte 0x05
0017549c: 26100001 addiu r16,r16,0x0001         |Tile Offset (S-Pad 0x200)
001754a0: 25080001 addiu r8,r8,0x0001           |Tile Counter +1
001754a4: 29020200 slti r2,r8,0x0200            |
001754a8: 1440ff90 bne r2,r0,0x001752ec     Λ Loop 0x200 Times (each Map's Tile)
001754ac: 25290005 addiu r9,r9,0x0005           |Tile Offset + 5
001754b0: 8fbf0020 lw r31,0x0020(r29)       END
001754b4: 8fb3001c lw r19,0x001c(r29)
001754b8: 8fb20018 lw r18,0x0018(r29)
001754bc: 8fb10014 lw r17,0x0014(r29)
001754c0: 8fb00010 lw r16,0x0010(r29)
001754c4: 27bd0028 addiu r29,r29,0x0028
001754c8: 03e00008 jr r31
001754cc: 00000000 nop

Return Location

BATTLE.BIN
00174dbc: 00174b8c_-_00174df4
001791b4: Find_Tiles_for_the_AI_to_move_to_(00178ca4)