
	section	justice,code

	move.l	#fella,$80.w
	trap	#0
fella:

	lea	$dff000,a5
	move.w	#$003f,$96(a5)	;TURN OFF DISK & SOUND DMA
	move.w	#$3fff,$9a(a5)	
	move.w	#$81c0,$96(a5)

	lea	bpls,a0
	move.l	#logo,d0
	moveq	#3,d7

blp:	move.w	d0,6(a0)
	swap	d0
	move.w	d0,2(a0)
	swap	d0
	add.l	#60*40,d0
	addq	#8,a0
	dbf	d7,blp
	
	lea	list,a0
	lea	$1e000,a1
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	move.l	(a0)+,(a1)+
	addq	#4,a1
	lea	list2,a0

cplp:	move.l	(a0)+,(a1)+
	cmp.l	#copslut,a0
	bne.s	cplp

	move.l	#$1e010,$dff080
	move.w	#$1234,$dff088
	not.w	$dff088
	
	bsr	spoff

	lea	$1000,a0
	lea	music,a1
	move.l	#(115330+4)/4,d7

lotlop:	move.l	(a1)+,(a0)+
	dbf	d7,lotlop

;----------- INTRO -----------------------------------------------------------
	move.l	#$24000,a3
	move.l	#del2,a0
	move.l	#del1+4,a5
	move.l	#dummy,a6

	bsr	decrunch

	bsr	mt_init

vb:	cmp.b	#$fe,$dff006
	bne.s	vb
vb2:	cmp.b	#$ff,$dff006
	bne.s	vb2
	bchg	#1,mw2
	bne.s	skip
	moveq	#15,d7
	lea	cols,a0
	bsr	fade
skip:	add.w	#1,mw
	cmp.w	#30,mw
	bne.s	vb

	move.l	#interrupt,$6c
	move.w	#$c020,$dff09a
	bsr	cop

	jsr	$24000
;------------ WELCOME ---------------------------------------------------------
	bsr	cop
	move.l	#$20000,a3
	move.l	#del3,a0
	move.l	#del2+4,a5
	move.l	#dummy,a6

	bsr	decrunch

	jsr	$20000

;------------- SYREMOLEKYL + ROTERANDE SCROLL ---------------------------------
	bsr	cop
	move.l	#$20000,a3
	move.l	#del4,a0
	move.l	#del3+4,a5
	move.l	#dummy,a6

	bsr	decrunch

	jsr	$20000
;--------------- CREDIT 1:SASQUATCH -------------------------------------------
	bsr	cop
	move.l	#$20000,a3
	move.l	#del6,a0
	move.l	#del5+4,a5
	move.l	#dummy,a6

	bsr	decrunch

	move.b	#1,d0
	jsr	$20000
;-------------- Z ROTATON + LIGHTVEKTOR ---------------------------------------
	bsr	cop
	move.l	#$20000,a3
	move.l	#del5,a0
	move.l	#del4+4,a5
	move.l	#dummy,a6

	bsr	decrunch

	jsr	$20000
;---------------- CREDIT 2 ----------------------------------------------------
	bsr	cop
	move.l	#$20000,a3
	move.l	#del6,a0
	move.l	#del5+4,a5
	move.l	#dummy,a6

	bsr	decrunch

	move.b	#2,d0
	jsr	$20000
;------------- WRITER 1 -------------------------------------------------------
	bsr	cop
	move.l	#$20000,a3
	move.l	#del10,a0
	move.l	#del9+4,a5
	move.l	#dummy,a6

	bsr	decrunch

	move.b	#1,d0
	jsr	$20000

	bsr	spoff

;--------------- WEIRD VEKTORS ------------------------------------------------
	bsr	cop
	move.l	#$20000,a3
	move.l	#del7,a0
	move.l	#del6+4,a5
	move.l	#dummy,a6

	bsr	decrunch

	jsr	$20000
;-------------------- CREDIT 3 ------------------------------------------------
	bsr	cop
	move.l	#$20000,a3
	move.l	#del6,a0
	move.l	#del5+4,a5
	move.l	#dummy,a6

	bsr	decrunch

	move.b	#3,d0
	jsr	$20000
;---------------- CIRKEL + SINUS ----------------------------------------------
	bsr	cop
	move.l	#$20000,a3
	move.l	#del8,a0
	move.l	#del7+4,a5
	move.l	#dummy,a6

	bsr	decrunch

	jsr	$20000
;------------------ FRAKTAL ---------------------------------------------------
	bsr	cop
	move.l	#$20000,a3
	move.l	#del9,a0
	move.l	#del8+4,a5
	move.l	#dummy,a6

	bsr	decrunch

	jsr	$20000
;------------- WRITER 2 -------------------------------------------------------
	bsr	cop
	move.l	#$20000,a3
	move.l	#del10,a0
	move.l	#del9+4,a5
	move.l	#dummy,a6

	bsr	decrunch

	move.b	#2,d0
	jsr	$20000
;------------------------------------------------------------------------------

slut:	bra.s	slut

dummy:	dc.l	0
mw:	dc.w	0
mw2:	dc.w	0

spoff:
	lea	$dff000,a5
	move.w	#$0020,$96(a5)
	moveq	#7,d7
sdat:	clr.w	$144(a5)
	addq	#8,a5
	dbf	d7,sdat
	rts	

cop:
	move.l	#$1e000,$dff080
	move.w	#$1234,$dff088
	not.w	$dff088
	rts


interrupt:
	btst	#6,$dff01f
	beq.s	ut
	movem.l	d0-d7/a0-a6,-(a7)
	bsr	mt_music
	lea	mwait,a0
	add.l	#1,(a0)
	cmp.l	#1646,(a0)
	beq	set
bk:	movem.l	(a7)+,d0-d7/a0-a6
ut:	move.w	#$0020,$dff09c
	rte
set:	bset	#1,$7fffe
	bra.s	bk


mwait:	dc.l	0

list:	dc.l	$01800000
	dc.l	$01000200
	dc.l	$fffffffe

list2:	
cols:	dc.w	$0180,$0000
	dc.w	$0182,$0DDF
	dc.w	$0184,$0CCE
	dc.w	$0186,$0BBD
	dc.w	$0188,$0AAC
	dc.w	$018A,$099B
	dc.w	$018C,$088A
	dc.w	$018E,$0779
	dc.w	$0190,$0668
	dc.w	$0192,$0557
	dc.w	$0194,$0446
	dc.w	$0196,$0335
	dc.w	$0198,$0224
	dc.w	$019A,$0113
	dc.w	$019C,$0002
	dc.w	$019E,$0000
	dc.l	$01000200
	dc.l	$01080000,$010a0000
	dc.l	$008e007b,$009030cb
	dc.l	$00920038,$009200d0
	dc.l	$01020000
	dc.l	$6001fffe
bpls:	dc.l	$00e00000,$00e20000		
	dc.l	$00e40000,$00e60000		
	dc.l	$00e80000,$00ea0000		
	dc.l	$00ec0000,$00ee0000		
	dc.l	$6101fffe,$01004200
	dc.l	$9e01fffe,$01000200
	dc.l	$fffffffe
copslut:

******************************************************
* DECRUNCH DATA ROUTINE                              *
* a3=Pointer to decrunch adress                      *
* a0=pointer to longword after crunched data         *
* a5=pointer to efficency                            *
* a6=decrunch coloradress                            *
* destroys a0-a6 and d0-d7                           *
******************************************************
Decrunch:
	moveq #3,d6
	moveq #7,d7
	moveq #1,d5
	move.l a3,a2				
	move.l -(a0),d1			
	tst.b d1
	beq.s NoEmptyBits
	bsr.s ReadBit				
	subq.b #1,d1
	lsr.l d1,d5					
NoEmptyBits:
	lsr.l #8,d1
	add.l d1,a3					
LoopCheckCrunch:
	bsr.s ReadBit				
	bcs.s CrunchedBytes
NormalBytes:
	moveq #0,d2
Read2BitsRow:
	moveq #1,d0
	bsr.s ReadD1
	add.w d1,d2
	cmp.w d6,d1
	beq.s Read2BitsRow
ReadNormalByte:
	moveq #7,d0
	bsr.s ReadD1
	move.b d1,-(a3)
	dbf d2,ReadNormalByte
	cmp.l a3,a2
	bcs.s CrunchedBytes
	rts
ReadBit:
	lsr.l #1,d5
	beq.s GetNextLong
	rts
GetNextLong:
	move.l -(a0),d5
	roxr.l #1,d5
	rts
ReadD1sub:
	subq.w #1,d0
ReadD1:
	moveq #0,d1
ReadBits:
	lsr.l #1,d5					
	beq.s GetNext
RotX:
	roxl.l #1,d1
	dbf d0,ReadBits
	rts
GetNext:
	move.l -(a0),d5
	roxr.l #1,d5				
	bra.s RotX
CrunchedBytes:
	moveq #1,d0
	bsr.s ReadD1				
	moveq #0,d0
	move.b 0(a5,d1.w),d0		
	move.w d1,d2				
	cmp.w d6,d2					
	bne.s ReadOffset
	bsr.s ReadBit				
	bcs.s LongBlockOffset
	moveq #7,d0
LongBlockOffset:
	bsr.s ReadD1sub
	move.w d1,d3				
Read3BitsRow:
	moveq #2,d0
	bsr.s ReadD1
	add.w d1,d2					
	cmp.w d7,d1					
	beq.s Read3BitsRow
	bra.s DecrunchBlock
ReadOffset:
	bsr.s ReadD1sub			
	move.w d1,d3				
DecrunchBlock:
	addq.w #1,d2
DecrunchBlockLoop:
	move.b 0(a3,d3.w),-(a3)
	dbf d2,DecrunchBlockLoop
EndOfLoop:
	move.w a3,(a6)
	cmp.l a3,a2
	bcs LoopCheckCrunch
	rts


*********************************************************
* FADE SUBROUTINE: A0=Position in copperlist for colors *
*                  D0=Number of colors to fade          *
*********************************************************


fade:	move.w	2(a0),d1
	move.w	d1,d2
	move.w	d2,d3
	and.w	#$0f00,d1
	and.w	#$00f0,d2
	and.w	#$000f,d3
	cmp.w	#0,d1
	beq.s	nored
	sub.w	#$0100,d1
nored:	cmp.w	#0,d2
	beq.s	nogreen
	sub.w	#$0010,d2
nogreen:cmp.w	#0,d3
	beq.s	noblue
	sub.w	#$0001,d3
noblue:	or.w	d1,d2
	or.w	d2,d3
	move.w	d3,2(a0)
	add.l	#4,a0
	dbf	d0,fade
	rts

;ญญญญญญญญญญญญญญญญญญญญญญญญญญญญญญญญญญญญญญญญ
;ญ     NoisetrackerV2.0 FASTreplay      ญ
;ญ  Uses lev6irq - takes 8 rasterlines  ญ
;ญ Do not disable Master irq in $dff09a ญ
;ญ Used registers: d0-d3/a0-a7|	=INTENA ญ
;ญ  Mahoney & Kaktus - (C) E.A.S. 1990  ญ
;ญญญญญญญญญญญญญญญญญญญญญญญญญญญญญญญญญญญญญญญญ

mt_data=$1000

mt_init:lea	mt_data,a0
	lea	mt_mulu(pc),a1
	move.l	#mt_data+$c,d0
	moveq	#$1f,d1
	moveq	#$1e,d3
mt_lop4:move.l	d0,(a1)+
	add.l	d3,d0
	dbf	d1,mt_lop4

	lea	$3b8(a0),a1
	moveq	#$7f,d0
	moveq	#0,d1
	moveq	#0,d2
mt_lop2:move.b	(a1)+,d1
	cmp.b	d2,d1
	ble.s	mt_lop
	move.l	d1,d2
mt_lop:	dbf	d0,mt_lop2
	addq.w	#1,d2

	asl.l	#8,d2
	asl.l	#2,d2
	lea	4(a1,d2.l),a2
	lea	mt_samplestarts(pc),a1
	add.w	#$2a,a0
	moveq	#$1e,d0
mt_lop3:clr.l	(a2)
	move.l	a2,(a1)+
	moveq	#0,d1
	move.b	d1,2(a0)
	move.w	(a0),d1
	asl.l	#1,d1
	add.l	d1,a2
	add.l	d3,a0
	dbf	d0,mt_lop3

	move.l	$78.w,mt_oldirq-mt_samplestarts-$7c(a1)
	or.b	#2,$bfe001
	move.b	#6,mt_speed-mt_samplestarts-$7c(a1)
	moveq	#0,d0
	lea	$dff000,a0
	move.w	d0,$a8(a0)
	move.w	d0,$b8(a0)
	move.w	d0,$c8(a0)
	move.w	d0,$d8(a0)
	move.b	d0,mt_songpos-mt_samplestarts-$7c(a1)
	move.b	d0,mt_counter-mt_samplestarts-$7c(a1)
	move.w	d0,mt_pattpos-mt_samplestarts-$7c(a1)
	rts


mt_end:	moveq	#0,d0
	lea	$dff000,a0
	move.w	d0,$a8(a0)
	move.w	d0,$b8(a0)
	move.w	d0,$c8(a0)
	move.w	d0,$d8(a0)
	move.w	#$f,$dff096
	rts


mt_music:
	lea	mt_data,a0
	lea	mt_voice1(pc),a4
	addq.b	#1,mt_counter-mt_voice1(a4)
	move.b	mt_counter(pc),d0
	cmp.b	mt_speed(pc),d0
	blt	mt_nonew
	moveq	#0,d0
	move.b	d0,mt_counter-mt_voice1(a4)
	move.w	d0,mt_dmacon-mt_voice1(a4)
	lea	mt_data,a0
	lea	$3b8(a0),a2
	lea	$43c(a0),a0

	moveq	#0,d1
	move.b	mt_songpos(pc),d0
	move.b	(a2,d0.w),d1
	lsl.w	#8,d1
	lsl.w	#2,d1
	add.w	mt_pattpos(pc),d1

	lea	$dff0a0,a5
	lea	mt_samplestarts-4(pc),a1
	lea	mt_playvoice(pc),a6
	jsr	(a6)
	addq.l	#4,d1
	lea	$dff0b0,a5
	lea	mt_voice2(pc),a4
	jsr	(a6)
	addq.l	#4,d1
	lea	$dff0c0,a5
	lea	mt_voice3(pc),a4
	jsr	(a6)
	addq.l	#4,d1
	lea	$dff0d0,a5
	lea	mt_voice4(pc),a4
	jsr	(a6)

	move.w	mt_dmacon(pc),d0
	beq.s	mt_nodma

	lea	$bfd000,a3
	move.b	#$7f,$d00(a3)
	move.w	#$2000,$dff09c
	move.w	#$a000,$dff09a
	move.l	#mt_irq1,$78.w
	moveq	#0,d0
	move.b	d0,$e00(a3)
	move.b	#$a8,$400(a3)
	move.b	d0,$500(a3)
	or.w	#$8000,mt_dmacon-mt_voice4(a4)
	move.b	#$11,$e00(a3)
	move.b	#$81,$d00(a3)

mt_nodma:
	add.w	#$10,mt_pattpos-mt_voice4(a4)
	cmp.w	#$400,mt_pattpos-mt_voice4(a4)
	bne.s	mt_exit
mt_next:clr.w	mt_pattpos-mt_voice4(a4)
	clr.b	mt_break-mt_voice4(a4)
	addq.b	#1,mt_songpos-mt_voice4(a4)
	and.b	#$7f,mt_songpos-mt_voice4(a4)
	move.b	-2(a2),d0
	cmp.b	mt_songpos(pc),d0
	bne.s	mt_exit
	move.b	-1(a2),mt_songpos-mt_voice4(a4)
mt_exit:tst.b	mt_break-mt_voice4(a4)
	bne.s	mt_next
	rts

mt_nonew:
	lea	$dff0a0,a5
	lea	mt_com(pc),a6
	jsr	(a6)
	lea	mt_voice2(pc),a4
	lea	$dff0b0,a5
	jsr	(a6)
	lea	mt_voice3(pc),a4
	lea	$dff0c0,a5
	jsr	(a6)
	lea	mt_voice4(pc),a4
	lea	$dff0d0,a5
	jsr	(a6)
	tst.b	mt_break-mt_voice4(a4)
	bne.s	mt_next
	rts

mt_irq1:tst.b	$bfdd00
	move.w	mt_dmacon(pc),$dff096
	move.l	#mt_irq2,$78.w
	move.w	#$2000,$dff09c
	rte

mt_irq2:tst.b	$bfdd00
	movem.l	a3/a4,-(a7)
	lea	mt_voice1(pc),a4
	lea	$dff000,a3
	move.l	$a(a4),$a0(a3)
	move.w	$e(a4),$a4(a3)
	move.l	$a+$1c(a4),$b0(a3)
	move.w	$e+$1c(a4),$b4(a3)
	move.l	$a+$38(a4),$c0(a3)
	move.w	$e+$38(a4),$c4(a3)
	move.l	$a+$54(a4),$d0(a3)
	move.w	$e+$54(a4),$d4(a3)
	movem.l	(a7)+,a3/a4
	move.b	#0,$bfde00
	move.b	#$7f,$bfdd00
	move.l	mt_oldirq(pc),$78.w
	move.w	#$2000,$dff09c
	move.w	#$2000,$dff09a
	rte

mt_playvoice:
	move.l	(a0,d1.l),(a4)
	moveq	#0,d2
	move.b	2(a4),d2
	lsr.b	#4,d2
	move.b	(a4),d0
	and.b	#$f0,d0
	or.b	d0,d2
	beq	mt_oldinstr

	asl.w	#2,d2
	move.l	(a1,d2.l),4(a4)
	move.l	mt_mulu(pc,d2.w),a3
	move.w	(a3)+,8(a4)
	move.w	(a3)+,$12(a4)
	move.l	4(a4),d0
	moveq	#0,d3
	move.w	(a3)+,d3
	beq	mt_noloop
	asl.w	#1,d3
	add.l	d3,d0
	move.l	d0,$a(a4)
	move.w	-2(a3),d0
	add.w	(a3),d0
	move.w	d0,8(a4)
	bra	mt_hejaSverige

mt_mulu:blk.l	$20,0

mt_noloop:
	add.l	d3,d0
	move.l	d0,$a(a4)
mt_hejaSverige:
	move.w	(a3),$e(a4)
	move.w	$12(a4),8(a5)

mt_oldinstr:
	move.w	(a4),d3
	and.w	#$fff,d3
	beq	mt_com2
	tst.w	8(a4)
	beq.s	mt_stopsound
	move.b	2(a4),d0
	and.b	#$f,d0
	cmp.b	#5,d0
	beq.s	mt_setport
	cmp.b	#3,d0
	beq.s	mt_setport

	move.w	d3,$10(a4)
	move.w	$1a(a4),$dff096
	clr.b	$19(a4)

	move.l	4(a4),(a5)
	move.w	8(a4),4(a5)
	move.w	$10(a4),6(a5)

	move.w	$1a(a4),d0
	or.w	d0,mt_dmacon-mt_playvoice(a6)
	bra	mt_com2

mt_stopsound:
	move.w	$1a(a4),$dff096
	bra	mt_com2

mt_setport:
	move.w	(a4),d2
	and.w	#$fff,d2
	move.w	d2,$16(a4)
	move.w	$10(a4),d0
	clr.b	$14(a4)
	cmp.w	d0,d2
	beq.s	mt_clrport
	bge	mt_com2
	move.b	#1,$14(a4)
	bra	mt_com2
mt_clrport:
	clr.w	$16(a4)
	rts

mt_port:moveq	#0,d0
	move.b	3(a4),d2
	beq.s	mt_port2
	move.b	d2,$15(a4)
	move.b	d0,3(a4)
mt_port2:
	tst.w	$16(a4)
	beq.s	mt_rts
	move.b	$15(a4),d0
	tst.b	$14(a4)
	bne.s	mt_sub
	add.w	d0,$10(a4)
	move.w	$16(a4),d0
	cmp.w	$10(a4),d0
	bgt.s	mt_portok
	move.w	$16(a4),$10(a4)
	clr.w	$16(a4)
mt_portok:
	move.w	$10(a4),6(a5)
mt_rts:	rts

mt_sub:	sub.w	d0,$10(a4)
	move.w	$16(a4),d0
	cmp.w	$10(a4),d0
	blt.s	mt_portok
	move.w	$16(a4),$10(a4)
	clr.w	$16(a4)
	move.w	$10(a4),6(a5)
	rts

mt_sin:
dc.b $00,$18,$31,$4a,$61,$78,$8d,$a1,$b4,$c5,$d4,$e0,$eb,$f4,$fa,$fd
dc.b $ff,$fd,$fa,$f4,$eb,$e0,$d4,$c5,$b4,$a1,$8d,$78,$61,$4a,$31,$18

mt_vib:	move.b	$3(a4),d0
	beq.s	mt_vib2
	move.b	d0,$18(a4)

mt_vib2:move.b	$19(a4),d0
	lsr.w	#2,d0
	and.w	#$1f,d0
	moveq	#0,d2
	move.b	mt_sin(pc,d0.w),d2
	move.b	$18(a4),d0
	and.w	#$f,d0
	mulu	d0,d2
	lsr.w	#7,d2
	move.w	$10(a4),d0
	tst.b	$19(a4)
	bmi.s	mt_vibsub
	add.w	d2,d0
	bra.s	mt_vib3
mt_vibsub:
	sub.w	d2,d0
mt_vib3:move.w	d0,6(a5)
	move.b	$18(a4),d0
	lsr.w	#2,d0
	and.w	#$3c,d0
	add.b	d0,$19(a4)
	rts


mt_arplist:
dc.b 0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1

mt_arp:	moveq	#0,d0
	move.b	mt_counter(pc),d0
	move.b	mt_arplist(pc,d0.w),d0
	beq.s	mt_normper
	cmp.b	#2,d0
	beq.s	mt_arp2
mt_arp1:move.b	3(a4),d0
	lsr.w	#4,d0
	bra.s	mt_arpdo
mt_arp2:move.b	3(a4),d0
	and.w	#$f,d0
mt_arpdo:
	asl.w	#1,d0
	move.w	$10(a4),d1
	lea	mt_periods(pc),a0
mt_arp3:cmp.w	(a0)+,d1
	blt.s	mt_arp3
	move.w	-2(a0,d0.w),6(a5)
	rts

mt_normper:
	move.w	$10(a4),6(a5)
	rts

mt_com:	move.w	2(a4),d0
	and.w	#$fff,d0
	beq.s	mt_normper
	move.b	2(a4),d0
	and.b	#$f,d0
	beq.s	mt_arp
	cmp.b	#6,d0
	beq.s	mt_volvib
	cmp.b	#4,d0
	beq	mt_vib
	cmp.b	#5,d0
	beq.s	mt_volport
	cmp.b	#3,d0
	beq	mt_port
	cmp.b	#1,d0
	beq.s	mt_portup
	cmp.b	#2,d0
	beq.s	mt_portdown
	move.w	$10(a4),6(a5)
	cmp.b	#$a,d0
	beq.s	mt_volslide
	rts

mt_portup:
	moveq	#0,d0
	move.b	3(a4),d0
	sub.w	d0,$10(a4)
	move.w	$10(a4),d0
	cmp.w	#$71,d0
	bpl.s	mt_portup2
	move.w	#$71,$10(a4)
mt_portup2:
	move.w	$10(a4),6(a5)
	rts

mt_portdown:
	moveq	#0,d0
	move.b	3(a4),d0
	add.w	d0,$10(a4)
	move.w	$10(a4),d0
	cmp.w	#$358,d0
	bmi.s	mt_portdown2
	move.w	#$358,$10(a4)
mt_portdown2:
	move.w	$10(a4),6(a5)
	rts

mt_volvib:
	 bsr	mt_vib2
	 bra.s	mt_volslide
mt_volport:
	 bsr	mt_port2

mt_volslide:
	moveq	#0,d0
	move.b	3(a4),d0
	lsr.b	#4,d0
	beq.s	mt_vol3
	add.b	d0,$13(a4)
	cmp.b	#$40,$13(a4)
	bmi.s	mt_vol2
	move.b	#$40,$13(a4)
mt_vol2:move.w	$12(a4),8(a5)
	rts

mt_vol3:move.b	3(a4),d0
	and.b	#$f,d0
	sub.b	d0,$13(a4)
	bpl.s	mt_vol4
	clr.b	$13(a4)
mt_vol4:move.w	$12(a4),8(a5)
	rts

mt_com2:move.b	2(a4),d0
	and.b	#$f,d0
	beq	mt_rts
	cmp.b	#$e,d0
	beq.s	mt_filter
	cmp.b	#$d,d0
	beq.s	mt_pattbreak
	cmp.b	#$b,d0
	beq.s	mt_songjmp
	cmp.b	#$c,d0
	beq.s	mt_setvol
	cmp.b	#$f,d0
	beq.s	mt_setspeed
	rts

mt_filter:
	move.b	3(a4),d0
	and.b	#1,d0
	asl.b	#1,d0
	and.b	#$fd,$bfe001
	or.b	d0,$bfe001
	rts

mt_pattbreak:
	move.b	#1,mt_break-mt_playvoice(a6)
	rts

mt_songjmp:
	move.b	#1,mt_break-mt_playvoice(a6)
	move.b	3(a4),d0
	subq.b	#1,d0
	move.b	d0,mt_songpos-mt_playvoice(a6)
	rts

mt_setvol:
	cmp.b	#$40,3(a4)
	bls.s	mt_sv2
	move.b	#$40,3(a4)
mt_sv2:	moveq	#0,d0
	move.b	3(a4),d0
	move.b	d0,$13(a4)
	move.w	d0,8(a5)
	rts

mt_setspeed:
	moveq	#0,d0
	move.b	3(a4),d0
	cmp.b	#$1f,d0
	bls.s	mt_sp2
	moveq	#$1f,d0
mt_sp2:	tst.w	d0
	bne.s	mt_sp3
	moveq	#1,d0
mt_sp3:	move.b	d0,mt_speed-mt_playvoice(a6)
	rts

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

mt_speed:	dc.b	6
mt_counter:	dc.b	0
mt_pattpos:	dc.w	0
mt_songpos:	dc.b	0
mt_break:	dc.b	0
mt_dmacon:	dc.w	0
mt_samplestarts:blk.l	$1f,0
mt_voice1:	blk.w	13,0
		dc.w	1
mt_voice2:	blk.w	13,0
		dc.w	2
mt_voice3:	blk.w	13,0
		dc.w	4
mt_voice4:	blk.w	13,0
		dc.w	8
mt_oldirq:	dc.l	0


music:	incbin	"df0:mod.treck"
crunch:	incbin	"df1:demo2"
logo:	incbin	'df0:oxlogo'
end:

del1=	crunch
del2=	del1+24172
del3=	del2+6840
del4=	del3+14216
del5=	del4+13720
del6=	del5+8444
del7=	del6+9108
del8=	del7+4312
del9=	del8+7876
del10=	del9+10832
