resonance 1.0.1
Loading...
Searching...
No Matches
Sch::Command Class Referenceabstract

Base of every action the scheduler performs on behalf of another subsystem. More...

#include <command.h>

Inheritance diagram for Sch::Command:
Collaboration diagram for Sch::Command:

Public Member Functions

 Command ()
 Construct a command that the scheduler has not queued.
virtual ~Command ()
 Release the command.
virtual int CmdID ()=0
 Report the identifier this class streams itself under.
virtual void Execute ()=0
 Perform the action this command stands for.
virtual void Print (std::ostream &stream)
 Write a description of this command to a diagnostic stream.
virtual void saveGuts (OBStream &stream) const
 Write this command's payload.
virtual void restoreGuts (IBStream &stream)
 Read this command's payload back.
Public Member Functions inherited from Attachment
 Attachment ()
virtual ~Attachment ()
int Release ()
 Give back one reference and destroy the object once the last one is gone.
virtual void Destroy ()
 Destroy the object.

Static Public Member Functions

static Command * NewCommand (int nCmdID)
 Produce a command of the identified class through the factory list.
Static Public Member Functions inherited from Attachment
static void ReleaseIfSet (Attachment *pAttachment)
 Give back one reference to an object that may be null.

Public Attributes

int mQueued
 Non-zero while the command sits in the scheduler's queue.
Public Attributes inherited from Attachment
int mRefs

Detailed Description

Base of every action the scheduler performs on behalf of another subsystem.

Its RTTI descriptor is at 0x008f0950. It derives publicly from Attachment at offset 0. The base subobject supplies the reference count at +0x00 and the vtable pointer at +0x04, this class adds one word at +0x08, and an instance is 0x0c bytes. Every derived class starts its own data at +0x0c. Three independent measurements agree on that boundary. The inlined construction at 0x0013a9a8 allocates 0x10 bytes and writes the reference count, the word at +0x08, the vtable pointer, and one derived pointer at +0x0c; ExitCmd::saveGuts() at 0x00194a50 streams +0x0c, +0x10, and +0x14; and GsPeriodical::PeriodicalCmd::Execute() at 0x001b4820 reads +0x0c and +0x10. The layout closes arithmetically with no unaccounted byte.

The vtable at 0x008288c0 runs eight entries and then a zero entry. The interface is therefore complete rather than partial:

Twenty-four classes derive from this one. Five are ordinary classes, ControllerCmd, SequencerCmd, LocalPlayerCmd, DoGameSystemPlayCmd, and EndRecordingCmd. The other nineteen are file-local, and their descriptors identify the translation unit that defines each one, among them AppTickTask.cpp, AppTimeTask.cpp, AppActiveFilter.cpp, CmdPostScript.cpp, ForceFeedbackMgr.cpp, GsAutoRiffer.cpp, GsNotePlayer.cpp, GsPeriodical.cpp, and GsPhraseMgr.cpp. Both slot 3 and slot 4 are pure here because every one of the twenty-four supplies its own body for each.

Both saveGuts() and restoreGuts() bodies stream one field after another in the same order through the two stream interfaces. CmdID() follows from the static member ControllerCmd::sCmdID and from the two diagnostics Streamed Command ID ld and Cannot find ID ld in Command Factory List; every slot-3 body returns one per-class word. The image initialises four of the twenty-four words to a non-zero identifier, and each of the four has a single reader and no writer: ControllerCmd 2 at 0x0067f238, DoGameSystemPlayCmd 4 at 0x006682b8, EndRecordingCmd 6 at 0x006693e8, and ExitCmd 7 at 0x0067f24c. The other twenty words are initialised to zero. Execute() and Print() are inferred from their bodies alone, and no string in the image identifies either.

Four classes register a factory, and recorded demos load their commands through the registered factories. ControllerCmd, DoGameSystemPlayCmd, EndRecordingCmd, and ExitCmd register under their identifiers. The other twenty-two Sch::CommandFactory call sites pass a zero identifier, for which the constructor returns without an insertion.

Constructor & Destructor Documentation

◆ Command()

Sch::Command::Command ( )
inline

Construct a command that the scheduler has not queued.

The compiler inlined this body into every derived constructor. No address of its own survives. The write of zero to mQueued is visible at 0x0013a9c4 among others.

◆ ~Command()

virtual Sch::Command::~Command ( )
virtual

Release the command.

The body restores this class's vtable pointer and runs the Attachment destructor, and it touches no member of its own.

Ghidra address:
NTSC-U/C: 0x00539ef8
Ghidra address:
PAL: 0x00579828

Member Function Documentation

◆ CmdID()

virtual int Sch::Command::CmdID ( )
pure virtual

Report the identifier this class streams itself under.

Every derived body returns one per-class word. A zero result marks the command as non-serializable, and operator<< reports that case through Fatal().

Returns
The identifier.

Implemented in ControllerCmd, DoGameSystemPlayCmd, EndRecordingCmd, GamerCmd, LocalPlayerCmd, and SequencerCmd.

◆ Execute()

virtual void Sch::Command::Execute ( )
pure virtual

Perform the action this command stands for.

Sch::TimedCommand::Run() dispatches this slot and discards nothing, because every derived body returns no value.

Implemented in ControllerCmd, DoGameSystemPlayCmd, EndRecordingCmd, GamerCmd, LocalPlayerCmd, and SequencerCmd.

◆ Print()

virtual void Sch::Command::Print ( std::ostream & stream)
virtual

Write a description of this command to a diagnostic stream.

The body here writes the literal {Command} and each derived body writes its own literal.

Parameters
streamThe stream to write to.
Ghidra address:
NTSC-U/C: 0x0053a088
Ghidra address:
PAL: 0x005799b8

Reimplemented in ControllerCmd, DoGameSystemPlayCmd, EndRecordingCmd, GamerCmd, LocalPlayerCmd, and SequencerCmd.

◆ saveGuts()

virtual void Sch::Command::saveGuts ( OBStream & stream) const
virtual

Write this command's payload.

The body here is a single jr ra. The base therefore does not write a payload.

Parameters
streamThe stream to write to.
Ghidra address:
NTSC-U/C: 0x00539f20
Ghidra address:
PAL: 0x00579850

Reimplemented in ControllerCmd, DoGameSystemPlayCmd, EndRecordingCmd, and LocalPlayerCmd.

◆ restoreGuts()

virtual void Sch::Command::restoreGuts ( IBStream & stream)
virtual

Read this command's payload back.

The body here is a single jr ra. The base therefore does not read a payload.

Parameters
streamThe stream to read from.
Ghidra address:
NTSC-U/C: 0x00539f28
Ghidra address:
PAL: 0x00579858

Reimplemented in ControllerCmd, DoGameSystemPlayCmd, and LocalPlayerCmd.

◆ NewCommand()

Command * Sch::Command::NewCommand ( int nCmdID)
static

Produce a command of the identified class through the factory list.

The compiler inlined this body into operator>>, and the standalone copy at the address below has no caller in the image. An unregistered identifier produces a null result, and operator>> reports it through Fatal().

Parameters
nCmdIDThe identifier to construct for.
Returns
The new command, or null when the identifier is zero or unregistered.
Ghidra address:
NTSC-U/C: 0x00539fe8
Ghidra address:
PAL: 0x00579918

Member Data Documentation

◆ mQueued

int Sch::Command::mQueued

Non-zero while the command sits in the scheduler's queue.

Public because the scheduler writes it from outside the hierarchy and the image exposes no accessor, and it writes it through the Sch::TimedCommand that refers to the command rather than through the command itself. Three writes exist. The delta queueing path writes 1 at 0x004ac768, the stream playback path writes 1 at 0x004ac7c8 before it queues, and the run loop writes 0 at 0x004aae84 as soon as Sch::TimedCommand::Run() has returned. The absolute queueing path at 0x004ac608 does not write it at all. No instruction in the image reads the member. The title is therefore inferred from the three writes rather than from a test.

+0x08


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