*	sound stuff	*
soundstarth:	equ	2
soundstartm:	equ	4
soundstartl:	equ	6
soundendh:	equ	$e
soundendm:	equ	$10
soundendl:	equ	$12
soundmode:	equ	$20
sounddma:	equ	0

*	blitter stuff	*
halftone:	equ	0
src_xinc:	equ	32
src_yinc:	equ	34
src_addr:	equ	36
endmask1:	equ	40
endmask2:	equ	42
endmask3:	equ	44
dst_xinc:	equ	46
dst_yinc:	equ	48
dst_addr:	equ	50
x_count:	equ	54
y_count:	equ	56
hop:		equ	58
op:		equ	59
line_num:	equ	60
skew:		equ	61
fhop_source:	equ	1
fhop_halftone:	equ	0
fskewfxsr:	equ	7
fskewnfsr:	equ	6
flinebusy:	equ	7
flinehog:	equ	6
flinesmudge:	equ	5
mhop_source:	equ	$02
mhop_halftone:	equ	$01
mskewfxsr:	equ	$80
mskewnfsr:	equ	$40
mlinebusy:	equ	$80
mlinehog:	equ	$40
mlinesmudge:	equ	$20


cspritex:	equ	0
cspritey:	equ	2
cspriteheight:	equ	8
cspritewidth:	equ	10
cspritead:	equ	4
nsamount2:	equ	1
ewamount2:	equ	1
nsamount:	equ	25
ewamount:	equ	25
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	1650
magic2:		equ	1650
numstars:	equ	12
speed:		equ	350
zclip:		equ	100
start:
	clr.l   -(SP)           ;Go into supervisor mode
        move.w  #$20,-(SP)
        trap    #1
        addq.l  #6,SP
        move.l  D0,savesup

	move.l	$426,rvsave
	move.l	$42a,resave
	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
	lea	palsave,a0
	move.l	#$ff8240,a1
	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)+

setupkey:
	move.w	#1,-(sp)
	move.w	#14,-(sp)
	trap	#14
	addq.l	#4,sp
	move.l	d0,keybuf


	lea	bluepalette,a0
	jsr	mydocolors
	jsr	putrout
	jsr	getscrn
	jsr	clearboth
	jsr	setuphbl
	jsr	plotinit
	move.l	#box,whichob
testloop:
	jsr	keyboard
*	jsr	clearpanel
*	jsr	doreadouts
	jsr	testdraw
	jsr	flip_scr2
	bra	testloop
*********************************************************
*	clipped sprite header				*
*********************************************************
ballsp2:
	dc.w	50,50		;x,y
	dc.l	balldata0	;address of bank of 16 prerotated sprites
	dc.w	8		;height
	dc.w	8
ballsp1:
	dc.w	50,50		;x,y
	dc.l	balldata1	;address of bank of 16 prerotated sprites
	dc.w	16		;height
	dc.w	16
ballsp0:
	dc.w	50,50		;x,y
	dc.l	balldata2	;address of bank of 16 prerotated sprites
	dc.w	16		;height
	dc.w	16

*********************************************************
*	draw prerotated and clippped sprite		*
*	pass address of sprite header in a0		*
*********************************************************
drawclipped:
	cmpi.w	#0,cspritex(a0)
	ble	nosprite
	cmpi.w	#cxmax,cspritex(a0)
	bgt	nosprite
	move.w	cspritex(a0),d2 	;get x
	move.w	d2,d0
	move.w	d0,d4
	move.w	cspritey(a0),d1 ;get y
	move.w	d1,d5
	and.w	#15,d2		;get last 4 bits=offset
	move.w	d2,d3		;get a copy of last 4 bits

	move	cspriteheight(a0),d7		;counter before clipping
	move.w	#cymin,d6	;is it above cymin
	cmp.w	d6,d5
	bge	spcl1
	sub.w	d5,d6		;gives number of lines missing
	sub.w	d6,d7		;for counter
	mulu	#20,d6		;for add to sprite data address
	move.l	hiden,a6
	lea	cymin*160(a6),a6
	bra	spcl2
spcl1:
	moveq	#0,d6
	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
spcl2:
	and.w	#$fff0,d0	;word
	lsr.w	#1,d0
	add.w	d0,a6		;a6 has actual screen address


	move.w	#cymax,d1
	sub.w	cspriteheight(a0),d1
	cmp.w	d1,d5
	ble	spcl3
	sub.w	d1,d5
	sub.w	d5,d7

spcl3:
	cmpi.w	#4,cspriteheight(a0)
	bne	spcl4
	move.l	cspritead(a0),a1
	lsl.w	#4,d3		;*16
	add.w	d3,a1		;a1 has ad of final sprite data
	lsl.w	#2,d3
	add.w	d3,a1
	add.w	d6,a1		;adjust for top yclip
	bra	extrastuff
spcl4:
	cmpi.w	#8,cspriteheight(a0)
	bne	spcl5
	move.l	cspritead(a0),a1
	lsl.w	#5,d3		;*16
	add.w	d3,a1		;a1 has ad of final sprite data
	lsl.w	#2,d3
	add.w	d3,a1
	add.w	d6,a1		;adjust for top yclip
	bra	extrastuff

spcl5:
	move.l	cspritead(a0),a1
	lsl.w	#6,d3		;*128
	add.w	d3,a1		;a1 has ad of final sprite data
	lsl.w	#2,d3
	add.w	d3,a1
	add.w	d6,a1		;adjust for top yclip

extrastuff:
	cmpi.w	#cxmin,d4
	bge	spcl6
	bra	clipleftsprite
spcl6:
	cmpi.w	#cxmax-16,d4
	ble	doallsprite
*	fall through

cliprightsprite:
	subq.w	#1,d7
	bmi	nosprite
crightloop:
	move.w	(a6),d0 	;get 4 screen words
	move.w	2(a6),d1
	move.w	4(a6),d2
	move.w	6(a6),d3
	and.w	(a1),d0 	;mask word
	and.w	(a1),d1 	;mask word
	and.w	(a1),d2 	;mask word
	and.w	(a1)+,d3	;mask word
	or.w	(a1)+,d0	;or the sprite image in the hole
	or.w	(a1)+,d1	;we just cut
	or.w	(a1)+,d2
	or.w	(a1)+,d3
	move.w	d0,(a6)+	;put the picture in th picture
	move.w	d1,(a6)+
	move.w	d2,(a6)+
	move.w	d3,(a6)+

*	 add.l	 #10,a1
	lea	10(a1),a1
*	 add.l	 #144+8,a6		 ;move to next screen line
	lea	144+8(a6),a6
	dbf	d7,crightloop
	rts

clipleftsprite:
	subq.w	#1,d7
	bmi	nosprite
cleftloop:
*	 add.l	 #10,a1
	lea	10(a1),a1
*	 addq.l  #8,a6
	lea	8(a6),a6
	move.w	(a6),d0 	;get 4 screen words
	move.w	2(a6),d1
	move.w	4(a6),d2
	move.w	6(a6),d3
	and.w	(a1),d0 	;mask word
	and.w	(a1),d1 	;mask word
	and.w	(a1),d2 	;mask word
	and.w	(a1)+,d3	;mask word
	or.w	(a1)+,d0	;or the sprite image in the hole
	or.w	(a1)+,d1	;we just cut
	or.w	(a1)+,d2
	or.w	(a1)+,d3
	move.w	d0,(a6)+	;put the picture in th picture
	move.w	d1,(a6)+
	move.w	d2,(a6)+
	move.w	d3,(a6)+
*	 add.l	 #144,a6	 ;move to next screen line
	lea	144(a6),a6
	dbf	d7,cleftloop
nosprite:
	rts
doallsprite:
	subq.w	#1,d7
	bmi	nosprite
doallloop:
	move.w	(a6),d0 	;get 4 screen words
	move.w	2(a6),d1
	move.w	4(a6),d2
	move.w	6(a6),d3
	and.w	(a1),d0 	;mask word
	and.w	(a1),d1 	;mask word
	and.w	(a1),d2 	;mask word
	and.w	(a1)+,d3	;mask word
	or.w	(a1)+,d0	;or the sprite image in the hole
	or.w	(a1)+,d1	;we just cut
	or.w	(a1)+,d2
	or.w	(a1)+,d3
	move.w	d0,(a6)+	;put the picture in th picture
	move.w	d1,(a6)+
	move.w	d2,(a6)+
	move.w	d3,(a6)+

	move.w	(a6),d0 	;get 4 screen words
	move.w	2(a6),d1
	move.w	4(a6),d2
	move.w	6(a6),d3
	and.w	(a1),d0 	;mask word
	and.w	(a1),d1 	;mask word
	and.w	(a1),d2 	;mask word
	and.w	(a1)+,d3	;mask word
	or.w	(a1)+,d0	;or the sprite image in the hole
	or.w	(a1)+,d1	;we just cut
	or.w	(a1)+,d2
	or.w	(a1)+,d3
	move.w	d0,(a6)+	;put the picture in th picture
	move.w	d1,(a6)+
	move.w	d2,(a6)+
	move.w	d3,(a6)+
*	 add.l	 #144,a6	 ;move to next screen line
	lea	144(a6),a6
	dbf	d7,doallloop
	rts



setuphbl:
	move.w	#$2700,sr
	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
	move.l	hbl_vec,oldhblvec

*	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
*	move.b	#0,tbcr
*	move.b	#1,tbdr
*	move.b	#8,tbcr
	move.w	#$2300,sr
	rts

vbl_handler:
	move.b	seen+1,$ff8205
	move.b	seen+2,$ff8207
	move.b	seen+3,$ff8209
*	move.b	#0,tbcr
*	move.b	#151,tbdr
*	move.b	#8,tbcr
*	movem.l	a0-a1,-(sp)
*	move.l	whichob,a0
*	move.l	obcolors(a0),a0
*	lea	$ff8240,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)+
*	movem.l	(sp)+,a0-a1
vblt:	jmp	$0

key_handler:
	move.w	#$2500,sr
keyt:	jmp	$0


oldvblvec:	dc.l	0
oldkeyvec:	dc.l	0
oldhblvec:	dc.l	0
oldieb:		dc.b	0
oldiea:		dc.b	0
oldima:		dc.b	0
	even
restoremfp:
	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
	rts

*****************************************
clip_poly:
	move.l	a0,a1
	move.w	d7,d0
	lsl	#2,d0
	lea	-4(a1,d0.w),a2
	movem	(a2)+,d0/d1
	move	d0,d2
	move.w	d1,d3

*	move.w	2(a6),d6
	move.w	#cymin,d6
	cmp.w	d6,d3
	bge.s	next_cp1_t
	bra.s	next_cp2_t
cp_lp1_t:
	movem	(a1)+,d0/d1
	cmp.w	d6,d1
	bge.s	cp1_t
	bsr	horiz_cross
	moveq	#-1,d4
	bra.s	next_cp2_t
cp3_t:
	bsr	horiz_cross
cp1_t:
	move.w	d0,(a2)+
	move.w	d1,(a2)+
	move.w	d0,d2
	move.w	d1,d3
next_cp1_t:
	dbra	d7,cp_lp1_t
	bra.s	cp5_t
cp_lp2_t:
	move.w	d0,d2
	move.w	d1,d3
	movem	(a1)+,d0/d1
	cmp.w	d6,d1
next_cp2_t:
	dbge	d7,cp_lp2_t
	beq.s	cp1_t
	bgt.s	cp3_t

cp5_t:
	subq.l	#4,a2
	move.w	(a2)+,d0
	move.w	(a2)+,d1
	move.w	d0,d2
	move.w	d1,d3
	move.l	a2,d7
	sub.l	a1,d7
	beq	cp_off
	lsr	#2,d7
*	move.w	(a6),d6
	move.w	#cxmin,d6
	cmp.w	d6,d2
	bge.s	next_cp1_l
	bra.s	next_cp2_l
cp_lp1_l:
	movem	(a1)+,d0/d1
	cmp.w	d6,d0
	bge.s	cp1_l
	bsr	vert_cross
	moveq	#-1,d4
	bra.s	next_cp2_l
cp3_l:
	bsr	vert_cross
cp1_l:
	move.w	d0,(a2)+
	move.w	d1,(a2)+
	move.w	d0,d2
	move.w	d1,d3
next_cp1_l:
	dbra	d7,cp_lp1_l
	bra	cp5_l
cp_lp2_l:
	move.w	d0,d2
	move.w	d1,d3
	movem	(a1)+,d0/d1
	cmp	d6,d0
next_cp2_l:
	dbge	d7,cp_lp2_l
	beq.s	cp1_l
	bgt.s	cp3_l

cp5_l:
	subq.l	#4,a2
	move.w	(a2)+,d0
	move.w	(a2)+,d1
	move.w	d0,d2
	move.w	d1,d3
	move.l	a2,d7
	sub.l	a1,d7
	beq	cp_off
	lsr	#2,d7
*	move.w	(a6),d6
	move.w	#cymax,d6
	cmp.w	d6,d3
	ble.s	next_cp1_b
	bra.s	next_cp2_b
cp_lp1_b:
	movem	(a1)+,d0/d1
	cmp.w	d6,d1
	ble.s	cp1_b
	bsr	horiz_cross
	moveq	#1,d4
	bra.s	next_cp2_b
cp3_b:
	bsr	horiz_cross
cp1_b:
	move.w	d0,(a2)+
	move.w	d1,(a2)+
	move.w	d0,d2
	move.w	d1,d3
next_cp1_b:
	dbra	d7,cp_lp1_b
	bra	cp5_b
cp_lp2_b:
	move.w	d0,d2
	move.w	d1,d3
	movem	(a1)+,d0/d1
	cmp	d6,d1
next_cp2_b:
	dble	d7,cp_lp2_b
	beq.s	cp1_b
	blt.s	cp3_b

cp5_b:
	subq.l	#4,a2
	move.w	(a2)+,d0
	move.w	(a2)+,d1
	move.w	d0,d2
	move.w	d1,d3
	move.l	a2,d7
	sub.l	a1,d7
	beq	cp_off
	lsr	#2,d7
*	move.w	(a6),d6
	move.l	a0,a2
	move.w	#cxmax,d6
	cmp.w	d6,d2
	ble.s	next_cp1_r
	bra.s	next_cp2_r
cp_lp1_r:
	movem	(a1)+,d0/d1
	cmp.w	d6,d0
	ble.s	cp1_r
	bsr	vert_cross
	moveq	#1,d4
	bra.s	next_cp2_r
cp3_r:
	bsr.s	vert_cross
cp1_r:
	move.w	d0,(a2)+
	move.w	d1,(a2)+
	move.w	d0,d2
	move.w	d1,d3
next_cp1_r:
	dbra	d7,cp_lp1_r
	bra	cp5_r
cp_lp2_r:
	move.w	d0,d2
	move.w	d1,d3
	movem	(a1)+,d0/d1
	cmp	d6,d0
next_cp2_r:
	dble	d7,cp_lp2_r
	beq.s	cp1_r
	blt.s	cp3_r
cp5_r:
	move.l	a2,d7
	sub.l	a0,d7
	beq.s	cp_off
	lsr.w	#2,d7
	moveq	#0,d0
	rts
cp_off:
	moveq	#-1,d0
	rts
horiz_cross:
	move.w	d0,d4
	sub.w	d2,d4
	move.w	d1,d5
	sub.w	d6,d5
	muls	d5,d4
	move	d1,d5
	sub.w	d3,d5
	divs	d5,d4
	neg	d4
	add	d0,d4
	move.w	d4,(a2)+
	move.w	d6,(a2)+
	rts
vert_cross:
	move.w	d1,d4
	sub.w	d3,d4
	move.w	d0,d5
	sub.w	d6,d5
	muls	d5,d4
	move	d0,d5
	sub.w	d2,d5
	divs	d5,d4
	neg	d4
	add	d1,d4
	move.w	d6,(a2)+
	move.w	d4,(a2)+
	rts

surfacedfn:	dc.w	0	;color
		dc.l	surfacevrt
surfacevrt:	dc.w	0	;number of points
		ds.w	300

*****************************************
*	my own personal poly draw	*
*****************************************
draw_polygon3:
	movem.l	d0-d7/a0-a6,-(sp)
	move.w	surfacedfn,d0		;color
*	move.w	surfacedfn+2,d5
	lea	surfacevrt,a0
	move.w	(a0)+,d7		;count
	addq.w	#1,d7

	move.w	d0,-(sp)
	bsr	clip_poly
	move	(sp)+,a1
	bmi	abort_poly
	move	a1,d0
	move.l	a6,-(sp)

	move.w	d0,d1
	lsl.w	#3,d1
	lea	col_dat,a1
	adda	d1,a1
	lea	col_code,a5
	move.l	(a1)+,(a5)+
	move.l	(a1),(a5)+
	move.b	d0,(a5)

	move.w	d7,d0
	move.w	d0,d2
	move.w	d2,d6
	lsl.w	#2,d0
	lea	(a0,d0.w),a1
	lea	(a1,d0.w),a2
	move.l	a1,a4
	move.w	#$8000,d0
	move.w	#$7fff,d1
	bra.s	next_coord
coord_lp:
	move.l	(a0)+,d3
	cmp.w	d3,d0
	bge.s	check_low_y
	move.w	d3,d0
check_low_y:
	cmp.w	d3,d1
	ble.s	coord_trans
	move.w	d3,d1
	move.l	a1,a4
coord_trans:
	move.l	d3,(a1)+
	move.l	d3,(a2)+
next_coord:
	dbra	d6,coord_lp

	move.w	d0,d7
	sub.w	d1,d7

	move.l	a4,a3
	move.l	(a4),d0
*	addq.w	#1,d7
flat_tp_lp1:
	addq.l	#4,a4
*	subq.w	#1,d7
*	bmi	abort_poly
	cmp	2(a4),d0
	beq.s	flat_tp_lp1
	bra.s	look_back
flat_tp_lp2:
	subq.l	#4,a3
look_back:
	cmp.w	-2(a3),d0
	beq.s	flat_tp_lp2
	move.l	hiden,a6
	lsl.w	#5,d0
	add.w	d0,a6
	lsl.w	#2,d0
	add.w	d0,a6
	moveq	#0,d6
	bra	start_poly
polyfill_lp:
	move.l	d3,d0
	swap	d0
	bpl.s	no_rnd_1
	addq.w	#1,d0
no_rnd_1:
	move.l	d4,d1
	swap	d1
	bpl.s	no_rnd_r
	addq.w	#1,d1
no_rnd_r:
	add.l	a1,d3
	add.l	a2,d4
*	cmp	d0,d1
*	bgt	v_order_ok
	exg	d0,d1
v_order_ok:
	move.w	d0,d2
	sub.w	d0,d1
	lsr.w	#1,d2
	and.w	#$fff8,d2
	lea	(a6,d2.w),a0
	and.w	#$f,d0
	moveq	#-1,d2
	lsr	d0,d2
	add.w	d1,d0
	sub.w	#16,d0
	bpl	multi_span
	addq.w	#1,d0
	neg.w	d0
	moveq	#-1,d1
	lsl.w	d0,d1
	and.w	d1,d2
	move.w	d2,d1
	not	d2
	jsr	2(a5)
	bra.s	row_done
multi_span:
	move.w	d2,d1
	not	d2
	jsr	2(a5)
	addq.w	#1,d0
	move.w	d0,d1
	lsr.w	#4,d0
	and.w	#$f,d1
	move.w	d1,-(sp)
	movem.l	-8(a5),d1/d2
	bra.s	next_p_row
p_row_lp:
	move.l	d1,(a0)+
	move.l	d2,(a0)+
next_p_row:
	dbra	d0,p_row_lp
	move.w	(sp)+,d1
	moveq	#-1,d2
	lsr.w	d1,d2
	move.w	d2,d1
	not	d1
	jsr	2(a5)
row_done:
	tst.w	d7
	beq.s	poly_done
	subq.w	#1,d5
	bpl.s	more_rows_1
start_poly:
	sub.l	a2,d4
	moveq	#0,d3
	move.w	(a3),d3
	swap	d3
	move.w	-(a3),d5
	sub	4(a3),d5
	moveq	#0,d0
	move.w	d5,d0
	moveq	#0,d1
	move.w	-(a3),d1
	sub.w	4(a3),d1

	bsr.s	get_grad
	move.l	d0,a1
	cmpi.w	#1,d6
	bmi.s	two_verts
	addq.w	#1,d7
	bra.s	next_scan
more_rows_1:
	subq.w	#1,d6
	bpl.s	more_rows_r
	addq.w	#1,d5
	sub.l	a1,d3
two_verts:
bp2:	moveq	#0,d4
	move.w	-4(a4),d4
	swap	d4
	moveq	#0,d1
	move.w	(a4)+,d1
	move.w	(a4)+,d6
	sub.w	-6(a4),d6
	moveq	#0,d0
	move.w	d6,d0
	sub.w	-8(a4),d1

	bsr.s	get_grad
	move.l	d0,a2
	addq.w	#1,d7
	bra.s	next_scan
more_rows_r:
	lea	160(a6),a6
next_scan:
	dbra	d7,polyfill_lp
poly_done:
	addq.l	#4,sp
abort_poly:
	movem.l	(sp)+,d0-d7/a0-a6
	rts
get_grad:
	beq.s	vert_grad
	bmi.s	neg_grad

	divu	d0,d1
	swap	d0
	move.w	d1,d0
	swap	d0
	clr	d1
	divu	d0,d1
	move.w	d1,d0
	rts
vert_grad:
	moveq	#0,d0
	rts
neg_grad:
	neg.w	d1
	divu	d0,d1
	swap	d0
	move.w	d1,d0
	swap	d0
	clr	d1
	divu	d0,d1
	move.w	d1,d0
	neg.l	d0
	rts

col_code:
	dc.l	0,0
	dc.w	0
	btst	#0,(a5)
	bne.s	s_p_a

	and.w	d2,(a0)+
	bra.s	c_p_a
s_p_a:
	or.w	d1,(a0)+
c_p_a:
	btst	#1,(a5)
	bne.s	s_p_b
	and.w	d2,(a0)+
	bra.s	c_p_b
s_p_b:
	or.w	d1,(a0)+
c_p_b:
	btst	#2,(a5)
	bne.s	s_p_c
	and.w	d2,(a0)+
	bra.s	c_p_c
s_p_c:
	or.w	d1,(a0)+
c_p_c:
	btst	#3,(a5)
	bne.s	s_p_d
	and.w	d2,(a0)+
	rts
s_p_d:
	or.w	d1,(a0)+
	rts

col_dat:
	dc.l	$00000000,$00000000
	dc.l	$ffff0000,$00000000
	dc.l	$0000ffff,$00000000
	dc.l	$ffffffff,$00000000
	dc.l	$00000000,$ffff0000
	dc.l	$ffff0000,$ffff0000
	dc.l	$0000ffff,$ffff0000
	dc.l	$ffffffff,$ffff0000
	dc.l	$00000000,$0000ffff
	dc.l	$ffff0000,$0000ffff
	dc.l	$0000ffff,$0000ffff
	dc.l	$ffffffff,$0000ffff
	dc.l	$00000000,$ffffffff
	dc.l	$ffff0000,$ffffffff
	dc.l	$0000ffff,$ffffffff
	dc.l	$ffffffff,$ffffffff

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


*************************************
leftbutton:	equ	1
rightbutton:	equ	2
bothbuttons:	equ	3
**********************************
clearboth:
	move.l	seen,a0
	move.l	hiden,a1
	move.w	#15999,d0
cbl:
	move.w	#0,(a0)+
	move.w	#0,(a1)+
	dbf	d0,cbl
	rts
*****************************************
copyintoboth:
	move.l	screen3,a0
	move.l	hiden,a1
	move.l	seen,a2
	move.w	#7999,d0
cibloop:
	move.l	(a0),(a1)+
	move.l	(a0)+,(a2)+
	dbf	d0,cibloop
	rts
*************************************
sortfaces:
	movem.l	a0-a2,-(sp)
	move.w	(a0)+,d7	;number of em
	subq.w	#2,d7		;account for first centre z
sfl1:
	move	#-1,a5		;flag for noswaps
	move.l	a0,a6
	move.l	a6,a4
	move.w	d7,d6

	addq.l	#2,a6		;skip color word
	move.w	(a6)+,d5	;num of verts in face
	move.w	d5,d4
	addq.w	#1,d4		;for div
	moveq	#0,d1
sfl3a:
	move.w	(a6)+,d2
	asl.w	#3,d2		;*8
	add.w	4(a1,d2.w),d1	;add the z
	dbf	d5,sfl3a
	divs	d4,d1		;d1 has initial centre z
	ext.l	d1
sfl2:
	addq.l	#2,a6
	move.w	(a6)+,d5		;num of verts in face
	move.w	d5,d4
	addq.w	#1,d4			;for div
	moveq	#0,d3
sfl3:
	move.w	(a6)+,d2
	asl.w	#3,d2			;*8
	add.w	4(a1,d2.w),d3		;add the z
	dbf	d5,sfl3
	divs	d4,d3		;theres centre z
	ext.l	d3
	cmp.w	d1,d3
	bgt	swapcoords
	move.w	d3,d1
	addq.l	#2,a4		;other pointer into list (skip col)
	move.w	(a4)+,d0
	addq.w	#1,d0
	add.w	d0,d0
	add.w	d0,a4		;now pointing at next face
	dbf	d6,sfl2
	cmp.w	#-1,a5
	bne	sfl1
	movem.l	(sp)+,a0-a2
	rts

swapcoords:
	move.w	#1,a5
	move.l	a4,a3		;another copy
	move.w	2(a3),d0
	addq.w	#2,d0		;make up for color and num and -1
	lea	holdingpen,a2
swapl1:
	move.w	(a3)+,(a2)+
	dbf	d0,swapl1

	move.w	2(a3),d0
	addq.w	#2,d0		;make up for color and num and -1
swapl2:
	move.w	(a3)+,(a4)+
	dbf	d0,swapl2

	lea	holdingpen,a2
	move.w	2(a2),d0
	addq.w	#2,d0		;make up for color and num and -1
	move.l	a4,a3
swapl3:
	move.w	(a2)+,(a3)+
	dbf	d0,swapl3
	dbf	d6,sfl2

*	cmpi.w	#-1,a5
	bra	sfl1
*	movem.l	(sp)+,a0-a2
*	rts


holdingpen:	ds.w	20
thetainc:	dc.w	0
phiinc:	dc.w	0
rhoinc:	dc.w	0
clz:		dc.w	1500
mytheta:	dc.w	0
myphi:		dc.w	0
myrho:		dc.w	0
whichob:	dc.l	0
lifetime:	dc.w	-1
demaddress:	dc.l	demlist
zfinal:		dc.w	0
halflife:	dc.w	0
**********************************************************
*	address,initial dist,initial theta,phi,rho,zincr,zfinal
*	phiinc,rhoinc
*	and lifetime
*	dc.l	box,twist,dna,dna2,starball,fuji,box2,ballbox

demlist:
	dc.l	box
	dc.w	5000,0,0,0,100,400,3,2,200
	dc.l	-1
demomode:
	subq.w	#1,lifetime
	bpl	stillalive
	move.l	demaddress,a0
	tst.l	(a0)
	bpl	norestart
	lea	demlist,a0
norestart:
	move.l	(a0)+,whichob
	lea	boxvpb,a1
	move.w	(a0)+,uniz
	move.w	(a0)+,unitheta
	move.w	(a0)+,uniphi
	move.w	(a0)+,unirho
	move.w	(a0)+,zinc
	move.w	(a0)+,zfinal
	move.w	(a0)+,phiinc
	move.w	(a0)+,rhoinc
	move.w	(a0)+,lifetime
	move.w	lifetime,d0
	asr.w	#2,d0			;/2
	move.w	d0,halflife
	move.l	a0,demaddress
stillalive:
	move.l	whichob,a5
	lea	boxvpb,a0
	move.w	phiinc,d0
	add.w	d0,uniphi
	move.w	rhoinc,d0
	add.w	d0,unirho
	move.w	halflife,d0
	cmp.w	lifetime,d0
	bgt.s	zoomout
	move.w	uniz,d0
	cmp.w	zfinal,d0
	ble	dobefore
	sub.w	zinc,d0
	move.w	d0,uniz
	bra	dobefore
zoomout:
	move.w	uniz,d0
	add.w	zinc,d0
	move.w	d0,uniz
	bra.s	dobefore


testdraw:
	move.l	whichob,a5
	move.l	obviewpb(a5),a0
*	tst.w	mcontrol
*	ble	nomc
	cmpi.w	#1,buttondat
	bne.s	mcin
	sub.w	#50,uniz
	bra.s	mouserots
mcin:
	cmpi.w	#2,buttondat
	bne.s	mouserots
	add.w	#50,uniz
mouserots:
	move.w	mx,unitheta
	move.w	my,uniphi
	bra.s	dobefore
nomc:
	tst.w	mcontrol
	beq	demomode
	move.w	thetainc,d0
	add.w	d0,unitheta
	move.w	phiinc,d0
	add.w	d0,uniphi
	move.w	rhoinc,d0
	add.w	d0,unirho
dobefore:
	move.w	unitheta,theta(a0)
	move.w	uniphi,phi(a0)
	move.w	unirho,rho(a0)
	move.w	uniz,obz(a5)
	move.w	obx(a5),plx
	move.w	oby(a5),ply
	move.w	obz(a5),plz
drawobject:
	bsr	init_vtrans
	move.l	whichob,a3 	;Point to verticies
	bsr	trans_vert	;Transform verticies
	move.l	whichob,a0
	lea	vtrans_vrt,a1	;list of transformed vertices
	lea	ptrans_vrt,a2	;list of onscreen coords
	move.w	linecolinfo(a0),linecolor
	cmpi.w	#dots,style(a0)
	beq	objectisdots
	cmpi.w	#balls,style(a0)
	beq	objectisballs
	move.w	hidenflag(a0),hdf
	move.l	obfacelist(a0),a0
	bsr	sortfaces
	move.w	(a0)+,d0	;number of faces
	subq	#1,d0
tdloop:
	move.w	(a0)+,facecolor1
	move.w	(a0)+,numfacesave	;number of points in face
	tst.w	hdf
	bmi	pdt
	move.w	(a0),d2		;offset of face point
	move.w	2(a0),d3	;second point
	move.w	4(a0),d4	;third point

	lsl.w	#3,d2
	lsl.w	#3,d3
	lsl.w	#3,d4

	move.w	(a1,d3.w),d5	;get x2
	move.w	d5,kx
	sub.w	(a1,d2.w),d5	;x2-x1
	move.w	d5,px
	move.w	2(a1,d3.w),d5	;get y2
	move.w	d5,ky
	sub.w	2(a1,d2.w),d5	;y2-y1
	move.w	d5,py
	move.w	4(a1,d3.w),d5	;get z2
	move.w	d5,kz
	sub.w	4(a1,d2.w),d5	;z2-z1
	move.w	d5,pz

	move.w	(a1,d4.w),d5	;x3
	sub.w	(a1,d2.w),d5	;x3-x1
	move.w	2(a1,d4.w),d6	;y3
	sub.w	2(a1,d2.w),d6	;y3-y1
	move.w	4(a1,d4.w),d7	;z3
	sub.w	4(a1,d2.w),d7	;z3-z1

	move.w	d5,d1
	move.w	d6,d2
	move.w	d7,d3

	muls	py,d3
	muls	pz,d2
	sub.w	d2,d3
	move.w	d3,rx
	muls	pz,d1
	muls	px,d7
	sub.w	d7,d1
	move.w	d1,ry
	muls	px,d6
	muls	py,d5
	sub.w	d5,d6
	move.w	d6,rz

	moveq	#0,d1		;projection centre x
	sub.w	kx,d1
	moveq	#0,d2		;projection centre y
	sub.w	ky,d2
	moveq	#0,d3		;projection centre z
	sub.w	kz,d3
	muls	rx,d1
	muls	ry,d2
	muls	rz,d3
	add.l	d1,d2
	add.l	d2,d3
	ble	notvisible
pdt:
	move.w	numfacesave,d1
	move.l	whichob,a5
	cmpi.w	#filled,style(a5)
	beq	drawfilled
	move.w	(a0),d2
	asl.w	#2,d2		;*4 for offsett
	move.w	(a2,d2.w),x1s
	move.w	2(a2,d2.w),y1s
	subq.w	#1,d1
	bpl.s	visible
	addq.w	#1,d1
visible:
	move.w	(a0),d2
	asl.w	#2,d2		;*4 for offsett
	move.w	(a2,d2.w),x1
	move.w	2(a2,d2.w),y1
	move.w	2(a0),d2
	asl.w	#2,d2		;*4 for offsett
	move.w	(a2,d2.w),x2
	move.w	2(a2,d2.w),y2
	move.w	x2,x2s
	move.w	y2,y2s
	bsr	clipit
	addq.l	#2,a0
	dbf	d1,visible
	move.w	x1s,x1
	move.w	y1s,y1
	move.w	x2s,x2
	move.w	y2s,y2
	bsr	clipit
	addq.l	#2,a0
	dbf	d0,tdloop
	rts

drawfilled:
	move.w	facecolor1,surfacedfn	;color
*	move.w	facecolor2,surfacedfn+2
	lea	surfacevrt,a5
	move.w	d1,(a5)+		;number of points
dfloop:
	move.w	(a0)+,d2
	asl.w	#2,d2		;*4 for offsett
	move.w	(a2,d2.w),(a5)+
	move.w	2(a2,d2.w),(a5)+
	dbf	d1,dfloop
	bsr	draw_polygon3
	dbf	d0,tdloop
	rts

notvisible:
	move.w	numfacesave,d1
	addq.w	#1,d1
	add.w	d1,d1
	add.w	d1,a0	
	dbf	d0,tdloop
	rts


objectisballs:
	lea	ptrans_vrt,a1
	lea	vtrans_vrt,a2
	move.w	numdots(a0),d0		;number of em
bp1:	subq.w	#1,d0
oibl1:
	moveq	#-1,d7		;flag
	move.w	d0,d6		;counter
	move.l	a2,a6
	move.l	a1,a5
oibl2:
	move.w	4(a6),d1	;trans z
	cmp.w	12(a6),d1	;trans z
	blt	swapball
	addq.l	#8,a6
	addq.l	#4,a5
	dbf	d6,oibl2
	tst.w	d7
	bpl	oibl1
	bra.s	drawballs
	rts
swapball:
	moveq	#1,d7
	move.w	(a5),d3		;get x
	move.w	2(a5),d4
	move.w	4(a5),(a5)
	move.w	6(a5),2(a5)
	move.w	d3,4(a5)
	move.w	d4,6(a5)

	move.w	12(a6),4(a6)
	move.w	d1,12(a6)

	addq.l	#4,a5
	addq.l	#8,a6
	dbf	d6,oibl2
	bra	oibl1

drawballs:
*	addq.w	#1,d0		;counter
dbloop:
	move.w	4(a2),d1
	cmp.w	#1000,d1
	bgt.s	dba
	lea	ballsp0,a0
	bra.s	drawball
dba:
	cmp.w	#2000,d1
	bgt.s	dbb
	lea	ballsp1,a0
	bra.s	drawball
dbb:
	lea	ballsp2,a0
drawball:
	addq.l	#8,a2
	move.w	(a1)+,cspritex(a0)
	move.w	(a1)+,cspritey(a0)
	movem.l	d0/a1,-(sp)
	bsr	drawclipped
	movem.l	(sp)+,d0/a1
	dbf	d0,dbloop
	rts



objectisdots:
	move.w	#12,pixelcolor
	lea	ptrans_vrt,a1	;list of onscreen coords
	lea	vtrans_vrt,a2
	move.w	plz,d1
	move.w	numdots(a0),d0	;get the number of points
	subq.w	#1,d0
	tst.w	hidenflag(a0)
	bmi	nohides
dotloop:
	cmp.w	4(a2),d1
	blt	nopl
	tst.w	4(a2)
	bmi	nono
	addq.l	#8,a2
	move.w	#12,pixelcolor
	move.w	(a1)+,pixelx
	move.w	(a1)+,pixely
	bsr	singleplot
	dbf	d0,dotloop
	rts
nopl:
	addq.l	#8,a2
	move.w	#13,pixelcolor
	move.w	(a1)+,pixelx
	move.w	(a1)+,pixely
	bsr	singleplot
	dbf	d0,dotloop
	rts
nono:	addq.l	#4,a1
	addq.l	#8,a2
	dbf	d0,dotloop
	rts


nohides:
	move.w	(a1)+,pixelx
	move.w	(a1)+,pixely
	bsr	singleplot
	dbf	d0,nohides
	rts

kx:	dc.w	0
px:	dc.w	0
ky:	dc.w	0
py:	dc.w	0
kz:	dc.w	0
pz:	dc.w	0
rx:	dc.w	0
ry:	dc.w	0
rz:	dc.w	0
hdf:		dc.w	0
numfacesave:	dc.w	0
facepoints:	dc.w	0
facecolor1:	dc.w	0
facecolor2:	dc.w	0
cxmin:		equ	0
cxmax:		equ	319
cymin:		equ	0
cymax:		equ	150
cbits:	dc.w	0
cbits2:	dc.w	0
xsav:	dc.w	0
ysav:	dc.w	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
	movem.l	(sp)+,d0-d7/a0
	rts
clipb:
	movem.l	(sp)+,d0-d7/a0
	rts
*********************************************************
linecolor:
	dc.w	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
	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
	adda.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
	move.w	d2,d3
	and.w	#15,d3
	bne	xmnloop
	subq.l	#8,a0
xmnloop:
	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:
	addq.w	#1,d2
	dbf	d7,xmnloop
specxneg:
	move.w	d2,d3
	and.w	#15,d3
	bne	spct1
	rts
spct1:	sub.w	#15,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
	move.w	d2,d3
	and.w	#15,d3
	bne	xmploop
	subq.l	#8,a0
xmploop:
	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:
	addq.w	#1,d2
	dbf	d7,xmploop
	move.w	d2,d3
	and.w	#15,d3
	bne	spct2
	rts
spct2:	sub.w	#15,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
	addq.w	#1,d7
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
	addq.w	#1,d7
stuploop1:
	bsr	putlinein
	sub.l	#160,a0
	dbf	d7,stuploop
*	movem.l	(sp)+,d4-d7/a0
	rts	


dump:	dc.w	0
gradient:	dc.w	0
x1:	dc.w	0
x2:	dc.w	0
y1:	dc.w	0
y2:	dc.w	0
dx:	dc.w	0
dy:	dc.w	0
plx:	dc.w	0
ply:	dc.w	0
plz:	dc.w	0
myviewx:	dc.w	0
myviewy:	dc.w	0

***************************************************************************
*		TRANSFORM A LIST OF VERTICIES
*		On entry,   d6 = number of verticies
*			    a3 = pointer to verticies
*		On exit , a0 = pointer to transformed verticies
*	Transform a list of verticies in 3-D space according to the
* 	viewing transformation.
trans_vert:
	lea.l	vtrans_vrt,a1	;Point to vertex tables
	lea.l	ptrans_vrt,a0
	move.l	a0,-(SP)
	move.l	obviewpb(a3),a5
	move.l	obvert(a3),a3
	move.w	(a3)+,d6	;get number of verts
	subq	#1,d6		;Pre-decrement vertex counter
trans_vert0:
	move	(a3)+,d0		;Get x-coordinate of vertex
	move	(a3)+,d1	;Get y-coordinate
	move	(a3)+,d2	;Get z-coordinate
	bsr	view_trans	;Apply view transformatrmed coordinates
	add.w	plx,d3
	add.w	ply,d4
	add.w	plz,d5
	add.w	myviewx,d3
	add.w	myviewy,d4
	move.w	d3,(a1)+
	move	d4,(a1)+
	cmpi.w	#zclip,d5
	bge	okz	
	move.w	#zclip,d5
okz:
	move	d5,(a1)+
	move.w	#0,(a1)+
	bsr	prsp_trans	;Apply perspective transformation
	move	d3,(a0)+	;Save transformed x-coordinate		
	move	d4,(a0)+	;Save transformed y-coordinate
	dbf	d6,trans_vert0
	move.l	(SP)+,a0	;Restore transformed vertex pointer
	rts

*******************************
*		VIEW TRANSFORM ON A VERTEX
*		On entry, d0 = x-coordinate of vertex
*			  d1 = y-coordinate of vertex
*			  d2 = z-coordinate of vertex
*		On exit , d3 = x-coordinate view transformed
*			  d4 = y-coordinate view transformed
*			  d5 = z-coordinate view transformed
*	Apply the view transform to a vertex.
view_trans:
	move.w	d0,d3			;get x
	muls	c_theta(a5),d3
	move.w	d1,d4			;get y
	muls	s_theta(a5),d4
	add.l	d4,d3
	swap	d3
	rol.l	#1,d3			;thats	x
	move.w	d1,d4			;get y
	muls	c_theta(a5),d4
	muls	s_theta(a5),d0		;x
	sub.l	d0,d4
	swap	d4
	rol.l	#1,d4			;thats	y
	move.w	d4,d1			;x
	move.w	d3,d0			;y

	move.w	d1,d3			;get y
	muls	c_phi(a5),d3
	move.w	d2,d4			;get z
	muls	s_phi(a5),d4
	add.l	d4,d3
	swap	d3
	rol.l	#1,d3			;thats	y
	move.w	d2,d4			;thats z
	muls	c_phi(a5),d4
	muls	s_phi(a5),d1		;y
	sub.l	d1,d4
	swap	d4
	rol.l	#1,d4			;thats	z
	move.w	d4,d2			;y

	move.w	d0,d4			;x
	muls	c_rho(a5),d4
	move.w	d2,d5
	muls	s_rho(a5),d5		;z
	sub.l	d5,d4
	swap	d4
	rol.l	#1,d4			;thats	x
	move.w	d4,d5
	muls	s_rho(a5),d0
	muls	c_rho(a5),d2
	add.l	d0,d2
	swap	d2
	rol.l	#1,d2		;thats	z
	move.w	d2,d5
	move.w	d3,d7
	move.w	d4,d3
	move.w	d7,d4
	rts

worldview_trans:
	tst.w	theta(a5)
	beq	skiptheta
	move.w	d0,d3			;get x
	muls	c_theta(a5),d3
	move.w	d1,d4			;get y
	muls	s_theta(a5),d4
	add.l	d4,d3
	swap	d3
	rol.l	#1,d3			;thats	y
	move.w	d1,d4			;get y
	muls	c_theta(a5),d4
	muls	s_theta(a5),d0		;x
	sub.l	d0,d4
	swap	d4
	rol.l	#1,d4			;thats	x
	move.w	d4,d1			;x
	move.w	d3,d0			;y

skiptheta:
	tst.w	rho(a5)
	beq	skiprho
	move.w	d0,d4			;x
	muls	c_rho(a5),d4
	move.w	d2,d5
	muls	s_rho(a5),d5		;z
	sub.l	d5,d4
	swap	d4
	rol.l	#1,d4			;thats	z
	move.w	d4,d7
	move.w	d0,d4
	muls	s_rho(a5),d4
	move.w	d2,d3
	muls	c_rho(a5),d3
	add.l	d4,d3
	swap	d3
	rol.l	#1,d3		;thats	x
	move.w	d3,d2
	move.w	d7,d0
skiprho:
	tst.w	phi(a5)
	beq	skipphi
	move.w	d1,d3			;get y
	muls	c_phi(a5),d3
	move.w	d2,d4			;get z
	muls	s_phi(a5),d4
	add.l	d4,d3
	swap	d3
	rol.l	#1,d3			;thats	z
	move.w	d2,d4			;thats z
	muls	c_phi(a5),d4
	muls	s_phi(a5),d1		;y
	sub.l	d1,d4
	swap	d4
	rol.l	#1,d4			;thats	y
	move.w	d4,d2			;y
	move.w	d3,d1
skipphi:
	move.w	d0,d3
	move.w	d1,d4
	move.w	d2,d5
	rts

***********************************************************************
*		PERSPECTIVE TRANSFORM
*		On entry, d3 = view transformed x-coordinate
*			  d4 = view transformed y-coordinate
*			  d5 = view transformed z-coordinate
*		On exit , d3 = screen x-coordinate ( Xe )
*			  d4 = screen y-coordinate ( Ye )
*	Calculate the screen coordinates of the vertex. The coordinates are
* centered about the centre of the screen.
*	Note, the distance to the screen is 2048.

prsp_trans:
	swap	d3		;Calculate Xs
	clr	d3		
	asr.l	#8,d3	  
	divs	d5,d3
	
	swap	d4		;Calculate Ys
	clr	d4
	asr.l	#8,d4
	divs	d5,d4

	add	#159,d3		;Adjust for centre of screen
	add	#76,d4
	rts

***************************************************************************
*		INITIALISE VIEW TRANSFORM
*	Initialise the viewing transformation.
*	expects	address of object data in a5
init_vtrans:
	move.l	obviewpb(a5),a5
	move	theta(a5),d3		;Calculate SIN amd COS theta
	bsr	trig
	move	d4,s_theta(a5)
	move	d5,c_theta(a5)
	
	move	phi(a5),d3	;Calculate SIN and COS phi
	bsr	trig
	move	d4,s_phi(a5)
	move	d5,c_phi(a5)

	move	rho(a5),d3	;Calculate Vl
	bsr	trig
	move.w	d4,s_rho(a5)
	move.w	d5,c_rho(a5)
	rts

***************************************************************************
*		CALCULATE SINE AND COSINE OF ANGLE
*		On entry, d3 = angle
*		On exit ,   d4 = sine of angle
*			    d5 = cosine of angle
*	Find the sine and cosine of an angle.

trig:	addi.w	#$40,d3		;Find cCOS of angle
	bsr	find_sin
	move	d4,d5
	subi.w	#$40,d3		;Find SIN of angle
	bsr	find_sin
	rts

***************************************************************************
*		FIND SINE OF AN ANGLE
*		On entry, d3 = angle
*		On exit ,   d5 = cosine of angle 
*	Find the cosine of an angle. The value of the sign is a 16 bit
* signed number.
*	Note, to scale down, divide by 15 bits, ie &8000.
find_cos:
	move	d4,-(SP)	;Save SIN
	move	d3,-(SP)	;Save angle
	addi.w	#$40,d3		;Find COS of angle
	bsr	find_sin
	move	d4,d5
		
	move	(SP)+,d3	;Restore angle
	move	(SP)+,d4	;Restore SIN
		
	rts	

***************************************************************************
*		FIND THE SIN OF AN ANGLE
*		On entry, d3 = angle
*		On exit ,   d4 = SIN of angle
*	Find the SIN of an angle. The value of the sign is a 16 bit
* signed number.
*	Note, to scale down, divide by 15 bits, ie &8000.

find_sin:
	move	d3,-(SP)	;Save angle	

	and.l	#$7F,d3		;Move to quadrants 1 and 2
	btst	#6,d3		;Test if in 1st quadrant
	beq	quad0		;Branch if in 1st quadrant
	bclr	#6,d3		;Reflect angle into 1st quadrant
	subi.b	#$3F,d3
	neg.b	d3
		
quad0:	asl	#1,d3		;Get value of SIN from table
	lea.l	sin_vt,a6
	move	0(a6,d3),d4
		
	move	(SP)+,d3

	btst	#7,d3		;Adjust value if 3rd or 4th quadrant
	beq	quad1
	neg	d4		;Negate SIN value
		
quad1:	rts

***************************************************************************
*		SIN LOOK UP TABLE
*	This is the SIN value look up table. Values for the 1st quadrant
* are given only. The values range from 0 - 32758 for angles 0 - 63.
* Thus, the value of a sine in the 1st quadrant is a 15 bit number.
* Therefore, the table can be used to construct a 16 bit signed value of
* SIN for angles 0 - 255.

sin_vt:	dc.w	0,804,1608,2411
	dc.w	3212,4011,4808,5602
	dc.w	6393,7180,7962,8740
	dc.w	9512,10279,11039,11793
	dc.w	12540,13279,14010,14733
	dc.w	15447,16151,16846,17531
	dc.w	18205,18868,19520,20160
	dc.w	20788,21403,22006,22595
	dc.w	23170,23732,24279,24812
	dc.w	25330,25832,26320,26791
	dc.w	27246,27684,28106,28511
	dc.w	28899,29269,29622,29957
	dc.w	30274,30572,30853,31114
	dc.w	31357,31581,31786,31972
	dc.w	32138,32286,32413,32522
	dc.w	32610,32679,32729,32758

clear:	dc.w	1
****************************************
keyboard:
	move.l	keybuf,a0
	move.w	6(a0),d0
	cmp.w	8(a0),d0
	bne	ischar
	rts
ischar:
	move.w	#2,-(sp)
	move.w	#2,-(sp)
	trap	#13
	addq.l	#4,sp
	swap	d0
quit:   cmpi.w  #$10,d0
        bne	cleark
        bra     gem
spaceb:
	cmpi.w	#$39,d0
	bne	cleark
	bra	pause
cleark:
	cmpi.w	#$2e,d0
	bne	thetapk
	neg.w	clear
thetapk:
	cmpi.w	#$6d,d0
	bne	thetamk
	addq.w	#1,thetainc
	rts
thetamk:
	cmpi.w	#$69,d0
	bne	phipk
	subq.w	#1,thetainc
	rts
phipk:
	cmpi.w	#$68,d0
	bne	phimk
	addq.w	#1,phiinc
	rts
phimk:
	cmpi.w	#$6e,d0
	bne	rhopk
	subq.w	#1,phiinc
	rts
rhopk:
	cmpi.w	#$6c,d0
	bne	rhomk
	addq.w	#1,rhoinc
	rts
rhomk:
	cmpi.w	#$6a,d0
	bne	undok
	subq.w	#1,rhoinc
	rts
undok:
	cmpi.w	#$61,d0
	bne	newobject
	tst.w	mcontrol
	bne	unok
	rts
unok:
	move.w	#0,unitheta
	move.w	#0,uniphi
	move.w	#0,unirho
	move.w	#1500,uniz
	move.w	#0,thetainc
	move.w	#0,phiinc
	move.w	#0,rhoinc
	rts
newobject:
	cmpi.w	#$1c,d0
	bne	morj
	tst.w	mcontrol
	bne	oknew
	move.w	halflife,lifetime
	rts
oknew:
	addq.w	#4,obcounter
	cmp.w	#28,obcounter
	ble	obok
	move.w	#0,obcounter
obok:
	move.w	obcounter,d0
	lea	oblist,a0
	move.l	(a0,d0.w),whichob
	rts
morj:
	cmpi.w	#$39,d0
	bne	obin
	addq.w	#1,mcontrol
	cmpi.w	#2,mcontrol
	blt	mcok
	move.w	#-1,mcontrol
mcok:
*	bsr	putcontrol
	move.w	#-1,lifetime
	move.l	#demlist,demaddress
	rts
obin:
	cmpi.w	#$4a,d0
	bne	obout
	add.w	#50,uniz
	rts
obout:
	cmpi.w	#$4e,d0
	bne	keyback
	sub.w	#50,uniz
	rts
keyback:rts

mcontrol:	dc.w	0
obcounter:	dc.l	0
oblist:
	dc.l	box
*****************************
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
gkey2:
	movem.l	d1-d7/a0-a6,-(sp)
gk3:    move.w  #$ff,-(sp)
        move.w  #6,-(sp)
        trap    #1
        addq.l  #4,sp
        tst.l   d0
        beq     gk3
	swap    d0
*	bsr	fitcode
	movem.l	(sp)+,d1-d7/a0-a6
        rts
cheat:	dc.w	-1


***********************************
mydocolors:
	move.l	#$ff8240,a1
	moveq	#15,d0
mdcloop:
	move.w	(a0)+,(a1)+
	dbf	d0,mdcloop
	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	screen3,generalstore
	subi.l	#100000,generalstore
	move.l	#ytable2,ytable
	move.l	#ytable1,sytable
	rts
screen1:	dc.l	0
screen2:	dc.l	0
screen3:	dc.l	0
generalstore:	dc.l	0
seen:	dc.l	0
hiden:	dc.l	0
screen:	dc.l	0


********************************************
* Atari ST hi-speed plotting subroutine    *
* For Low-resolution mode only		   *
********************************************
plotinit:
	move.l	seen,a0		;screen addr in A0
	move.b	#200,d1		;200 Y positions
	lea	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
	lea	ytable2,a1	;y table address in A1

iloop2:
	move.l	a0,(a1)+	;move address to table
	adda.w	#160,a0		;increment address
	subq.b	#1,d1		;1 less y position
	bne	iloop2		;loop if there's more!
	rts

pixelx:		dc.w	0
pixely:		dc.w	0
pixelcolor:
		dc.w	0
ytable1:	ds.l	200
ytable2:	ds.l	200
ytable:		dc.l	0
sytable:	dc.l	0
**********************************************
singleplot:
	movem.l	d0-d5/a0-a1,-(sp)
	move.w	pixelx,d0      ;x coordinate in D0
	cmp.w	#cxmax,d0
	bgt	pltxit
	cmpi.w	#cxmin,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	#cymax,d1
	bgt	pltxit
	cmpi.w	#cymin,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
	bra	myphere

myphere:
	and.l d5,(a0)        ;turn off old pixel
	and.l d5,4(a0)       ;(both longwords)
******************************
* Now turn on the new pixel! *
******************************
	btst #0,d2           ;set the bit?
	beq bit2             ;no!
	or.w d4,(a0)         ;turn it on!
bit2:
	btst #1,d2           ;set it?
	beq bit4             ;no!
	or.w d4,2(a0)        ;turn it on!
bit4:
	btst #2,d2           ;set bit?
	beq bit8             ;no!
	or.w d4,4(a0)        ;turn it on!
bit8:
	btst #3,d2           ;set bit?
	beq pltxit           ;no, exit.
	or.w d4,6(a0)        ;turn it on!
pltxit:
	movem.l	(sp)+,d0-d5/a0-a1
	rts                  ;bye!
pltxit2:
	movem.l	(sp)+,d0-d5/a0-a1
	moveq	#-1,d0
	rts                  ;bye!

*************************************
clearquick:
	tst.w	clear
	bmi	noclear
	move.l	hiden,a0
	move	#153,d0
	moveq	#0,d6
cl2loop:
	move.l	d6,(a0)+
	move.l	d6,(a0)+
	move.l	d6,(a0)+
	move.l	d6,(a0)+
	move.l	d6,(a0)+
	move.l	d6,(a0)+
	move.l	d6,(a0)+
	move.l	d6,(a0)+
	move.l	d6,(a0)+
	move.l	d6,(a0)+
	move.l	d6,(a0)+
	move.l	d6,(a0)+
	move.l	d6,(a0)+
	move.l	d6,(a0)+
	move.l	d6,(a0)+
	move.l	d6,(a0)+
	move.l	d6,(a0)+
	move.l	d6,(a0)+
	move.l	d6,(a0)+
	move.l	d6,(a0)+
	move.l	d6,(a0)+
	move.l	d6,(a0)+
	move.l	d6,(a0)+
	move.l	d6,(a0)+
	move.l	d6,(a0)+
	move.l	d6,(a0)+
	move.l	d6,(a0)+
	move.l	d6,(a0)+
	move.l	d6,(a0)+
	move.l	d6,(a0)+
	move.l	d6,(a0)+
	move.l	d6,(a0)+
	move.l	d6,(a0)+
	move.l	d6,(a0)+
	move.l	d6,(a0)+
	move.l	d6,(a0)+
	move.l	d6,(a0)+
	move.l	d6,(a0)+
	move.l	d6,(a0)+
	move.l	d6,(a0)+
	dbf	d0,cl2loop
noclear:
	rts

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
	move.l	d0,a0
	move.w	#0,(a0)
	rts
flip_scr:
	move.l	seen,d1
	move.l	d1,d2
	add.l	#4000,d1
	add.l	#22000,d2
skloop:
	lea	$ff8205,a0
	moveq	#0,d0
	move.b	(a0),d0
	asl.l	#8,d0
	addq.l	#2,a0
	move.b	(a0),d0
	asl.l	#8,d0
	addq.l	#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
        move.l  sytable,A6
        move.l  ytable,sytable
        move.l  A6,ytable
	bsr	clearquick
*	move.b	seen+1,$ff8201
*	move.b	seen+2,$ff8203
*	move.b	seen+1,$ff8205
*	move.b	seen+2,$ff8207
*	move.b	seen+3,$ff8209
	rts


flip_scr2:
        move.l  seen,A6
        move.l  hiden,seen
        move.l  A6,hiden
        move.l  sytable,A6
        move.l  ytable,sytable
        move.l  A6,ytable
	move.w	#37,-(sp)
	trap	#14
	addq.l	#2,sp
	bsr	clearquick
	rts

numvbl:		dc.w	0
frames:		dc.w	0
framess:		dc.w	0
*****************************************
prtnum: 
	movem.l	d0/d6/d7/a0/a5/a1/a2,-(sp)
        moveq  	#0,d7
        move.w  number,d7
        andi.l  #$ffff,d7
        lea	lineout,a5
	tst.w	d7
	bpl	dodec2
	neg.w	d7
dodec2:
	move.l  d7,d6
        divu    #10,d6
        move.w  d6,d7
        swap    d6
        move.b  d6,(a5)+
	subq.w	#1,d0
        tst.w  d7
        bne     dodec2
	lea	smallnumbers,a3
	move.w	numwhere,d6
out2:
	cmpa.l  #lineout,a5
        beq     decback2
	moveq	#0,d7
        move.b  -(a5),d7
	mulu	#28,d7
	move.l	a3,a0
	add.w	d7,a0
	moveq	#6,d0
	move.l	hiden,a2
	adda.w	d6,a2
oloop2:
	move.b	(a0)+,(a2)
	move.b	(a0)+,2(a2)
	move.b	(a0)+,4(a2)
	move.b	(a0)+,6(a2)
	lea	160(a2),a2
	dbf	d0,oloop2
	btst	#0,d6
	beq	oh2
	addq.w	#6,d6
oh2:	addq.w	#1,d6
	bra	out2
decback2:
	movem.l	(sp)+,d0/d6/d7/a0/a5/a1/a2
	rts


safe:	dc.w	0
lineout:	ds.l	5
times:		dc.w	0
number:		dc.w	0
numwhere:	dc.w	0
palsave:	ds.w	16
alertout:
	move.l	#0,ap1resv
	move.l	#0,ap2resv
	move.l	#0,ap3resv
	move.l	#0,ap4resv
	move.w	#10,opcode
	move.w	#0,sintin
	move.w	#1,sintout
	move.w	#0,saddrin
	move.w	#0,saddrout
	move.l	#aespb,d1
	move.w	#$c8,d0
	trap	#2

	move.w	#77,opcode
	move.w	#0,sintin
	move.w	#5,sintout
	move.w	#0,saddrin
	move.w	#0,saddrout
	move.l	#aespb,d1
	move.w	#$c8,d0
	trap	#2

	move.w	intout,grhandle

	move.w	#100,opcode
	move.w	#0,contrl+2
	move.w	#11,contrl+6
	move.w	grhandle,contrl+12
	move.w	#1,intin
	move.w	#1,intin+2
	move.w	#1,intin+4
	move.w	#1,intin+6
	move.w	#1,intin+8
	move.w	#1,intin+10
	move.w	#1,intin+12
	move.w	#1,intin+14
	move.w	#1,intin+16
	move.w	#1,intin+18
	move.w	#1,intin+20

	move.l	#vdipb,d1
	move.w	#$73,d0
	trap	#2


	move.w	#52,contrl	;form alert
	move.w	#1,contrl+2
	move.w	#1,contrl+4
	move.w	#1,contrl+6
	move.w	#0,contrl+8
	move.w	#1,intin
	move.l	#alarmtext,addrin
	move.l	#aespb,d1
	move.w	#$c8,d0
	trap	#2
	bra	gem2

alarmtext:
	dc.b	'[1][       This demo is for|'
	dc.b	'         the STE only|]'
	dc.b	'[ OH DEAR | BETTER BUY ONE ]',0,0
	even

aespb:
	dc.l	contrl,global,intin,intout,addrin,addrout
contrl:
opcode:	dc.w	10
sintin:	dc.w	0
sintout:dc.w	1
saddrin:dc.w	0
saddrout:dc.l	0
	ds.w	5

global:
apversion:	dc.w	0
apcount:	dc.w	0
apid:		dc.w	0
apprivate:	dc.l	0
apptree:	dc.l	0
ap1resv:	dc.l	0
ap2resv:	dc.l	0
ap3resv:	dc.l	0
ap4resv:	dc.l	0

intin:
	ds.w	128
ptsin:
	ds.w	128
intout:
	ds.w	128
ptsout:
	ds.w	128
addrin:
	ds.w	128
addrout:
	ds.w	128
vdipb:
	dc.l	contrl,intin,ptsin,intout,ptsout
grhandle:	dc.w	0

******************************************
*               RETURN TO GEM
gem:
	jsr	restoremfp
*	move.b	#%11111110,$ff820a
*	move.w	#$0,$ff8900


	move.l	#$ff8240,a0
	lea	palsave,a1
	moveq	#15,d7
rspl:
	move.w	(a1)+,d0
	and.w	#$0777,d0
	move.w	d0,(a0)+
	dbf	d7,rspl


        move.b  #7,$484

	move.w  #34,-(sp)
        trap    #14
        addq.l  #2,sp
        move.l  d0,a0
	move.l	oldmouse,16(a0)

        move.w  ressave,-(sp)
        move.l  screen,-(sp)
        move.l  screen,-(sp)
        move.w  #5,-(sp)
        trap    #14
        add.l  #12,sp

	move.l	rvsave,$426
	move.l	resave,$42a
        
gem2:
        move.l  savesup,-(SP)    ;Back to user mode
        move.w  #$20,-(SP)
        trap    #1
        addq.l  #6,SP
*illegal
	clr.w	-(sp)
	trap	#1

rvsave:	dc.l	0
resave:	dc.l	0
*********************************************************
*	my routines for loading in the screens		*
*********************************************************
loadscr:
*	move.b	oldieb,ieb
	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
	tst.w	d0
	bmi	nofile
	move.l	hiden,-(SP)    ;load it straight onto screen
	move.l	#32000,-(SP)		;length to read in
	move	D0,-(SP)	;Handle
	move	#$3F,-(SP)	;bios number
	trap	#1		;Read file in
	add.l	 #12,SP

	move	#$3E,-(SP)	;Handle already on stack
	trap	#1		;Close file
	addq.l	#2,SP
*	and.b	#$df,ieb

	move.l	hiden,a0
	move.l	a0,a1
stl:
	move.b	(a1)+,d0
	bne	stl
	move.l	screen3,a2	;where to put it
decom:
	move.l	a2,a3		; a3 sauvegarde debut ecran
	moveq	#39,d0		; d0 indice des colonnes = 40 passages
	move.l	#199,d1 	; d1 indice des lignes	 = 200 passages
	sub.l	d2,d2		; d2 est remis a zero ...
	move.b	(a0)+,d2	; on prend le premier compteur
	subq.l	#1,d2		; decrement du compteur pour dbra
	move.b	(a1)+,d3
	lsl.l	#8,d3
	move.b	(a1)+,d3
	lsl.l	#8,d3
	move.b	(a1)+,d3
	lsl.l	#8,d3
	move.b	(a1)+,d3
	moveq	#4,d7
boucle:
	move.l	d3,(a2) 	; qu'on bazarde a l'ecran
	dbra	d2,encore	; test et decrement du compteur
	sub.l	d2,d2		; remise a zero du compteur
	move.b	(a0)+,d2	; si le compteur = 0 on rechoppe de 
	subq.l	#1,d2		; decrement de d2 (pour faire un dbra)
	move.b	(a1)+,d3
	lsl.l	#8,d3
	move.b	(a1)+,d3
	lsl.l	#8,d3
	move.b	(a1)+,d3
	lsl.l	#8,d3
	move.b	(a1)+,d3
encore:
	lea	160(a2),a2
	dbra	d1,boucle	; test pour voir si on est en bas
	adda.l	d7,a3		; un long plus loin
	move.l	a3,a2
	move.l	#199,d1 	; et c'est parti pour une nouvelle colonne
	dbra	d0,boucle
nofile:
	rts

length:		dc.w	0
***************************************
oldmouse:	dc.l	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)
        rts
lastb:		dc.w	-1
**************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
*	lsl.w	#6,d0
*	lsl.w	#6,d1
	sub.w	d0,mx
	sub.w	d1,my
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	#mminx,d0
        bge     extra1
        move.w	#mmaxx,d0
        bra     extra2
extra1: cmpi.w   #mmaxx,d0
        ble     extra2
        move.w  #mminx,d0
extra2:	cmpi.w  #mminy,d1
        bge     extra3
        move.w  #mmaxy,d1
        bra	extra4
extra3: cmpi.w   #mmaxy,d1
        ble     extra4
        move.w  #mminy,d1
extra4:
        rts

buttondat:	dc.w	0
mx:		dc.w	160
my:		dc.w	100

mminx:	equ	0	;13
mmaxx:	equ	255
mminy:	equ	0	;3
mmaxy:	equ	255	; 13 123
fileshipcomp:	dc.b	'front.cmp',0
	even
savesup:	dc.l	0
ressave:	dc.w	0
filename:	dc.l	0
bluepalette:
	incbin	'ste.pal'

smallnumbers:
	 dc.b	$00,$00,$44,$7C,$00,$00,$AA,$EE
	 dc.b	$00,$00,$54,$DE,$00,$00,$28,$BA
	 dc.b	$00,$00,$54,$F6,$00,$00,$AA,$EE
	 dc.b	$00,$00,$44,$7C,$00,$00,$20,$30
	 dc.b	$00,$00,$40,$70,$00,$00,$20,$30
	 dc.b	$00,$00,$00,$10,$00,$00,$00,$10
	 dc.b	$00,$00,$28,$38,$00,$00,$44,$7C
	 dc.b	$00,$00,$82,$FE,$00,$00,$44,$C6
	 dc.b	$00,$00,$04,$06,$00,$00,$82,$FE
	 dc.b	$00,$00,$40,$C0,$00,$00,$40,$C0
	 dc.b	$00,$00,$00,$FE,$00,$00,$82,$FE
	 dc.b	$00,$00,$44,$C6,$00,$00,$04,$06
	 dc.b	$00,$00,$22,$3E,$00,$00,$04,$06
	 dc.b	$00,$00,$44,$C6,$00,$00,$82,$FE
	 dc.b	$00,$00,$10,$1C,$00,$00,$28,$3C
	 dc.b	$00,$00,$50,$74,$00,$00,$AA,$EE
	 dc.b	$00,$00,$00,$FE,$00,$00,$0A,$0E
	 dc.b	$00,$00,$00,$04,$00,$00,$00,$FE
	 dc.b	$00,$00,$40,$C0,$00,$00,$40,$C0
	 dc.b	$00,$00,$82,$FE,$00,$00,$04,$06
	 dc.b	$00,$00,$04,$06,$00,$00,$02,$FE
	 dc.b	$00,$00,$82,$FE,$00,$00,$44,$C6
	 dc.b	$00,$00,$40,$C0,$00,$00,$02,$FE
	 dc.b	$00,$00,$44,$C6,$00,$00,$44,$C6
	 dc.b	$00,$00,$82,$FE,$00,$00,$00,$FE
	 dc.b	$00,$00,$04,$06,$00,$00,$0A,$0E
	 dc.b	$00,$00,$14,$1C,$00,$00,$28,$38
	 dc.b	$00,$00,$50,$70,$00,$00,$20,$60
	 dc.b	$00,$00,$82,$FE,$00,$00,$44,$C6
	 dc.b	$00,$00,$44,$C6,$00,$00,$82,$FE
	 dc.b	$00,$00,$44,$C6,$00,$00,$44,$C6
	 dc.b	$00,$00,$82,$FE,$00,$00,$82,$FE
	 dc.b	$00,$00,$40,$C2,$00,$00,$44,$C6
	 dc.b	$00,$00,$80,$FE,$00,$00,$04,$06
	 dc.b	$00,$00,$04,$06,$00,$00,$82,$FE

	even
vtrans_vrt:	ds.w	1700	;View transformed coordinates	
ptrans_vrt:	ds.w	1700	;Perspective transformed coordinates
***************************************************************************
filled:		equ	0
line:		equ	1
dots:		equ	2
balls:		equ	3
obviewpb:	equ	0	;offsets for object linked list desc'n
obx:		equ	4
oby:		equ	6
obz:		equ	8
obvert:		equ	10
obfacelist:	equ	14
obvrtnum:	equ	0
obfacenum:	equ	0
centrepoint:	equ	20
style:		equ	18
numdots:	equ	20
linecolinfo:	equ	20
obcolors:	equ	22
hidenflag:	equ	26
activeflag:	equ	28
canitbehit:	equ	30
obw:		equ	32
onscreenx:	equ	34
onscreeny:	equ	36
obint:		equ	38
obxvel:		equ	40
obyvel:		equ	42
obzvel:		equ	44
worldvpb:	ds.w	20
boxvpb:		ds.w	20

box2:
	dc.l	boxvpb
	dc.w	0,0,1500
	dc.l	box2vrt
	dc.l	box2face
	dc.w	filled
	dc.w	12
	dc.l	box2palette
	dc.w	1
box2palette:
	dc.w	$0000,$040f,$010d,$0c3f,$021f,$0000,$0000,$0000
	dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
box2vrt:
	dc.w	4*4
	dc.w	-40,40,50
	dc.w	40,40,50
	dc.w	40,-40,50
	dc.w	-40,-40,50

	dc.w	50,40,40
	dc.w	50,40,-40
	dc.w	50,-40,-40
	dc.w	50,-40,40

	dc.w	40,40,-50
	dc.w	-40,40,-50
	dc.w	-40,-40,-50
	dc.w	40,-40,-50

	dc.w	-50,40,-40
	dc.w	-50,40,40
	dc.w	-50,-40,40
	dc.w	-50,-40,-40
	
box2face:
	dc.w	8
	dc.w	1,3,0,1,2,3
	dc.w	2,3,4,5,6,7
	dc.w	1,3,8,9,10,11
	dc.w	2,3,12,13,14,15

	dc.w	3,3,3,2,1,0
	dc.w	4,3,7,6,5,4
	dc.w	3,3,11,10,9,8
	dc.w	4,3,15,14,13,12

box:
	dc.l	boxvpb
	dc.w	0,0,1500
	dc.l	ttvrt
	dc.l	ttface
	dc.w	filled
	dc.w	15
	dc.l	0
	dc.w	1

ttvrt:
	dc.w	72
        dc.w    -124,00,-25
        dc.w    -106,00,-79
        dc.w    -105,00,-25
        dc.w    -97,00,-50
        dc.w    -88,00,-25
        dc.w    -87,00,-79
        dc.w    -80,00,-62
        dc.w    -71,00,-79
        dc.w    -70,00,-25
        dc.w    -66,00,49
        dc.w    -66,00,31
        dc.w    -61,00,-50
        dc.w    -53,00,-25
        dc.w    -52,00,-79
        dc.w    -49,00,-79
        dc.w    -44,00,31
        dc.w    -44,00,-17
        dc.w    -34,00,-25
        dc.w    -31,00,-25
        dc.w    -30,00,-79
        dc.w    -26,00,31
        dc.w    -26,00,-17
        dc.w    -26,00,-65
        dc.w    -21,00,-51
        dc.w    -09,00,-51
        dc.w    -05,00,-65
        dc.w    -04,00,49
        dc.w    -04,00,31
        dc.w    -00,00,49
        dc.w    -00,00,31
        dc.w    -00,00,-79
        dc.w    00,00,-25
        dc.w    17,00,-79
        dc.w    21,00,31
        dc.w    21,00,-17
        dc.w    21,00,-25
        dc.w    21,00,-79
        dc.w    35,00,-35
        dc.w    35,00,-51
        dc.w    35,00,-66
        dc.w    35,00,-79
        dc.w    39,00,31
        dc.w    39,00,-17
        dc.w    44,00,-35
        dc.w    44,00,-51
        dc.w    47,00,-38
        dc.w    47,00,-48
        dc.w    47,00,-79
        dc.w    48,00,-25
        dc.w    49,00,-60
        dc.w    52,00,-64
        dc.w    57,00,-57
        dc.w    58,00,-30
        dc.w    61,00,49
        dc.w    61,00,31
        dc.w    61,00,-37
        dc.w    61,00,-48
        dc.w    65,00,-37
        dc.w    65,00,-43
        dc.w    69,00,-29
        dc.w    70,00,-53
        dc.w    78,00,-25
        dc.w    86,00,-39
        dc.w    89,00,-64
        dc.w    97,00,-79
        dc.w    105,00,-51
        dc.w    107,00,-73
        dc.w    110,00,-60
        dc.w    110,00,-66
        dc.w    114,00,-25
        dc.w    114,00,-39
        dc.w    -15,00,-36
ttface:
	dc.w	26

        dc.w    15,3,10,27,26,09	;TT
        dc.w    15,3,16,21,20,15
        dc.w    15,3,29,54,53,28
        dc.w    15,3,34,42,41,33
        dc.w    15,4,00,01,05,03,02	;W
        dc.w    15,4,05,06,08,04,03
        dc.w    15,4,06,07,13,11,08
        dc.w    15,3,13,17,12,11
        dc.w    15,4,22,23,18,14,19	;A
        dc.w    15,2,71,18,23
        dc.w    15,3,22,25,24,23
        dc.w    15,2,31,18,71
        dc.w    15,3,24,25,31,71
        dc.w    15,3,30,32,31,25
        dc.w    15,5,36,40,39,38,37,35		;R
        dc.w    15,3,48,35,37,43
        dc.w    15,3,52,48,43,45
        dc.w    15,5,55,52,45,46,51,56
        dc.w    15,3,49,51,46,44
        dc.w    15,3,38,39,49,44
        dc.w    15,3,50,49,39,47
        dc.w    15,3,47,64,63,50		;S
        dc.w    15,6,64,66,68,67,65,62,63
        dc.w    15,3,60,63,62,58
        dc.w    15,4,58,62,61,59,57
        dc.w    15,3,61,62,70,69




palette:
	dc.w	$0077,$0167,$0257,$0347,$0437,$0527,$0617
	dc.w	$0707,$0716,$0725,$0734,$0743,$0752,$0761
	dc.w	$0770,$0771,$0772,$0773,$0774,$0775,$0776
	dc.w	$0777,$0677,$0577,$0477,$0377,$0277,$0177
	dc.w	$0077,$0067,$0057,$0047,$0037,$0027,$0017
	dc.w	$0007,$0107,$0207,$0307,$0407,$0507,$0607
	dc.w	$0707,$0706,$0705,$0704,$0703,$0702,$0701
	dc.w	$0700,$0710,$0720,$0730,$0740,$0750,$0760
	dc.w	$0770,$0670,$0570,$0470,$0370,$0270,$0170
	dc.w	$0070,$0071,$0072,$0073,$0074,$0075,$0076
	
letters:
	 dc.b	$38,$7C,$E6,$E6,$FE,$E6,$E6,$00
	 dc.b	$FC,$E6,$E6,$FC,$E6,$E6,$FC,$00
	 dc.b	$7C,$E6,$E0,$E0,$E0,$E6,$7C,$00
	 dc.b	$F8,$EC,$E6,$E6,$E6,$EC,$F8,$00
	 dc.b	$FE,$E0,$E0,$FC,$E0,$E0,$FE,$00
	 dc.b	$FE,$E0,$E0,$FC,$E0,$E0,$E0,$00
	 dc.b	$7E,$E0,$E0,$EE,$E6,$E6,$7E,$00
	 dc.b	$E6,$E6,$E6,$FE,$E6,$E6,$E6,$00
	 dc.b	$7C,$18,$18,$18,$18,$38,$7C,$00
	 dc.b	$06,$06,$06,$06,$06,$EE,$7C,$00
	 dc.b	$E6,$EC,$F8,$F0,$F8,$EC,$E6,$00
	 dc.b	$E0,$E0,$E0,$E0,$E0,$E0,$FE,$00
	 dc.b	$E3,$FF,$FF,$EB,$E3,$E3,$E3,$00
	 dc.b	$E6,$F6,$FE,$FE,$FE,$EE,$E6,$00
	 dc.b	$7C,$EE,$E6,$E6,$E6,$EE,$7C,$00
	 dc.b	$FC,$E6,$E6,$FC,$E0,$E0,$E0,$00
	 dc.b	$7C,$E6,$E6,$E6,$F6,$FC,$7E,$00
	 dc.b	$FC,$E6,$E6,$FC,$FC,$E6,$E6,$00
	 dc.b	$7C,$E6,$E0,$7C,$06,$E6,$7C,$00
	 dc.b	$FE,$38,$38,$38,$38,$38,$38,$00
	 dc.b	$E6,$E6,$E6,$E6,$E6,$E6,$7E,$00
	 dc.b	$E6,$E6,$E6,$E6,$E6,$7C,$38,$00
	 dc.b	$E3,$E3,$E3,$FB,$FF,$FF,$E7,$00
	 dc.b	$E6,$EE,$7C,$38,$7C,$EE,$E6,$00
	 dc.b	$E6,$E6,$EE,$7C,$38,$38,$38,$00
	 dc.b	$FE,$0E,$1C,$38,$70,$E0,$FE,$00
spacechar:
	dc.b	0,0,0,0,0,0,0,0

rho:		equ	0
theta:		equ	2
phi:		equ	4
s_theta:	equ	6
c_theta:	equ	8
s_phi:		equ	10
c_phi:		equ	12
s_rho:		equ	14
c_rho:		equ	16
x1s:	dc.w	0
y1s:	dc.w	0
x2s:	dc.w	0
y2s:	dc.w	0
yadd:	dc.l	0

balldata2:
 DC.W	$F81F,$0000,$07E0,$07E0,$0000,$FFFF,$0000,$0000,$0000,$0000
 DC.W	$E007,$01E0,$1E18,$1FF8,$0000,$FFFF,$0000,$0000,$0000,$0000
 DC.W	$C003,$0210,$3C0C,$3FFC,$0000,$FFFF,$0000,$0000,$0000,$0000
 DC.W	$8001,$04A8,$78E6,$7F1E,$0000,$FFFF,$0000,$0000,$0000,$0000
 DC.W	$8001,$3554,$79B2,$7E0E,$0000,$FFFF,$0000,$0000,$0000,$0000
 DC.W	$0000,$34E4,$F953,$FE4F,$0040,$FFFF,$0000,$0000,$0000,$0000
 DC.W	$0000,$3554,$F9B3,$FE0F,$0000,$FFFF,$0000,$0000,$0000,$0000
 DC.W	$0000,$34A4,$F8E3,$FF1F,$0000,$FFFF,$0000,$0000,$0000,$0000
 DC.W	$0000,$3408,$F807,$FFFF,$0000,$FFFF,$0000,$0000,$0000,$0000
 DC.W	$0000,$B414,$780F,$FFFF,$0000,$FFFF,$0000,$0000,$0000,$0000
 DC.W	$0000,$9BE8,$7C1F,$FFFF,$0000,$FFFF,$0000,$0000,$0000,$0000
 DC.W	$8001,$4C18,$3FFE,$7FFE,$0000,$FFFF,$0000,$0000,$0000,$0000
 DC.W	$8001,$4FF0,$3FFE,$7FFE,$0000,$FFFF,$0000,$0000,$0000,$0000
 DC.W	$C003,$23E0,$1FFC,$3FFC,$0000,$FFFF,$0000,$0000,$0000,$0000
 DC.W	$E007,$1800,$07F8,$1FF8,$0000,$FFFF,$0000,$0000,$0000,$0000
 DC.W	$F81F,$03C0,$0420,$07E0,$0000,$FFFF,$0000,$0000,$0000,$0000
 DC.W	$FC0F,$0000,$03F0,$03F0,$0000,$FFFF,$0000,$0000,$0000,$0000
 DC.W	$F003,$00F0,$0F0C,$0FFC,$0000,$FFFF,$0000,$0000,$0000,$0000
 DC.W	$E001,$0108,$1E06,$1FFE,$0000,$FFFF,$0000,$0000,$0000,$0000
 DC.W	$C000,$0254,$3C73,$3F8F,$0000,$FFFF,$0000,$0000,$0000,$0000
 DC.W	$C000,$1AAA,$3CD9,$3F07,$0000,$FFFF,$0000,$0000,$0000,$0000
 DC.W	$8000,$1A72,$7CA9,$7F27,$0020,$7FFF,$0000,$8000,$8000,$0000
 DC.W	$8000,$1AAA,$7CD9,$7F07,$0000,$7FFF,$0000,$8000,$8000,$0000
 DC.W	$8000,$1A52,$7C71,$7F8F,$0000,$7FFF,$0000,$8000,$8000,$0000
 DC.W	$8000,$1A04,$7C03,$7FFF,$0000,$7FFF,$0000,$8000,$8000,$0000
 DC.W	$8000,$5A0A,$3C07,$7FFF,$0000,$7FFF,$0000,$8000,$8000,$0000
 DC.W	$8000,$4DF4,$3E0F,$7FFF,$0000,$7FFF,$0000,$8000,$8000,$0000
 DC.W	$C000,$260C,$1FFF,$3FFF,$0000,$FFFF,$0000,$0000,$0000,$0000
 DC.W	$C000,$27F8,$1FFF,$3FFF,$0000,$FFFF,$0000,$0000,$0000,$0000
 DC.W	$E001,$11F0,$0FFE,$1FFE,$0000,$FFFF,$0000,$0000,$0000,$0000
 DC.W	$F003,$0C00,$03FC,$0FFC,$0000,$FFFF,$0000,$0000,$0000,$0000
 DC.W	$FC0F,$01E0,$0210,$03F0,$0000,$FFFF,$0000,$0000,$0000,$0000
 DC.W	$FE07,$0000,$01F8,$01F8,$0000,$FFFF,$0000,$0000,$0000,$0000
 DC.W	$F801,$0078,$0786,$07FE,$0000,$FFFF,$0000,$0000,$0000,$0000
 DC.W	$F000,$0084,$0F03,$0FFF,$0000,$FFFF,$0000,$0000,$0000,$0000
 DC.W	$E000,$012A,$1E39,$1FC7,$0000,$7FFF,$0000,$8000,$8000,$0000
 DC.W	$E000,$0D55,$1E6C,$1F83,$0000,$7FFF,$0000,$8000,$8000,$0000
 DC.W	$C000,$0D39,$3E54,$3F93,$0010,$3FFF,$0000,$C000,$C000,$0000
 DC.W	$C000,$0D55,$3E6C,$3F83,$0000,$3FFF,$0000,$C000,$C000,$0000
 DC.W	$C000,$0D29,$3E38,$3FC7,$0000,$3FFF,$0000,$C000,$C000,$0000
 DC.W	$C000,$0D02,$3E01,$3FFF,$0000,$3FFF,$0000,$C000,$C000,$0000
 DC.W	$C000,$2D05,$1E03,$3FFF,$0000,$3FFF,$0000,$C000,$C000,$0000
 DC.W	$C000,$26FA,$1F07,$3FFF,$0000,$3FFF,$0000,$C000,$C000,$0000
 DC.W	$E000,$1306,$0FFF,$1FFF,$0000,$7FFF,$0000,$8000,$8000,$0000
 DC.W	$E000,$13FC,$0FFF,$1FFF,$0000,$7FFF,$0000,$8000,$8000,$0000
 DC.W	$F000,$08F8,$07FF,$0FFF,$0000,$FFFF,$0000,$0000,$0000,$0000
 DC.W	$F801,$0600,$01FE,$07FE,$0000,$FFFF,$0000,$0000,$0000,$0000
 DC.W	$FE07,$00F0,$0108,$01F8,$0000,$FFFF,$0000,$0000,$0000,$0000
 DC.W	$FF03,$0000,$00FC,$00FC,$0000,$FFFF,$0000,$0000,$0000,$0000
 DC.W	$FC00,$003C,$03C3,$03FF,$0000,$FFFF,$0000,$0000,$0000,$0000
 DC.W	$F800,$0042,$0781,$07FF,$0000,$7FFF,$0000,$8000,$8000,$0000
 DC.W	$F000,$0095,$0F1C,$0FE3,$0000,$3FFF,$0000,$C000,$C000,$0000
 DC.W	$F000,$06AA,$0F36,$0FC1,$0000,$3FFF,$8000,$4000,$C000,$0000
 DC.W	$E000,$069C,$1F2A,$1FC9,$0008,$1FFF,$8000,$6000,$E000,$0000
 DC.W	$E000,$06AA,$1F36,$1FC1,$0000,$1FFF,$8000,$6000,$E000,$0000
 DC.W	$E000,$0694,$1F1C,$1FE3,$0000,$1FFF,$8000,$6000,$E000,$0000
 DC.W	$E000,$0681,$1F00,$1FFF,$0000,$1FFF,$0000,$E000,$E000,$0000
 DC.W	$E000,$1682,$0F01,$1FFF,$0000,$1FFF,$8000,$E000,$E000,$0000
 DC.W	$E000,$137D,$0F83,$1FFF,$0000,$1FFF,$0000,$E000,$E000,$0000
 DC.W	$F000,$0983,$07FF,$0FFF,$0000,$3FFF,$0000,$C000,$C000,$0000
 DC.W	$F000,$09FE,$07FF,$0FFF,$0000,$3FFF,$0000,$C000,$C000,$0000
 DC.W	$F800,$047C,$03FF,$07FF,$0000,$7FFF,$0000,$8000,$8000,$0000
 DC.W	$FC00,$0300,$00FF,$03FF,$0000,$FFFF,$0000,$0000,$0000,$0000
 DC.W	$FF03,$0078,$0084,$00FC,$0000,$FFFF,$0000,$0000,$0000,$0000
 DC.W	$FF81,$0000,$007E,$007E,$0000,$FFFF,$0000,$0000,$0000,$0000
 DC.W	$FE00,$001E,$01E1,$01FF,$0000,$7FFF,$0000,$8000,$8000,$0000
 DC.W	$FC00,$0021,$03C0,$03FF,$0000,$3FFF,$0000,$C000,$C000,$0000
 DC.W	$F800,$004A,$078E,$07F1,$0000,$1FFF,$8000,$6000,$E000,$0000
 DC.W	$F800,$0355,$079B,$07E0,$0000,$1FFF,$4000,$2000,$E000,$0000
 DC.W	$F000,$034E,$0F95,$0FE4,$0004,$0FFF,$4000,$3000,$F000,$0000
 DC.W	$F000,$0355,$0F9B,$0FE0,$0000,$0FFF,$4000,$3000,$F000,$0000
 DC.W	$F000,$034A,$0F8E,$0FF1,$0000,$0FFF,$4000,$3000,$F000,$0000
 DC.W	$F000,$0340,$0F80,$0FFF,$0000,$0FFF,$8000,$7000,$F000,$0000
 DC.W	$F000,$0B41,$0780,$0FFF,$0000,$0FFF,$4000,$F000,$F000,$0000
 DC.W	$F000,$09BE,$07C1,$0FFF,$0000,$0FFF,$8000,$F000,$F000,$0000
 DC.W	$F800,$04C1,$03FF,$07FF,$0000,$1FFF,$8000,$E000,$E000,$0000
 DC.W	$F800,$04FF,$03FF,$07FF,$0000,$1FFF,$0000,$E000,$E000,$0000
 DC.W	$FC00,$023E,$01FF,$03FF,$0000,$3FFF,$0000,$C000,$C000,$0000
 DC.W	$FE00,$0180,$007F,$01FF,$0000,$7FFF,$0000,$8000,$8000,$0000
 DC.W	$FF81,$003C,$0042,$007E,$0000,$FFFF,$0000,$0000,$0000,$0000
 DC.W	$FFC0,$0000,$003F,$003F,$0000,$FFFF,$0000,$0000,$0000,$0000
 DC.W	$FF00,$000F,$00F0,$00FF,$0000,$3FFF,$0000,$C000,$C000,$0000
 DC.W	$FE00,$0010,$01E0,$01FF,$0000,$1FFF,$8000,$6000,$E000,$0000
 DC.W	$FC00,$0025,$03C7,$03F8,$0000,$0FFF,$4000,$3000,$F000,$0000
 DC.W	$FC00,$01AA,$03CD,$03F0,$0000,$0FFF,$A000,$9000,$7000,$0000
 DC.W	$F800,$01A7,$07CA,$07F2,$0002,$07FF,$2000,$9800,$7800,$0000
 DC.W	$F800,$01AA,$07CD,$07F0,$0000,$07FF,$A000,$9800,$7800,$0000
 DC.W	$F800,$01A5,$07C7,$07F8,$0000,$07FF,$2000,$1800,$F800,$0000
 DC.W	$F800,$01A0,$07C0,$07FF,$0000,$07FF,$4000,$3800,$F800,$0000
 DC.W	$F800,$05A0,$03C0,$07FF,$0000,$07FF,$A000,$7800,$F800,$0000
 DC.W	$F800,$04DF,$03E0,$07FF,$0000,$07FF,$4000,$F800,$F800,$0000
 DC.W	$FC00,$0260,$01FF,$03FF,$0000,$0FFF,$C000,$F000,$F000,$0000 
 DC.W	$FC00,$027F,$01FF,$03FF,$0000,$0FFF,$8000,$F000,$F000,$0000
 DC.W	$FE00,$011F,$00FF,$01FF,$0000,$1FFF,$0000,$E000,$E000,$0000
 DC.W	$FF00,$00C0,$003F,$00FF,$0000,$3FFF,$0000,$C000,$C000,$0000
 DC.W	$FFC0,$001E,$0021,$003F,$0000,$FFFF,$0000,$0000,$0000,$0000
 DC.W	$FFE0,$0000,$001F,$001F,$0000,$7FFF,$0000,$8000,$8000,$0000
 DC.W	$FF80,$0007,$0078,$007F,$0000,$1FFF,$8000,$6000,$E000,$0000
 DC.W	$FF00,$0008,$00F0,$00FF,$0000,$0FFF,$4000,$3000,$F000,$0000
 DC.W	$FE00,$0012,$01E3,$01FC,$0000,$07FF,$A000,$9800,$7800,$0000
 DC.W	$FE00,$00D5,$01E6,$01F8,$0000,$07FF,$5000,$C800,$3800,$0000
 DC.W	$FC00,$00D3,$03E5,$03F9,$0001,$03FF,$9000,$4C00,$3C00,$0000
 DC.W	$FC00,$00D5,$03E6,$03F8,$0000,$03FF,$5000,$CC00,$3C00,$0000
 DC.W	$FC00,$00D2,$03E3,$03FC,$0000,$03FF,$9000,$8C00,$7C00,$0000
 DC.W	$FC00,$00D0,$03E0,$03FF,$0000,$03FF,$2000,$1C00,$FC00,$0000
 DC.W	$FC00,$02D0,$01E0,$03FF,$0000,$03FF,$5000,$3C00,$FC00,$0000
 DC.W	$FC00,$026F,$01F0,$03FF,$0000,$03FF,$A000,$7C00,$FC00,$0000
 DC.W	$FE00,$0130,$00FF,$01FF,$0000,$07FF,$6000,$F800,$F800,$0000
 DC.W	$FE00,$013F,$00FF,$01FF,$0000,$07FF,$C000,$F800,$F800,$0000
 DC.W	$FF00,$008F,$007F,$00FF,$0000,$0FFF,$8000,$F000,$F000,$0000
 DC.W	$FF80,$0060,$001F,$007F,$0000,$1FFF,$0000,$E000,$E000,$0000
 DC.W	$FFE0,$000F,$0010,$001F,$0000,$7FFF,$0000,$8000,$8000,$0000
 DC.W	$FFF0,$0000,$000F,$000F,$0000,$3FFF,$0000,$C000,$C000,$0000
 DC.W	$FFC0,$0003,$003C,$003F,$0000,$0FFF,$C000,$3000,$F000,$0000
 DC.W	$FF80,$0004,$0078,$007F,$0000,$07FF,$2000,$1800,$F800,$0000
 DC.W	$FF00,$0009,$00F1,$00FE,$0000,$03FF,$5000,$CC00,$3C00,$0000
 DC.W	$FF00,$006A,$00F3,$00FC,$0000,$03FF,$A800,$6400,$1C00,$0000
 DC.W	$FE00,$0069,$01F2,$01FC,$0000,$01FF,$C800,$A600,$9E00,$8000
 DC.W	$FE00,$006A,$01F3,$01FC,$0000,$01FF,$A800,$6600,$1E00,$0000
 DC.W	$FE00,$0069,$01F1,$01FE,$0000,$01FF,$4800,$C600,$3E00,$0000
 DC.W	$FE00,$0068,$01F0,$01FF,$0000,$01FF,$1000,$0E00,$FE00,$0000
 DC.W	$FE00,$0168,$00F0,$01FF,$0000,$01FF,$2800,$1E00,$FE00,$0000
 DC.W	$FE00,$0137,$00F8,$01FF,$0000,$01FF,$D000,$3E00,$FE00,$0000
 DC.W	$FF00,$0098,$007F,$00FF,$0000,$03FF,$3000,$FC00,$FC00,$0000
 DC.W	$FF00,$009F,$007F,$00FF,$0000,$03FF,$E000,$FC00,$FC00,$0000
 DC.W	$FF80,$0047,$003F,$007F,$0000,$07FF,$C000,$F800,$F800,$0000
 DC.W	$FFC0,$0030,$000F,$003F,$0000,$0FFF,$0000,$F000,$F000,$0000
 DC.W	$FFF0,$0007,$0008,$000F,$0000,$3FFF,$8000,$4000,$C000,$0000
 DC.W	$FFF8,$0000,$0007,$0007,$0000,$1FFF,$0000,$E000,$E000,$0000
 DC.W	$FFE0,$0001,$001E,$001F,$0000,$07FF,$E000,$1800,$F800,$0000
 DC.W	$FFC0,$0002,$003C,$003F,$0000,$03FF,$1000,$0C00,$FC00,$0000
 DC.W	$FF80,$0004,$0078,$007F,$0000,$01FF,$A800,$E600,$1E00,$0000
 DC.W	$FF80,$0035,$0079,$007E,$0000,$01FF,$5400,$B200,$0E00,$0000
 DC.W	$FF00,$0034,$00F9,$00FE,$0000,$00FF,$E400,$5300,$4F00,$4000
 DC.W	$FF00,$0035,$00F9,$00FE,$0000,$00FF,$5400,$B300,$0F00,$0000
 DC.W	$FF00,$0034,$00F8,$00FF,$0000,$00FF,$A400,$E300,$1F00,$0000
 DC.W	$FF00,$0034,$00F8,$00FF,$0000,$00FF,$0800,$0700,$FF00,$0000
 DC.W	$FF00,$00B4,$0078,$00FF,$0000,$00FF,$1400,$0F00,$FF00,$0000
 DC.W	$FF00,$009B,$007C,$00FF,$0000,$00FF,$E800,$1F00,$FF00,$0000
 DC.W	$FF80,$004C,$003F,$007F,$0000,$01FF,$1800,$FE00,$FE00,$0000
 DC.W	$FF80,$004F,$003F,$007F,$0000,$01FF,$F000,$FE00,$FE00,$0000
 DC.W	$FFC0,$0023,$001F,$003F,$0000,$03FF,$E000,$FC00,$FC00,$0000
 DC.W	$FFE0,$0018,$0007,$001F,$0000,$07FF,$0000,$F800,$F800,$0000
 DC.W	$FFF8,$0003,$0004,$0007,$0000,$1FFF,$C000,$2000,$E000,$0000
 DC.W	$FFFC,$0000,$0003,$0003,$0000,$0FFF,$0000,$F000,$F000,$0000
 DC.W	$FFF0,$0000,$000F,$000F,$0000,$03FF,$F000,$0C00,$FC00,$0000
 	DC.W	$FFE0,$0001,$001E,$001F,$0000,$01FF,$0800,$0600,$FE00,$0000
	DC.W	$FFC0,$0002,$003C,$003F,$0000,$00FF,$5400,$7300,$8F00,$0000
	DC.W	$FFC0,$001A,$003C,$003F,$0000,$00FF,$AA00,$D900,$0700,$0000
	DC.W	$FF80,$001A,$007C,$007F,$0000,$007F,$7200,$A980,$2780,$2000
	DC.W	$FF80,$001A,$007C,$007F,$0000,$007F,$AA00,$D980,$0780,$0000
	DC.W	$FF80,$001A,$007C,$007F,$0000,$007F,$5200,$7180,$8F80,$0000
	DC.W	$FF80,$001A,$007C,$007F,$0000,$007F,$0400,$0380,$FF80,$0000
	DC.W	$FF80,$005A,$003C,$007F,$0000,$007F,$0A00,$0780,$FF80,$0000
	DC.W	$FF80,$004D,$003E,$007F,$0000,$007F,$F400,$0F80,$FF80,$0000
	DC.W	$FFC0,$0026,$001F,$003F,$0000,$00FF,$0C00,$FF00,$FF00,$0000
	DC.W	$FFC0,$0027,$001F,$003F,$0000,$00FF,$F800,$FF00,$FF00,$0000
	DC.W	$FFE0,$0011,$000F,$001F,$0000,$01FF,$F000,$FE00,$FE00,$0000
	DC.W	$FFF0,$000C,$0003,$000F,$0000,$03FF,$0000,$FC00,$FC00,$0000
	DC.W	$FFFC,$0001,$0002,$0003,$0000,$0FFF,$E000,$1000,$F000,$0000
	DC.W	$FFFE,$0000,$0001,$0001,$0000,$07FF,$0000,$F800,$F800,$0000
	DC.W	$FFF8,$0000,$0007,$0007,$0000,$01FF,$7800,$8600,$FE00,$0000
	DC.W	$FFF0,$0000,$000F,$000F,$0000,$00FF,$8400,$0300,$FF00,$0000
	DC.W	$FFE0,$0001,$001E,$001F,$0000,$007F,$2A00,$3980,$C780,$0000
	DC.W	$FFE0,$000D,$001E,$001F,$0000,$007F,$5500,$6C80,$8380,$0000
	DC.W	$FFC0,$000D,$003E,$003F,$0000,$003F,$3900,$54C0,$93C0,$1000
	DC.W	$FFC0,$000D,$003E,$003F,$0000,$003F,$5500,$6CC0,$83C0,$0000
	DC.W	$FFC0,$000D,$003E,$003F,$0000,$003F,$2900,$38C0,$C7C0,$0000
	DC.W	$FFC0,$000D,$003E,$003F,$0000,$003F,$0200,$01C0,$FFC0,$0000
	DC.W	$FFC0,$002D,$001E,$003F,$0000,$003F,$0500,$03C0,$FFC0,$0000
	DC.W	$FFC0,$0026,$001F,$003F,$0000,$003F,$FA00,$07C0,$FFC0,$0000
	DC.W	$FFE0,$0013,$000F,$001F,$0000,$007F,$0600,$FF80,$FF80,$0000
	DC.W	$FFE0,$0013,$000F,$001F,$0000,$007F,$FC00,$FF80,$FF80,$0000
	DC.W	$FFF0,$0008,$0007,$000F,$0000,$00FF,$F800,$FF00,$FF00,$0000
	DC.W	$FFF8,$0006,$0001,$0007,$0000,$01FF,$0000,$FE00,$FE00,$0000
	DC.W	$FFFE,$0000,$0001,$0001,$0000,$07FF,$F000,$0800,$F800,$0000
	DC.W	$FFFF,$0000,$0000,$0000,$0000,$03FF,$0000,$FC00,$FC00,$0000
	DC.W	$FFFC,$0000,$0003,$0003,$0000,$00FF,$3C00,$C300,$FF00,$0000
	DC.W	$FFF8,$0000,$0007,$0007,$0000,$007F,$4200,$8180,$FF80,$0000
	DC.W	$FFF0,$0000,$000F,$000F,$0000,$003F,$9500,$1CC0,$E3C0,$0000
	DC.W	$FFF0,$0006,$000F,$000F,$0000,$003F,$AA80,$3640,$C1C0,$0000
	DC.W	$FFE0,$0006,$001F,$001F,$0000,$001F,$9C80,$2A60,$C9E0,$0800
	DC.W	$FFE0,$0006,$001F,$001F,$0000,$001F,$AA80,$3660,$C1E0,$0000
	DC.W	$FFE0,$0006,$001F,$001F,$0000,$001F,$9480,$1C60,$E3E0,$0000
	DC.W	$FFE0,$0006,$001F,$001F,$0000,$001F,$8100,$00E0,$FFE0,$0000
	DC.W	$FFE0,$0016,$000F,$001F,$0000,$001F,$8280,$01E0,$FFE0,$0000
	DC.W	$FFE0,$0013,$000F,$001F,$0000,$001F,$7D00,$83E0,$FFE0,$0000
	DC.W	$FFF0,$0009,$0007,$000F,$0000,$003F,$8300,$FFC0,$FFC0,$0000
	DC.W	$FFF0,$0009,$0007,$000F,$0000,$003F,$FE00,$FFC0,$FFC0,$0000
	DC.W	$FFF8,$0004,$0003,$0007,$0000,$007F,$7C00,$FF80,$FF80,$0000
	DC.W	$FFFC,$0003,$0000,$0003,$0000,$00FF,$0000,$FF00,$FF00,$0000
	DC.W	$FFFF,$0000,$0000,$0000,$0000,$03FF,$7800,$8400,$FC00,$0000
	DC.W	$FFFF,$0000,$0000,$0000,$0000,$81FF,$0000,$7E00,$7E00,$0000
	DC.W	$FFFE,$0000,$0001,$0001,$0000,$007F,$1E00,$E180,$FF80,$0000
	DC.W	$FFFC,$0000,$0003,$0003,$0000,$003F,$2100,$C0C0,$FFC0,$0000
	DC.W	$FFF8,$0000,$0007,$0007,$0000,$001F,$4A80,$8E60,$F1E0,$0000
	DC.W	$FFF8,$0003,$0007,$0007,$0000,$001F,$5540,$9B20,$E0E0,$0000
	DC.W	$FFF0,$0003,$000F,$000F,$0000,$000F,$4E40,$9530,$E4F0,$0400
	DC.W	$FFF0,$0003,$000F,$000F,$0000,$000F,$5540,$9B30,$E0F0,$0000
	DC.W	$FFF0,$0003,$000F,$000F,$0000,$000F,$4A40,$8E30,$F1F0,$0000
	DC.W	$FFF0,$0003,$000F,$000F,$0000,$000F,$4080,$8070,$FFF0,$0000
	DC.W	$FFF0,$000B,$0007,$000F,$0000,$000F,$4140,$80F0,$FFF0,$0000
	DC.W	$FFF0,$0009,$0007,$000F,$0000,$000F,$BE80,$C1F0,$FFF0,$0000
	DC.W	$FFF8,$0004,$0003,$0007,$0000,$001F,$C180,$FFE0,$FFE0,$0000
	DC.W	$FFF8,$0004,$0003,$0007,$0000,$001F,$FF00,$FFE0,$FFE0,$0000
	DC.W	$FFFC,$0002,$0001,$0003,$0000,$003F,$3E00,$FFC0,$FFC0,$0000
	DC.W	$FFFE,$0001,$0000,$0001,$0000,$007F,$8000,$7F80,$FF80,$0000
	DC.W	$FFFF,$0000,$0000,$0000,$0000,$81FF,$3C00,$4200,$7E00,$0000
	DC.W	$FFFF,$0000,$0000,$0000,$0000,$C0FF,$0000,$3F00,$3F00,$0000
	DC.W	$FFFF,$0000,$0000,$0000,$0000,$003F,$0F00,$F0C0,$FFC0,$0000
	DC.W	$FFFE,$0000,$0001,$0001,$0000,$001F,$1080,$E060,$FFE0,$0000
	DC.W	$FFFC,$0000,$0003,$0003,$0000,$000F,$2540,$C730,$F8F0,$0000
	DC.W	$FFFC,$0001,$0003,$0003,$0000,$000F,$AAA0,$CD90,$F070,$0000
	DC.W	$FFF8,$0001,$0007,$0007,$0000,$0007,$A720,$CA98,$F278,$0200
	DC.W	$FFF8,$0001,$0007,$0007,$0000,$0007,$AAA0,$CD98,$F078,$0000
	DC.W	$FFF8,$0001,$0007,$0007,$0000,$0007,$A520,$C718,$F8F8,$0000
	DC.W	$FFF8,$0001,$0007,$0007,$0000,$0007,$A040,$C038,$FFF8,$0000
	DC.W	$FFF8,$0005,$0003,$0007,$0000,$0007,$A0A0,$C078,$FFF8,$0000
	DC.W	$FFF8,$0004,$0003,$0007,$0000,$0007,$DF40,$E0F8,$FFF8,$0000
	DC.W	$FFFC,$0002,$0001,$0003,$0000,$000F,$60C0,$FFF0,$FFF0,$0000
	DC.W	$FFFC,$0002,$0001,$0003,$0000,$000F,$7F80,$FFF0,$FFF0,$0000
	DC.W	$FFFE,$0001,$0000,$0001,$0000,$001F,$1F00,$FFE0,$FFE0,$0000
	DC.W	$FFFF,$0000,$0000,$0000,$0000,$003F,$C000,$3FC0,$FFC0,$0000
	DC.W	$FFFF,$0000,$0000,$0000,$0000,$C0FF,$1E00,$2100,$3F00,$0000
	DC.W	$FFFF,$0000,$0000,$0000,$0000,$E07F,$0000,$1F80,$1F80,$0000
	DC.W	$FFFF,$0000,$0000,$0000,$0000,$801F,$0780,$7860,$7FE0,$0000
	DC.W	$FFFF,$0000,$0000,$0000,$0000,$000F,$0840,$F030,$FFF0,$0000
	DC.W	$FFFE,$0000,$0001,$0001,$0000,$0007,$12A0,$E398,$FC78,$0000
	DC.W	$FFFE,$0000,$0001,$0001,$0000,$0007,$D550,$E6C8,$F838,$0000
	DC.W	$FFFC,$0000,$0003,$0003,$0000,$0003,$D390,$E54C,$F93C,$0100
	DC.W	$FFFC,$0000,$0003,$0003,$0000,$0003,$D550,$E6CC,$F83C,$0000
	DC.W	$FFFC,$0000,$0003,$0003,$0000,$0003,$D290,$E38C,$FC7C,$0000
	DC.W	$FFFC,$0000,$0003,$0003,$0000,$0003,$D020,$E01C,$FFFC,$0000
	DC.W	$FFFC,$0002,$0001,$0003,$0000,$0003,$D050,$E03C,$FFFC,$0000
	DC.W	$FFFC,$0002,$0001,$0003,$0000,$0003,$6FA0,$F07C,$FFFC,$0000
	DC.W	$FFFE,$0001,$0000,$0001,$0000,$0007,$3060,$FFF8,$FFF8,$0000
	DC.W	$FFFE,$0001,$0000,$0001,$0000,$0007,$3FC0,$FFF8,$FFF8,$0000
	DC.W	$FFFF,$0000,$0000,$0000,$0000,$000F,$8F80,$7FF0,$FFF0,$0000
	DC.W	$FFFF,$0000,$0000,$0000,$0000,$801F,$6000,$1FE0,$7FE0,$0000
	DC.W	$FFFF,$0000,$0000,$0000,$0000,$E07F,$0F00,$1080,$1F80,$0000
	DC.W	$FFFF,$0000,$0000,$0000,$0000,$F03F,$0000,$0FC0,$0FC0,$0000
	DC.W	$FFFF,$0000,$0000,$0000,$0000,$C00F,$03C0,$3C30,$3FF0,$0000
	DC.W	$FFFF,$0000,$0000,$0000,$0000,$8007,$0420,$7818,$7FF8,$0000
	DC.W	$FFFF,$0000,$0000,$0000,$0000,$0003,$0950,$F1CC,$FE3C,$0000
	DC.W	$FFFF,$0000,$0000,$0000,$0000,$0003,$6AA8,$F364,$FC1C,$0000
	DC.W	$FFFE,$0000,$0001,$0001,$0000,$0001,$69C8,$F2A6,$FC9E,$0080
	DC.W	$FFFE,$0000,$0001,$0001,$0000,$0001,$6AA8,$F366,$FC1E,$0000
	DC.W	$FFFE,$0000,$0001,$0001,$0000,$0001,$6948,$F1C6,$FE3E,$0000
	DC.W	$FFFE,$0000,$0001,$0001,$0000,$0001,$6810,$F00E,$FFFE,$0000
	DC.W	$FFFE,$0001,$0000,$0001,$0000,$0001,$6828,$F01E,$FFFE,$0000
	DC.W	$FFFE,$0001,$0000,$0001,$0000,$0001,$37D0,$F83E,$FFFE,$0000
	DC.W	$FFFF,$0000,$0000,$0000,$0000,$0003,$9830,$7FFC,$FFFC,$0000
	DC.W	$FFFF,$0000,$0000,$0000,$0000,$0003,$9FE0,$7FFC,$FFFC,$0000
	DC.W	$FFFF,$0000,$0000,$0000,$0000,$8007,$47C0,$3FF8,$7FF8,$0000
	DC.W	$FFFF,$0000,$0000,$0000,$0000,$C00F,$3000,$0FF0,$3FF0,$0000
	DC.W	$FFFF,$0000,$0000,$0000,$0000,$F03F,$0780,$0840,$0FC0,$0000


balldata1:
	DC.L	$F07F0000,$0F800F80,$0000FFFF,$00000000,$00000000,$C01F0440,$38203FE0,$0000FFFF
	DC.L	$00000000,$00000000,$800F0A80,$73B07C70,$0000FFFF,$00000000,$00000000,$800F2960
	DC.L	$72D07C30,$0000FFFF,$00000000,$00000000,$00072960,$F2D8FC38,$0000FFFF,$00000000
	DC.L	$00000000,$00072AA0,$F398FC78,$0000FFFF,$00000000,$00000000,$00072800,$F038FFF8
	DC.L	$0000FFFF,$00000000,$00000000,$0007B780,$7878FFF8,$0000FFFF,$00000000,$00000000
	DC.L	$800F5840,$3FF07FF0,$0000FFFF,$00000000,$00000000,$800F5FC0,$3FF07FF0,$0000FFFF
	DC.L	$00000000,$00000000,$C01F3000,$0FE03FE0,$0000FFFF,$00000000,$00000000,$F07F0700
	DC.L	$08800F80,$0000FFFF,$00000000,$00000000,$FFFF0000,$00000000,$0000FFFF,$00000000
	DC.L	$00000000,$FFFF0000,$00000000,$0000FFFF,$00000000,$00000000,$FFFF0000,$00000000
	DC.L	$0000FFFF,$00000000,$00000000,$FFFF0000,$00000000,$0000FFFF,$00000000,$00000000
	DC.L	$F83F0000,$07C007C0,$0000FFFF,$00000000,$00000000,$E00F0220,$1C101FF0,$0000FFFF
	DC.L	$00000000,$00000000,$C0070540,$39D83E38,$0000FFFF,$00000000,$00000000,$C00714B0
	DC.L	$39683E18,$0000FFFF,$00000000,$00000000,$800314B0,$796C7E1C,$0000FFFF,$00000000
	DC.L	$00000000,$80031550,$79CC7E3C,$0000FFFF,$00000000,$00000000,$80031400,$781C7FFC
	DC.L	$0000FFFF,$00000000,$00000000,$80035BC0,$3C3C7FFC,$0000FFFF,$00000000,$00000000
	DC.L	$C0072C20,$1FF83FF8,$0000FFFF,$00000000,$00000000,$C0072FE0,$1FF83FF8,$0000FFFF
	DC.L	$00000000,$00000000,$E00F1800,$07F01FF0,$0000FFFF,$00000000,$00000000,$F83F0380
	DC.L	$044007C0,$0000FFFF,$00000000,$00000000,$FFFF0000,$00000000,$0000FFFF,$00000000
	DC.L	$00000000,$FFFF0000,$00000000,$0000FFFF,$00000000,$00000000,$FFFF0000,$00000000
	DC.L	$0000FFFF,$00000000,$00000000,$FFFF0000,$00000000,$0000FFFF,$00000000,$00000000
	DC.L	$FC1F0000,$03E003E0,$0000FFFF,$00000000,$00000000,$F0070110,$0E080FF8,$0000FFFF
	DC.L	$00000000,$00000000,$E00302A0,$1CEC1F1C,$0000FFFF,$00000000,$00000000,$E0030A58
	DC.L	$1CB41F0C,$0000FFFF,$00000000,$00000000,$C0010A58,$3CB63F0E,$0000FFFF,$00000000
	DC.L	$00000000,$C0010AA8,$3CE63F1E,$0000FFFF,$00000000,$00000000,$C0010A00,$3C0E3FFE
	DC.L	$0000FFFF,$00000000,$00000000,$C0012DE0,$1E1E3FFE,$0000FFFF,$00000000,$00000000
	DC.L	$E0031610,$0FFC1FFC,$0000FFFF,$00000000,$00000000,$E00317F0,$0FFC1FFC,$0000FFFF
	DC.L	$00000000,$00000000,$F0070C00,$03F80FF8,$0000FFFF,$00000000,$00000000,$FC1F01C0
	DC.L	$022003E0,$0000FFFF,$00000000,$00000000,$FFFF0000,$00000000,$0000FFFF,$00000000
	DC.L	$00000000,$FFFF0000,$00000000,$0000FFFF,$00000000,$00000000,$FFFF0000,$00000000
	DC.L	$0000FFFF,$00000000,$00000000,$FFFF0000,$00000000,$0000FFFF,$00000000,$00000000
	DC.L	$FE0F0000,$01F001F0,$0000FFFF,$00000000,$00000000,$F8030088,$070407FC,$0000FFFF
	DC.L	$00000000,$00000000,$F0010150,$0E760F8E,$0000FFFF,$00000000,$00000000,$F001052C
	DC.L	$0E5A0F86,$0000FFFF,$00000000,$00000000,$E000052C,$1E5B1F87,$0000FFFF,$00000000
	DC.L	$00000000,$E0000554,$1E731F8F,$0000FFFF,$00000000,$00000000,$E0000500,$1E071FFF
	DC.L	$0000FFFF,$00000000,$00000000,$E00016F0,$0F0F1FFF,$0000FFFF,$00000000,$00000000
	DC.L	$F0010B08,$07FE0FFE,$0000FFFF,$00000000,$00000000,$F0010BF8,$07FE0FFE,$0000FFFF
	DC.L	$00000000,$00000000,$F8030600,$01FC07FC,$0000FFFF,$00000000,$00000000,$FE0F00E0
	DC.L	$011001F0,$0000FFFF,$00000000,$00000000,$FFFF0000,$00000000,$0000FFFF,$00000000
	DC.L	$00000000,$FFFF0000,$00000000,$0000FFFF,$00000000,$00000000,$FFFF0000,$00000000
	DC.L	$0000FFFF,$00000000,$00000000,$FFFF0000,$00000000,$0000FFFF,$00000000,$00000000
	DC.L	$FF070000,$00F800F8,$0000FFFF,$00000000,$00000000,$FC010044,$038203FE,$0000FFFF
	DC.L	$00000000,$00000000,$F80000A8,$073B07C7,$0000FFFF,$00000000,$00000000,$F8000296
	DC.L	$072D07C3,$0000FFFF,$00000000,$00000000,$F0000296,$0F2D0FC3,$00007FFF,$00008000
	DC.L	$80000000,$F00002AA,$0F390FC7,$00007FFF,$00008000,$80000000,$F0000280,$0F030FFF
	DC.L	$00007FFF,$00008000,$80000000,$F0000B78,$07870FFF,$00007FFF,$00008000,$80000000
	DC.L	$F8000584,$03FF07FF,$0000FFFF,$00000000,$00000000,$F80005FC,$03FF07FF,$0000FFFF
	DC.L	$00000000,$00000000,$FC010300,$00FE03FE,$0000FFFF,$00000000,$00000000,$FF070070
	DC.L	$008800F8,$0000FFFF,$00000000,$00000000,$FFFF0000,$00000000,$0000FFFF,$00000000
	DC.L	$00000000,$FFFF0000,$00000000,$0000FFFF,$00000000,$00000000,$FFFF0000,$00000000
	DC.L	$0000FFFF,$00000000,$00000000,$FFFF0000,$00000000,$0000FFFF,$00000000,$00000000
	DC.L	$FF830000,$007C007C,$0000FFFF,$00000000,$00000000,$FE000022,$01C101FF,$0000FFFF
	DC.L	$00000000,$00000000,$FC000054,$039D03E3,$00007FFF,$00008000,$80000000,$FC00014B
	DC.L	$039603E1,$00007FFF,$00008000,$80000000,$F800014B,$079607E1,$00003FFF,$0000C000
	DC.L	$C0000000,$F8000155,$079C07E3,$00003FFF,$0000C000,$C0000000,$F8000140,$078107FF
	DC.L	$00003FFF,$0000C000,$C0000000,$F80005BC,$03C307FF,$00003FFF,$0000C000,$C0000000
	DC.L	$FC0002C2,$01FF03FF,$00007FFF,$00008000,$80000000,$FC0002FE,$01FF03FF,$00007FFF
	DC.L	$00008000,$80000000,$FE000180,$007F01FF,$0000FFFF,$00000000,$00000000,$FF830038
	DC.L	$0044007C,$0000FFFF,$00000000,$00000000,$FFFF0000,$00000000,$0000FFFF,$00000000
	DC.L	$00000000,$FFFF0000,$00000000,$0000FFFF,$00000000,$00000000,$FFFF0000,$00000000
	DC.L	$0000FFFF,$00000000,$00000000,$FFFF0000,$00000000,$0000FFFF,$00000000,$00000000
	DC.L	$FFC10000,$003E003E,$0000FFFF,$00000000,$00000000,$FF000011,$00E000FF,$00007FFF
	DC.L	$00008000,$80000000,$FE00002A,$01CE01F1,$00003FFF,$0000C000,$C0000000,$FE0000A5
	DC.L	$01CB01F0,$00003FFF,$80004000,$C0000000,$FC0000A5,$03CB03F0,$00001FFF,$80006000
	DC.L	$E0000000,$FC0000AA,$03CE03F1,$00001FFF,$80006000,$E0000000,$FC0000A0,$03C003FF
	DC.L	$00001FFF,$0000E000,$E0000000,$FC0002DE,$01E103FF,$00001FFF,$0000E000,$E0000000
	DC.L	$FE000161,$00FF01FF,$00003FFF,$0000C000,$C0000000,$FE00017F,$00FF01FF,$00003FFF
	DC.L	$0000C000,$C0000000,$FF0000C0,$003F00FF,$00007FFF,$00008000,$80000000,$FFC1001C
	DC.L	$0022003E,$0000FFFF,$00000000,$00000000,$FFFF0000,$00000000,$0000FFFF,$00000000
	DC.L	$00000000,$FFFF0000,$00000000,$0000FFFF,$00000000,$00000000,$FFFF0000,$00000000
	DC.L	$0000FFFF,$00000000,$00000000,$FFFF0000,$00000000,$0000FFFF,$00000000,$00000000
	DC.L	$FFE00000,$001F001F,$0000FFFF,$00000000,$00000000,$FF800008,$0070007F,$00003FFF
	DC.L	$80004000,$C0000000,$FF000015,$00E700F8,$00001FFF,$00006000,$E0000000,$FF000052
	DC.L	$00E500F8,$00001FFF,$C000A000,$60000000,$FE000052,$01E501F8,$00000FFF,$C000B000
	DC.L	$70000000,$FE000055,$01E701F8,$00000FFF,$40003000,$F0000000,$FE000050,$01E001FF
	DC.L	$00000FFF,$00007000,$F0000000,$FE00016F,$00F001FF,$00000FFF,$0000F000,$F0000000
	DC.L	$FF0000B0,$007F00FF,$00001FFF,$8000E000,$E0000000,$FF0000BF,$007F00FF,$00001FFF
	DC.L	$8000E000,$E0000000,$FF800060,$001F007F,$00003FFF,$0000C000,$C0000000,$FFE0000E
	DC.L	$0011001F,$0000FFFF,$00000000,$00000000,$FFFF0000,$00000000,$0000FFFF,$00000000
	DC.L	$00000000,$FFFF0000,$00000000,$0000FFFF,$00000000,$00000000,$FFFF0000,$00000000
	DC.L	$0000FFFF,$00000000,$00000000,$FFFF0000,$00000000,$0000FFFF,$00000000,$00000000
	DC.L	$FFF00000,$000F000F,$00007FFF,$00008000,$80000000,$FFC00004,$0038003F,$00001FFF
	DC.L	$40002000,$E0000000,$FF80000A,$0073007C,$00000FFF,$8000B000,$70000000,$FF800029
	DC.L	$0072007C,$00000FFF,$6000D000,$30000000,$FF000029,$00F200FC,$000007FF,$6000D800
	DC.L	$38000000,$FF00002A,$00F300FC,$000007FF,$A0009800,$78000000,$FF000028,$00F000FF
	DC.L	$000007FF,$00003800,$F8000000,$FF0000B7,$007800FF,$000007FF,$80007800,$F8000000
	DC.L	$FF800058,$003F007F,$00000FFF,$4000F000,$F0000000,$FF80005F,$003F007F,$00000FFF
	DC.L	$C000F000,$F0000000,$FFC00030,$000F003F,$00001FFF,$0000E000,$E0000000,$FFF00007
	DC.L	$0008000F,$00007FFF,$00008000,$80000000,$FFFF0000,$00000000,$0000FFFF,$00000000
	DC.L	$00000000,$FFFF0000,$00000000,$0000FFFF,$00000000,$00000000,$FFFF0000,$00000000
	DC.L	$0000FFFF,$00000000,$00000000,$FFFF0000,$00000000,$0000FFFF,$00000000,$00000000
	DC.L	$FFF80000,$00070007,$00003FFF,$0000C000,$C0000000,$FFE00002,$001C001F,$00000FFF
	DC.L	$20001000,$F0000000,$FFC00005,$0039003E,$000007FF,$4000D800,$38000000,$FFC00014
	DC.L	$0039003E,$000007FF,$B0006800,$18000000,$FF800014,$0079007E,$000003FF,$B0006C00
	DC.L	$1C000000,$FF800015,$0079007E,$000003FF,$5000CC00,$3C000000,$FF800014,$0078007F
	DC.L	$000003FF,$00001C00,$FC000000,$FF80005B,$003C007F,$000003FF,$C0003C00,$FC000000
	DC.L	$FFC0002C,$001F003F,$000007FF,$2000F800,$F8000000,$FFC0002F,$001F003F,$000007FF
	DC.L	$E000F800,$F8000000,$FFE00018,$0007001F,$00000FFF,$0000F000,$F0000000,$FFF80003
	DC.L	$00040007,$00003FFF,$80004000,$C0000000,$FFFF0000,$00000000,$0000FFFF,$00000000
	DC.L	$00000000,$FFFF0000,$00000000,$0000FFFF,$00000000,$00000000,$FFFF0000,$00000000
	DC.L	$0000FFFF,$00000000,$00000000,$FFFF0000,$00000000,$0000FFFF,$00000000,$00000000
	DC.L	$FFFC0000,$00030003,$00001FFF,$0000E000,$E0000000,$FFF00001,$000E000F,$000007FF
	DC.L	$10000800,$F8000000,$FFE00002,$001C001F,$000003FF,$A000EC00,$1C000000,$FFE0000A
	DC.L	$001C001F,$000003FF,$5800B400,$0C000000,$FFC0000A,$003C003F,$000001FF,$5800B600
	DC.L	$0E000000,$FFC0000A,$003C003F,$000001FF,$A800E600,$1E000000,$FFC0000A,$003C003F
	DC.L	$000001FF,$00000E00,$FE000000,$FFC0002D,$001E003F,$000001FF,$E0001E00,$FE000000
	DC.L	$FFE00016,$000F001F,$000003FF,$1000FC00,$FC000000,$FFE00017,$000F001F,$000003FF
	DC.L	$F000FC00,$FC000000,$FFF0000C,$0003000F,$000007FF,$0000F800,$F8000000,$FFFC0001
	DC.L	$00020003,$00001FFF,$C0002000,$E0000000,$FFFF0000,$00000000,$0000FFFF,$00000000
	DC.L	$00000000,$FFFF0000,$00000000,$0000FFFF,$00000000,$00000000,$FFFF0000,$00000000
	DC.L	$0000FFFF,$00000000,$00000000,$FFFF0000,$00000000,$0000FFFF,$00000000,$00000000
	DC.L	$FFFE0000,$00010001,$00000FFF,$0000F000,$F0000000,$FFF80000,$00070007,$000003FF
	DC.L	$88000400,$FC000000,$FFF00001,$000E000F,$000001FF,$50007600,$8E000000,$FFF00005
	DC.L	$000E000F,$000001FF,$2C005A00,$86000000,$FFE00005,$001E001F,$000000FF,$2C005B00
	DC.L	$87000000,$FFE00005,$001E001F,$000000FF,$54007300,$8F000000,$FFE00005,$001E001F
	DC.L	$000000FF,$00000700,$FF000000,$FFE00016,$000F001F,$000000FF,$F0000F00,$FF000000
	DC.L	$FFF0000B,$0007000F,$000001FF,$0800FE00,$FE000000,$FFF0000B,$0007000F,$000001FF
	DC.L	$F800FE00,$FE000000,$FFF80006,$00010007,$000003FF,$0000FC00,$FC000000,$FFFE0000
	DC.L	$00010001,$00000FFF,$E0001000,$F0000000,$FFFF0000,$00000000,$0000FFFF,$00000000
	DC.L	$00000000,$FFFF0000,$00000000,$0000FFFF,$00000000,$00000000,$FFFF0000,$00000000
	DC.L	$0000FFFF,$00000000,$00000000,$FFFF0000,$00000000,$0000FFFF,$00000000,$00000000
	DC.L	$FFFF0000,$00000000,$000007FF,$0000F800,$F8000000,$FFFC0000,$00030003,$000001FF
	DC.L	$44008200,$FE000000,$FFF80000,$00070007,$000000FF,$A8003B00,$C7000000,$FFF80002
	DC.L	$00070007,$000000FF,$96002D00,$C3000000,$FFF00002,$000F000F,$0000007F,$96002D80
	DC.L	$C3800000,$FFF00002,$000F000F,$0000007F,$AA003980,$C7800000,$FFF00002,$000F000F
	DC.L	$0000007F,$80000380,$FF800000,$FFF0000B,$0007000F,$0000007F,$78008780,$FF800000
	DC.L	$FFF80005,$00030007,$000000FF,$8400FF00,$FF000000,$FFF80005,$00030007,$000000FF
	DC.L	$FC00FF00,$FF000000,$FFFC0003,$00000003,$000001FF,$0000FE00,$FE000000,$FFFF0000
	DC.L	$00000000,$000007FF,$70008800,$F8000000,$FFFF0000,$00000000,$0000FFFF,$00000000
	DC.L	$00000000,$FFFF0000,$00000000,$0000FFFF,$00000000,$00000000,$FFFF0000,$00000000
	DC.L	$0000FFFF,$00000000,$00000000,$FFFF0000,$00000000,$0000FFFF,$00000000,$00000000
	DC.L	$FFFF0000,$00000000,$000083FF,$00007C00,$7C000000,$FFFE0000,$00010001,$000000FF
	DC.L	$2200C100,$FF000000,$FFFC0000,$00030003,$0000007F,$54009D80,$E3800000,$FFFC0001
	DC.L	$00030003,$0000007F,$4B009680,$E1800000,$FFF80001,$00070007,$0000003F,$4B0096C0
	DC.L	$E1C00000,$FFF80001,$00070007,$0000003F,$55009CC0,$E3C00000,$FFF80001,$00070007
	DC.L	$0000003F,$400081C0,$FFC00000,$FFF80005,$00030007,$0000003F,$BC00C3C0,$FFC00000
	DC.L	$FFFC0002,$00010003,$0000007F,$C200FF80,$FF800000,$FFFC0002,$00010003,$0000007F
	DC.L	$FE00FF80,$FF800000,$FFFE0001,$00000001,$000000FF,$80007F00,$FF000000,$FFFF0000
	DC.L	$00000000,$000083FF,$38004400,$7C000000,$FFFF0000,$00000000,$0000FFFF,$00000000
	DC.L	$00000000,$FFFF0000,$00000000,$0000FFFF,$00000000,$00000000,$FFFF0000,$00000000
	DC.L	$0000FFFF,$00000000,$00000000,$FFFF0000,$00000000,$0000FFFF,$00000000,$00000000
	DC.L	$FFFF0000,$00000000,$0000C1FF,$00003E00,$3E000000,$FFFF0000,$00000000,$0000007F
	DC.L	$1100E080,$FF800000,$FFFE0000,$00010001,$0000003F,$2A00CEC0,$F1C00000,$FFFE0000
	DC.L	$00010001,$0000003F,$A580CB40,$F0C00000,$FFFC0000,$00030003,$0000001F,$A580CB60
	DC.L	$F0E00000,$FFFC0000,$00030003,$0000001F,$AA80CE60,$F1E00000,$FFFC0000,$00030003
	DC.L	$0000001F,$A000C0E0,$FFE00000,$FFFC0002,$00010003,$0000001F,$DE00E1E0,$FFE00000
	DC.L	$FFFE0001,$00000001,$0000003F,$6100FFC0,$FFC00000,$FFFE0001,$00000001,$0000003F
	DC.L	$7F00FFC0,$FFC00000,$FFFF0000,$00000000,$0000007F,$C0003F80,$FF800000,$FFFF0000
	DC.L	$00000000,$0000C1FF,$1C002200,$3E000000,$FFFF0000,$00000000,$0000FFFF,$00000000
	DC.L	$00000000,$FFFF0000,$00000000,$0000FFFF,$00000000,$00000000,$FFFF0000,$00000000
	DC.L	$0000FFFF,$00000000,$00000000,$FFFF0000,$00000000,$0000FFFF,$00000000,$00000000
	DC.L	$FFFF0000,$00000000,$0000E0FF,$00001F00,$1F000000,$FFFF0000,$00000000,$0000803F
	DC.L	$08807040,$7FC00000,$FFFF0000,$00000000,$0000001F,$1500E760,$F8E00000,$FFFF0000
	DC.L	$00000000,$0000001F,$52C0E5A0,$F8600000,$FFFE0000,$00010001,$0000000F,$52C0E5B0
	DC.L	$F8700000,$FFFE0000,$00010001,$0000000F,$5540E730,$F8F00000,$FFFE0000,$00010001
	DC.L	$0000000F,$5000E070,$FFF00000,$FFFE0001,$00000001,$0000000F,$6F00F0F0,$FFF00000
	DC.L	$FFFF0000,$00000000,$0000001F,$B0807FE0,$FFE00000,$FFFF0000,$00000000,$0000001F
	DC.L	$BF807FE0,$FFE00000,$FFFF0000,$00000000,$0000803F,$60001FC0,$7FC00000,$FFFF0000
	DC.L	$00000000,$0000E0FF,$0E001100,$1F000000,$FFFF0000,$00000000,$0000FFFF,$00000000
	DC.L	$00000000,$FFFF0000,$00000000,$0000FFFF,$00000000,$00000000,$FFFF0000,$00000000
	DC.L	$0000FFFF,$00000000,$00000000,$FFFF0000,$00000000,$0000FFFF,$00000000,$00000000

balldata0:
	DC.L	$C3FF0800,$34003C00,$0000FFFF,$00000000,$00000000,$81FF0000,$6A007600,$0000FFFF
	DC.L	$00000000,$00000000,$00FF4A00,$F500E300,$0000FFFF,$00000000,$00000000,$00FF4600
	DC.L	$ED00F300,$0000FFFF,$00000000,$00000000,$00FF7800,$E700FF00,$0000FFFF,$00000000
	DC.L	$00000000,$00FFA400,$7F00FF00,$0000FFFF,$00000000,$00000000,$81FF1800,$7E007E00
	DC.L	$0000FFFF,$00000000,$00000000,$C3FF1000,$2C003C00,$0000FFFF,$00000000,$00000000
	DC.L	$E1FF0400,$1A001E00,$0000FFFF,$00000000,$00000000,$C0FF0000,$35003B00,$0000FFFF
	DC.L	$00000000,$00000000,$807F2500,$7A807180,$0000FFFF,$00000000,$00000000,$807F2300
	DC.L	$76807980,$0000FFFF,$00000000,$00000000,$807F3C00,$73807F80,$0000FFFF,$00000000
	DC.L	$00000000,$807F5200,$3F807F80,$0000FFFF,$00000000,$00000000,$C0FF0C00,$3F003F00
	DC.L	$0000FFFF,$00000000,$00000000,$E1FF0800,$16001E00,$0000FFFF,$00000000,$00000000
	DC.L	$F0FF0200,$0D000F00,$0000FFFF,$00000000,$00000000,$E07F0000,$1A801D80,$0000FFFF
	DC.L	$00000000,$00000000,$C03F1280,$3D4038C0,$0000FFFF,$00000000,$00000000,$C03F1180
	DC.L	$3B403CC0,$0000FFFF,$00000000,$00000000,$C03F1E00,$39C03FC0,$0000FFFF,$00000000
	DC.L	$00000000,$C03F2900,$1FC03FC0,$0000FFFF,$00000000,$00000000,$E07F0600,$1F801F80
	DC.L	$0000FFFF,$00000000,$00000000,$F0FF0400,$0B000F00,$0000FFFF,$00000000,$00000000
	DC.L	$F87F0100,$06800780,$0000FFFF,$00000000,$00000000,$F03F0000,$0D400EC0,$0000FFFF
	DC.L	$00000000,$00000000,$E01F0940,$1EA01C60,$0000FFFF,$00000000,$00000000,$E01F08C0
	DC.L	$1DA01E60,$0000FFFF,$00000000,$00000000,$E01F0F00,$1CE01FE0,$0000FFFF,$00000000
	DC.L	$00000000,$E01F1480,$0FE01FE0,$0000FFFF,$00000000,$00000000,$F03F0300,$0FC00FC0
	DC.L	$0000FFFF,$00000000,$00000000,$F87F0200,$05800780,$0000FFFF,$00000000,$00000000
	DC.L	$FC3F0080,$034003C0,$0000FFFF,$00000000,$00000000,$F81F0000,$06A00760,$0000FFFF
	DC.L	$00000000,$00000000,$F00F04A0,$0F500E30,$0000FFFF,$00000000,$00000000,$F00F0460
	DC.L	$0ED00F30,$0000FFFF,$00000000,$00000000,$F00F0780,$0E700FF0,$0000FFFF,$00000000
	DC.L	$00000000,$F00F0A40,$07F00FF0,$0000FFFF,$00000000,$00000000,$F81F0180,$07E007E0
	DC.L	$0000FFFF,$00000000,$00000000,$FC3F0100,$02C003C0,$0000FFFF,$00000000,$00000000
	DC.L	$FE1F0040,$01A001E0,$0000FFFF,$00000000,$00000000,$FC0F0000,$035003B0,$0000FFFF
	DC.L	$00000000,$00000000,$F8070250,$07A80718,$0000FFFF,$00000000,$00000000,$F8070230
	DC.L	$07680798,$0000FFFF,$00000000,$00000000,$F80703C0,$073807F8,$0000FFFF,$00000000
	DC.L	$00000000,$F8070520,$03F807F8,$0000FFFF,$00000000,$00000000,$FC0F00C0,$03F003F0
	DC.L	$0000FFFF,$00000000,$00000000,$FE1F0080,$016001E0,$0000FFFF,$00000000,$00000000
	DC.L	$FF0F0020,$00D000F0,$0000FFFF,$00000000,$00000000,$FE070000,$01A801D8,$0000FFFF
	DC.L	$00000000,$00000000,$FC030128,$03D4038C,$0000FFFF,$00000000,$00000000,$FC030118
	DC.L	$03B403CC,$0000FFFF,$00000000,$00000000,$FC0301E0,$039C03FC,$0000FFFF,$00000000
	DC.L	$00000000,$FC030290,$01FC03FC,$0000FFFF,$00000000,$00000000,$FE070060,$01F801F8
	DC.L	$0000FFFF,$00000000,$00000000,$FF0F0040,$00B000F0,$0000FFFF,$00000000,$00000000
	DC.L	$FF870010,$00680078,$0000FFFF,$00000000,$00000000,$FF030000,$00D400EC,$0000FFFF
	DC.L	$00000000,$00000000,$FE010094,$01EA01C6,$0000FFFF,$00000000,$00000000,$FE01008C
	DC.L	$01DA01E6,$0000FFFF,$00000000,$00000000,$FE0100F0,$01CE01FE,$0000FFFF,$00000000
	DC.L	$00000000,$FE010148,$00FE01FE,$0000FFFF,$00000000,$00000000,$FF030030,$00FC00FC
	DC.L	$0000FFFF,$00000000,$00000000,$FF870020,$00580078,$0000FFFF,$00000000,$00000000
	DC.L	$FFC30008,$0034003C,$0000FFFF,$00000000,$00000000,$FF810000,$006A0076,$0000FFFF
	DC.L	$00000000,$00000000,$FF00004A,$00F500E3,$0000FFFF,$00000000,$00000000,$FF000046
	DC.L	$00ED00F3,$0000FFFF,$00000000,$00000000,$FF000078,$00E700FF,$0000FFFF,$00000000
	DC.L	$00000000,$FF0000A4,$007F00FF,$0000FFFF,$00000000,$00000000,$FF810018,$007E007E
	DC.L	$0000FFFF,$00000000,$00000000,$FFC30010,$002C003C,$0000FFFF,$00000000,$00000000
	DC.L	$FFE10004,$001A001E,$0000FFFF,$00000000,$00000000,$FFC00000,$0035003B,$0000FFFF
	DC.L	$00000000,$00000000,$FF800025,$007A0071,$00007FFF,$00008000,$80000000,$FF800023
	DC.L	$00760079,$00007FFF,$00008000,$80000000,$FF80003C,$0073007F,$00007FFF,$00008000
	DC.L	$80000000,$FF800052,$003F007F,$00007FFF,$00008000,$80000000,$FFC0000C,$003F003F
	DC.L	$0000FFFF,$00000000,$00000000,$FFE10008,$0016001E,$0000FFFF,$00000000,$00000000
	DC.L	$FFF00002,$000D000F,$0000FFFF,$00000000,$00000000,$FFE00000,$001A001D,$00007FFF
	DC.L	$00008000,$80000000,$FFC00012,$003D0038,$00003FFF,$80004000,$C0000000,$FFC00011
	DC.L	$003B003C,$00003FFF,$80004000,$C0000000,$FFC0001E,$0039003F,$00003FFF,$0000C000
	DC.L	$C0000000,$FFC00029,$001F003F,$00003FFF,$0000C000,$C0000000,$FFE00006,$001F001F
	DC.L	$00007FFF,$00008000,$80000000,$FFF00004,$000B000F,$0000FFFF,$00000000,$00000000
	DC.L	$FFF80001,$00060007,$00007FFF,$00008000,$80000000,$FFF00000,$000D000E,$00003FFF
	DC.L	$00004000,$C0000000,$FFE00009,$001E001C,$00001FFF,$4000A000,$60000000,$FFE00008
	DC.L	$001D001E,$00001FFF,$C000A000,$60000000,$FFE0000F,$001C001F,$00001FFF,$0000E000
	DC.L	$E0000000,$FFE00014,$000F001F,$00001FFF,$8000E000,$E0000000,$FFF00003,$000F000F
	DC.L	$00003FFF,$0000C000,$C0000000,$FFF80002,$00050007,$00007FFF,$00008000,$80000000
	DC.L	$FFFC0000,$00030003,$00003FFF,$80004000,$C0000000,$FFF80000,$00060007,$00001FFF
	DC.L	$0000A000,$60000000,$FFF00004,$000F000E,$00000FFF,$A0005000,$30000000,$FFF00004
	DC.L	$000E000F,$00000FFF,$6000D000,$30000000,$FFF00007,$000E000F,$00000FFF,$80007000
	DC.L	$F0000000,$FFF0000A,$0007000F,$00000FFF,$4000F000,$F0000000,$FFF80001,$00070007
	DC.L	$00001FFF,$8000E000,$E0000000,$FFFC0001,$00020003,$00003FFF,$0000C000,$C0000000
	DC.L	$FFFE0000,$00010001,$00001FFF,$4000A000,$E0000000,$FFFC0000,$00030003,$00000FFF
	DC.L	$00005000,$B0000000,$FFF80002,$00070007,$000007FF,$5000A800,$18000000,$FFF80002
	DC.L	$00070007,$000007FF,$30006800,$98000000,$FFF80003,$00070007,$000007FF,$C0003800
	DC.L	$F8000000,$FFF80005,$00030007,$000007FF,$2000F800,$F8000000,$FFFC0000,$00030003
	DC.L	$00000FFF,$C000F000,$F0000000,$FFFE0000,$00010001,$00001FFF,$80006000,$E0000000
	DC.L	$FFFF0000,$00000000,$00000FFF,$2000D000,$F0000000,$FFFE0000,$00010001,$000007FF
	DC.L	$0000A800,$D8000000,$FFFC0001,$00030003,$000003FF,$2800D400,$8C000000,$FFFC0001
	DC.L	$00030003,$000003FF,$1800B400,$CC000000,$FFFC0001,$00030003,$000003FF,$E0009C00
	DC.L	$FC000000,$FFFC0002,$00010003,$000003FF,$9000FC00,$FC000000,$FFFE0000,$00010001
	DC.L	$000007FF,$6000F800,$F8000000,$FFFF0000,$00000000,$00000FFF,$4000B000,$F0000000
	DC.L	$FFFF0000,$00000000,$000087FF,$10006800,$78000000,$FFFF0000,$00000000,$000003FF
	DC.L	$0000D400,$EC000000,$FFFE0000,$00010001,$000001FF,$9400EA00,$C6000000,$FFFE0000
	DC.L	$00010001,$000001FF,$8C00DA00,$E6000000,$FFFE0000,$00010001,$000001FF,$F000CE00
	DC.L	$FE000000,$FFFE0001,$00000001,$000001FF,$4800FE00,$FE000000,$FFFF0000,$00000000
	DC.L	$000003FF,$3000FC00,$FC000000,$FFFF0000,$00000000,$000087FF,$20005800,$78000000


keybuf:	dc.l	0
unitheta:	dc.w	0
uniphi:		dc.w	0
unirho:		dc.w	0
uniz:		dc.w	500
zinc:		dc.w	0
