2001 August 22: cpm-0.2.1-mod3

This release compiles on modern Linux systems, too.

The Z80 emulation was extended to support many unofficial instructions
(all of them regarding to IXh and IXl registers). The Z80 emulation was
also reviewed and enhanced, and now it's almost perfect. The only
instructions that return wrong flags are DAA, CPL, SCF and CCF. The
emulator pass almost all test cases of ZEXDOC (the Z80 Documented 
Instructions Exerciser from YAZE).

The BDOS location was also changed (from 0xF006 to 0xFC06), to free more
memory for the CP/M programs (TPA now is 64512 bytes, 3kb greater than
previous version).

Added option -x: When calling emulator with command line parameters,
there is no need to load CCP anymore. Instead, the .COM file is loaded in
memory and automatically executed (the first argument must be the name of
the .COM file in the directory selected). So, when using the emulator in
batch mode, there's not need of a cpm.sys file (nice when you
aren't root and can't complete install the emulator). When the emulator is
called with parameters in the command line (with or without option -x) it
becomes quiet as possible.

Finally, in the debugger you can set more than 15 repetitions for
listpoint/breakpoint.

 -- "Adriano C. R. da Cunha" <adrcunha@yahoo.com.br>

2000 March 3: cpm-0.2.1-mod2

This release compiles on modern Linux systems.

A font file with the Kaypro 2x character generator bitmaps is now
included. It's called `kaypro2x.fnt'. A program to convert such
bitmaps into X11-style BDF fonts is also included. It's called
`fnt2bdf'.

The `format' utility was renamed to `cpm-format'.

A Bash script, `xcpm', is also included. It can run on the console,
under X11, or inside a VT100 terminal emulator (I recommend installing
GNU `screen' if your terminal isn't VT100-compatible.) It tries to use
colors and fonts reminiscent of the Kaypro 2x's. It's really a
complete hack...

I have modified the Makefile to include an `install' target which puts
everything in /usr/local/{bin,lib/cpm} by default; change PREFIX in
the Makefile to install elsewhere. This target does require X11 to be
installed, as it uses bdftopcf to convert a font file. A complementary
`uninstall' target is also included.

 -- "Benjamin C. W. Sittler" <bsittler@iname.com>

From the cpm-0.2.1-mod:

I have updated this for our primary local purpose, playing Ladders
and Catchum. These games were produced by `Yahoo Software' in the
early 1980's, and the copies I have were `installed' for a Kaypro
computer, such as the Kaypro 2x I used to play them on.

The Kaypro 2x supports several extensions to the ADM 3A terminal
escapes, and I added translations to vt52() for some of these
extensions. vt52() should probably be replaced by a proper curses
applications so we don't depend on having an ANSI terminal, but I'm
lazy...

Here are the added escape sequences:

ESC E (insert line)
ESC R (delete line)
ESC B 0 (start reverse video)
ESC C 0 (stop reverse video)
ESC B 1 (start half intensity)
ESC C 1 (stop half intensity)
ESC B 2 (start blinking)
ESC C 2 (stop blinking)
ESC B 3 (start underlining)
ESC C 3 (stop underlining)
ESC B 4 (cursor on)
ESC C 4 (cursor off)
ESC B 6 (remember cursor position)
ESC C 6 (restore cursor position)

The following sequences are recognized by vt52() but don't cause any
ANSI output:

ESC B 5 (enter video mode)
ESC C 5 (leave video mode)
ESC B 7 (preserve status line)
ESC C 7 (don't preserve status line)
ESC * row+32 col+32 (set pixel)
ESC SPC row+32 col+32 (clear pixel)
ESC L row+32 col+32 row+32 col+32 (set line)
ESC D row+32 col+32 row+32 col+32 (delete line)

I also added a VBELL #define in io.c which causes those annoying BELs
to be replaced by temporary flashing, providing your terminal supports
the ESC [ ? 5 h and ESC ? 5 l sequences (invert and revert screen.)
Both XFree86 3.3.1 xterm and the Linux console support them, so I'm
happy.

TTY output conversions are disabled.

The emulator now starts out in `accurate timing' mode so that the game
is playably slow.  I found a 4MHz emulated Z80 to be closer to the
Kaypro 2x speed than the 2MHz emulated Z80 was, so I made a FASTZ80
#define. I moved the benchmarking code into its own function which is
called every time the program is run. This allows the accurate timing
to work.

NOTE: Timing is horribly inaccurate. Sorry. This is a result of
      switching from timed gettimeofday() calls to nanosleep(),
      and of the other hackery I have performed to get Kaypro support.

I added BDOS function 32, "Get Disk Parameters", so that Catchum had a
chance of working (I still had to patch the Catchum binary, though.)
Here's the change I made to `catchum.com', starting at offset 3c87: I
replaced the CALL instruction (cd 8c 3c) with 3 NOP's (00 00 00).
Here are the `sum' outputs for the original and modified binaries, as
seen on an i586 Linux system:

25346    29 catchum.com (original)
05646    29 catchum.com (modified)

 -- "Benjamin C. W. Sittler" <bsittler@iname.com>

From the original cpm-0.2.1:

The original author of cpm-0.2, Michael Bischoff, cannot be reached
under the e-mail address given in the cpm.lsm. I have therefore decided
to put this version on sunsite myself. The only changes so far were to
make it compile under modern Linux systems using the ELF binary file format
and to make it easy to change the location where it will look for its
files (CPMLIBDIR in the Makefile). 

It seems that DIR doesn't work using the emulated BDOS. I haven't tried
running a real CP/M yet.

Achim Oppelt <aoppelt@theorie3.physik.uni-erlangen.de>       Mar-4-1998

Original README follows:

%
%  Time-stamp: <06/06/94 23:08:26 Michael Bischoff moulder>
%
% CP/M emulator README
%

Introduction:
=============

Type 'UNIX' at the CCP prompt to leave the emulator.
(Or ctrl-@, followed by 'q' any time the keyboard is polled)


WARNING! This software runs only on 386 compatible processors
and systems which allow nonaligned word/dword memory access.

WARNING! This software has no documentation. If you want to use it, you're
probably a Real Programmer; and Real Programmers don't read documentation.

WARNING! This software is supplied AS IS. There is No Warranty!

The software emulates an Intel 8080 CPU (quite accurate,
except for the halfcarry flag for a couple of instructions)
and a lot of Zilog Z80 instructions (not the complete set).
Unimplemented instructions are input/output commands (IN A,(nn); OUT (nn),A;
  INI, OUTI, INIR, OTIR, IND, OUTD, INDR, OTDR, IN C,(r), OUT r,(C)), and
interrupt mode commands (IM 0, IM 1, IM 2, RETN, RETI), and the refresh
register doesn't count at all.

A 486DX2-66 emulates a Z80 clocked at 22 MHz, a 386DX-33 simulates a 6MHz
Z80. (approximately)


The BDOS emulator does only provide
- user 0
- a single drive (A:)
- access to lowercase-files.

A CCP-lookalike command interpreter is provided and the BDOS
is emulated. The CCP is stored in the file /usr/local/lib/cpm/cpm.sys.
Any CP/M .COM-files may also go in the directory /usr/local/lib/cpm.

If you have an original CP/M, with CCP-address e800, BDOS-address f006,
and put it in the file /usr/local/lib/cpm/cpm.sys, you can have an
emulator quite near to the original thing, using the -e option.
The -e option tells the emulator to use the BDOS from cpm.sys,
instead of catching the BDOS-calls.
Pros:
- a real CP/M running
- access to CP/M-formatted floppies (you have to set the DPB correctly)
  Try "cpm -e -i /dev/fd1" with a 800 KB CP/M floppy in B:
	 (bls = 2K, drm = 255)
  after setting setfdprm -p /dev/fd1 800/1200 or the like.

Cons:
- no access to the Linux filesystem


About the emulator:
===================

Type "cpm -h" for a short usage message.
You can interrupt the emulator by typing ctrl-@. This will enter
the debug mode, where you can disassemble z80 memory, dump memory,
edit data, set listpoints, breakpoints, set counts for breakpoints
and the like. Type '?' for a short summary.


extensions:
BDOS:
 there is a new BDOS function (41), "change directory"
 and a CP/M program CD.COM which calls this function.

CCP:
 ERA understands the /Q option (question!)
 Example: ERA *.*/Q
 TYPE understands the /W option (wait!)
 Example: TYPE TEST.TXT/W
 You can access files from other user numbers (image mode only)
 Example: ERA *.BAS/2

 Again: Type UNIX to leave the Emulator.



TODO:
=====
- Improve the emulation of BDOS
- Allow multiple drives (some as CP/M filesystem images?)
- implement interrupt modes / signal catching to simulate NMI, INT
- improve the accuracy of the emulator (but; after all, a Z80 isn't
  8080-compatible as well; the sequence
	XOR A
	DEC A
	JP PO,Z80_installed
	/* an 8080, if we are here */
  will find out...
- merge the code with xtrs-80, to play GALAXY again!


BUGS:
=====

Surely there are LOTS of bugs. Please send fixes to mbi@mo.math.nat.tu-bs.de
Bug reports (without fixes) are also accepted, but it would be nice if you
could track down the bad opcode.
