Calculate Targeting for Menu Types
Jump to navigation
Jump to search
r4 = pointer to Attacker 0x16e returns : r2 = -0x01 if targeted coordinates are invalids, or action menu unknow 2 r2 = -0x01 if action menu is katana inventory and used item is not a katana r2 = -0x01 if Ability ID >= Potion and Routine is trying to get in targeting routine (AoE) r2 = 0x00 if Valid targeting (classic) r2 = 0x01 for Mathematics r2 = 0x02 if Non offensive action menu (Defend, Change Equipment, Unnown 1, Blank) or Invalid action menu (ID >= 0x10) --------------------------------------------------------------------------------------------------------------- 0017aaf8: 27bdffc8 addiu r29,r29,-0x0038 | 0017aafc: 27a50010 addiu r5,r29,0x0010 |r5 = Stack Pointer + 0x10 0017ab00: afbf0034 sw r31,0x0034(r29) | 0017ab04: afb20030 sw r18,0x0030(r29) | 0017ab08: afb1002c sw r17,0x002c(r29) | 0017ab0c: 0c01788b jal 0x0005e22c |-->Copy_Byte_Data_(20_Bytes) Copy Attacker 0x16e to 0x181 on Stack r29 0x10 to 0x23 0017ab10: afb00028 sw r16,0x0028(r29) | 0017ab14: 93a30010 lbu r3,0x0010(r29) |r3 = Attacker ID (0x16e from stack) 0017ab18: 00000000 nop | 0017ab1c: 2c620015 sltiu r2,r3,0x0015 |r2 = 0x01 if Attacker ID is < 0x15 0017ab20: 10400042 beq r2,r0,0x0017ac2c #If Attacker ID is valid /Else branch to a jump to END (r2 will be -0x01) 0017ab24: 34110001 ori r17,r0,0x0001 |r17 = 0x01 (Default value for all action menus) 0017ab28: 000310c0 sll r2,r3,0x03 |r2 = Attacker ID *8 0017ab2c: 00431023 subu r2,r2,r3 |r2 = Attacker ID *7 0017ab30: 00021180 sll r2,r2,0x06 |r2 = Attacker ID *448 0017ab34: 3c038019 lui r3,0x8019 |r3 = 0x80190000 0017ab38: 246308cc addiu r3,r3,0x08cc |r3 = Start of unit data ( 0x801908cc ) 0017ab3c: 00432021 addu r4,r2,r3 |r4 = Attacker's Data Pointer 0017ab40: 90830001 lbu r3,0x0001(r4) |r3 = Attacker ID 0017ab44: 340200ff ori r2,r0,0x00ff |r2 = 0xff 0017ab48: 10620038 beq r3,r2,0x0017ac2c #If Attacker exists (ID <> 0xff) /Else branch to a jump to END (r2 will be -0x01) 0017ab4c: 34020006 ori r2,r0,0x0006 |r2 = 0x06 0017ab50: 93a3001a lbu r3,0x001a(r29) |r3 = Attacker 0x178 (reaction ID ?) from stack 0017ab54: 00000000 nop | 0017ab58: 14620006 bne r3,r2,0x0017ab74 #If Attacker 0x178 = 0x06 (Target specific ability ?) /Else avoid checking Target ID validity 0017ab5c: 00000000 nop | 0017ab60: 93a2001b lbu r2,0x001b(r29) |r2 = Target ID Attacker 0x179 from stack 0017ab64: 00000000 nop | 0017ab68: 2c420015 sltiu r2,r2,0x0015 |r2 = 0x01 if Target ID < 15 0017ab6c: 10400041 beq r2,r0,0x0017ac74 #If Target is valid /Else branch to END (r2 = -0x01) 0017ab70: 2402ffff addiu r2,r0,0xffff |r2 = -0x01 0017ab74: 93a20011 lbu r2,0x0011(r29) #E |r2 = Attacker used skillset 0017ab78: 3c018006 lui r1,0x8006 |r1 = 0x80060000 0017ab7c: 00220821 addu r1,r1,r2 |r1 = 0x80060000 + Skillset ID 0017ab80: 90235cb4 lbu r3,0x5cb4(r1) |r3 = Attacker skillset's action menu 0017ab84: 00000000 nop | 0017ab88: 2c620010 sltiu r2,r3,0x0010 |r2 = 0x01 if action menu < 0x10 0017ab8c: 1040001e beq r2,r0,0x0017ac08 #If Action menu is valid /Else branch to blank action menu section (r2 = 0x02 and jump to end) 0017ab90: 00031080 sll r2,r3,0x02 |r2 = Action menu ID * 4 0017ab94: 3c018017 lui r1,0x8017 |r1 = 0x80170000 0017ab98: 00220821 addu r1,r1,r2 |r1 = 0x80170000 + Action menu ID*4 (offset table) 0017ab9c: 8c2240a8 lw r2,0x40a8(r1) |r2 = Jump adress depending on action menu Data/Table_Locations#0x801740a8 0017aba0: 00000000 nop | 0017aba4: 00400008 jr r2 >>Jump to adress (r17 = 0x01) 0017aba8: 00000000 nop | *Default/Monster* 0017abac: 97b00012 lhu r16,0x0012(r29) |r16 = Attacker used ability ID 0017abb0: 0805eb05 j 0x0017ac14 >>jump to Targeting routine section (r17 = 0x01) 0017abb4: 34020001 ori r2,r0,0x0001 |r2 = 0x01 *Item/Weapon Inventory/Attack/Jump/Charge* 0017abb8: 0805eb04 j 0x0017ac10 >>jump to Targeting routine section (r17 = 0x02) 0017abbc: 34110002 ori r17,r0,0x0002 |r17 = 0x02 *Arithmeticks* 0017abc0: 0c05ed34 jal 0x0017b4d0 |-->Calculator_Routine r2 = Hit counter 0017abc4: 27a40010 addiu r4,r29,0x0010 |r4 = stack pointer to Attacker 0x16e - 0x181 data 0017abc8: 00409021 addu r18,r2,r0 |r18 = Hit counter 0017abcc: 0805eb04 j 0x0017ac10 >>jump to Targeting routine section (r17 = 0x00) 0017abd0: 00008821 addu r17,r0,r0 |r17 = 0x00 *Elements* 0017abd4: 0c05fcb6 jal 0x0017f2d8 |-->Get_Elemental_Ability_ID r2 = geomancy ability ID 0017abd8: 00000000 nop | 0017abdc: 0805eb04 j 0x0017ac10 >>jump to Targeting routine section (r17 = 0x01) 0017abe0: 00408021 addu r16,r2,r0 |r16 = Elemental Ability ID *Katana Inventory* 0017abe4: 93a20018 lbu r2,0x0018(r29) |r2 = Attacker's Used Item/Equip ID 0017abe8: 00000000 nop | 0017abec: 2442ffda addiu r2,r2,0xffda |r2 = Attacker's Used item ID - 0x26 0017abf0: 2c42000a sltiu r2,r2,0x000a |r2 = 0x01 if r2 < 0x0a 0017abf4: 1040001f beq r2,r0,0x0017ac74 #If Used Item is a katana (ID between 0x26 and 0x30) /Branch to END if item is not a katana (r2 = -0x01) 0017abf8: 2402ffff addiu r2,r0,-0x0001 |r2 = -0x01 0017abfc: 93a20018 lbu r2,0x0018(r29) |r2 = Attacker's Used Item/Equip ID 0017ac00: 0805eb04 j 0x0017ac10 >>jump to Targeting routine section (r17 = 0x01) 0017ac04: 24500026 addiu r16,r2,0x0026 |r16 = Ability ID (Katana ID + 0x26) *Defend/Change Equipment/Unknown1/Blank / Invalid Action menu (by branch)* 0017ac08: 0805eb1d j 0x0017ac74 >>Jump to END (r2 = 0x02) 0017ac0c: 34020002 ori r2,r0,0x0002 |r2 = 0x02 *Every case not branched to end (except unknown 2 cf below) 0017ac10: 34020001 ori r2,r0,0x0001 |r2 = 0x01 most of action menus section jumps here (setting r2 = 0x01) 0017ac14: 1622000c bne r17,r2,0x0017ac48 #If r17 = 0x01 (Default, monster, Elements, Katanas) /Else branch with r2 = 0x02 0017ac18: 34020002 ori r2,r0,0x0002 |r2 = 0x02 0017ac1c: 3202ffff andi r2,r16,0xffff |r2 = Ability ID 0017ac20: 2c420170 sltiu r2,r2,0x0170 |r2 = 0x01 if Ability ID < Potion 0017ac24: 14400003 bne r2,r0,0x0017ac34 #If ability ID >= Potion /Else avoid jumping to end 0017ac28: 00000000 nop | 0017ac2c: 0805eb1d j 0x0017ac74 #E #E >j >>Jump to END (r2 = -0x01) (Unknown 2 jump adress / Invalid or not existing Attacker ID ) 0017ac30: 2402ffff addiu r2,r0,0x-0x0001 |r2 = -0x01 0017ac34: a7b00012 sh r16,0x0012(r29) #Else Store Ability ID as Attacker used ability ID (on stack) 0017ac38: 0c05ee1d jal 0x0017b874 |-->Targeting_routine Returns r2 = number of targeted tiles (-0x01 if invalid coordinates) 0017ac3c: 27a40010 addiu r4,r29,0x0010 |r4 = Stack Pointer to Attacker 0x16e - 0x181 data 0017ac40: 00409021 addu r18,r2,r0 |r18 = Targeted tiles counter 0017ac44: 34020002 ori r2,r0,0x0002 |r2 = 0x02 0017ac48: 16220004 bne r17,r2,0x0017ac5c #If r17= 0x02 Item/Weapon Inventory/Attack/Jump/Charge 0017ac4c: 00000000 nop | 0017ac50: 0c05eded jal 0x0017b7b4 |-->Disable_Green_Panel_on_all_but_Target%27s_Tile Returns r2 = 0x01 if ok, -0x01 if invalid targeted coordinates 0017ac54: 27a40010 addiu r4,r29,0x0010 |r4 = Stack Pointer 0x10 0017ac58: 00409021 addu r18,r2,r0 |r18 = 0x01 or -0x01 0017ac5c: 16400003 bne r18,r0,0x0017ac6c #If r18 = 0 (maths) 0017ac60: 00121027 nor r2,r0,r18 |r2 = 0x00 if r18 = -0x01 (invalid) 0017ac64: 0805eb1d j 0x0017ac74 >>jump to end (r2 = 0x01) 0017ac68: 34020001 ori r2,r0,0x0001 |r2 = 0x01 0017ac6c: 2c420001 sltiu r2,r2,0x0001 |r2 = 0x01 if r18 = -0x01 0017ac70: 00021023 subu r2,r0,r2 |r2 = -0x01 if invalid, 0x00 if anything else 0017ac74: 8fbf0034 lw r31,0x0034(r29) 0017ac78: 8fb20030 lw r18,0x0030(r29) 0017ac7c: 8fb1002c lw r17,0x002c(r29) 0017ac80: 8fb00028 lw r16,0x0028(r29) 0017ac84: 27bd0038 addiu r29,r29,0x0038 0017ac88: 03e00008 jr r31 0017ac8c: 00000000 nop
Notes
Test Attacker ID < 0x15 - if not exit with r2 = -0x01 Test Attacker ID <> 0x00ff - if not exit with r2 = -0x01 Test Target ID < 0x15 Only if Ability is target specific (Attacker 0x178 = 0x06) - if not exit with r2 = -0x01 Test Action Menu < 0x10 - if not exit with r2 = 0x02 Jump to specific section depending of action menu, and set r17 and r16 (ability ID) - Default and Monster : r17 = 0x01 (go to targeting routine) and set hit counter (nb of tile hitted) - Item/Weapon Inventory/Attack/Jump/Charge : r17 = 0x02 (forces targeted panel to be the only tile hitted) - Arithmeticks : uses a specific routine to set hit counter - r17 = 0x00 (hit coutner preserved) - Elements : Change ability ID to match attacker's Tile ID, r17 = 0x01 (go to targeting routine) - Katana : change Ability ID based on used item, r17 = 0x01 (go to targeting routine) - branch to end with r2 = -0x01 if item is not a katana - Defend/Change Equipment/Unknown1/Blank / Invalid Action menu (by branch) : jump to end with r2 = 0x02 - unknown 2 : branch to end with r2 = -0x01 If r17 = 0x01 - if Ability ID >= potion : branch to end with r2 = -0x01 - get in Targeting_routine - Set various AoE type and count hitted tiles If r17 = 0x02 - get in Disable_Green_Panel_on_all_but_Target's_Tile and only keeps targeted tile (hit count = 1)
Return locations
Battle.bin 00068708: AT_List_Check_if_Unit_is_Charging_Ability 00071780: Get_next_acting_unit? 00074384: Select_Target_Tile 0017cdf4: Map_calculations_for_attack