Difference between revisions of "Set Target Tiles"

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
m (Added a note)
m
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
  [0x0017a8c0] addiu r29,r29,-0x0048
+
  '''BATTLE.BIN''' :  - Set_Target_Tiles      ''' Alternate Version '''by Glain : [[Calculate_Target_Panels]]
[0x0017a8c4] addiu r5,r29,0x0010
+
  ------------------------------------------------------------------------------------------
  [0x0017a8c8] sw r31,0x0040(r29)
+
  Parameter : r4 Pointer to Action Data (Battle 0x16e model)
[0x0017a8cc] sw r21,0x003c(r29)
+
  Return : r2 = 0x00 if there are tiles to target and Ability can [Follow Target]
[0x0017a8d0] sw r20,0x0038(r29)
+
          r2 = 0x01 if there are tiles to target and Ability cannot [Follow Target]
[0x0017a8d4] sw r19,0x0034(r29)
+
          r2 = 0x03 if there are no tiles to target
[0x0017a8d8] sw r18,0x0030(r29)
+
          r2 = 0x02 if unhandled situation (action menu or ranged weapon auto-target with range 0)
[0x0017a8dc] jal 0x0005e22c                [[Transfer Target ID? Through Mount Data]]
+
          r2 = -0x01 if invalid situation (action menu, Ids)
  [0x0017a8e0] sw r16,0x0028(r29)
+
  ------------------------------------------------------------------------------------------
  [0x0017a8e4] lbu r3,0x0010(r29)
+
  0017a8c0: 27bdffb8 addiu r29,r29,-0x0048    |
[0x0017a8e8] nop
+
  0017a8c4: 27a50010 addiu r5,r29,0x0010      |{{f/std|Stack 0x10}}
  [0x0017a8ec] sltiu r2,r3,0x0015
+
  0017a8c8: afbf0040 sw r31,0x0040(r29)        |
  [0x0017a8f0] beq r2,r0,0x0017aa40
+
  0017a8cc: afb5003c sw r21,0x003c(r29)        |
[0x0017a8f4] addu r16,r0,r0
+
  0017a8d0: afb40038 sw r20,0x0038(r29)        |
[0x0017a8f8] sll r2,r3,0x03
+
  0017a8d4: afb30034 sw r19,0x0034(r29)       |
[0x0017a8fc] subu r2,r2,r3
+
  0017a8d8: afb20030 sw r18,0x0030(r29)        |
[0x0017a900] sll r2,r2,0x06
+
  0017a8dc: afb1002c sw r17,0x002c(r29)       |
[0x0017a904] lui r3,0x8019
+
  0017a8e0: 0c01788b jal 0x8005e22c            |{{f/jal|Copy_Byte_Data_(20_Bytes)|Copy_Byte_Data_(20_Bytes)}} {{f/std|From r4 to r5 }}
[0x0017a908] addiu r3,r3,0x08cc
+
  0017a8e4: afb00028 sw r16,0x0028(r29)        |
  [0x0017a90c] addu r17,r2,r3
+
0017a8e8: 93a30010 lbu r3,0x0010(r29)        |{{f/load|Unit ID}}
  [0x0017a910] lbu r3,0x0001(r17)
+
  0017a8ec: 00000000 nop                      |
  [0x0017a914] ori r2,r0,0x00ff
+
0017a8f0: 2c620015 sltiu r2,r3,0x0015        |
  [0x0017a918] beq r3,r2,0x0017aacc
+
  0017a8f4: 10400053 beq r2,r0,0x8017aa44      {{f/Cond|If Unit ID is invalid}} {{f/loc|Exit}} {{f/Returns|returns -0x01}}
  [0x0017a91c] addiu r2,r0,-0x0001
+
  0017a8f8: 00008021 addu r16,r0,r0            |{{f/std|Default Action menu type Type  (inner routine variable)}}
  [0x0017a920] lbu r2,0x0011(r29)
+
  0017a8fc: 000310c0 sll r2,r3,0x03            |
  [0x0017a924] lui r1,0x8006
+
  0017a900: 00431023 subu r2,r2,r3            |
  [0x0017a928] addu r1,r1,r2
+
  0017a904: 00021180 sll r2,r2,0x06            |{{f/std|Unit ID * 0x1c0}}
[0x0017a92c] lbu r3,0x5cb4(r1)
+
  0017a908: 3c038019 lui r3,0x8019            |
  [0x0017a930] nop
+
  0017a90c: 246308cc addiu r3,r3,0x08cc        |{{f/adr|Pointer to Unit Battle data}}
  [0x0017a934] sltiu r2,r3,0x0010
+
  0017a910: 00438821 addu r17,r2,r3            |
  [0x0017a938] beq r2,r0,0x0017aa84
+
  0017a914: 92230001 lbu r3,0x0001(r17)       |{{f/load|Unit Battle ID}}
  [0x0017a93c] sll r2,r3,0x02
+
  0017a918: 340200ff ori r2,r0,0x00ff          |
  [0x0017a940] lui r1,0x8017
+
  0017a91c: 1062006c beq r3,r2,0x8017aad0      {{f/Cond|If Unit do not Exist anymore }} {{f/loc|Exit}} {{f/Returns|returns -0x01}}
  [0x0017a944] addu r1,r1,r2
+
  0017a920: 2402ffff addiu r2,r0,-0x0001      |
  [0x0017a948] lw r2,0x4068(r1)
+
  0017a924: 93a20011 lbu r2,0x0011(r29)       |{{f/load|Considered Ability's Skillset ID}}
  [0x0017a94c] nop
+
  0017a928: 3c018006 lui r1,0x8006            |
[0x0017a950] jr r2
+
  0017a92c: 00220821 addu r1,r1,r2             |
  [0x0017a954] nop
+
  0017a930: 90235cb4 lbu r3,0x5cb4(r1)        |{{f/load|Considered Skillset Action Menu}} {{f/adr|0x80065cb4 + Skillset offset}}
  [0x0017a958] lhu r20,0x0012(r29)
+
  0017a934: 00000000 nop                      |
  [0x0017a95c] j 0x0017aa28
+
  0017a938: 2c620010 sltiu r2,r3,0x0010        |
  [0x0017a960] ori r16,r0,0x0001
+
  0017a93c: 10400052 beq r2,r0,0x8017aa88      {{f/Cond|If Considered Action Menu > 0x0f}} {{f/loc|Exit}} {{f/Returns|returns 0x02}}
[0x0017a964] lbu r2,0x0091(r17)
+
  0017a940: 00031080 sll r2,r3,0x02            |{{f/std|Action menu offset (word)}}
  [0x0017a968] nop
+
  0017a944: 3c018017 lui r1,0x8017            |
[0x0017a96c] andi r2,r2,0x0008
+
  0017a948: 00220821 addu r1,r1,r2            |
  [0x0017a970] bne r2,r0,0x0017a988
+
  0017a94c: 8c224068 lw r2,0x4068(r1)          |{{f/adr|Jump loaction based on action menu}}
  [0x0017a974] ori r18,r0,0x0004
+
  0017a950: 00000000 nop                      |
  [0x0017a978] lbu r3,0x0003(r17)
+
  0017a954: 00400008 jr r2                    {{f/jump|Jump to Action menu dedicated location}}
  [0x0017a97c] ori r2,r0,0x005d
+
  0017a958: 00000000 nop                      |
  [0x0017a980] bne r3,r2,0x0017a990
+
   
  [0x0017a984] nop
+
  {{f/sec|Default / Monster}}
  [0x0017a988] j 0x0017aa28
+
  0017a95c: 97b40012 lhu r20,0x0012(r29)       |{{f/load|Considered Ability ID}}
  [0x0017a98c] ori r16,r0,0x0002
+
  0017a960: 0805ea8a j 0x8017aa28              {{f/jump|Avoid other Action menu sections}}
  [0x0017a990] ori r18,r0,0x0001
+
  0017a964: 34100001 ori r16,r0,0x0001        |{{f/std|<nowiki>Set type = 0x1</nowiki>}}
  [0x0017a994] j 0x0017aa28
+
[0x0017a998] ori r16,r0,0x0002
+
  {{f/sec|Item Inventory}}
[0x0017a99c] lbu r2,0x003a(r17)
+
  0017a968: 92220091 lbu r2,0x0091(r17)       |{{f/load|Considered Unit Support 3}}
  [0x0017a9a0] ori r16,r0,0x0002
+
  0017a96c: 00000000 nop                      |
  [0x0017a9a4] j 0x0017aa28
+
0017a970: 30420008 andi r2,r2,0x0008        |
  [0x0017a9a8] ori r18,r2,0x0080
+
  0017a974: 14400005 bne r2,r0,0x8017a98c      {{f/Cond|If Unit  use [Throw Item] : branch to}}
  [0x0017a9ac] jal 0x001810a0
+
0017a978: 34120004 ori r18,r0,0x0004        |{{f/std|<nowiki>Range = 0x4</nowiki>}}
  [0x0017a9b0] addu r4,r17,r0
+
  0017a97c: 92230003 lbu r3,0x0003(r17)       |{{f/load|Unit Job}}
  [0x0017a9b4] sll r2,r2,0x03
+
  0017a980: 3402005d ori r2,r0,0x005d          |
  [0x0017a9b8] lui r1,0x8019
+
  0017a984: 14620003 bne r3,r2,0x8017a994      {{f/Cond|If Unit is not a mime : branch to}}
  [0x0017a9bc] addu r1,r1,r2
+
  0017a988: 00000000 nop                          |
  [0x0017a9c0] lbu r2,-0x0734(r1)
+
                                            {{f/sec|<nowiki>Throw item or Mime (range = 0x4)</nowiki>}}
  [0x0017a9c4] nop
+
0017a98c: 0805ea8a j 0x8017aa28                  {{f/jump|Avoid other Action menu sections}}
  [0x0017a9c8] andi r2,r2,0x003f
+
  0017a990: 34100002 ori r16,r0,0x0002            |{{f/std|<nowiki>Type = 0x02</nowiki>}}
  [0x0017a9cc] lui r1,0x8006
+
                                            {{f/sec|<nowiki>Not Throw item nor Mime (range = 0x1)</nowiki>}}
  [0x0017a9d0] addu r1,r1,r2
+
  0017a994: 34120001 ori r18,r0,0x0001            |{{f/std|<nowiki>range = 0x1</nowiki>}}
[0x0017a9d4] lbu r20,-0x1630(r1)
+
  0017a998: 0805ea8a j 0x8017aa28                  {{f/jump|Avoid other Action menu sections}}
  [0x0017a9d8] j 0x0017aa28
+
  0017a99c: 34100002 ori r16,r0,0x0002            |{{f/std|<nowiki>Type = 0x02</nowiki>}}
  [0x0017a9dc] ori r16,r0,0x0001
+
   
  [0x0017a9e0] lbu r2,0x0018(r29)
+
  {{f/sec|Weapon Inventory}}
  [0x0017a9e4] nop
+
  0017a9a0: 9222003a lbu r2,0x003a(r17)        |{{f/load|Unit move}}
[0x0017a9e8] addiu r2,r2,-0x0026
+
0017a9a4: 34100002 ori r16,r0,0x0002        |{{f/std|<nowiki>Type = 0x02</nowiki>}}
  [0x0017a9ec] sltiu r2,r2,0x000a
+
0017a9a8: 0805ea8a j 0x8017aa28              {{f/jump|Avoid other Action menu sections}}
  [0x0017a9f0] beq r2,r0,0x0017aa40
+
  0017a9ac: 34520080 ori r18,r2,0x0080        |{{f/std|<nowiki>Range = Move with flag 0x80</nowiki>}}
  [0x0017a9f4] ori r16,r0,0x0001
+
  [0x0017a9f8] lbu r2,0x0018(r29)
+
{{f/sec|Elements}}
  [0x0017a9fc] j 0x0017aa28
+
0017a9b0: 0c060428 jal 0x801810a0            |{{f/jal|Map_Location_Calculation|Map_Location_Calculation}} {{f/std|Returns unit Tile ID}}
  [0x0017aa00] addiu r20,r2,0x0026
+
  0017a9b4: 02202021 addu r4,r17,r0            |{{f/std|Send Unit battle pointer}}
  [0x0017aa04] jal 0x0017a518                  [[Set targeting for weapon attack 2]]
+
  0017a9b8: 000210c0 sll r2,r2,0x03            |
  [0x0017aa08] addiu r4,r29,0x0010
+
0017a9bc: 3c018019 lui r1,0x8019            |
  [0x0017aa0c] j 0x0017aa24
+
  0017a9c0: 00220821 addu r1,r1,r2            |
  [0x0017aa10] addu r19,r2,r0
+
  0017a9c4: 9022f8cc lbu r2,-0x0734(r1)        |{{f/load|Unit Tile Type}} {{f/adr|0x8018f8cc + Tile offset}}
  [0x0017aa14] jal 0x00179dc8                  [[Set Ability Targeting?]]
+
0017a9c8: 00000000 nop                      |
  [0x0017aa18] addiu r4,r29,0x0010
+
  0017a9cc: 3042003f andi r2,r2,0x003f        |{{f/std|keep only tile type}}
  [0x0017aa1c] addu r19,r2,r0
+
  0017a9d0: 3c018006 lui r1,0x8006            |
  [0x0017aa20] ori r21,r0,0x0010
+
  0017a9d4: 00220821 addu r1,r1,r2            |
  [0x0017aa24] ori r2,r0,0x0001
+
  0017a9d8: 9034e9d0 lbu r20,-0x1630(r1)      |{{f/load|Ability ID based on Terrain}} {{f/adr|0x8005e9d0 + Terrain offset}} {{f/std|[[Geomancy_tiles_type_to_ability_table]]}}
  [0x0017aa28] bne r16,r2,0x0017aaa0
+
0017a9dc: 0805ea8a j 0x8017aa28              {{f/jump|Avoid other Action menu sections}}
  [0x0017aa2c] ori r2,r0,0x0002
+
  0017a9e0: 34100001 ori r16,r0,0x0001        |{{f/std|<nowiki>Type = 0x01</nowiki>}}
  [0x0017aa30] andi r3,r20,0xffff
+
   
  [0x0017aa34] sltiu r2,r3,0x0170
+
{{f/sec|katana inventory}}
  [0x0017aa38] bne r2,r0,0x0017aa48
+
0017a9e4: 93a20018 lbu r2,0x0018(r29)        |{{f/load|Ability used item ID}}
  [0x0017aa3c] sll r2,r3,0x03
+
  0017a9e8: 00000000 nop                      |
  [0x0017aa40] j 0x0017aad0
+
  0017a9ec: 2442ffda addiu r2,r2,-0x0026      |{{f/std|Ability - 0x26}}
  [0x0017aa44] addiu r2,r0,-0x0001
+
  0017a9f0: 2c42000a sltiu r2,r2,0x000a        |{{f/std|Hardcoded check Ability to item (max 10 abilities)}}
  [0x0017aa48] subu r2,r2,r3
+
  0017a9f4: 10400013 beq r2,r0,0x8017aa44      {{f/Cond|If Ability and katanas are mismatching}} {{f/loc|Exit }} {{f/Returns|Returns -0x01}}
  [0x0017aa4c] sll r2,r2,0x01
+
  0017a9f8: 34100001 ori r16,r0,0x0001        |{{f/std|<nowiki>Type = 0x1</nowiki>}}
  [0x0017aa50] lui r3,0x8006
+
  0017a9fc: 93a20018 lbu r2,0x0018(r29)        |{{f/load|Ability used item ID}}
  [0x0017aa54] addiu r3,r3,-0x0410
+
0017aa00: 0805ea8a j 0x8017aa28              {{f/jump|Avoid other Action menu sections}}
  [0x0017aa58] addu r2,r2,r3
+
0017aa04: 24540026 addiu r20,r2,0x0026      |{{f/std|<nowiki>Ability ID = katana ID - 0x26</nowiki>}}
  [0x0017aa5c] lbu r18,0x0000(r2)
+
   
  [0x0017aa60] lbu r3,0x0003(r2)
+
  {{f/sec|Attack / Charge}}
  [0x0017aa64] lbu r21,0x0004(r2)
+
0017aa08: 0c05e946 jal 0x8017a518            |{{f/jal|Set_targeting_for_weapon_attack_2|Set_targeting_for_weapon_attack_2}}
  [0x0017aa68] andi r2,r3,0x0002
+
0017aa0c: 27a40010 addiu r4,r29,0x0010      |{{f/std|Send Action pointer}}
  [0x0017aa6c] beq r2,r0,0x0017aa8c
+
  0017aa10: 0805ea89 j 0x8017aa24              {{f/jump|Avoid other Action menu sections }} {{f/std|Follow Target will be forced OFF (this is a reverted flag in Patcher)}}
  [0x0017aa70] nop
+
  0017aa14: 00409821 addu r19,r2,r0            |{{f/std|Preserve results (0 if no Tiles to target ?)}}
[0x0017aa74] bne r18,r0,0x0017aa8c
+
   
  [0x0017aa78] andi r2,r3,0x0020
+
{{f/sec|Jump}}
  [0x0017aa7c] bne r2,r0,0x0017aa8c
+
0017aa18: 0c05e772 jal 0x80179dc8            |{{f/jal|Set_Jump_Ability_Targeting|Set_Jump_Ability_Targeting}}
  [0x0017aa80] nop
+
0017aa1c: 27a40010 addiu r4,r29,0x0010      |{{f/std|Send Action pointer}}
  [0x0017aa84] j 0x0017aad0
+
  0017aa20: 00409821 addu r19,r2,r0           |{{f/std|Preserve results (0 if no Tiles to target ?)}}
  [0x0017aa88] ori r2,r0,0x0002
+
  0017aa24: 34150010 ori r21,r0,0x0010        |{{f/std|Follow Target is forced OFF (this is a reverted flag in Patcher)}}
  [0x0017aa8c] sh r20,0x0012(r29)
+
  [0x0017aa90] jal 0x0017a290                    [[Set panels affected by ability?]]
+
  {{f/sec|--- POST ACTION MENU SECTION ---}}
[0x0017aa94] addiu r4,r29,0x0010
+
0017aa28: 34020001 ori r2,r0,0x0001          |
  [0x0017aa98] addu r19,r2,r0
+
  0017aa2c: 1602001d bne r16,r2,0x8017aaa4    {{f/Cond|If Type is 0x01 (default / monster /Geomancy / Katana)}}
  [0x0017aa9c] ori r2,r0,0x0002
+
0017aa30: 34020002 ori r2,r0,0x0002              |
  [0x0017aaa0] bne r16,r2,0x0017aab8
+
  0017aa34: 3283ffff andi r3,r20,0xffff            |{{f/std|Ability ID}}
  [0x0017aaa4] addu r4,r17,r0
+
  0017aa38: 2c620170 sltiu r2,r3,0x0170            |
  [0x0017aaa8] jal 0x0017a16c                    [[calculate ability range with map parameters?]]
+
  0017aa3c: 14400003 bne r2,r0,0x8017aa4c          {{f/Cond|If Ability do not have a data 2 Table}}
[0x0017aaac] andi r5,r18,0x00ff
+
  0017aa40: 000310c0 sll r2,r3,0x03                    |
  [0x0017aab0] addu r19,r2,r0
+
0017aa44: 0805eab4 j 0x8017aad0                      |{{f/loc|Exit }} {{f/Returns|Returns -0x01}}
  [0x0017aab4] ori r21,r0,0x0010
+
  0017aa48: 2402ffff addiu r2,r0,-0x0001              |
  [0x0017aab8] bne r19,r0,0x0017aac8
+
                                                  '''Else : Ability has a data 2 table'''
  [0x0017aabc] andi r2,r21,0x0010
+
  0017aa4c: 00431023 subu r2,r2,r3                    |
  [0x0017aac0] j 0x0017aad0
+
  0017aa50: 00021040 sll r2,r2,0x01                    |
  [0x0017aac4] ori r2,r0,0x0003
+
  0017aa54: 3c038006 lui r3,0x8006                    |
  [0x0017aac8] sltu r2,r0,r2
+
  0017aa58: 2463fbf0 addiu r3,r3,-0x0410              |{{f/std|0x8005fbf0}}
  [0x0017aacc] lw r31,0x0040(r29)
+
0017aa5c: 00431021 addu r2,r2,r3                    |{{f/adr|Pointer to Ability data 2}}
  [0x0017aad0] lw r21,0x003c(r29)
+
  0017aa60: 90520000 lbu r18,0x0000(r2)                |{{f/load|Ability Range}}
  [0x0017aad4] lw r20,0x0038(r29)
+
  0017aa64: 90430003 lbu r3,0x0003(r2)                |{{f/load|Ability Flags 1}}
  [0x0017aad8] lw r19,0x0034(r29)
+
  0017aa68: 90550004 lbu r21,0x0004(r2)                |{{f/load|Ability Flags 2}}
  [0x0017aadc] lw r18,0x0030(r29)
+
  0017aa6c: 30620002 andi r2,r3,0x0002                |
  [0x0017aae0] lw r17,0x002c(r29)
+
  0017aa70: 10400007 beq r2,r0,0x8017aa90              {{f/Cond|If Ability has [Auto Target]}}
  [0x0017aae4] lw r16,0x0028(r29)
+
  0017aa74: 00000000 nop                                  |
  [0x0017aae8] addiu r29,r29,0x0048
+
  0017aa78: 16400005 bne r18,r0,0x8017aa90                {{f/Cond|<nowiki>If Ability Range = 0x00</nowiki>}}
  [0x0017aaec] jr r31
+
  0017aa7c: 30620020 andi r2,r3,0x0020                        |
  [0x0017aaf0] nop
+
0017aa80: 14400003 bne r2,r0,0x8017aa90                      {{f/Cond|If Ability do not have [Weapon Range]}}
 
+
  0017aa84: 00000000 nop                                          |
 
+
0017aa88: 0805eab4 j 0x8017aad0                                  |{{f/loc|Exit}}
Notes
+
0017aa8c: 34020002 ori r2,r0,0x0002                              |{{f/Returns|Return 0x02}}
  j 0x0017aad0
+
                                                      '''Else : Not Auto Target / or Range <>  0x00 or / Weapon Range'''
There are two jumps in this routine that bypass reloading r31. This looks like a mistake to me, because it would just jump right back to this routine once it hits jr r31. Need to investigate the conditions for hitting these jumps...
+
  0017aa90: a7b40012 sh r20,0x0012(r29)                   |{{f/store|Preserve Ability ID}}
 +
0017aa94: 0c05e8a4 jal 0x8017a290                        |{{f/jal|Set_panels_affected_by_ability%3F|Set_panels_affected_by_ability%3F}} {{f/std|Spread Ability Range around Caster Tile}}
 +
0017aa98: 27a40010 addiu r4,r29,0x0010                  |{{f/std|Send Action Data pointer}}
 +
  0017aa9c: 00409821 addu r19,r2,r0                        |{{f/std|Preserve result (Nb of Targeted Tiles)}}
 +
  0017aaa0: 34020002 ori r2,r0,0x0002                      |
 +
  0017aaa4: 16020005 bne r16,r2,0x8017aabc    {{f/Cond|If Ability Type is 0x02 (Item / Weapon inventory/Default)}}
 +
  0017aaa8: 02202021 addu r4,r17,r0                |{{f/std|Send Pointer to caster battle data}}
 +
  0017aaac: 0c05e85b jal 0x8017a16c                |{{f/jal|Calculate_ability_range_with_map_parameters%3F|Calculate_ability_range_with_map_parameters%3F}}
 +
  0017aab0: 324500ff andi r5,r18,0x00ff            |{{f/std|Send range}}
 +
  0017aab4: 00409821 addu r19,r2,r0                |{{f/std|Preserve result (Nb of Targeted Tiles ?)}}
 +
  0017aab8: 34150010 ori r21,r0,0x0010            |{{f/std|Follow Target is forced OFF (this is a reverted flag in Patcher)}}
 +
0017aabc: 16600003 bne r19,r0,0x8017aacc    {{f/Cond|If there is Targetable tiles}} {{f/loc|Exit}} {{f/Returns|Returns 0x01 if  [Follow Target] is OFF else 0x00}} {{f/std|Reverted flag}}
 +
0017aac0: 32a20010 andi r2,r21,0x0010        |
 +
                                              '''Else : no targetable tiles'''
 +
0017aac4: 0805eab4 j 0x8017aad0              |{{f/loc|Exit}} {{f/Returns|Returns 0x03}}
 +
0017aac8: 34020003 ori r2,r0,0x0003
 +
0017aacc: 0002102b sltu r2,r0,r2
 +
0017aad0: 8fbf0040 lw r31,0x0040(r29)
 +
0017aad4: 8fb5003c lw r21,0x003c(r29)
 +
0017aad8: 8fb40038 lw r20,0x0038(r29)
 +
0017aadc: 8fb30034 lw r19,0x0034(r29)
 +
0017aae0: 8fb20030 lw r18,0x0030(r29)
 +
0017aae4: 8fb1002c lw r17,0x002c(r29)
 +
0017aae8: 8fb00028 lw r16,0x0028(r29)
 +
0017aaec: 27bd0048 addiu r29,r29,0x0048
 +
0017aaf0: 03e00008 jr r31
 +
0017aaf4: 00000000 nop
 +
===Notes===
 +
'''Table at 0x80174068'''
 +
Jump addresses for Action menu
 +
 +
    RAM    | Rank  | Action Menu        | Jump Address  |
 +
-----------|-------|--------------------|---------------|
 +
0x80174068 | 0x00  | Default            | 0x8017a95c    |
 +
0x8017406c | 0x01  | Item Inventory    | 0x8017a968    |
 +
0x80174070 | 0x02  | Weapon Inventory  | 0x8017a9a0    |
 +
0x80174074 | 0x03  | Arithmeticks      | 0x8017aa88    |
 +
0x80174078 | 0x04  | Elements          | 0x8017a9b0    |
 +
0x8017407c | 0x05  | Blank              | 0x8017aa44    |
 +
0x80174080 | 0x06  | Monster            | 0x8017a95c    |
 +
0x80174084 | 0x07  | Katana Inventory  | 0x8017a9e4    |
 +
0x80174088 | 0x08  | Attack            | 0x8017aa08    |
 +
0x8017408c | 0x09  | Jump              | 0x8017aa18    |
 +
0x80174090 | 0x0A  | Charge            | 0x8017aa08    |
 +
0x80174094 | 0x0B  | Defend            | 0x8017aa88    |
 +
0x80174098 | 0x0C  | Change Equipment  | 0x8017aa88    |
 +
0x8017409c | 0x0D  | Unknown            | 0x8017aa88    |
 +
0x801740a0 | 0x0E  | Blank              | 0x8017aa88    |
 +
0x801740a4 | 0x0F  | Unknown            | 0x8017aa44    |
 +
===Return locations===
 +
'''BATTLE.BIN'''
 +
  00075238: [[Decide_what_to_do_based_on_skillset/ability_selections%3F]]
 +
  00075568: [[Set_move/act_based_on_skillset]]
 +
  0017e6a0: [[Store_counter_ability%3F]]
 +
  0018f1b4: [[Mimic_ability_setting]]
 +
  00197998: [[Range_Calculation%3F]]
 +
  0019ce74: [[AI_Target_Unit_for_Direct_vs_Arc_Attack_(0019cd9c)]]

Latest revision as of 12:58, 4 June 2024

BATTLE.BIN :  - Set_Target_Tiles        Alternate Version by Glain : Calculate_Target_Panels
------------------------------------------------------------------------------------------
Parameter : r4 Pointer to Action Data (Battle 0x16e model)
Return : r2 = 0x00 if there are tiles to target and Ability can [Follow Target]
         r2 = 0x01 if there are tiles to target and Ability cannot [Follow Target]
         r2 = 0x03 if there are no tiles to target
         r2 = 0x02 if unhandled situation (action menu or  ranged weapon auto-target with range 0)
         r2 = -0x01 if invalid situation (action menu, Ids)
------------------------------------------------------------------------------------------
0017a8c0: 27bdffb8 addiu r29,r29,-0x0048     |
0017a8c4: 27a50010 addiu r5,r29,0x0010       |Stack 0x10
0017a8c8: afbf0040 sw r31,0x0040(r29)        |
0017a8cc: afb5003c sw r21,0x003c(r29)        |
0017a8d0: afb40038 sw r20,0x0038(r29)        |
0017a8d4: afb30034 sw r19,0x0034(r29)        |
0017a8d8: afb20030 sw r18,0x0030(r29)        |
0017a8dc: afb1002c sw r17,0x002c(r29)        |
0017a8e0: 0c01788b jal 0x8005e22c            |-->Copy_Byte_Data_(20_Bytes) From r4 to r5 
0017a8e4: afb00028 sw r16,0x0028(r29)        |
0017a8e8: 93a30010 lbu r3,0x0010(r29)        |Unit ID
0017a8ec: 00000000 nop                       |
0017a8f0: 2c620015 sltiu r2,r3,0x0015        |
0017a8f4: 10400053 beq r2,r0,0x8017aa44      #If Unit ID is invalid Exit returns -0x01
0017a8f8: 00008021 addu r16,r0,r0            |Default Action menu type Type  (inner routine variable)
0017a8fc: 000310c0 sll r2,r3,0x03            |
0017a900: 00431023 subu r2,r2,r3             |
0017a904: 00021180 sll r2,r2,0x06            |Unit ID * 0x1c0
0017a908: 3c038019 lui r3,0x8019             |
0017a90c: 246308cc addiu r3,r3,0x08cc        |Pointer to Unit Battle data
0017a910: 00438821 addu r17,r2,r3            |
0017a914: 92230001 lbu r3,0x0001(r17)        |Unit Battle ID
0017a918: 340200ff ori r2,r0,0x00ff          |
0017a91c: 1062006c beq r3,r2,0x8017aad0      #If Unit do not Exist anymore  Exit returns -0x01
0017a920: 2402ffff addiu r2,r0,-0x0001       |
0017a924: 93a20011 lbu r2,0x0011(r29)        |Considered Ability's Skillset ID
0017a928: 3c018006 lui r1,0x8006             |
0017a92c: 00220821 addu r1,r1,r2             |
0017a930: 90235cb4 lbu r3,0x5cb4(r1)         |Considered Skillset Action Menu 0x80065cb4 + Skillset offset
0017a934: 00000000 nop                       |
0017a938: 2c620010 sltiu r2,r3,0x0010        |
0017a93c: 10400052 beq r2,r0,0x8017aa88      #If Considered Action Menu > 0x0f Exit returns 0x02
0017a940: 00031080 sll r2,r3,0x02            |Action menu offset (word)
0017a944: 3c018017 lui r1,0x8017             |
0017a948: 00220821 addu r1,r1,r2             |
0017a94c: 8c224068 lw r2,0x4068(r1)          |Jump loaction based on action menu
0017a950: 00000000 nop                       |
0017a954: 00400008 jr r2                     >>Jump to Action menu dedicated location
0017a958: 00000000 nop                       |

Default / Monster
0017a95c: 97b40012 lhu r20,0x0012(r29)       |Considered Ability ID
0017a960: 0805ea8a j 0x8017aa28              >>Avoid other Action menu sections
0017a964: 34100001 ori r16,r0,0x0001         |Set type = 0x1

Item Inventory
0017a968: 92220091 lbu r2,0x0091(r17)        |Considered Unit Support 3
0017a96c: 00000000 nop                       |
0017a970: 30420008 andi r2,r2,0x0008         |
0017a974: 14400005 bne r2,r0,0x8017a98c      #If Unit  use [Throw Item] : branch to
0017a978: 34120004 ori r18,r0,0x0004         |Range = 0x4
0017a97c: 92230003 lbu r3,0x0003(r17)        |Unit Job
0017a980: 3402005d ori r2,r0,0x005d          |
0017a984: 14620003 bne r3,r2,0x8017a994      #If Unit is not a mime : branch to
0017a988: 00000000 nop                           |
                                            Throw item or Mime (range = 0x4)
0017a98c: 0805ea8a j 0x8017aa28                  >>Avoid other Action menu sections
0017a990: 34100002 ori r16,r0,0x0002             |Type = 0x02
                                            Not Throw item nor Mime (range = 0x1)
0017a994: 34120001 ori r18,r0,0x0001             |range = 0x1
0017a998: 0805ea8a j 0x8017aa28                  >>Avoid other Action menu sections
0017a99c: 34100002 ori r16,r0,0x0002             |Type = 0x02

Weapon Inventory
0017a9a0: 9222003a lbu r2,0x003a(r17)        |Unit move
0017a9a4: 34100002 ori r16,r0,0x0002         |Type = 0x02
0017a9a8: 0805ea8a j 0x8017aa28              >>Avoid other Action menu sections
0017a9ac: 34520080 ori r18,r2,0x0080         |Range = Move  with flag 0x80

Elements
0017a9b0: 0c060428 jal 0x801810a0            |-->Map_Location_Calculation Returns unit Tile ID
0017a9b4: 02202021 addu r4,r17,r0            |Send Unit battle pointer
0017a9b8: 000210c0 sll r2,r2,0x03            |
0017a9bc: 3c018019 lui r1,0x8019             |
0017a9c0: 00220821 addu r1,r1,r2             |
0017a9c4: 9022f8cc lbu r2,-0x0734(r1)        |Unit Tile Type 0x8018f8cc + Tile offset
0017a9c8: 00000000 nop                       |
0017a9cc: 3042003f andi r2,r2,0x003f         |keep only tile type
0017a9d0: 3c018006 lui r1,0x8006             |
0017a9d4: 00220821 addu r1,r1,r2             |
0017a9d8: 9034e9d0 lbu r20,-0x1630(r1)       |Ability ID based on Terrain 0x8005e9d0 + Terrain offset Geomancy_tiles_type_to_ability_table
0017a9dc: 0805ea8a j 0x8017aa28              >>Avoid other Action menu sections
0017a9e0: 34100001 ori r16,r0,0x0001         |Type = 0x01

katana inventory
0017a9e4: 93a20018 lbu r2,0x0018(r29)        |Ability used item ID
0017a9e8: 00000000 nop                       |
0017a9ec: 2442ffda addiu r2,r2,-0x0026       |Ability - 0x26
0017a9f0: 2c42000a sltiu r2,r2,0x000a        |Hardcoded check Ability to item (max 10 abilities)
0017a9f4: 10400013 beq r2,r0,0x8017aa44      #If Ability and katanas are mismatching Exit  Returns -0x01
0017a9f8: 34100001 ori r16,r0,0x0001         |Type = 0x1
0017a9fc: 93a20018 lbu r2,0x0018(r29)        |Ability used item ID
0017aa00: 0805ea8a j 0x8017aa28              >>Avoid other Action menu sections
0017aa04: 24540026 addiu r20,r2,0x0026       |Ability ID = katana ID - 0x26

Attack / Charge
0017aa08: 0c05e946 jal 0x8017a518            |-->Set_targeting_for_weapon_attack_2
0017aa0c: 27a40010 addiu r4,r29,0x0010       |Send Action pointer
0017aa10: 0805ea89 j 0x8017aa24              >>Avoid other Action menu sections  Follow Target will be forced OFF (this is a reverted flag in Patcher)
0017aa14: 00409821 addu r19,r2,r0            |Preserve results (0 if no Tiles to target ?)

Jump
0017aa18: 0c05e772 jal 0x80179dc8            |-->Set_Jump_Ability_Targeting
0017aa1c: 27a40010 addiu r4,r29,0x0010       |Send Action pointer
0017aa20: 00409821 addu r19,r2,r0            |Preserve results (0 if no Tiles to target ?)
0017aa24: 34150010 ori r21,r0,0x0010         |Follow Target is forced OFF (this is a reverted flag in Patcher)

--- POST ACTION MENU SECTION ---
0017aa28: 34020001 ori r2,r0,0x0001          |
0017aa2c: 1602001d bne r16,r2,0x8017aaa4     #If Type is 0x01 (default / monster /Geomancy / Katana)
0017aa30: 34020002 ori r2,r0,0x0002              |
0017aa34: 3283ffff andi r3,r20,0xffff            |Ability ID
0017aa38: 2c620170 sltiu r2,r3,0x0170            |
0017aa3c: 14400003 bne r2,r0,0x8017aa4c          #If Ability do not have a data 2 Table
0017aa40: 000310c0 sll r2,r3,0x03                    |
0017aa44: 0805eab4 j 0x8017aad0                      |Exit  Returns -0x01
0017aa48: 2402ffff addiu r2,r0,-0x0001               |
                                                 Else : Ability has a data 2 table
0017aa4c: 00431023 subu r2,r2,r3                     |
0017aa50: 00021040 sll r2,r2,0x01                    |
0017aa54: 3c038006 lui r3,0x8006                     |
0017aa58: 2463fbf0 addiu r3,r3,-0x0410               |0x8005fbf0
0017aa5c: 00431021 addu r2,r2,r3                     |Pointer to Ability data 2
0017aa60: 90520000 lbu r18,0x0000(r2)                |Ability Range
0017aa64: 90430003 lbu r3,0x0003(r2)                 |Ability Flags 1
0017aa68: 90550004 lbu r21,0x0004(r2)                |Ability Flags 2
0017aa6c: 30620002 andi r2,r3,0x0002                 |
0017aa70: 10400007 beq r2,r0,0x8017aa90              #If Ability has [Auto Target]
0017aa74: 00000000 nop                                   |
0017aa78: 16400005 bne r18,r0,0x8017aa90                 #If Ability Range = 0x00
0017aa7c: 30620020 andi r2,r3,0x0020                         |
0017aa80: 14400003 bne r2,r0,0x8017aa90                      #If Ability do not have  [Weapon Range]
0017aa84: 00000000 nop                                           |
0017aa88: 0805eab4 j 0x8017aad0                                  |Exit
0017aa8c: 34020002 ori r2,r0,0x0002                              |Return 0x02
                                                     Else : Not Auto Target / or Range <>  0x00 or / Weapon Range
0017aa90: a7b40012 sh r20,0x0012(r29)                    |Preserve Ability ID
0017aa94: 0c05e8a4 jal 0x8017a290                        |-->Set_panels_affected_by_ability%3F Spread Ability Range around Caster Tile
0017aa98: 27a40010 addiu r4,r29,0x0010                   |Send Action Data pointer
0017aa9c: 00409821 addu r19,r2,r0                        |Preserve result (Nb of Targeted Tiles)
0017aaa0: 34020002 ori r2,r0,0x0002                      |
0017aaa4: 16020005 bne r16,r2,0x8017aabc     #If Ability Type is 0x02 (Item / Weapon inventory/Default)
0017aaa8: 02202021 addu r4,r17,r0                |Send Pointer to caster battle data
0017aaac: 0c05e85b jal 0x8017a16c                |-->Calculate_ability_range_with_map_parameters%3F
0017aab0: 324500ff andi r5,r18,0x00ff            |Send range
0017aab4: 00409821 addu r19,r2,r0                |Preserve result (Nb of Targeted Tiles ?)
0017aab8: 34150010 ori r21,r0,0x0010             |Follow Target is forced OFF (this is a reverted flag in Patcher)
0017aabc: 16600003 bne r19,r0,0x8017aacc     #If there is Targetable tiles Exit Returns 0x01 if  [Follow Target] is OFF else 0x00 Reverted flag
0017aac0: 32a20010 andi r2,r21,0x0010        |
                                             Else : no targetable tiles
0017aac4: 0805eab4 j 0x8017aad0              |Exit Returns 0x03
0017aac8: 34020003 ori r2,r0,0x0003
0017aacc: 0002102b sltu r2,r0,r2
0017aad0: 8fbf0040 lw r31,0x0040(r29)
0017aad4: 8fb5003c lw r21,0x003c(r29)
0017aad8: 8fb40038 lw r20,0x0038(r29)
0017aadc: 8fb30034 lw r19,0x0034(r29)
0017aae0: 8fb20030 lw r18,0x0030(r29)
0017aae4: 8fb1002c lw r17,0x002c(r29)
0017aae8: 8fb00028 lw r16,0x0028(r29)
0017aaec: 27bd0048 addiu r29,r29,0x0048
0017aaf0: 03e00008 jr r31
0017aaf4: 00000000 nop

Notes

Table at 0x80174068

Jump addresses for Action menu

    RAM    | Rank  | Action Menu        | Jump Address  |
-----------|-------|--------------------|---------------|
0x80174068 | 0x00  | Default            | 0x8017a95c    |
0x8017406c | 0x01  | Item Inventory     | 0x8017a968    |
0x80174070 | 0x02  | Weapon Inventory   | 0x8017a9a0    |
0x80174074 | 0x03  | Arithmeticks       | 0x8017aa88    |
0x80174078 | 0x04  | Elements           | 0x8017a9b0    |
0x8017407c | 0x05  | Blank              | 0x8017aa44    |
0x80174080 | 0x06  | Monster            | 0x8017a95c    |
0x80174084 | 0x07  | Katana Inventory   | 0x8017a9e4    |
0x80174088 | 0x08  | Attack             | 0x8017aa08    |
0x8017408c | 0x09  | Jump               | 0x8017aa18    |
0x80174090 | 0x0A  | Charge             | 0x8017aa08    |
0x80174094 | 0x0B  | Defend             | 0x8017aa88    |
0x80174098 | 0x0C  | Change Equipment   | 0x8017aa88    |
0x8017409c | 0x0D  | Unknown            | 0x8017aa88    |
0x801740a0 | 0x0E  | Blank              | 0x8017aa88    |
0x801740a4 | 0x0F  | Unknown            | 0x8017aa44    |

Return locations

BATTLE.BIN
 00075238: Decide_what_to_do_based_on_skillset/ability_selections?
 00075568: Set_move/act_based_on_skillset
 0017e6a0: Store_counter_ability?
 0018f1b4: Mimic_ability_setting
 00197998: Range_Calculation?
 0019ce74: AI_Target_Unit_for_Direct_vs_Arc_Attack_(0019cd9c)