I share the same confusion tepples does. There's no manipulation here other than writing values (writing = STA, STX or STYing).
The bits in the value you write set (or clear) the specific bits of those registers. The bits of those registers control what the system is doing -- so in effect, the value you write determines the behavior of the hardware.
blargg's APU doc wrote:
$4000/4 ddle nnnn duty, loop env/disable length, env disable, vol/env
The high two bits of the value you write to $4000 set the duty.
Bit 5, when set, will disable the length counter and set the envelope unit to looop. When clear, it will enable length, and the envelope won't loop.
Bit 4 disables (when set) or enables (when clear) the envelope generator
and the low 4 bits set the fixed volume and envelope speed.
So if you want:
- 50% duty (%10xxxxxx)
- disabled length (%xx1xxxxx)
- disabled envelope (%xxx1xxxx)
- a volume level of 8 (%xxxx1000)
then you write %10111000 to $4000:
Laserbeak43 wrote:quick question, the number value loaded into the register determines what feature will be used?
Yes. Whatever value you set the register to determines what the hardware does.
so if #$01 loads a black hole
and #$03 loads my ninja turtles dvd
load my ninja turtle DVDs while running a black hole?
This example doesn't make any sense. #$01 doesn't "load" anything, it's just a number. When you write that number to a register, the effect it has depends on what the register does.
$4014 is kind of tricky, because it's not really an actual register -- it's more like a CPU macro. I don't understand your whole ninja turtle/black hole metaphore but basically $4014 works like this:
writing to $4014 starts a DMA transfer. Bytes are read from $nn00 (where 'nn' is the value written to $4014) and written to $2004 (which puts that byte in OAM). So for example, if do:
that is basically the same thing as:
Code: Select all
Only much faster because the CPU doesn't have to fetch opcode and address bytes repeatedly. Plus it's much smaller code.
Writing to $4014 copies a 256 byte page to OAM. So if you write $03 to $4014, then the page at $0300-03FF gets copied in full to OAM.