Difference between revisions of "Auto Battle Handling"

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
 
(6 intermediate revisions by one other user not shown)
Line 1: Line 1:
<font face='Courier New'>
+
'''BATTLE.BIN''' :  -  Auto Battle Handling
 +
------------------------------------------------------------------------------------------
 +
Parameter : Nothing
 +
Return : r2 = 0x00 if invalid or unhandled Autobattle flag
 +
Return : r2 = -0x01 if Any Auto Battle routines returns - 0x01
 +
Return : r2 = 0x01if when Auto Battle routine has been called and didn't return -0x01
 +
------------------------------------------------------------------------------------------
 +
00197f14: 27bdffe8 addiu r29,r29,-0x0018    |
 +
00197f18: 3c03801a lui r3,0x801a            |
 +
00197f1c: 90630d7a lbu r3,0x0d7a(r3)        |{{f/load|Load AutoBattle Flags}} {{f/std|8019f3c4 + 0x19b6 aka 801a0d7a}}
 +
00197f20: 3402000e ori r2,r0,0x000e          |
 +
00197f24: 10620013 beq r3,r2,0x00197f74      {{f/Cond|If Auto Battle is 0x0e : Branch to }} {{f/loc|Protect Allies}}
 +
00197f28: afbf0010 sw r31,0x0010(r29)            |
 +
00197f2c: 2862000f slti r2,r3,0x000f        |{{f/std|If Less Than 0xf}}
 +
00197f30: 10400005 beq r2,r0,0x00197f48      {{f/Cond|If below 0x0e}}
 +
00197f34: 3402000c ori r2,r0,0x000c              |
 +
00197f38: 1062000a beq r3,r2,0x00197f64          {{f/Cond|If Auto Battle is 0x0c : branch to }} {{f/loc|Fight for your life}}
 +
00197f3c: 00001021 addu r2,r0,r0                    |
 +
00197f40: 08065ff9 j 0x00197fe4                  {{f/jump|Else}} {{f/loc|Exit}} {{f/Returns|Returns 0x00}}
 +
00197f44: 00000000 nop                              |
 +
                                            '''Else : Auto Battle above 0x0e'''
 +
00197f48: 34020010 ori r2,r0,0x0010                  |
 +
00197f4c: 10620014 beq r3,r2,0x00197fa0          {{f/Cond|If Auto Battle 0x10 : branch to }} {{f/loc|Save Fading life}}
 +
00197f50: 34020011 ori r2,r0,0x0011                  |
 +
00197f54: 1062001d beq r3,r2,0x00197fcc          {{f/Cond|If Auto Battle 0x11 : branch to}} {{f/loc|Run like a rabbit}}
 +
00197f58: 00001021 addu r2,r0,r0                    |
 +
00197f5c: 08065ff9 j 0x00197fe4                  {{f/jump|Else}} {{f/loc|Exit}} {{f/Returns|Returns 0x00}}
 +
00197f60: 00000000 nop                              |
 
   
 
   
  00197f14: 27bdffe8 addiu r29,r29,0xffe8
+
  {{f/sec|Fight For your Life ( Focus Unit + Enemy Target) - Auto Battle 0x0c}}
00197f18: 3c03801a lui r3,0x801a
+
  00197f64: 0c065ffd jal 0x00197ff4                   |{{f/jal|Fight_for_Life_-_Auto_Battle_(00197ff4)|Fight_for_Life_-_Auto_Battle_(00197ff4)}}
00197f1c: 90630d7a lbu r3,0x0d7a(r3)
+
  00197f68: 00000000 nop                               |
00197f20: 3402000e ori r2,r0,0x000e
+
  00197f6c: 08065ff6 j 0x00197fd8                     {{f/jump|Jump to resolution}}
00197f24: 10620013 beq r3,r2,0x00197f74
+
  00197f70: 2403ffff addiu r3,r0,-0x0001                  |
00197f28: afbf0010 sw r31,0x0010(r29)
+
00197f2c: 2862000f slti r2,r3,0x000f
+
{{f/sec|Protect Allies (Focus Unit + Allied Target) - Auto Battle 0x0e}}
00197f30: 10400005 beq r2,r0,0x00197f48
+
  00197f74: 0c06613b jal 0x001984ec                   |{{f/jal|Protect_Allies_-_Auto_Battle_(001984ec)|Protect_Allies_-_Auto_Battle_(001984ec)}}
00197f34: 3402000c ori r2,r0,0x000c
+
  00197f78: 00000000 nop                               |
00197f38: 1062000a beq r3,r2,0x00197f64
+
  00197f7c: 00401821 addu r3,r2,r0                     |
00197f3c: 00001021 addu r2,r0,r0
+
  00197f80: 2402ffff addiu r2,r0,-0x0001              |
00197f40: 08065ff9 j 0x00197fe4
+
  00197f84: 10620017 beq r3,r2,0x00197fe4             {{f/Cond|If Returned value is -0x0001 :}} {{f/loc|Exit}} {{f/Returns|Returns -0x01}}
00197f44: 00000000 nop
+
  00197f88: 00000000 nop                                   |
00197f48: 34020010 ori r2,r0,0x0010
+
  00197f8c: 2402fffe addiu r2,r0,-0x0002                  |
00197f4c: 10620014 beq r3,r2,0x00197fa0
+
  00197f90: 1062000e beq r3,r2,0x00197fcc             {{f/Cond|If Returned value is -0x0002 : branch to }} {{f/loc|Run like a rabbit}}
00197f50: 34020011 ori r2,r0,0x0011
+
  00197f94: 34020001 ori r2,r0,0x0001                     |
00197f54: 1062001d beq r3,r2,0x00197fcc
+
  00197f98: 08065ff9 j 0x00197fe4                     {{f/jump|Else :}} {{f/loc|Exit}} {{f/Returns|Return 0x01}}
00197f58: 00001021 addu r2,r0,r0
+
  00197f9c: 00000000 nop                                   |
00197f5c: 08065ff9 j 0x00197fe4
+
00197f60: 00000000 nop
+
{{f/sec|Save Fading Life (Auto Battle 0x10)}}
  00197f64: 0c065ffd jal 0x00197ff4 [[Choose Target and Set a bunch of stuff]]
+
  00197fa0: 0c06637c jal 0x00198df0                   |{{f/jal|Save_Fading_Life_-_Auto_Battle_(00198df0)|Save_Fading_Life_-_Auto_Battle_(00198df0)}}
  00197f68: 00000000 nop
+
  00197fa4: 00000000 nop                               |
  00197f6c: 08065ff6 j 0x00197fd8
+
  00197fa8: 00401821 addu r3,r2,r0                     |
  00197f70: 2403ffff addiu r3,r0,0xffff
+
  00197fac: 2402ffff addiu r2,r0,-0x0001              |
  00197f74: 0c06613b jal 0x001984ec [[001984ec - 00198818]]
+
  00197fb0: 1062000c beq r3,r2,0x00197fe4             {{f/Cond|If Returned value is -0x0001 :}} {{f/loc|Exit}} {{f/Returns|Returns -0x01}}
  00197f78: 00000000 nop
+
  00197fb4: 00000000 nop                                   |
  00197f7c: 00401821 addu r3,r2,r0
+
  00197fb8: 2402fffe addiu r2,r0,-0x0002                  |
  00197f80: 2402ffff addiu r2,r0,0xffff
+
  00197fbc: 1062ffed beq r3,r2,0x00197f74             {{f/Cond|If Returned value is -0x0002 : branch to }} {{f/loc|Protect Ally}}
  00197f84: 10620017 beq r3,r2,0x00197fe4
+
  00197fc0: 34020001 ori r2,r0,0x0001                     |
  00197f88: 00000000 nop
+
  00197fc4: 08065ff9 j 0x00197fe4                     {{f/jump|Else :}} {{f/loc|Exit}} {{f/Returns|Return 0x01}}
  00197f8c: 2402fffe addiu r2,r0,0xfffe
+
  00197fc8: 00000000 nop                                   |
  00197f90: 1062000e beq r3,r2,0x00197fcc
+
  00197f94: 34020001 ori r2,r0,0x0001
+
{{f/sec|Run like a Rabbit (Auto Battle 0x11)}}
  00197f98: 08065ff9 j 0x00197fe4
+
  00197fcc: 0c066398 jal 0x00198e60               |{{f/jal|AI_Critical_or_Run_Like_Rabbit|AI_Critical_or_Run_Like_Rabbit}}
  00197f9c: 00000000 nop
+
  00197fd0: 00000000 nop                           |
  00197fa0: 0c06637c jal 0x00198df0 [[00198df0 - 00198e5c]]
+
  00197fd4: 2403ffff addiu r3,r0,0xffff           |
  00197fa4: 00000000 nop
+
  00197fa8: 00401821 addu r3,r2,r0
+
{{f/sec|Terminal section}}
  00197fac: 2402ffff addiu r2,r0,0xffff
+
  00197fd8: 14430002 bne r2,r3,0x00197fe4     {{f/Cond|If Auto Battle routine returns r2 <> -0x0001}} {{f/Returns|Returns 0x01}}
  00197fb0: 1062000c beq r3,r2,0x00197fe4
+
  00197fdc: 34020001 ori r2,r0,0x0001             |
  00197fb4: 00000000 nop
+
                                            '''Else : Auto Battle routine '''
  00197fb8: 2402fffe addiu r2,r0,0xfffe
+
  00197fe0: 2402ffff addiu r2,r0,-0x0001          |{{f/Returns|Returns -0x01}}
  00197fbc: 1062ffed beq r3,r2,0x00197f74
 
  00197fc0: 34020001 ori r2,r0,0x0001
 
  00197fc4: 08065ff9 j 0x00197fe4
 
  00197fc8: 00000000 nop
 
  00197fcc: 0c066398 jal 0x00198e60 [[00198e60 - 00199058]]
 
  00197fd0: 00000000 nop
 
  00197fd4: 2403ffff addiu r3,r0,0xffff
 
  00197fd8: 14430002 bne r2,r3,0x00197fe4
 
  00197fdc: 34020001 ori r2,r0,0x0001
 
  00197fe0: 2402ffff addiu r2,r0,0xffff
 
 
  00197fe4: 8fbf0010 lw r31,0x0010(r29)
 
  00197fe4: 8fbf0010 lw r31,0x0010(r29)
 
  00197fe8: 27bd0018 addiu r29,r29,0x0018
 
  00197fe8: 27bd0018 addiu r29,r29,0x0018
 
  00197fec: 03e00008 jr r31
 
  00197fec: 03e00008 jr r31
 
  00197ff0: 00000000 nop
 
  00197ff0: 00000000 nop
</font>
+
===Return locations===
 +
'''BATTLE.BIN'''
 +
  00195f14: [[AI_Initial_Targeting_Selection]]

Latest revision as of 15:53, 10 April 2024

BATTLE.BIN :  -  Auto Battle Handling
------------------------------------------------------------------------------------------
Parameter : Nothing
Return : r2 = 0x00 if invalid or unhandled Autobattle flag
Return : r2 = -0x01 if Any Auto Battle routines returns - 0x01
Return : r2 = 0x01if when Auto Battle routine has been called and didn't return -0x01
------------------------------------------------------------------------------------------
00197f14: 27bdffe8 addiu r29,r29,-0x0018     |
00197f18: 3c03801a lui r3,0x801a             |
00197f1c: 90630d7a lbu r3,0x0d7a(r3)         |Load AutoBattle Flags 8019f3c4 + 0x19b6 aka 801a0d7a
00197f20: 3402000e ori r2,r0,0x000e          |
00197f24: 10620013 beq r3,r2,0x00197f74      #If Auto Battle is 0x0e : Branch to  Protect Allies
00197f28: afbf0010 sw r31,0x0010(r29)            |
00197f2c: 2862000f slti r2,r3,0x000f         |If Less Than 0xf
00197f30: 10400005 beq r2,r0,0x00197f48      #If below 0x0e
00197f34: 3402000c ori r2,r0,0x000c              |
00197f38: 1062000a beq r3,r2,0x00197f64          #If Auto Battle is 0x0c : branch to  Fight for your life
00197f3c: 00001021 addu r2,r0,r0                     |
00197f40: 08065ff9 j 0x00197fe4                  >>Else Exit Returns 0x00
00197f44: 00000000 nop                               |
                                            Else : Auto Battle above 0x0e
00197f48: 34020010 ori r2,r0,0x0010                  |
00197f4c: 10620014 beq r3,r2,0x00197fa0          #If Auto Battle 0x10 : branch to  Save Fading life
00197f50: 34020011 ori r2,r0,0x0011                  |
00197f54: 1062001d beq r3,r2,0x00197fcc          #If Auto Battle 0x11 : branch to Run like a rabbit
00197f58: 00001021 addu r2,r0,r0                     |
00197f5c: 08065ff9 j 0x00197fe4                  >>Else Exit Returns 0x00
00197f60: 00000000 nop                               |

Fight For your Life ( Focus Unit + Enemy Target) - Auto Battle 0x0c
00197f64: 0c065ffd jal 0x00197ff4                    |-->Fight_for_Life_-_Auto_Battle_(00197ff4)
00197f68: 00000000 nop                               |
00197f6c: 08065ff6 j 0x00197fd8                      >>Jump to resolution
00197f70: 2403ffff addiu r3,r0,-0x0001                   |

Protect Allies (Focus Unit + Allied Target) - Auto Battle 0x0e
00197f74: 0c06613b jal 0x001984ec                    |-->Protect_Allies_-_Auto_Battle_(001984ec)
00197f78: 00000000 nop                               |
00197f7c: 00401821 addu r3,r2,r0                     |
00197f80: 2402ffff addiu r2,r0,-0x0001               |
00197f84: 10620017 beq r3,r2,0x00197fe4              #If Returned value is -0x0001 : Exit Returns -0x01
00197f88: 00000000 nop                                   |
00197f8c: 2402fffe addiu r2,r0,-0x0002                   |
00197f90: 1062000e beq r3,r2,0x00197fcc              #If Returned value is -0x0002 : branch to  Run like a rabbit
00197f94: 34020001 ori r2,r0,0x0001                      |
00197f98: 08065ff9 j 0x00197fe4                      >>Else : Exit Return 0x01
00197f9c: 00000000 nop                                   |

Save Fading Life (Auto Battle 0x10)
00197fa0: 0c06637c jal 0x00198df0                    |-->Save_Fading_Life_-_Auto_Battle_(00198df0)
00197fa4: 00000000 nop                               |
00197fa8: 00401821 addu r3,r2,r0                     |
00197fac: 2402ffff addiu r2,r0,-0x0001               |
00197fb0: 1062000c beq r3,r2,0x00197fe4              #If Returned value is -0x0001 : Exit Returns -0x01
00197fb4: 00000000 nop                                   |
00197fb8: 2402fffe addiu r2,r0,-0x0002                   |
00197fbc: 1062ffed beq r3,r2,0x00197f74              #If Returned value is -0x0002 : branch to  Protect Ally
00197fc0: 34020001 ori r2,r0,0x0001                      |
00197fc4: 08065ff9 j 0x00197fe4                      >>Else : Exit Return 0x01
00197fc8: 00000000 nop                                   |

Run like a Rabbit (Auto Battle 0x11)
00197fcc: 0c066398 jal 0x00198e60                |-->AI_Critical_or_Run_Like_Rabbit
00197fd0: 00000000 nop                           |
00197fd4: 2403ffff addiu r3,r0,0xffff            |

Terminal section
00197fd8: 14430002 bne r2,r3,0x00197fe4      #If Auto Battle routine returns r2 <> -0x0001 Returns 0x01
00197fdc: 34020001 ori r2,r0,0x0001              |
                                            Else : Auto Battle routine 
00197fe0: 2402ffff addiu r2,r0,-0x0001           |Returns -0x01
00197fe4: 8fbf0010 lw r31,0x0010(r29)
00197fe8: 27bd0018 addiu r29,r29,0x0018
00197fec: 03e00008 jr r31
00197ff0: 00000000 nop

Return locations

BATTLE.BIN
 00195f14: AI_Initial_Targeting_Selection