dmnet.st Commando

How it works · write-up

Native grenade and shared blast

docs/NATIVE_GRENADE.md · 3 KB · updated 2026-10-14

Working notes, rendered as they are: they were written while building the game, so expect ROM addresses, register names and references to source files that are not published.

Frame and producer order

The active player launches through $9302 before actors. $8E93 updates fourteen shot records, then $9100 calls $9262 before updating $E140 and checking an empty-record grenade press. Actor $04/$0D/$1F blasts begin earlier in their physical slot; the common $9262 clocks each new count16 to15 once. A player grenade lands after that pass, so its new blast remains16 until the next update.

native-grenade.ts preserves all retained record bytes and sprite $FF44. Its physics calls the same typed stepGrenadeFlight used by isolated fixtures. A nonzero scroll pulse subtracts one high-byte pixel and decrements retained candidate byte+$07. StateFF decrements the timer modulo256; other nonzero states land immediately. The overlapping92C7 entry clearsE09C before empty-record input uses qualified input, playerFF, zero throw delay and nonzero BCD stock. No new throw is accepted on a landing update. Eight raw table entries preserve the actual data read by phase6/7 after a retained or malformed timer; these are not invented gameplay phases.

native-blast.ts translates $920D/$9262. Birth writes timer16 and four wrapped positions, retaining codes/attributes. It checks the unsigned player rectangle and emits sound07 through the runtime producer. The updater stores incoming CPU A at E09C, advances one timer byte, selects the named four-code pose and moves sprite X once for any nonzero scroll. Expiry clears only Y. A reused blast can display its old pose at birth. $03B7 hides all output while preserving E080 during restart/transition; hidden retained output does not create a visible replacement entity.

The whole blast remains one model entity with four ROM pieces. Production arcade presentation reads those retained hardware bytes; replacement presentation receives the compound origin and animation age. The lab only initializes state.

Verification

  • capture_mame_native_grenade.lua:256 complete player/grenade records, all384 sprite bytes, blast timer/contact bytes and stock pairs across state/input guards, all eight phases, fractions and nonzero scroll magnitudes.
  • capture_mame_blast.lua:256 complete updater pairs covering every timer byte and arbitrary incoming A;128 birth pairs covering wrapped coordinates, player state and both contact-axis edges. Full player/sprite/latch regions match.
  • capture_mame_blast_restart.lua:complete sprite hide at03B7/03C8 confirms retained timer15 and Y-only clearing.
  • Production acceptance tests cover retained reuse, scrolling origin/pieces, native first-gate0D expiry at count15 with one sound, and a blast born on the last death update followed by restart hiding.
  • HTTP presets blast-retained-reuse and blast-scroll-wrap are visually verified. Existing launch/landing presets use the same modules.

Remaining closure

The complete fourteen-record pass and returned A are implemented under105; see NATIVE_PROJECTILES.md. Empty grenade entry92C7 clears the latch after9262, while active flight can retain a nonzero A with previous contact coordinates. Both combined contexts match MAME. Complete mixed landing contacts for every core subtype, shared sprite aliases and interruptible consumers remain under67/92/99/102. The full output comparisons do not certify those separate paths.