;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;=						     =
;= Standard IRQ-setup for ESA Norway demos & intros. =
;=						     =
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
definitions:
     custom       = $dff000
     cop1lch      = $080
     dmacon       = $096

	BLTCON0 = $40
	BLTCON1 = $42
	BLTAMOD = $64
 	BLTBMOD = $62
 	BLTCMOD = $60
	BLTDMOD = $66
	BLTADAT = $74
	BLTBDAT = $72
	BLTCDAT = $70
	BLTDDAT = $00
	BLTAFWM = $44
	BLTALWM = $46
	BLTAPT  = $50
	BLTBPT  = $4C
	BLTCPT  = $48
	BLTDPT  = $54
	BLTSIZE = $58

	DMACONR = $02
	DMACONW = $96
	INTREQR = $1E
	INTREQ  = $9C
	VHPOS   = $06

	IRQBASE = $6C
	LEFTMUS = $BFE001
	SWIDE = 40

prgstrt:
	lea	custom,a0		; A0 points at custom chips
	move.w	#$8180,dmacon(a0)	; Enable the 2 DMA
	move.w	#$0020,dmacon(a0)	; Disable the spr DMA
	move.l	4,a6			; Base of exec.lib
	move.l	156(a6),a1		; a1 = gfx.lib.adr.
	move.l	38(a1),sys_copper	; Stores old copper1
	move.l	a7,sys_stack		; Stores old stack
	move.l	#cop,cop1lch(a0)	; Starts new copper1

check:	btst	#6,$bfe001		; Waits for the
	beq	quit			; left mousebutton
vblank:	cmp.b	#255,vhpos(a0)		; Vertical blacking
	bne	vblank
	movem.l	d0-d7/a0-a6,-(sp)	; Sub-routines
	movem.l	(sp)+,d0-d7/a0-a6
	jmp	check

quit:	move.l	sys_stack,a7
	move.l	sys_copper,$dff080
	clr.l	d0
	lea	custom,a0		; A0 points at custom chips
	move.w	#$8020,dmacon(a0)	; Re-enable sprite DMA
	clr.l	d0
	rts

sys_stack:	dc.l	0
sys_copper:	dc.l	0
SCREEN:	DC.L 	$60000
BUFSEL:	DC.W 	$0001


cop:	dc.w	$ffff,$fffe
