Skip to content

Commit

Permalink
custom song sources show in DateAcquired, MusicLibrary jump groundwork
Browse files Browse the repository at this point in the history
  • Loading branch information
InvoxiPlayGames committed Oct 7, 2022
1 parent 45fa660 commit f5413b6
Show file tree
Hide file tree
Showing 13 changed files with 174 additions and 88 deletions.
11 changes: 11 additions & 0 deletions include/MusicLibrary.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
RB3Enhanced - MusicLibrary.h
Functions for interacting with the music library. (Not to be confused with rb3/MusicLibrary.h)
*/

// selects any entry based on the full artist name or the game origin
void MusicLibrarySelectHeading(char *heading);
// selects any entry based on album name
void MusicLibrarySelectSubHeading(char *heading);
// selects a song based on its shortname
void MusicLibrarySelectSong(char *shortname);
5 changes: 3 additions & 2 deletions include/SongSort.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
#include "rb3/Symbol.h"
#include "rb3/SongSortByRecentEntry.h"

SongSortByRecentEntry * SongSortHook(int * songSortByRecent, int * unk, char * songName, char * gameOrigin, int * unk2);
Symbol * GetSymbolByGameOriginHook(Symbol * sym, int gameOrigin);
SongSortByRecentEntry *SongSortByRecentHook(int *songSortByRecent, int *unk, char *songName, char *gameOrigin, int *unk2);
Symbol *GetSymbolByGameOriginHook(Symbol *sym, int gameOrigin);
int GetGameOriginBySymbolHook(Symbol sym);
1 change: 1 addition & 0 deletions include/crc32.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Header file for public domain CRC32 code, from http://home.thep.lu.se/~bjorn/crc/crc32_simple.c
*/

#include <stddef.h>
#include <stdint.h>

void crc32(const void *data, size_t n_bytes, uint32_t *crc);
12 changes: 12 additions & 0 deletions include/ports.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@
#define PORT_PREPARESOMEVECTORMAYBE 0x82796d90 // Prepares some vector, used by BuildInstrumentSelectionList
#define PORT_SOMEVECTORPUSHBACKMAYBE 0x82b6aa10 // vector<class_Key<class_Vector2>,class_stlpmtx_std::StlNodeAlloc<class_Key<class_Vector2>_>_>::push_back
#define PORT_POSTPROC_DOPOST 0x82b89a08 // NgPostProc::DoPost
#define PORT_MUSICLIBRARYSELECTMAYBE 0x8253EB00 // Selects an entry in the Music Library screen - actual name not known
#define PORT_GETSYMBOLBYGAMEORIGIN 0x8265bb78 // SongSortByRecent::GetSymbolByGameOrigin
#define PORT_GETGAMEORIGINBYSYMBOL 0x8265b910 // SongSortByRecent::GetGameOriginBySymbol
#define PORT_SONGSORTBYRECENT 0x8265bde8 // RecentCmp::__ct
// instance addresses
#define PORT_MODIFIERMGR_POINTER 0x82dfec08 // pointer to ModifierManager
#define PORT_ROCKCENTRALGATEWAY 0x82cc8f60 // address of RockCentralGateway
Expand All @@ -110,6 +114,8 @@
#define PORT_THESONGMGR 0x82dfe7b4 // address of TheSongMgr
#define PORT_THEMETAPERFORMER 0x82dfe954 // address of TheMetaPerformer
#define PORT_THEBANDUSERMGR 0x82e023b8 // address of TheBandUserMgr
#define PORT_THESONGSORTMGR 0x82dfee5c // pointer to TheSongSortMgr
#define PORT_THEMUSICLIBRARY 0x82dfd3a8 // pointer to TheMusicLibrary
// import function stubs
#define PORT_XEKEYSSETKEY_STUB 0x82c4c47c
#define PORT_XEKEYSAESCBC_STUB 0x82c4c48c
Expand Down Expand Up @@ -184,12 +190,18 @@ void DbgPrint(const char *s, ...);
#define PORT_PREPARESOMEVECTORMAYBE 0x80247c58 // Prepares some vector, used by BuildInstrumentSelectionList
#define PORT_SOMEVECTORPUSHBACKMAYBE 0x802484a8 // vector<class_Key<class_Vector2>,class_stlpmtx_std::StlNodeAlloc<class_Key<class_Vector2>_>_>::push_back
#define PORT_POSTPROC_DOPOST 0x806b52b4 // WiiPostProc::DoPost
#define PORT_MUSICLIBRARYSELECTMAYBE 0x80230d64 // Selects an entry in the Music Library screen - actual name not known
#define PORT_GETSYMBOLBYGAMEORIGIN 0x8027dd3c // SongSortByRecent::GetSymbolByGameOrigin
#define PORT_GETGAMEORIGINBYSYMBOL 0x8027dc58 // SongSortByRecent::GetGameOriginBySymbol
#define PORT_SONGSORTBYRECENT 0x8027dba8 // RecentCmp::__ct
// instance addresses
#define PORT_MODIFIERMGR_POINTER 0x808fda68 // pointer to ModifierManager
#define PORT_ROCKCENTRALGATEWAY 0x80900870 // address of RockCentralGateway
#define PORT_GDATAFUNCS 0x8091a528 // address of gDataFuncs
#define PORT_THEUI 0x808fc398 // address of TheUI
#define PORT_NULLSYMBOL 0x808540e0 // address of gNullSymbol
#define PORT_THEMUSICLIBRARY 0x808fda84 // pointer to TheMusicLibrary
#define PORT_THESONGSORTMGR 0x808ff988 // pointer to TheSongSortMgr
// string pointers
#define PORT_NASWII_AC_URL 0x808e2310
#define PORT_NASWII_PR_URL 0x808e2390
Expand Down
9 changes: 9 additions & 0 deletions include/rb3/MusicLibrary.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef _MUSICLIBRARY_H
#define _MUSICLIBRARY_H

#include "Symbol.h"

// Jumps to a given entry in the music library
void MusicLibrarySelectMaybe(int theMusicLibrary, Symbol entryName, int sortType, int unk_r6);

#endif // _MUSICLIBRARY_H_
13 changes: 7 additions & 6 deletions include/rb3/SongSortByRecentEntry.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@

typedef struct _SongSortByRecentEntry
{
int * vtablePtr;
int *vtablePtr;
int gameOrigin;
int * acquireTime; // ??? game seems to check if this is 0xFFFFFFFF and if so puts it in "previously acquired", so I'm guessing this is some sort of time since acquired thing
Symbol songName; // probably actually a symbol, need to double-check
int *acquireTime; // ??? game seems to check if this is 0xFFFFFFFF and if so puts it in "previously acquired", so I'm guessing this is some sort of time since acquired thing
Symbol songName; // probably actually a symbol, need to double-check
} SongSortByRecentEntry;

extern SongSortByRecentEntry * SongSort(int * songSortByRecent, int * unk, char * songName, char * gameOrigin, int * unk2);
extern Symbol * GetSymbolByGameOrigin(Symbol * sym, int gameOrigin);
extern SongSortByRecentEntry *SongSortByRecent(int *songSortByRecent, int *dateAcquired, char *songName, Symbol gameOrigin, int *unk2);
extern Symbol *GetSymbolByGameOrigin(Symbol *sym, int gameOrigin);
extern int GetGameOriginBySymbol(Symbol sym);

#endif // _SONGSORTBYRECENTENTRY_H
#endif // _SONGSORTBYRECENTENTRY_H
31 changes: 31 additions & 0 deletions include/rb3_include.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#ifndef _RB3INCLUDE_H
#define _RB3INCLUDE_H

#include "rb3/App.h"
#include "rb3/Archive.h"
#include "rb3/BandLabel.h"
#include "rb3/BandSongMgr.h"
#include "rb3/BandUI.h"
#include "rb3/BandUser.h"
#include "rb3/BandUserMgr.h"
#include "rb3/Data.h"
#include "rb3/File.h"
#include "rb3/Game.h"
#include "rb3/GameGem.h"
#include "rb3/InetAddress.h"
#include "rb3/Locale.h"
#include "rb3/MetaPerformer.h"
#include "rb3/ModifierManager.h"
#include "rb3/MusicLibrary.h"
#include "rb3/PassiveMessagesPanel.h"
#include "rb3/Random.h"
#include "rb3/RockCentralGateway.h"
#include "rb3/SongMetadata.h"
#include "rb3/SongSortByRecentEntry.h"
#include "rb3/SortNode.h"
#include "rb3/String.h"
#include "rb3/Symbol.h"
#include "rb3/TrackPanelDirBase.h"
#include "rb3/UsbWii.h"

#endif // _RB3INCLUDE_H_
29 changes: 29 additions & 0 deletions include/rb3e_include.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#ifndef RB3EINCLUDE_H_
#define RB3EINCLUDE_H_

#include "rb3_include.h"
#include "config.h"
#include "crc32.h"
#include "DTAFunctions.h"
#include "GameHooks.h"
#include "GemHooks.h"
#include "GlobalSymbols.h"
#include "gocentral.h"
#include "inih.h"
#include "LocaleHooks.h"
#include "MusicLibrary.h"
#include "net_events.h"
#include "net.h"
#include "OvershellHooks.h"
#include "ports.h"
#include "ppcasm.h"
#include "rb3enhanced.h"
#include "SetlistHooks.h"
#include "SongHooks.h"
#include "SongSort.h"
#include "SpeedHooks.h"
#include "utilities.h"
#include "wii_usbhid.h"
#include "xbox360.h"

#endif // RB3EINCLUDE_H_
28 changes: 28 additions & 0 deletions source/MusicLibrary.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
RB3Enhanced - MusicLibrary.c
Functions for interacting with the music library.
*/

#include "rb3e_include.h"

// selects any entry based on the full artist name or the game origin
void MusicLibrarySelectHeading(char *heading)
{
Symbol headingname;
SymbolConstruct(&headingname, heading);
MusicLibrarySelectMaybe(*(int *)PORT_THEMUSICLIBRARY, headingname, 2, 1);
}
// selects any entry based on album name
void MusicLibrarySelectSubHeading(char *heading)
{
Symbol headingname;
SymbolConstruct(&headingname, heading);
MusicLibrarySelectMaybe(*(int *)PORT_THEMUSICLIBRARY, headingname, 3, 1);
}
// selects a song based on its shortname
void MusicLibrarySelectSong(char *shortname)
{
Symbol songname;
SymbolConstruct(&songname, shortname);
MusicLibrarySelectMaybe(*(int *)PORT_THEMUSICLIBRARY, songname, 4, 1);
}
2 changes: 2 additions & 0 deletions source/SetlistHooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ static char *originToIcon[][2] = {
{"ugc", "<alt>U</alt> "},
{"ugc_c3", "<alt>y</alt> "},
{"ugc_plus", "<alt>U</alt> "},
{"ugc1", "<alt>U</alt> "},
{"ugc2", "<alt>U</alt> "},
{"lego", "<alt>A</alt> "},
{"greenday", "<alt>0</alt> "},
{"beatles", "<alt>b</alt> "},
Expand Down
67 changes: 32 additions & 35 deletions source/SongSort.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,40 +10,11 @@
#include "rb3/Symbol.h"
#include "rb3/SongSortByRecentEntry.h"

#define RB3E_SONGSORT_START 20
const char *defaultOrigins[11] = {"rb1", "rb2", "rb3", "rb1_dlc", "rb2_dlc", "rb3_dlc", "greenday", "pearljam", "lego", "ugc", "ugc_plus"};
Symbol origins[256] = {0};
int newOrigins = 0;

SongSortByRecentEntry *SongSortHook(int *songSortByRecent, int *unk, char *songName, char *gameOrigin, int *unk2)
{
int i = 0;
SongSortByRecentEntry *entry = SongSort(songSortByRecent, unk, songName, gameOrigin, unk2);

if (!gameOrigin) // if there is no origin, return the default
return entry;
for (i = 0; i < 11; i++)
{ // if it's an existing game origin, return the default
if (strcmp(gameOrigin, defaultOrigins[i]) == 0)
return entry;
}

// it is not an existing song origin, it is custom
RB3E_DEBUG("Non-standard origin detected: %s", gameOrigin);
for (i = 0; i < newOrigins; i++)
{
if (strcmp(origins[i].sym, gameOrigin) == 0)
{
// we've seen this origin before, return the default value
entry->gameOrigin = i + RB3E_SONGSORT_START;
return entry;
}
}
// we haven't seen this origin before, construct the origin
entry->gameOrigin = newOrigins + RB3E_SONGSORT_START;
SymbolConstruct(&origins[newOrigins++], gameOrigin);
return entry;
}
#define RB3E_SONGSORT_START 10
static const char *defaultOrigins[9] = {"rb1", "rb2", "rb3", "greenday", "pearljam", "lego", "rb1_dlc", "rb3_dlc", "ugc_plus"};
static const int defaultOriginCount = 9;
static Symbol origins[256] = {0};
static int newOrigins = 0;

Symbol *GetSymbolByGameOriginHook(Symbol *sym, int gameOrigin)
{
Expand All @@ -54,4 +25,30 @@ Symbol *GetSymbolByGameOriginHook(Symbol *sym, int gameOrigin)
return sym;
}
return GetSymbolByGameOrigin(sym, gameOrigin);
}
}

int GetGameOriginBySymbolHook(Symbol gameOrigin)
{
int i, r = 0;

// if we don't have a game origin or if its 0, return the default
if (gameOrigin.sym == NULL || strlen(gameOrigin.sym) == 0)
return GetGameOriginBySymbol(gameOrigin);

for (i = 0; i < defaultOriginCount; i++)
{
// if it's an existing game origin, return the default
if (strcmp(gameOrigin.sym, defaultOrigins[i]) == 0)
return GetGameOriginBySymbol(gameOrigin);
}
for (i = 0; i < newOrigins; i++)
{
// if we've seen this origin before, return the existing value
if (strcmp(origins[i].sym, gameOrigin.sym) == 0)
return i + RB3E_SONGSORT_START;
}
// we haven't seen this origin before, construct the new origin
r = newOrigins + RB3E_SONGSORT_START;
SymbolConstruct(&origins[newOrigins++], gameOrigin.sym);
return r;
}
6 changes: 4 additions & 2 deletions source/_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ RB3E_STUB(Localize)
RB3E_STUB(SetVenue)
RB3E_STUB(ModifierManagerConstructor)
RB3E_STUB(NewFile)
RB3E_STUB(SongSort)
RB3E_STUB(GetSymbolByGameOrigin)
RB3E_STUB(WillBeNoStrum)
RB3E_STUB(AddGameGem)
RB3E_STUB(SetSongAndArtistName)
Expand All @@ -67,3 +65,7 @@ RB3E_STUB(GameDestruct)
RB3E_STUB(SetSongNameFromNode)
RB3E_STUB(PrepareSomeVectorMaybe)
RB3E_STUB(SomeVectorPushBackMaybe)
RB3E_STUB(MusicLibrarySelectMaybe)
RB3E_STUB(SongSortByRecent)
RB3E_STUB(GetSymbolByGameOrigin)
RB3E_STUB(GetGameOriginBySymbol)
48 changes: 5 additions & 43 deletions source/rb3enhanced.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,9 @@
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include "ports.h"
#include "ppcasm.h"
#include "config.h"
#include "utilities.h"
#include "version.h"
#include "LocaleHooks.h"
#include "GemHooks.h"
#include "GameHooks.h"
#include "GlobalSymbols.h"
#include "OvershellHooks.h"
#include "rb3enhanced.h"
#include "DTAFunctions.h"
#include "SongHooks.h"
#include "SetlistHooks.h"
#include "SpeedHooks.h"
#include "gocentral.h"
#include "wii_usbhid.h"
#include "net.h"
#include "net_events.h"
#include "rb3/App.h"
#include "rb3/BandLabel.h"
#include "rb3/BandSongMgr.h"
#include "rb3/BandUserMgr.h"
#include "rb3/Data.h"
#include "rb3/File.h"
#include "rb3/Game.h"
#include "rb3/GameGem.h"
#include "rb3/InetAddress.h"
#include "rb3/Locale.h"
#include "rb3/MetaPerformer.h"
#include "rb3/ModifierManager.h"
#include "rb3/PassiveMessagesPanel.h"
#include "rb3/Random.h"
#include "rb3/RockCentralGateway.h"
#include "rb3/SortNode.h"
#include "rb3/Symbol.h"
#include "rb3/TrackPanelDirBase.h"
#include "rb3/UsbWii.h"
#include "rb3_include.h"
#include "rb3e_include.h"

static int DefinesStep = 0;
char *DefinesHook(char *string_define, int always_null)
Expand Down Expand Up @@ -207,12 +172,6 @@ void ApplyConfigurablePatches()
POKE_32(PORT_FACE_PAINT_CHECK, LI(3, 1));
POKE_32(PORT_VIDEO_VENUE_CHECK, LI(3, 1));
}
if (config.DisablePostProcessing == 1)
{
// Disables post processing effects
// Should improve framerate on emulators and maybe Wii
POKE_32(PORT_POSTPROC_DOPOST, BLR);
}
}

void InitialiseFunctions()
Expand Down Expand Up @@ -241,6 +200,7 @@ void InitialiseFunctions()
POKE_B(&FileExists, PORT_FILE_EXISTS);
POKE_B(&SetAddress, PORT_SETADDRESS);
POKE_B(&QueueMessage, PORT_QUEUEMESSAGE);
POKE_B(&MusicLibrarySelectMaybe, PORT_MUSICLIBRARYSELECTMAYBE);
RB3E_MSG("Functions initialized!", NULL);
}

Expand All @@ -267,6 +227,8 @@ void ApplyHooks()
HookFunction(PORT_DATAREADFILE, &DataReadFile, &DataReadFileHook);
HookFunction(PORT_GAME_CT, &GameConstruct, &GameConstructHook);
HookFunction(PORT_GAME_DT, &GameDestruct, &GameDestructHook);
HookFunction(PORT_GETSYMBOLBYGAMEORIGIN, &GetSymbolByGameOrigin, &GetSymbolByGameOriginHook);
HookFunction(PORT_GETGAMEORIGINBYSYMBOL, &GetGameOriginBySymbol, &GetGameOriginBySymbolHook);
#ifdef RB3E_WII // wii exclusive hooks
HookFunction(PORT_USBWIIGETTYPE, &UsbWiiGetType, &UsbWiiGetTypeHook);
HookFunction(PORT_WIINETINIT_DNSLOOKUP, &StartDNSLookup, &StartDNSLookupHook);
Expand Down

0 comments on commit f5413b6

Please sign in to comment.