* kp-cls.asm
 
* clear screen/25th line/restore cursor - for video-able kaypros
* also toggles all video attributes OFF (defaults)
 
* v1.0  24-Oct-84
* v1.1  05-Jul-85  Added stack save/restore code

* Steve Sanders
* Tampa Bay Kaypro Users Group
* DataCOM NETWORK System #1 (813) 937-3608  300/1200/2400 bps

bdos	equ	5
printf	equ	9
esc	equ	1bh

	org	100h

begin:	
	lxi	h,0		;save old stack
	dad	sp
	shld	cpmstk		;store it in a safe place
	lxi	sp,stack+5	;generate new stack

	mvi	c,printf	;print string command
	lxi	d,clear		;point to message
	call	bdos		;and do it

	lhld	cpmstk		;get old stack
	sphl			;switch into stack pointer
	ret			;and exit 'cleanly' to CP/M

; following console msg will reset all attributes to default

clear:
	db	esc,'B4'	;ESCape, cursor ON (if OFF)
	db	esc,'C0'	;inverse video OFF
	db	esc,'C1'	;half intensity OFF
	db	esc,'C2'	;blinking OFF
	db	esc,'C3'	;underlining OFF
	db	esc,'C7'	;disable status line before 1ah
	db	1ah		;and clear whole screen/home cursor
	db	'$'		;thats all folks

cpmstk	dw	0		;old stack saved here

	ds	5
stack	equ	$

	end
