Skip to content
This repository was archived by the owner on Jan 26, 2022. It is now read-only.

Double buffering

Peter Tillema edited this page Dec 1, 2018 · 1 revision

The 84+CE is capable of having a screen buffer and another buffer, which is perfect for games. You can display one buffer, while drawing to the other buffer, which isn’t visible. At the end of all the drawing commands, you can then just swap the LCD pointers with SwapDraw( to display the back buffer, and set the current visible buffer to the back buffer. It's very easy to use:

Begin
SetDraw(1)
While <conditon>
    <display sprites/objects>
    SwapDraw
    <do all math stuff>
End

You need to tell your program to draw always at the back buffer with SetDraw(1). Then your main loop starts. Right after you draw everything, like tilemaps/sprites/object, you need to swap the pointers with SwapDraw. Try to put the math after swapping the pointers! That is, it might happen that the screen updated while you do your math, in which case you don't need to wait for the LCD anymore to switch. Then your program loops again, drawing to the back buffer, and displaying that buffer at the end of the loop. This has the main advantage that you don't see the screen objects being drawn. Instead, it displays all the objects at the same time!

Clone this wiki locally