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…

7 thoughts on “Tinkering with C64 CP/M

  1. I really enjoyed your post about CP/M on the C64. Have you tried any terminal software (such as MEX) to control a serial device on the user port (such as a modem)? Do you have any idea if serial communication would function when booted into CP/M on this platform?

    Like

  2. Would you be able to outline the process of creating a new .D64 image that uses your modified (enhanced) CP/M configuration with SOFT80? I see you have created a number of these for a variety of ‘popular’ software packages and would like to try creating a different one.

    Regarding the modem – I don’t have one either. My plan is to test in emulation (WinVice) using tcpser.exe with flags -v 25232 -s 1200

    Below is the rest of the configuration that links WinVice with tcpser.exe which is now bound to the loopback IP of your localhost.

    WinVice Configuration:
    RS232 userport settings
    > enable emulation
    > userport device RS232 device 1
    > userport baud rate 1200

    RS232 settings
    > RS232 device 1 127.0.0.1:25232

    Thanks.

    Like

  3. Thanks Felipe – ctools worked really well. I poked around with it for a while and could not get data to tx/rx on the Commodore user port. After a little research I found this important design note in the C64 CP/M user’s guide. If you know of any software that already contains this functionality do let me know. My assumption is that it may not exist.

    3.5 THE COMMODORE 64 USER PORT

    Your Commodore 64 user port can accommodate some useful optional devices. Most interesting from CP/M are the VICMODEM and the RS-232 communications cartridge. If you acquire one of these cartridges and you want to
    access it from CP/M, you must write the processing code for execution in native mode under the 6510 main processor. This is necessary because these cartridges generate nonmaskable interrupts which must be handled by the 6510 processor.

    You can gain access to special code for handling these cartridges through BIOS65 function codes 7, 8, or 9. (See
    the discussion of the CP/M BIOS in Chapter 6 for details on using these function codes.)
    In designing this code, you should consider receiving a certain number of characters-say 128 or 256-into a shared buffer. When you have received these characters, inform the device you are communicating with that you are not ready to receive data. You can then safely switch control from the 6510 main processor to the Z80. which can do
    whatever is required with those characters.

    For detailed information on programming for the RS-232 port, see the Commodore 64 Programmer’s Reference Manual.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s