Classic Computer Magazine Archive COMPUTE! ISSUE 79 / DECEMBER 1986 / PAGE 10

Readers’ Feedback

If you have any questions, comments, or suggestions you would like to see addressed in this column, write to "Readers' Feedback," COMPUTE!, P.O. Box 5406, Greensboro, NC 27403. Due to the volume of mail we receive, we regret that we cannot provide personal answers to technical questions.

Characters In Apple Hi-Res

I have a question concerning the program "Apple Superfont," published in the April 1985 issue of COMPUTE!. I made a character which was a green square, but when I loaded it into my program and printed it, it was purple on every other column. Is there any way around this color problem?

- Jim Cooper

Unlike many home computers, the Apple II does not let you replace its standard character set with one of your own design for text-mode display. Apple Superfont redefines characters by displaying custom shapes in the Apple's high-resolution display mode. To understand how redefined characters can appear in different colors in different places on the screen, let's first take a look at how colors are displayed on the Apple II hi-res screen. You can draw in six different colors in this mode—black, white, green, violet, blue, and orange—but the use of these colors is somewhat limited. As the figure shows, each row of the hi-res screen, containing 280 pixels in all, is described by 40 bytes of memory, and each of those bytes describes 7 pixels. The highest order bit of the byte selects the color set for these 7 pixels. If this bit is on (if the value of the byte is 128 or greater), the pixels controlled by that byte can be blue, orange, black, or white. If the highest bit is off (if the byte's value is 127 or less), the available colors are purple, green, black, and white. The color that appears for each of the seven pixels depends on the position of the pixel and the state of its neighbors on the same row. If a pixel has been turned on (the associated bit in the controlling byte is set to 1), and both of the adjacent pixels are off (their controlling bits are set to 0), it will appear as a purple, blue, green, or orange dot. If the pixel is in an even-numbered column on the screen, it will be either purple or blue. Odd-numbered pixels will either be green or orange, depending on the state of the high bit in the same byte. If two adjacent pixels are both turned on, they appear as a white line two pixels long, regardless of position. If a pixel is turned off, it appears as a black dot on the screen unless both neighboring pixels are turned on—in which case the group of three pixels will be seen as a purple, blue, green, or orange line three dots in length. HROUT, the machine language utility that Apple Superfont uses to print on the hi-res screen, displays each character as a 7 X 8-pixel grid. Not only does this size coincide with the size of text-mode characters, but it also maps neatly into the array of memory bytes which control the hi-res screen. But since each memory byte controls seven pixels, there are two obvious classes of memory bytes: those which begin and end with even-numbered pixels, and those which begin and end with odd-numbered pixels. If you store the same value in two adjacent bytes, the image produced by the second byte has its colors reversed from the first: purple for green and blue for orange. In your case, you can solve this problem by defining two solid blocks: one which appears to be green when printed in the first column on each row or any other odd column, and another which appears purple in an odd column, If you print them both in even-numbered columns, theircolors will be reversed. When you need a green block in an odd-numbered column, you can print the first character. When you need one in an even-numbered column, you can print the second. If you've defined these blocks as characters 94 and 95 (normally ^ and–.), this line prints the correct character:

OE = POS (0) - 2 * INT (POS (0) / 2): PRINT CHR$ (95-OE);

The function POS returns a value one less than the cursor's horizontal position; after the instruction HTAB 6, POS returns a value of 5. Thus, the variable OE equals 1 if the cursor is in an even column, printing character 94, or it equals 0 if the cursor's column is odd, printing character 95. By the way, this color effect is not unique to Apple Superfont. The same thing can happen with Apple text characters if you're in combination hi-res/text mode. Just enter the HGR command to get in this mode, then type a bunch of M characters. Half of them will be green and half will be purple.