allow small .com files to be exectued with not much free memory left;
int27 always clears the returned error code; fixes corncob3d music Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3048
This commit is contained in:
parent
0e6e7bea4c
commit
10b39bc067
3 changed files with 21 additions and 13 deletions
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: dos_inc.h,v 1.71 2007-11-07 22:08:03 c2woody Exp $ */
|
||||
/* $Id: dos_inc.h,v 1.72 2007-11-18 10:30:11 c2woody Exp $ */
|
||||
|
||||
#ifndef DOSBOX_DOS_INC_H
|
||||
#define DOSBOX_DOS_INC_H
|
||||
|
@ -150,7 +150,7 @@ void DOS_SetupDevices(void);
|
|||
bool DOS_NewPSP(Bit16u pspseg,Bit16u size);
|
||||
bool DOS_ChildPSP(Bit16u pspseg,Bit16u size);
|
||||
bool DOS_Execute(char * name,PhysPt block,Bit8u flags);
|
||||
bool DOS_Terminate(bool tsr);
|
||||
bool DOS_Terminate(bool tsr,Bit8u exitcode);
|
||||
|
||||
/* Memory Handling Routines */
|
||||
void DOS_SetupMemory(void);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: dos.cpp,v 1.105 2007-11-04 11:11:34 c2woody Exp $ */
|
||||
/* $Id: dos.cpp,v 1.106 2007-11-18 10:30:12 c2woody Exp $ */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -384,7 +384,7 @@ static Bitu DOS_21Handler(void) {
|
|||
//TODO First get normal files executing
|
||||
// Important: This service does not set the carry flag!
|
||||
DOS_ResizeMemory(dos.psp(),®_dx);
|
||||
DOS_Terminate(true);
|
||||
DOS_Terminate(true,reg_al);
|
||||
dos.return_code=reg_al; //Officially a field in the SDA
|
||||
dos.return_mode=RETURN_TSR;
|
||||
break;
|
||||
|
@ -689,7 +689,7 @@ static Bitu DOS_21Handler(void) {
|
|||
reg_ax=0x4c00; /* Terminate Program */
|
||||
case 0x4c: /* EXIT Terminate with return code */
|
||||
{
|
||||
if (DOS_Terminate(false)) {
|
||||
if (DOS_Terminate(false,reg_al)) {
|
||||
/* This can't ever return false normally */
|
||||
} else {
|
||||
reg_ax=dos.errorcode;
|
||||
|
@ -1011,7 +1011,6 @@ static Bitu DOS_21Handler(void) {
|
|||
break;
|
||||
};
|
||||
return CBRET_NONE;
|
||||
/* That's it now let's get it working */
|
||||
};
|
||||
|
||||
|
||||
|
@ -1024,7 +1023,7 @@ static Bitu DOS_20Handler(void) {
|
|||
static Bitu DOS_27Handler(void) {
|
||||
// Terminate & stay resident
|
||||
Bit16u para = (reg_dx/16)+((reg_dx % 16)>0);
|
||||
if (DOS_ResizeMemory(dos.psp(),¶)) DOS_Terminate(true);
|
||||
if (DOS_ResizeMemory(dos.psp(),¶)) DOS_Terminate(true,0);
|
||||
return CBRET_NONE;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: dos_execute.cpp,v 1.62 2007-10-19 19:39:27 c2woody Exp $ */
|
||||
/* $Id: dos_execute.cpp,v 1.63 2007-11-18 10:30:12 c2woody Exp $ */
|
||||
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
@ -104,9 +104,9 @@ void DOS_UpdatePSPName(void) {
|
|||
GFX_SetTitle(-1,-1,false);
|
||||
}
|
||||
|
||||
bool DOS_Terminate(bool tsr) {
|
||||
bool DOS_Terminate(bool tsr,Bit8u exitcode) {
|
||||
|
||||
dos.return_code=reg_al;
|
||||
dos.return_code=exitcode;
|
||||
dos.return_mode=RETURN_EXIT;
|
||||
|
||||
Bit16u mempsp = dos.psp();
|
||||
|
@ -330,9 +330,18 @@ bool DOS_Execute(char * name,PhysPt block_pt,Bit8u flags) {
|
|||
else maxsize=0xffff;
|
||||
}
|
||||
if (maxfree<minsize) {
|
||||
DOS_SetError(DOSERR_INSUFFICIENT_MEMORY);
|
||||
DOS_FreeMemory(envseg);
|
||||
return false;
|
||||
if (iscom) {
|
||||
/* Reduce minimum of needed memory size to filesize */
|
||||
pos=0;DOS_SeekFile(fhandle,&pos,DOS_SEEK_SET);
|
||||
Bit16u dataread=0xf800;
|
||||
DOS_ReadFile(fhandle,loadbuf,&dataread);
|
||||
if (dataread<0xf800) minsize=((dataread+0x10)>>4)+0x20;
|
||||
}
|
||||
if (maxfree<minsize) {
|
||||
DOS_SetError(DOSERR_INSUFFICIENT_MEMORY);
|
||||
DOS_FreeMemory(envseg);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (maxfree<maxsize) memsize=maxfree;
|
||||
else memsize=maxsize;
|
||||
|
|
Loading…
Add table
Reference in a new issue