List targeting data of all valid units
Jump to navigation
Jump to search
Parameters : r4 = Unit ID (always Attacker ?) r5 = Not valid Unit ID (preset value) r6 = Previous routine stack pointer Store : "0x1f800000" on previous routine stack pointer (0x00) A table of all valid unit targeting data (X mod, Height, Y mod, Spritesheets height) at 0x1f800000 (see notes) --------------------------------------------------------------------------------------------------------- 001af770: 27bdffc8 addiu r29,r29,-0x0038 | 001af774: afb40028 sw r20,0x0028(r29) | 001af778: 0080a021 addu r20,r4,r0 |r20 = Attacker's ID 001af77c: afb5002c sw r21,0x002c(r29) | 001af780: 00a0a821 addu r21,r5,r0 |r21 = Preset Value 001af784: afb20020 sw r18,0x0020(r29) | 001af788: 00c09021 addu r18,r6,r0 |r18 = Stack Pointer P 001af78c: afb30024 sw r19,0x0024(r29) | 001af790: 00009821 addu r19,r0,r0 |r19 = 0x00 (future loop counter - used as unit ID) 001af794: 3c021f80 lui r2,0x1f80 |r2 = 0x1f800000 001af798: afbf0030 sw r31,0x0030(r29) | 001af79c: afb1001c sw r17,0x001c(r29) | 001af7a0: afb00018 sw r16,0x0018(r29) | 001af7a4: ae420000 sw r2,0x0000(r18) |Store 0x1f800000 on previous routine stack pointer 001af7a8: ac400000 sw r0,0x0000(r2) |Store 0x00 at 0x1f800000 (future valid unit counter) 001af7ac: 0c0602bf jal 0x00180afc @ LOOP - ALL UNITS -->Get_Unit%27s_Data_Pointer returns r2 = stack pointer of Unit ID = r19 001af7b0: 02602021 addu r4,r19,r0 |r4 = Loop Counter (Unit ID) 001af7b4: 00408821 addu r17,r2,r0 |r17 = Unit's Data Pointer (matching r19) 001af7b8: 92230001 lbu r3,0x0001(r17) |r3 = Unit's ID 001af7bc: 00000000 nop | 001af7c0: 1074002f beq r3,r20,0x001af880 #If Unit is not the attacker / Else branch to next loop iteration 001af7c4: 26730001 addiu r19,r19,0x0001 |Increase counter (r19) 001af7c8: 1075002e beq r3,r21,0x001af884 #If unit <> Preset value / Else branch to next loop iteration (check counter < 0x15 is here...) 001af7cc: 2a620015 slti r2,r19,0x0015 |r2 = 0x01 if counter < 0x15 (for branch above ...) 001af7d0: 340200ff ori r2,r0,0x00ff |r2 =0xff 001af7d4: 1062002b beq r3,r2,0x001af884 #If Unit Exists / Else branch to next loop iteration 001af7d8: 2a620015 slti r2,r19,0x0015 |r2 = 0x01 if counter < 0x15 (for branch above ...) 001af7dc: 92220058 lbu r2,0x0058(r17) |r2 = Unit's Current Statuses 1 001af7e0: 00000000 nop | 001af7e4: 30420004 andi r2,r2,0x0004 |r2 = 0x04 if unit is jumping 001af7e8: 14400026 bne r2,r0,0x001af884 #If unit is not jumping / Else branch to next loop iteration 001af7ec: 2a620015 slti r2,r19,0x0015 |r2 = 0x01 if counter < 0x15 (for branch above ...) 001af7f0: 92220182 lbu r2,0x0182(r17) |r2 = Unit's Mount Info 001af7f4: 00000000 nop | 001af7f8: 30420040 andi r2,r2,0x0040 |r2 = 0x40 if unit is being ridden 001af7fc: 14400021 bne r2,r0,0x001af884 #If unit is not being ridden / Else branch to next loop iteration 001af800: 2a620015 slti r2,r19,0x0015 |r2 = 0x01 if counter < 0x15 (for branch above ...) 001af804: 8e430000 lw r3,0x0000(r18) |r3 = 0x1f800000 001af808: 00000000 nop | 001af80c: 8c700000 lw r16,0x0000(r3) |r16 = Valid unit counter 001af810: 00000000 nop | 001af814: 26020001 addiu r2,r16,0x0001 |r2 = Valid unit counter + 1 001af818: ac620000 sw r2,0x0000(r3) |store new valid unit counter at 0x1f800000 001af81c: 8e420000 lw r2,0x0000(r18) |r2 = 0x1f800000 001af820: 92230001 lbu r3,0x0001(r17) |r3 = Unit's ID 001af824: 00501021 addu r2,r2,r16 |r2 = 0x1f800000 + unchanged Pointer Mod 001af828: a0430004 sb r3,0x0004(r2) |Store unit ID at 0x1f800000 + Nb of valid Unit + 0x04 001af82c: 92240001 lbu r4,0x0001(r17) |r4 = unit's ID 001af830: 0c02311a jal 0x0008c468 |-->Set_Unit_Xmod,_Y_Mod_and_Height_data_from_unit_ID -returns r2 = 0x01 if data are on stack pointer 001af834: 27a50010 addiu r5,r29,0x0010 |r5 = Stack Pointer 0x10 001af838: 8e430000 lw r3,0x0000(r18) |r3 = 0x1f800000 001af83c: 001010c0 sll r2,r16,0x03 |r2 = r16 * 8 001af840: 00431021 addu r2,r2,r3 |r2 = 0x1f800000 + Nb of valid unit * 8 (2 words per valid unit) 001af844: 8ba30013 lwl r3,0x0013(r29) | 001af848: 9ba30010 lwr r3,0x0010(r29) |r3 = unaligned word at r29 0x10 - 0x13 (X mod and height data) 001af84c: 8ba40017 lwl r4,0x0017(r29) | 001af850: 9ba40014 lwr r4,0x0014(r29) |r4 = unaligned word at r29 0x14-0x17 (Y mod) 001af854: a843001d swl r3,0x001d(r2) | 001af858: b843001a swr r3,0x001a(r2) |Store Unit X mod and height data at 0x1f80001a + Valid unit counter * 8 001af85c: a8440021 swl r4,0x0021(r2) | 001af860: b844001e swr r4,0x001e(r2) |Store Unit Y mod and ?? (nothing ?) at 0x1f80001e + Valid unit counter * 8 001af864: 92240001 lbu r4,0x0001(r17) |r4 = Unit's ID 001af868: 0c023727 jal 0x0008dc9c |-->Find_Unit%27s_Misc_Data_Pointer_and_Load_Spritesheet_Value returns r2 = Unit spritesheet graphic height 001af86c: 00108080 sll r16,r16,0x02 |r16 = Nb of valid unit * 32 001af870: 8e430000 lw r3,0x0000(r18) |r3 = 0x1f800000 001af874: 00000000 nop | 001af878: 02038021 addu r16,r16,r3 |r16 = 0x1f800000 + Valid unit counter * 4 001af87c: ae0200c4 sw r2,0x00c4(r16) |Store Unit spritesheet graphic height at 0x1f8000c4 + Valid unit counter * 4 (one word per unit) 001af880: 2a620015 slti r2,r19,0x0015 |r2 = 0x01 if loop counter < 0x15 001af884: 1440ffc9 bne r2,r0,0x001af7ac #Loop while counter < 0x15 001af888: 00000000 nop | 001af88c: 8fbf0030 lw r31,0x0030(r29) | 001af890: 8fb5002c lw r21,0x002c(r29) | 001af894: 8fb40028 lw r20,0x0028(r29) | 001af898: 8fb30024 lw r19,0x0024(r29) | 001af89c: 8fb20020 lw r18,0x0020(r29) | 001af8a0: 8fb1001c lw r17,0x001c(r29) | 001af8a4: 8fb00018 lw r16,0x0018(r29) | 001af8a8: 27bd0038 addiu r29,r29,0x0038 | 001af8ac: 03e00008 jr r31 END 001af8b0: 00000000 nop
Notes
Store targeting data at 0x1f800000 0x00 : valid unit counter -- Unit ID -- (0x04 + counter) 0x004 : 1st valid unit ID 0x005 : 2nd valid unit ID ... 0x019 : 15th valid unit (max allowed units) -- Unit Xmod, Height, Y mod -- (0x1a + valid unit counter * 8) 0x01a : 1st unit X mod (halfword) 0x01c : 1st unit Height data (halfword) 0x01e : 1st unit Y mod (halfword) 0x020 : nothing ? ... 0x0ba : 15th unit X mod 0x0bc : 15th unit height 0x0be : 15th unit Y mod 0x0c0 : nothing ? 0x0c2 : nothing -- Unit spritesheet height -- (0xc4 + valid unit counter * 4) 0x0c4 : 1st unit spritesheet's height (word) 0x0c8 : 2nd unit spritesheet's height (word) ... 0x114 : 15th unit spritesheet's height
Return locations
Battle.bin 001afdf8: 001afd90_-_001aff14 001affb0: Set_and_Validate_Arc_Trajectory r4 = Attacker / preset value = -0x01 (0xffffffff) 001b074c: 001b06d0_-_001b0814 001b08ac: 001b0818_-_001b0a8c