	section	lard,code
	opt	c-
	opt	d+
	
code:	IncDir	"DH0:Include/"
	Include	Intuition/Intuition.I
	Include	Intuition/Intuition_Lib.I
	Include	Libraries/dos_LIb.i
	Include	Libraries/Dos.i
	Include	Exec/Exec_Lib.I
	Include	Exec/Exec.I
	Include	Exec/ExecBase.I
	Include	Graphics/GfxBase.I
	Include	Graphics/Graphics_Lib.I
	Include	Graphics/Display.I
	;Include	Misc/EasyStart.i

	Lea	GFXName,A1
	Moveq	#0,D0
	CALLEXEC	OpenLibrary
	Move.l 	D0,_GfxBase
	Beq	Error

	Lea	DosName,A1
	Moveq	#0,D0
	CALLEXEC	OpenLibrary
	Move.l 	D0,_DOSBase
	Beq	Error

	Lea	IntName,A1
	Moveq	#0,D0
	CALLEXEC	OpenLibrary
	Move.l	D0,_IntuitionBase
	Beq	Error

	*-----------------------------------------------*

	Lea	MyScreen,a0
	CALLINT	OpenScreen
	Move.l	D0,_MyScrBase
	Beq	CloseInt

	Lea	MyWindow,a0
	move.l	_MyScrBase,nw_Screen(a0)
	CALLINT	OpenWindow
	Move.l	D0,_MyWinBase
	Beq	CloseInt
	Move.l	D0,A0
	Move.l	wd_RPort(A0),_MyWinRPort
	Move.l	wd_UserPort(a0),_MyWinUserPort

	*-----------------------------------------------*

.WaitLoop	Move.l	_MyWinUserPort,A0
	CALLEXEC	WaitPort
	Move.l	_MyWinUserPort,A0
	CALLEXEC	GetMsg
	Move.l	D0,A1
	Move.l	im_Class(A1),D2	;D2=IDCMP Flags Directly
	Move.w	im_Code(A1),D3	;D3=Data ie key why class=Rawkey
	Move.w	im_Qualifier(A1),D4	;D4=things like CTRL SHIFT
	Move.w	im_MouseX(a1),D5	;D5=MouseX Coordinate
	Move.w	im_MouseY(a1),D6	;D5=MouseY Coordinate
	Move.l	im_IAddress(A1),D7	;D7=Addres of Intuition Obj ie Gadget
	Movem.l	D0-D7/A0-A6,-(A7)	
	CALLEXEC	ReplyMsg
	Movem.l	(a7)+,D0-D7/A0-A6

	Cmp.l	#MOUSEBUTTONS,D2
	bne	.nomouse

	;move.w	$dff006,$dff180

.nomouse	Cmp.l	#CLOSEWINDOW,D2
	bne	.WaitLoop
	
.Exit	Move.l	_MyWinBase,A0
	CALLINT	CloseWindow

	Move.l	_MyScrBase,A0
	CALLINT	CloseScreen

	*-------------------------------*
	
CloseInt	Move.l	_IntuitionBase,A1
	CALLEXEC	CloseLibrary

	Move.l	_DOSBase,A1
	CALLEXEC	CloseLibrary

	Move.l	_GfxBase,A1
	CALLEXEC	CloseLibrary

	*-------------------------------*

Error	Moveq	#0,D0
	Rts

	*-------------------------------*

_MyScrBase		Dc.l	0

_MyWinBase		Dc.l	0
_MyWinRPort		Dc.l	0
_MyWinUserPort	Dc.l	0
_MyWinVPort		Dc.l	0

_IntuitionBase	Dc.l	0
_DOSBase		Dc.l	0
_GfxBase		dc.l	0

GFXName		GRAFNAME
IntName		INTNAME
DosName		DOSNAME
		even

	*********************************************
MyWindow:	
	dc.w	70,15
	dc.w	200,156
	dc.b	0,1
	dc.l	CLOSEWINDOW+MOUSEBUTTONS
	dc.l	WINDOWCLOSE+ACTIVATE+RMBTRAP+NOCAREREFRESH
	dc.l	0
	dc.l	0
	dc.l	SymbolWindowName
	dc.l	0
	dc.l	0
	dc.w	5,5
	dc.w	-1,-1
	dc.w	CUSTOMSCREEN
SymbolWindowName:
	dc.b	'Select Symbol',0
	cnop 0,2

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

MyScreen:	dc.w	0,0		;screen XY origin relative to View
	dc.w	320,200		;screen width and height
	dc.w	0		;screen depth (number of bitplanes)
	dc.b	0,0		;detail and block pens
	dc.w	0		;display modes for this screen
	dc.w	CUSTOMSCREEN+CUSTOMBITMAP+SCREENQUIET         	
				;screen type
	dc.l	0		;pointer to default screen font
	dc.l	0		;screen title
	dc.l	0		;first in list of custom screen gadgets
	dc.l	MyBitMap		;pointer to custom BitMap structure

MyBitMap:	dc.w	40		;bm_BytesPerRow (.w)
	dc.w	200		;bm_Rows (.w)
	dc.b	0		;bm_Flags (.b)
	dc.b	4		;bm_Depth (.b)
	dc.w	0		;bm_Pad (.w)
	dc.l	Scr+(0*40*256)	;bm_Planes (.l) 1
	dc.l	Scr+(1*40*256)	;bm_Planes (.l) 2
	dc.l	Scr+(2*40*256)	;bm_Planes (.l) 3
	dc.l	Scr+(3*40*256)	;bm_Planes (.l) 4
	dc.l	Scr+(4*40*256)	;bm_Planes (.l) 5
	dc.l	Scr+(5*40*256)	;bm_Planes (.l) 6
	dc.l	Scr+(6*40*256)	;bm_Planes (.l) 7
	dc.l	Scr+(7*40*256)	;bm_Planes (.l) 8
	
	
	section	chipmem,data_c
	
scr:	ds.l	20*200*3

	end


