; -------------------------------------------------------------------
; Demoprogramm mit Beispiel zur Nutzung der phobos.library
; Sourcecode mit ASM-ONE geschrieben
; phobos.library Copyright 1991 bei DR. KRALLE/TIME-LIGHT
; -------------------------------------------------------------------

	incdir	dh0:asm/include/
	include	exec/exec_lib.i
	incdir	dh0:comp/phobos/lib_asm/
	include	lib_func.i

ExecBase = 4

	moveq	#0,d0
	move.b	(a0),d0
	sub.b	#'0',d0
	move.l	d0,portnum

; ----- phobos.library öffnen
	move.l	ExecBase,a6
	lea	LibName,a1
	jsr	_LVOOpenLibrary(a6)
	move.l	d0,LibBase
	beq.s	LibNotFound

; ----- Verbindung zu Phobos herstellen
	move.l	LibBase,a6
	move.l	portnum,d0
	jsr	OpenPhobos(a6)
	move.l	d0,Phobos

; ----- TestText ausgeben (Text muß mit 0 abschließen)
	move.l	LibBase,a6	; Library Basis
	lea	TestText,a1	; Adresse Ausgabetext
	moveq	#10,d0		; X-Position
	moveq	#10,d1		; Y-Position
	move.l	Phobos,a0
	jsr	PrintAt(a6)	; Lib-Funktion aufrufen

; ----- TestText ausgeben (Text muß mit 0 abschließen)
	move.l	LibBase,a6	; Library Basis
	lea	TestText1,a1	; Adresse Ausgabetext
	moveq	#10,d0		; X-Position
	moveq	#12,d1		; Y-Position
	move.l	Phobos,a0
	jsr	PrintAt(a6)	; Lib-Funktion aufrufen

; ----- Auf Taste Escape warten oder bis Gadget RAUS DA! gedrückt wird
Warten:	move.l	LibBase,a6
	move.l	Phobos,a0
	jsr	ChSer(a6)
	cmp.b	#27,d0		; Gedrückte Taste = Escape ?
	beq.s	Escape		; ja, Ende
	move.l	Phobos,a0
	jsr	GetCarrier(a6)	; Carrierzustand holen
	tst.b	d0		; D0 = TRUE?
	bne.s	Warten		; ja, dann Carrier noch da
; ----- Hier gehts weiter, wenn Carrier weg ist oder ESC gedrückt wurde
Escape:

; ----- Verbindung zu Phobos trennen
	move.l	LibBase,a6
	move.l	Phobos,a0
	jsr	ClosePhobos(a6)

; ----- phobos.library wieder schließen
	move.l	ExecBase,a6
	move.l	LibBase,a1
	jsr	_LVOCloseLibrary(a6)
LibNotFound:
	rts


Phobos:		dc.l	0
LibBase:	dc.l	0
portnum:	dc.l	0
LibName:	dc.b	"phobos.library",0
TestText:	dc.b	"[34mDieser Text wurde mit der Funktion"
		dc.b	" PrintAt() geschrieben[0m",0
TestText1:	dc.b	"[35mBitte ESC oder Gadget RAUS DA! drücken[0m",0
