Set Target Tiles
Jump to navigation
Jump to search
BATTLE.BIN : - Set_Target_Tiles Alternate Version by Glain : Calculate_Target_Panels ------------------------------------------------------------------------------------------ Parameter : r4 Pointer to Action Data (Battle 0x16e model) Return : r2 = 0x00 if there are tiles to target and Ability can [Follow Target] r2 = 0x01 if there are tiles to target and Ability cannot [Follow Target] r2 = 0x03 if there are no tiles to target r2 = 0x02 if unhandled situation (action menu or ranged weapon auto-target with range 0) r2 = -0x01 if invalid situation (action menu, Ids) ------------------------------------------------------------------------------------------ 0017a8c0: 27bdffb8 addiu r29,r29,-0x0048 | 0017a8c4: 27a50010 addiu r5,r29,0x0010 |Stack 0x10 0017a8c8: afbf0040 sw r31,0x0040(r29) | 0017a8cc: afb5003c sw r21,0x003c(r29) | 0017a8d0: afb40038 sw r20,0x0038(r29) | 0017a8d4: afb30034 sw r19,0x0034(r29) | 0017a8d8: afb20030 sw r18,0x0030(r29) | 0017a8dc: afb1002c sw r17,0x002c(r29) | 0017a8e0: 0c01788b jal 0x8005e22c |-->Copy_Byte_Data_(20_Bytes) From r4 to r5 0017a8e4: afb00028 sw r16,0x0028(r29) | 0017a8e8: 93a30010 lbu r3,0x0010(r29) |Unit ID 0017a8ec: 00000000 nop | 0017a8f0: 2c620015 sltiu r2,r3,0x0015 | 0017a8f4: 10400053 beq r2,r0,0x8017aa44 #If Unit ID is invalid Exit returns -0x01 0017a8f8: 00008021 addu r16,r0,r0 |Default Action menu type Type (inner routine variable) 0017a8fc: 000310c0 sll r2,r3,0x03 | 0017a900: 00431023 subu r2,r2,r3 | 0017a904: 00021180 sll r2,r2,0x06 |Unit ID * 0x1c0 0017a908: 3c038019 lui r3,0x8019 | 0017a90c: 246308cc addiu r3,r3,0x08cc |Pointer to Unit Battle data 0017a910: 00438821 addu r17,r2,r3 | 0017a914: 92230001 lbu r3,0x0001(r17) |Unit Battle ID 0017a918: 340200ff ori r2,r0,0x00ff | 0017a91c: 1062006c beq r3,r2,0x8017aad0 #If Unit do not Exist anymore Exit returns -0x01 0017a920: 2402ffff addiu r2,r0,-0x0001 | 0017a924: 93a20011 lbu r2,0x0011(r29) |Considered Ability's Skillset ID 0017a928: 3c018006 lui r1,0x8006 | 0017a92c: 00220821 addu r1,r1,r2 | 0017a930: 90235cb4 lbu r3,0x5cb4(r1) |Considered Skillset Action Menu 0x80065cb4 + Skillset offset 0017a934: 00000000 nop | 0017a938: 2c620010 sltiu r2,r3,0x0010 | 0017a93c: 10400052 beq r2,r0,0x8017aa88 #If Considered Action Menu > 0x0f Exit returns 0x02 0017a940: 00031080 sll r2,r3,0x02 |Action menu offset (word) 0017a944: 3c018017 lui r1,0x8017 | 0017a948: 00220821 addu r1,r1,r2 | 0017a94c: 8c224068 lw r2,0x4068(r1) |Jump loaction based on action menu 0017a950: 00000000 nop | 0017a954: 00400008 jr r2 >>Jump to Action menu dedicated location 0017a958: 00000000 nop | Default / Monster 0017a95c: 97b40012 lhu r20,0x0012(r29) |Considered Ability ID 0017a960: 0805ea8a j 0x8017aa28 >>Avoid other Action menu sections 0017a964: 34100001 ori r16,r0,0x0001 |Set type = 0x1 Item Inventory 0017a968: 92220091 lbu r2,0x0091(r17) |Considered Unit Support 3 0017a96c: 00000000 nop | 0017a970: 30420008 andi r2,r2,0x0008 | 0017a974: 14400005 bne r2,r0,0x8017a98c #If Unit use [Throw Item] : branch to 0017a978: 34120004 ori r18,r0,0x0004 |Range = 0x4 0017a97c: 92230003 lbu r3,0x0003(r17) |Unit Job 0017a980: 3402005d ori r2,r0,0x005d | 0017a984: 14620003 bne r3,r2,0x8017a994 #If Unit is not a mime : branch to 0017a988: 00000000 nop | Throw item or Mime (range = 0x4) 0017a98c: 0805ea8a j 0x8017aa28 >>Avoid other Action menu sections 0017a990: 34100002 ori r16,r0,0x0002 |Type = 0x02 Not Throw item nor Mime (range = 0x1) 0017a994: 34120001 ori r18,r0,0x0001 |range = 0x1 0017a998: 0805ea8a j 0x8017aa28 >>Avoid other Action menu sections 0017a99c: 34100002 ori r16,r0,0x0002 |Type = 0x02 Weapon Inventory 0017a9a0: 9222003a lbu r2,0x003a(r17) |Unit move 0017a9a4: 34100002 ori r16,r0,0x0002 |Type = 0x02 0017a9a8: 0805ea8a j 0x8017aa28 >>Avoid other Action menu sections 0017a9ac: 34520080 ori r18,r2,0x0080 |Range = Move with flag 0x80 Elements 0017a9b0: 0c060428 jal 0x801810a0 |-->Map_Location_Calculation Returns unit Tile ID 0017a9b4: 02202021 addu r4,r17,r0 |Send Unit battle pointer 0017a9b8: 000210c0 sll r2,r2,0x03 | 0017a9bc: 3c018019 lui r1,0x8019 | 0017a9c0: 00220821 addu r1,r1,r2 | 0017a9c4: 9022f8cc lbu r2,-0x0734(r1) |Unit Tile Type 0x8018f8cc + Tile offset 0017a9c8: 00000000 nop | 0017a9cc: 3042003f andi r2,r2,0x003f |keep only tile type 0017a9d0: 3c018006 lui r1,0x8006 | 0017a9d4: 00220821 addu r1,r1,r2 | 0017a9d8: 9034e9d0 lbu r20,-0x1630(r1) |Ability ID based on Terrain 0x8005e9d0 + Terrain offset Geomancy_tiles_type_to_ability_table 0017a9dc: 0805ea8a j 0x8017aa28 >>Avoid other Action menu sections 0017a9e0: 34100001 ori r16,r0,0x0001 |Type = 0x01 katana inventory 0017a9e4: 93a20018 lbu r2,0x0018(r29) |Ability used item ID 0017a9e8: 00000000 nop | 0017a9ec: 2442ffda addiu r2,r2,-0x0026 |Ability - 0x26 0017a9f0: 2c42000a sltiu r2,r2,0x000a |Hardcoded check Ability to item (max 10 abilities) 0017a9f4: 10400013 beq r2,r0,0x8017aa44 #If Ability and katanas are mismatching Exit Returns -0x01 0017a9f8: 34100001 ori r16,r0,0x0001 |Type = 0x1 0017a9fc: 93a20018 lbu r2,0x0018(r29) |Ability used item ID 0017aa00: 0805ea8a j 0x8017aa28 >>Avoid other Action menu sections 0017aa04: 24540026 addiu r20,r2,0x0026 |Ability ID = katana ID - 0x26 Attack / Charge 0017aa08: 0c05e946 jal 0x8017a518 |-->Set_targeting_for_weapon_attack_2 0017aa0c: 27a40010 addiu r4,r29,0x0010 |Send Action pointer 0017aa10: 0805ea89 j 0x8017aa24 >>Avoid other Action menu sections Follow Target will be forced OFF (this is a reverted flag in Patcher) 0017aa14: 00409821 addu r19,r2,r0 |Preserve results (0 if no Tiles to target ?) Jump 0017aa18: 0c05e772 jal 0x80179dc8 |-->Set_Jump_Ability_Targeting 0017aa1c: 27a40010 addiu r4,r29,0x0010 |Send Action pointer 0017aa20: 00409821 addu r19,r2,r0 |Preserve results (0 if no Tiles to target ?) 0017aa24: 34150010 ori r21,r0,0x0010 |Follow Target is forced OFF (this is a reverted flag in Patcher) --- POST ACTION MENU SECTION --- 0017aa28: 34020001 ori r2,r0,0x0001 | 0017aa2c: 1602001d bne r16,r2,0x8017aaa4 #If Type is 0x01 (default / monster /Geomancy / Katana) 0017aa30: 34020002 ori r2,r0,0x0002 | 0017aa34: 3283ffff andi r3,r20,0xffff |Ability ID 0017aa38: 2c620170 sltiu r2,r3,0x0170 | 0017aa3c: 14400003 bne r2,r0,0x8017aa4c #If Ability do not have a data 2 Table 0017aa40: 000310c0 sll r2,r3,0x03 | 0017aa44: 0805eab4 j 0x8017aad0 |Exit Returns -0x01 0017aa48: 2402ffff addiu r2,r0,-0x0001 | Else : Ability has a data 2 table 0017aa4c: 00431023 subu r2,r2,r3 | 0017aa50: 00021040 sll r2,r2,0x01 | 0017aa54: 3c038006 lui r3,0x8006 | 0017aa58: 2463fbf0 addiu r3,r3,-0x0410 |0x8005fbf0 0017aa5c: 00431021 addu r2,r2,r3 |Pointer to Ability data 2 0017aa60: 90520000 lbu r18,0x0000(r2) |Ability Range 0017aa64: 90430003 lbu r3,0x0003(r2) |Ability Flags 1 0017aa68: 90550004 lbu r21,0x0004(r2) |Ability Flags 2 0017aa6c: 30620002 andi r2,r3,0x0002 | 0017aa70: 10400007 beq r2,r0,0x8017aa90 #If Ability has [Auto Target] 0017aa74: 00000000 nop | 0017aa78: 16400005 bne r18,r0,0x8017aa90 #If Ability Range = 0x00 0017aa7c: 30620020 andi r2,r3,0x0020 | 0017aa80: 14400003 bne r2,r0,0x8017aa90 #If Ability do not have [Weapon Range] 0017aa84: 00000000 nop | 0017aa88: 0805eab4 j 0x8017aad0 |Exit 0017aa8c: 34020002 ori r2,r0,0x0002 |Return 0x02 Else : Not Auto Target / or Range <> 0x00 or / Weapon Range 0017aa90: a7b40012 sh r20,0x0012(r29) |Preserve Ability ID 0017aa94: 0c05e8a4 jal 0x8017a290 |-->Set_panels_affected_by_ability%3F Spread Ability Range around Caster Tile 0017aa98: 27a40010 addiu r4,r29,0x0010 |Send Action Data pointer 0017aa9c: 00409821 addu r19,r2,r0 |Preserve result (Nb of Targeted Tiles) 0017aaa0: 34020002 ori r2,r0,0x0002 | 0017aaa4: 16020005 bne r16,r2,0x8017aabc #If Ability Type is 0x02 (Item / Weapon inventory/Default) 0017aaa8: 02202021 addu r4,r17,r0 |Send Pointer to caster battle data 0017aaac: 0c05e85b jal 0x8017a16c |-->Calculate_ability_range_with_map_parameters%3F 0017aab0: 324500ff andi r5,r18,0x00ff |Send range 0017aab4: 00409821 addu r19,r2,r0 |Preserve result (Nb of Targeted Tiles ?) 0017aab8: 34150010 ori r21,r0,0x0010 |Follow Target is forced OFF (this is a reverted flag in Patcher) 0017aabc: 16600003 bne r19,r0,0x8017aacc #If there is Targetable tiles Exit Returns 0x01 if [Follow Target] is OFF else 0x00 Reverted flag 0017aac0: 32a20010 andi r2,r21,0x0010 | Else : no targetable tiles 0017aac4: 0805eab4 j 0x8017aad0 |Exit Returns 0x03 0017aac8: 34020003 ori r2,r0,0x0003 0017aacc: 0002102b sltu r2,r0,r2 0017aad0: 8fbf0040 lw r31,0x0040(r29) 0017aad4: 8fb5003c lw r21,0x003c(r29) 0017aad8: 8fb40038 lw r20,0x0038(r29) 0017aadc: 8fb30034 lw r19,0x0034(r29) 0017aae0: 8fb20030 lw r18,0x0030(r29) 0017aae4: 8fb1002c lw r17,0x002c(r29) 0017aae8: 8fb00028 lw r16,0x0028(r29) 0017aaec: 27bd0048 addiu r29,r29,0x0048 0017aaf0: 03e00008 jr r31 0017aaf4: 00000000 nop
Notes
Table at 0x80174068
Jump addresses for Action menu RAM | Rank | Action Menu | Jump Address | -----------|-------|--------------------|---------------| 0x80174068 | 0x00 | Default | 0x8017a95c | 0x8017406c | 0x01 | Item Inventory | 0x8017a968 | 0x80174070 | 0x02 | Weapon Inventory | 0x8017a9a0 | 0x80174074 | 0x03 | Arithmeticks | 0x8017aa88 | 0x80174078 | 0x04 | Elements | 0x8017a9b0 | 0x8017407c | 0x05 | Blank | 0x8017aa44 | 0x80174080 | 0x06 | Monster | 0x8017a95c | 0x80174084 | 0x07 | Katana Inventory | 0x8017a9e4 | 0x80174088 | 0x08 | Attack | 0x8017aa08 | 0x8017408c | 0x09 | Jump | 0x8017aa18 | 0x80174090 | 0x0A | Charge | 0x8017aa08 | 0x80174094 | 0x0B | Defend | 0x8017aa88 | 0x80174098 | 0x0C | Change Equipment | 0x8017aa88 | 0x8017409c | 0x0D | Unknown | 0x8017aa88 | 0x801740a0 | 0x0E | Blank | 0x8017aa88 | 0x801740a4 | 0x0F | Unknown | 0x8017aa44 |
Return locations
BATTLE.BIN 00075238: Decide_what_to_do_based_on_skillset/ability_selections? 00075568: Set_move/act_based_on_skillset 0017e6a0: Store_counter_ability? 0018f1b4: Mimic_ability_setting 00197998: Range_Calculation? 0019ce74: AI_Target_Unit_for_Direct_vs_Arc_Attack_(0019cd9c)