Calculate Height Difference Between Units
Jump to navigation
Jump to search
BATTLE.BIN : Calculate Height Difference Between Units ------------------------------------------------------------------------------------------ Parameters : r4 = Acting unit data pointer r5 = Target Unit data pointer Returns : r2 = (Target Height - Acting unit Height)/2 ----------------------------------------------------------------------------------------- 0019b6b0: 90a20048 lbu r2,0x0048(r5) |Load Target's Y 0019b6b4: 3c06801a lui r6,0x801a | 0019b6b8: 90c601fe lbu r6,0x01fe(r6) |Load Map Max X (AI data) 801a01fe 0019b6bc: 00000000 nop | 0019b6c0: 00460018 mult r2,r6 | 0019b6c4: 00003812 mflo r7 |Target Y * Max X 0019b6c8: 90830002 lbu r3,0x0002(r4) |Load Acting Unit's Y 0019b6cc: 94a20048 lhu r2,0x0048(r5) |Load Target's Y + Map Level 0019b6d0: 00660018 mult r3,r6 | 0019b6d4: 000213c2 srl r2,r2,0x0f |Elevation flag 0019b6d8: 00021200 sll r2,r2,0x08 |Elevation * 256 (Offset of elevated tiles) 0019b6dc: 00471021 addu r2,r2,r7 |TY * Max X + Map Level * 256 0019b6e0: 90a30047 lbu r3,0x0047(r5) |Load Target's X 0019b6e4: 3c058019 lui r5,0x8019 | 0019b6e8: 24a5f8cc addiu r5,r5,-0x0734 |Start of Tiles data pointer 8018f8cc 0019b6ec: 00431021 addu r2,r2,r3 |Tile ID (Y coord * Max X) + X coord + (Elevation * 100) 0019b6f0: 000210c0 sll r2,r2,0x03 |Tile ID * 8 (offset in Tiles data) 0019b6f4: 00453021 addu r6,r2,r5 |Target's Tile data pointer 0019b6f8: 90830001 lbu r3,0x0001(r4) |Load Acting Unit's Elevation 0019b6fc: 90840000 lbu r4,0x0000(r4) |Load Acting Unit's X 0019b700: 00031a00 sll r3,r3,0x08 | 0019b704: 00001012 mflo r2 |Acting Unit Y* Max X 0019b708: 00621821 addu r3,r3,r2 | 0019b70c: 00641821 addu r3,r3,r4 |Acting unit tile ID (Y coord * Max X) + X coord + (Elevation * 100) 0019b710: 000318c0 sll r3,r3,0x03 |ID * 8 0019b714: 90c20002 lbu r2,0x0002(r6) |Load Target's Tile Height 0019b718: 90c40003 lbu r4,0x0003(r6) |Load Target's Tile Halves + Depth 0019b71c: 00653021 addu r6,r3,r5 |r6 = Acting Unit's Tile data pointer 0019b720: 90c30003 lbu r3,0x0003(r6) |Load Acting Unit's Tile Halves + Depth 0019b724: 00021040 sll r2,r2,0x01 |Target Height * 2 0019b728: 3084001f andi r4,r4,0x001f |Target Halves only 0019b72c: 00441021 addu r2,r2,r4 |Target Total Height Height * 2 + Halves 0019b730: 90c40002 lbu r4,0x0002(r6) |Load Acting Unit's Tile Height 0019b734: 3063001f andi r3,r3,0x001f |Actor Halves 0019b738: 00042040 sll r4,r4,0x01 |Actor height * 2 0019b73c: 00832021 addu r4,r4,r3 |Actor total height 0019b740: 00441023 subu r2,r2,r4 |Delta Height 0019b744: 00021fc2 srl r3,r2,0x1f |1 if negative value 0019b748: 00431021 addu r2,r2,r3 |Add 1 if Target is below Actor 0019b74c: 03e00008 jr r31 | 0019b750: 00021043 sra r2,r2,0x01 |Height Difference / 2
Return Locations
BATTLE.BIN 00199280: Calculate_Physical?_Target 0019b660: AI_Depth_Elemental_Monster_Skill_Use_Check_(0019b4f4)