Calculate Height Data
Jump to navigation
Jump to search
Calculate Height Data
0017c158: 27bdffd8 addiu r29,r29,0xffd8 0017c15c: afb20020 sw r18,0x0020(r29) 0017c160: 00809021 addu r18,r4,r0 r18 = Stack Pointer 0017c164: 00004021 addu r8,r0,r0 Height Mod = 0 0017c168: 000510c0 sll r2,r5,0x03 ID * 8 0017c16c: 00451023 subu r2,r2,r5 ID * 7 0017c170: 00021180 sll r2,r2,0x06 ID * 448 0017c174: 3c048019 lui r4,0x8019 0017c178: 248408cc addiu r4,r4,0x08cc 0017c17c: afb1001c sw r17,0x001c(r29) 0017c180: 00448821 addu r17,r2,r4 r17 = Unit's Data Pointer 0017c184: 2ca20015 sltiu r2,r5,0x0015 0017c188: afbf0024 sw r31,0x0024(r29) 0017c18c: 10400076 beq r2,r0,0x0017c368 Branch if ID >= 0x15 0017c190: afb00018 sw r16,0x0018(r29) 0017c194: 92230001 lbu r3,0x0001(r17) Load Unit's ID 0017c198: 340200ff ori r2,r0,0x00ff 0017c19c: 10620073 beq r3,r2,0x0017c36c Branch if Unit doesn't exist 0017c1a0: 34020080 ori r2,r0,0x0080 r2 = 0x80 0017c1a4: 96220058 lhu r2,0x0058(r17) Load Unit's Current Statuses 1&2 0017c1a8: 00000000 nop 0017c1ac: 30420140 andi r2,r2,0x0140 0017c1b0: 1440006e bne r2,r0,0x0017c36c Branch if Unit is Crystal/Treasure 0017c1b4: 34020080 ori r2,r0,0x0080 r2 = 0x80 0017c1b8: 92230003 lbu r3,0x0003(r17) Load Unit's Job ID 0017c1bc: 00000000 nop 0017c1c0: 2462ffa2 addiu r2,r3,0xffa2 ID - 0x5e 0017c1c4: 2c420003 sltiu r2,r2,0x0003 0017c1c8: 14400002 bne r2,r0,0x0017c1d4 Branch if Job is a chocobo 0017c1cc: 00a08021 addu r16,r5,r0 r16 = Unit's ID 0017c1d0: 34b00020 ori r16,r5,0x0020 Enable 0x20 in Unit ID 0017c1d4: 00003821 addu r7,r0,r0 Counter = 0 0017c1d8: 92220047 lbu r2,0x0047(r17) Load Unit's X coordinate 0017c1dc: 00803021 addu r6,r4,r0 r6 = Unit Data Pointer 0017c1e0: 304900ff andi r9,r2,0x00ff r9 = Unit's X Coordinate 0017c1e4: a3a20010 sb r2,0x0010(r29) Store X Coordinate 0017c1e8: 92240048 lbu r4,0x0048(r17) Load Unit's Y Coordinate 0017c1ec: 93a20012 lbu r2,0x0012(r29) Load ? 0017c1f0: 340a00ff ori r10,r0,0x00ff r10 = 0xff 0017c1f4: a3a40011 sb r4,0x0011(r29) Store Y Coordinate 0017c1f8: 308400ff andi r4,r4,0x00ff 0017c1fc: 96230048 lhu r3,0x0048(r17) Load Unit's Y Coordinate + Flags 0017c200: 30420080 andi r2,r2,0x0080 ? AND 0x80 0017c204: 00031bc2 srl r3,r3,0x0f Get Higher Elevation Flag 0017c208: 00431025 or r2,r2,r3 r2 = 0x0, 0x01, 0x80, or 0x81 0017c20c: a3a20012 sb r2,0x0012(r29) Store Higher Elevation + ? flag 0017c210: 10e50017 beq r7,r5,0x0017c270 Branch if Unit ID = Counter 0017c214: 00000000 nop 0017c218: 90c20001 lbu r2,0x0001(r6) Load Unit's ID 0017c21c: 00000000 nop 0017c220: 104a0013 beq r2,r10,0x0017c270 Branch if Unit doesn't exist 0017c224: 00000000 nop 0017c228: 90c20047 lbu r2,0x0047(r6) Load Unit's X Coordinate 0017c22c: 00000000 nop 0017c230: 1449000f bne r2,r9,0x0017c270 Branch if X Coordinates differ 0017c234: 00000000 nop 0017c238: 90c20048 lbu r2,0x0048(r6) Load Unit's Y Coordinate 0017c23c: 00000000 nop 0017c240: 1444000b bne r2,r4,0x0017c270 Branch if Y Coordinates Differ 0017c244: 00000000 nop 0017c248: 94c20048 lhu r2,0x0048(r6) Load Unit's Y Coordinate + Flags 0017c24c: 00000000 nop 0017c250: 000213c2 srl r2,r2,0x0f Get Higher Elevation Flag 0017c254: 14430006 bne r2,r3,0x0017c270 Branch if Elevations are different 0017c258: 32020020 andi r2,r16,0x0020 0017c25c: 10400002 beq r2,r0,0x0017c268 Branch if Unit is a chocobo 0017c260: 34080002 ori r8,r0,0x0002 Height Mod = 2 0017c264: 00c08821 addu r17,r6,r0 r17 = Unit Data Pointer 0017c268: 0805f0a0 j 0x0017c280 0017c26c: 36100040 ori r16,r16,0x0040 Enable 0x40 in Unit ID 0017c270: 24e70001 addiu r7,r7,0x0001 Counter ++ 0017c274: 28e20015 slti r2,r7,0x0015 0017c278: 1440ffe5 bne r2,r0,0x0017c210 Branch if Counter < 0x15 0017c27c: 24c601c0 addiu r6,r6,0x01c0 Unit Data Pointer += 0x1c0 0017c280: a3b00013 sb r16,0x0013(r29) Store Unit ID 0017c284: 9230005a lbu r16,0x005a(r17) Load Unit's Current Statuses 3 0017c288: 00000000 nop 0017c28c: 32020006 andi r2,r16,0x0006 0017c290: 14400002 bne r2,r0,0x0017c29c Branch if Unit is a frog/chicken 0017c294: 25020004 addiu r2,r8,0x0004 Height Mod += 4 (6 for chocobo) 0017c298: 25020006 addiu r2,r8,0x0006 Height Mod += 6 (8 for chocobo) 0017c29c: a3a20014 sb r2,0x0014(r29) Store Height Mod 0017c2a0: 92300095 lbu r16,0x0095(r17) Load Unit's Movement 3 0017c2a4: 0c060428 jal 0x001810a0 Map Location Calculation 0017c2a8: 02202021 addu r4,r17,r0 r4 = Unit Data Pointer 0017c2ac: 000210c0 sll r2,r2,0x03 Tile ID * 8 0017c2b0: 3c038019 lui r3,0x8019 0017c2b4: 2463f8cc addiu r3,r3,0xf8cc 0017c2b8: 00431021 addu r2,r2,r3 r2 = Tile's Data Pointer 0017c2bc: 90440002 lbu r4,0x0002(r2) Load Tile's Height 0017c2c0: 90430003 lbu r3,0x0003(r2) Load Tile's Height + Depth 0017c2c4: 90420003 lbu r2,0x0003(r2) Load Tile's Height + Depth 0017c2c8: 00042040 sll r4,r4,0x01 Height * 2 0017c2cc: 3063001f andi r3,r3,0x001f r3 = Height (halves) 0017c2d0: 00832021 addu r4,r4,r3 Height * 2 + Halves 0017c2d4: 00022942 srl r5,r2,0x05 r5 = Depth 0017c2d8: 10a00014 beq r5,r0,0x0017c32c Branch if Depth = 0 0017c2dc: 00801821 addu r3,r4,r0 r3 = Height * 2 + Halves 0017c2e0: 9222005a lbu r2,0x005a(r17) Load Unit's Current Statuses 3 0017c2e4: 00000000 nop 0017c2e8: 30420040 andi r2,r2,0x0040 0017c2ec: 10400004 beq r2,r0,0x0017c300 Branch if Unit isn't Floating 0017c2f0: 00051040 sll r2,r5,0x01 Depth * 2 0017c2f4: 24420002 addiu r2,r2,0x0002 Depth * 2 + 2 0017c2f8: 0805f0d1 j 0x0017c344 0017c2fc: 00821821 addu r3,r4,r2 Height*2 + Halves + Depth*2 + 2 0017c300: 32020080 andi r2,r16,0x0080 0017c304: 10400003 beq r2,r0,0x0017c314 Branch if Unit doesn't have Walk on Water 0017c308: 00051040 sll r2,r5,0x01 Depth * 2 0017c30c: 0805f0d1 j 0x0017c344 0017c310: 00821821 addu r3,r4,r2 Height*2 + Halves + Depth*2 0017c314: 32020040 andi r2,r16,0x0040 0017c318: 1040000a beq r2,r0,0x0017c344 Branch if Unit doesn't have Move in Water 0017c31c: 00051040 sll r2,r5,0x01 Depth * 2 0017c320: 2442fffe addiu r2,r2,0xfffe Depth * 2 - 2 0017c324: 0805f0d1 j 0x0017c344 0017c328: 00821821 addu r3,r4,r2 Height*2 + Halves + Depth*2 - 2 0017c32c: 9222005a lbu r2,0x005a(r17) Load Unit's Current Statuses 3 0017c330: 00000000 nop 0017c334: 30420040 andi r2,r2,0x0040 0017c338: 10400002 beq r2,r0,0x0017c344 Branch if Unit doesn't have Float (0 depth) 0017c33c: 00000000 nop 0017c340: 24830002 addiu r3,r4,0x0002 Height*2 + Halves + 2 0017c344: 93a20014 lbu r2,0x0014(r29) Load Height Mod 0017c348: a3a30015 sb r3,0x0015(r29) Store Modified Height 0017c34c: 00621021 addu r2,r3,r2 Modified Height + Height Mod 0017c350: a3a20016 sb r2,0x0016(r29) Store Final Height 0017c354: 92220058 lbu r2,0x0058(r17) Load Unit's Current Statuses 1 0017c358: 00000000 nop 0017c35c: 30420020 andi r2,r2,0x0020 0017c360: 10400003 beq r2,r0,0x0017c370 Branch if Unit isn't Dead 0017c364: 00000000 nop 0017c368: 34020080 ori r2,r0,0x0080 r2 = 0x80 0017c36c: a3a20013 sb r2,0x0013(r29) Store Unit ID = 0x80 0017c370: 8ba20013 lwl r2,0x0013(r29) Load X/Y/Higher Elevation/ID 0017c374: 9ba20010 lwr r2,0x0010(r29) 0017c378: 83a30014 lb r3,0x0014(r29) Load Height Mod 0017c37c: 83a40015 lb r4,0x0015(r29) Load Modified Height 0017c380: 83a50016 lb r5,0x0016(r29) Load Final Height 0017c384: aa420003 swl r2,0x0003(r18) Transfer from stack... to stack 0017c388: ba420000 swr r2,0x0000(r18) 0017c38c: a2430004 sb r3,0x0004(r18) 0017c390: a2440005 sb r4,0x0005(r18) 0017c394: a2450006 sb r5,0x0006(r18) 0017c398: 02401021 addu r2,r18,r0 r2 = Stack Pointer 0017c39c: 8fbf0024 lw r31,0x0024(r29) 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