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