*************************************************************************
*
*	FTrans.asm - A demonstration of accessing the MC68881 math chip
*		    on MicroBotics MFM module installed in a StarBoard2
*		    from assembly language using the new support libraries,
*		    mathieeedoubbas.library, mathieeedoubtrans.library,
*		    and io68881.library.  Written for the Manx Assembler.
*
*	Author - David Milligan	, Integrated Systems, Inc.,
*		  		  for MicroBotics, Inc.
*
*	Copyright (C) 1987 by MicroBotics, Inc. and David Milligan.
*	All rights reserved. Permission is granted to reproduce and
*	redistribute on a strictly non-profit basis provided all.
*	copyright messages and source comments remain intact.
*
*
*	8-29-87	-  The program has no external variable input at present,
*		   with the values being hardcoded in place. This WILL
*		   change shortly.
*
*************************************************************************

		include "exec/types.i"
		include	"libraries/mathieeedoubbas_lib.i"
		include	"libraries/mathieeedoubtrans_lib.i"
		include "intuition/intuition.i"

XLIB		MACRO		* Macro used to reference external system
		XREF	_LVO\1	* functions and make the code more readable.
		ENDM

XCALL		MACRO		* Macro used to call system routines
		jsr	_LVO\1	* and make the code more readable.
		ENDM

	DSEG
******************************* equates *******************************

SysBase	equ	4		* Single hard address in the amiga
INTUITION	equ	$00000001
GRAPHICS	equ	$00000002
SCREEN	equ		$00000004
WINDOW	equ		$00000008
MIDB	equ		$00000010
MIDT	equ		$00000020

NW_IDCMP	equ	MOUSEBUTTONS!GADGETDOWN!GADGETUP!CLOSEWINDOW
NW_FLAGS	equ	BORDERLESS!BACKDROP!ACTIVATE!WINDOWCLOSE

TRUE	equ	1		* Boolean flags
FALSE	equ	0
NULL	equ	$0000
CX	equ	320		* X-offset used in plotting
CY	equ	200		* Y-offset used in plotting
XTWEAK	equ	170
YTWEAK	equ	140
ROT	equ	$0001
VX	equ	$0002
VY	equ	$0003
WHOA	equ	$0004
GO	equ	$0005
NUMGADS	equ	5
BOOLAFLAGS	equ	RELVERIFY!GADGIMMEDIATE
STRAFLAGS	equ	RELVERIFY!GADGIMMEDIATE!STRINGCENTER
GADL_EDGE	equ	5
GADT_EDGE	equ	30

	CSEG

************************ external system calls ************************
**** exec.library ****
	XLIB	OpenLibrary
	XLIB	CloseLibrary
	XLIB	GetMsg
	XLIB	ReplyMsg

**** intuition.library ****
	XLIB	OpenWindow
	XLIB	CloseWindow
	XLIB	OpenScreen
	XLIB	CloseScreen
	XLIB	ShowTitle
	XLIB	RefreshWindowFrame

**** graphics.library ****
	XLIB	Draw
	XLIB	Move
	XLIB	SetAPen
	XLIB	SetBPen
	XLIB	SetRGB4
	XLIB	SetRast

**** mathieeedoubbas.library ****

	XLIB	IEEEDPFlt	* convert integer to IEEE double-precision
	XLIB	IEEEDPFix	* convert IEEE double-precision to integer 
	XLIB	IEEEDPTst	* test an IEEE double-precision # against 0
	XLIB	IEEEDPAbs	* get absolute value of IEEE double-precision #
	XLIB	IEEEDPAdd	* add 2 IEEE double-precision numbers
	XLIB	IEEEDPMul	* multiply 2 IEEE double-precision numbers
	XLIB	IEEEDPDiv	* divide 2 IEEE double-precision numbers

**** mathieeedoubtrans.library ****

	XLIB	IEEEDPSin	* return sine of IEEE double-precision number
	XLIB	IEEEDPCos	* return cosine of IEEE double-precision number

**** system constants externally defined in include files ****
	XREF     sc_RastPort
	XREF     sc_ViewPort
	XREF     wd_UserPort
	XREF     im_Class
	XREF     im_IAddress
	XREF	 gg_GadgetID
*************************************************************************
*	This code  from crt0.a68 is necessary to make an assembler program
*	executable from CLI without using the Aztec C _main function.
*	Other assembler users will need to change this.
*************************************************************************
startup:
        entry .begin
        public .begin
.begin
        public  __H1_org,__H2_org,__H2_end

        far     code
        far     data
        lea     __H1_org+32766,A4
	near    code
        near    data

        lea     __H2_org,A1
        move.w  #((__H2_end-__H2_org)/4)-1,D1
        bmi    Trans

loop:   clr.l   (A1)+
	dbra   d1,loop
*************************************************************************
Trans:
	move.l	sp,stashsp		* save the stack pointer (a7)
	move.l	a4,stasha4		* save a4 for Manx

	jsr	open_libraries		* open the libraries we use
	jsr	open_screen		* open a screen to use
	jsr	open_window		* open a window to draw onto
	jsr	plook_palette		* setup the color registers

	jsr	Fuz			* routine using the 68881 routines
					* to draw stuff
	jsr	stage_left		* tidy up a bit before we leave

way_out:
	move.l	stashsp,sp		* restore the stack pointer (a7)
	move.l	stasha4,a4		* restore a4
	rts				* say goodnite dick

*************************************************************************
*   This is the routine that plots shapes with a rather odd algorithm
*************************************************************************
Fuz:
	jsr Fuz_init			* set up stuff for the first run

*************************************************************************
* This routine is a loop that checks for IDCMP messages while drawing
*  the trans. function on the screen. Handy if you want to exit without
*  resorting to control-ah-ah.
*************************************************************************
Fuz_loop:
	move.l	SysBase,a6		* see if there are any messages
	move.l	userport,a0		* in our window's UserPort
	XCALL	GetMsg(a6)
	move.l	d0,message		* see if there's a message
	beq	do_Fuz			* if not, go draw some more

	move.l	message,a0		* there was a message 
	move.l	im_Class(a0),class	* get the Class of the message
	move.l	im_IAddress(a0),gad	* get the IAddress
	move.l	message,a1		* that's all we want
	XCALL	ReplyMsg(a6)		* so we'll reply to the message

	move.l	class,d0		* so we check the class
	cmp	#CLOSEWINDOW,d0		* do we CLOSEWINDOW ?
	bne	not_yet			* not yet

	rts				* head for the door
not_yet:
	cmp	#GADGETDOWN,d0		* What other gadget got hit?
	beq	what_gad
	cmp	#GADGETUP,d0
	beq	that_gad


what_gad:
	cmp.l	#GADGETUP,class		* Make sure it's released before we
	bne	do_Fuz			* do anything rash.

that_gad:
	move.l	#0,d0
	move.l	gad,a2
	move.w	gg_GadgetID(a2),d0	* Who is it?
	move.l	d0,gadgid
	cmp	#WHOA,d0		* Oh. The boring one.
	beq	stop_de_music

	cmp	#GO,d0			* Fire that mother up
	bne	do_Fuz
* This is where that damned ascii to binary thing goes

	move.l	rp,a1
	move.l	#0,d0
	move.l	gfxbase,a6
	XCALL	SetRast(a6)
	move.l	intuitionbase,a6
	move.l	window,a0
	XCALL	RefreshWindowFrame(a6)
	move.l	rp,a1
	move.l	#1,d0
	move.l	gfxbase,a6
	XCALL	SetAPen(a6)
	move.l	rp,a1
	move.l	#CX,d0
	move.l	#CY,d1
	add.l	#YTWEAK,d1
	XCALL	Move(a6)
	move.l	#0,d0
	move.l	d0,inc
	move.l	d0,inc+4
	move.l	d0,ny
	move.l	d0,cnt
	move.l	d0,t2
* Grab the new start time here
	move.w	#FALSE,idling


	bra	do_Fuz

stop_de_music:
	move.l	#YTWEAK,ny
*	The time function call will go here (I hope)
	bra	Fuz_loop		* then loop

*************************************************************************
* This is the algorithm that calculates the points to draw with.
*************************************************************************
do_Fuz:
	cmp.l	#YTWEAK,ny		* is ny < #YTWEAK ?
	bge	Fuz_loop		* nope. it's > #YTWEAK, so we loop

	*****************************************************************
	* IEEEDPAdd(arg1,arg2)[d0/d1,d2/d3] - add 2 IEEEdp values	*
	*	INPUT  - IEEEdp arg1 in d0/d1, IEEEdp arg2 in d2/d3	*
	*	OUTPUT _ IEEEDP result in d0/d1				*
	*****************************************************************
	move.l	inc,d0			* inc is arg1
	move.l	inc+4,d1
	move.l	rot,d2			* rot is arg2
	move.l	rot+4,d3
	move.l	mathieeedoubbasbase,a6
	XCALL	IEEEDPAdd(a6)		* so inc += rot is what we're doing
	move.l	d0,inc			* save it for later
	move.l	d1,inc+4

	*****************************************************************
	* IEEEDPTst(arg)[d0/d1] - test an IEEEdp value against zero.	*
	*	INPUT  - IEEEdp arg in d0/d1				*
	*	OUTPUT - d0 = +1 if arg > 0.0				*
	*		 d0 = -1 if arg < 0.0				*
	*		 d0 = 0  if arg = 0.0				*
	*****************************************************************
	move.l	vx,d0			* see if vx = 0
	move.l	vx+4,d1
	XCALL	IEEEDPTst(a6)
	bne	Fuz_nx2			* not 0, so do regular calculation

	*******************************************
	* if(vx == 0) nx = (int)(sin(inc*DEG)*140);
	*******************************************
	jsr	Fuz_deginc		* go do inc*DEG & store in deginc

	*****************************************************************
	* IEEEDPSin(arg)[d0/d1] - return the sine of an IEEEdp value	*
	*	INPUT  - IEEEdp arg in d0/d1				*
	*	OUTPUT - IEEEdp sine result in d0/d1			*
	*****************************************************************
	move.l	mathieeedoubtransbase,a6	* d0/d1 should still contain
	XCALL	IEEEDPSin(a6)			* deginc, so we do sin(deginc)

	*****************************************************************
	* IEEEDPMul(arg1,arg2)[d0/d1,d2/d3] - multiply 2 IEEEdp values	*
	*	INPUT  - IEEEdp arg1 in d0/d1, IEEEdp arg2 in d2/d3	*
	*	OUTPUT - IEEEdp result in d0/d1				*
	*****************************************************************
	move.l	x_tweak,d2			* we want multiply the
	move.l	x_tweak+4,d3			* sine result with #140
	move.l	mathieeedoubbasbase,a6		* which we already took
	XCALL	IEEEDPMul(a6)			* to IEEEdp format
	XCALL	IEEEDPFix(a6)
	move.l	d0,nx				* store in nx

	bra	Fuz_ny				* compute y co-ordinate

	******************************************************************
	* if(vx <> 0) nx = (int)(sin(inc*DEG)*fabs(sin((inc*DEG)*vx))*140);
	******************************************************************
Fuz_nx2
	jsr	Fuz_deginc			* go figure deginc value
	move.l	mathieeedoubtransbase,a6	* deginc = (inc*DEG)
	XCALL	IEEEDPSin(a6)			* get sin(deginc)
	move.l	d0,sintemp			* save the result
	move.l	d1,sintemp+4

	move.l	deginc,d0			* now we do (deginc*vx)
	move.l	deginc+4,d1
	move.l	vx,d2
	move.l	vx+4,d3
	move.l	mathieeedoubbasbase,a6
	XCALL	IEEEDPMul(a6)
						* d0/d1 should still be valid
	move.l	mathieeedoubtransbase,a6	* so now we get the sine
	XCALL	IEEEDPSin(a6)

	*****************************************************************
	* IEEEDPAbs(arg)[d0/d1] - get absolute value of IEEEdp arg	*
	*	INPUT  - IEEEdp arg in d0/d1				*
	*	OUTPUT - IEEEdp absolute value in d0/d1			*
	*****************************************************************
	move.l	mathieeedoubbasbase,a6		* get the absolute value
	XCALL	IEEEDPAbs(a6)			* of the sine

	move.l	sintemp,d2			* multiply it with the
	move.l	sintemp+4,d3			* previous sine value
	XCALL	IEEEDPMul(a6)

	move.l	x_tweak,d2			* then multiply the result
	move.l	x_tweak+4,d3			* with x_tweak
	XCALL	IEEEDPMul(a6)

	XCALL	IEEEDPFix(a6)
	move.l	d0,nx				* and save in nx

	******************************************************
	* ny = (int)(cos(inc*DEG)*fabs(cos((inc*DEG)*vy))*70);
	******************************************************
Fuz_ny
	*****************************************************************
	* IEEEDPCos(arg)[d0/d1] - return the cosine of an IEEEdp value	*
	*	INPUT  - IEEEdp arg in d0/d1				*
	*	OUTPUT - IEEEdp cosine result in d0/d1			*
	*****************************************************************
	move.l	deginc,d0			* deginc has been figured
	move.l	deginc+4,d1			* already, so now we get
	move.l	mathieeedoubtransbase,a6	* it's cosine
	XCALL	IEEEDPCos(a6)
	move.l	d0,costemp			* and save it as costemp
	move.l	d1,costemp+4

	move.l	deginc,d0			* now we get deginc again
	move.l	deginc+4,d1
	move.l	vy,d2				* multiply with vy
	move.l	vy+4,d3
	move.l	mathieeedoubbasbase,a6
	XCALL	IEEEDPMul(a6)

	move.l	mathieeedoubtransbase,a6	* get the cosine of result
	XCALL	IEEEDPCos(a6)

	move.l	mathieeedoubbasbase,a6		* get absolute value of
	XCALL	IEEEDPAbs(a6)			* the cosine result

	move.l	costemp,d2			* multiply that with the
	move.l	costemp+4,d3			* first cosine result
	XCALL	IEEEDPMul(a6)

	move.l	y_tweak,d2			* multiply THAT with y_tweak
	move.l	y_tweak+4,d3
	XCALL	IEEEDPMul(a6)

	XCALL	IEEEDPFix(a6)
	move.l	d0,ny				* save the result as ny

	add.l	#1,cnt				* increment cnt

	cmp.l	#61,cnt				* see if cnt >= 61
	ble	Fuz_draw			* not yet, go draw

	move.l	#0,cnt				* reset cnt to 0
	add.l	#1,col				* increment pen color
	cmp.l	#15,col				* see if it's the last color
	bne	incr_pen			* not yet

	move.l	#2,col				* reset pen color to 2
incr_pen:
	move.l	col,d0
	move.l	rp,a1
	move.l	gfxbase,a6
	XCALL	SetAPen(a6)

Fuz_draw:
	move.l	ny,d1				* put ny into d1
	add.l	#CY,d1				* add #CY offset to d1
	move.l	nx,d0				* put nx into d0
	add.l	#CX,d0				* add #CX offset to d0
	move.l	rp,a1				* the address of our RastPort
	move.l	gfxbase,a6			* a graphics routine
	XCALL	Draw(a6)			* Draw(rp,nx+CX,ny+CY)


Fuz_done:
	bra	Fuz_loop			* go check for messages & loop
*	rts

*************************************************************************
* This subroutine calculates the value of deginc = (inc*DEG)
*************************************************************************
Fuz_deginc:
	move.l	inc,d0
	move.l	inc+4,d1
	move.l	DEG,d2
	move.l	DEG+4,d3
	move.l	mathieeedoubbasbase,a6
	XCALL	IEEEDPMul(a6)
	move.l	d0,deginc
	move.l	d1,deginc+4

	rts

*************************************************************************
Fuz_init:
	move.l	#1,col		* initialize our variables
	move.l	#0,cnt		* loop counter to change colors
	move.l	#0,ny		* y co-ordinate variable
	move.l	#0,nx		* x co-ordinate variable

	*********************************************************
	* IEEEDPFlt(integer)[d0] - convert an integer variable 	*
	*	to IEEE double-precision format. All of the	*
	*	IEEEDP math functions need numbers in this	*
	*	format, or they won't work the way you expect	*
	* INPUT  - integer in d0				*
	* OUTPUT - IEEE double-precision result in d0/d1	*
	*********************************************************
	
	move.l	#0,d0		* make sure that 0 is in IEEEDP format
	move.l	mathieeedoubbasbase,a6	* offset from mathieeedoubbasbase
	XCALL	IEEEDPFlt(a6)		* call using macro
	move.l	d0,inc			* store in variable upper
	move.l	d1,inc+4		* and lower longword area

	move.l	pt02,d0			* get pre-converted ieee value
	move.l	pt02+4,d1		* for .02
	move.l	d0,rot			* store as variable rot
	move.l	d1,rot+4

	move.l	#198,d0			* convert #198 to IEEEDP
	XCALL	IEEEDPFlt(a6)
	move.l	d0,vx			* store as variable vx
	move.l	d1,vx+4

	move.l	#192,d0			* convert #192 to farthings
	XCALL	IEEEDPFlt(a6)
	move.l	d0,vy			* store under an old log
	move.l	d1,vy+4

	move.l	#XTWEAK,d0		* convert #XTWEAK to IEEEdp format
	XCALL	IEEEDPFlt(a6)
	move.l	d0,x_tweak		* store as variable x_tweak
	move.l	d1,x_tweak+4

	move.l	#YTWEAK,d0		* convert YTWEAK to IEEEdp format
	XCALL	IEEEDPFlt(a6)
	move.l	d0,y_tweak		* store as variable y_tweak
	move.l	d1,y_tweak+4

	move.l	#80,d0			* convert #80 to IEEEdp format
	XCALL	IEEEDPFlt(a6)

	*********************************************************
	* IEEEDPDiv(arg1,arg2)[d0/d1,d2/d3] - divide 2 IEEE 	*
	*	double-precision variables arg1/arg2		*
	* INPUT  - IEEEdp arg1 in d0/d1, IEEEdp arg2 in d2/d3	*
	* OUTPUT - IEEEdp result in d0/d1			*
	*********************************************************

	move.l	d0,d2			* move converted #80 to d2/d3
	move.l	d1,d3
	move.l	PI,d0			* move pre-converted PI into d0/d1
	move.l	PI+4,d1
	XCALL	IEEEDPDiv(a6)		* divide PI with #80
	move.l	d0,DEG			* store as variable DEG
	move.l	d1,DEG+4

	move.l	#0,d0			* set the background pen to 0
	move.l	rp,a1
	move.l	gfxbase,a6
	XCALL	SetBPen(a6)
	move.l	col,d0			* set the foreground pen to col
	move.l	rp,a1
	XCALL	SetAPen(a6)

	move.l	#CX,d0			* set our starting point to draw
	move.l	#CY,d1
	add.l	#YTWEAK,d1		* add an offset to the y co-ord
	move.l	rp,a1
	XCALL	Move(a6)		* and move the cursor there.

	rts

*************************************************************************
*	Open the libraries that we plan on using, and exit if one
*	doesn't return a valid address. 
*************************************************************************
open_libraries:
	move.l	SysBase,a6		* base address for Exec
	lea.l	grlib,a1		* address of library name in a1
	moveq	#0,d0			* load d0 with version #. 0 = any
	XCALL	OpenLibrary(a6)		* jsr to the open routine
	move.l	d0,gfxbase		* store the returned adrress
	beq	open_fail		* 0 returned means the open failed

	move.l	SysBase,a6		* etc.
	lea.l	intuitlib,a1
	moveq	#0,d0
	XCALL	OpenLibrary(a6)
	move.l	d0,intuitionbase
	beq	open_fail

	move.l	SysBase,a6		* the new IEEEDP libraries assume
	lea.l	midblib,a1		* that you have io68881.library
	moveq	#0,d0			* in your libs: directory.
	XCALL	OpenLibrary(a6)		* they complain loudly if it's
	move.l	d0,mathieeedoubbasbase	* not present. In fact it'll
	beq	open_fail		* probably puke in your lap.

	move.l	SysBase,a6
	lea.l	midtlib,a1
	moveq	#0,d0
	XCALL	OpenLibrary(a6)
	move.l	d0,mathieeedoubtransbase
	beq	open_fail

	rts

*************************************************************************
*	open screen and get RastPort & ViewPort addresses
*************************************************************************
open_screen:
	move.l	intuitionbase,a6	* use intuitionbase to offset from
	lea.l	newscreen,a0		* address of our screen data
	XCALL	OpenScreen(a6)
	move.l	d0,screen		* store the address for later
	beq	open_fail		* it won't open, so exit

	move.l	d0,d2			* copy screen address for re-use
	move.l	d0,a0			* put screen adr in a0 for ShowTitle
	add.l	#sc_RastPort,d0		* add RastPort offset value to adr
	move.l	d0,rp			* rp now contains RastPort address
	add.l	#sc_ViewPort,d2		* add ViewPort offset to adr in d2
	move.l	d2,vp			* vp now contains ViewPort address
	move.l	intuitionbase,a6	* we'll offset from intuitionbase
	move.l	#FALSE,d0		* load the desired command
	XCALL	ShowTitle(a6)		* turn off the screen's title bar

	rts

*************************************************************************
*	open window & get UserPort address
*************************************************************************
open_window:
	move.l	screen,newwindow_screen	*pointer to screen
	move.l	intuitionbase,a6
	lea.l	newwindow,a0		* address of window data
	XCALL	OpenWindow(a6)
	move.l	d0,window
	beq	open_fail

	move.l	d0,a0			* copy window address to a0
	move.l	wd_UserPort(a0),d1	* extract UserPort adr from window
	move.l	d1,userport		* save it for GetMsg stuff
	
	rts

*************************************************************************
*
*	This routine loads the color registers from 3 tables.
*	Not particularly elegant, but easy to modify.
*
*************************************************************************
plook_palette:
	move.l	#0,d4			* init our counter to 0
color_loop:
	move.l	d4,d0			* our counter will be our offset
	asl.l	#1,d0			* multiply by 2
	lea	blue,a1			* get address of blue data
	move.l	#0,d3			* init its data register
	move.w	(a1,d0.l),d3		* move the proper data into data reg
	lea	green,a1		* then do green...
	move.l	#0,d2
	move.w	(a1,d0.l),d2
	lea	red,a1			* then red...
	move.l	#0,d1
	move.w	(a1,d0.l),d1
	move.l	d4,d0			* counter = color register number
	move.l	vp,a0			* address of our viewport
	move.l	gfxbase,a6		* SetRGB4 is a graphics routine
	XCALL	SetRGB4(a6)		* set the color register

	add.l	#1,d4			* increment our counter
	cmp.l	#16,d4			* we're using 16 colors
	blt	color_loop		* loop 'till it's plooked

	rts

*************************************************************************
* an attempted Open failed, so we load d0 with an error flag & die
*************************************************************************
open_fail:
	moveq	#-1,d1
	move.l	d1,d0
	bra	way_out

*************************************************************************
* Close all the screens, windows & librarys that we opened
*************************************************************************
stage_left:
	move.l	SysBase,a6
	move.l	mathieeedoubtransbase,a1
	XCALL	CloseLibrary(a6)

	move.l	SysBase,a6
	move.l	mathieeedoubbasbase,a1
	XCALL	CloseLibrary(a6)

	move.l	intuitionbase,a6
	move.l	window,a0
	XCALL	CloseWindow(a6)

	move.l	intuitionbase,a6
	move.l	screen,a0
	XCALL	CloseScreen(a6)

	move.l	SysBase,a6
	move.l	gfxbase,a1
	XCALL	CloseLibrary(a6)

	move.l	SysBase,a6
	move.l	intuitionbase,a1
	XCALL	CloseLibrary(a6)

	rts

*************************************************************************
* data area - variables, constants, etc.
*************************************************************************
	cseg

	bss	stashsp,4
	bss	stasha4,4
	bss	gfxbase,4
	bss	intuitionbase,4
	bss	screen,4
	bss	window,4
	bss	userport,4
	bss	rp,4
	bss	vp,4
	bss	col,4
	bss	cnt,4
	bss	nx,4
	bss	ny,4
	bss	t1,4
	bss	t2,4
	bss	mathieeedoubbasbase,4
	bss	mathieeedoubtransbase,4
	bss	idling,2
	even

	bss	message,8
	bss	class,8
	bss	gad,8
	bss	gadgid,8
	bss	masque,8
	bss	win,8
	bss	mclass,8

	bss	rot,8
	bss	vx,8
	bss	vy,8
	bss	inc,8
	bss	DEG,8
	bss	deginc,8
	bss	x_tweak,8
	bss	y_tweak,8
	bss	sintemp,8
	bss	costemp,8

	dseg
	ds	0
PI	dc.l	$400921fb,$54442cba
pt02	dc.l	$3f947ae1,$47ae147b	;pt = .02

grlib		dc.b	'graphics.library',0
intuitlib	dc.b	'intuition.library',0
midblib		MATHIEEEDOUBBASNAME
midtlib		MATHIEEEDOUBTRANSNAME
window_title:
 dc.b ' The StringGads Do not Work on the asm Fuzzy Number Plotter, by Dmil',0
fontname	dc.b	'topaz.font',0

red:	dc.w	0,13,11,12,13,13,14,15,8,4,0,0,0,0,0,4
green:	dc.w	0,2,3,4,5,7,9,13,11,9,6,4,2,0,5,10
blue:	dc.w	0,2,2,2,2,1,1,0,0,0,2,7,10,14,15,15

Topfont:
	dc.l	fontname
	dc.w	TOPAZ_SIXTY
	dc.b	FSF_EXTENDED!FSF_ITALIC!FSF_BOLD
	dc.b	FPF_ROMFONT!FPF_PROPORTIONAL
Toyfont:
	dc.l	fontname
	dc.w	 TOPAZ_EIGHTY
	dc.b	FSF_EXTENDED
	dc.b	FPF_ROMFONT!FPF_PROPORTIONAL


newscreen:
	dc.w	0				;start x position
	dc.w	0				;start y position
	dc.w	640				;width
	dc.w	400				;height
	dc.w	4				;depth
	dc.b	0				;detail pen
	dc.b	0				;block pen
	dc.w	V_HIRES!V_LACE			;screen viewmode
	dc.w	CUSTOMSCREEN			;screen type
	dc.l	Toyfont				;screen font
	dc.l	0				;screen title
	dc.l	0				;gadget pointer
	ds.l	0				;pointer to bitmap
	even

newwindow:
	dc.w	0				;start x position
	dc.w	12				;start y position
	dc.w	640				;width
	dc.w	388				;height
	dc.b	7				;detail pen
	dc.b	0				;block pen
	dc.l	NW_IDCMP			;IDCMP flags
	dc.l	NW_FLAGS			;window flags
	dc.l	rot_gad				;pointer to gadget list
	dc.l	0				;ptr to menu checkmark images
	dc.l	window_title			; window title
newwindow_screen
	dc.l	0				;pointer to screen
	dc.l	0				;pointer to bitmap structure
	dc.w	0				;minwidth
	dc.w	0				;minheight
	dc.w	0				;maxwidth
	dc.w	0				;maxheight
	dc.w	CUSTOMSCREEN			;screen type

rotbuf:
	dc.b	'.02',0
	dc.b	6
	even
vxbuf:
	dc.b	'199',0
	dc.b	6
	even
vybuf:
	dc.b	'198',0
	dc.b	6
	even

rot_gad:
	dc.l	vx_gad
	dc.w	GADL_EDGE,GADT_EDGE
	dc.w	80,10
	dc.w	GADGHCOMP,STRAFLAGS,STRGADGET
	dc.l	rot_brdr
	dc.l	NULL
	dc.l	rot_txt
	dc.l	NULL
	dc.l	rot_info
	dc.w	ROT
	dc.l	NULL
vx_gad
	dc.l	vy_gad
	dc.w	GADL_EDGE,GADT_EDGE+25
	dc.w	80,10
	dc.w	GADGHCOMP,STRAFLAGS,STRGADGET
	dc.l	vx_brdr
	dc.l	NULL
	dc.l	vx_txt
	dc.l	NULL
	dc.l	vx_info
	dc.w	VX
	dc.l	NULL
vy_gad
	dc.l	whoa_gad
	dc.w	GADL_EDGE,GADT_EDGE+50
	dc.w	80,10
	dc.w	GADGHCOMP,STRAFLAGS,STRGADGET
	dc.l	vy_brdr
	dc.l	NULL
	dc.l	vy_txt
	dc.l	NULL
	dc.l	vy_info
	dc.w	VY
	dc.l	NULL
whoa_gad
	dc.l	go_gad
	dc.w	GADL_EDGE+11,GADT_EDGE+65
	dc.w	58,9
	dc.w	GADGHCOMP,BOOLAFLAGS,BOOLGADGET
	dc.l	stop_brdr
	dc.l	NULL
	dc.l	stop_txt
	dc.l	NULL
	dc.l	NULL
	dc.w	WHOA
	dc.l	NULL
go_gad
	dc.l	NULL
	dc.w	GADL_EDGE+11,GADT_EDGE+80
	dc.w	58,9
	dc.w	GADGHCOMP,BOOLAFLAGS,BOOLGADGET
	dc.l	start_brdr
	dc.l	NULL
	dc.l	start_txt
	dc.l	NULL
	dc.l	NULL
	dc.w	GO
	dc.l	NULL

rot_info:
	dc.l	rotbuf
	dc.l	NULL
	dc.w	0,10,0,0,0,0,2,1
	dc.l	NULL,NULL,NULL
vx_info:
	dc.l	vxbuf
	dc.l	NULL
	dc.w	0,10,0,0,0,0,2,1
	dc.l	NULL,NULL,NULL
vy_info:
	dc.l	vybuf
	dc.l	NULL
	dc.w	0,10,0,0,0,0,2,1
	dc.l	NULL,NULL,NULL

rot_txt:
	dc.b	7,0,RP_JAM2,0
	dc.w	28,-12
	dc.l	Toyfont
	dc.l	rot_text
	dc.l	NULL
vx_txt:
	dc.b	7,0,RP_JAM2,0
	dc.w	34,-12
	dc.l	Toyfont
	dc.l	vx_text
	dc.l	NULL
vy_txt:
	dc.b	7,0,RP_JAM2,0
	dc.w	34,-12
	dc.l	Toyfont
	dc.l	vy_text
	dc.l	NULL
stop_txt
	dc.b	7,4,RP_JAM2,0
	dc.w	1,0
	dc.l	Topfont
	dc.l	stop_text
	dc.l	NULL
start_txt:
	dc.b	7,9,RP_JAM2,0
	dc.w	1,0
	dc.l	Topfont
	dc.l	start_text
	dc.l	NULL

rot_text:
	dc.b	'rot',0
	even
vx_text:
	dc.b	'vx',0
	even
vy_text:
	dc.b	'vy',0
	even
stop_text:
	dc.b	'Whoa!',0
	even

start_text:
	dc.b	'Start',0
	even

rot_brdr:
	dc.w	-2,-3
	dc.b	15,0,RP_JAM1,5
	dc.l	rotgadvecs
	dc.l	NULL
vx_brdr:
	dc.w	-2,-3
	dc.b	13,0,RP_JAM1,5
	dc.l	vxgadvecs
	dc.l	NULL
vy_brdr:
	dc.w	-2,-3
	dc.b	11,0,RP_JAM1,5
	dc.l	vygadvecs
	dc.l	NULL
stop_brdr:
	dc.w	-2,-1
	dc.b	5,0,RP_JAM1,5
	dc.l	stopgadvecs
	dc.l	NULL
start_brdr:
	dc.w	-2,-1
	dc.b	10,0,RP_JAM1,5
	dc.l	startgadvecs
	dc.l	NULL

vxgadvecs:
	dc.w	0,0,84,0,84,12,0,12,0,0
vygadvecs:
	dc.w	0,0,84,0,84,12,0,12,0,0
rotgadvecs:
	dc.w	0,0,84,0,84,12,0,12,0,0
stopgadvecs:
	dc.w	0,0,58,0,58,10,0,10,0,0
startgadvecs:
	dc.w	0,0,58,0,58,10,0,10,0,0

	end
******************************************************************
