;[]-------------------------------------------------------------------------[]
;|	Program name: 2_4_1.ASM                                              |
;|	Image   file: 2_4_1.COM                                              |
;|	Note        : This TSR program is modified from 2_2_6.ASM.           |
;|                    It is chained with INT 05H & INT 60H ISR.              |
;|                    This TSR program can be removed.                       |
;[]-------------------------------------------------------------------------[]


cseg	segment
	assume	cs:cseg,ds:cseg
	org	100H
start:
	jmp	initialize

;------- Data area ---------------------

old_int05	dd	?
old_int60	dd	?

;------- INT 05H -----------------------

new_int05	proc	far

	sti

	push	ax			; Save the register value
	push	bx
	push	cx
	push	dx

	mov	ah,7			; Scroll screen down one line
	mov	al,1
	mov	bh,7
	mov	ch,0
	mov	cl,0
	mov	dh,24
	mov	dl,79
	int	10H

	pop	dx			; Restore the register value
	pop	cx
	pop	bx
	pop	ax

	cli
	pushf				; Run the old INT 05H routine
	call	cs:old_int05

	iret

new_int05	endp

;------- INT 60H -----------------------

new_int60	proc	far

	sti

	push	ax
	push	dx
	push	ds

	mov	dx,cs:word ptr old_int05	; restore INT 05H
	mov	ds,cs:word ptr old_int05[2]
	mov	ax,2505H
	int	21H

	mov	dx,cs:word ptr old_int60	; restore INT 60H
	mov	ds,cs:word ptr old_int60[2]
	mov	ax,2560H
	int	21H

	pop	ds
	pop	dx
	pop	ax

	iret

new_int60	endp

;------- Main program ------------------

initialize:

	mov	al,05H			; Get the INT 05H interrupt vector
	mov	ah,35H
	int	21H
	mov	word ptr old_int05,bx	; Save the vector in old_int05
	mov	word ptr old_int05[2],es

	mov	al,60H			; Get the INT 60H interrupt vector
	mov	ah,35H
	int	21H
	mov	word ptr old_int60,bx	; Save the vector in old_int60
	mov	word ptr old_int60[2],es

	mov	dx,offset new_int05	; Set the INT 05H interrupt vector
	mov	al,05H
	mov	ah,25H
	int	21H

	mov	dx,offset new_int60	; Set the INT 60H interrupt vector
	mov	al,60H
	mov	ah,25H
	int	21H

	mov	dx,offset initialize	; Terminate and stay resident
	int	27H

cseg	ends
	end	start