Skip to content

NesFrameCounter ​

Struct

Source: AudioTypes.h

Description ​

NES APU frame counter (sequencer) state.

Counts APU cycles (CPU/2) and dispatches quarter/half clocks at the step boundaries defined by nes_apu::kMode0ApuCyclesPerStep (4-step, mode 0) and nes_apu::kMode1ApuCyclesPerStep (5-step, mode 1).

Default state: enabled=false (counter OFF), mode=0, all clocks disabled. Consumers opt in with ApuCore::setNesFrameCounterMode(0 or 1). Hito 2 M3.

Properties ​

NameTypeDescription
modeint0 = 4-step (mode 0), 1 = 5-step (mode 1). Default is 0.
enabledboolWhen false, the frame counter does not advance and dispatches no clocks. Set to true by ApuCore::setNesFrameCounterMode and reset to false by ApuCore::reset (or unit-test reset). Default OFF keeps the canonical track PCM byte-for-byte identical.
currentStepintCurrent step within the cycle (0 = wrap point, 1..maxStep = active).
apuCyclesdoubleContinuous APU-cycle accumulator. Doubled per render sample.
irqFlagboolFrame interrupt flag. Set on mode-0 cycle wrap (if not inhibited).
irqInhibitbool$4017 bit 6 (inhibit). When true, the IRQ flag is cleared and not set.
resetPendingboolReset pending: when true, the next "step entry" zeroes the cycle accumulator and fires quarter+half (mirrors $4017 M=1 side effect).

Released under the MIT License.