Optimiz6.Txt by Danny Gump danielgump@chainmailsales.com http://chainmailsales.com/virtuasoft This text file is the seventh in a guide for use by QB/QBASIC programmers to help optimize the program code for greater efficiency and/or give a program a more professional look.. If you have any questions, contact VirtuaSoft at gump@gnt.net. Address to Danny. (Note: This is not for the beginning programmer. A strong background in QB/QBASIC programming is highly recommended.) 7. DOUBLE-BUFFERING I a. GET-PUT storage format b. Using GET-PUT for double-buffering 7. DOUBLE-BUFFERING I a. GET-PUT storage format GET and PUT are the most efficient form of image storage that exists. This format basically tells a picture's width and its height then lists all the color values of the image. Below is a breakdown of the GET-PUT format as it stores an image in screen 13H as an INTEGER array. array%(0) = width of image in bits array%(1) = height of image in pixels array%(2) ... = listing of pixel values array%(n) For double buffering, the array's 0 element will have the value of 2560 because 13H has 320 pixels across at 8 bits each and 320*8=2560. The array's 1 element will have the value of 200 because 13H has 200 pixels in its height. Then all the remaining elements will have two pixels per element (INTEGERs are 16-bit and the pixels are 8-bit). So, the array will look as follows: array%(0) = 2560 array%(1) = 200 array%(2) = pixel at 0,0, pixel at 1,0 ... array%(n) = pixel at 318,199, pixel at 319,199 b. Using GET-PUT for double-buffering Now that you're an expert on GET-PUT arrays for 13H, you understand enough to POKE values into that array, right? It's basically the same as POKEing onto the screen except for a different memory segment. Below is a comparison of how POKEing into an array and onto the screen differ: SCREEN: DEF SEG = &HA000 POKE x% + 320& * y%, color% GET-PUT ARRAY: DEF SEG = VARSEG(array%(0)) POKE VARPTR(array%(2)) + x% + 320& * y%, color% It's now that much different, is it? The only difference is that you define a different memory segment, and you need to also include the array's offset (the offset of SCREEN 13H is 0, so an offset was never needed before), then it's the same POKEing formula after that. So to use this for double buffering, simply draw your screen image directly into this GET-PUT array, then PUT the final image on the screen like this: PUT (0, 0), array%, PSET. If you're wondering about how to POKE LINEs and CIRCLEs into a GET-PUT array, I will begin making a library that will do that and release it on my web site eventually. ... This concludes the lesson ...