/*--------------------------------------------------------------------------*/
/*	Program name: 4_3_2.C                                               */
/*	Compile mode: Tiny                                                  */
/*	Image   file: None                                                  */
/*	Note        : List NewInt21() procedure only.                       */
/*--------------------------------------------------------------------------*/


/*----------------- NewInt21 -----------------------------------------------*/

void	interrupt	NewInt21( unsigned BP,unsigned DI,unsigned SI,
				  unsigned DS,unsigned ES,unsigned DX,
				  unsigned CX,unsigned BX,unsigned AX,
				  unsigned IP,unsigned CS,unsigned FLAGS )
{	static	union	REGS	regs;
	static	struct	SREGS	sregs;
	static	char	far	*ptr;
	static	int	i;
	char	ah;


	if (Busy)	goto	i21_done;
	_AX=AX;
	ah=_AH;
	if ((ah!=0x3D)&&(ah!=0x4E))	goto	i21_done;

	Busy=1;

	regs.x.ax=AX;
	regs.x.bx=BX;
	regs.x.cx=CX;
	regs.x.dx=DX;
	regs.x.si=SI;
	regs.x.di=DI;
	regs.x.flags=FLAGS;
	sregs.es=ES;
	sregs.ds=DS;

	OLD_SS=_SS;
	OLD_SP=_SP;

	disable();
	_SS=TSR_SS;
	_SP=TSR_SP;
	enable();

	ptr=MK_FP(sregs.ds,regs.x.dx);
	while((*ptr)&&(i<0x1000))	name_buf[i++]=*ptr++;
	if (i<0x1000)	i++;

	int86x(0x21,&regs,&regs,&sregs);

	disable();
	_SS=OLD_SS;
	_SP=OLD_SP;
	enable();

	AX=regs.x.ax;
	BX=regs.x.bx;
	CX=regs.x.cx;
	DX=regs.x.dx;
	SI=regs.x.si;
	DI=regs.x.di;
	FLAGS=regs.x.flags;
	ES=sregs.es;
	DS=sregs.ds;

	Busy=0;

	return;




i21_done:
	_SP=_SP-6;
	_BP=_BP-6;
	BP=DS;
	DI=ES;
	SI=DX;
	DS=CX;
	ES=BX;
	DX=AX;
	CX=IP;
	BX=CS;
	AX=FLAGS;
	_BP=_BP+6;
	CX=(unsigned int)OldInt21;
	BX=(unsigned long)OldInt21 / 65536;
	AX=FLAGS;
	_BP=_BP-6;
}

