Weather/time of day/tile palette modification

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search

Also used for chicken/crystal/frog/treasure

00081d54: 27bdffb0 addiu r29,r29,0xffb0
00081d58: afb60040 sw r22,0x0040(r29)
00081d5c: 0080b021 addu r22,r4,r0
00081d60: afb00028 sw r16,0x0028(r29)
00081d64: afbf004c sw r31,0x004c(r29)
00081d68: afbe0048 sw r30,0x0048(r29)
00081d6c: afb70044 sw r23,0x0044(r29)
00081d70: afb5003c sw r21,0x003c(r29)
00081d74: afb40038 sw r20,0x0038(r29)
00081d78: afb30034 sw r19,0x0034(r29)
00081d7c: afb20030 sw r18,0x0030(r29)
00081d80: afb1002c sw r17,0x002c(r29)
00081d84: afa60020 sw r6,0x0020(r29)
00081d88: 92de0005 lbu r30,0x0005(r22)		load spritesheet VRAM slot
00081d8c: 92d70007 lbu r23,0x0007(r22)		load palette
00081d90: 001e1100 sll r2,r30,0x04		VRAM ID * 10
00081d94: 005e1023 subu r2,r2,r30		VRAM ID * f
00081d98: 00021100 sll r2,r2,0x04		VRAM ID * f0
00081d9c: 005e1021 addu r2,r2,r30		VRAM ID * f1
00081da0: 00021880 sll r3,r2,0x02		VRAM ID * 3c4
00081da4: 00621823 subu r3,r3,r2		VRAM ID * 2d3
00081da8: 000310c0 sll r2,r3,0x03		VRAM ID * 1698
00081dac: 00621821 addu r3,r3,r2		VRAM ID * 196b
00081db0: 00031840 sll r3,r3,0x01		VRAM ID * 32d6
00081db4: 3c01800c lui r1,0x800c
00081db8: 00230821 addu r1,r1,r3
00081dbc: 90227ce9 lbu r2,0x7ce9(r1)		load spritesheet ID
00081dc0: 92d50004 lbu r21,0x0004(r22)		load misc ID
00081dc4: 2442ffa0 addiu r2,r2,0xffa0		sprite - 60
00081dc8: 2c42003b sltiu r2,r2,0x003b		set if generic sprite
00081dcc: 10400008 beq r2,r0,0x00081df0			branch if unique or monster sprite
00081dd0: 00a08021 addu r16,r5,r0			r16 = tile effects flags?

If generic sprite:

00081dd4: 3c02800d lui r2,0x800d
00081dd8: 2442adbe addiu r2,r2,0xadbe
00081ddc: 00621021 addu r2,r3,r2
00081de0: 00172140 sll r4,r23,0x05				palette shift left 0x05
00081de4: 24840100 addiu r4,r4,0x0100			r4 = palette shifted + 0x0100
00081de8: 0802077f j 0x00081dfc
00081dec: 00442021 addu r4,r2,r4				palette shifted + 0x0100 + address

If unique sprite:

00081df0: 3c04800d lui r4,0x800d
00081df4: 2484aebe addiu r4,r4,0xaebe			0x800daebe
00081df8: 00642021 addu r4,r3,r4			VRAM graphic data slot for unit
00081dfc: 3405000a ori r5,r0,0x000a
00081e00: 02a03021 addu r6,r21,r0			Unit's misc. ID
00081e04: 0c0249b6 jal 0x000926d8				get palette data
00081e08: 00003821 addu r7,r0,r0
00081e0c: 00009021 addu r18,r0,r0
00081e10: 00009821 addu r19,r0,r0
00081e14: 34020002 ori r2,r0,0x0002
00081e18: 12020011 beq r16,r2,0x00081e60		branch if tile effects = 2
00081e1c: 00008821 addu r17,r0,r0
00081e20: 2a020003 slti r2,r16,0x0003
00081e24: 10400005 beq r2,r0,0x00081e3c			branch if tile effects > 2
00081e28: 34020001 ori r2,r0,0x0001
00081e2c: 12020008 beq r16,r2,0x00081e50		branch if tile effects = 1
00081e30: 00000000 nop
00081e34: 0802079f j 0x00081e7c
00081e38: 00000000 nop
00081e3c: 34020003 ori r2,r0,0x0003
00081e40: 1202000b beq r16,r2,0x00081e70		branch if tile effects = 3
00081e44: 00000000 nop
00081e48: 0802079f j 0x00081e7c
00081e4c: 00000000 nop
tile effects = 1
00081e50: 2412fffc addiu r18,r0,0xfffc
00081e54: 2413fffc addiu r19,r0,0xfffc
00081e58: 0802079f j 0x00081e7c
00081e5c: 2411fffc addiu r17,r0,0xfffc
tile effects = 2
00081e60: 2412fff8 addiu r18,r0,0xfff8
00081e64: 2413fff8 addiu r19,r0,0xfff8
00081e68: 0802079f j 0x00081e7c
00081e6c: 2411fff8 addiu r17,r0,0xfff8
tile effects = 3
00081e70: 2412fff4 addiu r18,r0,0xfff4
00081e74: 2413fff4 addiu r19,r0,0xfff4
00081e78: 2411fff4 addiu r17,r0,0xfff4
00081e7c: 3c14800b lui r20,0x800b
00081e80: 26946698 addiu r20,r20,0x6698
00081e84: 8e820000 lw r2,0x0000(r20)		load ??
00081e88: 00000000 nop
00081e8c: 30420002 andi r2,r2,0x0002
00081e90: 14400044 bne r2,r0,0x00081fa4		
00081e94: 00000000 nop
00081e98: 0c04ed64 jal 0x0013b590			get time of day
00081e9c: 34040023 ori r4,r0,0x0023
00081ea0: 34040024 ori r4,r0,0x0024
00081ea4: 0c04ed64 jal 0x0013b590			get weather effects
00081ea8: 00408021 addu r16,r2,r0
00081eac: 1440001d bne r2,r0,0x00081f24		branch if stormy weather?
00081eb0: 00000000 nop
Time of day mods?
00081eb4: 8e820000 lw r2,0x0000(r20)
00081eb8: 00000000 nop
00081ebc: 30420001 andi r2,r2,0x0001
00081ec0: 1040000b beq r2,r0,0x00081ef0		branch if skipping time of day mod?
00081ec4: 2e020005 sltiu r2,r16,0x0005
00081ec8: 10400007 beq r2,r0,0x00081ee8		branch if time of day out of bounds?
00081ecc: 00101080 sll r2,r16,0x02
00081ed0: 3c018006 lui r1,0x8006
00081ed4: 00220821 addu r1,r1,r2
00081ed8: 8c227e00 lw r2,0x7e00(r1)
00081edc: 00000000 nop
00081ee0: 00400008 jr r2
00081ee4: 00000000 nop
00081ee8: 080207df j 0x00081f7c
00081eec: 2631fffe addiu r17,r17,0xfffe
00081ef0: 1040000a beq r2,r0,0x00081f1c		branch if time of day out of bounds?
00081ef4: 00101080 sll r2,r16,0x02
00081ef8: 3c018006 lui r1,0x8006
00081efc: 00220821 addu r1,r1,r2
00081f00: 8c227e18 lw r2,0x7e18(r1)
00081f04: 00000000 nop
00081f08: 00400008 jr r2
00081f0c: 00000000 nop
00081f10: 2631ffff addiu r17,r17,0xffff
00081f14: 080207e9 j 0x00081fa4
00081f18: 26520001 addiu r18,r18,0x0001
00081f1c: 080207df j 0x00081f7c
00081f20: 2631fffe addiu r17,r17,0xfffe
Stormy Weather?
00081f24: 8e820000 lw r2,0x0000(r20)
00081f28: 00000000 nop
00081f2c: 30420001 andi r2,r2,0x0001
00081f30: 10400009 beq r2,r0,0x00081f58			branch if skipping?
00081f34: 2e020005 sltiu r2,r16,0x0005
00081f38: 10400017 beq r2,r0,0x00081f98
00081f3c: 00101080 sll r2,r16,0x02
00081f40: 3c018006 lui r1,0x8006
00081f44: 00220821 addu r1,r1,r2
00081f48: 8c227e30 lw r2,0x7e30(r1)
00081f4c: 00000000 nop
00081f50: 00400008 jr r2
00081f54: 00000000 nop
00081f58: 1040000f beq r2,r0,0x00081f98
00081f5c: 00101080 sll r2,r16,0x02
00081f60: 3c018006 lui r1,0x8006
00081f64: 00220821 addu r1,r1,r2
00081f68: 8c227e48 lw r2,0x7e48(r1)
00081f6c: 00000000 nop
00081f70: 00400008 jr r2
00081f74: 00000000 nop
00081f78: 2631fffd addiu r17,r17,0xfffd
00081f7c: 2673ffff addiu r19,r19,0xffff
00081f80: 080207e9 j 0x00081fa4
00081f84: 26520002 addiu r18,r18,0x0002
00081f88: 2631fffc addiu r17,r17,0xfffc
00081f8c: 2673ffff addiu r19,r19,0xffff
00081f90: 080207e9 j 0x00081fa4
00081f94: 26520003 addiu r18,r18,0x0003
00081f98: 2631fffc addiu r17,r17,0xfffc
00081f9c: 2673fffe addiu r19,r19,0xfffe
00081fa0: 26520004 addiu r18,r18,0x0004
00081fa4: 0c01f4fd jal 0x0007d3f4
00081fa8: 02c02021 addu r4,r22,r0
00081fac: 3c03800b lui r3,0x800b
00081fb0: 8c636698 lw r3,0x6698(r3)
00081fb4: 00000000 nop
00081fb8: 30630002 andi r3,r3,0x0002
00081fbc: 1460000a bne r3,r0,0x00081fe8		
00081fc0: 00021400 sll r2,r2,0x10
00081fc4: 00021403 sra r2,r2,0x10
00081fc8: 86c30042 lh r3,0x0042(r22)
00081fcc: 2442ffd0 addiu r2,r2,0xffd0		some height mod?
00081fd0: 0062182a slt r3,r3,r2
00081fd4: 10600004 beq r3,r0,0x00081fe8
00081fd8: 00000000 nop
00081fdc: 00009021 addu r18,r0,r0			clear modifications
00081fe0: 00009821 addu r19,r0,r0
00081fe4: 00008821 addu r17,r0,r0
00081fe8: 92c40006 lbu r4,0x0006(r22)		load spritesheet ID?
00081fec: 3402009c ori r2,r0,0x009c
00081ff0: 10820012 beq r4,r2,0x0008203c		branch if Chicken!
00081ff4: 2882009d slti r2,r4,0x009d
00081ff8: 10400005 beq r2,r0,0x00082010		branch if frog or treasure!
00081ffc: 3402009b ori r2,r0,0x009b
00082000: 1082000a beq r4,r2,0x0008202c		branch if Crystal!
00082004: 001e1100 sll r2,r30,0x04
00082008: 0802081b j 0x0008206c			uh error i guess?
0008200c: 00000000 nop

spritesheet = frog or treasure

00082010: 3402009d ori r2,r0,0x009d
00082014: 1082000d beq r4,r2,0x0008204c		Branch if frog!
00082018: 3402009e ori r2,r0,0x009e
0008201c: 1082000f beq r4,r2,0x0008205c		branch if treasure!
00082020: 001e1100 sll r2,r30,0x04
00082024: 0802081b j 0x0008206c			?
00082028: 00000000 nop

spritesheet = crystal

0008202c: 3c04800c lui r4,0x800c
00082030: 2484f8d0 addiu r4,r4,0xf8d0			crystal palette data starts at 0x800cf8d0
00082034: 08020827 j 0x0008209c
00082038: 00171140 sll r2,r23,0x05			r23 = palette shifted to get palette address index

spritesheet = chicken

0008203c: 3c04800c lui r4,0x800c
00082040: 2484f790 addiu r4,r4,0xf790			chicken palette data starts at 0x800cf790
00082044: 08020827 j 0x0008209c
00082048: 00171140 sll r2,r23,0x05

spritesheet = frog

0008204c: 3c04800c lui r4,0x800c
00082050: 2484f830 addiu r4,r4,0xf830			frog palette data starts at 0x800cf830
00082054: 08020827 j 0x0008209c
00082058: 00171140 sll r2,r23,0x05

spritesheet = treasure

0008205c: 3c04800c lui r4,0x800c
00082060: 2484f990 addiu r4,r4,0xf990			treasure palette data starts at 0x800cf990
00082064: 08020827 j 0x0008209c
00082068: 00171140 sll r2,r23,0x05

spritesheet not any of the above. resolve with unit's sprite palette?

0008206c: 005e1023 subu r2,r2,r30
00082070: 00021100 sll r2,r2,0x04
00082074: 005e1021 addu r2,r2,r30
00082078: 00022080 sll r4,r2,0x02
0008207c: 00822023 subu r4,r4,r2
00082080: 000410c0 sll r2,r4,0x03
00082084: 00822021 addu r4,r4,r2
00082088: 00042040 sll r4,r4,0x01
0008208c: 3c02800d lui r2,0x800d
00082090: 2442adbe addiu r2,r2,0xadbe
00082094: 00822021 addu r4,r4,r2
00082098: 00171140 sll r2,r23,0x05

Branch here if chicken/frog/crystal/treasure

0008209c: 00822021 addu r4,r4,r2			r4 = palette address to copy
000820a0: 34050003 ori r5,r0,0x0003
000820a4: 02a03021 addu r6,r21,r0			r6 = misc ID
000820a8: 00003821 addu r7,r0,r0
000820ac: 00111400 sll r2,r17,0x10			
000820b0: 00021403 sra r2,r2,0x10		
000820b4: afa20010 sw r2,0x0010(r29)		store palette mod 1
000820b8: 00131400 sll r2,r19,0x10
000820bc: 00021403 sra r2,r2,0x10
000820c0: afa20014 sw r2,0x0014(r29)		store palette mod 2
000820c4: 00121400 sll r2,r18,0x10
000820c8: 8fa80020 lw r8,0x0020(r29)		load r6 input
000820cc: 00021403 sra r2,r2,0x10
000820d0: afa20018 sw r2,0x0018(r29)		store palette mod 3
000820d4: 0c024b53 jal 0x00092d4c			00092d4c - 00092dbc - edit unit's palette
000820d8: afa8001c sw r8,0x001c(r29)		store r6 input
000820dc: 8fbf004c lw r31,0x004c(r29)
000820e0: 8fbe0048 lw r30,0x0048(r29)
000820e4: 8fb70044 lw r23,0x0044(r29)
000820e8: 8fb60040 lw r22,0x0040(r29)
000820ec: 8fb5003c lw r21,0x003c(r29)
000820f0: 8fb40038 lw r20,0x0038(r29)
000820f4: 8fb30034 lw r19,0x0034(r29)
000820f8: 8fb20030 lw r18,0x0030(r29)
000820fc: 8fb1002c lw r17,0x002c(r29)
00082100: 8fb00028 lw r16,0x0028(r29)
00082104: 27bd0050 addiu r29,r29,0x0050
00082108: 03e00008 jr r31
0008210c: 00000000 nop