home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 573b.lha / SpectrumEmulator_v1.0 / Spectrum.doc.pp / Spectrum.doc
Text File  |  1991-11-10  |  31KB  |  846 lines

  1.  
  2.  
  3.             Sinclair ZX Spectrum Emulator V1.0     9 Nov 1991
  4.             -----------------------------------
  5.  
  6.  
  7. This program emulates a Sinclair ZX Spectrum 48-kbyte z80-based computer on any
  8. Amiga computer.
  9.  
  10.     +-------------------------------------------------------------------+
  11.     | IMPORTANT:  You need to already own a Spectrum to be able to use  |
  12.     | this program.  This is because I am not taking the risk of        |
  13.     | distributing the Spectrum ROM code.  I think that would probably  |
  14.     | be illegal.  Therefore this archive does not include the Spectrum |
  15.     | ROM code. --- You should supply it independently.            |
  16.     +-------------------------------------------------------------------+
  17.  
  18. The files in this archive may be distributed anywhere provided they are
  19. unmodified and are not sold for profit.  Ownership remains with the author,
  20.  
  21.     Peter McGavin, 86 Totara Crescent, Lower Hutt, New Zealand.
  22.     e-mail: srwmpnm@wnv.dsir.govt.nz .
  23.  
  24.  
  25. I assume you have enough knowledge to manipulate binary files and to transfer
  26. data over a serial line without help.  If you don't know what I'm talking
  27. about, don't try this program.
  28.  
  29.  
  30. Spectrum-sr is an executable for 68000-based Amigas.
  31.  
  32.  
  33. Spectrum-ccr is for 68010/20/30/40/50...-based Amigas.
  34.  
  35.  
  36. Both the programs require the file "spectrum.rom" (not supplied) in the current
  37. directory, or they will not load.
  38.  
  39. The emulator uses the dreaded move-sr instruction after almost every z80
  40. instruction emulated.  It ran 30-40% slower when I tried replacing the
  41. move-sr instruction with a call to GetCC()!  This is quite exceptional ---
  42. with most programs you wouldn't notice the difference.  Therefore I have
  43. supplied a second executable which uses move-ccr instead of move-sr for
  44. 68010/20/30/40-based Amigas.
  45.  
  46. The program has been tested on a 3.5 Mbyte Amiga 500 and on a 2 Mbyte Amiga
  47. 3000 (but it uses only about 300 kbytes).
  48.  
  49. I developed the code, entirely in assembler, in my spare time using z80
  50. emulation code based (originally) on Ulf Nordquist's CP/M emulator (Fred Fish
  51. disk 165).  I have fixed several bugs in the z80 emulation code, and made it
  52. more than twice as fast, but there are still some (very hard to find) bugs.
  53.  
  54.  
  55.  
  56. Features:
  57. ---------
  58.  
  59. The following Spectrum features are implemented:
  60.  
  61.     screen output in the same resolution and colours as a real Spectrum
  62.         --- includes bright, reverse and flash attributes (looks much
  63.         better than the old TV!)
  64.  
  65.     keyboard implemented at the z80 "in" instruction level.  Note that
  66.         like a real Spectrum you have to hold the key down until it
  67.         registers.  Because the emulator is running slower, you might
  68.         have to hold keys down longer.  More often, you might have to
  69.         hold your fingers off the keyboard for longer.  Make sure the
  70.         Spectrum window is active when you start to type.  See
  71.         Appendix 1 for key map.
  72.  
  73.     kempston joystick implemented at the Z80 "in" instruction level.  This
  74.         uses the rear Amiga gameport.  Note that the joystick is
  75.         active only when the Spectrum window is active.  If another
  76.         Amiga program is currently using the joystick, you will get a
  77.         retry/no-joystick requester.
  78.  
  79.     sound implemented by trapping calls to the "beeper" routine at $03b5
  80.         in the Spectrum rom.  Sound works with all Basic programs and
  81.         some machine code programs, but it won't work with machine code
  82.         programs that bang on the hardware to make sounds.
  83.  
  84.     cassette tape loading, if you have a sound sampler capable of at least
  85.         20 kHz sampling rate attached to your parallel port.  This is
  86.         implemented by trapping calls to the "ld-bytes" routine at
  87.         $0556 in the Spectrum rom.  Note that copy-protected games
  88.         with custom loaders cannot always be loaded this way.
  89.  
  90. It is possible to save to and load from amiga disk files.
  91.  
  92.  
  93.  
  94. That Missing File:
  95. ------------------
  96.  
  97. As already mentioned, a vital file is missing.  You must supply an image of
  98. the Spectrum's ROM in the file "spectrum.rom".  The file must be exactly
  99. 16384 bytes long and must contain exactly the same byte sequence as memory
  100. locations 0..16383 in the Spectrum.  There are several ways to get this
  101. across to your Amiga, including:
  102.  
  103.     Use the Sinclair Interface 1 serial port connected to the Amiga's
  104.     serial port.  The data can be transferred using a small BASIC program
  105.     on the Spectrum, then captured on the Amiga with either another small
  106.     program or a terminal emulation program.
  107.  
  108.     Use a Spectrum disk drive system that writes IBM-format sectors, then
  109.     read the diskettes on your Amiga using MSH (Fred Fish disk 382) or
  110.     CrossDOS (commercial) and a sector editor like DiskX (Fred Fish disk
  111.     158).  An MGT PLUS D disk drive will work for this.
  112.  
  113.     Find a program that will read Spectrum cassette tapes through an Amiga
  114.     sound sampler, writing the data to a disk file as it goes.  Kristian
  115.     Nielson (e-mail bombadil@freja.diku.dk) has written a program that will
  116.     do this.  Try looking for specload.lzh at your local PD site.
  117.  
  118. I'll leave it up to you to figure out how to get the data across.  You
  119. could always type it in :-)  There are several third-party books that list
  120. the code, e.g,
  121.  
  122.     "The Complete Spectrum ROM Disassembly" by Dr Ian Logan and Dr Frank
  123.     O'Hara, Melbourne House Software Ltd, ISBN 0 86161 116 0, or
  124.     ISBN 0 86759 117 X, 1983;
  125.  
  126.     "The Spectrum Machine Code Reference Guide" by Richard Ross-Langley,
  127.     Interface Publications, ISBN 0 907563 51 1, September 1983.
  128.  
  129. In fact you can supply any 16384-byte file containing valid z80 code and
  130. called spectrum.rom.  The emulator will transfer z80 control to location 0.
  131. Screen and keyboard hardware is programmed the same as a real Spectrum.
  132. (Once loaded, the first 16384 memory locations are readonly.)
  133.  
  134. Please don't ask me to e-mail spectrum.rom to you, because I won't.
  135.  
  136.  
  137.  
  138. Operation:
  139. ----------
  140.  
  141. You can start the emulator from either the Workbench or SHELL (or CLI).  There
  142. are no command-line parameters.
  143.  
  144. If you use the SHELL (or CLI), spectrum.rom must be in the current directory.
  145. From the workbench, spectrum.rom should be in the same directory as the
  146. program.
  147.  
  148. If the emulator can't find spectrum.rom, then it will display a requester
  149. saying so, and it will not run.
  150.  
  151. To use the ARP file requester, you must have arp.library installed in your LIBS:
  152. directory.
  153.  
  154. The emulator runs in its own custom screen and window.
  155.  
  156. The emulator does not disable multitasking, and it does not interfere with other
  157. tasks (except when loading from a sound sampler).  You can drag the screen down
  158. or click it to the back with the mouse, in the usual way.  (Grab the screen bar
  159. to the left of the window to pull it down.)
  160.  
  161. The emulator lowers its own priority to -5, otherwise it would significantly
  162. slow down other tasks.  Raising the priority back to 0 (e.g, with xoper or
  163. artm) does not significantly speed up the emulator on a standard system.
  164. Raising it higher will prevent most other tasks from running at all.
  165.  
  166. To exit the emulator, do any of the following:
  167.  
  168.     o  click the close box with the left mouse button;
  169.  
  170.     o  select "Quit..." from the Project menu, or
  171.  
  172.     o  press the ESC key.
  173.  
  174.  
  175.  
  176. Menus:
  177. ------
  178.  
  179. Project menu
  180.  
  181.     Load snapshot...  F1
  182.  
  183.     Loads a disk file that has been created with "Save snapshot",
  184.     restoring the state of the system to what it was when the snapshot
  185.     was made.  Any currently loaded Spectrum program is lost.  Uses
  186.     the ARP file requester.
  187.  
  188.     You can use "Load snapshot..." even if the Spectrum has "crashed",
  189.     or if you are running a Spectrum program which does not have a
  190.     "quit" option.
  191.  
  192.     The format of a snapshot file is listed in Appendix 2.
  193.  
  194.     Save snapshot...  F2
  195.  
  196.     Saves the current state of the emulator to a disk file.  The entire
  197.     state of the system is saved, including all 48 kbytes of Spectrum ram
  198.     and the state of the z80 processor.  Uses the ARP file requester.
  199.  
  200.     Help...         HELP
  201.  
  202.     Displays the "Spectrum.help" file, which is a diagram of a real
  203.     Spectrum keyboard.  You need about 70 kb of CHIP ram free for this.
  204.  
  205.     Quit...          ESC
  206.  
  207.     Quits the emulator.  (You get a chance to change your mind.)
  208.  
  209.  
  210. Settings menu
  211.  
  212.     LOAD/MERGE/VERIFY...
  213.  
  214.     Selects what happens when the emulator executes a Spectrum BASIC
  215.     LOAD, MERGE or VERIFY command.
  216.  
  217.     Note that this has nothing at all to do with "Load snapshot", which
  218.     always loads from disk.  What it does do, is to change the behaviour
  219.     of the standard Spectrum BASIC tape loading commands, which are
  220.     normally used to load, merge and verify BASIC programs, array data
  221.     and binary code, from cassette tape.
  222.  
  223.     In fact, this selects what happens when any program (including any
  224.     machine code program) calls the cassette tape loading routine in the
  225.     Spectrum rom.
  226.  
  227.     You have a choice of:
  228.  
  229.         Disk files
  230.  
  231.         Select a disk file using the ARP file requester.  The data
  232.         in the file is interpreted as if it is being read from cassette
  233.         tape.
  234.  
  235.         The first byte in the file is the "header" byte, then the raw
  236.         data, then the checksum byte.
  237.  
  238.         The Spectrum normally reads 2 blocks of data from cassette
  239.         tape, a "header" file followed by the "data" file.  These
  240.         should be stored in 2 separate disk files.  The emulator will
  241.         request both files.  I implemented it this way to allow support
  242.         for "headerless" files which are used by many Spectrum machine
  243.         code programs.
  244.  
  245.         Note that the Spectrum still thinks it is reading from cassette
  246.         tape, so you might see messages like "Start tape now", even
  247.         though it is reading from disk.
  248.  
  249.         If the file you select is not in the correct format, or if the
  250.         checksum is wrong, the Spectrum will usually just request the
  251.         same file again, without any messages, as if it read garbage
  252.         noise from cassette tape.
  253.  
  254.         ProSound
  255.  
  256.         Read data from a ProSound sound sampler connected to the
  257.         parallel port.
  258.  
  259.         Other sampler
  260.  
  261.         Read data from any other kind of sound sampler connected to the
  262.         parallel port.
  263.  
  264.         The sampler must be capable of at least 20 kHz sampling rate
  265.         and it must be connected to the parallel port (not the game
  266.         port).
  267.  
  268.         You should be able to feed standard Spectrum cassette tapes in.
  269.  
  270.         Some copy-protected programs have custom loaders that will not
  271.         work in the emulator.
  272.  
  273.         It is possible to connect the Spectrum EAR output to the sound
  274.         sampler to transfer data directly from your Spectrum.  (Use a
  275.         SAVE command at one end, and a LOAD at the other.)
  276.  
  277.         Important: Interrupts on the amiga are disabled while you are
  278.         loading from a sound sampler.  This will interfere with other
  279.         tasks.  For example, a file transfer running in the background
  280.         will probably fail.
  281.  
  282.         It seems as if the whole amiga has frozen while interrupts are
  283.         disabled.  To restore control, click the left mouse button.
  284.  
  285.     SAVE...
  286.  
  287.     Selects what happens when the emulator executes a Spectrum BASIC
  288.     SAVE command.
  289.  
  290.     Note that this has nothing at all to do with "Save snapshot", which
  291.     always saves to disk.  What it does do, is to change the behaviour
  292.     of the standard Spectrum BASIC SAVE commands, which are normally used
  293.     to save BASIC programs, array data and binary code, to cassette tape.
  294.  
  295.     In fact, this selects what happens when any program (including any
  296.     machine code program) calls the cassette tape saving routine in the
  297.     Spectrum rom.
  298.  
  299.     You have a choice of:
  300.  
  301.         Disk files
  302.  
  303.         Select a disk file using the ARP file requester.  The data
  304.         that would normally be written to cassette tape is written
  305.         to the selected file instead.
  306.  
  307.         The first byte in the file is the "header" byte, then the raw
  308.         data, then a checksum byte.
  309.  
  310.         The Spectrum normally writes 2 blocks of data to cassette
  311.         tape, a "header" file followed by the "data" file.  These
  312.         should be stored in 2 separate disk files.  The emulator will
  313.         request both files.  I implemented it this way to allow support
  314.         for "headerless" files which are used by many Spectrum machine
  315.         code programs.
  316.  
  317.         Note that the Spectrum still thinks it is writing to cassette
  318.         tape, so you might see messages like "Start tape, then press
  319.         any key".
  320.  
  321.         Audio
  322.  
  323.         Not implemented in V1.0.
  324.  
  325.  
  326.  
  327. More on Reading Cassette Tapes:
  328. -------------------------------
  329.  
  330. To load a cassette tape through your sound sampler, enter LOAD "" (that is,
  331. J followed by ALT/P twice, then RETURN).  Now start the cassette tape playing
  332. into your sound sampler.  If it is working, the screen should flash colours,
  333. very much like your Spectrum, and the mouse pointer will be frozen.
  334.  
  335. If you got a file requester instead, then you forgot to select your sound
  336. sampler type for "LOAD/MERGE/VERIFY..." in the "Settings" menu.
  337.  
  338. The MERGE and VERIFY commands should also work, as should things like
  339. LOAD "" CODE, etc.
  340.  
  341. If the screen is mostly yellow and blue, the load is working.  If it is
  342. flashing mostly red, it is either synchronising or not working.  If it is
  343. not flashing at all, it is not working at all.  If it doesn't work, try
  344. adjusting the volume and tone controls on the tape recorder.  If you have
  345. trouble, try adjusting the controls while sampling with software that
  346. came with your sampler.  Ideally, the input should be a square wave which
  347. fills the graphic display.  If it still doesn't work, tell me about it.
  348.  
  349. You should be able to save directly from your Spectrum to the Amiga with a
  350. direct connection --- i.e, no cassette tape or recorder at all.  Use a SAVE
  351. command on the Spectrum and a corresponding LOAD command in the emulator.
  352.  
  353. Loading works by intercepting calls to the LD-BYTES routine at location
  354. $0556 in the Spectrum ROM.  If a Spectrum program has its own loading
  355. routine, then it won't work.  Some copy-protected games and fast-loaders
  356. are like that, and they will not work.  On the other hand, some Spectrum
  357. programs call LD-BYTES to load headerless tape files.  Those programs
  358. should work fine.
  359.  
  360. The following sound samplers should be suitable, but I have not had the
  361. opportunity to test any except the first:
  362.  
  363.     o ProSound
  364.  
  365.     o Perfect Sound
  366.  
  367.     o Datel DSS
  368.  
  369.     o Future Sound
  370.  
  371. Note that the tape-loading routine disables interrupts for the whole time
  372. it takes to load a tape.  That greatly exceeds Commodore's recommended
  373. limit of 250 microseconds.  While interrupts are disabled, the mouse
  374. pointer freezes, the keyboard is locked out, all other tasks stop, and any
  375. data arriving at the serial port is lost.  If I knew another way to make
  376. it work, I'd do it that way.  As far as I am aware, all sound sampling
  377. software on the Amiga disables interrupts for excessive periods.  The
  378. Spectrum loader has to interpret the incoming data in real time, which is
  379. quite a lot more than just saving it to a buffer in memory.
  380.  
  381. To break out of the load routine without actually loading anything, press
  382. the left mouse button.  The Spectrum BREAK key (SHIFT/SPACE) won't work in
  383. this situation.
  384.  
  385. If the keyboard doesn't work after you break out with the left mouse
  386. button, it's probably because you accidently deselected the window (by
  387. clicking outside it).  Just click anywhere inside the Spectrum window
  388. and the keyboard will work again.
  389.  
  390. The load routine is based on code kindly provided by Kristian Nielson.
  391. It has been tested on both standard and accelerated amigas.
  392.  
  393.  
  394. General Notes:
  395. --------------
  396.  
  397. o   The emulator runs about 3 to 10 times slower than a real Spectrum, on a
  398.     standard 68000-based A500.  If you are the lucky owner of an Amiga 3000,
  399.     the emulator runs at about the same speed as a real Spectrum, but make
  400.     certain it's running out of FAST ram.  If you run it out of CHIP ram,
  401.     then it's more than twice as slow.  I'm afraid the 68000 doesn't have a
  402.     built-in z80 emulation mode, and a 3.5 MHz z80 is much harder to emulate
  403.     than a 6502 as used in the Commodore 64 and BBC microcomputers.  The
  404.     Spectrum NEW command takes 9.8 seconds on an A500, compared with about 2.0
  405.     seconds on a real Spectrum, 2.1 seconds on an A3000 (in FAST static-
  406.     column ram), and 1.9 seconds on a 33MHz Mega-Midget-Racer with 32-bit ram.
  407.  
  408.  
  409. o   This version of Spectrum uses the blitter to refresh the screen in
  410.     parallel with the emulator.  That is, it uses multi-processing.  Thus,
  411.     the overhead of a z80 instruction writing to the Spectrum's display file
  412.     is minimised.  Before you A3000 owners complain that the 68030 is faster
  413.     than the blitter for blitting, remember that while the blitter is
  414.     refreshing the screen, the 68030 is busy emulating the z80.  The program
  415.     uses QBlit() for concurrency, not OwnBlitter() which would block the z80
  416.     emulator.
  417.  
  418.  
  419. o   I've just about run out of ideas on how to significantly speed up the
  420.     code from what it is now.  One thought is to code some common ROM routines
  421.     in pure 68000.  Obvious candidates are the text output, scrolling, and
  422.     maskable interrupt routines.  Of course this would only speed up programs
  423.     that call the ROM, which excludes most games.  Also, It would probably be
  424.     illegal.  The major speed bottleneck used to be the z80 instruction
  425.     decode.  I've pretty well eliminated that by going to threaded code.  The
  426.     display routines are about as fast as I can get them.  Taking over the
  427.     machine and doing everything at the hardware level would probably give
  428.     only a slight speed improvement, and the program would become much less
  429.     friendly and less portable.
  430.  
  431.  
  432. o   In version 1.0, the following Spectrum features are NOT implemented yet:
  433.  
  434.     border colour (except during cassette tape loading);
  435.  
  436.     saving to cassette tape;
  437.  
  438.     bank roms (e.g, Interface 1);
  439.  
  440.  
  441. o   The following z80 features are NOT properly implemented:
  442.  
  443.     the z80 h processor flag;
  444.  
  445.     the z80 daa instruction (decimal adjust a) --- daa works properly only
  446.         immediately after add, sub, adc or sbc;
  447.  
  448.     the timer interrupt occurs after every 1500 branch, jump, call and
  449.         return z80 machine instructions, instead of every 20 ms.  On
  450.         accelerated amigas, interrupts will not occur any faster than
  451.         every 20 ms.
  452.  
  453.     updating of the flash attribute occurs every 24000 branch, jump, call
  454.         and return z80 instructions, instead of every 320 ms.  On
  455.         accelerated amigas, the flash speed will never be faster than
  456.         every 320 ms.
  457.  
  458.     interrupts and screen updates can occur only immediately after branch,
  459.         jump, call, return and halt z80 machine instructions.
  460.  
  461.     because the emulator is not real-time, the real interval between timer
  462.         interrupts and flash attribute updates depends on the nature
  463.         of the Spectrum program being run.
  464.  
  465.     there might still be rare problems executing certain long,
  466.     self-modifying z80 instructions located at exactly 32763..32766 in z80
  467.     memory, because of the 68000 addressing modes used to load instruction
  468.     operands;
  469.  
  470.     there is at least one other bug I haven't been able to track down yet.
  471.  
  472.  
  473. o   Because it's running slower, maybe now you can get past that "impossible"
  474.     level in your favourite game.
  475.  
  476.  
  477. o   Now you can print Spectrum graphics by transferring to your Amiga.
  478.  
  479.  
  480. o   If you're cross-developing Spectrum software, now you can see which parts
  481.     need speeding up.
  482.  
  483.  
  484. o   I've tested it with several Sinclair Basic programs and all ran perfectly.
  485.  
  486.  
  487. o   I've tried several machine-code programs and had mixed success.  Most
  488.     simple programs work.  It still has trouble with some flight simulators
  489.     and a few programs with sophisticated graphics routines.
  490.  
  491.     The following programs seem to work ok in the emulator:
  492.  
  493.         Zeus Assembler and Monitor
  494.         Scrabble
  495.         Jetset Willy            no sound
  496.         Atic Atac            no sound
  497.         Jetpac                no sound
  498.         Tron                full sound
  499.         The Train Game            no sound
  500.         Backgammon
  501.         PSSST                some sound
  502.         Horace and the Spiders
  503.         Sam Spade            full sound effects
  504.         Draughts
  505.         Sam Stoat            some sound
  506.         3D Deathchase            no sound
  507.         Technician Ted            no sound
  508.         Kosmic Kanga
  509.         Monty Mole
  510.         Talk Chess            no speech, sorry
  511.         Horace Goes Skiing        some sound
  512.         Hungry Horace            some sound
  513.         Star Raid            no sound
  514.         Cyclone                some sound
  515.         Wheelie                no sound
  516.         Full Throttle            no sound
  517.         Mugsy
  518.         Dynamite Dan            no sound
  519.         Dynamite Dan II            full sound effects
  520.         Heathrow            beeps
  521.         IS Chess 48
  522.         Matchpoint
  523.         Max Headroom            no joystick
  524.         Spy vs Spy
  525.         Kong
  526.         The Alchemist
  527.         Daley Decathlon
  528.         Automania
  529.         Penetrator
  530.         Gyron
  531.         Alien8
  532.         Cyberun
  533.         KnightLore
  534.         Batman
  535.  
  536.  
  537.     Tomahawk locks up when it tries to render scenery.
  538.  
  539.     Fighter Pilot works until you try to turn left or right, then it
  540.     displays the horizon wrong.
  541.  
  542.     St Bernard resets the Spectrum after a long, long pause.
  543.  
  544.     Athena renders scenery wrong.
  545.  
  546.     SabreWulf runs, except sometimes the rhino runs backwards (very
  547.     amusing).
  548.  
  549.     Basil the Detective displays only the left half the screen.
  550.  
  551.     (If you know why any of these programs don't work, please tell me.)
  552.  
  553.     Note: The Amiga doesn't crash.  If a Spectrum program crashes, you can
  554.     either:  Quit the emulator and continue working on the Amiga, or:
  555.     Press F1 and load another snapshot.
  556.  
  557.     Note: Some of the above have not been tested since Spectrum v0.7 or v0.8.
  558.  
  559.  
  560. o   One problem I have had with snapshotting games by transferring a snapshot
  561.     file from the real Spectrum to the amiga, is as follows:  If there is
  562.     non-standard hardware in your real Spectrum (like a non-standard joystick or
  563.     disk drive), and the program knows about the special hardware, then the
  564.     program might have already done a hardware test (before you made the
  565.     snapshot) that makes it believe the special hardware exists permanently.
  566.     Then, when run under the emulator, the program tries to access the
  567.     non-existent hardware and behaves erratically.
  568.  
  569.     What is wrong is that the program was started in one environment (the real
  570.     Spectrum with add-ons) and is now running in another (the plain Spectrum
  571.     emulator).  For example, if your program behaves as if the joystick button
  572.     is continuously pressed (when run in the emulator), maybe it is because
  573.     you made the original snapshot from a Spectrum which has non-standard
  574.     joystick hardware.  See if you can disconnect the joystick interface and
  575.     reload the original program from tape before you make a snapshot.
  576.  
  577.  
  578. o   I am not supplying the source of the emulator yet.
  579.  
  580.  
  581. o   Please report bugs to srwmpnm@windy.dsir.govt.nz.  I'd much prefer bug
  582.     reports like "the `or' instruction doesn't zero the carry flag" to
  583.     "Dan Dare doesn't work".
  584.  
  585.  
  586.  
  587. Appendix 1:  The keyboard:
  588.  
  589. The Spectrum has a weird way of mapping functions to keys that doesn't
  590. translate nicely to the Amiga.  To get a "[" on a real Spectrum, for example,
  591. you press CAPS-SHIFT and SYMBOL-SHIFT together followed by SYMBOL-SHIFT and F.
  592. In the emulator, you do the same thing except CAPS-SHIFT is either of the
  593. SHIFT keys and SYMBOL-SHIFT is either of the ALT keys.  Pressing "[" on the
  594. Amiga keyboard won't work.
  595.  
  596. The following table lists the Amiga key(s) corresponding to each Spectrum key:
  597.  
  598.     Spectrum key        Amiga key
  599.  
  600.     0..9            0..9 (main keyboard or keypad)
  601.     A..Z            A..Z
  602.     SPACE            SPACE
  603.     ENTER            RETURN or ENTER
  604.     CAPS-SHIFT        either SHIFT key
  605.     SYMBOL-SHIFT        either ALT key
  606.  
  607. The following special Amiga keys correspond to Spectrum key combinations.
  608.  
  609.     Amiga key        Spectrum key combination
  610.  
  611.     .            SYMBOL-SHIFT/M
  612.     ,            SYMBOL-SHIFT/N
  613.     ;            SYMBOL-SHIFT/O
  614.     -            SYMBOL-SHIFT/J
  615.     =            SYMBOL-SHIFT/L
  616.     keypad (        SYMBOL-SHIFT/8
  617.     keypad )        SYMBOL-SHIFT/9
  618.     keypad /        SYMBOL-SHIFT/V
  619.     keypad *        SYMBOL-SHIFT/B
  620.     keypad -        SYMBOL-SHIFT/J
  621.     keypad +        SYMBOL-SHIFT/K
  622.     keypad ENTER        ENTER
  623.     keypad .        SYMBOL-SHIFT/M
  624.     left arrow        SHIFT/5
  625.     down arrow        SHIFT/6
  626.     up arrow        SHIFT/7
  627.     right arrow        SHIFT/8
  628.  
  629. ESC quits the emulator (unless you cancel the requester that comes up).
  630.  
  631. HELP displays the Spectrum.help file, which is a diagram of the real Spectrum
  632. keyboard.  (You need about 70 kb of CHIP ram free for this.)
  633.  
  634. F1 brings up the load snapshot requester (provided arp.library is installed).
  635.  
  636. F2 brings up the save snapshot requester (provided arp.library is installed).
  637.  
  638. F3 changes the sampler type for cassette tape loading.
  639.  
  640. All the other Amiga keys do nothing.
  641.  
  642.  
  643.  
  644. Appendix 2:  Snapshot file format:
  645.  
  646. This format is based on the format used by the Mirage Microdriver "Dump"
  647. command.  Snapshot files are always 49179 bytes long.  Note that in the table,
  648. the byte offset starts from 0, not 1.
  649.  
  650.     Byte offset into file        Value
  651.  
  652.     0                i  register
  653.     1                l' register
  654.     2                h' register
  655.     3                e' register
  656.     4                d' register
  657.     5                c' register
  658.     6                b' register
  659.     7                f' register
  660.     8                a' register
  661.     9                l  register
  662.     10                h  register
  663.     11                e  register
  664.     12                d  register
  665.     13                c  register
  666.     14                b  register
  667.     15                iy low register
  668.     16                iy high register
  669.     17                ix low register
  670.     18                ix high register
  671.     19                bit 2 is set if interrupts are enabled
  672.     20                r register
  673.     21                flags register
  674.     22                a register
  675.     23                sp low register
  676.     24                sp high register
  677.     25                interrupt mode (0, 1 or 2)
  678.     26                filler (not used)
  679.     27..49178            48 kbytes ram dump
  680.  
  681.  
  682.  
  683. Appendix 3:  Other Spectrum Emulators for the Amiga:
  684.  
  685.  
  686. This emulator is different to, and was developed independently from, the public
  687. domain KGB Spectrum Emulator that you might have seen.  My emulator is about
  688. the same speed as the KGB v1.2 emulator on a 68000, and is about 2 or 3 times
  689. faster on an accelerated Amiga.  The KGB v1.2 emulator does not appear to
  690. multitask.  Also, the snapshot file format is different.
  691.  
  692. This emulator is also completely different from the Whitby Software Spectrum
  693. Simulator that you might have seen.  The Whitby Software Spectrum Simulator is
  694. an implementation of Spectrum Basic in 6502 for the Commodore 64.  It runs just
  695. fine on the Amiga under TheA64Package, and it seems to be about the same speed
  696. as my emulator.  But because it is a ROM rewrite, not a z80 emulator, you
  697. can't run machine code programs under it (i.e, most games).  You can only run
  698. Spectrum Basic programs.
  699.  
  700.  
  701.  
  702. Appendix 4:   Update Notes:
  703.  
  704.  
  705. v0.0    22 Oct 1990
  706.  
  707. First release.
  708.  
  709.  
  710. v0.1    15 Nov 1990
  711.  
  712. Sped up display code slightly.  Also sped up main instruction decode slightly.
  713. Display flash attribute as reverse.
  714.  
  715.  
  716. v0.2    30 Dec 1990
  717.  
  718. Now use double buffered display and implemented flash attribute properly.
  719. Added error requesters.
  720. Used pc-relative jump tables in z80 emulator --- slightly faster, and much,
  721. much smaller.
  722.  
  723.  
  724. v0.3    20 Jan 1991
  725.  
  726. Changed display routines to update screen periodically instead of after every
  727. z80 instruction that pokes the Spectrum's display file.  Used the blitter for
  728. this, running in parallel with the z80 emulator.  (Only character rows that
  729. have changed since the last screen update are redrawn.)
  730. Reverted to single buffer display and used blitter to implement flash.  (It's
  731. smaller and faster this way.)
  732. Fixed bug where couldn't use path string in arp file requester.
  733.  
  734.  
  735. v0.4
  736.  
  737. Changed the z80 emulator to use threaded code.  Now all that is executed between
  738. each pair of z80 instructions is "move.w (a3)+,d6; jmp table(pc,d6.w)" instead
  739. of about ten 68000 instructions to decode the next z80 opcode byte.  Overheads
  740. introduced are a new 128 kbyte table giving the routine offset for every byte
  741. in z80 ram, and the necessity to write a zero word into this table every time
  742. the emulator writes to z80 ram.  The overall speed increase is about 20%.
  743. Expanded some subroutines to macros and expanded $dd and $fd prefix
  744. instructions to independent code for a slight speed increase.  A side-effect
  745. is that the executable increased in size from 27k to over 40k.
  746. Introduced some bugs during the systematic changes that are proving hard to
  747. track down.
  748.  
  749.  
  750. v0.5     7 Apr 1991
  751.  
  752. Fixed bug in "sra a" instruction.
  753. Fixed bugs in rotate and shift (ix+d) and (iy+d) instructions.
  754. Fixed bugs where used "offset(a4,rr.w)" to address z80 memory space where offset
  755. is -2, -1, 1 or 2.  (Can't use that mode because of the unlikely event of rr.w
  756. being near $8000.)
  757. Implemented mode 2 interrupts.  Low byte of interrupt vector (normally
  758. provided by an external peripheral device) is assumed to be 0.
  759. Increased the interrupt interval from 2500 instructions to every 5000
  760. instructions, because otherwise some programs with their own (mode 2)
  761. interrupt routines overflowed the stack.
  762.  
  763.  
  764. v0.6    23 Apr 1991
  765.  
  766. Fixed bugs in the following z80 instructions:
  767.     ld     ixh,b
  768.     ld    ixh,d
  769.     rl    (ix+dd)
  770.     rr    (ix+dd)
  771.     sla    (ix+dd)
  772.     cpdr
  773. and iy equivalents of the above instructions.
  774. Implemented ini, outi, ind, outd, inir, otir, indr, otdr.  (Out instructions do
  775.     nothing).
  776. Now preserve (otherwise) unused flag bits in push af, pop af and ex af,af'
  777.     (instead of setting them all to 0).
  778. Changed layout of vector table for threaded code (origin now in middle).
  779. Fixed bug in vector table wraparound code (when pc incremented from 32767 to
  780.     32768).
  781. Sped up ram writes by optimising macro for writing a byte to ram.
  782. Added processor type check.  Now you get a requester when you try to run the
  783.     wrong version for your processor type, instead of "Software Error,
  784.     Task Held".
  785. Implemented sound by opening audio.device and trapping calls to the "beeper"
  786. subroutine at $03b5 in Spectrum ROM.
  787.  
  788.  
  789. v0.7
  790.  
  791. Optimised blits to update flash attributes by keeping track of which parts of
  792. the display are flashing and updating only those parts.  That saves a lot of
  793. blits.  No blits are needed at all when there are no flashing characters
  794. displayed.  It used to redraw the entire display for every blink.
  795.  
  796.  
  797. v0.8    13 May 1991
  798.  
  799. Further optimised the display routines by adding a 6144-byte lookup table.
  800.  
  801.  
  802. v0.9    22 Jul 1991
  803.  
  804. Lower task priority to -5 at startup.  This is friendlier to other tasks
  805. because Spectrum is highly CPU intensive.  If Spectrum is running at a higher
  806. priority than another task, then that other task is completely blocked.
  807. Sped up the emulator by 5% by checking for interrupts only after branch, jump,
  808. call and return instructions, instead of after all instructions.
  809. Open gameport.device and emulate Kempston joystick (at Z80 "in" instruction
  810. level) using the rear Amiga gameport.
  811.  
  812.  
  813. v0.9b    1 Sep 1991
  814.  
  815. Implemented all the undocumented z80 sls instructions.
  816. Fixed bug in ld (nn),sp instruction.  (It didn't work at all!)
  817. Implemented the z80 n flag --- all instructions now set/reset the n flag.
  818. Fixed bugs in inc/dec (hl), inc/dec (ix+dd) & inc/dec (iy+dd) (never set v).
  819. The daa instruction now works correctly after add and sub (not just adc & sbc).
  820. Incorporated Kristian Nielson's tape load routine.
  821. Allocate/free misc.resource.
  822. Added "File already exists! Overwrite?" requester (in save snapshot).
  823. Fixed keypad 0 key.
  824. Rationalised keyboard.  Arrow keys are now equivalent to SHIFT+5/6/7/8 instead
  825. of 5/6/7/8 (without the SHIFT).
  826. ESC key quits.
  827. The halt instruction now calls WaitTOF().  (Was too fast.)  The Spectrum Basic
  828. PAUSE function now works correctly.
  829. Added a separate timer task to prevent interrupts occurring too quickly.  The
  830. "flash" rate and keyboard interrupt rates are now more constant.
  831. The HELP key now displays Spectrum.help IFF/ILBM file from current directory.
  832. Reorganised register usage in z80 emulator to try to speed it up (lots of work
  833. but not much success).
  834.  
  835.  
  836. v1.0    9 Nov 1991
  837.  
  838. Implemented menus.
  839. Added noise correction code to cassette tape loader.
  840. Added support for 2 kinds of sound samplers.
  841. Screen to front after error requester in IFF loader.
  842. Use an interrupt server instead of extra task for timer.
  843. Further optimised blitter routines.
  844. Put z80 parity byte in a register (slight speedup).
  845. Implemented ld-bytes and sa-bytes to/from disk.
  846.