Flicker

Hardware Hacking, Programming and Game Solutions/Cheats
Post Reply
User avatar
Bosco
Posts: 333
Joined: Tue Mar 04, 2014 11:49 pm
Location: Nottingham, UK

Flicker

Post by Bosco »

Hi.

I've hit a problem with flickering graphics.

To demonstrate I've made this short assembly program that puts the Dragon into PMODE 1, then repeatedly clears the screen and draws six coloured blocks vertically in the centre. Despite waiting for the `Field Sync Interrupt' before redrawing I still get a violent flicker over the upper portion of the screen.

Can anyone with more experience tell me where I'm going wrong?

I've attached the source and Bin files.

Thanks.

Code: Select all

; Flicker Test

				org $4000

; *********************************************
; Constants
; *********************************************		
GM04			equ $c0 ; colour graphics mode 4 (PMODE 1)

PIA1_PDRB		equ $ff22 ; peripheral interface adapter 1 data register B	
SCREEN			equ $0600 ; base address of screen
SCREEN_END		equ $1200

COL_GREEN		equ $0000
COL_YELLOW		equ $5555
COL_BLUE		equ $aaaa
COL_RED			equ $ffff

; *********************************************
; Initialisation
; *********************************************		
			; setup VDG & SAM	
			lda PIA1_PDRB
			anda #$07 ; preserve bits 0-2
			ora #GM04 ; overwrite bits 3-7
			sta PIA1_PDRB
			sta $ffc0 ; clear V0
			sta $ffc2 ; clear V1
			sta $ffc5 ; set V2
			sta $ffc7 ; base page 0

; *********************************************
; MAIN LOOP
; *********************************************	
MAIN_LOOP	lda $ff02
@WAIT_TV	lda $ff03
			anda #128
			beq @WAIT_TV ; wait for frame fly-back
			
			; clear screen
			ldu #COL_RED
			bsr CLR_SCREEN
			
			; draw coloured blocks
			ldx #SCREEN
			leax $0f,x

			ldu #COL_YELLOW
			bsr DRW_BLOCK

			ldu #COL_BLUE
			bsr DRW_BLOCK

			ldu #COL_GREEN
			bsr DRW_BLOCK

			ldu #COL_YELLOW
			bsr DRW_BLOCK

			ldu #COL_BLUE
			bsr DRW_BLOCK

			ldu #COL_GREEN
			bsr DRW_BLOCK

			bra MAIN_LOOP
		

			
; *********************************************
; Copy U into all screen addresses
; *********************************************		
CLR_SCREEN	ldx #SCREEN
@NXT_WORD	stu ,x++
			cmpx #SCREEN_END
			blo @NXT_WORD
			rts

; *********************************************
; Draw a block 2 bytes wide and 16 pixels high
; *********************************************				
DRW_BLOCK	ldb #$10
@NXT_WORD	stu ,x
			leax $20,x
			decb
			bne @NXT_WORD
			rts

Attachments
Flicker.rar
Execute Address &H4000
(906 Bytes) Downloaded 274 times
pser1
Posts: 1665
Joined: Sun Mar 25, 2012 7:32 pm
Location: Barcelona (SPAIN)

Re: Flicker

Post by pser1 »

Hello,
welcome to the forum!
I have not seen anywhere in the program a sentence to allow interrupts.
Something like
ORCC #$50
that would need another to cancel them before ending the program
ANDCC #$AF

Hope this would help
cheers
pere
pser1
Posts: 1665
Joined: Sun Mar 25, 2012 7:32 pm
Location: Barcelona (SPAIN)

Re: Flicker

Post by pser1 »

Hello,
I have been tying your example and it really shows the flicker in the upper part of the screen.
This means that you are taking too much time in your routine and so, the final part of this execution is done when the screen is being redrawn.
You can verify that just commenting the hardest part of your test, the line: BSR CLR_SCREEN
You will see that the image no longer flickers.
So, you can use some cycles from the moment the interrupt arises, but not more than a certain time limit (in time)
The ORCC #$50 is no needed, because these TV signals occur always.
best regards
pere
zephyr
Posts: 1474
Joined: Mon Jul 21, 2008 1:18 am

Re: Flicker

Post by zephyr »

You need to slow it down with a delay loop. Try the attached example.
Attachments
flicker_test2.zip
(1.08 KiB) Downloaded 274 times
User avatar
Bosco
Posts: 333
Joined: Tue Mar 04, 2014 11:49 pm
Location: Nottingham, UK

Re: Flicker

Post by Bosco »

Hi pser1, zephyr.

Thanks for taking a look. I suspected I might be drawing too much but didn't want to rule out other possibilities.

I'm experimenting at the moment, getting a feel for what the Dragon can do. I might try drawing to a `back buffer' and flipping the display page base address when the scanline flys back to the top of the screen.

Cheers.
Post Reply