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.

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.

CP/M & Zork in Java Script!!!

Yes, it’s finally happened!!!!

This morning, I got an email from Stefan Tramm, informing me of his work.. Basically he’s combined ShellInABox’s vt100 commands, js8080’s Intel 8080 emulator, along with z80pack’s disk format, and CP/M port to provide a CP/M emulator that works in Java Script!!!

YES.

It is that cool.

Now the emulator is one of these new fancy HTML5 applications, which means you’ll need either Google Chrome 5, or Safari 5.. I would imagine Internet Explorer 9 and a later Firefox ought to work….

One thing that you’ll want to do is configure your popup blocker to allow the domain tramm.li to open up popup windows, as that is how you mount disk images into the VM..

To get going though it’s real simple. Just click http://www.tramm.li/i8080/ and hit the “Start Emu8080” link, and you’ll get to the console.

Next you’ll have to download a copy of CP/M 2.2 from the server into your local browser datastore by type in:

 

CPM-1

r 0 cpma

Then load in the bootsector…

CPM2

 

b

Then start executing at 0

CPM3

 

g 0

 

Then you’ll be in CP/M

All running in a browser!

So taking it one step further, I downloaded and built the Cpmtools 2.13 on OS X, used the cpma.cpm disk image as a template, deleted it’s contents and then inserted the ZORK 1 data & program into the disk image… Giving you a zork1.cpm.

So if you’ve turned off the popup blocker on Chrome, you can type in the ‘dsk’ command before you boot up CP/M. This way you can load it into the disk 1 position (B:) then boot up CP/M and play….

CP-M Zork1 on Javascript

 

All and all, I have to say this is really impressive for something like javascript to actually be somewhat usable… Naturally a 3Ghz+ CPU makes it all possible…. lol GWBasic users back on the 4Mhz machines ought to cringe every time thinking about the level of speed required to pull this off…!!!!

And thanks to Stefan for emailing me about this!

— edit

Stefan has added the zork1 disk image onto his server, so you can now simply load it via:

r 1 zork1

And that’ll place Zork 1 into the ‘B:’ drive.

Some Java & Javascript

Well I found this program, Dioscuri quite interesting… It’s a PC emulator written in JAVA!

It’s very interesting in how it’s trying to be accurate hardware wise, although holding down keys tends to cause it to crash…. 😐

Maybe a later version will work, but for what it’s worth, here is the title screen from Battle Tech.

battletech

The best game of 1988!

Naturally, any machine with a good JVM ought to be able to run this… But I’ve always found Java to be such a moving target….

Another thing I came across was this fantastic i8080 emulator coded in javascript. And it’s setup to play space invaders!

On Chrome, or Firefox it should perform at a reasonable rate. Internet explorer users are in the cold, as IE doesn’t have a javascript canvas. Sorry. But here is what you are missing out on.

javascript space invaders

Complete with i8080 emulator in Javascirpt!

 

This is some really neat stuff (to me) anyways.

Toledo 8080 emulator!

While googling around on various i8080 CPU emulators, I came across this post, from the 19th IOCCC. Best of Show winner, Óscar Toledo.

Simply put, it’s amazing, 3.5kb of source that emulates not only an 8080 CPU, but a basic environment capable of running CP/M.

That’s right. 3.5k!!

I’ve found it runs great with either the SUA/SFU environment for Windows, and Linux x86.

Toledo2 running on Vista's SUA Unix emulation.

Toledo2 running on Vista’s SUA Unix emulation.

Anyways it doesn’t work on the Sparc QEMU thing, nor my m68k NeXT cube… But hell it’s amazing to watch this thing in action. If you have the right setup you should check it out!

Also today, a copy of Zork 1 for CP/M on 8″ diskette arrived! I’ll have to take some photos of it later.