
; RI   Font3           ==> font 
; RI   First_one_logo  ==> logo

;org	$6a000
;load	$6a000

begin:
move.l	$4,a6
jsr	-132(a6)

move.b	#$ff,$bfd100
move.b	#$87,$bfd100

lea	gfxname,a1
jsr	-408(a6)
move.l	d0,gfxbase

lea	$70000,a0
lea	$80000,a1

clloop:
clr.l	(a0)+
cmp.l	a0,a1
bne	clloop

lea	logo,a0
lea	$70000,a1
bsr	unpack
bsr	setupcol

lea	font,a0
lea	$77000,a1
bsr	unpack

bsr	setcop

bsr     mt_init

move.l  #sprite,d0
move.w  d0,sprite0+6
swap    d0
move.w  d0,sprite0+2
bsr     sterne

move.l	$6c,oldirq+2

move.l	gfxbase,a0
move.l	38(a0),oldclist

move.w	#$8180,$dff096
move.l	#newclist,$dff080
move.w	#0,$dff088

move.l	#newirq,$6c

wait:   
move.b  $dff006,d0
cmp.b   #$ff,d0
bne     wait
bsr     stern_move
btst	#6,$bfe001
bne	wait
eor.b   #02,$bfe001
move.l	oldirq+2,$6c
move.l	oldclist,$dff080
move.w	#0,$dff088

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

move.l	$4,a6
move.l	gfxbase,a1
jsr	-414(a6)
jsr	-138(a6)
rts

nextchr:
move.w	#26,newchar
move.l	textzeiger,a6

nextchr1:
move.b	(a6)+,d0
bne	nextchr2
move.l	#text,a6
bra	nextchr1

nextchr2:
cmp.b	#'+',d0
bne	nextchr3
move.b	(a6)+,d0
sub.b	#'0',d0
move.b	d0,xshft+1
bra	nextchr1

nextchr3:
move.l	#38,d1
lea	asc,a0

lprint:
cmp.b	(a0,d1.l),d0
beq	okprint
sub.l	#1,d1
bpl	lprint
add.l	#1,a6
move.l	a6,textzeiger
rts

okprint:
lsl.l	#2,d1
add.l	#atable,d1
move.l	d1,a2
move.l	(a2),a0
lea	$7b028,a1

move.l	a6,textzeiger
return:
move.l	#32,d0

loopset:
move.b	(a0),(a1)
move.b	1(a0),1(a1)
move.b	2(a0),2(a1)
clr.b	3(a1)
move.b	$28(a0),$2c(a1)
move.b	$29(a0),$2d(a1)
move.b	$2a(a0),$2e(a1)
clr.b	$2f(a1)
move.b	$50(a0),$58(a1)
move.b	$51(a0),$59(a1)
move.b	$52(a0),$5a(a1)
clr.b	$5b(a1)
add.l	#$78,a0
add.l	#$84,a1
sub.w	#1,d0
bne	loopset
rts

a = $77000
b = $77000 + [$28*3*32]
c = $77000 + [$28*3*64]
d = $77000 + [$28*3*96]

asc:	dc.b	"abcdefghijklmnopqrstuvwxyz0123456789!- "

even
atable:	dc.l	a,a+3,a+6,a+9,a+12,a+15,a+18,a+21,a+24,a+27
	dc.l	a+30,a+33,a+36
	dc.l	b,b+3,b+6,b+9,b+12,b+15,b+18,b+21,b+24,b+27
	dc.l	b+30,b+33,b+36
	dc.l	c,c+3,c+6,c+9,c+12,c+15,c+18,c+21,c+24,c+27
	dc.l	c+30,c+33,c+36

inhalt:	dc.l $80000000,$00008000,$00008000,$80008000
	dc.l $80008000

speed:	dc.b 2,4,1,3,5,3,2,1,3,2,5,1,4,3,4,3,4,1,3,2,5,4,3,2,5
	dc.b 2,3,1,5,4,1,4,2,3,1,4,3,2,5,1,3,2,4,5,1,2,4,5,3,1
	dc.b 4,3,5,1,2,1,4,4,5,3,2,4,1,5,2,4,2,5,3,5,3,4,3,1,4
	dc.b 4,5,3,2,4,1,3,4,1,3,2,5,4,1,3,4,2,3,1,4,3,4,1,2,5
	dc.b 3,5,1,4,3,5,2,4,2,5,1,4,2,3,4,1,3,5,2,4,3,2,1,5,3
	dc.b 4,3,5,1,2,4,1


xpos:	dc.b $1e,$4f,$ab,$dd,$1b,$bb,$6a,$f3,$88,$ab,$f3,$73
	dc.b $27,$8a,$0e,$22,$bc,$3b,$20,$0e,$91,$14,$59,$f0
	dc.b $d5,$79,$b0,$32,$d3,$55,$b1,$95,$89,$5b,$c3,$99
	dc.b $01,$30,$d4,$c3,$b9,$a1,$7e,$91,$09,$4e,$70,$a0
	dc.b $c0,$5b,$1a,$98,$81,$d3,$22,$48,$91,$c5,$ff,$12
	dc.b $45,$95,$a1,$39,$e0,$84,$05,$b4,$af,$76,$72,$19
	dc.b $49,$58,$c0,$d2,$e2,$92,$19,$f5,$06,$35,$a8,$d3
	dc.b $89,$7e,$29,$90,$a4,$12,$b9,$c0,$e3,$88,$41,$2e
	dc.b $59,$12,$f0,$c3,$6e,$91,$2c,$55,$79,$1c,$01,$96
	dc.b $a5,$c1,$d9,$e7,$14,$86,$10,$99,$d3,$69,$a3,$c8
	dc.b $93,$12,$f5,$28,$c2,$39,$92,$a0,$38,$bb,$e1,$e3


textzeiger:	dc.l	text

font:           blk.b   7194,0
logo:           blk.b   12042,0
sprite:         blk.l   265,0

clear1:
btst	#6,$dff002
bne	clear1
rts

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


move.l	#$7b000,d0
bsr	scroll
tst.w	newchar
bpl	irq1
;eor.b #02,$bfe001
bsr	nextchr
;eor.b #02,$bfe001
irq1:

endirq:
bsr     mt_music
movem.l	(sp)+,d0-d7/a0-a6
oldirq:
jmp	$000000

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
bchg #1,$bfe001
rts

newchar:dc.w	24
xshft:	dc.w	1

scroll:	tst.w	xshft
	bne	scroll2
	rts

scroll2:move.w	xshft,d1
	sub.w	d1,newchar
	move.l	d0,$dff054
	add.l	#2,d0
	move.l	d0,$dff050
	move.w	#0,$dff064
	move.w	#0,$dff066
	move.l	#$ffffffff,$dff044
	move.w	#16,d1
	sub.w	xshft,d1
	lsl.w	#8,d1
	lsl.w	#4,d1
	or.w	#$09f0,d1
	move.w	d1,$dff040
	move.w	#0,$dff042
	move.w	#$1816,$dff058
	bra	clear1

sterne:	clr.l	d0			;Set stars (as Sprite 1, which
	clr.l	d2			; reuses the DMA channel)
	lea	xpos(pc),a0		;table with X-coordinates
	lea	speed(pc),a2		;table with speed/color (1-5)
	lea	sprite(pc),a1		;sprite start (Datalist)
	move.b	#$20,d0			;start at line 32
sternloop:
	clr.l	d1
	lea	inhalt-4(pc),a3		;table with color
	move.b	d0,(a1)+		;set sprite vertikal
	move.b	(a0)+,(a1)+		;set sprite horizontal
	addq.w	#1,d0			;add 1 for V-stop position
	move.b	d0,(a1)+		;set vertikal stop
	move.b	d2,(a1)+		;sprite vert. < or > 255 ??
	move.b	(a2)+,d1
	lsl.w	#2,d1
	add.l	d1,a3
	move.l	(a3),(a1)+		;set color
	addq.w	#1,d0			;next sprite reuse !!
	cmp.w	#$00fe,d0		;until line 254 (then I must
	ble.S	sternloop		; change vertikal bit 8 to 1
	moveq	#6,d2			;<= this is it (Bit8 = 1)
	cmp.w	#$0128,d0		;end in line 296
	bne.S	sternloop
	rts				;all stars are set

stern_move:
	move.w	#131,d0			;move 306 points
	lea	speed(pc),a2		;table with speed (1/5)
	lea	sprite+1(pc),a1		;1. sprite X-position
move_loop:
	move.b	(a1),d1			;sprite X to d1
	move.b	(a2)+,d2		;speed to d2
	add.b	d2,d1			;add d1 to d2 (stars to the
	move.b	d1,(a1)			;              right)
	add.l	#8,a1			;point to next line
	dbf	d0,move_loop		;until all stars are moved
	rts				;end of sprite moving !


newclist:
dc.w	$008e,$2c61,$0090,$2cd1,$0092,$0038,$0094,$00d0
dc.w	$0102,$0000,$0104,$0000,$0108,$0078,$010a,$0078
dc.w	$0100,$4200,$0180,$0000

adr:
dc.w	$00e0,$0007,$00e2,$00,$00e4,$0007,$00e6,$28
dc.w	$00e8,$0007,$00ea,$50,$00ec,$0007,$00ee,$78
sprite0:
dc.w	$120,0,$122,0,$124,0,$126,0,$128,0,$12a,0,$12c,0
dc.w	$12e,0,$130,0,$132,0,$134,0,$136,0,$138,0,$13a,0
dc.w	$13c,0,$13e,0,$1a2,$888,$1a4,$aaa,$1a6,$fff
copcol:
blk.l	16,0
frcol:
blk.w	32,0
dc.w	$d811,$fffe,$180,0,$182,$aaa,$184,$400
dc.w	$186,$004,$188,$040,$18a,$080,$18c,$800,$18e,$008
dc.w	$0100,$0200,$e0,$7,$e2,$b000
dc.w	$e4,$7,$e6,$b02c,$e8,$7,$ea,$b058,$102,0
dc.w	$108,$5c,$10a,$5c
dc.w    $da11,$fffe,$180,0,$0100,$3200
dc.w    $e011,$fffe,$180,$b00
dc.w    $e111,$fffe,$180,$f00
dc.w    $e411,$fffe,$180,$b00
dc.w    $e511,$fffe,$180,$000
dc.w    $e811,$fffe,$180,$00b
dc.w    $e911,$fffe,$180,$00f
dc.w    $ec11,$fffe,$180,$00b
dc.w    $ed11,$fffe,$180,$000
dc.w    $f011,$fffe,$180,$0b0
dc.w    $f111,$fffe,$180,$0f0
dc.w    $f411,$fffe,$180,$0b0
dc.w    $f511,$fffe,$180,$000
end:

oldclist:
dc.l	0
gfxbase:
dc.l	0
gfxname:
dc.b	"graphics.library",0
even

yko:	dc.b	$54,0

setcol:
move.l	a1,a3
add.l	#4,a3
move.w	(a4),2(a3)
rts

setcop:
lea	table,a6
lea	frcol,a2
lea	frcol,a1
move.l	trck1,a4
move.l	#8,d3
nsc:
move.b	(a6)+,d5
add.b	yko,d5
move.b	d5,(a2)+
move.b	#$11,(a2)+
move.w	#$fffe,(a2)+
move.l	#$01020000,(a2)+
bsr	setcol
add.l	#8,a1
add.l	#2,a4
subi.l	#1,d3
bne	nsc
rts

copscroll:
clr.l	d6
move.b	1(a2),d0
add.b	d0,(a2)
bcc	scrl1
add.l	#2,a3
cmp.l	a3,a5
bne	scrl2
lea	track1,a3

scrl2:
move.l	a3,a4
move.l	#7,d2
move.l	a1,a0
add.l	#4,a0

scrl3:
move.w	50(a0),58(a0)
sub.l	#8,a0
sub.l	#1,d2
bne	scrl3
move.l	a3,zwsp
jsr	setcol
move.l	zwsp,a3

scrl1:
clr.l	d0
move.b	(a2),d0
lsr.w	#2,d0
and.w	#$fff8,d0
lea	table,a0
add.l	d0,a0
move.l	#8,d2

scrl4:
move.b	(a0)+,d0
add.b	yko,d0
move.b	d0,(a1)
add.l	#8,a1
sub.l	#1,d2
bne	scrl4
rts

zwsp:	dc.l	0
count1:	dc.b	0,80
trck1:	dc.l	track1
etrck1:	dc.l	etrack1

table:	dc.b 13,21,29,37,45,53,61,69
	dc.b 14,22,30,38,46,54,62,70
	dc.b 15,23,31,39,47,55,63,71
	dc.b 16,24,32,40,48,56,64,72
	dc.b 17,25,33,41,49,57,65,73
	dc.b 18,26,34,42,50,58,66,74
	dc.b 19,27,35,43,51,59,67,75
	dc.b 20,28,36,44,52,60,68,76

track1:	dc.w    0,0,0,0,0,0,0,0 
        dc.w    0,0,0,0,0,0,0,0
        dc.w	$f00,$e00,$d00,$c00,$b00,$a00,$900,$800
	dc.w	$710,$620,$530,$440,$350,$260,$170
	dc.w	$080,$090,$0a0,$0b0,$0c0,$0d0,$0e0,$0f0
	dc.w	$e0,$d0,$c0,$b0,$a0,$90,$80
	dc.w	$71,$62,$53,$44,$35,$26,$17
	dc.w	$008,$009,$00a,$00b,$00c,$00d,$00e,$00f
	dc.w	$00e,$00d,$00c,$00b,$00a,$009,$008
	dc.w	$117,$226,$335,$444,$555,$666,$777
	dc.w	$888,$999,$aaa,$bbb,$ccc,$ddd,$eee,$ddd
	dc.w	$ccc,$bbb,$aaa,$999,$888,$887
	dc.w	$886,$885,$884,$883,$882,$881
	dc.w	$880,$990,$aa0,$bb0,$cc0,$dd0,$ee0,$ff0
	dc.w	$fe0,$fd0,$fc0,$fb1,$fa2,$f93,$f84,$f75
	dc.w	$f66,$f55,$f44,$f33,$f22,$f11
etrack1:
text:	dc.b "+3  howdy!!  this is sigma striking with their first"
        dc.b " intro "
        dc.b "ever on this wonderful machine! release date for this intro"
        dc.b " is the 5th of june 1989"
        dc.b "  first some credits  -  "
        dc.b "coding by me            +1- mastermind -"            
        dc.b "             +3and             +1- mr f -"
        dc.b "             +3all graphics by           "     
        dc.b "  +1- megastar -              "
        dc.b "+3the great music is made by frederic hahn "
        dc.b " megastar composed some music in soundtracker but when"
        dc.b " he was finished after about 5 hours of work his amiga said"
        dc.b " poff and it was gone!!  i was angry  mr f was angry and"
        dc.b " megastar was maaaaaaad as hell!!" 
        dc.b " now i am going to tell you a little about sigmas history!"
        dc.b " sigma was founded by me and megastar about 8 months ago"
        dc.b "  in the beginning we were gigalamers!! we did not know"
        dc.b " anything about the amiga  actually we were lamers until"
        dc.b " my birthday the 14th of march 1989!  at my birthday i got"
        dc.b " the technical reference series and i started to code in"
        dc.b " seka  the result after 3 months spare time coding can"
        dc.b " you see on the screen right now!!!  we did it in a weekend"
        dc.b " when we were gatherd together at my place  we did not get"
        dc.b " to much sleep that weekend i can ensure you that!"
        dc.b "  now to the mezzies - mastermind sends a mezzie to"
        dc.b " striper of horizon -- please send my disks back now!!! --" 
        dc.b " megastar sends mezzies to all musaxers -- we need you "
        dc.b " feel free to contact megastar at            +1roger"
        dc.b " nilsson             skragatan 20            275 36  sjobo"
        dc.b "             sweden              +3now some greetz - special greetz to"
        dc.b "+5            - delta of triax - big bang of air force -"
        dc.b " iceman of oversize - striper of horizon - the taxman of" 
        dc.b " bsc -             bye from sigma"
        dc.b "+9 -------------------------------- ",0

        
; -----------------------------------------------------------------
; ------- Mega fast playroutine for D.O.C-SoundTracker V2.1 -------
; -----------------------------------------------------------------
; ---------- Improved and omptimized by Unknown of D.O.C ----------
; --------------- Based on the playroutine from TJC ---------------
; -----------------------------------------------------------------

mt_init:lea	mt_data(pc),a0
	add.l	#$01d8,a0
	move.l	#$0080,d0
	moveq	#$00,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	mt_data(pc),a0
	lea	mt_sample1(pc),a1
	asl.l	#$08,d2
	asl.l	#$02,d2
	add.l	#$0258,d2
	add.l	a0,d2
	moveq	#$0e,d0
mt_init4:
	move.l	d2,(a1)+
	moveq	#$00,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	#$00,d0
mt_clear:
	move.l	(a0,d0),a1
	clr.l	(a1)
	addq.l	#4,d0
	cmp.l	#$3c,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	mt_data+$1d6,mt_maxpart+1
	rts

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

mt_music:
	addq.l	#1,mt_counter
mt_cool:cmp.l	#6,mt_counter
	bne.s	mt_notsix
	clr.l	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.s	mt_arpegrt
	cmp.b	#1,d0
	beq.s	mt_portup
	cmp.b	#2,d0
	beq.s	mt_portdwn
	rts

mt_portup:
	moveq	#$00,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	#$00,d0
	move.b	3(a6),d0
	add.w	d0,22(a6)
	cmp.w	#$358,22(a6)
	bmi.s	mt_ok2
	move.w	#$358,22(a6)
mt_ok2:	move.w	22(a6),6(a5)
	rts

mt_arpegrt:
	cmp.l	#1,mt_counter
	beq.s	mt_loop2
	cmp.l	#2,mt_counter
	beq.s	mt_loop3
	cmp.l	#3,mt_counter
	beq.s	mt_loop4
	cmp.l	#4,mt_counter
	beq.s	mt_loop2
	cmp.l	#5,mt_counter
	beq.s	mt_loop3
	rts

mt_loop2:
	moveq	#$00,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:
	asl.w	#1,d0
	moveq	#$00,d1
	move.w	16(a6),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	mt_data(pc),a0
	move.l	a0,a3
	add.l	#$0c,a3
	move.l	a0,a2
	add.l	#$1d8,a2
	add.l	#$258,a0
	move.l	mt_partnrplay,d0
	moveq	#$00,d1
	move.b	(a2,d0),d1
	asl.l	#$08,d1
	asl.l	#$02,d1
	add.l	mt_partnote,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	#$008a,d1
mt_loop:dbf	d1,mt_loop
	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,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	#$00,d0
	move.w	mt_maxpart,d0
	move.l	mt_partnrplay,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),(a6)
	addq.l	#4,d1
	moveq	#$00,d2
	move.b	2(a6),d2
	and.b	#$f0,d2
	lsr.b	#4,d2
	tst.b	d2
	beq.s	mt_nosamplechange

	moveq	#$00,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),8(a6)
	move.w	2(a3,d4),18(a6)
	move.w	4(a3,d4),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),8(a6)
	move.w	6(a3,d4),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),14(a6)
	move.w	18(a6),8(a5)
mt_nosamplechange:
	tst.w	(a6)
	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),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	#11,d0
	beq.s	mt_posjmp
	cmp.b	#12,d0
	beq.s	mt_setvol
	cmp.b	#13,d0
	beq.s	mt_break
	cmp.b	#14,d0
	beq.s	mt_setfil
	cmp.b	#15,d0
	beq.s	mt_setspeed
	rts

mt_posjmp:
	not.w	mt_status
	moveq	#$00,d0
	move.b	3(a6),d0
	subq.b	#$01,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	#$00,d0
	move.b	3(a6),d0
	and.b	#$01,d0
	rol.b	#$01,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.l	mt_counter
	move.b	d0,mt_cool+5
mt_back:rts

mt_aud1temp:
	blk.w	10,0
	dc.w	$0001
	blk.w	2,0
mt_aud2temp:
	blk.w	10,0
	dc.w	$0002
	blk.w	2,0
mt_aud3temp:
	blk.w	10,0
	dc.w	$0004
	blk.w	2,0
mt_aud4temp:
	blk.w	10,0
	dc.w	$0008
	blk.w	2,0
mt_partnote:	dc.l	0
mt_partnrplay:	dc.l	0
mt_counter:	dc.l	0
mt_partpoint:	dc.l	0
mt_samples:dc.l	0
mt_sample1:blk.l 15,0
mt_maxpart:dc.w	$0000
mt_dmacon:dc.w	$0000
mt_status:dc.w	$0000

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

mt_data:
blk.b	109226,0
