mirror of
https://github.com/D-Modem/courier-emu.git
synced 2026-11-28 20:38:07 -08:00
9083 appears nowhere in the image because nothing branches to it. 907f calls 901a, and the two-word "b 9099" that follows is either executed or stepped over: 901a ends in pop / add #02 / bacc, returning past it to 9083, which is where the scheduler yield that eventually opens the answer-tone gates lives. Two conditions must both hold, and both were confirmed by running the call site with the table and flag seeded rather than by reading: highest non-zero word at ff2c or above (index >= 4), AND @1f bit 14 set Either alone falls through to 9099 and the yield never runs. Two cautions are recorded with it. The scan stops at the first non-zero from the top, so the index measures how high the table is filled and not how many entries it holds - populating more words below the top does not move it. And the call site must be entered with DP already 6, as 9077 leaves it; entering at 907f with DP 0 sends "sar ar1, @5b" to the wrong cell and every case falls through to 9099, which is indistinguishable from the gate being closed. The first run of this experiment made exactly that mistake. Still unshown: what fills the table, and what sets bit 14 of @1f. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
295 lines
13 KiB
Markdown
295 lines
13 KiB
Markdown
# The datapump's second voice: a 2100 Hz answer tone
|
|
|
|
DSP 3.1.2's dial path was already producing DTMF through the firmware's own
|
|
oscillator, mixer and serial ISR ([audio-312-path.md](audio-312-path.md)). It
|
|
is not the only generator in the resident bank. The same callback slot drives a
|
|
family of oscillators, and one of them is a modem tone rather than a dialling
|
|
tone: **2100.0 Hz, with a 180 degree phase reversal every 3239 samples**.
|
|
|
|
Both numbers come out of the firmware, not out of a specification consulted
|
|
first, and the ROM's own caller supplies them.
|
|
|
|
## How the generators are selected
|
|
|
|
The mixer at `80d3` calls whatever address sits in data `0x39a`. Scanning the
|
|
resident bank for stores to that cell finds the family:
|
|
|
|
| callback | what it does |
|
|
|---|---|
|
|
| `874f` | one oscillator: increment `0x3f2`, amplitude `0x3f3`, phase `0x3c0` |
|
|
| `8743` | a second oscillator on `0x3f4`/`0x3f5`/`0x3c1`, falling through to `874f` - the DTMF pair |
|
|
| `8739` | decrements a counter, inverts the phase's top bit with `XPL` when it expires, reloads, falls through to `874f` |
|
|
| `8712`, `8716` | `874f` or `8739`, then `8718`, a second oscillator that *multiplies* the tone |
|
|
|
|
The arming routine at `86d1` takes a phase increment in the accumulator, stores
|
|
it at `0x3f2`, installs `874f`, sets the amplitude to `0x0898` and clears the
|
|
phase. Its caller at `9f40` is what makes this a modem tone:
|
|
|
|
```text
|
|
9f40 lacc #4aab
|
|
9f42 call 86d1
|
|
9f44 splk @28, #01d7
|
|
9f46 splk @75, #0ca7 ; the reversal counter's reload
|
|
9f4c splk @1a, #8739 ; the reversing callback
|
|
9f58 splk @73, #06cf ; a quieter amplitude than 86d1's
|
|
```
|
|
|
|
At the dial path's 7200 Hz, `0x4aab / 65536 * 7200` is **2100.04 Hz**, and
|
|
`0x0ca7` is 3239 samples, or **449.9 ms**. Those are the V.25 answer tone and
|
|
its 450 ms phase-reversal period, to within the resolution the numbers have.
|
|
This is a second, independent corroboration of the 7200 Hz figure that
|
|
`audio-312-path.md` inferred from the DTMF increments: no other plausible rate
|
|
puts `0x4aab` on a standard tone and `0x0ca7` on a standard interval at once.
|
|
|
|
`8718` is the same story one level up. It advances a second phase at increment
|
|
`0x0089` - 15.05 Hz at 7200 Hz - and multiplies the carrier by it. That is
|
|
V.8's ANSam amplitude modulation, and it explains why the selector offers four
|
|
callbacks rather than two: reversals or not, modulated or not.
|
|
|
|
## Rendering it
|
|
|
|
`courier_emu.answer_tone` arms the tone with the firmware's own instruction
|
|
words, lifted verbatim from `9f40`, `9f46`, `9f4c` and `9f58`, and then runs the
|
|
same main-loop mixer and serial ISR body that `audio312` runs for DTMF. It
|
|
synthesizes nothing.
|
|
|
|
```sh
|
|
.venv/bin/python -m courier_emu.answer_tone \
|
|
--rom artifacts/courier-board-21210-capture-403/courier-board.rom \
|
|
--output /tmp/answer-tone --variant ans-reversals --seconds 2
|
|
```
|
|
|
|
Saved runs are in `artifacts/answer-tone-01/`. Measured from the rendered PCM:
|
|
|
|
| variant | callback | measured | reversals |
|
|
|---|---|---|---|
|
|
| `ans` | `874f` | 2100.0 Hz | none |
|
|
| `ans-reversals` | `8739` | 2100.0 Hz | every 3200-3264 samples |
|
|
|
|
The reversal spacing is reported to the detector's 64-sample block, which
|
|
brackets the counter's 3239.
|
|
|
|
## One correction to the harness, and it is load-bearing
|
|
|
|
`audio312` enters the frame at `80d3`, the callback call itself. That is fine
|
|
for `874f` and `8743`, and wrong for `8739`, whose `BANZ` tests the register
|
|
the ARP currently points at rather than the `AR1` the instruction before it
|
|
loaded. The mixer sets ARP to 1 at `80c9`; entering below that leaves it
|
|
elsewhere, the counter is never stored back, `XPL` fires on every sample, and
|
|
the output is a constant-magnitude square instead of a tone. This harness
|
|
therefore enters at `80c7`, the top of the mixer's sample body.
|
|
|
|
That failure is worth recording because it is silent: the path runs, the ISR
|
|
transmits 1440 words, and the result is simply the wrong signal.
|
|
|
|
## What this does not show
|
|
|
|
* **Not a boot.** As with `audio312`, frame scheduling, idle RAM and one buffer
|
|
pair are fixtures. The ISR body is entered directly rather than by interrupt.
|
|
* **Not the supervisor's decision to send it.** `9f40` is reached from a state
|
|
machine this harness does not run; what it renders is the generator, armed
|
|
the way that site arms it.
|
|
|
|
*Closed on this image too, 2026-09-08.* The path is traced in
|
|
[the section below](#the-path-to-9f40). *Also closed on the other image.* `ATA` on `IDSDL302.ROM` (DSP 3.0.13)
|
|
emits ANSam in the full emulator, supervisor and all, from its own analogue of
|
|
this site at `0x9f62` - and follows it with a 2250 Hz tone armed at `0xd354`.
|
|
See [ata-answer-tone-302.md](ata-answer-tone-302.md), which also maps 3.0.13's
|
|
oscillator family onto this one: the code addresses differ throughout, but the
|
|
data cells - increment `0x3f2`, amplitude `0x3f3`, phase `0x3c0` - are the
|
|
same in both builds. That does not locate 3.1.2's own path to `9f40`.
|
|
* **ANSam renders too.** *Corrected.* This section used to say the `8712` and
|
|
`8716` variants could not be rendered, and blamed missing delay-line state.
|
|
The real cause was a bug in this repository's C5x core: `MADD` and `MADS`
|
|
read their coefficients from data memory instead of program memory, so the
|
|
shaping filter at `8a88` returned zero. With that fixed - see
|
|
[fsk-modulation.md](fsk-modulation.md) - both variants produce the 15.05 Hz
|
|
amplitude modulation, as a symmetric sideband pair at 2085 and 2115 Hz, each
|
|
about 10% of the carrier.
|
|
* **The `&T` self-test was not the way in.** Driving the supervisor with
|
|
`AT&T1`, `AT&T8` and `ATS18=2&T8` under `courier_emu.mailbox_tap` produces
|
|
`OK` and the same fourteen idle-cycle mailbox messages as a bare `AT`. The
|
|
generator above was found by reading the callback slot's writers instead.
|
|
|
|
*Corrected.* This originally added "the loopback path does not engage in the
|
|
emulator", on the grounds that the runs showed no distinct execution. That
|
|
was read off `hot_addresses`, which lists only the most-executed addresses
|
|
and is therefore dominated by the idle loop either way. Recording every
|
|
address instead - `CourierMachine(code_observer=...)`, added for this -
|
|
shows `AT&T8` reaching **548 addresses a bare `AT` never reaches**, in some
|
|
thirty regions of the supervisor. The handler runs. What has not been shown
|
|
is that it reaches the datapump within the window observed.
|
|
|
|
## The path to `9f40`
|
|
|
|
`9f40` is never branched to. It is reached by falling into it, from a state the
|
|
scheduler dispatches.
|
|
|
|
### The scheduler
|
|
|
|
`875c` is a one-shot state machine driven from the idle path (`9f0d: call
|
|
875c`). Two memory-mapped cells drive it - `0x006e`, a frame countdown, and
|
|
`0x006d`, the address of the state to run when that countdown expires:
|
|
|
|
```text
|
|
875c: lamm @6e ; the countdown
|
|
875d: bcnd 8762, eq
|
|
875f: sub #01
|
|
8760: samm @6e
|
|
8761: retc neq ; still waiting
|
|
8762: lamm @6d ; the state vector
|
|
8763: retc eq ; nothing armed
|
|
8764: bacc ; branch into the state
|
|
8765: samm @6e ; (entry point) arm the countdown
|
|
8766: pop
|
|
8767: samm @6d ; (entry point) arm the state
|
|
```
|
|
|
|
### What arms the answer-tone state
|
|
|
|
Two sites write `9f3e` into that vector, and each is gated on a bit of the
|
|
flags word at data `0x006f`:
|
|
|
|
```text
|
|
afeb lar ar1, #6f reached by conditional call from
|
|
... b0e7, b233, b5a1 and b5ca
|
|
afff bcnd 9e09, tc gate: bit 0 of 0x006f
|
|
9e0a splk @6d, #9f3e @26 = 4000, @27 = 0008
|
|
|
|
a320 countdown at 0x031a called from aaa2 and ab7e
|
|
a327 bit 14, * gate: bit 1 of 0x006f
|
|
a32c call 8140 sets the codec sample rate first
|
|
a32e b 9e13
|
|
9e14 splk @6d, #9f3e @26 = 4010, @27 = 0000
|
|
```
|
|
|
|
Note `bit 14` is a bit *code*, not a bit number: the C5x tests bit `15 - code`
|
|
(the core evaluates `(~op >> 8) & 0xf`), so `bit 14` reads bit 1 and `bit 15`
|
|
reads bit 0. The disassembler prints the raw code.
|
|
|
|
That path B calls `8140` on the way is a small corroboration of
|
|
[codec-rate-312.md](codec-rate-312.md): the sample rate is programmed
|
|
immediately before the tone that assumes it.
|
|
|
|
### Into the tone
|
|
|
|
```text
|
|
9f3a: lacc @2b ; sub #01 ; sacl @2b ; retc gt the timer variant
|
|
9f3e: call a092 falls through
|
|
9f40: lacc #4aab ; call 86d1 the arming
|
|
```
|
|
|
|
`9f3a` is the same state with a countdown in front, entered from `9f12`,
|
|
`9f20`, `9f28` and `9f33`; the stubs at `9f11` and `9f15` that dispatch to them
|
|
are themselves armed at `9e1d` and `9e21`.
|
|
|
|
### Confirmed by running it
|
|
|
|
Rather than a full boot - which this image does not currently reach, for
|
|
reasons unrelated to this path - the last two links were confirmed directly.
|
|
Seeding `0x006d` with `9f3e` and `0x006e` with zero, then entering the
|
|
scheduler at `875c`, executes `9f3e`, `9f40` and `86d1` and leaves:
|
|
|
|
| cell | value | |
|
|
|---|---|---|
|
|
| `0x3f2` | `4aab` | 2100.04 Hz at 7200 |
|
|
| `0x3f3` | `0898` | `86d1`'s own amplitude literal |
|
|
| `0x39a` | `874f` | the oscillator, installed |
|
|
|
|
So the scheduler does reach the arming, and the arming does load the answer
|
|
tone.
|
|
|
|
### What sets the two gate bits
|
|
|
|
Scanning for writes to `0x006f` needs care in both directions. `SPLK @6f` is
|
|
DP-relative, so most apparent writers are `0x036f` or `0x03ef` at DP 6 or 7 and
|
|
have nothing to do with this word; and the reliable ones reach it through
|
|
`lar ar1, #6f` and an indirect `*`, which a search for `@6f` never sees at all.
|
|
Only writes with an `LDP #000` immediately before them, or an explicit AR load,
|
|
can be attributed here.
|
|
|
|
Three sites survive that filter, and each was confirmed by executing it:
|
|
|
|
| site | instruction | effect on `0x006f` |
|
|
|---|---|---|
|
|
| `9090` | `lar ar1, #6f` / `opl *, #0003` | **sets both**, preserving the rest |
|
|
| `a372` | `ldp #000` / `splk @6f, #0043` | **sets both**, and bit 6, as a whole word |
|
|
| `a337` | `ldp #000` / `splk @6f, #0040` | **clears both** |
|
|
|
|
`9090` is itself a scheduler resume. Two instructions earlier the code yields -
|
|
|
|
```text
|
|
908c: lacc #0508
|
|
908e: call 8765 ; @6e := 0x508, @6d := the return address
|
|
9090: lar ar1, #6f ; ...resumed 1288 frames later
|
|
9091: opl *, #0003
|
|
```
|
|
|
|
so the gates open on a timer, not on an event. `a372` is reached from `9f98`,
|
|
inside the answer sequence itself, so that write re-asserts the bits rather
|
|
than opening them the first time.
|
|
|
|
Note that `9091` only works because `ARP` is 1 when it runs: `lar ar1, #6f`
|
|
loads the register but does not select it, and with `ARP` left at 0 the `opl`
|
|
lands on `0x0000` instead. Executing the pair with `ARP` forced to 1 turns
|
|
`4400` into `4403`; with `ARP` at 0 the cell does not change.
|
|
|
|
Several sites clear both gates by writing the word wholesale - `a338` (`#0040`)
|
|
above, and at DP 0 also `d9cc` (`#0000`), `da31` and `da46` (`#0010`).
|
|
|
|
**Unresolved.** `c583` (`xpl @6f, #0001`) and `c58f` (`xpl @6f, #0002`) toggle
|
|
bits 0 and 1 of *something*, in a toggle-and-test shape that usually means an
|
|
alternating-sample flag. Their nearest `LDP` is 20 and 32 words back with a
|
|
`ret` in between, so the DP is inherited from whoever calls that routine and
|
|
these cannot be attributed to `0x006f` by reading alone. The surrounding
|
|
`MACD`/`MPY`/`APAC` argues they belong to a filter and not to this word, but
|
|
that is an impression, not a measurement.
|
|
|
|
### What decides to run the yield
|
|
|
|
`9083` appears nowhere in the image, because it is not branched to: it is
|
|
reached by a **skip-return**. `907f` calls `901a`, and the two-word `b 9099` at
|
|
`9081` is either executed or stepped over depending on how that call returns.
|
|
|
|
```text
|
|
901a: lar ar1, #ff2d
|
|
901c: lacl *- ; scan down for the first non-zero word
|
|
901d: bcnd 901c, eq
|
|
901f: sar ar1, @5b ; where the scan stopped
|
|
9021: sub #ff27 ; as an index
|
|
9024: sub #04
|
|
9025: retc lt ; index < 4 -> ordinary return, and 9081 runs
|
|
902a: bit 1, @1f ; bit 14
|
|
902b: retc ntc ; clear -> ordinary return
|
|
902c: call 90c3
|
|
902e: pop
|
|
902f: add #02 ; return address + 2: step over the branch
|
|
9030: bacc ; -> 9083, the yield
|
|
```
|
|
|
|
Both conditions were checked by running the call site with the table and the
|
|
flag seeded, and reading where control lands:
|
|
|
|
| highest non-zero word | index | `@1f` bit 14 | lands on |
|
|
|---|---|---|---|
|
|
| `ff2b` or below | 0-3 | set | `9099` (normal) |
|
|
| `ff2c` | 4 | set | **`9083`** (yield) |
|
|
| `ff2d` | 5 | set | **`9083`** (yield) |
|
|
| `ff2d` | 5 | clear | `9099` (normal) |
|
|
|
|
So the yield - and 1288 frames later the two gate bits, and after that the
|
|
answer tone - runs only when the table ending at `0xff2d` is filled to within
|
|
two words of its top **and** bit 14 of `@1f` is set. Either condition alone is
|
|
not enough.
|
|
|
|
Two cautions for anyone re-running this. The scan stops at the *first* non-zero
|
|
from the top, so the index measures how high the table is filled, not how many
|
|
entries it holds; populating more words below the top does not change it. And
|
|
the call site must be entered with `DP` already 6, as `9077` leaves it -
|
|
entering at `907f` with `DP` at 0 sends `sar ar1, @5b` to the wrong cell and
|
|
every case falls through to `9099`, which looks exactly like the gate being
|
|
closed.
|
|
|
|
What is still not shown is what fills that table, or what sets bit 14 of `@1f`.
|
|
|