mirror of
https://github.com/joncampbell123/dosbox-x.git
synced 2025-10-13 17:48:10 +08:00
retab
This commit is contained in:
@@ -286,7 +286,7 @@ bool DOS_Execute(const char* name, PhysPt block_pt, uint8_t flags) {
|
||||
uint16_t pspseg,envseg,loadseg,memsize=0xffff,readsize;
|
||||
uint16_t maxsize,maxfree=0xffff;
|
||||
PhysPt loadaddress;RealPt relocpt;
|
||||
uint32_t headersize = 0, imagesize = 0;
|
||||
uint32_t headersize = 0, imagesize = 0;
|
||||
DOS_ParamBlock block(block_pt);
|
||||
uint32_t checksum = 0;
|
||||
uint32_t checksum_bytes = 0;
|
||||
@@ -303,17 +303,17 @@ bool DOS_Execute(const char* name, PhysPt block_pt, uint8_t flags) {
|
||||
/* Check for EXE or COM File */
|
||||
bool iscom=false;
|
||||
if (!DOS_OpenFile(name,OPEN_READ,&fhandle)) {
|
||||
int16_t fLen = (int16_t)strlen(name);
|
||||
bool shellcom =(!strcasecmp(name+fLen-8, "4DOS.COM") && (fLen == 8 || *(name+fLen-9)=='\\')) || (!strcasecmp(name+fLen-11, "COMMAND.COM") && (fLen == 11 || *(name+fLen-12)=='\\')); // Trap 4DOS.COM and COMMAND.COM
|
||||
char z4dos[]="Z:\\4DOS\\4DOS.COM", zcmd[]="Z:\\COMMAND.COM";
|
||||
if (ZDRIVE_NUM!=25) {
|
||||
z4dos[0]='A'+ZDRIVE_NUM;
|
||||
zcmd[0]='A'+ZDRIVE_NUM;
|
||||
}
|
||||
if (!shellcom || !DOS_OpenFile(!strcasecmp(name+fLen-8, "4DOS.COM")?z4dos:zcmd,OPEN_READ,&fhandle)) {
|
||||
DOS_SetError(DOSERR_FILE_NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
int16_t fLen = (int16_t)strlen(name);
|
||||
bool shellcom =(!strcasecmp(name+fLen-8, "4DOS.COM") && (fLen == 8 || *(name+fLen-9)=='\\')) || (!strcasecmp(name+fLen-11, "COMMAND.COM") && (fLen == 11 || *(name+fLen-12)=='\\')); // Trap 4DOS.COM and COMMAND.COM
|
||||
char z4dos[]="Z:\\4DOS\\4DOS.COM", zcmd[]="Z:\\COMMAND.COM";
|
||||
if (ZDRIVE_NUM!=25) {
|
||||
z4dos[0]='A'+ZDRIVE_NUM;
|
||||
zcmd[0]='A'+ZDRIVE_NUM;
|
||||
}
|
||||
if (!shellcom || !DOS_OpenFile(!strcasecmp(name+fLen-8, "4DOS.COM")?z4dos:zcmd,OPEN_READ,&fhandle)) {
|
||||
DOS_SetError(DOSERR_FILE_NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
len=sizeof(EXE_Header);
|
||||
if (!DOS_ReadFile(fhandle,(uint8_t *)&head,&len)) {
|
||||
@@ -380,17 +380,17 @@ bool DOS_Execute(const char* name, PhysPt block_pt, uint8_t flags) {
|
||||
if (head.maxmemory!=0) maxsize=long2para(imagesize+((unsigned int)head.maxmemory<<4u)+256u);
|
||||
else maxsize=0xffffu;
|
||||
|
||||
/* Bugfix: scene.org mirrors/hornet/demos/1991/putrefac.zip Putrefaction !PF.{3}
|
||||
* has an EXE header that specifies a maxsize less than minsize, and a
|
||||
* initial stack pointer that is only valid if we use the maxsize.
|
||||
*
|
||||
* This allows it to run without the SS:IP out of range error below. */
|
||||
if (maxsize < minsize) maxsize = minsize;
|
||||
/* Bugfix: scene.org mirrors/hornet/demos/1991/putrefac.zip Putrefaction !PF.{3}
|
||||
* has an EXE header that specifies a maxsize less than minsize, and a
|
||||
* initial stack pointer that is only valid if we use the maxsize.
|
||||
*
|
||||
* This allows it to run without the SS:IP out of range error below. */
|
||||
if (maxsize < minsize) maxsize = minsize;
|
||||
}
|
||||
maxfree = DOS_GetMaximumFreeSize(minsize);
|
||||
if (maxfree<minsize) {
|
||||
DOS_CloseFile(fhandle);
|
||||
delete[] loadbuf;
|
||||
delete[] loadbuf;
|
||||
DOS_SetError(DOSERR_INSUFFICIENT_MEMORY);
|
||||
DOS_FreeMemory(envseg);
|
||||
return false;
|
||||
@@ -472,11 +472,11 @@ bool DOS_Execute(const char* name, PhysPt block_pt, uint8_t flags) {
|
||||
SetupCMDLine(pspseg,block);
|
||||
}
|
||||
CALLBACK_SCF(false); /* Carry flag cleared for caller if successful */
|
||||
if(flags == OVERLAY) {
|
||||
reg_ax = 0; // Testing with MS-DOS (6.22) shows that if INT 21 AX=4B is called with the overlay flag (AL==3), then AX and DX are 0 on return.
|
||||
reg_dx = 0;
|
||||
return true; /* Everything done for overlays */
|
||||
}
|
||||
if(flags == OVERLAY) {
|
||||
reg_ax = 0; // Testing with MS-DOS (6.22) shows that if INT 21 AX=4B is called with the overlay flag (AL==3), then AX and DX are 0 on return.
|
||||
reg_dx = 0;
|
||||
return true; /* Everything done for overlays */
|
||||
}
|
||||
RealPt csip,sssp;
|
||||
if (iscom) {
|
||||
unsigned int stack_sp = 0xfffe;
|
||||
|
@@ -67,8 +67,8 @@ static void DOS_Mem_E_Exit(const char *msg) {
|
||||
LOG_MSG("End dump\n");
|
||||
|
||||
#if C_DEBUG
|
||||
LOG_MSG("DOS fatal memory error: %s",msg);
|
||||
throw int(7); // DOS non-fatal error (restart when debugger runs again)
|
||||
LOG_MSG("DOS fatal memory error: %s",msg);
|
||||
throw int(7); // DOS non-fatal error (restart when debugger runs again)
|
||||
#else
|
||||
E_Exit("%s",msg);
|
||||
#endif
|
||||
@@ -159,16 +159,16 @@ static uint16_t GetMaximumMCBFreeSize(uint16_t mcb_segment)
|
||||
{
|
||||
uint16_t largestSize = 0;
|
||||
DOS_MCB mcb(mcb_segment);
|
||||
uint16_t last_mcb_segment;
|
||||
uint16_t last_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;
|
||||
last_mcb_segment = mcb_segment;
|
||||
last_mcb_segment = mcb_segment;
|
||||
mcb_segment += size+1;
|
||||
if (mcb_segment == last_mcb_segment) // Check for infinite loop
|
||||
break;
|
||||
if (mcb_segment == last_mcb_segment) // Check for infinite loop
|
||||
break;
|
||||
}
|
||||
return largestSize;
|
||||
}
|
||||
@@ -432,13 +432,13 @@ bool DOS_ResizeMemory(uint16_t segment,uint16_t * blocks) {
|
||||
|
||||
|
||||
bool DOS_FreeMemory(uint16_t segment) {
|
||||
//TODO Check if allowed to free this segment
|
||||
//TODO Check if allowed to free this segment
|
||||
if (segment < DOS_MEM_START+1) {
|
||||
LOG(LOG_DOSMISC,LOG_ERROR)("Program tried to free %X ---ERROR",segment);
|
||||
DOS_SetError(DOSERR_MB_ADDRESS_INVALID);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
DOS_MCB mcb(segment-1);
|
||||
if ((mcb.GetType()!=0x4d) && (mcb.GetType()!=0x5a)) {
|
||||
DOS_SetError(DOSERR_MB_ADDRESS_INVALID);
|
||||
@@ -450,7 +450,7 @@ bool DOS_FreeMemory(uint16_t segment) {
|
||||
#endif
|
||||
|
||||
mcb.SetPSPSeg(MCB_FREE);
|
||||
// DOS_CompressMemory();
|
||||
// DOS_CompressMemory();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -461,8 +461,8 @@ void DOS_BuildUMBChain(bool umb_active,bool /*ems_active*/) {
|
||||
|
||||
/* UMBs are only possible if the machine has 1MB+64KB of RAM */
|
||||
if (umb_active && (machine!=MCH_TANDY) && seg_limit >= (0x10000+0x1000-1) && first_umb_seg < GetEMSPageFrameSegment()) {
|
||||
/* XMS emulation sets UMB size now.
|
||||
* PCjr mode disables UMB emulation */
|
||||
/* XMS emulation sets UMB size now.
|
||||
* PCjr mode disables UMB emulation */
|
||||
#if 0
|
||||
if (ems_active) {
|
||||
/* we can use UMBs up to the EMS page frame */
|
||||
@@ -521,7 +521,7 @@ bool DOS_LinkUMBsToMemChain(uint16_t linkstate) {
|
||||
}
|
||||
|
||||
if ((linkstate&1)==(dos_infoblock.GetUMBChainState()&1)) return true;
|
||||
|
||||
|
||||
/* Scan MCB-chain for last block before UMB-chain */
|
||||
uint16_t mcb_segment=dos.firstMCB;
|
||||
uint16_t prev_mcb_segment=dos.firstMCB;
|
||||
|
Reference in New Issue
Block a user