Skip to content

ZXSpectrum ​

python
ZXSpectrum(zx: DotNetZXSpectrum | None = None, emulator_type: EmulatorType | None = None, screen_type: ScreenType | None = None)

A 48K ZX Spectrum with access to its CPU, keyboard, memory and screen.

With no arguments, creates a fast emulator and fast screen. Set emulator_type or screen_type to choose another implementation. The zx argument wraps an existing .NET emulator and cannot be combined with those options.

Source

Properties ​

cpu ​

python
cpu: Z80

The machine CPU and its registers.

Source

keyboard ​

python
keyboard: Keyboard

The machine keyboard.

Source

memory ​

python
memory: Memory

The 64K address space, indexed by byte address.

Source

screen ​

python
screen: Screen

The machine display.

Source

type ​

python
type: EmulatorType

The selected CPU execution model.

Source

Methods ​

dump ​

python
dump(path: str | PathLike, exception: Exception | DotNetException | None = None)

Write an HTML diagnostic dump to the supplied path.

A .NET exception can be included in the dump. Python exceptions are not passed through to the underlying .NET dump.

Source

execute_frame ​

python
execute_frame() -> ExecutionResult

Execute one frame and return whether execution completed or hit a breakpoint.

Source

execute_frames ​

python
execute_frames(frames: int) -> ExecutionResult

Execute the requested number of frames, stopping early at a breakpoint.

Source

get_screen_memory ​

python
get_screen_memory() -> np.ndarray[typing.Any, np.dtype[np.uint8]]

Return a NumPy view of a copy of the 6912 screen-memory bytes.

Changing the returned array does not change emulator memory.

Source

load ​

python
load(path: str | PathLike) -> None

Load a ZX Spectrum file, for example a snapshot, into the emulator. Compressed files, for example .z80.zst, are decompressed automatically.

Source

reset ​

python
reset() -> None

Reset the machine, clearing its RAM and CPU state.

Source

run_until_address ​

python
run_until_address(address: int) -> None

Execute until the CPU reaches the given address.

Source

save_z80_snapshot ​

python
save_z80_snapshot(directory: str | PathLike, name: str, compression: CompressionFormat = CompressionFormat.NONE) -> Path

Save a Z80 snapshot as name.z80 in the given directory, optionally compressed, and return the path of the saved file.

Source