It is currently Tue Oct 17, 2017 4:37 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Fri Aug 05, 2016 6:03 pm 
Offline

Joined: Wed Oct 21, 2015 10:28 pm
Posts: 20
Hello!
I've got some questions about the Length Counter that I can't seem to resolve by reading PanDocs, GBSSOUND.txt, http://gbdev.gg8.se/wiki/articles/Gameboy_sound_hardware(Wiki) and other sources.

Q1: Is the "enabled flag" that's mentioned in the Wiki the same as the length enable flag in bit 6 of NRx4?

Q2: I currently have the following logic for outputting the current waveform. Is this logic correct?
(I have removed other details such as duty, LFSR, DAC power, etc. to make it simple.)
Code:
    if (length != 0 || !length_enable)
        output current_volume
    else
        output 0

Q2.5: I'm using the same logic for NR52's status bits. (1 if length != 0 || !length_enable, 0 otherwise.) Is this also correct?

Q3: The Wiki mentioned that when a channel is triggered it becomes enabled. Does this mean enabling length_enable (bit 6 of NRx4) OR the "enabled flag" that's mentioned in the Wiki?

EDIT: Add Q4.
Q4: During a trigger event, if the length counter is 0, it is set to either 64(square and noise) or 256(wave). Aren't 63 or 255 the correct values?

Thank you!


Top
 Profile  
 
PostPosted: Sat Aug 06, 2016 11:25 am 
Offline

Joined: Thu Jun 16, 2016 11:53 am
Posts: 10
OK, I'm not 100% on these answers, but my emulator does pass blargg's dmg_sound test, so I'll give it a shot:

Quote:
Q1: Is the "enabled flag" that's mentioned in the Wiki the same as the length enable flag in bit 6 of NRx4?

No, I don't think so. It describes it as an "internal enabled flag", which implies its value is not exposed to the user. In my emulator, I use the NR52 status bit for this.

Quote:
Q2: I currently have the following logic for outputting the current waveform. Is this logic correct?

This seems like it should work, but I don't do it this way. Since we need to update the status bit anyway, I clear it when the length becomes zero. Then I check it to determine whether I need to produce a sample for that channel. This way I don't ouptut sound if the sweep causes the status to be disabled either.

Quote:
Q2.5: I'm using the same logic for NR52's status bits. (1 if length != 0 || !length_enable, 0 otherwise.) Is this also correct?

Same as above, I manipulate the status bit independently. A few things can affect this, length counter, DAC enabled, sweep overflow, and writing to NR10 (in a specific case).

Quote:
Q3: The Wiki mentioned that when a channel is triggered it becomes enabled. Does this mean enabling length_enable (bit 6 of NRx4) OR the "enabled flag" that's mentioned in the Wiki?

I think it just means that the channel will start producing sound, so yeah the "enabled flag". You can trigger a channel without enabling the length counter, for example.

Quote:
Q4: During a trigger event, if the length counter is 0, it is set to either 64(square and noise) or 256(wave). Aren't 63 or 255 the correct values?

It seems like 64 and 256 are correct. But there is a case where it will be 63 or 255, see under "Obscure Behavior" on that wiki:

Quote:
If a channel is triggered when the frame sequencer's next step is one that doesn't clock the length counter and the length counter is now enabled and length is being set to 64 (256 for wave channel) because it was previously zero, it is set to 63 instead (255 for wave channel).


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group