; *******************************************************
; *							*
; *    "SnackMan", (C) Copyright Stig A. Olsen, 1992	*
; * 	   INTERNET (email): stigo@ifi.uio.no		*
; *  Mail: 4A311 Kringsjaa, Sognsvn. 218, N-0864 OSLO 	*
; *							*
; *******************************************************
; Version: 1.00, 07.10.92
	section	hoved,code_c	
NONE = 0	; direction constants
RIGHT = 1	; one bit per direction
LEFT = 2
UP = 4
DOWN = 8	

BAD = 0 	; ghost status values
EATABLE = 1	
EATEN = 2

GPOS = 0	; ghost-image structure offsets
GPOSX = 0	; x position
GPOSY = 2	; y position
GDIR = 4	; direction
GSEED = 6	; random seed
GRIGHT = 10	; right Sprite Image Pointer
GLEFT = 14	; left SIP
GUP = 18	; up SIP
GDOWN = 22	; down SIP
GPTR = 26	; copperlist sprite pointer for this sprite
GSPEED = 30	; ghost speed
GSTATUS = 32	; ghost status
GDEAD = 34	; dead SIP

STARTLIVES = 3	; no of lives at start of game
STARTSPEED = 1	; speed of pac at start of game
BOOSTTIME = 300 ; no of frames with vitamin boost
BOOSTWARNING = 100 ; warning time before ghosts kill

start:
	or.b 	#%10000000,$bfd100
	and.b 	#%10000111,$bfd100 ; turn off drive motor

	move.w	#$20,$dff1dc	; PAL mode (overweight Agnus only)

	move.w	#$012,$dff180
	jsr	setupscreen	; initialize screen pointers
	jsr 	mt_init

	move.l	$4,a6		; Execbase
	jsr	-120(a6)	; Disable interrupts
				; (also disables multitasking)
	jsr	-132(a6)	; Forbid multitasking
	lea.l	grname,a1
	jsr	-408(a6)	; open gfx library
	move.l	d0,a0
	lea.l	oldcopper,a1
	move.l	38(a0),(a1)	; store old cprlist
	lea.l	olddmacon,a1
	move.w	$dff002,(a1)
	bset	#15,(a1)

	jsr	introduction	; startupscreen

	move.w	#$7fff,$dff096 	; clear/set DMA
	lea.l	coplist,a0
	move.l	a0,$dff080	; sets my coplist
	move.w	$dff088,d0	; strobe
	move.w	#$83e0,$dff096 	; ON|DMAEN|BPLEN|COP|BLIT|DISK

	move.w	$dff01c,oldintena
	bset	#15,oldintena	; activate set-bit
	move.l	$6c,oldvbint	
	move.w	#$7fff,$dff09a	; turn off all interrupts
	move.l	#vbint,$6c	; set my interrupt
	move.w	#$c020,$dff09a  ; turn on vertical blank interrupt

;	**** INTIALIZATION ****

	jsr	updatelives
	jsr	initsprite	; set sprite pointers to blank sprite
	jsr	initcollision	; initialize collision register
	jsr	gameover
	bra	main		; jump to main loop

;	**** STANDARD STARTUP VARIABLES *****

oldcopper:	dc.l	0	; standard initializing variables
oldvbint:	dc.l	0
olddmacon:	dc.w	0
oldintena:	dc.w	0
grname: dc.b	"graphics.library",0,0

; 	**** VERTICAL BLANKING INTERRUPT ROUTINE ****	
vbint:
	movem.l	d0-d7/a0-a6,-(a7)	; save old values
	jsr	pacimage	; set right sprite pointer for pac
	jsr	mt_music		; do music
	move.w	#$0020,$dff09c		; clear vb interrupt	
	movem.l	(a7)+,d0-d7/a0-a6 	; reset registers
	rte


; 	**** MAIN LOOP ****

main:
	bsr	vblank		; sync with rasterbeam

	;move.w	#$017,$dff180 	; rastertime start

	jsr	checkjoystick	; check joystick movement
	jsr	movepac		; find new pac position
	jsr	setpac		; set right position

	lea.l	ghost1,a6	; set ghost structure pointer
	jsr	ghostdir	; choose new direction
	jsr	ghostmove	; update x/y variables
	jsr	ghostset	; set sprite on screen
	jsr	checkflash	; check if ghost eaten

	lea.l	ghost2,a6
	jsr	ghostdir
	jsr	ghostmove
	jsr	ghostset
	jsr	checkflash

	lea.l	ghost3,a6
	jsr	ghostdir
	jsr	ghostmove
	jsr	ghostset
	jsr	checkflash

	lea.l	ghost4,a6
	jsr	ghostdir
	jsr	ghostmove
	jsr	ghostset
	jsr	checkflash

	jsr	checkcollision

	jsr	eatcheese
	jsr	alleaten
	jsr	printscore
	jsr	updatelives

	jsr	boostcheck

	;move.w	#$012,$dff180 	; rastertime stop
	btst	#6,$bfe001	; left mousebutton
	bne	main


; 	**** CLEAN-UP ROUTINES  ****

end:
	jsr	jatilef		; endscreen
	lea.l	oldcopper,a0
	lea.l	olddmacon,a1
	move.l	(a0),$dff080	; restore copper
	move.w	(a1),$dff096	; restore dmacon
	move.w	#$0,$dff088
	move.w	#$7fff,$dff09a	; turn off all interrupts
	move.l	oldvbint,$6c	; restore old interrupt
	move.w	oldintena,$dff09a ; turn on old interrupts	
	move.l	$4,a6		; Execbase
	jsr	-126(a6)	; Enable
	jsr	-138(a6)	; Permit

	jsr	mt_end		; kill music

	move.l	#$0,d0		; no silly dos-errors in the
	rts			; startup-seq or other scripts

;	**** END OF EXECUTION ****

;	**** VERTICAL BLANK SYNC ****

vblank:				; vertical blanking wait
	cmp.b	#$00,$dff006
	bne.s	vblank
	btst	#0,$dff005
	beq.s	vblank
	rts
realblank:			; for turning off sprites
	cmp.b	#$00,$dff006
	bne.s	realblank
	btst	#0,$dff005
	bne.s	realblank
	rts

;	**** INITIALIZING ROUTINES ****

initcollision:
	move.w	#$0000,$dff098	; CLXCON
	move.w	#0,collctr
	rts

setupscreen:
	lea.l	board,a0	; boardpointer
	lea.l	pl1h,a1		; first plane pointer in copperlist
	move.l	a0,d0
	
	move.w	d0,6(a1)	; set least significant word
	swap	d0
	move.w	d0,2(a1)	; set most significant word
	swap	d0

	add.l	#10240,d0	; next plane for board
	add.l	#8,a1		; next pointer in copperlist
	move.w	d0,6(a1)
	swap	d0
	move.w	d0,2(a1)
	swap	d0

	add.l	#10240,d0
	add.l	#8,a1
	move.w	d0,6(a1)
	swap	d0
	move.w	d0,2(a1)

	lea.l	cheeseboard,a0
	move.l	a0,d0
	add.l	#8,a1
	move.w	d0,6(a1)
	swap	d0
	move.w	d0,2(a1)

	lea.l	scoreboard,a0
	lea.l	scr1h,a1
	move.l	a0,d0
	move.w	d0,6(a1)
	swap	d0
	move.w	d0,2(a1)

	lea.l	infoscreen,a0
	lea.l	pl5h,a1
	move.l	a0,d0
	move.w	d0,6(a1)
	swap	d0
	move.w	d0,2(a1)
	rts

initsprite:
	lea.l	nullspr,a0	; set sprites to null
	lea.l	spr1h,a1
	move.l	a0,d0

	move.w	d0,6(a1)	; 0
	move.w	d0,14(a1)	; 1
	move.w	d0,22(a1)	; 2
	move.w	d0,30(a1)	; 3
	move.w	d0,38(a1)	; 4
	move.w	d0,46(a1)	; 5
	move.w	d0,54(a1)	; 6
	move.w	d0,62(a1)	; 7
	swap	d0
	move.w	d0,2(a1)	; 0
	move.w	d0,10(a1)	; 1
	move.w	d0,18(a1)	; 2
	move.w	d0,26(a1)	; 3
	move.w	d0,34(a1)	; 4
	move.w	d0,42(a1)	; 5
	move.w	d0,50(a1)	; 6
	move.w	d0,58(a1)	; 7
	rts

drawboard:
	; put pointer to boarddata in a0
	lea.l	board,a2	; graphic area for board	

	move.w	#14,d7		; height = 15 words
outerloop:
	move.w	#19,d6		; width = 20 words
innerloop:			; 1 block = 16x16 pixels
	lea.l	blocks,a1
	move.b	(a0)+,d0
	and.w	#$00ff,d0
	cmp.w	#19,d0
	ble	not2ndrow
	sub.w	#20,d0
	add.l	#640,a1
not2ndrow:
	add.w	d0,d0
	add.w	d0,a1

	move.l	#$dff000,a6
	jsr	waitblit	; wait for until blitter is ready
	move.l 	a1,$50(a6)	; A channel pointer
	move.l 	a2,$54(a6)	; D channel pointer
	move.w 	#38,$64(a6)	; modulo i bytes A kanal
	move.w 	#38,$66(a6)	; modulo i bytes D kanal
	move.l 	#$ffffffff,$44(a6) ; blitter a mask
	move.w  #$09f0,$40(a6)	; blitcon0
	move.w 	#$0000,$42(a6)	; blitcon1
	move.w 	#64*16+1,$58(a6); blitsize
	add.l	#10240,a2
	add.l	#1920,a1
	jsr	waitblit
	move.l 	a1,$50(a6)	; next bitplane
	move.l 	a2,$54(a6)
	move.w 	#38,$64(a6)
	move.w 	#38,$66(a6)
	move.l 	#$ffffffff,$44(a6)
	move.w  #$09f0,$40(a6)
	move.w 	#$0000,$42(a6)
	move.w 	#64*16+1,$58(a6)
	add.l	#1920,a1
	add.l	#10240,a2
	jsr	waitblit
	move.l	a1,$50(a6)
	move.l 	a2,$54(a6)
	move.w 	#38,$64(a6)
	move.w 	#38,$66(a6)
	move.l 	#$ffffffff,$44(a6)
	move.w  #$09f0,$40(a6)
	move.w 	#$0000,$42(a6)
	move.w 	#64*16+1,$58(a6)
	add.l	#1920,a1
	add.l	#10240,a2
	jsr	waitblit
	move.l 	a1,$50(a6)
	move.l 	a2,$54(a6)
	move.w 	#38,$64(a6)
	move.w 	#38,$66(a6)
	move.l 	#$ffffffff,$44(a6)
	move.w  #$09f0,$40(a6)
	move.w 	#$0000,$42(a6)
	move.w 	#64*16+1,$58(a6)
	
	sub.l	#30720,a2	; subtract bitplanes
	add.l	#2,a2		; go to next position
	dbra	d6,innerloop	; next horizontal block
	add.l	#600,a2
	dbra	d7,outerloop	; next vertical line
	rts

initcheese:
	; put pointer to cheesedata in a0
	lea.l	newtab,a1
	move.w	#159,d7
cpyloop:
	move.w	(a0)+,(a1)+
	dbra	d7,cpyloop
	jsr	clearcheese
	lea.l	newtab,a0
	lea.l	cheeseboard,a2
	move.w	#0,cheesecount
	move.w	#0,cheeseeaten	
	move.w	#14,d7
icoloop:		; InitCheeseOuterLoop
	move.w	#19,d6
iciloop:		; InitCheeseInnerLoop
	move.b	(a0)+,d0
	cmp.b	#1,d0
	bne	no_cheese
	add.w	#1,cheesecount
	lea.l	cheese,a1	; image to screen with '68000
	move.w	(a1)+,(a2)	;0
	add.w	#40,a2
	move.w	(a1)+,(a2)	;1
	add.w	#40,a2
	move.w	(a1)+,(a2)	;2
	add.w	#40,a2
	move.w	(a1)+,(a2)	;3
	add.w	#40,a2
	move.w	(a1)+,(a2)	;4
	add.w	#40,a2
	move.w	(a1)+,(a2)	;5
	add.w	#40,a2
	move.w	(a1)+,(a2)	;6
	add.w	#40,a2
	move.w	(a1)+,(a2)	;7
	add.w	#40,a2
	move.w	(a1)+,(a2)	;8
	add.w	#40,a2
	move.w	(a1)+,(a2)	;9
	add.w	#40,a2
	move.w	(a1)+,(a2)	;a
	add.w	#40,a2
	move.w	(a1)+,(a2)	;b
	add.w	#40,a2
	move.w	(a1)+,(a2)	;c
	add.w	#40,a2
	move.w	(a1)+,(a2)	;d
	add.w	#40,a2
	move.w	(a1)+,(a2)	;e
	add.w	#40,a2
	move.w	(a1)+,(a2)	;f
	sub.l	#[40*15],a2	
no_cheese:
	cmp.b	#2,d0
	bne	no_vitamin
	lea.l	vitamin,a1	; image to screen with '68000
	move.w	(a1)+,(a2)	;0
	add.w	#40,a2
	move.w	(a1)+,(a2)	;1
	add.w	#40,a2
	move.w	(a1)+,(a2)	;2
	add.w	#40,a2
	move.w	(a1)+,(a2)	;3
	add.w	#40,a2
	move.w	(a1)+,(a2)	;4
	add.w	#40,a2
	move.w	(a1)+,(a2)	;5
	add.w	#40,a2
	move.w	(a1)+,(a2)	;6
	add.w	#40,a2
	move.w	(a1)+,(a2)	;7
	add.w	#40,a2
	move.w	(a1)+,(a2)	;8
	add.w	#40,a2
	move.w	(a1)+,(a2)	;9
	add.w	#40,a2
	move.w	(a1)+,(a2)	;a
	add.w	#40,a2
	move.w	(a1)+,(a2)	;b
	add.w	#40,a2
	move.w	(a1)+,(a2)	;c
	add.w	#40,a2
	move.w	(a1)+,(a2)	;d
	add.w	#40,a2
	move.w	(a1)+,(a2)	;e
	add.w	#40,a2
	move.w	(a1)+,(a2)	;f
	sub.l	#[40*15],a2	
no_vitamin:
	add.l	#2,a2
	dbra	d6,iciloop
	add.l	#600,a2
	dbra	d7,icoloop
	rts	
	
clearcheese:
	jsr	waitblit
	move.l 	#cheeseboard,$54(a6)	; D kanal peker
	move.w 	#00,$66(a6)	; modulo i bytes D kanal
	move.l 	#$ffffffff,$44(a6) ; blitter mask
	move.w  #$0100,$40(a6)	; blitcon0
	move.w 	#$0000,$42(a6)	; blitcon1
	move.w 	#64*256+20,$58(a6)	; blitsize
	jsr	waitblit	; must wait here!
	rts

;	**** OTHER ROUTINES ****
waitblit:
	btst	#14,$dff002	; blitter ready?
	nop			
	bne.s	waitblit
	rts

checkcollision:			; this routine is a kludge
	add.w	#1,collctr	; fix it later
	move.w	collctr,d0
	btst	#0,d0
	beq	fr2
fr1:
	move.w	$dff00e,coll1
	move.w	#$e000,$dff098
	rts
fr2:
	move.w	$dff00e,coll2
	move.w	#$0000,$dff098
	
	move.w	coll1,d0
	btst	#9,d0
	bne	img1coll
	btst	#10,d0
	bne	img3coll
	move.w	coll2,d0
	btst	#9,d0
	bne	img2coll		
	btst	#10,d0
	bne	img4coll
	rts
img1coll:
	lea.l	ghost1,a6
	bra	collision
img2coll:
	lea.l	ghost2,a6
	move.w	pacpos,d0
	sub.w	GPOSX(a6),d0
	bpl	img2plus1
	neg.w	d0
img2plus1:
	cmp.w	#$10,d0
	bhi	fake
	move.w	pacpos+2,d0
	sub.w	GPOSY(a6),d0
	bpl	img2plus2
	neg.w	d0
img2plus2:
	cmp.w	#$10,d0
	bhi	fake
	bra	collision
fake:
	rts
img3coll:
	lea.l	ghost3,a6
	bra	collision
img4coll:
	lea.l	ghost4,a6
	move.w	pacpos,d0
	sub.w	GPOSX(a6),d0
	bpl	img4plus1
	neg.w	d0
img4plus1:
	cmp.w	#$10,d0
	bhi	fake
	move.w	pacpos+2,d0
	sub.w	GPOSY(a6),d0
	bpl	img4plus2
	neg.w	d0
img4plus2:
	cmp.w	#$10,d0
	bhi	fake
collision:
	move.w	GSTATUS(a6),d0
	cmp.w	#BAD,d0
	beq	badone
	cmp.w	#EATABLE,d0
	beq	edible
	; STATUS = EATEN
	rts	
badone:
	jsr	badcollision
	rts
edible:
	move.w	#EATEN,GSTATUS(a6)
	jsr	fivepoints
	rts

checkflash:
	move.w	GSTATUS(a6),d0
	cmp.w	#EATEN,d0
	bne	checkend
	move.l	GDEAD(a6),d0
	move.l	GPTR(a6),a0
	move.w	d0,6(a0)
	swap	d0
	move.w	d0,2(a0)
checkend:
	rts	

badcollision:
	sub.b	#1,lives
	jsr	updatelives	
	jsr	gotyou

	move.l	#$009800d8,pacpos	; initial pac position
	move.l	#pacBALL,dirpac
	move.w	#NONE,joydirection
	move.w	#NONE,curdir
	jsr	setpac
	lea.l	ghost1,a6		; initial ghost positions
	move.l	#$00380018,GPOS(a6)
	jsr	ghostset
	lea.l	ghost2,a6
	move.l	#$00680018,GPOS(a6)
	jsr	ghostset
	lea.l	ghost3,a6
	move.l	#$00980018,GPOS(a6)
	jsr	ghostset
	lea.l	ghost4,a6
	move.l	#$00c80018,GPOS(a6)
	move.w	boost,d0
	beq	checkgameover
	move.w	pacspeed,d0	; loose vitamin when
	lsr.w	#1,d0		; you loose a life
	move.w	d0,pacspeed
	move.w	#0,boost

checkgameover:
	move.b	lives,d0
	cmp.b	#0,d0
	bne	notgameover
	bra	gameover
notgameover:
	jsr	ghostset
	jsr	getready
	jsr	go
	rts

setpac:
	moveq	#0,d2		; sprite control longword
	moveq	#0,d3
	move.w	pacpos+2,d1	; y pos
	move.w	pacpos,d0	; x pos
	
	add.w	#$78,d0		; offset to get image to screen
	add.w	#$25,d1

	move.w	d1,d4
	add.w	#$10,d4		; sprite height, 16 lines
	
	move.b	d1,d2
	rol.w	#8,d2

	move.w	d4,d3
	rol.w	#8,d3

	btst	#8,d1
	beq	vstartmsbCLR
	bset	#2,d3
vstartmsbCLR:
	btst	#8,d4
	beq	vstopmsbCLR
	bset	#1,d3
vstopmsbCLR:

	lsr.w	#1,d0
	bcs	hstartlsbSET
	move.b	d0,d2
	bclr	#0,d3	
	bra	posOK
hstartlsbSET:
	move.b	d0,d2
	bset	#0,d3	
posOK:
	swap	d2
	move.w	d3,d2
	move.l	d2,pacBALL	
	move.l	d2,pacL
	move.l	d2,pacR
	move.l	d2,pacU
	move.l	d2,pacD		; update all pac-sprites
	rts

checkjoystick:
	lea.l	joydirection,a0	; check for joystick push
	move.w	$dff00c,d0
	btst	#1,d0
	bne	rightpressed
	btst	#9,d0
	bne	leftpressed		
	btst	#0,d0
	bne	downpressed
	btst	#8,d0
	bne	uppressed

	;move.l	#NONE,(a0)	; remove this in finished version
	rts

rightpressed:
	move.w	#RIGHT,(a0)
	rts
leftpressed:
	move.w	#LEFT,(a0)
	rts
downpressed:
	move.w	#DOWN,(a0)
	rts
uppressed:
	move.w	#UP,(a0)
	rts

movepac:
	move.w	joydirection,d0
	cmp.w	#RIGHT,d0
	bne	next1
	move.l	pacpos,testpos
	move.w	pacspeed,d5
	add.w	d5,testpos
	jsr	testposition
	tst.w	d0
	beq	next4
	move.w	pacspeed,d5
	add.w	d5,pacpos
	move.l	#pacR,dirpac
	move.w	#RIGHT,curdir
	rts
next1:
	cmp.w	#LEFT,d0
	bne	next2
	move.l	pacpos,testpos
	move.w	pacspeed,d5
	sub.w	d5,testpos
	jsr	testposition
	tst.w	d0
	beq	next4
	move.w	pacspeed,d5
	sub.w	d5,pacpos
	move.l	#pacL,dirpac
	move.w	#LEFT,curdir
	rts
next2:
	cmp.w	#UP,d0
	bne	next3
	move.l	pacpos,testpos
	move.w	pacspeed,d5
	sub.w	d5,testpos+2
	jsr	testposition
	tst.w	d0
	beq	next4
	move.w	pacspeed,d5
	sub.w	d5,pacpos+2
	move.l	#pacU,dirpac
	move.w	#UP,curdir
	rts
next3:
	cmp.w	#DOWN,d0
	bne	next4
	move.l	pacpos,testpos
	move.w	pacspeed,d5
	add.w	d5,testpos+2
	jsr	testposition
	tst.w	d0
	beq	next4
	move.w	pacspeed,d5
	add.w	d5,pacpos+2
	move.l	#pacD,dirpac
	move.w	#DOWN,curdir
	rts
next4:
	move.w	curdir,d0
	cmp.w	#RIGHT,d0
	bne	nexxt1
	move.l	pacpos,testpos
	move.w	pacspeed,d5
	add.w	d5,testpos
	jsr	testposition
	tst.w	d0
	beq	nexxt4
	move.w	pacspeed,d5
	add.w	d5,pacpos
	move.l	#pacR,dirpac
	move.w	#RIGHT,curdir
	rts
nexxt1:
	cmp.w	#LEFT,d0
	bne	nexxt2
	move.l	pacpos,testpos
	move.w	pacspeed,d5
	sub.w	d5,testpos
	jsr	testposition
	tst.w	d0
	beq	nexxt4
	move.w	pacspeed,d5
	sub.w	d5,pacpos
	move.l	#pacL,dirpac
	move.w	#LEFT,curdir
	rts
nexxt2:
	cmp.w	#UP,d0
	bne	nexxt3
	move.l	pacpos,testpos
	move.w	pacspeed,d5
	sub.w	d5,testpos+2
	jsr	testposition
	tst.w	d0
	beq	nexxt4
	move.w	pacspeed,d5
	sub.w	d5,pacpos+2
	move.l	#pacU,dirpac
	move.w	#UP,curdir
	rts
nexxt3:
	cmp.w	#DOWN,d0
	bne	nexxt4
	move.l	pacpos,testpos
	move.w	pacspeed,d5
	add.w	d5,testpos+2
	jsr	testposition
	tst.w	d0
	beq	nexxt4
	move.w	pacspeed,d5
	add.w	d5,pacpos+2
	move.l	#pacD,dirpac
	move.w	#DOWN,curdir
	rts
nexxt4:
	move.l	#pacBALL,dirpac	
	move.w	#NONE,curdir
	rts

pacimage:
	lea.l	spr1h,a0
	add.w	#1,dirctr
	btst	#3,dirctr+1
	beq	ball
	move.l	dirpac,d0
	move.w	d0,6(a0)
	swap	d0
	move.w	d0,2(a0)
	rts
ball:
	move.l	#pacBALL,d0
	move.w	d0,6(a0)
	swap	d0
	move.w	d0,2(a0)
	rts	
		; check if loaction is a valid image-location
testposition:
	lea.l	board+[10240*3],a0
	lea.l	invtable,a2
	move.w	testpos+2,d0
	mulu.w	#40,d0
	add.w	d0,a0	; + vertical

	move.w	testpos,d0
	move.w	d0,d1
	and.w	#$7,d1
	add.w	d1,d1
	move.w	(a2,d1.w),d1

	lsr	#3,d0
	add.w	d0,a0	; + horizontal

	btst	d1,(a0)
	beq	faultypos
	move.w	#-1,d0
	rts
faultypos:
	move.w	#$0,d0
	rts

ghostdir:
	moveq	#0,d7
	move.l	GPOS(a6),testpos
	move.w	GSPEED(a6),d5
	add.w	d5,testpos
	jsr	testposition
	tst.w	d0
	beq	ghostrna
	or.w	#RIGHT,d7
ghostrna:	
	move.l	GPOS(a6),testpos
	move.w	GSPEED(a6),d5
	sub.w	d5,testpos
	jsr	testposition
	tst.w	d0
	beq	ghostlna
	or.w	#LEFT,d7
ghostlna:
	move.l	GPOS(a6),testpos
	move.w	GSPEED(a6),d5
	add.w	d5,testpos+2
	jsr	testposition
	tst.w	d0
	beq	ghostdna
	or.w	#DOWN,d7
ghostdna:
	move.l	GPOS(a6),testpos
	move.w	GSPEED(a6),d5
	sub.w	d5,testpos+2
	jsr	testposition
	tst.w	d0
	beq	ghostuna
	or.w	#UP,d7
ghostuna:
	lea.l	bitcnttable,a0
	lea.l	oppositetable,a1
	lea.l	selecttable,a2

	move.w	d7,d6
	add.w	d6,d6
	move.w	(a0,d6.w),d6
	cmp.w	#1,d6	
	beq	ghostend
	
	move.w	GDIR(a6),d6	; clear the opposite direction
	add.w	d6,d6
	move.w	(a1,d6.w),d6
	not.w	d6
	and.w	d6,d7
	
	move.w	d7,d6
	add.w	d6,d6
	move.w	(a0,d6.w),d6
	cmp.w	#1,d6
	beq	ghostend
	
	;move.l	GSEED(a6),d0	; simple randomgenerator routine
	move.l	RANDOMSEED,d0
	rol.l	#3,d0
	eor.l	#$26754ace,d0	; another "random" number
	;move.l	d0,GSEED(a6)
	move.l	d0,RANDOMSEED	

	and.l	#$f8,d0		; 8 byte alignment
	move.w	(a2,d0.w),d1	; clear 2nd unwanted direction
	not.w	d1
	and.w	d1,d7

	move.w	d7,d6
	add.w	d6,d6
	move.w	(a0,d6.w),d6
	cmp.w	#1,d6
	beq	ghostend

	add.w	#2,d0
	move.w	(a2,d0.w),d1	; clear 3rd unwanted direction
	not.w	d1
	and.w	d1,d7

	move.w	d7,d6
	add.w	d6,d6
	move.w	(a0,d6.w),d6
	cmp.w	#1,d6
	beq	ghostend

	add.w	#2,d0
	move.w	(a2,d0.w),d1	; clear 4th unwanted direction
	not	d1		; do we ever get here?
	and.w	d1,d7		; hope not! :-)

ghostend:	
	move.w	d7,GDIR(a6)	
	rts

ghostmove:
	move.w	GDIR(a6),d0
	cmp.w	#RIGHT,d0
	bne	ghostnext1
	move.w	GSPEED(a6),d5
	add.w	d5,GPOSX(a6)
	move.l	GRIGHT(a6),d0
	move.l	GPTR(a6),a0
	move.w	d0,6(a0)
	swap	d0
	move.w	d0,2(a0)
	rts
ghostnext1:	
	cmp.w	#LEFT,d0
	bne	ghostnext2
	move.w	GSPEED(a6),d5
	sub.w	d5,GPOSX(a6)
	move.l	GLEFT(a6),d0
	move.l	GPTR(a6),a0
	move.w	d0,6(a0)
	swap	d0
	move.w	d0,2(a0)
	rts
ghostnext2:
	cmp.w	#UP,d0
	bne	ghostnext3
	move.w	GSPEED(a6),d5
	sub.w	d5,GPOSY(a6)
	move.l	GUP(a6),d0
	move.l	GPTR(a6),a0
	move.w	d0,6(a0)
	swap	d0
	move.w	d0,2(a0)
	rts
ghostnext3:
	cmp.w	#DOWN,d0
	bne	ghostnext4
	move.w	GSPEED(a6),d5
	add.w	d5,GPOSY(a6)
	move.l	GDOWN(a6),d0
	move.l	GPTR(a6),a0
	move.w	d0,6(a0)
	swap	d0
	move.w	d0,2(a0)
	rts
ghostnext4:
	rts

ghostset:
	moveq	#0,d2		; sprite control longword
	moveq	#0,d3
	move.w	GPOSY(a6),d1	; y pos
	move.w	GPOSX(a6),d0	; x pos
	
	add.w	#$78,d0
	add.w	#$25,d1

	move.w	d1,d4
	add.w	#$10,d4		; sprite height
	
	move.b	d1,d2
	rol.w	#8,d2

	move.w	d4,d3
	rol.w	#8,d3

	btst	#8,d1
	beq	ghostvstartmsbCLR
	bset	#2,d3
ghostvstartmsbCLR:
	btst	#8,d4
	beq	ghostvstopmsbCLR
	bset	#1,d3
ghostvstopmsbCLR:

	lsr.w	#1,d0
	bcs	ghosthstartlsbSET
	move.b	d0,d2
	bclr	#0,d3	
	bra	ghostposOK
ghosthstartlsbSET:
	move.b	d0,d2
	bset	#0,d3	
ghostposOK:
	swap	d2
	move.w	d3,d2	
	move.l	GLEFT(a6),a0
	move.l	d2,(a0)
	move.l	GRIGHT(a6),a0
	move.l	d2,(a0)
	move.l	GUP(a6),a0
	move.l	d2,(a0)
	move.l	GDOWN(a6),a0
	move.l	d2,(a0)		; update spritepointers for image
	move.l	GDEAD(a6),a0
	move.l	d2,(a0)
	rts

eatcheese:
	move.w	pacpos,d0	;x
	move.w	pacpos+2,d1	;y
	lsr.w	#4,d0
	lsr.w	#4,d1
	move.w	d0,d2
	move.w	d1,d3
	mulu.w	#20,d1
	add.w	d1,d0
	lea.l	newtab,a0
	add.w	d0,a0
	move.b	(a0),d1
	cmp.b	#1,d1	;	1 = cheese
	beq	foundcheese
	cmp.b	#2,d1	;	2 = vitamin (no other snacks yet)
	beq	foundvitamin
	rts
foundcheese:	
	move.b	#00,(a0)	; clear cheese in table
	add.w	#1,cheeseeaten	; we've just eaten one
	jsr	onepoint
	bra	clearobject
foundvitamin:
	move.b	#00,(a0)	 ; clear vitamin in table
	lea.l	ghost1,a6
	move.w	#EATABLE,GSTATUS(a6)
	lea.l	ghost2,a6
	move.w	#EATABLE,GSTATUS(a6)
	lea.l	ghost3,a6
	move.w	#EATABLE,GSTATUS(a6)
	lea.l	ghost4,a6
	move.w	#EATABLE,GSTATUS(a6)
	move.w	#$35c,col12	; new eatable color
	move.w	#$35c,col34
	jsr	tenpoints
	move.w	boost,d0
	beq	noboosting
	move.w	#-1,boost 
noboosting:
	add.w	#BOOSTTIME,boost ; boost-speed for n frames
	and.w	#$fff8,pacpos	; align position
	and.w	#$fff8,pacpos+2
	bra	clearobject
clearobject:
	lea.l	cheeseboard,a1
	move.w	pacpos,d0
	lsr.w	#4,d0
	add.w	d0,d0
	add.w	d0,a1
	move.w	pacpos+2,d1
	lsr.w	#4,d1
	mulu.w	#640,d1
	add.w	d1,a1
	move.w	#$0000,(a1)
	add.w	#40,a1
	move.w	#$0000,(a1)
	add.w	#40,a1
	move.w	#$0000,(a1)
	add.w	#40,a1
	move.w	#$0000,(a1)
	add.w	#40,a1
	move.w	#$0000,(a1)
	add.w	#40,a1
	move.w	#$0000,(a1)
	add.w	#40,a1
	move.w	#$0000,(a1)
	add.w	#40,a1
	move.w	#$0000,(a1)
	add.w	#40,a1
	move.w	#$0000,(a1)
	add.w	#40,a1
	move.w	#$0000,(a1)
	add.w	#40,a1
	move.w	#$0000,(a1)
	add.w	#40,a1
	move.w	#$0000,(a1)
	add.w	#40,a1
	move.w	#$0000,(a1)
	add.w	#40,a1
	move.w	#$0000,(a1)
	add.w	#40,a1
	move.w	#$0000,(a1)
	rts

boostcheck:
	move.w	boost,d0
	cmp.w	#BOOSTTIME,d0
	beq	newboost
	cmp.w	#1,d0
	beq	lastboost
	cmp.w	#0,d0
	bne	activeboost
	rts
activeboost:
	sub.w	#1,boost
	cmp.w	#BOOSTWARNING,d0
	bls	warn_end_of_boost
	rts
warn_end_of_boost:
	btst	#4,d0
	beq	bluecol
	move.w	#$c35,col12	; flash ghosts
	move.w	#$3c5,col34
	rts
bluecol:
	move.w	#$35c,col12
	move.w	#$35c,col34
	rts
lastboost:
	move.w	pacspeed,d0
	lsr.w	#1,d0
	cmp.w	#16,d0
	bge	maxspeed
	move.w	d0,pacspeed
	sub.w	#1,boost
	lea.l	ghost1,a6
	move.w	#BAD,GSTATUS(a6)
	lea.l	ghost2,a6
	move.w	#BAD,GSTATUS(a6)
	lea.l	ghost3,a6
	move.w	#BAD,GSTATUS(a6)
	lea.l	ghost4,a6
	move.w	#BAD,GSTATUS(a6)
	move.w	#$c35,col12
	move.w	#$3c5,col34
	rts	
maxspeed:
	move.w	#0,boost
	rts
newboost:
	move.w	pacspeed,d0
	lsl.w	#1,d0
	move.w	d0,pacspeed
	sub.w	#1,boost
	rts

alleaten:
	move.w	cheesecount,d0
	move.w	cheeseeaten,d1
	cmp.w	d0,d1
	beq	no_more_cheese
	rts
no_more_cheese:
	jsr	printscore
	jsr	initsprite
	move.l	#$009800d8,pacpos	; initial pac position
	move.l	#pacBALL,dirpac
	move.w	#NONE,joydirection
	move.w	#NONE,curdir
	jsr	setpac
	lea.l	ghost1,a6		; initial ghost positions
	move.l	#$00380018,GPOS(a6)
	move.w	#BAD,GSTATUS(a6)
	jsr	ghostset
	lea.l	ghost2,a6
	move.l	#$00680018,GPOS(a6)
	move.w	#BAD,GSTATUS(a6)
	jsr	ghostset
	lea.l	ghost3,a6
	move.l	#$00980018,GPOS(a6)
	move.w	#BAD,GSTATUS(a6)
	jsr	ghostset
	lea.l	ghost4,a6
	move.l	#$00c80018,GPOS(a6)
	move.w	#BAD,GSTATUS(a6)
	jsr	ghostset
	move.w	#$c35,col12
	move.w	#$3c5,col34

	; more level ations here

	move.w	#0,boost	; boost lost at level completion
	add.w	#1,difficulty
	move.w	difficulty,d0	; choose difficulty
	cmp.w	#1,d0
	bne	not_diff1
	lea.l	ghost1,a6
	move.w	#1,GSPEED(a6)
	lea.l	ghost2,a6
	move.w	#1,GSPEED(a6)
	lea.l	ghost3,a6
	move.w	#1,GSPEED(a6)
	lea.l	ghost4,a6
	move.w	#1,GSPEED(a6)
	move.w	#1,pacspeed
	lea.l	board2,a0
	jsr	drawboard
	lea.l	cheese2,a0
	jsr	initcheese
	bra	diff_set
not_diff1:
	cmp.w	#2,d0
	bne	not_diff2
	lea.l	ghost1,a6
	move.w	#1,GSPEED(a6)
	lea.l	ghost2,a6
	move.w	#1,GSPEED(a6)
	lea.l	ghost3,a6
	move.w	#1,GSPEED(a6)
	lea.l	ghost4,a6
	move.w	#1,GSPEED(a6)
	move.w	#1,pacspeed
	lea.l	board3,a0
	jsr	drawboard
	lea.l	cheese3,a0
	jsr	initcheese
	bra	diff_set
not_diff2:
	cmp.w	#3,d0
	bne	not_diff3
	lea.l	ghost1,a6
	move.w	#1,GSPEED(a6)
	lea.l	ghost2,a6
	move.w	#1,GSPEED(a6)
	lea.l	ghost3,a6
	move.w	#1,GSPEED(a6)
	lea.l	ghost4,a6
	move.w	#1,GSPEED(a6)
	move.w	#1,pacspeed
	lea.l	board4,a0
	jsr	drawboard
	lea.l	cheese4,a0
	jsr	initcheese
	bra	diff_set
not_diff3:
	cmp.w	#4,d0
	bne	not_diff4
	lea.l	ghost1,a6
	move.w	#1,GSPEED(a6)
	lea.l	ghost2,a6
	move.w	#1,GSPEED(a6)
	lea.l	ghost3,a6
	move.w	#1,GSPEED(a6)
	lea.l	ghost4,a6
	move.w	#1,GSPEED(a6)
	move.w	#1,pacspeed
	lea.l	board5,a0
	jsr	drawboard
	lea.l	cheese5,a0
	jsr	initcheese
	bra	diff_set
not_diff4:
	cmp.w	#5,d0
	bne	not_diff5
	lea.l	ghost1,a6
	move.w	#2,GSPEED(a6)
	lea.l	ghost2,a6
	move.w	#2,GSPEED(a6)
	lea.l	ghost3,a6
	move.w	#2,GSPEED(a6)
	lea.l	ghost4,a6
	move.w	#2,GSPEED(a6)
	move.w	#2,pacspeed
	lea.l	board1,a0
	jsr	drawboard
	lea.l	cheese1,a0
	jsr	initcheese
	bra	diff_set
not_diff5:
	cmp.w	#6,d0
	bne	not_diff6
	lea.l	ghost1,a6
	move.w	#2,GSPEED(a6)
	lea.l	ghost2,a6
	move.w	#2,GSPEED(a6)
	lea.l	ghost3,a6
	move.w	#2,GSPEED(a6)
	lea.l	ghost4,a6
	move.w	#2,GSPEED(a6)
	move.w	#2,pacspeed
	lea.l	board2,a0
	jsr	drawboard
	lea.l	cheese2,a0
	jsr	initcheese
	bra	diff_set
not_diff6:
	cmp.w	#7,d0
	bne	not_diff7
	lea.l	ghost1,a6
	move.w	#2,GSPEED(a6)
	lea.l	ghost2,a6
	move.w	#2,GSPEED(a6)
	lea.l	ghost3,a6
	move.w	#2,GSPEED(a6)
	lea.l	ghost4,a6
	move.w	#2,GSPEED(a6)
	move.w	#2,pacspeed
	lea.l	board3,a0
	jsr	drawboard
	lea.l	cheese3,a0
	jsr	initcheese
	bra	diff_set
not_diff7:
	cmp.w	#8,d0
	bne	not_diff8
	lea.l	ghost1,a6
	move.w	#2,GSPEED(a6)
	lea.l	ghost2,a6
	move.w	#2,GSPEED(a6)
	lea.l	ghost3,a6
	move.w	#2,GSPEED(a6)
	lea.l	ghost4,a6
	move.w	#2,GSPEED(a6)
	move.w	#2,pacspeed
	lea.l	board4,a0
	jsr	drawboard
	lea.l	cheese4,a0
	jsr	initcheese
	bra	diff_set
not_diff8:
	cmp.w	#9,d0
	bne	not_diff9
	lea.l	ghost1,a6
	move.w	#2,GSPEED(a6)
	lea.l	ghost2,a6
	move.w	#2,GSPEED(a6)
	lea.l	ghost3,a6
	move.w	#2,GSPEED(a6)
	lea.l	ghost4,a6
	move.w	#2,GSPEED(a6)
	move.w	#2,pacspeed
	lea.l	board5,a0
	jsr	drawboard
	lea.l	cheese5,a0
	jsr	initcheese
	bra	diff_set
not_diff9:
	cmp.w	#10,d0
	bne	not_diff10
	lea.l	ghost1,a6
	move.w	#4,GSPEED(a6)
	lea.l	ghost2,a6
	move.w	#2,GSPEED(a6)
	lea.l	ghost3,a6
	move.w	#4,GSPEED(a6)
	lea.l	ghost4,a6
	move.w	#2,GSPEED(a6)
	move.w	#2,pacspeed
	lea.l	board1,a0
	jsr	drawboard
	lea.l	cheese1,a0
	jsr	initcheese
	bra	diff_set
not_diff10:
	lea.l	ghost1,a6
	move.w	#4,GSPEED(a6)
	lea.l	ghost2,a6
	move.w	#4,GSPEED(a6)
	lea.l	ghost3,a6
	move.w	#4,GSPEED(a6)
	lea.l	ghost4,a6
	move.w	#4,GSPEED(a6)
	move.w	#2,pacspeed
	lea.l	board2,a0
	jsr	drawboard
	lea.l	cheese2,a0
	jsr	initcheese
	bra	diff_set
diff_set:
	jsr	congratulations
	jsr	hundredpoints	; 100 is really 1,000
	jsr	printscore
	jsr	getready
	jsr	go
	rts

onepoint:
	lea.l	onept+4,a0
	bra	setscore
fivepoints:
	lea.l	fivept+4,a0
	bra	setscore
tenpoints:
	lea.l	tenpt+4,a0
	bra	setscore
hundredpoints:
	lea.l	hundredpt+4,a0
setscore:
	lea.l	score+4,a1
	move	#0,ccr
	abcd	-(a0),-(a1)
	abcd	-(a0),-(a1)
	abcd	-(a0),-(a1)
	abcd	-(a0),-(a1)
	rts
calculatehiscore:
	move.l	score,d0
	move.l	hiscore,d1
	cmp.l	d1,d0
	bge	newhiscore
	rts
newhiscore:
	move.l	d0,hiscore
	rts

printhiscore:
	lea.l	digits,a0
	lea.l	infomsgs,a2
	add.l	#22+[40*112],a2
	moveq	#0,d0
	move.b	hiscore,d0
	lsr.w	#4,d0
	bsr.l	printletter
	moveq	#0,d0
	move.b	hiscore,d0
	and.w	#$0f,d0
	bsr.l	printletter
	moveq	#0,d0
	move.b	hiscore+1,d0
	lsr.w	#4,d0
	bsr.l	printletter
	moveq	#0,d0
	move.b	hiscore+1,d0
	and.w	#$0f,d0
	bsr.l	printletter
	moveq	#0,d0
	move.b	hiscore+2,d0
	lsr.w	#4,d0
	bsr.l	printletter
	moveq	#0,d0
	move.b	hiscore+2,d0
	and.w	#$0f,d0
	bsr.l	printletter
	moveq	#0,d0
	move.b	hiscore+3,d0
	lsr.w	#4,d0
	bsr.l	printletter
	moveq	#0,d0
	move.b	hiscore+3,d0
	and.w	#$0f,d0
	bsr.l	printletter
	rts

printscore:
	lea.l	digits,a0
	lea.l	scoreboard,a2
	add.l	#12,a2
	moveq	#0,d0
	move.b	score,d0
	lsr.w	#4,d0
	bsr.L	printletter
	moveq	#0,d0
	move.b	score,d0
	and.w	#$0f,d0
	bsr.L	printletter
	moveq	#0,d0
	move.b	score+1,d0
	lsr.w	#4,d0
	bsr.L	printletter
	moveq	#0,d0
	move.b	score+1,d0
	and.w	#$0f,d0
	bsr.L	printletter
	moveq	#0,d0
	move.b	score+2,d0	
	lsr.w	#4,d0
	bsr.s	printletter
	moveq	#0,d0
	move.b	score+2,d0
	and.w	#$0f,d0
	bsr.s	printletter
	moveq	#0,d0
	move.b	score+3,d0
	lsr.w	#4,d0
	bsr.s	printletter
	moveq	#0,d0
	move.b	score+3,d0
	and.w	#$0f,d0
	bsr.s	printletter
	rts

updatelives:
	lea.l	scoreboard,a2
	lea.l	digits,a0
	add.l	#38,a2
	moveq	#0,d0
	move.b	lives,d0
	and.w	#$0f,d0
	bsr.s	printletter
	rts

printletter:
	add.w	d0,d0
	move.l	a0,a1
	add.w	d0,a1
	move.w	#15,d7
sc1stloop:
	add.w	#40,a1
	add.w	#40,a2
	move.w	(a1),(a2)
	dbra	d7,sc1stloop
	sub.l	#640,a2
	add.l	#2,a2	
	rts

getready:
	jsr	initsprite
	lea.l	infomsgs,a0
	lea.l	infoscreen,a1
	add.l	#48*40,a0	; get ready offset
	add.l	#4480,a1	; position on screen
	move.l	#$dff000,a6
	move.w	#100,d7
getdll:			; print image and wait...
	jsr	waitblit
	move.l 	a0,$50(a6)	; A kanal peker
	move.l 	a1,$54(a6)	; D kanal peker
	move.w 	#00,$64(a6)	; modulo i bytes A kanal
	move.w 	#00,$66(a6)	; modulo i bytes D kanal
	move.l 	#$ffffffff,$44(a6) ; blitter a mask
	move.w  #$09f0,$40(a6)	; blitcon0
	move.w 	#$0000,$42(a6)	; blitcon1
	move.w 	#64*16+20,$58(a6)	; blitsize
	jsr	vblank
	dbra	d7,getdll
	jsr	clearinfo
	rts

go:
	lea.l	infomsgs,a0
	lea.l	infoscreen,a1
	add.l	#64*40,a0	; go offset
	add.l	#4480,a1	; position on screen
	move.l	#$dff000,a6
	move.w	#10,d7
godll:
	jsr	waitblit
	move.l 	a0,$50(a6)	; A kanal peker
	move.l 	a1,$54(a6)	; D kanal peker
	move.w 	#00,$64(a6)	; modulo i bytes A kanal
	move.w 	#00,$66(a6)	; modulo i bytes D kanal
	move.l 	#$ffffffff,$44(a6) ; blitter a mask
	move.w  #$09f0,$40(a6)	; blitcon0
	move.w 	#$0000,$42(a6)	; blitcon1
	move.w 	#64*16+20,$58(a6)	; blitsize
	jsr	vblank
	dbra	d7,godll
	jsr	clearinfo
	rts

highscore:
	lea.l	infomsgs,a0
	lea.l	infoscreen,a1
	add.l	#112*40,a0	; go offset
	;add.l	#224*40,a1
	move.l	#$dff000,a6
	jsr	waitblit
	move.l 	a0,$50(a6)	; A kanal peker
	move.l 	a1,$54(a6)	; D kanal peker
	move.w 	#00,$64(a6)	; modulo i bytes A kanal
	move.w 	#00,$66(a6)	; modulo i bytes D kanal
	move.l 	#$ffffffff,$44(a6) ; blitter a mask
	move.w  #$09f0,$40(a6)	; blitcon0
	move.w 	#$0000,$42(a6)	; blitcon1
	move.w 	#64*16+20,$58(a6)	; blitsize
	rts

snackman:
	lea.l	infomsgs,a0
	lea.l	infoscreen,a1
	add.l	#[16*40],a1
	add.l	#128*40,a0	; go offset
	move.l	#$dff000,a6
	jsr	waitblit
	move.l 	a0,$50(a6)	; A kanal peker
	move.l 	a1,$54(a6)	; D kanal peker
	move.w 	#00,$64(a6)	; modulo i bytes A kanal
	move.w 	#00,$66(a6)	; modulo i bytes D kanal
	move.l 	#$ffffffff,$44(a6) ; blitter a mask
	move.w  #$09f0,$40(a6)	; blitcon0
	move.w 	#$0000,$42(a6)	; blitcon1
	move.w 	#64*96+20,$58(a6)	; blitsize
	rts

credits:
	lea.l	infomsgs,a0
	lea.l	infoscreen,a1
	add.l	#144*40,a1
	add.l	#224*40,a0	; go offset
	move.l	#$dff000,a6
	jsr	waitblit
	move.l 	a0,$50(a6)	; A kanal peker
	move.l 	a1,$54(a6)	; D kanal peker
	move.w 	#00,$64(a6)	; modulo i bytes A kanal
	move.w 	#00,$66(a6)	; modulo i bytes D kanal
	move.l 	#$ffffffff,$44(a6) ; blitter a mask
	move.w  #$09f0,$40(a6)	; blitcon0
	move.w 	#$0000,$42(a6)	; blitcon1
	move.w 	#64*64+20,$58(a6)	; blitsize
	rts

congratulations:
	jsr	initsprite
	lea.l	infomsgs,a0
	lea.l	infoscreen,a1
	add.l	#0*40,a0	; congratulations offset
	add.l	#4160,a1	; position on screen
	move.l	#$dff000,a6
	move.w	#150,d7
congdll:
	jsr	waitblit
	move.l 	a0,$50(a6)	; A kanal peker
	move.l 	a1,$54(a6)	; D kanal peker
	move.w 	#00,$64(a6)	; modulo i bytes A kanal
	move.w 	#00,$66(a6)	; modulo i bytes D kanal
	move.l 	#$ffffffff,$44(a6) ; blitter a mask
	move.w  #$09f0,$40(a6)	; blitcon0
	move.w 	#$0000,$42(a6)	; blitcon1
	move.w 	#64*32+20,$58(a6)	; blitsize
	jsr	vblank
	dbra	d7,congdll
	jsr	clearinfo
	rts

gotyou:
	jsr	initsprite
	lea.l	infomsgs,a0
	lea.l	infoscreen,a1
	add.l	#32*40,a0	; congratulations offset
	add.l	#4480,a1	; position on screen
	move.l	#$dff000,a6
	move.w	#150,d7
gotyoudll:
	jsr	waitblit
	move.l 	a0,$50(a6)	; A kanal peker
	move.l 	a1,$54(a6)	; D kanal peker
	move.w 	#00,$64(a6)	; modulo i bytes A kanal
	move.w 	#00,$66(a6)	; modulo i bytes D kanal
	move.l 	#$ffffffff,$44(a6) ; blitter a mask
	move.w  #$09f0,$40(a6)	; blitcon0
	move.w 	#$0000,$42(a6)	; blitcon1
	move.w 	#64*16+20,$58(a6)	; blitsize
	jsr	vblank
	dbra	d7,gotyoudll
	jsr	clearinfo
	rts

gameover:
	jsr	calculatehiscore
	jsr	printhiscore
	jsr	highscore
	jsr	snackman
	jsr	credits
	move.w	#$540,cheesecolor
	lea.l	board1,a0
	jsr	drawboard
	lea.l	cheese1,a0
	jsr	initcheese

	moveq	#0,d5
goloop:
	jsr	vblank
	jsr	doscroller
	jsr	scrollertoscreen
	lea.l	infomsgs,a0
	lea.l	infoscreen,a1
	add.l	#80*40,a0
	add.l	#112*40,a1	
	lea.l	$dff000,a6
	add.l	#1,d5
	btst	#4,d5
	beq	clearit	
	jsr	waitblit
	move.l 	a0,$50(a6)	; A kanal peker
	move.l 	a1,$54(a6)	; D kanal peker
	move.w 	#00,$64(a6)	; modulo i bytes A kanal
	move.w 	#00,$66(a6)	; modulo i bytes D kanal
	move.l 	#$ffffffff,$44(a6) ; blitter a mask
	move.w  #$09f0,$40(a6)	; blitcon0
	move.w 	#$0000,$42(a6)	; blitcon1
	move.w 	#64*32+20,$58(a6)	; blitsize
	bra	waitforpress
clearit:
	jsr	waitblit
	move.l 	a1,$54(a6)	; D kanal peker
	move.w 	#00,$66(a6)	; modulo i bytes D kanal
	move.l 	#$ffffffff,$44(a6) ; blitter a mask
	move.w  #$0100,$40(a6)	; blitcon0
	move.w 	#$0000,$42(a6)	; blitcon1
	move.w 	#64*32+20,$58(a6)	; blitsize
waitforpress:
	btst	#6,$bfe001
	beq	terminate
	btst	#7,$bfe001
	bne	goloop

	jsr	initsprite
	jsr	initcollision

	move.w	#$a90,cheesecolor
	move.b	#STARTLIVES,lives	
	move.l	#$00000000,score
	move.w	#0,difficulty
	move.w	#STARTSPEED,pacspeed
			; set start difficulty
	lea.l	ghost1,a6
	move.w	#1,GSPEED(a6)
	move.l	#$00380018,GPOS(a6)
	lea.l	ghost2,a6
	move.w	#1,GSPEED(a6)
	move.l	#$00680018,GPOS(a6)
	lea.l	ghost3,a6
	move.w	#1,GSPEED(a6)
	move.l	#$00980018,GPOS(a6)
	lea.l	ghost4,a6
	move.w	#1,GSPEED(a6)
	move.l	#$00c80018,GPOS(a6)
	move.w	#1,pacspeed

	jsr	clearinfo
	jsr	getready
	jsr	go
terminate:
	rts

newletter:
	move.l	scrptr,a0
	move.b	(a0),d0
	bne.s	doletter
	lea.l	scrtxt,a0
	move.l	a0,scrptr
	move.b	(a0),d0
doletter:
	add.l	#1,scrptr
	lea.l	font8x8,a1
	sub.b	#32,d0
	and.w	#$00ff,d0
	add.w	d0,a1
	lea.l	scrmem,a2
	add.l	#39,a2
	move.w	#6,d2
doltrloop:
	move.b	(a1),(a2)
	add.w	#100,a1
	add.w	#40,a2
	dbra	d2,doltrloop
	rts

shiftscrleft:
	lea.l	scrmem,a0
	add.l	#40*7,a0
	move.l	#$dff000,a6
	jsr	waitblit
	move.l 	a0,$50(a6)	; A kanal peker
	move.l 	a0,$54(a6)	; D kanal peker
	move.w 	#00,$64(a6)	; modulo i bytes A kanal
	move.w 	#00,$66(a6)	; modulo i bytes D kanal
	move.l 	#$ffffffff,$44(a6) ; blitter a mask
	move.w  #$29f0,$40(a6)	; blitcon0 - pixel shift
	move.w 	#$0002,$42(a6)	; blitcon1 - descending mode
	move.w 	#64*7+20,$58(a6)	; blitsize
	rts

doscroller:
	move.w	scrcounter,d0
	and.w	#$3,d0
	bne	nonewltr
	jsr	newletter
nonewltr:
	jsr	shiftscrleft
	add.w	#1,scrcounter
	rts

scrollertoscreen:
	lea.l	scrmem,a0
	add.l	#2,a0
	lea.l	infoscreen,a1
	add.l	#228*40+2,a1
	move.l	#$dff000,a6
	jsr	waitblit
	move.l 	a0,$50(a6)	; A kanal peker
	move.l 	a1,$54(a6)	; D kanal peker
	move.w 	#04,$64(a6)	; modulo i bytes A kanal
	move.w 	#04,$66(a6)	; modulo i bytes D kanal
	move.l 	#$ffffffff,$44(a6) ; blitter a mask
	move.w  #$09f0,$40(a6)	; blitcon0
	move.w 	#$0000,$42(a6)	; blitcon1
	move.w 	#64*8+18,$58(a6)	; blitsize
	rts

clearinfo:
	lea.l	$dff000,a6
	jsr	waitblit
	move.l 	#infoscreen,$54(a6)	; D kanal peker
	move.w 	#00,$66(a6)	; modulo i bytes D kanal
	move.l 	#$ffffffff,$44(a6) ; blitter a mask
	move.w  #$0100,$40(a6)	; blitcon0
	move.w 	#$0000,$42(a6)	; blitcon1
	move.w 	#64*256+20,$58(a6)	; blitsize
	jsr	waitblit
	rts

jatilef:
	jsr	initsprite
	lea.l	efscreen,a0
	lea.l	ef1h,a1
	move.l	a0,d0
	move.w	d0,6(a1)
	swap	d0
	move.w	d0,2(a1)
	swap	d0
	add.l	#10240,d0
	add.l	#8,a1
	move.w	d0,6(a1)
	swap	d0
	move.w	d0,2(a1)
	swap	d0
	add.l	#10240,d0
	add.l	#8,a1
	move.w	d0,6(a1)
	swap	d0
	move.w	d0,2(a1)

	jsr	realblank
	move.w	#$7fff,$dff096
	lea.l	efcoplist,a0
	move.l	a0,$dff080
	move.w	#0,$dff088
	move.w	#$8380,$dff096
jadelay:
	lea.l	efccol,a2
	lea.l	efcol,a3
	move.w	#7,d5
	jsr	faderoutine

	btst	#10,$dff016 
	beq.s	e_nuff
	bra.s	jadelay
e_nuff:	
	lea.l	efccol,a2
	lea.l	efcol2,a3
	move.w	#7,d5
	jsr	faderoutine
	rts

introduction:
	lea.l	board,a0
	lea.l	intd1h,a1
	move.l	a0,d0
	move.w	d0,6(a1)
	swap	d0
	move.w	d0,2(a1)
	swap	d0
	add.l	#10240,d0
	add.l	#8,a1
	move.w	d0,6(a1)
	swap	d0
	move.w	d0,2(a1)
	swap	d0
	add.l	#10240,d0
	add.l	#8,a1
	move.w	d0,6(a1)
	swap	d0
	move.w	d0,2(a1)
	swap	d0
	add.l	#10240,d0
	add.l	#8,a1
	move.w	d0,6(a1)
	swap	d0
	move.w	d0,2(a1)
	swap	d0
	add.l	#10240,d0
	add.l	#8,a1
	move.w	d0,6(a1)
	swap	d0
	move.w	d0,2(a1)

	jsr	realblank
	move.w	#$7fff,$dff096
	lea.l	intdcoplist,a0
	move.l	a0,$dff080
	move.w	#0,$dff088
	move.w	#$83c0,$dff096

	lea.l	introccol,a2
	lea.l	introcol,a3
	move.w	#31,d5
	jsr	faderoutine	; fadein opening screen
introdelay:
	jsr	vblank
	btst	#7,$bfe001
	bne	introdelay	; wait until button is pressed
continue:	
	jsr	vblank
	btst	#7,$bfe001
	beq	continue	; wait until button is released

	lea.l	introccol,a2
	lea.l	introcol2,a3
	move.w	#31,d5
	jsr	faderoutine
	
	lea.l	board,a0	; clear board
	move.w	#10239,d7
intclrlp:
	move.l	#0,(a0)+
	dbra	d7,intclrlp
		
	rts

faderoutine:
	move.w	#3,d6
	mulu.w	d5,d6
fadeouter:	
	move.w	#3,fadespeed
fadeit:
	jsr	vblank
	jsr	realblank
	sub.w	#1,fadespeed
	bne	fadeit

	move.l	a2,a0
	move.l	a3,a1
	move.w	d5,d7

	adda.l	#2,a0
fadeloop:
	move.w	(a0),d0
	move.w	(a1)+,d1
	
	move.w	d0,d2
	move.w	d1,d3

	and.w	#$00f,d2
	and.w	#$00f,d3
	cmp.w	d2,d3
	beq	fadenext
	ble	fadedown
	add.w	#$001,d0
	bra	fadenext	
fadedown:
	sub.w	#$001,d0
fadenext:	
	move.w	d0,d2
	move.w	d1,d3
	and.w	#$0f0,d2
	and.w	#$0f0,d3
	cmp.w	d2,d3
	beq	fadenext2
	ble	fadedown2
	add.w	#$010,d0
	bra	fadenext2
fadedown2:
	sub.w	#$010,d0
fadenext2:
	move.w	d0,d2
	move.w	d1,d3
	and.w	#$f00,d2
	and.w	#$f00,d3
	cmp.w	d2,d3
	beq	fadenext3
	ble	fadedown3
	add.w	#$100,d0
	bra	fadenext3
fadedown3:
	sub.w	#$100,d0
fadenext3:						
	move.w	d0,(a0)

	adda.l	#4,a0
	dbra	d7,fadeloop
	dbra	d6,fadeouter
	rts
fadespeed:
	dc.w	0
	
;	**** MUSIC ROUTINE ****

;********************************************
;* ----- Protracker V1.1B Playroutine ----- *
;* Lars "Zap" Hamre/Amiga Freelancers 1991  *
;* Bekkeliveien 10, N-2010 STRØMMEN, Norway *
;********************************************

; VBlank Version 2:
; Call mt_init to initialize the routine, then call mt_music on
; each vertical blank (50 Hz). To end the song and turn off all
; voices, call mt_end.

; This playroutine is not very fast, optimized or well commented,
; but all the new commands in PT1.1A should work.
; If it's not good enough, you'll have to change it yourself.
; We'll try to write a faster routine soon...

; Changes from V1.0C playroutine:
; - Vibrato depth changed to be compatible with Noisetracker 2.0.
;   You'll have to double all vib. depths on old PT modules.
; - Funk Repeat changed to Invert Loop.
; - Period set back earlier when stopping an effect.

DMAWait = 300 ; Set this as low as possible without losing low notes.

n_note		EQU	0  ; W
n_cmd		EQU	2  ; W
n_cmdlo		EQU	3  ; B
n_start		EQU	4  ; L
n_length	EQU	8  ; W
n_loopstart	EQU	10 ; L
n_replen	EQU	14 ; W
n_period	EQU	16 ; W
n_finetune	EQU	18 ; B
n_volume	EQU	19 ; B
n_dmabit	EQU	20 ; W
n_toneportdirec	EQU	22 ; B
n_toneportspeed	EQU	23 ; B
n_wantedperiod	EQU	24 ; W
n_vibratocmd	EQU	26 ; B
n_vibratopos	EQU	27 ; B
n_tremolocmd	EQU	28 ; B
n_tremolopos	EQU	29 ; B
n_wavecontrol	EQU	30 ; B
n_glissfunk	EQU	31 ; B
n_sampleoffset	EQU	32 ; B
n_pattpos	EQU	33 ; B
n_loopcount	EQU	34 ; B
n_funkoffset	EQU	35 ; B
n_wavestart	EQU	36 ; L
n_reallength	EQU	40 ; W

mt_init	LEA	mt_data,A0
	MOVE.L	A0,mt_SongDataPtr
	MOVE.L	A0,A1
	LEA	952(A1),A1
	MOVEQ	#127,D0
	MOVEQ	#0,D1
mtloop	MOVE.L	D1,D2
	SUBQ.W	#1,D0
mtloop2	MOVE.B	(A1)+,D1
	CMP.B	D2,D1
	BGT.S	mtloop
	DBRA	D0,mtloop2
	ADDQ.B	#1,D2
			
	LEA	mt_SampleStarts(PC),A1
	ASL.L	#8,D2
	ASL.L	#2,D2
	ADD.L	#1084,D2
	ADD.L	A0,D2
	MOVE.L	D2,A2
	MOVEQ	#30,D0
mtloop3	CLR.L	(A2)
	MOVE.L	A2,(A1)+
	MOVEQ	#0,D1
	MOVE.W	42(A0),D1
	ASL.L	#1,D1
	ADD.L	D1,A2
	ADD.L	#30,A0
	DBRA	D0,mtloop3

	OR.B	#2,$BFE001
	MOVE.B	#6,mt_speed
	CLR.B	mt_counter
	CLR.B	mt_SongPos
	CLR.W	mt_PatternPos
mt_end	CLR.W	$DFF0A8
	CLR.W	$DFF0B8
	CLR.W	$DFF0C8
	CLR.W	$DFF0D8
	MOVE.W	#$F,$DFF096
	RTS

mt_music
	MOVEM.L	D0-D4/A0-A6,-(SP)
	ADDQ.B	#1,mt_counter
	MOVE.B	mt_counter(PC),D0
	CMP.B	mt_speed(PC),D0
	BLO.S	mt_NoNewNote
	CLR.B	mt_counter
	TST.B	mt_PattDelTime2
	BEQ.S	mt_GetNewNote
	BSR.S	mt_NoNewAllChannels
	BRA	mt_dskip

mt_NoNewNote
	BSR.S	mt_NoNewAllChannels
	BRA	mt_NoNewPosYet

mt_NoNewAllChannels
	LEA	$DFF0A0,A5
	LEA	mt_chan1temp(PC),A6
	BSR	mt_CheckEfx
	LEA	$DFF0B0,A5
	LEA	mt_chan2temp(PC),A6
	BSR	mt_CheckEfx
	LEA	$DFF0C0,A5
	LEA	mt_chan3temp(PC),A6
	BSR	mt_CheckEfx
	LEA	$DFF0D0,A5
	LEA	mt_chan4temp(PC),A6
	BRA	mt_CheckEfx

mt_GetNewNote
	MOVE.L	mt_SongDataPtr(PC),A0
	LEA	12(A0),A3
	LEA	952(A0),A2	;pattpo
	LEA	1084(A0),A0	;patterndata
	MOVEQ	#0,D0
	MOVEQ	#0,D1
	MOVE.B	mt_SongPos(PC),D0
	MOVE.B	(A2,D0.W),D1
	ASL.L	#8,D1
	ASL.L	#2,D1
	ADD.W	mt_PatternPos(PC),D1
	CLR.W	mt_DMACONtemp

	LEA	$DFF0A0,A5
	LEA	mt_chan1temp(PC),A6
	BSR.S	mt_PlayVoice
	LEA	$DFF0B0,A5
	LEA	mt_chan2temp(PC),A6
	BSR.S	mt_PlayVoice
	LEA	$DFF0C0,A5
	LEA	mt_chan3temp(PC),A6
	BSR.S	mt_PlayVoice
	LEA	$DFF0D0,A5
	LEA	mt_chan4temp(PC),A6
	BSR.S	mt_PlayVoice
	BRA	mt_SetDMA

mt_PlayVoice
	TST.L	(A6)
	BNE.S	mt_plvskip
	BSR	mt_PerNop
mt_plvskip
	MOVE.L	(A0,D1.L),(A6)
	ADDQ.L	#4,D1
	MOVEQ	#0,D2
	MOVE.B	n_cmd(A6),D2
	AND.B	#$F0,D2
	LSR.B	#4,D2
	MOVE.B	(A6),D0
	AND.B	#$F0,D0
	OR.B	D0,D2
	TST.B	D2
	BEQ	mt_SetRegs
	MOVEQ	#0,D3
	LEA	mt_SampleStarts(PC),A1
	MOVE	D2,D4
	SUBQ.L	#1,D2
	ASL.L	#2,D2
	MULU	#30,D4
	MOVE.L	(A1,D2.L),n_start(A6)
	MOVE.W	(A3,D4.L),n_length(A6)
	MOVE.W	(A3,D4.L),n_reallength(A6)
	MOVE.B	2(A3,D4.L),n_finetune(A6)
	MOVE.B	3(A3,D4.L),n_volume(A6)
	MOVE.W	4(A3,D4.L),D3 ; Get repeat
	TST.W	D3
	BEQ.S	mt_NoLoop
	MOVE.L	n_start(A6),D2	; Get start
	ASL.W	#1,D3
	ADD.L	D3,D2		; Add repeat
	MOVE.L	D2,n_loopstart(A6)
	MOVE.L	D2,n_wavestart(A6)
	MOVE.W	4(A3,D4.L),D0	; Get repeat
	ADD.W	6(A3,D4.L),D0	; Add replen
	MOVE.W	D0,n_length(A6)
	MOVE.W	6(A3,D4.L),n_replen(A6)	; Save replen
	MOVEQ	#0,D0
	MOVE.B	n_volume(A6),D0
	MOVE.W	D0,8(A5)	; Set volume
	BRA.S	mt_SetRegs

mt_NoLoop
	MOVE.L	n_start(A6),D2
	ADD.L	D3,D2
	MOVE.L	D2,n_loopstart(A6)
	MOVE.L	D2,n_wavestart(A6)
	MOVE.W	6(A3,D4.L),n_replen(A6)	; Save replen
	MOVEQ	#0,D0
	MOVE.B	n_volume(A6),D0
	MOVE.W	D0,8(A5)	; Set volume
mt_SetRegs
	MOVE.W	(A6),D0
	AND.W	#$0FFF,D0
	BEQ	mt_CheckMoreEfx	; If no note
	MOVE.W	2(A6),D0
	AND.W	#$0FF0,D0
	CMP.W	#$0E50,D0
	BEQ.S	mt_DoSetFineTune
	MOVE.B	2(A6),D0
	AND.B	#$0F,D0
	CMP.B	#3,D0	; TonePortamento
	BEQ.S	mt_ChkTonePorta
	CMP.B	#5,D0
	BEQ.S	mt_ChkTonePorta
	CMP.B	#9,D0	; Sample Offset
	BNE.S	mt_SetPeriod
	BSR	mt_CheckMoreEfx
	BRA.S	mt_SetPeriod

mt_DoSetFineTune
	BSR	mt_SetFineTune
	BRA.S	mt_SetPeriod

mt_ChkTonePorta
	BSR	mt_SetTonePorta
	BRA	mt_CheckMoreEfx

mt_SetPeriod
	MOVEM.L	D0-D1/A0-A1,-(SP)
	MOVE.W	(A6),D1
	AND.W	#$0FFF,D1
	LEA	mt_PeriodTable(PC),A1
	MOVEQ	#0,D0
	MOVEQ	#36,D7
mt_ftuloop
	CMP.W	(A1,D0.W),D1
	BHS.S	mt_ftufound
	ADDQ.L	#2,D0
	DBRA	D7,mt_ftuloop
mt_ftufound
	MOVEQ	#0,D1
	MOVE.B	n_finetune(A6),D1
	MULU	#36*2,D1
	ADD.L	D1,A1
	MOVE.W	(A1,D0.W),n_period(A6)
	MOVEM.L	(SP)+,D0-D1/A0-A1

	MOVE.W	2(A6),D0
	AND.W	#$0FF0,D0
	CMP.W	#$0ED0,D0 ; Notedelay
	BEQ	mt_CheckMoreEfx

	MOVE.W	n_dmabit(A6),$DFF096
	BTST	#2,n_wavecontrol(A6)
	BNE.S	mt_vibnoc
	CLR.B	n_vibratopos(A6)
mt_vibnoc
	BTST	#6,n_wavecontrol(A6)
	BNE.S	mt_trenoc
	CLR.B	n_tremolopos(A6)
mt_trenoc
	MOVE.L	n_start(A6),(A5)	; Set start
	MOVE.W	n_length(A6),4(A5)	; Set length
	MOVE.W	n_period(A6),D0
	MOVE.W	D0,6(A5)		; Set period
	MOVE.W	n_dmabit(A6),D0
	OR.W	D0,mt_DMACONtemp
	BRA	mt_CheckMoreEfx
 
mt_SetDMA
	MOVE.W	#300,D0
mt_WaitDMA
	DBRA	D0,mt_WaitDMA
	MOVE.W	mt_DMACONtemp(PC),D0
	OR.W	#$8000,D0
	MOVE.W	D0,$DFF096
	MOVE.W	#300,D0
mt_WaitDMA2
	DBRA	D0,mt_WaitDMA2

	LEA	$DFF000,A5
	LEA	mt_chan4temp(PC),A6
	MOVE.L	n_loopstart(A6),$D0(A5)
	MOVE.W	n_replen(A6),$D4(A5)
	LEA	mt_chan3temp(PC),A6
	MOVE.L	n_loopstart(A6),$C0(A5)
	MOVE.W	n_replen(A6),$C4(A5)
	LEA	mt_chan2temp(PC),A6
	MOVE.L	n_loopstart(A6),$B0(A5)
	MOVE.W	n_replen(A6),$B4(A5)
	LEA	mt_chan1temp(PC),A6
	MOVE.L	n_loopstart(A6),$A0(A5)
	MOVE.W	n_replen(A6),$A4(A5)

mt_dskip
	ADD.W	#16,mt_PatternPos
	MOVE.B	mt_PattDelTime,D0
	BEQ.S	mt_dskc
	MOVE.B	D0,mt_PattDelTime2
	CLR.B	mt_PattDelTime
mt_dskc	TST.B	mt_PattDelTime2
	BEQ.S	mt_dska
	SUBQ.B	#1,mt_PattDelTime2
	BEQ.S	mt_dska
	SUB.W	#16,mt_PatternPos
mt_dska	TST.B	mt_PBreakFlag
	BEQ.S	mt_nnpysk
	SF	mt_PBreakFlag
	MOVEQ	#0,D0
	MOVE.B	mt_PBreakPos(PC),D0
	CLR.B	mt_PBreakPos
	LSL.W	#4,D0
	MOVE.W	D0,mt_PatternPos
mt_nnpysk
	CMP.W	#1024,mt_PatternPos
	BLO.S	mt_NoNewPosYet
mt_NextPosition	
	MOVEQ	#0,D0
	MOVE.B	mt_PBreakPos(PC),D0
	LSL.W	#4,D0
	MOVE.W	D0,mt_PatternPos
	CLR.B	mt_PBreakPos
	CLR.B	mt_PosJumpFlag
	ADDQ.B	#1,mt_SongPos
	AND.B	#$7F,mt_SongPos
	MOVE.B	mt_SongPos(PC),D1
	MOVE.L	mt_SongDataPtr(PC),A0
	CMP.B	950(A0),D1
	BLO.S	mt_NoNewPosYet
	CLR.B	mt_SongPos
mt_NoNewPosYet	
	TST.B	mt_PosJumpFlag
	BNE.S	mt_NextPosition
	MOVEM.L	(SP)+,D0-D4/A0-A6
	RTS

mt_CheckEfx
	BSR	mt_UpdateFunk
	MOVE.W	n_cmd(A6),D0
	AND.W	#$0FFF,D0
	BEQ.S	mt_PerNop
	MOVE.B	n_cmd(A6),D0
	AND.B	#$0F,D0
	BEQ.S	mt_Arpeggio
	CMP.B	#1,D0
	BEQ	mt_PortaUp
	CMP.B	#2,D0
	BEQ	mt_PortaDown
	CMP.B	#3,D0
	BEQ	mt_TonePortamento
	CMP.B	#4,D0
	BEQ	mt_Vibrato
	CMP.B	#5,D0
	BEQ	mt_TonePlusVolSlide
	CMP.B	#6,D0
	BEQ	mt_VibratoPlusVolSlide
	CMP.B	#$E,D0
	BEQ	mt_E_Commands
SetBack	MOVE.W	n_period(A6),6(A5)
	CMP.B	#7,D0
	BEQ	mt_Tremolo
	CMP.B	#$A,D0
	BEQ	mt_VolumeSlide
mt_Return2
	RTS

mt_PerNop
	MOVE.W	n_period(A6),6(A5)
	RTS

mt_Arpeggio
	MOVEQ	#0,D0
	MOVE.B	mt_counter(PC),D0
	DIVS	#3,D0
	SWAP	D0
	CMP.W	#0,D0
	BEQ.S	mt_Arpeggio2
	CMP.W	#2,D0
	BEQ.S	mt_Arpeggio1
	MOVEQ	#0,D0
	MOVE.B	n_cmdlo(A6),D0
	LSR.B	#4,D0
	BRA.S	mt_Arpeggio3

mt_Arpeggio1
	MOVEQ	#0,D0
	MOVE.B	n_cmdlo(A6),D0
	AND.B	#15,D0
	BRA.S	mt_Arpeggio3

mt_Arpeggio2
	MOVE.W	n_period(A6),D2
	BRA.S	mt_Arpeggio4

mt_Arpeggio3
	ASL.W	#1,D0
	MOVEQ	#0,D1
	MOVE.B	n_finetune(A6),D1
	MULU	#36*2,D1
	LEA	mt_PeriodTable(PC),A0
	ADD.L	D1,A0
	MOVEQ	#0,D1
	MOVE.W	n_period(A6),D1
	MOVEQ	#36,D7
mt_arploop
	MOVE.W	(A0,D0.W),D2
	CMP.W	(A0),D1
	BHS.S	mt_Arpeggio4
	ADDQ.L	#2,A0
	DBRA	D7,mt_arploop
	RTS

mt_Arpeggio4
	MOVE.W	D2,6(A5)
	RTS

mt_FinePortaUp
	TST.B	mt_counter
	BNE.S	mt_Return2
	MOVE.B	#$0F,mt_LowMask
mt_PortaUp
	MOVEQ	#0,D0
	MOVE.B	n_cmdlo(A6),D0
	AND.B	mt_LowMask(PC),D0
	MOVE.B	#$FF,mt_LowMask
	SUB.W	D0,n_period(A6)
	MOVE.W	n_period(A6),D0
	AND.W	#$0FFF,D0
	CMP.W	#113,D0
	BPL.S	mt_PortaUskip
	AND.W	#$F000,n_period(A6)
	OR.W	#113,n_period(A6)
mt_PortaUskip
	MOVE.W	n_period(A6),D0
	AND.W	#$0FFF,D0
	MOVE.W	D0,6(A5)
	RTS	
 
mt_FinePortaDown
	TST.B	mt_counter
	BNE	mt_Return2
	MOVE.B	#$0F,mt_LowMask
mt_PortaDown
	CLR.W	D0
	MOVE.B	n_cmdlo(A6),D0
	AND.B	mt_LowMask(PC),D0
	MOVE.B	#$FF,mt_LowMask
	ADD.W	D0,n_period(A6)
	MOVE.W	n_period(A6),D0
	AND.W	#$0FFF,D0
	CMP.W	#856,D0
	BMI.S	mt_PortaDskip
	AND.W	#$F000,n_period(A6)
	OR.W	#856,n_period(A6)
mt_PortaDskip
	MOVE.W	n_period(A6),D0
	AND.W	#$0FFF,D0
	MOVE.W	D0,6(A5)
	RTS

mt_SetTonePorta
	MOVE.L	A0,-(SP)
	MOVE.W	(A6),D2
	AND.W	#$0FFF,D2
	MOVEQ	#0,D0
	MOVE.B	n_finetune(A6),D0
	MULU	#37*2,D0
	LEA	mt_PeriodTable(PC),A0
	ADD.L	D0,A0
	MOVEQ	#0,D0
mt_StpLoop
	CMP.W	(A0,D0.W),D2
	BHS.S	mt_StpFound
	ADDQ.W	#2,D0
	CMP.W	#37*2,D0
	BLO.S	mt_StpLoop
	MOVEQ	#35*2,D0
mt_StpFound
	MOVE.B	n_finetune(A6),D2
	AND.B	#8,D2
	BEQ.S	mt_StpGoss
	TST.W	D0
	BEQ.S	mt_StpGoss
	SUBQ.W	#2,D0
mt_StpGoss
	MOVE.W	(A0,D0.W),D2
	MOVE.L	(SP)+,A0
	MOVE.W	D2,n_wantedperiod(A6)
	MOVE.W	n_period(A6),D0
	CLR.B	n_toneportdirec(A6)
	CMP.W	D0,D2
	BEQ.S	mt_ClearTonePorta
	BGE	mt_Return2
	MOVE.B	#1,n_toneportdirec(A6)
	RTS

mt_ClearTonePorta
	CLR.W	n_wantedperiod(A6)
	RTS

mt_TonePortamento
	MOVE.B	n_cmdlo(A6),D0
	BEQ.S	mt_TonePortNoChange
	MOVE.B	D0,n_toneportspeed(A6)
	CLR.B	n_cmdlo(A6)
mt_TonePortNoChange
	TST.W	n_wantedperiod(A6)
	BEQ	mt_Return2
	MOVEQ	#0,D0
	MOVE.B	n_toneportspeed(A6),D0
	TST.B	n_toneportdirec(A6)
	BNE.S	mt_TonePortaUp
mt_TonePortaDown
	ADD.W	D0,n_period(A6)
	MOVE.W	n_wantedperiod(A6),D0
	CMP.W	n_period(A6),D0
	BGT.S	mt_TonePortaSetPer
	MOVE.W	n_wantedperiod(A6),n_period(A6)
	CLR.W	n_wantedperiod(A6)
	BRA.S	mt_TonePortaSetPer

mt_TonePortaUp
	SUB.W	D0,n_period(A6)
	MOVE.W	n_wantedperiod(A6),D0
	CMP.W	n_period(A6),D0
	BLT.S	mt_TonePortaSetPer
	MOVE.W	n_wantedperiod(A6),n_period(A6)
	CLR.W	n_wantedperiod(A6)

mt_TonePortaSetPer
	MOVE.W	n_period(A6),D2
	MOVE.B	n_glissfunk(A6),D0
	AND.B	#$0F,D0
	BEQ.S	mt_GlissSkip
	MOVEQ	#0,D0
	MOVE.B	n_finetune(A6),D0
	MULU	#36*2,D0
	LEA	mt_PeriodTable(PC),A0
	ADD.L	D0,A0
	MOVEQ	#0,D0
mt_GlissLoop
	CMP.W	(A0,D0.W),D2
	BHS.S	mt_GlissFound
	ADDQ.W	#2,D0
	CMP.W	#36*2,D0
	BLO.S	mt_GlissLoop
	MOVEQ	#35*2,D0
mt_GlissFound
	MOVE.W	(A0,D0.W),D2
mt_GlissSkip
	MOVE.W	D2,6(A5) ; Set period
	RTS

mt_Vibrato
	MOVE.B	n_cmdlo(A6),D0
	BEQ.S	mt_Vibrato2
	MOVE.B	n_vibratocmd(A6),D2
	AND.B	#$0F,D0
	BEQ.S	mt_vibskip
	AND.B	#$F0,D2
	OR.B	D0,D2
mt_vibskip
	MOVE.B	n_cmdlo(A6),D0
	AND.B	#$F0,D0
	BEQ.S	mt_vibskip2
	AND.B	#$0F,D2
	OR.B	D0,D2
mt_vibskip2
	MOVE.B	D2,n_vibratocmd(A6)
mt_Vibrato2
	MOVE.B	n_vibratopos(A6),D0
	LEA	mt_VibratoTable(PC),A4
	LSR.W	#2,D0
	AND.W	#$001F,D0
	MOVEQ	#0,D2
	MOVE.B	n_wavecontrol(A6),D2
	AND.B	#$03,D2
	BEQ.S	mt_vib_sine
	LSL.B	#3,D0
	CMP.B	#1,D2
	BEQ.S	mt_vib_rampdown
	MOVE.B	#255,D2
	BRA.S	mt_vib_set
mt_vib_rampdown
	TST.B	n_vibratopos(A6)
	BPL.S	mt_vib_rampdown2
	MOVE.B	#255,D2
	SUB.B	D0,D2
	BRA.S	mt_vib_set
mt_vib_rampdown2
	MOVE.B	D0,D2
	BRA.S	mt_vib_set
mt_vib_sine
	MOVE.B	0(A4,D0.W),D2
mt_vib_set
	MOVE.B	n_vibratocmd(A6),D0
	AND.W	#15,D0
	MULU	D0,D2
	LSR.W	#7,D2
	MOVE.W	n_period(A6),D0
	TST.B	n_vibratopos(A6)
	BMI.S	mt_VibratoNeg
	ADD.W	D2,D0
	BRA.S	mt_Vibrato3
mt_VibratoNeg
	SUB.W	D2,D0
mt_Vibrato3
	MOVE.W	D0,6(A5)
	MOVE.B	n_vibratocmd(A6),D0
	LSR.W	#2,D0
	AND.W	#$003C,D0
	ADD.B	D0,n_vibratopos(A6)
	RTS

mt_TonePlusVolSlide
	BSR	mt_TonePortNoChange
	BRA	mt_VolumeSlide

mt_VibratoPlusVolSlide
	BSR.S	mt_Vibrato2
	BRA	mt_VolumeSlide

mt_Tremolo
	MOVE.B	n_cmdlo(A6),D0
	BEQ.S	mt_Tremolo2
	MOVE.B	n_tremolocmd(A6),D2
	AND.B	#$0F,D0
	BEQ.S	mt_treskip
	AND.B	#$F0,D2
	OR.B	D0,D2
mt_treskip
	MOVE.B	n_cmdlo(A6),D0
	AND.B	#$F0,D0
	BEQ.S	mt_treskip2
	AND.B	#$0F,D2
	OR.B	D0,D2
mt_treskip2
	MOVE.B	D2,n_tremolocmd(A6)
mt_Tremolo2
	MOVE.B	n_tremolopos(A6),D0
	LEA	mt_VibratoTable(PC),A4
	LSR.W	#2,D0
	AND.W	#$001F,D0
	MOVEQ	#0,D2
	MOVE.B	n_wavecontrol(A6),D2
	LSR.B	#4,D2
	AND.B	#$03,D2
	BEQ.S	mt_tre_sine
	LSL.B	#3,D0
	CMP.B	#1,D2
	BEQ.S	mt_tre_rampdown
	MOVE.B	#255,D2
	BRA.S	mt_tre_set
mt_tre_rampdown
	TST.B	n_vibratopos(A6)
	BPL.S	mt_tre_rampdown2
	MOVE.B	#255,D2
	SUB.B	D0,D2
	BRA.S	mt_tre_set
mt_tre_rampdown2
	MOVE.B	D0,D2
	BRA.S	mt_tre_set
mt_tre_sine
	MOVE.B	0(A4,D0.W),D2
mt_tre_set
	MOVE.B	n_tremolocmd(A6),D0
	AND.W	#15,D0
	MULU	D0,D2
	LSR.W	#6,D2
	MOVEQ	#0,D0
	MOVE.B	n_volume(A6),D0
	TST.B	n_tremolopos(A6)
	BMI.S	mt_TremoloNeg
	ADD.W	D2,D0
	BRA.S	mt_Tremolo3
mt_TremoloNeg
	SUB.W	D2,D0
mt_Tremolo3
	BPL.S	mt_TremoloSkip
	CLR.W	D0
mt_TremoloSkip
	CMP.W	#$40,D0
	BLS.S	mt_TremoloOk
	MOVE.W	#$40,D0
mt_TremoloOk
	MOVE.W	D0,8(A5)
	MOVE.B	n_tremolocmd(A6),D0
	LSR.W	#2,D0
	AND.W	#$003C,D0
	ADD.B	D0,n_tremolopos(A6)
	RTS

mt_SampleOffset
	MOVEQ	#0,D0
	MOVE.B	n_cmdlo(A6),D0
	BEQ.S	mt_sononew
	MOVE.B	D0,n_sampleoffset(A6)
mt_sononew
	MOVE.B	n_sampleoffset(A6),D0
	LSL.W	#7,D0
	CMP.W	n_length(A6),D0
	BGE.S	mt_sofskip
	SUB.W	D0,n_length(A6)
	LSL.W	#1,D0
	ADD.L	D0,n_start(A6)
	RTS
mt_sofskip
	MOVE.W	#$0001,n_length(A6)
	RTS

mt_VolumeSlide
	MOVEQ	#0,D0
	MOVE.B	n_cmdlo(A6),D0
	LSR.B	#4,D0
	TST.B	D0
	BEQ.S	mt_VolSlideDown
mt_VolSlideUp
	ADD.B	D0,n_volume(A6)
	CMP.B	#$40,n_volume(A6)
	BMI.S	mt_vsuskip
	MOVE.B	#$40,n_volume(A6)
mt_vsuskip
	MOVE.B	n_volume(A6),D0
	MOVE.W	D0,8(A5)
	RTS

mt_VolSlideDown
	MOVEQ	#0,D0
	MOVE.B	n_cmdlo(A6),D0
	AND.B	#$0F,D0
mt_VolSlideDown2
	SUB.B	D0,n_volume(A6)
	BPL.S	mt_vsdskip
	CLR.B	n_volume(A6)
mt_vsdskip
	MOVE.B	n_volume(A6),D0
	MOVE.W	D0,8(A5)
	RTS

mt_PositionJump
	MOVE.B	n_cmdlo(A6),D0
	SUBQ.B	#1,D0
	MOVE.B	D0,mt_SongPos
mt_pj2	CLR.B	mt_PBreakPos
	ST 	mt_PosJumpFlag
	RTS

mt_VolumeChange
	MOVEQ	#0,D0
	MOVE.B	n_cmdlo(A6),D0
	CMP.B	#$40,D0
	BLS.S	mt_VolumeOk
	MOVEQ	#$40,D0
mt_VolumeOk
	MOVE.B	D0,n_volume(A6)
	MOVE.W	D0,8(A5)
	RTS

mt_PatternBreak
	MOVEQ	#0,D0
	MOVE.B	n_cmdlo(A6),D0
	MOVE.L	D0,D2
	LSR.B	#4,D0
	MULU	#10,D0
	AND.B	#$0F,D2
	ADD.B	D2,D0
	CMP.B	#63,D0
	BHI.S	mt_pj2
	MOVE.B	D0,mt_PBreakPos
	ST	mt_PosJumpFlag
	RTS

mt_SetSpeed
	MOVE.B	3(A6),D0
	BEQ	mt_Return2
	CLR.B	mt_counter
	MOVE.B	D0,mt_speed
	RTS

mt_CheckMoreEfx
	BSR	mt_UpdateFunk
	MOVE.B	2(A6),D0
	AND.B	#$0F,D0
	CMP.B	#$9,D0
	BEQ	mt_SampleOffset
	CMP.B	#$B,D0
	BEQ	mt_PositionJump
	CMP.B	#$D,D0
	BEQ.S	mt_PatternBreak
	CMP.B	#$E,D0
	BEQ.S	mt_E_Commands
	CMP.B	#$F,D0
	BEQ.S	mt_SetSpeed
	CMP.B	#$C,D0
	BEQ	mt_VolumeChange
	BRA	mt_PerNop

mt_E_Commands
	MOVE.B	n_cmdlo(A6),D0
	AND.B	#$F0,D0
	LSR.B	#4,D0
	BEQ.S	mt_FilterOnOff
	CMP.B	#1,D0
	BEQ	mt_FinePortaUp
	CMP.B	#2,D0
	BEQ	mt_FinePortaDown
	CMP.B	#3,D0
	BEQ.S	mt_SetGlissControl
	CMP.B	#4,D0
	BEQ	mt_SetVibratoControl
	CMP.B	#5,D0
	BEQ	mt_SetFineTune
	CMP.B	#6,D0
	BEQ	mt_JumpLoop
	CMP.B	#7,D0
	BEQ	mt_SetTremoloControl
	CMP.B	#9,D0
	BEQ	mt_RetrigNote
	CMP.B	#$A,D0
	BEQ	mt_VolumeFineUp
	CMP.B	#$B,D0
	BEQ	mt_VolumeFineDown
	CMP.B	#$C,D0
	BEQ	mt_NoteCut
	CMP.B	#$D,D0
	BEQ	mt_NoteDelay
	CMP.B	#$E,D0
	BEQ	mt_PatternDelay
	CMP.B	#$F,D0
	BEQ	mt_FunkIt
	RTS

mt_FilterOnOff
	MOVE.B	n_cmdlo(A6),D0
	AND.B	#1,D0
	ASL.B	#1,D0
	AND.B	#$FD,$BFE001
	OR.B	D0,$BFE001
	RTS	

mt_SetGlissControl
	MOVE.B	n_cmdlo(A6),D0
	AND.B	#$0F,D0
	AND.B	#$F0,n_glissfunk(A6)
	OR.B	D0,n_glissfunk(A6)
	RTS

mt_SetVibratoControl
	MOVE.B	n_cmdlo(A6),D0
	AND.B	#$0F,D0
	AND.B	#$F0,n_wavecontrol(A6)
	OR.B	D0,n_wavecontrol(A6)
	RTS

mt_SetFineTune
	MOVE.B	n_cmdlo(A6),D0
	AND.B	#$0F,D0
	MOVE.B	D0,n_finetune(A6)
	RTS

mt_JumpLoop
	TST.B	mt_counter
	BNE	mt_Return2
	MOVE.B	n_cmdlo(A6),D0
	AND.B	#$0F,D0
	BEQ.S	mt_SetLoop
	TST.B	n_loopcount(A6)
	BEQ.S	mt_jumpcnt
	SUBQ.B	#1,n_loopcount(A6)
	BEQ	mt_Return2
mt_jmploop	MOVE.B	n_pattpos(A6),mt_PBreakPos
	ST	mt_PBreakFlag
	RTS

mt_jumpcnt
	MOVE.B	D0,n_loopcount(A6)
	BRA.S	mt_jmploop

mt_SetLoop
	MOVE.W	mt_PatternPos(PC),D0
	LSR.W	#4,D0
	MOVE.B	D0,n_pattpos(A6)
	RTS

mt_SetTremoloControl
	MOVE.B	n_cmdlo(A6),D0
	AND.B	#$0F,D0
	LSL.B	#4,D0
	AND.B	#$0F,n_wavecontrol(A6)
	OR.B	D0,n_wavecontrol(A6)
	RTS

mt_RetrigNote
	MOVE.L	D1,-(SP)
	MOVEQ	#0,D0
	MOVE.B	n_cmdlo(A6),D0
	AND.B	#$0F,D0
	BEQ.S	mt_rtnend
	MOVEQ	#0,D1
	MOVE.B	mt_counter(PC),D1
	BNE.S	mt_rtnskp
	MOVE.W	(A6),D1
	AND.W	#$0FFF,D1
	BNE.S	mt_rtnend
	MOVEQ	#0,D1
	MOVE.B	mt_counter(PC),D1
mt_rtnskp
	DIVU	D0,D1
	SWAP	D1
	TST.W	D1
	BNE.S	mt_rtnend
mt_DoRetrig
	MOVE.W	n_dmabit(A6),$DFF096	; Channel DMA off
	MOVE.L	n_start(A6),(A5)	; Set sampledata pointer
	MOVE.W	n_length(A6),4(A5)	; Set length
	MOVE.W	#300,D0
mt_rtnloop1
	DBRA	D0,mt_rtnloop1
	MOVE.W	n_dmabit(A6),D0
	BSET	#15,D0
	MOVE.W	D0,$DFF096
	MOVE.W	#300,D0
mt_rtnloop2
	DBRA	D0,mt_rtnloop2
	MOVE.L	n_loopstart(A6),(A5)
	MOVE.L	n_replen(A6),4(A5)
mt_rtnend
	MOVE.L	(SP)+,D1
	RTS

mt_VolumeFineUp
	TST.B	mt_counter
	BNE	mt_Return2
	MOVEQ	#0,D0
	MOVE.B	n_cmdlo(A6),D0
	AND.B	#$F,D0
	BRA	mt_VolSlideUp

mt_VolumeFineDown
	TST.B	mt_counter
	BNE	mt_Return2
	MOVEQ	#0,D0
	MOVE.B	n_cmdlo(A6),D0
	AND.B	#$0F,D0
	BRA	mt_VolSlideDown2

mt_NoteCut
	MOVEQ	#0,D0
	MOVE.B	n_cmdlo(A6),D0
	AND.B	#$0F,D0
	CMP.B	mt_counter(PC),D0
	BNE	mt_Return2
	CLR.B	n_volume(A6)
	MOVE.W	#0,8(A5)
	RTS

mt_NoteDelay
	MOVEQ	#0,D0
	MOVE.B	n_cmdlo(A6),D0
	AND.B	#$0F,D0
	CMP.B	mt_Counter,D0
	BNE	mt_Return2
	MOVE.W	(A6),D0
	BEQ	mt_Return2
	MOVE.L	D1,-(SP)
	BRA	mt_DoRetrig

mt_PatternDelay
	TST.B	mt_counter
	BNE	mt_Return2
	MOVEQ	#0,D0
	MOVE.B	n_cmdlo(A6),D0
	AND.B	#$0F,D0
	TST.B	mt_PattDelTime2
	BNE	mt_Return2
	ADDQ.B	#1,D0
	MOVE.B	D0,mt_PattDelTime
	RTS

mt_FunkIt
	TST.B	mt_counter
	BNE	mt_Return2
	MOVE.B	n_cmdlo(A6),D0
	AND.B	#$0F,D0
	LSL.B	#4,D0
	AND.B	#$0F,n_glissfunk(A6)
	OR.B	D0,n_glissfunk(A6)
	TST.B	D0
	BEQ	mt_Return2
mt_UpdateFunk
	MOVEM.L	D1/A0,-(SP)
	MOVEQ	#0,D0
	MOVE.B	n_glissfunk(A6),D0
	LSR.B	#4,D0
	BEQ.S	mt_funkend
	LEA	mt_FunkTable(PC),A0
	MOVE.B	(A0,D0.W),D0
	ADD.B	D0,n_funkoffset(A6)
	BTST	#7,n_funkoffset(A6)
	BEQ.S	mt_funkend
	CLR.B	n_funkoffset(A6)

	MOVE.L	n_loopstart(A6),D0
	MOVEQ	#0,D1
	MOVE.W	n_replen(A6),D1
	ADD.L	D1,D0
	ADD.L	D1,D0
	MOVE.L	n_wavestart(A6),A0
	ADDQ.L	#1,A0
	CMP.L	D0,A0
	BLO.S	mt_funkok
	MOVE.L	n_loopstart(A6),A0
mt_funkok
	MOVE.L	A0,n_wavestart(A6)
	MOVEQ	#-1,D0
	SUB.B	(A0),D0
	MOVE.B	D0,(A0)
mt_funkend
	MOVEM.L	(SP)+,D1/A0
	RTS


mt_FunkTable dc.b 0,5,6,7,8,10,11,13,16,19,22,26,32,43,64,128

mt_VibratoTable	
	dc.b   0, 24, 49, 74, 97,120,141,161
	dc.b 180,197,212,224,235,244,250,253
	dc.b 255,253,250,244,235,224,212,197
	dc.b 180,161,141,120, 97, 74, 49, 24

mt_PeriodTable
; Tuning 0, Normal
	dc.w	856,808,762,720,678,640,604,570,538,508,480,453
	dc.w	428,404,381,360,339,320,302,285,269,254,240,226
	dc.w	214,202,190,180,170,160,151,143,135,127,120,113
; Tuning 1
	dc.w	850,802,757,715,674,637,601,567,535,505,477,450
	dc.w	425,401,379,357,337,318,300,284,268,253,239,225
	dc.w	213,201,189,179,169,159,150,142,134,126,119,113
; Tuning 2
	dc.w	844,796,752,709,670,632,597,563,532,502,474,447
	dc.w	422,398,376,355,335,316,298,282,266,251,237,224
	dc.w	211,199,188,177,167,158,149,141,133,125,118,112
; Tuning 3
	dc.w	838,791,746,704,665,628,592,559,528,498,470,444
	dc.w	419,395,373,352,332,314,296,280,264,249,235,222
	dc.w	209,198,187,176,166,157,148,140,132,125,118,111
; Tuning 4
	dc.w	832,785,741,699,660,623,588,555,524,495,467,441
	dc.w	416,392,370,350,330,312,294,278,262,247,233,220
	dc.w	208,196,185,175,165,156,147,139,131,124,117,110
; Tuning 5
	dc.w	826,779,736,694,655,619,584,551,520,491,463,437
	dc.w	413,390,368,347,328,309,292,276,260,245,232,219
	dc.w	206,195,184,174,164,155,146,138,130,123,116,109
; Tuning 6
	dc.w	820,774,730,689,651,614,580,547,516,487,460,434
	dc.w	410,387,365,345,325,307,290,274,258,244,230,217
	dc.w	205,193,183,172,163,154,145,137,129,122,115,109
; Tuning 7
	dc.w	814,768,725,684,646,610,575,543,513,484,457,431
	dc.w	407,384,363,342,323,305,288,272,256,242,228,216
	dc.w	204,192,181,171,161,152,144,136,128,121,114,108
; Tuning -8
	dc.w	907,856,808,762,720,678,640,604,570,538,508,480
	dc.w	453,428,404,381,360,339,320,302,285,269,254,240
	dc.w	226,214,202,190,180,170,160,151,143,135,127,120
; Tuning -7
	dc.w	900,850,802,757,715,675,636,601,567,535,505,477
	dc.w	450,425,401,379,357,337,318,300,284,268,253,238
	dc.w	225,212,200,189,179,169,159,150,142,134,126,119
; Tuning -6
	dc.w	894,844,796,752,709,670,632,597,563,532,502,474
	dc.w	447,422,398,376,355,335,316,298,282,266,251,237
	dc.w	223,211,199,188,177,167,158,149,141,133,125,118
; Tuning -5
	dc.w	887,838,791,746,704,665,628,592,559,528,498,470
	dc.w	444,419,395,373,352,332,314,296,280,264,249,235
	dc.w	222,209,198,187,176,166,157,148,140,132,125,118
; Tuning -4
	dc.w	881,832,785,741,699,660,623,588,555,524,494,467
	dc.w	441,416,392,370,350,330,312,294,278,262,247,233
	dc.w	220,208,196,185,175,165,156,147,139,131,123,117
; Tuning -3
	dc.w	875,826,779,736,694,655,619,584,551,520,491,463
	dc.w	437,413,390,368,347,328,309,292,276,260,245,232
	dc.w	219,206,195,184,174,164,155,146,138,130,123,116
; Tuning -2
	dc.w	868,820,774,730,689,651,614,580,547,516,487,460
	dc.w	434,410,387,365,345,325,307,290,274,258,244,230
	dc.w	217,205,193,183,172,163,154,145,137,129,122,115
; Tuning -1
	dc.w	862,814,768,725,684,646,610,575,543,513,484,457
	dc.w	431,407,384,363,342,323,305,288,272,256,242,228
	dc.w	216,203,192,181,171,161,152,144,136,128,121,114

mt_chan1temp	dc.l	0,0,0,0,0,$00010000,0,  0,0,0,0
mt_chan2temp	dc.l	0,0,0,0,0,$00020000,0,  0,0,0,0
mt_chan3temp	dc.l	0,0,0,0,0,$00040000,0,  0,0,0,0
mt_chan4temp	dc.l	0,0,0,0,0,$00080000,0,  0,0,0,0

mt_SampleStarts	dc.l	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
		dc.l	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

mt_SongDataPtr	dc.l 0

mt_speed	dc.b 6
mt_counter	dc.b 0
mt_SongPos	dc.b 0
mt_PBreakPos	dc.b 0
mt_PosJumpFlag	dc.b 0
mt_PBreakFlag	dc.b 0
mt_LowMask	dc.b 0
mt_PattDelTime	dc.b 0
mt_PattDelTime2	dc.b 0,0

mt_PatternPos	dc.w 0
mt_DMACONtemp	dc.w 0

;/* End of File */

;	**** VARIOUS DATA ****
collctr:		; collision variables
	dc.w	0
coll1:
	dc.w	0
coll2:
	dc.w	0

cheeseeaten:
	dc.w	0
cheesecount:
	dc.w	0
onept:
	dc.l	$1
fivept:
	dc.l	$50
tenpt:
	dc.l	$10
hundredpt:
	dc.l	$100
score:
	dc.l	0
hiscore:
	dc.l	0
lives:
	dc.b	STARTLIVES,0
boost:
	dc.w	0
difficulty:
	dc.w	0
invtable:
	dc.w	7,6,5,4,3,2,1,0
bitcnttable:
	dc.w	0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4
oppositetable:
	dc.w	0,2,1,0,8,0,0,0,4
selecttable:
	dc.w	1,2,4,8
	dc.w	1,2,8,4
	dc.w	1,4,2,8
	dc.w	1,4,8,2
	dc.w	1,8,2,4
	dc.w	1,8,4,2

	dc.w	2,1,4,8
	dc.w	2,1,8,4
	dc.w	2,4,1,8
	dc.w	2,4,8,1
	dc.w	2,8,1,4
	dc.w	2,8,4,1

	dc.w	4,1,2,8
	dc.w	4,1,8,2
	dc.w	4,2,1,8
	dc.w	4,2,8,1
	dc.w	4,8,1,2
	dc.w	4,8,2,1

	dc.w	8,1,2,4
	dc.w	8,1,4,2
	dc.w	8,2,1,4
	dc.w	8,2,4,1
	dc.w	8,4,1,2
	dc.w	8,4,2,1

	dc.w	1,2,4,8
	dc.w	1,2,8,4
	dc.w	1,4,2,8
	dc.w	1,4,8,2
	dc.w	1,8,2,4
	dc.w	1,8,4,2

	dc.w	2,1,4,8
	dc.w	2,1,8,4
	dc.w	2,4,1,8
	dc.w	2,4,8,1
	dc.w	2,8,1,4
	dc.w	2,8,4,1
pacpos:
	dc.w	$98,$d8	; x,y
joydirection:
	dc.w	0
curdir:
	dc.w	0
dirpac:
	dc.l	pacBALL
dirctr:
	dc.w	0
pacspeed:
	dc.w	STARTSPEED	; pacman speed, pixels/sec
testpos:
	dc.w	0,0

ghost1:
; gpos
	dc.w	$38,$18
; gdir
	dc.w	LEFT
; gseed
	dc.l	$8742bca2
; gright
	dc.l	g1_R
; gleft
	dc.l	g1_L
; gup
	dc.l	g1_U
; gdown
	dc.l	g1_D
; gptr
	dc.l	g11h
; gspeed
	dc.w	1
; gstatus
	dc.w	BAD
; gdead
	dc.l	g1_DEAD

ghost2:
; gpos
	dc.w	$68,$18
; gdir
	dc.w	RIGHT
; gseed
	dc.l	$8742bca2
; gright
	dc.l	g2_R
; gleft
	dc.l	g2_L
; gup
	dc.l	g2_U
; gdown
	dc.l	g2_D
; gptr
	dc.l	g21h
; gspeed
	dc.w	1
; gstatus
	dc.w	BAD
; gdead
	dc.l	g2_DEAD

ghost3:
; gpos
	dc.w	$98,$18
; gdir
	dc.w	LEFT
; gseed
	dc.l	$6ca37503
; gright
	dc.l	g3_R
; gleft
	dc.l	g3_L
; gup
	dc.l	g3_U
; gdown
	dc.l	g3_D
; gptr
	dc.l	g31h
; gspeed
	dc.w	1
; gstatus
	dc.w	BAD
; gdead
	dc.l	g3_DEAD

ghost4:
; gpos
	dc.w	$c8,$18
; gdir
	dc.w	RIGHT
; gseed
	dc.l	$6ca37593
; gright
	dc.l	g4_R
; gleft
	dc.l	g4_L
; gup
	dc.l	g4_U
; gdown
	dc.l	g4_D
; gptr
	dc.l	g41h
; gspeed
	dc.w	1
; gstatus
	dc.w	BAD
; gdead
	dc.l	g4_DEAD
RANDOMSEED:
	dc.l	$748c8a29
newtab:
	blk.b	16*20,0
	;	00,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19
cheese1:
	dc.b	00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
	dc.b	00,02,01,01,01,01,01,01,01,01,01,01,01,01,01,01,01,01,02,00
	dc.b	00,01,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,01,00
	dc.b	00,01,00,01,01,01,01,01,01,01,01,01,01,01,01,01,01,00,01,00
	dc.b	00,01,00,01,00,00,00,00,00,00,00,00,00,00,00,00,01,00,01,00
	dc.b	00,01,00,01,00,01,01,01,01,01,01,01,01,01,01,00,01,00,01,00
	dc.b	00,01,00,01,00,01,00,00,00,00,00,00,00,00,01,00,01,00,01,00
	dc.b	00,01,00,01,00,01,00,00,01,01,01,01,00,00,01,00,01,00,01,00
	dc.b	00,01,00,01,00,01,00,00,00,00,00,00,00,00,01,00,01,00,01,00
	dc.b	00,01,00,01,00,01,01,01,01,01,01,01,01,01,01,00,01,00,01,00
	dc.b	00,01,00,01,00,00,00,00,00,00,00,00,00,00,00,00,01,00,01,00
	dc.b	00,01,00,01,01,01,01,01,01,01,01,01,01,01,01,01,01,00,01,00
	dc.b	00,01,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,01,00
	dc.b	00,02,01,01,01,01,01,01,00,00,00,00,01,01,01,01,01,01,02,00
	dc.b	00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
	dc.b	00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
board1:
	dc.b	03,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,04
	dc.b	01,23,22,22,28,22,22,28,22,22,22,22,28,22,22,28,22,22,24,01
	dc.b	01,21,03,14,21,12,14,21,12,02,02,14,21,12,14,21,12,04,21,01
	dc.b	01,21,11,23,30,22,28,30,28,22,22,28,30,28,22,30,24,11,21,01
	dc.b	01,27,22,29,03,14,21,15,21,12,14,21,15,21,12,04,27,22,29,01
	dc.b	01,21,13,21,11,23,30,28,30,22,22,30,28,30,24,11,21,13,21,01
	dc.b	01,21,11,27,22,29,13,21,12,02,02,14,21,13,27,22,29,11,21,01
	dc.b	01,27,22,29,15,21,01,27,22,22,22,22,29,01,21,15,27,22,29,01
	dc.b	01,21,13,27,22,29,11,21,12,02,02,14,21,11,27,22,29,13,21,01
	dc.b	01,21,11,21,13,25,28,30,28,22,22,28,30,28,26,13,21,11,21,01
	dc.b	01,27,22,29,05,14,21,15,21,12,14,21,15,21,12,06,27,22,29,01
	dc.b	01,21,13,25,28,22,30,28,30,22,22,30,28,30,22,28,26,13,21,01
	dc.b	01,21,05,14,21,12,14,21,12,02,02,14,21,12,14,21,12,06,21,01
	dc.b	01,25,22,22,30,22,22,30,22,22,22,22,30,22,22,30,22,22,26,01
	dc.b	05,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,06
	dc.b	16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16
cheese2:
	dc.b	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
	dc.b	0,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,0
	dc.b	0,1,0,0,1,0,0,0,1,0,0,1,0,0,0,1,0,0,1,0
	dc.b	0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0
	dc.b	0,1,0,1,0,0,0,1,0,0,0,0,1,0,0,0,1,0,1,0
	dc.b	0,1,0,1,1,1,0,1,1,1,1,1,1,0,1,1,1,0,1,0
	dc.b	0,1,1,1,0,1,0,0,1,0,0,1,0,0,1,0,1,1,1,0
	dc.b	0,0,0,1,0,1,1,1,1,1,1,1,1,1,1,0,1,0,0,0
	dc.b	0,1,1,1,1,1,0,1,0,0,0,0,1,0,1,1,1,1,1,0
	dc.b	0,1,0,1,0,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0
	dc.b	0,1,1,1,0,0,0,0,1,0,0,1,0,0,0,0,1,1,1,0
	dc.b	0,1,0,1,1,1,1,0,1,1,1,1,0,1,1,1,1,0,1,0
	dc.b	0,1,0,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,1,0
	dc.b	0,2,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,2,0
	dc.b	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
	dc.b	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
board2:
	dc.b	03,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,04
	dc.b	01,23,22,22,28,22,22,22,28,22,22,28,22,22,22,28,22,22,24,01
	dc.b	01,21,03,14,21,12,02,14,21,12,14,21,12,02,14,21,12,04,21,01
	dc.b	01,21,01,23,30,22,22,28,30,22,22,30,28,22,22,30,24,01,21,01
	dc.b	01,21,01,21,12,02,04,21,12,02,02,14,21,03,02,14,21,01,21,01
	dc.b	01,21,11,27,22,24,01,25,28,22,22,28,26,01,23,22,29,11,21,01
	dc.b	01,25,22,29,13,21,05,14,21,12,14,21,12,06,21,13,27,22,26,01
	dc.b	07,02,14,21,11,27,22,28,30,22,22,30,28,22,29,11,21,12,02,09
	dc.b	01,23,22,20,22,29,15,21,12,02,02,14,21,15,27,22,20,22,24,01
	dc.b	01,21,15,21,13,25,28,30,28,22,22,28,30,28,26,13,21,15,21,01
	dc.b	01,27,22,29,05,14,21,13,21,12,14,21,13,21,12,06,27,22,29,01
	dc.b	01,21,13,25,22,28,26,01,27,22,22,29,01,25,28,22,26,13,21,01
	dc.b	01,21,05,02,14,21,12,06,21,12,14,21,05,14,21,12,02,06,21,01
	dc.b	01,25,22,22,22,30,22,22,30,22,22,30,22,22,30,22,22,22,26,01
	dc.b	05,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,06
	dc.b	16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16
cheese3:
	dc.b	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
	dc.b	0,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,0
	dc.b	0,1,0,1,0,1,0,1,0,0,0,0,1,0,1,0,1,0,1,0
	dc.b	0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0
	dc.b	0,1,0,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,1,0
	dc.b	0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0
	dc.b	0,0,0,1,0,0,0,1,0,0,0,0,1,0,0,0,1,0,0,0
	dc.b	0,1,1,1,1,1,0,1,1,1,1,1,1,0,1,1,1,1,1,0
	dc.b	0,1,0,1,0,1,0,1,0,0,0,0,1,0,1,0,1,0,1,0
	dc.b	0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0
	dc.b	0,0,0,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,0,0
	dc.b	0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0
	dc.b	0,1,0,1,0,1,0,0,1,0,0,1,0,0,1,0,1,0,1,0
	dc.b	0,2,1,1,0,1,1,0,0,0,0,0,0,1,1,0,1,1,2,0
	dc.b	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
	dc.b	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
board3:
	dc.b	03,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,04
	dc.b	01,23,22,28,22,28,22,28,22,22,22,22,28,22,28,22,28,22,24,01
	dc.b	01,21,13,21,15,21,15,21,12,02,02,14,21,15,21,15,21,13,21,01
	dc.b	01,21,01,25,22,20,22,30,28,22,22,28,30,22,20,22,26,01,21,01
	dc.b	01,21,05,02,14,21,12,14,21,12,14,21,12,14,21,12,02,06,21,01
	dc.b	01,25,22,28,22,30,22,28,30,22,22,30,28,22,30,22,28,22,26,01
	dc.b	07,02,14,21,12,02,04,21,12,02,02,14,21,03,02,14,21,12,02,09
	dc.b	01,23,22,20,22,24,01,27,22,22,22,22,29,01,23,22,20,22,24,01
	dc.b	01,21,15,21,15,21,11,21,12,02,02,14,21,11,21,15,21,15,21,01
	dc.b	01,25,22,30,22,20,22,30,28,22,22,28,30,22,20,22,30,22,26,01
	dc.b	07,02,02,02,14,21,12,14,21,12,14,21,12,14,21,12,02,02,02,09
	dc.b	01,23,22,28,22,20,22,22,20,22,22,20,22,22,20,22,28,22,24,01
	dc.b	01,21,15,21,13,21,12,14,21,12,14,21,12,14,21,13,21,15,21,01
	dc.b	01,25,22,26,01,25,22,22,30,22,22,30,22,22,26,01,25,22,26,01
	dc.b	05,02,02,02,10,02,02,02,02,02,02,02,02,02,02,10,02,02,02,06
	dc.b	15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15
cheese4:
	dc.b	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
	dc.b	0,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,0
	dc.b	0,1,0,1,0,1,0,1,0,1,0,0,1,0,1,0,1,0,1,0
	dc.b	0,1,1,1,1,1,1,1,0,1,1,0,1,1,1,1,1,1,1,0
	dc.b	0,1,0,1,0,1,0,1,0,0,1,0,1,0,1,0,1,0,1,0
	dc.b	0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0
	dc.b	0,1,0,1,0,1,0,1,0,1,0,0,1,0,1,0,1,0,1,0
	dc.b	0,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,0
	dc.b	0,1,0,1,0,1,0,1,0,1,0,0,1,0,1,0,1,0,1,0
	dc.b	0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0
	dc.b	0,1,0,1,0,1,0,1,0,0,1,0,1,0,1,0,1,0,1,0
	dc.b	0,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,0
	dc.b	0,1,0,1,0,1,0,1,0,0,1,0,1,0,1,0,1,0,1,0
	dc.b	0,2,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,2,0
	dc.b	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
	dc.b	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
board4:
	dc.b	03,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,04
	dc.b	01,23,22,28,22,28,22,28,22,28,22,22,28,22,28,22,28,22,24,01
	dc.b	01,21,15,21,15,21,15,21,13,21,12,04,21,15,21,15,21,15,21,01
	dc.b	01,27,22,20,22,20,22,29,01,25,24,01,27,22,20,22,20,22,29,01
	dc.b	01,21,15,21,15,21,15,21,05,14,21,11,21,15,21,15,21,15,21,01
	dc.b	01,27,22,20,22,20,22,20,22,28,30,22,20,22,20,22,20,22,29,01
	dc.b	01,21,15,21,15,21,15,21,13,21,12,14,21,15,21,15,21,15,21,01
	dc.b	01,27,22,20,22,20,22,29,01,27,22,22,20,22,20,22,20,22,29,01
	dc.b	01,21,15,21,15,21,15,21,11,21,12,14,21,15,21,15,21,15,21,01
	dc.b	01,27,22,20,22,20,22,20,22,30,28,22,20,22,20,22,20,22,29,01
	dc.b	01,21,15,21,15,21,15,21,12,14,21,13,21,15,21,15,21,15,21,01	
	dc.b	01,27,22,20,22,20,22,20,22,22,29,01,27,22,20,22,20,22,29,01
	dc.b	01,21,15,21,15,21,15,21,12,14,21,11,21,15,21,15,21,15,21,01
	dc.b	01,25,22,30,22,30,22,30,22,22,30,22,30,22,30,22,30,22,26,01
	dc.b	05,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,06
	dc.b	15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15
cheese5:
	dc.b	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
	dc.b	0,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0
	dc.b	0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0
	dc.b	0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0
	dc.b	0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,1,1,0
	dc.b	0,1,0,1,0,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0
	dc.b	0,1,0,1,0,1,0,1,0,1,0,0,1,0,1,0,1,0,1,0
	dc.b	0,1,0,1,1,1,1,1,0,1,2,0,1,1,1,1,1,0,1,0
	dc.b	0,1,0,1,0,1,0,1,0,0,0,0,1,0,1,0,1,0,1,0
	dc.b	0,1,0,1,0,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0
	dc.b	0,1,1,1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0
	dc.b	0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0
	dc.b	0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0
	dc.b	0,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,2,0
	dc.b	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
	dc.b	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
board5:
	dc.b	03,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,04
	dc.b	01,23,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,24,01
	dc.b	01,21,03,02,02,02,02,02,02,02,02,02,02,02,02,02,02,04,21,01
	dc.b	01,21,01,23,22,22,28,22,28,22,22,28,22,28,22,22,24,11,21,01
	dc.b	01,21,01,21,03,14,21,15,21,12,14,21,15,21,12,04,27,22,29,01
	dc.b	01,21,01,21,01,23,30,28,30,28,22,30,28,30,24,01,21,13,21,01
	dc.b	01,21,01,21,11,21,15,21,13,21,12,04,21,15,21,11,21,01,21,01
	dc.b	01,21,01,27,22,20,22,29,01,25,34,01,27,22,20,22,29,01,21,01
	dc.b	01,21,01,21,13,21,15,21,05,02,02,06,21,15,21,13,21,01,21,01
	dc.b	01,21,01,21,01,25,28,30,28,22,22,28,30,28,26,01,21,01,21,01
	dc.b	01,27,22,29,05,14,21,15,21,12,14,21,15,21,12,06,21,01,21,01
	dc.b	01,21,13,25,22,22,30,22,30,22,22,30,22,30,22,22,26,01,21,01
	dc.b	01,21,05,02,02,02,02,02,02,02,02,02,02,02,02,02,02,06,21,01
	dc.b	01,25,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,26,01
	dc.b	05,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,02,06
	dc.b	15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15

scrcounter:
	dc.w	0
scrtxt:
	dc.b	" - SnackMan V1.00 07.10.92 -  "
	dc.b	" WELCOME TO SnackMan! THIS GAME WAS BROUGHT TO YOU"
	DC.B	" BY STIG A. OLSEN, ALIAS XTAZY of NEW WAVE."
	dc.b	" CODING BY ME (contact me at stigo@ifi.uio.no),"
	dc.b	" MUSIC BY STIAN W. ARNESEN (stiana@ifi.uio.no),"
	dc.b	" MUSIC REPLAYROUTINE FROM PROTRACKER BY LARS"
	DC.B	" HAMRE (Amiga Freelancers)."
	dc.b	" NON-INTERNET'ERS CONTACT ME AT"
	DC.B	" THIS SNAIL-MAIL ADDRESS: "
	dc.b	" STIG A. OLSEN, 4A311 KRINGSJAA, SOGNSVN. 218,"
	dc.b	" N-0864  OSLO, NORWAY.   "
	dc.b	" FOR MORE INFORMATION ABOUT THIS GAME, READ"
	DC.B	" THE DOCUMENTATION FILE THAT SHOULD BE ON THE SAME"
	DC.B	" DISK AS THIS GAME. You are not allowed to make any"
	dc.b	" copies without reading the documentation first!    "
	dc.b	" YOU MIGHT WONDER WHY SOMEONE WOULD WRITE A GAME THAT"
	DC.B	" LOOKS A LOT LIKE PAC-MAN, BUT I WANTED A RELATIVELY"
	DC.B	" SIMPLE PROJECT AS MY FIRST ATTEMPT TO WRITE A GAME."
	dc.b	" THIS IS NOT AN EXACT PACMAN REPLICA, I HAVEN'T PLAYED"
	DC.B	" PACMAN FOR YEARS, THIS IS A PRODUCT MADE FROM SCRATCH"
	DC.B	" BY ME."
	DC.B	" SO THIS IS IT! IF YOU DON'T LIKE IT, LEAVE IT!!!   "
	dc.b	" INSTRUCTIONS: Just eat as much cheese"
	dc.b	" (yellow dots) as possible without getting"
	dc.b	" in contact with"
	dc.b	" the ghosts. The vitamin pills (big yellow dots) make"
	dc.b	" you go twice as fast and you can"
	dc.b	" eat the ghosts for a while. Each cheese gives 10"
	dc.b	" points,"
	dc.b	" each vitamin 100, a ghost eaten gives 500,"
	dc.b	" and each level completed"
	dc.b	" gives 1000 points. You have 3 lives to begin with,"
	dc.b	" and it's impossible to get more. There are 5 levels,"
	dc.b	" when you've mastered them all the ghosts starts"
	dc.b	" going faster."
	dc.b	" Finally: Happy gaming and GOOD LUCK!"
	dc.b	"   Left mousebutton exits game!   "
	DC.B	" AND NOW THE INCREDIBLY BORING PART FOR THOSE WHO IS"
	DC.B	" NOT IN IT, THE GREETINGS LIST:"
	DC.B	" [NEW WAVE MEMBERS INCLUDING] BUSHMAN, MM, EMO, MUTANT"
	dc.b	" AND"
	DC.B	" BOLD EAGLE, [UNIVERSITY OF OSLO BUDDIES] PERPLEX"
	DC.B	"/OFFENCE (also known as FractaLarz),"
	dc.b	" QUINCY/S!P-SCOOPEX (strandeeed), QUARK or VIOL8R (how's"
	dc.b	" the flightsim coming?),"
	dc.b	" MORBID (ja til sykkelbukser!),"
	DC.B	" PUSHEAD (and nothing else matters), TOMMY ("
	dc.b	"gone '386 eh?),"
	dc.b	" JOERN <THE OMEN> T. (no peace without smoke!)"
	DC.B	" [INTERNET'ERS THAT I HAVE ENJOYED (or hated) TALKING"
	dc.b	" TO] ALL THE #amiga IRC-chatters; REALDUCK, ARE@SSB,"
	dc.b	" OLDMAN (long time, no see),"
	dc.b	" the regulars on the channel; "
	dc.b	" U4IA, CALIBURN, ILL, ZOP, FER, PUMPKIN,"
	dc.b	" PJOTR, Billy The Kid, KINTEL, CELEBRANDIL"
	dc.b	" (what an UGLY photo in DatorMz! :-) ) AND ALL I'VE"
	dc.b	" FORGOTTEN PROBABLY INCLUDING YOU!"
	dc.b	" ALSO VERY SPECIAL GREETINGS TO LARS HAMRE FOR YOUR"
	dc.b	" LONG EMAIL-LETTERS, AND THE GUYS (SHORTIE & Co.) IN"
	dc.b	" SONIC FOR KEEPING THE 'INTERNET AMIGA SCENE ADDRESS-LIST.'"
	dc.b	" A SPECIAL GREETING ALSO TO GEIR H. FOR DIGITAL (hmm..."
	dc.b	" what happened to the disk issue??)!"
	dc.b	" THE LAST (AND LEAST ---- NOT!) GREETINGS GO TO"
	dc.b	" arvidj/UiO (for the amiga section),"
	DC.B	" Lars J., Sjur K., the EON dudes from Nes, Jomar/Talent"
	dc.b	" & friends, Chris Johnsen (Canada),"
	dc.b	" Sandra Salamander, Kollbjorn Kommune and ALL"
	dc.b	" sheilas out there!"
	dc.b	" Some great greetings also to my BEER and SOCCER buddies,"
	dc.b	" Paal W. & Per Ola S. that doesn't give a shit about"
	dc.b	" computers. Party on, dudes!     "
	dc.b	" En melding til alle nordmenn: Stem JA TIL EF!!"
	dc.b	" Gi vaart konkurransedyktige naeringsliv en sjanse til"
	dc.b	" aa utnytte markedet bedre - til alles beste!   "
	dc.b	" Non norwegians: It was just a little political message!"
	dc.b	"    Everybody out there," 
	dc.b	" I love getting feedback,"
	dc.b	" so do contact me on one of the addresses listed!!"
	dc.b	" Any comments, questions, suggestions etc is welcome."
	dc.b	"            [Text Restarts]                  "
	dc.b	0
	even
scrptr:
	dc.l	scrtxt

;	**** COPPERLIST/CHIPMEM DATA ****
	even
coplist:
	dc.w	$0092,$0038 	; ddfstrt
	dc.w	$0094,$00d0	; ddfstop
	dc.w	$008e,$2c81	; diwstrt
	dc.w	$0090,$2cc1	; diwstop PAL
	dc.w	$0102,$0000	; bplcon1 scroll value
	dc.w	$0108,$0000	; odd modulo
	dc.w	$010a,$0000	; even modulo

;	**** BITPLANE POINTERS ****

pl1h:	dc.w	$00e0,0		; bpl pointers
	dc.w	$00e2,0
pl2h:	dc.w	$00e4,0
	dc.w	$00e6,0
pl3h:	dc.w	$00e8,0
	dc.w	$00ea,0
pl4h:	dc.w	$00f0,0
	dc.w	$00f2,0
pl5h:	dc.w	$00ec,0
	dc.w	$00ee,0

pl6h:	dc.w	$00f4,0
	dc.w	$00f6,0

;	**** COLOURS ****
colors:
	dc.w	$0180,$0023,$0182,$057d,$0184,$046b,$0186,$045a
	dc.w	$0188,$0359,$018a,$0347,$018c,$0b52,$018e,$00cc

	dc.w	$0190,$0ccc,$0192,$0ccc,$0194,$0ccc,$0196,$0ccc
	dc.w	$0198,$0ccc,$019a,$0ccc,$019c,$0ccc,$019e,$0ccc

spritecolors:
	dc.w	$01a0
cheesecolor:
	dc.w	$0a90	; sprite0,1 transparency color
	dc.w	$01a2
paccolor:
	dc.w	$0dd0
	dc.w	$01a4,$00f0
	dc.w	$01a6,$000f

	dc.w	$01a8,$0000	; sprite2,3
	dc.w	$01aa,$0000
	dc.w	$01ac
col12:	dc.w	$0c35
	dc.w	$01ae,$0fff

	dc.w	$01b0,$0ccc	; sprite4,5
	dc.w	$01b2,$0000
	dc.w	$01b4
col34:	dc.w	$03c5
	dc.w	$01b6,$0fff

	dc.w	$01b8,$00ff	; sprite6,7
	dc.w	$01ba,$0f00
	dc.w	$01bc,$00f0
	dc.w	$01be,$000f	; color 31

;	**** SPRITEPOINTERS ****

spr1h:	dc.w	$0120,0
	dc.w	$0122,0
	
	dc.w	$0124,0
	dc.w	$0126,0

g11h:	dc.w	$0128,0
	dc.w	$012a,0

g21h:	dc.w	$012c,0
	dc.w	$012e,0

g31h:	dc.w	$0130,0
	dc.w	$0132,0

g41h:	dc.w	$0134,0
	dc.w	$0136,0

	dc.w	$0138,0
	dc.w	$013a,0

	dc.w	$013c,0
	dc.w	$013e,0


;	**** BITPLANE CONTROL REGS ETC ***

	dc.w	$2c07,$fffe
	dc.w	$0100,$5200	; bplcon0 

	dc.w	$ffdf,$fffe
	dc.w	$1c07,$fffe
scr1h:
	dc.w	$00e0,0		; bpl pointers
	dc.w	$00e2,0

	dc.w	$0182,$0c25
	dc.w	$ffff,$fffe

;	**** GRAPHICS DATA ****
blocks:
	incbin	"blocks.raw"
board:
	incbin	"intropic.raw"
scoreboard:
	incbin	"scoreb.raw"
digits:
	incbin	"digits.raw"
infoscreen:
	blk.b	10240,0
infomsgs:
	incbin	"info.raw"
scrmem:
	blk.b	40*8,0
font8x8:
	incbin	"8x8font.raw"
cheeseboard:
	blk.b	10240,0
cheese:
	dc.w	%0000000000000000
	dc.w	%0000000000000000
	dc.w	%0000000000000000
	dc.w	%0000000000000000
	dc.w	%0000000000000000
	dc.w	%0000000000000000
	dc.w	%0000001111000000
	dc.w	%0000011111100000
	dc.w	%0000011111100000
	dc.w	%0000011111100000
	dc.w	%0000001111000000
	dc.w	%0000000000000000
	dc.w	%0000000000000000
	dc.w	%0000000000000000
	dc.w	%0000000000000000
	dc.w	%0000000000000000
vitamin:
	dc.w	%0000000000000000
	dc.w	%0000000000000000
	dc.w	%0000000000000000
	dc.w	%0000000000000000
	dc.w	%0000001111000000
	dc.w	%0000111111110000
	dc.w	%0001111111111000
	dc.w	%0001111111111000
	dc.w	%0001111111111000
	dc.w	%0001111111111000
	dc.w	%0001111111111000
	dc.w	%0000111111110000
	dc.w	%0000001111000000
	dc.w	%0000000000000000
	dc.w	%0000000000000000
	dc.w	%0000000000000000

pacR:
	dc.w	$0000,$0000,$03e0,$0000,$0ff8,$0000,$1ffc,$0000
	dc.w	$3ff8,$0000,$3ff0,$0000,$7fe0,$0000,$7fc0,$0000
	dc.w	$7f80,$0000,$7fc0,$0000,$7fe0,$0000,$3ff0,$0000
	dc.w	$3ff8,$0000,$1ffc,$0000,$0ff8,$0000,$03e0,$0000
	dc.w	$0000,$0000
	dc.w	$0000,$0000
pacL:
	dc.w	$0000,$0000,$03e0,$0000,$0ff8,$0000,$1ffc,$0000
	dc.w	$0ffe,$0000,$07fe,$0000,$03ff,$0000,$01ff,$0000
	dc.w	$00ff,$0000,$01ff,$0000,$03ff,$0000,$07fe,$0000
	dc.w	$0ffe,$0000,$1ffc,$0000,$0ff8,$0000,$03e0,$0000
	dc.w	$0000,$0000
	dc.w	$0000,$0000
pacU:
	dc.w	$0000,$0000,$0000,$0000,$0000,$0000,$1004,$0000
	dc.w	$380e,$0000,$3c1e,$0000,$7e3f,$0000,$7f7f,$0000
	dc.w	$7fff,$0000,$7fff,$0000,$7fff,$0000,$3ffe,$0000
	dc.w	$3ffe,$0000,$1ffc,$0000,$0ff8,$0000,$03e0,$0000
	dc.w	$0000,$0000
	dc.w	$0000,$0000
pacD:	
	dc.w	$0000,$0000,$03e0,$0000,$0ff8,$0000,$1ffc,$0000
	dc.w	$3ffe,$0000,$3ffe,$0000,$7fff,$0000,$7fff,$0000
	dc.w	$7fff,$0000,$7f7f,$0000,$7e3f,$0000,$3c1e,$0000
	dc.w	$380e,$0000,$1004,$0000,$0000,$0000,$0000,$0000
	dc.w	$0000,$0000
	dc.w	$0000,$0000
pacBALL:
	dc.w	$0000,$0000
	dc.w	$03e0,$0000,$0ff8,$0000,$1ffc,$0000
	dc.w	$3ffe,$0000,$3ffe,$0000,$7fff,$0000,$7fff,$0000
	dc.w	$7fff,$0000,$7fff,$0000,$7fff,$0000,$3ffe,$0000
	dc.w	$3ffe,$0000,$1ffc,$0000,$0ff8,$0000,$03e0,$0000
	dc.w	$0000,$0000
	dc.w	$0000,$0000
nullspr:
	dc.w	$0000,$0000,$0000,$00000
	dc.w	$0000,$0000
g1_R:
	dc.w	$0000,$0000,$0000,$1ff8,$0000,$1ff8,$0000,$7ffe
	dc.w	$0e70,$7ffe,$0e70,$7ffe,$0e70,$79ce,$0e70,$79ce
	dc.w	$0000,$7ffe,$0000,$7ffe,$0000,$7ffe,$0000,$7ffe
	dc.w	$0000,$7ffe,$0000,$7ffe,$0000,$6666,$0000,$6666
	dc.w	$0000,$0000
	dc.w	$0000,$0000
g1_L:
	dc.w	$0000,$0000,$0000,$1ff8,$0000,$1ff8,$0000,$7ffe
	dc.w	$0e70,$7ffe,$0e70,$7ffe,$0e70,$739e,$0e70,$739e
	dc.w	$0000,$7ffe,$0000,$7ffe,$0000,$7ffe,$0000,$7ffe
	dc.w	$0000,$7ffe,$0000,$7ffe,$0000,$6666,$0000,$6666
	dc.w	$0000,$0000
	dc.w	$0000,$0000
g1_U:
	dc.w	$0000,$0000,$0000,$1ff8,$0000,$1ff8,$0000,$7ffe
	dc.w	$0e70,$799e,$0e70,$799e,$0e70,$7ffe,$0e70,$7ffe
	dc.w	$0000,$7ffe,$0000,$7ffe,$0000,$7ffe,$0000,$7ffe
	dc.w	$0000,$7ffe,$0000,$7ffe,$0000,$6666,$0000,$6666
	dc.w	$0000,$0000
	dc.w	$0000,$0000
g1_D:
	dc.w	$0000,$0000,$0000,$1ff8,$0000,$1ff8,$0000,$7ffe
	dc.w	$0e70,$7ffe,$0e70,$7ffe,$0e70,$799e,$0e70,$799e
	dc.w	$0000,$7ffe,$0000,$7ffe,$0000,$7ffe,$0000,$7ffe
	dc.w	$0000,$7ffe,$0000,$7ffe,$0000,$6666,$0000,$6666
	dc.w	$0000,$0000
	dc.w	$0000,$0000

g2_R:
	dc.w	$0000,$0000,$0000,$1ff8,$0000,$1ff8,$0000,$7ffe
	dc.w	$0e70,$7ffe,$0e70,$7ffe,$0e70,$79ce,$0e70,$79ce
	dc.w	$0000,$7ffe,$0000,$7ffe,$0000,$7ffe,$0000,$7ffe
	dc.w	$0000,$7ffe,$0000,$7ffe,$0000,$6666,$0000,$6666
	dc.w	$0000,$0000
	dc.w	$0000,$0000
g2_L:
	dc.w	$0000,$0000,$0000,$1ff8,$0000,$1ff8,$0000,$7ffe
	dc.w	$0e70,$7ffe,$0e70,$7ffe,$0e70,$739e,$0e70,$739e
	dc.w	$0000,$7ffe,$0000,$7ffe,$0000,$7ffe,$0000,$7ffe
	dc.w	$0000,$7ffe,$0000,$7ffe,$0000,$6666,$0000,$6666
	dc.w	$0000,$0000
	dc.w	$0000,$0000
g2_U:
	dc.w	$0000,$0000,$0000,$1ff8,$0000,$1ff8,$0000,$7ffe
	dc.w	$0e70,$799e,$0e70,$799e,$0e70,$7ffe,$0e70,$7ffe
	dc.w	$0000,$7ffe,$0000,$7ffe,$0000,$7ffe,$0000,$7ffe
	dc.w	$0000,$7ffe,$0000,$7ffe,$0000,$6666,$0000,$6666
	dc.w	$0000,$0000
	dc.w	$0000,$0000
g2_D:
	dc.w	$0000,$0000,$0000,$1ff8,$0000,$1ff8,$0000,$7ffe
	dc.w	$0e70,$7ffe,$0e70,$7ffe,$0e70,$799e,$0e70,$799e
	dc.w	$0000,$7ffe,$0000,$7ffe,$0000,$7ffe,$0000,$7ffe
	dc.w	$0000,$7ffe,$0000,$7ffe,$0000,$6666,$0000,$6666
	dc.w	$0000,$0000
	dc.w	$0000,$0000
g3_R:
	dc.w	$0000,$0000,$0000,$1ff8,$0000,$1ff8,$0000,$7ffe
	dc.w	$0e70,$7ffe,$0e70,$7ffe,$0e70,$79ce,$0e70,$79ce
	dc.w	$0000,$7ffe,$0000,$7ffe,$0000,$7ffe,$0000,$7ffe
	dc.w	$0000,$7ffe,$0000,$7ffe,$0000,$6666,$0000,$6666
	dc.w	$0000,$0000
	dc.w	$0000,$0000
g3_L:
	dc.w	$0000,$0000,$0000,$1ff8,$0000,$1ff8,$0000,$7ffe
	dc.w	$0e70,$7ffe,$0e70,$7ffe,$0e70,$739e,$0e70,$739e
	dc.w	$0000,$7ffe,$0000,$7ffe,$0000,$7ffe,$0000,$7ffe
	dc.w	$0000,$7ffe,$0000,$7ffe,$0000,$6666,$0000,$6666
	dc.w	$0000,$0000
	dc.w	$0000,$0000
g3_U:
	dc.w	$0000,$0000,$0000,$1ff8,$0000,$1ff8,$0000,$7ffe
	dc.w	$0e70,$799e,$0e70,$799e,$0e70,$7ffe,$0e70,$7ffe
	dc.w	$0000,$7ffe,$0000,$7ffe,$0000,$7ffe,$0000,$7ffe
	dc.w	$0000,$7ffe,$0000,$7ffe,$0000,$6666,$0000,$6666
	dc.w	$0000,$0000
	dc.w	$0000,$0000
g3_D:
	dc.w	$0000,$0000,$0000,$1ff8,$0000,$1ff8,$0000,$7ffe
	dc.w	$0e70,$7ffe,$0e70,$7ffe,$0e70,$799e,$0e70,$799e
	dc.w	$0000,$7ffe,$0000,$7ffe,$0000,$7ffe,$0000,$7ffe
	dc.w	$0000,$7ffe,$0000,$7ffe,$0000,$6666,$0000,$6666
	dc.w	$0000,$0000
	dc.w	$0000,$0000
g4_R:
	dc.w	$0000,$0000,$0000,$1ff8,$0000,$1ff8,$0000,$7ffe
	dc.w	$0e70,$7ffe,$0e70,$7ffe,$0e70,$79ce,$0e70,$79ce
	dc.w	$0000,$7ffe,$0000,$7ffe,$0000,$7ffe,$0000,$7ffe
	dc.w	$0000,$7ffe,$0000,$7ffe,$0000,$6666,$0000,$6666
	dc.w	$0000,$0000
	dc.w	$0000,$0000
g4_L:
	dc.w	$0000,$0000,$0000,$1ff8,$0000,$1ff8,$0000,$7ffe
	dc.w	$0e70,$7ffe,$0e70,$7ffe,$0e70,$739e,$0e70,$739e
	dc.w	$0000,$7ffe,$0000,$7ffe,$0000,$7ffe,$0000,$7ffe
	dc.w	$0000,$7ffe,$0000,$7ffe,$0000,$6666,$0000,$6666
	dc.w	$0000,$0000
	dc.w	$0000,$0000
g4_U:
	dc.w	$0000,$0000,$0000,$1ff8,$0000,$1ff8,$0000,$7ffe
	dc.w	$0e70,$799e,$0e70,$799e,$0e70,$7ffe,$0e70,$7ffe
	dc.w	$0000,$7ffe,$0000,$7ffe,$0000,$7ffe,$0000,$7ffe
	dc.w	$0000,$7ffe,$0000,$7ffe,$0000,$6666,$0000,$6666
	dc.w	$0000,$0000
	dc.w	$0000,$0000
g4_D:
	dc.w	$0000,$0000,$0000,$1ff8,$0000,$1ff8,$0000,$7ffe
	dc.w	$0e70,$7ffe,$0e70,$7ffe,$0e70,$799e,$0e70,$799e
	dc.w	$0000,$7ffe,$0000,$7ffe,$0000,$7ffe,$0000,$7ffe
	dc.w	$0000,$7ffe,$0000,$7ffe,$0000,$6666,$0000,$6666
	dc.w	$0000,$0000
	dc.w	$0000,$0000

g1_DEAD:
	dc.w	$0000,$0000,$0000,$1ff8,$0000,$1008,$0000,$700e
	dc.w	$0000,$4c32,$0000,$524a,$0000,$524a,$0000,$524a
	dc.w	$0000,$4c32,$0000,$4002,$0000,$4002,$0000,$4002
	dc.w	$0000,$4002,$0000,$599a,$0000,$6666,$0000,$6666
	dc.w	$0000,$0000
	dc.w	$0000,$0000
g2_DEAD:
	dc.w	$0000,$0000,$0000,$1ff8,$0000,$1008,$0000,$700e
	dc.w	$0000,$4c32,$0000,$524a,$0000,$524a,$0000,$524a
	dc.w	$0000,$4c32,$0000,$4002,$0000,$4002,$0000,$4002
	dc.w	$0000,$4002,$0000,$599a,$0000,$6666,$0000,$6666
	dc.w	$0000,$0000
	dc.w	$0000,$0000
g3_DEAD:
	dc.w	$0000,$0000,$0000,$1ff8,$0000,$1008,$0000,$700e
	dc.w	$0000,$4c32,$0000,$524a,$0000,$524a,$0000,$524a
	dc.w	$0000,$4c32,$0000,$4002,$0000,$4002,$0000,$4002
	dc.w	$0000,$4002,$0000,$599a,$0000,$6666,$0000,$6666
	dc.w	$0000,$0000
	dc.w	$0000,$0000
g4_DEAD:
	dc.w	$0000,$0000,$0000,$1ff8,$0000,$1008,$0000,$700e
	dc.w	$0000,$4c32,$0000,$524a,$0000,$524a,$0000,$524a
	dc.w	$0000,$4c32,$0000,$4002,$0000,$4002,$0000,$4002
	dc.w	$0000,$4002,$0000,$599a,$0000,$6666,$0000,$6666
	dc.w	$0000,$0000
	dc.w	$0000,$0000

efcoplist:
	dc.w	$0092,$0038 	; ddfstrt
	dc.w	$0094,$00d0	; ddfstop
	dc.w	$008e,$2c81	; diwstrt
	dc.w	$0090,$2cc1	; diwstop PAL
	dc.w	$0102,$0000	; bplcon1 scroll value
	dc.w	$0108,$0000	; odd modulo
	dc.w	$010a,$0000	; even modulo

;	**** BITPLANE POINTERS ****

ef1h:	dc.w	$00e0,0		; bpl pointers
	dc.w	$00e2,0
ef2h:	dc.w	$00e4,0
	dc.w	$00e6,0
ef3h:	dc.w	$00e8,0
	dc.w	$00ea,0
efccol:
	dc.w	$0180,$0fff,$0182,$0fff,$0184,$0fff
	dc.w	$0186,$0fff,$0188,$0fff
	dc.w	$018a,$0fff,$018c,$0fff,$018e,$0fff

	dc.w	$0100,$3200
	dc.w	$ffff,$fffe

efscreen:
	incbin	"jatilef.raw"
efcol:
	dc.w	$0128,$0bbb,$0889
	dc.w	$0332,$0126
	dc.w	$0eb0,$0a70,$0b02

intdcoplist:
	dc.w	$0092,$0038 	; ddfstrt
	dc.w	$0094,$00d0	; ddfstop
	dc.w	$008e,$2c81	; diwstrt
	dc.w	$0090,$2cc1	; diwstop PAL
	dc.w	$0102,$0000	; bplcon1 scroll value
	dc.w	$0108,$0000	; odd modulo
	dc.w	$010a,$0000	; even modulo

;	**** BITPLANE POINTERS ****

intd1h:	dc.w	$00e0,0		; bpl pointers
	dc.w	$00e2,0
intd2h:	dc.w	$00e4,0
	dc.w	$00e6,0
intd3h:	dc.w	$00e8,0
	dc.w	$00ea,0
intd4d:	dc.w	$00ec,0
	dc.w	$00ee,0
intd5d:	dc.w	$00f0,0
	dc.w	$00f2,0

introccol:
	dc.w	$0180,$0000,$0182,$0000,$0184,$0000,$0186,$0000
	dc.w	$0188,$0000,$018a,$0000,$018c,$0000,$018e,$0000
	dc.w	$0190,$0000,$0192,$0000,$0194,$0000,$0196,$0000
	dc.w	$0198,$0000,$019a,$0000,$019c,$0fff,$019e,$0fff
	dc.w	$01a0,$0fff,$01a2,$0fff,$01a4,$0fff,$01a6,$0fff
	dc.w	$01a8,$0fff,$01aa,$0fff,$01ac,$0fff,$01ae,$0fff
	dc.w	$01b0,$0fff,$01b2,$0fff,$01b4,$0fff,$01b6,$0fff
	dc.w	$01b8,$0fff,$01ba,$0fff,$01bc,$0fff,$01be,$0fff

	dc.w	$0100,$5200
	dc.w	$ffff,$fffe
introcol:
	dc.w	$0000,$0bcf,$09bd,$089c
	dc.w	$068a,$0579,$0467,$0356
	dc.w	$0fe4,$0eb3,$0d93,$0c72
	dc.w	$0831,$0fe0,$0def,$0bdf
	dc.w	$09ce,$07ae,$069e,$048d
	dc.w	$037d,$016d,$015b,$005a
	dc.w	$0437,$0048,$0426,$0037
	dc.w	$0325,$0314,$0203,$0000
efcol2:
introcol2:
	dc.w	$0000,$0000,$0000,$0000
	dc.w	$0000,$0000,$0000,$0000
	dc.w	$0000,$0000,$0000,$0000
	dc.w	$0000,$0000,$0000,$0000
	dc.w	$0000,$0000,$0000,$0000
	dc.w	$0000,$0000,$0000,$0000
	dc.w	$0000,$0000,$0000,$0000
	dc.w	$0000,$0000,$0000,$0000
;	**** MUSIC MODULE ****
mt_data:
	incbin	"mod.swa-snackman_music"	
	dc.l	0
