xamount:	equ	1
zamount:	equ	1
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	350
velocity:	equ	10
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	putrout
        jsr     getscrn
	jsr	plotinit
        jsr     linea
        move.w  #10,d0
        jsr     randomseed
*	bsr	prestuff
	lea	myvbl,a0
	jsr	putvbl
	move.l	a1,oldvbl1
	move.w	#10,linecolor
	move.l	#palette1,temppal
	bsr	docolors
	move.l	#filediscs,filename
	bsr	loadscr
	bsr	copyintoboth
	bsr	maketable
	move.w	#1199,mmax	;1199
	move.w	#0,mmin
	move.w	#6,mmax2	;3
	move.w	#0,mmin2	;3
	move.w	#3,my
	move.w	#0,mymanx
	move.w	#80,mymany
	move.w	#275,mymanz
	move.w	#150,mx
main:
	addq.w	#1,fcount
*	bsr	joydir
	bsr	printscore
	bsr	dosquare
	bsr	drawsquare
	bsr	drawcursor
	bsr	discs
	bsr	domyman
	bsr	flip2
	bsr	stopdisc
	bsr	keyboard
	bra	main
*	move.w	#$0777,$ff8240
*	bra	gem
	
stopdisc:
	cmpi.w	#2,buttondat
	bne	stdb
	lea	mydisc1,a0
	move.w	#-1,(a0)
	lea	mydisc2,a0
	move.w	#-1,(a0)
	lea	mydisc3,a0
	move.w	#-1,(a0)
stdb:
	rts

drawcursor:
	move.w	#13,linecolor
	move.l	#cursortable,a0
	move.w	mx,d0
	asl.w	#3,d0			;mult by 8
	move.w	(a0,d0.w),d1		;x
	move.w	2(a0,d0.w),d2		;y
	move.w	4(a0,d0.w),d3		;z
	move.w	6(a0,d0.w),d4		;flag
	move.w	d4,cursorflag
	cmpi.w	#1,d4
	beq	dc2
	move.l	#cursordef1,a0
	move.w	d1,(a0)
	lea	squaredef,a1
	move.w	2(a1),2(a0)
	move.w	d3,4(a0)
	bsr	calculator
	move.l	#cursordef1,a0
	move.l	8(a0),a0
drawcloop1:
	move.w	(a0),x1
	move.w	2(a0),y1
	move.w	8(a0),x2
	move.w	10(a0),y2
	bsr	clipit
	move.w	4(a0),x1
	move.w	6(a0),y1
	move.w	12(a0),x2
	move.w	14(a0),y2
	bsr	clipit
	rts
dc2:
	move.l	#cursordef2,a0
	move.w	d1,(a0)
	lea	squaredef,a1
	move.w	2(a1),2(a0)
	move.w	d3,4(a0)
	bsr	calculator
	move.l	#cursordef2,a0
	move.l	8(a0),a0
drawcloop2:
	move.w	(a0),x1
	move.w	2(a0),y1
	move.w	8(a0),x2
	move.w	10(a0),y2
	bsr	clipit
	move.w	4(a0),x1
	move.w	6(a0),y1
	move.w	12(a0),x2
	move.w	14(a0),y2
	bsr	clipit
	rts

drawsquare:
	move.w	#4,linecolor
	lea	squaredef,a0
	move.l	8(a0),a0
drawsloop:
	move.w	(a0),x1
	move.w	2(a0),y1
	move.w	4(a0),x2
	move.w	6(a0),y2
	bsr	clipit
	move.w	4(a0),x1
	move.w	6(a0),y1
	move.w	8(a0),x2
	move.w	10(a0),y2
	bsr	clipit
	move.w	12(a0),x1
	move.w	14(a0),y1
	move.w	(a0),x2
	move.w	2(a0),y2
	bsr	clipit
	rts

dosquare:
	lea	squaredef,a0
	move.w	my,d0
	lea	sqparam,a1
	asl.w	#1,d0
	move.w	(a1,d0.w),2(a0)
	bsr	calculator
	rts

sqparam:
	dc.w	50,60,70,80,90,100,110


calculator:
	move.w	(a0)+,d0	;x
	move.w	(a0)+,d1	;y
	move.w	(a0)+,d2	;z
	move.w	(a0)+,d7	;number of points
	subq.w	#1,d7
	move.l	(a0)+,a6	;ad of place to points calc'd points
calcloop:
	moveq	#0,d3
	move.w	(a0)+,d3	;get x
	add.w	d0,d3
	muls	#magic,d3	;persp
	move.w	2(a0),d4	;get z
	add.w	d2,d4
	divs	d4,d3
	add.w	#159,d3		;adjust for centre of screen
	move.w	d3,(a6)+	;put in place

	moveq	#0,d3		;get y
	move.w	(a0)+,d3
	add.w	d1,d3		;add y offs		
	muls	#magic,d3
	divs	d4,d3
	add.w	#20,d3		;adjust for centre
	move.w	d3,(a6)+
	addq.l	#2,a0
	dbf	d7,calcloop
	rts
*************************************************
*	Move me about				*
*************************************************
domyman:
	move.w	mymanx,d0
	sub.w	#10,d0
	move.w	mymany,d1
	sub.w	#30,d1
	move.w	mymanz,d2
	bsr	a3dmath
	lea	mymansp,a0
	move.w	d6,(a0)
	move.w	d7,2(a0)
	bra	putsprite
	rts

*************************************************
*	routine to bounce discs			*
*************************************************
discs:
	cmpi.w	#1,buttondat	;is there a new shot
	bne	movediscs	;if not just move the current dsc
	tst.w	discdelaycount
	bpl	movediscs
	move.w	#2,discdelaycount
	move.w	#0,buttondat
	lea	mydisc1,a0	;otherwise find inactive one
	tst.w	(a0)
	bpl	discs2		;if active go to 2
	move.w	#1,(a0)
	move.w	#0,32(a0)	;middle flag
	move.w	#0,34(a0)	;middle flag
	move.w	#0,36(a0)	;middle flag
	move.w	#0,38(a0)	;middle flag
	lea	myshad1,a1
	bsr	getcursor	;get x,y,z of cursor do math
	bra	movediscs
discs2:
	lea	mydisc2,a0	;otherwise find inactive one
	tst.w	(a0)
	bpl	discs3		;if active go to 2
	move.w	#1,(a0)
	move.w	#0,32(a0)	;middle flag
	move.w	#0,34(a0)	;middle flag
	move.w	#0,36(a0)	;middle flag
	move.w	#0,38(a0)	;middle flag
	lea	myshad2,a1
	bsr	getcursor	;get x,y,z of cursor do math
	bra	movediscs
discs3:
	lea	mydisc3,a0	;otherwise find inactive one
	tst.w	(a0)
	bpl	movediscs		;if active go to 2
	move.w	#1,(a0)
	move.w	#0,32(a0)	;middle flag
	move.w	#0,34(a0)	;middle flag
	move.w	#0,36(a0)	;middle flag
	move.w	#0,38(a0)	;middle flag
	lea	myshad3,a1
	bsr	getcursor	;get x,y,z of cursor do math
movediscs:
	lea	mydisc1,a0
	tst.w	(a0)
	bmi	md2
	lea	myshad1,a1
	bsr	discmath
	move.w	2(a1),d0
	move.w	4(a1),d1
	move.w	6(a1),d2
	bsr	a3dmath
	move.w	d6,d2
	move.w	d7,d1
	cmpi.w	#195,d1
	bge	skmd1
	bsr	doitb
skmd1:	lea	mydisc1,a0
	move.w	2(a0),d0
	move.w	4(a0),d1
	move.w	6(a0),d2
	bsr	a3dmath
	move.w	d6,d2
	move.w	d7,d1
	bsr	doit
md2:
	lea	mydisc2,a0
	tst.w	(a0)
	bmi	md3
	lea	myshad2,a1
	bsr	discmath
	move.w	2(a1),d0
	move.w	4(a1),d1
	move.w	6(a1),d2
	bsr	a3dmath
	move.w	d6,d2
	move.w	d7,d1
	cmpi.w	#195,d1
	bge	skmd2
	bsr	doitb
skmd2:	lea	mydisc2,a0
	move.w	2(a0),d0
	move.w	4(a0),d1
	move.w	6(a0),d2
	bsr	a3dmath
	move.w	d6,d2
	move.w	d7,d1
	bsr	doit
md3:
	lea	mydisc3,a0
	tst.w	(a0)
	bmi	md4
	lea	myshad3,a1
	bsr	discmath
	move.w	2(a1),d0
	move.w	4(a1),d1
	move.w	6(a1),d2
	bsr	a3dmath
	move.w	d6,d2
	move.w	d7,d1
	cmpi.w	#195,d1
	bge	skmd3
	bsr	doitb
skmd3:	lea	mydisc3,a0
	move.w	2(a0),d0
	move.w	4(a0),d1
	move.w	6(a0),d2
	bsr	a3dmath
	move.w	d6,d2
	move.w	d7,d1
	bsr	doit
md4:
	subq.w	#1,discdelaycount
	bmi	md5
	rts
md5:
	move.w	#-1,discdelaycount
	rts

discmath:	
	cmpi.w	#2,36(a0)
	beq	specialdm
	cmpi.w	#5,38(a0)
	bge	specialdm
	move.l	20(a0),d0	;x scaled up
	move.l	24(a0),d1	;y
	move.l	28(a0),d2	;z
	add.l	8(a0),d0	;add dx
	add.l	12(a0),d1	;add dy
	add.l	16(a0),d2	;add dz
	move.l	d0,20(a0)
	move.l	d1,24(a0)
	move.l	d2,28(a0)
	asr.l	#4,d0		;scale down
	asr.l	#4,d1
	asr.l	#4,d2
	move.w	d0,2(a0)
	move.w	d1,4(a0)
	move.w	d2,6(a0)
	move.w	d0,2(a1)
	move.w	d2,6(a1)
	bsr	chkbounds
	rts

makeneg:
	tst.l	d7
	blt	mnback
	neg.l	d7
mnback:
	rts
makeplus:
	tst.l	d7
	bgt	mpback
	neg.l	d7
mpback:
	rts

specialdm:
	move.w	mymanx,d0
	move.w	mymany,d1
	move.w	mymanz,d2
	bsr	chkmyman
sdm1:
	cmp.w	2(a0),d0
	bgt	sdm2
*	move.l	8(a0),d7
*	bsr	makeneg
	move.l	#-300,8(a0)
	bra	sdm3
sdm2:
*	move.l	8(a0),d7
*	bsr	makeplus
	move.l	#300,8(a0)
sdm3:
	cmp.w	6(a0),d2
	bgt	sdm4
*	move.l	16(a0),d7
*	bsr	makeneg
	move.l	#-500,16(a0)
	bra	sdm5
sdm4:
*	move.l	16(a0),d7
*	bsr	makeplus
	move.l	#500,16(a0)
sdm5:
	move.l	20(a0),d0	;x scaled up
	move.l	24(a0),d1	;y
	move.l	28(a0),d2	;z
	add.l	8(a0),d0	;add dx
	add.l	12(a0),d1	;add dy
	add.l	16(a0),d2	;add dz
	move.l	d0,20(a0)
	move.l	d1,24(a0)
	move.l	d2,28(a0)
	asr.l	#6,d0		;scale down
	asr.l	#6,d1
	asr.l	#6,d2
	move.w	d0,2(a0)
	move.w	d1,4(a0)
	move.w	d2,6(a0)
	move.w	d0,2(a1)
	move.w	d2,6(a1)
	bsr	chkbounds
	rts

chkmyman:
	subq.w	#5,d0		;x
	add.w	#10,d1		;y
	addq.w	#5,d2		;z
cmm1:
	cmp.w	2(a0),d0
	bgt	notbackyet
cmm2:
	cmp.w	4(a0),d1
	bgt	notbackyet
cmm3:
	cmp.w	6(a0),d2
	blt	notbackyet

	add.w	#10,d0
	sub.w	#20,d1
	sub.w	#10,d2
cmm4:
	cmp.w	2(a0),d0
	blt	notbackyet
cmm5:
	cmp.w	4(a0),d1
	blt	notbackyet
cmm6:
	cmp.w	6(a0),d2
	bgt	notbackyet
cmm7:
	move.w	#-1,(a0)
notbackyet:
	rts

chkbounds:
	move.w	2(a0),d0
	move.w	4(a0),d1
	move.w	6(a0),d2
cb1:
	cmpi.w	#-100,d0
	bge	cb2
	neg.l	8(a0)
	move.w	#-100,2(a0)
	addq.w	#1,38(a0)
	bra	cb3
cb2:
	cmpi.w	#100,d0
	ble	cb3
	neg.l	8(a0)
	move.w	#100,2(a0)
	addq.w	#1,38(a0)
cb3:
	cmpi.w	#225,d2
	bge	cb4
	neg.l	16(a0)
	move.w	#225,6(a0)
	addq.w	#1,38(a0)
	bra	cb5
cb4:
	cmpi.w	#625,d2
	ble	cb5
	neg.l	16(a0)
	move.w	#625,6(a0)
	addq.w	#1,38(a0)
cb5:
	cmpi.w	#325,d2
	bge	cb6
	move.w	#1,32(a0)
	bra	cb7
cb6:
	move.w	#1,34(a0)
cb7:
	move.w	32(a0),d7
	and.w	34(a0),d7
	tst.w	d7
	beq	cb8
	addq.w	#1,36(a0)
	move.w	#0,32(a0)
	move.w	#0,34(a0)
cb8:	
	rts


getcursor:
	cmpi.w	#1,cursorflag
	beq	gc2
	lea	cursordef1,a6
	move.w	(a6),d0		;get x
	move.w	2(a6),d1	;y
	move.w	4(a6),d2	;z
	bra	cmath
gc2:
	lea	cursordef2,a6
	move.w	(a6),d0		;get x
	move.w	2(a6),d1	;y
	move.w	4(a6),d2	;z

cmath:
	and.l	#$ffff,d0
	and.l	#$ffff,d1
	and.l	#$ffff,d2
	moveq	#0,d5
	moveq	#0,d6
	moveq	#0,d7
	move.w	mymanx,d5	;note:z used for y
	move.w	mymany,d6
	move.w	mymanz,d7
	move.w	d5,2(a0)
	move.w	d6,4(a0)
	move.w	d7,6(a0)
	asl.l	#4,d0		;scale em all up
	asl.l	#4,d1
	asl.l	#4,d2
	asl.l	#4,d5
	asl.l	#4,d6
	asl.l	#4,d7
	move.l	d5,20(a0)
	move.l	d6,24(a0)
	move.l	d7,28(a0)
	sub.l	d0,d5		;d5=dx
	sub.l	d1,d6		;d6=dy
	sub.l	d2,d7		;d7=dz
	neg.l	d5
	neg.l	d7
	neg.l	d6
	asr.l	#4,d5
	asr.l	#4,d6
	asr.l	#4,d7
	ext.l	d5
	ext.l	d6
	ext.l	d7
	move.w	d5,d0
	move.w	d0,d1
	muls	d1,d0		;sqr x
	move.w	d7,d1		;sqr z
	move.w	d1,d2
	muls	d2,d1
	add.l	d1,d0
	move.l	d0,d4		;save that
	bsr	sqrt
	and.l	#$ffff,d1
mybp:	and.l	#$ffff,d5
	asl.l	#4,d5		;*vel
	ext.l	d5
	divs	d1,d5
	and.l	#$ffff,d5
	asl.l	#4,d5		;scaleup
	move.l	d5,8(a0)

	and.l	#$ffff,d7
	asl.l	#4,d7		;*vel
	ext.l	d7
	divs	d1,d7
	and.l	#$ffff,d7
	ext.l	d7
	asl.l	#4,d7		;scaleup
	move.l	d7,16(a0)

	move.w	d6,d0
	move.w	d0,d1
	muls	d1,d0
	add.l	d4,d0
	bsr	sqrt

	and.l	#$ffff,d6
	asl.l	#4,d6		;*vel
	ext.l	d6
	divs	d1,d6
	and.l	#$ffff,d6
	ext.l	d6
	asl.l	#4,d6		;scaleup
	move.l	d6,12(a0)
mp:	rts

*************************************************
*	Sqroot routine courtesy of Armin	*
*	Input:	d0.l	number to get root of	*
*		d1	answer			*
*************************************************
sqrt:
	move.w	#10,d4
	lsr.l	#1,d0
	move.l	d0,d1
	lsr.l	#1,d1
sqloop:
	move.w	d1,d2
	lsr.l	#1,d2
	move.l	d0,d3
	divu	d1,d3
	sub.l	d2,d1
	add.w	d3,d1
	dbf	d4,sqloop
	rts



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,d6		;return screenx in d6

	moveq	#0,d3		;get y
	move.w	d1,d3
	muls	#magic,d3
	divs	d4,d3
	add.w	#20,d3		;adjust for centre
	move.w	d3,d7		;return screeny in d7
	rts


cursorflag:	blk.w	1,0
mymanx:		blk.w	1,0
mymany:		blk.w	1,0
mymanz:		blk.w	1,0
discdelaycount:	blk.w	1,0
mydisc1:
	dc.w	-1		;flag for active neg=no
	dc.w	0,0,0		;x,y,z current loc
	dc.l	0,0,0		;dx,dy,dz
	dc.l	0,0,0		;x,y,z scaled up
	dc.w	0,0,0		;flag for cross of middle
	dc.w	0
mydisc2:
	dc.w	-1		;flag for active neg=no
	dc.w	0,0,0		;x,y,z current loc
	dc.l	0,0,0		;dx,dy,dz
	dc.l	0,0,0		;x,y,z scaled up
	dc.w	0,0,0		;flag for cross of middle
	dc.w	0
mydisc3:
	dc.w	-1		;flag for active neg=no
	dc.w	0,0,0		;x,y,z current loc
	dc.l	0,0,0		;dx,dy,dz
	dc.l	0,0,0		;x,y,z scaled up
	dc.w	0,0,0		;flag for cross of middle
	dc.w	0
myshad1:
	dc.w	-1		;flag for active neg=no
	dc.w	0,140,0		;x,y,z current loc
	dc.l	0,0,0		;dx,dy,dz
	dc.l	0,8960,0	;x,y,z scaled up
	dc.w	0,0,0		;flag for cross of middle
	dc.w	0
myshad2:
	dc.w	-1		;flag for active neg=no
	dc.w	0,140,0		;x,y,z current loc
	dc.l	0,0,0		;dx,dy,dz
	dc.l	0,8960,0	;x,y,z scaled up
	dc.w	0,0,0		;flag for cross of middle
	dc.w	0
myshad3:
	dc.w	-1		;flag for active neg=no
	dc.w	0,140,0		;x,y,z current loc
	dc.l	0,0,0		;dx,dy,dz
	dc.l	0,8960,0	;x,y,z scaled up
	dc.w	0,0,0		;flag for cross of middle
	dc.w	0


squaredef:
	dc.w	0,-20,425		;x,y,z
	dc.w	4		;number of points
	dc.l	sqpts
	dc.w	-100,0,200
	dc.w	100,0,200
	dc.w	100,0,-200
	dc.w	-100,0,-200
sqpts:	blk.w	8,0
cursordef1:
	dc.w	0,0,0		;x,y,z
	dc.w	4		;number of points
	dc.l	curspts1
	dc.w	-5,5,0
	dc.w	5,5,0
	dc.w	5,-5,0
	dc.w	-5,-5,0
curspts1:
	blk.w	20,0
cursordef2:
	dc.w	0,0,0		;x,y,z
	dc.w	4		;number of points
	dc.l	curspts2
	dc.w	0,5,-5
	dc.w	0,5,5
	dc.w	0,-5,5
	dc.w	0,-5,-5
curspts2:
	blk.w	20,0

*********************************************
maketable:
	move.l	#cursortable,a0		;address of table
	move.w	#100,d0
mtl1:
	move.w	d0,(a0)+		;thats x
	move.w	#0,(a0)+		;thats y(filled in later)
	move.w	#225,(a0)+		;thats z
	move.w	#0,(a0)+		;flag for which type
	subq.w	#1,d0
	cmpi.w	#-100,d0
	bgt	mtl1

	move.w	#225,d0
mtl2:
	move.w	#-100,(a0)+		;thats x
	move.w	#0,(a0)+		;thats y(filled in later)
	move.w	d0,(a0)+		;thats z
	move.w	#1,(a0)+		;flag for which type
	addq.w	#1,d0
	cmpi.w	#625,d0
	blt	mtl2

	move.w	#-100,d0
mtl3:
	move.w	d0,(a0)+		;thats x
	move.w	#0,(a0)+		;thats y(filled in later)
	move.w	#625,(a0)+		;thats z
	move.w	#0,(a0)+		;flag for which type
	addq.w	#1,d0
	cmpi.w	#100,d0
	blt	mtl3

	move.w	#625,d0
mtl4:
	move.w	#100,(a0)+		;thats x
	move.w	#0,(a0)+		;thats y(filled in later)
	move.w	d0,(a0)+		;thats z
	move.w	#1,(a0)+		;flag for which type
	subq.w	#1,d0
	cmpi.w	#225,d0
	bgt	mtl4
	rts
cursortable:
	blk.w	5000,0

myvbl:
	addq.w	#1,vblcount
	cmpi.w	#50,vblcount
	blt	myvb
	move.w	fcount,score
	move.w	#0,fcount
	move.w	#0,vblcount
myvb:
	rts

vblcount:	blk.w	1,0
fcount:		blk.w	1,0

setuphbl:
	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	hbl_vec,hblt+2
	move.l	#hblhandler2,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

hblhandler2:
	movem.l	d0/a0,-(sp)
	move.b	#0,tbcr
	move.b	#3,tbdr
	move.b	#8,tbcr
	move.l	#backcolors,a0
	move.w	colorcount,d0
	move.w	(a0,d0.w),$ff8240
	addq.w	#2,colorcount
	cmpi.w	#42,d0
	blt	hblover
	move.w	#0,colorcount	
	move.b	#0,tbcr
	move.b	#100,tbdr
	move.b	#8,tbcr
hblover:
	bclr	#0,isra
	movem.l	(sp)+,d0/a0
	rte


vbl_handler:
*	move.w	#0,linecount
	move.w	#$0001,$ff8240
	move.w	#0,colorcount
	move.b	#0,tbcr
	move.b	#90,tbdr
	move.b	#8,tbcr
vblt:	jmp	$0



key_handler:
	move.w	#$2500,sr
keyt:	jmp	$0

colorcount:	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	$0000
	

putballs:
*	move.l	masterimage,a0
	move.w	d0,d2		;get copy of x
	and.w	#15,d0		;last 4 bits is offset
	move.w	d0,d3
	mulu	#240,d0
	adda.w	d0,a0		;now pointing at correct image
	move.l	a0,imageptr
*	move.l	mastermask,a0
	asr.w	#1,d0
	adda.w	d0,a0
	move.l	a0,maskptr
	move.l	hiden,a0
	lsl.w	#5,d1		;mult y by 128
	adda.w	d1,a0		;add it to screen address
	lsl.w	#2,d1		;mult by 32 makes mult by 160
	add.w	d1,a0
	and.w	#$fff0,d2	;mask off last 4 bits gives word across
	lsr.w	#1,d2
	adda.w	d2,a0
	move.l	a0,screenloc
	move.w	#1,width
	move.w	#15,height
	bsr	pdrawimage
	rts
*****************************************
myreset:
	rts
cxmin:		equ	0
cxmax:		equ	319
cymin:		equ	0
cymax:		equ	199
cbits:	blk.w	1,0
cbits2:	blk.w	1,0
xsav:	blk.w	1,0
ysav:	blk.w	1,0
*dx:	blk.w	1,0
*dy:	blk.w	1,0
*/**//*/*//*//*/*//*//*/*/*//*/*/*/*//*/*/*/*//*//*//*///*/*/
bitcode:clr.l   d4
        cmpi.w  #cxmin,d0
        bge     b1
        or.b    #8,d4
b1:     cmpi.w  #cxmax,d0
        ble     b2
        or.b    #4,d4
b2:     cmpi.w  #cymin,d1
        bge     b3
        or.b    #1,d4
b3:     cmpi.w  #cymax,d1
        ble     b4
        or.b    #2,d4
b4:     move.w  d4,cbits
        rts
*****
bitc2:   clr.l   d5
        cmpi.w  #cxmin,d2
        bge     b5
        or.b    #8,d5
b5:     cmpi.w  #cxmax,d2
        ble     b6
        or.b    #4,d5
b6:     cmpi.w  #cymin,d3
        bge     b7
        or.b    #1,d5
b7:     cmpi.w  #cymax,d3
        ble     b8
        or.b    #2,d5
b8:     move.w  d5,cbits2
        rts
********************************************************
clipit:
	movem.l	d0-d7/a0,-(sp)
	move.w	x1,d0
	move.w	y1,d1
	move.w	x2,d2
	move.w	y2,d3

	bsr     bitcode
        bsr     bitc2
clipit2:or.b    d4,d5
        tst.b   d5
        beq     cliphome        ;finish if
        move.w  cbits,d4
        move.w  d2,xsav
        move.w  d3,ysav
        move.w  cbits2,d5
clip1:  and.b   d4,d5
        tst.b   d5
        bgt     clipb           ;home if line completely out
        move.w  cbits,d4
        move.w  cbits2,d5
        sub.w   d0,d2           ;d1 has dx
        move.w  d2,dx
        sub.w   d1,d3           ;d3 has dy
        move.w  d3,dy
        move.w  xsav,d2
        move.w  ysav,d3
        tst.w   d4
        beq     clip2   	;if x1<xmin
        cmpi.w  #cxmin,d0 	;y1=y1+dy*(xmin-x1)/dx
        bge     c1      
        move.w  #cxmin,d7         ;put xmin in d7
        sub.w   d0,d7
        muls    dy,d7           ;multiply by dy
        divs    dx,d7
        add.w   d1,d7
        move.w  d7,d1
        move.w  #cxmin,d0         ;x1=xmin
        bra     c4
c1:     cmpi.w  #cxmax,d0         ;if x1>xmax
        ble     c2              ;y1=y1+dy*(xmax-x1)/dx
        move.w  #cxmax,d7         ;put xmax in d7
        sub.w   d0,d7
        muls    dy,d7           ;multiply by dy
        divs    dx,d7
        add.w   d1,d7
        move.w  d7,d1
        move.w  #cxmax,d0         ;x1=xmax
        bra     c4
c2:     cmpi.w  #cymin,d1         ;if y1<ymin
        bge     c3
        move.w  #cymin,d7         ;put ymin in d7
        sub.w   d1,d7
        muls    dx,d7           ;multiply by dx
        divs    dy,d7
        add.w   d0,d7
        move.w  d7,d0
        move.w  #cymin,d1         ;y1=ymin
        bra     c4
c3:     cmpi.w  #cymax,d1         ;if y1>xmax
        ble     c4
        move.w  #cymax,d7         ;put ymax in d7
        sub.w   d1,d7
        muls    dx,d7           ;multiply by dy
        divs    dy,d7
        add.w   d0,d7
        move.w  d7,d0
        move.w  #cymax,d1         ;y1=ymax
c4:     bsr     bitcode
        bra     cliploop
******
clip2:  cmpi.w  #cxmin,d2 ;	y1=y1+dy*(xmin-x1)/dx
        bge     cc1     
        move.w  #cxmin,d7         ;put xmin in d7
        sub.w   d2,d7
        muls    dy,d7           ;multiply by dy
        divs    dx,d7
        add.w   d3,d7
        move.w  d7,d3
        move.w  #cxmin,d2         ;x2=xmin
        bra     cc4
cc1:    cmpi.w  #cxmax,d2         ;if x2>xmax
        ble     cc2
        move.w  #cxmax,d7         ;put xmax in d7
        sub.w   d2,d7
        muls    dy,d7           ;multiply by dy
        divs    dx,d7
        add.w   d3,d7
        move.w  d7,d3
        move.w  #cxmax,d2         ;x1=xmax
        bra     cc4
cc2:    cmpi.w  #cymin,d3         ;if y1<ymin
        bge     cc3
        move.w  #cymin,d7         ;put ymin in d7
        sub.w   d3,d7
        muls    dx,d7           ;multiply by dx
        divs    dy,d7
        add.w   d2,d7
        move.w  d7,d2
        move.w  #cymin,d3         ;y1=ymin
        bra     cc4
cc3:    cmpi.w  #cymax,d3         ;if y1>xmax
        ble     cc4
        move.w  #cymax,d7         ;put ymax in d7
        sub.w   d3,d7
        muls    dx,d7           ;multiply by dy
        divs    dy,d7
        add.w   d2,d7
        move.w  d7,d2
        move.w  #cymax,d3         ;y1=ymax
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:
	move.l	#0,d0
	move.w	dx,d0
	divs	dy,d0
	bmi	xpositive

xnegative:
	move.l	hiden,a0	;screen ad
	move.w	dx,d0
	move.w	d0,d7	;counter is d7
	subq.w	#1,d7
bp:	asr.w	#1,d0	;div by 2
	move.w	d0,d6	;dump is d6
	move.w	x1,d0	;will hold bitpattern
	move.w	d0,d2
	move.w	y1,d1
	lsl.w	#5,d1	;mult y by 128
	adda.w	d1,a0	;add it to screen address
	lsl.w	#2,d1	;mult by 32 makes mult by 160
	add.w	d1,a0	;a0 now has start screen address
	and.w	#$fff0,d0	;mask off last 4 bits gives word across
	lsr.w	#1,d0
	add.w	d0,a0
	moveq	#0,d4
	tst.w	d7
	bmi	specxneg
xmnloop:
	addq.w	#1,d2
	move.w	d2,d3
	and.w	#15,d3
	bne	xmnla
	bsr	putlinein
	moveq	#0,d4
	addq.l	#8,a0
xmnla:	sub.w	#15,d3
	neg	d3
	bset	d3,d4
	sub.w	dy,d6	;sub dy from dump
	bpl	xmn
	add.w	dx,d6
	bsr	putlinein
	adda.l	#160,a0		;moveit to next line
	moveq	#0,d4
xmn:
	dbf	d7,xmnloop
specxneg:
	move.w	d2,d3
	and.w	#15,d3
	sub.w	#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:
	move.l	#0,d0
	move.w	dy,d0
	divs	dx,d0
	bmi	ypositive
ynegative:
	tst.w	dx
	beq	straightup1	;special case vertical line
	move.l	hiden,a0	;screen ad
	move.w	dy,d0
	move.w	d0,d7	;counter is d7
*	subq.w	#1,d7
	asr.w	#1,d0	;div by 2
	move.w	d0,d6	;dump is d6
	move.w	x1,d0	;will hold bitpattern
	move.w	d0,d3
	move.w	y1,d1
	move.w	d1,d2
	lsl.w	#5,d1	;mult y by 128
	adda.w	d1,a0	;add it to screen address
	lsl.w	#2,d1	;mult by 32 makes mult by 160
	add.w	d1,a0	;a0 now has start screen address
	and.w	#$fff0,d0	;mask off last 4 bits gives word across
	lsr.w	#1,d0
	add.w	d0,a0
	move.w	d3,d0	;x
	moveq	#0,d4
	move.w	d0,d3
	and.w	#15,d3
	move.w	#$8000,d4
	lsr.w	d3,d4
ymnloop:
	bsr	putlinein
	add.w	#160,a0	;y+1
	sub.w	dx,d6	;sub dy from dump
	bpl	ymn
	add.w	dy,d6
	addq.w	#1,d0	;x+1
	move.w	d0,d3
	and.w	#15,d3
	bne	ymnla
	addq.l	#8,a0
ymnla:	move.w	#$8000,d4
	lsr.w	d3,d4
ymn:
	dbf	d7,ymnloop
*	movem.l	(sp)+,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

*********************************************

*****************************************
ramware:
	move.w	#0,let1c
	move.w	#326,let2c
	move.w	#308,let3c
	move.w	#290,let4c
	move.w	#272,let5c
	move.w	#254,let6c
	move.w	#236,let7c

rw2:
	bsr	clearsmall
	bsr	doletters
	bsr	keyboard
	bsr	flip2
	tst.w	firebutton
	bmi	rw2
	rts
clearsmall:
	move.l	hiden,a0
	add.l	#56,a0
	move.w	#36,d7
clsm:
	move.l	#0,(a0)+
	move.l	#0,(a0)+
	move.l	#0,(a0)+
	move.l	#0,(a0)+
	move.l	#0,(a0)+
	move.l	#0,(a0)+
	move.l	#0,(a0)+
	move.l	#0,(a0)+
	move.l	#0,(a0)+
	move.l	#0,(a0)+
	move.l	#0,(a0)+
	move.l	#0,(a0)+
	move.l	#0,(a0)+
	move.l	#0,(a0)+
	move.l	#0,(a0)+
	move.l	#0,(a0)+
	move.l	#0,(a0)+
	move.l	#0,(a0)+
	move.l	#0,(a0)+
	move.l	#0,(a0)+
	move.l	#0,(a0)+
	move.l	#0,(a0)+
	move.l	#0,(a0)+
	move.l	#0,(a0)+
	add.w	#64,a0
	dbf	d7,clsm
	rts

doletters:
	move.l	#rampat,a0
	move.w	let1c,d0
	cmpi.w	#344,d0
	blt	dl1
	move.w	#0,let1c
dl1:
	asl.w	#2,d0		;mul by 4
	move.w	(a0,d0.w),d2	;thats x
	move.w	2(a0,d0.w),d1	;thats y
	move.l	#rsprite,spblock+8
	bsr	doit		;put the sucker up
	addq.w	#1,let1c
*	rts

	move.l	#rampat,a0
	move.w	let2c,d0
	cmpi.w	#344,d0
	blt	dl2
	move.w	#0,let2c
dl2:
	asl.w	#2,d0		;mul by 4
	move.w	(a0,d0.w),d2	;thats x
	move.w	2(a0,d0.w),d1	;thats y
	move.l	#asprite,spblock+8
	bsr	doit		;put the sucker up
	addq.w	#1,let2c

	move.l	#rampat,a0
	move.w	let3c,d0
	cmpi.w	#344,d0
	blt	dl3
	move.w	#0,let3c
dl3:
	asl.w	#2,d0		;mul by 4
	move.w	(a0,d0.w),d2	;thats x
	move.w	2(a0,d0.w),d1	;thats y
	move.l	#msprite,spblock+8
	bsr	doit		;put the sucker up
	addq.w	#1,let3c

	move.l	#rampat,a0
	move.w	let4c,d0
	cmpi.w	#344,d0
	blt	dl4
	move.w	#0,let4c
dl4:
	asl.w	#2,d0		;mul by 4
	move.w	(a0,d0.w),d2	;thats x
	move.w	2(a0,d0.w),d1	;thats y
	move.l	#wsprite,spblock+8
	bsr	doit		;put the sucker up
	addq.w	#1,let4c

	move.l	#rampat,a0
	move.w	let5c,d0
	cmpi.w	#344,d0
	blt	dl5
	move.w	#0,let5c
dl5:
	asl.w	#2,d0		;mul by 4
	move.w	(a0,d0.w),d2	;thats x
	move.w	2(a0,d0.w),d1	;thats y
	move.l	#asprite,spblock+8
	bsr	doit		;put the sucker up
	addq.w	#1,let5c

	move.l	#rampat,a0
	move.w	let6c,d0
	cmpi.w	#344,d0
	blt	dl6
	move.w	#0,let6c
dl6:
	asl.w	#2,d0		;mul by 4
	move.w	(a0,d0.w),d2	;thats x
	move.w	2(a0,d0.w),d1	;thats y
	move.l	#rsprite,spblock+8
	bsr	doit		;put the sucker up
	addq.w	#1,let6c

	move.l	#rampat,a0
	move.w	let7c,d0
	cmpi.w	#344,d0
	blt	dl7
	move.w	#0,let7c
dl7:
	asl.w	#2,d0		;mul by 4
	move.w	(a0,d0.w),d2	;thats x
	move.w	2(a0,d0.w),d1	;thats y
	move.l	#esprite,spblock+8
	bsr	doit		;put the sucker up
	addq.w	#1,let7c
	rts


doit:
	subq.w	#6,d2
	cmpi.w	#425,6(a0)
	blt	doit2
	move.l	#bdiscsp2,a0
	move.w	d2,(a0)		;putx
	move.w	d1,2(a0)	;puty
	bra	putsprite
doit2:
	cmpi.w	#325,6(a0)
	blt	doit3
	move.l	#bdiscsp1,a0
	move.w	d2,(a0)		;putx
	move.w	d1,2(a0)	;puty
	bra	putsprite
doit3:
	move.l	#bdiscsp0,a0
	move.w	d2,(a0)		;putx
	move.w	d1,2(a0)	;puty
	bra	putsprite


doitb:
	subq.w	#6,d2
	cmpi.w	#425,6(a0)
	blt	doit2b
	move.l	#sdiscsp2,a0
	move.w	d2,(a0)		;putx
	move.w	d1,2(a0)	;puty
	bra	putsprite
doit2b:
	cmpi.w	#325,6(a0)
	blt	doit3b
	move.l	#sdiscsp1,a0
	move.w	d2,(a0)		;putx
	move.w	d1,2(a0)	;puty
	bra	putsprite
doit3b:
	move.l	#sdiscsp0,a0
	move.w	d2,(a0)		;putx
	move.w	d1,2(a0)	;puty
	bra	putsprite

bdiscsp0:
	dc.w	0,0	;x,y
	dc.w	3,0	;height,width
	dc.w	144	;add to sc
	dc.l	bdisc0
bdiscsp1:
	dc.w	0,0	;x,y
	dc.w	2,0	;height,width
	dc.w	144	;add to sc
	dc.l	bdisc1
bdiscsp2:
	dc.w	0,0	;x,y
	dc.w	2,0	;height,width
	dc.w	144	;add to sc
	dc.l	bdisc2

sdiscsp0:
	dc.w	0,0	;x,y
	dc.w	3,0	;height,width
	dc.w	144	;add to sc
	dc.l	sdisc0
sdiscsp1:
	dc.w	0,0	;x,y
	dc.w	2,0	;height,width
	dc.w	144	;add to sc
	dc.l	sdisc1
sdiscsp2:
	dc.w	0,0	;x,y
	dc.w	2,0	;height,width
	dc.w	144	;add to sc
	dc.l	sdisc2
mymansp:
	dc.w	0,0	;x,y
	dc.w	38,1	;height,width
	dc.w	136	;add to sc
	dc.l	mymantemp


spblock:
	blk.w	50,0
let1c:	blk.w	1,0
let2c:	blk.w	1,0
let3c:	blk.w	1,0
let4c:	blk.w	1,0
let5c:	blk.w	1,0
let6c:	blk.w	1,0
let7c:	blk.w	1,0

********************************
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
	add.w	#zamount,mymanz
	rts
neast:	cmpi.b	#9,d0
	bne	east
	add.w	#xamount,mymanx
	add.w	#zamount,mymanz
	rts
east:	cmpi.b	#8,d0
	bne	seast
	add.w	#xamount,mymanx
	rts
seast:	cmpi.b	#10,d0
	bne	south
	add.w	#xamount,mymanx
	sub.w	#zamount,mymanz
	rts

south:	cmpi.b	#2,d0
	bne	swest
	sub.w	#zamount,mymanz
	rts
swest:	cmpi.b	#6,d0
	bne	west
	sub.w	#xamount,mymanx
	sub.w	#zamount,mymanz
	rts
west:	cmpi.b	#4,d0
	bne	nwest
	sub.w	#xamount,mymanx
	rts
nwest:	cmpi.b	#5,d0
	bne	jdback
	sub.w	#xamount,mymanx
	add.w	#zamount,mymanz
	rts
jdback:
	rts

minusvel:	blk.w	1,0
plusvel:	blk.w	1,0
myx:	blk.w	1,0
myy:	blk.w	1,0
myxvel:	blk.w	1,0
myyvel:	blk.w	1,0
firebutton:	blk.w	1,-1
*******************************
*gtemp:	blk.w	5000,0
*gmask:	blk.w	5000,0
*****************************************
*	set up joystick handler		*
*****************************************
joystuff:
init_joy:
	move.w	#$14,-(sp)
	move.w	#4,-(sp)
	move.w	#3,-(sp)
	trap	#13
	addq.l	#6,sp

	move.w	#$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
*************************************************
prestuff:
	move.w	#0,d7
*	move.l	#myship,origptr
*	move.l	#myshipbuffer,imageptr
	move.w	#0,offset
ps1:
	move.w	#1,width
	move.w	#15,height
	jsr	pshiftimage	
	addq.w	#1,offset
	add.l	#240,imageptr
	addq.w	#1,d7
	cmpi.w	#15,offset
	ble	ps1

	move.w	#0,d7
*	move.l	#myshipmask,maskptr
*	move.l	#myshipbuffer,imageptr
	move.w	#0,offset
psm1:
	move.w	#1,width
	move.w	#15,height
	bsr	pmakemask	
	addq.w	#1,offset
	add.l	#240,imageptr
	add.l	#120,maskptr
	cmpi.w	#15,offset
	ble	psm1


*****************************************
*	height- height			*
*	width				*
*	offset				*
*	origptr				*
*	imageptr			*
*****************************************

pshiftimage:
        move.w  height,d1        ;height in d1
        move.w  offset,d2       ;offset to d2
        subq.w  #1,d1           ;height - 1 = height if count starts at zero
        subq.w  #1,width        ;width - 1 = width if count starts at zero
        move.l  origptr,a0      ;object pointer to a0
        move.l  imageptr,a1     ;image pointer to a1
psi1:   move.w  width,d0		;width in d0
        clr.l   (a1)            ;for each line, the first word of the
        clr.l   4(a1)           ;image must be cleared
psi0:    clr.l   d4              ;make sure that the top halves of these
        clr.l   d5              ;registers are zeroed out
        clr.l   d6
        clr.l   d7
        move.w  (a0)+,d4        ;load in one word (four planes)
        move.w  (a0)+,d5        ;to be rotated
        move.w  (a0)+,d6
        move.w  (a0)+,d7
        ror.l   d2,d4           ;rotate all planes by the offset(d2)
        ror.l   d2,d5
        ror.l   d2,d6
        ror.l   d2,d7
        or.w    d4,(a1)+        ;add low order bits to the high order bits
        or.w    d5,(a1)+        ;stored by move instructions farther
        or.w    d6,(a1)+        ;down in this routine
        or.w    d7,(a1)+
        swap    d4              ;move high order bits into lower halves
        swap    d5              ;of the registers
        swap    d6
        swap    d7
        move.w  d4,(a1)         ;save the high orders bits to be ORed
        move.w  d5,2(a1)        ;in the loop (do not increment a1 because
        move.w  d6,4(a1)        ;the ORs in the loop must function on
        move.w  d7,6(a1)        ;the same addresses as these moves.
        dbf     d0,psi0          ;repeat width times
        addq.l  #8,a1           ;new line, move to next word( * 4 planes = 8)
        dbf     d1,psi1          ;repeat height times
        rts                     ;done

pmakemask:
        move.w  height,d1        ;height in d1
        subq.w  #1,d1           ;height - 1 = height if count starts at zero
        move.l  imageptr,a0        ;image pointer to a0
        move.l  maskptr,a1       ;mask pointer to a1
pmm1:    move.w  width,d0        ;width in d0
pmm0:    move.w  (a0)+,d2        ;load first plane of bit image in d2
        or.w    (a0)+,d2        ;OR it with the 3 other planes
        or.w    (a0)+,d2
        or.w    (a0)+,d2
        move.w  d2,d3           ;store inverse mask in d3 (temporary)
        swap    d2              ;move inverse mask to top half of register
        move.w  d3,d2           ;and also in bottom half
        eor.l   #-1,d2          ;mask no longer inverse
        move.l  d2,(a1)+        ;store mask in buffer
        dbf     d0,pmm0          ;repeat 'width' times
        dbf     d1,pmm1          ;repeat 'height' times
        rts                     ;done
**************************************************
*	routine to draw image of prerotated
*	sprite
*	must load width,height,screenloc,imageptr,maskptr
pdrawimage:
        move.w  height,d1        ;height to d1
        subq.w  #1,d1           ;height - 1 = height if count starts at zero
        move.l  imageptr,a1       ;image pointer to a1
        move.l  maskptr,a2       ;mask pointer to a2
        move.l  screenloc,a3       ;screen buffer pointer to a3
pdi1:    move.w  width,d0        ;width to d0
        move.l  screenloc,a0        ;absolute screen address to a0
pdi0:    move.l  (a2)+,d3        ;load mask data into d3
        move.l  (a1)+,d6        ;load screen image into d6 and d7
        move.l  (a1)+,d7        ;2 words each covers all 4 planes
        move.l  (a3)+,d4        ;do the same for the background
        move.l  (a3)+,d5        ;in d4 and d5 (from buffer, not screen)
        and.l   d3,d4           ;mask background
        and.l   d3,d5
        or.l    d6,d4           ;copy image onto background
        or.l    d7,d5           ;giving final image on top of background
        move.l  d4,(a0)+        ;copy final image into screen memory
        move.l  d5,(a0)+
        dbf     d0,pdi0          ;repeat for 'width' times
        add.l   #160,screenloc      ;move to next screen line
	add.l	#144,a3
        dbf     d1,pdi1          ;repeat 'height' times
        rts                     ;done

shadow:
	tst.w	shad
	bmi	sback
	move.w	height,d1
	subq.w	#1,d1
	move.l	screenloc,a0
	move.l	maskptr,a1
	add.l	#1592,a0
sd:
	move.l	(a1)+,d0
	and.l	d0,(a0)+
	and.l	d0,(a0)+
	move.l	(a1)+,d0
	and.l	d0,(a0)+
	and.l	d0,(a0)+
	add.l	#144,a0
	dbf	d1,sd
	move.w	#-1,shad
	rts
sback:	
	move.w	#1,shad
	rts

shad:	blk.w	1,0
height:	blk.w	1,0
width:	blk.w	1,0
screenloc:	blk.l	1,0
imageptr:	blk.l	1,0
maskptr:	blk.l	1,0
****************************************
keyboard:
        move.w  #$ff,-(sp)
        move.w  #6,-(sp)
        trap    #1
        addq.l  #4,sp
        tst.l   d0
        beq     keyback
        swap    d0
quit:   cmpi.w  #$10,d0
        bne     space
        bra     gem
space:
	cmpi.w	#$39,d0
	bne	keyback
	bra	pause
	
keyback:rts
*****************************
pause:  
        move.w  #$ff,-(sp)
        move.w  #6,-(sp)
        trap    #1
        addq.l  #4,sp
        tst.l   d0
        beq     pause
        swap    d0
        cmpi.w  #$1e,d0
        bne     keyback 
        bsr     gkey
        cmpi.w  #$32,d0
        bne     keyback
        bsr     gkey
        cmpi.w  #$1e,d0
        bne     keyback
        bsr     gkey
        cmpi.w  #$31,d0
        bne     keyback
        bsr     gkey
        cmpi.w  #$20,d0
        bne     keyback
        bsr     gkey
        cmpi.w  #$1e,d0
        bne     keyback
*        bra     tmode

gkey:
        move.w  #$ff,-(sp)
        move.w  #6,-(sp)
        trap    #1
        addq.l  #4,sp
        tst.l   d0
        beq     gkey
        swap    d0
        rts

*********************************************************
*	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
        move.l  #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
	move.l  #gtemp,a1	;image pointer to a0
	move.l  #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
	move.l  #gtemp,a1	;image pointer to a1
	move.l  #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
************code to determine  x offset *****************
*               and absolute screen address             *
*               parameters to pass on stack as follows  *
*               1-      x of sprite                     *
*               2-      y of sprite                     *
*               3-      screen address                  *
*       paremeters returned are x offset in d0          *
*       absolute screen address in d2                   *
*********************************************************
shipsp:
calc:
        clr.l   d0
        move.w  pblock,d0       ;put x value in d0
        divu    #16,d0          ;divide by 16 leaves word boundry in d0
        move.w  pblock+2,d1     ;put y value in d1
        mulu    #160,d1         ;gives offset in words of line
        move.w  d0,d3
        mulu    #8,d3
        add     d3,d1           ;gives word to poke sprite
        move.l  pblock+16,d2    ;put screen address in d2
        add     d1,d2           ;gives actual screen address for sprite
        move.l  d2,pblock+20
        asr.l   #8,d0
        asr.l   #8,d0           ;leaves x offset in d0          
        move.w  d0,pblock+24


*************CODE TO ROTATE A SPRITE IMAGE***********************
*       parameters to be passed on the stack in order are       *       
*       1-      x offset from start of word                     *
*       2-      address of place to put shifted image(tempsp)   *
*       3-      address of sprite data                          *
*       4-      height of object in pixels                      *
*       5-      width of object in words - 1                    *
*****************************************************************
shiftimage:
        move.w  pblock+4,d1        ;height in d1
        move.w  pblock+24,d2       ;offset to d2
        subq.w  #1,d1           ;height - 1 = height if count starts at zero
        subq.w  #1,pblock+6        ;width - 1 = width if count starts at zero
        move.l  pblock+8,a0        ;object pointer to a0
        move.l  pblock+12,a1       ;image pointer to a1
si1:    move.w  pblock+6,d0        ;width in d0
        clr.l   (a1)            ;for each line, the first word of the
        clr.l   4(a1)           ;image must be cleared
si0:    clr.l   d4              ;make sure that the top halves of these
        clr.l   d5              ;registers are zeroed out
        clr.l   d6
        clr.l   d7
        move.w  (a0)+,d4        ;load in one word (four planes)
        move.w  (a0)+,d5        ;to be rotated
        move.w  (a0)+,d6
        move.w  (a0)+,d7
        ror.l   d2,d4           ;rotate all planes by the offset(d2)
        ror.l   d2,d5
        ror.l   d2,d6
        ror.l   d2,d7
        or.w    d4,(a1)+        ;add low order bits to the high order bits
        or.w    d5,(a1)+        ;stored by move instructions farther
        or.w    d6,(a1)+        ;down in this routine
        or.w    d7,(a1)+
        swap    d4              ;move high order bits into lower halves
        swap    d5              ;of the registers
        swap    d6
        swap    d7
        move.w  d4,(a1)         ;save the high orders bits to be ORed
        move.w  d5,2(a1)        ;in the loop (do not increment a1 because
        move.w  d6,4(a1)        ;the ORs in the loop must function on
        move.w  d7,6(a1)        ;the same addresses as these moves.
        dbf     d0,si0          ;repeat width times
        addq.l  #8,a1           ;new line, move to next word( * 4 planes = 8)
        dbf     d1,si1          ;repeat height times
        addi.w  #1,pblock+6
make_mask:
        move.w  pblock+4,d1        ;height in d1
        subq.w  #1,d1           ;height - 1 = height if count starts at zero
        move.l  pblock+12,a0        ;image pointer to a0
        move.l  pblock+38,a1       ;mask pointer to a1
mm1:	move.w  pblock+6,d0        ;width in d0
mm0:	move.w  (a0)+,d2        ;load first plane of bit image in d2
        or.w    (a0)+,d2        ;OR it with the 3 other planes
        or.w    (a0)+,d2
        or.w    (a0)+,d2
        move.w  d2,d3           ;store inverse mask in d3 (temporary)
        swap    d2              ;move inverse mask to top half of register
        move.w  d3,d2           ;and also in bottom half
        eor.l   #-1,d2          ;mask no longer inverse
        move.l  d2,(a1)+        ;store mask in buffer
        dbf     d0,mm0          ;repeat 'width' times
        dbf     d1,mm1          ;repeat 'height' times

draw:
        move.w  pblock+4,d1     ;height to d1
        subq.w  #1,d1           ;height - 1 = height if count starts at zero
        move.l  pblock+12,a1    ;image pointer to a1
        move.l  pblock+38,a2    ;mask pointer to a2
        move.l  pblock+20,a3    ;screen buffer pointer to a3
di1:	move.w  pblock+6,d0     ;width to d0
        move.l  pblock+20,a0    ;absolute screen address to a0
di0:	move.l  (a2)+,d3        ;load mask data into d3
        move.l  (a1)+,d6        ;load screen image into d6 and d7
        move.l  (a1)+,d7        ;2 words each covers all 4 planes
        move.l  (a3)+,d4        ;do the same for the background
        move.l  (a3)+,d5        ;in d4 and d5 (from buffer, not screen)
        and.l   d3,d4           ;mask background
        and.l   d3,d5
        or.l    d6,d4           ;copy image onto background
        or.l    d7,d5           ;giving final image on top of background
        move.l  d4,(a0)+        ;copy final image into screen memory
        move.l  d5,(a0)+
        dbf     d0,di0          ;repeat for 'width' times
        add.l   #160,pblock+20  ;move to next screen line
        add.w   pblock+46,a3
        dbf     d1,di1          ;repeat 'height' times
	rts
***********************************
printscore:
*	tst.b	numsflag
*	bmi	noput
	move.w	#0,numwhere
	move.w	score,number
	bsr	prtnum
*	subq.b	#1,numsflag
*	rts
noput:
	move.b	#-1,numsflag
printships:
*	tst.b	shipsflag
*	bmi	noputs
	move.w	#2560,numwhere
	move.w	ships,number
	bsr	prtnum
*	subq.b	#1,shipsflag
	rts
noputs:
	move.b	#-1,numsflag
	rts

emancnt:	blk.w	1,0
numwhere:	blk.w	1,0
numsflag:	blk.b	1,0
shipsflag:	blk.b	1,0
levelflag:	blk.b	1,0
even
**********************************************
clearquick:
	move.l	screen3,a0
	move.l	hiden,a1
	addi.l	#7200,a0
	addi.l	#7200,a1
	move.w	#154,d0		;154
clloop:
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	dbf	d0,clloop
	rts

**************************************************************************

*               RETURN TO GEM

gem:
	move.w	#$0777,$ff8240
*	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	#0,$452
	move.l	oldvbl1,a0
	move.l	#0,(a0)
	move.w	#1,$452

*	jsr	res_mouse
	move.w  #34,-(sp)
        trap    #14
        addq.l  #2,sp
        move.l  d0,a0
	move.l	oldmouse,16(a0)

	jsr	rs2

        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
	move.l	#0,d0
	move.b	(a0),d0
	asl.l	#8,d0
	adda.w	#2,a0
	move.b	(a0),d0
	asl.l	#8,d0
	adda.w	#2,a0
	move.b	(a0),d0
	rts
flip_scr:
	move.l	seen,d1
	move.l	d1,d2
	add.l	#10000,d1
	add.l	#16000,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
*	bsr	beamer
	cmp.l	d1,d0
	blt	skloop
	cmp.l	d2,d0
	bgt	skloop

	jsr	clearquick
        move.l  seen,A6
        move.l  hiden,seen
        move.l  A6,hiden
        move.l  sytable,A6
        move.l  ytable,sytable
        move.l  A6,ytable
*       rts
df:     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
************************************************************
flip2:
        move.l  seen,A6
        move.l  hiden,seen
        move.l  A6,hiden
        move.l  sytable,A6
        move.l  ytable,sytable
        move.l  A6,ytable
*       rts
df2:     move.w  #-1,-(sp)
        move.l  seen,-(sp)
        move.l  hiden,-(sp)
        move.w  #5,-(sp)
        trap    #14
        addi.l  #12,sp  
	move.w	#37,-(sp)
	trap	#14
	addq.l	#2,sp
	bsr	clearquick
        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

**************************************
* PLOT A PIXEL WITH MY ROUTINE       *
*                                    *
* CALL WITH:                         *
* myplot(X,Y,COLOR)                  *
**************************************
myplot:
movem.l	d0-d5/a0-a1,-(sp)
move.w pixelx,d0      ;x coordinate in D0
cmp.w #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 #199,d1
bcc pltxit
lsl.w #2,d1          ;mult by 4 for index
move.w pixelcolor,d2      ;get color number

lsr.w 	#1,d0             ;x coord / 2
and.w #$00f8,d0      ;strip lower 3 bits
move.w d0,a0        ;move x offset to A0
move.l ytable,a1   ;get y table addr
adda.l 0(a1,d1.w),a0 ;got final pixel addr!
cmpi.w	#15,d3
beq	singlepix
move.w #$c000,d4     ;set ON pixel mask
lsr.w d3,d4          ;shift right D3 times
move.l #$c000c000,d5 ;set OFF pixel mask
lsr.l d3,d5          ;shift right D3 times
eor.l #$ffffffff,d5  ;toggle all bits in D5
bra	myphere

singlepix:
move.w #$8000,d4     ;set ON pixel mask
lsr.w d3,d4          ;shift right D3 times
move.l #$80008000,d5 ;set OFF pixel mask
lsr.l d3,d5          ;shift right D3 times
eor.l #$ffffffff,d5  ;toggle all bits in D5
and.l d5,(a0)        ;turn off old pixel
and.l d5,4(a0)       ;(both longwords)

******************************
* Now turn on the new pixel! *
******************************

* 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:
adda.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!

**********************
* get low-rez pixel  *
* get0(scrnbase,x,y) *
**********************
*gets pixel in hiden screen

mygetpix:
move.l hiden,a1
clr.w d0		;zero result register
move.w pixely,d3	;get Y coordinate
and.l #$0000ffff,d3	;mask off for multiply
mulu #160,d3		;multiply by 160 (# of bytes per scan line)
adda.l d3,a1		;add to screen base address
move.w pixelx,d1	;get X coordinate
move.w d1,d2		;duplicate it in D2
lsr.w #1,d1		;divide it by 2
and.w #$00f8,d1		;turn off lower 3 bits
adda.w d1,a1		;add to screen address register

move.w (a1),d3		;grab screen word
and.l #15,d2		;mask X to 0-15
move.w #$8000,d1	;set up bit mask
lsr.w d2,d1		;shift bit mask 0-15 bits
and.w d1,d3		;mask off bit 0
beq bit0b		;bit's off, go get next color bit
move.w #1,d0		;turn on bit 0 in result

bit0b:
move.w 2(a1),d3		;get screen word for bit 1 of color
and.w d1,d3		;get bit 1
beq bit0c		;it's off, try bit 2
or.w #2,d0		;turn on bit 1 in result

bit0c:
move.w 4(a1),d3		;get screen word for bit 2
and.w d1,d3		;get bit 2
beq bit0d		;it's off, try bit 3
or.w #4,d0		;turn on bit 2 in result

bit0d:
move.w 6(a1),d3		;get word for bit 3
and.w d1,d3		;get bit 3
beq getx0		;it's off!
or.w #8,d0		;turn on bit 3 in result

getx0:
rts
*************************************************
linea:  dc.w    $a000
        move.l  a0,linepar
        move.l  8(a0),intin
        move.l  12(a0),ptsin
        rts

*************************************************

***********************fancy clear screen****************
clearsc:move.l  #99,d0
        move.l  screen,a0
cl1:    move.w  #159,d1
cl2:    move.w  #0,(a0)+
        dbf     d1,cl2
        addi.l  #160,a0
        dbf     d0,cl1
        move.w  #99,d0
        move.l  screen,a0
        addi.l  #160,a0
cl3:    move.w  #159,d1
cl4:    move.w  #0,(a0)+
        dbf     d1,cl4
        addi.l  #160,a0
        dbf     d0,cl3
        rts


cldel:  move.w  #3000,d2
cdel1:  nop
        dbf     d2,cdel1
        rts
********************************
copyintoboth:
        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
	rts
**********************routine to print a dec nuber*************
prtnum: 
	move.w	#0,times
        move.l  #0,d7
        move.w  number,d7
        andi.l  #$ffff,d7
        move.l  #line,a5

dodec:  move.l  d7,d6
        divu    #10,d6
        move.w  d6,d7
        swap    d6
*        addi.w  #16,d6
        move.b  d6,(a5)+
        cmpi.w  #0,d7
        bne     dodec
	
out:    cmpa.l  #line,a5
        beq     decback
        move.b  -(a5),d7
        andi.w  #$ff,d7
	lea	numbers,a0
	mulu	#40,d7
	add.w	d7,a0
	move.w	#9,d0
	move.l	hiden,a1
	adda.w	numwhere,a1
oloop:
	move.b	(a0)+,(a1)
	move.b	(a0)+,2(a1)
	move.b	(a0)+,4(a1)
	move.b	(a0)+,6(a1)
	add.l	#160,a1
	dbf	d0,oloop
	addq.w	#1,times
	cmpi.w	#2,times
	blt	oh
	move.w	#0,times
	addq.w	#6,numwhere
oh:	addq.w	#1,numwhere
	
	bra	out
	rts        
decback:
	rts
times:	blk.w	1,0

prtnum2: 
        move.l  #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
        addi.w  #48,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
        move.w  d7,-(sp)
        move.w  #2,-(sp)
        trap    #1
        addq.l  #4,sp
        bra     out2

decback2:
	rts
*************puts my mouse interupt in***************** 

mx:	blk.w	1,0
my:	blk.w	1,0
buttondat:	blk.w	1,0
mmin:	blk.w	1,0
mmax:	blk.w	1,0
mmin2:	blk.w	1,0
mmax2:	blk.w	1,0
************get screen address***************
getscrn:move.w  #2,-(sp)
        trap    #14
        addq.l  #2,sp
        move.l  d0,screen
        move.l  d0,screen1
        move.l  d0,screen2
        subi.l  #$8000,screen2
        move.l  screen1,seen
        move.l  screen2,hiden
	move.l	screen2,screen3
	subi.l	#$8000,screen3
	move.l	#ytable2,ytable
	move.l	#ytable1,sytable
        rts

************change colors****************
docolors:
	move.l temppal,-(sp)
        move.w #6,-(sp)
        trap #14
        addq.l #6,sp
        rts
************change colors****************

darkcolors:
        move.l #palette2,-(sp)
        move.w #6,-(sp)
        trap #14
        addq.l #6,sp
        rts

*****************wait for a key*********************
wait:   move.w  $26e6,d0
        cmpi.w  #2,d0
        beq     wback
        bra     wait
wback:  rts
***************turn mouse off***********************
mousof: dc.w    $a00a   
        rts

oldmouse:	blk.l	1,0
*************puts my mouse interupt in***************** 
putrout:move.w  #34,-(sp)
        trap    #14
        addq.l  #2,sp
        move.l  d0,a0
	move.l	16(a0),oldmouse
        move.l  #myrout,16(a0)

*	move.w	#$0202,-(sp)
*	move.w	#$b,-(sp)
*	move.w	#4,-(sp)
*	move.w	#3,-(sp)
*	trap	#13
*	addq	#8,sp
        rts
**************my ubeut mouse interupt*******************
myrout:
	movem.l	d0-d2/a0-a1,-(sp)
	moveq	#0,d0	
	move.b	(a0),d0
	cmpi.b	#$fa,d0
	bne	myr1
	move.w	#1,buttondat
	bra	myrxy
myr1:
	cmpi.b	#$f9,d0
	bne	myr2
	move.w	#2,buttondat
	bra	myrxy
myr2:
	cmpi.b	#$fb,d0
	bne	myr3
	move.w	#3,buttondat
	bra	myrxy
myr3:
	move.w	#0,buttondat

myrxy:
	moveq	#0,d0
	move.b	1(a0),d0
	ext.w	d0
	moveq	#0,d1
	move.b	2(a0),d1
	ext.w	d1
	add.w	d0,mx
	tst.w	d1
	beq	myr4
	bmi	myr5
	moveq	#1,d1
	bra	myr6
myr5:	moveq	#-1,d1
myr6:	subq.w	#1,ycounter
	bpl	myr4
	add.w	d1,my
	move.w	#50,ycounter
myr4:	move.w	mx,d0
	move.w	my,d1
	bsr	extra
	move.w	d0,mx
	move.w	d1,my
	movem.l	(sp)+,d0-d2/a0-a1
	rts

extra:  cmpi.w	mmin,d0
        bge    .S extra1
        move.w	mmax,d0
        bra    .S extra2
extra1: cmpi.w   mmax,d0
        ble    .S extra2
        move.w  mmin,d0
extra2:	cmpi.w  mmin2,d1
        bge    .S extra3
        move.w  mmin2,d1
        bra	extra4
extra3: cmpi.w   mmax2,d1
        ble    .S extra4
        move.w  mmax2,d1
extra4:
        rts

ycounter:	blk.w	1,0
*******************************************************************
; 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    D0,-(SP)        ;Save handle

        move.l  #dummy,-(SP)    ;load pallette into safe area
        move.l  #128,-(SP)       ;length to read in
        move    D0,-(SP)        ;Handle
        move    #$3F,-(SP)      ;bios number
        trap    #1              ;Read file in
        addi.l   #12,SP
        move    (sp),d0        
               
        move.l  screen3,-(SP)    ;load it straight onto screen
        move.l  #32000,-(SP)    ;length to read in
        move    D0,-(SP)        ;Handle
        move    #$3F,-(SP)      ;bios number
        trap    #1              ;Read file in
        addi.l   #12,SP
                
        move    #$3E,-(SP)      ;Handle already on stack
        trap    #1              ;Close file
        addq.l  #4,SP
        rts

*********************************************************
*********************************************************
loadtitle:
	move    #0,-(SP)        ;Open file
        move.l  #filescreen3,-(SP) ;Address of filename
        move    #$3D,-(SP)
        trap    #1              ;Get handle number in D0
        addq.l  #8,SP
                
        move    D0,-(SP)        ;Save handle

        move.l  #dummy,-(SP)    ;load pallette into safe area
        move.l  #128,-(SP)       ;length to read in
        move    D0,-(SP)        ;Handle
        move    #$3F,-(SP)      ;bios number
        trap    #1              ;Read file in
        addi.l   #12,SP
        move    (sp),d0        
               
*        move.l  screen4,-(SP)    ;load it straight onto screen
        move.l  #32000,-(SP)    ;length to read in
        move    D0,-(SP)        ;Handle
        move    #$3F,-(SP)      ;bios number
        trap    #1              ;Read file in
        addi.l   #12,SP
                
        move    #$3E,-(SP)      ;Handle already on stack
        trap    #1              ;Close file
        addq.l  #4,SP
        rts

filescreen3:
	dc.b	'title.neo',0
	even
******************************
*******************blocks for rotated sprites*************
gtemp:		blk.w	5000,0
gmask:		blk.w	5000,0
offset:		blk.w	1,0
origptr:	blk.l	1,0
screen3:	blk.l   1,0
pblock: 	blk.l   50
screen: 	blk.l   1
screen2:	blk.l   1
screen1:	blk.l   1
dummy:  	blk.l   32
filename:       blk.l	1,0
filediscs:	dc.b	'disc3.neo',0  
even
line:		blk.b   10
number: 	blk.w   1
even
ships:		blk.w	1,0
intin:  	blk.l   1
ptsin:  	blk.l   1
putpix: 	equ     $a001
getpix: 	equ     $a002
seen:   	blk.l   1
hiden:  	blk.l   1
palette2:
        	dc.w    $0000,$0000,$0000
        	dc.w    $0000,$0000,$0000
        	dc.w    $0000,$0000,$0000
        	dc.w    $0000,$0000,$0000
        	dc.w    $0000,$0000,$0000
        	dc.w    $0000
rnd:            blk.l   2,0
score:          blk.w   1,0
level:          blk.w   1,0
linepar:        blk.l   1,0
pulsecol:	blk.w	1,0

titlepalette:
	dc.w	$0000,$0777,$0555,$0333,$0007,$0005,$0004,$0477
	dc.w	$0366,$0244,$0570,$0460,$0340,$0700,$0600,$0700

palette1:
	dc.w	$0000,$0507,$0223,$0112,$0077,$0007,$0005,$0003
	dc.w	$0732,$0521,$0700,$0305,$0304,$0070,$0373,$0773

temppal:
	blk.l	1,0


mymantemp:
	 dc.w	$0000,$0000,$000F,$0000,$0000,$0000,$0000,$0000
	 dc.w	$000F,$0000,$001F,$0000,$0000,$0000,$8000,$0000
	 dc.w	$0010,$000F,$001F,$0000,$8000,$0000,$8000,$0000
	 dc.w	$0010,$000F,$001F,$0000,$8000,$0000,$8000,$0000
	 dc.w	$0019,$001F,$001F,$0000,$8000,$8000,$8000,$0000
	 dc.w	$000F,$000F,$000F,$0000,$0000,$0000,$0000,$0000
	 dc.w	$003F,$0000,$003F,$0000,$C000,$0000,$C000,$0000
	 dc.w	$00FF,$0000,$00FF,$0000,$F000,$0000,$F000,$0000
	 dc.w	$01C0,$0036,$01FF,$0000,$3800,$C000,$F800,$0000
	 dc.w	$0180,$006F,$01FF,$0000,$1800,$6000,$F800,$0000
	 dc.w	$0100,$00EF,$01FF,$0000,$0800,$7000,$F800,$0000
	 dc.w	$0100,$02FF,$01FF,$0200,$0800,$F400,$F800,$0400
	 dc.w	$03C6,$0079,$027F,$0186,$3C00,$E000,$E400,$1800
	 dc.w	$0240,$01FF,$03FF,$0000,$2400,$F800,$FC00,$0000
	 dc.w	$04A0,$03B9,$07BF,$0000,$5200,$DC00,$DE00,$0000
	 dc.w	$0530,$033F,$073F,$0000,$4200,$CC00,$CE00,$0000
	 dc.w	$0F30,$073F,$0F3F,$0000,$CF00,$CE00,$CF00,$0000
	 dc.w	$1230,$0E3F,$1E3F,$0000,$C480,$C700,$C780,$0000
	 dc.w	$6C3F,$1C3F,$7C3F,$0000,$C360,$C380,$C3E0,$0000
	 dc.w	$903F,$7000,$F03F,$0000,$C090,$00E0,$C0F0,$0000
	 dc.w	$407F,$C000,$C07F,$0000,$E020,$0030,$E030,$0000
	 dc.w	$005F,$0020,$007F,$0000,$A000,$4000,$E000,$0000
	 dc.w	$00CF,$0070,$00FF,$0000,$3000,$E000,$F000,$0000
	 dc.w	$00F6,$007F,$00FF,$0000,$F000,$E000,$F000,$0000
	 dc.w	$0139,$00F9,$01F9,$0000,$C800,$F000,$F800,$0000
	 dc.w	$0130,$00F0,$01F0,$0000,$C800,$F000,$F800,$0000
	 dc.w	$0130,$00F0,$01F0,$0000,$C800,$F000,$F800,$0000
	 dc.w	$0220,$01E0,$03E0,$0000,$4400,$7800,$7C00,$0000
	 dc.w	$0260,$01E0,$03E0,$0000,$6400,$7800,$7C00,$0000
	 dc.w	$04C0,$03C0,$07C0,$0000,$3200,$3C00,$3E00,$0000
	 dc.w	$0080,$0780,$0780,$0000,$1000,$1E00,$1E00,$0000
	 dc.w	$0080,$0780,$0780,$0000,$1000,$1E00,$1E00,$0000
	 dc.w	$0180,$0780,$0780,$0000,$1800,$1E00,$1E00,$0000
	 dc.w	$0100,$0700,$0700,$0000,$0800,$0E00,$0E00,$0000
	 dc.w	$0100,$0700,$0700,$0000,$0800,$0E00,$0E00,$0000
	 dc.w	$0200,$0600,$0600,$0000,$0400,$0600,$0600,$0000
	 dc.w	$0A00,$0600,$0E00,$0000,$0500,$0600,$0700,$0000
	 dc.w	$127F,$0E7F,$1E00,$0000,$E480,$E700,$0780,$0000
	 dc.w	$FFFF,$FFFF,$3E00,$0000,$FFF0,$FFF0,$07C0,$0000


bdisc0:	 dc.w	$0000,$0000,$0FF0,$0000,$0FF0,$0000,$3FFC,$0000
	 dc.w	$0FF0,$0000,$3FFC,$0000,$0000,$0000,$0FF0,$0000
bdisc1:	 dc.w	$0000,$0000,$03C0,$0000
	 dc.w	$03C0,$0000,$0FF0,$0000,$0000,$0000,$03C0,$0000
bdisc2:	 dc.w	$0000,$0000,$0100,$0000,$0100,$0000,$07C0,$0000
	 dc.w	$0000,$0000,$0100,$0000

rdisc0:	 dc.w	$0000,$0000,$0000,$0FF0,$0000,$0FF0,$0000,$3FFC
	 dc.w	$0000,$0FF0,$0000,$3FFC,$0000,$0000,$0000,$0FF0
rdisc1:	 dc.w	$0000,$0000,$0000,$03C0
	 dc.w	$0000,$03C0,$0000,$0FF0,$0000,$0000,$0000,$03C0
rdisc2:	 dc.w	$0000,$0000,$0000,$0100,$0000,$0100,$0000,$07C0
	 dc.w	$0000,$0000,$0000,$0100


sdisc0:	 dc.w	$0FF0,$0FF0,$0000,$0000,$3FFC,$3FFC,$0000,$0000
	 dc.w	$3FFC,$3FFC,$0000,$0000,$0FF0,$0FF0,$0000,$0000
sdisc1:	 dc.w	$03C0,$03C0,$0000,$0000
	 dc.w	$0FF0,$0FF0,$0000,$0000,$03C0,$03C0,$0000,$0000
sdisc2:	 dc.w	$0100,$0100,$0000,$0000,$07C0,$07C0,$0000,$0000
	 dc.w	$0100,$0100,$0000,$0000


numbers:
	 dc.b	$7F,$FF,$00,$00,$81,$01,$7E,$00
	 dc.b	$9D,$21,$42,$00,$A5,$39,$42,$00
	 dc.b	$A5,$39,$42,$00,$A5,$39,$42,$00
	 dc.b	$A5,$39,$42,$00,$B9,$3D,$42,$00
	 dc.b	$81,$01,$7E,$00,$FE,$01,$00,$00
	 dc.b	$18,$FF,$00,$00,$28,$CF,$10,$00
	 dc.b	$28,$CF,$10,$00,$28,$CF,$10,$00
	 dc.b	$28,$CF,$10,$00,$28,$CF,$10,$00
	 dc.b	$28,$CF,$10,$00,$28,$CF,$10,$00
	 dc.b	$28,$CF,$10,$00,$30,$CF,$00,$00
	 dc.b	$7F,$FF,$00,$00,$81,$01,$7E,$00
	 dc.b	$FD,$01,$02,$00,$79,$FD,$02,$00
	 dc.b	$81,$01,$7E,$00,$9E,$21,$40,$00
	 dc.b	$A0,$3F,$40,$00,$BF,$3F,$40,$00
	 dc.b	$81,$01,$7E,$00,$FE,$01,$00,$00
	 dc.b	$7F,$FF,$00,$00,$81,$01,$7E,$00
	 dc.b	$FD,$01,$02,$00,$39,$FD,$02,$00
	 dc.b	$41,$81,$3E,$00,$7D,$81,$02,$00
	 dc.b	$05,$F9,$02,$00,$79,$FD,$02,$00
	 dc.b	$81,$01,$7E,$00,$FE,$01,$00,$00
	 dc.b	$63,$FF,$00,$00,$A5,$39,$42,$00
	 dc.b	$A5,$39,$42,$00,$B9,$3D,$42,$00
	 dc.b	$81,$01,$7E,$00,$FD,$01,$02,$00
	 dc.b	$05,$F9,$02,$00,$05,$F9,$02,$00
	 dc.b	$05,$F9,$02,$00,$06,$F9,$00,$00
	 dc.b	$7F,$FF,$00,$00,$81,$01,$7E,$00
	 dc.b	$BE,$01,$40,$00,$BF,$3F,$40,$00
	 dc.b	$81,$01,$7E,$00,$F9,$05,$02,$00
	 dc.b	$05,$FD,$02,$00,$7D,$FD,$02,$00
	 dc.b	$81,$01,$7E,$00,$FE,$01,$00,$00
	 dc.b	$7F,$FF,$00,$00,$81,$01,$7E,$00
	 dc.b	$BE,$01,$40,$00,$BF,$3F,$40,$00
	 dc.b	$81,$01,$7E,$00,$9D,$21,$42,$00
	 dc.b	$A5,$39,$42,$00,$B9,$3D,$42,$00
	 dc.b	$81,$01,$7E,$00,$FE,$01,$00,$00
	 dc.b	$7F,$FF,$00,$00,$81,$01,$7E,$00
	 dc.b	$FD,$01,$02,$00,$05,$F9,$02,$00
	 dc.b	$05,$F9,$02,$00,$05,$F9,$02,$00
	 dc.b	$05,$F9,$02,$00,$05,$F9,$02,$00
	 dc.b	$05,$F9,$02,$00,$06,$F9,$00,$00
	 dc.b	$7F,$FF,$00,$00,$81,$01,$7E,$00
	 dc.b	$9D,$21,$42,$00,$B9,$3D,$42,$00
	 dc.b	$81,$01,$7E,$00,$9D,$21,$42,$00
	 dc.b	$A5,$39,$42,$00,$B9,$3D,$42,$00
	 dc.b	$81,$01,$7E,$00,$FE,$01,$00,$00
	 dc.b	$7F,$FF,$00,$00,$81,$01,$7E,$00
	 dc.b	$9D,$21,$42,$00,$B9,$3D,$42,$00
	 dc.b	$81,$01,$7E,$00,$FD,$01,$02,$00
	 dc.b	$05,$F9,$02,$00,$05,$F9,$02,$00
	 dc.b	$05,$F9,$02,$00,$06,$F9,$00,$00

rsprite:
	 dc.w	$0000,$0000,$FFF0,$0000,$0000,$0008,$9040,$0000
	 dc.w	$0000,$0000,$9024,$0000,$0000,$0000,$9024,$0000
	 dc.w	$0000,$0000,$9024,$0000,$0000,$0000,$9058,$0000
	 dc.w	$4000,$0000,$9FE0,$4000,$6600,$0000,$9900,$6600
	 dc.w	$6300,$0000,$9480,$6300,$0000,$0000,$9240,$6180
	 dc.w	$0000,$0000,$9120,$60C0,$6060,$6060,$F0F0,$0000
	 dc.w	$6030,$6030,$F078,$0000,$0000,$0000,$F03C,$0000

asprite:
	 dc.w	$0000,$0010,$3FE0,$0000,$0008,$0000,$4840,$0000
	 dc.w	$0000,$0000,$9024,$0000,$0000,$0000,$9024,$0000
	 dc.w	$0000,$0000,$9024,$0000,$0000,$0000,$9024,$0000
	 dc.w	$4008,$0000,$9024,$4008,$6018,$0000,$9FE4,$6018
	 dc.w	$6018,$0000,$9024,$6018,$0000,$0000,$9024,$6018
	 dc.w	$0000,$0000,$9024,$6018,$6018,$6018,$F03C,$0000
	 dc.w	$6018,$6018,$F03C,$0000,$0000,$0000,$F03C,$0000

msprite:
	 dc.w	$2000,$4000,$8007,$0000,$0000,$0000,$9009,$0000
	 dc.w	$0000,$0000,$8811,$0000,$0000,$0000,$8421,$0000
	 dc.w	$0000,$0000,$9249,$0000,$0000,$0000,$9999,$0000
	 dc.w	$4242,$0000,$9429,$4242,$6186,$0000,$9249,$6186
	 dc.w	$6006,$0000,$9189,$6006,$0000,$0000,$9009,$6006
	 dc.w	$0000,$0000,$9009,$6006,$6006,$6006,$F00F,$0000
	 dc.w	$6006,$6006,$F00F,$0000,$0000,$0000,$F00F,$0000

wsprite:
	 dc.w	$0041,$0002,$F38C,$0000,$0000,$0001,$9248,$0000
	 dc.w	$0000,$0000,$9249,$0000,$0000,$0000,$9249,$0000
	 dc.w	$0002,$0000,$9249,$0002,$0086,$0000,$9249,$0086
	 dc.w	$4186,$0000,$9249,$4186,$6180,$0000,$9249,$6186
	 dc.w	$6000,$0000,$9249,$6186,$0006,$0006,$924F,$6180
	 dc.w	$0186,$0186,$93CF,$6000,$6184,$6184,$F3CF,$0000
	 dc.w	$6000,$6000,$F7DE,$0000,$0000,$0000,$FEF8,$0000

esprite:
	 dc.w	$0004,$0008,$FFF0,$0000,$0000,$0000,$9000,$0000
	 dc.w	$0000,$0000,$9000,$0000,$0000,$0000,$9000,$0000
	 dc.w	$0000,$0000,$9000,$0000,$0000,$0000,$9000,$0000
	 dc.w	$2010,$0020,$9FC0,$2000,$6000,$0000,$9000,$6000
	 dc.w	$6000,$0000,$9000,$6000,$0000,$0000,$9000,$6000
	 dc.w	$0000,$0000,$9000,$6000,$6000,$6000,$F000,$0000
	 dc.w	$6000,$6000,$F000,$0000,$0000,$0000,$FFFC,$0000

even
*350
rampat:
 dc.w 161,022
 dc.w 160,022
 dc.w 159,022
 dc.w 158,022
 dc.w 157,022
 dc.w 156,022
 dc.w 154,022
 dc.w 152,022
 dc.w 150,022
 dc.w 149,022
 dc.w 147,022
 dc.w 146,022
 dc.w 144,022
 dc.w 142,022
 dc.w 140,022
 dc.w 139,022
 dc.w 137,022
 dc.w 136,022
 dc.w 134,022
 dc.w 132,022
 dc.w 131,021
 dc.w 129,020
 dc.w 127,020
 dc.w 126,019
 dc.w 124,018
 dc.w 122,017
 dc.w 121,016
 dc.w 119,015
 dc.w 118,014
 dc.w 117,013
 dc.w 116,012
 dc.w 116,011
 dc.w 116,010
 dc.w 116,009
 dc.w 116,008
 dc.w 117,007
 dc.w 118,006
 dc.w 118,005
 dc.w 120,004
 dc.w 121,003
 dc.w 122,002
 dc.w 123,001
 dc.w 125,001
 dc.w 126,000
 dc.w 127,000
 dc.w 128,000
 dc.w 129,000
 dc.w 130,000
 dc.w 131,000
 dc.w 132,000
 dc.w 133,000
 dc.w 134,000
 dc.w 135,001
 dc.w 135,002
 dc.w 136,003
 dc.w 137,004
 dc.w 138,005
 dc.w 138,007
 dc.w 138,009
 dc.w 138,010
 dc.w 138,011
 dc.w 138,012
 dc.w 138,013
 dc.w 138,014
 dc.w 137,015
 dc.w 135,016
 dc.w 133,017
 dc.w 132,017
 dc.w 131,017
 dc.w 129,017
 dc.w 127,017
 dc.w 126,017
 dc.w 124,017
 dc.w 123,017
 dc.w 122,017
 dc.w 121,017
 dc.w 121,016
 dc.w 120,016
 dc.w 120,014
 dc.w 120,013
 dc.w 120,011
 dc.w 120,010
 dc.w 120,008
 dc.w 121,007
 dc.w 122,006
 dc.w 123,005
 dc.w 124,004
 dc.w 126,003
 dc.w 127,002
 dc.w 129,001
 dc.w 131,000
 dc.w 133,000
 dc.w 135,000
 dc.w 138,000
 dc.w 140,000
 dc.w 142,000
 dc.w 144,000
 dc.w 146,000
 dc.w 148,000
 dc.w 150,000
 dc.w 151,000
 dc.w 154,000
 dc.w 156,000
 dc.w 159,000
 dc.w 161,000
 dc.w 164,000
 dc.w 166,000
 dc.w 168,000
 dc.w 171,000
 dc.w 173,000
 dc.w 175,000
 dc.w 178,000
 dc.w 180,000
 dc.w 183,000
 dc.w 186,000
 dc.w 188,000
 dc.w 190,000
 dc.w 192,000
 dc.w 194,000
 dc.w 197,000
 dc.w 200,000
 dc.w 202,000
 dc.w 204,000
 dc.w 207,000
 dc.w 210,000
 dc.w 212,000
 dc.w 215,000
 dc.w 217,000
 dc.w 219,000
 dc.w 221,000
 dc.w 223,000
 dc.w 225,000
 dc.w 226,000
 dc.w 228,000
 dc.w 230,000
 dc.w 231,000
 dc.w 234,000
 dc.w 236,000
 dc.w 238,000
 dc.w 240,000
 dc.w 242,000
 dc.w 243,000
 dc.w 245,000
 dc.w 246,000
 dc.w 248,000
 dc.w 250,000
 dc.w 251,000
 dc.w 253,000
 dc.w 254,000
 dc.w 256,000
 dc.w 258,000
 dc.w 259,000
 dc.w 261,000
 dc.w 263,000
 dc.w 265,000
 dc.w 266,000
 dc.w 268,000
 dc.w 270,001
 dc.w 272,001
 dc.w 273,001
 dc.w 274,001
 dc.w 276,002
 dc.w 277,002
 dc.w 278,003
 dc.w 279,003
 dc.w 280,004
 dc.w 280,005
 dc.w 280,006
 dc.w 281,007
 dc.w 281,008
 dc.w 282,009
 dc.w 282,011
 dc.w 282,012
 dc.w 282,013
 dc.w 282,015
 dc.w 282,016
 dc.w 282,017
 dc.w 282,018
 dc.w 281,019
 dc.w 281,020
 dc.w 280,021
 dc.w 279,022
 dc.w 278,022
 dc.w 276,022
 dc.w 274,022
 dc.w 272,022
 dc.w 270,022
 dc.w 268,022
 dc.w 267,022
 dc.w 265,022
 dc.w 263,022
 dc.w 262,022
 dc.w 261,020
 dc.w 260,019
 dc.w 259,018
 dc.w 259,016
 dc.w 259,015
 dc.w 259,014
 dc.w 259,012
 dc.w 259,011
 dc.w 259,010
 dc.w 259,009
 dc.w 260,008
 dc.w 261,007
 dc.w 262,006
 dc.w 263,005
 dc.w 264,004
 dc.w 265,003
 dc.w 266,003
 dc.w 267,002
 dc.w 268,002
 dc.w 269,002
 dc.w 270,002
 dc.w 272,002
 dc.w 274,002
 dc.w 275,002
 dc.w 276,002
 dc.w 277,003
 dc.w 278,003
 dc.w 278,004
 dc.w 279,005
 dc.w 279,007
 dc.w 280,007
 dc.w 280,009
 dc.w 280,011
 dc.w 280,012
 dc.w 280,013
 dc.w 280,014
 dc.w 279,015
 dc.w 279,016
 dc.w 279,017
 dc.w 278,018
 dc.w 277,019
 dc.w 275,020
 dc.w 274,021
 dc.w 273,022
 dc.w 272,022
 dc.w 271,022
 dc.w 270,022
 dc.w 269,022
 dc.w 267,022
 dc.w 266,022
 dc.w 265,022
 dc.w 263,022
 dc.w 262,022
 dc.w 261,022
 dc.w 259,022
 dc.w 258,022
 dc.w 257,022
 dc.w 256,022
 dc.w 255,022
 dc.w 254,022
 dc.w 253,022
 dc.w 252,022
 dc.w 251,022
 dc.w 250,022
 dc.w 249,022
 dc.w 248,022
 dc.w 247,022
 dc.w 246,022
 dc.w 245,022
 dc.w 244,022
 dc.w 243,022
 dc.w 242,022
 dc.w 241,022
 dc.w 240,022
 dc.w 239,022
 dc.w 238,022
 dc.w 237,022
 dc.w 236,022
 dc.w 235,022
 dc.w 234,022
 dc.w 233,022
 dc.w 232,022
 dc.w 231,022
 dc.w 230,022
 dc.w 229,022
 dc.w 228,022
 dc.w 227,022
 dc.w 226,022
 dc.w 225,022
 dc.w 224,022
 dc.w 223,022
 dc.w 222,022
 dc.w 221,022
 dc.w 220,022
 dc.w 219,022
 dc.w 218,022
 dc.w 217,022
 dc.w 216,022
 dc.w 215,022
 dc.w 214,022
 dc.w 213,022
 dc.w 212,022
 dc.w 211,022
 dc.w 210,022
 dc.w 209,022
 dc.w 208,022
 dc.w 207,022
 dc.w 206,022
 dc.w 205,022
 dc.w 204,022
 dc.w 203,022
 dc.w 202,022
 dc.w 201,022
 dc.w 200,022
 dc.w 199,022
 dc.w 198,022
 dc.w 197,022
 dc.w 196,022
 dc.w 195,022
 dc.w 194,022
 dc.w 193,022
 dc.w 192,022
 dc.w 191,022
 dc.w 190,022
 dc.w 189,022
 dc.w 188,022
 dc.w 187,022
 dc.w 186,022
 dc.w 185,022
 dc.w 184,022
 dc.w 183,022
 dc.w 182,022
 dc.w 181,022
 dc.w 180,022
 dc.w 179,022
 dc.w 178,022
 dc.w 177,022
 dc.w 176,022
 dc.w 175,022
 dc.w 174,022
 dc.w 173,022
 dc.w 172,022
 dc.w 171,022
 dc.w 170,022
 dc.w 169,022
 dc.w 168,022
 dc.w 167,022
 dc.w 166,022
 dc.w 165,022
 dc.w 164,022
 dc.w 163,022
 dc.w 162,022
 dc.w 161,022
 dc.w 160,022
 dc.w 159,022
 dc.w 158,022
 dc.w 157,022
 dc.w 156,022
 dc.w 175,022
