Setting up z80pack to create an emulated CP/M system
Written by Lawrence Woodman on 17th October 2008
Tags: CP/M, Emulation, Retro, Tutorials, Z80

Picture of loading screen for CP/M 3.0 on z80pack I have decided to try out some old CP/M software, but need something to run it on.  I could either do this on my Commodore 128 or through emulation.  Unfortunately the 1571 disk drive for my Commodore is currently out of action, so that leaves me with emulation.  I was going to use vice to emulate a C128, but have always found it a pain to get CP/M files onto .D64/71 disk images.  After looking around for the best emulator to run CP/M on, I came up with either YAZE-AG or z80pack.  z80pack seems to be better supported, has more documentation and is being actively developed, so that's the one I have chosen for this article.

Installing z80pack

  1. First download the source (z80pack-x.y.tgz, currently z80pack-1.16.tgz) for z80pack from its ftp site.  The following installation instructions are taken from the z80pack site.  More information can be found there, in particular, information on installing z80pack on non Linux/Unix systems.
  2. Unpack the source archive in your home directory:
    $ tar xzvf z80pack-x.y.tgz
  3. 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.16 z80pack
  4. Compile the emulator:
    $ cd ~/z80pack/cpmsim/srcsim
    $ make
    $ make clean
  5. Compile the support programs:
    $ cd ~/z80pack/cpmsim/srctools
    $ make
    $ make clean
This is leaves, on Linux, a few bash scripts in the ~/z80pack/cpmsim/ directory, cpm2, cpm3, mpm, which automatically start the emulator by booting into CP/M 2.2, CP/M 3.0, MP/M, etc.

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.

Create a 4Mb Hard Disk Image

It would be useful to create a 4Mb Hard Disk Image, as this may be needed if we want to use any bigger applications such as a C compiler.  To create this we can use Cpmtools, but first we need to make sure that it has the correct disk definition by editing /etc/cpmtools/diskdefs and adding the following lines:

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

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 create a blank 4Mb Hard Disk image called main.hd4.cpm, run:
$ mkfs.cpm -fhd main.hd4.cpm

Then to copy all the .COM files from the current directory into the image in user area 0, run:
$ cpmcp -fhd hd4.cpm *.COM 0:

Create a Floppy Diskette Image

To create a floppy diskette image called, work.dsk.cpm, run:
$ mkfs.cpm work.dsk.cpm

Then to copy all the .DOC files from the current directory into the image in user area 0: run:
$ cpmcp work.dsk.cpm *.DOC 0:

Configuring z80pack

We now have a 4mb disk image and a floppy disk image.  We can connect them to the emulator by creating a script in the ~/z80pack/cpmsim/ directory called work.  First copy main.hd4.cpm and work.dsk.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].cpm
ln disks/library/cpm3-1.dsk disks/drivea.cpm
ln disks/library/cpm3-2.dsk disks/driveb.cpm
ln disks/library/work.dsk.cpm disks/drivec.cpm
ln disks/library/main.hd4.cpm disks/drivei.cpm
./cpmsim -f4

This attaches the two CP/M disks on drive A and B, our work.dsk.cpm image on drive C, and our main.hd4.cpm image on I:
The line ./cpmsim -f4 tells the emulator to run at 4Mhz, which makes it a bit more realistic.

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.

To leave the emulator type:
A> a:bye

Where Now?

For more information on CP/M take a look at the Resources section under CP/M.




Creative Commons License
Setting up z80pack to create an emulated CP/M system
by TechTinkering is licensed under a Creative Commons Attribution 2.0 UK: England & Wales License.
Add a Comment

Please leave a comment.  I would love to hear what you think.
All comments are checked before displaying to prevent SPAM.

Your Name (Optional)

Your Email (Optional)
Not displayed, just used to pickup a Gravatar

Your Website (Optional)

Comment

All comments preformatted i.e. newlines and spaces display properly.
All HTML will be displayed literally e.g. <br /> will not create a line break.
URLs beginning with http:// or ftp:// will be converted to links.

        Privacy Policy

Contact Details

I would love to hear from you and welcome your feedback on the site.

You can keep in contact with me through the following services:
Click to get email address
GitHub
Linkedin
Twitter
Delicious
StumbleUpon
YouTube
Technorati
FriendFeed
MyBlogLog