Skip to content

Commit

Permalink
Added "-nodebug 1" flag for gens to start without IDA waiting.
Browse files Browse the repository at this point in the history
  • Loading branch information
lab313ru committed Feb 4, 2023
1 parent 0bcf7c0 commit f7a136c
Show file tree
Hide file tree
Showing 4 changed files with 182 additions and 169 deletions.
5 changes: 5 additions & 0 deletions Gens/gens.vcxproj.user
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,9 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release8|Win32'">
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug_68k|Win32'">
<LocalDebuggerCommandArguments>-nodebug 1</LocalDebuggerCommandArguments>
<LocalDebuggerWorkingDirectory>$(OutDir)</LocalDebuggerWorkingDirectory>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
</Project>
2 changes: 2 additions & 0 deletions Gens/include/g_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ extern "C" {
extern char Gens_Path[1024];
extern POINT Window_Pos;

extern int no_debug; // -nodebug cmdline flag

#define MAX_RECENT_SCRIPTS 15
extern char Recent_Scripts[MAX_RECENT_SCRIPTS][1024];

Expand Down
5 changes: 4 additions & 1 deletion Gens/src/g_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ HWND RamCheatHWnd = NULL; // modeless dialog
std::vector<HWND> LuaScriptHWnds; // modeless dialogs
HWND VolControlHWnd = NULL;

int no_debug = 0;
char Str_Tmp[1024];
char Comment[256];
char Gens_Path[1024];
Expand Down Expand Up @@ -2654,7 +2655,9 @@ int GensLoadRom(const char* filename)

ReopenRamWindows();

init_dbg_server();
if (!no_debug) {
init_dbg_server();
}

return loaded; // positive = success
}
Expand Down
339 changes: 171 additions & 168 deletions Gens/src/parsecmdline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,179 +21,182 @@ extern int Paused;

void ParseCmdLine(LPSTR lpCmdLine, HWND HWnd)
{
std::string argumentList; //Complete command line argument
argumentList.assign(lpCmdLine); //Assign command line to argumentList
int argLength = argumentList.size(); //Size of command line argument

//List of valid commandline args
std::string argCmds[] = { "-cfg", "-rom", "-play", "-readwrite", "-loadstate", "-pause", "-lua", "" }; //Hint: to add new commandlines, start by inserting them here.

//Strings that will get parsed:
std::string CfgToLoad = ""; //Cfg filename
std::string RomToLoad = ""; //ROM filename
std::string MovieToLoad = ""; //Movie filename
std::string StateToLoad = ""; //Savestate filename
std::vector<std::string> ScriptsToLoad; //Lua script filenames
std::string FileToLoad = ""; //Any file
std::string PauseGame = ""; //adelikat: If user puts anything after -pause it will flag true, documentation will probably say put "1". There is no case for "-paused 0" since, to my knowledge, it would serve no purpose
std::string ReadWrite = ""; //adelikat: Read Only is the default so this will be the same situation as above, any value will set to read+write status

//Temps for finding string list
int commandBegin = 0; //Beginning of Command
int commandEnd = 0; //End of Command
std::string newCommand; //Will hold newest command being parsed in the loop
std::string trunc; //Truncated argList (from beginning of command to end of argumentList

//--------------------------------------------------------------------------------------------
//Commandline parsing loop
for (int x = 0; x < (sizeof argCmds / sizeof std::string); x++)
std::string argumentList; //Complete command line argument
argumentList.assign(lpCmdLine); //Assign command line to argumentList
int argLength = argumentList.size(); //Size of command line argument

//List of valid commandline args
std::string argCmds[] = { "-cfg", "-rom", "-play", "-readwrite", "-loadstate", "-pause", "-lua", "-nodebug", "" }; //Hint: to add new commandlines, start by inserting them here.

//Strings that will get parsed:
std::string CfgToLoad = ""; //Cfg filename
std::string RomToLoad = ""; //ROM filename
std::string MovieToLoad = ""; //Movie filename
std::string StateToLoad = ""; //Savestate filename
std::vector<std::string> ScriptsToLoad; //Lua script filenames
std::string FileToLoad = ""; //Any file
std::string PauseGame = ""; //adelikat: If user puts anything after -pause it will flag true, documentation will probably say put "1". There is no case for "-paused 0" since, to my knowledge, it would serve no purpose
std::string ReadWrite = ""; //adelikat: Read Only is the default so this will be the same situation as above, any value will set to read+write status

//Temps for finding string list
int commandBegin = 0; //Beginning of Command
int commandEnd = 0; //End of Command
std::string newCommand; //Will hold newest command being parsed in the loop
std::string trunc; //Truncated argList (from beginning of command to end of argumentList

//--------------------------------------------------------------------------------------------
//Commandline parsing loop
for (int x = 0; x < (sizeof argCmds / sizeof std::string); x++)
{
if (argumentList.find(argCmds[x]) != std::string::npos)
{
if (argumentList.find(argCmds[x]) != std::string::npos)
{
commandBegin = argumentList.find(argCmds[x]) + argCmds[x].size() + (argCmds[x].empty() ? 0 : 1); //Find beginning of new command
trunc = argumentList.substr(commandBegin); //Truncate argumentList
commandEnd = trunc.find(" "); //Find next space, if exists, new command will end here
if (argumentList[commandBegin] == '\"') //Actually, if it's in quotes, extend to the end quote
{
commandEnd = trunc.find('\"', 1);
if (commandEnd >= 0)
commandBegin++, commandEnd--;
}
if (commandEnd < 0) commandEnd = argLength; //If no space, new command will end at the end of list
newCommand = argumentList.substr(commandBegin, commandEnd); //assign freshly parsed command to newCommand
}
else
newCommand.clear();

//Assign newCommand to appropriate variable
switch (x)
{
case 0: //-cfg
CfgToLoad = newCommand;
break;
case 1: //-rom
RomToLoad = newCommand;
break;
case 2: //-play
MovieToLoad = newCommand;
break;
case 3: //-readwrite
ReadWrite = newCommand;
break;
case 4: //-loadstate
StateToLoad = newCommand;
break;
case 5: //-pause
PauseGame = newCommand;
break;
case 6: //-lua
ScriptsToLoad.push_back(newCommand);
break;
case 7: // (a filename on its own, this must come BEFORE any other options on the commandline)
if (newCommand[0] != '-')
FileToLoad = newCommand;
break;
}
commandBegin = argumentList.find(argCmds[x]) + argCmds[x].size() + (argCmds[x].empty() ? 0 : 1); //Find beginning of new command
trunc = argumentList.substr(commandBegin); //Truncate argumentList
commandEnd = trunc.find(" "); //Find next space, if exists, new command will end here
if (argumentList[commandBegin] == '\"') //Actually, if it's in quotes, extend to the end quote
{
commandEnd = trunc.find('\"', 1);
if (commandEnd >= 0)
commandBegin++, commandEnd--;
}
if (commandEnd < 0) commandEnd = argLength; //If no space, new command will end at the end of list
newCommand = argumentList.substr(commandBegin, commandEnd); //assign freshly parsed command to newCommand
}
//--------------------------------------------------------------------------------------------
//Execute commands
else
newCommand.clear();

// anything (rom, movie, cfg, luascript, etc.)
if (FileToLoad[0])
//Assign newCommand to appropriate variable
switch (x)
{
GensOpenFile(FileToLoad.c_str());
case 0: //-cfg
CfgToLoad = newCommand;
break;
case 1: //-rom
RomToLoad = newCommand;
break;
case 2: //-play
MovieToLoad = newCommand;
break;
case 3: //-readwrite
ReadWrite = newCommand;
break;
case 4: //-loadstate
StateToLoad = newCommand;
break;
case 5: //-pause
PauseGame = newCommand;
break;
case 6: //-lua
ScriptsToLoad.push_back(newCommand);
break;
case 7: //-nodebug
no_debug = 1;
break;
case 8: // (a filename on its own, this must come BEFORE any other options on the commandline)
if (newCommand[0] != '-')
FileToLoad = newCommand;
break;
}

//Cfg
if (CfgToLoad[0])
{
Load_Config((char*)CfgToLoad.c_str(), NULL);
strcpy(Str_Tmp, "config loaded from ");
strcat(Str_Tmp, CfgToLoad.c_str());
Put_Info(Str_Tmp);
}

//ROM
if (RomToLoad[0])
}
//--------------------------------------------------------------------------------------------
//Execute commands

// anything (rom, movie, cfg, luascript, etc.)
if (FileToLoad[0])
{
GensOpenFile(FileToLoad.c_str());
}

//Cfg
if (CfgToLoad[0])
{
Load_Config((char*)CfgToLoad.c_str(), NULL);
strcpy(Str_Tmp, "config loaded from ");
strcat(Str_Tmp, CfgToLoad.c_str());
Put_Info(Str_Tmp);
}

//ROM
if (RomToLoad[0])
{
GensLoadRom(RomToLoad.c_str());
}

//Movie
if (MovieToLoad[0]) GensPlayMovie(MovieToLoad.c_str(), 1);

//Read+Write
if (ReadWrite[0] && MainMovie.ReadOnly != 2) MainMovie.ReadOnly = 0;

//Loadstate
if (StateToLoad[0])
{
Load_State((char*)StateToLoad.c_str());
}

//Lua Scripts
for (unsigned int i = 0; i < ScriptsToLoad.size(); i++)
{
if (ScriptsToLoad[i][0])
{
GensLoadRom(RomToLoad.c_str());
const char* error = GensOpenScript(ScriptsToLoad[i].c_str());
if (error)
fprintf(stderr, "failed to start script \"%s\" because: %s\n", ScriptsToLoad[i].c_str(), error);
}

//Movie
if (MovieToLoad[0]) GensPlayMovie(MovieToLoad.c_str(), 1);

//Read+Write
if (ReadWrite[0] && MainMovie.ReadOnly != 2) MainMovie.ReadOnly = 0;

//Loadstate
if (StateToLoad[0])
{
Load_State((char*)StateToLoad.c_str());
}

//Lua Scripts
for (unsigned int i = 0; i < ScriptsToLoad.size(); i++)
{
if (ScriptsToLoad[i][0])
{
const char* error = GensOpenScript(ScriptsToLoad[i].c_str());
if (error)
fprintf(stderr, "failed to start script \"%s\" because: %s\n", ScriptsToLoad[i].c_str(), error);
}
}

//Paused
if (PauseGame[0]) Paused = 1;

/* OLD CODE
char Str_Tmpy[1024];
int src;
#ifdef CC_SUPPORT
// src = CC_Connect("CCGEN://Stef:gens@emu.consoleclassix.com/sonicthehedgehog2.gen", (char *) Rom_Data, CC_End_Callback);
src = CC_Connect(lpCmdLine, (char *) Rom_Data, CC_End_Callback);
if (src == 0)
{
Load_Rom_CC(CCRom.RName, CCRom.RSize);
Build_Main_Menu();
}
else if (src == 1)
{
MessageBox(HWnd, "Error during connection", NULL, MB_OK);
}
else if (src == 2)
{
#endif
src = 0;
if (lpCmdLine[src] == '"')
{
src++;
while ((lpCmdLine[src] != '"') && (lpCmdLine[src] != 0))
{
Str_Tmpy[src - 1] = lpCmdLine[src];
src++;
}
Str_Tmpy[src - 1] = 0;
}
else
{
while (lpCmdLine[src] != 0)
{
Str_Tmpy[src] = lpCmdLine[src];
src++;
}
Str_Tmpy[src] = 0;
}
Pre_Load_Rom(HWnd, Str_Tmpy);
#ifdef CC_SUPPORT
}
#endif
*/
}

//Paused
if (PauseGame[0]) Paused = 1;

/* OLD CODE
char Str_Tmpy[1024];
int src;
#ifdef CC_SUPPORT
// src = CC_Connect("CCGEN://Stef:gens@emu.consoleclassix.com/sonicthehedgehog2.gen", (char *) Rom_Data, CC_End_Callback);
src = CC_Connect(lpCmdLine, (char *) Rom_Data, CC_End_Callback);
if (src == 0)
{
Load_Rom_CC(CCRom.RName, CCRom.RSize);
Build_Main_Menu();
}
else if (src == 1)
{
MessageBox(HWnd, "Error during connection", NULL, MB_OK);
}
else if (src == 2)
{
#endif
src = 0;
if (lpCmdLine[src] == '"')
{
src++;
while ((lpCmdLine[src] != '"') && (lpCmdLine[src] != 0))
{
Str_Tmpy[src - 1] = lpCmdLine[src];
src++;
}
Str_Tmpy[src - 1] = 0;
}
else
{
while (lpCmdLine[src] != 0)
{
Str_Tmpy[src] = lpCmdLine[src];
src++;
}
Str_Tmpy[src] = 0;
}
Pre_Load_Rom(HWnd, Str_Tmpy);
#ifdef CC_SUPPORT
}
#endif
*/
}

0 comments on commit f7a136c

Please sign in to comment.