
**	CODE	ELLIPSE'S
**	CODER	MARC.B




	incdir		sys:include/
	
	include		intuition/intuition.i
	include		intuition/intuition_lib.i
	include		exec/exec.i
	include		exec/exec_lib.i
	include		source:include/hardware.i
	include		graphics/gfx.i
	include		graphics/graphics_lib.i

	
************************************
*	OPEN INTUITION LIBRARY	   *
************************************

	lea		int_name,a1
	moveq		#0,d0
	CALLEXEC	OldOpenLibrary
	tst		d0
	beq		the_end
	move.l		d0,_IntuitionBase

************************************
*	OPEN GRAPHICS LIBRARY	   *
************************************

	lea		gfx_name,a1
	moveq		#0,d0
	CALLEXEC	OldOpenLibrary
	tst		d0
	beq		exit
	move.l		d0,_GfxBase

***************************************
*		OPEN WINDOW	      *
***************************************

	lea		window_main,a0
	CALLINT		OpenWindow
	tst		d0
	beq		exit
	move.l		d0,window_handle
	move.l		d0,a0	
	move.l		wd_UserPort(a0),window.up
	move.l		wd_RPort(a0),window.rp
	

****************************************
*	MAIN CODE LOOP		       *
****************************************

	
	
	bsr		ellipse_setup

****************************************
*	MOUSE BUTTON LOOP	       *
****************************************

loop
	
	btst		#6,CIAAPRA
	bne		loop

***************************************** 
*	   CLOSE WINDOW			*
*****************************************

close
	move.l		window_handle,a0
	CALLINT		CloseWindow
	

*****************************************
*		CLOSE INTUITION		*
*****************************************

	move.l		_GfxBase,a1
	CALLEXEC	CloseLibrary
exit
	
	move.l		_IntuitionBase,a1
	CALLEXEC	CloseLibrary

the_end
	rts

*************************************
*	DRAWING ROUTINES	    *
*************************************

ellipse_setup

	lea		ellipse_data,a0
	move.b		#(data_length/2)-1,d4

;this routine reads co_ords from the table in a0
;draws ellipse's to form a pattern the length of the table
;is in d4 and the routine loops until d4 is 0 it then
;exits into the mouse button loop

draw_ellipse

	clr.l		d2
	clr.l		d3
	move.b		(a0)+,d2
	move.b		(a0)+,d3	
	movem.l		d0-d7/a0-a6,-(sp)
	move.l		window.rp,a1
	move.l		#320,d0
	move.l		#120,d1
	CALLGRAF	DrawEllipse
	movem.l		(sp)+,d0-d7/a0-a6
	dbra		d4,draw_ellipse
	rts

*****************************************
*	    CODE DATA SECTION		*
*****************************************


window_main
	dc.w	0,0,640,250
	dc.b	1,0
	dc.l	GADGETUP!GADGETDOWN
	dc.l	ACTIVATE
	dc.l  	0,0,title,0,0
	dc.w	80,24,-1,-1,WBENCHSCREEN
title	dc.b	'  ELLIPSE..................',0
	even


ellipse_data
		
		dc.b	80,60,60,70,40,80,20,90,5,100
		dc.b	70,65,50,75,30,85,10,95
		dc.b	200,5,180,10,170,15,160,20,150,25,140,30
		dc.b	130,35,120,40,110,45,100,50,200,100
		dc.b	180,90,160,80,140,70,120,60,100,50
data_end

data_length	equ	data_end-ellipse_data
	even

***************************************
*	CODE VARIABLES		      *
***************************************

_IntuitionBase	dc.l 0
_GfxBase	dc.l 0
window_handle	dc.l 0
window.up	dc.l 0
window.rp	dc.l 0
colour		dc.w 0
prefbuffer	ds.b 232


int_name	dc.b 'intuition.library',0
gfx_name	dc.b 'graphics.library',0	
end

