Difference between revisions of "Calculate Distance Between Units"
Jump to navigation
Jump to search
(Created page with " 0019936c: 90860047 lbu r6,0x0047(r4) Load Acting Unit's X 00199370: 90a30047 lbu r3,0x0047(r5) Load Target Unit's X 00199374: 90840048 lbu r4,0x0048(r4) Load Acting Unit...") |
|||
Line 1: | Line 1: | ||
− | 0019936c: 90860047 lbu r6,0x0047(r4) | + | BATTLE.BIN : Calculate Distance Between Units |
− | 00199370: 90a30047 lbu r3,0x0047(r5) | + | ------------------------------------------------------------------------------------------ |
− | 00199374: 90840048 lbu r4,0x0048(r4) | + | Parameters - r4 : Acting Unit data pointer (battle) |
− | 00199378: 90a20048 lbu r2,0x0048(r5) | + | r5 : Considered Unit data pointer |
− | 0019937c: 00c33023 subu r6,r6,r3 | + | Returns r2 : distance between the 2 units (Distance X + Distance Y) |
− | 00199380: 04c10002 bgez r6,0x0019938c | + | ----------------------------------------------------------------------------------------- |
− | 00199384: 00822023 subu r4,r4,r2 | + | 0019936c: 90860047 lbu r6,0x0047(r4) |{{f/load|Load Acting Unit's X}} |
− | 00199388: 00063023 subu r6,r0,r6 | + | 00199370: 90a30047 lbu r3,0x0047(r5) |{{f/load|Load Target Unit's X}} |
− | 0019938c: 04810002 bgez r4,0x00199398 | + | 00199374: 90840048 lbu r4,0x0048(r4) |{{f/load|Load Acting Unit's Y}} |
− | 00199390: 00000000 nop | + | 00199378: 90a20048 lbu r2,0x0048(r5) |{{f/load|Load Target Unit's Y}} |
− | 00199394: 00042023 subu r4,r0,r4 | + | 0019937c: 00c33023 subu r6,r6,r3 |{{f/std|Attacker X - Target X}} |
− | 00199398: 03e00008 jr r31 | + | 00199380: 04c10002 bgez r6,0x0019938c {{f/Cond|If delta X is negative}} |
− | 0019939c: 00c41021 addu r2,r6,r4 | + | 00199384: 00822023 subu r4,r4,r2 |{{f/std|Attacker Y - Target Y}} |
+ | 00199388: 00063023 subu r6,r0,r6 |{{f/std|Delta X becomes positive}} | ||
+ | 0019938c: 04810002 bgez r4,0x00199398 {{f/Cond|If Delta Y is negative}} | ||
+ | 00199390: 00000000 nop | | ||
+ | 00199394: 00042023 subu r4,r0,r4 |{{f/std|Delta Y becomes positive}} | ||
+ | 00199398: 03e00008 jr r31 Returns | ||
+ | 0019939c: 00c41021 addu r2,r6,r4 |{{f/std|<nowiki>r2 = Delta X + Delta Y</nowiki>}} | ||
+ | ===Return Locations=== | ||
+ | '''BATTLE.BIN''' | ||
+ | 00198b9c: [[Find_Peril_Most_Unit_(00198b04)]] | ||
+ | 0019926c: [[Calculate_Physical%3F_Target]] | ||
+ | 00199308: [[Calculate_Physical%3F_Target]] | ||
+ | 0019d0f8: [[AI_Target_Unit_for_Direct_vs_Arc_Attack_(0019cd9c)]] |
Latest revision as of 19:57, 3 May 2023
BATTLE.BIN : Calculate Distance Between Units ------------------------------------------------------------------------------------------ Parameters - r4 : Acting Unit data pointer (battle) r5 : Considered Unit data pointer Returns r2 : distance between the 2 units (Distance X + Distance Y) ----------------------------------------------------------------------------------------- 0019936c: 90860047 lbu r6,0x0047(r4) |Load Acting Unit's X 00199370: 90a30047 lbu r3,0x0047(r5) |Load Target Unit's X 00199374: 90840048 lbu r4,0x0048(r4) |Load Acting Unit's Y 00199378: 90a20048 lbu r2,0x0048(r5) |Load Target Unit's Y 0019937c: 00c33023 subu r6,r6,r3 |Attacker X - Target X 00199380: 04c10002 bgez r6,0x0019938c #If delta X is negative 00199384: 00822023 subu r4,r4,r2 |Attacker Y - Target Y 00199388: 00063023 subu r6,r0,r6 |Delta X becomes positive 0019938c: 04810002 bgez r4,0x00199398 #If Delta Y is negative 00199390: 00000000 nop | 00199394: 00042023 subu r4,r0,r4 |Delta Y becomes positive 00199398: 03e00008 jr r31 Returns 0019939c: 00c41021 addu r2,r6,r4 |r2 = Delta X + Delta Y
Return Locations
BATTLE.BIN 00198b9c: Find_Peril_Most_Unit_(00198b04) 0019926c: Calculate_Physical?_Target 00199308: Calculate_Physical?_Target 0019d0f8: AI_Target_Unit_for_Direct_vs_Arc_Attack_(0019cd9c)