resonance 1.0.1
Loading...
Searching...
No Matches
Rnd::AMovieSet Class Reference

Reader that plays a chunked movie file into per-track handlers. More...

#include <amovieset.h>

Collaboration diagram for Rnd::AMovieSet:

Classes

struct  Track
 Track description a MOVT chunk supplies, 0x2c bytes. More...
struct  PaletteChunk
 Payload of a PALL chunk. More...
struct  FrameChunk
 Payload of a FRAM chunk, followed by the frame's pixels. More...
struct  BlankChunk
 Payload of a BLAK chunk. More...

Public Types

typedef void(* ChunkHandler) (AMovieChunkHdr *pHeader, void *pPayload, void *pData)
 Receiver of one track's chunks.

Public Member Functions

 AMovieSet (const char *pszPath, int bStreaming, int *pnError)
 Open a movie file and queue its first read.
 ~AMovieSet ()
 Close the file, cancel an outstanding read, and destroy the ring buffer.
void Update (int nTick, int nReadSize)
 Consume every chunk due by nTick and top up a streaming buffer.
int ParseHeader (char *pBuffer, int nBytes)
 Parse the MOVS and MOVT chunks at the start of a loaded buffer and set up the ring buffer.
void AssignHandler (int nTrackId, ChunkHandler pfnHandler, void *pData)
 Install the handler for one track.
int RequestRead (int nBytes)
 Queue the next streaming read of up to nBytes, as Update() does inline.

Public Attributes

int mFile
ACircBuff * mCircBuff
char * mBuffer
int mBufferSize
unsigned char mReserved10 [8]
Track mTracks [kTrackCount]
ChunkHandler mHandlers [kTrackCount]
void * mHandlerData [kTrackCount]
int mLoopTicks
 Tick offset the LOOP chunks have accumulated.
int mLastTick
int mDataStart
unsigned char mReserved364 [4]
int mStreaming
int mLoaded
int mFileLength
int mFileOffset
int mAsyncHandle
int mSoundHold

Static Public Attributes

static constexpr int kTrackCount = 16
 Tracks a file can describe, and so the handler slots.

Detailed Description

Reader that plays a chunked movie file into per-track handlers.

The class emits no RTTI. Its name comes from the debugging symbols of the North American demo release. The object is 0x380 bytes and is allocated untagged. Rnd::Movie plays its .mmv file through one, and the synth plays its sound bank movie through another (0x00462908).

A file begins with a MOVS chunk and one MOVT chunk per track, which ParseHeader() copies into mTracks. The chunks that follow carry palettes (PALL), frames (FRAM), blank frames (BLAK), loop points (LOOP), and three kinds of sound data (SNDH, SNDB, SNDP). Update() consumes every chunk whose tick has arrived and passes it to the handler AssignHandler() installed for its track. A whole file is read into memory at once. A streaming file is read in 0x8000 byte and smaller requests into an ACircBuff in the zone "movieStreamBuff", which must be at least 512K.

Member Typedef Documentation

◆ ChunkHandler

typedef void(* Rnd::AMovieSet::ChunkHandler) (AMovieChunkHdr *pHeader, void *pPayload, void *pData)

Receiver of one track's chunks.

Parameters
pHeaderThe chunk.
pPayloadThe bytes after the header.
pDataThe value installed with the handler.

Constructor & Destructor Documentation

◆ AMovieSet()

Rnd::AMovieSet::AMovieSet ( const char * pszPath,
int bStreaming,
int * pnError )

Open a movie file and queue its first read.

A whole file is read into a zone block of its uncompressed length through AsyncLoadFileByPath(). A streaming file takes every byte the zone "movieStreamBuff" has left, which a missing zone, a zone under 512K, or a file that will not open reports as fatal, and its first 0x8000 bytes are read through AsyncSubmitRequest(). Either way the stream joins the list MovieAsyncCallback searches, and ParseHeader() runs once the read completes.

Parameters
pszPathThe file.
bStreamingNon-zero to stream rather than read the whole file.
pnErrorReceives 0, -1 when the buffer could not be allocated, or -2 when the file has no length.
Ghidra address:
NTSC-U/C: 0x0057f7b8
Ghidra address:
PAL: 0x005c27f0

◆ ~AMovieSet()

Rnd::AMovieSet::~AMovieSet ( )

Close the file, cancel an outstanding read, and destroy the ring buffer.

The data buffer belongs to its zone and is not released, and a stream destroyed before its header arrives stays in the pending list.

Ghidra address:
NTSC-U/C: 0x00580858
Ghidra address:
PAL: 0x005c3890

Member Function Documentation

◆ Update()

void Rnd::AMovieSet::Update ( int nTick,
int nReadSize )

Consume every chunk due by nTick and top up a streaming buffer.

A tick earlier than the last one rewinds to the first data chunk. At most one video chunk and one sound chunk are dispatched per call, and a LOOP chunk advances mLoopTicks by its length. A LOOP chunk in a whole file moves the read pointer back to the start. An unknown chunk type is fatal.

Parameters
nTickThe current tick.
nReadSizeThe largest streaming read to queue.
Ghidra address:
NTSC-U/C: 0x0057fac8
Ghidra address:
PAL: 0x005c2b00

◆ ParseHeader()

int Rnd::AMovieSet::ParseHeader ( char * pBuffer,
int nBytes )

Parse the MOVS and MOVT chunks at the start of a loaded buffer and set up the ring buffer.

MovieAsyncCallback::Done() calls it once the first read completes.

Parameters
pBufferThe buffer the read filled.
nBytesThe bytes read.
Returns
0, -1 when the ring buffer could not be allocated, or -6 when the file does not begin with a MOVS chunk.
Ghidra address:
NTSC-U/C: 0x0057ffd0
Ghidra address:
PAL: 0x005c3008

◆ AssignHandler()

void Rnd::AMovieSet::AssignHandler ( int nTrackId,
ChunkHandler pfnHandler,
void * pData )

Install the handler for one track.

Parameters
nTrackIdThe track.
pfnHandlerThe handler, or null to drop the track's chunks.
pDataThe value passed to the handler.
Ghidra address:
NTSC-U/C: 0x005808d0
Ghidra address:
PAL: 0x005c3908

◆ RequestRead()

int Rnd::AMovieSet::RequestRead ( int nBytes)

Queue the next streaming read of up to nBytes, as Update() does inline.

Nothing is queued unless the stream is streaming and loaded, no other streaming read is outstanding, and more than 0x400 bytes are free. A read that would pass the end of the file is shortened, or the file is rewound to the first data chunk when nothing is left. The out-of-line copy has no caller, and its name is inferred.

Parameters
nBytesThe largest read to queue.
Returns
The bytes queued, or 0.
Ghidra address:
NTSC-U/C: 0x005808e8
Ghidra address:
PAL: 0x005c3920

Member Data Documentation

◆ kTrackCount

int Rnd::AMovieSet::kTrackCount = 16
staticconstexpr

Tracks a file can describe, and so the handler slots.

◆ mFile

int Rnd::AMovieSet::mFile

The open file, or -1. +0x00

◆ mCircBuff

ACircBuff* Rnd::AMovieSet::mCircBuff

Ring buffer over the chunk data. +0x04

◆ mBuffer

char* Rnd::AMovieSet::mBuffer

Start of the loaded data, headers included. +0x08

◆ mBufferSize

int Rnd::AMovieSet::mBufferSize

Size of the data buffer. +0x0c

◆ mReserved10

unsigned char Rnd::AMovieSet::mReserved10[8]

◆ mTracks

Track Rnd::AMovieSet::mTracks[kTrackCount]

Track descriptions. +0x18

◆ mHandlers

ChunkHandler Rnd::AMovieSet::mHandlers[kTrackCount]

Handler per track. +0x2d8

◆ mHandlerData

void* Rnd::AMovieSet::mHandlerData[kTrackCount]

Value passed to each handler. +0x318

◆ mLoopTicks

int Rnd::AMovieSet::mLoopTicks

Tick offset the LOOP chunks have accumulated.

Public because the synth's sound bank starter at 0x00462908 sets it to the song tick directly. +0x358

◆ mLastTick

int Rnd::AMovieSet::mLastTick

Tick of the previous Update(). +0x35c

◆ mDataStart

int Rnd::AMovieSet::mDataStart

File offset of the first data chunk. +0x360

◆ mReserved364

unsigned char Rnd::AMovieSet::mReserved364[4]

◆ mStreaming

int Rnd::AMovieSet::mStreaming

Non-zero when the file is streamed. +0x368

◆ mLoaded

int Rnd::AMovieSet::mLoaded

Non-zero once ParseHeader() has succeeded. +0x36c

◆ mFileLength

int Rnd::AMovieSet::mFileLength

Uncompressed length of the file. +0x370

◆ mFileOffset

int Rnd::AMovieSet::mFileOffset

File offset the next streaming read starts at. +0x374

◆ mAsyncHandle

int Rnd::AMovieSet::mAsyncHandle

Identifier of the outstanding read, or 0. +0x378

◆ mSoundHold

int Rnd::AMovieSet::mSoundHold

Updates left before another sound chunk may play. +0x37c


The documentation for this class was generated from the following file: