Expand description
Cycle-accurate Ricoh 2A03 APU implementation.
See docs/apu-2a03.md for the implementation spec and
ref-docs/research-report.md §APU for the source material.
Five-channel APU (pulse 1, pulse 2, triangle, noise, DMC) with the
lookup-table non-linear mixer, analog highpass / lowpass filter chain,
frame counter (4-step + 5-step modes with the documented IRQ flag),
band-limited synthesis at host sample rate, and DMC sample DMA. The
bus-side DMC DMA scheduling lives in rustynes-core::LockstepBus.
Modules§
- provenance
- Audio provenance (v2.3.7 “Overtone”) — why does this moment sound like that?
Structs§
- Apu
- Top-level APU.
- BlipBuf
- Streaming BLEP decimator + filter chain that feeds host-rate samples to the frontend’s audio thread.
- Dmc
- DMC channel state.
- Envelope
- Envelope generator.
- Filter
Chain - 3-stage filter chain. The stages are model-dependent (see
FilterModel); the defaultFilterModel::NesRfis HPF 90 Hz → HPF 440 Hz → LPF 14 kHz. - Frame
Counter - Frame counter state.
- Frame
Events - Output of one APU
tickdescribing what events the frame counter fired. - Length
Counter - Length counter shared by pulse, triangle, noise channels.
- Mixer
- Pre-computed mixer state.
- Noise
- Noise channel state.
- OnePole
- Single-pole IIR filter.
lpfflag controls whether it’s a low-pass or high-pass. - Opll
- OPLL (YM2413 / VRC7) FM synthesizer instance.
- Opll
Patch - One OPLL patch — the 13-field instrument definition.
- Pulse
- Pulse channel state.
- Triangle
- Triangle channel state.
Enums§
- ApuSnapshot
Error - Errors returned by
Apu::restore. - Filter
Model - v2.1.3 — the analog output-filter model the APU emulates.
- Frame
Counter Mode - Frame counter mode.
- Opll
Chip Type - Chip type — selects the patch ROM table.
- Opll
State Error - Errors returned by
Opll::restore. - Region
- NES region — picks clock dividers and per-region tables.
Constants§
- APU_
SNAPSHOT_ VERSION - Schema version for the APU snapshot blob.
- CHANNEL_
GAIN_ UNITY - All
Apu::channel_gainentries at1.0— every channel at full, unattenuated output (the default and the byte-identical value the oracle / test ROMs always run with). - CHANNEL_
MASK_ ALL - All
Apu::channel_maskbits set — every channel audible (the default and the determinism-safe value the oracle / test ROMs always run with). - CPU_
HZ_ NTSC - CPU cycles per second, NTSC.
- CPU_
HZ_ PAL - CPU cycles per second, PAL (slightly slower).
- LENGTH_
TABLE - 32-entry length lookup table (from the NESdev wiki).
- NTSC_
NOISE_ PERIODS - 16-entry NTSC noise period table (NESdev wiki). Index = bits 0-3 of
$400E. - OPLL_
SNAPSHOT_ LEN - Total serialized size of an OPLL snapshot, in bytes.
- OPLL_
SNAPSHOT_ VERSION - Schema version of the blob
Opll::snapshotemits. - PAL_
NOISE_ PERIODS - 16-entry PAL noise period table (NESdev wiki).
Statics§
- REENABLE_
BUMP - v2.0 Phase 2 (
mc-r1-dmc-reenable-phase): swept byte-timer realignment. - SUBPOS_
DELAY - v2.0 final lever #1 (
mc-r1-dmc-halt-subpos): swept per-CPU-cycle arm DELAY.
Traits§
- ApuBus
- Bus surface seen by the APU. A small subset of the full CPU bus for the DMC’s sample-fetch DMA.
Functions§
- version
- Returns the crate version string.