Double buffer grey scale?

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

Re: Double buffer grey scale?

Post by KayBee » Wed May 31, 2017 4:35 pm

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 7:39 pm

Re: Double buffer grey scale?

Post by monzamess » Sun Aug 20, 2017 7:58 pm

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: 627
Joined: Sat Nov 26, 2016 1:42 am

Re: Double buffer grey scale?

Post by Lardo Boffin » Sun Aug 20, 2017 8:05 pm

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.
ZX81 iss 1 (bugged ROM, kludge fix, normal, kit)
Iss 3 with ZXVid, another in nearly perfect box
TS 1000 iss 3, ZXPand AY, ZX8-CCB & ZX-KDLX
TS 1500
TS 2000
Spectrum 16k (iss 1 s/n 1499)
Spectrum 48k
Toastrack + DIVMMC future

Lardo Boffin
Posts: 627
Joined: Sat Nov 26, 2016 1:42 am

Re: Double buffer grey scale?

Post by Lardo Boffin » Wed Sep 06, 2017 10:31 pm

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 9 times
ZX81 iss 1 (bugged ROM, kludge fix, normal, kit)
Iss 3 with ZXVid, another in nearly perfect box
TS 1000 iss 3, ZXPand AY, ZX8-CCB & ZX-KDLX
TS 1500
TS 2000
Spectrum 16k (iss 1 s/n 1499)
Spectrum 48k
Toastrack + DIVMMC future

Lardo Boffin
Posts: 627
Joined: Sat Nov 26, 2016 1:42 am

Re: Double buffer grey scale?

Post by Lardo Boffin » Wed Sep 06, 2017 10:50 pm

This example bounces three little characters up and down by a pixel.
Attachments
bounce.p
(2.25 KiB) Downloaded 14 times
ZX81 iss 1 (bugged ROM, kludge fix, normal, kit)
Iss 3 with ZXVid, another in nearly perfect box
TS 1000 iss 3, ZXPand AY, ZX8-CCB & ZX-KDLX
TS 1500
TS 2000
Spectrum 16k (iss 1 s/n 1499)
Spectrum 48k
Toastrack + DIVMMC future

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

Re: Double buffer grey scale?

Post by monzamess » Thu Sep 07, 2017 3:06 am

Great! Hoping I have some time this weekend to really check it out!

Moggy
Posts: 1507
Joined: Wed Jun 18, 2008 1:00 pm

Re: Double buffer grey scale?

Post by Moggy » Thu Sep 07, 2017 3:39 pm

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: 1267
Joined: Fri May 09, 2008 1:48 pm
Location: notts UK

Re: Double buffer grey scale?

Post by Andy Rea » Thu Sep 07, 2017 6: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
6 x ZX81, 1 x TS1500 , 1 x +3e, 1 x timex 2040 printer, 1 x timex 2020 cassette deck, siclair printer and some spectrum

Moggy
Posts: 1507
Joined: Wed Jun 18, 2008 1:00 pm

Re: Double buffer grey scale?

Post by Moggy » Thu Sep 07, 2017 8:24 pm

Andy Rea wrote:
Thu Sep 07, 2017 6: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

Who is online

Users browsing this forum: No registered users and 3 guests