Skip to main content

Crate rustynes_apu

Crate rustynes_apu 

Source
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.
FilterChain
3-stage filter chain. The stages are model-dependent (see FilterModel); the default FilterModel::NesRf is HPF 90 Hz → HPF 440 Hz → LPF 14 kHz.
FrameCounter
Frame counter state.
FrameEvents
Output of one APU tick describing what events the frame counter fired.
LengthCounter
Length counter shared by pulse, triangle, noise channels.
Mixer
Pre-computed mixer state.
Noise
Noise channel state.
OnePole
Single-pole IIR filter. lpf flag controls whether it’s a low-pass or high-pass.
Opll
OPLL (YM2413 / VRC7) FM synthesizer instance.
OpllPatch
One OPLL patch — the 13-field instrument definition.
Pulse
Pulse channel state.
Triangle
Triangle channel state.

Enums§

ApuSnapshotError
Errors returned by Apu::restore.
FilterModel
v2.1.3 — the analog output-filter model the APU emulates.
FrameCounterMode
Frame counter mode.
OpllChipType
Chip type — selects the patch ROM table.
OpllStateError
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_gain entries at 1.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_mask bits 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::snapshot emits.
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.