Difference between revisions of "Set type of target for all targets"
Jump to navigation
Jump to search
m (Correction the notes around setting Critical HP Flag) |
|||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | + | BATTLE.BIN : Set type of target for all targets | |
− | + | ------------------------------------------------------------------------------------------------------- | |
− | + | Parameters : Nothing | |
− | + | ||
− | + | Returns : r2 = 0x00 if [[AI_End_of_turn,_in_between_turn,_etc.]] returns -0x01 | |
− | + | then flag 0x01000000 at [0x801a0078] if OFF (aka 8019f3c4 + 0xcb4) | |
− | + | r2 = -0x01 if [[AI_End_of_turn,_in_between_turn,_etc.]] does'nt return -0x01 | |
− | + | then flag 0x01000000 at [0x801a0078] is untouched (ON ?) (aka 8019f3c4 + 0xcb4) | |
− | + | ||
− | + | Set Some AI decision flags for all units | |
− | + | --------------------------------------------------------------------------------------------------------- | |
− | + | 00194314: 3c02801a lui r2,0x801a | | |
− | + | 00194318: 90420d7b lbu r2,0x0d7b(r2) |{{f/load|Load Action decision flag}} | |
− | + | 0019431c: 27bdffd8 addiu r29,r29,-0x0028 | | |
− | + | 00194320: afb3001c sw r19,0x001c(r29) | | |
− | + | 00194324: 3c13801a lui r19,0x801a | | |
− | + | 00194328: 2673f3c4 addiu r19,r19,0xf3c4 |{{f/adr|Start AI Data Pointer}} | |
− | + | 0019432c: afbf0024 sw r31,0x0024(r29) | | |
− | + | 00194330: afb40020 sw r20,0x0020(r29) | | |
− | + | 00194334: afb20018 sw r18,0x0018(r29) | | |
− | + | 00194338: afb10014 sw r17,0x0014(r29) | | |
− | + | 0019433c: 14400077 bne r2,r0,0x0019451c {{f/Cond|If Action is not decided}} | |
− | + | 00194340: afb00010 sw r16,0x0010(r29) | | |
− | + | 00194344: 00009021 addu r18,r0,r0 |{{f/std|Initialize Unit Counter (Used as Unit ID in the loop)}} | |
− | + | 00194348: 0000a021 addu r20,r0,r0 |{{f/std|Unit battle data offset (+0x1c0 each iteration)}} | |
− | + | 0019434c: 3c028019 lui r2,0x8019 {{f/bloop|LOOP}} | |
− | + | 00194350: 244208cc addiu r2,r2,0x08cc {{f/Cond|Start of Unit Battle Data pointer}} | |
− | + | 00194354: 02828821 addu r17,r20,r2 |{{f/adr|This iteration Unit's Data Pointer}} | |
− | + | 00194358: 00121100 sll r2,r18,0x04 |{{f/std|Unit ID * 16}} | |
− | + | 0019435c: 2442182c addiu r2,r2,0x182c | | |
− | + | 00194360: 02628021 addu r16,r19,r2 |{{f/adr|This iteration AI Decision Data Pointer}} {{f/std| 8019f3c4 + 0x182c + Unit offset}} | |
− | + | 00194364: 0c065b3a jal 0x00196ce8 |{{f/jal|Check if Unit can be Targeted (Cryst/Trea/Mount/Trans)|Check if Unit can be Targeted (Cryst/Trea/Mount/Trans)}} {{f/std|<nowiki>r2 = 0x00 if unit is targetable</nowiki>}} | |
− | + | 00194368: 02402021 addu r4,r18,r0 |{{f/std|<nowiki>r4 = Unit ID</nowiki>}} | |
− | + | 0019436c: 10400006 beq r2,r0,0x00194388 {{f/Cond|If Unit is not Targetable}} | |
− | + | 00194370: 00000000 nop | | |
− | + | 00194374: 92020007 lbu r2,0x0007(r16) |{{f/load|Load Unit AI Targeting Flags}} | |
− | + | 00194378: 00000000 nop | | |
− | + | 0019437c: 34420010 ori r2,r2,0x0010 |{{f/std|Enable [Can't Be Targeted]}} | |
− | + | 00194380: 0806513c j 0x001944f0 {{f/jump|Jump to }} {{f/loc|next Unit}} | |
− | + | 00194384: a2020007 sb r2,0x0007(r16) |{{f/store|Store updated Flags}} | |
− | + | '''Else - Unit is Targetable''' | |
− | + | 00194388: 92620e2e lbu r2,0x0e2e(r19) |{{f/load|Load Acting Unit's ID}} | |
− | + | 0019438c: 00000000 nop | | |
− | + | 00194390: 12420008 beq r18,r2,0x001943b4 {{f/Cond|If Unit is not Acting unit}} | |
− | + | 00194394: 00000000 nop | | |
− | + | 00194398: 922201ba lbu r2,0x01ba(r17) |{{f/load|Load Unit's Modified ENTD Flags}} | |
− | + | 0019439c: 92630e39 lbu r3,0x0e39(r19) |{{f/load|Load Acting Unit's Team}} | |
− | + | 001943a0: 30420030 andi r2,r2,0x0030 |{{f/std|Check This Unit [Team]}} | |
− | + | 001943a4: 10430003 beq r2,r3,0x001943b4 {{f/Cond|If This Unit is not in Acting Unit Team}} | |
− | + | 001943a8: 34020001 ori r2,r0,0x0001 |{{f/std|<nowiki>r2 = 0x1</nowiki>}} | |
− | + | 001943ac: 080650ee j 0x001943b8 {{f/jump|Avoid Ally Team section}} | |
− | + | 001943b0: a2020008 sb r2,0x0008(r16) |{{f/store|<nowiki>Store Enemy Flag = True</nowiki>}} | |
− | + | '''Else - This Unit is acting unit or is in the team of Acting Unit''' | |
− | + | 001943b4: a2000008 sb r0,0x0008(r16) |{{f/store|<nowiki>Store Enemy Flag = False</nowiki>}} | |
− | + | 001943b8: 92020007 lbu r2,0x0007(r16) |{{f/load|Load AI Targeting Flags}} | |
− | + | 001943bc: 00000000 nop | | |
− | + | 001943c0: 3043000c andi r3,r2,0x000c |{{f/std|Preserve [Save CT] and [Allied Target?] flags}} | |
− | + | 001943c4: a2030007 sb r3,0x0007(r16) |{{f/store|Erase all flags but [Save CT] and [Allied Target]}} | |
− | + | 001943c8: 92220058 lbu r2,0x0058(r17) |{{f/load|Load Unit's Current Statuses 1}} | |
− | + | 001943cc: 00000000 nop | | |
− | + | 001943d0: 30420020 andi r2,r2,0x0020 |{{f/std|Check [Dead]}} | |
− | + | 001943d4: 10400008 beq r2,r0,0x001943f8 {{f/Cond|If Unit is Dead}} | |
− | + | 001943d8: 00000000 nop | | |
− | + | 001943dc: 9222005a lbu r2,0x005a(r17) |{{f/load|Load Unit's Current Statuses 3}} | |
− | + | 001943e0: 00000000 nop | | |
− | + | 001943e4: 30420020 andi r2,r2,0x0020 |{{f/std|Check [Reraise]}} | |
− | + | 001943e8: 14400002 bne r2,r0,0x001943f4 {{f/Cond|If Unit do not have reraise}} | |
− | + | 001943ec: 34620040 ori r2,r3,0x0040 |{{f/std|Enable Dead Unit with Reraise}} | |
− | + | 001943f0: 34620020 ori r2,r3,0x0020 |{{f/std|Enable Dead Unit without Reraise}} | |
− | + | 001943f4: a2020007 sb r2,0x0007(r16) |{{f/store|Store new AI Targeting Flags (Dead w/o Reraise)}} | |
− | + | 001943f8: 9622002a lhu r2,0x002a(r17) |{{f/load|Load Max HP}} | |
− | + | 001943fc: 96230028 lhu r3,0x0028(r17) |{{f/load|Load Current HP}} | |
− | + | 00194400: 00021042 srl r2,r2,0x01 |{{f/std|Max HP / 2}} | |
− | + | 00194404: 0062182b sltu r3,r3,r2 | | |
− | + | 00194408: 10600005 beq r3,r0,0x00194420 {{f/Cond|If Unit HP has Less than 50% of HP}} | |
− | + | 0019440c: 00000000 nop | | |
− | + | 00194410: 92020007 lbu r2,0x0007(r16) |{{f/load|Load AI Targeting Flags}} | |
− | + | 00194414: 00000000 nop | | |
− | + | 00194418: 34420001 ori r2,r2,0x0001 |{{f/std|Enable Low HP Unit}} | |
− | + | 0019441c: a2020007 sb r2,0x0007(r16) |{{f/store|Enable Low HP Unit in AI Targeting Flags}} | |
− | + | 00194420: 9202000b lbu r2,0x000b(r16) |{{f/load|Load MP Usage Mod}} {{f/std| (Based on Nb of available Abilities using MP)}} | |
− | + | 00194424: 00000000 nop | | |
− | + | 00194428: 10400019 beq r2,r0,0x00194490 {{f/Cond|If Unit uses some abilities with MP}} | |
− | + | 0019442c: 00000000 nop | | |
− | + | 00194430: 9622002e lhu r2,0x002e(r17) |{{f/load|Load Max MP}} | |
− | + | 00194434: 9623002c lhu r3,0x002c(r17) |{{f/load|Load Current MP}} | |
− | + | 00194438: 00021042 srl r2,r2,0x01 |{{f/std|Max MP / 2}} | |
− | + | 0019443c: 0062182b sltu r3,r3,r2 | | |
− | + | 00194440: 10600005 beq r3,r0,0x00194458 {{f/Cond|If Unit HP has Less than 50% of MP}} | |
− | + | 00194444: 00000000 nop | | |
− | + | 00194448: 92020007 lbu r2,0x0007(r16) |{{f/load|Load AI Targeting Flags}} | |
− | + | 0019444c: 00000000 nop | | |
− | + | 00194450: 34420002 ori r2,r2,0x0002 |{{f/std|Enable Low MP Unit}} | |
− | + | 00194454: a2020007 sb r2,0x0007(r16) |{{f/store|Enable Low MP Unit in AI Targeting Flags}} | |
− | + | 00194458: 92620e39 lbu r2,0x0e39(r19) |{{f/load|Load Acting Unit's Team}} | |
− | + | 0019445c: 00000000 nop | | |
− | + | 00194460: 1040000b beq r2,r0,0x00194490 {{f/Cond|If Unit is not in Player Team}} | |
− | + | 00194464: 00000000 nop | | |
− | + | 00194468: 9622002c lhu r2,0x002c(r17) |{{f/load|Load Unit's Current MP}} | |
− | + | 0019446c: 92030009 lbu r3,0x0009(r16) |{{f/load|Load Highest MP Cost}} | |
− | + | 00194470: 00000000 nop | | |
− | + | 00194474: 0043102b sltu r2,r2,r3 | | |
− | + | 00194478: 10400005 beq r2,r0,0x00194490 {{f/Cond|If Unit lack of MP to cast is Higher MP ability}} | |
− | + | 0019447c: 00000000 nop | | |
− | + | 00194480: 92020007 lbu r2,0x0007(r16) |{{f/load|Load AI Targeting Flags}} | |
− | + | 00194484: 00000000 nop | | |
− | + | 00194488: 34420002 ori r2,r2,0x0002 |{{f/std|Enable Low MP Unit}} | |
− | + | 0019448c: a2020007 sb r2,0x0007(r16) |{{f/store|Store new AI Targeting Flags}} | |
− | + | 00194490: 92020007 lbu r2,0x0007(r16) |{{f/load|Load AI Targeting Flags}} | |
− | + | 00194494: 00000000 nop | | |
− | + | 00194498: 3045007f andi r5,r2,0x007f |{{f/std|Disable 0x80 (already done above with AND 0x0c)}} | |
− | + | 0019449c: a2050007 sb r5,0x0007(r16) |{{f/store|Store new AI Targeting Flags}} | |
− | + | 001944a0: 96230028 lhu r3,0x0028(r17) |{{f/load|Load Unit's Current HP}} | |
− | + | 001944a4: 9624002a lhu r4,0x002a(r17) |{{f/load|Load Unit's Max HP}} | |
− | + | 001944a8: 00031880 sll r3,r3,0x02 |{{f/std|Current * 4}} | |
− | + | 001944ac: 00041080 sll r2,r4,0x02 |{{f/std|Max * 4}} | |
− | + | 001944b0: 00441023 subu r2,r2,r4 |{{f/std|Max * 3}} | |
− | + | 001944b4: 0062182a slt r3,r3,r2 |{{f/std|Check Current *4 Vs Max*3}} | |
− | + | 001944b8: 10600002 beq r3,r0,0x001944c4 {{f/Cond|If Unit has less than 75% HP}} | |
− | + | 001944bc: 34a20080 ori r2,r5,0x0080 |{{f/std|Enable Critical HP Unit (?)}} | |
− | + | 001944c0: a2020007 sb r2,0x0007(r16) |{{f/store|Store new AI Targeting Flags}} | |
− | + | 001944c4: 92020004 lbu r2,0x0004(r16) |{{f/load|Load AI Behavior Flags (from Battle 0x167)}} | |
− | + | 001944c8: 92030008 lbu r3,0x0008(r16) |{{f/load|Load Enemy Flag}} | |
− | + | 001944cc: 3044007f andi r4,r2,0x007f |{{f/std|Disable [0x80]}} {{f/std|Take in consideration ? (AI ignores unit without this flag)}} | |
− | + | 001944d0: 10600005 beq r3,r0,0x001944e8 {{f/Cond|If Unit is an enemy}} | |
− | + | 001944d4: a2040004 sb r4,0x0004(r16) |{{f/store|Disable 0x80}} | |
− | + | 001944d8: 9223015d lbu r3,0x015d(r17) |{{f/load|Load Current Ability CT}} | |
− | + | 001944dc: 340200ff ori r2,r0,0x00ff |{{f/std|<nowiki>r2 = 0xff (not doing anything)</nowiki>}} | |
− | + | 001944e0: 10620003 beq r3,r2,0x001944f0 {{f/Cond|<nowiki>Branch if CT = 0xFF and Unit is an enemy (keeping flag 0x80 off)</nowiki>}} {{f/std|No proof of life so far ?}} | |
− | + | 001944e4: 00000000 nop | | |
− | + | '''Else : Ally or enemy charging/performing something''' | |
− | + | 001944e8: 34820080 ori r2,r4,0x0080 |{{f/std|Enable Charging/Performing}} | |
− | + | 001944ec: a2020004 sb r2,0x0004(r16) |{{f/store|Enable [0x80] (Take in consideration ?)}} | |
− | + | 001944f0: 26520001 addiu r18,r18,0x0001 |{{f/std|Unit counter + 1}} | |
− | + | 001944f4: 2a420015 slti r2,r18,0x0015 |{{f/std|Check limit}} | |
− | + | 001944f8: 1440ff94 bne r2,r0,0x0019434c {{f/eloop|Loop 0x15 Time}} | |
− | + | 001944fc: 269401c0 addiu r20,r20,0x01c0 |{{f/std|<nowiki>Pointer Mod += 0x1c0</nowiki>}} | |
− | + | 00194500: 34020001 ori r2,r0,0x0001 |{{f/std|<nowiki>r2 = 0x1</nowiki>}} | |
− | + | 00194504: a2620014 sb r2,0x0014(r19) |{{f/store|Store 0x1 at 0x8019f3d8}} {{f/std| 8019f3c4 + 0x14}} | |
− | + | 00194508: 8e620cb4 lw r2,0x0cb4(r19) |{{f/adr|Load [ 801a0078 ]}} {{f/std| 8019f3c4 + 0xcb4}} | |
− | + | 0019450c: 3c030100 lui r3,0x0100 | | |
− | + | 00194510: a260001d sb r0,0x001d(r19) |{{f/store|Reset Skillset of last Attack}} {{f/std| 8019f3c4 + 0x1d}} | |
− | 0019454c: 8fbf0024 lw r31,0x0024(r29) | + | 00194514: 00431025 or r2,r2,r3 | |
+ | 00194518: ae620cb4 sw r2,0x0cb4(r19) |{{f/store|Enable flag 0x01000000 at 0x801a0078}} {{f/std| Flag 0x01 at 801a007b}} | ||
+ | 0019451c: 0c0674df jal 0x0019d37c |{{f/jal|AI_End_of_turn,_in_between_turn,_etc.|AI_End_of_turn,_in_between_turn,_etc.}} {{f/std|returns r2}} | ||
+ | 00194520: 00000000 nop | | ||
+ | 00194524: 2403ffff addiu r3,r0,-0x0001 | | ||
+ | 00194528: 10430007 beq r2,r3,0x00194548 {{f/Cond|If returned value is not -0x01}} | ||
+ | 0019452c: 3c04feff lui r4,0xfeff | | ||
+ | 00194530: 3484ffff ori r4,r4,0xffff |{{f/std|<nowiki>r4 = 0xfeffffff</nowiki>}} | ||
+ | 00194534: 8e630cb4 lw r3,0x0cb4(r19) |{{f/adr|Load [ 801a0078 ]}} | ||
+ | 00194538: 00001021 addu r2,r0,r0 |{{f/std|<nowiki>returns r2 = 0x00</nowiki>}} | ||
+ | 0019453c: 00641824 and r3,r3,r4 |{{f/std|Remove flag 0x01000000}} | ||
+ | 00194540: 08065153 j 0x0019454c | | ||
+ | 00194544: ae630cb4 sw r3,0x0cb4(r19) |{{f/store|Disable flag 0x01000000 at 0x801a0078}} | ||
+ | '''Else : returned value is -0x0001''' | ||
+ | 00194548: 2402ffff addiu r2,r0,-0x0001 |{{f/std|<nowiki>Returns r2 = -0x01</nowiki>}} | ||
+ | 0019454c: 8fbf0024 lw r31,0x0024(r29) END | ||
00194550: 8fb40020 lw r20,0x0020(r29) | 00194550: 8fb40020 lw r20,0x0020(r29) | ||
00194554: 8fb3001c lw r19,0x001c(r29) | 00194554: 8fb3001c lw r19,0x001c(r29) | ||
Line 150: | Line 165: | ||
00194568: 03e00008 jr r31 | 00194568: 03e00008 jr r31 | ||
0019456c: 00000000 nop | 0019456c: 00000000 nop | ||
+ | |||
+ | === Return Locations === | ||
+ | '''BATTLE.BIN''' | ||
+ | 00193ff8: [[Main_AI_action_setup]] |
Latest revision as of 09:22, 21 March 2024
BATTLE.BIN : Set type of target for all targets ------------------------------------------------------------------------------------------------------- Parameters : Nothing Returns : r2 = 0x00 if AI_End_of_turn,_in_between_turn,_etc. returns -0x01 then flag 0x01000000 at [0x801a0078] if OFF (aka 8019f3c4 + 0xcb4) r2 = -0x01 if AI_End_of_turn,_in_between_turn,_etc. does'nt return -0x01 then flag 0x01000000 at [0x801a0078] is untouched (ON ?) (aka 8019f3c4 + 0xcb4) Set Some AI decision flags for all units --------------------------------------------------------------------------------------------------------- 00194314: 3c02801a lui r2,0x801a | 00194318: 90420d7b lbu r2,0x0d7b(r2) |Load Action decision flag 0019431c: 27bdffd8 addiu r29,r29,-0x0028 | 00194320: afb3001c sw r19,0x001c(r29) | 00194324: 3c13801a lui r19,0x801a | 00194328: 2673f3c4 addiu r19,r19,0xf3c4 |Start AI Data Pointer 0019432c: afbf0024 sw r31,0x0024(r29) | 00194330: afb40020 sw r20,0x0020(r29) | 00194334: afb20018 sw r18,0x0018(r29) | 00194338: afb10014 sw r17,0x0014(r29) | 0019433c: 14400077 bne r2,r0,0x0019451c #If Action is not decided 00194340: afb00010 sw r16,0x0010(r29) | 00194344: 00009021 addu r18,r0,r0 |Initialize Unit Counter (Used as Unit ID in the loop) 00194348: 0000a021 addu r20,r0,r0 |Unit battle data offset (+0x1c0 each iteration) 0019434c: 3c028019 lui r2,0x8019 @LOOP 00194350: 244208cc addiu r2,r2,0x08cc #Start of Unit Battle Data pointer 00194354: 02828821 addu r17,r20,r2 |This iteration Unit's Data Pointer 00194358: 00121100 sll r2,r18,0x04 |Unit ID * 16 0019435c: 2442182c addiu r2,r2,0x182c | 00194360: 02628021 addu r16,r19,r2 |This iteration AI Decision Data Pointer 8019f3c4 + 0x182c + Unit offset 00194364: 0c065b3a jal 0x00196ce8 |-->Check if Unit can be Targeted (Cryst/Trea/Mount/Trans) r2 = 0x00 if unit is targetable 00194368: 02402021 addu r4,r18,r0 |r4 = Unit ID 0019436c: 10400006 beq r2,r0,0x00194388 #If Unit is not Targetable 00194370: 00000000 nop | 00194374: 92020007 lbu r2,0x0007(r16) |Load Unit AI Targeting Flags 00194378: 00000000 nop | 0019437c: 34420010 ori r2,r2,0x0010 |Enable [Can't Be Targeted] 00194380: 0806513c j 0x001944f0 >>Jump to next Unit 00194384: a2020007 sb r2,0x0007(r16) |Store updated Flags Else - Unit is Targetable 00194388: 92620e2e lbu r2,0x0e2e(r19) |Load Acting Unit's ID 0019438c: 00000000 nop | 00194390: 12420008 beq r18,r2,0x001943b4 #If Unit is not Acting unit 00194394: 00000000 nop | 00194398: 922201ba lbu r2,0x01ba(r17) |Load Unit's Modified ENTD Flags 0019439c: 92630e39 lbu r3,0x0e39(r19) |Load Acting Unit's Team 001943a0: 30420030 andi r2,r2,0x0030 |Check This Unit [Team] 001943a4: 10430003 beq r2,r3,0x001943b4 #If This Unit is not in Acting Unit Team 001943a8: 34020001 ori r2,r0,0x0001 |r2 = 0x1 001943ac: 080650ee j 0x001943b8 >>Avoid Ally Team section 001943b0: a2020008 sb r2,0x0008(r16) |Store Enemy Flag = True Else - This Unit is acting unit or is in the team of Acting Unit 001943b4: a2000008 sb r0,0x0008(r16) |Store Enemy Flag = False 001943b8: 92020007 lbu r2,0x0007(r16) |Load AI Targeting Flags 001943bc: 00000000 nop | 001943c0: 3043000c andi r3,r2,0x000c |Preserve [Save CT] and [Allied Target?] flags 001943c4: a2030007 sb r3,0x0007(r16) |Erase all flags but [Save CT] and [Allied Target] 001943c8: 92220058 lbu r2,0x0058(r17) |Load Unit's Current Statuses 1 001943cc: 00000000 nop | 001943d0: 30420020 andi r2,r2,0x0020 |Check [Dead] 001943d4: 10400008 beq r2,r0,0x001943f8 #If Unit is Dead 001943d8: 00000000 nop | 001943dc: 9222005a lbu r2,0x005a(r17) |Load Unit's Current Statuses 3 001943e0: 00000000 nop | 001943e4: 30420020 andi r2,r2,0x0020 |Check [Reraise] 001943e8: 14400002 bne r2,r0,0x001943f4 #If Unit do not have reraise 001943ec: 34620040 ori r2,r3,0x0040 |Enable Dead Unit with Reraise 001943f0: 34620020 ori r2,r3,0x0020 |Enable Dead Unit without Reraise 001943f4: a2020007 sb r2,0x0007(r16) |Store new AI Targeting Flags (Dead w/o Reraise) 001943f8: 9622002a lhu r2,0x002a(r17) |Load Max HP 001943fc: 96230028 lhu r3,0x0028(r17) |Load Current HP 00194400: 00021042 srl r2,r2,0x01 |Max HP / 2 00194404: 0062182b sltu r3,r3,r2 | 00194408: 10600005 beq r3,r0,0x00194420 #If Unit HP has Less than 50% of HP 0019440c: 00000000 nop | 00194410: 92020007 lbu r2,0x0007(r16) |Load AI Targeting Flags 00194414: 00000000 nop | 00194418: 34420001 ori r2,r2,0x0001 |Enable Low HP Unit 0019441c: a2020007 sb r2,0x0007(r16) |Enable Low HP Unit in AI Targeting Flags 00194420: 9202000b lbu r2,0x000b(r16) |Load MP Usage Mod (Based on Nb of available Abilities using MP) 00194424: 00000000 nop | 00194428: 10400019 beq r2,r0,0x00194490 #If Unit uses some abilities with MP 0019442c: 00000000 nop | 00194430: 9622002e lhu r2,0x002e(r17) |Load Max MP 00194434: 9623002c lhu r3,0x002c(r17) |Load Current MP 00194438: 00021042 srl r2,r2,0x01 |Max MP / 2 0019443c: 0062182b sltu r3,r3,r2 | 00194440: 10600005 beq r3,r0,0x00194458 #If Unit HP has Less than 50% of MP 00194444: 00000000 nop | 00194448: 92020007 lbu r2,0x0007(r16) |Load AI Targeting Flags 0019444c: 00000000 nop | 00194450: 34420002 ori r2,r2,0x0002 |Enable Low MP Unit 00194454: a2020007 sb r2,0x0007(r16) |Enable Low MP Unit in AI Targeting Flags 00194458: 92620e39 lbu r2,0x0e39(r19) |Load Acting Unit's Team 0019445c: 00000000 nop | 00194460: 1040000b beq r2,r0,0x00194490 #If Unit is not in Player Team 00194464: 00000000 nop | 00194468: 9622002c lhu r2,0x002c(r17) |Load Unit's Current MP 0019446c: 92030009 lbu r3,0x0009(r16) |Load Highest MP Cost 00194470: 00000000 nop | 00194474: 0043102b sltu r2,r2,r3 | 00194478: 10400005 beq r2,r0,0x00194490 #If Unit lack of MP to cast is Higher MP ability 0019447c: 00000000 nop | 00194480: 92020007 lbu r2,0x0007(r16) |Load AI Targeting Flags 00194484: 00000000 nop | 00194488: 34420002 ori r2,r2,0x0002 |Enable Low MP Unit 0019448c: a2020007 sb r2,0x0007(r16) |Store new AI Targeting Flags 00194490: 92020007 lbu r2,0x0007(r16) |Load AI Targeting Flags 00194494: 00000000 nop | 00194498: 3045007f andi r5,r2,0x007f |Disable 0x80 (already done above with AND 0x0c) 0019449c: a2050007 sb r5,0x0007(r16) |Store new AI Targeting Flags 001944a0: 96230028 lhu r3,0x0028(r17) |Load Unit's Current HP 001944a4: 9624002a lhu r4,0x002a(r17) |Load Unit's Max HP 001944a8: 00031880 sll r3,r3,0x02 |Current * 4 001944ac: 00041080 sll r2,r4,0x02 |Max * 4 001944b0: 00441023 subu r2,r2,r4 |Max * 3 001944b4: 0062182a slt r3,r3,r2 |Check Current *4 Vs Max*3 001944b8: 10600002 beq r3,r0,0x001944c4 #If Unit has less than 75% HP 001944bc: 34a20080 ori r2,r5,0x0080 |Enable Critical HP Unit (?) 001944c0: a2020007 sb r2,0x0007(r16) |Store new AI Targeting Flags 001944c4: 92020004 lbu r2,0x0004(r16) |Load AI Behavior Flags (from Battle 0x167) 001944c8: 92030008 lbu r3,0x0008(r16) |Load Enemy Flag 001944cc: 3044007f andi r4,r2,0x007f |Disable [0x80] Take in consideration ? (AI ignores unit without this flag) 001944d0: 10600005 beq r3,r0,0x001944e8 #If Unit is an enemy 001944d4: a2040004 sb r4,0x0004(r16) |Disable 0x80 001944d8: 9223015d lbu r3,0x015d(r17) |Load Current Ability CT 001944dc: 340200ff ori r2,r0,0x00ff |r2 = 0xff (not doing anything) 001944e0: 10620003 beq r3,r2,0x001944f0 #Branch if CT = 0xFF and Unit is an enemy (keeping flag 0x80 off) No proof of life so far ? 001944e4: 00000000 nop | Else : Ally or enemy charging/performing something 001944e8: 34820080 ori r2,r4,0x0080 |Enable Charging/Performing 001944ec: a2020004 sb r2,0x0004(r16) |Enable [0x80] (Take in consideration ?) 001944f0: 26520001 addiu r18,r18,0x0001 |Unit counter + 1 001944f4: 2a420015 slti r2,r18,0x0015 |Check limit 001944f8: 1440ff94 bne r2,r0,0x0019434c Λ Loop 0x15 Time 001944fc: 269401c0 addiu r20,r20,0x01c0 |Pointer Mod += 0x1c0 00194500: 34020001 ori r2,r0,0x0001 |r2 = 0x1 00194504: a2620014 sb r2,0x0014(r19) |Store 0x1 at 0x8019f3d8 8019f3c4 + 0x14 00194508: 8e620cb4 lw r2,0x0cb4(r19) |Load [ 801a0078 ] 8019f3c4 + 0xcb4 0019450c: 3c030100 lui r3,0x0100 | 00194510: a260001d sb r0,0x001d(r19) |Reset Skillset of last Attack 8019f3c4 + 0x1d 00194514: 00431025 or r2,r2,r3 | 00194518: ae620cb4 sw r2,0x0cb4(r19) |Enable flag 0x01000000 at 0x801a0078 Flag 0x01 at 801a007b 0019451c: 0c0674df jal 0x0019d37c |-->AI_End_of_turn,_in_between_turn,_etc. returns r2 00194520: 00000000 nop | 00194524: 2403ffff addiu r3,r0,-0x0001 | 00194528: 10430007 beq r2,r3,0x00194548 #If returned value is not -0x01 0019452c: 3c04feff lui r4,0xfeff | 00194530: 3484ffff ori r4,r4,0xffff |r4 = 0xfeffffff 00194534: 8e630cb4 lw r3,0x0cb4(r19) |Load [ 801a0078 ] 00194538: 00001021 addu r2,r0,r0 |returns r2 = 0x00 0019453c: 00641824 and r3,r3,r4 |Remove flag 0x01000000 00194540: 08065153 j 0x0019454c | 00194544: ae630cb4 sw r3,0x0cb4(r19) |Disable flag 0x01000000 at 0x801a0078 Else : returned value is -0x0001 00194548: 2402ffff addiu r2,r0,-0x0001 |Returns r2 = -0x01 0019454c: 8fbf0024 lw r31,0x0024(r29) END 00194550: 8fb40020 lw r20,0x0020(r29) 00194554: 8fb3001c lw r19,0x001c(r29) 00194558: 8fb20018 lw r18,0x0018(r29) 0019455c: 8fb10014 lw r17,0x0014(r29) 00194560: 8fb00010 lw r16,0x0010(r29) 00194564: 27bd0028 addiu r29,r29,0x0028 00194568: 03e00008 jr r31 0019456c: 00000000 nop
Return Locations
BATTLE.BIN 00193ff8: Main_AI_action_setup