use calling application's code segment rather than psp value for some old-style (dos 1.0) terminate functions (ripsaw, fixes fortune teller)
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3476
This commit is contained in:
parent
42d8d2e962
commit
1c410c147e
3 changed files with 20 additions and 29 deletions
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: dos_inc.h,v 1.81 2009-07-09 20:06:56 c2woody Exp $ */
|
||||
/* $Id: dos_inc.h,v 1.82 2009-10-04 14:28:06 c2woody Exp $ */
|
||||
|
||||
#ifndef DOSBOX_DOS_INC_H
|
||||
#define DOSBOX_DOS_INC_H
|
||||
|
@ -154,7 +154,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,Bit8u exitcode);
|
||||
void DOS_Terminate(Bit16u pspseg,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.119 2009-07-31 16:41:37 qbix79 Exp $ */
|
||||
/* $Id: dos.cpp,v 1.120 2009-10-04 14:28:07 c2woody Exp $ */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -70,6 +70,9 @@ static Bitu DOS_21Handler(void) {
|
|||
char name1[DOSNAMEBUF+2+DOS_NAMELENGTH_ASCII];
|
||||
char name2[DOSNAMEBUF+2+DOS_NAMELENGTH_ASCII];
|
||||
switch (reg_ah) {
|
||||
case 0x00: /* Terminate Program */
|
||||
DOS_Terminate(mem_readw(SegPhys(ss)+reg_sp+2),false,0);
|
||||
break;
|
||||
case 0x01: /* Read character from STDIN, with echo */
|
||||
{
|
||||
Bit8u c;Bit16u n=1;
|
||||
|
@ -390,11 +393,9 @@ static Bitu DOS_21Handler(void) {
|
|||
reg_cx=0x0000;
|
||||
break;
|
||||
case 0x31: /* Terminate and stay resident */
|
||||
//TODO First get normal files executing
|
||||
// Important: This service does not set the carry flag!
|
||||
DOS_ResizeMemory(dos.psp(),®_dx);
|
||||
DOS_Terminate(true,reg_al);
|
||||
dos.return_mode=RETURN_TSR;
|
||||
DOS_Terminate(dos.psp(),true,reg_al);
|
||||
break;
|
||||
case 0x1f: /* Get drive parameter block for default drive */
|
||||
case 0x32: /* Get drive parameter block for specific drive */
|
||||
|
@ -708,18 +709,9 @@ static Bitu DOS_21Handler(void) {
|
|||
}
|
||||
break;
|
||||
//TODO Check for use of execution state AL=5
|
||||
case 0x00:
|
||||
reg_ax=0x4c00; /* Terminate Program */
|
||||
case 0x4c: /* EXIT Terminate with return code */
|
||||
{
|
||||
if (DOS_Terminate(false,reg_al)) {
|
||||
/* This can't ever return false normally */
|
||||
} else {
|
||||
reg_ax=dos.errorcode;
|
||||
CALLBACK_SCF(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
DOS_Terminate(dos.psp(),false,reg_al);
|
||||
break;
|
||||
case 0x4d: /* Get Return code */
|
||||
reg_al=dos.return_code;/* Officially read from SDA and clear when read */
|
||||
reg_ah=dos.return_mode;
|
||||
|
@ -1051,7 +1043,7 @@ static Bitu DOS_21Handler(void) {
|
|||
|
||||
|
||||
static Bitu DOS_20Handler(void) {
|
||||
reg_ax=0x4c00;
|
||||
reg_ah=0x00;
|
||||
DOS_21Handler();
|
||||
return CBRET_NONE;
|
||||
}
|
||||
|
@ -1059,7 +1051,8 @@ 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,0);
|
||||
Bit16u psp = mem_readw(SegPhys(ss)+reg_sp+2);
|
||||
if (DOS_ResizeMemory(psp,¶)) DOS_Terminate(psp,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.67 2009-05-27 09:15:41 qbix79 Exp $ */
|
||||
/* $Id: dos_execute.cpp,v 1.68 2009-10-04 14:28:07 c2woody Exp $ */
|
||||
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
@ -104,15 +104,13 @@ void DOS_UpdatePSPName(void) {
|
|||
GFX_SetTitle(-1,-1,false);
|
||||
}
|
||||
|
||||
bool DOS_Terminate(bool tsr,Bit8u exitcode) {
|
||||
void DOS_Terminate(Bit16u pspseg,bool tsr,Bit8u exitcode) {
|
||||
|
||||
dos.return_code=exitcode;
|
||||
dos.return_mode=RETURN_EXIT;
|
||||
dos.return_mode=(tsr)?RETURN_TSR:RETURN_EXIT;
|
||||
|
||||
Bit16u mempsp = dos.psp();
|
||||
|
||||
DOS_PSP curpsp(mempsp);
|
||||
if (mempsp==curpsp.GetParent()) return true;
|
||||
DOS_PSP curpsp(pspseg);
|
||||
if (pspseg==curpsp.GetParent()) return;
|
||||
/* Free Files owned by process */
|
||||
if (!tsr) curpsp.CloseFiles();
|
||||
|
||||
|
@ -136,10 +134,10 @@ bool DOS_Terminate(bool tsr,Bit8u exitcode) {
|
|||
interrupts enabled, test flags cleared */
|
||||
mem_writew(SegPhys(ss)+reg_sp+4,0x7202);
|
||||
// Free memory owned by process
|
||||
if (!tsr) DOS_FreeProcessMemory(mempsp);
|
||||
if (!tsr) DOS_FreeProcessMemory(pspseg);
|
||||
DOS_UpdatePSPName();
|
||||
|
||||
if ((!(CPU_AutoDetermineMode>>CPU_AUTODETERMINE_SHIFT)) || (cpu.pmode)) return true;
|
||||
if ((!(CPU_AutoDetermineMode>>CPU_AUTODETERMINE_SHIFT)) || (cpu.pmode)) return;
|
||||
|
||||
CPU_AutoDetermineMode>>=CPU_AUTODETERMINE_SHIFT;
|
||||
if (CPU_AutoDetermineMode&CPU_AUTODETERMINE_CYCLES) {
|
||||
|
@ -159,7 +157,7 @@ bool DOS_Terminate(bool tsr,Bit8u exitcode) {
|
|||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
static bool MakeEnv(char * name,Bit16u * segment) {
|
||||
|
|
Loading…
Add table
Reference in a new issue