* window2

* In diesen Files stecken diverse Deklarationen und Makros.
* Schauen Sie mal rein!

	incdir	":include/"

	include	intuition/intuition.i
	include	intuition/intuition_lib.i
	include	exec/exec_lib.i
	include	graphics/graphics_lib.i


* Intuition Library oeffnen:
* --------------------------
	lea	intname,a1                 
	moveq	#0,d0		
	CALLEXEC OpenLibrary
	tst.l	d0
	beq	abbruch	
	move.l	d0,_IntuitionBase    ;Basis-Zeiger sichern	

* Ggraphics Library oeffnen
* -------------------------
	lea	grafname,a1
	moveq	#0,d0
	CALLEXEC OpenLibrary
	tst.l	d0
	beq	closeint
	move.l	d0,_GfxBase          ;Basis-Zeiger sichern


* Window oeffnen
* --------------
	jsr     InitWindow           ;initialisiere NewWindow

	lea	NewWindow,a0 	     ;zeige auf Window-Struktur
	CALLINT	OpenWindow	     ;oeffne Window
	tst.l	d0 		     ;ging was schief?
	beq	closegraf	     ;wenn ja		
	move.l	d0,windowptr	     ;Window-Zeiger sichern


* Text im Fenster zeichnen
* ------------------------
	moveq	#100,d0		     ;X-Position
	moveq	#50,d1		     ;Y
	move.l	windowptr,a1	     ;Via Window-Zeiger
	move.l	wd_RPort(a1),a1	     ;  Rast-Port-Adresse holen
	CALLGRAF Move                ;Funtion Move to X,Y

	move.l	windowptr,a1         ;brauche wieder Rastport
	move.l	wd_RPort(a1),a1
	lea	msg,a0	             ;Adresse Text
	moveq	#msglen,d0           ;seine Laenge
	CALLGRAF Text                ;und ausgeben

* Auf Event warten (kann hier nur WINDOWCLOSE sein)
* -------------------------------------------------
        move.l	windowptr,a0         ;zeige auf Window-Struktur
	move.l	wd_UserPort(a0),a0   ;nun auf Message-Port
	move.b	MP_SIGBIT(a0),d1     ;Anzahl Signal Bits -> d1
	moveq.l	#1,d0                ;in Maske
	lsl.l	d1,d0	             ;       konvertieren
	CALLEXEC Wait                ;Schlaf gut!


* Fenster schliessen
* ------------------
	move.l	windowptr,a0         ;wir sind wieder wach
	CALLINT	CloseWindow	     ;Fenster zu


* Libraries schliessen
* --------------------
closegraf
	move.l	_GfxBase,a1
	CALLEXEC CloseLibrary

closeint
	move.l	_IntuitionBase,a1
	CALLEXEC CloseLibrary

abbruch
	move.l	#0,d0               ;oder normales Ende
	rts

W_Gadgets equ   WINDOWSIZING!WINDOWDRAG!WINDOWDEPTH!WINDOWCLOSE
W_Extras  equ   SMART_REFRESH!ACTIVATE

W_Title dc.b    'Fenster-Titel',0

***************************************************************
NewWindow	ds.b	nw_SIZE	    ;Puffer f. Windowstruktur *
***************************************************************

InitWindow
	lea	NewWindow,a0	        ;Fuelle Struktur
	move.w	#200,nw_LeftEdge(a0)
	move.w	#50,nw_TopEdge(a0)
	move.w	#300,nw_Width(a0)
	move.w	#100,nw_Height(a0)
	move.b	#0,nw_DetailPen(a0)
	move.b	#1,nw_BlockPen(a0)
	move.l	#W_Title,nw_Title(a0)
	move.l	#W_Gadgets!W_Extras,nw_Flags(a0)
	move.l	#CLOSEWINDOW,nw_IDCMPFlags(a0)
	clr.l	nw_FirstGadget(a0)
	clr.l	nw_CheckMark(a0)
	clr.l	nw_Screen(a0)			
	clr.l	nw_BitMap(a0)
	move.w	#100,nw_MinWidth(a0)
	move.w	#20,nw_MinHeight(a0)
	move.w	#640,nw_MaxWidth(a0)
	move.w	#200,nw_MaxHeight(a0)
	move.w	#WBENCHSCREEN,nw_Type(a0)
	rts

intname		INTNAME		    ;Name Intuition Lib (via Makro)
grafname	GRAFNAME	    ;Name Graphics Lib

                
msg	        dc.b	'Hello, World! '
msglen	        equ	*-msg

_IntuitionBase	ds.l	1	   ;Speicher fuer Zeiger	
_GfxBase	ds.l	1	
windowptr	ds.l	1	

