From b7b183afa7a90adf693214aaee4c41c73903305d Mon Sep 17 00:00:00 2001 From: maron2000 <68574602+maron2000@users.noreply.github.com> Date: Sat, 17 Feb 2024 00:13:02 +0900 Subject: [PATCH] Boot with drive number when booting from image --- src/dos/dos_programs.cpp | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/dos/dos_programs.cpp b/src/dos/dos_programs.cpp index 46977ca4a7a..f4051c05387 100644 --- a/src/dos/dos_programs.cpp +++ b/src/dos/dos_programs.cpp @@ -706,7 +706,21 @@ void MenuBrowseImageFile(char drive, bool arc, bool boot, bool multiple) { strcat(mountstring,files.size()?files.c_str():fname.c_str()); if(!multiple) strcat(mountstring, "\""); if(mountiro[drive - 'A']) strcat(mountstring, " -ro"); - if(boot) strcat(mountstring, " -u"); + if(boot) { + strcat(mountstring, " -u"); + mountstring[0] = drive - 'A' + '0'; + runImgmount(mountstring); // mount by drive number + std::string bootstr = "-Q "; + bootstr += drive; + bootstr += ':'; + runBoot(bootstr.c_str()); + std::string drive_warn = "Drive " + std::string(1, drive) + ": failed to boot."; + systemmessagebox("Error", drive_warn.c_str(), "ok", "error", 1); + bootstr = "-u "; + bootstr += drive - 'A' + '0'; + runImgmount(bootstr.c_str()); // unmount if boot failed + return; + } if(arc) { strcat(mountstring," -q"); runMount(mountstring); @@ -716,17 +730,11 @@ void MenuBrowseImageFile(char drive, bool arc, bool boot, bool multiple) { qmount=false; } chdir( Temp_CurrentDir ); - if (!Drives[drive-'A']) { + if (!Drives[drive - 'A']) { drive_warn="Drive "+str+": failed to mount."; systemmessagebox("Error",drive_warn.c_str(),"ok","error", 1); return; - } else if (boot) { - char str[] = "-Q A:"; - str[3]=drive; - runBoot(str); - std::string drive_warn="Drive "+std::string(1, drive)+": failed to boot."; - systemmessagebox("Error",drive_warn.c_str(),"ok","error", 1); - } else if (multiple) { + } else if (multiple) { systemmessagebox("Information",("Mounted disk images to Drive "+std::string(1,drive)+(dos.loaded_codepage==437?":\n"+files:".")+(mountiro[drive-'A']?"\n(Read-only mode)":"")).c_str(),"ok","info", 1); } else if (lTheOpenFileName) { systemmessagebox("Information",(std::string(arc?"Mounted archive":"Mounted disk image")+" to Drive "+std::string(1,drive)+":\n"+std::string(lTheOpenFileName)+(arc||mountiro[drive-'A']?"\n(Read-only mode)":"")).c_str(),"ok","info", 1);