Difference between revisions of "Calculate Height Data"
Jump to navigation
Jump to search
m (Notes Formatting, return location) |
m |
||
Line 15: | Line 15: | ||
0017c158: 27bdffd8 addiu r29,r29,-0x0028 | | 0017c158: 27bdffd8 addiu r29,r29,-0x0028 | | ||
0017c15c: afb20020 sw r18,0x0020(r29) | | 0017c15c: afb20020 sw r18,0x0020(r29) | | ||
− | 0017c160: 00809021 addu r18,r4,r0 |{{f/ | + | 0017c160: 00809021 addu r18,r4,r0 |{{f/adr|<nowiki>r18 = Stack Pointer</nowiki>}} |
0017c164: 00004021 addu r8,r0,r0 |{{f/std|<nowiki>r8 = 0 (serve as height mod)</nowiki>}} | 0017c164: 00004021 addu r8,r0,r0 |{{f/std|<nowiki>r8 = 0 (serve as height mod)</nowiki>}} | ||
0017c168: 000510c0 sll r2,r5,0x03 |{{f/std|<nowiki>r2 = Checked Unit ID * 8</nowiki>}} | 0017c168: 000510c0 sll r2,r5,0x03 |{{f/std|<nowiki>r2 = Checked Unit ID * 8</nowiki>}} | ||
Line 23: | Line 23: | ||
0017c178: 248408cc addiu r4,r4,0x08cc |{{f/std|<nowiki>r4 = 0x801908cc (start of units data)</nowiki>}} | 0017c178: 248408cc addiu r4,r4,0x08cc |{{f/std|<nowiki>r4 = 0x801908cc (start of units data)</nowiki>}} | ||
0017c17c: afb1001c sw r17,0x001c(r29) | | 0017c17c: afb1001c sw r17,0x001c(r29) | | ||
− | 0017c180: 00448821 addu r17,r2,r4 |{{f/ | + | 0017c180: 00448821 addu r17,r2,r4 |{{f/adr|<nowiki>r17 = Checked Unit's Data Pointer </nowiki>}} |
0017c184: 2ca20015 sltiu r2,r5,0x0015 |{{f/std|<nowiki>r2 = 0x01 if Checked unit ID < 0x15 (= valid)</nowiki>}} | 0017c184: 2ca20015 sltiu r2,r5,0x0015 |{{f/std|<nowiki>r2 = 0x01 if Checked unit ID < 0x15 (= valid)</nowiki>}} | ||
0017c188: afbf0024 sw r31,0x0024(r29) | | 0017c188: afbf0024 sw r31,0x0024(r29) | | ||
Line 81: | Line 81: | ||
0017c25c: 10400002 beq r2,r0,0x0017c268 {{f/Cond|<nowiki>If checked unit is not a chocobo</nowiki>}} | 0017c25c: 10400002 beq r2,r0,0x0017c268 {{f/Cond|<nowiki>If checked unit is not a chocobo</nowiki>}} | ||
0017c260: 34080002 ori r8,r0,0x0002 |{{f/std|<nowiki>r8 = 0x02 (2 units on same tile)</nowiki>}} | 0017c260: 34080002 ori r8,r0,0x0002 |{{f/std|<nowiki>r8 = 0x02 (2 units on same tile)</nowiki>}} | ||
− | 0017c264: 00c08821 addu r17,r6,r0 |{{f/ | + | 0017c264: 00c08821 addu r17,r6,r0 |{{f/adr|<nowiki>r17 = Loop Unit Data Pointer - ridden unit ?</nowiki>}} |
0017c268: 0805f0a0 j 0x0017c280 {{f/jump|<nowiki>Jump after loop</nowiki>}} | 0017c268: 0805f0a0 j 0x0017c280 {{f/jump|<nowiki>Jump after loop</nowiki>}} | ||
0017c26c: 36100040 ori r16,r16,0x0040 |{{f/std|<nowiki>r16 Unit ID with 0x40 Enabled (= same tile than Unit)</nowiki>}} | 0017c26c: 36100040 ori r16,r16,0x0040 |{{f/std|<nowiki>r16 Unit ID with 0x40 Enabled (= same tile than Unit)</nowiki>}} | ||
Line 149: | Line 149: | ||
0017c36c: a3a20013 sb r2,0x0013(r29) |{{f/store|<nowiki>Store checked Unit ID = 0x80</nowiki>}} | 0017c36c: a3a20013 sb r2,0x0013(r29) |{{f/store|<nowiki>Store checked Unit ID = 0x80</nowiki>}} | ||
0017c370: 8ba20013 lwl r2,0x0013(r29) | | 0017c370: 8ba20013 lwl r2,0x0013(r29) | | ||
− | 0017c374: 9ba20010 lwr r2,0x0010(r29) |{{f/ | + | 0017c374: 9ba20010 lwr r2,0x0010(r29) |{{f/load|<nowiki>r2 = X/Y/Elevation/ID (load unaligned word in two commands)</nowiki>}} |
0017c378: 83a30014 lb r3,0x0014(r29) |{{f/load|<nowiki>r3 = Unit(s) height</nowiki>}} | 0017c378: 83a30014 lb r3,0x0014(r29) |{{f/load|<nowiki>r3 = Unit(s) height</nowiki>}} | ||
0017c37c: 83a40015 lb r4,0x0015(r29) |{{f/load|<nowiki>r4 = walking height</nowiki>}} | 0017c37c: 83a40015 lb r4,0x0015(r29) |{{f/load|<nowiki>r4 = walking height</nowiki>}} | ||
Line 158: | Line 158: | ||
0017c390: a2440005 sb r4,0x0005(r18) |{{f/store|<nowiki>r18 0x05 = walking height</nowiki>}} | 0017c390: a2440005 sb r4,0x0005(r18) |{{f/store|<nowiki>r18 0x05 = walking height</nowiki>}} | ||
0017c394: a2450006 sb r5,0x0006(r18) |{{f/store|<nowiki>r18 0x06 = total height</nowiki>}} | 0017c394: a2450006 sb r5,0x0006(r18) |{{f/store|<nowiki>r18 0x06 = total height</nowiki>}} | ||
− | 0017c398: 02401021 addu r2,r18,r0 |{{f/ | + | 0017c398: 02401021 addu r2,r18,r0 |{{f/adr|<nowiki>r2 = Stack Pointer</nowiki>}} |
0017c39c: 8fbf0024 lw r31,0x0024(r29) '''END''' | 0017c39c: 8fbf0024 lw r31,0x0024(r29) '''END''' | ||
0017c3a0: 8fb20020 lw r18,0x0020(r29) | 0017c3a0: 8fb20020 lw r18,0x0020(r29) |
Revision as of 22:34, 10 December 2021
Calculate Height Data
Parameters : r4 = previous routine stack pointer r5 = unit ID Returns : r2 = previous routine stack pointer (r4) stack 0x00 = Unit X coordinates stack 0x01 = Unit Y coordinates stack 0x02 = Unit Elevation (0x00 or 0x01) +/- 0x80 (from ? on stack 0x12) stack 0x03 = Unit ID (0x80 if invalid Unit ID / crystal / treasure / dead) + 0x20 flag if not a chocobo + 0x40 flag if riding a unit (strickly two units at same coordinates) stack 0x04 = unit(s) height (check riding, frog, chicken) - 0x04 if frog-chicken, else 0x06 , + 0x02 if two units one same tile stack 0x05 = walking height (check float, depht + move on/in water) - Default : Tile Height (0x02) * 2 + Tile halves (0x03) stack 0x06 = total height (walking + unit) -------------------------------------------------------------------------------------------------------------------------------------------------------- 0017c158: 27bdffd8 addiu r29,r29,-0x0028 | 0017c15c: afb20020 sw r18,0x0020(r29) | 0017c160: 00809021 addu r18,r4,r0 |r18 = Stack Pointer 0017c164: 00004021 addu r8,r0,r0 |r8 = 0 (serve as height mod) 0017c168: 000510c0 sll r2,r5,0x03 |r2 = Checked Unit ID * 8 0017c16c: 00451023 subu r2,r2,r5 |r2 = Checked Unit ID * 7 0017c170: 00021180 sll r2,r2,0x06 |r2 = Checked Unit ID * 448 (0x1c0) 0017c174: 3c048019 lui r4,0x8019 | 0017c178: 248408cc addiu r4,r4,0x08cc |r4 = 0x801908cc (start of units data) 0017c17c: afb1001c sw r17,0x001c(r29) | 0017c180: 00448821 addu r17,r2,r4 |r17 = Checked Unit's Data Pointer 0017c184: 2ca20015 sltiu r2,r5,0x0015 |r2 = 0x01 if Checked unit ID < 0x15 (= valid) 0017c188: afbf0024 sw r31,0x0024(r29) | 0017c18c: 10400076 beq r2,r0,0x0017c368 #If Checked Unit ID is valid #Else branch near end (r2 = 0x80) 0017c190: afb00018 sw r16,0x0018(r29) | 0017c194: 92230001 lbu r3,0x0001(r17) |r3 = Checked Unit's ID 0017c198: 340200ff ori r2,r0,0x00ff |r2 = 0x00ff 0017c19c: 10620073 beq r3,r2,0x0017c36c #If Checked Unit exists #Else branch near end (r2 = 0x80) 0017c1a0: 34020080 ori r2,r0,0x0080 |r2 = 0x80 0017c1a4: 96220058 lhu r2,0x0058(r17) |r2 = Checked Unit's Current Statuses 1&2 0017c1a8: 00000000 nop | 0017c1ac: 30420140 andi r2,r2,0x0140 |r2 <> 0x00 if Checked unit has crystal or treasure 0017c1b0: 1440006e bne r2,r0,0x0017c36c #If Checked Unit has neither crystal nor treasure #Else branch near end (r2 = 0x80) 0017c1b4: 34020080 ori r2,r0,0x0080 |r2 = 0x80 0017c1b8: 92230003 lbu r3,0x0003(r17) |r3 = Checked Unit's Job ID 0017c1bc: 00000000 nop | 0017c1c0: 2462ffa2 addiu r2,r3,-0x005e |r2 = Checked Unit Job ID - 0x5e 0017c1c4: 2c420003 sltiu r2,r2,0x0003 |r2 = 0x01 if Job is chocobo (yellow, black and red) 0017c1c8: 14400002 bne r2,r0,0x0017c1d4 #If Checked Unit is not a chocobo #Branch if Job is a chocobo 0017c1cc: 00a08021 addu r16,r5,r0 |r16 = Chocobo Checked Unit's ID 0017c1d0: 34b00020 ori r16,r5,0x0020 |r16 = Checked Unit ID with 0x20 Enabled (not chocobo) 0017c1d4: 00003821 addu r7,r0,r0 |r7 = 0x00 (counter for next loop) 0017c1d8: 92220047 lbu r2,0x0047(r17) |r2 = Checked Unit's X coordinate 0017c1dc: 00803021 addu r6,r4,r0 |r6 = 0x801908cc 0017c1e0: 304900ff andi r9,r2,0x00ff |r9 = Checked Unit's X Coordinate (used in loop) 0017c1e4: a3a20010 sb r2,0x0010(r29) |Store Checked unit X Coordinate on pointer 0017c1e8: 92240048 lbu r4,0x0048(r17) |r4 = Checked Unit's Y Coordinate 0017c1ec: 93a20012 lbu r2,0x0012(r29) |Load ? 0017c1f0: 340a00ff ori r10,r0,0x00ff |r10 = 0x00ff 0017c1f4: a3a40011 sb r4,0x0011(r29) |Store Checked unit Y Coordinate on pointer 0017c1f8: 308400ff andi r4,r4,0x00ff |r4 = Checked Unit's Y Coordinate 0017c1fc: 96230048 lhu r3,0x0048(r17) |r3 = Checked Unit's Y Coordinate + Elevation/facing byte 0017c200: 30420080 andi r2,r2,0x0080 |? AND 0x80 0017c204: 00031bc2 srl r3,r3,0x0f |r3 = elevation bit (0x00 if not elevated, else 0x01) 0017c208: 00431025 or r2,r2,r3 |r2 = 0x0, 0x01, 0x80, or 0x81 0017c20c: a3a20012 sb r2,0x0012(r29) |Store Higher Elevation + ? Flag on stack 0x012 LOOP through unit ID seeking a unit on same tile than Unit (from r5) 0017c210: 10e50017 beq r7,r5,0x0017c270 @ LOOP #If Counter <> Checked Unit ID /Else branch to next loop iteration 0017c214: 00000000 nop | 0017c218: 90c20001 lbu r2,0x0001(r6) |r2 =Loop Unit's ID 0017c21c: 00000000 nop | 0017c220: 104a0013 beq r2,r10,0x0017c270 #If Loop unit exists /Else branch to next loop iteration 0017c224: 00000000 nop | 0017c228: 90c20047 lbu r2,0x0047(r6) |r2 = Loop Unit's X Coordinate 0017c22c: 00000000 nop | 0017c230: 1449000f bne r2,r9,0x0017c270 #If Loop Unit X coord matches checked Unit X coord /Else branch to next loop iteration 0017c234: 00000000 nop | 0017c238: 90c20048 lbu r2,0x0048(r6) |r2 =Loop Unit's Y Coordinate 0017c23c: 00000000 nop | 0017c240: 1444000b bne r2,r4,0x0017c270 #If loop unit Y coord matches checked unit Y coord /Else branch to next loop iteration 0017c244: 00000000 nop | 0017c248: 94c20048 lhu r2,0x0048(r6) |r2 = loop Unit's Y Coordinate + Elevation/facing Flags 0017c24c: 00000000 nop | 0017c250: 000213c2 srl r2,r2,0x0f |r2 = elevation bit (0x00 if not elevated, else 0x01) 0017c254: 14430006 bne r2,r3,0x0017c270 #If loop Unit Elevation matches checked Unit Elevation /Else branch to next loop iteration 0017c258: 32020020 andi r2,r16,0x0020 |r2 = 0x20 if checked Unit is not a chocobo 0017c25c: 10400002 beq r2,r0,0x0017c268 #If checked unit is not a chocobo 0017c260: 34080002 ori r8,r0,0x0002 |r8 = 0x02 (2 units on same tile) 0017c264: 00c08821 addu r17,r6,r0 |r17 = Loop Unit Data Pointer - ridden unit ? 0017c268: 0805f0a0 j 0x0017c280 >>Jump after loop 0017c26c: 36100040 ori r16,r16,0x0040 |r16 Unit ID with 0x40 Enabled (= same tile than Unit) 0017c270: 24e70001 addiu r7,r7,0x0001 |r7 = loop counter + 1 0017c274: 28e20015 slti r2,r7,0x0015 |r2 = 0x01 if r7 < 0x15 0017c278: 1440ffe5 bne r2,r0,0x0017c210 Λ Loop while counter < 0x15 0017c27c: 24c601c0 addiu r6,r6,0x01c0 |r6 = Unit Data Pointer += 0x1c0 (matching r7) 0017c280: a3b00013 sb r16,0x0013(r29) |Store updated checked Unit ID on stack 0x13 0017c284: 9230005a lbu r16,0x005a(r17) |r16 = Checked unit / Loop unit status set 3 0017c288: 00000000 nop | 0017c28c: 32020006 andi r2,r16,0x0006 |r2 <> 0x00 if unit on ground has frog 0017c290: 14400002 bne r2,r0,0x0017c29c #If unit on ground don't have chiken nor frog /Else branch (unit height set to 0x04 +/- 0x02) 0017c294: 25020004 addiu r2,r8,0x0004 |r2= 0x04 (or 0x06 if 2 units on same tile) 0017c298: 25020006 addiu r2,r8,0x0006 |r2 = 0x06 (or 0x08 if 2 units on same tile) - if unit don't have frog nor chicken 0017c29c: a3a20014 sb r2,0x0014(r29) |Store r2 (unit(s) height) on stack 0x14 0017c2a0: 92300095 lbu r16,0x0095(r17) |r16 = Unit's on ground Movement 3 0017c2a4: 0c060428 jal 0x001810a0 |-->Map_Location_Calculation returns r2 = Unit tile ID 0017c2a8: 02202021 addu r4,r17,r0 |r4 = Unit on ground Data Pointer 0017c2ac: 000210c0 sll r2,r2,0x03 |Unit on ground Tile ID * 8 0017c2b0: 3c038019 lui r3,0x8019 | 0017c2b4: 2463f8cc addiu r3,r3,-0x0734 |r3 = 0x8018f8cc (start of tiles data) 0017c2b8: 00431021 addu r2,r2,r3 |r2 = Tile's Data Pointer 0017c2bc: 90440002 lbu r4,0x0002(r2) |r4 = Unit Tile's Height 0017c2c0: 90430003 lbu r3,0x0003(r2) |r3 = Unit Tile's Height/2 + Depth 0017c2c4: 90420003 lbu r2,0x0003(r2) |r2 = Unit's Tile's Height/2 + Depth 0017c2c8: 00042040 sll r4,r4,0x01 |r4 = unit Tile's Height * 2 0017c2cc: 3063001f andi r3,r3,0x001f |r3 = unit tiles Height (halves) slope ? 0017c2d0: 00832021 addu r4,r4,r3 |r4 = unit Tiles Height * halves 0017c2d4: 00022942 srl r5,r2,0x05 |r5 = unit tiles Depth 0017c2d8: 10a00014 beq r5,r0,0x0017c32c #If depht <> 0x00 / Branch if Depth = 0 (avoiding gestion of depht in height calculation 0017c2dc: 00801821 addu r3,r4,r0 |r3 = Height * 2 + Halves 0017c2e0: 9222005a lbu r2,0x005a(r17) |r2 = Unit's Current Statuses 3 0017c2e4: 00000000 nop | 0017c2e8: 30420040 andi r2,r2,0x0040 |r2 = 0x40 if unit is floating 0017c2ec: 10400004 beq r2,r0,0x0017c300 #If Unit is floating 0017c2f0: 00051040 sll r2,r5,0x01 |r2 = Depth * 2 0017c2f4: 24420002 addiu r2,r2,0x0002 |r2 = Depth * 2 + 2 0017c2f8: 0805f0d1 j 0x0017c344 >>Jump after depht section 0017c2fc: 00821821 addu r3,r4,r2 |r3 = Height*2 + Halves + Depth*2 + 2 0017c300: 32020080 andi r2,r16,0x0080 #Else (not floating) r2 = 0x80 if unit as walk on water 0017c304: 10400003 beq r2,r0,0x0017c314 #If Unit walk on water 0017c308: 00051040 sll r2,r5,0x01 |r2 = Depth * 2 0017c30c: 0805f0d1 j 0x0017c344 >>Jump after depht section 0017c310: 00821821 addu r3,r4,r2 |r3 = Height*2 + Halves + Depth*2 0017c314: 32020040 andi r2,r16,0x0040 #Else (not floating - not walking on water) r2 = 0x40 if unit has move in water 0017c318: 1040000a beq r2,r0,0x0017c344 #If unit use move in water /Else branch after depht section (Depht * 2 will be added to height) 0017c31c: 00051040 sll r2,r5,0x01 |r2 = Depth * 2 0017c320: 2442fffe addiu r2,r2,0xfffe |r2 = Depth * 2 - 2 0017c324: 0805f0d1 j 0x0017c344 >>Jump after depht section 0017c328: 00821821 addu r3,r4,r2 |Height*2 + Halves + Depth*2 - 2 0017c32c: 9222005a lbu r2,0x005a(r17) #Else (depht = 0x00) r2 = Unit's Current Statuses 3 0017c330: 00000000 nop | 0017c334: 30420040 andi r2,r2,0x0040 |r2 = 0x40 if unit have float 0017c338: 10400002 beq r2,r0,0x0017c344 #If unit have float #Branch if Unit doesn't have Float (0 depth) 0017c33c: 00000000 nop | 0017c340: 24830002 addiu r3,r4,0x0002 |r3 = Height*2 + Halves + 2 0017c344: 93a20014 lbu r2,0x0014(r29) >>> r2 = unit(s) height /(jumps above landing site) 0017c348: a3a30015 sb r3,0x0015(r29) |Store walking Height at r29 0x15 0017c34c: 00621021 addu r2,r3,r2 |r2 = walking height + unit(s) height = total height 0017c350: a3a20016 sb r2,0x0016(r29) |Store total Height at r29 0x16 0017c354: 92220058 lbu r2,0x0058(r17) |r2 = Unit's on ground Current Statuses 1 0017c358: 00000000 nop | 0017c35c: 30420020 andi r2,r2,0x0020 |r2 = 0x20 if unit on ground is dead 0017c360: 10400003 beq r2,r0,0x0017c370 #If walking unit is dead #Branch if Unit isn't Dead 0017c364: 00000000 nop | 0017c368: 34020080 ori r2,r0,0x0080 #Else (invalid unit ID) r2 = 0x80 0017c36c: a3a20013 sb r2,0x0013(r29) |Store checked Unit ID = 0x80 0017c370: 8ba20013 lwl r2,0x0013(r29) | 0017c374: 9ba20010 lwr r2,0x0010(r29) |r2 = X/Y/Elevation/ID (load unaligned word in two commands) 0017c378: 83a30014 lb r3,0x0014(r29) |r3 = Unit(s) height 0017c37c: 83a40015 lb r4,0x0015(r29) |r4 = walking height 0017c380: 83a50016 lb r5,0x0016(r29) |r5 = total height 0017c384: aa420003 swl r2,0x0003(r18) |r18 0x01 = Y coord / 0x02 = elevation / 0x03 = Unit ID (with flags)) 0017c388: ba420000 swr r2,0x0000(r18) |r18 0x00 = unit X coord 0017c38c: a2430004 sb r3,0x0004(r18) |r18 0x04 = Unit(s) height 0017c390: a2440005 sb r4,0x0005(r18) |r18 0x05 = walking height 0017c394: a2450006 sb r5,0x0006(r18) |r18 0x06 = total height 0017c398: 02401021 addu r2,r18,r0 |r2 = Stack Pointer 0017c39c: 8fbf0024 lw r31,0x0024(r29) END 0017c3a0: 8fb20020 lw r18,0x0020(r29) 0017c3a4: 8fb1001c lw r17,0x001c(r29) 0017c3a8: 8fb00018 lw r16,0x0018(r29) 0017c3ac: 27bd0028 addiu r29,r29,0x0028 0017c3b0: 03e00008 jr r31 0017c3b4: 00000000 nop
Return locations
0006a7f8: 0006a7c0_-_0006aa7c 0006aab8: 0006aa80_-_0006ad14 0006cd28: Some_Knockback_Handling 0006ce60: Some_Knockback_Handling 0007d108: 0007d0d4_-_0007d2d8 0017447c: Store_movement_stuff_into_scratch_pad 0017b094: Auxilary_targeting_validation 0017b0bc: Auxilary_targeting_validation 0017b2a8: Auxilary_targeting_validation 0017b300: Auxilary_targeting_validation 0017b380: Auxilary_targeting_validation 0017b41c: Height/coordinate_validation 0017b444: Height/coordinate_validation 0017b660: Calculator_Routine 0018246c: Monster_Skill_check_prep 00182608: Monster_Skill_check