$Id: README,v 1.5 2011-04-08 23:14:27 drmiller Exp $

This is the start of a Z80 Simulator, mainly targeting CP/M programs.

This initial version does not implement all Z80 instructions, and certainly
there are bugs to find.

It does have a simple BDOS emulator which will allow running
of vanilla CP/M programs (code that only calls BDOS, does not directly
access BIOS or hardware).

I plan on eventually being able to simulate a Z89 such that any code should run.

The BDOS simulator will use native file systems to hold CP/M files.
BIOS and Hardware simulation will use raw disk images on the native
filesystem.

Perhaps there will be some BDOS enhancements to allow both modes, so that
CP/M images can be created from native files.

Configure TRACE in z80_sys.h if you *might* want to trace simulations.

Configure USE_BDOS in z80_sys.h for the BDOS emulator mentioned above
(required unless program is stand-alone - but without I/O that's limited).

simulator command options:

z80-sim [-t] [[-p program [-l load-addr] [-e entry]]
z80-sim [-t] [[-C ccp [-L load-addr] [-E entry]]

Option -t will enable trace, with the expected volumes of output.

Form 1 will execute "program" (anywhere in the native filesystem),
loading it into "load-addr" (default 0x0100), and jumping to entry
point "entry" (defalt load-addr).

Form 2 will run in "CP/M" mode using the CCP.SYS named by "ccp".
Since CCP images must run in high memory, you must specify where
the named image was relocated. CCP entry point is the load address.

There is also a crude interactive mode, entered initially with a -i
option but may also be entered with ^C (your interrupt character).
There is "help" and control of trace, plus dumping registers.
More to come.

The BDOS emulator currently hard-codes it's filesystem in

	./cpm_disks/A:/
	            B:/
	            C:/
	            etc..

files in non-zero user codes are prefixed with "<user>:". This is not
working 100% yet. Only "vanilla" CP/M programs can be run from the CCP,
as there is no BIOS or hardware, currently.

...still a work in progress...

EXAMPLE:

unpack the mms-cpm.tgz files into a directory:

	mkdir -p ./cpm_disks
	cd ./cpm_disks
	tar -xzvf ..../mms-cpm.tgz
	mv mms-cpm A:
	cd -


Then (after unpacking and building it) run the simulator:

	./.../z80-sim -C ./cpm_disks/A:/31:ccp.sys -L 0xd300

NOTE: the "0xd300" might not be the right value depending on what image is used.
TODO: use a relocatable ccp.sys. Perhaps reference out of MOVCPM.COM

You should get a CP/M prompt:

A0>

...and away you go (barring any bugs)...

I'm still working out all the bugs. PIP does seem to mostly work.
I have had success with DDT.  SUBMIT works but ED strips CR characters
(which breaks SUBMIT).  And, of course, none of the MMS utils are
tested - as most use direct access to hardware or the BIOS, or use
H19 ESC sequences.  I've also been able to use z80asm to write small
programs and run them. Of course, debug options are a bit limited.

You can also run programs directly in the simulator (no CCP), still
with BDOS support.

Some sample output:

A0>dir

BASECPM.COM    DDT.COM        BASIC.COM      MAC.COM        MODE.COM       
B5316.HEX      SYSGEN.ASM     SYSGEN.COM     SYSGEN.HEX     MOVCPM.COM     
ED.COM         SETUP.COM      JUNK.SUB       PROGRAM1.COM   FORMAT.COM     
Z80.LIB        LOAD.COM       INTCON.ASM     INTCON.HEX     STAT.COM       
DRIVES.COM     ASM.COM        M316.HEX       SUBMIT.COM     PIP.COM        
CCP.SYS        JUNK2.SUB      LINK.COM       
A0>stat *.*


 Recs  Bytes  Ext Acc
   64    16k    1 R/W A:ASM.COM
    7    16k    1 R/W A:B5316.HEX
   79    16k    1 R/W A:BASECPM.COM
  144    32k    1 R/W A:BASIC.COM
   16    16k    1 R/W A:CCP.SYS
   38    16k    1 R/W A:DDT.COM
   20    16k    1 R/W A:DRIVES.COM
   52    16k    1 R/W A:ED.COM
   69    16k    1 R/W A:FORMAT.COM
   42    16k    1 R/W A:INTCON.ASM
   14    16k    1 R/W A:INTCON.HEX
    1    16k    1 R/W A:JUNK.SUB
    1    16k    1 R/W A:JUNK2.SUB
   17    16k    1 R/W A:LINK.COM
   14    16k    1 R/W A:LOAD.COM
   58    16k    1 R/W A:M316.HEX
   92    16k    1 R/W A:MAC.COM
   30    16k    1 R/W A:MODE.COM
  100    16k    1 R/W A:MOVCPM.COM
   58    16k    1 R/W A:PIP.COM
    1    16k    1 R/W A:PROGRAM1.COM
   83    16k    1 R/W A:SETUP.COM
   41    16k    1 R/W A:STAT.COM
   17    16k    1 R/W A:SUBMIT.COM
  105    16k    1 R/W A:SYSGEN.ASM
   16    16k    1 R/W A:SYSGEN.COM
   45    16k    1 R/W A:SYSGEN.HEX
   46    16k    1 R/W A:Z80.LIB
Bytes Remaining On A: 2048k

A0>

NOTE, the disk "geometry" is completely fake, so while the number of
records above is accurate, the number of Bytes (allocated blocks)
and Ext is completely fictitious as is the Bytes Remaining for the
drive. Keep in mind, this is a Unix filesystem which doesn't map
directly to CP/M in details like allocation blocks and directory
entries.
