s:
;lea	$57000,a0
;lea	$59000,a1
;loesch:
;clr.l	(a0)+
;cmp.l	a0,a1
;bne	loesch
bsr	start_muzak

lea	$71000,a0
lea	$50000,a1
bsr	unpack
lea	$74000,a0	; Beginning of Compacted - Picture
lea	$40000,a1	; Entpackted Picture
bsr	unpack		; Entpacken
bsr	setupcol	; Farben setzen
lea	$78000,a0
lea	$47000,a1
bsr	unpack

move.l	#$2a11fffe,d0
move.l	#$01800000,d1
move.l	#$01080078,d2
move.l	#$010a0078,d3
move.w	#160,d4
lea	coppar,a0
setcop:
move.l	d0,(a0)+
move.l	d1,(a0)+
move.l	d2,(a0)+
move.l	d3,(a0)+
add.l	#$01000000,d0
move.w	d0,$dff180
sub.w	#1,d4
bne	setcop
move.l	d0,(a0)+
move.l	#$01800f0f,(a0)+
move.l	#$01080038,(a0)+
move.l	#$010a0038,(a0)+
move.l	#$cb11fffe,(a0)+
move.l	#$018000ff,(a0)+
move.l	#$00e00005,(a0)+
move.l	#$00e27004,(a0)+
move.l	#$cc11fffe,(a0)+
move.l	#$01800ff0,(a0)+
move.l	#$00e40005,(a0)+
move.l	#$00e67094,(a0)+
move.l	#$cd11fffe,(a0)+
move.l	#$01800f00,(a0)+
move.l	#$01002200,(a0)+
move.l	#$01860aaa,(a0)+
move.l	#$ce11fffe,d1
move.l	#$01800000,d2
move.w	#100,d0
nextcop:
move.l	d1,(a0)+
move.l	d2,(a0)+
move.l	#$01820eee,(a0)+
move.l	#$01840ccc,(a0)+
add.l	#$01000000,d1
add.l	#$00000002,d2
sub.w	#$1,d0
cmp.l	#$0011fffe,d1
bne	nextcop
sub.w	#1,d0
move.l	#$ffe1fffe,(a0)+
move.l	#$01b00000,(a0)+
move.l	#$01b00000,(a0)+
move.l	#$01b00000,(a0)+
contcop:
move.l	d1,(a0)+
move.l	d2,(a0)+
move.l	#$01820eee,(a0)+
move.l	#$01840ccc,(a0)+
add.l	#$01000000,d1
add.l	#$00000002,d2
sub.w	#1,d0
bne	contcop

move.l	$04,a6
jsr	-132(a6)
lea	gfxname,a1
jsr	-408(a6)
move.l	d0,gfxbase
move.l	d0,a0
move.l	50(a0),oldclist
move.l	#newclist,50(a0)
move.l	$6c,oldirq+2
move.l	#newirq,$6c
wait:
btst	#6,$bfe001
bne.s	wait
move.l	oldirq+2,$6c
move.l	gfxbase,a0
move.l	oldclist,50(a0)
move.l	$04,a6
move.l	gfxbase,a1
jsr	-414(a6)
jsr	-138(a6)
bsr	stop_muzak
rts

newirq:
movem.l	d0-d7/a0-a6,-(sp)

bsr	copyscroll
bsr	scrolldat
bsr	calcnewmod
bsr	writes1
bsr	scrollc1
bsr	turnit
bsr	check

bsr	scroll
sub.w	#1,shift
bne	notget
bsr	getchar
move.w	#16,shift
notget:

exit:
movem.l	(sp)+,d0-d7/a0-a6
oldirq:
jmp	$00000000

newclist:
dc.w	$008e,$2c81,$0090,$2cc1,$0092,$0038,$0094,$00d0
dc.w	$0102,$0000,$0104,$0000,$0108,120,$010a,120
dc.w	$0100,$4200,$0180,$0000
adresses:
dc.w	$00e0,$0004,$00e2,$0000,$00e4,$0004,$00e6,$0028
dc.w	$00e8,$0004,$00ea,$0050,$00ec,$0004,$00ee,$0078
copcol:
blk.l	16,0
dc.w	$120,0,$122,0,$124,0,$126,0,$128,$12a,$12c,0,$12e,0
dc.w	$130,0,$132,0,$134,0,$136,0,$138,$13a,$13c,0,$13e,0
coppar:
blk.w	160*8,0
blk.w	32,0
blk.w	100*8,0
dc.w	$180,0
dc.w	$ffff,$fffe

even
oldclist:
dc.l	0
gfxbase:
dc.l	0
gfxname:
dc.b	"graphics.library",0
even
unpack:
	add.l	#12,a0
	move.l	4(a0),d0
	add.l	d0,a0
	add.l	#8,a0
	move.l	a0,cmapchunk

iff1:	cmp.l	#$424f4459,(a0)
	beq	iff0
	add.l	#2,a0
	bra	iff1

iff0:	move.l	4(a0),d0	; Anzahl Bytes
	add.l	#1,d0
	and.l	#$fffffffe,d0

	add.l	#8,a0		; Pointer to first Byte

iff4:	clr.l	d2
	move.b	(a0)+,d2
	bmi	iff6

iff5:	move.b	(a0)+,(a1)+
	subi.l	#1,d0
	subi.b	#1,d2
	bpl	iff5
	bra	iff7
	
iff6:	neg.b	d2
	beq	iff7

iff61:	move.b	(a0),(a1)+
	subi.b	#1,d2
	bpl	iff61
	subi.l	#1,d0
	add.l	#1,a0

iff7:	subi.l	#1,d0
	bmi	iff8
	beq	iff8
	bra	iff4

iff8:	move.l	cmapchunk,a0
	move.l	cmap,a1
	add.l	#8,a0
	move.l	#16,d0

cmaploop:
	clr.l	d1
	move.b	(a0),d1
	lsl.w	#4,d1
	move.b	2(a0),d1
	lsr.b	#4,d1
	or.b	1(a0),d1
	move.w	d1,(a1)+
	add.l	#3,a0
	sub.w	#1,d0
	bne	cmaploop
	rts

cmapchunk:
	dc.l	0

cmap:	dc.l	color1

color1:	blk.w	16,0

setupcol:
lea	color1,a0
lea	copcol,a1
move.l	#$01800000,d0
move.l	#16,d1

suc1:
move.w	(a0)+,d0
move.l	d0,(a1)+
add.l	#$00020000,d0
sub.w	#1,d1
bne	suc1
rts

Turn72 = $3b000

copywerte:
lea	turn72+[48*160],a0
move.l	a0,a1

copyturn:
move.b	-(a0),(a1)+
cmp.l	#turn72,a0
bne	copyturn
rts

calcnewmod:
lea	$40000,a6
lea	adresses,a5
lea	mod1table,a0	; Order of rasters
move.l	#160,d7		; 72 lines
lea	coppar,a2
move.w	#$28,d4

move.w	(a0)+,d0	; Get Line No
mulu	#40*4,d0	; multiply by 5 Bitplanes Width 80
add.l	a6,d0		; add Startadress
move.l	d0,d6		; Save Adress

move.l	d0,d1		; Copy Adress
swap	d1
move.w	d1,2(a5)	; High
move.w	d0,6(a5)	; Low
add.w	d4,d0		; Next Line

move.l	d0,d1
swap	d1
move.w	d1,10(a5)
move.w	d0,14(a5)
add.w	d4,d0

move.l	d0,d1
swap	d1
move.w	d1,18(a5)
move.w	d0,22(a5)
add.w	d4,d0

move.l	d0,d1
swap	d1
move.w	d1,26(a5)
move.w	d0,30(a5)

clr.l	d0
move.l	#160,d4

cnmloop:
move.w	(a0)+,d1	; Get next

gtnxt:
mulu	d4,d1
add.l	a6,d1
move.l	d1,d2
sub.l	#40,d1
sub.l	d6,d1
move.w	d1,14(a2)
move.w	d1,10(a2)
move.l	d2,d6

add.l	#16,a2
sub.w	#1,d7
bne	cnmloop
rts

mod1table:
dc.w	0,1,2,3,4,5,6,7,8,9
dc.w	10,11,12,13,14,15,16,17,18,19
dc.w	20,21,22,23,24,25,26,27,28,29
dc.w	30,31,32,33,34,35,36,37,38,39
dc.w	40,41,42,43,44,45,46,47,48,49
dc.w	50,51,52,53,54,55,56,57,58,59
dc.w	60,61,62,63,64,65,66,67,68,69
dc.w	70,71,72,73,74,75,76,77,78,79
dc.w	80,81,82,83,84,85,86,87,88,89
dc.w	90,91,92,93,94,95,96,97,98,99
dc.w	100,101,102,103,104,105,106,107,108,109
dc.w	110,111,112,113,114,115,116,117,118,119
dc.w	120,121,122,123,124,125,126,127,128,129
dc.w	130,131,132,133,134,135,136,137,138,139
dc.w	140,141,142,143,144,145,146,147,148,149
dc.w	150,151,152,153,154,155,156,157,158,159
dc.w	160,161,162,163,164,165,166,167,168,169
dc.w	170,171,172,173,174,175,176,177,178,179
dc.w	180,181,182,183,184,185,186,187,188,189
dc.w	190,191,192,193,194,195,196,197,198,199

ti_adr:	dc.l	turn72
ti_mo:	dc.w	0
ti_no:	dc.w	0

turnit:
lea	mod1table,a0
move.l	ti_adr,a1
clr.l	d0
move.l	#159,d6
move.w	ti_mo,d5
bmi	tunit

turnit2:
move.b	(a1)+,d0
move.w	d0,(a0)+
dbf	d6,turnit2
add.w	#1,ti_no
cmp.w	#48,ti_no
bne	turnit3
sub.l	#160,a1
move.w	#$ffff,ti_mo

turnit3:
move.l	a1,ti_adr
move.w	#1,d0
rts

tunit:

tunit2:
move.b	(a1)+,d0
move.w	d0,(a0)+
dbf	d6,tunit2
sub.l	#160*2,a1
sub.w	#1,ti_no
bne	tunit3
add.l	#160,a1
move.w	#1,ti_mo
move.l	a1,ti_adr
add.w	#1,ti_count
cmp.w	#3,ti_count
bne	tunit3
clr.l	d0
rts

tunit3:
move.l	a1,ti_adr
move.w	#1,d0
rts

ti_count:	dc.w	0

check:
move.l	adrzeiger,a0
jump:
move.b	(a0)+,d0
cmp.b	#1,d0
bne	check2
move.l	#$40000,calcnewmod+2
check2:
cmp.b	#2,d0
bne	checkff
move.l	#$47000,calcnewmod+2
checkff:
cmp.b	#$ff,d0
bne	exitcheck
lea	adrd,a0
bra	jump
exitcheck:
move.l	a0,adrzeiger
rts
adrd:
blk.b	48,1
blk.b	48,2
blk.b	48,2
blk.b	48,1
dc.b	$ff
even
adrzeiger:	dc.l	adrd
scroll:
bsr	bltwait
move.l	#$dff000,a4
move.l	#$55182,$50(a4)
move.l	#$55180,$54(a4)
move.w	#0,$64(a4)
move.w	#0,$66(a4)
move.w	#$ffff,$44(a4)
move.w	#0,$46(a4)
move.l	#$e9f00000,$40(a4)
move.w	#$1818,$58(a4)
bsr	replay_muzak
wartemal:
btst	#6,$dff002
bne	wartemal
rts
getchar:
move.l	textzeiger,a0
move.b	(a0)+,d0
bne	contchar
lea	text,a0
move.b	(a0)+,d0
contchar:
move.l	a0,textzeiger
lea	ascii,a0
move.l	a0,a1
notrchar:
cmp.b	(a0)+,d0
bne	notrchar
sub.l	#1,a0
sub.l	a1,a0
clr.l	d1
move.l	a0,d1
cmp.l	#10,d1
bcs	mi10
cmp.l	#20,d1
bcs	mi20
cmp.l	#30,d1
bcs	mi30
cmp.l	#40,d1
bcs	mi40
cmp.l	#50,d1
bcs	mi50
bra	return
mi50:
sub.l	#40,d1
add.l	#$a00,d1
bra	mi10
mi40:
sub.l	#30,d1
add.l	#$780,d1
bra	mi10
mi30:
sub.l	#20,d1
add.l	#$500,d1
bra	mi10
mi20:
sub.l	#10,d1
add.l	#$280,d1
mi10:
mulu	#4,d1
move.l	#$50000,d2
add.l	d1,d2

move.l	d2,$dff050
move.l	#$55180+$2c,$dff054
move.w	#36,$dff064
move.w	#44,$dff066
move.l	#$ffffffff,$dff044
move.l	#$09f00000,$dff040
move.w	#$1002,$dff058
ratemal:
btst	#6,$dff002
bne	ratemal
return:
rts
shift:	dc.w	16
ascii:;  123456789012345678901234567890123456789
dc.b	"abcdefghijklmnopqrstuvwxyz0123456789.:,^*!? "
text:
dc.b	"sargon is proud to present you our megademo...   "
dc.b	"this part was done by btc with help from danny   "
dc.b	"this megademo was spreaded at the wow copy party "
dc.b	"in aachen ...    "
dc.b	"do you think this scroll is very lame ??? mark said to me "
dc.b	"that i shouldn*t make this scroller faster ...   "
dc.b	"this is a very short text ...  credits go to : beastie boys "
dc.b	"for their great sound called slowly raising ...     "
dc.b	"gfx and logo by mbytes ...     coding by btc with some help "
dc.b	"from danny ...     charsets by phalanx and red sector inc "
dc.b	"     i will stop now because of the speed ...   "
dc.b	"   sargon is looking for new members ....     "
dc.b	0
even
textzeiger:
dc.l	text

adres:	dc.l	$57182
copyscroll:
move.l	#$ffffffff,$dff044
;move.w	#$2e,$dff066
;move.w	#$2e,$dff064
;move.w	#$2e,$dff062
move.w	#$2e,d0
move.w	d0,$dff066
move.w	d0,$dff064
move.w	d0,$dff062

move.l	adres,a0
move.l	#$55184,a1
lea	sinusdat,a3
move.w	(a3),d0
add.w	d0,adres+2
moveq	#19,d1
move.w	#$1001,d4
move.w	#$180,d3
move.l	#$dff000,a4

cloop2:
sub.w	d3,a0
sub.w	d3,a1
bsr	bltwait
move.l	a0,$54(a4)
move.l	a1,$50(a4)
move.w	#$f000,$44(a4)
move.l	#$09f00000,$40(a4)
move.w	#$1401,$58(a4)
add.w	d3,a0
add.w	d3,a1
add.w	(a3)+,a0

bsr	bltwait
move.l	a0,$54(a4)
move.l	a1,$50(a4)
move.l	a0,$4c(a4)
move.w	#$0f00,$44(a4)
move.l	#$0dfc0000,$40(a4)
move.w	d4,$58(a4)
add.w	(a3)+,a0

bsr	bltwait
move.l	a0,$54(a4)
move.l	a1,$50(a4)
move.l	a0,$4c(a4)
move.w	#$00f0,$44(a4)
move.w	d4,$58(a4)
add.w	(a3)+,a0

bsr	bltwait
move.l	a0,$54(a4)
move.l	a1,$50(a4)
move.l	a0,$4c(a4)
move.w	#$000f,$44(a4)
move.w	d4,$58(a4)
add.w	(a3)+,a0

add.w	#2,a0
add.w	#2,a1
dbf	d1,cloop2
rts

bltwait:
btst	#6,$dff002
bne	bltwait
rts

sinusdat:
blk.w	4,0
dc.w	96,0,0,96,0,0,96,0,96,0,96,0,96,0,96,96,0,96,96,0,96,96,96
dc.w	0,96,96,96,96,96,0,96,96,96,96,96,96,96,96,96,96,96
dc.w	96,0,96,96,96,96,96,96,96,96,96,96,96,0,96,96,96,96
dc.w	96,0,96,96,96,0,96,96,0,96,96,0,96,0,96,0,96,0,96,0,0
dc.w	96,0,0,96,0,0,0,0,0,0,0,0,96,-96
dc.w	0,0,0,0,0,0,0,0,-96,0,0,-96,0,0,-96,0,-96,0,-96,0,-96
dc.w	0,-96,-96,0,-96,-96,0,-96,-96,-96,0,-96,-96,-96,-96,-96,0
dc.w	-96,-96,-96,-96,-96,-96,-96,-96,-96,-96,-96,0,-96
dc.w	-96,-96,-96,-96,-96,-96,-96,-96,-96,-96,-96,0,-96,-96
dc.w	-96,-96,-96,0,-96,-96,-96,0,-96,-96,0,-96,-96,0,-96
dc.w	0,-96,0,-96,0,-96,0,0,-96,0,0,-96
blk.w	4,0
lsinus:

scrolldat:
lea	sinusdat,a0
lea	lsinus-2,a1
move.w	(a0),d0
scrollweiter:
move.w	2(a0),(a0)
addq.l	#2,a0
cmp.l	a0,a1
bne.s	scrollweiter
move.w	d0,(a1)
rts

writes1:
;add.l	#10*16*16,a0
moveq	#13,d4
lea	c1,a1
lea	coppar+[10*16*16],a0
not14:
moveq	#8,d0
contc1:
move.w	(a1)+,6(a0)
add.l	#16,a0
subq.w	#1,d0
bne	contc1
sub.l	#14,a1
subq.w	#1,d4
bne	not14
rts
c1:
dc.w	0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,13,12,11,10
dc.w	9,8,7,6,5,4,3,2,1
dc.w	0,0,0,0,0,0,0,0,0,0
dc.w	$100,$200,$300,$400,$500,$600,$700,$800,$900,$a00
dc.w	$b00,$c00,$d00,$e00,$f00,$e00,$d00,$c00,$b00,$a00,$900
dc.w	$800,$700,$600,$500,$400,$300,$200,$100
dc.w	0,0,0,0,0,0,0,0,0
lc1:
dc.w	0

blk.w	10,0

scrollc1:
lea	c1,a0
lea	lc1,a1
move.w	(a0),d0
scrollagain1:
move.w	2(a0),(a0)
addq.l	#2,a0
cmp.l	a0,a1
bne	scrollagain1
move.w	d0,(a1)
rts

start_muzak:
	move.l	#data,muzakoffset	;** get offset

init0:	move.l	muzakoffset,a0		;** get highest used pattern
	add.l	#472,a0
	move.l	#$80,d0
	clr.l	d1
init1:	move.l	d1,d2
	subq.w	#1,d0
init2:	move.b	(a0)+,d1
	cmp.b	d2,d1
	bgt.s	init1
	dbf	d0,init2
	addq.b	#1,d2

init3:	move.l	muzakoffset,a0		;** calc samplepointers
	lea	pointers,a1
	mulu	#1024,d2
	add.l	#600,d2
	add.l	a0,d2
	move.l	#15-1,d0
init4:	move.l	d2,(a1)+
	clr.l	d1
	move.w	42(a0),d1
	lsl.l	#1,d1
	add.l	d1,d2
	add.l	#30,a0
	dbf	d0,init4

init5:	move.w	#$0,$dff0a8		;** clear used values
	move.w	#$0,$dff0b8
	move.w	#$0,$dff0c8
	move.w	#$0,$dff0d8
	clr.w	timpos
	clr.l	trkpos
	clr.l	patpos

init6:	move.l	muzakoffset,a0		;** initialize timer irq
	move.b	470(a0),numpat+1	;number of patterns
	move.l	#240,d0
	sub.b	471(a0),d0
	mulu	#122,d0
	move.b	#$0,$bfde00
	move.b	d0,$bfd400
	lsr.w	#8,d0
	move.b	d0,$bfd500
	rts

stop_muzak:
	move.w	#$0,$dff0a8
	move.w	#$0,$dff0b8
	move.w	#$0,$dff0c8
	move.w	#$0,$dff0d8
	move.w	#$f,$dff096
	rts


replay_muzak:
	addq.w	#1,timpos
speed:	cmp.w	#6,timpos
	beq	replaystep

chaneleffects:				;** seek effects
	lea	datach0,a6
	tst.b	3(a6)
	beq.s	ceff1
	lea	$dff0a0,a5
	bsr.s	ceff5
ceff1:	lea	datach1,a6
	tst.b	3(a6)
	beq.s	ceff2
	lea	$dff0b0,a5
	bsr.s	ceff5
ceff2:	lea	datach2,a6
	tst.b	3(a6)
	beq.s	ceff3
	lea	$dff0c0,a5
	bsr.s	ceff5
ceff3:	lea	datach3,a6
	tst.b	3(a6)
	beq.s	ceff4
	lea	$dff0d0,a5
	bsr.s	ceff5
ceff4:	rts

ceff5:	move.b	2(a6),d0		;room for some more
	and.b	#$0f,d0			;implementations below
	tst.b	d0
	beq.s	arpreggiato
	cmp.b	#1,d0
	beq	pitchup
	cmp.b	#2,d0
	beq	pitchdown
	cmp.b	#12,d0
	beq	setvol
	cmp.b	#14,d0
	beq	setfilt
	cmp.b	#15,d0
	beq	setspeed
	rts

arpreggiato:				;** spread by time
	cmp.w	#1,timpos
	beq.s	arp1
	cmp.w	#2,timpos
	beq.s	arp2
	cmp.w	#3,timpos
	beq.s	arp3
	cmp.w	#4,timpos
	beq.s	arp1
	cmp.w	#5,timpos
	beq.s	arp2
	rts

arp1:	clr.l	d0			;** get higher note-values
	move.b	3(a6),d0		;   or play original
	lsr.b	#4,d0
	bra.s	arp4
arp2:	clr.l	d0
	move.b	3(a6),d0
	and.b	#$0f,d0
	bra.s	arp4
arp3:	move.w	16(a6),d2
	bra.s	arp6
arp4:	lsl.w	#1,d0
	clr.l	d1
	move.w	16(a6),d1
	lea	notetable,a0
arp5:	move.w	(a0,d0.w),d2
	cmp.w	(a0),d1
	beq.s	arp6
	addq.l	#2,a0
	bra.s	arp5
arp6:	move.w	d2,6(a5)
	rts

pitchdown:
	bsr	newrou
	clr.l	d0
	move.b	3(a6),d0
	and.b	#$0f,d0
	add.w	d0,(a4)
	cmp.w	#$358,(a4)
	bmi.s	ok1
	move.w	#$358,(a4)
ok1:	move.w	(a4),6(a5)
	rts

pitchup:bsr	newrou
	clr.l	d0
	move.b	3(a6),d0
	and.b	#$0f,d0
	sub.w	d0,(a4)
	cmp.w	#$71,(a4)
	bpl.s	ok2
	move.w	#$71,(a4)
ok2:	move.w	(a4),6(a5)
	rts

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

setfilt:move.b	3(a6),d0
	and.b	#$01,d0
	asl.b	#$01,d0
	and.b	#$fd,$bfe001
	or.b	d0,$bfe001
	rts

setspeed:
	clr.l	d0
	move.b	3(a6),d0
	and.b	#$0f,d0
	move.w	d0,speed+2
	rts

newrou:	cmp.l	#datach0,a6
	bne.s	next1
	lea	voi1,a4
	rts
next1:	cmp.l	#datach1,a6
	bne.s	next2
	lea	voi2,a4
	rts
next2:	cmp.l	#datach2,a6
	bne.s	next3
	lea	voi3,a4
	rts
next3:	lea	voi4,a4
	rts

replaystep:				;** work next pattern-step
	clr.w	timpos
	move.l	muzakoffset,a0
	move.l	a0,a3
	add.l	#12,a3			;ptr to soundprefs
	move.l	a0,a2
	add.l	#472,a2			;ptr to pattern-table
	add.l	#600,a0			;ptr to first pattern
	clr.l	d1
	move.l	trkpos,d0		;get ptr to current pattern
	move.b	(a2,d0),d1
	mulu	#1024,d1
	add.l	patpos,d1		;get ptr to current step
	clr.w	enbits
	lea	$dff0a0,a5		;chanel 0
	lea	datach0,a6
	bsr	chanelhandler
	lea	$dff0b0,a5		;chanel 1
	lea	datach1,a6
	bsr	chanelhandler
	lea	$dff0c0,a5		;chanel 2
	lea	datach2,a6
	bsr	chanelhandler
	lea	$dff0d0,a5		;chanel 3
	lea	datach3,a6
	bsr	chanelhandler
	move.l	#400,d0			;** wait a while and set len
rep1:	dbf	d0,rep1			;   of oneshot to 1 word
	move.l	#$8000,d0
	or.w	enbits,d0
	move.w	d0,$dff096
	cmp.w	#1,datach0+14
	bne.s	rep2
	clr.w	datach0+14
	move.w	#1,$dff0a4
rep2:	cmp.w	#1,datach1+14
	bne.s	rep3
	clr.w	datach1+14
	move.w	#1,$dff0b4
rep3:	cmp.w	#1,datach2+14
	bne.s	rep4
	clr.w	datach2+14
	move.w	#1,$dff0c4
rep4:	cmp.w	#1,datach3+14
	bne.s	rep5
	clr.w	datach3+14
	move.w	#1,$dff0d4

rep5:	add.l	#16,patpos		;next step
	cmp.l	#64*16,patpos		;pattern finished ?
	bne	rep6
	clr.l	patpos
	addq.l	#1,trkpos		;next pattern in table
	clr.l	d0
	move.w	numpat,d0
	cmp.l	trkpos,d0		;song finished ?
	bne	rep6
	clr.l	trkpos
rep6:	rts

chanelhandler:
	move.l	(a0,d1.l),(a6)		;get period & action-word
	addq.l	#4,d1			;point to next chanel
	clr.l	d2
	move.b	2(a6),d2		;get nibble for soundnumber
	lsr.b	#4,d2
	beq.s	chan2			;no soundchange !
	move.l	d2,d4			;** calc ptr to sample
	lsl.l	#2,d2
	mulu	#30,d4
	lea	pointers-4,a1
	move.l	(a1,d2.l),4(a6)		;store sample-address
	move.w	(a3,d4.l),8(a6)		;store sample-len in words
	move.w	2(a3,d4.l),18(a6)	;store sample-volume

	move.l	d0,-(a7)
	move.b	2(a6),d0
	and.b	#$0f,d0
	cmp.b	#$0c,d0
	bne.s	ok3
	move.b	3(a6),8(a5)
	bra.s	ok4
ok3:	move.w	2(a3,d4.l),8(a5)	;change chanel-volume
ok4:	move.l	(a7)+,d0

	clr.l	d3
	move.w	4(a3,d4),d3		;** calc repeatstart
	add.l	4(a6),d3
	move.l	d3,10(a6)		;store repeatstart
	move.w	6(a3,d4),14(a6)		;store repeatlength
	cmp.w	#1,14(a6)
	beq.s	chan2			;no sustainsound !
	move.l	10(a6),4(a6)		;repstart  = sndstart
	move.w	6(a3,d4),8(a6)		;replength = sndlength
chan2:	cmp.w	#0,(a6)
	beq.s	chan4			;no new note set !
	move.w	22(a6),$dff096		;clear dma
	cmp.w	#0,14(a6)
	bne.s	chan3			;no oneshot-sample
	move.w	#1,14(a6)		;allow resume (later)
chan3:	bsr	newrou
	move.w	(a6),(a4)
	move.w	(a6),16(a6)		;save note for effect
	move.l	4(a6),0(a5)		;set samplestart
	move.w	8(a6),4(a5)		;set samplelength
	move.w	(a6),6(a5)		;set period
	move.w	22(a6),d0
	or.w	d0,enbits		;store dma-bit
	move.w	18(a6),20(a6)		;volume trigger
chan4:	rts

datach0:	dc.w	0,0,0,0,0,0,0,0,0,0,0,1
datach1:	dc.w	0,0,0,0,0,0,0,0,0,0,0,2
datach2:	dc.w	0,0,0,0,0,0,0,0,0,0,0,4
datach3:	dc.w	0,0,0,0,0,0,0,0,0,0,0,8
voi1:		dc.w	0
voi2:		dc.w	0
voi3:		dc.w	0
voi4:		dc.w	0
pointers:	dc.l	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
notetable:	dc.w	856,808,762,720,678,640,604,570
		dc.w	538,508,480,453,428,404,381,360
		dc.w	339,320,302,285,269,254,240,226  
		dc.w	214,202,190,180,170,160,151,143
		dc.w	135,127,120,113,000
muzakoffset:	dc.l	0
lev6save:	dc.l	0
trkpos:		dc.l	0
patpos:		dc.l	0
numpat:		dc.w	0
enbits:		dc.w	0
timpos:		dc.w	0
data = $5a000
