Emulating a CP/M System With z80pack

  /     /   CP/M     Emulation     Retro     Tutorial    

z80pack is great for creating an emulated CP/M system. It can either be used to create a general CP/M system or can emulate a specific system such as an IMSAI or ALTAIR including a graphical front-panel. It is well documented and is being actively developed.

Installing z80pack

  • First download the source (z80pack-x.y.tgz, currently z80pack-1.36.tgz) for z80pack from here. The following installation instructions are adapted from those on the z80pack site. More information can be found there, in particular, information on installing z80pack on non Linux/Unix systems.

  • Unpack the source archive in your home directory:

    $ tar xzvf z80pack-1.36.tgz
    
  • Change the directory it is extracted to, to make this article easier to explain. There is no need for you to do this.

    $ mv z80pack-1.36 z80pack
    
  • Compile the emulator for your operating system, e.g. for linux use -f Makefile.linux:

    $ cd ~/z80pack/cpmsim/srcsim
    $ make -f Makefile.operating-system
    $ make -f Makefile.operating-system clean
    
  • Compile the support programs:

    $ cd ~/z80pack/cpmsim/srctools
    $ make
    $ make clean
    
  • If you want to copy the srctools to your ~/bin directory then from within ~/z80pack/cpmsim/srctools run:

    $ make install
    

This leaves a few bash scripts in the ~/z80pack/cpmsim/ directory, cpm2, cpm3, mpm, etc, which automatically start the emulator by booting into CP/M 2.2, CP/M 3.0, MP/M, respectively.

Backup Included Disk Images

z80pack includes a number of disk images in ~/z80pack/cpmsim/disks/library/. These can easily get corrupted so it makes sense to backup these first:

cd ~/z80pack/cpmsim/disks/library
cp -p * ../backups

I also keep my own disk images of useful software in the library/ directory and keep a backup in the backups/ directory as well.

Creating disk images

We now needed to create some disk images; to do this I recommend Cpmtools which is a part of many Linux distros. If you don't have this as part of your distro, the source can be downloaded from here. Cpmtools is a great collection of tools used to manipulate CP/M images and file systems in a variety of formats and works well with z80pack.

Creating Floppy Diskette Images

The emulator uses 8" SD disk drives as the first 4 drives: A:, B:, C:, D:. This disk specification is the default for Cpmtools. To create a floppy diskette image called, work.floppy.cpm, run:

$ mkfs.cpm work.floppy.cpm

When working with floppies I create a blank floppy called blank.floppy.cpm and then just copy that every time I want to create a new image, rather than creating the image directly.

Creating Hard Disk Images

z80pack supports a 4Mb hard disk image connected to the I: drive and a 512Mb hard disk image connnected to the P: drive. These can be particularly useful when dealing with bigger applications such as a C compiler.  To create these we can use Cpmtools, but first we need to make sure that it has the correct disk definitions by editing the diskdefs file typically found in /usr/share/ or /usr/local/share/ and adding the following lines, if not already present:

# 4mb HDD for z80pack
diskdef z80pack-hd
  seclen 128
  tracks 255
  sectrk 128
  blocksize 2048
  maxdir 1024
  skew 0
  boottrk 0
  os 2.2
end

# 512mb HDD for z80pack
diskdef z80pack-hdb
  seclen 128
  tracks 256
  sectrk 16384
  blocksize 16384
  maxdir 8192
  skew 0
  boottrk 0
  os 2.2
end

To create a blank 4Mb Hard Disk image called main.hd4.cpm, run:

$ mkfs.cpm -fz80pack-hd hd4.cpm

To create a blank 512Mb Hard Disk image called main.hd512.cpm, run:

$ mkfs.cpm -fz80pack-hdb hd512.cpm

Managing Files on Disk Images With Cpmtools

Cpmtools comes with a number of commands such as: cpmls, cpmcp, cpmrm. These allow you to manage files on a disk image and get them on and off. With all of the commands below if using a 4Mb HDD image add -fz80pack-hd and for a 512Mb HDD image add -fz80pack-hdb after the Unix command.

CP/M has 16 'user areas' which can be used to organize data on a disk. They are effectively like a crude directory system. User area 0 is the default and the only one we will work with in this article.

To copy all the .DOC files from the current directory into the image, work.floppy.cpm in user area 0 run:

$ cpmcp work.floppy.cpm *.DOC 0:

To copy all the .COM files from the current directory into the hd4.cpm image in user area 0 we need to specify the format with -fz80pack-hd:

$ cpmcp -fz80pack-hd hd4.cpm *.COM 0:

To copy all the .DOC files in user area 0, from the work.floppy.cpm image to the current directory:

$ cpmcp work.floppy.cpm "0:*.DOC" .

To list the files on work.floppy.cpm:

$ cpmls work.floppy.cpm

Configuring z80pack

In the ~/z80pack/cpmsim/ directory there are a number of scripts such as cpm2, cpm3, etc. These are scripts which tell z80pack which disk images to use for which drives. We can edit these or create our own. z80pack expects the disk image files to be in ~/z80pack/cpmsim/disks/ with the first four 8" floppy disks called drivea.dsk to drived.dsk, the 4Mb HDD called drivei.dsk and the 512Mb HDD called drivep.dsk. You don't have to have all these disks, but this is what is available to be used.

As an example we'll create a script called work which uses our 4Mb HDD and floppy disk images created above. First copy main.hd4.cpm and work.floppy.cpm to the ~z80pack/cpmsim/disks/library/ directory. It is also worth copying them to the backups directory as well: ~/z80pack/cpmsim/disks/backups/

Now create a script in ~/z80pack/cpmsim/ called work to start z80pack with our disk image files attached:

#!/bin/sh
rm -f disks/drive[abci].dsk
cp disks/library/cpm3-1.dsk disks/drivea.dsk
cp disks/library/cpm3-2.dsk disks/driveb.dsk
ln disks/library/work.floppy.cpm disks/drivec.dsk
ln disks/library/main.hd4.cpm disks/drivei.dsk
./cpmsim -f4

This attaches the two CP/M disks on drive A and B, our work.floppy.cpm image on drive C:, and our main.hd4.cpm image on I:. I copy rather than create links to disk images I know I don't want altered to keep them in a consistent state. The line ./cpmsim -f4 tells the emulator to run at 4Mhz, which makes it a bit more realistic.

To make the script executable run:

$ chmod +x work

Starting the Emulator

From the ~/z80pack/cpmsim/ directory, run the script we created:

$ ./work

The CP/M operating system will now boot up and leave you at the A> prompt. You will have access to the A: and B: diskette images which will contain the CP/M 3 files. C: will be linked to your work.floppy.cpm disk image and I: will be linked to your 4Mb HDD image.

For here you can run the normal CP/M commands such as DIR and start exploring.

There is a command on the A: drive called bye to leave the emulator:

A> bye

Where Now?

I have a growing number of CP/M articles on this site and there is also a CP/M Playlist on the TechTinkering YouTube Channel.

Creative Commons License
Emulating a CP/M System With z80pack by Lawrence Woodman is licensed under a Creative Commons Attribution 4.0 International License.

Related Articles

Transferring Files to and from CP/M .D71 Disk Images Using ctools

Using Vice to emulate a Commodore 128 running CP/M works very well, but it isn't easy to get CP/M files directly onto and off a .D64/.D71 disk image. The easiest way to do this under Linux is to use c...   Read More

Connecting to a Remote Serial Port over TCP/IP

Most modern machines don't have a serial port as standard; you could use a USB to serial lead, however, if you have another machine available that does have a serial port you can access it remotely ove...   Read More

Emulating a DEC PDP-8 with SimH

The DEC PDP-8 mini-computer was launched on 22 March 1965 and was a great success. It was fairly cheap for the day and could easily be expanded. What attracts me most to the PDP-8 is its simple desig...   Read More

Using the latest z80pack, version 1.17, to emulate an Altair 8800 or IMSAI 8080 using the new graphical FrontPanel

Udo Munk has just released the latest version of his z80pack emulator, version 1.17, which now includes John Kichury's FrontPanel library. As well as being a superb emulator to run CP/M on, it now giv...   Read More

Using DOSBox to Run DOS Games and Applications

There were some brilliant games and applications released for DOS, and some of the games such as Command and Conquer are still very playable. There are a number of options to play these games today, f...   Read More

Sign up to get new articles straight to your inbox.

Delivered by FeedBurner

Comments

blog comments powered by Disqus