parallel: drive the Centronics status lines from the attached peripheral#215
Merged
Conversation
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.
Contributor
There was a problem hiding this comment.
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 defineCTL_BUSY/CTL_POUT/CTL_SELstatus 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:(orPRT:) 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
ParallelPortgainscontrol_lines() -> Option<u8>(bitsCTL_BUSY/CTL_POUT/CTL_SEL): the pin levels the peripheral holds the three lines at. The defaultNonemodels 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.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-0xFFramp toPAR:and a text file toPRT:against--parallel printer: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 anAssign 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).