resonance 1.0.1
Loading...
Searching...
No Matches
Sch::TimeClock Class Reference

Time base a scheduler measures its due times against, and the base class of Sch::TickClock. More...

#include <timeclock.h>

Inheritance diagram for Sch::TimeClock:
Collaboration diagram for Sch::TimeClock:

Public Member Functions

 TimeClock (Scheduler *pWatchdog)
void SetOrigin (long long nNanoseconds)
 Fix the origin of the time base.
long long Now ()
 Report the current time.
void Pause ()
 Stop the time base at its current reading.
void Resume ()
 Restart the time base from the reading Pause() stopped it at.
void Post (Sch::Command *pCommand, Sch::Time tick, CmdID &id, int bRecordable, int bDelta)
 Queue a command, choosing between the absolute and the delta path.
void Withdraw (const CmdID &id)
 Withdraw the first wrapper queued under a handle.
void PostIn (Sch::Command *pCommand, Sch::Time tick, CmdID &id, int bRecordable)
 Queue a command a distance from now, under a handle the caller retains.
void PostIn (Sch::Command *pCommand, Sch::Time tick)
 Queue a command a distance from now, discarding the handle.

Public Attributes

long long mNegatedOrigin
 The origin, negated, in nanoseconds.
long long mPausedNs
 The reading Now() reports while no origin is set, in nanoseconds.
int mHasOrigin
 Non-zero while the time base runs against the scheduler.
Scheduler * mWatchdog
 The scheduler whose current time the readings follow.

Detailed Description

Time base a scheduler measures its due times against, and the base class of Sch::TickClock.

The class is not polymorphic and has no RTTI, and no literal in the retail images identifies it. Its name comes from the debugging symbols of the North American demo release. The demo's constructor and destructor have the same instructions as this class's. This 0x18-byte object is the base of Sch::TickClock, and the bodies at 0x004a7828, 0x004a7848, 0x004a7878, and 0x004a77c0 are single bodies shared between the two.

The origin is stored negated and may be set only once, so a second SetOrigin() is ignored. Every member is public, because Sch::TickClock reads each one directly and the image has no accessor.

Constructor & Destructor Documentation

◆ TimeClock()

Sch::TimeClock::TimeClock ( Scheduler * pWatchdog)
Parameters
pWatchdogThe scheduler these readings belong to.
Ghidra address:
NTSC-U/C: 0x004a7780
Ghidra address:
PAL: 0x004e5890

Member Function Documentation

◆ SetOrigin()

void Sch::TimeClock::SetOrigin ( long long nNanoseconds)

Fix the origin of the time base.

The first call wins. Every later call is ignored.

Parameters
nNanosecondsThe reading to treat as zero.
Ghidra address:
NTSC-U/C: 0x004a7828
Ghidra address:
PAL: 0x004e5938

◆ Now()

long long Sch::TimeClock::Now ( )

Report the current time.

Before an origin is set the reading is mPausedNs. Afterwards it is the scheduler's most recent due tick relative to the origin.

Returns
The time in nanoseconds.
Ghidra address:
NTSC-U/C: 0x004a77c0
Ghidra address:
PAL: 0x004e58d0

◆ Pause()

void Sch::TimeClock::Pause ( )

Stop the time base at its current reading.

Clears mHasOrigin and stores the reading Now() would have reported in mPausedNs. Now() reports mPausedNs from then on. Does nothing while mHasOrigin is already clear. GrooveWorld::StopLevel() at 0x0018ec90 calls it on the song clock. The title is inferred.

Ghidra address:
NTSC-U/C: 0x004a7878
Ghidra address:
PAL: 0x004e5988

◆ Resume()

void Sch::TimeClock::Resume ( )

Restart the time base from the reading Pause() stopped it at.

Sets mHasOrigin and stores the origin that makes Now() continue from mPausedNs. Does nothing while mHasOrigin is already set. GrooveWorld::StartPlay() calls it on the song clock. The title is inferred.

Ghidra address:
NTSC-U/C: 0x004a7848
Ghidra address:
PAL: 0x004e5958

◆ Post()

void Sch::TimeClock::Post ( Sch::Command * pCommand,
Sch::Time tick,
CmdID & id,
int bRecordable,
int bDelta )

Queue a command, choosing between the absolute and the delta path.

A non-zero bDelta takes the delta path, which resolves the due tick against the later of the scheduler's current time and its clock. A zero bDelta takes the absolute path, which subtracts this clock's origin instead and passes a zero recordable flag. Two facts place it on this class rather than on Sch::TickClock. The body reads only mNegatedOrigin and mWatchdog, and TimeTask posts through it on the plain timer that Globals::InitServices() builds.

Parameters
pCommandThe command to run.
tickThe tick the caller requests.
idThe handle to queue under, allocated when it is still -2.
bRecordableNon-zero for a post the recorded stream is to include. Recording writes such a post out and playback suppresses it, because the stream supplies it instead.
bDeltaNon-zero to treat tick as a distance from now.
Ghidra address:
NTSC-U/C: 0x004a78b8
Ghidra address:
PAL: 0x004e59c8

◆ Withdraw()

void Sch::TimeClock::Withdraw ( const CmdID & id)

Withdraw the first wrapper queued under a handle.

Forwards a copy of the handle to Scheduler::WithdrawByCmdID(). The body reads only mWatchdog.

Parameters
idThe handle to withdraw.
Ghidra address:
NTSC-U/C: 0x004a79d0
Ghidra address:
PAL: 0x004e5ae0

◆ PostIn() [1/2]

void Sch::TimeClock::PostIn ( Sch::Command * pCommand,
Sch::Time tick,
CmdID & id,
int bRecordable )

Queue a command a distance from now, under a handle the caller retains.

The body reads only mWatchdog, which is what places it on this class rather than on Sch::TickClock. GameRecorder::ScheduleEnd() calls it on the plain Sch::TimeClock that Globals creates.

Parameters
pCommandThe command to run.
tickThe distance from now.
idThe handle to queue under.
bRecordableNon-zero for a post the recorded stream is to include.
Ghidra address:
NTSC-U/C: 0x004a60a0
Ghidra address:
PAL: 0x004e4140

◆ PostIn() [2/2]

void Sch::TimeClock::PostIn ( Sch::Command * pCommand,
Sch::Time tick )

Queue a command a distance from now, discarding the handle.

The body reads only mWatchdog, as the keyed overload does.

Parameters
pCommandThe command to run.
tickThe distance from now.
Ghidra address:
NTSC-U/C: 0x004a6178
Ghidra address:
PAL: 0x004e4218

Member Data Documentation

◆ mNegatedOrigin

long long Sch::TimeClock::mNegatedOrigin

The origin, negated, in nanoseconds.

Sch::TickClock::PostAt() and both PostAtSongTick() overloads subtract it to express a due time in the scheduler's frame.

◆ mPausedNs

long long Sch::TimeClock::mPausedNs

The reading Now() reports while no origin is set, in nanoseconds.

Sch::TickClock::SetSongTick() writes it.

◆ mHasOrigin

int Sch::TimeClock::mHasOrigin

Non-zero while the time base runs against the scheduler.

◆ mWatchdog

Scheduler* Sch::TimeClock::mWatchdog

The scheduler whose current time the readings follow.

Sch::TickClock::PostAt() and both PostAtSongTick() overloads queue through it.


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