+------------------------------------+
| SPEC v1.4w                         |
| by Robin Edwards                   |
| (robin@methedrine.demon.co.uk)     |
+------------------------------------+

------------
Introduction
------------
SPEC is a basic, but capable, ZX Spectrum 48k emulator.

I wrote this program mainly to learn about the principles of writing an
emulator. My intention was to write something that would play Jetpac, and stop
there. Then I kept on going because I didn't like to leave it unfinished.

SPEC requires a fast 486 or Pentium for decent emulation. I kept the z80 CPU
module portable so I could use it again (maybe for a gameboy emulator) and so
it would compile on other machines. The downside of this is, it's a bit slow.

----------
Disclaimer
----------
As far as I am aware, the sample games that I have provided with the emulator
are now public domain. If this is not the case would those who now hold the
copyright let me know and I will remove them.

-----
Files
-----
o SPEC.EXE        the emulator
o SPEC.TXT        this document
o SPECTRUM.ROM    (no longer required but see below)

Usage SPEC <filename.sna>
If a filename is not supplied, the spectrum will boot to ROM.

The ZX Spectrum ROM is now stored as part of the executable and no separate
file is needed. If however you wish to use your own ROM, just place a file
called SPECTRUM.ROM in the same directory as SPEC.EXE and it will be loaded
instead.

In Windows, snapshot files can either be dragged onto SPEC to run them, or if
you double click the snapshot file, SPEC.EXE can be specified as the program
to open them.

----
Keys
----
The 40 spectrum keys are the same as their PC equivalents, except CAPS shift
and SYMBOL shift which are emulated as follows-
o LEFT SHIFT  = caps shift
o LEFT CTRL   = symbol shift

Extra keys are-
o BACKSPACE   = caps shift + zero (delete on the spectrum)
o ESC         = quit emulator
o LEFT ALT    = 0
o CURSOR KEYS = 5678

--------
Joystick
--------
The PC joystick (if present) will emulate a kempston joystick on the spectrum.
The PC cursor keys & left ALT emulate a cursor joystick.

---------------
Emulation speed
---------------
On a Pentium, the speed should be exactly that of a Spectrum. A tick mark will
appear in the corner of the screen if the Spectrum is running at the correct
speed. If it doesn't, or it flickers, then I'm afraid your PC is too slow.

----------------
Working software
----------------
o Sinclair ROM
o Jetpac, Knightlore, Underwurlde, Atic Atac, Nightshade, Alien 8
o Manic Miner, Jet Set Willy
o TLL, Cyclone, Chuckie Egg, Batman, Commando

---------
Technical (for those interested)
---------
SPEC was compiled using Borland C++ 5 (dos).

SPEC tries to sync the Z80 cpu cycles with the PC 1.1Mhz timer, since this
was the only way I could get the sound to work on fast machines. Every 69888
cycles an interrupt is signalled and the screen,joystick & keyboard are updated.

All documented and undocumented instructions are implemented (as far as I know)
The undocumented behaviour of the S & P flags with BIT is implemented.
The R register works properly. Interrupts work properly.
The screen is drawn in one go every 50hz, so border effects will not work.

All writes to memory are allowed, including the ROM. Quite a bug.
I only realised this after it was too much work to change.

The emulator does not currently emulate the undocumented behaviour of bits 3
and 5 of the flag register.

-----
TO DO
-----
o Direct Draw Version
o Save snapshots
o Compile a better list of what doesn't work and hopefully fix

--------------------
Credits & References
--------------------
o Spectrum Machine Language for the Absolute Beginner (1982) Melbourne House
o Z80 Programming for Logic Design (1978) Osborne
o Programming The Z80 3rd.Ed.(1981) Syrex.
o Programming in Z80 Assembly Language (1984) Macmillan
o comp.sys.sinclair FAQ v3.0
o various posts to comp.sys.sinclair
o Marat Fayzullin's VGB source, which showed me (one way) how to write an
  emulator in C.
o The PGPE (PC games programmer's encyclopedia) for information on keyboard
  interrupts, interrupts, joystick, sound, etc.

----------------
Revision History
----------------
v1.0  First version released. Timing not 100% perfect.
v1.0a More keys added (Cursor joystick emulated with cursor keys).
v1.1  Timings sorted. Speeded up on slow machines. Tick added.
v1.2  Major bug sorted. IM2 was completed wrong. Lots more games now work.
v1.3  Now syncs to PC clock, so sound better on fast machines.
v1.4  Bug that caused it to hang after 1 hour removed.
v1.4e ROM now stored as part of the spec.exe file. Screen redraw improved.
v1.4w Emulation improved.
-END-

