Sunday 27 March 2022

Commodore PET Datasette Port 2 Problems

This is quite a convoluted one, so please bear with me.


It all starts with a new game for the Future Was 8 bit 499 range, Cheese and Chive. A game by Misfit, in a similar style to their very successful VIC 20 game, Cheese and Onion. (and yes, I was again responsible for the crisp based name for this one)

As with Misfit's previous titles, this one is quite large, so would ideally need a fastloader to reduce loading times. So the designer of the previous fastloaders, Daniel Kahlin came up with a PET fastloader.

It's a really nice fast loader with animation and a tune and a block counter and it loads fast.


That was all very impressive loading from datasette port 1, but ideally it should also support loading from datasette port 2. Since it bypasses the kernal loading routines, it would need code to fast load from a different IO pin.

After persuading the developers of Vice to add support for the second datasette port, Daniel was able to update the fastloader to support loading from port 1 or 2. This was tested and it worked in Vice.


When I tested it on the Mini PET, it worked fine on datasette 1, but not on datasette 2. It started loading, but locked up at block 41, immediately after it played the first notes of the music.


Daniel confirmed that it did work in vice, and suggested I test it on a "real" PET, just to be sure.

On a real PET (a CBM 8032 board which was being tested using the monitor in my 4032 case), it loaded.


BUT, and this is where my head started to hurt. BUT, there was no sound in the game and when reset, there was no power on beep either.


I turned everything off, moved the datasette back to port 1, powered the PET back on and the power on beep was back. I loaded the game from port 1 and that loaded and there was sound again.

And so begins lots and lots of testing of various different combinations or machines and datasettes, trying to work out what was going on here.

It seems the real PET would not make a power on beep if there was a datasette plugged into port 2. I found also that the game sound returned immediately I unplugged the datasette from port 2, and went away when it was reattached. A datasette in port 1 had no effect on the sound.

I went back to the Mini PET, and repeated the tests, and checked. There was a power on beep, and sound was playing in the game, even if there was a datasette in port 2. 

I thought it may be a faulty datasette drive, so I tried another.

And then another.....and another....


The older drives, the two black PET drives, and the beige early VIC20 one seemed to behave differently to the later VIC20 and C64 ones. 


With these drives, the power on beep and the in game sound was not stopped when plugged into port 2. The game still wouldn't load from port 2, but was fine in port 1.


Or at least it did after I replaced the belt on the beige one. That must be the loosest belt I have seen in a cassette drive.


That's better.

The "new" style drives, those from C64's and later VIC20's, all behaved the same as the first drive I had tested. They blocked the sounds from the real PET when plugged into port 2.


I even tried a C16 one with an adapter, that should be representative of the last generation of these drives.


The PET ones were the earliest generation (at least of Commodore drives - there were some off the shelf cassette players adapted for the very early PET 2001s). The black one appears to have come out of a later 2001, it still has the mounting bracket attached - now you know why there were screw holes on the back of the PET drives and even the early VIC20 drives.


So, to recap.

Mini PET (all datasettes):

Port 1 - all drives load

Port 2 - all drives lock up at 041, no loss of sound

CBM 8032 (old datasettes):

Port 1 - all drives load

Port 2 -  all drives lock up at 041, but there is sound

CBM 8032 (new datasettes):

Port 1 - all drives load

Port 2 - game loads but with no sound


So what's the difference? Well, port 1 read input is wired to the CA1 pin of one of the PIA chips. Port 2 read input is wired to the CB1 pin of the VIA. Sound is wired to the CB2 pin of the same VIA chip. It certainly seems to be due to those two pins being on the same chip. 

As an experiment, I tried the MOS 6522 from the 8032 in the Mini PET.


That made the Mini PET behave like the CBM 8032, loading on new datasettes but loss of sound.

I tried a few other 6522 chips, and all the MOS ones behaved like that one. 


I tried a Rockwell R6522, and that behaved like the WDC W65C22N, no loss of sound but lock ups on loading.


So the behaviour did seem to be down to the chips. Checking the datasheets, there are some differences. The output port of the MOS 6522 should be something like other older NMOS chips:


When used as an output, the pin is either pulled high by the P channel FET, or pulled low by the N channel one. When used as an input, both FETs are disabled and the resistor acts as a pullup on the input.


With the WDC part, the pin is driven by a P channel FET via a resistor when used as an output and a different P channel FET and probably a higher value resistor when used as an input. 

One explanation of the problem could be the CB2 pin is being configured as an output, but is also being driven by the datasette drive, causing a lockup at the output of the device. With the WDC part, the resistor stops this from happening.

Driving the CAx and CBx pins is not as simple as a standard output, they are controlled by the PCR (Peripheral Control Register). This single register controls four pins, as follows:


On the PET, CB1 is the input for the cassette 2 read signal, and CB2 drives the speaker.


From this, it looks like CB1 is only being used as an interrupt source, and cannot be set as an output. However, it is used as an output in certain modes of the shift register functionality, such as when a sound is being played.

This is an annotated disassembly of the code that plays the power on beep sound.


This does not set the PCR, but uses the ACR (Auxiliary Control Register) to shift out bits to the CB2 pin repeatedly at a certain frequency to make a beep.


It starts by setting the ACR to 16 (0001 0000), which sets timer 1 to disabled and timer 2 to timed interrupts and "shift out free running at T2 rate".


This mode clocks the bits out of pin CB2, and does not mention CB1. Some of the other modes send the pulse clock out on pin CB1. I presume what is happening here is CB1 is still being set as an output, but not used. This is conflicting with the signal from the datasette drive. 

Conclusion

When playing sound, the datasette 2 read pin changes from an input to an output. There are two issues here.


1) The design of the PET and 6522 means that when you are playing sounds you cannot reliably read from datasette port 2. This is not normally a problem, only with a fastloader that is trying to play sounds whilst loading from datasette port 2.

To get around this, Daniel has disabled the loading sounds on the fastloader when loading from port 2. That has been tested extensively, and all combinations of drive and port and machine now work.


2) Depending on the type of 6522 and the type of datasette, this can cause the loss of sounds as the two outputs conflict.

If you have a Rockwell R6522 or WDC W65C22N (Mini PET, Mini PET 40/80 or Mini PET 40/80D), then this should not be a problem. The output of these chip have resistors in the high side drivers, as do the outputs of the datasettes, so that prevents any lock ups. 

If you have a MOS 6522 (most original PETs), then there is no resistor in the 6522, so if the datasette is pulling low, and the PET is trying to drive high, the transistor in the datasette output will be fighting with the P channel FET in the PET.


The output of the old style datasette is normally high, so the FETs in the 6522 can drive that high or low and there will just be a bit of wasted energy driving against the pullup resistor in the 7414 / 74LS14 output gate (or discrete transistor depending on model).

The new datasette output is normally low, so the transistor in the inverter gate is active and fights against the P channel FET in the 6522. How strong that is depends on the chip. Some have 7414, some 74LS14, and there will be variations for manufacturer to manufacturer and chip to chip. If that is stronger than the P channel FET in the MOS 6522, then the 6522 output rail gets pulled low and the sound stops.

Based on that, I would not advise leaving a datasette drive plugged into port 2 on an original Commodore PET. It does not appear to be healthy for the 6522 or the datasette drive. Old drives may be less of an issue, but either way, I wouldn't do it. The Mini PETs are not affected.



Advertisements

Cheese and Chive is available on cassette from The Future Was 8 bit.

https://www.thefuturewas8bit.com/shop/games/cas023.html

N.B. on the invoice this will shows a C&C as we have had problems with customs impounding orders as they thought "Cheese and Chive" was a foodstuff.


Or if you want a more immediate fix of Cheese and Chive, you can get a Mini PET 40/80D which has the game built into ROM.

https://www.thefuturewas8bit.com/shop/tynemouth-products/minipet4080d.html


This post is an expanded and updated version of a post from my Patreon. If you want advance previews of posts like this and behind the scenes progress on new projects, you can follow along and support me on Patreon:

https://www.patreon.com/tynemouthsoftware

Sunday 20 March 2022

The Mini PET 40/80D

 Introducing the Mini PET 40/80D.

This is a drop in replacement motherboard for any Commodore PET or CBM*. It comes with the full 32K of RAM, a selection of BASIC versions, including Mini PET BASIC 4.1. It also has a built in SD2PET SD card disk drive.


The board come preassembled, using all surface mount parts (other than the ROMs). It is based on the design of the Mini PET 40/80, and uses real WDC W65 series chips. There is a microcontroller based CRT controller using the same dual port video RAM, and as before video is generated from video RAM, indexing a character ROM and output via a shift register.


It comes all programmed and tested and ready to run.


12" PET 4032 / CBM 8032

As you can see, the Mini PET 40/80D board is quite a lot shorter than the 8032 board, but it is the same width, and has the same rear mounting holes and edge connectors for IEEE-488, Userport and Datasette port 1. All three are gold plated (unlike the PET boards, most of which only had gold on the IEEE-488 port)

It is powered by from the PET's internal power supply, and can drive the internal monitor and use the built in keyboard. A complete drop in replacement.


It also has a built in SD2PET SD card disk drive that can be used alongside the external IEEE-488 port.

This has the same built in file browser as the Mini PET 40/80, activated by the menu button on the side. The SD card slots and menu and reset buttons are on there side where the expansion connector was on the 2001, or the second datasette port on the 8032.


The SD2PET can be set as ID 8,9,10 or 11, or disabled all together.


I recently repaired an 8250LP (blog post on that to follow), so I have been using the 40/80D to do a lot of testing on that (shown with an earlier prototype version with ZIF socket during ROM developemnt)


The 8250LP may be low profile, but it's still a massive dual disk drive which also makes a nice stand for a Mini PET 40/80.


I have been doing a lot of file transfers and drive tests to give the IEEE-488 bus a good workout.


Text adventures are a good test to create lots of disk activity, but also to show off the 80 column text mode. Even if it doesn't like my suggestions.


The Min PET 40/80D comes with a cheat sheet showing all the DIP switch options. You should set this up according to the type of monitor and keyboard you have.

The chiclet, normal and graphics keyboard are supported, for simplicity, the guide is split based on the number of keys in the numeric keypad. You select the version of BASIC and 40 or 80 colums and set the DIP switches as shown.


The missing switches are set based on the type of monitor. PET 9" and 12" monitors are support, as well as composite video output at 50Hz or 60Hz for PAL or NTSC regions.

You would normally set these to match the board you were replacing, but you can run 80 column on a 4032 or a 2001 or 40 column text on an 8032 if you like, 

9" PET 2001N / 30xx / 40xx


The 9" PET machines usually had this version of the board, again the Mini PET is a drop in replacement. 

Original PET 2001


The Mini PET 40/80D can be used to replace the board in a PET 2001. (Mine here has already had the IO chips replaced, video RAM replaced, and the character ROM replaced. All the main ROM and RAM has been removed, as 6540 and 6550 chips just seem to sit there getting hotter and slowly wiping each other out until they all fail, so my remaining working chips are safely in a box somewhere and the board is running on a PET ROM/RAM board. )


All of those can now take a rest as the Mini PET 40/80D has been fitted.

The connections on the 2001 are slightly different as the power connector is 5 pin and there is an internal datasette, but both are supported on the Mini PET 40/80D.

The internal datasette is wired as port #2 leaving port #1 on the rear


I doubt there are many PET 2001's that can run in 80 columns (here running the built in self test).

Standalone / Testing


As well as being fitted into a PET case, the Mini PET 40/80D can be used for bench testing, here powered by my PET test power supply, or it can be powered from an external 9V DC power supply.


What else can I say? What more do you want?

OK, how about a built in version of Cheese and Chive?



* What can't it do?

Well, I may as well get this one in here, there is no support for a Commodore 64 or VIC 20 keyboard. AZERTY, QWERTZ and other international keyboards will need a custom ROM (or just rearrange the keycaps to QWERTY).

The board will fit in the case for an 8032-SK and 8096-SK (here shown an earlier through hole version of the Min PET), but the keyboard cable may be a bit too short to reach, there appears to have been some variation of the course of their production.

It might be possible to fit the Mini PET 40/80 D into the 8296 or 8296D, but it would require quite a lot of changes, so best not.

There is no support for anything that plugs into the 6502 socket, ROM sockets or expansion connectors on a normal PET. No ROM boards, 64K RAM boards or Super PET 9000 boards etc.

Where can I get one?

The Mini PET 40/80D preassembled board and the Mini PET 40/80 self assembly kit are available from the Future Was 8 bit, shipping now.


https://www.thefuturewas8bit.com/shop/tynemouth-products/minipet4080d.html

https://www.thefuturewas8bit.com/shop/tynemouth-products/minipet4080.html

Read more about the Mini PET 40/80 self assembly kit with built in keyboard here

http://blog.tynemouthsoftware.co.uk/2022/02/the-mini-pet-4080.html

Update:

The Mini PET40/80 kits are now sold out, but you can still buy the the original Mini PET from my SellMyRetro store in A (stand alone) and B (PET replacement) versions,

These are also available as kits or fully built versions:


http://blog.tynemouthsoftware.co.uk/2023/09/minstrel-and-mini-pet-kit-updates.html

Also a choice of keyboard PCBS (original flavour and deluxe)