You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add VIA2 socket support for external I/O integration
Adds optional -via2-socket support to allow external processes to
communicate with the emulator via a UNIX domain socket.
Includes documentation and example usage.
Copy file name to clipboardExpand all lines: README.md
+108Lines changed: 108 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -128,6 +128,7 @@ When starting `x16emu` without arguments, it will pick up the system ROM (`rom.b
128
128
*`-sound <device>` can be used to specify the output sound device. If 'none', no audio is generated.
129
129
*`-abufs` can be used to specify the number of audio buffers (defaults to 8 when using the SD card, 32 when using HostFS). If you're experiencing stuttering in the audio, try increasing this number. This will result in additional audio latency though.
130
130
*`-via2` installs the second VIA chip expansion at $9F10.
131
+
*`-via2-socket <socket>` Use a socket to emulate VIA2 I/O. Currently only UNIX / POSIX are supported. The emulator opens this socket as a client, so it must be set up in advance. The -via2 option must be specified along with this option. See [Using -via2-socket](#via2-socket) for sample server and client code.
131
132
*`-midline-effects` enables mid-scanline raster effects at the cost of vastly increased host CPU usage.
132
133
*`-mhz <integer>` sets the emulated CPU's speed. Range is from 1-40. This option is mainly for testing and benchmarking.
133
134
*`-enable-ym2151-irq` connects the YM2151's IRQ pin to the system's IRQ line with a modest increase in host CPU usage.
@@ -450,6 +451,113 @@ When `-debug` is selected the STP instruction (opcode $DB) will break into the d
450
451
451
452
Keyboard routines only work when the emulator is running normally. Single stepping through keyboard code will not work at present.
452
453
454
+
<aname="via2-socket"></a>
455
+
Using -via2-socket
456
+
------------------
457
+
458
+
Reads from and writes to `$9F10` and `$9F11` (VIA ports A and B) are forwarded to the socket.
459
+
460
+
There are no restrictions on the protocol except that a value of `255` is reserved for "no data yet" when reading.
461
+
462
+
The following example demonstrates a simple bidirectional chat interface implemented using the `-via2-socket` option.
463
+
464
+
### Sample server (Python)
465
+
466
+
Save as `via2.py`:
467
+
468
+
```python
469
+
#!/usr/bin/env python3
470
+
import os
471
+
import socket
472
+
import subprocess
473
+
import sys
474
+
475
+
SOCKET_PATH="/tmp/via2.sock"
476
+
CHT_EOL=b'\x00'
477
+
478
+
# Remove old socket if present
479
+
try:
480
+
os.unlink(SOCKET_PATH)
481
+
exceptFileNotFoundError:
482
+
pass
483
+
484
+
# Create UNIX domain socket
485
+
server = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
0 commit comments