Skip to content

Commit

Permalink
Game Name specification in Core
Browse files Browse the repository at this point in the history
allows Core to know which game we're playing
  • Loading branch information
LittleCoaks committed Jul 30, 2023
1 parent 316eb53 commit 2efbe60
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Source/Core/Core/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ static Common::EventHook s_frame_presented = AfterPresentEvent::Register(
"Core Frame Presented");

DefaultGeckoCodes CodeWriter;
static GameName mGameBeingPlayed = GameName::UnknownGame;
const std::map<std::string, GameName> mGameMap = {
{"GYQE01", GameName::MarioBaseball},
{"GFTE01", GameName::ToadstoolTour}
};

bool GetIsThrottlerTempDisabled()
{
Expand Down Expand Up @@ -220,6 +225,9 @@ void FrameUpdateOnCPUThread()
// anything that needs to read or write to memory should be getting run from here
void RunRioFunctions(const Core::CPUThreadGuard& guard)
{
if (mGameBeingPlayed != GameName::MarioBaseball)
return;

if (s_stat_tracker) {
s_stat_tracker->Run(guard);
}
Expand Down Expand Up @@ -749,6 +757,13 @@ bool Init(std::unique_ptr<BootParameters> boot, const WindowSystemInfo& wsi)
s_is_booting.Set();
s_emu_thread = std::thread(EmuThread, std::move(boot), prepared_wsi);

// initialize current game variable
std::string game_id = SConfig::GetInstance().GetGameID();
if (Core::mGameMap.find(game_id) == mGameMap.end())
mGameBeingPlayed = GameName::UnknownGame;
else
mGameBeingPlayed = mGameMap.at(game_id);

std::optional<std::vector<ClientCode>> client_codes =
GetActiveTagSet(NetPlay::IsNetPlayRunning()).has_value() ?
GetActiveTagSet(NetPlay::IsNetPlayRunning()).value().client_codes_vector() :
Expand Down
7 changes: 7 additions & 0 deletions Source/Core/Core/Core.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <string>
#include <string_view>
#include <optional>
#include <map>

#include "Common/CommonTypes.h"

Expand Down Expand Up @@ -49,6 +50,12 @@ enum class State
Starting,
};

enum class GameName : u8 {
UnknownGame = 0,
MarioBaseball = 1,
ToadstoolTour = 2,
};

// Console type values based on:
// - YAGCD 4.2.1.1.2
// - OSInit (GameCube ELF from Finding Nemo)
Expand Down

0 comments on commit 2efbe60

Please sign in to comment.