nineTENdo wrote:
is there a correlation b/w the values stored in the DMC length $4013. (ie. #$00 is supposed to mean fetch 1 sample at time. does #$01 mean fetch 2 samples and so forth?
It's 16*n+1 bytes, or 128*n+8 samples, before it one of 1)Stops 2)Interrupts your current code asking what to do 3)Repeats
Quote:
i made a little chart to see if i was actully understanding well. change if you need to or add what you can. cause i will not be able to understand with out pics.
I don't have a place to store an image, so hopefully this will help.
So, say you initialize the DMC like follows-
[$4010] = #$0F (no interrupts, no loops, play once at highest rate)
[$4011] = #64 (initialize DAC at the 50% point)
[$4012] = #0 (load samples starting at $C000)
[$4013] = #1 (play 17 bytes of delta-encoded data)
Further, say that the memory at C000 is
00 FF 00 FF 00 FF 00 FF 00 FF 00 FF 00 FF 00 FF 00
What happens is:
the DMC fetches the byte at $C000 (00)
the DMC looks at the lsb (0)
the DMC decrements the value of the DAC by 2 (minimum 0 or 1)
the DMC waits 54(NTSC) or 50(PAL) instruction cycles
the DMC looks at the 2nd lsb (also 0)
(repeat as necessary for all 8 bits)
Then the DMC fetches the byte at $C001 (FF)
it looks at the lsb (1)
the DMC then increments the value of the DAC by 2 (maximum 126 or 127)
and repeat, until we've fetched all 17 bytes.
Caveat: I don't know whether the delay is before or after the increment/decrement, but i suspect it doesn't matter in practice.
So, what's wrong with your picture is-
1- in 8 DMC cycles, you'll only be able to change the value of the DAC by 8*2=16.
2- Full scale is not FF but 7F
3- Different pitches do not consist of different numbers of the same wave but different horizontal stretching of the same wave.