;*
;* asmcls
;*

;* Version T1.00 - 06-Dec-86 - tmk - Initial version
;* Version T1.01 - 02-Jul-87 - tmk - Add support for Turbo C
;* Version T1.02 - 14-Jul-87 - tmk - Fix clear screen on non-EGA systems,
;*				     stick version no. in binary
;* Version T1.03 - 15-Oct-87 - tmk - Remove .287 for MASM 5.0

;* do stuff for C interfaces

	TITLE   asmcls

_TEXT	SEGMENT  BYTE PUBLIC 'CODE'
_TEXT	ENDS
_DATA	SEGMENT  WORD PUBLIC 'DATA'
_DATA	ENDS
CONST	SEGMENT  WORD PUBLIC 'CONST'
CONST	ENDS
_BSS	SEGMENT  WORD PUBLIC 'BSS'
_BSS	ENDS
DGROUP	GROUP	CONST,	_BSS,	_DATA
	ASSUME  CS: _TEXT, DS: DGROUP, SS: DGROUP, ES: DGROUP
_TEXT	SEGMENT

	PUBLIC	_asmcls

	db	'ASMCLS T1.03 - 15-Oct-87 - tmk'

_asmcls	PROC NEAR
	push	bp
	push	si		;these 2 are Turbo C register variables
	push	di
	mov	bp,sp
	push	bp		;save C's BP
	push	es		;and ES
	sub	bh,bh		;ensure valid parameter to call
	mov	dl,25		;[1.02] set a reasonable default for non-EGA
	mov	ax,1130h	;return number of rows (EGA only)
	int	10h
	mov	ah,0fh		;return number of columns
	int	10h
	dec	ah		;number of columns (0-based)
	mov	ch,dl
	mov	cl,ah		;CX = rows, columns
	mov	ah,0		;default attribute for graphics modes
	cmp	al,7		;monochrome mode?
	jz	mono		;if so
	cmp	al,3		;text mode?
	ja	grafix		;if not
mono:	mov	dl,' '		;write a space to the display
	mov	ah,2		;using DOS services
	int	21h
	mov	ax,0e08h	;now backspace over it
	int	10h
	mov	ah,8		;now read it's attribute
	int	10h
grafix:	push	bx		;save current video page
	mov	bh,ah		;using desired attribute
	mov	dx,cx		;bottom right of screen
	sub	cx,cx		;top left of screen
	mov	ax,0600h	;scroll screen
	int	10h
	pop	bx		;restore desired video page
	sub	dx,dx		;home cursor
	mov	ah,2
	int	10h
	pop	es
	pop	bp
	mov	sp,bp
	pop	di
	pop	si
	pop	bp
	ret			;and back to C

_asmcls	ENDP
_TEXT	ENDS
	END
                                                                                                                                                                         