	section andy,code_c
	opt c-

	incdir	df1:

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

startlist1	equ	38
startlist2	equ	50

T		equ	255
B		equ	254
S		equ	253

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

	MOVE.W	#$0080,$dff096
	move.w	$dff01c,sysint
	or.w	#$c000,sysint
	move.w	#$7fff,$dff09a
	move.w	#$c020,$dff09a
	move.l	$6c,intsave
	clr.w	$dff088
	move.w	#$8480,$dff096	
	bset.b	#1,$bfe001

	move.l	#logo,stor
	move.w	stor,bp1+2
	move.w	stor+2,bp1+6
	add.l	#40*48,stor
	move.w	stor,bp2+2
	move.w	stor+2,bp2+6
	add.l	#40*48,stor
	move.w	stor,bp3+2
	move.w	stor+2,bp3+6
	add.l	#40*48,stor
	move.w	stor,bp4+2
	move.w	stor+2,bp4+6
	add.l	#40*48,stor

	lea	copcol+2,a0
	move.l	#15,d0
	move.l	stor,a1
.lp3:	move.w	(a1)+,(a0)+
	add.l	#2,a0
	dbra	d0,.lp3


* Create copper with dummy colors

	lea	cop,a0
	lea	cop2,a1
	move.l	#$7c35fffe,d0
	move.l	#173,d1
	move.l	#$01800000,d2
poo:	move.l	d0,(a0)+
	move.l	d0,(a1)+

	move.l	#43,d3
poo2:	move.l	d2,(a0)+
	move.l	d2,(a1)+
	dbra	d3,poo2

	add.l	#$01000000,d0
	dbra	d1,poo

* Create buffer and implant colors

	lea	buffer,a0
	lea	cols,a1
	moveq.l	#0,d0		;cols index (0-128).l
	move.l	#349,d1		;counter number vert
	
.lp2:	move.l	#43,d2		;counter number horiz
.lp	move.w	#$0180,(a0)+
	move.w	(a1,d0),(a0)+
	dbra	d2,.lp

	add.l	#2,d0		;next color
	and.l	#$7f,d0		;wrap?

	dbra	d1,.lp2		;another bar?

* Create scroll buffer and implant colors

	lea	scrollbuffer,a0
	moveq.l	#0,d0		;cols index (0-128).l
	move.l	#47,d1		;counter number vert
	
.lp5:	move.l	#43,d2		;counter number horiz
.lp4:	move.w	#$0180,(a0)+
	move.w	#0,(a0)+
	dbra	d2,.lp4

	dbra	d1,.lp5		;another bar?

	jsr	blit2		;clr scroll area in buffer

	jsr	start

	move.l	#newcopper,$dff080
	move.l	#cop,$dff084
	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	gfxbase,a1
	jsr	-414(a6)
	
	jsr	stopmus

	moveq.l	#0,d0

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

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

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

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

sp0:	dc.w	$0120,$0000,$0122,$0000	
	dc.w	$0124,$0000,$0126,$0000	
	dc.w	$0128,$0000,$012a,$0000	
	dc.w	$012c,$0000,$012e,$0000	
	dc.w	$0130,$0000,$0132,$0000	
	dc.w	$0134,$0000,$0136,$0000	
	dc.w	$0138,$0000,$013a,$0000	
	dc.w	$013c,$0000,$013e,$0000	
copcol:	
	dc.w	$0180,$0000
	dc.w	$0182,$0000
	dc.w	$0184,$0000
	dc.w	$0186,$0000
	dc.w	$0188,$0000
	dc.w	$018a,$0000
	dc.w	$018c,$0000
	dc.w	$018e,$0000
	dc.w	$0190,$0000
	dc.w	$0192,$0000
	dc.w	$0194,$0000
	dc.w	$0196,$0000
	dc.w	$0198,$0000
	dc.w	$019a,$0000
	dc.w	$019c,$0000
	dc.w	$019e,$0000

	dc.w	$6c01,$fffe,$0100,$0200

	dc.w	$7801,$fffe,$0180,$0444
	dc.w	$7901,$fffe,$0180,$0888
	dc.w	$7a01,$fffe,$0180,$0ccc
	dc.w	$7b01,$fffe,$0180,$0fff

	dc.w	$008a,$0001
cop:	
	rept	174

	ds.l	45

	endr

	dc.w	$2a01,$fffe,$0180,$0fff
	dc.w	$2b01,$fffe,$0180,$0ccc
	dc.w	$2c01,$fffe,$0180,$0888
	dc.w	$2d01,$fffe,$0180,$0444
	dc.w	$2e01,$fffe,$0180,$0000

	dc.w	$ffff,$fffe
cop2:	
	rept	174

	ds.l	45

	endr

	dc.w	$2a01,$fffe,$0180,$0fff
	dc.w	$2b01,$fffe,$0180,$0ccc
	dc.w	$2c01,$fffe,$0180,$0888
	dc.w	$2d01,$fffe,$0180,$0444
	dc.w	$2e01,$fffe,$0180,$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
count:	dc.l	0
count2:	dc.l	0
count3:	dc.l	240*4
frame:	dc.l	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	#$e800,d0
	bne	task

	;move.w	#$0fff,$dff180

	eor.l	#1,frame

	move.l	#43,d2
	move.l	#0,d3
	move.l	count,count2
	lea	smlcircle,a0
	add.l	count3,a0

	move.w	#$00ac,$dff064	;a mod
	move.w	#$00b0,$dff066	;d mod
	move.w	#$ffff,$dff044	;fw mask
	move.w	#$ffff,$dff046	;lw mask
	move.w	#%0000100111110000,$dff040	;con0
	move.w	#%0000000000000000,$dff042	;con1

	rept	43

	move.l	-(a0),d0
	move.l	d3,d1
	;add.l	#63,d0		;middle
	mulu	#176,d0
	add.l	d1,d0
	jsr	blit
	add.l	#1,count2
	add.l	#4,d3

	endr

	add.l	#1,count
	and.l	#63,count

	add.l	#8,count3
	cmp.l	#480*4,count3
	bne	.lp

	move.l	#240*4,count3

.lp:	
	jsr	blit3			

	jsr	replay

	;move.w	#$0,$dff180

	rts

blit:	
	add.l	#buffer,d0
	tst.l	frame
	beq	.lp2
	add.l	#cop+4,d1
	move.l	#cop,$dff084
	bra	.lp3
.lp2:	add.l	#cop2+4,d1
	move.l	#cop2,$dff084
.lp3:	;move.w	#$0fff,$dff180
	move.l	d0,$dff050	
	move.l	d1,$dff054	
	move.w	#%0010101110000010,$dff058			
	;move.w	#$0000,$dff180
.lp:	;btst	#14,$dff002
	;bne	.lp
	rts
blit2:	
	move.l	#scrollbuffer,d0
	move.l	#buffer+94*176,d1
	;move.w	#$0fff,$dff180
	move.l	d0,$dff050	
	move.l	d1,$dff054	

	move.w	#$0032,$dff064	
	move.w	#$0032,$dff066	
	move.w	#$ffff,$dff044	
	move.w	#$ffff,$dff046	

	move.w	#%0000100111110000,$dff040	
	move.w	#%0000000000000000,$dff042	
	move.w	#%0000110000111111,$dff058	
	;move.w	#$0000,$dff180
.lp:	;btst	#14,$dff002
	;bne	.lp

	move.l	#scrollbuffer+126,d0
	move.l	#buffer+126+94*176,d1
	;move.w	#$0fff,$dff180
	move.l	d0,$dff050	
	move.l	d1,$dff054	

	move.w	#$007e,$dff064	
	move.w	#$007e,$dff066	
	move.w	#$ffff,$dff044	
	move.w	#$ffff,$dff046	

	move.w	#%0000100111110000,$dff040	
	move.w	#%0000000000000000,$dff042	
	move.w	#%0000110000011001,$dff058		
	;move.w	#$0000,$dff180
	;btst	#14,$dff002
	;bne	.lp
	rts

blit3:	
	tst.l	pause
	beq	.lp6
	sub.l	#1,pause
	bra	.lp4
	rts
.lp6:


	move.l	#buffer+94*176+4,d0
	move.l	#buffer+94*176,d1
	;move.w	#$0fff,$dff180
	move.l	d0,$dff050	
	move.l	d1,$dff054	

	move.w	#$0032,$dff064	
	move.w	#$0032,$dff066	
	move.w	#$ffff,$dff044	
	move.w	#$ffff,$dff046	

	move.w	#%0000100111110000,$dff040	
	move.w	#%0000000000000000,$dff042	
	move.w	#%0000110000111111,$dff058	
	;move.w	#$0000,$dff180
.lp:	;btst	#14,$dff002
	;bne	.lp

	move.l	#buffer+126+94*176+4,d0
	move.l	#buffer+126+94*176,d1
	;move.w	#$0fff,$dff180
	move.l	d0,$dff050	
	move.l	d1,$dff054	

	move.w	#$007e,$dff064	
	move.w	#$007e,$dff066	
	move.w	#$ffff,$dff044	
	move.w	#$ffff,$dff046	

	move.w	#%0000100111110000,$dff040	
	move.w	#%0000000000000000,$dff042	
	move.w	#%0000110000011001,$dff058		
	;move.w	#$0000,$dff180
	;btst	#14,$dff002
	;bne	.lp

	cmp.l	#7,chbit
	bne	.lp4
	jsr	getchr

	
.lp4:	tst.l	pause
	beq	.lp5
	;sub.l	#1,pause
	rts
.lp5:

	lea	buffer+94*176,a0
	lea	ch,a1
	add.l	#174,a0
	move.l	#5,d0
	move.l	#0,d2		;row number
	move.l	chbit,d1
.lp2:	btst.b	d1,(a1)+
	beq	.lp3
	
	lea	scrollcol,a2
	add.l	toff,a2
	add.l	d2,a2

	move.w	(a2)+,(a0)
	add.l	#176,a0
	move.w	(a2)+,(a0)
	add.l	#176,a0
	move.w	(a2)+,(a0)
	add.l	#176,a0
	move.w	(a2)+,(a0)
	add.l	#176,a0
	move.w	(a2)+,(a0)
	add.l	#176,a0
	move.w	(a2)+,(a0)
	add.l	#176,a0
	move.w	(a2)+,(a0)
	add.l	#176,a0
	move.w	(a2)+,(a0)
	add.l	#176,a0
	add.l	#16,d2
	dbra	d0,.lp2
	sub.l	#1,chbit
	and.l	#7,chbit
	rts

.lp3:	
	lea	backcol,a2
	add.l	boff,a2
	add.l	d2,a2

	move.w	(a2)+,(a0)
	add.l	#176,a0
	move.w	(a2)+,(a0)
	add.l	#176,a0
	move.w	(a2)+,(a0)
	add.l	#176,a0
	move.w	(a2)+,(a0)
	add.l	#176,a0
	move.w	(a2)+,(a0)
	add.l	#176,a0
	move.w	(a2)+,(a0)
	add.l	#176,a0
	move.w	(a2)+,(a0)
	add.l	#176,a0
	move.w	(a2)+,(a0)
	add.l	#176,a0
	add.l	#16,d2
	dbra	d0,.lp2
	sub.l	#1,chbit
	and.l	#7,chbit
	rts

Getchr:	moveq.l	#0,d0
	lea	mess,a0
	add.l	messpoint,a0
	lea	chars,a1
	move.b	(a0),d0	
	beq	end

	cmp.b	#255,d0
	beq	chtext
	cmp.b	#254,d0
	beq	chback
	cmp.b	#253,d0
	beq	stop
	sub.b	#32,d0

	btst.l	#6,d0
	beq	notlo2


	sub.b	#32,d0
notlo2:	add.l	d0,a1
	
	move.b	(a1),ch
	move.b	66(a1),ch+1
	move.b	132(a1),ch+2
	move.b	198(a1),ch+3
	move.b	264(a1),ch+4
	move.b	330(a1),ch+5
	add.l	#1,messpoint
	rts	
end:	move.l	#0,messpoint
	bra	getchr

chback:	add.l	#2,messpoint
	move.b	(a0)+,d0
	move.b	(a0)+,d0
	mulu	#96,d0
	move.w	d0,boff+2
	bra	getchr

chtext:	add.l	#2,messpoint
	move.b	(a0)+,d0
	move.b	(a0)+,d0
	mulu	#96,d0
	move.w	d0,toff+2
	bra	getchr

stop:	move.l	#120,pause
	add.l	#1,messpoint
	move.l	#0,chbit
	lea	chars,a1
	move.b	(a1),ch
	move.b	66(a1),ch+1
	move.b	132(a1),ch+2
	move.b	198(a1),ch+3
	move.b	264(a1),ch+4
	move.b	330(a1),ch+5
	rts

chars:	incbin	'sstext'
	even

	* Commands
	* t,0-5 text color   grn,red,blu,yell,gy,purp
	* b,0-5 back color   purp,gry,yell,blu,grn,red
	* s pause scroller

mess:	dc.b	B,0,T,0,'      YO,',T,1,' ITS US AGAIN WITH A NEW VERY BRILLIANT COPPER SCROLL,',T,2,' THIS HAS GOTTA BE THE FIRST COPPER SCROLL EVER TRIED...',B,2,' WE CAN EVEN CHANGE THE COLOUR OF THE TEXT AS YOU CAN see',B,1,T,1
	DC.B	' ANYWAY THIS IS MYSTIK TYPING IN THIS SCROLL, ZAG THINKS THIS IS CRAP BUT EVERYTHING HE DOES HE THINKS IS CRAP, BUT WE KNOW ITS NOT!!!   ',T,2,B,2,' WE THINK ITS GREAT.',T,1,B,0,'    LOGO BY ELECTRO AND THE MUSIC IS BY ANIMATE'
	dc.b	t,0,b,0,' THIS IS'
	dc.b	t,1,b,1,' MYSTIK '
	dc.b	t,2,b,2,' HANDING'
	dc.b	t,3,b,3,' THE KEYBOARD OVER TO '
	dc.b	t,4,b,4,' WIZOID!!      ',b,0,t,2,' YOOOOOOOOO  THIS IS THE MIGHTY COOL WIZOID ERE!!  WELL THIS INTRO IS QUITE COOL DON''T YOU THINK...    WELL I THINK I''LL GIVE A FEW PERSONAL GREETS TO:'
	dc.b	t,5,b,5,' MR BIG AND J-DROKK (ANARCHY) KEEP COOL GUYZ AS ALLWAYS!!!    ',T,3,B,3,' STORMGOD AND HAVOK (ECSTASY) YOU ARE SO COOL!!!         POD AND ADS(INNER CITY) KEEP COOL      OHH WELL I''M' 
	DC.B	T,0,B,5,' VERY BORED NOW SO I''LL PASS THE KEYBOARD OVER TO ELECTRO!!!?'
	dc.b 	t,5,b,1,' ELECTRO HERE!  WELL, I HAVEN''T REALLY MUCH TO SAY, SO ILL HEAD'
	dc.b 	' STRAIGHT FOR MY PERSONAL GREETINGS, (IN A-Z ORDER!)...    HEARTY'
	dc.b 	' HANDSHAKES GO OUT TO ALL EXTREMISTS WORLDWIDE, IN PARTICULAR'
	dc.b 	' MYSTIC, OVERKILL, SKEXIS AND WIZOID,    GREETINGS ALSO FLY OVER'
	dc.b 	' TO:    ',T,5,' EZY/ECSTACY, ',T,2,' FENDER/T.H.R., ',B,0,' FROGGY/MERCENERY,'
	dc.b 	T,5,B,2,' JAKE/HACKTRICK, SCARFACE/ADEPT, ',T,3,' THE PRIDE/FLASH PRODUCTION,'
	dc.b 	' VANGUARD/TEAM-X AND LAST BUT NOT LEAST ZAPHOD/AMAZE   ' 
	dc.b 	'    OH WELL THATS ALL FROM ME GUYS...    LATER...   ',B,3,T,0,'  '     
   	DC.B	' OK NOW TIME FOR SOMEONE ELSE TO TYPE SOME SCROLL TEXT IN-----      '
	DC.B	0
	
chbit:	dc.l	7
Boff:	dc.l	0
Toff:	dc.l	0
pause:	dc.l	0
messpoint:
	dc.l	0

ch:	
	dc.b	%01111000
	dc.b	%10000100
	dc.b	%11111100
	dc.b	%10000100
	dc.b	%10000100
	dc.b	%00000000


scrollcol:
	dc.w	$0000,$0010,$0020,$0030,$0040,$0050,$0060,$0070
	dc.w	$0080,$0090,$00a0,$00b0,$00c0,$00d0,$00e0,$00f0
	dc.w	$01f1,$02f2,$03f3,$04f4,$05f5,$06f6,$07f7,$08f8
	dc.w	$08f8,$07f7,$06f6,$05f5,$04f4,$03f3,$02f2,$01f1
	dc.w	$00f0,$00e0,$00d0,$00c0,$00b0,$00a0,$0090,$0080
	dc.w	$0070,$0060,$0050,$0040,$0030,$0020,$0010,$0000

	dc.w	$0000,$0100,$0200,$0300,$0400,$0500,$0600,$0700
	dc.w	$0800,$0900,$0a00,$0b00,$0c00,$0d00,$0e00,$0f00
	dc.w	$0f11,$0f22,$0f33,$0f44,$0f55,$0f66,$0f77,$0f88
	dc.w	$0f88,$0f77,$0f66,$0f55,$0f44,$0f33,$0f22,$0f11
	dc.w	$0f00,$0e00,$0d00,$0c00,$0b00,$0a00,$0900,$0800
	dc.w	$0700,$0600,$0500,$0400,$0300,$0200,$0100,$0000

	dc.w	$0000,$0001,$0002,$0003,$0004,$0005,$0006,$0007
	dc.w	$0008,$0009,$000a,$000b,$000c,$000d,$000e,$000f
	dc.w	$011f,$022f,$033f,$044f,$055f,$066f,$077f,$088f
	dc.w	$088f,$077f,$066f,$055f,$044f,$033f,$022f,$011f
	dc.w	$000f,$000e,$000d,$000c,$000b,$000a,$0009,$0008
	dc.w	$0007,$0006,$0005,$0004,$0003,$0002,$0001,$0000

	dc.w	$0000,$0110,$0220,$0330,$0440,$0550,$0660,$0770
	dc.w	$0880,$0990,$0aa0,$0bb0,$0cc0,$0dd0,$0ee0,$0ff0
	dc.w	$0ff1,$0ff2,$0ff3,$0ff4,$0ff5,$0ff6,$0ff7,$0ff8
	dc.w	$0ff8,$0ff7,$0ff6,$0ff5,$0ff4,$0ff3,$0ff2,$0ff1
	dc.w	$0ff0,$0ee0,$0dd0,$0cc0,$0bb0,$0aa0,$0990,$0880
	dc.w	$0770,$0660,$0550,$0440,$0330,$0220,$0110,$0000

	dc.w	$0000,$0000,$0111,$0111,$0222,$0222,$0333,$0333
	dc.w	$0444,$0444,$0555,$0555,$0666,$0666,$0777,$0777
	dc.w	$0888,$0888,$0999,$0999,$0aaa,$0aaa,$0bbb,$0bbb
	dc.w	$0bbb,$0bbb,$0aaa,$0aaa,$0999,$0999,$0888,$0888
	dc.w	$0777,$0777,$0666,$0666,$0555,$0555,$0444,$0444
	dc.w	$0333,$0333,$0222,$0222,$0111,$0111,$0000,$0000

	dc.w	$0000,$0101,$0202,$0303,$0404,$0505,$0606,$0707
	dc.w	$0808,$0909,$0a0a,$0b0b,$0c0c,$0d0d,$0e0e,$0f0f
	dc.w	$0f1f,$0f2f,$0f3f,$0f4f,$0f5f,$0f6f,$0f7f,$0f8f
	dc.w	$0f8f,$0f7f,$0f6f,$0f5f,$0f4f,$0f3f,$0f2f,$0f1f
	dc.w	$0f0f,$0e0e,$0d0d,$0c0c,$0b0b,$0a0a,$0909,$0808
	dc.w	$0707,$0606,$0505,$0404,$0303,$0202,$0101,$0000


backcol:
	dc.w	$0b0b,$0b0b,$0a0a,$0a0a,$0909,$0909,$0808,$0808
	dc.w	$0707,$0707,$0606,$0606,$0505,$0505,$0404,$0404
	dc.w	$0303,$0303,$0202,$0202,$0101,$0101,$0000,$0000
	dc.w	$0000,$0000,$0101,$0101,$0202,$0202,$0303,$0303
	dc.w	$0404,$0404,$0505,$0505,$0606,$0606,$0707,$0707
	dc.w	$0808,$0808,$0909,$0909,$0a0a,$0a0a,$0b0b,$0b0b

	dc.w	$0bbb,$0bbb,$0aaa,$0aaa,$0999,$0999,$0888,$0888
	dc.w	$0777,$0777,$0666,$0666,$0555,$0555,$0444,$0444
	dc.w	$0333,$0333,$0222,$0222,$0111,$0111,$0000,$0000
	dc.w	$0000,$0000,$0111,$0111,$0222,$0222,$0333,$0333
	dc.w	$0444,$0444,$0555,$0555,$0666,$0666,$0777,$0777
	dc.w	$0888,$0888,$0999,$0999,$0aaa,$0aaa,$0bbb,$0bbb

	dc.w	$0bb0,$0bb0,$0aa0,$0aa0,$0990,$0990,$0880,$0880
	dc.w	$0770,$0770,$0660,$0660,$0550,$0550,$0440,$0440
	dc.w	$0330,$0330,$0220,$0220,$0110,$0110,$0000,$0000
	dc.w	$0000,$0000,$0110,$0110,$0220,$0220,$0330,$0330
	dc.w	$0440,$0440,$0550,$0550,$0660,$0660,$0770,$0770
	dc.w	$0880,$0880,$0990,$0990,$0aa0,$0aa0,$0bb0,$0bb0

	dc.w	$000b,$000b,$000a,$000a,$0009,$0009,$0008,$0008
	dc.w	$0007,$0007,$0006,$0006,$0005,$0005,$0004,$0004
	dc.w	$0003,$0003,$0002,$0002,$0001,$0001,$0000,$0000
	dc.w	$0000,$0000,$0001,$0001,$0002,$0002,$0003,$0003
	dc.w	$0004,$0004,$0005,$0005,$0006,$0006,$0007,$0007
	dc.w	$0008,$0008,$0009,$0009,$000a,$000a,$000b,$000b

	dc.w	$00b0,$00b0,$00a0,$00a0,$0090,$0090,$0080,$0080
	dc.w	$0070,$0070,$0060,$0060,$0050,$0050,$0040,$0040
	dc.w	$0030,$0030,$0020,$0020,$0010,$0010,$0000,$0000
	dc.w	$0000,$0000,$0010,$0010,$0020,$0020,$0030,$0030
	dc.w	$0040,$0040,$0050,$0050,$0060,$0060,$0070,$0070
	dc.w	$0080,$0080,$0090,$0090,$00a0,$00a0,$00b0,$00b0

	dc.w	$0b00,$0b00,$0a00,$0a00,$0900,$0900,$0800,$0800
	dc.w	$0700,$0700,$0600,$0600,$0500,$0500,$0400,$0400
	dc.w	$0300,$0300,$0200,$0200,$0100,$0100,$0000,$0000
	dc.w	$0000,$0000,$0100,$0100,$0200,$0200,$0300,$0300
	dc.w	$0400,$0400,$0500,$0500,$0600,$0600,$0700,$0700
	dc.w	$0800,$0800,$0900,$0900,$0a00,$0a00,$0b00,$0b00




logo:	incbin	'extreme.map'


cols:	dc.w	$0000,$0100,$0200,$0300,$0400,$0500,$0600,$0700
	dc.w	$0800,$0900,$0a00,$0b00,$0c00,$0d00,$0e00,$0f00

	dc.w	$0f10,$0e20,$0d30,$0c40,$0b50,$0a60,$0970,$0880
	dc.w	$0790,$06a0,$05b0,$04c0,$03d0,$02e0,$01f0,$00f0

	dc.w	$00f1,$00e2,$00d3,$00c4,$00b5,$00a6,$0097,$0088
	dc.w	$0079,$006a,$005b,$004c,$003d,$002e,$001f,$000f

	dc.w	$000f,$000e,$000d,$000c,$000b,$000a,$0009,$0008
	dc.w	$0007,$0006,$0005,$0004,$0003,$0002,$0001,$0000

buffer:	
	rept	350
	ds.l	44
	endr

scrollbuffer:	
	rept	48
	ds.l	44
	endr

smlcircle:
	dc.l	59,59,59,59,59,59,59,59,59,59,58,58,58,58
	dc.l	58,57,57,57,56,56,55,55,55,54,54,53,53,52,52,51,51,50,50,49
	dc.l	48,48,47,47,46,45,45,44,43,42,42,41,40,40,39,38,37,37,36,35
	dc.l	34,33,33,32,31,30,30,29,28,27,26,26,25,24,23,23,22,21,20,20
	dc.l	19,18,17,17,16,15,15,14,13,13,12,11,11,10,9,9,8,8,7,7,6,6
	dc.l	5,5,4,4,4,3,3,2,2,2,2,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0
	dc.l	0,0,0,0,0,0,0,0,1,1,1,1,1,2,2,2,3,3,3,4,4,5,5,6,6,7,7
	dc.l	8,8,9,9,10,11,11,12,12,13,14,14,15,16,17,17,18,19,19,20,21
	dc.l	22,22,23,24,25,26,26,27,28,29,29,30,31,32,33,33,34,35,36,36
	dc.l	37,38,39,39,40,41,42,42,43,44,44,45,46,46,47,48,48,49,50,50
	dc.l	51,51,52,52,53,53,54,54,55,55,55,56,56,57,57,57,57,58,58,58
	dc.l	58,59,59,59,59,59,59,59,59,59,59

	dc.l	59,59,59,59,59,59,59,59,59,59,58,58,58,58
	dc.l	58,57,57,57,56,56,55,55,55,54,54,53,53,52,52,51,51,50,50,49
	dc.l	48,48,47,47,46,45,45,44,43,42,42,41,40,40,39,38,37,37,36,35
	dc.l	34,33,33,32,31,30,30,29,28,27,26,26,25,24,23,23,22,21,20,20
	dc.l	19,18,17,17,16,15,15,14,13,13,12,11,11,10,9,9,8,8,7,7,6,6
	dc.l	5,5,4,4,4,3,3,2,2,2,2,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0
	dc.l	0,0,0,0,0,0,0,0,1,1,1,1,1,2,2,2,3,3,3,4,4,5,5,6,6,7,7
	dc.l	8,8,9,9,10,11,11,12,12,13,14,14,15,16,17,17,18,19,19,20,21
	dc.l	22,22,23,24,25,26,26,27,28,29,29,30,31,32,33,33,34,35,36,36
	dc.l	37,38,39,39,40,41,42,42,43,44,44,45,46,46,47,48,48,49,50,50
	dc.l	51,51,52,52,53,53,54,54,55,55,55,56,56,57,57,57,57,58,58,58
	dc.l	58,59,59,59,59,59,59,59,59,59,59


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

; call 'mt_init' to initialize the playroutine

start:	lea	mt_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	mt_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	mt_data+$3b6,mt_maxpart+1
	rts

; call 'mt_end' to switch the sound off

stopmus:
	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	mt_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)
	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
mt_aud2temp:
	dcb.w	10,0
	dc.w	2
	dcb.w	2,0
mt_aud3temp:
	dcb.w	10,0
	dc.w	4
	dcb.w	2,0
mt_aud4temp:
	dcb.w	10,0
	dc.w	8
	dcb.w	2,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

mt_data:	incbin	'df1:modules/mod.track'

