Classic Computer Magazine Archive COMPUTE! ISSUE 87 / AUGUST 1987 / PAGE 76

64 Eighty

Jeffrey Partch

Now Commodore 64 owners can enjoy the benefits of an 80-column screen display without buying expensive hardware add-ons. Through clever programming, "64 Eighty" gives you an 80-column display with normal color output, simultaneous access to any of the 64's character sets, underlining, boldface, and an enhanced screen editor that supports many of the special editing functions of the Commodore 128.

If you own a Commodore 64, or you use a Commodore 128 in 64 mode, you may have wished for a way to display an 80-column screen. Eighty-column displays are very useful because they allow you to fit a lot of text on the screen at one time. "64 Eighty" lets you add an 80-column capability to your 64 without sacrificing the other features which make the 64's editor so powerful.

The 64 Eighty program works in the background: Once it is installed, the usual editing functions, such as cursor keys, work as they do normally. However, now each line is 80, instead of 40, characters wide. In addition, you can have more than one character set on the screen at one time. And 64 Eighty also implements many of the special editing functions available on the Commodore 128.

Because 64 Eighty uses high-resolution graphics to create the 80-column display, it is recommended that you use it only if you have a composite video monitor. The smaller 80-column characters may not be very readable if you use the program with a TV set.

Typing It In

64 Eighty is written in machine language, so you'll need to use the "MLX" machine language entry program to type it in. MLX is printed elsewhere in this issue. Please read all of the instructions before you type in the program. When you run MLX, you will be asked for a starting address and an ending address for the data you'll be entering. For 64 Eighty, use the following values:

Starting Address: 0801

Ending Address: 1890

64 Eighty is designed to load and run exactly like a BASIC program. Load it as you would any BASIC program; then type RUN and press RETURN. 64 Eighty switches the display to 80-column mode and displays a short startup message. The READY prompt indicates that the BASIC screen editor is ready for use.

To turn off 64 Eighty and return to 40-column mode, type SYS 64738 and press RETURN. Note that this SYS resets the computer and does a NEW of any BASIC program in memory. Be sure to save any program that you wish to preserve before you perform this SYS.

The 64 Eighty Environment

Once the 80-column screen is active, you can use the screen editor normally. The RETURN key enters a line, the cursor keys move the flashing cursor, and so on. You also can change screen colors in the normal way. 64 Eighty always begins with blue letters on a black screen background, but this is easy to change. For instance, run 64 Eighty and type this line in direct mode (without a line number):

POKE 646, 0: POKE 53280, 15: POKE 53281, 15

You should see black letters on a light gray screen. The POKE to location 646 changes the current text color. You also can change this color by pressing CTRL and a number key as usual. As in 40-column mode, pressing RUN/STOP-RESTORE resets the screen and text colors to their original values.

You may wish to customize the program to display different screen colors when it starts and when you press RUN/STOP-RESTORE. To change the default screen colors, follow these steps exactly.

1. Load 64 Eighty into memory. Do not run the program.

2. Write down the color numbers for the background color, border color, and text colors you wish to use. Your owner's manual has a list of the 16 color numbers; the color number for black is zero, and so forth.

3.Type the following statements in direct mode (without line numbers), replacing BO, BG, and TX with the desired border, background, and text color numbers, respectively:

POKE 3425, BO
POKE 3426, BG
POKE 3860, TX

For example, if you wish to set the border and background to white (color 1), and the text color to black (color 0), you would type these lines, pressing RETURN at the end of each line:

POKE 3425, 1
POKE 3426, 1
POKE 3860, 0

4. After you type the POKEs, resave the program using a name different from the one you used when saving it from MLX. Do not run the program before you resave it. 64 Eighty performs a NEW after installing itself in memory, so if you run the program before saving the modified version, your work will be lost.

For the most part, the 64 Eighty editor functions just like the familiar 40-column editor. Note, however, that while the 40-column editor restricts the length of a logical line to 80 characters, the 64 Eighty editor imposes no limit other than screen size. BASIC's input routine allows as many as 88 characters in a line, so you can enter BASIC program lines containing up to 88 characters.

New Editing Functions

This program offers a number of special screen editing functions similar to those on the Commodore 128. Since the 64's keyboard has no key labeled ESC (ESCape), this program interprets the left-arrow key at the upper left corner of the keyboard as ESC. If you are using a Commodore 128 in 64 mode, you must use this key with 64 Eighty rather than the 128's ESC key, which is ignored in 64 mode. If you need to type the normal left-arrow symbol, press the left-arrow key twice in succession.

To invoke an ESC-key feature, press the left-arrow key once; then release it and press the key indicated in Table 1. For instance, to change the cursor from a flashing block shape to a flashing underline, press the left-arrow key followed by the U key.

Although the ESC functions are designed primarily for direct mode, they also can be invoked in program mode with this syntax:

PRINT CHR$(27); code$

Replace code$ in this example with the letter for the function you want to use. For example, to change the cursor to an underline, you would execute PRINT CHR$(27); "U" or PRINT CHR$(27);CHR$(85).

Table 1: ESCape Functions

ESC A Enable autoinsert mode
ESC C Disable autoinsert mode
ESC D Delete physical line at cursor position
ESC I Insert blank line at cursor position
ESC E Turn off cursor flashing
ESC F Set cursor to flashing mode
ESC @ Clear screen from cursor to bottom
ESC Q Erase from cursor to end of logical line
ESC P Erase from cursor to start of logical line
ESC G Enable bell sound by CTRL-G
ESC H Disable bell sound by CTRL-G
ESC J Move cursor to start of logical line
ESC K Move cursor to end of logical line
ESC L Enable screen scrolling
ESC M Disable screen scrolling
ESC O Cancel quote, insert, underline, reverse, and boldface modes
ESC U Cursor appears as an underline
ESC S Cursor appears as charactersize block
ESC B Set bottom right corner of screen at cursor
ESC T Set top left corner of screen at cursor
ESC V Scroll screen window up
ESC W Scroll screen window down

New Control Functions

64 Eighty also adds several functions which you invoke with the CTRL key. Table 2 lists all of these functions. To invoke a CTRL function, hold down CTRL and press the indicated key. For instance, to make a bell sound, hold down CTRL and press G.

Some of these functions can be invoked in program mode by printing a single CHR$ value. For example, the statement PRINT CHR$(7) makes a bell sound. Boldface characters are simply characters from the normal 40-column character set. On a screen containing 80-column characters, boldface characters stand out dramatically. Note that boldface characters are for cosmetic purposes only; when you press RETURN over a line of boldface characters, the 64 Eighty editor interprets them as spaces.

Table 2: CTRL Functions

ASCII value Keys Result
CHR$(2) CTRL-B Underline on
CHR$(7) CTRL-G Bell sound
CHR$(15) CTRL-O Boldface on
CHR$(27) → or CTRL [ Send ESCape Code
CHR$(130) none Underline off
CHR$(143) none Boldface off

64 Eighty Memory Organization

Although the 64 Eighty editor works much like the normal editor, it makes several changes to the computer's normal memory configuration. Like any other reconfiguration, these changes affect what you can do in 80-column mode—including what sort of programs you can run successfully. In the following explanations, all memory addresses refer to the computer's configuration after 64 Eighty has been installed.

Screen Memory. Screen memory is no longer in its normal location. The area where screen memory normally resides, locations 1024–2047, is used to hold a character set for 64 Eighty. Thus, any program that POKEs or PEEKs locations 1024–2047 will need to be modified before using it with 64 Eighty.

Within the area from 1024 to 2047, each eight-byte group stores the shape of one character. The upper four bits in each byte describe the uppercase/graphics version of that character, and the lower four bits hold the lowercase/uppercase version. Thus, each character is four dots wide and eight dots high. Only ASCII values 0–127 are defined. The reverse-video and underline effects are handled by the screen editor.

64 Eighty uses the 2000-byte area in locations 33729–35791 as its screen memory. Each byte in this zone contains the screen code for one character space on the 80-column screen. Values POKEd into this area are recognized by the screen editor, but have no effect on the display itself (you can't make a character appear by POKEing its screen code into this area).

The 48 bytes in locations 35792–35839 are used internally for line links and other miscellaneous data.

Color Memory. Locations 35840-36863 serve as color memory for 64 Eighty. Only the first 1000 bytes contain valid color information, but this range is also interpreted by the VIC-II chip as the video matrix, which must be 1024 bytes in length. Because color memory is limited to 1000 bytes, but screen memory contains 2000, each byte of data in this area affects the color of two adjacent characters on the screen.

The simplest way to change the text color is with the CTRL key combinations listed in your user's manual. As noted above, the border and background colors can be changed with POKEs to locations 53280-53281.

You also can change the color of characters by POKEing new values directly into this memory area. The upper four bits of each byte control the foreground color of a character, while the lower four bits control its background. Thus, you could use this area to simulate the extended background color mode available on the 40-column screen.

If you are looking for safe spaces to store sprite shapes or other data, note that locations 36840-36863 and 39912-40959 are not used by 64 Eighty for any purpose.

Display memory. Locations 40960-48959 contain the high-resolution bitmap that determines what you see on the screen. This image is normally a representation of the screen codes stored in screen memory (see above). To avoid sacrificing too much BASIC program space, this bitmapped image resides in the RAM underlying the 64's BASIC ROM chip—a zone that is not normally accessible with PEEK from BASIC. However, you might want to read the contents of this area to create graphics or fancy characters on the 64 Eighty screen. To make this possible, 64 Eighty includes a special machine language routine you can invoke with USR.

To use this feature, first execute the statements POKE 785,199 and POKE 786,155. Those POKEs tell USR where to find the machine language routine. Then invoke the routine with the statement X = USR (address), where address is the memory location you want to PEEK. After this statement executes, the variable X contains the value held in the specified byte.

Compatibility

Because 64 Eighty reconfigures the computer, there's no guarantee that it will work with any and every program you might want to run. The simplest way to test whether a particular program is compatibile is to install 64 Eighty, then load and run the program. If the computer doesn't lock up and the screen looks as expected, you're probably in business. If it doesn't work, you must either modify the program or abandon the idea. (No harm is done if the computer crashes; simply turn the power off and on to regain control.)

Some programs, of course, can't possibly be made to work while 64 Eighty is active. This includes all high-resolution graphics programs and many machine language programs, such as COMPUTE!'s popular SpeedScript word processor, which take you out of the BASIC environment completely. 64 Eighty is a modification to the BASIC screen editor; if a program doesn't use that environment, it cannot be expected to work with 64 Eighty.

Of course, any program that POKEs or otherwise corrupts the memory used by 64 Eighty itself will probably crash the system.

64 Eighty

Please refer to the "MLX" article in this issue before entering the following program.