Skip to content

libs: sceGsSyncV waits for the next vblank (opt-in) - #160

Merged
boubou666 merged 2 commits into
masterfrom
amp/syncv-vblank
Nov 27, 2026
Merged

boubou666 merged 2 commits into
masterfrom
amp/syncv-vblank

Conversation

@boubou666

@boubou666 boubou666 commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #150. The new commit is 7678d91; the one below it is #150's. (Rebased onto master; #156 was closed, master has the same function.)

What

Adds Libraries::syncVWaitsForVblank, off by default. When a port turns it on, sceGsSyncV behaves as the console's does:

  • The EE clock goes on to the next vblank's start.
  • The result is that field's parity: the vblanks started by then, odd or even.

Off, nothing changes. sceGsSyncV still ends the game frame at once, held to the host's frame period, and returns the parity of the frames ended. That is the reference's behaviour (TMB's boot and match1p calls).

Why

Amplitude's movie player paces itself:

  1. As a picture goes up, it starts the EE's timer 0 on hblanks.
  2. It feeds the decoder until 500 hblanks (1.905 fields) have passed.
  3. It calls sceGsSyncV until the parity is even.
  4. It shows the picture with sceGsPutDispEnv.

On the console the vblank wait takes the remaining 0.1 field: two fields a picture. Holding the frame end to a whole period after another frame end instead made three fields a picture. The logos' and the intro's sound ran 1.45 times too fast and ended long before the movie's last picture.

With the option on (plus the port's sceGsPutDispEnv no longer ending a frame), the intro plays 300 pictures in 10.01 s of EE time, two vblanks each. Its sound lasts as long as its pictures.

Testing

Amplitude, headless and in the window:

  • 300 pictures take 10.01 s of EE time and 10.0 s of real time.
  • The recorded sound covers the movie, then the title's music.
  • Only the movie player calls sceGsSyncV in Amplitude, so the game's own frames are unchanged.

No other port is affected: the option defaults off.

🤖 Generated with Claude Code

boubou666 and others added 2 commits November 27, 2026 10:16
…nit; whole stream reads (opt-in)

What Amplitude_Recomp answered in its port, generic SDK behaviour:
- sceIoctl: request 1, the status a file opened with O_NOWAIT is polled with, is "done" (*arg = 0): the native
  sceOpen / sceRead have finished as they return. Any other request: -1.
- sceSifInitCmd, sceSifSetDChain, isceSifSetDChain: nothing to set up or arm (Onimusha_Recomp answered
  sceSifSetDChain the same way in its port).
- sceIpuInit: no IPU to reset.
- CdState::wholeStreamReads (off by default): a sceCdStRead that does not wait brings all its sectors or none,
  as a console's drive fills the stream ring a bank at a time. Amplitude's movie player resumes its demux at
  buffer + 0x4000 - bytes left and skipped a sector after a short read.
- texture.h: Texture::rgba carries the GS's alpha (0x80 opaque); the comment said 255.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A game that paces itself on the EE's timers and then calls sceGsSyncV gets
the console's wait: the EE clock goes on to the next vblank's start, and
the result is that field's parity. Off (the default, the reference's), the
frame ends at once, held to the frame period, with the parity of the frames
ended.

Amplitude's movie player waits 500 hblanks on timer 0, then sceGsSyncV:
two fields a picture with the wait, three with a frame end held to a whole
period.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@boubou666
boubou666 merged commit cc28745 into master Nov 27, 2026
4 checks passed
@boubou666
boubou666 deleted the amp/syncv-vblank branch November 27, 2026 09:47
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