Skip to content

Commit

Permalink
DOS SHELL: Apparently INT 2Eh (command shell) was not implemented. Bo…
Browse files Browse the repository at this point in the history
…rrow INT 2Eh handler from DOSBox SVN to add it. This fixes certain demoscene productions that rely on INT 2Eh to direct COMMAND.COM for some demo parts
  • Loading branch information
joncampbell123 committed Jul 13, 2018
1 parent b3f8ffc commit d28179f
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion src/shell/shell.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@


extern bool dos_shell_running_program; extern bool dos_shell_running_program;


Bitu shell_psp = 0;

void CALLBACK_DeAllocate(Bitu in); void CALLBACK_DeAllocate(Bitu in);


Bitu call_shellstop = 0; Bitu call_shellstop = 0;
Expand Down Expand Up @@ -563,6 +565,41 @@ void AUTOEXEC_Init() {
AddVMEventFunction(VM_EVENT_DOS_SURPRISE_REBOOT,AddVMEventFunctionFuncPair(AUTOEXEC_ShutDown)); AddVMEventFunction(VM_EVENT_DOS_SURPRISE_REBOOT,AddVMEventFunctionFuncPair(AUTOEXEC_ShutDown));
} }


static Bitu INT2E_Handler(void) {
/* Save return address and current process */
RealPt save_ret=real_readd(SegValue(ss),reg_sp);
Bit16u save_psp=dos.psp();

/* Set first shell as process and copy command */
dos.psp(shell_psp);//DOS_FIRST_SHELL);
DOS_PSP psp(shell_psp);//DOS_FIRST_SHELL);
psp.SetCommandTail(RealMakeSeg(ds,reg_si));
SegSet16(ss,RealSeg(psp.GetStack()));
reg_sp=2046;

/* Read and fix up command string */
CommandTail tail;
MEM_BlockRead(PhysMake(dos.psp(),128),&tail,128);
if (tail.count<127) tail.buffer[tail.count]=0;
else tail.buffer[126]=0;
char* crlf=strpbrk(tail.buffer,"\r\n");
if (crlf) *crlf=0;

/* Execute command */
if (strlen(tail.buffer)) {
DOS_Shell temp;
temp.ParseLine(tail.buffer);
temp.RunInternal();
}

/* Restore process and "return" to caller */
dos.psp(save_psp);
SegSet16(cs,RealSeg(save_ret));
reg_ip=RealOff(save_ret);
reg_ax=0;
return CBRET_NONE;
}

static char const * const path_string="PATH=Z:\\"; static char const * const path_string="PATH=Z:\\";
static char const * const comspec_string="COMSPEC=Z:\\COMMAND.COM"; static char const * const comspec_string="COMSPEC=Z:\\COMMAND.COM";
static char const * const prompt_string="PROMPT=$P$G"; static char const * const prompt_string="PROMPT=$P$G";
Expand Down Expand Up @@ -915,6 +952,7 @@ void SHELL_Init() {


// now COMMAND.COM has a main body and PSP segment, reflect it // now COMMAND.COM has a main body and PSP segment, reflect it
dos.psp(psp_seg); dos.psp(psp_seg);
shell_psp = psp_seg;


{ {
DOS_MCB mcb((Bit16u)(env_seg-1)); DOS_MCB mcb((Bit16u)(env_seg-1));
Expand Down Expand Up @@ -943,7 +981,13 @@ void SHELL_Init() {


/* Set up int 23 to "int 20" in the psp. Fixes what.exe */ /* Set up int 23 to "int 20" in the psp. Fixes what.exe */
real_writed(0,0x23*4,((Bit32u)psp_seg<<16)); real_writed(0,0x23*4,((Bit32u)psp_seg<<16));


/* Set up int 2e handler */
Bitu call_int2e=CALLBACK_Allocate();
RealPt addr_int2e=RealMake(psp_seg+16+1,8);
CALLBACK_Setup(call_int2e,&INT2E_Handler,CB_IRET_STI,Real2Phys(addr_int2e),"Shell Int 2e");
RealSetVec(0x2e,addr_int2e);

/* Setup environment */ /* Setup environment */
PhysPt env_write=PhysMake(env_seg,0); PhysPt env_write=PhysMake(env_seg,0);
MEM_BlockWrite(env_write,path_string,(Bitu)(strlen(path_string)+1)); MEM_BlockWrite(env_write,path_string,(Bitu)(strlen(path_string)+1));
Expand Down

0 comments on commit d28179f

Please sign in to comment.