Old Article

This is an old article which is only being kept for historical purposes.

Please navigate and update any links to the new article: Emulating a CP/M System with z80pack.

Setting up z80pack to Create an Emulated CP/M System

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

  • First download the source (z80pack-x.y.tgz, currently z80pack-1.17.tgz) for z80 pack from here. 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.
  • Unpack the source archive in your home directory:
    $ tar xzvf z80pack-x.y.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.16 z80pack
    
  • Compile the emulator:
    $ cd ~/z80pack/cpmsim/srcsim
    $ make
    $ make clean
    
  • Compile the support programs:
    $ cd ~/z80pack/cpmsim/srctools
    $ make
    $ make clean
    

This 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
Creative Commons License
Setting up z80pack to Create an Emulated CP/M System by Lawrence Woodman is licensed under a Creative Commons Attribution 4.0 International License.

Share This Post

Feedback/Discuss

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

Emulating a CP/M System With z80pack

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-pan...   Read More

Installing the HI-TECH Z80 C Compiler for CP/M

My language of choice is C and I am currently getting more involved with the CP/M operating system. I have therefore decided that it would be nice to have a C compiler working under CP/M. There are a...   Read More

Hamurabi and Similar Games on CP/M

Hamurabi is probably the best known land and resource management game on CP/M. However, there are a few other similar text-based games that sought to extend the concept such as Dukedom and Kingdom. T...   Read More

Advanced Use of .LBR files on CP/M

Lots of utilities make use of .LBR (Library) files to provide extra facilities such as the ability to run commands from archives or mount them as if they were drives. This article shows some more adva...   Read More