Pi1541 adventure!

Enter the Pi1541! What makes this different from the SD2IEC is that this emulates both the 6502 processor of the 1541 drive, it also emulates the two 6522 chips as well giving far stronger emulation. Is this enough to satisfy CP/M? Or is my issue something deeper?

Cleaned up a little

So in my continuing adventure of stuff arriving for my Commodore 64 project, I took the opportunity to pull the keyboard apart and clean it. I didn’t do any weird retrobrite thing, as I don’t care that this looks 30+ years old. And I haven’t swapped out any further caps just yet, although I did also get a big box of random caps ranging from 0.1 to 220uF, so I can probably do all the small stuff on the board when I feel like it next.

It took a bit extra effort to get this far.

The IEC cables had finally arrived, and that means I could connect up the Pi1541 hat I bought and get this project going.

Although it’s the latest ‘rev 4’ board, it doesn’t support the Pi4 (does anything support the Pi4? What an evolutionary dead end!), auction did include the LCD display, but no software, and no serial cable. The cooler looking one I wanted was all assembled in Poland and they are unable to ship.

Bummer.

Anyways, turns out the software is written by one Stephen White, who doesn’t get any cut of the board sales, but in turn I guess they aren’t bundling the software either… I’d have imagined it’d be some kind of 1+1 thing, but it’s not to be. I guess it’s also why so many people keep on thinking you can buy a PiZero for $5 or so, when they are much closer to $25.

Anways, getting the initial part of the board working was just a matter of reading Steve’s site, and following which files to be download, and where to be placed onto a FAT32 formatted SD card. This is one of those ‘bare metal’ type projects, so this also doesn’t run Linux.

Unfortunately for me the Pi1541 didn’t do ANYTHING on powering on, that is until I connected the HDMI cable. And yeah what a let down. And even worse when trying to load anything it’d just hang. So frustraiting!

But thanks to this post by jerrykurtz over on lemon64, I was able to put together this fragment to get it working (for me!)

deviceID = 8
splitIECLines = 1
scrollHighlightRate = 0.07
ChargenFont = chargen
OnResetChangeToStartingFolder = 1
GraphIEC = 1
SoundOnGPIO = 1
SoundOnGPIODuration = 1000
SoundOnGPIOFreq = 1200
LCDName = ssd1306_128x64
LcdLogoName = 1541classic
i2cBusMaster = 1
IgnoreReset = 1

Now this of course works for my v4 hat, and the way I like it. Also keep in mind that if the C64 isn’t detected it will appear to hang after loading the chargen ROM. It took a while to figure that out, until I just turned on the c64 to see what would happen. I also hate having it change disks when I power cycle, so IgnoreReset was a great feature, well for me anyways.

I fired up CP/M, and yeah it’s doing the same thing. So it turns out that it’s not the SD2IEC adapter that I have. I’m kind of mixed about this, on the one hand that’s great as the SD2IEC’s are significantly cheaper and easier to come by, at the same time I had hoped a little that the bigger investment of the Pi1541 would make the difference. At least it’ll be the difference for stuff like Ghosts’N’Goblins Arcade.

CP/M Planetfall

One interesting thing is that SOFT80 is now faster, getting somewhere between 1-3cps. It’s still totally unplayable, but I guess that’s progress?

Still waiting for the dead test cart to see if it tells me anything useful.

Big plans going nowhere

Ever since I found that ‘cheap’ Commodore 64 online I’ve been wanting to try something. The machine came with a tape drive, so I ordered some ‘cheap’ reproduction tape game, to see if it worked.

1530 mech

While it almost works, it sees the program on the tape, the thing stalls out. Granted it being dated to 1991 probably means the belts are beyond usable. I am having a friend proxy some belts for me as nobody will ship them to Hong Kong (pandemic didn’t have any real effect there).

While this machine is a newer ‘C’ model, I’ve had seen this auction pop on and off on Ebay from time to time advertising a refactored and improved CP/M cart advertising that it works on all models. I’ve read somewhere that post 128 that they finally had figured it out, far too late to matter. But maybe with this new cartridge things could work?

I managed to get a SD2IEC board delivered from Germany, which uses external USB power, so it won’t tax the C64 PSU (I should look, is there an ATX to C64 PSU?). I can load some silly games and stuff seemingly okay. I haven’t bothered with GEOS, as I used it far too much when I had to, and it’s just far too slow to even dream of being usable. Anyways with the SD2IEC it came with ZERO instructions but I did find the page with the needed firmware, and the ‘FB64.PRG’ program to have it browse the SD card and mound D64 images as needed.

I have to admit, ever since I did that article about “Running CP/M on the Commodore 64” I’ve been dying to try this on real hardware. With all the excitement in the room, I mounted the CP/M disk, and held my breath as the *’s went across the screen….

DDDDDDDDDOOOOOOOOOOBBBLE TROUBLEEEEEEEEEEEE

And, well something isn’t right. I tried a bunch of images I could find online, and they all do the same thing. They print far too many characters on the screen from time to time. Clearly it’s some timing/IRQ issue. Something to do with the VIC chip.

Despite the screen being corrupt, it is running, and it does let you run commands, it’s just the output is being doubled (or 10x!) up.

So I tried the soft80 program which will setup an 80 column CP/M experience. It didn’t matter what version I used, the old one from the 80’s or the patched up one from Luis Antoniosi, they all do the same thing, which is run at a blistering 1cps.

I thought it’d be fun to stream this old beast playing the CP/M version of planetfall, but at 1cps I just can’t do it. Which is just a shame. I haven’t tried a regular C64 Infocom game, as the 40 cols was always crazy, but I guess it’s the fallback.

I know these things are so rare, but I had high hopes for this thing.

So close, and yet so far away.

Running CP/M on the Commodore 64!

 

CP/M cartridge retail box

Back in 1983 there was this great idea of expanding the Commodore 64 with the then popular (but declining) base of serious business software from the CP/M side of the world by creating a cartridge with a z80 processor inside, and a special port of the CP/M operating system that would take over the C64 letting you run real programs like Fortran, Cobol and the far better (and updated) Microsoft Basic v5!

However as always the major failing of CP/M was the massively different and incompatible diskettes of every platform.  The Commodore 64, lacking in RS-232 ports, and it’s incredibly incompatible 1541 drive rendered it nearly impossible for the average home user to transfer any programs in the specially formatted CP/M diskettes for the cartridge.  Not being able to read a standard 1541 diskette would prove to be it’s undoing.

While messing around in Vice, I saw that this cartridge is emulated now!  A quick search led me to zimmers.net where I was able to then locate the needed cpm.d64.gz, and I was booted up into CP/M and of course that hit the first snag which is of course, where is the software?

Well another search brought me to the package ‘ctools‘ which I quickly built on the Linux subsystem for Windows (I had to add -fpermissive to get it compile..), and now I could take that CP/M diskette delete the contents, and for the heck of it insert in Zork.. Of course where to find Zork along with other CP/M software?  The zip zork123_80.zip can be located on retroarchive.org, even fun things like Microsoft BASIC v5.21 (Interpreter), along with the manual.

CP/M only recognized a single drive, so you have to swap diskettes (Such a typical Commodore 64 experience), and here we go!

via Vice

Naturally the Commodore 64’s 40 column mode is… terrible.

However even back in 1984, a fine program aptly called soft80.com sets up the Commodore 64 in high resolution graphics mode, and emulates an 80 column mode.  Even better, the magic for the most part happens on the 6502 side, meaning it doesn’t take away from the precious memory on the CP/M side.

Zork 1 under CP/M / Soft80

Its worth noting that although Infocom games are dreadfully slow on the Commodore 64, playing under CP/M is also dreadfully slow, taking some 10-15 seconds to complete a command.

At least under emulation there is the warp mode.  And what took an hour to put together would have been months no doubt in the 1980’s ending in the CP/M cartridge going into a drawer to never be seen again.

A Z80 on a cart is pretty interesting.  It would have been interesting if other CPUs had made their way, a 68000 would have been interesting to have bridge the 8 bit world out, or even if Commodore had tried to put an 8088 onto that card, as early PC’s were nowhere near the 640kb hard disk wielding monsters they would become much later.  Naturally one could only dream of the power of an 80386 or the once vaunted NS32016

CP/M Exchange and the CP/M Player

Exchange & CP/M Player

Exchange & CP/M Player

While on the road, I stumbled onto a link that referred to this program called Exchange, which is a decapitated ‘port’ of CP/M that simply allows you to read and write CP/M disk images.  While on the surface it may not seem much, but the fact it actually uses the 68000 kernel from CP/M seemed really interesting to me.  With minor fighting I had it running on MinGW!

http://anachronda.homeunix.com:8000/~rivie/exchange/

And what fun would that be if we left it there? Oh sure you can get files in and out of standard 8″ images, but can you run them?

Over at the Takeda Toshiya’s page, not only does he make the MS-DOS player, and a whole host of other Japanese machine emulators, but he also has a CP/M player that works in the same style!

http://takeda-toshiya.my.coocan.jp/

So, combine the two, and now you too can trivially export and import files for emulators like SIMH, or just run files naively at the Win32/Win64 command line!

SIMH on demand!

Ok starting with my shellinabox post, I’ve expanded to include SIMH’s Altair emulator!

CP/M 2.2 in a box!

CP/M 2.2 in a box!

Executing this is really simple!  A small shell script will take care of the whole thing.

#!/bin/sh
set -m
PID=$$
mkdir /tmp/$PID
cd /tmp/$PID
cp /usr/local/altair/1.ini .
cp /usr/local/altair/cpm22.dsk .
/usr/local/altair/altair 1.ini
cd /tmp
rm -rf /tmp/$PID

Of course I’m assuming dead processes get reaped.  But check it out!

I’ve put BASIC-80 rev 5.21 and ZORK I in there!

Some advice on SIMH thought, you can execute a shell with the ! command (hitting Control-E will interrupt SIMH) so to prevent that alter the line in scp.c to make sure it’s a noop_cmd instead of spawn_cmd.  Not that anyone was doing anything sneaky as the nobody user, but to prevent it.

{ “!”, &noop_cmd, 0, HLP_SPAWN },

Also an ini file of:

attach dsk0 cpm22.dsk
set throttle 2%
go 177400
exit

Keeps SIMH pretty tame.

Additionally I guess I should do a 12 hour cronjob to kill displaced altairs.

CP/M-68K Simulator

I found this last night, and thought it was worth sharing.

This simple CP/M-68K simulator, is built around the famous Musashi MC68000 simulator core.  So it’s a little more well debugged than the SIMH CP/M-68k. Namely that COM works!

COM running Zork1 on CP/M-68K

COM running Zork1 on CP/M-68K

I managed to build this under Window with MinGW, the only caveats were that it opens the disk files without explicitly in binary so on Windows it opens everything in ASCII and nothing works.  Also MinGW doesn’t emulate a vt100 or provide termios so all of that had to be commented out.  But for the full experience you’d want to run it on *NIX.

I suppose you could write an ANSI intercept, and manipulate the NT Console, but that is a lot of work.

On the plus side, this solution is more stable, faster and feels more robust with a 16MB hard disk, and a standard IBM 3740 floppy disk in the ‘a’ position.

One thing that was a snag to me, was the windows version of cpmtools is built to default to the apple-do type, aka Apple II CP/M skew for DOS 3.3 … So I was trying to setup a floppy image with too much work.  Also the default size of the 3740 disk is 256,256 bytes.

For example:

 

C:\temp\cpm\cpmtools>cpmls -f ibm-3740 zork1.cpm

0:
bye.com
zork1.com
zork1.dat

But if you find z80/8080 CP/M too mainstream, give the 68k a shot!

telnettable Altair 8080 clone!

complete with Zork!

Trying 192.222.136.174
Connected to micronick.com.
Escape character is ‘^]’.

Welcome to my Altair 8800 Clone !
Press ENTER…

A>dir
A: ZORK1 COM : ZORK1 DAT : ZORK2 DAT : ZORK3 DAT
A: ZORK2 COM : ZORK3 COM
A>zork1
ZORK I: The Great Underground Empire
Copyright (c) 1981, 1982, 1983 Infocom, Inc. All rights
reserved.
ZORK is a registered trademark of Infocom, Inc.
Revision 88 / Serial number 840726

West of House
You are standing in an open field west of a white house, with
a boarded front door.
There is a small mailbox here.

>

As seen on reddit!

Be sure to check out the web page for a live picture of the machine in action!

SAGE CP/M disk fun

Wow this was without a doubt one of the more confusing things I’ve ever done.

So here is the problem. I want to delete some files from an IMD disk image, and then copy some new ones in.  Easy right? .. maybe.

Ok first up the easiest tool I’ve found to manipulate CP/M disk images is cpmtools.  Even better their pre-compiled binary is for Win32, so I’ll run it with Wine on OS X.  which works fine. Â Although there is one slight problem, cpmtools doesn’t read the IMD disk format.  So you will have to download imd118.zip from a backup of the late author’s computer.

Now using IMD you need to convert the OS disk into a ‘raw’ or ‘binary’ file.  Naturally IMD is a MS-DOS program so firing up DOSBox, I ran:

Screen Shot 2013-12-05 at 8.35.58 PM

Uncompressing, so easy!

IMDU CPM68K12.IMD CPM.RAW /B

And a few seconds later I had my raw file.  Now the next thing was to manipulate the image in cpmtools.  cpmtools has a database of disk drive types, and naturally there is no definition for the SAGE2.  However thanks to a friend of mine (hi Lorenzo!) I took a look at 22disk, and found their demo version did in-fact have a definition for the SAGE:

BEGIN SAG2 Sage IV – DSDD 96 tpi 5.25″
DENSITY MFM,LOW
CYLINDERS 80
SIDES 2
SECTORS 8,512
SIDE1 0 1,2,3,4,5,6,7,8
SIDE2 1 1,2,3,4,5,6,7,8
ORDER SIDES
BSH 4 BLM 15 EXM 0 DSM 315 DRM 63 AL0 080H AL1 0 OFS 2
END

Which is great, however it took a bit of experimenting to work out how to format this information for cpmtools.  I compared a bunch of known formats, and then managed to work this out:

diskdef sage2
seclen 512
tracks 160
sectrk 8
blocksize 2048
maxdir 128
skew 1
boottrk 2
os 2.2
end

And now I can look at the image file!

$ wine cpmls -f sage2 CPM68K12.RAW
0:
ar68.68k
armath.sub
as.sub
as68.68k
as68symb.dat
asgo.sub
brwnies.txt
copy.68k
core.sub
cpm.sys
ddt.68k
ddt68000.68k
dump.68k
e.sub
find.68k
halt.68k
init.68k
linkcore.sub
lnk.sub
lo68.68k
m.sub
mcc.sub
mince.68k
mince.swp
mind.sub
orbit.sub
p.sub
pe.sub
pip.68k
print.68k
red.sub
redasm.sub
sage4utl.68k
sagebios.sys
screen.68k
setenv.68k
setprntr.68k
sig.txt
space.sub
spacem.sub
startup.sub
stat.68k
tlnk.sub

So, I tidy up the image and copy it back to the IMD program for compressing.  And this was, without a doubt the most difficult to figure out, until after a bunch of searching, and Lorenzo once more again pointed me in the direction of bin2imd

not intuitive!

not intuitive!

So yeah.

BIN2IMD X.RAW X.IMD DM=2 N=80 SS=512 SM=1-8 /2

And the best part is that it worked!  So now I was able to transfer over a binary version of com.68k, com2.68k, along with Zork, and fire it up!

8080 Zork on 68k CP/M

8080 Zork on 68k CP/M

Unfortunately, the interpreter doesn’t work right.  It could be the disk transfers fault, maybe the SIMH SAGE emulator, or even the 8080 emulator.  But it worked this far.

SAGE CP/M 68k on SIMH

Somehow, I missed this as a ‘beta’ driver for the last public release of SIMH.

68k CP/M 1.2

68k CP/M 1.2

What makes the 68000 version of CP/M different from the i8080 version is that it was coded in C.  And of course 68k CP/M suffered the same problem every other processor incompatible ‘same os’ OS has ever suffered which is no applications.  But that is when I remembered the COM, which started out it’s life as an 8080 emulator for the 68000.  With a LOT of creative googlling, I managed to find the source, mysteriously labelled 8088M.ZIP.  I also found a binary here. But unfortunately that is as far as I got.  I haven’t managed to figure out a way to inject files into the SAGE CP/M IMD disk images.

So this is where I’m stuck, and this is my call for help.  If anyone knows how to get files in/out of these IMD files give me a shout.  For anyone interested in 68k CP/M this is your chance to get it running.

The one funny thing I found in a hex editor of the disk image was this:

Screen Shot 2013-12-05 at 12.20.20 AM

Cryptic message

Oh well.

 

***EDIT***

Never mind, me and a friend of mine (hi Lorenzo!) got the disk image thing figured out!