; (C)1988 by Brian Postma
; Contact me at:
; P.O.Box 367
; 7570 AJ Oldenzaal
; Holland
; Or call:05410-14763

execbase = 4
allocmem = -198
mem_chip = 2
coolcapture = 46

start:	move.l		execbase,a6		;first we allocate
	move.l		#bpend-bpstart,d0	;some mem for the
	move.l		#mem_chip,d1		;program code
	jsr		allocmem(a6)
	move.l		d0,a1
	move.l		d0,a5
	beq		einde
	move.l		coolcapture(a6),oldcool	;save old coolcap
	move.l		d0,coolcapture(a6)	;and here is my one
	lea		bpstart,a0		;now we'll start
cloop:	move.b		(a0)+,(a1)+		;copying my program
	cmpa.l		#bpend,a0		;to the just allocated
	bne		cloop			;memory .. NOTE!! the
	clr.l		d0			;proggy must be PC
	lea		34(a6),a0		;relative
	move.w		#22,d1			;now we need a
chkloop:add.w		(a0)+,d0		;checksum, or else the
	dbf		d1,chkloop		;amiga won't execute
	not.w		d0			;my little program
	move.w		82(a6),oldchk		;save old checksum
	move.w		d0,82(a6)		;and here's mine
einde:	clr.l		d0			;no dos errors
	rts					;C.U.L.8.ER

; Program Code Placed Here

bpstart:move.w		#$81c0,$dff096		;bitplanes etc. on
	move.l		4,a6
	move.l		#6144,d0
	move.l		#$10002,d1
	jsr		-198(a6)		;AllocMem voor Plane
	lea		plane(pc),a0
	move.l		d0,(a0)			;and put in copper
	lea		planes(pc),a0		;notice all the pc
	move.w		d0,6(a0)		;relative code
	swap		d0
	move.w		d0,2(a0)
	swap		d0
	add.l		#48,d0
	move.w		d0,14(a0)
	swap		d0
	move.w		d0,10(a0)

	move.l		4,a6
	move.l		#11776,d0
	move.l		#$10002,d1
	jsr		-198(a6)	;AllocMem voor plane2
	lea		plane2(pc),a0
	move.l		d0,(a0)
	lea		planes(pc),a0	;and yep another one in
	move.w		d0,22(a0)	;the copperlist
	swap		d0
	move.w		d0,18(a0)

	move.l		4,a6
	move.l		#11776,d0
	move.l		#$10002,d1
	jsr		-198(a6)	; AllocMem voor plane3
	lea		plane3(pc),a0	;shit !! another one ??
	move.l		d0,(a0)
	lea		planes(pc),a0
	move.w		d0,30(a0)
	swap		d0
	move.w		d0,26(a0)

	lea		stringpointer(pc),a0	;init scroll
	lea		string(pc),a1
	move.l		a1,(a0) 

	lea		copper(pc),a0		;and my copperlist
	move.l		a0,$dff080		;to hardware

	lea		inter(pc),a1		;a new interrupt
	lea		bpnewirq(pc),a5		;via the system ???
	move.l		a5,18(a1)		;that's funny or what
	moveq		#5,d0
	move.l		4,a6
	jsr		-168(a6)		;Interrupt on

bpwait:	lea		random(pc),a0		;calculate a random
	move.b		$dff007,d0		;value by using
	add.b		d0,(a0)			;the hor. raster
	lea		random2(pc),a0		;and one more
	move.b		$dff007,d0		;coz there are 2
	sub.b		d0,(a0)			;random starfields
	btst		#7,$bfe001		;joystick button ??
	beq		eruit			;dit is nederlands
	btst		#6,$bfe001		;right button ??
	bne		bpwait			;und deutsch
	move.l		4,a6
	lea		bpstart(pc),a1		;allocate my program
	move.l		#bpend-bpstart,d0	;again
	jsr		-204(a6) 		;AllocAbs

backtonorm:
	move.l		4,a6			;now we must
	moveq		#32,d0			;clean up all the
	lea		inter(pc),a1		;shit we produced
	jsr		-174(a6)		;Interrupt Off
	move.l		4,a6
	move.l		#6144,d0
	move.l		plane(pc),a1
	jsr		-210(a6)		;Free BitPlane Mem

	move.l		#11776,d0
	move.l		plane2(pc),a1
	jsr		-210(a6) 		;Free BitPlane2 Mem
	move.l		#11776,d0
	move.l		plane3(pc),a1
	jsr		-210(a6)		;And plane 3
	rts

eruit:	move.l		4,a6
	move.l		oldcool(pc),46(a6)	;old capture back
	move.w		oldchk(pc),82(a6)	;and checksum
	bra		backtonorm

bpnewirq:
	movem.l		d0-d7/a0-a6,-(a7)	;thiz is my irq
	bsr		stars2			;starfield 1
	bsr		stars			;starfield 2
	bsr		scroll			;and a scroller
	movem.l		(a7)+,d0-d7/a0-a6
	moveq		#0,d0			;back from irq
	rts

stars:  bsr		waitblt			;wait for blitter
	move.w		#$39f0,$dff040		;BLTCON0
	move.w		#0,$dff042		;BLTCON1
	move.w		#$ffff,$dff044		;BLTMSK0
	move.w		#$fff0,$dff046		;BLTMSK1
	move.l		plane2(pc),d0
	move.l		d0,$dff054		;DEST D
	move.l		d0,$dff050		;SRC A
	clr.l		$dff064			;MOD A/D
	move.w		#$4017,$dff058		;BLTSIZE
	clr.l		d0
	move.b		random(pc),d0		;new random star
	mulu		#46,d0			;screenwidth
	move.l		plane2(pc),a0
	bset		#6,(a0,d0.w)		;set bit
	rts
stars2: bsr		waitblt
	move.w		#$49f0,$dff040		;Scroll starfield #2
	move.w		#0,$dff042
	move.w		#$ffff,$dff044
	move.w		#$fff0,$dff046
	move.l		plane3(pc),d0
	move.l		d0,$dff054
	move.l		d0,$dff050
	clr.l		$dff064
	move.w		#$4017,$dff058
	clr.l		d0			;and draw
	move.b		random2(pc),d0		;another random star
	mulu		#46,d0
	move.l		plane3(pc),a0
	bset		#6,(a0,d0.w)
	rts
	
scroll: bsr		waitblt			;scroll the scrolltext
	move.w		#$e9f0,$dff040
	move.w		#0,$dff042
	move.w		#$ffff,$dff044
	move.w		#$ff00,$dff046
	move.l		plane(pc),d0
	move.l		d0,$dff054
	addq.l		#2,d0
	move.l		d0,$dff050
	clr.l		$dff064
	move.w		#$1018,$dff058
	lea		count(pc),a0		;draw a new char
	subq.b		#1,(a0)
	beq		newtext			;yes ??
	rts					;or no !!
newtext:move.b		#8,(a0)			;new char delay
	lea		stringpointer(pc),a1	;fetch char from
	addq.l		#1,(a1)			;string
	move.l		(a1),a0
	bsr		waitblt			;blitter free ??
	clr.w		d0
	move.b		(a0),d0
	cmpi.b		#32,d0			;is it a space
	beq		space			;yes ??
	sub.b		#48,d0			;else we calculate
	cmpi.b		#14,d0			;the offset
	blt		skip1			;to the font
	subq.b		#3,d0			;bitplane
skip1:	mulu		#64,d0
	lea		font(pc),a1
	add.l		a1,d0
	move.l		d0,$dff050				
	move.l		plane(pc),d0
	add.l		#46,d0			;blit char
	move.l		d0,$dff054		;on the bitplane
	clr.w		$dff042
	clr.w		$dff064
	move.l		#$ffffffff,$dff044
	move.w		#$09f0,$dff040
	move.w		#46,$dff066
	move.w		#%0000100000000001,$dff058
space:	lea		endstring(pc),a0	;end of string
	lea		stringpointer(pc),a1	;then
	cmp.l		(a1),a0			;reset the
	bne		notend			;stringpointer
	lea		string(pc),a0
	move.l		a0,(a1)
notend:	rts

waitblt:btst		#14,$dff002		;wait for blitter
	bne		waitblt	
	rts

inter:		dc.l	0,0			;exec inter structure
		dc.b	2,127
		dc.l	0,0
		dc.l	0

plane:		dc.l 0				;my bitplane pointers
plane2:		dc.l 0
plane3:		dc.l 0
stringpointer:	dc.l 0				;and stringpointer
copper:
 dc.w	$100,$4000,$180,0,$92,$28,$94,$d8,$8e,$296a,$90,$29fa
 dc.w	$108,-46,$10a,0
 dc.w	$182,$eca,$184,$fc0,$186,$eca,$188,$f00,$18a,$f80
 dc.w	$18c,$f00,$18e,$f80,$190,$ca0
 dc.w	$192,$eca,$194,$fc0,$196,$eca,$198,$f00,$19a,$f80
 dc.w	$19c,$f00,$19e,$f80
planes: dc.w $e0,0,$e2,0,$e8,0,$ea,0,$e4,0,$e6,0,$ec,0,$ee,0
 dc.w	$8001,$fffe,$180,3,$190,3,$184,3,$194,3
 dc.w	$8101,$fffe,$180,7,$190,7,$184,7,$194,7
 dc.w	$8201,$fffe,$180,11,$190,11,$184,11,$194,11
 dc.w	$8301,$fffe,$180,15,$190,15,$184,15,$194,15
 dc.w	$8501,$fffe,$180,11,$190,11,$184,11,$194,11
 dc.w	$8601,$fffe,$180,7,$190,7,$184,7,$194,7
 dc.w	$8701,$fffe,$180,3,$190,3,$184,3,$194,3
 dc.w	$8c01,$fffe,$108,50,$9f01,$fffe

 dc.w	$a101,$fffe,$108,-46,$180,7,$190,7,$184,7,$194,7
 dc.w	$a201,$fffe,$180,11,$190,11,$184,11,$194,11
 dc.w	$a301,$fffe,$180,15,$190,15,$184,15,$194,15
 dc.w	$a501,$fffe,$180,11,$190,11,$184,11,$194,11
 dc.w	$a601,$fffe,$180,7,$190,7,$184,7,$194,7
 dc.w	$a701,$fffe,$180,3,$190,3,$184,3,$194,3
 dc.w	$a801,$fffe,$180,0,$190,$ca0,$184,$fc0,$194,$fc0
 dc.w	$fffe,$ffff	

oldcool:	dc.l	0
oldchk:		dc.w	0
font:		blk.b	2560,0
count:		dc.b	1
random:		dc.b	0
random2:	dc.b	128
; Scroll Codes ->
; : = (   ; = )   = = .   < = ,
string:	dc.b	" THE TIMECIRCLE PRESENTS === A RESET INTERRUPT"
	dc.b	" ROUTINE === FEATURING === A DUAL BITPLANE "
	dc.b	"BLITTER SCROLLED STARFIELD< A MULTICOLOURED "
 	dc.b	"BLITTER SCROLLED FONT< AND A PROGRAM THAT "
	dc.b	"DOES NOT WANT TO LEAVE === THIZ PROGGY WAS "
	dc.b	"CODED BY BRIAN :EXODUS; POSTMA FROM THE TIME"
	dc.b	"CIRCLE IN 1988 :WHICH IS SOME TIME AGO< BUT "
	dc.b	"IT IS STILL A NICE ONE< OR NOT; "
	dc.b	"=== EXCLUSIVE P=D RIGHTS BY U=G=A AND N=U=K === "
	dc.b	"IF YOU WANNA CONTACT ME THEN WRITE TO === "
	dc.b	"P=O BOX 367< 7570 AJ< OLDENZAAL< OR CALL ME AT"
	dc.b	" 05410 14763 IN HOLLAND OF COURSE ====="
	dc.b	"                   "
endstring:dc.b	32
bpend:
