Classic Computer Magazine Archive ANTIC VOL. 7, NO. 3 / JULY 1988



TEXT SCREEN CODEMAKER

Converts word displays into program lines

BY JOHN BERNDT


Text Screen Codemaker is a quick, easy tool for adding screens of text to your programs, especially help screens for applications with lots of commands. This BASIC program works with 8-bit Atari computers of any memory size, disk or cassette.

TEXT SCREEN CODEMAKER is a useful utility that converts onscreen text into actual source code that can be included in your BASIC programs. Using the Text Screen Codemaker is so simple that I find myself writing every menu, introduction screen and prompt with it.

Type in Listing 1, CODEMAKE.BAS, check it with TYPO II and SAVE a copy before you RUN it. The pause when you RUN the program is due to the Player/Missile cursor being initialized.

The opening prompt asks for the first line of your program. The Screen Formatter begins with line 20000, so any number below that is fine. Then you're asked for the line increment--any increment works unless it will eventually interfere with the Text Screen Codemaker.

At the Left Margin prompt, enter the column number where you want printing to begin on your screen. The default is 2, because many television screens cut off the first couple of columns. Now press [START] to begin creating your screens.

The [CLEAR], [INSERT], [DELETE], [ARROW] keys, etc., function as normally. For large jumps across the screen, use the [ARROW] keys because this eliminates most of the problems caused by the computer keeping track of all the logical lines. Don't press [RETURN] until you are done!

Also, don't type on the last line at the bottom of the screen--or on the last space in the second to last line. This will make the screen scroll upward and eliminate the top line. Press [RETURN] and let the Codemaker do its stuff only after you're satisfied that everything is the way you want it.

During the first pass of the cursor, ATASCII character 253 (the crooked left arrow made by pressing [ESCAPE] and then [CONTROL] [2]) is added to mark the end of each line for later use. All the onscreen characters are stored in memory during the cursor's next pass.

Next, the computer counts the spaces before each line begins. The source lines are then written and stored in memory. After everything is finished, the new lines are displayed, and you are asked if you want to SAVE them. If so, enter a filename at the next prompt. You can LIST the lines to any device, including a cassette (by entering C:) or printer (by entering P:). To SAVE them to disk, enter D: and a filename.

TECHNICAL NOTES

I discovered that Text Screen Codemaker needed a special cursor because the normal cursor left a trace character onscreen that was picked up in the final source code. Jerry White's P/M Cursor routine (Antic, November 1984) provided a fine solution. I stripped White's previously full-featured program into the bare DATA stamps and an initialization routine for the machine language (lines 20025-20035).

Lines 20255-20320 are the logic of the Codemaker program. They check to see whether there are more than six spaces before the actual line begins, in which case a POSITION statement would be more practical. Another case where a POSITION statement would be added is if one or more lines are skipped between two lines. Lines 20170 prevents the skipped line that would be caused by placing the character 253 in the last column.

I used several programming tricks in Text Screen Codemaker. The POKE 84,4 replaces a standard POSITION statement by POKEing a number into the computer's memory location for the current row, thereby skipping the appropriate number of lines.

POKE 842,13 activates the Atari's Forced Read mode, which makes the computer "press" [RETURN] automatically. This can be handy by previously positioning the cursor above a line you wish to enter into memory and then doing the POKE. POKE 842,12 turns this feature off.

I created an all-purpose error-handling routine (lines 20425-204 35) to replace dozens of TRAP statements. Location 195 holds the most recent error number. The subroutine always has to be re-initialized when it is used. Line 20435 returns the program to the line before the error.

John Berndt is a high school student from Rochester, New York. He has been an Atari programmer since 1983 and participates in his local users group, ACORN.

Listing:CODEMAKE.BAS Download