Load lucavi SHP & SEQ data to RAM

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search

00088904: 27bdffc8 addiu r29,r29,0xffc8
00088908: afb1002c sw r17,0x002c(r29)
0008890c: 3c11800a lui r17,0x800a
00088910: 26318d78 addiu r17,r17,0x8d78		Load func. index (0 = loading file, 1 = nulled phase, 2 = copying file & Animating units, 3 = finalise)
00088914: afbf0034 sw r31,0x0034(r29)
00088918: afb20030 sw r18,0x0030(r29)
0008891c: afb00028 sw r16,0x0028(r29)
00088920: 8e230000 lw r3,0x0000(r17)
00088924: 34120001 ori r18,r0,0x0001
00088928: 107200c9 beq r3,r18,0x00088c50		branch if 98d78 = 1 (copying file; not RUKA/ARUTE/KANZEN?)
0008892c: 28620002 slti r2,r3,0x0002
00088930: 10400005 beq r2,r0,0x00088948		branch if >= 2 (copying file, RUKA/ARUTE/KANZEN?)
00088934: 34100002 ori r16,r0,0x0002
00088938: 10600009 beq r3,r0,0x00088960		branch if 0 (loading file?)
0008893c: 00000000 nop
00088940: 080223ac j 0x00088eb0
00088944: 00000000 nop
00088948: 107000ca beq r3,r16,0x00088c74		branch if = 2 (copying file for RUKA+)
0008894c: 34020003 ori r2,r0,0x0003
00088950: 10620137 beq r3,r2,0x00088e30		branch if = 3 (finalise)
00088954: 00000000 nop
00088958: 080223ac j 0x00088eb0
0008895c: 00000000 nop

if loading file:

00088960: 3c10800a lui r16,0x800a
00088964: 8e108d74 lw r16,-0x728c(r16)			file func. index
00088968: 00000000 nop
0008896c: 12120036 beq r16,r18,0x00088a48		if loading SEQ
00088970: 2a020002 slti r2,r16,0x0002
00088974: 10400005 beq r2,r0,0x0008898c		if 98d74 >= 2
00088978: 00000000 nop
0008897c: 12000008 beq r16,r0,0x000889a0		if loading SHP
00088980: 00000000 nop
00088984: 080223ac j 0x00088eb0
00088988: 00000000 nop
0008898c: 34020002 ori r2,r0,0x0002
00088990: 1202005d beq r16,r2,0x00088b08		if loading SPR data
00088994: 00000000 nop
00088998: 080223ac j 0x00088eb0
0008899c: 00000000 nop

loading SEQ file:

000889a0: 3c03800a lui r3,0x800a
000889a4: 8c638d7c lw r3,-0x7284(r3)			ENTD slot of unit? maybe? sprite slot? (so, 9 max sprites for example, 9 table entries here)
000889a8: 00000000 nop
000889ac: 00031080 sll r2,r3,0x02
000889b0: 00431021 addu r2,r2,r3			* 5
000889b4: 00021080 sll r2,r2,0x02			* 14
000889b8: 3c018005 lui r1,0x8005
000889bc: 00220821 addu r1,r1,r2
000889c0: 84229c22 lh r2,-0x63de(r1)			Load spritesheet ID of units sprite-dedicated, slot thing.
000889c4: 00000000 nop
000889c8: 00021080 sll r2,r2,0x02
000889cc: 3c018009 lui r1,0x8009
000889d0: 00220821 addu r1,r1,r2
000889d4: 90234748 lbu r3,0x4748(r1)			load spritesheet's SHP ID
000889d8: 00000000 nop
000889dc: 28620005 slti r2,r3,0x0005
000889e0: 14400030 bne r2,r0,0x00088aa4		Branch if not RUKA/ARUTE/KANZEN
000889e4: 00000000 nop
000889e8: 3c028009 lui r2,0x8009
000889ec: 8c426124 lw r2,0x6124(r2)
000889f0: 00000000 nop
000889f4: 1062002b beq r3,r2,0x00088aa4		Branch if unit's SHP ID matches SHP ID in 0x00096124?
000889f8: 000380c0 sll r16,r3,0x03
000889fc: 3c018009 lui r1,0x8009
00088a00: 00300821 addu r1,r1,r16
00088a04: 8c244c50 lw r4,0x4c50(r1)			load size of RUKA/ARUTE/KANZEN SEQ file in question?
00088a08: 3c018009 lui r1,0x8009
00088a0c: ac236124 sw r3,0x6124(r1)
00088a10: 0c011105 jal 0x00044414		dedicate RAM space to load file into ram
00088a14: 00000000 nop
00088a18: 3c01800a lui r1,0x800a
00088a1c: ac228d80 sw r2,-0x7280(r1)		store location of loaded file
00088a20: 10400123 beq r2,r0,0x00088eb0
00088a24: 00403021 addu r6,r2,r0
00088a28: 3c018009 lui r1,0x8009
00088a2c: 00300821 addu r1,r1,r16
00088a30: 8c244c4c lw r4,0x4c4c(r1)		file LBA pointer
00088a34: 3c018009 lui r1,0x8009
00088a38: 00300821 addu r1,r1,r16
00088a3c: 8c254c50 lw r5,0x4c50(r1)		file size
00088a40: 0802230a j 0x00088c28
00088a44: 00000000 nop

Loading SHP file:

00088a48: 3c03800a lui r3,0x800a
00088a4c: 8c638d7c lw r3,-0x7284(r3)		load unique spritesheet number?
00088a50: 00000000 nop
00088a54: 00031080 sll r2,r3,0x02
00088a58: 00431021 addu r2,r2,r3
00088a5c: 00021080 sll r2,r2,0x02
00088a60: 3c018005 lui r1,0x8005
00088a64: 00220821 addu r1,r1,r2
00088a68: 84229c22 lh r2,-0x63de(r1)		load unique spritesheet no.'s ID
00088a6c: 00000000 nop
00088a70: 00021080 sll r2,r2,0x02
00088a74: 3c018009 lui r1,0x8009
00088a78: 00220821 addu r1,r1,r2
00088a7c: 90234749 lbu r3,0x4749(r1)		load SEQ ID
00088a80: 00000000 nop
00088a84: 28620005 slti r2,r3,0x0005
00088a88: 14400006 bne r2,r0,0x00088aa4	branch if not RUKA/ARUTE/KANZEN
00088a8c: 00000000 nop
00088a90: 3c028009 lui r2,0x8009
00088a94: 8c426120 lw r2,0x6120(r2)
00088a98: 00000000 nop
00088a9c: 14620007 bne r3,r2,0x00088abc	branch if SEQ doesn't match SEQ at 0x80096120?
00088aa0: 000380c0 sll r16,r3,0x03

SEQ/SHP file ID matches RAM:

00088aa4: 34120002 ori r18,r0,0x0002		check return 0x2 if still SHP/SEQ to load?
00088aa8: 34020003 ori r2,r0,0x0003
00088aac: 3c01800a lui r1,0x800a
00088ab0: ac208d80 sw r0,-0x7280(r1)		set ram location of file loaded into ram, to 0	
00088ab4: 080223ac j 0x00088eb0
00088ab8: ae220000 sw r2,0x0000(r17)		set load func. index to 3 (animate all units thrice, finalise)

SEQ does not match ID in RAM:

00088abc: 3c018009 lui r1,0x8009
00088ac0: 00300821 addu r1,r1,r16
00088ac4: 8c244c08 lw r4,0x4c08(r1)		load file size of SEQ
00088ac8: 3c018009 lui r1,0x8009
00088acc: ac236120 sw r3,0x6120(r1)		make it match
00088ad0: 0c011105 jal 0x00044414		dedicate RAM
00088ad4: 00000000 nop
00088ad8: 3c01800a lui r1,0x800a
00088adc: ac228d80 sw r2,-0x7280(r1)		store file location
00088ae0: 104000f3 beq r2,r0,0x00088eb0
00088ae4: 00403021 addu r6,r2,r0
00088ae8: 3c018009 lui r1,0x8009
00088aec: 00300821 addu r1,r1,r16
00088af0: 8c244c04 lw r4,0x4c04(r1)		load file LBA
00088af4: 3c018009 lui r1,0x8009
00088af8: 00300821 addu r1,r1,r16
00088afc: 8c254c08 lw r5,0x4c08(r1)		load file size
00088b00: 0802230a j 0x00088c28
00088b04: 00000000 nop

loading spritesheet data for RUKA+

00088b08: 3c02800a lui r2,0x800a
00088b0c: 8c428d7c lw r2,-0x7284(r2)		load unique spritesheet No.
00088b10: 00000000 nop
00088b14: 00021880 sll r3,r2,0x02
00088b18: 00621821 addu r3,r3,r2
00088b1c: 00031880 sll r3,r3,0x02
00088b20: 3c018005 lui r1,0x8005
00088b24: 00230821 addu r1,r1,r3
00088b28: 84229c22 lh r2,-0x63de(r1)		load unique spritesheet No.'s ID
00088b2c: 00000000 nop
00088b30: 284200a0 slti r2,r2,0x00a0		check if legal
00088b34: 14400004 bne r2,r0,0x00088b48	branch if so
00088b38: 34020001 ori r2,r0,0x0001
00088b3c: 3c018005 lui r1,0x8005
00088b40: 00230821 addu r1,r1,r3
00088b44: a4229c22 sh r2,-0x63de(r1)		set sprite to 1 if illegal
00088b48: 3c03800a lui r3,0x800a
00088b4c: 8c638d7c lw r3,-0x7284(r3)
00088b50: 00000000 nop
00088b54: 00031080 sll r2,r3,0x02
00088b58: 00431021 addu r2,r2,r3
00088b5c: 00021080 sll r2,r2,0x02
00088b60: 3c018005 lui r1,0x8005
00088b64: 00220821 addu r1,r1,r2
00088b68: 84249c22 lh r4,-0x63de(r1)		load unique spritesheet ID
00088b6c: 0c020707 jal 0x00081c1c		Save Spritesheet ID to spritesheet data - checks if unique spritesheet? up to maximum of 9
00088b70: 00000000 nop
00088b74: 10400006 beq r2,r0,0x00088b90	branch if not unique spritesheet
00088b78: 00000000 nop
00088b7c: 34120002 ori r18,r0,0x0002		if unique spritesheet, return 2 if not yet at limit of sprites?
00088b80: 3c01800a lui r1,0x800a
00088b84: ac208d80 sw r0,-0x7280(r1)		set sprite file to 0 (not needed)
00088b88: 080223ac j 0x00088eb0
00088b8c: ae300000 sw r16,0x0000(r17)		set counter? thing? to 0

unique spritesheet?

00088b90: 3c02800a lui r2,0x800a
00088b94: 8c428d7c lw r2,-0x7284(r2)
00088b98: 00000000 nop
00088b9c: 00021880 sll r3,r2,0x02
00088ba0: 00621821 addu r3,r3,r2
00088ba4: 00031880 sll r3,r3,0x02
00088ba8: 3c018005 lui r1,0x8005
00088bac: 00230821 addu r1,r1,r3
00088bb0: 84229c22 lh r2,-0x63de(r1)
00088bb4: 00000000 nop
00088bb8: 000210c0 sll r2,r2,0x03
00088bbc: 3c018009 lui r1,0x8009
00088bc0: 00220821 addu r1,r1,r2
00088bc4: 8c244cd8 lw r4,0x4cd8(r1)		load Spritesheet filesize?
00088bc8: 0c011105 jal 0x00044414
00088bcc: 00000000 nop
00088bd0: 00403021 addu r6,r2,r0
00088bd4: 3c01800a lui r1,0x800a
00088bd8: ac228d80 sw r2,-0x7280(r1)		store pointer to sheet in RAM
00088bdc: 10c000b4 beq r6,r0,0x00088eb0
00088be0: 00000000 nop
00088be4: 3c02800a lui r2,0x800a
00088be8: 8c428d7c lw r2,-0x7284(r2)
00088bec: 00000000 nop
00088bf0: 00021880 sll r3,r2,0x02
00088bf4: 00621821 addu r3,r3,r2
00088bf8: 00031880 sll r3,r3,0x02
00088bfc: 3c018005 lui r1,0x8005
00088c00: 00230821 addu r1,r1,r3
00088c04: 84229c22 lh r2,-0x63de(r1)
00088c08: 00000000 nop
00088c0c: 000210c0 sll r2,r2,0x03
00088c10: 3c018009 lui r1,0x8009
00088c14: 00220821 addu r1,r1,r2
00088c18: 8c244cd4 lw r4,0x4cd4(r1)		load spritesheet LBA
00088c1c: 3c018009 lui r1,0x8009
00088c20: 00220821 addu r1,r1,r2
00088c24: 8c254cd8 lw r5,0x4cd8(r1)		load SPR filesize?
00088c28: 0c0111a5 jal 0x00044694			load data from disc
00088c2c: 00000000 nop
00088c30: 1040000b beq r2,r0,0x00088c60
00088c34: 00000000 nop
00088c38: 3c04800a lui r4,0x800a
00088c3c: 8c848d80 lw r4,-0x7280(r4)
00088c40: 0c011273 jal 0x000449cc
00088c44: 00000000 nop
00088c48: 080223ac j 0x00088eb0
00088c4c: 00000000 nop

nulled load phase

00088c50: 0c0111b2 jal 0x000446c8		return *0x8004eaf8?
00088c54: 00000000 nop
00088c58: 14400095 bne r2,r0,0x00088eb0	branch if not 0
00088c5c: 00000000 nop
00088c60: 8e220000 lw r2,0x0000(r17)
00088c64: 00000000 nop
00088c68: 24420001 addiu r2,r2,0x0001
00088c6c: 080223ac j 0x00088eb0
00088c70: ae220000 sw r2,0x0000(r17)		if 0, add 1 to counter? thing? and end.

Copying data to ram:

00088c74: 3c03800a lui r3,0x800a
00088c78: 8c638d74 lw r3,-0x728c(r3)			file func. index
00088c7c: 00000000 nop
00088c80: 10720017 beq r3,r18,0x00088ce0		Branch if copying SEQ data to RAM
00088c84: 28620002 slti r2,r3,0x0002
00088c88: 10400005 beq r2,r0,0x00088ca0		
00088c8c: 00000000 nop
00088c90: 10600007 beq r3,r0,0x00088cb0		Branch if copying SHP data to RAM
00088c94: 00000000 nop
00088c98: 08022385 j 0x00088e14
00088c9c: 00000000 nop
00088ca0: 1070001b beq r3,r16,0x00088d10		Branch if making unit appear on screen? (boss style, i guess)
00088ca4: 00000000 nop
00088ca8: 08022385 j 0x00088e14
00088cac: 00000000 nop

RUKA/ARUTE/KANZEN SHP copying

00088cb0: 3c04800a lui r4,0x800a
00088cb4: 2484839c addiu r4,r4,0x839c			SHP address for RUKA/ARUTE/KANZEN frame graphic pointers
00088cb8: 3c05800a lui r5,0x800a
00088cbc: 8ca58d80 lw r5,-0x7280(r5)			location of file loaded into ram
00088cc0: 3c02800a lui r2,0x800a
00088cc4: 24428dec addiu r2,r2,0x8dec
00088cc8: 3c01800c lui r1,0x800c
00088ccc: ac22f78c sw r2,-0x0874(r1)			parse start of true graphic data
00088cd0: 0c021cef jal 0x000873bc			copy SHP data into RAM
00088cd4: 00000000 nop
00088cd8: 08022385 j 0x00088e14
00088cdc: 00000000 nop

RUKA/ARUTE/KANZEN SEQ copying

00088ce0: 3c04800c lui r4,0x800c
00088ce4: 24840e58 addiu r4,r4,0x0e58			SEQ address for RUKA/ARUTE/KANZEN animation pointers
00088ce8: 3c05800a lui r5,0x800a
00088cec: 8ca58d80 lw r5,-0x7280(r5)			location of file loaded into ram
00088cf0: 3c02800e lui r2,0x800e
00088cf4: 24424670 addiu r2,r2,0x4670
00088cf8: 3c01800a lui r1,0x800a
00088cfc: ac221c58 sw r2,0x1c58(r1)			0x800a1c58 - start of animation instructions for RUKA/ARUTE/KANZEN
00088d00: 0c021c7d jal 0x000871f4			Copy SEQ data into RAM - only used for RUKA/ARUTE/KANZEN?
00088d04: 00000000 nop
00088d08: 08022385 j 0x00088e14
00088d0c: 00000000 nop

RUKA/ARUTE/KANZEN boss appearance (animates all units 3 frames. helpful?)

00088d10: 3c03800a lui r3,0x800a
00088d14: 8c638d7c lw r3,-0x7284(r3)			load unique spritesheet no.
00088d18: 00000000 nop
00088d1c: 00031080 sll r2,r3,0x02
00088d20: 00431021 addu r2,r2,r3
00088d24: 00021080 sll r2,r2,0x02
00088d28: 3c018005 lui r1,0x8005
00088d2c: 00220821 addu r1,r1,r2
00088d30: 84289c22 lh r8,-0x63de(r1)			load USN's ID
00088d34: 3c018005 lui r1,0x8005
00088d38: 00220821 addu r1,r1,r2
00088d3c: 90249c1c lbu r4,-0x63e4(r1)			load X Coordinate
00088d40: 3c018005 lui r1,0x8005
00088d44: 00220821 addu r1,r1,r2
00088d48: 90259c1d lbu r5,-0x63e3(r1)			load Y Coordinate
00088d4c: 3c018005 lui r1,0x8005
00088d50: 00220821 addu r1,r1,r2
00088d54: 90269c1e lbu r6,-0x63e2(r1)			Load Map Level
00088d58: 3c03800a lui r3,0x800a
00088d5c: 8c638d7c lw r3,-0x7284(r3)			load USN
00088d60: 3c018005 lui r1,0x8005
00088d64: 00220821 addu r1,r1,r2
00088d68: 84279c20 lh r7,-0x63e0(r1)			current facing
00088d6c: 00031080 sll r2,r3,0x02
00088d70: 00431021 addu r2,r2,r3
00088d74: 00021080 sll r2,r2,0x02
00088d78: afa80010 sw r8,0x0010(r29)			parse USN's ID
00088d7c: 3c018005 lui r1,0x8005
00088d80: 00220821 addu r1,r1,r2
00088d84: 84229c24 lh r2,-0x63dc(r1)			unit Palette ID
00088d88: 3c03800a lui r3,0x800a
00088d8c: 8c638d7c lw r3,-0x7284(r3)			load USN
00088d90: afa20014 sw r2,0x0014(r29)			
00088d94: 00031080 sll r2,r3,0x02
00088d98: 00431021 addu r2,r2,r3
00088d9c: 00021080 sll r2,r2,0x02
00088da0: 3c018005 lui r1,0x8005
00088da4: 00220821 addu r1,r1,r2
00088da8: 84229c26 lh r2,-0x63da(r1)			load unit's Misc. ID
00088dac: 3c03800a lui r3,0x800a
00088db0: 8c638d7c lw r3,-0x7284(r3)			USN
00088db4: afa20018 sw r2,0x0018(r29)
00088db8: 00031080 sll r2,r3,0x02
00088dbc: 00431021 addu r2,r2,r3
00088dc0: 00021080 sll r2,r2,0x02
00088dc4: 3c018005 lui r1,0x8005
00088dc8: 00220821 addu r1,r1,r2
00088dcc: 8c229c28 lw r2,-0x63d8(r1)			Load Unit's Battle data pointer
00088dd0: 3c03800a lui r3,0x800a
00088dd4: 8c638d7c lw r3,-0x7284(r3)
00088dd8: afa2001c sw r2,0x001c(r29)			parse battle data pointer
00088ddc: 00031080 sll r2,r3,0x02
00088de0: 00431021 addu r2,r2,r3
00088de4: 00021080 sll r2,r2,0x02
00088de8: 3c018005 lui r1,0x8005
00088dec: 00220821 addu r1,r1,r2
00088df0: 8c239c2c lw r3,-0x63d4(r1)			unit's battle presense (0 = present, 1 = absent)
00088df4: 3c02800a lui r2,0x800a
00088df8: 8c428d80 lw r2,-0x7280(r2)			load file pointer to currently loaded file?
00088dfc: 00000000 nop
00088e00: afa20024 sw r2,0x0024(r29)
00088e04: 0c021e8a jal 0x00087a28			Misc unit data initialization
00088e08: afa30020 sw r3,0x0020(r29)			0 if setting unit to toggle unit graphic trigger on
00088e0c: 0c022202 jal 0x00088808			Perform Animate All Units 3 times
00088e10: 00000000 nop
00088e14: 3c03800a lui r3,0x800a
00088e18: 24638d78 addiu r3,r3,0x8d78			load func. index
00088e1c: 8c620000 lw r2,0x0000(r3)
00088e20: 00000000 nop
00088e24: 24420001 addiu r2,r2,0x0001
00088e28: 080223ac j 0x00088eb0
00088e2c: ac620000 sw r2,0x0000(r3)			Increment and store (set 3)

Finalise

00088e30: 3c04800a lui r4,0x800a
00088e34: 8c848d80 lw r4,-0x7280(r4)			load pointer to file in RAM
00088e38: 00000000 nop
00088e3c: 10800003 beq r4,r0,0x00088e4c
00088e40: 00000000 nop
00088e44: 0c011273 jal 0x000449cc			restore file
00088e48: 00000000 nop
00088e4c: 3c03800a lui r3,0x800a
00088e50: 8c638d74 lw r3,-0x728c(r3)			load USN
00088e54: 00000000 nop
00088e58: 04600014 bltz r3,0x00088eac			?
00088e5c: ae200000 sw r0,0x0000(r17)			store load func. index as 0
00088e60: 28620002 slti r2,r3,0x0002
00088e64: 14400005 bne r2,r0,0x00088e7c	Branch if file func. index < 2
00088e68: 00000000 nop
00088e6c: 10700008 beq r3,r16,0x00088e90	Branch if = 2
00088e70: 34120002 ori r18,r0,0x0002
00088e74: 080223ac j 0x00088eb0
00088e78: 00000000 nop
00088e7c: 24620001 addiu r2,r3,0x0001
00088e80: 3c01800a lui r1,0x800a
00088e84: ac228d74 sw r2,-0x728c(r1)		increment func. index by 1
00088e88: 080223ac j 0x00088eb0
00088e8c: 34120002 ori r18,r0,0x0002		return 2 if not at max sprites?
00088e90: 3c02800a lui r2,0x800a
00088e94: 8c428d7c lw r2,-0x7284(r2)
00088e98: 3c01800a lui r1,0x800a
00088e9c: ac208d74 sw r0,-0x728c(r1)		Reset load func. index to 0
00088ea0: 24420001 addiu r2,r2,0x0001
00088ea4: 3c01800a lui r1,0x800a
00088ea8: ac228d7c sw r2,-0x7284(r1)		increment USN
00088eac: 34120002 ori r18,r0,0x0002

End:

00088eb0: 3c02800a lui r2,0x800a
00088eb4: 8c428d7c lw r2,-0x7284(r2)		load current unique spritesheet ID
00088eb8: 3c038005 lui r3,0x8005
00088ebc: 8c639c18 lw r3,-0x63e8(r3)		number of sprites to load in this loop (like... loading all 5 units from formation, this number would be 5 i guess?)
00088ec0: 00000000 nop
00088ec4: 0043102a slt r2,r2,r3		check against limit?
00088ec8: 00021023 subu r2,r0,r2
00088ecc: 02421024 and r2,r18,r2		return 0x0, 0x1 or 0x2?
00088ed0: 8fbf0034 lw r31,0x0034(r29)
00088ed4: 8fb20030 lw r18,0x0030(r29)
00088ed8: 8fb1002c lw r17,0x002c(r29)
00088edc: 8fb00028 lw r16,0x0028(r29)
00088ee0: 27bd0038 addiu r29,r29,0x0038
00088ee4: 03e00008 jr r31
00088ee8: 00000000 nop