; MovieScroller
; (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		-132(a6)	;multitasking off
	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
	move.l		4,a6
	jsr		-138(a6)	;Multitasking on
quit:	movem.l		(a7)+,d0-d7/a0-a6
	rts

initcop:rts

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

scroll:	move.l		gfxbase,a6
	clr.l		d0		;dx
	move.l		#1,d1		;dy ->1 pixel up
	move.l		#0,d2		;min x
	move.l		#0,d3		;min y
	move.l		#320,d4		;max x
	move.l		#275,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		#15,scrcount	;newtext delay
	move.l		stringpointer,a0
	tst.b		(a0)		;reached end of string
	bne		not_end
	move.l		#string-1,stringpointer	;restart string
not_end:clr.l		d0
count:	addq.l		#1,d0
	tst.b		(a0)+
	bne		count		;count chars in string
	move.l		stringpointer,a0
	add.l		d0,stringpointer;next position in string
	subq.l		#1,d0		;number of legal chars
	move.w		d0,d1
	mulu		#10/2,d1	;10 is width of char
	move.w		#320/2,d2	;320 is screenwidth
	sub.w		d1,d2		;320-stringwidth/2=x offset
	move.l		rastport,a1
	move.w		d2,36(a1)	;x coord
	move.w		#265,38(a1)	;y coord
	move.l		gfxbase,a6
	jsr		-60(a6)		;TEXT
	rts

osargs:	dc.w	0,0,320,276		;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

newcop:	dc.w	$0096,$0020,$0180,$0000	;sprites of/backcol=black
	dc.w	$008e,$296a,$0090,$29fa	;DIWStart/DIWStop
	dc.w	$0092,$0038,$0094,$00d0	;DFFStart/DFFStop->normal
	dc.w	$0108,$0000,$010a,$0000	;BPL0MOD/BPL1MOD
	dc.w	$0102,$0000,$0104,$0000
	dc.w	$0182,$0111		;Char Color
planes:	dc.w	$00e0,$0000,$00e2,$0000	;Bitplane Pointers
	dc.w	$0100,$1000		;Bitplanes on
	dc.w	$2a07,$fffe,$0182,$0222	;color
	dc.w	$2c07,$fffe,$0182,$0333	;change
	dc.w	$2e07,$fffe,$0182,$0444	;from
	dc.w	$3007,$fffe,$0182,$0555	;black
	dc.w	$3207,$fffe,$0182,$0666	;to
	dc.w	$3407,$fffe,$0182,$0777	;white
	dc.w	$3607,$fffe,$0182,$0888	;coming
	dc.w	$3807,$fffe,$0182,$0999	;slowly
	dc.w	$3a07,$fffe,$0182,$0aaa	;but
	dc.w	$3c07,$fffe,$0182,$0bbb	;still
	dc.w	$3e07,$fffe,$0182,$0ccc	;they
	dc.w	$4007,$fffe,$0182,$0ddd	;come !!!
	dc.w	$4207,$fffe,$0182,$0eee	;where have I
	dc.w	$4407,$fffe,$0182,$0fff	;heard that before
	dc.w	$ffdf,$fffe		;Wait till end of NTSC screen
	dc.w	$0c07,$fffe,$0182,$0eee	;and
	dc.w	$0e07,$fffe,$0182,$0ddd	;now
	dc.w	$1007,$fffe,$0182,$0ccc	;we
	dc.w	$1207,$fffe,$0182,$0bbb	;are
	dc.w	$1407,$fffe,$0182,$0aaa	;going
	dc.w	$1607,$fffe,$0182,$0999	;back
	dc.w	$1807,$fffe,$0182,$0888	;to
	dc.w	$1a07,$fffe,$0182,$0777	;black
	dc.w	$1c07,$fffe,$0182,$0666	;I
	dc.w	$1e07,$fffe,$0182,$0555	;have
	dc.w	$2007,$fffe,$0182,$0444	;no
	dc.w	$2207,$fffe,$0182,$0333	;words
	dc.w	$2407,$fffe,$0182,$0222	;left
	dc.w	$2607,$fffe,$0182,$0111	;!!!!!
	dc.w	$ffff,$fffe		;End of Copperlist

scrcount:	dc.w	1
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	" ",0		;Empty Line
		DC.B	" ",0
		DC.B	" ",0
		dc.b	"+----------------+",0
		dc.b	"| THE TIMECIRCLE |",0
		dc.b	"+----------------+",0
		DC.B	"PRESENTS",0
		DC.B	"THE MOVIESCROLL",0
		DC.B	"CODED BY",0
		DC.B	"BRIAN POSTMA",0
		DC.B	"FOR THE",0
		DC.B	"*** NEWSFLASH ***",0
		DC.B	"MAGAZINE",0
		DC.B	" ",0		;Empty Line
		DC.B	" ",0
		DC.B	" ",0
		DC.B	0		;0 for end
