Skip to content

gba: allocate the frame buffers before the ROM cache; skip only when behind - #11

Merged
finger563 merged 1 commit into
mainfrom
fix/gba-frame-buffers
Oct 24, 2026
Merged

finger563 merged 1 commit into
mainfrom
fix/gba-frame-buffers

Conversation

@finger563

Copy link
Copy Markdown
Contributor

Every GBA game showed a white screen (with sound): the core was running and
rendering, but no frame reached the display. gpSP's ROM cache takes 1 MB
PSRAM blocks until it has 16 of them or one fails, which left ~320 KB, and
the two 150 KB frame buffers video_cb alternates between were allocated on
first use after that: the second one failed, and video_cb returned before
pushing every frame.

  • init_gba allocates both frame buffers before the core starts.
  • The cache's heap blocks stop short of the last 2 MB of PSRAM, for the
    pause menu's screenshots and a save state's 425 KB buffer (which, with no
    exceptions, would abort rather than throw). 16 MB ROMs now page their
    last couple of MB from the card, as gpSP does when the cache is smaller
    than the ROM.

Also: the frame pacing counted a frame that started just after its deadline
(the sleep wakes up to a 1 ms tick late) as behind, so every other frame was
skipped even at 4 ms a frame (Metroid Fusion: 1194 rendered, 1193 skipped).
A frame is now behind only a quarter frame late: 1785 rendered, 4 skipped.
Minish Cap 1657 / 135, Fire Red 1647 / 115.

🤖 Generated with Claude Code

…behind

Every GBA game showed a white screen (with sound): the core was running and
rendering, but no frame reached the display. gpSP's ROM cache takes 1 MB
PSRAM blocks until it has 16 of them or one fails, which left ~320 KB, and
the two 150 KB frame buffers video_cb alternates between were allocated on
first use after that: the second one failed, and video_cb returned before
pushing every frame.

- init_gba allocates both frame buffers before the core starts.
- The cache's heap blocks stop short of the last 2 MB of PSRAM, for the
  pause menu's screenshots and a save state's 425 KB buffer (which, with no
  exceptions, would abort rather than throw). 16 MB ROMs now page their
  last couple of MB from the card, as gpSP does when the cache is smaller
  than the ROM.

Also: the frame pacing counted a frame that started just after its deadline
(the sleep wakes up to a 1 ms tick late) as behind, so every other frame was
skipped even at 4 ms a frame (Metroid Fusion: 1194 rendered, 1193 skipped).
A frame is now behind only a quarter frame late: 1785 rendered, 4 skipped.
Minish Cap 1657 / 135, Fire Red 1647 / 115.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

ESP-IDF Size Report for 'Tab5 Emu'

Metric Base PR Delta
FLASH 0 bytes (0.00%) 0 bytes (0.00%) 0 bytes (0.00%)
DRAM 267,182 bytes (60.54%) 267,182 bytes (60.54%) 0 bytes (0.00%)
IRAM 0 bytes 0 bytes 0 bytes
RAM (DRAM+IRAM) 267,182 bytes 267,182 bytes 0 bytes (0.00%)

FLASH uses app .bin size or json2 flash sum. RAM sums DRAM+IRAM via idf_size. Percentages shown when totals are available.
DRAM/IRAM usage does not include memory used by the heap allocator at runtime.
This report was generated by esp-idf-size-delta.

@finger563
finger563 merged commit d2a0cd6 into main Oct 24, 2026
1 check passed
@finger563
finger563 deleted the fix/gba-frame-buffers branch October 24, 2026 18:39
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