Discussion about software development for the old-school Gameboys, ranging from the "Gray brick" to Gameboy Color
(Launched in 2008)
You are not logged in.
So,
As I understand it, there are 16 registers for the different wave forms of the wave sound channel, and each register is divided into 4-bit nibbles making a total of 32 sound wave variations for the 'wave table'.
My question is, how do these 4 bits represent wave patterns and how are there 32 variations instead 256? How does the system interpret them?
I've tried figuring out the math, but as far as I can tell you'd need more than 16 8-bit registers for all the sound waves since it seems like you'd need 8 bits for each 4-beat wave (the minimum points for a wave pattern). Even if each wave has only 4 points, it seems like each point would need 2 bits to show where they appear on the graph; 00=off, 01=low, 10=mid, 11=high.
So what is the algorithm here?
I clearly don't how this is working, but given what I've described above, here's how I thought it would be coded:
Waveform (1 byte):
-point 1: 2 bits
-point 2: 2 bits
-point 3: 2 bits
-point 4: 2 bits
4 possible places for 4 wavepoints = 4^4 = 256 waveforms (which include all wave variations that include 'turned off' notes)
Thank you
Offline
Obviously you could cut out duplicates, but I didn't check if this was exactly half of the variations.
Maybe it is?
That would solve the problem because then you'd only have 2^4 variations = 16.
Seems like something is off here though.
A flip register?
Offline
It's so simple that you're probably going to say "d'oh!" when you hear it. It's simply a single looping waveform with 32 samples. Each byte contains two 4-bit samples, one in each nibble. So for example a sine wave might look something like this:
__---__ _- -_ _ - - -_ _ _ _ - - -_ _- --___-- 9ACDEEFFFEEDCA986532110001123568
In this case, [$FF30]=$9A, [$FF31]=$9CD, [$FF32]=$EE and so on.
If you want to play a new waveform you need to stop the channel (to be able to safely access the wave buffer) and load the new waveform.
Offline
nitro2k01 wrote:
It's so simple that you're probably going to say "d'oh!" when you hear it. It's simply a single looping waveform with 32 samples. Each byte contains two 4-bit samples, one in each nibble. So for example a sine wave might look something like this:
Code:
__---__ _- -_ _ - - -_ _ _ _ - - -_ _- --___-- 9ACDEEFFFEEDCA986532110001123568In this case, [$FF30]=$9A, [$FF31]=$9CD, [$FF32]=$EE and so on.
If you want to play a new waveform you need to stop the channel (to be able to safely access the wave buffer) and load the new waveform.
D'OH!
Haha, seriously - THANK YOU!
That is so awesomely simple I can't believe I didn't see it. I was trying to make charts figuring out 16 variations of tiny waveforms. It never occurred to me it would be a big 32-part wave that you could take parts out of and duplicate to form new 32-part waveforms. I'm an amateur, so I was expecting the waveform to be 16 bits at most due to the addressing. I guess my next obvious question then is, why is it 16 bytes (although I definitely get why you might break those up into 32 parts)? Also, does it take longer to listen to a full sine wave than one that uses fewer registers?
Offline
It's 16 bytes because that fits 32 4-bit samples. Why 32 samples? Ask Nintendo. I'm guessing it's a sweet spot, not too short, not too long.
The wave channel always loops all 32 samples. There's no way to make it use fewer of the registers/samples.
Offline
nitro2k01 wrote:
It's 16 bytes because that fits 32 4-bit samples. Why 32 samples? Ask Nintendo. I'm guessing it's a sweet spot, not too short, not too long.
The wave channel always loops all 32 samples. There's no way to make it use fewer of the registers/samples.
I thought that might be the case.
Thank you again for answering.
Offline