Command line

Xpeccy+ takes file names and options on the command line:

xpeccy-plus [options] [files]

On Windows Xpeccy+ is xpeccy-plus.exe. If a name has spaces in it, put it in quotes.

-h or --help prints the list of options and quits without opening the window. On Windows add -c to see the list.

If Xpeccy+ does not know an option, or an option comes last without its value, the emulator does not open it as a file. Instead it writes a warning to the log and, once the window is up, shows a message over the picture. If an address or a page number is not a number, you get the same warning, and the option is ignored.

Files

Every word that is not an option is a file to open: a snapshot, a tape, a disk or anything else that File > Open… can open. To open several files, name them all, for example a disk and a tape. From an archive, Xpeccy+ opens the first image. To open another image in it, add the image’s name after the archive’s name, as in game.zip/Side B.tzx.

The command line is read from left to right, and an option acts on the files after it.

A tape or a disk named here is run, as if Run opened media were chosen on the File types page of Options. If Mount opened media is chosen there, the tape or disk is only mounted. The command line never asks which one you want, even if Ask: run or mount is chosen. Two options override this for one start:

  • --autostart - run the files named here, whatever Options says;

  • --no-autostart - only mount them.

A file opened here can switch the machine, as it does when you open the file from the menu (see Run a program), unless -m names the machine.

If Options is set to ask for the machine at start, and you name a file or a machine here, Xpeccy+ skips the Start Machine question (see Machine at start).

Machine and media

  • -m ID, --machine ID - start on this machine. ID is the machine’s name as the list shows it, such as "ZX Spectrum 128K", or its short id: the name of its file, such as zx48, zx128, zxplus2, zxplus2a, zxplus3, zxnext, pent, pent1024, scorp, scorptp, robik, atm2, profi3, profi, phoenix, evo-baseconf, evo-tsconf, alf, alf128. -m acts before anything else, wherever it stands, so a snapshot named before it is not lost. If it is given twice, the last one counts. It works as if you had picked the machine in the Machine menu.

  • --disk X - the floppy drive for the disks named after it: 0 to 3, a to d or A to D. Without it a disk goes into drive A.

  • --sdcard PATH - the SD card of the ZX Evolution, the ZX Spectrum Next or a Z-Controller: an image, or a folder served as a card.

  • --next-system DIR - the System/Next folder a ZX Spectrum Next program starts from, instead of the release unpacked in the settings folder (see Starting programs).

  • --uart-esp PORT, --uart-pi PORT - for this run only, what is on the ZX Spectrum Next’s ESP UART or Pi UART: a serial port of this computer (COM3, /dev/ttyUSB0, \\.\pipe\NAME on Windows), esp for the emulated ESP-01, - for nothing (see Wi-Fi and serial ports).

  • --confdir DIR - take the settings from another folder instead of the usual one (see Where the settings are).

xpeccy-plus -m pent game.trd
xpeccy-plus --disk b data.trd --disk a boot.trd

Cheats

A cheat file (.pok) named here goes into the Cheats window, and the window opens. It takes the place of the image’s own cheat file, whichever of the two comes first.

--poke LIST puts a trainer into the window without a file. It is meant for a program that starts Xpeccy+ with a game and keeps its pokes itself. The trainer is not ticked, just as a cheat file’s trainers are not. Tick it once the game has loaded.

--poke [NAME=]POKE[:POKE...]
  • POKE is ADR,VAL: the address and the byte to write there, 0 to 255. If the byte is ?, Xpeccy+ asks for it when the trainer is ticked.

  • PAGE/ADR,VAL writes into a 128K memory page, 0 to 7, at that address in the page.

  • ADR,VAL,ORG adds the byte the game has there, so the window can tell whether the game in memory is the one the poke is for. 0 means it is not known, as in a cheat file.

  • NAME= names the trainer. Without it the trainer is named by its pokes.

  • ADR can be a label, also as LABEL+N or LABEL-N, from -l or from the image’s own labels. A loaded label wins over a hex number spelled the same, such as each. The label carries its page, so you do not put PAGE/ before it. Its address is looked up each time the trainer is ticked, so after you rebuild your program and File > Reload it, the poke goes where the label is now. If a label is not loaded, the trainer’s row shows its name, and the trainer cannot be ticked.

Give --poke once for each trainer: all the pokes of one --poke are ticked together. The trainers come after those of a cheat file named on the command line. If there is no such file, they take the place of the image’s own cheat file, and they are removed when another game is opened. Numbers are written as in the debugging options. If a poke cannot be read, the message over the picture and the log show it, and its --poke is left out.

If you use File > Reload on the image named here, the cheats named with it stay, with nothing ticked.

xpeccy-plus game.tap --poke "Infinite lives=35899,0" --poke 1/49152,0:1/49153,0
xpeccy-plus -l game.lab game.tap --poke "Lives=lives,9" --poke "No check=check+2,0"

Window

These options change the setting itself, as Options would, and the new value stays for the next start.

  • -s N, --size N - window size, 1 to 6 (x1 to x6).

  • --fullscreen 1 - start fullscreen; --fullscreen 0 - in a window.

  • -r 1, --ratio 1 - keep the picture’s shape in fullscreen; 0 stretches it.

  • -n N, --noflick N - anti-flicker intensity, 0 to 100 percent.

  • --style - macOS only: use the system’s own look instead of the one Xpeccy+ sets.

These are for this run only:

  • --no-gl - draw the picture without OpenGL, and so with no shader. Xpeccy+ does this by itself when the computer’s graphics have no usable OpenGL.

  • --no-update-check - do not look for a newer version (see Updates).

Debugging

  • -d, --debug - open the Debugger right away.

  • -l FILE, --labels FILE - load a labels file: the Debugger’s own, SjASMPlus’s LABELSLIST, CSPECTMAP or SLD, a SkoolKit control file or a ZX Spin symbol file (see Label files). They take precedence over the labels that come with an image.

  • -a ADR, --adr ADR - the address at which -f loads the file; 16384 (0x4000) if not given.

  • -f FILE, --file FILE - load a binary file into memory at that address.

  • -b N, --bank N - put RAM page N at #C000.

  • --pc ADR - set the PC register.

  • --sp ADR - set the SP register.

  • --bp ADR - a breakpoint on executing that address. A label name works too. If a label is in a page that is not paged in at start, the breakpoint goes on its cell, so it stops when that page runs the code there. A ROM label in several banks gets a breakpoint in each, and so does a short ROM name shared by several systems: --bp LD_BYTES on a +3 stops in ROM 1’s and in ROM 3’s.

  • --brk FILE - load a list of breakpoints (.xbrk). Its addresses can be labels, set the way --bp sets them. Give it more than once to load several lists.

  • --brk-log FILE - where the breakpoint log goes. With -, the log goes to the standard output.

  • --xmap FILE - load a memory map saved by earlier versions of the Debugger (.xmap).

  • --dezog - for this run, let DeZog debug the machine from VS Code, on the port set in Options > Application > DeZog port.

  • --dezog-port N - the same, on port N.

A number in these options is hex with #, $ or 0x in front (#8000, $8000, 0x8000), and decimal without one (32768). A leading zero changes nothing: 0100 is one hundred. In a shell, # starts a comment and $ a variable, so there write 0x8000, or put the number in quotes: "#8000".

--bp and --brk are set after all the options are read, so they can use the labels of -l wherever -l stands. The other options act at the moment they are read, so put them after the snapshot they apply to: a snapshot loaded later sets its own registers and memory. If a tape or a disk is run, it resets the machine after all the options are read, and this undoes --pc and --sp.

xpeccy-plus -m zx128 -a 0x8000 -f code.bin --pc 0x8000 -d
xpeccy-plus game.sna --bp main -l game.lab

Running with no window

--bench N runs the machine for N frames with no window, as fast as the computer can, with no sound, and quits. It is for scripts: running a test program, measuring a routine, taking a picture or a snapshot at a given frame. Everything else on the command line acts as usual, so the files, the machine and the breakpoints are set first.

A breakpoint whose action is Debugger ends the run where it fires. A breakpoint with Counter counts and lets the run go on, and one with Log writes its log line, as it does in the window.

What the run prints goes to the standard output. Xpeccy+’s log, if it is written to the console, goes to the standard error. A run ends with a line that shows its speed:

bench: machine zx48, fast, 83 frames in 0.153 s: 543.5 fps, x10.85 real time, 26.14 ns/T (stopped early)

(stopped early) means a breakpoint ended the run. After this line comes one SPAN line for each span the breakpoints measured (see Spans).

The exit code tells a script how the run ended:

Code

Meaning

0

the run went through every frame asked for

1

something on the command line was not understood; nothing was run

2

a breakpoint stopped the run

More options for such a run:

  • --bench-skip N - run N frames first, left out of the timing;

  • --bench-steps N - then run N more instructions, to stop in the middle of a frame;

  • --bench-full - mix the sound too, as a run with the window does;

  • --bench-keys SPEC - press keys on given frames, see below;

  • --bench-hash - print a check sum of the frames, the sound, the RAM and the registers, to tell whether two runs did the same;

  • --bench-shot FILE - save the last frame, with the whole border, as a PPM picture;

  • --bench-save FILE - save a snapshot at the end, in the format of the file’s extension;

  • --bench-state FILE - save the raw state of the machine at the end;

  • --bench-nodraw - draw no picture, to measure the rest without it;

  • --bench-heat - collect the memory heat map, and include it in the --bench-hash sum;

  • --bench-prof FILE - Windows only: write to FILE where the emulation spends its time.

The value of --bench-keys is a list separated by commas. Each item is FRAME:KEYS or FRAME:KEYS/N: the keys are pressed on that frame of the run and held for N frames, or 4 if N is not given. The keys of one item are pressed together. Digits and lowercase letters are the same keys of the Spectrum; E is Enter, C Caps Shift, S Symbol Shift and _ Space. joy: followed by joystick directions and buttons joined by +, such as joy:up+fire, holds them on the joystick, and joyb: does the same on the second joystick. nmi presses the NMI button, and pc: with a keymap name presses a key of the PC keyboard of a ZX Evolution or a ZX Spectrum Next: pc:F1, pc:UP, pc:ENT.

xpeccy-plus -m zx48 game.tap --bench-keys "500:5,600:_/10" --bench 2000 --bench-shot end.ppm

--help lists a few more --bench- options. They are for testing the emulator itself.

On Linux and macOS, a shell waits for the run and gets its exit code as usual. On Windows, the console you start Xpeccy+ from does not wait for it. In PowerShell, send what it prints into a pipe, and the exit code is in $LASTEXITCODE:

.\xpeccy-plus.exe -m zx48 --brk test.xbrk --bench 3000 | Out-String
$LASTEXITCODE

In the Command Prompt, start it with start /wait "" xpeccy-plus.exe ..., and the exit code is in %errorlevel%.

Recording

  • --wav-out FILE - record the sound to a WAV file from the start.

  • --video-out FILE - record a video from the start, .mp4 or .mkv.

  • --video-auto, --no-video-auto - turn on or off the automatic start and stop of video recording, whatever Options says.

  • --video-autostart AT, --video-autostop AT - when the automatic recording starts and stops.

See Capture menu for what each one does.

Logging

These options act for this start only. The settings in Options stay as they are.

  • --log - write a log file, to logs/<date>/ beside Xpeccy+. If the emulator’s folder cannot be written to, the log goes to the settings folder.

  • --no-log - no log file, even if Options says to write one.

  • --log-dir DIR - put the logs folder into DIR.

  • --log-level LEVEL - how much is written: error, warn, info (the usual), debug or trace.

  • --log-groups SPEC - a level for separate parts of Xpeccy+, such as "video:trace,net:off". "all:debug" sets them all, and a part with - in front, such as -sound, is turned off. The parts are app, conf, core, cpu, video, sound, tape, disk, input, hw, file, gui, gl, net and brk.

  • --log-console - write the log to the standard error as well, as To the console in Options does. On Windows Xpeccy+ has a standard error only when it is started with -c or with its output redirected.

  • -c, --console - Windows only: write to the console Xpeccy+ was started from, or open a console of its own if there is none. That console waits for a key before it closes. The log goes there at debug level unless --log-level says otherwise. Output sent to a file stays in the file.