It Came from the Desert — Amiga recompilation
It Came from the Desert — Amiga recompilation is a native PC port of It Came from the Desert for Windows and MS-DOS.
- Type: PC port
- Game: It Came from the Desert
- Runs on Windows
- By Tim Rachor
- Latest release RecompLauncher, 2026-11-20
- Source: https://github.com/Santorayo3/icftd-recomp
README
It Came from the Desert — Amiga recompilation
Statically recompiling the 1989 Cinemaware game "It Came from the Desert" from its three original
Amiga floppy images: the original dshell binary (750 functions, 137 KB of 68000 code) is
translated to C and runs against a portable runtime we write. Targets: Windows (32-bit PE, Open
Watcom) and MS-DOS (VGA mode 13h, DOS/32A; being brought to full parity with the Windows
build — see docs\dos-parity.md).
No game data is in this repository. The disk images are copyrighted, and so is everything
decoded from them (assets/, export/, re/, ref/); .gitignore keeps all of it out of git.
You supply the images; the tools decode them locally.
RULE 0 — a bug is a DIFFERENCE, never a symptom
Every fix is a diff against the original — for bugs of any kind: picture, sound, crash, hang, wrong
value, wrong speed, ignored input. Find the path the original takes, find the same path in our code,
close the gap. A change that only makes the symptom go away is rejected, even when all tests pass;
and a real fix never stays behind an opt-in flag. The one exception is code the original does not
have — save slots, OSD, the present/window backend, host input, our tooling. Full text:
.github/copilot-instructions.md and the top of
docs/recomp-architecture.md; what a feature on that side has to show
instead is docs/port-features.md.
The two phases
| phase | what it is | state |
|---|---|---|
| A — run the original | The real dshell image executing on the vendored Musashi 68000 core plus our own Amiga OS shims. This is the oracle (src\oracle + src\runtime): it is how we learn what the program actually does, and where the fixtures come from. A tool — the shipped game links no 68000 core. | Done, frozen. Boots, plays the intro, runs the game loop: 30M instructions reach frame 5823 with a raster presented every frame, 0 dropped blit writes. OS surface measured every run: 49 library calls used, 45 kinds implemented, 4 answered with 0 (OpenDiskFont, three IEEE single-precision ops). |
| B — the product | Static translation of the 750 functions into src\recomp\fn_<addr>.c + fn_table.c against a cpu_t context, jsr (d16,A6) → os_call(), computed jumps → table lookup with interpreter fallback. | Done. recomp emits all 750 functions (121 362 of 121 362 bytes) plus all 51 blocks of code the model does not cover; nothing is left for the interpreter, and the report has no refused entry. The differential is green: 263 of 263 fixtures verified, 0 skipped, 0 failed. |
How correctness is decided
Parity is machine state, never images:
D0-D7, A0-A7, SR, PC + custom-chip register file + hash of the full RAM image
compared at frame boundaries, driven by a frame-indexed input script.
- Function level: a translated function must equal the interpreter on the same fixture — all registers and the memory it touched — for pinned fixtures and seeded random ones.
- Whole program: the interpreted build and the translated build, given the same input script, must produce the same state hash at every frame boundary.
- OS surface: the call census must show no library call answered with
0.
Validation scales with the change, not with the table: tools\gate.ps1 runs the translation core
(builds + the two fixture layers), -Full adds the port's own scene checks, and -Only <step> runs
one of them. A change owes the measurement that covers it, not a whole-gate run.
Frames, screenshots, WinUAE captures and image matching are retired. They cannot cover a whole game, and pixel-watching is the trial-and-error this project already paid for. If the machine state matches, the visuals follow by construction; the only model left is planar→chunky + palette, which is a pure function of RAM and is verified once with synthetic bitmaps.
The game never has to be played to be verified: coverage is measured with executed-function and basic-block counters, and scenes are reached by calling the engine's own entry points (the MovE label table), not by earning them.
Quick start
# 1. copy the three Amiga disk images into disks\ (see disks\README.md)
# 2. extract the filesystems and decompile
powershell -ExecutionPolicy Bypass -File tools\extract.ps1
powershell -ExecutionPolicy Bypass -File tools\ghidra\run-ghidra.ps1
# 3. gate: exporter build + oracle build + the two fixture layers (the translation core)
powershell -ExecutionPolicy Bypass -File tools\gate.ps1
# -Full adds the port's own checks (presenter, title menu, settings, quit notice, pointer,
# crosshair, aim, border, loading line, the Ctrl+W minigame cheat, the Ctrl+T clock freeze, the
# hospital escape's camera, the WASD aliases, the art tables), -Only <step> runs one of them while working on that surface
Running the original (Phase A)
tools\build-oracle.ps1
bin\win32\icftd-oracle.exe export\code\dshell4k\dshell.img 0x4000 --run
# space or left mouse = fire, esc or close = quit; runs at the Amiga's 50 Hz
# batch / scripted runs - always bounded, so a stuck model cannot hang the terminal
powershell -ExecutionPolicy Bypass -File tools\oracle-run.ps1 -Insns 30000000 -Progress
Flags worth knowing: --progress (counters every million steps), --lvo (library-call census),
--press <frame> / --release <frame> (scripted fire), --doslog, --dfflog, --watch <pc>,
--dump <prefix> [n] (BMP per presented raster), --state <prefix> [--every n] [--ram <frames>]
(canonical machine-state dump per frame boundary) and --input <script> (frame-indexed input:
<frame> <fire> <joy0> [<joy1>]). tools\state-diff.ps1 -A -B compares two dumps.
The translated build takes the same measurement flags, plus --cover <file>: one line per function
that ran (<entry> <calls>, and <pc> <instructions> for code the core executed), which is how
"what never ran" is a list instead of a guess (docs\implementation-survey.md).
The Windows release
A release is the executable plus three empty folders — no game data is distributed:
It Came from the Desert.exe the translated game
export\ empty: filled on the first start
disks\ empty: the player's three original Amiga floppy images go here
saves\ empty: the ten save slots
The executable's icon and version page (It Came from the Desert, Copyright © 2026 Tim Rachor)
are compiled into it from src\runtime\plat\win32\icftd.rc; the icon is the port's own
assets\app_icon.png, resampled to a multi-size .ico by tools\mkappicon.ps1, and the game's
window carries it too — the title bar and Alt+Tab show the game's picture, not a generic icon.
powershell -ExecutionPolicy Bypass -File tools\win32-pack.ps1
# -> bin\win32\game (what a release is)
# -> bin\win32\icftd-win32.zip
Double-clicking It Came from the Desert.exe plays the game: the console window the executable is
given is hidden, so only the game's own window is seen. Started from a terminal (or by one of the
check scripts, which read its log through a redirected handle) the console is left alone — the log
belongs to whoever started the run. A run that ends by itself leaves nothing beside the executable;
a run that did not — a crash, a hang, a process killed from outside — leaves game-log.txt there
with the last frame's machine state, and the unhandled exception appends its code and address.
On the first start
src\runtime\assets.c extracts the files the engine asks for from the player's own disk images in
disks\ and writes them to
export\ (disk1..3 plus code\dshell4k\dshell.img, the game program flattened at 0x4000), then
boots; later starts read export\ and never look at disks\ again. Without the three images it
shows one line and stops:
Please put the three original 'It Came from the Desert' disk images in the 'disks' folder and restart.
Which images it accepts. Any raw image of the three floppies — disks\ is read file by file, so
the names and extensions there are the player's business; each file is tried as an AmigaDOS
floppy. What has to match is the filesystem: a raw, uncompressed sector image of a double-density
disk (901 120 bytes, the .adf a dumper writes), formatted with the original OFS filesystem,
carrying the volume labels Desert1, Desert2 and Desert3. A second image with the same label is
ignored (the first by file name is used). Copy-protection schemes do not matter, because the data is
read through the filesystem rather than the floppy's tracks; compressed or flux-level containers
(.adz, .dms, .ipf, .scp, .hfe) have to be converted to a plain .adf first, and
FFS-formatted or high-density images are refused. A different revision of the game is not
supported: the extractor only checks the structure, but the recompiled program is bound to this
exact dshell at its load address, so another build would neither run nor say so cleanly.
The extraction is the exporter's formats in C (src\assetExport\Adf.cs/AmigaFs.cs/Hunk.cs
ported), and it lands on the same bytes tools\extract.ps1 writes — that identity, not a
screenshot, is what the feature is checked against (docs\port-features.md, "The first start").
Controls. The stick is the keyboard: the arrow cluster, or W/A/S/D for the same four
directions. Space (or the left mouse button) fires, Esc restarts the game, F1–F4 pick a save slot
and F5 steps to the next one, and the title screen's 1–7 and W/C/T start its scenes.
The title's own menu is clicked with the pointer: New Game, Load Game (the ten save slots), Settings
(the fullscreen toggle, the two volume rows and the language row, which all take effect at once and
are written back to icftd.ini) and Quit Game, which shows a ten-second notice naming the successor
on a black screen before the application closes. Alt+Enter is the shortcut for the same window
switch, on every screen the game has (the settings view's toggle shows it there and then), and it
writes [VIDEO] fullscreen back as well. The language row steps through the languages the game found
at start-up — English, the original's, then every complete lang\<code>.csv next to the executable,
shown by its two-letter name — and each step switches the interface and the game at once, so a
translation is added by dropping its file in, not by editing anything (en, the default, is the
original's English): see docs\port-features.md, "The language", and lang\README.md. The game's own
text — the menus, the messages, the port's screens and the story, what the rooms narrate and what the
people say on the telephone — is entirely in that file, whose English side the game writes itself on
the first start (from the data it just extracted, never shipped), and which tools\lang-export.ps1
writes in three steps for a development tree: the game's own text (lang\en.csv, not committed), the
translator's three-column working file, and the finished translation keyed by an id instead of by the
English — so the shipped file carries none of the original's script. Two cheats: left Ctrl+W ends a
minigame in that scene's own success state, and left Ctrl+T on the situation map freezes the game's
clock (Time frozen, then Time unfrozen again), holding it through every screen until the game is
restarted or a new game is started from the title.
The MS-DOS build
The same translated image, on MS-DOS: VGA mode 13h (320x200, one byte per pixel), the 8042 keyboard
polled for held keys, a 50 Hz clock from the 8254 timer, and the machine's own icftd.ini (without a
[VIDEO] fullscreen entry - a DOS program owns the display). 32-bit DOS needs an extender; the build
binds DOS/32A, which Open Watcom already ships, so nothing extra has to be downloaded.
Double-click play_dos.cmd. It stages the release on first use (build + package) and starts
DOSBox with the settings the game needs. Its clock defaults to cycles=30000, a 486DX2-66-class
machine - the hardware this port is aimed at - so what you see is the real target performance;
set ICFTD_CYCLES=max runs it at whatever the host can do. The individual steps, if you want them:
powershell -ExecutionPolicy Bypass -File tools\build-dos.ps1 # -> bin\dos\ICFTD.EXE
powershell -ExecutionPolicy Bypass -File tools\dos-pack.ps1 # -> bin\dos\game (empty release)
powershell -ExecutionPolicy Bypass -File tools\dos-run.ps1 # DOSBox, cycles=max, core=dynamic
bin\dos\game is the release as it ships: ICFTD.EXE, an empty DISKS\ (the player's three
original floppy images go there), an empty SAVES\ and ICFTD.CONF, a DOSBox config for it -
start it with dosbox -conf ICFTD.CONF. There is no game data in it: the game extracts the
player's own disks on its first start and shows
Please put the three original 'It Came from the Desert' disk images in the 'disks' folder and restart.
when they are not there, and while it reads them it says
Please wait... extracting resources from disk images. Those two lines are the only text the DOS
build writes to the screen - everything else goes to stdout, which a played run binds to NUL so
no diagnostic can draw into the mode 13h picture. What that first start writes is the tree the
engine runs from: DISK1..3
(the three filesystems, every file under a legal DOS 8.3 name), NAMES.TXT and DSHELL.IMG (the
game program flattened at 0x4000), plus ICFTD.INI. NAMES.TXT exists because the engine asks for
AmigaDOS names FAT cannot hold (fonts\newnem.font); the extractor renames those files to 8.3 and
the platform layer retries a failed open through that map. Save slots are directories next to the
executable (SAVES\SLOT1..4), holding the engine's ICFTD file, exactly as on Windows.
The mouse works on DOS. The platform layer reads the DOS driver through INT 33h, so the title
menu's buttons, the Load Game list and the Settings view are clicked with the pointer, and on the
situation map the game's own cursor follows it — pushed past the travel window the picture scrolls,
and the SAVE GAME mark holds the window still while the pointer is over it. The room screens' arrow,
the menu-line hover, the fight's crosshair and the two minigame aims are installed as well, and a
click on the map's SAVE GAME mark opens the same ten-slot picker Windows has. The engine's long
screen transitions say Loading while the game's own loader runs, as on Windows.
A first start extracts itself. play_dos.cmd hands the game the repository's disks\ folder
(--disks), so the first run in a freshly staged bin\dos\game fills it with the tree above and
boots. A release is the same thing with the player's own images dropped into DISKS\; with none
there the game prints the message and exits, and ICFTD.EXE --extract does the extraction on its
own. DSHELL.IMG is written last, so an interrupted extraction is simply redone, and the tree is
byte-identical to what tools\dos-pack.ps1 -Data <dir> stages from the development export\ tree
(tools\dos-extract-check.ps1 is the check).
DOSBox settings matter: core=dynamic (the JIT) is roughly ten times faster than core=normal,
and the cycle count is the emulated CPU: 30000 is about a 486DX2-66, 3000 a 386 (the stock
setting, on which the game crawls) and max whatever the host can do. Those are DOSBox's own
settings - they say nothing about real hardware, where the binary simply runs natively. What the
hardware sees is the work per frame: ~3.5 million x86 cycles currently, i.e. about 8 fps on a
486DX2-66 against the 50 fps target, so the DOS target still needs roughly a 6x reduction (the
vblank handler running on the 68000 interpreter is the first item). Measured cost, method and plan:
docs/next-session.md.
Layout
disks/*.adf the original floppies (not in git)
export/disk1..disk3 extracted filesystems
export/code dshell flattened for Ghidra (base 0) and for the runtime (base 0x4000)
re/ Ghidra project, decompiled C, disassembly, exported program model
ref/fixtures pinned 68000 harness fixtures (the oracle's test inputs)
src/assetExport ADF filesystem, banks, SMS/LZ codecs, hunk loader, AND the 68000
interpreter + the rcmp/rleaf differential harness
src/runtime the machine the game code runs on: memory, library shims, heap, exec
structures, blitter, planar display, platform (ships)
src/oracle the 68000 front end: executes the original binary so it can be measured
and mined for fixtures (dev tool, links Musashi)
src/recomp the translated functions (`fn_<addr>.c`), `fn_table.c`, `cpu_t`, the fixture replay
third_party/musashi MIT 68000 core
tools/ see below
docs/ architecture, plan, program model
Tools
| tool | purpose |
|---|---|
tools\gate.ps1 | the gate, tiered: by default the translation core (exporter build, oracle build, interpreter fixtures, translated vs interpreted); -Full adds the port's own checks (presenter, title menu, title settings, quit notice, map pointer, save picker, room pointer, crosshair, ant-head aim, border, loading line, pointer aim, minigame cheat, clock freeze, hospital camera, WASD keys, art tables), -Only <step> runs one |
tools\build-oracle.ps1 | build bin\win32\icftd-oracle.exe (runtime + Musashi front end) |
tools\oracle-run.ps1 | run the oracle with a hard timeout, log to out\ |
tools\state-diff.ps1 | first divergent frame between two --state dumps, and the RAM byte ranges |
tools\build-recomp.ps1 | build bin\win32\recomp-check.exe: runtime + src\recomp, no 68000 core |
tools\win32-pack.ps1 | stage the Windows release in bin\win32\game (It Came from the Desert.exe + empty export\, disks\, saves\) and zip it |
tools\mkappicon.ps1 | the executable's icon: assets\app_icon.png → bin\win32\res\icftd.ico (build output, linked in by tools\build-host.ps1) |
tools\build-dos.ps1 | build bin\dos\ICFTD.EXE: the game for MS-DOS (DOS/32A extender) |
tools\dos-pack.ps1 | stage the DOS release in bin\dos\game (ICFTD.EXE, empty DISKS\/SAVES\, ICFTD.CONF); -Data <dir> stages the extracted 8.3 tree the first start writes (the check's reference) |
tools\dos-run.ps1 | run the DOS build under DOSBox with a generated config |
tools\dos-extract-check.ps1 | the DOS first start: an empty release folder plus the floppy images extracts the tree dos-pack.ps1 -Data stages (8.3 paths, NAMES.TXT, DSHELL.IMG), a second start does nothing, an empty or incomplete disks\ is refused, and the run boots the same machine |
tools\recomp-fixtures.ps1 | translated vs interpreted, one fixture at a time (-Rand n for random fields) |
tools\musashi-gen.ps1 | generate Musashi's m68kops.c (git-ignored) |
tools\extract.ps1 | disk images → export\ |
tools\ghidra\run-ghidra.ps1 | decompile + export the program model (-ModelOnly, -Annotated) |
tools\harness-check.ps1 | re-run the pinned interpreter fixtures |
tools\fieldmap.ps1, structs.ps1, asmrange.ps1, banktable.ps1 | query the model / disassembly |
tools\analyse-os-calls.ps1, decompile-quality.ps1, global-heat.ps1 | model reporting |
tools\gamepack.ps1 | pack assets for the shipped runtime (the data seam) |
tools\dos-save-test.ps1 | build + run the save path (DSAVE: → saves\slot<N>\ICFTD and the add-on's ICFTD2) against rt_os_call, and the slot state the two files make |
tools\mkosdicon.ps1 | PNG → src\runtime\amiga\osd_icon.h, the table the on-screen display draws |