Moon Landing in Kerbal Space Program via ZX Spectrum: Technical Details
Enthusiast Scott Manley implemented control of the lunar lander in the Kerbal Space Program simulator using a 1982 ZX Spectrum. The 8-bit computer—with a 3.5 MHz Z80A processor and up to 128 KB of memory—handled the task despite two-second delays. Integration relied on the Fuse emulator, Interface 1, and kRPC mod.
Hardware Limitations of the ZX Spectrum and Comparison with AGC
The ZX Spectrum featured a Z80A processor (3.5 MHz), Sinclair BASIC, and 16–128 KB of memory. This outperformed the Apollo Guidance Computer (AGC) from the Apollo 11 mission: 2.048 MHz, 15-bit architecture, and 2048 words of memory with 1-bit parity. AGC programmers optimized code for minimal resource use, requiring considerable ingenuity.
Manley noted that modern smartphone chargers have more computing power than a ZX Spectrum, but the retro machine still demanded careful optimization. He had to pack variables for calculating orientation, acceleration, and trajectory into the limited memory to enable maneuvers and landing.
Integrating ZX Spectrum with Kerbal Space Program
Direct connection isn't possible due to the lack of USB. The solution:
- Fuse emulator for ZX Spectrum.
- Virtual Interface 1 with RS232 port.
- Python script for data exchange over the serial interface.
- Kerbal RPC mod (kRPC) for external control of KSP via Python or other languages.
The BASIC program read telemetry and sent commands. A Python script acted as the go-between for RS232 and kRPC, relaying data to the simulation in real time.
10 REM Chtenie data with RS232
20 INPUT #1, a$,b$,c$
30 PRINT "Telemetry: ";a$;" ";b$
40 REM Sending komand
50 PRINT #1, "THROTTLE 0.5"
60 GOTO 10
This loop provided basic spacecraft control.
Landing Process and Performance
After launch, the program initiated the module's descent to the Moon. The system processed data with a ~2-second delay—mirroring the AGC's cycle, which computed navigation parameters at the same interval and successfully landed Apollo 11.
Manley had previously set up the connection for monitoring and control. Full stack: Fuse + Interface 1 + Python + kRPC. The delays didn't prevent trajectory corrections and a soft landing.
Additional Project: ZX Spectrum Emulator in C++
Manley revived an abandoned ZX Spectrum emulator written in C++. The project had stalled due to the Z80's 158 basic instructions, which expand to 800+ opcodes with prefixes and addressing modes. Manual implementation was tedious.
Using Gemini 3 Pro and Google Antigravity IDE, he finished development in an evening. The AI generated the opcode handling, allowing the emulator to run games.
- AI advantages: automates tedium, delivers accurate Z80 emulation.
- Result: a working emulator free of bugs in basic scenarios.
Key Takeaways
- ZX Spectrum (1982) outpowers AGC (1969), but still needs optimization for real-time tasks.
- The Fuse + Interface 1 + kRPC stack lets you integrate 8-bit systems with modern simulators.
- A two-second cycle matches AGC and is enough for landing.
- AI (Gemini 3 Pro) accelerates Z80 emulation by generating 800+ opcodes in hours.
— Editorial Team
No comments yet.