resonance 1.0.1
Loading...
Searching...
No Matches
Catcher Class Referenceabstract

Catcher that scores the gems one track presents. More...

#include <catcher.h>

Inheritance diagram for Catcher:
Collaboration diagram for Catcher:

Public Member Functions

 Catcher (PhraseMgr *pPhraseMgr, Quantizer *pQuantizer, const TrackData *pTrackData, Sch::TickClock *pClock, int nSeekerBarCount, Sch::Tick catchWindow)
virtual ~Catcher ()
 Withdraw both commands through Stop().
virtual void DispatchPriv (Message *pMsg)
 Act on a message.
virtual void Start ()
 Schedule the catcher's two commands on the clock.
virtual void Stop ()
 Withdraw the catcher's two commands from the clock.
virtual int IsPhraseRunEmpty ()
 Report whether the catcher has nothing outstanding.
virtual void MissGem (int nTick, int nGem)
 Record a missed gem.
virtual void CatchGem (int nTick, int nGem)
 Record a caught gem.
virtual void CapturePhrase (int nBar, int nRun, int nAutoCatch)=0
 Capture the phrase a caught run of bars completes.
virtual void ReportCaughtPowerbar (int nBar)=0
 Report a caught bar's power bar.
void ProcessGemCommand (int nTick)
 Run the post-gem command at a song position.
void SimulateRemoteGem (int nTick)
 Play the remote player's gem at a song position, then schedule the next gem command.
Public Member Functions inherited from GenericCatcher
 GenericCatcher ()
virtual ~GenericCatcher ()
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 MsgSource
virtual ~MsgSource ()
virtual void AddSink (MsgSink *pSink)
 Register a sink, ignoring a sink that is already registered.
virtual void RemoveSink (MsgSink *pSink)
 Unregister the first occurrence of a sink.
void Send (Message *pMsg) const
 Deliver a message to every registered sink, in registration order.
void ClearSinks ()
 Unregister every sink.

Protected Member Functions

void PostPhraseMuffedMsg (int nBar, Sch::Tick position)
 Sends a PhraseMuffedMsg for a bar once, recording the bar in mLastMuffedBar.
void PostCatchMsg (PitchRiffMsg *pMsg)
 Scores a PitchRiffMsg for this track.
void PostCaughtBarMsg (int nBar, int nNextBar)
 Does nothing once a gem of the phrase was missed or muffed.
int SnapToNearestGem (int nTick)
 Returns the gem on either side of nTick nearer to it when that gem lies within mCatchWindow, and nTick otherwise.
void OnTrackSelect (TrackSelectMsg *pMsg)
 Takes the track for the player a TrackSelectMsg names.
void OnAutoCatch (AutoCatchMsg *pMsg)
 Plays a free bar for the player an AutoCatchMsg identifies through CapturePhrase(), marks the message handled through CmdMsg::mResult, and replays the bar from the current offset through PhraseMgr::ReplayBar() when the song is inside it.
void EndBar (int nBar)
 Closes the counts for a bar.
int FindNextGemTick (int nTick)
 Returns the first gem position after nTick.
void SchedulePostGemCommand (int nTick)
 Build a PostGemCmd for the gem after nTick and queue it one tick after PostGemDelay() under the handle mPostGemCommand.
void ScheduleGemCommand (int nTick)
 Build a GemCmd for the gem after nTick and queue it at that gem under the handle mGemCommand.
int PostGemDelay (int nTick)
 Returns the earlier of the midpoint between nTick and the next gem, and nTick plus mCatchWindow.
void UpdateSeeker (int nBar)
 Finds the next free bar within 32 bars of nBar (or of the bar after mLastMuffedBar) and points the seeker at the phrase starting there, or turns the seeker off.
void PostSeekerMsg ()
 Sends a SeekerMsg that turns the seeker off and clears mSeekerEnabled.
void PostSeekerRangeMsg (int nFirstBar, int nBarCount)
 Sends a SeekerMsg for nBarCount bars from nFirstBar at position 0, and records the range in mSeekerFirstBar, mSeekerEndBar, and mSeekerEnabled.
int IsBarFree (int nBar)
 Returns whether a bar is non-negative, playable according to TrackData::QueryBar(), and owned by no player.
void OnInvalidateSeeker (InvalidateSeekerMsg *pMsg)
 The out-of-line copy of the InvalidateSeekerMsg branch DispatchPriv() expands inline.
void SetPhraseOwners (int nFirstBar, int nEndBar, Player *pPlayer)
 Gives every bar from nFirstBar up to nEndBar to one player.

Protected Attributes

Quantizer * mQuantizer
PhraseMgr * mPhraseMgr
const TrackData * mTrackData
Player * mPlayer
Sch::TickClock * mClock
Sch::CmdID mPostGemCommand
Sch::CmdID mGemCommand
Sch::Tick mTicksPerBar
int mSeekerBarCount
int mCatchWindow
int mEnabled
Sch::Tick mLastCaughtPosition
Sch::Tick mLastMissedPosition
int mTrack
int mCaughtGems
int mMissedGems
int mMuffedGems
int mLastEndedBar
int mPhraseRunBars
int mLastMuffedBar
int mSeekerFirstBar
int mSeekerEndBar
int mSeekerEnabled
Player * mRemotePlayer
float mRemoteSuccess
Sch::Tick mRemotePosition

Additional Inherited Members

Public Attributes inherited from MsgSource
int mGraphBuilt
 A word no member of this class reads.

Detailed Description

Catcher that scores the gems one track presents.

Its RTTI descriptor is at 0x00902010. It has GenericCatcher as its only base at offset 0. Its primary table is at 0x007e0c38 with eleven entries and its MsgSource subobject table at 0x007e0c10 with four. Two classes derive from it, MultiCatcher and SingleCatcher, and both retain eleven entries. Neither introduces a virtual.

The class supplies MsgSink::DispatchPriv() and GenericCatcher's Start(), Stop(), and IsPhraseRunEmpty(), and it introduces four virtuals at slots 7 through 10. CapturePhrase() and ReportCaughtPowerbar(), slots 9 and 10, address the shared pure-virtual stub at 0x005381a8. This class is therefore abstract, and the two subclasses exist to supply them. The object is 0x80 bytes, as MultiCatcher's tagged allocation measures. SingleCatcher's is 0x84 and adds one word.

The constructor's parameter list is attested rather than inferred. The anonymous-namespace marker for the file-local command class GemCmd records the enclosing constructor's signature, Catcher(PhraseMgr *, Quantizer *, const TrackData *, Sch::TickClock *, int, Sch::Tick). A second marker records PostGemCmd in the same translation unit. Both are the commands Start() schedules.

DispatchPriv() dispatches a PitchRiffMsg to PostCatchMsg(), a TrackSelectMsg to OnTrackSelect(), an AutoCatchMsg to OnAutoCatch(), and an InvalidateSeekerMsg to the inline copy of OnInvalidateSeeker(). A CatchProgressPacket for this track stores its player, success rate, and position in mRemotePlayer, mRemoteSuccess, and mRemotePosition.

The two file-local commands, PostGemCmd and GemCmd, sit in the anonymous namespace the RTTI records for this unit and call ProcessGemCommand() and SimulateRemoteGem().

0x001adb78, 0x001b15a8, 0x001b1610, 0x001b19a0, 0x001abe50, and 0x001abfd8 sit in this class's table at slots 3, 4, 5, 6, 7, and 8. SingleCatcher's table has the same six addresses at the same indices.

Constructor & Destructor Documentation

◆ Catcher()

Catcher::Catcher ( PhraseMgr * pPhraseMgr,
Quantizer * pQuantizer,
const TrackData * pTrackData,
Sch::TickClock * pClock,
int nSeekerBarCount,
Sch::Tick catchWindow )
Parameters
pPhraseMgrThe phrase manager for the track.
pQuantizerThe quantiser for the track.
pTrackDataThe track description.
pClockThe clock the scheduled commands run on.
nSeekerBarCountThe bars each seeker range spans. MultiCatcher passes 1.
catchWindowThe catch window, in MIDI ticks.
Ghidra address:
NTSC-U/C: 0x001aba30
Ghidra address:
PAL: 0x001b1798

◆ ~Catcher()

virtual Catcher::~Catcher ( )
virtual

Withdraw both commands through Stop().

Ghidra address:
NTSC-U/C: 0x001abc10
Ghidra address:
PAL: 0x001b1978

Member Function Documentation

◆ DispatchPriv()

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

Act on a message.

Slot 3. The routine dispatches on the message's registered identity over the five identities the class documentation lists, and every other message is discarded.

Parameters
pMsgThe message.
Ghidra address:
NTSC-U/C: 0x001adb78
Ghidra address:
PAL: 0x001b38e0

Implements MsgSink.

◆ Start()

virtual void Catcher::Start ( )
virtual

Schedule the catcher's two commands on the clock.

Slot 4. The post-gem command is always scheduled and the gem command only in kGameModeNet.

Ghidra address:
NTSC-U/C: 0x001b15a8
Ghidra address:
PAL: 0x001b7368

Reimplemented from GenericCatcher.

◆ Stop()

virtual void Catcher::Stop ( )
virtual

Withdraw the catcher's two commands from the clock.

Slot 5. The two withdrawals mirror Start(), the second being conditional on kGameModeNet in the same way.

Ghidra address:
NTSC-U/C: 0x001b1610
Ghidra address:
PAL: 0x001b73d0

Reimplemented from GenericCatcher.

◆ IsPhraseRunEmpty()

virtual int Catcher::IsPhraseRunEmpty ( )
virtual

Report whether the catcher has nothing outstanding.

Slot 6.

Returns
Non-zero when mPhraseRunBars is zero.
Ghidra address:
NTSC-U/C: 0x001b19a0
Ghidra address:
PAL: 0x001b7760

Implements GenericCatcher.

◆ MissGem()

virtual void Catcher::MissGem ( int nTick,
int nGem )
virtual

Record a missed gem.

Slot 7. The routine plays the miss sound for the player's own slot, SND_MISS_PLAYER1 through SND_MISS_PLAYER4 by Player::GetInputSlot(), and plays nothing for any other slot. It then sends a missed CatchMsg for the gem. When the tick's bar matches mLastEndedBar, or mPhraseRunBars is positive, it records the tick in mLastMissedPosition, increments mMissedGems, clears mPhraseRunBars, reports the muffed phrase, and refreshes the seeker from the bar.

Parameters
nTickThe scheduler time of the miss.
nGemThe gem the CatchMsg reports.
Ghidra address:
NTSC-U/C: 0x001abe50
Ghidra address:
PAL: 0x001b1bb8

◆ CatchGem()

virtual void Catcher::CatchGem ( int nTick,
int nGem )
virtual

Record a caught gem.

Slot 8. The routine records the tick in mLastCaughtPosition, counts the gem in mCaughtGems, and sends the gem's riff as a MultiMuseMsg. While no gem of the phrase was missed or muffed, it totals the gems and points of the bars from the phrase's first bar up to mSeekerEndBar, and the first caught gem of a phrase sends a BeginPhraseCatchMsg with the points and the multiplier Player::GetMultiplier() reports. It then sends a caught CatchMsg with the progress through the phrase and a GemMsg, calls Player::CountCaughtGem() and discards the result, and posts the caught-bar message when the next gem lies in another bar.

Parameters
nTickThe scheduler time of the gem.
nGemThe gem.
Ghidra address:
NTSC-U/C: 0x001abfd8
Ghidra address:
PAL: 0x001b1d40

◆ CapturePhrase()

virtual void Catcher::CapturePhrase ( int nBar,
int nRun,
int nAutoCatch )
pure virtual

Capture the phrase a caught run of bars completes.

Slot 9, pure. SingleCatcher captures the whole step around the bar and MultiCatcher the bar alone.

Parameters
nBarThe last bar of the run.
nRunThe bars the run spans.
nAutoCatchNon-zero for an automatic catch. Both subclasses branch on whether it is zero.

Implemented in MultiCatcher, and SingleCatcher.

◆ ReportCaughtPowerbar()

virtual void Catcher::ReportCaughtPowerbar ( int nBar)
pure virtual

Report a caught bar's power bar.

Slot 10, pure. MultiCatcher's override is empty and SingleCatcher's sends a CaughtPowerbarMsg to its player when the phrase manager reports a value other than -1.

Parameters
nBarThe caught bar. SingleCatcher's override passes it to PhraseMgr::GetPowerbar().

Implemented in MultiCatcher, and SingleCatcher.

◆ ProcessGemCommand()

void Catcher::ProcessGemCommand ( int nTick)

Run the post-gem command at a song position.

The PostGemCmd the class schedules calls it. A position other than mLastCaughtPosition counts a muffed gem (mMuffedGems incremented, mPhraseRunBars cleared, the muffed phrase reported, the seeker refreshed from mLastMuffedBar, and slot 15 of mPlayer invoked). The routine then ends the bar when the next gem falls in a later bar and schedules the next post-gem command.

Parameters
nTickThe song position the command was scheduled for.
Ghidra address:
NTSC-U/C: 0x001b1828
Ghidra address:
PAL: 0x001b75e8

◆ SimulateRemoteGem()

void Catcher::SimulateRemoteGem ( int nTick)

Play the remote player's gem at a song position, then schedule the next gem command.

The GemCmd the class schedules calls it. A gem is played only when mRemotePlayer is not the stand-in, reports -1 from Player::GetInputSlot(), is within one bar of mRemotePosition, and a draw from the C library's rand() modulo 256 falls below mRemoteSuccess times 256. Playing it sends the riff of the gem as a MultiMuseMsg when TrackData::GetRiff() reports one, then a caught CatchMsg and a GemMsg for mRemotePlayer.

Parameters
nTickThe song position the command was scheduled for.
Ghidra address:
NTSC-U/C: 0x001ace78
Ghidra address:
PAL: 0x001b2be0

◆ PostPhraseMuffedMsg()

void Catcher::PostPhraseMuffedMsg ( int nBar,
Sch::Tick position )
protected

Sends a PhraseMuffedMsg for a bar once, recording the bar in mLastMuffedBar.

The message reports the phrase as tried when the bar is free and a gem of it was caught or missed.

Ghidra address:
NTSC-U/C: 0x001ad3b0
Ghidra address:
PAL: 0x001b3118

◆ PostCatchMsg()

void Catcher::PostCatchMsg ( PitchRiffMsg * pMsg)
protected

Scores a PitchRiffMsg for this track.

A riff from another player queries that player's slot 5 and plays SND_INACTIVE. A riff snapped into a bar that is not free plays SND_INACTIVE and sends a missed CatchMsg. Otherwise a riff on the gem at the snapped position, other than the last one caught, goes to CatchGem(), and every other riff to MissGem().

Ghidra address:
NTSC-U/C: 0x001ac370
Ghidra address:
PAL: 0x001b20d8

◆ PostCaughtBarMsg()

void Catcher::PostCaughtBarMsg ( int nBar,
int nNextBar )
protected

Does nothing once a gem of the phrase was missed or muffed.

Otherwise it delivers a CaughtBarMsg to the player, extends the phrase run in mPhraseRunBars towards nNextBar (bounded by the next step and mSeekerBarCount), and scores the run through CapturePhrase() when it ends the seeker range.

Ghidra address:
NTSC-U/C: 0x001ac7e8
Ghidra address:
PAL: 0x001b2550

◆ SnapToNearestGem()

int Catcher::SnapToNearestGem ( int nTick)
protected

Returns the gem on either side of nTick nearer to it when that gem lies within mCatchWindow, and nTick otherwise.

PostCatchMsg() is the caller.

Ghidra address:
NTSC-U/C: 0x001abcf8
Ghidra address:
PAL: 0x001b1a60

◆ OnTrackSelect()

void Catcher::OnTrackSelect ( TrackSelectMsg * pMsg)
protected

Takes the track for the player a TrackSelectMsg names.

Ghidra address:
NTSC-U/C: 0x001ac550
Ghidra address:
PAL: 0x001b22b8

◆ OnAutoCatch()

void Catcher::OnAutoCatch ( AutoCatchMsg * pMsg)
protected

Plays a free bar for the player an AutoCatchMsg identifies through CapturePhrase(), marks the message handled through CmdMsg::mResult, and replays the bar from the current offset through PhraseMgr::ReplayBar() when the song is inside it.

Ghidra address:
NTSC-U/C: 0x001ac688
Ghidra address:
PAL: 0x001b23f0

◆ EndBar()

void Catcher::EndBar ( int nBar)
protected

Closes the counts for a bar.

A muffed phrase is reported for the previous bar when gems were missed or muffed and some were caught.

Ghidra address:
NTSC-U/C: 0x001ac958
Ghidra address:
PAL: 0x001b26c0

◆ FindNextGemTick()

int Catcher::FindNextGemTick ( int nTick)
protected

Returns the first gem position after nTick.

When none lies within TrackData::mGemSearchBars bars of the track, returns nTick plus that many bars less one.

Ghidra address:
NTSC-U/C: 0x001aca48
Ghidra address:
PAL: 0x001b27b0

◆ SchedulePostGemCommand()

void Catcher::SchedulePostGemCommand ( int nTick)
protected

Build a PostGemCmd for the gem after nTick and queue it one tick after PostGemDelay() under the handle mPostGemCommand.

Ghidra address:
NTSC-U/C: 0x001acba0
Ghidra address:
PAL: 0x001b2908

◆ ScheduleGemCommand()

void Catcher::ScheduleGemCommand ( int nTick)
protected

Build a GemCmd for the gem after nTick and queue it at that gem under the handle mGemCommand.

Ghidra address:
NTSC-U/C: 0x001acca0
Ghidra address:
PAL: 0x001b2a08

◆ PostGemDelay()

int Catcher::PostGemDelay ( int nTick)
protected

Returns the earlier of the midpoint between nTick and the next gem, and nTick plus mCatchWindow.

Ghidra address:
NTSC-U/C: 0x001acd30
Ghidra address:
PAL: 0x001b2a98

◆ UpdateSeeker()

void Catcher::UpdateSeeker ( int nBar)
protected

Finds the next free bar within 32 bars of nBar (or of the bar after mLastMuffedBar) and points the seeker at the phrase starting there, or turns the seeker off.

It does nothing while mPlayer is the stand-in or reports -1 from Player::GetInputSlot().

Ghidra address:
NTSC-U/C: 0x001ad0e8
Ghidra address:
PAL: 0x001b2e50

◆ PostSeekerMsg()

void Catcher::PostSeekerMsg ( )
protected

Sends a SeekerMsg that turns the seeker off and clears mSeekerEnabled.

Ghidra address:
NTSC-U/C: 0x001ad4e0
Ghidra address:
PAL: 0x001b3248

◆ PostSeekerRangeMsg()

void Catcher::PostSeekerRangeMsg ( int nFirstBar,
int nBarCount )
protected

Sends a SeekerMsg for nBarCount bars from nFirstBar at position 0, and records the range in mSeekerFirstBar, mSeekerEndBar, and mSeekerEnabled.

Ghidra address:
NTSC-U/C: 0x001ad560
Ghidra address:
PAL: 0x001b32c8

◆ IsBarFree()

int Catcher::IsBarFree ( int nBar)
protected

Returns whether a bar is non-negative, playable according to TrackData::QueryBar(), and owned by no player.

UpdateSeeker(), OnAutoCatch(), PostCatchMsg(), and PostPhraseMuffedMsg() expand the same test inline.

Ghidra address:
NTSC-U/C: 0x001b1488
Ghidra address:
PAL: 0x001b7248

◆ OnInvalidateSeeker()

void Catcher::OnInvalidateSeeker ( InvalidateSeekerMsg * pMsg)
protected

The out-of-line copy of the InvalidateSeekerMsg branch DispatchPriv() expands inline.

Ghidra address:
NTSC-U/C: 0x001b1578
Ghidra address:
PAL: 0x001b7338

◆ SetPhraseOwners()

void Catcher::SetPhraseOwners ( int nFirstBar,
int nEndBar,
Player * pPlayer )
protected

Gives every bar from nFirstBar up to nEndBar to one player.

The image has no caller.

Ghidra address:
NTSC-U/C: 0x001b1918
Ghidra address:
PAL: 0x001b76d8

Member Data Documentation

◆ mQuantizer

Quantizer* Catcher::mQuantizer
protected

◆ mPhraseMgr

PhraseMgr* Catcher::mPhraseMgr
protected

◆ mTrackData

const TrackData* Catcher::mTrackData
protected

◆ mPlayer

Player* Catcher::mPlayer
protected

◆ mClock

Sch::TickClock* Catcher::mClock
protected

◆ mPostGemCommand

Sch::CmdID Catcher::mPostGemCommand
protected

◆ mGemCommand

Sch::CmdID Catcher::mGemCommand
protected

◆ mTicksPerBar

Sch::Tick Catcher::mTicksPerBar
protected

◆ mSeekerBarCount

int Catcher::mSeekerBarCount
protected

◆ mCatchWindow

int Catcher::mCatchWindow
protected

◆ mEnabled

int Catcher::mEnabled
protected

◆ mLastCaughtPosition

Sch::Tick Catcher::mLastCaughtPosition
protected

◆ mLastMissedPosition

Sch::Tick Catcher::mLastMissedPosition
protected

◆ mTrack

int Catcher::mTrack
protected

◆ mCaughtGems

int Catcher::mCaughtGems
protected

◆ mMissedGems

int Catcher::mMissedGems
protected

◆ mMuffedGems

int Catcher::mMuffedGems
protected

◆ mLastEndedBar

int Catcher::mLastEndedBar
protected

◆ mPhraseRunBars

int Catcher::mPhraseRunBars
protected

◆ mLastMuffedBar

int Catcher::mLastMuffedBar
protected

◆ mSeekerFirstBar

int Catcher::mSeekerFirstBar
protected

◆ mSeekerEndBar

int Catcher::mSeekerEndBar
protected

◆ mSeekerEnabled

int Catcher::mSeekerEnabled
protected

◆ mRemotePlayer

Player* Catcher::mRemotePlayer
protected

◆ mRemoteSuccess

float Catcher::mRemoteSuccess
protected

◆ mRemotePosition

Sch::Tick Catcher::mRemotePosition
protected

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