Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/dusk/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ extern bool IsRunning;
extern bool IsShuttingDown;
extern bool IsGameLaunched;
extern bool RestartRequested;
extern uint8_t SaveRequested;
extern std::string StageRequested;
extern std::filesystem::path ConfigPath;
extern std::filesystem::path CachePath;

Expand Down
80 changes: 79 additions & 1 deletion src/d/d_s_logo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,13 @@
#include "m_Do/m_Do_main.h"
#include "JSystem/JUtility/JUTConsole.h"

#ifdef TARGET_PC
#include <sstream>
#include "dusk/logging.h"
#include "dusk/version.hpp"
#include "dusk/main.h"
#include "m_Do/m_Do_MemCard.h"
#endif

#if !PLATFORM_GCN
#include <revolution/os.h>
Expand Down Expand Up @@ -757,7 +762,80 @@ void dScnLogo_c::nextSceneChange() {
if (!mDoRst::isReset()) {
if (!isOpeningCut())
{
dComIfG_changeOpeningScene(this, fpcNm_OPENING_SCENE_e);
#ifdef TARGET_PC
// If we are requesting a save from the command line, load it here and set the scene to play instead of loading the LOGO SCENE
if (dusk::SaveRequested >= 1 && dusk::SaveRequested <= 3) {
u8 buf[SAVEDATA_SIZE * 3];
mDoMemCd_Load();
uint8_t status;
do {
status = mDoMemCd_LoadSync(buf, sizeof(buf), 0);
// Wait until the card is loaded
} while (status == 0);

if (status == 1) {
dComIfGs_setCardToMemory(buf, dusk::SaveRequested - 1);
} else {
dComIfGs_init();
}

dComIfGs_setNoFile(dusk::SaveRequested);
dComIfGs_setDataNum(dusk::SaveRequested-1);

dComIfGs_gameStart();

fopScnM_ChangeReq(this, fpcNm_PLAY_SCENE_e, 0, 30);

dKy_clear_game_init();
dComIfGs_resetDan();
dComIfGs_setRestartRoomParam(0);

DuskLog.info("Loaded Save From Slot {}",dusk::SaveRequested);
dusk::SaveRequested = 0xff;
} else if (dusk::SaveRequested == 0xff) {
// This indicates that the save has loaded, but we are waiting for the scene
// manager to change to play
} else if (dusk::StageRequested.size() > 0) {

} else{
#endif
dComIfG_changeOpeningScene(this, fpcNm_OPENING_SCENE_e);
#ifdef TARGET_PC
}

if (dusk::StageRequested.size() > 0) {
std::stringstream ss(dusk::StageRequested);
std::string token;

std::getline(ss,token,',');
std::string stageName = token;
s8 room = 0;
s16 point = 0;
s8 layer = -1;
if (std::getline(ss,token,',')) {
room = std::stoi(token);
Comment thread
encounter marked this conversation as resolved.
Outdated
if (std::getline(ss,token,',')) {
point = std::stoi(token);
if (std::getline(ss,token,',')) {
layer = std::stoi(token);
}
}
}

if (dusk::SaveRequested == 0) {
dComIfGs_init();

fopScnM_ChangeReq(this, fpcNm_PLAY_SCENE_e, 0, 30);
dusk::SaveRequested = 0xff; //Skip requesting the scene from above
}

// Use both to force-set start stage
dComIfGp_setNextStage(stageName.c_str(), point, room, layer);
g_dComIfG_gameInfo.play.mNextStage.getStartStage()->set(stageName.c_str(),point,room,layer);
Comment thread
encounter marked this conversation as resolved.
Outdated

dusk::StageRequested = ""; //Reset so we don't re-do this
}
#endif
} else {
#if DEBUG
fopScnM_ChangeReq(this, fpcNm_MENU_SCENE_e, 0, 30);
Expand Down
26 changes: 23 additions & 3 deletions src/m_Do/m_Do_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ bool dusk::IsRunning = true;
bool dusk::IsShuttingDown = false;
bool dusk::IsGameLaunched = false;
bool dusk::RestartRequested = false;
uint8_t dusk::SaveRequested = 0;
std::string dusk::StageRequested;
std::filesystem::path dusk::ConfigPath;
std::filesystem::path dusk::CachePath;
#endif
Expand Down Expand Up @@ -516,7 +518,10 @@ int game_main(int argc, char* argv[]) {
("dvd", "Path to DVD image file", cxxopts::value<std::string>())
("mods", "Path to mods directory", cxxopts::value<std::string>())
("backend", "Graphics API backend to use (auto, d3d12, d3d11, metal, vulkan, null)", cxxopts::value<std::string>())
("cvar", "Override configuration variables without modifying config", cxxopts::value<std::vector<std::string>>());
("cvar", "Override configuration variables without modifying config", cxxopts::value<std::vector<std::string>>())
("develop", "Enable the game's developer mode and OSReport for debugging", cxxopts::value<bool>()->default_value("false")->implicit_value("true"))
("load-save", "Skip the opening and load a save from slot 1-3", cxxopts::value<uint8_t>()->default_value("0"))
("stage", "Upon launching, load a stage, room, spawn point, and layer. Format (STAGE,ROOM,POINT,LAYER). Example: (STAGE) or (STAGE,0,0,-1)", cxxopts::value<std::string>());

arg_options.parse_positional({"dvd"});
arg_options.positional_help("<dvd-image>");
Expand All @@ -542,6 +547,12 @@ int game_main(int argc, char* argv[]) {
dusk::CachePath = dataPaths.cachePath;
dusk::InitializeFileLogging(dusk::CachePath, startupLogLevel);

// Development Mode
if (parsed_arg_options.count("develop")) {
mDoMain::developmentMode = parsed_arg_options["develop"].as<bool>(); // Enable Dev Mode for Debugging
dusk::OSReportReallyForceEnable = parsed_arg_options["develop"].as<bool>(); // Print OSReport to console
}

log_build_info();

dusk::config::load_from_user_preferences();
Expand Down Expand Up @@ -784,8 +795,17 @@ int game_main(int argc, char* argv[]) {
// Global Context Init
dComIfG_ct();

// Development Mode
// mDoMain::developmentMode = 1; // Force Dev Mode for Debugging
// Load save from here
if (parsed_arg_options.contains("load-save")){
uint8_t slot = parsed_arg_options["load-save"].as<uint8_t>();
if (slot >= 1 && slot <= 3) {
dusk::SaveRequested = slot;
}
}
if (parsed_arg_options.contains("stage")) {
dusk::StageRequested = parsed_arg_options["stage"].as<std::string>();
}

mDoDvdThd::SyncWidthSound = false;

// Mod search directories, highest priority first: user dir (--mods replaces it), then
Expand Down
Loading