For Retro Computing Enthusiasts

Machine Language for Beginners: Customizing

By Richard Mansfield — originally published in December 1986 (Vol. 4, No. 12)

If you’ve discovered a clever time-saving technique or a brief but effective programming shortcut, send it to “Hints & Tips,” c/o COMPUTE!’S GAZETTE. If we use it, we’ll pay you $35. We regret that, due to the volume of items submitted, we cannot reply individually to submissions.

Positioning The Cursor

Douglas W. Brown

There are several ways to put the cursor at a certain location on the screen. You can POKE a couple of locations, SYS to the Kernal PLOT routine, or do something like this:

PRINT “{HOME}{DOWN}{DOWN}{RIGHT}{RIGHT}{RIGHT}”;

But what happens when you finish the program, put it aside, and three months later decide you want to add some features?

A program full of POKE and SYS statements isn’t very readable—and it’s not much fun looking for memory locations in a book, trying to remember what the program was supposed to do. A line full of {DOWN}s and {RIGHT}s isn’t very readable, either. The reverse graphics characters that represent cursor movements in quote mode blend together when you have several in one line.

Here’s another way to position the cursor. It’s not necessarily any faster than other techniques, and it might use up a little more memory. What’s good about it is that the listing is very easy to follow. For example, to put the cursor at line 10, column 12, and print HELLO, you’d use the following line:

60 PRINT LN$(10); CL$(12); “HELLO”

This won’t work until you set up the arrays, of course. To create the arrays LN$ and CL$ (for lines and columns), add this short subroutine to your program:

Now you can move the cursor anywhere on the screen by using the arrays LN$ and CL$. The 25 lines are numbered 0–24; the columns, 0–39. If you prefer not to start counting at zero, change the first part of line 60000 to F = 1 (the columns will now be numbered 1–40 and the rows 1–25).

To see this technique in action, type in the subroutine above and add these lines:

Untwist A Renumbered Program

Michael A. Lang

The RENUMBER command on the 128 is a delight, but using it makes it tough to find the new starting line number for subroutines and other sections of your program. This is my solution:

10 GOTO 100
20 GOSUB 1000: INITIALIZATION
30 GOSUB 2000: OPEN DATA FILE
40 GOSUB 3000: SORT ROUTINE
99 REM MAIN ROUTINE STARTS BELOW
100 …

The GOTO in line 10 jumps right to line 100, which means lines 11–99 are never executed. But the 128 doesn’t know that and modifies those lines when you renumber. After renumbering is finished, press F7 to list the program and then hit the NO SCROLL key to pause the listing. You’ll see what amounts to a menu of subroutines and their starting line numbers.

If you have a renumbering utility for the 64, this trick will also work in 64 mode.

This is especially useful when it’s been a few weeks since you last examined a program. The first few lines provide an overview of how the program is organized.

Companion disk Companion Disk (.d64)

Enjoyed this? It’s what we do every month.

The revived COMPUTE!’s Gazette brings the spirit of the golden era to today’s retro scene — Commodore, Atari, Amiga, and more, in full-color print and digital every month.