' CLS.INC: 		Procedures to make clearing the screen faster.
'
' version:		06-25-84
' compiler:		Structured BASIC v1.12
' uses:			assemler routine CLS.DATA
' module type:	include
'
' Function FNWHERE(P) locates assembler language program as a
' string in memory. Be careful about changing code to load it!

procedure SETUP.CLS		'Load the assembler program, set up variables
	def FNWHERE(P) = 256*peek(P+2) + peek(P+1)
	CLS.ASM$ = space$(23)
	restore CLS.DATA
    SETUP.CLS.P = FNWHERE(VARPTR(CLS.ASM$))
	for SETUP.CLS.I%=1 to 22
		read SETUP.CLS.J%
		poke SETUP.CLS.P,SETUP.CLS.J%
		SETUP.CLS.P = SETUP.CLS.P + 1
	next SETUP.CLS.I%
endproc

procedure CLEOS			'Clear from cursor to end of screen
	EOS.COUNT% = 24*SCREEN.WIDTH - (csrlin-1)*SCREEN.WIDTH - pos(0)
	CLS.SUB = FNWHERE(varptr(CLS.ASM$))
	call CLS.SUB(EOS.COUNT%)
endproc

procedure CLEOL			'Clear from cursor to end of line
	EOL.COUNT% = SCREEN.WIDTH-pos(0)
	CLS.SUB = FNWHERE(varptr(CLS.ASM$))
	call CLS.SUB(EOL.COUNT%)
endproc

CLS.DATA|
	data &H55, &H8B, &HEC, &H8B, &H76, &H06, &H8B, &H0C, &HB7, &H00
	data &HB0, &H20, &HB3, &H07, &HB4, &H09, &HCD, &H10, &H5D, &HCA
	data &H02, &H00
