Difference between revisions of "Call AI Ability Processing"

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<font face='Courier New'>
+
'''BATTLE.BIN''' :  - Call AI Ability Processing
   
+
------------------------------------------------------------------------------------------
  0019dcbc: 27bdffe8 addiu r29,r29,0xffe8
+
Parameter : r4 : Pointer to Action Data (Battle 0x16e format)
  0019dcc0: 340200ff ori r2,r0,0x00ff
+
  Return : r2 = 0x00 if Ability do not strike any unit enabled in AI 0xc8d or if Ability did not strike at all
  0019dcc4: afbf0014 sw r31,0x0014(r29)
+
          r2 = 0x01 if Ability strikes
  0019dcc8: afb00010 sw r16,0x0010(r29)
+
------------------------------------------------------------------------------------------
  0019dccc: 3c01801a lui r1,0x801a
+
  0019dcbc: 27bdffe8 addiu r29,r29,-0x0018    |
  0019dcd0: a022007e sb r2,0x007e(r1)             store 0xff
+
  0019dcc0: 340200ff ori r2,r0,0x00ff         |{{f/std|<nowiki>r2 = 0x00FF</nowiki>}}
  0019dcd4: 90830000 lbu r3,0x0000(r4)
+
  0019dcc4: afbf0014 sw r31,0x0014(r29)       |
  0019dcd8: 3c02801a lui r2,0x801a
+
  0019dcc8: afb00010 sw r16,0x0010(r29)       |
  0019dcdc: 904201f2 lbu r2,0x01f2(r2)           load acting unit ID
+
  0019dccc: 3c01801a lui r1,0x801a             |
  0019dce0: 3c10801a lui r16,0x801a
+
  0019dcd0: a022007e sb r2,0x007e(r1)         |{{f/store|<nowiki>Set 0x801a007e = 0xff</nowiki>}} {{f/std|AI 0xcba}}
  0019dce4: 2610f3c4 addiu r16,r16,0xf3c4
+
  0019dcd4: 90830000 lbu r3,0x0000(r4)         |{{f/load|Load Acting Unit ID (for considered Action)}}
  0019dce8: 1462000e bne r3,r2,0x0019dd24         branch if ID is not acting units
+
  0019dcd8: 3c02801a lui r2,0x801a             |
  0019dcec: 34020001 ori r2,r0,0x0001
+
  0019dcdc: 904201f2 lbu r2,0x01f2(r2)         |{{f/load|Load Acting Unit's ID}} {{f/std|AI 0xe2e}}
  0019dcf0: 3c03801a lui r3,0x801a
+
  0019dce0: 3c10801a lui r16,0x801a           |
  0019dcf4: 9063f3f5 lbu r3,-0x0c0b(r3)         load CT of ability
+
  0019dce4: 2610f3c4 addiu r16,r16,-0x0c3c    |{{f/adr|<nowiki>r16 = AI Data Pointer</nowiki>}}
  0019dcf8: 3c01801a lui r1,0x801a
+
  0019dce8: 1462000e bne r3,r2,0x0019dd24     {{f/Cond|If Considered Unit is Acting Unit}}
  0019dcfc: a0220d80 sb r2,0x0d80(r1)           store 1
+
  0019dcec: 34020001 ori r2,r0,0x0001             |
  0019dd00: 340200ff ori r2,r0,0x00ff
+
  0019dcf0: 3c03801a lui r3,0x801a                 |
  0019dd04: 14620007 bne r3,r2,0x0019dd24         branch if not ff
+
  0019dcf4: 9063f3f5 lbu r3,-0x0c0b(r3)           |{{f/load|Load AI 0x31}}
  0019dd08: 00000000 nop
+
  0019dcf8: 3c01801a lui r1,0x801a                 |
  0019dd0c: 3c01801a lui r1,0x801a
+
  0019dcfc: a0220d80 sb r2,0x0d80(r1)             |{{f/store|<nowiki>AI 0x19bc = 0x01</nowiki>}} {{f/std| 801a0d80}}
  0019dd10: a020007e sb r0,0x007e(r1)
+
  0019dd00: 340200ff ori r2,r0,0x00ff             |
  0019dd14: 3c01801a lui r1,0x801a
+
  0019dd04: 14620007 bne r3,r2,0x0019dd24         {{f/Cond|<nowiki>if AI 0x31 = 0xff</nowiki>}} {{f/std|Base Hit not set ?}}
  0019dd18: a420007c sh r0,0x007c(r1)
+
  0019dd08: 00000000 nop                               |
  0019dd1c: 3c01801a lui r1,0x801a
+
  0019dd0c: 3c01801a lui r1,0x801a                     |
  0019dd20: a0200d7e sb r0,0x0d7e(r1)
+
  0019dd10: a020007e sb r0,0x007e(r1)                 |{{f/store|Initialize AI 0xcba}} {{f/std|hit counter (Nb of Targets and Nb of strikes)}}
  0019dd24: 0c067763 jal 0x0019dd8c          
+
  0019dd14: 3c01801a lui r1,0x801a                     |
  0019dd28: 00002821 addu r5,r0,r0
+
  0019dd18: a420007c sh r0,0x007c(r1)                 |{{f/store|Initialize AI 0xcb8 }} {{f/std|Sum of all Target action  Hit%}}
  0019dd2c: 92030cba lbu r3,0x0cba(r16)
+
  0019dd1c: 3c01801a lui r1,0x801a                     |
  0019dd30: 340200ff ori r2,r0,0x00ff
+
  0019dd20: a0200d7e sb r0,0x0d7e(r1)                 |{{f/store|Initialize AI 0x19ba}} {{f/std|Flag for hitting a valuable target ?}}
  0019dd34: 10620010 beq r3,r2,0x0019dd78
+
  0019dd24: 0c067763 jal 0x0019dd8c           |{{f/jal|AI ability processing|AI ability processing}} {{f/std|Ability Simulation}}
  0019dd38: 34020001 ori r2,r0,0x0001
+
  0019dd28: 00002821 addu r5,r0,r0             |{{f/std|Simulate acting unit action}}
  0019dd3c: 920219ba lbu r2,0x19ba(r16)
+
  0019dd2c: 92030cba lbu r3,0x0cba(r16)       |{{f/load|Load Strike counter}}
  0019dd40: 00000000 nop
+
  0019dd30: 340200ff ori r2,r0,0x00ff         |
  0019dd44: 10400003 beq r2,r0,0x0019dd54
+
  0019dd34: 10620010 beq r3,r2,0x0019dd78     {{f/Cond|if AI 0xcba is not set : }} {{f/loc|Exit}} {{f/Returns|Returns 0x01}} {{f/std|reached his limit ?}}
  0019dd48: 00000000 nop
+
  0019dd38: 34020001 ori r2,r0,0x0001             |
  0019dd4c: 14600003 bne r3,r0,0x0019dd5c
+
  0019dd3c: 920219ba lbu r2,0x19ba(r16)           |{{f/load|Load (0x0d7e)}}
  0019dd50: 00000000 nop
+
  0019dd40: 00000000 nop                           |
  0019dd54: 0806775e j 0x0019dd78
+
  0019dd44: 10400003 beq r2,r0,0x0019dd54         {{f/Cond|If Ability did not hit any unit in 0xc8d Table}} {{f/loc|Exit}} {{f/Returns|Returns 0x00}} {{f/std|valuable targets table ?}}
  0019dd58: 00001021 addu r2,r0,r0
+
  0019dd48: 00000000 nop                           |
  0019dd5c: 96020cb8 lhu r2,0x0cb8(r16)
+
  0019dd4c: 14600003 bne r3,r0,0x0019dd5c         {{f/Cond|If Strike counter is null}}
  0019dd60: 00000000 nop
+
  0019dd50: 00000000 nop                               |
  0019dd64: 0043001a div r2,r3
+
  0019dd54: 0806775e j 0x0019dd78                     |{{f/loc|Exit}} {{f/Returns|Returns 0x00}}
  0019dd68: 00001012 mflo r2
+
  0019dd58: 00001021 addu r2,r0,r0                         |
  0019dd6c: 00000000 nop
+
                                                  '''Else : Strike counter not null'''
  0019dd70: a2020031 sb r2,0x0031(r16)
+
  0019dd5c: 96020cb8 lhu r2,0x0cb8(r16)               |{{f/load|Load sum of hit%}}
  0019dd74: 34020001 ori r2,r0,0x0001
+
  0019dd60: 00000000 nop                               |
  0019dd78: 8fbf0014 lw r31,0x0014(r29)
+
  0019dd64: 0043001a div r2,r3                         |
 +
  0019dd68: 00001012 mflo r2                           |{{f/std|Average Hit%}} {{f/std|Sum of hit% / nb of strikes}}
 +
  0019dd6c: 00000000 nop                               |
 +
  0019dd70: a2020031 sb r2,0x0031(r16)                 |{{f/store|Store Average Hit%}}
 +
  0019dd74: 34020001 ori r2,r0,0x0001                 |{{f/Returns|Return 0x01}}
 +
  0019dd78: 8fbf0014 lw r31,0x0014(r29)       END
 
  0019dd7c: 8fb00010 lw r16,0x0010(r29)
 
  0019dd7c: 8fb00010 lw r16,0x0010(r29)
 
  0019dd80: 27bd0018 addiu r29,r29,0x0018
 
  0019dd80: 27bd0018 addiu r29,r29,0x0018
 
  0019dd84: 03e00008 jr r31
 
  0019dd84: 03e00008 jr r31
 
  0019dd88: 00000000 nop
 
  0019dd88: 00000000 nop
</font>
+
===Return locations===
 +
'''BATTLE.BIN'''
 +
  0019d46c: [[AI_End_of_turn,_in_between_turn,_etc.]]  r4 = Pointer to 8019f3c4 + 0x1c
 +
  0019d4cc: [[AI_End_of_turn,_in_between_turn,_etc.]]  r4 = Pointer to 8019f3c4 + 0x1c
 +
  0019d5f0: [[AI_End_of_turn,_in_between_turn,_etc.]]  r4 = Pointer to Battle Data + 0x16e

Latest revision as of 20:07, 28 May 2024

BATTLE.BIN :  - Call AI Ability Processing
------------------------------------------------------------------------------------------
Parameter : r4 : Pointer to Action Data (Battle 0x16e format)
Return : r2 = 0x00 if Ability do not strike any unit enabled in AI 0xc8d or if Ability did not strike at all
         r2 = 0x01 if Ability strikes
------------------------------------------------------------------------------------------
0019dcbc: 27bdffe8 addiu r29,r29,-0x0018     |
0019dcc0: 340200ff ori r2,r0,0x00ff          |r2 = 0x00FF
0019dcc4: afbf0014 sw r31,0x0014(r29)        |
0019dcc8: afb00010 sw r16,0x0010(r29)        |
0019dccc: 3c01801a lui r1,0x801a             |
0019dcd0: a022007e sb r2,0x007e(r1)          |Set 0x801a007e = 0xff AI 0xcba
0019dcd4: 90830000 lbu r3,0x0000(r4)         |Load Acting Unit ID (for considered Action)
0019dcd8: 3c02801a lui r2,0x801a             |
0019dcdc: 904201f2 lbu r2,0x01f2(r2)         |Load Acting Unit's ID AI 0xe2e
0019dce0: 3c10801a lui r16,0x801a            |
0019dce4: 2610f3c4 addiu r16,r16,-0x0c3c     |r16 = AI Data Pointer
0019dce8: 1462000e bne r3,r2,0x0019dd24      #If Considered Unit is Acting Unit
0019dcec: 34020001 ori r2,r0,0x0001              |
0019dcf0: 3c03801a lui r3,0x801a                 |
0019dcf4: 9063f3f5 lbu r3,-0x0c0b(r3)            |Load AI 0x31
0019dcf8: 3c01801a lui r1,0x801a                 |
0019dcfc: a0220d80 sb r2,0x0d80(r1)              |AI 0x19bc = 0x01  801a0d80
0019dd00: 340200ff ori r2,r0,0x00ff              |
0019dd04: 14620007 bne r3,r2,0x0019dd24          #if AI 0x31 = 0xff Base Hit not set ?
0019dd08: 00000000 nop                               |
0019dd0c: 3c01801a lui r1,0x801a                     |
0019dd10: a020007e sb r0,0x007e(r1)                  |Initialize AI 0xcba hit counter (Nb of Targets and Nb of strikes)
0019dd14: 3c01801a lui r1,0x801a                     |
0019dd18: a420007c sh r0,0x007c(r1)                  |Initialize AI 0xcb8  Sum of all Target action  Hit%
0019dd1c: 3c01801a lui r1,0x801a                     |
0019dd20: a0200d7e sb r0,0x0d7e(r1)                  |Initialize AI 0x19ba Flag for hitting a valuable target ?
0019dd24: 0c067763 jal 0x0019dd8c            |-->AI ability processing Ability Simulation
0019dd28: 00002821 addu r5,r0,r0             |Simulate acting unit action
0019dd2c: 92030cba lbu r3,0x0cba(r16)        |Load Strike counter
0019dd30: 340200ff ori r2,r0,0x00ff          |
0019dd34: 10620010 beq r3,r2,0x0019dd78      #if AI 0xcba is not set :  Exit Returns 0x01 reached his limit ?
0019dd38: 34020001 ori r2,r0,0x0001              |
0019dd3c: 920219ba lbu r2,0x19ba(r16)            |Load (0x0d7e)
0019dd40: 00000000 nop                           |
0019dd44: 10400003 beq r2,r0,0x0019dd54          #If Ability did not hit any unit in 0xc8d Table Exit Returns 0x00 valuable targets table ?
0019dd48: 00000000 nop                           |
0019dd4c: 14600003 bne r3,r0,0x0019dd5c          #If Strike counter is null
0019dd50: 00000000 nop                               |
0019dd54: 0806775e j 0x0019dd78                      |Exit Returns 0x00
0019dd58: 00001021 addu r2,r0,r0                         |
                                                 Else : Strike counter not null
0019dd5c: 96020cb8 lhu r2,0x0cb8(r16)                |Load sum of hit%
0019dd60: 00000000 nop                               |
0019dd64: 0043001a div r2,r3                         |
0019dd68: 00001012 mflo r2                           |Average Hit% Sum of hit% / nb of strikes
0019dd6c: 00000000 nop                               |
0019dd70: a2020031 sb r2,0x0031(r16)                 |Store Average Hit%
0019dd74: 34020001 ori r2,r0,0x0001                  |Return 0x01
0019dd78: 8fbf0014 lw r31,0x0014(r29)        END
0019dd7c: 8fb00010 lw r16,0x0010(r29)
0019dd80: 27bd0018 addiu r29,r29,0x0018
0019dd84: 03e00008 jr r31
0019dd88: 00000000 nop

Return locations

BATTLE.BIN
 0019d46c: AI_End_of_turn,_in_between_turn,_etc.   r4 = Pointer to 8019f3c4 + 0x1c
 0019d4cc: AI_End_of_turn,_in_between_turn,_etc.   r4 = Pointer to 8019f3c4 + 0x1c
 0019d5f0: AI_End_of_turn,_in_between_turn,_etc.   r4 = Pointer to Battle Data + 0x16e