Repository navigation
Home
Moved from the repo's
docs/process/on 2026-09-25. Open work is in the issues; the dense technical reference stays in the repo's PORTING_PLAN.md.
This folder is a walkthrough of the method, not a reference of the results. It exists so you (the project owner, not just an AI agent picking up context) can follow how each file format got cracked and, eventually, do the next one yourself.
The results — the actual current ground truth about every format, every open question,
every architectural decision — live in docs/PORTING_PLAN.md. That
document is optimized for an AI agent resuming work with no memory of this conversation:
dense, exhaustive, organized by topic. These documents are optimized for a human reading
them in order for the first time: narrative, worked examples, real commands you can re-run.
For a diagram of how the pieces fit together (the offline pipeline, the runtime's modules),
see docs/ARCHITECTURE.md.
Never commit extracted game assets or decompiled code to this repository. Every
converter writes its output to /build/, which is gitignored. Every Ghidra project lives
outside this repo entirely (C:\Users\Alex\Documents\code\tools\ghidra_projects\), because
a Ghidra project file is a disassembled/decompiled copy of the copyrighted binary. What's
committed here is original analysis and original code: which byte means what, and the
converter that acts on that knowledge — never the game's own bytes or code. See
docs/PORTING_PLAN.md section 0 for the full legal rationale.
This is also why the images in docs/process/images/ are either original schematic
diagrams (redrawn to illustrate a finding, not real cel pixels) or, where noted, a
synthetic debug visualization whose colours are procedurally assigned by numeric ID
(tools/convert_rfm.py's render_debug_png()) rather than sampled from the game's own
art — never a crop of real extracted sprite art, even a small one.
| What | Where |
|---|---|
| The plan / current ground truth | docs/PORTING_PLAN.md |
| This walkthrough | docs/process/ |
| Converters (Python, no dependencies) | tools/*.py |
| Ghidra scripts (Java, compiled on the fly) | tools/ghidra_scripts/ |
| Dumped lookup tables from the binary | tools/data/ |
| Your own copy of the game |
C:\Users\Alex\Documents\returnfire (not in this repo) |
| Ghidra + JDK + the analysis project |
C:\Users\Alex\Documents\code\tools\ (not in this repo) |
| Converter output |
build/ (gitignored, regenerate any time) |
Two importers build the same pack (tools/tests/importer_parity_check.gd checks that): the Python pipeline
tools/import_original.py, used for RE work, and the in-game GDScript importer importer/rf_importer.gd, which is the
one players run on first launch. Both write into <pack>.partial and swap it into place only when every step has
worked:
Mermaid source
flowchart TB
SRC[("the player's own copy<br/>install folder, or the CD's .iso")] --> CAR & RFM & SDT
CAR["ART/ART.CAR: sprites<br/>convert_car.py<br/>RFCarDecoder"]
RFM["WORLDS/*.RFM: levels<br/>convert_rfm.py<br/>RFRfmDecoder"]
SDT["SOUND/*.SDT: sounds<br/>convert_sdt.py<br/>(plain WAV, copied)"]
DATA[("tools/data/*.json<br/>tables traced and dumped<br/>from RFIRE.BIN")] --> BUILD
CAR & RFM & SDT --> BUILD["assemble the pack<br/>build_pack.py / RFPackBuilder"]
BUILD --> EXTRA["the extras from ART/ and TITLE/<br/>HUD strips, compass lamps, victory banners,<br/>level previews, level list marks"]
EXTRA --> MUS{"a CD image?"}
MUS -- yes --> MUSIC["music and victory jingles<br/>extract_music.py, extract_win_jingles.py"]
MUS -- "no: a warning" --> VAL
MUSIC --> VAL["validate the pack<br/>validate_pack.py"]
VAL --> OUT(["swap the .partial pack into place<br/>packs/original_pc, or user://packs/original_pc"])
-
Setting up the toolchain — what's installed, where, and why it has to run headless (no GUI automation available to an AI agent).
-
Easy formats first —
.SDTand.RFA, cracked with nothing but a hex viewer and knowledge of two standard file formats. No disassembler needed. Start here to build intuition before reaching for Ghidra. -
The Ghidra workflow — the general recipe for cracking a format that isn't just a renamed standard one: anchor on a string or API call, decompile outward from it, form a hypothesis, verify against every real file.
-
Worked example: the
.RFMmap format — the recipe from step 3, run in full, on a real format, with real commands and real output. This is the one to read closely. -
Worked example:
ART.CARand a wrong turn — the same recipe, except the first hypothesis was wrong, it got shipped as a "best effort" converter anyway, and that was a mistake — here's how it got caught and fixed. -
Verification philosophy — the handful of hard-won rules that came out of documents 4 and 5, distilled so you don't have to relearn them the expensive way.
Keep
TRACING_CHEATSHEET.mdopen while reading the game-logic documents (45 onward): the object/field maps, how to read the assembly, and which script answers which question.Before continuing to document 8, check
NEXT_STEPS.md. It's deliberately not numbered into this sequence — everything above and below it is a frozen snapshot of how one specific question got answered, butNEXT_STEPS.mdis the opposite: it's edited in place every time the backlog changes, so it always reflects the current open-questions state rather than the state as of whenever it was written. Read the numbered docs below for the story of how each item got solved; readNEXT_STEPS.mdfor what's actually left right now. -
Worked example: mapping
.RFMart ids toART.CARcels — the backlog's top item, solved: the recipe applied a third time, this time chaining two data-structure traces straight to an exact answer with no guessing needed. -
Worked example: the exact tint colour of
ART.CAR's effect masks — document 5's own loose end, solved: reading a fallback-generation algorithm in full, catching a real refinement by checking mask bytes against real data instead of trusting the code alone, and discovering one of the 93 "masks" wasn't a mask at all. -
Worked example: what the
>>1computation actually does — a deliberately small one: twoFindDataXrefs.javacalls, no dead ends, and a stale guess corrected along the way — plus a postscript chasing the obvious next hop into a real, honestly-recorded dead end. -
Worked example: confirming a dead end fast by rereading work already on hand — the smallest one here: zero new Ghidra calls, just rereading a decompile log this project had already produced for a different question.
-
Worked example: decoding the
.RFMheader body with no Ghidra at all — a pure byte-variance correlation across all 204 real files finds a timestamp pair and the actual level designers' names, still sitting in the shipped data. No disassembler needed, by design this time rather than luck. -
Worked example: catching a wrong guess by finally rendering it — document 9's "team-colour swatch" guess, retracted: the 4 cels turn out to be a target-lock reticle. A disproof that cost one crop of already-generated converter output, not a new investigation.
-
Worked example: is the music CD audio or a WAV file? (Both.) — tracing every caller of
mciSendCommandAfinds a CD-audio path and a WAV-streaming fallback sharing one per-track table, and along the way disproves the obvious guess about which WAV file (it's notDRUMS.WAV). -
Worked example: the native resolution, and a tick rate that resists being found — one backlog item that resolves cleanly (320x240) and a paired one that traces all the way to the real per-frame dispatch chain without landing a confirmed number, recorded honestly as a bounded, not-yet-finished trail rather than forced into a tidy answer. Its postscript then takes that trail's own next hop and rules it out as the wrong system entirely (the boot-time title slideshow).
-
Worked example: there's no sprite pivot, because it's not 2D — the biggest architecture finding yet: vehicles are rendered via real perspective-projected 3D quads (64 discrete headings, a shared 1/z table also used by the terrain blitter), not flat sprites rotated around a pivot. Reframes a data question into a real, now-informed rendering-architecture decision for Godot.
-
Worked example: reference discs arrive, and a stale guess gets corrected for free — no Ghidra this time: cataloguing a newly-supplied retail ISO and identifying a 3DO expansion-pack disc image quietly disproves a guess that had been sitting in the plan since section 1.2 (the "missing
.avicutscenes" are actually more streamed audio) and opens a genuinely new goal (3DO "Maps o' Death" extraction). -
Worked example: finding a COM vtable call with no symbol to search for — closes out document 15's tick-rate loose end:
Sleep()andSetTimerwere both ruled out by name, but the last candidate,IDirectDrawSurface::Flip, has no name to search for at all. A new script hunts vtable calls by slot offset instead, finds the game's one present routine, and shows there's no fixed tick — a blockingFlip()paces fullscreen play on vsync, and windowed play isn't paced by this mechanism at all. -
Worked example: classifying 2165 cels without a disassembler — a different kind of document: building the asset ID registry (section 2.4.1) isn't a reverse-engineering question, it's an authoring task. Covers the contact-sheet tooling, a scope trade-off made explicitly (coarse pass now, refine later) rather than assumed, two places a pixel-colour average beat eyeballing, and what just looking at every cel turned up: a new lead on team colouring and a possible rescue/infantry mechanic nobody had suspected before.
-
Worked example: a wrong palette that never looked wrong enough to notice — the game's first rendered screenshot looked plausible and was still wrong: a raw pixel byte needs a
-10shift into the shared PLUT before it matches the game's real, active palette, traced through a fade routine that's the only caller ofSetPaletteanywhere in the binary. Caught only because the user compared it against real screenshots — internal consistency checks (this project's usual habit) can't catch a bug that's wrong everywhere in the same plausible way. -
Worked example: "the sprite looks very wrong after moving" was two bugs, not one — Phase 4 steps 2/3 (a player-controlled vehicle, a scrolling camera): a real mirror-flip bug in the vehicle's rotation rendering, and how tracing it surfaced a second, unrelated bug — an asset-registry auto-numbering script quietly undoing an already-confirmed team-colour rename every time it ran.
-
Worked example: reusing a solved RE finding as running code — Phase 4 steps 4/5 (weapons/projectiles, destructible targets): step 4 is an honestly- flagged placeholder, but step 5 turns a mechanism section 1.5 already fully traced from the binary directly into running Godot code — and shows what verification looks like when the real answer is already known and the only question is whether the reimplementation is actually correct (a 2000-trial unit test plus a real-scene integration test, not a screenshot).
-
Worked example: an opponent with no reverse-engineering behind it at all — Phase 4 step 6 (enemy AI): unlike every other Phase 4 step so far, this one reimplements nothing from
RFIRE.BIN— Phase 3's AI backlog is still untouched. Covers splittingVehicle's movement/firing code into two overridable decision seams instead of copy- pasting a second vehicle script, and a rate-dependent behaviour test that had to stop relying on headless mode's real (unthrottled) frame timing and drive_process()directly at a fixed timestep instead. -
Worked example: a debug string, a dedicated object, and a capture-the-flag lead — the first anchor in this project that started from user domain knowledge instead of a byte pattern. A hidden developer debug menu still shipped in
RFIRE.BIN("Flag in first building: %s"), traced straight into the exact function this project already reimplemented asTargetPool(document 22) and a uniquely-single-call-site object with homing movement — a strong, multi-source lead on the win condition, honestly not yet a closed case. Also catches a real asset-registry mislabel (4 flag frames filed as an unrelated terrain decoration) found only by re-rendering a cel range everyone had skimmed past once already. -
Worked example: a user's screen recording, tracked frame-by-frame, finds a real registry bug — the first anchor that starts from a video instead of a byte pattern or an art range. A small ffmpeg + colour-tracking pipeline turns a 16-second recording into per-frame crops, confirming the "sprite breaks apart while turning" report is real, not a compression artifact — and comparing the raw source cels pixel-by-pixel finds the actual cause: the tan rotation set was missing a 9th frame that green already had, misfiled as debris by the original bulk pass. Fixed with a registry correction and no code change; verified with a headless heading-to-frame dump instead of another video.
-
Worked example: reading a branch to the end instead of its summary — document 24's flag lead, closed one step further: exhaustively re-checking cross-references finds the flag-state value has no write site anywhere except a hidden debug menu, so it's always 0 in real play — and reading the destruction handler's full branch logic under that condition (not just its earlier summary) pins down the exact trigger: a pool's flag object spawns precisely when its targets are fully exhausted, exactly what
TargetPool. destroy_active()already returnsfalsefor. Made real with a newFlagMarkernode and the confirmed flag art, verified by a real-scene integration test. -
Worked example: a screenshot catches a gap between a finding and what got built — no new anchor this time, just rereading a decompile this project already had the address for. Document 16's own "terrain and objects share one perspective system" note turns out to mean the terrain blitter runs a genuine per-scanline perspective projection (Mode 7-style, receding toward a horizon), not a flat top-down grid — and Phase 4 step 1 was built flat anyway because the two findings never got connected. Reframes an accepted-plan bullet into a real, still-open architecture decision instead of fixing anything outright.
-
Worked example: the fix that made the camera work was lighting, not rotation — Phase 0 (closing the last RE unknowns) confirms the camera's tilt is exactly 45 degrees, algebraically, hardcoded once and never rewritten anywhere in the binary. Phase 1 builds the first real 3D scaffold and hits two wrong guesses in a row before the actual bug: a black screenshot blamed on a rotation-sign guess turned out to be a missing light, and the look_at()-based fix that came from that wrong guess turned out to introduce exactly the hidden camera rotation the user had just said shouldn't exist.
-
Worked example: the real terrain art, seen through a real 3D camera, on the first try — Phase 2 extracts terrain_view.gd's tile-drawing loop into its own reusable node (no duplicated logic to drift out of sync) and bakes it into a SubViewport texture on the new 3D scene's ground plane. Real terrain art, genuinely perspective-projected, matching the flat 2D scene's own screenshot exactly -- and, unusually for this project, worked on the first real screenshot.
-
Worked example: the same frame-selection code, a different last step — Phase 3 renders a real, completely unmodified Vehicle as a billboard Sprite3D instead of a placeholder box, calling Vehicle._frame_for_heading() -- the exact quadrant-mirror logic document 25 fixed a real bug in -- directly, with Vehicle's own 2D draw output just suppressed rather than duplicated into a second implementation. A 12-heading sweep confirms that fix still holds through the new rendering path.
-
Worked example: chasing a rotation-mirroring bug found a whole vehicle roster — a precise diagnosis of the "same sprite, no matter what" heading bug (turning 180 degrees renders pixel-identical, since flipping a symmetric base frame changes nothing) led back into the long-abandoned real-facing-table trace, which surfaced a genuine string table naming the game's actual vehicle roster: Tank, Jeep, MSV, and Helicopter -- not the one "hovercraft" this project had built against the whole time. A geometric search for a helicopter's distinctive rotor-blade silhouette found a real mini-map icon set confirming all four, though their actual in-game rotation art is still unlocated.
-
Worked example: one image, rotated correctly, beats nine images flipped — tests whether the "90/270 degree frames look like little triangles" complaint is a rendering-technique gap rather than missing art, by prototyping a real, non-billboarded, ground-plane-aligned quad that rotates in true 3D to match the vehicle's heading. One canonical texture, correctly rotated, produces a smoother, always-coherent silhouette at every heading than the old nine-frame mirror-and-flip approach ever did.
-
Worked example: finishing the rendering migration means extracting the game, not just the picture — Phase 4 (projectiles, target/pool markers, the flag marker), the rendering-migration plan's last phase. Required extracting terrain_view.gd's gameplay logic (spawning, hit-testing, the flag-spawn trigger) into a new shared MatchController first, so the flat 2D and 3D scenes provably run identical rules instead of two hand-copied implementations. Projectiles and the flag reuse Phase 3's real-node-paired-with-a-billboard pattern; the debug spawn/pool markers, which had no dedicated gameplay node to pair with, get Phase 2's baked-SubViewport treatment instead. A driven screenshot confirms all three working together in the 3D scene, foreshortened correctly by the same tilted camera as the terrain.
-
Worked example: trees can't be tile art, and neither can vehicles — the same 7-bit mask proves it — chasing a user observation that reference footage shows real, camera-aware trees (not flat paint) found that no level actually places any tree art at all -- the one registry entry named "decoration.tree" was a misclassification (a small bunker structure, corrected). Real tree art exists in ART.CAR but is never referenced by any level's tile grid, because the terrain blitter masks every tile's art id to 7 bits (
& 0x7F, already known from section 1.5/1.7) and the real tree cels are numbered above that ceiling -- the same structural reason vehicles need the separate per-object 3D projection path section 1.10 found. Where tree placements are actually recorded is still unknown. -
Worked example: the coastline-blend id is also the decoration-spawn id — finds the mechanism document 34 left open. Decompiling the level loader's coastal-blend helper in full shows it writes the coastal id into a second, previously-undecoded field of the tile's runtime word; the terrain blitter reads it back and, when nonzero, passes the coastal table's own pointer field -- long dumped, but only ever read as a boolean flag -- into the same depth-sorted per-object render queue vehicles use. One id, two jobs: pick a blended ground texture, and optionally queue a real decoration object. Following that descriptor's own callbacks (real code Ghidra had never disassembled) all the way through confirms decorations use the identical CCB cel-index-plus-quad-corner rendering vehicles do -- one object renderer for the whole game, not two. A new script then walked all 91 coastal ids mechanically: 82 resolved to real, registry-verified decoration definitions (saved to
tools/data/coastal_decorations.json), spot-checked and found universally coherent -- bushes, saplings, flowers, coral, dock frame-posts. Only 3 ids remain unresolved. -
Worked example: putting the decoration catalogue on screen — wires document 35's real decoration catalogue into the converter and both rendering scenes.
tools/convert_rfm.pyrecords every tile's coastal id;tools/build_pack.pyresolves it into real sprite ids through the same registry lookup terrain tiles already use. Rendered by extendinggame/terrain_tile_renderer.gd's existing one-shot draw rather than adding a new per-object node type -- a decoration never moves after level load, so baking it alongside the terrain gives the same real perspective projection a live node would, far more cheaply. A real screenshot shows dense, individually readable coastline foliage where every earlier screenshot this session showed one flat, mottled texture. Addendum: the palm-frond cels turned out to have no trunk pixels of their own -- a real, matching trunk cel sat completely unused in the registry, now drawn under any decoration built entirely from a small, hand-verified set of frond cels. -
Worked example: the Tank was never a flat sprite — chasing a user-reported "no visible tank tread" observation all the way through found that
vehicle.hovercraft.rotation.tan.01-09, this project's Tank art since Phase 4 step 2, was never the game's real Tank at all. Traces a real cross-reference chase (spawn-position table -> per-team spawn function -> a 4-entry vehicle-type table whose entry 0 name string reads literally "Tank") down to the real Tank's own per-vehicle-type data: a genuine six-face 3D box built from real local 3D corner coordinates, including the tank-tread graphic this project had sitting completely unused the whole time. Also fixes a real front-facing/movement-direction mismatch found along the way.game/vehicle_box_3d.gdreplaces the old flat-card approach as the default vehicle presentation. -
Worked example: the Tank has 14 real parts, not 8 -- and a general classification audit — document 37's own "8 parts, not 6" addendum was itself an undercount; re-deriving the real boundary generally (not eyeballed) finds 14 -- reduced back to document 37's original 6 by document 39, which found the other 8 were never hull parts at all. Also builds a reusable registry-vs-real-code audit (
tools/registry/audit_code_referenced_cels.py), extracts Jeep/MSV/Heli's real geometry for the first time, and fixes 33 flatly wrong registry classifications it found this way. -
Worked example: the turret and gun barrel are a real, separate object — decompiling the real vehicle draw dispatcher (
FUN_00402dc0, one level up from the generic per-descriptor renderer document 38 had already decompiled) found it draws the hull once, then swaps in a wholly different descriptor and draws again with an independently composed rotation -- a genuine, separate turret+barrel object, sitting in memory immediately after the hull's own data (which is exactly why document 38's boundary detection walked into it and misread it as 8 more hull parts, resolved against the wrong corner array). The turret is now found, extracted, and rendered, matching the user's reference screenshots directly. One part (the muzzle ring) still renders at the wrong size/position -- checked three ways and confirmed genuinely unresolved, not guessed at further. -
Worked example: the muzzle ring's corners are never static in the first place — the "unrelated small 7-corner linkage computation" document 39 skipped over turns out to be a previously-untraced, always-executing block of code that overwrites exactly the far barrel-tip + muzzle-ring corner cluster every frame, from a small local "base" shape plus one constant offset (found by catching that a helper function's offset-pointer argument is never advanced in its own loop — an easy misread of the decompile at first). The values this project had read as static geometry for that cluster were never what a running game actually shows. Confirmed the ring itself is a plain painted asset with no fire-triggered visibility or texture change. Recomputing the affected corners the correct way and rendering the result fixes the bug, confirmed by screenshot across all 8 discrete headings.
-
Worked example: decorations are real 3D entities, not paint on the ground — document 36's choice to bake decorations flush into the ground texture (reasoned to be "as correct as a live Node3D" since a real Camera3D projects it either way) turns out to be wrong for anything with real height: flat-with-the-dirt content can never look like it stands up, no matter how correct the projection math is. Direct atlas inspection found the two cel families involved are drawn from genuinely different implied angles (canopy from above, trunk from the side) -- confirming which one needed to lie flat and which needed to stand. New
game/decoration_field_3d.gdgives every decoration real Node3D presence, elevating canopy-only ones on a real vertical trunk and keeping ground-hugging decorations at ground level, all still using document 36's own composition rule, just rendered as real geometry instead of baked texture. -
Worked example: a symmetric hull hid a 180-degree facing bug for four documents — the box hull's yaw-correction constant has been 180 degrees wrong since document 37, but the hull is fully symmetric front-to-back, so no screenshot comparison of it alone could ever have caught a full 180-degree error. The turret (document 39) is the vehicle's first directional feature, and a real driven-forward test showed it faithfully rendering that pre-existing error for the first time anyone could see it: the barrel pointed exactly opposite the vehicle's own confirmed direction of travel. One constant fix, reverified the same way. Also answers a real design question the same report raised: yes, the original does aim the turret independently of the hull's own heading -- this project doesn't model that yet, a documented simplification, not touched by this fix.
-
worked example the green turret the ground hitch and what a level asks
-
worked example the buildings stages checked against the code
-
worked example terrain passability and the jeeps road following
-
worked example the original screen layout and the classic hud
-
worked example the victory jingles and what follows the ribbon
-
worked example the Jeep's wheels in the footage and the depth tie
-
worked example the panel in the footage: the fuel can, the bar colours and the compass lamp
-
worked example the render descriptor: the Tank (and every moving part) as data
-
worked example per-map vehicle rosters and level.override.json
-
worked example standalone projects with no base content at all
-
worked example the game flow and the win screen that never appeared
-
worked example the original's computer opponents: what exists, and what does not
-
worked example the sound mixer and where every sound comes from
-
worked example the wreck, its fall, and the Heli's hit reaction
-
worked example the wading splash, the sinking vehicle and the ripple
-
worked example the panel's slide-in and the hangar in the classic picture
-
worked example how the original unlocked and recorded levels
-
worked example two header fields a shift table and the tanks sinking pictures
-
worked example two-player endings, the skull's icons and the per-player block
-
worked example the controls, keys, joysticks and the Config program
-
computer players 1: what a computer player is and how it plugs in
-
computer players 12: why five-minute games end without a winner
-
design: a deterministic, fixed-point simulation (the netplay prerequisite)
-
deterministic sim 10: damage, fuel and ammunition in 16.16 (S5.4)
-
deterministic sim 11: mines, gates, the flag and the edge guard in 16.16 (S5.5a)
-
deterministic sim 16: the vehicle's height and water in 16.16 (S6.1)
-
deterministic sim 17: the Heli's take-off and automatic landing in 16.16 (S6.2)
-
deterministic sim 18: the weapons, gun mount and cooldowns in 16.16 (S6.3)
-
deterministic sim 19: the explosion damage boxes in 16.16 (S6.4a)
-
deterministic sim 20: the Jeep's road assist in 16.16 (S6.4b)
-
deterministic sim 21: the dock test and the rest of the match controller in 16.16 (S6.4c)
-
deterministic sim 22: the view code fenced off, the float lint at zero (S6.4d)
-
deterministic sim 23: the determinism check in CI, on Linux, Windows and the web (S6.5)
-
mod tool 2: the S7 plan, a toolset to make a whole game by hand
-
mod tool 10: the netplay test game, openfire-nettest (S7.8 design)
-
mod tool 15: proving the build holds no original asset (S7.8, #141)
-
mod tool 16: the game's recorded match on Linux, Windows and the web (S7.8, #142)
-
netplay 1: the plan, rollback on the deterministic sim (Phase 5, #43)
-
netplay 2: save and restore of the match; the tile collapse moves into the sim (N1, #149)
Return Fire, rebuilt
Elsewhere