5.4 KiB
De-SWF: replacing the Iggy/Flash UI with PNG + RmlUi
Status
The closed-source Iggy Flash player (iggy_w64.dll) is fully replaced by an
open reimplementation, iggy-shim. The game links our iggy_shim_w64.lib
instead of RAD's; no Flash runtime and no .swf parsing remain in the
render path. UI art is loaded from the extracted PNGs; scene structure
from the layout manifests.
The full game flow works through the shim — verified by screenshots at each
stage: title attract → autosave dialog → main menu → Play Game → EULA (scroll +
accept) → Load/Create/Join → Create tab → Create New World → world options
(name / seed / mode / difficulty) → Create → world generates → in-game with
the HUD rendering. Every UI subsystem is exercised: PNG sprite rendering,
bitmap-font text, focus highlight, keyboard nav, button press, scene
transitions, dynamic FJ_List population, checkboxes, tab switch.
Two render paths exist behind the same shim:
| Path | State | Notes |
|---|---|---|
Display-tree renderer (ui_renderer + text_renderer + raw_d3d) |
working, default | Renders PNG quads + text through a raw D3D11 pipeline. The device is harvested from a GDraw texture handle (layout mirrored from the open gdraw_d3d1x source); shaders are compiled at runtime; text uses the game's own Mojangles bitmap glyphs uploaded as RGBA. GDraw still does texture uploads; we bind its SRVs. This is what drives the working flow above. |
RmlUi backend (rml_backend + rml_render) |
built + linked + wired; gated IGGY_SHIM_RML=1 |
RmlUi 6.2 (HTML/CSS game-UI library) + FreeType, both cross-compiled for the target, rendering through GDraw. A page-fault at Rml::Initialise under Wine remains to debug before it can be the default. |
Why a raw D3D11 pipeline instead of GDraw's DrawIndexedTriangles?
Draw calls issued through the game's GDraw vtable executed (non-zero batch
stats) but produced no visible pixels — a render-state black box that was not
worth reverse-engineering. Harvesting the ID3D11Device and drawing with a
tiny owned pipeline (the same save/set/draw/restore pattern the game's
PostProcesser uses for gamma) made the UI render immediately and is fully
under our control.
Known remaining polish
- Button/panel skin art: buttons render as text only; the
MainMenuButtonselection bar and 9-slice dialog panels aren't drawn yet (the skin-symbol → PNG resolution needs the 9-slice scale handling). - List-item font scale:
FJ_Listitems inherit the list node's bundle scale and render oversized; items need a fixed font size. - RmlUi
Rml::InitialiseWine page-fault (see below).
Architecture
The game talks to its UI through the Iggy C API (240 symbols) from ~100
unmodified UIScene/UIControl C++ classes: it creates a "player" per scene,
pushes state in every frame via IggyPlayerCallMethodRS (SetHealth, Init,
SetLabel, SetFocus, …), and receives button/focus events back through an
ExternalInterface-style callback (handlePress, handleFocusChange, …).
iggy-shim implements that whole contract:
- Object model (
iggy_object.*): a Flash-like display/property tree that value-paths address and method calls mutate. - Scene identity: the game still hands us the raw SWF bytes with a null
config, so we fingerprint them (size + crc32) against
uiassets/scenes.tsvto know which converted scene to build — 366 scenes. - Scene bundles (
uiassets/scenes/<name>.scene): generated from the layout manifests + AS3 bygen-scene-bundles.py. Each placement resolves to a concrete PNG (followingImportAssets2links into the skin SWFs, and AS3 instance-var classes likeButton:FJ_MenuButton_Normalinto skin symbols). Nav links (m_objNav*) are extracted from the AS3 too. - Editable ActionScript (
as3/<name>/scripts): decompiled byextract-ui-as3.sh. Same-named SWFs with different contents are preserved underas3/_variants/; identical duplicates are deduplicated. - Interactivity (
scene_registry.cpp): generic semantics forInit/SetLabel/SetFocus/SetSafeZone/Show*/Hide*/checkbox; focus enumeration by id; keyboard nav (authored links + geometric fallback);handlePress/handleFocusChange/handleInitFocusemitted back to the game.
Build
cd iggy-shim
./fetch-deps.sh # cross-compiles RmlUi + FreeType for windows-clang-cl
cmake -B build -G Ninja # (see build-macos.sh for the full toolchain flags)
cmake --build build # -> iggy_shim_w64.dll + .lib
../extract-ui-pngs.sh # editable bitmap/shape/sprite art
../extract-ui-as3.sh # editable ActionScript sources
python3 ../gen-scenes-tsv.py # scene fingerprints
python3 ../gen-scene-bundles.py # scene bundles
Remaining work
- Debug the RmlUi
Rml::Initialisepage-fault under Wine (winedbg backtrace; likely an ABI/runtime detail of the static lib under wow64), then flipIGGY_SHIM_RML=1to default. - Per-scene fidelity (M-D): the display-tree renderer draws the correct art+text and handles the common control types; tightening the remaining ~60 scenes (inventory item slots via custom-draw, containers, settings sliders, DLC lists) is mechanical work over the same manifests.
- Ship without SWFs: once every scene is verified, drop the
.swfassets and.arcloader from the packaged build —uiassets/(PNG + JSON + TTF) is already the sole source the shim reads.