;
; Simple version of the C "sprintf" function.  Assumes C-style
; stack-based function conventions.
;
;   long eyecount;
;   eyecount=2;
;   sprintf(string,"%s have %ld eyes.","Fish",eyecount);
;
; would produce "Fish have 2 eyes." in the string buffer.
;
	xdef _SPrintf
	xdef _VSPrintf
	xref _AbsExecBase
	xref _LVORawDoFmt

	section SprintfCode,code

_SPrintf       ; ( ostring, format, {values} )
	   movem.l a2/a3/a6,-(sp)

	   move.l  16(sp),a3       ;Get the output string pointer
	   move.l  20(sp),a0       ;Get the FormatString pointer
	   lea.l   24(sp),a1       ;Get the pointer to the DataStream
SPrintfEntry
	   lea.l   stuffChar,a2
;           lea.l   stuffChar(pc),a2
	   move.l  _AbsExecBase,a6
	   jsr     _LVORawDoFmt(a6)

	   movem.l (sp)+,a2/a3/a6
	   rts

_VSPrintf      ; ( ostring, format, pointer to values )
	   movem.l a2/a3/a6,-(sp)

	   move.l  16(sp),a3       ;Get the output string pointer
	   move.l  20(sp),a0       ;Get the FormatString pointer
	   move.l  24(sp),a1       ;Get the address from the first element
	   bra     SPrintfEntry
;           bra     SPrintfEntry(pc)

;------ PutChProc function used by RawDoFmt -----------
stuffChar  move.b  d0,(a3)+        ;Put data to output string
	   rts

