home *** CD-ROM | disk | FTP | other *** search
-
-
- Sinclair ZX Spectrum Emulator V0.0 22 Oct 1990
- ----------------------------------
-
-
- This program emulates a Sinclair ZX Spectrum 48-kbyte Z80-based computer on any
- Amiga computer.
-
-
- +-------------------------------------------------------------------+
- | IMPORTANT: You need to already own a Spectrum to be able to use |
- | this program. This is because I am not taking the risk of |
- | distributing the Spectrum ROM code. I think that would probably |
- | be illegal. Therefore this archive does not include the Spectrum |
- | ROM code. --- You should supply it independently. |
- +-------------------------------------------------------------------+
-
-
- The files in this archive may be distributed anywhere provided they are
- unmodified and are not sold for profit. Ownership remains with the author,
-
- Peter McGavin, 86 Totara Crescent, Lower Hutt, New Zealand.
- e-mail: srwmpnm@wnv.dsir.govt.nz .
-
-
- I assume you have enough knowledge to manipulate binary files and to transfer
- data over a serial line without help. If you don't know what I'm talking
- about, don't try this program.
-
- The file called spectrum is an executable for 68000-based Amigas.
-
- The file called spectrum2 is an executable 68010/20/30/40/50...-based Amigas.
-
- Both files require the file "spectrum.rom" (not supplied) in the current
- directory, or they will not load.
-
- The emulator uses the dreaded move-sr instruction after almost every Z80
- instruction emulated. It ran significantly slower when I tried replacing the
- move-sr instruction with a call to exec. Therefore I have supplied a second
- executable which uses move-ccr instead of move-sr for 68010/20/30/40-based
- Amigas. I don't see any reason why one or the other shouldn't run on all Amiga
- models.
-
- I have not yet had the opportunity to test spectrum2. (It gurus on a my plain
- 68000 Amiga.)
-
- I developed the code in assembler in my spare time in the last 3 weekends,
- using Z80 emulation code that I already had.
-
- General Notes:
-
- o As already mentioned, a vital file is missing. You must supply an image of
- the Spectrum's ROM in the file "spectrum.rom". The file must be exactly
- 16384 bytes long and must contain exactly the same byte sequence as memory
- locations 0..16383 in the Spectrum. The easiest way I know of to get this
- to your Amiga is via the Sinclair Interface 1 serial port. I'll leave it
- up to you to figure out how to get the data across. You could always type
- it in :-) There are several third-party books that list the code, e.g,
-
- "The Complete Spectrum ROM Disassembly" by Dr Ian Logan and Dr Frank
- O'Hara, Melbourne House Software Ltd, ISBN 0 86161 116 0, or
- ISBN 0 86759 117 X, 1983;
-
- "The Spectrum Machine Code Reference Guide" by Richard Ross-Langley,
- Interface Publications, ISBN 0 907563 51 1, September 1983.
-
- In fact you can supply any 16384-byte file containing valid Z80 code and
- called spectrum.rom. The emulator will transfer Z80 control to location 0.
- Screen and keyboard hardware is programmed the same as a real Spectrum.
- (Once loaded, the first 16384 memory locations are readonly.)
-
- o Please don't ask me to e-mail spectrum.rom to you, because I won't.
-
- o If the emulator can't find spectrum.rom, then it will not load.
-
- o The following Spectrum features are implemented:
-
- screen output in the same resolution and colours as a real Spectrum
- --- includes bright and reverse attributes (looks much better
- than the old TV!)
-
- keyboard implemented at the Z80 "in" instruction level. Note that
- like a real Spectrum you have to hold the key down until it
- registers. Because the emulator is running slower, you might
- have to hold keys down longer. Make sure the Spectrum window
- is active when you start to type. See Appendix 1 for key map.
-
- o The emulator runs in its own custom screen and window. To quit, click the
- close box (any time).
-
- o The emulator does not disable multitasking.
-
- o The emulator runs about 5 to 20 times slower than a real Spectrum on a
- standard 68000-based A500. Most things are about 8 times slower. I'm
- afraid the 68000 doesn't have a built-in Z80 emulation mode, and a Z80
- is much harder to emulate than a 6502 as used in the Commodore 64 and BBC
- microcomputers. Writing to the Spectrum's display file (memory locations
- 16384..22527) is particularly slow, and writing to the attribute area
- (locations 22528..23295) is even slower. The Spectrum's video RAM is not
- laid out in a way that easily maps on to the Amiga's. A 28 MHz 68030
- ought to keep up, but I haven't had the opportunity to test the emulator
- on anything faster than my plain A500. The Spectrum NEW command takes
- 16.4 seconds on my Amiga, compared with about 2 seconds on a real Spectrum.
- I have run out of ideas on how to significantly speed up the code from what
- it is now.
-
- o In version 0.0, the following Spectrum features are NOT implemented yet:
-
- flash attribute;
-
- sound;
-
- cassette tape;
-
- bank roms (e.g, Interface 1);
-
- joystick;
-
- the timer interrupt occurs after every 2000 machine instructions
- instead of every 20 ms.
-
- o The following Z80 features are NOT properly implemented:
-
- the Z80 h and n processor flags are always 0;
-
- the Z80 daa instruction (decimal adjust a) --- daa works properly only
- immediately after adc or sbc;
-
- the Z80 ini, outi, ind, outd, inir, otir, indr and otdr instructions;
-
- interrupts are always mode 1;
-
- there is at least one bug I haven't been able to track down yet.
-
- o If you have arp.library installed in the libs: directory, you can press F2
- to save the current state of the emulator in a file. (This uses the arp
- file name requestor.) Press F1 to load a saved file back again. The
- entire state of the system is saved, including all 48 kbytes of Spectrum
- RAM and the state of the Z80 processor. Load and save work in less than 1
- second on a hard drive.
-
- o The format of a snapshot file (loaded with F1 and saved with F2) is listed
- in Appendix 2. If you have a Mirage Microdriver or equivalent you can
- transfer any Spectrum program to the Amiga.
-
- o If you don't have arp.library installed in the libs: directory, F1 and F2
- do nothing. (A fix to this is high on my priority list.)
-
- o Because it's running slower, maybe now you can get past that "impossible"
- level in your favourite game.
-
- o Now you can print Spectrum graphics by transferring to your Amiga.
-
- o If you're cross-developing Spectrum software, now you can see which parts
- need speeding up.
-
- o I've tested it with several Sinclair Basic programs and all ran perfectly.
-
- o I've tried several machine-code games and found only a few problems.
-
- Scrabble works brilliantly! (Write a native Amiga version someone
- please. How did the programmer cram the English dictionary
- and program into 48k? --- I easily ran 6 copies of the emulator
- running Scrabble simultaneously on a 1 Mbyte Amiga 500.)
-
- Jetset Willy works fine until you come to a room with a rope hanging
- from the ceiling.
-
- Atic Atac works until you try to go through a door. If someone finds
- the bug, please tell me.
-
- o I am not supplying the source of the emulator yet.
-
- o Please report bugs to srwmpnm@windy.dsir.govt.nz. I'd much prefer bug
- reports like "the `or' instruction doesn't zero the carry flag" to
- "Dan Dare doesn't work".
-
-
- Appendix 1: The keyboard:
-
- The Spectrum has a weird way of mapping functions to keys that doesn't
- translate nicely to the Amiga. To get a "[" on a real Spectrum, for example,
- you press CAPS-SHIFT and SYMBOL-SHIFT together followed by SYMBOL-SHIFT and F.
- In the emulator, you do the same thing except CAPS-SHIFT is either of the
- SHIFT keys and SYMBOL-SHIFT is either of the ALT keys. Pressing "[" on the
- Amiga keyboard won't work.
-
- The following table lists the Amiga key(s) corresponding to each Spectrum key:
-
- Spectrum key Amiga key
-
- 0..9 either 0..9, arrow keys also map to 5,6,7,8
- A..Z A..Z
- SPACE SPACE
- ENTER RETURN or ENTER
- CAPS-SHIFT either SHIFT key
- SYMBOL-SHIFT either ALT key
-
- All the other Amiga keys (except F1 and F2) do nothing.
-
-
- Appendix 2: Snapshot file format (as used by F1 and F2 keys):
-
- This format is based on the format used by the Mirage Microdriver "Dump"
- command. Snapshot files are always 49179 bytes long. Note that in the table,
- the byte offset starts from 0, not 1.
-
- Byte offset into file Value
-
- 0 i register
- 1 l' register
- 2 h' register
- 3 e' register
- 4 d' register
- 5 c' register
- 6 b' register
- 7 f' register
- 8 a' register
- 9 l register
- 10 h register
- 11 e register
- 12 d register
- 13 c register
- 14 b register
- 15 iy low register
- 16 iy high register
- 17 ix low register
- 18 ix high register
- 19 bit 2 is set if interrupts are enabled
- 20 r register
- 21 flags register
- 22 a register
- 23 sp low register
- 24 sp high register
- 25 interrupt mode (0, 1 or 2)
- 26 filler (not used)
- 27..49178 48 kbytes RAM dump
-