Skip to content

Commit

Permalink
beatmatch stuff (#469)
Browse files Browse the repository at this point in the history
* beatmatch/tickedinfo stuff

* refactor foreachobjref macro

* songdata retail syms

* songdata stuff

* fix rangeddata class

* songdata and esp rangeddata work

* more rangeddata stuff

* more rangeddata crap

* finish up songdata rangeddata usage

* songdata far enough along to document

* songdata doc

* link submix

* link timespanvector

* slotchannelmapping has linkissues

* link fillinfo

* try to doc fillinfo and songdata

* rename rangeddata funcs

* fillinfo doc

* rangeddata doc

* songdata context
  • Loading branch information
rjkiv authored Jan 28, 2025
1 parent 3e58d5c commit 1f8b2d7
Show file tree
Hide file tree
Showing 45 changed files with 1,918 additions and 467 deletions.
460 changes: 230 additions & 230 deletions config/SZBE69/symbols.txt

Large diffs are not rendered by default.

17 changes: 10 additions & 7 deletions config/SZBE69_B8/objects.json
Original file line number Diff line number Diff line change
Expand Up @@ -885,11 +885,11 @@
"system/beatmatch/BeatMatcher.cpp": "MISSING",
"system/beatmatch/ButtonGuitarController.cpp": "Matching",
"system/beatmatch/DrumFillTrackWatcherImpl.cpp": "MISSING",
"system/beatmatch/DrumMap.cpp": "MISSING",
"system/beatmatch/DrumMixDB.cpp": "MISSING",
"system/beatmatch/DrumMap.cpp": "NonMatching",
"system/beatmatch/DrumMixDB.cpp": "NonMatching",
"system/beatmatch/DrumPlayer.cpp": "Matching",
"system/beatmatch/DrumTrackWatcherImpl.cpp": "NonMatching",
"system/beatmatch/FillInfo.cpp": "NonMatching",
"system/beatmatch/FillInfo.cpp": "Matching",
"system/beatmatch/GameGem.cpp": "Matching",
"system/beatmatch/GameGemDB.cpp": "Matching",
"system/beatmatch/GameGemList.cpp": "NonMatching",
Expand All @@ -907,18 +907,21 @@
"system/beatmatch/PhraseAnalyzer.cpp": "NonMatching",
"system/beatmatch/PhraseDB.cpp": "Matching",
"system/beatmatch/PhraseList.cpp": "Matching",
"system/beatmatch/Playback.cpp": "NonMatching",
"system/beatmatch/Playback.cpp": "Equivalent",
"system/beatmatch/PlayerTrackConfigList.cpp": "NonMatching",
"system/beatmatch/RealGuitarController.cpp": "Matching",
"system/beatmatch/RealGuitarTrackWatcherImpl.cpp": "NonMatching",
"system/beatmatch/RGGemMatcher.cpp": "NonMatching",
"system/beatmatch/RGState.cpp": "Matching",
"system/beatmatch/RGUtl.cpp": "NonMatching",
"system/beatmatch/SlotChannelMapping.cpp": "NonMatching",
"system/beatmatch/SlotChannelMapping.cpp": {
"status": "LinkIssues",
"comment": "The ordering of stlport funcs versus weak SlotChannelMapping funcs"
},
"system/beatmatch/SongData.cpp": "NonMatching",
"system/beatmatch/SongParser.cpp": "NonMatching",
"system/beatmatch/Submix.cpp": "NonMatching",
"system/beatmatch/TimeSpanVector.cpp": "MISSING",
"system/beatmatch/Submix.cpp": "Matching",
"system/beatmatch/TimeSpanVector.cpp": "Matching",
"system/beatmatch/TrackType.cpp": "Matching",
"system/beatmatch/TrackWatcher.cpp": "NonMatching",
"system/beatmatch/TrackWatcherImpl.cpp": "NonMatching",
Expand Down
2 changes: 1 addition & 1 deletion src/band3/game/SongDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ bool SongDB::IsInCoda(int i) const {
return mCodaStartTick != -1 && i >= mCodaStartTick;
}

int SongDB::GetNumTracks() const { return mSongData->unk10; }
int SongDB::GetNumTracks() const { return mSongData->mNumTracks; }
int SongDB::GetNumTrackData() const { return mTrackData.size(); }

int SongDB::GetBaseMaxPoints(const UserGuid& u) const {
Expand Down
5 changes: 1 addition & 4 deletions src/system/beatmatch/BeatMaster.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef BEATMATCH_BEATMASTER_H
#define BEATMATCH_BEATMASTER_H
#pragma once
#include "beatmatch/BeatMasterSink.h"
#include "beatmatch/SongParserSink.h"
#include "beatmatch/HxMaster.h"
Expand Down Expand Up @@ -64,5 +63,3 @@ class BeatMasterLoader : public Loader {

BeatMaster* mBeatMaster; // 0x18
};

#endif
2 changes: 2 additions & 0 deletions src/system/beatmatch/BeatMatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class BeatMatcher : public TrackWatcherParent, public BeatMatchControllerSink {
void SetFillLogic(FillLogic);
bool IsAutoplay();
void SetAutoplay(bool);
void PostLoad();
void AddTrack(int, Symbol, SongInfoAudioType, TrackType, bool);

int dummy;
};
Expand Down
31 changes: 31 additions & 0 deletions src/system/beatmatch/DrumMap.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include "beatmatch/DrumMap.h"

DrumMap::DrumMap() : mCurrentLanes(0) {
mLanes.AddInfo(0, 0);
}

bool DrumMap::LaneOn(int tick, int i2){
int mask = 1 << i2;
if(mCurrentLanes & mask) return false;
else {
UpdateLanes(tick, mCurrentLanes | mask);
return true;
}
}

bool DrumMap::LaneOff(int tick, int i2){
int mask = 1 << i2;
if(!(mCurrentLanes & mask)) return false;
else {
UpdateLanes(tick, mCurrentLanes & ~mask);
return true;
}
}

void DrumMap::UpdateLanes(int tick, int newLaneMask){
mCurrentLanes = newLaneMask;
if(!mLanes.mInfos.empty() && tick == mLanes.mInfos.back().mTick){
mLanes.mInfos.back().mInfo = newLaneMask;
}
else mLanes.AddInfo(tick, newLaneMask);
}
21 changes: 21 additions & 0 deletions src/system/beatmatch/DrumMap.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#pragma once
#include "beatmatch/FillInfo.h"

class DrumFillInfo : public FillInfo {
public:
DrumFillInfo(){}
virtual ~DrumFillInfo(){}
};

class DrumMap : public DrumFillInfo {
public:
DrumMap();
virtual ~DrumMap(){}

void Clear(){ FillInfo::Clear(); }
bool LaneOn(int, int);
bool LaneOff(int, int);
void UpdateLanes(int, int);

int mCurrentLanes; // 0x14
};
40 changes: 40 additions & 0 deletions src/system/beatmatch/DrumMixDB.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include "beatmatch/DrumMixDB.h"
#include "macros.h"
#include "os/Debug.h"

DrumMixDB::DrumMixDB(int num_mixes){
mMixLists.reserve(num_mixes);
for(int i = 0; i < num_mixes; i++){
mMixLists.push_back(new TickedInfoCollection<String>());
}
}

DrumMixDB::~DrumMixDB(){
for(int i = 0; i < mMixLists.size(); i++){
RELEASE(mMixLists[i]);
}
}

void DrumMixDB::Clear(){
for(int i = 0; i < mMixLists.size(); i++){
mMixLists[i]->Clear();
}
}

bool DrumMixDB::AddMix(int diff, int tick, const char* str){
MILO_ASSERT_RANGE(diff, 0, mMixLists.size(), 0x2D);
return mMixLists[diff]->AddInfo(tick, str);
}

TickedInfoCollection<String>& DrumMixDB::GetMixList(int diff){
MILO_ASSERT_RANGE(diff, 0, mMixLists.size(), 0x39);
return *mMixLists[diff];
}

DrumMixDB* DrumMixDB::Duplicate() const {
DrumMixDB* db = new DrumMixDB(mMixLists.size());
for(int i = 0; i < mMixLists.size(); i++){
*db->mMixLists[i] = *mMixLists[i];
}
return db;
}
16 changes: 16 additions & 0 deletions src/system/beatmatch/DrumMixDB.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once
#include <vector>
#include "utl/Str.h"
#include "utl/TickedInfo.h"

class DrumMixDB {
public:
DrumMixDB(int);
~DrumMixDB();
void Clear();
bool AddMix(int, int, const char*);
TickedInfoCollection<String>& GetMixList(int);
DrumMixDB* Duplicate() const;

std::vector<TickedInfoCollection<String>*> mMixLists; // 0x0
};
74 changes: 44 additions & 30 deletions src/system/beatmatch/FillInfo.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#include "beatmatch/FillInfo.h"
#include <algorithm>

bool FillExtentCmp(const FillExtent& ext, int i){
return ext.end - 1 < i;
bool FillExtentCmp(const FillExtent& ext, int tick){
return ext.end - 1 < tick;
}

bool FillExtentCmpIncludingEnd(const FillExtent& ext, int i){
return ext.end < i;
bool FillExtentCmpIncludingEnd(const FillExtent& ext, int tick){
return ext.end < tick;
}

void FillInfo::Clear(){
Expand All @@ -15,50 +15,64 @@ void FillInfo::Clear(){
}

// fn_8045F964
bool FillInfo::AddFill(int start, int end, bool bre){
int num = (start + 0xF) % 0x1E;
if(mFills.empty() || mFills.back().end <= num){
mFills.push_back(FillExtent(start, end, bre));
bool FillInfo::AddFill(int start, int duration, bool bre){
int newStart = ((start + 15) / 30) * 30;
int newEnd = ((start + duration + 15) / 30) * 30;
int newDuration = newEnd - newStart;
if(mFills.empty() || mFills.back().end <= newStart){
mFills.push_back(FillExtent(newStart, newStart + newDuration, bre));
return true;
}
else return false;
else return false;
}

bool FillInfo::FillAt(int i, bool include_end) const {
// std::lower_bound(mFills.begin(), mFills.end(), FillExtentCmp);
bool FillInfo::FillAt(int tick, bool include_end) const {
const FillExtent* ext = std::lower_bound(mFills.begin(), mFills.end(), tick, include_end ? FillExtentCmpIncludingEnd : FillExtentCmp);
if(ext == mFills.end()) return false;
else return ext->CheckBounds(tick);
}

bool FillInfo::NextFillExtents(int i, FillExtent& ext) const {
for(std::vector<FillExtent>::const_iterator it = mFills.begin(); it != mFills.end(); ++it){
if(i <= (*it).start){
ext.start = (*it).start;
ext.end = (*it).end;
return true;
}
bool FillInfo::FillAt(int tick, FillExtent& outExtent, bool include_end) const {
const FillExtent* e = std::lower_bound(mFills.begin(), mFills.end(), tick, include_end ? FillExtentCmpIncludingEnd : FillExtentCmp);
if(e == mFills.end()) return false;
else if(!e->CheckBounds(tick)) return false;
else {
outExtent.start = e->start;
outExtent.end = e->end;
return true;
}
return false;
}

bool FillInfo::FillExtentAtOrBefore(int i, FillExtent& ext) const {
bool FillInfo::NextFillExtents(int tick, FillExtent& outExtent) const {
for(std::vector<FillExtent>::const_iterator it = mFills.begin(); it != mFills.end(); ++it){
if((*it).start <= i){
ext.start = (*it).start;
ext.end = (*it).end;
if(tick <= it->start){
outExtent.start = it->start;
outExtent.end = it->end;
return true;
}
}
return false;
}

// fn_8045CCBC
bool FillInfo::AddLanes(int i, int j){
if(mLanes.mInfos.empty() || mLanes.mInfos.back().mTick <= i){
mLanes.mInfos.push_back(TickedInfo<int>(i, j));
bool FillInfo::FillExtentAtOrBefore(int tick, FillExtent& outExtent) const {
std::vector<FillExtent>::const_iterator it;
for(it = mFills.begin(); it != mFills.end() && it->start <= tick; ++it);
if(it == mFills.begin()) return false;
else {
--it;
outExtent.start = it->start;
outExtent.end = it->end;
return true;
}
return false;
}

int FillInfo::LanesAt(int i) const {
// std::upper_bound(mLanes.mInfos.begin(), mLanes.mInfos.end(), TickedInfoCollection<int>::Cmp);
// fn_8045CCBC
bool FillInfo::AddLanes(int tick, int lanes){
return mLanes.AddInfo(tick, lanes);
}

int FillInfo::LanesAt(int tick) const {
const TickedInfo<int>* info = std::upper_bound(mLanes.mInfos.begin(), mLanes.mInfos.end(), tick, TickedInfoCollection<int>::Cmp);
if(info != mLanes.mInfos.begin()) info--;
return info->mInfo;
}
69 changes: 56 additions & 13 deletions src/system/beatmatch/FillInfo.h
Original file line number Diff line number Diff line change
@@ -1,30 +1,73 @@
#ifndef BEATMATCH_FILLINFO_H
#define BEATMATCH_FILLINFO_H
#pragma once
#include "utl/TickedInfo.h"
#include <vector>

/** Info for a single fill. */
struct FillExtent {
FillExtent(int s, int e, bool b) : start(s), end(e), bre(b) {}
int start;
int end;
bool bre;
bool CheckBounds(int tick) const {
return tick >= start && tick <= end;
}
/** The starting tick. */
int start; // 0x0
/** The ending tick. */
int end; // 0x4
/** Is this fill for a BRE? */
bool bre; // 0x8
};

/** A general collection of fill information. */
class FillInfo {
public:
FillInfo(){}
virtual ~FillInfo(){}

/** Completely empty the lane and fill collections. */
void Clear();
bool AddFill(int, int, bool);
bool FillAt(int, bool) const;
bool AddLanes(int, int);
bool NextFillExtents(int, FillExtent&) const;
bool FillExtentAtOrBefore(int, FillExtent&) const;
int LanesAt(int) const;
/** Add a fill to our fill collection.
* @param [in] start The start tick of this fill.
* @param [in] duration How long in ticks this fill should last.
* @param [in] bre Is this fill for a BRE?
* @returns True if the fill was successfully added, false if not.
*/
bool AddFill(int start, int duration, bool bre);
/** Checks if a fill exists at the given tick.
* @param [in] tick The tick to check.
* @param [in] include_end TODO: unknown
* @returns True if a fill exists at the given tick, false if not.
*/
bool FillAt(int tick, bool include_end) const;
/** Add a new TickedInfo entry for the supplied lanes.
* @param [in] tick The tick the lanes occur at.
* @param [in] lanes The lanes.
* @returns True if the lanes were successfully added, false if not.
*/
bool AddLanes(int tick, int lanes);
/** Get the next coming FillExtent relative to the supplied tick.
* @param [in] tick The tick to check.
* @param [out] outExtent The next FillExtent coming after this tick.
* @returns True if a FillExtent exists after the supplied tick, false if not.
*/
bool NextFillExtents(int tick, FillExtent& outExtent) const;
/** Get the FillExtent either at or before the supplied tick.
* @param [in] tick The tick to check.
* @param [out] outExtent The FillExtent at or before this tick.
* @returns True if a FillExtent exists at or before the supplied tick, false if not.
*/
bool FillExtentAtOrBefore(int tick, FillExtent& outExtent) const;
/** Get the lanes associated with the supplied tick.
* @param [in] tick The tick to check.
* @returns The lanes associated with the tick.
*/
int LanesAt(int tick) const;
/** Checks if a fill exists at the given tick, and if so, write its tick range to outExtent.
* @param [in] tick The tick to check.
* @param [out] outExtent The FillExtent containing this tick.
* @param [in] include_end TODO: unknown
* @returns True if a fill exists at the given tick, false if not.
*/
bool FillAt(int tick, FillExtent& outExtent, bool include_end) const;

TickedInfoCollection<int> mLanes; // 0x4
std::vector<FillExtent> mFills; // 0xc
};

#endif
1 change: 1 addition & 0 deletions src/system/beatmatch/GameGem.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class GameGem {
bool IgnoreDuration() const { return mIgnoreDuration; }
unsigned int GetSlots() const { return mSlots; }
bool GetForceStrum() const { return mForceStrum; }
int GetDurationTicks() const { return mDurationTicks; }

bool CompareTimes(const GameGem& g1, const GameGem& g2){
return g1.mMs < g2.mMs;
Expand Down
Loading

0 comments on commit 1f8b2d7

Please sign in to comment.