NESDev and Strangulation Records messageboards
Forum Index | FAQ | New User | Login | Search

Previous ThreadView All ThreadsNext ThreadShow in Flat Mode*


SubjectRe: DMC Saw and Square without hogging CPU  
Posted byblargg
Posted on11/28/03 06:52 AM
From IP199.170.89.63  



It looks and sounds as if only the DMC period is affecting the pitch. The slopes of the saws are evenly stepped, with no delays in them, so it seems the fine-tune delay isn't having any effect. My guess is that the IRQ occurs immediately after the first (and only) byte is fetched, and that the retriggering of the DMC is delayed until after all 8 bits of the sample have been played:

    _                                                _
| |_ | |_
| |_ | |_
| |_ |
| |_ |
| |_ |
| |_ |
| |_ |
| |_ |
| |_ |
| |_ |
| |_ |
| |_ |
| |_ |
| |_ |
| |_ |
___| |________________|
AB C B C B C B

A: Reset DAC. Start DMC with 1 sample.

B: DMC fetches first and only byte of sample. It invokes IRQ handler
immediately since no *more* samples need to be fetched. IRQ handler runs
delay loop while DMC outputs 8 1-bit samples.

C: IRQ handler's delay loop completes and DMC is set to restart, but this is
deferred since it's already playing. Thus the delay loop has no effect.

B: DMC finishes previous sample. Restart request is noted so it starts
playing a new sample. DMC reads byte. No more bytes, so trigger IRQ. IRQ
handler enters delay loop.

C: Delay loop finishes... etc.

If this is what's happening, it makes fine-tuning of the overall wave period
more tricky. A solution is to insert a larger delay at the end of the wave,
with the DMC still outputting the sample while the delay takes place. This
would use more CPU time but for lower notes would be somewhat reasonable.
The new scheme would work like this:

_ _
| |_ | |_
| |_ | |_
| |_ |
| |_ |
| |_ |
| |_ |
| |_ |
| |_ |
| |_ |
| |_ |
| |_ |
| |_ |
| |_ |
| |_ |
| |_ |
___| |________________|
A B C D E

A: Start DMC. Immediate IRQ. Set DMC to start again after current sample finishes.

B: DMC IRQ as it begins second sample. Set DMC to start again after current sample finishes.

C: DMC IRQ as it begins third sample. Delay while DMC finishes

D: DMC finishes sample. Still delaying.

E: Start DMC. Immediate IRQ. Set DMC to start again after current sample finishes.

etc.

In this example, 33% or more CPU would be used for the delay.

I have some other ideas if this is the case. They involve running the DMC with a 17-byte sample to quickly move through some of the samples by setting its period to a higher value for a short time, then setting it back down. This might allow lower CPU usage.

I'm going to modify my NSF player to do what I think the real NES hardware does based on this new data and if it generates similar output, then I'm going to try out some new schemes.




-
Entire Thread
Subject  Posted byPosted On
*DMC Saw and Square without hogging CPU  blargg11/24/03 12:33 PM
.*Re: DMC Saw and Square without hogging CPU  Anonymous11/27/03 11:09 PM
...Re: DMC Saw and Square without hogging CPU  blargg11/28/03 06:52 AM
...*Re: DMC Saw and Square without hogging CPU  Anonymous11/28/03 11:34 AM
....*Re: DMC Saw and Square without hogging CPU  Memblers11/28/03 7:41 PM
.....*Re: DMC Saw and Square without hogging CPU  blargg11/28/03 11:30 PM
......*Re: DMC Saw and Square without hogging CPU  Memblers12/3/03 10:37 PM
.......*Re: DMC Saw and Square without hogging CPU  blargg12/4/03 00:21 AM
........*Finally works on NES hardware!  blargg12/4/03 09:35 AM
.........*Re: Finally works on NES hardware!  tepples12/4/03 4:21 PM
..........*Re: Finally works on NES hardware!  blargg12/5/03 00:21 AM
...........*Re: Finally works on NES hardware!  tepples12/5/03 01:30 AM
............*Re: Finally works on NES hardware!  Memblers12/6/03 01:32 AM
.............*Re: Finally works on NES hardware!  blargg12/6/03 10:46 PM
..............*Re: Finally works on NES hardware!  blargg12/7/03 09:27 AM
...............*Re: Finally works on NES hardware!  Memblers12/7/03 10:33 PM
........*Re: DMC Saw and Square without hogging CPU  Memblers12/4/03 06:00 AM
.........*Re: DMC Saw and Square without hogging CPU  Disch12/4/03 08:19 AM
........*Re: DMC Saw and Square without hogging CPU  tepples12/4/03 04:32 AM
.*Re: DMC Saw and Square without hogging CPU  Memblers11/24/03 9:46 PM
..*Re: DMC Saw and Square without hogging CPU  blargg11/25/03 06:31 AM
...*Re: DMC Saw and Square without hogging CPU  Memblers11/25/03 10:40 AM
....*Re: DMC Saw and Square without hogging CPU  blargg11/25/03 2:59 PM
.....*Re: DMC Saw and Square without hogging CPU  Anonymous11/25/03 4:15 PM
......*Re: verifying DMC IRQ timing  blargg11/25/03 10:41 PM
.......*Re: verifying DMC IRQ timing  Xodnizel11/25/03 11:01 PM
........*Re: verifying DMC IRQ timing  Memblers11/26/03 11:07 AM
.........*Re: verifying DMC IRQ timing  Memblers11/27/03 07:25 AM
Jump to

Memblers' homepage             Contact Me

Forums powered by WWWThreads Demo