pub const WAVE_RAM: VolBlock<u8, Unsafe, Unsafe, 16>;Expand description
Storage for one of the sound channel’s waveform
Wave RAM is 16 bytes long; each byte holds two “samples”, each 4 bits.
As CH3 plays, it reads wave RAM left to right, upper nibble first. That is, $FF30’s upper
nibble, $FF30’s lower nibble, $FF31’s upper nibble, and so on.
§Warning
When CH3 is started, the first sample read is the one at index 1, i.e. the lower nibble of the first byte, NOT the upper nibble.
§Safety
Accessing wave RAM while CH3 is active (i.e. playing) causes accesses to misbehave:
- On AGB, reads return
$FF, and writes are ignored. - On monochrome consoles, wave RAM can only be accessed on the same cycle that CH3 does.
Otherwise, reads return
$FF, and writes are ignored. - On other consoles, the byte accessed will be the on CH3 is currently reading; that is, if Ch3
is currently reading one of the first two samples, the CPU will really access
$FF30, regardless of the address being used.
Wave RAM can be accessed normally even if the DAC is on, as long as the channel is not active. This is especially relevant on GBA whose mixer behaves as if DACs are always enabled.
The way it works is that wave RAM is a 16-byte memory buffer, and whie it’s playing, CH3 has priority over the CPU when choosing which of those 16 bytes is accessed. So, from the CPU’s point of view, wave RAM reads out the same byte, reagardless of the address.