* Sine Scroller by MARK (MATRIX) for soundtracker songs just 
* add the source code)	
	bsr start
	move.l $4,a6
	movem.l a0-a6/d0-d7,-(a7)
	lea $dff000,a5
	move.w #$83a0,150(a5)
	move.w #$4000,154(a5)
	move.l #$68000,$0108
	move.l (a6),a0
	move.l (a0),a0
	move.l a0,$0100
	move.l 38(a0),$104
	lea copper(pc),a0
	move.l a0,128(a5)
	bsr clearscreen
	bsr init2
	bsr init3
vposr1:
	cmpi.b #$64,$dff006
	bne vposr1
vposr2:
	cmpi.b #$0a,$dff006
	bne vposr2
	bsr jump1
	bsr movestars
	bsr jump1
	bsr bouncetext
	btst #6,$bfe001
	bne vposr1
endroutine:


	move.l $0104,$dff080
	clr.w $dff088
	move.w #$83a0,$dff096
	
	move.l $4,a6
	move.l gfxbase,a1
	jsr -414(a6)
	movem.l (a7)+,d0-d7/a0-a6
	clr.l d0
	rts
clearscreen:
	move.l $0108,a0
	lea -16384(a0),a0
	move.w #$2fff,d0
loop:	clr.l (a0)+
	dbf d0,loop
	sub.w #$1000,a0
	move.l a0,$010c
	sub.w #$1000,a0
	move.l a0,$0114
	rts
init2:
	move.l $0100,a6
	move.l $010c,a1
	clr.l $0110
	jsr -198(a6)
	move.l 148(a6),52(a1)
	move.w #$0008,58(a1)
	move.w #$0004,28(a1)
	lea 128(a1),a0
	move.l a0,4(a1)
	moveq #$01,d0
	move.w #$2a0,d1
	move.w #$00c8,d2
	jsr -390(a6)
	move.l #$68000,136(a1)
	rts
unknown:
	move.l $010c,a1
	lea text(pc),a0
	move.w (a0)+,d0   *get character from scrolltext
	tst.b (a0,d0.w)   *test for zero ?
	bne.s skip
	clr.w -(a0)
	bra unknown
skip:
	addq.w #1,-2(a0)	* this is the text pointer
	adda.w d0,a0
	moveq #$01,d0
	move.w #$0140,36(a1)
	move.w #$004e,38(a1)
	bsr skip2
	move.w #$0290,36(a1)
	bsr skip2
	cmpi.b #$a0,(a0) 	*I think this produces gap in scroll
	beq gap
	move.b #$08,$0110
	rts
gap:
	move.b #$f8,$0110
	rts
skip2:
	movem.l a0-a1/d0,-(a7)
	jsr -60(a6)  		* text()
	movem.l (a7)+,a0-a1/d0
	rts
jump1:
	tst.b $0110
	bne skip3
	bsr unknown
skip3:
	subq.b #1,$0110		* this value should be 1/text width
	lea $69a40,a0
qqqq2:	moveq #$0f,d0
qqqq1:	moveq #$13,d1
	lsl.w -(a0)
qqqq:	roxl.w -(a0)
	dbf d1,qqqq
	dbf d0,qqqq1
	rts
init3:
	move.l $0114,a0
	clr.l d6
	lea $fd0003,a1
	move.w #$00ff,d0	* number of stars i think
	move.l #$30003100,d1
blug:	move.l d1,(a0)
	move.b (a1),d6
	move.b 6(a1),d5
	eor.b d5,d6
	adda.w #$0004,a1	* i think this is the y add for stars
	lsl.l #8,d6
	lsl.l #8,d6
	addi.l #$00200000,d6	* or may be this/ should be 200000
	andi.l #$00ff0000,d6
	or.l d6,(a0)+
	lsr.l #8,d6
	lsr.l #8,d6
	cmpi.w #$0001,$0118
	beq wow
	cmpi.w #$0002,$0118
	beq wow1
	cmpi.w #$0003,$0118
	beq wow3
	clr.w $118
wow3:	move.l #$00010001,(a0)+
	bra skip4
wow:	move.l #$00000001,(a0)+
	bra skip4
wow1:	move.l #$00010000,(a0)+
skip4:	addi.l #$02000200,d1	* should be 2000200
	bcc bone
	ori.b #$06,d1
bone:
	addi.w #$0002,$0118	* should be 1
	dbf d0,blug		
	clr.l (a0)+
	rts

movestars:
	move.l $0114,a0
	move.w #$0020,d0
quicky:	subq.b #1,1(a0)		
	subq.b #2,25(a0)
	subq.b #3,9(a0)
	subq.b #4,17(a0)
	adda.w #$0020,a0	* move pointer to next sprite
	dbf d0,quicky
	rts
bouncetext:
	lea sintable(pc),a0
	move.w $0112,d0
	move.b (a0,d0.w),d0
	bne bouncescroll
	clr.w $0112
	bra bouncetext
	
bouncescroll:
	lea copper2(pc),a0
	move.w #$7652,d1
	subi.b #$80,d0
	mulu #$002a,d0
	add.w d1,d0
	addi.w #$002a,d0
	move.w d0,d2
	move.w #$ff,d3
	sub.w d2,d3
	move.w d3,14(a0)
	move.w d0,6(a0)		* this was d0
	addq.w #1,$0112		* pointer for sin table
	rts
	even

copper:
 dc.w $0100,$2200,$0102,$0020,$0104,$0000,$0108,$0002
 dc.w $010a,$0002,$008e,$1800,$0090,$40ff,$0092,$0038
 dc.w $0094,$00d0
copper2:

 dc.w $00e0,$0006,$00e2,$8000,$00e4,$0006
 dc.w $00e6,$8000,$0180,$0000,$0182,$0100,$0184,$0010
 dc.w $0186,$0000,$01a0,$0000,$01a2,$0fff,$01a4,$0ddd
 dc.w $01a6,$0bbb,$0120,$0006,$0122,$e000,$0124,$0000
 dc.w $0126,$0000,$0128,$0000,$012a,$0000,$012c,$0000
 dc.w $012e,$0000,$0130,$0000,$0132,$0000,$0134,$0000
 dc.w $0136,$0000,$0138,$0000,$013a,$0000,$013c,$0000
 dc.w $013e,$0000
scroll1:
 dc.w $620f,$fffe,$0182,$0f00,$0184,$00f0,$6a0f,$fffe,$0182,$0f00,$0184,$00f0
 dc.w $740f,$fffe,$0182,$0e00,$0184,$00e0,$7a0f,$fffe,$0182,$0d00,$0184,$00d0
 dc.w $840f,$fffe,$0182,$0c00,$0184,$00c0,$8a0f,$fffe,$0182,$0b00,$0184,$00b0
 dc.w $8e0f,$fffe,$0182,$0a00,$0184,$00a0,$900f,$fffe,$0182,$0900,$0184,$0090
 dc.w $940f,$fffe,$0182,$0800,$0184,$0080,$9a0f,$fffe,$0182,$0700,$0184,$0070
 dc.w $a40f,$fffe,$0182,$0600,$0184,$0060,$aa0f,$fffe,$0182,$0500,$0184,$0050
 dc.w $b40f,$fffe,$0182,$0400,$0184,$0040,$ba0f,$fffe,$0182,$0200,$0184,$0020   
	 
 dc.w $ffff,$fffe
	even
sintable: 
 dc.b $ff,$fe,$fe,$fd,$fc,$fb,$f9,$f7,$f5,$f2,$ef,$ec,$e9,$e5,$e2
 dc.b $de,$d9,$d5,$d0,$cb,$c6,$c1,$bb,$b6,$b0,$aa,$a4,$9e,$98,$92
 dc.b $8c,$85,$85,$8c,$92,$98,$9e,$a4,$aa,$b0,$b6,$bb,$c1,$c6,$cb
 dc.b $d0,$d5,$d9,$de,$e2,$e5,$e9,$ec,$ef,$f2,$f5,$f7,$f9,$fb,$fc
 dc.b $fd,$fe,$fe,$ff
text:

 dc.b ' ....MATRIX OF MATRIX DIVISION SPEAKING.... ',$a0
 dc.b 'HERE IS MY SECOND STAR/COPPER DEMO'
 dc.b $a0
 dc.b 'HI TO OTHER MEMBERS OF MATRIX DIVISION (GREML1N,'
 dc.b ',WILDCAT,UBI KENUBI)..TND,ACCUMULATORS,BARLICK HACKERS'
 dc.b ' AND EVERYBODY ELSE WE KNOW'
 dc.b $a0
 	even
start:
	lea grafname(pc),a1
	move.l $4,a6
	moveq #$00,d0
	jsr -408(a6)
	move.l d0,gfxbase
	rts
 	even
grafname: dc.b 'graphics.library',0,0
 	even
gfxbase: dc.l 0  	

