שתשת                                        

; !!!  IMPORTANT !!!

;** Very simple example code which shows how to make copper lists **;
;** to (do not) work properly with scandoublers                   **;
;**                                                               **;
;** see scandoubler testing area in copperlist                    **;
;
;                                    by Zeleny & Troda in co-op
; (ASM-One version)


WB = 0	; 0 - run from ASM_One
	; 1 - run from WB/CLI

TEST = 2	; 0 - correct signal
		; 1 - fucked horizontal sync
		; 2 - fucked horizontal & vertical sync
		; 3 - signal jam

	ifne	WB
	auto	wo\
	endc


	section	demo,code_f

	incdir	Work:Assembler/Sources/scandoubler_test/ ;set this to progdir

	include	inc/startupVBR.i
	include	inc/custom_aga.i

;------------------------

	ifeq	WB
	bsr	.s
	illegal
	else
	include	inc/icon_startup.i
	endc
.s
	BSR.W	ByeSystem
	bsr	demo
	move.w	#$7fff,$dff096
	BSR.W	HelloSystem
	moveq	#0,d0
	RTS


demo	lea	bpldef,a0
	move.l	#screen,d0
	move.w	d0,2(a0)
	swap	d0
	move.w	d0,6(a0)

	move.l	#copper,$dff080
	move.w	#SET!COPEN!BPLEN!DMAEN,$dff096

loop	btst	#6,$bfe001
	bne	loop
	rts

;-----------------------------------------

	section	chip1,data_c

copper	dc.w	FMODE,3
	dc.w	DDFSTRT,$30
	dc.w	DDFSTOP,$b0
	dc.w	DIWSTRT,$2c82
	dc.w	DIWSTOP,$2cc0

	dc.w	BPL1MOD,-40	; reduce screen to 1 repeating line (for testing)
	dc.w	BPL2MOD,-40
	dc.w	DMACON,CLR!SPREN

bpldef	dc.w	BPL1PTL,0
	dc.w	BPL1PTH,0

	dc.w	BPLCON1,0
	dc.w	BPLCON2,KILLEHB
	dc.w	BPLCON3,0

	dc.w	COLOR00,0
	dc.w	COLOR01,$dca

;***** scandoubler testing area #0 - OK *****

	IF	TEST=0

	dc.w	BPLCON0,BPU1!COLOR	; 1 bpl - OK

	ENDIF
	

;***** scandoubler testing area #1 - horiz sync sync *****

	IF	TEST=1

	dc.w	BPLCON0,BPU1!COLOR	; 1 bpl - OK

	dc.w	$6001,-2
	dc.w	$100,BPU1		; 1 bpl - distorted with scandoubler

	dc.w	$9001,-2
	dc.w	$100,0			; blank screen - distorted with scandoubler

	dc.w	$c001,-2
	dc.w	$100,COLOR		; blank screen - OK

	dc.w	$f001,-2
	dc.w	BPLCON0,BPU1!COLOR	; 1 bpl - OK

	ENDIF

;***** scandoubler testing area #2 - horiz & vert sync *****

	IF	TEST=2

	dc.w	$100,BPU1		; 1 bpl - sync is completely fucked
					; (COLOR bit cleared in copperlist)

	ENDIF

;***** scandoubler testing area #3 - signal jam *****

	IF	TEST=3

	dc.w	$100,BPU1		; 1 bpl - sync is completely fucked

	dc.w	$a001,-2
	dc.w	$100,BPU1!COLOR

	dc.w	$d001,-2
	dc.w	$100,0			; blank screen - fucked too

	ENDIF

;***** end of scandoubler testing area *****


	dc.l	-2	; end of copper

;----------------------------------------

screen	blk.l	10,$00ff0f0f	;-)

