Skip to content

Expose a parallel port - #1613

Merged
copy merged 5 commits into
copy:masterfrom
parkertomatoes:master
Aug 9, 2026
Merged

Expose a parallel port#1613
copy merged 5 commits into
copy:masterfrom
parkertomatoes:master

Conversation

@parkertomatoes

Copy link
Copy Markdown
Contributor

This adds a "device" that only emits bus events for the LPT1 registers. The goal is to make it possible to add a virtual printer from outside the emulator.

Parallel port logic is timing based, but this hacks around it by latching falling ACK events until the guest reads the status register. For both bochs and seabios that's enough to keep int 17h synchronized while the bus blasts status and control register updates at whatever speed.

I would have also included a printer, but the best library for parsing printer protocols, GhostPDL, has a copyleft license that isn't compatible with v86. So I made a separate GhostPDL-based PCL5 printer that can be wired to this interface but has an AGPL3 license:
https://github.com/parkertomatoes/inkjet-emu

And some demos with DOS and Windows 3.x printing with v86 and inkjet-emu:
https://inkjet-emu-demo.swannerfly42.workers.dev/

Comment thread src/parallel.js Outdated
Comment on lines +183 to +185
// For Types Only
import { CPU } from "./cpu.js";
import { BusConnector } from "./bus.js";

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.

nit-pick: move this to the top of file

@SuperMaxusa

Copy link
Copy Markdown
Contributor

It would be good if you could create multiple LPT ports like in UART:

v86/src/cpu.js

Lines 1184 to 1195 in 2f1346b

if(settings.uart1)
{
this.devices.uart1 = new UART(this, 0x2F8, device_bus);
}
if(settings.uart2)
{
this.devices.uart2 = new UART(this, 0x3E8, device_bus);
}
if(settings.uart3)
{
this.devices.uart3 = new UART(this, 0x2E8, device_bus);
}

@parkertomatoes

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Added LPT2, but I don't think seabios or boch's support LPT3/LPT4.

Comment thread tests/devices/parallel.js Outdated
@@ -0,0 +1,150 @@
#!/usr/bin/env node

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

To be honest, I don't find this test very useful: It tests mostly internal implementation details, not whether this presents a working parallel port to the guest OS.

A more useful test would be to boot Linux or DOS, run some commands that interact with the parallel port and test that the corresponding events get called.

@parkertomatoes parkertomatoes Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I see what you mean. test/api/floppy.js seems to do what you're asking so I tweaked it a bit to make a higher-level parallel port test.

@copy
copy merged commit f3d4472 into copy:master Aug 9, 2026
3 checks passed
@copy

copy commented Aug 9, 2026

Copy link
Copy Markdown
Owner

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants