Back to Projects or Publications


January 1988, Ahoy! Magazine
Save and restore C128 40-column text screens

More than just a memory mover that stored C128 40-column text screens somewhere in memory and recalled them, TextSave also saved color memory and preserved the Screen Editor values (see Window Dressing, below,) in effect for the screen being saved. All this 40-column data was stored in 80-column memory: If 40-column mode was in use, then the 80-column display didn't need its memory, right? By carefully POKEing the routine it could be made to save other data in 80-column memory. What's more instead of storing 40-column screens in 80-column memory, it could also be altered to store an 80-column screen in main memory -- clumsily. I later wrote a routine specifically for the 80-column display. (Keep-80)

While saving and restoring 40-column screens might seem trivial, TextSave was invaluable when combined with...

Window Dressing

July 1988, Ahoy! Magazine
Enhancements for the C128 Window statement

BASIC 7.0 in the Commodore 128 included a WINDOW command. All it did was confine text output to new coordinates within the 40- or 80-column screen and optionally Clear the area within the new window. Very no-frills. Window Dressing was four machine language routines to "dress up" the WINDOW command, giving any user-written programs a more sophisticated look.

SYS FRAME [,,,,,heading] PRINTed a border (with optional Heading,) around an existing Window and opened a new Window inside the frame/border.

SYS was a command for calling machine language from BASIC. In the C64 and VIC-20, values could be passed to the 65xx microprocessor registers by first POKEing certain memory locations reserved for that purpose. In BASIC 7.0, values could be passed in the statement by separating them with commas after the address (FRAME, in this case,) in the order A, X, Y, SR. Commas with nothing between them meant no change to the corresponding register(s). That's the reason for the five commas if FRAME is to include a heading. If four commas were present FRAME looked for a fifth comma and if present called a BASIC ROM rountine and looked for something PRINTable.

SYS AT, flag,row,column [,,string]

This was a type of PRINTAT command. BASIC 7.0 had CHAR as a kind of PRINTAT primarily for the bit-map screen that could also be used on a text screen. But it had limitations: it could only print text within quotes or one -- and ONLY ONE -- string variable. A numeric variable had to first be converted to a string and if more than one item was to be printed they had to be contcatenated into one string variable. Items could not be separated by commas or semicolons, as in a PRINT statement. Very clumsy. In SYS AT, string could be in any form that could be handled by an ordinary PRINT statement. The two commas with nothing between them were necessary due to the way SYS passes register values, described above.

The flag determined if the cursor returned to where it had been before AT was called, or remained at its new position on the screen after AT completed. The cursor location was always saved, but if cursor restore was deferred, by making flag non-zero, it could be restored to where it had been by another Window Dressing rountine, SYS CR. This allowed multiple PRINTs to follow SYS AT before returning the cursor to its previous location.

The final Window Dressing routine was SYS ED, set, direction. This would save and restore five sets of Screen Editor values -- the screen/window dimensions, character color, cursor location, and which lines were "linked" or continued from the line above. This allowed a program to jump from window to window, printing menus, receiving input, displaying results, etc. A user-written program would have to keep track of which set of Editor values needed to be recalled after saving.

These routines functioned in 40- or 80-column mode and, like all my published programs, were relocatable by changing a number in the BASIC program that POKEd the machine language into memory.

Back to Projects or Publications