
;structure example


	include	"baselibs.i"
	include	"intuition.i"
	include	"baseintuition.i"
	include	"basegfx.i"



	#define		IDCMPflags,NEWSIZE|REFRESHWINDOW|MOUSEBUTTONS|CLOSEWINDOW|VANILLAKEY
	#define		flags,WINDOWSIZING|WINDOWDRAG|WINDOWCLOSE|ACTIVATE



	DATAAREA
	{
		structset	myscreen
		{
		sw	0
		sw	0	;ns_TopEdge
		sw	320	;ns_Width
		sw	256	;ns_Height
		sw	3	;ns_Depth
		sb	1	;ns_DetailPen
		sb	3	;ns_BlockPen
		sw	$40	;ns_ViewModes
		sw	15	;ns_Type
		sl	0	;ns_Font
		sl	0	;ns_DefaultTitle
		sl	0	;ns_Gadgets
		sl	64	;ns_CustomBitMap
		}
		structset	mywindow
		{
		sw	0	;nw_LeftEdge
		sw	0	;nw_TopEdge
		sw	310	;nw_Width
		sw	240	;nw_Height
		sb	1	;nw_DetailPen
		sb	3	;nw_BlockPen
		sl	IDCMPflags	;nw_IDCMPFlags
		sl	flags		;nw_Flags
		sl	0	;nw_FirstGadget
		sl	0	;nw_CheckMark
		sl	0	;nw_Title
		sl	0	;nw_Screen
		sl	0	;nw_BitMap
		sw	200	;nw_MinWidth
		sw	200	;nw_MinHeight
		sw	320	;nw_MaxWidth
		sw	256	;nw_MaxHeight
		sw	15	;nw_Type
		}
		structset	tmpras,tr_SIZEOF

		structset	areainfo,ai_SIZEOF
	}


	variables

	CPTR	_IntuitionBase
	CPTR	_GfxBase
	array	char,areabuffer,400
	
	main()

	CPTR	rp
	CPTR	screenl
	CPTR	windowl
	{
	

		func	_IntuitionBase,=,openlibrary,"intuition.library",0
		if	_IntuitionBase,!=,0,1
		{
			func	_GfxBase,=,openlibrary,"graphics.library",0
			if	_GfxBase,!=,0,2
			{
				func	screenl,=,openscreen,myscreen
				if	screenl,!=,0,3
				{
					structput	mywindow,.,nw_Screen,=,screenl
					func	windowl,=,openwindow,mywindow
					if	windowl,!=,0,4
					{
						structput	rp,=,windowl,->,wd_RPort
						ROUTINE	draw,rp,windowl
					}
					ifend	4
					closewindow	windowl
				}
				ifend	3
				closescreen	screenl
			}
			ifend	2
			closelibrary	_GfxBase
		}
		ifend	1
		closelibrary	_IntuitionBase
	}

;draw graphic into a window

		VOID	draw,rp,windowl
	
		
		CPTR	rp,windowl
		CPTR	planePtr
		short	width,height
		CPTR	_areabuffer
		CPTR	_areainfo
		CPTR	_tmpras
		int		xa,ya
		int		count	

		{
			pointer	_areabuffer,=&,areabuffer
			pointer	_areainfo,=&,areainfo
			pointer	_tmpras,=&,tmpras
			calc	width,=,320
			calc	height,=,256
			calc	xa,=,100
			calc	ya,=,100

			
			
				func	planePtr,=,AllocRaster,width,height
				
				InitArea	_areainfo,_areabuffer,80
				structput	rp,->,rp_AreaInfo,=,_areainfo

				InitTmpRas	tmpras,planePtr,width,height
				structput	rp,->,rp_TmpRas,=,_tmpras

				SetRast		rp,0

				calc	count,=,0
				while	count,!=,10,1
				{
				SetAPen		rp,4
				setopen		rp,3
				areamove		rp,50,140
				areaDraw		rp,xa,ya
				areaDraw		rp,150,140
				areaDraw		rp,100,180
				areaend			rp

				setapen		rp,5
				areamove	rp,50,70
				areadraw	rp,100,20
				areadraw	rp,xa,ya
				areadraw	rp,50,140
				areaend		rp

				setapen		rp,6
				areamove	rp,xa,ya
				areadraw	rp,100,20
				areadraw	rp,150,70
				areadraw	rp,150,140
				areaend		rp

				calc	xa,=,xa,+,4
				calc	ya,=,ya,-,4
				calc	count,++
				}	1

				FreeRaster	planePtr,width,height
				GetIntuiMsg	windowl
		
		}
		
	end