v:		equ	2
master:		equ	0
slave:		equ	1
single:		equ	2
yv8:		equ	3
xv8:		equ	3
nsamount2:	equ	1
*	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
putlast:	equ	0
cxmax:		equ	319
cxmin:		equ	0
cymax:		equ	200
cymin:		equ	0
cspritex:	equ	0
cspritey:	equ	2
cspriteheight:	equ	8
cspritewidth:	equ	10
cspritead:	equ	4
cactive:	equ	12
cspritebuffer:	equ	14
cquickaddress:	equ	18
cquickspaddress:equ	22
cspritexvel:	equ	26
cspriteyvel:	equ	28
cspritelife:	equ	30
cspritesub:	equ	30
cspritelocation:	equ	34
cspriteheading:		equ	38
cspritegoing:		equ	42
cspritelistad:		equ	44
cspritefollow:		equ	48
cspritefight:		equ	50
cspritehits:		equ	52
tankspine:		equ	54
tankplanee:		equ	56
tankimagee:		equ	58
tankstarte:		equ	62
tankadde:		equ	66
enshotlistp:		equ	70
whichmee:		equ	74
whichmestarte:		equ	75
whichmehighe:		equ	76
cspritevels:		equ	78
cspriteshotdel:		equ	80
cspriteexploding:	equ	82
cspriterotate:		equ	84

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
start:
*	move.l	sp,a5
*	move.l	4(a5),a5
*	move.l	$c(a5),d0
*	add.l	$14(a5),d0
*	add.l	$1c(a5),d0
*	add.l	#$100,d0	;basepage amount
*	add.l	#512000,d0
*	move.l	d0,-(sp)	;amount to keep
*	move.l	a5,-(sp)	;mem to mod
*	move	d0,-(sp)	;dummy
*	move.w	#$4a,-(sp)
*	trap	#1
*	add.l	#12,sp
*	tst.l	d0
*	bne	gem2

	clr.l   -(SP)           ;Go into supervisor mode
        move.w  #$20,-(SP)
        trap    #1
        addq.l  #6,SP
        move.l  D0,savesup

	bsr	setupgem
*	move.l	$4f2,a0
*	addq.l	#2,a0
*	move.w	(a0),d0
*	cmpi.w	#$0106,d0
*	beq	righttos
*	jmp	alertout
righttos:
	cmpi.b	#5,$424
	bge.s	rightmem
	jmp	alertout
rightmem:
	dc.w	$a00a
*	move.b	#0,$484
	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)+

	move.l	#myprt,$502

	move.w	#2,-(sp)
	move.w	#14,-(sp)
	trap	#14
	addq.l	#4,sp
	move.l	d0,a0
	move.l	a0,midibuff
	move.l	$84,trappoke+2
	move.l	#mytrap,$84
	jsr	getscrn

	lea	blackpal2,a0
	bsr	mydocolors3
	bsr	dotitle
	move.w	#-1,novbl

*	move.b	#%11111110,$ff820a
	bsr	putrout


	move.l	#filefb,filename
	move.l	#blocks,wheretoload
	jsr	loadscr
	move.l	#fileme,filename
	move.l	#mesprites,wheretoload
	jsr	loadscr
	move.l	#filemetank,filename
	move.l	#metanksprites,wheretoload
	jsr	loadscr
	move.l	#fileshots,filename
	move.l	#shotsprites,wheretoload
	jsr	loadscr
	move.l	#fileenemy,filename
	move.l	#enemysprites,wheretoload
	jsr	loadscr
	move.l	#fileenemytank,filename
	move.l	#enemytanksprites,wheretoload
	jsr	loadscr
	move.l	#filesounds,filename
	move.l	#sounds,wheretoload
	jsr	loadscr
	move.l	#filemap1,filename
	move.l	#gamemap,wheretoload
	jsr	loadscr
	move.l	#fileintel,filename
	move.l	#list,wheretoload
	bsr	loadscr

	lea	blackpal2,a0
	bsr	mydocolors3
	move.w	#1,novbl
	move.l	oldvbl1,$70
	move.l	$70,oldvbl1
	move.l	$70,gooldvbl+2
	move.l	#framevbl,$70
	move.l	#filemap,filename
	move.l	screen,wheretoload
	jsr	loadscr

	move.l	$ff8206,d0
	bsr	randomseed

	bsr	joystuff
	bsr	mydocolors
	move.w	#1,my
	bsr	setuphbl
	bsr	setgemcolor
	bsr	setgemsize	;small font

dorestart:
	bsr	doclearnums
	move.w	#0,enemydead
	move.w	#0,number
	move.w	#4001,numwhere
	bsr	prtnum
	move.w	#3,mines
	move.w	#2,tanks
	move.w	#0,mehits
	move.w	#-1,memapsp
	move.w	#-1,enmapsp0
	move.w	#-1,enmapsp1
	move.w	#64,shots
	move.w	#-1,mewepsp
	move.w	#-1,enwepsp
	bsr	clearallsprites
*	bsr	makemap
	bra	establishcoms

gamemulti:
mainloop:
	bsr	stch
	tst.w	tankspin
	bpl.s	skipjoy
	bsr	joydir
skipjoy:
	bsr	docollisions
	bsr	doshots
	bsr	dome
	bsr	sortsprites
	bsr	domines
	jsr	keyboard
	bsr	sendme
	bsr	doothers
	bsr	plotplayersm
	tst.w	cheatmode
	bpl.s	skipcheat1
	cmpi.w	#12,mehits
	bge.s	exploding
skipcheat1:
	move.w	#1,setflag
	lea	setflag,a0
wvbl:
	tst.w	(a0)
	bpl	wvbl
	bra.s	mainloop
exploding:
	move.w	#-1,tankplane
	lea	tanksp,a0
	move.w	tanks,d0
	lea	tankxylist,a1
	asl.w	#1,d0
	move.w	(a1,d0.w),(a0)
	bsr	putsprite
	subq.w	#1,tanks
	bsr	doboom
	move.w	#0,xvel
	move.w	#0,yvel
	lea	mesp,a0
	move.w	#-2,cactive(a0)
	lea	meshot1,a1
	lea	meshot2,a2
	lea	meshot3,a3
	lea	meshot4,a4
	move.w	cspritex(a0),d0
	move.w	cspritey(a0),d1
	addq.w	#7-1,d0
	addq.w	#7-1,d1
	move.w	d0,cspritex(a1)
	move.w	d1,cspritey(a1)
	addq.w	#3,cspritex(a1)
	subq.w	#3,cspritey(a1)
	move.w	#1,cactive(a1)
	move.w	#3,cspritexvel(a1)
	move.w	#-3,cspriteyvel(a1)
	move.w	#50,cspritelife(a1)
	move.w	d0,cspritex(a2)
	move.w	d1,cspritey(a2)
	addq.w	#3,cspritex(a2)
	addq.w	#3,cspritey(a2)
	move.w	#1,cactive(a2)
	move.w	#3,cspritexvel(a2)
	move.w	#3,cspriteyvel(a2)
	move.w	#50,cspritelife(a2)
	move.w	d0,cspritex(a3)
	move.w	d1,cspritey(a3)
	subq.w	#3,cspritex(a3)
	addq.w	#3,cspritey(a3)
	move.w	#1,cactive(a3)
	move.w	#-3,cspritexvel(a3)
	move.w	#3,cspriteyvel(a3)
	move.w	#50,cspritelife(a3)
	move.w	d0,cspritex(a4)
	move.w	d1,cspritey(a4)
	move.w	#1,cactive(a4)
	move.w	#-3,cspritexvel(a4)
	move.w	#-3,cspriteyvel(a4)
	move.w	#50,cspritelife(a4)
	subq.w	#3,cspritex(a4)
	subq.w	#3,cspritey(a4)
exploop2:
	bsr	movemyshots
	bsr	docollisions
	bsr	sortsprites
	bsr	sendme
	bsr	doothers
	bsr	plotplayersm
	lea	meshot1,a0
	cmpi.w	#-1,cactive(a0)
	bne.s	go2
	lea	meshot2,a0
	cmpi.w	#-1,cactive(a0)
	bne.s	go2
	lea	meshot3,a0
	cmpi.w	#-1,cactive(a0)
	bne.s	go2
	lea	meshot4,a0
	cmpi.w	#-1,cactive(a0)
	bne.s	go2
	bra.s	nomore
go2:	move.w	#1,setflag
	lea	setflag,a0
wvbl3:
	tst.w	(a0)
	bpl.s	wvbl3
	bra	exploop2
nomore:
	lea	poslist,a0
	moveq	#4,d0
	bsr	randomplus
	lsl.w	#2,d0
	move.w	(a0,d0.w),screenx
	move.w	2(a0,d0.w),screeny
	lea	mesp,a0
	bsr	testc
	move.w	cspritex(a0),d0
	move.w	cspritey(a0),d1
	lea	enemysp0,a1
	sub.w	cspritex(a1),d0
	sub.w	cspritey(a1),d1
	muls	d0,d0
	muls	d1,d1
	add.l	d0,d1
	bsr	sqrt
	cmpi.l	#200,d1
	blt	nomore

	move.w	#0,mehits
	lea	bar2sp,a0
	bsr	putsprite
	move.w	#-1,tankplane
	lea	mesp,a0
	move.l	#metanksprites,cspritead(a0)
	move.w	#1,cactive(a0)
	move.b	#8,whichme
	move.w	#-1,tankspin
	move.w	#-yv8,shotyvel
	move.w	#0,shotxvel
	bra	mainloop

gamesingle:
	bsr	stch
	tst.w	tankspin
	bpl.s	skipjoys
	bsr	joydir
skipjoys:
	bsr	docollisions
	bsr	doshots
	bsr	doenemyshots
	bsr	doenminedrop
	bsr	dome
	bsr	enemycollision
	bsr	doenemy
	bsr	doenexplode
	bsr	sortsprites
	bsr	domines
	jsr	keyboard
	bsr	plotplayers
	tst.w	cheatmode
	bpl.s	skipcheat2
	cmpi.w	#12,mehits
	bge	exploding2
skipcheat2:
	move.w	#1,setflag
	lea	setflag,a0
wvbls:
	tst.w	(a0)
	bpl	wvbls
	bra.s	gamesingle

exploding2:
	move.w	#-1,tankplane
	lea	tanksp,a0
	move.w	tanks,d0
	lea	tankxylist,a1
	asl.w	#1,d0
	move.w	(a1,d0.w),(a0)
	bsr	putsprite
	subq.w	#1,tanks
	bsr	doboom
	move.w	#0,xvel
	move.w	#0,yvel
	lea	mesp,a0
	move.w	#-2,cactive(a0)
	lea	meshot1,a1
	lea	meshot2,a2
	lea	meshot3,a3
	lea	meshot4,a4
	move.w	cspritex(a0),d0
	move.w	cspritey(a0),d1
	addq.w	#7-1,d0
	addq.w	#7-1,d1
	move.w	d0,cspritex(a1)
	move.w	d1,cspritey(a1)
	addq.w	#3,cspritex(a1)
	subq.w	#3,cspritey(a1)
	move.w	#1,cactive(a1)
	move.w	#3,cspritexvel(a1)
	move.w	#-3,cspriteyvel(a1)
	move.w	#50,cspritelife(a1)
	move.w	d0,cspritex(a2)
	move.w	d1,cspritey(a2)
	addq.w	#3,cspritex(a2)
	addq.w	#3,cspritey(a2)
	move.w	#1,cactive(a2)
	move.w	#3,cspritexvel(a2)
	move.w	#3,cspriteyvel(a2)
	move.w	#50,cspritelife(a2)
	move.w	d0,cspritex(a3)
	move.w	d1,cspritey(a3)
	subq.w	#3,cspritex(a3)
	addq.w	#3,cspritey(a3)
	move.w	#1,cactive(a3)
	move.w	#-3,cspritexvel(a3)
	move.w	#3,cspriteyvel(a3)
	move.w	#50,cspritelife(a3)
	move.w	d0,cspritex(a4)
	move.w	d1,cspritey(a4)
	move.w	#1,cactive(a4)
	move.w	#-3,cspritexvel(a4)
	move.w	#-3,cspriteyvel(a4)
	move.w	#50,cspritelife(a4)
	subq.w	#3,cspritex(a4)
	subq.w	#3,cspritey(a4)
exploop2s:
	bsr	docollisions
	bsr	enemycollision
	bsr	doshots
	bsr	doenemyshots
	bsr	doenemy
	bsr	sortsprites
	jsr	keyboard
	bsr	plotplayers
	lea	meshot1,a0
	cmpi.w	#-1,cactive(a0)
	bne.s	go2s
	lea	meshot2,a0
	cmpi.w	#-1,cactive(a0)
	bne.s	go2s
	lea	meshot3,a0
	cmpi.w	#-1,cactive(a0)
	bne.s	go2s
	lea	meshot4,a0
	cmpi.w	#-1,cactive(a0)
	bne.s	go2s
	bra.s	nomores
go2s:	move.w	#1,setflag
	lea	setflag,a0
wvbl3s:
	tst.w	(a0)
	bpl.s	wvbl3s
	bra	exploop2s
nomores:
	tst.w	tanks
	bmi.L	restartsingle
	lea	poslist,a0
	moveq	#4,d0
	bsr	randomplus
	lsl.w	#2,d0
	move.w	(a0,d0.w),screenx
	move.w	2(a0,d0.w),screeny
	move.w	#0,mehits
	lea	bar2sp,a0
	bsr	putsprite
	move.w	#-1,tankplane
	lea	mesp,a0
	move.l	#metanksprites,cspritead(a0)
	move.w	#1,cactive(a0)
	move.b	#8,whichme
	move.w	#-1,tankspin
	move.w	#-yv8,shotyvel
	move.w	#0,shotxvel
	bra	gamesingle


doenexplode:
	lea	enemysp0,a0
	tst.w	cspriteexploding(a0)
	bmi.s	de1
	bsr	tsteend
	bra.s	de2
de1:
	cmpi.w	#12,cspritehits(a0)
	blt.s	de2
	addq.w	#1,enemydead
	move.w	enemydead,number
	move.w	#4001,numwhere
	bsr	prtnum
	bsr	setupboom
de2:
	lea	enemysp1,a0
	tst.w	cspriteexploding(a0)
	bmi.s	de3
	bsr	tsteend
	bra.s	de4
de3:
	cmpi.w	#12,cspritehits(a0)
	blt.s	de4
	addq.w	#1,enemydead
	move.w	enemydead,number
	move.w	#4001,numwhere
	bsr	prtnum
	bsr	setupboom
de4:
	rts


setupboom:
	move.w	#1,cspriteexploding(a0)
	bsr	doboom
	move.w	#-2,cactive(a0)
	move.l	enshotlistp(a0),a6
	move.l	(a6)+,a1
	move.l	(a6)+,a2
	move.l	(a6)+,a3
	move.l	(a6)+,a4
	move.w	cspritex(a0),d0
	move.w	cspritey(a0),d1
	addq.w	#7-1,d0
	addq.w	#7-1,d1
	move.w	d0,cspritex(a1)
	move.w	d1,cspritey(a1)
	addq.w	#3,cspritex(a1)
	subq.w	#3,cspritey(a1)
	move.w	#1,cactive(a1)
	move.w	#3,cspritexvel(a1)
	move.w	#-3,cspriteyvel(a1)
	move.w	#50,cspritelife(a1)
	move.w	d0,cspritex(a2)
	move.w	d1,cspritey(a2)
	addq.w	#3,cspritex(a2)
	addq.w	#3,cspritey(a2)
	move.w	#1,cactive(a2)
	move.w	#3,cspritexvel(a2)
	move.w	#3,cspriteyvel(a2)
	move.w	#50,cspritelife(a2)
	move.w	d0,cspritex(a3)
	move.w	d1,cspritey(a3)
	subq.w	#3,cspritex(a3)
	addq.w	#3,cspritey(a3)
	move.w	#1,cactive(a3)
	move.w	#-3,cspritexvel(a3)
	move.w	#3,cspriteyvel(a3)
	move.w	#50,cspritelife(a3)
	move.w	d0,cspritex(a4)
	move.w	d1,cspritey(a4)
	move.w	#1,cactive(a4)
	move.w	#-3,cspritexvel(a4)
	move.w	#-3,cspriteyvel(a4)
	move.w	#50,cspritelife(a4)
	subq.w	#3,cspritex(a4)
	subq.w	#3,cspritey(a4)
	rts
tsteend:
	move.l	enshotlistp(a0),a6
	move.l	(a6)+,a1
	cmpi.w	#-1,cactive(a1)
	bne.s	go2se
	move.l	(a6)+,a1
	cmpi.w	#-1,cactive(a1)
	bne.s	go2se
	move.l	(a6)+,a1
	cmpi.w	#-1,cactive(a1)
	bne.s	go2se
	move.l	(a6)+,a1
	cmpi.w	#-1,cactive(a1)
	bne.s	go2se
	bsr	getrandlist
	move.l	a1,cspritelocation(a0)
	move.l	a1,cspriteheading(a0)
	move.l	a1,cspritelistad(a0)
	move.w	#-1,cspritegoing(a0)
	move.w	#1,cactive(a0)
	move.w	#-1,cspritefollow(a0)
	move.w	#1,cspritefight(a0)
	move.w	#0,cspritehits(a0)
	move.w	#-1,cspriteexploding(a0)
	bsr	dolist
go2se:
	rts

restartsingle:
	move.w	#1,novbl
	move.w	#1,my
	bsr	cleartext
	lea	medeadtext1,a0
	bsr	gemprint
	lea	mewintext2,a0
	bsr	gemprint
	bsr	clearkeyboard
waitkos:
	move.w	#$ff,-(sp)
	move.w	#6,-(sp)
	trap	#1
	addq.l	#4,sp
	tst.l	d0		;wait for keypress
	beq	waitkos
	bra	dorestart



poslist:
	dc.w	16+176-160-8,16+144-100-8
	dc.w	16+1088-160-8,16+144-100-8
	dc.w	16+176-160-8,16+672-100-8
	dc.w	16+1088-160-8,16+672-100-8
***************************************
doenminedrop:
	lea	enemysp0,a0
	tst.w	tankplanee(a0)
	bpl.s	demd
	tst.w	cactive(a0)
	bmi.s	demd
	move.w	#1000,d0
	bsr	randomplus
	cmpi.w	#5,d0
	bgt.s	demd
	bsr	doenemymine2
demd:
	lea	enemysp0,a1
	tst.w	tankplanee(a0)
	bpl.s	demd2
	tst.w	cactive(a0)
	bmi.s	demd2
	move.w	#1000,d0
	bsr	randomplus
	cmpi.w	#5,d0
	bgt.s	demd2
	bsr	doenemymine2
demd2:
	rts


***************************************
doenemy:
	lea	enemysp0,a0
	bsr	doenmove
	lea	enemysp1,a0
	bsr	doenmove
	rts

doenmove:
	tst.w	cactive(a0)
	bmi	deov
	bsr	doenemyspin
	bsr	doenemyspinning
	tst.w	cspritefight(a0)	;is he being chicken
	bmi.s	findnextbb
	tst.w	tankspine(a0)
	bpl	amsp
	move.w	cspritesub(a0),d0
	beq	findnexta		;zero is a prob
	sub.w	d0,cspritegoing(a0)
	bmi	findnexta
	move.w	cspritexvel(a0),d0
	move.w	cspriteyvel(a0),d1
	add.w	d0,cspritex(a0)
	add.w	d1,cspritey(a0)
amsp:	bsr	preparesprite
deov:	rts

findnexta:
	move.l	cspriteheading(a0),cspritelocation(a0)
	subq.w	#1,cspritefollow(a0)
	bpl.L	findnext
findnextb:
*	moveq	#100,d0
*	bsr	randomplus
*	cmpi.w	#1,d0
*	bgt.s	noflee
*	move.w	#-1,cspritefight(a0)
*	lea	list,a1
*	moveq	#64,d0
*	bsr	randomplus
*	asl.w	#3,d0
*	add.w	d0,a1
*	move.l	a1,cspritelistad(a0)
*	move.w	#20,cspritefollow(a0)
*	bra.L	findnext
noflee:
	move.w	#1,cspritefight(a0)
	bra.s	dolist

findnextbb:
	move.l	cspritelocation(a0),cspriteheading(a0)
	move.l	cspriteheading(a0),a6
	move.w	cspritex(a0),d6
	move.w	cspritey(a0),d7
	cmpi.w	#-2,cspritefight(a0)
	beq.s	runwellaway
	move.w	#0,cspritefight(a0)	;go back one place
	bra	fudge	
runwellaway:
	move.w	#0,cspritefight(a0)	;go back one place
	bsr	getrandlist
	move.l	a1,cspritelistad(a0)
	move.w	#12,cspritefollow(a0)
	bra	fudge


headingto:
	dc.l	0
mylocation:	dc.l	list
listad:	dc.l	-1
bdelay:	dc.w	0
going:	dc.w	-1
*************************************************
*	Sqroot routine courtesy of Armin	*
*	Input:	d0.l	number to get root of	*
*		d1	answer			*
*************************************************
sqrt:
	movem.w	d2/d3,-(sp)
	moveq	#5,d4
	lsr.l	#1,d0
	move.l	d0,d1
	lsr.l	#1,d1
sqloop:
	move.w	d1,d2
	lsr.l	#1,d2
	move.l	d0,d3
	divu	d1,d3
	sub.l	d2,d1
	add.w	d3,d1
	dbf	d4,sqloop
	movem.w	(sp)+,d2/d3
	rts
*******************************************
dolist:
	lea	list,a6
	lea	mesp,a5
	move.w	cspritex(a5),d2
	move.w	cspritey(a5),d3
	move.l	#25000,d7	;shortest
getloop:
	tst.b	(a6)
	bmi.s	pfindnext
	cmp.w	8(a6),d2	;tlx
	blt.s	glnext
	cmp.w	10(a6),d3	;tly
	blt.s	glnext
	cmp.w	12(a6),d2	;tlx
	bgt.s	glnext
	cmp.w	14(a6),d3	;tly
	bgt.s	glnext
	move.l	a6,cspritelistad(a0)
	bgt.s	pfindnext
glnext:
	lea	16(a6),a6
	bra.s	getloop
pfindnext:
	move.w	#2,cspritefollow(a0)
findnext:
	move.l	cspritelocation(a0),a1
	move.l	cspritelistad(a0),a2
	move.b	1(a1),d0
	cmp.b	1(a2),d0
	bne.s	thirdok1		;if on right track dont rev
	move.b	2(a1),d1
	cmp.b	2(a2),d1
	beq.s	thirdok			;if on right track dont rev
thirdok1:
	move.b	3(a1),d2		;third lev
	beq.s	thirdok			;if 0 must be at 2nd lev node
	subq.b	#1,d2
	move.b	2(a1),d1
	bra.L	findentry
thirdok:
	move.b	1(a1),d0
	cmp.b	1(a2),d0
	beq.s	secok		;if on right track dont rev
	move.b	2(a1),d1
	beq.s	secok
	subq.b	#1,d1
	move.b	3(a1),d2
	bra.L	findentry
secok:
	move.b	1(a1),d0
	cmp.b	1(a2),d0
	beq.s	dosec
	move.b	1(a2),d1
	sub.b	d0,d1
	tst.b	d1
	bpl.s	ffn1
	subq.b	#1,d0		;first number
	move.b	2(a1),d1		;second
	move.b	3(a1),d2		;third
	bra.L	findentry
ffn1:
	addq.b	#1,d0
	move.b	2(a1),d1		;second
	move.b	3(a1),d2		;third
	bra.L	findentry
dosec:
	move.b	2(a1),d1
	cmp.b	2(a2),d1
	beq.s	dothird
	move.b	2(a2),d3
	sub.b	d1,d3
	tst.b	d3
	bpl.s	dos1
	subq.b	#1,d1		;first number
	move.b	1(a1),d0		;second
	move.b	3(a1),d2		;third
	bra.L	findentry
dos1:
	addq.b	#1,d1
	move.b	1(a1),d0		;second
	move.b	3(a1),d2		;third
	bra.L	findentry
dothird:
	move.b	3(a1),d2
	cmp.b	3(a2),d2
	beq.s	imthere
	move.b	3(a2),d3
	sub.b	d2,d3
	tst.b	d3
	bpl.s	dot1
	subq.b	#1,d2		;first number
	move.b	1(a1),d0		;second
	move.b	2(a1),d1		;third
	bra.L	findentry
dot1:
	addq.b	#1,d2
	move.b	1(a1),d0		;second
	move.b	2(a1),d1		;third
	bra.s	findentry
imthere:
	move.w	#-1,cspritegoing(a0)
	tst.w	cspriterotate(a0)	;time to rotate 45
	bmi.s	itb
	move.w	#-1,cspriterotate(a0)
	moveq	#0,d0
	move.b	whichmee(a0),d0
	addq.w	#1,d0
	cmpi.w	#8,d0
	blt.s	itb1
	moveq	#0,d0
itb1:
	move.l	d0,d1
	addq.b	#8,d1
	move.b	d0,whichmee(a0)
	asl.w	#2,d0
	lea	velslist,a1
	move.w	(a1,d0.w),cspritexvel(a0)
	move.w	2(a1,d0.w),cspriteyvel(a0)
	lea	enemysprites,a2
	mulu	#5120,d1
	add.l	d1,a2
	move.l	a2,cspritead(a0)
	bsr	preparesprite
itb:	rts

velslist:
	dc.w	0,-2,2,-2,2,0,2,2,0,2,-2,2,-2,0,-2,-2


findentry:
	lea	list,a6
fel:
	tst.b	(a6)
	bmi.L	feover
	cmp.b	1(a6),d0
	bne.L	feover1
	cmp.b	2(a6),d1
	bne.L	feover1
	cmp.b	3(a6),d2
	bne.L	feover1
	move.l	a6,cspriteheading(a0)
	move.l	cspritelocation(a0),a1
	move.w	4(a1),cspritex(a0)
	move.w	6(a1),cspritey(a0)
	move.w	4(a1),d6
	move.w	6(a1),d7
**********************************
*	when I jump here put my x,y in d6,d7
*	put enspad in a0 and csprite heading in a6
fudge:
	moveq	#50,d4
	moveq	#0,d5
	move.w	4(a6),d0	;x head
	move.w	6(a6),d1
	sub.w	d6,d0
	bmi.s	xneg
	beq.s	xzero
	move.w	d0,d4		;counter
	move.w	cspritevels(a0),d2		;xvel
	move.w	cspritevels(a0),d5
	bra.s	doy
xzero:
	moveq	#0,d2
	bra.s	doy
xneg:
	neg.w	d0
	move.w	d0,d4		;counter
	move.w	cspritevels(a0),d2		;xvel
	move.w	cspritevels(a0),d5
	neg.w	d2
*	moveq	#-v,d2		;xvel
*	moveq	#v,d5
doy:
*	sub.w	6(a1),d1		;y2-y1
	sub.w	d7,d1
	bmi.s	yneg
	beq.s	yzero
	move.w	d1,d4		;counter
	move.w	cspritevels(a0),d3		;xvel
	move.w	cspritevels(a0),d5
*	moveq	#v,d3		;yvel
*	moveq	#v,d5
	bra.s	velsdone
yzero:
	moveq	#0,d3
	bra.s	velsdone
yneg:
	neg.w	d1
	move.w	d1,d4		;counter
	move.w	cspritevels(a0),d3		;xvel
	move.w	cspritevels(a0),d5
	neg.w	d3
*	moveq	#-v,d3
*	moveq	#v,d5
velsdone:
	move.w	d2,cspritexvel(a0)
	move.w	d3,cspriteyvel(a0)
*	subq.w	#1,d4
	move.w	d4,cspritegoing(a0)
	move.w	d5,cspritesub(a0)

	moveq	#0,d4
	tst.w	d2
	beq.s	ed1
	tst.w	d3
	beq.s	ed2
	bpl.s	ed3
ed4:
	tst.w	d2
	bpl.s	ed4a
	moveq	#7,d4
	bra.s	dirdone
ed4a:
	moveq	#1,d4
	bra.s	dirdone
ed3:
	tst.w	d2
	bpl.s	ed3a
	moveq	#5,d4
	bra.s	dirdone
ed3a:
	moveq	#3,d4
	bra.s	dirdone
ed2:
	tst.w	d2
	bpl.s	ed2a
	moveq	#6,d4
	bra.s	dirdone
ed2a:
	moveq	#2,d4
	bra.s	dirdone
ed1:
	tst.w	d3
	bpl.s	ed1a
	moveq	#0,d4
	bra.s	dirdone
ed1a:
	moveq	#4,d4
*	bra.s	dirdone
dirdone:
	lea	enemysprites,a2
	tst.w	tankplanee(a0)
	bpl.s	dd2
	addq	#8,d4
dd2:
	move.b	d4,whichmee(a0)
	mulu	#5120,d4
	add.l	d4,a2
	move.l	a2,cspritead(a0)
	bra	doenmove
feover1:
	lea	16(a6),a6
	bra.L	fel
feover:
	rts
************************************
domines:
	lea	mymine1,a0
	bsr	dominestuff
	lea	mymine2,a0
	bsr	dominestuff
	lea	mymine3,a0
	bsr	dominestuff
	lea	mymine4,a0
	bsr	dominestuff

	lea	enmine1,a0
	bsr	dominestuff2
	lea	enmine2,a0
	bsr	dominestuff2
	lea	enmine3,a0
	bsr	dominestuff2
	lea	enmine4,a0
	bsr	dominestuff2
	rts


dominestuff:
	tst.w	mineact(a0)
	bmi.s	nomine
	subq.w	#1,minelife(a0)
	bpl.s	nomine
	move.w	#-2,mineact(a0)
	lea	minesp,a0
	lea	minexylist,a1
	addq.w	#1,mines
	move.w	mines,d0
	asl.w	#1,d0
	move.w	(a1,d0.w),(a0)
	bsr	putsprite
nomine:
	rts

dominestuff2:
	tst.w	mineact(a0)
	bmi.s	nomine2
	subq.w	#1,minelife(a0)
	bpl.s	nomine2
	move.w	#-2,mineact(a0)
nomine2:
	rts

*************************************
plotplayers:
	lea	mapsplist2,a4
	move.w	enemynum,d7
	addq.w	#3,d7			;for me
pplc:
	move.l	(a4)+,a0
	tst.w	(a0)
	bmi.s	noplpl			;not at all active
	bsr	putsprite		;remove old
noplpl:
	dbf	d7,pplc
here1:
	lea	mapsplist,a1		;put em in
	lea	mapsplist2,a4
	move.w	enemynum,d7
	addq.w	#1,d7			;for me
pplcb:
	move.l	(a1)+,a2
	move.l	(a4)+,a0
	tst.w	cactive(a2)
	bmi.s	noplplb			;not at all active
	move.w	cspritex(a2),d0
	move.w	cspritey(a2),d1
	asr.w	#3,d0		;div by 8
	asr.w	#3,d1
	add.w	#80,d0
	add.w	#29,d1
	move.w	d0,(a0)
	move.w	d1,2(a0)
	bsr	putsprite
	dbf	d7,pplcb
	bra.s	wepbits
noplplb:
	move.w	#-1,(a0)
	dbf	d7,pplcb
wepbits:
	lea	mywep,a2
	move.l	(a4)+,a0
	tst.w	mineact(a2)
	bmi.s	dw2			;not at all active
	move.w	minex2(a2),d0
	move.w	miney2(a2),d1
	asr.w	#3,d0		;div by 8
	asr.w	#3,d1
	add.w	#80,d0
	add.w	#29,d1
	move.w	d0,(a0)
	move.w	d1,2(a0)
	bsr	putsprite
	bra.s	dw2a
dw2:
	move.w	#-1,(a0)
dw2a:
	lea	enwep,a2
	move.l	(a4)+,a0
	tst.w	mineact(a2)
	bmi.s	nomap			;not at all active
	move.w	minex2(a2),d0
	move.w	miney2(a2),d1
	asr.w	#3,d0		;div by 8
	asr.w	#3,d1
	add.w	#80,d0
	add.w	#29,d1
	move.w	d0,(a0)
	move.w	d1,2(a0)
	bsr	putsprite
	rts
nomap:
	move.w	#-1,(a0)
	rts


*************************************
plotplayersm:
	lea	mapsplist2m,a4
	moveq	#3,d7
pplcm:
	move.l	(a4)+,a0
	tst.w	(a0)
	bmi.s	noplplm			;not at all active
	bsr	putsprite		;remove old
noplplm:
	dbf	d7,pplcm
here1m:
	lea	mapsplistm,a1		;put em in
	lea	mapsplist2m,a4
	moveq	#1,d7
pplcbm:
	move.l	(a1)+,a2
	move.l	(a4)+,a0
	tst.w	cactive(a2)
	bmi.s	noplplbm			;not at all active
	move.w	cspritex(a2),d0
	move.w	cspritey(a2),d1
	asr.w	#3,d0		;div by 8
	asr.w	#3,d1
	add.w	#80,d0
	add.w	#29,d1
	move.w	d0,(a0)
	move.w	d1,2(a0)
	bsr	putsprite
	dbf	d7,pplcbm
	bra.s	wepbitsm
noplplbm:
	move.w	#-1,(a0)
	dbf	d7,pplcbm
wepbitsm:
	lea	mywep,a2
	move.l	(a4)+,a0
	tst.w	mineact(a2)
	bmi.s	dw2m			;not at all active
	move.w	minex2(a2),d0
	move.w	miney2(a2),d1
	asr.w	#3,d0		;div by 8
	asr.w	#3,d1
	add.w	#80,d0
	add.w	#29,d1
	move.w	d0,(a0)
	move.w	d1,2(a0)
	bsr	putsprite
	bra.s	dw2am
dw2m:
	move.w	#-1,(a0)
dw2am:
	lea	enwep,a2
	move.l	(a4)+,a0
*	lea	enwepsp,a0
	tst.w	mineact(a2)
	bmi.s	nomapm			;not at all active
	move.w	minex2(a2),d0
	move.w	miney2(a2),d1
	asr.w	#3,d0		;div by 8
	asr.w	#3,d1
	add.w	#80,d0
	add.w	#29,d1
	move.w	d0,(a0)
	move.w	d1,2(a0)
	bsr	putsprite
	rts
nomapm:
	move.w	#-1,(a0)
	rts

mapsplist:
	dc.l	mesp,enemysp0,enemysp1
mapsplistm:
	dc.l	mesp,enemysp0
mapsplist2:
	dc.l	memapsp,enmapsp0,enmapsp1,mewepsp,enwepsp
mapsplist2m:
	dc.l	memapsp,enmapsp0,mewepsp,enwepsp

*************************************
subshot:
	movem.l	d0-d7/a0-a6,-(sp)
	lea	barclearsp,a0
	move.w	shots,d0
	add.w	#32,d0
	move.w	d0,(a0)		;x-y already set
	bsr	putsprite
	tst.w	shots
	bgt	ssb
	lea	mywep,a6
	bsr	handlewep
ssb:
	movem.l	(sp)+,d0-d7/a0-a6
	rts
subdamage:
	movem.l	d0/a0,-(sp)
	tst.w	cheatmode
	bpl.s	sksd
	lea	barclearsp2,a0
	moveq	#12,d0
	sub.w	mehits,d0
	asl.w	#2,d0
	add.w	#144,d0
	move.w	d0,(a0)		;x-y already set
	bsr	putsprite
sksd:
	movem.l	(sp)+,d0/a0
	rts


checkblock2:
	lea	mymine1,a0
	bsr	cb2
	lea	mymine2,a0
	bsr	cb2
	lea	mymine3,a0
	bsr	cb2
	lea	mymine4,a0
	bsr	cb2

	lea	enmine1,a0
	bsr	cb2
	lea	enmine2,a0
	bsr	cb2
	lea	enmine3,a0
	bsr	cb2
	lea	enmine4,a0
	bsr	cb2
	lea	enwep,a0
	bsr	cb2
	lea	mywep,a0
	bsr	cb2
	rts
cb2:
	cmpi.w	#-1,mineact(a0)
	beq.s	noblockmatch2
	cmp.w	minex(a0),d0
	bne.s	noblockmatch2
	cmp.w	miney(a0),d1
	bne.s	noblockmatch2
	addq.l	#8,sp
	bra.s	wrong
noblockmatch2:
	rts

******************************
*	pass ad of block in a6
handlewep:
wrong:
	moveq	#33,d0
	bsr	randomplus
	add.w	#10,d0
	move.w	d0,d1
	moveq	#48,d0
	bsr	randomplus
	add.w	#12,d0
	move.w	d0,d2
	move.w	d1,d3
	mulu	#80,d3
	add.w	d2,d3
	lea	gamemap,a0
	cmpi.b	#16,(a0,d3.w)
	bge.s	wrong
	bsr	checkblock2
	move.w	d0,minex(a6)
	move.w	d1,miney(a6)
	move.b	#1,wepdrop
handlewep2:
	move.w	d0,d2
	move.w	d1,d3
	move.l	seen,a5
	asl.w	#4,d2		;gives actual screen x y
	asl.w	#4,d3
	move.w	d2,minex2(a6)
	move.w	d3,miney2(a6)
	mulu	#640,d3
	adda.l	d3,a5		;add to screen base address
	asr.w	#1,d2		;divide it by 2
	and.w	#$fff8,d2	;turn off lower 3 bits
	adda.w	d2,a5		;add to screen address register
	move.l	a5,minead(a6)

	mulu	#80,d1
	add.w	d0,d1
	lea	gamemap,a2
	lea	blocks,a3
	moveq	#0,d0
	move.b	(a2,d1.w),d0
	asl.w	#7,d0
	add.w	d0,a3
	move.l	a3,minerestore(a6)
	move.w	#1,mineact(a6)
	rts

doenemywep:
	lea	enwep,a6
	move.w	minex(a6),d0
	move.w	miney(a6),d1
	bsr	handlewep2
	rts

putmore:
	move.w	#64,shots
	lea	bar1sp,a0
	bsr	putsprite
	rts
wepdrop:	dc.b	-1
even
*************************************
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.b	#0,tbcr
	move.b	#189,tbdr
	move.b	#8,tbcr
	move.w	#$2300,sr
	rts

hblhandler1:
	movem.l	d0/a0,-(sp)
	lea	tbdr,a0
	move.b	#0,tbcr
	move.b	#200,(a0)
	move.b	#8,tbcr
	move.w	#$2700,sr
	nop
	nop
	nop
	nop
	move.b	(a0),d0
wait:
	cmp.b	(a0),d0
	beq.s	wait
	move.w	#0,$ff8264
	move.b	screen+2,$ff8207
	move.b	screen+1,$ff8205
	move.b	screen+3,$ff8209
	move.w	#0,$ff820e	;linwide
	move.w	#0,$ff820c
	move.w	#$0003,$ff8240+4
	bclr	#0,isra
	move.w	#$2300,sr
	movem.l	(sp)+,d0/a0
	rte

key_handler:
	move.w	#$2500,sr
keyt:	jmp	$0

ysave:		dc.w	0
oldvblvec:	blk.l	1,0
oldkeyvec:	blk.l	1,0
oldhblvec:	blk.l	1,0
oldieb:		blk.b	1,0
oldiea:		blk.b	1,0
oldima:		blk.b	1,0
even
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

boomflag:	dc.w	-1
**************************************
doboom:
	movem.l	d0-d1/a0,-(sp)
	move.l	#boom,d0
	move.l	#shoot,d1
	move.w	#1,boomflag
	bra.s	dosound
doshoot:
	movem.l	d0-d1/a0,-(sp)
	move.w	$ff8900,d0
	btst	#0,d0
	beq.s	noact
	tst.w	boomflag
	bmi.s	noact
	movem.l	(sp)+,d0-d1/a0
	rts
noact:
	move.w	#-1,boomflag
	move.l	#shoot,d0
	move.l	#wall,d1
	bra.s	dosound
dowall:
	movem.l	d0-d1/a0,-(sp)
	move.w	$ff8900,d0
	btst	#0,d0
	beq.s	noact2
	tst.w	boomflag
	bmi.s	noact2
	movem.l	(sp)+,d0-d1/a0
	rts
noact2:
	move.l	#wall,d0
	move.l	#wallend,d1
*****************************************
*	new sound chip stuff		*
*	pass sound start in d0		*
*	and sound end in d1		*
*****************************************
dosound:
	lea	$ff8900,a0	;sound register base address
	move.w	#0,sounddma(a0)
*	move.l	#music,d0
	move.w	d0,soundstartl(a0)
	lsr.l	#8,d0
	move.w	d0,soundstartm(a0)
	lsr.l	#8,d0
	move.w	d0,soundstarth(a0)

*	move.l	#musicend,d0
	move.w	d1,soundendl(a0)
	lsr.l	#8,d1
	move.w	d1,soundendm(a0)
	lsr.l	#8,d1
	move.w	d1,soundendh(a0)
	move.w	#%0000000010000000,soundmode(a0)
	move.w	#%0000000000000001,sounddma(a0)
	movem.l	(sp)+,d0-d1/a0
	rts

******************************
docollisions:
	lea	enshotlist,a0	;enemyshots hit me
	move.w	enemynum,d7
	addq.w	#1,d7
	asl.w	#2,d7
	subq.w	#1,d7
*	moveq	#3,d7
	lea	mesp,a1
	tst.w	cactive(a1)
	bmi.s	docollisionsme
	move.w	cspritex(a1),d0
	move.w	cspritey(a1),d1
	move.w	d0,d2
	move.w	d1,d3
	add.w	#16,d2
	add.w	#16,d3
dcloop:
	move.l	(a0)+,a1
	tst.w	cactive(a1)
	bmi.s	nogo
	move.w	cspritex(a1),d4
	move.w	cspritey(a1),d5
	cmp.w	d4,d2
	blt.s	nogo
	cmp.w	d5,d3
	blt.s	nogo
	addq.w	#3,d4
	addq.w	#3,d5
	cmp.w	d4,d0
	bgt.s	nogo
	cmp.w	d5,d1
	bgt.s	nogo
	cmpi.w	#0,enemynum
	beq.s	colfudge
	move.w	#-2,cactive(a1)
colfudge:
	move.w	#$0f50,$ff8240
	addq.w	#1,mehits
	bsr	subdamage
nogo:
	dbf	d7,dcloop
docollisionsme:
	move.w	enemynum,d7	;my shots hit enemy
	lea	enemylist,a0
dcml:
	move.l	(a0)+,a1
	tst.w	cactive(a1)
	bmi.s	dcml2
	move.w	cspritex(a1),d0
	move.w	cspritey(a1),d1
	move.w	d0,d2
	move.w	d1,d3
	add.w	#15,d2
	add.w	#15,d3
	bsr	checkenemy
dcml2:	dbf	d7,dcml
collisionseach:
	move.w	enemynum,d7	;we collide
	lea	enemylist,a0
	lea	mesp,a1
	move.w	cspritex(a1),d0
	move.w	cspritey(a1),d1
	add.w	xvel,d0
	add.w	yvel,d1
	move.w	d0,d2
	move.w	d1,d3
	add.w	#15,d2
	add.w	#15,d3
cel:
	move.l	(a0)+,a1
	tst.w	cactive(a1)
	bmi.s	nogoea
	move.w	cspritex(a1),d4
	move.w	cspritey(a1),d5
	cmp.w	d4,d2
	blt.s	nogoea
	cmp.w	d5,d3
	blt.s	nogoea
	add.w	#15,d4
	add.w	#15,d5
	cmp.w	d4,d0
	bgt.s	nogoea
	cmp.w	d5,d1
	bgt.s	nogoea
	bsr	dowall
	neg.w	xvel
	neg.w	yvel
	move.w	#-1,cspritefight(a1)
nogoea:
	dbf	d7,cel
checkmines:
	lea	mesp,a1			;I collide with mine
	move.w	cspritex(a1),d0
	move.w	cspritey(a1),d1
	move.w	d0,d2
	move.w	d1,d3
	add.w	#15,d2
	add.w	#15,d3
	lea	enminelist,a0
	bsr	checkem
	tst.w	d6
	bmi.s	nomhm
	move.w	#13,mehits
nomhm:
	lea	enemysp0,a1	;enemy collides with mine
	tst.w	cactive(a1)
	bmi	noe2
	move.w	cspritex(a1),d0
	move.w	cspritey(a1),d1
	move.w	d0,d2
	move.w	d1,d3
	add.w	#15,d2
	add.w	#15,d3
	lea	myminelist,a0
	bsr	checkem
	tst.w	d6
	bmi	noe2
	lea	enemysp0,a1	;enemy collides with mine
	move.w	#13,cspritehits(a1)
	lea	minesp,a0
	lea	minexylist,a1
	addq.w	#1,mines
	move.w	mines,d0
	asl.w	#1,d0
	move.w	(a1,d0.w),(a0)
	bsr	putsprite
noe2:
	lea	enemysp1,a1	;enemy collides with mine
	tst.w	cactive(a1)
	bmi	nohmh
	move.w	cspritex(a1),d0
	move.w	cspritey(a1),d1
	move.w	d0,d2
	move.w	d1,d3
	add.w	#15,d2
	add.w	#15,d3
	lea	myminelist,a0
	bsr	checkem
	tst.w	d6
	bmi	nohmh
	lea	enemysp1,a1	;enemy collides with mine
	move.w	#13,cspritehits(a1)
	lea	minesp,a0
	lea	minexylist,a1
	addq.w	#1,mines
	move.w	mines,d0
	asl.w	#1,d0
	move.w	(a1,d0.w),(a0)
	bsr	putsprite
nohmh:
	lea	mywep,a0	;check for me run over wep cash
	lea	mesp,a1
	bsr	checktwo
	tst.w	d6
	bmi	cho
	move.w	#-2,mineact(a0)
	bsr	putmore
cho:
	lea	enwep,a0	;check for enemy over wep
	lea	enemysp0,a1
	bsr	checktwo
	tst.w	d6
	bmi	cho2
	move.w	#-2,mineact(a0)
*	move.w	#64,cshots(a0)
cho2:
	rts

checkem:
	moveq	#3,d7
celc:
	move.l	(a0)+,a1
	tst.w	mineact(a1)
	bmi.s	nogoec
	move.w	minex2(a1),d4
	move.w	miney2(a1),d5
	cmp.w	d4,d2
	blt.s	nogoec
	cmp.w	d5,d3
	blt.s	nogoec
	add.w	#15,d4
	add.w	#15,d5
	cmp.w	d4,d0
	bgt.s	nogoec
	cmp.w	d5,d1
	bgt.s	nogoec
	move.w	#-2,mineact(a1)
	moveq	#1,d6
	rts
nogoec:
	dbf	d7,celc
	moveq	#-1,d6
	rts

checkenemy:
	lea	myshotlist,a2
	moveq	#3,d6
checken:
	move.l	(a2)+,a3
	tst.w	cactive(a3)
	bmi.s	nogoe
	move.w	cspritex(a3),d4
	move.w	cspritey(a3),d5
	cmp.w	d4,d2
	blt.s	nogoe
	cmp.w	d5,d3
	blt.s	nogoe
	addq.w	#3,d4
	addq.w	#3,d5
	cmp.w	d4,d0
	bgt.s	nogoe
	cmp.w	d5,d1
	bgt.s	nogoe
	move.w	#-2,cactive(a3)
	addq.w	#1,cspritehits(a1)
	cmpi.w	#5,cspritehits(a1)
	blt.s	nogoe
	move.w	#-2,cspritefight(a1)	;run away
nogoe:
	dbf	d6,checken
	rts
checktwo:
	tst.w	mineact(a0)
	bmi.s	chtb
	move.w	cspritex(a1),d0
	move.w	cspritey(a1),d1
	move.w	d0,d2
	move.w	d1,d3
	add.w	#15,d2
	add.w	#15,d3
	move.w	minex2(a0),d4
	move.w	miney2(a0),d5
	cmp.w	d4,d2
	blt.s	chtb
	cmp.w	d5,d3
	blt.s	chtb
	add.w	#15,d4
	add.w	#15,d5
	cmp.w	d4,d0
	bgt.s	chtb
	cmp.w	d5,d1
	bgt.s	chtb
	moveq	#1,d6
	rts
chtb:
	moveq	#-1,d6
	rts


enemycollision:
	lea	enemysp0,a5
*	tst.w	tankspine(a5)
*	bpl.s	ecback
	move.w	cspritex(a5),d0
	move.w	cspritey(a5),d1
	tst.w	cspritegoing(a5)
	bmi.s	skxy1
	add.w	cspritexvel(a5),d0
	add.w	cspriteyvel(a5),d1
skxy1:	move.w	d0,d2
	move.w	d1,d3
	add.w	#16,d2
	add.w	#16,d3
	lea	enemysp1,a1
	tst.w	cactive(a1)
	bmi.s	nogoee
*	tst.w	tankspine(a1)
*	bpl.s	ecback
	move.w	cspritex(a1),d4
	move.w	cspritey(a1),d5
	tst.w	cspritegoing(a1)
	bmi.s	skxy2
	add.w	cspritexvel(a1),d4
	add.w	cspriteyvel(a1),d5
skxy2:	cmp.w	d4,d2
	blt.s	nogoee
	cmp.w	d5,d3
	blt.s	nogoee
	add.w	#16,d4
	add.w	#16,d5
	cmp.w	d4,d0
	bgt.s	nogoee
	cmp.w	d5,d1
	bgt.s	nogoee
	bsr	dowall
	tst.w	cspritegoing(a1)
	bmi.s	tg1
	tst.w	tankspine(a1)
	bpl.s	nogoee
	move.w	#-2,cspritefight(a1)
	rts
tg1:
	tst.w	tankspine(a5)
	bpl.s	nogoee
	move.w	#-2,cspritefight(a5)
nogoee:
ecback:
	rts

enminelist:	dc.l	enmine1,enmine2,enmine3,enmine4
myminelist:	dc.l	mymine1,mymine2,mymine3,mymine4
myshotlist:
	dc.l	meshot1,meshot2,meshot3,meshot4,-1

midibuff:	dc.l	0
setflag:	dc.w	0
novbl:	dc.w	-1
even
sorm:	dc.w	-1
**************************************
establishcoms:
	bsr	clearmidi
	bsr	cleartext
	lea	miditext1,a0
	bsr 	gemprint
	lea	miditext2,a0
	bsr	gemprint
	bsr	keymidi
	cmpi.w	#master,sorm
	beq	icontrol
	cmpi.w	#single,sorm
	beq	onlyme
amslave:
waitstart:
	move.w	#3,-(sp)	;midi device
	move.w	#1,-(sp)
	trap	#13		;is there a char waiting
	addq.l	#4,sp
	tst.w	d0
	beq	waitstart

	move.w	#midiport,-(sp)
	move.w	#2,-(sp)
	trap	#13		;get and discard midi dat
	addq.l	#4,sp
	bra	setupall
icontrol:
*	bsr	cleartext
	lea	mastertext2,a0
	bsr	gemprint
waitk:
	move.w	#$ff,-(sp)
	move.w	#6,-(sp)
	trap	#1
	addq.l	#4,sp
	tst.l	d0		;wait for keypress
	beq	waitk

	move.b	#0,startstring
	move.l	#startstring,-(sp)
	move.w	#0,-(sp)
	move.w	#12,-(sp)
	trap	#14		;send start message
	addq.l	#8,sp
	bra	setupall

onlyme:
	bsr	cleartext
	lea	singletext,a0
	bsr	gemprint
	lea	singletext2,a0
	bsr	gemprint
	move.w	#1,enemynum
waitks:
	move.w	#$ff,-(sp)
	move.w	#6,-(sp)
	trap	#1
	addq.l	#4,sp
	tst.l	d0
	beq	waitks

	lea	poslist,a0
	move.w	#4,d0
	bsr	randomplus
	lsl.w	#2,d0
	move.w	(a0,d0.w),screenx
	move.w	2(a0,d0.w),screeny
	move.w	#0,mehits
	move.w	#-1,tankplane
	lea	mesp,a0
	move.w	screenx,d1
	move.w	screeny,d2
	add.w	#160-8,d1
	add.w	#100-8,d2
	move.w	d1,cspritex(a0)
	move.w	d2,cspritey(a0)
	move.l	#metanksprites,cspritead(a0)
	move.w	#1,cactive(a0)
	move.b	#8,whichme
	move.w	#-1,tankspin
	move.w	#-yv8,shotyvel
	move.w	#0,shotxvel


	lea	enemysp0,a0
	bsr	getrandlist
	move.l	a1,cspritelocation(a0)
	move.l	a1,cspriteheading(a0)
	move.l	a1,cspritelistad(a0)
	move.w	#-1,cspritegoing(a0)
	move.w	#1,cactive(a0)
	move.w	#-1,cspritefollow(a0)
	move.w	#1,cspritefight(a0)
	move.w	#0,cspritehits(a0)
	move.w	#-1,cspriteexploding(a0)
	move.l	a1,a6
	bsr	dolist

	lea	enemysp1,a0
da:	bsr	getrandlist
	cmp.l	a6,a1
	beq.s	da
	move.l	a1,cspritelocation(a0)
	move.l	a1,cspriteheading(a0)
	move.l	a1,cspritelistad(a0)
	move.w	#-1,cspritegoing(a0)
	move.w	#1,cactive(a0)
	move.w	#-1,cspritefollow(a0)
	move.w	#1,cspritefight(a0)
	move.w	#0,cspritehits(a0)
	move.w	#-1,cspriteexploding(a0)
	bsr	dolist

	bsr	dosmallmap
	bsr	makemap
	bsr	putbarsandbits
	move.w	#-1,novbl
	move.w	#189,my
	bra	gamesingle

setupall:
	move.w	#0,enemynum
	lea	poslist,a0
	move.w	#4,d0
	bsr	randomplus
	lsl.w	#2,d0
	move.w	(a0,d0.w),screenx
	move.w	2(a0,d0.w),screeny
	move.w	#0,mehits
	move.w	#-1,tankplane
	lea	mesp,a0
	move.l	#metanksprites,cspritead(a0)
	move.w	#1,cactive(a0)
	move.b	#8,whichme
	move.w	#-1,tankspin
	move.w	#-yv8,shotyvel
	move.w	#0,shotxvel
	bsr	testc
	bsr	sendme
	bsr	doothers
testd:
	lea	enemysp0,a0
	lea	mesp,a1
	move.w	cspritex(a1),d0
	cmp.w	cspritex(a0),d0
	bne.s	ok1
	move.w	cspritey(a1),d0
	cmp.w	cspritey(a0),d0
	bne.s	ok1
	lea	poslist,a0
	move.w	#4,d0
	bsr	randomplus
	lsl.w	#2,d0
	move.w	(a0,d0.w),screenx
	move.w	2(a0,d0.w),screeny
	lea	mesp,a0
	bsr	testc
	bra.s	testd
ok1:
	bsr	sendme
	bsr	dosmallmap
	bsr	makemap
	bsr	putbarsandbits
	move.w	#-1,novbl
	move.w	#189,my
	bra	gamemulti

getrandlist:
	lea	list,a1
	moveq	#75,d0
	bsr	randomplus
	asl.w	#4,d0
	add.w	d0,a1
	rts


*****************************************
putbarsandbits:
	lea	bar1sp,a0
	bsr	putsprite
	lea	bar2sp,a0
	bsr	putsprite

	lea	minesp,a0
	move.w	#224,(a0)
	move.w	#1,12(a0)	;treat as proper sprite
	bsr	putsprite
	move.w	#232,(a0)
	bsr	putsprite
	move.w	#240,(a0)
	bsr	putsprite
	move.w	#248,(a0)
	bsr	putsprite
	move.w	#-1,12(a0)	;treat as proper sprite

	lea	tanksp,a0
	move.w	#288,(a0)
	move.w	#1,12(a0)	;treat as proper sprite
	bsr	putsprite
	move.w	#296,(a0)
	bsr	putsprite
	move.w	#304,(a0)
	bsr	putsprite
	move.w	#-1,12(a0)
	rts


startstring:
	dc.b	0
miditext1:
	dc.b	91,34,'SPACE BAR TO BEGIN MIDI',0
miditext2:
	DC.B	100,40,'ANY OTHER FOR SINGLE',0
singletext:
	DC.B	106,34,'SINGLE PLAYER GAME',0
singletext2:
	DC.B	82,40,'SELECTED, ANY KEY TO START',0
even
clearmidi:
	move.w	#3,-(sp)	;midi device
	move.w	#1,-(sp)
	trap	#13		;is there a char waiting
	addq.l	#4,sp
	tst.w	d0
	beq	clearback	;already clear
	move.w	#midiport,-(sp)
	move.w	#2,-(sp)
	trap	#13
	addq.l	#4,sp
	bra	clearmidi
clearback:
	rts

midistring:
	blk.b	60,0

medeadtext1:
	dc.b	91,34,'YOU HAVE BEEN DEFEATED !',0
medeadtext2:
	dc.b	82,41,'AWAITING VICTOR TO RESTART',0
even
medead:
	move.w	#1,novbl
	move.w	#1,my
	addq.l	#4,sp
	move.b	#$12,(a0)+
	move.b	#$12,(a0)+
	bsr	nowd2		;send I'm dead
	bsr	cleartext
	lea	medeadtext1,a0
	bsr	gemprint
	lea	medeadtext2,a0
	bsr	gemprint
	bsr	clearmidi
	move.w	#midiport,-(sp)
	move.w	#2,-(sp)
	trap	#13
	addq.l	#4,sp		;get and discard midi dat
	bra	dorestart

******************************
sendme:
	lea	midistring,a0
	move.l	a0,a2
	tst.w	tanks
	bge.s	no
	bra.s	medead
no:	move.b	#0,(a0)+		;a not over byte
	lea	mesp,a1
	move.w	cactive(a1),d0
	bpl.s	plact
	move.b	d0,(a0)+
	bra.s	sendshot1
plact:
	move.b	cspritex(a1),(a0)+	;x
	move.b	cspritex+1(a1),(a0)+	;x
	move.b	cspritey(a1),(a0)+	;y
	move.b	cspritey+1(a1),(a0)+	;y
	move.b	whichme,(a0)+		;playerimage
sendshot1:
	lea	meshot1,a1
	move.w	cactive(a1),d0
	bpl.s	shact1
	move.b	d0,(a0)+
	bra.s	sendshot2
shact1:
	move.b	cspritex(a1),(a0)+	;x
	move.b	cspritex+1(a1),(a0)+	;x
	move.b	cspritey(a1),(a0)+	;y
	move.b	cspritey+1(a1),(a0)+	;y
sendshot2:
	lea	meshot2,a1
	move.w	cactive(a1),d0
	bpl.s	shact2
	move.b	d0,(a0)+
	bra.s	sendshot3
shact2:
	move.b	cspritex(a1),(a0)+	;x
	move.b	cspritex+1(a1),(a0)+	;x
	move.b	cspritey(a1),(a0)+	;y
	move.b	cspritey+1(a1),(a0)+	;y
sendshot3:
	lea	meshot3,a1
	move.w	cactive(a1),d0
	bpl.s	shact3
	move.b	d0,(a0)+
	bra.s	sendshot4
shact3:
	move.b	cspritex(a1),(a0)+	;x
	move.b	cspritex+1(a1),(a0)+	;x
	move.b	cspritey(a1),(a0)+	;y
	move.b	cspritey+1(a1),(a0)+	;y
sendshot4:
	lea	meshot4,a1
	move.w	cactive(a1),d0
	bpl.s	shact4
	move.b	d0,(a0)+
	bra.s	sendshot5
shact4:
	move.b	cspritex(a1),(a0)+	;x
	move.b	cspritex+1(a1),(a0)+	;x
	move.b	cspritey(a1),(a0)+	;y
	move.b	cspritey+1(a1),(a0)+	;y
sendshot5:
	move.b	minedrop,(a0)+
	tst.w	minedrop
	bmi	nokd
	move.b	#-1,minedrop
nokd:
	tst.b	wepdrop
	bmi	nowd
	move.b	#-1,wepdrop
	lea	mywep,a1
	move.b	minex(a1),(a0)+
	move.b	minex+1(a1),(a0)+
	move.b	miney(a1),(a0)+	
	move.b	miney+1(a1),(a0)+
	bra.s	nowd2
nowd:
	move.b	#-1,(a0)+
nowd2:
	lea	$ffffffc04,a1
	sub.l	a2,a0
	subq.w	#1,a0
	move.w	a0,d3		;counter of chars to write to midi
*	lea	midistring,a2
miditest:
	move.b	0(a1),d2
	btst	#1,d2
	beq.s	miditest
	move.b	(a2)+,2(a1)
	dbf	d3,miditest
	rts

sendmestop:
	lea	midistring,a0
	move.l	a0,a2
	move.b	#$12,(a0)+
	bsr	nowd2
	move.w	#1,my		;put screen up


minedrop:	dc.b	-1
even
************************
enshotlist:
	dc.l	enemyshot00,enemyshot01,enemyshot02,enemyshot03
	dc.l	enemyshot10,enemyshot11,enemyshot12,enemyshot13,-1
*	dc.l	enemyshot20,enemyshot21,enemyshot22,enemyshot23
*	dc.l	enemyshot30,enemyshot31,enemyshot32,enemyshot33
enemylist:
	dc.l	enemysp0,enemysp1,-1	;,enemysp1,enemysp2,enemysp3
enemynum:	dc.w	0
**************************************
midiport:	equ	3
mygetmidi:
	move.l	midibuff,a0
mgm1:
	lea	6(a0),a2
	lea	8(a0),a3
	cmpm.w	(a3)+,(a2)+
	bne.s	mgm2
	bra.s	mgm1
mgm2:
	move.w	sr,-(sp)
	or.w	#$700,sr
	move.w	6(a0),d1
	cmp.w	8(a0),d1
	beq.s	mgm4
	addq.w	#1,d1
	cmp.w	4(a0),d1
	bcs.s	mgm3
	moveq	#0,d1
mgm3:
	move.l	0(a0),a1
	move.b	0(a1,d1.w),d0
	move.w	d1,6(a0)
mgm4:
	move.w	(sp)+,sr
	rts

doothers:
	bsr	mygetmidi
	cmpi.b	#$12,d0		;special status byte
	beq	startover
	lea	enshotlist,a6
	lea	enemylist,a5
dootloop:
	move.l	(a5)+,a4	;get player sp
	bsr	mygetmidi
	tst.b	d0
	bmi	noshotactp
	move.b	d0,cspritex(a4)
	bsr	mygetmidi
	move.b	d0,cspritex+1(a4)	;that makes x

	bsr	mygetmidi
	move.b	d0,cspritey(a4)
	bsr	mygetmidi
	move.b	d0,cspritey+1(a4)	;that makes y

	bsr	mygetmidi
	and.l	#$ff,d0
	lea	enemysprites,a0
	mulu	#5120,d0
	add.l	d0,a0
	move.l	a0,cspritead(a4)
	move.w	#1,cactive(a4)
	bra.s	getshots
noshotactp:
	ext.w	d0
	move.w	d0,cactive(a4)	;this one aint active for 1st time
getshots:
	moveq	#3,d6		;4 shots for each player
gsloop:
	move.l	(a6)+,a4
shotdata:
	bsr	mygetmidi
	tst.b	d0
	bmi	noshotact
	move.b	d0,cspritex(a4)
	bsr	mygetmidi
	move.b	d0,cspritex+1(a4)	;that makes x
	bsr	mygetmidi
	move.b	d0,cspritey(a4)
	bsr	mygetmidi
	move.b	d0,cspritey+1(a4)	;that makes x
	move.w	#1,cactive(a4)
	dbf	d6,gsloop
	bra.s	domineot
noshotact:
	ext.w	d0
	cmpi.w	#-2,d0
	bne	dont
	move.w	d0,cactive(a4)	;this one aint active for 1st time
dont:
	dbf	d6,gsloop
domineot:
	bsr	mygetmidi
	tst.b	d0
	bmi.s	nonewmine
	movem.l	d0-d7/a0-a6,-(sp)
	bsr	doenemymine
	movem.l	(sp)+,d0-d7/a0-a6
nonewmine:
	bsr	mygetmidi
	tst.b	d0
	bmi.s	nonewwep
	lea	enwep,a4
*	bsr	mygetmidi
	move.b	d0,minex(a4)
	bsr	mygetmidi
	move.b	d0,minex+1(a4)
	bsr	mygetmidi
	move.b	d0,miney(a4)
	bsr	mygetmidi
	move.b	d0,miney+1(a4)
	movem.l	d0-d7/a0-a6,-(sp)
	bsr	doenemywep
	movem.l	(sp)+,d0-d7/a0-a6
nonewwep:
putothers:
	lea	enemysp0,a0
	bsr	preparesprite
	lea	enemyshot00,a0
	bsr	preparesprite
	lea	enemyshot01,a0
	bsr	preparesprite
	lea	enemyshot02,a0
	bsr	preparesprite
	lea	enemyshot03,a0
	bsr	preparesprite
	rts

startover:
	move.w	#1,novbl
	move.w	#1,my
	addq.l	#4,sp
	bsr	clearmidi
	bsr	cleartext
	lea	mewintext1,a0
	bsr	gemprint
	lea	mewintext2,a0
	bsr	gemprint
	bsr	clearkeyboard
waitko:
	move.w	#$ff,-(sp)
	move.w	#6,-(sp)
	trap	#1
	addq.l	#4,sp
	tst.l	d0		;wait for keypress
	beq	waitko
	move.l	#masterstring,-(sp)
	move.w	#0,-(sp)
	move.w	#12,-(sp)
	trap	#14
	addq.l	#8,sp		;send sig to restart
	bra	dorestart

clearkeyboard:
cleark:
	move.w	#$ff,-(sp)
	move.w	#6,-(sp)
	trap	#1
	addq.l	#4,sp
	tst.l	d0		;wait for keypress
	bne	cleark
	rts

mewintext1:
	dc.b	100,34,'YOU ARE VICTORIOUS !',0
mewintext2:
	dc.b	103,40,'ANY KEY TO RESTART',0
even
*************************************
stch:
	move.w	buttondat,d0
	cmp.w	lastb,d0
	beq	nochange
	move.w	#-1,changestate
	move.w	d0,lastb
	rts
nochange:
	move.w	#1,changestate
	rts
changestate:
	dc.w	-1


doenemyshots:
	lea	enemysp0,a1
	tst.w	cactive(a1)
	bmi.s	deso1
	subq.w	#1,cspriteshotdel(a1)
	bpl	deso1
	move.w	#-1,cspriteshotdel(a1)
	tst.w	tankplanee(a1)
	bpl.s	deso1
	tst.w	tankspine(a1)
	bpl.s	deso1
*	cmpi.w	#2,cspritevels(a1)
*	bgt.s	deso1
	lea	enemyshot00,a0
	tst.w	cactive(a0)
	bpl.s	dsa1
	bsr	doeshotavail
	bra.s	deso1
dsa1:
	lea	enemyshot01,a0
	tst.w	cactive(a0)
	bpl.s	dsa2
	bsr	doeshotavail
	bra.s	deso1
dsa2:
	lea	enemyshot02,a0
	tst.w	cactive(a0)
	bpl.s	dsa3
	bsr	doeshotavail
	bra.s	deso1
dsa3:
	lea	enemyshot03,a0
	tst.w	cactive(a0)
	bpl.s	deso1
	bsr	doeshotavail
deso1:
	lea	enemysp1,a1
	tst.w	cactive(a1)
	bmi.s	deso2
	subq.w	#1,cspriteshotdel(a1)
	bpl	deso2
	move.w	#-1,cspriteshotdel(a1)
	tst.w	tankplanee(a1)
	bpl.s	deso2
	tst.w	tankspine(a1)
	bpl.s	deso2
*	cmpi.w	#2,cspritevels(a1)
*	bgt.s	deso2
	lea	enemyshot10,a0
	tst.w	cactive(a0)
	bpl.s	dsb1
	bsr	doeshotavail
	bra.s	deso2
dsb1:
	lea	enemyshot11,a0
	tst.w	cactive(a0)
	bpl.s	dsb2
	bsr	doeshotavail
	bra.s	deso2
dsb2:
	lea	enemyshot12,a0
	tst.w	cactive(a0)
	bpl.s	dsb3
	bsr	doeshotavail
	bra.s	deso2
dsb3:
	lea	enemyshot13,a0
	tst.w	cactive(a0)
	bpl.s	deso2
	bsr	doeshotavail
deso2:
	lea	enemyshot00,a0
	bsr	domoves
	bsr	preparesprite
	lea	enemyshot01,a0
	bsr	domoves
	bsr	preparesprite
	lea	enemyshot02,a0
	bsr	domoves
	bsr	preparesprite
	lea	enemyshot03,a0
	bsr	domoves
	bsr	preparesprite
	lea	enemyshot10,a0
	bsr	domoves
	bsr	preparesprite
	lea	enemyshot11,a0
	bsr	domoves
	bsr	preparesprite
	lea	enemyshot12,a0
	bsr	domoves
	bsr	preparesprite
	lea	enemyshot13,a0
	bsr	domoves
	bsr	preparesprite
	rts

doeshotavail:
	bsr	doshoot
	move.w	#8,cspriteshotdel(a1)
	move.w	cspritexvel(a1),d0
	move.w	cspriteyvel(a1),d1
	move.w	d0,d2
	bpl.L	dsaa
	neg.w	d2
dsaa:
	cmpi.w	#2,d2
	bgt.s	dsab
	move.w	d1,d2
	bpl.s	dsaab
	neg.w	d2
dsaab:
	cmpi.w	#2,d2
	bgt.s	dsab
	add.w	d0,d0
	add.w	d1,d1
	move.w	d0,cspritexvel(a0)
	move.w	d1,cspriteyvel(a0)
	move.w	cspritex(a1),cspritex(a0)
	move.w	cspritey(a1),cspritey(a0)
	add.w	#8-1,cspritex(a0)
	add.w	#8-1,cspritey(a0)
	move.w	#1,cactive(a0)
	move.w	#150,cspritelife(a0)
	move.w	#1,cspriterotate(a1)
dsab:	rts

***************************************
doshots:
	tst.w	tankplane
	bpl	noshot
	tst.w	changestate
	bpl.L	movemyshots
	tst.w	buttondat
	beq.L	movemyshots
	tst.w	shots
	ble	movemyshots
	lea	meshot1,a0
	tst.w	cactive(a0)
	bpl.s	isshot2
	bsr	doshotavail
	bra.s	movemyshots
isshot2:
	lea	meshot2,a0
	tst.w	cactive(a0)
	bpl.s	isshot3
	bsr	doshotavail
	bra.s	movemyshots
isshot3:
	lea	meshot3,a0
	tst.w	cactive(a0)
	bpl.s	isshot4
	bsr	doshotavail
	bra.s	movemyshots
isshot4:
	lea	meshot4,a0
	tst.w	cactive(a0)
	bpl.s	movemyshots
	bsr	doshotavail

movemyshots:
	lea	meshot1,a0
	bsr.L	domoves
	bsr	preparesprite
	lea	meshot2,a0
	bsr.L	domoves
	bsr	preparesprite
	lea	meshot3,a0
	bsr.L	domoves
	bsr	preparesprite
	lea	meshot4,a0
	bsr.L	domoves
	bsr	preparesprite
	rts

domoves:
	tst.w	cactive(a0)
	bmi.L	dmback
	subq.w	#1,cspritelife(a0)
	bmi.L	endofshot
	move.w	cspritexvel(a0),d3
	move.w	cspriteyvel(a0),d4
	move.w	cspritex(a0),d1
	move.w	cspritey(a0),d2
	add.w	d3,d1
	add.w	d4,d2
	move.w	d1,d5
	move.w	d2,d6

	tst.w	d3
	beq.L	upordown
	tst.w	d4
	beq.L	leftorright
	tst.w	d3
	bmi	goingleft
goingright:
	move.w	#-1,hits2
	tst.w	d4
	bmi	ru
rd:
	bsr	chrights
	bsr	chbots
	tst.w	hits2
	bgt	endofshot
	add.w	d3,cspritex(a0)
	add.w	d4,cspritey(a0)
noshot:
	rts
ru:
	bsr	chrights
	bsr	chtops
	tst.w	hits2
	bgt	endofshot
	add.w	d3,cspritex(a0)
	add.w	d4,cspritey(a0)
	rts
hits2:	dc.w	-1
goingleft:
	move.w	#-1,hits2
	tst.w	d4
	bmi	lu
ld:
	bsr	chlefts
	bsr	chbots
	tst.w	hits2
	bgt	endofshot
	add.w	d3,cspritex(a0)
	add.w	d4,cspritey(a0)
	rts
lu:
	bsr	chlefts
	bsr	chtops
	tst.w	hits2
	bgt	endofshot
	add.w	d3,cspritex(a0)
	add.w	d4,cspritey(a0)
	rts


leftorright:
	tst.w	d3
	bmi.s	left
	bsr	chrights
	add.w	d3,cspritex(a0)
	add.w	d4,cspritey(a0)
	rts
left:
	bsr	chlefts
	add.w	d3,cspritex(a0)
	add.w	d4,cspritey(a0)
	rts
upordown:
	tst.w	d4
	bmi.s	up
	bsr	chbots
	add.w	d3,cspritex(a0)
	add.w	d4,cspritey(a0)
	rts
up:
	bsr	chtops
	add.w	d3,cspritex(a0)
	add.w	d4,cspritey(a0)
	rts
	
chstops:
	add.w	d3,cspritex(a0)
	add.w	d4,cspritey(a0)
	rts

chlefts:
	move.w	d5,d1
	move.w	d6,d2
	subq.w	#1,d1
	addq.w	#2,d2
	move.w	d1,pixelx
	move.w	d2,pixely
	bsr	mygetpix
	tst.w	d0
	beq.s	ishita
	cmpi.w	#3,d0
	blt.s	chlback
	cmpi.w	#7,d0
	bge.s	chlback
ishita:
	neg.w	cspritexvel(a0)
	neg.w	d3
	addq.w	#1,hits2
chlback:
	rts

chrights:
	move.w	d5,d1
	move.w	d6,d2
	addq.w	#4,d1
	addq.w	#2,d2
	move.w	d1,pixelx
	move.w	d2,pixely
	bsr	mygetpix
	tst.w	d0
	beq.s	ishitb
	cmpi.w	#3,d0
	blt.s	chrback
	cmpi.w	#7,d0
	bge.s	chrback
ishitb:
	neg.w	cspritexvel(a0)
	neg.w	d3
	addq.w	#1,hits2
chrback:
	rts
chtops:
	move.w	d5,d1
	move.w	d6,d2
	addq.w	#1,d1
	subq.w	#1,d2
	move.w	d1,pixelx
	move.w	d2,pixely
	bsr	mygetpix
	tst.w	d0
	beq.s	ishitc
	cmpi.w	#3,d0
	blt.s	chtback
	cmpi.w	#7,d0
	bge.s	chtback
ishitc:
	neg.w	cspriteyvel(a0)
	neg.w	d4
	addq.w	#1,hits2
chtback:
	rts

chbots:
	move.w	d5,d1
	move.w	d6,d2
	addq.w	#5,d2
	addq.w	#1,d1
	move.w	d1,pixelx
	move.w	d2,pixely
	bsr	mygetpix
	tst.w	d0
	beq.s	ishitd
	cmpi.w	#3,d0
	blt.s	chbback
	cmpi.w	#7,d0
	bge.s	chbback
ishitd:
	neg.w	cspriteyvel(a0)
	neg.w	d4
	addq.w	#1,hits2
chbback:
	rts
endofshot:
	move.w	#-2,cactive(a0)
dmback:
	rts
doshotavail:
	bsr	doshoot
	subq.w	#1,shots
	bsr	subshot
	move.w	shotxvel,d0
	move.w	shotyvel,d1
	move.w	d0,cspritexvel(a0)
	move.w	d1,cspriteyvel(a0)
	lea	mesp,a1
	move.w	cspritex(a1),cspritex(a0)
	move.w	cspritey(a1),cspritey(a0)
	add.w	#8-1,cspritex(a0)
	add.w	#8-1,cspritey(a0)
	move.w	#1,cactive(a0)
	move.w	#150,cspritelife(a0)
	rts

tankplane:	dc.w	-1
tankspin:	dc.w	100
tankimage:	dc.l	metanksprites
tankstart:	dc.l	metanksprites
tankadd:	dc.l	0
whichmehigh:	dc.b	0
whichmestart:	dc.b	0

doenemyspinning:
	tst.w	cactive(a0)
	bmi	normalmee
	tst.w	tankspine(a0)
	bmi.L	normalmee
	subq.w	#1,tankspine(a0)
	bpl.s	nospece
	tst.w	tankplanee(a0)
	bpl.s	isplanee
	move.b	whichmestarte(a0),d0
	add.b	#8,d0
	move.b	d0,whichmee(a0)
	lea	enemytanksprites,a2
	add.l	tankadde(a0),a2
	move.l	a2,cspritead(a0)
	bra.s	normalmee
isplanee:
	move.b	whichmestarte(a0),d0
	subq.b	#8,d0
	move.b	d0,whichmee(a0)
	lea	enemysprites,a2
	add.l	tankadde(a0),a2
	move.l	a2,cspritead(a0)
	bra.s	normalmee
nospece:
	addq.b	#1,whichmee(a0)
	move.b	whichmehighe(a0),d0
	cmp.b	whichmee(a0),d0
	bgt.s	whm1e
	move.b	whichmestarte(a0),whichmee(a0)
whm1e:
*	lea	mesp,a1
	move.l	tankimagee(a0),cspritead(a0)
	move.l	tankstarte(a0),d0
	add.l	#8*5120,d0
	add.l	#5120,tankimagee(a0)
	cmpi.l	tankimagee(a0),d0
	bgt.s	normalmee
	move.l	tankstarte(a0),tankimagee(a0)
normalmee:
	rts
***************************************
dome:
	tst.w	tankspin
	bmi.L	normalme
	subq.w	#1,tankspin
	bpl.s	nospec
	lea	mesp,a1
	tst.w	tankplane
	bpl.s	isplane
	move.b	whichmestart,d0
	add.b	#8,d0
	move.b	d0,whichme
	lea	metanksprites,a0
	add.l	tankadd,a0
	move.l	a0,cspritead(a1)
	bra.s	normalme
isplane:
	move.b	whichmestart,d0
	subq.b	#8,d0
	move.b	d0,whichme
	lea	mesprites,a0
	add.l	tankadd,a0
	move.l	a0,cspritead(a1)
	bra.s	normalme
nospec:
	addq.b	#1,whichme
	move.b	whichmehigh,d0
	cmp.b	whichme,d0
	bgt.s	whm1
	move.b	whichmestart,whichme
whm1:
	lea	mesp,a1
	move.l	tankimage,cspritead(a1)
	move.l	tankstart,d0
	add.l	#8*5120,d0
	add.l	#5120,tankimage
	cmpi.l	tankimage,d0
	bgt.s	normalme
	move.l	tankstart,tankimage
normalme:
	tst.w	tankplane
	bpl.s	plane
	moveq	#2,d0
	moveq	#-2,d1
	bra.s	realstuff
plane:
	moveq	#8,d0
	moveq	#-8,d1
realstuff:
	move.w	xvel,d3
	move.w	yvel,d4
	cmp.w	d0,d3
	ble.s	dm1
	move.w	d0,d3
	move.w	d0,xvel
	bra.s	dm2
dm1:
	cmp.w	d1,d3
	bge.s	dm2
	move.w	d1,d3
	move.w	d1,xvel
dm2:
	cmp.w	d0,d4
	ble.s	dm3
	move.w	d0,d4
	move.w	d0,yvel
	bra.s	dm4
dm3:
	cmp.w	d1,d4
	bge.s	dm4
	move.w	d1,d4
	move.w	d1,yvel
dm4:
	movem.w	d3-d4,-(sp)
	lea	mesp,a0
	move.w	screenx,d1
	move.w	screeny,d2
	add.w	d3,d1
	add.w	d4,d2
	move.w	d1,d5
	move.w	d2,d6
	add.w	#151,d1
	add.w	#100,d2
	tst.w	d3
	bge.s	chright
	move.w	d1,pixelx
	move.w	d2,pixely
	bsr	mygetpix
	tst.w	d0
	beq.s	ishit1
	cmpi.w	#3,d0
	blt.s	chtop
	cmpi.w	#7,d0
	bge.s	chtop
ishit1:
	neg.w	xvel
	moveq	#0,d3
	bra.s	chtop
chright:
	add.w	#17,d1
	tst.w	d3
	beq.s	chtop
	move.w	d1,pixelx
	move.w	d2,pixely
	bsr	mygetpix
	tst.w	d0
	beq.s	ishit2
	cmpi.w	#3,d0
	blt.s	chtop
	cmpi.w	#7,d0
	bge.s	chtop
ishit2:
	neg.w	xvel
	moveq	#0,d3
chtop:
	move.w	d5,d1
	move.w	d6,d2
	add.w	#91,d2
	add.w	#159,d1
	tst.w	d4
	bgt.s	chbot
	beq.s	chstop
	move.w	d1,pixelx
	move.w	d2,pixely
	bsr	mygetpix
	tst.w	d0
	beq.s	ishit3
	cmpi.w	#3,d0
	blt.s	chstop
	cmpi.w	#7,d0
	bge.s	chstop
ishit3:
	neg.w	yvel
	moveq	#0,d4
	bra.s	chstop
chbot:
	add.w	#17,d2
	move.w	d1,pixelx
	move.w	d2,pixely
	bsr	mygetpix
	tst.w	d0
	beq.s	ishit4
	cmpi.w	#3,d0
	blt.s	chstop
	cmpi.w	#7,d0
	bge.s	chstop
ishit4:
	neg.w	yvel
	moveq	#0,d4
chstop:
	movem.w	(sp)+,d0-d1
	cmp.w	d0,d3
	beq.s	chs1
	bsr	dowall
	bra.s	chs2
chs1:
	cmp.w	d1,d4
	beq.s	chs2
	bsr	dowall
chs2:
	add.w	d3,screenx
	add.w	d4,screeny
testc:	move.w	screenx,d1
	move.w	screeny,d2
	add.w	#160-8,d1
	add.w	#100-8,d2
	move.w	d1,cspritex(a0)
	move.w	d2,cspritey(a0)
	move.w	#1,cactive(a0)
	bsr	preparesprite
	rts
****************************************
whichme:	dc.b	0
even
****************************************
joydir:
	lea	mesp,a0
	tst.w	tankplane
	bpl.s	plim
	lea	metanksprites,a1
	move.w	#8,d7
	bra.s	joystart
plim:	lea	mesprites,a1
	move.b	#0,d7
joystart:
	move.l	a1,tankstart
	tst.b	joyport1
	beq	jdback2aa
	move.b	d7,whichme
	move.b	joyport1,d0
north2:
	cmpi.b	#1,d0
	bne	neast2
	sub.w	#nsamount2,yvel
	move.w	#-yv8,shotyvel
	move.w	#0,shotxvel
	move.l	a1,cspritead(a0)
	add.b	#0,whichme
	bra.L	jdback2a
neast2: cmpi.b	#9,d0
	bne	east2
	sub.w	#nsamount2,yvel
	add.w	#nsamount2,xvel
	move.w	#-yv8,shotyvel
	move.w	#xv8,shotxvel
	lea	5120*1(a1),a1
	move.l	a1,cspritead(a0)
	add.b	#1,whichme
	bra.L	jdback2
east2:	cmpi.b	#8,d0
	bne	seast2
	add.w	#nsamount2,xvel
	move.w	#0,shotyvel
	move.w	#xv8,shotxvel
	lea	5120*2(a1),a1
	move.l	a1,cspritead(a0)
	add.b	#2,whichme
	bra.L	jdb2
seast2: cmpi.b	#10,d0
	bne	south2
	add.w	#nsamount2,yvel
	add.w	#nsamount2,xvel
	move.w	#yv8,shotyvel
	move.w	#xv8,shotxvel
	lea	5120*3(a1),a1
	move.l	a1,cspritead(a0)
	add.b	#3,whichme
	bra.L	jdback2
south2: cmpi.b	#2,d0
	bne	swest2
	add.w	#nsamount2,yvel
	move.w	#yv8,shotyvel
	move.w	#0,shotxvel
	lea	5120*4(a1),a1
	move.l	a1,cspritead(a0)
	add.b	#4,whichme
	bra.L	jdback2a
swest2: cmpi.b	#6,d0
	bne	west2
	add.w	#nsamount2,yvel
	sub.w	#nsamount2,xvel
	move.w	#yv8,shotyvel
	move.w	#-xv8,shotxvel
	lea	5120*5(a1),a1
	move.l	a1,cspritead(a0)
	add.b	#5,whichme
	bra.s	jdback2
west2:	cmpi.b	#4,d0
	bne	nwest2
	sub.w	#nsamount2,xvel
	move.w	#0,shotyvel
	move.w	#-xv8,shotxvel
	lea	5120*6(a1),a1
	move.l	a1,cspritead(a0)
	add.b	#6,whichme
	bra.s	jdb2
nwest2: cmpi.b	#5,d0
	bne	jdback2
	sub.w	#nsamount2,yvel
	sub.w	#nsamount2,xvel
	move.w	#-yv8,shotyvel
	move.w	#-xv8,shotxvel
	add.l	#5120*7,a1
	move.l	a1,cspritead(a0)
	add.b	#7,whichme
jdback2:
	rts

jdback2a:
	tst.w	xvel
	bmi.s	jdb1
	beq.s	jdb2a
	subq.w	#1,xvel
	bra.s	jdb2a
jdb1:
	addq.w	#1,xvel
jdb2a:
	rts

jdback2aa:
	tst.w	xvel
	bmi.s	jdb1aa
	beq.s	jdb2
	subq.w	#1,xvel
	bra.s	jdb2
jdb1aa:
	addq.w	#1,xvel
jdb2:
	tst.w	yvel
	bmi.s	jdb3
	beq.s	jdbb
	subq.w	#1,yvel
	rts
jdb3:
	addq.w	#1,yvel
jdbb:
	rts

firebutton:	blk.w	1,-1
*****************************************
*	set up joystick handler 	*
*****************************************
joystuff:
	move.w	#34,-(sp)
	trap	#14
	addq.l	#2,sp
	move.l	d0,a0
	adda.l	#24,a0
	move.l	(a0),old_packh		;save the old handler
	move.l	#joy_packet,(a0)	;put in mine
	rts
*****************************************	
*	this is the joy pak handler	*
*****************************************
joy_packet:
	movem.l a0/a1,-(sp)
	lea	joyport0,a1
	move.b	1(a0),(a1)
	move.b	2(a0),1(a1)
	movem.l (sp)+,a0/a1
	rts

joyport0:	blk.b	1,0
joyport1:	blk.b	1,0
	even

res_mouse:
	move.w	#34,-(sp)
	trap	#14
	addq.l	#2,sp
	move.l	d0,a0
	adda.l	#24,a0
	move.l	old_packh,(a0)

rs2:	move.w	#128,-(sp)
	move.w	#4,-(sp)
	move.w	#3,-(sp)
	trap	#13
	addq.l	#6,sp

	move.w	#1,-(sp)
	move.w	#4,-(sp)
	move.w	#3,-(sp)
	trap	#13
	addq.l	#6,sp
	rts

old_packh:	blk.l	1,0

*****************************************
sortsprites:
	lea	drawlist,a0
	lea	drawlistonscreen,a1
	lea	drawlistoffscreen,a2
	addq.l	#2,a1
	move.w	screenx,d0
	move.w	screeny,d1
	move.w	d0,d4
	move.w	d1,d5
	sub.w	#16,d0
	sub.w	#16,d1
	add.w	#320,d4
	add.w	#200,d5
	move.w	(a0)+,d7	;number of em
	moveq	#-1,d6
	move.w	#0,numsave
sortloop1:
	move.l	(a0)+,a6
	cmpi.w	#-1,cactive(a6)
	beq.s	noton
	cmpi.w	#-2,cactive(a6)
	beq.s	inanyway
	move.w	cspritex(a6),d2
	move.w	cspritey(a6),d3
	cmp.w	d0,d2
	blt.s	noton1
	cmp.w	d1,d3
	blt.s	noton1
	cmp.w	d4,d2
	bgt.s	noton1
	cmp.w	d5,d3
	bgt.s	noton1
inanyway:
	move.l	a6,(a1)+	;its in the onscreen list
	addq.w	#1,d6
	dbf	d7,sortloop1
	bra.s	sortys
noton:
	dbf	d7,sortloop1
	bra.s	sortys
noton1:
	move.l	a6,(a2)+	;list of offscreen but active
	addq.w	#1,numsave	;and number
	dbf	d7,sortloop1
sortys:
	lea	drawlistonscreen,a0
	move.w	d6,(a0)+
	move.l	a0,a1		;copy list
	tst.w	d6
	ble	noneactive
	subq.w	#1,d6
onloop1:
	move.w	d6,d7		;copy count
	move.l	a0,a1		;copy list
	moveq	#0,d0
onloop2:
	move.l	(a1),a2
	move.l	4(a1),a3
	move.w	cspritey(a2),d1	;this y
	cmp.w	cspritey(a3),d1
	bgt.s	swapem
	addq.l	#4,a1
	dbf	d7,onloop2
	tst.w	d0
	bne.s	onloop1
noneactive:
	move.w	numsave,d7
	beq	reallynone
	add.w	d7,-2(a0)
	subq.w	#1,d7
	lea	drawlistoffscreen,a0
	addq.l	#4,a1
offloop:
	move.l	(a0)+,(a1)+
	dbf	d7,offloop
reallynone:
	rts
swapem:
	move.l	a3,(a1)+
	move.l	a2,(a1)
	moveq	#1,d0		;flag that I swapped somethin'
	dbf	d7,onloop2
	bra.s	onloop1



numsave:	dc.w	-1
dl1:
drawlistoffscreen:
	blk.w	20,0
dl:
drawlistonscreen:
	dc.w	-1
	blk.l	20,0

drawlist:
	dc.w	14
	dc.l	mesp,meshot1,meshot2,meshot3,meshot4
	dc.l	enemysp0,enemyshot00,enemyshot01,enemyshot02,enemyshot03
	dc.l	enemysp1,enemyshot10,enemyshot11,enemyshot12,enemyshot13
*	dc.l	testsp6,testsp7,testsp8,testsp9
*	dc.l	testsp9,testsp8,testsp7,testsp6,testsp5,testsp4
*	dc.l	testsp3,testsp2,testsp1,testsp0
drawlist2:
	blk.l	20,0
testbuffer0:
	dc.w	-1	;putlast
	dc.l	0	;add of screen
	blk.w	2*4*16,0
testbuffer1:
	dc.w	-1	;putlast
	dc.l	0	;add of screen
	blk.w	2*4*4,0
testbuffer2:
	dc.w	-1	;putlast
	dc.l	0	;add of screen
	blk.w	2*4*4,0
testbuffer3:
	dc.w	-1	;putlast
	dc.l	0	;add of screen
	blk.w	2*4*4,0
testbuffer4:
	dc.w	-1	;putlast
	dc.l	0	;add of screen
	blk.w	2*4*4,0
enemysp0buffer:
	dc.w	-1	;putlast
	dc.l	0	;add of screen
	blk.w	2*4*16,0
enemyshot00buffer:
	dc.w	-1	;putlast
	dc.l	0	;add of screen
	blk.w	2*4*4,0
enemyshot01buffer:
	dc.w	-1	;putlast
	dc.l	0	;add of screen
	blk.w	2*4*4,0
enemyshot02buffer:
	dc.w	-1	;putlast
	dc.l	0	;add of screen
	blk.w	2*4*4,0
enemyshot03buffer:
	dc.w	-1	;putlast
	dc.l	0	;add of screen
	blk.w	2*4*4,0
enemysp1buffer:
	dc.w	-1	;putlast
	dc.l	0	;add of screen
	blk.w	2*4*16,0
enemyshot10buffer:
	dc.w	-1	;putlast
	dc.l	0	;add of screen
	blk.w	2*4*4,0
enemyshot11buffer:
	dc.w	-1	;putlast
	dc.l	0	;add of screen
	blk.w	2*4*4,0
enemyshot12buffer:
	dc.w	-1	;putlast
	dc.l	0	;add of screen
	blk.w	2*4*4,0
enemyshot13buffer:
	dc.w	-1	;putlast
	dc.l	0	;add of screen
	blk.w	2*4*4,0

***********************************
putback:
	move.l	cspritebuffer(a0),a1
	move.w	#-1,(a1)+
	move.l	(a1)+,a2	;address of screen
	move.w	cspriteheight(a0),d0	;height
	move.l	#$ff8a00,a3
waitblitpb:
	btst	#7,$ff8a3c
	bne.s	oldmethodpb
	move.l	a2,dst_addr(a3)	;set dest address
	move.l	a1,src_addr(a3)	;*
	move.w	d0,y_count(a3)
	move.b	#%11000000,$ff8a3c
	move.w	#-1,cactive(a0)
	rts
oldmethodpb:
	subq.w	#1,d0
alllastpb:
	move.l	(a1)+,(a2)+
	move.l	(a1)+,(a2)+
	move.l	(a1)+,(a2)+
	move.l	(a1)+,(a2)+
	lea	624(a2),a2
	dbf	d0,alllastpb
	move.w	#-1,cactive(a0)
	rts

restoreclipped:
	move.l	cspritebuffer(a0),a1
	tst.w	putlast(a1)
	bmi	nolast
	addq.l	#2,a1		;skip put last
	move.l	(a1)+,a2	;address of screen
	move.w	cspriteheight(a0),d0	;height
	move.l	#$ff8a00,a3
waitblit:
	btst	#7,$ff8a3c
	bne.s	oldmethod
	move.l	a2,dst_addr(a3)	;set dest address
	move.l	a1,src_addr(a3)	;*
	move.w	d0,y_count(a3)
	move.b	#%11000000,$ff8a3c
	rts
oldmethod:
	subq.w	#1,d0
alllast:
	move.l	(a1)+,(a2)+
	move.l	(a1)+,(a2)+
	move.l	(a1)+,(a2)+
	move.l	(a1)+,(a2)+
	lea	624(a2),a2
	dbf	d0,alllast
nolast:
	rts
*****************************************
*	precalc all add stuff		*
*****************************************
preparesprite:
*	tst.w	cactive(a0)
*	bmi	noprepare
	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
	lea	scr,a6
	mulu	#640,d1
	add.l	d1,a6			;=*160 gives line add
	and.w	#$fff0,d0		;word
	lsr.w	#1,d0
	add.w	d0,a6			;a6 has actual screen address
	move.l	a6,cquickaddress(a0)	;for actual put

	cmpi.w	#4,cspriteheight(a0)
	bne.s	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
	bra.s	extrastuff
spcl4:
	cmpi.w	#8,cspriteheight(a0)
	bne.s	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
	bra.s	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
extrastuff:
	move.l	a1,cquickspaddress(a0)
noprepare:
	rts
saveclipped:
	move.l	cspritebuffer(a0),a3	;new bit
	move.w	#1,(a3)+
	move.l	cquickaddress(a0),a1
	move.w	cspriteheight(a0),d0
	move.l	a1,(a3)+	;for restore
	move.l	#$ff8a00,a4
	btst	#7,$ff8a3c
	bne.s	oldmethod2
	move.l	a3,dst_addr(a4)	;set dest address
	move.l	a1,src_addr(a4)	;*
	move.w	d0,y_count(a4)
	move.b	#%11000000,$ff8a3c
	rts
oldmethod2:
	subq.w	#1,d0
scl:
	move.l	(a1)+,(a3)+
	move.l	(a1)+,(a3)+
	move.l	(a1)+,(a3)+
	move.l	(a1)+,(a3)+
	lea	624(a1),a1
	dbf	d0,scl
	rts
*********************************
drawclipped:
	move.l	cspritebuffer(a0),a3
	addq.l	#2,a3
	move.l	cquickaddress(a0),a2
	move.l	cquickspaddress(a0),a1
	move.w	cspriteheight(a0),d4
doallsprite:
	subq.w	#1,d4
	move.l	a2,(a3)+	;for restore
doallloop:
*	move.w	(a2),d0 	;get 4 screen words
*	move.w	2(a2),d1
*	move.w	4(a2),d2
*	move.w	6(a2),d3
	movem.w	(a2),d0-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,(a2)+	;put the picture in th picture
	move.w	d1,(a2)+
	move.w	d2,(a2)+
	move.w	d3,(a2)+
*	move.w	(a2),d0 	;get 4 screen words
*	move.w	2(a2),d1
*	move.w	4(a2),d2
*	move.w	6(a2),d3
	movem.w	(a2),d0-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,(a2)+	;put the picture in th picture
	move.w	d1,(a2)+
	move.w	d2,(a2)+
	move.w	d3,(a2)+
	lea	624(a2),a2
	dbf	d4,doallloop
	rts

****************************************
mesp:
	dc.w	50,50		;x,y
	dc.l	mesprites	;address of bank of 16 prerotated sprites
	dc.w	16		;height
	dc.w	16		;width
	dc.w	-1		;cactive
	dc.l	testbuffer0
	dc.l	0		;quickaddress
	dc.l	0		;quickspaddress
meshot1:
	dc.w	50,50		;x,y
	dc.l	shotsprites	;address of bank of 16 prerotated sprites
	dc.w	4		;height
	dc.w	4		;width
	dc.w	-1		;cactive
	dc.l	testbuffer1
	dc.l	0		;quickaddress
	dc.l	0		;quickspaddress
	dc.w	0,0		;x y vel 
	dc.w	0		;life
meshot2:
	dc.w	50,50		;x,y
	dc.l	shotsprites	;address of bank of 16 prerotated sprites
	dc.w	4		;height
	dc.w	4		;width
	dc.w	-1		;cactive
	dc.l	testbuffer2
	dc.l	0		;quickaddress
	dc.l	0		;quickspaddress
	dc.w	0,0
	dc.w	0	
meshot3:
	dc.w	50,50		;x,y
	dc.l	shotsprites	;address of bank of 16 prerotated sprites
	dc.w	4		;height
	dc.w	4		;width
	dc.w	-1		;cactive
	dc.l	testbuffer3
	dc.l	0		;quickaddress
	dc.l	0		;quickspaddress
	dc.w	0,0
	dc.w	0	
meshot4:
	dc.w	50,50		;x,y
	dc.l	shotsprites	;address of bank of 16 prerotated sprites
	dc.w	4		;height
	dc.w	4		;width
	dc.w	-1		;cactive
	dc.l	testbuffer4
	dc.l	0		;quickaddress
	dc.l	0		;quickspaddress
	dc.w	0,0
	dc.w	0	
enemysp0:
	dc.w	50,50		;x,y
	dc.l	enemysprites	;address of bank of 16 prerotated sprites
	dc.w	16		;height
	dc.w	16		;width
	dc.w	-1		;cactive
	dc.l	enemysp0buffer
	dc.l	0		;quickaddress
	dc.l	0		;quickspaddress
	dc.w	0,0,0,0		;xvel,yvel,x2,y2,
	dc.l	0		;mylocation
	dc.l	0		;headingto
	dc.w	-1		;going
	dc.l	0		;listad
	dc.w	0		;cspritefollow
	dc.w	0,0		;fight hits
	dc.w	-1,-1		;tankspine,tankplane
	dc.l	0,enemytanksprites,0		;ti,ts,ta
	dc.l	en0shotlist
	dc.b	0,0,0,0		;whichme,whichmest,whichmeh
	dc.w	2		;cspritevels
	dc.w	0		;shotdel
	dc.w	0		;cspriteexploding
	dc.w	0		;rotate
en0shotlist:
	dc.l	enemyshot00,enemyshot01,enemyshot02,enemyshot03
enemyshot00:
	dc.w	50,50		;x,y
	dc.l	shotsprites+1280;address of bank of 16 prerotated sprites
	dc.w	4		;height
	dc.w	4		;width
	dc.w	-1		;cactive
	dc.l	enemyshot00buffer
	dc.l	0		;quickaddress
	dc.l	0		;quickspaddress
	dc.w	0,0,0
enemyshot01:
	dc.w	50,50		;x,y
	dc.l	shotsprites+1280;address of bank of 16 prerotated sprites
	dc.w	4		;height
	dc.w	4		;width
	dc.w	-1		;cactive
	dc.l	enemyshot01buffer
	dc.l	0		;quickaddress
	dc.l	0		;quickspaddress
	dc.w	0,0,0
enemyshot02:
	dc.w	50,50		;x,y
	dc.l	shotsprites+1280;address of bank of 16 prerotated sprites
	dc.w	4		;height
	dc.w	4		;width
	dc.w	-1		;cactive
	dc.l	enemyshot02buffer
	dc.l	0		;quickaddress
	dc.l	0		;quickspaddress
	dc.w	0,0,0
enemyshot03:
	dc.w	50,50		;x,y
	dc.l	shotsprites+1280;address of bank of 16 prerotated sprites
	dc.w	4		;height
	dc.w	4		;width
	dc.w	-1		;cactive
	dc.l	enemyshot03buffer
	dc.l	0		;quickaddress
	dc.l	0		;quickspaddress
	dc.w	0,0,0
enemysp1:
	dc.w	50,50		;x,y
	dc.l	enemysprites	;address of bank of 16 prerotated sprites
	dc.w	16		;height
	dc.w	16		;width
	dc.w	-1		;cactive
	dc.l	enemysp1buffer
	dc.l	0		;quickaddress
	dc.l	0		;quickspaddress
	dc.w	0,0,0,0		;xvel,yvel,x2,y2,
	dc.l	0		;mylocation
	dc.l	0		;headingto
	dc.w	-1		;going
	dc.l	0		;listad
	dc.w	0		;cspritefollow
	dc.w	0,0		;fight hits
	dc.w	-1,-1		;tankspine,tankplane
	dc.l	0,enemytanksprites,0		;ti,ts,ta
	dc.l	en1shotlist
	dc.b	0,0,0,0		;whichme,whichmest,whichmeh
	dc.w	2
	dc.w	0		;shotdel
	dc.w	0		;cspriteexploding
	dc.w	0
even
en1shotlist:
	dc.l	enemyshot10,enemyshot11,enemyshot12,enemyshot13

enemyshot10:
	dc.w	50,50		;x,y
	dc.l	shotsprites+1280;address of bank of 16 prerotated sprites
	dc.w	4		;height
	dc.w	4		;width
	dc.w	-1		;cactive
	dc.l	enemyshot10buffer
	dc.l	0		;quickaddress
	dc.l	0		;quickspaddress
	dc.w	0,0,0
enemyshot11:
	dc.w	50,50		;x,y
	dc.l	shotsprites+1280;address of bank of 16 prerotated sprites
	dc.w	4		;height
	dc.w	4		;width
	dc.w	-1		;cactive
	dc.l	enemyshot11buffer
	dc.l	0		;quickaddress
	dc.l	0		;quickspaddress
	dc.w	0,0,0
enemyshot12:
	dc.w	50,50		;x,y
	dc.l	shotsprites+1280;address of bank of 16 prerotated sprites
	dc.w	4		;height
	dc.w	4		;width
	dc.w	-1		;cactive
	dc.l	enemyshot12buffer
	dc.l	0		;quickaddress
	dc.l	0		;quickspaddress
	dc.w	0,0,0
enemyshot13:
	dc.w	50,50		;x,y
	dc.l	shotsprites+1280;address of bank of 16 prerotated sprites
	dc.w	4		;height
	dc.w	4		;width
	dc.w	-1		;cactive
	dc.l	enemyshot13buffer
	dc.l	0		;quickaddress
	dc.l	0		;quickspaddress
	dc.w	0,0,0
***************************************
makemap:
	lea	$ff8900,a0	;sound register base address
	move.w	#%0000000000000000,sounddma(a0)		;stop sound
*	bsr	resetsound
	lea	blocks,a2
	move.l	seen,a1
	lea	gamemap,a0
	moveq	#49,d0		;down
mml:
	moveq	#79,d1		;across
	move.l	a1,a6
mml2:
	moveq	#0,d2
	move.b	(a0)+,d2
	asl.w	#7,d2		;*128
	move.l	a2,a3	;block ad
	add.w	d2,a3
	bsr	putblock
	add.l	#8,a6
	dbf	d1,mml2
	add.l	#640*16,a1
	dbf	d0,mml
	rts

putblock:
	move.l	a6,a4		;copy screen ad
*	move.l	#-1,(a4)+
*	rts

	move.l	(a3)+,(a4)+
	move.l	(a3)+,(a4)+
	lea	640-8(a4),a4
	move.l	(a3)+,(a4)+
	move.l	(a3)+,(a4)+
	lea	640-8(a4),a4
	move.l	(a3)+,(a4)+
	move.l	(a3)+,(a4)+
	lea	640-8(a4),a4
	move.l	(a3)+,(a4)+
	move.l	(a3)+,(a4)+
	lea	640-8(a4),a4
	move.l	(a3)+,(a4)+
	move.l	(a3)+,(a4)+
	lea	640-8(a4),a4
	move.l	(a3)+,(a4)+
	move.l	(a3)+,(a4)+
	lea	640-8(a4),a4
	move.l	(a3)+,(a4)+
	move.l	(a3)+,(a4)+
	lea	640-8(a4),a4
	move.l	(a3)+,(a4)+
	move.l	(a3)+,(a4)+
	lea	640-8(a4),a4
	move.l	(a3)+,(a4)+
	move.l	(a3)+,(a4)+
	lea	640-8(a4),a4
	move.l	(a3)+,(a4)+
	move.l	(a3)+,(a4)+
	lea	640-8(a4),a4
	move.l	(a3)+,(a4)+
	move.l	(a3)+,(a4)+
	lea	640-8(a4),a4
	move.l	(a3)+,(a4)+
	move.l	(a3)+,(a4)+
	lea	640-8(a4),a4
	move.l	(a3)+,(a4)+
	move.l	(a3)+,(a4)+
	lea	640-8(a4),a4
	move.l	(a3)+,(a4)+
	move.l	(a3)+,(a4)+
	lea	640-8(a4),a4
	move.l	(a3)+,(a4)+
	move.l	(a3)+,(a4)+
	lea	640-8(a4),a4
	move.l	(a3)+,(a4)+
	move.l	(a3)+,(a4)+
	lea	640-8(a4),a4
	rts


***************************************
dosmallmap:
	lea	gamemap,a6
	moveq	#29,d4		;y
	moveq	#49,d0		;down
mmls:
	moveq	#79,d1		;across
	move.w	d1,d3		;x
*	move.l	a1,a6
mml2s:
	moveq	#0,d2
	move.b	(a6)+,d2
	bsr	putminiblock
	addq.w	#2,d3		;advance x
	dbf	d1,mml2s
	addq.w	#2,d4		;advance y
	dbf	d0,mmls
	rts

putminiblock:
	cmpi.b	#16,d2
	bge.s	wallblock
	lea	floorsp,a0
	move.w	d3,(a0)
	move.w	d4,2(a0)
	bsr	putsprite
	rts
wallblock:
	lea	wallsp,a0
	move.w	d3,(a0)
	move.w	d4,2(a0)
	bsr	putsprite
	rts

*********************************************************
*	New sprite routine				*
*	New version give ad of sprite structure in A0	*
*********************************************************
putsprite:
	movem.l	d0-d7/a0-a6,-(sp)
	move.w	(a0),d2
	move.w	d2,d0
	move.w	2(a0),d1
	and.w	#15,d2
	move.l	screen,a6
	lsl.w	#5,d1
	add.w	d1,a6
	lsl.w	#2,d1
	add.w	d1,a6
	and.w	#$fff0,d0
	lsr.w	#1,d0
	add.w	d0,a6
	move.l	a6,a2
*************CODE TO ROTATE A SPRITE IMAGE***********************
shiftimages:
	move.w	4(a0),d1
	move.l	8(a0),a1
	lea	gtemp,a2
ssi1:
	move.w	6(a0),d0
	clr.l	(a2)
	clr.l	4(a2)
ssi0:	
	moveq	#0,d4
	moveq	#0,d5
	moveq	#0,d6
	moveq	#0,d7
	move.w	(a1)+,d4
	move.w	(a1)+,d5
	move.w	(a1)+,d6
	move.w	(a1)+,d7
	ror.l	d2,d4
	ror.l	d2,d5
	ror.l	d2,d6
	ror.l	d2,d7
	or.w	d4,(a2)+
	or.w	d5,(a2)+
	or.w	d6,(a2)+
	or.w	d7,(a2)+
	swap	d4
	swap	d5
	swap	d6
	swap	d7
	move.w	d4,(a2)
	move.w	d5,2(a2)
	move.w	d6,4(a2)
	move.w	d7,6(a2)
	dbf	d0,ssi0
	addq.l	#8,a2
	dbf	d1,ssi1
	tst.w	12(a0)
	bmi	specsprite
smake_mask:
	move.w	4(a0),d1
	lea	gtemp,a1
	lea	gmask,a2
smm1:
	move.w	6(a0),d0
	addq.w	#1,d0
smm0:	move.w	(a1)+,d2
	or.w	(a1)+,d2
	or.w	(a1)+,d2
	or.w	(a1)+,d2
	move.w	d2,d3
	swap	d2
	move.w	d3,d2
	eor.l	#-1,d2
	move.l	d2,(a2)+
	dbf	d0,smm0
	dbf	d1,smm1

*********code to put sprite on screen********************
sdraw:
	move.w	4(a0),d1
	lea	gtemp,a1
	lea	gmask,a2
	move.l	a6,a3
sdi1:	move.w	6(a0),d0
	addq.w	#1,d0
	move.l	a6,a5
sdi0:	move.l	(a2)+,d3
*	move.l	(a1)+,d6
*	move.l	(a1)+,d7
	movem.l	(a1)+,d6-d7
*	move.l	(a3)+,d4
*	move.l	(a3)+,d5
	movem.l	(a3)+,d4-d5
	and.l	d3,d4
	and.l	d3,d5
	or.l	d6,d4
	or.l	d7,d5
	move.l	d4,(a5)+
	move.l	d5,(a5)+
	dbf	d0,sdi0
	lea	160(a6),a6
	move.l	a6,a3
	dbf	d1,sdi1
	movem.l	(sp)+,d0-d7/a0-a6
	rts

*********code to put sprite on screen********************
specsprite:
	move.w	4(a0),d1
	lea	gtemp,a1
sdi1s:
	move.w	6(a0),d0
	addq.w	#1,d0
	move.l	a6,a5
sdi0s:
*	move.l	(a1)+,d6
*	move.l	(a1)+,d7
	movem.l	(a1)+,d6-d7
	eor.l	d6,(a5)+
	eor.l	d7,(a5)+
	dbf	d0,sdi0s
	lea	160(a6),a6
	dbf	d1,sdi1s
	movem.l	(sp)+,d0-d7/a0-a6
	rts

wallsp:
	dc.w	0,0
	dc.w	1,0
	dc.l	walldat
	dc.w	1
walldat:
	dc.w	$c000,$c000,0,0
	dc.w	$c000,$c000,0,0

floorsp:
	dc.w	0,0
	dc.w	1,0
	dc.l	floordat
	dc.w	1
floordat:
	dc.w	$c000,0,0,0
	dc.w	$c000,0,0,0
memapsp:
	dc.w	-1,0
	dc.w	1,0
	dc.l	medat
	dc.w	-1
medat:
	dc.w	$0,$c000,0,$c000
	dc.w	$0,$c000,0,$c000

barclearsp:
	dc.w	0,3
	dc.w	3,0
	dc.l	bcdat
	dc.w	1
bcdat:
	dc.w	$0,$8000,$8000,0
	dc.w	$0,$8000,$8000,0
	dc.w	$0,$8000,$8000,0
	dc.w	$0,$8000,$8000,0

barclearsp2:
	dc.w	0,3
	dc.w	3,0
	dc.l	bcdat2
	dc.w	1
bcdat2:
	dc.w	$0,$f000,$f000,0
	dc.w	$0,$f000,$f000,0
	dc.w	$0,$f000,$f000,0
	dc.w	$0,$f000,$f000,0
enmapsp0:
	dc.w	-1,0
	dc.w	1,0
	dc.l	endat
	dc.w	-1
enmapsp1:
	dc.w	-1,0
	dc.w	1,0
	dc.l	endat
	dc.w	-1
endat:
	dc.w	$0,0,$c000,$c000
	dc.w	$0,0,$c000,$c000

mewepsp:
	dc.w	-1,0
	dc.w	1,0
	dc.l	mewdat1
	dc.w	-1
mewdat1:
	dc.w	$0000,$8000,$0000,$8000
	dc.w	$0000,$4000,$0000,$4000
enwepsp:
	dc.w	-1,0
	dc.w	1,0
	dc.l	enwdat1
	dc.w	-1
enwdat1:
	dc.w	$0000,$0000,$8000,$8000
	dc.w	$0000,$0000,$4000,$4000

bar1sp:
	dc.w	32,3
	dc.w	3,3
	dc.l	shotsbar
	dc.w	1		;eor or proper
bar2sp:
	dc.w	144,3
	dc.w	3,2
	dc.l	damagebar
	dc.w	1		;eor or proper
minesp:
	dc.w	144,2
	dc.w	5,0
	dc.l	mineimg
	dc.w	-1		;eor or proper
tanksp:
	dc.w	144,3
	dc.w	4,0
	dc.l	tankimg
	dc.w	1		;eor or proper

***************************************
oldmouse:	blk.l	1,0
*************puts my mouse interupt in***************** 
putrout:move.w  #34,-(sp)
        trap    #14
        addq.l  #2,sp
        move.l  d0,a0
	move.l	16(a0),oldmouse
        move.l  #myrout,16(a0)
        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
	add.w	d0,mx
	add.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    .S extra1
        move.w	#mminx,d0
        bra    .S extra2
extra1: cmpi.w   #mmaxx,d0
        ble    .S extra2
        move.w  #mmaxx,d0
extra2:	cmpi.w  #mminy,d1
        bge    .S extra3
        move.w  #mminy,d1
        bra	extra4
extra3: cmpi.w   #mmaxy,d1
        ble    .S extra4
        move.w  #mmaxy,d1
extra4:
        rts

buttondat:	dc.w	0
mx:		dc.w	0
my:		dc.w	189

mminx:	equ	0	;13
mmaxx:	equ	960
mminy:	equ	1	;3
mmaxy:	equ	189	; 13 123
******************************************
keymidi:
	move.w	#$ff,-(sp)
	move.w	#6,-(sp)
	trap	#1
	addq.l	#4,sp
	tst.l	d0
	beq	anydata
	swap	d0
midistart:
	cmpi.w	#$39,d0
	bne	singlegame		;become master

	bsr	cleartext
	lea	mgs,a0
	bsr	gemprint	;print 'midi game selected
	lea	mastertext,a0	;this machine becomes boss'
	bsr	gemprint

	move.w	#master,sorm
	move.l	#masterstring,-(sp)	;send master message
	move.w	#0,-(sp)
	move.w	#12,-(sp)
	trap	#14
	addq.l	#8,sp		;now wait for responses
waitresp:
	move.w	#midiport,-(sp)
	move.w	#2,-(sp)
	trap	#13
	addq.l	#4,sp		;get and discard midi dat
	rts

singlegame:
	move.w	#single,sorm
	rts

anydata:
	move.w	#3,-(sp)	;midi device
	move.w	#1,-(sp)
	trap	#13		;is there a char waiting
	addq.l	#4,sp
	tst.w	d0
	beq	keymidi
	move.w	#midiport,-(sp)
	move.w	#2,-(sp)
	trap	#13
	addq.l	#4,sp
	cmpi.b	#master,d0	;has a machine become master
	bne	keymidi

	bsr	cleartext
	lea	mgs,a0
	bsr	gemprint
	lea	slavetext,a0
	bsr	gemprint
	lea	slavetext2,a0
	bsr	gemprint

	move.l	#slavestring,-(sp)	;send slave message
	move.w	#0,-(sp)
	move.w	#12,-(sp)
	trap	#14
	addq.l	#8,sp
	move.w	#slave,sorm
	rts

slavestring:
	dc.b	slave
masterstring:
	dc.b	master
mgs:
	DC.B	106,34,'MIDI GAME SELECTED',0
mastertext:
	DC.B	85,40,'THIS MACHINE BECOMES BOSS',0
mastertext2:
	DC.B	112,46,'ANY KEY TO START',0
slavetext:
	dc.b	82,40,'THIS MACHINE BECOMES SLAVE',0
slavetext2:
	DC.B	85,46,'WAITING FOR BOSS TO BEGIN',0
even
*****************************************
clearallsprites:
	lea	enemylist,a0
	bsr	doclear
	lea	enshotlist,a0
	bsr	doclear
	lea	myshotlist,a0
	bsr	doclear
	lea	mesp,a0
	move.w	#-1,cactive(a0)
	move.l	cspritebuffer(a0),a0
	move.w	#-1,putlast(a0)
	move.w	#-1,memapsp
	move.w	#-1,enmapsp0
	move.w	#-1,enmapsp1
	lea	enmine1,a0
	move.w	#-1,mineact(a0)
	lea	enmine2,a0
	move.w	#-1,mineact(a0)
	lea	enmine3,a0
	move.w	#-1,mineact(a0)
	lea	enmine4,a0
	move.w	#-1,mineact(a0)
	lea	mymine1,a0
	move.w	#-1,mineact(a0)
	lea	mymine2,a0
	move.w	#-1,mineact(a0)
	lea	mymine3,a0
	move.w	#-1,mineact(a0)
	lea	mymine4,a0
	move.w	#-1,mineact(a0)
	lea	enwep,a0
	move.w	#-1,mineact(a0)
	lea	mywep,a0
	move.w	#-1,mineact(a0)
	move.b	#-1,wepdrop
	move.b	#-1,minedrop
	rts

doclear:
	move.l	(a0)+,d0
	bmi	dcback
	move.l	d0,a1
	move.w	#-1,cactive(a1)
	move.l	cspritebuffer(a1),a1
	move.w	#-1,putlast(a1)
	bra.s	doclear
dcback:
	rts

****************************************
keyboard:
        move.w  #$ff,-(sp)
        move.w  #6,-(sp)
        trap    #1
        addq.l  #4,sp
        tst.l   d0
        beq     keyback
        swap    d0
quit:   cmpi.w  #$10,d0
        bne     spacep
        bra     gem
spacep:
	cmpi.w	#$39,d0
	bne	dropmine
	tst.w	tankspin
	bpl	alrs
setspin:
	neg.w	tankplane
	move.w	#5*8,tankspin
	move.b	whichme,whichmestart
	cmpi.b	#7,whichme
	ble.s	whm2
	move.b	#7,whichmehigh
	bra.s	whm3
whm2:
	move.b	#15,whichmehigh
whm3:
	lea	mesp,a0
	move.l	cspritead(a0),tankimage
	move.l	tankimage,d0
	sub.l	tankstart,d0
	move.l	d0,tankadd
	lea	myshotlist,a0
	moveq	#3,d0
loopsc:
	move.l	(a0)+,a1
	tst.w	cactive(a1)
	bmi.s	loopsc2
	move.w	#-2,cactive(a1)
loopsc2:
	dbf	d0,loopsc
alrs:
	rts
dropmine:
	cmpi.w	#$32,d0
	bne.s	pkey
	lea	mesp,a0
	lea	mymine1,a1
	cmpi.w	#-1,mineact(a1)
	beq.s	dodrop
	lea	mymine2,a1
	cmpi.w	#-1,mineact(a1)
	beq.s	dodrop
	lea	mymine3,a1
	cmpi.w	#-1,mineact(a1)
	beq.s	dodrop
	lea	mymine4,a1
	cmpi.w	#-1,mineact(a1)
	beq.s	dodrop
	rts
pkey:
	cmpi.w	#$19,d0
	bne.s	keyback
	bra	paused

keyback:
	rts

paused:
	lea	cheatlist,a6
paused1:
	move.w  #7,-(sp)
	trap    #1
	addq.l  #2,sp
	cmpi.b	#80,d0		;P
	beq.s	pauseover
	cmp.b	#112,d0		;p
	beq.s	pauseover
	move.b	(a6)+,d7
	bmi.s	paused2
	addq.b	#1,d7
	cmp.b	d0,d7
	bne.s	paused
	bra	paused1
paused2:
	neg.w	cheatmode
pauseover:
	rts

cheatlist:
	dc.b	'h'-1,'o'-1,'n'-1,'e'-1,'y'-1,'b'-1,'u'-1,'n'-1,-1
even
dodrop:
	move.l	seen,a6
	moveq	#0,d0		;zero result register
	moveq	#0,d1
	move.w	cspritex(a0),d0
	move.w	cspritey(a0),d1
	addq.w	#8,d0
	addq.w	#8,d1
	move.l	d0,d2
	and.w	#$fff0,d1
	move.l	d1,d3
	mulu	#640,d3
	adda.l	d3,a6		;add to screen base address
	asr.w	#1,d2		;divide it by 2
	and.w	#$fff8,d2	;turn off lower 3 bits
	adda.w	d2,a6		;add to screen address register
	move.l	a6,minead(a1)
	and.w	#$fff0,d0
	move.w	d0,minex2(a1)
	move.w	d1,miney2(a1)
	asr.w	#4,d0
	asr.w	#4,d1
	bsr	checkblock
	move.w	#1500,minelife(a1)
	move.w	d0,minex(a1)
	move.w	d1,miney(a1)
	mulu	#80,d1
	add.w	d0,d1
	lea	gamemap,a2
	lea	blocks,a3
	moveq	#0,d0
	move.b	(a2,d1.w),d0
	asl.w	#7,d0
	add.w	d0,a3
	move.l	a3,minerestore(a1)
	move.w	#1,mineact(a1)
	lea	minesp,a0
	move.w	mines,d0
	lea	minexylist,a1
	asl.w	#1,d0
	move.w	(a1,d0.w),(a0)
	bsr	putsprite
	subq.w	#1,mines
	move.b	#1,minedrop
	rts

checkblock:
	lea	mymine1,a0
	bsr	cb
	lea	mymine2,a0
	bsr	cb
	lea	mymine3,a0
	bsr	cb
	lea	mymine4,a0
	bsr	cb

	lea	enmine1,a0
	bsr	cb
	lea	enmine2,a0
	bsr	cb
	lea	enmine3,a0
	bsr	cb
	lea	enmine4,a0
	bsr	cb
	lea	enwep,a0
	bsr	cb
	lea	mywep,a0
	bsr	cb
	rts
cb:
	cmpi.w	#-1,mineact(a0)
	beq.s	noblockmatch
	cmp.w	minex(a0),d0
	bne.s	noblockmatch
	cmp.w	miney(a0),d1
	bne.s	noblockmatch
	addq.l	#8,sp		;remove 2 ret ad
noblockmatch:
	rts


doenemymine:
	lea	enemysp0,a0
doenemymine2:
	lea	enmine1,a1
	cmpi.w	#-1,mineact(a1)
	beq.s	dodrope
	lea	enmine2,a1
	cmpi.w	#-1,mineact(a1)
	beq.s	dodrope
	lea	enmine3,a1
	cmpi.w	#-1,mineact(a1)
	beq.s	dodrope
	lea	enmine4,a1
	cmpi.w	#-1,mineact(a1)
	beq.s	dodrope
	rts
dodrope:
	move.w	#1500,minelife(a1)
	move.l	seen,a6
	moveq	#0,d0		;zero result register
	moveq	#0,d1
	move.w	cspritex(a0),d0
	move.w	cspritey(a0),d1
	addq.w	#8,d0
	addq.w	#8,d1
	move.l	d0,d2
	and.w	#$fff0,d1
	move.l	d1,d3
	mulu	#640,d3
	adda.l	d3,a6		;add to screen base address
	asr.w	#1,d2		;divide it by 2
	and.w	#$fff8,d2	;turn off lower 3 bits
	adda.w	d2,a6		;add to screen address register
	move.l	a6,minead(a1)
	and.w	#$fff0,d0
	move.w	d0,minex2(a1)
	move.w	d1,miney2(a1)
	asr.w	#4,d0
	asr.w	#4,d1
	bsr	checkblock
	move.w	d0,minex(a1)
	move.w	d1,miney(a1)
	mulu	#80,d1
	add.w	d0,d1
	lea	gamemap,a2
	lea	blocks,a3
	moveq	#0,d0
	move.b	(a2,d1.w),d0
	asl.w	#7,d0
	add.w	d0,a3
	move.l	a3,minerestore(a1)
	move.w	#1,mineact(a1)
	rts


doenemyspin:
	tst.w	cactive(a0)
	bmi	alrse
	tst.w	tankspine(a0)
	bpl.L	alrse
	move.l	cspritelistad(a0),a1
	move.l	cspritelocation(a0),a2
	move.b	1(a1),d0
	sub.b	1(a2),d0
	move.b	2(a1),d1
	sub.b	2(a2),d1
	move.b	3(a1),d2
	sub.b	3(a2),d2
	tst.b	d0
	bpl.s	t1
	neg.b	d0
t1:
	tst.b	d1
	bpl.s	t2
	neg.b	d1
t2:
	tst.b	d2
	bpl.s	t3
	neg.b	d2
t3:
	add.b	d1,d0
	add.b	d2,d0		;d0 is number of moves away
	cmpi.b	#2,d0
	bgt.s	plok1
	tst.w	tankplanee(a0)
	bmi.s	alrse		;close and already tank
	move.w	#2,cspritevels(a0)
	bra.s	setspine
plok1:
	tst.w	tankplanee(a0)
	bpl.s	alrse		;far away and already plane
	move.w	#6,cspritevels(a0)
setspine:
	neg.w	tankplanee(a0)
	move.w	#5*8,tankspine(a0)
	move.b	whichmee(a0),whichmestarte(a0)
	cmpi.b	#7,whichmee(a0)
	ble.s	whm2e
	move.b	#7,whichmehighe(a0)
whm2e:
	move.b	#15,whichmehighe(a0)
whm3e:
*	lea	mesp,a0
	move.l	cspritead(a0),tankimagee(a0)
	move.l	tankimagee(a0),d0
	sub.l	tankstarte(a0),d0
	move.l	d0,tankadde(a0)
	move.l	enshotlistp(a0),a1
	moveq	#3,d0
loopsce:
	move.l	(a1)+,a2
	tst.w	cactive(a2)
	bmi.s	loopsc2e
	move.w	#-2,cactive(a2)
loopsc2e:
	dbf	d0,loopsce
alrse:
	rts


minex:		equ	0
miney:		equ	2
mineact:	equ	4
minead:		equ	6
minerestore:	equ	10
minelife:	equ	14
minex2:		equ	16
miney2:		equ	18
mines:		dc.w	3	;mines avail
minexylist:
	dc.w	224,232,240,248
tankxylist:
	dc.w	288,296,304
mymine1:
	dc.w	0,0		;x,y in block coords
	dc.w	-1		;mineact
	dc.l	0		;address to put
	dc.l	0		;minerestore
	dc.w	0		;minelife
	dc.w	0,0		;x,y,2
mymine2:
	dc.w	0,0		;x,y in block coords
	dc.w	-1		;mineact
	dc.l	0		;address to put
	dc.l	0		;minerestore
	dc.w	0		;minelife
	dc.w	0,0		;x,y,2
mymine3:
	dc.w	0,0		;x,y in block coords
	dc.w	-1		;mineact
	dc.l	0		;address to put
	dc.l	0		;minerestore
	dc.w	0		;minelife
	dc.w	0,0		;x,y,2
mymine4:
	dc.w	0,0		;x,y in block coords
	dc.w	-1		;mineact
	dc.l	0		;address to put
	dc.l	0		;minerestore
	dc.w	0		;minelife
	dc.w	0,0		;x,y,2

enmine1:
	dc.w	0,0		;x,y in block coords
	dc.w	-1		;mineact
	dc.l	0		;address to put
	dc.l	0		;minerestore
	dc.w	0		;minelife
	dc.w	0,0		;x,y,2
enmine2:
	dc.w	0,0		;x,y in block coords
	dc.w	-1		;mineact
	dc.l	0		;address to put
	dc.l	0		;minerestore
	dc.w	0		;minelife
	dc.w	0,0		;x,y,2
enmine3:
	dc.w	0,0		;x,y in block coords
	dc.w	-1		;mineact
	dc.l	0		;address to put
	dc.l	0		;minerestore
	dc.w	0		;minelife
	dc.w	0,0		;x,y,2
enmine4:
	dc.w	0,0		;x,y in block coords
	dc.w	-1		;mineact
	dc.l	0		;address to put
	dc.l	0		;minerestore
	dc.w	0		;minelife
	dc.w	0,0		;x,y,2

enwep:
	dc.w	0,0		;x,y in block coords
	dc.w	-1		;mineact
	dc.l	0		;address to put
	dc.l	0		;minerestore
	dc.w	0		;minelife
	dc.w	0,0		;x,y,2
mywep:
	dc.w	0,0		;x,y in block coords
	dc.w	-1		;mineact
	dc.l	0		;address to put
	dc.l	0		;minerestore
	dc.w	0		;minelife
	dc.w	0,0		;x,y,2

allactive:
	dc.w	-1
cldelay:	dc.w	-1
rcldelay:	dc.w	-0
wx:		dc.w	0
wy:		dc.w	0
wz:		dc.w	0
proz:		dc.w	0
spadd:		dc.w	0
***********************************
mydocolors:
	lea	bluepalette,a0
mydocolors3:
saver:
	move.l	#$ff8240,a1
	moveq	#15,d0
mdcloop2:
	move.w	(a0)+,(a1)+
	dbf	d0,mdcloop2
	rts
mydocolors2:
	lea	textpalette,a0
	bra.s	saver

************get screen address***************
getscrn:move.w  #2,-(sp)
        trap    #14
        addq.l  #2,sp
        move.l  d0,screen
	subi.l	#32000,d0
	move.l	d0,hiden
	move.l	#scr,seen
	rts
seen:	dc.l	0
hiden:	dc.l	0
screen:	dc.l	0


flip_scr:
        move.l  seen,A6
        move.l  hiden,seen
        move.l  A6,hiden
	move.b	seen+1,$ff8201
	move.b	seen+2,$ff8203
	move.w	#37,-(sp)
	trap	#14
	addq.l	#2,sp
	rts


dltvbl:
	movem.l	d0-d7/a0-a6,-(sp)
	tst.w	novbl
	bpl	donodlt
	move.l	screen,a0
	move.l	a0,vbltemp
	move.b	vbltemp+1,$ff8205
	move.b	vbltemp+2,$ff8207
	move.b	vbltemp+3,$ff8209
	bsr	dodlt
donodlt:
	movem.l	(sp)+,d0-d7/a0-a6
tgooldvbl:
	jmp	$0

dodlt:
	move.l	dltmemcount,a0
	move.l	screen,a1
	move.w	(a0)+,d0
	beq	dltover
	subq.w	#1,d0
dodltloop:
	move.w	(a0)+,d1
	move.l	(a0)+,d2
	eor.l	d2,(a1,d1.w)
	dbf	d0,dodltloop
	move.l	a0,dltmemcount
nodlt:
	rts

dltover:
	move.l	dltsave,dltmemcount
	bra	dodlt


dsave:	dc.w	0
framevbl:
	movem.l	d0-d7/a0-a6,-(sp)
	move.w	#-1,setflag
	move.w	#$0000,$ff8240
	move.b	#0,tbcr
	moveq	#0,d0
	move.w	my,d0
	move.b	d0,tbdr
	move.b	#8,tbcr
	tst.w	novbl
	bpl	diskhappenning
	move.w	#$0004,$ff8240+4
	move.w	screenx,d0
	move.w	d0,d1
	and.l	#$0f,d0
	move.b	d0,$ff8265	;hscroll
	tst.b	d0
	bne	nonzero
	move.b	#240,$ff820f	;linwide
	bra.s	join
nonzero:
	move.b	#236,$ff820f
join:
	move.l	seen,a0
	move.w	screeny,d0
	mulu	#160*4,d0
	adda.l	d0,a0
	asr.w	#1,d1
	and.w	#$fff8,d1
	adda.w	d1,a0
	move.l	a0,vbltemp
	move.b	vbltemp+1,$ff8205
	move.b	vbltemp+2,$ff8207
	move.b	vbltemp+3,$ff8209
here:
	tst.w	$43e
	bne.s	diskhappenning
	bsr	drawsprites
	move.l	colorwhere,a0
	move.w	(a0)+,$ff825e
	cmp.l	#colorend,a0
	ble.s	cvblok
	lea	colors,a0
cvblok:
	move.l	a0,colorwhere
diskhappenning:
	movem.l	(sp)+,d0-d7/a0-a6
gooldvbl:
	jmp	$0

colorwhere:	dc.l	colors
colors:
	dc.w	$0f00,$0611,$0522,$0433,$0344,$0255,$0166,$00ff
	dc.w	$0166,$0255,$0344,$0433,$0522
colorend:
	dc.w	$0611

drawsprites:			;first either restore or end restore
	move.l	#$ff8a00,a3
waitblitset1:
	btst	#7,$ff8a3c
	bne	waitblitset1
	move.w	#2,src_xinc(a3)		;set stuff not needed every
	move.w	#2,src_yinc(a3)		;time
	move.w	#2,dst_xinc(a3)
	move.w	#626,dst_yinc(a3)
	move.w	#8,x_count(a3)
	move.w	#-1,endmask1(a3)
	move.w	#-1,endmask2(a3)
	move.w	#-1,endmask3(a3)
	move.b	#$3,op(a3)
	move.b	#2,hop(a3)
	move.b	#0,skew(a3)
	lea	drawlistonscreen,a6
	lea	drawlist2,a5
	move.w	(a6)+,d7	;number to draw
	bmi	nosprites
	moveq	#-1,d6		;counter
dspl:
	move.l	(a6)+,a0
	cmpi.w	#-2,cactive(a0)
	beq.s	justrestore
	tst.w	cactive(a0)
	bmi.s	nosprite
	bsr	restoreclipped
	move.l	a0,(a5)+
	addq.w	#1,d6		;only these will pass to next
nosprite:
	dbf	d7,dspl
	bra.s	handlemines
justrestore:
	bsr	putback
	dbf	d7,dspl
handlemines:
	btst	#7,$ff8a3c	;bug fix
	bne	handlemines
	lea	mymine1,a0
	bsr	handlemine
	lea	mymine2,a0
	bsr	handlemine
	lea	mymine3,a0
	bsr	handlemine
	lea	mymine4,a0
	bsr	handlemine

	lea	enmine1,a0
	bsr	handlemine2
	lea	enmine2,a0
	bsr	handlemine2
	lea	enmine3,a0
	bsr	handlemine2
	lea	enmine4,a0
	bsr	handlemine2
	lea	enwep,a0
	bsr	handlemine3
	lea	mywep,a0
	bsr	handlemine4
saveloop:
	lea	drawlist2,a6
	move.w	d6,d7		;number to draw
	bmi	nosprites2
	move.l	#$ff8a00,a3
waitblitset2:
	btst	#7,$ff8a3c
	bne	waitblitset2
	move.w	#626,src_yinc(a3)		;time
	move.w	#2,dst_yinc(a3)
dspl2:
	move.l	(a6)+,a0	;if its here its active
	bsr	saveclipped
	dbf	d7,dspl2
drawloop:
	lea	drawlist2,a6
	move.w	d6,d7		;number to draw
dspl3:
	move.l	(a6)+,a0	;if its here its active
	bsr	drawclipped
	dbf	d7,dspl3
nosprites2:
	rts

nosprites:
	lea	mymine1,a0
	bsr	handlemine
	lea	mymine2,a0
	bsr	handlemine
	lea	mymine3,a0
	bsr	handlemine
	lea	mymine4,a0
	bsr	handlemine
	lea	enmine1,a0
	bsr	handlemine2
	lea	enmine2,a0
	bsr	handlemine2
	lea	enmine3,a0
	bsr	handlemine2
	lea	enmine4,a0
	bsr	handlemine2
	lea	enwep,a0
	bsr	handlemine3
	lea	mywep,a0
	bsr	handlemine4
*	move.w	#$0044,$ff8240
	rts
handlemine4:
	lea	mywepons,a1
	bra.s	dom2
handlemine3:
	lea	enemywepons,a1
	bra.s	dom2
handlemine2:
	lea	enemymine,a1
	bra.s	dom2
handlemine:
	lea	mymine,a1
blitfix:
	btst	#7,$ff8a3c
	bne.s	blitfix
dom2:
	cmpi.w	#-1,mineact(a0)
	beq.L	domine2
	cmpi.w	#0,mineact(a0)
	beq	domine2		;no action necessary
	cmpi.w	#-2,mineact(a0)
	beq.L	restoremine
	move.w	#0,mineact(a0)
	move.l	minead(a0),a2
	move.l	(a1)+,(a2)+
	move.l	(a1)+,(a2)+
	lea	640-8(a2),a2
	move.l	(a1)+,(a2)+
	move.l	(a1)+,(a2)+
	lea	640-8(a2),a2
	move.l	(a1)+,(a2)+
	move.l	(a1)+,(a2)+
	lea	640-8(a2),a2
	move.l	(a1)+,(a2)+
	move.l	(a1)+,(a2)+
	lea	640-8(a2),a2
	move.l	(a1)+,(a2)+
	move.l	(a1)+,(a2)+
	lea	640-8(a2),a2
	move.l	(a1)+,(a2)+
	move.l	(a1)+,(a2)+
	lea	640-8(a2),a2
	move.l	(a1)+,(a2)+
	move.l	(a1)+,(a2)+
	lea	640-8(a2),a2
	move.l	(a1)+,(a2)+
	move.l	(a1)+,(a2)+
	lea	640-8(a2),a2
	move.l	(a1)+,(a2)+
	move.l	(a1)+,(a2)+
	lea	640-8(a2),a2
	move.l	(a1)+,(a2)+
	move.l	(a1)+,(a2)+
	lea	640-8(a2),a2
	move.l	(a1)+,(a2)+
	move.l	(a1)+,(a2)+
	lea	640-8(a2),a2
	move.l	(a1)+,(a2)+
	move.l	(a1)+,(a2)+
	lea	640-8(a2),a2
	move.l	(a1)+,(a2)+
	move.l	(a1)+,(a2)+
	lea	640-8(a2),a2
	move.l	(a1)+,(a2)+
	move.l	(a1)+,(a2)+
	lea	640-8(a2),a2
	move.l	(a1)+,(a2)+
	move.l	(a1)+,(a2)+
	lea	640-8(a2),a2
	move.l	(a1)+,(a2)+
	move.l	(a1)+,(a2)+
domine2:
	rts

restoremine:
	move.w	#-1,mineact(a0)
	move.l	minerestore(a0),a1
	move.l	minead(a0),a2
	move.l	(a1)+,(a2)+
	move.l	(a1)+,(a2)+
	lea	640-8(a2),a2
	move.l	(a1)+,(a2)+
	move.l	(a1)+,(a2)+
	lea	640-8(a2),a2
	move.l	(a1)+,(a2)+
	move.l	(a1)+,(a2)+
	lea	640-8(a2),a2
	move.l	(a1)+,(a2)+
	move.l	(a1)+,(a2)+
	lea	640-8(a2),a2
	move.l	(a1)+,(a2)+
	move.l	(a1)+,(a2)+
	lea	640-8(a2),a2
	move.l	(a1)+,(a2)+
	move.l	(a1)+,(a2)+
	lea	640-8(a2),a2
	move.l	(a1)+,(a2)+
	move.l	(a1)+,(a2)+
	lea	640-8(a2),a2
	move.l	(a1)+,(a2)+
	move.l	(a1)+,(a2)+
	lea	640-8(a2),a2
	move.l	(a1)+,(a2)+
	move.l	(a1)+,(a2)+
	lea	640-8(a2),a2
	move.l	(a1)+,(a2)+
	move.l	(a1)+,(a2)+
	lea	640-8(a2),a2
	move.l	(a1)+,(a2)+
	move.l	(a1)+,(a2)+
	lea	640-8(a2),a2
	move.l	(a1)+,(a2)+
	move.l	(a1)+,(a2)+
	lea	640-8(a2),a2
	move.l	(a1)+,(a2)+
	move.l	(a1)+,(a2)+
	lea	640-8(a2),a2
	move.l	(a1)+,(a2)+
	move.l	(a1)+,(a2)+
	lea	640-8(a2),a2
	move.l	(a1)+,(a2)+
	move.l	(a1)+,(a2)+
	lea	640-8(a2),a2
	move.l	(a1)+,(a2)+
	move.l	(a1)+,(a2)+
	lea	640-8(a2),a2
	rts


alternate:	dc.w	-1
vbltemp:
	dc.l	0
*****************************************
*	load a1 with routine address	*
*****************************************
vbl_list=$4ce
prt_cnt=$4ee
putvbl:
	move.l	#vbl_list,a0	; put start of vbl queue in a0
scanq:
	tst.l	(a0)		; current queue entry empty?
	beq.s	newvbl		; yes, install new vbl routine
	addq.l	#4,a0		; no, check next entry
	bra.s	scanq		; loop back
newvbl:
	move.l	a1,(a0)		; install routine in queue
	rts
oldvbl1:	dc.l	0
even
******************************************
*               RETURN TO GEM
gem:
*	move.b	oldieb,ieb
*	move.b	#%11111110,$ff820a
	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.l	oldvbl1,$70
	bsr	restoremfp

	move.w  #34,-(sp)
        trap    #14
        addq.l  #2,sp
        move.l  d0,a0
	move.l	oldmouse,16(a0)

	bsr	res_mouse
	move.b  #7,$484
	move.l	trappoke+2,$84


	move.w	#0,$ff820c
	move.b	#0,$ff820f
	move.b	#0,$ff8265
	move.b	screen+1,$ff8205
	move.b	screen+2,$ff8207
	move.b	screen+3,$ff8209

        move.w  ressave,-(sp)
        move.l  screen,-(sp)
        move.l  screen,-(sp)
        move.w  #5,-(sp)
        trap    #14
        addi.l  #12,sp

        move.w  #$ff,-(sp)
        move.w  #6,-(sp)
        trap    #1
        addq.l  #4,sp

gem3:	move.l  savesup,-(SP)    ;Back to user mode
        move.w  #$20,-(SP)
        trap    #1
        addq.l  #6,SP
gem2:
illegal
	clr.w	-(sp)
	trap	#1


rvsave:	dc.l	0
resave:	dc.l	0
palsave:	blk.w	16,0
***********************************
alertout:
	lea	alerttext1,a0
	bsr	doalert
	bra	gem3
doalert:
	move.w	#52,opcode
	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	a0,addrin
	move.l	#aespb,d1
	move.w	#$c8,d0
	trap	#2
	rts

alerttext1:
	dc.b	'[3][This game only runs on a| |'
	dc.b	    '    1 MEG ATARI STE]'
	dc.b	'[SORRY]',0,0
*********************************************************
mygetpix:
	movem.l	d1-d3/a1,-(sp)
	move.l	seen,a1
	moveq	#0,d0		;zero result register
	move.w	pixely,d3	;get Y coordinate
	and.l	#$0000ffff,d3	;mask off for multiply
*	lsl.w	#5,d3
	mulu	#640,d3		;multiply by 160 (# of bytes per scan line)
	adda.l	d3,a1		;add to screen base address
	move.w	pixelx,d1	;get X coordinate
	move.w	d1,d2		;duplicate it in D2
	asr.w	#1,d1		;divide it by 2
	and.w	#$fff8,d1	;turn off lower 3 bits
	adda.w	d1,a1		;add to screen address register
	move.w	(a1),d3		;grab screen word
	and.l	#15,d2		;mask X to 0-15
	move.w	#$8000,d1	;set up bit mask
	lsr.w	d2,d1		;shift bit mask 0-15 bits
	and.w	d1,d3		;mask off bit 0
	beq.s	bit0b		;bit's off, go get next color bit
	move.w	#1,d0		;turn on bit 0 in result

bit0b:
	move.w	2(a1),d3		;get screen word for bit 1 of color
	and.w	d1,d3		;get bit 1
	beq.s	bit0c		;it's off, try bit 2
	or.w	#2,d0		;turn on bit 1 in result
bit0c:
	move.w	4(a1),d3		;get screen word for bit 2
	and.w	d1,d3		;get bit 2
	beq.s	bit0d		;it's off, try bit 3
	or.w	#4,d0		;turn on bit 2 in result
bit0d:
	move.w	6(a1),d3		;get word for bit 3
	and.w	d1,d3		;get bit 3
	beq.s	getx0		;it's off!
	or.w	#8,d0		;turn on bit 3 in result
getx0:
*	not.w	d1
*	and.w	d1,(a1)+
*	and.w	d1,(a1)+
*	and.w	d1,(a1)+
*	and.w	d1,(a1)+
	movem.l	(sp)+,d1-d3/a1
	rts

*********************************************************
*       my routines for loading in the screens          *
*********************************************************
loadscr:move    #0,-(SP)        ;Open file
        move.l  filename,-(SP) ;Address of filename
        move    #$3D,-(SP)
        trap    #1              ;Get handle number in D0
        addq.l  #8,SP
                
	move.w	d0,-(sp)
	move.w	(sp),d0
	move.l  wheretoload,-(SP)    ;load it straight onto screen
        move.l  #300000,-(SP)    	;length to read in
        move    D0,-(SP)        ;Handle
        move    #$3F,-(SP)      ;bios number
        trap    #1              ;Read file in
        addi.l   #12,SP

        move    #$3E,-(SP)      ;Handle already on stack
        trap    #1              ;Close file
        addq.l  #4,SP
	rts

mytrap:
	MOVE.L	A0,L2DDB0
	BTST	#5,(A7)
	BNE.S	L2DA36
	MOVE.L	USP,A0
	BRA.S	L2DA3A
L2DA36:	move.L	A7,A0
	ADDQ.L	#6,A0
L2DA3A:	CMPI.W	#$3F,(A0)
	BEQ.S	L2DAA8
	CMPI.W	#$42,(A0)
	BEQ.S	L2DA94
	CMPI.W	#$4E,(A0)
	BEQ.S	L2DA80
	CMPI.W	#$2F,(A0)
	BEQ.S	L2DA6C
	CMPI.W	#$1A,(A0)
	BNE.S	L2DAC0
	MOVE.L	2(A7),L2DAE2+2
	MOVE.L	#L2DAD8,2(A7)
	BRA	L2DAC0
L2DA6C:	MOVE.L	2(A7),L2DAD4+
	MOVE.L	#L2DACC,2(A7)
	BRA	L2DAC0
L2DA80:	MOVE.L	2(A7),L2DB58+2
	MOVE.L	#L2DAE6,2(A7)
	BRA	L2DAC0
L2DA94:	MOVE.L	2(A7),L2DC1E+2
	MOVE.L	#L2DB5E,2(A7)
	BRA	L2DAC0
L2DAA8:	MOVE.L	8(A0),L2DDBC
	MOVE.L	2(A7),L2DD7c+2
	MOVE.L	#L2DC22,2(A7)
L2DAC0:	move.L	L2DDB0,A0
trappoke:
	JMP	0
L2DACC:	MOVE.L	D0,L2DDEC
l2dad4:
	JMP	0
L2DAD8:	MOVE.L	2(A7),L2DDEC
l2dae2:	JMP	0
L2DAE6:	TST.L	D0
	BNE	L2DB58
	MOVE.L	D0,L2DDE4
	MOVE.L	A0,L2DDE8
	MOVE.L	2(A7),L2DDF0
	MOVE.W	#2,-(A7)
	MOVE.L	L2DDF0,-(A7)
	MOVE.W	#$3D,-(A7)
	TRAP	#1
	ADDQ.L	#8,A7
	MOVE.W	D0,L2DDE0
	MOVE.W	#2,-(A7)
	MOVE.W	D0,-(A7)
	MOVE.L	#0,-(A7)
	MOVE.W	#$42,-(A7)
	TRAP	#1
	ADDA.L	#$A,A7
	move.L	L2DDEC,A0
	ADDA.L	#$1A,A0
	MOVE.L	D0,(A0)
	MOVE.W	L2DDE0,-(A7)
	MOVE.W	#$3E,-(A7)
	TRAP	#1
	ADDQ.L	#4,A7
	MOVE.L	L2DDE4,D0
	move.L	L2DDE8,A0
L2DB58:	JMP	0
L2DB5E:	CMPI.W	#2,8(A7)
	BNE	L2DC14
	CMPI.L	#0,2(A7)
	BNE	L2DC14
	MOVE.W	6(A7),L2DDD2
	MOVE.L	D0,L2DDD4
	MOVE.L	A0,L2DDD8
	CMP.L	#$A,D0
	BLT	L2DC08
	MOVE.L	L2DC1E,L2DDDC
	MOVE.W	#2,-(A7)
	MOVE.W	L2DDD2,-(A7)
	MOVE.L	#$FFFFFFF8,-(A7)
	MOVE.W	#$42,-(A7)
	TRAP	#1
	ADDA.L	#$A,A7
	ADDQ.L	#8,D0
	MOVE.L	D0,L2DDF6
	MOVE.W	#1,L2DDD0
	MOVE.L	#L2DDA8,-(A7)
	MOVE.L	#8,-(A7)
	MOVE.W	L2DDD2,-(A7)
	MOVE.W	#$3F,-(A7)
	TRAP	#1
	ADDA.L	#$C,A7
	MOVE.L	L2DDDC,L2DC1E
	CMPI.L	#$5359534A,L2DDAC
	BNE	L2DC08
	MOVE.L	L2DDA8,D0
	BRA	L2DC0E
L2DC08:	MOVE.L	L2DDD4,D0
L2DC0E:	move.L	L2DDD8,A0
L2DC14:	MOVE.W	#0,L2DDD0
l2dc1e:	JMP	0
L2DC22:	TST.W	2(A7)
	BMI	L2DD7C
	MOVEM.L	D0-d7/A0-a6,-(A7)
	MOVE.L	D0,L2DDC8
	MOVE.L	D0,L2DDB4
	BTST	#0,D0
	BNE	L2DD6A
	CMPI.W	#1,L2DDD0
	BEQ	L2DD6A
	move.L	L2DDBC,A0
	ADDA.L	D0,A0
	MOVE.L	-(A0),D0
	CMP.L	#$5359534A,D0
	BEQ	L2DC66
	BRA	L2DD6A
L2DC66:	MOVE.L	-(A0),L2DDB4
	MOVE	SR,D1
	BTST	#$D,D1
	BNE	L2DC90
	CLR.L	-(A7)
	MOVE.W	#$20,-(A7)
	TRAP	#1
	ADDQ.L	#6,A7
	LEA	L2DDC4,A6
	MOVE.L	D0,(A6)
	MOVE.W	#1,L2DDC0
L2DC90:
	MOVE.W	$FFF8240,L2DDCC
	SUBQ.L	#4,L2DDC8
	move.L	L2DDBC,A0
	ADDA.L	L2DDC8,A0
	move.L	L2DDBC,A1
	move.L	-(A0),A2
	ADDA.L	A1,A2
	MOVE.L	-(A0),D5
	MOVE.L	-(A0),D0
	EOR.L	D0,D5
L2DCBC:	LSR.L	#1,D0
	BNE.S	L2DCC4
	BSR	L2DD82
L2DCC4:	BCS.S	L2DD06
	MOVEQ	#8,D1
	MOVEQ	#1,D3
	LSR.L	#1,D0
	BNE.S	L2DCD2
	BSR	L2DD82
L2DCD2:	BCS.S	L2DD32
	MOVEQ	#3,D1
	CLR.W	D4
L2DCD8:	BSR	L2DD8E
	MOVE.W	D2,D3
	ADD.W	D4,D3
L2DCE0:	MOVEQ	#7,D1
L2DCE2:	LSR.L	#1,D0
	BNE.S	L2DCEA
	BSR	L2DD82
L2DCEA:	ROXL.L	#1,D2
	DBF	D1,L2DCE2
	MOVE.B	D2,-(A2)
*	MOVE.W	A2,$FFF8240
	DBF	D3,L2DCE0
	BRA	L2DD40
L2DD00:	MOVEQ	#8,D1
	MOVEQ	#8,D4
	BRA.S	L2DCD8
L2DD06:	MOVEQ	#2,D1
	BSR	L2DD8E
	CMP.B	#2,D2
	BLT.S	L2DD28
	CMP.B	#3,D2
	BEQ.S	L2DD00
	MOVEQ	#8,D1
	BSR	L2DD8E
	MOVE.W	D2,D3
	MOVE.W	#$C,D1
	BRA	L2DD32
L2DD28:	MOVE.W	#9,D1
	ADD.W	D2,D1
	ADDQ.W	#2,D2
	MOVE.W	D2,D3
L2DD32:	BSR	L2DD8E
L2DD36:	SUBQ.W	#1,A2
	MOVE.B	0(A2,D2.W),(A2)
	DBF	D3,L2DD36
L2DD40:	CMPA.L	A2,A1
	BLT	L2DCBC
*	MOVE.W	L2DDCC,$FFF8240
	CMPI.W	#1,L2DDC0
	BNE	L2DD6A
	MOVE.L	L2DDC4,-(A7)
	MOVE.W	#$20,-(A7)
	TRAP	#1
	ADDQ.L	#6,A7
L2DD6A:	MOVE.W	#0,L2DDC0
	MOVEM.L	(A7)+,D0-d7/A0-a6
	MOVE.L	L2DDB4,D0
L2DD7C:	JMP	0
L2DD82:	MOVE.L	-(A0),D0
	EOR.L	D0,D5
	MOVE.B	#$10,CCR
	ROXR.L	#1,D0
	RTS
L2DD8E:	SUBQ.W	#1,D1
	CLR.W	D2
L2DD92:	LSR.L	#1,D0
	BNE.S	L2DDA0
	MOVE.L	-(A0),D0
	EOR.L	D0,D5
	MOVE.B	#$10,CCR
	ROXR.L	#1,D0
L2DDA0:	ROXL.L	#1,D2
	DBF	D1,L2DD92
	RTS

L2DDA8:	DC.W	0,0,
l2ddac:	dc.w	0,0
L2DDB0:	DC.W	0,0,
l2ddb4:	dc.w	0,0
	DC.W	0,0
l2ddbc:	dc.w	0,0
L2DDC0:	DC.W	0,0,
l2ddc4:	dc.w	0,0
L2DDC8:	DC.W	0,0,
l2ddcc:	dc.w	0,0
L2DDD0:	DC.W	0,
l2ddd2:	dc.w	0,
l2ddd4:	dc.w	0,0
L2DDD8:	DC.W	0,0,
l2dddc:	dc.w	0,0
L2DDE0:	DC.W	0,0,
l2dde4:	dc.w	0,0
L2DDE8:	DC.W	0,0,
l2ddec:	dc.w	0,0
L2DDF0:	DC.W	0,0,0
l2ddf6:	dc.w	0
***************************************
safe:		dc.w	0

*****************************************
rnd:	blk.l	5,0
*******************************************************************
randomseed:	ADD.L	D0,D1
		MOVEM.L D0/D1,RND
LongRnd:	MOVEM.L D1-D3,-(SP)	
		MOVEM.L RND,D0/D1
		ANDI.B	#$0E,D0
		ORI.B	#$20,D0
		MOVE.L	D0,D2
		MOVE.L	D1,D3
		ADD.L	D2,D2
		ADDX.L	D3,D3
		ADD.L	D2,D0
		ADDX.L	D3,D1
		SWAP	D3
		SWAP	D2
		MOVE.W	D2,D3
		CLR.W	D2
		ADD.L	D2,D0
		ADDX.L	D3,D1
		MOVEM.L D0/D1,RND
		MOVE.L	D1,D0
		MOVEM.L (SP)+,D1-D3
		RTS
random: 	MOVE.w	D2,-(SP)
		MOVE.W	D0,D2
		BEQ.S	r1
		BSR.S	LongRnd
		CLR.W	D0
		SWAP	D0
		ext.l	d0
		DIVs	D2,D0
		CLR.W	D0
		SWAP	D0
r1:		MOVE.w	(SP)+,D2
		RTS

randomplus:	MOVE.w	D2,-(SP)
		MOVE.W	D0,D2
		BEQ.S	r2
		BSR.S	LongRnd
		CLR.W	D0
		SWAP	D0
		DIVu	D2,D0
		CLR.W	D0
		SWAP	D0
r2:		MOVE.w	(SP)+,D2
		RTS

*****************************************
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
clearnums:
	lea	numbers,a3
	move.w	numwhere,d6
out2:
	cmpa.l  #lineout,a5
        beq     decback2
	moveq	#0,d7
        move.b  -(a5),d7
	mulu	#52,d7
	move.l	a3,a0
	add.w	d7,a0
	moveq	#12,d0
	move.l	screen,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


doclearnums:
	movem.l	d0/d6/d7/a0/a5/a1/a2,-(sp)
	move.w	#4001,numwhere
	lea	lineout,a5
	move.b	#10,(a5)+
	move.b	#10,(a5)+
	move.b	#10,(a5)+
	move.b	#10,(a5)+
	move.b	#10,(a5)+
	bra	clearnums

safe2:	dc.w	0
lineout:	blk.l	5
times:		dc.w	0
number:		dc.w	0
numwhere:	dc.w	0



setupgem:
	move.l	a7,a6
        move.l  savesup,-(SP)    ;Back to user mode
        move.w  #$20,-(SP)
        trap    #1
        addq.l  #6,SP
	move.l	a6,a7
	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
	clr.l   -(SP)           ;Go into supervisor mode
        move.w  #$20,-(SP)
        trap    #1
        addq.l  #6,SP
*        move.l  D0,savesup
	rts
*********************************
*	call with color in d0	*
*********************************
setgemcolor:
	move.l  #0,-(SP)    ;Back to user mode
        move.w  #$20,-(SP)
        trap    #1
        addq.l  #6,SP
	move.w	#22,contrl		;color
	move.w	#0,contrl+2
	move.w	#1,contrl+6
	move.w	grhandle,contrl+12
	move.w	#1,intin		;which color
	move.l	#vdipb,d1
	move.w	#$73,d0
	trap	#2
setgemeffects:
	move.w	#106,contrl		;effects
	move.w	#0,contrl+2
	move.w	#1,contrl+6
	move.w	grhandle,contrl+12
	move.w	#0,intin
	move.l	#vdipb,d1
	move.w	#$73,d0
	trap	#2
	clr.l   -(SP)           ;Go into supervisor mode
        move.w  #$20,-(SP)
        trap    #1
        addq.l  #6,SP
	rts

setwrtmode:
	move.l  #0,-(SP)    ;Back to user mode
        move.w  #$20,-(SP)
        trap    #1
        addq.l  #6,SP
	move.w	#32,contrl		;write mode
	move.w	#0,contrl+2
	move.w	#1,contrl+6
	move.w	grhandle,contrl+12
	move.w	d7,intin
	move.l	#vdipb,d1
	move.w	#$73,d0
	trap	#2
	clr.l   -(SP)           ;Go into supervisor mode
        move.w  #$20,-(SP)
        trap    #1
        addq.l  #6,SP
	rts

setgemsize:
        move.l  #0,-(SP)    ;Back to user mode
        move.w  #$20,-(SP)
        trap    #1
        addq.l  #6,SP
	move.w	#107,contrl
	move.w	#0,contrl+2
	move.w	#1,contrl+6
	move.w	grhandle,contrl+12
	move.w	#6,intin		;small chars
	move.l	#vdipb,d1
	move.w	#$73,d0
	trap	#2
	clr.l   -(SP)           ;Go into supervisor mode
        move.w  #$20,-(SP)
        trap    #1
        addq.l  #6,SP
	rts
	
*****************************************
*	output string using gem		*
*	call with a0 ad of string	*
*	null termn.			*
*	x,y in d0,d1			*
*****************************************
gemprint:
	move.w	#$0fff,$ff825e
	move.l	a0,a6
        move.l  #0,-(SP)    ;Back to user mode
        move.w  #$20,-(SP)
        trap    #1
        addq.l  #6,SP
	move.l	a6,a0
	moveq	#0,d0
	move.b	(a0)+,d0
	move.w	d0,ptsin
	moveq	#0,d0
	move.b	(a0)+,d0
	move.w	d0,ptsin+2
	lea	intin,a1		;put text in and count
	moveq	#-1,d7
loop1:
	addq.w	#1,d7
	move.b	#0,(a1)+
	move.b	(a0)+,(a1)+
	bne.s	loop1
	move.w	#8,contrl	;text
	move.w	#1,contrl+2	;number of pairs of coords
	move.w	d7,contrl+6	;length of intin
	move.w	grhandle,contrl+12
	move.l	#vdipb,d1
	move.w	#$73,d0
	trap	#2
	clr.l   -(SP)           ;Go into supervisor mode
        move.w  #$20,-(SP)
        trap    #1
        addq.l  #6,SP
*        move.l  D0,savesup
	rts

cleartext:
	move.w	#1,d7
	bsr	setwrtmode
	lea	ct1,a0
	bsr	gemprint
	lea	ct2,a0
	bsr	gemprint
	lea	ct3,a0
	bsr	gemprint
	lea	ct4,a0
	bsr	gemprint
	lea	ct5,a0
	bsr	gemprint
	lea	ct6,a0
	bsr	gemprint
	lea	ct7,a0
	bsr	gemprint
	lea	ct8,a0
	bsr	gemprint
	move.w	#2,d7
	bsr	setwrtmode
	rts
ct1:
	dc.b	79,33,'                          ',0
ct2:
	dc.b	79,39,'                          ',0
ct3:
	dc.b	79,45,'                          ',0
ct4:
	dc.b	79,51,'                          ',0
ct5:
	dc.b	233,33,' ',0
ct6:
	dc.b	233,39,' ',0
ct7:
	dc.b	233,45,' ',0
ct8:
	dc.b	233,51,' ',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
	blk.w	5,0

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:
	blk.w	128,0
ptsin:
	blk.w	128,0
intout:
	blk.w	128,0
ptsout:
	blk.w	128,0
addrin:
	blk.w	128,0
addrout:
	blk.w	128,0
vdipb:
	dc.l	contrl,intin,ptsin,intout,ptsout
grhandle:	dc.w	0
specscreen1:	dc.l	0
colortable1:	dc.l	0
specscreen2:	dc.l	0
colortable2:	dc.l	0

resetsound:
stls:
	cmpi.w	#$7ff,$ff8924
	bne	stls
	move.w	#%0000010011101000,d0		;011 for master vol
	move.w	d0,$ff8922			;send data
stl2:
	cmpi.w	#$7ff,$ff8924
	bne	stl2
	move.w	#%0000010000000001,d0		;000 for mix vol
	move.w	d0,$ff8922			;send data
stl3:
	cmpi.w	#$7ff,$ff8924
	bne	stl3
	move.w	#%0000010101010100,d0		;101 for left vol
	move.w	d0,$ff8922			;send data
stl4:
	cmpi.w	#$7ff,$ff8924
	bne	stl4
	move.w	#%0000010100010100,d0		;100 for right vol
	move.w	d0,$ff8922			;send data
stl5:
	cmpi.w	#$7ff,$ff8924
	bne	stl5
	move.w	#%0000010010000110,d0		;010 for treb vol
	move.w	d0,$ff8922			;send data
stl6:
	cmpi.w	#$7ff,$ff8924
	bne	stl6
	move.w	#%0000010001000110,d0		;001 for bass vol
	move.w	d0,$ff8922			;send data
	rts

dltmemcount:	dc.l	0
dltsave:	dc.l	0
dotitle:
	move.w	#1,novbl
	move.l	#scr,d0
	add.l	#388368,d0
	move.l	d0,wheretoload
	move.l	#filedlt,filename
	jsr	loadscr
	move.l	wheretoload,d0
	move.l	d0,dltmemcount
	move.l	d0,dltsave
	move.l	screen,d0
	move.l	d0,wheretoload
	move.l	#fileload,filename
	jsr	loadscr
	lea	blackpal,a0
	bsr	mydocolors3
	move.l	$70,oldvbl1
	move.l	$70,tgooldvbl+2
	move.l	#dltvbl,$70
	move.w	#-1,novbl

	move.w	#$7ff,$ff8924
settreb:
	cmpi.w	#$7ff,$ff8924
	bne	settreb
	move.w	#%0000010010000100,d0		;010 for treb vol
	move.w	d0,$ff8922			;send data

	move.l	#filetitmus,filename	;load title music
	move.l	#scr,wheretoload
	jsr	loadscr
mybell:
	move.l	#scr,d0
	move.l	#scr+284160,d1
	lea	$ff8900,a0	;sound register base address
	move.w	#0,sounddma(a0)
	move.w	d0,soundstartl(a0)
	lsr.l	#8,d0
	move.w	d0,soundstartm(a0)
	lsr.l	#8,d0
	move.w	d0,soundstarth(a0)
	move.w	d1,soundendl(a0)
	lsr.l	#8,d1
	move.w	d1,soundendm(a0)
	lsr.l	#8,d1
	move.w	d1,soundendh(a0)
	move.w	#%0000000000000000,soundmode(a0)	;stereo 6258
	move.w	#%0000000000000011,sounddma(a0)		;repeat
	lea	gamemap,a0
dtl1:
	move.l	a0,d0
	divu	#512,d0
	swap	d0
	tst.w	d0
	beq.s	dtl2
	addq.l	#2,a0
	bra	dtl1
dtl2:
	move.l	a0,specscreen1
	add.l	#32000,a0
	move.l	a0,colortable1
	add.l	#19104,a0
dtl3:
	move.l	a0,d0
	divu	#512,d0
	swap	d0
	tst.w	d0
	beq.s	dtl4
	addq.l	#2,a0
	bra	dtl3
dtl4:
	move.l	a0,specscreen2
	add.l	#32000,a0
	move.l	a0,colortable2

	move.l	#filetit1,filename
	move.l	specscreen1,wheretoload
	jsr	loadscr
	move.l	#filetit2,filename
	move.l	specscreen2,wheretoload
	jsr	loadscr
	move.w	#1,novbl
laceloop:
	move.l	colortable1,-(sp)
	move.l	specscreen1,-(sp)
	move.l	colortable2,-(sp)
	move.l	specscreen2,-(sp)
	move.w	#1,-(sp)
	bsr	show512
	add.l	#18,sp
laceloop2:
	move.w	#$ff,-(sp)
	move.w	#6,-(sp)
	trap	#1
	addq.l	#4,sp
	tst.l	d0		;wait for keypress
	beq	laceloop2
	move.w	#0,-(sp)
	jsr	show512
	addq.w	#2,sp
	rts

show512:
	MOVEM.L D3-D7/A3-A6,-(A7)	;save regs
	LEA     thisis26a,A6
	ST      $0001(A6)		;set true
	TST.W   $0028(A7)		;was it turn off ?
	BEQ     restoreeverything	;yep

	TST.B   (A6)		;is the vbl and mouse already fixed
	BNE	alreadyin	;yep

	MOVE.W  #2,-(A7)		;get screen physical
	TRAP    #14
	ADDQ.L  #2,A7			;stack cleanup
	MOVE.L  D0,$000C(A6)		;save screen address
	PEA     mousecommand1		;turn mouse off $12
	CLR.W   -(A7)			;length-1
	MOVE.W  #$0019,-(A7)		;send string to int keyboard
	TRAP    #14
	ADDQ.L  #8,A7			;clean stack

	MOVE.B  43(A7),$0002(A6)
	MOVE.B  44(A7),$0003(A6)
	MOVE.L  46(A7),$0004(A6)
	MOVE.B  51(A7),otherscreen1
	MOVE.B  52(A7),otherscreen2
	move.l	54(a7),otherpalette

	PEA	setup512vbl
	MOVE.W  #$0026,-(A7)		;execute in supervisor mode
	TRAP    #$E
	ADDQ.L  #6,A7			;clean stack
	BRA.S   skipalready
alreadyin:
	MOVE.B  $002B(A7),$0002(A6)
	MOVE.B  $002C(A7),$0003(A6)
	MOVE.L  $002E(A7),$0004(A6)
	MOVE.B  51(A7),otherscreen1
	MOVE.B  52(A7),otherscreen2
	move.l	54(a7),otherpalette

skipalready:
	TST.B   $0001(A6)
	BNE.S   skipalready
	BRA	exit

*	Turn off 512 color display	*
restoreeverything:
	TST.B	(A6)		;hadn't been started so no restore
	BEQ	exit
	PEA	restorethings
	MOVE.W	#$0026,-(A7)		;execute in supervisor
	TRAP	#14
	ADDQ.L  #6,A7			;clean stack

restorescreen:
	MOVE.W	#-1,-(A7)		;ignore res
	MOVE.L	$000C(A6),-(A7)		;put saved physbase
	MOVE.L	#-1,-(A7)		;ignore logical
	MOVE.W	#5,-(A7)		;set screen
	TRAP	#14
	LEA	$000C(A7),A7

	PEA	mousecommand2		;08 re-enable mouse
	CLR.W   -(A7)			;length-1
	MOVE.W  #$0019,-(A7)		;int keyboard sen
	TRAP    #14
	ADDQ.L  #8,A7			;clean stack
	SF      (A6)			;back to original state
exit:
	MOVEM.L (A7)+,D3-D7/A3-A6	;restore regs and return
	RTS


setup512vbl:
	LEA	$00FF8240,A0		;color reg 0
	LEA	savecolors,A1
	MOVE.W  #$000F,D7
savecoloop:
	MOVE.W  (A0)+,(A1)+
	dbf	D7,savecoloop

	LEA     $00FF8260,A0		;shift mode
	LEA	shiftsave,A1
	MOVE.B  (A0),(A1)		;save the shift mode
	CLR.B   (A0)			;set to low res

	LEA	vblsave,A0
	move.l  $000004CE,(A0)		;vbl que save
	move.b	$ff820a,d7
	btst	#1,d7
	bne	ispal
	LEA     my512vbl,A0
	MOVE.L  A0,$000004CE		;address of my vbl rout
	RTS
ispal:
	LEA     my512vblpal,A0
	MOVE.L  A0,$000004CE		;address of my vbl rout
	RTS

restorethings:
	MOVE.L	vblsave,$000004CE	;restore old vbl
	MOVE.B	shiftsave,$00FF8260	;restore old shift mode
	LEA	$00FF8240,A0		;color 0
	LEA	savecolors,A1
	MOVE.W	#$000F,D7
restorecoloop:
	MOVE.W	(A1)+,(A0)+
	DBF	D7,restorecoloop
	RTS

my512vblpal:
	TST.W   $0000043E	;do nothing if disk activity
	BNE     thisis268
	MOVE    SR,-(A7)	;save the sr
	ORI     #$0700,SR
	LEA     thisis26a,A0
	TST.B   (A0)
	BEQ     thisis246
	LEA     $00FF8240,A4	;color 0
	LEA     $00FF8209,A5	;vid address counter low
	LEA     thisis174p,A6
	MOVE.L	thisis272,A3
	LEA     $0020(A3),A3
	MOVE.W  #$00C4,D7
	CLR.L   D0
waitloopp:
	TST.B   (A5)
	BEQ.S   waitloopp

	MOVE.B  (A5),D0
	adda.l	d0,a6
	JMP     (A6)
thisis174p:
	blk.w	120,$4e71
colloop1p:
	nop
	NOP
	LEA     (A4),A0
	LEA     (A4),A1
	LEA     (A4),A2
	MOVE.L  (A3)+,(A0)+
	MOVE.L  (A3)+,(A0)+
	MOVE.L  (A3)+,(A0)+
	MOVE.L  (A3)+,(A0)+
	MOVE.L  (A3)+,(A0)+
	MOVE.L  (A3)+,(A0)+
	MOVE.L  (A3)+,(A0)+
	MOVE.L  (A3)+,(A0)+
	MOVE.L  (A3)+,(A1)+
	MOVE.L  (A3)+,(A1)+
	MOVE.L  (A3)+,(A1)+
	MOVE.L  (A3)+,(A1)+
	MOVE.L  (A3)+,(A1)+
	MOVE.L  (A3)+,(A1)+
	MOVE.L  (A3)+,(A1)+
	MOVE.L  (A3)+,(A1)+
	MOVE.L  (A3)+,(A2)+
	MOVE.L  (A3)+,(A2)+
	MOVE.L  (A3)+,(A2)+
	MOVE.L  (A3)+,(A2)+
	MOVE.L  (A3)+,(A2)+
	MOVE.L  (A3)+,(A2)+
	MOVE.L  (A3)+,(A2)+
	MOVE.L  (A3)+,(A2)+
	DBF     D7,colloop1p
	nop
	LEA     (A4),A0
	LEA     (A4),A1
	LEA     (A4),A2
	MOVE.L  (A3)+,(A0)+
	MOVE.L  (A3)+,(A0)+
	MOVE.L  (A3)+,(A0)+
	MOVE.L  (A3)+,(A0)+
	MOVE.L  (A3)+,(A0)+
	MOVE.L  (A3)+,(A0)+
	MOVE.L  (A3)+,(A0)+
	MOVE.L  (A3)+,(A0)+
	MOVE.L  (A3)+,(A1)+
	MOVE.L  (A3)+,(A1)+
	MOVE.L  (A3)+,(A1)+
	MOVE.L  (A3)+,(A1)+
	MOVE.L  (A3)+,(A1)+
	MOVE.L  (A3)+,(A1)+
	MOVE.L  (A3)+,(A1)+
	MOVE.L  (A3)+,(A1)+
	MOVE.L  (A3)+,(A2)+
	MOVE.L  (A3)+,(A2)+
	MOVE.L  (A3)+,(A2)+
	MOVE.L  (A3)+,(A2)+
	MOVE.L  (A3)+,(A2)+
	MOVE.L  (A3)+,(A2)+
	MOVE.L  (A3)+,(A2)+
	MOVE.L  (A3)+,(A2)+
	LEA     (A4),A0
	LEA     (A4),A1
	LEA     (A4),A2
	lea	-$4a60(A3),A4
	NOP
	NOP
	nop
	MOVE.L  (A3)+,(A0)+
	MOVE.L  (A3)+,(A0)+
	MOVE.L  (A3)+,(A0)+
	MOVE.L  (A3)+,(A0)+
	MOVE.L  (A3)+,(A0)+
	MOVE.L  (A3)+,(A0)+
	MOVE.L  (A3)+,(A0)+
	MOVE.L  (A3)+,(A0)+
	MOVE.L  (A3)+,(A1)+
	MOVE.L  (A3)+,(A1)+
	MOVE.L  (A3)+,(A1)+
	MOVE.L  (A3)+,(A1)+
	MOVE.L  (A3)+,(A1)+
	MOVE.L  (A3)+,(A1)+
	MOVE.L  (A3)+,(A1)+
	MOVE.L  (A3)+,(A1)+
	MOVE.L  (A4)+,(A2)+
	MOVE.L  (A4)+,(A2)+
	MOVE.L  (A4)+,(A2)+
	MOVE.L  (A4)+,(A2)+
	MOVE.L  (A4)+,(A2)+
	MOVE.L  (A4)+,(A2)+
	MOVE.L  (A4)+,(A2)+
	MOVE.L  (A4)+,(A2)+
	LEA     thisis26a,A6
	ST      (A6)
	SF      $0001(A6)
	move.b	2(a6),d0
	move.b	otherscreen1,2(a6)
	move.b	d0,otherscreen1
	move.b	3(a6),d0
	move.b	otherscreen2,3(a6)
	move.b	d0,otherscreen2
	move.l	4(a6),d0
	move.l	otherpalette,4(a6)
	move.l	d0,otherpalette

	MOVE.B  $0002(A6),$00FF8201	;vidbasehi
	MOVE.B  $0003(A6),$00FF8203	;"   "  lo
	MOVE.L  $0004(A6),$0008(A6)
	MOVE    (A7)+,SR		;restore the sr
	RTS

my512vbl:
	TST.W   $0000043E	;flock, why I don't know
	BNE     thisis268
	MOVE    SR,-(A7)	;save the sr
	ORI     #$0700,SR
	LEA     thisis26a,A0
	TST.B   (A0)
	BEQ     thisis246
	LEA     $00FF8240,A4	;color 0
	LEA     $00FF8209,A5	;vid address counter low
	LEA     thisis174,A6
	MOVE.L thisis272,A3
	LEA     $0020(A3),A3
	MOVE.W  #$00C4,D7
	CLR.L   D0
waitloop:
	TST.B   (A5)
	BEQ.S   waitloop

	MOVE.B  (A5),D0
	CMP.B   #$18,D0
	BHI     thisis246
	ADDA.L  D0,A6
	JMP     (A6)
thisis174:
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	MOVE.W  #$0018,D0
waitloop2:
	NOP
	DBF     D0,waitloop2
colloop1:
	NOP
	LEA     (A4),A0
	LEA     (A4),A1
	LEA     (A4),A2
	MOVE.L  (A3)+,(A0)+
	MOVE.L  (A3)+,(A0)+
	MOVE.L  (A3)+,(A0)+
	MOVE.L  (A3)+,(A0)+
	MOVE.L  (A3)+,(A0)+
	MOVE.L  (A3)+,(A0)+
	MOVE.L  (A3)+,(A0)+
	MOVE.L  (A3)+,(A0)+
	MOVE.L  (A3)+,(A1)+
	MOVE.L  (A3)+,(A1)+
	MOVE.L  (A3)+,(A1)+
	MOVE.L  (A3)+,(A1)+
	MOVE.L  (A3)+,(A1)+
	MOVE.L  (A3)+,(A1)+
	MOVE.L  (A3)+,(A1)+
	MOVE.L  (A3)+,(A1)+
	MOVE.L  (A3)+,(A2)+
	MOVE.L  (A3)+,(A2)+
	MOVE.L  (A3)+,(A2)+
	MOVE.L  (A3)+,(A2)+
	MOVE.L  (A3)+,(A2)+
	MOVE.L  (A3)+,(A2)+
	MOVE.L  (A3)+,(A2)+
	MOVE.L  (A3)+,(A2)+
	DBF     D7,colloop1

	LEA     (A4),A0
	LEA     (A4),A1
	LEA     (A4),A2
	MOVE.L  (A3)+,(A0)+
	MOVE.L  (A3)+,(A0)+
	MOVE.L  (A3)+,(A0)+
	MOVE.L  (A3)+,(A0)+
	MOVE.L  (A3)+,(A0)+
	MOVE.L  (A3)+,(A0)+
	MOVE.L  (A3)+,(A0)+
	MOVE.L  (A3)+,(A0)+
	MOVE.L  (A3)+,(A1)+
	MOVE.L  (A3)+,(A1)+
	MOVE.L  (A3)+,(A1)+
	MOVE.L  (A3)+,(A1)+
	MOVE.L  (A3)+,(A1)+
	MOVE.L  (A3)+,(A1)+
	MOVE.L  (A3)+,(A1)+
	MOVE.L  (A3)+,(A1)+
	MOVE.L  (A3)+,(A2)+
	MOVE.L  (A3)+,(A2)+
	MOVE.L  (A3)+,(A2)+
	MOVE.L  (A3)+,(A2)+
	MOVE.L  (A3)+,(A2)+
	MOVE.L  (A3)+,(A2)+
	MOVE.L  (A3)+,(A2)+
	MOVE.L  (A3)+,(A2)+
	LEA     (A4),A0
	LEA     (A4),A1
	LEA     (A4),A2
	lea	-$4a60(A3),A4
	NOP
	NOP
	MOVE.L  (A3)+,(A0)+
	MOVE.L  (A3)+,(A0)+
	MOVE.L  (A3)+,(A0)+
	MOVE.L  (A3)+,(A0)+
	MOVE.L  (A3)+,(A0)+
	MOVE.L  (A3)+,(A0)+
	MOVE.L  (A3)+,(A0)+
	MOVE.L  (A3)+,(A0)+
	MOVE.L  (A3)+,(A1)+
	MOVE.L  (A3)+,(A1)+
	MOVE.L  (A3)+,(A1)+
	MOVE.L  (A3)+,(A1)+
	MOVE.L  (A3)+,(A1)+
	MOVE.L  (A3)+,(A1)+
	MOVE.L  (A3)+,(A1)+
	MOVE.L  (A3)+,(A1)+
	MOVE.L  (A4)+,(A2)+
	MOVE.L  (A4)+,(A2)+
	MOVE.L  (A4)+,(A2)+
	MOVE.L  (A4)+,(A2)+
	MOVE.L  (A4)+,(A2)+
	MOVE.L  (A4)+,(A2)+
	MOVE.L  (A4)+,(A2)+
	MOVE.L  (A4)+,(A2)+
thisis246:
	LEA     thisis26a,A6
	ST      (A6)
	SF      $0001(A6)

	move.b	2(a6),d0
	move.b	otherscreen1,2(a6)
	move.b	d0,otherscreen1
	move.b	3(a6),d0
	move.b	otherscreen2,3(a6)
	move.b	d0,otherscreen2
	move.l	4(a6),d0
	move.l	otherpalette,4(a6)
	move.l	d0,otherpalette

	MOVE.B  $0002(A6),$00FF8201	;vidbasehi
	MOVE.B  $0003(A6),$00FF8203	;"   "  lo
	MOVE.L  $0004(A6),$0008(A6)
	MOVE    (A7)+,SR		;restore the sr
thisis268:
	RTS
thisis26a:
	blk.l	2,0
thisis272:
	blk.l	2,0
vblsave:
	blk.l	1,0
savecolors:
	blk.w	16,0
otherpalette:	dc.l	0
mousecommand1:
	dc.b    $12
mousecommand2:
	dc.b	08
shiftsave:
	dc.b	0
otherscreen1:	dc.b	0
otherscreen2:	dc.b	0
even

filedlt:	dc.b	'loading.dl2',0
fileload:	dc.b	'load.d2',0
filetitmus:	dc.b	'atmos.img',0
filetit1:	dc.b	'lace.im1',0
filetit2:	dc.b	'lace.im2',0
filefb:		dc.b	'game3.dat',0
fileme:		dc.b	'mep2.img',0
fileshots:	dc.b	'shot2.img',0
filemetank:	dc.b	'met2.img',0
fileenemy:	dc.b	'ep2.img',0
fileenemytank:	dc.b	'et2.img',0
filesounds:	dc.b	'sounds.img',0
filemap:	dc.b	'midimap.img',0
filemap1:	dc.b	'game1.map',0
fileintel:	dc.b	'intel1.img',0
even
savesup:	dc.l	0
ressave:	dc.w	0
filename:	dc.l	0
bluepalette:
	dc.w	$0000,$0005,$0004,$0fff,$0445,$0223,$0112,$0310
	dc.w	$0420,$0541,$0f62,$00f0,$0030,$0f00,$0300,$0707
blackpal:
	dc.w	$0000,$000f
blackpal2:
	blk.w	16,0
textpalette:
	dc.w	$0000,$0005,$0004,$0fff,$0445,$0223,$0112,$0310
	dc.w	$0420,$0541,$0f62,$00f0,$0030,$0f00,$0300,$0fff
gtemp:	blk.w	100,0
gsave:	blk.w	100,0
gmask:	blk.w	100,0

gamemap:
	blk.b	4000,0
mesprites:
	blk.b	40960,0
metanksprites:
	blk.b	40960,0
enemysprites:
	blk.b	40960,0
enemytanksprites:
	blk.b	40960,0
shotsprites:
	blk.b	2560,0
sounds:
boom:
	blk.b	23344,0
shoot:
	blk.b	6836,0
wall:
	blk.b	2352,0
wallend:

screenx:	dc.w	100
screeny:	dc.w	100
blocks:
	blk.b	6400,0
xvel:	dc.w	0
yvel:	dc.w	0
pixelx:	dc.w	0
pixely:	dc.w	0
wheretoload:	dc.l	0
shotxvel:	dc.w	0
shotyvel:	dc.w	0
mehits:		dc.w	0
tanks:		dc.w	0
shotsbar:
	 dc.w	$FFFF,$0000,$FFFF,$FFFF,$0000,$FFFF,$0000,$FFFF
	 dc.w	$03FF,$FFFF,$0000,$FFFF,$FFFF,$FFFF,$0000,$FFFF
	 dc.w	$FFFF,$0000,$FFFF,$FFFF,$0000,$FFFF,$0000,$FFFF
	 dc.w	$03FF,$FFFF,$0000,$FFFF,$FFFF,$FFFF,$0000,$FFFF
	 dc.w	$FFFF,$0000,$FFFF,$FFFF,$0000,$FFFF,$0000,$FFFF
	 dc.w	$03FF,$FFFF,$0000,$FFFF,$FFFF,$FFFF,$0000,$FFFF
	 dc.w	$FFFF,$0000,$FFFF,$FFFF,$0000,$FFFF,$0000,$FFFF
	 dc.w	$03FF,$FFFF,$0000,$FFFF,$FFFF,$FFFF,$0000,$FFFF
damagebar:
	dc.w	$FFF0,$000F,$FFF0,$FFFF,$0007,$FFFF,$0000,$FFFF
	dc.w	$FFFF,$FFFF,$0000,$FFFF,$FFF0,$000F,$FFF0,$FFFF
	dc.w	$0007,$FFFF,$0000,$FFFF,$FFFF,$FFFF,$0000,$FFFF
	dc.w	$FFF0,$000F,$FFF0,$FFFF,$0007,$FFFF,$0000,$FFFF
	dc.w	$FFFF,$FFFF,$0000,$FFFF,$FFF0,$000F,$FFF0,$FFFF
	dc.w	$0007,$FFFF,$0000,$FFFF,$FFFF,$FFFF,$0000,$FFFF
mineimg:
	 dc.w	$7800,$0400,$0000,$FC00,$8400,$8800,$B000,$7C00
	 dc.w	$D400,$C000,$8800,$7C00,$E400,$E000,$A800,$5C00
	 dc.w	$F400,$F000,$C000,$3C00,$F800,$F800,$F800,$0400
tankimg:
	 dc.w	$7000,$6000,$4000,$3000,$E800,$B000,$8000,$7800
	 dc.w	$E800,$B000,$8000,$7800,$F800,$A000,$8000,$7800
	 dc.w	$7000,$7000,$5000,$2000
shots:	dc.w	64	;number of shots

mymine:
	 dc.w	$7FFE,$0001,$0000,$FFFF,$BFFD,$8002,$8000,$7FFF
	 dc.w	$D00B,$C004,$CFF0,$3FFF,$E817,$E008,$E7E0,$1FFF
	 dc.w	$F7EB,$F010,$D004,$2FFF,$F833,$F800,$CBCC,$37FF
	 dc.w	$F813,$F840,$CFAC,$37FF,$FA13,$FA00,$CDEC,$37FF
	 dc.w	$FA13,$FA00,$CDEC,$37FF,$F993,$F980,$CE6C,$37FF
	 dc.w	$FC13,$FC00,$CFCC,$33FF,$FFEB,$FFE0,$DFE4,$201F
	 dc.w	$FFF7,$FFF0,$F810,$07EF,$FFFB,$FFF8,$F008,$0FF7
	 dc.w	$FFFD,$FFFC,$FFFC,$0003,$FFFE,$FFFE,$FFFE,$0001
enemymine:
	 dc.w	$7FFE,$0001,$0000,$FFFF,$BFFD,$8002,$8000,$7FFF
	 dc.w	$D00B,$CFF4,$CFF0,$3FFF,$E817,$E7E8,$E7E0,$1FFF
	 dc.w	$F7EB,$D014,$F004,$2FFF,$F833,$CBCC,$FBCC,$37FF
	 dc.w	$F813,$CFEC,$FFAC,$37FF,$FA13,$CDEC,$FFEC,$37FF
	 dc.w	$FA13,$CDEC,$FFEC,$37FF,$F993,$CE6C,$FFEC,$37FF
	 dc.w	$FC13,$CFCC,$FFCC,$33FF,$FFEB,$DFE4,$FFE4,$201F
	 dc.w	$FFF7,$F810,$FFF0,$07EF,$FFFB,$F008,$FFF8,$0FF7
	 dc.w	$FFFD,$FFFC,$FFFC,$0003,$FFFE,$FFFE,$FFFE,$0001
mywepons:
	 dc.w	$7FFE,$0001,$0000,$FFFF,$BFFD,$8002,$8000,$7FFF
	 dc.w	$C003,$C000,$FFFC,$3FFF,$C003,$C000,$FFFC,$3FFF
	 dc.w	$CC33,$CC30,$F3CC,$3FFF,$C813,$C810,$F7EC,$3FFF
	 dc.w	$C813,$C810,$F7EC,$3FFF,$C813,$C810,$F7EC,$3FFF
	 dc.w	$C993,$C990,$F66C,$3FFF,$CBD3,$CBD0,$F42C,$3FFF
	 dc.w	$CE73,$CE70,$F18C,$3FFF,$CC33,$CC30,$F3CC,$3FFF
	 dc.w	$C003,$C000,$FFFC,$3FFF,$C003,$C000,$FFFC,$3FFF
	 dc.w	$FFFD,$FFFC,$FFFC,$0003,$FFFE,$FFFE,$FFFE,$0001
enemywepons:
	 dc.w	$7FFE,$0001,$0000,$FFFF,$BFFD,$8002,$8000,$7FFF
	 dc.w	$C003,$FFFC,$FFFC,$3FFF,$C003,$FFFC,$FFFC,$3FFF
	 dc.w	$CC33,$F3CC,$FFFC,$3FFF,$C813,$F7EC,$FFFC,$3FFF
	 dc.w	$C813,$F7EC,$FFFC,$3FFF,$C813,$F7EC,$FFFC,$3FFF
	 dc.w	$C993,$F66C,$FFFC,$3FFF,$CBD3,$F42C,$FFFC,$3FFF
	 dc.w	$CE73,$F18C,$FFFC,$3FFF,$CC33,$F3CC,$FFFC,$3FFF
	 dc.w	$C003,$FFFC,$FFFC,$3FFF,$C003,$FFFC,$FFFC,$3FFF
	 dc.w	$FFFD,$FFFC,$FFFC,$0003,$FFFE,$FFFE,$FFFE,$0001
myprt:
	rts

numbers:
	 dc.b	$78,$00,$FF,$78,$B4,$00,$FF,$B4
	 dc.b	$CC,$00,$FF,$CC,$CC,$00,$FF,$CC
	 dc.b	$CC,$00,$FF,$CC,$84,$30,$FF,$B4
	 dc.b	$00,$78,$FF,$78,$84,$30,$FF,$B4
	 dc.b	$CC,$00,$FF,$CC,$CC,$00,$FF,$CC
	 dc.b	$CC,$00,$FF,$CC,$B4,$00,$FF,$B4
	 dc.b	$78,$00,$FF,$78,$00,$78,$FF,$78
	 dc.b	$04,$B0,$FF,$B4,$0C,$C0,$FF,$CC
	 dc.b	$0C,$C0,$FF,$CC,$0C,$C0,$FF,$CC
	 dc.b	$04,$B0,$FF,$B4,$00,$78,$FF,$78
	 dc.b	$04,$B0,$FF,$B4,$0C,$C0,$FF,$CC
	 dc.b	$0C,$C0,$FF,$CC,$0C,$C0,$FF,$CC
	 dc.b	$04,$B0,$FF,$B4,$00,$78,$FF,$78
	 dc.b	$78,$00,$FF,$78,$34,$80,$FF,$B4
	 dc.b	$0C,$C0,$FF,$CC,$0C,$C0,$FF,$CC
	 dc.b	$0C,$C0,$FF,$CC,$34,$80,$FF,$B4
	 dc.b	$78,$00,$FF,$78,$B0,$04,$FF,$B4
	 dc.b	$C0,$0C,$FF,$CC,$C0,$0C,$FF,$CC
	 dc.b	$C0,$0C,$FF,$CC,$B0,$04,$FF,$B4
	 dc.b	$78,$00,$FF,$78,$78,$00,$FF,$78
	 dc.b	$34,$80,$FF,$B4,$0C,$C0,$FF,$CC
	 dc.b	$0C,$C0,$FF,$CC,$0C,$C0,$FF,$CC
	 dc.b	$34,$80,$FF,$B4,$78,$00,$FF,$78
	 dc.b	$34,$80,$FF,$B4,$0C,$C0,$FF,$CC
	 dc.b	$0C,$C0,$FF,$CC,$0C,$C0,$FF,$CC
	 dc.b	$34,$80,$FF,$B4,$78,$00,$FF,$78
	 dc.b	$00,$78,$FF,$78,$84,$30,$FF,$B4
	 dc.b	$CC,$00,$FF,$CC,$CC,$00,$FF,$CC
	 dc.b	$CC,$00,$FF,$CC,$B4,$00,$FF,$B4
	 dc.b	$78,$00,$FF,$78,$34,$80,$FF,$B4
	 dc.b	$0C,$C0,$FF,$CC,$0C,$C0,$FF,$CC
	 dc.b	$0C,$C0,$FF,$CC,$04,$B0,$FF,$B4
	 dc.b	$00,$78,$FF,$78,$78,$00,$FF,$78
	 dc.b	$B0,$04,$FF,$B4,$C0,$0C,$FF,$CC
	 dc.b	$C0,$0C,$FF,$CC,$C0,$0C,$FF,$CC
	 dc.b	$B0,$04,$FF,$B4,$78,$00,$FF,$78
	 dc.b	$34,$80,$FF,$B4,$0C,$C0,$FF,$CC
	 dc.b	$0C,$C0,$FF,$CC,$0C,$C0,$FF,$CC
	 dc.b	$34,$80,$FF,$B4,$78,$00,$FF,$78
	 dc.b	$78,$00,$FF,$78,$B0,$04,$FF,$B4
	 dc.b	$C0,$0C,$FF,$CC,$C0,$0C,$FF,$CC
	 dc.b	$C0,$0C,$FF,$CC,$B0,$04,$FF,$B4
	 dc.b	$78,$00,$FF,$78,$B4,$00,$FF,$B4
	 dc.b	$CC,$00,$FF,$CC,$CC,$00,$FF,$CC
	 dc.b	$CC,$00,$FF,$CC,$B4,$00,$FF,$B4
	 dc.b	$78,$00,$FF,$78,$78,$00,$FF,$78
	 dc.b	$34,$80,$FF,$B4,$0C,$C0,$FF,$CC
	 dc.b	$0C,$C0,$FF,$CC,$0C,$C0,$FF,$CC
	 dc.b	$04,$B0,$FF,$B4,$00,$78,$FF,$78
	 dc.b	$04,$B0,$FF,$B4,$0C,$C0,$FF,$CC
	 dc.b	$0C,$C0,$FF,$CC,$0C,$C0,$FF,$CC
	 dc.b	$04,$B0,$FF,$B4,$00,$78,$FF,$78
	 dc.b	$78,$00,$FF,$78,$B4,$00,$FF,$B4
	 dc.b	$CC,$00,$FF,$CC,$CC,$00,$FF,$CC
	 dc.b	$CC,$00,$FF,$CC,$B4,$00,$FF,$B4
	 dc.b	$78,$00,$FF,$78,$B4,$00,$FF,$B4
	 dc.b	$CC,$00,$FF,$CC,$CC,$00,$FF,$CC
	 dc.b	$CC,$00,$FF,$CC,$B4,$00,$FF,$B4
	 dc.b	$78,$00,$FF,$78,$78,$00,$FF,$78
	 dc.b	$B4,$00,$FF,$B4,$CC,$00,$FF,$CC
	 dc.b	$CC,$00,$FF,$CC,$CC,$00,$FF,$CC
	 dc.b	$B4,$00,$FF,$B4,$78,$00,$FF,$78
	 dc.b	$34,$80,$FF,$B4,$0C,$C0,$FF,$CC
	 dc.b	$0C,$C0,$FF,$CC,$0C,$C0,$FF,$CC
	 dc.b	$34,$80,$FF,$B4,$78,$00,$FF,$78
	 dc.b	$00,$78,$FF,$78,$00,$B4,$FF,$B4
	 dc.b	$00,$CC,$FF,$CC,$00,$CC,$FF,$CC
	 dc.b	$00,$CC,$FF,$CC,$00,$B4,$FF,$B4
	 dc.b	$00,$78,$FF,$78,$00,$B4,$FF,$B4
	 dc.b	$00,$CC,$FF,$CC,$00,$CC,$FF,$CC
	 dc.b	$00,$CC,$FF,$CC,$00,$B4,$FF,$B4
	 dc.b	$00,$78,$FF,$78
enemydead:
	dc.w	0
cheatmode:
	dc.w	-1

list:	blk.b	2024,-1

scr:
*	blk.b	512000,0	;as we are given all memory this should
				;be sufficient
