Programming resources for the Commodore Pet?

Other Computers and Game Systems

Moderator: Moderators

Post Reply
User avatar
AndyH
Vic 20 Afficionado
Posts: 364
Joined: Thu Jun 17, 2004 5:51 am
Website: https://www.hewco.uk
Location: UK
Occupation: Developer

Programming resources for the Commodore Pet?

Post by AndyH »

Wasn't sure where to ask this, thought this is likely the most appropriate place.

I've recently built one of the Mini Pet kits from Tynemouth Software. Always intrigued by the Pet, came across them a lot but mostly in short bursts, a bit of a go with BASIC or watching someone else load something up.

I'm looking to make something on it, with Turbo Rascal of course, but that doesn't factor in as it could easily be with BASIC or a conventional assembler. The problem I have is finding some solid and consistent documentation. I realise I'm so spoilt with Denial and its abundance of information. Plus loads of books. Not finding the same for the Pet.

The Mini Pet can use BASIC ROM's 1 through 4 plus a tweaked BASIC 4 and the documentation says it is close to the 2001 with a 40 column display (9" screen), 32k RAM and the speaker modification. I'll be sticking with the BASIC 4 ROMS and not going to worry about compatibility with others, at least for now.

Found it fascinating digging in, how the 1k video memory just wraps round in the whole of the $8000 - $8fff space. The compatibility issues between BASIC 1, 2 and 4 and can see where the emphasis of vectors probably came from.

There are two areas I am wondering if there are any Pet experts around to point me in the right direction (or have an answer)?

1. Keyboard

I have so far found the byte where I can read one key being pressed that I can check ($97), but that is no good for detecting multiple key presses. On the Vic 20, I can use $9120 and $9121 to select a row and work out what keys are held down. Assume there must be the same on the Pet. Any ideas?

2. Raster / VBL synchronisation

Not sure if the Pet has access to where the raster beam is like the Vic 20 or C64, or if it can detect when a vertical blank is occurring? Initial purpose is just to keep a steady pace in the timing of a game loop so it can run at a consistent speed. The best I have worked out is to read part fo the TI$ variable (the part at $8f) which appears to increment every frame. Looking at example code I do not spot any evidence of how this can be best done. I see a lot of FOR loops to create a delay and relying on a BASIC game's code to enforce an estimated steady pace.

Any ideas for a better way, preferably if I can sync somehow with the vertical blank?
--
AndyH
HEWCO | Vic 20 blog
User avatar
AndyH
Vic 20 Afficionado
Posts: 364
Joined: Thu Jun 17, 2004 5:51 am
Website: https://www.hewco.uk
Location: UK
Occupation: Developer

Re: Programming resources for the Commodore Pet?

Post by AndyH »

As usually happens, after much time searching the Internet and not finding the answer, posting here and within 30 minutes I find something new. The keyboard question is it is the same as the Vic 20, the addresses to write and read from are $E810 and $E812 if that helps anyone else out. Also, put 60 into $e813 to disable the keyboard scan in the interrupt, 61 to enable it again.

I've also found something about the flyback interrupt that updates the keyboard, the TI and other stuff 60 times a second. I don't fully grasp what it is trying to explain (reading huge blocks of courier font is hard going) but I'll dig a bit deeper.
Last edited by AndyH on Mon Jan 18, 2021 7:09 pm, edited 1 time in total.
--
AndyH
HEWCO | Vic 20 blog
groepaz
Vic 20 Scientist
Posts: 1187
Joined: Wed Aug 25, 2010 5:30 pm

Re: Programming resources for the Commodore Pet?

Post by groepaz »

There are test programs in the vice repo that do stuff synced with the raster, so it must be doable... perhaps look there: https://sourceforge.net/p/vice-emu/code ... ET/hi-res/
I'm just a Software Guy who has no Idea how the Hardware works. Don't listen to me.
User avatar
AndyH
Vic 20 Afficionado
Posts: 364
Joined: Thu Jun 17, 2004 5:51 am
Website: https://www.hewco.uk
Location: UK
Occupation: Developer

Re: Programming resources for the Commodore Pet?

Post by AndyH »

Thanks - that could be quite useful.

On the keyboard, I have documented the row and bits that correspond to each key. It essentially goes rows 0 through 9 for the first two columns of keys (the !, " then Q, W, A, S, Z, X etc) each clearing bit 0 if the key is pressed. Then the next two columns (keys #, $, E, R etc) for rows 0 through 9 clearing bit 1 if pressed, up to bit 7 for the end of the numeric keypad.
--
AndyH
HEWCO | Vic 20 blog
User avatar
javierglez
Vic 20 Hobbyist
Posts: 107
Joined: Sat Jun 03, 2017 3:33 pm

Re: Programming resources for the Commodore Pet?

Post by javierglez »

I found this resource http://www.primrosebank.net/computers/pet/pet_docs.htm and there's some scanned books on the topic of PET programming, Programming The PET/CBM by Raeto West and some other.
I'm not interested in PET programming, but I wonder if they are good.
User avatar
majikeyric
Vic 20 Afficionado
Posts: 351
Joined: Fri Oct 24, 2014 2:08 pm
Website: http://majikeyric.free.fr
Location: France

Re: Programming resources for the Commodore Pet?

Post by majikeyric »

Have you tried Bombjack ? https://commodore.bombjack.org/kim-pet/
User avatar
AndyH
Vic 20 Afficionado
Posts: 364
Joined: Thu Jun 17, 2004 5:51 am
Website: https://www.hewco.uk
Location: UK
Occupation: Developer

Re: Programming resources for the Commodore Pet?

Post by AndyH »

Thanks all - I figured it out with some help. There is a bit to test for the vbl starting and the the PIA addresses (different) work exactly the same as the VIA for reading the keyboard, but with more rows and the graphic v business keyboards to contend with. The code is in the latest release of Turbo Rascal.
--
AndyH
HEWCO | Vic 20 blog
Post Reply