Skip to content

Survival entry fade (decompile notes)

This page documents the menu → Survival fade behavior using the static decompile as the authoritative source. The goal is to mirror the original pipeline and identify any missing runtime triggers before changing the rewrite behavior.

Fullscreen fade overlay (render order)

The classic renderer applies a fullscreen black overlay using screen_fade_alpha (DAT_00487264) after the world render and before UI elements:

  • gameplay_render_world (0x00405960) draws grim_draw_fullscreen_color(0,0,0,screen_fade_alpha) after projectiles/bonuses.
  • game_update_generic_menu (0x00406af0) draws the same fullscreen color after the menu/world pass and before ui_elements_update_and_render.

This ordering matches the observed effect: ground can dim while UI panels slide out, because the UI is rendered after the fade overlay.

Fade update rates (authoritative)

The main update loop updates screen_fade_alpha every frame:

if (screen_fade_ramp_flag == 0) {
  screen_fade_alpha -= frame_dt * 2.0;
} else {
  screen_fade_alpha += frame_dt * 10.0;
}
screen_fade_alpha = clamp(screen_fade_alpha, 0.0, 1.0);

Decompile reference: crimsonland.exe_decompiled.c around the screen_fade_alpha update block (see ~0x0040c4b7 region and the DAT_0048702c checks).

Implication: fade-to-black is very fast (~0.1s at 60fps), while fade-from-black is slower (~0.5s at 60fps).

Trigger observations (static)

Static references to screen_fade_ramp_flag (DAT_0048702c):

  • Set to 0 on game_state_set(9) (Survival/Rush/Quests gameplay entry).
  • No obvious write of screen_fade_ramp_flag = 1 on the Survival start path was found in the current decompile dump.

Runtime evidence (confirmed)

Runtime trace (2026-01-30): analysis/frida/raw/screen_fade_trace.jsonl captured with scripts/frida/screen_fade_trace.js (raw logs are ignored in git).

Reduced summary: analysis/frida/screen_fade_trace_summary.json (generated by uv run scripts/screen_fade_trace_reduce.py).

Observed behavior when starting Survival from the Play Game menu:

  • When the menu requests gameplay (game_state_pending = 9), screen_fade_ramp_flag flips 0 → 1 at ts=1769544752317 and screen_fade_alpha ramps 0 → 1 by ts=1769544752421 (~104ms, fade-to-black).
  • On gameplay entry, screen_fade_ramp_flag flips 1 → 0 at ts=1769544752619 while screen_fade_alpha is still 1.0, then screen_fade_alpha ramps 1 → 0 by ts=1769544753120 (~501ms, fade-from-black).
  • The renderer uses grim_draw_fullscreen_color(0,0,0,alpha) with the same alpha.

Rewrite alignment

To match the original timing (fast fade-to-black during menu close, then fade-from-black on gameplay entry), the rewrite does:

  • On menu close for gameplay actions: set screen_fade_alpha = 0.0 and screen_fade_ramp = True.
  • On gameplay open: if screen_fade_ramp is still True, clamp screen_fade_alpha = 1.0 and then set screen_fade_ramp = False so the fade-from-black begins immediately.

Reproduce / recapture

Capture a runtime trace when selecting Survival from the Play Game menu:

just frida-attach script="scripts\\frida\\screen_fade_trace.js"

This writes screen_fade_trace.jsonl into the Frida share directory (default C:\share\frida). Import it into the repo with:

just frida-copy-share
just frida-import-raw