Repository navigation
End sceMpegIsEnd at the PSS program end when no sceCdSt stream fed the movie - #414
Open
0xLeathery wants to merge 2 commits into
Open
0xLeathery wants to merge 2 commits into
0xLeathery wants to merge 2 commits into
Conversation
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.
Problem
The MPEG HLE's
sceMpegIsEndonly returns 1 once the producer reports end of file:currentCdStreamEofSeenplus a matchingcdStreamGeneration. Only the HLE'ssceCdStstreaming path advances those.Many games don't use
sceCdSt. Sly 2 (SCUS-97316) reads its movies with plainsceCdReadinto its own ring and demuxes them withsceMpegDemuxPssRing. For those games the EOF flag is never set, sosceMpegIsEndnever returns 1 and a loop likedo { …GetPicture… } while (!sceMpegIsEnd(mp))never exits.This happens even though the demux has already seen the PSS program-end code (
0x000001B9) and setplayback.streamEnded. Unlike a sequence-end code, the program end marks the end of the whole PSS file.Change
sceCdSt(playback.cdStreamGeneration == 0, meaning nosceCdStStartthis session): the producer counts as ended oncestreamEndedis set by the program-end path.sceCdSt-fed playback keeps exactly the previous rule.[MPEG:IsEnd]trace gains acdStreamFed=field.Testing
New tests in
ps2_runtime_expansion_tests.cpp:sceCdSt: IsEnd stays 0 while frames are queued and returns 1 once they've been shown and two real VBlanks have passed. This test failed before the change.sceCdStpath: a program end alone doesn't end an activesceCdStstream; its EOF still does.Results:
ps2x_tests: 449/449.B7) never ends.With a recompiled Sly 2 (USA), whose
sceMpegIsEndat0x24B610is bound to the HLE, the intro movie now ends and boot continues past it. The movie's data on disc does end with00 00 01 B9.Known limits, not changed here
sceCdStmovie that plays while ansceCdStstream has started but hasn't reached EOF still waits for that EOF. Once that stream reaches EOF or is stopped, the old rule ends the movie.sceMpegReset(rather thansceMpegCreate), the handle carriesstreamEndedforward, andappendPssBytesdrops the next movie's bytes. With this change, a second movie played on the same handle reports IsEnd immediately; before, it hung. Worth a separate issue.Built and tested on macOS arm64 (Apple clang).