Running the machine
Choose an implementation
python
from mrkwatkins.oakemu.zxspectrum import EmulatorType, ScreenType, ZXSpectrum
spectrum = ZXSpectrum(
emulator_type=EmulatorType.ACCURATE,
screen_type=ScreenType.ACCURATE,
)The CPU choices are BASIC, FAST and ACCURATE. The screen choices are FAST and ACCURATE; choose the accurate screen when border and flashing effects matter.
CPU and screen choices are independent. Both default to FAST.
Execute frames
python
from mrkwatkins.oakemu.zxspectrum import ExecutionResult
result = spectrum.execute_frame()
if result == ExecutionResult.BREAKPOINT_STOP:
print("Execution stopped at a breakpoint")execute_frames(count) runs several frames and stops early if a breakpoint is reached. Frame counts describe emulated time; they do not make execution wait for real time to pass.
The wrapper exposes FRAME_RATE and T_STATES_PER_FRAME for code that needs the machine timing constants.
Run to an address
python
spectrum.run_until_address(30000)This executes until the CPU reaches the supplied address. Choose an address the running program will reach.
Reset
python
spectrum.reset()Reset clears the machine RAM and CPU state. Existing keyboard, memory, screen and CPU wrappers still refer to the same machine.