Get Item Ranking Value

From Final Fantasy Hacktics Wiki
Revision as of 03:55, 26 September 2024 by Pride (talk | contribs)
Jump to navigation Jump to search
# Returns one of the following stats from an item: Weapon Power, HP Bonus, Physical Evade, or Required Level.
# This value is then later used to sort an array of items by descending order to display on the screen (such as the
# shop menu or when seeing the item list when equipping from the party menu.)
# Return values:
#   item type = Weapon: Weapon Power
#   item type = Shield: Physical Evade
#   item type = Headgear: HP Bonus
#   item type = Bodygear: HP Bonus
#   item type = Accessory: Required Level
#   item type = Cannot Equip: Required Level

00121568: 27bdffe8 addiu r29,r29,0xffe8         #
0012156c: afb00010 sw r16,0x0010(r29)           #
00121570: 00808021 addu r16,r4,r0               # item_number = r4
00121574: 00102400 sll r4,r16,0x10              # 
00121578: afbf0014 sw r31,0x0014(r29)           #
0012157c: 0c0494dd jal 0x00125374               # item_type = Get Item Type from Item Number(item_number)
00121580: 00042403 sra r4,r4,0x10               # 
00121584: 12000010 beq r16,r0,0x001215c8        # if item_number == 0: goto 0x001215c8
00121588: 00401821 addu r3,r2,r0                # r3 = item_type
0012158c: 1460000f bne r3,r0,0x001215cc         # if item_type == item_type["weapon"]:
00121590: 34020001 ori r2,r0,0x0001             # 
00121594: 00101040 sll r2,r16,0x01              # 
00121598: 00501021 addu r2,r2,r16               # 
0012159c: 00021080 sll r2,r2,0x02               # 
001215a0: 3c018006 lui r1,0x8006                # 
001215a4: 00220821 addu r1,r1,r2                # 
001215a8: 90222ebc lbu r2,0x2ebc(r1)            #   secondary_id = ITEM_DATA[item_number].secondary_id
001215ac: 00000000 nop                          #
001215b0: 000210c0 sll r2,r2,0x03               #   
001215b4: 3c018006 lui r1,0x8006                # 
001215b8: 00220821 addu r1,r1,r2                # 
001215bc: 90223abc lbu r2,0x3abc(r1)            #   weapon_power = WEAPON_DATA[secondary_id].weapon_power
001215c0: 08048590 j 0x00121640                 #   return weapon_power
001215c4: 00000000 nop                          # 
001215c8: 34020001 ori r2,r0,0x0001             # r2 = 1
001215cc: 1462000e bne r3,r2,0x00121608         # if item_type == item_type["shield"]:
001215d0: 28620004 slti r2,r3,0x0004            # 
001215d4: 00101040 sll r2,r16,0x01              # 
001215d8: 00501021 addu r2,r2,r16               # 
001215dc: 00021080 sll r2,r2,0x02               # 
001215e0: 3c018006 lui r1,0x8006                # 
001215e4: 00220821 addu r1,r1,r2                # 
001215e8: 90222ebc lbu r2,0x2ebc(r1)            #   secondary_id = ITEM_DATA[item_number].secondary_id
001215ec: 00000000 nop                          # 
001215f0: 00021040 sll r2,r2,0x01               # 
001215f4: 3c018006 lui r1,0x8006                # 
001215f8: 00220821 addu r1,r1,r2                # 
001215fc: 90223eb8 lbu r2,0x3eb8(r1)            #   physical_evasion = SHIELD_DATA[secondary_id].p_evade
00121600: 08048590 j 0x00121640                 #   return physical_evasion
00121604: 00000000 nop                          # 
00121608: 10400007 beq r2,r0,0x00121628         # if item_type is less than 0x04:
0012160c: 2602ff70 addiu r2,r16,-0x0090         #   r2 = item_number - 0x90
00121610: 00021040 sll r2,r2,0x01               #   
00121614: 3c018006 lui r1,0x8006                #
00121618: 00220821 addu r1,r1,r2                #
0012161c: 90223ed8 lbu r2,0x3ed8(r1)            #   hp_bonus = HELM_ARMOR_DATA[item_number - 0x90]
00121620: 08048590 j 0x00121640                 #   return hp_bonus
00121624: 00000000 nop                          # 
00121628: 00101040 sll r2,r16,0x01              # 
0012162c: 00501021 addu r2,r2,r16               # 
00121630: 00021080 sll r2,r2,0x02               # 
00121634: 3c018006 lui r1,0x8006                # 
00121638: 00220821 addu r1,r1,r2                # 
0012163c: 90222eba lbu r2,0x2eba(r1)            # return ITEM_DATA[item_number].required_level
00121640: 8fbf0014 lw r31,0x0014(r29)           # 
00121644: 8fb00010 lw r16,0x0010(r29)           # 
00121648: 27bd0018 addiu r29,r29,0x0018         # 
0012164c: 03e00008 jr r31                       # 
00121650: 00000000 nop                          # 

Return Locations

WORLD.bin
00121898: 00121654 - 00121c5c
00121a30: 00121654 - 00121c5c