Skip to main content
← PSoXide SDK guides and examples · SDK f2fec1c301f1 · All Cargo features enabled; check feature gates before use.

Module player

Module player 

Source
Expand description

A streaming STR player a game can call: play streams one movie from the disc at double speed, decodes it through the MDEC and shows it, with its interleaved XA audio going straight from the drive to the SPU.

The pipeline is the hello-fmv console test’s, without the test’s sector stamps and overlay:

  1. A polled pump drains every sector the drive has ready into a ring of three frame slots. It runs between every unit of work, including every wait and every two macroblocks of the bitstream decode.
  2. crate::bitstream::decode_frame turns the next frame’s bitstream into one of two run-length buffers while the MDEC decodes the previous frame from the other.
  3. Decoded 16-pixel columns come back over DMA1 into one of two column buffers and go to a free display buffer over DMA2 while DMA1 fills the other.
  4. The flip is queued to the VBlank handler. There are three display buffers, so the MDEC can start the next frame while the last one waits for its flip.

Pacing follows the drive, not the VBlank: a frame is shown Config::latency_vblanks after its last sector arrived. The audio plays as its sectors arrive, so picture and sound keep a fixed offset for the whole movie whatever the display’s refresh rate, and a 25 fps PAL movie plays at 25 fps on a 60 Hz display. A frame completed while an older one still waits for the decoder replaces it (counted in Outcome::skipped).

Memory comes from the caller (memory_words says how much), so a game lends a buffer that is idle while the movie plays, such as a level buffer at boot. The player takes over the CD drive, the MDEC, DMA channels 0 to 2, root counter 2, the display and the VRAM under Config::buffers while it runs. No frame of the caller’s may be in flight on the GPU when it starts, and the SPU must already be initialised.

Structs§

Config
Where and how to show it.
Movie
One movie on the disc, as the build measured it.
Outcome
What happened, for logs and tests.

Enums§

Depth
Colour depth of the decoded picture.
Stop
Why play returned.

Constants§

DEFAULT_BUFFERS
Display buffers at (0, 0), (0, 256) and (512, 0): room for 320 pixels at 24 bits (480 halfwords) by up to 256 lines each.
WEDGE_ERRORS
Consecutive MDEC failures that end a movie as Stop::Wedged.

Functions§

find_root_file
Find a file in the disc’s root directory by name: (lba, bytes). Takes the drive over (data mode, double speed) and leaves it stopped.
memory_words
Words of memory play needs for movie at depth.
play
Play movie until it ends or poll returns true (checked once per VBlank, e.g. for a skip button). memory must hold at least memory_words words and is free again on return. At 15 bits the last frame stays on screen (the display start may be any of the three buffers); at 24 bits every buffer is cleared to black and the caller’s display mode is restored. The drive is stopped and the CD audio volume left at 0.