Double buffering on the Spectrum

The place for codemasters or beginners to talk about programming any language for the Spectrum.
User avatar
Ast A. Moore
Dynamite Dan
Posts: 1074
Joined: Mon Nov 13, 2017 3:16 pm

Re: Double buffering on the Spectrum

Post by Ast A. Moore » Mon Apr 16, 2018 9:25 am

djnzx48 wrote:
Mon Apr 16, 2018 9:21 am
Sorry, I was meaning to ask how the +2A/+3 floating bus differs from on the Sinclair machines.
Yup. Got it. See my edit above . . . uh . . . the previous page, as of now. ;)
1 x
Every man should plant a tree, build a house, and write a ZX Spectrum game.

Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.

User avatar
Ersh
Microbot
Posts: 185
Joined: Mon Nov 13, 2017 1:06 pm

Re: Double buffering on the Spectrum

Post by Ersh » Mon Apr 16, 2018 9:50 am

Ast A. Moore wrote:
Mon Apr 16, 2018 9:15 am
... If there’s enough interest in the subject, I’ll do a separate writeup, something along the lines of “The Definitive Guide to Using the Floating Bus” with an actual example and make a separate post about it.
Please do. :)
0 x

User avatar
utz
Dizzy
Posts: 53
Joined: Wed Nov 15, 2017 9:04 am
Contact:

Re: Double buffering on the Spectrum

Post by utz » Mon Apr 16, 2018 6:44 pm

Ersh wrote:
Mon Apr 16, 2018 9:50 am
Ast A. Moore wrote:
Mon Apr 16, 2018 9:15 am
... If there’s enough interest in the subject, I’ll do a separate writeup, something along the lines of “The Definitive Guide to Using the Floating Bus” with an actual example and make a separate post about it.
Please do. :)
Here's some more interest ;)
0 x

Wall_Axe
Microbot
Posts: 175
Joined: Mon Nov 13, 2017 11:13 pm

Re: Double buffering on the Spectrum

Post by Wall_Axe » Mon Apr 16, 2018 6:52 pm

if you put the still stuff like score and logo in the top third of the screen
and simply used interrupt mode 2,
to use the time the raster takes to traverse the first third of the screen..
to draw the sprites on the bottom two thirds

how is that better/worse than...

putting the still stuff in the bottom third of the screen
waiting for floating bus to indicate raster is two thirds of the way down
drawing sprites in first two thirds of screen


it seems like you still get the same amount of time to draw stuff?

does the floating bus tell you when the raster is in the border? that would give more time to draw sprites
0 x

spectron
Berk
Posts: 22
Joined: Thu Mar 29, 2018 2:27 pm

Re: Double buffering on the Spectrum

Post by spectron » Mon Apr 16, 2018 8:00 pm

As already mentioned, there is no definitive answer.

Being pedantic I'd like to leave the double buffering term for the 128k ability to swap memory whereas I'd always call the term of writing off screen then copying to the visible screen as back buffering. But that's a moot point.

Most solid 3d stuff wrote to aback buffer (starstrike2 for example) and so did games like Elite. I used it to just draw the top 3d section for the conversion of Accolade's Gunboat and from memory used the stack to copy the data and also rearranged the off screen buffer to a more sensible layout with each line following the other in memory.

When doing the 100m and hurdles in Summer games, the code blitted the bottom sprites straight after the vblank then the top sprites later once the beam had gone down the screen. It did initially cause issues because the code was written in top memory but then the other coder combining all the events together assembled it into contended memory so everything started to flicker
0 x

Wall_Axe
Microbot
Posts: 175
Joined: Mon Nov 13, 2017 11:13 pm

Re: Double buffering on the Spectrum

Post by Wall_Axe » Mon Apr 16, 2018 8:49 pm

" used the stack to copy the data and also rearranged the off screen buffer to a more sensible layout with each line following the other in memory."

this does sound like the best way for a lot of games
0 x

AndyC
Manic Miner
Posts: 234
Joined: Mon Nov 13, 2017 5:12 am

Re: Double buffering on the Spectrum

Post by AndyC » Mon Apr 16, 2018 9:35 pm

spectron wrote:
Mon Apr 16, 2018 8:00 pm
Being pedantic I'd like to leave the double buffering term for the 128k ability to swap memory whereas I'd always call the term of writing off screen then copying to the visible screen as back buffering. But that's a moot point.
Strictly speaking, double buffering is any technique which uses a single back buffer to draw in that is then used to update the screen (with triple buffering being the same but with two buffers and the main screen). The "proper" term for a double or triple buffer which uses a hardware switch to swap the buffers over is page flipping.
0 x

User avatar
MonkZy
Dizzy
Posts: 89
Joined: Thu Feb 08, 2018 1:01 pm

Re: Double buffering on the Spectrum

Post by MonkZy » Mon Apr 16, 2018 9:54 pm

Thank you all for this incredibly illuminating thread.

I have successfully coded a working sinus-scroller, although currently it flickers rather badly. My method could be described as placing 28 sprites along a pre-calculated sine wave (i used BASIC to create a lookup table which I copied into my source code). Each character/sprite memory address is calculated real time and the character is bit-shifted into position a line at a time, no lookup-tables. After a HALT I clear all the characters (by ld'ing 0's into RAM over each character position) and start over. I am starting to think I need some serious optimisation or possibly more lookup tables to achieve a true 50hz scroller. I most certainly will need to work out the floating bus method of sync'ing. Using HALT you waste the time the raster takes to fill the bottom border, and you are forced to place your scrolling text at the bottom of the screen.

I will continue, armed with more knowledge after reading this thread.
0 x

dfzx
Microbot
Posts: 165
Joined: Mon Nov 13, 2017 6:55 pm
Location: New Forest, UK
Contact:

Re: Double buffering on the Spectrum

Post by dfzx » Tue Apr 17, 2018 7:59 am

Wall_Axe wrote:
Mon Apr 16, 2018 6:52 pm
if you put the still stuff like score and logo in the top third of the screen
and simply used interrupt mode 2,
to use the time the raster takes to traverse the first third of the screen..
to draw the sprites on the bottom two thirds

how is that better/worse than...

putting the still stuff in the bottom third of the screen
waiting for floating bus to indicate raster is two thirds of the way down
drawing sprites in first two thirds of screen


it seems like you still get the same amount of time to draw stuff?

does the floating bus tell you when the raster is in the border? that would give more time to draw sprites
My understanding, which might stand correction :) :

using IM2 tells you when the raster is at the start of the top border, so from there you get the time it takes to draw the top border, plus the time it takes to draw your static stuff at the top of the display.

Using the floating bus, you get the time it takes to draw your static stuff at the bottom of the display, plus the lower border, plus the top border.

So floating bus gives you more time, and has the advantage that your play area is at the top of the screen, which is normally aesthetically better.
1 x

giorgio.denunzio
Berk
Posts: 1
Joined: Tue Apr 17, 2018 8:11 am

Re: Double buffering on the Spectrum

Post by giorgio.denunzio » Tue Apr 17, 2018 8:12 am

Hi all!
I've just registered to this interesting Forum, and I'have not read the whole thread yet, so perhaps the information I am giving you is of little interest, but in these days there has been a discussion on the floating-bus subject at https://www.facebook.com/groups/z80asm/ ... 271378839/
I am conducting some tests, at present on the ZX48k (emulated, by now). In case you are interested, please take a look. On the other hand I'll read with attention this thread, which looks really interesting.
Thanks
Giorgio
0 x

Post Reply