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 28, 2023
1 parent 046a986 commit 1879f90
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 25 deletions.
17 changes: 9 additions & 8 deletions src/cores/pfbneo/sources/pfbneo_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,21 @@ PFBAConfig::PFBAConfig(c2d::Io *io, int version) : PEMUConfig(io, "PFBNEO", vers
printf("PFBNConfig(%s, v%i)\n", getPath().c_str(), version);

/// add custom roms paths to config
for (const auto &gl: getCoreGameListInfo()) {
for (const auto &gl: PFBAConfig::getCoreGameListInfo()) {
getGroup(CFG_ID_ROMS)->addOption({gl.cfg_name, io->getDataPath() + gl.rom_path + "/"});
}

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

/// ROMS OPTIONS
auto group = getGroup(PEMUConfig::OptId::MENU_ROM_OPTIONS);
auto group = getGroup(PEMUConfig::GrpId::EMULATION);
if (!group) {
printf("PFBNConfig: error, group not found (MENU_ROM_OPTIONS)\n");
return;
}
group->addOption({"FORCE_60HZ", {"OFF", "ON"}, 1, PEMUConfig::OptId::EMU_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::OptId::EMU_AUDIO_FREQ, C2D_CONFIG_RESTART_EMU_NEEDED});
group->addOption({"AUDIO_INTERPOLATION", {"0", "1", "3"},
Expand All @@ -37,7 +38,7 @@ PFBAConfig::PFBAConfig(c2d::Io *io, int version) : PEMUConfig(io, "PFBNEO", vers
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});
1, PEMUConfig::OptId::EMU_ROTATION, C2D_CONFIG_RESTART_EMU_NEEDED});
#else
group->addOption({"ROTATION", {"OFF", "ON", "FLIP"},
1, PEMUConfig::OptId::EMU_ROTATION, C2D_CONFIG_RESTART_EMU_NEEDED});
Expand All @@ -51,15 +52,15 @@ PFBAConfig::PFBAConfig(c2d::Io *io, int version) : PEMUConfig(io, "PFBNEO", vers
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);
group->getOption(PEMUConfig::OptId::EMU_NEOBIOS)->setArrayIndex(4);
group->addOption({"FRAMESKIP", {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"},
0, PEMUConfig::Id::ROM_FRAMESKIP, C2D_CONFIG_RESTART_EMU_NEEDED});
0, PEMUConfig::OptId::EMU_FRAMESKIP, C2D_CONFIG_RESTART_EMU_NEEDED});
#endif

#if defined(__PS4__) || defined(ANDROID)
// force 48000hz audio output
get(PEMUConfig::Id::ROM_AUDIO_FREQ)->setArrayIndex(4);
get(PEMUConfig::Id::ROM_AUDIO_FREQ)->setFlags(PEMUConfig::Flags::HIDDEN);
get(PEMUConfig::OptId::EMU_AUDIO_FREQ)->setArrayIndex(4);
get(PEMUConfig::OptId::EMU_AUDIO_FREQ)->setFlags(PEMUConfig::Flags::HIDDEN);
#endif

// "c2dui_romlist" will also reload config, but we need new roms paths
Expand Down
8 changes: 4 additions & 4 deletions src/cores/pfbneo/sources/pfbneo_ui_emu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ int PFBAUiEmu::getSekCpuCore() {
std::vector<std::string> zipList;
int hardware = BurnDrvGetHardwareCode();

std::string bios = pMain->getConfig()->get(PEMUConfig::Id::ROM_NEOBIOS, true)->getString();
std::string bios = pMain->getConfig()->get(PEMUConfig::OptId::EMU_NEOBIOS, true)->getString();
if (isHardware(hardware, HARDWARE_PREFIX_SNK) && Utility::contains(bios, "UNIBIOS")) {
sekCpuCore = 1; // SEK_CORE_M68K: USE C M68K CORE
pMain->getUiMessageBox()->show(
Expand Down Expand Up @@ -294,7 +294,7 @@ void PFBAUiEmu::onUpdate() {
if (clock.getElapsedTime().asSeconds() > 2) {
if (pgi_reset) {
pMain->getUiStatusBox()->show("TIPS: PRESS START "
"BUTTON 2 SECONDS FOR DIAG MENU...");
"BUTTON 2 SECONDS FOR DIAG MENU...");
pgi_reset->Input.nVal = 1;
*(pgi_reset->Input.pVal) = pgi_reset->Input.nVal;
}
Expand All @@ -306,7 +306,7 @@ void PFBAUiEmu::onUpdate() {
if (clock.getElapsedTime().asSeconds() > 2) {
if (pgi_diag) {
pMain->getUiStatusBox()->show("TIPS: PRESS COIN "
"BUTTON 2 SECONDS TO RESET CURRENT GAME...");
"BUTTON 2 SECONDS TO RESET CURRENT GAME...");
pgi_diag->Input.nVal = 1;
*(pgi_diag->Input.pVal) = pgi_diag->Input.nVal;
}
Expand All @@ -318,7 +318,7 @@ void PFBAUiEmu::onUpdate() {

// update fbneo video buffer and audio
#ifdef __VITA__
int skip = pMain->getConfig()->get(PEMUConfig::Id::ROM_FRAMESKIP, true)->getInteger();
int skip = pMain->getConfig()->get(PEMUConfig::OptId::EMU_FRAMESKIP, true)->getInteger();
#else
int skip = 0;
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/cores/pfbneo/sources/pfbneo_ui_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ bool PFBAGuiMenu::isOptionHidden(c2d::config::Option *option) {
}

#ifdef __SWITCH__
if (option->getId() == PEMUConfig::Id::ROM_FRAMESKIP) {
if (option->getId() == PEMUConfig::OptId::EMU_FRAMESKIP) {
return true;
}
#endif
Expand Down
6 changes: 3 additions & 3 deletions src/cores/pnes/sources/pnes_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ PNESConfig::PNESConfig(c2d::Io *io, int version) : PEMUConfig(io, "PNES", versio
printf("PNESConfig(%s, v%i)\n", getPath().c_str(), version);

// add custom roms paths to config
for (const auto &gl: getCoreGameListInfo()) {
for (const auto &gl: PNESConfig::getCoreGameListInfo()) {
getGroup(CFG_ID_ROMS)->addOption({gl.cfg_name, io->getDataPath() + gl.rom_path + "/"});
}

Expand All @@ -21,8 +21,8 @@ PNESConfig::PNESConfig(c2d::Io *io, int version) : PEMUConfig(io, "PNES", versio

#ifdef __SWITCH__
// on nintendo switch invert A/B buttons
getOption(PEMUConfig::Id::JOY_A)->setInteger(KEY_JOY_B_DEFAULT);
getOption(PEMUConfig::Id::JOY_B)->setInteger(KEY_JOY_A_DEFAULT);
getOption(PEMUConfig::OptId::JOY_A)->setInteger(KEY_JOY_B_DEFAULT);
getOption(PEMUConfig::OptId::JOY_B)->setInteger(KEY_JOY_A_DEFAULT);
#endif

// "c2dui_romlist" will also reload config, but we need new roms paths
Expand Down
6 changes: 3 additions & 3 deletions src/cores/psnes/sources/psnes_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ PSNESConfig::PSNESConfig(c2d::Io *io, int version) : PEMUConfig(io, "PSNES", ver
printf("PSNESConfig(%s, v%i)\n", getPath().c_str(), version);

// add custom roms paths to config
for (const auto &gl: getCoreGameListInfo()) {
for (const auto &gl: PSNESConfig::getCoreGameListInfo()) {
getGroup(CFG_ID_ROMS)->addOption({gl.cfg_name, io->getDataPath() + gl.rom_path + "/"});
}

auto group = getGroup(PEMUConfig::OptId::MENU_ROM_OPTIONS);
auto group = getGroup(PEMUConfig::GrpId::EMULATION);
if (!group) {
printf("PSNESConfig: error, group not found (MENU_ROM_OPTIONS)\n");
return;
Expand All @@ -32,7 +32,7 @@ PSNESConfig::PSNESConfig(c2d::Io *io, int version) : PEMUConfig(io, "PSNES", ver
{"OFF", "AUTO", "1", "2", "3", "4", "5", "6", "7", "8", "9"},
0, PEMUConfig::OptId::EMU_PSNES_FRAMESKIP});
#ifdef __VITA__
get(PEMUConfig::Id::ROM_PSNES_FRAMESKIP)->setArrayIndex(3);
get(PEMUConfig::OptId::EMU_PSNES_FRAMESKIP)->setArrayIndex(3);
#endif
group->addOption({"TURBO_MODE", {"OFF", "ON"}, 0, PEMUConfig::OptId::EMU_PSNES_TURBO_MODE});
group->addOption({"TURBO_FRAMESKIP",
Expand Down
2 changes: 1 addition & 1 deletion src/skeleton/ui_emu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void UiEmu::resume() {
pMain->getInput()->setRepeatDelay(0);

#ifdef __VITA__
config::Option *option = pMain->getConfig()->get(PEMUConfig::Id::ROM_WAIT_RENDERING, true);
config::Option *option = pMain->getConfig()->get(PEMUConfig::OptId::EMU_WAIT_RENDERING, true);
if (option) {
((PSP2Renderer *) pMain)->setWaitRendering(option->getInteger());
}
Expand Down
10 changes: 5 additions & 5 deletions src/skeleton/ui_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,11 +369,11 @@ bool UiMenu::onInput(c2d::Input::Player *players) {
}
break;
#ifdef __VITA__
case PEMUConfig::Id::ROM_WAIT_RENDERING:
if (isEmuRunning) {
((PSP2Renderer *) ui)->setWaitRendering(option->getInteger());
}
break;
case PEMUConfig::OptId::EMU_WAIT_RENDERING:
if (isEmuRunning) {
((PSP2Renderer *) ui)->setWaitRendering(option->getInteger());
}
break;
#endif
case PEMUConfig::OptId::UI_VIDEO_SNAP_DELAY:
ui->getUiRomList()->setVideoSnapDelay(option->getInteger());
Expand Down

0 comments on commit 1879f90

Please sign in to comment.