Lost Eden static recomp
Lost Eden static recomp is a Windows port of the Philips CD-i game Lost Eden, featuring Cartoon HD filters and run-ahead.
- Type: PC port
- Game: Lost Eden
- Runs on Windows
- By tools81
- Latest release v1.0.0, 2026-11-29
- Source: https://github.com/tools81/lost-eden-static-recomp
README
Lost Eden (CD-i) — static recompilation
A native Windows port of the Philips CD-i version of Lost Eden (Europe,
PAL), made from the CD-i static recompilation template described further
down. The game's 68000 code (CMDS/cdi_load, CMDS/cdi_edstart with its
linked modules cdi_edlink1 and cdi_edlink2) is translated to C. The
runtime emulates CD-RTOS, the CD-i video and audio hardware and the Digital
Video Cartridge (MPEG-1 video and audio), which the game requires.
No game files are included in this repository or in the releases: you
need your own copy of the disc as a .cue/.bin image.
Download and play
Get the latest release from the Releases page:
LostEden-<version>-setup.exe: installer. It asks for the folder with your.cue/.bin, needs no administrator rights, and installs to%LOCALAPPDATA%\Programs\Lost Eden(any folder can be chosen).LostEden-<version>-portable.zip: unzip anywhere and runlosteden.exe. The first time it asks for the disc image (or put it in aromfolder next to the program).
The program is portable: saves, quicksaves, settings, the disc location
and the log are written to saves\ next to losteden.exe, never to AppData
or the registry. The shaders are built into the executable, and it is linked
with the static C runtime, so nothing else has to be installed. The shortcuts
pass --portable, which is the default behaviour.
At start-up the game checks this repository for a newer release and offers
to install it (saves and settings are kept; --no-update-check turns this
off).
The release executable is built without the translated game code
(RECOMP_INTERP_ONLY): it reads the game's program from your disc and runs
it in the runtime's 68000 interpreter, with the same output as the
recompiled build.
Controls
| Key | Action |
|---|---|
| Arrow keys (Shift = faster), gamepad stick or D-pad | move the pointer |
| Z / Space / A / Enter, gamepad A | button 1 |
| X / Ctrl / S, gamepad B or Y | button 2 |
| F2 / F3 / F4 | quicksave / next slot (1-10) / load |
| F6 | run-ahead 0-3 fields (default 1) |
| F7 | sprite interpolation to 60 fps on/off (default on) |
| F9 / F10 / F11 | aspect ratio / filter / fullscreen (or Alt+Enter) |
| Tab (hold) | fast forward |
| Esc | quit |
Enhancements
- Cartoon HD and Cartoon HD+ filters (F10,
runtime/cartoon.c): edge-directed 4x upscaling to 1536x960 after the xBR edge rule, run on all CPU cores and only over the parts of the picture that changed. HD+ also inks dark line art and applies an adaptive sharpen. - Run-ahead (
runtime/frontend.c): after each real field the emulator is snapshotted, runs N more fields with the current input, shows that picture and restores the snapshot, so the game answers N fields (20 ms each) sooner. Only the real field is heard. - Sprite interpolation to 60 fps (
runtime/motion.c): the game runs at 50 fields a second and holds most pictures for several fields. The frontend looks ahead (from a snapshot) for the next picture, finds which 8x8 blocks moved, and shows each 60 Hz frame with the moving parts at their position for that moment. Changes of shape switch when they did on the CD-i, and full motion video is shown at its own frame rate. - Quicksaves (
runtime/state.c): F2 saves a complete snapshot of the emulated player to the selected slot (in memory andsaves\quicksave_<n>.sav), F4 restores it, F3 selects one of 10 slots. Runtime heap objects (display tables, sound buffers, the MPEG decoders) live in one fixed-address arena, so a snapshot is the 68000 state, the used RAM, each module's globals and that arena.
If the PC cannot emulate the extra fields in time, interpolation and then run-ahead are turned down automatically, with a message on screen.
Building from source
- Put your disc image (
Lost Eden (Europe).bin+.cue) inrom/. - Run
build.bat(needs Python 3, CMake 3.19+ and Visual Studio 2022). It extracts the program modules, recompiles them to C ingen/and buildslosteden.exe. - Run
losteden.exe.
package.bat builds the release packages in dist\: the portable zip and,
with Inno Setup 6 installed, the
single-file installer (installer\losteden.iss). Both use the
interpreter-only build, so they contain nothing from the disc. The version
is in runtime\version.h and VERSION.
Lost Eden-specific options: --overscan shows all 280 lines of the PAL field
(by default the game's 240-line picture area is shown), --runahead N,
--interpolation on|off and --filter N (0-5). For debugging there are also
--mpegdump (write decoded MPEG pictures to saves/), --dumpdcp N (log the
display program and compositing of field N), --data DIR (use DIR instead of
saves/, for running several tests at once) and --hashlog (a checksum and
cycle count of every field, for comparing runs). Headless runs leave the
enhancements off unless --runahead/--interpolation are given; with them,
the real fields must hash the same as without (a check that snapshots are
complete). Script keys Q, E, W press F2, F3 and F4.
tools/contact.py and tools/framestats.py turn frame dumps into a contact
sheet and per-frame brightness figures.
What this port added to the template
runtime/mpeg.c: the Digital Video Cartridge's MPEG video (/mv) and MPEG audio (/ma) drivers. It demuxes the CD-i MPEG sectors and decodes them with the vendored pl_mpeg (MIT).- Kernel: F$Chain, F$Event (with the system
line_event), F$CCtl, and the system globals pointer at address 0 (D_Ticks). The CSD now describes a player with the cartridge. Blocking calls (F$Sleep, event waits) resume by re-executing the trap, so a field always ends at the top-level dispatcher, where a snapshot can be taken. - PAL video (280 lines, 50 Hz), selected with
"video": "pal"ingame.json. - Analyzer: modules stored together in one file, lazy-binding call
trampolines, branch tables, unrolled loops and code pointers in data. Code
it still misses runs in the interpreter and is logged to
saves/missed_entries.txt. "interpret"ingame.jsonlists self-modifying code, which always runs in the interpreter (Lost Eden's 3D pointer renderer patches its rotation matrix intomuls.w #imminstructions).- Audio output is locked to the sound card's clock with about 100 ms queued, and MPEG playback follows the stream's SCR/PTS timing.
- Frontend, snapshots, Cartoon HD upscalers, sprite interpolation, portable data folder, update check and packaging (see above).
- Fixes: the extractor no longer relies on directory file numbers, run-length decoding is limited to CLUT7 and CLUT4, and the SC_Atten byte order is corrected.
All the details are in docs/CDI_NOTES.md (see "Additions from Lost Eden").
CD-i static recompilation template
This is a starting point for turning a Philips CD-i game into a native Windows program. The game's 68000 code is translated ahead of time into C. A runtime provides the parts of the CD-i the code expects: the CD-RTOS (OS-9) kernel, the CD file manager, the video decoder (with a Direct3D 11 presenter at any resolution) and the ADPCM audio processor.
It was extracted from the Link: The Faces of Evil project. That build is bit-identical to a pure-interpreter run of the same game, and this template reproduces it exactly.
Starting a new game
- Copy this folder to a new project folder.
- Put the disc image (
.bin+.cue, raw 2352-byte sectors) inrom/. - Edit
game.json: settitle,exe_name, and the modules to recompile (see below). - Run
build.bat. It extracts the program modules from the disc, recompiles them intogen/, builds with MSVC and copies<exe_name>.exeto the project root. - Run the game, and use the debugging workflow below for anything that breaks.
Requirements: Windows 10+, Visual Studio 2022 (C compiler), CMake 3.19+ and Python 3.8+. No third-party libraries are needed.
game.json
{
"title": "My CD-i Game",
"exe_name": "mygame",
"modules": [
{"file": "auto", "base": "0x100000", "extra_entries": [], "a5_table": "auto"},
{"file": "cdi_bumper", "base": "0xE0000", "a5_table": "auto"}
]
}
- The first module is the program the player boots.
"auto"reads its name from the disc label's application identifier (extracted/_app.txt). - Other modules are programs the game loads at run time with F$Load or
F$Fork, for example the Philips logo "bumper". Each one is recompiled for its
baseaddress, and the runtime places it there. Ranges must not overlap and must stay below0x140000, where the heap starts. Program modules the game loads that are not listed still run, slowly, in the built-in interpreter. extra_entriesare code addresses the analyzer can't discover, as absolute hex values (base + offset). The analyzer already finds:- call and branch targets;
- switch tables;
- MPW A5 jump tables;
- Microware
move.l #off,dN / jsr (pc,dN.l)calls; - F$Icpt handlers;
lea/peafunction pointers that start withlinkormovem.
a5_table:"auto"detects programs built with Apple MPW-style toolchains, whose calls go throughjsr N(a5).
To see what the analyzer found, run python tools/analyze.py [module index].
It writes a disassembly with recovered function names, from MacsBug symbols if
present, to build/listing_<module>.asm.
Layout
| Path | Contents |
|---|---|
tools/cdi_extract.py | Green Book filesystem reader. Writes program files and _app.txt (--all also dumps the real-time streams). |
tools/m68k.py | MC68000 decoder |
tools/os9mod.py | OS-9 module header, idata and irefs |
tools/analyze.py | Code discovery (recursive descent plus the patterns above) |
tools/gen.py | 68000→C generator, flag liveness, dispatch tables, gen/game_config.h |
tools/config.py | game.json loader |
tools/gen_tests.py | Per-instruction differential tests |
tools/bmp2png.py | Converts frame dumps to PNG |
runtime/cpu.c | Dispatcher and run loop |
runtime/interp.c | 68000 interpreter, for RAM code and the --interp reference mode |
runtime/alu.c | Shifts, division and BCD with exact flags |
runtime/os9.c | OS-9 kernel: memory, processes (fork/wait/exit), signals, alarms, paths, NVRAM, CSD |
runtime/cdfm.c | CD file manager: reads, and real-time SS_Play with PCB/PCL/CIL |
runtime/video.c | UCM display control (FCT/LCT), MCD212-style renderer, cursor, pointer |
runtime/audio.c | ADPCM levels A/B/C, sound maps with gapless SM_Out, attenuation |
runtime/render_d3d11.c | GPU presenter: aspect modes and sharp/smooth/CRT filters |
runtime/host_win32.c | Window, input (keyboard and XInput), waveOut, pacing, scripted and fuzz input |
test/ | Instruction differential tester and ALU reference vectors |
docs/CDI_NOTES.md | CD-i facts and API codes worked out during the first port |
Debugging workflow
-
Find what fails. Unimplemented OS calls and SetStat/GetStat codes are logged to
saves/recomp.log. Fatal errors also show a 68k register dump and a stack backtrace with function names. -
Debug options:
--trace/--trace3log syscalls with callers, signals and disc activity.--headless --frames N --dump Kruns fast without a window and writes every Kth frame as a BMP.--script "field:key:dur,..."scripts input (keys1 2 L R U D).--fuzz SEEDdrives the game with random input.--wav out.wavrecords the audio.
-
Check the translation. Run the same headless session twice, once with
--interp, which executes everything in the interpreter, and compare the frame dumps and WAVs.--interp-range LO-HI(hex) interprets only the recompiled functions entered in that range: bisect with it to find the function that is translated wrongly. Headless runs are deterministic: emulated time is counted in instructions, and the clock uses a fixed epoch. Any difference points to a translation bug. -
Unit-level checks.
python tools/gen_tests.pyandpython test/gen_alu_vectors.pygenerate test sources. Then build theinsn_testandalu_testtargets:cmake --build build\cmake --config Release --target insn_test alu_test build\cmake\Release\insn_test.exe rom\<image>.bin 200 build\cmake\Release\alu_test.exe -
Code that jumps into RAM is not an error. It runs in the interpreter. Jumps to undiscovered addresses inside a recompiled module are fatal. Add those addresses to
extra_entries, or teachanalyze.pythe pattern.
Things a new game may need
- More CD-RTOS calls. The runtime implements what the first game used. See
docs/CDI_NOTES.mdfor what's known and what isn't. The CD-i Full Functional Specification (Green Book, May 1994) documents the calls but gives no numeric function codes. Infer those from the game's library wrappers: look at thed2values passed withos9 I$SetStt. - UCM drawing functions (DM_/DP_/DR_/RG_ and text). These aren't implemented yet because the first game drew everything itself.
- PAL games. Set
"video": "pal"ingame.json. This selects a 625-line CSD, 280 lines and 50 Hz. - Full Motion Video (Digital Video Cartridge) is supported for what Lost
Eden uses. See
runtime/mpeg.cand docs/CDI_NOTES.md.