Classic Computer Magazine Archive CREATIVE COMPUTING VOL. 10, NO. 9 / SEPTEMBER 1984 / PAGE 202

Commodore's port; port on Compuserve and Simon's Basic graphics. John J. Anderson.

Commodore's Port

Port on Compuserve and Simon's Basic graphics

Hey there, Commodorians. I know you missed the column last month, and it feels good to be back. We have quite a few topics on the agenda, so let's get to it.

Avoid Save and Replace

As more or less an afterthought to the June column, I mentioned that a save and replace function does in fact exist for the Commodore 64 and gave its format. Since that time I have received letters and phone calls admonishing me for reiterating the information.

The problem with the save and replace command in its current form is that it is buggy. It will work fine for a while, then obliterate an innocent bystander file for no apparent reason.

The common mood of all those who got in touch was an undercurrent of melancholia resulting from lost data. Glen Johnson, of Sydney, Nova Scotia, summed it up, saying "Please, John. Recommend that people avoid that command like the plague.'

Commodorians, avoid the save and replace command like the plague. Do all your file manipulation from the MiniDOS Menu program (more about that ahead).

Gibson Gibe

A trade paper recently reported that master light pen maven and micro-man-about-town Steve Gibson had some cruel words for the C-64 at a recent Apple shindig. "The thing looks overinflated,' he was quoted to say. "Somebody ought to let some air out of it.'

Well, Steve, you know how much respect I have for you, how much I appreciate your wit, and how much I like you as a person. So you won't really mind if I point out that the same occasionally could be said of you.

Sure, the C-64 has its faults--they are numerous, and many are far more than skin-deep (as this month's column underscores). But the C-64 is capable of great things; its potential is unlimited. I would guess that too can be said of you, Steve.

While I've basically been too reasonable to snipe at the looks of the C-64, there is one point upon which I could not agree more--the keyboard on the 64 does not feel as good as it should. The overinflation metaphor does hit home on this account.

It really feels like the keys are harder to press (more pressurized) on the Commodore 64 than on other machines. I've said it before, and it's time to say it again: Commodore, retrofit the keyboard you have on the SX-64 to the C-64. It has a much superior look and feel.

Menu Autorun Fix

At first I thought it was purely because our Commodore readers were so happy with the MiniDOS Menu programs (C-64 version, May; Vic-20 version, June) that so many wrote in regarding it. Then the truth hit--it was debug-time in the old Port once again.

Okay, string him up by his gums, he has screwed up again. But I can't really take 100 percent credit for this one. Part of it has to go to the occasionally rather quirky nature of the C-64 itself.

It seems that the autorun function, selectable from the main menu, will truncate certain programs during a load. If a program is shorter than nine sectors (the length of the Menu program itself) it will load and autorun as advertised. If the selected file is longer than the Menu program, however, only the first nine sectors of it will load at all.

A good one, huh? Why does it happen? Don't ask me, I just work here. It's another "feature,' like save and replace, you know. If anyone can hazard a guess on either weirdness, I'd sure like to hear it.

All I have discovered regarding the original autorun is that the technique was erratic. The latest revision of the MiniDOS was for a book I am writing (more on this to follow) within which nearly all programs are nine sectors or shorter. Hence I was convinced that the autorun command was functioning perfectly during testing.

In one case I got to a title screen on a 27-sector file, and assumed that the program had loaded properly. Had I tried to run it, I would have discovered that little more than the title screen had in fact made it into RAM.

Enough excuses. The fix for the Commodore 64 appears as Figure 1. I'm hoping that once I lay out the technique, one of our Vic readers will submit a Vic fix, sparing me the work. The idea is to POKE two carriage returns and a RUN command into the keyboard buffer. Then we fully load the specified program, which of course knocks the MiniDOS out of memory. Once the program is loaded, we pop the RUN command and another carriage return out of the keyboard buffer, and the program autoruns.

The fix consists of a modified line 570 and the addition of a new line, which we'll call 575. As you can see, this is less elegant than my original approach, which more or less listed as INPUT:LOAD:RUN. Really pretty, but as I've said, works only part of the time.

Here, line 570 asks for input, then types a legal LOAD command using the input string as the filename. Because we can't embed quotes within PRINT statements, we stick them in as CHR$ (34)s. The three special graphics characters at the end of the line are SHIFT-CURSORUPS typed inside the quote mode. Don't forget them. They put the cursor where we want it to be when line 575 comes into play.

Line 575 literally packs the keyboard buffer with "phantom keystrokes.' Location 631 is the start of the buffer. A 13 is the CHR$ equivalent of a carriage return, so our cursor, which has been repositioned over the LOAD command line, can be RETURNed, entering the line. The next values--82, 85 and 78--spell out the word RUN in CHR$ values. Then we add another value of 13, this time in location 635, allowing our "phantom typist' to press RETURN over the RUN statement once it pops out of the buffer.

The final POKE, in location 198, tells the C-64 how many characters to count out of the buffer. The total here is 5, and that is exactly what we POKE into location 198. So very simple.

So this approach, while quite a bit bulkier, is foolproof. It will load any size file, and autorun it without alteration.

Thanks for your otherwise largely kind comments regarding the MiniDOS Menu.

Commodore's Port on Compuserve

If you still don't have a copy of the MiniDOS Menu, one thing you now can do is download it from the Creative Computing SIG Special Interest Group) on Compuserve. Yep, that's right, Creative Computing is on-line, and if you can get onto Compuserve, you can communicate with us directly anytime you want. You can download Commodore-specific articles, programs, and scuttlebutt too.

Just type GO PCS-22 at any exclamation prompt. Leave a message asking to become a member, and we'll validate you within 24 hours. Among other goodies, you will find an on-line version of Commodore's Port on the SIG, where you can ask questions, give answers, and otherwise sound off. More programs for download are added to our databases every day.

So if you have modem, give it a try. It could well become a regular thing. Get on-line soon, and show those Atarians that C-64s can telecommunicate, too.

Simon's Basic Sight and Sound

The debugged and fully-featured cartridge version of Simon's Basic is finally widely available, and it is about time. The language adds 114 commands to plain vanilla Basic, finally making the true power of the Commodore 64 available to the novice programmer.

If you own a 64 and are interested in programming, you owe it to yourself to pick up Simon's Basic. I am so impressed with the language, I am writing a book about it.

Because graphics and sound are my major interests, Commodore 64 Sight and Sound will deal primarily with the graphics and sound commands available from Simon's Basic. They are easy to use, and especially powerful.

Here, in an excerpt from Sight and Sound, is a look at just a few Simon's Basic low-res graphics commands, and examples of their use:

SCRSV and SCRLD

Perhaps the most important lo-res commands available from Simon's Basic are SCRSV and SCRLD. SCRSV stands for screen save, which allows you to save a lo-res screen. SCRLD, which stands for screen load, allows you to load a screen saved with a SCRSV command.

Instead of having to go through the trouble of keying in a program to load and save lo-res screens, as we did from plain old Basic, Simon's Basic has dedicated commands to make the job simple for us. They can be used in the direct or the deferred modes.

To save a screen to disk, you use the following command format:

SCRSV 2,8,2, "screen filename, S, W' (screen filename is the name you have chosen for the screen).

The parameters other than the screen filename, which you will supply, will always remain the same--these tell Simon's Basic to open a file to disk, write screen data to it sequentially, and then mark it with an end-of-file marker.

To load a screen that has been saved to disk, follow this format:

SCRLD 2,8,2, "screen filename'

It is just that simple. The screen you saved as that filename will appear on the screen. Any lo-res screens, even those in color and using special graphics characters, can be saved in this manner. In this way you can preserve your lo-res works of art forever.

FLASH and OFF

Using the FLASH command is a good way to draw attention to the screen itself or to certain words on the screen. It can take either of two alternate formats:

FLASH color, speed (color = 0-15, and speed = 1-255).

This command enables you to flash all characters in a single color, at a rate of speed that is selectable. The speed range may be any number from 1 to 255--with 1 as the fastest flash rate and 255 the slowest.

Alternatively, you may use this format:

FLASH color (color = 0-15). This will flash a color at a default rate of once every four seconds.

To stope flashing when you are ready to do so, simply use the command OFF. The only trick to using the OFF command is to make sure to turn off the flashing when the characters are visible --otherwise you could run into problems with an invisible cursor.

As a remedy to off-timing FLASH, you could redefine cursor color after using an OFF command.

Listings 1 and 2 show a couple of uses of the FLASH command.

FILL

The command FILL allows you to fill a rectangular area of the screen (in a size and location you choose) with text characters of a specific color and type. Command format is as follows:

FILL row, column, width, length, POKE code, color (row = 0-24; column = 0-39; width = 1-24; length = 1-39; POKE code = code for selected text character; and color = 0-15).

The first four parameters in the FILL command define the area of the screen to be FILLed. Rows are numbered 0 to 24, and columns 0 to 39. The parameters row and column represent the top left-hand point of the FILL, and the parameters width and depth the size of the rectangular shape to be filled. The next parameter, POKE code, is the POKE code associated with the character that will comprise the fill. A list of POKE codes appears as an appendix in the Commodore Programmer's Reference Munual.

The final parameter is the color of the FILL character you desire. Listing 3 is one form that use of the FILL command might take.

MOVE

MOVE is an extremely powerful and useful command, that allows you to copy a section of the screen and move it elsewhere on the screen. The command format is as follows:

MOVE row, column, width, length, destination row, destination column (row = 0-24; column = 0-39; width = 1-24; length = 1-39; destination row = 0-24; and destination column = 0-39).

The first four command parameters define the screen area you wish to reproduce. The last two specify the row and column coordinates of the top left-hand corner of the area where the screen will be duplicated.

Be sure that parameters you use do not result in a MOVE exceeding the limits of the screen. This means that the depth of the screen area to be duplicated added to the row number of the area into which the information is to be reproduced must not exceed 25. It also means that the column number of the area into which the data are to be reproduced must not be greater than 40. No MOVE command can execute if those parameters result in a BAD MODE error.

Listings 4 and 5 are some examples of MOVE commands.

So there you have it. Next month we continue our exploration of Simon's Basic graphics, and take a look at the exploding number of hardware/software graphics packages for the C-64. See you then.

Table: Figure 1.

Table: Listing 1.

Table: Listing 2.

Table: Listing 3.

Table: Listing 4.

Table: Listing 5.