Difference between revisions of "Status/CT based decision"
Jump to navigation
Jump to search
m (Choto moved page 0019f15c - 0019f254 to Status/CT based decision) |
|||
Line 1: | Line 1: | ||
− | + | '''BATTLE.BIN''' : - Status/CT based decision | |
− | Status/CT based decision < | + | ------------------------------------------------------------------------------------------ |
− | + | Parameter : r4 = Preset Value | |
− | + | r5 = Unit ID | |
− | + | Return : r2 = 0x01 if Unit is Active (Exists, Speed > 0, Do not have stop, sleep or don't move, is not Dead | |
− | + | r2 = 0x01 if Unit is dead but will get a turn in a nb of clockticks <Preset value | |
− | + | r2 = 0x00 if Any of the situation above is false | |
− | + | ------------------------------------------------------------------------------------------ | |
− | + | 0019f15c: 27bdffe0 addiu r29,r29,-0x0020 | | |
− | + | 0019f160: afb10014 sw r17,0x0014(r29) | | |
− | + | 0019f164: 000510c0 sll r2,r5,0x03 | | |
− | + | 0019f168: 00451023 subu r2,r2,r5 | | |
− | + | 0019f16c: 00021180 sll r2,r2,0x06 |{{f/std|Unit ID * 0x1c0}} | |
− | + | 0019f170: 3c038019 lui r3,0x8019 | | |
− | + | 0019f174: 246308cc addiu r3,r3,0x08cc | | |
− | + | 0019f178: afb00010 sw r16,0x0010(r29) | | |
− | + | 0019f17c: 00438021 addu r16,r2,r3 |{{f/adr| unit data pointer}} | |
− | + | 0019f180: afbf0018 sw r31,0x0018(r29) | | |
− | + | 0019f184: 92030001 lbu r3,0x0001(r16) |{{f/load|load unit ID}} | |
− | + | 0019f188: 340200ff ori r2,r0,0x00ff | | |
− | + | 0019f18c: 1062002b beq r3,r2,0x0019f23c {{f/Cond|If doesn't exist : branch to }} {{f/loc|END}} {{f/std|returns 0x00}} | |
− | + | 0019f190: 00808821 addu r17,r4,r0 |{{f/std|Preserves preset value}} | |
− | + | 0019f194: 92020038 lbu r2,0x0038(r16) |{{f/load|Unit speed}} | |
− | + | 0019f198: 00000000 nop | | |
− | + | 0019f19c: 10400028 beq r2,r0,0x0019f240 {{f/Cond|<nowiki>If speed = 0 branch to </nowiki>}} {{f/loc|END}} {{f/std|returns 0x00}} | |
− | + | 0019f1a0: 00001021 addu r2,r0,r0 | | |
− | + | 0019f1a4: 96020058 lhu r2,0x0058(r16) |{{f/load|Unit Current status 1 and 2}} | |
− | + | 0019f1a8: 00000000 nop | | |
− | + | 0019f1ac: 30428140 andi r2,r2,0x8140 | | |
− | + | 0019f1b0: 14400023 bne r2,r0,0x0019f240 {{f/Cond|If unit has Crystal, pretrify or treasure : branch to }} {{f/loc|END}} {{f/std|returns 0x00}} | |
− | + | 0019f1b4: 00001021 addu r2,r0,r0 | | |
− | + | 0019f1b8: 02202021 addu r4,r17,r0 |{{f/std|Send Preset value}} | |
− | + | 0019f1bc: 02002821 addu r5,r16,r0 |{{f/std|Send Unit Battle data pointer}} | |
− | + | 0019f1c0: 0c067bc9 jal 0x0019ef24 |{{f/jal|Check if Status Should/Can be Added|Check if Status Should/Can be Added}} {{f/std|Check for Stop}} | |
− | + | 0019f1c4: 3406001e ori r6,r0,0x001e |{{f/std|Send 0x1e}} | |
− | + | 0019f1c8: 1440001d bne r2,r0,0x0019f240 {{f/Cond|If Unit has Stop (?) : branch to }} {{f/loc|END}} {{f/std|returns 0x00}} | |
− | + | 0019f1cc: 00001021 addu r2,r0,r0 | | |
− | + | 0019f1d0: 02202021 addu r4,r17,r0 | | |
− | + | 0019f1d4: 02002821 addu r5,r16,r0 | | |
− | + | 0019f1d8: 0c067bc9 jal 0x0019ef24 |{{f/jal|Check if Status Should/Can be Added|Check if Status Should/Can be Added}} {{f/std|Check for Don't move}} | |
− | + | 0019f1dc: 34060024 ori r6,r0,0x0024 | | |
− | + | 0019f1e0: 14400017 bne r2,r0,0x0019f240 {{f/Cond|If Unit has don't move : branch to }} {{f/loc|END}} {{f/std|returns 0x00}} | |
− | + | 0019f1e4: 00001021 addu r2,r0,r0 | | |
− | + | 0019f1e8: 02202021 addu r4,r17,r0 | | |
− | + | 0019f1ec: 02002821 addu r5,r16,r0 | | |
− | + | 0019f1f0: 0c067bc9 jal 0x0019ef24 |{{f/jal|Check if Status Should/Can be Added|Check if Status Should/Can be Added}} {{f/std| Check for Sleep}} | |
− | + | 0019f1f4: 34060023 ori r6,r0,0x0023 | | |
− | + | 0019f1f8: 14400011 bne r2,r0,0x0019f240 {{f/Cond|If Unit has sleep : branch to }} {{f/loc|END}} {{f/std|returns 0x00}} | |
− | + | 0019f1fc: 00001021 addu r2,r0,r0 | | |
− | + | 0019f200: 92020058 lbu r2,0x0058(r16) |{{f/load|Unit current Status 1}} | |
− | + | 0019f204: 00000000 nop | | |
− | + | 0019f208: 30420020 andi r2,r2,0x0020 | | |
− | + | 0019f20c: 1040000c beq r2,r0,0x0019f240 {{f/Cond|If Unit is NOT DEAD : branch to }} {{f/loc|END}} {{f/std|returns 0x01}} | |
− | + | 0019f210: 34020001 ori r2,r0,0x0001 | | |
− | + | {{f/sec|<nowiki>=== Dead Unit ===</nowiki>}} | |
− | + | 0019f214: 9202005a lbu r2,0x005a(r16) |{{f/load|Unit status 3}} | |
− | + | 0019f218: 00000000 nop | | |
− | + | 0019f21c: 30420020 andi r2,r2,0x0020 | | |
− | + | 0019f220: 10400007 beq r2,r0,0x0019f240 {{f/Cond|If Unit won't reraise : branch to }} {{f/loc|END}} {{f/std|returns 0x00}} | |
− | + | 0019f224: 00001021 addu r2,r0,r0 | | |
− | + | 0019f228: 0c0666e6 jal 0x00199b98 |{{f/jal|Calculate Clockticks Until Unit Acts|Calculate Clockticks Until Unit Acts}} | |
− | + | 0019f22c: 02002021 addu r4,r16,r0 | | |
− | + | 0019f230: 0222102a slt r2,r17,r2 |{{f/std|1 if preset value < Nb of ticks before unit turn}} | |
− | + | 0019f234: 10400002 beq r2,r0,0x0019f240 {{f/Cond|If Preset Value > Nb of Ticks : branch to}} {{f/loc|END}} {{f/std|returns 0x01}} | |
− | + | 0019f238: 34020001 ori r2,r0,0x0001 | | |
− | + | 0019f23c: 00001021 addu r2,r0,r0 |{{f/std|Else : returns 0x00}} | |
− | + | 0019f240: 8fbf0018 lw r31,0x0018(r29) | |
− | + | 0019f244: 8fb10014 lw r17,0x0014(r29) | |
− | + | 0019f248: 8fb00010 lw r16,0x0010(r29) | |
− | + | 0019f24c: 27bd0020 addiu r29,r29,0x0020 | |
+ | 0019f250: 03e00008 jr r31 | ||
+ | 0019f254: 00000000 nop | ||
+ | ===Return locations=== | ||
+ | '''BATTLE.BIN''' | ||
+ | 0019d628: [[AI_End_of_turn,_in_between_turn,_etc.]] | ||
+ | 0019f138: [[See_if_ability_should_be_used_based_on_CT]] |
Revision as of 20:40, 18 March 2024
BATTLE.BIN : - Status/CT based decision ------------------------------------------------------------------------------------------ Parameter : r4 = Preset Value r5 = Unit ID Return : r2 = 0x01 if Unit is Active (Exists, Speed > 0, Do not have stop, sleep or don't move, is not Dead r2 = 0x01 if Unit is dead but will get a turn in a nb of clockticks <Preset value r2 = 0x00 if Any of the situation above is false ------------------------------------------------------------------------------------------ 0019f15c: 27bdffe0 addiu r29,r29,-0x0020 | 0019f160: afb10014 sw r17,0x0014(r29) | 0019f164: 000510c0 sll r2,r5,0x03 | 0019f168: 00451023 subu r2,r2,r5 | 0019f16c: 00021180 sll r2,r2,0x06 |Unit ID * 0x1c0 0019f170: 3c038019 lui r3,0x8019 | 0019f174: 246308cc addiu r3,r3,0x08cc | 0019f178: afb00010 sw r16,0x0010(r29) | 0019f17c: 00438021 addu r16,r2,r3 | unit data pointer 0019f180: afbf0018 sw r31,0x0018(r29) | 0019f184: 92030001 lbu r3,0x0001(r16) |load unit ID 0019f188: 340200ff ori r2,r0,0x00ff | 0019f18c: 1062002b beq r3,r2,0x0019f23c #If doesn't exist : branch to END returns 0x00 0019f190: 00808821 addu r17,r4,r0 |Preserves preset value 0019f194: 92020038 lbu r2,0x0038(r16) |Unit speed 0019f198: 00000000 nop | 0019f19c: 10400028 beq r2,r0,0x0019f240 #If speed = 0 branch to END returns 0x00 0019f1a0: 00001021 addu r2,r0,r0 | 0019f1a4: 96020058 lhu r2,0x0058(r16) |Unit Current status 1 and 2 0019f1a8: 00000000 nop | 0019f1ac: 30428140 andi r2,r2,0x8140 | 0019f1b0: 14400023 bne r2,r0,0x0019f240 #If unit has Crystal, pretrify or treasure : branch to END returns 0x00 0019f1b4: 00001021 addu r2,r0,r0 | 0019f1b8: 02202021 addu r4,r17,r0 |Send Preset value 0019f1bc: 02002821 addu r5,r16,r0 |Send Unit Battle data pointer 0019f1c0: 0c067bc9 jal 0x0019ef24 |-->Check if Status Should/Can be Added Check for Stop 0019f1c4: 3406001e ori r6,r0,0x001e |Send 0x1e 0019f1c8: 1440001d bne r2,r0,0x0019f240 #If Unit has Stop (?) : branch to END returns 0x00 0019f1cc: 00001021 addu r2,r0,r0 | 0019f1d0: 02202021 addu r4,r17,r0 | 0019f1d4: 02002821 addu r5,r16,r0 | 0019f1d8: 0c067bc9 jal 0x0019ef24 |-->Check if Status Should/Can be Added Check for Don't move 0019f1dc: 34060024 ori r6,r0,0x0024 | 0019f1e0: 14400017 bne r2,r0,0x0019f240 #If Unit has don't move : branch to END returns 0x00 0019f1e4: 00001021 addu r2,r0,r0 | 0019f1e8: 02202021 addu r4,r17,r0 | 0019f1ec: 02002821 addu r5,r16,r0 | 0019f1f0: 0c067bc9 jal 0x0019ef24 |-->Check if Status Should/Can be Added Check for Sleep 0019f1f4: 34060023 ori r6,r0,0x0023 | 0019f1f8: 14400011 bne r2,r0,0x0019f240 #If Unit has sleep : branch to END returns 0x00 0019f1fc: 00001021 addu r2,r0,r0 | 0019f200: 92020058 lbu r2,0x0058(r16) |Unit current Status 1 0019f204: 00000000 nop | 0019f208: 30420020 andi r2,r2,0x0020 | 0019f20c: 1040000c beq r2,r0,0x0019f240 #If Unit is NOT DEAD : branch to END returns 0x01 0019f210: 34020001 ori r2,r0,0x0001 | === Dead Unit === 0019f214: 9202005a lbu r2,0x005a(r16) |Unit status 3 0019f218: 00000000 nop | 0019f21c: 30420020 andi r2,r2,0x0020 | 0019f220: 10400007 beq r2,r0,0x0019f240 #If Unit won't reraise : branch to END returns 0x00 0019f224: 00001021 addu r2,r0,r0 | 0019f228: 0c0666e6 jal 0x00199b98 |-->Calculate Clockticks Until Unit Acts 0019f22c: 02002021 addu r4,r16,r0 | 0019f230: 0222102a slt r2,r17,r2 |1 if preset value < Nb of ticks before unit turn 0019f234: 10400002 beq r2,r0,0x0019f240 #If Preset Value > Nb of Ticks : branch to END returns 0x01 0019f238: 34020001 ori r2,r0,0x0001 | 0019f23c: 00001021 addu r2,r0,r0 |Else : returns 0x00 0019f240: 8fbf0018 lw r31,0x0018(r29) 0019f244: 8fb10014 lw r17,0x0014(r29) 0019f248: 8fb00010 lw r16,0x0010(r29) 0019f24c: 27bd0020 addiu r29,r29,0x0020 0019f250: 03e00008 jr r31 0019f254: 00000000 nop
Return locations
BATTLE.BIN 0019d628: AI_End_of_turn,_in_between_turn,_etc. 0019f138: See_if_ability_should_be_used_based_on_CT