GWBasic Graphics
Screen 1
There are a number of screens available for GWBasic. The default screen
is Screen Zero. Screen 1 offers some advantages by providing graphics
and color attributes. The colors provided will vary, depending on the
hardware configuration of your computer station. Play around with the
COLOR and PALETTE statements and the attribute parameters in the LINE
and PRINT statements to select the best choice.
Just a
reminder that these exercises may be done on a floppy disk. This has
the distinct advantage of keeping all the incidental files created in a
location where they can be dealt with later. Of course, the exercise
may be done on the hard drive, but if some files get misplaces, they
may be hard to re-locate for subsequent deletion after the exercise.
Example of a Screen 1
graphics application
I have learned that the best way for me to create a program that I want
is to examine programs. I run them, evaluate them, edit them and
eventually get it the way I want. Copy and Paste this example into your
GWBasic folder and play around with it. I will make some comments that
may be helpful to you.
If
you
are
using
Native
DOS
(Windows
isn't
running)
then
the program will
need to be typed in because the drop down menu isn't available. Either
way will work nicely for this example. If you are using XP, then
GWBasic will necessarily be run under the Windows system. Using Windows
98 and earlier, GWBasic can be run from the floppy without calling
Windows by booting up on a floppy disk formated as a systems disk with
the GWBasic.exe program on it. Both methods have their advantage.
Copy and paste this program to be run with GWBasic......
10 KEY OFF: CLS
20 CL=100: PI=3.1416: K= 2*PI/360
30 SCREEN 1: COLOR 8
40 LINE (0,0)-(319,199),1,B,&H7FFF
50 LINE (0,CL)-(319,CL),1,,&HCCCC
60 LOCATE 2,2: PRINT "Sin..."
70 LOCATE 3,2: PRINT "Cos..."
80 '
90 '
100 FOR N=1 TO 720 STEP 5
110 X=N* (319/720) *.98+3:
120 Y=SIN(N*K)*90
130 PSET (X,Y+CL),2
140 Y=COS(N*K)*90
150 PSET (X,Y+CL),3
160 NEXT N
170 '
180 '
190 DEF SEG= &HB800
200 BSAVE "SCREEN.x01",0,16384
210 '
220 N$= INKEY$: IF N$="" THEN 220
230 SCREEN 2: SCREEN 0
240 END
250 SAVE "screen_1",A
Brief line by line explaination for the program
line 10
My customary opening code.
line 20
CL (center ordinate line)
PI
(the
value)
K
(conversion
factor
to
change
radians
to degrees)
line 30 Select screen 1
hardware configuration with color 8
line
40 Line ( box co-ordinates), color,
box instruction, style 0001-1111-1111-1111
line
50 Line (line co-ordinates), color,
no box or fill, style 1100-1100-1100-1100
lines 60-70 locate and post text
line
100 For N= 1 to 720 degrees in
steps of 5 degrees.
line 110
absissa= degrees * 319 max x/ max degrees.
*98
reduces
the
curves's
span keeping the last dot off the
right border.
+3
nudges the first dot a little from the left border.
line 120
ordinate= SIN (degrees*Radian conversion factor)* (max ordinate value)
line 130 posts a dot at the
(absissa, ordinate from center line), color 2
line 140
ordinate= COS (degrees*Radian conversion factor)* (max ordinate value)
line 150 posts a dot at the
(absissa, ordinate from center line), color 3
line
160 completes the FOR-NEXT
definition.
line 170-180 Define segment and Bsave this image
(just for kicks and giggles)
line 220 INKEY$ loops here
forever till N$ captures a keystroke... N$ other than ""
line 230
screen 2 first restores small text in screen 0
otherwise it will be large.
line 240 halts the program so the next
line isn't executed.
line 250 house-keeping. Makes
it easy to periodically back up my program.
Some notes
Notice that when running this program under Windows, that the ALT-ENTER
key exits GWBasic and returns to Windows because Native DOS necessarily
doesn't have Windows to return to. Our program returns to Screen 0 via
Screen 2 in order to work with the program that produces the Screen 1
display. Working in Screen 0 and running the program in Screen 1
becomes an important concept when using the GWBasic SCREEN instruction.
The program could be developed in Screen 1, but the large characters
make it unsightly to do so.
Using the color attributes can make the background color lignt so you
won't waste ink with hard copies.
When using Windows to run GWBasic, SCREEN 1 opens in full screen
instead of the DOS console. ALT ENTER will return to Windows rather
than to the DOS console as it does in Screen 0 mode.
Only a few of the graphic's features are displayed in this example. See
the GWBasic Users Manual for more of the many graphics instructions
such as LINE, COLOR, PALLETTE, CIRCLE, DRAW, VIEW, WINDOW .
The
display
may
be
saved
to a file in Screen 1 mode, as it was with Screen
0 by using the Bsave instruction to save the same memory data to an
image file. I may also be restored with a Bload instruction in the
Screen 1 mode. A screen capture to the Clipboard Buffer or a Bload
restore to screen 0 will return data that isn't recognizable as a
plot. Image data for the display is different between the screen modes.
This makes it difficult to make a hard copy of the image created in the
Screen 1 graphics mode.......
Just a thought for some
future BWBasic project: Create a program to convert the Screen 1 image
data format to Screen 0 format so that it may be copied to the
Clipboard Buffer for printing.
Summary
Screen 1 may be used to create graphics display using the GWBasic
mathmatical instruction. It also permits the use of ascii text tp
prompt the operatore for inputs needed in the plot.
The use of Screen 1 will depend on your stations configuration because
the Video display and Extended Video hardware has evolved a great deal.
A google search for CGA, EGA, VGA, XGCA, are a few search target
strings. The best way to learn your particular features is to
jump in and see what you can do. My example should work for most
configurations; however, there are many more features that you may wish
to use on your station.
In short.... play around and have fun.........