;	*** OPENSCREEN ***

; This program opens a hardware screen with the Copper and closes it after-
; wards. It's meant as an example, and I know it can be done shorter!
; The biggest advantage of such screens is that you won't have to use slow
; library routines and thus create a much faster environment.

Plane	= 40*256	; Format is 40 bytes * 256 lines

lea	$dff000,a5	; The base of the custom chips
move.l	$4.w,a6		; It's NOT forbidden to use Exec!
lea	gn(pc),a1
jsr	-408(a6)	; Open GFX-library (don't worry, it's for the
move.l	d0,a0		; current copperlistadress.)
move.l	38(a0),OldCopper

move.l	#plane*5,d0	; Reserve memory for 5 bitplanes (example...)
move.l	#$10003,d1	; Empty chipmem ofcourse
jsr	-198(a6)
move.l	d0,a4		; A4 contains the screenbase
beq.L	Quit		; Test for availability

move.l	#copperlength,d0
moveq	#3,d1
jsr	-198(a6)
move.l	d0,ChipCopper	; Reserve chipmem for copperlist
move.l	d0,a0

move.l	#copperlength/2-1,d1
lea	Copper(pc),a1

CopyLoop1:
move.w	(a1)+,(a0)+
dbra	d1,CopyLoop1	; Loop to copy copperlist

move.l	d0,a0
move.l	a4,d0
move.w	#$e0,d1
moveq	#4,d2		; 5 Bitplanes

Creation:
move.w	d1,(a0)+	; BPLPTHx
swap	d0
move.w	d0,(a0)+	; High bits
addq	#2,d1
move.w	d1,(a0)+	; BPLPTLx
swap	d0
move.w	d0,(a0)+	; Low bits
addq	#2,d1
dbra	d2,Creation	; Keep repeating

; So the copperlist is ready... Show it!

move.w	#$a0,$96(a5)	; Switch off copper and sprite-DMA
move.l	ChipCopper,$80(a5)
clr.w	$88(a5)		; Load copper-PC
move.w	#$8380,$96(a5)	; Start Copper,bitplane and ALL DMA.

; Here you can put your own program, and remember these things:
;	A4 contains the adress of the first bitplane
;	A5 contains the base adress of the custom chips

; If somebody has any questions, write or call me:
;	Niels 'Nitro' Keurentjes
;	Hartelstein 50
;	5655 AL Eindhoven
;	The Netherlands
;	040-521640

; Thanx to Lars Hamre for his (late) service with the ProTracker V1.1b
; replayer.

; Check for both mouseybuttons:

IncredibleLoop:
btst	#6,$bfe001
bne.s	IncredibleLoop
btst	#2,$16(a5)
bne.s	IncredibleLoop

; Now destroy that screen... (Har,har!!!)

move.w	#$80,$96(a5)	; No copper!
move.l	OldCopper(pc),$80(a5)
clr.w	$88(a5)
move.w	#$80a0,$96(a5)	; Reactivate sprite and copper-DMA

move.l	ChipCopper(pc),a1
move.l	#copperlength,d0
jsr	-210(a6)

move.l	a4,a1
move.l	#plane*5,d0
jsr	-210(a6)

Quit:			; As it says
moveq	#0,d0		; No errorcode!!!
rts

OldCopper:	dc.l 0
ChipCopper:	dc.l 0
GN:	dc.b	'graphics.library',0

; Now start the almighty copperlist on a word-aligned adress

even
Copper:
blk.l	10,0		; Empty space for bitplane adresses
dc.w	$008e,$2c81	; I'm not going to explain all this, you can
dc.w	$0090,$2cc1	; buy Amiga Intern I if you want to know about
dc.w	$0092,$0038	; it. (Data Becker, around f90,-)
dc.w	$0094,$00d0
dc.w	$0100,$5000
dc.w	$0102,$0000
dc.w	$0104,$0000
dc.w	$0108,$0000
dc.w	$010a,$0000

; Here comes the palette! Don't worry about the numbers like $0180 and
; $1ac, the others are the colors.

dc.w	$0180,$000,$0182,$000	; Allright, I'll be honest, I didn't really
dc.w	$0184,$000,$0186,$000	; feel like filling it up. But it's also
dc.w	$0188,$000,$018a,$000	; fun to look at a big, black screen!
dc.w	$018c,$000,$018e,$000	; Now you can recognise the colours even
dc.w	$0190,$000,$0192,$000	; better, they're the zeroes (hihi!)
dc.w	$0194,$000,$0196,$000
dc.w	$0198,$000,$019a,$000
dc.w	$019c,$000,$019e,$000
dc.w	$01a0,$000,$01a2,$000
dc.w	$01a4,$000,$01a6,$000
dc.w	$01a8,$000,$01aa,$000
dc.w	$01ac,$000,$01ae,$000
dc.w	$01b0,$000,$01b2,$000
dc.w	$01b4,$000,$01b6,$000
dc.w	$01b8,$000,$01ba,$000
dc.w	$01bc,$000,$01be,$000

; To do you a favour, you won't have to look at a black screen (hrmpf).

dc.w	$300f,$fffe,$0180,$222	; Wait for line 48, change color
dc.w	$310f,$fffe,$0180,$444	; Wait for line 49, change color
dc.w	$330f,$fffe,$0180,$666	; Wait for line 51, change color
dc.w	$360f,$fffe,$0180,$888	; Etcetera...
dc.w	$3a0f,$fffe,$0180,$aaa	; And so on...
dc.w	$3f0f,$fffe,$0180,$888	; The story continues...
dc.w	$430f,$fffe,$0180,$666	; Buzz off!!!
dc.w	$460f,$fffe,$0180,$444
dc.w	$480f,$fffe,$0180,$222
dc.w	$490f,$fffe,$0180,$000

; And the "Pro" Effect:

dc.w	$800f,$fffe,$0180,$fff,$810f,$fffe,$0180,$000

dc.w	$ffff,$fffe	; The End
TheEnd:

copperlength = theend-copper
