Difference between revisions of "Throw Ability & Item Loading"

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
(Created page with "<font face='Courier New'> 00181cdc: 27bdff10 addiu r29,r29,0xff10 00181ce0: afb100cc sw r17,0x00cc(r29) 00181ce4: 00808821 addu r17,r4,r0 00181ce8: afb400d8 sw r20,0x00d...")
 
m (Talcall moved page 00181cdc - 00181eec to Throw Ability & Item Loading: I figured out what do.)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
<font face='Courier New'>
 
<font face='Courier New'>
 
   
 
   
  00181cdc: 27bdff10 addiu r29,r29,0xff10
+
  00181cdc: 27bdff10 addiu r29,r29,0xff10 #stack - 0xf0
 +
0x20 - 0x40: Ability IDs
 +
0x48 - 0x58: Ability's used Item type IDs
 +
0x60 - 0x70: MP cost per ability
 +
0x78 - 0x88: Raw CT
 +
0x90 - 0xa0: Silence/performance checks
 +
0xa8 - 0xb8: turns to resolve
 +
0x110 - 0x210: List of Valid Throwable item IDs
 
  00181ce0: afb100cc sw r17,0x00cc(r29)
 
  00181ce0: afb100cc sw r17,0x00cc(r29)
  00181ce4: 00808821 addu r17,r4,r0
+
  00181ce4: 00808821 addu r17,r4,r0 #unit battle ID
 
  00181ce8: afb400d8 sw r20,0x00d8(r29)
 
  00181ce8: afb400d8 sw r20,0x00d8(r29)
  00181cec: 00c0a021 addu r20,r6,r0
+
  00181cec: 00c0a021 addu r20,r6,r0 #stack + 0x110 (Valid Item IDs for Throw in a list, 0x110 - 0x210. lots of room when at most, 0x80 items could appear in vanilla.)
 
  00181cf0: afb500dc sw r21,0x00dc(r29)
 
  00181cf0: afb500dc sw r21,0x00dc(r29)
 
  00181cf4: 0000a821 addu r21,r0,r0
 
  00181cf4: 0000a821 addu r21,r0,r0
Line 14: Line 21:
 
  00181d08: afb600e0 sw r22,0x00e0(r29)
 
  00181d08: afb600e0 sw r22,0x00e0(r29)
 
  00181d0c: afb300d4 sw r19,0x00d4(r29)
 
  00181d0c: afb300d4 sw r19,0x00d4(r29)
  00181d10: 0c060435 jal 0x001810d4
+
  00181d10: 0c060435 jal 0x001810d4 #get Unit battle data pointer
 
  00181d14: afb200d0 sw r18,0x00d0(r29)
 
  00181d14: afb200d0 sw r18,0x00d0(r29)
  00181d18: 0040b021 addu r22,r2,r0
+
  00181d18: 0040b021 addu r22,r2,r0 #r22 = unit data pointer
  00181d1c: 16c00003 bne r22,r0,0x00181d2c
+
  00181d1c: 16c00003 bne r22,r0,0x00181d2c #
  00181d20: 320300ff andi r3,r16,0x00ff
+
  00181d20: 320300ff andi r3,r16,0x00ff |
  00181d24: 080607b0 j 0x00181ec0
+
  00181d24: 080607b0 j 0x00181ec0 |If Unit data pointer is invalid, End
  00181d28: 00001021 addu r2,r0,r0
+
  00181d28: 00001021 addu r2,r0,r0 |return 0
  00181d2c: 34020014 ori r2,r0,0x0014
+
  00181d2c: 34020014 ori r2,r0,0x0014 #
  00181d30: 14620010 bne r3,r2,0x00181d74
+
  00181d30: 14620010 bne r3,r2,0x00181d74 #branch if ? is 0x20
 
  00181d34: 340200ff ori r2,r0,0x00ff
 
  00181d34: 340200ff ori r2,r0,0x00ff
  00181d38: 02202021 addu r4,r17,r0
+
  00181d38: 02202021 addu r4,r17,r0 #unit battle ID back in r4
 
  00181d3c: 34050014 ori r5,r0,0x0014
 
  00181d3c: 34050014 ori r5,r0,0x0014
  00181d40: 27a60020 addiu r6,r29,0x0020
+
  00181d40: 27a60020 addiu r6,r29,0x0020 #r6 = Ability ID pointer (halfword per ability, 0x20 spaces in stack)
  00181d44: 27a20078 addiu r2,r29,0x0078
+
  00181d44: 27a20078 addiu r2,r29,0x0078 #stack address + 0x78 (points to CT cost)
  00181d48: afa20010 sw r2,0x0010(r29)
+
  00181d48: afa20010 sw r2,0x0010(r29) #store CT cost in stack pointer to stack
  00181d4c: 27a20090 addiu r2,r29,0x0090
+
  00181d4c: 27a20090 addiu r2,r29,0x0090 #stack pointer + 0x90
  00181d50: afa20018 sw r2,0x0018(r29)
+
  00181d50: afa20018 sw r2,0x0018(r29) #parse stack + 0x90 (silence + performance per ability)
  00181d54: 27a200a8 addiu r2,r29,0x00a8
+
  00181d54: 27a200a8 addiu r2,r29,0x00a8 #
  00181d58: 27a70060 addiu r7,r29,0x0060
+
  00181d58: 27a70060 addiu r7,r29,0x0060 #r7 = MP cost per ability pointer (byte per ability)
  00181d5c: afa00014 sw r0,0x0014(r29)
+
  00181d5c: afa00014 sw r0,0x0014(r29) #store 0 at 0x14 in stack
  00181d60: 0c0605f0 jal 0x001817c0
+
  00181d60: 0c0605f0 jal 0x001817c0 # --> [[Load ability data for skillset]]
  00181d64: afa2001c sw r2,0x001c(r29)
+
  00181d64: afa2001c sw r2,0x001c(r29) #store stack address + 0xa8 (#turns before resolution per ability)
  00181d68: 00409021 addu r18,r2,r0
+
  00181d68: 00409021 addu r18,r2,r0 #r18 = No. abilities in skillset
  00181d6c: 16400004 bne r18,r0,0x00181d80
+
  00181d6c: 16400004 bne r18,r0,0x00181d80 #branch if No. abilities is not 0
 
  00181d70: 340200ff ori r2,r0,0x00ff
 
  00181d70: 340200ff ori r2,r0,0x00ff
  00181d74: a2820000 sb r2,0x0000(r20)
+
  00181d74: a2820000 sb r2,0x0000(r20) #store ff to 0x110 in stack?
 
  00181d78: 080607b0 j 0x00181ec0
 
  00181d78: 080607b0 j 0x00181ec0
  00181d7c: 00001021 addu r2,r0,r0
+
  00181d7c: 00001021 addu r2,r0,r0 #END return 0
  00181d80: 02b2102a slt r2,r21,r18
+
  00181d80: 02b2102a slt r2,r21,r18 #r2 = true if No. abilities > r21
  00181d84: 10400018 beq r2,r0,0x00181de8
+
  00181d84: 10400018 beq r2,r0,0x00181de8 #if No. abilities > r21
 
  00181d88: 00008821 addu r17,r0,r0
 
  00181d88: 00008821 addu r17,r0,r0
  00181d8c: 3407fe82 ori r7,r0,0xfe82
+
  00181d8c: 3407fe82 ori r7,r0,0xfe82 #r7 = -0x017e (shuriken)
 
  00181d90: 3c068006 lui r6,0x8006
 
  00181d90: 3c068006 lui r6,0x8006
 
  00181d94: 24c61020 addiu r6,r6,0x1020
 
  00181d94: 24c61020 addiu r6,r6,0x1020
  00181d98: 27a50048 addiu r5,r29,0x0048
+
  00181d98: 27a50048 addiu r5,r29,0x0048 #0x48 stack pointer
  00181d9c: 27a40020 addiu r4,r29,0x0020
+
  00181d9c: 27a40020 addiu r4,r29,0x0020 #Ability ID stack pointer
  00181da0: 94830000 lhu r3,0x0000(r4)
+
  00181da0: 94830000 lhu r3,0x0000(r4) #load ability ID
 
  00181da4: 00000000 nop
 
  00181da4: 00000000 nop
  00181da8: 00671021 addu r2,r3,r7
+
  00181da8: 00671021 addu r2,r3,r7 #ability ID - 0x017e (shuriken)
 
  00181dac: 3042ffff andi r2,r2,0xffff
 
  00181dac: 3042ffff andi r2,r2,0xffff
  00181db0: 2c42000c sltiu r2,r2,0x000c
+
  00181db0: 2c42000c sltiu r2,r2,0x000c #set if ability is in throw hardcoded range
  00181db4: 10400008 beq r2,r0,0x00181dd8
+
  00181db4: 10400008 beq r2,r0,0x00181dd8 #Next Ability ID
  00181db8: 24840002 addiu r4,r4,0x0002
+
  00181db8: 24840002 addiu r4,r4,0x0002 #If Shuriken <= Ability ID <= Bomb (else branch)
  00181dbc: 2462fe82 addiu r2,r3,0xfe82
+
  00181dbc: 2462fe82 addiu r2,r3,0xfe82 #r2 = ID -0x017e
 
  00181dc0: 00021400 sll r2,r2,0x10
 
  00181dc0: 00021400 sll r2,r2,0x10
 
  00181dc4: 00021403 sra r2,r2,0x10
 
  00181dc4: 00021403 sra r2,r2,0x10
  00181dc8: 00461021 addu r2,r2,r6
+
  00181dc8: 00461021 addu r2,r2,r6 #80061020 + throw ID
  00181dcc: 90420000 lbu r2,0x0000(r2)
+
  00181dcc: 90420000 lbu r2,0x0000(r2) #load throw Item Type ID
 
  00181dd0: 00000000 nop
 
  00181dd0: 00000000 nop
  00181dd4: a0a20000 sb r2,0x0000(r5)
+
  00181dd4: a0a20000 sb r2,0x0000(r5) #save Throw Item Type ID to 0x48 stack
  00181dd8: 26310001 addiu r17,r17,0x0001
+
  00181dd8: 26310001 addiu r17,r17,0x0001 #counter + 1
  00181ddc: 0232102a slt r2,r17,r18
+
  00181ddc: 0232102a slt r2,r17,r18 #r2 = true if counter <> No. Abilities in skillset
  00181de0: 1440ffef bne r2,r0,0x00181da0
+
  00181de0: 1440ffef bne r2,r0,0x00181da0 #loop No. Abilities in skillset times
  00181de4: 24a50001 addiu r5,r5,0x0001
+
  00181de4: 24a50001 addiu r5,r5,0x0001 #0x48 stack + 1
  00181de8: 00008821 addu r17,r0,r0
+
  00181de8: 00008821 addu r17,r0,r0 #Item ID counter
  00181dec: 27b70048 addiu r23,r29,0x0048
+
  00181dec: 27b70048 addiu r23,r29,0x0048 #0x48 stack pointer
  00181df0: 00009821 addu r19,r0,r0
+
  00181df0: 00009821 addu r19,r0,r0 #Item table counter
 
  00181df4: 3c028006 lui r2,0x8006
 
  00181df4: 3c028006 lui r2,0x8006
  00181df8: 24422eb8 addiu r2,r2,0x2eb8
+
  00181df8: 24422eb8 addiu r2,r2,0x2eb8 #item data start
  00181dfc: 02623021 addu r6,r19,r2
+
  00181dfc: 02623021 addu r6,r19,r2 #r6 = item's data pointer
  00181e00: 90c20005 lbu r2,0x0005(r6)
+
  00181e00: 90c20005 lbu r2,0x0005(r6) #load item type
  00181e04: 1a40000e blez r18,0x00181e40
+
  00181e04: 1a40000e blez r18,0x00181e40 #branch if No. Abilities < 0 (constant error check :why:)
  00181e08: 00002021 addu r4,r0,r0
+
  00181e08: 00002021 addu r4,r0,r0 #r4 = 0
  00181e0c: 304700ff andi r7,r2,0x00ff
+
  00181e0c: 304700ff andi r7,r2,0x00ff #redundant
  00181e10: 02e01821 addu r3,r23,r0
+
  00181e10: 02e01821 addu r3,r23,r0 #r3 = 0x48 stack pointer
  00181e14: 02432821 addu r5,r18,r3
+
  00181e14: 02432821 addu r5,r18,r3 #stack pointer + No. Abilities
  00181e18: 90620000 lbu r2,0x0000(r3)
+
  00181e18: 90620000 lbu r2,0x0000(r3) #load ability's used Item ID
 
  00181e1c: 00000000 nop
 
  00181e1c: 00000000 nop
  00181e20: 14e20003 bne r7,r2,0x00181e30
+
  00181e20: 14e20003 bne r7,r2,0x00181e30 #if item's item type = used item type
 
  00181e24: 00000000 nop
 
  00181e24: 00000000 nop
  00181e28: 08060790 j 0x00181e40
+
  00181e28: 08060790 j 0x00181e40 #skip forward
  00181e2c: 34040001 ori r4,r0,0x0001
+
  00181e2c: 34040001 ori r4,r0,0x0001 #r4 = 1
  00181e30: 24630001 addiu r3,r3,0x0001
+
  00181e30: 24630001 addiu r3,r3,0x0001 #0x48 stack pointer + 1 (if item's item type <> used item type)
  00181e34: 0065102a slt r2,r3,r5
+
  00181e34: 0065102a slt r2,r3,r5 #r2 is true if 0x48 stack pointer <> final ability's 0x48 stack pointer
  00181e38: 1440fff7 bne r2,r0,0x00181e18
+
  00181e38: 1440fff7 bne r2,r0,0x00181e18 #loop if so
 
  00181e3c: 00000000 nop
 
  00181e3c: 00000000 nop
  00181e40: 10800019 beq r4,r0,0x00181ea8
+
  00181e40: 10800019 beq r4,r0,0x00181ea8 #branch if there are no valid abilities for the weapon?
  00181e44: 2673000c addiu r19,r19,0x000c
+
  00181e44: 2673000c addiu r19,r19,0x000c #counter + c (item data table length)
  00181e48: 90c20003 lbu r2,0x0003(r6)
+
  00181e48: 90c20003 lbu r2,0x0003(r6) #Item type flags (wear slot)
 
  00181e4c: 00000000 nop
 
  00181e4c: 00000000 nop
  00181e50: 30420080 andi r2,r2,0x0080
+
  00181e50: 30420080 andi r2,r2,0x0080 #weapon
  00181e54: 10400014 beq r2,r0,0x00181ea8
+
  00181e54: 10400014 beq r2,r0,0x00181ea8 #branch if not even a weapon lol noob.
 
  00181e58: 00000000 nop
 
  00181e58: 00000000 nop
  00181e5c: 90c20004 lbu r2,0x0004(r6)
+
  00181e5c: 90c20004 lbu r2,0x0004(r6) #second table ID
 
  00181e60: 00000000 nop
 
  00181e60: 00000000 nop
  00181e64: 000210c0 sll r2,r2,0x03
+
  00181e64: 000210c0 sll r2,r2,0x03
 
  00181e68: 3c018006 lui r1,0x8006
 
  00181e68: 3c018006 lui r1,0x8006
 
  00181e6c: 00220821 addu r1,r1,r2
 
  00181e6c: 00220821 addu r1,r1,r2
  00181e70: 90223ab9 lbu r2,0x3ab9(r1)
+
  00181e70: 90223ab9 lbu r2,0x3ab9(r1) #load item's attack flags
 
  00181e74: 00000000 nop
 
  00181e74: 00000000 nop
  00181e78: 30420002 andi r2,r2,0x0002
+
  00181e78: 30420002 andi r2,r2,0x0002 #throwable
  00181e7c: 1040000a beq r2,r0,0x00181ea8
+
  00181e7c: 1040000a beq r2,r0,0x00181ea8 #branch if not throwable
  00181e80: 02c02021 addu r4,r22,r0
+
  00181e80: 02c02021 addu r4,r22,r0 #r4 = unit battle data pointer
  00181e84: 02208021 addu r16,r17,r0
+
  00181e84: 02208021 addu r16,r17,r0 #move r17 counter to r16
  00181e88: 320500ff andi r5,r16,0x00ff
+
  00181e88: 320500ff andi r5,r16,0x00ff #move r17 counter to r5
  00181e8c: 0c05f255 jal 0x0017c954
+
  00181e8c: 0c05f255 jal 0x0017c954 # --> [[Player Item Quantity decrement]]
  00181e90: 00003021 addu r6,r0,r0
+
  00181e90: 00003021 addu r6,r0,r0 #r6 = Don't actually decrement item quantity this is just a check
  00181e94: 14400004 bne r2,r0,0x00181ea8
+
  00181e94: 14400004 bne r2,r0,0x00181ea8 #branch if enemy unit, or if there is none of the item remaining
 
  00181e98: 00000000 nop
 
  00181e98: 00000000 nop
  00181e9c: a2900000 sb r16,0x0000(r20)
+
  00181e9c: a2900000 sb r16,0x0000(r20) #if ally unit with stock left, save Item ID counter to 0x110 in stack
  00181ea0: 26940001 addiu r20,r20,0x0001
+
  00181ea0: 26940001 addiu r20,r20,0x0001 #increase 0x110 stack counter by 1
  00181ea4: 26b50001 addiu r21,r21,0x0001
+
  00181ea4: 26b50001 addiu r21,r21,0x0001 #increase number of valid consumable items by 1
  00181ea8: 26310001 addiu r17,r17,0x0001
+
  00181ea8: 26310001 addiu r17,r17,0x0001 #increase r17 counter by 1
  00181eac: 2a220100 slti r2,r17,0x0100
+
  00181eac: 2a220100 slti r2,r17,0x0100 #set if r17 < 0x0100
  00181eb0: 1440ffd0 bne r2,r0,0x00181df4
+
  00181eb0: 1440ffd0 bne r2,r0,0x00181df4 #loop 0x0100 times
  00181eb4: 340200ff ori r2,r0,0x00ff
+
  00181eb4: 340200ff ori r2,r0,0x00ff #
  00181eb8: a2820000 sb r2,0x0000(r20)
+
  00181eb8: a2820000 sb r2,0x0000(r20) #store invalid item to item 0xff (because it doesn't exist lol)
  00181ebc: 26a20100 addiu r2,r21,0x0100
+
  00181ebc: 26a20100 addiu r2,r21,0x0100 #r2 = number of valid consumable items + 0x100
 
  00181ec0: 8fbf00e8 lw r31,0x00e8(r29)
 
  00181ec0: 8fbf00e8 lw r31,0x00e8(r29)
 
  00181ec4: 8fb700e4 lw r23,0x00e4(r29)
 
  00181ec4: 8fb700e4 lw r23,0x00e4(r29)

Latest revision as of 11:28, 17 February 2022

00181cdc: 27bdff10 addiu r29,r29,0xff10		#stack - 0xf0 
	0x20 - 0x40: Ability IDs
	0x48 - 0x58: Ability's used Item type IDs
	0x60 - 0x70: MP cost per ability
	0x78 - 0x88: Raw CT
	0x90 - 0xa0: Silence/performance checks
	0xa8 - 0xb8: turns to resolve
	0x110 - 0x210: List of Valid Throwable item IDs
00181ce0: afb100cc sw r17,0x00cc(r29)
00181ce4: 00808821 addu r17,r4,r0			#unit battle ID
00181ce8: afb400d8 sw r20,0x00d8(r29)
00181cec: 00c0a021 addu r20,r6,r0			#stack + 0x110 (Valid Item IDs for Throw in a list, 0x110 - 0x210. lots of room when at most, 0x80 items could appear in vanilla.)
00181cf0: afb500dc sw r21,0x00dc(r29)
00181cf4: 0000a821 addu r21,r0,r0
00181cf8: afb000c8 sw r16,0x00c8(r29)
00181cfc: 00a08021 addu r16,r5,r0
00181d00: afbf00e8 sw r31,0x00e8(r29)
00181d04: afb700e4 sw r23,0x00e4(r29)
00181d08: afb600e0 sw r22,0x00e0(r29)
00181d0c: afb300d4 sw r19,0x00d4(r29)
00181d10: 0c060435 jal 0x001810d4			#get Unit battle data pointer
00181d14: afb200d0 sw r18,0x00d0(r29)
00181d18: 0040b021 addu r22,r2,r0			#r22 = unit data pointer
00181d1c: 16c00003 bne r22,r0,0x00181d2c		#
00181d20: 320300ff andi r3,r16,0x00ff				|
00181d24: 080607b0 j 0x00181ec0				|If Unit data pointer is invalid, End
00181d28: 00001021 addu r2,r0,r0				|return 0
00181d2c: 34020014 ori r2,r0,0x0014			#
00181d30: 14620010 bne r3,r2,0x00181d74		#branch if ? is 0x20
00181d34: 340200ff ori r2,r0,0x00ff
00181d38: 02202021 addu r4,r17,r0			#unit battle ID back in r4
00181d3c: 34050014 ori r5,r0,0x0014
00181d40: 27a60020 addiu r6,r29,0x0020			#r6 = Ability ID pointer (halfword per ability, 0x20 spaces in stack)
00181d44: 27a20078 addiu r2,r29,0x0078			#stack address + 0x78 (points to CT cost)
00181d48: afa20010 sw r2,0x0010(r29)			#store CT cost in stack pointer to stack 
00181d4c: 27a20090 addiu r2,r29,0x0090			#stack pointer + 0x90
00181d50: afa20018 sw r2,0x0018(r29)			#parse stack + 0x90 (silence + performance per ability)
00181d54: 27a200a8 addiu r2,r29,0x00a8			#
00181d58: 27a70060 addiu r7,r29,0x0060			#r7 = MP cost per ability pointer (byte per ability)
00181d5c: afa00014 sw r0,0x0014(r29)			#store 0 at 0x14 in stack
00181d60: 0c0605f0 jal 0x001817c0			# --> Load ability data for skillset
00181d64: afa2001c sw r2,0x001c(r29)			#store stack address + 0xa8 (#turns before resolution per ability)
00181d68: 00409021 addu r18,r2,r0			#r18 = No. abilities in skillset
00181d6c: 16400004 bne r18,r0,0x00181d80		#branch if No. abilities is not 0
00181d70: 340200ff ori r2,r0,0x00ff
00181d74: a2820000 sb r2,0x0000(r20)			#store ff to 0x110 in stack?
00181d78: 080607b0 j 0x00181ec0
00181d7c: 00001021 addu r2,r0,r0			#END return 0
00181d80: 02b2102a slt r2,r21,r18			#r2 = true if No. abilities > r21
00181d84: 10400018 beq r2,r0,0x00181de8		#if No. abilities > r21
00181d88: 00008821 addu r17,r0,r0
00181d8c: 3407fe82 ori r7,r0,0xfe82				#r7 = -0x017e (shuriken)
00181d90: 3c068006 lui r6,0x8006
00181d94: 24c61020 addiu r6,r6,0x1020
00181d98: 27a50048 addiu r5,r29,0x0048				#0x48 stack pointer
00181d9c: 27a40020 addiu r4,r29,0x0020				#Ability ID stack pointer
00181da0: 94830000 lhu r3,0x0000(r4)				#load ability ID
00181da4: 00000000 nop
00181da8: 00671021 addu r2,r3,r7				#ability ID - 0x017e (shuriken)
00181dac: 3042ffff andi r2,r2,0xffff
00181db0: 2c42000c sltiu r2,r2,0x000c				#set if ability is in throw hardcoded range
00181db4: 10400008 beq r2,r0,0x00181dd8			#Next Ability ID
00181db8: 24840002 addiu r4,r4,0x0002				#If Shuriken <= Ability ID <= Bomb (else branch)
00181dbc: 2462fe82 addiu r2,r3,0xfe82					#r2 = ID -0x017e
00181dc0: 00021400 sll r2,r2,0x10
00181dc4: 00021403 sra r2,r2,0x10
00181dc8: 00461021 addu r2,r2,r6					#80061020 + throw ID
00181dcc: 90420000 lbu r2,0x0000(r2)					#load throw Item Type ID
00181dd0: 00000000 nop
00181dd4: a0a20000 sb r2,0x0000(r5)					#save Throw Item Type ID to 0x48 stack
00181dd8: 26310001 addiu r17,r17,0x0001			#counter + 1
00181ddc: 0232102a slt r2,r17,r18				#r2 = true if counter <> No. Abilities in skillset
00181de0: 1440ffef bne r2,r0,0x00181da0			#loop No. Abilities in skillset times
00181de4: 24a50001 addiu r5,r5,0x0001				#0x48 stack + 1
00181de8: 00008821 addu r17,r0,r0			#Item ID counter
00181dec: 27b70048 addiu r23,r29,0x0048		#0x48 stack pointer
00181df0: 00009821 addu r19,r0,r0			#Item table counter
00181df4: 3c028006 lui r2,0x8006
00181df8: 24422eb8 addiu r2,r2,0x2eb8			#item data start
00181dfc: 02623021 addu r6,r19,r2			#r6 = item's data pointer
00181e00: 90c20005 lbu r2,0x0005(r6)			#load item type
00181e04: 1a40000e blez r18,0x00181e40			#branch if No. Abilities < 0 (constant error check :why:)
00181e08: 00002021 addu r4,r0,r0			#r4 = 0
00181e0c: 304700ff andi r7,r2,0x00ff			#redundant
00181e10: 02e01821 addu r3,r23,r0			#r3 = 0x48 stack pointer
00181e14: 02432821 addu r5,r18,r3			#stack pointer + No. Abilities
00181e18: 90620000 lbu r2,0x0000(r3)			#load ability's used Item ID
00181e1c: 00000000 nop
00181e20: 14e20003 bne r7,r2,0x00181e30		#if item's item type = used item type
00181e24: 00000000 nop
00181e28: 08060790 j 0x00181e40			#skip forward
00181e2c: 34040001 ori r4,r0,0x0001			#r4 = 1
00181e30: 24630001 addiu r3,r3,0x0001			#0x48 stack pointer + 1 (if item's item type <> used item type)
00181e34: 0065102a slt r2,r3,r5			#r2 is true if 0x48 stack pointer <> final ability's 0x48 stack pointer
00181e38: 1440fff7 bne r2,r0,0x00181e18		#loop if so
00181e3c: 00000000 nop
00181e40: 10800019 beq r4,r0,0x00181ea8		#branch if there are no valid abilities for the weapon?
00181e44: 2673000c addiu r19,r19,0x000c		#counter + c (item data table length)
00181e48: 90c20003 lbu r2,0x0003(r6)			#Item type flags (wear slot)
00181e4c: 00000000 nop
00181e50: 30420080 andi r2,r2,0x0080			#weapon
00181e54: 10400014 beq r2,r0,0x00181ea8		#branch if not even a weapon lol noob.
00181e58: 00000000 nop
00181e5c: 90c20004 lbu r2,0x0004(r6)			#second table ID
00181e60: 00000000 nop
00181e64: 000210c0 sll r2,r2,0x03			
00181e68: 3c018006 lui r1,0x8006
00181e6c: 00220821 addu r1,r1,r2
00181e70: 90223ab9 lbu r2,0x3ab9(r1)			#load item's attack flags
00181e74: 00000000 nop
00181e78: 30420002 andi r2,r2,0x0002			#throwable
00181e7c: 1040000a beq r2,r0,0x00181ea8		#branch if not throwable
00181e80: 02c02021 addu r4,r22,r0			#r4 = unit battle data pointer
00181e84: 02208021 addu r16,r17,r0			#move r17 counter to r16
00181e88: 320500ff andi r5,r16,0x00ff			#move r17 counter to r5
00181e8c: 0c05f255 jal 0x0017c954			# --> Player Item Quantity decrement
00181e90: 00003021 addu r6,r0,r0			#r6 = Don't actually decrement item quantity this is just a check
00181e94: 14400004 bne r2,r0,0x00181ea8		#branch if enemy unit, or if there is none of the item remaining
00181e98: 00000000 nop
00181e9c: a2900000 sb r16,0x0000(r20)			#if ally unit with stock left, save Item ID counter to 0x110 in stack
00181ea0: 26940001 addiu r20,r20,0x0001		#increase 0x110 stack counter by 1
00181ea4: 26b50001 addiu r21,r21,0x0001		#increase number of valid consumable items by 1
00181ea8: 26310001 addiu r17,r17,0x0001		#increase r17 counter by 1
00181eac: 2a220100 slti r2,r17,0x0100			#set if r17 < 0x0100
00181eb0: 1440ffd0 bne r2,r0,0x00181df4		#loop 0x0100 times 
00181eb4: 340200ff ori r2,r0,0x00ff			#
00181eb8: a2820000 sb r2,0x0000(r20)			#store invalid item to item 0xff (because it doesn't exist lol)
00181ebc: 26a20100 addiu r2,r21,0x0100			#r2 = number of valid consumable items + 0x100
00181ec0: 8fbf00e8 lw r31,0x00e8(r29)
00181ec4: 8fb700e4 lw r23,0x00e4(r29)
00181ec8: 8fb600e0 lw r22,0x00e0(r29)
00181ecc: 8fb500dc lw r21,0x00dc(r29)
00181ed0: 8fb400d8 lw r20,0x00d8(r29)
00181ed4: 8fb300d4 lw r19,0x00d4(r29)
00181ed8: 8fb200d0 lw r18,0x00d0(r29)
00181edc: 8fb100cc lw r17,0x00cc(r29)
00181ee0: 8fb000c8 lw r16,0x00c8(r29)
00181ee4: 27bd00f0 addiu r29,r29,0x00f0
00181ee8: 03e00008 jr r31
00181eec: 00000000 nop