Auto Battle Handling

From Final Fantasy Hacktics Wiki
(Redirected from 00197f14 - 00197ff0)
Jump to navigation Jump to search
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