home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 433.lha / SpectrumEmulator_V0.0 / spectrum.doc < prev    next >
Text File  |  1990-11-04  |  9KB  |  239 lines

  1.  
  2.  
  3.             Sinclair ZX Spectrum Emulator V0.0    22 Oct 1990
  4.             ----------------------------------
  5.  
  6.  
  7. This program emulates a Sinclair ZX Spectrum 48-kbyte Z80-based computer on any
  8. Amiga computer.
  9.  
  10.  
  11.     +-------------------------------------------------------------------+
  12.     | IMPORTANT:  You need to already own a Spectrum to be able to use  |
  13.     | this program.  This is because I am not taking the risk of        |
  14.     | distributing the Spectrum ROM code.  I think that would probably  |
  15.     | be illegal.  Therefore this archive does not include the Spectrum |
  16.     | ROM code. --- You should supply it independently.            |
  17.     +-------------------------------------------------------------------+
  18.  
  19.  
  20. The files in this archive may be distributed anywhere provided they are
  21. unmodified and are not sold for profit.  Ownership remains with the author,
  22.  
  23.     Peter McGavin, 86 Totara Crescent, Lower Hutt, New Zealand.
  24.     e-mail: srwmpnm@wnv.dsir.govt.nz .
  25.  
  26.  
  27. I assume you have enough knowledge to manipulate binary files and to transfer
  28. data over a serial line without help.  If you don't know what I'm talking
  29. about, don't try this program.
  30.  
  31. The file called spectrum is an executable for 68000-based Amigas.
  32.  
  33. The file called spectrum2 is an executable 68010/20/30/40/50...-based Amigas.
  34.  
  35. Both files require the file "spectrum.rom" (not supplied) in the current
  36. directory, or they will not load.
  37.  
  38. The emulator uses the dreaded move-sr instruction after almost every Z80
  39. instruction emulated.  It ran significantly slower when I tried replacing the
  40. move-sr instruction with a call to exec.  Therefore I have supplied a second
  41. executable which uses move-ccr instead of move-sr for 68010/20/30/40-based
  42. Amigas.  I don't see any reason why one or the other shouldn't run on all Amiga
  43. models.
  44.  
  45. I have not yet had the opportunity to test spectrum2.  (It gurus on a my plain
  46. 68000 Amiga.)
  47.  
  48. I developed the code in assembler in my spare time in the last 3 weekends,
  49. using Z80 emulation code that I already had.
  50.  
  51. General Notes:
  52.  
  53. o   As already mentioned, a vital file is missing.  You must supply an image of
  54.     the Spectrum's ROM in the file "spectrum.rom".  The file must be exactly
  55.     16384 bytes long and must contain exactly the same byte sequence as memory
  56.     locations 0..16383 in the Spectrum.  The easiest way I know of to get this
  57.     to your Amiga is via the Sinclair Interface 1 serial port.  I'll leave it
  58.     up to you to figure out how to get the data across.  You could always type
  59.     it in :-)  There are several third-party books that list the code, e.g,
  60.  
  61.     "The Complete Spectrum ROM Disassembly" by Dr Ian Logan and Dr Frank
  62.     O'Hara, Melbourne House Software Ltd, ISBN 0 86161 116 0, or
  63.     ISBN 0 86759 117 X, 1983;
  64.  
  65.     "The Spectrum Machine Code Reference Guide" by Richard Ross-Langley,
  66.     Interface Publications, ISBN 0 907563 51 1, September 1983.
  67.  
  68.     In fact you can supply any 16384-byte file containing valid Z80 code and
  69.     called spectrum.rom.  The emulator will transfer Z80 control to location 0.
  70.     Screen and keyboard hardware is programmed the same as a real Spectrum.
  71.     (Once loaded, the first 16384 memory locations are readonly.)
  72.  
  73. o   Please don't ask me to e-mail spectrum.rom to you, because I won't.
  74.  
  75. o   If the emulator can't find spectrum.rom, then it will not load.
  76.  
  77. o   The following Spectrum features are implemented:
  78.  
  79.     screen output in the same resolution and colours as a real Spectrum
  80.         --- includes bright and reverse attributes (looks much better
  81.         than the old TV!)
  82.  
  83.     keyboard implemented at the Z80 "in" instruction level.  Note that
  84.         like a real Spectrum you have to hold the key down until it
  85.         registers.  Because the emulator is running slower, you might
  86.         have to hold keys down longer.  Make sure the Spectrum window
  87.                 is active when you start to type.  See Appendix 1 for key map.
  88.  
  89. o   The emulator runs in its own custom screen and window.  To quit, click the
  90.     close box (any time).
  91.  
  92. o   The emulator does not disable multitasking.
  93.  
  94. o   The emulator runs about 5 to 20 times slower than a real Spectrum on a
  95.     standard 68000-based A500.  Most things are about 8 times slower.  I'm
  96.     afraid the 68000 doesn't have a built-in Z80 emulation mode, and a Z80
  97.     is much harder to emulate than a 6502 as used in the Commodore 64 and BBC
  98.     microcomputers.  Writing to the Spectrum's display file (memory locations
  99.     16384..22527) is particularly slow, and writing to the attribute area
  100.     (locations 22528..23295) is even slower.  The Spectrum's video RAM is not
  101.     laid out in a way that easily maps on to the Amiga's.  A 28 MHz 68030
  102.     ought to keep up, but I haven't had the opportunity to test the emulator
  103.     on anything faster than my plain A500.  The Spectrum NEW command takes
  104.     16.4 seconds on my Amiga, compared with about 2 seconds on a real Spectrum.
  105.     I have run out of ideas on how to significantly speed up the code from what
  106.     it is now.
  107.  
  108. o   In version 0.0, the following Spectrum features are NOT implemented yet:
  109.  
  110.     flash attribute;
  111.  
  112.     sound;
  113.  
  114.     cassette tape;
  115.  
  116.     bank roms (e.g, Interface 1);
  117.  
  118.     joystick;
  119.  
  120.     the timer interrupt occurs after every 2000 machine instructions
  121.         instead of every 20 ms.
  122.  
  123. o   The following Z80 features are NOT properly implemented:
  124.  
  125.     the Z80 h and n processor flags are always 0;
  126.  
  127.     the Z80 daa instruction (decimal adjust a) --- daa works properly only
  128.         immediately after adc or sbc;
  129.  
  130.     the Z80 ini, outi, ind, outd, inir, otir, indr and otdr instructions;
  131.  
  132.     interrupts are always mode 1;
  133.  
  134.     there is at least one bug I haven't been able to track down yet.
  135.  
  136. o   If you have arp.library installed in the libs: directory, you can press F2
  137.     to save the current state of the emulator in a file.  (This uses the arp
  138.     file name requestor.)  Press F1 to load a saved file back again.  The
  139.     entire state of the system is saved, including all 48 kbytes of Spectrum
  140.     RAM and the state of the Z80 processor.  Load and save work in less than 1
  141.     second on a hard drive.
  142.  
  143. o   The format of a snapshot file (loaded with F1 and saved with F2) is listed
  144.     in Appendix 2.  If you have a Mirage Microdriver or equivalent you can
  145.     transfer any Spectrum program to the Amiga.
  146.  
  147. o   If you don't have arp.library installed in the libs: directory, F1 and F2
  148.     do nothing.  (A fix to this is high on my priority list.)
  149.  
  150. o   Because it's running slower, maybe now you can get past that "impossible"
  151.     level in your favourite game.
  152.  
  153. o   Now you can print Spectrum graphics by transferring to your Amiga.
  154.  
  155. o   If you're cross-developing Spectrum software, now you can see which parts
  156.     need speeding up.
  157.  
  158. o   I've tested it with several Sinclair Basic programs and all ran perfectly.
  159.  
  160. o   I've tried several machine-code games and found only a few problems.
  161.  
  162.     Scrabble works brilliantly!  (Write a native Amiga version someone
  163.         please.  How did the programmer cram the English dictionary
  164.         and program into 48k? --- I easily ran 6 copies of the emulator
  165.         running Scrabble simultaneously on a 1 Mbyte Amiga 500.)
  166.  
  167.     Jetset Willy works fine until you come to a room with a rope hanging
  168.         from the ceiling.
  169.  
  170.     Atic Atac works until you try to go through a door.  If someone finds
  171.         the bug, please tell me.
  172.  
  173. o   I am not supplying the source of the emulator yet.
  174.  
  175. o   Please report bugs to srwmpnm@windy.dsir.govt.nz.  I'd much prefer bug
  176.     reports like "the `or' instruction doesn't zero the carry flag" to
  177.     "Dan Dare doesn't work".
  178.  
  179.  
  180. Appendix 1:  The keyboard:
  181.  
  182. The Spectrum has a weird way of mapping functions to keys that doesn't
  183. translate nicely to the Amiga.  To get a "[" on a real Spectrum, for example,
  184. you press CAPS-SHIFT and SYMBOL-SHIFT together followed by SYMBOL-SHIFT and F.
  185. In the emulator, you do the same thing except CAPS-SHIFT is either of the
  186. SHIFT keys and SYMBOL-SHIFT is either of the ALT keys.  Pressing "[" on the
  187. Amiga keyboard won't work.
  188.  
  189. The following table lists the Amiga key(s) corresponding to each Spectrum key:
  190.  
  191.     Spectrum key        Amiga key
  192.  
  193.     0..9            either 0..9, arrow keys also map to 5,6,7,8
  194.     A..Z            A..Z
  195.     SPACE            SPACE
  196.     ENTER            RETURN or ENTER
  197.     CAPS-SHIFT        either SHIFT key
  198.     SYMBOL-SHIFT        either ALT key
  199.  
  200. All the other Amiga keys (except F1 and F2) do nothing.
  201.  
  202.  
  203. Appendix 2:  Snapshot file format (as used by F1 and F2 keys):
  204.  
  205. This format is based on the format used by the Mirage Microdriver "Dump"
  206. command.  Snapshot files are always 49179 bytes long.  Note that in the table,
  207. the byte offset starts from 0, not 1.
  208.  
  209.     Byte offset into file        Value
  210.  
  211.     0                i  register
  212.     1                l' register
  213.     2                h' register
  214.     3                e' register
  215.     4                d' register
  216.     5                c' register
  217.     6                b' register
  218.     7                f' register
  219.     8                a' register
  220.     9                l  register
  221.     10                h  register
  222.     11                e  register
  223.     12                d  register
  224.     13                c  register
  225.     14                b  register
  226.     15                iy low register
  227.     16                iy high register
  228.     17                ix low register
  229.     18                ix high register
  230.     19                bit 2 is set if interrupts are enabled
  231.     20                r register
  232.     21                flags register
  233.     22                a register
  234.     23                sp low register
  235.     24                sp high register
  236.     25                interrupt mode (0, 1 or 2)
  237.     26                filler (not used)
  238.     27..49178            48 kbytes RAM dump
  239.