
start:  clr.l   -(SP)           ;Go into supervisor mode
        move.w  #$20,-(SP)
        trap    #1
        addq.l  #6,SP
        move.l  D0,spv_sp
	move.b	#0,$484

	move.l	#$31415926,$426	;set reset vector valid
	move.l	#myreset,$42a
	move.w	#4,-(sp)
	trap	#14
	addq.l	#2,sp
	move.w	d0,ressave


	move.w	#0,-(sp)	;set to low res
	move.l	#-1,-(sp)
	move.l	#-1,-(sp)
	move.w	#5,-(sp)
	trap	#14
	add.l	#12,sp


        jsr     mousof
	jsr	joystuff
        jsr     getscrn
	jsr	plotinit
        jsr     linea
        move.w  #10,d0
        jsr     randomseed
*	bsr	prestuff	;prerotate some sprites matey

	lea	joydir,a0
	jsr	putvbl
	move.l	a1,oldvbl1
	move.w	#$0777,blade1
	move.w	#$0222,blade2
	lea	colorint,a0
	jsr	putvbl
	move.l	a1,oldvbl2
	move.l	#helipalette,temppal
	bsr	docolors

************************************************
*********************************
*	stars demo       	*
*********************************
inc:		equ	0
magic:		equ	250
buttondat:	equ	$26e6
mx:		equ	$26e0
my:		equ	$26e2
tall:		equ	15
yadj:		equ	100
xadj:		equ	200

ftf:
	bsr	loadscreen
	bsr	copyintoboth
	bsr	ramware
	move.w	#15,linecolor
	move.w	#10,mx
	move.w	#100,my
	move.w	#170,pixelx
	move.w	#110,pixely
	move.w	#15,reccolor
	move.w	#167,centrex
	move.w	#100,centrey
	move.w	#800,myheight
	bsr	prebuildstuff
	bsr	interference
test:
*	bsr	clearfast
	bsr	printinfo
	bsr	joy
	bsr	moveroad
	bsr	attack1
	bsr	puthelishad
	bsr	movebuildings
	bsr	shoot
	bsr	moveshots
	bsr	shotcollisions
	bsr	helicollision
	bsr	putheli
	bsr	keyboard
	bsr	flip_scr
	addq.w	#1,score
	bra	test

*********************************
*	tv like interference	*
*********************************
interference:
	bsr	flip_scr
	bsr	flip_scr
	move.l	#150000,d0
intloop:
	move.w	#$0fff,$ff8244
	move.w	#0,$ff8244
	subq.l	#1,d0
	bpl	intloop
	move.w	#$0463,$ff8244
	rts

*************************************************
*	sets up initial building stuff		*
*************************************************
prebuildstuff:
	bsr	newbuild
	move.l	a0,b1image
	move.w	d0,b1height
	move.w	d1,b1xl
	move.w	d2,b1yl
	bsr	newbuild
	move.l	a0,b2image
	move.w	d0,b2height
	move.w	d1,b2xl
	move.w	d2,b2yl
	bsr	newbuild
	move.l	a0,b3image
	move.w	d0,b3height
	move.w	d1,b3xl
	move.w	d2,b3yl
	bsr	newbuild
	move.l	a0,b4image
	move.w	d0,b4height
	move.w	d1,b4xl
	move.w	d2,b4yl
	bsr	newbuild
	move.l	a0,b5image
	move.w	d0,b5height
	move.w	d1,b5xl
	move.w	d2,b5yl
	bsr	newbuild
	move.l	a0,b6image
	move.w	d0,b6height
	move.w	d1,b6xl
	move.w	d2,b6yl
	move.w	#-300,b1y
	move.w	#-150,b1x
	move.w	#-300,b2y
	move.w	#150,b2x
	move.w	#-100,b3y
	move.w	#-150,b3x
	move.w	#-100,b4y
	move.w	#150,b4x
	move.w	#100,b5y
	move.w	#-150,b5x
	move.w	#100,b6y
	move.w	#150,b6x
	move.w	#0,roadx
	move.w	#0,roady
	rts

*************************************************
*	move the buildings down the screen	*
*	and check for out of view, if so	*
*	create a new random building		*
*	also draws them on the hiden screen	*
*************************************************
movebuildings:
	add.w	#dspeed,b1y
	cmpi.w	#bottom,b1y
	blt	bmove2
	move.w	#top,b1y
	bsr	newbuild
	move.l	a0,b1image
	move.w	d0,b1height
	move.w	d1,b1xl
	move.w	d2,b1yl
bmove2:
	lea	view_b1,a0
	move.l	b1image,object
	move.w	b1x,d0
	add.w	masterx,d0
	move.w	d0,xoffs
	move.w	b1y,yoffs
	bsr	buildput

	add.w	#dspeed,b2y
	cmpi.w	#bottom,b2y
	blt	bmove3
	move.w	#top,b2y
	bsr	newbuild
	move.l	a0,b2image
	move.w	d0,b2height
	move.w	d1,b2xl
	move.w	d2,b2yl
bmove3:
	lea	view_b2,a0
	move.l	b2image,object
	move.w	b2x,d0
	add.w	masterx,d0
	move.w	d0,xoffs
	move.w	b2y,yoffs
	bsr	buildput

	add.w	#dspeed,b3y
	cmpi.w	#bottom,b3y
	blt	bmove4
	move.w	#top,b3y
	bsr	newbuild
	move.l	a0,b3image
	move.w	d0,b3height
	move.w	d1,b3xl
	move.w	d2,b3yl
bmove4:
	lea	view_b3,a0
	move.l	b3image,object
	move.w	b3x,d0
	add.w	masterx,d0
	move.w	d0,xoffs
	move.w	b3y,yoffs
	bsr	buildput

	add.w	#dspeed,b4y
	cmpi.w	#bottom,b4y
	blt	bmove5
	move.w	#top,b4y
	bsr	newbuild
	move.l	a0,b4image
	move.w	d0,b4height
	move.w	d1,b4xl
	move.w	d2,b4yl
bmove5:
	lea	view_b4,a0
	move.l	b4image,object
	move.w	b4x,d0
	add.w	masterx,d0
	move.w	d0,xoffs
	move.w	b4y,yoffs
	bsr	buildput
*	rts
	add.w	#dspeed,b5y
	cmpi.w	#bottom,b5y
	blt	bmove6
	move.w	#top,b5y
	bsr	newbuild
	move.l	a0,b5image
	move.w	d0,b5height
	move.w	d1,b5xl
	move.w	d2,b5yl
bmove6:
	lea	view_b5,a0
	move.l	b5image,object
	move.w	b5x,d0
	add.w	masterx,d0
	move.w	d0,xoffs
	move.w	b5y,yoffs
	bsr	buildput

	add.w	#dspeed,b6y
	cmpi.w	#bottom,b6y
	blt	bmove7
	move.w	#top,b6y
	bsr	newbuild
	move.l	a0,b6image
	move.w	d0,b6height
	move.w	d1,b6xl
	move.w	d2,b6yl
bmove7:
	lea	view_b6,a0
	move.l	b6image,object
	move.w	b6x,d0
	add.w	masterx,d0
	move.w	d0,xoffs
	move.w	b6y,yoffs
	bsr	buildput
	rts
*********************************************************
*	returns address of object definition in a0	*
*	building height in d0				*
*	building x length in d1				*
*	building y length in d2				*
********************************************************* 
newbuild:
	lea	buildlist,a0
	move.w	#3,d0
	bsr	randomplus
	move.w	d0,d7
	asl.w	#2,d0
	move.l	(a0,d0.w),a0
	lea	heightlist,a1
	asl.w	#1,d7
	move.w	(a1,d7.w),d0	;gets height
	lea	xlist,a1
	move.w	(a1,d7.w),d1	;gets xlength
	lea	ylist,a1
	move.w	(a1,d7.w),d2	;gets ylength
	rts



buildlist:
	dc.l	building1,building2,building3
heightlist:
	dc.w	150,300,240
xlist:	dc.w	50,40,50
ylist:	dc.w	70,40,50

blade1:		blk.w	1,0
blade2:		blk.w	1,0
*************************************************
*	moves the road left and right		*
*	note no need to move down		*
*************************************************
moveroad:
	lea	view_road,a0
	move.l	#road,object
	move.w	roadx,d0
	add.w	masterx,d0
	move.w	d0,xoffs
	move.w	roady,yoffs
	bsr	buildput
	rts	

*********************************************************
*	subroutine to draw the building			*
*	add of vpb in a0				*
*********************************************************
buildput:
	move.l	a0,view_pb
	move.w	myheight,rho(a0)
	move.w	#0,phi(a0)
	move.w	#0,theta(a0)
	bsr	plot_obj
	rts

*************************************************
*	put helicopter shadow			*
*	several methods none satisfactory	*
*************************************************
puthelishad:
	cmpi.w	#300,myheight
	bge	shadback

	moveq	#1,d6		;shorten shadow
	moveq	#0,d4
	move.w	#15592,d5
pshad:
	move.l	hiden,a0
	adda.l	d5,a0
	move.l	masterhelimask,a2
	moveq	#0,d7
phl:
	move.w	(a2)+,d0
	eor.w	#-1,d0
	and.w	d0,(a0)+	;cut me a hole
	and.w	d0,(a0)+
	and.w	d0,(a0)+
	and.w	d0,(a0)+
	move.w	(a2)+,d0
	eor.w	#-1,d0
	and.w	d0,(a0)+
	and.w	d0,(a0)+
	and.w	d0,(a0)+
	and.w	d0,(a0)+
	adda.l	#144,a0
	add.w	d6,d7
	add.w	d4,a2
	cmpi.w	#36,d7
	ble	phl
	rts
shadback:
	rts
*************************************************
*	initial attacker code			*
*************************************************
attack1:
	lea	view_at1,a0
	move.l	a0,view_pb
	move.w	myheight,rho(a0)
	move.w	#0,phi(a0)
	move.w	#60,theta(a0)
	move.w	#30,yoffs
	move.w	masterx,xoffs
	move.l	#tank1,object
	bsr	plot_obj
	rts
*************************************************
*	puts the appropriate heli image		*
*	into the centre of the screen		*
*************************************************
putheli:	
	tst.w	helidead
	bmi	phback
	move.l	hiden,a0
	adda.l	#14000,a0
	move.l	masterheli,a1
	move.l	masterhelimask,a2
	move.w	#36,d7
phl2:
	move.w	(a2)+,d0
	eor.w	#-1,d0
	and.w	d0,(a0)		;cut me a hole
	and.w	d0,2(a0)
	and.w	d0,4(a0)
	and.w	d0,6(a0)
	move.w	(a2)+,d0
	eor.w	#-1,d0
	and.w	d0,8(a0)
	and.w	d0,10(a0)
	and.w	d0,12(a0)
	and.w	d0,14(a0)
	move.w	(a1)+,d0
	or.w	d0,(a0)+
	move.w	(a1)+,d0
	or.w	d0,(a0)+
	move.w	(a1)+,d0
	or.w	d0,(a0)+
	move.w	(a1)+,d0
	or.w	d0,(a0)+
	move.w	(a1)+,d0
	or.w	d0,(a0)+
	move.w	(a1)+,d0
	or.w	d0,(a0)+
	move.w	(a1)+,d0
	or.w	d0,(a0)+
	move.w	(a1)+,d0
	or.w	d0,(a0)+
	adda.l	#144,a0		;move screen ad down one line
	dbf	d7,phl2
phback:	rts
*************************************************
*	joystic direction stuff			*
*	also handles max and min both		*
*	up and down.				*
*	note: only handles direction		*
*	not firing				*
*************************************************
joy:
	move.w	myxvel,d0
	sub.w	d0,masterx
	cmpi.w	#-200,masterx
	bge	jt2
	move.w	#-200,masterx
	bra	joyt3
jt2:	cmpi.w	#200,masterx
	ble	joyt3
	move.w	#200,masterx

joyt3:	move.w	myyvel,d0
	add.w	d0,myheight

	cmpi.w	#200,myheight
	bge	jt3
	move.w	#200,myheight
	bra	joyt4
jt3:	cmpi.w	#700,myheight
	ble	joyt4
	move.w	#700,myheight
joyt4:
	tst.w	firebutton
	bmi	jtback
	move.w	#1,helidead
jtback:
	rts
*****************************************
*	shoot routine			*
*	handles shooting		*
*****************************************
shoot:
	tst.w	firebutton
	bmi	shootback
	tst.w	shot1avail
	bpl	shoot2
	move.w	#1,shot1avail
*	move.w	myheight,
	move.w	#100,shot1z
	move.w	#0,shot1y
	move.w	masterx,d0
	neg	d0
	move.w	d0,shot1x
*	move.w	masterx,shot1x
	addq.w	#4,shot1x
	move.w	#-1,firebutton
shoot2:
shootback:
	rts
*****************************************
*	moves shots			*
*****************************************
moveshots:
	tst.w	shot1avail
	bmi	mshot2
	lea	view_shot1,a0
	move.l	a0,view_pb
	move.l	#shot1image,object
	move.w	#0,theta(a0)
	move.w	#0,phi(a0)
	add.w	#30,shot1z
	move.w	shot1z,rho(a0)
	subq.w	#8,shot1y
	move.w	shot1y,yoffs
	move.w	shot1x,d0
	add.w	masterx,d0
	move.w	d0,xoffs
	bsr	plot_obj


mshot2:
mshotback:
	rts
*************************************************
*	shot check for reaching ground		*
*************************************************
shotcollisions:
	tst.w	shot1avail
	bmi	shotcol2
	move.w	myheight,d0
	cmp.w	shot1z,d0
	bgt	sh1bcol
	move.w	#-1,shot1avail
	bra	shotcol2
sh1bcol:
	move.w	shot1x,d7
	move.w	myheight,d6
	sub.w	shot1z,d6
	move.w	shot1y,coly
	bsr	colmath2
	tst.w	d5
	bpl	shotcol2
	move.w	#-1,shot1avail
shotcol2:
scback:
	rts

shot1avail:	blk.w	1,-1
shot1x:		blk.w	1,0
shot1y:		blk.w	1,0
shot1z:		blk.w	1,0
coly:		blk.w	1,0
*****************************************
*	heli collisions			*
*	with buildings			*
*	call with d7=x			*
*	d6=height			*
*	a0=y				*
*****************************************
helicollision:
	moveq	#0,d5
	move.w	masterx,d7
	move.w	myheight,d6
	sub.w	#100,d6
	move	#0,coly
	bsr	colmath
	tst.w	d5
	bpl	helicolback
	move.w	#-1,helidead
helicolback:
	rts


colmath:
	cmp.w	b1height,d6
	bgt	helic2
	move.w	b1x,d0		;get build x and y
	add.w	d7,d0
	move.w	b1y,d1
	move.w	b1xl,d2
	move.w	b1yl,d3
	bsr	hcsub
	tst.w	d5
	bmi	helic7

helic2:
	cmp.w	b2height,d6
	bgt	helic3
	move.w	b2x,d0		;get build x and y
	add.w	d7,d0
	move.w	b2y,d1
	move.w	b2xl,d2
	move.w	b2yl,d3
	bsr	hcsub
	tst.w	d5
	bmi	helic7
helic3:
	cmp.w	b3height,d6
	bgt	helic4
	move.w	b3x,d0		;get build x and y
	add.w	d7,d0
	move.w	b3y,d1
	move.w	b3xl,d2
	move.w	b3yl,d3
	bsr	hcsub
	tst.w	d5
	bmi	helic7
helic4:
	cmp.w	b4height,d6
	bgt	helic5
	move.w	b4x,d0		;get build x and y
	add.w	d7,d0
	move.w	b4y,d1
	move.w	b4xl,d2
	move.w	b4yl,d3
	bsr	hcsub
	tst.w	d5
	bmi	helic7
helic5:
	cmp.w	b5height,d6
	bgt	helic6
	move.w	b5x,d0		;get build x and y
	add.w	d7,d0
	move.w	b5y,d1
	move.w	b5xl,d2
	move.w	b5yl,d3
	bsr	hcsub
	tst.w	d5
	bmi	helic7
helic6:
	cmp.w	b6height,d6
	bgt	helic7
	move.w	b6x,d0		;get build x and y
	add.w	d7,d0
	move.w	b6y,d1
	move.w	b6xl,d2
	move.w	b6yl,d3
	bsr	hcsub
*	tst.w	d5
*	bmi	helic7
helic7:
	rts

hcsub:
	move.w	d0,d4		;copy x and y
	move.w	d1,d5
	sub.w	d2,d0
	sub.w	d3,d1
	cmp.w	coly,d1
	bgt	hcback
	cmp.w	#0,d0
	bgt	hcback
	add.w	d2,d4
	add.w	d3,d5
	cmp.w	coly,d5
	blt	hcback
	cmp.w	#0,d4
	blt	hcback
hct:	move.w	#-1,d5
	rts
hcback:
	move.w	#1,d5
	rts

hcsub2:
	move.w	d0,d4		;copy x and y
	move.w	d1,d5
	sub.w	d2,d0
	sub.w	d3,d1
	cmp.w	coly,d1
	bgt	hcback2
	cmp.w	d7,d0
	bgt	hcback2
	add.w	d2,d4
	add.w	d3,d5
	cmp.w	coly,d5
	blt	hcback2
	cmp.w	d7,d4
	blt	hcback2
hct2:	move.w	#-1,d5
	rts
hcback2:
	move.w	#1,d5
	rts

colmath2:
	cmp.w	b1height,d6
	bgt	helic2b
	move.w	b1x,d0		;get build x and y
	move.w	b1y,d1
	move.w	b1xl,d2
	move.w	b1yl,d3
	bsr	hcsub2
	tst.w	d5
	bmi	helic7b

helic2b:
	cmp.w	b2height,d6
	bgt	helic3b
	move.w	b2x,d0		;get build x and y
	move.w	b2y,d1
	move.w	b2xl,d2
	move.w	b2yl,d3
	bsr	hcsub2
	tst.w	d5
	bmi	helic7b
helic3b:
	cmp.w	b3height,d6
	bgt	helic4b
	move.w	b3x,d0		;get build x and y
	move.w	b3y,d1
	move.w	b3xl,d2
	move.w	b3yl,d3
	bsr	hcsub2
	tst.w	d5
	bmi	helic7b
helic4b:
	cmp.w	b4height,d6
	bgt	helic5b
	move.w	b4x,d0		;get build x and y
	move.w	b4y,d1
	move.w	b4xl,d2
	move.w	b4yl,d3
	bsr	hcsub2
	tst.w	d5
	bmi	helic7b
helic5b:
	cmp.w	b5height,d6
	bgt	helic6b
	move.w	b5x,d0		;get build x and y
	move.w	b5y,d1
	move.w	b5xl,d2
	move.w	b5yl,d3
	bsr	hcsub2
	tst.w	d5
	bmi	helic7b
helic6b:
	cmp.w	b6height,d6
	bgt	helic7b
	move.w	b6x,d0		;get build x and y
	move.w	b6y,d1
	move.w	b6xl,d2
	move.w	b6yl,d3
	bsr	hcsub2
helic7b:
	rts

helidead:	blk.w	1,0
bottom:		equ	300
top:		equ	-300
dspeed:		equ	4
myheight:	blk.w	1,0
masterx:	blk.w	1,0
view_b1:	blk.w	50,0
view_b2:	blk.w	50,0
view_b3:	blk.w	50,0
view_b4:	blk.w	50,0
view_b5:	blk.w	50,0
view_b6:	blk.w	50,0
view_road:	blk.w	50,0
view_at1:	blk.w	50,0
view_at2:	blk.w	50,0
view_at3:	blk.w	50,0
view_at4:	blk.w	50,0
view_at5:	blk.w	50,0
view_at6:	blk.w	50,0
view_shot1:	blk.w	50,0
view_shot2:	blk.w	50,0
counter:	blk.w	1,0
b1x:		blk.w	1,0
b1y:		blk.w	1,0
b2x:		blk.w	1,0
b2y:		blk.w	1,0
b3x:		blk.w	1,0
b3y:		blk.w	1,0
b4x:		blk.w	1,0
b4y:		blk.w	1,0
b5x:		blk.w	1,0
b5y:		blk.w	1,0
b6x:		blk.w	1,0
b6y:		blk.w	1,0
b1xl:		blk.w	1,0
b1yl:		blk.w	1,0
b1height:	blk.w	1,0
b2xl:		blk.w	1,0
b2yl:		blk.w	1,0
b2height:	blk.w	1,0
b3xl:		blk.w	1,0
b3yl:		blk.w	1,0
b3height:	blk.w	1,0
b4xl:		blk.w	1,0
b4yl:		blk.w	1,0
b4height:	blk.w	1,0
b5xl:		blk.w	1,0
b5yl:		blk.w	1,0
b5height:	blk.w	1,0
b6xl:		blk.w	1,0
b6yl:		blk.w	1,0
b6height:	blk.w	1,0

b1image:	blk.l	1,0
b2image:	blk.l	1,0
b3image:	blk.l	1,0
b4image:	blk.l	1,0
b5image:	blk.l	1,0
b6image:	blk.l	1,0
roadx:		blk.w	1,0
roady:		blk.w	1,0

cint:
	addq.w	#1,counter
	cmpi.w	#50,counter
	blt	cintback
	bsr	printscore
	move.w	#0,counter
	move.w	#0,score
cintback:
	rts

colorint:
	move.w	blade1,d0
	move.w	blade2,blade1
	move.w	d0,blade2
	move.w	blade1,$ff824e
	move.w	blade2,$ff8250
	rts	

pointsf:blk.w	1,1
linesf:	blk.w	1,1
polyf:	blk.w	1,1
**********************************************

mypolytest:
	move.l	#polyvert,a0
	move.w	#3,(a0)+
	move.w	#100,(a0)+	;x1
	move.w	#150,(a0)+	;y1
	move.w	#300,(a0)+	;x2
	move.w	#150,(a0)+	;y2
	move.w	#200,(a0)+	;x3
	move.w	#20,(a0)+	;y3
	move.w	#100,(a0)+	;x4		      ^
	move.w	#150,(a0)+	;y4	last is first |

mypolygon:
	bsr	initsortlist 
	move.l	#polyvert,a0	;get ad of polydata
	move.w	(a0)+,d0	;get number of verts
	cmpi.w	#2,d0
	ble	mypolygonback
	bsr	sortpolyverts	;sort into y order

mypolygonback:
	rts


sortpolyverts:
	move.l	a0,a1		;copy add of verts
	move.w	d0,d1		;copy num of verts
	moveq	#0,d2		;count for lines saved
	subq.w	#1,d1		;sub 1 because we do one out of loop
	move.w	(a1)+,d6	;get first x
	move.w	(a1)+,d7	;get first y
spl:
	move.w	(a1)+,d4	;get next x
	move.w	(a1)+,d5	;get next y
	cmp.w	d7,d5		;cmp the two y's
	beq	spl2		;ignore horizontal lines
	bsr	insertvert	;otherwise put it in proper place
	move.w	d4,d6		;x1=x2
	move.w	d5,d7		;y1=y2
	addq.w	#1,d2
	dbf	d1,spl
	rts
spl2:
	move.w	d4,d6		;x1=x2
	move.w	d5,d7		;y1=y2
	dbf	d1,spl
	rts

insertvert:
	move.w	d2,-(sp)
	asl.w	#1,d2		;mult by 2	
	move.l	#ymin,a2
	move.l	#ymax,a3
	move.l	#xtop,a4
	move.l	#xinc,a5
	add.w	d2,a2		;should make it end of list so far
	add.w	d2,a3		;should make it end of list so far
	add.w	d2,a4		;should make it end of list so far
	asl.w	#1,d2		;mult by 2 makes 4	
	add.w	d2,a5		;should make it end of list so far
	cmp.w	d7,d5
	blt	ins2
	bsr	calcdx1
	move.w	d7,d3		;make d7 ymin
	move.w	d4,d2		;d2 is xtop
	move.w	d5,a6		;a6 has ymax
	bra	insl
ins2:
	move.w	d6,d2
	bsr	calcdx2
	move.w	d5,d3		;make d5 ymin
	move.w	d7,a6
insl:
	cmp.w	(a2),d3
	bgt	insl2
	move.w	(a2),2(a2)
	move.w	(a3),2(a3)
	move.w	(a4),2(a4)
	move.l	(a5),4(a5)
	move.w	d3,(a2)		;put in ymin
	move.w	a6,(a3)		;ymax
	move.w	d2,(a4)		;x associated with ymin
	move.l	longxy,(a5)		;xinc
	move.w	(sp)+,d2	;restore d2
	rts			;and return
insl2:
	subq.w	#2,a2		;move up to next y
	subq.w	#2,a3		;move up to next y
	subq.w	#2,a4		;move up to next y
	subq.w	#4,a5		;move up to next y
	bra	insl

calcdx1:
	movem.w	d4-d7,-(sp)
	sub.w	d5,d7		;gives	y2-y1
	sub.w	d4,d6	
	swap	d6		;top half has dx
	move.w	d7,d6		;bottom half has dy
	move.l	d6,longxy
	movem.w	(sp)+,d4-d7
	rts
calcdx2:
	movem.w	d4-d7,-(sp)
	sub.w	d7,d5		;gives	y2-y1
	sub.w	d6,d4	
	swap	d4		;top half has dx
	move.w	d7,d4		;bottom half has dy
	move.l	d4,longxy
	movem.w	(sp)+,d4-d7
	rts
longxy:	blk.l	1,0

*************************************************
*    just fill sortlist with max possible y	*
*************************************************
initsortlist:
	move.l	#ymin,a0
	move.w	#1024,(a0)+
	move.w	#1024,(a0)+
	move.w	#1024,(a0)+
	move.w	#1024,(a0)+
	move.w	#1024,(a0)+
	move.w	#1024,(a0)+
	move.w	#1024,(a0)+
	move.w	#1024,(a0)+
	move.w	#1024,(a0)+
	move.w	#1024,(a0)+
	move.w	#1024,(a0)+
	move.w	#1024,(a0)+
	move.w	#1024,(a0)+
	move.w	#1024,(a0)+
	move.w	#1024,(a0)+
	move.w	#1024,(a0)+
	move.w	#1024,(a0)+
	move.w	#1024,(a0)+
	move.w	#1024,(a0)+
	move.w	#1024,(a0)+
	rts

polyvert:	blk.w	100,0	;room for 48 verts
ymax:		blk.w	100,0
ymin:		blk.w	100,0
xtop:		blk.w	100,0
xinc:		blk.w	100,0

optest:
	move.l	ptsin,a0
	move.w	#100,(a0)+
	move.w	#20,(a0)+
	move.w	#320,(a0)+
	move.w	#25,(a0)+
	move.w	#200,(a0)+
	move.w	#199,(a0)+
*	move.w	mx,(a0)+
*	move.w	my,(a0)+
	move.w	#100,(a0)+
	move.w	#20,(a0)+
	move.w	#0,(a0)+
	move.w	#0,(a0)+	;x-y params

	move.l	linepar,a0
	move.l	4(a0),a6	;contrl
	move.w	#3,2(a6)	;num of coord pairs
	move.w	#1,24(a0)
	move.w	#1,26(a0)
	move.w	#1,28(a0)
	move.w	#1,30(a0)	;planes
	move.w	#0,36(a0)	;wrtmode
	move.l	#dumpat,46(a0)	;patptr
	move.w	#0,50(a0)	;patmsk
	move.w	#0,54(a0)
	move.w	#96,56(a0)
	move.w	#10,58(a0)
	move.w	#303,60(a0)
	move.w	#189,62(a0)
	move.w	#199,d7
	move.w	#0,40(a0)
	move.w	#0,52(a0)

opl:
	move.l	linepar,a0
	addq.w	#1,40(a0)
	move.w	40(a0),y1
	move.w	d7,-(sp)
	bsr	mypoloy
*	dc.w	$a006
	move.w	(sp)+,d7
	dbf	d7,opl
	rts
	
dumpat:	dc.w	$ffff

mypoloy:
FC9DAC:
	MOVE.L $0000293E,A0	;add of cntrl
	MOVE.W  $0002(A0),D0	;num verts in poly
	SUBQ.W  #1,D0		;sub 1 from above
	MOVE.L $00002946,A0	;add of ptsin
	LEA     $0000167A,A1	;???????maybe temp storage
	MOVE.W  #$0000,$000025BE;???????

*i beleive this to be the sort routine

FC9DCC:	MOVE.W  $0006(A0),D1	;y2 of vertices in d1
	MOVE.W  $0002(A0),D2	;y1 of vertices in d2
	SUB.W   D2,D1		;sub y1 from y2
	BEQ.S   FC9E0E		;bra there
	MOVE.W  $00002962,D3	;get y1 (not from ptsin)
	MOVE.W  D3,D4		;copy y1
	SUB.W   D2,D4		;sub y1 from vert from y1 scanlin
	SUB.W   $0006(A0),D3	;sub y2 of verts from y1 scanlin
	MOVE.W  D4,D2		;copy result from above
	EOR.W   D3,D2
	BPL.S   FC9E0E		;bra there again move along list of vert?
	MOVE.W  $0004(A0),D2	;get x2 from ptsin
	SUB.W   $0000(A0),D2	;sub x1 from x2
	ASL.W   #1,D2		;mult by 2
	MULS    D2,D4		;mult d4 by d2
	DIVS    D1,D4		;div d4 by d1
	BMI     FC9EAC		;bra there
	ADDQ.W  #1,D4
	ASR.W   #1,D4		;mult by 2
FC9E02: ADD.W   (A0),D4		;add x1 to d4
	MOVE.W  D4,(A1)+	;i think put in temp storage?????
	ADDQ.W  #1,$000025BE	;not too sure?????
FC9E0E:
*	LEA     $0004(A0),A0	; buggered(should be add of x2 in ptsin)
	addq.l	#4,a0
	DBRA    D0,FC9DCC
	MOVE.W  $000025BE,D0	;must be number of ????h line segments?
	BNE.S   FC9E20		;ok to go ahead
	RTS			;all done
********************************************
*	unclipped draw routine
********************************************
FC9E20: LEA     $0000167A,A0	;temp storage mabe x1,x2 etc for hline
	BSR     FC9EB8		;it may be a sort
	MOVE.W  $000025BE,D0	;get num of hline segs again???
	ASR.W   #1,D0		;mult by 2
	SUBQ.W	#1,D0		;dbf purposes i guess
	TST.W   $00002970	;clipping flag
	BNE.S   FC9E5A		;anything but zero and clip
FC9E3C: MOVE.W  (A1)+,x1	;x1 coord in linparams
	MOVE.W  (A1)+,x2	;x2 coord "   "
	MOVE.W  D0,-(A7)	;save d0
	MOVE.L  A1,-(A7)	;save a1
FC9E4C: ;jSR     $00FCA2DE	;draw hline routine
	jSR     myhline		;draw hline routine
	MOVE.L (A7)+,A1	;preserve a1 and d2
	MOVE.W  (A7)+,D0
	DBRA    D0,FC9E3C	;do any more h lines
	RTS			;all done

*************************************************
*	clip routine				*
*************************************************
FC9E5A: MOVE.W  (A1)+,$00002960	;x1 in linepar

	MOVE.W  (A1)+,$00002964	;x2 in linepar
	MOVE.W  $00002972,D1	;min x clipping value in linepar
	MOVE.W  $00002960,D2	;x1
	MOVE.W  $00002964,D3	;x2
	CMP.W   D1,D2
	BGE.S   FC9E86
	CMP.W   D1,D3
	BLT.S   FC9EA6
	MOVE.W  D1,$00002960	;put clip value into x1

FC9E86: MOVE.W  $00002976,D1	;max x clip

	CMP.W   D1,D3
	BLE.S   FC9E9A
	CMP.W   D1,D2
	BGT.S   FC9EA6
	MOVE.W  D1,$00002964	;put clipped into x2
FC9E9A: MOVE.W  D0,-(A7)	;save d0
	MOVE.L  A1,-(A7)	;save a1
*FC9E9E: jSR     $00FCA2DE	;bsr draw hline
	jSR     myhline		;bsr draw hline
	MOVE.L (A7)+,A1	;restore registers
	MOVE.W  (A7)+,D0	;
FC9EA6: DBRA    D0,FC9E5A
	RTS			;alldone

***********************************************                           
FC9EAC: NEG.W   D4

	ADDQ.W  #1,D4
	ASR.W   #1,D4
	NEG.W   D4
	BRA     FC9E02

*********************************************************
*	perhaps some sort routine             		*
*********************************************************
FC9EB8: TST.W   D0		;test num of hline segs???
	BEQ.S   FC9EDE
	SUBQ.W  #1,D0		;for dbf purpose i assume
	BEQ.S   FC9EDE
	SUBQ.W  #1,D0		;beats me
	MOVE.W  D0,D1		;strange????
	MOVE.L A0,A1
FC9EC6: MOVE.W  D1,D0
	MOVE.L A1,A0
FC9ECA: MOVE.W  (A0)+,D2
	CMP.W   (A0),D2
	BLE.S   FC9ED6
	MOVE.W  (A0),-2(A0)	;some sort of sort perhaps?
	MOVE.W  D2,(A0)
FC9ED6: DBRA    D0,FC9ECA
	DBRA    D1,FC9EC6
FC9EDE: RTS			;finished get here due to erl test


*****************************************************************
*	my 3d routines						*
*****************************************************************
view:	blk.l	1,0
object:	blk.l	1,0
numsav:	blk.w	1,0
viewsav:
	blk.w	1,0
linesav:
	blk.l	1,0
plx:	blk.w	1,0
ply:	blk.w	1,0
plz:	blk.w	1,0
xoffs:	blk.w	1,0
yoffs:	blk.w	1,0
zoffs:	blk.w	1,0
***************************************************************************
*		PLOT AN OBJECT
*		On entry, a4 = pointer to object defintion
*		Plota 3-D object on the screen.
***************************************************************************
plot_obj:
	move.l	view_pb,view
	bsr	init_vtrans
	move.l	view,a6
	move.l	a6,viewsav
	move.l	object,a4	;object definition address
	move.w	(a4)+,d6 	;Get number of verticies in object
	move.l	(a4)+,a3 	;Point to verticies
	move.w	(a4)+,d0 	;Get type of object
	addq.w	#2,a4
	move.l	(a4),a4
	bsr	trans_vert	;Transform verticies
	bsr	drawit
	rts

*****************************************************************
*	Note the type definitions are as follows, dude.		*
*	0= Normal wireframe	*implemented 4/4/88		*
*	1= Hidden wireframe	*not yet implemented		*
*	2= Filled polygon	*not yet implemented		*
*	3= Filled squares	*implemented 4/4/88		*	
*****************************************************************
drawit:
	move.l	a0,a6		;add of transformed vertices
	move.l	object,a4	;object definition address
	addq.l	#6,a4		;pass first params
	move.w	(a4)+,d0 	;Get type of object
	beq	wireframe	;if 0 then normal wireframe
	cmpi.w	#3,d0
	beq	squares		;if 3 then its a sqaure
	rts		;else return due to no other implementations

wireframe:
	move.w	(a4)+,d7 	;number of lines
	subq.w	#1,d7
	move.l	(a4),a5		;address of connection info

wire:	move.w	(a5)+,d4	;start of line seg
	move.w	(a5)+,d5	;end of line segment
	asl.w	#2,d4		;mult by 4
	asl.w	#2,d5
	move.w	(a6,d4.w),x1
	move.w	2(a6,d4.w),y1
	move.w	(a6,d5.w),x2
	move.w	2(a6,d5.w),y2
*	bsr	clipit
	dbf	d7,wire
	rts

squares:
	move.w	(a4)+,d7 	;number of sqaures
	subq.w	#1,d7
	move.l	(a4),a5		;address of connection info
square:
	tst.w	(a5)+
	bmi	sqno
	move.w	(a5)+,reccolor	;get the color
	move.w	(a5)+,d4	;start of line seg
	move.w	(a5)+,d5	;end of line segment
	asl.w	#2,d4		;mult by 4
	asl.w	#2,d5
	move.w	(a6,d4.w),x1
	move.w	2(a6,d4.w),y1
	move.w	(a6,d5.w),x2
	move.w	2(a6,d5.w),y2
	bsr	rectangle
	dbf	d7,square
	rts
sqno:
	addq.l	#6,a5
	dbf	d7,square
	rts

***************************************************************************
*		TRANSFORM A LIST OF VERTICIES
*		On entry,   d6 = number of verticies
*			    a3 = pointer to verticies
*		On exit ,   a0 = pointer to transformed verticies
*	Transform a list of verticies in 3-D space according to the
* 	viewing transformation.
************************************************************************
trans_vert:
	move.w	#-1,sflag
	lea.l	vtrans_vrt,a1	;Point to vertex tables
	lea.l	ptrans_vrt,a0
	move.l	a0,-(SP)
	subq	#1,d6		;Pre-decrement vertex counter
	cmpi.w	#3,d0
	beq	trvrt2
trans_vert0:
	move	(a3)+,d0	;Get x-coordinate of vertex
	add.w	plx,d0
	move	(a3)+,d1	;Get y-coordinate
	add.w	ply,d1
	move	(a3)+,d2	;Get z-coordinate
	add.w	plz,d2
	bsr	view_trans	;Apply view transformed coordinates
	add.w	xoffs,d3
	move.w	d3,(a1)+
	add.w	yoffs,d4
	move	d4,(a1)+
	add.w	zoffs,d5
	move	d5,(a1)+
	bsr	prsp_trans	;Apply perspective transformation
	move	d3,(a0)+	;Save transformed x-coordinate		
	move	d4,(a0)+	;Save transformed y-coordinate
	dbf	d6,trans_vert0
	move.l	(SP)+,a0	;Restore transformed vertex pointer
	rts

trvrt2:
	move	(a3)+,d0	;Get x-coordinate of vertex
	add.w	plx,d0
	move	(a3)+,d1	;Get y-coordinate
	add.w	ply,d1
	move	(a3)+,d2	;Get z-coordinate
	add.w	plz,d2
	bsr	view_trans	;Apply view transformed coordinates
	add.w	xoffs,d3
	move.w	d3,(a1)+
	add.w	yoffs,d4
	move	d4,(a1)+
	add.w	zoffs,d5
	move	d5,(a1)+
	tst.w	sflag
	bpl	tva
	cmpi.w	#10,d5
	ble	trvrt3
	move.w	#1,(a4)+
	addq.l	#6,a4
	move.w	#1,sflag
	bra	tvb
tva:
	move.w	#-1,sflag
tvb:	bsr	prsp_trans	;Apply perspective transformation
	move	d3,(a0)+	;Save transformed x-coordinate		
	move	d4,(a0)+	;Save transformed y-coordinate
	dbf	d6,trvrt2
	move.l	(SP)+,a0	;Restore transformed vertex pointer
	rts
trvrt3:
	move.w	#1,sflag
	move.w	#-1,(a4)+
	addq.l	#6,a4
	bsr	prsp_trans	;Apply perspective transformation
	move	d3,(a0)+	;Save transformed x-coordinate		
	move	d4,(a0)+	;Save transformed y-coordinate
	dbf	d6,trvrt2
	move.l	(SP)+,a0	;Restore transformed vertex pointer
	rts

vtrans_vrt:	blk.w	1000	;View transformed coordinates	
ptrans_vrt:	blk.w	1000	;Perspective transformed coordinates
sflag:		blk.w	1,0
****************************************0***********************************
helishad:
	dc.w	2		;number of vertices
	dc.l	shadvrt		;address of vertices
	dc.w	3		;flag for object type-3=sqare
	dc.w	1		;number of sqaures
	dc.l	shadinfo	;address of line info
shadvrt:
	dc.w	-15,10,0
	dc.w	15,-10,0
shadinfo:
	dc.w	0
	dc.w	9
	dc.w	0,1	

building1:
	dc.w	10		;number of vertices
	dc.l	b1vrt		;address of vertices
	dc.w	3		;flag for object type-3=sqare
	dc.w	5		;number of sqaures
	dc.l	b1info		;address of line info
b1vrt:
	dc.w	-90,30,0
	dc.w	50,-70,0		;shadow square

	dc.w	-70,50,0
	dc.w	70,-50,0
	dc.w	-70,50,50
	dc.w	70,-50,50
	dc.w	-70,50,100
	dc.w	70,-50,100
	dc.w	-70,50,150
	dc.w	70,-50,150

b1info:
	dc.w	0		;drawit flag
	dc.w	9		;color number
	dc.w	0,1		;first rectangle diags

	dc.w	0		;drawit flag
	dc.w	1		;color number
	dc.w	2,3		;first rectangle diags

	dc.w	0		;drawit flag
	dc.w	12		;color number
	dc.w	4,5		;first rectangle diags

	dc.w	0		;drawit flag
	dc.w	13		;color number
	dc.w	6,7		;first rectangle diags

	dc.w	0		;drawit flag
	dc.w	14		;color number
	dc.w	8,9		;first rectangle diags

building2:
	dc.w	26		;number of vertices
	dc.l	b2vrt		;address of vertices
	dc.w	3		;flag for object type-3=sqare
	dc.w	13		;number of sqaures
	dc.l	b2info		;address of line info
b2vrt:
	dc.w	-70,10,0
	dc.w	10,-70,0
	dc.w	-40,40,0
	dc.w	40,-40,0
	dc.w	-35,35,0
	dc.w	-5,5,0
	dc.w	10,-10,0
	dc.w	35,-35,0

	dc.w	-40,40,100
	dc.w	40,-40,100
	dc.w	-35,35,100
	dc.w	-5,5,100
	dc.w	10,-10,100
	dc.w	35,-35,100

	dc.w	-40,40,200
	dc.w	40,-40,200
	dc.w	-35,35,200
	dc.w	-5,5,200
	dc.w	10,-10,200
	dc.w	35,-35,200

	dc.w	-40,40,300
	dc.w	40,-40,300
	dc.w	-35,35,300
	dc.w	-5,5,300
	dc.w	10,-10,300
	dc.w	35,-35,300

b2info:
	dc.w	0
	dc.w	9
	dc.w	0,1

	dc.w	0		;drawit flag
	dc.w	1		;color number
	dc.w	2,3		;first rectangle diags
	dc.w	0		;drawit flag
	dc.w	6		;color number
	dc.w	4,5		;first rectangle diags
	dc.w	0		;drawit flag
	dc.w	6		;color number
	dc.w	6,7		;first rectangle diags

	dc.w	0		;drawit flag
	dc.w	12		;color number
	dc.w	8,9		;first rectangle diags
	dc.w	0		;drawit flag
	dc.w	6		;color number
	dc.w	10,11		;first rectangle diags
	dc.w	0		;drawit flag
	dc.w	6		;color number
	dc.w	12,13		;first rectangle diags

	dc.w	0		;drawit flag
	dc.w	13		;color number
	dc.w	14,15		;first rectangle diags
	dc.w	0		;drawit flag
	dc.w	6		;color number
	dc.w	16,17		;first rectangle diags
	dc.w	0		;drawit flag
	dc.w	6		;color number
	dc.w	18,19		;first rectangle diags

	dc.w	0		;drawit flag
	dc.w	14		;color number
	dc.w	20,21		;first rectangle diags
	dc.w	0		;drawit flag
	dc.w	6		;color number
	dc.w	22,23		;first rectangle diags
	dc.w	0		;drawit flag
	dc.w	6		;color number
	dc.w	24,25		;first rectangle diags

building3:
	dc.w	18		;number of vertices
	dc.l	b3vrt		;address of vertices
	dc.w	3		;flag for object type-3=sqare
	dc.w	9		;number of sqaures
	dc.l	b3info		;address of line info
b3vrt:
	dc.w	-70,30,0
	dc.w	25,-70,0

	dc.w	-50,50,0
	dc.w	50,-20,0
	dc.w	-45,-20,0
	dc.w	45,-50,0

	dc.w	-50,50,80
	dc.w	50,-20,80
	dc.w	-45,-20,80
	dc.w	45,-50,80

	dc.w	-50,50,160
	dc.w	50,-20,160
	dc.w	-45,-20,160
	dc.w	45,-50,160

	dc.w	-50,50,240
	dc.w	50,-20,240
	dc.w	-45,-20,240
	dc.w	45,-50,240

b3info:
	dc.w	0	;shadow
	dc.w	9
	dc.w	0,1

	dc.w	0
	dc.w	1
	dc.w	2,3
	dc.w	0
	dc.w	1
	dc.w	4,5

	dc.w	0
	dc.w	12
	dc.w	6,7
	dc.w	0
	dc.w	12
	dc.w	8,9

	dc.w	0
	dc.w	13
	dc.w	10,11
	dc.w	0
	dc.w	13
	dc.w	12,13

	dc.w	0
	dc.w	14
	dc.w	14,15
	dc.w	0
	dc.w	14
	dc.w	16,17

tank1:
	dc.w	10		;number of vertices
	dc.l	t1vrt		;address of vertices
	dc.w	0		;flag for object type-0=wire
	dc.w	13		;number of sqaures
	dc.l	t1lines		;address of line info

t1vrt:
	dc.w	-10,6,0
	dc.w	10,6,0
	dc.w	10,-6,0
	dc.w	-10,-6,0
	dc.w	8,4,6
	dc.w	8,-4,6
	dc.w	6,2,4
	dc.w	6,-2,4
	dc.w	-8,-2,4
	dc.w	-8,2,4

t1lines:
	dc.w	0,1
	dc.w	1,2
	dc.w	2,3
	dc.w	3,0
	dc.w	1,4
	dc.w	4,5
	dc.w	5,2
	dc.w	4,0
	dc.w	5,3
	dc.w	6,7
	dc.w	7,8
	dc.w	8,9
	dc.w	9,6
road:
	dc.w	2		;number of vertices
	dc.l	roadvrt		;address of vertices
	dc.w	3		;flag for object type-0=wire
	dc.w	1		;number of sqaures
	dc.l	roadinfo	;address of line info

roadvrt:
	dc.w	-300,-40,0
	dc.w	300,40,0
roadinfo:
	dc.w	0
	dc.w	12
	dc.w	0,1

shot1image:
	dc.w	4		;number of vertices
	dc.l	shot1vrt	;address of vertices
	dc.w	3		;flag for object type-0=wire
	dc.w	2		;number of sqaures
	dc.l	shot1lines	;address of line info
shot1vrt:
	dc.w	-3,3,0
	dc.w	3,2,0
	dc.w	-3,-2,0
	dc.w	3,-3,0

shot1lines:
	dc.w	0
	dc.w	15
	dc.w	0,1

	dc.w	0
	dc.w	15
	dc.w	2,3

*******************************
*		VIEW TRANSFORM ON A VERTEX
*		On entry, d0 = x-coordinate of vertex
*			  d1 = y-coordinate of vertex
*			  d2 = z-coordinate of vertex
*		On exit , d3 = x-coordinate view transformed
*			  d4 = y-coordinate view transformed
*			  d5 = z-coordinate view transformed
*		Apply the view transform to a vertex.
********************************
view_trans:
	move.l	viewsav,a5
	move	d0,d7		;Calculate Xe
	muls	Va(a5),d7
	move.l	d7,d3
	move	d1,d7
	muls	Vb(a5),d7
	add.l	d7,d3
	swap	d3
	rol.l	#1,d3
		
	move	d0,d7		;Calculate Ye
	muls	Ve(a5),d7
	move.l	d7,d4
	move	d1,d7
	muls	Vf(a5),d7
	add.l	d7,d4
	move	d2,d7
	muls	Vg(a5),d7
	add.l	d7,d4
	swap	d4
	rol	#1,d4
		
	move	d0,d7		;Calculate Ze
	muls	Vi(a5),d7
	move.l	d7,d5
	move	d1,d7
	muls	Vj(a5),d7
	add.l	d7,d5
	move	d2,d7
	muls	Vk(a5),d7
	add.l	d7,d5
	swap	d5
	rol.l	#1,d5
	add	Vl(a5),d5
	rts
		
***************************************************************************
*		PERSPECTIVE TRANSFORM
*		On entry, d3 = view transformed x-coordinate
*			  d4 = view transformed y-coordinate
*			  d5 = view transformed z-coordinate
*		On exit , d3 = screen x-coordinate ( Xe )
*			  d4 = screen y-coordinate ( Ye )
*	Calculate the screen coordinates of the vertex. The coordinates are
* 	centered about the centre of the screen.
*	Note, the distance to the screen is 2048.
***************************************************************************
prsp_trans:
	swap	d3		;Calculate Xs
	clr	d3		
	asr.l	#8,d3		;amount of perspective	  
*	asr.l	#1,d3		;ie field of view
	divs	d5,d3
		
	swap	d4		;Calculate Ys
	clr	d4
	asr.l	#8,d4
*	asr.l	#1,d4
	divs	d5,d4

	add	centrex,d3	;Adjust for centre of screen
	add	centrey,d4
	rts

centrex:	blk.w	1,0
centrey:	blk.w	1,0
***************************************************************************
*		VIEW PARAMETER BLOCK
*	This is the parameter block for the view coordinate system
* 	and view transformation.

view_pb:blk.l	1,0		;Parameter block declaration
rho:	equ	0
theta:	equ	2
phi:	equ	4
s_theta:equ	6
c_theta:equ	8
s_phi:	equ	10
c_phi:	equ	12
va:	equ	14
vb:	equ	16
Ve:	equ	18
Vf:	equ	20
Vg:	equ	22
Vi:	equ	24
Vj:	equ	26
Vk:	equ	28
Vl:	equ	30
***************************************************************************
*		INITIALISE VIEW TRANSFORM
*	Initialise the viewing transformation.
**************************************************************************
init_vtrans:
	move.l	view,a5		;Point to parameter block
	move	theta(a5),d3	;Calculate SIN amd COS theta
	bsr	trig
	move	d4,s_theta(a5)
	move	d5,c_theta(a5)
	neg	d4		;Calcualte Va and Vb
	move	d4,Va(a5)
	move	d5,Vb(a5)
	move	phi(a5),d3	;Calculate SIN and COS phi
	bsr	trig
	move	d4,s_phi(a5)
	move	d5,c_phi(a5)
	move	d4,-(SP)	;Save SIN and COS phi
	move	d5,-(SP)
	neg	d5		;calculate Vg and Vk
	move	d4,Vg(a5)
	move	d5,Vk(a5)
	muls	c_theta(a5),d5  ;Calculate Ve
	swap	d5
	rol.l	#1,d5
	move	d5,Ve(a5)
	muls	c_theta(a5),d4  ;Calculate Vi
	swap	d4
	rol.l	#1,d4
	neg	d4
	move	d4,Vi(a5)
	move	(SP)+,d5	;Restore SIN and COS phi
	move	(SP)+,d4
	muls	Va(a5),d5	;Calculate Vf
	swap	d5
	rol.l	#1,d5
	move	d5,Vf(a5)
	muls	Va(a5),d4	;Calculate Vj
	swap	d4
	rol.l	#1,d4
	move	d4,Vj(a5)
	move	rho(a5),Vl(a5)	;Calculate Vl
	rts

***************************************************************************
*		CALCULATE SINE AND COSINE OF ANGLE
*		On entry, d3 = angle
*		On exit ,   d4 = sine of angle
*			    d5 = cosine of angle
*	Find the sine and cosine of an angle.
**************************************************************************
trig:	addi.w	#$40,d3		;Find cCOS of angle
	bsr	find_sin
	move	d4,d5
	subi.w	#$40,d3		;Find SIN of angle
	bsr	find_sin
	rts
		
***************************************************************************
*		FIND SINE OF AN ANGLE
*		On entry, d3 = angle
*		On exit ,   d5 = cosine of angle 
*	Find the cosine of an angle. The value of the sign is a 16 bit
* 	signed number.
*	Note, to scale down, divide by 15 bits, ie &8000.
*************************************************************************
find_cos:
	move	d4,-(SP)	;Save SIN
	move	d3,-(SP)	;Save angle
	addi.w	#$40,d3		;Find COS of angle
	bsr	find_sin
	move	d4,d5
		
	move	(SP)+,d3	;Restore angle
	move	(SP)+,d4	;Restore SIN
	rts	
***************************************************************************
*		FIND THE SIN OF AN ANGLE
*		On entry, d3 = angle
*		On exit ,   d4 = SIN of angle
*	Find the SIN of an angle. The value of the sign is a 16 bit
* 	signed number.
*	Note, to scale down, divide by 15 bits, ie &8000.
*************************************************************************
find_sin:
	move	d3,-(SP)	;Save angle	
	and.l	#$7F,d3		;Move to quadrants 1 and 2
	btst	#6,d3		;Test if in 1st quadrant
	beq	quad0		;Branch if in 1st quadrant
	bclr	#6,d3		;Reflect angle into 1st quadrant
	subi.b	#$3F,d3
	neg.b	d3
		
quad0:	asl	#1,d3		;Get value of SIN from table
	lea.l	sin_vt,a6
	move	0(a6,d3),d4
	move	(SP)+,d3
	btst	#7,d3		;Adjust value if 3rd or 4th quadrant
	beq	quad1
	neg	d4		;Negate SIN value
quad1:	rts

***************************************************************************
*		SIN LOOK UP TABLE
*	This is the SIN value look up table. Values for the 1st quadrant
* are given only. The values range from 0 - 32758 for angles 0 - 63.
* Thus, the value of a sine in the 1st quadrant is a 15 bit number.
* Therefore, the table can be used to construct a 16 bit signed value of
* SIN for angles 0 - 255.
*************************************************************************
sin_vt:	dc.w	0,804,1608,2411
	dc.w	3212,4011,4808,5602
	dc.w	6393,7180,7962,8740
	dc.w	9512,10279,11039,11793
	dc.w	12540,13279,14010,14733
	dc.w	15447,16151,16846,17531
	dc.w	18205,18868,19520,20160
	dc.w	20788,21403,22006,22595
	dc.w	23170,23732,24279,24812
	dc.w	25330,25832,26320,26791
	dc.w	27246,27684,28106,28511
	dc.w	28899,29269,29622,29957
	dc.w	30274,30572,30853,31114
	dc.w	31357,31581,31786,31972
	dc.w	32138,32286,32413,32522
	dc.w	32610,32679,32729,32758



**********************************************************
reccolor:	blk.w	1,0
**********************************************************
*	my filled rectangle routine
**********************************************************
rectangle:
	movem.l	d0-d7/a0-a4,-(sp)
	move.w	x1,d2		;get x do clipping
	move.w	y1,d0		;get y
	move.w	x2,d4		;get x do clipping
	move.w	y2,d6		;get y

	cmp.w	d4,d2
	blt	pr1
	exg	d4,d2
pr1:
	cmp.w	d0,d6
	bgt	pr2
	exg	d0,d6
pr2:

	cmpi.w	#cxmin,d2
	bgt	rclip1
	move.w	#cxmin,d2
	bra	rclip2

rclip1:	cmpi.w	#cxmax,d2
	blt	rclip2
	bra	recback
			;none visible
rclip2:	cmpi.w	#cymin,d0
	bgt	rclip3
	move.w	#cymin,d0
	bra	rclip4		
rclip3:
	cmpi.w	#cymax,d0
	blt	rclip4
	bra	recback

rclip4:
	cmpi.w	#cxmin,d4
	bgt	rclip5
	bra	recback

rclip5:	cmpi.w	#cxmax,d4
	blt	rclip6
	move.w	#cxmax,d4

rclip6:	cmpi.w	#cymin,d6
	bgt	rclip7
	bra	recback

rclip7:
	cmpi.w	#cymax,d6
	blt	rclip8
	move.w	#cymax,d6
rclip8:
	move.w	d2,x1
	move.w	d4,x2	
	move.w	reccolor,d7
	bsr	init_hcol2
	move.l	ytable,a0	;add of tab with y addresses
	move.w	d0,d1		;get a copy of it
	lsl.w	#2,d0		;mult by 4
	move.l	(a0,d0.w),a0	;a0 has add of start of line
	move.w	d2,d3		;make a copy x1
	and.w	#$fff0,d2
	lsr.w	#1,d2	
	add.w	d2,a0		;a0 has add of start of line
	move.w	d4,d5		;d5 has x2
	and.w	#$fff0,d4
	lsr.w	#4,d4
	move.w	d3,d2
	and.w	#$fff0,d2
	lsr.w	#4,d2
	sub.w	d2,d4		;gives number of words across
	sub.w	d1,d6		;gives number of y
	move.l	#endmask,a1
	and.w	#15,d3
	lsl.w	#1,d3
	move.w	(a1,d3.w),d0	;d0 start mask
	move.l	#startmask,a1
	and.w	#15,d5
	lsl.w	#1,d5
	move.w	(a1,d5.w),d1	;d1 end mask
	move.l	a0,a1
*	draw the start section
	subq.w	#1,d6
drawlineloop:
	bsr	drawhline
	adda.l	#160,a1
	move.l	a1,a0
	dbf	d6,drawlineloop
recback:
	movem.l	(sp)+,d0-d7/a0-a4
	rts
*************************************************
*	Draw hline myversion			*
*************************************************#
myhline:
	movem.l	d0-d7/a0-a4,-(sp)
	move.w	reccolor,d0
	bsr	init_hcol
	move.w	x1,d2		;get x do clipping
	move.w	y1,d0		;get y
	move.w	x2,d4		;get x do clipping
*	move.w	y2,d6		;get y

	move.l	ytable,a0	;add of tab with y addresses
	move.w	d0,d1		;get a copy of it
	lsl.w	#2,d0		;mult by 4
	move.l	(a0,d0.w),a0	;a0 has add of start of line
	move.w	d2,d3		;make a copy x1
	and.w	#$fff0,d2
	lsr.w	#1,d2	
	add.w	d2,a0		;a0 has add of start of line
	move.w	d4,d5		;d5 has x2
	and.w	#$fff0,d4
	lsr.w	#4,d4
	move.w	d3,d2
	and.w	#$fff0,d2
	lsr.w	#4,d2
	sub.w	d2,d4		;gives number of words across
*	sub.w	d1,d6		;gives number of y
	move.l	#endmask,a1
	and.w	#15,d3
	lsl.w	#1,d3
	move.w	(a1,d3.w),d0	;d0 start mask
	move.l	#startmask,a1
	and.w	#15,d5
	lsl.w	#1,d5
	move.w	(a1,d5.w),d1	;d1 end mask
	move.l	a0,a1
*	draw the start section
*	subq.w	#1,d6
	bsr	drawhline
	movem.l	(sp)+,d0-d7/a0-a4
	rts

*******************
*	d0=start mask
*	d1=end mask
*	d4=words across may have to sub 1 or 2 ????
*	d6=number of y positions
*	a0=start address
*	a1=copy of a0
*	a3=color table
*******************
drawhline:
*	move.w	x2,d3
*	sub.w	x1,d3
*ble	allline	
	cmpi.w	#1,d4
	blt	allline
	beq	spechline
	bsr	drawstart
	bsr	drawmid
	bsr	drawend
	rts

spechline:
	bsr	drawstart
	bsr	drawend
	rts

drawstart:
	move.w	d0,d7
	not	d7
	and.w	d0,(a0)
	move.w	(a3),d5
	and.w	d7,d5
	or	d5,(a0)+

	and.w	d0,(a0)
	move.w	2(a3),d5
	and.w	d7,d5
	or	d5,(a0)+

	and.w	d0,(a0)
	move.w	4(a3),d5
	and.w	d7,d5
	or	d5,(a0)+

	and.w	d0,(a0)
	move.w	6(a3),d5
	and.w	d7,d5
	or	d5,(a0)+
	rts
*******************
*	d0=start mask
*	d1=end mask
*	d4=words across may have to sub 1 or 2 ????
*	d6=number of y positions
*	a0=start address
*	a1=copy of a0
*	a3=color table
*******************
drawmid:
	move.w	d4,d2	;copy width
	subq.w	#2,d2
dml:
	move.w	(a3),(a0)+
	move.w	2(a3),(a0)+
	move.w	4(a3),(a0)+
	move.w	6(a3),(a0)+
	dbf	d2,dml
	rts
drawend:
	move.w	d1,d7
	not	d7
	and.w	d1,(a0)
	move.w	(a3),d5
	and.w	d7,d5
	or	d5,(a0)+

	and.w	d1,(a0)
	move.w	2(a3),d5
	and.w	d7,d5
	or	d5,(a0)+

	and.w	d1,(a0)
	move.w	4(a3),d5
	and.w	d7,d5
	or	d5,(a0)+

	and.w	d1,(a0)
	move.w	6(a3),d5
	and.w	d7,d5
	or	d5,(a0)+
	rts
drhs:
	bsr	drawstart
	bra	drawend

allline:
*	move.w	$cccc,(a0)
*	rts
	move.w	x1,d2
	and.w	#15,d2
	move.w	x2,d5
	and.w	#15,d5
*	addq.w	#1,d5
	add.w	d2,d2
	add.w	d5,d5
*	cmp.w	d2,d5
*	bmi	drhs

	move.l	#startmask,a4
	move.w	(a4,d2.w),d0	
	move.l	#endmask,a4
	and.w	(a4,d5.w),d0	
	move.w	d0,d7
	not	d7

	and.w	d7,(a0)
	move.w	(a3),d5
	and.w	d0,d5
	or	d5,(a0)+

	and.w	d7,(a0)
	move.w	2(a3),d5
	and.w	d0,d5
	or	d5,(a0)+

	and.w	d7,(a0)
	move.w	4(a3),d5
	and.w	d0,d5
	or	d5,(a0)+

	and.w	d7,(a0)
	move.w	6(a3),d5
	and.w	d0,d5
	or	d5,(a0)+
	rts

startmask:
	dc.w	$ffff,$7fff,$3fff,$1fff
	dc.w	$0fff,$07ff,$03ff,$01ff
	dc.w	$00ff,$007f,$003f,$001f
	dc.w	$000f,$0007,$0003,$0001
	dc.w	$0000
endmask:
	dc.w	$0000,$8000,$c000,$e000
	dc.w	$f000,$f800,$fc00,$fe00
	dc.w	$ff00,$ff80,$ffc0,$ffe0
	dc.w	$fff0,$fff8,$fffc,$fffe
	dc.w	$ffff

patmsk:	dc.w	$cccc
	dc.w	$3333



cxmin:		equ	80
cxmax:		equ	255
cymin:		equ	16
cymax:		equ	183
cbits:	blk.w	1,0
cbits2:	blk.w	1,0
xsav:	blk.w	1,0
ysav:	blk.w	1,0
*dx:	blk.w	1,0
*dy:	blk.w	1,0
*/**//*/*//*//*/*//*//*/*/*//*/*/*/*//*/*/*/*//*//*//*///*/*/
bitcode:clr.l   d4
        cmpi.w  #cxmin,d0
        bge     b1
        or.b    #8,d4
b1:     cmpi.w  #cxmax,d0
        ble     b2
        or.b    #4,d4
b2:     cmpi.w  #cymin,d1
        bge     b3
        or.b    #1,d4
b3:     cmpi.w  #cymax,d1
        ble     b4
        or.b    #2,d4
b4:     move.w  d4,cbits
        rts
*****
bitc2:   clr.l   d5
        cmpi.w  #cxmin,d2
        bge     b5
        or.b    #8,d5
b5:     cmpi.w  #cxmax,d2
        ble     b6
        or.b    #4,d5
b6:     cmpi.w  #cymin,d3
        bge     b7
        or.b    #1,d5
b7:     cmpi.w  #cymax,d3
        ble     b8
        or.b    #2,d5
b8:     move.w  d5,cbits2
        rts
********************************************************
clipit:
	movem.l	d0-d7/a0,-(sp)
	move.w	x1,d0
	move.w	y1,d1
	move.w	x2,d2
	move.w	y2,d3

	bsr     bitcode
        bsr     bitc2
clipit2:or.b    d4,d5
        tst.b   d5
        beq     cliphome        ;finish if
        move.w  cbits,d4
        move.w  d2,xsav
        move.w  d3,ysav
        move.w  cbits2,d5
clip1:  and.b   d4,d5
        tst.b   d5
        bgt     clipb           ;home if line completely out
        move.w  cbits,d4
        move.w  cbits2,d5
        sub.w   d0,d2           ;d1 has dx
        move.w  d2,dx
        sub.w   d1,d3           ;d3 has dy
        move.w  d3,dy
        move.w  xsav,d2
        move.w  ysav,d3
        tst.w   d4
        beq     clip2   	;if x1<xmin
        cmpi.w  #cxmin,d0 	;y1=y1+dy*(xmin-x1)/dx
        bge     c1      
        move.w  #cxmin,d7         ;put xmin in d7
        sub.w   d0,d7
        muls    dy,d7           ;multiply by dy
        divs    dx,d7
        add.w   d1,d7
        move.w  d7,d1
        move.w  #cxmin,d0         ;x1=xmin
        bra     c4
c1:     cmpi.w  #cxmax,d0         ;if x1>xmax
        ble     c2              ;y1=y1+dy*(xmax-x1)/dx
        move.w  #cxmax,d7         ;put xmax in d7
        sub.w   d0,d7
        muls    dy,d7           ;multiply by dy
        divs    dx,d7
        add.w   d1,d7
        move.w  d7,d1
        move.w  #cxmax,d0         ;x1=xmax
        bra     c4
c2:     cmpi.w  #cymin,d1         ;if y1<ymin
        bge     c3
        move.w  #cymin,d7         ;put ymin in d7
        sub.w   d1,d7
        muls    dx,d7           ;multiply by dx
        divs    dy,d7
        add.w   d0,d7
        move.w  d7,d0
        move.w  #cymin,d1         ;y1=ymin
        bra     c4
c3:     cmpi.w  #cymax,d1         ;if y1>xmax
        ble     c4
        move.w  #cymax,d7         ;put ymax in d7
        sub.w   d1,d7
        muls    dx,d7           ;multiply by dy
        divs    dy,d7
        add.w   d0,d7
        move.w  d7,d0
        move.w  #cymax,d1         ;y1=ymax
c4:     bsr     bitcode
        bra     cliploop
******
clip2:  cmpi.w  #cxmin,d2 ;	y1=y1+dy*(xmin-x1)/dx
        bge     cc1     
        move.w  #cxmin,d7         ;put xmin in d7
        sub.w   d2,d7
        muls    dy,d7           ;multiply by dy
        divs    dx,d7
        add.w   d3,d7
        move.w  d7,d3
        move.w  #cxmin,d2         ;x2=xmin
        bra     cc4
cc1:    cmpi.w  #cxmax,d2         ;if x2>xmax
        ble     cc2
        move.w  #cxmax,d7         ;put xmax in d7
        sub.w   d2,d7
        muls    dy,d7           ;multiply by dy
        divs    dx,d7
        add.w   d3,d7
        move.w  d7,d3
        move.w  #cxmax,d2         ;x1=xmax
        bra     cc4
cc2:    cmpi.w  #cymin,d3         ;if y1<ymin
        bge     cc3
        move.w  #cymin,d7         ;put ymin in d7
        sub.w   d3,d7
        muls    dx,d7           ;multiply by dx
        divs    dy,d7
        add.w   d2,d7
        move.w  d7,d2
        move.w  #cymin,d3         ;y1=ymin
        bra     cc4
cc3:    cmpi.w  #cymax,d3         ;if y1>xmax
        ble     cc4
        move.w  #cymax,d7         ;put ymax in d7
        sub.w   d3,d7
        muls    dx,d7           ;multiply by dy
        divs    dy,d7
        add.w   d2,d7
        move.w  d7,d2
        move.w  #cymax,d3         ;y1=ymax
*       bra     cliploop        
cc4:    bsr     bitc2
        bra     cliploop

cliploop:
        bra     clipit2
cliphome:
        move.w  d0,x1
        move.w  d1,y1
        move.w  d2,x2
        move.w  d3,y2
	bra	myline
clipb:
	movem.l	(sp)+,d0-d7/a0
	rts
*********************************************************
linecolor:
	blk.w	1,0
***********************************************
*	lets plot a fucking line
*	but lets do it fast
*	first some conventions
*	draws line on hiden screen
*	between x1,y1,x2,y2 
***********************************************
myline:
calcdx:
	move.w	x2,d0
	sub.w	x1,d0	;x2-x1
	move.w	d0,dx	;d0 is dx
	bpl	calcdy
	neg	d0
calcdy:
	move.w	y2,d1
	sub.w	y1,d1	;y2-y1	
	move.w	d1,dy	;d6 is dy
	bpl	cmparedxdy
	neg	d1
cmparedxdy:
	cmp.w	d0,d1
	bgt	ymajor	;if dy is greater then ymajor
xmajor:
*	tst.w	dy
*	beq	horizontal	;special case
	tst.w	dx
	bpl	noswapx
	move.w	x2,d0
	move.w	x1,x2
	move.w	d0,x1
	move.w	y2,d0
	move.w	y1,y2
	move.w	d0,y1
	neg	dx
	neg	dy
noswapx:
	move.l	#0,d0
	move.w	dx,d0
	divs	dy,d0
	bmi	xpositive

xnegative:
	move.l	hiden,a0	;screen ad
	move.w	dx,d0
	move.w	d0,d7	;counter is d7
	subq.w	#1,d7
bp:	asr.w	#1,d0	;div by 2
	move.w	d0,d6	;dump is d6
	move.w	x1,d0	;will hold bitpattern
	move.w	d0,d2
	move.w	y1,d1
	lsl.w	#5,d1	;mult y by 128
	adda.w	d1,a0	;add it to screen address
	lsl.w	#2,d1	;mult by 32 makes mult by 160
	add.w	d1,a0	;a0 now has start screen address
	and.w	#$fff0,d0	;mask off last 4 bits gives word across
	lsr.w	#1,d0
	add.w	d0,a0
	moveq	#0,d4
	tst.w	d7
	bmi	specxneg
xmnloop:
	addq.w	#1,d2
	move.w	d2,d3
	and.w	#15,d3
	bne	xmnla
	bsr	putlinein
	moveq	#0,d4
	addq.l	#8,a0
xmnla:	sub.w	#15,d3
	neg	d3
	bset	d3,d4
	sub.w	dy,d6	;sub dy from dump
	bpl	xmn
	add.w	dx,d6
	bsr	putlinein
	adda.l	#160,a0		;moveit to next line
	moveq	#0,d4
xmn:
	dbf	d7,xmnloop
specxneg:
	move.w	d2,d3
	and.w	#15,d3
	sub.w	#15,d3
	neg	d3
	bset	d3,d4
	bsr	putlinein
	movem.l	(sp)+,d0-d7/a0
	rts

putlinein:
	move.w	d4,d5
	eor.w	#$ffff,d5
	and.w	d5,(a0)		;clearout old pixels
	and.w	d5,2(a0)
	and.w	d5,4(a0)
	and.w	d5,6(a0)
	move.w	linecolor,d5
plane1:
	btst	#0,d5
	beq	plane2
	or.w	d4,(a0)
plane2:
	btst	#1,d5
	beq	plane3
	or.w	d4,2(a0)
plane3:
	btst	#2,d5
	beq	plane4
	or.w	d4,4(a0)
plane4:
	btst	#3,d5
	beq	plane5
	or.w	d4,6(a0)
plane5:
	rts



xpositive:
	move.l	hiden,a0	;screen ad
	move.w	dx,d0
	move.w	d0,d7	;counter is d7
	subq.w	#1,d7
	asr.w	#1,d0	;div by 2
	move.w	d0,d6	;dump is d6
	move.w	x1,d0	;will hold bitpattern
	move.w	d0,d2
	move.w	y1,d1
	lsl.w	#5,d1	;mult y by 128
	adda.w	d1,a0	;add it to screen address
	lsl.w	#2,d1	;mult by 32 makes mult by 160
	add.w	d1,a0	;a0 now has start screen address
	and.w	#$fff0,d0	;mask off last 4 bits gives word across
	lsr.w	#1,d0
	add.w	d0,a0
	moveq	#0,d4
xmploop:
	addq.w	#1,d2
	move.w	d2,d3
	and.w	#15,d3
	bne	xmpla
	bsr	putlinein
	moveq	#0,d4
	addq.l	#8,a0
xmpla:	sub.w	#15,d3
	neg	d3
	bset	d3,d4
	add.w	dy,d6	;sub dy from dump
	bpl	xmp
	add.w	dx,d6
	bsr	putlinein
	moveq	#0,d4
	suba.l	#160,a0		;moveit to next line
xmp:
	dbf	d7,xmploop
	move.w	d2,d3
	and.w	#15,d3
	sub.w	#15,d3
	neg	d3
	bset	d3,d4
	bsr	putlinein
	movem.l	(sp)+,d0-d7/a0
	rts

ymajor:
	tst.w	dy
	bpl	noswapy
	move.w	x2,d0
	move.w	x1,x2
	move.w	d0,x1
	move.w	y2,d0
	move.w	y1,y2
	move.w	d0,y1
	neg	dx
	neg	dy
noswapy:
	move.l	#0,d0
	move.w	dy,d0
	divs	dx,d0
	bmi	ypositive
ynegative:
	tst.w	dx
	beq	straightup1	;special case vertical line
	move.l	hiden,a0	;screen ad
	move.w	dy,d0
	move.w	d0,d7	;counter is d7
*	subq.w	#1,d7
	asr.w	#1,d0	;div by 2
	move.w	d0,d6	;dump is d6
	move.w	x1,d0	;will hold bitpattern
	move.w	d0,d3
	move.w	y1,d1
	move.w	d1,d2
	lsl.w	#5,d1	;mult y by 128
	adda.w	d1,a0	;add it to screen address
	lsl.w	#2,d1	;mult by 32 makes mult by 160
	add.w	d1,a0	;a0 now has start screen address
	and.w	#$fff0,d0	;mask off last 4 bits gives word across
	lsr.w	#1,d0
	add.w	d0,a0
	move.w	d3,d0	;x
	moveq	#0,d4
	move.w	d0,d3
	and.w	#15,d3
	move.w	#$8000,d4
	lsr.w	d3,d4
ymnloop:
	bsr	putlinein
	add.w	#160,a0	;y+1
	sub.w	dx,d6	;sub dy from dump
	bpl	ymn
	add.w	dy,d6
	addq.w	#1,d0	;x+1
	move.w	d0,d3
	and.w	#15,d3
	bne	ymnla
	addq.l	#8,a0
ymnla:	move.w	#$8000,d4
	lsr.w	d3,d4
ymn:
	dbf	d7,ymnloop
	movem.l	(sp)+,d0-d7/a0
	rts

ypositive:
	tst.w	dx
	beq	straightup	;special case vertical line
	move.l	hiden,a0	;screen ad
	move.w	dy,d0
	move.w	d0,d7	;counter is d7
	subq.w	#1,d7
	asr.w	#1,d0	;div by 2
	move.w	d0,d6	;dump is d6
	move.w	x1,d0	;will hold bitpattern
	move.w	d0,d3
	move.w	y1,d1
	move.w	d1,d2
	lsl.w	#5,d1	;mult y by 128
	adda.w	d1,a0	;add it to screen address
	lsl.w	#2,d1	;mult by 32 makes mult by 160
	add.w	d1,a0	;a0 now has start screen address
	and.w	#$fff0,d0	;mask off last 4 bits gives word across
	lsr.w	#1,d0
	add.w	d0,a0
	move.w	d3,d0	;x
	moveq	#0,d4
*	move.w	d0,d3
	and.w	#15,d3
	move.w	#$8000,d4
	lsr.w	d3,d4

ymploop:
	bsr	putlinein
	add.w	#160,a0	;y+1
	add.w	dx,d6	;sub dy from dump
	bpl	ymp
	add.w	dy,d6
	subq.w	#1,d0	;x+1
	move.w	d0,d3
	and.w	#15,d3
	cmpi.w	#15,d3
	bne	ympla
	subq.l	#8,a0
ympla:	move.w	#$8000,d4
	lsr.w	d3,d4
ymp:
	dbf	d7,ymploop
	movem.l	(sp)+,d0-d7/a0
	rts

straightup:
	move.l	hiden,a0	;screen ad
	move.w	dy,d7
	move.w	x1,d0	;will hold bitpattern
	move.w	d0,d3
	move.w	y1,d1
	lsl.w	#5,d1	;mult y by 128
	adda.w	d1,a0	;add it to screen address
	lsl.w	#2,d1	;mult by 32 makes mult by 160
	add.w	d1,a0	;a0 now has start screen address
	and.w	#$fff0,d0	;mask off last 4 bits gives word across
	lsr.w	#1,d0
	add.w	d0,a0	;now a0 is ready
	moveq	#0,d4
	and.w	#15,d3
	move.w	#$8000,d4
	lsr.w	d3,d4	;d4 has proper bit pattern
	add.l	#160,a0
stuploop:
	bsr	putlinein
	add.l	#160,a0
	dbf	d7,stuploop
	movem.l	(sp)+,d0-d7/a0
	rts	

straightup1:
	move.l	hiden,a0	;screen ad
	move.w	dy,d7
	move.w	x1,d0	;will hold bitpattern
	move.w	d0,d3
	move.w	y1,d1
	lsl.w	#5,d1	;mult y by 128
	adda.w	d1,a0	;add it to screen address
	lsl.w	#2,d1	;mult by 32 makes mult by 160
	add.w	d1,a0	;a0 now has start screen address
	and.w	#$fff0,d0	;mask off last 4 bits gives word across
	lsr.w	#1,d0
	add.w	d0,a0	;now a0 is ready
	moveq	#0,d4
	and.w	#15,d3
	move.w	#$8000,d4
	lsr.w	d3,d4	;d4 has proper bit pattern
	add.l	#160,a0

stuploop1:
	bsr	putlinein
	sub.l	#160,a0
	dbf	d7,stuploop
	movem.l	(sp)+,d0-d7/a0
	rts

dump:		blk.w	1,0
gradient:	blk.w	1,0
x1:		blk.w	1,0
x2:		blk.w	1,0
y1:		blk.w	1,0
y2:		blk.w	1,0
dx:		blk.w	1,0
dy:		blk.w	1,0
*************************************************************************
*               POLYGON WORKSPACE DECLARATION				*
***************************************************************************
poly_par:	blk.w	20,0	;Polygon parameter block
verticies:	equ	0	;number of verticies
vert_min:	equ	2	;Pointer to 1st vertex in data list
vert_max:	equ	6	;Pointer to last vertex in data list
left_vdx:	equ	10	;Left line x increment
right_vdx:	equ	14	;Right line x increment
left_vcnt:	equ	18	;Left line increment counter
right_vcnt:	equ	20	;Right line increment counter
surf_dfn:	blk.w	1,0
		dc.l	surf_vrt
surf_vrt:	blk.w	1,0
		blk.w	64,0        
***************************************************************************
*               DRAW A FILLED POLYGON
*               On entry, a6 = pointer to polygon data
*************************************************************************
draw_polygon:
        movem.l D0-D7/A0-A6,-(SP)       ;Save work registsers
        bsr     init_poly_draw          ;Initialise the polygon draw routine
draw_p0:
	swap    d3		;Correct format
        swap    d4

        movem.l  d3-d4/a6,-(SP)	;Save parameter block pointer
*        move.w  d3,d6		;Calculate start a6 address
*        move.w  d5,d7
*        bsr     calc_vsa
	bsr     draw_hline	;Connect left and right edges
        movem.l  (SP)+,d3-d4/a6

        swap    d4		;Next co-ordinates
        swap    d3
        add.l   left_vdx(a6),d3
        add.l   right_vdx(a6),d4
                
        subq.w  #1,left_vcnt(a6)	;Check if left vertex reached
        bpl     draw_p1			;Branch if <>
        subq.w  #1,verticies(a6)	;Check if finished
        bmi     draw_p3			;Branch if finished
        bsr     next_lvertex		;Calculate new vectors
        add.l   left_vdx(a6),d3
                
draw_p1:
	subq.w  #1,right_vcnt(a6)	;Check if right vertex reached
        bpl     draw_p2			;Branch if <>
        subq.w  #1,verticies(a6)	;Check if finished
        bmi     draw_p3			;Branch if finished
        bsr     next_rvertex		;Calculate new vectors
        add.l   right_vdx(a6),d4
                
draw_p2:
	addq.w  #1,d5			;Next line up
        bra     draw_p0

draw_p3:
	movem.l (SP)+,D0-D7/A0-A6
        rts				;Polygon drawn!!! I hope

***************************************************************************
*               INITIALISE POLYGON DRAW
*               On entry, a6 = polygon data pointer
*       Initialise the polygon draw routine. The 1st word of the polygon
* 	data specifies the logical color number to draw the polygon in
*	The
* 	next long word points to the vertex data.
**************************************************************************
init_poly_draw:
        move.w  (a6)+,D0	;Set color of polygon
        bsr     init_hcol
        move.l  (a6),a4		;Point to vertex data
        lea     poly_par,a6	;Point to paramter block
        bsr     find_vbase	;Set up vertex pointers
        move.w  2(a5),d5
        move.l  a5,a1
        move.l  a5,a2

        bsr     next_lvertex	;Calculate start vectors
        bsr     next_rvertex
        subq.w  #1,verticies(a6)
        subq.w  #1,verticies(a6)
        lea     hline_mask,a5	;Set up line mask pointers
        rts

***************************************************************************
*               NEW LEFT VERTEX
*               On entry, a1 = pointer to current vertex data
*               On exit ,    d3 = start x co-ordinate of line
*                          left_vdx = x co-ordinate increment
*                         left_vcnt = height of line
*************************************************************************
next_lvertex:
        move.w  (a1),d3		;Save current x co-ordinate
        ext.l   d3
        subq.l  #4,a1		;Point to destination vertex
        cmp.l   vert_min(a6),a1	;Check for wrap round
        bpl     nxt_lv0
        move.l  vert_max(a6),a1
                
nxt_lv0:
	move.w  (a1),d2		;Get destination x co-ord
        sub.w   d3,d2		;Calculate line d2
        ext.l   d2                
        move.w  2(a1),left_vcnt(a6)	;Calculate height of line
        sub.w   d5,left_vcnt(a6)
        beq     nxt_lv1
                
        move.w  left_vcnt(a6),d1
        bsr     vert_div

nxt_lv1:
	move.l  d2,left_vdx(a6)
        swap    d3         
        rts

***************************************************************************
*               NEW RIGHT VERTEX
*               On entry, a2 = pointer to current vertex data
*               On exit ,    d4 = start x co-ordinate of line
*                          right_vdx = x co-ordinate increment
*                         right_vcnt = height of line
*************************************************************************
next_rvertex:
        move.w  (a2),d4		;Save current x co-ordinate
        ext.l   d4
        addq.l  #4,a2		;Point to destination vertex
        move.l  vert_max(a6),d2	;Check for wrap round
        cmp.l   a2,d2
        bpl     nxt_rv0
        move.l  vert_min(a6),a2
nxt_rv0:
	move.w  (a2),d2		;Get destination x co-ord
        sub.w   d4,d2		;Calculate line d2
        ext.l   d2
                
        move.w  2(a2),right_vcnt(a6)	;Calculate height of line
        sub.w   d5,right_vcnt(a6)
        beq     nxt_rv1
                
        move.w  right_vcnt(a6),d1
        bsr     vert_div        

nxt_rv1:
	move.l  d2,right_vdx(a6)
        swap    d4
	rts
***************************************************************************
*               VERTEX DIVISION ROUTINE
*               On entry, d1 = bit divisor
*                          d2 = dividend
*               On exit ,  d2 = 32 bit quotient
*	Divide a 16 bit value into a signed 32 bit value giving a 32 bit
*	quotient.
*       Note, the dividend is always greter than $10000.
************************************************************************
vert_div:	bclr    #31,d1
                btst    #15,d2		;Check if dividend -ve
                beq     vert_div0	;Branch if positive
                neg     d2		;Make dividend +ve
                bset    #31,d1		;flag dividend -ve

vert_div0:	ext.l   d2
                divu    d1,d2
		move.w  d2,d0
                swap    d0
                clr     d0
                clr     d2                

                divu    d1,d2
                and.l   #$FFFF,d2
                add.l   d0,d2

                btst    #31,d1		;Check if need to fix sign
                beq     vert_div1	;Branch if dividend was +ve
                neg.l   d2		;Negate result

vert_div1:       rts

***************************************************************************
*               FIND LOWEST VERTEX
*               On entry, a4 = pointer to vertex data list
*               On exit , a5 = pointer to 1st vertex to draw from
*                         vert_min = pointer to lst vertex in list
*                         vert_max = pointer to last vertex in list
*                         d7 = number of verticies in list
**************************************************************************
find_vbase:
        move.w  (a4)+,d7		;Get number of verticies
        move.w  d7,verticies(a6)
        subq.w  #1,d7

        move.l  a4,vert_min(a6)		;1st vertex in list
                
        move.w  #1024,d6		;Initialise lowest y co-ord
        addq.l  #2,a4			;Point to y co-ordinate

fnd_vb0:
	cmp.w   (a4),d6			;Check if this vertex lower
        bmi     fnd_vb1			;Branch if <>
        move.w  (a4),d6
        move.l  a4,a5
                
fnd_vb1:
	addq.l  #4,a4			;Point to next vertex
        dbf     d7,fnd_vb0		;Loop until all vericies
	subq.l  #2,a5			;Adjust to x co-ordinate
        subq.l  #6,a4			;Adjust to last vertex
        move.l  a4,vert_max(a6)
        rts

***************************************************************************
*               DRAW A HORIZONTAL LINE
*               On entry,  d3 = start x co-ordinate
*                         d4 = end x co-ordinate
*                          a6 = a6 address of start of line
*       Registers corrupted,
*       Draw a horizontal line from left to right.
*************************************************************************
draw_hline:
		cmpi.w	#96,d3
		bge	dhc1
		move.w	#96,d3
dhc1:
		cmpi.w	#303,d4
		ble	dhc2
		move.w	#303,d4
dhc2:
		move.w	d3,d6
		move.w	d5,d7
		bsr	calc_vsa
	
		cmp.w   d3,d4		;Glitch fix
                bmi     draw_hline0

                move.w  d4,d2		;Calculate length in pixels
                sub.w   d3,d2
                addq.w  #1,d2		;d2 } length of line

                cmp.w   #16,d2		;Check for special case
                bmi     drw_hls

                jsr     draw_start	;Draw start section
                jsr     draw_mid
                jsr     draw_end
        
draw_hline0:
		rts

**************************************************************************
draw_mid:       move.w  d2,D0		;Calculate number of centre sections
                lsr.w   #4,D0
                beq     drwmid1		;Branch if no centre sections
                subq.w  #1,D0		;Pre-decrement counter
        
drwmid0:	move.w  (a3),(a6)+	;Fill 1 section
                move.w  2(a3),(a6)+
                move.w  4(a3),(a6)+
                move.w  6(a3),(a6)+
                dbf     D0,drwmid0	;Loop until centre section complete
		and.w   #15,d2
drwmid1:
		rts

**************************************************************************
*               SPECIAL CASE - DRAW ALL OF LINE
*       This is the special case when the line is less then 16 pixels
* long. In this case, the whole line is plotted as 1 section.
************************************************************************
drw_hs:		bsr     draw_start
                bra     draw_end
drw_hls:
		move.w  d3,D0
                and.w   #15,D0
                move.w  d4,D1
                and.w   #15,D1
                addq.w  #1,D1
                add.w   D0,D0
                add.w   D1,D1           

                cmp.w   D0,D1		;Check for special case
                bmi     drw_hs
                
                move.w  (a5,D0.w),D6
                and.w   34(a5,D1.w),D6
                move.w  D6,D1
                not.w   D6

                and.w   D6,(a6)		;Colour plane 0
                move.w  (a3),D0
                and.w   D1,D0
                or.w    D0,(a6)+            

                and.w   D6,(a6)		;Colour plane 1
                move.w  2(a3),D0
                and.w   D1,D0
                or.w    D0,(a6)+
                
                and.w   D6,(a6)		;Colour plane 2
                move.w  4(a3),D0
                and.w   D1,D0
                or.w    D0,(a6)+            
                
                and.w   D6,(a6)		;Colour plane 3
                move.w  6(a3),D0
                and.w   D1,D0
                or.w    D0,(a6)+
                rts

**************************************************************************
*               DRAW START SECTION OF LINE
*               On entry, A6 = a6 address
*                         D2 = length of line in pixels
*                         D3 = start x co-ordinate of line
*       Draw the start section of the horizontal line. The start section
* can be up to 15 pixels long.
***************************************************************************
draw_start:
		move.w  d3,D6		;Check pixel start position
                andi.w  #15,D6
                beq     drwstr0		;Branch if no need to draw

                move.w  D6,D7		;Subtract start section pixel length
                eor.w   #15,D7
                sub.w   D7,d2
                subq.w  #1,d2
        
                add.w   D6,D6		;calculate pixel masks
                move.w  34(a5,D6.w),D1
                move.w  D1,D7
                not.w   D7
                
                and.w   D1,(a6)		;Colour plane 0
                move.w  (a3),D6
                and.w   D7,D6
                or.w    D6,(a6)+

                and.w   D1,(a6)		;Colour plane 1
                move.w  2(a3),D6
                and.w   D7,D6
                or.w    D6,(a6)+
        
                and.w   D1,(a6)		;Colour plane 2
                move.w  4(a3),D6
                and.w   D7,D6
                or.w    D6,(a6)+

                and.w   D1,(a6)		;Colour plane 3
                move.w  6(a3),D6
                and.w   D7,D6
                or.w    D6,(a6)+

drwstr0:        rts
        
***************************************************************************
*               DRAW END SECTION OF LINE
*               On entry, A6 = a6 address
*                         D4 = end x co-ordinate of line
*       Draw the end section of the horizontal line. The end section
* can be up to 15 pixels long.
**************************************************************************
draw_end:       cmp.w   #0,d2		;Check if need to draw end section
                beq     drwend0		;Branch if no need to draw

                move.w  d4,D6
                andi.w  #15,D6
                addq.w  #1,D6
        
                add.w   D6,D6
                move.w  (a5,D6.w),D1
                move.w  D1,D7
                not.w   D7
                
                and.w   D1,(a6)		;Colour plane 0
                move.w  (a3),D6
                and.w   D7,D6
                or.w    D6,(a6)+    
                
                and.w   D1,(a6)		;Colour plane 1
                move.w  2(a3),D6
                and.w   D7,D6
                or.w    D6,(a6)+

                and.w   D1,(a6)		;Colour plane 2
                move.w  4(a3),D6
                and.w   D7,D6
                or.w    D6,(a6)+

                and.w   D1,(a6)		;Colour plane 3
                move.w  6(a3),D6
                and.w   D7,D6
                or.w    D6,(a6)+

drwend0:
		rts

***************************************************************************
*               INITIALISE HORIZONTAL LINE COLOUR
*               On entry,     D0 = a3 number
*               On exit , a3 = a3 start address
*       Initialise the a3 pointer to the correct a3 planes.
************************************************************************
init_hcol:
		asl.w   #3,D0		;index a3 table
                lea     col_table,a3
                lea     (a3,D0.w),a3 
                rts
init_hcol2:
		asl.w   #3,D7		;index a3 table
                lea     col_table,a3
                lea     (a3,D7.w),a3 
                rts
                
col_table:
		DC.w      00,00,00,00     ;Colour 0
                DC.w      -1,00,00,00     ;Colour 1
                DC.w      00,-1,00,00     ;Colour 2
                DC.w      -1,-1,00,00     ;Colour 3
                DC.w      00,00,-1,00     ;Colour 4        
                DC.w      -1,00,-1,00     ;Colour 5        
                DC.w      00,-1,-1,00     ;Colour 6        
                DC.w      -1,-1,-1,00     ;Colour 7        
                DC.w      00,00,00,-1     ;Colour 8        
                DC.w      -1,00,00,-1     ;Colour 9
                DC.w      00,-1,00,-1     ;Colour 10
                DC.w      -1,-1,00,-1     ;Colour 11
                DC.w      00,00,-1,-1     ;Colour 12
                DC.w      -1,00,-1,-1     ;Colour 13
                DC.w      00,-1,-1,-1     ;Colour 14       
                DC.w      -1,-1,-1,-1     ;Colour 15

***************************************************************************
*               MASK TABLES
*                RSRESET
**************************************************************************
even
hline_mask:
start_mask:
*		RS      17
                DC.w      $FFFF,$7FFF,$3FFF,$1FFF
                DC.w      $0FFF,$07FF,$03FF,$01FF
                DC.w      $00FF,$007F,$003F,$001F
                DC.w      $000F,$0007,$0003,$0001
                DC.w      $0000
end_mask:
*		RS      17
                DC.w      $0000,$8000,$C000,$E000
                DC.w      $F000,$F800,$FC00,$FE00
                DC.w      $FF00,$FF80,$FFC0,$FFE0
                DC.w      $FFF0,$FFF8,$FFFC,$FFFE
                DC.w      $FFFF

********************************
delay:
	move.w	#55000,d0
d:	dbf	d0,d
	rts		

putballs:
*	move.l	masterimage,a0
	move.w	d0,d2		;get copy of x
	and.w	#15,d0		;last 4 bits is offset
	move.w	d0,d3
	mulu	#240,d0
	adda.w	d0,a0		;now pointing at correct image
	move.l	a0,imageptr
*	move.l	mastermask,a0
	asr.w	#1,d0
	adda.w	d0,a0
	move.l	a0,maskptr
	move.l	hiden,a0
	lsl.w	#5,d1		;mult y by 128
	adda.w	d1,a0		;add it to screen address
	lsl.w	#2,d1		;mult by 32 makes mult by 160
	add.w	d1,a0
	and.w	#$fff0,d2	;mask off last 4 bits gives word across
	lsr.w	#1,d2
	adda.w	d2,a0
	move.l	a0,screenloc
	move.w	#1,width
	move.w	#15,height
	bsr	pdrawimage
	rts
*****************************************
myreset:
	rts
*****************************************
ramware:
	move.w	#0,let1c
	move.w	#326,let2c
	move.w	#308,let3c
	move.w	#290,let4c
	move.w	#272,let5c
	move.w	#254,let6c
	move.w	#236,let7c
	rts

rw2:
	bsr	clearfast
*	bsr	clearsmall
	bsr	doletters
	bsr	keyboard
	bsr	flip2
	tst.w	buttondat
	beq	rw2
	rts

clearsmall:
	move.l	hiden,a0
	add.l	#56,a0
	move.w	#36,d7
clsm:
	move.l	#0,(a0)+
	move.l	#0,(a0)+
	move.l	#0,(a0)+
	move.l	#0,(a0)+
	move.l	#0,(a0)+
	move.l	#0,(a0)+
	move.l	#0,(a0)+
	move.l	#0,(a0)+
	move.l	#0,(a0)+
	move.l	#0,(a0)+
	move.l	#0,(a0)+
	move.l	#0,(a0)+
	move.l	#0,(a0)+
	move.l	#0,(a0)+
	move.l	#0,(a0)+
	move.l	#0,(a0)+
	move.l	#0,(a0)+
	move.l	#0,(a0)+
	move.l	#0,(a0)+
	move.l	#0,(a0)+
	move.l	#0,(a0)+
	move.l	#0,(a0)+
	move.l	#0,(a0)+
	move.l	#0,(a0)+
	add.w	#64,a0
	dbf	d7,clsm
	rts

doletters:
	move.l	#rampat,a0
	move.w	let1c,d0
	cmpi.w	#344,d0
	blt	dl1
	move.w	#0,let1c
dl1:
	asl.w	#2,d0		;mul by 4
	move.w	(a0,d0.w),d2	;thats x
	move.w	2(a0,d0.w),d1	;thats y
	add.w	#100,d1
	move.l	#rsprite,spblock+8
	bsr	doit		;put the sucker up
	addq.w	#1,let1c
*	rts

	move.l	#rampat,a0
	move.w	let2c,d0
	cmpi.w	#344,d0
	blt	dl2
	move.w	#0,let2c
dl2:
	asl.w	#2,d0		;mul by 4
	move.w	(a0,d0.w),d2	;thats x
	move.w	2(a0,d0.w),d1	;thats y
	add.w	#100,d1
	move.l	#asprite,spblock+8
	bsr	doit		;put the sucker up
	addq.w	#1,let2c

	move.l	#rampat,a0
	move.w	let3c,d0
	cmpi.w	#344,d0
	blt	dl3
	move.w	#0,let3c
dl3:
	asl.w	#2,d0		;mul by 4
	move.w	(a0,d0.w),d2	;thats x
	move.w	2(a0,d0.w),d1	;thats y
	add.w	#100,d1
	move.l	#msprite,spblock+8
	bsr	doit		;put the sucker up
	addq.w	#1,let3c

	move.l	#rampat,a0
	move.w	let4c,d0
	cmpi.w	#344,d0
	blt	dl4
	move.w	#0,let4c
dl4:
	asl.w	#2,d0		;mul by 4
	move.w	(a0,d0.w),d2	;thats x
	move.w	2(a0,d0.w),d1	;thats y
	add.w	#100,d1
	move.l	#wsprite,spblock+8
	bsr	doit		;put the sucker up
	addq.w	#1,let4c

	move.l	#rampat,a0
	move.w	let5c,d0
	cmpi.w	#344,d0
	blt	dl5
	move.w	#0,let5c
dl5:
	asl.w	#2,d0		;mul by 4
	move.w	(a0,d0.w),d2	;thats x
	move.w	2(a0,d0.w),d1	;thats y
	add.w	#100,d1
	move.l	#asprite,spblock+8
	bsr	doit		;put the sucker up
	addq.w	#1,let5c

	move.l	#rampat,a0
	move.w	let6c,d0
	cmpi.w	#344,d0
	blt	dl6
	move.w	#0,let6c
dl6:
	asl.w	#2,d0		;mul by 4
	move.w	(a0,d0.w),d2	;thats x
	move.w	2(a0,d0.w),d1	;thats y
	add.w	#100,d1
	move.l	#rsprite,spblock+8
	bsr	doit		;put the sucker up
	addq.w	#1,let6c

	move.l	#rampat,a0
	move.w	let7c,d0
	cmpi.w	#344,d0
	blt	dl7
	move.w	#0,let7c
dl7:
	asl.w	#2,d0		;mul by 4
	move.w	(a0,d0.w),d2	;thats x
	move.w	2(a0,d0.w),d1	;thats y
	add.w	#100,d1
	move.l	#esprite,spblock+8
	bsr	doit		;put the sucker up
	addq.w	#1,let7c
	rts


doit:
	move.w  d2,spblock
        move.w  d1,spblock+2
        move.w  #14,spblock+4
        move.w  #1,spblock+6
        move.l  #gtemp,spblock+12
        move.w  #1,spblock+26
        move.l  #gmask,spblock+38
	jsr	putsprite
	rts

spblock:
	blk.w	50,0
let1c:	blk.w	1,0
let2c:	blk.w	1,0
let3c:	blk.w	1,0
let4c:	blk.w	1,0
let5c:	blk.w	1,0
let6c:	blk.w	1,0
let7c:	blk.w	1,0
********************************
clearfast:
	move.l	hiden,a0
	move.w	#167,d0
	adda.l	#2600,a0
	moveq	#0,d1
	moveq	#-1,d2
	moveq	#0,d3
	moveq	#0,d4
cf:
	move.w	d1,(a0)+
	move.w	d2,(a0)+
	move.w	d3,(a0)+
	move.w	d4,(a0)+
	move.w	d1,(a0)+
	move.w	d2,(a0)+
	move.w	d3,(a0)+
	move.w	d4,(a0)+
	move.w	d1,(a0)+
	move.w	d2,(a0)+
	move.w	d3,(a0)+
	move.w	d4,(a0)+
	move.w	d1,(a0)+
	move.w	d2,(a0)+
	move.w	d3,(a0)+
	move.w	d4,(a0)+
	move.w	d1,(a0)+
	move.w	d2,(a0)+
	move.w	d3,(a0)+
	move.w	d4,(a0)+
	move.w	d1,(a0)+
	move.w	d2,(a0)+
	move.w	d3,(a0)+
	move.w	d4,(a0)+
	move.w	d1,(a0)+
	move.w	d2,(a0)+
	move.w	d3,(a0)+
	move.w	d4,(a0)+
	move.w	d1,(a0)+
	move.w	d2,(a0)+
	move.w	d3,(a0)+
	move.w	d4,(a0)+
	move.w	d1,(a0)+
	move.w	d2,(a0)+
	move.w	d3,(a0)+
	move.w	d4,(a0)+
	move.w	d1,(a0)+
	move.w	d2,(a0)+
	move.w	d3,(a0)+
	move.w	d4,(a0)+
	move.w	d1,(a0)+
	move.w	d2,(a0)+
	move.w	d3,(a0)+
	move.w	d4,(a0)+

	adda.l	#72,a0
	dbf	d0,cf
	rts
********************************
joydir:
	bsr	cint
	tst.b	joyport1
	beq	jdback
	move.b	joyport1,d0
	btst	#7,d0
	beq	northa
	move.w	#1,firebutton
	bclr	#7,d0
	bra	north
northa:	move.w	#-1,firebutton
north:	cmpi.b	#1,d0
	bne	neast
	move.w	#minusy,myyvel
	move.w	#0,myxvel
	move.l	#heli4sp,masterheli
	move.l	#heli4mask,masterhelimask
	rts
neast:	cmpi.b	#9,d0
	bne	east
	move.w	#minusy,myyvel
	move.w	#plusx,myxvel
	move.l	#heli8sp,masterheli
	move.l	#heli8mask,masterhelimask
	rts
	
east:	cmpi.b	#8,d0
	bne	seast
	move.w	#0,myyvel
	move.w	#plusx,myxvel
	move.l	#heli3sp,masterheli
	move.l	#heli3mask,masterhelimask
	rts
seast:	cmpi.b	#10,d0
	bne	south
	move.w	#plusy,myyvel
	move.w	#plusx,myxvel
	move.l	#heli9sp,masterheli
	move.l	#heli9mask,masterhelimask
	rts
south:	cmpi.b	#2,d0
	bne	swest
	move.w	#plusy,myyvel
	move.w	#0,myxvel
	move.l	#heli5sp,masterheli
	move.l	#heli5mask,masterhelimask
	rts
swest:	cmpi.b	#6,d0
	bne	west
	move.w	#plusy,myyvel
	move.w	#minusx,myxvel
	move.l	#heli7sp,masterheli
	move.l	#heli7mask,masterhelimask
	rts
west:	cmpi.b	#4,d0
	bne	nwest
	move.w	#0,myyvel
	move.w	#minusx,myxvel
	move.l	#heli2sp,masterheli
	move.l	#heli2mask,masterhelimask
	rts

nwest:	cmpi.b	#5,d0
	bne	jdback
	move.w	#minusy,myyvel
	move.w	#minusx,myxvel
	move.l	#heli6sp,masterheli
	move.l	#heli6mask,masterhelimask
	rts
jdback:
	move.l	#heli1sp,masterheli
	move.l	#heli1mask,masterhelimask
	move.w	#0,myyvel
	move.w	#0,myxvel
	rts

plusy:		equ	20
minusy:		equ	-20
plusx:		equ	14
minusx:		equ	-14
masterheli:	blk.l	1,0
masterhelimask:	blk.l	1,0
myx:	blk.w	1,0
myy:	blk.w	1,0
myxvel:	blk.w	1,0
myyvel:	blk.w	1,0
firebutton:	blk.w	1,-1
*******************************
gtemp:	blk.w	1000,0
gmask:	blk.w	1000,0
*****************************************
*	set up joystick handler		*
*****************************************
joystuff:
init_joy:
	move.w	#$14,-(sp)
	move.w	#4,-(sp)
	move.w	#3,-(sp)
	trap	#13
	addq.l	#6,sp

	move.w	#34,-(sp)
	trap	#14
	addq.l	#2,sp
	move.l	d0,a0
	adda.l	#24,a0
	move.l	(a0),old_packh		;save the old handler
	move.l	#joy_packet,(a0)	;put in mine
	rts
*****************************************	
*	this is the joy pak handler	*
*****************************************
joy_packet:
	movem.l	a0/a1,-(sp)
	lea	joyport0,a1
	move.b	1(a0),(a1)
	move.b	2(a0),1(a1)
	movem.l	(sp)+,a0/a1
	rts

joyport0:	blk.b	1,0
joyport1:	blk.b	1,0
	even

res_mouse:
	move.w	#34,-(sp)
	trap	#14
	addq.l	#2,sp
	move.l	d0,a0
	adda.l	#24,a0
	move.l	old_packh,(a0)

	move.w	#128,-(sp)
	move.w	#4,-(sp)
	move.w	#3,-(sp)
	trap	#13
	addq.l	#6,sp

	move.w	#1,-(sp)
	move.w	#4,-(sp)
	move.w	#3,-(sp)
	trap	#13
	addq.l	#6,sp
	rts

old_packh:	blk.l	1,0
*************************************************
prestuff:
	move.w	#0,d7
*	move.l	#myship,origptr
	move.l	#myshipbuffer,imageptr
	move.w	#0,offset
ps1:
	move.w	#1,width
	move.w	#15,height
	jsr	pshiftimage	
	addq.w	#1,offset
	add.l	#240,imageptr
	addq.w	#1,d7
	cmpi.w	#15,offset
	ble	ps1

	move.w	#0,d7
	move.l	#myshipmask,maskptr
	move.l	#myshipbuffer,imageptr
	move.w	#0,offset
psm1:
	move.w	#1,width
	move.w	#15,height
	bsr	pmakemask	
	addq.w	#1,offset
	add.l	#240,imageptr
	add.l	#120,maskptr
	cmpi.w	#15,offset
	ble	psm1


*****************************************
*	height- height			*
*	width				*
*	offset				*
*	origptr				*
*	imageptr			*
*****************************************

pshiftimage:
        move.w  height,d1        ;height in d1
        move.w  offset,d2       ;offset to d2
        subq.w  #1,d1           ;height - 1 = height if count starts at zero
        subq.w  #1,width        ;width - 1 = width if count starts at zero
        move.l  origptr,a0      ;object pointer to a0
        move.l  imageptr,a1     ;image pointer to a1
psi1:   move.w  width,d0		;width in d0
        clr.l   (a1)            ;for each line, the first word of the
        clr.l   4(a1)           ;image must be cleared
psi0:    clr.l   d4              ;make sure that the top halves of these
        clr.l   d5              ;registers are zeroed out
        clr.l   d6
        clr.l   d7
        move.w  (a0)+,d4        ;load in one word (four planes)
        move.w  (a0)+,d5        ;to be rotated
        move.w  (a0)+,d6
        move.w  (a0)+,d7
        ror.l   d2,d4           ;rotate all planes by the offset(d2)
        ror.l   d2,d5
        ror.l   d2,d6
        ror.l   d2,d7
        or.w    d4,(a1)+        ;add low order bits to the high order bits
        or.w    d5,(a1)+        ;stored by move instructions farther
        or.w    d6,(a1)+        ;down in this routine
        or.w    d7,(a1)+
        swap    d4              ;move high order bits into lower halves
        swap    d5              ;of the registers
        swap    d6
        swap    d7
        move.w  d4,(a1)         ;save the high orders bits to be ORed
        move.w  d5,2(a1)        ;in the loop (do not increment a1 because
        move.w  d6,4(a1)        ;the ORs in the loop must function on
        move.w  d7,6(a1)        ;the same addresses as these moves.
        dbf     d0,psi0          ;repeat width times
        addq.l  #8,a1           ;new line, move to next word( * 4 planes = 8)
        dbf     d1,psi1          ;repeat height times
        rts                     ;done
pmakemask:
        move.w  height,d1        ;height in d1
        subq.w  #1,d1           ;height - 1 = height if count starts at zero
        move.l  imageptr,a0        ;image pointer to a0
        move.l  maskptr,a1       ;mask pointer to a1
pmm1:    move.w  width,d0        ;width in d0
pmm0:    move.w  (a0)+,d2        ;load first plane of bit image in d2
        or.w    (a0)+,d2        ;OR it with the 3 other planes
        or.w    (a0)+,d2
        or.w    (a0)+,d2
        move.w  d2,d3           ;store inverse mask in d3 (temporary)
        swap    d2              ;move inverse mask to top half of register
        move.w  d3,d2           ;and also in bottom half
        eor.l   #-1,d2          ;mask no longer inverse
        move.l  d2,(a1)+        ;store mask in buffer
        dbf     d0,pmm0          ;repeat 'width' times
        dbf     d1,pmm1          ;repeat 'height' times
        rts                     ;done
**************************************************
*	routine to draw image of prerotated
*	sprite
*	must load width,height,screenloc,imageptr,maskptr
pdrawimage:
        move.w  height,d1        ;height to d1
        subq.w  #1,d1           ;height - 1 = height if count starts at zero
        move.l  imageptr,a1       ;image pointer to a1
        move.l  maskptr,a2       ;mask pointer to a2
        move.l  screenloc,a3       ;screen buffer pointer to a3
pdi1:    move.w  width,d0        ;width to d0
        move.l  screenloc,a0        ;absolute screen address to a0
pdi0:    move.l  (a2)+,d3        ;load mask data into d3
        move.l  (a1)+,d6        ;load screen image into d6 and d7
        move.l  (a1)+,d7        ;2 words each covers all 4 planes
        move.l  (a3)+,d4        ;do the same for the background
        move.l  (a3)+,d5        ;in d4 and d5 (from buffer, not screen)
        and.l   d3,d4           ;mask background
        and.l   d3,d5
        or.l    d6,d4           ;copy image onto background
        or.l    d7,d5           ;giving final image on top of background
        move.l  d4,(a0)+        ;copy final image into screen memory
        move.l  d5,(a0)+
        dbf     d0,pdi0          ;repeat for 'width' times
        add.l   #160,screenloc      ;move to next screen line
	add.l	#144,a3
        dbf     d1,pdi1          ;repeat 'height' times
        rts                     ;done

shadow:
	tst.w	shad
	bmi	sback
	move.w	height,d1
	subq.w	#1,d1
	move.l	screenloc,a0
	move.l	maskptr,a1
	add.l	#1592,a0
sd:
	move.l	(a1)+,d0
	and.l	d0,(a0)+
	and.l	d0,(a0)+
	move.l	(a1)+,d0
	and.l	d0,(a0)+
	and.l	d0,(a0)+
	add.l	#144,a0
	dbf	d1,sd
	move.w	#-1,shad
	rts
sback:	
	move.w	#1,shad
	rts

shad:	blk.w	1,0
height:	blk.w	1,0
width:	blk.w	1,0
screenloc:	blk.l	1,0
imageptr:	blk.l	1,0
maskptr:	blk.l	1,0
****************************************
keyboard:
        move.w  #$ff,-(sp)
        move.w  #6,-(sp)
        trap    #1
        addq.l  #4,sp
        tst.l   d0
        beq     keyback
        swap    d0
quit:   cmpi.w  #$10,d0
        bne     space
        bra     gem
space:
	cmpi.w	#$39,d0
	bne	pkey
	bra	pause
pkey:
	cmpi.w	#$3b,d0
	bne	lkey
	neg	pointsf
	rts
lkey:
	cmpi.w	#$3c,d0
	bne	pokey
	neg	linesf
	rts
pokey:
	cmpi.w	#$3d,d0
	bne	keyback
	neg	polyf
keyback:rts
*****************************
pause:  
        move.w  #$ff,-(sp)
        move.w  #6,-(sp)
        trap    #1
        addq.l  #4,sp
        tst.l   d0
        beq     pause
        swap    d0
        cmpi.w  #$1e,d0
        bne     keyback 
        bsr     gkey
        cmpi.w  #$32,d0
        bne     keyback
        bsr     gkey
        cmpi.w  #$1e,d0
        bne     keyback
        bsr     gkey
        cmpi.w  #$31,d0
        bne     keyback
        bsr     gkey
        cmpi.w  #$20,d0
        bne     keyback
        bsr     gkey
        cmpi.w  #$1e,d0
        bne     keyback
*        bra     tmode

gkey:
        move.w  #$ff,-(sp)
        move.w  #6,-(sp)
        trap    #1
        addq.l  #4,sp
        tst.l   d0
        beq     gkey
        swap    d0
        rts

************code to determine  x offset *****************
*               and absolute screen address             *
*               parameters to pass on stack as follows  *
*               1-      x of sprite                     *
*               2-      y of sprite                     *
*               3-      screen address                  *
*       paremeters returned are x offset in d0          *
*       absolute screen address in d2                   *
*********************************************************
*	note use of a6					*
*********************************************************
putsprite:
	lea	spblock,a6
        move.l  hiden,16(a6)
	move.l  #0,d0
        move.w  (a6),d0       ;put x value in d0
        divu    #16,d0          ;divide by 16 leaves word boundry in d0
        move.w  2(a6),d1     ;put y value in d1
        mulu    #160,d1         ;gives offset in words of line
        move.w  d0,d3
        asl.w	#3,d3
        add.w	d3,d1           ;gives word to poke sprite
        move.l  hiden,d2    ;put screen address in d2
        add     d1,d2           ;gives actual screen address for sprite
        move.l  d2,20(a6)
        asr.l   #8,d0
        asr.l   #8,d0           ;leaves x offset in d0          
        move.w  d0,24(a6)

*************CODE TO ROTATE A SPRITE IMAGE***********************
*****************************************************************
shiftimages:
        move.w  4(a6),d1        ;height in d1
        move.w  24(a6),d2       ;offset to d2
        subq.w  #1,d1           ;height - 1 = height if count starts at zero
        subq.w  #1,6(a6)        ;width - 1 = width if count starts at zero
        move.l  8(a6),a0        ;object pointer to a0
        move.l  12(a6),a1       ;image pointer to a1
ssi1:	move.w  6(a6),d0        ;width in d0
        clr.l   (a1)            ;for each line, the first word of the
        clr.l   4(a1)           ;image must be cleared
ssi0:	clr.l   d4              ;make sure that the top halves of these
        clr.l   d5              ;registers are zeroed out
        clr.l   d6
        clr.l   d7
        move.w  (a0)+,d4        ;load in one word (four planes)
        move.w  (a0)+,d5        ;to be rotated
        move.w  (a0)+,d6
        move.w  (a0)+,d7
        ror.l   d2,d4           ;rotate all planes by the offset(d2)
        ror.l   d2,d5
        ror.l   d2,d6
        ror.l   d2,d7
        or.w    d4,(a1)+        ;add low order bits to the high order bits
        or.w    d5,(a1)+        ;stored by move instructions farther
        or.w    d6,(a1)+        ;down in this routine
        or.w    d7,(a1)+
        swap    d4              ;move high order bits into lower halves
        swap    d5              ;of the registers
        swap    d6
        swap    d7
        move.w  d4,(a1)         ;save the high orders bits to be ORed
        move.w  d5,2(a1)        ;in the loop (do not increment a1 because
        move.w  d6,4(a1)        ;the ORs in the loop must function on
        move.w  d7,6(a1)        ;the same addresses as these moves.
        dbf     d0,ssi0          ;repeat width times
        addq.l  #8,a1           ;new line, move to next word( * 4 planes = 8)
        dbf     d1,ssi1          ;repeat height times
        addq.w  #1,6(a6)
smake_mask:
        move.w  4(a6),d1        ;height in d1
        subq.w  #1,d1           ;height - 1 = height if count starts at zero
        move.l  12(a6),a0        ;image pointer to a0
        move.l  38(a6),a1       ;mask pointer to a1
smm1:	move.w  6(a6),d0        ;width in d0
smm0:	move.w  (a0)+,d2        ;load first plane of bit image in d2
        or.w    (a0)+,d2        ;OR it with the 3 other planes
        or.w    (a0)+,d2
        or.w    (a0)+,d2
        move.w  d2,d3           ;store inverse mask in d3 (temporary)
        swap    d2              ;move inverse mask to top half of register
        move.w  d3,d2           ;and also in bottom half
        eor.l   #-1,d2          ;mask no longer inverse
        move.l  d2,(a1)+        ;store mask in buffer
        dbf     d0,smm0          ;repeat 'width' times
        dbf     d1,smm1          ;repeat 'height' times

*********code to put sprite on screen********************
*********parameters to be passed on the stack are********
*********1-     shifted sprite address (tempsp) *********
*********2-     absolute screen address to put image*****
*********3-     height in pixels                *********
*********4-     width in words -1               *********
sdraw:
        move.w  4(a6),d1     ;height to d1
        subq.w  #1,d1           ;height - 1 = height if count starts at zero
        move.l  12(a6),a1    ;image pointer to a1
        move.l  38(a6),a2    ;mask pointer to a2
        move.l  20(a6),a3    ;screen buffer pointer to a3
sdi1:	move.w  6(a6),d0     ;width to d0
        move.l  20(a6),a0    ;absolute screen address to a0
sdi0:	move.l  (a2)+,d3        ;load mask data into d3
        move.l  (a1)+,d6        ;load screen image into d6 and d7
        move.l  (a1)+,d7        ;2 words each covers all 4 planes
        move.l  (a3)+,d4        ;do the same for the background
        move.l  (a3)+,d5        ;in d4 and d5 (from buffer, not screen)
        and.l   d3,d4           ;mask background
        and.l   d3,d5
        or.l    d6,d4           ;copy image onto background
        or.l    d7,d5           ;giving final image on top of background
        move.l  d4,(a0)+        ;copy final image into screen memory
        move.l  d5,(a0)+
        dbf     d0,sdi0          ;repeat for 'width' times
        addi.l	#160,20(a6)  ;move to next screen line
        addi.l  #144,a3
        dbf     d1,sdi1          ;repeat 'height' times
	rts
***********************************
printinfo:
	move.w	#3200,numwhere
	move.w	myheight,number
	bsr	prtnum
*	subq.b	#1,numsflag
	rts
*************************

printscore:
*	tst.b	numsflag
*	bmi	noput
	move.w	#0,numwhere
	move.w	score,number
	bsr	prtnum
*	subq.b	#1,numsflag
	rts
noput:
	move.b	#-1,numsflag
printships:
	tst.b	shipsflag
	bmi	noputs
	move.w	#14104,numwhere
	move.w	ships,number
	bsr	prtnum
	subq.b	#1,shipsflag
	rts
noputs:
	move.b	#-1,numsflag
	rts

emancnt:	blk.w	1,0
numwhere:	blk.w	1,0
numsflag:	blk.b	1,0
shipsflag:	blk.b	1,0
levelflag:	blk.b	1,0
even
**************************************************************************
*               RETURN TO GEM
**************************************************************************
gem:
	move.w	#0,$452
	move.l	oldvbl1,a0
	move.l	#0,(a0)
	move.l	oldvbl2,a0
	move.l	#0,(a0)
	move.w	#1,$452

	jsr	res_mouse
        move.b  #7,$484

        move.w  ressave,-(sp)
*	move.w	#-1,-(sp)
        move.l  screen1,-(sp)
        move.l  screen1,-(sp)
        move.w  #5,-(sp)
        trap    #14
        addi.l  #12,sp

        move.l  spv_sp,-(SP)    ;Back to user mode
        move.w  #$20,-(SP)
        trap    #1
        addq.l  #6,(SP)

illegal
        CLR.W   -(SP)           ;RETURN TO GEM
        TRAP    #1

spv_sp: blk.l   1               ;supervisor SP store
ressave:	blk.w	1,0
********************************************************
beamer:
	move.l	#$ff8205,a0
	move.l	#0,d0
	move.b	(a0),d0
	asl.l	#8,d0
	adda.w	#2,a0
	move.b	(a0),d0
	asl.l	#8,d0
	adda.w	#2,a0
	move.b	(a0),d0
	rts
flip_scr:
	move.l	seen,d1
	move.l	d1,d2
	add.l	#9920,d1
	add.l	#20000,d2
skloop:
	bsr	beamer
	cmp.l	d1,d0
	blt	skloop
	cmp.l	d2,d0
	bgt	skloop

        move.l  seen,A6
        move.l  hiden,seen
        move.l  A6,hiden
	jsr	clearfast
        move.l  sytable,A6
        move.l  ytable,sytable
        move.l  A6,ytable
*       rts
df:     move.w  #-1,-(sp)
        move.l  seen,-(sp)
        move.l  hiden,-(sp)
        move.w  #5,-(sp)
        trap    #14
        addi.l  #12,sp  
        rts
************************************************************
flip2:
        move.l  seen,A6
        move.l  hiden,seen
        move.l  A6,hiden
        move.l  sytable,A6
        move.l  ytable,sytable
        move.l  A6,ytable
*       rts
df2:     move.w  #-1,-(sp)
        move.l  seen,-(sp)
        move.l  hiden,-(sp)
        move.w  #5,-(sp)
        trap    #14
        addi.l  #12,sp  
	move.w	#37,-(sp)
	trap	#14
	addq.l	#2,sp
        rts
*************************************************
calc_vsa:
	cmpi.w	#10,d7
	bge	cv1
	move.w	#10,d7
	bra	cvv
cv1:
	cmpi.w	#189,d7
	ble	cvv
	move.w	#189,d7

cvv:
	swap	d7
	move.w	#0,d7
	swap	d7
	swap	d6
	move.w	#0,d6
	swap	d6

	mulu	#160,d7
	asr.w	#4,d6
	asl.w	#3,d6
	add.w	d6,d7
	move.l	hiden,a6
	add.w	d7,a6
	rts

herec:
	movem.l	d0-d7/a0-a6,-(sp)
	move.w d6,d0      ;x coordinate in D0
	move.w d7,d1      ;get y coordinate,
	lsl.w #2,d1          ;mult by 4 for index
	lsr.w 	#1,d0             ;x coord / 2
	and.w #$00f8,d0      ;strip lower 3 bits
	move.w d0,a0        ;move x offset to A0
	move.l ytable,a1   ;get y table addr
	adda.l 0(a1,d1.w),a0 ;got final pixel addr!
	move.l	a0,a6
	movem.l	(sp)+,d0-d7/a0-a6
	rts
********************************************
* Atari ST hi-speed plotting subroutine    *
********************************************
* For Low-resolution mode only		   *
********************************************
**************************************
* INITIALIZE THE PLOTTING ROUTINE:   *
* BUILDS PLOT ADDRESS TABLE (YTABLE) *
* FOR FAST PLOTTING.                 *
*                                    *
* CALL WITH:                         *
* pinit(SCREENADDRESS)               *
**************************************
plotinit:
	move.l seen,a0    ;screen addr in A0
	move.b #200,d1     ;200 Y positions
	move.l #ytable1,a1 ;y table address in A1

iloop:
	move.l a0,(a1)+    ;move address to table
	adda.w #160,a0     ;increment address
	subq.b #1,d1       ;1 less y position
	bne iloop          ;loop if there's more!

	move.l hiden,a0    ;screen addr in A0
	move.b #200,d1     ;200 Y positions
	move.l #ytable2,a1 ;y table address in A1

iloop2:
	move.l a0,(a1)+    ;move address to table
	adda.w #160,a0     ;increment address
	subq.b #1,d1       ;1 less y position
	bne iloop2         ;loop if there's more!
rts

pixelx:	blk.w	1,0
pixely:	blk.w	1,0
pixelcolor:
	blk.w	1,0
ytable1:	blk.l	200,0
ytable2:	blk.l	200,0
ytable:		blk.l	1,0
sytable:		blk.l	1,0

**************************************
* PLOT A PIXEL WITH MY ROUTINE       *
*                                    *
* CALL WITH:                         *
* myplot(X,Y,COLOR)                  *
**************************************
myplot:
	movem.l	d0-d5/a0-a1,-(sp)
	move.w pixelx,d0      ;x coordinate in D0
	cmp.w #303,d0
	bcc pltxit
	cmpi.w	#96,d0
	blt	pltxit
	move.w d0,d3		;duplicate in D3
	andi.w #15,d3		;mask off lower 4 bits
	move.w pixely,d1	;get y coordinate,
	cmpi.w	#10,d1
	blt	pltxit
	cmp.w #189,d1
	bcc pltxit
	lsl.w #2,d1		;mult by 4 for index
	move.w pixelcolor,d2	;get color number

	lsr.w 	#1,d0		;x coord / 2
	and.w #$00f8,d0		;strip lower 3 bits
	move.w d0,a0		;move x offset to A0
	move.l ytable,a1	;get y table addr
	adda.l 0(a1,d1.w),a0 	;got final pixel addr!
	cmpi.w	#15,d3
	beq	singlepix
	move.w #$c000,d4     	;set ON pixel mask
	lsr.w d3,d4          	;shift right D3 times
	move.l #$c000c000,d5 	;set OFF pixel mask
	lsr.l d3,d5          	;shift right D3 times
	eor.l #$ffffffff,d5  	;toggle all bits in D5
	bra	myphere

singlepix:
	move.w #$8000,d4     ;set ON pixel mask
	lsr.w d3,d4          ;shift right D3 times
	move.l #$80008000,d5 ;set OFF pixel mask
	lsr.l d3,d5          ;shift right D3 times
	eor.l #$ffffffff,d5  ;toggle all bits in D5
	and.l d5,(a0)        ;turn off old pixel
	and.l d5,4(a0)       ;(both longwords)

******************************
* Now turn on the new pixel! *
******************************
	btst #0,d2           ;set the bit?
	beq bbit2             ;no!
	or.w d4,(a0)         ;turn it on!
bbit2:
	btst #1,d2           ;set it?
	beq bbit4             ;no!
	or.w d4,2(a0)        ;turn it on!
bbit4:
	btst #2,d2           ;set bit?
	beq bbit8             ;no!
	or.w d4,4(a0)        ;turn it on!
bbit8:
	btst #3,d2           ;set bit?
	beq mysec           ;no, exit.
	or.w d4,6(a0)        ;turn it on!

mysec:
	adda.l	#8,a0
	move.w #$8000,d4     ;set ON pixel mask
	move.l #$80008000,d5 ;set OFF pixel mask
	eor.l #$ffffffff,d5  ;toggle all bits in D5
	and.l d5,(a0)        ;turn off old pixel
	and.l d5,4(a0)       ;(both longwords)

******************************
*    Turn off old pixel!     *
******************************
myphere:
	and.l d5,(a0)        ;turn off old pixel
	and.l d5,4(a0)       ;(both longwords)

******************************
* Now turn on the new pixel! *
******************************
	btst #0,d2           ;set the bit?
	beq bit2             ;no!
	or.w d4,(a0)         ;turn it on!
bit2:
	btst #1,d2           ;set it?
	beq bit4             ;no!
	or.w d4,2(a0)        ;turn it on!
bit4:
	btst #2,d2           ;set bit?
	beq bit8             ;no!
	or.w d4,4(a0)        ;turn it on!
bit8:
	btst #3,d2           ;set bit?
	beq pltxit           ;no, exit.
	or.w d4,6(a0)        ;turn it on!
pltxit:
	movem.l	(sp)+,d0-d5/a0-a1
	rts                  ;bye!

**********************
* get low-rez pixel  *
* get0(scrnbase,x,y) *
**********************
*gets pixel in hiden screen
*	should rewrite to take advantage of table
**************************
mygetpix:
	move.l hiden,a1
	clr.w d0		;zero result register
	move.w pixely,d3	;get Y coordinate
	and.l #$0000ffff,d3	;mask off for multiply
	mulu #160,d3		;multiply by 160 (# of bytes per scan line)
	adda.l d3,a1		;add to screen base address
	move.w pixelx,d1	;get X coordinate
	move.w d1,d2		;duplicate it in D2
	lsr.w #1,d1		;divide it by 2
	and.w #$00f8,d1		;turn off lower 3 bits
	adda.w d1,a1		;add to screen address register

	move.w (a1),d3		;grab screen word
	and.l #15,d2		;mask X to 0-15
	move.w #$8000,d1	;set up bit mask
	lsr.w d2,d1		;shift bit mask 0-15 bits
	and.w d1,d3		;mask off bit 0
	beq bit0b		;bit's off, go get next color bit
	move.w #1,d0		;turn on bit 0 in result

bit0b:
	move.w 2(a1),d3		;get screen word for bit 1 of color
	and.w d1,d3		;get bit 1
	beq bit0c		;it's off, try bit 2
	or.w #2,d0		;turn on bit 1 in result

bit0c:
	move.w 4(a1),d3		;get screen word for bit 2
	and.w d1,d3		;get bit 2
	beq bit0d		;it's off, try bit 3
	or.w #4,d0		;turn on bit 2 in result

bit0d:
	move.w 6(a1),d3		;get word for bit 3
	and.w d1,d3		;get bit 3
	beq getx0		;it's off!
	or.w #8,d0		;turn on bit 3 in result
getx0:
	rts
*************************************************
linea:  dc.w    $a000
        move.l  a0,linepar
        move.l  8(a0),intin
        move.l  12(a0),ptsin
        rts
********************************
copyintoboth:
        move.l  hiden,a0
        move.l  seen,a1
        move.w  #4000,d0
cib3:
        move.l  (a0)+,(a1)+
        move.l  (a0)+,(a1)+
        dbf     d0,cib3
	rts
**********************routine to print a dec nuber*************
prtnum: 
	move.w	#0,times
        move.l  #0,d7
        move.w  number,d7
        andi.l  #$ffff,d7
        move.l  #line,a5

dodec:  move.l  d7,d6
        divu    #10,d6
        move.w  d6,d7
        swap    d6
*        addi.w  #16,d6
        move.b  d6,(a5)+
        cmpi.w  #0,d7
        bne     dodec
	
out:    cmpa.l  #line,a5
        beq     decback
        move.b  -(a5),d7
        andi.w  #$ff,d7
	lea	numbers,a0
	mulu	#40,d7
	add.w	d7,a0
	move.w	#9,d0
	move.l	hiden,a1
	adda.w	numwhere,a1
oloop:
	move.b	(a0)+,(a1)
	move.b	(a0)+,2(a1)
	move.b	(a0)+,4(a1)
	move.b	(a0)+,6(a1)
	add.l	#160,a1
	dbf	d0,oloop
	addq.w	#1,times
	cmpi.w	#2,times
	blt	oh
	move.w	#0,times
	addq.w	#6,numwhere
oh:	addq.w	#1,numwhere
	
	bra	out
	rts        
decback:
	rts
times:	blk.w	1,0

*************puts my mouse interupt in***************** 
mmin:	blk.w	1,0
mmax:	blk.w	1,0
************get screen address***************
getscrn:move.w  #2,-(sp)
        trap    #14
        addq.l  #2,sp
        move.l  d0,screen
        move.l  d0,screen1
        move.l  d0,screen2
        subi.l  #$8000,screen2
        move.l  screen1,seen
        move.l  screen2,hiden
	move.l	#ytable2,ytable
	move.l	#ytable1,sytable
        rts
map:	blk.l	1,0
************change colors****************
docolors:
	move.l temppal,-(sp)
        move.w #6,-(sp)
        trap #14
        addq.l #6,sp
        rts
*****************wait for a key*********************
wait:   move.w  $26e6,d0
        cmpi.w  #2,d0
        beq     wback
        bra     wait
wback:  rts
***************turn mouse off***********************
mousof: dc.w    $a00a   
        rts
*******************************************************************
; SYSNOPSIS
;    RandomSeed( SeedValue )
;                   D0

randomseed:     ADD.L   D0,D1           ;user seed in d0 (d1 too)
                MOVEM.L D0/D1,RND

; drops through to the main random function (not user callable)

LongRnd:        MOVEM.L D2-D3,-(SP)     
                MOVEM.L RND,D0/D1       ;D0=LSB's, D1=MSB's of random number
                ANDI.B  #$0E,D0         ;ensure upper 59 bits are an...
                ORI.B   #$20,D0         ;...odd binary number
                MOVE.L  D0,D2
                MOVE.L  D1,D3
                ADD.L   D2,D2           ;accounts for 1 of 17 left shifts
                ADDX.L  D3,D3           ;[D2/D3] = RND*2
                ADD.L   D2,D0
                ADDX.L  D3,D1           ;[D0/D1] = RND*3
                SWAP    D3              ;shift [D2/D3] additional 16 times
                SWAP    D2
                MOVE.W  D2,D3
                CLR.W   D2
                ADD.L   D2,D0           ;add to [D0/D1]
                ADDX.L  D3,D1
                MOVEM.L D0/D1,RND       ;save for next time through
                MOVE.L  D1,D0           ;most random part to D0
                MOVEM.L (SP)+,D2-D3
                RTS

; SYSNOPSIS
;    RndNum = Random( UpperLimit )
;      D0                 D0

random:
	        MOVE.W  D2,-(SP)
                MOVE.W  D0,D2           ;save upper limit
                BEQ.S   r1              ;range of 0 returns 0 always
                BSR.S   LongRnd         ;get a longword random number
                CLR.W   D0              ;use upper word (it's most random)
                SWAP    D0
                ext.l   d0
                DIVs    D2,D0           ;divide by range...
                CLR.W   D0              ;...and use remainder for the value
                SWAP    D0              ;result in D0.W
r1:             MOVE.W  (SP)+,D2
                RTS

randomplus:     MOVE.W  D2,-(SP)
                MOVE.W  D0,D2           ;save upper limit
                BEQ.S   r2              ;range of 0 returns 0 always
                BSR.S   LongRnd         ;get a longword random number
                CLR.W   D0              ;use upper word (it's most random)
                SWAP    D0
                DIVu    D2,D0           ;divide by range...
                CLR.W   D0              ;...and use remainder for the value
                SWAP    D0              ;result in D0.W
r2:             MOVE.W  (SP)+,D2
                RTS
*********************************************************
*       a brilliant routine courtesy of janko to        *
*       insert the vbi addresses in the jump table      *
*       lea address of routine in a0 do a jsr           *
*       putvbl and thats it!!!                          *
*********************************************************
putvbl: lea     $452,a1
        move.w  #1,(a1)
        moveq   #7,d1
        lea     $456,a1
        move.l  (a1),a1
vbl3:   subq.b  #1,d1
        cmpi.b  #0,d1
        beq.s   vbl4
        move.l  (a1)+,d0
        cmpi.l  #0,d0
        bne.S   vbl3
        suba.l  #4,a1
        move.l  a0,(a1)
vbl4:   rts

oldvbl1:	
	blk.l	1,0
oldvbl2:
	blk.l	1,0
oldvbl3:
	blk.l	1,0
*********************************************************
*       my routines for loading in the screens          *
*********************************************************
loadscreen:
	move    #0,-(SP)        ;Open file
        move.l  #filename,-(SP) ;Address of filename
        move    #$3D,-(SP)
        trap    #1              ;Get handle number in D0
        addq.l  #8,SP
                
        move    D0,-(SP)        ;Save handle

        move.l  #dummy,-(SP)    ;load pallette into safe area
        move.l  #128,-(SP)       ;length to read in
        move    D0,-(SP)        ;Handle
        move    #$3F,-(SP)      ;bios number
        trap    #1              ;Read file in
        addi.l   #12,SP
        move    (sp),d0        
               
        move.l  hiden,-(SP)    ;load it straight onto screen
        move.l  #32000,-(SP)    ;length to read in
        move    D0,-(SP)        ;Handle
        move    #$3F,-(SP)      ;bios number
        trap    #1              ;Read file in
        addi.l   #12,SP
                
        move    #$3E,-(SP)      ;Handle already on stack
        trap    #1              ;Close file
        addq.l  #4,SP
        rts
filename:
	dc.b	'heli.neo',0
even

*********************************************************
*********************************************************
loadtitle:
	move    #0,-(SP)        ;Open file
        move.l  #filescreen3,-(SP) ;Address of filename
        move    #$3D,-(SP)
        trap    #1              ;Get handle number in D0
        addq.l  #8,SP
                
        move    D0,-(SP)        ;Save handle

        move.l  #dummy,-(SP)    ;load pallette into safe area
        move.l  #128,-(SP)       ;length to read in
        move    D0,-(SP)        ;Handle
        move    #$3F,-(SP)      ;bios number
        trap    #1              ;Read file in
        addi.l   #12,SP
        move    (sp),d0        
               
*        move.l  screen4,-(SP)    ;load it straight onto screen
        move.l  #32000,-(SP)    ;length to read in
        move    D0,-(SP)        ;Handle
        move    #$3F,-(SP)      ;bios number
        trap    #1              ;Read file in
        addi.l   #12,SP
                
        move    #$3E,-(SP)      ;Handle already on stack
        trap    #1              ;Close file
        addq.l  #4,SP
        rts

filescreen3:
	dc.b	'title.neo',0
	even
******************************
*******************blocks for rotated sprites*************
myshipbuffer:
	blk.w	1920,0

myshipmask:
	blk.w	960,0
offset:	blk.w	1,0
origptr:	blk.l	1,0
screen3:blk.l   1,0
pblock: blk.l   50
screen: blk.l   1
screen2:blk.l   1
screen1:blk.l   1
dummy:  blk.l   32
line:   blk.b   10
number: blk.w   1
even
ships:	blk.w	1,0
intin:  blk.l   1
ptsin:  blk.l   1
putpix: equ     $a001
getpix: equ     $a002
seen:   blk.l   1
hiden:  blk.l   1
palette2:
        dc.w    $0000,$0000,$0000
        dc.w    $0000,$0000,$0000
        dc.w    $0000,$0000,$0000
        dc.w    $0000,$0000,$0000
        dc.w    $0000,$0000,$0000
        dc.w    $0000
rnd:            blk.l   2,0
score:          blk.w   1,0
level:          blk.w   1,0
linepar:        blk.l   1,0
pulsecol:	blk.w	1,0

temppal:
	blk.l	1,0
helipalette:
	dc.w	$0000,$0222,$0463,$0033,$0066,$0007,$0003,$0777
	dc.w	$0222,$0030,$0050,$0070,$0333,$0555,$0777,$0700

helisp:
	 dc.w	$0070,$0070,$0070,$0000,$1C00,$1C00,$1C00,$0000
	 dc.w	$0180,$0180,$0180,$000F,$0300,$0300,$0300,$C000
	 dc.w	$0200,$0200,$0200,$0010,$0080,$0080,$0080,$0000
	 dc.w	$0400,$0400,$0400,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0800,$0800,$0800,$0000,$0000,$0000,$0000,$0000
	 dc.w	$1000,$1000,$1000,$0000,$0000,$0000,$0000,$0080
	 dc.w	$0000,$0007,$0001,$0007,$4000,$C000,$0000,$C040
	 dc.w	$0000,$000F,$0007,$0009,$2000,$E000,$C000,$2020
	 dc.w	$0107,$001F,$000F,$1110,$9104,$F004,$E004,$1100
	 dc.w	$0280,$013F,$001F,$13A1,$0A84,$F904,$F004,$0B80
	 dc.w	$02C0,$0100,$003F,$13FF,$0E84,$7904,$F804,$F780
	 dc.w	$02BE,$0120,$0020,$239F,$6A82,$1902,$0802,$F380
	 dc.w	$0172,$03C0,$0049,$23BF,$ED02,$1F82,$0402,$FB80
	 dc.w	$82B2,$8100,$800D,$23BF,$4E80,$BD00,$0400,$FB88
	 dc.w	$8298,$8100,$8026,$23BF,$1280,$4900,$8000,$FB88
	 dc.w	$8294,$8100,$8022,$23BE,$1280,$4900,$8000,$FB88
	 dc.w	$8288,$8100,$8033,$03BF,$1280,$2900,$8000,$FB88
	 dc.w	$82B8,$8120,$8027,$039F,$CA80,$3900,$0800,$F388
	 dc.w	$42E4,$413A,$4021,$03DF,$BE80,$F900,$0800,$F780
	 dc.w	$429E,$4100,$4001,$039F,$F280,$1100,$1000,$E380
	 dc.w	$0293,$0103,$000F,$039C,$E284,$D104,$8004,$7390
	 dc.w	$0282,$0101,$000C,$0B8F,$C288,$2108,$0008,$E380
	 dc.w	$0286,$0101,$0000,$0787,$8288,$4108,$0008,$C380
	 dc.w	$0082,$0101,$0000,$0383,$8290,$0110,$0010,$8380
	 dc.w	$0002,$0001,$0000,$0103,$8120,$0020,$0020,$8100
	 dc.w	$0001,$0003,$0000,$0003,$0040,$8040,$0040,$8000
	 dc.w	$0202,$0201,$0200,$0003,$8080,$0080,$0080,$8000
	 dc.w	$0180,$0180,$0180,$0003,$0300,$0300,$0300,$E000
	 dc.w	$0062,$0061,$0060,$0003,$9C00,$1C00,$1C00,$8000
	 dc.w	$0002,$0001,$0000,$0003,$8000,$0000,$0000,$8000
	 dc.w	$0001,$0003,$0000,$0003,$0000,$8000,$0000,$8000
	 dc.w	$0001,$0003,$0000,$0003,$0000,$8000,$0000,$8000
	 dc.w	$000A,$0009,$0008,$0003,$8000,$0000,$0000,$8000
	 dc.w	$0002,$0001,$0000,$000B,$8000,$0000,$0000,$8000
	 dc.w	$000A,$0009,$0008,$0003,$8000,$0000,$0000,$8000
	 dc.w	$0002,$0001,$0000,$000B,$8000,$0000,$0000,$8000
	 dc.w	$0008,$000F,$0008,$0007,$C000,$C000,$0000,$C000
	 dc.w	$001C,$000B,$0008,$0017,$7000,$B000,$0000,$F000
	 dc.w	$000A,$0009,$0008,$0003,$8000,$0000,$0000,$8000
	 dc.w	$0000,$0001,$0000,$0009,$0000,$0000,$0000,$0000
	 dc.w	$0008,$0009,$0008,$0001,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0001,$0000,$0009,$0000,$0000,$0000,$0000
	 dc.w	$0009,$0008,$0008,$0001,$0000,$0000,$0000,$0000
	 dc.w	$0001,$0000,$0000,$0001,$0000,$0000,$0000,$0000

helimask:
	 dc.w	$0070,$1C00,$018F,$C300,$0210,$0080,$0400,$0000
	 dc.w	$0800,$0000,$1000,$0080,$0007,$C040,$000F,$E020
	 dc.w	$111F,$F104,$13BF,$FB84,$13FF,$FF84,$23BF,$FB82
	 dc.w	$23FF,$FF82,$A3BF,$FF88,$A3BF,$FB88,$A3BF,$FB88
	 dc.w	$83BF,$FB88,$83BF,$FB88,$43FF,$FF80,$439F,$F380
	 dc.w	$039F,$F394,$0B8F,$E388,$0787,$C388,$0383,$8390
	 dc.w	$0103,$8120,$0003,$8040,$0203,$8080,$0183,$E300
	 dc.w	$0063,$9C00,$0003,$8000,$0003,$8000,$0003,$8000
	 dc.w	$000B,$8000,$000B,$8000,$000B,$8000,$000B,$8000
	 dc.w	$000F,$C000,$001F,$F000,$000B,$8000,$0009,$0000
	 dc.w	$0009,$0000,$0009,$0000,$0009,$0000,$0001,$0000


numbers:
	 dc.b	$7F,$FF,$FF,$FF,$81,$01,$FF,$81
	 dc.b	$81,$1D,$FF,$9D,$81,$1D,$FF,$9D
	 dc.b	$81,$1D,$FF,$9D,$81,$1D,$FF,$9D
	 dc.b	$81,$1D,$FF,$9D,$81,$01,$FF,$81
	 dc.b	$81,$01,$FF,$81,$FE,$01,$FF,$FF
	 dc.b	$7F,$FF,$FF,$FF,$81,$67,$FF,$E7
	 dc.b	$81,$47,$FF,$C7,$81,$67,$FF,$E7
	 dc.b	$81,$67,$FF,$E7,$81,$67,$FF,$E7
	 dc.b	$81,$67,$FF,$E7,$81,$67,$FF,$E7
	 dc.b	$81,$67,$FF,$E7,$FE,$01,$FF,$FF
	 dc.b	$7F,$FF,$FF,$FF,$81,$01,$FF,$81
	 dc.b	$81,$3D,$FF,$BD,$81,$7D,$FF,$FD
	 dc.b	$81,$01,$FF,$81,$81,$1F,$FF,$9F
	 dc.b	$81,$1F,$FF,$9F,$81,$1D,$FF,$9D
	 dc.b	$81,$01,$FF,$81,$FE,$01,$FF,$FF
	 dc.b	$7F,$FF,$FF,$FF,$81,$01,$FF,$81
	 dc.b	$81,$3D,$FF,$BD,$81,$7D,$FF,$FD
	 dc.b	$81,$41,$FF,$C1,$81,$79,$FF,$F9
	 dc.b	$81,$79,$FF,$F9,$81,$39,$FF,$B9
	 dc.b	$81,$01,$FF,$81,$FE,$01,$FF,$FF
	 dc.b	$7F,$FF,$FF,$FF,$81,$1D,$FF,$9D
	 dc.b	$81,$1D,$FF,$9D,$81,$1D,$FF,$9D
	 dc.b	$81,$01,$FF,$81,$81,$79,$FF,$F9
	 dc.b	$81,$79,$FF,$F9,$81,$79,$FF,$F9
	 dc.b	$81,$79,$FF,$F9,$FE,$01,$FF,$FF
	 dc.b	$7F,$FF,$FF,$FF,$81,$01,$FF,$81
	 dc.b	$81,$1F,$FF,$9F,$81,$1F,$FF,$9F
	 dc.b	$81,$01,$FF,$81,$81,$7D,$FF,$FD
	 dc.b	$81,$7D,$FF,$FD,$81,$3D,$FF,$BD
	 dc.b	$81,$01,$FF,$81,$FE,$01,$FF,$FF
	 dc.b	$7F,$FF,$FF,$FF,$81,$01,$FF,$81
	 dc.b	$81,$1D,$FF,$9D,$81,$1F,$FF,$9F
	 dc.b	$81,$01,$FF,$81,$81,$1D,$FF,$9D
	 dc.b	$81,$1D,$FF,$9D,$81,$1D,$FF,$9D
	 dc.b	$81,$01,$FF,$81,$FE,$01,$FF,$FF
	 dc.b	$7F,$FF,$FF,$FF,$81,$01,$FF,$81
	 dc.b	$81,$39,$FF,$B9,$81,$79,$FF,$F9
	 dc.b	$81,$79,$FF,$F9,$81,$79,$FF,$F9
	 dc.b	$81,$79,$FF,$F9,$81,$79,$FF,$F9
	 dc.b	$81,$79,$FF,$F9,$FE,$01,$FF,$FF
	 dc.b	$7F,$FF,$FF,$FF,$81,$01,$FF,$81
	 dc.b	$81,$1D,$FF,$9D,$81,$1D,$FF,$9D
	 dc.b	$81,$01,$FF,$81,$81,$1D,$FF,$9D
	 dc.b	$81,$1D,$FF,$9D,$81,$1D,$FF,$9D
	 dc.b	$81,$01,$FF,$81,$FE,$01,$FF,$FF
	 dc.b	$7F,$FF,$FF,$FF,$81,$01,$FF,$81
	 dc.b	$81,$1D,$FF,$9D,$81,$1D,$FF,$9D
	 dc.b	$81,$01,$FF,$81,$81,$79,$FF,$F9
	 dc.b	$81,$79,$FF,$F9,$81,$79,$FF,$F9
	 dc.b	$81,$79,$FF,$F9,$FE,$01,$FF,$FF
rsprite:
	 dc.w	$0000,$0000,$FFF0,$0000,$0000,$0008,$9040,$0000
	 dc.w	$0000,$0000,$9024,$0000,$0000,$0000,$9024,$0000
	 dc.w	$0000,$0000,$9024,$0000,$0000,$0000,$9058,$0000
	 dc.w	$4000,$0000,$9FE0,$4000,$6600,$0000,$9900,$6600
	 dc.w	$6300,$0000,$9480,$6300,$0000,$0000,$9240,$6180
	 dc.w	$0000,$0000,$9120,$60C0,$6060,$6060,$F0F0,$0000
	 dc.w	$6030,$6030,$F078,$0000,$0000,$0000,$F03C,$0000

asprite:
	 dc.w	$0000,$0010,$3FE0,$0000,$0008,$0000,$4840,$0000
	 dc.w	$0000,$0000,$9024,$0000,$0000,$0000,$9024,$0000
	 dc.w	$0000,$0000,$9024,$0000,$0000,$0000,$9024,$0000
	 dc.w	$4008,$0000,$9024,$4008,$6018,$0000,$9FE4,$6018
	 dc.w	$6018,$0000,$9024,$6018,$0000,$0000,$9024,$6018
	 dc.w	$0000,$0000,$9024,$6018,$6018,$6018,$F03C,$0000
	 dc.w	$6018,$6018,$F03C,$0000,$0000,$0000,$F03C,$0000

msprite:
	 dc.w	$2000,$4000,$8007,$0000,$0000,$0000,$9009,$0000
	 dc.w	$0000,$0000,$8811,$0000,$0000,$0000,$8421,$0000
	 dc.w	$0000,$0000,$9249,$0000,$0000,$0000,$9999,$0000
	 dc.w	$4242,$0000,$9429,$4242,$6186,$0000,$9249,$6186
	 dc.w	$6006,$0000,$9189,$6006,$0000,$0000,$9009,$6006
	 dc.w	$0000,$0000,$9009,$6006,$6006,$6006,$F00F,$0000
	 dc.w	$6006,$6006,$F00F,$0000,$0000,$0000,$F00F,$0000

wsprite:
	 dc.w	$0041,$0002,$F38C,$0000,$0000,$0001,$9248,$0000
	 dc.w	$0000,$0000,$9249,$0000,$0000,$0000,$9249,$0000
	 dc.w	$0002,$0000,$9249,$0002,$0086,$0000,$9249,$0086
	 dc.w	$4186,$0000,$9249,$4186,$6180,$0000,$9249,$6186
	 dc.w	$6000,$0000,$9249,$6186,$0006,$0006,$924F,$6180
	 dc.w	$0186,$0186,$93CF,$6000,$6184,$6184,$F3CF,$0000
	 dc.w	$6000,$6000,$F7DE,$0000,$0000,$0000,$FEF8,$0000

esprite:
	 dc.w	$0004,$0008,$FFF0,$0000,$0000,$0000,$9000,$0000
	 dc.w	$0000,$0000,$9000,$0000,$0000,$0000,$9000,$0000
	 dc.w	$0000,$0000,$9000,$0000,$0000,$0000,$9000,$0000
	 dc.w	$2010,$0020,$9FC0,$2000,$6000,$0000,$9000,$6000
	 dc.w	$6000,$0000,$9000,$6000,$0000,$0000,$9000,$6000
	 dc.w	$0000,$0000,$9000,$6000,$6000,$6000,$F000,$0000
	 dc.w	$6000,$6000,$F000,$0000,$0000,$0000,$FFFC,$0000

even
*350
rampat:
 dc.w 161,022
 dc.w 160,022
 dc.w 159,022
 dc.w 158,022
 dc.w 157,022
 dc.w 156,022
 dc.w 154,022
 dc.w 152,022
 dc.w 150,022
 dc.w 149,022
 dc.w 147,022
 dc.w 146,022
 dc.w 144,022
 dc.w 142,022
 dc.w 140,022
 dc.w 139,022
 dc.w 137,022
 dc.w 136,022
 dc.w 134,022
 dc.w 132,022
 dc.w 131,021
 dc.w 129,020
 dc.w 127,020
 dc.w 126,019
 dc.w 124,018
 dc.w 122,017
 dc.w 121,016
 dc.w 119,015
 dc.w 118,014
 dc.w 117,013
 dc.w 116,012
 dc.w 116,011
 dc.w 116,010
 dc.w 116,009
 dc.w 116,008
 dc.w 117,007
 dc.w 118,006
 dc.w 118,005
 dc.w 120,004
 dc.w 121,003
 dc.w 122,002
 dc.w 123,001
 dc.w 125,001
 dc.w 126,000
 dc.w 127,000
 dc.w 128,000
 dc.w 129,000
 dc.w 130,000
 dc.w 131,000
 dc.w 132,000
 dc.w 133,000
 dc.w 134,000
 dc.w 135,001
 dc.w 135,002
 dc.w 136,003
 dc.w 137,004
 dc.w 138,005
 dc.w 138,007
 dc.w 138,009
 dc.w 138,010
 dc.w 138,011
 dc.w 138,012
 dc.w 138,013
 dc.w 138,014
 dc.w 137,015
 dc.w 135,016
 dc.w 133,017
 dc.w 132,017
 dc.w 131,017
 dc.w 129,017
 dc.w 127,017
 dc.w 126,017
 dc.w 124,017
 dc.w 123,017
 dc.w 122,017
 dc.w 121,017
 dc.w 121,016
 dc.w 120,016
 dc.w 120,014
 dc.w 120,013
 dc.w 120,011
 dc.w 120,010
 dc.w 120,008
 dc.w 121,007
 dc.w 122,006
 dc.w 123,005
 dc.w 124,004
 dc.w 126,003
 dc.w 127,002
 dc.w 129,001
 dc.w 131,000
 dc.w 133,000
 dc.w 135,000
 dc.w 138,000
 dc.w 140,000
 dc.w 142,000
 dc.w 144,000
 dc.w 146,000
 dc.w 148,000
 dc.w 150,000
 dc.w 151,000
 dc.w 154,000
 dc.w 156,000
 dc.w 159,000
 dc.w 161,000
 dc.w 164,000
 dc.w 166,000
 dc.w 168,000
 dc.w 171,000
 dc.w 173,000
 dc.w 175,000
 dc.w 178,000
 dc.w 180,000
 dc.w 183,000
 dc.w 186,000
 dc.w 188,000
 dc.w 190,000
 dc.w 192,000
 dc.w 194,000
 dc.w 197,000
 dc.w 200,000
 dc.w 202,000
 dc.w 204,000
 dc.w 207,000
 dc.w 210,000
 dc.w 212,000
 dc.w 215,000
 dc.w 217,000
 dc.w 219,000
 dc.w 221,000
 dc.w 223,000
 dc.w 225,000
 dc.w 226,000
 dc.w 228,000
 dc.w 230,000
 dc.w 231,000
 dc.w 234,000
 dc.w 236,000
 dc.w 238,000
 dc.w 240,000
 dc.w 242,000
 dc.w 243,000
 dc.w 245,000
 dc.w 246,000
 dc.w 248,000
 dc.w 250,000
 dc.w 251,000
 dc.w 253,000
 dc.w 254,000
 dc.w 256,000
 dc.w 258,000
 dc.w 259,000
 dc.w 261,000
 dc.w 263,000
 dc.w 265,000
 dc.w 266,000
 dc.w 268,000
 dc.w 270,001
 dc.w 272,001
 dc.w 273,001
 dc.w 274,001
 dc.w 276,002
 dc.w 277,002
 dc.w 278,003
 dc.w 279,003
 dc.w 280,004
 dc.w 280,005
 dc.w 280,006
 dc.w 281,007
 dc.w 281,008
 dc.w 282,009
 dc.w 282,011
 dc.w 282,012
 dc.w 282,013
 dc.w 282,015
 dc.w 282,016
 dc.w 282,017
 dc.w 282,018
 dc.w 281,019
 dc.w 281,020
 dc.w 280,021
 dc.w 279,022
 dc.w 278,022
 dc.w 276,022
 dc.w 274,022
 dc.w 272,022
 dc.w 270,022
 dc.w 268,022
 dc.w 267,022
 dc.w 265,022
 dc.w 263,022
 dc.w 262,022
 dc.w 261,020
 dc.w 260,019
 dc.w 259,018
 dc.w 259,016
 dc.w 259,015
 dc.w 259,014
 dc.w 259,012
 dc.w 259,011
 dc.w 259,010
 dc.w 259,009
 dc.w 260,008
 dc.w 261,007
 dc.w 262,006
 dc.w 263,005
 dc.w 264,004
 dc.w 265,003
 dc.w 266,003
 dc.w 267,002
 dc.w 268,002
 dc.w 269,002
 dc.w 270,002
 dc.w 272,002
 dc.w 274,002
 dc.w 275,002
 dc.w 276,002
 dc.w 277,003
 dc.w 278,003
 dc.w 278,004
 dc.w 279,005
 dc.w 279,007
 dc.w 280,007
 dc.w 280,009
 dc.w 280,011
 dc.w 280,012
 dc.w 280,013
 dc.w 280,014
 dc.w 279,015
 dc.w 279,016
 dc.w 279,017
 dc.w 278,018
 dc.w 277,019
 dc.w 275,020
 dc.w 274,021
 dc.w 273,022
 dc.w 272,022
 dc.w 271,022
 dc.w 270,022
 dc.w 269,022
 dc.w 267,022
 dc.w 266,022
 dc.w 265,022
 dc.w 263,022
 dc.w 262,022
 dc.w 261,022
 dc.w 259,022
 dc.w 258,022
 dc.w 257,022
 dc.w 256,022
 dc.w 255,022
 dc.w 254,022
 dc.w 253,022
 dc.w 252,022
 dc.w 251,022
 dc.w 250,022
 dc.w 249,022
 dc.w 248,022
 dc.w 247,022
 dc.w 246,022
 dc.w 245,022
 dc.w 244,022
 dc.w 243,022
 dc.w 242,022
 dc.w 241,022
 dc.w 240,022
 dc.w 239,022
 dc.w 238,022
 dc.w 237,022
 dc.w 236,022
 dc.w 235,022
 dc.w 234,022
 dc.w 233,022
 dc.w 232,022
 dc.w 231,022
 dc.w 230,022
 dc.w 229,022
 dc.w 228,022
 dc.w 227,022
 dc.w 226,022
 dc.w 225,022
 dc.w 224,022
 dc.w 223,022
 dc.w 222,022
 dc.w 221,022
 dc.w 220,022
 dc.w 219,022
 dc.w 218,022
 dc.w 217,022
 dc.w 216,022
 dc.w 215,022
 dc.w 214,022
 dc.w 213,022
 dc.w 212,022
 dc.w 211,022
 dc.w 210,022
 dc.w 209,022
 dc.w 208,022
 dc.w 207,022
 dc.w 206,022
 dc.w 205,022
 dc.w 204,022
 dc.w 203,022
 dc.w 202,022
 dc.w 201,022
 dc.w 200,022
 dc.w 199,022
 dc.w 198,022
 dc.w 197,022
 dc.w 196,022
 dc.w 195,022
 dc.w 194,022
 dc.w 193,022
 dc.w 192,022
 dc.w 191,022
 dc.w 190,022
 dc.w 189,022
 dc.w 188,022
 dc.w 187,022
 dc.w 186,022
 dc.w 185,022
 dc.w 184,022
 dc.w 183,022
 dc.w 182,022
 dc.w 181,022
 dc.w 180,022
 dc.w 179,022
 dc.w 178,022
 dc.w 177,022
 dc.w 176,022
 dc.w 175,022
 dc.w 174,022
 dc.w 173,022
 dc.w 172,022
 dc.w 171,022
 dc.w 170,022
 dc.w 169,022
 dc.w 168,022
 dc.w 167,022
 dc.w 166,022
 dc.w 165,022
 dc.w 164,022
 dc.w 163,022
 dc.w 162,022
 dc.w 161,022
 dc.w 160,022
 dc.w 159,022
 dc.w 158,022
 dc.w 157,022
 dc.w 156,022
 dc.w 175,022
***********************************************
*	heli sprites
heli1sp:
	 dc.w	$0077,$0077,$0077,$0008,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0180,$0000,$0000,$0000,$C000
	 dc.w	$0000,$0000,$0000,$0600,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0100,$0100,$0100,$0001,$0000,$0000,$0000,$0000
	 dc.w	$2200,$2200,$2200,$0000,$0000,$0000,$0000,$8000
	 dc.w	$31FF,$30FF,$2000,$11FF,$1200,$1200,$0200,$3000
	 dc.w	$31FF,$107F,$0000,$71FF,$3000,$1000,$0000,$3100
	 dc.w	$71DF,$505F,$4001,$31FE,$3800,$1800,$0800,$3100
	 dc.w	$B183,$901F,$8001,$31FE,$B800,$9800,$8800,$3080
	 dc.w	$BF83,$8057,$8001,$3FFE,$1000,$F000,$0000,$F080
	 dc.w	$BF83,$8067,$8002,$3FF5,$1000,$F000,$0000,$F080
	 dc.w	$3FE3,$0063,$0061,$BF82,$9000,$F000,$8000,$7000
	 dc.w	$3F91,$0075,$0010,$BFE7,$1000,$F000,$0000,$F000
	 dc.w	$31A2,$007A,$0020,$31DF,$F080,$1080,$0080,$F000
	 dc.w	$31E2,$107E,$1060,$219F,$3080,$1080,$0080,$B000
	 dc.w	$31FE,$1022,$1020,$21DF,$3100,$1100,$0100,$3000
	 dc.w	$31FF,$0001,$0000,$31FF,$3000,$1000,$0000,$3000
	 dc.w	$11EF,$0011,$0000,$31FF,$3000,$1000,$0000,$3000
	 dc.w	$0030,$0010,$0000,$2430,$0000,$0000,$0000,$0000
	 dc.w	$1030,$1010,$1000,$0230,$2000,$2000,$2000,$0400
	 dc.w	$0030,$0010,$0000,$0830,$8000,$8000,$8000,$0800
	 dc.w	$0620,$0600,$0600,$0030,$3000,$3000,$3000,$0000
	 dc.w	$0030,$0010,$0000,$0030,$0000,$0000,$0000,$0000
	 dc.w	$0070,$0070,$0070,$0008,$0000,$0000,$0000,$0000
	 dc.w	$0030,$0010,$0000,$0030,$0000,$0000,$0000,$0000
	 dc.w	$0030,$0010,$0000,$0030,$0000,$0000,$0000,$0000
	 dc.w	$0030,$0010,$0000,$0030,$0000,$0000,$0000,$0000
	 dc.w	$0030,$0010,$0000,$0030,$0000,$0000,$0000,$0000
	 dc.w	$00EE,$001E,$0000,$00FE,$0000,$0000,$0000,$0000
	 dc.w	$00E8,$0016,$0000,$00FE,$0000,$0000,$0000,$0000
	 dc.w	$0010,$0010,$0000,$0010,$0000,$0000,$0000,$0000
	 dc.w	$0010,$0010,$0000,$0010,$0000,$0000,$0000,$0000
	 dc.w	$0010,$0010,$0000,$0010,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0010,$0000,$0010,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0010,$0000,$0010,$0000,$0000,$0000,$0000
	 dc.w	$0010,$0000,$0000,$0010,$0000,$0000,$0000,$0000

heli2sp:
	 dc.w	$0076,$0076,$0076,$0008,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0181,$0000,$0000,$0000,$8000
	 dc.w	$0000,$0000,$0000,$0200,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0100,$0100,$0100,$0002,$0000,$0000,$0000,$0000
	 dc.w	$1200,$1200,$1200,$0001,$0000,$0000,$0000,$0000
	 dc.w	$1080,$107F,$1000,$00FF,$8800,$8C00,$0800,$C400
	 dc.w	$0281,$007F,$0000,$22FF,$8800,$8000,$0000,$8C00
	 dc.w	$2287,$207F,$2000,$02FF,$9800,$9000,$1000,$8C00
	 dc.w	$43DF,$4007,$4002,$03FD,$9C00,$9400,$1000,$8E00
	 dc.w	$439F,$4007,$4003,$03FC,$FC00,$8400,$0000,$FE00
	 dc.w	$43D7,$4007,$4002,$03FD,$FC00,$8400,$0000,$FE00
	 dc.w	$03C7,$0007,$0004,$43D3,$FC00,$8400,$0000,$FC00
	 dc.w	$03E7,$0067,$0063,$4384,$FC00,$8400,$0000,$FC00
	 dc.w	$02FB,$0013,$0010,$02EF,$8E00,$8600,$0200,$8C00
	 dc.w	$0AFD,$0825,$0820,$02DF,$8E00,$8600,$0200,$8C00
	 dc.w	$0AFC,$0864,$0860,$029F,$8C00,$8400,$0400,$8800
	 dc.w	$02FD,$0021,$0020,$02DF,$8800,$8400,$0000,$8C00
	 dc.w	$02FF,$0001,$0000,$12FF,$8800,$8400,$0000,$8C00
	 dc.w	$0018,$0008,$0000,$1018,$0000,$0000,$0000,$0000
	 dc.w	$0818,$0808,$0800,$0218,$4000,$4000,$4000,$0000
	 dc.w	$0019,$0009,$0001,$0418,$0000,$0000,$0000,$1000
	 dc.w	$0208,$0208,$0200,$0018,$6000,$6000,$6000,$0000
	 dc.w	$0018,$0008,$0000,$0018,$0000,$0000,$0000,$0000
	 dc.w	$0070,$0070,$0070,$0008,$0000,$0000,$0000,$0000
	 dc.w	$0018,$0008,$0000,$0018,$0000,$0000,$0000,$0000
	 dc.w	$0018,$0008,$0000,$0018,$0000,$0000,$0000,$0000
	 dc.w	$0018,$0008,$0000,$0018,$0000,$0000,$0000,$0000
	 dc.w	$0018,$0008,$0000,$0018,$0000,$0000,$0000,$0000
	 dc.w	$0078,$0008,$0000,$0078,$0000,$0000,$0000,$0000
	 dc.w	$007A,$000E,$0000,$007E,$0000,$0000,$0000,$0000
	 dc.w	$001C,$000A,$0000,$001E,$0000,$0000,$0000,$0000
	 dc.w	$0008,$0008,$0000,$0008,$0000,$0000,$0000,$0000
	 dc.w	$0008,$0008,$0000,$0008,$0000,$0000,$0000,$0000
	 dc.w	$0008,$0008,$0000,$0008,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0008,$0000,$0008,$0000,$0000,$0000,$0000
	 dc.w	$0008,$0000,$0000,$0008,$0000,$0000,$0000,$0000

heli3sp:
	 dc.w	$00FC,$00FC,$00FC,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0102,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0600,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0004,$0000,$0000,$0000,$0000
	 dc.w	$0200,$0200,$0200,$0002,$0000,$0000,$0000,$0000
	 dc.w	$6202,$21FE,$0000,$63FF,$0000,$0000,$0000,$0000
	 dc.w	$4302,$00FF,$0000,$63FF,$8000,$8000,$0000,$9000
	 dc.w	$63C6,$203F,$2000,$43FF,$C000,$C000,$4000,$9000
	 dc.w	$63BE,$603F,$4004,$23FB,$C000,$C000,$4000,$8800
	 dc.w	$673E,$783F,$4006,$3FF9,$8000,$8000,$0000,$8800
	 dc.w	$67BE,$783F,$4004,$3FFB,$8000,$8000,$0000,$8800
	 dc.w	$27CE,$380F,$0008,$7FE7,$8000,$8000,$0000,$8000
	 dc.w	$27E6,$38E7,$00C6,$7F21,$8000,$8000,$0000,$8000
	 dc.w	$7FE7,$2026,$0020,$7FCF,$8800,$8800,$0800,$8000
	 dc.w	$73EB,$306A,$1040,$63BF,$8800,$8800,$0800,$8000
	 dc.w	$73F9,$30C0,$10C0,$633F,$9000,$9000,$1000,$8000
	 dc.w	$63FB,$2042,$0040,$63BF,$8000,$8000,$0000,$8000
	 dc.w	$63FF,$2000,$0000,$63FF,$8000,$8000,$0000,$8000
	 dc.w	$0030,$0010,$0000,$0430,$0000,$0000,$0000,$0000
	 dc.w	$1031,$1011,$1001,$0230,$0000,$0000,$0000,$2000
	 dc.w	$0032,$0012,$0002,$0830,$0000,$0000,$0000,$4000
	 dc.w	$0611,$0611,$0601,$0030,$8000,$8000,$8000,$0000
	 dc.w	$0030,$0010,$0000,$0030,$0000,$0000,$0000,$0000
	 dc.w	$00F0,$00F0,$00E0,$0010,$0000,$0000,$0000,$0000
	 dc.w	$0030,$0010,$0000,$0030,$0000,$0000,$0000,$0000
	 dc.w	$0030,$0010,$0000,$0030,$0000,$0000,$0000,$0000
	 dc.w	$0030,$0010,$0000,$0030,$0000,$0000,$0000,$0000
	 dc.w	$0030,$0010,$0000,$0030,$0000,$0000,$0000,$0000
	 dc.w	$0038,$0018,$0000,$0038,$0000,$0000,$0000,$0000
	 dc.w	$00F8,$00F8,$0000,$00F8,$0000,$0000,$0000,$0000
	 dc.w	$0130,$00F0,$0000,$01F0,$0000,$0000,$0000,$0000
	 dc.w	$0010,$0010,$0000,$0010,$0000,$0000,$0000,$0000
	 dc.w	$0010,$0010,$0000,$0010,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0010,$0000,$0010,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0010,$0000,$0010,$0000,$0000,$0000,$0000
	 dc.w	$0010,$0000,$0000,$0010,$0000,$0000,$0000,$0000

heli4sp:
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$003B,$003B,$003B,$0004,$8000,$8000,$8000,$0000
	 dc.w	$0000,$0000,$0000,$0300,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0080,$0080,$0080,$0000,$0000,$0000,$0000,$8000
	 dc.w	$1000,$1000,$1000,$0000,$0100,$0100,$0100,$1000
	 dc.w	$0000,$0000,$0000,$2000,$0000,$0000,$0000,$0080
	 dc.w	$4040,$400F,$4000,$007F,$C400,$C400,$C400,$0040
	 dc.w	$4060,$400B,$4000,$007F,$C000,$C000,$8000,$4040
	 dc.w	$4C61,$4411,$4001,$0C78,$CC00,$C400,$0000,$CC40
	 dc.w	$0C68,$0418,$0008,$4C71,$CC00,$C400,$0000,$CC00
	 dc.w	$0C70,$041D,$0010,$0C6F,$4C40,$4440,$0040,$CC00
	 dc.w	$0FF0,$083F,$0830,$07CF,$0440,$3C40,$0040,$FC00
	 dc.w	$0FFF,$0000,$0000,$0FFF,$8400,$7C00,$0000,$FC00
	 dc.w	$0C7F,$0000,$0000,$1C7F,$FC00,$0400,$0000,$FC00
	 dc.w	$0C7F,$0804,$0800,$057F,$DC00,$5400,$1000,$CE00
	 dc.w	$087F,$0004,$0000,$0C7F,$C800,$4000,$4000,$8C00
	 dc.w	$0F04,$0304,$0300,$0C0C,$1C00,$1C00,$1800,$0400
	 dc.w	$0038,$0038,$0038,$0004,$0000,$0000,$0000,$0000
	 dc.w	$000C,$0004,$0000,$000C,$0000,$0000,$0000,$0000
	 dc.w	$000C,$0004,$0000,$000C,$0000,$0000,$0000,$0000
	 dc.w	$000C,$0004,$0000,$000C,$0000,$0000,$0000,$0000
	 dc.w	$000C,$0004,$0000,$000C,$0000,$0000,$0000,$0000
	 dc.w	$000C,$0004,$0000,$000C,$0000,$0000,$0000,$0000
	 dc.w	$0078,$0007,$0000,$007F,$8000,$8000,$0000,$8000
	 dc.w	$007A,$0005,$0000,$007F,$0000,$8000,$0000,$8000
	 dc.w	$0004,$0004,$0000,$0004,$0000,$0000,$0000,$0000
	 dc.w	$0004,$0004,$0000,$0004,$0000,$0000,$0000,$0000
	 dc.w	$0004,$0004,$0000,$0004,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0004,$0000,$0004,$0000,$0000,$0000,$0000
	 dc.w	$0004,$0000,$0000,$0004,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000

heli5sp:
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0077,$0077,$0077,$0008,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0600,$0000,$0000,$0000,$0000
	 dc.w	$1800,$0800,$0000,$1800,$0C00,$0400,$0000,$0C00
	 dc.w	$19FE,$09FE,$0100,$18FF,$8C00,$8400,$0000,$8C00
	 dc.w	$39FF,$28FF,$2000,$19FF,$8E00,$8600,$0200,$AC00
	 dc.w	$19FF,$08FF,$0000,$59FF,$8C00,$8400,$0000,$8D00
	 dc.w	$9F9F,$801F,$8001,$1FFE,$8800,$FC00,$8800,$7480
	 dc.w	$9FD7,$8057,$8001,$1FFE,$0000,$FC00,$0000,$FC80
	 dc.w	$9FC3,$8023,$8002,$1FF1,$0400,$FC00,$0000,$FC80
	 dc.w	$18D1,$0031,$0010,$98E3,$8C00,$8400,$0000,$8C00
	 dc.w	$18E0,$003A,$0020,$18DF,$8C80,$8480,$0080,$8C00
	 dc.w	$18E0,$107E,$1060,$089F,$0C80,$0480,$0080,$8C00
	 dc.w	$00C1,$003F,$0000,$00FF,$8000,$8000,$0000,$8000
	 dc.w	$00FF,$0001,$0000,$20FF,$8000,$8000,$0000,$8000
	 dc.w	$1018,$1008,$1000,$0218,$2000,$2000,$2000,$0400
	 dc.w	$0018,$0008,$0000,$0818,$8000,$8000,$8000,$0800
	 dc.w	$0608,$0608,$0600,$0018,$3000,$3000,$3000,$0000
	 dc.w	$0070,$0070,$0070,$0008,$0000,$0000,$0000,$0000
	 dc.w	$0018,$0008,$0000,$0018,$0000,$0000,$0000,$0000
	 dc.w	$0018,$0008,$0000,$0018,$0000,$0000,$0000,$0000
	 dc.w	$0018,$0008,$0000,$0018,$0000,$0000,$0000,$0000
	 dc.w	$0018,$0008,$0000,$0018,$0000,$0000,$0000,$0000
	 dc.w	$0070,$000F,$0000,$007F,$0000,$0000,$0000,$0000
	 dc.w	$0077,$0008,$0000,$007F,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0008,$0000,$0008,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0008,$0000,$0008,$0000,$0000,$0000,$0000
	 dc.w	$0008,$0000,$0000,$0008,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000

heli6sp:
	 dc.w	$0000,$0000,$0000,$0006,$0000,$0000,$0000,$0000
	 dc.w	$0020,$0020,$0020,$0002,$C000,$C000,$C000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0010,$0010,$0010,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0040,$0000,$0000,$0000,$1000
	 dc.w	$0001,$0001,$0000,$0001,$0000,$0000,$0000,$1000
	 dc.w	$0827,$0827,$0820,$0007,$1800,$0800,$0800,$1000
	 dc.w	$182F,$1837,$1820,$021F,$1800,$0800,$0800,$1000
	 dc.w	$10F9,$1021,$1020,$00DF,$9800,$8800,$0000,$9800
	 dc.w	$00F1,$0011,$0010,$10EF,$B800,$A800,$2000,$9800
	 dc.w	$20F7,$2006,$2000,$00FF,$F800,$0800,$0000,$F800
	 dc.w	$22E7,$2107,$2000,$03EF,$F800,$0800,$0000,$F800
	 dc.w	$2227,$2127,$2020,$03C7,$9800,$8800,$0000,$9800
	 dc.w	$02FF,$001B,$0018,$03E7,$9800,$8800,$0000,$B800
	 dc.w	$1BFF,$1808,$1808,$23F7,$B800,$A800,$2000,$D800
	 dc.w	$03FF,$0008,$0008,$63F7,$F800,$6000,$6000,$9800
	 dc.w	$03FF,$0008,$0000,$03FF,$C000,$4000,$4000,$8000
	 dc.w	$02FE,$0108,$0000,$03FE,$0000,$0000,$0000,$0000
	 dc.w	$0219,$0109,$0001,$0318,$0000,$0000,$0000,$0000
	 dc.w	$1219,$1109,$1001,$0318,$0000,$0000,$0000,$0000
	 dc.w	$0338,$0028,$0020,$131C,$0000,$0000,$0000,$0000
	 dc.w	$0818,$0808,$0808,$0010,$0000,$0000,$0000,$0000
	 dc.w	$0E18,$0E08,$0E00,$0118,$0000,$0000,$0000,$0000
	 dc.w	$001A,$000A,$0000,$001A,$0000,$0000,$0000,$0000
	 dc.w	$001C,$0002,$0000,$001E,$0000,$0000,$0000,$0000
	 dc.w	$0038,$0004,$0000,$003C,$0000,$0000,$0000,$0000
	 dc.w	$0078,$0008,$0000,$0078,$0000,$0000,$0000,$0000
	 dc.w	$0008,$0008,$0000,$0008,$0000,$0000,$0000,$0000
	 dc.w	$0008,$0008,$0000,$0008,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0008,$0000,$0008,$0000,$0000,$0000,$0000
	 dc.w	$0008,$0000,$0000,$0008,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000

heli7sp:
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$3800,$3800,$3800,$0400,$0000,$0000,$0000,$0000
	 dc.w	$2020,$2020,$2020,$0000,$0000,$0000,$0000,$0000
	 dc.w	$1080,$0080,$0080,$5010,$0000,$0000,$0000,$0000
	 dc.w	$5004,$4004,$4004,$1000,$0000,$0000,$0000,$0000
	 dc.w	$1004,$0004,$0004,$1000,$0000,$0000,$0000,$0000
	 dc.w	$1000,$0400,$0000,$1400,$0000,$0000,$0000,$0000
	 dc.w	$1001,$0781,$0001,$1780,$0000,$0000,$0000,$0000
	 dc.w	$1825,$07FD,$0021,$9FDC,$E000,$A000,$8000,$6000
	 dc.w	$7820,$67FC,$6020,$9FDD,$E000,$A000,$8000,$6000
	 dc.w	$1864,$03FC,$0060,$1F9C,$6000,$2000,$0000,$E000
	 dc.w	$989C,$84FC,$8080,$1F7C,$6000,$2000,$0000,$6000
	 dc.w	$9E5F,$8018,$8000,$1E7F,$E000,$2000,$0000,$E000
	 dc.w	$9E5F,$8018,$8000,$1E7F,$E000,$2000,$0000,$E000
	 dc.w	$07C7,$0040,$0040,$47BF,$E000,$A000,$8000,$6000
	 dc.w	$47E4,$40A4,$4080,$077C,$6000,$2000,$0000,$6000
	 dc.w	$67FC,$60BC,$6080,$0F7C,$6000,$2000,$2000,$4000
	 dc.w	$27FC,$20BC,$2080,$077C,$6000,$2000,$2000,$4000
	 dc.w	$00FC,$001C,$0000,$00FC,$2000,$2000,$0000,$6000
	 dc.w	$00C0,$0040,$0000,$01C0,$0000,$0000,$0000,$4000
	 dc.w	$00C0,$0040,$0040,$0080,$0000,$0000,$0000,$0000
	 dc.w	$00C0,$0040,$0000,$00C0,$0000,$0000,$0000,$0000
	 dc.w	$00C0,$0040,$0000,$00C0,$0000,$0000,$0000,$0000
	 dc.w	$00C3,$00C3,$0083,$0048,$0000,$0000,$0000,$0000
	 dc.w	$00C0,$0040,$0000,$00D8,$0000,$0000,$0000,$0000
	 dc.w	$00C0,$0140,$0000,$01C0,$0000,$0000,$0000,$0000
	 dc.w	$01C0,$0040,$0000,$01C0,$0000,$0000,$0000,$0000
	 dc.w	$00E0,$0040,$0000,$00E0,$0000,$0000,$0000,$0000
	 dc.w	$0040,$0070,$0000,$0070,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0040,$0000,$0040,$0000,$0000,$0000,$0000
	 dc.w	$0040,$0000,$0000,$0040,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000

heli8sp:
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0060,$0000,$0000,$0000,$0000
	 dc.w	$0304,$0304,$0304,$0040,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0008,$0008,$0008,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0802,$0000,$0000,$0000,$0000
	 dc.w	$0200,$0000,$0000,$0A00,$0000,$0000,$0000,$0000
	 dc.w	$7384,$3044,$1004,$63C0,$1000,$1000,$1000,$0000
	 dc.w	$73E4,$3034,$1004,$63F0,$1800,$1800,$1800,$4000
	 dc.w	$639C,$201C,$0004,$63F8,$0800,$0800,$0800,$0000
	 dc.w	$678E,$240E,$0408,$63F6,$0000,$0000,$0000,$0800
	 dc.w	$41EE,$3E2E,$0000,$7FFE,$0400,$0400,$0400,$0000
	 dc.w	$61E7,$3E26,$0000,$7FF7,$0400,$0400,$0400,$0000
	 dc.w	$63E4,$2004,$0004,$63E3,$8400,$8400,$0400,$8000
	 dc.w	$63FF,$201E,$0018,$67E7,$0000,$0000,$0000,$8000
	 dc.w	$65FF,$2413,$0410,$63EF,$9800,$9800,$1800,$8400
	 dc.w	$67FF,$2613,$0610,$61EF,$8000,$8000,$0000,$8600
	 dc.w	$03FF,$0210,$0200,$01FF,$8000,$8000,$0000,$8000
	 dc.w	$003F,$0010,$0000,$003F,$8000,$8000,$0000,$8000
	 dc.w	$00B1,$0090,$0080,$0031,$8000,$8000,$0000,$8000
	 dc.w	$00B1,$0090,$0080,$0031,$8800,$8800,$0800,$8000
	 dc.w	$0015,$0014,$0004,$0031,$8000,$8000,$0000,$8800
	 dc.w	$0030,$0010,$0010,$0020,$1000,$1000,$1000,$0000
	 dc.w	$0030,$0010,$0000,$0030,$7000,$7000,$7000,$8000
	 dc.w	$0030,$0010,$0000,$0030,$0000,$0000,$0000,$0000
	 dc.w	$01F0,$00F0,$0000,$01F0,$0000,$0000,$0000,$0000
	 dc.w	$00F0,$0010,$0000,$00F0,$0000,$0000,$0000,$0000
	 dc.w	$0038,$0018,$0000,$0038,$0000,$0000,$0000,$0000
	 dc.w	$0010,$0010,$0000,$0010,$0000,$0000,$0000,$0000
	 dc.w	$0010,$0010,$0000,$0010,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0010,$0000,$0010,$0000,$0000,$0000,$0000
	 dc.w	$0010,$0000,$0000,$0010,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000

heli9sp:
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0001,$E000,$E000,$E000,$0000
	 dc.w	$0020,$0020,$0020,$0000,$2000,$2000,$2000,$0000
	 dc.w	$0008,$0008,$0008,$0040,$0000,$0000,$0000,$1000
	 dc.w	$0101,$0100,$0100,$0001,$9000,$9000,$1000,$8000
	 dc.w	$0101,$0100,$0100,$0001,$0000,$8000,$0000,$8000
	 dc.w	$0001,$0000,$0000,$0001,$0000,$8000,$0000,$8000
	 dc.w	$041D,$0402,$0400,$001F,$0000,$8000,$0000,$8000
	 dc.w	$0CE1,$0C3F,$0C20,$00DF,$8000,$8000,$0000,$8C00
	 dc.w	$6BA1,$287F,$0820,$67DF,$B000,$B000,$3000,$8800
	 dc.w	$6032,$23FE,$0030,$6BCF,$0000,$8000,$0000,$8000
	 dc.w	$6209,$21F8,$0008,$63F7,$0800,$8800,$0800,$8000
	 dc.w	$630F,$20DE,$0000,$63FF,$0800,$8800,$0800,$8000
	 dc.w	$43D7,$3C56,$0000,$7FF7,$0800,$8800,$0800,$8000
	 dc.w	$4917,$3E16,$0810,$77E7,$0000,$8000,$0000,$9000
	 dc.w	$412E,$3E2E,$0008,$7FE6,$1000,$1000,$1000,$0000
	 dc.w	$63FE,$203E,$2008,$43F6,$3000,$3000,$3000,$8000
	 dc.w	$63FE,$203C,$2008,$43F6,$2000,$2000,$2000,$0000
	 dc.w	$43FC,$2038,$0000,$73FC,$0000,$0000,$0000,$0000
	 dc.w	$43F0,$2010,$0000,$73F4,$0000,$0000,$0000,$0000
	 dc.w	$0030,$0010,$0010,$0020,$0000,$0000,$0000,$0000
	 dc.w	$0030,$0010,$0000,$0030,$0000,$0000,$0000,$0000
	 dc.w	$0030,$0010,$0000,$0030,$0000,$0000,$0000,$0000
	 dc.w	$0638,$0618,$0608,$00B0,$0000,$0000,$0000,$0000
	 dc.w	$0030,$0010,$0000,$00F0,$0000,$0000,$0000,$0000
	 dc.w	$0030,$0010,$0000,$0030,$0000,$0000,$0000,$0000
	 dc.w	$0038,$0018,$0000,$0038,$0000,$0000,$0000,$0000
	 dc.w	$0038,$0018,$0000,$0038,$0000,$0000,$0000,$0000
	 dc.w	$0010,$0070,$0000,$0070,$0000,$0000,$0000,$0000
	 dc.w	$0010,$00D0,$0000,$00D0,$0000,$0000,$0000,$0000
	 dc.w	$0010,$0010,$0000,$0010,$0000,$0000,$0000,$0000
	 dc.w	$0010,$0010,$0000,$0010,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000

heli1mask:
	 dc.w	$007F,$0000,$0180,$C000,$0600,$0000,$0000,$0000
	 dc.w	$0101,$0000,$2200,$8000,$31FF,$3200,$71FF,$3100
	 dc.w	$71FF,$3900,$B1FF,$B880,$BFFF,$F080,$BFF7,$F080
	 dc.w	$BFE3,$F000,$BFF7,$F000,$31FF,$F080,$31FF,$B080
	 dc.w	$31FF,$3100,$31FF,$3000,$31FF,$3000,$2430,$0000
	 dc.w	$1230,$2400,$0830,$8800,$0630,$3000,$0030,$0000
	 dc.w	$0078,$0000,$0030,$0000,$0030,$0000,$0030,$0000
	 dc.w	$0030,$0000,$00FE,$0000,$00FE,$0000,$0010,$0000
	 dc.w	$0010,$0000,$0010,$0000,$0010,$0000,$0010,$0000
	 dc.w	$0010,$0000
heli2mask:
	 dc.w	$007E,$0000,$0181,$8000,$0200,$0000,$0000,$0000
	 dc.w	$0102,$0000,$1201,$0000,$10FF,$CC00,$22FF,$8C00
	 dc.w	$22FF,$9C00,$43FF,$9E00,$43FF,$FE00,$43FF,$FE00
	 dc.w	$43D7,$FC00,$43E7,$FC00,$02FF,$8E00,$0AFF,$8E00
	 dc.w	$0AFF,$8C00,$02FF,$8C00,$12FF,$8C00,$1018,$0000
	 dc.w	$0A18,$4000,$0419,$1000,$0218,$6000,$0018,$0000
	 dc.w	$0078,$0000,$0018,$0000,$0018,$0000,$0018,$0000
	 dc.w	$0018,$0000,$0078,$0000,$007E,$0000,$001E,$0000
	 dc.w	$0008,$0000,$0008,$0000,$0008,$0000,$0008,$0000
	 dc.w	$0008,$0000
heli3mask:
	 dc.w	$00FC,$0000,$0102,$0000,$0600,$0000,$0000,$0000
	 dc.w	$0004,$0000,$0202,$0000,$63FF,$0000,$63FF,$9000
	 dc.w	$63FF,$D000,$63FF,$C800,$7FFF,$8800,$7FFF,$8800
	 dc.w	$7FEF,$8000,$7FE7,$8000,$7FEF,$8800,$73FF,$8800
	 dc.w	$73FF,$9000,$63FF,$8000,$63FF,$8000,$0430,$0000
	 dc.w	$1231,$2000,$0832,$4000,$0631,$8000,$0030,$0000
	 dc.w	$00F0,$0000,$0030,$0000,$0030,$0000,$0030,$0000
	 dc.w	$0030,$0000,$0038,$0000,$00F8,$0000,$01F0,$0000
	 dc.w	$0010,$0000,$0010,$0000,$0010,$0000,$0010,$0000
	 dc.w	$0010,$0000
heli4mask:
	 dc.w	$0000,$0000,$0000,$0000,$003F,$8000,$0300,$0000
	 dc.w	$0000,$0000,$0080,$8000,$1000,$1100,$2000,$0080
	 dc.w	$407F,$C440,$407F,$C040,$4C79,$CC40,$4C79,$CC00
	 dc.w	$0C7F,$CC40,$0FFF,$FC40,$0FFF,$FC00,$1C7F,$FC00
	 dc.w	$0D7F,$DE00,$0C7F,$CC00,$0F0C,$1C00,$003C,$0000
	 dc.w	$000C,$0000,$000C,$0000,$000C,$0000,$000C,$0000
	 dc.w	$000C,$0000,$007F,$8000,$007F,$8000,$0004,$0000
	 dc.w	$0004,$0000,$0004,$0000,$0004,$0000,$0004,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000
heli5mask:
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$007F,$0000,$0600,$0000,$1800,$0C00
	 dc.w	$19FF,$8C00,$39FF,$AE00,$59FF,$8D00,$9FFF,$FC80
	 dc.w	$9FFF,$FC80,$9FF3,$FC80,$98F3,$8C00,$18FF,$8C80
	 dc.w	$18FF,$8C80,$00FF,$8000,$20FF,$8000,$1218,$2400
	 dc.w	$0818,$8800,$0618,$3000,$0078,$0000,$0018,$0000
	 dc.w	$0018,$0000,$0018,$0000,$0018,$0000,$007F,$0000
	 dc.w	$007F,$0000,$0008,$0000,$0008,$0000,$0008,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000
heli6mask:
	 dc.w	$0006,$0000,$0022,$C000,$0000,$0000,$0000,$0000
	 dc.w	$0010,$0000,$0040,$1000,$0001,$1000,$0827,$1800
	 dc.w	$1A3F,$1800,$10FF,$9800,$10FF,$B800,$20FF,$F800
	 dc.w	$23EF,$F800,$23E7,$9800,$03FF,$B800,$3BFF,$F800
	 dc.w	$63FF,$F800,$03FF,$C000,$03FE,$0000,$0319,$0000
	 dc.w	$1319,$0000,$133C,$0000,$0818,$0000,$0F18,$0000
	 dc.w	$001A,$0000,$001E,$0000,$003C,$0000,$0078,$0000
	 dc.w	$0008,$0000,$0008,$0000,$0008,$0000,$0008,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000
heli7mask:
	 dc.w	$0000,$0000,$3C00,$0000,$2020,$0000,$5090,$0000
	 dc.w	$5004,$0000,$1004,$0000,$1400,$0000,$1781,$0000
	 dc.w	$9FFD,$E000,$FFFD,$E000,$1FFC,$E000,$9FFC,$6000
	 dc.w	$9E7F,$E000,$9E7F,$E000,$47FF,$E000,$47FC,$6000
	 dc.w	$6FFC,$6000,$27FC,$6000,$00FC,$6000,$01C0,$4000
	 dc.w	$00C0,$0000,$00C0,$0000,$00C0,$0000,$00CB,$0000
	 dc.w	$00D8,$0000,$01C0,$0000,$01C0,$0000,$00E0,$0000
	 dc.w	$0070,$0000,$0040,$0000,$0040,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000
heli8mask:
	 dc.w	$0000,$0000,$0060,$0000,$0344,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0008,$0000,$0802,$0000,$0A00,$0000
	 dc.w	$73C4,$1000,$73F4,$5800,$63FC,$0800,$67FE,$0800
	 dc.w	$7FFE,$0400,$7FF7,$0400,$63E7,$8400,$67FF,$8000
	 dc.w	$67FF,$9C00,$67FF,$8600,$03FF,$8000,$003F,$8000
	 dc.w	$00B1,$8000,$00B1,$8800,$0035,$8800,$0030,$1000
	 dc.w	$0030,$F000,$0030,$0000,$01F0,$0000,$00F0,$0000
	 dc.w	$0038,$0000,$0010,$0000,$0010,$0000,$0010,$0000
	 dc.w	$0010,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000
heli9mask:
	 dc.w	$0000,$0000,$0000,$0000,$0001,$E000,$0020,$2000
	 dc.w	$0048,$1000,$0101,$9000,$0101,$8000,$0001,$8000
	 dc.w	$041F,$8000,$0CFF,$8C00,$6FFF,$B800,$6BFF,$8000
	 dc.w	$63FF,$8800,$63FF,$8800,$7FF7,$8800,$7FF7,$9000
	 dc.w	$7FEE,$1000,$63FE,$B000,$63FE,$2000,$73FC,$0000
	 dc.w	$73F4,$0000,$0030,$0000,$0030,$0000,$0030,$0000
	 dc.w	$06B8,$0000,$00F0,$0000,$0030,$0000,$0038,$0000
	 dc.w	$0038,$0000,$0070,$0000,$00D0,$0000,$0010,$0000
	 dc.w	$0010,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000


