Double buffer grey scale?
Re: Double buffer grey scale?
Gray effect aside, I would love to see how you are double buffering for smoother animation. Please share an example.
Thank you.
KB
Thank you.
KB
Re: Double buffer grey scale?
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.
-
- Posts: 2202
- Joined: Sat Nov 26, 2016 2:42 am
Re: Double buffer grey scale?
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.
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
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
-
- Posts: 2202
- Joined: Sat Nov 26, 2016 2:42 am
Re: Double buffer grey scale?
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: -
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
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
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 247 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
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
-
- Posts: 2202
- Joined: Sat Nov 26, 2016 2:42 am
Re: Double buffer grey scale?
This example bounces three little characters up and down by a pixel.
- Attachments
-
- bounce.p
- (2.25 KiB) Downloaded 266 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
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
Re: Double buffer grey scale?
Great! Hoping I have some time this weekend to really check it out!
Re: Double buffer grey scale?
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.
Re: Double buffer grey scale?
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
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...
Re: Double buffer grey scale?
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.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