This part is concerning using the z80pack Z80 emulator to run CP/M on Linux, and afterward using the CP/M implementation to run Zork 1. I've chosen Zork 1 for this example since it's a non-trivial program that, nonetheless, uses lone plain content input and output. Running item akin WordStar power be additional illustrative, but it raises terminal-related problems that I don't desire to enter in this simple example. However, I volition conversation this topic at the end of the article.
Note:
There is entirely no applicable logic to perform Zork using a CP/M emulator. There are many improved ways to perform Zork -- should you desire to -- on a contemporary computer. A logic -- likely the lone logic -- for using a CP/M emulator is to rotate into acquainted alongside CP/M in general, alongside a perspective to construction your own Z80-based retro computer.
Zork is an first example of what these days is called "interactive fiction", but was cognize as a "text adventure" rear in the days whenever all computing was text-based. Zork accepts uncomplicated instructions akin "take axe" and "look at box" as input to what is basically a puzzle-solving exercise. CP/M is an first functioning system, initially for microcomputers alongside floppy drives, but eventually for first difficult drives. Almost nobody under the age of 50 remembers using CP/M whenever it was the latest and greatest, but its bequest lives on in MS-DOS, which it inspired.
CP/M was initially developed for 8080 microprocessors, but was additional widely used alongside the Z80. To run CP/M on Linux, likely the easiest method is to use a Z80 emulator.
In this part I'll outline how to get and build z80pack and several CP/M tools for Linux, how to set up virtual disks to shop the Zork files, and how to run the program from the CP/M command prompt.
I'm assuming that you're acquainted alongside Linux, and consenting to work with command-line tools. I additionally assume you have at smallest an inkling what CP/M is.
Installing z80pack
I don't think that z80pack is routinely accessible in norm Linux repositories -- if it is, it power not be up-to-date. You'll need to Download the source and build it.
Unpack the origin into any convenient directory. I'm using $HOME/lib/z80pack-1.37.
Compile the core:
$ cd ~/lib/z80pack-1.37/cpmsim/srcsim $ create -f Makefile.linux
Compile the supporting tools:
$ cd ~/lib/z80pack-1.37/cpmsim/srctools $ create -f Makefile.linux
Test that the facility is basically functional, by starting CP/M 3:
$ cd ~/lib/z80pack-1.37/cpmsim $ ./cpm3
Note that cpm3 is fair a script, that runs ./cpmsim following copying relevant disks from the disk depiction archive (more on this below).
Build and instal cpmtools
cpmtools is a set of utilities for managing CP/M disk images. It can list disk depiction contents, and copy records to and from them. We'll need this for copying program records and data from the presenter system to CP/M.
cpmtools is accessible in assorted Linux repositories, but I established that the repository type for my (Fedora 31) scheme did not activity reliably. It's easy to build from source, however.
Download the source. Unpack the archive, run ./configure, afterward make, the sudo create install. The default facility is in /usr/local/bin which may, or may not, be in your $PATH.
How z80pack handles disks
z80pack uses records (images) to portray bodily disks, as most virtualisation application does. The records have a construction that is in some senses a depiction of a bodily disk, so the tools that manipulate them (that is, the utilities from the cpmtools package) need to cognize about physical disk structure. The cpmtools utilities assume, by default, a 720kB, 8-inch floppy disk -- this is fine for many purposes. It will be fine for operating Zork 1, in fact, but I'll explain how to create a hard disk depiction anyway, since it's apt that you'll need to at some point.
cpmsim looks for disk images in the "./disks" directory by default. That is, it looks in a directory related to the current working directory. It supports, essentially, six disk devices: floppy drives A: to D:, and difficult disks I: and P:. It expects to discover images for these disks as files drivea.dsk, driveb.dsk, etc. If these image files are not all present, cpmsim volition motionless commencement -- it volition fair respond as if there's no average in the drive.
The minimum needed to footwear CP/M 3 is the depiction disks/library/cpm3-1.dsk as run A: However, there are several helpful utilities on the second disk of the CP/M set, destined for run B: So:
$ cp disks/library/cpm3-1.dsk disks/drivea.dsk $ cp disks/library/cpm3-2.dsk disks/driveb.dsk
You should now be capable to run ./cpmsim, and you'll discover that lone drives A: and B: are available.
Let's create a 4Mb difficult disk to assist as run I: (CP/M-3 really supports up to 500Mb, but 4Mb is additional than adequate for this example).
$ /usr/local/bin/mkfs.cpm -fz80pack-hd disks/drivei.dsk
In this command, z80pack-hd refers to a set of bodily disk parameters that are stored in the document /usr/local/share/diskdefs. Omitting this indicator volition outcome in the innovation of a 720kB floppy disk image.
Obtaining and installing the Zork 1 program files
Like all the first Infocom games, the Zork sequence exists in a kind of lawful limbo, and likely volition continue to do so for at smallest another ten years. It isn't apparent who now owns the intelligent property, and what redistribution terms, if any, exist. Consequently, although it's easy to get clasp of the CP/M type of Zork 1, there is no "official" source, and I'm not going to be hosting it myself. I got my copy from here.
The CP/M type of Zork 1 consists of two files: the binary ZORK1.COM and the data document ZORK1.DAT. The data file is really a z-machine program, and can be played using various alternative z-machine emulators, akin frotz. These two records need to be placed into the identical disk image, akin this:
$ /usr/local/bin/cpmcp -fz80pack-hd disks/drivei.dsk ZORK1.COM 0: $ /usr/local/bin/cpmcp -fz80pack-hd disks/drivei.dsk ZORK1.DAT 0:
Note:
CP/M disks do not assistance subdirectories. Instead, they have numbered "user areas" which can be selected at the command prompt. In the commands above, we're copying to the default person area, area zero.
Playing Zork 1
There is a minor complication connected to the use of the "backspace" key in cpmsim. In general, Linux terminals and terminal emulators generate the DEL code (ASCII 127) whenever you hit the backspace key. The CP/M command immediate volition react to DEL and erase a character, but Zork 1 requires the additional traditional "ctrl-h" (ASCII 8). You could motionless category "ctrl-h" explicitly to delete a character, but it's additional elegant to set the terminal so that the backspace key really generates a ctrl-h. With Gnome terminal, the applicable environment is in the "Compatibility" tab of the overview settings page. Other terminals and terminal emulators volition have another ways to change this setting.
Having made this change, you'll likely have to inform the Linux terminal infrastructure concerning the new key mapping, or the backspace key won't activity anywhere except in Zork. To do that:
$ stty erase ^H The Linux casing should motionless activity as normal, but the backspace key will be generating a distinct code. Now it have to be extremely straightforward to run Zork 1:
$ ./cpmsim ... ... A> i: I> zork1 ZORK I: The Great Underground Empire Copyright 1982 by Infocom, Inc. All entitlements reserved. ZORK is a trademark of Infocom, Inc. Release 25 / Serial figure 000000 West of House You are position in an open site west of a pale house, with a boarded forefront door. There is a small mailbox here. >open mailbox Opening the mailbox reveals a leaflet. >read leaflet (Taken) WELCOME TO ZORK ZORK is a equivalent of adventure, danger, and low cunning. In it you volition examine several of the most amazing district ever seen by mortals. No device have to be without one! Copyright 1982 by Infocom, Inc. All entitlements reserved. ZORK is a trademark of Infocom, Inc.
... and distant we go.
Further adventures alongside CP/M
CP/M was a hugely famous functioning scheme in its day, and there is a massive amount of application accessible for it. Much of it is in a legally-uncertain position, as the Zork games are. However, the software is uncomplicated to get and, as "abandonware", using it for personal and educational purposes is improbable to disturb anybody.
The "killer app" for CP/M was WordStar, and this rudimentary term processor is motionless available, and amazingly extensively used. Another honourable mention goes to Borland's Turbo Pascal -- an astonishingly fine compiler, which used assorted tricks to get about the constricted RAM (64k) that the Z80 could address.
All these applications are screen-based, fairly than line-based; operating them raises complications connected to terminal handling. There was no universal way of doing terminal output in a CP/M use -- all application made its own provision. z80pack does not provision a terminal -- it fair passes the output from the CP/M program to the terminal that is hosting it. Most Linux terminal emulators are broadly VT100-like, and if you configure CP/M application to use a VT100 or VT52 terminal, you'll probably get sensible results.
Have you posted item in reply to this page?
Feel liberated to dispatch a webmention to notify me, giving the URL of the blog or leaf that refers to this one.