Add a dosbox.conf option to enable the MCB auto cleanup code

This commit is contained in:
Jonathan Campbell
2025-10-06 00:35:49 -07:00
parent cbe963bc81
commit 714c2859ee
3 changed files with 12 additions and 1 deletions

View File

@@ -152,6 +152,7 @@ bool incall = false;
bool startnopause = false;
int file_access_tries = 0;
int dos_initial_hma_free = 34*1024;
bool auto_repair_dos_psp_mcb_corruption = false;
int dos_sda_size = 0x560;
int dos_clipboard_device_access;
const char *dos_clipboard_device_name;
@@ -4147,6 +4148,7 @@ public:
enable_filenamechar = section->Get_bool("filenamechar");
file_access_tries = section->Get_int("file access tries");
dos_initial_hma_free = section->Get_int("hma free space");
auto_repair_dos_psp_mcb_corruption = section->Get_bool("mcb corruption becomes application free memory");
minimum_mcb_free = section->Get_hex("minimum mcb free");
minimum_mcb_segment = section->Get_hex("minimum mcb segment");
private_segment_in_umb = section->Get_bool("private area in umb");

View File

@@ -28,6 +28,8 @@
// uncomment for alloc/free debug messages
#define DEBUG_ALLOC
extern bool auto_repair_dos_psp_mcb_corruption;
uint16_t CONV_MAX_SEG = 0xA000;
Bitu UMB_START_SEG = 0x9FFF;
/* FIXME: This should be a variable that reflects the last RAM segment.
@@ -95,7 +97,7 @@ void DOS_CompressMemory(uint16_t first_segment=0/*default*/,uint32_t healfrom=0x
* block header. Real MS-DOS appears in this case to just scan up to the last valid block and
* then right after it, write a new free MCB block there. We can't do this for the split memory
* layout of the PCjr emulation. */
if (nseg >= healfrom && (nseg+1u) < CONV_MAX_SEG && !(machine==MCH_PCJR)) {
if (auto_repair_dos_psp_mcb_corruption && nseg >= healfrom && (nseg+1u) < CONV_MAX_SEG && !(machine==MCH_PCJR)) {
LOG(LOG_DOSMISC,LOG_ERROR)("Corrupted MCB chain, but within the possible memory region of the DOS application.");
DOS_Mem_MCBdump();
LOG(LOG_DOSMISC,LOG_ERROR)("Declaring all memory past it as a free block. This is apparently MS-DOS behavior.");

View File

@@ -4633,6 +4633,13 @@ void DOSBOX_SetupConfigSections(void) {
"Set either \"ipx=true\" in [ipx] section or \"ne2000=true\" in [ne2000] section for a full network redirector environment.");
Pbool->SetBasic(true);
Pbool = secprop->Add_bool("mcb corruption becomes application free memory",Property::Changeable::WhenIdle,false);
Pbool->Set_help("If MCB chain corruption occurs following the DOS program PSP segment and the DOS program does anything to cause memory allocation,"
"make a new free memory block in it's place instead of halting emulation with an MCB chain error. Some DOS programs are sloppy"
"with memory to corrupt the MCB chain after itself in memory. This is apparently real MS-DOS behavior, set to true to enable."
"If set to false, all MCB chain corruption will halt emulation as DOSBox forks typically do already.");
Pbool->SetBasic(true);
Phex = secprop->Add_hex("minimum dos initial private segment", Property::Changeable::WhenIdle,0);
Phex->Set_help("In non-mainline mapping mode, where DOS structures are allocated from base memory, this sets the\n"
"minimum segment value. Recommended value is 0x70. You may reduce the value down to 0x50 if freeing\n"