Calculate/Store ENTD Unit Equipment

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
Calculate/Store ENTD Unit Equipment
0005bdf0: 27bdffd8 addiu r29,r29,0xffd8		(messy copypasta ftl)
0005bdf4: afb00010 sw r16,0x0010(r29)
0005bdf8: 00808021 addu r16,r4,r0		r16 = Unit's Data Pointer
0005bdfc: afbf0024 sw r31,0x0024(r29)
0005be00: afb40020 sw r20,0x0020(r29)
0005be04: afb3001c sw r19,0x001c(r29)
0005be08: afb20018 sw r18,0x0018(r29)
0005be0c: afb10014 sw r17,0x0014(r29)
0005be10: 92020006 lbu r2,0x0006(r16)		Load Unit's Gender Byte
0005be14: 00000000 nop
0005be18: 30420020 andi r2,r2,0x0020
0005be1c: 1040 0005 beq r2,r0,0x 0005be34		Branch if Unit isn't a monster
0005be20: 00a0a021 addu r20,r5,r0		r20 = ENTD Pointer
0005be24: 0c016f6c jal 0x 0005bdb0		Monster Equipment Storing
0005be28: 00000000 nop
0005be2c: 08017096 j 0x 0005c258
0005be30: 00000000 nop
0005be34: 340200fe ori r2,r0,0x00fe		r2 = FE
0005be38: 92840015 lbu r4,0x0015(r20)		Load ENTD RH Equip
0005be3c: 92110091 lbu r17,0x0091(r16)		Load Unit's Support set 3
0005be40: 309200ff andi r18,r4,0x00ff		r18 = RH Equip
0005be44: 16420012 bne r18,r2,0x 0005be90	Branch if RH Equip isn't Random
0005be48: 32220002 andi r2,r17,0x0002
0005be4c: 10400006 beq r2,r0,0x 0005be68		Branch if Unit doesn't have Two-Hands
0005be50: 34050080 ori r5,r0,0x0080		Item Type = Weapon
0005be54: 02002021 addu r4,r16,r0		r4 = Unit's Data Pointer
0005be58: 34060004 ori r6,r0,0x0004		Required Flags = Two-Hands
0005be5c: 0c017326 jal 0x 0005cc98		Calculate Random Equipment
0005be60: 340700ff ori r7,r0,0x00ff		Chosen Type = Any
0005be64: 00402021 addu r4,r2,r0		r4 = Chosen Weapon ID
0005be68: 308200ff andi r2,r4,0x00ff
0005be6c: 14520008 bne r2,r18,0x 0005be90	Branch if a Weapon was chosen (!= FE)
0005be70: 32220001 andi r2,r17,0x0001
0005be74: 10400006 beq r2,r0,0x 0005be90		Branch if Unit doesn't have Two Swords
0005be78: 34050080 ori r5,r0,0x0080		Item Type = Weapons
0005be7c: 02002021 addu r4,r16,r0		r4 = Unit's Data Pointer
0005be80: 34060008 ori r6,r0,0x0008		Required Flags = 2 Swords
0005be84: 0c017326 jal 0x 0005cc98		Calculate Random Equipment
0005be88: 340700ff ori r7,r0,0x00ff		Chosen Type = Any
0005be8c: 00402021 addu r4,r2,r0		r4 = Chosen Weapon ID
0005be90: 9211008f lbu r17,0x008f(r16)		Load Unit's Support set 1
0005be94: 309300ff andi r19,r4,0x00ff		r19 = Chosen Weapon ID
0005be98: 340200fe ori r2,r0,0x00fe
0005be9c: 1662004e bne r19,r2,0x 0005bfd8	Branch if a Weapon was chosen
0005bea0: 308200ff andi r2,r4,0x00ff		r2 = Chosen Weapon ID
0005bea4: 32220020 andi r2,r17,0x0020
0005bea8: 10400006 beq r2,r0,0x 0005bec4		Branch if Unit doesn't have Equip Swords
0005beac: 34050080 ori r5,r0,0x0080		Item Type = Weapons
0005beb0: 02002021 addu r4,r16,r0		r4 = Unit's Data Pointer
0005beb4: 00003021 addu r6,r0,r0		Required Flags = None
0005beb8: 0c017326 jal 0x 0005cc98		Calculate Random Equipment
0005bebc: 34070003 ori r7,r0,0x0003		Chosen Type = Swords
0005bec0: 00402021 addu r4,r2,r0		r4 = Chosen Weapon ID
0005bec4: 309200ff andi r18,r4,0x00ff		r18 = Chosen Weapon ID
0005bec8: 16530043 bne r18,r19,0x 0005bfd8	Branch if a Weapon was chosen
0005becc: 308200ff andi r2,r4,0x00ff		r2 = Chosen Weapon ID
0005bed0: 32220010 andi r2,r17,0x0010
0005bed4: 10400006 beq r2,r0,0x 0005bef0		Branch if Unit doesn't have Equip Katana
0005bed8: 34050080 ori r5,r0,0x0080		Item Type = Weapons
0005bedc: 02002021 addu r4,r16,r0		r4 = Unit's Data Pointer
0005bee0: 00003021 addu r6,r0,r0		Required Flags = None
0005bee4: 0c017326 jal 0x 0005cc98		Calculate Random Equipment
0005bee8: 3407 0005 ori r7,r0,0x 0005		Chosen Type = Katanas
0005beec: 00402021 addu r4,r2,r0		r4 = Chosen Weapon ID
0005bef0: 309300ff andi r19,r4,0x00ff		r19 = Chosen Weapon ID
0005bef4: 16720038 bne r19,r18,0x 0005bfd8	Branch if a Weapon was chosen
0005bef8: 308200ff andi r2,r4,0x00ff		r2 = Chosen Weapon ID
0005befc: 32220008 andi r2,r17,0x0008
0005bf00: 10400006 beq r2,r0,0x 0005bf1c		Branch if Unit doesn't have Equip Crossbow
0005bf04: 34050080 ori r5,r0,0x0080		Item Type = Weapons
0005bf08: 02002021 addu r4,r16,r0		r4 = Unit's Data Pointer
0005bf0c: 00003021 addu r6,r0,r0		Required Flags = None
0005bf10: 0c017326 jal 0x 0005cc98		Calculate Random Equipment
0005bf14: 3407000b ori r7,r0,0x000b		Chosen Type = Crossbow
0005bf18: 00402021 addu r4,r2,r0		r4 = Chosen Weapon ID
0005bf1c: 309200ff andi r18,r4,0x00ff		r18 = Chosen Weapon ID
0005bf20: 1653002d bne r18,r19,0x 0005bfd8	Branch if a Weapon was chosen
0005bf24: 308200ff andi r2,r4,0x00ff		r2 = Chosen Weapon ID
0005bf28: 32220004 andi r2,r17,0x0004
0005bf2c: 10400006 beq r2,r0,0x 0005bf48		Branch if Unit doesn't have Equip Spear
0005bf30: 34050080 ori r5,r0,0x0080		Item Type = Weapons
0005bf34: 02002021 addu r4,r16,r0		r4 = Unit's Data Pointer
0005bf38: 00003021 addu r6,r0,r0		Required Flags = None
0005bf3c: 0c017326 jal 0x 0005cc98		Calculate Random Equipment
0005bf40: 3407000f ori r7,r0,0x000f		Chosen Type = Polearm
0005bf44: 00402021 addu r4,r2,r0		r4 = Chosen Weapon ID
0005bf48: 309300ff andi r19,r4,0x00ff		r19 = Chosen Weapon ID
0005bf4c: 16720022 bne r19,r18,0x 0005bfd8	Branch if a Weapon was chosen
0005bf50: 308200ff andi r2,r4,0x00ff		r2 = Chosen Weapon ID
0005bf54: 32220002 andi r2,r17,0x0002
0005bf58: 10400006 beq r2,r0,0x 0005bf74		Branch if Unit doesn't have Equip Axe
0005bf5c: 34050080 ori r5,r0,0x0080		Item Type = Weapons
0005bf60: 02002021 addu r4,r16,r0		r4 = Unit's Data Pointer
0005bf64: 00003021 addu r6,r0,r0		Required Flags = None
0005bf68: 0c017326 jal 0x 0005cc98		Calculate Random Equipment
0005bf6c: 34070006 ori r7,r0,0x0006		Chosen Type = Axes
0005bf70: 00402021 addu r4,r2,r0		r4 = Chosen Weapon ID
0005bf74: 309200ff andi r18,r4,0x00ff		r18 = Chosen Weapon ID
0005bf78: 16530017 bne r18,r19,0x 0005bfd8	Branch if a Weapon was chosen
0005bf7c: 308200ff andi r2,r4,0x00ff		r2 = Chosen Weapon ID
0005bf80: 32220001 andi r2,r17,0x0001
0005bf84: 10400006 beq r2,r0,0x 0005bfa0		Branch if Unit doesn't have Equip Gun
0005bf88: 34050080 ori r5,r0,0x0080		Item Type = Weapons
0005bf8c: 02002021 addu r4,r16,r0		r4 = Unit's Data Pointer
0005bf90: 00003021 addu r6,r0,r0		Required Flags = None
0005bf94: 0c017326 jal 0x 0005cc98		Calculate Random Equipment
0005bf98: 3407000a ori r7,r0,0x000a		Chosen Type = Guns
0005bf9c: 00402021 addu r4,r2,r0		r4 = Chosen Weapon ID
0005bfa0: 309100ff andi r17,r4,0x00ff		r17 = Chosen Weapon ID
0005bfa4: 1632000c bne r17,r18,0x 0005bfd8	Branch if a Weapon was Chosen
0005bfa8: 308200ff andi r2,r4,0x00ff		r2 = Chosen Weapon ID
0005bfac: 02002021 addu r4,r16,r0		r4 = Unit's Data Pointer
0005bfb0: 34050080 ori r5,r0,0x0080		Item Type = Weapons
0005bfb4: 00003021 addu r6,r0,r0		Required Flags = None
0005bfb8: 0c017326 jal 0x 0005cc98		Calculate Random Equipment
0005bfbc: 340700ff ori r7,r0,0x00ff		Chosen Type = Any
0005bfc0: 00402021 addu r4,r2,r0		r4 = Chosen Weapon ID
0005bfc4: 308200ff andi r2,r4,0x00ff		r2 = Chosen Weapon ID
0005bfc8: 14510004 bne r2,r17,0x 0005bfdc	Branch if a weapon was Chosen
0005bfcc: 00021840 sll r3,r2,0x01		ID * 2
0005bfd0: 340400ff ori r4,r0,0x00ff		Chosen Weapon ID = Unarmed
0005bfd4: 308200ff andi r2,r4,0x00ff		r2 = Chosen Weapon ID
0005bfd8: 00021840 sll r3,r2,0x01		ID * 2
0005bfdc: 00621821 addu r3,r3,r2		ID * 3
0005bfe0: 00031880 sll r3,r3,0x02		ID * 12
0005bfe4: 3c018006 lui r1,0x8006
0005bfe8: 00230821 addu r1,r1,r3
0005bfec: 90222ebb lbu r2,0x2ebb(r1)		Load Chosen Weapon's Type Flags
0005bff0: 00000000 nop
0005bff4: 30420040 andi r2,r2,0x0040
0005bff8: 10400004 beq r2,r0,0x 0005c00c		Branch if Weapon isn't a Shield
0005bffc: 340200ff ori r2,r0,0x00ff		r2 = FF
0005c000: a204001e sb r4,0x001e(r16)		Store Unit's RH Shield = Chosen Weapon ID
0005c004: 08017005 j 0x 0005c014			(even though a shield isn't an outcome here)
0005c008: a202001d sb r2,0x001d(r16)		Store Unit's RH Weapon = None
0005c00c: a204001d sb r4,0x001d(r16)		Store Unit's RH Weapon = Chosen Weapon ID
0005c010: a202001e sb r2,0x001e(r16)		Store Unit's RH Shield = None
0005c014: 340200ff ori r2,r0,0x00ff		r2 = FF
0005c018: 9203001d lbu r3,0x001d(r16)		Load Unit's RH Weapon
0005c01c: 92840016 lbu r4,0x0016(r20)		Load ENTD LH Equip
0005c020: 10620015 beq r3,r2,0x 0005c078		Branch if RH Weapon = Unarmed
0005c024: 00031040 sll r2,r3,0x01		ID * 2
0005c028: 00431021 addu r2,r2,r3		ID * 3
0005c02c: 00021080 sll r2,r2,0x02		ID * 12
0005c030: 3c018006 lui r1,0x8006
0005c034: 00220821 addu r1,r1,r2
0005c038: 90222ebc lbu r2,0x2ebc(r1)		Load RH Weapon's Second Table ID
0005c03c: 00000000 nop
0005c040: 000210c0 sll r2,r2,0x03		ID * 8
0005c044: 3c018006 lui r1,0x8006
0005c048: 00220821 addu r1,r1,r2
0005c04c: 90223ab9 lbu r2,0x3ab9(r1)		Load Weapon's Attack Flags
0005c050: 00000000 nop
0005c054: 30420001 andi r2,r2,0x0001
0005c058: 14400006 bne r2,r0,0x 0005c074		Branch if Weapon is Forced Two-Hands
0005c05c: 00000000 nop
0005c060: 92020091 lbu r2,0x0091(r16)		Load Unit's Support set 3
0005c064: 00000000 nop
0005c068: 30420002 andi r2,r2,0x0002
0005c06c: 10400002 beq r2,r0,0x 0005c078		Branch if Unit doesn't have Two-Hands
0005c070: 00000000 nop
0005c074: 340400ff ori r4,r0,0x00ff		LH Equip = FF
0005c078: 92110091 lbu r17,0x0091(r16)		Load Unit's Support Set 3
0005c07c: 308300ff andi r3,r4,0x00ff		r3 = LH Equip
0005c080: 340200fe ori r2,r0,0x00fe		r2 = FE
0005c084: 14620008 bne r3,r2,0x 0005c0a8		Branch if LH Equip is Random
0005c088: 32220001 andi r2,r17,0x0001
0005c08c: 10400006 beq r2,r0,0x 0005c0a8		Branch if Unit doesn't have Two Swords
0005c090: 34050080 ori r5,r0,0x0080		Item Type = Weapon
0005c094: 02002021 addu r4,r16,r0		r4 = Unit's Data Pointer
0005c098: 34060008 ori r6,r0,0x0008		Required Flags = Two Swords
0005c09c: 0c017326 jal 0x 0005cc98		Calculate Random Equipment
0005c0a0: 340700ff ori r7,r0,0x00ff		Chosen Type = Any
0005c0a4: 00402021 addu r4,r2,r0		r4 = Chosen Weapon ID
0005c0a8: 9211004c lbu r17,0x004c(r16)		Load Unit's Equippable Items set 3
0005c0ac: 308300ff andi r3,r4,0x00ff		r3 = Unit's Chosen Weapon
0005c0b0: 340200fe ori r2,r0,0x00fe		r2 = FE
0005c0b4: 1462000c bne r3,r2,0x 0005c0e8		Branch if a Weapon was chosen
0005c0b8: 308200ff andi r2,r4,0x00ff		r2 = Chosen Weapon ID
0005c0bc: 32220010 andi r2,r17,0x0010
0005c0c0: 10400007 beq r2,r0,0x 0005c0e0		Branch if Unit can't equip Shields
0005c0c4: 02002021 addu r4,r16,r0		r4 = Unit's Data Pointer
0005c0c8: 34050040 ori r5,r0,0x0040		Item Type = Shield
0005c0cc: 00003021 addu r6,r0,r0		Required Flags = None
0005c0d0: 0c017326 jal 0x 0005cc98		Calculate Random Equipment
0005c0d4: 340700ff ori r7,r0,0x00ff		Chosen Type = Any
0005c0d8: 08017039 j 0x 0005c0e4
0005c0dc: 00402021 addu r4,r2,r0		r4 = Chosen Shield ID
0005c0e0: 340400ff ori r4,r0,0x00ff		Chosen Shield = None
0005c0e4: 308200ff andi r2,r4,0x00ff		r2 = Chosen Shield ID
0005c0e8: 00021840 sll r3,r2,0x01		ID * 2
0005c0ec: 00621821 addu r3,r3,r2		ID * 3
0005c0f0: 00031880 sll r3,r3,0x02		ID * 12
0005c0f4: 3c018006 lui r1,0x8006
0005c0f8: 00230821 addu r1,r1,r3
0005c0fc: 90222ebb lbu r2,0x2ebb(r1)		Load Equip's Type Flags
0005c100: 00000000 nop
0005c104: 30420080 andi r2,r2,0x0080
0005c108: 10400004 beq r2,r0,0x 0005c11c		Branch if Equip isn't a Weapon
0005c10c: 340200ff ori r2,r0,0x00ff		r2 = FF
0005c110: a204001f sb r4,0x001f(r16)		Store LH Weapon ID = Chosen Weapon
0005c114: 08017049 j 0x 0005c124
0005c118: a2020020 sb r2,0x0020(r16)		Store LH Shield = None
0005c11c: a2040020 sb r4,0x0020(r16)		Store LH Shield = Chosen Shield
0005c120: a202001f sb r2,0x001f(r16)		Store LH Weapon = None
0005c124: 340200fe ori r2,r0,0x00fe		r2 = FE
0005c128: 92840012 lbu r4,0x0012(r20)		Load ENTD Helmet
0005c12c: 9211008f lbu r17,0x008f(r16)		Load Unit's Support Set 1
0005c130: 309300ff andi r19,r4,0x00ff		r19 = ENTD Helmet
0005c134: 16620014 bne r19,r2,0x 0005c188	Branch if Helmet isn't Random
0005c138: 32220080 andi r2,r17,0x0080
0005c13c: 10400006 beq r2,r0,0x 0005c158		Branch if Unit doesn't have Equip Armor
0005c140: 34050020 ori r5,r0,0x0020		Item Type = Headgear
0005c144: 02002021 addu r4,r16,r0		r4 = Unit's Data Pointer
0005c148: 00003021 addu r6,r0,r0		Required Flags = None
0005c14c: 0c017326 jal 0x 0005cc98		Calculate Random Equipment
0005c150: 34070014 ori r7,r0,0x0014		Chosen Type = Heavy Helms
0005c154: 00402021 addu r4,r2,r0		r4 = Chosen Helmet ID
0005c158: 309200ff andi r18,r4,0x00ff		r18 = Chosen Helmet
0005c15c: 1653000a bne r18,r19,0x 0005c188	Branch if a Helmet was chosen
0005c160: 34050020 ori r5,r0,0x0020		Item Type = Headgear
0005c164: 02002021 addu r4,r16,r0		r4 = Unit's Data Pointer
0005c168: 00003021 addu r6,r0,r0		Required Flags = None
0005c16c: 0c017326 jal 0x 0005cc98		Calculate Random Equipment
0005c170: 340700ff ori r7,r0,0x00ff		Chosen Type = Any
0005c174: 00402021 addu r4,r2,r0		r4 = Chosen Helmet ID
0005c178: 308200ff andi r2,r4,0x00ff		r2 = Chosen Helmet
0005c17c: 14520002 bne r2,r18,0x 0005c188	Branch if a Helmet was chosen
0005c180: 00000000 nop
0005c184: 340400ff ori r4,r0,0x00ff		Chosen Helmet = None
0005c188: a204001a sb r4,0x001a(r16)		Store Chosen Helmet ID
0005c18c: 92840013 lbu r4,0x0013(r20)		Load ENTD Armor ID
0005c190: 340200fe ori r2,r0,0x00fe		r2 = FE
0005c194: 309200ff andi r18,r4,0x00ff		r18 = Chosen ENTD Armor ID
0005c198: 16420014 bne r18,r2,0x 0005c1ec	Branch if Armor isn't Random
0005c19c: 32220040 andi r2,r17,0x0040
0005c1a0: 10400006 beq r2,r0,0x 0005c1bc		Branch if Unit doesn't have Equip Shield (Bug, Equip Armor)
0005c1a4: 34050010 ori r5,r0,0x0010		Item Type = Armor
0005c1a8: 02002021 addu r4,r16,r0		r4 = Unit's Data Pointer
0005c1ac: 00003021 addu r6,r0,r0		Required Flags = None
0005c1b0: 0c017326 jal 0x 0005cc98		Calculate Random Equipment
0005c1b4: 34070017 ori r7,r0,0x0017		Chosen Type = Heavy Armor
0005c1b8: 00402021 addu r4,r2,r0		r4 = Chosen Armor ID
0005c1bc: 309100ff andi r17,r4,0x00ff		r17 = Chosen Armor
0005c1c0: 1632000a bne r17,r18,0x 0005c1ec	Branch if an Armor was chosen
0005c1c4: 34050010 ori r5,r0,0x0010		Item Type = Armor
0005c1c8: 02002021 addu r4,r16,r0		r4 = Unit's Data Pointer
0005c1cc: 00003021 addu r6,r0,r0		Required Flags = None
0005c1d0: 0c017326 jal 0x 0005cc98		Calculate Random Equipment
0005c1d4: 340700ff ori r7,r0,0x00ff		Chosen Type = Any
0005c1d8: 00402021 addu r4,r2,r0		r4 = Chosen Armor ID
0005c1dc: 308200ff andi r2,r4,0x00ff		r2 = Chosen Armor
0005c1e0: 14510002 bne r2,r17,0x 0005c1ec	Branch if an Armor was chosen
0005c1e4: 00000000 nop
0005c1e8: 340400ff ori r4,r0,0x00ff		Chosen Armor = None
0005c1ec: a204001b sb r4,0x001b(r16)		Store Chosen Armor
0005c1f0: 92840014 lbu r4,0x0014(r20)		Load ENTD Accessory ID
0005c1f4: 340200fe ori r2,r0,0x00fe		r2 = FE
0005c1f8: 309100ff andi r17,r4,0x00ff		r17 = ENTD Accessory ID
0005c1fc: 1622000a bne r17,r2,0x 0005c228	Branch if Accessory isn't Random
0005c200: 34050008 ori r5,r0,0x0008		Item Type = Accessory
0005c204: 02002021 addu r4,r16,r0		r4 = Unit's Data Pointer
0005c208: 00003021 addu r6,r0,r0		Required Flags = None
0005c20c: 0c017326 jal 0x 0005cc98		Calculate Random Equipment
0005c210: 340700ff ori r7,r0,0x00ff		Chosen Type = Any
0005c214: 00402021 addu r4,r2,r0		r4 = Chosen Accessory
0005c218: 308200ff andi r2,r4,0x00ff		r2 = Chosen Accessory
0005c21c: 14510002 bne r2,r17,0x 0005c228	Branch if an Accessory was chosen
0005c220: 00000000 nop
0005c224: 340400ff ori r4,r0,0x00ff		Chosen Accessory = None
0005c228: a204001c sb r4,0x001c(r16)		Store Chosen Accessory
0005c22c: 00001821 addu r3,r0,r0		Counter = 0
0005c230: 340500ff ori r5,r0,0x00ff		r5 = FF
0005c234: 02032021 addu r4,r16,r3		r4 = Unit's Data Pointer + Counter
0005c238: 9082001a lbu r2,0x001a(r4)		Load Unit's Equipment ID
0005c23c: 00000000 nop
0005c240: 14400002 bne r2,r0,0x 0005c24c		Branch if Equipment ID != 0
0005c244: 24630001 addiu r3,r3,0x0001		Counter ++
0005c248: a085001a sb r5,0x001a(r4)		Store Equipment ID = None
0005c24c: 28620007 slti r2,r3,0x0007
0005c250: 1440fff9 bne r2,r0,0x 0005c238		Branch if Counter < 7
0005c254: 02032021 addu r4,r16,r3		r4 = Unit's Data Pointer + Counter
0005c258: 8fbf0024 lw r31,0x0024(r29)
0005c25c: 8fb40020 lw r20,0x0020(r29)
0005c260: 8fb3001c lw r19,0x001c(r29)
0005c264: 8fb20018 lw r18,0x0018(r29)
0005c268: 8fb10014 lw r17,0x0014(r29)
0005c26c: 8fb00010 lw r16,0x0010(r29)
0005c270: 27bd0028 addiu r29,r29,0x0028
0005c274: 03e00008 jr r31
0005c278: 00000000 nop


Return Locations

0005aac8: Unit Battle Initialization