Difference between revisions of "AI Check Options - Stop/Don't Act/Sleep/Chicken/Charm"

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
(Created page with "<font face='Courier New'> 0019971c: 27bdffc8 addiu r29,r29,0xffc8 00199720: afb20028 sw r18,0x0028(r29) 00199724: 3c12801a lui r18,0x801a 00199728: 2652f3c4 addiu r18,r1...")
 
m
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<font face='Courier New'>
+
BATTLE.BIN : AI Check Options - Stop/Don't Act/Sleep/Chicken/Charm
 +
------------------------------------------------------------------------------------------
 +
Parameters : r4 = Considered Unit ID
 
   
 
   
  0019971c: 27bdffc8 addiu r29,r29,0xffc8
+
  Returns : r2 = 0x00 if all checked statuses can/should be added
  00199720: afb20028 sw r18,0x0028(r29)
+
              = 0x01 if one of them is not an option
  00199724: 3c12801a lui r18,0x801a
+
  Note : seems to be used to determine if the unit is/will be able to Act or not
  00199728: 2652f3c4 addiu r18,r18,0xf3c4
+
  -----------------------------------------------------------------------------------------
0019972c: afb00020 sw r16,0x0020(r29)
+
  001998c8: 27bdffe0 addiu r29,r29,-0x0020   |
  00199730: 00008021 addu r16,r0,r0
+
  001998cc: 00041100 sll r2,r4,0x04          |{{f/std|Unit ID * 16 (Unit offset for AI decision data)}}
00199734: afb3002c sw r19,0x002c(r29)
+
  001998d0: afbf0018 sw r31,0x0018(r29)       |
  00199738: 34130001 ori r19,r0,0x0001
+
  001998d4: afb10014 sw r17,0x0014(r29)       |
0019973c: afbf0030 sw r31,0x0030(r29)
+
  001998d8: afb00010 sw r16,0x0010(r29)       |
  00199740: afb10024 sw r17,0x0024(r29)
+
  001998dc: 3c01801a lui r1,0x801a            |
  00199744: 02508821 addu r17,r18,r16
+
  001998e0: 00220821 addu r1,r1,r2            |{{f/adr|Start of AI data + Unit offset}}
00199748: a2200c8d sb r0,0x0c8d(r17)
+
  001998e4: 90220bf8 lbu r2,0x0bf8(r1)        |{{f/load|Load AI Enemy Flag}} {{f/std|8019f3c4 + 0x182c + 0x08 + Unit offset}}
  0019974c: 0c065b23 jal 0x00196c8c
+
  001998e8: 00000000 nop                     |
  00199750: 02002021 addu r4,r16,r0
+
  001998ec: 10400029 beq r2,r0,0x00199994    {{f/Cond|If Unit is an enemy}} / '''Else :''' {{f/loc|returns 0x01}}
  00199754: 14400006 bne r2,r0,0x00199770
+
  001998f0: 000410c0 sll r2,r4,0x03              |{{f/std|ID * 8}}
  00199758: 00000000 nop
+
  001998f4: 00441023 subu r2,r2,r4                |{{f/std|ID * 7}}
  0019975c: 0c066632 jal 0x001998c8 check if statii can be inflicted
+
  001998f8: 00021180 sll r2,r2,0x06              |{{f/std|Unit ID * 0x1c0}} {{f/std|Unit offset in Battle data}}
00199760: 02002021 addu r4,r16,r0
+
  001998fc: 3c038019 lui r3,0x8019               |
00199764: 14400002 bne r2,r0,0x00199770
+
  00199900: 246308cc addiu r3,r3,0x08cc           |
00199768: 00000000 nop
+
  00199904: 00438821 addu r17,r2,r3              |{{f/adr|<nowiki>r17 = Unit's Data Pointer (Battle stats)</nowiki>}}
  0019976c: a2330c8d sb r19,0x0c8d(r17)
+
  00199908: 3c10801a lui r16,0x801a              |
00199770: 26100001 addiu r16,r16,0x0001
+
  0019990c: 92100213 lbu r16,0x0213(r16)         |{{f/load|Load ClockTicks left before acting unit next turn}} Set in [[Acting_Unit%27s_Data_Setup]]
  00199774: 2a020015 slti r2,r16,0x0015
+
  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>}}
  00199778: 1440fff3 bne r2,r0,0x00199748
+
  00199914: 02202021 addu r4,r17,r0               |{{f/std|<nowiki>r4 = Unit's Data Pointer</nowiki>}}
  0019977c: 02508821 addu r17,r18,r16
+
  00199918: 0202802a slt r16,r16,r2              |{{f/std|Check Ticks left : Acting unit Vs Considered Unit}}
00199780: 00007021 addu r14,r0,r0
+
  0019991c: 16000024 bne r16,r0,0x001999b0        {{f/Cond|If Acting unit won't get another turn before considered unit }}
00199784: 3c118019 lui r17,0x8019
+
  00199920: 34020001 ori r2,r0,0x0001            |{{f/std|<nowiki>r2 = 0x1 (Fail)</nowiki>}}
  00199788: 263108cc addiu r17,r17,0x08cc
+
  00199924: 3c04801a lui r4,0x801a                    |
  0019978c: 340f000a ori r15,r0,0x000a
+
  00199928: 90840213 lbu r4,0x0213(r4)               |{{f/load|Load Clockticks Before Acting unit next turn}}
00199790: 02406821 addu r13,r18,r0
+
  0019992c: 02202821 addu r5,r17,r0                   |{{f/std|<nowiki>r5 = Unit's Data Pointer</nowiki>}}
  00199794: 02406021 addu r12,r18,r0
+
  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>}}
  00199798: 92420e3b lbu r2,0x0e3b(r18)
+
  00199934: 3406001e ori r6,r0,0x001e                |{{f/std|<nowiki>r6 = 0x1e (Stop)</nowiki>}}
  0019979c: 00000000 nop
+
  00199938: 1440001d bne r2,r0,0x001999b0            {{f/Cond|If Stop is an option}}
001997a0: 1840003c blez r2,0x00199894
+
  0019993c: 34020001 ori r2,r0,0x0001                |{{f/std|<nowiki>r2 = 0x1 (Fail)</nowiki>}}
  001997a4: 00004021 addu r8,r0,r0
+
  00199940: 3c04801a lui r4,0x801a                        |
  001997a8: 25ab0174 addiu r11,r13,0x0174
+
  00199944: 90840213 lbu r4,0x0213(r4)                   |{{f/load|Load Clockticks Before Acting unit next turn}}
  001997ac: 258a0a74 addiu r10,r12,0x0a74
+
  00199948: 02202821 addu r5,r17,r0                      |{{f/std|<nowiki>r5 = Unit's Data Pointer</nowiki>}}
  001997b0: 95490000 lhu r9,0x0000(r10)
+
  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>}}
  001997b4: 00000000 nop
+
  00199950: 34060025 ori r6,r0,0x0025                    |{{f/std|<nowiki>r6 = 0x25 (Don't Act)</nowiki>}}
001997b8: 11200030 beq r9,r0,0x0019987c
+
  00199954: 14400016 bne r2,r0,0x001999b0                {{f/Cond|If Don't Act is an option}}
  001997bc: 00000000 nop
+
  00199958: 34020001 ori r2,r0,0x0001                    |{{f/std|<nowiki>r2 = 0x1 (Fail)</nowiki>}}
001997c0: 92420e3a lbu r2,0x0e3a(r18)
+
  0019995c: 3c04801a lui r4,0x801a                            |
  001997c4: 00000000 nop
+
  00199960: 90840213 lbu r4,0x0213(r4)                       |{{f/load|Load Clockticks Required}}
001997c8: 1840002c blez r2,0x0019987c
+
  00199964: 02202821 addu r5,r17,r0                          |{{f/std|<nowiki>r5 = Unit's Data Pointer</nowiki>}}
001997cc: 00002821 addu r5,r0,r0
+
  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>}}
001997d0: 01603021 addu r6,r11,r0
+
  0019996c: 34060023 ori r6,r0,0x0023                        |{{f/std|<nowiki>r6 = 0x23 (Sleep)</nowiki>}}
001997d4: 00a91004 sllv r2,r9,r5
+
  00199970: 1440000f bne r2,r0,0x001999b0                    {{f/Cond|If Sleep is an option}}
  001997d8: 30428000 andi r2,r2,0x8000
+
  00199974: 34020001 ori r2,r0,0x0001                        |{{f/std|<nowiki>r2 = 0x1 (Fail)</nowiki>}}
  001997dc: 10400022 beq r2,r0,0x00199868
+
  00199978: 3c04801a lui r4,0x801a                                |
001997e0: 00000000 nop
+
  0019997c: 90840213 lbu r4,0x0213(r4)                           |{{f/load|Load Clockticks Required}}
001997e4: a0c00000 sb r0,0x0000(r6)
+
  00199980: 02202821 addu r5,r17,r0                              |{{f/std|<nowiki>r5 = Unit's Data Pointer</nowiki>}}
  001997e8: 00008021 addu r16,r0,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>}}
  001997ec: 00c03821 addu r7,r6,r0
+
  00199988: 34060015 ori r6,r0,0x0015                            |{{f/std|<nowiki>r6 = 0x15 (Chicken)</nowiki>}}
001997f0: 02202021 addu r4,r17,r0
+
  0019998c: 10400003 beq r2,r0,0x0019999c                        {{f/Cond|Branch if Chicken isn't an option}}
001997f4: 02501021 addu r2,r18,r16
+
  00199990: 02202821 addu r5,r17,r0                              |{{f/std|<nowiki>r5 = Unit's Data Pointer</nowiki>}}
001997f8: 90420c8d lbu r2,0x0c8d(r2)
+
  00199994: 0806666c j 0x001999b0                                    {{f/jump|Jump to END and }} {{f/loc|<nowiki>returns r2 = 0x01</nowiki>}}
  001997fc: 00000000 nop
+
  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>}}
00199800: 10400015 beq r2,r0,0x00199858
+
   
00199804: 00000000 nop
+
  {{f/sec|-- Every status checked above can/should be added --}}
  00199808: 90820047 lbu r2,0x0047(r4)
+
  0019999c: 3c04801a lui r4,0x801a            |
  0019980c: 00000000 nop
+
  001999a0: 90840213 lbu r4,0x0213(r4)        |{{f/load|Load Clockticks Required}}
00199810: 00451823 subu r3,r2,r5
+
  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>}}
  00199814: 04610002 bgez r3,0x00199820
+
  001999a8: 34060022 ori r6,r0,0x0022        |{{f/std|<nowiki>r6 = 0x22 (Charm)</nowiki>}}
  00199818: 00000000 nop
+
  001999ac: 0002102b sltu r2,r0,r2            |{{f/std|Keep r2 unchanged ()}}
0019981c: 00031823 subu r3,r0,r3
+
  001999b0: 8fbf0018 lw r31,0x0018(r29)       END
00199820: 90820048 lbu r2,0x0048(r4)
+
  001999b4: 8fb10014 lw r17,0x0014(r29)
  00199824: 00000000 nop
+
  001999b8: 8fb00010 lw r16,0x0010(r29)
00199828: 00481023 subu r2,r2,r8
+
  001999bc: 27bd0020 addiu r29,r29,0x0020
  0019982c: 04410002 bgez r2,0x00199838
+
  001999c0: 03e00008 jr r31
00199830: 00000000 nop
+
  001999c4: 00000000 nop
00199834: 00021023 subu r2,r0,r2
+
===Return Locations===
  00199838: 00621821 addu r3,r3,r2
+
'''BATTLE.BIN'''
0019983c: 2862000b slti r2,r3,0x000b
+
00199258: [[Calculate_Physical%3F_Target]]
00199840: 10400005 beq r2,r0,0x00199858
+
00199764: [[Check_for_good_units_to_target_(based_on_distance,status,coordinate)]]
00199844: 01e31823 subu r3,r15,r3
 
  00199848: 90e20000 lbu r2,0x0000(r7)
 
  0019984c: 00000000 nop
 
00199850: 00431021 addu r2,r2,r3
 
  00199854: a0e20000 sb r2,0x0000(r7)
 
  00199858: 26100001 addiu r16,r16,0x0001
 
  0019985c: 2a020015 slti r2,r16,0x0015
 
  00199860: 1440ffe4 bne r2,r0,0x001997f4
 
  00199864: 248401c0 addiu r4,r4,0x01c0
 
  00199868: 92420e3a lbu r2,0x0e3a(r18)
 
  0019986c: 24a50001 addiu r5,r5,0x0001
 
  00199870: 00a2102a slt r2,r5,r2
 
  00199874: 1440ffd7 bne r2,r0,0x001997d4
 
  00199878: 24c60001 addiu r6,r6,0x0001
 
  0019987c: 256b0010 addiu r11,r11,0x0010
 
  00199880: 92420e3b lbu r2,0x0e3b(r18)
 
  00199884: 25080001 addiu r8,r8,0x0001
 
00199888: 0102102a slt r2,r8,r2
 
  0019988c: 1440ffc8 bne r2,r0,0x001997b0
 
  00199890: 254a0002 addiu r10,r10,0x0002
 
  00199894: 25ad0120 addiu r13,r13,0x0120
 
  00199898: 25ce0001 addiu r14,r14,0x0001
 
  0019989c: 29c20002 slti r2,r14,0x0002
 
  001998a0: 1440ffbd bne r2,r0,0x00199798
 
001998a4: 258c0024 addiu r12,r12,0x0024
 
001998a8: 8fbf0030 lw r31,0x0030(r29)
 
  001998ac: 8fb3002c lw r19,0x002c(r29)
 
  001998b0: 8fb20028 lw r18,0x0028(r29)
 
  001998b4: 8fb10024 lw r17,0x0024(r29)
 
  001998b8: 8fb00020 lw r16,0x0020(r29)
 
  001998bc: 27bd0038 addiu r29,r29,0x0038
 
  001998c0: 03e00008 jr r31
 
  001998c4: 00000000 nop
 
</font>
 

Latest revision as of 19:10, 7 May 2023

BATTLE.BIN : AI 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
Note : seems to be used to determine if the unit is/will be able to Act or not
-----------------------------------------------------------------------------------------
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)