Finalise Unit's Equips from Formation

From Final Fantasy Hacktics Wiki
(Redirected from 00124428 - 00124578)
Jump to navigation Jump to search

00124428: 27bdffd0 addiu r29,r29,0xffd0
0012442c: 00801821 addu r3,r4,r0			r4 input: current unit formation ID
00124430: 00a03821 addu r7,r5,r0			r5 input: hand to swap equipment into
00124434: 00031400 sll r2,r3,0x10			total nonsense
00124438: afb20018 sw r18,0x0018(r29)
0012443c: 00029403 sra r18,r2,0x10			r18 = ID
00124440: 02402021 addu r4,r18,r0			Current unit's formation ID
00124444: 00071400 sll r2,r7,0x10
00124448: afb10014 sw r17,0x0014(r29)
0012444c: 00028c03 sra r17,r2,0x10			r17 = hand polarity
00124450: 02202821 addu r5,r17,r0			Hand to swap equipment into
00124454: afb40020 sw r20,0x0020(r29)
00124458: 0060a021 addu r20,r3,r0			r20 = ID
0012445c: afb50024 sw r21,0x0024(r29)
00124460: 00e0a821 addu r21,r7,r0			r21 = hand polarity/equip slot?
00124464: 30c603ff andi r6,r6,0x03ff			r6 input: Item to Equip
00124468: afb60028 sw r22,0x0028(r29)
0012446c: 00c0b021 addu r22,r6,r0			r22 = item ID
00124470: afbf002c sw r31,0x002c(r29)
00124474: afb3001c sw r19,0x001c(r29)
00124478: 0c049185 jal 0x00124614			WORLD: 2 H/S Check on Equip check 2 hands/swords. no output for neither, but i imagine sword + fists still displays, 2 hands on the units menu?
0012447c: afb00010 sw r16,0x0010(r29)
00124480: 00408021 addu r16,r2,r0			r16 = 0 (2 hands), 1 (2 swords)
00124484: 06000032 bltz r16,0x00124550			branch if equip is invalid
00124488: 34130014 ori r19,r0,0x0014
0012448c: 12530009 beq r18,r19,0x001244b4		branch if unit ID = 0x14 (I believe this is the... preview unit ID?)
00124490: 00121080 sll r2,r18,0x02
00124494: 3c01801d lui r1,0x801d
00124498: 00220821 addu r1,r1,r2
0012449c: 8c23d5ec lw r3,-0x2a14(r1)			Load unit's formation pointer
001244a0: 00111040 sll r2,r17,0x01
001244a4: 00431021 addu r2,r2,r3			pointer + hand polarity * 2
001244a8: 84440054 lh r4,0x0054(r2)			Load current hand's equip
001244ac: 0c04822e jal 0x001208b8			Change Item Quantity on Equip
001244b0: 34050001 ori r5,r0,0x0001			change item quantity by +1
001244b4: 2a220002 slti r2,r17,0x0002			
001244b8: 10400015 beq r2,r0,0x00124510		branch if slot to equip into is head/chest/accessory
001244bc: 34020001 ori r2,r0,0x0001
001244c0: 12020014 beq r16,r2,0x00124514		Branch if not 2 handing equipment
001244c4: 00141c00 sll r3,r20,0x10			If 2 handing new equipment:
001244c8: 1253000a beq r18,r19,0x001244f4		branch if unit is preview unit
001244cc: 2e300001 sltiu r16,r17,0x0001		opposite hand polarity
001244d0: 00121080 sll r2,r18,0x02			
001244d4: 3c01801d lui r1,0x801d
001244d8: 00220821 addu r1,r1,r2
001244dc: 8c23d5ec lw r3,-0x2a14(r1)			load unit formation pointer
001244e0: 00101040 sll r2,r16,0x01
001244e4: 00431021 addu r2,r2,r3
001244e8: 84440054 lh r4,0x0054(r2)			Load other hand's equip
001244ec: 0c04822e jal 0x001208b8			Change Item Quantity on Equip
001244f0: 34050001 ori r5,r0,0x0001			Change item quantity by +1
001244f4: 00121080 sll r2,r18,0x02
001244f8: 3c01801d lui r1,0x801d
001244fc: 00220821 addu r1,r1,r2
00124500: 8c23d5ec lw r3,-0x2a14(r1)			load unit formation pointer
00124504: 00101040 sll r2,r16,0x01
00124508: 00431021 addu r2,r2,r3
0012450c: a4400054 sh r0,0x0054(r2)			Store no equip in other hand
00124510: 00141c00 sll r3,r20,0x10
00124514: 00031c03 sra r3,r3,0x10			unit ID
00124518: 00032080 sll r4,r3,0x02			ID * 4
0012451c: 00151400 sll r2,r21,0x10
00124520: 3c01801d lui r1,0x801d
00124524: 00240821 addu r1,r1,r4
00124528: 8c24d5ec lw r4,-0x2a14(r1)			Load unit's pointer
0012452c: 000213c3 sra r2,r2,0x0f			Hand polarity * 2
00124530: 00441021 addu r2,r2,r4
00124534: a4560054 sh r22,0x0054(r2)			store new item ID in unit's equip
00124538: 34020014 ori r2,r0,0x0014
0012453c: 10620004 beq r3,r2,0x00124550		Branch if preview unit
00124540: 34020001 ori r2,r0,0x0001			Success?
00124544: 0c0484ae jal 0x001212b8			001212b8 - 00121564 - copy formation data to unit data
00124548: 00000000 nop
0012454c: 34020001 ori r2,r0,0x0001			return r2 = 1
00124550: 8fbf002c lw r31,0x002c(r29)
00124554: 8fb60028 lw r22,0x0028(r29)
00124558: 8fb50024 lw r21,0x0024(r29)
0012455c: 8fb40020 lw r20,0x0020(r29)
00124560: 8fb3001c lw r19,0x001c(r29)
00124564: 8fb20018 lw r18,0x0018(r29)
00124568: 8fb10014 lw r17,0x0014(r29)
0012456c: 8fb00010 lw r16,0x0010(r29)
00124570: 27bd0030 addiu r29,r29,0x0030
00124574: 03e00008 jr r31
00124578: 00000000 nop