Skip to content

parallel: drive the Centronics status lines from the attached peripheral#215

Merged
LinuxJedi merged 1 commit into
mainfrom
feature/parallel-control-lines
Jul 18, 2026
Merged

parallel: drive the Centronics status lines from the attached peripheral#215
LinuxJedi merged 1 commit into
mainfrom
feature/parallel-control-lines

Conversation

@LinuxJedi

Copy link
Copy Markdown
Owner

Follow-up to #138. The parallel-port rework there put the data, strobe, and /ACK on the right CIA, but printing still could not work end-to-end: nothing modelled the Centronics status lines, so the guest's parallel.device never sent a byte.

Problem

CIA-B port A pins 0-2 are the parallel port's BUSY, POUT, and SEL status inputs, pulled up when undriven. With no peripheral model for them, a guest read of CIA-B PRA returned $FF -- printer busy and out of paper -- and parallel.device's default write path polls BUSY before each transfer. Copy file TO PAR: (or PRT:) therefore hung forever with an empty capture file: a CIA access trace shows thousands of CIA-B PRA polls reading $FF and zero CIA-A PRB/DDRB accesses. (This is authentic no-printer-connected behaviour, and it predates #138 -- the earlier wiring could not print either.)

Fix

  • ParallelPort gains control_lines() -> Option<u8> (bits CTL_BUSY/CTL_POUT/CTL_SEL): the pin levels the peripheral holds the three lines at. The default None models the unplugged cable, keeping the authentic wait-forever behaviour of an empty port. The sampler is untouched.
  • FileParallelPort (the printer capture) drives SEL high with BUSY and POUT low: a ready online printer.
  • The bus applies the driven levels to CIA-B PRA reads on input pins only; pins the guest has switched to outputs via DDRA stay CIA-driven.

No state-shape change (the port stays serde-skipped host IO), so no STATE_VERSION bump.

Verification

Headless Workbench 3.2 boot (A4000/IDE, KS 3.2 ROM) with a startup-sequence that copies a 4 KiB 0x00-0xFF ramp to PAR: and a text file to PRT: against --parallel printer:

  • Before: both copies hang, capture empty.
  • After: both complete; the capture holds the ramp byte-exact (all eight data lines land, correct order) followed by the PRT: text via printer.device + the Generic driver (with its LF -> LF+CR translation), the transfer paced by the PC-strobe -> /ACK -> CIA-A FLAG handshake.

Guest-side note for anyone reproducing: the 3.2 Port-Handler lives on extras3.2.adf (L/Port-Handler), and with no printer.prefs, printer.device wants an Assign PRINTERS: SYS:Devs/Printers.

Unit tests cover the null port (all lines float high), the printer's ready levels, and DDRA-output pins winning over the peripheral. Full suite 1610 passed / 0 failed; clippy and fmt clean. Docs updated (README parallel section, configuration guide).

CIA-B port A pins 0-2 are the parallel port's BUSY, POUT, and SEL status
inputs, pulled up when nothing drives them. With no model for them a guest
read of CIA-B PRA returned $FF - printer busy, out of paper - so
parallel.device's default write path polled BUSY forever and never sent a
byte: printing to PAR: or PRT: hung with an empty capture, on the sampler
rework and on the earlier wiring alike.

Give ParallelPort a control_lines() hook returning the pin levels the
peripheral holds the three lines at (default None = an unplugged cable,
which keeps the authentic wait-forever behaviour of an empty port). The
printer capture drives SEL high with BUSY and POUT low, a ready online
printer. The bus applies the driven levels to CIA-B PRA reads on input
pins only; pins the guest has switched to outputs stay CIA-driven.

Verified end-to-end on Workbench 3.2 (A4000/IDE): a 4 KiB 0x00-0xFF ramp
copied to PAR: lands byte-exact in the capture, and PRT: output through
printer.device and the Generic driver follows, paced by the PC-strobe
/ACK handshake into CIA-A FLAG.
Copilot AI review requested due to automatic review settings July 18, 2026 05:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR completes the parallel-port printer path by modelling the Centronics status inputs (BUSY/POUT/SEL) on CIA-B port A pins 0–2, allowing AmigaOS parallel.device to observe a “ready/online” printer and actually transmit data to an attached parallel peripheral (e.g., the file-capture printer).

Changes:

  • Extend the parallel peripheral interface with control_lines() -> Option<u8> and define CTL_BUSY/CTL_POUT/CTL_SEL status bits.
  • Drive ready/online status levels from FileParallelPort, and apply peripheral-driven status levels to CIA-B PRA reads while respecting DDRA output pins.
  • Add unit tests for null-vs-printer status behavior and update user docs (README + configuration guide).

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/parallel.rs Adds Centronics status-line API and constants; implements ready/online levels for the file-capture printer; adds unit tests.
src/chipset/cia.rs Exposes CIA port-A DDR so the bus can distinguish peripheral-driven inputs from CIA-driven outputs.
src/bus.rs Merges peripheral status levels into CIA-B PRA reads on PA0–PA2, masked to input pins only.
src/bus/tests.rs Adds coverage for CIA-B PRA status behavior with/without an attached printer and with DDRA overriding peripheral input.
README.md Documents that BUSY/POUT/SEL status lines are modelled and float high when unplugged.
docs/guide/configuration.md Documents printer status-line driving behavior and its impact on parallel.device sending bytes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/bus/tests.rs
@LinuxJedi
LinuxJedi merged commit 4f94c91 into main Jul 18, 2026
9 checks passed
@LinuxJedi
LinuxJedi deleted the feature/parallel-control-lines branch July 18, 2026 05:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants