Store used weapon

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
Parameters : r4 = Attacker 0x16e pointer

Store data at 0x801938d8 (current ability used weapon)
  - By default right or left hand equiped weapon (depend if it's first hit or not)
  - If action menu is item or katana inventory : store attacker used item ID (Attacker 0x0176 - stored in pre formula stack)
  - If Jump or unknown 0x0f : store 0x00 (unarmed)
  - If weapon ID is 0xff : store 0x00 (weapon doesn't exist - flag for off hand with two hand weapon)
-------------------------------------------------------------------------------------------------------------------
0018b274: 3c028019 lui r2,0x8019            |
0018b278: 904238c3 lbu r2,0x38c3(r2)        |r2 =  current action strike counter
0018b27c: 00000000 nop                      |
0018b280: 14400005 bne r2,r0,0x0018b298     #if first strike
0018b284: 00000000 nop                           | 
0018b288: 3c058019 lui r5,0x8019                 | 
0018b28c: 90a538c4 lbu r5,0x38c4(r5)             |r5 = current action right hand weapon
0018b290: 08062ca8 j 0x0018b2a0                  >>jump post left hand section
0018b294: 00000000 nop                           |
0018b298: 3c058019 lui r5,0x8019            #E not first strike
0018b29c: 90a538c5 lbu r5,0x38c5(r5)             |r5 = current action left hand weapon 11
0018b2a0: 90820001 lbu r2,0x0001(r4)        |r2 = attacker last skillset used                                                       
0018b2a4: 3c018006 lui r1,0x8006            |
0018b2a8: 00220821 addu r1,r1,r2            |
0018b2ac: 90235cb4 lbu r3,0x5cb4(r1)        |r3 = last used skillset action menu
0018b2b0: 00000000 nop                      |
0018b2b4: 2c620010 sltiu r2,r3,0x0010       |r2 = 0x01 if action menu is <= 0xf (action menu exist)
0018b2b8: 1040001b beq r2,r0,0x0018b328     #if action menu is valid /Else go to Attack section
0018b2bc: 00031080 sll r2,r3,0x02                |r2 = action menu ID * 4
0018b2c0: 3c018017 lui r1,0x8017                 |
0018b2c4: 00220821 addu r1,r1,r2                 |
0018b2c8: 8c224304 lw r2,0x4304(r1)              |r2 = action menu return adress  -->|Action_menu_return_adress
0018b2cc: 00000000 nop                           |
0018b2d0: 00400008 jr r2                         >>Jump to action menu dedicated section
0018b2d4: 00000000 nop                           |

                                             --- Default / Math skill/ Elemental/ Monster  section---
0018b2d8: 84840002 lh r4,0x0002(r4)              |r4 = Attacker last used ability
0018b2dc: 00000000 nop                           |
0018b2e0: 28820170 slti r2,r4,0x0170             |r2 = 0x01 if ability ID is < Potion
0018b2e4: 10400010 beq r2,r0,0x0018b328          #If ability ID < Potion
0018b2e8: 000410c0 sll r2,r4,0x03                    |r2 = ability ID * 8
0018b2ec: 00441023 subu r2,r2,r4                     |r2 = ability ID * 7
0018b2f0: 00021040 sll r2,r2,0x01                    |r2 = ability ID * 14
0018b2f4: 3c018006 lui r1,0x8006                     |
0018b2f8: 00220821 addu r1,r1,r2                     |
0018b2fc: 9022fbf3 lbu r2,-0x040d(r1)                |r2 = Ability Data 2 flag 1
0018b300: 00000000 nop                               |
0018b304: 30420024 andi r2,r2,0x0024                 |r2 = flag 1 filtered  with weapon strike and  weapon range 
0018b308: 14400008 bne r2,r0,0x0018b32c              #If neither weapon strike nor weapon range is checked /Else branch in attack section
0018b30c: 30a300ff andi r3,r5,0x00ff                 |r3 = weapon ID
0018b310: 08062cca j 0x0018b328                          >>jump in attack section (weapon will be 0x00)
0018b314: 00002821 addu r5,r0,r0                         |r5 = 0x00

                                            --- Item / Katana inventory  section ---
0018b318: 90850008 lbu r5,0x0008(r4)             |r5 =  used item
0018b31c: 08062ccb j 0x0018b32c                  >>jump in attack section (weapon will be used item)
0018b320: 30a300ff andi r3,r5,0x00ff             |r3 = used item

                                            --- Jump / Unknow section
0018b324: 00002821 addu r5,r0,r0                 |r5 = 0x00

                                            ---  Weapon inventory / Attack / Blank / Charge / Defend / Equip change / Unknown / Blank section ---
0018b328: 30a300ff andi r3,r5,0x00ff             |r3 = weapon ID  (or 0x00 if coming from jump at 18b310, used item ID jump from 18b31c)

                                            --- Store weapon section ---
0018b32c: 340200ff ori r2,r0,0x00ff              |r2 = 0xff
0018b330: 14620002 bne r3,r2,0x0018b33c          #if weapon doesn't exist /Else branch keeping r5
0018b334: 00000000 nop                               | 
0018b338: 00002821 addu r5,r0,r0                     |r5 = 0x00 (will be stored as used weapon)
0018b33c: 3c018019 lui r1,0x8019                     |
0018b340: a02538d8 sb r5,0x38d8(r1)              |store r5 as current ability used weapon ID
0018b344: 03e00008 jr r31                        |
0018b348: 00000000 nop                           

Return location

0017d0a4: Main_ability_loading_routine?
0018b414: Pre_Formula_Setup_(FDC)