	section	ClrScn,CODE
	IDNT	Blank

**	ClrScn
**		for clearing the StdOut screen
**
**		Copyright ©1990 DigiSoft
**
**	Permission is granted to purchasers of Macro68 to modify this source
**	file.  Permission is further granted to distribute the source code that
**	they have modified subject to the following conditions:
**	1.  That the original, unaltered, source is included with the
**	    distribution.
**	2.  That no charge is made for the distribution, other than the cost of
**	    media.                    (Distribution via Fred Fish is permitted)
**	3.  That my copyright notice remains as part of this and any other
**	    file adapted from this file.
**                                               Paul Coward
**                                                         DigiSoft
**
**	Tabstops : 8
**	Assemble with Macro68


**	20-07-90	** written


**  FUNCTION & USAGE
**
**	ClrScn row
**
**	Clear the current StdOut screen.  Position the cursor @ row.
**
***********************************************************



		OBJFILE		"ram:ClrScn"
	;	ERRFILE		"ram:ClrScn.bugs"

	;	PALL
	;	HALL
	;	LFCOND
		EXEOBJ
	;	LIST
	;	LISTSYMS
	;	ADDSYM
	;	LISTFILE	"ram:ClrScn.lst"
	;	CREFFILE	"ram:ClrScn.cref"
	;	EQUFILE		"ram:ClrScn.equ"
	;	REALTIME
		STRICT


	ifnd	EXEC_TYPES_I
_AbsExecBase		equ	4
_LVOAlert		equ	-108	;exec
_LVOCloseLibrary	equ	-414	;exec
_LVOOpenLibrary		equ	-552	;exec
AT_Recovery		equ	$00000000
AG_OpenLib		equ	$00030000
RETURN_OK		equ	0
RETURN_ERROR		equ	10
	endc


	ifnd	AO_DSSLib
AO_DSSLib		equ	$00008099	;alert number id support library can't be opened
Lf			equ	$0a
csd_Output		equ	20*4
	endc


_LVOdsAllocCPremember	equ	-30
_LVOdsAllocScratch	equ	-42
_LVOdsDosWrite		equ	-864
_LVOdsGetDecimal	equ	-180
_LVOdsParse		equ	-216
_LVOdsPuts		equ	-648
_LVOdsReadLine		equ	-654
_LVOdsStrLen		equ	-288
_LVOdsToLower		equ	-840



		setso	84
csd_RememberKey	so.l	1
csd_Args	so.b	8
csd_SIZEOF	soval


Release			equ	'1.0 '
VerNo			equ	'0.01'

*************************
*	COLD ENTRY	*
*************************


START:		moveq		#0,d3
		move.l		a0,d6
		move.l		d0,d7
		movea.l		(_AbsExecBase).w,a6	;establish exec for calls

	; --- open the support library

		moveq		#2,d0			;version #
		lea	 	(supportLibName,pc),a1	;point to liberary name
		jsr		(_LVOOpenLibrary,a6)	;exec
		tst.l		d0
		bne.b		1$
		move.l		#AT_Recovery!AG_OpenLib!AO_DSSLib,d7
		jsr		(_LVOAlert,a6)
		bra		fail

	; --- initialize the scratch area

1$		movea.l		d0,a6
		move.l		#csd_SIZEOF,d0
		moveq		#33,d1
		moveq		#0,d2
		jsr		(_LVOdsAllocScratch,a6)
		bne		fail

	; --- initialize the argument pointers

		movem.l		d6-d7,(csd_Args,a5)	;& a_Length(A0)

	; --- parse args

		lea		(csd_RememberKey,a5),a0
		move.l		#256,d0
		jsr		(_LVOdsAllocCPremember,a6)
		move.l		d0,(ArgPointers).l
		beq		fail

		lea		(csd_Args,a5),a0
		lea		(additionalHelp,pc),a1
		lea		(ArgPointers+4,pc),a2
		lea		(CmdTemplate,pc),a3
		jsr		(_LVOdsParse,a6)
		bpl.b		configure
		movea.l		(ArgPointers,pc),a1
		jsr		(_LVOdsPuts,a6)
		bra		fail

	; --- do it

configure:	move.l		(csd_Output,a5),d1
		beq.b		fail
		move.l		#ClearString,d2
		moveq		#1,d3
		jsr		(_LVOdsDosWrite,a6)

		move.l		(rowNum,pc),d0
		beq.b		2$
		movea.l		d0,a0
		jsr		(_LVOdsGetDecimal,a6)
		beq.b		fail
		move.l		d0,d4
		move.l		#LfString,d2
		bra.b		1$
..		jsr		(_LVOdsDosWrite,a6)
1$		dbra		d4,..

2$		movea.l		a6,a1
		movea.l		(_AbsExecBase).w,a6
		jsr		(_LVOCloseLibrary,a6)
		moveq		#RETURN_OK,d0
		rts


fail:		movea.l		a6,a1
		movea.l		(_AbsExecBase).w,a6
		jsr		(_LVOCloseLibrary,a6)
		moveq		#RETURN_ERROR,d0		;fail by default
		rts


***************************************
***************************************
***************************************


ArgPointers:	dl	0
rowNum:		dl	0		;pointer to filename


CmdTemplate:
	db	'NUM/K',0


additionalHelp:
	db	'USAGE:',Lf
	cstr	'ClrScn [NUM]'


***************************************
***************************************
***************************************


supportLibName:
	db	'digisoftSupport.library',0


ClearString:
	db	$0c

LfString:
	db	Lf


*******************************************************************************

	END
