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
+105Lines changed: 105 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,110 @@ 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
+
The following example demonstrates a simple bidirectional chat interface implemented using the `-via2-socket` option.
459
+
460
+
### Sample server (Python)
461
+
462
+
Save as `via2.py`:
463
+
464
+
```python
465
+
#!/usr/bin/env python3
466
+
import os
467
+
import socket
468
+
import subprocess
469
+
import sys
470
+
471
+
SOCKET_PATH="/tmp/via2.sock"
472
+
CHT_EOL=b'\x00'
473
+
474
+
# Remove old socket if present
475
+
try:
476
+
os.unlink(SOCKET_PATH)
477
+
exceptFileNotFoundError:
478
+
pass
479
+
480
+
# Create UNIX domain socket
481
+
server = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
0 commit comments