From 267d3c2539f997afa8dd1f80a9db118bc6e167b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Strohh=C3=A4cker?= Date: Thu, 13 Oct 2005 16:24:42 +0000 Subject: [PATCH] resize MCB to maximum if requested size is too big (DSPlay) Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2347 --- src/dos/dos_memory.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) 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; }