WORLD.BIN Check Valid Equip (Check 2 Hands / 2 Swords)
Jump to navigation
Jump to search
#Parameters: #r4 = Current Unit Formation ID #r5 = Hand to swap Equipment into (RH = 0, LH = 1) #r6 = Item to equip #Returns: #r2 = 1 if valid equip = 0 if invalid equip
00124614: 27bdffc8 addiu r29,r29,0xffc8 00124618: 00801821 addu r3,r4,r0 #r3 = Current Unit Formation ID 0012461c: afb20018 sw r18,0x0018(r29) 00124620: 00a09021 addu r18,r5,r0 #r18 = Hand to swap Equipment into 00124624: afb00010 sw r16,0x0010(r29) 00124628: 00c08021 addu r16,r6,r0 #r16 = Item to equip 0012462c: 00031400 sll r2,r3,0x10 #compiler math 00124630: afb10014 sw r17,0x0014(r29) 00124634: 00028c03 sra r17,r2,0x10 #r17 = Current Unit Formation ID 00124638: 02202021 addu r4,r17,r0 #r4 = Unit Formation ID in upper halfword 0012463c: afb60028 sw r22,0x0028(r29) 00124640: 0060b021 addu r22,r3,r0 #r22 = Current Unit Formation ID 00124644: afbf0030 sw r31,0x0030(r29) 00124648: afb7002c sw r23,0x002c(r29) 0012464c: afb50024 sw r21,0x0024(r29) 00124650: afb40020 sw r20,0x0020(r29) 00124654: 0c049550 jal 0x00125540 #Lock Equipment And Abilities 00124658: afb3001c sw r19,0x001c(r29) 0012465c: 00409821 addu r19,r2,r0 #r19 = "Lock Equipment" result 00124660: 06600055 bltz r19,0x001247b8 #Branch to End if Equipment is locked 00124664: 0240a021 addu r20,r18,r0 #r20 = Hand to swap Equipment into 00124668: 320203ff andi r2,r16,0x03ff #r2 = Item to equip 0012466c: 00408021 addu r16,r2,r0 #r16 = Item to equip 00124670: 1200003a beq r16,r0,0x0012475c #Branch if Item to equip is 0 (Fists) 00124674: 0040b821 addu r23,r2,r0 #r23 = Item to equip 00124678: 02202021 addu r4,r17,r0 #r4 = Current Unit Formation ID 0012467c: 0c04915f jal 0x0012457c #Can Unit equip Item ID 00124680: 02002821 addu r5,r16,r0 #r5 = Item to equip 00124684: 00409821 addu r19,r2,r0 #r19 = "Can Unit equip Item ID" result 00124688: 00121400 sll r2,r18,0x10 #compiler math 0012468c: 00021403 sra r2,r2,0x10 #r2 = Hand to swap Equipment into 00124690: 28420002 slti r2,r2,0x0002 #Check valid hand (only 0 and 1 are valid inputs, for RH and LH respectively) 00124694: 10400047 beq r2,r0,0x001247b4 #Branch if invalid input 00124698: 34020001 ori r2,r0,0x0001 #r2 = 1 0012469c: 16620046 bne r19,r2,0x001247b8 #Branch to End if Equipment is locked 001246a0: 02601021 addu r2,r19,r0 #r2 = "Can Unit equip Item ID" result 001246a4: 2a02007a slti r2,r16,0x007a #Check if Item to Equip is a Weapon 001246a8: 38520001 xori r18,r2,0x0001 #r18 = 0 if Item to Equip is a Weapon 001246ac: 12400003 beq r18,r0,0x001246bc #Branch if Item to Equip is a Weapon 001246b0: 0000a821 addu r21,r0,r0 #r21 = 0 (Shields can't be Forced 2 Hands) 001246b4: 080491b6 j 0x001246d8 #Jump 001246b8: 00002021 addu r4,r0,r0 #r4 = 0 (Shields can't be 2 Swordable) 001246bc: 001010c0 sll r2,r16,0x03 #r2 = Weapon Type * 8 001246c0: 3c018006 lui r1,0x8006 001246c4: 00220821 addu r1,r1,r2 001246c8: 90223ab9 lbu r2,0x3ab9(r1) #r2 = Weapon's Attack flag 001246cc: 00000000 nop 001246d0: 30550001 andi r21,r2,0x0001 #r21 = Forced 2 Hands flag 001246d4: 30440008 andi r4,r2,0x0008 #r4 = 2 Swordable flag 001246d8: 00141c00 sll r3,r20,0x10 #compiler math 001246dc: 2c630001 sltiu r3,r3,0x0001 #r3 = 1 if RH, r3 = 0 if LH 001246e0: 00161400 sll r2,r22,0x10 #compiler math 001246e4: 00021383 sra r2,r2,0x0e #r2 = Current Unit Formation ID * 4 001246e8: 3c01801d lui r1,0x801d 001246ec: 00220821 addu r1,r1,r2 001246f0: 8c22d5ec lw r2,-0x2a14(r1) #r2 = Unit Formation Pointer 001246f4: 00031840 sll r3,r3,0x01 #r3 = 2 if RH, r3 = 0 if LH 001246f8: 00621821 addu r3,r3,r2 #Unit Formation Pointer + hand offset 001246fc: 94620054 lhu r2,0x0054(r3) #r2 = Load Other hand Equipment 00124700: 00000000 nop 00124704: 305103ff andi r17,r2,0x03ff #r17 = Other hand Equipment 00124708: 2a22007a slti r2,r17,0x007a #r2 = 1 if Other hand Equipment is a Weapon 0012470c: 38500001 xori r16,r2,0x0001 #r16 = 0 Other hand Equipment is a Weapon 00124710: 12000003 beq r16,r0,0x00124720 #Branch if Other hand Equipment is a Weapon 00124714: 0000a021 addu r20,r0,r0 #r20 = 0 (Shields can't be Forced 2 Hands) 00124718: 080491cf j 0x0012473c #Jump 0012471c: 00001021 addu r2,r0,r0 #r2 = 0 (Shields can't be 2 Swordable) 00124720: 001110c0 sll r2,r17,0x03 #r2 = Current Weapon * 8 00124724: 3c018006 lui r1,0x8006 00124728: 00220821 addu r1,r1,r2 0012472c: 90223ab9 lbu r2,0x3ab9(r1) #r2 = Attack flags of Current Weapon in other hand 00124730: 00000000 nop 00124734: 30540001 andi r20,r2,0x0001 #r20 = Forced 2 hands flag of Current Weapon in other hand 00124738: 30420008 andi r2,r2,0x0008 #r2 = 2 Swordable flag of Current Weapon in other hand 0012473c: 10800009 beq r4,r0,0x00124764 #Branch if Weapon to Equip is not 2 swordable 00124740: 00000000 nop 00124744: 10400007 beq r2,r0,0x00124764 #Branch if Weapon in other hand is not 2 swordable 00124748: 00162400 sll r4,r22,0x10 #compiler math 0012474c: 0c048a21 jal 0x00122884 #Check For Two Swords 00124750: 00042403 sra r4,r4,0x10 #r4 = Current Unit Formation ID 00124754: 10400003 beq r2,r0,0x00124764 #Branch if Unit does not have 2 Swords Equipped 00124758: 00000000 nop 0012475c: 080491ee j 0x001247b8 # #Jump to End 00124760: 34020001 ori r2,r0,0x0001 #r2 = 1 (Return valid 2 Swords equips) 00124764: 16400009 bne r18,r0,0x0012478c #Branch if Item to Equip is a Shield 00124768: 00000000 nop 0012476c: 16000005 bne r16,r0,0x00124784 #Branch if Other hand Equipment is a Shield 00124770: 00000000 nop 00124774: 12e00003 beq r23,r0,0x00124784 #Branch if Item to Equip is Fists 00124778: 00000000 nop 0012477c: 1620000e bne r17,r0,0x001247b8 #Branch to End if Other hand Equipment is not Fist 00124780: 00001021 addu r2,r0,r0 #r2 = 0 (2 Weapons without 2 Swords? Invalid?) 00124784: 12400007 beq r18,r0,0x001247a4 # # #Branch if Item to Equip is a Weapon 00124788: 00000000 nop 0012478c: 1600000a bne r16,r0,0x001247b8 # #Branch to End if Other hand Equipment is a Shield 00124790: 00001021 addu r2,r0,r0 #r2 = 0 (2 Shields? Invalid?) 00124794: 12400003 beq r18,r0,0x001247a4 #Branch if Item to Equip is a Weapon 00124798: 00000000 nop 0012479c: 16800006 bne r20,r0,0x001247b8 #Branch to End if Current Weapon in other hand is Forced 2 Hands 001247a0: 00000000 nop 001247a4: 12000003 beq r16,r0,0x001247b4 # #Branch if Other hand Equipment is a Weapon 001247a8: 00000000 nop 001247ac: 16a00002 bne r21,r0,0x001247b8 #Branch to End if Forced 2 Hands is true 001247b0: 00001021 addu r2,r0,r0 #r2 = 0 (cant equip Item if Other hand Equipment is Forced 2 Hands) 001247b4: 02601021 addu r2,r19,r0 # # #r2 = "Lock Equipment" result? (valid equip?) 001247b8: 8fbf0030 lw r31,0x0030(r29) #End 001247bc: 8fb7002c lw r23,0x002c(r29) 001247c0: 8fb60028 lw r22,0x0028(r29) 001247c4: 8fb50024 lw r21,0x0024(r29) 001247c8: 8fb40020 lw r20,0x0020(r29) 001247cc: 8fb3001c lw r19,0x001c(r29) 001247d0: 8fb20018 lw r18,0x0018(r29) 001247d4: 8fb10014 lw r17,0x0014(r29) 001247d8: 8fb00010 lw r16,0x0010(r29) 001247dc: 27bd0038 addiu r29,r29,0x0038 001247e0: 03e00008 jr r31 001247e4: 00000000 nop