Calculate Target Panels
Jump to navigation
Jump to search
# ROUTINE: CALCULATE TARGET PANELS Alternate version by Orkney Set_Target_Tiles # Parameters: # r4 = (usedActionData) Used action data # Returns: # r2 = { # -1, if: # * Acting unit index is invalid ( >= 21 ) # * Unit does not exist # * Katana inventory item ID was invalid (not in range 0x26 to 0x2F) # * Action menu ID was 5 or 15 # * Ability ID >= 0x170 for certain action menus (Default, Monster, Geomancy, Katana Inventory) # 0, if ability can follow target # 1, if ability cannot follow target # 2, if: # * Action menu ID is invalid ( >= 16 ), or unhandled (3, 11, 12, 13, 14) # * Using ranged weapon auto-target with range 0 # 3, if: # * No panels can be targeted # } 8017a8c0: 27bdffb8 addiu r29,r29,-0x0048 8017a8c4: 27a50010 addiu r5,r29,0x0010 # localActionData 8017a8c8: afbf0040 sw r31,0x0040(r29) 8017a8cc: afb5003c sw r21,0x003c(r29) 8017a8d0: afb40038 sw r20,0x0038(r29) 8017a8d4: afb30034 sw r19,0x0034(r29) 8017a8d8: afb20030 sw r18,0x0030(r29) 8017a8dc: afb1002c sw r17,0x002c(r29) 8017a8e0: 0c01788b jal 0x8005e22c # Copy Byte Data (20 Bytes) (Used Action data) (usedActionData, localActionData); 8017a8e4: afb00028 sw r16,0x0028(r29) 8017a8e8: 93a30010 lbu r3,0x0010(r29) # localActionData.ActingUnitIndex 8017a8ec: 00000000 nop 8017a8f0: 2c620015 sltiu r2,r3,0x0015 8017a8f4: 10400053 beq r2,r0,0x8017aa44 # if (localActionData.ActingUnitIndex >= 21) return -1; 8017a8f8: 00008021 addu r16,r0,r0 # type = 0 8017a8fc: 000310c0 sll r2,r3,0x03 # localActionData.ActingUnitIndex * 8 8017a900: 00431023 subu r2,r2,r3 # localActionData.ActingUnitIndex * 7 8017a904: 00021180 sll r2,r2,0x06 # localActionData.ActingUnitIndex * 448 8017a908: 3c038019 lui r3,0x8019 8017a90c: 246308cc addiu r3,r3,0x08cc # battleUnits 8017a910: 00438821 addu r17,r2,r3 # unit = battleUnits[localActionData.ActingUnitIndex] 8017a914: 92230001 lbu r3,0x0001(r17) # unit.UnitID 8017a918: 340200ff ori r2,r0,0x00ff 8017a91c: 1062006c beq r3,r2,0x8017aad0 # if (unit.UnitID == 0xff) return -1; 8017a920: 2402ffff addiu r2,r0,-0x0001 8017a924: 93a20011 lbu r2,0x0011(r29) # localActionData.SkillsetID 8017a928: 3c018006 lui r1,0x8006 8017a92c: 00220821 addu r1,r1,r2 8017a930: 90235cb4 lbu r3,0x5cb4(r1) # actionMenus[localActionData.SkillsetID] 8017a934: 00000000 nop 8017a938: 2c620010 sltiu r2,r3,0x0010 8017a93c: 10400052 beq r2,r0,0x8017aa88 # if (actionMenus[localActionData.SkillsetID] >= 16) return 2; 8017a940: 00031080 sll r2,r3,0x02 # actionMenus[localActionData.SkillsetID] * 4 8017a944: 3c018017 lui r1,0x8017 8017a948: 00220821 addu r1,r1,r2 8017a94c: 8c224068 lw r2,0x4068(r1) # jumpPtr = *(0x80174068 + (actionMenus[localActionData.SkillsetID] * 4)) 8017a950: 00000000 nop 8017a954: 00400008 jr r2 # // (jump to jumpPtr - see switch statement) 8017a958: 00000000 nop # value &jumpPtr jumpPtr # 0x00 0x80174068 0x8017a95c # 0x01 0x8017406c 0x8017a968 # 0x02 0x80174070 0x8017a9a0 # 0x03 0x80174074 0x8017aa88 # 0x04 0x80174078 0x8017a9b0 # 0x05 0x8017407c 0x8017aa44 # 0x06 0x80174080 0x8017a95c # 0x07 0x80174084 0x8017a9e4 # 0x08 0x80174088 0x8017aa08 # 0x09 0x8017408c 0x8017aa18 # 0x0A 0x80174090 0x8017aa08 # 0x0B 0x80174094 0x8017aa88 # 0x0C 0x80174098 0x8017aa88 # 0x0D 0x8017409c 0x8017aa88 # 0x0E 0x801740a0 0x8017aa88 # 0x0F 0x801740a4 0x8017aa44 # switch (actionMenus[localActionData.SkillsetID]) { # case 0: case 6: // Default or Monster 8017a95c: 97b40012 lhu r20,0x0012(r29) # abilityID = localActionData.AbilityID 8017a960: 0805ea8a j 0x8017aa28 8017a964: 34100001 ori r16,r0,0x0001 # type = 1 # break; # case 1: // Item Inventory 8017a968: 92220091 lbu r2,0x0091(r17) # unit.Support3 8017a96c: 00000000 nop 8017a970: 30420008 andi r2,r2,0x0008 # unit.Support3 & FLAG_THROW_ITEM 8017a974: 14400005 bne r2,r0,0x8017a98c 8017a978: 34120004 ori r18,r0,0x0004 # range = 4 8017a97c: 92230003 lbu r3,0x0003(r17) # if ((unit.Support3 & FLAG_THROW_ITEM) 8017a980: 3402005d ori r2,r0,0x005d 8017a984: 14620003 bne r3,r2,0x8017a994 # or (unit.JobID == JOB_MIME)) 8017a988: 00000000 nop # { 8017a98c: 0805ea8a j 0x8017aa28 8017a990: 34100002 ori r16,r0,0x0002 # type = 2 # } else { 8017a994: 34120001 ori r18,r0,0x0001 # range = 1 8017a998: 0805ea8a j 0x8017aa28 8017a99c: 34100002 ori r16,r0,0x0002 # type = 2 # } # break; # case 2: // Weapon Inventory 8017a9a0: 9222003a lbu r2,0x003a(r17) # unit.Move 8017a9a4: 34100002 ori r16,r0,0x0002 # type = 2 8017a9a8: 0805ea8a j 0x8017aa28 8017a9ac: 34520080 ori r18,r2,0x0080 # range = unit.Move | 0x80 # break; # case 4: // Geomancy 8017a9b0: 0c060428 jal 0x801810a0 # tileID = Map Location Calculation (unit); 8017a9b4: 02202021 addu r4,r17,r0 8017a9b8: 000210c0 sll r2,r2,0x03 # tileID * 8 8017a9bc: 3c018019 lui r1,0x8019 8017a9c0: 00220821 addu r1,r1,r2 8017a9c4: 9022f8cc lbu r2,-0x0734(r1) # tiles[tileID] 8017a9c8: 00000000 nop 8017a9cc: 3042003f andi r2,r2,0x003f # tiles[tileID] & 0x3f 8017a9d0: 3c018006 lui r1,0x8006 8017a9d4: 00220821 addu r1,r1,r2 8017a9d8: 9034e9d0 lbu r20,-0x1630(r1) # abilityID = geomancyAbility[tiles[tileID] & 0x3f] 8017a9dc: 0805ea8a j 0x8017aa28 8017a9e0: 34100001 ori r16,r0,0x0001 # type = 1 # break; # case 7: // Katana Inventory 8017a9e4: 93a20018 lbu r2,0x0018(r29) # localActionData.UsedItemID 8017a9e8: 00000000 nop 8017a9ec: 2442ffda addiu r2,r2,-0x0026 # localActionData.UsedItemID - 0x26 8017a9f0: 2c42000a sltiu r2,r2,0x000a 8017a9f4: 10400013 beq r2,r0,0x8017aa44 # if ((localActionData.UsedItemID - 0x26) >= 10) return -1; 8017a9f8: 34100001 ori r16,r0,0x0001 # type = 1 8017a9fc: 93a20018 lbu r2,0x0018(r29) # localActionData.UsedItemID 8017aa00: 0805ea8a j 0x8017aa28 8017aa04: 24540026 addiu r20,r2,0x0026 # abilityID = localActionData.UsedItemID + 0x26 # break; # case 8: case 10: // Attack or Charge 8017aa08: 0c05e946 jal 0x8017a518 # numPanels = Set targeting for weapon attack 2 (localActionData); 8017aa0c: 27a40010 addiu r4,r29,0x0010 8017aa10: 0805ea89 j 0x8017aa24 # break; 8017aa14: 00409821 addu r19,r2,r0 # case 9: // Jump 8017aa18: 0c05e772 jal 0x80179dc8 # numPanels = Set Ability Targeting? (localActionData); 8017aa1c: 27a40010 addiu r4,r29,0x0010 8017aa20: 00409821 addu r19,r2,r0 8017aa24: 34150010 ori r21,r0,0x0010 # flags = FLAG_NO_FOLLOW_TARGET # break; # case 5: case 15: // Blank/Unknown # return -1; # default: # return 2; # } 8017aa28: 34020001 ori r2,r0,0x0001 8017aa2c: 1602001d bne r16,r2,0x8017aaa4 # if (type == 1) { 8017aa30: 34020002 ori r2,r0,0x0002 8017aa34: 3283ffff andi r3,r20,0xffff # abilityID 8017aa38: 2c620170 sltiu r2,r3,0x0170 8017aa3c: 14400003 bne r2,r0,0x8017aa4c 8017aa40: 000310c0 sll r2,r3,0x03 # abilityID * 8 # if (abilityID >= 0x0170) { 8017aa44: 0805eab4 j 0x8017aad0 # return -1; 8017aa48: 2402ffff addiu r2,r0,-0x0001 # } 8017aa4c: 00431023 subu r2,r2,r3 # abilityID * 7 8017aa50: 00021040 sll r2,r2,0x01 # abilityID * 14 8017aa54: 3c038006 lui r3,0x8006 8017aa58: 2463fbf0 addiu r3,r3,-0x0410 8017aa5c: 00431021 addu r2,r2,r3 # abilityData2[abilityID] 8017aa60: 90520000 lbu r18,0x0000(r2) # range = abilityData2[abilityID].range 8017aa64: 90430003 lbu r3,0x0003(r2) # abilityData2[abilityID].Flags1 8017aa68: 90550004 lbu r21,0x0004(r2) # flags = abilityData2[abilityID].Flags2 8017aa6c: 30620002 andi r2,r3,0x0002 # abilityData2[abilityID].Flags1 & FLAGS_AUTO 8017aa70: 10400007 beq r2,r0,0x8017aa90 # if ((abilityData2[abilityID].Flags1 & FLAGS_AUTO) 8017aa74: 00000000 nop 8017aa78: 16400005 bne r18,r0,0x8017aa90 # and (range == 0) 8017aa7c: 30620020 andi r2,r3,0x0020 8017aa80: 14400003 bne r2,r0,0x8017aa90 # and ((abilityData2[abilityID].Flags1 & FLAGS_RANGED_WEAPON) == 0)) 8017aa84: 00000000 nop # { 8017aa88: 0805eab4 j 0x8017aad0 # return 2; 8017aa8c: 34020002 ori r2,r0,0x0002 # } 8017aa90: a7b40012 sh r20,0x0012(r29) # localActionData.AbilityID = abilityID 8017aa94: 0c05e8a4 jal 0x8017a290 # numPanels = Set panels affected by ability? (localActionData); 8017aa98: 27a40010 addiu r4,r29,0x0010 8017aa9c: 00409821 addu r19,r2,r0 8017aaa0: 34020002 ori r2,r0,0x0002 8017aaa4: 16020005 bne r16,r2,0x8017aabc # } else if (type == 2) { 8017aaa8: 02202021 addu r4,r17,r0 8017aaac: 0c05e85b jal 0x8017a16c 8017aab0: 324500ff andi r5,r18,0x00ff # numPanels = Calculate ability range with map parameters? (unit, range); 8017aab4: 00409821 addu r19,r2,r0 8017aab8: 34150010 ori r21,r0,0x0010 # flags = FLAG_NO_FOLLOW_TARGET; # } 8017aabc: 16600003 bne r19,r0,0x8017aacc 8017aac0: 32a20010 andi r2,r21,0x0010 # flags & FLAG_NO_FOLLOW_TARGET # if (numPanels == 0) { 8017aac4: 0805eab4 j 0x8017aad0 # return 3; 8017aac8: 34020003 ori r2,r0,0x0003 # } 8017aacc: 0002102b sltu r2,r0,r2 # return (flags & FLAG_NO_FOLLOW_TARGET) ? 1 : 0; 8017aad0: 8fbf0040 lw r31,0x0040(r29) 8017aad4: 8fb5003c lw r21,0x003c(r29) 8017aad8: 8fb40038 lw r20,0x0038(r29) 8017aadc: 8fb30034 lw r19,0x0034(r29) 8017aae0: 8fb20030 lw r18,0x0030(r29) 8017aae4: 8fb1002c lw r17,0x002c(r29) 8017aae8: 8fb00028 lw r16,0x0028(r29) 8017aaec: 27bd0048 addiu r29,r29,0x0048 8017aaf0: 03e00008 jr r31 8017aaf4: 00000000 nop
Return Locations
Battle.bin 00075568: Set move/act based on skillset