	section andy,code_c
	opt c-,d+

	jmp	starts

stp	equ	255

Title:	dc.b	'up your ring vol.1',0			;Title of album

Number:	dc.l	13				;number of tunes upto 16

	* Names to be seen on screen

nam1:	dc.b	'music2',0
nam2:	dc.b	'rearended',0
nam3:	dc.b	'nightly thrustings',0
nam4:	dc.b	'art forgery 2',0
nam5:	dc.b	'guitariffola',0
nam6:	dc.b	'pukeydook',0
nam7:	dc.b	'throbbing bulge',0
nam8:	dc.b	'throbbing high',0
nam9:	dc.b	'blueveiner',0
nam10:	dc.b	'deep cleavage',0
nam11:	dc.b	'boner',0
nam12:	dc.b	'horizontal jogging',0
nam13:	dc.b	'ghostbusters',0
nam14:	dc.b	' ',0
nam15:	dc.b	' ',0
nam16:	dc.b	' ',0

	* Filenames on the disk

dnam1:	dc.b	'music2',0
dnam2:	dc.b	'rearended',0
dnam3:	dc.b	'nightly',0
dnam4:	dc.b	'art2',0
dnam5:	dc.b	'guitariffola',0
dnam6:	dc.b	'pukeydook',0
dnam7:	dc.b	'throbbing',0
dnam8:	dc.b	'throbhigh',0
dnam9:	dc.b	'blueveiner',0
dnam10:	dc.b	'deepcleavage',0
dnam11:	dc.b	'boner',0
dnam12:	dc.b	'horizontal',0
dnam13:	dc.b	'ghostbusters',0
dnam14:	dc.b	'',0
dnam15:	dc.b	'',0
dnam16:	dc.b	'',0

loadtext:
	dc.b	16,29,'loading',0
decomtext:
	dc.b	14,29,'decrunching    ',0
clrtext:
	dc.b	14,29,'               ',0
message:
	dc.b	'  ANDY WAS ERE, SO WHAT ARE YOU GOING TO DO ABOUT IT??....     ',stp,0

	even

namlist:	
	dc.l	nam1,nam2,nam3,nam4,nam5,nam6,nam7,nam8,nam9,nam10,nam11,nam12,nam13,nam14,nam15,nam16
dnamlist:	
	dc.l	dnam1,dnam2,dnam3,dnam4,dnam5,dnam6,dnam7,dnam8,dnam9,dnam10,dnam11,dnam12,dnam13,dnam14,dnam15,dnam16

	*************************
	* Setup V2.1 Rev.3/3/90 *
	*************************

startlist1	equ	38
startlist2	equ	50

plnw		equ	40
plnh		equ	300
plnsize		equ	plnw*plnh
plnnum		equ	1
plndata		equ	plnsize*plnnum

starts:
	move.l	$4,a6
	lea	dosname,a1
	jsr	-552(a6)
	move.l	d0,dosbase
	beq	error

	move.l	4,a6
	move.l	#$10002,d1
	move.l	#plndata,d0
	jsr	-198(a6)
	cmp.l	#$00,d0
	beq	error
	move.l	d0,plnbase

	move.l	4,a6
	move.l	#gfxname,a1
	moveq.l	#0,d0
	jsr	-552(a6)
	move.l	d0,gfxbase

	moveq.l	#0,d0			;do title
	lea	title,a0
	lea	toptext+2,a1
	
.lp:	add.l	#1,d0
	move.b	(a0)+,(a1)+
	bne	.lp

	move.l	#40,d1
	sub.l	d0,d1
	lsr.l	#1,d1

	move.b	d1,toptext

	MOVE.W	#$0080,$dff096
	move.w	$dff01c,sysint
	or.w	#$c000,sysint
	move.w	#$7fff,$dff09a
	move.w	#$c02f,$dff09a
	move.l	$6c,intsave
	move.l	#newcopper,$dff080
	clr.w	$dff088
	move.w	#$8480,$dff096	
	move.l	plnbase,a1
	move.l	#plnsize,d0
	move.l	a1,stor
	move.l	stor,pln1
	move.w	stor,bp1+2
	move.w	stor+2,bp1+6
	add.l	d0,stor
	move.l	stor,pln2
	move.w	stor,bp2+2
	move.w	stor+2,bp2+6

	jsr	getnames

	lea	toptext,a0
	jsr	print	

	move.w	#0,$dff180
	move.l	#isr,$6c

wait:	jsr	task			;jmp to our sub.
	btst	#6,$bfe001		;wait for mouse.
	bne	wait
	move.l	gfxbase,a4
	move.l	startlist1(a4),$dff080
	move.l	startlist2(a4),$dff084
	clr.w	$dff088	
	move.l	intsave,$6c
	move.w	sysint,$dff09a
	move.w	#$8080,$dff096
	move.w	#$0400,$dff096
	move.l	4,a6
	move.l	plnbase,a1
	move.l	#plndata,d0
	jsr	-210(a6)
	move.l	gfxbase,a1
	jsr	-414(a6)

	jsr	stop

error:	move.w	#$0fff,$dff180
	rts				;exit.

newcopper:					
	dc.w	$0100,$1200
scrl:	dc.w	$0102,$0000

bp1:	dc.w	$00e0,$0100,$00e2,$0000
bp2:	dc.w	$00e4,$0100,$00e6,$0000
bp3:	dc.w	$00e8,$0100,$00ea,$0000
bp4:	dc.w	$00ec,$0100,$00ee,$0000
bp5:	dc.w	$00f0,$0100,$00f2,$0000

	dc.w	$008E,$2c81,$0090,$2cb9                                 
	dc.w	$0092,$0038,$0094,$00d0
mod:	dc.w	$0108,$0000,$010a,$0000

sp0:	dc.w	$0120,$fffe,$0122,$0000	
	dc.w	$0124,$fffe,$0126,$0000	
	dc.w	$0128,$fffe,$012a,$0000	
	dc.w	$012c,$fffe,$012e,$0000	
	dc.w	$0130,$fffe,$0132,$0000	
	dc.w	$0134,$fffe,$0136,$0000	
	dc.w	$0138,$fffe,$013a,$0000	
	dc.w	$013c,$fffe,$013e,$0000	

	dc.w	$0180,$0000

	dc.w	$3f01,$fffe,$0180,$0f00	
	dc.w	$3c01,$fffe,$0180,$0c00	
	dc.w	$3801,$fffe,$0180,$0800	
	dc.w	$3401,$fffe,$0180,$0400	

	dc.w	$3501,$fffe,$0180,$0000

	dc.w	$2401,$fffe,$0180,$0004	
	dc.w	$4001,$fffe,$0180,$0008	
	dc.w	$4101,$fffe,$0180,$000c	
	dc.w	$4201,$fffe,$0180,$000f	

	dc.w	$3301,$fffe,$0180,$0006	

barstrt:dc.w	$2421,$fffe,$0182,$0faf
	dc.w	$2521,$fffe,$0182,$0fcf
	dc.w	$2621,$fffe,$0182,$0fff
	dc.w	$2721,$fffe,$0182,$0fcf
	dc.w	$2821,$fffe,$0182,$0faf
 
barstop:dc.w	$6901,$fffe,$0182,$0fff
	


	dc.w	$9401,$fffe,$0180,$001e	
	dc.w	$9501,$fffe,$0180,$001a	
	dc.w	$9601,$fffe,$0180,$0016	
	dc.w	$9701,$fffe,$0180,$0012	

	dc.w	$9801,$fffe,$0180,$0100

bar1:	
	dc.w	$b021,$fffe,$0180,$0444
	dc.w	$b031,$fffe,$0180,$0044
	dc.w	$b039,$fffe,$0180,$0000

	dc.w	$b121,$fffe,$0180,$0888
	dc.w	$b131,$fffe,$0180,$0088
	dc.w	$b139,$fffe,$0180,$0000

	dc.w	$b221,$fffe,$0180,$0bbb
	dc.w	$b231,$fffe,$0180,$00bb
	dc.w	$b239,$fffe,$0180,$0000

	dc.w	$b321,$fffe,$0180,$0ddd
	dc.w	$b331,$fffe,$0180,$00dd
	dc.w	$b339,$fffe,$0180,$0000

	dc.w	$b421,$fffe,$0180,$0bbb
	dc.w	$b431,$fffe,$0180,$00bb
	dc.w	$b439,$fffe,$0180,$0000

	dc.w	$b521,$fffe,$0180,$0888
	dc.w	$b531,$fffe,$0180,$0088
	dc.w	$b539,$fffe,$0180,$0000

	dc.w	$b621,$fffe,$0180,$0444
	dc.w	$b631,$fffe,$0180,$0044
	dc.w	$b639,$fffe,$0180,$0000

bar2:	
	dc.w	$b821,$fffe,$0180,$0444
	dc.w	$b831,$fffe,$0180,$0044
	dc.w	$b839,$fffe,$0180,$0000

	dc.w	$b921,$fffe,$0180,$0888
	dc.w	$b931,$fffe,$0180,$0088
	dc.w	$b939,$fffe,$0180,$0000

	dc.w	$ba21,$fffe,$0180,$0bbb
	dc.w	$ba31,$fffe,$0180,$00bb
	dc.w	$ba39,$fffe,$0180,$0000

	dc.w	$bb21,$fffe,$0180,$0ddd
	dc.w	$bb31,$fffe,$0180,$00dd
	dc.w	$bb39,$fffe,$0180,$0000

	dc.w	$bc21,$fffe,$0180,$0bbb
	dc.w	$bc31,$fffe,$0180,$00bb
	dc.w	$bc39,$fffe,$0180,$0000

	dc.w	$bd21,$fffe,$0180,$0888
	dc.w	$bd31,$fffe,$0180,$0088
	dc.w	$bd39,$fffe,$0180,$0000

	dc.w	$be21,$fffe,$0180,$0444
	dc.w	$be31,$fffe,$0180,$0044
	dc.w	$be39,$fffe,$0180,$0000

bar3:	
	dc.w	$c021,$fffe,$0180,$0444
	dc.w	$c031,$fffe,$0180,$0044
	dc.w	$c039,$fffe,$0180,$0000

	dc.w	$c121,$fffe,$0180,$0888
	dc.w	$c131,$fffe,$0180,$0088
	dc.w	$c139,$fffe,$0180,$0000

	dc.w	$c221,$fffe,$0180,$0bbb
	dc.w	$c231,$fffe,$0180,$00bb
	dc.w	$c239,$fffe,$0180,$0000

	dc.w	$c321,$fffe,$0180,$0ddd
	dc.w	$c331,$fffe,$0180,$00dd
	dc.w	$c339,$fffe,$0180,$0000

	dc.w	$c421,$fffe,$0180,$0bbb
	dc.w	$c431,$fffe,$0180,$00bb
	dc.w	$c439,$fffe,$0180,$0000

	dc.w	$c521,$fffe,$0180,$0888
	dc.w	$c531,$fffe,$0180,$0088
	dc.w	$c539,$fffe,$0180,$0000

	dc.w	$c621,$fffe,$0180,$0444
	dc.w	$c631,$fffe,$0180,$0044
	dc.w	$c639,$fffe,$0180,$0000

bar4:	
	dc.w	$c821,$fffe,$0180,$0444
	dc.w	$c831,$fffe,$0180,$0044
	dc.w	$c839,$fffe,$0180,$0000

	dc.w	$c921,$fffe,$0180,$0888
	dc.w	$c931,$fffe,$0180,$0088
	dc.w	$c939,$fffe,$0180,$0000

	dc.w	$ca21,$fffe,$0180,$0bbb
	dc.w	$ca31,$fffe,$0180,$00bb
	dc.w	$ca39,$fffe,$0180,$0000

	dc.w	$cb21,$fffe,$0180,$0ddd
	dc.w	$cb31,$fffe,$0180,$00dd
	dc.w	$cb39,$fffe,$0180,$0000

	dc.w	$cc21,$fffe,$0180,$0bbb
	dc.w	$cc31,$fffe,$0180,$00bb
	dc.w	$cc39,$fffe,$0180,$0000

	dc.w	$cd21,$fffe,$0180,$0888
	dc.w	$cd31,$fffe,$0180,$0088
	dc.w	$cd39,$fffe,$0180,$0000

	dc.w	$ce21,$fffe,$0180,$0444
	dc.w	$ce31,$fffe,$0180,$0044
	dc.w	$ce39,$fffe,$0180,$0000
	


	dc.w	$ffdf,$fffe


	dc.w	$1601,$fffe,$0182,$01f0
	dc.w	$1701,$fffe,$0182,$01e0
	dc.w	$1801,$fffe,$0182,$01a0
	dc.w	$1901,$fffe,$0182,$0180


	dc.w    $0108,-80
	dc.w    $010a,-80
	
	dc.w    $ff01,$fffe
        dc.w    $0108,$0000
	dc.w    $010a,$0000
	
	dc.w	$ffff,$fffe
	
gfxname:dc.b	'graphics.library',0
	even
gfxbase:dc.l	0

stor:	dc.l	0
pln1:	dc.l	0
pln2:	dc.l	0
pln3:	dc.l	0
pln4:	dc.l	0
pln5:	dc.l	0
sysint:	dc.w	0
intsave:dc.l	0
plnbase:dc.l	0
barpos:	dc.l	0
barcol:	dc.l	0
song:	dc.l	0

toptext:
	dc.b	0,0,'                                         ',0


isr:	movem.l	d0-d7/a0-a6,-(sp)
	move.w	#$0020,$dff09c
	movem.l	(sp)+,d0-d7/a0-a6
	rte

task:	move.w	$dff006,d0
	and.w	#$ff00,d0
	cmp.w	#$af00,d0
	bne	task
	;move.w	#$000f,$dff09a
	jsr	getkey
	jsr	drawbar
	jsr	scroller
	tst.l	song
	beq	.lp
	jsr	replay
	jsr	dospec
	jsr	docbars
	jsr	dokey
	rts
.lp:	move.w	#-1,mt_aud1temp
	move.w	#-1,mt_aud2temp
	move.w	#-1,mt_aud3temp
	move.w	#-1,mt_aud4temp
	jsr	dospec
	jsr	docbars
	;move.w	#$c00f,$dff09a
	jsr	dokey
	rts

Drawbar:
	move.l	barpos,d0
	mulu	#6,d0
	add.l	#$44,d0
	move.b	d0,barstrt
	add.l	#1,d0
	move.b	d0,barstrt+8
	add.l	#1,d0
	move.b	d0,barstrt+16
	add.l	#1,d0
	move.b	d0,barstrt+24
	add.l	#1,d0
	move.b	d0,barstrt+32
	add.l	#1,d0
	move.b	d0,barstop

	rts

dokey:	
	cmp.b	#$67,keyread
	beq	up
	cmp.b	#$65,keyread
	beq	down
	cmp.b	#$77,keyread
	beq	return
	rts
up:	tst.l	barpos
	beq	.lp
	sub.l	#1,barpos
.lp:	
	rts

down:	move.l	number,d0
	sub.l	#1,d0
	cmp.l	barpos,d0
	beq	.lp
	add.l	#1,barpos
.lp:	rts
return:	
	move.l	intsave,$6c
	move.w	sysint,$dff09a
	lea	dnamlist,a0
	move.l	barpos,d0
	asl.l	#2,d0
	add.l	d0,a0
	move.l	(a0),a0
	lea	loadname,a1
.lp:	move.b	(a0)+,(a1)+
	bne	.lp
	tst.l	song
	beq	.lp2
	jsr	stop
.lp2:	lea	loadtext,a0
	jsr	print
	jsr	load
	tst.l	d0
	bne	.lp3
	move.l	#1,song
	lea	decomtext,a0
	jsr	print
	jsr	decomp
	lea	clrtext,a0
	jsr	print
	jsr	start
.lp3:	move.w	#$7fff,$dff09a
	move.l	#isr,$6c
	move.w	#$c02f,$dff09a
	rts		

getnames:
	move.l	number,d0
	sub.l	#1,d0
	lea	namlist,a0
	move.l	#4,d1

.lp2:	move.b	d1,namtxt+1
	move.l	(a0)+,a1
	lea	namtxt+2,a2
	moveq.l	#0,d2

.lp:	add.l	#1,d2
	move.b	(a1)+,(a2)+
	bne	.lp	

	move.l	#40,d3
	sub.l	d2,d3

	lsr.l	#1,d3
	move.b	d3,namtxt	
	
	movem.l	d0-d7/a0-a6,-(sp)
	lea	namtxt,a0
	jsr	print
	movem.l	(sp)+,d0-d7/a0-a6
	
	add.l	#1,d1

	dbra	d0,.lp2
	rts

namtxt:ds.b	42

	*****************************
	*Note:-       		    *
	* A-Obj       		    *
	* B-Msk                     *
	* C-Bck                     *
	* D-Bck                     *
	* M-00001111 10111000       *
	*****************************

	******************************
	*Char string print grey chars
	*chars 1 bp,528 pix w,66 chars 
	*screen width equ #40b
	*a0 text string x,y
	*pln num in a6
	*255 cr,0 termination
	*d7,d6
	*a0,a5,a6
	******************************
Print:	
	move.l	pln1,a6
	moveq.l	#0,d7
	moveq.l	#0,d6
	move.b	(a0)+,d7	;get x
	add.l	d7,a6
	move.b	(a0)+,d7	;get y
	mulu.w	#40*6,d7
	add.l	d7,a6		;a6 strt addr
	;add.l	#120,a6

prchr2:	moveq.l	#0,d7
	lea	chars,a5
	move.b	(a0)+,d7	;get char
	beq	prend2
	bmi	print
	sub.b	#32,d7
	btst.l	#6,d7
	beq	notlo2
	sub.b	#32,d7
notlo2:	add.l	d7,a5
	
	move.b	(a5),(a6)
	
	move.b	66(a5),40(a6)

	move.b	132(a5),80(a6)

	move.b	198(a5),120(a6)
	
	move.b	264(a5),160(a6)
	
	move.b	330(a5),200(a6)
	add.l	#1,a6
	bra	prchr2
prend2:	rts	
chars:	incbin	'context'
	even

	**************************
	*Read keyboard & auto repeat
	*key in keyread.b
	*d0
	**************************

Getkey:	add.l	#1,slow
	and.l	#1,slow
	btst.b	#0,slow+3
	beq	nokeys
	cmp.b	#0,keyrep
	beq	tstkey
	move.b	keypress,d0
	cmp.b	$bfec01,d0
	beq	subrep
newkey:	move.b	$bfec01,keypress
	move.b	$bfec01,keyread
	move.b	#4,keyrep
	rts
subrep:	sub.b	#1,keyrep
	move.b	#0,keyread
	rts
tstkey:	move.b	keypress,d0
	cmp.b	$bfec01,d0
	bne	newkey
	move.b	$bfec01,keyread
	rts	
nokeys:
	move.b	#0,keyread
	rts

keyread:
	dc.l	0
slow:	dc.l	0
keyrep:	dc.l	0
keypress:
	dc.l	0
	even


Decomp:	
	move.l	songlen,d0		;length
	move.l	#BUFFER,a1
	move.l	#DATA,a0
	move.l	a0,a2
	add.l	d0,a2
next_byte:
	move.b	(a1)+,d0		;get command byte
	tst.b	d0			;if plus string decompress
	bpl	str_dec

more_mult:
	move.b	(a1),(a0)+		;write multi byte

	;move.w	#$0f00,$dff180

	cmp.l	a2,a0			;chk last byte
	beq	last_dec

	add.b	#1,d0			;any more?
	bmi	more_mult
	add.l	#1,a1			;goto next command byte
	bra	next_byte

str_dec:
	move.b	(a1)+,(a0)+		;write next byte string

	;move.w	#$00f0,$dff180

	cmp.l	a2,a0			;chk last byte
	beq	last_dec		

	sub.b	#1,d0
	bpl	str_dec			;any more?
	bra	next_byte

last_dec
	rts

load:	
	move.l	#1005,d2
	bsr	openfile
	beq	derror
	bsr	read
	bsr	closefile
	moveq.l	#0,d0
	rts
derror:	move.l	#-1,d0
	rts
openfile:
	move.l	dosbase,a6
	move.l	#loadname,d1
	jsr	-30(a6)
	move.l	d0,filehd
	rts
closefile:
	move.l	dosbase,a6
	move.l	filehd,d1
	jsr	-36(a6)
	rts
read:	move.l	dosbase,a6
	move.l	filehd,d1
	move.l	#songlen,d2	;start addr
	move.l	#$3ffff,d3	;length
	jsr	-42(a6)
	rts	

filehd:	dc.l	0
dosbase:dc.l	0
dosname:dc.b	"dos.library",0
	even

songlen:dc.l	0
buffer:	ds.b	150*1024
data:	ds.b	150*1024


loadname:
	dc.b	'                               ',0		;new filename

; -----------------------------------------------
; ------- Soundtracker V2.4 - playroutine -------
; -----------------------------------------------

; call 'mt_init' to initialize the playroutine

start:	lea	data,a0
	add.l	#$03b8,a0
	moveq	#$7f,d0
	moveq	#0,d1
mt_init1:
	move.l	d1,d2
	subq.w	#1,d0
mt_init2:
	move.b	(a0)+,d1
	cmp.b	d2,d1
	bgt.s	mt_init1
	dbf	d0,mt_init2
	addq.b	#1,d2

mt_init3:
	lea	data,a0
	lea	mt_sample1(pc),a1
	asl.l	#8,d2
	asl.l	#2,d2
	add.l	#$438,d2
	add.l	a0,d2
	moveq	#$1e,d0
mt_init4:
	move.l	d2,(a1)+
	moveq	#0,d1
	move.w	42(a0),d1
	asl.l	#1,d1
	add.l	d1,d2
	add.l	#$1e,a0
	dbf	d0,mt_init4

	lea	mt_sample1(PC),a0
	moveq	#0,d0
mt_clear:
	move.l	(a0,d0.w),a1
	clr.l	(a1)
	addq.w	#4,d0
	cmp.w	#$7c,d0
	bne.s	mt_clear

	clr.w	$dff0a8
	clr.w	$dff0b8
	clr.w	$dff0c8
	clr.w	$dff0d8
	clr.l	mt_partnrplay
	clr.l	mt_partnote
	clr.l	mt_partpoint

	move.b	data+$3b6,mt_maxpart+1
	rts

; call 'mt_end' to switch the sound off

stop:	clr.w	$dff0a8
	clr.w	$dff0b8
	clr.w	$dff0c8
	clr.w	$dff0d8
	move.w	#$f,$dff096
	rts

; the playroutine - call this every frame

replay:
	addq.w	#1,mt_counter
mt_cool:cmp.w	#6,mt_counter
	bne.s	mt_notsix
	clr.w	mt_counter
	bra	mt_rout2

mt_notsix:
	lea	mt_aud1temp(PC),a6
	tst.b	3(a6)
	beq.s	mt_arp1
	lea	$dff0a0,a5		
	bsr.s	mt_arprout
mt_arp1:lea	mt_aud2temp(PC),a6
	tst.b	3(a6)
	beq.s	mt_arp2
	lea	$dff0b0,a5
	bsr.s	mt_arprout
mt_arp2:lea	mt_aud3temp(PC),a6
	tst.b	3(a6)
	beq.s	mt_arp3
	lea	$dff0c0,a5
	bsr.s	mt_arprout
mt_arp3:lea	mt_aud4temp(PC),a6
	tst.b	3(a6)
	beq.s	mt_arp4
	lea	$dff0d0,a5
	bra.s	mt_arprout
mt_arp4:rts

mt_arprout:
	move.b	2(a6),d0
	and.b	#$0f,d0
	tst.b	d0
	beq	mt_arpegrt
	cmp.b	#$01,d0
	beq.s	mt_portup
	cmp.b	#$02,d0
	beq.s	mt_portdwn
	cmp.b	#$0a,d0
	beq.s	mt_volslide
	rts

mt_portup:
	moveq	#0,d0
	move.b	3(a6),d0
	sub.w	d0,22(a6)
	cmp.w	#$71,22(a6)
	bpl.s	mt_ok1
	move.w	#$71,22(a6)
mt_ok1:	move.w	22(a6),6(a5)
	rts

mt_portdwn:
	moveq	#0,d0
	move.b	3(a6),d0
	add.w	d0,22(a6)
	cmp.w	#$538,22(a6)
	bmi.s	mt_ok2
	move.w	#$538,22(a6)
mt_ok2:	move.w	22(a6),6(a5)
	rts

mt_volslide:
	moveq	#0,d0
	move.b	3(a6),d0
	lsr.b	#4,d0
	tst.b	d0
	beq.s	mt_voldwn
	add.w	d0,18(a6)
	cmp.w	#64,18(a6)
	bmi.s	mt_ok3
	move.w	#64,18(a6)
mt_ok3:	move.w	18(a6),8(a5)
	rts
mt_voldwn:
	moveq	#0,d0
	move.b	3(a6),d0
	and.b	#$0f,d0
	sub.w	d0,18(a6)
	bpl.s	mt_ok4
	clr.w	18(a6)
mt_ok4:	move.w	18(a6),8(a5)
	rts

mt_arpegrt:
	move.w	mt_counter(PC),d0
	cmp.w	#1,d0
	beq.s	mt_loop2
	cmp.w	#2,d0
	beq.s	mt_loop3
	cmp.w	#3,d0
	beq.s	mt_loop4
	cmp.w	#4,d0
	beq.s	mt_loop2
	cmp.w	#5,d0
	beq.s	mt_loop3
	rts

mt_loop2:
	moveq	#0,d0
	move.b	3(a6),d0
	lsr.b	#4,d0
	bra.s	mt_cont
mt_loop3:
	moveq	#$00,d0
	move.b	3(a6),d0
	and.b	#$0f,d0
	bra.s	mt_cont
mt_loop4:
	move.w	16(a6),d2
	bra.s	mt_endpart
mt_cont:
	add.w	d0,d0
	moveq	#0,d1
	move.w	16(a6),d1
	and.w	#$fff,d1
	lea	mt_arpeggio(PC),a0
mt_loop5:
	move.w	(a0,d0),d2
	cmp.w	(a0),d1
	beq.s	mt_endpart
	addq.l	#2,a0
	bra.s	mt_loop5
mt_endpart:
	move.w	d2,6(a5)
	rts

mt_rout2:
	lea	data,a0
	move.l	a0,a3
	add.l	#$0c,a3
	move.l	a0,a2
	add.l	#$3b8,a2
	add.l	#$43c,a0
	move.l	mt_partnrplay(PC),d0
	moveq	#0,d1
	move.b	(a2,d0),d1
	asl.l	#8,d1
	asl.l	#2,d1
	add.l	mt_partnote(PC),d1
	move.l	d1,mt_partpoint
	clr.w	mt_dmacon

	lea	$dff0a0,a5
	lea	mt_aud1temp(PC),a6
	bsr	mt_playit
	lea	$dff0b0,a5
	lea	mt_aud2temp(PC),a6
	bsr	mt_playit
	lea	$dff0c0,a5
	lea	mt_aud3temp(PC),a6
	bsr	mt_playit
	lea	$dff0d0,a5
	lea	mt_aud4temp(PC),a6
	bsr	mt_playit
	move.w	#$01f4,d0
mt_rls:	dbf	d0,mt_rls

	move.w	#$8000,d0
	or.w	mt_dmacon,d0
	move.w	d0,$dff096

	lea	mt_aud4temp(PC),a6
	cmp.w	#1,14(a6)
	bne.s	mt_voice3
	move.l	10(a6),$dff0d0
	move.w	#1,$dff0d4
mt_voice3:
	lea	mt_aud3temp(PC),a6
	cmp.w	#1,14(a6)
	bne.s	mt_voice2
	move.l	10(a6),$dff0c0
	move.w	#1,$dff0c4
mt_voice2:
	lea	mt_aud2temp(PC),a6
	cmp.w	#1,14(a6)
	bne.s	mt_voice1
	move.l	10(a6),$dff0b0
	move.w	#1,$dff0b4
mt_voice1:
	lea	mt_aud1temp(PC),a6
	cmp.w	#1,14(a6)
	bne.s	mt_voice0
	move.l	10(a6),$dff0a0
	move.w	#1,$dff0a4
mt_voice0:
	move.l	mt_partnote(PC),d0
	add.l	#$10,d0
	move.l	d0,mt_partnote
	cmp.l	#$400,d0
	bne.s	mt_stop
mt_higher:
	clr.l	mt_partnote
	addq.l	#1,mt_partnrplay
	moveq	#0,d0
	move.w	mt_maxpart(PC),d0
	move.l	mt_partnrplay(PC),d1
	cmp.l	d0,d1
	bne.s	mt_stop
	clr.l	mt_partnrplay
mt_stop:tst.w	mt_status
	beq.s	mt_stop2
	clr.w	mt_status
	bra.s	mt_higher
mt_stop2:
	rts

mt_playit:
	move.l	(a0,d1.l),(a6)
	move.l	(a0,d1.l),24(a6)
	addq.l	#4,d1
	moveq	#0,d2
	move.b	2(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.s	mt_nosamplechange

	moveq	#0,d3
	lea	mt_samples(PC),a1
	move.l	d2,d4
	asl.l	#2,d2
	mulu	#$1e,d4
	move.l	(a1,d2),4(a6)
	move.w	(a3,d4.l),8(a6)
	move.w	2(a3,d4.l),18(a6)
	move.w	4(a3,d4.l),d3
	tst.w	d3
	beq.s	mt_displace
	move.l	4(a6),d2
	add.l	d3,d2
	move.l	d2,4(a6)
	move.l	d2,10(a6)
	move.w	6(a3,d4.l),8(a6)
	move.w	6(a3,d4.l),14(a6)
	move.w	18(a6),8(a5)
	bra.s	mt_nosamplechange

mt_displace:
	move.l	4(a6),d2
	add.l	d3,d2
	move.l	d2,10(a6)
	move.w	6(a3,d4.l),14(a6)
	move.w	18(a6),8(a5)
mt_nosamplechange:
	move.w	(a6),d0
	and.w	#$fff,d0
	tst.w	d0
	beq.s	mt_retrout
	move.w	(a6),16(a6)
	move.w	20(a6),$dff096
	move.l	4(a6),(a5)
	move.w	8(a6),4(a5)
	move.w	(a6),d0
	and.w	#$fff,d0
	move.w	d0,6(a5)
	move.w	20(a6),d0
	or.w	d0,mt_dmacon

mt_retrout:
	tst.w	(a6)
	beq.s	mt_nonewper
	move.w	(a6),22(a6)

mt_nonewper:
	move.b	2(a6),d0
	and.b	#$0f,d0
	cmp.b	#$0b,d0
	beq.s	mt_posjmp
	cmp.b	#$0c,d0
	beq.s	mt_setvol
	cmp.b	#$0d,d0
	beq.s	mt_break
	cmp.b	#$0e,d0
	beq.s	mt_setfil
	cmp.b	#$0f,d0
	beq.s	mt_setspeed
	rts

mt_posjmp:
	not.w	mt_status
	moveq	#0,d0
	move.b	3(a6),d0
	subq.b	#1,d0
	move.l	d0,mt_partnrplay
	rts

mt_setvol:
	move.b	3(a6),8(a5)
	rts

mt_break:
	not.w	mt_status
	rts

mt_setfil:
	moveq	#0,d0
	move.b	3(a6),d0
	and.b	#1,d0
	rol.b	#1,d0
	and.b	#$fd,$bfe001
	or.b	d0,$bfe001
	rts

mt_setspeed:
	move.b	3(a6),d0
	and.b	#$0f,d0
	beq.s	mt_back
	clr.w	mt_counter
	move.b	d0,mt_cool+3
mt_back:rts

mt_aud1temp:
	dcb.w	10,0
	dc.w	1
	dcb.w	2,0
	dc.w	0
mt_aud2temp:
	dcb.w	10,0
	dc.w	2
	dcb.w	2,0
	dc.w	0
mt_aud3temp:
	dcb.w	10,0
	dc.w	4
	dcb.w	2,0
	dc.w	0
mt_aud4temp:
	dcb.w	10,0
	dc.w	8
	dcb.w	2,0
	dc.w	0

mt_partnote:	dc.l	0
mt_partnrplay:	dc.l	0
mt_counter:	dc.w	0
mt_partpoint:	dc.l	0
mt_samples:	dc.l	0
mt_sample1:	dcb.l	31,0
mt_maxpart:	dc.w	0
mt_dmacon:	dc.w	0
mt_status:	dc.w	0

mt_arpeggio:
	dc.w $0358,$0328,$02fa,$02d0,$02a6,$0280,$025c
	dc.w $023a,$021a,$01fc,$01e0,$01c5,$01ac,$0194,$017d
	dc.w $0168,$0153,$0140,$012e,$011d,$010d,$00fe,$00f0
	dc.w $00e2,$00d6,$00ca,$00be,$00b4,$00aa,$00a0,$0097
	dc.w $008f,$0087,$007f,$0078,$0071,$0000,$0000,$0000



	* M-00001111 10111000       *
	*****************************


	**************************
	*Gets new notes for spec and displays all
	*a0,a1,a2,a3
	*d0,d1
	**************************

Dospec:
	;move.w	#$00f0,specol+2
	jsr	getspec
	moveq.l	#0,d0
.lp5:	lea	spech,a0
	tst.b	(a0,d0)
	beq	.lp4
	move.l	pln1,a1
	add.l	#253*40,a1
	add.l	#2,a1
	moveq.l	#0,d1
	move.b	(a0,d0),d1
	mulu.w	#80,d1
	sub.l	d1,a1
	move.b	#0,(a1,d0)
	add.l	#80,a1
.lp2:	move.b	#%11111110,(a1,d0)
	add.l	#80,a1
	sub.l	#80,d1
	bne	.lp2
	sub.b	#1,(a0,d0)
	
.lp4:	lea	spect,a0
	tst.b	(a0,d0)
	beq	.lp3
	move.l	pln1,a1
	add.l	#253*40,a1
	add.l	#2,a1
	moveq.l	#0,d1
	move.b	(a0,d0),d1
	mulu.w	#80,d1
	sub.l	d1,a1
	move.b	#0,(a1,d0)
	move.b	#%11111110,80(a1,d0)
	lea	spech,a0
	tst.b	(a0,d0)
	bne	.lp3
	lea	spect,a0
	sub.b	#1,(a0,d0)
.lp3:	add.l	#1,d0
	cmp.l	#36,d0
	bne	.lp5
	rts
	even
	
	*************************
	*Get info and put into spec
	*chngx sample number.b
	*fchngx pointer to frequ of note.b
	*a0,a1,a2,a3
	*d0,d1
	*************************

getspec:
	lea	mt_arpeggio,a0
	move.w	mt_aud1temp,d1
	jsr	aspect
	move.w	#1,mt_aud1temp
	lea	mt_arpeggio,a0
	move.w	mt_aud2temp,d1
	jsr	aspect
	move.w	#1,mt_aud2temp
	lea	mt_arpeggio,a0
	move.w	mt_aud3temp,d1
	jsr	aspect
	move.w	#1,mt_aud3temp
	lea	mt_arpeggio,a0
	move.w	mt_aud4temp,d1
	jsr	aspect
	move.w	#1,mt_aud4temp
	rts
	
aspect	move.l	#0,d0
.lp:	cmp.w	(a0)+,d1
	beq	.lp2
	add.l	#1,d0
	cmp.l	#36,d0
	bne	.lp
	rts

.lp2:	
	lea	spech,a0
	move.b	#16,(a0,d0)
	lea	spect,a0
	move.b	#16,(a0,d0)

	sub.l	#1,d0
	bmi	.lp7
	lea	spech,a0
	add.b	#4,(a0,d0)
	cmp.b	#16,(a0,d0)
	ble	.lp6
	move.b	#16,(a0,d0)
.lp6:	move.b	(a0,d0),d1
	lea	spect,a0
	cmp.b	(a0,d0),d1
	ble	.lp7
	move.b	d1,(a0,d0)

.lp7:	add.l	#2,d0
	cmp.l	#36,d0
	beq	.lp8
.lp4:	lea	spech,a0
	add.b	#4,(a0,d0)
	cmp.b	#16,(a0,d0)
	ble	.lp5
	move.b	#16,(a0,d0)
.lp5:	move.b	(a0,d0),d1
	lea	spect,a0
	cmp.b	(a0,d0),d1
	ble	.lp8
	move.b	d1,(a0,d0)
.lp8:	rts
	
spech:	rept	36
	dc.b	1
	endr
spect:	rept	36
	dc.b	1
	endr
chng0:	dc.b	0	
fchng0:	dc.b	0	
chng1:	dc.b	0	
fchng1:	dc.b	0	
chng2:	dc.b	0	
fchng2:	dc.b	0	
chng3:	dc.b	0	
fchng3:	dc.b	0	
	even
cbar1:	dc.l	0
cbar2:	dc.l	0
cbar3:	dc.l	0
cbar4:	dc.l	0

Docbars:
	jsr	chkchans

	lea	cbar1,a0
	lea	bar1,a1

	moveq.l	#3,d4
.lp2:	moveq.l	#6,d0
	move.l	(a0)+,d1
	asl.l	#3,d1
	move.b	#$31,d2
	move.b	#$39,d3

	add.b	d1,d2
	add.b	d1,d3

.lp:	move.b	d2,9(a1)
	move.b	d3,17(a1)

	add.l	#24,a1
	dbra	d0,.lp
	dbra	d4,.lp2
	rts

chkchans:
	move.w	mt_aud1temp+24,d0
	cmp.w	#0,d0
	beq	.lp
	move.w	#0,mt_aud1temp+24
	move.l	#22,cbar1
.lp:
	move.w	mt_aud2temp+24,d0
	cmp.w	#0,d0
	beq	.lp2
	move.w	#0,mt_aud2temp+24
	move.l	#22,cbar2
.lp2:
	move.w	mt_aud3temp+24,d0
	cmp.w	#0,d0
	beq	.lp3
	move.w	#0,mt_aud3temp+24
	move.l	#22,cbar3
.lp3:
	move.w	mt_aud4temp+24,d0
	cmp.w	#0,d0
	beq	.lp4
	move.w	#0,mt_aud4temp+24
	move.l	#22,cbar4
.lp4:	
	tst.l	cbar1
	beq	.lp5
	sub.l	#1,cbar1
.lp5:
	tst.l	cbar2
	beq	.lp6
	sub.l	#1,cbar2
.lp6:
	tst.l	cbar3
	beq	.lp7
	sub.l	#1,cbar3
.lp7:
	tst.l	cbar4
	beq	.lp8
	sub.l	#1,cbar4
.lp8:	rts

	even

pause:	dc.l	0
messcount:
	dc.l	0
pixcount:
	dc.l	4

scroller:
	tst.l	pause
	beq	.lp
	sub.l	#1,pause
	rts

.lp:	
	;move.w	#$0fff,$dff180
	move.l	pln1,d0
	add.l	#7520-40,d0
	move.l	d0,d1
	add.l	#2,d1
	move.l	d0,a0
	move.b	#0,39(a0)

	move.l	d1,$dff050	;a source IM
	move.l	d0,$dff054	;d source
	move.w	#$0000,$dff064	;a mod
	move.w	#$0000,$dff066	;d mod
	move.w	#$ffff,$dff044	;fw mask
	move.w	#$ffff,$dff046	;lw mask
	move.w	#%1110100111110000,$dff040	;con0
	move.w	#%0000000000000000,$dff042	;con1
	move.w	#%0000000111010100,$dff058	;size		
	;move.w	#$0000,$dff180

	sub.l	#1,pixcount
	bne	.lp2

.lp4:	move.l	pln1,a0
	add.l	#7559,a0
	lea	message,a1
	add.l	messcount,a1
	moveq.l	#0,d0
	move.b	(a1),d0
	bmi	.lp5
	tst.b	d0
	bne	.lp3
	move.l	#0,messcount
	bra	.lp4
.lp3:	sub.b	#32,d0
	add.l	#chars,d0
	move.l	d0,a1
		 
	move.b	(a1),(a0)
	move.b	66(a1),40(a0)
	move.b	132(a1),80(a0)
	move.b	198(a1),120(a0)
	move.b	264(a1),160(a0)
	move.b	330(a1),200(a0)

	add.l	#1,messcount
	move.l	#4,pixcount

.lp2:	rts
.lp5:	move.l	#1,pixcount
	move.l	#200,pause
	add.l	#1,messcount
	rts




