Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data byte should not be ignored for latched noise channel 3 or latched volume (all channels) #5

Open
bhrousseau opened this issue Feb 21, 2024 · 0 comments

Comments

@bhrousseau
Copy link

in vgmpacker.py (def split_raw) :

					else:
						if verbose:
							print(" tone data on latched channel " + str(latched_channel))
						registers[latched_channel*2+1] = d # we no longer do any masking here # d & 63 # tone data only contains 6 bits of info anyway, so no need for mask
						if latched_channel == 3:
							print("ERROR CHANNEL")

This code does not handle when :

  • data byte is written after a latch volume (all channels)
  • data byte is written after a latch noise on channel 3

When reading this :
https://www.smspower.org/Development/SN76489
It appears that data byte should not be ignored.

Volume registers
(DDDDDD)dddd = (--vvvv)vvvv
dddd gives the 4-bit volume value.
If a data byte is written, the low 4 bits of DDDDDD update the 4-bit volume value. However, this is unnecessary.

Noise register
(DDDDDD)dddd = (---trr)-trr
The low 2 bits of dddd select the shift rate and the next highest bit (bit 2) selects the mode (white (1) or "periodic" (0)).
If a data byte is written, its low 3 bits update the shift rate and mode in the same way.

The data byte is NOT ignored. If it is, some games (e.g. Micro Machines) produce the wrong sound on their noise channel.

I suggest to use this code instead (verbose should be updated) :

		latched_type = 0

...
			if packet_size == 255:
				Packet = False
			else:
				for x in range(packet_size):
					d = rawData[n+x]
					if verbose:
					   print "  frame byte number=" +str(x)
					   print "    frame byte=" +str(d)
					if d & 128:
						# latch
						c = (d>>5)&3
						latched_channel = c
						if d & 16:
							# volume
							if verbose:
								print(" volume on channel " + str(c))
							registers[c+7] = d & register_mask
							latched_type = 1

						else:
							# tone
							if verbose:
								print(" tone on channel " + str(c))

							registers[c*2+0] = d & register_mask
							latched_type = 0                    

					else:
						if verbose:
							print(" tone data on latched channel " + str(latched_channel))

						if latched_type == 0:
							if latched_channel < 3:
								# tone upper bits
								registers[latched_channel*2+1] = d
							else:
								# update noise 
								registers[latched_channel*2] = d & 7
						else:
							# update volume
							registers[latched_channel+7] = d & 15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant