Page 1 of 1

Confusing byte format in APU docs

Posted: Sat Apr 22, 2017 11:34 am
by wbrian
I'm reading through the triangle generator docs here and I had a question about the following snippet:
DPCM samples must begin in the memory range $C000-FFFF at an address set by register $4012 (address = %11AAAAAA.AA000000).
The length of the sample in bytes is set by register $4013 (length = %LLLL.LLLL0001).
I'm confused by the formats used for address and length calculations—What does the "%" prefix mean, and what's the significance of the period? It's unlike any format I've seen while reading through the PPU docs, so I want to make sure I'm interpreting it correctly.

Re: Confusing byte format in APU docs

Posted: Sat Apr 22, 2017 11:38 am
by lidnariq
wbrian wrote:What does the "%" prefix mean
Binary number. From what I've seen, it's actually vaguely standard among 6502 assemblers.
and what's the significance of the period?
Byte separator.

Re: Confusing byte format in APU docs

Posted: Sat Apr 22, 2017 11:39 am
by dougeff
Binary. Those are the digits.

You set the address with 1 byte (8 bits). Bit-shift left 6 times, OR with 0xc0 (the upper byte of a 2 byte address) gets a CPU address between 0xc000 and 0xffc0 as the start address of the DMC sample.

(Edited slightly.)

Re: Confusing byte format in APU docs

Posted: Sat Apr 22, 2017 3:12 pm
by Zepper
Let me translate them to you.

Code: Select all

              dmc_address = 0xC000 | (reg4012 << 6);
              dmc_length = (reg4013 << 4) | 1;