Difference between revisions of "Movement routine"

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
 
Line 29: Line 29:
 
  0017595c: afb00010 sw r16,0x0010(r29)      |
 
  0017595c: afb00010 sw r16,0x0010(r29)      |
 
  00175960: 3c108019 lui r16,0x8019          |
 
  00175960: 3c108019 lui r16,0x8019          |
  00175964: 8e10f4e4 lw r16,-0x0b1c(r16)      |{{f/adr|Pointer to Scratch Pad (0x1f800180)}}
+
  00175964: 8e10f4e4 lw r16,-0x0b1c(r16)      |{{f/adr|Pointer to Scratch Pad}} [[1f800180|<span style=color:blue>0x1f800180</span>]]
 
  00175968: afb3001c sw r19,0x001c(r29)      |
 
  00175968: afb3001c sw r19,0x001c(r29)      |
 
  0017596c: 00a09821 addu r19,r5,r0          |{{f/std|<nowiki>r19 = Preset Value</nowiki>}}
 
  0017596c: 00a09821 addu r19,r5,r0          |{{f/std|<nowiki>r19 = Preset Value</nowiki>}}
 
  00175970: afb20018 sw r18,0x0018(r29)      |
 
  00175970: afb20018 sw r18,0x0018(r29)      |
 
  00175974: 3c128019 lui r18,0x8019          |
 
  00175974: 3c128019 lui r18,0x8019          |
  00175978: 8e52f4e0 lw r18,-0x0b20(r18)      |{{f/adr|Pointer to Scratch Pad (0x1f800000)}}
+
  00175978: 8e52f4e0 lw r18,-0x0b20(r18)      |{{f/adr|Pointer to scratch pad}} [[1f800000|<span style=color:blue>0x1f800000</span>]]
 
  0017597c: 3c058019 lui r5,0x8019            |
 
  0017597c: 3c058019 lui r5,0x8019            |
  00175980: 8ca5f4f0 lw r5,-0x0b10(r5)        |{{f/adr|Pointer to Scratch Pad (0x1f800200)}}
+
  00175980: 8ca5f4f0 lw r5,-0x0b10(r5)        |{{f/adr|Pointer to Scratch Pad}} [[1f800200|<span style=color:blue>0x1f800200</span>]]
 
  00175984: 3c068019 lui r6,0x8019            |
 
  00175984: 3c068019 lui r6,0x8019            |
  00175988: 8cc6f4e8 lw r6,-0x0b18(r6)        |{{f/adr|Poiter to Other units Scratchpad ( 0x1f800080 )}}
+
  00175988: 8cc6f4e8 lw r6,-0x0b18(r6)        |{{f/adr|Pointer to scratch pad}} [[1f800080|<span style=color:blue>0x1f800080</span>]]
 
  0017598c: afb40020 sw r20,0x0020(r29)      |
 
  0017598c: afb40020 sw r20,0x0020(r29)      |
 
  00175990: 3c148019 lui r20,0x8019          |
 
  00175990: 3c148019 lui r20,0x8019          |
  00175994: 8e94f4ec lw r20,-0x0b14(r20)      |{{f/adr|Pointer to Scratch Pad (0x1f800100)}}
+
  00175994: 8e94f4ec lw r20,-0x0b14(r20)      |{{f/adr|Pointer to scratch pad}} [[1f800100|<span style=color:blue>0x1f800100</span>]]
 
  00175998: 30820001 andi r2,r4,0x0001        |{{f/std|Elevation flag (0 , 1 , 0 ,1)}}
 
  00175998: 30820001 andi r2,r4,0x0001        |{{f/std|Elevation flag (0 , 1 , 0 ,1)}}
 
  0017599c: afbf0024 sw r31,0x0024(r29)      |
 
  0017599c: afbf0024 sw r31,0x0024(r29)      |

Latest revision as of 13:33, 2 June 2023

BATTLE.BIN : Movement Routine

Called while spreading Move AoE. Each time it's called (always 4 times ?) it checks a different elevation and path
(Path on Tile or Path above unit). If Tile is a Valid and efficient destination it is flagged to become a future origin
-------------------------------------------------------------------------------------------------------------------------
Parameters : r4 - Some Counter : Determines destination's elevation and tested Path 
             r5 - Preset value : used as a movement malus

Returns  : r2 - 0x00 if Valid Path (Possible and best) (only returned value checked ?) Destination Tile is flagged to be a future Origin                      
              - 0x01 Destination flags 0x20 and 0x08 are OFF (Above unit path)             
              - 0x02 Destination flags 0x10 is OFF (Tile path)
              - 0x03 Tile is too steep : flag 0x04 ON and Higher destination (Tile path)  
              - 0x04 Destination ceiling is too low (< than exit + size)
              - 0x05 Origin Ceiling is too low (< Entry)
              - 0x06 Destination ceiling is too low (< then Entry + Size)

              - 0x08 PV <> 0x00 and Destination is higher
              - 0x09 Acting Unit cannot Jump the vertical drop

              - 0x0b Movement cost is too high (Unit Path)
              - 0x0c This Path is a detour (Unit Path)
              - 0x0d This Path is less convenient (Higher Vertical drop) (Unit Path)
              - 0x0e Movement cost is too high (Tile Path)
              - 0x0f This Path is a detour (Tile Path)
              - 0x10 This Path is less convenient (Higher Vertical drop) (Tile Path)
              - 0x11 Destination flags 0x20 (Unit Path - Exit without Updating moves)
-------------------------------------------------------------------------------------------------------------------------
00175958: 27bdffd8 addiu r29,r29,-0x0028    |
0017595c: afb00010 sw r16,0x0010(r29)       |
00175960: 3c108019 lui r16,0x8019           |
00175964: 8e10f4e4 lw r16,-0x0b1c(r16)      |Pointer to Scratch Pad 0x1f800180
00175968: afb3001c sw r19,0x001c(r29)       |
0017596c: 00a09821 addu r19,r5,r0           |r19 = Preset Value
00175970: afb20018 sw r18,0x0018(r29)       |
00175974: 3c128019 lui r18,0x8019           |
00175978: 8e52f4e0 lw r18,-0x0b20(r18)      |Pointer to scratch pad 0x1f800000
0017597c: 3c058019 lui r5,0x8019            |
00175980: 8ca5f4f0 lw r5,-0x0b10(r5)        |Pointer to Scratch Pad 0x1f800200
00175984: 3c068019 lui r6,0x8019            |
00175988: 8cc6f4e8 lw r6,-0x0b18(r6)        |Pointer to scratch pad 0x1f800080
0017598c: afb40020 sw r20,0x0020(r29)       |
00175990: 3c148019 lui r20,0x8019           |
00175994: 8e94f4ec lw r20,-0x0b14(r20)      |Pointer to scratch pad 0x1f800100
00175998: 30820001 andi r2,r4,0x0001        |Elevation flag (0 , 1 , 0 ,1)
0017599c: afbf0024 sw r31,0x0024(r29)       |
001759a0: afb10014 sw r17,0x0014(r29)       |
001759a4: a6020034 sh r2,0x0034(r16)        |Store elevation flag
001759a8: 000417c2 srl r2,r4,0x1f           |always 0 ?
001759ac: 00822021 addu r4,r4,r2            |
001759b0: 86030032 lh r3,0x0032(r16)        |Destination Y
001759b4: 00042043 sra r4,r4,0x01           |Counter / 2 ( 0 0 1 1)
001759b8: a2040042 sb r4,0x0042(r16)        |Store Tile/Unit path flag
001759bc: 92420018 lbu r2,0x0018(r18)       |Load Max X
001759c0: 00000000 nop                      |
001759c4: 00620018 mult r3,r2               |
001759c8: 86020034 lh r2,0x0034(r16)        |Load elevation flag
001759cc: 96040030 lhu r4,0x0030(r16)       |Destination X
001759d0: 00021200 sll r2,r2,0x08           |Flag becomes elevation offset Elevation ?
001759d4: 00001812 mflo r3                  |Max X * Y to spread
001759d8: 00431021 addu r2,r2,r3            |
001759dc: 00441021 addu r2,r2,r4            |Destination Tile ID  Y*Max X + X + Elevation (0 or 0x100)
001759e0: a602001c sh r2,0x001c(r16)        |Store ID of destination Tile
001759e4: 00021400 sll r2,r2,0x10           |
001759e8: 00021343 sra r2,r2,0x0d           |Tile ID * 8
001759ec: 3c038019 lui r3,0x8019            |
001759f0: 2463f8cc addiu r3,r3,-0x0734      |
001759f4: 00431021 addu r2,r2,r3            |Destination data pointer  8018f8cc + Tile offset
001759f8: 8604001c lh r4,0x001c(r16)        |Destination ID
001759fc: 3c038019 lui r3,0x8019            |
00175a00: 24632dd8 addiu r3,r3,0x2dd8       |
00175a04: ae020004 sw r2,0x0004(r16)        |Store Pointer of destination Tile data
00175a08: 00041080 sll r2,r4,0x02           |
00175a0c: 00441021 addu r2,r2,r4            |Tile ID*5
00175a10: 8e040004 lw r4,0x0004(r16)        |Destinaton data pointer
00175a14: 00431021 addu r2,r2,r3            |Destination grid data pointer  80192dd8 + Tile offset
00175a18: ae02000c sw r2,0x000c(r16)        |Store Grid pointer 
00175a1c: 90820002 lbu r2,0x0002(r4)        |Destination Height
00175a20: 8e030004 lw r3,0x0004(r16)        |Tile's data pointer
00175a24: 00021040 sll r2,r2,0x01           |
00175a28: a202004d sb r2,0x004d(r16)        |Store Destination Height*2 (S-Pad 0x180)
00175a2c: 90620003 lbu r2,0x0003(r3)        |Destination Halves + depth
00175a30: 8e030004 lw r3,0x0004(r16)        |Destination data pointer
00175a34: 3042001f andi r2,r2,0x001f        |
00175a38: a2020057 sb r2,0x0057(r16)        |Store Destination Halves (S-Pad 0x180)
00175a3c: 90620004 lbu r2,0x0004(r3)        |Destination Slope Type
00175a40: 00000000 nop                      |
00175a44: a2020059 sb r2,0x0059(r16)        |Store Destination Slope Type (S-Pad 0x180)
00175a48: 8602001c lh r2,0x001c(r16)        |Tile ID
00175a4c: 92030042 lbu r3,0x0042(r16)       |Path Flag
00175a50: 00000000 nop                      |
00175a54: 10600026 beq r3,r0,0x00175af0     #If "Above Units" Path
00175a58: 00a28821 addu r17,r5,r2           |Destination pointer in S-Pad 0x200
--- Above Unit Path Section ---
00175a5c: 92220000 lbu r2,0x0000(r17)           |Destination Flags
00175a60: 00000000 nop                          |
00175a64: 30420028 andi r2,r2,0x0028            |
00175a68: 10400104 beq r2,r0,0x00175e7c         #If Flags 0x20 and 0x08 are OFF :  Exit and return 0x01
00175a6c: 34020001 ori r2,r0,0x0001                 |
00175a70: 8e02000c lw r2,0x000c(r16)            |Destination grid pointer
00175a74: 86040030 lh r4,0x0030(r16)            |Destination X  (for jal)
00175a78: 90420002 lbu r2,0x0002(r2)            |ID of Unit on destination Tile
00175a7c: 00000000 nop                          |
00175a80: a2020043 sb r2,0x0043(r16)            |Store Unit ID in S-Pad 0x180
00175a84: 92030043 lbu r3,0x0043(r16)           |Destination Unit ID
00175a88: 86050032 lh r5,0x0032(r16)            |Destination Y  (for jal)
00175a8c: 000310c0 sll r2,r3,0x03               |
00175a90: 00431023 subu r2,r2,r3                |
00175a94: 00461021 addu r2,r2,r6                |Pointer to Unit ID in Scratch-Pad 0x080
00175a98: 90420006 lbu r2,0x0006(r2)            |Unit Height + Size
00175a9c: 92060045 lbu r6,0x0045(r16)           |Destination Entry slope mod  (for jal)
00175aa0: 2447ffff addiu r7,r2,-0x0001          |Unit Height + Size - 1  (for jal)
00175aa4: 30e700ff andi r7,r7,0x00ff            |
00175aa8: 0c05d859 jal 0x00176164               |-->Calculate_Tile_Ceiling
00175aac: a202004a sb r2,0x004a(r16)            |Store Present Unit Height + Size -1
00175ab0: a2020047 sb r2,0x0047(r16)            |Store Ceiling Height
00175ab4: 92220000 lbu r2,0x0000(r17)           |Load Destination Flags (S-Pad 0x200)
00175ab8: 00000000 nop                          |
00175abc: 30420020 andi r2,r2,0x0020            |
00175ac0: 10400004 beq r2,r0,0x00175ad4         #If Flag 0x20 is ON (Mountable chocobo on tile)
00175ac4: 00000000 nop                              |
00175ac8: 92040043 lbu r4,0x0043(r16)               |Load ID of Present Unit
00175acc: 0c05d7e9 jal 0x00175fa4                   |-->Check Some Height and Units size  Store Origine AoE-1 in Destination Grid 0x03
00175ad0: 02602821 addu r5,r19,r0                   |Send Preset value
00175ad4: 92220000 lbu r2,0x0000(r17)           |Load Destination Flags (S-Pad 0x200)
00175ad8: 00000000 nop                          |
00175adc: 30420008 andi r2,r2,0x0008            |
00175ae0: 14400030 bne r2,r0,0x00175ba4         #If 0x08 is ON Go to  Terminal section
00175ae4: 34020011 ori r2,r0,0x0011                 |
00175ae8: 0805d79f j 0x00175e7c                     >>if 0x20 Only  Exit and returns 0x11
00175aec: 00000000 nop                              |
--- Tile Path Section ---
00175af0: 92220000 lbu r2,0x0000(r17)           |Destination's flags
00175af4: 00000000 nop                          |
00175af8: 30420010 andi r2,r2,0x0010            |
00175afc: 104000df beq r2,r0,0x00175e7c         #If Tile is not Walkable (Flag 0x10 is off) :   Exit and returns 0x02
00175b00: 34020002 ori r2,r0,0x0002                 |
00175b04: 92020059 lbu r2,0x0059(r16)           |Destination Slope Type
00175b08: 92030045 lbu r3,0x0045(r16)           |Destination Entry side slope mod
00175b0c: 00000000 nop                          |
00175b10: 00621007 srav r2,r2,r3                |Entry side Slope 
00175b14: 92030057 lbu r3,0x0057(r16)           |Destination's Halves
00175b18: 30420003 andi r2,r2,0x0003            |
00175b1c: 00620018 mult r3,r2                   |
00175b20: 92020059 lbu r2,0x0059(r16)           |Destination Slope Type
00175b24: 92030044 lbu r3,0x0044(r16)           |Opposite side Slope Mod
00175b28: 00000000 nop                          |
00175b2c: 00621007 srav r2,r2,r3                |Opposite Side slope
00175b30: 00003812 mflo r7                      |Entry Side Slope * Halves
00175b34: 92030057 lbu r3,0x0057(r16)           |Destination's Halves
00175b38: 30420003 andi r2,r2,0x0003            |
00175b3c: 00620018 mult r3,r2                   |
00175b40: 86040030 lh r4,0x0030(r16)            |Destination X  (for jal)
00175b44: 86050032 lh r5,0x0032(r16)            |Destination Y  (for jal)
00175b48: 9202004d lbu r2,0x004d(r16)           |Destination Height*2
00175b4c: 92060045 lbu r6,0x0045(r16)           |Entry Side Slope mod  (for jal)
00175b50: 00471021 addu r2,r2,r7                |
00175b54: a202004a sb r2,0x004a(r16)            |Store Entry Side Height
00175b58: 9202004d lbu r2,0x004d(r16)           |
00175b5c: 00001812 mflo r3                      |Opposite side slope * Halves
00175b60: 00431021 addu r2,r2,r3                |
00175b64: a202004b sb r2,0x004b(r16)            |Destination Opposite Side Height
00175b68: 9202004b lbu r2,0x004b(r16)           |Tile Opposite side height
00175b6c: 9203004a lbu r3,0x004a(r16)           |Tile Entry side height
00175b70: 9207004a lbu r7,0x004a(r16)           |Tile Entry Side Height  (for jal)
00175b74: 00431023 subu r2,r2,r3                |
00175b78: 0c05d859 jal 0x00176164               |-->Calculate_Tile_Ceiling returns r2 = ceiling
00175b7c: a6020038 sh r2,0x0038(r16)            |Store Destination sides height difference (Delta height)
00175b80: 86030038 lh r3,0x0038(r16)            |Load Delta Height
00175b84: 00000000 nop                          |
00175b88: 18600006 blez r3,0x00175ba4           #If delta height > 0 (rising Tile)
00175b8c: a2020047 sb r2,0x0047(r16)            |Store Ceiling
00175b90: 92220000 lbu r2,0x0000(r17)               |Load Tile's flags (S-pad 0x200)
00175b94: 00000000 nop                              |
00175b98: 30420040 andi r2,r2,0x0040                |Steep flag
00175b9c: 144000b7 bne r2,r0,0x00175e7c             #If Tile is too steep :   Exit and returns 0x03
00175ba0: 34020003 ori r2,r0,0x0003                     |
--- Terminal Section (Flag 0x10 or Flag 0x08) ---
00175ba4: 92020048 lbu r2,0x0048(r16)       |Load Origin Tile Exit Side Height
00175ba8: 9244001b lbu r4,0x001b(r18)       |Load Unit Size
00175bac: 92050047 lbu r5,0x0047(r16)       |Load Destination ceiling height
00175bb0: 00441021 addu r2,r2,r4            |
00175bb4: 00a2102a slt r2,r5,r2             |0x1 if Destination Ceiling Height < Exit Side + Unit size
00175bb8: 144000b0 bne r2,r0,0x00175e7c     #If Ceiling is below Unit :  Exit and returns 0x04
00175bbc: 34020004 ori r2,r0,0x0004             |
00175bc0: 9203004a lbu r3,0x004a(r16)       |Tile Entry Height
00175bc4: 92020046 lbu r2,0x0046(r16)       |Origin Tile ceiling height
00175bc8: 00641821 addu r3,r3,r4            |
00175bcc: 0043102a slt r2,r2,r3             |0x1 if Origin ceiling < Entry Height
00175bd0: 144000aa bne r2,r0,0x00175e7c     #If Origin Ceiling < Entry Height  Exit and returns 0x05
00175bd4: 34020005 ori r2,r0,0x0005             |
00175bd8: 00a3102a slt r2,r5,r3             |0x1 if Origin Ceiling < Destination Ceiling
00175bdc: 144000a7 bne r2,r0,0x00175e7c     #If Destination Ceiling < Destination Ceiling  Exit and returns 0x06
00175be0: 34020006 ori r2,r0,0x0006             |
00175be4: 92020042 lbu r2,0x0042(r16)       |Load Path Flag
00175be8: 00000000 nop                      |
00175bec: 14400009 bne r2,r0,0x00175c14     #If Tile Path - Check depth
00175bf0: 00000000 nop                          |
00175bf4: 8e020004 lw r2,0x0004(r16)            |Destination data pointer
00175bf8: 00000000 nop                          |
00175bfc: 90420003 lbu r2,0x0003(r2)            |Destination Halves + Depth
00175c00: 9203004a lbu r3,0x004a(r16)           |Destination Entry Height
00175c04: 00021142 srl r2,r2,0x05               |
00175c08: 00021040 sll r2,r2,0x01               |Depth * 2
00175c0c: 00621821 addu r3,r3,r2                |
00175c10: a203004a sb r3,0x004a(r16)            |Update entry height with depth if needed
00175c14: 9203004a lbu r3,0x004a(r16)       |Destination entry height
00175c18: 92020048 lbu r2,0x0048(r16)       |Origin exit height
00175c1c: 00000000 nop                      |
00175c20: 0043102b sltu r2,r2,r3            |0x1 if Origin height < Destination height
00175c24: 10400007 beq r2,r0,0x00175c44     #If Origin Height < Destination height
00175c28: 00000000 nop                          |
00175c2c: 16600093 bne r19,r0,0x00175e7c        #If Preset Value (from r5) <> 0x00  Exit and returns 0x08
00175c30: 34020008 ori r2,r0,0x0008                 |
00175c34: 9202004a lbu r2,0x004a(r16)           |Destination Height
00175c38: 92030048 lbu r3,0x0048(r16)           |Origin Height
00175c3c: 0805d715 j 0x00175c54                 >>Jump with delta height
00175c40: 00431023 subu r2,r2,r3                |Delta Height (Destination - Origin)
                                            Else : Origin Height > Destination height
00175c44: 92020048 lbu r2,0x0048(r16)           |Origin Height
00175c48: 9203004a lbu r3,0x004a(r16)           |Destination Height
00175c4c: 00000000 nop                          |
00175c50: 00431023 subu r2,r2,r3                |Delta Height(Origin - Destination)
00175c54: a2020064 sb r2,0x0064(r16)        |Store positive delta height
00175c58: 92030064 lbu r3,0x0064(r16)       |Delta height
00175c5c: 92420002 lbu r2,0x0002(r18)       |Acting unit Jump*2
00175c60: 00000000 nop                      |
00175c64: 0043102b sltu r2,r2,r3            |
00175c68: 14400084 bne r2,r0,0x00175e7c     #If Acting Unit cannot jump the height difference  Exit and returns 0x09
00175c6c: 34020009 ori r2,r0,0x0009             |
00175c70: 8e020010 lw r2,0x0010(r16)        |Pointer to Origin grid data
00175c74: 00000000 nop                      |
00175c78: 90430004 lbu r3,0x0004(r2)        |Lower height entry
00175c7c: 92020064 lbu r2,0x0064(r16)       |Delta height
00175c80: 00000000 nop                      |
00175c84: 0062102b sltu r2,r3,r2            |
00175c88: 10400002 beq r2,r0,0x00175c94     #If Grid 0x04 < Delta height
00175c8c: a2030050 sb r3,0x0050(r16)        |Store Grid 0x04 (Lower height entry)
00175c90: 92030064 lbu r3,0x0064(r16)           |Delta height
00175c94: 00000000 nop                          |
00175c98: a2030064 sb r3,0x0064(r16)        |Store Grid 0x04 or delta height (higher) Higher Jump memory ?
00175c9c: 9242000e lbu r2,0x000e(r18)       |Acting Unit move type
00175ca0: 00000000 nop                      |
00175ca4: 14400002 bne r2,r0,0x00175cb0     #If Acting Unit is Flying
00175ca8: 00000000 nop                          |
00175cac: a2000064 sb r0,0x0064(r16)            |Nullify delta height
00175cb0: 92020042 lbu r2,0x0042(r16)       |Path Flag
00175cb4: 00000000 nop                      |
--- Above Unit Terminal Section ---
00175cb8: 10400033 beq r2,r0,0x00175d88     #If Above Unit Path  Pass data on Post-Grid Table
00175cbc: 3403ffff ori r3,r0,0xffff             |
00175cc0: 8e020010 lw r2,0x0010(r16)            |Origin Grid pointer
00175cc4: 00000000 nop                          |
00175cc8: 90420000 lbu r2,0x0000(r2)            |Load Remaining Moves
00175ccc: 00000000 nop                          |
00175cd0: 00431021 addu r2,r2,r3                |Movement - 1
00175cd4: 00531023 subu r2,r2,r19               |Movement - Preset Value
00175cd8: a6020022 sh r2,0x0022(r16)            |Movement left (to spread)
00175cdc: 00021400 sll r2,r2,0x10               |Shift in Upper part : if less then 0x10000 becomes negative
00175ce0: 18400066 blez r2,0x00175e7c           #If remaining movement is negative  Exit and returns 0x0b
00175ce4: 3402000b ori r2,r0,0x000b                 |
00175ce8: 92020043 lbu r2,0x0043(r16)           |Destination Unit ID
00175cec: 92050022 lbu r5,0x0022(r16)           |Acting Unit Movement left Origin Tile Grid 0x00 - 1
00175cf0: 24420200 addiu r2,r2,0x0200           |Post Grid Offset
00175cf4: 00021880 sll r3,r2,0x02               |
00175cf8: 00621821 addu r3,r3,r2                |Unit Offset * 5
00175cfc: 3c018019 lui r1,0x8019                |
00175d00: 00230821 addu r1,r1,r3                |Part of pointer to Post grid Unit data  801937d8 + Unit offset
00175d04: 90242dd8 lbu r4,0x2dd8(r1)            |Load Post-Grid 0x00 (AoE move to spread)
00175d08: 00000000 nop                          |
00175d0c: 00a4102b sltu r2,r5,r4                |If Move Left < Post-Grid 0x00
00175d10: 1440005a bne r2,r0,0x00175e7c         #If This Path is a detour  Exit and returns 0x0c  Tile already reached, using less move
00175d14: 3402000c ori r2,r0,0x000c                 |
00175d18: 14a40009 bne r5,r4,0x00175d40         #If This Path is equal to the shortest past
00175d1c: 00000000 nop                              |
00175d20: 92020064 lbu r2,0x0064(r16)               |Height to Pass  Difference between Origin and Destination
00175d24: 3c018019 lui r1,0x8019                    |
00175d28: 00230821 addu r1,r1,r3                    |Part of Pointer to Post Grid data
00175d2c: 90232ddc lbu r3,0x2ddc(r1)                |Load Post Grid 0x04
00175d30: 00000000 nop                              |
00175d34: 0043102b sltu r2,r2,r3                    |
00175d38: 10400050 beq r2,r0,0x00175e7c             #If Height to Pass > Higher Vertical drop (less convenient)  Exit and returns 0x0d
00175d3c: 3402000d ori r2,r0,0x000d                     |
--- New best Path (Above unit)---
00175d40: 92030043 lbu r3,0x0043(r16)           |Destination Unit ID
00175d44: 92040022 lbu r4,0x0022(r16)           |Acting Unit Movement left
00175d48: 24630200 addiu r3,r3,0x0200           |
00175d4c: 00031080 sll r2,r3,0x02               |
00175d50: 00431021 addu r2,r2,r3                |
00175d54: 3c018019 lui r1,0x8019                |
00175d58: 00220821 addu r1,r1,r2                |Part of pointer to Post grid Unit data
00175d5c: a0242dd8 sb r4,0x2dd8(r1)             |Store Acting Unit Move Left in Post-Grid 0x00  Path lenght to reach this spot
00175d60: 92030043 lbu r3,0x0043(r16)           |Destination Unit ID
00175d64: 92040064 lbu r4,0x0064(r16)           |Delta Height
00175d68: 24630200 addiu r3,r3,0x0200           |
00175d6c: 00031080 sll r2,r3,0x02               |
00175d70: 00431021 addu r2,r2,r3                |
00175d74: 3c018019 lui r1,0x8019                |
00175d78: 00220821 addu r1,r1,r2                |Part of pointer to Post grid Unit data
00175d7c: a0242ddc sb r4,0x2ddc(r1)             |Store New best vertical drop in Post-Grid 0x04  
00175d80: 0805d787 j 0x00175e1c                 >>Avoid Tile Path section
00175d84: 00000000 nop                          |
--- Tile Path Terminal section
                                            Else : Tile Path
00175d88: 8e020004 lw r2,0x0004(r16)            |Destination Tile pointer  8018f8cc
00175d8c: 00000000 nop                          |
00175d90: 90430000 lbu r3,0x0000(r2)            |Destination Tile Type
00175d94: 8e020010 lw r2,0x0010(r16)            |Pointer to Origin Grid Data  80192dd8
00175d98: 3063003f andi r3,r3,0x003f            |Tile Type
00175d9c: 02831821 addu r3,r20,r3               |Tile Offset in S-Pad 0x100 (Movement cost)
00175da0: 90420000 lbu r2,0x0000(r2)            |Remaining moves
00175da4: 90630000 lbu r3,0x0000(r3)            |Load Movement cost
00175da8: 00531023 subu r2,r2,r19               |Movement - Preset Value
00175dac: 00431023 subu r2,r2,r3                |Movement - Move Cost
00175db0: a6020022 sh r2,0x0022(r16)            |Store New Movement left
00175db4: 00021400 sll r2,r2,0x10               |
00175db8: 18400030 blez r2,0x00175e7c           #If Destination is too far (Min value is 0x1)  Exit and returns 0x0e
00175dbc: 3402000e ori r2,r0,0x000e                 |
00175dc0: 8e05000c lw r5,0x000c(r16)            |Destination Grid Pointer 80192dd8
00175dc4: 92040022 lbu r4,0x0022(r16)           |Movement Left
00175dc8: 90a30000 lbu r3,0x0000(r5)            |Remaining moves is already reached - 0x00 if not
00175dcc: 00000000 nop                          |
00175dd0: 0083102b sltu r2,r4,r3                |
00175dd4: 14400029 bne r2,r0,0x00175e7c         #If This Path is a detour  Exit and returns 0x0f
00175dd8: 3402000f ori r2,r0,0x000f                 |
00175ddc: 14830007 bne r4,r3,0x00175dfc         #If This Path is equal to the shortest past  Same distance from center of AoE
00175de0: 00000000 nop                              |
00175de4: 92020064 lbu r2,0x0064(r16)               |Delta Height
00175de8: 90a30004 lbu r3,0x0004(r5)                |Destination Grid 0x04
00175dec: 00000000 nop                              |
00175df0: 0043102b sltu r2,r2,r3                    |
00175df4: 10400021 beq r2,r0,0x00175e7c             #If Height to Pass > Higher Vertical drop (less convenient)  Exit and returns 0x10
00175df8: 34020010 ori r2,r0,0x0010                     |
--- New best Path (Tile)---
00175dfc: 8e03000c lw r3,0x000c(r16)            |Destination Grid Pointer 80192dd8
00175e00: 92020022 lbu r2,0x0022(r16)           |Movement Left
00175e04: 00000000 nop                          |
00175e08: a0620000 sb r2,0x0000(r3)             |Store Move Left in Grid 0x00 (lower)
00175e0c: 8e03000c lw r3,0x000c(r16)            |Destination Grid Pointer
00175e10: 92020064 lbu r2,0x0064(r16)           |Delta Height
00175e14: 00000000 nop                          |
00175e18: a0620004 sb r2,0x0004(r3)             |Store new Lower vertical drop in Grid 0x04
--- New best (Both)---
00175e1c: 86020022 lh r2,0x0022(r16)        |Movement Left
00175e20: 00000000 nop                      |
00175e24: 28420002 slti r2,r2,0x0002        |
00175e28: 14400014 bne r2,r0,0x00175e7c     #If Movement Left <= 1 (Last Tile)  Exit and returns 0x00
00175e2c: 00001021 addu r2,r0,r0                |
00175e30: 8602001c lh r2,0x001c(r16)        |Destination Tile ID
00175e34: 3c038019 lui r3,0x8019            |
00175e38: 8c63f4f0 lw r3,-0x0b10(r3)        |Pointer to Scratch Pad (0x1f800200)
00175e3c: 00000000 nop                      |
00175e40: 00621821 addu r3,r3,r2            |Destination Offset in S-Pad 0x200
00175e44: 90620000 lbu r2,0x0000(r3)        |Destination Flags
00175e48: 00000000 nop                      |
00175e4c: 34420001 ori r2,r2,0x0001         |
00175e50: a0620000 sb r2,0x0000(r3)         |Enable 0x01 (Used to spread AoE)   This tile will be an origin in a few loops
00175e54: 92030022 lbu r3,0x0022(r16)       |Movement Left
00175e58: 92020062 lbu r2,0x0062(r16)       |
00175e5c: 00000000 nop                      |
00175e60: 0043102b sltu r2,r2,r3            |
00175e64: 10400005 beq r2,r0,0x00175e7c     #If S-Pad 0x180 0x62 > Movement left  Exit and returns 0x00 Keep Higher movement left to spread AoE
00175e68: 00001021 addu r2,r0,r0                |
00175e6c: 92020022 lbu r2,0x0022(r16)       |Movement Left
00175e70: 00000000 nop                      |
00175e74: a2020062 sb r2,0x0062(r16)        |Store in 0x62
00175e78: 00001021 addu r2,r0,r0            |
00175e7c: 8fbf0024 lw r31,0x0024(r29)       END
00175e80: 8fb40020 lw r20,0x0020(r29)
00175e84: 8fb3001c lw r19,0x001c(r29)
00175e88: 8fb20018 lw r18,0x0018(r29)
00175e8c: 8fb10014 lw r17,0x0014(r29)
00175e90: 8fb00010 lw r16,0x0010(r29)
00175e94: 27bd0028 addiu r29,r29,0x0028
00175e98: 03e00008 jr r31
00175e9c: 00000000 nop

Return Location

BATTLE.BIN
00175f5c: Check_and_Spread_Movement_One_Tile_Around
00176654: Spread_Horizontal_Jump