Move remaining options used by core to CoreOptions

This commit is contained in:
Fabrice de Gans 2023-02-14 16:08:25 -08:00 committed by Fabrice de Gans
parent 3f507b6c6a
commit d37a3a32e1
13 changed files with 70 additions and 78 deletions

View File

@ -103,8 +103,6 @@ const char* batteryDir;
const char* biosFileNameGB;
const char* biosFileNameGBA;
const char* biosFileNameGBC;
const char* loadDotCodeFile;
const char* saveDotCodeFile;
const char* saveDir;
const char* screenShotDir;
int agbPrint;
@ -126,9 +124,6 @@ int preparedCheats = 0;
int rewindTimer = 0;
int showSpeed;
int showSpeedTransparent;
uint32_t throttle = 100;
uint32_t speedup_throttle = 100;
uint32_t speedup_frame_skip = 9;
bool allowKeyboardBackgroundInput = false;
bool allowJoystickBackgroundInput = true;
@ -324,14 +319,14 @@ void LoadConfig()
gb_effects_config.stereo = (float)ReadPref("gbSoundEffectsStereo", 15) / 100.0f;
gb_effects_config.surround = ReadPref("gbSoundEffectsSurround", 0);
ifbType = ReadPref("ifbType", 0);
loadDotCodeFile = ReadPrefString("loadDotCodeFile");
coreOptions.loadDotCodeFile = ReadPrefString("loadDotCodeFile");
openGL = ReadPrefHex("openGL");
optFlashSize = ReadPref("flashSize", 0);
pauseWhenInactive = ReadPref("pauseWhenInactive", 1);
rewindTimer = ReadPref("rewindTimer", 0);
coreOptions.rtcEnabled = ReadPref("rtcEnabled", 0);
saveDir = ReadPrefString("saveDir");
saveDotCodeFile = ReadPrefString("saveDotCodeFile");
coreOptions.saveDotCodeFile = ReadPrefString("saveDotCodeFile");
screenShotDir = ReadPrefString("screenShotDir");
showSpeed = ReadPref("showSpeed", 0);
showSpeedTransparent = ReadPref("showSpeedTransparent", 1);
@ -340,9 +335,9 @@ void LoadConfig()
coreOptions.skipSaveGameCheats = ReadPref("skipSaveGameCheats", 0);
soundFiltering = (float)ReadPref("gbaSoundFiltering", 50) / 100.0f;
soundInterpolation = ReadPref("gbaSoundInterpolation", 1);
throttle = ReadPref("throttle", 100);
speedup_throttle = ReadPref("speedupThrottle", 100);
speedup_frame_skip = ReadPref("speedupFrameSkip", 9);
coreOptions.throttle = ReadPref("throttle", 100);
coreOptions.speedup_throttle = ReadPref("speedupThrottle", 100);
coreOptions.speedup_frame_skip = ReadPref("speedupFrameSkip", 9);
coreOptions.speedup_throttle_frame_skip = ReadPref("speedupThrottleFrameSkip", 0);
coreOptions.useBios = ReadPrefHex("useBiosGBA");
coreOptions.winGbPrinterEnabled = ReadPref("gbPrinter", 0);
@ -747,10 +742,10 @@ int ReadOpts(int argc, char ** argv)
filter = kStretch2x;
}
break;
case 'T':
if (optarg)
throttle = atoi(optarg);
break;
case 'T':
if (optarg)
coreOptions.throttle = atoi(optarg);
break;
case 'I':
if (optarg) {
ifbType = (IFBFilter)atoi(optarg);
@ -946,20 +941,20 @@ int ReadOpts(int argc, char ** argv)
case OPT_DOTCODE_FILE_NAME_LOAD:
// --dotcode-file-name-load
loadDotCodeFile = optarg;
coreOptions.loadDotCodeFile = optarg;
break;
case OPT_DOTCODE_FILE_NAME_SAVE:
// --dotcode-file-name-save
saveDotCodeFile = optarg;
coreOptions.saveDotCodeFile = optarg;
break;
case OPT_SPEEDUP_THROTTLE:
if (optarg)
speedup_throttle = atoi(optarg);
coreOptions.speedup_throttle = atoi(optarg);
break;
case OPT_SPEEDUP_FRAME_SKIP:
if (optarg)
speedup_frame_skip = atoi(optarg);
coreOptions.speedup_frame_skip = atoi(optarg);
break;
case OPT_NO_SPEEDUP_THROTTLE_FRAME_SKIP:
coreOptions.speedup_throttle_frame_skip = false;

View File

@ -39,13 +39,16 @@ extern struct CoreOptions {
int skipSaveGameCheats = 0;
int useBios = 0;
int winGbPrinterEnabled = 1;
uint32_t speedup_throttle = 100;
uint32_t speedup_frame_skip = 9;
uint32_t throttle = 100;
const char *loadDotCodeFile = nullptr;
const char *saveDotCodeFile = nullptr;
} coreOptions;
extern const char *biosFileNameGB;
extern const char *biosFileNameGBA;
extern const char *biosFileNameGBC;
extern const char *loadDotCodeFile;
extern const char *saveDotCodeFile;
extern int agbPrint;
extern int autoFireMaxCount;
extern int autoFrameSkip;
@ -64,9 +67,6 @@ extern int pauseWhenInactive;
extern int rewindTimer;
extern int showSpeed;
extern int showSpeedTransparent;
extern uint32_t throttle;
extern uint32_t speedup_throttle;
extern uint32_t speedup_frame_skip;
extern bool allowKeyboardBackgroundInput;
extern bool allowJoystickBackgroundInput;

View File

@ -31,7 +31,7 @@ const double SoundSDL::buftime = 0.100;
SoundSDL::SoundSDL():
samples_buf(0),
sound_device(0),
current_rate(static_cast<unsigned short>(throttle)),
current_rate(static_cast<unsigned short>(coreOptions.throttle)),
initialized(false)
{}

View File

@ -4958,17 +4958,17 @@ void gbEmulate(int ticksToStop)
static uint32_t last_throttle;
if (turbo_button_pressed) {
if (speedup_frame_skip)
framesToSkip = speedup_frame_skip;
if (coreOptions.speedup_frame_skip)
framesToSkip = coreOptions.speedup_frame_skip;
else {
if (!speedup_throttle_set && throttle != speedup_throttle) {
last_throttle = throttle;
soundSetThrottle(speedup_throttle);
if (!speedup_throttle_set && coreOptions.throttle != coreOptions.speedup_throttle) {
last_throttle = coreOptions.throttle;
soundSetThrottle(coreOptions.speedup_throttle);
speedup_throttle_set = true;
}
if (coreOptions.speedup_throttle_frame_skip)
framesToSkip += std::ceil(double(speedup_throttle) / 100.0) - 1;
framesToSkip += std::ceil(double(coreOptions.speedup_throttle) / 100.0) - 1;
}
}
else if (speedup_throttle_set) {

View File

@ -1707,40 +1707,40 @@ void doMirroring(bool b)
const char* GetLoadDotCodeFile()
{
return loadDotCodeFile;
return coreOptions.loadDotCodeFile;
}
const char* GetSaveDotCodeFile()
{
return saveDotCodeFile;
return coreOptions.saveDotCodeFile;
}
void ResetLoadDotCodeFile()
{
if (loadDotCodeFile) {
free((char*)loadDotCodeFile);
if (coreOptions.loadDotCodeFile) {
free((char*)coreOptions.loadDotCodeFile);
}
loadDotCodeFile = strdup("");
coreOptions.loadDotCodeFile = strdup("");
}
void SetLoadDotCodeFile(const char* szFile)
{
loadDotCodeFile = strdup(szFile);
coreOptions.loadDotCodeFile = strdup(szFile);
}
void ResetSaveDotCodeFile()
{
if (saveDotCodeFile) {
free((char*)saveDotCodeFile);
if (coreOptions.saveDotCodeFile) {
free((char*)coreOptions.saveDotCodeFile);
}
saveDotCodeFile = strdup("");
coreOptions.saveDotCodeFile = strdup("");
}
void SetSaveDotCodeFile(const char* szFile)
{
saveDotCodeFile = strdup(szFile);
coreOptions.saveDotCodeFile = strdup(szFile);
}
void CPUUpdateRender()
@ -3825,17 +3825,17 @@ void CPULoop(int ticks)
static uint32_t last_throttle;
if (turbo_button_pressed) {
if (speedup_frame_skip)
framesToSkip = speedup_frame_skip;
if (coreOptions.speedup_frame_skip)
framesToSkip = coreOptions.speedup_frame_skip;
else {
if (!speedup_throttle_set && throttle != speedup_throttle) {
last_throttle = throttle;
soundSetThrottle(speedup_throttle);
if (!speedup_throttle_set && coreOptions.throttle != coreOptions.speedup_throttle) {
last_throttle = coreOptions.throttle;
soundSetThrottle(coreOptions.speedup_throttle);
speedup_throttle_set = true;
}
if (coreOptions.speedup_throttle_frame_skip)
framesToSkip += std::ceil(double(speedup_throttle) / 100.0) - 1;
framesToSkip += std::ceil(double(coreOptions.speedup_throttle) / 100.0) - 1;
}
}
else if (speedup_throttle_set) {

View File

@ -22,9 +22,6 @@
#define _stricmp strcasecmp
#endif // ! _MSC_VER
const char* loadDotCodeFile;
const char* saveDotCodeFile;
void utilPutDword(uint8_t* p, uint32_t value)
{
*p++ = value & 255;

View File

@ -2457,7 +2457,7 @@ EVT_HANDLER(GeneralConfigure, "General options...")
update_opts();
if (panel->game_type() != IMAGE_UNKNOWN)
soundSetThrottle(throttle);
soundSetThrottle(coreOptions.throttle);
if (rew != gopts.rewind_interval) {
if (!gopts.rewind_interval) {
@ -2481,16 +2481,16 @@ EVT_HANDLER(SpeedupConfigure, "Speedup / Turbo options...")
{
wxDialog* dlg = GetXRCDialog("SpeedupConfig");
unsigned save_speedup_throttle = speedup_throttle;
unsigned save_speedup_frame_skip = speedup_frame_skip;
unsigned save_speedup_throttle = coreOptions.speedup_throttle;
unsigned save_speedup_frame_skip = coreOptions.speedup_frame_skip;
bool save_speedup_throttle_frame_skip = coreOptions.speedup_throttle_frame_skip;
if (ShowModal(dlg) == wxID_OK)
update_opts();
else {
// Restore values if cancel pressed.
speedup_throttle = save_speedup_throttle;
speedup_frame_skip = save_speedup_frame_skip;
coreOptions.speedup_throttle = save_speedup_throttle;
coreOptions.speedup_frame_skip = save_speedup_frame_skip;
coreOptions.speedup_throttle_frame_skip = save_speedup_throttle_frame_skip;
}
}

View File

@ -268,9 +268,9 @@ std::array<Option, kNbOptions>& Option::All() {
Option(OptionID::kPrefSkipBios, &coreOptions.skipBios, 0, 1),
Option(OptionID::kPrefSkipSaveGameCheats, &coreOptions.skipSaveGameCheats, 0, 1),
Option(OptionID::kPrefSkipSaveGameBattery, &coreOptions.skipSaveGameBattery, 0, 1),
Option(OptionID::kPrefThrottle, &throttle, 0, 450),
Option(OptionID::kPrefSpeedupThrottle, &speedup_throttle, 0, 3000),
Option(OptionID::kPrefSpeedupFrameSkip, &speedup_frame_skip, 0, 300),
Option(OptionID::kPrefThrottle, &coreOptions.throttle, 0, 450),
Option(OptionID::kPrefSpeedupThrottle, &coreOptions.speedup_throttle, 0, 3000),
Option(OptionID::kPrefSpeedupFrameSkip, &coreOptions.speedup_frame_skip, 0, 300),
Option(OptionID::kPrefSpeedupThrottleFrameSkip, &coreOptions.speedup_throttle_frame_skip),
Option(OptionID::kPrefUseBiosGB, &gopts.use_bios_file_gb),
Option(OptionID::kPrefUseBiosGBA, &gopts.use_bios_file_gba),

View File

@ -252,7 +252,7 @@ void DirectSound::write(uint16_t* finalWave, int length)
LPVOID lpvPtr2;
DWORD dwBytes2 = 0;
if (!coreOptions.speedup && throttle && !gba_joybus_active) {
if (!coreOptions.speedup && coreOptions.throttle && !gba_joybus_active) {
hr = dsbSecondary->GetStatus(&status);
if (status & DSBSTATUS_PLAYING) {

View File

@ -2189,7 +2189,7 @@ public:
void Init(wxShowEvent& ev)
{
ev.Skip();
DoSetThrottleSel(throttle);
DoSetThrottleSel(coreOptions.throttle);
}
} throttle_ctrl;
@ -2205,8 +2205,8 @@ public:
evt.Skip(false);
if (val == 0) {
speedup_throttle = 0;
speedup_frame_skip = 0;
coreOptions.speedup_throttle = 0;
coreOptions.speedup_frame_skip = 0;
coreOptions.speedup_throttle_frame_skip = false;
frame_skip_cb->SetValue(false);
@ -2216,32 +2216,32 @@ public:
return; // Do not update value if user cleared text box.
}
else if (val <= 450) {
speedup_throttle = val;
speedup_frame_skip = 0;
coreOptions.speedup_throttle = val;
coreOptions.speedup_frame_skip = 0;
frame_skip_cb->SetValue(prev_frame_skip_cb);
frame_skip_cb->Enable();
}
else { // val > 450
speedup_throttle = 100;
coreOptions.speedup_throttle = 100;
coreOptions.speedup_throttle_frame_skip = false;
unsigned rounded = std::round((double)val / 100) * 100;
speedup_frame_skip = rounded / 100 - 1;
coreOptions.speedup_frame_skip = rounded / 100 - 1;
// Round up or down to the nearest 100%.
// For example, when the up/down buttons are pressed on the spin
// control.
if ((int)(val - rounded) > 0)
speedup_frame_skip++;
coreOptions.speedup_frame_skip++;
else if ((int)(val - rounded) < 0)
speedup_frame_skip--;
coreOptions.speedup_frame_skip--;
frame_skip_cb->SetValue(true);
frame_skip_cb->Disable();
val = (speedup_frame_skip + 1) * 100;
val = (coreOptions.speedup_frame_skip + 1) * 100;
}
speedup_throttle_spin->SetValue(val);
@ -2258,16 +2258,16 @@ public:
void Init(wxShowEvent& ev)
{
if (speedup_frame_skip != 0) {
speedup_throttle_spin->SetValue((speedup_frame_skip + 1) * 100);
if (coreOptions.speedup_frame_skip != 0) {
speedup_throttle_spin->SetValue((coreOptions.speedup_frame_skip + 1) * 100);
frame_skip_cb->SetValue(true);
frame_skip_cb->Disable();
}
else {
speedup_throttle_spin->SetValue(speedup_throttle);
speedup_throttle_spin->SetValue(coreOptions.speedup_throttle);
frame_skip_cb->SetValue(coreOptions.speedup_throttle_frame_skip);
if (speedup_throttle != 0)
if (coreOptions.speedup_throttle != 0)
frame_skip_cb->Enable();
else
frame_skip_cb->Disable();
@ -3303,7 +3303,7 @@ bool MainFrame::BindControls()
getrbi("PNG", captureFormat, 0);
getrbi("BMP", captureFormat, 1);
getsc("RewindInterval", gopts.rewind_interval);
getsc_uint("Throttle", throttle);
getsc_uint("Throttle", coreOptions.throttle);
throttle_ctrl.thr = sc;
throttle_ctrl.thrsel = SafeXRCCTRL<wxChoice>(d, "ThrottleSel");
throttle_ctrl.thr->Connect(wxEVT_COMMAND_SPINCTRL_UPDATED,

View File

@ -284,7 +284,7 @@ void OpenAL::write(uint16_t* finalWave, int length)
if (nBuffersProcessed == gopts.audio_buffers) {
// we only want to know about it when we are emulating at full speed or faster:
if ((throttle >= 100) || (throttle == 0)) {
if ((coreOptions.throttle >= 100) || (coreOptions.throttle == 0)) {
if (systemVerbose & VERBOSE_SOUNDOUTPUT) {
static unsigned int i = 0;
log("OpenAL: Buffers were not refilled fast enough (i=%i)\n", i++);
@ -292,7 +292,7 @@ void OpenAL::write(uint16_t* finalWave, int length)
}
}
if (!coreOptions.speedup && throttle && !gba_joybus_active) {
if (!coreOptions.speedup && coreOptions.throttle && !gba_joybus_active) {
// wait until at least one buffer has finished
while (nBuffersProcessed == 0) {
winlog(" waiting...\n");

View File

@ -255,7 +255,7 @@ void GameArea::LoadGame(const wxString& name)
gbSoundSetSampleRate(!gopts.sound_qual ? 48000 : 44100 / (1 << (gopts.sound_qual - 1)));
soundSetVolume((float)gopts.sound_vol / 100.0);
// this **MUST** be called **AFTER** setting sample rate because the core calls soundInit()
soundSetThrottle(throttle);
soundSetThrottle(coreOptions.throttle);
gbGetHardwareType();
@ -370,7 +370,7 @@ void GameArea::LoadGame(const wxString& name)
soundSetSampleRate(!gopts.sound_qual ? 48000 : 44100 / (1 << (gopts.sound_qual - 1)));
soundSetVolume((float)gopts.sound_vol / 100.0);
// this **MUST** be called **AFTER** setting sample rate because the core calls soundInit()
soundSetThrottle(throttle);
soundSetThrottle(coreOptions.throttle);
soundFiltering = (float)gopts.gba_sound_filter / 100.0f;
rtcEnableRumble(true);

View File

@ -541,7 +541,7 @@ void XAudio2_Output::write(uint16_t* finalWave, int length)
break;
} else {
// the maximum number of buffers is currently queued
if (!coreOptions.speedup && throttle && !gba_joybus_active) {
if (!coreOptions.speedup && coreOptions.throttle && !gba_joybus_active) {
// wait for one buffer to finish playing
if (WaitForSingleObject(notify.hBufferEndEvent, 10000) == WAIT_TIMEOUT) {
device_changed = true;