Skip to content

Commit

Permalink
Fix regression with auto booting disk image
Browse files Browse the repository at this point in the history
  • Loading branch information
schellingb committed Sep 7, 2024
1 parent 6f8f8b1 commit 352deef
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 20 deletions.
5 changes: 2 additions & 3 deletions dosbox_pure_libretro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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)
{
Expand Down
15 changes: 8 additions & 7 deletions dosbox_pure_osd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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);
Expand All @@ -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; }
Expand Down Expand Up @@ -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);
}
Expand Down
21 changes: 11 additions & 10 deletions dosbox_pure_run.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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);
Expand All @@ -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;
Expand All @@ -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");
Expand All @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -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<<CPU_AUTODETERMINE_SHIFT)))
CPU_OldCycleMax = autoinput.oldcycles; // we switched to protected mode since auto input, fix up old cycles
Expand Down
1 change: 1 addition & 0 deletions include/control.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class Config{
Section* GetSection(int index);
#ifdef C_DBP_LIBRETRO
Section* GetSection(char const * const _sectionname) const;
Property* GetProp(char const * const _sectionname, char const * const _property) const;
#endif
Section* GetSection(std::string const&_sectionname) const;
Section* GetSectionFromProperty(char const * const prop) const;
Expand Down
7 changes: 7 additions & 0 deletions src/misc/setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,13 @@ Section* Config::GetSection(char const * const _sectionname) const {
}
return NULL;
}

Property* Config::GetProp(char const * const _sectionname, char const * const _property) const {
for (const_it tel = sectionlist.begin(); tel != sectionlist.end(); ++tel){
if (!strcasecmp((*tel)->GetName(),_sectionname)) return (*tel)->GetProp(_property);
}
return NULL;
}
#endif

Section* Config::GetSection(string const& _sectionname) const {
Expand Down

0 comments on commit 352deef

Please sign in to comment.