Calculate Tile Ceiling
(Redirected from 00176164 - 00176228)
Jump to navigation
Jump to search
BATTLE.BIN : Calculate Tile Ceiling ------------------------------------------------------------------------------------------------------- Parameters : r4 - Tile X coordinate r5 - Tile Y coordinate r6 - Tile Exit side slope mod r7 - Tile Exit side height / Or Tile Height + Unit Size (High elevation spreading) Returns : r2 = Ceiling Height if any r2 = 0x7f if no ceiling or invalid results Uses Data from ScratchPad 0x1f800000 --------------------------------------------------------------------------------------------------------- 00176164: 3c028019 lui r2,0x8019 | 00176168: 8c42f4e0 lw r2,-0x0b20(r2) |Pointer to scratch pad 0x1f800000 Pointer at 8019f4e0 0017616c: 00000000 nop | 00176170: 90420018 lbu r2,0x0018(r2) |Map Max X 00176174: 00000000 nop | 00176178: 00a20018 mult r5,r2 | 0017617c: 00805821 addu r11,r4,r0 |Tile's X Coord 00176180: 3408007f ori r8,r0,0x007f |Max Height (no ceiling) 00176184: 00005021 addu r10,r0,r0 |Initialize Elevation counter 00176188: 3c0c8019 lui r12,0x8019 | 0017618c: 258cf8cc addiu r12,r12,-0x0734 |Pointer : Tiles data ( 8019f8cc ) 00176190: 00004812 mflo r9 |Y*Max X @LOOP - 2 Times (Low elevation and High elevation) 00176194: 012b1021 addu r2,r9,r11 |This Iteration Tile ID (Low or High elevation) 00176198: 000210c0 sll r2,r2,0x03 |Tile's ID *8 0017619c: 004c2821 addu r5,r2,r12 |dynamic Tile data pointer ( 8019f8cc Table - from sent data) 001761a0: 90a20006 lbu r2,0x0006(r5) |Tile's 0x06 001761a4: 00000000 nop | 001761a8: 30420001 andi r2,r2,0x0001 | 001761ac: 14400019 bne r2,r0,0x00176214 #If Tile is Unselectable : branch to Next iteration 001761b0: 00000000 nop | 001761b4: 90a30003 lbu r3,0x0003(r5) |Load Halves + Depht 001761b8: 90a20004 lbu r2,0x0004(r5) |Load Slope Type 001761bc: 3063001f andi r3,r3,0x001f |Keep only halves 001761c0: 00c21007 srav r2,r2,r6 | 001761c4: 30420003 andi r2,r2,0x0003 |Keep Exit Side Slope type 001761c8: 00620018 mult r3,r2 | 001761cc: 90a40002 lbu r4,0x0002(r5) |Load Height 001761d0: 90a30005 lbu r3,0x0005(r5) |Load Tile's 0x05 (Thickness) 001761d4: 00042040 sll r4,r4,0x01 |Height * 2 001761d8: 3063001f andi r3,r3,0x001f |Thickness only Thickness ? 001761dc: 00031840 sll r3,r3,0x01 |Thickness * 2 001761e0: 00001012 mflo r2 |Halve * Exit Side slope mod 001761e4: 00822021 addu r4,r4,r2 |Exit Side Height 001761e8: 00832023 subu r4,r4,r3 |Potential Ceiling Height (Exit Side Height - Thickness) 001761ec: 308300ff andi r3,r4,0x00ff |Dynamic Ceiling Height 001761f0: 30e200ff andi r2,r7,0x00ff |Not Dynamic Exit Side Height 001761f4: 0043102b sltu r2,r2,r3 | 001761f8: 10400006 beq r2,r0,0x00176214 #If Exit Side height < Ceiling height False if no ceiling - keep 0x7f 001761fc: 310200ff andi r2,r8,0x00ff |0x7f 00176200: 0043102b sltu r2,r2,r3 |0x1 if 0x7f < Ceiling height 00176204: 10400002 beq r2,r0,0x00176210 #If Ceiling Height is invalid ? (> 0x7f) 00176208: 00000000 nop | 0017620c: 01002021 addu r4,r8,r0 |Preserve 0x7f 00176210: 00804021 addu r8,r4,r0 |r8 = Ceiling height 00176214: 254a0001 addiu r10,r10,0x0001 |Counter + 1 00176218: 29420002 slti r2,r10,0x0002 | 0017621c: 1440ffdd bne r2,r0,0x00176194 Λ Loop 2 times 00176220: 25290100 addiu r9,r9,0x0100 |High Elevation Offset 00176224: 03e00008 jr r31 | 00176228: 310200ff andi r2,r8,0x00ff |Returns Ceiling Height, or 0x7f
Return Locations
BATTLE.BIN 001757c0: 0017567c_-_00175954 00175868: 0017567c_-_00175954 00175ab0: Movement_routine 00175b80: Movement_routine 001772cc: 00177180_-_001773b4 00177344: 00177180_-_001773b4 001775ec: 001773b8_-_00177790 001776b4: 001773b8_-_00177790