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.

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 at 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!

Found an old ad for 86-DOS

Seattle 86 Ad

GO 16-BIT NOW – WE HAVE MADE IT EASY
8086
8 Mhz. 2-card CPU Set
WITH 86-DOS®
ASSEMBLED,TESTED,GUARANTEED
With our 2-card 8086 CPU set you can upgrade your Z80 8-
bit S-100 system to run three times as fast by swapping the
CPUs. lf you use our 16-bit memory, it will run five times as
fast. Up to 64K of your static 8-bit memory may be used in the
8086’s 1-megabyte addressing range. A switch allows either 4
or 8 Mhz. operation. Memory access requirements at 4 Mhz.
exceed 500 nsec.
The EPROM monitor allows you to display, alter, and
search memory, do inputs and outputs, and boot your disk.
Debugging aids include register display and change, single
stepping, and execute with breakpoints.
The set includes a serial port with programmable baud rate,
four independent programmable 16-bit timers (two may be
combined for a time-of-day clock), a parallel in and parallel out
port, and an interrupt controller with 15 inputs. External power
may be applied to the timers to maintain the clock during
system power-off time. Total power: 2 amps at + 8V, less than
100 mao at + 16V and at -16V.
86-DOS@>, our $195 8086 single user disk operating
system, is provided without additional charge. It allows
functions such as console 1/0 of characters and strings, and
random or sequencial reading and writing to named disk files .
While it has a different format from CPIM, it performs similar
calls plus some extensions (CP/M is a registered trademark of
Digital Research Corporation). Its construction allows relatively
easy configuration of 1/0 to different hardware. Directly
supported are the Tarbell and Cromemco disk controllers.
The 86-D08@> package includes an 8086 resident assembler,
a Z80 to 8086 source code translator, a utility to read
files written in CPIM and convert them to the 86-DOS format, a
line editor, and disk maintenance utilities. Of significance to
Z80 users is the ability of the translator to accept Z80 source
code written for CPIM, translate this to 8086 source code,
assemble the source code, and then run the program on the
8086 processor under 86-D08. This allows the conversion of
any Z80 program, for which source code is available, to run on
the much higher performance 8086.
BASIC-86 by Microsoft is available for the 8086 at $350.
Several firms are working on application programs. Call for
current software status.
All software licensed for use on a single computer only.
Non-disclosure agreements required. Shipping from stock to
one week. Bank cards, personal checks, CODs okay. There is
a 10-day return privilege. All boards are guaranteed one year
– both parts and labor. Shipped prepaid by air in US and
Canada. Foreign purchases must be prepaid in US funds.
Also add $10 per board for overseas air shipment.
8/16 16-BIT MEMORY
This board was designed for the 1980s. It is configured as
16K by 8 bits when accessed by an 8-bit processor and
configured 8K by 16 bits when used with a 16-bit processor.
The configuration switching is automatic and is done by the
card sampling the “sixteen request” signal sent out by all S-
100 IEEE 16-bit CPU boards. The card has all the high noise
immunity features of our well known PLUS RAM cards as well
as “extended addressing”. Extended addressing is a replacement
for bank select. It makes use of a total of 24 address lines
to give a directly addressable range of over 16 megabytes.
(For older systems, a switch will cause the card to ignore the
top 8 address lines.) This card ensures that your memory
board purchase will not soon be obsolete. It is guaranteed to
run without wait states with our 8086 CPU set using an 8 Mhz.
clock. Shipped from stock. Prices: 1-4, $280; 5-9, $260; 10-up,
$240.

~Seattle (amputer Products, Inc. ~ 1114 Industry Drive, Seattle, WA. 98188
(206) 575-1830

 

The ad is from December of 1980, and of course the PC was released in August of 1981… Its interesting to see even back then there was some clear partnering with Microsoft!

Transferring data into CP/M with SIMH

This has been an exersize in insnaity..

So for some strange reason I wanted to load up Zork into SIMH‘s less featured (and much simpler) altair 8080 emulator.  The catch is the disk format which for the life of me I couldn’t get to work in any of the CP/M disk access tools.

The Altair z80 emulator as part of the same SIMH package includes a far more complicated setup, but out of the box it CANNOT read the disk image from the 8080 emulator.  After digging around it seems that one of the ‘approved’ methods of getting stuff into CP/M was to load it into memory, and just save the block (provided it fits in the 64k, more on that later).  The syntax really is quite simple:

load zork1.com 100

And that’ll load it up at the normal program entry point (just like an MS-DOS COM file!)..

Except it doesn’t want to work.

What?

but of course it works on the z80.

No problems here!

Which is great but the z80 can’t read the 8080’s disks..!  So after digging through the source code, I find this small gem that the z8080 has been changed to use a much larger disk size!

#define MAX_TRACKS 254 /* number of tracks,
original Altair has 77 tracks only */

So yes, by changing that to 77 I can now boot off the 8080’s boot disk on the z80!  Of course it also means that I’m unable to ‘see’ the hardisk in the z80, or any of the other great peripherals as no doubt the altair CP/M disk hasn’t been configured for all of these fine things.  I also tried only altering one of the disks on the z80 for 77 tracks, but once more again it seems that CP/M has an everything/nothing type idea for a disk controller.

But the load command works on the monitor, and the Altair CP/M can handle two disks, so its enough for me to format the B: drive ( a copy of the CP/M disks) and work with that.

Once you’ve loaded a program into memory, you toggle back to CP/M and run the ‘save’ command which then dumps how many pages back to disk.

For example, the program STAT is 5,248 bytes in size. 5248/256 = 20.5. Thus, the save command would be:

A>SAVE 21 STAT.COM

Pretty simple, right?  But what happens if you have a file greater than memory?  Well first I thought I could compress it, and I’d forgotten just how many old compression programs there were for CP/M, crunch, arc, zoo, zip … Finding MS-DOS equivalents wasn’t too bad (thanks for dosbox!) but I couldn’t get the 84kb data file into the memory limit, so I figure’d I’d just split the file into something on  a 256 byte boundary.  Loading them into RAM wasn’t too hard, as saving them out.. but how do you join them together on CP/M?  I found PLENTY of utils to split files, but nothing on putting them back together!

On MS-DOS you can just do a copy /B file1+file2 bigfile

But I couldn’t find out how to do this on CP/M until I looked further into the PIP command, CP/M’s answer to copy.

To join a binary file it goes something like this:

>PIP sd.com=sd.001[OV],sd.002[OV],sd.003[OV]

So with all that work, I was now able to create a zork1.dsk that the 8080 emulator is capable of playing!

Zork1 finally loaded on the SIMH Altair 8080

And for the curious, here is Zork1, in the old Altair 77 track format.

 

 

Island 8080 Emulator

Island 8080 running CP/M on MinivMac

I’ve never heard of this before, but a friend pointed me towards this this page, that has a CP/M version that’ll run on a Macintosh.  But as they list out it ONLY works on super ancient Mac’s namely the 128k & 512k varities.  Plus owners & everyone beyond them is out of luck.

So what is there to say?  Well it does in fact run CP/M, and the demo disk includes WordStar but without a clear way of getting data on & off the diskettes it is kind of .. pointless?  I’m sure back in the day this would have been an awesome programme for Macintosh users as you could run ‘all that CP/M’ stuff out there on these giant 400kb diskettes.  Needless to say the rise of the IBM PC killed that and everyone went to MS-DOS but for some people I’m sure this was the tipping point of why to go Mac.  In this day & age emulators to run emulators may seem silly but I figured it was at least worth mentioning that this did in fact exist…

I suppose I could rig something to transfer the 8080 version of Zork1 to it, but is it worth the effort?