Difference between revisions of "AI Check Options - Stop/Don't Act/Sleep/Chicken/Charm"
Jump to navigation
Jump to search
(Corrected Documentation (on what statuses are being searched for here.)) |
|||
Line 1: | Line 1: | ||
− | + | BATTLE.BIN : Check Options - Stop/Don't Act/Sleep/Chicken/Charm | |
+ | ------------------------------------------------------------------------------------------ | ||
+ | Parameters : r4 = Considered Unit ID | ||
− | 001998c8: 27bdffe0 addiu r29,r29, | + | Returns : r2 = 0x00 if all checked statuses can/should be added |
− | 001998cc: 00041100 sll r2,r4,0x04 | + | = 0x01 if one of them is not an option |
− | 001998d0: afbf0018 sw r31,0x0018(r29) | + | ----------------------------------------------------------------------------------------- |
− | 001998d4: afb10014 sw r17,0x0014(r29) | + | 001998c8: 27bdffe0 addiu r29,r29,-0x0020 | |
− | 001998d8: afb00010 sw r16,0x0010(r29) | + | 001998cc: 00041100 sll r2,r4,0x04 |{{f/std|Unit ID * 16 (Unit offset for AI decision data)}} |
− | 001998dc: 3c01801a lui r1,0x801a | + | 001998d0: afbf0018 sw r31,0x0018(r29) | |
− | 001998e0: 00220821 addu r1,r1,r2 | + | 001998d4: afb10014 sw r17,0x0014(r29) | |
− | 001998e4: 90220bf8 lbu r2,0x0bf8(r1) | + | 001998d8: afb00010 sw r16,0x0010(r29) | |
− | 001998e8: 00000000 nop | + | 001998dc: 3c01801a lui r1,0x801a | |
− | 001998ec: 10400029 beq r2,r0,0x00199994 | + | 001998e0: 00220821 addu r1,r1,r2 |{{f/adr|Start of AI data + Unit offset}} |
− | 001998f0: 000410c0 sll r2,r4,0x03 | + | 001998e4: 90220bf8 lbu r2,0x0bf8(r1) |{{f/load|Load AI Enemy Flag}} {{f/std|8019f3c4 + 0x182c + 0x08 + Unit offset}} |
− | 001998f4: 00441023 subu r2,r2,r4 | + | 001998e8: 00000000 nop | |
− | 001998f8: 00021180 sll r2,r2,0x06 | + | 001998ec: 10400029 beq r2,r0,0x00199994 {{f/Cond|If Unit is an enemy}} / '''Else :''' {{f/loc|returns 0x01}} |
− | 001998fc: 3c038019 lui r3,0x8019 | + | 001998f0: 000410c0 sll r2,r4,0x03 |{{f/std|ID * 8}} |
− | 00199900: 246308cc addiu r3,r3,0x08cc | + | 001998f4: 00441023 subu r2,r2,r4 |{{f/std|ID * 7}} |
− | 00199904: 00438821 addu r17,r2,r3 | + | 001998f8: 00021180 sll r2,r2,0x06 |{{f/std|Unit ID * 0x1c0}} {{f/std|Unit offset in Battle data}} |
− | 00199908: 3c10801a lui r16,0x801a | + | 001998fc: 3c038019 lui r3,0x8019 | |
− | 0019990c: 92100213 lbu r16,0x0213(r16) | + | 00199900: 246308cc addiu r3,r3,0x08cc | |
− | 00199910: 0c0666e6 jal 0x00199b98 | + | 00199904: 00438821 addu r17,r2,r3 |{{f/adr|<nowiki>r17 = Unit's Data Pointer (Battle stats)</nowiki>}} |
− | 00199914: 02202021 addu r4,r17,r0 | + | 00199908: 3c10801a lui r16,0x801a | |
− | 00199918: 0202802a slt r16,r16,r2 | + | 0019990c: 92100213 lbu r16,0x0213(r16) |{{f/load|Load ClockTicks left before acting unit next turn}} Set in [[Acting_Unit%27s_Data_Setup]] |
− | 0019991c: 16000024 bne r16,r0,0x001999b0 | + | 00199910: 0c0666e6 jal 0x00199b98 |{{f/jal|Calculate Clockticks Until Unit Acts|Calculate Clockticks Until Unit Acts}} {{f/std|<nowiki>Returns r2 = Ticks left before unit turns</nowiki>}} |
− | 00199920: 34020001 ori r2,r0,0x0001 | + | 00199914: 02202021 addu r4,r17,r0 |{{f/std|<nowiki>r4 = Unit's Data Pointer</nowiki>}} |
− | 00199924: 3c04801a lui r4,0x801a | + | 00199918: 0202802a slt r16,r16,r2 |{{f/std|Check Ticks left : Acting unit Vs Considered Unit}} |
− | 00199928: 90840213 lbu r4,0x0213(r4) | + | 0019991c: 16000024 bne r16,r0,0x001999b0 {{f/Cond|If Acting unit won't get another turn before considered unit }} |
− | 0019992c: 02202821 addu r5,r17,r0 | + | 00199920: 34020001 ori r2,r0,0x0001 |{{f/std|<nowiki>r2 = 0x1 (Fail)</nowiki>}} |
− | 00199930: 0c067bc9 jal 0x0019ef24 | + | 00199924: 3c04801a lui r4,0x801a | |
− | 00199934: 3406001e ori r6,r0,0x001e | + | 00199928: 90840213 lbu r4,0x0213(r4) |{{f/load|Load Clockticks Before Acting unit next turn}} |
− | 00199938: 1440001d bne r2,r0,0x001999b0 | + | 0019992c: 02202821 addu r5,r17,r0 |{{f/std|<nowiki>r5 = Unit's Data Pointer</nowiki>}} |
− | 0019993c: 34020001 ori r2,r0,0x0001 | + | 00199930: 0c067bc9 jal 0x0019ef24 |{{f/jal|Check if Status Should/Can be Added|Check if Status Should/Can be Added}} {{f/std|<nowiki>Returns r2 = 0x00 if worth to be added</nowiki>}} |
− | 00199940: 3c04801a lui r4,0x801a | + | 00199934: 3406001e ori r6,r0,0x001e |{{f/std|<nowiki>r6 = 0x1e (Stop)</nowiki>}} |
− | 00199944: 90840213 lbu r4,0x0213(r4) | + | 00199938: 1440001d bne r2,r0,0x001999b0 {{f/Cond|If Stop is an option}} |
− | 00199948: 02202821 addu r5,r17,r0 | + | 0019993c: 34020001 ori r2,r0,0x0001 |{{f/std|<nowiki>r2 = 0x1 (Fail)</nowiki>}} |
− | 0019994c: 0c067bc9 jal 0x0019ef24 | + | 00199940: 3c04801a lui r4,0x801a | |
− | 00199950: 34060025 ori r6,r0,0x0025 | + | 00199944: 90840213 lbu r4,0x0213(r4) |{{f/load|Load Clockticks Before Acting unit next turn}} |
− | 00199954: 14400016 bne r2,r0,0x001999b0 | + | 00199948: 02202821 addu r5,r17,r0 |{{f/std|<nowiki>r5 = Unit's Data Pointer</nowiki>}} |
− | 00199958: 34020001 ori r2,r0,0x0001 | + | 0019994c: 0c067bc9 jal 0x0019ef24 |{{f/jal|Check if Status Should/Can be Added|Check if Status Should/Can be Added}} {{f/std|<nowiki>Returns r2 = 0x00 if worth to be added</nowiki>}} |
− | 0019995c: 3c04801a lui r4,0x801a | + | 00199950: 34060025 ori r6,r0,0x0025 |{{f/std|<nowiki>r6 = 0x25 (Don't Act)</nowiki>}} |
− | 00199960: 90840213 lbu r4,0x0213(r4) | + | 00199954: 14400016 bne r2,r0,0x001999b0 {{f/Cond|If Don't Act is an option}} |
− | 00199964: 02202821 addu r5,r17,r0 | + | 00199958: 34020001 ori r2,r0,0x0001 |{{f/std|<nowiki>r2 = 0x1 (Fail)</nowiki>}} |
− | 00199968: 0c067bc9 jal 0x0019ef24 | + | 0019995c: 3c04801a lui r4,0x801a | |
− | 0019996c: 34060023 ori r6,r0,0x0023 | + | 00199960: 90840213 lbu r4,0x0213(r4) |{{f/load|Load Clockticks Required}} |
− | 00199970: 1440000f bne r2,r0,0x001999b0 | + | 00199964: 02202821 addu r5,r17,r0 |{{f/std|<nowiki>r5 = Unit's Data Pointer</nowiki>}} |
− | 00199974: 34020001 ori r2,r0,0x0001 | + | 00199968: 0c067bc9 jal 0x0019ef24 |{{f/jal|Check if Status Should/Can be Added|Check if Status Should/Can be Added}} {{f/std|<nowiki>Returns r2 = 0x00 if worth to be added</nowiki>}} |
− | 00199978: 3c04801a lui r4,0x801a | + | 0019996c: 34060023 ori r6,r0,0x0023 |{{f/std|<nowiki>r6 = 0x23 (Sleep)</nowiki>}} |
− | 0019997c: 90840213 lbu r4,0x0213(r4) | + | 00199970: 1440000f bne r2,r0,0x001999b0 {{f/Cond|If Sleep is an option}} |
− | 00199980: 02202821 addu r5,r17,r0 | + | 00199974: 34020001 ori r2,r0,0x0001 |{{f/std|<nowiki>r2 = 0x1 (Fail)</nowiki>}} |
− | 00199984: 0c067bc9 jal 0x0019ef24 | + | 00199978: 3c04801a lui r4,0x801a | |
− | 00199988: 34060015 ori r6,r0,0x0015 | + | 0019997c: 90840213 lbu r4,0x0213(r4) |{{f/load|Load Clockticks Required}} |
− | 0019998c: 10400003 beq r2,r0,0x0019999c | + | 00199980: 02202821 addu r5,r17,r0 |{{f/std|<nowiki>r5 = Unit's Data Pointer</nowiki>}} |
− | 00199990: 02202821 addu r5,r17,r0 | + | 00199984: 0c067bc9 jal 0x0019ef24 |{{f/jal|Check if Status Should/Can be Added|Check if Status Should/Can be Added}} {{f/std|<nowiki>Returns r2 = 0x00 if worth to be added</nowiki>}} |
− | 00199994: 0806666c j 0x001999b0 | + | 00199988: 34060015 ori r6,r0,0x0015 |{{f/std|<nowiki>r6 = 0x15 (Chicken)</nowiki>}} |
− | 00199998: 34020001 ori r2,r0,0x0001 | + | 0019998c: 10400003 beq r2,r0,0x0019999c {{f/Cond|Branch if Chicken isn't an option}} |
− | 0019999c: 3c04801a lui r4,0x801a | + | 00199990: 02202821 addu r5,r17,r0 |{{f/std|<nowiki>r5 = Unit's Data Pointer</nowiki>}} |
− | 001999a0: 90840213 lbu r4,0x0213(r4) | + | 00199994: 0806666c j 0x001999b0 {{f/jump|Jump to END and }} {{f/loc|<nowiki>returns r2 = 0x01</nowiki>}} |
− | 001999a4: 0c067bc9 jal 0x0019ef24 | + | 00199998: 34020001 ori r2,r0,0x0001 {{f/Cond|E }} {{f/Cond|E }} {{f/Cond|E }} {{f/Cond|E }} |{{f/std|<nowiki>r2 = 0x1 (Fail)</nowiki>}} |
− | 001999a8: 34060022 ori r6,r0,0x0022 | + | |
− | 001999ac: 0002102b sltu r2,r0,r2 | + | {{f/sec|-- Every status checked above can/should be added --}} |
− | 001999b0: 8fbf0018 lw r31,0x0018(r29) | + | 0019999c: 3c04801a lui r4,0x801a | |
+ | 001999a0: 90840213 lbu r4,0x0213(r4) |{{f/load|Load Clockticks Required}} | ||
+ | 001999a4: 0c067bc9 jal 0x0019ef24 |{{f/jal|Check if Status Should/Can be Added|Check if Status Should/Can be Added}} {{f/std|<nowiki>Returns r2 = 0x00 if worth to be added</nowiki>}} | ||
+ | 001999a8: 34060022 ori r6,r0,0x0022 |{{f/std|<nowiki>r6 = 0x22 (Charm)</nowiki>}} | ||
+ | 001999ac: 0002102b sltu r2,r0,r2 |{{f/std|Keep r2 unchanged (…)}} | ||
+ | 001999b0: 8fbf0018 lw r31,0x0018(r29) END | ||
001999b4: 8fb10014 lw r17,0x0014(r29) | 001999b4: 8fb10014 lw r17,0x0014(r29) | ||
001999b8: 8fb00010 lw r16,0x0010(r29) | 001999b8: 8fb00010 lw r16,0x0010(r29) | ||
Line 65: | Line 72: | ||
001999c0: 03e00008 jr r31 | 001999c0: 03e00008 jr r31 | ||
001999c4: 00000000 nop | 001999c4: 00000000 nop | ||
− | + | ===Return Locations=== | |
− | + | '''BATTLE.BIN''' | |
+ | 00199258: [[Calculate_Physical%3F_Target]] | ||
+ | 00199764: [[Check_for_good_units_to_target_(based_on_distance,status,coordinate)]] |
Revision as of 19:35, 5 May 2023
BATTLE.BIN : Check Options - Stop/Don't Act/Sleep/Chicken/Charm ------------------------------------------------------------------------------------------ Parameters : r4 = Considered Unit ID Returns : r2 = 0x00 if all checked statuses can/should be added = 0x01 if one of them is not an option ----------------------------------------------------------------------------------------- 001998c8: 27bdffe0 addiu r29,r29,-0x0020 | 001998cc: 00041100 sll r2,r4,0x04 |Unit ID * 16 (Unit offset for AI decision data) 001998d0: afbf0018 sw r31,0x0018(r29) | 001998d4: afb10014 sw r17,0x0014(r29) | 001998d8: afb00010 sw r16,0x0010(r29) | 001998dc: 3c01801a lui r1,0x801a | 001998e0: 00220821 addu r1,r1,r2 |Start of AI data + Unit offset 001998e4: 90220bf8 lbu r2,0x0bf8(r1) |Load AI Enemy Flag 8019f3c4 + 0x182c + 0x08 + Unit offset 001998e8: 00000000 nop | 001998ec: 10400029 beq r2,r0,0x00199994 #If Unit is an enemy / Else : returns 0x01 001998f0: 000410c0 sll r2,r4,0x03 |ID * 8 001998f4: 00441023 subu r2,r2,r4 |ID * 7 001998f8: 00021180 sll r2,r2,0x06 |Unit ID * 0x1c0 Unit offset in Battle data 001998fc: 3c038019 lui r3,0x8019 | 00199900: 246308cc addiu r3,r3,0x08cc | 00199904: 00438821 addu r17,r2,r3 |r17 = Unit's Data Pointer (Battle stats) 00199908: 3c10801a lui r16,0x801a | 0019990c: 92100213 lbu r16,0x0213(r16) |Load ClockTicks left before acting unit next turn Set in Acting_Unit's_Data_Setup 00199910: 0c0666e6 jal 0x00199b98 |-->Calculate Clockticks Until Unit Acts Returns r2 = Ticks left before unit turns 00199914: 02202021 addu r4,r17,r0 |r4 = Unit's Data Pointer 00199918: 0202802a slt r16,r16,r2 |Check Ticks left : Acting unit Vs Considered Unit 0019991c: 16000024 bne r16,r0,0x001999b0 #If Acting unit won't get another turn before considered unit 00199920: 34020001 ori r2,r0,0x0001 |r2 = 0x1 (Fail) 00199924: 3c04801a lui r4,0x801a | 00199928: 90840213 lbu r4,0x0213(r4) |Load Clockticks Before Acting unit next turn 0019992c: 02202821 addu r5,r17,r0 |r5 = Unit's Data Pointer 00199930: 0c067bc9 jal 0x0019ef24 |-->Check if Status Should/Can be Added Returns r2 = 0x00 if worth to be added 00199934: 3406001e ori r6,r0,0x001e |r6 = 0x1e (Stop) 00199938: 1440001d bne r2,r0,0x001999b0 #If Stop is an option 0019993c: 34020001 ori r2,r0,0x0001 |r2 = 0x1 (Fail) 00199940: 3c04801a lui r4,0x801a | 00199944: 90840213 lbu r4,0x0213(r4) |Load Clockticks Before Acting unit next turn 00199948: 02202821 addu r5,r17,r0 |r5 = Unit's Data Pointer 0019994c: 0c067bc9 jal 0x0019ef24 |-->Check if Status Should/Can be Added Returns r2 = 0x00 if worth to be added 00199950: 34060025 ori r6,r0,0x0025 |r6 = 0x25 (Don't Act) 00199954: 14400016 bne r2,r0,0x001999b0 #If Don't Act is an option 00199958: 34020001 ori r2,r0,0x0001 |r2 = 0x1 (Fail) 0019995c: 3c04801a lui r4,0x801a | 00199960: 90840213 lbu r4,0x0213(r4) |Load Clockticks Required 00199964: 02202821 addu r5,r17,r0 |r5 = Unit's Data Pointer 00199968: 0c067bc9 jal 0x0019ef24 |-->Check if Status Should/Can be Added Returns r2 = 0x00 if worth to be added 0019996c: 34060023 ori r6,r0,0x0023 |r6 = 0x23 (Sleep) 00199970: 1440000f bne r2,r0,0x001999b0 #If Sleep is an option 00199974: 34020001 ori r2,r0,0x0001 |r2 = 0x1 (Fail) 00199978: 3c04801a lui r4,0x801a | 0019997c: 90840213 lbu r4,0x0213(r4) |Load Clockticks Required 00199980: 02202821 addu r5,r17,r0 |r5 = Unit's Data Pointer 00199984: 0c067bc9 jal 0x0019ef24 |-->Check if Status Should/Can be Added Returns r2 = 0x00 if worth to be added 00199988: 34060015 ori r6,r0,0x0015 |r6 = 0x15 (Chicken) 0019998c: 10400003 beq r2,r0,0x0019999c #Branch if Chicken isn't an option 00199990: 02202821 addu r5,r17,r0 |r5 = Unit's Data Pointer 00199994: 0806666c j 0x001999b0 >>Jump to END and returns r2 = 0x01 00199998: 34020001 ori r2,r0,0x0001 #E #E #E #E |r2 = 0x1 (Fail) -- Every status checked above can/should be added -- 0019999c: 3c04801a lui r4,0x801a | 001999a0: 90840213 lbu r4,0x0213(r4) |Load Clockticks Required 001999a4: 0c067bc9 jal 0x0019ef24 |-->Check if Status Should/Can be Added Returns r2 = 0x00 if worth to be added 001999a8: 34060022 ori r6,r0,0x0022 |r6 = 0x22 (Charm) 001999ac: 0002102b sltu r2,r0,r2 |Keep r2 unchanged (…) 001999b0: 8fbf0018 lw r31,0x0018(r29) END 001999b4: 8fb10014 lw r17,0x0014(r29) 001999b8: 8fb00010 lw r16,0x0010(r29) 001999bc: 27bd0020 addiu r29,r29,0x0020 001999c0: 03e00008 jr r31 001999c4: 00000000 nop
Return Locations
BATTLE.BIN 00199258: Calculate_Physical?_Target 00199764: Check_for_good_units_to_target_(based_on_distance,status,coordinate)