Difference between revisions of "Set unit untargetable based on 19f0d8 routine"

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
(Created page with "<font face='Courier New'> 0019f01c: 27bdffd8 addiu r29,r29,0xffd8 0019f020: afb3001c sw r19,0x001c(r29) 0019f024: 00009821 addu r19,r0,r0 0019f028: afb00010 sw r16,0x001...")
 
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
<font face='Courier New'>
+
'''BATTLE.BIN''' :  -
   
+
May disable some Enemy Unit in AI 0xc8d List (potential Targets). Disabled if will act before the end of a harmfull ability CT.
  0019f01c: 27bdffd8 addiu r29,r29,0xffd8
+
------------------------------------------------------------------------------------------
  0019f020: afb3001c sw r19,0x001c(r29)
+
Parameter : Nothing
  0019f024: 00009821 addu r19,r0,r0
+
Return : r2 = if there is at least one potentiel Target in List
  0019f028: afb00010 sw r16,0x0010(r29)
+
          r2 = 0x00 if no Target left
  0019f02c: 00008021 addu r16,r0,r0
+
  ------------------------------------------------------------------------------------------
  0019f030: afb40020 sw r20,0x0020(r29)
+
  0019f01c: 27bdffd8 addiu r29,r29,-0x0028    |
  0019f034: 3c14801a lui r20,0x801a
+
  0019f020: afb3001c sw r19,0x001c(r29)       |
  0019f038: 2694f3c4 addiu r20,r20,0xf3c4
+
  0019f024: 00009821 addu r19,r0,r0           |{{f/std|Initialize [found a Target] flag}}
  0019f03c: afb20018 sw r18,0x0018(r29)
+
  0019f028: afb00010 sw r16,0x0010(r29)       |
  0019f040: 02809021 addu r18,r20,r0
+
  0019f02c: 00008021 addu r16,r0,r0           |{{f/std|Initialize Unit counter}}
  0019f044: afbf0024 sw r31,0x0024(r29)
+
  0019f030: afb40020 sw r20,0x0020(r29)       |
  0019f048: afb10014 sw r17,0x0014(r29)
+
  0019f034: 3c14801a lui r20,0x801a           |
  0019f04c: 02908821 addu r17,r20,r16
+
  0019f038: 2694f3c4 addiu r20,r20,-0x0c3c    |{{f/adr|0x8019f3c4}}
  0019f050: 92220c8d lbu r2,0x0c8d(r17)
+
  0019f03c: afb20018 sw r18,0x0018(r29)       |
  0019f054: 00000000 nop
+
  0019f040: 02809021 addu r18,r20,r0           |{{f/adr|Prepare dynamic AI pointer}}
  0019f058: 10400011 beq r2,r0,0x0019f0a0
+
  0019f044: afbf0024 sw r31,0x0024(r29)       |
  0019f05c: 00000000 nop
+
  0019f048: afb10014 sw r17,0x0014(r29)       |
  0019f060: 8e82000c lw r2,0x000c(r20)
+
                                            {{f/bloop|LOOP - through all units}}
  0019f064: 00000000 nop
+
  0019f04c: 02908821 addu r17,r20,r16             |{{f/adr|Dynamic pointer to AI data (8019f3c4 + 1 byte per iteration)}}
  0019f068: 30420002 andi r2,r2,0x0002
+
  0019f050: 92220c8d lbu r2,0x0c8d(r17)           |{{f/load|This Unit Targetable flag}} {{f/std|From 0x8019f3c4 + 0x0c8d}}
  0019f06c: 1040000b beq r2,r0,0x0019f09c
+
  0019f054: 00000000 nop                           |
  0019f070: 00000000 nop
+
  0019f058: 10400011 beq r2,r0,0x0019f0a0         {{f/Cond|If This Unit is not a potential Target : branch to}} {{f/loc|Next Unit}}
  0019f074: 92421834 lbu r2,0x1834(r18)
+
  0019f05c: 00000000 nop                           |
  0019f078: 00000000 nop
+
  0019f060: 8e82000c lw r2,0x000c(r20)             |{{f/load|Considered Ability AI behavior flags 1 to 4}}
  0019f07c: 10400007 beq r2,r0,0x0019f09c
+
  0019f064: 00000000 nop                           |
  0019f080: 00000000 nop
+
  0019f068: 30420002 andi r2,r2,0x0002             |
  0019f084: 0c067c36 jal 0x0019f0d8
+
  0019f06c: 1040000b beq r2,r0,0x0019f09c         {{f/Cond|If considered Ability has [Target Enemies]}}
  0019f088: 02002021 addu r4,r16,r0
+
  0019f070: 00000000 nop                               |
  0019f08c: 10400003 beq r2,r0,0x0019f09c
+
  0019f074: 92421834 lbu r2,0x1834(r18)               |{{f/load|This Unit Enemy flag}} {{f/adr|8019f3c4 + 0x182c + 0x08 + Unit offset}}
  0019f090: 00000000 nop
+
  0019f078: 00000000 nop                               |
  0019f094: 08067c28 j 0x0019f0a0
+
  0019f07c: 10400007 beq r2,r0,0x0019f09c             {{f/Cond|If This Unit is an Enemy}}
  0019f098: a2200c8d sb r0,0x0c8d(r17)
+
  0019f080: 00000000 nop                                   |
  0019f09c: 34130001 ori r19,r0,0x0001
+
  0019f084: 0c067c36 jal 0x0019f0d8                       |{{f/jal|See_if_ability_should_be_used_based_on_CT|See_if_ability_should_be_used_based_on_CT}} {{f/std|returns 0x00 if Ability CT ends before Unit next active turn}}
  0019f0a0: 26100001 addiu r16,r16,0x0001
+
  0019f088: 02002021 addu r4,r16,r0                       |{{f/std|Send Unit ID}}
  0019f0a4: 2a020015 slti r2,r16,0x0015
+
  0019f08c: 10400003 beq r2,r0,0x0019f09c                 {{f/Cond|If Ability won't  Hit the unit before his next turn}}
  0019f0a8: 1440ffe8 bne r2,r0,0x0019f04c
+
  0019f090: 00000000 nop                                       |
  0019f0ac: 26520010 addiu r18,r18,0x0010
+
  0019f094: 08067c28 j 0x0019f0a0                             |{{f/loc|Next Unit}}
  0019f0b0: 02601021 addu r2,r19,r0
+
  0019f098: a2200c8d sb r0,0x0c8d(r17)                         |{{f/store|Disable Unit in Potential Targets list}}
 +
                                                  '''Else : Considered ability do not have [Target Enemies] / This Unit is an Ally / Enemy won't act before Ability CT end'''
 +
  0019f09c: 34130001 ori r19,r0,0x0001                 |{{f/std|Enable found a Targetflag}}
 +
  0019f0a0: 26100001 addiu r16,r16,0x0001         |{{f/std|Unit counter + 1}}
 +
  0019f0a4: 2a020015 slti r2,r16,0x0015           |
 +
  0019f0a8: 1440ffe8 bne r2,r0,0x0019f04c     {{f/eloop|do for all units}}
 +
  0019f0ac: 26520010 addiu r18,r18,0x0010         |{{f/adr|Dynamic pointer to AI data (8019f3c4 + 0x10 byte per iteration)}} {{f/std| Used for Data at AI 0x182c}}
 +
  0019f0b0: 02601021 addu r2,r19,r0           |{{f/std|<nowiki>r2 = 1 if any unit is targetable</nowiki>}}
 
  0019f0b4: 8fbf0024 lw r31,0x0024(r29)
 
  0019f0b4: 8fbf0024 lw r31,0x0024(r29)
 
  0019f0b8: 8fb40020 lw r20,0x0020(r29)
 
  0019f0b8: 8fb40020 lw r20,0x0020(r29)
Line 48: Line 55:
 
  0019f0d0: 03e00008 jr r31
 
  0019f0d0: 03e00008 jr r31
 
  0019f0d4: 00000000 nop
 
  0019f0d4: 00000000 nop
</font>
+
===Return locations===
 +
'''BATTLE.BIN'''
 +
  0019b290: [[AI_ability_use_control_routine]]

Latest revision as of 19:13, 1 May 2024

BATTLE.BIN :  - 
May disable some Enemy Unit in AI 0xc8d List (potential Targets). Disabled if will act before the end of a harmfull ability CT.
------------------------------------------------------------------------------------------
Parameter : Nothing
Return : r2 = if there is at least one potentiel Target in List
         r2 = 0x00 if no Target left
------------------------------------------------------------------------------------------
0019f01c: 27bdffd8 addiu r29,r29,-0x0028     |
0019f020: afb3001c sw r19,0x001c(r29)        |
0019f024: 00009821 addu r19,r0,r0            |Initialize [found a Target] flag
0019f028: afb00010 sw r16,0x0010(r29)        |
0019f02c: 00008021 addu r16,r0,r0            |Initialize Unit counter
0019f030: afb40020 sw r20,0x0020(r29)        |
0019f034: 3c14801a lui r20,0x801a            |
0019f038: 2694f3c4 addiu r20,r20,-0x0c3c     |0x8019f3c4
0019f03c: afb20018 sw r18,0x0018(r29)        |
0019f040: 02809021 addu r18,r20,r0           |Prepare dynamic AI pointer
0019f044: afbf0024 sw r31,0x0024(r29)        |
0019f048: afb10014 sw r17,0x0014(r29)        |
                                            @LOOP - through all units
0019f04c: 02908821 addu r17,r20,r16              |Dynamic pointer to AI data (8019f3c4 + 1 byte per iteration)
0019f050: 92220c8d lbu r2,0x0c8d(r17)            |This Unit Targetable flag From 0x8019f3c4 + 0x0c8d
0019f054: 00000000 nop                           |
0019f058: 10400011 beq r2,r0,0x0019f0a0          #If This Unit is not a potential Target : branch to Next Unit
0019f05c: 00000000 nop                           |
0019f060: 8e82000c lw r2,0x000c(r20)             |Considered Ability AI behavior flags 1 to 4
0019f064: 00000000 nop                           |
0019f068: 30420002 andi r2,r2,0x0002             |
0019f06c: 1040000b beq r2,r0,0x0019f09c          #If considered Ability has [Target Enemies]
0019f070: 00000000 nop                               |
0019f074: 92421834 lbu r2,0x1834(r18)                |This Unit Enemy flag 8019f3c4 + 0x182c + 0x08 + Unit offset
0019f078: 00000000 nop                               |
0019f07c: 10400007 beq r2,r0,0x0019f09c              #If This Unit is an Enemy
0019f080: 00000000 nop                                   |
0019f084: 0c067c36 jal 0x0019f0d8                        |-->See_if_ability_should_be_used_based_on_CT returns 0x00 if Ability CT ends before Unit next active turn
0019f088: 02002021 addu r4,r16,r0                        |Send Unit ID
0019f08c: 10400003 beq r2,r0,0x0019f09c                  #If Ability won't  Hit the unit before his next turn
0019f090: 00000000 nop                                       |
0019f094: 08067c28 j 0x0019f0a0                              |Next Unit
0019f098: a2200c8d sb r0,0x0c8d(r17)                         |Disable Unit in Potential Targets list
                                                 Else : Considered ability do not have [Target Enemies] / This Unit is an Ally / Enemy won't act before Ability CT end
0019f09c: 34130001 ori r19,r0,0x0001                 |Enable found a Targetflag
0019f0a0: 26100001 addiu r16,r16,0x0001          |Unit counter + 1
0019f0a4: 2a020015 slti r2,r16,0x0015            |
0019f0a8: 1440ffe8 bne r2,r0,0x0019f04c      Λ do for all units
0019f0ac: 26520010 addiu r18,r18,0x0010          |Dynamic pointer to AI data (8019f3c4 + 0x10 byte per iteration)  Used for Data at AI 0x182c
0019f0b0: 02601021 addu r2,r19,r0            |r2 = 1 if any unit is targetable
0019f0b4: 8fbf0024 lw r31,0x0024(r29)
0019f0b8: 8fb40020 lw r20,0x0020(r29)
0019f0bc: 8fb3001c lw r19,0x001c(r29)
0019f0c0: 8fb20018 lw r18,0x0018(r29)
0019f0c4: 8fb10014 lw r17,0x0014(r29)
0019f0c8: 8fb00010 lw r16,0x0010(r29)
0019f0cc: 27bd0028 addiu r29,r29,0x0028
0019f0d0: 03e00008 jr r31
0019f0d4: 00000000 nop

Return locations

BATTLE.BIN
 0019b290: AI_ability_use_control_routine