resonance 1.0.1
Loading...
Searching...
No Matches
GrooveWorld Class Reference

Owner of the world a game session runs in. More...

#include <grooveworld.h>

Inheritance diagram for GrooveWorld:
Collaboration diagram for GrooveWorld:

Public Member Functions

 GrooveWorld (Application *pApp, GameStats *pStats)
 Construct an empty world.
virtual ~GrooveWorld ()
virtual void DispatchPriv (Message *pMsg)
 Route a CripplePacket to the delayer and a BumpPacket to the track selector.
virtual void OnControllerReading (int nTag, int nPadIndex, int nButton, float flValue)
 Report a controller reading.
void ReplayControllerReading (const MetControllerReading *pReading)
 Hand one recorded controller reading to the input map.
void PostExit (int nMode, int bContinueJukebox, int bRestart)
 Queue an ExitCmd built from three values.
void Exit (int nMode, int bContinueJukebox, int bRestart)
 Leave the game in one of three modes.
void OnCripplePacket (Message *pMsg)
 Hand a CripplePacket to the delayer.
void OnBumpPacket (Message *pMsg)
 Hand a BumpPacket to the track selector.
void SetNetIO (MsgSink *pSink, MsgSource *pSource)
 Install the sink and the source the gamer is wired to.
void StartLoad (const HxStr &path)
 Create the level and begin reading its MIDI file asynchronously.
int IsLoadDone ()
 Report whether the MIDI file read has completed.
void FinishLoad ()
 Convert the MIDI file into the level and adopt the level's tempo map.
void PrepareLevel ()
 Prepare the loaded level for play.
void StartPlay ()
 Starts play on a prepared level.
void AddNetPlayer (int nId, int nUnused, const HxStr &name, const FreqAppearance *pAppearance)
 Create a remote player and append it to mPlayers.
void AddLocalPlayer (int nId, int nInputSlot, int nUnused, const HxStr &colorName, MetPersonaData *pPersona)
 Create a player this console drives and append it to mPlayers and mLocalPlayers.
void RemovePlayer (int nId)
 Remove the first player with an identifier from mPlayers, without destroying it.
void KillRenderer ()
 Detach the renderer from every source that feeds it and delete it.
void SavePhrases (OBStream &stream)
 Write the phrase database of every score track graph.
void LoadPhrases (IBStream &stream, int bClearOwners)
 Read the phrase database of every score track graph back.
void EnableInput ()
 Enable every entry of the input map.
void PostFinish ()
 Queue the finish exit, mode 1, with the current mContinueJukebox.
void PostQuit ()
 Queue the quit exit, mode 2.
void PostRestart ()
 Queue the restart exit, mode 3, with mRestart set.
void Shutdown ()
 Tear the world down ahead of destruction.
Sch::TickClock * GetSongClock ()
 Report the world's song clock.
PlayMap * GetPlayMap ()
 Report the level's play map.
LevelData * GetLevel ()
RendererBase * GetRendererSink ()
 Report the renderer's RendererBase half.
void MarkStatsFlag ()
 Set the statistics word at +0x14 of mStats to 1.
void DisplayText (const HxStr &text)
 Show a line of text on the track displays.
HxStr GetSongName () const
 Report the jukebox song title.
Public Member Functions inherited from MsgSink
void * operator new (size_t nSize)
 Allocate a sink from the tagged heap under the tag "MsgSink".
void operator delete (void *pBlock)
 Release a sink to the tagged heap.
virtual ~MsgSink ()
virtual void Dispatch (Message *pMsg)
 Accept a message.
Public Member Functions inherited from RawController
virtual ~RawController ()

Public Attributes

InputMap * mInputMap
 The input map of the world's players.
Gamer * mGamer
 The scoring state.
ForceFeedbackMgr * mForceFeedback
 Vibration driver of the controllers.
std::vector< ScoreTrackGraph * > mTrackGraphs
std::vector< Player * > mPlayers
 Every player in the world, in slot order.
std::vector< Player * > mLocalPlayers
 The players this console drives.
int mIsPlayback
 Non-zero while the world plays back a recording.
int mIsTutorial
 Non-zero in a tutorial level, from the tutorial configuration flag 0x3a1.
HxStr mSongName
 Song title shown in jukebox mode.
int mContinueJukebox
 Non-zero while a jukebox session goes on to its next song.

Friends

class InputPoller

Detailed Description

Owner of the world a game session runs in.

Its RTTI descriptor is at 0x008eff70. It has MsgSink as a public base at offset 0 and RawController as a public base at +0x04. The allocation in GameManagerImpl::CreateWorld() fixes the object at 0xbc bytes. The tagged release at 0x00194d5c records the translation unit as GrooveWorld.cpp with line 302. ControllerCmd and the file-local FuncCmd and ExitCmd share the unit.

Two vtables belong to the class, and the secondary one precedes the primary one in memory. The RawController subobject addresses 0x007dc628, whose three entries each adjust this by -4, and the MsgSink subobject addresses 0x007dc648 with no adjustment. The primary table has four entries and a zero terminator at index 4, the type function at 0x001936f8, the destructor at 0x0018c368, the inherited MsgSink::Dispatch() at 0x00105158, and the DispatchPriv() override below. The secondary table has three entries and a zero terminator at index 3, the same type function and destructor followed by the RawController override below.

The member map comes from the constructor, the destructor, and BuildGraphs(). BuildGraphs() creates the input map, the track selector, the message joiner, the delayer, the gamer, the synthesiser, and the score track graphs, and each type is resolved through the table its constructor installs. mState steps through 1 while the level file loads, 2 once it is converted, 4 while the world accepts controller readings, and 6 on one shutdown path.

GameManagerImpl reads mInputMap from three of its handlers, writes mIsPlayback from its load path and its begin-game handler, and reads mIsTutorial from its unpause handler. 0x0018dc88 and 0x0018de38 both run once the world is ready.

Constructor & Destructor Documentation

◆ GrooveWorld()

GrooveWorld::GrooveWorld ( Application * pApp,
GameStats * pStats )

Construct an empty world.

It clears every member except the three load-buffer words, sets mContinueJukebox to 1, and creates the song clock on the application's Sch::Scheduler with no tempo map, the cheat detector over g_gameCheatSequences, and the force-feedback manager.

Parameters
pAppThe application.
pStatsThe game manager's statistics.
Ghidra address:
NTSC-U/C: 0x0018bef0
Ghidra address:
PAL: 0x00191998

◆ ~GrooveWorld()

virtual GrooveWorld::~GrooveWorld ( )
virtual
Ghidra address:
NTSC-U/C: 0x0018c368
Ghidra address:
PAL: 0x00191e40

Member Function Documentation

◆ DispatchPriv()

virtual void GrooveWorld::DispatchPriv ( Message * pMsg)
virtual

Route a CripplePacket to the delayer and a BumpPacket to the track selector.

Slot 3 of the primary table. Each identity is confirmed by the Type() slot that returns it, CripplePacket::Type() at 0x003f0cd8 and BumpPacket::Type() at 0x003f0ef8. A message matching neither is discarded. The two forwarders below are expanded inline here.

Parameters
pMsgThe message to route.
Ghidra address:
NTSC-U/C: 0x00195388
Ghidra address:
PAL: 0x0019b008

Implements MsgSink.

◆ OnControllerReading()

virtual void GrooveWorld::OnControllerReading ( int nTag,
int nPadIndex,
int nButton,
float flValue )
virtual

Report a controller reading.

Slot 2 of the secondary table.

The body returns at once unless mState is 4, and passes the reading to the cheat detector unless mIsTutorial is set. In jukebox mode a joystick press of button 10 clears mContinueJukebox and posts the finish exit, and every other reading is dropped. While a playback runs, a joystick press of any button below 100 posts the finish exit. Otherwise a joystick press of button 10 from a local pad posts the finish exit once a solo game song is complete, and queues a PauseGameSystemMsg and stops the riffs in any other case. Every remaining reading is queued as a ControllerCmd for replay, unless mIgnoreReadings is set outside a playback.

Parameters
nTagThe device tag, a four-character code.
nPadIndexThe controller that produced the reading, from 1.
nButtonThe button or axis control number.
flValueThe reading's value.
Ghidra address:
NTSC-U/C: 0x0018ed98
Ghidra address:
PAL: 0x001948e8

Implements RawController.

◆ ReplayControllerReading()

void GrooveWorld::ReplayControllerReading ( const MetControllerReading * pReading)

Hand one recorded controller reading to the input map.

It returns at once unless the input map exists and mState is 4, and otherwise builds a RawControllerMsg from the reading and the song clock's position on the stack and passes it to InputMap's MsgSink half. ControllerCmd::Execute() is the recovered caller.

Parameters
pReadingThe reading.
Ghidra address:
NTSC-U/C: 0x0018f078
Ghidra address:
PAL: 0x00194bc8

◆ PostExit()

void GrooveWorld::PostExit ( int nMode,
int bContinueJukebox,
int bRestart )

Queue an ExitCmd built from three values.

Does nothing unless mState is 4, and otherwise sets mState to 5. While a playback runs, or when bRestart is set, it runs Exit() at once. Otherwise it queues the ExitCmd on the application's watchdog timer with no delay, as a recordable command. PostFinish(), PostQuit(), and PostRestart() are the recovered callers.

Parameters
nModeThe value Exit() stores in mExitMode.
bContinueJukeboxThe value Exit() stores in mContinueJukebox.
bRestartThe value Exit() stores in mRestart.
Ghidra address:
NTSC-U/C: 0x0018e368
Ghidra address:
PAL: 0x00193e98

◆ Exit()

void GrooveWorld::Exit ( int nMode,
int bContinueJukebox,
int bRestart )

Leave the game in one of three modes.

It stores nMode in mExitMode, bContinueJukebox in mContinueJukebox, and bRestart in mRestart, stops the riffs and disables the input map, and sends a GameOverMsg to the delayer. The fade is 5000 milliseconds in jukebox mode, 3000 for the finish exit or a running playback, and 1000 otherwise, and the screen fade sent to the delayer runs 500 longer. The synthesiser fades out over the same length for the finish exit or a playback. Otherwise the notes stop at once, the watchdog takes a snapshot, and the song clock pauses. It then stops the force feedback and queues FinishSong() 600 milliseconds after the fade. ExitCmd::Execute() is the recovered caller.

Parameters
nModeThe exit mode.
bContinueJukeboxStored in mContinueJukebox.
bRestartStored in mRestart.
Ghidra address:
NTSC-U/C: 0x0018e478
Ghidra address:
PAL: 0x00193fb0

◆ OnCripplePacket()

void GrooveWorld::OnCripplePacket ( Message * pMsg)

Hand a CripplePacket to the delayer.

DispatchPriv() expands this body inline, and a second out-of-line copy sits at 0x00194b20.

Parameters
pMsgThe packet.
Ghidra address:
NTSC-U/C: 0x00195348
Ghidra address:
PAL: 0x0019afc8

◆ OnBumpPacket()

void GrooveWorld::OnBumpPacket ( Message * pMsg)

Hand a BumpPacket to the track selector.

DispatchPriv() expands this body inline.

Parameters
pMsgThe packet.
Ghidra address:
NTSC-U/C: 0x00194b50
Ghidra address:
PAL: 0x0019a7d0

◆ SetNetIO()

void GrooveWorld::SetNetIO ( MsgSink * pSink,
MsgSource * pSource )

Install the sink and the source the gamer is wired to.

The source is retained only in game mode 3, and a null pointer is stored otherwise. The image has no caller, and the network role of both is inferred from that game mode.

Parameters
pSinkThe sink stored in mNetSink.
pSourceThe source stored in mNetSource in game mode 3.
Ghidra address:
NTSC-U/C: 0x00194b80
Ghidra address:
PAL: 0x0019a800

◆ StartLoad()

void GrooveWorld::StartLoad ( const HxStr & path)

Create the level and begin reading its MIDI file asynchronously.

The read is submitted with no zone current, and mState becomes 1.

Parameters
pathThe file to read. An empty path reads g_szEmptyString.
Ghidra address:
NTSC-U/C: 0x00194bc8
Ghidra address:
PAL: 0x0019a848

◆ IsLoadDone()

int GrooveWorld::IsLoadDone ( )

Report whether the MIDI file read has completed.

A failed read is reported through Fatal().

Returns
Non-zero once the read is complete.
Ghidra address:
NTSC-U/C: 0x00194ca0
Ghidra address:
PAL: 0x0019a920

◆ FinishLoad()

void GrooveWorld::FinishLoad ( )

Convert the MIDI file into the level and adopt the level's tempo map.

The buffer the read filled is released, and mState becomes 2.

Ghidra address:
NTSC-U/C: 0x00194d00
Ghidra address:
PAL: 0x0019a980

◆ PrepareLevel()

void GrooveWorld::PrepareLevel ( )

Prepare the loaded level for play.

Resets the synthesiser through its slots 5 and 6, sets its jam flag from the play mode, runs BuildGraphs(), CreateRenderer(), and ConnectPlayers(), starts the streamed audio named by configuration code 0x3a5 when code 0x3a4 is set, and reads the start offset from code 0x38d as the negated song start clamped to the finite range. It then stores the tutorial flag, configuration code 0x3a1, in mIsTutorial and sets mState to 3. GameManagerImpl's FinishWorldLoad() and Load() call it after FinishLoad(). The title is inferred.

Ghidra address:
NTSC-U/C: 0x0018dc88
Ghidra address:
PAL: 0x001937a0

◆ StartPlay()

void GrooveWorld::StartPlay ( )

Starts play on a prepared level.

Disables the input map entries, flushes the watchdog, resumes mSongClock, starts the note destroyer, and sets mState to 4. It runs synthesiser slot 10 and builds the mIntroGraphs sequencers. Unless mIsTutorial is set, it posts EnableInput() half a quantum of the first track ahead of the song start, and it always posts StartSequencers() at the start. It sends a GameBeginMsg to the delayer and the joiner and a one-second FadeGameMsg that fades in to the delayer, resets the statistics for the player count, runs Player slot 11 on every player, and configures the force feedback manager (jukebox mode, mIsPlayback, the settings flag, the local player count, and a metronome 3200 ticks ahead). GameManagerImpl::StartPlay() is the only caller. The title is inferred.

Ghidra address:
NTSC-U/C: 0x0018de38
Ghidra address:
PAL: 0x00193968

◆ AddNetPlayer()

void GrooveWorld::AddNetPlayer ( int nId,
int nUnused,
const HxStr & name,
const FreqAppearance * pAppearance )

Create a remote player and append it to mPlayers.

Parameters
nIdThe player's identifier, passed to NetPlayer twice.
nUnusedNot read.
nameThe player's name.
pAppearanceThe appearance the player is drawn with.
Ghidra address:
NTSC-U/C: 0x00194de8
Ghidra address:
PAL: 0x0019aa68

◆ AddLocalPlayer()

void GrooveWorld::AddLocalPlayer ( int nId,
int nInputSlot,
int nUnused,
const HxStr & colorName,
MetPersonaData * pPersona )

Create a player this console drives and append it to mPlayers and mLocalPlayers.

The track is nId, except in solo mode, where it is configuration code 0x3a6 minus 1. The player receives the persona's appearance (MetPersonaData::mAppearance). The title is inferred.

Parameters
nIdThe player's identifier.
nInputSlotThe controller slot.
nUnusedNot read. GameManagerImpl::AddPersonaPlayers() passes the shuffled index.
colorNameThe player's colour name.
pPersonaThe persona the player plays as.
Ghidra address:
NTSC-U/C: 0x0018c600
Ghidra address:
PAL: 0x001920f8

◆ RemovePlayer()

void GrooveWorld::RemovePlayer ( int nId)

Remove the first player with an identifier from mPlayers, without destroying it.

Parameters
nIdThe identifier to match against Player::mPlayerId.
Ghidra address:
NTSC-U/C: 0x00194ef0
Ghidra address:
PAL: 0x0019ab70

◆ KillRenderer()

void GrooveWorld::KillRenderer ( )

Detach the renderer from every source that feeds it and delete it.

Ghidra address:
NTSC-U/C: 0x00194f88
Ghidra address:
PAL: 0x0019ac08

◆ SavePhrases()

void GrooveWorld::SavePhrases ( OBStream & stream)

Write the phrase database of every score track graph.

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

◆ LoadPhrases()

void GrooveWorld::LoadPhrases ( IBStream & stream,
int bClearOwners )

Read the phrase database of every score track graph back.

Parameters
streamThe stream to read from.
bClearOwnersNon-zero to return every loaded phrase to the stand-in player.
Ghidra address:
NTSC-U/C: 0x001950c0
Ghidra address:
PAL: 0x0019ad40

◆ EnableInput()

void GrooveWorld::EnableInput ( )

Enable every entry of the input map.

Ghidra address:
NTSC-U/C: 0x00195150
Ghidra address:
PAL: 0x0019add0

◆ PostFinish()

void GrooveWorld::PostFinish ( )

Queue the finish exit, mode 1, with the current mContinueJukebox.

Gamer posts it at the end of a song, the stop-game script command posts it, and GameManagerImpl posts it when a press interrupts a playback.

Ghidra address:
NTSC-U/C: 0x00195170
Ghidra address:
PAL: 0x0019adf0

◆ PostQuit()

void GrooveWorld::PostQuit ( )

Queue the quit exit, mode 2.

The pause menu's quit item posts it.

Ghidra address:
NTSC-U/C: 0x00195198
Ghidra address:
PAL: 0x0019ae18

◆ PostRestart()

void GrooveWorld::PostRestart ( )

Queue the restart exit, mode 3, with mRestart set.

The pause menu's restart item posts it.

Ghidra address:
NTSC-U/C: 0x001951c0
Ghidra address:
PAL: 0x0019ae40

◆ Shutdown()

void GrooveWorld::Shutdown ( )

Tear the world down ahead of destruction.

It runs StopLevel() when mState is 6 and DeletePlayers() always, deletes the level, the song clock, the cheat detector, and mForceFeedback, and then stops and destroys the note destroyer through StopNoteDestroyer() and DestroyNoteDestroyer(). The destructor is the recovered caller.

Ghidra address:
NTSC-U/C: 0x001951e8
Ghidra address:
PAL: 0x0019ae68

◆ GetSongClock()

Sch::TickClock * GrooveWorld::GetSongClock ( )

Report the world's song clock.

Globals::GetSongClock() is the out-of-line caller, and the constructor creates the clock.

Returns
The clock.
Ghidra address:
NTSC-U/C: 0x001952a0
Ghidra address:
PAL: 0x0019af20

◆ GetPlayMap()

PlayMap * GrooveWorld::GetPlayMap ( )

Report the level's play map.

Globals' accessor at 0x00118da0 is the recovered caller.

Returns
The play map.
Ghidra address:
NTSC-U/C: 0x001952a8
Ghidra address:
PAL: 0x0019af28

◆ GetLevel()

LevelData * GrooveWorld::GetLevel ( )
Returns
The level.
Ghidra address:
NTSC-U/C: 0x001952d8
Ghidra address:
PAL: 0x0019af58

◆ GetRendererSink()

RendererBase * GrooveWorld::GetRendererSink ( )

Report the renderer's RendererBase half.

GameManagerImpl::DrawFrame() runs RendererBase slots 6, 7, and 8 through it, and skips the world when it is null.

Returns
The renderer, or null when no renderer exists.
Ghidra address:
NTSC-U/C: 0x001952e0
Ghidra address:
PAL: 0x0019af60

◆ MarkStatsFlag()

void GrooveWorld::MarkStatsFlag ( )

Set the statistics word at +0x14 of mStats to 1.

Ghidra address:
NTSC-U/C: 0x00195378
Ghidra address:
PAL: 0x0019aff8

◆ DisplayText()

void GrooveWorld::DisplayText ( const HxStr & text)

Show a line of text on the track displays.

Sends a TextMsg through mDelayer, and does nothing before mDelayer exists. The script binding at 0x00153464 is the caller.

Parameters
textThe text.
Ghidra address:
NTSC-U/C: 0x0018f140
Ghidra address:
PAL: 0x00194c90

◆ GetSongName()

HxStr GrooveWorld::GetSongName ( ) const

Report the jukebox song title.

The image has no caller. Overlay copies mSongName directly instead. The name is inferred.

Returns
A copy of mSongName.
Ghidra address:
NTSC-U/C: 0x001937a8
Ghidra address:
PAL: 0x001993d0

◆ InputPoller

friend class InputPoller
friend

Member Data Documentation

◆ mInputMap

InputMap* GrooveWorld::mInputMap

The input map of the world's players.

+0x0c

Public because GameManagerImpl::OnUnpauseGameSystem() rebuilds it directly at 0x00106b74, and the image has no accessor for it.

◆ mGamer

Gamer* GrooveWorld::mGamer

The scoring state.

+0x2c

Public because the juice, section, and track cheats reach it through Globals::GetWorld() with no accessor in the image.

◆ mForceFeedback

ForceFeedbackMgr* GrooveWorld::mForceFeedback

Vibration driver of the controllers.

+0x34

Built by the constructor at 0x0016dae0 and deleted by Shutdown(). Public because TnlCrippleFX's frame routine at 0x0043e500 reads it through Globals::GetWorld() with no accessor in the image.

◆ mTrackGraphs

std::vector<ScoreTrackGraph *> GrooveWorld::mTrackGraphs

◆ mPlayers

std::vector<Player *> GrooveWorld::mPlayers

Every player in the world, in slot order.

+0x68

Public because Renderer and Overlay walk it directly, and the image has no accessor for it.

◆ mLocalPlayers

std::vector<Player *> GrooveWorld::mLocalPlayers

The players this console drives.

+0x74

The element type is proven by the routine at 0x00102790, which reads the identifier at +0x20 of the first element. The role is inferred from Renderer, which resolves one tnl locald.view per element. Public because Renderer and AppTunnel read it directly, and the image has no accessor for it.

◆ mIsPlayback

int GrooveWorld::mIsPlayback

Non-zero while the world plays back a recording.

+0x8c

GameManagerImpl::OnBeginGameLocal() clears it at 0x001067c4, and GameManagerImpl::Load() (run by GamePlaybacker) sets it at 0x001074b8. StartPlay() passes it to the force feedback manager. Public because both GameManagerImpl routines write it directly, and the image has no accessor for it.

◆ mIsTutorial

int GrooveWorld::mIsTutorial

Non-zero in a tutorial level, from the tutorial configuration flag 0x3a1.

+0x90

GameManagerImpl::OnUnpauseGameSystem() reads it directly at 0x00106b54 and rebuilds mInputMap only while it is zero. The image has no accessor for it.

◆ mSongName

HxStr GrooveWorld::mSongName

Song title shown in jukebox mode.

+0xb0

The constructor zeroes both words and the destructor frees the text through the inline ~HxStr(). Overlay's constructor copy-constructs it at 0x0041d358 and displays it. Public because Overlay reads it directly, and the image has no accessor for it.

◆ mContinueJukebox

int GrooveWorld::mContinueJukebox

Non-zero while a jukebox session goes on to its next song.

Starts at 1. +0xb8

A pause press in jukebox mode clears it, PostFinish() posts it with the exit, and EndLevel() skips the synthesiser's LoadBankSet4() while it is set in jukebox mode. Public because GameManagerImpl::EndGame() reads it directly at 0x00106c30 and announces MetFreqEndedMsg(1) only while it is zero. The image has no accessor for it.


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