102 Dalmatians: Puppies to the Rescue
Decompilation Source Reference | GitLab repository
Loading...
Searching...
No Matches
replay.c
Go to the documentation of this file.
1/* Recovered game implementation; original addresses identify provenance. */
5#include "pcdogs/game/types.h"
10#include <string.h>
11
12// Original pcdogs.exe: 0x42d380
13// Loads the selected bonus replay into an allocated header and fixed-size input buffer, cycling through six replay choices. A null source only queries whether a replay buffer already exists.
14bool Replay_LoadBonusReplay(uint8_t const *bonus_replay_source)
15{
16 if (!bonus_replay_source)
18
21
23 {
26 return false;
27 }
28
29 int32_t level = g_bonusReplayRecordIndices[(int32_t)g_bonusReplayIndex];
32 g_bonusReplayBuffer->random_seed = 1;
34
35 const uint8_t *source = bonus_replay_source + level * REPLAY_SOURCE_RECORD_BYTES + REPLAY_SOURCE_INPUT_OFFSET;
36 uint8_t *destination = (uint8_t *)g_bonusReplayBuffer->records;
37 /* The original advances both pointers one DWORD at a time. */
38 for (size_t offset = 0; offset < REPLAY_INPUT_BYTES; offset += sizeof(uint32_t))
39 {
40 uint32_t word;
41 memcpy(&word, source + offset, sizeof(word));
42 memcpy(destination + offset, &word, sizeof(word));
43 }
44 return g_bonusReplayBuffer != NULL;
45}
46
47// Original pcdogs.exe: 0x4430b0
48// Selects replay input records, saves and reseeds random state, and enables playback when both header and records are present.
50{
51 struct Replay_Header32 *replay_header = g_bonusReplayBuffer;
52
53 if (!replay_header)
54 return;
55
56 g_demoReplayInputPtr = replay_header->records;
58 {
61 }
62}
63
64// Original pcdogs.exe: 0x4430f0
65// Disables playback and, when a replay allocation exists, frees it and restores saved random state. The input cursor is not cleared, and stopping again without a buffer does not restore random state again.
#define REPLAY_INPUT_BYTES
Definition constants.h:62
#define REPLAY_SOURCE_RECORD_BYTES
Definition constants.h:60
#define GAME_TRANSITION_BONUS_REPLAY
Definition constants.h:27
#define REPLAY_SOURCE_INPUT_OFFSET
Definition constants.h:61
#define REPLAY_BUFFER_BYTES
Definition constants.h:59
#define REPLAY_BONUS_COUNT
Definition constants.h:49
#define GAME_TRANSITION_REPLAY_PLAYBACK
Definition constants.h:21
#define Game_FrameTransitionFlags
Definition globals.h:47
#define g_demoReplayInputPtr
Definition globals.h:41
#define g_bonusReplayBuffer
Definition globals.h:53
#define g_demoReplaySavedRandomSeed
Definition globals.h:50
#define g_bonusReplayIndex
Definition globals.h:20
#define g_bonusReplayRecordIndices
Definition globals.h:17
@ LEVEL_CAMPAIGN_FIRST
Definition constants.h:85
#define g_levelIndex
Definition globals.h:100
uint32_t Math_SetRandomSeed(uint32_t seed)
void Replay_StartPlayback()
Definition replay.c:49
void Replay_StopPlayback()
Definition replay.c:66
bool Replay_LoadBonusReplay(uint8_t const *bonus_replay_source)
Definition replay.c:14
void * CRT_malloc(uint32_t size)
Definition heap.c:16
void CRT_free(void *ptr)
Definition heap.c:164
struct Replay_InputRecord32 * records
Definition types.h:71
uint32_t random_seed
Definition types.h:70