mars3142 d2ce128065
Replay checker / checker (push) Successful in 43s
Handheld release / port (push) Successful in 1h23m46s
Release 0.4.11
Signed-off-by: Peter Siegmund <developer@mars3142.org>
2026-11-02 00:07:25 +01:00
2026-11-02 00:07:25 +01:00

Dogfight (working title)

First-person WWI biplane dogfight for PortMaster handhelds (R36S family, 4:3 and 1:1) and macOS. C++17, SDL3 (static), OpenGL ES 2.0 on the device / OpenGL 2.1 on the Mac.

The full specification is in Confluence; the work is tracked in Jira (project DF). Current state: M0 skeleton (§11) — a Fokker Dr.I you can fly over a ground plane, a SPAD XIII flown by the autopilot, low-res render target with integer upscale, gamepad + keyboard, unit and smoke tests, PortMaster packaging.

Build & run

make run          # Mac, 720x720 (R36S Plus)
make run-r36      # Mac, 640x480 (R36S)
make debug        # in lldb (Mac) or gdb (Linux), no IDE needed
make test         # unit tests + smoke tests with the real game
make sanitize     # the same with ASan + UBSan
make build        # aarch64 in the PortMaster container, runs the unit tests there
make screenshot   # build-desktop/screenshot.png (make package retakes it every time)
make package      # dist/dogfight.zip
make install-card # copy onto the mounted SD card
make deploy-install HOST=ark@<ip> PORTDIR=/roms2/ports  # PortMaster installs it on its next start

Needs only CMake, the Xcode command line tools and Docker; SDL3, glm and doctest are fetched by CMake (pinned by SHA256); six correctly rounded math functions from CORE-MATH (MIT) are in third_party/. The make targets need no IDE. The native build also works on Linux (CMake, a C++ compiler and SDL3's X11/Wayland, OpenGL and audio development packages; no debug overlay there).

Versions

The version is set in project() in CMakeLists.txt and follows the milestones (D-62): 0.3.0 = M3, 0.4.0 = M4, the third number for builds in between, 1.0.0 with the PortMaster release (M6).

Releases

A release tag v<version> (it must match project()) builds in CI:

  • .gitea/workflows/checker.yml: the replay checker as WebAssembly, published as the package dogfight-checker/<version> (D-69).
  • .gitea/workflows/r36.yml: the PortMaster port, attached to the tag's release as Dogfight-<version>-PortMaster-aarch64.zip - for the R36S, R36S Plus and other aarch64 handhelds, to unzip into the ports folder or drop into PortMaster's autoinstall folder. It is built in the PortMaster build image on a runner labelled linux-arm64, and its screenshot is rendered by the device build itself with SDL's offscreen driver and Mesa's software GLES (make screenshot-r36, make zip DOCKER= SHOT=build-arm64/screenshot.png). If the job's token may not write releases, it uses the secret RELEASE_TOKEN (scope write:repository). Started by hand it only builds.

make release does it all from the Mac: on a clean main it pushes, tags v<version> (signed) and pushes the tag - CI takes over the two above - then builds and notarizes the macOS DMG (below) and attaches it to the same release as Dogfight-<version>-macOS-universal.dmg (tools/release_upload.sh; the release is made there if CI hasn't yet). NOTES=notes.md sets the release's text. make release-macos attaches the DMG again for the tag at HEAD. The token (scope write:repository) comes from GITEA_TOKEN or the login keychain, stored once with security add-generic-password -s git.mars3142.dev -a release -w.

macOS app

make macos-app        # dist-macos/Dogfight.app: universal (Apple Silicon + Intel), macOS 11+, signed
make macos-dmg        # dist-macos/Dogfight-<version>-macOS-universal.dmg with a link to Applications, signed
make macos-notarize   # notarize the DMG at Apple and staple the ticket

Release build without the debug overlay, bundle id dev.mars3142.dogfight, signed with a Developer ID (SIGN_ID=) and the hardened runtime. The icon is rendered from the game (port/macos/icon-art.png) and shaped by tools/macos_icon.swift. Notarizing needs a notarytool profile once (an app-specific password of the Apple ID): xcrun notarytool store-credentials notarytool-profile --apple-id <mail> --team-id <team> (NOTARY_PROFILE= picks another name).

VS Code

Building and running work out of the box through the tasks (Cmd/Ctrl+Shift+B, "Run Task..."), as does "Debug in the terminal" (make debug). The debug configurations behind F5 need the CodeLLDB extension - without it VS Code reports that the debug type "lldb" is not supported. The workspace recommends it together with clangd (Extensions view, @recommended); Microsoft's C/C++ extension is marked unwanted, it clashes with clangd.

Controls

Layout per spec §3.9. Face buttons by position (Xbox labels; on the R36S the top button is X). Scheme A on two-stick pads, Scheme B on one-stick pads.

Gamepad Keyboard Action
Left stick Arrows pitch / roll (pull back / Down = nose up)
Right stick — free look, snaps back (Scheme A)
D-pad I / J / K / L snap views up / left / rear / right, diagonals = quarter views (hold)
L1 / R1 S / W throttle down / up — rudder in the rudder layout (auto-coordination off; throttle then on D-pad up / down)
— Q / E rudder (auto-coordination off)
hold throttle-down 2 s at idle hold S engine off (ignition cut); throttle-up switches it on, it catches once the prop windmills fast enough (dive)
L2 Shift padlock: follow the other aircraft (hold)
R2 / A Space fire both MGs (500 rounds each)
B (hold ~1.5 s) B clear a gun jam; a hard jam needs a second try
X X gun-sight zoom (hold)
Y C panel mode: full / slim / text
Start Esc / P pause menu: resume, restart, view (drone only), options, main menu
— V / R / O cockpit / chase view (drone only), Retro / Sharp, auto-coordination

On the Mac, Select (View on an Xbox pad) also switches Retro / Sharp; on the device Select stays unbound (Select+Start is the firmware's exit hotkey).

Menus

The game starts in the main menu over the next duel's map. Quick Dogfight starts at once with the last setup; Dogfight Setup picks your aircraft (the opponent flies the other one), the opponent's skill, the weather and the start: head-on, neutral (side by side), advantage (behind and above him), disadvantage (him behind and above you) or random. Options (also from the pause menu) set the difficulty - Casual (the default), Normal, Realistic, or Custom for any other mix - and the single assists: lead mark, visibility aid, enemy arrow (a chevron at the edge of the view toward an enemy off screen; lost from sight, toward where he was last seen, fading), auto-coordination, stall warning, gun jams, pilot protection, the opponent's skill; invert pitch; Retro / Sharp and the volume. Sticks (with a pad) shows both sticks live and sets their dead zone and expo for the pad in use; Calibrate measures where each stick rests and how far it reaches, so a worn or short-throw stick still gives full deflection. Buttons (with a pad) moves the flying actions - fire, padlock, zoom, clear jam, panel, throttle - to other buttons: choose one, press its button (Start cancels); a button taken from another action swaps them. The menus, Start and the D-pad stay put. Both are kept per pad model. In a duel's pause menu what its replay depends on (difficulty, jams, protection, opponent) waits for the next duel and isn't offered. In every menu the D-pad or the left stick (arrows) moves and changes a choice - held, it repeats, A (Enter) selects, B (Esc) goes back; in the debrief Start (Esc) leads back to the main menu. Training has five short lessons - flying, the stall, gunnery at the drone with the lead mark, views and guns (padlock, zoom, clearing a jam) and a first dogfight set up to be won (a Novice ahead and below). Every lesson flies with every help on (Casual), whatever the options say. Each step says what to do with this device's buttons and goes on once it is done; a lesson done is marked in the list. On the very first start the main menu suggests it once. The pause menu's Controls shows the controls as they are now.

The menus and the debrief play music of the time - songs in the public domain as MIDI files in assets/music/, synthesized by the game as they play and looped seamlessly (music.txt says which stretch of which file plays where; the sources are in SOURCES.txt): "It's a Long Way to Tipperary" in the menu with the SPAD, "Alte Kameraden" with the Dr.I, "Keep the Home-Fires Burning" in the debrief. None in flight; MUSIC in the options. Any MIDI file works: put it in the folder and name it in music.txt.

On the first start the game asks before the main menu whether to share every duel on the web (D-64); the answer can be changed in the options (SHARE DUELS). In the first duels a line under the panel explains what just happened - a stall, a jam, no ammo, the enemy lost, the edge of the battle, how to get away when badly hit - each at most twice, HINTS in the options turns them off. Everything else is kept in settings.txt in the game's data folder. Scripted runs (see below) and the drone practice start in the air as before.

Environment variables (D-25)

WINDOW=WxH, SCREENSHOT=file.bmp + SCREENSHOT_FRAME=n, AUTOPILOT=1, FAST=1, FRAMES=n, SEED=n, RENDER=retro|sharp, MENU=1|setup|options|sticks|buttons|consent (the main menu, or that screen of it, in a scripted run - for screenshots), FACE_BUTTONS=labels|positions (how the pad's mapping names its face buttons), WEATHER=clear|scattered|broken|overcast (default scattered), START=duel|neutral|advantage|disadvantage|random (how a duel starts; duel = head-on), LESSON=1..5 (start in that training lesson), SCHEME=a|b, AUTOCOORD=0, INVERT_PITCH=1, AIRCRAFT=dr1|spad (the player's type; the other aircraft gets the opposing one), VIS_AID=0 (visibility aid off), JAMS=0 (guns never jam), PILOT_PROTECTION=0 (the player's pilot can be killed), RUMBLE=0..1 (rumble strength, 0 = off), REPLAY=file.dfr (watch a recorded duel), CAMERA=cockpit|chase (the first camera, a replay's too; with SCREENSHOT for pictures from the cockpit), MAP=1 (the debrief shows the front map first), DEADZONE=0..0.5 and EXPO=0..1 (stick dead zone and response curve; by default a handheld's built-in sticks get 0.04 / 0.5 - their driver already cuts the centre - and other pads 0.15 / 0.3 until set in the options' Sticks; set here, they win over that). AIRCRAFT, SKILL=novice|veteran|elite, WEATHER, RENDER, AUTOCOORD, JAMS, PILOT_PROTECTION, VIS_AID and INVERT_PITCH win over the saved settings.

On the handheld the launcher reads debug.env from the port's folder if it is there, e.g. export WEATHER=overcast or export AUTOPILOT=1 - delete it to play normally again. Every 5 s the log (log.txt there) names the frame times and what the terrain drew: chunks, how many of them carry the finest level, triangles.

Replays

Every duel is recorded - seed, start and both aircraft's inputs, 120 times a second - and saved when it is over (or when you quit mid-fight) as replays/duel-<date>-<time>.dfr in the game's data folder (SDL's pref path: under ~/Library/Application Support/ on macOS, in the port's conf/ folder on the device; the log names the file); the newest 20 are kept. Scripted runs (autopilot, FAST, FRAMES, screenshots) save no replays. Each replay names the build that recorded it (version, git commit, target and optimization, e.g. 0.3.0 9c3d82c macos-arm64 opt). Since D-65 (after 0.4.0) the simulation computes the same on every target, so a replay plays out the same on any build of its commit - the device, either half of the Mac app, Debug or Release; the game and replay_check warn only when the version or commit differs (a replay from 0.4.0 or earlier still needs exactly the build that recorded it). In the debrief Y (Tab on the keyboard) plays the duel back:

Gamepad Keyboard Action
Y V chase / cockpit view
D-pad left / right Left / Right watch the other aircraft
D-pad up Up speed 1x / 2x / 4x
Right stick — look around / orbit
Start P pause
B Esc back to the debrief

./build-desktop/replay_check file.dfr replays a file headless and checks that it ends in the recorded state; make test does that for the golden AI duels in tests/replays/ (TR-20). After an intended change to the simulation or the aircraft data, record them again with make golden-replays. ai_tournament --record DIR writes a replay of every fight. make checker builds the same check as WebAssembly for a web server (build-wasm/dogfight-checker.mjs, D-69) and runs the golden replays through it under Node; every release tag publishes it as the package dogfight-checker/<version> (.gitea/workflows/checker.yml). Backend and viewer for the web: the web spec. The checker also makes the flight track a web viewer draws (docs/TRACK.md); ./build-desktop/replay_track file.dfr > track.json makes it natively, and make track-samples records three AI duels with their tracks into build-desktop/tracks/. Replay files can be read in a hex editor: tools/imhex/dfr.hexpat for ImHex (File > Import > Pattern File, or copy it into ImHex's patterns folder) and tools/hexfiend/dfr.tcl for Hex Fiend (copy it into ~/Library/Application Support/com.ridiculousfish.HexFiend/Templates/, then View > Binary Templates). Long duels have tens of thousands of input runs, so the input section takes a moment to build.

Rumble

Pads with rumble motors shake when you are hit (harder in the engine), when an enemy goes down, on a crash or nearby explosion, in a stall and with a damaged engine. On an Xbox pad the guns tick in the right trigger with every round and a jam knocks it hard. The log line Gamepad rumble: motors ..., triggers ... says what the connected pad supports. In the debug overlay (Controls) a slider sets the strength and buttons play each effect on its own.

Playtesting (§8.5)

The duels speak for themselves: the replays the game keeps (and those sent to the server with the player's consent) hold the version, assists, aircraft, seed, result, shots and hits; the website's statistics sum them up. Testers send their replay files.

Debug overlay (Mac only)

Pause, then press D: a Dear ImGui window with statistics and settings that have no menu yet - map seed, aircraft, drone respawn, repair, assists, render mode, FOV, fog, terrain detail, stick expo and dead zone, and every flight parameter live (with "Save to data file"). Desktop builds only (D-58); the device build doesn't contain it.

AI opponent (M3)

By default you fly a duel against an AI (SKILL=novice|veteran|elite, default veteran). It sees you only through its own eyes - vision cone, blind spots below and behind, line of sight through terrain, reaction time and noise - and flies with the same stick, throttle and trigger as you (spec §6.1). OPPONENT=drone brings back the M2 target drone.

The map has a front line (trenches and barbed wire, no-man's-land): the SPAD starts on the Allied side, the Dr.I on the Central side. Observation balloons float behind both lines - roundels over the Allied side, crosses over the Central side - so you can tell whose ground you are over from afar; fly into one and you go down. A railway runs behind one side's lines through a town and over the river on a bridge; villages with church towers lie around. A duel ends when one of you goes down (both within 1 s is a draw), when either side stays over its own territory more than 600 m from the enemy for 10 s ("RETURNING HOME" / "ENEMY ESCAPING"), when you leave the combat area for 15 s ("TURN BACK!"), or in a mid-air collision (always a defeat). Forced down over your own lines you survive, over enemy lines you are captured. A downed aircraft gets a 3 s kill cam (any button skips it), then the debrief shows the result and your numbers; A (Enter on the keyboard) starts the next duel on a new map, B (M) shows the front map instead of the aircraft - both sides of the front, the river, and where you (white) and the opponent (red) flew, from the dot where each started to an X where one went down. When the replay server answers, the debrief also offers X: UPLOAD (U on the keyboard; the label follows the device's buttons): the duel's replay goes to https://api.dogfight.mars3142.dev, which replays it with the checker of its release and keeps it if it is valid - the debrief shows the answer, and for a kept duel its code (CODE 8HWV30): type it at dogfight.mars3142.dev or go to dogfight.mars3142.dev/8HWV30 to watch it. Nothing is sent unless you press it; offline the line doesn't show. Builds that are not a release are refused. UPLOAD_URL= sets another server (empty: no upload). The game uses the system's curl for it, and sends a small proof of work along (about a second on the handheld, web spec §8.1); the debrief offers it only without the consent below. Whoever said yes to share every duel (asked on the first start, changed in the options) needs no button: every duel against the AI of at least 30 s goes to the server by itself, never during a flight, flown offline it waits in replays/queue/ for the next start with a network. It goes with a random install key, never with a name; stopping deletes the key and the queue. The chase view is only available against the drone.

Scattered cumulus clouds (from the map seed) hide whatever is behind or inside them - from you and from the AI alike: its eyes, your padlock and the lead indicator all use the same line of sight. Fly into one and the world turns white. The weather (WEATHER=, or the debug overlay) sets how many: clear, scattered, broken, or overcast - a closed grey layer high above the fight with a few clouds below it, no sun and dull light. The sun stands where the map's seed puts it: an aircraft right in front of it can't be seen - by you or by the AI - and looking into it washes out the view, so attack out of the sun.

Headless AI-vs-AI duels for tuning (§6.8):

./build-desktop/ai_tournament --fights 200 --a dr1:veteran --b spad:veteran

--tail 150 starts B 150 m ahead of A on the same course (A holds its fire for 2 s), for tuning the defense against a pursuer on the tail; the summary counts the hits of each side.

make test runs three of these with the acceptance limits (matchup 30-70 % and mirror 40-60 % until AI v2, elite beats novice >= 80 %, collisions < 1 %).

Gunnery practice (M2)

The other aircraft is a target drone. Bring the gun sight onto the lead diamond and fire; hits spark, a damaged engine smokes, and a downed drone is replaced by a new one ahead after a few seconds.

The guns hit reliably only within a few hundred metres, like the real ones (D-61): get close - 100 to 200 m - and fire short bursts; long bursts spread wider. The lead diamond shows only within 400 m.

Scenery

Trees along forest edges, poplar rows and hedges on field borders, trees in the villages and shattered trunks in no-man's-land come from Kenney's Nature Kit (CC0, D-35). tools/kenney_convert.py turns its OBJ models into assets/data/scenery/ (height 1, colours as palette keys, so they take the game's palette); it expects the kit in ../kenney_game_assets/. They exist only on the finest terrain level, which is built on a worker thread for the chunks near the aircraft and freed behind it, so their cost stays the same wherever you fly.

Tuning

Flight parameters live in assets/data/aircraft/*.txt (speeds in km/h, rates in deg/s). On the Mac, saving a file while the game runs reloads it within a second; a broken file keeps the old values and the log names the line. span_m and length_m set an aircraft's size: the AI's eyes, the hit zones, collisions, the muzzles and the drawn model all follow it (also live from the debug overlay's sliders).

Layout

Path Content
engine/ SDL3 platform layer (window/GL context, low-res presenter, input, audio, files) — knows nothing about the game
src/core/ viewport/scaling (FR-RS-*), seeded RNG
src/sim/ deterministic simulation, the same on every platform: flight model, guns and rounds, damage, AI (sensor + brain), terrain, world — no SDL/GL (enforced by CMake), no libm sin/cos/… (sim/math.h, checked by make test)
tools/ headless AI tournament, replay check (native and WebAssembly), converters
src/render/ flat-shaded meshes, terrain chunks with LOD, scene renderer with turning propellers, particle effects
src/hud/ 2D HUD (pixel art in Retro, smooth in Sharp): canvas, pixel + stroke font, instrument panel — no GL
src/audio/ generated engine and combat sounds
src/app/ main loop (120 Hz fixed step), controls, env switches
assets/ shaders, aircraft data (CC BY-NC-SA)
port/ PortMaster launcher and metadata templates

License

Code: GPL-3.0-or-later; third_party/core-math/: MIT. Assets: CC BY-NC-SA 4.0 — the complete game must not be sold. Streams and let's plays, including monetized ones, are explicitly allowed.

S
Description
First-person WWI biplane dogfight in low-poly 3D: find the enemy, use clouds, sun and terrain, and shoot him down before he does the same to you.
Readme
2.3 MiB
0 Stars 1 Watchers 0 Forks
2026-11-02 06:43:07 +00:00
Languages
C++ 94%
CMake 2.2%
Makefile 1.2%
Python 0.6%
Shell 0.6%
Other 1.3%