iea:		equ	$fffa07
ieb:		equ	$fffa09
isra:		equ	$fffa0f
ima:		equ	$fffa13
tbcr:		equ	$fffa1b
tbdr:		equ	$fffa21
vbl_vec:	equ	$70
key_vec:	equ	$118
hbl_vec:	equ	$120
magic:		equ	700
magic2:		equ	350
velocity:	equ	10
shotspeed:	equ	400
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
        moveq   #10,d0
        jsr     randomseed
	lea	myvbl,a0
	jsr	putvbl
	move.l	a1,oldvbl1
	move.l	#blackpal,temppal
	jsr	docolors
	jsr	loadpan
	move.l	#paneldlt,dltmemcount
	move.w	#1,dontdlt
	bsr	titlestuff
	move.l	#paneldlt,dltmemcount
	move.w	#-1,dontdlt
	move.w	#0,dltdelay
	move.w	#1,playedatall
restart:
	move.w	#0,getaways
	move.w	#-1,cheat
	move.w	#0,endnum
	move.w	#275,normspeed
	move.w	#2000,energy
	move.w	#0,level
	move.w	#0,score
	move.b	#1,numsflag
	move.l	#filetwi,filename
	jsr	loadscr
res2:	move.w	#-1,hitmeflag
	addq.w	#1,level
	move.b	#1,shipsflag
	move.l	#palette1,temppal
	bsr.L	docolors
	bsr.L	copyintoboth
	bsr	endnumstuff
part1:
	add.w	#15,normspeed
	move.w	#-2,titflag
	bsr.L	getridofhbl
	bsr.L	setuphbl1
	bsr.L	preground
	move.w	normspeed,speed
*	move.w	#250,speed
	move.w	#50,myheight
	move.w	#3,shotlist+2
	move.w	#10,ships
	bsr	restorevalues
	bsr	restorevalues
	bsr.L	clearobjects
	bsr.L	clearshots
	move.w	#10,sortnumber
	move.w	#10,boomcolor
	move.w	#-1200,endoflevel
	bra.L	gameloop1
part2:
	move.l	#palette3,temppal
	bsr.L	getridofhbl
	bsr.L	setuphbl2
	bsr.L	preground2
	move.w	#500,speed
*	move.w	#50,myheight
	move.w	#3,shotlist+2
	move.w	#0,frames
	bsr.L	clearobjects
	bsr.L	clearshots
	move.w	#-1,endoflevel
	move.w	#7,boomcolor
	move.w	#-400,endoflevel
	bsr	maintainhbl2
	bsr	printinfo
	bra.L	gameloop2
part3:
	move.l	#palette4,temppal
	bsr.L	getridofhbl
	bsr.L	setuphbl2
	bsr.L	preground2
	move.w	normspeed,speed
*	move.w	#250,speed
*	move.w	#50,myheight
	move.w	#3,shotlist+2
	bsr.L	clearobjects
	bsr.L	clearshots
	move.w	#0,frames
	move.w	#-1,endoflevel
	move.w	#10,sortnumber
	move.w	#7,boomcolor
	move.w	#-1200,endoflevel
	bra.L	gameloop3
part4:
	move.l	#palettefrac,temppal
	bsr.L	getridofhbl
	bsr.L	setuphblfrac
	bsr.L	prefracscape
	move.w	#0,fracstart
	move.w	#30,fractrend
	move.w	#375,speed
	move.w	#150,myheight
	move.w	#3,shotlist+2
	bsr.L	clearobjects
	bsr.L	clearshots
	move.w	#0,frames
	move.w	#-1,endoflevel
	move.w	#10,sortnumber
	move.w	#7,boomcolor
	move.w	#-500,endoflevel
	bsr	printinfo
	bra.s	gameloop4
gameloop4:
	bsr	joydir2
	bsr	energycontrol
	bsr	dofractrend
	bsr	fracscape
	bsr	printscore
	bsr	printships
*	bsr.s	doradar2
	bsr	flip_scr
	bsr	limits3
	bsr	keyboard
	bsr	amihit
	addq.w	#1,endoflevel
	bpl.s	egloop4
	bra.s	gameloop4
egloop4:
	move.w	#0,speed
*	bsr	joydir2
	bsr	energycontrol
	bsr	dofractrend
	bsr	fracscape
	bsr	printscore
	bsr	printships
*	bsr	doradar2
	bsr	flip_scr
	bsr	limits3
	bsr	keyboard
	bsr	amihit
	tst.w	hitmeflag
	bmi.s	egloop4a
	bra.s	egloop4
egloop4a:
	bra.L	res2

gameloop3:
	bsr	joydir
	bsr	energycontrol
	bsr	ground2
	bsr	doboom
	bsr	shoot
	bsr	dothingspart3
	bsr	drawraceshot
	bsr	detectmultiple
	bsr	mycollisions
	bsr	shotcollisions
	bsr	printscore
	bsr	printships
	bsr	doradar2
	bsr	flip_scr
	bsr	limits2
	bsr	keyboard
	bsr	maintainhbl2
	bsr	amihit
	addq.w	#1,endoflevel
	bpl.s	egloop3
	bra.s	gameloop3
egloop3:
	addq.w	#1,frames
	cmpi.w	#100,frames
	bgt.s	gameloop3enda
	cmpi.w	#99,frames
	blt	ex3
	cmpi.w	#2,level
	ble	part4
ex3:	bra.s	gameloop3

gameloop3enda:
	sub.w	#5,speed
	bmi.s	gameloop3endb
	move.w	#70,frames
	bsr	energycontrol
	bsr	ground2
	bsr	doboom
	bsr	shoot
	bsr	dothingspart3
	bsr	mycollisions
	bsr	shotcollisions
	bsr	printscore
	bsr	printships
	bsr	doradar2
	bsr	flip_scr
	bsr	limits2
	bsr	keyboard
	bsr	maintainhbl2
	bsr	amihit
	bra.s	gameloop3enda
gameloop3endb:
	move.w	#0,xspeed
	move.w	#-1,udflag
	move.w	#0,speed
	subq.w	#1,frames
	bmi.s	gameloop3end		
	bsr	energycontrol
	bsr	ground2
	bsr	dothings4
	bsr	printscore
	bsr	printships
	bsr	doradar2
	bsr	flip_scr
	bsr	keyboard
	bsr	maintainhbl2
	move.w	#0,endhits
	bra.s	gameloop3endb
gameloop3end:
	move.w	#1,udflag
	move.w	#0,speed
	bsr	energycontrol
	bsr	joydir
	bsr	ground2
	bsr	doboom
	bsr	shoot
	bsr	dothings4
	bsr	shotcollisions3
	bsr	printscore
	bsr	printships
	bsr	doradar2
	bsr	flip_scr
	bsr	limits2
	bsr	keyboard
	bsr	maintainhbl2
	bsr	amihit
	move.w	endhits,d0
	cmp.w	endnum,d0
	bge.L	part4
	bra.s	gameloop3end

gameloop2:
	bsr	joydir
	bsr	energycontrol
	bsr	ground2
	bsr	doboom
	bsr	dothingspart2
	bsr	detectmultiple
	bsr	mycollisions2
	bsr	printscore
	bsr	printships
	bsr	doradar3
	bsr	flip_scr
	bsr	limits2
	bsr	keyboard
	bsr	maintainhbl2
	bsr	amihit
	addq.w	#1,endoflevel
	bpl.s	egloop2
	bra.s	gameloop2
egloop2:
	addq.w	#1,frames
	cmpi.w	#100,frames
	bgt.s	gameloop2enda
	bra.s	gameloop2
gameloop2enda:
	bra.L	part3

gameloop1:
	bsr	joydir
	bsr	energycontrol
	bsr	ground
	bsr	doboom
	bsr	shoot
	bsr	dothings
	bsr	drawraceshot
	bsr	detectmultiple
	bsr	mycollisions
	bsr	shotcollisions
	bsr	printscore
	bsr	printships
	bsr	doradar
	bsr	flip_scr
	bsr	limits
	bsr	keyboard
	bsr	maintainhbl
	bsr	dodlt
	bsr	amihit
	addq.w	#1,endoflevel
	bpl.s	egloop1
	bra.s	gameloop1
egloop1:
	addq.w	#1,frames
	cmpi.w	#100,frames
	bgt.s	gameloop1enda
	cmpi.w	#99,frames
	blt	ex1
	cmpi.w	#2,level
	blt	part2
ex1:	bra.s	gameloop1


gameloop1enda:
	subq.w	#5,speed
	bmi.s	gameloop1endb
	move.w	#100,frames
	bsr	energycontrol
	bsr	ground
	bsr	doboom
	bsr	shoot
	bsr	dothings
	bsr	mycollisions
	bsr	shotcollisions
	bsr	printscore
	bsr	printships
	bsr	doradar
	bsr	flip_scr
	bsr	limits
	bsr	keyboard
	bsr	maintainhbl
	bsr	amihit
	bra.s	gameloop1enda
gameloop1endb:
	move.w	#0,xspeed
	move.w	#-1,udflag
	move.w	#0,speed
	subq.w	#1,frames
	bmi.s	gameloop1end		
	bsr	energycontrol
	bsr	ground
	bsr	dothings2
	bsr	printscore
	bsr	printships
	bsr	doradar
	bsr	flip_scr
	bsr	keyboard
	bsr	maintainhbl
	move.w	#0,endhits
	bra.s	gameloop1endb

gameloop1end:
	move.w	#1,udflag
	move.w	#0,speed
	bsr	energycontrol
	bsr	joydir
	bsr	ground
	bsr	doboom
	bsr	shoot
	bsr	dothings2
	bsr	shotcollisions2
	bsr	printscore
	bsr	printships
	bsr	doradar
	bsr	flip_scr
	bsr	limits
	bsr	keyboard
	bsr	maintainhbl
	bsr	amihit
	move.w	endhits,d0
	cmpi.w	endnum,d0
	bge.L	part2
	bra.s	gameloop1end

endhits:	blk.w	1,0
boomcolor:	blk.w	1,0
playedatall:	blk.w	1,-1
endnum:		blk.w	1,0
***********************************
endnumstuff:
	cmpi.w	#1,level
	ble	endb
	addq.w	#1,endnum
	cmpi.w	#5,endnum
	ble	endb
	move.w	#5,endnum
endb:
	rts
*************************************************
*	info bit				*
*************************************************
printinfo:
	move.l	#energyrun,-(sp)
	move.w	#9,-(sp)
	trap	#1
	addq.l	#6,sp
	bsr	flip_scr
	move.l	#500000,d7
	bsr	generaldelay
	rts

energyrun:	dc.b	27,'b',1,27,'Y',32+4,32+15,'ENERGY RUN',0
even
*************************************************
*	Fractal landscape bit			*
*************************************************
dofractrend:
	subq.w	#1,ftdelay
	bpl	nocft
	move.w	#10,ftdelay
	move.w	#300,d0
	bsr	random
	move.w	d0,fractrend
nocft:
	rts
ftdelay:	blk.w	1,0
*************************************************
*	Fractal landscape bit			*
*************************************************
fracscape:
	lea	drawlist,a0
	move.l	#fland1,(a0)+
	move.l	#fland2,(a0)+
	move.l	#fland3,(a0)+
	move.l	#fland4,(a0)+
	move.l	#fland5,(a0)+
	move.l	#fland6,(a0)+
	move.l	#fland7,(a0)+
	move.l	#fland8,(a0)+
	bsr	sortndrawlist2	;sort them front to back
	rts

*************************************************
*	Fractal landscape bit			*
*************************************************
prefracscape:
	lea	drawlist,a0
	move.l	#fland1,(a0)+
	move.l	#fland2,(a0)+
	move.l	#fland3,(a0)+
	move.l	#fland4,(a0)+
	move.l	#fland5,(a0)+
	move.l	#fland6,(a0)+
	move.l	#fland7,(a0)+
	move.l	#fland8,(a0)+
	move.w	#12000,d0
	lea	drawlist,a0
	moveq	#7,d7
pfsloop:
	move.l	(a0)+,a1
	move.w	#0,(a1)+	;x
	move.w	#0,(a1)+	;y
	move.w	d0,(a1)+
	lea	fracbasic,a2
	moveq	#15,d2
pfsloop2:
	movem.l	d0/d2/d7,-(sp)
	move.w	(a2)+,(a1)+
	move.w	(a2)+,(a1)
	move.w	#fracrand,d0
	bsr	random
	add.w	d0,(a1)+
	movem.l	(sp)+,d0/d2/d7
	dbf	d2,pfsloop2
	subi.w	#1437,d0
	dbf	d7,pfsloop
	rts

newfracrand:
	lea	fracbasic,a2
	moveq	#15,d2
	addq.l	#6,a0
pfsloop2f:
	move.w	(a2)+,(a0)+
	move.w	(a2)+,(a0)
	move.w	#fracrand,d0
	bsr	random
	add.w	d0,(a0)+
	dbf	d2,pfsloop2f
	rts


fracrand:	equ	90
fracbasic:
	dc.w	-1000,-500,-833,-500,-666,-500,-500,-500
	dc.w	-366,-333,-232,-166,-100,0,-33,0
	dc.w	34,0,100,0,232,-166,366,-333
	dc.w	500,-500,666,-500,833,-500,1000,-500


fland1:	
	dc.w	0,0,0	;z
	blk.w	42,0	;space for 6 points
fland2:	
	dc.w	0,0,0	;z
	blk.w	42,0	;space for 6 points
fland3:	
	dc.w	0,0,0	;z
	blk.w	42,0	;space for 6 points
fland4:	
	dc.w	0,0,0	;z
	blk.w	42,0	;space for 6 points
fland5:	
	dc.w	0,0,0	;z
	blk.w	42,0	;space for 6 points
fland6:	
	dc.w	0,0,0	;z
	blk.w	42,0	;space for 6 points
fland7:	
	dc.w	0,0,0	;z
	blk.w	42,0	;space for 6 points
fland8:	
	dc.w	0,0,0	;z
	blk.w	42,0	;space for 6 points
fracpoints:
	blk.w	400,0	;space for 200 points across screen
fraconscreen:
	blk.w	42,0	;6 points
normspeed:	dc.w	0
*************************************************
*	Sound stuff				*
*************************************************
domehitsound:
	cmpi.w	#4,soundlevpr
	ble	nopr1
	tst.w	soundpriority
	bpl	nosounds
nopr1:
	move.w	#4,soundlevpr
	move.w	#50,soundpriority
	lea	mehitdat,a0
	move.b	31(a0),processflag
	move.b	33(a0),sreg
	move.b	35(a0),stoadd
	move.b	37(a0),stoequal
	bra	dothatsound
dosilencesound:
	lea	silencedat,a0
	move.b	31(a0),processflag
	move.b	33(a0),sreg
	move.b	35(a0),stoadd
	move.b	37(a0),stoequal
	bra	dothatsound
dohittargetsound:
	cmpi.w	#3,soundlevpr
	ble	nopr2
	tst.w	soundpriority
	bpl	nosounds
nopr2:
	move.w	#3,soundlevpr
	move.w	#50,soundpriority
	lea	hittargetdat,a0
	move.b	31(a0),processflag
	move.b	33(a0),sreg
	move.b	35(a0),stoadd
	move.b	37(a0),stoequal
	bra	dothatsound
doshootsound:
	cmpi.w	#1,soundlevpr
	ble	nopr3
	tst.w	soundpriority
	bpl	nosounds
nopr3:
	move.w	#1,soundlevpr
	move.w	#0,soundpriority
	lea	shootdat,a0
	move.b	31(a0),processflag
	move.b	33(a0),sreg
	move.b	35(a0),stoadd
	move.b	37(a0),stoequal
	bra	dothatsound
doundersound:
	cmpi.w	#3,soundlevpr
	ble	nopr4
	tst.w	soundpriority
	bpl	nosounds
nopr4:
	move.w	#3,soundlevpr
	move.w	#80,soundpriority
	lea	underdat,a0
	move.b	31(a0),processflag
	move.b	33(a0),sreg
	move.b	35(a0),stoadd
	move.b	37(a0),stoequal
	bra	dothatsound

doraceshotsound:
	cmpi.w	#2,soundlevpr
	ble	nopr5
	tst.w	soundpriority
	bpl	nosounds
nopr5:
	move.w	#2,soundlevpr
	move.w	#10,soundpriority
	lea	raceshotdat,a0
	move.b	31(a0),processflag
	move.b	33(a0),sreg
	move.b	35(a0),stoadd
	move.b	37(a0),stoequal
	bra	dothatsound

nosounds:
	rts

dothatsound:
	move.w	(a0)+,d7
	subq.w	#1,d7
sdloop:
	move.b	(a0)+,d0
	move.b	(a0)+,d1
	bsr	writedata
	dbf	d7,sdloop
	rts

writedata:
	movem.l	d7/a0,-(sp)
	move.b	d0,$ff8800
	cmp.b	#7,d0
	bne	wd2
	and.b	#$3f,d1
	move.b	$ff8800,d0
	and.b	#$c0,d0
	or.b	d0,d1
wd2:
	move.b	d1,$ff8802
	movem.l	(sp)+,d7/a0
	rts

mysoundprocessor:
	subq.w	#1,soundpriority
	tst.b	processflag
	beq	nosprocess
	move.b	sreg,d0
	move.b	stoadd,d1
	add.b	d1,processflag
	move.b	processflag,d1
	cmpi.b	stoequal,d1
	beq	mspover
	bsr	writedata
nosprocess:
	rts
mspover:
	move.b	#0,processflag
	bsr	writedata
	rts


soundlevpr:	blk.w	1,0
soundpriority:	blk.w	1,0
processflag:	dc.b	0
sreg:		dc.b	0
stoadd:		dc.b	0
stoequal:	dc.b	0
*****************************************
*	Sound interrupt			*
*****************************************
MFP:	EQU	$FFFA00
IERA:	EQU	MFP+$07
IERB:	EQU	MFP+$09
IPRA:	EQU	MFP+$0B
iISRA:	EQU	MFP+$0F
IMRA:	EQU	MFP+$13
IMRB:	EQU	MFP+$15
VECTOR:	EQU	MFP+$17
TACR:	EQU	MFP+$19
TADR:	EQU	MFP+$1F
ISRVEC:	EQU	$134
SCREG:	EQU	$FF8800		;CHIP REGISTER SELECT
SCDATA:	EQU	$FF8802		;REGISTER DATA

P_TERM_OLD: EQU	0	
F_SUPER:  EQU	$20
GETMPB:	 EQU	0
BCONSTAT: EQU	1
BCONIN:	 EQU	2
BCONOUT:	 EQU	3
INPUT:	EQU	$FB0001
OUTPUT:	EQU	$FA0000

setupsoundint:
	BSR	SAVEMFP		;SAVE NATURAL MFP CONDITIONS
	MOVE.W	#$2700,SR
	LEA	INULL,A0
	BSR	SETINT		;SET NULL INTERRUPT ADDRESS
	MOVEQ	#1,D0		;SET INITIAL FREQUENCY
	BSR	SETFREQ
	BSR	ENABMFP		;SET THE MFP RUNNING
	BSR	SETSND		;SET UP SOUND REGISTERS
*	SF	XTERNAL		;SET THE MODE FOR INTERNAL ATARI USE
	move.b	#-1,xternal
	MOVE.W	#$2000,SR	;ENABLE THE INTERRUPTS
	rts

*****************************************************************
startsound:
	move.b	#1,inuse
	lea	ireplay,a0
	bsr	setint
	rts

****************************************
*     THE NULL INTERRUPT ROUTINE       *
****************************************

INULL:	RTE
****************************************
*       REPLAY FROM MEMORY             *
****************************************
IREPLAY:
	movem.l	d0/d3/d4/d5/d7/a0/a3/a4/a6,-(sp)
*	move.w	#$0007,$ff8240
*	move.w	#0,$ff8240
	move.w	#$2500,sr
	MOVEQ	#0,D7
	move.l	currentsad,a6
	MOVE.B	(A6)+,D7	;READ FROM RAM
	CMP.L	bottom,A6		;EXCEDED END STOP
	BGT.S	HALTREP		;BRANCH IF SO
	move.l	a6,currentsad
	tst.b	xternal
	bpl	throughport
	JMP	INTOUTP		;ELSE OUTPUT IT

HALTREP:
	move.l	soundstart,currentsad
	move.b	#-1,INUSE
	movem.l	(sp)+,d0/d3/d4/d5/d7/a0/a3/a4/a6
	RTE

throughport:
	and.w	#$00ff,d7
	lsl.w	#1,d7
	move.l	#$fa0000,a4
	move.b	0(a4,d7.w),d7
	movem.l	(sp)+,d0/d3/d4/d5/d7/a0/a3/a4/a6
	move.w	#$2000,sr
	rte

currentsad:	blk.l	1,0
bottom:		blk.l	1,0
soundstart:	blk.l	1,0
INTOUTP:
	lea	screg,a4
	lea	snd_out,a3
	AND.W	#$00FF,D7	;MASK OFF RUBBISH
	ADD.B	#$80,D7		;COMPLENT VALUE
	LSL.W	#3,D7		;DOUBLE LONG WORD OFFSET
	MOVE.L	0(A3,D7.W),d5	;GET DATA #1
	MOVE.W	4(A3,D7.W),D4	;GET DATA #2
	MOVEP.L	D5,0(A4)	;PLAY #1
	MOVEP.W	D4,0(A4)	;PLAY #2
	move.w	#$2000,sr
	movem.l	(sp)+,d0/d3/d4/d5/d7/a0/a3/a4/a6
	RTE

*       PRESERVE THE MFP REGISTERS      *
SAVEMFP:
	move.w	sr,mysr
	MOVE.B	IERA,MFPMEM	;PUSH CURRENT MFP DATA
	MOVE.B	IERB,MFPMEM+1
	MOVE.B	IMRA,MFPMEM+2
	MOVE.B	IMRB,MFPMEM+3
	MOVE.B	TADR,MFPMEM+4
	MOVE.B	TACR,MFPMEM+5
	MOVE.B	VECTOR,MFPMEM+6
	RTS
mysr:
	blk.w	1,0
*   REPLACE NATURAL RUNNING MFP VALUES  *
OLDMFP:
	MOVE.B	MFPMEM+6,VECTOR	;RESTORE OLD MFP VALS
	MOVE.B	MFPMEM+5,TACR
	MOVE.B	MFPMEM+4,TADR
	MOVE.B	MFPMEM+3,IMRB
	MOVE.B	MFPMEM+2,IMRA
	MOVE.B	MFPMEM+1,IERB
	MOVE.B	MFPMEM,IERA
	move.w	mysr,sr
	RTS

*	CHOOSE INTERRUPT VECTOR         *
*   SET UP SELECTED INTERRUPT WITH A0.L
*   CONTAINING THE NEW ROUTINE VECTOR.
SETINT:	MOVE.W	SR,D0		;SAVE SYSTEM STATUS
	MOVE.W	#$2700,SR	;INTERRUPTS OFF
	MOVE.L	A0,ISRVEC	;INSTALL NEW ROUTINE
	MOVE.W	D0,SR		;RE-ASSERT OLD STATUS
	RTS

*       SET UP MFP FREQUENCY            *
SETFREQ:
	MOVE.B	#0,TACR		;DISABLE TIMER
	AND.W	#7,D0		;ENSURE 0-7
	MOVE.W	D0,FREQNUM	;SAVE FOR PROSPERITY
	LEA	FREQTAB,A0	;GET THE FREQUENCY XREF ADDR
	LSL.W	#1,D0		;CONVERT TO WORD TABLE OFFSET
	MOVE.W	0(A0,D0.W),D0	;& GET THE MFP DATA
	MOVE.B	D0,TACR		;LSB = CONTROL REG BYTE
	LSR.W	#8,D0		;SHIFT DOWN NEXT BYTE
 	MOVE.B	D0,TADR		;NEXT = DATA REG BYTE
	RTS
*       ENABLE THE MFP            *
ENABMFP:
	bset	#5,IMRA
*	MOVE.B	#0,IMRB
	bset	#5,IERA
*	MOVE.B	#0,IERB
	BCLR	#3,VECTOR
	RTS

*    SET UP THE SOUND CHIP CHANNELS     *
SETSND:
	MOVE.B	#0,SCREG	;CHANNEL A
	MOVE.B	#0,SCDATA
	MOVE.B	#1,SCREG
	MOVE.B	#0,SCDATA

	MOVE.B	#2,SCREG	;CHANNEL B
	MOVE.B	#0,SCDATA
	MOVE.B	#3,SCREG
	MOVE.B	#0,SCDATA

	MOVE.B	#4,SCREG	;CHANNEL C
	MOVE.B	#0,SCDATA
	MOVE.B	#5,SCREG
	MOVE.B	#0,SCDATA

	MOVE.B	#7,SCREG	;SET UP CHANNEL MIXING & PORT 'A' I/O
	MOVE.B	#$FF,SCDATA

	MOVE.B	#8,SCREG	;SET ALL VOLUMES TO ZERO
	MOVE.B	#0,SCDATA
	MOVE.B	#9,SCREG
	MOVE.B	#0,SCDATA
	MOVE.B	#10,SCREG
	MOVE.B	#0,SCDATA
	RTS

**************************************
*       MFP/FREQUENCY TABLE          *
**************************************
	EVEN
FREQTAB:
	DC.W	$0506	;4.9 KHZ
	DC.W	$0505	;7.68 KHZ
	DC.W	$0405	;9.6 KHZ
	DC.W	$2901	;14.99 KHZ
	DC.W	$1F01	;19.8 KHZ
	DC.W	$0802	;30.7 KHZ
	DC.W	$0106	;DUMMY	
	DC.W	$0106	;DUMMY

**************************************
*	DEFINE PROGRAM STORAGE       *
**************************************
	EVEN
XTERNAL:
	blk.B	1,0	;$FF = EXTERNAL O/P SELECTED
INUSE:
	blk.B	1,0	;INTERRUPT IN USE FLAG
OPTION:	blk.B	1,0	;INT. OPTION  $FF = SAMPLE
	EVEN
FREQNUM:
	blk.W	1,1	;FREQUENCY SELECTED

MFPMEM:	blk.B	30,0	;SAVED MFP DATA

*****************************************************************
startbass:
	move.l	dltmem,d0
	add.l	#77280,d0
	add.l	#53609,d0
	move.l	d0,soundstart
	move.l	d0,currentsad
	add.l	#10204,d0
	move.l	d0,bottom
	bsr	startsound
	rts
startwater:
	move.l	dltmem,d0
	add.l	#77280,d0
	add.l	#63813,d0
	move.l	d0,soundstart
	move.l	d0,currentsad
	add.l	#15007,d0
	move.l	d0,bottom
	bsr	startsound
	rts
startstab:
	move.l	dltmem,d0
	add.l	#77280,d0
	add.l	#78820,d0
	move.l	d0,soundstart
	move.l	d0,currentsad
	add.l	#11587,d0
	move.l	d0,bottom
	bsr	startsound
	rts
startbells:
	move.l	dltmem,d0
	add.l	#77280,d0
*	add.l	#36798,d0
	move.l	d0,soundstart
	move.l	d0,currentsad
	add.l	#53609,d0
	move.l	d0,bottom
	bsr	startsound
	rts
startmusic:
	move.l	dltmem,d0
	add.l	#77280,d0
	add.l	#53609,d0
	move.l	d0,soundstart
	move.l	d0,currentsad
	add.l	#76924,d0
	move.l	d0,bottom
	bsr	startsound
	rts
dc.b	'TWYLYTE DEMO VERSION'
dc.b	'COPYRIGHT T.BARKER 8/9/88 ENIGMASOFT'
*************************************************
*	Title bisso				*
*************************************************
titlestuff:
	move.l	#blackpal,temppal
	bsr	docolors
	move.w	#1,titflag
	bsr	loadintrosounds
	bsr	setupsoundint
	bsr	startbass
	move.l	#filetit,filename
	bsr	loadscr
	bsr	copyintoboth
	move.l	#titlepalette,temppal
*	bsr	docolors
	bsr	flip2
	move.l	#filetit2,filename
	bsr	loadscr
	bsr	clearhiden
*	bsr	flip2
	bsr	startwater
	bsr	fadein
	bsr	loaddlt
	move.l	#850000,d7
	bsr	generaldelay
	bsr	fadeto
	lea	twishadsp,a0
	bsr	putsprite
	move.l	#350000,d7
	bsr	generaldelay
	move.l	#twi1pal,temppal
	bsr	docolors
	bsr	startstab
	bsr	flip2	
wstabl:
	tst.b	inuse
	bpl	wstabl
	bsr	startbells
	bsr	loadmusic
	bsr	startmusic
	move.l	#blackpal,temppal
	bsr	docolors
	bsr	copyintoboth
	bsr	flip2
	move.w	#-1,titflag
	move.l	#twi2pal,temppal
	bsr	docolors
	bsr	setuphbltit
	move.l	#dltmem,dltmemcount
	move.w	#1,dltdir
	move.w	#0,dltcount
	move.w	#5000,dltdelay
uffwait:
	bsr	keyboard
	bsr	joydir
	bsr	dodlt2
*	bsr	flip_scr
	tst.w	firebutton
	bmi	uffwait
	move.l	#blackpal,temppal
	bsr	docolors
	bsr	clearhiden
	bsr	flip2
	bsr	clearhiden
	move.w	#-1,firebutton
*	move.w	#-2,titflag
*	bra	gem
	bsr	oldmfp
	bsr	dosilencesound
	rts

minititle:
	move.w	#1,dontdlt
	move.w	#-1,firebutton
	move.l	#blackpal,temppal
	bsr	docolors
	bsr	getridofhbl
	bsr	setupsoundint
	move.w	#1,titflag
	move.l	#blackpal,temppal
	bsr	docolors
	bsr	startbells
	move.l	#filetit2,filename
	bsr	loadscr
	bsr	copyintoboth
	bsr	clearhiden
	lea	twishadsp,a0
	bsr	putsprite
	bsr	flip2
	move.l	#twi1pal,temppal
	bsr	fadein
	move.l	#500000,d7
	bsr	generaldelay
*	bsr	loadmusic
	bsr	startmusic
	move.l	#blackpal,temppal
	bsr	docolors
*	bsr	copyintoboth
	bsr	flip2
	move.w	#-1,titflag
	move.l	#twi2pal,temppal
	bsr	docolors
	bsr	setuphbltit
	move.l	#dltmem,dltmemcount
	move.w	#1,dltdir
	move.w	#0,dltcount
	move.w	#8000,dltdelay
uffwait2:
	bsr	keyboard
	bsr	joydir
	bsr	dodlt2
	tst.w	firebutton
	bmi	uffwait2
	move.l	#blackpal,temppal
	bsr	docolors
	bsr	clearhiden
	bsr	flip2
	bsr	clearhiden
	move.w	#-1,firebutton
	bsr	oldmfp
	bsr	dosilencesound
	move.l	#paneldlt,dltmemcount
	move.w	#-1,dontdlt
	move.w	#0,dltdelay
	rts

*****************************************
*	Hopefully a quick delta		*
* 	Frame player			*
*****************************************
dodlt2:
	subq.w	#1,dltdelay
	bpl	nodlt2
	move.w	#-1,dltdelay
	cmpi.w	#52,dltcount
	ble	ddt
	neg.w	dltdir
	move.w	#52,dltcount
	bra	ddt2
ddt:
	cmpi.w	#-1,dltcount
	bgt	ddt2
	beq	ddt3
	neg.w	dltdir
	move.w	#0,dltcount	
*	move.w	#80000,dltdelay
	bra	ddt2
ddt3:
	move.w	#70000,dltdelay
	bra	ndt2
ddt2:
	move.l	seen,a1
	move.l	dltmem,a0
	move.w	dltcount,d0
	beq	spdlt
	subq.w	#1,d0
ddtouter:
	move.w	(a0)+,d1
	subq.w	#1,d1	
ddtinner:
	addq.l	#6,a0
	dbf	d1,ddtinner
	dbf	d0,ddtouter
spdlt:	move.w	(a0)+,d1
	subq.w	#1,d1
dodltloop2:
	move.w	(a0)+,d2
	move.l	(a0)+,d3
	eor.l	d3,(a1,d2.w)
	dbf	d1,dodltloop2
ndt2:	move.w	dltdir,d0
	add.w	d0,dltcount
nodlt2:
	rts

dltcount:	blk.w	1,0
dltdir:		blk.w	1,1	


dodlt:
	subq.w	#1,dltdelay
	bpl	nodlt
	move.w	#3,dltdelay
	move.l	dltmemcount,a0
	move.l	seen,a1
	move.l	hiden,a2
	move.w	(a0)+,d0
	beq	dltover
	subq.w	#1,d0
dodltloop:
	move.w	(a0)+,d1
	move.l	(a0)+,d2
	eor.l	d2,(a1,d1.w)
	eor.l	d2,(a2,d1.w)
	dbf	d0,dodltloop
	move.l	a0,dltmemcount
nodlt:	rts
dltover:
	move.l	#paneldlt,dltmemcount
	rts

dltdelay:	dc.w	0
dltmemcount:	dc.l	0
*****************************************
*	general fadeto routine		*
* load color for fade into fadetocol	*
*****************************************
fadeto:
	lea	fadebuff,a0
	move.l	temppal,a1
	moveq	#15,d7
ftl:
	move.w	(a1)+,(a0)+
	dbf	d7,ftl
	moveq	#6,d7
ftoloop:
	movem.l	d0-d7/a0-a6,-(sp)
	bsr	fademath
	move.l	#5000,d7
	bsr	generaldelay
	move.l	#fadebuff,-(sp)
	move.w	#6,-(sp)
	trap	#14
	addq.l	#6,sp
	move.w	#37,-(sp)
	trap	#14
	addq.l	#2,sp
	movem.l	(sp)+,d0-d7/a0-a6
	dbf	d7,ftoloop
	rts
fademath:
	moveq	#15,d7
	lea	fadebuff,a1
fml:
	move.w	(a1),d0
	move.w	d0,d1
	move.w	d0,d2
	and.w	#$0f00,d0
	and.w	#$00f0,d1
	and.w	#$000f,d2
	sub.w	#$0100,d0
	tst.w	d0
	bpl	fml2
	moveq	#0,d0
fml2:
	sub.w	#$0010,d1
	tst.w	d1
	bpl	fml3
	moveq	#0,d1
fml3:
	sub.w	#$0001,d2
	tst.w	d2
	bpl	fml4
	move.w	#0,d2
fml4:
	or.w	d2,d0
	or.w	d1,d0
	move.w	d0,(a1)+
	dbf	d7,fml
	rts

*****************************************
*	general fadeto routine		*
* load color for fade into fadetocol	*
*****************************************
fadein:
	lea	fadebuff,a0
*	move.l	temppal,a1
	moveq	#15,d7
ftli:
	move.w	#0,(a0)+
	dbf	d7,ftli
	moveq	#6,d7
ftoloopi:
	move.w	d7,-(sp)
	bsr	fademathi
	move.l	#15000,d7
	bsr	generaldelay
	move.l	#fadebuff,-(sp)
	move.w	#6,-(sp)
	trap	#14
	addq.l	#6,sp
	move.w	#37,-(sp)
	trap	#14
	addq.l	#2,sp
	move.w	(sp)+,d7
	dbf	d7,ftoloopi
	rts
fademathi:
	moveq	#15,d7
	lea	fadebuff,a1
	move.l	temppal,a2
fmli:
	move.w	(a1),d0
	move.w	d0,d1
	move.w	d0,d2
	and.w	#$0f00,d0
	and.w	#$00f0,d1
	and.w	#$000f,d2
	add.w	#$0100,d0
	move.w	(a2),d3
	and.w	#$0f00,d3
	cmp.w	d0,d3
	bge	fml2i
	move.w	d3,d0
fml2i:
	move.w	(a2),d3
	and.w	#$00f0,d3
	add.w	#$0010,d1
	cmp.w	d1,d3
	bge	fml3i
	move.w	d3,d1
fml3i:
	move.w	(a2)+,d3
	and.w	#$000f,d3
	add.w	#$0001,d2
	cmp.w	d2,d3
	bge	fml4i
	move.w	d3,d2
fml4i:
	or.w	d2,d0
	or.w	d1,d0
	move.w	d0,(a1)+
	dbf	d7,fmli
	rts

fadeto2:
	lea	fadebuff,a0
	lea	temppal,a1
	move.w	#$0777,(a0)+
	move.w	#$0333,(a0)+
	moveq	#6,d7
ftoloop2:
	move.w	d7,-(sp)
	bsr	fademath2
	move.l	#5000,d7
	bsr	generaldelay
	lea	fadebuff,a0
	move.w	(a0)+,$ff8240
	move.w	(a0)+,$ff8242
	move.w	#37,-(sp)
	trap	#14
	addq.l	#2,sp
	move.w	(sp)+,d7
	dbf	d7,ftoloop2
	rts
fademath2:
	lea	fadebuff,a1
	moveq	#1,d7
fml2a:
	move.w	(a1),d0
	move.w	d0,d1
	move.w	d0,d2
	and.w	#$0f00,d0
	and.w	#$00f0,d1
	and.w	#$000f,d2
	sub.w	#$0100,d0
	tst.w	d0
	bpl	fml22
	move.w	#0,d0
fml22:
	sub.w	#$0010,d1
	tst.w	d1
	bpl	fml32
	moveq	#0,d1
fml32:
	sub.w	#$0001,d2
	tst.w	d2
	bpl	fml42
	moveq	#0,d2
fml42:
	or.w	d2,d0
	or.w	d1,d0
	move.w	d0,(a1)+
	dbf	d7,fml2a
	rts

fadebuff:	blk.w	16,0

generaldelay:
	subq.l	#1,d7
	bpl	generaldelay
	rts

clearhiden:
	move.l	hiden,a0
	add.l	#32000,a0
	moveq	#0,d0
	moveq	#0,d1
	moveq	#0,d2
	moveq	#0,d3
	moveq	#0,d4
	moveq	#0,d5
	moveq	#0,d6
	move.w	#199,d7
	move.l	d0,a1
	move.l	a1,a2
	move.l	a2,a3
clhidloop:
	movem.l	d0-d6/a1-a3,-(a0)
	movem.l	d0-d6/a1-a3,-(a0)
	movem.l	d0-d6/a1-a3,-(a0)
	movem.l	d0-d6/a1-a3,-(a0)
	dbf	d7,clhidloop
	rts

twishadsp:
	dc.w	86,77		;x,y
	dc.w	48,9		;h,w
	dc.w	72
	dc.l	twishad


titflag:	dc.w	-1
filetit:	dc.b	'pre.cmp',0
filetit2:	dc.b	'title.cmp',0
even	
*************************************************
*	draw in a road				*
*************************************************
drawroad:
	lea	road1,a0
	move.w	xspeed,d3
	add.w	d3,2(a0)
	move.w	2(a0),d3
*	move.w	speed,d4
*	add.w	d4,4(a0)
	move.w	4(a0),d4
	move.w	myheight,d5
	move.l	6(a0),a1
	bsr	drawthat
	rts
road1:
	dc.w	1	;flag
	dc.w	0,0	;x,y
	dc.l	road1def
road1def:
	dc.w	2
	dc.w	4
	dc.w	-50,-200,50,200
	dc.w	5
	dc.w	-60,-200,-50,200
	dc.w	5
	dc.w	50,-200,60,200
*************************************************
*	draw and move the buildings		*
*************************************************
dobuildings:
	lea	build1,a0
	bsr	drawbuild
	lea	build2,a0
	bsr	drawbuild
	lea	build3,a0
	bsr	drawbuild
	lea	build4,a0
	bsr	drawbuild
	rts

drawbuild:
	move.w	xspeed,d3
	add.w	d3,2(a0)
	move.w	2(a0),d3
	move.w	speed,d4
	add.w	d4,4(a0)
	move.w	4(a0),d4
	move.w	myheight,d5
	move.l	8(a0),a1
	bsr	drawthat
	sub.w	6(a0),d5
	move.l	8(a0),a1
	bsr	drawthat
	sub.w	6(a0),d5
	move.l	8(a0),a1
	bsr	drawthat
drback:
	cmpi.w	#300,4(a0)
	ble	rdback
	move.w	#-300,4(a0)
rdback:
	rts	

drawthat:
	move.w	(a1)+,d7
drtloop:
	move.w	(a1)+,reccolor
	move.w	(a1)+,d0		;get x
	add.w	d3,d0
	move.w	(a1)+,d1		;get y
	add.w	d4,d1
	move.w	d5,d2
	bsr	a3dmath2
	move.w	d0,x1
	move.w	d1,y1
	move.w	(a1)+,d0		;get x
	add.w	d3,d0
	move.w	(a1)+,d1		;get y
	add.w	d4,d1
	move.w	d5,d2
	bsr	a3dmath2
	move.w	d0,x2
	move.w	d1,y2
	bsr	rectangle
	dbf	d7,drtloop
	rts

build1:
	dc.w	1		;flag
	dc.w	-160,-150	;x,y
	dc.w	150		;add to z to make height
	dc.l	build2def
build2:
	dc.w	1		;flag
	dc.w	160,-50	;x,y
	dc.w	300		;add to z to make height
	dc.l	build2def
build3:
	dc.w	1		;flag
	dc.w	-160,150	;x,y
	dc.w	250		;add to z to make height
	dc.l	build2def
build4:
	dc.w	1		;flag
	dc.w	160,250		;x,y
	dc.w	200		;add to z to make height
	dc.l	build2def



build2def:
	dc.w	4
	dc.w	2
	dc.w	-60,-60,60,60
	dc.w	1
	dc.w	-50,-60,50,-50
	dc.w	1
	dc.w	50,-60,60,50
	dc.w	3
	dc.w	-60,-50,-50,60
	dc.w	3
	dc.w	-50,50,50,60



build1def:
	dc.w	7		;recs-1
	dc.w	1		;color
	dc.w	0,0,200,180
	dc.w	2
	dc.w	10,20,180,170
	dc.w	3
	dc.w	10,10,190,20
	dc.w	3
	dc.w	180,20,190,170
	dc.w	1
	dc.w	50,40,150,50
	dc.w	1
	dc.w	140,50,150,140
	dc.w	3
	dc.w	40,50,50,150
	dc.w	3
	dc.w	50,140,140,150

*************************************************
*	energy level control			*
*************************************************
energycontrol:
	move.w	energy,tx
	tst.w	endoflevel
	bmi	ec1
	cmpi.w	#500,energy
	bgt	ec1
	bra	endofgame
ec1:
	tst.w	energy
	bmi	endofgame
	rts


endofgame:
	bsr	putrad
	move.l	temppal,a0
	lea	endpal,a1
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.l	#endpal,temppal
	bsr	doend
	bsr	keyboard
	bra	endofgame
*************************************************
*	do the end thingy			*
*************************************************
doend:
	bsr	putrad
	bsr	ground
	bsr	putend
	bsr	keyboard
	move.b	joyport1,d0
	btst	#7,d0
	bne	herewegoagain
	bsr	flip_scre
	bra	doend

herewegoagain:
	bsr	minititle
	bra	restart
putend:
	lea	end2struct,a0
	move.w	(a0)+,d0
	add.w	d0,(a0)
	cmpi.w	#500,(a0)
	bge	nost
	neg.w	-2(a0)
nost:
	cmpi.w	#12000,(a0)
	ble	nost2
	neg.w	-2(a0)	
nost2:
	move.w	(a0)+,d6
	move.w	(a0)+,d7	;number of rects
	
peloop:
	move.w	(a0)+,reccolor
	move.w	(a0)+,d0
	sub.w	#100,d0
	move.w	(a0)+,d1
	sub.w	#75,d1
	move.w	d6,d2
	bsr	a3dmath
	move.w	d0,x1
	move.w	d1,y1
	move.w	(a0)+,d0
	sub.w	#100,d0
	move.w	(a0)+,d1
	sub.w	#75,d1
	move.w	d6,d2
	bsr	a3dmath
	move.w	d0,x2
	move.w	d1,y2
	bsr	rectangle
	dbf	d7,peloop
	rts

col1:	equ	10
col2:	equ	11
end2struct:
	dc.w	-200
	dc.w	12000		;universal z
	dc.w	32		;num of recs-1
	dc.w	col1		;color of rectangle
	dc.w	10,0,40,10	;background square
	dc.w	col1		;color of rectangle
	dc.w	0,10,10,60	;background square
	dc.w	col1		;color of rectangle
	dc.w	10,60,40,70	;background square
	dc.w	col1		;color of rectangle
	dc.w	40,40,50,60	;background square
	dc.w	col1		;color of rectangle
	dc.w	60,10,70,70	;background square
	dc.w	col1		;color of rectangle
	dc.w	70,0,90,10	;background square
	dc.w	col1		;color of rectangle
	dc.w	70,30,90,40	;background square
	dc.w	col1		;color of rectangle
	dc.w	90,10,100,70	;background square
	dc.w	col1		;color of rectangle
	dc.w	110,0,120,70	;background square
	dc.w	col1		;color of rectangle
	dc.w	120,10,130,20	;background square
	dc.w	col1		;color of rectangle
	dc.w	130,20,140,30	;background square
	dc.w	col1		;color of rectangle
	dc.w	140,10,150,20	;background square
	dc.w	col1		;color of rectangle
	dc.w	150,0,160,70	;background square
	dc.w	col1		;color of rectangle
	dc.w	170,0,180,70	;background square
	dc.w	col1		;color of rectangle
	dc.w	180,0,210,10	;background square
	dc.w	col1		;color of rectangle
	dc.w	180,30,200,40	;background square
	dc.w	col1		;color of rectangle
	dc.w	180,60,210,70	;background square
	dc.w	col2		;color of rectangle
	dc.w	20,80,50,90	;background square
	dc.w	col2		;color of rectangle
	dc.w	10,90,20,140	;background square
	dc.w	col2		;color of rectangle
	dc.w	20,140,50,150	;background square
	dc.w	col2		;color of rectangle
	dc.w	50,90,60,140	;background square
	dc.w	col2		;color of rectangle
	dc.w	70,80,80,140	;background square
	dc.w	col2		;color of rectangle
	dc.w	80,140,90,150	;background square
	dc.w	col2		;color of rectangle
	dc.w	90,80,100,140	;background square
	dc.w	col2		;color of rectangle
	dc.w	110,80,120,150	;background square
	dc.w	col2		;color of rectangle
	dc.w	120,80,150,90	;background square
	dc.w	col2		;color of rectangle
	dc.w	120,110,140,120	;background square
	dc.w	col2		;color of rectangle
	dc.w	120,140,150,150	;background square
	dc.w	col2		;color of rectangle
	dc.w	160,80,170,150	;background square
	dc.w	col2		;color of rectangle
	dc.w	170,80,190,90	;background square
	dc.w	col2		;color of rectangle
	dc.w	170,110,190,120	;background square
	dc.w	col2		;color of rectangle
	dc.w	190,90,200,110	;background square
	dc.w	col2		;color of rectangle
	dc.w	190,120,200,150	;background square

*************************************************
*	take control of radar business		*
*************************************************
doradar:
	bsr	putrad
	move.w	#13,pixelcolor
	lea	attack1,a0
	bsr	radplot
	move.w	#10,pixelcolor
	lea	race1,a0
	bsr	radplot
	lea	race2,a0
	bsr	radplot
	move.w	#9,pixelcolor
	lea	thing1,a0
	bsr	radplot
	lea	thing2,a0
	bsr	radplot
	lea	thing3,a0
	bsr	radplot
	lea	thing4,a0
	bsr	radplot
	lea	thing5,a0
	bsr	radplot
	lea	thing8,a0
	bsr	radplot
	move.w	#12,pixelcolor
	lea	thing6,a0
	bsr	radplot
	rts
radplot:
	tst.w	(a0)
	bmi	pat2
	move.w	2(a0),d0	;x
	move.w	6(a0),d1	;z
	ext.l	d0
	ext.l	d1
	asr.l	#5,d0
	asr.l	#8,d1
	neg.w	d1
	add.w	#159,d1
	add.w	#160,d0
	move.w	d1,pixely
	move.w	d0,pixelx
	bsr	doubleplot2
	addq.w	#1,pixely
	bsr	doubleplot2
pat2:
	rts
*************************************************
*	take control of radar business		*
*************************************************
doradar2:
	bsr	putrad
	move.w	#13,pixelcolor
	lea	attack1,a0
	bsr	radplot
	move.w	#10,pixelcolor
	lea	race1,a0
	bsr	radplot
	lea	race2,a0
	bsr	radplot
	move.w	#9,pixelcolor
	lea	diamond1,a0
	bsr	radplot
	lea	diamond2,a0
	bsr	radplot
	lea	diamond3,a0
	bsr	radplot
	lea	diamond4,a0
	bsr	radplot
	lea	diamond5,a0
	bsr	radplot
	lea	diamond6,a0
	bsr	radplot
	move.w	#12,pixelcolor
	lea	thing6,a0
	bsr	radplot
	rts
*************************************************
*	take control of radar business		*
*************************************************
doradar3:
	bsr	putrad
	move.w	#13,pixelcolor
	lea	tower1,a0
	bsr	radplot
	lea	tower2,a0
	bsr	radplot
	lea	tower3,a0
	bsr	radplot
	lea	tower4,a0
	bsr	radplot
	lea	tower5,a0
	bsr	radplot
	lea	tower6,a0
	bsr	radplot
	rts
tx:	blk.w	1,0

putrad:
	moveq	#47,d7
	move.l	hiden,a0
	addi.l	#17984,a0
	cmpi.w	#500,energy
	bgt	prad1
	lea	radartoolow,a1
	bra	drloop
prad1:
	cmpi.w	#1000,energy
	bgt	prad2
	lea	radarlow,a1
	bra	drloop
prad2:
	lea	radar,a1
drloop:
	move.l	(a1)+,(a0)+
	move.l	(a1)+,(a0)+
	move.l	(a1)+,(a0)+
	move.l	(a1)+,(a0)+
	move.l	(a1)+,(a0)+
	move.l	(a1)+,(a0)+
	move.l	(a1)+,(a0)+
	move.l	(a1)+,(a0)+
	addi.l	#128,a0
	dbf	d7,drloop
	rts
*************************************************
*	jiggle the screen about a bit		*
*************************************************
amihit:
	tst.w	hitmeflag
	bmi	nohit2
	moveq	#45,d0
	bsr	random
	add.w	d0,myheight
	subq.w	#1,hitmeflag
	rts
nohit2:
	move.w	#-1,hitmeflag
	rts
*************************************************
*	Clear the shots so none active		*
*************************************************
clearshots:
	lea	shotlist,a0
	addq.l	#2,a0
	move.w	(a0)+,d0
clearsloop:
	move.w	#-1,(a0)+
	dbf	d0,clearsloop
	move.w	#3,shotlist+2
	rts
*************************************************
*	Clear the objects so none active	*
*************************************************
clearobjects:
	move.w	#-1,thing1
	move.w	#-1,thing2
	move.w	#-1,thing3
	move.w	#-1,thing4
	move.w	#-1,thing5
	move.w	#-1,thing6
	move.w	#-1,race1
	move.w	#-1,race2
	move.w	#-1,thing7
	move.w	#-1,thing8
	move.w	#-1,thing9
	move.w	#-1,attack1
	move.w	#-1,diamond1
	move.w	#-1,diamond2
	move.w	#-1,diamond3
	move.w	#-1,diamond4
	move.w	#-1,diamond5
	move.w	#-1,diamond6
	move.w	#-1,boomob
	rts
*************************************************
*	limits for jstick			*
*************************************************
limits:
	cmpi.w	#300,myheight
	blt	lim2
	move.w	#300,myheight
	rts
lim2:
	cmpi.w	#30,myheight
	bgt	lim3
	move.w	#30,myheight
lim3:	rts

limits2:
	cmpi.w	#220,myheight
	blt	lim22
	move.w	#220,myheight
	rts
lim22:
	cmpi.w	#40,myheight
	bgt	lim32
	move.w	#40,myheight
lim32:	rts
limits3:
	cmpi.w	#400,myheight
	blt	lim23
	move.w	#400,myheight
	rts
lim23:
	cmpi.w	#30,myheight
	bgt	lim33
	move.w	#30,myheight
lim33:	rts
*************************************************
*	Explosion only one of these at a time	*
*************************************************
doboom:
	lea	boomob,a0
	tst.w	(a0)
	bmi	noboom
	move.w	boomcolor,pixelcolor
	subq.w	#1,(a0)+
	moveq	#25,d7
boomloop:
	move.w	(a0),d3	;get the vels
	addq.w	#1,2(a0)
	move.w	2(a0),d4
	move.w	4(a0),d5
	add.w	d3,6(a0)
	add.w	d4,8(a0)
	add.w	d5,10(a0)
	
	move.w	xspeed,d0
	add.w	d0,6(a0)
	move.w	6(a0),d0
	move.w	myheight,d1
	add.w	8(a0),d1
	tst.w	8(a0)
	bmi	notmi
	neg.w	2(a0)
notmi:
	move.w	speed,d2
	asr.w	#1,d2
	sub.w	d2,10(a0)
	move.w	10(a0),d2
	cmpi.w	#100,d2
	bgt	carryboom
	move.w	#-1,(a0)
	bra	noboom
carryboom:
	movem.w	d0/d2,-(sp)
	bsr	a3dmath
	move.w	d0,pixelx
	move.w	d1,pixely
	cmpi.w	#2500,d2
	blt	bclose
	move.w	boomcolor,pixelcolor
	bsr	singleplot
	movem.w	(sp)+,d0/d2
	move.w	myheight,d1
	bsr	a3dmath
	move.w	#15,pixelcolor
	move.w	d0,pixelx
	move.w	d1,pixely
	bsr	singleplot
	bra	bmc
bclose:
	move.w	boomcolor,pixelcolor
	bsr	doubleplot
	addq.w	#1,pixely
	bsr	doubleplot
	movem.w	(sp)+,d0/d2
	move.w	myheight,d1
	bsr	a3dmath
	move.w	#15,pixelcolor
	move.w	d0,pixelx
	move.w	d1,pixely
	bsr	doubleplot
bmc:
	add.l	#12,a0
	dbf	d7,boomloop
noboom:
	rts
boomob:	blk.w	200,-1
*************************************************
*	Detect a few collisions with shots	*
*************************************************
shotcollisions:
	move	#-1,a1
	lea	attack1,a0
	bsr	haveihitthis
	move	#-1,a1
	lea	race2,a0
	bsr	haveihitthis
	move	#-1,a1
	lea	race1,a0
	bsr	haveihitthis
	rts

shotcollisions2:
	move	#1,a1
	lea	thing1,a0
	bsr	haveihitthis
	move	#1,a1
	lea	thing2,a0
	bsr	haveihitthis
	move	#1,a1
	lea	thing3,a0
	bsr	haveihitthis
	move	#1,a1
	lea	thing4,a0
	bsr	haveihitthis
	move	#1,a1
	lea	thing5,a0
	bsr	haveihitthis
	move	#1,a1
	lea	thing7,a0
	bsr	haveihitthis
	move	#1,a1
	lea	thing8,a0
	bsr	haveihitthis
	move	#1,a1
	lea	thing9,a0
	bsr	haveihitthis
	moveq	#-1,d6
	lea	thing6,a0
	bsr	haveihitthis
	tst.w	d6
	bmi	noadd
	addq.w	#1,endhits
noadd:
	rts

shotcollisions3:
	move	#1,a1
	lea	diamond1,a0
	bsr	haveihitthis
	move	#1,a1
	lea	diamond2,a0
	bsr	haveihitthis
	move	#1,a1
	lea	diamond3,a0
	bsr	haveihitthis
	move	#1,a1
	lea	diamond4,a0
	bsr	haveihitthis
	move	#1,a1
	lea	diamond5,a0
	bsr	haveihitthis
	move	#1,a1
	lea	diamond6,a0
	bsr	haveihitthis
	move	#1,a1
	moveq	#-1,d6
	lea	thing6,a0
	bsr	haveihitthis
	tst.w	d6
	bmi	noadd3
	addq.w	#1,endhits
noadd3:
	rts

haveihitthis:
	tst.w	(a0)
	bmi	noihavent
	lea	shotlist,a6
	move.w	2(a0),d0
	move.w	4(a0),d1
	move.w	6(a0),d2
	move.w	d0,a3
	move.w	d1,a4
	move.w	d2,a5
	addq.l	#2,a6
	move.w	(a6)+,d7	;max number of shots
hihloop:
	tst.w	(a6)+
	bmi	notact
	move.w	(a6)+,d3
	move.w	(a6)+,d4
	move.w	(a6)+,d5
	bsr	tstshot
	tst.w	d6
	bpl	noihavent2
	move.w	(a6)+,d3
	move.w	(a6)+,d4
	move.w	(a6)+,d5
	bsr	tstshot
	tst.w	d6
	bpl	noihavent3
	dbf	d7,hihloop
	rts
notact:
	add.l	#12,a6
noihavent:
	rts
noihavent2:
	move.w	#-1,-8(a6)
	lea	shotlist,a6
	subq.w	#1,(a6)
	rts
noihavent3:
	move.w	#-1,-14(a6)
	lea	shotlist,a6
	subq.w	#1,(a6)
	rts

tstshot:
	sub.w	#50,d0		;make bottom left corner of hit cube
	add.w	#30,d1
	sub.w	#50,d2
	cmp.w	d0,d3
	blt	nohit
	cmp.w	d1,d4
	bgt	nohit
	cmp.w	d2,d5
	blt	nohit
	add.w	#100,d0		;make bottom left corner of hit cube
	sub.w	#60,d1
	add.w	#shotspeed,d2	;an idea
	cmp.w	d0,d3
	bgt	nohit
	cmp.w	d1,d4
	blt	nohit
	cmp.w	d2,d5
	bgt	nohit
	cmpi.w	#1,a1
	beq	dki
	move.w	#-1,(a0)
	add.w	#10,score
	move.b	#1,numsflag
dki:	lea	boomob,a0
	move.w	#40,(a0)+
	moveq	#25,d6
putvelsloop:
	moveq	#10,d0
	bsr	random
	move.w	d0,(a0)+	;xvel
	move.w	#30,d0
	bsr	randomplus
	neg	d0
	move.w	d0,(a0)+	;yvel
	moveq	#10,d0
	bsr	random
	move.w	d0,(a0)+	;zvel
	move.w	a3,(a0)+
	move.w	a4,(a0)+
	move.w	a5,(a0)+
	dbf	d6,putvelsloop
	bsr	dohittargetsound
	moveq	#1,d6
	rts
nohit:
	moveq	#-1,d6		;signify nohit
	rts

*************************************************
*	Detect multiple shots			*
*************************************************
detectmultiple:
	lea	thing6,a0
	tst.w	(a0)
	bmi	nomult
	move.w	6(a0),d0
	cmpi.w	speed,d0	;see if it is close enough
	bgt	nomult
	cmpi.w	#-50,2(a0)	;check left x
	blt	nomult
	cmpi.w	#50,2(a0)	;check right x
	bgt	nomult
	move.w	myheight,d0
	neg	d0
	cmp.w	4(a0),d0
	blt	nomult
	add.w	#200,energy
	bsr	doundersound
	add.w	#100,score
	move.b	#1,numsflag
nomult:
	rts

energy:	blk.w	1,0
*************************************************
*	Detect a few collisions with me		*
*************************************************
mycollisions:
	lea	drawlist,a6
	move.w	sortnumber,d7
	subq.w	#1,d7
mcloop:
	move.l	(a6)+,a0
	tst.w	(a0)		;is it even active
	bmi	notthisone	
	move.w	6(a0),d0
	cmpi.w	speed,d0	;see if it is close enough
	bgt	notthisone
	cmpi.w	#-50,2(a0)	;check left x
	blt	notthisone
	cmpi.w	#50,2(a0)	;check right x
	bgt	notthisone
	move.w	myheight,d0
	neg	d0
	add.w	#40,d0
	cmp.w	4(a0),d0
	blt	notthisone
	sub.w	#80,d0
	cmp.w	4(a0),d0
	bgt	notthisone
skt:	move.w	#-1,(a0)
	sub.w	#200,energy
	bra	gotme
notthisone:
	dbf	d7,mcloop
	rts
gotme:
	bsr	domehitsound
	move.w	#20,hitmeflag
	rts	
*************************************************
*	Detect a few collisions with me		*
*************************************************
mycollisions2:
	lea	drawlist,a6
	move.w	sortnumber,d7
	subq.w	#1,d7
mcloop2:
	move.l	(a6)+,a0
	cmp.l	#thing6,a0
	beq	notthisone2
	tst.w	(a0)		;is it even active
	bmi	notthisone2	
	move.w	6(a0),d0
	cmpi.w	speed,d0	;see if it is close enough
	bgt	notthisone2
	cmpi.w	#-60,2(a0)	;check left x
	blt	notthisone2
	cmpi.w	#60,2(a0)	;check right x
	bgt	notthisone2
skt2:	move.w	#-1,(a0)
	sub.w	#200,energy
	bra	gotme2
notthisone2:
	dbf	d7,mcloop2
	rts
gotme2:
	bsr	domehitsound
	move.w	#20,hitmeflag
	rts	
*************************************************
*	Shoot routine hopefully			*
*************************************************
shoot:
	tst.w	firebutton
	bmi	moveshots
	cmpi.w	#500,energy
	blt	moveshots
	move.w	#-1,firebutton
	tst.w	firecount
	bpl	moveshots
	moveq	#10,d0
	sub.w	shotlist+2,d0
	move.w	d0,firecount
	lea	shotlist,a0
	move.w	(a0),d0		;shots active
	cmp.w	2(a0),d0	;have we exceeded the max num of shots
	bge	moveshots	;yep so move those that are active
	move.w	2(a0),d0	;max number-1 for dbf
	addq.l	#4,a0
findnewslot:
	tst.w	(a0)
	bmi	foundit
	addi.l	#14,a0
	dbf	d0,findnewslot
	bra	moveshots
foundit:
	move.w	#1,(a0)+		;change it's flag
	move.w	#-50,(a0)+		;x for left shot
	move.w	myheight,d0
	neg	d0
	add.w	#20,d0
	move.w	d0,(a0)+		;y for left shot
	move.w	#50,(a0)+		;z for left shot
	move.w	#50,(a0)+		;x for right shot
	move.w	d0,(a0)+		;y for right shot
	move.w	#50,(a0)+		;z for right shot
	addq.w	#1,shotlist		;add to number active
	sub.w	#20,energy
	bsr	doshootsound
moveshots:
	subq.w	#1,firecount
	bpl	ms2
	move.w	#-1,firecount
ms2:
	lea	shotlist,a0
	move.w	2(a0),d7		;max no of shots active-1
	addq.l	#4,a0			;move to start of data
msloop:
	tst.w	(a0)
	bmi	nactive
	add.w	#shotspeed,6(a0)
	move.w	xspeed,d0
	add.w	d0,2(a0)
	move.w	2(a0),d0	;x
	move.w	myheight,d1
	add.w	4(a0),d1	;y
	move.w	6(a0),d2	;z
	cmpi.w	#12000,d2
	bge	itsgone
	addq.w	#4,simagecount
	cmpi.w	#12,simagecount
	ble	noms2
	move.w	#0,simagecount
noms2:
	move.w	d0,-(sp)
	move.w	simagecount,d0
	lea	shotimages,a6
	move.l	(a6,d0.w),a6
	move.w	(sp)+,d0
	bsr	drawshot
	add.w	#shotspeed,12(a0)
	move.w	xspeed,d0
	add.w	d0,8(a0)
	move.w	8(a0),d0	;x
	move.w	myheight,d1
	add.w	10(a0),d1	;y
	move.w	12(a0),d2	;z
	addq.w	#4,simagecount2
	cmpi.w	#12,simagecount2
	ble	noms22
	move.w	#0,simagecount2
noms22:
	move.w	d0,-(sp)
	move.w	simagecount2,d0
	lea	shotimages2,a6
	move.l	(a6,d0.w),a6
	move.w	(sp)+,d0
	bsr	drawshot
nactive:
	add.l	#14,a0
	dbf	d7,msloop
noms:
	rts

itsgone:
	subq.w	#1,shotlist
	move.w	#-1,(a0)
	add.l	#14,a0
	dbf	d7,msloop
	rts

drawshot:
	move.w	d7,-(sp)
	move.w	#7,linecolor
*	move.w	d0,-(sp)
*	move.w	simagecount,d0
*	lea	shotimages,a6
*	move.l	(a6,d0.w),a6
*	move.w	(sp)+,d0
	lea	onscreenxy,a3
	move.w	(a6)+,d7
dsloop:
	move.w	(a6)+,d3
	add.w	d0,d3
	move.w	(a6)+,d4
	add.w	d1,d4
	move.w	(a6)+,d5
	add.w	d2,d5

	moveq	#0,d6
	move.w	d3,d6		;get x
	muls	#magic,d6	;persp
	divs	d5,d6
	add.w	#159,d6		;adjust for centre of screen
	move.w	d6,(a3)+	;return screenx in d6
	moveq	#0,d6		;get y
	move.w	d4,d6
	muls	#magic,d6
	divs	d5,d6
	add.w	#22,d6		;adjust for centre
	move.w	d6,(a3)+	;return screeny in d7
	dbf	d7,dsloop

	lea	onscreenxy,a3
	move.w	(a3),x1
	move.w	2(a3),y1
	move.w	4(a3),x2
	move.w	6(a3),y2
	bsr	clipit
	move.w	8(a3),x1
	move.w	10(a3),y1
	move.w	12(a3),x2
	move.w	14(a3),y2
	bsr	clipit
	move.w	(sp)+,d7
	rts

simagecount:	blk.w	1,0
simagecount2:	blk.w	1,0

shotimages:
	dc.l	shotdef1,shotdef2,shotdef3,shotdef4
shotimages2:
	dc.l	shotdef1,shotdef4,shotdef3,shotdef2

shotdef1:
	dc.w	3		;number of points-1
	dc.w	-10,10,0
	dc.w	-10,-10,0
	dc.w	10,10,0
	dc.w	10,-10,0
shotdef2:
	dc.w	3		;number of points-1
	dc.w	-10,0,0
	dc.w	0,10,0
	dc.w	10,0,0
	dc.w	0,-10,0
shotdef3:
	dc.w	3		;number of points-1
	dc.w	-10,10,0
	dc.w	10,10,0
	dc.w	-10,-10,0
	dc.w	10,-10,0
shotdef4:
	dc.w	3		;number of points-1
	dc.w	0,10,0
	dc.w	10,0,0
	dc.w	-10,0,0
	dc.w	0,-10,0

shotlist:	blk.w	100,-1
firecount:	blk.w	1,0
*************************************************
willitappear:
	bsr	randomplus
	cmpi.w	#5,d0		;will it come out?
	bgt	noitwont
	move.w	#1,(a0)
	bsr	getrandomthings
noitwont:
	rts
willitappear2:
	bsr	randomplus
	cmpi.w	#5,d0		;will it come out?
	bgt	noitwont2
	move.w	#1,(a0)
	bsr	getrandomthings2
noitwont2:
	rts
willitappear3:
	bsr	randomplus
	cmpi.w	#5,d0		;will it come out?
	bgt	noitwont3
	move.w	#1,(a0)
	bsr	getrandomthings3
noitwont3:
	rts
rotatecount:	blk.w	1,0
ram:	equ	11
*********************************************
dothings2:
	lea	thing1,a0	;address of attacker 1 structure
	tst.w	(a0)
	bpl	drt2
	move.w	#-1,udflag
	move.w	#10,udvel
	move.w	#0,udcount
	move.w	#1,(a0)
	move.w	#3000,6(a0)	;z
	move.w	#0,2(a0)
	move.w	#-100,4(a0)
	move.w	#ram,rotatecount
drt2:
	lea	thing2,a0	;address of attacker 1 structure
	tst.w	(a0)
	bpl	drt3
	tst.w	rotatecount
	bpl	drt3
	move.w	#1,(a0)
	move.w	#3000,6(a0)	;z
	move.w	#0,2(a0)
	move.w	#-100,4(a0)
	move.w	#ram,rotatecount
drt3:
	lea	thing3,a0	;address of attacker 1 structure
	tst.w	(a0)
	bpl	drt4
	tst.w	rotatecount
	bpl	drt4
	move.w	#1,(a0)
	move.w	#3000,6(a0)	;z
	move.w	#0,2(a0)
	move.w	#-100,4(a0)
	move.w	#ram,rotatecount
drt4:
	lea	thing4,a0	;address of attacker 1 structure
	tst.w	(a0)
	bpl	drt5
	tst.w	rotatecount
	bpl	drt5
	move.w	#1,(a0)
	move.w	#3000,6(a0)	;z
	move.w	#0,2(a0)
	move.w	#-100,4(a0)
	move.w	#ram,rotatecount
drt5:
	lea	thing5,a0	;address of attacker 1 structure
	tst.w	(a0)
	bpl	drt6
	tst.w	rotatecount
	bpl	drt6
	move.w	#1,(a0)
	move.w	#3000,6(a0)	;z
	move.w	#0,2(a0)
	move.w	#-100,4(a0)
	move.w	#ram,rotatecount
drt6:
	lea	thing7,a0	;address of attacker 1 structure
	tst.w	(a0)
	bpl	drt7
	tst.w	rotatecount
	bpl	drt7
	move.w	#1,(a0)
	move.w	#3000,6(a0)	;z
	move.w	#0,2(a0)
	move.w	#-100,4(a0)
	move.w	#ram,rotatecount
drt7:
	lea	thing8,a0	;address of attacker 1 structure
	tst.w	(a0)
	bpl	drt8
	tst.w	rotatecount
	bpl	drt8
	move.w	#1,(a0)
	move.w	#3000,6(a0)	;z
	move.w	#0,2(a0)
	move.w	#-100,4(a0)
	move.w	#ram,rotatecount
drt8:
	lea	thing9,a0	;address of attacker 1 structure
	tst.w	(a0)
	bpl	drt9
	tst.w	rotatecount
	bpl	drt9
	move.w	#1,(a0)
	move.w	#3000,6(a0)	;z
	move.w	#0,2(a0)
	move.w	#-100,4(a0)
	move.w	#ram,rotatecount
drt9:
	lea	thing6,a0	;address of attacker 1 structure
	tst.w	(a0)
	bpl	drt10
	tst.w	rotatecount
	bpl	drt10
	move.w	#1,(a0)
	move.w	#2500,6(a0)	;z
	move.w	#0,2(a0)
	move.w	#-100,4(a0)
drt10:
rthings:
	subq.w	#1,rotatecount
	bsr	rotatethings
	bsr	upanddown
	lea	drawlist,a6
	move.l	#thing1,(a6)+
	move.l	#thing2,(a6)+
	move.l	#thing3,(a6)+
	move.l	#thing4,(a6)+
	move.l	#thing5,(a6)+
	move.l	#thing8,(a6)+
	move.l	#thing7,(a6)+
	move.l	#thing9,(a6)+
	move.l	#thing6,(a6)+
	move.w	#9,sortnumber
	bsr	sortndrawlist
	rts
******************************
udflag:		dc.w	-1
udvel:		dc.w	10
udcount:	dc.w	0
******************************
upanddown:
	tst.w	udflag
	bmi	noud
	subq.w	#1,udcount
	bpl	ud1
	move.w	#10,udcount
	neg	udvel
ud1:
	move.w	udvel,d0
	lea	thing1,a0
	add.w	d0,4(a0)	;add it to y
	lea	thing2,a0
	add.w	d0,4(a0)	;add it to y
	lea	thing3,a0
	add.w	d0,4(a0)	;add it to y
	lea	thing4,a0
	add.w	d0,4(a0)	;add it to y
	lea	thing5,a0
	add.w	d0,4(a0)	;add it to y
	lea	thing6,a0
	add.w	d0,4(a0)	;add it to y
	lea	thing7,a0
	add.w	d0,4(a0)	;add it to y
	lea	thing8,a0
	add.w	d0,4(a0)	;add it to y
	lea	thing9,a0
	add.w	d0,4(a0)	;add it to y
noud:	rts

rotatethings:
	lea	thing1,a0
	bsr	rotatethem
	lea	thing2,a0
	bsr	rotatethem
	lea	thing3,a0
	bsr	rotatethem
	lea	thing4,a0
	bsr	rotatethem
	lea	thing5,a0
	bsr	rotatethem
	lea	thing7,a0
	bsr	rotatethem
	lea	thing8,a0
	bsr	rotatethem
	lea	thing9,a0
	bsr	rotatethem
	rts

rotatethem:
	tst.w	(a0)
	bmi	norotate
	move.w	18(a0),d0
	add.w	d0,20(a0)
	subq.w	#1,16(a0)	;counter for dodge
	bpl	rot1
	move.w	#ra1,16(a0)
	neg.w	18(a0)		;change dodge factor
rot1:
	move.w	20(a0),d0
	add.w	d0,2(a0)
rrot:
	move.w	24(a0),d0
	add.w	d0,26(a0)
	subq.w	#1,22(a0)	;counter for dodge
	bpl	rot2
	move.w	#ra1,22(a0)
	neg.w	24(a0)		;change dodge factor
rot2:
	move.w	26(a0),d0
	add.w	d0,6(a0)
norotate:
	rts

sortnumber:	blk.w	1,0
ram2:		equ	10
udlvel:		equ	20
*********************************************
dothings4:
	lea	diamond1,a0	;address of attacker 1 structure
	tst.w	(a0)
	bpl	d3t2
	move.w	#1,(a0)
	move.w	#3000,6(a0)	;z
	move.w	#-375,2(a0)	;x
	move.w	#-208,4(a0)	;y
	move.w	#ram2,rotatecount
	move.w	#-udlvel,16(a0)
d3t2:
	lea	diamond2,a0	;address of attacker 1 structure
	tst.w	(a0)
	bpl	d3t3
	tst.w	rotatecount
	bpl	d3t3
	move.w	#1,(a0)
	move.w	#3000,6(a0)	;z
	move.w	#-225,2(a0)
	move.w	#-175,4(a0)
	move.w	#ram2,rotatecount
	move.w	#-udlvel,16(a0)
d3t3:
	lea	diamond3,a0	;address of attacker 1 structure
	tst.w	(a0)
	bpl	d3t4
	tst.w	rotatecount
	bpl	d3t4
	move.w	#1,(a0)
	move.w	#3000,6(a0)	;z
	move.w	#-75,2(a0)
	move.w	#-142,4(a0)
	move.w	#ram2,rotatecount
	move.w	#-udlvel,16(a0)
d3t4:
	lea	diamond4,a0	;address of attacker 1 structure
	tst.w	(a0)
	bpl	d3t5
	tst.w	rotatecount
	bpl	d3t5
	move.w	#1,(a0)
	move.w	#3000,6(a0)	;z
	move.w	#75,2(a0)
	move.w	#-109,4(a0)
	move.w	#ram2,rotatecount
	move.w	#-udlvel,16(a0)
d3t5:
	lea	diamond5,a0	;address of attacker 1 structure
	tst.w	(a0)
	bpl	d3t6
	tst.w	rotatecount
	bpl	d3t6
	move.w	#1,(a0)
	move.w	#3000,6(a0)	;z
	move.w	#225,2(a0)
	move.w	#-76,4(a0)
	move.w	#ram2,rotatecount
	move.w	#-udlvel,16(a0)
d3t6:
	lea	diamond6,a0	;address of attacker 1 structure
	tst.w	(a0)
	bpl	d3t7
	tst.w	rotatecount
	bpl	d3t7
	move.w	#1,(a0)
	move.w	#3000,6(a0)	;z
	move.w	#375,2(a0)
	move.w	#-43,4(a0)
	move.w	#ram2,rotatecount
	move.w	#-udlvel,16(a0)
d3t7:
	lea	thing6,a0	;address of attacker 1 structure
	tst.w	(a0)
	bpl	d3t8
	tst.w	rotatecount
	bpl	d3t8
	move.w	#1,(a0)
	move.w	#3500,6(a0)	;z
	move.w	#0,2(a0)
	move.w	#-100,4(a0)
	move.w	#ram2,rotatecount
	move.w	#0,18(a0)
	move.w	#15,16(a0)
d3t8:
things3:
	subq.w	#1,rotatecount
	bsr	bouncethings
	bsr	leftnright
	lea	drawlist,a6
	move.l	#diamond1,(a6)+
	move.l	#diamond2,(a6)+
	move.l	#diamond3,(a6)+
	move.l	#diamond4,(a6)+
	move.l	#diamond5,(a6)+
	move.l	#diamond6,(a6)+
	move.l	#thing6,(a6)+
	move.w	#7,sortnumber
	bsr	sortndrawlist
	rts

leftnright:
	lea	thing6,a0
	move.w	16(a0),d0
	add.w	d0,2(a0)
	add.w	d0,18(a0)
	cmpi.w	#-300,18(a0)
	bgt	lnr2
	neg.w	16(a0)
	rts	
lnr2:	cmpi.w	#300,18(a0)
	blt	lnr3
	neg.w	16(a0)
lnr3:
	rts

bouncethings:
	tst.w	udflag
	bmi	nobounce
	lea	diamond1,a0
	bsr	dobounce
	lea	diamond2,a0
	bsr	dobounce
	lea	diamond3,a0
	bsr	dobounce
	lea	diamond4,a0
	bsr	dobounce
	lea	diamond5,a0
	bsr	dobounce
	lea	diamond6,a0
	bsr	dobounce
nobounce:
	rts	

dobounce:
	tst.w	(a0)
	bmi	ndb
	move.w	16(a0),d0
	add.w	d0,4(a0)
	cmpi.w	#-ulimit,4(a0)
	bgt	chudl2
	neg	16(a0)
	bra	ndb
chudl2:
	cmpi.w	#-50,4(a0)
	blt	ndb
	neg	16(a0)
ndb:
	rts
ulimit:		equ	250
*************************************************
*		just experimenting		*
*************************************************
willtowerappear:
	bsr	randomplus
	cmpi.w	#5,d0
	bgt	wap
	move.w	#1,(a0)
	move.w	#800,d0
	bsr	random
	move.w	d0,2(a0)
	move.w	#-125,4(a0)
	move.w	#12000,6(a0)
wap:
	rts
*************************************************
*		just experimenting		*
*************************************************
dothingspart2:
	tst.w	endoflevel
	bpl	dtb9
	lea	tower1,a0	;address of tower1 structure
	tst.w	(a0)
	bpl	dtb2
	moveq	#100,d0
	bsr	willtowerappear
dtb2:
	lea	tower2,a0	;address of tower1 structure
	tst.w	(a0)
	bpl	dtb3
	moveq	#100,d0
	bsr	willtowerappear
dtb3:
	lea	tower3,a0	;address of tower1 structure
	tst.w	(a0)
	bpl	dtb4
	moveq	#100,d0
	bsr	willtowerappear
dtb4:
	lea	tower4,a0	;address of tower1 structure
	tst.w	(a0)
	bpl	dtb5
	moveq	#100,d0
	bsr	willtowerappear
dtb5:
	lea	tower5,a0	;address of tower1 structure
	tst.w	(a0)
	bpl	dtb6
	moveq	#100,d0
	bsr	willtowerappear
dtb6:
	lea	tower6,a0	;address of tower1 structure
	tst.w	(a0)
	bpl	dtb7
	moveq	#100,d0
	bsr	willtowerappear
dtb7:
	lea	tower7,a0	;address of tower1 structure
	tst.w	(a0)
	bpl	dtb8
	moveq	#100,d0
	bsr	willtowerappear
dtb8:
	lea	thing6,a0	;address of tower1 structure
	tst.w	(a0)
	bpl	dtb9
	moveq	#100,d0
	bsr	willtowerappear
dtb9:
	lea	drawlist,a6
	move.l	#tower1,(a6)+
	move.l	#tower2,(a6)+
	move.l	#tower3,(a6)+
	move.l	#tower4,(a6)+
	move.l	#tower5,(a6)+
	move.l	#tower6,(a6)+
	move.l	#tower7,(a6)+
	move.l	#thing6,(a6)+
	move.w	#8,sortnumber
	bsr	sortndrawlist
	rts
*************************************************
*		just experimenting		*
*************************************************
willdiamondappear:
	bsr	randomplus
	cmpi.w	#5,d0
	bgt	wdap
	move.w	#1,(a0)
	move.w	#800,d0
	bsr	random
	move.w	d0,2(a0)
	moveq	#40,d0
	bsr	randomplus
	move.w	d0,16(a0)
	move.w	#-200,4(a0)
	move.w	#12000,6(a0)
wdap:
	rts

*************************************************
*		just experimenting		*
*************************************************
dothingspart3:
	tst.w	endoflevel
	bpl	dtc12
	lea	diamond1,a0	;address of tower1 structure
	tst.w	(a0)
	bpl	dtc2
	moveq	#100,d0
	bsr	willdiamondappear
dtc2:
	lea	diamond2,a0	;address of tower1 structure
	tst.w	(a0)
	bpl	dtc3
	moveq	#100,d0
	bsr	willdiamondappear
dtc3:
	lea	diamond3,a0	;address of tower1 structure
	tst.w	(a0)
	bpl	dtc4
	moveq	#100,d0
	bsr	willdiamondappear
dtc4:
	lea	diamond4,a0	;address of tower1 structure
	tst.w	(a0)
	bpl	dtc5
	moveq	#100,d0
	bsr	willdiamondappear
dtc5:
	lea	diamond5,a0	;address of tower1 structure
	tst.w	(a0)
	bpl	dtc6
	moveq	#100,d0
	bsr	willdiamondappear
dtc6:
	lea	diamond6,a0	;address of tower1 structure
	tst.w	(a0)
	bpl	dtc8
	moveq	#100,d0
	bsr	willdiamondappear
dtc8:
	lea	attack1,a0	;address of attacker 1 structure
	tst.w	(a0)
	bpl	dtc9
	move.w	#200,d0
	bsr	willitappear2
dtc9:
	lea	race2,a0	;address of attacker 1 structure
	tst.w	(a0)
	bpl	dtc10
	move.w	#500,d0
	bsr	willitappear3
dtc10:
	lea	thing6,a0	;address of attacker 1 structure
	tst.w	(a0)
	bpl	dtc11
	move.w	#1000,d0
	bsr	willitappear
dtc11:
	lea	race1,a0	;address of attacker 1 structure
	tst.w	(a0)
	bpl	dtc12
	move.w	#500,d0
	bsr	willitappear3
dtc12:
	bsr	raceintelligence
	bsr	attackintelligence
	bsr	flapwings
	bsr	raceshoot
	bsr	diamonddrop
	lea	drawlist,a6
	move.l	#diamond1,(a6)+
	move.l	#diamond2,(a6)+
	move.l	#diamond3,(a6)+
	move.l	#diamond4,(a6)+
	move.l	#diamond5,(a6)+
	move.l	#diamond6,(a6)+
	move.l	#thing6,(a6)+
	move.l	#race1,(a6)+
	move.l	#race2,(a6)+
	move.l	#attack1,(a6)+
	move.w	#10,sortnumber
	bsr	sortndrawlist
	rts
*************************************************
*		just experimenting		*
*************************************************
diamonddrop:
	lea	diamond1,a0
	bsr	dropem
	lea	diamond2,a0
	bsr	dropem
	lea	diamond3,a0
	bsr	dropem
	lea	diamond4,a0
	bsr	dropem
	lea	diamond5,a0
	bsr	dropem
	lea	diamond6,a0
	bsr	dropem
	rts
dropem:
	move.w	16(a0),d0
	add.w	d0,4(a0)
	cmpi.w	#-50,4(a0)
	bge	hitbot
	cmpi.w	#-200,4(a0)
	ble	hitbot
	rts

hitbot:
*	move.w	#0,14(a0)
	neg.w	16(a0)
	rts

*************************************************
*		just experimenting		*
*************************************************
dothings:
	tst.w	endoflevel
	bpl	dt11
	lea	thing1,a0	;address of attacker 1 structure
	tst.w	(a0)
	bpl	dt2
	moveq	#100,d0
	bsr	willitappear
dt2:
	lea	thing2,a0	;address of attacker 1 structure
	tst.w	(a0)
	bpl	dt3
	moveq	#100,d0
	bsr	willitappear
dt3:
	lea	thing3,a0	;address of attacker 1 structure
	tst.w	(a0)
	bpl	dt4
	moveq	#100,d0
	bsr	willitappear
dt4:
	lea	thing4,a0	;address of attacker 1 structure
	tst.w	(a0)
	bpl	dt5
	moveq	#100,d0
	bsr	willitappear
dt5:
	lea	thing5,a0	;address of attacker 1 structure
	tst.w	(a0)
	bpl	dt6
	moveq	#100,d0
	bsr	willitappear
dt6:
	lea	attack1,a0	;address of attacker 1 structure
	tst.w	(a0)
	bpl	dt7
	move.w	#500,d0
	bsr	willitappear2
dt7:
	lea	race2,a0	;address of attacker 1 structure
	tst.w	(a0)
	bpl	dt8
	move.w	#500,d0
	bsr	willitappear3
dt8:
	lea	thing6,a0	;address of attacker 1 structure
	tst.w	(a0)
	bpl	dt9
	move.w	#1000,d0
	bsr	willitappear
dt9:
	lea	race1,a0	;address of attacker 1 structure
	tst.w	(a0)
	bpl	dt10
	move.w	#500,d0
	bsr	willitappear3
dt10:
	lea	thing8,a0	;address of attacker 1 structure
	tst.w	(a0)
	bpl	dt11
	moveq	#100,d0
	bsr	willitappear
dt11:
	bsr	attackintelligence
	bsr	raceintelligence
	bsr	flapwings
	bsr	raceshoot
	lea	drawlist,a6
	move.l	#thing1,(a6)+
	move.l	#thing2,(a6)+
	move.l	#thing3,(a6)+
	move.l	#thing4,(a6)+
	move.l	#thing5,(a6)+
	move.l	#thing6,(a6)+
	move.l	#race1,(a6)+
	move.l	#thing8,(a6)+
	move.l	#attack1,(a6)+
	move.l	#race2,(a6)+
	move.w	#10,sortnumber
	bsr	sortndrawlist
	rts

drawraceshot:
	lea	race1,a0
	bsr	drawrs
	lea	race2,a0
	bsr	drawrs
	rts
drawrs:
	tst.w	22(a0)
	bmi	drsb
	subq.w	#1,22(a0)
	move.w	2(a0),d0	;x,y,z
	move.w	myheight,d1
	add.w	4(a0),d1
	move.w	6(a0),d2
	bsr	a3dmath
	move.w	d0,x1
	move.w	d1,y1
	move.w	#30,d0
	bsr	randomplus
	add.w	#150,d0
	move.w	d0,x2
	move.w	#10,d0
	bsr	randomplus
	add.w	#40,d0
	move.w	d0,y2
	move.w	boomcolor,linecolor
	bsr	clipit
	subq.w	#5,energy
drsb:
	rts

raceshoot:
	lea	race1,a0
	bsr	rshootstuff
	lea	race2,a0
	bsr	rshootstuff
	rts

rshootstuff:
	tst.w	(a0)
	bmi	rstb
	tst.w	22(a0)
	bpl	rstb
	move.w	#1000,d0
	bsr	randomplus
	cmpi.w	#15,d0
	bgt	rstb
	move.w	#3,22(a0)	;flag to draw a shot num=frames to last
	bsr	doraceshotsound
rstb:
	rts

flapwings:
	lea	race1vert,a0
	move.w	30(a0),d0	;flap vel
	add.w	d0,2(a0)
	add.w	d0,20(a0)
	addq.w	#1,32(a0)
	cmpi.w	#14,32(a0)
	blt	fwb
	move.w	#0,32(a0)
	neg	30(a0)
fwb:
	rts
	
raceintelligence:
	lea	race1,a0
	tst.w	(a0)
	bmi	ri2
	subq.w	#1,16(a0)	;counter for dodge
	bpl	ri1b
	move.w	#15,16(a0)
	neg.w	18(a0)		;change dodge factor
ri1b:
	move.w	18(a0),d0
	add.w	d0,2(a0)
	move.w	20(a0),d0	;add its speed
	tst.w	endoflevel
	bmi	notfast1
	move.w	#-1000,d0
notfast1:
	add.w	d0,6(a0)
	cmpi.w	#100,6(a0)
	bgt	ri2
	move.w	#-1,(a0)
ri2:
	lea	race2,a0
	tst.w	(a0)
	bmi	ri3
	subq.w	#1,16(a0)	;counter for dodge
	bpl	ri2b
	move.w	#15,16(a0)
	neg.w	18(a0)		;change dodge factor
ri2b:
	move.w	18(a0),d0
	add.w	d0,2(a0)
	move.w	20(a0),d0
	tst.w	endoflevel
	bmi	notfast2
	move.w	#-1000,d0
notfast2:
	add.w	d0,6(a0)
	cmpi.w	#100,6(a0)
	bgt	ri3
	move.w	#-1,(a0)
ri3:	rts

attackintelligence:
	lea	attack1,a0
	bsr	doint
	rts
doint:
	tst.w	(a0)
	bmi	ati2
	sub.w	#20,6(a0)
	tst.w	2(a0)
	bpl	at1i
	add.w	#12,2(a0)
	bra	ati2
at1i:
	sub.w	#12,2(a0)
ati2:
	rts

*********************************
*	preload all this stuff	*
*********************************
sortndrawlist2:
	moveq	#7,d6
*	subq.w	#1,d6
sortobs2:
	moveq	#6,d7		;number of obs-2?
	lea	drawlist,a6
soloop2:
	move.l	(a6),a0
	move.l	4(a6),a1
	move.w	4(a0),d0
	cmp.w	4(a1),d0
	bgt	swapem2
	addq.l	#4,a6
	dbf	d7,soloop2
	bra	preallymovem2
swapem2:
	move.l	a1,(a6)
	move.l	a0,4(a6)
	addq.l	#4,a6
	dbf	d7,soloop2
preallymovem2:
	dbf	d6,sortobs2
drawobjects2:
	lea	fracpoints,a0
	move.w	#319,d0
dobs2:
	move.w	#29000,(a0)+	;only the y's
	dbf	d0,dobs2
	move.w	#0,pixelcolor
	lea	drawlist,a5
	moveq	#7,d7
droloop2:
	move.w	d7,-(sp)
	move.l	(a5)+,a0
	bsr	calcndraw2
rm22:
	move.w	(sp)+,d7
	dbf	d7,droloop2
	tst.w	hitmeflag
	bmi	nosf
	bsr	domehitsound
nosf:	rts

calcndraw2:
*	move.w	xspeed,d0
*	add.w	d0,(a0)
	move.w	(a0),d0		;x
	add.w	xspeed,d0
	move.w	myheight,d1
	add.w	2(a0),d1	;y
	move.w	speed,d2
	sub.w	d2,4(a0)
	move.w	4(a0),d2	;z
	cmpi.w	#500,d2
	blt	itsoff2
	move.l	a0,a1
	addq.l	#6,a1
	moveq	#15,d7
	lea	fraconscreen,a3
cndloop2f:
	move.w	(a1)+,d3
	add.w	d0,d3
	move.w	(a1)+,d4
	add.w	d1,d4
	move.w	d2,d5

	moveq	#0,d6
	move.w	d3,d6		;get x
	muls	#magic2,d6	;persp
	divs	d5,d6
	add.w	#159,d6		;adjust for centre of screen
	move.w	d6,(a3)+	;return screenx in d6
	moveq	#0,d6		;get y
	move.w	d4,d6
	muls	#magic2,d6
	divs	d5,d6
	add.w	#22,d6		;adjust for centre
	move.w	d6,(a3)+	;return screeny in d7
	dbf	d7,cndloop2f
	cmpi.w	#7,pixelcolor
	bge	noaddtocol
	addq.w	#1,pixelcolor
*	move.w	#1,pixelcolor
noaddtocol:
	lea	fraconscreen,a3
	lea	fracpoints,a6
	moveq	#14,d7
fdloop:
	move.w	(a3),x1
	move.w	2(a3),y1
	move.w	4(a3),x2
	move.w	6(a3),y2
	bsr	drawveryspecial
	addq.l	#4,a3
	dbf	d7,fdloop
*	cmpi.w	#500,4(a0)
*	ble	itsoff2
	rts
itsoff2:
	addq.w	#5,energy
	move.w	#12000,4(a0)	;make it the back again
	move.w	fractrend,d0
	add.w	d0,fracstart
	move.w	fracstart,(a0)
	move.w	#0,2(a0)
	bsr	newfracrand
	lea	fracpoints,a0
	moveq	#31,d0
dobs2f:
	move.w	#29000,(a0)+	;only the y's
	move.w	#29000,(a0)+	;only the y's
	move.w	#29000,(a0)+	;only the y's
	move.w	#29000,(a0)+	;only the y's
	move.w	#29000,(a0)+	;only the y's
	move.w	#29000,(a0)+	;only the y's
	move.w	#29000,(a0)+	;only the y's
	move.w	#29000,(a0)+	;only the y's
	move.w	#29000,(a0)+	;only the y's
	move.w	#29000,(a0)+	;only the y's
	dbf	d0,dobs2f
	rts			;will add hooks for rand later

drawveryspecial:
	cmpi.w	#60,x2
	bmi	dvsover
	cmpi.w	#259,x1
	bgt	dvsover
	movem.l	d0-d4,-(sp)
	move.w	x2,d0
	sub.w	x1,d0		;d0 is number of x points
	move.w	d0,d4
	move.w	y2,d1
	sub.w	y1,d1		;ypoints
	asl.l	#4,d1
	ext.l	d1
	divs	d0,d1
	ext.l	d1
	move.w	d4,d0	
	subq.w	#1,d0
	move.w	y1,d3
	asl.l	#4,d3
	ext.l	d3
	cmpi.w	#200,d0
	bgt	nododvs
dvsloop:
	move.w	x1,pixelx
	move.l	d3,d4
	asr.l	#4,d4
	move.w	d4,pixely
	move.w	pixelx,d4
	tst.w	d4
	bmi	dontplotit
	cmpi.w	#319,d4
	bgt	dontplotit
	asl.w	#1,d4
	move.w	(a6,d4.w),d2		;y at same x last time
	cmp.w	pixely,d2
	ble	dontplotit	
	move.w	pixely,(a6,d4.w)
	bsr	specialplot
dontplotit:
	addq.w	#1,x1
	add.l	d1,d3
	dbf	d0,dvsloop
nododvs:
	movem.l	(sp)+,d0-d4
dvsover:
	rts

fracstart:	dc.w	0
fractrend:	dc.w	30
*********************************
*	preload all this stuff	*
*********************************
sortndrawlist:
	move	sortnumber,d6
	subq.w	#1,d6
sortobs:
	move.w	sortnumber,d7		;number of obs-2?
	subq.w	#2,d7
	lea	drawlist,a6
soloop:
	move.l	(a6),a0
	move.l	4(a6),a1
	move.w	6(a0),d0
	cmp.w	6(a1),d0
	blt	swapem
	addq.l	#4,a6
	dbf	d7,soloop
	bra	preallymovem
swapem:
	move.l	a1,(a6)
	move.l	a0,4(a6)
	addq.l	#4,a6
	dbf	d7,soloop
preallymovem:
	dbf	d6,sortobs
drawobjects:
	lea	drawlist,a5
	move.w	sortnumber,d7
	subq.w	#1,d7
droloop:
	move.w	d7,-(sp)
	move.l	(a5)+,a0
	tst.w	(a0)
	bmi	rm2
	bsr	calcndraw
rm2:
	move.w	(sp)+,d7
	dbf	d7,droloop
	rts

calcndraw:
	move.w	xspeed,d0
	add.w	d0,2(a0)
	move.w	2(a0),d0	;x
	tst.w	endoflevel
	bpl	ncw
	cmpi.w	#-1000,d0
	blt	itsoff
	cmpi.w	#1000,d0
	bgt	itsoff	
ncw:	move.w	myheight,d1
	add.w	4(a0),d1	;y
	move.w	speed,d2
	sub.w	d2,6(a0)
	move.w	6(a0),d2	;z
	cmpi.w	#50,d2
	blt	itsoff
cnds:
	move.l	8(a0),a1	;add of def
	move.w	10(a1),d7	;number of verts
	bmi	noshadow
	move.l	12(a1),a2	;add of points
	lea	onscreenxy,a3
cndsloop:
	move.w	(a2)+,d3
	add.w	d0,d3
	move.w	(a2)+,d4
	move.w	myheight,d4
	move.w	(a2)+,d5
	add.w	d2,d5
	
	moveq	#0,d6
	move.w	d3,d6		;get x
	muls	#magic,d6	;persp
	divs	d5,d6
	add.w	#159,d6		;adjust for centre of screen
	move.w	d6,(a3)+	;return screenx in d6
	moveq	#0,d6		;get y
	move.w	d4,d6
	muls	#magic,d6
	divs	d5,d6
	add.w	#22,d6		;adjust for centre
	move.w	d6,(a3)+	;return screeny in d7
	dbf	d7,cndsloop

	movem.w	d0-d2,-(sp)
	move.l	16(a1),a2	;add of points
	lea	onscreenxy,a3
	move.w	(a2)+,d7	;number of faces-1
cndsloop2:
	move.w	(a2)+,surfacedfn
	lea	surfacevrt,a6
	move.w	(a2)+,d6
	move.w	d6,(a6)+	;numbert of vrts
	subq.w	#1,d6
cndsiloop:
	move.w	(a2)+,d0
	asl.w	#2,d0
	move.w	(a3,d0.w),(a6)+
	move.w	2(a3,d0.w),(a6)+
	dbf	d6,cndsiloop
	lea	surfacedfn,a6
	bsr	draw_polygon
	dbf	d7,cndsloop2

	movem.w	(sp)+,d0-d2
noshadow:
	move.w	(a1),d7		;number of verts
	move.l	2(a1),a2	;add of points
	lea	onscreenxy,a3
cndloop:
	move.w	(a2)+,d3
	add.w	d0,d3
	move.w	(a2)+,d4
	add.w	d1,d4
	move.w	(a2)+,d5
	add.w	d2,d5
	
	moveq	#0,d6
	move.w	d3,d6		;get x
	muls	#magic,d6	;persp
	divs	d5,d6
	add.w	#159,d6		;adjust for centre of screen
	move.w	d6,(a3)+	;return screenx in d6
	moveq	#0,d6		;get y
	move.w	d4,d6
	muls	#magic,d6
	divs	d5,d6
	add.w	#22,d6		;adjust for centre
	move.w	d6,(a3)+	;return screeny in d7
	dbf	d7,cndloop

	move.w	#4,surfacedfn
	move.l	6(a1),a2	;add of points
	lea	onscreenxy,a3
	move.w	(a2)+,d7	;number of faces
cndloop2:
	move.w	(a2)+,surfacedfn
	lea	surfacevrt,a6
	move.w	(a2)+,d6
	move.w	d6,(a6)+	;numbert of vrts
	subq.w	#1,d6
cndiloop:
	move.w	(a2)+,d0
	asl.w	#2,d0
	move.w	(a3,d0.w),(a6)+
	move.w	2(a3,d0.w),(a6)+
	dbf	d6,cndiloop
	lea	surfacedfn,a6
	bsr	draw_polygon
	dbf	d7,cndloop2
	rts
itsoff:
	cmp.l	#race1,a0
	bne	itof2
	addq.w	#1,getaways
	move.b	#1,shipsflag
	bra	itof3
itof2:
	cmp.l	#race2,a0
	bne	itof3
	move.b	#1,shipsflag
	addq.w	#1,getaways
itof3:	move.w	#-1,(a0)
	rts

getrandomthings:
	move.w	#800,d0		;random x
	bsr	random
	move.w	d0,2(a0)
	move.w	#280,d0		;random y
	bsr	randomplus
	neg	d0
	sub.w	#25,d0
	move.w	d0,4(a0)
	move.w	#12000,6(a0)
	rts
getrandomthings2:
	move.w	#500,d0		;random x
	bsr	random
	move.w	d0,2(a0)
	move.w	myheight,d0
	neg	d0
	move.w	d0,4(a0)
	move.w	#12000,6(a0)
	rts
getrandomthings3:
	move.w	#500,d0		;random x
	bsr	random
	move.w	d0,2(a0)
	move.w	myheight,d0
	neg	d0
	move.w	d0,4(a0)
*	move.w	speed,6(a0)
	move.w	#12000,6(a0)
	moveq	#120,d0		;random x
	bsr	randomplus
*	add.w	speed,d0
*	neg	d0
	move.w	d0,20(a0)
	rts

onscreenxy:	blk.w	130,0
drawlist:	blk.l	10,0
ra1:	equ	49
ra2:	equ	25
ra3:	equ	24
restorevalues:
	lea	thing1,a0
	bsr	rstv
	lea	thing2,a0
	bsr	rstv
	lea	thing3,a0
	bsr	rstv
	lea	thing4,a0
	bsr	rstv
	lea	thing5,a0
	bsr	rstv
	lea	thing7,a0
	bsr	rstv
	lea	thing8,a0
	bsr	rstv
	lea	thing9,a0
	bsr	rstv
	rts
rstv:
	lea	restorevals,a1
	add.l	#16,a0
	move.w	(a1)+,(a0)+
	move.w	(a1)+,(a0)+
	move.w	(a1)+,(a0)+
	move.w	(a1)+,(a0)+
	move.w	(a1)+,(a0)+
	move.w	(a1)+,(a0)+
	rts

restorevals:
	dc.w	ra1		;counter for dodge
	dc.w	-1		;dodge factor
	dc.w	ra2		;dodge vel
	dc.w	ra3		;counter for dodge
	dc.w	-2		;dodge factor
	dc.w	0		;dodge vel

thing1:
	dc.w	-1		;flag
	dc.w	0,0,0		;x,y,z
	dc.l	thing1def	;address of things verts
	dc.w	4		;color offset
	dc.w	1		;flag for filled or wireframe 1=filled
	dc.w	ra1		;counter for dodge
	dc.w	-1		;dodge factor
	dc.w	ra2		;dodge vel
	dc.w	ra3		;counter for dodge
	dc.w	-2		;dodge factor
	dc.w	0		;dodge vel

thing2:
	dc.w	-1		;flag
	dc.w	0,0,0		;x,y,z
	dc.l	thing1def	;address of things verts
	dc.w	4		;color offset
	dc.w	1		;flag for filled or wireframe 1=filled
	dc.w	ra1		;counter for dodge
	dc.w	-1		;dodge factor
	dc.w	ra2		;dodge vel
	dc.w	ra3		;counter for dodge
	dc.w	-2		;dodge factor
	dc.w	0		;dodge vel
thing3:
	dc.w	-1		;flag
	dc.w	0,0,0		;x,y,z
	dc.l	thing1def	;address of things verts
	dc.w	4		;color offset
	dc.w	1		;flag for filled or wireframe 1=filled
	dc.w	ra1		;counter for dodge
	dc.w	-1		;dodge factor
	dc.w	ra2		;dodge vel
	dc.w	ra3		;counter for dodge
	dc.w	-2		;dodge factor
	dc.w	0		;dodge vel
thing4:
	dc.w	-1		;flag
	dc.w	0,0,0		;x,y,z
	dc.l	thing1def	;address of things verts
	dc.w	4		;color offset
	dc.w	1		;flag for filled or wireframe 1=filled
	dc.w	ra1		;counter for dodge
	dc.w	-1		;dodge factor
	dc.w	ra2		;dodge vel
	dc.w	ra3		;counter for dodge
	dc.w	-2		;dodge factor
	dc.w	0		;dodge vel
thing5:
	dc.w	-1		;flag
	dc.w	0,0,0		;x,y,z
	dc.l	thing1def	;address of things verts
	dc.w	4		;color offset
	dc.w	1		;flag for filled or wireframe 1=filled
	dc.w	ra1		;counter for dodge
	dc.w	-1		;dodge factor
	dc.w	ra2		;dodge vel
	dc.w	ra3		;counter for dodge
	dc.w	-2		;dodge factor
	dc.w	0		;dodge vel
thing7:
	dc.w	-1		;flag
	dc.w	0,0,0		;x,y,z
	dc.l	thing1def	;address of things verts
	dc.w	4		;color offset
	dc.w	1		;flag for filled or wireframe 1=filled
	dc.w	ra1		;counter for dodge
	dc.w	-1		;dodge factor
	dc.w	ra2		;dodge vel
	dc.w	ra3		;counter for dodge
	dc.w	-2		;dodge factor
	dc.w	0		;dodge vel
thing9:
	dc.w	-1		;flag
	dc.w	0,0,0		;x,y,z
	dc.l	thing1def	;address of things verts
	dc.w	4		;color offset
	dc.w	1		;flag for filled or wireframe 1=filled
	dc.w	ra1		;counter for dodge
	dc.w	-1		;dodge factor
	dc.w	ra2		;dodge vel
	dc.w	ra3		;counter for dodge
	dc.w	-2		;dodge factor
	dc.w	0		;dodge vel
thing6:
	dc.w	-1		;flag
	dc.w	0,0,0		;x,y,z
	dc.l	thing2def	;address of things verts
	dc.w	11		;color offset
	dc.w	1		;flag for filled or wireframe 1=filled
	dc.w	-5		;x vel
	dc.w	0		;counter
race1:
	dc.w	-1		;flag
	dc.w	0,0,0		;x,y,z
	dc.l	race1def	;address of things verts
	dc.w	6		;color offset
	dc.w	1		;flag for filled or wireframe 1=filled
	dc.w	0		;counter for dodge
	dc.w	10		;dodge factor
	dc.w	0		;speed storage
	dc.w	-1		;race shooting flag
race2:
	dc.w	-1		;flag
	dc.w	0,0,0		;x,y,z
	dc.l	race1def	;address of things verts
	dc.w	6		;color offset
	dc.w	1		;flag for filled or wireframe 1=filled
	dc.w	0		;counter for dodge
	dc.w	10		;dodge factor
	dc.w	0		;speed storage
	dc.w	-1		;race shooting flag

thing8:
	dc.w	-1		;flag
	dc.w	0,0,0		;x,y,z
	dc.l	thing1def	;address of things verts
	dc.w	4		;color offset
	dc.w	1		;flag for filled or wireframe 1=filled
	dc.w	ra1		;counter for dodge
	dc.w	-1		;dodge factor
	dc.w	ra2		;dodge vel
	dc.w	ra3		;counter for dodge
	dc.w	-2		;dodge factor
	dc.w	0		;dodge vel
attack1:
	dc.w	-1		;flag
	dc.w	0,0,0		;x,y,z
	dc.l	at1def		;address of things verts
	dc.w	7		;color offset
	dc.w	1		;flag for filled or wireframe 1=filled
attack2:
	dc.w	-1		;flag
	dc.w	0,0,0		;x,y,z
	dc.l	at1def		;address of things verts
	dc.w	7		;color offset
	dc.w	1		;flag for filled or wireframe 1=filled

diamond1:
	dc.w	-1		;flag
	dc.w	0,0,0		;x,y,z
	dc.l	diamond1def	;address of things verts
	dc.w	4		;color offset
	dc.w	1		;flag for filled or wireframe 1=filled
	dc.w	0		;velocity for drop
diamond2:
	dc.w	-1		;flag
	dc.w	0,0,0		;x,y,z
	dc.l	diamond1def	;address of things verts
	dc.w	4		;color offset
	dc.w	1		;flag for filled or wireframe 1=filled
	dc.w	0		;velocity for drop
diamond3:
	dc.w	-1		;flag
	dc.w	0,0,0		;x,y,z
	dc.l	diamond1def	;address of things verts
	dc.w	4		;color offset
	dc.w	1		;flag for filled or wireframe 1=filled
	dc.w	0		;velocity for drop
diamond4:
	dc.w	-1		;flag
	dc.w	0,0,0		;x,y,z
	dc.l	diamond1def	;address of things verts
	dc.w	4		;color offset
	dc.w	1		;flag for filled or wireframe 1=filled
	dc.w	0		;velocity for drop
diamond5:
	dc.w	-1		;flag
	dc.w	0,0,0		;x,y,z
	dc.l	diamond1def	;address of things verts
	dc.w	4		;color offset
	dc.w	1		;flag for filled or wireframe 1=filled
	dc.w	0		;velocity for drop
diamond6:
	dc.w	-1		;flag
	dc.w	0,0,0		;x,y,z
	dc.l	diamond1def	;address of things verts
	dc.w	4		;color offset
	dc.w	1		;flag for filled or wireframe 1=filled
	dc.w	0		;velocity for drop

thing1def:
	dc.w	3		;number of points-1
	dc.l	thing1vert	;add of actual vertices
	dc.l	thing1con	;connection list
	dc.w	3		;points in shad-1
	dc.l	thing1shad
	dc.l	thing1scon
thing2def:
	dc.w	3		;number of points-1
	dc.l	thing1vert	;add of actual vertices
	dc.l	thing2con	;connection list
	dc.w	3		;points in shad-1
	dc.l	thing1shad
	dc.l	thing1scon
diamond1def:
	dc.w	4		;number of points-1
	dc.l	diamond1vert	;add of actual vertices
	dc.l	diamond1con	;connection list
	dc.w	3		;points in shad-1 neg means no shad
	dc.l	thing1shad
	dc.l	thing1scon
race1def:
	dc.w	4		;number of points-1
	dc.l	race1vert	;add of actual vertices
	dc.l	race1con	;connection list
	dc.w	3		;points in shad-1
	dc.l	race1shad
	dc.l	race1scon

thing1vert:
	dc.w	-50,25,50
	dc.w	0,25,0
	dc.w	50,25,50
	dc.w	0,-25,50
thing1con:
	dc.w	1
	dc.w	5
	dc.w	4
	dc.w	3,1,0,3
	dc.w	4
	dc.w	4
	dc.w	3,2,1,3
thing2con:
	dc.w	1		;nuber of faces-1
	dc.w	12		;color
	dc.w	4		;number of verts
	dc.w	3,1,0,3
	dc.w	11
	dc.w	4
	dc.w	3,2,1,3

thing1shad:
	dc.w	0,0,100
	dc.w	50,0,50
	dc.w	0,0,0
	dc.w	-50,0,50
thing1scon:
	dc.w	0		;number of faces
	dc.w	15		;color
	dc.w	5		;number of vrts
	dc.w	0,1,2,3,0

diamond1vert:
	dc.w	-50,0,50
	dc.w	0,0,0
	dc.w	50,0,50
	dc.w	0,50,0
	dc.w	0,-50,0
diamond1con:
	dc.w	3
	dc.w	5
	dc.w	4
	dc.w	4,1,0,4
	dc.w	4
	dc.w	4
	dc.w	4,2,1,4
	dc.w	10
	dc.w	4
	dc.w	1,3,0,1
	dc.w	5
	dc.w	4
	dc.w	2,3,1,2

race1vert:
	dc.w	-50,00,100
	dc.w	-10,0,0
	dc.w	10,0,0
	dc.w	50,00,100
	dc.w	0,-10,100
	dc.w	10,7		;flap vel,times

race1con:
	dc.w	2		;nuber of faces-1
	dc.w	14		;color
	dc.w	4		;number of verts
	dc.w	4,1,0,4
	dc.w	6
	dc.w	4
	dc.w	4,2,1,4
	dc.w	13
	dc.w	4
	dc.w	4,3,2,4

race1shad:
	dc.w	-50,0,100
	dc.w	-10,0,0
	dc.w	10,0,0
	dc.w	50,0,100
race1scon:
	dc.w	0		;number of faces
	dc.w	15		;color
	dc.w	5		;number of vrts
	dc.w	0,3,2,1,0

at1def:
	dc.w	3		;number of points-1
	dc.l	at1vert		;add of actual vertices
	dc.l	at1con		;connection list
	dc.w	2		;points in shad-1
	dc.l	at1shad
	dc.l	at1scon
	dc.w	1

at1vert:
	dc.w	0,-20,20
	dc.w	-10,10,10
	dc.w	10,10,10
	dc.w	0,0,0
at1con:
	dc.w	2		;nuber of faces-1
	dc.w	7		;color
	dc.w	4		;number of verts
	dc.w	0,2,3,0
	dc.w	8
	dc.w	4
	dc.w	0,3,1,0
	dc.w	9
	dc.w	4
	dc.w	3,2,1,3

at1shad:
	dc.w	-10,0,20
	dc.w	10,0,20
	dc.w	0,0,0
at1scon:
	dc.w	0		;nuber of faces-1
	dc.w	15		;color
	dc.w	4		;number of verts
	dc.w	0,1,2,0

tower1:
	dc.w	-1		;flag
	dc.w	0,0,0		;x,y,z
	dc.l	tower1def	;address of things verts
	dc.w	4		;color offset
	dc.w	1		;flag for filled or wireframe 1=filled
	dc.w	ra1		;counter for dodge
	dc.w	-1		;dodge factor
	dc.w	ra2		;dodge vel
	dc.w	ra3		;counter for dodge
	dc.w	-2		;dodge factor
	dc.w	0		;dodge vel
tower2:
	dc.w	-1		;flag
	dc.w	0,0,0		;x,y,z
	dc.l	tower1def	;address of things verts
	dc.w	4		;color offset
	dc.w	1		;flag for filled or wireframe 1=filled
	dc.w	ra1		;counter for dodge
	dc.w	-1		;dodge factor
	dc.w	ra2		;dodge vel
	dc.w	ra3		;counter for dodge
	dc.w	-2		;dodge factor
	dc.w	0		;dodge vel
tower3:
	dc.w	-1		;flag
	dc.w	0,0,0		;x,y,z
	dc.l	tower1def	;address of things verts
	dc.w	4		;color offset
	dc.w	1		;flag for filled or wireframe 1=filled
	dc.w	ra1		;counter for dodge
	dc.w	-1		;dodge factor
	dc.w	ra2		;dodge vel
	dc.w	ra3		;counter for dodge
	dc.w	-2		;dodge factor
	dc.w	0		;dodge vel
tower4:
	dc.w	-1		;flag
	dc.w	0,0,0		;x,y,z
	dc.l	tower1def	;address of things verts
	dc.w	4		;color offset
	dc.w	1		;flag for filled or wireframe 1=filled
	dc.w	ra1		;counter for dodge
	dc.w	-1		;dodge factor
	dc.w	ra2		;dodge vel
	dc.w	ra3		;counter for dodge
	dc.w	-2		;dodge factor
	dc.w	0		;dodge vel
tower5:
	dc.w	-1		;flag
	dc.w	0,0,0		;x,y,z
	dc.l	tower1def	;address of things verts
	dc.w	4		;color offset
	dc.w	1		;flag for filled or wireframe 1=filled
	dc.w	ra1		;counter for dodge
	dc.w	-1		;dodge factor
	dc.w	ra2		;dodge vel
	dc.w	ra3		;counter for dodge
	dc.w	-2		;dodge factor
	dc.w	0		;dodge vel
tower6:
	dc.w	-1		;flag
	dc.w	0,0,0		;x,y,z
	dc.l	tower1def	;address of things verts
	dc.w	4		;color offset
	dc.w	1		;flag for filled or wireframe 1=filled
	dc.w	ra1		;counter for dodge
	dc.w	-1		;dodge factor
	dc.w	ra2		;dodge vel
	dc.w	ra3		;counter for dodge
	dc.w	-2		;dodge factor
	dc.w	0		;dodge vel
tower7:
	dc.w	-1		;flag
	dc.w	0,0,0		;x,y,z
	dc.l	tower1def	;address of things verts
	dc.w	4		;color offset
	dc.w	1		;flag for filled or wireframe 1=filled
	dc.w	ra1		;counter for dodge
	dc.w	-1		;dodge factor
	dc.w	ra2		;dodge vel
	dc.w	ra3		;counter for dodge
	dc.w	-2		;dodge factor
	dc.w	0		;dodge vel

tower1def:
	dc.w	11		;number of points-1
	dc.l	tower1vert	;add of actual vertices
	dc.l	tower1con	;connection list
	dc.w	-1		;points in shad-1 neg means no shad
*	dc.l	1shad
*	dc.l	thing1scon
tower1vert:
	dc.w	-40,-125,40
	dc.w	0,-125,0
	dc.w	40,-125,40
	dc.w	-20,-100,40
	dc.w	0,-100,0
	dc.w	20,-100,40
	dc.w	-20,100,40
	dc.w	0,100,0
	dc.w	20,100,40
	dc.w	-40,125,40
	dc.w	0,125,0
	dc.w	40,125,40
tower1con:
	dc.w	5		;number of faces
	dc.w	4		;color
	dc.w	5		;number of vrts
	dc.w	1,4,3,0,1
	dc.w	3		;color
	dc.w	5		;number of vrts
	dc.w	2,5,4,1,2
	dc.w	3		;color
	dc.w	5		;number of vrts
	dc.w	3,4,7,6,3
	dc.w	2		;color
	dc.w	5		;number of vrts
	dc.w	4,5,8,7,4
	dc.w	2		;color
	dc.w	5		;number of vrts
	dc.w	6,7,10,9,6
	dc.w	1		;color
	dc.w	5		;number of vrts
	dc.w	7,8,11,10,7

*************************************************
*	Ground routine				*
*	will add hooks for up down		*
*************************************************
ground:
	lea	groundstuff,a0
	moveq	#69,d7
gloop:
	move.w	xspeed,d0
	add.w	d0,(a0)
	move.w	(a0)+,d0	;get x
	move.w	(a0)+,d1	;y
	move.w	speed,d2
	sub.w	d2,(a0)		;add speed to z
	move.w	(a0)+,d2	;get z		
	tst.w	d2
	bpl	gl2
	bsr	getrandom2
	moveq	#0,d2
	bra	sph
gl2:
	move.w	d2,d6
	move.w	myheight,d5
	add.w	d5,d1
	bsr	a3dmath
	move.w	d0,pixelx
	move.w	d1,pixely
	and.l	#$ffff,d6
	divu	#4000,d6
*	and.l	#$ffff,d6
	addq.w	#1,d6
	move.w	d6,pixelcolor
	cmpi.w	#1,d6
	bgt	splot
	bsr	doubleplot
	dbf	d7,gloop
	rts
splot:
	bsr	singleplot
sph:	dbf	d7,gloop
	rts
*************************************************
*	Ground routine				*
*	will add hooks for up down		*
*************************************************
ground2:
	lea	groundstuff,a0
	moveq	#69,d7
gloop2:
	move.w	xspeed,d0
	add.w	d0,(a0)
	move.w	(a0)+,d0	;get x
	move.w	(a0)+,d1	;y
	move.w	speed,d2
	sub.w	d2,(a0)		;add speed to z
	move.w	(a0)+,d2	;get z		
	tst.w	d2
	bpl	gl22
	bsr	getrandom4
	moveq	#0,d2
gl22:
	move.w	d2,d6
	move.w	myheight,d5
	add.w	d5,d1
	bsr	a3dmath
	move.w	d0,pixelx
	move.w	d1,pixely
	and.l	#$ffff,d6
	divu	#4000,d6
*	and.l	#$ffff,d6
	addq.w	#1,d6
	move.w	d6,pixelcolor
	cmpi.w	#1,d6
	bgt	splot2
	bsr	doubleplot
	dbf	d7,gloop2
	rts
splot2:
	bsr	singleplot
	dbf	d7,gloop2
	rts
***********************************************
preground:
	lea	groundstuff,a0
	moveq	#69,d7			;number of ground dots
pgloop:
	bsr	getrandom
	dbf	d7,pgloop
	rts

preground2:
	lea	groundstuff,a0
	moveq	#69,d7			;number of ground dots
pgloop2:
	bsr	getrandom3
	dbf	d7,pgloop2
	rts

getrandom:
	move.w	#1500,d0
	bsr	random
	move.w	d0,(a0)+	;x
	move.w	#0,(a0)+	;y
	move.w	#12000,d0
	bsr	randomplus
	move.w	d0,(a0)+	;z
	rts

getrandom3:
	move.w	#1500,d0
	bsr	random
	move.w	d0,(a0)+		;x
	moveq	#100,d0
	bsr	random
	tst.w	d0
	ble	gr2
	move.w	#0,(a0)+
	bra	gr3
gr2:
	move.w	#-250,(a0)+		;y
gr3:
	move.w	#12000,d0		;z
	bsr	randomplus
	move.w	d0,(a0)+
	rts

getrandom2:
	move.w	#1500,d0
	bsr	random
	move.w	d0,-6(a0)		;x
	move.w	#0,-4(a0)		;y
	move.w	#12000,-2(a0)		;z
	rts

getrandom4:
	move.w	#1500,d0
	bsr	random
	move.w	d0,-6(a0)		;x
	moveq	#100,d0
	bsr	random
	tst.w	d0
	ble	gr2b
	move.w	#0,-4(a0)
	bra	gr3b
gr2b:
	move.w	#-250,-4(a0)		;y
gr3b:
	move.w	#12000,-2(a0)		;z
	rts


groundstuff:	blk.w	400,0
speed:		blk.w	1,0
*****************************************
*	give x,y,z in d0,d1,d2		*
*	returns onscreen coords in	*
*	d0,d1				*
*****************************************
a3dmath:
	moveq	#0,d3
	move.w	d0,d3		;get x
	muls	#magic,d3	;persp
	move.w	d2,d4		;get z
	divs	d4,d3
	add.w	#159,d3		;adjust for centre of screen
	move.w	d3,d0		;return screenx in d6

	moveq	#0,d3		;get y
	move.w	d1,d3
	muls	#magic,d3
	divs	d4,d3
	add.w	#22,d3		;adjust for centre
	move.w	d3,d1		;return screeny in d7
	rts
a3dmath2:
	movem.w	d3-d4,-(sp)
	moveq	#0,d3
	move.w	d0,d3		;get x
	muls	#magic2,d3	;persp
	move.w	d2,d4		;get z
	divs	d4,d3
	add.w	#159,d3		;adjust for centre of screen
	move.w	d3,d0		;return screenx in d6

	moveq	#0,d3		;get y
	move.w	d1,d3
	muls	#magic2,d3
	divs	d4,d3
	add.w	#50,d3		;adjust for centre
	move.w	d3,d1		;return screeny in d7
	movem.w	(sp)+,d3-d4
	rts
*******************************************
myvbl:
	bsr	mysoundprocessor
	tst.w	titflag
	bpl	nocls
	bsr	dovblcolors
	cmpi.w	#-1,titflag
	beq	nocls
	tst.w	dontdlt
	bpl	nocls
	bsr	dodlt
nocls:
	rts

vblcount:	blk.w	1,0
fcount:		blk.w	1,0
hitmeflag:	blk.w	1,-1
*****************************************
*	maintain the hbl position	*
*****************************************
maintainhbl:
	move.w	myheight,d1
	move.w	#12000,d2	;z
	moveq	#0,d3		;get y
	move.w	d1,d3
	muls	#magic,d3
	divs	d2,d3
	add.w	#1,d3		;adjust for centre
	move.b	d3,hblstart	;return screeny in d7
	and.w	#$ff,d3
	addi.b	#21,d3
	move.b	#100,hblstart2
	sub.b	d3,hblstart2
	rts
maintainhbl2:
	move.w	myheight,d1
	sub.w	#50,d1
	move.w	#12000,d2	;z
	moveq	#0,d3		;get y
	move.w	d1,d3
	muls	#magic,d3
	divs	d2,d3
	addq.w	#1,d3		;adjust for centre
	move.b	d3,hblstart	;return screeny in d7
	and.w	#$ff,d3
	addi.b	#31,d3
	move.b	#100,hblstart2
	sub.b	d3,hblstart2
	rts


setuphbl1:
	move.w	#1,wasthereever
	move.b	ieb,oldieb
	move.b	iea,oldiea
	move.b	ima,oldima
	move.l	key_vec,oldkeyvec
	move.l	key_vec,keyt+2
	move.l	#key_handler,key_vec	;put new key stuff in
	and.b	#$df,ieb		;stop 200hz timer
	and.b	#$fe,iea		;stop hblank
	move.l	hbl_vec,oldhblvec
	move.l	#hblhandler1,hbl_vec
	or.b	#1,iea			;enable hblank
	or.b	#1,ima
	move.l	vbl_vec,vblt+2		;set up vbl handler
	move.l	vbl_vec,oldvblvec
	move.l	#vbl_handler,vbl_vec
	rts
setuphblfrac:
	move.w	#1,wasthereever
	move.b	ieb,oldieb
	move.b	iea,oldiea
	move.b	ima,oldima
	move.l	key_vec,oldkeyvec
	move.l	key_vec,keyt+2
	move.l	#key_handler,key_vec	;put new key stuff in
	and.b	#$df,ieb		;stop 200hz timer
	and.b	#$fe,iea		;stop hblank
	move.l	hbl_vec,oldhblvec
	move.l	#hblhandlerfrac,hbl_vec
	or.b	#1,iea			;enable hblank
	or.b	#1,ima
	move.l	vbl_vec,vblt+2		;set up vbl handler
	move.l	vbl_vec,oldvblvec
	move.l	#vbl_handler,vbl_vec
	move.b	#1,hblstart
	rts
setuphbl2:
	move.w	#1,wasthereever
	move.b	ieb,oldieb
	move.b	iea,oldiea
	move.b	ima,oldima
	move.l	key_vec,oldkeyvec
	move.l	key_vec,keyt+2
	move.l	#key_handler,key_vec	;put new key stuff in
	and.b	#$df,ieb		;stop 200hz timer
	and.b	#$fe,iea		;stop hblank
	move.l	hbl_vec,oldhblvec
	move.l	#hblhandler3,hbl_vec
	or.b	#1,iea			;enable hblank
	or.b	#1,ima
	move.l	vbl_vec,vblt+2		;set up vbl handler
	move.l	vbl_vec,oldvblvec
	move.l	#vbl_handler,vbl_vec
	rts
setuphbltit:
	move.w	#1,wasthereever
	move.b	ieb,oldieb
	move.b	iea,oldiea
	move.b	ima,oldima
	move.l	key_vec,oldkeyvec
	move.l	key_vec,keyt+2
	move.l	#key_handler,key_vec	;put new key stuff in
	and.b	#$df,ieb		;stop 200hz timer
	and.b	#$fe,iea		;stop hblank
	move.l	hbl_vec,oldhblvec
	move.l	#hblhandlertit,hbl_vec
	or.b	#1,iea			;enable hblank
	or.b	#1,ima
	move.l	vbl_vec,vblt+2		;set up vbl handler
	move.l	vbl_vec,oldvblvec
	move.l	#vbl_handler,vbl_vec
	move.b	#50,hblstart
	rts
hblhandlertit:
	movem.l	d0/a0,-(sp)
	lea	backcolors,a0
	move.w	colorcount,d0
	move.w	(a0,d0.w),$ff8240
	lea	backcolors2,a0
	move.w	(a0,d0.w),$ff8242
	move.b	#0,tbcr
	move.b	#3,tbdr
	move.b	#8,tbcr
	addq.w	#2,colorcount
	cmpi.w	#42,d0
	blt	hblovertit
	move.w	#0,colorcount	
	move.b	#0,tbcr
	move.b	#150,tbdr
	move.b	#8,tbcr
hblovertit:
	bclr	#0,isra
	movem.l	(sp)+,d0/a0
	rte

hblhandler3:
	movem.l	d0/a0,-(sp)
	lea	bluecolors,a0
	move.w	colorcount,d0
	move.w	(a0,d0.w),$ff8240
	move.b	#0,tbcr
	move.b	#1,tbdr
	move.b	#8,tbcr
	addq.w	#2,colorcount
	cmpi.w	#60,d0
	blt	hblover3
	move.w	#0,colorcount	
	move.b	#0,tbcr
	move.b	hblstart2,tbdr
	move.b	#8,tbcr
	move.l	#hblhandler4,hbl_vec
hblover3:
	bclr	#0,isra
	movem.l	(sp)+,d0/a0
	rte

hblhandler1:
	movem.l	d0/a0,-(sp)
	lea	backcolors,a0
	move.w	colorcount,d0
	move.w	(a0,d0.w),$ff8240
	move.b	#0,tbcr
	move.b	#1,tbdr
	move.b	#8,tbcr
	addq.w	#2,colorcount
	cmpi.w	#42,d0
	blt	hblover
	move.w	#0,colorcount	
	move.b	#0,tbcr
	move.b	hblstart2,tbdr
	move.b	#8,tbcr
	move.l	#hblhandler2,hbl_vec
hblover:
	bclr	#0,isra
	movem.l	(sp)+,d0/a0
	rte
hblhandlerfrac:
	movem.l	a0-a1,-(sp)
	lea	palettefrac,a0
	move.l	#$ff8240,a1
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.b	#0,tbcr
	move.b	#100,tbdr
	move.b	#8,tbcr
	move.l	#hblhandlerfracb,hbl_vec
	bclr	#0,isra
	movem.l	(sp)+,a0-a1
	rte
hblhandlerfracb:
	movem.l	a0-a1,-(sp)
	lea	palette2,a0
	move.l	#$ff8242,a1
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.b	#0,tbcr
	move.b	#200,tbdr
	move.b	#8,tbcr
	move.l	#hblhandlerfrac,hbl_vec
	bclr	#0,isra
	movem.l	(sp)+,a0-a1
	rte

hblhandler2:
	movem.l	a0-a1,-(sp)
	lea	palette2,a0
	move.l	#$ff8242,a1
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.b	#0,tbcr
	move.b	#200,tbdr
	move.b	#8,tbcr
	move.l	#hblhandler1,hbl_vec
	bclr	#0,isra
	movem.l	(sp)+,a0-a1
	rte
hblhandler4:
	movem.l	a0-a1,-(sp)
	lea	palette2,a0
	move.l	#$ff8242,a1
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.b	#0,tbcr
	move.b	#200,tbdr
	move.b	#8,tbcr
	move.l	#hblhandler3,hbl_vec
	bclr	#0,isra
	movem.l	(sp)+,a0-a1
	rte

vbl_handler:
	move.w	#0,colorcount
	move.b	#0,tbcr
	move.b	hblstart,tbdr
	move.b	#8,tbcr
vblt:	jmp	$0

dovblcolors:
	move.l	temppal,a0
	move.l	#$ff8240,a1
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	move.w	(a0)+,(a1)+
	rts

key_handler:
	move.w	#$2500,sr
keyt:	jmp	$0

hblstart:	blk.b	1,0
hblstart2:	blk.b	1,0
even
colorcount:	blk.w	1,0
colorcount2:	blk.w	1,0
oldvblvec:	blk.l	1,0
oldkeyvec:	blk.l	1,0
oldhblvec:	blk.l	1,0
oldieb:		blk.b	1,0
oldiea:		blk.b	1,0
oldima:		blk.b	1,0
even
backcolors:
	dc.w	$0001,$0002,$0003,$0004,$0005,$0006,$0007
	dc.w	$0107,$0207,$0307,$0407,$0507,$0607,$0707
	dc.w	$0716,$0725,$0734,$0743,$0752,$0761,$0770
	dc.w	$0223
backcolors2:
	dc.w	$0000,$0001,$0001,$0002,$0005,$0005,$0005
	dc.w	$0005,$0005,$0105,$0205,$0305,$0405,$0505
	dc.w	$0504,$0503,$0512,$0521,$0530,$0540,$0550
	dc.w	$0001
bluecolors:
	dc.w	$0005,$0005,$0005,$0005,$0005,$0005,$0005
	dc.w	$0005,$0004,$0004,$0003,$0002,$0001,$0001
	dc.w	$0001,$0000,$0000,$0000,$0001
	dc.w	$0001,$0001,$0002,$0003,$0004,$0004,$0005
	dc.w	$0005,$0006,$0006,$0006,$0007,$0007,$0007

myreset:
	rts
cxmin:		equ	0
cxmax:		equ	319
cymin:		equ	0
cymax:		equ	99
cbits:	blk.w	1,0
cbits2:	blk.w	1,0
xsav:	blk.w	1,0
ysav:	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
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
	bsr	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:
*	movem.l	d4-d7/a0,-(sp)
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:
	moveq	#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	#14,d3
	neg	d3
	bset	d3,d4
	bsr	putlinein
	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	#14,d3
	neg	d3
	bset	d3,d4
	bsr	putlinein
	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:
	moveq	#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)+,d4-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)+,d4-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)+,d4-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)+,d4-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
*********************************************
pointsf:blk.w	1,1
linesf:	blk.w	1,1
polyf:	blk.w	1,1
**********************************************************
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
	bra	norect
	exg	d4,d2
pr1:
	cmp.w	d0,d6
	bgt	pr2
	bra	norect
	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:
norect:
	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
*************************************************************************
*               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
surfacedfn:	blk.w	1,0	;color
		dc.l	surfacevrt
surfacevrt:	blk.w	1,0	;number
		blk.w	64,0        
forcedfill:	blk.w	1,-1
***************************************************************************
*               DRAW A FILLED POLYGON
*               On entry, a6 = pointer to polygon data
*************************************************************************
draw_polygon:
	tst.w	forcedfill
	bmi	allnormal
	bra	forcedwire
allnormal:
	tst.w	14(a0)		;test for filled or wire frame
	bpl	itisfilled
forcedwire:
	movem.l	d7/a6,-(sp)
	move.w	12(a0),linecolor
	lea	surfacevrt,a6
	move.w	(a6)+,d7
	subq.w	#2,d7
itsalineloop:
	move.w	(a6)+,x1
	move.w	(a6)+,y1
	move.w	(a6),x2
	move.w	2(a6),y2
	bsr	clipit
	dbf	d7,itsalineloop
	movem.l	(sp)+,d7/a6
	rts	
itisfilled:
        movem.l D0-D7/A0-A6,-(SP)       ;Save work registsers
	lea	surfacevrt,a6
	move.w	(a6)+,d7		;get number
	subq.w	#2,d7
	move.w	#-1024,d0		;lowest poss x,y
	move.w	#-1024,d1
getmaxloop:
	cmp.w	(a6)+,d0
	bgt	gm1
	move.w	-2(a6),d0		;becomes new max
gm1:
	cmp.w	(a6)+,d1
	bgt	gm2
	move.w	-2(a6),d1		;becomes new max
gm2:
	dbf	d7,getmaxloop

	lea	surfacevrt,a6
	move.w	(a6)+,d7		;get number
	subq.w	#2,d7
	move.w	#1024,d2		;lowest poss x,y
	move.w	#1024,d3
getminloop:
	cmp.w	(a6)+,d2
	blt	gmm1
	move.w	-2(a6),d2		;becomes new max
gmm1:
	cmp.w	(a6)+,d3
	blt	gmm2
	move.w	-2(a6),d3		;becomes new max
gmm2:
	dbf	d7,getminloop

	tst.w	d0
	bmi	draw_p3
	tst.w	d1
	bmi	draw_p3
	cmpi.w	#319,d2
	bgt	draw_p3
	cmpi.w	#99,d3
	bgt	draw_p3
	lea	surfacedfn,a6

        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  #2,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)
        blt     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	#0,d3
		bge	dhc1
		moveq	#0,d3
dhc1:
		cmpi.w	#319,d4
		ble	dhc2
		move.w	#319,d4
dhc2:
		move.w	d3,d6
		move.w	d5,d7
		bsr	calc_vsa
		cmpi.w	#-1,a6
		beq	draw_hline0
		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
*********************************************************
*	calc virtual screen ad return in a6		*
*********************************************************
calc_vsa:
	tst.w	d7
	bge	cv2
	move.w	#-1,a6
	rts
cv2:
	cmpi.w	#99,d7
	blt	cv4
	move.w	#-1,a6
	rts
cv4:
	and.l	#$ffff,d6
	and.l	#$ffff,d7
	lsl.w	#2,d7         	;mult by 4 for index
	lsr.w	#1,d6           ;x coord / 2
	and.w	#$00f8,d6      	;strip lower 3 bits
	move.l	ytable,a6   	;get y table addr
	move.l	(a6,d7.w),a6 	;got final pixel addr!
	add.w	d6,a6
	rts

	mulu	#160,d7
	asr.w	#4,d6
	asl.w	#3,d6
	add.w	d6,d7
	move.l	hiden,a6
	add.w	d7,a6
	rts


	lsl.w	#2,d7
	lsr.w	#1,d6
	and.w	#$00f8,d6
	move.l	d6,a6
	move.l	a0,-(sp)
	move.l	ytable,a0
	adda.l	(a6,d7.w),a6
	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
********************************
joydir:
	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
	sub.w	#nsamount,myheight
	move.w	#0,xspeed
	rts
neast:	cmpi.b	#9,d0
	bne	east
	sub.w	#nsamount,myheight
	move.w	#minusxamount,xspeed
	rts
east:	cmpi.b	#8,d0
	bne	seast
	move.w	#minusxamount,xspeed
	rts
seast:	cmpi.b	#10,d0
	bne	south
	add.w	#nsamount,myheight
	move.w	#minusxamount,xspeed
	rts
south:	cmpi.b	#2,d0
	bne	swest
	add.w	#nsamount,myheight
	move.w	#0,xspeed
	rts
swest:	cmpi.b	#6,d0
	bne	west
	add.w	#nsamount,myheight
	move.w	#plusxamount,xspeed
	rts
west:	cmpi.b	#4,d0
	bne	nwest
	move.w	#plusxamount,xspeed
	rts
nwest:	cmpi.b	#5,d0
	bne	jdback
	sub.w	#nsamount,myheight
	move.w	#plusxamount,xspeed
	rts
jdback:
	move.w	#0,xspeed
	rts

joydir2:
	tst.b	joyport1
	beq	jdback2
	move.b	joyport1,d0
	btst	#7,d0
	beq	northa2
	move.w	#1,firebutton
	bclr	#7,d0
	bra	north2
northa2:
	move.w	#-1,firebutton
north2:	cmpi.b	#1,d0
	bne	neast2
	sub.w	#nsamount2,myheight
*	move.w	#0,xspeed
	rts
neast2:	cmpi.b	#9,d0
	bne	east2
	sub.w	#nsamount2,myheight
	add.w	#minusxamount2,xspeed
	rts
east2:	cmpi.b	#8,d0
	bne	seast2
	add.w	#minusxamount2,xspeed
	rts
seast2:	cmpi.b	#10,d0
	bne	south2
	add.w	#nsamount2,myheight
	add.w	#minusxamount2,xspeed
	rts
south2:	cmpi.b	#2,d0
	bne	swest2
	add.w	#nsamount2,myheight
*	move.w	#0,xspeed
	rts
swest2:	cmpi.b	#6,d0
	bne	west2
	add.w	#nsamount2,myheight
	add.w	#plusxamount2,xspeed
	rts
west2:	cmpi.b	#4,d0
	bne	nwest2
	add.w	#plusxamount2,xspeed
	rts
nwest2:	cmpi.b	#5,d0
	bne	jdback2
	sub.w	#nsamount2,myheight
	add.w	#plusxamount2,xspeed
	rts
jdback2:
*	move.w	#0,xspeed
	rts


xspeed:		blk.w	1,0
myheight:	blk.w	1,0
minusxamount:	equ	-30
plusxamount:	equ	30
minusxamount2:	equ	-80
plusxamount2:	equ	80
nsamount:	equ	15
nsamount2:	equ	45
minusvel:	blk.w	1,0
plusvel:	blk.w	1,0
firebutton:	blk.w	1,-1
*****************************************
*	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	#$11,-(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)

rs2:	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
****************************************
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	tofillornot
	bra	pause
tofillornot:
	cmpi.w	#$21,d0
	bne	endit
	neg	forcedfill
	bra	keyback
upspeed:
	cmpi.w	#$4e,d0
	bne	downspeed
	add.w	#50,speed
	bra	keyback
downspeed:
	cmpi.w	#$4a,d0
	bne	endit
	sub.w	#50,speed
	bra	keyback
endit:
	cmpi.w	#$0f,d0
	bne	energyp
	tst.w	cheat
	bmi	keyback
	move.w	#1,endoflevel
	move.w	#6,endhits
	move.w	#0,frames
	bra	keyback
energyp:
	cmpi.w	#$12,d0
	bne	sounddir
	neg.w	energyflag
	bra	keyback
sounddir:
	cmpi.w	#$2d,d0
	bne	keyback
	neg.b	xternal
keyback:rts

endoflevel:	blk.w	1,-1
frames:		blk.w	1,0
energyflag:	blk.w	1,-1
*****************************
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
	move.w	#1,cheat
	rts

gkey:
        move.w  #$ff,-(sp)
        move.w  #6,-(sp)
        trap    #1
        addq.l  #4,sp
        tst.l   d0
        beq     gkey
        swap    d0
        rts
cheat:	dc.w	-1
*********************************************************
*	New sprite routine				*
*	New version give ad of sprite structure in A0	*
*********************************************************
putsprite:
	move.w	(a0),d2		;get x
	move.w	d2,d0
	move.w	2(a0),d1	;get y
	and.w	#15,d2		;get last 4 bits=offset
	move.l	hiden,a6
	lsl.w	#5,d1		;*128
	add.w	d1,a6
	lsl.w	#2,d1
	add.w	d1,a6		;=*160 gives line add
	and.w	#$fff0,d0	;word
	lsr.w	#1,d0
	add.w	d0,a6		;a6 has actual screen address

*************CODE TO ROTATE A SPRITE IMAGE***********************
shiftimages:
        move.w  4(a0),d1        ;height in d1
        move.l  10(a0),a1        ;object pointer to a0
	lea	gtemp,a2       ;image pointer to a1
ssi1:
        move.w  6(a0),d0       	;width - 1 = width if count starts at zero
        clr.l   (a2)            ;for each line, the first word of the
        clr.l   4(a2)           ;image must be cleared
ssi0:	
	moveq	#0,d4		;make sure that the top halves of these
	moveq	#0,d5		;registers are zeroed out
	moveq	#0,d6		;registers are zeroed out
	moveq	#0,d7		;registers are zeroed out
        move.w  (a1)+,d4        ;load in one word (four planes)
        move.w  (a1)+,d5        ;to be rotated
        move.w  (a1)+,d6
        move.w  (a1)+,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,(a2)+        ;add low order bits to the high order bits
        or.w    d5,(a2)+        ;stored by move instructions farther
        or.w    d6,(a2)+        ;down in this routine
        or.w    d7,(a2)+
        swap    d4              ;move high order bits into lower halves
        swap    d5              ;of the registers
        swap    d6
        swap    d7
        move.w  d4,(a2)         ;save the high orders bits to be ORed
        move.w  d5,2(a2)        ;in the loop (do not increment a1 because
        move.w  d6,4(a2)        ;the ORs in the loop must function on
        move.w  d7,6(a2)        ;the same addresses as these moves.
        dbf     d0,ssi0          ;repeat width times
        addq.l  #8,a2           ;new line, move to next word( * 4 planes = 8)
        dbf     d1,ssi1          ;repeat height times

smake_mask:
	move.w  4(a0),d1	;height in d1
	lea	gtemp,a1	;image pointer to a0
	lea	gmask,a2	;mask pointer to a1
smm1:
	move.w  6(a0),d0	;width in d0
	addq.w	#1,d0
smm0:	move.w  (a1)+,d2        ;load first plane of bit image in d2
        or.w    (a1)+,d2        ;OR it with the 3 other planes
        or.w    (a1)+,d2
        or.w    (a1)+,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,(a2)+        ;store mask in buffer
        dbf     d0,smm0          ;repeat 'width' times
        dbf     d1,smm1          ;repeat 'height' times

*********code to put sprite on screen********************
sdraw:
	move.w  4(a0),d1	;height to d1
	lea	gtemp,a1	;image pointer to a1
	lea	gmask,a2	;mask pointer to a2
	move.l  a6,a3		;screen buffer pointer to a3
sdi1:	move.w  6(a0),d0	;width to d0
	addq.w	#1,d0
	move.l  a6,a5    	;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,(a5)+        ;copy final image into screen memory
        move.l  d5,(a5)+
        dbf     d0,sdi0		;repeat for 'width' times
        addi.l	#160,a6		;move to next screen line
        add.w  	8(a0),a3
        dbf     d1,sdi1		;repeat 'height' times
	rts
***********************************
printscore:
	tst.b	numsflag
	bmi	noput
	subq.b	#1,numsflag
	move.w	#21944,numwhere
	move.w	score,number
	bsr	prtnum
	rts
noput:
	move.b	#-1,numsflag
	rts

printships:
	tst.b	shipsflag
	bmi	noputs
	subq.b	#1,shipsflag
	move.w	#24504,numwhere
	move.w	level,number
	bsr	prtnum
	move.w	#27064,numwhere
	move.w	getaways,number
	bsr	prtnum
	rts
noputs:
	move.b	#-1,shipsflag
	rts

getaways:	blk.w	1,0
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
**********************************************
clearquick2:
	move.l	hiden,a0
	moveq	#99,d0
	moveq	#0,d7
cl2loop:
	move.l	d7,(a0)+
	move.l	d7,(a0)+
	move.l	d7,(a0)+
	move.l	d7,(a0)+
	move.l	d7,(a0)+
	move.l	d7,(a0)+
	move.l	d7,(a0)+
	move.l	d7,(a0)+
	move.l	d7,(a0)+
	move.l	d7,(a0)+
	move.l	d7,(a0)+
	move.l	d7,(a0)+
	move.l	d7,(a0)+
	move.l	d7,(a0)+
	move.l	d7,(a0)+
	move.l	d7,(a0)+
	move.l	d7,(a0)+
	move.l	d7,(a0)+
	move.l	d7,(a0)+
	move.l	d7,(a0)+
	move.l	d7,(a0)+
	move.l	d7,(a0)+
	move.l	d7,(a0)+
	move.l	d7,(a0)+
	move.l	d7,(a0)+
	move.l	d7,(a0)+
	move.l	d7,(a0)+
	move.l	d7,(a0)+
	move.l	d7,(a0)+
	move.l	d7,(a0)+
	move.l	d7,(a0)+
	move.l	d7,(a0)+
	move.l	d7,(a0)+
	move.l	d7,(a0)+
	move.l	d7,(a0)+
	move.l	d7,(a0)+
	move.l	d7,(a0)+
	move.l	d7,(a0)+
	move.l	d7,(a0)+
	move.l	d7,(a0)+
	dbf	d0,cl2loop
cqback:	rts

getridofhbl:
	tst.w	wasthereever
	bmi	wasno
	move.b	oldieb,ieb
	move.b	oldiea,iea
	move.b	oldima,ima
	move.l	oldkeyvec,key_vec
	move.l	oldhblvec,hbl_vec
	move.l	oldvblvec,vbl_vec
	move.w	#-1,wasthereever
wasno:	rts
wasthereever:	blk.w	1,-1
******************************************
*               RETURN TO GEM
gem:
	move.w	#$0777,$ff8240
	move.w	#$0000,$ff8242
	move.w	#$0000,$ff8244
	move.w	#$0000,$ff8246
*	bsr	oldmfp
	bsr	getridofhbl

	move.w	#0,$452
	move.l	oldvbl1,a0
	move.l	#0,(a0)
	move.w	#1,$452

	jsr	res_mouse
        move.b  #7,$484

        move.w  ressave,-(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
	moveq	#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	#3200,d1
	add.l	#22000,d2
skloop:
	move.l	#$ff8205,a0
	moveq	#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
	cmp.l	d1,d0
	blt.s	skloop
	cmp.l	d2,d0
	bgt.s	skloop

        move.l  seen,A6
        move.l  hiden,seen
        move.l  A6,hiden
	jsr	clearquick2
        move.l  sytable,A6
        move.l  ytable,sytable
        move.l  A6,ytable
df:     move.w  #-1,-(sp)
        move.l  seen,-(sp)
        move.l  hiden,-(sp)
        move.w  #5,-(sp)
        trap    #14
        addi.l  #12,sp  
	bsr	printenergy
        rts
flip_scre:
	move.l	seen,d1
	move.l	d1,d2
	add.l	#3200,d1
	add.l	#22000,d2
skloope:
	move.l	#$ff8205,a0
	moveq	#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
	cmp.l	d1,d0
	blt.s	skloope
	cmp.l	d2,d0
	bgt.s	skloope

        move.l  seen,A6
        move.l  hiden,seen
        move.l  A6,hiden
	jsr	clearquick2
        move.l  sytable,A6
        move.l  ytable,sytable
        move.l  A6,ytable
	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
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

********************************************
* 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!
*move.l	#ytable2,ytable
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
**********************************************
specialplot:
	movem.l	d0-d5/a0-a1,-(sp)
	tst.w	endoflevel
	bpl	nohitv
	cmpi.w	#1000,4(a0)
	bgt	nohitv
	cmpi.w	#0,pixely
	bgt	nohitv
	cmpi.w	#130,pixelx
	blt	nohitv
	cmpi.w	#190,pixelx
	bgt	nohitv
	move.w	#0,endoflevel
	move.w	#20,hitmeflag
nohitv:
	move.w	pixelx,d0      ;x coordinate in D0
	move.w	d0,d3         ;duplicate in D3
	andi.w	#15,d3        ;mask off lower 4 bits
	move.w	pixely,d1      ;get y coordinate,
	cmp.w	#99,d1
	bgt	pltxit
	cmpi.w	#0,d1
	blt	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	(a1,d1.w),a0 	;got final pixel addr!

	move.w #$8000,d4     ;set ON pixel mask
	lsr.w d3,d4          ;shift right D3 times

	btst #0,d2			;set the bit?
	beq pl2				;no!
	or.w d4,(a0)			;turn it on!

pl2:
	btst #1,d2           ;set it?
	beq pl3             ;no!
	or.w d4,2(a0)        ;turn it on!
pl3:
	btst #2,d2           ;set bit?
	beq pl4             ;no!
	or.w d4,4(a0)        ;turn it on!
pl4:
	btst #3,d2           ;set bit?
	beq pl5           ;no, exit.
	or.w d4,6(a0)        ;turn it on!
pl5:
	movem.l	(sp)+,d0-d5/a0-a1
	rts				;bye!


**********************************************
singleplot:
	movem.l	d0-d5/a0-a1,-(sp)
	move.w	pixelx,d0      ;x coordinate in D0
	cmp.w	#319,d0
	bcc	pltxit
	cmpi.w	#0,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,
	cmp.w	#99,d1
	bgt	pltxit
	cmpi.w	#0,d1
	blt	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	(a1,d1.w),a0 ;got final pixel addr!

	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)
	bra	myphere

doubleplot2:
	movem.l	d0-d5/a0-a1,-(sp)
	move.w	pixelx,d0      ;x coordinate in D0
	cmp.w	#191,d0
	bcc	pltxit
	cmpi.w	#128,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,
	cmp.w	#159,d1
	bgt	pltxit
	cmpi.w	#112,d1
	blt	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	(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
*	and.l d5,(a0)        	;turn off old pixel
*	and.l d5,4(a0)       	;(both longwords)
	bra	myphere

**************************************
* PLOT A PIXEL WITH MY ROUTINE       *
*                                    *
* CALL WITH:                         *
* myplot(X,Y,COLOR)                  *
**************************************
doubleplot:
	movem.l	d0-d5/a0-a1,-(sp)
	move.w	pixelx,d0      ;x coordinate in D0
	cmp.w	#319,d0
	bcc	pltxit
	cmpi.w	#0,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,
	cmp.w	#99,d1
	bgt	pltxit
	cmpi.w	#0,d1
	blt	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	(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
*	and.l d5,(a0)        ;turn off old pixel
*	and.l d5,4(a0)       ;(both longwords)
	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)
spec2:
******************************
* Now turn on the new pixel! *
******************************

* BIT 1 *

	btst #0,d2           ;set the bit?
	beq bbit2             ;no!
	or.w d4,(a0)         ;turn it on!

* BIT 2 *

bbit2:
	btst #1,d2           ;set it?
	beq bbit4             ;no!
	or.w d4,2(a0)        ;turn it on!

* BIT 4 *

bbit4:
	btst #2,d2           ;set bit?
	beq bbit8             ;no!
	or.w d4,4(a0)        ;turn it on!

* BIT 8 *

bbit8:
	btst #3,d2           ;set bit?
	beq mysec           ;no, exit.
	or.w d4,6(a0)        ;turn it on!

mysec:
	addq.l	#8,a0
	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)

******************************
*    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! *
******************************

* BIT 1 *

btst #0,d2           ;set the bit?
beq bit2             ;no!
or.w d4,(a0)         ;turn it on!

* BIT 2 *

bit2:
btst #1,d2           ;set it?
beq bit4             ;no!
or.w d4,2(a0)        ;turn it on!

* BIT 4 *

bit4:
btst #2,d2           ;set bit?
beq bit8             ;no!
or.w d4,4(a0)        ;turn it on!

* BIT 8 *

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!

********************************
copyintoboth:
	move.w	#1,dontdlt
        move.l  screen3,a0
        move.l  screen1,a1
        move.w  #4000,d0
cib3:
        move.l  (a0)+,(a1)+
        move.l  (a0)+,(a1)+
        dbf     d0,cib3

        move.l  screen3,a0
        move.l  screen2,a1
        move.w  #4000,d0
cib:
        move.l  (a0)+,(a1)+
        move.l  (a0)+,(a1)+
        dbf     d0,cib
	move.l	#paneldlt,dltmemcount
	move.w	#-1,dontdlt
	rts
**********************routine to print a dec nuber*************
prtnum: 
	move.w	#0,times
        moveq  	#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
        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	#44,d7
	add.w	d7,a0
	moveq	#10,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

prtnum2: 
	move.w	#0,times
        moveq  	#0,d7
        move.w  number,d7
        andi.l  #$ffff,d7
        move.l  #line,a5
dodec2:
	move.l  d7,d6
        divu    #10,d6
        move.w  d6,d7
        swap    d6
        move.b  d6,(a5)+
        cmpi.w  #0,d7
        bne     dodec2
out2:
	cmpa.l  #line,a5
        beq     decback2
        move.b  -(a5),d7
        andi.w  #$ff,d7
	lea	smallnumbers,a0
	mulu	#28,d7
	add.w	d7,a0
	moveq	#6,d0
	move.l	seen,a1
	adda.w	numwhere,a1
oloop2:
	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,oloop2
	addq.w	#1,times
	cmpi.w	#2,times
	blt	oh2
	move.w	#0,times
	addq.w	#6,numwhere
oh2:	addq.w	#1,numwhere
	bra	out2
	rts        
decback2:
	rts

*****************************************
*	print the energy value		*
*****************************************
printenergy:
	tst.w	energyflag
	bmi	noenergyp
	move.w	energy,number
	bge	pen
	move.w	#0,number
pen:	move.w	#24384,numwhere
	bsr	prtnum2
noenergyp:
	rts
************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	screen2,screen3
	subi.l	#$8000,screen3
	move.l	#ytable2,ytable
	move.l	#ytable1,sytable
	move.l	screen3,d0
	subi.l	#207814,d0
	move.l	d0,dltmem
        rts
dltmem:	blk.l	1,0

************change colors****************
docolors:
	move.l temppal,-(sp)
        move.w #6,-(sp)
        trap #14
        addq.l #6,sp
        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          *
*********************************************************
loadscr: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.w	d0,-(sp)
	move.l  #length,-(SP)    ;load it straight onto screen
        move.l  #2,-(SP)    ;length to read in
        move    D0,-(SP)        ;Handle
        move    #$3F,-(SP)      ;bios number
        trap    #1              ;Read file in
        addi.l   #12,SP

	move.w	(sp),d0
	move.l  hiden,-(SP)    ;load it straight onto screen
	moveq	#0,d1
	move.w	length,d1
        move.l  d1,-(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
decomp:
	move.l	hiden,a0
	move.w	(a0)+,d0	;count of loops through
	subq.w	#1,d0
	move.l	screen3,a1
dcloopa:
	move.w	(a0)+,d1
	bmi	dcloopover
	move.l	(a0)+,d2
	move.l	(a0)+,d3
dcloopb:
	move.l	d2,(a1)+
	move.l	d3,(a1)+
	dbf	d1,dcloopb
	bra	dcloopa
dcloopover:
	rts
length:		dc.w	0
*********************************************************
loaddlt:
	move    #0,-(SP)        ;Open file
        move.l  #filedlt,-(SP) ;Address of filename
        move    #$3D,-(SP)
        trap    #1              ;Get handle number in D0
        addq.l  #8,SP
              
        move    D0,-(SP)        ;Save handle
        move    (sp),d0        
               
        move.l  dltmem,-(SP)	;load it straight onto screen
        move.l  #72954,-(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

filedlt:
	dc.b	'title.dlt',0
	even
******************************************************
*********************************************************
loadpan:
	move    #0,-(SP)        ;Open file
        move.l  #filepan,-(SP) ;Address of filename
        move    #$3D,-(SP)
        trap    #1              ;Get handle number in D0
        addq.l  #8,SP
              
        move    D0,-(SP)        ;Save handle
        move    (sp),d0        
               
        move.l  #paneldlt,-(SP)	;load it straight onto screen
        move.l  #16160,-(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

filepan:
	dc.b	'panel.dlt',0
	even

*********************************************************
loadintrosounds:
	move    #0,-(SP)        ;Open file
        move.l  #fileisound,-(SP) ;Address of filename
        move    #$3D,-(SP)
        trap    #1              ;Get handle number in D0
        addq.l  #8,SP
              
        move    D0,-(SP)        ;Save handle
        move    (sp),d0        
               
	move.l	dltmem,d7
	add.l	#77280,d7
        move.l  d7,-(SP)	;load it straight onto screen
        move.l  #90407,-(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
fileisound:
	dc.b	'combined.spl',0
	even
*********************************************************
loadmusic:
	move    #0,-(SP)        ;Open file
        move.l  #filemusic,-(SP) ;Address of filename
        move    #$3D,-(SP)
        trap    #1              ;Get handle number in D0
        addq.l  #8,SP
              
        move    D0,-(SP)        ;Save handle
        move    (sp),d0        
               
	move.l	dltmem,d7
	add.l	#77280,d7
	add.l	#53609,d7
        move.l  d7,-(SP)	;load it straight onto screen
        move.l  #76924,-(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
filemusic:
	dc.b	'music.spl',0
	even
*******************blocks for rotated sprites*************
gtemp:		blk.w	3000,0
gmask:		blk.w	3000,0
screen3:	blk.l   1,0
screen: 	blk.l   1
screen2:	blk.l   1
screen1:	blk.l   1
dummy:  	blk.l   32
filename:       blk.l	1,0
filetwi:	dc.b	'twi2.cmp',0  
even
line:		blk.b   10
number: 	blk.w   1
even
ships:		blk.w	1,0
seen:   	blk.l   1
hiden:  	blk.l   1
rnd:            blk.l   2,0
score:          blk.w   1,0
level:          blk.w   1,0
blackpal:
	dc.w	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
endpal:
	dc.w	$0001,$0077,$0055,$0033,$0507,$0304,$0007,$0077
	dc.w	$0055,$0033,$0770,$0077,$0040,$0005,$0003,$0112
palette1:
	dc.w	$0001,$0677,$0455,$0233,$0507,$0304,$0007,$0077
	dc.w	$0055,$0033,$0740,$0070,$0040,$0005,$0003,$0112
palette3:
	dc.w	$0005,$0077,$0055,$0033,$0022,$0305,$0740,$0700
	dc.w	$0500,$0300,$0103,$0070,$0040,$0520,$0310,$0005
palette4:
	dc.w	$0005,$0077,$0055,$0033,$0407,$0305,$0740,$0700
	dc.w	$0500,$0300,$0103,$0070,$0040,$0520,$0310,$0005
palettefrac:
	dc.w	$0000,$0077,$0066,$0055,$0044,$0033,$0022,$0011
	dc.w	$0500,$0300,$0103,$0070,$0040,$0520,$0310,$0005
palette2:
	dc.w	$0777,$0666,$0555,$0444,$0333,$0222,$0421
	dc.w	$0642,$0407,$0007,$0005,$0070,$0077,$0044,$0121
titlepalette:
	dc.w	$0111,$0000,$0077,$0077,$0066,$0055,$0033,$0347
	dc.w	$0457,$0557,$0667,$0310,$0420,$0531,$0642,$0754
twi1pal:
	dc.w	$0111,$0000,$0007,$0006,$0005,$0004,$0003,$0002
	dc.w	$0777,$0557,$0667,$0310,$0420,$0531,$0642,$0754
twi2pal:
	dc.w	$0000,$0000,$0007,$0006,$0005,$0004,$0003,$0002
	dc.w	$0223,$0077,$0066,$0055,$0044,$0033,$0022,$0754
temppal:
	blk.l	1,0

paneldlt:	blk.b	16160,0

radar:
	 dc.w	$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF
	 dc.w	$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF
	 dc.w	$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF
	 dc.w	$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF
	 dc.w	$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF
	 dc.w	$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF
	 dc.w	$EEEE,$EEEE,$FFFF,$EEEE,$EEEE,$EEEE,$FFFF,$EEEE
	 dc.w	$EEEE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$FFFF,$0000,$FE00,$7E00,$8000,$0000
	 dc.w	$0001,$2001,$3F82,$0000,$FFF0,$FBFF,$0400,$0000
	 dc.w	$0000,$8002,$0003,$0000,$1FC0,$2FC0,$F03F,$0000
	 dc.w	$0000,$0000,$FFFF,$0000,$03F0,$0000,$FFF0,$0000
	 dc.w	$0003,$0003,$0003,$0000,$F8FF,$FFFF,$FFFF,$0000
	 dc.w	$31FF,$FFFF,$FFFF,$0000,$8100,$C100,$FE00,$0000
	 dc.w	$7803,$4607,$7F04,$0000,$100E,$120F,$E3F0,$0000
	 dc.w	$0004,$0007,$0007,$0000,$4483,$E4FC,$FB7F,$0000
	 dc.w	$00E0,$FF1F,$FFFF,$0000,$07E0,$F7C0,$FFE0,$0000
	 dc.w	$0007,$0007,$0007,$0000,$E3FF,$FFFF,$FFFF,$0000
	 dc.w	$3AFF,$FFFF,$FFFF,$0000,$C080,$E080,$FF00,$0000
	 dc.w	$8803,$F40B,$FE0C,$0000,$2004,$2106,$C1F8,$0000
	 dc.w	$0008,$000F,$000F,$0000,$8D00,$CDFF,$F2FF,$0000
	 dc.w	$8380,$7C7F,$FFFF,$0000,$0FC0,$EF80,$FFC0,$0000
	 dc.w	$03FF,$000F,$000F,$0000,$FFFF,$FFFF,$FFFF,$0000
	 dc.w	$77FF,$FFFF,$FFFF,$0000,$E07F,$F041,$FF81,$0000
	 dc.w	$0BE1,$F011,$FC1E,$0000,$7F02,$4082,$81FC,$0000
	 dc.w	$07FF,$001F,$001F,$0000,$0FFD,$8FFE,$F1FF,$0000
	 dc.w	$CFFF,$3FFF,$FFFF,$0000,$DF80,$FF80,$FF80,$0000
	 dc.w	$07FF,$0000,$0000,$0000,$FFFF,$0007,$0007,$0000
	 dc.w	$7FFE,$E07E,$F07F,$0000,$003E,$0823,$0FC3,$0000
	 dc.w	$07C0,$F020,$F83F,$0000,$FE8F,$804F,$03F0,$0000
	 dc.w	$0FFE,$0001,$0001,$0000,$0FFB,$0C0C,$F00F,$0000
	 dc.w	$5FFF,$80FC,$E0FE,$0000,$C000,$0000,$0000,$0000
	 dc.w	$0FFF,$0000,$0000,$0000,$FFFF,$000F,$000F,$0000
	 dc.w	$FF81,$C0FC,$E0FE,$0000,$0018,$0417,$07E7,$0000
	 dc.w	$0F81,$E041,$F07E,$0000,$FF58,$0338,$04E7,$0000
	 dc.w	$9FFC,$8002,$0003,$0000,$0FF6,$0819,$F01F,$0000
	 dc.w	$3FE7,$81F8,$C1FC,$0000,$8000,$0000,$0000,$0000
	 dc.w	$1FFF,$0000,$0000,$0000,$FFFF,$001F,$001F,$0000
	 dc.w	$FFE3,$8118,$C1FC,$0000,$81E8,$03EF,$0217,$0000
	 dc.w	$1F03,$C082,$E0FC,$0000,$FF88,$0798,$0877,$0000
	 dc.w	$7FF8,$4004,$8007,$0000,$1FE0,$103F,$E03F,$0000
	 dc.w	$7F1F,$03F0,$83F8,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0FEF,$003F,$003F,$0000
	 dc.w	$FFB7,$0240,$83F8,$0000,$C6FC,$01FF,$0103,$0000
	 dc.w	$3E87,$8184,$C178,$0000,$FF80,$0FC8,$100F,$0000
	 dc.w	$23F0,$2008,$C00F,$0000,$3FC0,$207E,$C07F,$0000
	 dc.w	$FCF0,$07E0,$07F0,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$1FC7,$007E,$007F,$0000
	 dc.w	$FC2F,$07C0,$07F0,$0000,$EF0E,$008F,$00F1,$0000
	 dc.w	$7CCF,$02C8,$8330,$0000,$EF00,$1F84,$2007,$0000
	 dc.w	$37E8,$3018,$C017,$0000,$7F81,$40FC,$80FE,$0000
	 dc.w	$FEE0,$0FC0,$0FE0,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$3FE1,$00FC,$00FE,$0000
	 dc.w	$F807,$0FC0,$0FE0,$0000,$FF83,$0043,$007C,$0000
	 dc.w	$F9FF,$05F0,$0600,$0000,$E680,$3F02,$4003,$0000
	 dc.w	$2FCC,$282C,$D033,$0000,$FF83,$8178,$01FC,$0000
	 dc.w	$FE40,$1F80,$1FC0,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$7F0F,$01F8,$01FC,$0000
	 dc.w	$F003,$1F80,$1FC0,$0000,$FFC0,$00E0,$00FF,$0000
	 dc.w	$F03F,$8820,$0FC0,$0000,$CDC0,$7E01,$8001,$0000
	 dc.w	$2787,$2447,$D878,$0000,$FE87,$0370,$03F8,$0000
	 dc.w	$FF80,$3F00,$3F80,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$FE7F,$03F0,$03F8,$0000
	 dc.w	$E401,$3B00,$3F80,$0000,$FF60,$01F0,$01FF,$0000
	 dc.w	$607F,$5040,$9F81,$0000,$CBE0,$FC00,$0000,$0000
	 dc.w	$3F1B,$BE9A,$C0E4,$0000,$FD8F,$0660,$07F0,$0000
	 dc.w	$EF00,$7E00,$7F00,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0001,$0000,$0000,$0000,$FFFF,$07E0,$07F0,$0000
	 dc.w	$CC00,$7200,$7F00,$0000,$FE30,$03F8,$03FF,$0000
	 dc.w	$00FF,$0081,$FF02,$0000,$D7F0,$F800,$0000,$0000
	 dc.w	$1117,$5014,$6FE8,$0000,$F91F,$0EC0,$0FE0,$0000
	 dc.w	$EFFF,$FC00,$FFFF,$0000,$E000,$0000,$E000,$0000
	 dc.w	$0003,$0000,$0000,$0000,$FBFF,$0FC0,$0FE0,$0000
	 dc.w	$F801,$8400,$FE00,$0000,$FE08,$05F4,$07F7,$0000
	 dc.w	$07FF,$0703,$F804,$0000,$83F8,$F000,$0000,$0000
	 dc.w	$D03F,$3038,$2FC0,$0000,$F1BF,$1E01,$1FC1,$0000
	 dc.w	$E7E7,$FFFF,$FFFF,$0000,$4000,$8000,$C000,$0000
	 dc.w	$0007,$0000,$0000,$0000,$F0FF,$1F81,$1FC1,$0000
	 dc.w	$E003,$1800,$FC00,$0000,$FA1C,$0DC2,$0FE3,$0000
	 dc.w	$07FF,$0607,$F808,$0000,$C1FD,$E000,$0000,$0000
	 dc.w	$E03F,$1030,$1FC0,$0000,$E17F,$3E03,$3F83,$0000
	 dc.w	$F3EF,$FFFF,$FFFF,$0000,$8000,$0000,$8000,$0000
	 dc.w	$000F,$0000,$0000,$0000,$FCFE,$3F03,$3F83,$0000
	 dc.w	$0047,$F060,$F860,$0000,$F63E,$1981,$1FC1,$0000
	 dc.w	$07FF,$040F,$F810,$0000,$80FF,$C000,$0000,$0000
	 dc.w	$F03F,$0820,$0FC0,$0000,$C2FF,$7C07,$7F07,$0000
	 dc.w	$FFFF,$FFFF,$FFFF,$0000,$0000,$0000,$0000,$0000
	 dc.w	$001F,$0000,$0000,$0000,$FCFC,$7E07,$7F07,$0000
	 dc.w	$038F,$E3E0,$F3F0,$0000,$E6FD,$3903,$3F82,$0000
	 dc.w	$0FFF,$081F,$F020,$0000,$007F,$8000,$0000,$0000
	 dc.w	$E07F,$1040,$1F80,$0000,$8DFE,$F00F,$FE0F,$0000
	 dc.w	$3F80,$C000,$E000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$003F,$0000,$0000,$0000,$FDFC,$FC0B,$FE0F,$0000
	 dc.w	$1C87,$DF70,$FFF8,$0000,$C2FB,$7C07,$7F04,$0000
	 dc.w	$1FFE,$103F,$E040,$0000,$003F,$0000,$0000,$0000
	 dc.w	$C0FF,$2081,$3F01,$0000,$FBF0,$001F,$FC1F,$0000
	 dc.w	$7F00,$8000,$C000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$007F,$0001,$0001,$0000,$FFFC,$F813,$FC1F,$0000
	 dc.w	$38FB,$E700,$FFFC,$0000,$81F3,$FC0B,$FE0C,$0000
	 dc.w	$3FFC,$207F,$C080,$0000,$0000,$FFFF,$0000,$0000
	 dc.w	$01FE,$4103,$FE03,$0000,$C7FF,$303F,$F83F,$0000
	 dc.w	$FE00,$0000,$8000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$00FF,$0003,$0003,$0000,$FFE1,$F03E,$F83F,$0000
	 dc.w	$F021,$0FDD,$FFFF,$0000,$3BE1,$C011,$FC1E,$0000
	 dc.w	$FFFE,$C0FF,$0100,$0000,$7FF8,$FFFE,$0001,$0000
	 dc.w	$03FD,$8206,$FC07,$0000,$8FCF,$607E,$F07F,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$01FF,$0007,$0007,$0000,$BFC3,$E07C,$F07F,$0000
	 dc.w	$3002,$CFFD,$FFFF,$0000,$37C7,$C027,$F838,$0000
	 dc.w	$FE78,$81FF,$0200,$0000,$FFFC,$FFFD,$0003,$0000
	 dc.w	$7FF9,$7C0E,$800F,$0000,$1FF6,$C0FC,$E0FE,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$03FF,$000F,$000F,$0000,$3F86,$C0F9,$E0FF,$0000
	 dc.w	$1F03,$E7FC,$FFFF,$0000,$EFBD,$007D,$F042,$0000
	 dc.w	$FF41,$03FF,$0400,$0000,$F3F8,$FFFA,$0007,$0000
	 dc.w	$5FFE,$5811,$A01F,$0000,$3FFF,$81F8,$C1FF,$0000
	 dc.w	$FFF8,$0000,$FFF8,$0000,$0000,$0000,$0000,$0000
	 dc.w	$07FE,$001F,$001F,$0000,$3F0C,$81F3,$C1FF,$0000
	 dc.w	$7F9B,$F8E4,$F8FF,$0000,$9F03,$4082,$E0FC,$0000
	 dc.w	$FF1F,$07FF,$0800,$0000,$F8F0,$FFF4,$000F,$0000
	 dc.w	$DFF8,$D027,$203F,$0000,$7FFB,$03FF,$83FF,$0000
	 dc.w	$FDD0,$FFE0,$FFF0,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0FFC,$003F,$003F,$0000,$7E3F,$03C7,$83FF,$0000
	 dc.w	$FFFC,$8043,$807F,$0000,$3E07,$8104,$C1F8,$0000
	 dc.w	$FF9F,$0FFF,$1000,$0000,$F807,$FFEF,$0018,$0000
	 dc.w	$BFC0,$A07E,$407F,$0000,$FFE7,$07FF,$07FF,$0000
	 dc.w	$F9E0,$FFC0,$FFE0,$0000,$0000,$0000,$0000,$0000
	 dc.w	$1FFF,$007F,$007F,$0000,$FFFF,$07F8,$07F8,$0000
	 dc.w	$FFFF,$003F,$003F,$0000,$7C0F,$8208,$83F0,$0000
	 dc.w	$FFFF,$0000,$3FFF,$0000,$FFEC,$001C,$FFF3,$0000
	 dc.w	$7FFD,$40FE,$80FE,$0000,$FFFF,$0FFF,$0FFF,$0000
	 dc.w	$FFC0,$FFC0,$FFC0,$0000,$0000,$0000,$0000,$0000
	 dc.w	$3F83,$0000,$0000,$0000,$FFF1,$0000,$0000,$0000
	 dc.w	$FFC1,$0000,$0000,$0000,$F83F,$0430,$07C0,$0000
	 dc.w	$FFFF,$0000,$0000,$0000,$FFC0,$0020,$003F,$0000
	 dc.w	$FF07,$8000,$0000,$0000,$FFFF,$0000,$0000,$0000
	 dc.w	$E000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$7F07,$0000,$0000,$0000,$FF00,$0000,$0000,$0000
	 dc.w	$FF83,$0000,$0000,$0000,$F07F,$0860,$0F80,$0000
	 dc.w	$FFFF,$0000,$0000,$0000,$FF81,$0041,$007E,$0000
	 dc.w	$FE0F,$0000,$0000,$0000,$FFFF,$0000,$0000,$0000
	 dc.w	$C000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$FE0F,$0000,$0000,$0000,$F000,$0000,$0000,$0000
	 dc.w	$7F07,$0000,$0000,$0000,$E0FF,$10C0,$1F00,$0000
	 dc.w	$FFFF,$0000,$0000,$0000,$FF03,$0082,$00FC,$0000
	 dc.w	$FC1F,$0000,$0000,$0000,$FFFF,$0000,$0000,$0000
	 dc.w	$8000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
	 dc.w	$000F,$0000,$0000,$0000,$C780,$2780,$3800,$0000
	 dc.w	$0000,$0000,$0000,$0000,$7E24,$0124,$01D8,$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	$001F,$0000,$0000,$0000,$8100,$4100,$7E00,$0000
	 dc.w	$0000,$0000,$0000,$0000,$FC28,$0228,$03D0,$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	$003F,$0000,$0000,$0000,$0200,$8200,$FC00,$0000
	 dc.w	$0001,$0000,$0000,$0000,$F870,$0470,$0780,$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	$007E,$0001,$0001,$0000,$0400,$0400,$F800,$0000
	 dc.w	$0003,$0000,$0000,$0000,$F060,$0860,$0F80,$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	$00FD,$0003,$0002,$0000,$0800,$0800,$F000,$0000
	 dc.w	$0007,$0000,$0000,$0000,$E040,$1040,$1F80,$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	$01F9,$0005,$0006,$0000,$1000,$1000,$E000,$0000
	 dc.w	$000F,$0000,$0000,$0000,$D080,$3080,$2F00,$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	$03F3,$000B,$000C,$0000,$A000,$A000,$4000,$0000
	 dc.w	$001F,$0000,$0000,$0000,$9100,$5100,$6E00,$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	$07E4,$0014,$001B,$0000,$C000,$C000,$0000,$0000
	 dc.w	$003F,$0000,$0000,$0000,$3200,$B200,$CC00,$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	$0FDC,$003C,$0023,$0000,$8000,$8000,$0000,$0000
	 dc.w	$007E,$0001,$0001,$0000,$2400,$2400,$D800,$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	$1F91,$0051,$006E,$0000,$0000,$0000,$0000,$0000
	 dc.w	$00FC,$0002,$0003,$0000,$7800,$7800,$8000,$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	$3F02,$0082,$00FC,$0000,$0000,$0000,$0000,$0000
	 dc.w	$01F8,$0004,$0007,$0000,$D000,$D000,$2000,$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	$7E04,$0104,$01F8,$0000,$0000,$0000,$0000,$0000
	 dc.w	$03F1,$0009,$000E,$0000,$A000,$A000,$4000,$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	$FC08,$0208,$03F0,$0000,$0000,$0000,$0000,$0000
	 dc.w	$07E3,$0013,$001C,$0000,$4000,$4000,$8000,$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,$0001,$0000,$0000,$0000
	 dc.w	$F810,$0410,$07E0,$0000,$0000,$0000,$0000,$0000
	 dc.w	$0FDE,$003E,$0021,$0000,$8000,$8000,$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,$0003,$0000,$0000,$0000
	 dc.w	$F7A0,$0FA0,$0840,$0000,$0000,$0000,$0000,$0000
	 dc.w	$1FB1,$0071,$004E,$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,$0007,$0000,$0000,$0000
	 dc.w	$E340,$1340,$1C80,$0000,$0000,$0000,$0000,$0000
	 dc.w	$3F02,$0082,$00FC,$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,$000F,$0000,$0000,$0000
	 dc.w	$C080,$2080,$3F00,$0000,$0000,$0000,$0000,$0000
	 dc.w	$7E0C,$010C,$01F0,$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,$001F,$0000,$0000,$0000
	 dc.w	$8100,$7E00,$7F00,$0000,$0000,$0000,$0000,$0000
	 dc.w	$FC08,$03F0,$03F8,$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,$003F,$0000,$0000,$0000
	 dc.w	$8000,$0000,$0000,$0000,$0001,$0000,$0000,$0000
	 dc.w	$FC00,$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,$007F,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0003,$0000,$0000,$0000
	 dc.w	$F800,$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,$00FE,$0000,$0000,$0000
	 dc.w	$0000,$0000,$0000,$0000,$0007,$0000,$0000,$0000
	 dc.w	$F000,$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


	EVEN
SND_OUT:
	dc.w	$80c,$90b,$a09,0,$80c,$90b,$a09,0
	dc.w	$80d,$908,$a08,0,$80b,$90b,$a0b,0
	dc.w	$80d,$909,$a05,0,$80c,$90b,$a08,0
	dc.w	$80d,$909,$a02,0,$80d,$908,$a06,0
	dc.w	$80c,$90b,$a07,0,$80d,$907,$a07,0
	dc.w	$80c,$90b,$a06,0,$80c,$90a,$a09,0
	dc.w	$80b,$90b,$a0a,0,$80c,$90b,$a02,0
	dc.w	$80c,$90b,$a00,0,$80c,$90a,$a08,0

	dc.w	$80d,$906,$a04,0,$80d,$905,$a05,0
	dc.w	$80d,$905,$a04,0,$80c,$909,$a09,0
	dc.w	$80d,$904,$a03,0,$80b,$90b,$a09,0
	dc.w	$80c,$90a,$a05,0,$80b,$90a,$a0a,0
	dc.w	$80c,$909,$a08,0,$80b,$90b,$a08,0
	dc.w	$80c,$90a,$a00,0,$80c,$90a,$a00,0
	dc.w	$80c,$909,$a07,0,$80b,$90b,$a07,0
	dc.w	$80c,$909,$a06,0,$80b,$90b,$a06,0

	dc.w	$80b,$90a,$a09,0,$80b,$90b,$a05,0
	dc.w	$80a,$90a,$a0a,0,$80b,$90b,$a02,0
	dc.w	$80b,$90a,$a08,0,$80c,$907,$a07,0
	dc.w	$80c,$908,$a04,0,$80c,$907,$a06,0
	dc.w	$80b,$909,$a09,0,$80c,$906,$a06,0
	dc.w	$80a,$90a,$a09,0,$80c,$907,$a03,0
	dc.w	$80b,$90a,$a05,0,$80b,$909,$a08,0
	dc.w	$80b,$90a,$a03,0,$80a,$90a,$a08,0

	dc.w	$80b,$90a,$a00,0,$80b,$909,$a07,0
	dc.w	$80b,$908,$a08,0,$80a,$90a,$a07,0
	dc.w	$80a,$909,$a09,0,$80c,$901,$a01,0
	dc.w	$80a,$90a,$a06,0,$80b,$908,$a07,0
	dc.w	$80a,$90a,$a05,0,$80a,$909,$a08,0
	dc.w	$80a,$90a,$a02,0,$80a,$90a,$a01,0
	dc.w	$80a,$90a,$a00,0,$809,$909,$a09,0
	dc.w	$80a,$908,$a08,0,$80b,$908,$a01,0

	dc.w	$80a,$909,$a06,0,$80b,$907,$a04,0
	dc.w	$80a,$909,$a05,0,$809,$909,$a08,0
	dc.w	$80a,$909,$a03,0,$80a,$908,$a06,0
	dc.w	$80a,$909,$a00,0,$809,$909,$a07,0
	dc.w	$809,$908,$a08,0,$80a,$908,$a04,0
	dc.w	$809,$909,$a06,0,$80a,$908,$a01,0
	dc.w	$809,$909,$a05,0,$809,$908,$a07,0
	dc.w	$808,$908,$a08,0,$809,$909,$a02,0

	dc.w	$809,$908,$a06,0,$809,$909,$a00,0
	dc.w	$809,$907,$a07,0,$808,$908,$a07,0
	dc.w	$809,$907,$a06,0,$809,$908,$a02,0
	dc.w	$808,$908,$a06,0,$809,$906,$a06,0
	dc.w	$808,$907,$a07,0,$808,$908,$a04,0
	dc.w	$808,$907,$a06,0,$808,$908,$a02,0
	dc.w	$807,$907,$a07,0,$808,$906,$a06,0
	dc.w	$808,$907,$a04,0,$807,$907,$a06,0

	dc.w	$808,$906,$a05,0,$808,$906,$a04,0
	dc.w	$807,$906,$a06,0,$807,$907,$a04,0
	dc.w	$808,$905,$a04,0,$806,$906,$a06,0
	dc.w	$807,$906,$a04,0,$807,$905,$a05,0
	dc.w	$806,$906,$a05,0,$806,$906,$a04,0
	dc.w	$806,$905,$a05,0,$806,$906,$a02,0
	dc.w	$806,$905,$a04,0,$805,$905,$a05,0
	dc.w	$806,$905,$a02,0,$805,$905,$a04,0

	dc.w	$805,$904,$a04,0,$805,$905,$a02,0
	dc.w	$804,$904,$a04,0,$804,$904,$a03,0
	dc.w	$804,$904,$a02,0,$804,$903,$a03,0
	dc.w	$803,$903,$a03,0,$803,$903,$a02,0
	dc.w	$803,$902,$a02,0,$802,$902,$a02,0
	dc.w	$802,$902,$a01,0,$801,$901,$a01,0
	dc.w	$802,$901,$a00,0,$801,$901,$a00,0
	dc.w	$801,$900,$a00,0,$800,$900,$a00,0

	dc.w	$80e,$90d,$a0c,0,$80f,$903,$a00,0
	dc.w	$80f,$903,$a00,0,$80f,$903,$a00,0
	dc.w	$80f,$903,$a00,0,$80f,$903,$a00,0
	dc.w	$80f,$903,$a00,0,$80e,$90d,$a0b,0
	dc.w	$80e,$90d,$a0b,0,$80e,$90d,$a0b,0
	dc.w	$80e,$90d,$a0b,0,$80e,$90d,$a0b,0
	dc.w	$80e,$90d,$a0b,0,$80e,$90d,$a0b,0
	dc.w	$80e,$90d,$a0a,0,$80e,$90d,$a0a,0

	dc.w	$80e,$90d,$a0a,0,$80e,$90d,$a0a,0
	dc.w	$80e,$90c,$a0c,0,$80e,$90d,$a00,0
	dc.w	$80d,$90d,$a0d,0,$80d,$90d,$a0d,0
	dc.w	$80d,$90d,$a0d,0,$80d,$90d,$a0d,0
	dc.w	$80d,$90d,$a0d,0,$80d,$90d,$a0d,0
	dc.w	$80e,$90c,$a0b,0,$80e,$90c,$a0b,0
	dc.w	$80e,$90c,$a0b,0,$80e,$90c,$a0b,0
	dc.w	$80e,$90c,$a0b,0,$80e,$90c,$a0b,0

	dc.w	$80e,$90c,$a0b,0,$80e,$90c,$a0b,0
	dc.w	$80e,$90c,$a0a,0,$80e,$90c,$a0a,0
	dc.w	$80e,$90c,$a0a,0,$80e,$90c,$a0a,0
	dc.w	$80d,$90d,$a0c,0,$80d,$90d,$a0c,0
	dc.w	$80e,$90c,$a09,0,$80e,$90c,$a09,0
	dc.w	$80e,$90c,$a05,0,$80e,$90c,$a00,0
	dc.w	$80e,$90c,$a00,0,$80e,$90b,$a0b,0
	dc.w	$80e,$90b,$a0b,0,$80e,$90b,$a0b,0

	dc.w	$80e,$90b,$a0b,0,$80e,$90b,$a0a,0
	dc.w	$80e,$90b,$a0a,0,$80e,$90b,$a0a,0
	dc.w	$80d,$90d,$a0b,0,$80d,$90d,$a0b,0
	dc.w	$80d,$90d,$a0b,0,$80e,$90b,$a09,0
	dc.w	$80e,$90b,$a09,0,$80e,$90b,$a09,0
	dc.w	$80d,$90c,$a0c,0,$80d,$90d,$a0a,0
	dc.w	$80e,$90b,$a07,0,$80e,$90b,$a00,0
	dc.w	$80e,$90b,$a00,0,$80d,$90d,$a09,0

	dc.w	$80d,$90d,$a09,0,$80e,$90a,$a09,0
	dc.w	$80d,$90d,$a08,0,$80d,$90d,$a07,0
	dc.w	$80d,$90d,$a04,0,$80d,$90d,$a00,0
	dc.w	$80e,$90a,$a04,0,$80e,$909,$a09,0
	dc.w	$80e,$909,$a09,0,$80d,$90c,$a0b,0
	dc.w	$80e,$909,$a08,0,$80e,$909,$a08,0
	dc.w	$80e,$909,$a07,0,$80e,$908,$a08,0
	dc.w	$80e,$909,$a01,0,$80c,$90c,$a0c,0

	dc.w	$80d,$90c,$a0a,0,$80e,$908,$a06,0
	dc.w	$80e,$907,$a07,0,$80e,$908,$a00,0
	dc.w	$80e,$907,$a05,0,$80e,$906,$a06,0
	dc.w	$80d,$90c,$a09,0,$80e,$905,$a05,0
	dc.w	$80e,$904,$a04,0,$80d,$90c,$a08,0
	dc.w	$80d,$90b,$a0b,0,$80e,$900,$a00,0
	dc.w	$80d,$90c,$a06,0,$80d,$90c,$a05,0
	dc.w	$80d,$90c,$a02,0,$80c,$90c,$a0b,0

	dc.w	$80c,$90c,$a0b,0,$80d,$90b,$a0a,0
	dc.w	$80d,$90b,$a0a,0,$80d,$90b,$a0a,0
	dc.w	$80d,$90b,$a0a,0,$80c,$90c,$a0a,0
	dc.w	$80c,$90c,$a0a,0,$80c,$90c,$a0a,0
	dc.w	$80d,$90b,$a09,0,$80d,$90b,$a09,0
	dc.w	$80d,$90a,$a0a,0,$80d,$90a,$a0a,0
	dc.w	$80d,$90a,$a0a,0,$80c,$90c,$a09,0
	dc.w	$80c,$90c,$a09,0,$80c,$90c,$a09,0

	dc.w	$80d,$90b,$a06,0,$80c,$90b,$a0b,0
	dc.w	$80c,$90c,$a08,0,$80d,$90b,$a00,0
	dc.w	$80d,$90b,$a00,0,$80c,$90c,$a07,0
	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