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

Traversal that runs the sequence once from start to end, repeating each section a set number of times. More...

#include <playmaplinear.h>

Inheritance diagram for PlayMapLinear:
Collaboration diagram for PlayMapLinear:

Classes

struct  Entry
 One section of the window, a step index paired with its repeat count. More...
struct  StepPair
 One partner record, a step paired with the step MapToLinkedStep() moves it to. More...

Public Member Functions

 PlayMapLinear (int bLoadStepRings)
 Construct an empty linear map.
virtual ~PlayMapLinear ()
virtual int MapBar (int nBar)
 Map a bar to its offset within the base's steps.
virtual std::vector< int > & FindBarsPlaying (int nStart, int nMin, int nEnd)
 Collect every position between two bounds that plays the same step offset as a position.
virtual int MapToLinkedStep (int nPosition, int nSet)
 Carry a position from its step to the partner step the table for one set records.
virtual int GetLength () const
 Report the position at which the window ends.
virtual int GetEndBar ()
virtual int GetNumSections () const
virtual int GetPatternSection (int nIndex)
virtual int GetPatternIndex (int nBar)
 Report the index within the recorded pattern of the window entry a bar falls in.
virtual int GetAbsoluteSectionIndex (int nBar)
 Report the absolute index of the window entry a bar falls in.
virtual int IsLooping (int nBar)
virtual int EndLoop (int nBar)
 End the looping section at a bar.
virtual int StartLoop (int nBar)
 Set the section a bar falls in looping forever, and move every later entry to follow it.
virtual int ToggleLoop (int nBar)
 Toggle the loop on the section a bar falls in.
virtual void RecordPattern ()
 Record the sections appended so far as the pattern, and the window end with it.
virtual void AppendSection (int nSection)
 Slot 20.
Public Member Functions inherited from PlayMap
void * operator new (size_t nSize)
 Allocate a map from the tagged heap under the tag PlayMap.
void operator delete (void *pBlock)
 Release a map to the tagged heap under the tag PlayMap.
 PlayMap ()
 Construct an empty map whose first step is at zero.
virtual ~PlayMap ()
 Inline.
virtual void AddStep (int nPosition, HxStr strLabel)
 Slot 2.
virtual void SetBarCount (int nBarCount)
 Slot 3.
virtual void ResetSpans ()
 Slot 4.
virtual void CloseSpan (int nRepeats)
 Slot 15.
int FindStepIndex (int nPosition)
 Report the index of the step at or before a position that has already been mapped.
int IsStepStart (int nBar)
 Report whether a bar maps exactly onto a step.
int StepStartBar (int nBar)
 Report the bar at which the step containing a bar began.
int NextStepBar (int nBar)
 Report the bar at which the first step at or after a bar begins.
int FollowingStepBar (int nBar)
 Report the bar at which the first step strictly after a bar begins.

Static Public Member Functions

static int SelfTest ()
 Exercise the map on four steps and seven sections.
static int RunSelfTest ()
 Run SelfTest() in the shape TestRegistry::TestFunc requires.

Protected Member Functions

void LoadStepRings ()
 Fill mStepRings from the script.
void GrowPastLimit (int nLimit)
 Advance the window until GetLength() passes the limit, then drop what it has passed.
int WindowIndex (int nBar)
 Grow the window past a bar and report the index of the entry it falls in.
void RestartFrom (std::vector< int >::size_type nFirst)
 Recompute the start of every window entry from an index onward.

Protected Attributes

std::vector< Entry > mWindow
std::vector< int > mWindowStarts
int mTrimmedCount
std::vector< Entry > mPattern
int mPatternEnd
std::vector< std::vector< StepPair > > mStepRings
Protected Attributes inherited from PlayMap
int mUnusedValue
std::vector< int > mFoundBars

Static Protected Attributes

static constexpr int kSetCount = 8
 The number of partner tables in mStepRings.
static constexpr int kRepeatForever = 10000
 The repeat count that marks a section looping until EndLoop() ends it.

Additional Inherited Members

Public Attributes inherited from PlayMap
int mBarCount
 The number of bars SetBarCount() stores.
std::vector< int > mSteps
 Ascending sequence of positions.
std::vector< int > mSectionLengths
 Length of each section, the gap between one step and the previous one.
std::vector< HxStr > mSectionNames
 Label of each section, the one AddStep() receives with the step.

Detailed Description

Traversal that runs the sequence once from start to end, repeating each section a set number of times.

PlayMapLinear in the RTTI descriptor at 0x008f2a20, with PlayMap as its only base at offset 0. It overrides the widest set of the three subclasses, slots 1, 5 through 14, and 16 through 19, and supplies slot 20, which no other subclass does.

The object is 0x74 bytes, which the tagged allocation in the LevelBuilder constructor at 0x001ea8f0 measures. Its own members follow the base at +0x3c.

The map plays a list of sections, each an index into the base's steps paired with a repeat count. AppendSection() appends one section, and RecordPattern() records the list as the pattern GrowPastLimit() appends again whenever a position runs past the end. A repeat count of kRepeatForever marks a section that loops until EndLoop() ends it at a bar, and StartLoop() sets a section looping again.

The unit registers SelfTest() with TestRegistry under the name PlayMapLinear.

Constructor & Destructor Documentation

◆ PlayMapLinear()

PlayMapLinear::PlayMapLinear ( int bLoadStepRings)
explicit

Construct an empty linear map.

Runs the PlayMap constructor, sizes mStepRings to kSetCount empty tables, and reserves eight elements in mWindow and mWindowStarts. A non-zero bLoadStepRings then runs LoadStepRings(). LevelBuilder's constructor passes 1, and SelfTest() passes 0.

Parameters
bLoadStepRingsWhether to fill the partner tables from the script.
Ghidra address:
NTSC-U/C: 0x00127a80
Ghidra address:
PAL: 0x001281a0

◆ ~PlayMapLinear()

virtual PlayMapLinear::~PlayMapLinear ( )
virtual
Ghidra address:
NTSC-U/C: 0x0012a4d8
Ghidra address:
PAL: 0x0012ac08

Member Function Documentation

◆ MapBar()

virtual int PlayMapLinear::MapBar ( int nBar)
virtual

Map a bar to its offset within the base's steps.

Finds the window entry the bar falls in and returns that section's first step plus the bar's distance into the entry, wrapped to the section's length.

Parameters
nBarThe bar to map.
Returns
The mapped position.
Ghidra address:
NTSC-U/C: 0x0012ad58
Ghidra address:
PAL: 0x0012b490

Implements PlayMap.

◆ FindBarsPlaying()

virtual std::vector< int > & PlayMapLinear::FindBarsPlaying ( int nStart,
int nMin,
int nEnd )
virtual

Collect every position between two bounds that plays the same step offset as a position.

The walk starts at the window entry at or before nMin and runs until an entry starts at or after nEnd. It does not test for the end of the window, and relies on GrowPastLimit() having grown the window past nEnd.

Parameters
nStartThe position whose section and offset are matched.
nMinThe lowest position to collect.
nEndThe position to stop below.
Returns
mFoundBars.
Ghidra address:
NTSC-U/C: 0x00128d08
Ghidra address:
PAL: 0x00129438

Implements PlayMap.

◆ MapToLinkedStep()

virtual int PlayMapLinear::MapToLinkedStep ( int nPosition,
int nSet )
virtual

Carry a position from its step to the partner step the table for one set records.

The position's step comes from PlayMap::FindStepIndex(). Without a record for that step in mStepRings[nSet] the position comes back unchanged.

Parameters
nPositionThe position to map.
nSetThe index into mStepRings.
Returns
The mapped position.
Ghidra address:
NTSC-U/C: 0x0012ae88
Ghidra address:
PAL: 0x0012b5c0

Reimplemented from PlayMap.

◆ GetLength()

virtual int PlayMapLinear::GetLength ( ) const
virtual

Report the position at which the window ends.

Returns
The start of the last window entry plus its section's length times its repeat count, or zero when the window is empty.
Ghidra address:
NTSC-U/C: 0x0012ae38
Ghidra address:
PAL: 0x0012b570

Reimplemented from PlayMap.

◆ GetEndBar()

virtual int PlayMapLinear::GetEndBar ( )
virtual
Returns
The window end RecordPattern() recorded.
Ghidra address:
NTSC-U/C: 0x0012aa60
Ghidra address:
PAL: 0x0012b198

Reimplemented from PlayMap.

◆ GetNumSections()

virtual int PlayMapLinear::GetNumSections ( ) const
virtual
Returns
The number of sections in the recorded pattern.
Ghidra address:
NTSC-U/C: 0x0012aa68
Ghidra address:
PAL: 0x0012b1a0

Reimplemented from PlayMap.

◆ GetPatternSection()

virtual int PlayMapLinear::GetPatternSection ( int nIndex)
virtual
Parameters
nIndexThe index into the recorded pattern.
Returns
The section at that index.
Ghidra address:
NTSC-U/C: 0x0012aa80
Ghidra address:
PAL: 0x0012b1b8

Reimplemented from PlayMap.

◆ GetPatternIndex()

virtual int PlayMapLinear::GetPatternIndex ( int nBar)
virtual

Report the index within the recorded pattern of the window entry a bar falls in.

Parameters
nBarThe bar.
Returns
The window index modulo the pattern length.
Ghidra address:
NTSC-U/C: 0x0012af30
Ghidra address:
PAL: 0x0012b668

Reimplemented from PlayMap.

◆ GetAbsoluteSectionIndex()

virtual int PlayMapLinear::GetAbsoluteSectionIndex ( int nBar)
virtual

Report the absolute index of the window entry a bar falls in.

Parameters
nBarThe bar.
Returns
The window index plus the count of entries the trim has dropped.
Ghidra address:
NTSC-U/C: 0x0012afb8
Ghidra address:
PAL: 0x0012b6f0

Reimplemented from PlayMap.

◆ IsLooping()

virtual int PlayMapLinear::IsLooping ( int nBar)
virtual
Parameters
nBarThe bar.
Returns
1 when the window entry the bar falls in repeats forever, and 0 otherwise.
Ghidra address:
NTSC-U/C: 0x0012b028
Ghidra address:
PAL: 0x0012b760

Reimplemented from PlayMap.

◆ EndLoop()

virtual int PlayMapLinear::EndLoop ( int nBar)
virtual

End the looping section at a bar.

When the window entry the bar falls in repeats forever, its repeat count becomes the number of whole passes up to and including the bar, and every later entry is moved to follow it.

Parameters
nBarThe bar.
Returns
1 when the entry was looping, and 0 otherwise.
Ghidra address:
NTSC-U/C: 0x00128ed8
Ghidra address:
PAL: 0x00129608

Reimplemented from PlayMap.

◆ StartLoop()

virtual int PlayMapLinear::StartLoop ( int nBar)
virtual

Set the section a bar falls in looping forever, and move every later entry to follow it.

Parameters
nBarThe bar.
Returns
Always 1.
Ghidra address:
NTSC-U/C: 0x00129038
Ghidra address:
PAL: 0x00129768

Reimplemented from PlayMap.

◆ ToggleLoop()

virtual int PlayMapLinear::ToggleLoop ( int nBar)
virtual

Toggle the loop on the section a bar falls in.

Parameters
nBarThe bar.
Returns
1 when a loop was ended, and 0 when one was started.
Ghidra address:
NTSC-U/C: 0x0012b0a8
Ghidra address:
PAL: 0x0012b7e0

Reimplemented from PlayMap.

◆ RecordPattern()

virtual void PlayMapLinear::RecordPattern ( )
virtual

Record the sections appended so far as the pattern, and the window end with it.

Slot 19.

Ghidra address:
NTSC-U/C: 0x0012aa18
Ghidra address:
PAL: 0x0012b150

◆ AppendSection()

virtual void PlayMapLinear::AppendSection ( int nSection)
virtual

Slot 20.

Append one section, played once, at the end of the window.

LevelBuilder's constructor calls it once per value of configuration code 0x39d.

Parameters
nSectionThe index of the section's first step.
Ghidra address:
NTSC-U/C: 0x00128c38
Ghidra address:
PAL: 0x00129368

◆ SelfTest()

int PlayMapLinear::SelfTest ( )
static

Exercise the map on four steps and seven sections.

The routine maps seven positions and toggles two loops, and discards every result. Nothing in the shipped game calls it apart from the test registry.

Returns
Always 1.
Ghidra address:
NTSC-U/C: 0x001293b0
Ghidra address:
PAL: 0x00129ae0

◆ RunSelfTest()

int PlayMapLinear::RunSelfTest ( )
static

Run SelfTest() in the shape TestRegistry::TestFunc requires.

The unit's static initialiser registers it. The integer result reaches the hx.test command through the return register, which decides its ok report.

Ghidra address:
NTSC-U/C: 0x0012b110
Ghidra address:
PAL: 0x0012b848

◆ LoadStepRings()

void PlayMapLinear::LoadStepRings ( )
protected

Fill mStepRings from the script.

Each of the kSetCount tables evaluates the script template 0x3a3 through EvalScriptTemplate() with its index, which yields a sequence of step rings. Each ring pairs every step with the one after it, and the last with the first. A step is read through Py::Int.

Ghidra address:
NTSC-U/C: 0x00128410
Ghidra address:
PAL: 0x00128b40

◆ GrowPastLimit()

void PlayMapLinear::GrowPastLimit ( int nLimit)
protected

Advance the window until GetLength() passes the limit, then drop what it has passed.

Every one of MapBar(), FindBarsPlaying(), GetPatternIndex(), GetAbsoluteSectionIndex(), IsLooping(), EndLoop(), and StartLoop() calls it with its own argument before doing anything else. The growth half appends one start to mWindowStarts from the result of GetLength() and one Entry to mWindow per section of the pattern. The test is at the top of the loop, and the body can run zero times. GetLength() is dispatched through the table rather than called directly.

The trim half drops as many leading elements from mWindow and mWindowStarts as the pattern has, and adds that count to mTrimmedCount. Its guard compares a byte offset against an element count. The trim therefore fires only once mWindow is more than eight times the length of the pattern.

Parameters
nLimitThe value GetLength() must exceed for the growth to stop.
Ghidra address:
NTSC-U/C: 0x00129150
Ghidra address:
PAL: 0x00129880

◆ WindowIndex()

int PlayMapLinear::WindowIndex ( int nBar)
protected

Grow the window past a bar and report the index of the entry it falls in.

Inline. GetPatternIndex(), GetAbsoluteSectionIndex(), IsLooping(), EndLoop(), and StartLoop() expand it, and MapBar() and SelfTest() call the out-of-line copy at 0x0012ade8.

Parameters
nBarThe bar.
Returns
The index of the last window entry starting at or before the bar.
Ghidra address:
NTSC-U/C: 0x0012ade8
Ghidra address:
PAL: 0x0012b520

◆ RestartFrom()

void PlayMapLinear::RestartFrom ( std::vector< int >::size_type nFirst)
protected

Recompute the start of every window entry from an index onward.

Inline, and expanded in EndLoop() and StartLoop(). Each start is the previous start plus the previous section's length times its repeat count.

Parameters
nFirstThe first index to recompute.

Member Data Documentation

◆ kSetCount

int PlayMapLinear::kSetCount = 8
staticconstexprprotected

The number of partner tables in mStepRings.

◆ kRepeatForever

int PlayMapLinear::kRepeatForever = 10000
staticconstexprprotected

The repeat count that marks a section looping until EndLoop() ends it.

◆ mWindow

std::vector<Entry> PlayMapLinear::mWindow
protected

◆ mWindowStarts

std::vector<int> PlayMapLinear::mWindowStarts
protected

◆ mTrimmedCount

int PlayMapLinear::mTrimmedCount
protected

◆ mPattern

std::vector<Entry> PlayMapLinear::mPattern
protected

◆ mPatternEnd

int PlayMapLinear::mPatternEnd
protected

◆ mStepRings

std::vector<std::vector<StepPair> > PlayMapLinear::mStepRings
protected

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