*******************************************************************************
* Blitter-assisted FullRes conversion and triple buffering example
*******************************************************************************
* INFO	shows how to work with a Blitter-assisted FullRes triple
*	buffered display
* NOTE	- experiment with the display definition parameters
*	- LMB to exit anytime
*******************************************************************************

	machine	68020

	include	INCLUDES:libraries/tcs.i
	include	INCLUDES:libraries/tcs_lib.i



*******************************************************************************
* custom display definitions
*******************************************************************************

DSPLWD	=	320	;our TCS display width and
DSPLHT	=	256	;height in 140 ns pixels
SCRWD	=	320	;TCS screen width and
SCRHT	=	256	;height in pixels
DSPLX0	=	$81*4	;display start
DSPLY0	=	$2c	;position (SHRES pixels)
DSPLX1	=	DSPLX0+DSPLWD*4	;display end
DSPLY1	=	DSPLY0+DSPLHT	;position (SHRES pixels)
DSPLBRTNS	=	256	;max brightness
GFXCTXT	=	0
CWBTM	=	0
CWTOP	=	0
CWRT	=	0
CWLF	=	0
VDOMODE	set	TCS_VM_RGBW | TCS_VMf_FullRes ;TCS display video mode
VDOMODE	set	VDOMODE | TCS_VMf_TriBuf | TCS_VMf_BltFRP



*******************************************************************************
* code start
*******************************************************************************

	include	/includes/shl_strtup.i



*******************************************************************************
* init
*******************************************************************************

_PrgInit	move.w	#0,ccr	;OK!
	rts



*******************************************************************************
* main
*******************************************************************************

_PrgMain	move.l	#Lev3Hndlr,([_VBR.l],$6c.w) ;set level3 autovector
	move.w	#$c020,$dff09a	;set INTENA.VERTB

.lp	movea.l	DIAdr,a0	;our display
	move.w	#SCRWD/2,d0	;centre x coordinate
	move.w	#SCRHT/2,d1	;centre y coordinate
	move.w	#50,d2	;radius
	move.b	#255,d3	;color
	CALLTCS	DrwCrcl2	;mark screen with a rectangle

	movea.l	DIAdr,a0	;render FullRes screen
	CALLTCS	BltFRPass0	;to make changes visible

	movea.l	DIAdr,a0	;acknowledge screen
	CALLTCS	TriUpd	;rendering completion

	btst.b	#6,$bfe001
	bne.s	.lp	;if not LMB...
	rts



*******************************************************************************
* cleanup
*******************************************************************************

_PrgClnUp	rts



*******************************************************************************
* Blitter-assisted FullRes & triple buffer handler (level 3 interrupt handler)
*******************************************************************************

Lev3Hndlr	movem.l	d0-d1/d7/a0-a1/a5-a6,-(sp)
	move.w       $dff01e,d7	;get INTREQR

	btst.l	#6,d7
	beq.s	.ChkVERTB	;if not BLIT...
	CALLTCS	BltFRPassHndlr	;perform FullRes conversion

.ChkVERTB	btst.l	#5,d7
	beq.s	.exit	;if not VERTB...

	movea.l	DIAdr,a0	;perform screen
	CALLTCS      TriSwp	;swapping

.exit	movem.l	(sp)+,d0-d1/d7/a0-a1/a5-a6
	move.w	#$70,$dff09c	;clr INTREQ.BLIT/VERTB/COPER
	rte



*******************************************************************************
* data
*******************************************************************************

	include	/includes/dat.i
