add a safe mode

disables audio output
enables software rendering
disables font loading

not automatic yet
This commit is contained in:
tildearrow 2023-10-16 06:53:21 -05:00
parent 80c9795773
commit c420b55a16
7 changed files with 66 additions and 9 deletions

View file

@ -75,6 +75,8 @@ bool displayEngineFailError=false;
bool cmdOutBinary=false;
bool vgmOutDirect=false;
bool safeMode=false;
std::vector<TAParam> params;
TAParamResult pHelp(String) {
@ -99,8 +101,10 @@ TAParamResult pAudio(String val) {
e.setAudio(DIV_AUDIO_JACK);
} else if (val=="sdl") {
e.setAudio(DIV_AUDIO_SDL);
} else if (val=="portaudio") {
e.setAudio(DIV_AUDIO_PORTAUDIO);
} else {
logE("invalid value for audio engine! valid values are: jack, sdl.");
logE("invalid value for audio engine! valid values are: jack, sdl, portaudio.");
return TA_PARAM_ERROR;
}
return TA_PARAM_SUCCESS;
@ -125,6 +129,11 @@ TAParamResult pConsole(String val) {
return TA_PARAM_SUCCESS;
}
TAParamResult pSafeMode(String val) {
safeMode=true;
return TA_PARAM_SUCCESS;
}
TAParamResult pBinary(String val) {
cmdOutBinary=true;
return TA_PARAM_SUCCESS;
@ -171,6 +180,9 @@ TAParamResult pVersion(String) {
printf("- RtMidi by Gary P. Scavone (RtMidi license)\n");
printf("- backward-cpp by Google (MIT)\n");
printf("- Dear ImGui by Omar Cornut (MIT)\n");
#ifdef HAVE_FREETYPE
printf("- FreeType (GPLv2)\n");
#endif
printf("- Portable File Dialogs by Sam Hocevar (WTFPL)\n");
printf("- Native File Dialog (modified version) by Frogtoss Games (zlib license)\n");
printf("- FFTW by Matteo Frigo and Steven G. Johnson (GPLv2)\n");
@ -326,7 +338,7 @@ bool needsValue(String param) {
void initParams() {
params.push_back(TAParam("h","help",false,pHelp,"","display this help"));
params.push_back(TAParam("a","audio",true,pAudio,"jack|sdl","set audio engine (SDL by default)"));
params.push_back(TAParam("a","audio",true,pAudio,"jack|sdl|portaudio","set audio engine (SDL by default)"));
params.push_back(TAParam("o","output",true,pOutput,"<filename>","output audio to file"));
params.push_back(TAParam("O","vgmout",true,pVGMOut,"<filename>","output .vgm data"));
params.push_back(TAParam("D","direct",false,pDirect,"","set VGM export direct stream mode"));
@ -340,6 +352,7 @@ void initParams() {
params.push_back(TAParam("l","loops",true,pLoops,"<count>","set number of loops (-1 means loop forever)"));
params.push_back(TAParam("s","subsong",true,pSubSong,"<number>","set sub-song"));
params.push_back(TAParam("o","outmode",true,pOutMode,"one|persys|perchan","set file output mode"));
params.push_back(TAParam("S","safemode",false,pSafeMode,"","enable safe mode (software rendering and no audio)"));
params.push_back(TAParam("B","benchmark",true,pBenchmark,"render|seek","run performance test"));
@ -496,6 +509,10 @@ int main(int argc, char** argv) {
e.preInit();
if (safeMode) {
e.setAudio(DIV_AUDIO_DUMMY);
}
if (!fileName.empty() && ((!e.getConfBool("tutIntroPlayed",false)) || e.getConfInt("alwaysPlayIntro",0)!=3 || consoleMode || benchMode || outName!="" || vgmOutName!="" || cmdOutName!="")) {
logI("loading module...");
FILE* f=ps_fopen(fileName.c_str(),"rb");
@ -654,6 +671,7 @@ int main(int argc, char** argv) {
}
#ifdef HAVE_GUI
if (safeMode) g.enableSafeMode();
g.bindEngine(&e);
if (!g.init()) {
reportError(g.getLastError());