PET/CBM FAQ - PROGRAMMING

DID MICROSOFT REALLY WRITE BASIC FOR THE COMMODORE PET?

Yep. back then Microsoft's main business was BASICs and other languages for microcomputers. In the upgrade ROMs they even placed an easter egg, just enter WAIT 6502,x to see 'MICROSOFT!' displayed on the screen x number of times.

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)

40×25 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 PETs 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:

  • POKE 59467,16 (turn on port for sound output use 0 to turn it off*)
  • POKE 59466,octave (octave number, see below)
  • POKE 59464,frequency (0 for no 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:

Note Frequency
octave=15 octave=51 octave=85
Oct.0 Oct.1 Oct.1 Oct.2 Oct.2 Oct.3
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:

  • on the VIC-20: 37147, 37146, and 37144
  • on the 64 or 128: 56587, 56586, and 56584

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.

Original ROM PET Bugs

This was the first general release of the PET, it was the first BASIC implemented by Commodore for the 6502 and there were bugs:

  • Commodore had not yet implemented the IEEE-488 disk routines.
  • Arrays are limited to 256 elements due to a bug in firmware.
  • There is no machine language monitor nor could one use the PEEK command access locations above memory location 49152.
  • Upper/lower case character set was inverted (SHIFT for lower case)
  • Due to the way the accumulators were handled you could not have a command such as POKE address,PEEK(address) work reliably.

(note: reading my sources there are A LOT of bugs, will take a while to compile them)

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.

WHAT ARE ROMS?

ROMs as an acronym for “Read Only Memory” a type of memory that always contain the same value. The computer's ROMs usually contain the programs that the computer needs to start up and perform it's basic operations. On earlier computers like the PET the ROMs contained not only the startup code, but the BASIC programming language, communications routines to work with the tape and disk drives as well as simple printer communications.

Since they weren't easily changed (back then you had to remove and replace the chips, in todays computers there are special electronics that make it so you only need to run a special program) ROMs would have to contain either serious flaws or shortcomings to warrant a new “revision” to be created and sold.

Just like different versions of operating systems today, some programs written for particular ROMs are not compatible with other ROM versions.

THE THREE ROM VERSIONS

The PET/CBM line had three major ROM revisions as well as a few minor ones. Presently this FAQ only covers the major revisions. As to what the version numbers are it can be a bit confusing, some people contend that BASIC version 1.0 never made it out of beta development and the PET line started with version 2.0 ROMs… Commodore on the other hand usually refers to the 'Upgraded ROMs' as V2, or 2.0. For the sake of sanity in this FAQ I will refer to the ROMs as original, upgrade and 4.0 ROMs using those definitions most PET fans will know what you are referring to.

WHAT VERSION OF ROMS DO I HAVE ON MY PET?

You cannot reliably determine the ROMs by looking at the outside of the PET (unless it has a large monitor, then it is definitely 4.0 ROMs). Fortunately there is an easy way to distinguish the three various versions by just turning on the computer and looking at the startup message.

Depending on how your start-up message looks you can determine the ROM version:

*** COMMODORE BASIC *** - Original ROMs

Original ROMs sometimes referred to as 2.0* ROMs. (only found in the older calculator keyboard style PETs) Occupy $C000-$FFFF. The original PET can be upgraded to “Upgrade ROMs”

This was the first general release of the PET, it was the first BASIC implemented by Commodore for the 6502 and there were bugs. Commodore had not yet implemented the IEEE-488 disk routines. Arrays are limited to 256 elements due to a bug in firmware. There is no machine language monitor nor could one use the PEEK command access locations above memory location 49152. The upper/lower case character set was inverted (SHIFT for lower case), due to the way the accumulators were handled you could not have a command such as POKE address,PEEK(address) work reliably. (note: reading my sources there are A LOT of bugs, will take a while to compile them)

### COMMODORE BASIC ### - Upgrade ROMs

Commonly known as the 'Upgrade ROMs' sometimes referred to as 2.0 or 3.0 ROMs depending on who you ask. Occupy $C000-$FFFF

Most Original ROM bugs were squashed. Now includes a tiny ML monitor and IEEE-488 disk operability, also PEEKing to upper memory was permitted. Easter Egg - enter WAIT 6502,x to see 'MICROSOFT!' displayed on the screen x number of times.

This is the BASIC model that was later used fore the Commodore VIC-20 and Commodore 64.

*** COMMODORE BASIC 4.0 *** - 4.0 ROMs

4.0 ROMs The only ROMs that will work on large-screen PETs and cannot work on original PETs. 4.0 ROMs occupy $B000-$FFFF

Based primarily on upgrade ROMs, 4.0 includes the addition of direct Disk operation commands DLOAD, DSAVE, COPY, HEADER, etc. Ability to repeat cursor control characters by holding down keys. Reserved DOS error-channel variables: DS,DS$. And on the large screen PETs the added screen 'window' formatting control characters and “bell” sound.

NOTE: The small screen-and large screen versions of these ROMs differ and some software developed for the small-screen 4.0 ROMS crash on the large screen units. This is due to the necessary changes made for the newer video controller of the 12” display PETs.

Also with the 4.0 ROMs it was necessary for Commodore to use some of the RAM allocated for the 2nd datasette interface buffer thus making operation of the second datasette useless.

ADDITIONAL ROMS/EMPTY ROM SOCKETS IN YOUR PET

If you have a later 2001/3000/4000 or 8000 motherboard there will be two or three available ROM sockets. These can be populated with various ROMs either containing programs or in the case of some commercial programs 'protection ROMs' containing code a disk program needs to run (to prevent unauthorized use on multiple computers). If you have a upgrade PET you will have three sockets unpopulated, two ROM sockets are available on a 4000/8000 or 4.0 PETs.

The addresses of the ROMs are

$9000 (36864) $A000(40960) $B000 (45056) - if Upgrade ROMs are in the PET - each ROM can hold 4096 bytes of information.

  • Programmer's Toolkit - Adds commands for helping in writing and debugging BASIC programs.
  • Graphics Subroutines - adds some handy graphics routines (only usable by other PETs with the same ROM)
  • Protection ROMs for: WordPro, VisiCalc, Delphi's Oracle/Consultant. (these are needed to run those programs)
  • PET Networking Utility ROMs for some networking units available for the PET.

If you have extra ROMs in your PET and they are unlabeled or seem like they might be program ROMs you can usually activate them by SYSing the start address of the ROM location. (i.e. enter SYS40960 if a chip is in the $A000 socket) the PET Models FAQ shows the ROM address positions.

Last modified:: 2020/11/22 09:26
   
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International