coastline 0.0.4
Loading...
Searching...
No Matches
replay.h File Reference

The ghost recording a race replays. More...

#include <PR/ultratypes.h>
#include "common/input.h"
#include "common/recordingformat.h"
#include "common/rle.h"
#include "common/vehicle.h"
#include "common/vehiclemodel.h"
Include dependency graph for replay.h:

Go to the source code of this file.

Classes

struct  LastLapBuffer
 The last lap of a player: the input of each local player over it, and a snapshot of the race at its start, which the instant replay plays from. More...
struct  SaveField
 A block of variables a snapshot saves, in a list ending in a NULL block. More...

Macros

#define ROM_GHOST_RECORDING   ((u32)_ghostRecordingSegmentRomStart)
 The cartridge offset of the ghost recording, which the race after the splash screens replays.
#define RECORDING_CAPACITY   0xDE5C
 The size of the buffer a player's input is recorded into.
#define LAST_LAP_RECORDING_SIZE   0x3840
 The bytes of the recording of each local player's input over the last lap.
#define g_aLastLapBuffers   ((LastLapBuffer *)g_aVehicleModels)
 Last-lap buffers share vehicle-model storage and descend through slots by local-player index.
#define LAST_LAP_FIRST_SLOT   3
 The slot of g_aLastLapBuffers of the first player; the others count down from it.
#define PAUSED_CLOCK_STATE_SIZE   0x40
 The bytes of the paused clock state.

Functions

s32 SerializeSaveData (SaveField *fields, u8 *buffer, s32 capacity, s32 offset)
 Copy the variables of a list one after another into a buffer, and report when they overflow it.
s32 DeserializeSaveData (SaveField *fields, u8 *buffer, s32 offset)
 Copy the variables of a list back from a buffer SerializeSaveData() filled.
void SaveRaceSnapshot (LastLapBuffer *buffer)
 Take a snapshot of the race into the buffer of a last lap.
void RestoreRaceSnapshot (LastLapBuffer *buffer)
 Restore the state of the race from a snapshot SaveLastLapSnapshot() took.
void SaveLastLapSnapshot (Vehicle *vehicle)
 At the start of the last lap, give each local player a buffer to record the lap into and take a snapshot of the race, which the instant replay starts from.
void RestoreReplayKeyframeState (void)
 In the demo, restore the race from a keyframe when the recording of the first vehicle reaches one, then place the trackside camera of the first vehicle anew.

Variables

u8 g_abGhostRecording []
 The recorded input of the ghost.
u32 g_dwGhostRecordingSize
 The bytes of g_abGhostRecording in use.
u8 g_abPlaybackRecording []
 The buffer the recording a race replays is copied to.
u8 g_aabInputRecordings [][0xF000]
 The buffers the input of each local player is recorded into, 0xF000 bytes apart.
s32 g_dwBestReplayLength
 The player whose recording the instant replay plays, and the length of that recording.
s32 g_dwBestReplayPlayer
 The player whose recording the instant replay plays.
u8 * g_apReplayGhostPtrs []
 The recordings the instant replay gives each local player, and their lengths.
s32 g_adwReplayGhostSizes []
 The lengths of the instant replay recordings of the local players, in bytes.
SaveField g_aRaceSnapshotFields []
 The variables a snapshot of the race saves: the vehicles, the racers, the clocks, the sounds and more.
SaveField g_aPausedClockFields []
 The random seed and the clocks a pause keeps.
u8 g_abPausedClockState [PAUSED_CLOCK_STATE_SIZE]
 Where a pause keeps them.
s32 g_dwReplayKeyframeFrameCount
 The frames RestoreReplayKeyframeState() has run.
SaveField g_aReplayKeyframeDescTable1 []
 The variables a keyframe of the recording of the demo restores, in the order of the keyframe.
SaveField g_aReplayKeyframeDescTable2 []
 The second group of variables restored from a demo keyframe.
SaveField g_aReplayKeyframeDescTable3 []
 The third group of variables restored from a demo keyframe.

Detailed Description

The ghost recording a race replays.

Macro Definition Documentation

◆ ROM_GHOST_RECORDING

#define ROM_GHOST_RECORDING   ((u32)_ghostRecordingSegmentRomStart)

The cartridge offset of the ghost recording, which the race after the splash screens replays.

◆ RECORDING_CAPACITY

#define RECORDING_CAPACITY   0xDE5C

The size of the buffer a player's input is recorded into.

◆ LAST_LAP_RECORDING_SIZE

#define LAST_LAP_RECORDING_SIZE   0x3840

The bytes of the recording of each local player's input over the last lap.

◆ g_aLastLapBuffers

#define g_aLastLapBuffers   ((LastLapBuffer *)g_aVehicleModels)

Last-lap buffers share vehicle-model storage and descend through slots by local-player index.

◆ LAST_LAP_FIRST_SLOT

#define LAST_LAP_FIRST_SLOT   3

The slot of g_aLastLapBuffers of the first player; the others count down from it.

◆ PAUSED_CLOCK_STATE_SIZE

#define PAUSED_CLOCK_STATE_SIZE   0x40

The bytes of the paused clock state.

Function Documentation

◆ SerializeSaveData()

s32 SerializeSaveData ( SaveField * fields,
u8 * buffer,
s32 capacity,
s32 offset )

Copy the variables of a list one after another into a buffer, and report when they overflow it.

Parameters
fieldsThe list of variables.
bufferThe buffer.
capacityThe size of the buffer in bytes.
offsetThe bytes past the start of each variable to copy from.
Returns
The bytes written.
Ghidra address:
EUR: 0x8022c144
Ghidra address:
JPN: 0x8022b8fc

◆ DeserializeSaveData()

s32 DeserializeSaveData ( SaveField * fields,
u8 * buffer,
s32 offset )

Copy the variables of a list back from a buffer SerializeSaveData() filled.

Parameters
fieldsThe list of variables.
bufferThe buffer.
offsetThe bytes past the start of each variable to copy to.
Returns
The bytes read.
Ghidra address:
EUR: 0x8022c1f8
Ghidra address:
JPN: 0x8022b9b0

◆ SaveRaceSnapshot()

void SaveRaceSnapshot ( LastLapBuffer * buffer)

Take a snapshot of the race into the buffer of a last lap.

Parameters
bufferThe buffer of the last lap.
Ghidra address:
USA: 0x8022aed8
Ghidra address:
Asia: 0x8022AA28
Ghidra address:
EUR: 0x8022c274
Ghidra address:
JPN: 0x8022ba2c
Ghidra address:
BRD3D: 0x10067940
Ghidra address:
BRGlide: 0x100609b0

◆ RestoreRaceSnapshot()

void RestoreRaceSnapshot ( LastLapBuffer * buffer)

Restore the state of the race from a snapshot SaveLastLapSnapshot() took.

Parameters
bufferThe buffer of the last lap holding the snapshot.
Ghidra address:
USA: 0x8022af08
Ghidra address:
Asia: 0x8022AA58
Ghidra address:
EUR: 0x8022c2ac
Ghidra address:
JPN: 0x8022ba64
Ghidra address:
BRD3D: 0x10067960
Ghidra address:
BRGlide: 0x100609d0

◆ SaveLastLapSnapshot()

void SaveLastLapSnapshot ( Vehicle * vehicle)

At the start of the last lap, give each local player a buffer to record the lap into and take a snapshot of the race, which the instant replay starts from.

Parameters
vehicleThe vehicle that reached the lap.
Ghidra address:
USA: 0x8022af90
Ghidra address:
Asia: 0x8022AAE0
Ghidra address:
EUR: 0x8022c4a0
Ghidra address:
JPN: 0x8022bc58

◆ RestoreReplayKeyframeState()

void RestoreReplayKeyframeState ( void )

In the demo, restore the race from a keyframe when the recording of the first vehicle reaches one, then place the trackside camera of the first vehicle anew.

Ghidra address:
EUR: 0x8022c340
Ghidra address:
JPN: 0x8022baf8

Variable Documentation

◆ g_abGhostRecording

u8 g_abGhostRecording[]
extern

The recorded input of the ghost.

A Controller Pak or the cartridge fills it.

Ghidra address:
USA: 0x80307f00
Ghidra address:
Asia: 0x803079C0
Ghidra address:
EUR: 0x80309bf0
Ghidra address:
JPN: 0x80308630

◆ g_dwGhostRecordingSize

u32 g_dwGhostRecordingSize
extern

The bytes of g_abGhostRecording in use.

Ghidra address:
USA: 0x80270784
Ghidra address:
Asia: 0x802702D4
Ghidra address:
EUR: 0x80272754
Ghidra address:
JPN: 0x80272204

◆ g_abPlaybackRecording

u8 g_abPlaybackRecording[]
extern

The buffer the recording a race replays is copied to.

The link script places it, below the frame buffers.

Ghidra address:
BRD3D: 0x117554f0
Ghidra address:
BRGlide: 0x11778850

◆ g_aabInputRecordings

u8 g_aabInputRecordings[][0xF000]
extern

The buffers the input of each local player is recorded into, 0xF000 bytes apart.

The link script places them, below and over the frame buffers.

Ghidra address:
BRD3D: 0x117644f0
Ghidra address:
BRGlide: 0x11787850

◆ g_dwBestReplayLength

s32 g_dwBestReplayLength
extern

The player whose recording the instant replay plays, and the length of that recording.

Ghidra address:
USA: 0x80315e3c
Ghidra address:
Asia: 0x803158FC
Ghidra address:
EUR: 0x80317b2c
Ghidra address:
JPN: 0x8031656c
Ghidra address:
BRD3D: 0x106909c8
Ghidra address:
BRGlide: 0x105ccb70

◆ g_dwBestReplayPlayer

s32 g_dwBestReplayPlayer
extern

The player whose recording the instant replay plays.

Ghidra address:
USA: 0x80315e40
Ghidra address:
Asia: 0x80315900
Ghidra address:
EUR: 0x80317b30
Ghidra address:
JPN: 0x80316570
Ghidra address:
BRD3D: 0x10680668
Ghidra address:
BRGlide: 0x105bc810

◆ g_apReplayGhostPtrs

u8* g_apReplayGhostPtrs[]
extern

The recordings the instant replay gives each local player, and their lengths.

Ghidra address:
USA: 0x80315e48
Ghidra address:
Asia: 0x80315908
Ghidra address:
EUR: 0x80317b38
Ghidra address:
JPN: 0x80316578

◆ g_adwReplayGhostSizes

s32 g_adwReplayGhostSizes[]
extern

The lengths of the instant replay recordings of the local players, in bytes.

Ghidra address:
USA: 0x80315e58
Ghidra address:
Asia: 0x80315918
Ghidra address:
EUR: 0x80317b48
Ghidra address:
JPN: 0x80316588

◆ g_aRaceSnapshotFields

SaveField g_aRaceSnapshotFields[]
extern

The variables a snapshot of the race saves: the vehicles, the racers, the clocks, the sounds and more.

Ghidra address:
USA: 0x8028bb0c
Ghidra address:
Asia: 0x8028B65C
Ghidra address:
EUR: 0x8028ddc0
Ghidra address:
JPN: 0x8028d7f0
Ghidra address:
BRD3D: 0x100b39b0

◆ g_aPausedClockFields

SaveField g_aPausedClockFields[]
extern

The random seed and the clocks a pause keeps.

Ghidra address:
USA: 0x8028bbc4
Ghidra address:
Asia: 0x8028B714
Ghidra address:
EUR: 0x8028de78
Ghidra address:
JPN: 0x8028d8a8
Ghidra address:
BRD3D: 0x100b3a68
Ghidra address:
BRGlide: 0x100b3270

◆ g_abPausedClockState

u8 g_abPausedClockState[PAUSED_CLOCK_STATE_SIZE]
extern

Where a pause keeps them.

Ghidra address:
USA: 0x8034e570
Ghidra address:
Asia: 0x8034E020
Ghidra address:
EUR: 0x80326800
Ghidra address:
JPN: 0x80325430
Ghidra address:
BRD3D: 0x10af9848
Ghidra address:
BRGlide: 0x10b1cba8

◆ g_dwReplayKeyframeFrameCount

s32 g_dwReplayKeyframeFrameCount
extern

The frames RestoreReplayKeyframeState() has run.

Ghidra address:
EUR: 0x8028dec0
Ghidra address:
JPN: 0x8028d8f0

◆ g_aReplayKeyframeDescTable1

SaveField g_aReplayKeyframeDescTable1[]
extern

The variables a keyframe of the recording of the demo restores, in the order of the keyframe.

Ghidra address:
EUR: 0x8028e2cc
Ghidra address:
JPN: 0x8028dcfc

◆ g_aReplayKeyframeDescTable2

SaveField g_aReplayKeyframeDescTable2[]
extern

The second group of variables restored from a demo keyframe.

Ghidra address:
EUR: 0x8028e22c
Ghidra address:
JPN: 0x8028dc5c

◆ g_aReplayKeyframeDescTable3

SaveField g_aReplayKeyframeDescTable3[]
extern

The third group of variables restored from a demo keyframe.

Ghidra address:
EUR: 0x8028dec4
Ghidra address:
JPN: 0x8028d8f4