Difference between revisions of "AI Ability Data Setting"

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
m (Link to Table)
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
  AI Ability Data Setting
+
  AI Ability Data Setting : reset and set some data in 0x8019f3c4 section. Bugs and hard coded things (see notes)
00195878: 27bdffc8 addiu r29,r29,0xffc8
+
  ----------------------------------------------------------------------------------------------------------------
0019587c: afb40020 sw r20,0x0020(r29)
+
  Parameters : r4 - Ability data pointer (used to load data)
  00195880: 0080a021 addu r20,r4,r0 r20 = Unit's Move List
+
   
00195884: afb00010 sw r16,0x0010(r29)
+
  Returns nothing
00195888: 3c10801a lui r16,0x801a
+
  ----------------------------------------------------------------------------------------
0019588c: 2610f3c4 addiu r16,r16,0xf3c4
+
  00195878: 27bdffc8 addiu r29,r29,-0x0038    |
00195890: 02002021 addu r4,r16,r0 r4 = AI Data Pointer?
+
  0019587c: afb40020 sw r20,0x0020(r29)       |
00195894: 34050014 ori r5,r0,0x0014 Limit = 0x14 (in bytes)
+
  00195880: 0080a021 addu r20,r4,r0          |{{f/adr|<nowiki>r20 = Ability pointer in AI Unit's Move List</nowiki>}} {{f/std| 801a02b4}}
  00195898: afbf0030 sw r31,0x0030(r29)
+
  00195884: afb00010 sw r16,0x0010(r29)       |
  0019589c: afb7002c sw r23,0x002c(r29)
+
  00195888: 3c10801a lui r16,0x801a          |
  001958a0: afb60028 sw r22,0x0028(r29)
+
  0019588c: 2610f3c4 addiu r16,r16,-0xc3c    |{{f/adr|Start of AI Used/processed Ability Data pointer}} {{f/std|0x8019f3c4 - 8019f3c4}}
  001958a4: afb50024 sw r21,0x0024(r29)
+
  00195890: 02002021 addu r4,r16,r0          |
001958a8: afb3001c sw r19,0x001c(r29)
+
  00195894: 34050014 ori r5,r0,0x0014        |{{f/std|Nb of byte to delete in routine below}}
001958ac: afb20018 sw r18,0x0018(r29)
+
  00195898: afbf0030 sw r31,0x0030(r29)      |
001958b0: 0c066ade jal 0x 0019ab78 Word Nulling
+
  0019589c: afb7002c sw r23,0x002c(r29)      |
001958b4: afb10014 sw r17,0x0014(r29)
+
  001958a0: afb60028 sw r22,0x0028(r29)       |
001958b8: 26040020 addiu r4,r16,0x0020 r4 = AI Data Pointer? + 0x20
+
  001958a4: afb50024 sw r21,0x0024(r29)       |
  001958bc: 0c066ade jal 0x 0019ab78 Word Nulling
+
  001958a8: afb3001c sw r19,0x001c(r29)       |
001958c0: 34050004 ori r5,r0,0x0004 Limit = 4 (in bytes)
+
  001958ac: afb20018 sw r18,0x0018(r29)      |
  001958c4: 92820002 lbu r2,0x0002(r20) Load Skillset
+
  001958b0: 0c066ade jal 0x0019ab78          |{{f/jal|Word_Nulling|Word_Nulling}} {{f/std|Nullify 5 Words from 0x8019f3c4 to 0x8019f3d7  (Some ability data - see notes)}}
  001958c8: 00000000 nop
+
  001958b4: afb10014 sw r17,0x0014(r29)      |
  001958cc: a2020000 sb r2,0x0000(r16) Store Skillset
+
  001958b8: 26040020 addiu r4,r16,0x0020      |{{f/std|Calculator Type Ability ID}}
  001958d0: 96830000 lhu r3,0x0000(r20) Load Ability/Unit ID
+
001958bc: 0c066ade jal 0x0019ab78          |{{f/jal|Word_Nulling|Word_Nulling}} {{f/std|Nullify calculator related data}}
  001958d4: 3c048019 lui r4,0x8019
+
  001958c0: 34050004 ori r5,r0,0x0004        |
  001958d8: 248408cc addiu r4,r4,0x08cc
+
  001958c4: 92820002 lbu r2,0x0002(r20)      |{{f/load|Load Ability skillset ID}}
  001958dc: 306303ff andi r3,r3,0x03ff r3 = Ability ID
+
  001958c8: 00000000 nop                      |
  001958e0: 00608821 addu r17,r3,r0 r17 = Ability ID
+
  001958cc: a2020000 sb r2,0x0000(r16)       |{{f/store|Store Skillset ID}}
  001958e4: 3c01801a lui r1,0x801a
+
  001958d0: 96830000 lhu r3,0x0000(r20)      |{{f/load|Byte 00 and 01 (both needed to find Ability ID)}}
  001958e8: a423f3c6 sh r3,-0x0c3a(r1) Store Ability ID (why not use r16 + 2?)
+
  001958d4: 3c048019 lui r4,0x8019            |
  001958ec: 96820000 lhu r2,0x0000(r20) Load Ability/Unit ID
+
  001958d8: 248408cc addiu r4,r4,0x08cc      |{{f/adr|Start of unit data}}
  001958f0: 92830002 lbu r3,0x0002(r20) Load Skillset
+
  001958dc: 306303ff andi r3,r3,0x03ff        |{{f/std|Ability ID mask }} {{f/std|(+flag 0x2 of byte 0x00 ?)}}
  001958f4: 00021400 sll r2,r2,0x10
+
  001958e0: 00608821 addu r17,r3,r0           |/r17 = Ability ID
  001958f8: 0002ae83 sra r21,r2,0x1a r21 = Unit's ID
+
  001958e4: 3c01801a lui r1,0x801a            |
  001958fc: 001510c0 sll r2,r21,0x03 Unit's ID * 8
+
  001958e8: a423f3c6 sh r3,-0x0c3a(r1)        |{{f/store|Store Ability ID at 0x8019f3c6}} {{f/std| 0x8019f3c4 - 0x02}}
  00195900: 00551023 subu r2,r2,r21 ID * 7
+
  001958ec: 96820000 lhu r2,0x0000(r20)       |{{f/load|Byte 00 and 01 (both needed to find Ability ID)}}
  00195904: 00021180 sll r2,r2,0x06 ID * 1c0
+
  001958f0: 92830002 lbu r3,0x0002(r20)      |{{f/load|Load Ability skillset ID}}
  00195908: 3c018006 lui r1,0x8006
+
  001958f4: 00021400 sll r2,r2,0x10          |{{f/std|Pass halfword in upper registery}}
  0019590c: 00230821 addu r1,r1,r3
+
  001958f8: 0002ae83 sra r21,r2,0x1a          |/Unit ID (from 0x801a02b4) {{f/std|Right shift destroying low byte and 2nd byte flag 0x1 and 0x2 (keep just Unit ID)}}
  00195910: 90375cb4 lbu r23,0x5cb4(r1) Load Skillset's Action Menu
+
  001958fc: 001510c0 sll r2,r21,0x03         |{{f/std|Unit ID * 8}}
  00195914: 00449021 addu r18,r2,r4 r18 = Unit's Data Pointer
+
  00195900: 00551023 subu r2,r2,r21          |{{f/std|Unit ID * 7}}
  00195918: 26e3ffff addiu r3,r23,0xffff r3 = Action Menu - 1
+
  00195904: 00021180 sll r2,r2,0x06          |{{f/std|Unid ID * 0x1c0 }}
  0019591c: 2c62000a sltiu r2,r3,0x000a
+
  00195908: 3c018006 lui r1,0x8006            |
  00195920: 104000b7 beq r2,r0,0x 00195c00 Branch if Action Menu - 1 >= a (Defend)
+
  0019590c: 00230821 addu r1,r1,r3            |{{f/std|0x80060000 + Ability's skillset ID}}
  00195924: 0000b021 addu r22,r0,r0 r22 = 0
+
  00195910: 90375cb4 lbu r23,0x5cb4(r1)       |{{f/load|<nowiki>r23 = Ability's Skillset's Action menu</nowiki>}}
  00195928: 00031080 sll r2,r3,0x02 Action Menu * 4
+
  00195914: 00449021 addu r18,r2,r4          |{{f/adr|<nowiki>r18 = Unit Battle Data Pointer</nowiki>}}
0019592c: 3c018019 lui r1,0x8019
+
  00195918: 26e3ffff addiu r3,r23,-0x0001    |
  00195930: 00220821 addu r1,r1,r2
+
  0019591c: 2c62000a sltiu r2,r3,0x000a      |{{f/std|<nowiki>r2 = 0x1 if Action menu is between 0x1 and 0xa    (not default, defend, equip change, unknown nor blank)</nowiki>}}
  00195934: 8c223d48 lw r2,0x3d48(r1) Load Pointer for below ([[BATTLE.BIN_Data_Tables#AI_Ability_Data_Setting_JumpAdr|Table details]])
+
  00195920: 104000b7 beq r2,r0,0x00195c00    {{f/Cond|Branch to }} {{f/loc| Default section }} if the action menu don't have a jump pointer address
  00195938: 00000000 nop
+
  00195924: 0000b021 addu r22,r0,r0          |{{f/std|<nowiki>r22 = 0x00 (will be used to store inflicted status in some section)</nowiki>}}
  0019593c: 00400008 jr r2
+
  00195928: 00031080 sll r2,r3,0x02              |{{f/std|Action menu offset (word)}}
  00195940: 00000000 nop
+
  0019592c: 3c018019 lui r1,0x8019                |
 
+
  00195930: 00220821 addu r1,r1,r2               |
*Attack*
+
  00195934: 8c223d48 lw r2,0x3d48(r1)             |{{f/adr|Load Action menu jump Adress}} ([[BATTLE.BIN_Data_Tables#AI_Ability_Data_Setting_JumpAdr|Table details]])
00195944: 02151021 addu r2,r16,r21
+
  00195938: 00000000 nop                         |
00195948: 9042198c lbu r2,0x198c(r2) Load Unit's Battle ID
+
  0019593c: 00400008 jr r2                       |{{f/std|jump to specific action menu section}}
  0019594c: 00000000 nop
+
  00195940: 00000000 nop                          |
00195950: 000210c0 sll r2,r2,0x03 ID * 8
+
   
  00195954: 24421778 addiu r2,r2,0x1778
+
    {{f/sec|----Attack / Charge ----}} {{f/std|Code jumps backward from charge section after setting CT}}
  00195958: 02021821 addu r3,r16,r2
+
00195944: 02151021 addu r2,r16,r21          |{{f/std|8019f3c4 + Unit ID}}
  0019595c: 90620000 lbu r2,0x0000(r3) Load Weapon's Range
+
  00195948: 9042198c lbu r2,0x198c(r2)       |{{f/load|Load Unit Battle ID }} {{f/std| 0x801a0d50}}
  00195960: 00000000 nop
+
  0019594c: 00000000 nop                     |
00195964: a2020004 sb r2,0x0004(r16) Store Ability's Range
+
  00195950: 000210c0 sll r2,r2,0x03          |{{f/std|Unit ID * 8}}
  00195968: 90620005 lbu r2,0x0005(r3) Load Weapon's Elements
+
  00195954: 24421778 addiu r2,r2,0x1778      |
  0019596c: 00000000 nop
+
  00195958: 02021821 addu r3,r16,r2          |{{f/adr|Unit AI Weapon Attack data pointer}} {{f/std| 0x801a0b3c + Unit ID *8 }}
00195970: a2020010 sb r2,0x0010(r16) Store Ability's Elements
+
  0019595c: 90620000 lbu r2,0x0000(r3)       |{{f/load|Load Unit Attack range}}
  00195974: 90620004 lbu r2,0x0004(r3) Load Weapon ID
+
  00195960: 00000000 nop                      |
  00195978: 00000000 nop
+
  00195964: a2020004 sb r2,0x0004(r16)        |{{f/store|Store attack range in AI used ability data }} {{f/std|8019f3c4 - 0x04}}
0019597c: a2020006 sb r2,0x0006(r16) Store Item Considered
+
  00195968: 90620005 lbu r2,0x0005(r3)       |{{f/load|Load unit Attack's element}} {{f/std| (weapon elements ? And if dual ?)}}
  00195980: 90620001 lbu r2,0x0001(r3) Load AI Behavior Flags 1
+
  0019596c: 00000000 nop                      |
  00195984: 00000000 nop
+
  00195970: a2020010 sb r2,0x0010(r16)       |{{f/store|Store Element in AI used ability data}}
  00195988: a202000c sb r2,0x000c(r16) Store AI Behavior Flags 1
+
    {{f/sec|----Attack / Charge / Jump----}} {{f/std|Code jumps backward from jump section after setting CT and range}}
  0019598c: 90620002 lbu r2,0x0002(r3) Load AI Behavior Flags 2
+
  00195974: 90620004 lbu r2,0x0004(r3)        |{{f/load|Load Unit's Weapon ID}}
  00195990: 00000000 nop
+
00195978: 00000000 nop                      |
00195994: a202000d sb r2,0x000d(r16) Store AI Behavior Flags 2
+
  0019597c: a2020006 sb r2,0x0006(r16)        |{{f/store|Store Weapon ID in AI used ability data (Item considered)}} {{f/std| 8019f3c4 - 0x06}}
  00195998: 90620003 lbu r2,0x0003(r3) Load AI Behavior Flags 3
+
  00195980: 90620001 lbu r2,0x0001(r3)       |{{f/load|Load Ability AI behavior flags 1}}
0019599c: 00000000 nop
+
  00195984: 00000000 nop                      |
001959a0: a202000e sb r2,0x000e(r16) Store AI Behavior Flags 3
+
  00195988: a202000c sb r2,0x000c(r16)       |{{f/store|Store AI behavior flags 1 in AI used abilty data}}
  001959a4: 92820003 lbu r2,0x0003(r20) Load Usage Type?
+
  0019598c: 90620002 lbu r2,0x0002(r3)       |{{f/load|Load Ability AI behavior flags 2}}
001959a8: 00000000 nop
+
00195990: 00000000 nop                      |
  001959ac: a202000f sb r2,0x000f(r16) Store Usage Type?
+
  00195994: a202000d sb r2,0x000d(r16)       |{{f/store|Store AI behavior flags 2 in AI used abilty data}}
  001959b0: 34020009 ori r2,r0,0x0009 r2 = 9
+
  00195998: 90620003 lbu r2,0x0003(r3)       |{{f/load|Load Ability AI behavior flags 3}}
  001959b4: 16e200eb bne r23,r2,0x 00195d64 Branch if Action menu != Jump
+
  0019599c: 00000000 nop                      |
001959b8: 2403fffe addiu r3,r0,0xfffe r3 = FFFE
+
  001959a0: a202000e sb r2,0x000e(r16)       |{{f/store|Store AI behavior flags 3 in AI used abilty data}}
  001959bc: 8e02000c lw r2,0x000c(r16) Load AI Behavior Flags 1
+
  001959a4: 92820003 lbu r2,0x0003(r20)      |{{f/load|Load Ability AI behavior flags 3 (again)}}
  001959c0: 00000000 nop
+
  001959a8: 00000000 nop                      |
  001959c4: 34420002 ori r2,r2,0x0002 Enable Target Enemies
+
  001959ac: a202000f sb r2,0x000f(r16)       |{{f/store|Store AI behavior flags 3 in AI used abilty data (tagged as AI4 ? Action menu specific ?)}}
  001959c8: 00431024 and r2,r2,r3 Disable Target Allies
+
  001959b0: 34020009 ori r2,r0,0x0009        |
  001959cc: 08065759 j 0x 00195d64
+
  001959b4: 16e200eb bne r23,r2,0x00195d64    {{f/Cond|If Action menu is Jump }} / Else jump to  {{f/loc|END}}
001959d0: ae02000c sw r2,0x000c(r16) Store new AI Behavior Flags 1
+
  001959b8: 2403fffe addiu r3,r0,-0x0002          |{{f/std|<nowiki>r3 = 0xfffffffe</nowiki>}}
 
+
  001959bc: 8e02000c lw r2,0x000c(r16)           |{{f/load|Load AI used ability data AI flags 1}}
  *Item Inventory*
+
001959c0: 00000000 nop                          |
  001959d4: 2622fe90 addiu r2,r17,0xfe90 Item ID = Ability ID - 0x170 (potion)
+
  001959c4: 34420002 ori r2,r2,0x0002            |{{f/std|Enable Target enemy flag (flag 0x02)}}
  001959d8: 00021840 sll r3,r2,0x01 Item ID * 2
+
  001959c8: 00431024 and r2,r2,r3                |{{f/std|Cancel Target Allies (flag 0x01)}}
  001959dc: 00621821 addu r3,r3,r2 ID * 3
+
001959cc: 08065759 j 0x00195d64                {{f/jump|Jump to }} {{f/loc|END}}
  001959e0: 92420091 lbu r2,0x0091(r18) Load Unit's Support 3
+
  001959d0: ae02000c sw r2,0x000c(r16)            |{{f/store|Store AI behavior flags 13 in AI used abilty data 0x0c with Target enemy flag ON}}
  001959e4: 3c018006 lui r1,0x8006
+
  001959e8: 00230821 addu r1,r1,r3
+
    {{f/sec|----Item inventory ----}}
001959ec: 90363f9a lbu r22,0x3f9a(r1) Load Item's Inflict Status ID
+
  001959d4: 2622fe90 addiu r2,r17,-0x0170    |{{f/std|<nowiki>Item ID (Ability ID - 0x170 (Potion = 0x00))</nowiki>}} {{f/std| Hard coded}}
001959f0: 30420008 andi r2,r2,0x0008
+
  001959d8: 00021840 sll r3,r2,0x01          |{{f/std|Item ID * 2}}
  001959f4: 10400004 beq r2,r0,0x 00195a08 Branch if Unit doesn't have Throw Item
+
  001959dc: 00621821 addu r3,r3,r2            |{{f/std|Item ID * 3}}
  001959f8: 34020001 ori r2,r0,0x0001 r2 = 1
+
  001959e0: 92420091 lbu r2,0x0091(r18)      |{{f/load|Load Unit 3rd Support set}}
  001959fc: 9242003a lbu r2,0x003a(r18) Load Unit's Move
+
001959e4: 3c018006 lui r1,0x8006            |
  00195a00: 08065683 j 0x 00195a0c
+
001959e8: 00230821 addu r1,r1,r3            |
  00195a04: a2020004 sb r2,0x0004(r16) Store Range = Move
+
  001959ec: 90363f9a lbu r22,0x3f9a(r1)       |{{f/load|Load Item Inflicted status}} {{f/std| 0x80063f98 - 0x02 + Item offset}}
  00195a08: a2020004 sb r2,0x0004(r16) Store Range = 1
+
  001959f0: 30420008 andi r2,r2,0x0008        |{{f/std|Check for throw item in 3rd set of support}}
  00195a0c: a2000005 sb r0,0x0005(r16) Store AoE = 0
+
  001959f4: 10400004 beq r2,r0,0x00195a08    {{f/Cond|If Unit uses throw item}}
  00195a10: 3c018006 lui r1,0x8006
+
  001959f8: 34020001 ori r2,r0,0x0001            |
00195a14: 00310821 addu r1,r1,r17
+
  001959fc: 9242003a lbu r2,0x003a(r18)           |{{f/load|Load Unit's Move stat}} / BUG : should be 0x4
00195a18: 90220ea0 lbu r2,0x0ea0(r1) Load Item Used ID
+
00195a00: 08065683 j 0x00195a0c                {{f/jump|Jump to preserve range value}}
  00195a1c: 08065700 j 0x 00195c00
+
  00195a04: a2020004 sb r2,0x0004(r16)           |{{f/store|Store it as range in AI used ability data}}
  00195a20: a2020006 sb r2,0x0006(r16) Store Item Considered = Item Used ID
+
                                            {{f/Cond|Else : Unit do not use throw item}}
 
+
  00195a08: a2020004 sb r2,0x0004(r16)           |{{f/store|Force range to 0x1 in AI used ability data}}
  *Katana Inventory*
+
  00195a0c: a2000005 sb r0,0x0005(r16)       |{{f/store|Nullify AoE }}
00195a24: 2622ffda addiu r2,r17,0xffda r2 = Katana ID
+
  00195a10: 3c018006 lui r1,0x8006            |
  00195a28: 08065700 j 0x 00195c00
+
  00195a14: 00310821 addu r1,r1,r17          |
  00195a2c: a2020006 sb r2,0x0006(r16) Store Item Considered = Katana ID
+
  00195a18: 90220ea0 lbu r2,0x0ea0(r1)       |{{f/load|Load Ability's used item}} {{f/std| (0x80061010 +for potion(ID is 0x170))}}
 
+
  00195a1c: 08065700 j 0x00195c00            {{f/jump|Jump to default section}}
  *Weapon Inventory*
+
  00195a20: a2020006 sb r2,0x0006(r16)       |{{f/store|Store used item ID in AI used ability data (as item considered)}}
00195a30: 2622ff86 addiu r2,r17,0xff86 r2 = Shuriken ID
+
   
  00195a34: 2c420003 sltiu r2,r2,0x0003
+
    {{f/sec|----Katana inventory ----}}
  00195a38: 14400005 bne r2,r0,0x 00195a50 Branch if Weapon isn't a Shuriken
+
  00195a24: 2622ffda addiu r2,r17,-0x0026    |{{f/std|<nowiki>r2 = Katana ID (Ability ID - 0x26)</nowiki>}} {{f/std|Hardcoded - 0x26 if the gap between first draw out Ability ID and first katana ID}}
  00195a3c: 3402017e ori r2,r0,0x017e r2 = 0x17e (Throw Shuriken)
+
  00195a28: 08065700 j 0x00195c00            {{f/jump|Jump to default section}}
  00195a40: 2622ff83 addiu r2,r17,0xff83 r2 = Ball ID
+
  00195a2c: a2020006 sb r2,0x0006(r16)        |{{f/store|Store used katana ID in AI used ability data (as item considered)}}
  00195a44: 2c420003 sltiu r2,r2,0x0003
+
   
  00195a48: 10400009 beq r2,r0,0x 00195a70 Branch if Weapon isn't a Ball
+
    {{f/sec|----Weapon inventory ----}}  {{f/std|For throw r17 is Threw Weapon ID ? }}
  00195a4c: 34020189 ori r2,r0,0x0189 r2 = Throw Ball
+
  00195a30: 2622ff86 addiu r2,r17,0xff86      |{{f/std|Used Weapon ID - 0x7A}}
00195a50: a6020002 sh r2,0x0002(r16) Store Ability ID = Throw Shuriken/Ball
+
  00195a34: 2c420003 sltiu r2,r2,0x0003      |{{f/std|Check if Weapon ID is between 0x7A and 0x7C (shurikens)}}
  00195a54: 001110c0 sll r2,r17,0x03 ID * 8
+
  00195a38: 14400005 bne r2,r0,0x00195a50    {{f/Cond|If Not a Shuriken}}
  00195a58: a2110006 sb r17,0x0006(r16) Store Item Considered = Weapon ID
+
  00195a3c: 3402017e ori r2,r0,0x017e        |{{f/std|<nowiki>r2 = 0x17e (Throw shuriken ability ID)</nowiki>}}
  00195a5c: 3c018006 lui r1,0x8006
+
  00195a40: 2622ff83 addiu r2,r17,0xff83          |{{f/std|Used weapon ID - 0x7D}}
00195a60: 00220821 addu r1,r1,r2
+
  00195a44: 2c420003 sltiu r2,r2,0x0003          |{{f/std|Check if used weapon ID is between 0x7D and 0x7F (Ball)}}
  00195a64: 90223abe lbu r2,0x3abe(r1) Load Weapon's Element
+
  00195a48: 10400009 beq r2,r0,0x00195a70        {{f/Cond|If Used Weapon is a Ball}}
00195a68: 080656a0 j 0x 00195a80
+
  00195a4c: 34020189 ori r2,r0,0x0189                |{{f/std|Set Ability ID to 0x189}}
  00195a6c: a2020010 sb r2,0x0010(r16) Store Ability's Element
+
00195a50: a6020002 sh r2,0x0002(r16)        {{f/Cond|E  }}    | {{f/store|Store Ability ID in AI used ability Data 0x02 (Ability ID)}}
  00195a70: 96020e14 lhu r2,0x0e14(r16) Load Chosen Throw ID?
+
  00195a54: 001110c0 sll r2,r17,0x03                  |{{f/std|Used weapon ID * 8}}
  00195a74: 92030e16 lbu r3,0x0e16(r16) Load Chosen Weapon ID?
+
  00195a58: a2110006 sb r17,0x0006(r16)               |{{f/store|Store Used Weapon ID as item considered}}
  00195a78: a6020002 sh r2,0x0002(r16) Store Ability ID = Chosen Throw ID?
+
  00195a5c: 3c018006 lui r1,0x8006                    |
  00195a7c: a2030006 sb r3,0x0006(r16) Store Item Considered = Chosen Weapon ID?
+
00195a60: 00220821 addu r1,r1,r2                   |{{f/std|0x80060000 + Item offset (8 bytes per item)}}
  00195a80: 9242003a lbu r2,0x003a(r18) Load Unit's Move
+
  00195a64: 90223abe lbu r2,0x3abe(r1)               |{{f/load|Load Weapon Element (0x80063ab8 - 0x06)}}
  00195a84: 86110002 lh r17,0x0002(r16) Load Ability ID
+
  00195a68: 080656a0 j 0x00195a80                    {{f/jump|Jump - Avoid normal weapon section}}
  00195a88: 08065700 j 0x 00195c00
+
  00195a6c: a2020010 sb r2,0x0010(r16)               |
  00195a8c: a2020004 sb r2,0x0004(r16) Store Ability Range = Move
+
                                                {{f/Cond|Else - Not a Shuriken nor a ball}}
 
+
  00195a70: 96020e14 lhu r2,0x0e14(r16)               |{{f/load|Load chosen Throw ability ID}}
*Jump*
+
  00195a74: 92030e16 lbu r3,0x0e16(r16)               |{{f/load|Load chosen Weapon ID}}
  00195a90: 92020e2e lbu r2,0x0e2e(r16) Load ?
+
  00195a78: a6020002 sh r2,0x0002(r16)               |{{f/store|Store Ability ID in AI used ability data 0x02}}
00195a94: 00000000 nop
+
  00195a7c: a2030006 sb r3,0x0006(r16)                |{{f/store|Store Weapon ID in AI used ability}}
  00195a98: 16a2000e bne r21,r2,0x 00195ad4 Branch if ? != Unit's ID
+
  00195a80: 9242003a lbu r2,0x003a(r18)       |{{f/load|Load unit's move}}
  00195a9c: 34020064 ori r2,r0,0x0064 r2 = 100
+
  00195a84: 86110002 lh r17,0x0002(r16)      |{{f/load|Load Ability ID (from AI data) in r17}}
00195aa0: 8e0317f8 lw r3,0x17f8(r16) Load Target's? Pointer
+
00195a88: 08065700 j 0x00195c00            {{f/jump|Jump to default section}}
  00195aa4: 00000000 nop
+
  00195a8c: a2020004 sb r2,0x0004(r16)       |{{f/store|Store Unit's move as Ability range}}
00195aa8: 90640039 lbu r4,0x0039(r3) Load Target's? CT
+
   
  00195aac: 90630038 lbu r3,0x0038(r3) Load Target's? SP
+
    {{f/sec|----Jump ----}}
00195ab0: 00441023 subu r2,r2,r4 r2 = 100 - CT
+
00195a90: 92020e2e lbu r2,0x0e2e(r16)      |{{f/load|Load acting unit ID}}
00195ab4: 0043001a div r2,r3 (100 - CT) / SP
+
  00195a94: 00000000 nop                     |
00195ab8: 00001012 mflo r2 r2 = (100 - CT) / SP
+
  00195a98: 16a2000e bne r21,r2,0x00195ad4    {{f/Cond|<nowiki>If Acting unit ID = Unit ID (AI data 0xe2e Vs ID from AI move list)</nowiki>}}
  00195abc: 00000000 nop
+
  00195a9c: 34020064 ori r2,r0,0x0064            |{{f/std|100}}
  00195ac0: 00021fc2 srl r3,r2,0x1f
+
  00195aa0: 8e0317f8 lw r3,0x17f8(r16)           |{{f/adr|Load acting unit data pointer}}
  00195ac4: 00431021 addu r2,r2,r3
+
  00195aa4: 00000000 nop                          |
00195ac8: 00021043 sra r2,r2,0x01 ((100 - CT) / SP) / 2
+
00195aa8: 90640039 lbu r4,0x0039(r3)           |{{f/load|Load Acting unit CT}}
  00195acc: 080656d7 j 0x 00195b5c
+
  00195aac: 90630038 lbu r3,0x0038(r3)            |{{f/load|Load Acting unit Speed}}
00195ad0: a2020001 sb r2,0x0001(r16) Store CT? = ((100 - CT) / SP) / 2
+
00195ab0: 00441023 subu r2,r2,r4                |{{f/std|100 - Acting unit CT}}
  00195ad4: 92450039 lbu r5,0x0039(r18) Load Unit's CT
+
  00195ab4: 0043001a div r2,r3                   |{{f/std|(100-CT)/Speed}}
  00195ad8: 00000000 nop
+
  00195ab8: 00001012 mflo r2                      |
00195adc: 2ca20065 sltiu r2,r5,0x0065
+
00195abc: 00000000 nop                          |
00195ae0: 14400005 bne r2,r0,0x 00195af8 Branch if CT < 101
+
00195ac0: 00021fc2 srl r3,r2,0x1f              |
  00195ae4: 34040064 ori r4,r0,0x0064 r4 = 100
+
  00195ac4: 00431021 addu r2,r2,r3                |{{f/std|rounded up if needed}}
  00195ae8: a2000001 sb r0,0x0001(r16) Store CT? = 0
+
00195ac8: 00021043 sra r2,r2,0x01              |{{f/std|((100 - CT) / Speed) / 2}}
  00195aec: 92420039 lbu r2,0x0039(r18) Load Unit's CT
+
  00195acc: 080656d7 j 0x00195b5c                |
  00195af0: 080656cb j 0x 00195b2c
+
  00195ad0: a2020001 sb r2,0x0001(r16)            |{{f/store|Store (100-CT/Speed)/2 in AI used Ability CT}}
  00195af4: 2444ff9c addiu r4,r2,0xff9c CT - 100
+
                                            {{f/Cond|Else : Unit is not acting unit (?)}}
00195af8: 92430038 lbu r3,0x0038(r18) Load Unit's SP
+
  00195ad4: 92450039 lbu r5,0x0039(r18)          |{{f/load|Unit CT (ID from Move list)}}
  00195afc: 00851023 subu r2,r4,r5 100 - CT
+
  00195ad8: 00000000 nop                         |
  00195b00: 0043001a div r2,r3 (100 - CT) / SP
+
  00195adc: 2ca20065 sltiu r2,r5,0x0065          |
  00195b04: 00001012 mflo r2 r2 = (100 - CT) / SP
+
  00195ae0: 14400005 bne r2,r0,0x00195af8        {{f/Cond|If unit CT > 100}}
  00195b08: 00000000 nop
+
  00195ae4: 34040064 ori r4,r0,0x0064            |{{f/std|100}}
00195b0c: a2020001 sb r2,0x0001(r16) Store CT? = (100 - CT) / SP
+
  00195ae8: a2000001 sb r0,0x0001(r16)                |{{f/store|Nullify AI used Ability CT}}
  00195b10: 92430039 lbu r3,0x0039(r18) Load Unit's CT
+
  00195aec: 92420039 lbu r2,0x0039(r18)              |{{f/load|Load unit's CT}}
  00195b14: 92420038 lbu r2,0x0038(r18) Load Unit's SP
+
  00195af0: 080656cb j 0x00195b2c                    {{f/jump|Jump after the other CT section}}
00195b18: 00832023 subu r4,r4,r3 100 - CT
+
  00195af4: 2444ff9c addiu r4,r2,-0x0064              |{{f/std|<nowiki>r4 = Unit CT - 100</nowiki>}}
  00195b1c: 0082001a div r4,r2 (100 - CT) / SP
+
                                                {{f/Cond|Else CT < 100}}
  00195b20: 00001810 mfhi r3 r3 = (100 - CT) / SP
+
  00195af8: 92430038 lbu r3,0x0038(r18)               |{{f/load|Load unit's speed}}
  00195b24: 00000000 nop
+
  00195afc: 00851023 subu r2,r4,r5                    |{{f/std|100 - CT}}
00195b28: 00432023 subu r4,r2,r3 SP - (100 - CT) / SP
+
  00195b00: 0043001a div r2,r3                        |{{f/std|(100-CT)/Speed}} {{f/std|Nb of turn before acting ?}}
  00195b2c: 34020064 ori r2,r0,0x0064 r2 = 100
+
  00195b04: 00001012 mflo r2                         |
  00195b30: 92430038 lbu r3,0x0038(r18) Load SP
+
  00195b08: 00000000 nop                              |
  00195b34: 00441023 subu r2,r2,r4 100 - (SP - (100 - CT) / SP)
+
  00195b0c: a2020001 sb r2,0x0001(r16)               |{{f/store|Store (100-CT)/Speed As Ability CT}}
  00195b38: 0043001a div r2,r3 (100 - (SP - (100 - CT) / SP)) / SP
+
  00195b10: 92430039 lbu r3,0x0039(r18)              |{{f/load|Unit's CT}}
  00195b3c: 00001012 mflo r2 r2 = "
+
  00195b14: 92420038 lbu r2,0x0038(r18)              |{{f/load|Unit's Speed}}
  00195b40: 00000000 nop
+
  00195b18: 00832023 subu r4,r4,r3                    |{{f/std|100 - CT}}
  00195b44: 00021fc2 srl r3,r2,0x1f
+
  00195b1c: 0082001a div r4,r2                        |{{f/std|(100-CT)/Speed}} {{f/std|Nb of turn before acting ?}}
  00195b48: 00431021 addu r2,r2,r3
+
00195b20: 00001810 mfhi r3                          |{{f/std|remainder }}
  00195b4c: 92030001 lbu r3,0x0001(r16) Load CT?
+
00195b24: 00000000 nop                              |
  00195b50: 00021043 sra r2,r2,0x01 ((100 - (SP - (100 - CT) / SP)) / SP) / 2
+
00195b28: 00432023 subu r4,r2,r3                    |{{f/std|Speed - Remainder}} {{f/std|CT above 100 when acting ? }}
  00195b54: 00621821 addu r3,r3,r2 CT? + "
+
  00195b2c: 34020064 ori r2,r0,0x0064                |{{f/std|100}}
  00195b58: a2030001 sb r3,0x0001(r16) Store new CT?
+
  00195b30: 92430038 lbu r3,0x0038(r18)               |{{f/load|Unit's speed}}
  00195b5c: 16200003 bne r17,r0,0x 00195b6c Branch if Ability ID != 0
+
  00195b34: 00441023 subu r2,r2,r4                    |{{f/std|100 * Extra CT}} {{f/std|Remaining CT before next turn}}
  00195b60: 2622fe76 addiu r2,r17,0xfe76 r2 = Ability ID - 0x18a (Level Jump 2)
+
  00195b38: 0043001a div r2,r3                        |{{f/std|Remaing CT / Speed}}
  00195b64: 080656df j 0x 00195b7c
+
  00195b3c: 00001012 mflo r2                         |
  00195b68: 34020001 ori r2,r0,0x0001 r2 = 1
+
  00195b40: 00000000 nop                             |
00195b6c: 00021040 sll r2,r2,0x01 ID * 2
+
  00195b44: 00021fc2 srl r3,r2,0x1f                  |
  00195b70: 3c018006 lui r1,0x8006
+
  00195b48: 00431021 addu r2,r2,r3                    |{{f/std|rounded up  if needed}}
00195b74: 00220821 addu r1,r1,r2
+
  00195b4c: 92030001 lbu r3,0x0001(r16)               |{{f/load|Load Nb of turn before acting}}
00195b78: 9022102c lbu r2,0x102c(r1) Load Jump's Range
+
  00195b50: 00021043 sra r2,r2,0x01                  |
  00195b7c: 00000000 nop
+
  00195b54: 00621821 addu r3,r3,r2                    |{{f/std|Nb of turns before second turn ? }}
  00195b80: a2020004 sb r2,0x0004(r16) Store Range = Jump's Range
+
  00195b58: a2030001 sb r3,0x0001(r16)                |{{f/store|Store Nb of turns before second turn as AI used Ability CT}}
  00195b84: 02151021 addu r2,r16,r21
+
  00195b5c: 16200003 bne r17,r0,0x00195b6c    {{f/Cond|<nowiki>If Ability ID = 0x00 ?</nowiki>}}
  00195b88: 9042198c lbu r2,0x198c(r2) Load Unit's Battle ID
+
  00195b60: 2622fe76 addiu r2,r17,-0x018a    |{{f/std|<nowiki>r2 = Ability ID - 0x18A (jump2 = 0)</nowiki>}}
  00195b8c: 00000000 nop
+
  00195b64: 080656df j 0x00195b7c                {{f/jump|Jump and force range to 0x01}}
00195b90: 000210c0 sll r2,r2,0x03 ID * 8
+
  00195b68: 34020001 ori r2,r0,0x0001            |{{f/std|<nowiki>r2 = 0x01</nowiki>}}
  00195b94: 24421778 addiu r2,r2,0x1778
+
                                            {{f/Cond|Else : Ability ID <> 0x00}}
  00195b98: 0806565d j 0x 00195974
+
  00195b6c: 00021040 sll r2,r2,0x01              |{{f/std|Jump Ability ID*2}}
  00195b9c: 02021821 addu r3,r16,r2 r3 = Unit's Weapon? Attack Data
+
  00195b70: 3c018006 lui r1,0x8006                |
 
+
  00195b74: 00220821 addu r1,r1,r2                |
  *Charge*
+
  00195b78: 9022102c lbu r2,0x102c(r1)           |{{f/load|Load Jump Ability Range}}
00195ba0: 2622fe6a addiu r2,r17,0xfe6a r2 = Ability ID - 0x196 (Charge + 1)
+
  00195b7c: 00000000 nop                     |{{f/std|}}
  00195ba4: 00021040 sll r2,r2,0x01 ID * 2
+
  00195b80: a2020004 sb r2,0x0004(r16)        |{{f/store|Store Range}}
  00195ba8: 3c018006 lui r1,0x8006
+
  00195b84: 02151021 addu r2,r16,r21          |{{f/adr|0x8019f3c4 + Unit ID}}
  00195bac: 00220821 addu r1,r1,r2
+
  00195b88: 9042198c lbu r2,0x198c(r2)       |{{f/load|Load Unit's Battle ID (0xff if not used)}}
  00195bb0: 90221044 lbu r2,0x1044(r1) Load Charge's CT
+
00195b8c: 00000000 nop                     |
  00195bb4: 08065651 j 0x 00195944
+
  00195b90: 000210c0 sll r2,r2,0x03          |{{f/std|Unit ID*8}}
00195bb8: a2020001 sb r2,0x0001(r16) Store CT = Charge's CT
+
  00195b94: 24421778 addiu r2,r2,0x1778      |
 
+
  00195b98: 0806565d j 0x00195974            {{f/jump|Jump at the end of the default attack section}}
  *Arithmeticks*
+
  00195b9c: 02021821 addu r3,r16,r2           |{{f/adr|Unit Weapon flag (in AI table) 0x8019f3c4 + 0x1778 + Unit battle ID * 8}}
00195bbc: 340300ff ori r3,r0,0x00ff r3 = FF
+
   
  00195bc0: 34040004 ori r4,r0,0x0004 Counter = 4
+
    {{f/sec|---- Charge ----}}
  00195bc4: 26020004 addiu r2,r16,0x0004
+
00195ba0: 2622fe6a addiu r2,r17,-0x0196    |{{f/std|<nowiki>Ability ID - 0x196 (Charge +1 = 0)</nowiki>}}
  00195bc8: a0430007 sb r3,0x0007(r2) Store Status Infliction = FF
+
00195ba4: 00021040 sll r2,r2,0x01           |{{f/std|Charge ID * 2}}
00195bcc: 2484ffff addiu r4,r4,0xffff Counter --
+
  00195ba8: 3c018006 lui r1,0x8006           |
  00195bd0: 0481fffd bgez r4,0x 00195bc8 Branch if Counter >= 0
+
  00195bac: 00220821 addu r1,r1,r2           |
00195bd4: 2442ffff addiu r2,r2,0xffff Pointer --
+
  00195bb0: 90221044 lbu r2,0x1044(r1)       |{{f/load|Load Charge's ability CT}}
00195bd8: 340200fc ori r2,r0,0x00fc r2 = FC
+
  00195bb4: 08065651 j 0x00195944            {{f/jump|Jump to Attack section}}
  00195bdc: a202000c sb r2,0x000c(r16) Store AI Behavior = all but Target E/A
+
  00195bb8: a2020001 sb r2,0x0001(r16)       |{{f/store|Store Charge's CT as AI used ability CT }}
  00195be0: 92820003 lbu r2,0x0003(r20) Load Usage Type?
+
   
  00195be4: 00000000 nop
+
    {{f/sec|---- Arithmeticks ----}}
00195be8: a202000f sb r2,0x000f(r16) Store Usage Type?
+
  00195bbc: 340300ff ori r3,r0,0x00ff        |
  00195bec: 8e02000c lw r2,0x000c(r16) Load AI Behavior Flags
+
  00195bc0: 34040004 ori r4,r0,0x0004        |{{f/std|Counter set for 5 loops}}
  00195bf0: 00000000 nop
+
  00195bc4: 26020004 addiu r2,r16,0x0004      |{{f/adr|Pointer to AI used ability 5th set of status infliction }}
  00195bf4: 34428000 ori r2,r2,0x8000 Enable Ignore Range?
+
                                            {{f/bloop|LOOP - Enables all status infliction flags}}
  00195bf8: 08065759 j 0x 00195d64
+
  00195bc8: a0430007 sb r3,0x0007(r2)             |{{f/store|Store 0xff in AI used ability Status infliction (all statuses ON)}}
  00195bfc: ae02000c sw r2,0x000c(r16) Store new AI Behavior Flags
+
  00195bcc: 2484ffff addiu r4,r4,-0x0001          |{{f/std|counter -1}}
 
+
  00195bd0: 0481fffd bgez r4,0x00195bc8      {{f/eloop|<nowiki>Loop while counter >= 0</nowiki>}}
  *Default*
+
  00195bd4: 2442ffff addiu r2,r2,-0x0001          |{{f/std|pointer -1}}
  00195c00: 2604000c addiu r4,r16,0x000c r4 = Pointer to AI Behavior Flags
+
  00195bd8: 340200fc ori r2,r0,0x00fc            |
  00195c04: 001198c0 sll r19,r17,0x03 r19 = Ability ID * 8
+
  00195bdc: a202000c sb r2,0x000c(r16)       |{{f/store|Store 0xfc in AI behavior 1 }} {{f/std|(everything but target allies / enemies)}}
  00195c08: 3c058006 lui r5,0x8006
+
  00195be0: 92820003 lbu r2,0x0003(r20)       |{{f/load|Load Ability usage type (from AI moves list)}} {{f/std| 801a02b4 - 0x03}}
  00195c0c: 24a5ebf4 addiu r5,r5,0xebf4
+
  00195be4: 00000000 nop                     |
00195c10: 02652821 addu r5,r19,r5 r5 = Ability's AI Behavior Flags Pointer
+
  00195be8: a202000f sb r2,0x000f(r16)        |{{f/store|Store usage as AI used ability extra behaviors flags}}
  00195c14: 0c066ac2 jal 0x 0019ab08 Transfer Halfword Values
+
  00195bec: 8e02000c lw r2,0x000c(r16)        |{{f/load|Load All AI behaviors flags}}
  00195c18: 34060004 ori r6,r0,0x0004 Limit = 4
+
  00195bf0: 00000000 nop                      |
  00195c1c: 26e2ffff addiu r2,r23,0xffff r2 = Action Menu - 1
+
  00195bf4: 34428000 ori r2,r2,0x8000        |{{f/std|Enable Ignore range}}
  00195c20: 2c420002 sltiu r2,r2,0x0002
+
  00195bf8: 08065759 j 0x00195d64            {{f/jump|Jump to }} {{f/jump|!!END!!}}
  00195c24: 10400005 beq r2,r0,0x 00195c3c Branch if Action Menu != Item/Weapon Inv.
+
  00195bfc: ae02000c sw r2,0x000c(r16)        |{{f/store|Update AI behavior flags (ignore range)}}
  00195c28: 3c030040 lui r3,0x0040
+
   
00195c2c: 8e02000c lw r2,0x000c(r16) Load AI Behavior Flags
+
    {{f/sec|----Default (direct) and  Weapon Katana Item----}}
  00195c30: 00000000 nop
+
  00195c00: 2604000c addiu r4,r16,0x000c      |{{f/adr|Pointer to AI used ability behaviors flags 1}}
  00195c34: 00431025 or r2,r2,r3 Enable Direct Attack
+
  00195c04: 001198c0 sll r19,r17,0x03        |{{f/std|Ability ID * 8}}
  00195c38: ae02000c sw r2,0x000c(r16) Store new AI Behavior Flags
+
  00195c08: 3c058006 lui r5,0x8006            |
  00195c3c: 92820003 lbu r2,0x0003(r20) Load Usage Type?
+
  00195c0c: 24a5ebf4 addiu r5,r5,0xebf4      |
00195c40: 00000000 nop
+
  00195c10: 02652821 addu r5,r19,r5          |{{f/adr|Pointer to Ability behaviors flags 1}} {{f/std|0x8006ebf0 - 0x04 + Ability offset (8 bytes)}}
  00195c44: a202000f sb r2,0x000f(r16) Store Usage Type?
+
  00195c14: 0c066ac2 jal 0x0019ab08          |{{f/jal|Transfer_Halfword_Values|Transfer_Halfword_Values}} {{f/std|Transfer AI behavior flags 1,2,3,4 from SCUS Ability Table to AI used Ability Behaviors flags}}
  00195c48: 2a220170 slti r2,r17,0x0170
+
  00195c18: 34060004 ori r6,r0,0x0004        |{{f/std|Limit for routine }}
  00195c4c: 1040002f beq r2,r0,0x 00195d0c Branch if Ability is a Normal Ability
+
  00195c1c: 26e2ffff addiu r2,r23,-0x0001    |{{f/std|Action menu -0x1}}
  00195c50: 02711023 subu r2,r19,r17 r2 = Ability ID * 7
+
  00195c20: 2c420002 sltiu r2,r2,0x0002      |{{f/std|Check for Item or Weapon inventory}}
  00195c54: 00021040 sll r2,r2,0x01 ID * 14
+
  00195c24: 10400005 beq r2,r0,0x00195c3c    {{f/Cond|If Action menu is Item or weapon inventory}}
  00195c58: 3c038006 lui r3,0x8006
+
  00195c28: 3c030040 lui r3,0x0040                |
  00195c5c: 2463fbf0 addiu r3,r3,0xfbf0
+
  00195c2c: 8e02000c lw r2,0x000c(r16)            |{{f/load|Load All AI used ability behaviors flags}}
00195c60: 00431821 addu r3,r2,r3
+
  00195c30: 00000000 nop                          |
  00195c64: 9062000c lbu r2,0x000c(r3) Load Ability's CT
+
  00195c34: 00431025 or r2,r2,r3                 |{{f/std|Enable Direct attack flag}}
  00195c68: 9076000b lbu r22,0x000b(r3) Load Ability's Inflict Status
+
  00195c38: ae02000c sw r2,0x000c(r16)            |{{f/store|Store updated behavior flags}}
  00195c6c: a2020001 sb r2,0x0001(r16) Store CT = Ability's CT
+
  00195c3c: 92820003 lbu r2,0x0003(r20)       |{{f/load|Load Usage flags from AI moves list}}
  00195c70: 90620007 lbu r2,0x0007(r3) Load Ability's Element
+
  00195c40: 00000000 nop                     |
  00195c74: 00000000 nop
+
  00195c44: a202000f sb r2,0x000f(r16)       |{{f/store|Store Usage flags as extra behavior flags}}
  00195c78: a2020010 sb r2,0x0010(r16) Store Ability's Element
+
  00195c48: 2a220170 slti r2,r17,0x0170      |{{f/std|Check if Ability has a second table (Before potion)}}
  00195c7c: 9062000d lbu r2,0x000d(r3) Load Ability's MP Cost
+
  00195c4c: 1040002f beq r2,r0,0x00195d0c    {{f/Cond|If Ability has a second table}}
  00195c80: 00000000 nop
+
  00195c50: 02711023 subu r2,r19,r17              |{{f/std|Ability ID*7}}
00195c84: a2020011 sb r2,0x0011(r16) Store Ability's MP Cost
+
  00195c54: 00021040 sll r2,r2,0x01               |{{f/std|ID*14}}
00195c88: 92420090 lbu r2,0x0090(r18) Load Unit's Support set 2
+
00195c58: 3c038006 lui r3,0x8006                |
  00195c8c: 00000000 nop
+
00195c5c: 2463fbf0 addiu r3,r3,0xfbf0          |
  00195c90: 30420080 andi r2,r2,0x0080
+
00195c60: 00431821 addu r3,r2,r3                |{{f/adr|Ability Table 2 pointer (SCUS)}} {{f/std|8006fbf0 + Ability offset (14 bytes)}}
  00195c94: 10400005 beq r2,r0,0x 00195cac Branch if Unit doesn't have Half of MP
+
00195c64: 9062000c lbu r2,0x000c(r3)            |{{f/load|Load Ability CT}}
  00195c98: 00000000 nop
+
00195c68: 9076000b lbu r22,0x000b(r3)          |{{f/load|Load Ability Inflict status}}
  00195c9c: 92020011 lbu r2,0x0011(r16) Load MP Cost
+
00195c6c: a2020001 sb r2,0x0001(r16)            |{{f/store|Store CT in AI used ability data}}
00195ca0: 00000000 nop
+
00195c70: 90620007 lbu r2,0x0007(r3)            |{{f/load|Load Ability Element}}
00195ca4: 00021042 srl r2,r2,0x01 MP Cost / 2
+
00195c74: 00000000 nop                          |
00195ca8: a2020011 sb r2,0x0011(r16) Store new MP Cost
+
00195c78: a2020010 sb r2,0x0010(r16)            |{{f/store|Store ability element in AI data}}
  00195cac: 90620003 lbu r2,0x0003(r3) Load Ability's Flags
+
00195c7c: 9062000d lbu r2,0x000d(r3)            |{{f/load|Load Ability MP cost}}
  00195cb0: 00000000 nop
+
00195c80: 00000000 nop                          |
  00195cb4: 30420020 andi r2,r2,0x0020
+
00195c84: a2020011 sb r2,0x0011(r16)            |{{f/store|Store MP cost in AI data}}
  00195cb8: 10400009 beq r2,r0,0x 00195ce0 Branch if Ability isn't a Ranged Weapon
+
00195c88: 92420090 lbu r2,0x0090(r18)          |{{f/load|Load Unit 2nd set of Support }}
  00195cbc: 02151021 addu r2,r16,r21
+
00195c8c: 00000000 nop                          |
  00195cc0: 9042198c lbu r2,0x198c(r2) Load Unit's Battle ID
+
00195c90: 30420080 andi r2,r2,0x0080            |{{f/std|Check for Half of MP}}
  00195cc4: 00000000 nop
+
00195c94: 10400005 beq r2,r0,0x00195cac        {{f/Cond|If Unit has Half of MP}}
00195cc8: 000210c0 sll r2,r2,0x03 ID * 8
+
00195c98: 00000000 nop                              |{{f/std|}}
  00195ccc: 02021021 addu r2,r16,r2
+
00195c9c: 92020011 lbu r2,0x0011(r16)              |{{f/load|Load MP cost from AI data}}
  00195cd0: 90421778 lbu r2,0x1778(r2) Load Unit's Weapon Range
+
00195ca0: 00000000 nop                              |
  00195cd4: a2000005 sb r0,0x0005(r16) Store AoE = 0
+
00195ca4: 00021042 srl r2,r2,0x01                  |{{f/std|MP Cost/2}}
00195cd8: 0806573e j 0x 00195cf8
+
00195ca8: a2020011 sb r2,0x0011(r16)                |{{f/store|Store updated MP cost}}
  00195cdc: a2020004 sb r2,0x0004(r16) Store Ability's Range = Weapon Range
+
00195cac: 90620003 lbu r2,0x0003(r3)            |{{f/load|Load Ability Flags 1}}
  00195ce0: 90620000 lbu r2,0x0000(r3) Load Ability's Range
+
00195cb0: 00000000 nop                          |
  00195ce4: 00000000 nop
+
00195cb4: 30420020 andi r2,r2,0x0020            |{{f/std|check for Weapon range}}
  00195ce8: a2020004 sb r2,0x0004(r16) Store Range = Ability's Range
+
00195cb8: 10400009 beq r2,r0,0x00195ce0        {{f/Cond|If Ability is weapon ranged}}
  00195cec: 90620001 lbu r2,0x0001(r3) Load Ability's AoE
+
00195cbc: 02151021 addu r2,r16,r21                  |{{f/std|0x8019f3c4 + Unit ID}}
  00195cf0: 00000000 nop
+
00195cc0: 9042198c lbu r2,0x198c(r2)                |{{f/load|Load Unit's battle ID}} {{f/std| 801a0d50 + Unit offset}}
  00195cf4: a2020005 sb r2,0x0005(r16) Store AoE = Ability's AoE
+
00195cc4: 00000000 nop                              |
  00195cf8: 90620005 lbu r2,0x0005(r3) Load Ability's Flags 3
+
00195cc8: 000210c0 sll r2,r2,0x03                  |{{f/std|Unit ID*8}}
  00195cfc: 00000000 nop
+
00195ccc: 02021021 addu r2,r16,r2                  |
  00195d00: 30420004 andi r2,r2,0x0004
+
00195cd0: 90421778 lbu r2,0x1778(r2)                |{{f/load|Load Weapon range from  AI Weapon data}} {{f/std| 801a0b3c + Unit offset (8 bytes)}}
  00195d04: 1440000f bne r2,r0,0x 00195d44 Branch if Ability has Persevere
+
00195cd4: a2000005 sb r0,0x0005(r16)                |{{f/store|Nullify AoE in AI data}}
  00195d08: 26040007 addiu r4,r16,0x0007 r4 = Pointer to ?
+
00195cd8: 0806573e j 0x00195cf8                    {{f/jump|Avoid the not weapon ranged section}}
  00195d0c: 92430092 lbu r3,0x0092(r18) Load Unit's Support set 4
+
00195cdc: a2020004 sb r2,0x0004(r16)                |{{f/store|Store Weapon range }}
  00195d10: 00000000 nop
+
                                                  {{f/Cond|Else : Ability is not weapon ranged}}                                         
00195d14: 30620080 andi r2,r3,0x0080 (supposed to be 0x08, Short Charge)
+
00195ce0: 90620000 lbu r2,0x0000(r3)                |{{f/load|Load Ability range (SCUS)}}
  00195d18: 10400006 beq r2,r0,0x 00195d34 Branch if Unit doesn't have Monster Skill
+
00195ce4: 00000000 nop                              |
  00195d1c: 30620040 andi r2,r3,0x0040
+
00195ce8: a2020004 sb r2,0x0004(r16)                |{{f/store|Store ability range in AI data}}
00195d20: 92020001 lbu r2,0x0001(r16) Load CT
+
00195cec: 90620001 lbu r2,0x0001(r3)                |{{f/load|Load AoE}}
  00195d24: 00000000 nop                         (supposed to add +1 to CT before dividing)
+
00195cf0: 00000000 nop                              |
  00195d28: 00021042 srl r2,r2,0x01 CT / 2
+
00195cf4: a2020005 sb r2,0x0005(r16)                |{{f/store|Store AoE}}
00195d2c: 08065750 j 0x 00195d40
+
00195cf8: 90620005 lbu r2,0x0005(r3)            |{{f/load|Load Flags 3}}
00195d30: a2020001 sb r2,0x0001(r16) Store new CT
+
00195cfc: 00000000 nop                          |
  00195d34: 10400003 beq r2,r0,0x 00195d44 Branch if Unit doesn't have Defend
+
00195d00: 30420004 andi r2,r2,0x0004            |{{f/std|Check for persevere}}
  00195d38: 26040007 addiu r4,r16,0x0007 (supposed to be 0x04 Non-Charge)
+
00195d04: 1440000f bne r2,r0,0x00195d44        {{f/Cond|If persevere flag is OFF}}
  00195d3c: a2000001 sb r0,0x0001(r16) CT = 0
+
00195d08: 26040007 addiu r4,r16,0x0007          |{{f/adr|pointer to AI used ability status infliction 1}}
00195d40: 26040007 addiu r4,r16,0x0007 r4 = Pointer to Inflicted Statuses
+
00195d0c: 92430092 lbu r3,0x0092(r18)      {{f/Cond|E  }}    | {{f/load|Load Unit Support 4}}
  00195d44: 00162840 sll r5,r22,0x01 Inflict Status ID * 2
+
00195d10: 00000000 nop                              |{{f/std|}}
00195d48: 00b62821 addu r5,r5,r22 ID * 3
+
00195d14: 30620080 andi r2,r3,0x0080                |{{f/std|Check for Monster skill}} / BUG : Should be 0x08 (short charge)
00195d4c: 00052840 sll r5,r5,0x01 ID * 6
+
00195d18: 10400006 beq r2,r0,0x00195d34            {{f/Cond|If Unit has Monster skill (Instead of short charge)}}
00195d50: 3c028006 lui r2,0x8006
+
00195d1c: 30620040 andi r2,r3,0x0040                |{{f/std|Check for Defend}} / BUG : Should be 0x04 (Non-Charge)
00195d54: 24423fc5 addiu r2,r2,0x3fc5
+
00195d20: 92020001 lbu r2,0x0001(r16)                  |{{f/load|Load AI used Ability CT}}
00195d58: 00a22821 addu r5,r5,r2 r5 = Pointer to Inflicted Statuses
+
00195d24: 00000000 nop                                  |
  00195d5c: 0c066ad2 jal 0x 0019ab48 Transfer Byte Values
+
00195d28: 00021042 srl r2,r2,0x01                      |{{f/std|CT/2}}
  00195d60: 34060005 ori r6,r0,0x0005 Limit = 5
+
00195d2c: 08065750 j 0x00195d40                        {{f/jump|Avoid the intended Non-Charge section }}
  00195d64: 8fbf0030 lw r31,0x0030(r29)
+
00195d30: a2020001 sb r2,0x0001(r16)                    |{{f/store|Store New CT}}
 +
00195d34: 10400003 beq r2,r0,0x00195d44            {{f/Cond|Else : if Unit Has Defend (instead of Non-Charge)}}
 +
00195d38: 26040007 addiu r4,r16,0x0007              |{{f/adr|pointer to AI used ability status infliction 1}}
 +
00195d3c: a2000001 sb r0,0x0001(r16)                    |{{f/store|Nullify Ability CT}}
 +
00195d40: 26040007 addiu r4,r16,0x0007                  |{{f/adr|pointer to AI used ability status infliction 1}}
 +
00195d44: 00162840 sll r5,r22,0x01          |{{f/std|Inflict status ID * 2}} {{f/std|(from item or ability)}}
 +
00195d48: 00b62821 addu r5,r5,r22          |{{f/std|ID*3}}
 +
00195d4c: 00052840 sll r5,r5,0x01          |{{f/std|Status ID * 6}}
 +
00195d50: 3c028006 lui r2,0x8006            |
 +
00195d54: 24423fc5 addiu r2,r2,0x3fc5      |
 +
00195d58: 00a22821 addu r5,r5,r2            |{{f/adr|Pointer to Inflicted Status ID 1st set of status}}
 +
  00195d5c: 0c066ad2 jal 0x0019ab48          |{{f/jal|Transfer_Byte_Values|Transfer_Byte_Values}} {{f/std|Transfer 5 set of status infliction form SCUS status table to AI used ability data}}
 +
  00195d60: 34060005 ori r6,r0,0x0005         |{{f/std|Limit (5 set of status)}}
 +
  00195d64: 8fbf0030 lw r31,0x0030(r29)       END
 
  00195d68: 8fb7002c lw r23,0x002c(r29)
 
  00195d68: 8fb7002c lw r23,0x002c(r29)
 
  00195d6c: 8fb60028 lw r22,0x0028(r29)
 
  00195d6c: 8fb60028 lw r22,0x0028(r29)
Line 343: Line 356:
 
  00195d8c: 03e00008 jr r31
 
  00195d8c: 03e00008 jr r31
 
  00195d90: 00000000 nop
 
  00195d90: 00000000 nop
 +
=== Notes ===
 +
'''Used AI section'''
 +
  - Fill 0x8019f3c4                {{f/std| 8019f3c4 }}
 +
  - Load data from 0x801a0b3c      {{f/std| 801a0b3c / 8019f3c4 + 0x1778}}
 +
  - Load data from 0x801a02b4      {{f/std| 801a02b4 / 8019f3c4 + 0x0ef0}}
 +
  - Load ID from 0x801a0d50        {{f/std| 801a0d50 / 8019f3c4 + 0x198c}}
 +
  - Load ID from 0x801a0e2e        {{f/std| 801a01f0 / 8019f3c4 + 0x0e2e}}
 +
 +
'''Hard-coded mechanics'''
 +
  - Item invetory : Link between Ability ID and item
 +
  - Katana inventory : Link Between Ability ID and katanas
 +
  - Weapon inventory : shurikens and ball (? to be confirmed)
 +
  - Jump is forced as hostile
 +
  - AoE nullified for Item inventory, default section is ability is weapon ranged, Left to 0x00 for Jump/Charge/Attack
 +
  - Item inventory and weapon inventory direct flag is forced ON
 +
 
 +
'''BUGS '''
 +
  - Throw item is move instead of 4
 +
  - Short CT is not correctly checked (0x80 instead of 0x08)
 +
  - No CT is not correctly checked (0x40 instead of 0x04)
 +
=== Return location ===
 +
'''Battle.bin'''
 +
00194f80: [[Set_AI_ability_considerations_for_all_units_and_self]]
 +
001954c0: [[Set_AI_ability_considerations_for_all_units_and_self]]
 +
001972a8: [[Set_chosen_ability/target_for_AI_status]]
 +
0019745c: [[Set_chosen_ability/target_for_AI_status]]
 +
00197ec8: [[Chose_Move_from_Move_List%3F|Chose_Move_from_Move_List?]]
 +
0019894c: [[Evaluate_Cancel_Status_Ability_(0019881c)]]
 +
00198fb0: [[00198e60_-_00199058]]
 +
00199fac: [[Usable_Ability_Setting/ENTD_AI_Calculations]]

Latest revision as of 20:44, 23 March 2024

AI Ability Data Setting : reset and set some data in 0x8019f3c4 section. Bugs and hard coded things (see notes)
----------------------------------------------------------------------------------------------------------------
Parameters : r4 - Ability data pointer (used to load data)

Returns nothing
----------------------------------------------------------------------------------------
00195878: 27bdffc8 addiu r29,r29,-0x0038    |
0019587c: afb40020 sw r20,0x0020(r29)       |
00195880: 0080a021 addu r20,r4,r0           |r20 = Ability pointer in AI Unit's Move List  801a02b4
00195884: afb00010 sw r16,0x0010(r29)       |
00195888: 3c10801a lui r16,0x801a           |
0019588c: 2610f3c4 addiu r16,r16,-0xc3c     |Start of AI Used/processed Ability Data pointer 0x8019f3c4 - 8019f3c4
00195890: 02002021 addu r4,r16,r0           |
00195894: 34050014 ori r5,r0,0x0014         |Nb of byte to delete in routine below
00195898: afbf0030 sw r31,0x0030(r29)       |
0019589c: afb7002c sw r23,0x002c(r29)       |
001958a0: afb60028 sw r22,0x0028(r29)       |
001958a4: afb50024 sw r21,0x0024(r29)       |
001958a8: afb3001c sw r19,0x001c(r29)       |
001958ac: afb20018 sw r18,0x0018(r29)       |
001958b0: 0c066ade jal 0x0019ab78           |-->Word_Nulling Nullify 5 Words from 0x8019f3c4 to 0x8019f3d7  (Some ability data - see notes)
001958b4: afb10014 sw r17,0x0014(r29)       |
001958b8: 26040020 addiu r4,r16,0x0020      |Calculator Type Ability ID
001958bc: 0c066ade jal 0x0019ab78           |-->Word_Nulling Nullify calculator related data
001958c0: 34050004 ori r5,r0,0x0004         |
001958c4: 92820002 lbu r2,0x0002(r20)       |Load Ability skillset ID
001958c8: 00000000 nop                      |
001958cc: a2020000 sb r2,0x0000(r16)        |Store Skillset ID
001958d0: 96830000 lhu r3,0x0000(r20)       |Byte 00 and 01 (both needed to find Ability ID)
001958d4: 3c048019 lui r4,0x8019            |
001958d8: 248408cc addiu r4,r4,0x08cc       |Start of unit data
001958dc: 306303ff andi r3,r3,0x03ff        |Ability ID mask  (+flag 0x2 of byte 0x00 ?)
001958e0: 00608821 addu r17,r3,r0           |/r17 = Ability ID 
001958e4: 3c01801a lui r1,0x801a            |
001958e8: a423f3c6 sh r3,-0x0c3a(r1)        |Store Ability ID at 0x8019f3c6  0x8019f3c4 - 0x02
001958ec: 96820000 lhu r2,0x0000(r20)       |Byte 00 and 01 (both needed to find Ability ID)
001958f0: 92830002 lbu r3,0x0002(r20)       |Load Ability skillset ID
001958f4: 00021400 sll r2,r2,0x10           |Pass halfword in upper registery
001958f8: 0002ae83 sra r21,r2,0x1a          |/Unit ID (from 0x801a02b4) Right shift destroying low byte and 2nd byte flag 0x1 and 0x2 (keep just Unit ID)
001958fc: 001510c0 sll r2,r21,0x03          |Unit ID * 8
00195900: 00551023 subu r2,r2,r21           |Unit ID * 7
00195904: 00021180 sll r2,r2,0x06           |Unid ID * 0x1c0 
00195908: 3c018006 lui r1,0x8006            |
0019590c: 00230821 addu r1,r1,r3            |0x80060000 + Ability's skillset ID
00195910: 90375cb4 lbu r23,0x5cb4(r1)       |r23 = Ability's Skillset's Action menu
00195914: 00449021 addu r18,r2,r4           |r18 = Unit Battle Data Pointer
00195918: 26e3ffff addiu r3,r23,-0x0001     |
0019591c: 2c62000a sltiu r2,r3,0x000a       |r2 = 0x1 if Action menu is between 0x1 and 0xa    (not default, defend, equip change, unknown nor blank)
00195920: 104000b7 beq r2,r0,0x00195c00     #Branch to   Default section  if the action menu don't have a jump pointer address
00195924: 0000b021 addu r22,r0,r0           |r22 = 0x00 (will be used to store inflicted status in some section)
00195928: 00031080 sll r2,r3,0x02               |Action menu offset (word)
0019592c: 3c018019 lui r1,0x8019                |
00195930: 00220821 addu r1,r1,r2                |
00195934: 8c223d48 lw r2,0x3d48(r1)             |Load Action menu jump Adress (Table details)
00195938: 00000000 nop                          |
0019593c: 00400008 jr r2                        |jump to specific action menu section
00195940: 00000000 nop                          |

    ----Attack / Charge ---- Code jumps backward from charge section after setting CT
00195944: 02151021 addu r2,r16,r21          |8019f3c4 + Unit ID
00195948: 9042198c lbu r2,0x198c(r2)        |Load Unit Battle ID   0x801a0d50
0019594c: 00000000 nop                      |
00195950: 000210c0 sll r2,r2,0x03           |Unit ID * 8
00195954: 24421778 addiu r2,r2,0x1778       |
00195958: 02021821 addu r3,r16,r2           |Unit AI Weapon Attack data pointer  0x801a0b3c + Unit ID *8  
0019595c: 90620000 lbu r2,0x0000(r3)        |Load Unit Attack range
00195960: 00000000 nop                      |
00195964: a2020004 sb r2,0x0004(r16)        |Store attack range in AI used ability data  8019f3c4 - 0x04
00195968: 90620005 lbu r2,0x0005(r3)        |Load unit Attack's element  (weapon elements ? And if dual ?)
0019596c: 00000000 nop                      |
00195970: a2020010 sb r2,0x0010(r16)        |Store Element in AI used ability data
    ----Attack / Charge / Jump---- Code jumps backward from jump section after setting CT and range
00195974: 90620004 lbu r2,0x0004(r3)        |Load Unit's Weapon ID
00195978: 00000000 nop                      |
0019597c: a2020006 sb r2,0x0006(r16)        |Store Weapon ID in AI used ability data (Item considered)  8019f3c4 - 0x06
00195980: 90620001 lbu r2,0x0001(r3)        |Load Ability AI behavior flags 1
00195984: 00000000 nop                      |
00195988: a202000c sb r2,0x000c(r16)        |Store AI behavior flags 1 in AI used abilty data
0019598c: 90620002 lbu r2,0x0002(r3)        |Load Ability AI behavior flags 2
00195990: 00000000 nop                      |
00195994: a202000d sb r2,0x000d(r16)        |Store AI behavior flags 2 in AI used abilty data
00195998: 90620003 lbu r2,0x0003(r3)        |Load Ability AI behavior flags 3
0019599c: 00000000 nop                      |
001959a0: a202000e sb r2,0x000e(r16)        |Store AI behavior flags 3 in AI used abilty data
001959a4: 92820003 lbu r2,0x0003(r20)       |Load Ability AI behavior flags 3 (again)
001959a8: 00000000 nop                      |
001959ac: a202000f sb r2,0x000f(r16)        |Store AI behavior flags 3 in AI used abilty data (tagged as AI4 ? Action menu specific ?)
001959b0: 34020009 ori r2,r0,0x0009         |
001959b4: 16e200eb bne r23,r2,0x00195d64    #If Action menu is Jump  / Else jump to  END
001959b8: 2403fffe addiu r3,r0,-0x0002          |r3 = 0xfffffffe
001959bc: 8e02000c lw r2,0x000c(r16)            |Load AI used ability data AI flags 1
001959c0: 00000000 nop                          |
001959c4: 34420002 ori r2,r2,0x0002             |Enable Target enemy flag (flag 0x02)
001959c8: 00431024 and r2,r2,r3                 |Cancel Target Allies (flag 0x01)
001959cc: 08065759 j 0x00195d64                 >>Jump to  END
001959d0: ae02000c sw r2,0x000c(r16)            |Store AI behavior flags 13 in AI used abilty data 0x0c with Target enemy flag ON

    ----Item inventory ---- 
001959d4: 2622fe90 addiu r2,r17,-0x0170     |Item ID (Ability ID - 0x170 (Potion = 0x00))  Hard coded
001959d8: 00021840 sll r3,r2,0x01           |Item ID * 2
001959dc: 00621821 addu r3,r3,r2            |Item ID * 3
001959e0: 92420091 lbu r2,0x0091(r18)       |Load Unit 3rd Support set
001959e4: 3c018006 lui r1,0x8006            |
001959e8: 00230821 addu r1,r1,r3            |
001959ec: 90363f9a lbu r22,0x3f9a(r1)       |Load Item Inflicted status  0x80063f98 - 0x02 + Item offset
001959f0: 30420008 andi r2,r2,0x0008        |Check for throw item in 3rd set of support
001959f4: 10400004 beq r2,r0,0x00195a08     #If Unit uses throw item
001959f8: 34020001 ori r2,r0,0x0001             |
001959fc: 9242003a lbu r2,0x003a(r18)           |Load Unit's Move stat / BUG : should be 0x4
00195a00: 08065683 j 0x00195a0c                 >>Jump to preserve range value
00195a04: a2020004 sb r2,0x0004(r16)            |Store it as range in AI used ability data
                                            #Else : Unit do not use throw item
00195a08: a2020004 sb r2,0x0004(r16)            |Force range to 0x1 in AI used ability data
00195a0c: a2000005 sb r0,0x0005(r16)        |Nullify AoE 
00195a10: 3c018006 lui r1,0x8006            |
00195a14: 00310821 addu r1,r1,r17           |
00195a18: 90220ea0 lbu r2,0x0ea0(r1)        |Load Ability's used item  (0x80061010 +for potion(ID is 0x170))
00195a1c: 08065700 j 0x00195c00             >>Jump to default section
00195a20: a2020006 sb r2,0x0006(r16)        |Store used item ID in AI used ability data (as item considered)

    ----Katana inventory ---- 
00195a24: 2622ffda addiu r2,r17,-0x0026     |r2 = Katana ID (Ability ID - 0x26) Hardcoded - 0x26 if the gap between first draw out Ability ID and first katana ID
00195a28: 08065700 j 0x00195c00             >>Jump to default section
00195a2c: a2020006 sb r2,0x0006(r16)        |Store used katana ID in AI used ability data (as item considered)

    ----Weapon inventory ----  For throw r17 is Threw Weapon ID ? 
00195a30: 2622ff86 addiu r2,r17,0xff86      |Used Weapon ID - 0x7A
00195a34: 2c420003 sltiu r2,r2,0x0003       |Check if Weapon ID is between 0x7A and 0x7C (shurikens)
00195a38: 14400005 bne r2,r0,0x00195a50     #If Not a Shuriken
00195a3c: 3402017e ori r2,r0,0x017e         |r2 = 0x17e (Throw shuriken ability ID)
00195a40: 2622ff83 addiu r2,r17,0xff83          |Used weapon ID - 0x7D
00195a44: 2c420003 sltiu r2,r2,0x0003           |Check if used weapon ID is between 0x7D and 0x7F (Ball)
00195a48: 10400009 beq r2,r0,0x00195a70         #If Used Weapon is a Ball
00195a4c: 34020189 ori r2,r0,0x0189                 |Set Ability ID to 0x189
00195a50: a6020002 sh r2,0x0002(r16)        #E      | Store Ability ID in AI used ability Data 0x02 (Ability ID)
00195a54: 001110c0 sll r2,r17,0x03                  |Used weapon ID * 8
00195a58: a2110006 sb r17,0x0006(r16)               |Store Used Weapon ID as item considered
00195a5c: 3c018006 lui r1,0x8006                    |
00195a60: 00220821 addu r1,r1,r2                    |0x80060000 + Item offset (8 bytes per item)
00195a64: 90223abe lbu r2,0x3abe(r1)                |Load Weapon Element (0x80063ab8 - 0x06)
00195a68: 080656a0 j 0x00195a80                     >>Jump - Avoid normal weapon section
00195a6c: a2020010 sb r2,0x0010(r16)                |
                                                #Else - Not a Shuriken nor a ball
00195a70: 96020e14 lhu r2,0x0e14(r16)               |Load chosen Throw ability ID
00195a74: 92030e16 lbu r3,0x0e16(r16)               |Load chosen Weapon ID
00195a78: a6020002 sh r2,0x0002(r16)                |Store Ability ID in AI used ability data 0x02
00195a7c: a2030006 sb r3,0x0006(r16)                |Store Weapon ID in AI used ability
00195a80: 9242003a lbu r2,0x003a(r18)       |Load unit's move
00195a84: 86110002 lh r17,0x0002(r16)       |Load Ability ID (from AI data) in r17
00195a88: 08065700 j 0x00195c00             >>Jump to default section
00195a8c: a2020004 sb r2,0x0004(r16)        |Store Unit's move as Ability range

    ----Jump ---- 
00195a90: 92020e2e lbu r2,0x0e2e(r16)       |Load acting unit ID
00195a94: 00000000 nop                      |
00195a98: 16a2000e bne r21,r2,0x00195ad4    #If Acting unit ID = Unit ID (AI data 0xe2e Vs ID from AI move list)
00195a9c: 34020064 ori r2,r0,0x0064             |100
00195aa0: 8e0317f8 lw r3,0x17f8(r16)            |Load acting unit data pointer
00195aa4: 00000000 nop                          |
00195aa8: 90640039 lbu r4,0x0039(r3)            |Load Acting unit CT
00195aac: 90630038 lbu r3,0x0038(r3)            |Load Acting unit Speed
00195ab0: 00441023 subu r2,r2,r4                |100 - Acting unit CT
00195ab4: 0043001a div r2,r3                    |(100-CT)/Speed
00195ab8: 00001012 mflo r2                      |
00195abc: 00000000 nop                          |
00195ac0: 00021fc2 srl r3,r2,0x1f               |
00195ac4: 00431021 addu r2,r2,r3                |rounded up if needed
00195ac8: 00021043 sra r2,r2,0x01               |((100 - CT) / Speed) / 2
00195acc: 080656d7 j 0x00195b5c                 |
00195ad0: a2020001 sb r2,0x0001(r16)            |Store (100-CT/Speed)/2 in AI used Ability CT
                                            #Else : Unit is not acting unit (?)
00195ad4: 92450039 lbu r5,0x0039(r18)           |Unit CT (ID from Move list)
00195ad8: 00000000 nop                          |
00195adc: 2ca20065 sltiu r2,r5,0x0065           |
00195ae0: 14400005 bne r2,r0,0x00195af8         #If unit CT > 100
00195ae4: 34040064 ori r4,r0,0x0064             |100
00195ae8: a2000001 sb r0,0x0001(r16)                |Nullify AI used Ability CT
00195aec: 92420039 lbu r2,0x0039(r18)               |Load unit's CT
00195af0: 080656cb j 0x00195b2c                     >>Jump after the other CT section
00195af4: 2444ff9c addiu r4,r2,-0x0064              |r4 = Unit CT - 100
                                                #Else CT < 100
00195af8: 92430038 lbu r3,0x0038(r18)               |Load unit's speed
00195afc: 00851023 subu r2,r4,r5                    |100 - CT
00195b00: 0043001a div r2,r3                        |(100-CT)/Speed Nb of turn before acting ?
00195b04: 00001012 mflo r2                          |
00195b08: 00000000 nop                              |
00195b0c: a2020001 sb r2,0x0001(r16)                |Store (100-CT)/Speed As Ability CT
00195b10: 92430039 lbu r3,0x0039(r18)               |Unit's CT
00195b14: 92420038 lbu r2,0x0038(r18)               |Unit's Speed
00195b18: 00832023 subu r4,r4,r3                    |100 - CT
00195b1c: 0082001a div r4,r2                        |(100-CT)/Speed Nb of turn before acting ?
00195b20: 00001810 mfhi r3                          |remainder 
00195b24: 00000000 nop                              |
00195b28: 00432023 subu r4,r2,r3                    |Speed - Remainder CT above 100 when acting ? 
00195b2c: 34020064 ori r2,r0,0x0064                 |100
00195b30: 92430038 lbu r3,0x0038(r18)               |Unit's speed
00195b34: 00441023 subu r2,r2,r4                    |100 * Extra CT Remaining CT before next turn
00195b38: 0043001a div r2,r3                        |Remaing CT / Speed
00195b3c: 00001012 mflo r2                          |
00195b40: 00000000 nop                              |
00195b44: 00021fc2 srl r3,r2,0x1f                   |
00195b48: 00431021 addu r2,r2,r3                    |rounded up  if needed
00195b4c: 92030001 lbu r3,0x0001(r16)               |Load Nb of turn before acting
00195b50: 00021043 sra r2,r2,0x01                   |
00195b54: 00621821 addu r3,r3,r2                    |Nb of turns before second turn ? 
00195b58: a2030001 sb r3,0x0001(r16)                |Store Nb of turns before second turn as AI used Ability CT
00195b5c: 16200003 bne r17,r0,0x00195b6c    #If Ability ID = 0x00 ?
00195b60: 2622fe76 addiu r2,r17,-0x018a     |r2 = Ability ID - 0x18A (jump2 = 0)
00195b64: 080656df j 0x00195b7c                 >>Jump and force range to 0x01
00195b68: 34020001 ori r2,r0,0x0001             |r2 = 0x01
                                            #Else : Ability ID <> 0x00
00195b6c: 00021040 sll r2,r2,0x01               |Jump Ability ID*2
00195b70: 3c018006 lui r1,0x8006                |
00195b74: 00220821 addu r1,r1,r2                |
00195b78: 9022102c lbu r2,0x102c(r1)            |Load Jump Ability Range
00195b7c: 00000000 nop                      |
00195b80: a2020004 sb r2,0x0004(r16)        |Store Range
00195b84: 02151021 addu r2,r16,r21          |0x8019f3c4 + Unit ID
00195b88: 9042198c lbu r2,0x198c(r2)        |Load Unit's Battle ID (0xff if not used)
00195b8c: 00000000 nop                      |
00195b90: 000210c0 sll r2,r2,0x03           |Unit ID*8
00195b94: 24421778 addiu r2,r2,0x1778       |
00195b98: 0806565d j 0x00195974             >>Jump at the end of the default attack section
00195b9c: 02021821 addu r3,r16,r2           |Unit Weapon flag (in AI table) 0x8019f3c4 + 0x1778 + Unit battle ID * 8

    ---- Charge ---- 
00195ba0: 2622fe6a addiu r2,r17,-0x0196     |Ability ID - 0x196 (Charge +1 = 0)
00195ba4: 00021040 sll r2,r2,0x01           |Charge ID * 2
00195ba8: 3c018006 lui r1,0x8006            |
00195bac: 00220821 addu r1,r1,r2            |
00195bb0: 90221044 lbu r2,0x1044(r1)        |Load Charge's ability CT
00195bb4: 08065651 j 0x00195944             >>Jump to Attack section
00195bb8: a2020001 sb r2,0x0001(r16)        |Store Charge's CT as AI used ability CT 

    ---- Arithmeticks ---- 
00195bbc: 340300ff ori r3,r0,0x00ff         |
00195bc0: 34040004 ori r4,r0,0x0004         |Counter set for 5 loops
00195bc4: 26020004 addiu r2,r16,0x0004      |Pointer to AI used ability 5th set of status infliction 
                                            @LOOP - Enables all status infliction flags
00195bc8: a0430007 sb r3,0x0007(r2)             |Store 0xff in AI used ability Status infliction (all statuses ON)
00195bcc: 2484ffff addiu r4,r4,-0x0001          |counter -1
00195bd0: 0481fffd bgez r4,0x00195bc8       Λ Loop while counter >= 0
00195bd4: 2442ffff addiu r2,r2,-0x0001          |pointer -1
00195bd8: 340200fc ori r2,r0,0x00fc             |
00195bdc: a202000c sb r2,0x000c(r16)        |Store 0xfc in AI behavior 1  (everything but target allies / enemies)
00195be0: 92820003 lbu r2,0x0003(r20)       |Load Ability usage type (from AI moves list)  801a02b4 - 0x03
00195be4: 00000000 nop                      |
00195be8: a202000f sb r2,0x000f(r16)        |Store usage as AI used ability extra behaviors flags
00195bec: 8e02000c lw r2,0x000c(r16)        |Load All AI behaviors flags
00195bf0: 00000000 nop                      |
00195bf4: 34428000 ori r2,r2,0x8000         |Enable Ignore range
00195bf8: 08065759 j 0x00195d64             >>Jump to  >>!!END!!
00195bfc: ae02000c sw r2,0x000c(r16)        |Update AI behavior flags (ignore range)

    ----Default (direct) and  Weapon Katana Item----
00195c00: 2604000c addiu r4,r16,0x000c      |Pointer to AI used ability behaviors flags 1
00195c04: 001198c0 sll r19,r17,0x03         |Ability ID * 8
00195c08: 3c058006 lui r5,0x8006            |
00195c0c: 24a5ebf4 addiu r5,r5,0xebf4       |
00195c10: 02652821 addu r5,r19,r5           |Pointer to Ability behaviors flags 1 0x8006ebf0 - 0x04 + Ability offset (8 bytes)
00195c14: 0c066ac2 jal 0x0019ab08           |-->Transfer_Halfword_Values Transfer AI behavior flags 1,2,3,4 from SCUS Ability Table to AI used Ability Behaviors flags
00195c18: 34060004 ori r6,r0,0x0004         |Limit for routine 
00195c1c: 26e2ffff addiu r2,r23,-0x0001     |Action menu -0x1
00195c20: 2c420002 sltiu r2,r2,0x0002       |Check for  Item or Weapon inventory
00195c24: 10400005 beq r2,r0,0x00195c3c     #If Action menu is Item or weapon inventory
00195c28: 3c030040 lui r3,0x0040                |
00195c2c: 8e02000c lw r2,0x000c(r16)            |Load All AI used ability behaviors flags
00195c30: 00000000 nop                          |
00195c34: 00431025 or r2,r2,r3                  |Enable Direct attack flag
00195c38: ae02000c sw r2,0x000c(r16)            |Store updated behavior flags
00195c3c: 92820003 lbu r2,0x0003(r20)       |Load Usage flags from AI moves list
00195c40: 00000000 nop                      |
00195c44: a202000f sb r2,0x000f(r16)        |Store Usage flags as extra behavior flags
00195c48: 2a220170 slti r2,r17,0x0170       |Check if Ability has a second table (Before potion)
00195c4c: 1040002f beq r2,r0,0x00195d0c     #If Ability has a second table
00195c50: 02711023 subu r2,r19,r17              |Ability ID*7
00195c54: 00021040 sll r2,r2,0x01               |ID*14
00195c58: 3c038006 lui r3,0x8006                |
00195c5c: 2463fbf0 addiu r3,r3,0xfbf0           |
00195c60: 00431821 addu r3,r2,r3                |Ability Table 2 pointer (SCUS) 8006fbf0 + Ability offset (14 bytes)
00195c64: 9062000c lbu r2,0x000c(r3)            |Load Ability CT
00195c68: 9076000b lbu r22,0x000b(r3)           |Load Ability Inflict status
00195c6c: a2020001 sb r2,0x0001(r16)            |Store CT in AI used ability data
00195c70: 90620007 lbu r2,0x0007(r3)            |Load Ability Element
00195c74: 00000000 nop                          |
00195c78: a2020010 sb r2,0x0010(r16)            |Store ability element in AI data
00195c7c: 9062000d lbu r2,0x000d(r3)            |Load Ability MP cost
00195c80: 00000000 nop                          |
00195c84: a2020011 sb r2,0x0011(r16)            |Store MP cost in AI data
00195c88: 92420090 lbu r2,0x0090(r18)           |Load Unit 2nd set of Support 
00195c8c: 00000000 nop                          |
00195c90: 30420080 andi r2,r2,0x0080            |Check for Half of MP
00195c94: 10400005 beq r2,r0,0x00195cac         #If Unit has Half of MP
00195c98: 00000000 nop                              |
00195c9c: 92020011 lbu r2,0x0011(r16)               |Load MP cost from AI data
00195ca0: 00000000 nop                              |
00195ca4: 00021042 srl r2,r2,0x01                   |MP Cost/2
00195ca8: a2020011 sb r2,0x0011(r16)                |Store updated MP cost
00195cac: 90620003 lbu r2,0x0003(r3)            |Load Ability Flags 1
00195cb0: 00000000 nop                          |
00195cb4: 30420020 andi r2,r2,0x0020            |check for Weapon range
00195cb8: 10400009 beq r2,r0,0x00195ce0         #If Ability is weapon ranged
00195cbc: 02151021 addu r2,r16,r21                  |0x8019f3c4 + Unit ID
00195cc0: 9042198c lbu r2,0x198c(r2)                |Load Unit's battle ID  801a0d50 + Unit offset
00195cc4: 00000000 nop                              |
00195cc8: 000210c0 sll r2,r2,0x03                   |Unit ID*8
00195ccc: 02021021 addu r2,r16,r2                   |
00195cd0: 90421778 lbu r2,0x1778(r2)                |Load Weapon range from  AI Weapon data  801a0b3c + Unit offset (8 bytes)
00195cd4: a2000005 sb r0,0x0005(r16)                |Nullify AoE in AI data
00195cd8: 0806573e j 0x00195cf8                     >>Avoid the not weapon ranged section
00195cdc: a2020004 sb r2,0x0004(r16)                |Store Weapon range 
                                                 #Else : Ability is not weapon ranged                                          
00195ce0: 90620000 lbu r2,0x0000(r3)                |Load Ability range (SCUS)
00195ce4: 00000000 nop                              |
00195ce8: a2020004 sb r2,0x0004(r16)                |Store ability range in AI data
00195cec: 90620001 lbu r2,0x0001(r3)                |Load AoE
00195cf0: 00000000 nop                              |
00195cf4: a2020005 sb r2,0x0005(r16)                |Store AoE
00195cf8: 90620005 lbu r2,0x0005(r3)            |Load Flags 3
00195cfc: 00000000 nop                          |
00195d00: 30420004 andi r2,r2,0x0004            |Check for persevere
00195d04: 1440000f bne r2,r0,0x00195d44         #If persevere flag is OFF
00195d08: 26040007 addiu r4,r16,0x0007          |pointer to AI used ability status infliction 1
00195d0c: 92430092 lbu r3,0x0092(r18)       #E      | Load Unit Support 4
00195d10: 00000000 nop                              |
00195d14: 30620080 andi r2,r3,0x0080                |Check for Monster skill / BUG : Should be 0x08 (short charge)
00195d18: 10400006 beq r2,r0,0x00195d34             #If Unit has Monster skill (Instead of short charge)
00195d1c: 30620040 andi r2,r3,0x0040                |Check for Defend / BUG : Should be 0x04 (Non-Charge)
00195d20: 92020001 lbu r2,0x0001(r16)                   |Load AI used Ability CT
00195d24: 00000000 nop                                  |
00195d28: 00021042 srl r2,r2,0x01                       |CT/2
00195d2c: 08065750 j 0x00195d40                         >>Avoid the intended Non-Charge section 
00195d30: a2020001 sb r2,0x0001(r16)                    |Store New CT
00195d34: 10400003 beq r2,r0,0x00195d44             #Else : if Unit Has Defend (instead of Non-Charge)
00195d38: 26040007 addiu r4,r16,0x0007              |pointer to AI used ability status infliction 1
00195d3c: a2000001 sb r0,0x0001(r16)                    |Nullify Ability CT
00195d40: 26040007 addiu r4,r16,0x0007                  |pointer to AI used ability status infliction 1
00195d44: 00162840 sll r5,r22,0x01          |Inflict status ID * 2 (from item or ability)
00195d48: 00b62821 addu r5,r5,r22           |ID*3
00195d4c: 00052840 sll r5,r5,0x01           |Status ID * 6
00195d50: 3c028006 lui r2,0x8006            |
00195d54: 24423fc5 addiu r2,r2,0x3fc5       |
00195d58: 00a22821 addu r5,r5,r2            |Pointer to Inflicted Status ID 1st set of status
00195d5c: 0c066ad2 jal 0x0019ab48           |-->Transfer_Byte_Values Transfer 5 set of status infliction form SCUS status table to AI used ability data
00195d60: 34060005 ori r6,r0,0x0005         |Limit (5 set of status)
00195d64: 8fbf0030 lw r31,0x0030(r29)       END
00195d68: 8fb7002c lw r23,0x002c(r29)
00195d6c: 8fb60028 lw r22,0x0028(r29)
00195d70: 8fb50024 lw r21,0x0024(r29)
00195d74: 8fb40020 lw r20,0x0020(r29)
00195d78: 8fb3001c lw r19,0x001c(r29)
00195d7c: 8fb20018 lw r18,0x0018(r29)
00195d80: 8fb10014 lw r17,0x0014(r29)
00195d84: 8fb00010 lw r16,0x0010(r29)
00195d88: 27bd0038 addiu r29,r29,0x0038
00195d8c: 03e00008 jr r31
00195d90: 00000000 nop

Notes

Used AI section
 - Fill 0x8019f3c4                 8019f3c4 
 - Load data from 0x801a0b3c       801a0b3c / 8019f3c4 + 0x1778
 - Load data from 0x801a02b4       801a02b4 / 8019f3c4 + 0x0ef0
 - Load ID from 0x801a0d50         801a0d50 / 8019f3c4 + 0x198c
 - Load ID from 0x801a0e2e         801a01f0 / 8019f3c4 + 0x0e2e

Hard-coded mechanics
 - Item invetory : Link between Ability ID and item
 - Katana inventory : Link Between Ability ID and katanas
 - Weapon inventory : shurikens and ball (? to be confirmed)
 - Jump is forced as hostile
 - AoE nullified for Item inventory, default section is ability is weapon ranged, Left to 0x00 for Jump/Charge/Attack
 - Item inventory and weapon inventory direct flag is forced ON
 
BUGS 
 - Throw item is move instead of 4
 - Short CT is not correctly checked (0x80 instead of 0x08)
 - No CT is not correctly checked (0x40 instead of 0x04)

Return location

Battle.bin
00194f80: Set_AI_ability_considerations_for_all_units_and_self
001954c0: Set_AI_ability_considerations_for_all_units_and_self
001972a8: Set_chosen_ability/target_for_AI_status
0019745c: Set_chosen_ability/target_for_AI_status
00197ec8: Chose_Move_from_Move_List?
0019894c: Evaluate_Cancel_Status_Ability_(0019881c)
00198fb0: 00198e60_-_00199058
00199fac: Usable_Ability_Setting/ENTD_AI_Calculations