mirror of
https://github.com/D-Modem/courier-emu.git
synced 2026-11-28 20:38:07 -08:00
Measurement said turn-taking, not lock-step: the only targeted write the controller makes into a selected channel is a slot identity at offset 0xbae1, which the card reads at 0xf64ec and reports back as parameter 0x00f3. That is a request/response exchange over shared channel memory, not two processors needing to run at the same instant. QuadChassis runs one side, moves the channel memory, runs the other, and moves it back. The controller reaches that memory through the aperture QuadBoard maps at 0x40000; the modem sees the same bytes at 0x00000. Resuming needed a small addition to CourierMachine rather than a refactor. run() builds a fresh Uc every call, but `begin` is already reassigned from current_pc() inside its loop, so only the entry point and the processor state had to be carried: snapshot() takes the general, segment and flags registers plus the instruction count, and resume_from() writes them into the next Uc and continues from the saved PC. Interrupt delivery and the modem's STI/HLT scheduler therefore keep working across a turn, which driving emu_start directly would have broken. Verified: both sides resume where they stopped - controller 8,000,003 then 8,500,008 instructions, modem 1,000,012 then 1,500,016 - and the controller's stamp is visible in the shared channel, 0xbae1 = 0x11. Not yet demonstrated: the 0x00f3 round trip. The modem's boot clears 0xbae1, so with the controller stamping before the modem boots the card has nothing to report. Ordering the turns so the stamp lands after the card is up is the next step, and it is what this harness exists to make possible. Arbitration is not modelled. Nothing here decides who may touch the channel when; the schedule is the caller's. On the board both parts address that memory freely and the chip selects at 0xff88/0xff94 resolve it, so this cannot be used to argue about races. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
35 lines
1.5 KiB
Python
35 lines
1.5 KiB
Python
"""Run the Quad controller and one modem channel by taking turns.
|
|
|
|
Checks that each side resumes where it stopped, and reports the slot identity
|
|
byte at channel offset 0xbae1 - the one targeted write the controller makes
|
|
into a selected channel, which the card reads at 0xf64ec and reports back as
|
|
parameter 0x00f3.
|
|
"""
|
|
import json
|
|
from pathlib import Path
|
|
|
|
from courier_emu.quad_chassis import QuadChassis
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
OUT = ROOT / 'artifacts/quad-chassis-20260910'
|
|
|
|
if __name__ == '__main__':
|
|
OUT.mkdir(parents=True, exist_ok=True)
|
|
chassis = QuadChassis(archive=ROOT / 'docs/x2/Qf060003.zip',
|
|
controller_slice=8_000_000, modem_slice=1_000_000)
|
|
report = {'controller_turn_1': chassis.run_controller(),
|
|
'slot_after_controller': hex(chassis.channel_byte(0xBAE1))}
|
|
report['modem_turn_1'] = chassis.run_modem(quad_terminal=True, tick_ms=5)
|
|
report['slot_after_modem'] = hex(chassis.channel_byte(0xBAE1))
|
|
first = dict(chassis.status())
|
|
chassis.controller_slice = chassis.modem_slice = 500_000
|
|
report['turn_2'] = chassis.turn(quad_terminal=True, tick_ms=5)
|
|
report['resumed'] = {
|
|
'controller': [first['controller_instructions'],
|
|
chassis.controller_instructions],
|
|
'modem': [first['modem_instructions'], chassis.modem_instructions],
|
|
}
|
|
report['status'] = chassis.status()
|
|
(OUT / 'results.json').write_text(json.dumps(report, indent=1) + '\n')
|
|
print(json.dumps(report, indent=1))
|