diff --git a/src/dos/dos_memory.cpp b/src/dos/dos_memory.cpp index 0f97762d..6a3c47a8 100644 --- a/src/dos/dos_memory.cpp +++ b/src/dos/dos_memory.cpp @@ -191,6 +191,7 @@ bool DOS_ResizeMemory(Bit16u segment,Bit16u * blocks) { mcb.SetPSPSeg(dos.psp()); return true; } + /* MCB will grow, try to join with following MCB */ if (mcb.GetType()!=0x5a) { if (mcb_next.GetPSPSeg()==MCB_FREE) { total+=mcb_next.GetSize()+1; @@ -198,6 +199,7 @@ bool DOS_ResizeMemory(Bit16u segment,Bit16u * blocks) { } if (*blockstotal, + in the second case resize block to maximum */ + + if (mcb.GetType()!=0x5a) { + /* adjust type of joined MCB */ + mcb.SetType(mcb_next.GetType()); } - *blocks=total; + mcb.SetSize(total); + mcb.SetPSPSeg(dos.psp()); + if (*blocks==total) return true; /* block fit exactly */ + + *blocks=total; /* return maximum */ DOS_SetError(DOSERR_INSUFFICIENT_MEMORY); return false; }