From 352deefcdde78111ccc3163f2d82ee0b06eb86c8 Mon Sep 17 00:00:00 2001 From: schellingb <14200249+schellingb@users.noreply.github.com> Date: Sun, 8 Sep 2024 01:06:03 +0900 Subject: [PATCH] Fix regression with auto booting disk image --- dosbox_pure_libretro.cpp | 5 ++--- dosbox_pure_osd.h | 15 ++++++++------- dosbox_pure_run.h | 21 +++++++++++---------- include/control.h | 1 + src/misc/setup.cpp | 7 +++++++ 5 files changed, 29 insertions(+), 20 deletions(-) diff --git a/dosbox_pure_libretro.cpp b/dosbox_pure_libretro.cpp index acdf58be..75d2a885 100644 --- a/dosbox_pure_libretro.cpp +++ b/dosbox_pure_libretro.cpp @@ -2759,9 +2759,8 @@ static bool check_variables(bool is_startup = false) case 'p': dbmachine = "pcjr"; break; } visibility_changed |= Variables::DosBoxSet("dosbox", "machine", dbmachine, false, true); + if (dbp_reboot_machine) dbp_reboot_machine = 0; Variables::DosBoxSet("dosbox", "vmemsize", retro_get_variable("dosbox_pure_svgamem", "2"), false, true); - if (dbp_reboot_machine) - control->GetSection("dosbox")->GetProp("machine")->OnChangedByConfigProgram(), dbp_reboot_machine = 0; const char* mem = retro_get_variable("dosbox_pure_memory_size", "16"); if (dbp_reboot_set64mem) mem = "64"; @@ -2773,7 +2772,7 @@ static bool check_variables(bool is_startup = false) const char* audiorate = retro_get_variable("dosbox_pure_audiorate", DBP_DEFAULT_SAMPLERATE_STRING); Variables::DosBoxSet("mixer", "rate", audiorate, false, true); Variables::DosBoxSet("mixer", "swapstereo", retro_get_variable("dosbox_pure_swapstereo", "false")); - dbp_swapstereo = (bool)control->GetSection("mixer")->GetProp("swapstereo")->GetValue(); // to also get dosbox.conf override + dbp_swapstereo = (bool)control->GetProp("mixer", "swapstereo")->GetValue(); // to also get dosbox.conf override if (dbp_state == DBPSTATE_BOOT) { diff --git a/dosbox_pure_osd.h b/dosbox_pure_osd.h index 47aadd01..5e3cbfa7 100644 --- a/dosbox_pure_osd.h +++ b/dosbox_pure_osd.h @@ -1069,10 +1069,10 @@ struct DBP_PureMenuState : DBP_MenuState if (DBP_Run::autoboot.startup.mode != DBP_Run::RUN_NONE) { if (DBP_Run::autoboot.startup.mode == DBP_Run::RUN_EXEC) GoToSubMenu(IT_RUN, IT_RUN, 0, &DBP_Run::autoboot.startup.exec); - else if (DBP_Run::autoboot.startup.mode == DBP_Run::RUN_BOOTOS) GoToSubMenu(IT_BOOTOSLIST, IT_BOOTOS, DBP_Run::autoboot.startup.info); - else if (DBP_Run::autoboot.startup.mode == DBP_Run::RUN_SHELL) GoToSubMenu(IT_SHELLLIST, IT_RUNSHELL, DBP_Run::autoboot.startup.info); - else if (DBP_Run::autoboot.startup.mode == DBP_Run::RUN_VARIANT) GoToSubMenu(IT_VARIANTLIST, IT_RUNVARIANT, DBP_Run::autoboot.startup.info); - else if (DBP_Run::autoboot.startup.mode == DBP_Run::RUN_BOOTIMG) GoToSubMenu(IT_BOOTIMG, IT_BOOTIMG, DBP_Run::autoboot.startup.info); + else if (DBP_Run::autoboot.startup.mode == DBP_Run::RUN_BOOTOS) GoToSubMenu(IT_BOOTOSLIST, IT_BOOTOS, DBP_Run::autoboot.startup.info); + else if (DBP_Run::autoboot.startup.mode == DBP_Run::RUN_SHELL) GoToSubMenu(IT_SHELLLIST, IT_RUNSHELL, DBP_Run::autoboot.startup.info); + else if (DBP_Run::autoboot.startup.mode == DBP_Run::RUN_VARIANT) GoToSubMenu(IT_VARIANTLIST, IT_RUNVARIANT, DBP_Run::autoboot.startup.info); + else if (DBP_Run::autoboot.startup.mode == DBP_Run::RUN_BOOTIMG) GoToSubMenu(IT_BOOTIMG, IT_BOOTIMG_MACHINE, DBP_Run::autoboot.startup.info); else { DBP_ASSERT(false); } if (DBP_Run::autoboot.startup.mode == DBP_Run::RUN_VARIANT) DBP_Run::autoboot.use = false; // DBP_Run::WriteAutoBoot force enables auto boot for RUN_VARIANT } @@ -1306,8 +1306,8 @@ struct DBP_PureMenuState : DBP_MenuState else if (ok_type == IT_BOOTIMG) { // Machine property was fixed by dbp_reboot_machine or DOSBOX.CONF and cannot be modified here, so automatically boot the image as is (RES_NONE check is for GoToSubMenu) - if (res != RES_NONE && DBP_FullscreenOSD && control->GetSection("dosbox")->GetProp("machine")->getChange() == Property::Changeable::OnlyByConfigProgram) - goto handle_result; + if (control->GetProp("dosbox", "machine")->getChange() == Property::Changeable::OnlyByConfigProgram) + { if (res != RES_NONE) goto handle_result; else goto top_menu; } list.clear(); list.emplace_back(IT_NONE, INFO_HEADER, "Select Boot System Mode"); list.emplace_back(IT_NONE); @@ -1316,7 +1316,7 @@ struct DBP_PureMenuState : DBP_MenuState list.emplace_back(IT_CANCEL, 0, "Cancel"); const std::string& img = (!dbp_images.empty() ? dbp_images[dbp_image_index].path : list[1].str); bool isPCjrCart = (img.size() > 3 && (img[img.size()-3] == 'J' || img[img.size()-2] == 'T')); - char wantmchar = (isPCjrCart ? 'p' : DBP_Run::GetDosBoxMachineChar()); + char wantmchar = (isPCjrCart ? 'p' : *(const char*)control->GetProp("dosbox", "machine")->GetValue()); for (const Item& it : list) if (it.info == wantmchar) { ResetSel((int)(&it - &list[0])); break; } @@ -1427,6 +1427,7 @@ struct DBP_PureMenuState : DBP_MenuState else if (ok_type == IT_CANCEL || (res == RES_CANCEL && list.back().type != IT_CLOSEOSD)) { // Go to top menu (if in submenu) or refresh list + top_menu: ResetSel(0, true); RefreshFileList(false); } diff --git a/dosbox_pure_run.h b/dosbox_pure_run.h index daaaaed0..0a6de4ae 100644 --- a/dosbox_pure_run.h +++ b/dosbox_pure_run.h @@ -335,10 +335,11 @@ struct DBP_Run if (mode == RUN_EXEC) startup.exec.swap(str); // remember to set cursor again and for rebooting a different IT_RUN } - if (startup.reboot || dbp_game_running || (mode == RUN_BOOTIMG && info && info != GetDosBoxMachineChar())) + Property* bootImgMachine = (mode == RUN_BOOTIMG && info ? control->GetProp("dosbox", "machine") : NULL); + if (startup.reboot || dbp_game_running || (bootImgMachine && info != *(const char*)bootImgMachine->GetValue() && bootImgMachine->getChange() != Property::Changeable::OnlyByConfigProgram)) { startup.reboot = false; - if (mode == RUN_BOOTIMG) dbp_reboot_machine = (info ? (char)info : GetDosBoxMachineChar()); + if (mode == RUN_BOOTIMG) dbp_reboot_machine = (info ? (char)info : *(const char*)bootImgMachine->GetValue()); DBP_OnBIOSReboot(); return true; } @@ -355,7 +356,7 @@ struct DBP_Run { // enforce cycle rate during auto input (but limited to 1994 CPU speed, above will likely just waste time waiting for rendering out the skipped frames) autoinput.oldcycles = CPU_CycleMax; - autoinput.oldchange = (Bit8u)control->GetSection("cpu")->GetProp("cycles")->getChange(); + autoinput.oldchange = (Bit8u)control->GetProp("cpu", "cycles")->getChange(); autoinput.oldyear = dbp_content_year; if (dbp_content_year > 1994) dbp_content_year = 1994; DBP_SetCyclesByYear(dbp_content_year, 1994); @@ -376,8 +377,6 @@ struct DBP_Run return true; } - static char GetDosBoxMachineChar() { return *((const char*)control->GetSection("dosbox")->GetProp("machine")->GetValue()); } - struct DOSYML { const char *Key, *End, *Next, *KeyX, *Val, *ValX; @@ -404,7 +403,7 @@ struct DBP_Run { const char* p = dbp_content_path.c_str(), *fs = strrchr(p, '/'), *bs = strrchr(p, '\\'); (((val += '^') += (yml_key[7] == 't' ? 'M' : 'S')).append(p, (fs > bs ? (fs - p) : bs ? (bs - p) : 0)) += CROSS_FILESPLIT).append(Val, (size_t)(ValX - Val)); - Property* prop = control->GetSection("midi")->GetProp("midiconfig"); + Property* prop = control->GetProp("midi", "midiconfig"); prop->SetValue(val); prop->OnChangedByConfigProgram(); val.assign("intelligent"); @@ -415,7 +414,7 @@ struct DBP_Run if (strncmp(mapFrom, Val, (size_t)(ValX - Val))) continue; val.append(mapTo); } - Property* prop = control->GetSection(db_section)->GetProp(db_key); + Property* prop = control->GetProp(db_section, db_key); bool res = (prop->SetValue(val) && !strcasecmp(prop->GetValue().ToString().c_str(), val.c_str())); if (res) prop->OnChangedByConfigProgram(); va_end(ap); @@ -504,7 +503,7 @@ struct DBP_Run if (!parseOthers ||l.Parse("video_card", "dosbox", "machine" , "generic_svga","svga_s3" , "generic_hercules","hercules" , "generic_cga","cga" , "generic_tandy","tandy" , "generic_pcjr","pcjr" , "generic_ega","ega" , "generic_vga","vgaonly" , "svga_s3_trio","svga_s3", "svga_tseng_et3000","svga_et3000" , "svga_tseng_et4000","svga_et4000" , "svga_paradise_pvga1a","svga_paradise" , "") ||l.Parse("video_memory", "dosbox", "vmemsize", "/") - ||l.Parse("video_voodoo", "pci", "voodoo" , "true","12mb" , "false","false" , "") + ||l.Parse("video_voodoo", "pci", "voodoo" , "true","8mb" , "false","false" , "") ) break; else goto syntaxerror; case 's': if (!parseOthers @@ -538,7 +537,7 @@ struct DBP_Run else { float cycle_per_hz = .3f; // default with auto (just a bad guess) - switch (*(const char*)control->GetSection("cpu")->GetProp("cputype")->GetValue()) + switch (*(const char*)control->GetProp("cpu", "cputype")->GetValue()) { case 'p': cycle_per_hz = .55700f; break; // Pentium (586): Mhz * 557.00 case '4': cycle_per_hz = .38000f; break; // 486: Mhz * 380.00 @@ -559,6 +558,8 @@ struct DBP_Run static bool PostInitFirstTime() { ReadAutoBoot(); + if (!patchDrive::Variants.size() && Drives['C'-'A'] && Drives['C'-'A']->FileExists("DOS.YML")) + patchDrive::Variants.push_back("Default Configuration"); int switchVariant = (patchDrive::Variants.size() ? autoboot.var : -1); if (switchVariant != -1 && patchDrive::SwitchVariant(switchVariant)) return true; // reset and re-run PreInit to load variant if (autoboot.use && autoboot.startup.mode != RUN_VARIANT) startup = autoboot.startup; @@ -797,7 +798,7 @@ struct DBP_Run DBP_KEYBOARD_ReleaseKeys(); if (autoinput.oldcycles) { - if (!CPU_CycleAutoAdjust && CPU_CycleMax == DBP_CyclesForYear(dbp_content_year, 1994) && control->GetSection("cpu")->GetProp("cycles")->getChange() == autoinput.oldchange) + if (!CPU_CycleAutoAdjust && CPU_CycleMax == DBP_CyclesForYear(dbp_content_year, 1994) && control->GetProp("cpu", "cycles")->getChange() == autoinput.oldchange) CPU_CycleMax = autoinput.oldcycles; // revert from Run() else if (CPU_CycleAutoAdjust && cpu.pmode && (CPU_AutoDetermineMode & (CPU_AUTODETERMINE_CORE<GetName(),_sectionname)) return (*tel)->GetProp(_property); + } + return NULL; +} #endif Section* Config::GetSection(string const& _sectionname) const {