ADAM Graphics Workshop
by Solomon M. Swift
DIGGING AROUND
When I got my first ADAM, Christmas 183, 1 had an APPLE-II TM and a
TRS-80 MODEL-3. All I did was word processing; I didn't know the first
thing about programming. My biggest accomplishment in this area was to
learn about typing RUN and tapping the ENTER key. ADAM didn't seem to
offer what I needed and It consequently was relegated to the wasteland
of official dust collector; then Coleco announced its plan to drop the
ADAM from production. Instead of scurrying about to grab all the
software I could lay my hands on, I viewed the situation as a challenge
to finally delve into programming.
HUNTING FOR THE COLOR POKE
After I became familiar with a few of the BASIC commands, my first real
objective was to add color to BASIC. I had located a color chart for
ADAM's video chip and concluded that the standard TEXT screen color was
a value of 240. I went PEEKing around in the interpreter hunting every
single value of 240 and (there are 50 occurrences of that value in the
Interpreter) changing It to 23 (black letters on a cyan backdrop).
Needless to say, the system crashed MANY times; I knew absolutely
nothing of Z80 programming. After many frustrating hours I came upon
address 17115. It worked -- sheer nirvana! In the weeks that followed my
tinkering paid off by finding nine addresses to change screen colors,
three each for TEXT, GR, and HGR. Although I covered the fundamentals of
these color changes a few years ago, this information may be useful to
those of you who are new to ADAM or new to BASIC programming.
HIGH AND LOW NIBBLE COLOR VALUES
The Texas Instruments video chip that ADAM uses, the TI-VDP TMS-9918A,
has independent capabilities for background and foreground colors. In
TEXT mode you can consider the foreground to be the actual letters of
the alphabet that you see on the monitor screen; the background is the
fill color. The TI-VDP has its own 16 color values; see the chart on the
bottom of page 15 in this issue.
In order to set the TEXT mode color you have to send both the letter
color and the backdrop color to the video chip in ONE BYTE. Each byte
consists of 8 BITs, or two NIBBLEs of 4 bits each. All we do is put the
backdrop color in one nibble and the letter color in the other. The
letter color goes in the HIGH ORDER nibble; this is accomplished by
multiplying the color value (a four bit number) by 16.
Suppose that you want a letter color of dark blue. The TI-VDP value of
dark blue is 4; refer to the chart. Just multiply 4 times 16 to get the
high order nibble value of 64. Now POKE 64 into address 17115 (this is
SmartBASIC's text color address: POKE 17115,64 and tap the (RETURN) key.
Now enter TEXT and tap <RETURN> again, It is that easy. Now suppose you
want a backdrop color of white and a letter color of dark blue. Just
find the TI-VDP color value for white in the chart (it is 15) and add
that to 64 for a total of 79. Now enter POKE 17115, 79: TEXT and tap
<RETURN> -Viola!
THE COLOR TABLE
The color table at the top of page 12 saves you the trouble of doing the
math in computing letter and backdrop color combinations. Just find your
letter color preference in the left hand column and cross-reference it
with the backdrop color across the top. Then POKE that value into the
appropriate address.
In the following table FRG means foreground (or letter) color and BKO
means background (or backdrop) color.
For SmartBASIC 1.0:
POKE 17059, BKG (BORDER)
POKE 17115, FRG & BKG (NORMAL)
POKE 17126, FRG & BKG (INVERSE)
TEXT
POKE 25431, BKG (BORDER)
POKE 25471, FRG & BKG (WINDOW)
POKE 25568, FRG & BKG (TEXT)
HGR
POKE 18607, BKG (BORDER)
POKE 18633, FRG & BKG (WINDOW)
POKE 18711, FRG & BKG (TEXT)
GR
For SmartBASIC 2.0:
POKE 17184, BKG (BORDER)
POKE 17240, FRG & BKG (NORMAL)
POKE 17251, FRG & BKG (INVERSE)
TEXT
POKE 24695, BKG (BORDER)
POKE 16783, FRG & BKG (WINDOW)
POKE 24847, FRG & BKG (TEXT)
HGR
POKE 24695, BKG (BORDER)
POKE 24784, FRG & BKG (WINDOW)
POKE 24847, FRG & BKG (TEXT)
GR
Page - 13
THE PR#5 PROGRAM
My personal preference when writing programs for ADAM is the graphics
mode because it permits detailed, colorful graphics. Texas Instruments
refers to this as GM2 mode; in SmartBASIC It is called HGR2 (HGR is HGR2
with four or eight text lines at the bottom of the screen). The
limitation of BASIC's implementation of GM2 is that there is no easy way
to put text beside or inside the detailed graphics that you can draw.
You could use a high resolution vectored shape table designed as a font
set, but this option requires extra memory for the table (2K to 3K) plus
the subroutine to print the characters uses up vital memory too. A
couple of years ago I wrote a Z80 routine to put standard text on the
GM2 screen for Nibbles & Bit, but it required at least intermediate
programming knowledge just to make use of it.
Now we have "PR#5: HGR/HGR2 TEXT", my latest freeware contribution,
which uses little memory and is simple enough to use for even the novice
BASIC programmer. The program LIST is on page 14 of this issue of A.C.T.
Just type it in, SAVE it, and then RUN it. It does a check sum on the
data. If it prints the error message, check your data elements.
HOW TO USE THE PROGRAM
You use the PR15 command to print the graphics on the HGR or HGR2 screen
(it automatically adjusts for the four extra lines in the HGR2 mode).
Use it the same way that you use PR#1 or PR#2 to direct PRINTing, to the
ADAM printer or a dot matrix. Be sure to enter HGR or HGR2 first. For
example:
(tap (RETURN) after each line)
HGR
PR#5: PRINT "Now is the time": PR#0
You can also use the VTAB and HTAB commands to print text on the
graphics screen at specific locations. Be sure to put a semi-colon (; )
after to print statement if you prefer to not erase any graphics to the
right of the printed text. Here is how to position text:
HGR VTAB 6: HTAB 4
PR#5: PRINT "The quick red fox": PR#0
The PR#0 function simply returns you to normal TEXT screen output. Also
note that when you attempt to print beyond the bottom right corner of
the graphics window, the entire window will scroll up one text line just
as in TEXT mode.
You can also set the letter and backdrop color of individual text lines
within the graphics window. Address 25471 is used to set the window
color before the HGR command and the same address can be used before a
PR#5 command to set the color of a text line. Always BE SURE that 25471
contains different letter and backdrop color values. The following will
set the graphics window color to white and then print the text line in
black letters with a light green backdrop.
POKE 25471, 31: HGR
POKE 25471, 19: VTAB 4: HTAB 2
PR#5: PRINT "WOW! Color controll";: PR#0
POKE 25471, 23: VTAB 6: HTAB 2
PR#5: PRINT "A variety of color";: PR#0
HOW THE PROGRAM WORKS
The SmartBASIC patch uses several Z80 subroutines and further patches
some of the BASIC commands. The assorted routines are annotated in the
REMark statements. We'll detail the Assembly specifics of them in
subsequent issues.
The HTAB function is patched in line #'s 1900 thru 1940 to accommodate
its use In HGR and HGR2 graphics printing. Likewise, the VTAB command is
patched in line #'s 1800 thru 1840. The TEXT command is patched in line
#'s 1700 thru 1740; this copies the bit image (shape designs) of the
standard character set to a 1k buffer at address 56320. This buffer is
typically unused; however Intel-LOAD (my BASIC speed loader) does use
this memory. To use Intel-LOAD with this patch: enter TEXT, then bload
the speed loader, and CALL 56320 (as the manual describes). Any time you
enter the TEXT command, though, the Intel-LOAD routine will be
over-written.
The HGR2 function (used by HGR too) is patched in line I Is 1600 thru
1660. This sets up the margins for either HGR or HGR2 and sets the
default VTAB and HTAB to the upper left corner of the graphics window.
The heart of the whole function is in line #'s 1300 thru 1340. This
prints a single character on the graphics screen. Line #'s 1400 thru
1450 create a Z80 routine to print a string of characters and updates
the screen after each character is displayed. Line #'s 1500 and 1510
simply patch the otherwise unused PR#5 output vector to this string
print function. The routines in line #'s 1000 thru 1250 constitute the
subordinate functions for scrolling the graphics window when a character
is printed beyond the bottom right margin.
I hope that you Ill enjoy this patch and find some good uses for it in
your own programs. In an upcoming issue I'll LIST functions for PR#2,
PR#3, and PR#4.
Page - 14
10REM "PR#5:HGR/HGR2 TEXT"
20REM (c) MAR 1990 PHOENIX 2000
30REM public domain effective 15 MAY 1990
40REM do NOT remove these REMark statements
100LOMEM :28000
110POKE 17115,244:POKE 25471,244
120HOME:? "reading data..."
130FOR x=27600 TO 28000:POKE x,0:NEXT
1000REM ***** set bottom line color
1010DATA 1,31,1,33,1,19,58,127,99,50,0,0,197,6,8,175,133,16,253
1020DATA 111,193,120,50,1,0,6,8
1030DATA 175,129,16,253,79,58,1,0,71,58,0,0,89,22,0,197
1040DATA 245,213,229,205,38,253,225,36,209,241,193,16,242,201
1050FOR x=27709 TO 27765:READ mc:POKE x,mc:NEXT
1100REM ***** clear bottom line
1110DATA 1,31,1,33,1,19,197,6,8,175,133,16,253,111,193,124
1120DATA 198,32,103,229,120,50,0,0,6,8,175,129,16,253,79,58,0,0,71,89
1130DATA 22,0,197,213,229,175,205,38,253,225,36,209,193,16,243,241,201
1140FOR x=27655 TO 27707:READ mc:POKE x,mc:NEXT
1200REM **** scroll window up
1210DATA 62,1,245,1,248,0,33,0,216,30,8,87,229,213,197,205,29,253
1220DATA 193,209,225,21,229,213,197,205,26,253,193,209,225,122
1230DATA 198,33,87,229,213,197,205,29,253,193,209,225,21,205,26,253
1240DATA 241,60,254,20,32,204,201
1250FOR x=27600 TO 27654:READ mc:POKE x,mc:NEXT
1300REM ***** display one character
1310DATA 245,6,8,33,0,0,95,22,0,25,16,253,1,0,220,9,58,118,108,79,6,8
1320DATA
175,129,16,253,95,58,119,108,198,32,87,1,8,0,197,213,229,205,26,253,225,209,193
1330DATA 107,122,214,32,103,58,127,99,17,8,0,205,38,253,241,201
1340FOR x=27768 TO 27828:READ mc:POKE x,mc:NEXT
1400REM ***** print hi-res char and update screen
1405DATA
245,58,112,66,254,2,48,2,241,201,241,245,254,13,202,241,108,205,120,108,33,118,108
1410DATA
52,126,254,32,48,2,241,201,62,1,119,35,52,126,254,20,48,2,241,201
1420DATA 33,1,19,34,118,108,205,208,107,205,7,108,205,61,108,241,201
1430DATA 33,118,108,126,254,31,202,212,108,62,31,70,144
1440DATA 71,62,32,197,205,181,108,193,16,247,24,231
1450FOR x=27829 TO 27913:READ mc:POKE x,mc:NEXT
1500REM ***** enable pr#5
1510POKE 16223,181:POKE 16224,108
1600REM ***** patch HGR2
1610DATA 33,1,0,34,118,108
1620DATA 58,112,66,6,19,254,3,32,2,6,23,120,50,66,108,50,12,108
1630DATA 60,50,3,108,50,219,108,33,123,65,195,92,99
1640FOR x=27914 TO 27950:READ mc:POKE x,mc:NEXT
1650DATA 195,10,109
1660FOR x=0 TO 2:READ mc:POKE x+25433,mc:NEXT
1700REM ***** patch TEXT
1710DATA 50,113,66,33,0,220,17,0,0,1,0,4,205,29,253,201
1720FOR x=27951 TO 27966:READ mc:POKE x,mc:NEXT
1730DATA 195,47,109
1740FOR x=17222 TO 17224:READ mc:POKE x,mc:NEXT
1800REM ***** patch VTAB
1810DATA 33,119,108,113,53,205,107,102,201
1820FOR x=27967 TO 27975:READ mc:POKE x,mc:NEXT
1830DATA 205,63,109
1840FOR x=11346 TO 11348:READ mc:POKE x,mc:NEXT
1900REM ***** patch HTAB
1910DATA 33,118,108,113,205,79,102,201
1920FOR x=27976 TO 27983:READ mc:POKE x,mc:NEXT
1930DATA 205,72,109
1940FOR x=11325 TO 11327:READ mc:POKE x,mc:NEXT
2000TEXT:? "running data checksum..."
2010 tt=0:FOR x=27600 TO 27983: tt=tt+PEEK(x):NEXT
2020IF tt=41497 GOTO 2040
2030?:? " ERROR!!!":END
2040?:? " CHECKSUM OKAY.":END
Page - 15
Page 15 is a graphic page NOT INCLUDED containing the color tables and
color conversion tables with the corresponding peeks and pokes. PAGE IS
NOT INCLUDED AS A WHOLE.
Back to
Top
|