Tinkering with C64 CP/M

I always wanted to play with the C64 CP/M cartridge, even knowing that it was a total flop and discontinued briefly after release. So I finally decided to try it and bought one from eBay. How bad could it be ?

IMG_0244

You can watch the instructional here:

Booting the CP/M

Looks cool eh ? First problem: finding a compatible C64 for it. Yes you read it right: It’s not compatible with all C64’s out there, but only the early models sporting a 5-pin A/V port. Tried on my C64C and it was a roller coaster.

If you plug a slot expander like Xpander-3 and some other cartridges on it it might work on the C64C. But is try and error. Once it boots and shows the prompt screen and a DIR command works, it keeps stable until you reset the machine. Strange eh ?

I can’t explain the reason behind this but adding more hardware would add more parasitic capacitance and noise to the bus. The only thing I know is that it works. It would require a digital probe and record the entire boot to find out what is the real cause.

Screen Shot 2018-06-10 at 10.40.05 PM

Since I got tired of trial and error, I just got a cheap 5-pin A/V C64 from eBay. I had to replace the VIC-II because it was dead. But now it works fine and the C64 is stable – if connected direct to the slot. Keep in mind if you replace the VIC-II it must be an early VIC-II chip. Newer ones are reported to not work with the CP/M cartridge. Also adding the Xpander-3 in the old C64 causes the same problems with the C64C. So my idea of using a 80-column expansion won’t be possible.

Expanding the user memory

The disk images I found online are for 44K user memory area. Looking the manual, it’s fairly easy to increase to 48K (the maximum allowed):

MOVCPM * 48
SYSGEN

when running SYSGEN, just skip the disk to load from, it will load from memory and write to the current logged disk. Reboot and you get whopping 48K! There is not much we can do about the RAM: it’s taking account for the Kernal, video + color buffer, the 6510 BIOS and the 8080 BIOS. They all add up to 16K of your precious memory.

But playing a little with it you figure out that there is no addressable cursor support, what means you cannot use full screen apps like Turbo Pascal IDE, VEdit Plus, SuperCalc, etc… and also WordStar needs at least 64 columns to work with.

But not everything is lost, if there is one thing Commodore did right was providing the source code with the disks, so we can modify it.

Software 80 column

Since the expansion issues made it impossible to use an external 80 column cartridge (if there is any besides the BI-80 which is incompatible with the CP/M cartridge anyway) it turns out there is an excellent software 80 column program made by Chris Lampton back in 1984.

And amazingly this program won’t take any byte out of the CP/M addressable memory, instead it installs itself in separate unused areas and the VIC-II graphics mode runs under the Kernal ROM. Pretty neat eh ?

Well almost, using it you find a strange issue: every time you type something you end up getting an echoed spacebar, although the text seems fine.

I dug into the source code and found the culprit. It is the CONIN routine that emulates a software cursor, for every typed character it will print a white space and then a backspace:

CONIN7: 
PUSH PSW    ;SAVE CHARACTER 
MVI A,1
STA FLASH   ;TURN OFF CURSOR 
MVI C,' '   ;GET SPACE 
CALL CONOUT ;PRINT SPACE 
MVI A,9DH   ;CURSOR LEFT COMMAND
CALL COUT5  ;BYPASS FILTER 
POP PSW     ;RESTORE CHARACTER

Commenting this section out and then you get a functional SOFT80. This change will cause minor cursor issues when in 40 column mode, like the cursor not being deleted when pressing ENTER at the prompt, but you don’t want to use it in 40 columns mode anyway.

Screen Shot 2018-07-05 at 6.44.05 PM

SOFT80 has its own ESC codes for cursor addressing which is not compatible with any CP/M machine and also the support for reverse characters is made through a direct memory access called IOBYTE that is not compatible with any CP/M program.

Extending SOFT80

SOFT80 is great but I wish it had a more common terminal than its own and also that it would support reverse characters, insert and delete lines, erase to the end of screen, etc. These commands make the CP/M experience much more pleasant, so I modified and patched SOFT80 adding Kaypro 2X support and default white over black screen.

With this modified version you can grab any Kaypro 2 software and it will work out of the box, except for the half bright and blinking support. I also changed the CP/M boot up sequence to autoload SOFT80 at the boot.

You can get the .D64 files with CP/M, SOFT80 and several applications from here.

Finally running WordStar 3.0

Wordstar 3.0 with all his glory running on a C64:

I implemented all fast screen operations like insert and delete lines, clear to the end of the line. So the usability of the Wordstar here is pretty good. Only the disk access is really slow but this is a chronic C64 feature.

Running SOFT80 on MESS

MESS has support to CP/M cartridge. You just need to launch the mess with the command below:

mess64 -c64 -cart cpm -flop1 ws3.d64 

Every disk I provided in my link comes with the CP/M boot and the SOFT80. So you can boot directly from them.

Don’t forget when changing floppies you need to press CTRL+C on prompt to allow CP/M to refresh the file entries. Otherwise the disk is deemed Read Only.

Enjoy your new C64 CP/M…

Poor man’s C64 S-Video MOD

I got an early NTSC 5-pin A/V Commodore 64 in very good condition, except that it was dead: black screen. After some investigation I found out it was a dead VIC-II. Since I only had in hand a 6569, I replaced the XTAL and the jumper and modified to PAL. Well at least I got some good demos on it right ?

IMG_0350

So the next step was getting a decent video output from it. It turns out these machines are known for the poor video quality you get from either RF or the composite video. Also these machines lack the Chroma output, they only have a super bright Luma output. The PAL mod had already killed my RF but who still uses RF anyway ?

Since I had success in past modding some TRS-80 Color and Atari 800’s adding the S-Video output I decided to investigate the least invasive way to do it because I don’t like defacing these old computers. Everything I do I make in a reversible way, so drilling holes in the case is a no for me.

The C64 5-pin already has Luma, although in my unit it is too bright. The problem is lack of Chroma, needed for a color S-Video output. The Chroma is generated from the VIC-II but the signal is tainted by the composite and RF circuits.

Measuring the Luma on my scope I could confirm it was 1.52 Peak to Peak. Sounds correct ? Let’s see: the analog video should be 1.0V Pk-Pk, being 0V Black and 1.0V deep white plus the sync pedestal of about 0.5V negative what seem to match the 1.52 Pk-Pk measure right ? Well think twice: this is the C64 welcome blue screen and not a deep white screen, the Luma should never reach 1.0V, there is no white on this screen. So clearly this confirms the signal seems a bit strong for the S-Video.

IMG_0347

So for use the original Luma in our S-Video mod we will need to attenuate it a little bit.

Instead of going to use color control screens and doing the math with a 75 Ohms impedance I just played around with some values and found that 150 Ohm was good enough. As I said this is a poor man’s S-Video we don’t do the engineering…

For the Chroma output it turns out some monitors will accept the composite video output as Chroma input, because internally they have low pass band filters anyway so if you are luck just a simple cable like this will be enough, add a 150 Ohm for the Luma and 330 Ohm for the composite as Chroma:

IMG_0334

In my LG 1721A monitor this looks pretty nice but it looks dreadful in my Dell 2001FP. The image suffers from the infamous checkerboard syndrome and is unreadable.

Thanks for the people from lemon64.com forum for pointing me out: the R10 resistor in this machine is wrong: 300 ohms instead of 120 ohm as the schematics from the service manual. The R10 together the R11 serves as a voltage divider for the Chroma and as Bias for the Luma.

Screen Shot 2018-07-11 at 12.47.19 AM

This 300 ohms R10 seems to be a factory error on all 326298 boards. You just need to replace this resistor to a 120 ohms and you get a much better composite video and also the new composite video works as a charm for the Chroma output in our modified S-Video cable.

 Here is the result:

IMG_0343

This is how it looks like in my Dell 2001FP monitors. As good as you get.

Other screens on my LG:

IMG_0356

And CRT in my PVM 8″:

IMG_0354

And a little bit of global thermonuclear war:

IMG_0353

Enjoy your new C64 🙂