• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..30-Aug-2018-

tests/H03-May-2022-

MakefileH A D03-May-20221.3 KiB5836

README.mdH A D30-Aug-201811.8 KiB295223

TERM.mdH A D30-Aug-20181 KiB4741

TODOH A D30-Aug-2018944 4027

bdos.cH A D30-Aug-201820.7 KiB841709

bios.cH A D30-Aug-201820.5 KiB972706

bye.macH A D30-Aug-2018188 1210

cpm.cH A D30-Aug-201832.7 KiB518515

cpmdisc.hH A D30-Aug-20181,012 3422

cpmtool.cH A D30-Aug-201833.1 KiB993792

defs.hH A D30-Aug-20187.5 KiB299197

disassem.cH A D30-Aug-201811.4 KiB854715

getunix.macH A D30-Aug-20182.2 KiB9687

main.cH A D30-Aug-201822.3 KiB1,125811

putunix.macH A D30-Aug-20181.4 KiB10491

vt.cH A D30-Aug-20187.7 KiB341313

vt.hH A D30-Aug-2018249 143

z80.cH A D30-Aug-201841.6 KiB2,0711,705

README.md

1
2# ANSI CP/M Emulator and disk image tool
3
4This emulator allows you to execute CP/M commands on UNIX (Linux or Cygwin).
5
6If a CP/M command is provided on the command line, it is executed
7immediately.  For example, this will start WordStar:
8
9	cpm ws
10
11Otherwise, you will get the CP/M command prompt:
12
13	cpm
14	A>
15
16By default, BDOS is emulated so that the current directory in UNIX appears
17as the __A>__ drive from CP/M.  The BDOS emulation can be optionally
18disabled.  In this case, P2DOS (a BDOS clone) is used to access real disk
19images.
20
21This is a modified version of Parag Patel's [CP/M](https://en.wikipedia.org/wiki/CP/M) emulator.  This
22version includes a filter/emulator for an [ADM-3A](https://en.wikipedia.org/wiki/ADM-3A) terminal as
23emulated by a [Kaypro 2x](http://www.oldcomputers.net/kayproii.html).  Basically it converts ADM-3A codes
24into ANSI codes on output and converts arrow keys and PgUp / PgDn into
25WordStar motion keys on input.
26
27This allows screen oriented programs written for Kaypro-II such as WordStar,
28Turbo PASCAL and dBASE-II to operate directly with ANSI terminal emulators,
29such as Xterm or RXVT for Linux and Cygwin.
30
31The output side of the VT52/ADM-3A and the BDOS emulation comes from
32Benjamin C.  Sittler bsittler@iname.com from another emulator:
33cpm-0.2.1-mod2.  CPM-0.2.1 is i686 only- it's partially written in assembly
34language.  Hence I prefer Parag's all C emulator.
35
36Type 'make' to build the program.
37
38Type './cpm __command__' to execute a CP/M .COM file located in the current
39directory.
40
41Type './cpm' to get the __A>__ prompt.  Type __bye__ to exit back to UNIX.
42
43Type './cpm --nobdos' to start it without BDOS emulation and instead use
44disk images called A-Hdrive and B-Hdrive.  In this case:
45
46At the __A>__ prompt:
47
48Type __bye__ to exit back to Linux
49
50Type __putunix cpm-file unixfile__ to copy a file out of CP/M and to UNIX/Linux.
51
52Type __getunix unixfile cpm-file__ to copy a file from UNIX/Linux into CP/M.
53
54The A-Hdrive and B-Hdrive disk images include some programs.  Many more are
55available from here.
56
57[http://www.retroarchive/org/cpm/](http://www.retroarchive.org/cpm/)
58
59Here is CP/M WordStar running on Ubuntu in an xterm:
60
61![CP/M WordStar](cpmws.png)
62
63			-- Joe Allen
64
65## cpmtool
66
67This is a tool which allows you to manipulate CP/M disk images.  It
68currently supports two image formats and automatically detects the correct
69format:
70
71* 8 inch CP/M 1.4 floppy images of exactly 256,256 bytes
72	* 128 byte sectors / records
73	* 77 tracks
74	* 26 sectors per track
75	* Two reserved tracks at the beginning
76	* 243 1K blocks
77	* 2 blocks for the directory
78	* 6 unused sectors at the end
79	* Sector interleave: 1,7,13,19,25,5,11,17,23,3,9,15,21,2,8,14,20,26,6,12,18,24,4,10,16,22
80
81* 5 MB ST-506 hard disk image
82	* 128 byte sectors
83	* 64 sectors per track
84	* Two reserved tracks at the beginning
85	* 2442 2K blocks
86	* 16 blocks for the directory
87	* No sector interleave
88
89    Syntax: cpmtool path-to-disk-image command args
90
91    Commands:
92
93      ls [-la1A]                    Directory listing
94                  -l for long
95                  -a to show system files
96                  -1 to show a single name per line
97
98      cat cpm-name                  Type file to console
99
100      get cpm-name [local-name]     Copy file from diskette to local-name
101
102      put local-name [cpm-name]     Copy file to diskette to cpm-name
103
104      free                          Print amount of free space
105
106      rm cpm-name                   Delete a file
107
108# Original README
109
110This is a Z80 instruction-set simulator written entirely ANSI C.  It can
111boot and run CP/M or CP/M clones.  It's also got a builtin debugger
112which supports tracing, single-stepping, breakpoints, read or write
113protected memory, memory-mapped I/O, logging, and disassembly.  This is
114not the fastest emulator around, but it's very portable.
115
116So far z80 has been tested under Linux, FreeBSD, DEC's UNIX on Alpha,
117and SunOS, the Macintosh using either Think C or CodeWarrior (PPC and
11868k), MS-DOS using DJGPP, and the BeOS.  It should be quite easy to port
119to other UNIX-line systems.
120
121The file "Makefile" will need tweaking for your system.  The two key
122compilation flags are -DLITTLE_ENDIAN and -DPOSIX_TTY as described
123further in the Makefile.  You'll almost certainly have to tweak the
124other make variables, such as CFLAGS and CC.  Then just type "make".
125
126For the Macintosh, the file "MacProj.hqx" is a BinHex SIT archive with
127three project files for Think C, CodeWarrior 68k, and CW PowerPC.
128
129The file "main.c" contains UNIX routines for character-mode I/O, if
130these need to be ported to your flavor of UNIX.  They're pretty generic
131and ought to work under just about anything.
132
133Once z80 is built, run it, and enter 'b' at the prompt to boot CP/M.
134Enter '?'  to see a list of debugging commands it understands.  The
135interrupt character, ^C, is wanted by CP/M for its own uses, so to force
136the z80 into its debugger, use ^_ (control-underscore).  (You may have
137to type <return> after the ^_ to wake it up.)
138
139If z80 is linked or renamed to "cpm", it will directly boot into CP/M
140without displaying the debugger prompt.  If an "A-Hdrive" doesn't exist
141in the current working directory for CP/M, it will be created.
142
143The file "z80.c" contains the emulator proper.  Most variables are
144accessed via macros defined in "defs.h".  The file "bios.c" contains the
145mock-BIOS code that allows the emulator to boot and run CP/M or its
146clones.  The file "cpm.c" contains an image of P2D0S 2.3 and ZCPR1, so
147it should be safe to distribute freely.  (This allows the z80 to
148directly boot CP/M.)
149
150The z80 program will automatically create virtual CP/M "drives" as they
151are accessed, and will only allocate disk space for them when it is
152needed.  The obsolete "makedisc.c" program is included to allocate all
153the space for a floppy at once and also allows placing a single Unix
154file within it.
155
156The "bios.c" code is built for two 5Mb virtual hard-drives (A-Hdrive,
157and B-Hdrive), and a bunch of floppy drives (C-drive, D-drive, and so
158on).  It is possible to rebuild it for different numbers of hard-drives
159by changing the macro NUMHDISCS at the top.  The hard disks emulated are
160the venerable ST-506 5Mb 5" 5Mb drives.  The floppies are the
161traditional 8" 256k drives.  The code names the virtual hard-drives as
162"?-Hdrive" and floppies as "?-drive" to help avoid accidentlally
163confusing one for the other.  Their contents should be identical to the
164real thing, even down to the reserved tracks, assuming I did it right.
165
166There are several "*.mac" files which are Z80 macro-assembly sources for
167getting files from UNIX into CP/M (GETUNIX.MAC), putting files out from
168CP/M to UNIX (PUTUNIX.MAC), and quitting the emulator (BYE.MAC).  All
169these files are also in "A-Hdrive", all assembled and ready to run.
170They do little useful error checking, but it should be pretty obvious
171from the code how they work.  Any text files transfered into CP/M must
172have CR-LF as the line separator or it gets awfully confused.
173
174Usage:
175	PUTUNIX <CP/M-file> <unixfile>
176	GETUNIX <unixfile> <CP/M-file>
177	BYE
178
179Additional utilities that come with the P2DOS23 distribution are also
180included to support the date/time functions of P2DOS.  These are located
181within the "A-Hdrive" and within the P2DOS archive.  These are date.com,
182ddir.com, initdir.com, public.com, set.com, and touch.com.
183
184I had picked up a Z80 assembler named "zmac" from the Internet quite
185some time ago.  I've hacked it heavily to add a lot of support for
186different assembler formats but it's still kind of finicky.  You'll need
187yacc of some flavor to compile it up.  Sorry, but I don't have a
188Makefile for it any longer.  The "*.z" files there are sample assembly
189sources.  There's also a separate Z80 disassembler that came with zmac.
190Unfortunately the sources did not come with any copyright, but the file
191"zmac.y" does contain a somewhat cryptic list of folks who hacked it.  I
192don't know if "zdis" is by the same authors or not - there are no
193comments in it.
194
195zmac assembled P2DOS 2.3 (off of the CP/M archives on oak.oakland.edu)
196without too much trouble.  ZCPR1 (from the archives) needed to be
197converted from the .ASM format to .MAC, which I did using XLATE5 (also
198from the Oak archives).  Then the resulting output had to be hacked
199somewhat so that zmac could assemble it.  Z80DOS23 and Z80CCP from the
200archives also assembled up without much trouble.
201
202To play with different BDOS/CCP replacements, just rename the assembler
203output HEX file from wherever you built it into the files "bdos.hex" and
204"ccp.hex".  If z80 sees these in the current directory, it will load
205them to boot CP/M instead of using its builtin versions of P2DOS/ZCPR1.
206
207There's a lot of stuff to do in this code, but it's functional enough to
208leave the rest as an exercise for the student.  The Mac version needs a
209really cool interface, with separate windows for the out, setting
210registers, tracing, a virtual terminal, etc.  The debug-level prompting
211code pretty much sucks and needs to be thrown out.
212
213This code has been designed so that the z80 emulator proper should be
214thread-safe and runs independently of CP/M.  It should be possible to
215run multiple z80s within one program if desired.
216
217The CP/M layer may be built so that the fake BIOS is turned into real
218Z80 code with all I/O occurring through fake devices using either
219INPUT/OUTPUT or the memory-mapped I/O hooks.  Conversely, it's also
220possible to turn then entire BDOS/CCP into C code much as the BIOS is
221currently coded with magic hooks that trigger the appropriate actions.
222
223Use this code as you wish, so long as it is properly attributed.  That
224is, display our copyrights where you would display yours (manuals,
225boot-up, etc) and do not claim that this code is yours.  If you do use
226it, please drop me a note.  This code is "as-is" without any warrantee.
227Be warned that P2DOS23 and ZCPR1 only allow free redistribution for
228non-commercial use.  (See their documentation for more details.)
229
230Copyright 1986-1988 by Parag Patel.  All Rights Reserved.
231Copyright 1994-1995 by CodeGen, Inc.  All Rights Reserved.
232
233
234		-- Parag Patel <parag@cgt.com>
235
236
237Version history:
238
2393.1	Added support for virtual 5Mb ST-506 drives in bios.c.
240	Fixed a few bugs in emulator, fake BIOS, and console I/O.
241	String search for "cpm" in argv[0] now uses strrchr() in main.c.
242	Change all "(char)" casts to "(signed char)" for AIX and other
243		systems that have "char" default to "unsigned".
244	Making a start at adding support for printing.
245
2463.0	First public release 1995.
247	Use publicly available P2DOS23 and ZCPR1 instead of
248		copyrighted CP/M 2.2.
249	Added date/time support for P2DOS and its utilities.
250
251## Readme from cpm-0.2.1-mod2
252
253The Kaypro 2x supports several extensions to the ADM 3A terminal
254escapes, and I added translations to vt52() for some of these
255extensions. vt52() should probably be replaced by a proper curses
256applications so we don't depend on having an ANSI terminal, but I'm
257lazy...
258
259Here are the added escape sequences:
260
261	ESC E (insert line)
262	ESC R (delete line)
263	ESC B 0 (start reverse video)
264	ESC C 0 (stop reverse video)
265	ESC B 1 (start half intensity)
266	ESC C 1 (stop half intensity)
267	ESC B 2 (start blinking)
268	ESC C 2 (stop blinking)
269	ESC B 3 (start underlining)
270	ESC C 3 (stop underlining)
271	ESC B 4 (cursor on)
272	ESC C 4 (cursor off)
273	ESC B 6 (remember cursor position)
274	ESC C 6 (restore cursor position)
275
276The following sequences are recognized by vt52() but don't cause any
277ANSI output:
278
279	ESC B 5 (enter video mode)
280	ESC C 5 (leave video mode)
281	ESC B 7 (preserve status line)
282	ESC C 7 (don't preserve status line)
283	ESC * row+32 col+32 (set pixel)
284	ESC SPC row+32 col+32 (clear pixel)
285	ESC L row+32 col+32 row+32 col+32 (set line)
286	ESC D row+32 col+32 row+32 col+32 (delete line)
287
288I also added a VBELL #define in io.c which causes those annoying BELs
289to be replaced by temporary flashing, providing your terminal supports
290the ESC [ ? 5 h and ESC ? 5 l sequences (invert and revert screen.)
291Both XFree86 3.3.1 xterm and the Linux console support them, so I'm
292happy.
293
294 -- "Benjamin C. W. Sittler" <bsittler@iname.com>
295