; SoftScroller
; (C)1989 by Brian Postma
; J.v.Hartenstraat 51
; 7576VX Oldenzaal (NL)
; Tel:05410-14763

start:	movem.l		d0-d7/a0-a6,-(a7)
	bsr		initcop		;Init CopperList
	lea		gfxname,a1	;Name of graphics library
	move.l		4,a6		;Execbase
	jsr		-408(a6)	;Open Library
	move.l		d0,gfxbase	;Rememer graphics base
	lea		intname,a1	;Name of intuition lib.
	jsr		-408(a6)	;Open Library
	move.l		d0,intbase	;Remember intuition base
	move.l		intbase,a6
	lea		osargs,a0	;Pointer to newscreen struct.
	jsr		-198(a6)	;Open Screen
	move.l		d0,screenbase	;Pointer to screen struct
	beq		quit		;Could I open it ??
	add.l		#84,d0		;Screenbase+84
	move.l		d0,rastport	;Is Rastport
	move.l		gfxbase,a6	
	move.l		rastport,a1
	clr.l		d0		;Color=0
	jsr		-234(a6)	;Setrast->Clear Screen
	move.l		screenbase,a0
	move.l		192(a0),d0	;Pointer to first bitplane
	move.w		d0,planes+6	;Low word in copperlist
	swap		d0
	move.w		d0,planes+2	;High word in copperlist
	move.l		gfxbase,a0	;gfxbase+$32=pointer to clist
	move.l		$32(a0),oldcop	;save old copperlist
	move.l		#newcop,$32(a0)	;My own copperlist
	move.l		$6c,oldirq	;Save old VBL irq pointer
	move.l		#newirq,$6c	;my VBL interrupt
wait:	btst		#6,$bfe001	;Left mouse button pressed ??
	bne		wait		;No !!
	move.l		oldirq,$6c	;Restore interrupt
	move.l		gfxbase,a0	;restore
	move.l		oldcop,$32(a1)	;old copperlist
	move.l		intbase,a6
	move.l		screenbase,a0
	jsr		-66(a6)		;Close the screen
quit:	movem.l		(a7)+,d0-d7/a0-a6
	rts

initcop:lea		colcop,a0	;pos in copperlist
	move.l		#$5007fffe,d1	;first rasterline
	move.l		#127,d7		;128 positions
icloop1:move.l		d1,(a0)+	;wait in copperlist
	add.l		#$01000000,d1	;next rasterline
	move.l		#$01800000,(a0)+;backcol in copperlist
	dbra		d7,icloop1
	rts

newirq:	movem.l		d0-d7/a0-a6,-(a7);Save regs
	bsr		scroll
	bsr		bars
	movem.l		(a7)+,d0-d7/a0-a6;Restore regs
	dc.w		$4ef9		;Code for 'JUMP'
oldirq:	dc.l		0		;Jump to oldirq

bars:	lea		colcop+6,a0	;pos in copperlist
	move.l		#127,d7		;128 positions
coloop1:clr.w		(a0)		;clear all colors
	addq.w		#8,a0		;next position
	dbra		d7,coloop1

	addq.w		#1,pointer	;next position
	move.w		pointer,d3
	lea		colcop+6,a0	;copperlist
	move.l		#8,d7		;9 bars
	lea		colors,a1	;and the colordata
	lea		sinedat,a2	;data for a sine
coloop2:and.w		#127,d3		;128 sinedatas
	clr.w		d0
	move.b		(a2,d3.w),d0	;screenpos
	lsl.w		#3,d0		;3 shifts left= x 8
	move.l		#7,d6		;8 colors per bar
coloop3:move.w		(a1)+,(a0,d0.w)	;color in copperlist
	addq.w		#8,d0		;next pos in copper
	dbra		d6,coloop3	;next color
	addq.w		#4,d3		;distance between bars
	dbra		d7,coloop2	;next bar
	rts

scroll:	move.l		gfxbase,a6
	move.l		#2,d0		;dx, 2 pixels to the left
	clr.l		d1		;dy
	move.l		#0,d2		;min x
	move.l		#60,d3		;min y
	move.l		#367,d4		;max x
	move.l		#75,d5		;max y
	move.l		rastport,a1	;rastport pointer
	jsr		-396(a6)	;ScrollRaster
	subq.w		#1,scrcount	;Counter for newtext
	beq		newtext		;is zero->new char
	rts				;else->bye ??
newtext:move.w		#5,scrcount	;newtext delay set
	move.l		gfxbase,a6
	move.l		rastport,a1
	move.l		#358,d0		;x
	move.l		#68,d1		;y
	jsr		-240(a6)	;move
	move.l		stringpointer,a0;pointer to string
	move.l		#1,d0		;1 char
	jsr		-60(a6)
	addq.l		#1,stringpointer;Next char
	cmpi.l		#endstring,stringpointer
	bne		notend		;end of string reached
	move.l		#string,stringpointer;Start al over
notend:	rts

newcop:	dc.w	$0092,$0028,$0094,$00d8	;DFFSTART,DFFSTOP->OverScan
	dc.w	$008e,$296a,$0090,$29fa	;DIWSTART,DIWSTOP
	dc.w	$0108,$0000,$010a,$0000	;BPL1MOD,BPL2MOD
	dc.w	$0096,$0020,$0100,$0000	;Sprites off,planes off
	dc.w	$0180,$0000,$0182,$0fff	;Colors
planes:	dc.w	$00e0,$0000,$00e2,$0000	;Plane1 low,high word
	dc.w	$5001,$fffe		;Wait till line 80 reached
	dc.w	$0100,$1000		;Bitplane 1 on
colcop:	blk.b	8*128,0			;Reserve place for colors
	dc.w	$d001,$fffe		;Wait till line 208 reached
	dc.w	$0100,$0000		;Bitplanes off
	dc.w	$0180,$0000		;background=black
	dc.w	$ffff,$fffe		;Wait till end

osargs:	dc.w	0,0,368,128		;x-min,y-min,width,height
	dc.w	1			;depth 1 bitplane
	dc.b	0,1			;detailpen,blockpen
	dc.w	0,15			;viewmodes,type=customscreen
	dc.l	textattr,0		;textattr,title=none
	dc.l	0,0			;gadgets,bitmap
textattr:
	dc.l	fontname		;Fontname
	dc.w	9			;fontsize
	dc.b	0			;Style=normal
	dc.b	1			;flags=romfont

; colors for copper bars
colors:	dc.w	$003,$007,$00b,$00f,$00f,$00b,$007,$003
	dc.w	$003,$007,$00b,$00f,$00f,$00b,$007,$003
	dc.w	$003,$007,$00b,$00f,$00f,$00b,$007,$003
	dc.w	$333,$777,$bbb,$fff,$fff,$bbb,$777,$333
	dc.w	$333,$777,$bbb,$fff,$fff,$bbb,$777,$333
	dc.w	$333,$777,$bbb,$fff,$fff,$bbb,$777,$333
	dc.w	$300,$700,$b00,$f00,$f00,$b00,$700,$300
	dc.w	$300,$700,$b00,$f00,$f00,$b00,$700,$300
	dc.w	$300,$700,$b00,$f00,$f00,$b00,$700,$300

scrcount:	dc.w	1
pointer:	dc.w	0
oldcop:		dc.l	0
gfxbase:	dc.l	0
intbase:	dc.l	0
rastport:	dc.l	0
screenbase:	dc.l	0
stringpointer:	dc.l	string
intname:	dc.b	"intuition.library",0
gfxname:	dc.b	"graphics.library",0
fontname:	dc.b	"topaz.font",0
string:
 DC.B	"HOW ABOUT THIS LITTLE SCROLLER ??? ... MADE FOR THE "
 DC.B	"UGA NEWSFLASH MAGAZINE BY BRIAN POSTMA   "
 DC.B	"      "
endstring:
sinedat:
 dc.b	60, 63, 66, 69, 72, 75, 77, 80
 dc.b	83, 86, 88, 91, 93, 96, 98, 100
 dc.b	102, 104, 106, 108, 110, 111, 113, 114
 dc.b	115, 116, 117, 118, 119, 119, 120, 120
 dc.b	120, 120, 120, 119, 119, 118, 117, 116
 dc.b	115, 114, 113, 111, 110, 108, 106, 104
 dc.b	102, 100, 98, 96, 93, 91, 88, 86
 dc.b	83, 80, 77, 75, 72, 69, 66, 63
 dc.b	60, 57, 54, 51, 48, 45, 43, 40
 dc.b	37, 34, 32, 29, 27, 24, 22, 20
 dc.b	18, 16, 14, 12, 10, 9, 7, 6
 dc.b	5, 4, 3, 2, 1, 1, 0, 0
 dc.b	0, 0, 0, 1, 1, 2, 3, 4
 dc.b	5, 6, 7, 9, 10, 12, 14, 16
 dc.b	18, 20, 22, 24, 27, 29, 32, 34
 dc.b	37, 40, 43, 45, 48, 51, 54, 57

