QB Programming
|
|||
Example 1This program draws some random pixels onto a virtual screen that is larger than the display resolution and allows the arrow keys to be used to pan around the virtual screen's area. The program quits when the ESCAPE key is hit. Although the code can easily be modified, it uses a 320x240 color mode for the screen resolution and a 400x400 resolution for the virtual screen area. This example demonstrates the following:
Example 1/Phase 1The first phase of this example simply uses the planar VGA memory organization to get the job done. There are a fewer routines involved, this way, but the main example code exposes more of the detailed steps. You can download phase 1 in a file designed to run with QBASIC, as QBAVGA01.BAS or compressed as QBAVGA01.ZIP. This .BAS version is older and can't be directly built from the compiler version mentioned below, which has been updated as I continued to develop demonstration code. They have diverged from each other. Sorry. You can also download the collection of separate modules designed to operate with one of the compiler tools, compressed as QBCVGA01.ZIP. This is a collection of .BAS and .BI files, together with the .MAK file that the compiler editor environment can use to automatically load all the modules. The modules in this version are organized, based on the VGA model they expose. Whether you download the code designed for QBASIC or for the compiler editors, QB, QBX, or VBDOS, they will operate properly from the editor environment. They do not rely on accidental "features" of the compiler's generated code, such as integer addition that behaves like unsigned integer addition. The modules are relatively well documented, but a detailed understanding of the VGA registers may be required to fully comprehend why things happen exactly as they do. Example 1/Phase 2The second phase does exactly the same thing, except that I've added a few more modules to support the use of concepts for a current display page and an active drawing page. This model is similar to what you find in QBASIC, for example. The added modules are fairly easy to understand and add new concepts in very small steps. It's at QBCVGA02.ZIP. I've dropped the idea of maintaining a QBASIC version for this phase, though. If you want to put the modules together to make it work with QB, feel free. It should be rather easy to do. SummaryThis example is NOT designed to show off speed. I know that this is important, but it's even more important to understand the VGA first. So this example is focused on illustrating how (x,y) coordinates get placed into the VGA and in demonstrating some of its features and hardware. A later example will demonstrate how to focus on speed, instead. |
|||
Quick Links: | |||
|
|||
Creation Date: Mon 29-Mar-1999 15:19:18 Last Modified: Sun 09-Apr-2000 20:45:53 Copyright (C) 1999, 2000 Jonathan Dale Kirwan |