# SPDX-License-Identifier: MIT """The fixed alignment between the core and the closed box, per path. Each constant was measured once through the closed box's pins (OBSERVED, atari_pokey @ 88a8e00) and is recorded with its measurement in docs/validation.md, "Closed-box differences". It is never fitted per stream. """ #: Rows: a box audio-pin change for a channel's fire appears this many rows #: after the core's fire tick (pure-tone channel, so the output toggles). #: Measured: an AUDCTL switch of channel 1 from 64 kHz to 1.79 MHz gives box #: toggles at fire + 3 (scratch experiment e11, 2026-11-14), and 3 is the #: offset of every slow-clock channel in the rung 2 pilot streams. RUNG2_FIRE_OFFSET = 3 #: Cycles by which a STIMER write is delayed on its way to the box. The box #: reloads on STIMER one cycle earlier than the hardware numbers (U1 row 1: #: IRQST at T+7+N instead of T+8+N; AUDF deadline T+1 instead of T+2), and the #: core follows the hardware, so the box gets each STIMER one cycle later. BOX_STIMER_DELAY = 1 #: Rows: the box's audio pin shows the core's levels() of this many ticks #: earlier (rung 3). Measured: AUDC writes reach the box's pin 2 rows after #: the write; fires 3 rows after the core's fire tick, i.e. 2 after the #: output flip-flop's tick (B3.1). RUNG3_LEVEL_OFFSET = 2 #: Rows: the box's /IRQ pin shows the core's ``irq`` of this many ticks earlier #: (rung 4): the box prints a pin's level during row t, the core's ``irq`` is #: after tick t. Measured by sweeping an IRQEN enable across a timer 1 fire #: (scratch irq_sweep, 2026-11-14): the box's IRQST bit and its pin change in #: the same row. IRQST reads need no offset. RUNG4_IRQ_OFFSET = 1 #: Ticks by which the box's first 15 kHz / 64 kHz pulse after init mode comes #: later than the core's (U1 rows 2-3: the box's IRQST at +84/+26; the core's #: +84/+25 after B2.1b, from Acid800 pokey_inittiming.s; before rung 4 the #: core followed the manual's +83/+24 and these were 1 and 2). BOX_CLOCK_LAG_15 = 0 BOX_CLOCK_LAG_64 = 1