mirror of
https://github.com/joncampbell123/dosbox-x.git
synced 2025-10-17 07:12:15 +08:00
Fix with how DOS_Execute allocates memory to comply with the memory allocation strategy for UMB...now, it will allocate and execute in UMB if there is enough memory for the minimum allocation of the executable
This commit is contained in:
@@ -16,8 +16,9 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "dosbox.h"
|
||||
#include "dosbox.h"
|
||||
#include "logging.h"
|
||||
#include "mem.h"
|
||||
#include "bios.h"
|
||||
@@ -153,6 +154,31 @@ void DOS_zeromem(uint16_t seg,uint16_t para) {
|
||||
}
|
||||
}
|
||||
|
||||
static uint16_t GetMaximumMCBFreeSize(uint16_t mcb_segment)
|
||||
{
|
||||
uint16_t largestSize = 0;
|
||||
DOS_MCB mcb(mcb_segment);
|
||||
for (bool endOfChain = false; !endOfChain; mcb.SetPt(mcb_segment))
|
||||
{
|
||||
auto size = mcb.GetSize();
|
||||
if (mcb.GetPSPSeg()==MCB_FREE) largestSize = std::max(largestSize, size);
|
||||
endOfChain = DOS_MCB::MCBType(mcb.GetType())==DOS_MCB::MCBType::LastBlock;
|
||||
mcb_segment += size+1;
|
||||
}
|
||||
return largestSize;
|
||||
}
|
||||
|
||||
uint16_t DOS_GetMaximumFreeSize(uint16_t minBlocks)
|
||||
{
|
||||
uint16_t umbFreeSize = 0;
|
||||
if (memAllocStrategy & 0xc0)
|
||||
{
|
||||
umbFreeSize = GetMaximumMCBFreeSize(dos_infoblock.GetStartOfUMBChain());
|
||||
if (memAllocStrategy & 0x40 || umbFreeSize >= minBlocks) return umbFreeSize;
|
||||
}
|
||||
return GetMaximumMCBFreeSize(dos.firstMCB);
|
||||
}
|
||||
|
||||
bool DOS_AllocateMemory(uint16_t * segment,uint16_t * blocks) {
|
||||
DOS_CompressMemory();
|
||||
uint16_t bigsize=0;
|
||||
|
Reference in New Issue
Block a user