Advice to PET Owners:
How To Be A VIC Expert
Jim Butterfield, Toronto
There are going to be a lot of VIC computers arriving very soon. All those new VIC owners are going to look to you for advice and counsel. After all, you've owned a PET for several months; and a VIC is just a junior version of a PET, right?
You don't want to blow your chance to become the block's VIC guru. It really is very much the same as the PET, but there are new things you will need to get used to.
I'll give a few hints here: Basic is the same as on the PET, right down to the LOG, SQR, and ATN functions. Because the VIC has fewer columns, you can link up to four rows together to generate a line of Basic. Many of the advanced VIC features, like color, are done the same way as programmed cursor on the PET. You clear the PET screen by printing a special reverse-character; you'll set color on the VIC exactly the same way.
The old familiar PEEK the POKE locations have moved around; when you find them, they will work the same as in the PET ... but that's a whole other story.
A good way to start is with a sample program. Here's a VIC program which you can type in on your PET, and save on tape. It won't work properly on the PET, but your tape will load in nicely on the VIC, and you'll get an insight into how some of the VIC things work. By the way, your cassette unit itself will plug into the VIC, so carry both tape and cassette unit over to the new machine.
100 remark : big letter display 110 rem by Jim butterfield 120 rem peeks the VIC character generator 130 rem in hex 8000 to 8FFF 140 input "graphic/text" ;g$ 150 g = asc(g$) 160 if g = 71 then b = 0 : goto 190 170 if g = 84 then b = 2048 : goto 190 180 stop 190 input "character #";n 200 if n < 0 or n > 255 or n <> int (n) goto 140 210 m = 32768 + b + 8 * n 220 print chr$(176); : for j = 1 to 8 : print chr$(192); : next j : print chr$(174) 230 for j = m to m + 7 240 print chr$(221); 250 x = peek(j) 260 for k = 1 to 8 270 y = 146 : x = x * 2 : if x > 255 then x = x - 256 : y = 18 280 print chr$(y); chr$(32); 290 next k 300 print chr$(146); chr$(221) 310 next j 320 print chr$(173); : for j = 1 to 8 : print chr$(192); : next j : print chr$(189) 330 goto 140
What does the above program do? It prints out the 256 characters used by VIC in large size. The user picks a character (from 0 to 255) and it is displayed on VIC's screen. The characters are screen format, not ASCII, so that a value of 1 gives an A character. You'll find that the characters are similar to those used by the PET.
How does this program behave in the VIC? You'll find a few differences that will cause you to change your programming style when you shift to the new machine. The first thing you'll notice is that you'll have trouble stopping the program. The INPUT statement on line 140 does not stop the machine if you press RETURN with no input. It continues running, and leaves variable G$ at its previous value. That's different: it means that you can set up a default for G$ and the user can invoke it by just pressing RETURN. It also means that you have to find another way of stopping the program. The trick here is to input a character such as X when asked, "GRAPHIC/TEXT". The program will continue only on a response of G or T - or no response, as noted before.
You'll have noticed that the program is very PET-compatible. In fact, it will run on the PET with two small differences. First, the PET can't read its own character generator, so you'll get nonsense displayed. Secondly, the PET behaves a little differently on the INPUT statement as we have noted.
Here's a puzzler: when you punched up your program on the PET, it occupied memory space starting at decimal 1025. On the VIC, the program will want to take up residence starting at decimal 4096. How can your PET program load properly to the VIC? Easy: VIC has a relocating loader; it just moves the program to the new place. Transferring programs the other way — from the VIC to the PET — isn't as easy, since the PET does not relocate programs.
A final note on the coding. There's a lot of use of CHR$ characters: why didn't I use the more familiar characters in quotes, which would certainly work? Answer: it would drive the staff of COMPUTE! wild, since they wouldn't be able to typeset all those fancy characters. Then they would substitute their own symbols, with a translation legend somewhere near, and you'd be driven wild in turn trying to type it in. Trust me: it's better this way. As an exercise, you can work out how to recode most of the CHR$ expressions into screen characters.
Thought for the day: if the character generator is accessible in memory, do you think that you might be allowed to code your own set of characters in RAM memory? The answer, of course, is yes; but you'll have to encode the whole character set you need since all characters must be grouped together. But that's another story ...
You've generated your first VIC program. Hopefully, you've discovered a few things about how the VIC works. Much of it will be the same as with the PET, but a few features are different.
Now, when all of the new VIC owners on the block beat a path to your door, practice saying wise things like, "Of course, on the big machines, we do it this way ..."