Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
 Welcome to our latest new user Brizio ! (Registered 2017-08-20) You are not logged in 
CSDb User Forums


Forums > C64 Coding > Preventing flickering = double-buffering?
2017-06-11 21:30
Rudi

Registered: May 2010
Posts: 98
Preventing flickering = double-buffering?

Hi,
do you use banks for "double buffering" or flicker-free drawing?

When I erase pixels I get flickering. I guess it does not only happen when the drawing is synched to the rasterbeam so I use banking for some kind of double buffering.

What do you guys use to prevent flickering?
Lets say you do dots or linedrawing and need to erase the pixels..

My idea is to draw in two banks and while showing one i erase and draw in the other. Then switch banks and do the same for the opposite bank and repeat.

The flicker should not occur when drawing is finished. I tried to sync $d012 to 252 and draw, but it still flickers.

	;----------------
	;double-buffering
	;----------------
	;try to draw when rasterbeam is away from screen
	;lda #252
	;cmp $d012	;raster
	;bne *-3

	lda IT0
	and #1
	beq drawjmp0
	jmp draw1
drawjmp0:	jmp draw0
draw1:
	#Line PX0, PY0, PX1, PY1, 0, 1	;draw (in bank 1)
	#Line QX0, QY0, QX1, QY1, 1, 0	;erase (in bank 0)

	;store old coordinates
	lda PX0
	sta RX0
	lda PY0
	sta RY0
	lda PX1
	sta RX1
	lda PY1
	sta RY1

	#SwitchBank bank4000			;switch to bank 1
jmp loop

draw0:

	#Line PX0, PY0, PX1, PY1, 0, 0	;draw (in bank 0)
	#Line RX0, RY0, RX1, RY1, 1, 1	;erase (in bank 1)

	;store old coordinates
	lda PX0
	sta QX0
	lda PY0
	sta QY0
	lda PX1
	sta QX1
	lda PY1
	sta QY1

	#SwitchBank bank0000			;switch to bank 0
jmp loop


Any ideas?
2017-06-11 22:09
Flavioweb

Registered: Nov 2011
Posts: 341
Maybe you should switch screens during VB, otherwise if the switch happen in the middle of the frame, some glitches appears...
2017-06-11 22:30
algorithm

Registered: May 2002
Posts: 682
What may come in useful is to put a dec $d020 at the beginning of a routine (such as your clear routine) if you use it. and then inc $d020 at the end.

When your program is running, that will tell you visually when the clear routine is running.
2017-06-11 22:32
Digger

Registered: Mar 2005
Posts: 241
As Flavio pointed out you should be able to draw anytime when you use double-buffering, it's more crucial to switch the bank display at the right time.

Also erase and then draw should happen in the same bank (while the other is shown). From your code comments it looks like you've been erasing and drawing the the opposite banks, which would explain the flicker.
2017-06-11 22:39
Rudi

Registered: May 2010
Posts: 98
yes, I was switching banks at the wrong time. such things happen when coding for too long, i dont see the obvious things. thanks for the replies anyhow.

It's solved now.
2017-06-12 07:23
Oswald

Registered: Apr 2002
Posts: 4054
waiting for vblank can be avoided by tripple buffering.

frame A is being drawn
frame B is on screen
frame C is ready to be shown when vblank is reached
2017-06-12 08:45
Mixer

Registered: Apr 2008
Posts: 225
Another way to avoid flicker is to run a circular coordinate buffer.

You have n dots on screen and you delete the oldest when you write a new one.

When you write a new dot, save the dot mem address to buffer, so you do not need to recalculate it when clearing.
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
aNdy/AL/Cosine
MetalSoftwareService
c0zmo/BLiSS
Dwangi/Fairlight
Nucleus/Desire
Harpoon
Guests online: 46
Top Demos
1 Uncensored  (9.7)
2 Edge of Disgrace  (9.7)
3 Coma Light 13  (9.6)
4 The Shores of Reflec..  (9.6)
5 Lunatico  (9.6)
6 Comaland 100%  (9.5)
7 Incoherent Nightmare  (9.5)
8 Wonderland XII  (9.5)
9 Comaland  (9.5)
10 Wonderland XIII  (9.5)
Top onefile Demos
1 Veterans of Style  (9.5)
2 Dawnfall V1.1  (9.5)
3 Daah, Those Acid Pil..  (9.5)
4 Treu Love [reu]  (9.4)
5 Dawnfall  (9.3)
6 SidRok  (9.3)
7 F1 Evolution  (9.3)
8 One-Der  (9.2)
9 Tunnel Vision  (9.2)
10 Game of Thrones [2sid]  (9.1)
Top Groups
1 Pond  (10)
2 Booze Design  (9.4)
3 Censor Design  (9.4)
4 Oxyron  (9.4)
5 Crest  (9.3)
Top Fullscreen Graphicians
1 Veto  (9.8)
2 Joe  (9.8)
3 Mirage  (9.7)
4 Jailbird  (9.6)
5 Hein  (9.5)

Home - Disclaimer
Copyright © No Name 2001-2017
Page generated in: 0.219 sec.