Map Location Calculation
Jump to navigation
Jump to search
Map Location Calculation (requires r4 = Target Data Pointer) 001810a0: 90830048 lbu r3,0x0048(r4) Target Y Coordinate 001810a4: 3c02800e lui r2,0x800e 001810a8: 90424e9c lbu r2,0x4e9c(r2) Map Max X Coordinate 001810ac: 00000000 nop 001810b0: 00620018 mult r3,r2 Y * Max X 001810b4: 94820048 lhu r2,0x0048(r4) Y Coordinate + Elevation/Facing Flags 001810b8: 90840047 lbu r4,0x0047(r4) X Coordinate 001810bc: 000213c2 srl r2,r2,0x0f Checks for Higher Elevation 001810c0: 00021200 sll r2,r2,0x08 r2 = 0 or 256 (if at a Higher Elevation) 001810c4: 00001812 mflo r3 001810c8: 00431021 addu r2,r2,r3 Y * Max X + 0 or 256 001810cc: 03e00008 jr r31 001810d0: 00441021 addu r2,r2,r4 r2 = X + Y * Max X + 0 or 256 (Target's Tile ID)