Skip to content

Commit

Permalink
ui: refactor config/options (wip)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cpasjuste committed Sep 27, 2023
1 parent d247949 commit 046a986
Show file tree
Hide file tree
Showing 23 changed files with 297 additions and 295 deletions.
2 changes: 1 addition & 1 deletion src/cores/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ int main(int argc, char **argv) {
auto cfg = new PEMUConfig(io, pemu_version);

// create main ui/renderer
auto fs = cfg->get(PEMUConfig::Id::GUI_FULLSCREEN);
auto fs = cfg->get(PEMUConfig::OptId::UI_FULLSCREEN);
pemu_ui = new PEMUUiMain(io, (fs && !fs->getInteger()) ? Vector2f{1280, 720} : Vector2f{0, 0});
pemu_ui->setConfig(cfg);

Expand Down
2 changes: 1 addition & 1 deletion src/cores/pfbneo/sources/fbneo/drv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static int DoLibInit() {
return 1;
}

NeoSystem = NeoSystemList[pemu_ui->getConfig()->get(PEMUConfig::Id::ROM_NEOBIOS, true)->getArrayIndex()];
NeoSystem = NeoSystemList[pemu_ui->getConfig()->get(PEMUConfig::OptId::EMU_NEOBIOS, true)->getArrayIndex()];

nRet = BurnDrvInit();
printf("DoLibInit: BurnDrvInit = %i\n", nRet);
Expand Down
16 changes: 8 additions & 8 deletions src/cores/pfbneo/sources/pfbneo_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,35 +20,35 @@ PFBAConfig::PFBAConfig(c2d::Io *io, int version) : PEMUConfig(io, "PFBNEO", vers
}

/// MAIN OPTIONS
get(PEMUConfig::Id::GUI_SHOW_ZIP_NAMES)->setArrayIndex(0);
get(PEMUConfig::OptId::UI_SHOW_ZIP_NAMES)->setArrayIndex(0);

/// ROMS OPTIONS
auto group = getGroup(PEMUConfig::Id::MENU_ROM_OPTIONS);
auto group = getGroup(PEMUConfig::OptId::MENU_ROM_OPTIONS);
if (!group) {
printf("PFBNConfig: error, group not found (MENU_ROM_OPTIONS)\n");
return;
}
group->addOption({"FORCE_60HZ", {"OFF", "ON"}, 1, PEMUConfig::Id::ROM_FORCE_60HZ, C2D_CONFIG_RESTART_EMU_NEEDED});
group->addOption({"FORCE_60HZ", {"OFF", "ON"}, 1, PEMUConfig::OptId::EMU_FORCE_60HZ, C2D_CONFIG_RESTART_EMU_NEEDED});
group->addOption({"AUDIO_FREQUENCY", {"11025", "22050", "32000", "44100", "48000"},
3, PEMUConfig::Id::ROM_AUDIO_FREQ, C2D_CONFIG_RESTART_EMU_NEEDED});
3, PEMUConfig::OptId::EMU_AUDIO_FREQ, C2D_CONFIG_RESTART_EMU_NEEDED});
group->addOption({"AUDIO_INTERPOLATION", {"0", "1", "3"},
2, PEMUConfig::Id::ROM_AUDIO_INTERPOLATION, C2D_CONFIG_RESTART_EMU_NEEDED});
2, PEMUConfig::OptId::EMU_AUDIO_INTERPOLATION, C2D_CONFIG_RESTART_EMU_NEEDED});
group->addOption({"AUDIO_FM_INTERPOLATION", {"0", "1", "3"},
2, PEMUConfig::Id::ROM_AUDIO_FMINTERPOLATION, C2D_CONFIG_RESTART_EMU_NEEDED});
2, PEMUConfig::OptId::EMU_AUDIO_FMINTERPOLATION, C2D_CONFIG_RESTART_EMU_NEEDED});
#ifdef __VITA__
group->addOption({"ROTATION", {"OFF", "ON", "FLIP", "CAB MODE"},
1, PEMUConfig::Id::ROM_ROTATION, C2D_CONFIG_RESTART_EMU_NEEDED});
#else
group->addOption({"ROTATION", {"OFF", "ON", "FLIP"},
1, PEMUConfig::Id::ROM_ROTATION, C2D_CONFIG_RESTART_EMU_NEEDED});
1, PEMUConfig::OptId::EMU_ROTATION, C2D_CONFIG_RESTART_EMU_NEEDED});
#endif
group->addOption(
{"NEOBIOS", {"UNIBIOS_4_0", "UNIBIOS_3_3", "UNIBIOS_3_2", "UNIBIOS_3_1",
"MVS_ASIA_EUR_V6S1", "MVS_ASIA_EUR_V5S1", "MVS_ASIA_EUR_V3S4",
"MVS_USA_V5S2", "MVS_USA_V5S4", "MVS_USA_V5S6", "MVS_JPN_V6",
"MVS_JPN_V5", "MVS_JPN_V3S4", "MVS_JPN_J3", "AES_ASIA",
"AES_JAPAN", "NEO_MVH_MV1CA", "NEO_MVH_MV1CJ", "DECK_V6", "DEVKIT"},
0, PEMUConfig::Id::ROM_NEOBIOS, C2D_CONFIG_RESTART_EMU_NEEDED});
0, PEMUConfig::OptId::EMU_NEOBIOS, C2D_CONFIG_RESTART_EMU_NEEDED});
#ifdef __PFBA_ARM__
// do not use unibios as default on vita for cyclone asm compatibility
group->getOption(PEMUConfig::Id::ROM_NEOBIOS)->setArrayIndex(4);
Expand Down
8 changes: 4 additions & 4 deletions src/cores/pfbneo/sources/pfbneo_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ class PFBAConfig : public pemu::PEMUConfig {

std::vector<int> getCoreHiddenOptionToEnable() override {
return {
PEMUConfig::Id::GUI_FILTER_CLONES,
PEMUConfig::Id::GUI_FILTER_SYSTEM,
PEMUConfig::Id::GUI_FILTER_ROTATION,
PEMUConfig::Id::GUI_FILTER_RESOLUTION
PEMUConfig::OptId::UI_FILTER_CLONES,
PEMUConfig::OptId::UI_FILTER_SYSTEM,
PEMUConfig::OptId::UI_FILTER_ROTATION,
PEMUConfig::OptId::UI_FILTER_RESOLUTION
};
}

Expand Down
10 changes: 5 additions & 5 deletions src/cores/pfbneo/sources/pfbneo_ui_emu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,10 @@ int PFBAUiEmu::load(const ss_api::Game &game) {
printf("nSekCpuCore: %s\n", nSekCpuCore > 0 ? "M68K" : "C68K (ASM)");
#endif

int audio_freq = pMain->getConfig()->get(PEMUConfig::Id::ROM_AUDIO_FREQ, true)->getInteger();
nInterpolation = pMain->getConfig()->get(PEMUConfig::Id::ROM_AUDIO_INTERPOLATION, true)->getInteger();
nFMInterpolation = pMain->getConfig()->get(PEMUConfig::Id::ROM_AUDIO_FMINTERPOLATION, true)->getInteger();
bForce60Hz = pMain->getConfig()->get(PEMUConfig::Id::ROM_FORCE_60HZ, true)->getInteger();
int audio_freq = pMain->getConfig()->get(PEMUConfig::OptId::EMU_AUDIO_FREQ, true)->getInteger();
nInterpolation = pMain->getConfig()->get(PEMUConfig::OptId::EMU_AUDIO_INTERPOLATION, true)->getInteger();
nFMInterpolation = pMain->getConfig()->get(PEMUConfig::OptId::EMU_AUDIO_FMINTERPOLATION, true)->getInteger();
bForce60Hz = pMain->getConfig()->get(PEMUConfig::OptId::EMU_FORCE_60HZ, true)->getInteger();
if (bForce60Hz) {
nBurnFPS = 6000;
}
Expand Down Expand Up @@ -264,7 +264,7 @@ bool PFBAUiEmu::onInput(c2d::Input::Player *players) {
// 1 > "ON"
// 2 > "FLIP"
// 3 > "CAB" (vita/switch)
int rotation = getUi()->getConfig()->get(PEMUConfig::Id::ROM_ROTATION, true)->getArrayIndex();
int rotation = getUi()->getConfig()->get(PEMUConfig::OptId::EMU_ROTATION, true)->getArrayIndex();
if (BurnDrvGetFlags() & BDF_ORIENTATION_VERTICAL) {
if (rotation == 0) {
pMain->getInput()->setRotation(Input::Rotation::R90, Input::Rotation::R0);
Expand Down
4 changes: 2 additions & 2 deletions src/cores/pfbneo/sources/pfbneo_ui_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
bool PFBAGuiMenu::isOptionHidden(c2d::config::Option *option) {
ss_api::Game game = getUi()->getUiRomList()->getSelection();

if (isRom() && option->getId() == PEMUConfig::Id::ROM_ROTATION && game.id > 0 && game.rotation == 0) {
if (isRom() && option->getId() == PEMUConfig::OptId::EMU_ROTATION && game.id > 0 && game.rotation == 0) {
return true;
}

// Neo-Geo system id == 142
if (isRom() && option->getId() == PEMUConfig::Id::ROM_NEOBIOS && game.id > 0 && game.system.id != 142) {
if (isRom() && option->getId() == PEMUConfig::OptId::EMU_NEOBIOS && game.id > 0 && game.system.id != 142) {
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/cores/pgba/sources/pgba_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ PGBAConfig::PGBAConfig(c2d::Io *io, int version) : PEMUConfig(io, "PGBA", versio
}

// no need for auto-scaling mode
getOption(PEMUConfig::Id::ROM_SCALING_MODE)->setArray({"ASPECT", "INTEGER"}, 0);
getOption(PEMUConfig::OptId::EMU_SCALING_MODE)->setArray({"ASPECT", "INTEGER"}, 0);

// "c2dui_romlist" will also reload config, but we need new roms paths
load();
Expand Down
2 changes: 1 addition & 1 deletion src/cores/pgen/sources/pgen_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ PGENConfig::PGENConfig(c2d::Io *io, int version) : PEMUConfig(io, "PGEN", versio
}

// no need for auto-scaling mode
getOption(PEMUConfig::Id::ROM_SCALING_MODE)->setArray({"ASPECT", "INTEGER"}, 0);
getOption(PEMUConfig::OptId::EMU_SCALING_MODE)->setArray({"ASPECT", "INTEGER"}, 0);

// "c2dui_romlist" will also reload config, but we need new roms paths
load();
Expand Down
2 changes: 1 addition & 1 deletion src/cores/pgen/sources/pgen_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class PGENConfig : public pemu::PEMUConfig {
}

std::vector<int> getCoreHiddenOptionToEnable() override {
return {PEMUConfig::Id::GUI_FILTER_SYSTEM};
return {PEMUConfig::OptId::UI_FILTER_SYSTEM};
}

std::string getCoreVersion() override {
Expand Down
2 changes: 1 addition & 1 deletion src/cores/pnes/sources/pnes_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ PNESConfig::PNESConfig(c2d::Io *io, int version) : PEMUConfig(io, "PNES", versio
}

// no need for auto-scaling mode on pnes
getOption(PEMUConfig::Id::ROM_SCALING_MODE)->setArray({"ASPECT", "INTEGER"}, 0);
getOption(PEMUConfig::OptId::EMU_SCALING_MODE)->setArray({"ASPECT", "INTEGER"}, 0);

#ifdef __SWITCH__
// on nintendo switch invert A/B buttons
Expand Down
20 changes: 10 additions & 10 deletions src/cores/psnes/sources/psnes_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,32 @@ PSNESConfig::PSNESConfig(c2d::Io *io, int version) : PEMUConfig(io, "PSNES", ver
getGroup(CFG_ID_ROMS)->addOption({gl.cfg_name, io->getDataPath() + gl.rom_path + "/"});
}

auto group = getGroup(PEMUConfig::Id::MENU_ROM_OPTIONS);
auto group = getGroup(PEMUConfig::OptId::MENU_ROM_OPTIONS);
if (!group) {
printf("PSNESConfig: error, group not found (MENU_ROM_OPTIONS)\n");
return;
}

group->addOption({"AUDIO_SYNC", {"OFF", "ON"}, 0, PEMUConfig::Id::ROM_AUDIO_SYNC,
group->addOption({"AUDIO_SYNC", {"OFF", "ON"}, 0, PEMUConfig::OptId::EMU_AUDIO_SYNC,
"ON: PERFECT AUDIO - OFF: MINOR AUDIO STUTTERING (FAVOR FPS)"});
group->addOption({"CHEATS", {"OFF", "ON"}, 1, PEMUConfig::Id::ROM_PSNES_CHEATS});
group->addOption({"BLOCk_INVALID_VRAM", {"OFF", "ON"}, 1, PEMUConfig::Id::ROM_PSNES_BLOCK_VRAM});
group->addOption({"TRANSPARENCY", {"OFF", "ON"}, 1, PEMUConfig::Id::ROM_PSNES_TRANSPARENCY});
group->addOption({"DISPLAY_MESSAGES", {"OFF", "ON"}, 1, PEMUConfig::Id::ROM_PSNES_DISPLAY_MESSAGES});
group->addOption({"CHEATS", {"OFF", "ON"}, 1, PEMUConfig::OptId::EMU_PSNES_CHEATS});
group->addOption({"BLOCk_INVALID_VRAM", {"OFF", "ON"}, 1, PEMUConfig::OptId::EMU_PSNES_BLOCK_VRAM});
group->addOption({"TRANSPARENCY", {"OFF", "ON"}, 1, PEMUConfig::OptId::EMU_PSNES_TRANSPARENCY});
group->addOption({"DISPLAY_MESSAGES", {"OFF", "ON"}, 1, PEMUConfig::OptId::EMU_PSNES_DISPLAY_MESSAGES});
group->addOption({"FRAMESKIP",
{"OFF", "AUTO", "1", "2", "3", "4", "5", "6", "7", "8", "9"},
0, PEMUConfig::Id::ROM_PSNES_FRAMESKIP});
0, PEMUConfig::OptId::EMU_PSNES_FRAMESKIP});
#ifdef __VITA__
get(PEMUConfig::Id::ROM_PSNES_FRAMESKIP)->setArrayIndex(3);
#endif
group->addOption({"TURBO_MODE", {"OFF", "ON"}, 0, PEMUConfig::Id::ROM_PSNES_TURBO_MODE});
group->addOption({"TURBO_MODE", {"OFF", "ON"}, 0, PEMUConfig::OptId::EMU_PSNES_TURBO_MODE});
group->addOption({"TURBO_FRAMESKIP",
{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10",
"11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25"},
15, PEMUConfig::Id::ROM_PSNES_TURBO_FRAMESKIP});
15, PEMUConfig::OptId::EMU_PSNES_TURBO_FRAMESKIP});

// no need for auto-scaling mode
getOption(PEMUConfig::Id::ROM_SCALING_MODE)->setArray({"ASPECT", "INTEGER"}, 0);
getOption(PEMUConfig::OptId::EMU_SCALING_MODE)->setArray({"ASPECT", "INTEGER"}, 0);

// "c2dui_romlist" will also reload config, but we need new roms paths
load();
Expand Down
16 changes: 8 additions & 8 deletions src/cores/psnes/sources/psnes_ui_emu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ int PSNESUiEmu::load(const ss_api::Game &game) {

// audio
Settings.Transparency =
pMain->getConfig()->get(PEMUConfig::Id::ROM_PSNES_TRANSPARENCY, true)->getInteger();
pMain->getConfig()->get(PEMUConfig::OptId::EMU_PSNES_TRANSPARENCY, true)->getInteger();
Settings.AutoDisplayMessages =
pMain->getConfig()->get(PEMUConfig::Id::ROM_PSNES_DISPLAY_MESSAGES, true)->getInteger();
pMain->getConfig()->get(PEMUConfig::OptId::EMU_PSNES_DISPLAY_MESSAGES, true)->getInteger();
Settings.InitialInfoStringTimeout = 120;
Settings.HDMATimingHack = 100;
Settings.BlockInvalidVRAMAccessMaster =
pMain->getConfig()->get(PEMUConfig::Id::ROM_PSNES_BLOCK_VRAM, true)->getInteger();
pMain->getConfig()->get(PEMUConfig::OptId::EMU_PSNES_BLOCK_VRAM, true)->getInteger();
Settings.StopEmulation = TRUE;
Settings.WrongMovieStateProtection = TRUE;
Settings.DumpStreamsMaxFrames = -1;
Expand All @@ -107,7 +107,7 @@ int PSNESUiEmu::load(const ss_api::Game &game) {
Settings.FastSavestates = TRUE;
Settings.SeparateEchoBuffer = FALSE;

int skipFramesCfg = pMain->getConfig()->get(PEMUConfig::Id::ROM_PSNES_FRAMESKIP, true)->getArrayIndex();
int skipFramesCfg = pMain->getConfig()->get(PEMUConfig::OptId::EMU_PSNES_FRAMESKIP, true)->getArrayIndex();
if (skipFramesCfg == 0) {
Settings.SkipFrames = 0;
} else if (skipFramesCfg == 1) {
Expand All @@ -116,8 +116,8 @@ int PSNESUiEmu::load(const ss_api::Game &game) {
Settings.SkipFrames = skipFramesCfg - 1;
}
printf("Settings.SkipFrames: %i\n", Settings.SkipFrames);
Settings.TurboMode = pMain->getConfig()->get(PEMUConfig::Id::ROM_PSNES_TURBO_MODE, true)->getInteger();
Settings.TurboSkipFrames = pMain->getConfig()->get(PEMUConfig::Id::ROM_PSNES_TURBO_FRAMESKIP,
Settings.TurboMode = pMain->getConfig()->get(PEMUConfig::OptId::EMU_PSNES_TURBO_MODE, true)->getInteger();
Settings.TurboSkipFrames = pMain->getConfig()->get(PEMUConfig::OptId::EMU_PSNES_TURBO_FRAMESKIP,
true)->getArrayIndex();
Settings.CartAName[0] = 0;
Settings.CartBName[0] = 0;
Expand Down Expand Up @@ -172,7 +172,7 @@ int PSNESUiEmu::load(const ss_api::Game &game) {

Memory.LoadSRAM(S9xGetFilename(".srm", SRAM_DIR).c_str());

Settings.ApplyCheats = pMain->getConfig()->get(PEMUConfig::Id::ROM_PSNES_CHEATS, true)->getInteger();
Settings.ApplyCheats = pMain->getConfig()->get(PEMUConfig::OptId::EMU_PSNES_CHEATS, true)->getInteger();
S9xDeleteCheats();
S9xCheatsEnable();
if (Settings.ApplyCheats) {
Expand All @@ -188,7 +188,7 @@ int PSNESUiEmu::load(const ss_api::Game &game) {
(float) Memory.ROMFramesPerSecond);
addAudio((int) Settings.SoundPlaybackRate, samples * 2);
audio_buffer = malloc(getAudio()->getSamplesSize() * getAudio()->getChannels() * 5);
optionAudioSync = pMain->getConfig()->get(PEMUConfig::Id::ROM_AUDIO_SYNC, true);
optionAudioSync = pMain->getConfig()->get(PEMUConfig::OptId::EMU_AUDIO_SYNC, true);

// video
S9xGraphicsInit();
Expand Down
Loading

0 comments on commit 046a986

Please sign in to comment.