Skip to content

Latest commit

 

History

History
365 lines (302 loc) · 17 KB

TODO.md

File metadata and controls

365 lines (302 loc) · 17 KB

TODO — Pingus ports, flake, and external/ work

Living checklist for the current development push (git subtrees, Nix flake cleanup, experimental WASM / Android / R36S). Update this file when items land or scope changes.

Done

Process / repo hygiene

  • Add AGENTS.md (coding standards, git-bundle handoffs, AI attribution)
  • Clarify handoffs: only git bundle + git pull; never git fetch / git cherry-pick as a substitute for stacking
  • Flake Windows outputs under host system (pingus-win32-x64 / pingus-win32-x86), not packages.*-windows
  • Drop x86_64-darwin from eachSystem (nixpkgs unstable dropped it)

external/ subtrees

  • Vendor helper libraries under external/ via git subtree add --squash
    • tinycmmc, uitest, argpp, geomcpp, logmich, sexpcpp, priocpp, strutcpp, tinygettext, xdgcpp, wstsound
  • Avoid recursive submodule checkout when adding subtrees
  • Nested upstream gitlinks (external/*/external/tinycmmc) left as gitlinks only — real modules live at external/tinycmmc

CMake + Nix using external/

  • tinycmmc_find_dependency: monorepo paths + aliases (geom→geomcpp, prio→priocpp, strut→strutcpp, sexp→sexpcpp)
  • Bootstrap TinyCMMC.cmake falls back to top-level external/tinycmmc
  • Hardcoded module paths in argpp/logmich/strut/wstsound fixed for monorepo
  • sexp ordered before prio for in-tree builds
  • Flake builds helpers with callPackage from external/*/ (no flake inputs for those libs)
  • Flake inputs reduced to nixpkgs, flake-utils, Win32 SDL ports (+ SDL source tarballs for Android/wasm)

Experimental ports (scaffolding from SuperTux Milestone 1)

  • Copy/adapt mk/{wasm,android,r36s} and nix/{wasm,android,r36s}.nix (GP2X/Wiz not brought over)
  • Wire host-system packages: pingus-wasm, pingus-android, pingus-r36s, PortMaster zips, arkos-sysroot, SDL helper outputs
  • CMake: SDL3_DIR / SDL3_image_DIR, PINGUS_USE_GLES, EMSCRIPTEN_LINK_FLAGS, html suffix, skip xdgcpp on Emscripten/Android
  • PINGUS_ENABLE_SOUND optional on Emscripten (was forced OFF; now ON via flake when wstsound path is ready)
  • wasm build-app.sh uses Pingus CMake options (not SuperTux ENABLE_*)

In progress / next

SDL3

  • Port the C++ code from SDL2 / SDL2_image to SDL3 / SDL3_image
  • CMake: find_package(SDL3) / find_package(SDL3_image) (CONFIG)
  • tinygettext: TINYGETTEXT_WITH_SDL3 (SDL_iconv)
  • Native Nix build (pkgs.sdl3, pkgs.sdl3-image)
  • Windows: SDL3 + SDL3_image cross-built from nixpkgs sources (nix/windows.nix), replacing the SDL2-win32 flake inputs
  • WASM: SDL3 + SDL3_image static builds instead of build-sdl2*.sh
  • Android: SDL3 (ndk-build, Java glue from SDL3), real SDL3_image (static, stb backend) instead of the img_stb_min.c shim
  • Android: test the SDL3 APK on a device
  • R36S: build SDL3 (KMSDRM + GLES) + SDL3_image against arkos-sysroot and ship libSDL3.so.0 / libSDL3_image.so.0 in the port
  • R36S: test the SDL3 build on the device (KMSDRM + GLES, joystick)
  • Drop the now unused sdl2-*-src, libxmp-src and SDL2*-win32 flake inputs

Dependencies

  • Replace {fmt} with std::format / std::vformat (C++20) in Pingus, logmich, and priocpp
  • Replace libsigc++ with the small pingus::Signal (src/util/signal.hpp)
  • Provide glm for Emscripten (EXTRA_PREFIX_PATH) and confirm find_package / pkg-config under FIND_ROOT BOTH

WASM (.#pingus-wasm)

  • Strip SuperTux-only EXPORTED_FUNCTIONS (_st_emscripten_*) from the link line; keep _main + main-loop pause/resume only
  • Legacy GL emulation superseded by real GLES2 shaders (FULL_ES2 only)
  • Soften mk/wasm/shell.html when optional _st_emscripten_* symbols are absent (guards already present; exports no longer require them)
  • Get a full emcmake + link of pingus past compile/link errors
  • Runtime: main loop / filesystem (data/ preload at /data), canvas resize, input
  • wstsound on Emscripten OpenAL (see section below) — not SDL2_mixer

WASM audio — wstsound on Emscripten OpenAL

Goal: real SFX + module music in the browser without OpenAL Soft. Use Emscripten’s OpenAL 1.1 → Web Audio (-lopenal) and a slim codec set.

Asset formats in-tree (what we actually need)

Path Formats Decoder
data/sounds/*.wav PCM WAV in-tree WavSoundFile (no extra dep)
data/music/*.it, one .s3m Impulse Tracker / Scream Tracker libmodplug

Not required for Pingus data: mpg123, libvorbis, opus. Keep those optional for desktop wstsound; do not pull them into the wasm closure unless a future asset needs them.

Approach

  1. Codecs as separate flake outputs (quick nix build .#libmodplug-wasm without rebuilding the game):
    • libmodplug-wasm — static libmodplug for wasm32-emscripten
    • Later: optional libogg-wasm / libvorbis-wasm only if needed
  2. Sources: fetch from the web first (fetchurl). Vendor under external/ only if packaging becomes painful or upstream disappears.
  3. wstsound wasm build:
    • Link Emscripten OpenAL (-lopenal), not OpenAL Soft
    • CMake options to disable unused codecs (WSTSOUND_WITH_MPG123=OFF, etc.)
    • Stub or #ifdef __EMSCRIPTEN__ EFX (alGenEffects / effect slots) — not available in Emscripten’s AL
    • Avoid requiring pthreads
  4. Pingus: stop forcing PINGUS_ENABLE_SOUND=OFF on Emscripten once wstsound-wasm links; keep autoplay / first-gesture behaviour in mind → done: CMake respects -DPINGUS_ENABLE_SOUND; flake sets enableSound=true

Checklist

  • libmodplug-wasm flake package (static, emconfigure/emmake or cmake)
  • wstsound CMake: WSTSOUND_WITH_{MODPLUG,VORBIS,OPUS,MPG123,EFX} options; default wasm profile = modplug + wav only; Soft loopback excluded
  • wstsound builds under emscripten against -lopenal (EFX stubbed)
  • wstsound-wasm flake output for isolated testing
  • Wire .#pingus-wasm with enableSound=true + preload music/sounds
  • Runtime: music + SFX after user gesture; greeting reflects real backend
  • Detect .s3m magic in SoundFile::from_stream (SCRM) so gd-giirm.s3m routes to ModPlug

Non-goals (for this track)

  • Porting OpenAL Soft itself to wasm
  • Shipping mpg123/vorbis/opus on wasm “just in case”
  • SDL2_mixer as the primary path (keep as a possible alternative only)

Android (.#pingus-android)

Runtime status (device / Fire tablet): menu, levels, levelsets, Options, translations, and editor groundpieces work after asset-index + empty-datadir fixes. Sound is still forced off (PINGUS_NO_SOUND).

  • Stage external/*/include into the NDK tree; exclude sound_real.cpp (until sound lands)
  • GLES context attributes in OpenGLFramebuffer when PINGUS_USE_GLES
  • Writable userdir via SDL_GetAndroidInternalStoragePath
  • Asset I/O: System::read_file / exist via SDL_IOFromFile
  • Load prio documents via System::read_file (load_document)
  • Legacy /images/... sprite paths stripped for AssetManager
  • GLES viewport synced to drawable size (1024×528 vs requested 1024×768)
  • Pingus launcher icons (mipmap-*/ic_launcher.png)
  • Translations: Android FileSystem for tinygettext + non-throwing po/ scan
  • android-asset-index.txt so opendir lists levelsets / prefabs / images
  • Empty-datadir opendir_recursive path fix (editor groundpieces)
  • Validate APK install on a device (Fire tablet / austin)
  • Build/link remaining external/ static libs for each ABI where needed
  • [~] wstsound + OpenAL Soft + libmodplug for real audio (wiring in; see below)
  • Pause/resume audio on Activity lifecycle

Android audio (wstsound) — in progress

Parity with wasm: wstsound → OpenAL, codecs modplug + wav.

  • Asset-aware open: SoundManager OpenFunc → System::read_file in sound_real.cpp (#ifdef ANDROID)
  • mk/android/scripts/build-audio-libs.sh — NDK CMake for OpenAL Soft (static) + libmodplug per ABI
  • nix/android.nix audioAndroidLibs + AUDIO_ANDROID_LIBS into APK build
  • Stage wstsound (wav+modplug only) + prebuilt .a in build-apk.sh
  • Android.mk: when ENABLE_ANDROID_SOUND=1, link openal+modplug, compile sound_real.cpp + wstsound, -lOpenSLES; else keep dummy
  • First successful nix build .#pingus-android with audio libs (fix OpenAL source hash if fetch fails)
  • Device test: menu music (.it) + SFX; pause on Activity lifecycle

Non-goals for this track: SDL2_mixer as primary path; full codec set; OpenAL EFX on mobile.

R36S / ArkOS (.#pingus-r36s)

  • Successful CMake configure against arkos-sysroot (SDL2, GL/GLES, fmt, glm, libpng, …)
  • Build external/ for aarch64-sysroot or rely on sysroot packages
  • Binary runs under PortMaster with SDL_GAMECONTROLLERCONFIG
  • Real screenshot/cover assets for PortMaster metadata

Shared engine work (unblocks WASM + Android + ES devices)

  • Request ES 2.0 context via SDL when PINGUS_USE_GLES / Emscripten
  • Compile-time PINGUS_DEFAULT_DATADIR from CMake DATA_PREFIX (wasm preload at /data)
  • Shader-based OpenGL path shared by OpenGL 3.3 Core (desktop default) and OpenGL ES 2.0 (PINGUS_USE_GLES / Emscripten): opengl_program.*, VBO draws, no fixed-function / no legacy GL emulation
  • Runtime verification on desktop GL 3.3, wasm GLES2, Android GLES2
  • Runtime verification of data path (DATA_PREFIX / preload) on each port

Flake / packaging polish

  • Run nix flake lock after input changes; prune unused lock nodes
  • CI: nix build .#pingus + optional port smoke jobs
  • Consider vendoring Win32 SDL under external/ later (optional)

ECS refactor (ecs-refactor branch)

Goal: data-driven Entity Component System for world objects and pingus, with game logic separated from presentation. All work stays on the ecs-refactor branch until it is in good shape; master is left alone. Demo replay compatibility is not a constraint (the demos were never fully reliable).

Regression check: extra/pingus-headless runs demos and levels without a display; diff its output before/after a change:

find data -name '*.pingus-demo' -o -path 'data/levels/*.pingus' | sort \
  | xargs -d '\n' build/extra/pingus-headless > results.txt

Architecture and how-tos: doc/ecs.md. Renderings can be compared as well (pingus-headless -s DIR -T TICKS).

  1. Separate game logic from sprites
    • AnimationClock: animation timing from .sprite metadata
    • Actions use clocks instead of Sprite frame state
    • World objects use clocks instead of Sprite frame state
    • Seeded Random in World (game_random, fx_random) replaces global rand() in world code
    • Pingu actions hold no sprites, they describe their look (get_look()) as animations of the player's animation set
  2. Data-driven visuals
    • Animation sets (data/animsets/), AnimatedSprite component; traps, teleporters and pingus use them
    • Game timing is explicit in the actions and traps, the art is mapped onto it proportionally; visual-only animations take their timing from the animation sets
    • Declarative effects (sound, particles, overlay at a step) in the animation sets; bomber, exiter, splashed, guillotine and smasher use them
    • Ice blocks, switch doors and conveyor belts use animation sets
    • Pingu sprites defined inline in the player animation sets, the action button icons in gui/action-buttons; 147 .sprite files removed
    • Liquid width in the collision map depends on the width of the level's surface sprite (game data from art)
  3. Headless smoke test
    • extra/pingus-headless (demos + levels with armageddon, offscreen screenshots)
    • Hook into ctest (test_pingus_headless, tutorial levels)
    • CI job
  4. Shared object schema
    • ObjectSchema / ObjectData describe all level object types
    • Editor reads, writes and derives its HAS_* flags from it
    • Editor property panel generated from the schema, HAS_* flags removed
    • WorldObjRenderer (pingus-level2png) still has its own per-type code
    • (Maybe) move the type definitions into a data file
  5. World objects as entities + systems
    • ecs::Registry, components, systems for all 22 object types
    • TriggerZone, Owner, ObjectId, SmallmapSymbol shared components
    • WorldObj level object classes and WorldObjFactory removed
    • Global WorldObj::world replaced by explicit references
    • Ground map and particles are plain services, WorldObj removed
    • Editor accesses properties by name, typed LevelObj accessors removed
    • Fixed system order (spawners, pingus, objects) instead of the old z-based update order
  6. Pingus as entities
    • Transform, PinguState, PinguBehavior, ActivePingu components, Pingu as interface component, PinguHolder no longer a WorldObj, systems in pingus/ecs/pingus.cpp
    • (Maybe) actions as data + systems instead of classes

Found along the way:

  • 44 levels failed to load because of syntax errors (multi-string descriptions, malformed numbers/bools, unescaped quotes); fixed
  • Editor dropped old (color ...) values and snow intensity on save; fixed by the schema
  • 87 demos reference levels that no longer exist
  • The (unused) smashed action shows pingus/playerN/bomber, which is the whole bomber sprite sheet as one image
  • Fake exit smashed forever after the first trigger (looping sprite); fixed
  • Build: an LD_LIBRARY_PATH pointing at system libraries built against a newer glibc breaks linking in nix develop; the develop shellHook clears system /usr/lib//lib entries

Asset viewer

  • SpriteViewerScreen for .sprite and .animset files via pingus path/to/file.{sprite,animset} (dispatch in application.cpp)
  • pingus --sprite-view opens the viewer without a file; optional FILE
  • Catalog browse: [/] or PageUp/PageDown cycle all datadir sprites/animsets
  • Animset: up/down select animation, left/right direction, space pause, ./n step when paused, R reload, Esc quit
  • HUD: name, frame, timing, loop; crosshair at draw anchor; effect-step markers; effects fire (sound, overlay, simple particles)
  • Removed obsolete extra/sprite-view (resource-name OpenGL smoke loop)
  • HUD panels for contrast; O toggles offset crosshair

Deterministic game logic

Goal: the same level + input gives bit-identical results on every build and platform (x86-64, win32-x86, aarch64, WASM), so demos replay everywhere. Floats stay where they don't feed back into game logic (rendering, sound, fx_random particles).

  1. Measure
    • State hash in src/pingus/state_hash.*; pingus-headless prints it per file, --trace DIR per tick (--trace-pingus adds every pingu), --repeat N checks runs in one process
    • All demos and levels give the same hash on repeated runs
    • Compare traces across builds: -O0/-O2, FMA (x86-64-v3), win32 under wine, aarch64, WASM
    • Re-record reference demos; most current demos no longer replay (19 of 72 loadable ones save any pingus)
  2. Compiler flags for game logic
    • -ffp-contract=off, SSE2 math on win32-x86, no fast-math
    • Locale independent float parsing/writing that round-trips exactly: sexpcpp detects float std::from_chars/to_chars at configure time (falls back to classic-locale iostreams, e.g. R36S), priocpp writes up to 9 digits instead of 6
    • No libm transcendentals in game logic (std::sin in angel.cpp)
  3. Fixed point for gameplay state
    • Pingu position/velocity, gravity, deadly/terminal velocity, collider, boarder/slider/angel/superman
    • Demo events store integer positions instead of raw float bits

Out of scope (for now)

  • GP2X / Wiz / Open2x (explicitly excluded)
  • Archive write, remote VFS, or other non-port features
  • Pixel-perfect SuperTux Milestone 1 feature parity (different game)

Quick commands

# Packages
nix build .#pingus
nix build .#pingus-win32-x64
nix build .#wasm-sdl3 .#wasm-sdl3-image  # SDL stack only
nix build .#pingus-wasm            # full wasm app (WIP)
nix build .#arkos-sysroot
nix build .#pingus-r36s            # WIP
nix build .#pingus-android         # WIP

# Out-of-tree Debug develop loop (nix develop)
nix develop
pingus-configure && pingus-build && pingus-run
# or: nix develop -c pingus-run
#      nix develop -c pingus-run-gdb

Reference