Classic Computer Magazine Archive COMPUTE! ISSUE 25 / JUNE 1982 / PAGE 87

PET Miscellany

Jim Butterfield
Toronto

Jim Butterfield responds to a number of recent queries about Commodore computers.

Q: How do I get my CBM disk to do things (like direct access) from machine language?

A: The disk doesn't know or care who's giving it instructions: BASIC or machine language. All you really need to do is to send to the disk (or receive from disk) exactly the same information that BASIC would send. Some commands go to the command channel (secondary address 15) and some to the data channel, so you'll need to keep things sorted out and know the command channel formats. See a separate article on Machine Language and the CBM Disk [COMPUTE!, March, 1982, #22, pg. 139].

Q: A previous article says that SYS 54386 on 4.0 systems will call the Machine Language Monitor (as opposed to breaking to the Monitor). What is the BASIC Upgrade ROM address for this? I'd like to get that C* to show instead of that B*.

A: Upgrade ROM may call the monitor with SYS 64785. It's not needed quite so badly in earlier ROMs since they do not turn off the CMD that's in effect.

Q: I see that memory locations 1001 to 1012 decimal are used in the Fat 40. Are there any that are useful to know to the average programmer? For example, what does "New Key Marker," location 1001, do?

A: The interrupt working values in the Fat 40 aren't really too important to the end user; you need to know that they're there so that you can leave those locations alone. I don't plan to comment in any depth on them ... if you want to play, be my guest. The New Key Marker spots if a new key is pressed, so that when you hold down cursor-right and then press cursor-down instantly, it still knows to pause before taking off again. (Note that it goofs up if you use the shift key to change cursor-left to cursor-right.)

Q: More questions on memory maps. The 80 column machine has a lot of constants used near the top of zero page for windows and things. What is this space used for in the 40 column ones?

A: The 80-column locations are mostly used in the 40-column job for the "line wrap table" which keeps track of single versus double lines. You don't need to do this in 80 columns, of course.

Q: I have a screen dump program which prints a hard copy of everything on the screen to the printer. At the end of each line it sends CHR$(0) five times before it proceeds to the next line. Why?

A: Some printers need time to return the carriage to the left hand side of the page. To allow for this, some programs add "pad" characters after the RETURN/LINEFEED to give this time; CHR$(0) doesn't print, but fills in the time.

Q: What is the difference between ASCII and "true ASCII"?

A: True ASCII is a standard 7-bit code. Upper case A is decimal 65, and lower case a is decimal 97. In the PET, an 8-bit code is used; if you're in Text mode then upper case A is 193 and lower case a is 65. To go to a standard device or a communications line, you'll need to do a translation from PET-ASCII to true-ASCII.

Q: I have a program which does a "soft" change of the device number of a particular device. How does it do it?

A: Some devices – notably disk units – place their device ID's into RAM at the time of power-up. If you can download to the device's memory, and know the locations, you can change these memory values and, thus, the disk ID.

Q: I'd like to be able to check to see if the disk is busy. If the disk is doing a Header (New), Collect (Verify), or other lengthy jobs, I'd like to know when it is finished. Trying to use the disk when it's busy causes my program to lock up until the disk is free.

A: Try using the following code:

POKE 59456, PEEK(59456) AND 251
X = PEEK(59456) AND 64
POKE 59456, PEEK(59456) OR 4

At this point, X will have a value of zero if the disk is busy, and 64 otherwise.