

	Opt	o+,c-

	Include ReeboKVectors:CustomRegisters
	Section	Cube,Code_c

Ciaapra = $BFE001
Disable	    = -120
Enable	    = -126
Startlist   = 38
Speed1		equ	2	;noumber of pixels star one moves per frame
Speed2		equ	2	;noumber of pixels star two moves per frame
Speed3		equ	3	;noumber of pixels star three moves per frame
Speed4		equ	3	;noumber of pixels star four moves per frame
VScrollPause	equ	200	;no. frames vscroll pauses for
ScrollHeight	equ	72	;no. lines to scroll at a time
VScrollPages	equ	3*2880	;no. of page of VScroll Text

	move.l	#$0,$0.w
	Move.l	$4.w,a6
	Jsr	Disable(a6)


	Move.l	#$60000,a0
	Move.w	#$5000,d0
again
	Clr.l	(a0)+
	Dbf	d0,again	
;	Jsr	mt_init
	Jsr	InitStars
	Jsr	InitLogo
	Jsr	InitVScroll
	Move.l	#Showplane,d0
	swap	d0
	Move.w	d0,Sine+2
	swap	d0
	Move.w	d0,Sine+6
	Move.l	#Clstart,Cop1lc
	Clr	Copjmp1

	Move.w	#$84a0,Dmacon
	Lea	Spr3data,a0
	Moveq	#4,d0
Clop
	Clr.l	(a0)
	Addq.l	#8,a0
	Dbf	d0,Clop
T

Wait:	Move.l	$dff004,d2
	And.l	#$0001ff00,d2	
	Cmp.l	#$00000100,d2
	Bne.s	Wait

	Btst	#10,$dff016
	Beq.s	Wait
	Bsr	MoveStars
	Bsr	VScroll
	jsr	scrolly
	Jsr	BlitClear
;	Bsr	mt_music
	Bsr	UpdateLetter

	Btst	#6,Ciaapra
	Bne.s	Wait
;	jsr	mt_end

	Move.l	$4.w,a6
	Move.l	#Grname,a1
	Clr.l	d0
	Jsr	-552(a6)
	Move.l	d0,a4
	Move.l	d0,GrBase
	Move.l	Startlist(a4),Cop1lc
	Clr.w	Copjmp1
	Move.w	#$84a0,Dmacon

	Move.l	$4.w,a6
	Move.l	GrBase,a1
	Jsr	-414(a6)

	Jsr	Enable(a6)
	Clr.l	d0
	Rts


InitVScroll:
	LEA	text(pc),A0
	clr.l	d2
	LEA	$62800,a1
lp1:	clr.l	d0
	move.b	(a0,d2),d0
	sub.b	#32,d0
	mulu	#8,d0
	move.l	d0,a2
	add.l	#chars,a2
	move.b	(a2),(a1)
	move.b	1(a2),40(a1)
	move.b	2(a2),80(a1)
	move.b	3(a2),120(a1)
	move.b	4(a2),160(a1)
	move.b	5(a2),200(a1)
	move.b	6(a2),240(a1)
	move.b	7(a2),280(a1)
	addq.l	#1,a1
	clr.l	d0
	clr.l	d1
	move.w	d2,d0
	move.w	d2,d1
	divu	#40,d0
	mulu	#40,d0
	sub.w	d0,d1
	tst.w	d1
	bne.s	next
	add.l	#280,a1
next:	addq.w	#1,d2
	cmp.w	#40*21,d2
	bne.s	lp1
	rts

UpdateLetter:
	Cmpi.l	#0,(a0)
	Bne.s	NoChange
	Cmpi.b	#0,(a0)
	Cmpi.b	#1,(a0)

NoChange
	Subq.l	#1,(a0)
	Rts

VScroll:
	Lea	ScrollPause,a0
	Cmpi.w	#0,(a0)
	Bne.s	DecPause
	Lea	ScrollCount,a0
	Cmpi.w	#0,(a0)
	Beq.s	InitPause
	Lea	VS1,a0
	Cmpi.w	#$49c0,(a0)
	bne.s	Nxt
	Move.w	#$1cc0,(a0)
Nxt	add.w	#40,(a0)
	Lea	VS2,a0
	Cmpi.w	#$49e8,(a0)
	bne.s	Cont
	Move.w	#$1ce8,(a0)
Cont	add.w	#40,(a0)
	Subq.w	#1,ScrollCount
	rts	

Decpause:
	subq.w	#1,(a0)
	Move.w	#ScrollHeight,ScrollCount
	rts

InitPause:
	move.w	#VScrollPause,ScrollPause
	rts

ScrollPause:
	dc.w	0
ScrollCount:
	dc.w	72
	even

Text:	;	'1234567890123456789009876543210987654321'
	dc.b	'            cc  INNERCITY cc            '
	DC.B	'               THE NEW AGE              '
	DC.B	'                                        '
	DC.B	'    PROUDLY PRESENT A NEW PRODUCTION    '
	DC.B	'                 CALLED                 '
	DC.B	'                                        '
	DC.B	'              VECTOR-SCOPE              '
	DC.B	'                                        '
	DC.B	'                                        '
	DC.B	' CREDITS FOR THIS MEGA NICE DEMO GO TO  '
	DC.B	'                                        ' 
	DC.B	'     CODING..................REEBOK     '
	DC.B	'                                        '
	DC.B	'     GRAPHIC DESIGN...........EDDIE     '
	DC.B	'                                        '
	DC.B	'     MUSIC...................MOZART     '
	DC.B	'                                        '
	DC.B	'                                        ' 
	DC.B	' CREDITS ARE DONE SO HOW ABOUT A BIT OF '
	DC.B	'            VERTICAL SCROLLY            '
	DC.B	'                                        '
	even

InitLogo:
	
	lea	Logo,a0
	move.l	a0,d0
	move.w	d0,Plane1+6
	swap	d0
	move.w	d0,Plane1+2

	lea	Logo,a0
	move.l	a0,d0
	add.w	#$a50,d0
	move.w	d0,Plane2+6
	swap	d0
	move.w	d0,Plane2+2

	lea	Logo,a0
	move.l	a0,d0
	add.w	#$14a0,d0
	move.w	d0,Plane3+6
	swap	d0
	move.w	d0,Plane3+2

	lea	Logo,a0
	move.l	a0,d0
	add.w	#$1ef0,d0
	move.w	d0,Plane4+6
	swap	d0
	move.w	d0,Plane4+2
	rts

InitStars:
	
	lea	sprite1,a0
	move.l	a0,d0
	move.w	d0,spr1+6
	swap	d0
	move.w	d0,spr1+2

	lea	sprite2,a0
	move.l	a0,d0
	move.w	d0,spr2+6
	swap	d0
	move.w	d0,spr2+2

	lea	sprite3,a0
	move.l	a0,d0
	move.w	d0,spr3+6
	swap	d0
	move.w	d0,spr3+2

	lea	sprite4,a0
	move.l	a0,d0
	move.w	d0,spr4+6
	swap	d0
	move.w	d0,spr4+2

	rts

MoveStars:
	movem.l	d0-d7/a0-a6,-(sp)
	lea	Sprite1+1,a1
	lea	Sprite2+1,a2
	lea	Sprite3+1,a3
	lea	Sprite4+1,a4
	moveq.l	#59,d0		;no. of stars in each plane
loop:
	cmpi.b	#$dd,(a1)
	bls.s	a1
	move.b	#$2b,(a1)
a1	cmpi.b	#$2b,(a2)
	bhs.s	a2
	move.b	#$dd,(a2)
a2	cmpi.b	#$dd,(a3)
	bls.s	a3
	move.b	#$2b,(a3)
a3	cmpi.b	#$2b,(a4)
	bhs.s	a4
	move.b	#$dd,(a4)
a4	addq.b	#Speed1,(a1)
	subq.b	#Speed2,(a2)
	addq.b	#Speed3,(a3)
	subq.b	#Speed4,(a4)
	addq.w	#8,a1
	addq.w	#8,a2
	addq.w	#8,a3
	addq.w	#8,a4
	dbf	d0,loop
	movem.l	(sp)+,d0-d7/a0-a6
	rts


Grname:	Dc.b	"graphics.library",0
	Even
GrBase:	Dc.l	0


Clstart:
	dc.w	$1401,$ff00
	dc.w	$0100,$0000
	dc.w	$0102,$0000
	dc.w	$0104,$0064
	dc.w	$0108,$0000
	dc.w	$010a,$0000
	dc.w	$0180,$0000
	dc.w	$008e,$2971
	dc.w	$0090,$29d1
	dc.w	$0092,$0030
	dc.w	$0094,$00d8
Spr1:	dc.w	$0120,$0000,$0122,$0000
Spr2:	dc.w	$0124,$0000,$0126,$0000
Spr3:	dc.w	$0128,$0000,$012a,$0000
Spr4:	dc.w	$012c,$0000,$012e,$0000
Spr5:	dc.w	$0130,$0000,$0132,$0000
Spr6:	dc.w	$0134,$0000,$0136,$0000
Spr7:	dc.w	$0138,$0000,$013a,$0000
Spr8:	dc.w	$013c,$0000,$013e,$0000
Plane1:	dc.w	$00e0,$0006,$00e2,$0000
Plane2:	dc.w	$00e4,$0006,$00e6,$0000
Plane3:	dc.w	$00e8,$0006,$00ea,$0000
Plane4:	dc.w	$00ec,$0006,$00ee,$0000
	;dc.w	$0180,$008c
	dc.w	$0182,$0fff
	dc.w	$0184,$0420
	dc.w	$0186,$0832
	dc.w	$0188,$0943
	dc.w	$018a,$0b42
	dc.w	$018c,$0c65
	dc.w	$018e,$0e87
	dc.w	$0190,$0000
	dc.w	$0192,$0fca
	dc.w	$0194,$0b63
	dc.w	$0196,$0d84
	dc.w	$0198,$0e95
	dc.w	$019a,$0fa4
	dc.w	$019c,$0fb7
	dc.w	$019e,$0000
	dc.w	$01a2,$0333
	dc.w	$01a4,$0777
	dc.w	$01aa,$0bbb
	dc.w	$01ac,$0fff
	dc.w	$2901,$ff00,$0100,$4200
	dc.w	$6401,$ff00,$0100,$0000
	dc.w	$0192,$0a54,$00e0,$0006
	dc.w	$00e2,$0000
	dc.w	$008e,$2c81
	dc.w	$0090,$2cc1
	dc.w	$0100,$1200
sine	dc.w	$00e0,$0000,$00e2,$0000
	dc.w	$e101,$ff00,$0180,$0999
	dc.w	$0100,$0200
	dc.w	$e201,$ff00,$0180,$0333
	dc.w	$e301,$ff00,$0180,$0000
	dc.w	$0182,$0300
	dc.w	$0192,$0a50
	dc.w	$0100,$2600
	dc.w	$0102,$0001
	dc.w	$00e0,$0006,$00e2
VS1:	dc.w	$1cc0
	dc.w	$00e4,$0006,$00e6
VS2:	dc.w	$1ce8
	dc.w	$e401,$ff00,$0182,$0400
	dc.w	$0192,$0b60
	dc.w	$e501,$ff00,$0182,$0500
	dc.w	$0192,$0c71
	dc.w	$e601,$ff00,$0182,$0610
	dc.w	$0192,$0d82
	dc.w	$e601,$ff00,$0182,$0721
	dc.w	$0192,$0e93
	dc.w	$e601,$ff00,$0182,$0832
	dc.w	$0192,$0fa4
	dc.w	$ffe1,$fffe
	dc.w	$2f01,$ff00,$0182,$0721
	dc.w	$0192,$0e93
	dc.w	$3001,$ff00,$0182,$0610
	dc.w	$0192,$0d82
	dc.w	$3101,$ff00,$0182,$0500
	dc.w	$0192,$0c71
	dc.w	$3201,$ff00,$0182,$0400
	dc.w	$0192,$0b60
	dc.w	$3301,$ff00,$0182,$0300
	dc.w	$0192,$0a50
	dc.w	$3401,$ff00,$0100,$0200
	dc.w	$00ec,$0006,$00ee,$5938
	dc.w	$00f0,$0006,$00f2,$69a0
	dc.w	$ffff,$fffe

A set 0
	Rept	320
	Dc.w	A*40
A set A+1
	Endr

A set 0
Bits
	Rept	320
	Dc.w	((A&$f)*$1000)+$bca
A set A+1
	Endr

Size
A set 0
	Rept	320
	Dc.w	(A*64)+2
A set A+1
	Endr

Logo:
	incbin	df2:Logo.raw
Sprite1:
	include	df2:SpriteData1
Sprite2:
	include	df2:SpriteData2
Sprite3:
	include	df2:SpriteData3
Sprite4:
	include	df2:SpriteData4


;ญญญญญญญญญญญญญญญญญญญญญญญญญญญญญญญญญญญญญญ
;ญ   NoisetrackerV2.0 Normal replay   ญ
;ญ     Uses registers d0-d3/a0-a5     ญ
;ญ Mahoney & Kaktus - (C) E.A.S. 1990 ญ
;ญญญญญญญญญญญญญญญญญญญญญญญญญญญญญญญญญญญญญญ


mt_init:movem.l	d0-d2/a0-a2,-(a7)
	lea	mt_data,a0
	lea	$3b8(a0),a1
	moveq	#$7f,d0
	moveq	#0,d2
	moveq	#0,d1
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.b	#1,d2

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

	or.b	#2,$bfe001
	move.b	#6,mt_speed
	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)
	clr.b	mt_songpos
	clr.b	mt_counter
	clr.w	mt_pattpos
	movem.l	(a7)+,d0-d2/a0-a2
	rts

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


mt_music:
	movem.l	d0-d3/a0-a5,-(a7)
	lea	mt_data,a0
	addq.b	#1,mt_counter
	move.b	mt_counter(pc),d0
	cmp.b	mt_speed(pc),d0
	blt	mt_nonew
	clr.b	mt_counter

	lea	mt_data,a0
	lea	$c(a0),a3
	lea	$3b8(a0),a2
	lea	$43c(a0),a0

	moveq	#0,d0
	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
	clr.w	mt_dmacon

	lea	$dff0a0,a5
	lea	mt_voice1(pc),a4
	bsr	mt_playvoice
	addq.l	#4,d1
	lea	$dff0b0,a5
	lea	mt_voice2(pc),a4
	bsr	mt_playvoice
	addq.l	#4,d1
	lea	$dff0c0,a5
	lea	mt_voice3(pc),a4
	bsr	mt_playvoice
	addq.l	#4,d1
	lea	$dff0d0,a5
	lea	mt_voice4(pc),a4
	bsr	mt_playvoice

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

	bsr	mt_wait
	or.w	#$8000,d0
	move.w	d0,$dff096
	bsr	mt_wait
mt_nodma:
	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)

	add.w	#$10,mt_pattpos
	cmp.w	#$400,mt_pattpos
	bne.s	mt_exit
mt_next:clr.w	mt_pattpos
	clr.b	mt_break
	addq.b	#1,mt_songpos
	and.b	#$7f,mt_songpos
	move.b	-2(a2),d0
	cmp.b	mt_songpos(pc),d0
	bne.s	mt_exit
	move.b	-1(a2),mt_songpos
mt_exit:tst.b	mt_break
	bne.s	mt_next
	movem.l	(a7)+,d0-d3/a0-a5
	rts

mt_wait:moveq	#3,d3
mt_wai2:move.b	$dff006,d2
mt_wai3:cmp.b	$dff006,d2
	beq.s	mt_wai3
	dbf	d3,mt_wai2
	moveq	#8,d2
mt_wai4:dbf	d2,mt_wai4
	rts

mt_nonew:
	lea	mt_voice1(pc),a4
	lea	$dff0a0,a5
	bsr	mt_com
	lea	mt_voice2(pc),a4
	lea	$dff0b0,a5
	bsr	mt_com
	lea	mt_voice3(pc),a4
	lea	$dff0c0,a5
	bsr	mt_com
	lea	mt_voice4(pc),a4
	lea	$dff0d0,a5
	bsr	mt_com
	bra.s	mt_exit

mt_mulu:
	dc.w $000,$01e,$03c,$05a,$078,$096,$0b4,$0d2,$0f0,$10e,$12c,$14a
	dc.w $168,$186,$1a4,$1c2,$1e0,$1fe,$21c,$23a,$258,$276,$294,$2b2
	dc.w $2d0,$2ee,$30c,$32a,$348,$366,$384,$3a2

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.s	mt_oldinstr

	lea	mt_samplestarts-4(pc),a1
	asl.w	#2,d2
	move.l	(a1,d2.l),4(a4)
	lsr.w	#1,d2
	move.w	mt_mulu(pc,d2.w),d2
	move.w	(a3,d2.w),8(a4)
	move.w	2(a3,d2.w),$12(a4)
	moveq	#0,d3
	move.w	4(a3,d2.w),d3
	tst.w	d3
	beq.s	mt_noloop
	move.l	4(a4),d0
	asl.w	#1,d3
	add.l	d3,d0
	move.l	d0,$a(a4)
	move.w	4(a3,d2.w),d0
	add.w	6(a3,d2.w),d0
	move.w	d0,8(a4)
	bra.s	mt_hejaSverige
mt_noloop:
	move.l	4(a4),d0
	add.l	d3,d0
	move.l	d0,$a(a4)
mt_hejaSverige:
	move.w	6(a3,d2.w),$e(a4)
	moveq	#0,d0
	move.b	$13(a4),d0
	move.w	d0,8(a5)

mt_oldinstr:
	move.w	(a4),d0
	and.w	#$fff,d0
	beq	mt_com2
	tst.w	8(a4)
	beq.s	mt_stopsound
	tst.b	$12(a4)
	bne.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	(a4),$10(a4)
	and.w	#$fff,$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	;dmaset
	or.w	d0,mt_dmacon
	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:move.b	3(a4),d0
	beq.s	mt_port2
	move.b	d0,$15(a4)
	clr.b	3(a4)
mt_port2:
	tst.w	$16(a4)
	beq.s	mt_rts
	moveq	#0,d0
	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_arp0
	cmp.b	#2,d0
	beq.s	mt_arp2
mt_arp1:moveq	#0,d0
	move.b	3(a4),d0
	lsr.b	#4,d0
	bra.s	mt_arpdo
mt_arp2:moveq	#0,d0
	move.b	3(a4),d0
	and.b	#$f,d0
mt_arpdo:
	asl.w	#1,d0
	move.w	$10(a4),d1
	and.w	#$fff,d1
	lea	mt_periods(pc),a0
	moveq	#$24,d2
mt_arp3:cmp.w	(a0)+,d1
	bge.s	mt_arpfound
	dbf	d2,mt_arp3
mt_arp0:move.w	$10(a4),6(a5)
	rts
mt_arpfound:
	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
	tst.b	d0
	beq.s	mt_arp
	cmp.b	#1,d0
	beq.s	mt_portup
	cmp.b	#2,d0
	beq.s	mt_portdown
	cmp.b	#3,d0
	beq	mt_port
	cmp.b	#4,d0
	beq	mt_vib
	cmp.b	#5,d0
	beq.s	mt_volport
	cmp.b	#6,d0
	beq.s	mt_volvib
	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:moveq	#0,d0
	move.b	$13(a4),d0
	move.w	d0,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:moveq	#0,d0
	move.b	$13(a4),d0
	move.w	d0,8(a5)
	rts

mt_com2:move.b	$2(a4),d0
	and.b	#$f,d0
	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
	rts

mt_songjmp:
	move.b	#1,mt_break
	move.b	3(a4),d0
	subq.b	#1,d0
	move.b	d0,mt_songpos
	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
	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:dcb.l	$1f,0
mt_voice1:	dcb.w	13,0
		dc.w	1
mt_voice2:	dcb.w	13,0
		dc.w	2
mt_voice3:	dcb.w	13,0
		dc.w	4
mt_voice4:	dcb.w	13,0
		dc.w	8
sinscroll:
	lea showplane,a0		; visible bitplane
blitready:
	btst #14,$dff002		
	bne.s blitready			; wait till blitter ready
	cmp.b #$ff,$dff006
	bne.s blitready
	move.l a0,$dff054		; source address
	move.l a0,$dff050		; destination address
	clr.l $dff044			; no FWM/LWM (see hardware manual)
	clr.l $dff064			; no MODULO (see hardware manual)

	move.w #%100000000,$dff040 	; Enable DMA channel D, nothing
					; else, no minterms active. 
	clr.w $dff042			; nothing set in BLTCON1
	move.w #%111100010101,$dff058	; Window size = 21 words wide
               				; 60 lines deep
	move.l sinpt,a3
	subq.l #1,a3
	move.b (a3),d0
	cmp.b #255,d0
	bne.s notendofsine
	lea sintabend(pc),a3
notendofsine:
	move.l a3,sinpt

	moveq #19,d0
	lea scrollplane,a0
	lea showplane,a1

sloop3:

	bsr getsinval

blitready2:
	btst #14,$dff002
	bne.s blitready2

	move.l a0,$dff050
	move.l a2,$dff054
	move.l #$f000f000,$dff044
	move.w #40,$dff064
	move.w #40,$dff066
	move.w #%0000100111110000,$dff040
	clr.w $dff042
	move.w #%100000000001,$dff058

	bsr getsinval

zonk2:
	btst #14,$dff002
	bne.s zonk2

	move.l a0,$dff050
	move.l a2,$dff054
	move.l a2,$dff04c
	move.l #$f000f00,$dff044
	move.w #40,$dff064
	move.w #40,$dff066
	move.w #40,$dff062
	move.w #%0000110111111100,$dff040
 	clr.w $dff042
	move.w #%100000000001,$dff058

	bsr getsinval
zonk3:
	btst #14,$dff002
	bne.s zonk3

	move.l a0,$dff050
	move.l a2,$dff054
	move.l a2,$dff04c
	move.l #$f000f0,$dff044
	move.w #40,$dff064
	move.w #40,$dff066
	move.w #40,$dff062
	move.w #%0000110111111100,$dff040
	clr.w $dff042
	move.w #%100000000001,$dff058

	bsr getsinval
zonk4:
	btst #14,$dff002
	bne.s zonk4
	move.l a0,$dff050
	move.l a2,$dff054
	move.l a2,$dff04c
	move.l #$f000f,$dff044
	move.w #40,$dff064
	move.w #40,$dff066
	move.w #40,$dff062
	move.w #%0000110111111100,$dff040
	clr.w $dff042
	move.w #%100000000001,$dff058



	addq.l #2,a0
LOAD:	addq.l #2,a1
	dbra d0,sloop3

rts

getsinval:
	moveq #0,d1
	move.b (a3)+,d1
	move.b (a3),d2
	cmp.b #255,d2
	bne okyar
	move.l #sintab,a3
okyar:

	lsr.b #1,d1

	bclr #0,d1


	mulu #21,d1

	move.l a1,a2
	add.l d1,a2

	rts
scrolly: 
	move.b pause,d0
	cmp.b #0,d0
	beq gopast
	sub.b #1,d0
	move.b d0,pause
	bra gopast2
gopast:
	move.l #scrollplane,a0
	move.l #scrollplane+2,a1
blitready3:
	btst #14,$dff002
	bne.s blitready3
	move.l a0,$dff054
	move.l a1,$dff050
	move.l #-1,$dff044
	clr.l $dff064
	move.w #%1100100111110000,$dff040
	clr.w $dff042
	move.w #%101000010111,$dff058
gopast2:
	bsr sinscroll
	move.b pause,d0
	cmp.b #0,d0
	bne iuo

	move.b countdown,d0
	sub.b #1,d0
	cmp.b #0,d0
	beq mfc
	move.b d0,countdown
iuo:
	rts
	
countdown:
	dc.b 4,0


sinpt: 	dc.l sintabend		
sinpt2: dc.l sintab2
mesptr	dc.l message

sintab:

	dc.b $3C,$3F,$42,$46,$49,$4C,$50,$53,$56,$59
	dc.b $5C,$5F,$61,$64,$67,$69,$6B,$6D,$6F,$71
	dc.b $72,$73,$75,$76,$76,$77,$77,$77,$77,$77
	dc.b $77,$76,$76,$75,$73,$72,$71,$6F,$6D,$6B
	dc.b $69,$67,$64,$61,$5F,$5C,$59,$56,$53,$50
	dc.b $4C,$49,$46,$42,$3F,$3C,$38,$35,$31,$2E
	dc.b $2B,$27,$24,$21,$1E,$1B,$18,$16,$13,$10
	dc.b $E,$C,$A,$8,$6,$5,$4,$2,$1,$1
	dc.b $0,$0,$0,$0,$0,$0,$1,$1,$2,$4
	dc.b $5,$6,$8,$A,$C,$E,$10,$13,$16,$18
	dc.b $1B,$1E,$21,$24,$27,$2B,$2E,$31,$35

sintabend:
 dc.b $38,255


sintab2:

 dc.b $2D
 dc.b $31,$2D,$29,$26,$22,$1F,$1C,$19,$15
 dc.b $13,$10,$D,$B,$9,$7,$5,$3,$2,$1,$1,$0,$0,$0,$1,$1,$2,$3,$5,$7,$9
 dc.b $B,$D,$10,$13,$15,$19,$1C,$1F,$22,$26,$29,$ff
 even
pause: 	dc.b 0
sinmodulo:
	dc.b 0

 	even
mfc:
	move.b #4,countdown
	clr.w scrollplane+40
	clr.w scrollplane+82
	move.l #scrollplane+124,a1
	bsr charaddress

	moveq #15,d0
zonkin:
	move.w (a0),(a1)
	lea 40(a0),a0
	lea 42(a1),a1
	dbf d0,zonkin

	rts
CHARADDRESS:
	move.l mesptr,a0
	moveq #0,d0
	move.l d0,d1
	move.l d0,d2
	move.b (a0)+,d0
	cmp.b #$0a,d0
	bne wizy
	move.b #32,d0
wizy:
	cmp.b #255,d0
	bne wazy
	move.l #message,a0
	move.b #32,d0
wazy:
	cmp.b #255,d0
	beq w1
	bra wozy
w1:
	move.b #32,d0
	move.b #$60,pause
	bra	wozy
wozy:

	move.l a0,mesptr
	sub.b #32,d0 
 	moveq #0,d1
 	divu #20,d0  		; 20 chars on each line
 	move.b d0,d1 
 	clr.w d0
 	swap d0  
	move.l #fnt2,a0
	mulu #640,d1
	add.l d0,d0
	add.l d0,a0
	add.l d1,a0

	rts

blitclear:
 lea showplane2,a0
 blitfin1:
 btst #14,$dff002
 bne.s blitfin1
 move.l a0,$dff054
 move.l a0,$dff050
 clr.l $dff044
 clr.l $dff064

 move.w #%100000000,$dff040
 clr.w $dff042
 move.w #%1011010010100,$dff058
 rts
check1: dc.w 0
even

showplane: 	ds.b 6000
showplane2:	ds.b 6000
scrollplane: 	ds.b 2500

fnt2:		incbin "df0:f"

message:
 dc.b  "  INNERCITY     ARE BACK AGAIN !!!!",255,"    "
 DC.B  " THIS TIME WE PRESENT .........."
 DC.B  " THE INNERCITY  MEGA COMPACT DISK ",255," WITH GRAPHICS BY      CRAZY LEGS      ",255,"   AND        FAST EDDIE    ",255
 DC.B  " MUSIC BY       RICK         ",255," AND          CASP          ",255  
 DC.B  "               GREETS GO OUT TO : RANDOM , QUARTEX , MAYHEM , ACIDFORCE , THR , SLIPSTREAM , ANARCHY U.K  AND ALL THE OTHERS WE KNOW ........ OHH BY THE WAY THE MUSIC WAS BY RICK OF INNERCITY .......... ",255
 ;                                                        
 dc.b ".......          "
 dc.b 255
	even


Chars:
	Incbin	df2:Tetris.font

mt_data:
		dc.b	0;incbin	ReeboKVectors:mod.CrackJunkadelia

