Timer		= 08
Idle		= 028
PrnScr		= 05

		jmp	@@Start

@@Timer:	pushf
		db	09a
_OldT:		dd	?
		push	es
		push	bx
		les	bx,cs:[offset _InDOS]
		cmp	byte ptr es:[bx],0
		pop	bx
		pop	es
		je	@@Check
		iret

@@Idle:		pushf
		db	09a
_OldI:		dd	?
@@Check:	cmp	byte ptr cs:[offset _Switch],1
		je	@@Main
		iret

@@Main:

mov	byte ptr cs:[offset _Switch],0

push	ax
push	bx
push	cx
push	dx
push	si
push	di
push	bp
push	ds
push	es

push	cs
pop	ds

mov	dx,ss
mov	bp,sp

cmp	byte ptr [offset _Prog],0
je	@@Load

mov	bx,[offset _PSP]
mov	ah,050
int	021
mov	ah,051
int	021
mov	[offset _PSP],bx

mov	ss,[offset _SS]
mov	sp,[offset _SP]

mov	[offset _SS],dx
mov	[offset _SP],bp

;xor	si,si
;mov	di,si
;mov	ds,si
;mov	es,si
;mov	cx,256*2
;@@Table:
;lodsw
;xchg	ax,cs:[offset @@Start+100][di]
;stosw
;loop	@@Table

@@Out:

pop	es
pop	ds
pop	bp
pop	di
pop	si
pop	dx
pop	cx
pop	bx
pop	ax

iret

@@Load:
		mov	byte ptr [offset _Prog],1
		mov	ah,051
		int	021
		mov	[offset _PSP],bx
		mov	[offset _SS],dx
		mov	[offset _SP],bp
		mov	[_ExecParamRec+4],cs
		mov	word ptr [_ExecParamRec+2],offset _CmdLine
		push	cs
		pop	es
		mov	dx,offset _ExecPath
		mov	bx,offset _ExecParamRec
		mov	ax,04b00
		int	021
		mov	ss,cs:[offset _SS]
		mov	sp,cs:[offset _SP]
		mov	byte ptr cs:[offset _Prog],0
		jmp	short @@Out

_Switch:	db	0
_InDOS:		dd	?
_Prog		db	0
_PSP:		dw	0
_SS:		dw	?
_SP:		dw	?

_ExecPath:	db	"p2.com",0
_ExecParamRec:	dw	0
		dd	?
_CmdLine	db	0,0d

@@PrnScr:	mov	byte ptr cs:[offset _Switch],1
		iret

@@Start:	mov	ah,034
		int	021
		mov	[offset _InDOS+2],es
		mov	[offset _InDOS],bx
		push	0
		pop	es
		cli
		mov	es:[PrnScr*4],offset @@PrnScr
		mov	ax,offset @@Timer
		xchg	ax,es:[Timer*4]
		mov	[offset _OldT],ax
		mov	ax,offset @@Idle
;		xchg	ax,es:[Idle*4]
		mov	[offset _OldI],ax
		mov	ax,ds
		mov	es:[PrnScr*4+2],ax
		xchg	ax,es:[Timer*4+2]
		mov	[offset _OldT+2],ax
		mov	ax,ds
;		xchg	ax,es:[Idle*4+2]
		mov	[offset _OldI+2],ax
		sti
		mov	dx,offset @@Start+1024
		int	027
