Classic Computer Magazine Archive CREATIVE COMPUTING VOL. 9, NO. 1 / JANUARY 1983 / PAGE 234

An IBM PC character generator. C. Kenneth Fan.

An IBM PC Character Generator

The IBMPC character generator is a program for making your own characters. You can make up any number of characters, in sets of 1927, and use them within your other programs. It allows you to make customized characters for special purposes, such as letters of the Greek or Cyrillic alphabets, and cursive or underlined characters.

You can also use it to make pictures that are one character in size or composites made up of many characters. There are as many applications as your imagination will allow.

You need an IBM Personal Computer, with preferably 96K or more RAM, a color graphics monitor adaptor, and BasicA.

Character Structure and Location

The programmable character set is possible because the IBM PC defines only the first 128 (0-127) characters in graphics mode. The rest of the characters are left to be designed by the user. The addresses of these characters are given at the locations 7C-7F hex.

Each character is formed in an area of 8 X 8 pixels. Each row of eight pixels (bits) forms one byte, so that every character is defined by eight bytes.

Figure 1 shows one example of a character and the bytes that define it. After its formation, the definition of the character is stored sequentially, as demonstrated in Figure 2.

Note that even though each character definition is eight bytes long, once it is located properly, it can be recalled by its assigned ASCII code (128-254), which is only one byte long.

Making Characters

The screen display for the character generator shows four major sections. The second line of text displays the current memory location fo the character set you are making or revising (in the format of segment: offset). The large 8 X 8 grid is where characters are actually designed. It represents the 8 X 8 pixels that make up the character space.

To its right, a box displays the ACII codes of the characters in hexadecimal. The first digit of the code is given by the column heading, and the second digit by the row heading. The last section is the command table at the bottom of the screen.

There is a total of 14 commands to help you design shapes. To use a command, simply type the first letter of that command. For example, if you wish to execute the command MEMORY, type the letter M. This first letter of the current command is shown to the lower left of the grid and remains until you change your command.

Before you begin to create shapes, be sure to indicate the memory location for the character set you want to make. To do this, use the MEMORY command, specifying the Segment and the Offset.

Be careful in using this command because doing so carelessly can "hang' the machine. (The CTRL-ATL-DELETE sequence may be inactvated.) Bad places to assign this location would be in the Basic work area (which could destroy the program), the system work area or BasicA program (both of which could "hang' the system), and the ROM (which would simply not let you create a character set). This why it i recommended that you have 96K or more RAM.

With less than 96K, you must find a safe place in the Basic work area that does not interfere with program variables, the program, or system variables. Once you have found a safe location, you must tell the computer by giving it the segment location and offset. If you wish, you may type in a hexadecimal number by proceeding it with &H.

The first four commands are UP, DOWN, LEFT, and RIGHT. Execution of these commands moves the cross hair on the grid in the specified direction. If you move the cross hair off a side of the grid, it will simply wrap around to the opposite side.

The next two commands, PLOT and ERASE, allow you to draw the character on the grid. To put a point on the grid, move the cross hair to the desired pixel location and type P for PLOT. Your character now has a point in this position. If you decide you no longer need a point, move the cross hair to the point you wish to erase and type E for ERASE. The point will disappear.

When you are done making a shape, you store it as a character by using the FINISHED command (type F). The computer then asks for your ASCII code for the character. This code must be between 128 and 254 (&H80-&HFE). After you type this number, the computer pauses a moment and then displays your character in the character set in the box on the right in the position designated by your ASCII code. If you do not want to keep the character, you can clear the grid at any time by typing C for CLEAR.

The GET command is the opposite of FINISHED. It takes a character from the character set and puts it into the grid. This can be used for revising an already existing character or for adding something (such as an underline) to it. When you execute the GET command, the computer asks for the ASCII code just as it does for the FINISHED command. It then asks whether you wish to merge the character or not. If you wish to merge (combine the character you asked for and the shape already in the grid), type Y.

The next four commands, ACCESS, SAVE, MEMORY, and NEW, affect the whole character set as opposed to a single character. The NEW command wipes out the character set. It CLEARs all characters from RAM, but not from disk. The MEMORY command is used to change the memory location of the character set, as described above.

The ACCESS and SAVE commands allow you to load from and save to disk respectively. The ACCESS command leads the character set under the specified filename at the current memory address. The SAVE command saves the current character set under the specified filename.

The last command, QUIT, simply ends the program. To prevent loss of your character set accidentially, the QUIT command asks if you are sure you want to quit.

Using the Characters in Other Programs

To use the characters made by the IBM PC Character Generator in your own program, type the instructions in Listing 1, either directly into RAM or as part of your program. This example assumes that your special character set will be loaded at memory location 1700:0, and is named GREEK.CHR.

Remember that the characters can be used only in a graphics mode. For 80 columns, use screen two (640 X 200); for 40 columns, use screen one (320 X 200). The characters will be displayed in the foregound color. If you wish to change this color, you can always use the BASICA PAINT command to fill the character. In 80 column mode you are struck with black and white.

To type one of your characters, simply hold down the CTRL and ALT keys and type the three digit ASCII number in decimal of the desired character. For example, to get character 143, use this sequence: CTRL-ALT-1-4-3.

You can now use your custom made character set.

Table: Figure 1.

Table: Figure 2.

Table: Listing 1.

Table: Listing 2.