
	opt	o+,ow-	get the most out of Devpac
	bra	_START	branch to routine startup code

;****************************************************************
;*  This program traces two sine curves in  diffirent colour.   *
;* It uses a table of sine values 'borrowed' from a routine     *
;* written by Marcus Lynn (Shadow) for Amiga Computing. Cheers  *
;* Marcus, thats a lot of keyboard bashing. This program WILL   *
;* run from the Workbench if you give it an icon.               *
;*  Press the left mouse button when you get bored of it        *
;*                                                              *
;*		MARK, 2.2.1990                 *
;*                                                              *
;****************************************************************

WIN	equ	1	Intuition window include
GFX	EQU	1	Graphics include

	incdir	"source_2:includes/"
	include	"header.asm"

MAIN	MAKEWIN	#TITLE,100,40,370,130,QUIT open a intuition window
	MOVE.L	D0,WINDOW	save handle
	MOVE.L	D0,A0	A0-->handle
	MOVE.L	WW.RPORT(A0),RP	RP-->windows rastport

	MOVE.L	#16384,D5
	MOVE.L	#55,D4
DOLOOP	LEA	CURVE0,A0
	MOVE.L	#-40,D6
	BSR	PLOTPIX
	LEA	CURVE1,A0
	BSR	PLOTPIX
	LEA	CURVE2,A0
	MOVE.L	#40,D6
	BSR	PLOTPIX
	LEA	CURVE3,A0
	BSR	PLOTPIX
	BTST	#6,$BFE001
	BNE	DOLOOP
			
	MOVEA.L	WINDOW,A0	get handle of our window
	INTLIB	CLOSEWINDOW	and close it
QUIT	RTS		now leave
	
PLOTPIX	MOVE.W	(A0)+,D0
	PUSHREG	D0
	BSR	GETSIN
	MULS	D6,D1
	DIVS	D5,D1
	ADD.W	D4,D1
	MOVE.W	(A0),D2
	SETAPEN	RP,D2
	PULLREG	D0
	DRAWPOINT	RP,D0,D1
	ADDI.W	#1,D0
	CMPI.W	#361,D0
	BNE	OKK
	MOVEQ.L	#0,D0
OKK	SUBA.L	#2,A0
	MOVE.W	D0,(A0)
	RTS
	
	
;**************************************************
;*	Get Sin Value for Angle in d0     *	
;**************************************************
	
GETSIN:	MOVE.L 	#SINTAB,A1	A1-->sine table
	TST 	D0	is angle -ve
	BPL 	SIN1	if not dont worry
	ADD 	#360,D0	otherwise shift it
SIN1:	LSL 	#1,D0	table entries are words
	MOVE 	(A1,D0),D1	fetch sine D0 into D1
	RTS		and return

;****************************************************************
;*	Data for Sintable		*
;*				*
;*	As using Floating Poi4nt Numbers would	*
;*	Be Tooooo Slow for the Computer to	*
;*	attain a suitable frame rate the values	*
;*	are first all multiplied by 16384	*
;*	which just happens to be 14 shifts	*
;*	left  (very helpfull) which gets	*
;*	rid of the decimal point and then	*
;*	when multiplied with X or Y are then	*
;*	Divided by 16384 (14 shifts right)	*
;*		Using this technique fast	*
;*	3d graphics are be possible.		*
;*				*
;****************************************************************

SINTAB:	DC.W 0,286,572,857,1143,1428,1713,1997,2280
	DC.W 2563,2845,3126,3406,3686,3964,4240,4516
	DC.W 4790,5063,5334,5604,5872,6138,6402,6664
	DC.W 6924,7182,7438,7692,7943,8192,8438,8682	
	DC.W 8923,9162,9397,9630,9860,10087,10311,10531
	DC.W 10749,10963,11174,11381,11585,11786,11982,12176
	DC.W 12365,12551,12733,12911,13085,13255,13421,13583
	DC.W 13741,13894,14044,14189,14330,14466,14598,14726
	DC.W 14849,14968,15082,15191,15296,15396,15491,15582
	DC.W 15668,15749,15826,15897,15964,16026,16083,16135
	DC.W 16182,16225,16262,16294,16322,16344,16362,16374
	DC.W 16382,16384
	DC.W 16382
	DC.W 16374,16362,16344,16322,16294,16262,16225,16182
	DC.W 16135,16083,16026,15964,15897,15826,15749,15668	
	DC.W 15582,15491,15396,15296,15191,15082,14967,14849
	DC.W 14726,14598,14466,14330,14189,14044,13894,13741	
	DC.W 13583,13421,13255,13085,12911,12733,12551,12365
	DC.W 12176,11982,11786,11585,11381,11174,10963,10749
	DC.W 10531,10311,10087,9860,9630,9397,9162,8923
	DC.W 8682,8438,8192,7943,7692,7438,7182,6924
	DC.W 6664,6402,6138,5872,5604,5334,5063,4790
	DC.W 4516,4240,3964,3686,3406,3126,2845,2563
	DC.W 2280,1997,1713,1428,1143,857,572,286,0
	DC.W -286,-572,-857,-1143,-1428,-1713,-1997,-2280
	DC.W -2563,-2845,-3126,-3406,-3686,-3964,-4240,-4516
	DC.W -4790,-5063,-5334,-5604,-5872,-6138,-6402,-6664
	DC.W -6924,-7182,-7438,-7692,-7943,-8192,-8438,-8682	
	DC.W -8923,-9162,-9397,-9630,-9860,-10087,-10311,-10531
	DC.W -10749,-10963,-11174,-11381,-11585,-11786,-11982,-12176
	DC.W -12365,-12551,-12733,-12911,-13085,-13255,-13421,-13583
	DC.W -13741,-13894,-14044,-14189,-14330,-14466,-14598,-14726
	DC.W -14849,-14968,-15082,-15191,-15296,-15396,-15491,-15582
	DC.W -15668,-15749,-15826,-15897,-15964,-16026,-16083,-16135
	DC.W -16182,-16225,-16262,-16294,-16322,-16344,-16362,-16374
	DC.W -16382,-16384
	DC.W -16382
	DC.W -16374,-16362,-16344,-16322,-16294,-16262,-16225,-16182
	DC.W -16135,-16083,-16026,-15964,-15897,-15826,-15749,-15668	
	DC.W -15582,-15491,-15396,-15296,-15191,-15082,-14967,-14849
	DC.W -14726,-14598,-14466,-14330,-14189,-14044,-13894,-13741	
	DC.W -13583,-13421,-13255,-13085,-12911,-12733,-12551,-12365
	DC.W -12176,-11982,-11786,-11585,-11381,-11174,-10963,-10749
	DC.W -10531,-10311,-10087,-9860,-9630,-9397,-9162,-8923
	DC.W -8682,-8438,-8192,-7943,-7692,-7438,-7182,-6924
	DC.W -6664,-6402,-6138,-5872,-5604,-5334,-5063,-4790
	DC.W -4516,-4240,-3964,-3686,-3406,-3126,-2845,-2563
	DC.W -2280,-1997,-1713,-1428,-1143,-857,-572,-286,0

TITLE	DC.B 'SINE TRACE',0
	EVEN
WINDOW	DC.L 0
RP	DC.L 0

CURVE0	DC.W 0
COLOUR0	DC.W 0
CURVE1	DC.W 30
COLOUR1	DC.W 1
CURVE2	DC.W 0
COLOUR2	DC.W 0
CURVE3	DC.W 30
COLOUR3	DC.W 3
