Repository navigation
libmpeg (SDK layout): stream callback entries in the work area, nothing from the game's heap - #161
Merged
Merged
Conversation
…ng from the game's heap Off the reference's layout, each stream callback's 32-byte entry came from the engine's heap, which by default starts after the game's .bss, where a game's own allocator works. Both handed out the same memory: Amplitude's task manager list header was overwritten from the movie's first frame. The entries now come from the last 64 x 32 bytes of the work area the game gave sceMpegCreate (libmpeg's own memory, never read by the game), freed as each handler ends. The reference's layout keeps the heap as before. A save state from before has no in-use mask: it loads as none waiting. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
With
MpegOptions::referenceLayoutoff (the SDK's layout), each stream callback's 32-byte entry now comes from the end of the work area the game gavesceMpegCreate. Before, it came from the engine's heap.The reference's layout (TMB) is unchanged: entries still come from the heap, at the same addresses.
Why
The engine's heap defaults to the region from
SetupHeap's result to the end of RAM, which is where a game's own allocator works. In Amplitude, libmpeg's entries and the game's own blocks shared the same memory. The task manager's list header was overwritten from the movie's first frame, and the task run after the intro had a null command. The port had to move the engine's heap into.textto avoid it.With this change, off the reference layout, libmpeg takes nothing from the game's heap, so a port doesn't need that workaround for its movies.
Save states
The in-use mask is appended to the "mpeg" section. A state written before has no mask and loads with no entry waiting: its waiting entries are heap addresses, still freed to the heap.
Testing
Amplitude, with this branch merged locally with #150 and #160, and the port's heap move turned off:
Onimusha and Shinobido also run off the reference layout: their entries now come from their work areas too. I haven't run those ports.
🤖 Generated with Claude Code