"Pixelator" is an easier way to design custom characters for the VIC. Three accompanying programs let you save and load the character data from cassette and convert it into DATA statements – ready to use in a program. If you don't want to type everything in, the author has offered to make tape copies (see information at the end of the article).
The first time you design your own characters on the Commodore VIC-20, the process can be downright thrilling. Marking off graph paper in eight by eight squares and drawing in a figure. Converting each line into a number as if the dark squares were binary one and the light squares were binary zero. Storing the numbers in memory.
Then you POKE the magic address, 36869. The screen fills with gobbledygook. But wait! Isn't that a space ship there where the "A" of READY is supposed to be? And that three-legged alien must be the "D."
Once the thrill wears off, the work can turn to drudgery. Converting your design into numbers is bad enough, but the job of typing all those numbers into DATA statements is not only boring but also subject to typographical error. A slip of the finger and your beautiful rocket cruiser looks as if it had been shot full of laser holes.
Designing Characters With Pixelator
A program called "Pixelator" restores some of the thrill of designing screen characters. Pixelator gives you four large eight by eight work areas on the screen for creating, editing, and comparing characters. Pixelator then stores those characters in RAM. On standard VICs with 3.5K memory, Pixelator will store up to 64 characters. With additional memory, the program will store up to 128 characters; it also can retrieve from memory any character you have already stored. You can even copy from the VIC's own ROM character set and change those characters to suit your needs.
Like most small computers, the VIC stores mosaics or maps of its characters in ROM (addresses 32768 to 36863). Unlike some other computers, whose characters may be five pixels wide by seven pixels tall, the VIC's characters are eight by eight. (A pixel is simply the smallest portion of the video image that a particular computer can control.) That makes the VIC's characters look a bit squat, but it's a tidy use of memory. Eight bytes are needed to describe a single character, with each byte corresponding to a horizontal line of the character. The vertical information comes from breaking the bytes into binary ones and zeros, corresponding to dark and light areas.
Just Enough Memory
By POKEing different numbers into address 36869, you can change where the Video Interface Chip looks for its character maps. You do this automatically when you change the keyboard from graphics to text mode. Graphics is a value of 240 at 36869, and text is 242. The value in between, 241, represents reversed graphics characters, but using the reversed characters doesn't normally change the value at 36869.
A value of 252 moves the map location to 4096, the start of standard 3.5K memory. Above 252 the corresponding address increases by increments of 1024, up to 7168 for a value of 255. Because of the length of the Pixelator program, it uses the highest value. (For a fuller explanation of what happens at address 36869, consult Jim Butterfield's "Browsing the VIC Chip" in the April 1982 issue of COMPUTE!.)
The Pixelator program, once it is up and running, consumes almost 3K of memory. On VICs that haven't been expanded, that leaves just room enough to store 64 characters. That limit coincides with the fact that the second half of the map memory starting at 7168 corresponds to screen memory in most machines. We'll discuss a way of getting around this 64-character limit later.
Of course, with expanded memory, all you have to do is select a memory location that doesn't interfere with screen memory. Sometimes the problem is solved automatically because the screen memory moves (as do the screen color addresses). The three variables in line 20 allow you to change the program to compensate. XX is map memory and should always be a multiple of 1024. SC is screen memory. CL is color memory.
When you run Pixelator, you first are offered a choice of creating a new character or retrieving an old one from memory. The choices are color-coded green and cyan, respectively. If you select "new character" by pressing the programmable key Fl, the border changes from white to green, and you are asked to select one of the four work frames by keying Fl, F3, F5, or F7. Next you are asked to select the character at the address where you intend to design a new shape.
Four Options Following Design
Once you've selected a character, you'll see a half-height dot screen figure pop up in the top left corner of the frame. That's your cursor, and you can move it anywhere within the frame by using the cursor controls. To design a character, use the space bar. SHIFT/SPACE leaves a trail of red spaces in its wake. Without shifting, the SPACE bar returns the spaces to white. You can clear a cluttered frame simply by holding the SPACE bar down until all the red is gone.
After you have worked on the character to your satisfaction, you have four options. Fl stores your creation in the appropriate eight bytes of memory and then returns you to the opening format. F3 aborts the frame, returning you to the opening format without storing the character. F5 renames the character, enabling you to reassign it to a memory location different from the one for which it originally was named. This is of more use when retrieving characters from memory than when creating new ones, but it works in both modes. F7 allows you to work on a series of characters without having to go through the "select frame – select character" process every time. The command stores the current character, jumps to the next frame, and increments the character name. You can keep doing this until you have stored the question mark, at which point you are returned to the opening format.
If at the opening format you opt to retrieve a character from memory, the border changes to cyan, and you are given five choices. Fl retrieves from RAM; i.e., it accesses either characters you have already stored or whatever garbage happens to be in memory at the time. F2 accesses the VIC's ROM characters from the graphics mode, and F4 calls up the reverse of those characters. F6 and F8 are for text mode, the latter key again applying to reversed characters. You can freely mix characters from all modes and modify them to suit your needs. (If you need a full alphabet to go along with your custom characters, there is a short cut, provided you store your characters at 7168. After POKEing 255 into 36869, you can use RVS ON to get any normal character from "@" to "?". RVS OFF gives you your custom characters. This works only at 255.)
From there you are asked to select frame and select character again, but if you call up a graphics character (or, in text mode, an uppercase character) from ROM, you will be asked to rename it to something with a screen value less than 64. You now have the same options as before: to store, to abort, to rename, or to store and increment. If you have renamed a character, both the original character and its new name will be incremented.
Saving Your Custom Characters
More than likely, you will want to use Pixelator to create characters for use in some other program, such as a video game. Three shorter programs allow you to save the information the Pixelator has created. To save the characters directly on cassette as a data file, interrupt the Pixelator with the STOP key and type NEW to get rid of the program. Then load "Pixaver" into the VIC. Pixaver allows you to save a block of characters of any size, up to 64, on tape as a single data file. The first number in the file represents the screen value of the first character; the second number is the last character. This allows you to record as many different blocks as you like. Each file will contain the information necessary to store the data in the right place. Also, for convenience, each file will be tagged with the name of its first character. Now you can turn your VIC off.
The "Pixeloader" program will read the data off the cassette and enter it back into memory. Notice line 10, which sets the value of XX, the start of map memory. By changing that value, you can load character data into many different memory locations, thus bypassing the 64-character limit. Be sure that XX is a multiple of 1024, or else the characters won't properly correspond to the keyboard.
A third accessory program, called "Pixdata," will convert a block of RAM character memory into DATA statements, one for each character. The line numbers of the DATA statements will correspond to the screen value of the characters, plus 5000. DATA statements are highly inefficient, memory-wise, for storing that information, but they are much more convenient than cassette data files because they can be included within a program, which saves you the trouble of loading the characters separately.
Pixdata is not as user-oriented as the other programs because it has been stripped down to bare essentials. You probably will have to modify some lines of Pixdata each time you run it. The values SR and LS initialized in line 30, for example, represent the first and last characters, respectively. If you have only 3.5K of free RAM, don't do more than 30 characters at a time, because you'll run out of memory.
What makes Pixdata interesting is that it self-destructs, saving you the chore of deleting it line by line to make room for your own program. (If you type Pixdata in by hand, be sure to save it on tape or disk before trying it.)
The secret of Pixdata lies in the way the VIC-20 stores BASIC lines. The first two bytes of a line represent the address of the next line. The third and fourth bytes are the line number. After that, the line consists of numbers that represent either tokens for BASIC commands (the token for DATA is 131) or the ASCII values of string characters. All numerals are treated as strings, so a DATA statement may need as many as three bytes to represent a single numerical value. The number 128, for example, becomes 49, 50, and 56. Throw in a 44 for each comma, and you see why a DATA statement can use up more than four times the memory needed to store the numbers it represents.
Pixdata starts creating DATA statements at 5120, which is represented by the variable ZZ in line 40. Line 10 also sets 5120 as the end of BASIC memory, thereby protecting the DATA statements from the program itself. When Pixdata Finishes creating DATA statements, it POKEs the low-high values of ZZ into the first and second bytes of line 1, the line that says "REM DELETE THIS LINE AFTER RUNNING. " This causes BASIC to skip from line 1 to the first DATA statement, ignoring the rest of Pixdata in between. When you delete line 1 (simply type a "1" on a blank line and hit RETURN), the line editor compacts the DATA statements to the beginning of memory, destroying Pixdata in the process. If by adding RAM you have changed the start of BASIC memory, be sure to adjust the two addresses in line 170 accordingly before running Pixdata.
To use the DATA statements in a program, you will need a line like the following:
FORL = SR TO LS : FORM = 0TO7 : READ C : POK XX + L * 8 + M, C : NEXTM : NEXTL
The values of XX (map memory), SR (first character screen value), and LS (last character) should be the same as they were in Pixdata.
Pixeloader and its companion programs should take some drudgery out of designing characters, but the programs themselves aren't much fun to type in from scratch. I will be glad to make cassette dubs of the programs for the standard fee of $3 a copy. Write "Pixelator" on a blank cassette and send it with a stamped, self-addressed mailer to James Calloway, Route 2, Box A-2, Morrisville, NC 27560.
The following articles in COMPUTE! provided valuable information and inspiration for the Pixelator: Jim Butterfield's "VIC Memory Map Above Page Zero" (January 1982); Doug Ferguson's "Large Alphabet for the VIC" and Butterfield's "More VIC Maps" (March 1982); Butterfield's "Browsing the VIC Chip " and Charles H. Gould's "Renumber VIC-20 BASIC Lines the Easy Way" (April 1982).