	section	FastEcho,CODE
	IDNT	QUERY

**	FastEcho
**		for outputting text to the screen (fast because it's small)
**
**		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
**
**	FastEcho STRING
**
**  KEYWORDS
**
**	STRING	optional keyword for string
**
**  NOTES
;	Escape characters may be used if preceeded with a \ character.
;	FastEcho currently recognizes the following special characters:
;
;	N   - newline
;	T   - horizontal tab
;	V   - vertical tab
;	B   - backspace
;	R   - return
;	F   - formfeed
;	E   - escape (ascii 27 decimal)
;	Xnn - character represented by hex value nn.
;
;	The above may be either upper or lower case.  If FastEcho finds
;	an escaped character which is not one of the above, it will return
;	the character value (i.e. '\A' will be replaced by the single
;	character 'A'. The sequence '\\' is replaced by the single
;	character '\', and so on.)
;
***********************************************************



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

	;	PALL
	;	HALL
	;	LFCOND
		EXEOBJ
	;	LIST
	;	LISTSYMS
	;	ADDSYM
	;	LISTFILE	"ram:FastEcho.lst"
	;	CREFFILE	"ram:FastEcho.cref"
	;	EQUFILE		"ram:FastEcho.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_FAIL		equ	20
	endc


_LVOdsAllocCPremember	equ	-30
_LVOdsAllocScratch	equ	-42
_LVOdsClearRemember	equ	-66
_LVOdsDosWrite		equ	-864
_LVOdsEscapeString	equ	-624
_LVOdsParse		equ	-216
_LVOdsPuts		equ	-648


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


		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
		moveq		#RETURN_FAIL,d5
		move.l		a0,d6
		move.l		d0,d7
		movea.l		(_AbsExecBase).w,a6	;establish exec for calls

	; --- open the support library

		moveq		#5,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		exit

	; --- initialize the scratch area

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

	; --- 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		exit

		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		exit

	; --- do it

configure:	move.l		(string,pc),d0
		beq.b		exit
		movea.l		d0,a0
		jsr		(_LVOdsEscapeString,a6)
		move.l		d0,d3
		beq.b		exit
		move.l		a0,d2
		move.l		(csd_Output,a5),d1
		jsr		(_LVOdsDosWrite,a6)
		moveq		#RETURN_OK,d5

exit:		lea		(csd_RememberKey,a5),a0
		jsr		(_LVOdsClearRemember,a6)
		movea.l		a6,a1
		movea.l		(_AbsExecBase).w,a6
		jsr		(_LVOCloseLibrary,a6)
		move.l		d5,d0
		rts


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


ArgPointers:	dl	0
string:		dl	0		;pointer to string


CmdTemplate:
	cstr	'STRING'


additionalHelp:
	db	'USAGE:',Lf
	cstr	'FastEcho <STRING>'


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


supportLibName:
	cstr	'digisoftSupport.library'


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

	END
