One of the requirements for the ECE385 lab's is to create a pushbroom which uses a font that is at most 8 pixels (LEDs) high. One has a few options: s/he can plot the characters on graph paper, calculate the bit values, and then write the individual values out to a file as an array which can be read into a C program. Alternatively, one could rip a font from the X windows system, as is recommended in class. But there are other options for doing less work.
The Commodore 64 computer was introduced in the early 1980's as the successor to the VIC-20 computer. But computers used an 8-bit 6502 based microprocessor, and some custom chips for graphic and sound. The Commodore 64 has built in fonts that were called "character sets". Each character set consisted of 128 characters: the alphabet, numbers, some punctuation and other various symbols. Further, there were another 128 characters which were the same as the first 128, but the inverse image. (I.e., all bits that were 0 were 1, and all that were 1 were 0).
The characters were exactly 8x8 bits, which fits nicely into the requirements for our pushbroom lab.
However, there are a few obstacles to overcome before one can use them in in the lab.
First, the characters are not stored in a conventional format. That is, if a person enters the letter 'a', you have to do some translations to get the lower case 'a' character from the Commodore character set. In specific, the Commodore had two storage mechanisms for its characters:
To complicate matters, character sets were actually 4k files, 256 characters of "upper case/graphics" characters, and 256 characters of "lowercase/uppercase" characters. The former were special graphics characters not found on any other computer to this day, and the latter was the full upper and lowercase alphabet, with some punctuation and numbers.
While this sounds complicated (it is), it is still easy to rip the character sets to a form that we can use.
First, one must obtain a character set to use. The ROM based character set that came with the Commodore can be found at ftp://pub/cbm/firmware/characters and these files provide a good starting point. One can also poke around with an emulator such as FRODO or VICE, and download any of the literally thousands of Commodore demos that have been made over the past twenty (yes, TWENTY) years and find any number of character sets by different *artists* out there. The nice thing is, that some character sets are in MULTIPLES of 8. So there are 1x1 characters (8x8 pixels), 2x2 characters (16x16 pixels), 4x4 chars (32x32 pixels) and so on! You can find a nice 2x2 characterset for lab 3.
Moving on. When you get the characterset, if it is a ROM character set it will be 4096 bytes. You can use the unix `split` command to split the file into two 2048 chunks. From there, you have to convert the file. Why?
Commodore characters are drawn like so:
........ ...**... ..****.. .**..**. .**..**. .******. .**..**. .**..**.Notice that they go up and down. The above character "A" would stored as the bytes { 0, 24, 60, 102, 102, 126, 102, 102 }. However, we need the character to be like this:
........ ...***** ..****** .**..*.. .**..*.. ..****** ...***** ........Why? Because the pushbroom is veritcal, so we want to show vertical lines of the character. By rotating the character counterclockwise we can now treat each byte as one verticle line and show it on our LEDs. But how to do the conversion? I've written a small C program to do it called psc2asctbl.c. psc2asctbl.c not only rotates the characters, but it also outputs everything as a plain text file with a 2d array in it. This array can be easily referenced from another C program. The first index is the letter you want, and the second index ranges from 0-7, which represents the individual bytes which make up the veritcal lines of the character.
Now one has to figure out how to translate everything. There are ASCII to PETSCII tables to convert from ASCII to PETSCII. One good table can be found at http://www.ffd2.com/fridge/misc/petcom.c To use them, simply reference ascToPetTable[x] where x is the character you wish to convert from ASCII to PETSCII. You can also go the other way. Remember however that our character set files are in screen code format (the latter of the two methods discussed). There aren't any out there but one can use the following quick function:
unsigned char asciiToScreen(unsigned char _c) { if (_c >= 48 && _c <= 63) { /* 0 - ? */ return (_c-48)+(48); } else if (_c >= 65 && _c <= 90) { /* A - Z */ return (_c-65) + 65; } else if (_c == 64) { /* @ */ return 0; } else if (_c >= 91 && _c <= 96) { /* [ - ` */ return (_c - 91) + 27; } else if (_c >= 97 && _c <= 126) { /* a - ~ */ return (_c-97) + 1; } }So, how does one use all of this?
After you convert your file, and use the array data in your source code, you can simply do:
for (i=0; iVoila! REFERENCES:
Compute!'s 128 Programmer's Guide, 1985, Compute! Publications Commodore Hacking, 1992-2002, http://www.ffd2.com/fridge/chacking/
local cache of above.