Difference between revisions of "Set Tile Flags for Pathfinding"
Jump to navigation
Jump to search
m (Orkney moved page 00174e84 - 00175284 to Set Tile Flags for Pathfinding) |
|
(No difference)
|
Latest revision as of 10:49, 3 June 2023
BATTLE.BIN : Set Tile's Flags for Pathfinding ------------------------------------------------------------------------------------------------------- Parameters : r4 - Preset Value 0x01 - Whole routine - Exclusive : Nullify Grid 0x04, set Grid/Post grid 0x00 to Unit Move +1 Set value of counters at S-Pad 0x184 - 0x54 and 0x55 0x02 - Preserves Grid 0x00, 0x03 and 0x04 bytes - Avoid Initialization of reachable tile counter (S-Pad 0x180 - 0x18) 0x03 - Does not set flags relating to the presence of units Returns : nothing Set Some Tile Flag on scratch Pad 0x1f800200 Initialize data on Targetable Grid ( 80192dd8 )and post grid ( 801937d8 ) ------------------------------------------------------------------------------------------------------- 00174e84: 00806021 addu r12,r4,r0 |Preset value 00174e88: 00004021 addu r8,r0,r0 |Initialize Tile counter 00174e8c: 00003821 addu r7,r0,r0 |Initialize Offset in targetable grid (+5 each iteration) 00174e90: 3c098019 lui r9,0x8019 | 00174e94: 8d29f4e0 lw r9,-0x0b20(r9) |Pointer to scratch pad 0x1f800000 00174e98: 3c0d8019 lui r13,0x8019 | 00174e9c: 8dadf4e4 lw r13,-0x0b1c(r13) |Pointer to Scratch Pad 0x1f800180 00174ea0: 3c0b8019 lui r11,0x8019 | 00174ea4: 8d6bf4f0 lw r11,-0x0b10(r11) |Pointer to Scratch Pad 0x1f800200 00174ea8: 3c0e8019 lui r14,0x8019 | 00174eac: 8dcef4e8 lw r14,-0x0b18(r14) |Pointer to scratch pad 0x1f800080 00174eb0: 01602021 addu r4,r11,r0 |Dynamic pointer to Scratch Pad 0x200 (+1 each iteration) 00174eb4: 01603021 addu r6,r11,r0 |Dynamic pointer to Scratch Pad 0x200 (+1 each iteration) 00174eb8: 3c028019 lui r2,0x8019 |LOOP - through each Tile 0x210 Loop - the 0x10 Extra are for Unit Post Grid data 00174ebc: 24422dd8 addiu r2,r2,0x2dd8 | 00174ec0: 00e22821 addu r5,r7,r2 |Pointer to this iteration Tile in Targetable grid 80192dd8 00174ec4: 31820001 andi r2,r12,0x0001 | 00174ec8: a0a00001 sb r0,0x0001(r5) |Initialize Tile's Grid 0x01 / Initial colour 00174ecc: 10400005 beq r2,r0,0x00174ee4 #If preset value has flag 0x01 0x1 or 0x3 00174ed0: a0a00002 sb r0,0x0002(r5) |Initialize Tile's grid 0x02 (Unit ID on Tile) 00174ed4: 340200ff ori r2,r0,0x00ff | 00174ed8: a0a00000 sb r0,0x0000(r5) |Initialize Tile Grid data 0x00 00174edc: a0a00003 sb r0,0x0003(r5) |Initialize Tile data 0x03 00174ee0: a0a20004 sb r2,0x0004(r5) |0xff in Tile data 0x04 00174ee4: 29020200 slti r2,r8,0x0200 | 00174ee8: 10400055 beq r2,r0,0x00175040 #If Loop counter < 0x200 00174eec: 000818c0 sll r3,r8,0x03 |Tile ID * 8 00174ef0: 3c028019 lui r2,0x8019 | 00174ef4: 2442f8cc addiu r2,r2,-0x0734 | 00174ef8: 00622821 addu r5,r3,r2 |This iteration Tile data pointer (8019f8cc) 00174efc: a0c00000 sb r0,0x0000(r6) |Initialize this Tile data in scratch pad (0x200) 00174f00: 90a20004 lbu r2,0x0004(r5) |Load Tile's Slope Type 00174f04: 00000000 nop | 00174f08: 30430005 andi r3,r2,0x0005 |Keep West and East data 00174f0c: 34020001 ori r2,r0,0x0001 | 00174f10: 10620003 beq r3,r2,0x00174f20 #If Slope type 0x41 or 0x11 Branch to Low corner section 00174f14: 34020004 ori r2,r0,0x0004 | 00174f18: 1462000d bne r3,r2,0x00174f50 #If Slope type 0x14 0x44 / Else Avoid low corner section 00174f1c: 00000000 nop | Low Corner Section 00174f20: 90830000 lbu r3,0x0000(r4) |Load Scratch Pad data 00174f24: 00000000 nop | 00174f28: 34620002 ori r2,r3,0x0002 | 00174f2c: a0820000 sb r2,0x0000(r4) |Enable flag 0x02 on S-Pad 0x200 00174f30: 90a20003 lbu r2,0x0003(r5) |Load Halves 00174f34: 00000000 nop | 00174f38: 3042001f andi r2,r2,0x001f | 00174f3c: 28420003 slti r2,r2,0x0003 | 00174f40: 1440000d bne r2,r0,0x00174f78 #If Halves > 0x2 / Else ignore Slope section 00174f44: 34620042 ori r2,r3,0x0042 | 00174f48: 0805d3de j 0x00174f78 >>Avoid Others Slope Type section 00174f4c: a0820000 sb r2,0x0000(r4) |Enable flag 0x42 on S-Pad 0x200 Not a Low Corner 00174f50: 90a20003 lbu r2,0x0003(r5) |Load Halves 00174f54: 91230004 lbu r3,0x0004(r9) |Load Acting Unit Jump routine at 00174430 00174f58: 3042001f andi r2,r2,0x001f | 00174f5c: 0062182a slt r3,r3,r2 | 00174f60: 10600005 beq r3,r0,0x00174f78 #If Acting Unit Jump < Halves 00174f64: 00000000 nop | 00174f68: 90820000 lbu r2,0x0000(r4) |Load Tile's 0x00 (scratch pad) 00174f6c: 00000000 nop | 00174f70: 34420040 ori r2,r2,0x0040 | 00174f74: a0820000 sb r2,0x0000(r4) |Update Tile's Flag in S-Pad 0x200 This Flag is checked while climbing up --- All cases --- 00174f78: 90a20006 lbu r2,0x0006(r5) |Load Tile's data 0x06 00174f7c: 00000000 nop | 00174f80: 30430001 andi r3,r2,0x0001 |Check [Unselectable] 00174f84: 00021042 srl r2,r2,0x01 | 00174f88: 30420001 andi r2,r2,0x0001 |Check [Cannot Target] (after right shift…) 00174f8c: 00621825 or r3,r3,r2 | 00174f90: 14600014 bne r3,r0,0x00174fe4 #If Tile Can beTargeted or Selected Else Avoid Flag 0x10 00174f94: 00000000 nop | 00174f98: 90a20003 lbu r2,0x0003(r5) |Load Halves/Depth 00174f9c: 00000000 nop | 00174fa0: 00021942 srl r3,r2,0x05 |Keep Depth 00174fa4: 10600005 beq r3,r0,0x00174fbc #If Depht <> 0x00 00174fa8: 2c620004 sltiu r2,r3,0x0004 |Depth Vs 0x4 00174fac: 91220011 lbu r2,0x0011(r9) |Load Cannot enter water flag 00174fb0: 00000000 nop | 00174fb4: 1440000b bne r2,r0,0x00174fe4 #Avoid Flag 0x10 if cannot enter water 00174fb8: 2c620004 sltiu r2,r3,0x0004 | 00174fbc: 14400005 bne r2,r0,0x00174fd4 #If Depht > 3 00174fc0: 00000000 nop | 00174fc4: 91220013 lbu r2,0x0013(r9) |Load Walk in/on water flag (0 if ok) 00174fc8: 00000000 nop | 00174fcc: 14400005 bne r2,r0,0x00174fe4 #Avoid Flag 0x10 if can't go at this depht 00174fd0: 00000000 nop | 00174fd4: 90820000 lbu r2,0x0000(r4) |Load Tiles flag 00174fd8: 00000000 nop | 00174fdc: 34420010 ori r2,r2,0x0010 | 00174fe0: a0820000 sb r2,0x0000(r4) |Enable flag 0x10 --- All cases --- 00174fe4: 90a30006 lbu r3,0x0006(r5) |Load Tile's data 0x06 00174fe8: 00000000 nop | 00174fec: 30620001 andi r2,r3,0x0001 | 00174ff0: 10400004 beq r2,r0,0x00175004 #If Tile is Unselectable 00174ff4: 00000000 nop | 00174ff8: 90820000 lbu r2,0x0000(r4) |Load Tiles 0x00 (scratchpad) 00174ffc: 0805d40f j 0x0017503c >>Jump with flag 0x80 and store it in scratch pad 00175000: 34420080 ori r2,r2,0x0080 | Else : Tile is selectable 00175004: 9122000e lbu r2,0x000e(r9) |Load Acting unit Move Type 00175008: 00000000 nop | 0017500c: 1440000c bne r2,r0,0x00175040 #If Unit is Flying 00175010: 30620002 andi r2,r3,0x0002 | 00175014: 1040000a beq r2,r0,0x00175040 #If Tile is not targetable 00175018: 3403003f ori r3,r0,0x003f | 0017501c: 90a20000 lbu r2,0x0000(r5) |Load Tile's Type 00175020: 00000000 nop | 00175024: 3042003f andi r2,r2,0x003f |Keep Type Only 00175028: 10430005 beq r2,r3,0x00175040 #If Tile is not a Cross Section 0017502c: 00000000 nop | 00175030: 90820000 lbu r2,0x0000(r4) |Load Tiles 0x00 (scratchpad) 00175034: 00000000 nop | 00175038: 34420010 ori r2,r2,0x0010 | 0017503c: a0820000 sb r2,0x0000(r4) |Enable flag 0x10 End of the "Tile only" loop part 00175040: 24840001 addiu r4,r4,0x0001 |Offset of scratchpad data + 1 00175044: 24c60001 addiu r6,r6,0x0001 |Offset of scratchpad data + 1 (only use to intialize data…on Grid + 210) 00175048: 25080001 addiu r8,r8,0x0001 |Loop counter +1 0017504c: 29020210 slti r2,r8,0x0210 | 00175050: 1440ff99 bne r2,r0,0x00174eb8 Λ Loop 0x210 times Grid and Post-Grid entries 00175054: 24e70005 addiu r7,r7,0x0005 |Targetable grid offset 00175058: 34020003 ori r2,r0,0x0003 | 0017505c: 11820052 beq r12,r2,0x001751a8 #If Preset value <> 0x03 00175060: 31820001 andi r2,r12,0x0001 | 00175064: 00004021 addu r8,r0,r0 |Initialize Unit counter 00175068: 01c03821 addu r7,r14,r0 |Dynamic Pointer to Other units Scratchpad ( 0x1f800080 ) LOOP - 0x10 (Unit in S-Pad 0x80) 0017506c: 90e60003 lbu r6,0x0003(r7) |This iteration Unit ID 00175070: 340200ff ori r2,r0,0x00ff | 00175074: 30c300ff andi r3,r6,0x00ff | 00175078: 10620046 beq r3,r2,0x00175194 #If Unit doesn't exist : branch to Next iteration 0017507c: 00000000 nop | 00175080: 90e30001 lbu r3,0x0001(r7) |This Unit Y 00175084: 91220018 lbu r2,0x0018(r9) |Map Max Y 00175088: 00000000 nop | 0017508c: 00620018 mult r3,r2 | 00175090: 90e20002 lbu r2,0x0002(r7) |This Unit Elevation + Stepping stone 00175094: 90e40000 lbu r4,0x0000(r7) |This Unit X 00175098: 3042007f andi r2,r2,0x007f |Keep only elevation (0x1) 0017509c: 00021200 sll r2,r2,0x08 |0x100 if higher elevation 001750a0: 00001812 mflo r3 |Map MaxY * Unit Y 001750a4: 00431021 addu r2,r2,r3 | 001750a8: 00445021 addu r10,r2,r4 |This Unit Tile ID (MaxY * Y) + X + Elevation offset 001750ac: 30c3001f andi r3,r6,0x001f |Unit ID without other flags 001750b0: 000310c0 sll r2,r3,0x03 | 001750b4: 00431023 subu r2,r2,r3 | 001750b8: 00021180 sll r2,r2,0x06 | 001750bc: 3c018019 lui r1,0x8019 | 001750c0: 00220821 addu r1,r1,r2 |Pointer to this iteration Unit battle data 001750c4: 902308cc lbu r3,0x08cc(r1) |Unit Base ID 001750c8: 34020049 ori r2,r0,0x0049 | 001750cc: 14620007 bne r3,r2,0x001750ec #If This Unit is Archangel / branch if not - WHAT'- KANZEN?? 001750d0: 016a2021 addu r4,r11,r10 |This Unit Tile's data in scratchpad (0x200) 001750d4: 016a1821 addu r3,r11,r10 |This Unit Tile's data in scratchpad 0x200 001750d8: 90620000 lbu r2,0x0000(r3) |Load Tile's data 001750dc: 00000000 nop | 001750e0: 34420080 ori r2,r2,0x0080 | 001750e4: 304200ef andi r2,r2,0x00ef | 001750e8: a0620000 sb r2,0x0000(r3) |Update Tile's Flag (enables 0x80 - Disable 0x10) Unselectable / Not walkable 001750ec: 000a1080 sll r2,r10,0x02 |Tile's ID * 4 001750f0: 004a1021 addu r2,r2,r10 |Tile's ID * 5 001750f4: 3c018019 lui r1,0x8019 | 001750f8: 00220821 addu r1,r1,r2 |Part of pointer to This unit Tile's data in Targetable grid 001750fc: a0282dda sb r8,0x2dda(r1) |Store Unit ID standing in Grid panel 0x02 00175100: 90820000 lbu r2,0x0000(r4) |Load Tile's data (scratchpad 0x200) 00175104: 00000000 nop | 00175108: 34450004 ori r5,r2,0x0004 |Enable flag 0x04 0017510c: 30c20040 andi r2,r6,0x0040 |Check Not in Active Team flag 00175110: 14400018 bne r2,r0,0x00175174 #If This Unit is in Acting Unit Team 00175114: a0850000 sb r5,0x0000(r4) |Store Tile's data with 0x04 enabled 00175118: 91220022 lbu r2,0x0022(r9) |Load Acting Stepping stone flag 0017511c: 00000000 nop | 00175120: 14400006 bne r2,r0,0x0017513c #If Acting Unit do not have stepping stone 00175124: 30a200f7 andi r2,r5,0x00f7 |Disable 0x08 00175128: 90e30002 lbu r3,0x0002(r7) |Load This iteration Unit Elevation/stepping stone 0017512c: 00000000 nop | 00175130: 000319c2 srl r3,r3,0x07 |Keep stepping stone (as 0x1) 00175134: 000318c0 sll r3,r3,0x03 |Stepping stone is 0x08 (You can walk on this unit) 00175138: 00431025 or r2,r2,r3 |Enable stepping stone (if present initialy) 0017513c: a0820000 sb r2,0x0000(r4) |Disable or Enable Flag 0x08 00175140: 30c20020 andi r2,r6,0x0020 |Check Unit's Not mountable Flag 00175144: 14400006 bne r2,r0,0x00175160 #If This ally unit is mountable Reversed flag : 0x20 if unmountable 00175148: 016a1821 addu r3,r11,r10 |This Unit Tile's data in scratchpad 0x200 0017514c: 90620000 lbu r2,0x0000(r3) |Load Tile's data 00175150: 00000000 nop | 00175154: 34420020 ori r2,r2,0x0020 |Enable 0x20 00175158: 0805d465 j 0x00175194 >>Jump to Next iteration 0017515c: a0620000 sb r2,0x0000(r3) |Store Data with flag 0x20 Else : Unmountable ally 00175160: 90620000 lbu r2,0x0000(r3) |Load Tile's data 00175164: 00000000 nop | 00175168: 304200df andi r2,r2,0x00df |Disable 0x20 0017516c: 0805d465 j 0x00175194 >>Jump to Next iteration 00175170: a0620000 sb r2,0x0000(r3) |Store Data without flag 0x20 Else : Unit is not is Acting Unit team (Flag 0x40 if ON) 00175174: 30a300cf andi r3,r5,0x00cf |Disable flag 0x20 and 0x10 00175178: a0830000 sb r3,0x0000(r4) |Store Data without flag 0x20 and 0x10 0017517c: 9122000e lbu r2,0x000e(r9) |Load acting unit Move Type 00175180: 00000000 nop | 00175184: 14400002 bne r2,r0,0x00175190 #If Active unit is Flying 00175188: 30a200c7 andi r2,r5,0x00c7 |Disable 0x08 0017518c: 34620008 ori r2,r3,0x0008 |Enable Tile's flag 0x08 00175190: a0820000 sb r2,0x0000(r4) |Store Tile's date (scratchpad 0x200) 00175194: 25080001 addiu r8,r8,0x0001 |Loop counter +1 00175198: 29020010 slti r2,r8,0x0010 |Check Limit 0017519c: 1440ffb3 bne r2,r0,0x0017506c Λ Loop 0x10 Times 001751a0: 24e70007 addiu r7,r7,0x0007 |Scratch pad 0x080 Offset (Other Units data) 001751a4: 31820001 andi r2,r12,0x0001 | 001751a8: 1040000d beq r2,r0,0x001751e0 #if Preset Value has flag 0x01 0x1 or 0x3 001751ac: 34020001 ori r2,r0,0x0001 | 001751b0: a5a00018 sh r0,0x0018(r13) |Initialize reachable tile counter 001751b4: 91230008 lbu r3,0x0008(r9) |Load Acting Unit Y 001751b8: 91220018 lbu r2,0x0018(r9) |Load Map Max X 001751bc: 00000000 nop | 001751c0: 00620018 mult r3,r2 | 001751c4: 91220009 lbu r2,0x0009(r9) |Load Acting Unit Elevation 001751c8: 91240007 lbu r4,0x0007(r9) |Load Acting Unit X 001751cc: 00021200 sll r2,r2,0x08 |Elevation becomes 0x100 001751d0: 00001812 mflo r3 |Y*Max X 001751d4: 00431021 addu r2,r2,r3 | 001751d8: 00445021 addu r10,r2,r4 |Acting Unit's Tile ID (replace Other Unit Tile ID) 001751dc: 34020001 ori r2,r0,0x0001 | 001751e0: 15820027 bne r12,r2,0x00175280 #If Preset Value = 0x1 / Else Branch to End 001751e4: 000a1880 sll r3,r10,0x02 |Tile ID*4 001751e8: 006a1821 addu r3,r3,r10 |Tile ID*5 001751ec: 3c048019 lui r4,0x8019 | 001751f0: 24842dd8 addiu r4,r4,0x2dd8 |Targetable grid pointer 001751f4: 016a1021 addu r2,r11,r10 |Pointer to Acting Unit Tile's data in scratchpad (0x200) 001751f8: 90420000 lbu r2,0x0000(r2) |Load acting unit Tile's Flags 001751fc: 00000000 nop | 00175200: 30420020 andi r2,r2,0x0020 | 00175204: 1040000d beq r2,r0,0x0017523c #If Flag 0x20 is ON (Tested when Acting unit stop riding) 00175208: 00642821 addu r5,r3,r4 |Pointer to Acting unit Tile's data (targetable grid) 0017520c: 34020024 ori r2,r0,0x0024 | 00175210: a1a20054 sb r2,0x0054(r13) |Store 0x24 in Scratch Pad 0x180 (Byte 0x54) Used as loop counter - seems to check incrementing height 00175214: 90a20002 lbu r2,0x0002(r5) |Load Unit ID (from Targetable Grid) 00175218: 24840a00 addiu r4,r4,0x0a00 |Targetable grid pointer + 0xa00 801937d8 (Just after Targetable grid panel 0x200 * 5 = A00) 0017521c: 00021880 sll r3,r2,0x02 |Unit ID * 4 00175220: 00621821 addu r3,r3,r2 |Unit ID * 5 00175224: 91220006 lbu r2,0x0006(r9) |Load Unit Move (scratch pad 0x00) 00175228: 00641821 addu r3,r3,r4 |801937d8 + Unit Offset (0x05 Byte per unit) 0017522c: a0600004 sb r0,0x0004(r3) |Nullify Unit 0x04 (Post Grid) 00175230: 24420001 addiu r2,r2,0x0001 | 00175234: 0805d491 j 0x00175244 | 00175238: a0620000 sb r2,0x0000(r3) |Store Move +1 at Unit 0x00 (Post Grid) This unit post-grid is used as center of AoE Else : Flag 0x20 is OFF 0017523c: 34020008 ori r2,r0,0x0008 | 00175240: a1a20054 sb r2,0x0054(r13) |Store 0x08 in Scratch Pad 0x180 (Byte 0x54) 00175244: 34020004 ori r2,r0,0x0004 | 00175248: a1a20055 sb r2,0x0055(r13) |Store 0x04 in Scratch Pad 0x180 (Byte 0x55) 0017524c: 91220006 lbu r2,0x0006(r9) |Load Unit Move (scratch pad 0x00) 00175250: 016a1821 addu r3,r11,r10 |Pointer to Acting Unit Tile's data in scratchpad (0x200) 00175254: a0a00004 sb r0,0x0004(r5) |Nullify Tile's 0x04 in Targetable grid 00175258: 24420001 addiu r2,r2,0x0001 | 0017525c: a0a20000 sb r2,0x0000(r5) |Store Move +1 in Tile's AoE 00175260: 90620000 lbu r2,0x0000(r3) |Load Acting Unit Tile's flag 00175264: 00000000 nop | 00175268: 34420001 ori r2,r2,0x0001 | 0017526c: a0620000 sb r2,0x0000(r3) |Enabled Flag 0x01 in Acting Unit tile's flag (scratch pad 0x200) 00175270: 91220006 lbu r2,0x0006(r9) |Load Unit Move (scratch pad 0x00) 00175274: 00000000 nop | 00175278: 24420001 addiu r2,r2,0x0001 |Move + 1 0017527c: a1a20062 sb r2,0x0062(r13) |Store Acting Unit move +1 on scratch pad 0x180 00175280: 03e00008 jr r31 END 00175284: 00000000 nop
Return Locations
BATTLE.BIN 00174bf0: Set_Reachable_Tiles r4 = 0x01 001767e4: 001766b4_-_00176c0c r4 = 0x02 001784b8: Find_Tiles_for_the_AI_to_move_to_(00178ca4) r4 = 0x01 00178d6c: Calculate_Pathing r4 = 0x03