00012d40 - 00012e78

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search

r4 = audio byte ID
r5 = ?

00012d40: 3c038003 lui r3,0x8003
00012d44: 8c632a60 lw r3,0x2a60(r3)			#load MUS pointer
00012d48: 00004821 addu r9,r0,r0
00012d4c: 00005021 addu r10,r0,r0
00012d50: 34070001 ori r7,r0,0x0001
00012d54: 34080008 ori r8,r0,0x0008
00012d58: 246600b8 addiu r6,r3,0x00b8			#pointer + 0xb8 (skips header information)
00012d5c: 246300ec addiu r3,r3,0x00ec			#P + 0xec (?)
00012d60: 94c20000 lhu r2,0x0000(r6)			"has sound"?
00012d64: 00000000 nop
00012d68: 30420001 andi r2,r2,0x0001
00012d6c: 10400009 beq r2,r0,0x00012d94		#branch if flag 1 not enabled?
00012d70: 2508ffff addiu r8,r8,0xffff			#-1
00012d74: 8c62ffd4 lw r2,-0x002c(r3)                   #sound effect in current channel
00012d78: 00000000 nop
00012d7c: 14440005 bne r2,r4,0x00012d94		#branch if sound effect in channel != input
00012d80: 00000000 nop
00012d84: 8c620000 lw r2,0x0000(r3)
00012d88: 01475025 or r10,r10,r7			#r10 = flags for all channels dedicated to sound effect ID
00012d8c: a4c00000 sh r0,0x0000(r6)			#store 0 here (sound effect found?)
00012d90: 01224825 or r9,r9,r2				#bitflag combine r9 and r2
00012d94: 00073840 sll r7,r7,0x01			#next flag to append to r10?
00012d98: 24630160 addiu r3,r3,0x0160			#next channel
00012d9c: 1500fff0 bne r8,r0,0x00012d60		#loop 8 times
00012da0: 24c60160 addiu r6,r6,0x0160			#next channel
00012da4: 34020006 ori r2,r0,0x0006
00012da8: 00452023 subu r4,r2,r5			#r4 = 6 - r5
00012dac: 34020020 ori r2,r0,0x0020
00012db0: 00451023 subu r2,r2,r5			#r2 = 0x20 - r5
00012db4: 2403ffff addiu r3,r0,0xffff			#0xffffffff 
00012db8: 00436006 srlv r12,r3,r2			#r12 = above divided by 2^(32 - r5) (leave r5 bitflags?)
00012dbc: 008c3804 sllv r7,r12,r4			#r7 = above multiplied by 2^(6 - r5) (leave r5 bitflags, between bitflag range 6 + r5 - 6 (num channels check?)
00012dc0: 00041040 sll r2,r4,0x01			#2 * r4
00012dc4: 00441021 addu r2,r2,r4			#3 *
00012dc8: 00021080 sll r2,r2,0x02			#0xc * r4
00012dcc: 00441023 subu r2,r2,r4			#0xb * r4
00012dd0: 00021140 sll r2,r2,0x05			#0x160 * (6 - r5) (space for channels expected to be used...?
00012dd4: 3c038003 lui r3,0x8003
00012dd8: 8c632a60 lw r3,0x2a60(r3)			#MUS pointer
00012ddc: 244200b8 addiu r2,r2,0x00b8                  #num channels + 0xb8
00012de0: 3c018003 lui r1,0x8003
00012de4: ac2a2a10 sw r10,0x2a10(r1)			#store bitflags for all channels dedicated to input sound effect
00012de8: 3c018003 lui r1,0x8003
00012dec: ac292a14 sw r9,0x2a14(r1)			#store bitcombined ? for all channels dedicated to input Sound Effect
00012df0: 00623021 addu r6,r3,r2			#Music file of located sound effect?
00012df4: 8c630058 lw r3,0x0058(r3)
00012df8: 000a1027 nor r2,r0,r10			#Nor r10
00012dfc: 00434024 and r8,r2,r3			#check for all music that did not match for?
00012e00: 01071024 and r2,r8,r7			#check for all music that did not match for number of channels expected?
00012e04: 1040001b beq r2,r0,0x00012e74		#branch if no valid music (end, return r2 = num channels expected)
00012e08: 240bffff addiu r11,r0,0xffff
00012e0c: 00051040 sll r2,r5,0x01                      #music file of exactly r5 channels?
00012e10: 00451021 addu r2,r2,r5
00012e14: 00021080 sll r2,r2,0x02
00012e18: 00451023 subu r2,r2,r5
00012e1c: 00024940 sll r9,r2,0x05			#r5 * 0x160 (for table entry valid to r5?)
00012e20: 8cc30010 lw r3,0x0010(r6)
00012e24: 00000000 nop
00012e28: 006b102b sltu r2,r3,r11
00012e2c: 10400008 beq r2,r0,0x00012e50		#branch ahead if not valid (?)
00012e30: 00a73806 srlv r7,r7,r5			#flush channel-expected flags with flag 6 (flags from flag 6 to 0 + r5)
00012e34: 90c2000d lbu r2,0x000d(r6)
00012e38: 00000000 nop
00012e3c: 2c420021 sltiu r2,r2,0x0021			#less than 33?
00012e40: 10400004 beq r2,r0,0x00012e54		#branch if not
00012e44: 00ec102b sltu r2,r7,r12
00012e48: 00605821 addu r11,r3,r0
00012e4c: 00806821 addu r13,r4,r0
00012e50: 00ec102b sltu r2,r7,r12
00012e54: 10400003 beq r2,r0,0x00012e64
00012e58: 00000000 nop
00012e5c: 08004b9d j 0x00012e74
00012e60: 01a02021 addu r4,r13,r0
00012e64: 00c93023 subu r6,r6,r9
00012e68: 01071024 and r2,r8,r7
00012e6c: 1440ffec bne r2,r0,0x00012e20
00012e70: 00852023 subu r4,r4,r5
00012e74: 03e00008 jr r31
00012e78: 00801021 addu r2,r4,r0