Hi,
I managed to get the two square channels in my emulator play correctly. Now I'm in the process of creating the channel 3, but I think I'm really stuck. In Blargg's "Game Boy Sound Operation" at "Wave Channel" it says:
Now what does that mean in raw practice? I got it like this in my mind (pseudo):
Apparently this is SO BAD as it sounds, but is there any other way to implement it using only the cpu clocks? Or I'm missing a lot of things here.
Thank you very much.
I managed to get the two square channels in my emulator play correctly. Now I'm in the process of creating the channel 3, but I think I'm really stuck. In Blargg's "Game Boy Sound Operation" at "Wave Channel" it says:
Quote:
The wave channel's frequency timer period is set to (2048-frequency)*2.
When the timer generates a clock, the position counter is advanced one
sample in the wave table, looping back to the beginning when it goes
past the end, then a sample is read into the sample buffer from this NEW
position.
When the timer generates a clock, the position counter is advanced one
sample in the wave table, looping back to the beginning when it goes
past the end, then a sample is read into the sample buffer from this NEW
position.
Now what does that mean in raw practice? I got it like this in my mind (pseudo):
Code:
channel3_clocks += CPU.clock; //increment a counter with cpu clocks
if(channel3_clocks >= frequency) {
advance_one_sample();
get_sample_amplitude();
channel3_clocks -= frequency;
}
if(channel3_clocks >= frequency) {
advance_one_sample();
get_sample_amplitude();
channel3_clocks -= frequency;
}
Apparently this is SO BAD as it sounds, but is there any other way to implement it using only the cpu clocks? Or I'm missing a lot of things here.
Thank you very much.