Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Productions > Multiple Buffering Demos
2025-04-18 21:23
Mr SQL

Registered: Feb 2023
Posts: 158
Multiple Buffering Demos

This thread is inspired by Sokrates double buffering thread:
Release id #252024 : C64ColorRamDoubleBuffer

In computer science, multiple buffering is the use of more than one buffer to hold a block of data, so that a "reader" will see a complete (though perhaps old) version of the data instead of a partially updated version of the data being created by a "writer".
https://en.wikipedia.org/wiki/Multiple_buffering

Are there any Multiple Buffering Demos?

This demo shows one example:
Christmas Inertia

This example is frame based. The display buffers are prepared prior to rendering the screen and can be updated with lazy writes while the screen is displayed.

The colorRAM in this example is static but the development kit now supports multiple buffering for colorRAM.
 
... 5 posts hidden. Click here to view all posts....
 
2025-04-19 16:35
chatGPZ

Registered: Dec 2001
Posts: 11499
Mmmh i have used triple buffers somewhere - but i can't remember what effect it was /o\
2025-04-19 16:51
WVL

Registered: Mar 2002
Posts: 923
The bitmap-mover in Halloweed IV uses a triple buffer. This is to save cycles preparing the next bitmap (which is shifted up by 6 rows). The part copies bytes from the displayed bitmap to the next bitmap (but 6 rows higher) and can reuse the byte for the third bitmap (12 rows higher).

This was needed to make the >25 rows of bitmap data possible (besides copying the bitmap up, the part also has to copy a new line at the bottom in each frame and the data also gets reused in bitmaps 2 and 3). Without triple buffering the copying was too slow.

The copies are also optimized to not pass page boundaries and such things.
2025-04-19 20:01
hollowman

Registered: Dec 2001
Posts: 475
Nothing But Code/Beyond Force
"...a piece of advice to coders outthere: use triple buffering to prevent frame update bugs.
.. i've seen some terrible bugs in c64 and pc-demos lately."
2025-04-19 21:10
mankeli

Registered: Oct 2010
Posts: 152
First effect in Skybox (scrolling petscii screen) was doublebuffered! :P

But since it was in screen mode, and d800 can't be doublebuffered in full resolution, it was updated in several passes less tall passes while racing the beam..

And afaik on Atari ST, some of the largest rotating 3d objects are done with multiple buffers (like 16 or more) in a such way that CPU renders frames as fast as it can, and then interrupt switches buffers 50Hz. It's a very obvious thing but apparently not very common on Amiga or something :)
2025-04-22 21:43
Monte Carlos

Registered: Jun 2004
Posts: 370
I feel,the technique is too widely applied to discuss in a thread. Even mentioning only the names of releases with dbl bffr would fill a bible.
2025-04-22 21:58
chatGPZ

Registered: Dec 2001
Posts: 11499
It'd indeed be easier to just list the ones that claim to do so, but actually don't :)
2025-04-22 23:51
Krill

Registered: Apr 2002
Posts: 3070
Triple-or-more buffering isn't so common on C-64 now, is it? :)
2025-04-22 23:52
chatGPZ

Registered: Dec 2001
Posts: 11499
Not what the original troll was about though :)
2025-04-23 06:04
Mr SQL

Registered: Feb 2023
Posts: 158
Quoting Krill
Quoting Mixer
I guess the reason for third buffer was that to use the calculation time effectively. f.ex if it takes 1.5 frames to draw, then you lose 0.5 frames until you can swap the displayed bitmap. So, begin drawing 3rd frame instead.
Triple-buffering also helps if there is some non-trivial variation in render times from one frame to the next.


Yes I made a sequel with multiple color RAM buffers and needed an extra frame to accommodate:

Inertia Zones 2

I was trying to do this without the extra frame but not enough cycles. Fortunately the update is infrequent just when the level is cleared so the extra frame is not noticed and the smooth cadence stays the whole round. I agree that is a primary reason for double and multiple buffering.

Ring Raiders keeps a smooth cadence by always taking two frames (or one double length frame) to render display buffers so color cycling can be part of the animation.
2025-04-23 20:42
Mr SQL

Registered: Feb 2023
Posts: 158
Quoting WVL
The bitmap-mover in Halloweed IV uses a triple buffer. This is to save cycles preparing the next bitmap (which is shifted up by 6 rows). The part copies bytes from the displayed bitmap to the next bitmap (but 6 rows higher) and can reuse the byte for the third bitmap (12 rows higher).

This was needed to make the >25 rows of bitmap data possible (besides copying the bitmap up, the part also has to copy a new line at the bottom in each frame and the data also gets reused in bitmaps 2 and 3). Without triple buffering the copying was too slow.

The copies are also optimized to not pass page boundaries and such things.


Quoting cobbpg
Stunt Car Racer doesn't waste time either after finishing work on frame 2 while presenting frame 1, it immediately starts processing the physics calculations for frame 3. It works out because that part of the workload always takes long enough that it can start presenting frame 2 by the time it needs to clear the back buffer.


Excellent multiple buffering engine details.

The engine doing the multiple buffering in Inertia is a soft blitter modeled after the ANTIC chip in the Atari 400/800.

This is a Display list scripting engine with scripting commands that can be programmed from assembly or BASIC.

The display list programs take an LMS (load memory scan) address to buffer all or part of the screen. And it adds an extra [intrinsic] JVB assembly instruction - jump after vertical blank - this runs the display list programs (or jumps to another set) again.

Just like ANTIC Display list programs are called only from within the vertical blanks.

What's different is you are already programming in both vertical blanks by running a gameloop in each one to saturate the available vertical blank cycles.

There is an option to raise an event to use a full frame if processing time beyond both vertical blanks is required.

This can be done constantly to half the framerate and greatly increase available cycles like in Ring Raiders.

The two RingRaiders binaries show this option to either insert a blank frame for MBR motion blur reduction or double the frame for more solidity.

This can also be done intermittently like the Inertia example when more cycles are needed for specific events.

I uploaded the BASIC program showing the display list programs to create the multiple buffering zones.

This scripting language can be programmed from Assembly or BASIC similarly.

JVB jump after vertical blank
The intrinsic scrollvirtualworldtoggle command is the JVB jump after vertical blank instruction.

You can see it being set to a different LMS address to render multiple screen zone buffers from the large tile bitmap backbuffer.

When it is set to 1 it uses an entire frame for rendering rather than the vertical blanks.

Sound list scripting language
I was inspired by display list programming to create a similar music list scripting language.

It allows programing the Tracker using "tracker scripts" in the chiptunes similar to ANTIC display list programming.

An MLI music scripting list similarly can JVB (jump after vertical blank) at any time in the sequence and can
call other music lists as events or repeat the same music list program like display list programming.
Previous - 1 | 2 - Next
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
trident
d0c
Beast/Crescent
Chesser/Blazon
Guests online: 137
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.6)
4 Coma Light 13  (9.6)
5 Codeboys & Endians  (9.6)
6 Edge of Disgrace  (9.6)
7 Signal Carnival  (9.6)
8 Comaland 100%  (9.6)
9 What Is The Matrix 2  (9.6)
10 Uncensored  (9.6)
Top onefile Demos
1 Scan and Spin  (9.9)
2 Nine  (9.8)
3 At the Cinema  (9.7)
4 Layers  (9.6)
5 Cubic Dream  (9.6)
6 Party Elk 2  (9.6)
7 Datastiltje 2014 Win..  (9.5)
8 Copper Booze  (9.5)
9 Onscreen 5k  (9.5)
10 Libertongo  (9.5)
Top Groups
1 Artline Designs  (9.4)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Performers  (9.3)
5 Censor Design  (9.3)
Top Musicians
1 Conrad  (9.7)
2 Reyn Ouwehand  (9.7)
3 Stinsen  (9.7)
4 LMan  (9.7)
5 Linus  (9.7)

Home - Disclaimer
Copyright © No Name 2001-2025
Page generated in: 0.074 sec.