Double buffer grey scale?

Any discussions related to the creation of new hardware or software for the ZX80 or ZX81
KayBee
Posts: 12
Joined: Mon Feb 13, 2017 5:34 pm

Re: Double buffer grey scale?

Post by KayBee »

Gray effect aside, I would love to see how you are double buffering for smoother animation. Please share an example.

Thank you.

KB
monzamess
Posts: 25
Joined: Sat Jul 08, 2017 8:39 pm

Re: Double buffer grey scale?

Post by monzamess »

I would also like to see how double buffering is done on ZX81. I am just playing around with z88dk right now and not getting too far with that.
Lardo Boffin
Posts: 2160
Joined: Sat Nov 26, 2016 2:42 am

Re: Double buffer grey scale?

Post by Lardo Boffin »

Sorry I missed the earlier question!

Conceptually it is pretty easy (in low resolution mode) - the location of the screen file is held in a system variable.

Create a second screen file with an identical structure and when you have finished building it change the system variable to point to the second screen file.

Now update the original screen file and when finished change the system variable back to the original location.

Repeat.

I have an example I can post (it is fairly rudimentary but works) but it will be a few days before I will be able to.
ZX80
ZX81 iss 1 (bugged ROM, kludge fix, normal, rebuilt)
TS 1000 iss 3, ZXPand AY and +, ZX8-CCB, ZX-KDLX & ChromaSCART
Tatung 81 + Wespi
TS 1500 & 2000
Spectrum 16k (iss 1 s/n 862)
Spectrum 48ks plus a DIVMMC future and SPECTRA
Lardo Boffin
Posts: 2160
Joined: Sat Nov 26, 2016 2:42 am

Re: Double buffer grey scale?

Post by Lardo Boffin »

Sorry it took a while to get time to post this!

I have attached a few files which show a double buffering example, albeit a very simple one!

Everything required to modify or build the files is in the attachments. To build it on a Windows PC open CMD and navigate to the folder where you put the files. Type zxasm animation01 and press enter. You can then run the animation01.p in EightyOne etc.

The process is: -

Fill buffer one with black squares
Fill buffer two with black squares
Place one white dot in buffer two
Repeatedly switch between the two buffers by changing the value of D_FILE and DF_CC (these variables tell the ZX81 ROM display routine where to look for the screen data)

Buffer one is just a location in memory big enough to hold a full screen of data (although you could do less than a full screen as required)
Buffer two is a different location, again big enough to hold the full screen

Buffer one and two are defined in the file screen.asm. If you look you will basically see two complete ZX81 1K screens

The animation comes from rapidly switching between the two buffers merely by changing the value of D_FILE and DF_CC, as the example below: -

Code: Select all

   ld bc,bufferOne              ;set the current screen to buffer one
   ld (D_FILE),bc	        ;set D_File to the location of buffer one
   inc bc                       ;increment bc by 1
   ld (DF_CC),bc                ;set DF_CC to address of bugffer one plus 1
After calling this code the next time the screen is displayed it will be using the data in buffer one.

If you were to do this in a game for example you would do the following: -

1) Display a menu screen (in buffer one) and do the following when the game starts: -
2) Build buffer two while buffer one is being displayed
3) Display buffer two when it is finished
4) Check for user input
5) Build buffer one to show the next frame of animation (based on user input)
6) Display buffer one when it is finished
7) Check for user input and then jump to step 2

Any questions feel free to ask although I am no expert on this!

Lardo
Attachments
Animation Test01.zip
Double buffer example
(135.43 KiB) Downloaded 235 times
ZX80
ZX81 iss 1 (bugged ROM, kludge fix, normal, rebuilt)
TS 1000 iss 3, ZXPand AY and +, ZX8-CCB, ZX-KDLX & ChromaSCART
Tatung 81 + Wespi
TS 1500 & 2000
Spectrum 16k (iss 1 s/n 862)
Spectrum 48ks plus a DIVMMC future and SPECTRA
Lardo Boffin
Posts: 2160
Joined: Sat Nov 26, 2016 2:42 am

Re: Double buffer grey scale?

Post by Lardo Boffin »

This example bounces three little characters up and down by a pixel.
Attachments
bounce.p
(2.25 KiB) Downloaded 239 times
ZX80
ZX81 iss 1 (bugged ROM, kludge fix, normal, rebuilt)
TS 1000 iss 3, ZXPand AY and +, ZX8-CCB, ZX-KDLX & ChromaSCART
Tatung 81 + Wespi
TS 1500 & 2000
Spectrum 16k (iss 1 s/n 862)
Spectrum 48ks plus a DIVMMC future and SPECTRA
monzamess
Posts: 25
Joined: Sat Jul 08, 2017 8:39 pm

Re: Double buffer grey scale?

Post by monzamess »

Great! Hoping I have some time this weekend to really check it out!
Moggy
Posts: 3231
Joined: Wed Jun 18, 2008 2:00 pm

Re: Double buffer grey scale?

Post by Moggy »

In a similar vain I once did a fairly simple animation of a piston rising and falling inside a cylinder by building up two differing display files and placing them above a lowered ramtop, then LDIR'ing them back alternately which gave the effect of a single cylinder engine working at real speed.
User avatar
Andy Rea
Posts: 1606
Joined: Fri May 09, 2008 2:48 pm
Location: Planet Earth
Contact:

Re: Double buffer grey scale?

Post by Andy Rea »

excuse me for jumping in and ( kinda ) hi-jacking the thread... a while ago i wrote a little animation that used page flipping 8 pages if i remeber correctly by chaging page each frame it creates a very nice illusion of fluid movement, iirc it is much better viewed on a real CRT display due to the persistence of vision effect.

i believe the source code is in this zip here to

link to post viewtopic.php?f=6&t=609&p=5321&hilit=moreball#p5321

regards Andy
what's that Smell.... smells like fresh flux and solder fumes...
Moggy
Posts: 3231
Joined: Wed Jun 18, 2008 2:00 pm

Re: Double buffer grey scale?

Post by Moggy »

Andy Rea wrote: Thu Sep 07, 2017 7:38 pm excuse me for jumping in and ( kinda ) hi-jacking the thread... a while ago i wrote a little animation that used page flipping 8 pages if i remeber correctly by chaging page each frame it creates a very nice illusion of fluid movement, iirc it is much better viewed on a real CRT display due to the persistence of vision effect.

i believe the source code is in this zip here to

link to post viewtopic.php?f=6&t=609&p=5321&hilit=moreball#p5321

regards Andy
Hells teeth I remember this little bugger, what ever you do don't stare to long at it after half a bottle of scotch like I did. :oops:
Post Reply