TRS-80 Tips and Tricks - Graphics

General Overview of TRS-80 Graphics

The TRS-80 had very rudimentary graphics. Little rectangles could be displayed to a maximum of 128 squots (square dots) across by 48 down, always beginning with row 0.

Squots could be put onto the screen with the SET(X,Y) command, removed with the RESET(X, Y) command, and checked for on/off status with the POINT (X, Y) command.

However, using SET/RESET was the slowest way to manipulate graphics and to do anything approximating gaming one would need another method.

In addition to the SET/RESET to control each squot, the TRS-80 had a character set which would include a 2 x 3 squot matrix. These characters, from 128 through 191, ran the gamut from completely off/black (128) to completely on (191), and everything in between.

The 2 x 3 matrix running from 128 to 191 was actually an 8-bit binary representation of a 7 bit number "1xxxxxxx" so if you wanted the top two squots it would be "10000011", the middle 2 squots would be "10001100", etc. The actual CHR$(xx) representations appear below on this page.

If you don't want to construct the block from that kind of binary, think of them as their decimal representations. The top 2 boxes would be 1 and 2. The middle boxes would be 4 and 8. The bottom boxes would be 16 and 32. So if you wanted a block that had only the left 3 lit up, you would add 1, 4, and 16 to the base of 128, which would give you CHR$(149) or Graphic 149.

But there's more!! While you could use PRINT and PRINT@ to put those CHR$(xxx) matrices on the screen (putting up 6 squots at once), you could also pack them into strings and move those strings around. This is called "String Packing" and is virtually identical to the packing technique used in embedding machine language routines in BASIC programs. String Packing is explained on the String Packing page.

Character Sets

Japanese Kana Character Set

Japanese Kana
(Default)

Dingbats Character Set

Dingbats

The TRS-80 Model III and 4 had alternate character sets built in, which included some characters that could be used in gaming. There were a couple of ways to access those:

  • CHR$(21) - Printing CHR$(21) would toggle the space compression codes from ASCII 192 - 255. The problem with using a toggle is that you would not be in a position to know which way those were set due to other programs which may have been run before yours. You could be trying to turn the codes on, but wind up turning them off.
  • CHR$(22) - Printing CHR$(22) would toggle between the Japanese Kana character set (the default) and the dingbats. Since this is a toggle, you have the same problem as you do for CHR$(21).
  • POKE 16912,x - 16912 is the mask location for port ECH. This port controlled a lot of things including CPU speed, the cassette motor, and the I/O bus. But it also controlled single and double width characters and the alternate character set. Since this was not a toggle, it could be set to reliable turn on or off those items. To control those, you needed to set the options at the bit level (more information can be found on the RAM Address page). Bit 2 would control the width (0=normal, 1=double) and Bit 3 would control the character set (0=Kana,1=Dingbat). For those less experienced, if you don't mind having the cassette motor off, the width as normal, the I/O bus as disabled, disabled video waits, and 2mhz CPU speed, you would POKE 16912,8 (which is bit 4 on) to change to the dingbats and POKE 16912,0 (which is bit 4 off ... well, its every bit off) to change to Japanese.

TRS-80 Graphic Worksheet

Video Display Worksheet
Click the image to download

Graphic Characters

Since the TRS-80 screen is black, each square represents what the screen would look like with that character on it. For example, 128 shows nothing and 191 shows a completely filled in block.

Graphic 128128
Graphic 129129
Graphic 130130
Graphic 131131
Graphic 132132
Graphic 133133
Graphic 134134
Graphic 135135
Graphic 136136
Graphic 137137
Graphic 138138
Graphic 139139
Graphic 140140
Graphic 141141
Graphic 142142
Graphic 143143
Graphic 144144
Graphic 145145
Graphic 146146
Graphic 147147
Graphic 148148
Graphic 149149
Graphic 150150
Graphic 151151
Graphic 152152
Graphic 153153
Graphic 154154
Graphic 155155
Graphic 156156
Graphic 157157
Graphic 158158
Graphic 159159
Graphic 160160
Graphic 161161
Graphic 162162
Graphic 163163
Graphic 164164
Graphic 165165
Graphic 166166
Graphic 167167
Graphic 168168
Graphic 169169
Graphic 170170
Graphic 171171
Graphic 172172
Graphic 173173
Graphic 174174
Graphic 175175
Graphic 176176
Graphic 177177
Graphic 178178
Graphic 179179
Graphic 180180
Graphic 181181
Graphic 182182
Graphic 183183
Graphic 184184
Graphic 185185
Graphic 186186
Graphic 187187
Graphic 188188
Graphic 189189
Graphic 190190
Graphic 191191