* $Revision Header * Header built automatically - do not edit! *************
*
*	(C) Copyright 1991 by Olaf 'Olsen' Barthel & MXM
*
*	Name .....: DPrintf.asm
*	Created ..: Thursday 19-Sep-91 17:49
*	Revision .: 1
*
*	Date            Author          Comment
*	=========       ========        ====================
*	19-Sep-91       Olsen           Created this file!
*
* $Revision Header *********************************************************

	include	"exec/types.i"
	include	"exec/ports.i"
	include	"exec/memory.i"

CALL	macro
	xref	_LVO\1
	jsr	_LVO\1(a6)
	endm

Args	equ	5*4+4
VarArgs	equ	Args+4

	csect	text,0,0,1,2

*--------------------------------------------------------------------------
*
*	This file replaces a bunch of routines originally residing
*	in termInit.c, note that the following routine interfaces
*	to a tool called `FarPortII' which is not included with the
*	`term' distribution.
*
*--------------------------------------------------------------------------

	xdef	_DPrintf

_DPrintf:
	movem.l	a2-a6,-(sp)

	move.l	4,a6

	lea	PortName(pc),a1			; FindPort("FarPort")
	CALL	FindPort
	tst.l	d0				; Success?
	beq	exit

	move.l	d0,a4				; Save port address

	move.l	#MN_SIZE+256,d0			; Allocate message body
	move.l	#MEMF_PUBLIC+MEMF_CLEAR,d1
	CALL	AllocMem

	tst.l	d0				; Success
	beq	exit

	move.l	d0,a5				; Save message
	move.w	#MN_SIZE+256,MN_LENGTH(a5)	; Fill in message data
	add.w	#MN_SIZE,d0
	move.l	d0,LN_NAME(a5)			; Fill in the name
	move.l	d0,a3				; Set up for sprintf call
	move.l	Args(sp),a0
	lea	VarArgs(sp),a1
	lea	stuffchar(pc),a2

	CALL	RawDoFmt

	move.l	a4,a0				; Get back port
	move.l	a5,a1				; Get back message

	CALL	PutMsg				; And post it...

exit	movem.l	(sp)+,a2-a6
	rts

stuffchar:
	move.b	d0,(a3)+
	rts

PortName:
	dc.b	'FarPort',0

	end
