Equipment Attribute Setting

From Final Fantasy Hacktics
Jump to: navigation, search
Equipment Attribute Setting
0005c5c8: 27bdffe0 addiu r29,r29,0xffe0		(Note: Level UP Check + 1 below is to prevent Level UP, and
0005c5cc: afb10014 sw r17,0x0014(r29)		 to set the new Max HP/MP and/or PA/MA/SP)
0005c5d0: 00808821 addu r17,r4,r0		r17 = Unit's Data Pointer
0005c5d4: afb00010 sw r16,0x0010(r29)
0005c5d8: 00a08021 addu r16,r5,r0		r16 = Level UP Check
0005c5dc: afb20018 sw r18,0x0018(r29)
0005c5e0: 26320033 addiu r18,r17,0x0033		r18 = Unit's Data Pointer (Bonus Stats)
0005c5e4: 02402021 addu r4,r18,r0		r4 = Unit's Data Pointer (Bonus Stats)
0005c5e8: afbf001c sw r31,0x001c(r29)
0005c5ec: 0c017991 jal 0x 0005e644		Data Nullifying (Bonus Stats)
0005c5f0: 34050003 ori r5,r0,0x0003		r5 = 3 (The three Bonus Stats)
0005c5f4: 02202021 addu r4,r17,r0		r4 = Unit's Data Pointer
0005c5f8: 0c016e20 jal 0x 0005b880		Calculate Actual Stats (No Level UP)
0005c5fc: 26050001 addiu r5,r16,0x0001		r5 = Level UP Check + 1 (1 = HP/MP/PA/MA/SP, 2 = HP/MP)
0005c600: 92220006 lbu r2,0x0006(r17)		Load Unit's Gender Byte
0005c604: 341003e7 ori r16,r0,0x03e7		HP/MP Cap = 999 (This is what causes ??? to re-cap)
0005c608: 30420020 andi r2,r2,0x0020
0005c60c: 14400087 bne r2,r0,0x 0005c82c		Branch if Unit is a Monster
0005c610: a2200184 sb r0,0x0184(r17)		Unit's Equipped Flags? = 0
0005c614: 02402021 addu r4,r18,r0		r4 = Unit's Data Pointer (Bonus Stats)
0005c618: 0 0005021 addu r10,r0,r0		Equipment Counter = 0
0005c61c: 022a1021 addu r2,r17,r10		r2 = Unit's Data Pointer + Equipment's Counter
0005c620: 9045001a lbu r5,0x001a(r2)		Load Unit's Equipment ID
0005c624: 34020020 ori r2,r0,0x0020		r2 = 20
0005c628: 30a300ff andi r3,r5,0x00ff		r3 = Unit's Equipment ID
0005c62c: 14620006 bne r3,r2,0x 0005c648		Branch if Item isn't Materia Blade
0005c630: 2c620080 sltiu r2,r3,0x0080
0005c634: 92220184 lbu r2,0x0184(r17)		Load Unit's Equipped Flags?
0005c638: 00000000 nop
0005c63c: 34420004 ori r2,r2,0x0004		Enable Materia Blade
0005c640: a2220184 sb r2,0x0184(r17)		Store New Equipped Flags?
0005c644: 2c620080 sltiu r2,r3,0x0080
0005c648: 1040000f beq r2,r0,0x 0005c688		Branch if Item isn't a weapon
0005c64c: 00031040 sll r2,r3,0x01		ID * 2
0005c650: 00431021 addu r2,r2,r3		ID * 3
0005c654: 00021080 sll r2,r2,0x02		ID * 12
0005c658: 3c018006 lui r1,0x8006
0005c65c: 00220821 addu r1,r1,r2
0005c660: 90222ebd lbu r2,0x2ebd(r1)		Load Weapon's Item Type
0005c664: 00000000 nop
0005c668: 2442fffd addiu r2,r2,0xfffd		Item Type - 3 (Sword)
0005c66c: 2c420002 sltiu r2,r2,0x0002
0005c670: 10400006 beq r2,r0,0x 0005c68c		Branch if Weapon isn't a Sword or Knight Sword
0005c674: 30a300ff andi r3,r5,0x00ff
0005c678: 92220184 lbu r2,0x0184(r17)		Load Equipped Flags?
0005c67c: 00000000 nop
0005c680: 34420008 ori r2,r2,0x0008		Enable Sword
0005c684: a2220184 sb r2,0x0184(r17)		Store new Equipped Flags?
0005c688: 30a300ff andi r3,r5,0x00ff
0005c68c: 340200ff ori r2,r0,0x00ff		r2 = ff
0005c690: 10620062 beq r3,r2,0x 0005c81c		Branch if nothing is equipped
0005c694: 00031040 sll r2,r3,0x01		ID * 2
0005c698: 00803021 addu r6,r4,r0		r6 = Unit's Data Pointer (Bonus Stats)
0005c69c: 00431021 addu r2,r2,r3		ID * 3
0005c6a0: 00021080 sll r2,r2,0x02		ID * 12
0005c6a4: 3c038006 lui r3,0x8006
0005c6a8: 24632eb8 addiu r3,r3,0x2eb8
0005c6ac: 00434821 addu r9,r2,r3
0005c6b0: 91230007 lbu r3,0x0007(r9)		Load Equipment's Item Attributes
0005c6b4: 24880003 addiu r8,r4,0x0003		r8 = Unit's Data Pointer (PA)
0005c6b8: 00031040 sll r2,r3,0x01		ID * 2
0005c6bc: 00431021 addu r2,r2,r3		ID * 3
0005c6c0: 000210c0 sll r2,r2,0x03		ID * 24
0005c6c4: 00431021 addu r2,r2,r3		ID * 25
0005c6c8: 3c038006 lui r3,0x8006
0005c6cc: 246342c4 addiu r3,r3,0x42c4
0005c6d0: 00433821 addu r7,r2,r3		r7 = Item Attribute's Data Location
0005c6d4: 00e02821 addu r5,r7,r0		r5 = Item Attribute's Data Location
0005c6d8: 90a20000 lbu r2,0x0000(r5)		Load Item Attribute's Stat
0005c6dc: 90c30000 lbu r3,0x0000(r6)		Load Unit's Bonus Stat
0005c6e0: 00000000 nop
0005c6e4: 00431821 addu r3,r2,r3		Bonus Stat + Item Attribute's Stat
0005c6e8: 2c620100 sltiu r2,r3,0x0100
0005c6ec: 14400002 bne r2,r0,0x 0005c6f8		Branch if new Stat < 256
0005c6f0: 24a50001 addiu r5,r5,0x0001		Item Attribute's Data Pointer += 1
0005c6f4: 340300ff ori r3,r0,0x00ff		Stat = 255
0005c6f8: a0c30000 sb r3,0x0000(r6)		Store new Bonus Stat
0005c6fc: 24c60001 addiu r6,r6,0x0001		Unit's Bonus Stat Pointer += 1
0005c700: 00c8102a slt r2,r6,r8
0005c704: 1440fff4 bne r2,r0,0x 0005c6d8		Branch if all Bonus Stats haven't been checked
0005c708: 00000000 nop
0005c70c: 90e20003 lbu r2,0x0003(r7)		Load Item Attribute's Move
0005c710: 9223003a lbu r3,0x003a(r17)		Load Unit's Move
0005c714: 00000000 nop
0005c718: 00431821 addu r3,r2,r3		Item Attribute's Move + Unit's Move
0005c71c: 2c6200fe sltiu r2,r3,0x00fe
0005c720: 14400002 bne r2,r0,0x 0005c72c		Branch if Move < 254
0005c724: 00000000 nop
0005c728: 340300fd ori r3,r0,0x00fd		Move = 253
0005c72c: a223003a sb r3,0x003a(r17)		Store Unit's new Move
0005c730: 90e20004 lbu r2,0x0004(r7)		Load Item Attribute's Jump
0005c734: 9223003b lbu r3,0x003b(r17)		Load Unit's Jump
0005c738: 00000000 nop
0005c73c: 00431821 addu r3,r2,r3		Item Attribute's Jump + Unit's Jump
0005c740: 2c620008 sltiu r2,r3,0x0008
0005c744: 14400002 bne r2,r0,0x 0005c750		Branch if Jump < 8
0005c748: 00002821 addu r5,r0,r0		Status Counter = 0
0005c74c: 34030007 ori r3,r0,0x0007		Jump = 7
0005c750: a223003b sb r3,0x003b(r17)		Store Unit's new Jump
0005c754: 2626004e addiu r6,r17,0x004e		r6 = Unit's Data Pointer (Innate Statuses)
0005c758: 00e51021 addu r2,r7,r5		r2 = Item Attribute's Pointer += Status Counter
0005c75c: 9042 0005 lbu r2,0x 0005(r2)		Load X Status set Y
0005c760: 90c30000 lbu r3,0x0000(r6)		Load Unit's X Status set Y
0005c764: 24a50001 addiu r5,r5,0x0001		Status Counter += 1
0005c768: 00431025 or r2,r2,r3			Combine Item and Unit's Innate Statuses
0005c76c: a0c20000 sb r2,0x0000(r6)		Store New Unit's Innate Statuses
0005c770: 28a2000f slti r2,r5,0x000f
0005c774: 1440fff8 bne r2,r0,0x 0005c758		Branch if all statuses haven't been set
0005c778: 24c60001 addiu r6,r6,0x0001		Unit's Status Pointer += 1
0005c77c: 00002821 addu r5,r0,r0		Elemental Counter = 0
0005c780: 2626006d addiu r6,r17,0x006d		r6 = Unit's Data Pointer (Elemental Absorption)
0005c784: 00e51021 addu r2,r7,r5		r2 = Item Attribute Pointer
0005c788: 90420014 lbu r2,0x0014(r2)		Load Item Attribute's Element byte X
0005c78c: 90c30000 lbu r3,0x0000(r6)		Load Unit's Element byte X
0005c790: 24a50001 addiu r5,r5,0x0001		Elemental Counter += 1
0005c794: 00431025 or r2,r2,r3			Combine Element Bytes
0005c798: a0c20000 sb r2,0x0000(r6)		Store new Unit's Element Byte X
0005c79c: 28a2 0005 slti r2,r5,0x 0005
0005c7a0: 1440fff8 bne r2,r0,0x 0005c784		Branch if all Element Bytes haven't been checked
0005c7a4: 24c60001 addiu r6,r6,0x0001		Unit's Elemental Pointer += 1
0005c7a8: 91220003 lbu r2,0x0003(r9)		Load Equipment's Item Type
0005c7ac: 00000000 nop
0005c7b0: 30420030 andi r2,r2,0x0030
0005c7b4: 10400019 beq r2,r0,0x 0005c81c		Branch if Equipment is not a Helm/Armor
0005c7b8: 00000000 nop
0005c7bc: 91220004 lbu r2,0x0004(r9)		Load Equipment's Second Table ID
0005c7c0: 9623002a lhu r3,0x002a(r17)		Load Unit's Max HP
0005c7c4: 00022840 sll r5,r2,0x01		ID * 2
0005c7c8: 3c018006 lui r1,0x8006
0005c7cc: 00250821 addu r1,r1,r5
0005c7d0: 90223ed8 lbu r2,0x3ed8(r1)		Load Equipment's HP Bonus
0005c7d4: 00000000 nop
0005c7d8: 00621821 addu r3,r3,r2		Max HP += HP Bonus
0005c7dc: 0203102b sltu r2,r16,r3
0005c7e0: 10400002 beq r2,r0,0x 0005c7ec		Branch if HP/MP Cap >= Max HP
0005c7e4: 00000000 nop
0005c7e8: 02001821 addu r3,r16,r0		Max HP = HP/MP Cap
0005c7ec: 9622002e lhu r2,0x002e(r17)		Load Unit's Max MP
0005c7f0: a623002a sh r3,0x002a(r17)		Store new Max HP
0005c7f4: 3c018006 lui r1,0x8006
0005c7f8: 00250821 addu r1,r1,r5
0005c7fc: 90233ed9 lbu r3,0x3ed9(r1)		Load Equipment's MP Bonus
0005c800: 00000000 nop
0005c804: 00431821 addu r3,r2,r3		Max MP += MP Bonus
0005c808: 0203102b sltu r2,r16,r3
0005c80c: 10400002 beq r2,r0,0x 0005c818		Branch if HP/MP Cap >= Max MP
0005c810: 00000000 nop
0005c814: 02001821 addu r3,r16,r0		Max MP = HP/MP Cap
0005c818: a623002e sh r3,0x002e(r17)		Store new Max MP
0005c81c: 254a0001 addiu r10,r10,0x0001		Equipment Counter += 1
0005c820: 29420007 slti r2,r10,0x0007
0005c824: 1440ff7e bne r2,r0,0x 0005c620		Branch if all equipments haven't been checked
0005c828: 022a1021 addu r2,r17,r10		Equipment Pointer += 1
0005c82c: 96230028 lhu r3,0x0028(r17)		Load Unit's Current HP
0005c830: 9622002a lhu r2,0x002a(r17)		Load Unit's Max HP
0005c834: 00000000 nop
0005c838: 0043102b sltu r2,r2,r3
0005c83c: 10400004 beq r2,r0,0x 0005c850		Branch if Max HP >= Current HP
0005c840: 00000000 nop
0005c844: 9622002a lhu r2,0x002a(r17)		Load Unit's Max HP
0005c848: 00000000 nop
0005c84c: a6220028 sh r2,0x0028(r17)		Store Unit's Current HP = Max HP
0005c850: 9623002c lhu r3,0x002c(r17)		Load Unit's Current MP
0005c854: 9622002e lhu r2,0x002e(r17)		Load Unit's Max MP
0005c858: 00000000 nop
0005c85c: 0043102b sltu r2,r2,r3
0005c860: 10400004 beq r2,r0,0x 0005c874		Branch if Max MP >= Current MP
0005c864: 26250030 addiu r5,r17,0x0030		r5 = Unit's Data Pointer (Original PA)
0005c868: 9622002e lhu r2,0x002e(r17)		Load Unit's Max MP
0005c86c: 00000000 nop
0005c870: a622002c sh r2,0x002c(r17)		Store Unit's Current MP = Max MP
0005c874: 26260032 addiu r6,r17,0x0032		r6 = Unit's Data Pointer (Original SP)
0005c878: 26240033 addiu r4,r17,0x0033		r4 = Unit's Data Pointer (Bonus PA)
0005c87c: 90a20003 lbu r2,0x0003(r5)		Load Unit's Bonus Stat
0005c880: 90a30000 lbu r3,0x0000(r5)		Load Unit's Original Stat
0005c884: 00000000 nop
0005c888: 00431821 addu r3,r2,r3		Original Stat += Bonus Stat
0005c88c: 00a6102a slt r2,r5,r6
0005c890: 1040 0005 beq r2,r0,0x 0005c8a8		Branch if New Stat is Speed
0005c894: 2c620064 sltiu r2,r3,0x0064
0005c898: 14400008 bne r2,r0,0x 0005c8bc		Branch if New Stat < 100
0005c89c: 00000000 nop
0005c8a0: 0801722f j 0x 0005c8bc
0005c8a4: 34030063 ori r3,r0,0x0063		New Stat = 99
0005c8a8: 3062ffff andi r2,r3,0xffff
0005c8ac: 2c420033 sltiu r2,r2,0x0033
0005c8b0: 14400002 bne r2,r0,0x 0005c8bc		Branch if New Speed < 51
0005c8b4: 00000000 nop
0005c8b8: 34030032 ori r3,r0,0x0032		New Speed = 50
0005c8bc: a0a30006 sb r3,0x0006(r5)		Store Unit's Actual Stat = New Stat
0005c8c0: 24a50001 addiu r5,r5,0x0001		Stat Pointer += 1
0005c8c4: 00a4102a slt r2,r5,r4
0005c8c8: 1440ffec bne r2,r0,0x 0005c87c		Branch if all stats haven't been set
0005c8cc: 00000000 nop
0005c8d0: 8fbf001c lw r31,0x001c(r29)
0005c8d4: 8fb20018 lw r18,0x0018(r29)
0005c8d8: 8fb10014 lw r17,0x0014(r29)
0005c8dc: 8fb00010 lw r16,0x0010(r29)
0005c8e0: 27bd0020 addiu r29,r29,0x0020
0005c8e4: 03e00008 jr r31
0005c8e8: 00000000 nop


Return Locations

0005ab18: Equipment/Move/Jump +X/Name Storing/Generation
0005d710: Status Setting/Checking + Equip/R/S/M Stats