Skip to content

IPC Socket support

Dimitris Panokostas edited this page Nov 19, 2026 · 12 revisions

IPC Socket Support

Amiberry supports cross-platform Inter-Process Communication (IPC) via Unix domain sockets on Linux, macOS, and FreeBSD, and via a named pipe on Windows in builds after 8.4.1 (BlitterStudio/amiberry#2466). This allows external applications to control a running Amiberry instance.

Note: For Linux-only D-Bus support, see D-Bus Support.

Enabling Support

IPC Socket support is enabled at build time with the USE_IPC_SOCKET CMake option, which is on by default:

cmake -DUSE_IPC_SOCKET=ON ..

It is available on Linux, macOS, FreeBSD, and Windows. Android and iOS builds turn it off.

Socket Path and Pipe Name

The endpoint is created at:

  • Linux: $XDG_RUNTIME_DIR/amiberry.sock (falls back to /tmp/amiberry.sock)
  • macOS/FreeBSD: /tmp/amiberry.sock
  • Windows: the named pipe \\.\pipe\amiberry

Multiple Instances

If you run multiple Amiberry instances, each will use a different endpoint:

  • First instance: amiberry.sock / \\.\pipe\amiberry
  • Second instance: amiberry_1.sock / \\.\pipe\amiberry_1
  • Third instance: amiberry_2.sock / \\.\pipe\amiberry_2
  • ...and so on, with suffixes _1 through _9 (up to 10 instances)

Stale Socket Cleanup

If Amiberry crashes or is killed without proper cleanup, a stale socket file may remain. On the next startup, Amiberry automatically detects and removes stale sockets by checking if any process is actually listening. On Windows this does not apply: a named pipe disappears with the process that created it, so the next instance simply takes the first free pipe name.

Windows Named Pipe

On Windows the transport is a byte-mode named pipe that uses the same line protocol as the Unix socket. Open it like a file, for example with CreateFile in C or System.IO.Pipes.NamedPipeClientStream in .NET. Keep the following in mind:

  • The pipe can only be opened from the local machine, and only by the user account Amiberry runs as.
  • Amiberry keeps one pipe instance waiting for a client and creates the next one within a frame of each connection. A client that gets ERROR_PIPE_BUSY (231) should retry for a short time. Python's builtin open() reports that error as EINVAL; tools/ipc_client.py calls _winapi.CreateFile so it can see the real error code.
  • A pipe cannot be half-closed: read the replies before closing the handle.
  • os.path.exists() and os.stat() on a pipe name open a client connection, so never use them to check whether Amiberry is running. To find instances, enumerate os.listdir('\\\\.\\pipe\\') and match amiberry and amiberry_<n>.

Protocol

The IPC protocol is text-based and simple:

Request format:

COMMAND\tARG1\tARG2\n

Response format:

OK\tRESULT1\tRESULT2\n
ERROR\tMESSAGE\n

Commands and arguments are separated by tabs (\t), and each message ends with a newline (\n). Up to 16 controllers can be connected at once, and a client whose request line grows past 64 KiB without a newline is disconnected. These limits are the same on the Unix socket and the Windows pipe.

Supported Commands

Emulation Control

Command Arguments Description
QUIT - Exit Amiberry
PAUSE - Pause emulation
RESUME - Resume emulation
RESET [HARD|SOFT] Reset emulation (default: SOFT)
FRAME_ADVANCE [count] Advance N frames when paused (default: 1)

Floppy Disk

Command Arguments Description
INSERTFLOPPY <path> <drive> Insert floppy (drive: 0-3)
EJECT_FLOPPY <drive> Eject floppy from drive (0-3)
LIST_FLOPPIES - List all floppy drives and contents
DISKSWAP <disk_num> <drive_num> Swap disk from swapper list
QUERYDISKSWAP <drive_num> Query disk in drive
SET_FLOPPY_SPEED <speed> Set speed (0=turbo, 100=1x, 200=2x, 400=4x, 800=8x)
GET_FLOPPY_SPEED - Get current floppy speed
DISK_WRITE_PROTECT <drive> <0|1> Set write protection on inserted disk
GET_DISK_WRITE_PROTECT <drive> Get write protection status

CD-ROM

Command Arguments Description
INSERTCD <path> Insert CD image
EJECT_CD - Eject CD

Hard Drives

Command Arguments Description
LIST_HARDDRIVES - List all mounted hard drives/directories

State Management

Command Arguments Description
SAVESTATE <state_file> <config_file> Save state and config (paths limited to MAX_DPATH characters)
LOADSTATE <state_file> Load a savestate (path limited to MAX_DPATH characters)
SCREENSHOT <filename> [ACTIONABLE] Take a screenshot (path limited to MAX_DPATH; ACTIONABLE returns geometry metadata)
QUICKSAVE [slot] Quick save to slot (0-9, default: 0)
QUICKLOAD [slot] Quick load from slot (0-9, default: 0)

Note: SAVESTATE and QUICKSAVE are refused while the CPU is stopped by the debugger (native debugger or GDB remote). Save state while emulation is running or after pausing with PAUSE.

File paths in SAVESTATE, LOADSTATE, SCREENSHOT, INSERTFLOPPY, INSERTCD, LOAD_CONFIG, and INSERT_WHDLOAD must be shorter than the system path limit (PATH_MAX: 4096 bytes on Linux, 1024 on macOS and FreeBSD). Longer paths are refused with the error Path exceeds maximum length.

Audio

Command Arguments Description
SET_VOLUME <0-100> Set master volume
GET_VOLUME - Get current volume
MUTE - Mute audio
UNMUTE - Unmute audio

Display

Command Arguments Description
TOGGLE_FULLSCREEN - Toggle fullscreen/windowed mode
SET_WARP <0|1> Enable/disable warp mode
GET_WARP - Get warp mode status
SET_DISPLAY_MODE <0-2> Set mode (0=window, 1=fullscreen, 2=fullwindow)
GET_DISPLAY_MODE - Get current display mode
SET_NTSC <0|1> Set video mode (0=PAL, 1=NTSC)
GET_NTSC - Get current video mode
TOGGLE_RTG [monid] Toggle between RTG and chipset display
TOGGLE_STATUS_LINE - Cycle status line (off/chipset/rtg/both)
GET_FPS - Get current frame rate and idle percentage

Sound

Command Arguments Description
SET_SOUND_MODE <0-3> Set mode (0=off, 1=normal, 2=stereo, 3=best)
GET_SOUND_MODE - Get current sound mode

Configuration

Command Arguments Description
LOAD_CONFIG <config_path> Load a .uae config file
LIST_CONFIGS - List available config files
GET_CONFIG <option> Get a config value
SET_CONFIG <option> <value> Set a config value
GET_STATUS - Get emulation status

Input

Command Arguments Description
SEND_KEY <keycode> <state> Send key (state: 0=release, 1=press)
SEND_MOUSE <dx> <dy> <buttons> Send relative mouse input (buttons: bit0=L, bit1=R, bit2=M)
SEND_MOUSE_ABS <x> <y> [buttons] Send absolute mouse coordinates (requires tablet_mode mousehack or real)
SET_MOUSE_SPEED <10-200> Set mouse sensitivity
GET_MOUSE_SPEED - Get current mouse speed
TOGGLE_MOUSE_GRAB - Toggle mouse capture

GUI Automation (Controller Primitives)

These commands provide window-logical coordinates, button bitmasks, and guarded revisions for automation controllers such as the Amiberry MCP Server. Applications should prefer MCP or HTTP interfaces rather than raw IPC automation primitives.

Command Arguments Description
SCREENSHOT <path> ACTIONABLE Capture PNG and return window-logical and screenshot geometry metadata (SDL and OpenGL only; unavailable on Vulkan)
GET_GUI_AUTOMATION_STATE - Observe focus, tablet mode, mouse untrap, and configuration revisions
SET_GUI_AUTOMATION_CONFIG <expected_tablet> <expected_untrap> <expected_rev> <tablet> <untrap> Guarded compare-and-set of automation configuration
SEND_MOUSE_ABS_GUARDED <x> <y> <button_mask> <runtime_id> <geom_rev> <monitor_id> <config_rev> Apply guarded coordinates and button mask (0-7: bit0=L, bit1=R, bit2=M) if revisions match
RELEASE_MOUSE_BUTTONS - Unconditionally release left, right, and middle mouse buttons

Joystick/Gamepad

Command Arguments Description
GET_JOYPORT_MODE <port> Get port mode (port: 0-3)
SET_JOYPORT_MODE <port> <mode> Set port mode (see below)
GET_AUTOFIRE <port> Get autofire mode for port
SET_AUTOFIRE <port> <mode> Set autofire mode (see below)

Joyport modes: 0=default, 1=wheel mouse, 2=mouse, 3=joystick, 4=gamepad, 5=analog joystick, 6=CDTV remote, 7=CD32 pad, 8=lightpen

Autofire modes: 0=off, 1=normal, 2=toggle, 3=always, 4=toggle (no autofire)

Status

Command Arguments Description
GET_LED_STATUS - Get all LED states (power, floppy, HD, CD, caps)

Hardware/Chipset

Command Arguments Description
SET_CHIPSET <chipset> Set chipset (OCS, ECS_AGNUS, ECS_DENISE, ECS, AGA)
GET_CHIPSET - Get current chipset
SET_CPU_SPEED <speed> Set CPU speed (-1=max, 0=cycle-exact, >0=percentage)
GET_CPU_SPEED - Get current CPU speed
GET_CPU_MODEL - Get CPU model and FPU info
SET_CPU_MODEL <model> Set CPU model (68000, 68010, 68020, 68030, 68040, 68060)
GET_MEMORY_CONFIG - Get all memory sizes (chip, fast, bogo, z3, rtg)

Memory Configuration

Command Arguments Description
SET_CHIP_MEM <size_kb> Set Chip RAM (256, 512, 1024, 2048, 4096, 8192 KB)
SET_FAST_MEM <size_kb> Set Fast RAM (0, 64, 128, 256, 512, 1024, 2048, 4096, 8192 KB)
SET_SLOW_MEM <size_kb> Set Slow RAM (0, 256, 512, 1024, 1536, 1792 KB)
SET_Z3_MEM <size_mb> Set Z3 Fast RAM (0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024 MB)

Note: Memory changes require a reset to take effect.

Window/Display Control

Command Arguments Description
SET_WINDOW_SIZE <width> <height> Set window dimensions (320-3840 x 200-2160)
GET_WINDOW_SIZE - Get current window dimensions
SET_SCALING <method> Set scaling (-1=auto, 0=nearest, 1=linear, 2=integer, 3=stretch; names accepted)
GET_SCALING - Get current scaling mode
SET_LINE_MODE <mode> Set line mode (0=single/none, 1=double, 2=scanlines; names accepted)
GET_LINE_MODE - Get current line mode
SET_RESOLUTION <mode> Set resolution (0=lores, 1=hires, 2=superhires; names accepted)
GET_RESOLUTION - Get current resolution mode
SET_AUTOCROP <0|1> Enable/disable automatic display cropping
GET_AUTOCROP - Get current autocrop status

WHDLoad

Command Arguments Description
INSERT_WHDLOAD <path> Load a WHDLoad game (LHA archive or directory)
EJECT_WHDLOAD - Eject currently loaded WHDLoad game
GET_WHDLOAD - Get currently loaded WHDLoad game info

Note: INSERT_WHDLOAD configures the emulator for the WHDLoad game automatically. A reset or restart is typically needed for changes to take effect.

Debugging and Diagnostics

These commands provide debugging and diagnostic capabilities for advanced troubleshooting and development.

Debugger Control

Command Arguments Description
DEBUG_ACTIVATE - Activate the built-in debugger
DEBUG_DEACTIVATE - Deactivate the debugger and resume emulation
DEBUG_STATUS - Get debugger status (active=, stopped=, debugging=, exception_debugging=, reason=)
DEBUG_STEP [count] Single-step N instructions (default: 1)
DEBUG_STEP_OVER - Step over subroutine calls
DEBUG_CONTINUE - Continue execution until next breakpoint
MONITOR <text> Execute GDB monitor command over IPC (see Debugger Monitor)

Note: Debugger commands require Amiberry to be built with debugger support (DEBUGGER preprocessor define).

When stopped in the native debugger, DEBUG_STATUS reports stopped=1 and reason= containing the stop text (e.g. watchpoint hit, condition match, exception, or program entry). reason= is empty when emulation is running or paused normally (stopped=0), and is cleared when resuming (DEBUG_CONTINUE) or stepping (DEBUG_STEP/DEBUG_STEP_OVER).

Amiberry continues servicing IPC requests while a GDB client has the CPU stopped (debugger_service_ipc() runs during the GDB stop loop). Read-only IPC queries continue to receive replies during GDB stops. State-changing monitor commands and input events are refused while GDB is connected.

CPU State

Command Arguments Description
GET_CPU_REGS - Get all CPU registers (D0-D7, A0-A7, PC, SR, USP, ISP)
DISASSEMBLE <address> [count] Disassemble N instructions at address (default: 10)

Custom Chip Registers

Command Arguments Description
GET_CUSTOM_REGS - Get key custom chip registers (DMACON, INTENA, INTREQ, etc.)
GET_COPPER_STATE - Get Copper coprocessor state (addresses, enabled status)
GET_BLITTER_STATE - Get Blitter state (busy, channels, dimensions, addresses)
GET_DMA_STATE - Get DMA channel states (bitplane, sprite, audio, disk, copper, blitter)

Breakpoints

Command Arguments Description
SET_BREAKPOINT <address> [slot] Set a breakpoint at address (hex or decimal); optional [slot] is 0-19
CLEAR_BREAKPOINT <address|ALL> Clear breakpoint at address or all standard PC breakpoints (ALL)
LIST_BREAKPOINTS - List all active standard PC breakpoints

Note: The debugger supports up to 20 breakpoint slots, shared between standard PC breakpoints and monitor conditions (MONITOR condition add). Standard breakpoint commands isolate PC breakpoints from monitor conditions: SET_BREAKPOINT skips condition slots when allocating, explicit requests for condition slots are refused, CLEAR_BREAKPOINT ALL preserves conditions, and LIST_BREAKPOINTS omits them. Monitor conditions must be listed and removed via MONITOR condition list and MONITOR condition remove <id>.

Drive and Audio State

Command Arguments Description
GET_DRIVE_STATE [drive] Get floppy drive state (track, side, motor, disk inserted)
GET_AUDIO_STATE - Get audio channel states (volume, period, enabled)

Debugger Monitor

Amiberry exposes the WinUAE GDB monitor command set directly over the IPC socket as MONITOR <text> (when built with DEBUGGER and GDBSERVER). This allows automation tools, scripts, and the Amiberry MCP Server to inspect guest state, set memory watchpoints with value predicates, capture guest debug output, and control execution without running a GDB client.

Command Syntax and Framing

Commands are sent as MONITOR <text> or MONITOR\t<command>\t[arguments...]:

  • Argument formatting: Arguments separated by tabs are joined with single spaces before being passed to the monitor parser. Arguments containing spaces (such as file paths or program names) must be sent within a single tab-separated field. Commands containing ASCII control characters (< 0x20) are rejected with Invalid control character in monitor command.
  • Response framing: A successful command returns OK followed by one tab-separated field per result line:
    • Single-line outputs (including all JSON replies) form a single field: OK\t<json_string>.
    • Multi-line outputs (such as disasm) return one field per instruction line: OK\t<line1>\t<line2>\t....
    • Any tab characters within result lines are replaced with spaces so that field count matches line count.
  • Errors: Failed commands return ERROR\t<message>.

Execution Rules and State Table

IPC commands execute on the emulation thread between frames or while the native debugger is stopped. Between frames, the 68k core is not executing, so guest RAM reads are consistent.

Command Group Commands Execution Rule
Always Allowed capabilities, execution-status, memory-map, memory-check, screenshot, exception, watch list, watch events, watch last, dma-watch list, condition list, history read, guest-output read, process-break status, input event, input release, input status Can be executed while emulation is running, paused, or stopped in the debugger.
Guest RAM Reads disasm, tasks, segments Can be executed while running, paused, or stopped. When the CPU runs on a thread of its own, the CPU thread is parked for the duration of each command.
State Changes watch add, watch range, watch remove, watch clear-events, dma-watch add, dma-watch remove, condition add, condition remove, exception-mask, history on, history off, guest-output on, guest-output off, guest-output clear, process-break name, process-break address, process-break clear Require PAUSE or a stopped native debugger. These commands modify debugger tables or remap memory banks (memwatch_setup()). If sent while running unpaused, returns ERROR\tmonitor state changes require PAUSE or a stopped debugger. When the CPU runs on a thread of its own, the CPU thread is parked for the duration of each command. Refused while a GDB client is connected.
Refused (GDB-Specific) step-over, checkpoint save, checkpoint restore, input sequence Refused over IPC because they depend on the GDB stop loop. Errors indicate the IPC alternative: use DEBUG_STEP_OVER, SAVESTATE / LOADSTATE, and MONITOR input event.

Stop Handling and DEBUG_STATUS reason= Values

When no GDB client is attached, monitor stops (watch hits, selected exceptions, program-entry breaks, condition matches) halt execution in the native debugger that IPC controls.

When the CPU stops, DEBUG_STATUS reports stopped=1 and reason= containing the stop text:

Stop Type DEBUG_STATUS reason= Format Description
Access Watchpoint T05awatch:<addr>;winuae-source:<source>;winuae-reg:<reg>; Read/write memory watchpoint hit
Write Watchpoint T05watch:<addr>;winuae-source:<source>;winuae-reg:<reg>; Write memory watchpoint hit
Read Watchpoint T05rwatch:<addr>;winuae-source:<source>;winuae-reg:<reg>; Read memory watchpoint hit
Selected Exception Tnnwinuae-exception:<vec>;winuae-faultpc:<pc>;11:<pc>; CPU exception vector (2-63, nn signal)
Program Entry Break T05winuae-entry:<process_addr>;11:<pc>; AmigaDOS program-entry breakpoint hit
Monitor Condition T05breakpoint:<slot>; Register condition match in slot 0-19

reason= is empty when emulation is running or paused normally (stopped=0). Resuming execution via DEBUG_CONTINUE, single-stepping via DEBUG_STEP / DEBUG_STEP_OVER, or exiting the debugger via DEBUG_DEACTIVATE clears reason=.

Note: MONITOR execution-status reports GDB's halt flag, not this native stop state.

Ownership Rules Between IPC and GDB

IPC and a connected GDB client share a single internal monitor object.

  • IPC during GDB stops: While a GDB client has the CPU stopped, IPC remains responsive and continues answering queries. However, state-changing MONITOR commands, input event, and input release are refused (ERROR\ta GDB client is connected; monitor state changes are refused).
  • GDB connection refusal: A GDB detach clears all monitor state. To prevent state collisions, a new GDB connection is refused (WinUAE GDB: connection refused; IPC monitor state is active) while IPC holds any active monitor state:
    • Installed predicate watches (watch add, watch range)
    • Installed DMA watches (dma-watch add)
    • Installed conditional breakpoints (condition add)
    • An armed program-entry breakpoint (process-break name, process-break address; once it has fired and stopped, it is consumed and does not block GDB)
    • Non-zero exception mask (exception-mask)
    • History recording enabled (history on)
    • Guest output capture enabled or records present in buffer (guest-output on or captured records)
    • Recorded watch events in the event log (watch events)
    • Injected keys or joystick buttons held down via input event (The last recorded exception reported by MONITOR exception does not block GDB; it is dropped when GDB detaches).

Releasing IPC-Held State Before Attaching GDB

To release all IPC-held monitor state so a GDB client can connect:

  1. MONITOR watch remove <id> for all predicate watches (check MONITOR watch list)
  2. MONITOR dma-watch remove <id> for all DMA watches (check MONITOR dma-watch list)
  3. MONITOR condition remove <id> for all conditions (check MONITOR condition list)
  4. MONITOR exception-mask 0
  5. MONITOR process-break clear
  6. MONITOR history off
  7. MONITOR guest-output off followed by MONITOR guest-output clear
  8. MONITOR watch clear-events
  9. MONITOR input release

For complete monitor command details, argument formats, and source mask tables, see GDB Remote Debugging.

Memory Access

Command Arguments Description
READ_MEM <address> <width> Read memory (width: 1, 2, or 4)
WRITE_MEM <address> <width> <value> Write memory

Utility

Command Arguments Description
GET_VERSION - Get Amiberry and SDL version info
PING - Test connection (returns PONG)
HELP - List available commands

GET_CONFIG / SET_CONFIG Options

Readable Options (GET_CONFIG)

Option Description
chipmem_size Chip RAM size in bytes
fastmem_size Fast RAM size in bytes
bogomem_size Slow RAM size in bytes
z3fastmem_size Zorro III Fast RAM size
cpu_model CPU model (68000, 68010, etc.)
cpu_speed CPU speed setting
cpu_compatible CPU compatibility mode (true/false)
cpu_24bit_addressing 24-bit addressing mode (true/false)
chipset Chipset mask value
ntsc NTSC mode (true/false)
floppy_speed Floppy drive speed
nr_floppies Number of floppy drives
gfx_width Display width
gfx_height Display height
gfx_fullscreen Fullscreen mode (true/false)
sound_output Sound output mode
sound_stereo Stereo mode
joyport0 Joystick port 0 ID
joyport1 Joystick port 1 ID
description Configuration description

Writable Options (SET_CONFIG)

Option Description
floppy_speed Floppy drive speed (0=turbo, 100=normal)
cpu_speed CPU speed setting
turbo_emulation Turbo mode (true/false or 1/0)
gfx_fullscreen Fullscreen mode (true/false or 1/0)
sound_output Sound output mode (0-3)
sound_stereo Stereo mode
sound_volume Master volume
ntsc NTSC mode (true/false or 1/0)

Example Usage

Using netcat (Unix-like systems)

# Pause emulation
echo "PAUSE" | nc -U /tmp/amiberry.sock

# Resume emulation
echo "RESUME" | nc -U /tmp/amiberry.sock

# Hard reset
echo -e "RESET\tHARD" | nc -U /tmp/amiberry.sock

# Get status
echo "GET_STATUS" | nc -U /tmp/amiberry.sock

# Get chip RAM size
echo -e "GET_CONFIG\tchipmem_size" | nc -U /tmp/amiberry.sock

# Set floppy speed to turbo
echo -e "SET_CONFIG\tfloppy_speed\t0" | nc -U /tmp/amiberry.sock

# Insert floppy in DF0
echo -e "INSERTFLOPPY\t/path/to/disk.adf\t0" | nc -U /tmp/amiberry.sock

# Eject floppy from DF0
echo -e "EJECT_FLOPPY\t0" | nc -U /tmp/amiberry.sock

# List all floppy drives
echo "LIST_FLOPPIES" | nc -U /tmp/amiberry.sock

# Take screenshot
echo -e "SCREENSHOT\t/tmp/screenshot.png" | nc -U /tmp/amiberry.sock

# Load a savestate
echo -e "LOADSTATE\t/path/to/save.uss" | nc -U /tmp/amiberry.sock

# Set volume to 50%
echo -e "SET_VOLUME\t50" | nc -U /tmp/amiberry.sock

# Toggle fullscreen
echo "TOGGLE_FULLSCREEN" | nc -U /tmp/amiberry.sock

# Enable warp mode
echo -e "SET_WARP\t1" | nc -U /tmp/amiberry.sock

# Get version info
echo "GET_VERSION" | nc -U /tmp/amiberry.sock

# Test connection
echo "PING" | nc -U /tmp/amiberry.sock

# Quick save to slot 1
echo -e "QUICKSAVE\t1" | nc -U /tmp/amiberry.sock

# Quick load from slot 1
echo -e "QUICKLOAD\t1" | nc -U /tmp/amiberry.sock

# List hard drives
echo "LIST_HARDDRIVES" | nc -U /tmp/amiberry.sock

# Get joystick port 1 mode
echo -e "GET_JOYPORT_MODE\t1" | nc -U /tmp/amiberry.sock

# Set port 1 to joystick mode
echo -e "SET_JOYPORT_MODE\t1\t3" | nc -U /tmp/amiberry.sock

# Set port 1 to CD32 gamepad mode
echo -e "SET_JOYPORT_MODE\t1\t7" | nc -U /tmp/amiberry.sock

# Enable autofire on port 1
echo -e "SET_AUTOFIRE\t1\t1" | nc -U /tmp/amiberry.sock

# Get all LED states
echo "GET_LED_STATUS" | nc -U /tmp/amiberry.sock

# Set display mode to fullscreen
echo -e "SET_DISPLAY_MODE\t1" | nc -U /tmp/amiberry.sock

# Switch to NTSC mode
echo -e "SET_NTSC\t1" | nc -U /tmp/amiberry.sock

# Get current video mode
echo "GET_NTSC" | nc -U /tmp/amiberry.sock

# Set sound to best quality
echo -e "SET_SOUND_MODE\t3" | nc -U /tmp/amiberry.sock

# Set floppy speed to turbo
echo -e "SET_FLOPPY_SPEED\t0" | nc -U /tmp/amiberry.sock

# Get current floppy speed
echo "GET_FLOPPY_SPEED" | nc -U /tmp/amiberry.sock

# Set write protection on DF0
echo -e "DISK_WRITE_PROTECT\t0\t1" | nc -U /tmp/amiberry.sock

# Get write protection status for DF0
echo -e "GET_DISK_WRITE_PROTECT\t0" | nc -U /tmp/amiberry.sock

# Toggle RTG display
echo "TOGGLE_RTG" | nc -U /tmp/amiberry.sock

# Get FPS and idle percentage
echo "GET_FPS" | nc -U /tmp/amiberry.sock

# Toggle status line
echo "TOGGLE_STATUS_LINE" | nc -U /tmp/amiberry.sock

# Get mouse speed
echo "GET_MOUSE_SPEED" | nc -U /tmp/amiberry.sock

# Toggle mouse grab
echo "TOGGLE_MOUSE_GRAB" | nc -U /tmp/amiberry.sock

# Set chipset to AGA
echo -e "SET_CHIPSET\tAGA" | nc -U /tmp/amiberry.sock

# Get current chipset
echo "GET_CHIPSET" | nc -U /tmp/amiberry.sock

# Set CPU speed to max
echo -e "SET_CPU_SPEED\t-1" | nc -U /tmp/amiberry.sock

# Get current CPU speed
echo "GET_CPU_SPEED" | nc -U /tmp/amiberry.sock

# Get memory configuration
echo "GET_MEMORY_CONFIG" | nc -U /tmp/amiberry.sock

# Get CPU model info
echo "GET_CPU_MODEL" | nc -U /tmp/amiberry.sock

# Set CPU to 68020
echo -e "SET_CPU_MODEL\t68020" | nc -U /tmp/amiberry.sock

# Set Chip RAM to 2MB
echo -e "SET_CHIP_MEM\t2048" | nc -U /tmp/amiberry.sock

# Set Fast RAM to 4MB
echo -e "SET_FAST_MEM\t4096" | nc -U /tmp/amiberry.sock

# Set Slow RAM to 512KB
echo -e "SET_SLOW_MEM\t512" | nc -U /tmp/amiberry.sock

# Set Z3 Fast RAM to 64MB
echo -e "SET_Z3_MEM\t64" | nc -U /tmp/amiberry.sock

# Set window size to 800x600
echo -e "SET_WINDOW_SIZE\t800\t600" | nc -U /tmp/amiberry.sock

# Get window size
echo "GET_WINDOW_SIZE" | nc -U /tmp/amiberry.sock

# Set scaling to auto
echo -e "SET_SCALING\t-1" | nc -U /tmp/amiberry.sock

# Get scaling mode
echo "GET_SCALING" | nc -U /tmp/amiberry.sock

# Set line mode to double
echo -e "SET_LINE_MODE\t1" | nc -U /tmp/amiberry.sock

# Get line mode
echo "GET_LINE_MODE" | nc -U /tmp/amiberry.sock

# Set resolution to hires
echo -e "SET_RESOLUTION\t1" | nc -U /tmp/amiberry.sock

# Get resolution
echo "GET_RESOLUTION" | nc -U /tmp/amiberry.sock

# Enable autocrop
echo -e "SET_AUTOCROP\t1" | nc -U /tmp/amiberry.sock

# Disable autocrop
echo -e "SET_AUTOCROP\t0" | nc -U /tmp/amiberry.sock

# Get autocrop status
echo "GET_AUTOCROP" | nc -U /tmp/amiberry.sock

# Load WHDLoad game from LHA archive
echo -e "INSERT_WHDLOAD\t/path/to/game.lha" | nc -U /tmp/amiberry.sock

# Get currently loaded WHDLoad game info
echo "GET_WHDLOAD" | nc -U /tmp/amiberry.sock

# Eject WHDLoad game
echo "EJECT_WHDLOAD" | nc -U /tmp/amiberry.sock

# --- Debugging Commands ---

# Activate the debugger
echo "DEBUG_ACTIVATE" | nc -U /tmp/amiberry.sock

# Check debugger status
echo "DEBUG_STATUS" | nc -U /tmp/amiberry.sock

# Single-step one instruction
echo "DEBUG_STEP" | nc -U /tmp/amiberry.sock

# Single-step 10 instructions
echo -e "DEBUG_STEP\t10" | nc -U /tmp/amiberry.sock

# Continue execution
echo "DEBUG_CONTINUE" | nc -U /tmp/amiberry.sock

# Deactivate the debugger
echo "DEBUG_DEACTIVATE" | nc -U /tmp/amiberry.sock

# Get all CPU registers
echo "GET_CPU_REGS" | nc -U /tmp/amiberry.sock

# Disassemble 10 instructions at address 0xFC0000
echo -e "DISASSEMBLE\t0xFC0000\t10" | nc -U /tmp/amiberry.sock

# Get custom chip registers
echo "GET_CUSTOM_REGS" | nc -U /tmp/amiberry.sock

# Set a breakpoint at address 0x400
echo -e "SET_BREAKPOINT\t0x400" | nc -U /tmp/amiberry.sock

# List all breakpoints
echo "LIST_BREAKPOINTS" | nc -U /tmp/amiberry.sock

# Clear a specific breakpoint
echo -e "CLEAR_BREAKPOINT\t0x400" | nc -U /tmp/amiberry.sock

# Clear all breakpoints
echo -e "CLEAR_BREAKPOINT\tALL" | nc -U /tmp/amiberry.sock

# Get Copper state
echo "GET_COPPER_STATE" | nc -U /tmp/amiberry.sock

# Get Blitter state
echo "GET_BLITTER_STATE" | nc -U /tmp/amiberry.sock

# Get DMA state
echo "GET_DMA_STATE" | nc -U /tmp/amiberry.sock

# Get floppy drive 0 state
echo -e "GET_DRIVE_STATE\t0" | nc -U /tmp/amiberry.sock

# Get all floppy drive states
echo "GET_DRIVE_STATE" | nc -U /tmp/amiberry.sock

# Get audio channel states
echo "GET_AUDIO_STATE" | nc -U /tmp/amiberry.sock

Using the Test Client

Amiberry includes a Python test client in tools/ipc_client.py. It works on both transports: it connects to the Unix socket on Linux, macOS, and FreeBSD, and to the named pipe on Windows:

# Interactive mode
python tools/ipc_client.py

# Single command mode
python tools/ipc_client.py PAUSE
python tools/ipc_client.py GET_STATUS
python tools/ipc_client.py SET_CONFIG floppy_speed 0
python tools/ipc_client.py INSERTFLOPPY /path/to/disk.adf 0
python tools/ipc_client.py EJECT_FLOPPY 0
python tools/ipc_client.py SET_VOLUME 75
python tools/ipc_client.py TOGGLE_FULLSCREEN
python tools/ipc_client.py GET_VERSION
python tools/ipc_client.py QUICKSAVE 1
python tools/ipc_client.py QUICKLOAD 1
python tools/ipc_client.py LIST_HARDDRIVES
python tools/ipc_client.py GET_JOYPORT_MODE 1
python tools/ipc_client.py SET_JOYPORT_MODE 1 7
python tools/ipc_client.py GET_LED_STATUS
python tools/ipc_client.py SET_NTSC 0
python tools/ipc_client.py SET_FLOPPY_SPEED 0
python tools/ipc_client.py GET_FLOPPY_SPEED
python tools/ipc_client.py TOGGLE_RTG
python tools/ipc_client.py GET_FPS
python tools/ipc_client.py SET_CHIPSET AGA
python tools/ipc_client.py GET_CHIPSET
python tools/ipc_client.py SET_CPU_SPEED -1
python tools/ipc_client.py GET_CPU_SPEED
python tools/ipc_client.py GET_MEMORY_CONFIG
python tools/ipc_client.py TOGGLE_MOUSE_GRAB
python tools/ipc_client.py GET_CPU_MODEL
python tools/ipc_client.py SET_CPU_MODEL 68020
python tools/ipc_client.py SET_CHIP_MEM 2048
python tools/ipc_client.py SET_FAST_MEM 4096
python tools/ipc_client.py SET_SLOW_MEM 512
python tools/ipc_client.py SET_Z3_MEM 64
python tools/ipc_client.py SET_WINDOW_SIZE 800 600
python tools/ipc_client.py GET_WINDOW_SIZE
python tools/ipc_client.py SET_SCALING 1
python tools/ipc_client.py GET_SCALING
python tools/ipc_client.py SET_LINE_MODE 1
python tools/ipc_client.py GET_LINE_MODE
python tools/ipc_client.py SET_RESOLUTION 1
python tools/ipc_client.py GET_RESOLUTION
python tools/ipc_client.py SET_AUTOCROP 1
python tools/ipc_client.py GET_AUTOCROP
python tools/ipc_client.py INSERT_WHDLOAD ~/Games/Turrican.lha
python tools/ipc_client.py GET_WHDLOAD
python tools/ipc_client.py EJECT_WHDLOAD

# Debugging commands
python tools/ipc_client.py DEBUG_ACTIVATE
python tools/ipc_client.py DEBUG_STATUS
python tools/ipc_client.py DEBUG_STEP 10
python tools/ipc_client.py DEBUG_CONTINUE
python tools/ipc_client.py DEBUG_DEACTIVATE
python tools/ipc_client.py GET_CPU_REGS
python tools/ipc_client.py DISASSEMBLE 0xFC0000 10
python tools/ipc_client.py GET_CUSTOM_REGS
python tools/ipc_client.py SET_BREAKPOINT 0x400
python tools/ipc_client.py LIST_BREAKPOINTS
python tools/ipc_client.py CLEAR_BREAKPOINT 0x400
python tools/ipc_client.py CLEAR_BREAKPOINT ALL
python tools/ipc_client.py GET_COPPER_STATE
python tools/ipc_client.py GET_BLITTER_STATE
python tools/ipc_client.py GET_DMA_STATE
python tools/ipc_client.py GET_DRIVE_STATE 0
python tools/ipc_client.py GET_AUDIO_STATE

The client supports tilde expansion (~) in file paths:

python tools/ipc_client.py SCREENSHOT ~/Downloads/screenshot.png

Using Python

import socket

def send_command(command, *args):
    sock_path = "/tmp/amiberry.sock"
    message = "\t".join([command] + list(args)) + "\n"

    with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as sock:
        sock.connect(sock_path)
        sock.sendall(message.encode())
        response = sock.recv(4096).decode().strip()

    parts = response.split("\t")
    success = parts[0] == "OK"
    data = parts[1:] if len(parts) > 1 else []
    return success, data

# Examples
send_command("PAUSE")
send_command("RESUME")
send_command("GET_STATUS")
send_command("SET_CONFIG", "floppy_speed", "0")
send_command("INSERTFLOPPY", "/path/to/disk.adf", "0")
send_command("EJECT_FLOPPY", "0")
send_command("SET_VOLUME", "50")
send_command("TOGGLE_FULLSCREEN")
send_command("SET_WARP", "1")
send_command("GET_VERSION")

This example uses socket.AF_UNIX, which CPython does not provide on Windows. On Windows, open the named pipe like a file instead (see Windows Named Pipe); tools/ipc_client.py shows a working implementation.

MCP Server Integration

The Amiberry MCP Server (GitHub repository) provides Model Context Protocol (MCP) tools and an HTTP API for controlling Amiberry from AI assistants (Claude, Codex, Gemini/Antigravity, Cursor, etc.) and automation scripts.

It exposes 150 tools spanning configuration editing, savestates, ROM identification, runtime IPC control, memory access, screenshot-driven GUI automation, and the full set of debugger monitor tools (MONITOR) added after Amiberry 8.4.1.

The MCP server connects over the Unix domain socket on Linux, macOS and FreeBSD, and over the named pipe on Windows (see MCP Server).

See MCP Server for complete documentation, installation instructions, client configuration snippets, and HTTP API endpoints.

Response Examples

GET_STATUS Response

OK	Paused=false	Config=A500	Floppy0=/path/to/disk1.adf	Floppy1=/path/to/disk2.adf

LIST_FLOPPIES Response

OK	DF0=/path/to/disk1.adf	DF1=<empty>	DF2=<empty>	DF3=<empty>

GET_VERSION Response

OK	version=8.0.0-pre18	sdl=2.28.5

GET_CONFIG Response

OK	2097152

Error Response

ERROR	Unknown option: invalid_option

Implementation Details

The IPC socket implementation is in:

  • src/osdep/amiberry_ipc.h - Interface definitions
  • src/osdep/amiberry_ipc_socket.cpp - Socket implementation

The socket (named pipe on Windows) is created during Amiberry initialization (via IPCSetup()) and polled in the main event loop (via IPCHandle()). Each client connection is handled synchronously with a short timeout to avoid blocking the emulation.

Comparison: IPC Socket vs D-Bus

Feature IPC Socket D-Bus
Platforms Linux, macOS, FreeBSD, Windows Linux only
Dependencies None libdbus
Protocol Simple text D-Bus wire protocol
Discovery Fixed socket path or pipe name D-Bus service name
Use case Cross-platform, automation Linux desktop integration

Both options support the same set of commands. Choose based on your platform and integration needs.

Clone this wiki locally