Difference between revisions of "Targeting routine"
Jump to navigation
Jump to search
(Updated documentation) |
|||
Line 1: | Line 1: | ||
+ | Targeting routine: | ||
− | |||
0017b874: 27bdffb8 addiu r29,r29,0xffb8 | 0017b874: 27bdffb8 addiu r29,r29,0xffb8 | ||
0017b878: 27a50010 addiu r5,r29,0x0010 | 0017b878: 27a50010 addiu r5,r29,0x0010 | ||
Line 9: | Line 9: | ||
0017b88c: afb20030 sw r18,0x0030(r29) | 0017b88c: afb20030 sw r18,0x0030(r29) | ||
0017b890: afb1002c sw r17,0x002c(r29) | 0017b890: afb1002c sw r17,0x002c(r29) | ||
− | 0017b894: 0c01788b jal 0x0005e22c | + | 0017b894: 0c01788b jal 0x0005e22c transfer target ID |
0017b898: afb00028 sw r16,0x0028(r29) | 0017b898: afb00028 sw r16,0x0028(r29) | ||
0017b89c: 3c058019 lui r5,0x8019 | 0017b89c: 3c058019 lui r5,0x8019 | ||
− | 0017b8a0: 24a508cc addiu r5,r5,0x08cc | + | 0017b8a0: 24a508cc addiu r5,r5,0x08cc Unit Data |
− | 0017b8a4: 87a20012 lh r2,0x0012(r29) | + | 0017b8a4: 87a20012 lh r2,0x0012(r29) load Ability ID |
− | 0017b8a8: 93b40010 lbu r20,0x0010(r29) | + | 0017b8a8: 93b40010 lbu r20,0x0010(r29) load unit ID |
0017b8ac: 000218c0 sll r3,r2,0x03 | 0017b8ac: 000218c0 sll r3,r2,0x03 | ||
0017b8b0: 00621823 subu r3,r3,r2 | 0017b8b0: 00621823 subu r3,r3,r2 | ||
0017b8b4: 00031840 sll r3,r3,0x01 | 0017b8b4: 00031840 sll r3,r3,0x01 | ||
0017b8b8: 3c028006 lui r2,0x8006 | 0017b8b8: 3c028006 lui r2,0x8006 | ||
− | 0017b8bc: 2442fbf0 addiu r2,r2,0xfbf0 | + | 0017b8bc: 2442fbf0 addiu r2,r2,0xfbf0 Ability data 2 |
0017b8c0: 00621821 addu r3,r3,r2 | 0017b8c0: 00621821 addu r3,r3,r2 | ||
0017b8c4: 001410c0 sll r2,r20,0x03 | 0017b8c4: 001410c0 sll r2,r20,0x03 | ||
0017b8c8: 00541023 subu r2,r2,r20 | 0017b8c8: 00541023 subu r2,r2,r20 | ||
0017b8cc: 00021180 sll r2,r2,0x06 | 0017b8cc: 00021180 sll r2,r2,0x06 | ||
− | 0017b8d0: 90690003 lbu r9,0x0003(r3) | + | 0017b8d0: 90690003 lbu r9,0x0003(r3) r9 = Ability flags 1 |
− | 0017b8d4: 90710004 lbu r17,0x0004(r3) | + | 0017b8d4: 90710004 lbu r17,0x0004(r3) r17 = Ability flags 2 |
− | 0017b8d8: 90640006 lbu r4,0x0006(r3) | + | 0017b8d8: 90640006 lbu r4,0x0006(r3) r4 = Ability flags 4 |
− | 0017b8dc: 90730001 lbu r19,0x0001(r3) | + | 0017b8dc: 90730001 lbu r19,0x0001(r3) r19 = AoE |
− | 0017b8e0: 90750002 lbu r21,0x0002(r3) | + | 0017b8e0: 90750002 lbu r21,0x0002(r3) r21 = Vertical |
0017b8e4: 30840020 andi r4,r4,0x0020 | 0017b8e4: 30840020 andi r4,r4,0x0020 | ||
− | 0017b8e8: 10800003 beq r4,r0,0x 0017b8f8 branch | + | 0017b8e8: 10800003 beq r4,r0,0x 0017b8f8 branch if not direct attack |
− | 0017b8ec: 00458021 addu r16,r2,r5 | + | 0017b8ec: 00458021 addu r16,r2,r5 r16 = Attacker Unit Data Pointer |
− | 0017b8f0: 35290020 ori r9,r9,0x0020 | + | 0017b8f0: 35290020 ori r9,r9,0x0020 r9 = 20 (Remove all flags from Ability Flags 1 except Weapon Range) |
− | 0017b8f4: 32310039 andi r17,r17,0x0039 | + | 0017b8f4: 32310039 andi r17,r17,0x0039 Remove hit allies/enemies/3 directions/linear attack/hit caster (bypasses Top Down as well) |
− | + | ||
− | 0017b8f8: 32220006 andi r2,r17,0x0006 | + | 0017b8f8: 32220006 andi r2,r17,0x0006 Check linear flag |
0017b8fc: 10400006 beq r2,r0,0x 0017b918 Branch if not linear | 0017b8fc: 10400006 beq r2,r0,0x 0017b918 Branch if not linear | ||
0017b900: 34020006 ori r2,r0,0x0006 | 0017b900: 34020006 ori r2,r0,0x0006 | ||
− | If linear | + | |
− | 0017b904: 92050047 lbu r5,0x0047(r16) | + | If linear |
− | 0017b908: 96020048 lhu r2,0x0048(r16) | + | |
− | 0017b90c: 92040048 lbu r4,0x0048(r16) | + | 0017b904: 92050047 lbu r5,0x0047(r16) r5 = Target X coordinate |
− | 0017b910: 0805ee59 j 0x 0017b964 | + | 0017b908: 96020048 lhu r2,0x0048(r16) r2 = Target Y & Map Level coordinate |
+ | 0017b90c: 92040048 lbu r4,0x0048(r16) r4 = Target y coordinate | ||
+ | 0017b910: 0805ee59 j 0x 0017b964 skip following routine | ||
0017b914: 00021bc2 srl r3,r2,0x0f r3= Map Level? | 0017b914: 00021bc2 srl r3,r2,0x0f r3= Map Level? | ||
− | If not linear | + | |
− | 0017b918: 93a3001a lbu r3,0x001a(r29) | + | If not linear |
+ | *0x001a - Modified in (0074308) where value is set to 05 if Unit is under player control (ENTD 08) or if Unit ID = 2 (0x0168 of Misc Unit Data (0b7308)). | ||
+ | I have no idea if 0x0168 is actually Unit ID and I suspect not (doesn't really seem to coordinate with Unit IDs in ENTD), but it is cycled through and changed constantly during the AI's decision making process. It could otherwise very well be the decision value or the AI derived Unit ID aka Battle ID? | ||
+ | Otherwise 0x001a is usually 06. I don't know the significance of 04 (Miming action?), but 02 = Player Control, 01 = AI Control. I've only ever seen 05 or 06 when the process comes here. Perhaps if it's not 04, it doesn't come here at all? | ||
+ | Complete guesswork on my part here, but 04 might be tied to Action Menu flags (If not Default/Elemental/Monster/etc., or any skillset type that doesn't normally take AoE, then don't even go to (0074308)? | ||
+ | |||
+ | Anyways, 0x001a is important because the AI has to get the targeted unit, then determine it's X,Y. Player Controlled Units already have the X,Y loaded into the stack. | ||
+ | |||
+ | 0017b918: 93a3001a lbu r3,0x001a(r29) r3 = Player/AI* | ||
0017b91c: 00000000 nop | 0017b91c: 00000000 nop | ||
− | 0017b920: 10620006 beq r3,r2,0x 0017b93c | + | 0017b920: 10620006 beq r3,r2,0x 0017b93c branch if Target was not Player Determined (AI). |
0017b924: 00000000 nop | 0017b924: 00000000 nop | ||
− | 0017b928: 93a5001c lbu r5,0x001c(r29) | + | |
− | 0017b92c: 93a40020 lbu r4,0x0020(r29) | + | Player Chosen Target |
− | 0017b930: 93a3001e lbu r3,0x001e(r29) | + | |
+ | 0017b928: 93a5001c lbu r5,0x001c(r29) r5 = Target X | ||
+ | 0017b92c: 93a40020 lbu r4,0x0020(r29) r4 = Target Y | ||
+ | 0017b930: 93a3001e lbu r3,0x001e(r29) r3 = Map level | ||
0017b934: 0805ee59 j 0x 0017b964 | 0017b934: 0805ee59 j 0x 0017b964 | ||
0017b938: 00000000 nop | 0017b938: 00000000 nop | ||
− | 0017b93c: 93a2001b lbu r2,0x001b(r29) load | + | AI Chosen Target |
+ | |||
+ | 0017b93c: 93a2001b lbu r2,0x001b(r29) load Unit ID | ||
0017b940: 00000000 nop | 0017b940: 00000000 nop | ||
0017b944: 000218c0 sll r3,r2,0x03 | 0017b944: 000218c0 sll r3,r2,0x03 | ||
0017b948: 00621823 subu r3,r3,r2 | 0017b948: 00621823 subu r3,r3,r2 | ||
0017b94c: 00031980 sll r3,r3,0x06 | 0017b94c: 00031980 sll r3,r3,0x06 | ||
− | 0017b950: 00651821 addu r3,r3,r5 | + | 0017b950: 00651821 addu r3,r3,r5 Get Target Unit Data |
− | 0017b954: 90650047 lbu r5,0x0047(r3) | + | 0017b954: 90650047 lbu r5,0x0047(r3) r5 = Target X |
− | 0017b958: 94620048 lhu r2,0x0048(r3) | + | 0017b958: 94620048 lhu r2,0x0048(r3) r2 = Target Y & Map Level (0x8000 = High Tile) |
− | 0017b95c: 90640048 lbu r4,0x0048(r3) | + | 0017b95c: 90640048 lbu r4,0x0048(r3) r4 = Target Y |
− | 0017b960: 00021bc2 srl r3,r2,0x0f r3 = | + | 0017b960: 00021bc2 srl r3,r2,0x0f r3 = Target map level |
+ | |||
+ | Coordinate Vetting | ||
0017b964: 3c06800e lui r6,0x800e | 0017b964: 3c06800e lui r6,0x800e | ||
− | 0017b968: 90c64e9c lbu r6,0x4e9c(r6) | + | 0017b968: 90c64e9c lbu r6,0x4e9c(r6) r6 = Map Max X |
0017b96c: 00000000 nop | 0017b96c: 00000000 nop | ||
− | 0017b970: 00a6102a slt r2,r5,r6 set if | + | 0017b970: 00a6102a slt r2,r5,r6 set if Target X < Max X |
− | 0017b974: 104000b6 beq r2,r0,0x 0017bc50 | + | 0017b974: 104000b6 beq r2,r0,0x 0017bc50 Exit if Target is off the map (Invalid Location) |
0017b978: 2402ffff addiu r2,r0,0xffff return 0xffff | 0017b978: 2402ffff addiu r2,r0,0xffff return 0xffff | ||
0017b97c: 3c02800e lui r2,0x800e | 0017b97c: 3c02800e lui r2,0x800e | ||
− | 0017b980: 90424ea0 lbu r2,0x4ea0(r2) | + | 0017b980: 90424ea0 lbu r2,0x4ea0(r2) r2 = Max Y |
0017b984: 00000000 nop | 0017b984: 00000000 nop | ||
− | 0017b988: 0082102a slt r2,r4,r2 | + | 0017b988: 0082102a slt r2,r4,r2 Set if Target Y < Max Y |
− | 0017b98c: 10400010 beq r2,r0,0x 0017b9d0 | + | 0017b98c: 10400010 beq r2,r0,0x 0017b9d0 Exit if Target is off the map (Invalid Location) |
− | 0017b990: 28620002 slti r2,r3,0x0002 | + | 0017b990: 28620002 slti r2,r3,0x0002 Set if Target Map Level < 02 |
− | 0017b994: 1040000e beq r2,r0,0x 0017b9d0 | + | 0017b994: 1040000e beq r2,r0,0x 0017b9d0 Exit if Target is off the map (Invalid Location) |
− | 0017b998: 00860018 mult r4,r6 Target Y * | + | |
− | 0017b99c: 00031200 sll r2,r3,0x08 r2 = | + | isSelectable Location? |
+ | |||
+ | 0017b998: 00860018 mult r4,r6 Target Y * Map Max X | ||
+ | 0017b99c: 00031200 sll r2,r3,0x08 r2 = Map Level (00 or 01) * 100 | ||
0017b9a0: 00001812 mflo r3 | 0017b9a0: 00001812 mflo r3 | ||
0017b9a4: 00431021 addu r2,r2,r3 | 0017b9a4: 00431021 addu r2,r2,r3 | ||
− | 0017b9a8: 00453021 addu r6,r2,r5 | + | 0017b9a8: 00453021 addu r6,r2,r5 Target Y * Map Max X + Map Level + Target X |
− | 0017b9ac: 000618c0 sll r3,r6,0x03 | + | 0017b9ac: 000618c0 sll r3,r6,0x03 |
0017b9b0: 3c028019 lui r2,0x8019 | 0017b9b0: 3c028019 lui r2,0x8019 | ||
− | 0017b9b4: 2442f8cc addiu r2,r2,0xf8cc load | + | 0017b9b4: 2442f8cc addiu r2,r2,0xf8cc load Tile Geography Data start |
− | 0017b9b8: 00622821 addu r5,r3,r2 r5 = | + | 0017b9b8: 00622821 addu r5,r3,r2 r5 = Target Tile Geography |
− | 0017b9bc: 90a20006 lbu r2,0x0006(r5) load | + | 0017b9bc: 90a20006 lbu r2,0x0006(r5) load Selectability |
0017b9c0: 00000000 nop | 0017b9c0: 00000000 nop | ||
0017b9c4: 30420001 andi r2,r2,0x0001 | 0017b9c4: 30420001 andi r2,r2,0x0001 | ||
− | 0017b9c8: 10400003 beq r2,r0,0x 0017b9d8 | + | 0017b9c8: 10400003 beq r2,r0,0x 0017b9d8 Branch if Selectable |
0017b9cc: 00000000 nop | 0017b9cc: 00000000 nop | ||
− | 0017b9d0: 0805ef14 j 0x 0017bc50 | + | 0017b9d0: 0805ef14 j 0x 0017bc50 Exit |
0017b9d4: 2402ffff addiu r2,r0,0xffff return 0xffff | 0017b9d4: 2402ffff addiu r2,r0,0xffff return 0xffff | ||
− | + | ||
+ | Get Tile Height | ||
+ | |||
0017b9d8: 90a40002 lbu r4,0x0002(r5) load tile height | 0017b9d8: 90a40002 lbu r4,0x0002(r5) load tile height | ||
0017b9dc: 90a30003 lbu r3,0x0003(r5) load depth | 0017b9dc: 90a30003 lbu r3,0x0003(r5) load depth | ||
Line 101: | Line 123: | ||
0017b9e4: 00042040 sll r4,r4,0x01 height*2 | 0017b9e4: 00042040 sll r4,r4,0x01 height*2 | ||
0017b9e8: 3063001f andi r3,r3,0x001f r3 = height(halves) | 0017b9e8: 3063001f andi r3,r3,0x001f r3 = height(halves) | ||
− | 0017b9ec: 00832021 addu r4,r4,r3 | + | 0017b9ec: 00832021 addu r4,r4,r3 r4 = (height*2) + height halves |
− | 0017b9f0: 00021142 srl r2,r2,0x05 | + | 0017b9f0: 00021142 srl r2,r2,0x05 depth/2^5 |
− | 0017b9f4: 00021040 sll r2,r2,0x01 | + | 0017b9f4: 00021040 sll r2,r2,0x01 depth*2 |
− | 0017b9f8: 00829021 addu r18,r4,r2 | + | 0017b9f8: 00829021 addu r18,r4,r2 r18 = Total Height |
+ | |||
+ | AoE = entire map if AoE = 255 | ||
+ | |||
0017b9fc: 326300ff andi r3,r19,0x00ff r3 = ability AoE | 0017b9fc: 326300ff andi r3,r19,0x00ff r3 = ability AoE | ||
0017ba00: 340200ff ori r2,r0,0x00ff | 0017ba00: 340200ff ori r2,r0,0x00ff | ||
− | 0017ba04: 1462000c bne r3,r2,0x 0017ba38 | + | 0017ba04: 1462000c bne r3,r2,0x 0017ba38 Skip to Initialize Panels if AoE isn't 255 |
0017ba08: 00002021 addu r4,r0,r0 | 0017ba08: 00002021 addu r4,r0,r0 | ||
− | + | ||
− | |||
0017ba0c: 34050001 ori r5,r0,0x0001 | 0017ba0c: 34050001 ori r5,r0,0x0001 | ||
0017ba10: 3c038019 lui r3,0x8019 | 0017ba10: 3c038019 lui r3,0x8019 | ||
Line 120: | Line 144: | ||
0017ba28: 1440fffb bne r2,r0,0x 0017ba18 | 0017ba28: 1440fffb bne r2,r0,0x 0017ba18 | ||
0017ba2c: 24630005 addiu r3,r3,0x0005 tile counter++ | 0017ba2c: 24630005 addiu r3,r3,0x0005 tile counter++ | ||
− | 0017ba30: 0805eebf j 0x 0017bafc | + | 0017ba30: 0805eebf j 0x 0017bafc skip to Caster Tile |
0017ba34: 00000000 nop | 0017ba34: 00000000 nop | ||
− | Initialize panels for targeting | + | Initialize panels for targeting |
+ | |||
+ | Initial Clearing of all panels | ||
+ | |||
0017ba38: 3c038019 lui r3,0x8019 | 0017ba38: 3c038019 lui r3,0x8019 | ||
0017ba3c: 24632dd8 addiu r3,r3,0x2dd8 | 0017ba3c: 24632dd8 addiu r3,r3,0x2dd8 | ||
Line 130: | Line 157: | ||
0017ba48: 24840001 addiu r4,r4,0x0001 | 0017ba48: 24840001 addiu r4,r4,0x0001 | ||
0017ba4c: 28820200 slti r2,r4,0x0200 | 0017ba4c: 28820200 slti r2,r4,0x0200 | ||
− | 0017ba50: 1440fffb bne r2,r0,0x 0017ba40 | + | 0017ba50: 1440fffb bne r2,r0,0x 0017ba40 Do for all panels |
0017ba54: 24630005 addiu r3,r3,0x0005 | 0017ba54: 24630005 addiu r3,r3,0x0005 | ||
− | 0017ba58: 00061080 sll r2,r6,0x02 | + | Save Target/AoE data to Map Copies |
− | 0017ba5c: 00461821 addu r3,r2,r6 Target panel | + | |
+ | 0017ba58: 00061080 sll r2,r6,0x02 Target panel * 4 | ||
+ | 0017ba5c: 00461821 addu r3,r2,r6 Target panel * 5 | ||
0017ba60: 3c048019 lui r4,0x8019 | 0017ba60: 3c048019 lui r4,0x8019 | ||
− | 0017ba64: 24842dd8 addiu r4,r4,0x2dd8 | + | 0017ba64: 24842dd8 addiu r4,r4,0x2dd8 Load Tile Coordinate Data (192dd8) |
− | 0017ba68: 00644021 addu r8,r3,r4 r8 = | + | 0017ba68: 00644021 addu r8,r3,r4 r8 = Targeted Panel |
− | 0017ba6c: 26620001 addiu r2,r19,0x0001 r2 = | + | 0017ba6c: 26620001 addiu r2,r19,0x0001 r2 = AoE + 1 |
− | 0017ba70: a1020000 sb r2,0x0000(r8) | + | 0017ba70: a1020000 sb r2,0x0000(r8) Store AoE + 1 |
− | 0017ba74: 28c20100 slti r2,r6,0x0100 set if Target panel | + | 0017ba74: 28c20100 slti r2,r6,0x0100 set if Target panel = High Tile |
− | 0017ba78: 10400005 beq r2,r0,0x 0017ba90 | + | 0017ba78: 10400005 beq r2,r0,0x 0017ba90 branch if not |
− | 0017ba7c: 24820500 addiu r2,r4,0x0500 r2 = | + | 0017ba7c: 24820500 addiu r2,r4,0x0500 r2 = Copy of Tile Coordinate Data + 500 (1932d8) |
− | 0017ba80: 00623821 addu r7,r3,r2 r7 = | + | 0017ba80: 00623821 addu r7,r3,r2 r7 = Targeted Tile on Copy of Map |
0017ba84: 34020001 ori r2,r0,0x0001 | 0017ba84: 34020001 ori r2,r0,0x0001 | ||
− | 0017ba88: 0805eea8 j 0x 0017baa0 | + | 0017ba88: 0805eea8 j 0x 0017baa0 Next |
− | 0017ba8c: a1020001 sb r2,0x0001(r8) | + | 0017ba8c: a1020001 sb r2,0x0001(r8) Tile = Targeted on Copy of Low Tile Map |
− | 0017ba90: 2482fb00 addiu r2,r4,0xfb00 | + | 0017ba90: 2482fb00 addiu r2,r4,0xfb00 Copy of Tile Coordinate Data - 500 (1928d8) |
0017ba94: 00623821 addu r7,r3,r2 | 0017ba94: 00623821 addu r7,r3,r2 | ||
0017ba98: 34020001 ori r2,r0,0x0001 | 0017ba98: 34020001 ori r2,r0,0x0001 | ||
− | 0017ba9c: a0e20001 sb r2,0x0001(r7) | + | 0017ba9c: a0e20001 sb r2,0x0001(r7) Tile = Targeted on Copy of High Tile Map |
− | 0017baa0: 30c300ff andi r3,r6,0x00ff r3 = | + | 0017baa0: 30c300ff andi r3,r6,0x00ff r3 = Absolute Coordinate of Targeted Tile |
0017baa4: 00031080 sll r2,r3,0x02 | 0017baa4: 00031080 sll r2,r3,0x02 | ||
− | 0017baa8: 00431021 addu r2,r2,r3 | + | 0017baa8: 00431021 addu r2,r2,r3 Tile ID * 5 |
0017baac: 34030001 ori r3,r0,0x0001 | 0017baac: 34030001 ori r3,r0,0x0001 | ||
0017bab0: 3c018019 lui r1,0x8019 | 0017bab0: 3c018019 lui r1,0x8019 | ||
0017bab4: 00220821 addu r1,r1,r2 | 0017bab4: 00220821 addu r1,r1,r2 | ||
− | 0017bab8: a0232dd9 sb r3,0x2dd9(r1) | + | 0017bab8: a0232dd9 sb r3,0x2dd9(r1) Tile = Targeted |
− | 0017babc: 31220020 andi r2,r9,0x0020 | + | 0017babc: 31220020 andi r2,r9,0x0020 Direct/Weapon Range check |
− | 0017bac0: 1440000e bne r2,r0,0x 0017bafc | + | 0017bac0: 1440000e bne r2,r0,0x 0017bafc Branch to Caster Tile (No AoE is generated) |
− | 0017bac4: 02602021 addu r4,r19,r0 | + | 0017bac4: 02602021 addu r4,r19,r0 r4 = AoE |
+ | |||
+ | Generate AoE | ||
− | |||
0017bac8: 00002821 addu r5,r0,r0 | 0017bac8: 00002821 addu r5,r0,r0 | ||
0017bacc: 26620001 addiu r2,r19,0x0001 | 0017bacc: 26620001 addiu r2,r19,0x0001 | ||
Line 171: | Line 201: | ||
0017bad4: 0c05e546 jal 0x00179518 Store surrounding panels AoE value | 0017bad4: 0c05e546 jal 0x00179518 Store surrounding panels AoE value | ||
0017bad8: a0e20000 sb r2,0x0000(r7) store aoe + 1 | 0017bad8: a0e20000 sb r2,0x0000(r7) store aoe + 1 | ||
− | 0017badc: 324400ff andi r4,r18,0x00ff | + | |
− | 0017bae0: 02a02821 addu r5,r21,r0 | + | Check AoE against Vertical |
− | 0017bae4: 00113142 srl r6,r17,0x05 | + | |
+ | 0017badc: 324400ff andi r4,r18,0x00ff r4 = Targeted Tile Height | ||
+ | 0017bae0: 02a02821 addu r5,r21,r0 r5 = Vertical | ||
+ | 0017bae4: 00113142 srl r6,r17,0x05 r6 = Top Down, Hit Enemy/Ally | ||
0017bae8: 0c05e4a9 jal 0x001792a4 check vertical tolerance + if tiles can be chosen | 0017bae8: 0c05e4a9 jal 0x001792a4 check vertical tolerance + if tiles can be chosen | ||
− | 0017baec: 30c60001 andi r6,r6,0x0001 | + | 0017baec: 30c60001 andi r6,r6,0x0001 r6 = Top Down Targeting |
− | 0017baf0: 87a40012 lh r4,0x0012(r29) | + | 0017baf0: 87a40012 lh r4,0x0012(r29) Load Ability ID |
− | 0017baf4: 0c05e481 jal 0x00179204 | + | 0017baf4: 0c05e481 jal 0x00179204 Moldball Virus Depth Check |
0017baf8: 00000000 nop | 0017baf8: 00000000 nop | ||
− | 0017bafc: 0c060428 jal 0x001810a0 | + | Caster Tile |
− | 0017bb00: 02002021 addu r4,r16,r0 | + | |
− | 0017bb04: 00021880 sll r3,r2,0x02 | + | 0017bafc: 0c060428 jal 0x001810a0 Map Location Calculation (Caster) |
− | 0017bb08: 00621821 addu r3,r3,r2 | + | 0017bb00: 02002021 addu r4,r16,r0 r4 = Caster ID |
+ | 0017bb04: 00021880 sll r3,r2,0x02 Caster Tile ID * 4 | ||
+ | 0017bb08: 00621821 addu r3,r3,r2 Caster Tile ID * 5 | ||
0017bb0c: 3c128019 lui r18,0x8019 | 0017bb0c: 3c128019 lui r18,0x8019 | ||
− | 0017bb10: 26522dd8 addiu r18,r18,0x2dd8 | + | 0017bb10: 26522dd8 addiu r18,r18,0x2dd8 Load Tile Coordinate Data |
− | 0017bb14: 32220001 andi r2,r17,0x0001 | + | 0017bb14: 32220001 andi r2,r17,0x0001 Get Hit Caster |
− | 0017bb18: 10400002 beq r2,r0,0x 0017bb24 | + | 0017bb18: 10400002 beq r2,r0,0x 0017bb24 branch if hitting Caster is allowed |
0017bb1c: 00721821 addu r3,r3,r18 r3 = caster tile | 0017bb1c: 00721821 addu r3,r3,r18 r3 = caster tile | ||
− | 0017bb20: a0600000 sb r0,0x0000(r3) | + | 0017bb20: a0600000 sb r0,0x0000(r3) Caster Tile is not targeted |
− | Linear | + | |
+ | Linear | ||
+ | |||
0017bb24: 32220004 andi r2,r17,0x0004 | 0017bb24: 32220004 andi r2,r17,0x0004 | ||
− | 0017bb28: 10400003 beq r2,r0,0x 0017bb38 | + | 0017bb28: 10400003 beq r2,r0,0x 0017bb38 Branch if not Linear |
0017bb2c: 27a40010 addiu r4,r29,0x0010 | 0017bb2c: 27a40010 addiu r4,r29,0x0010 | ||
− | 0017bb30: 0c05ef9a jal 0x 0017be68 | + | 0017bb30: 0c05ef9a jal 0x 0017be68 Linear/Tri routine |
− | 0017bb34: 34050001 ori r5,r0,0x0001 | + | 0017bb34: 34050001 ori r5,r0,0x0001 r5 = isLinear |
− | 3 directions | + | |
+ | 3 directions | ||
+ | |||
0017bb38: 32220002 andi r2,r17,0x0002 | 0017bb38: 32220002 andi r2,r17,0x0002 | ||
− | 0017bb3c: 10400004 beq r2,r0,0x 0017bb50 | + | 0017bb3c: 10400004 beq r2,r0,0x 0017bb50 Branch if not 3 directions |
0017bb40: 323000c0 andi r16,r17,0x00c0 | 0017bb40: 323000c0 andi r16,r17,0x00c0 | ||
0017bb44: 27a40010 addiu r4,r29,0x0010 | 0017bb44: 27a40010 addiu r4,r29,0x0010 | ||
− | 0017bb48: 0c05ef9a jal 0x 0017be68 | + | 0017bb48: 0c05ef9a jal 0x 0017be68 Linear/Tri routine |
− | 0017bb4c: 34050003 ori r5,r0,0x0003 | + | 0017bb4c: 34050003 ori r5,r0,0x0003 r5 = isTri |
− | + | ||
− | 0017bb50: 12000006 beq r16,r0,0x 0017bb6c branch if | + | Hit Ally/Enemy Routine Prep |
− | 0017bb54: 02802021 addu r4,r20,r0 | + | |
− | 0017bb58: 32250080 andi r5,r17,0x0080 | + | 0017bb50: 12000006 beq r16,r0,0x 0017bb6c branch if neither hit ally/enemy are flagged (Normal Targeting) |
− | 0017bb5c: 32260040 andi r6,r17,0x0040 | + | 0017bb54: 02802021 addu r4,r20,r0 r4 = Unit ID |
− | 0017bb60: 3a6700ff xori r7,r19,0x00ff | + | 0017bb58: 32250080 andi r5,r17,0x0080 r5 = HitEnemies? |
+ | 0017bb5c: 32260040 andi r6,r17,0x0040 r6 = HitAllies? | ||
+ | 0017bb60: 3a6700ff xori r7,r19,0x00ff r7 = AoE - 255 | ||
0017bb64: 0c05ef1e jal 0x 0017bc78 hit ally/enemy routine | 0017bb64: 0c05ef1e jal 0x 0017bc78 hit ally/enemy routine | ||
− | 0017bb68: 2ce70001 sltiu r7,r7,0x0001 | + | 0017bb68: 2ce70001 sltiu r7,r7,0x0001 r7 = True if AoE = 255 |
+ | |||
+ | Mark AoE on Map | ||
− | 0017bb6c: 1600001d bne r16,r0,0x 0017bbe4 branch if | + | 0017bb6c: 1600001d bne r16,r0,0x 0017bbe4 branch if either Hit Ally/Enemy |
− | 0017bb70: 00003021 addu r6,r0,r0 | + | 0017bb70: 00003021 addu r6,r0,r0 r6 = Targeted Panel Counter |
− | 0017bb74: 00002021 addu r4,r0,r0 | + | 0017bb74: 00002021 addu r4,r0,r0 r4 = Tile Counter |
− | 0017bb78: 02402821 addu r5,r18,r0 | + | 0017bb78: 02402821 addu r5,r18,r0 r5 = Tile Coordinate Data |
0017bb7c: 3c038019 lui r3,0x8019 | 0017bb7c: 3c038019 lui r3,0x8019 | ||
− | 0017bb80: 2463f8cc addiu r3,r3,0xf8cc | + | 0017bb80: 2463f8cc addiu r3,r3,0xf8cc r3 = Tile Geography Data |
− | 0017bb84: 90a20000 lbu r2,0x0000(r5) | + | 0017bb84: 90a20000 lbu r2,0x0000(r5) Load Tile AoE |
0017bb88: 00000000 nop | 0017bb88: 00000000 nop | ||
− | 0017bb8c: 1040000a beq r2,r0,0x 0017bbb8 | + | 0017bb8c: 1040000a beq r2,r0,0x 0017bbb8 Branch if no AoE |
0017bb90: 00000000 nop | 0017bb90: 00000000 nop | ||
− | 0017bb94: 90620006 lbu r2,0x0006(r3) | + | 0017bb94: 90620006 lbu r2,0x0006(r3) Load Targetable/Selectable |
0017bb98: 00000000 nop | 0017bb98: 00000000 nop | ||
0017bb9c: 30420003 andi r2,r2,0x0003 | 0017bb9c: 30420003 andi r2,r2,0x0003 | ||
− | 0017bba0: 14400005 bne r2,r0,0x 0017bbb8 | + | 0017bba0: 14400005 bne r2,r0,0x 0017bbb8 Branch if not Targetable/Selectable |
0017bba4: 00000000 nop | 0017bba4: 00000000 nop | ||
− | 0017bba8: 90620005 lbu r2,0x0005(r3) | + | 0017bba8: 90620005 lbu r2,0x0005(r3) Load Panel Marking |
− | 0017bbac: 24c60001 addiu r6,r6,0x0001 | + | 0017bbac: 24c60001 addiu r6,r6,0x0001 Targeted Panel Counter++ |
0017bbb0: 0805eef1 j 0x 0017bbc4 | 0017bbb0: 0805eef1 j 0x 0017bbc4 | ||
− | 0017bbb4: 34420080 ori r2,r2,0x0080 | + | 0017bbb4: 34420080 ori r2,r2,0x0080 Add Marked Flag |
− | 0017bbb8: 90620005 lbu r2,0x0005(r3) | + | 0017bbb8: 90620005 lbu r2,0x0005(r3) Load Panel Marking |
0017bbbc: 00000000 nop | 0017bbbc: 00000000 nop | ||
− | 0017bbc0: 3042007f andi r2,r2,0x007f | + | 0017bbc0: 3042007f andi r2,r2,0x007f Invalidate Targeted Flag |
− | 0017bbc4: a0620005 sb r2,0x0005(r3) | + | 0017bbc4: a0620005 sb r2,0x0005(r3) Add or Invalidate Marked Flag |
− | 0017bbc8: 24a50005 addiu r5,r5,0x0005 | + | 0017bbc8: 24a50005 addiu r5,r5,0x0005 Tile Coordinate Data++ |
− | 0017bbcc: 24840001 addiu r4,r4,0x0001 | + | 0017bbcc: 24840001 addiu r4,r4,0x0001 Tile Counter++ |
0017bbd0: 28820200 slti r2,r4,0x0200 | 0017bbd0: 28820200 slti r2,r4,0x0200 | ||
− | 0017bbd4: 1440ffeb bne r2,r0,0x 0017bb84 | + | 0017bbd4: 1440ffeb bne r2,r0,0x 0017bb84 Branch for all 0200 panels |
− | 0017bbd8: 24630008 addiu r3,r3,0x0008 | + | 0017bbd8: 24630008 addiu r3,r3,0x0008 Tile Geography Data++ |
+ | |||
+ | 0017bbdc: 0805ef14 j 0x 0017bc50 End Routine | ||
+ | 0017bbe0: 00c01021 addu r2,r6,r0 Return # of Targeted Panels | ||
− | + | Mark Targeted Panels on Map | |
− | + | (Hit Enemy/Ally denotes panels that have targetable units on them via marking them as Targeted, as opposed to just zeroing out the AoE for the panels that shouldn't be targeted.) | |
− | 0017bbe4: 00002021 addu r4,r0,r0 | + | 0017bbe4: 00002021 addu r4,r0,r0 r4 = Tile Counter |
− | 0017bbe8: 02402821 addu r5,r18,r0 | + | 0017bbe8: 02402821 addu r5,r18,r0 r5 = Tile Coordinate Data |
0017bbec: 3c038019 lui r3,0x8019 | 0017bbec: 3c038019 lui r3,0x8019 | ||
− | 0017bbf0: 2463f8cc addiu r3,r3,0xf8cc | + | 0017bbf0: 2463f8cc addiu r3,r3,0xf8cc r3 = Tile Geography Data |
− | + | ||
− | 0017bbf4: 90a20001 lbu r2,0x0001(r5) | + | 0017bbf4: 90a20001 lbu r2,0x0001(r5) Load Targeted Flag |
0017bbf8: 00000000 nop | 0017bbf8: 00000000 nop | ||
− | 0017bbfc: 1040000a beq r2,r0,0x 0017bc28 | + | 0017bbfc: 1040000a beq r2,r0,0x 0017bc28 Branch if not Targeted |
0017bc00: 00000000 nop | 0017bc00: 00000000 nop | ||
− | 0017bc04: 90620006 lbu r2,0x0006(r3) | + | 0017bc04: 90620006 lbu r2,0x0006(r3) load Targetable/Selectable |
0017bc08: 00000000 nop | 0017bc08: 00000000 nop | ||
0017bc0c: 30420003 andi r2,r2,0x0003 | 0017bc0c: 30420003 andi r2,r2,0x0003 | ||
− | 0017bc10: 14400005 bne r2,r0,0x 0017bc28 | + | 0017bc10: 14400005 bne r2,r0,0x 0017bc28 Branch if not Targetable/Selectable |
0017bc14: 00000000 nop | 0017bc14: 00000000 nop | ||
− | 0017bc18: 90620005 lbu r2,0x0005(r3) | + | 0017bc18: 90620005 lbu r2,0x0005(r3) load Map Marking |
− | 0017bc1c: 24c60001 addiu r6,r6,0x0001 | + | 0017bc1c: 24c60001 addiu r6,r6,0x0001 Targeted Panel Counter++ |
− | 0017bc20: 0805ef0d j 0x 0017bc34 | + | 0017bc20: 0805ef0d j 0x 0017bc34 |
− | 0017bc24: 34420080 ori r2,r2,0x0080 | + | 0017bc24: 34420080 ori r2,r2,0x0080 Add Map Marking |
− | 0017bc28: 90620005 lbu r2,0x0005(r3) | + | 0017bc28: 90620005 lbu r2,0x0005(r3) |
0017bc2c: 00000000 nop | 0017bc2c: 00000000 nop | ||
− | 0017bc30: 3042007f andi r2,r2,0x007f | + | 0017bc30: 3042007f andi r2,r2,0x007f Invalidate Targeted Flag |
+ | |||
+ | 0017bc34: a0620005 sb r2,0x0005(r3) Add or Invalidate Map Marking | ||
+ | 0017bc38: 24a50005 addiu r5,r5,0x0005 Tile Coordinate Data++ | ||
+ | 0017bc3c: 24840001 addiu r4,r4,0x0001 Tile Counter++ | ||
+ | 0017bc40: 28820200 slti r2,r4,0x0200 | ||
+ | 0017bc44: 1440ffeb bne r2,r0,0x 0017bbf4 Branch for all 0200 panels (multiple selections how?) | ||
+ | 0017bc48: 24630008 addiu r3,r3,0x0008 Tile Geography Data++ | ||
+ | 0017bc4c: 00c01021 addu r2,r6,r0 Return # of Targeted Panels | ||
+ | |||
+ | <> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
0017bc50: 8fbf0040 lw r31,0x0040(r29) | 0017bc50: 8fbf0040 lw r31,0x0040(r29) | ||
0017bc54: 8fb5003c lw r21,0x003c(r29) | 0017bc54: 8fb5003c lw r21,0x003c(r29) |
Revision as of 02:07, 9 March 2017
Targeting routine:
0017b874: 27bdffb8 addiu r29,r29,0xffb8 0017b878: 27a50010 addiu r5,r29,0x0010 0017b87c: afbf0040 sw r31,0x0040(r29) 0017b880: afb5003c sw r21,0x003c(r29) 0017b884: afb40038 sw r20,0x0038(r29) 0017b888: afb30034 sw r19,0x0034(r29) 0017b88c: afb20030 sw r18,0x0030(r29) 0017b890: afb1002c sw r17,0x002c(r29) 0017b894: 0c01788b jal 0x0005e22c transfer target ID 0017b898: afb00028 sw r16,0x0028(r29) 0017b89c: 3c058019 lui r5,0x8019 0017b8a0: 24a508cc addiu r5,r5,0x08cc Unit Data 0017b8a4: 87a20012 lh r2,0x0012(r29) load Ability ID 0017b8a8: 93b40010 lbu r20,0x0010(r29) load unit ID 0017b8ac: 000218c0 sll r3,r2,0x03 0017b8b0: 00621823 subu r3,r3,r2 0017b8b4: 00031840 sll r3,r3,0x01 0017b8b8: 3c028006 lui r2,0x8006 0017b8bc: 2442fbf0 addiu r2,r2,0xfbf0 Ability data 2 0017b8c0: 00621821 addu r3,r3,r2 0017b8c4: 001410c0 sll r2,r20,0x03 0017b8c8: 00541023 subu r2,r2,r20 0017b8cc: 00021180 sll r2,r2,0x06 0017b8d0: 90690003 lbu r9,0x0003(r3) r9 = Ability flags 1 0017b8d4: 90710004 lbu r17,0x0004(r3) r17 = Ability flags 2 0017b8d8: 90640006 lbu r4,0x0006(r3) r4 = Ability flags 4 0017b8dc: 90730001 lbu r19,0x0001(r3) r19 = AoE 0017b8e0: 90750002 lbu r21,0x0002(r3) r21 = Vertical 0017b8e4: 30840020 andi r4,r4,0x0020 0017b8e8: 10800003 beq r4,r0,0x 0017b8f8 branch if not direct attack 0017b8ec: 00458021 addu r16,r2,r5 r16 = Attacker Unit Data Pointer 0017b8f0: 35290020 ori r9,r9,0x0020 r9 = 20 (Remove all flags from Ability Flags 1 except Weapon Range) 0017b8f4: 32310039 andi r17,r17,0x0039 Remove hit allies/enemies/3 directions/linear attack/hit caster (bypasses Top Down as well)
0017b8f8: 32220006 andi r2,r17,0x0006 Check linear flag 0017b8fc: 10400006 beq r2,r0,0x 0017b918 Branch if not linear 0017b900: 34020006 ori r2,r0,0x0006
If linear
0017b904: 92050047 lbu r5,0x0047(r16) r5 = Target X coordinate 0017b908: 96020048 lhu r2,0x0048(r16) r2 = Target Y & Map Level coordinate 0017b90c: 92040048 lbu r4,0x0048(r16) r4 = Target y coordinate 0017b910: 0805ee59 j 0x 0017b964 skip following routine 0017b914: 00021bc2 srl r3,r2,0x0f r3= Map Level?
If not linear *0x001a - Modified in (0074308) where value is set to 05 if Unit is under player control (ENTD 08) or if Unit ID = 2 (0x0168 of Misc Unit Data (0b7308)). I have no idea if 0x0168 is actually Unit ID and I suspect not (doesn't really seem to coordinate with Unit IDs in ENTD), but it is cycled through and changed constantly during the AI's decision making process. It could otherwise very well be the decision value or the AI derived Unit ID aka Battle ID? Otherwise 0x001a is usually 06. I don't know the significance of 04 (Miming action?), but 02 = Player Control, 01 = AI Control. I've only ever seen 05 or 06 when the process comes here. Perhaps if it's not 04, it doesn't come here at all? Complete guesswork on my part here, but 04 might be tied to Action Menu flags (If not Default/Elemental/Monster/etc., or any skillset type that doesn't normally take AoE, then don't even go to (0074308)?
Anyways, 0x001a is important because the AI has to get the targeted unit, then determine it's X,Y. Player Controlled Units already have the X,Y loaded into the stack.
0017b918: 93a3001a lbu r3,0x001a(r29) r3 = Player/AI* 0017b91c: 00000000 nop 0017b920: 10620006 beq r3,r2,0x 0017b93c branch if Target was not Player Determined (AI). 0017b924: 00000000 nop
Player Chosen Target
0017b928: 93a5001c lbu r5,0x001c(r29) r5 = Target X 0017b92c: 93a40020 lbu r4,0x0020(r29) r4 = Target Y 0017b930: 93a3001e lbu r3,0x001e(r29) r3 = Map level 0017b934: 0805ee59 j 0x 0017b964 0017b938: 00000000 nop
AI Chosen Target
0017b93c: 93a2001b lbu r2,0x001b(r29) load Unit ID 0017b940: 00000000 nop 0017b944: 000218c0 sll r3,r2,0x03 0017b948: 00621823 subu r3,r3,r2 0017b94c: 00031980 sll r3,r3,0x06 0017b950: 00651821 addu r3,r3,r5 Get Target Unit Data 0017b954: 90650047 lbu r5,0x0047(r3) r5 = Target X 0017b958: 94620048 lhu r2,0x0048(r3) r2 = Target Y & Map Level (0x8000 = High Tile) 0017b95c: 90640048 lbu r4,0x0048(r3) r4 = Target Y 0017b960: 00021bc2 srl r3,r2,0x0f r3 = Target map level
Coordinate Vetting
0017b964: 3c06800e lui r6,0x800e 0017b968: 90c64e9c lbu r6,0x4e9c(r6) r6 = Map Max X 0017b96c: 00000000 nop 0017b970: 00a6102a slt r2,r5,r6 set if Target X < Max X 0017b974: 104000b6 beq r2,r0,0x 0017bc50 Exit if Target is off the map (Invalid Location) 0017b978: 2402ffff addiu r2,r0,0xffff return 0xffff 0017b97c: 3c02800e lui r2,0x800e 0017b980: 90424ea0 lbu r2,0x4ea0(r2) r2 = Max Y 0017b984: 00000000 nop 0017b988: 0082102a slt r2,r4,r2 Set if Target Y < Max Y 0017b98c: 10400010 beq r2,r0,0x 0017b9d0 Exit if Target is off the map (Invalid Location) 0017b990: 28620002 slti r2,r3,0x0002 Set if Target Map Level < 02 0017b994: 1040000e beq r2,r0,0x 0017b9d0 Exit if Target is off the map (Invalid Location)
isSelectable Location?
0017b998: 00860018 mult r4,r6 Target Y * Map Max X 0017b99c: 00031200 sll r2,r3,0x08 r2 = Map Level (00 or 01) * 100 0017b9a0: 00001812 mflo r3 0017b9a4: 00431021 addu r2,r2,r3 0017b9a8: 00453021 addu r6,r2,r5 Target Y * Map Max X + Map Level + Target X 0017b9ac: 000618c0 sll r3,r6,0x03 0017b9b0: 3c028019 lui r2,0x8019 0017b9b4: 2442f8cc addiu r2,r2,0xf8cc load Tile Geography Data start 0017b9b8: 00622821 addu r5,r3,r2 r5 = Target Tile Geography 0017b9bc: 90a20006 lbu r2,0x0006(r5) load Selectability 0017b9c0: 00000000 nop 0017b9c4: 30420001 andi r2,r2,0x0001 0017b9c8: 10400003 beq r2,r0,0x 0017b9d8 Branch if Selectable 0017b9cc: 00000000 nop 0017b9d0: 0805ef14 j 0x 0017bc50 Exit 0017b9d4: 2402ffff addiu r2,r0,0xffff return 0xffff
Get Tile Height
0017b9d8: 90a40002 lbu r4,0x0002(r5) load tile height 0017b9dc: 90a30003 lbu r3,0x0003(r5) load depth 0017b9e0: 90a20003 lbu r2,0x0003(r5) load depth 0017b9e4: 00042040 sll r4,r4,0x01 height*2 0017b9e8: 3063001f andi r3,r3,0x001f r3 = height(halves) 0017b9ec: 00832021 addu r4,r4,r3 r4 = (height*2) + height halves 0017b9f0: 00021142 srl r2,r2,0x05 depth/2^5 0017b9f4: 00021040 sll r2,r2,0x01 depth*2 0017b9f8: 00829021 addu r18,r4,r2 r18 = Total Height
AoE = entire map if AoE = 255
0017b9fc: 326300ff andi r3,r19,0x00ff r3 = ability AoE 0017ba00: 340200ff ori r2,r0,0x00ff 0017ba04: 1462000c bne r3,r2,0x 0017ba38 Skip to Initialize Panels if AoE isn't 255 0017ba08: 00002021 addu r4,r0,r0
0017ba0c: 34050001 ori r5,r0,0x0001 0017ba10: 3c038019 lui r3,0x8019 0017ba14: 24632dd8 addiu r3,r3,0x2dd8 0017ba18: a0650000 sb r5,0x0000(r3) store highlight panel for targeting 0017ba1c: a0600001 sb r0,0x0001(r3) store panel not targeted 0017ba20: 24840001 addiu r4,r4,0x0001 Counter++ 0017ba24: 28820200 slti r2,r4,0x0200 Do for all tiles 0017ba28: 1440fffb bne r2,r0,0x 0017ba18 0017ba2c: 24630005 addiu r3,r3,0x0005 tile counter++ 0017ba30: 0805eebf j 0x 0017bafc skip to Caster Tile 0017ba34: 00000000 nop
Initialize panels for targeting
Initial Clearing of all panels
0017ba38: 3c038019 lui r3,0x8019 0017ba3c: 24632dd8 addiu r3,r3,0x2dd8 0017ba40: a0600000 sb r0,0x0000(r3) store panel not targetable 0017ba44: a0600001 sb r0,0x0001(r3) store panel not targeted 0017ba48: 24840001 addiu r4,r4,0x0001 0017ba4c: 28820200 slti r2,r4,0x0200 0017ba50: 1440fffb bne r2,r0,0x 0017ba40 Do for all panels 0017ba54: 24630005 addiu r3,r3,0x0005
Save Target/AoE data to Map Copies
0017ba58: 00061080 sll r2,r6,0x02 Target panel * 4 0017ba5c: 00461821 addu r3,r2,r6 Target panel * 5 0017ba60: 3c048019 lui r4,0x8019 0017ba64: 24842dd8 addiu r4,r4,0x2dd8 Load Tile Coordinate Data (192dd8) 0017ba68: 00644021 addu r8,r3,r4 r8 = Targeted Panel 0017ba6c: 26620001 addiu r2,r19,0x0001 r2 = AoE + 1 0017ba70: a1020000 sb r2,0x0000(r8) Store AoE + 1 0017ba74: 28c20100 slti r2,r6,0x0100 set if Target panel = High Tile 0017ba78: 10400005 beq r2,r0,0x 0017ba90 branch if not 0017ba7c: 24820500 addiu r2,r4,0x0500 r2 = Copy of Tile Coordinate Data + 500 (1932d8)
0017ba80: 00623821 addu r7,r3,r2 r7 = Targeted Tile on Copy of Map 0017ba84: 34020001 ori r2,r0,0x0001 0017ba88: 0805eea8 j 0x 0017baa0 Next 0017ba8c: a1020001 sb r2,0x0001(r8) Tile = Targeted on Copy of Low Tile Map
0017ba90: 2482fb00 addiu r2,r4,0xfb00 Copy of Tile Coordinate Data - 500 (1928d8) 0017ba94: 00623821 addu r7,r3,r2 0017ba98: 34020001 ori r2,r0,0x0001 0017ba9c: a0e20001 sb r2,0x0001(r7) Tile = Targeted on Copy of High Tile Map
0017baa0: 30c300ff andi r3,r6,0x00ff r3 = Absolute Coordinate of Targeted Tile 0017baa4: 00031080 sll r2,r3,0x02 0017baa8: 00431021 addu r2,r2,r3 Tile ID * 5 0017baac: 34030001 ori r3,r0,0x0001 0017bab0: 3c018019 lui r1,0x8019 0017bab4: 00220821 addu r1,r1,r2 0017bab8: a0232dd9 sb r3,0x2dd9(r1) Tile = Targeted 0017babc: 31220020 andi r2,r9,0x0020 Direct/Weapon Range check 0017bac0: 1440000e bne r2,r0,0x 0017bafc Branch to Caster Tile (No AoE is generated) 0017bac4: 02602021 addu r4,r19,r0 r4 = AoE
Generate AoE
0017bac8: 00002821 addu r5,r0,r0 0017bacc: 26620001 addiu r2,r19,0x0001 0017bad0: a1020000 sb r2,0x0000(r8) store aoe + 1 0017bad4: 0c05e546 jal 0x00179518 Store surrounding panels AoE value 0017bad8: a0e20000 sb r2,0x0000(r7) store aoe + 1
Check AoE against Vertical
0017badc: 324400ff andi r4,r18,0x00ff r4 = Targeted Tile Height 0017bae0: 02a02821 addu r5,r21,r0 r5 = Vertical 0017bae4: 00113142 srl r6,r17,0x05 r6 = Top Down, Hit Enemy/Ally 0017bae8: 0c05e4a9 jal 0x001792a4 check vertical tolerance + if tiles can be chosen 0017baec: 30c60001 andi r6,r6,0x0001 r6 = Top Down Targeting 0017baf0: 87a40012 lh r4,0x0012(r29) Load Ability ID 0017baf4: 0c05e481 jal 0x00179204 Moldball Virus Depth Check 0017baf8: 00000000 nop
Caster Tile
0017bafc: 0c060428 jal 0x001810a0 Map Location Calculation (Caster) 0017bb00: 02002021 addu r4,r16,r0 r4 = Caster ID 0017bb04: 00021880 sll r3,r2,0x02 Caster Tile ID * 4 0017bb08: 00621821 addu r3,r3,r2 Caster Tile ID * 5 0017bb0c: 3c128019 lui r18,0x8019 0017bb10: 26522dd8 addiu r18,r18,0x2dd8 Load Tile Coordinate Data 0017bb14: 32220001 andi r2,r17,0x0001 Get Hit Caster 0017bb18: 10400002 beq r2,r0,0x 0017bb24 branch if hitting Caster is allowed 0017bb1c: 00721821 addu r3,r3,r18 r3 = caster tile 0017bb20: a0600000 sb r0,0x0000(r3) Caster Tile is not targeted
Linear
0017bb24: 32220004 andi r2,r17,0x0004 0017bb28: 10400003 beq r2,r0,0x 0017bb38 Branch if not Linear 0017bb2c: 27a40010 addiu r4,r29,0x0010 0017bb30: 0c05ef9a jal 0x 0017be68 Linear/Tri routine 0017bb34: 34050001 ori r5,r0,0x0001 r5 = isLinear
3 directions
0017bb38: 32220002 andi r2,r17,0x0002 0017bb3c: 10400004 beq r2,r0,0x 0017bb50 Branch if not 3 directions 0017bb40: 323000c0 andi r16,r17,0x00c0 0017bb44: 27a40010 addiu r4,r29,0x0010 0017bb48: 0c05ef9a jal 0x 0017be68 Linear/Tri routine 0017bb4c: 34050003 ori r5,r0,0x0003 r5 = isTri
Hit Ally/Enemy Routine Prep
0017bb50: 12000006 beq r16,r0,0x 0017bb6c branch if neither hit ally/enemy are flagged (Normal Targeting) 0017bb54: 02802021 addu r4,r20,r0 r4 = Unit ID 0017bb58: 32250080 andi r5,r17,0x0080 r5 = HitEnemies? 0017bb5c: 32260040 andi r6,r17,0x0040 r6 = HitAllies? 0017bb60: 3a6700ff xori r7,r19,0x00ff r7 = AoE - 255 0017bb64: 0c05ef1e jal 0x 0017bc78 hit ally/enemy routine 0017bb68: 2ce70001 sltiu r7,r7,0x0001 r7 = True if AoE = 255
Mark AoE on Map
0017bb6c: 1600001d bne r16,r0,0x 0017bbe4 branch if either Hit Ally/Enemy 0017bb70: 00003021 addu r6,r0,r0 r6 = Targeted Panel Counter 0017bb74: 00002021 addu r4,r0,r0 r4 = Tile Counter 0017bb78: 02402821 addu r5,r18,r0 r5 = Tile Coordinate Data 0017bb7c: 3c038019 lui r3,0x8019 0017bb80: 2463f8cc addiu r3,r3,0xf8cc r3 = Tile Geography Data 0017bb84: 90a20000 lbu r2,0x0000(r5) Load Tile AoE 0017bb88: 00000000 nop 0017bb8c: 1040000a beq r2,r0,0x 0017bbb8 Branch if no AoE 0017bb90: 00000000 nop 0017bb94: 90620006 lbu r2,0x0006(r3) Load Targetable/Selectable 0017bb98: 00000000 nop 0017bb9c: 30420003 andi r2,r2,0x0003 0017bba0: 14400005 bne r2,r0,0x 0017bbb8 Branch if not Targetable/Selectable 0017bba4: 00000000 nop 0017bba8: 90620005 lbu r2,0x0005(r3) Load Panel Marking 0017bbac: 24c60001 addiu r6,r6,0x0001 Targeted Panel Counter++ 0017bbb0: 0805eef1 j 0x 0017bbc4 0017bbb4: 34420080 ori r2,r2,0x0080 Add Marked Flag
0017bbb8: 90620005 lbu r2,0x0005(r3) Load Panel Marking 0017bbbc: 00000000 nop 0017bbc0: 3042007f andi r2,r2,0x007f Invalidate Targeted Flag
0017bbc4: a0620005 sb r2,0x0005(r3) Add or Invalidate Marked Flag 0017bbc8: 24a50005 addiu r5,r5,0x0005 Tile Coordinate Data++ 0017bbcc: 24840001 addiu r4,r4,0x0001 Tile Counter++ 0017bbd0: 28820200 slti r2,r4,0x0200 0017bbd4: 1440ffeb bne r2,r0,0x 0017bb84 Branch for all 0200 panels 0017bbd8: 24630008 addiu r3,r3,0x0008 Tile Geography Data++
0017bbdc: 0805ef14 j 0x 0017bc50 End Routine 0017bbe0: 00c01021 addu r2,r6,r0 Return # of Targeted Panels
Mark Targeted Panels on Map (Hit Enemy/Ally denotes panels that have targetable units on them via marking them as Targeted, as opposed to just zeroing out the AoE for the panels that shouldn't be targeted.)
0017bbe4: 00002021 addu r4,r0,r0 r4 = Tile Counter 0017bbe8: 02402821 addu r5,r18,r0 r5 = Tile Coordinate Data 0017bbec: 3c038019 lui r3,0x8019 0017bbf0: 2463f8cc addiu r3,r3,0xf8cc r3 = Tile Geography Data
0017bbf4: 90a20001 lbu r2,0x0001(r5) Load Targeted Flag 0017bbf8: 00000000 nop 0017bbfc: 1040000a beq r2,r0,0x 0017bc28 Branch if not Targeted 0017bc00: 00000000 nop 0017bc04: 90620006 lbu r2,0x0006(r3) load Targetable/Selectable 0017bc08: 00000000 nop 0017bc0c: 30420003 andi r2,r2,0x0003 0017bc10: 14400005 bne r2,r0,0x 0017bc28 Branch if not Targetable/Selectable 0017bc14: 00000000 nop 0017bc18: 90620005 lbu r2,0x0005(r3) load Map Marking 0017bc1c: 24c60001 addiu r6,r6,0x0001 Targeted Panel Counter++ 0017bc20: 0805ef0d j 0x 0017bc34 0017bc24: 34420080 ori r2,r2,0x0080 Add Map Marking
0017bc28: 90620005 lbu r2,0x0005(r3) 0017bc2c: 00000000 nop 0017bc30: 3042007f andi r2,r2,0x007f Invalidate Targeted Flag
0017bc34: a0620005 sb r2,0x0005(r3) Add or Invalidate Map Marking 0017bc38: 24a50005 addiu r5,r5,0x0005 Tile Coordinate Data++ 0017bc3c: 24840001 addiu r4,r4,0x0001 Tile Counter++ 0017bc40: 28820200 slti r2,r4,0x0200 0017bc44: 1440ffeb bne r2,r0,0x 0017bbf4 Branch for all 0200 panels (multiple selections how?) 0017bc48: 24630008 addiu r3,r3,0x0008 Tile Geography Data++ 0017bc4c: 00c01021 addu r2,r6,r0 Return # of Targeted Panels
<>
0017bc50: 8fbf0040 lw r31,0x0040(r29) 0017bc54: 8fb5003c lw r21,0x003c(r29) 0017bc58: 8fb40038 lw r20,0x0038(r29) 0017bc5c: 8fb30034 lw r19,0x0034(r29) 0017bc60: 8fb20030 lw r18,0x0030(r29) 0017bc64: 8fb1002c lw r17,0x002c(r29) 0017bc68: 8fb00028 lw r16,0x0028(r29) 0017bc6c: 27bd0048 addiu r29,r29,0x0048 0017bc70: 03e00008 jr r31 0017bc74: 00000000 nop