• Please review our updated Terms and Rules here

Detecting the keyboard type on a PET?

hjalfi

Experienced Member
Joined
Feb 11, 2017
Messages
265
Location
Zürich, Switzerland
I'm writing a game for the Commodore PET, because apparently I have too much free time.

How do I detect at run time whether the model that I'm running on has a business keyboard or a graphics keyboard? Because the keyboard matrices are different, I need to know so I can use the right values for sensing keys. This should be possible because they use different editor ROMs, but I don't know what to look for.

Thanks!
 
I'm not sure how to do it automatically, but if you know the values for both types of keyboard, you can have the user press a key that's distinctly different between models (e.g. if A is hex 22 on one but is hex 56 on the other) and tell the game to use whichever keyboard that matches. Also if the business model lacks PETSCII graphics (I've never messed with one so I'm not sure), you can see if there's a quick way to run a checksum against the character ROM to determine the machine type, and that could work as an automatic detection.
 
Also if the business model lacks PETSCII graphics (I've never messed with one so I'm not sure), you can see if there's a quick way to run a checksum against the character ROM to determine the machine type, and that could work as an automatic detection.

The character ROM is "hardwired" to the pixel output chain in all PETs, the CPU physically cannot read it. But it doesn't really matter because all PETs have both the "business" and "graphics" character sets. (The top address line of the ROM is connected to an output on one of the I/O PIAs to switch between them.)

The "it should mostly work" way of telling the difference would be to take a checksum of the EDIT ROM (the one at Exxx) and compare it to a stored list, but that may fail if someone is using an obscure/rare model or has replaced the standard ROM with a custom one. Asking the user to hit a known key when the program starts is probably the easier hack; almost all the key locations are different between the two matrixes so you shouldn't have any trouble asking the user to hit a letter and scanning both locations to see which shows up.

(Granted that will also break if someone's created a custom ROM to use a completely different key matrix, but you probably shouldn't have to expect that. Only way to really handle that is to use the keyboard handling routines in ROM to abstract it, which of course comes with significant overhead for an action game.)
 
I'm not sure how to do it automatically, but if you know the values for both types of keyboard, you can have the user press a key that's distinctly different between models...

Ooh, that's cunning! And should solve my problem seamlessly, too. I have a title screen where the user presses the spacebar to move on --- and that's bit 2 row 8 on the business keyboard and bit 2 row 9 on the graphics keyboard. This should work fine. Thanks!

(Of course, if the user presses 6 or ] instead of SPACE then they're going to have problems.)
 
Last edited:
I don't know exactly where it is, but in the Edit ROM somewhere, there is a keyboard translation table that should be detectable.
The Edit ROM is where all the physical differences are accounted for, like the screen and keyboard.
 
Yes you are right and I was thinking that myself earlier this week ... the following book details the locations

http://www.primrosebank.net/compute...ramming_The_PET_CBM_197x_West,_Raeto_text.pdf

Turn to page 427 (in the book) ...

However, I thought the rom checksum to be a quick and dirty method, I guess inspecting the rom dumps in Zimmers would reveal the differences, as being pedantic, one would have to account for not only the 80 column business keyboard but also the 40 column business variant too which are rare but still around.

Andy



[ QUOTE=Hutch;662165]I don't know exactly where it is, but in the Edit ROM somewhere, there is a keyboard translation table that should be detectable.
The Edit ROM is where all the physical differences are accounted for, like the screen and keyboard.[/QUOTE]
 
Back
Top