| PortCommodore.com | (site map) - (random page) |
| MAIN - CLASSIC COMPUTING - Commodore PET/CBM Pages - PET Frequently Asked Questions - | |
| portcommodore.com PET/CBM FAQ |
| PROGRAMMING AND PET BASIC |
WHAT ARE THE BASIC COMMANDS FOR MY PET?
For the most part the BASIC on the 64 is identical to the upgrade ROM PETs and it only varies by a few commands and features between original and 4.0 ROMs. On the other hand the 'memory map', the locations you POKE numbers into, vary quite a bit between ROM revisions. Memory Maps are available for all the versions...
Quick Reference of all the BASIC commands and functions: PET BASIC Quick Reference (text file)
Description of PET commands/functions with examples: PET BASIC Command Reference (text file)
Table of the Commodore-8-bit Character Set, BASIC tokens, PETASCII Codes, etc.: Commodore Multi-Chart (PDF)
40x25 Screen Layout Map (good for planning screens, playfields): Commodore Screen Map (PDF)
HOW DO I ACCESS UPPER/LOWER CASE OR GRAPHICS CHARACTER SETS?
In order to have graphic symbols to to draw simple charts and for games as well as upper and lower case characters for word processing Commodore gave the PET two 256 character sets, one with upper and lower case characters for word processing and business applications and one with upper case and graphics characters for charts, games, etc. In order to change the 'mode' of the PET you must direct the computer to 'look' at one of two character sets via a POKE command.
The PETs start up in one of two modes, upper case characters (pressing shift types graphics symbols) or lower case characters (pressing shift shift types upper case characters).
To direct the computer to uppercase/graphics mode:
POKE 59468,12
To direct the computer to lower/uppercase mode:
POKE 59468,14
Note that when you change sets the characters on the screen change immediately to the new image, you cannot have characters from both set on the screen at the same time without some specially timed program to perform it.
Original ROM PET have reversed reversed upper/lower case characters:
Commodore had the upper/lower case characters reversed in the original ROM models where both modes started with upper case characters and you pressed SHIFT for lower case or graphics. This is the reason for some older software having reversed case text. There are utilities available that will adjust all your PRINT statements to the proper case for the newer or older ROM machines.
12" 4000/8000 series:
The 12" 4000/8000 series PETs allow you to change case by printing a control character: CHR$(14) - Text Mode CHR$(142)-Graphics Mode When you issue a CHR$(14) on a 4000/800 series PET the newer display controller will be adjusted so there is a pixel or two gap between screen lines. If you do not wish this gap in text mode just POKE 59468,14 instead of printing CHR$(14) (if you want the gap in character mode you can issue a ? CHR$(14) and then POKE 59468,12 to produce the desired effect.)
Unlike the later Commodore 8-Bits there is no way to edit the characters on the screen in software alone.
HOW DO I MAKE SOUND ON MY PET?
This process sets the PET's shift register in a free-running state where the signal is used for sound generation. By adjusting the pattern of the output and the frequency you can produce a wide variety of sounds, and even music!
Three pokes are required to make sound:
After setting 59467 you can adjust 59466 and 59464 to get any sort of sound, but to get music you need to set them with specific values, here is a three-octave note table:
Note Table:
octave=15 octave=51 octave=85
Note Oct.0 Oct.1 ! Oct.1 Oct.2 ! Oct.2 Oct.3
Freq ------------+-------------+--------------
B 251 125 ! 251 125 ! 251 125
C 238 118 ! 238 118 ! 238 118
C# 224 110 ! 224 110 ! 224 110
D 210 104 ! 210 104 ! 210 104
D# 199 99 ! 199 99 ! 199 99
E 188 93 ! 188 93 ! 188 93
F 177 88 ! 177 88 ! 177 88
F# 168 83 ! 168 83 ! 168 83
G 158 78 ! 158 78 ! 158 78
G# 149 74 ! 149 74 ! 149 74
A 140 69 ! 140 69 ! 140 69
A# 133 65 ! 133 65 ! 133 65
Set 59466 with octave range desired and play notes by setting the frequency in 59464. To stop any sound use POKE 59464,0.
* Note, due to a hardware bug, leaving the shift register in free running mode will cause problems when attempting to use the datasette so always POKE 59467,0 before attempting to use any tape commands.
The process for using and playing sound can also be done on the 64/128 and VIC-20 the same connector pins are involved but the POKEs are different:
Instead of 59467, 59466, and 59464 for the PET use these:
WHAT IS THE 'KILLER POKE' AND SHOULD I WORRY ABOUT IT?
This is THE POKE of computer lore, the command that WILL physically break a computer! Of course other commands and methods are known that can potentially cause damage (usually to disks, hard drives or other mechanical units), but this is the most notable mainly because it was a command somewhat commonly used and it affects solid-state circuitry.
Lately debate has gone up about how lethal is this POKE to the circuitry, some contend it will not cause damage, but so far no one has volunteered their equipment for testing.
History of 'the killer poke'
When the first PETs (small 9" screen) models came out, the display wasn't all that fast.
The old PETs were slow because the print character ROM routine waited for the interval between screen scans before updating the screen memory. This reduced conflicts over the screen RAM which would have resulted in random pixels (snow) being illuminated on the screen. There was an input on one of the I/O chips which was hooked up to the video circuitry and told the routine when to access the video RAM.
It wasn't too long before someone learned they could improve the character display speed via a poke to location 59458; which would set the video controller to update more readily. It was a noticeable improvement of speed on programs using PRINT often, it was kind of like a free upgrade. It was mentioned in a few publications and used in many programs that relied on printing to the screen. I had learned of the poke through Cursor Magazine, a monthly tape-based publication. They printed the command in one of the 'newsletter' flyers included with an issue which you could insert into their game "joust" to make it play faster.
Later on, when Commodore released the larger display (14") PETs, they had improved the display controller which made that POKE unnecessary. An unfortunate side effect was that the POKE to 59458 affected a different register which adjusts one of the newer screen display capabilities, which could result in damaging the PETs video circuitry when left running. I discovered it by accident after our school received some large-screen 4016s. When active, the screen starts to warp after about the third line and the display stops around the fifth, the keyboard is also unresponsive. When a PET is in this mode, the only solution is to turn it off, FAST! Fortunately none of the school's PETs were damaged due to this POKE. Later Cursor Magazine published a 'fix' that would allow older PETs to use the poke and keep the large-screen units from frying. Unfortunately there are still many programs that do not have this fix.
Prevention
Make sure to check BASIC programs (especially games) when running them on a large-screen PET and be ready with the power switch when you first run it. I have usually found the 'killer poke' statement looking like this:
POKE 59458,PEEK(59458)OR 32
It will always be a POKE to 59458, the remainder of the POKE may vary.
HOW DO I ACCESS THE PET's M/L MONITOR?
The 'Terminal Interface Monitor' (known as TIM to some tinymon to others.) is available on all PETs but the original ROM version (which Commodore offered to users on tape later on). TIM is activated by executing a BRK instruction by SYSing any memory location containing a zero (0), most people enter SYS 1024, as it almost always contains a 0.
WHAT ARE THE COMMANDS FOR THE M/L MONITOR?
G - Execute M/L: G programaddress (i.e. G 033C)
L - Load: L "filename",dev (i.e. L "PACMAN",08)
S - Save: S "filename",dev,startaddress,endaddress
(i.e. S "FLASH ATTACK",02,027A,2000)
R - Display Processor Registers
X - Exit Tiny Mon
M - Memory Display: M startaddress endaddress (i.e. M 0400 04A0)
: - Modify Memory (supplied in memory dumps using the M command)
; - Modify Processor Registers (supplied in the processor register, P command)
CAN I GET A BETTER M/L MONITOR FOR MY PET?
Yes, there are two that I know of that are readily available. The most popular (and universal among the Commodore 8-bits) is Jim Butterfield's Supermon. There are versions available for all ROM revisions including original ROM PETS and offer a mini Assembler and Disassembler among other useful memory/ML commands. The other, similar to Supermon is called Extramon. There are other versions many of which are commercial but I have little information on them.