Skip to content

Jedi Knight: every launch starts from a clean engine state, as on desktop - #40

Merged
finger563 merged 1 commit into
mainfrom
fix/jk-session-globals-reset
Nov 23, 2026
Merged

finger563 merged 1 commit into
mainfrom
fix/jk-session-globals-reset

Conversation

@finger563

Copy link
Copy Markdown
Contributor

Engine side: esp-cpp/OpenJKDF2#5. This PR bumps components/jk/OpenJKDF2 to that branch (ea0c9c18).

Summary

  • Every Jedi Knight launch now starts from a clean engine state, as on desktop.
    • tab5-emu runs the engine several times per boot, but unlike desktop's launcher it never reset the engine's globals between launches, so anything left from the last session carried over.
    • Jedi Knight: keys work at the menus after a quit and relaunch; console commands too #39 fixed the cases that broke keys and console commands by hand. This resets all of the engine's generated globals at the start of each launch, which makes those hand fixes redundant.
  • Also fixed:
    • a latent double free when JK was quit before any level, after a session that had played one;
    • two small leaks: the HUD inventory bitmaps of bins 100–199, and the loading-screen texts.
  • The change was audited before it was written: reset values against boot values, port writes made before startup, and allocations meant to outlive a session. Two skeptics then verified the plan. Details are in the engine PR.

Testing (Tab5)

Result
Four JK sessions in one boot (play and save; quit during the intro; load that save from the intro and play on; play again) all pass; keys and console commands work in every session
Light campaign 01 → 18 in a third session; both endings in later sessions every level loads, with the same memory as in first sessions
Launcher PSRAM after each quit back to the boot value every time (no per-session leak)

🤖 Generated with Claude Code

https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY

esp-cpp/OpenJKDF2 esp32/session-globals-reset. tab5-emu runs the engine more
than once per boot, but unlike desktop's launcher it never reset the engine's
globals between launches. So state from the last session carried over: the
handler table and the console counts were found and fixed by hand in #39, and
a quit before any level, after a session that had played one, freed a HUD
buffer twice. The engine now resets all of its generated globals at the start
of each launch. Two small leaks that would otherwise have become permanent
are fixed at the source.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
@finger563
finger563 merged commit d120517 into main Nov 23, 2026
2 checks passed
@finger563
finger563 deleted the fix/jk-session-globals-reset branch November 23, 2026 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant