
sup:    clr.l   -(sp)
        move.w  #$20,-(sp)
        trap    #1
        addq.l  #6,sp
	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
	move.w  #-1,ynflg       
	move.w	#-1,bynflg
	move.w	#-1,outflg
	move.w	#-1,gynflg
	move.w	#150,ghostx
	move.w	#20,ghosty
	move.w	#24,bally
	move.w	#149,ballx
	move.b	#0,$484		;turn key click and repeat off
	move.w	#0,nbrks
	move.w	#0,nrem
	move.w	#-1,current
	move.w	#1,plev
	move.w	#0,score
	move.w	#4,bound
	move.w	#-1,brick
	move.w	#-1,brtimes
	move.w	#3,xvel
	move.w	#0,lev
	move.w	#0,count
	move.w	#10,pdelay
	move.w	#0,yvel
	move.w	#150,bbx
	move.w	#97,bby
	move.l	#$ffffc00,kkk
	jsr	mousof
        jsr     getscrn
	move.l	screen,d1
	addi.l	#$8000,d1
        move.l  d1,batadd
        move.l  d1,tempad
	move.l	d1,ballad
	move.l	d1,ghostad
	move.l	d1,safe
	move.w	#-1,fast
	jsr	linea	
	jsr	colors
	jsr	loadscr
	jsr	loadtit
	jsr     clearsc
	move.l	screen3,which	;title screen in screen3
	jsr	copysc
	lea	ball,a0
	jsr	putvbl
	move.w	#2,xvel
	move.w	#2,yvel
	jsr	putrout
	jsr	wait
	move.w	#0,xvel
	move.w	#0,yvel
	jsr	testd
	move.w	#0,$452
	move.w	#-1,bynflg
	move.l	screen2,which	;main screen in screen2
	jsr	copysc	
	jsr	putfirst
	jsr	prtbnd
	jsr	prtlev
	lea     putsp,a0
	jsr     putvbl
*	jsr	putrout
	lea	prtscr,a0
	jsr	putvbl
	lea	zball,a0
	jsr	putvbl
	lea	ghost,a0
	jsr	putvbl
	move.w	#1,$452
	move.w	#178,bally
*	jsr     colors
start:	jsr	wait2
	jsr	testd
tst:
*	jsr	testd
	jsr	fin
	jsr	ballout
	jsr	quick
	jsr	stick
*	jsr	pause
        jmp     tst

testd:	move.w	#24000,d5
td:	nop
	dbf	d5,td
	rts

*********************pause and jump***************
pause:	clr.l	d0
	move.l	kkk,a1
	move.b	(a1),d0
	btst	#7,d0
	bne	pausehome
	move.b	2(a1),d0
	btst	#7,d0
	bne	pausehome
	cmpi.b	#127,d0
	bgt	pausehome
	cmpi.b	#1,d0
	bne	pausehome
	move.w	#0,$452
pa1:	clr.l	d0
	move.b	(a1),d0
	btst	#7,d0
	bne	pa1
	move.b	2(a1),d0
	btst	#7,d0
	bne	pa1
	cmpi.b	#127,d0
	bgt	pa1
	cmpi.b	#114,d0
	beq	jumplev
	move.w	#1,$452
	rts

jumplev:rts


pausehome:
	rts
********************vbi to pulse red**************
pulse:	move.w	pdelay,d0
	tst.w	d0
	bge	pback
	clr.l	d0
	move.w	count,d0
	move.l	#redcol,a1
	move.w	(a1,d0),$ff8258
	cmpi.w	#10,count
	blt	pback2
	move.w	#0,count
	rts
pback2:	addq.w	#2,count
	move.w	#8,pdelay
	rts	
pback:	subq.w	#1,pdelay
	rts

*********************stick to bat*******************
stick:	move.w	catches,d0
	tst.w	d0
	bmi	sthome
	cmpi.w	#175,bally
	ble	sthome
	move.w	mx,d0
	cmp.w	ballx,d0
	bgt	sthome
	addi.w	#32,d0
	cmp.w	ballx,d0
	blt	sthome	
	cmpi.w	#2,buttondat
	bne	sthome
st:	cmpi.w	#2,buttondat
	bne	sthome2
	move.w	#0,xvel
	move.w	#0,yvel
	move.w	mx,d0
	addi.w	#12,d0
	move.w	d0,ballx
	bra	st
sthome2:move.w	#2,xvel
	move.w	#-2,yvel
	subq.w	#1,catches
	rts
sthome:	rts

*********************test if ball should go faster**********
quick:	move.w	buttondat,d1
	cmpi.w	#1,d1
	beq	qhome
	rts
qhome:	move.w	#1,fast
	rts
*************ball out***************
ballout:move.w	outflg,d0
	tst.w	d0
	bmi	outback
	move.w	#0,xvel
	move.w	#0,yvel
	move.w	#178,bally
	move.w	#-1,fast
	jsr	testd
	move.w	#0,$452
	move.l	#boom,-(sp)
	move.w	#32,-(sp)
	trap	#14
	addq.l	#6,sp
	move.w	#13,d0
	move.l	#boomcol,a0
	move.l	#$ff8240,a1
bc:	move.w	(a0)+,(a1)
	jsr	boomdel
	dbf	d0,bc
	subq.w	#1,bound
	move.w	bound,d0
	tst.w	d0
	bmi	playerdead
	jsr	prtbnd
	move.w	#1,$452
	jsr	wait2
	move.w	#-1,outflg
outback:rts
boomdel:move.w	#50000,d5
bd1:	nop
	dbf	d5,bd1
	rts

******************wait two**************
wait2:	move.w	buttondat,d0
	tst.w	d0
	bgt	w2home
	move.w	mx,d0
	addi.w	#12,d0
	move.w	d0,ballx
	bra	wait2
w2home:	move.w	#2,xvel
	move.w	#-2,yvel
	rts


****************player dead*******************
playerdead:
        move.w  #-1,ynflg       
	move.w	#-1,bynflg
	move.w	#-1,outflg
	move.w	#-1,gynflg
	move.w	#178,bally
	move.w	#150,ballx
	move.l	safe,ghostad
	move.w	#-1,current
	move.w	#-1,fast
	move.w	#0,nbrks
	move.w	#0,nrem
	move.w	#1,plev
	move.w	#4,bound
	move.w	#-1,brick
	move.w	#-1,brtimes
	move.w	#0,xvel
	move.w	#0,lev
	move.w	#0,yvel
	move.w	#150,bbx
	move.w	#97,bby
	move.l	screen3,which
	jsr	copysc
	jsr	prtscr
	jsr	wait
	move.l	screen2,which
	move.w	#0,score
	jsr	copysc
	jsr	prtlev
	jsr	prtbnd
	jsr	putfirst
	move.w	#1,$452
	jsr	wait2
	bra	start
*******************all bricks dead?*************
fin:	move.w	nbrks,d0
	move.w	nrem,d1
	cmp.w	d0,d1
	blt	finback
*	move.w	#-1,gynflg
	move.w	#192,ghosty
	move.w	#0,xvel
	move.w	#0,yvel
	move.w	#178,bally
	addq.w	#1,plev
	jsr	testd
	move.w	#0,$452
	jsr	prtlev
	addq.w	#4,lev
	move.w	#-1,fast
	jsr	putfirst
	move.w	#1,$452
	jsr	wait2
	move.w	#0,nrem
	rts

finback:rts



******************remove a brick******************
rembrick:
	move.w	#-1,brtimes
	addi.w	#2,score
	clr.l	d4
	clr.l	d5
	move.w	bbx,d5
	move.w	bby,d4
	divu	#16,d5
	divu	#8,d4
	mulu	#16,d5		;x
	mulu	#8,d4		;y
	move.w	current,d0
	tst.w	d0
	bge	rr1
	clr.l	d0
	move.w	#17,-(sp)
	trap	#14
	addq.l	#2,sp
	asr.l	#8,d0
	cmpi.l	#4500,d0
	bgt	rr1
	move.w	d4,ghosty
	move.w	d5,ghostx
	addi.w	#32,ghosty
	move.w	#1,current
rr1:	mulu	#160,d4
	divu	#16,d5
	mulu	#8,d5
	add.w	d5,d4
	add.l	screen,d4
	move.l	d4,a2
rembr:	move.w  #8,d6		;copy height to d1
        subq.w  #1,d6		;height - 1 = height if count starts at zero
rem1:	move.w	#0,d7		;copy width to d0
rem0:	move.l  #0,(a2)+	;move all four planes
        move.l  #0,(a2)+	;(2 longs = 4 words(planes))
        dbf     d7,rem0		;repeat width times
        add.l   #152,a2		;move pointer to next line
        dbf     d6,rem1		;repeat height times
remhome:rts



******************two hit brick******************
tbrick:	move.w	thbrick,d0
	tst.w	d0
	bmi	thhome
	addi.w	#2,score
	move.w	bbx,d2
	move.w	bby,d1
	divu	#16,d2
	divu	#8,d1
	mulu	#16,d2
	mulu	#8,d1
	mulu	#160,d1
	divu	#16,d2
	mulu	#8,d2
	add.w	d2,d1
	add.l	screen,d1
	move.l	d1,a2
	move.l	d1,bad2
	move.w	#8,brtimes
	move.l	#bricks,a1
	addi.l	#128,a1
	move.l	a1,bad
	move.w	#-1,thbrick
thhome:	rts
*******************brick flash***************
	
bflash:	move.w	brtimes,d5	
	tst.w	d5
	bmi	nearth
	move.w  #8,d6		;copy height to d1
        subq.w  #1,d6		;height - 1 = height if count starts at zero
	move.l	bad2,a2	
	move.l	bad,a1
th1:	move.w	#0,d7		;copy width to d0
th0:	move.l  (a1)+,(a2)+	;move all four planes
        move.l  (a1)+,(a2)+	;(2 longs = 4 words(planes))
        dbf     d7,th0		;repeat width times
        add.l   #152,a2		;move pointer to next line
        dbf     d6,th1		;repeat height times
	move.l	a1,bad
	subq.w	#1,d5
	move.w	d5,brtimes
	tst.w	d5
	bmi	nearth
	rts
nearth:	rts




************************put the first bricks****************
putfirst:
	move.w	#5,catches
	move.l	#pattern,a0	
	clr.l	d0
	move.w	lev,d0
	move.l	(a0,d0),a1	;gives addr of pattern data
pf1:	move.w	(a1)+,$ff825a	;colors of bricks
	move.w	(a1)+,$ff825c
	move.w	(a1)+,d0	;number of bricks in pattern
	move.w	d0,nbrks
	addq.w	#1,nbrks
	move.w	(a1)+,a6
pf2:	movem.l	d0-d7/a0-a6,-(a7)
	move.l	#hitbat,-(sp)
	move.w	#32,-(sp)
	trap	#14
	addq.l	#6,sp	
	movem.l	(a7)+,d0-d7/a0-a6
	move.w	(a1)+,d1	;first brick
	mulu	#2,d1		
	move.l	#adds,a0	;screen addresses
	move.w	(a0,d1),a2	;address of brick
	add.l	screen,a2

fillbr:	move.w  #8,d6		;copy height to d1
        subq.w  #1,d6		;height - 1 = height if count starts at zero
        move.l	#bricks,a0	;shifted sprite address
	adda.l	a6,a0

fill1:	move.w	#0,d7		;copy width to d0
fill0:	move.l  (a0)+,(a2)+	;move all four planes
        move.l  (a0)+,(a2)+	;(2 longs = 4 words(planes))
        dbf     d7,fill0	;repeat width times
        add.l   #152,a2		;move pointer to next line
        dbf     d6,fill1	;repeat height times
	jsr	testd
	dbf	d0,pf2
	rts	
	

***************************************
ball:
	jsr	pulse
	jsr	bflash
	move.w	xvel,d0
	move.w	yvel,d1
	add.w	d1,bally
	add.w	d0,ballx
	move.w	bally,d2
	cmpi.w	#190,d2
	bge	bllout
        move.w  ballx,block
        move.w  bally,block+2
        move.w  #$7,block+4
        move.w  #$1,block+6
        move.l  #ballsp,block+8
        move.l  #balltemp,block+12
        move.l  screen,block+16
        move.w  #$1,block+26
        move.l  ballad,block+30
	move.l	#ballad,block+34
	move.w	bynflg,d0
	tst.w	d0
	bmi	cbalc
cblr1:	move.w  block+4,d1        ;copy height to d1
	subq.w  #1,d1           ;height - 1 = height if count starts at zero
        move.l  block+12,a0      ;shifted sprite address
cblr2:	move.w  block+6,d0        ;copy width to d0
        move.l  block+30,a1       ;absolute screen address to a1
        move.l  block+30,d6
cblr3:	move.l  (a0)+,d3        ;move all four planes
        eor.l   d3,(a1)+
        move.l  (a0)+,d3        ;(2 longs = 4 words(planes))
        eor.l   d3,(a1)+
        dbf     d0,cblr3         ;repeat width times
        add.l   #160,block+30     ;move pointer to next line
        dbf     d1,cblr2         ;repeat height times
        move.l  d6,block+30
cba:	move.l	ptsin,a6
	move.w	xvel,d0
	move.w	yvel,d1
	move.w	ballx,(a6)
	move.w	bally,2(a6)
	add.w	d0,(a6)
	add.w	d1,2(a6)
	addq.w	#2,(a6)
	subq.w	#1,2(a6)
	dc.w	getpix
	tst.w	d0
	ble	c1
	neg	yvel
	jsr	hit
c1:	addq.w	#3,(a6)
	addq.w	#3,2(a6)
	dc.w	getpix
	tst.w	d0
	ble	c2
	neg	xvel
	jsr	hit
c2:	addq.w	#3,2(a6)
	subq.w	#3,(a6)
	dc.w	getpix
	tst.w	d0
	ble	c3
	neg	yvel
	jsr	hit
c3:	subq.w	#3,(a6)
	subq.w	#3,2(a6)
	dc.w	getpix
	tst.w	d0
	ble	cbalc
	neg	xvel
	jsr	hit
	bra	cbalc
hit:	cmpi.w	#2,d0		;hit a two hit brick
	bne	hit1
	move.w	(a6),bbx
	move.w	2(a6),bby
	move.w	#1,thbrick
	move.l	#hitbr2,-(sp)
	move.w	#32,-(sp)
	trap	#14
	jsr	tbrick
	addq.l	#6,sp
	rts
hit1:	cmpi.w	#13,d0		;hit a normal brick
	blt	hit2
	move.w	(a6),bbx
	move.w	2(a6),bby
	move.l	#hitbr,-(sp)
	move.w	#32,-(sp)
	trap	#14
	addq.l	#6,sp
	addq.w	#1,nrem
	jsr	rembrick
	rts
hit2:	cmpi.w	#12,d0		;hit red bat
	bne	hit3
	move.l	#hitbat,-(sp)
	move.w	#32,-(sp)
	trap	#14
	addq.l	#6,sp
	move.w	xvel,d1
	tst.w	d1
	bmi	hitneg
	move.w	#4,xvel
	rts
hitneg:	move.w	#-4,xvel
	rts
hit3:	cmpi.w	#11,d0
	bne	hit4
	move.l	#hitbat,-(sp)
	move.w	#32,-(sp)
	trap	#14
	addq.l	#6,sp
	move.w	xvel,d1
	tst.w	d1
	bmi	hitneg2
	move.w	#2,xvel
	rts
hitneg2:move.w	#-2,xvel
	rts
hit4:	move.l	#hitbat,-(sp)
	move.w	#32,-(sp)
	trap	#14
	addq.l	#6,sp
	rts


cbalc:	move.w	#1,bynflg
	clr.l   d0
        move.w  block,d0       ;put x value in d0
        divu    #16,d0          ;divide by 16 leaves word boundry in d0
        move.w  block+2,d1     ;put y value in d1
        mulu    #160,d1         ;gives offset in words of line
        move.w  d0,d3
        mulu    #8,d3
        add     d3,d1           ;gives word to poke sprite
        move.l  block+16,d2    ;put screen address in d2
        add     d1,d2           ;gives actual screen address for sprite
	move.l	block+34,a0
        move.l  d2,(a0)
        move.l  d2,block+20
        asr.l   #8,d0
        asr.l   #8,d0           ;leaves x offset in d0          
        move.w  d0,block+24


*************CODE TO ROTATE A SPRITE IMAGE***********************
*       parameters to be passed on the stack in order are       *       
*       1-      x offset from start of word                     *
*       2-      address of place to put shifted image(tempsp)   *
*       3-      address of sprite data                          *
*       4-      height of object in pixels                      *
*       5-      width of object in words - 1                    *
*****************************************************************
bshiftimage:
        move.w  block+4,d1        ;height in d1
        move.w  block+24,d2       ;offset to d2
        subq.w  #1,d1           ;height - 1 = height if count starts at zero
        subq.w  #1,block+6        ;width - 1 = width if count starts at zero
        move.l  block+8,a0        ;object pointer to a0
        move.l  block+12,a1       ;image pointer to a1
sbi1:   move.w  block+6,d0        ;width in d0
        clr.l   (a1)            ;for each line, the first word of the
        clr.l   4(a1)           ;image must be cleared
sbi0:   clr.l   d4              ;make sure that the top halves of these
        clr.l   d5              ;registers are zeroed out
        clr.l   d6
        clr.l   d7
        move.w  (a0)+,d4        ;load in one word (four planes)
        move.w  (a0)+,d5        ;to be rotated
        move.w  (a0)+,d6
        move.w  (a0)+,d7
        ror.l   d2,d4           ;rotate all planes by the offset(d2)
        ror.l   d2,d5
        ror.l   d2,d6
        ror.l   d2,d7
        or.w    d4,(a1)+        ;add low order bits to the high order bits
        or.w    d5,(a1)+        ;stored by move instructions farther
        or.w    d6,(a1)+        ;down in this routine
        or.w    d7,(a1)+
        swap    d4              ;move high order bits into lower halves
        swap    d5              ;of the registers
        swap    d6
        swap    d7
        move.w  d4,(a1)         ;save the high orders bits to be ORed
        move.w  d5,2(a1)        ;in the loop (do not increment a1 because
        move.w  d6,4(a1)        ;the ORs in the loop must function on
        move.w  d7,6(a1)        ;the same addresses as these moves.
        dbf     d0,sbi0          ;repeat width times
        addq.l  #8,a1           ;new line, move to next word( * 4 planes = 8)
        dbf     d1,sbi1          ;repeat height times
        addi.w  #1,block+6

*********code to put sprite on screen********************
*********parameters to be passed on the stack are********
*********1-     shifted sprite address (tempsp) *********
*********2-     absolute screen address to put image*****
*********3-     height in pixels                *********
*********4-     width in words -1               *********

pbotsp:	move.w  block+4,d1     ;copy height to d1
        subq.w  #1,d1           ;height - 1 = height if count starts at zero
        move.l  block+12,a0    ;shifted sprite address
rbs1:	move.w block+26,d0     ;copy width to d0
        move.l  block+20,a1    ;absolute screen address to a1
        move.l  block+20,d6
rbs0:	move.l  (a0)+,d2	;move all four planes
        eor.l   d2,(a1)+
        move.l  (a0)+,d2	;(2 longs = 4 words(planes))
        eor.l   d2,(a1)+
        dbf     d0,rbs0          ;repeat width times
        add.l   #160,block+20  ;move pointer to next line
        dbf     d1,rbs1          ;repeat height times
        move.l  d6,block+20
bdone:	rts                     ;done


bllout:move.w	#1,outflg
	rts

***************************************
ghost:	move.w	current,d0
	tst.w	d0
	bmi	gdone	
	addq.w	#2,ghosty
        move.w  ghostx,gblock
        move.w  ghosty,gblock+2
        move.w  #$8,gblock+4
        move.w  #$1,gblock+6
        move.l  #ghostbr,gblock+8
        move.l  #ghosttemp,gblock+12
        move.l  screen,gblock+16
        move.w  #$1,gblock+26
        move.l  ghostad,gblock+30
	move.l	#ghostad,gblock+34
	move.w	gynflg,d0
	tst.w	d0
	bmi	gcalc
gblr1:	move.w  gblock+4,d1        ;copy height to d1
	subq.w  #1,d1           ;height - 1 = height if count starts at zero
        move.l  gblock+12,a0      ;shifted sprite address
gblr2:	move.w  gblock+6,d0        ;copy width to d0
        move.l  gblock+30,a1       ;absolute screen address to a1
        move.l  gblock+30,d6
gblr3:	move.l  (a0)+,d3        ;move all four planes
        eor.l   d3,(a1)+
        move.l  (a0)+,d3        ;(2 longs = 4 words(planes))
        eor.l   d3,(a1)+
        dbf     d0,gblr3         ;repeat width times
        add.l   #160,gblock+30     ;move pointer to next line
        dbf     d1,gblr2         ;repeat height times
        move.l  d6,gblock+30
	move.w	ghosty,d2
	cmpi.w	#190,d2
	bge	ghostout

ghit:	move.l	ptsin,a5
	move.w	ghosty,2(a5)
	move.w	ghostx,(a5)
	addi.w	#12,2(a5)
	dc.w	getpix
	cmpi.w	#8,d0
	ble	ghit2
	cmpi.w	#13,d0
	bge	ghit2
	move.w	#-1,current
	move.w	#-1,gynflg
	bra	gout2
ghit2:	addq.w	#4,(a5)
	dc.w	getpix
	cmpi.w	#8,d0
	ble	ghit3
	cmpi.w	#13,d0
	bge	ghit3
	move.w	#-1,current
	move.w	#-1,gynflg
	bra	gout2
	
ghit3:	addq.w	#4,(a5)
	dc.w	getpix
	cmpi.w	#8,d0
	ble	ghit4
	cmpi.w	#13,d0
	bge	ghit4
	move.w	#-1,current
	move.w	#-1,gynflg
	bra	gout2

ghit4:	addq.w	#4,(a5)
	dc.w	getpix
	cmpi.w	#8,d0
	ble	gcalc
	cmpi.w	#13,d0
	bge	gcalc
	move.w	#-1,current
	move.w	#-1,gynflg
	bra	gout2

gcalc:	move.w	#1,gynflg
	clr.l   d0
        move.w  gblock,d0       ;put x value in d0
        divu    #16,d0          ;divide by 16 leaves word boundry in d0
        move.w  gblock+2,d1     ;put y value in d1
        mulu    #160,d1         ;gives offset in words of line
        move.w  d0,d3
        mulu    #8,d3
        add     d3,d1           ;gives word to poke sprite
        move.l  gblock+16,d2    ;put screen address in d2
        add     d1,d2           ;gives actual screen address for sprite
	move.l	gblock+34,a0
        move.l  d2,(a0)
        move.l  d2,gblock+20
        asr.l   #8,d0
        asr.l   #8,d0           ;leaves x offset in d0          
        move.w  d0,gblock+24


*************CODE TO ROTATE A SPRITE IMAGE***********************
*       parameters to be passed on the stack in order are       *       
*       1-      x offset from start of word                     *
*       2-      address of place to put shifted image(tempsp)   *
*       3-      address of sprite data                          *
*       4-      height of object in pixels                      *
*       5-      width of object in words - 1                    *
*****************************************************************
gshiftimage:
        move.w  gblock+4,d1        ;height in d1
        move.w  gblock+24,d2       ;offset to d2
        subq.w  #1,d1           ;height - 1 = height if count starts at zero
        subq.w  #1,gblock+6        ;width - 1 = width if count starts at zero
        move.l  gblock+8,a0        ;object pointer to a0
        move.l  gblock+12,a1       ;image pointer to a1
gsbi1:   move.w  gblock+6,d0        ;width in d0
        clr.l   (a1)            ;for each line, the first word of the
        clr.l   4(a1)           ;image must be cleared
gsbi0:   clr.l   d4              ;make sure that the top halves of these
        clr.l   d5              ;registers are zeroed out
        clr.l   d6
        clr.l   d7
        move.w  (a0)+,d4        ;load in one word (four planes)
        move.w  (a0)+,d5        ;to be rotated
        move.w  (a0)+,d6
        move.w  (a0)+,d7
        ror.l   d2,d4           ;rotate all planes by the offset(d2)
        ror.l   d2,d5
        ror.l   d2,d6
        ror.l   d2,d7
        or.w    d4,(a1)+        ;add low order bits to the high order bits
        or.w    d5,(a1)+        ;stored by move instructions farther
        or.w    d6,(a1)+        ;down in this routine
        or.w    d7,(a1)+
        swap    d4              ;move high order bits into lower halves
        swap    d5              ;of the registers
        swap    d6
        swap    d7
        move.w  d4,(a1)         ;save the high orders bits to be ORed
        move.w  d5,2(a1)        ;in the loop (do not increment a1 because
        move.w  d6,4(a1)        ;the ORs in the loop must function on
        move.w  d7,6(a1)        ;the same addresses as these moves.
        dbf     d0,gsbi0          ;repeat width times
        addq.l  #8,a1           ;new line, move to next word( * 4 planes = 8)
        dbf     d1,gsbi1          ;repeat height times
        addi.w  #1,gblock+6

*********code to put sprite on screen********************
*********parameters to be passed on the stack are********
*********1-     shifted sprite address (tempsp) *********
*********2-     absolute screen address to put image*****
*********3-     height in pixels                *********
*********4-     width in words -1               *********

gpotsp:	move.w  gblock+4,d1     ;copy height to d1
        subq.w  #1,d1           ;height - 1 = height if count starts at zero
        move.l  gblock+12,a0    ;shifted sprite address
grbs1:	move.w gblock+26,d0     ;copy width to d0
        move.l  gblock+20,a1    ;absolute screen address to a1
        move.l  gblock+20,d6
grbs0:	move.l  (a0)+,d2	;move all four planes
        eor.l   d2,(a1)+
        move.l  (a0)+,d2	;(2 longs = 4 words(planes))
        eor.l   d2,(a1)+
        dbf     d0,grbs0          ;repeat width times
        add.l   #160,gblock+20  ;move pointer to next line
        dbf     d1,grbs1          ;repeat height times
        move.l  d6,gblock+20
gdone:	rts                     ;done


ghostout:
	move.l	safe,ghostad
	move.w	#1,goutflg
	move.w	#-1,current
	rts
gout2:	move.l	safe,ghostad
	addi.w	#25,score
	rts


***************************************
zball:	move.w	fast,d0
	tst.w	d0
	bmi	zbdone
	move.w	xvel,d0
	move.w	yvel,d1
	add.w	d1,bally
	add.w	d0,ballx
	move.w	bally,d2
	cmpi.w	#190,d2
	bge	zbllout
        move.w  ballx,block
        move.w  bally,block+2
        move.w  #$7,block+4
        move.w  #$1,block+6
        move.l  #ballsp,block+8
        move.l  #balltemp,block+12
        move.l  screen,block+16
        move.w  #$1,block+26
        move.l  ballad,block+30
	move.l	#ballad,block+34
	move.w	bynflg,d0
	tst.w	d0
	bmi	zcbalc
zcblr1:	move.w  block+4,d1        ;copy height to d1
	subq.w  #1,d1           ;height - 1 = height if count starts at zero
        move.l  block+12,a0      ;shifted sprite address
zcblr2:	move.w  block+6,d0        ;copy width to d0
        move.l  block+30,a1       ;absolute screen address to a1
        move.l  block+30,d6
zcblr3:	move.l  (a0)+,d3        ;move all four planes
        eor.l   d3,(a1)+
        move.l  (a0)+,d3        ;(2 longs = 4 words(planes))
        eor.l   d3,(a1)+
        dbf     d0,zcblr3         ;repeat width times
        add.l   #160,block+30     ;move pointer to next line
        dbf     d1,zcblr2         ;repeat height times
        move.l  d6,block+30
	jsr	bflash
zcba:	move.l	ptsin,a6
	move.w	xvel,d0
	move.w	yvel,d1
	move.w	ballx,(a6)
	move.w	bally,2(a6)
	add.w	d0,(a6)
	add.w	d1,2(a6)
	addq.w	#2,(a6)
	subq.w	#1,2(a6)
	dc.w	getpix
	tst.w	d0
	ble	zc1
	neg	yvel
	jsr	zhit
zc1:	addq.w	#3,(a6)
	addq.w	#3,2(a6)
	dc.w	getpix
	tst.w	d0
	ble	zc2
	neg	xvel
	jsr	zhit
zc2:	addq.w	#3,2(a6)
	subq.w	#3,(a6)
	dc.w	getpix
	tst.w	d0
	ble	zc3
	neg	yvel
	jsr	zhit
zc3:	subq.w	#3,(a6)
	subq.w	#3,2(a6)
	dc.w	getpix
	tst.w	d0
	ble	zcbalc
	neg	xvel
	jsr	zhit
	bra	zcbalc
zhit:	cmpi.w	#2,d0		;hit a two hit brick
	bne	zhit1
	move.w	(a6),bbx
	move.w	2(a6),bby
	move.w	#1,thbrick
	move.l	#hitbr2,-(sp)
	move.w	#32,-(sp)
	trap	#14
	jsr	tbrick
	addq.l	#6,sp
	rts
zhit1:	cmpi.w	#13,d0		;hit a normal brick
	blt	zhit2
	move.w	(a6),bbx
	move.w	2(a6),bby
	move.l	#hitbr,-(sp)
	move.w	#32,-(sp)
	trap	#14
	addq.l	#6,sp
	addq.w	#1,nrem
	jsr	rembrick
	rts
zhit2:	cmpi.w	#12,d0
	bne	zhit3
	move.l	#hitbat,-(sp)
	move.w	#32,-(sp)
	trap	#14
	addq.l	#6,sp
	move.w	xvel,d1
	tst.w	d1
	bmi	zhitneg
	move.w	#3,xvel
	rts
zhitneg:move.w	#-3,xvel
	rts
zhit3:	cmpi.w	#11,d0
	bne	zhit4
	move.l	#hitbat,-(sp)
	move.w	#32,-(sp)
	trap	#14
	addq.l	#6,sp
	move.w	xvel,d1
	tst.w	d1
	bmi	zhitneg2
	move.w	#2,xvel
	rts
zhitneg2:move.w	#-2,xvel
	rts
zhit4:	move.l	#hitbat,-(sp)
	move.w	#32,-(sp)
	trap	#14
	addq.l	#6,sp
	rts


zcbalc:	move.w	#1,bynflg
	clr.l   d0
        move.w  block,d0       ;put x value in d0
        divu    #16,d0          ;divide by 16 leaves word boundry in d0
        move.w  block+2,d1     ;put y value in d1
        mulu    #160,d1         ;gives offset in words of line
        move.w  d0,d3
        mulu    #8,d3
        add     d3,d1           ;gives word to poke sprite
        move.l  block+16,d2    ;put screen address in d2
        add     d1,d2           ;gives actual screen address for sprite
	move.l	block+34,a0
        move.l  d2,(a0)
        move.l  d2,block+20
        asr.l   #8,d0
        asr.l   #8,d0           ;leaves x offset in d0          
        move.w  d0,block+24


*************CODE TO ROTATE A SPRITE IMAGE***********************
*       parameters to be passed on the stack in order are       *       
*       1-      x offset from start of word                     *
*       2-      address of place to put shifted image(tempsp)   *
*       3-      address of sprite data                          *
*       4-      height of object in pixels                      *
*       5-      width of object in words - 1                    *
*****************************************************************
zbshiftimage:
        move.w  block+4,d1        ;height in d1
        move.w  block+24,d2       ;offset to d2
        subq.w  #1,d1           ;height - 1 = height if count starts at zero
        subq.w  #1,block+6        ;width - 1 = width if count starts at zero
        move.l  block+8,a0        ;object pointer to a0
        move.l  block+12,a1       ;image pointer to a1
zsbi1:   move.w  block+6,d0        ;width in d0
        clr.l   (a1)            ;for each line, the first word of the
        clr.l   4(a1)           ;image must be cleared
zsbi0:   clr.l   d4              ;make sure that the top halves of these
        clr.l   d5              ;registers are zeroed out
        clr.l   d6
        clr.l   d7
        move.w  (a0)+,d4        ;load in one word (four planes)
        move.w  (a0)+,d5        ;to be rotated
        move.w  (a0)+,d6
        move.w  (a0)+,d7
        ror.l   d2,d4           ;rotate all planes by the offset(d2)
        ror.l   d2,d5
        ror.l   d2,d6
        ror.l   d2,d7
        or.w    d4,(a1)+        ;add low order bits to the high order bits
        or.w    d5,(a1)+        ;stored by move instructions farther
        or.w    d6,(a1)+        ;down in this routine
        or.w    d7,(a1)+
        swap    d4              ;move high order bits into lower halves
        swap    d5              ;of the registers
        swap    d6
        swap    d7
        move.w  d4,(a1)         ;save the high orders bits to be ORed
        move.w  d5,2(a1)        ;in the loop (do not increment a1 because
        move.w  d6,4(a1)        ;the ORs in the loop must function on
        move.w  d7,6(a1)        ;the same addresses as these moves.
        dbf     d0,zsbi0          ;repeat width times
        addq.l  #8,a1           ;new line, move to next word( * 4 planes = 8)
        dbf     d1,zsbi1          ;repeat height times
        addi.w  #1,block+6

*********code to put sprite on screen********************
*********parameters to be passed on the stack are********
*********1-     shifted sprite address (tempsp) *********
*********2-     absolute screen address to put image*****
*********3-     height in pixels                *********
*********4-     width in words -1               *********

zpbotsp:move.w  block+4,d1     ;copy height to d1
        subq.w  #1,d1           ;height - 1 = height if count starts at zero
        move.l  block+12,a0    ;shifted sprite address
zrbs1:	move.w block+26,d0     ;copy width to d0
        move.l  block+20,a1    ;absolute screen address to a1
        move.l  block+20,d6
zrbs0:	move.l  (a0)+,d2	;move all four planes
        eor.l   d2,(a1)+
        move.l  (a0)+,d2	;(2 longs = 4 words(planes))
        eor.l   d2,(a1)+
        dbf     d0,zrbs0          ;repeat width times
        add.l   #160,block+20  ;move pointer to next line
        dbf     d1,zrbs1          ;repeat height times
        move.l  d6,block+20
zbdone:	rts                     ;done


zbllout:move.w	#1,outflg
	rts







***********************fancy clear screen****************
clearsc:move.l  #99,d0
        move.l  screen,a0
cl1:    move.w  #159,d1
cl2:    move.w  #0,(a0)+
        dbf     d1,cl2
        addi.l  #160,a0
        jsr     cldel
        dbf     d0,cl1
        move.w  #99,d0
        move.l  screen,a0
        addi.l  #160,a0
cl3:    move.w  #159,d1
cl4:    move.w  #0,(a0)+
        dbf     d1,cl4
        addi.l  #160,a0
        jsr     cldel
        dbf     d0,cl3
        rts


cldel:  move.w  #3000,d2
cdel1:  nop
        dbf     d2,cdel1
        rts
********************fancy copy screen*************
copysc: move.w  #99,d0
        move.l  screen,a0
        move.l  which,a1
cop1:   move.w  #159,d1
cop2:   move.w  (a1)+,(a0)+
        dbf     d1,cop2
        addi.l  #160,a0
        addi.l  #160,a1
        jsr     cldel
        dbf     d0,cop1
        move.w  #99,d0
        move.l  screen,a0
        addi.l  #160,a0
        move.l  which,a1
        addi.l  #160,a1
cop3:   move.w  #159,d1
cop4:   move.w  (a1)+,(a0)+
        dbf     d1,cop4
        addi.l  #160,a0
        addi.l  #160,a1
        jsr     cldel
        dbf     d0,cop3
        rts
**********************routine to print a dec nuber*************
prtlev:

        move.l  #0,d7
        move.w  plev,d7
        andi.l  #$ffff,d7
        move.l  #line,a5

dodec:  move.l  d7,d6
        divu    #10,d6
        move.w  d6,d7
        swap    d6
        addi.w  #16,d6
        move.b  d6,(a5)+
        cmpi.w  #0,d7
        bne     dodec

        move.l  #pos,-(sp)
        move.w  #9,-(sp)
        trap    #1
        addq.l  #6,sp
        move.l  #col,-(sp)
        move.w  #9,-(sp)
        trap    #1
        addq.l  #6,sp

out:    cmpa.l  #line,a5
        beq     decback

        move.b  -(a5),d7
        andi.w  #$ff,d7
        
        move.w  d7,-(sp)
	move.w	#5,-(sp)
        move.w  #3,-(sp)
        trap    #13
        addq.l  #6,sp

        bra     out


decback: rts


****************print score************
prtscr:
	move.l  #0,d7
        move.w  score,d7
	andi.l  #$ffff,d7
        move.l  #line,a5

sodec:  move.l  d7,d6
        divu    #10,d6
        move.w  d6,d7
        swap    d6
        addi.w  #16,d6
        move.b  d6,(a5)+
        cmpi.w  #0,d7
        bne     sodec

        move.l  #spos,-(sp)
        move.w  #9,-(sp)
        trap    #1
        addq.l  #6,sp
        move.l  #col,-(sp)
        move.w  #9,-(sp)
        trap    #1
        addq.l  #6,sp

sout:	cmpa.l  #line,a5
        beq     secback

        move.b  -(a5),d7
        andi.w  #$ff,d7
        
        move.w  d7,-(sp)
	move.w	#5,-(sp)
        move.w  #3,-(sp)
        trap    #13
        addq.l  #6,sp

        bra     sout
secback:clr.l	d0
	move.w	score,d0
	cmpi.l	#65000,d0
	bgt	ppp
	rts
ppp:	move.w  #6,d1     ;copy height to d1
        move.l  #76,a0    ;shifted sprite address
	addi.l	screen,a0
pp1:	move.w	#2,d0
pp2:	move.l	#0,(a0)+
	move.l	#0,(a0)+
	dbf	d0,pp2
	addi.l	#136,a0
	dbf	d1,pp1

	move.w	#0,score
	rts

****************print bounders left************
prtbnd:	move.l  #0,d7
        move.w  bound,d7
        andi.l  #$ffff,d7
        move.l  #line,a5

bodec:  move.l  d7,d6
        divu    #10,d6
        move.w  d6,d7
        swap    d6
        addi.w  #16,d6
        move.b  d6,(a5)+
        cmpi.w  #0,d7
        bne     bodec

        move.l  #bpos,-(sp)
        move.w  #9,-(sp)
        trap    #1
        addq.l  #6,sp
        move.l  #col,-(sp)
        move.w  #9,-(sp)
        trap    #1
        addq.l  #6,sp

bout:	cmpa.l  #line,a5
        beq     becback

        move.b  -(a5),d7
        andi.w  #$ff,d7
        
        move.w  d7,-(sp)
	move.w	#5,-(sp)
        move.w  #3,-(sp)
        trap    #13
        addq.l  #6,sp

        bra     bout


becback:rts

*************puts my mouse interupt in***************** 
***************************************
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
*	lsl.w	#6,d0
*	lsl.w	#6,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  #mmaxy,d1
        bra	extra4
extra3: cmpi.w   #mmaxy,d1
        ble    .S extra4
        move.w  #mminy,d1
extra4:
        rts

buttondat:	dc.w	0
mx:		dc.w	160
my:		dc.w	100

mminx:	equ	16	;13
mmaxx:	equ	275
mminy:	equ	0	;3
mmaxy:	equ	255	; 13 123
**************my ubeut mouse interupt*******************


************code to determine  x offset *****************
*               and absolute screen address             *
*               parameters to pass on stack as follows  *
*               1-      x of sprite                     *
*               2-      y of sprite                     *
*               3-      screen address                  *
*       paremeters returned are x offset in d0          *
*       absolute screen address in d2                   *
*********************************************************
putsp:	
************bat********************
bat:	move.w  mx,pblock
        move.w  #186,pblock+2
        move.w  #$e,pblock+4
        move.w  #$2,pblock+6
        move.l  #batsp,pblock+8
        move.l  #battemp,pblock+12
        move.l  screen,pblock+16
        move.w  #$2,pblock+26
        move.l  batadd,pblock+30
	move.l	#batadd,pblock+34
	move.w	ynflg,d0
	tst.w	d0
	bmi	calc

clr1:   move.w  pblock+4,d1        ;copy height to d1
        subq.w  #1,d1           ;height - 1 = height if count starts at zero
        move.l  pblock+12,a0      ;shifted sprite address
clr2:   move.w  pblock+6,d0        ;copy width to d0
        move.l  pblock+30,a1       ;absolute screen address to a1
        move.l  pblock+30,d6
clr3:   move.l  (a0)+,d3        ;move all four planes
        eor.l   d3,(a1)+
        move.l  (a0)+,d3        ;(2 longs = 4 words(planes))
        eor.l   d3,(a1)+
        dbf     d0,clr3         ;repeat width times
        add.l   #160,pblock+30     ;move pointer to next line
        dbf     d1,clr2         ;repeat height times
        move.l  d6,pblock+30
	move.w	ynflg,d0
	tst.w	d0
	bge	calc
	move.l	ptsin,a0
	move.w	ballx+2,(a0)
	move.w	bally+2,2(a0)
	dc.w	getpix
	cmpi.w	#5,d0
	ble	calc
	neg	xvel
	neg	yvel	

calc:	move.w	#1,ynflg
	clr.l   d0
        move.w  pblock,d0       ;put x value in d0
        divu    #16,d0          ;divide by 16 leaves word boundry in d0
        move.w  pblock+2,d1     ;put y value in d1
        mulu    #160,d1         ;gives offset in words of line
        move.w  d0,d3
        mulu    #8,d3
        add     d3,d1           ;gives word to poke sprite
        move.l  pblock+16,d2    ;put screen address in d2
        add     d1,d2           ;gives actual screen address for sprite
	move.l	pblock+34,a0
        move.l  d2,(a0)
        move.l  d2,pblock+20
        asr.l   #8,d0
        asr.l   #8,d0           ;leaves x offset in d0          
        move.w  d0,pblock+24


*************CODE TO ROTATE A SPRITE IMAGE***********************
*       parameters to be passed on the stack in order are       *       
*       1-      x offset from start of word                     *
*       2-      address of place to put shifted image(tempsp)   *
*       3-      address of sprite data                          *
*       4-      height of object in pixels                      *
*       5-      width of object in words - 1                    *
*****************************************************************
shiftimage:
        move.w  pblock+4,d1        ;height in d1
        move.w  pblock+24,d2       ;offset to d2
        subq.w  #1,d1           ;height - 1 = height if count starts at zero
        subq.w  #1,pblock+6        ;width - 1 = width if count starts at zero
        move.l  pblock+8,a0        ;object pointer to a0
        move.l  pblock+12,a1       ;image pointer to a1
si1:    move.w  pblock+6,d0        ;width in d0
        clr.l   (a1)            ;for each line, the first word of the
        clr.l   4(a1)           ;image must be cleared
si0:    clr.l   d4              ;make sure that the top halves of these
        clr.l   d5              ;registers are zeroed out
        clr.l   d6
        clr.l   d7
        move.w  (a0)+,d4        ;load in one word (four planes)
        move.w  (a0)+,d5        ;to be rotated
        move.w  (a0)+,d6
        move.w  (a0)+,d7
        ror.l   d2,d4           ;rotate all planes by the offset(d2)
        ror.l   d2,d5
        ror.l   d2,d6
        ror.l   d2,d7
        or.w    d4,(a1)+        ;add low order bits to the high order bits
        or.w    d5,(a1)+        ;stored by move instructions farther
        or.w    d6,(a1)+        ;down in this routine
        or.w    d7,(a1)+
        swap    d4              ;move high order bits into lower halves
        swap    d5              ;of the registers
        swap    d6
        swap    d7
        move.w  d4,(a1)         ;save the high orders bits to be ORed
        move.w  d5,2(a1)        ;in the loop (do not increment a1 because
        move.w  d6,4(a1)        ;the ORs in the loop must function on
        move.w  d7,6(a1)        ;the same addresses as these moves.
        dbf     d0,si0          ;repeat width times
        addq.l  #8,a1           ;new line, move to next word( * 4 planes = 8)
        dbf     d1,si1          ;repeat height times
        addi.w  #1,pblock+6

*********code to put sprite on screen********************
*********parameters to be passed on the stack are********
*********1-     shifted sprite address (tempsp) *********
*********2-     absolute screen address to put image*****
*********3-     height in pixels                *********
*********4-     width in words -1               *********

potsp:  move.w  pblock+4,d1     ;copy height to d1
        subq.w  #1,d1           ;height - 1 = height if count starts at zero
        move.l  pblock+12,a0    ;shifted sprite address
rs1:    move.w  pblock+26,d0     ;copy width to d0
        move.l  pblock+20,a1    ;absolute screen address to a1
        move.l  pblock+20,d6
rs0:    move.l  (a0)+,d2	;move all four planes
        eor.l   d2,(a1)+
        move.l  (a0)+,d2	;(2 longs = 4 words(planes))
        eor.l   d2,(a1)+
        dbf     d0,rs0          ;repeat width times
        add.l   #160,pblock+20  ;move pointer to next line
        dbf     d1,rs1          ;repeat height times
        move.l  d6,pblock+20
done:	rts                     ;done
*********************joy interupt*********************
getkey:	lea	key,a1
	move.b	(a1),d0
	rts

getjoy1:lea.l   joy1,a1
        move.b  (a1),d0
        rts

getjoy2:lea.l   joy2,a1
        move.b  (a1),d0
        rts




keyset:
*	pea     mess1
*       move.w  #1,-(sp)
*        move.w  #25,-(sp)
*        trap    #14
*        addq.l  #8,sp

*        pea     mess2
*        move.w  #0,-(sp)
*        move.w  #25,-(sp)

*        trap    #14
*        addq.l  #8,sp
        
        move.w  #34,-(sp)
        trap    #14
        addq.l  #2,sp
        move.l  d0,a0
        lea.l   keyint,a1
        move.l  a1,32(a0)
        rts
even
mess1:  dc.b    $12,$14
mess2:  dc.b    $14


even
keyint: lea.l   $fffffc00,a1
        move.b  0(a1),d0
        btst    #7,d0
        beq.s   intk4
        btst    #0,d0
        bne.s   kriti
        andi.b  #$20,d0
        bne.s   kerror
kriti:  movem.l d2/a0-a4,-(sp)
        move.b  2(a1),d0
        lea.l   intwt,a2
        cmpi.b  #0,(a2)
        bne.s   keyj7
        cmpi.b  #$fc,d0
        bcs.s   keyj
        lea.l   joystat,a1
        cmpi.b  #$ff,d0
        bne.s   intk1
        move.b  #2,(a1)
intko:  bra.s   ekraj
kerror: move.b  2(a1),d0
intk4:  rts

ekraj:  movem.l (sp)+,d2/a0-a4
        and.b   #$20,d2
        beq.s   ekraj1
        move.b  2(a1),d0
ekraj1: rts

intk1:  cmpi.b  #$fe,d0
        beq.s   intk2
        lea.l   intwt,a4
        subi.b  #$f6,d0
        and.l   #$ff,d0
        lea.l   kentlen,a3
        move.b  0(a3,d0.w),(a4)
        bra.S   ekraj
intk2:  move.b  #1,(a1)
        bra     ekraj
keyj:   lea.l   intwt,a2
        cmpi.b  #0,(a2)
        beq.s   keyj5
keyj7:  subi.b  #1,(a2)
        bra     ekraj
keyj5:  lea.l   joystat,a1
        btst    #0,(a1)
        bne.s   jop1
        btst    #1,(a1)
        bne.s   jop2
	lea.l   nkey,a3
        move.b  d0,(a3)
        cmpi.b  #$80,d0
        bcs.s   keji
        move.b  #0,d0
        ;
keji:   lea.l   key,a3
keyj1:  move.b  d0,(a3)
        move.b  #0,(a1)
        bra     ekraj
jop1:   lea.l   joy1,a3
        bra.s   keyj1
jop2:   lea.l   joy2,a3
        bra.s   keyj1
scre:   rts
even
nkey:   dc.b    0
key:    dc.b    0
joy1:   dc.b    0
joy2:   dc.b    0
joystat:dc.b    0
intwt:  dc.b    0
kentlen:dc.b    7,5,2,2,2,2,6,2,1,1
bojaflg:dc.b    0
even
        dc.b    0,0,0,0,0,0,0,0
even
setloc: dc.l    0
cintno: dc.b    0
intim:  dc.b    0
        

even


************get screen address***************
getscrn:move.w  #2,-(sp)
        trap    #14
        addq.l  #2,sp
        move.l  d0,screen
        move.l  d0,screen1
        move.l  d0,screen2
        subi.l  #$8000,screen2
	subi.l	#$10000,d0
	move.l	d0,screen3
        rts



************change colors****************
colors: move.l #palette,-(sp)
        move.w #6,-(sp)
        trap #14
        addq.l #6,sp
        rts

*****************wait for a key*********************
wait:   move.w  buttondat,d0
        tst.w	d0
        bgt     wback
        bra     wait
wback:  rts
***************turn mouse off***********************
mousof: dc.w    $a00a   
        rts

******************get line a params and stuff***************
linea:  dc.w    $a000
        move.l  8(a0),intin
        move.l  12(a0),ptsin
*       move.w  #0,36(a0)
        rts



*********************************************************
*       a brilliant routine courtesy of janko to        *
*       insert the vbi addresses in the jump table      *
*       lea address of routine in a0 do a jsr           *
*       putvbl and thats it!!!                          *
*********************************************************


putvbl: lea     $452,a1
        move.w  #1,(a1)
        moveq   #7,d1
        lea     $456,a1
        move.l  (a1),a1
vbl3:   subi.b  #1,d1
        cmpi.b  #0,d1
        beq.s   vbl4
        move.l  (a1)+,d0
        cmpi.l  #0,d0
        bne.S   vbl3
        suba.l  #4,a1
        move.l  a0,(a1)
vbl4:   rts

*********************************************************
*       my routines for loading in the screens          *
*       note i use degas format even though I           *
*       hate the package,due to it's simple format      *
*       ie: 32l for pallette and straight 32k screen    *
*       dump                                            *
*********************************************************

loadscr:move    #0,-(SP)        ;Open file
        move.l  #filename,-(SP) ;Address of filename
        move    #$3D,-(SP)
        trap    #1              ;Get handle number in D0
        addq.l  #8,SP
                
        move    D0,-(SP)        ;Save handle

        move.l  #dummy,-(SP)    ;load pallette into safe area
        move.l  #34,-(SP)       ;length to read in
        move    D0,-(SP)        ;Handle
        move    #$3F,-(SP)      ;bios number
        trap    #1              ;Read file in
        add.l   #12,SP
        move    (sp),d0        
               
        move.l  screen2,-(SP)    ;load it straight onto screen
        move.l  #32000,-(SP)    ;length to read in
        move    D0,-(SP)        ;Handle
        move    #$3F,-(SP)      ;bios number
        trap    #1              ;Read file in
        add.l   #12,SP
                
        move    #$3E,-(SP)      ;Handle already on stack
        trap    #1              ;Close file
        addq.l  #4,SP
        rts
***************************************
loadtit:move    #0,-(SP)        ;Open file
        move.l  #titname,-(SP) ;Address of filename
        move    #$3D,-(SP)
        trap    #1              ;Get handle number in D0
        addq.l  #8,SP
                
        move    D0,-(SP)        ;Save handle

        move.l  #dummy,-(SP)    ;load pallette into safe area
        move.l  #34,-(SP)       ;length to read in
        move    D0,-(SP)        ;Handle
        move    #$3F,-(SP)      ;bios number
        trap    #1              ;Read file in
        add.l   #12,SP
        move    (sp),d0        
               
        move.l  screen3,-(SP)    ;load it straight onto screen
        move.l  #32000,-(SP)    ;length to read in
        move    D0,-(SP)        ;Handle
        move    #$3F,-(SP)      ;bios number
        trap    #1              ;Read file in
        add.l   #12,SP
                
        move    #$3E,-(SP)      ;Handle already on stack
        trap    #1              ;Close file
        addq.l  #4,SP
        rts

*******************blocks for rotated sprites*************
tempsp: blk.w   500
onscreen:       blk.l   1
pblock: blk.l   40
block:	blk.l	40
ghosttemp:	blk.w	500
ghostad:blk.l	1
gynflg:	blk.w	1
gblock:	blk.l	40
ghostx:	blk.w	1
ghosty:	blk.w	1
safe:	blk.l	1
current:blk.w	1
goutflg:blk.w	1
keysav:	blk.l	1
kkk:	blk.l	1
plev:	blk.w	1
pdelay:	blk.w	1
count:	blk.w	1
catches:blk.w	1
fast:	blk.w	1
score:	blk.w	1
bound:	blk.w	1
brtimes:blk.w	1
which:	blk.l	1
bad:	blk.l	1
bad2:	blk.l	1
balldo:	blk.w	1
dir:    blk.w   1
tmx:    blk.w   1
nrem:	blk.w	1
nbrks:	blk.w	1
bynflg:	blk.w	1
bdel:   blk.w   1
screen: blk.l   1
ynflg:  blk.w   1
batadd: blk.l   1
screen2:blk.l   1
screen1:blk.l   1
screen3:blk.l	1
clrbr:	blk.w	50,0
dummy:  blk.l   32
xvel:	blk.w	1
yvel:	blk.w	1
thbrick:blk.w	1
brick:	blk.w	1
lev:	blk.w	1
bbx:	blk.w	1
bby:	blk.w	1
filename:       dc.b    'brkmain.pi1',0  
titname:	dc.b	'brktitle.pi1',0
even
tempad: blk.l   1       
line:   blk.b   10
pos:    dc.b    27,89,32,38,0
col:    dc.b    27,98,15,0
spos:	dc.b	27,89,32,51,0
bpos:	dc.b	27,89,32,69,0
even
oldshad:blk.l   1
bitoffs:blk.w   1
tempsh: blk.l   1
whsp:   blk.w   1
first:  blk.w   1
intin:  blk.l   1
ptsin:  blk.l   1
putpix: equ     $a001
getpix: equ     $a002
lastx:  blk.w   1
lasty:  blk.w   1
area:	blk.w	200
balltemp:	blk.w	500
battemp:blk.w	500
ballx:	blk.w	1
bally:	blk.w	1
ballad:	blk.l	1
outflg:	blk.w	1
even
*  Hardware color pallet  (color 0 to 15):
*
boomcol:dc.w	$0106,$0205,$0304,$0403,$0502,$0601,$0700,$0601
	dc.w	$0502,$0403,$0304,$0205,$0106,$0007
palette:dc.w	$0007,$0005,$0501,$0056,$0045,$0034,$0410,$0520
	dc.w	$0630,$0030,$0250,$0070,$0700,$0224,$0455,$0777


batsp:	dc.w	$007F,$007F,$3F80,$3FFF,$F000,$F000,$0FE0,$FFE0
	dc.w	$00FF,$00FF,$7F00,$7FFF,$F800,$F800,$07F0,$FFF0
	dc.w	$3EFF,$3EFF,$C100,$FFFF,$FBE0,$FBE0,$0418,$FFF8
	dc.w	$1EFF,$7EFF,$8100,$FFFF,$FBC0,$FBF0,$0408,$FFF8
	dc.w	$8000,$7EFF,$0100,$FFFF,$0008,$FBF0,$0400,$FFF8
	dc.w	$C000,$3EFF,$0100,$FFFF,$0018,$FBE0,$0400,$FFF8
	dc.w	$7EFF,$0100,$0100,$7EFF,$FBF0,$0400,$0400,$FBF0
	dc.w	$3EFF,$0100,$0100,$3EFF,$FBF0,$0400,$0400,$FBE0
	dc.w	$0FFF,$0000,$0000,$0000,$FFF8,$0000,$0000,$0000
	dc.w	$1FFF,$0000,$0000,$0000,$FFFC,$0000,$0000,$0000
	dc.w	$1FFF,$0000,$0000,$0000,$FFFC,$0000,$0000,$0000
	dc.w	$1FFF,$0000,$0000,$0000,$FFFC,$0000,$0000,$0000
	dc.w	$0FFF,$0000,$0000,$0000,$FFF8,$0000,$0000,$0000
	dc.w	$07FF,$0000,$0000,$0000,$FFF0,$0000,$0000,$0000


ballsp:	dc.w	$6000,$6000,$6000,$1000,$5000,$D000,$D000,$3800
	dc.w	$4400,$C000,$C000,$3800,$7E00,$F800,$F800,$0000
	dc.w	$0E00,$7000,$7000,$0000,$3E00,$0000,$0000,$0000
	dc.w	$1C00,$0000,$0000,$0000

ghostbr:dc.w	$7FFF,$FFFF,$0000,$FFFF,$8001,$0001,$0000,$8001
	dc.w	$8001,$1EF1,$0000,$9EF1,$8001,$0281,$0000,$8281
	dc.w	$8001,$1EF1,$0000,$9EF1,$8001,$1011,$0000,$9011
	dc.w	$8001,$1EF1,$0000,$9EF1,$FFFE,$0001,$0000,$FFFF



bricks:	dc.w	$7FFF,$FFFF,$FFFF,$FFFF,$8001,$7FFF,$FFFF,$FFFF
	dc.w	$8001,$7FFF,$FFFF,$FFFF,$8001,$7FFF,$FFFF,$FFFF
	dc.w	$8001,$7FFF,$FFFF,$FFFF,$8001,$7FFF,$FFFF,$FFFF
	dc.w	$8001,$7FFF,$FFFF,$FFFF,$FFFE,$0001,$FFFF,$FFFF
	dc.w	$0000,$FFFF,$0000,$0000,$0000,$FFFF,$0000,$0000
	dc.w	$1FF8,$E007,$1FF8,$1FF8,$200C,$FFF3,$3FFC,$3FFC
	dc.w	$3004,$FFFB,$3FFC,$3FFC,$1FF8,$FFFF,$1FF8,$1FF8
	dc.w	$0000,$FFFF,$0000,$0000,$0000,$FFFF,$0000,$0000
	dc.w	$FFFF,$FFFF,$FFFF,$FFFF,$C001,$FFFF,$FFFF,$FFFF
	dc.w	$8001,$FFFF,$FFFF,$FFFF,$8001,$7FFF,$FFFF,$FFFF
	dc.w	$8001,$7FFF,$FFFF,$FFFF,$8001,$7FFF,$FFFF,$FFFF
	dc.w	$8001,$7FFF,$FFFF,$FFFF,$FFFE,$0001,$FFFF,$FFFF
	dc.w	$7FFF,$FFFF,$FFFF,$FFFF,$B001,$7FFF,$FFFF,$FFFF
	dc.w	$E001,$7FFF,$FFFF,$FFFF,$C001,$FFFF,$FFFF,$FFFF
	dc.w	$8001,$FFFF,$FFFF,$FFFF,$8001,$7FFF,$FFFF,$FFFF
	dc.w	$8001,$7FFF,$FFFF,$FFFF,$FFFE,$0001,$FFFF,$FFFF
	dc.w	$FFFF,$FFFF,$FFFF,$FFFF,$8601,$7FFF,$FFFF,$FFFF
	dc.w	$8C01,$7FFF,$FFFF,$FFFF,$9801,$7FFF,$FFFF,$FFFF
	dc.w	$B001,$7FFF,$FFFF,$FFFF,$E001,$7FFF,$FFFF,$FFFF
	dc.w	$C001,$FFFF,$FFFF,$FFFF,$FFFE,$8001,$FFFF,$FFFF
	dc.w	$7FFF,$FFFF,$FFFF,$FFFF,$80C1,$7FFF,$FFFF,$FFFF
	dc.w	$8181,$7FFF,$FFFF,$FFFF,$8301,$7FFF,$FFFF,$FFFF
	dc.w	$8601,$7FFF,$FFFF,$FFFF,$8C01,$7FFF,$FFFF,$FFFF
	dc.w	$9801,$7FFF,$FFFF,$FFFF,$FFFE,$3001,$FFFF,$FFFF
	dc.w	$7FFF,$FFFF,$FFFF,$FFFF,$8019,$7FFF,$FFFF,$FFFF
	dc.w	$8031,$7FFF,$FFFF,$FFFF,$8061,$7FFF,$FFFF,$FFFF
	dc.w	$80C1,$7FFF,$FFFF,$FFFF,$8181,$7FFF,$FFFF,$FFFF
	dc.w	$8301,$7FFF,$FFFF,$FFFF,$FFFE,$0601,$FFFF,$FFFF
	dc.w	$7FFF,$FFFF,$FFFF,$FFFF,$8003,$7FFF,$FFFF,$FFFF
	dc.w	$8007,$7FFF,$FFFF,$FFFF,$800D,$7FFF,$FFFF,$FFFF
	dc.w	$8019,$7FFF,$FFFF,$FFFF,$8031,$7FFF,$FFFF,$FFFF
	dc.w	$8061,$7FFF,$FFFF,$FFFF,$FFFE,$00C1,$FFFF,$FFFF
	dc.w	$7FFF,$FFFF,$FFFF,$FFFF,$8001,$7FFF,$FFFF,$FFFF
	dc.w	$8001,$7FFF,$FFFF,$FFFF,$8001,$7FFF,$FFFF,$FFFF
	dc.w	$8003,$7FFF,$FFFF,$FFFF,$8007,$7FFF,$FFFF,$FFFF
	dc.w	$800D,$7FFF,$FFFF,$FFFF,$FFFE,$0019,$FFFF,$FFFF
	dc.w	$7FFF,$FFFF,$FFFF,$FFFF,$8001,$7FFF,$FFFF,$FFFF
	dc.w	$8001,$7FFF,$FFFF,$FFFF,$8001,$7FFF,$FFFF,$FFFF
	dc.w	$8001,$7FFF,$FFFF,$FFFF,$8001,$7FFF,$FFFF,$FFFF
	dc.w	$8003,$7FFF,$FFFF,$FFFF,$FFFF,$0007,$FFFF,$FFFF
	dc.w	$7FFF,$FFFF,$FFFF,$FFFF,$8001,$7FFF,$FFFF,$FFFF
	dc.w	$8001,$7FFF,$FFFF,$FFFF,$8001,$7FFF,$FFFF,$FFFF
	dc.w	$8001,$7FFF,$FFFF,$FFFF,$8001,$7FFF,$FFFF,$FFFF
	dc.w	$8001,$7FFF,$FFFF,$FFFF,$FFFE,$0001,$FFFF,$FFFF




redcol:	dc.w	$0700,$0600,$0500,$0400,$0500,$0600



*****opening
lev1:	dc.w	$0224,$0455,79,0
	dc.w	37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52
	dc.w	91,92,93,94,95,96,97,98,99,100,101,102,103,104,105
	dc.w	106,145,146,147,148,149,150,151,152,153,154,155
	dc.w	156,157,158,159,160,199,200,201,202,203,204,205
	dc.w	206,207,208,209,210,211,212,213,214,253,254,255
	dc.w	256,257,258,259,260,261,262,263,264,265,266,267,268
**opening double
lev2:	dc.w	$0035,$0057,79,64
	dc.w	37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52
	dc.w	91,92,93,94,95,96,97,98,99,100,101,102,103,104,105
	dc.w	106,145,146,147,148,149,150,151,152,153,154,155
	dc.w	156,157,158,159,160,199,200,201,202,203,204,205
	dc.w	206,207,208,209,210,211,212,213,214,253,254,255
	dc.w	256,257,258,259,260,261,262,263,264,265,266,267,268
***alternate
lev3:	dc.w	$0331,$0657,83,64
	dc.w	36,37,53,90,161,198
	dc.w	38,39,40,41,42,43,44,45,46,47,48,49,50,51,92,93,94,95
	dc.w	96,97,98,99,100,101,102,103,104,105,106,107,
	dc.w	144,145,146,147,148,149,150,151,152,153,154,155,156
	dc.w	157,158,159,200,201,202,203,204,205,206,207,208,209
	dc.w	210,211,212,213,214,215,252,253,254,255,256
	dc.w	257,258,259,260,261,262,263,264,265,266,267
*plus
lev4:	dc.w	$0030,$0060,37,0
	dc.w	44,45,62,63,80,81,98,99,116,117,134,135,152,153
	dc.w	170,171,188,189,206,207,224,225,242,243,260,261	
	dc.w	146,147,148,149,150,151,154,155,156,157,158,159
**arch
lev5:	dc.w	$0405,$0757,83,64
	dc.w	38,39,51,52,56,57,58,59,60,61,62,63,64,65,66,67,68
	dc.w	69,70,74,75,92,93,110,111,128,129,146,147,164,165
	dc.w	182,183,200,201,218,219,236,237,254,255,87,88,105
	dc.w	106,123,124,141,142,159,160,177,178,195,196,213,214
	dc.w	231,232,249,250,267,268,132,133,134,135,136,137,138
	dc.w	150,151,152,153,154,155,156,168,169,170,171,172,173,174

******lots
lev9:	dc.w	$0224,$0455,165,0,36
	dc.w	37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,57,58
	dc.w	59,60,61,62,63,64,65,66,67,68,75,76,77,78,79,80,81,82
	dc.w	83,84,85,86,90,91,92,93,94,95,96,97,98,99,100
	dc.w	101,102,103,104,105,106,107,113,114,115,116,117,118
	dc.w	119,120,132,133,134,135,136,137,144,145,146,147,148
	dc.w	149,150,151,152,153,154,155,156,157,158,159,160,161
	dc.w	168,169,170,171,172,173,185,186,187,188,189,190,191
	dc.w	192,198,199,200,201,202,203,204,205,206,207,208,209
	dc.w	210,211,212,213,214,215,219,220,221,222,223,224,225
	dc.w	226,227,228,229,230,237,238,239,240,241,242,243,244
	dc.w	245,246,247,248,252,253,254,255,256,257,258,259,260
	dc.w	261,262,263,264,265,266,267,268,269

***AM
lev10:	dc.w	$0035,$0057,122,0	
	dc.w	40,41,42,43,44,45,51,57,58,59,60,61,62,63,64,68,69
	dc.w	75,76,77,78,79,80,81,82,83,85,86,87,93,94,97,98,99,100
	dc.w	101,102,103,104,105,111,112,115,116,117,118,119,120
	dc.w	121,122,123,129,130,133,134,135,136,137,138,139,140
	dc.w	141,147,148,149,150,151,152,153,154,156,158,159,165
	dc.w	166,167,168,169,170,171,172,176,177,183,184,187,188
	dc.w	189,190,194,195,201,202,205,206,207,208,212,213,219
	dc.w	220,223,224,225,226,230,231,237,238,241,242,243,244
	dc.w	248,249,255,256,259,260,261,262,266,267
***TB
lev11:	dc.w	$0331,$0651,52,64
	dc.w	76,77,78,79,80,81,82,83,84,85,96,114,132,150,168,186
	dc.w	204,205,222,223,240,241,258,259,99,117,135,153,154
	dc.w	171,172,173,174,189,207,225,226,243,244,261,262,263,264
	dc.w	103,121,139,157,175,193,211,229,247,265
*atari***
lev12:	dc.w	$0030,$0060,67,64
	dc.w	92,105,42,60,78,96,114,132,150,168,186,204,185
	dc.w	202,203,220,221,237,238,254,255,256,44,45,62
	dc.w	63,80,81,98,99,116,117,134,135,152,153,170,171
	dc.w	188,189,206,207,224,225,242,243,260,261,47,65,83,101
	dc.w	119,137,155,173,191,209,192,210,211,228,229,247,248,265
	dc.w	266,267

lev13:	dc.w	$0405,$0707,86,64
	dc.w	58,59,60,61,62,63,64,65,66,67,76,85,94,96,97,98,99
	dc.w	100,101,102,103,112,121,130,131,132,133,134,135,136
	dc.w	137,139,148,157,166,168,169,170,171,172,173,174,175
	dc.w	184,193,202,203,204,205,206,207,208,209,211,220,229
	dc.w	238,239,240,241,242,243,244,245,246,247,256,265,274
	dc.w	275,276,277,278,279,280,281,283,288,289,290,291,292
	dc.w	301,302,303,304,305

lev14:	dc.w	$0035,$0057,69,64
	dc.w	292,300,303,290,297,298
	dc.w	293,294,295,296,299,301,302,291,252,253,254,255
	dc.w	256,257,258,259,262,263,264,265,266,267,268,269,221
	dc.w	222,223,224,225,226,227,228,180,181,182,183,184,185
	dc.w	186,187,190,191,192,193,194,195,196,197,25,43,61,79
	dc.w	97,115,133,151,28,46,64,82,100,118,136,154	
lev15:	dc.w	$0244,$0355,10,0
	dc.w	18,19,20,21,22,23,24,25,26,27,28

pattern:
	dc.l	lev1,lev2,lev3,lev4,lev5,lev9
	dc.l	lev10,lev11,lev12,lev13,lev14


adds:	dc.w	2568,2576,2584,2592,2600,2608,2616,2624,2632,2640
	dc.w	2648,2656,2664,2672,2680,2688,2696,2704
	dc.w	3848,3856,3864,3872,3880,3888,3896,3904,3912,3920
	dc.w	3928,3936,3944,3952,3960,3968,3976,3984
	dc.w	5128,5136,5144,5152,5160,5168,5176,5184,5192,5200
	dc.w	5208,5216,5224,5232,5240,5248,5256,5264
	dc.w	6408,6416,6424,6432,6440,6448,6456,6464,6472,6480
	dc.w	6488,6496,6504,6512,6520,6528,6536,6544
	dc.w	7688,7696,7704,7712,7720,7728,7736,7744,7752,7760
	dc.w	7768,7776,7784,7792,7800,7808,7816,7824
	dc.w	8968,8976,8984,8992,9000,9008,9016,9024,9032,9040
	dc.w	9048,9056,9064,9072,9080,9088,9096,9104
	dc.w	10248,10256,10264,10272,10280,10288,10296,10304,10312
	dc.w	10320,10328,10336,10344,10352,10360,10368,10376,10384
	dc.w	11528,11536,11544,11552,11560,11568,11576,11584,11592
	dc.w	11600,11608,11616,11624,11632,11640,11648,11656,11664
	dc.w	12808,12816,12824,12832,12840,12848,12856,12864,12872
	dc.w	12880,12888,12896,12904,12912,12920,12928,12936,12944
	dc.w	14088,14096,14104,14112,14120,14128,14136,14144,14152
	dc.w	14160,14168,14176,14184,14192,14200,14208,14216,14224
	dc.w	15368,15376,15384,15392,15400,15408,15416,15424,15432
	dc.w	15440,15448,15456,15464,15472,15480,15488,15496,15504
	dc.w	16648,16656,16664,16672,16680,16688,16696,16704,16712
	dc.w	16720,16728,16736,16744,16752,16760,16768,16776,16784
	dc.w	17928,17936,17944,17952,17960,17968,17976,17984,17992
	dc.w	18000,18008,18016,18024,18032,18040,18048,18056,18064
	dc.w	19208,19216,19224,19232,19240,19248,19256,19264,19272
	dc.w	19280,19288,19296,19304,19312,19320,19328,19336,19344
	dc.w	20488,20496,20504,20512,20520,20528,20536,20544,20552
	dc.w	20560,20568,20576,20584,20592,20600,20608,20616,20624
	dc.w	21768,21776,21784,21792,21800,21808,21816,21824,21832
	dc.w	21840,21848,21856,21864,21872,21880,21888,21896,21904
	dc.w	23048,23056,23064,23072,23080,23088,23096,23104,23112
	dc.w	23120,23128,23136,23144,23152,23160,23168,23176,23184
even
hitbat:	dc.b	0,0,1,0,2,0,3,0,4,0,5,1,6,0,7,$3b,8,$10,9,$10,10,$10
	dc.b	11,0,12,$10,13,9
	dc.b	$80,2,$81,4,$40,1,$82,0,0
hitbr:	dc.b	0,0,1,0,2,0,3,0,4,0,5,0,6,0,7,$3e,8,$10,9,$10,10,$10
	dc.b	11,0,12,$10,13,9
	dc.b	$80,$20,$81,0,$40,1,$82,0,0
hitbr2:	dc.b	0,0,1,0,2,$20,3,0,4,0,5,1,6,0,7,$3c,8,$10,9,$10,10,$10
	dc.b	11,0,12,$10,13,0
	dc.b	$80,2,$81,0,$40,1,$82,0,0
boom:	dc.b	0,0,1,$f,2,0,3,0,4,0,5,1,6,$1f,7,$2e,8,$10,9,$10,10,$0
	dc.b	11,0,12,$80,13,9,$82,0

even




