home *** CD-ROM | disk | FTP | other *** search
/ Emulator Universe CD / emulatoruniversecd1998.iso / Speccy / Emulators / z80 / Z80.DOC < prev    next >
Encoding:
Text File  |  1996-08-09  |  158.9 KB  |  3,262 lines

  1. Sinclair ZX Spectrum Emulator 'Z80' v3.04  -  10/8/96  -  by G.A. Lunter
  2.  
  3.  
  4.  
  5. Contents:
  6.  
  7.     1.    INTRODUCTION, REGISTRATION, GENERAL INFORMATION
  8.     1.1   Some general remarks
  9.     1.2   Registering - sounds interesting!
  10.     1.3   Other emulators
  11.     1.4   Acknowledgements
  12.     1.5   Disclaimers
  13.     1.6   Copyright notices
  14.  
  15.     2.    THE EMULATOR
  16.     2.1   Starting the emulator
  17.     2.2   Using the emulator
  18.     2.3   Keyboard emulation
  19.     2.4   Screen emulation
  20.     2.5   Sound emulation
  21.     2.6   Loading programs from tape
  22.     2.7   Using .TAP files
  23.     2.8   Using .VOC files
  24.     2.9   Multi-load games
  25.     2.10  Using the Microdrive
  26.     2.11  Using the Disciple and Plus D interfaces
  27.     2.12  Using the Multiface
  28.     2.13  Using the RS232 channel
  29.     2.14  On joysticks and mice
  30.     2.15  The utility ConvZ80
  31.     2.16  Converting file formats - the utility CONVERT
  32.     2.17  The utilities Z802TAP, TAP2TAPE and TAP2VOC
  33.     2.18  The utility OUT2VOC - and how to make .OUT files
  34.     2.19  The utilities READVOC and READSB
  35.     2.20  Quick overview of command line switches, and features
  36.     2.21  Miscellaneous remarks
  37.  
  38.     3.    THE SAMRAM
  39.     3.1   Basic extensions
  40.     3.2   NMI software
  41.     3.3   The built-in monitor
  42.  
  43.     4.    THE SPECTRUM
  44.     4.1   The Spectrum
  45.     4.2   The Interface I
  46.     4.3   The DISCiPLE and Plus D Interfaces - Introduction
  47.     4.4   The DISCiPLE and Plus D Interfaces - Basic commands
  48.     4.5   The DISCiPLE and Plus D Interfaces - More advanced commands
  49.     4.6   The DISCiPLE and Plus D Interfaces - The snapshot button
  50.     4.7   The Spectrum 128
  51.  
  52.     5.    TECHNICAL INFORMATION  (in file TECHINFO.DOC)
  53.     5.1   The Spectrum 48K
  54.     5.2   The Spectrum 128K
  55.     5.3   The AY-3-8912 sound chip
  56.     5.4   The ZX Printer
  57.     5.5   The Interface I
  58.     5.6   The SamRam
  59.     5.7   The Multiface 128
  60.     5.8   The Z80 microprocessor
  61.     5.9   File formats
  62.  
  63.  
  64.  
  65.  
  66.  
  67. 1. INTRODUCTION, REGISTRATION, GENERAL INFORMATION
  68.  
  69.  
  70.  
  71.  
  72. 1.1  Some general remarks
  73.  
  74.  
  75.     This is the documentation for 'Z80', a Sinclair ZX Spectrum 48/128
  76.     emulator.  The program turns your PC into a Spectrum.  Its features in
  77.     a (largish) nut-shell:
  78.  
  79.       - Emulates ZX Spectrum 48K model 2 or 3, and Spectrum 128K.
  80.       - Best compatibility of current Spectrum emulators.
  81.       - Emulates Interface I and Microdrive (cartridge in cartridge file),
  82.         Disciple and Plus D disk interfaces, Multiface 128.
  83.       - Full tape support: loads both normal and turbo-saved programs using
  84.         either tape interface on LPT port, SoundBlaster AD converter or
  85.         .VOC sound sample files; can also use .TAP binary tape image files
  86.         by trapping ROM save/load routines.  Saving back to tape is also
  87.         possible, either directly to tape or to a .VOC sound sample file.
  88.       - Full emulation of Spectrum screen, including all colour effects.
  89.         Border, and timing-sensitive border and attribute effects are also
  90.         emulated.
  91.       - Emulation of ZX Printer, for Epson and HP Laserjet compatible
  92.         printers.
  93.       - Emulation of beeper through PC beeper, and of 128K sound through
  94.         either PC beeper or AdLib (SoundBlaster) compatible cards
  95.       - Supports digital and analogue joysticks, and mouse, controlling
  96.         Cursor, Sinclair, Kempston or user-defined joystick.
  97.       - Emulates Spectrum AMS Mouse interface (used by e.g. Art Studio)
  98.       - Runs on any PC with 80286 or later processor; support for 8086 is
  99.         discontinued starting from version 3.04.
  100.       - Emulator runs just above 100% of actual Spectrum speed on 20 MHz
  101.         286 and 25 MHz 386SX; can be slowed down on faster machines.
  102.       - Z80 emulation includes emulation of R register, all unofficial
  103.         instruction codes, and unofficial flags; interrupts once every
  104.         1/50th emulated second; I have tried to make each instruction
  105.         execute in a time proportional to the time taken on a real Z80.
  106.       - Registered package includes all source files.
  107.       - Interface I and Spectrum 128's "p" channel input/output can be
  108.         re-routed to LPT or COM port, or to a file.
  109.       - Includes several utilities; to convert from and to other snapshot
  110.         and tape file formats, to convert snapshots into tape files, tape
  111.         files into sound sample files, to display contents of snapshot
  112.         files, to convert screen snapshots to .PCX and .GIF files, to read
  113.         .VOC sound sample files from the LPT tape interface or
  114.         SoundBlaster.
  115.       - A program is included which makes .VOC or raw sound sample files
  116.         of sounds produces by the Spectrum, either by the beeper, the
  117.         soundchip of the Spectrum 128, or the MIC port.
  118.       - OUTs to any port can be logged, and stored in a log file with
  119.         timing information.  This log file can be translated into a .VOC
  120.         sound sample file using OUT2VOC, for both ear and AY soundchip
  121.         output.
  122.       - Simple tracing feature
  123.       - Opcode mapping feature, tags bytes that are executed during
  124.         emulation; useful for debugging and disassembling purposes.
  125.         (It is meant to be used with the disassembler program DNSA by
  126.          Leslie Styles, lms@soton.ac.uk)
  127.       - Multi-level support as in XZX 0.5.2; also support of .SLT files.
  128.       - Emulator can set a breakpoint, invisible to the running program.
  129.       - Emulator can load and save blocks of Spectrum memory to disk
  130.         directly.
  131.       - Emulator can run under Windows (95).
  132.       - Supports VGA, EGA, CGA and Hercules video adapters including
  133.         monochrome VGA.  (Support for Plantronics discontinued.)
  134.  
  135.     There is quite a lot to explain in this documentation.  First of all
  136.     the emulator itself requires some of your PC's resources.  It is not
  137.     really a demanding program, but there are some things that need
  138.     attention.  These technicalities are dealt with in section 2.1.
  139.  
  140.  
  141.     Some general things about the emulator are explained in section 2.2.
  142.     After reading sections 2.1 and 2.2, you will know most of the basics.
  143.     The details can be found in subsequent sections.
  144.  
  145.     The Spectrum has a number of ways to communicate with the outside
  146.     world, like the obvious keyboard and the screen, but also the
  147.     microdrives, the DISCiPLE/Plus D disk interfaces, the tape interface,
  148.     the beeper, the sound chip of the Spectrum 128, the Kempston joystick,
  149.     the AMS Mouse, the ZX Printer interface, and the RS232 channel of the
  150.     Interface I and Spectrum 128 can be used to communicate with PC
  151.     channels in some way. For instance, the keyboard is connected to the PC
  152.     keyboard, and the tape I/O can be routed to a file, as well as to a
  153.     physical tape recorder, or it can come from a .VOC sound sample file.
  154.     All these things are explained in the rest of chapter 2.
  155.  
  156.     For our own Spectrums Johan Muizelaar and I built a piece of hardware
  157.     we called the SamRam (which has nothing to do with the SAM Coupe, by
  158.     the way!).  It contains a monitor program and software to make
  159.     snapshots of programs.  It's still very useful and I still use it a
  160.     lot.  An explanation of its functions is to be found in chapter 3.
  161.  
  162.     Some things peculiar to the Spectrum or its interfaces, not specific to
  163.     this program but useful to know, are collected in chapter 4.  It
  164.     contains for instance a table of Spectrum keywords and the key
  165.     combination to get them; unfortunately this information is not printed
  166.     on standard PC keyboards! More importantly, in this chapter it is
  167.     explained how to use the Microdrive and DISCiPLE interfaces, both of
  168.     which are probably unfamiliar to many former Spectrum users.
  169.  
  170.     There are some interesting technical facts about the Spectrum that I
  171.     discovered while debugging the emulator.  As much as I could think of
  172.     is contained in the final chapter, which can be found in the separate
  173.     file TECHINFO.DOC.  You don't need to read this chapter to use the
  174.     emulator.  A specification of the file formats used by the emulator is
  175.     also included there.
  176.  
  177.     Please note that the Tatort BBS, which used to be the 'Spectrum
  178.     emulator support BBS', has ceased to exist.
  179.  
  180.     There is by now a great lot of Spectrum-related information and
  181.     software available on the net.  A good starting point is the FAQ
  182.     (Frequently Asked Questions) list originally started by Marat
  183.     Fayzullin, and now maintained by Damien Burke.  It can be found at
  184.     http://www.cs.bham.ac.uk/~dmb/speccy/faq.html.  It is also available at
  185.     ftp://ftp.nvg.unit.no/pub/sinclair/docs/specfaq.  This latter site
  186.     carries a lot of Spectrum snapshot and Sinclair-related information.
  187.     Highly recommended!  A long list of FTP sites carrying Spectrum
  188.     programs is included in Damien Burke's FAQ list.
  189.  
  190.     If you have access to internet newsgroups, take a look at
  191.     comp.sys.sinclair, where many Sinclair enthousiasts meet and share
  192.     thoughts.  You will find lots of well-informed people there.  Please
  193.     read the aforementioned FAQ file before asking questions, but be
  194.     invited to join in afterwards.  Note: Please do *not* post binaries to
  195.     the comp.sys.sinclair newsgroup!
  196.  
  197.  
  198.  
  199.  
  200.  
  201. 1.2  Registering - sounds interesting!
  202.  
  203.  
  204.     'Z80' is a shareware program.  The program is not completely
  205.     functional, and the parts which are left out are included when you
  206.     register.  You are encouraged to give this demo version to friends, but
  207.     DO NOT change the original archive in any way, please.  The shareware
  208.     version of the emulator consists of the Z80-304.ZIP archive file, which
  209.     should contain the following 12 files:
  210.  
  211.         Z80.EXE      - The emulator itself.
  212.         Z80.INI      - Default initialisation file (used by Z80.EXE).
  213.         Z80.PIF      - Program Info File to run 'Z80' under Windows (3.1/95)
  214.         Z80.ICO      - Windows icon.
  215.         Z80.DOC      - Documentation file for the emulator.
  216.         Z80FAQ.DOC   - Frequently asked questions and answers.
  217.         REGISTER.DOC - This file.
  218.         NEW.DOC      - The What's New file.
  219.         ROMS.BIN     - Various ROM images (used by Z80.EXE).
  220.         TECHINFO.DOC - Technical info about the Spectrum etc.
  221.         LAYOUT.SCR   - Keyboard layout help screen (used by Z80.EXE).
  222.         DIAGRAM.Z80  - Circuit diagram for tape interface, and calibration
  223.  
  224.     The shareware version of the emulator differs from the registered
  225.     version in the following respects: it displays a message when the
  226.     program is started, and will only run normally for five minutes, after
  227.     which the program cannot be slowed down anymore.  Furthermore, it
  228.     cannot load from or save to tape, and it does not emulate the DISCiPLE
  229.     and the Plus D interfaces.  Everything else works as in the registered
  230.     version.
  231.  
  232.     If you register, you get the fully working version, and the following
  233.     utilities:
  234.  
  235.  
  236.         CONVERT  - a general conversion program: can list out BASIC and
  237.                    translate it back, produce .GIF or .PCX files from
  238.                    screen dumps, translate Spectrum ASCII (CR) to PC ASCII
  239.                    (CR/LF), and some other things.
  240.         CONVZ80  - Translates various snapshot and tape formats of other
  241.                    Spectrum emulators into each other.  Can handle the
  242.                    familiar .SNA format use by several emulators (JPP,
  243.                    XZX,...), and also Pedro Gimeno's (VGASPEC and SPECTRUM)
  244.                    .SP format and Kevin J. Phairs' (SPECEM) .PRG format.
  245.                    It can also handle tape files of SPECEM and L. Rindt and
  246.                    E. Brukner's emulator ZX.
  247.         DISCIPLE - Reads DISCiPLE and Plus D diskettes, both 3.5'' and
  248.                    5.25''.  It translates the 48K and 128K snapshot files
  249.                    to .Z80 snapshots, and ordinary files and screen
  250.                    snapshots to .TAP tape files. (Not necessary for the
  251.                    fully registered version, but handy for the cheaper
  252.                    one.)
  253.         ADDDAT   - Utility to edit the additional data part of .SLT
  254.                    snapshot files, which contain loading screens and level
  255.                    data.
  256.         Z802TAP  - Converts a .Z80 snapshot, 48K or 128K, to a .TAP file
  257.                    which can be loaded into the emulator and saved to tape
  258.                    by the next utility:
  259.         TAP2TAPE - Saves the contents of a .TAP file back to tape, to load
  260.                    it into an ordinary Spectrum.
  261.         TAP2VOC  - Converts a .TAP file to a .VOC sound sample file, to
  262.                    write to tape, or to load into the emulator.
  263.         READVOC  - Reads in a long, 'digital' .VOC sound sample, to be used
  264.                    as input to the emulator, from the LPT tape interface or
  265.                    a SoundBlaster.
  266.         READSB   - Reads .VOC sound samples from SoundBlaster using DMA,
  267.                    and applies a digital filtering and oversampling algo-
  268.                    rithm tuned for Spectrum tapes.
  269.         OUT2VOC  - Converts .OUT log files into .VOC or raw sound sample
  270.                    files, so that you can easily extract music samples from
  271.                    Spectrum/Spectrum 128 games, or SAVE directly to a .VOC
  272.                    or raw sample file.
  273.         Z80DUMP  - Shows the header and the contents of a .Z80 file.
  274.  
  275.  
  276.     You will also receive the source files of the emulator, the above
  277.     utilities and the SamRam, and you will be kept informed about future
  278.     updates.
  279.  
  280.     You can also choose to register for the emulator without DISCiPLE and
  281.     Plus D emulation, if you are not interested in those parts.  The
  282.     registration fee is a bit lower then, but you will receive everything
  283.     stated above (including the DISCIPLE program); the only difference is
  284.     that you get a version of the emulator that will not emulate the M.G.T.
  285.     interfaces.
  286.  
  287.     There are several registration sites, the main one being B.G. Services
  288.     in the U.K.  You can also register with Jimaz in the Czech Republic,
  289.     or David Pomeroy in New Zealand, whichever is most convenient.  Please
  290.     note that Friendware in Spain and Sinclair Freakeren are no longer
  291.     registration sites.
  292.  
  293.     IMPORTANT NOTE:
  294.  
  295.     When sending registrations, please either PRINT your order and address,
  296.     or use BLOCK CAPITALS to aid readability.  If you use a postal cheque
  297.     service, or direct transfer, please try to also send a letter to the
  298.     site with details of the payment etc.  Many payment slips are
  299.     unreadable copies.
  300.  
  301.  
  302.  
  303.     B G Services, U.K.
  304.     ------------------
  305.  
  306.     The registration fee is BP 20 or BP 15 (BP=British Pound) for the
  307.     version with or without DISCiPLE/Plus D emulation respectively.
  308.     Payment can be by cheques (Sterling on a UK bank, or Eurocheques) or UK
  309.     postal order made payable to B G Services.  You can also transfer
  310.     directly to the Giro account 324.82.16  (B G Services).  Girobank plc,
  311.     Bootle, Merseyside G1R 0AA.
  312.  
  313.     You can also send money in cash, in which case also US Dollars and
  314.     German Marks (registration fee US$ 30/US$ 25, DM 50/DM 40 respectively)
  315.     can be accepted.
  316.  
  317.     Please do not use other currencies than British Pounds on cheques; it
  318.     is not economic to change.  If it is the only option available, please
  319.     add BP 8 to cover drawing costs.  I regret I cannot accept orders via
  320.     charge or credit card.
  321.  
  322.     The address is:
  323.  
  324.                 B G Services
  325.                 64 Roebuck Road
  326.                 Chessington
  327.                 Surrey KT9 1JX
  328.                 (United Kingdom)
  329.  
  330.     Telephone enquiries on (0181) 287 4180, Fax (0181) 391 0744, or from
  331.     abroad: +44 181 287 4180 and +44 181 391 0744 respectively.
  332.  
  333.     B G Services can also supply ready built tape interfaces for BP 14.50.
  334.     These are professional quality items built into 25W 'D' connectors.
  335.     (If this archive is old, please enquire on price before ordering)
  336.  
  337.     Files will be on a 3.5" HD disc together with some ready converted
  338.     software, which is either PD, or has the approval of the authors.
  339.     Other disc sizes may be requested, but these may not contain all the
  340.     extra files.
  341.  
  342.  
  343.  
  344.  
  345.     Jimaz, Czech Republic
  346.     ---------------------
  347.  
  348.     For registrations in the Czech Republic, you can contact Jimaz.
  349.  
  350.                 JIMAZ s.r.o.
  351.                 Hermanova 37
  352.                 170 00 Praha 7
  353.                 phone: +42 2 379 498
  354.                 fax:   +42 2 378 103
  355.                 Email: vondrack@cslab.felk.cvut.cs
  356.  
  357.     Registration fee is 500 and 650 Czech crowns.
  358.  
  359.  
  360.  
  361.     David Pomeroy, New Zealand and Australia
  362.     ----------------------------------------
  363.  
  364.     For registrations in New Zealand and Australia, contact
  365.  
  366.                 David Pomeroy
  367.                 P O Box 2939
  368.                 Shortland Street
  369.                 Auckland
  370.                 New Zealand
  371.                 Phone: (09) 627-9618
  372.                 Email: davidpom@iconz.co.nz
  373.  
  374.  
  375.     The registration fee is 40/50 NZ$, or 30/40 AUS$.
  376.  
  377.  
  378.  
  379.                               ==================
  380.  
  381.  
  382.  
  383.     All sites reserve the right to ignore any order which does not comply
  384.     with the conditions above.
  385.  
  386.     If you have an older registered version and wish to upgrade, please
  387.     contact your registration site, sending return postage.  Updates within
  388.     the same version number and normally sent free if a disc and return
  389.     postage is received.  Updates from previous versions will carry a small
  390.     update fee.
  391.  
  392.  
  393.  
  394. 1.3  Other emulators
  395.  
  396.  
  397.     I used to have a list of other emulators for the PC and other computers
  398.     here, but the list in Marat Fayzullin/Damien Burke's FAQ was much more
  399.     complete and detailed, so I deleted mine.  It lists:
  400.  
  401.     14 emulators for PC's,
  402.     6 for the Commodore Amiga,
  403.     4 for the Acorn Archimedes,
  404.     4 for UNIX platforms,
  405.     3 for the Macintosh,
  406.     1 for the Atari ST,
  407.     1 for the NeXTStep, and
  408.     1 very old one for the Commodore 64
  409.  
  410.     I believe this makes the Sinclair ZX Spectrum the most often emulated
  411.     computer ever!
  412.  
  413.     There are also emulators available for the ZX81.  Carlo Delhez, who
  414.     also wrote a Spectrum emulator for the QL, wrote the ZX81 emulators
  415.     XTricator (for the QL) and XTender (for PC's).  There are probably
  416.     more.  For more information, take a look at the FAQ of the newsgroup
  417.     comp.sys.emulators.misc.
  418.  
  419.  
  420.  
  421.  
  422. 1.4  Acknowledgements
  423.  
  424.  
  425.     From the very first beginning in november 1988, when I wrote the first
  426.     lines of code for the emulator, Johan Muizelaar has been a very
  427.     demanding and critical user, being only satisfied when it was perfect.
  428.     Besides, there are quite a few things I would never have started
  429.     working on if he hadn't insisted that I would!
  430.  
  431.     I have also profited much from the fine cooperation with Brian Gaff,
  432.     who, besides handling the UK registrations, also generates a continual
  433.     stream of suggestions, remarks and bug reports.  He also brought me
  434.     into contact with many people that contributed to the emulator in
  435.     several ways.
  436.  
  437.     A major part of the things new to version 3 of the emulator have been
  438.     written by Hugh McLenaghan.  He wrote all code for the Disciple/Plus D
  439.     emulation, and for the ZX Printer emulation (where I subsequently
  440.     introduced bugs...)  Also, Hugh wrote much of the documentation for the
  441.     Disciple and Plus D interfaces in this file.
  442.  
  443.     
  444.     Finally, thanks are due to
  445.  
  446.     o   Carlo Delhez for information on the '128 and several other things,
  447.     o   Andre Mostert for some more '128 info and info on EMS memory,
  448.     o   Walter Prins for many '128 programs,
  449.     o   Marco Holmer for making the program such a big hit at the HCC dagen,
  450.     o   Henk de Groot, for finding a solution to a bug in A86 v3.22,
  451.     o   Arnt Gulbrandsen for a suggestion which made the emulator faster,
  452.             and information on a group of unofficial Z80 opcodes,
  453.     o   Ruud Zandbergen for his digital joystick interface,
  454.     o   Jan Garnier for providing the chips to reanimate my real Spectrum,
  455.     o   Ettore de Simone for finding a noisy bug,
  456.     o   Rudy Biesma and Tonnie Stap for providing info on the DISCiPLE disk
  457.             formats,
  458.     o   Burkhard Taige for various bug reports on it,
  459.     o   Ian Cull for enhancing the DISCiPLE program and two bugfixes,
  460.     o   Bert Lenaerts for information on the AZERTY keyboard,
  461.     o   Chris Lemon for fixing a bug in the CALL instruction,
  462.  
  463.     and many more not mentioned!
  464.  
  465.  
  466.  
  467.  
  468. 1.5  Disclaimers
  469.  
  470.  
  471.     The last version contained a few bugs, but this version is guaranteed
  472.     to be bug-free.  You can safely operate nuclear power plants or life
  473.     support systems with this software.  And if it still happens to break
  474.     down, feel free to sue me.
  475.  
  476.     Many of the bugs that disfigured the previous version are gotten rid of
  477.     now.  Most notably, the problem that saving a Disciple/+D snapshot
  478.     caused old data to be overwritten has been fixed.  On the other hand,
  479.     FORMATting Disciple/+D disks still has its problems, but, depending on
  480.     the machine in question, they have overcome in particular cases.
  481.  
  482.     Some people have sent me bug reports, for which I am very grateful.  I
  483.     have removed most of those, but have not been able to remove them all,
  484.     sometimes because the report was too vague and/or irreproducible on my
  485.     machine, or because of a mixture of reasons like: difficult to find,
  486.     not a problem to most people, easily circumvented, or laziness on my
  487.     part.
  488.  
  489.  
  490.  
  491.  
  492. 1.6  Copyrights etc.
  493.  
  494.  
  495.     Amstrad still holds the copyright on the 48K and 128K rom.  However,
  496.     they have kindly allowed free use of them.
  497.  
  498.     The Disciple ROM is (c) Bruce Gordon / Format Publications.
  499.  
  500.     The Plus D ROM is copyright Datel / Format Publications.
  501.  
  502.     Multiface and Lifeguard are registered trademarks of Romantic Robot.
  503.     They are licensed from Romantic Robot for use in Z80.
  504.  
  505.     The registered version of the Spectrum emulator 'Z80', and the version
  506.     distributed with PC Format, may NOT be further distributed.  The source
  507.     codes, which are part of the registered package, may NOT be used in
  508.     other Spectrum emulators running on PC's.  In principle, it is okay to
  509.     use the Z80 emulator code in an emulator for another Z80-based
  510.     computer; however, please do contact me if you want to use it.
  511.  
  512.  
  513.  
  514.  
  515.  
  516.  
  517. 2.  THE EMULATOR
  518.  
  519.  
  520.  
  521.  
  522. 2.1  Starting the emulator
  523.  
  524.  
  525.     The emulator will work on any PC with 640K memory and at least a 80286
  526.     processor, with a VGA, EGA, Hercules or CGA video adapter.  If
  527.     available, it will also use EMS memory, an Adlib compatible soundcard,
  528.     the SoundBlaster card, a mouse, and an analogue or digital joystick.
  529.  
  530.     The emulator will first read in the switches that are given in the
  531.     Z80.INI file.  You can enter switches there just like you do on the
  532.     command line.  Lines starting with a % sign are ignored; they are used
  533.     for comments.
  534.  
  535.     After any switches, you may specify a snapshot file on the command
  536.     line. This file will then be loaded and executed directly.  The
  537.     extension .Z80 is not necessary.  The emulator will also read .SNA
  538.     files (the snapshot format of, amongst others, Arnt Gulbrandsen's JPP);
  539.     you don't have to convert them to .Z80 files (but you may want to to
  540.     save disk space), and it reads .SLT files (containing snapshots plus
  541.     additional data, mostly level data for games consisting of various game
  542.     levels).
  543.  
  544.     The emulator tries to figure out what hardware is available, and uses
  545.     things as it finds them.  Most of the time this will work without you
  546.     having to tell it anything, but if you have to, you can override the
  547.     defaults by putting switches on the command line.  Switches that you
  548.     use often can be put in the Z80.INI file.  If you give a switch a
  549.     second time, for instance if it is also in the Z80.INI file, it will
  550.     disable it again.
  551.  
  552.     If you're using a Trident VGA with version 3 BIOS, you may see the
  553.     picture compressed at the top of the screen, while the bottom half
  554.     contains vertical white lines.  This is due to a bug in the Trident VGA
  555.     Bios.  Start the emulator with the switch -xv to get a full picture.
  556.  
  557.     Some VGA adapters do not produce a stable picture when Z80 is using the
  558.     standard VGA mode.  If your monitor doesn't sync, try switch -xv.
  559.  
  560.     Some black-and-white VGA monitors only display one of the three RGB
  561.     colours (green most of the times), resulting in several Spectrum
  562.     colours becoming indistinguishable.  Use -xb to use grey tones instead
  563.     of colours.
  564.  
  565.     If you are using Hercules, try starting the emulator with -xh on the
  566.     command line.  The emulator will use a non-standard Hercules mode to
  567.     display a full-screen Spectrum picture.  You may need to calibrate your
  568.     monitor to make the image steady.
  569.  
  570.     If you're using Plantronics, try -p and -q to see which gives the best
  571.     result.
  572.  
  573.     If you haven't got EMS memory, the page swapping of the Spectrum 128
  574.     cannot be emulated exactly, and, more seriously, it is extremely slow.
  575.     Although most programs will work, they will be too slow to be of any
  576.     use.  Also, the emulator needs lots of base memory if no EMS memory is
  577.     present; if you don't have enough, try specifying -xt on the command
  578.     line to make the emulator use as little memory as possible (by
  579.     shrinking several buffers).  The emulator uses 332K or 572K of base
  580.     memory (with and without EMS memory respectively), and 47K less in both
  581.     cases if -xt is specified.  If this is still not enough, try to use
  582.     -xu, which saves 83K, but then Hi Resolution Colour emulation does not
  583.     work anymore.
  584.  
  585.     On 386 and 486 machines you can emulate EMS by software using EMM386
  586.     for instance.  The speed of the EMS emulator determines in part the
  587.     emulation speed of Spectrum 128K programs, so it may be wise to try a
  588.     few for the best results.  I use QEMM, which seems to be faster than
  589.     EMM386.
  590.  
  591.     The Spectrum 128 has a built-in sound chip.  If you have an Adlib
  592.     compatible soundcard installed, the Spectrum 128 sound will be played
  593.     through the Adlib card.  If you haven't, the loudest of the three sound
  594.     channels will be played through the internal PC speaker.  Sometimes the
  595.     effect is quite nice, sometimes it is horrible, but it's all I can do
  596.     on a standard PC.  If you don't want to have the Spectrum 128 sound
  597.     played through the internal speaker, use the switch -xi.  If you don't
  598.     want the Adlib card to be used (for instance to hear the sound through
  599.     the internal speaker) use -xa.
  600.  
  601.     If you're using the Pro-Audio Spectrum 16 sound card, do not install
  602.     the resident FM.EXE program; it causes problems with the emulator. Do
  603.     make sure that MVSOUND.SYS is installed in your CONFIG.SYS file, to
  604.     make the Pro-Audio Spectrum 16 Adlib compatible.
  605.  
  606.     The noise channels of the Spectrum 128 sound chip can work on different
  607.     frequencies, whereas the FM chips of the Adlib card cannot.  However,
  608.     if your Soundblaster is equipped with CMS chips, the noise frequency
  609.     can be programmed.  Specify -xc to use the CMS chips.  (These chips are
  610.     not available on Soundblaster Pro cards, and neither on most
  611.     Soundblaster clones).
  612.  
  613.     If you're living in Belgium or France, you are probably using an AZERTY
  614.     keyboard.  Specifying -xz on the command line will make all letter keys
  615.     and many punctuation keys work in the right way.
  616.  
  617.     If the emulator erroneously detects an analogue or digital joystick,
  618.     use the switch -kk.
  619.  
  620.     The emulator can now also be run under Windows 3.1!  However, you
  621.     cannot use the tape interface and Real mode doesn't work anymore.  In
  622.     version 3.04, keyboard handling under Windows is much improved, and
  623.     works as well as without Windows.  If you let the emulator run
  624.     full-screen you may use EGA or VGA, if you want to run it windowed
  625.     you'll have to use CGA, because the virtual video display driver of
  626.     Windows cannot handle the VGA mode I use (although it's only a standard
  627.     text mode; even Windows 95 doesn't know how to handle it). You'll
  628.     probably want other default settings of some parameters (such as the
  629.     video mode) if you run the emulator under Windows; the emulator will
  630.     always use the .INI file in the directory of the Z80.EXE file so the
  631.     other switches must be put on the command line or in a .PIF file. An
  632.     example .PIF file (which runs the emulator in windowed CGA mode) and a
  633.     .ICO icon file are supplied.
  634.  
  635.     The emulator measures the speed of the computer it runs on in the
  636.     normal way.  Under Windows 95 this gives reliable results; however,
  637.     Windows 3.1 causes Z80 to run about 3 to 4 times slower than normal.
  638.     You may have to tinker with the speed setting to get it to run at a
  639.     reasonable speed.
  640.  
  641.     The emulator will automatically detect whether Windows is running, and
  642.     act appropriately.  To run the emulator in Windows compatibility mode
  643.     in a normal DOS environment, use -xw.  If you use this switch under
  644.     Windows, it turns windows compatibility mode OFF, and hangs unless you
  645.     use Hi Resolution Colour emulation (which doesn't rely on the timer).
  646.  
  647.     When running the emulator under Desqview, use -e for EGA mode display.
  648.  
  649.     At present running under OS/2 is not a good idea as it will crash if
  650.     the speed is altered.
  651.  
  652.     These are the most important switches that you have to specify when you
  653.     start the emulator.  Most of the other switches are used to select
  654.     default values for various things which can also be changed when the
  655.     emulator is running.  Some useful things to select are default
  656.     directories for .Z80, .TAP and .MDR files; these will be explained
  657.     below.
  658.  
  659.  
  660.  
  661.  
  662. 2.2  Using the emulator
  663.  
  664.  
  665.     In this section, the basic functions of the emulator, residing under
  666.     the function keys F1-F10, are explained.
  667.  
  668.     When the emulator starts, you'll see the usual Spectrum copyright
  669.     message appear on screen.  Pressing F1 will pop up a small help screen
  670.     that explains the function of the function keys and various other
  671.     special keys.
  672.  
  673.     By pressing F10, you enter the main menu of the emulator.  Most of the
  674.     menu options can be chosen directly by pressing another function key; a
  675.     small help screen pops up if you press F1.  If you're somewhere deep in
  676.     the menu structure from the main menu, pressing ESC will get you one
  677.     level higher most of the time.  Pressing F10 will get you back to the
  678.     main menu.
  679.  
  680.     The 'Select Hardware' menu option sits under function key F9.  There
  681.     are seven major configuration to choose from:
  682.  
  683.         Spectrum 48K
  684.         Spectrum 48K + Interface I
  685.         Spectrum 48K + SamRam + Interface I
  686.         Spectrum 48K + M.G.T. Interface  (i.e. DISCiPLE or Plus D)
  687.         Spectrum 128K
  688.         Spectrum 128K + Interface I
  689.         Spectrum 128K + M.G.T.
  690.  
  691.     This menu also allows to choose the M.G.T. type, +D, Disciple with a
  692.     pre-loaded operating system supporting graphics output using the Epson
  693.     format, and one supporting HP-PCL format graphics output.
  694.  
  695.     In all configurations except the one with SamRam, the Multiface 128 can
  696.     be emulated too.  The Multiface 128 software is aware of, and can read
  697.     and write to, the Microdrive of the Interface I and the Disciple and +D
  698.     disk drive.
  699.  
  700.     After a change has been made, pressing ENTER switches to that mode and
  701.     resets the Spectrum.  If you don't want the Spectrum to reset, pressing
  702.     CTRL-ENTER will switch to the new mode while preserving as much of the
  703.     runninge program as possible.  Switching from 128K mode to 48K mode
  704.     will almost always crash the program, except if you enter the SPECTRUM
  705.     command before switching.  Be careful when you change the disk drive
  706.     emulation; when switching an MGT interface (Disciple or +D) on or off,
  707.     it is wise always to reset the emulator, as otherwise the hardware will
  708.     often not match the system variables.
  709.  
  710.     To use SamRam's monitor on a 128 program, switch the hardware from the
  711.     main menu, and generate an NMI (Extra functions - N) before returning
  712.     to the emulator.  This will often work, but you can't return to the
  713.     program without crashing it.
  714.  
  715.     On a real Spectrum 128, the menu bar of the startup screen is moved
  716.     using the cursor keys on the '128 keyboard.  These keys simultaneously
  717.     press a normal cursor key (5,6,7 or 8) and shift.  So you can shift the
  718.     menu bar with shift-6 and shift-7.  It is possible to use the PC cursor
  719.     keys for this; you have to select Cursor joystick emulation (which is
  720.     selected by default) and press Num-Lock once to have the PC-cursor keys
  721.     press the Spectrum Shift key too.  You could also specify -xs on the
  722.     command line (or put it in the Z80.INI file) to make the PC cursor keys
  723.     by default press shift for you in '128 mode; see also the Miscellaneous
  724.     remarks section.
  725.  
  726.     The Save and Load Program options (F2 and F3) will save the whole state
  727.     of the Spectrum and some of the emulators' settings to a .Z80 snapshot
  728.     file.  It will pack the data somewhat, so that the length of the file
  729.     varies.  The amount of memory saved depends on the current hardware
  730.     mode; 48K for normal Spectrum, 80K for SamRam, and 128K for Spectrum
  731.     128.  (Note that the RAM contents of the M.G.T. interface or the
  732.     Multiface 128 are not saved.)  The settings that are saved are those
  733.     that are program dependent, for instance which joystick emulation is
  734.     used, and more technical settings like those of the R register, LDIR
  735.     and Issue 2 emulation, double interrupt frequency and video
  736.     synchronisation.  These are explained below.
  737.  
  738.     Loading a .Z80 file will cause several settings to be changed.
  739.     Resetting the Spectrum will not reset these settings to their default
  740.     values! Especially the joystick emulation setting change can be
  741.     confusing.
  742.  
  743.     All settings can be checked and changed in the Change Settings menu,
  744.     which pops up if you press F4. You can do many things here.  The I and
  745.     O options can be used to redirect the RS232 output; see section 2.13
  746.     for information on this.  R - R register emulation, and L - LDIR
  747.     emulation are usually only necessary when loading programs;  for
  748.     remarks on these options see section 2.6, and section 5.1 for more
  749.     technical details.  Other settings and switches are:
  750.  
  751.     H - Hi resolution colour emulation, also called 'coppering'.  To
  752.     eliminate flickering of moving characters, and to see some colour
  753.     effects otherwise not visible.  Also, this allows you to see the famous
  754.     loading stripes in the border.  See section 2.4 for more information.
  755.  
  756.     2 - Issue 2 emulation will turn the emulated Spectrum in an Issue 2
  757.     Spectrum.  (This option also works, but is out of place, in Spectrum
  758.     128 mode).  Some very old programs (Blue Ribband, Spinads) will not
  759.     respond to the keyboard properly on Issue 3 Spectrums, and for these
  760.     programs this option was added.  Seldom needed.
  761.  
  762.     S - sound enables you to turn off all sound, useful for late-night
  763.     playing.
  764.  
  765.     D - double interrupt frequency is useful for slow machines, as some
  766.     programs will run faster when this option is on.  If you're typing in a
  767.     BASIC program on a slow machine, always turn this on, since the
  768.     keyboard, which is polled by an interrupt routine, will respond much
  769.     better.  On the other hand, some programs will crash with this option
  770.     active.
  771.  
  772.     V - video synchronisation is used to remove the flickering of moving
  773.     characters in some programs.  You can choose between Normal, High and
  774.     Low.  Normal works well for almost all programs; Ghosts and Goblins and
  775.     Zynaps look much better when this is turned to High.  If you see
  776.     characters not moving smoothly or flicker, or a background not moving
  777.     as a whole, experiment a little bit with this setting, and re-save the
  778.     snapshot when you've found the best setting.  On fast computers, try to
  779.     use Hi res colour emulation instead.  This setting has no effect when
  780.     Hi res colour emulation is on.  (For a more detailed discussion of this
  781.     option see section 2.4 and section 5.1)
  782.  
  783.     J - joystick emulation specifies which Spectrum joystick the PC cursor
  784.     keys (and mouse, and analogue or digital joystick, if available)
  785.     control. You can choose from Cursor (default), Kempston, Interface 2
  786.     and user-defined.  As already said above, if Cursor joystick is chosen,
  787.     the Num-Lock key controls whether Shift is pressed too with a joystick
  788.     movement. (Since the shift and number keys are pressed exactly
  789.     simultaneously, it is possible that the Spectrum has already read the
  790.     Shift key, but not yet the others, when you press both keys down.
  791.     Sometimes you will therefore get the number 5,6,7 or 8 instead of a
  792.     cursor movement. If you have used a +3 or +2A Spectrum, you will be
  793.     familiar with this!)
  794.  
  795.     Finally, C - Change speed lets you control the speed of the emulator.
  796.     As a side effect, slowing down the emulator makes the timing of the
  797.     various opcodes correspond more exactly to the actual timing on a real
  798.     processor.  (Remember this is not possible on slow PCs!)
  799.  
  800.     That concludes the discussion of the F4-'change settings' menu.  Let's
  801.     continue with the other function keys.
  802.  
  803.     F5 generates an NMI. This is used to activate the Samram, Multiface
  804.     128, or start the Disciple/+D Snapshot facility. If none of these are
  805.     active it may reset the Spectrum or do nothing.
  806.  
  807.     ALT-F5 or CTRL-F5 resets the Spectrum.
  808.  
  809.     F6 turns on Real Mode.  Try this when the emulator is playing a tune
  810.     and sounds a little harsh.  This mode is needed when you want to load
  811.     turbo-saved games from tape; see below for more information.
  812.  
  813.     F7 and F8 activate the tape and Microdrive/M.G.T. menus.  Again, see
  814.     below for more information.
  815.  
  816.     Resetting the Spectrum, or generating an NMI can be done from the main
  817.     menu too, in the X - Extra Functions menu.  This is useful if you want
  818.     to activate the NMI software of the SamRam for instance just after
  819.     loading a snapshot file, or just after you changed the hardware mode.
  820.  
  821.     In this menu it is also possible to save or load a memory block or
  822.     screen snapshot; to set a breakpoint (see section 2.21) or to
  823.     temporarily shell to DOS. Furthermore, here you can find another
  824.     sub-menu for the OUT logging feature.  If port FE is logged, such a log
  825.     file can be translated into a .VOC sound sample file using the OUT2VOC
  826.     utility.
  827.  
  828.     When you're typing BASIC-programs in 48K mode, you'll probably have to
  829.     look up some Spectrum keywords.  Further down in this documentation
  830.     there is an alphabetical list of all keywords and their
  831.     key-combination. For 'on-line' help, press ALT-F1 to see the Spectrum
  832.     keyboard layout.
  833.  
  834.  
  835.  
  836.  
  837. 2.3  Keyboard emulation
  838.  
  839.  
  840.     The keyboard.  Letter keys are mapped to the Spectrum's letter keys.
  841.     The ALT and CTRL keys can both be used for Symbol Shift.  Then, there
  842.     are a lot of keys on the PC keyboard which don't exist on the Spectrum
  843.     keyboard.  Many of them are used, to make things easier:
  844.  
  845.     The function keys have several special functions.  See the previous
  846.     section.
  847.  
  848.     CTRL-Break and CTRL-ALT-DEL quit the emulator.  Better use F10-Q-Y
  849.     though.
  850.  
  851.     The punctuation keys - = ; ' , .  / and their shifts: _ + : " < > ?
  852.     have the effect of pressing Symbol Shift and the corresponding letter
  853.     key, so you can use these in the straightforward way.
  854.  
  855.     The ESC key presses Shift-1, EDIT, used as a sort of ESC key in many
  856.     Spectrum programs.  The Backspace key presses Shift-0, the Delete of
  857.     the Spectrum.  CapsLock presses Shift-2, Spectrum's capslock key.
  858.  
  859.     The PC-cursor keys and the numeric keypad keys 8,4,6 and 2 control the
  860.     Cursor, Interface 2, Kempston or user-defined joystick.  The TAB key,
  861.     and 0,5 and ./DEL on the numeric keypad control the fire button.  If
  862.     the Cursor joystick is selected, you can select whether Shift should
  863.     also be pressed with the NumLock key (but see the discussion above of
  864.     the -xs switch).
  865.  
  866.     If you're running the emulator on a slow computer, try selecting double
  867.     interrupt frequency.  Most programs poll the keyboard by interrupt, in
  868.     any case the ROM does, and doubling the frequency with which this
  869.     happens will make the emulated Spectrum react much more quickly on your
  870.     keystrokes.
  871.  
  872.     If you've got an AZERTY keyboard, the standard mappings of the keys
  873.     won't work at all properly.  Include the switch -xz in your Z80.INI
  874.     file in this case; many punctuation keys will now also work properly.
  875.     There is no support for other non-US keyboard layouts; sorry!
  876.  
  877.     You can re-map the keyboard by yourself by using the -kx switch.  It
  878.     has the format
  879.  
  880.         -kxABCD
  881.  
  882.     where #AB denoted the scan-code (in hex, between #01 and #58) and #CD
  883.     the key that should be pressed when the emulator sees this scan code.
  884.     Normal keys are coded by bytes below #40; the lower three bits denote
  885.     the row number (0-7), and the upper three bits the column number (1-5).
  886.     Column 1 of rows 0-7 are respectively Shift,A,Q,1,0,P,Enter and Space.
  887.     Column 2 to 5 are the keys on the same line, but more toward the
  888.     center.  For instance, C is on row 0, column 4, and has code 0+8*4=32=
  889.     #20.  Function key F11 has scan code #57, so to map F11 to C use
  890.     -kx5720.  Code keys '#CD' in the range #C0 - #DD are used to code for
  891.     special keys.  Here is the list of codes in this range:
  892.  
  893.         #C0  Edit                          #CF  Joystick left
  894.         #C1  - or _                        #D0  Joystick right
  895.         #C2  + or =                        #D1  + or =
  896.         #C3  Delete                        #D2  Joystick down
  897.         #C4  ; or :                        #D3  Joystick fire
  898.         #C5  " or '                        #D4  F1
  899.         #C6  , or <                        #D5  F2
  900.         #C7  . or >                        #D6  F3
  901.         #C8  / or ?                        #D7  F4
  902.         #C9  *                             #D8  F5
  903.         #CA  Capslock                      #D9  F10
  904.         #CB  Numlock (Shift toggle)        #DA  F6
  905.         #CC  Scroll lock (+CTRL=Quit)      #DB  F7
  906.         #CD  Joystick up                   #DC  F8
  907.         #CE  - or _ (for grey -)           #DD  F9
  908.  
  909.     Simultaneous keypresses on the PC keyboard are only transmitted to the
  910.     PC to a certain extent, depending on the particular keyboard.  My old
  911.     keyboard could handle TAB and the keys on the numerical keypad
  912.     simultaneously, but my new keyboard can't.  There is absolutely nothing
  913.     to be done about it.  Playing games can be a problem sometimes.  You'll
  914.     have to live with it.  All information sent by the keyboard is used.
  915.  
  916.  
  917.  
  918.  
  919. 2.4  Screen emulation
  920.  
  921.  
  922.     There are two different ways the emulator can emulate the screen.  The
  923.     standard way, in which 50 times an emulated second the screen is
  924.     checked for changes, and they are subsequently displayed on the
  925.     monitor. This works fine, and was the only mode available in previous
  926.     versions. It works basically the same with all video modes; however,
  927.     some are much slower than others. EGA is notoriously slow, due to the
  928.     ugly way it has to be addressed. VGA is definetely the fastest. EGA and
  929.     VGA are the only video modes in which the colour of the overscan can be
  930.     controlled; in these modes, some emulation of border effects (loading
  931.     stripes, for example) can be done. You don't see these effects in the
  932.     other video modes.
  933.  
  934.     Changing the overscan colour results in 'snow' lines appearing on the
  935.     screen.  It is possible to eliminate these by waiting until the video
  936.     adapter is in horizontal retrace.  This takes some time, therefore the
  937.     emulator doesn't do this in Real Mode. Real time loading requires
  938.     minimum delay, so the screen does not update. You can select the update
  939.     option, but you risk Tape Loading errors!
  940.  
  941.     In the standard mode, the point (relative to the 50 Hz interrupt) at
  942.     which the screen is displayed can be controlled by setting the 'Video
  943.     Synchronisation Mode' to normal, high or low.  If you see moving
  944.     characters flickering excessively, try changing this setting.  For
  945.     instance, BC's Quest for Tires won't look at all good with a wrong
  946.     setting; many programs display subtle differences in different modes.
  947.  
  948.     In the Hercules and CGA modes not all colours can be displayed.  In EGA
  949.     mode, all colours can be displayed, but some colours have the same
  950.     intensity in Bright 1 as in in Bright 0.  Only in VGA mode the colours
  951.     resemble closely the Spectrum originals.
  952.  
  953.     The other video emulation mode is called Hi-resolution colour emulation
  954.     mode. In this mode great care is taken to display each video line at
  955.     exactly the right time, and also the precise times the border colour is
  956.     changed is used to build the border pattern. In this mode, every
  957.     hi-resolution colour effect is visible; all flickering problems are
  958.     also eliminated (provided they weren't already there on a real
  959.     Spectrum!), so no need to adjust the Video Synchronisation Mode.
  960.  
  961.     The drawback of using this mode is that it is much slower, since the
  962.     emulator has to keep track of the number of T states passed, and also
  963.     has to grab a line from screen memory and put it in a buffer 192 times,
  964.     50 times a second.  But on fast computers, 486's and up, the emulator
  965.     can still easily emulate at 100%.
  966.  
  967.     HRC mode only works with a VGA video adapter.
  968.  
  969.     Finally, when loading turbo-saved programs in Real mode, screen updates
  970.     are suspended because they take too much time (even on fast computers).
  971.     You can refresh the screen by pressing U - Update in Real mode, but you
  972.     should do this only if you're sure that the emulated program is not
  973.     loading a block, for pressing U during loading is a sure way to get a
  974.     tape loading error.
  975.  
  976.  
  977.  
  978.  
  979. 2.5  Sound emulation
  980.  
  981.  
  982.     The Spectrum beeper is emulated by the PC's internal beeper.  Because
  983.     every 1/50th of a second the screen has to be updated, and this takes a
  984.     little time even if there are no changes, the sound is a bit harsh.  If
  985.     you select real mode, the emulator won't update the screen and music
  986.     will sound good.  If you select HRC mode, the sound will be even
  987.     harsher than it does in normal mode.
  988.  
  989.     The sound of the Spectrum 128's sound chip is played through the Adlib
  990.     card; if you haven't got such a card some notes are played through the
  991.     internal speaker.  That sound will be turned off, however, as soon as
  992.     the program makes a sound through the normal speaker of the Spectrum.
  993.     Some Spectrum 128 programs use the sound chip and the beeper at the
  994.     same time, and this won't work properly without an Adlib card.
  995.  
  996.  
  997.  
  998.  
  999. 2.6  Loading programs from tape
  1000.  
  1001.  
  1002.     This emulator can load programs that are saved to tape in the usual
  1003.     way, but also turbo-saved programs can be loaded.  Furthermore, you can
  1004.     make a disk file act as an 'emulated tape', so that the normal SAVE and
  1005.     LOAD commands can be used to transfer data to and from disk easily.
  1006.  
  1007.     The emulator can load programs from .VOC sound sample files.  This is
  1008.     very useful for multi level games; the levels on the tape can be put in
  1009.     .VOC samples, and loaded when needed without having to re-install the
  1010.     tape recorder.  How to use .VOC files is described in section 2.8
  1011.     below.  The current section is about loading programs directly from
  1012.     tape.
  1013.  
  1014.     First of all, you need an interface to connect the tape recorder to the
  1015.     PC.  There are two ways of doing this.  You can use a tape interface on
  1016.     the LPT port.  A circuit diagram is in the DIAGRAM.Z80 program, or you
  1017.     can obtain a ready-made interface from B G Services, see section 1.2
  1018.     for more details.
  1019.  
  1020.     Version 3 can also use the SoundBlaster for tape input.  This is easier
  1021.     since no additional interface is needed.  The LPT tape interface
  1022.     however is more robust in loading.  When using the SoundBlaster, you
  1023.     have to be careful not to put the volume level too high, since
  1024.     otherwise the SoundBlaster will clip, which is a sure way to producing
  1025.     tape loading errors.  The LPT tape interface is not sensitive to this.
  1026.  
  1027.     It has proven very difficult to load programs directly via
  1028.     SoundBlaster.  This is due to the fact that the emulator does not have
  1029.     time to filter the SoundBlaster input (except for a trivial hi-pass
  1030.     filter to remove a 50 Hz hum) in Real mode.  For direct loading, the
  1031.     LPT interface is strongly recommended.  For loading via the
  1032.     SoundBlaster, the utility READSB (see section 2.19) will read in and
  1033.     filter the sample.  Loading via READSB is, I think, as reliable as
  1034.     loading via the LPT interface.
  1035.  
  1036.     If you want to save programs back to tape, you have to use the LPT
  1037.     interface; it is not possible to use the SoundBlaster for this.  (There
  1038.     is a way to save programs in standard format to tape though; put them
  1039.     in a .TAP file - see below - convert it to a .VOC file and play this
  1040.     sample to a tape.  Use a good sample player, one that doesn't halt for
  1041.     half a millisecond between blocks!)
  1042.  
  1043.     In the program DIAGRAM.Z80 a tape tester is present.  The LPT tape
  1044.     interface has to be calibrated, and this program can also be used to
  1045.     check the volume level when using the SoundBlaster as input device. The
  1046.     variable resistor of the LPT tape interface has to be adjusted so that
  1047.     the bar, which should go to 0% when the volume is down, points just
  1048.     below 50% at normal volume.  In the case of the SoundBlaster, when the
  1049.     volume is turned up, the bar first goes from 0% to 50% and over, and
  1050.     then saturates and drops below 50% again.  The volume has to be set
  1051.     such that it is just 50% in the non-saturated zone.
  1052.  
  1053.     You have to tell the emulator which LPT port you use for tape I/O.  Use
  1054.     command line switch -b2 for example to select LPT2 for tape input (or
  1055.     put it in the Z80.INI file).  Use -xo to select the SoundBlaster for
  1056.     tape input.  It uses base address 0220 by default; if this is not
  1057.     correct, use for instance -xq 0240 to specify address 0240.  The
  1058.     emulator does not use the SoundBlaster interrupts.
  1059.  
  1060.     There are two ways to load programs: in 'real' or normal mode.  In real
  1061.     mode, the emulator doesn't update the screen or scan the keyboard, so
  1062.     that the emulated Spectrum program can run smoothly.  The emulator has
  1063.     to run at about 100%, but then you're able to load everything a normal
  1064.     Spectrum would load, including turbo-saved programs.  The only thing
  1065.     you see on screen are the loading bars in the border (on EGA or VGA
  1066.     screens).  Real mode is selected by pressing F6.  Saving programs in
  1067.     real mode is a bit useless but it works; enter the SAVE command, press
  1068.     a key to start saving and quickly press F6 when the saving starts.  It
  1069.     will continue in real mode.
  1070.  
  1071.     Please note that in real mode, the PC clock is not updated.  It will
  1072.     run behind for as many minutes as real mode has been switched on.  The
  1073.     CMOS clock won't be affected, so the next time you start up your
  1074.     computer things will be normal again.
  1075.  
  1076.     If your computer is just fast enough, don't slow the emulator down too
  1077.     much.  Because the IN instruction is relatively slow, the emulator has
  1078.     to run at about 110% for the best results.  If your computer is really
  1079.     fast, you can best slow it down to exactly 100%.  If your computer is
  1080.     just a bit too slow, you can try to make your tape recorder run slower
  1081.     too (usually you can do this by adjusting a little screw at the back of
  1082.     the motor), I successfully loaded several speed-saved programs at 90%.
  1083.  
  1084.     In normal mode, the standard ROM loading and saving routines are
  1085.     'trapped' (at addresses 04d8 and 056a) when they're about to start
  1086.     saving or loading.  A routine in the emulator itself then takes over,
  1087.     and loads or saves a block to tape (or a disk file, see below).
  1088.  
  1089.     When you enter LOAD "", the emulator starts loading using its internal
  1090.     loading routine.  You'll see a blue window appear.  Pressing F6 now
  1091.     will switch to Real mode, and the emulated Spectrum program will
  1092.     continue the loading process (if it is running at 100%).
  1093.  
  1094.     Every time a block is loaded or saved, a window containing some
  1095.     information of the block to be loaded or saved appears.  If you don't
  1096.     want this, for example because you want to enjoy the loading screen,
  1097.     specify -tx on the command line.
  1098.  
  1099.     Using these SAVE and LOAD routines has a great advantage as well as a
  1100.     disadvantage compared to using the Spectrum's own routines in real
  1101.     mode. The advantage is that the internal routines work on every
  1102.     machine, no matter how slow or fast, without having to make the
  1103.     emulator run at 100%.  The disadvantage at using them is that they
  1104.     obviously won't understand turbo-saved files.  For normal use, these
  1105.     internal routines work much easier, and real mode loading is only
  1106.     necessary for turbo-saved and well protected programs.
  1107.  
  1108.     Today, most programs are protected.  The emulation of the Z80 processor
  1109.     has to be exactly right, or those strange decoding routines that use
  1110.     all features of the processor the programmer could think of, will
  1111.     definitely crash.  It is most important to switch the R-register and
  1112.     LDIR emulation on, as virtually all protected programs use at least the
  1113.     R register.  Sometimes programs are real sensitive to the timing of the
  1114.     interrupts; if programs refuse to load, try sampling the first few
  1115.     blocks in a .VOC file (see below) and load it from there (of course
  1116.     with R register and LDIR emulation on); when loading from VOC files,
  1117.     interrupt timings are exact.
  1118.  
  1119.  
  1120.  
  1121.  
  1122. 2.7  Using .TAP files
  1123.  
  1124.  
  1125.     The emulator uses files with the extension .TAP to hold a piece of
  1126.     'tape', with several blocks on it.  Each block is usually either a
  1127.     header or a data block; a normal file thus consists of two blocks.
  1128.     There are two modes of operation when loading and saving to disk files,
  1129.     single and multiple .TAP file mode.
  1130.  
  1131.     In single .TAP file mode, each block saved is appended to the end of
  1132.     the .TAP file, like what would happen if you were actually saving to
  1133.     tape.  In the same way, when loading in single file mode, each time the
  1134.     ROM wants to load a block, it is presented the next block in the .TAP
  1135.     file.  It is handled as it would if the block was loaded from tape, so
  1136.     that if the ROM needs a header and is presented a data block, it will
  1137.     skip it.  The header will however be considered to be read.  So,
  1138.     entering LOAD "rubbish" will show all headers in the .TAP file, just as
  1139.     an actual Spectrum would show all headers on the tape if you left the
  1140.     tape running.
  1141.  
  1142.     If the last block is loaded, the file pointer is moved to the start
  1143.     again.  So a .TAP file can be considered to be an infinite tape. Single
  1144.     .TAP file mode is useful to save whole programs to disk, or for
  1145.     multi-load games that need to load in levels as you play.
  1146.  
  1147.     A sort of 'random access' file management is also useful, for instance
  1148.     when you're developing a program and need to save several pieces of
  1149.     data to disk and later load back a specific one.  This can be done in
  1150.     single .TAP file mode (by positioning the file pointer using the Browse
  1151.     function), but there's a different mode of operation that makes things
  1152.     easier: multiple .TAP file mode.  In fact, by default the emulator is
  1153.     in this mode.
  1154.  
  1155.     When the emulator is in multiple .TAP file mode, it will read all
  1156.     blocks from all .TAP files in a specified directory, one after the
  1157.     other.  When it has finished reading the last one, it will start all
  1158.     over again.
  1159.  
  1160.     When saving, the emulator will put the two blocks of a normal file, the
  1161.     header and the data block, in one .TAP file with a unique name made up
  1162.     of the printable letters of the file name and a two-digit number.  The
  1163.     name of the .TAP file is irrelevant to the emulator, but to have it
  1164.     resemble the name of the actual Spectrum file you saved is simply
  1165.     convenient.  If the Spectrum program saves a data block to tape without
  1166.     first saving a header, the .TAP file produced will contain only this
  1167.     data block, and the DOS file name will be HDRLES, with a two-digit
  1168.     number appended to make it unique.  The format of the .TAP files saved
  1169.     in multiple .TAP file mode is exactly the same as the format used in
  1170.     single .TAP file mode.
  1171.  
  1172.     You can easily string together .TAP files; for instance a number of
  1173.     .TAP files created in multiple .TAP file mode can be put into one big
  1174.     .TAP file simply by concatenating them, e.g.
  1175.  
  1176.         COPY /B FILE1.TAP + FILE2.TAP ALL.TAP.
  1177.  
  1178.     Now you know what you can do, but how to get the emulator to do it?
  1179.     That's what the final section is about: the tape menu.
  1180.  
  1181.     Press F7 to enter the tape menu.  Pressing S will select or de-select
  1182.     single file mode.  As a default, multiple .TAP file mode is selected.
  1183.     In this mode there are three other possible choices in the menu.  First
  1184.     of all, D selects a tape-file directory where the .TAP files will be
  1185.     saved into and loaded from.  A default directory can be selected by
  1186.     putting the -xs switch on the command line or in the Z80.INI file; for
  1187.     example -xs c:\spectrum\taps.
  1188.  
  1189.     The I and O options are used to select the source and destination of
  1190.     the saving and loading: the LPT port (in/out) or SoundBlaster port
  1191.     (only input) for a physical tape recorder, or 'disk' for disk files.
  1192.     Input and output are directed to disk by default if a default tape file
  1193.     directory is given by means of a switch on the command line or .INI
  1194.     file.
  1195.  
  1196.     If Single .TAP file mode is selected, different and more menu options
  1197.     appear.  With R and W, the input and output tape files can be selected.
  1198.     They may be the same.  If a specified output file already exists, you
  1199.     may choose to append to or overwrite this old file.  Saving is always
  1200.     at the end of the file; loading always starts at the beginning of the
  1201.     .TAP file.
  1202.  
  1203.     A useful shortcut is ALT-F7: it will automatically select single file
  1204.     mode, and prompt for an input .TAP file.
  1205.  
  1206.     With the B option - Browse - the position of the file pointer into the
  1207.     input .TAP file can be changed.  If you, for instance, type LOAD""
  1208.     instead of LOAD "" CODE, the first header is read, and you would have
  1209.     to read all other headers before trying to load the file again.  With
  1210.     the browse option you can conveniently change the file pointer.  Of
  1211.     every header (that is, every block with flag byte 0 and length exactly
  1212.     17) the name and type, and of every data block the length is shown.
  1213.  
  1214.     The option B can also be used to delete specific blocks from a .TAP
  1215.     file.  Make sure you do not only delete a data block or a header, or
  1216.     the ROM may get confused.  (Double data blocks will be skipped, but
  1217.     double headers can generate Tape Loading errors).
  1218.  
  1219.     As in multiple .TAP file mode, I and O are used to specify the source
  1220.     and destination for saving and loading.  If you enter a .TAP file name
  1221.     with R or W, this will automatically be set correctly.  You can then
  1222.     always reset the input or output back to physical i/o again, of course.
  1223.  
  1224.     Finally, in Single .TAP file mode you can use 'tape mirroring': loading
  1225.     programs from tape (in normal mode, i.e.  not using Real mode) and at
  1226.     the same time saving a copy of each block loaded into a .TAP file. This
  1227.     .TAP file can later be used to load the program again, in case
  1228.     something goes wrong.  There are two ways of mirroring: normal
  1229.     mirroring and exact mirroring.  The last one must be used only in
  1230.     exceptional cases; it will always make a copy of a block, even if it
  1231.     had a tape error (the corresponding block in the .TAP file will also
  1232.     have a tape error).  This causes ticks in leader tones to make 0-byte
  1233.     blocks, so the .TAP file may get messy.  Do not use exact mirroring if
  1234.     you don't really have to; I think normal mirroring will always work in
  1235.     practice.
  1236.  
  1237.     If you try to leave the tape menu when for instance tape mirroring is
  1238.     selected, and no output filename is given, the emulator will warn you
  1239.     and will insist that the error be corrected.  Yes, it's stubborn!
  1240.  
  1241.     One final point about multiple .TAP file mode.  If you select a
  1242.     directory that contains no .TAP files at all, and try to load from the
  1243.     directory, the emulator will reset itself to physical tape I/O.  Select
  1244.     a different directory and try again.  Note that simply putting a .TAP
  1245.     file in the directory does not reset the emulator to multiple .TAP file
  1246.     mode, as it will not look in the directory again as soon as it uses
  1247.     physical tape I/O.
  1248.  
  1249.  
  1250.  
  1251.  
  1252. 2.8  Using .VOC files
  1253.  
  1254.  
  1255.     .VOC files contain sound samples, so they can also contain the sound of
  1256.     a computer tape.  The emulator can load programs from these sound
  1257.     sample files, by keeping track of exactly how much time elapses during
  1258.     the emulation of a program, and every time the emulated Spectrum
  1259.     program reads the EAR port, supplying it with the right sample.  Via an
  1260.     intermediate file, a .OUT log file, the emulator can also SAVE and
  1261.     produce a .VOC file with the right sounds in it.
  1262.  
  1263.     In this section .VOC file playback is discussed.  For a discussion of
  1264.     how to SAVE to a .VOC file, or how to produce a .VOC file of
  1265.     Spectrum-generated music, please read section 2.18 about the OUT2VOC
  1266.     utility.
  1267.  
  1268.     Because the emulator has to keep track of the emulated time, and also
  1269.     has to do some calculation every time the EAR port is read (which a
  1270.     program does rather often when loading), the emulation speed drops
  1271.     considerably (by a factor of two, roughly) when playing back .VOC
  1272.     sample files.  So loading programs using VOC files may take longer than
  1273.     loading them directly.  On the other hand, it is not at all necessary
  1274.     to have the emulator run at 100% now, so that even slow computers can
  1275.     load turbo-saved programs, provided that they can read samples.  And on
  1276.     fast computers, the emulator can be set at the maximum speed, to load
  1277.     programs much faster than usual.
  1278.  
  1279.     Using .VOC files is sensible for instance when you have a multi level
  1280.     game, where subsequent levels are saved in a non-standard format, so
  1281.     that they cannot be stored in .TAP files.  The higher levels can be
  1282.     stored in .VOC files, and loaded when needed, without having to
  1283.     re-install the cassette player.
  1284.  
  1285.     You can take a sample with any sampler program.  The emulator supports
  1286.     most VOC block types.  It does not support compressed blocks, though;
  1287.     use full 8 bit samples.  The problem with some samplers is that they
  1288.     leave a small gap between subsequent blocks within the .VOC file.
  1289.     These gaps are usually inaudible, but do cause tape loading errors.  It
  1290.     is very important that the sample is taken without any gaps.  The
  1291.     READVOC program reads samples from the LPT tape interface or the
  1292.     SoundBlaster, and can take long continuous samples without gaps.
  1293.     Because the emulator converts the 8-bit sample to a simple High or Low
  1294.     value, READVOC also uses only two values for the signal height.  This
  1295.     results in highly compressible .VOC files; compression factors of about
  1296.     25 are no exception.
  1297.  
  1298.     READVOC is good at taking samples from the LPT tape interface, but it
  1299.     performs worse when used to take samples from sound cards.  You'll be
  1300.     better off using samplers provided with the card.
  1301.  
  1302.     It is also possible to convert .TAP files to .VOC files, with the
  1303.     utility TAP2VOC.  This was useful to test the .VOC playback feature,
  1304.     and also makes it possible to write .TAP files back to tape using a
  1305.     sample player.
  1306.  
  1307.     To play back a VOC file, press F7 to go to the tape menu, and press P
  1308.     to select the VOC file playback menu, and enter the name of the VOC
  1309.     file to be played. The VOC file is now in stand-by. Just for
  1310.     convenience, the emulator starts playing back the VOC file as soon as
  1311.     the ROM loading routine is hit; that is, as soon as you type LOAD ""
  1312.     and ENTER.  The emulator will now play the VOC file to the end
  1313.     (irrespective of what the emulated Spectrum program is doing with the
  1314.     sound supplied to the EAR port!).  When the end is reached, a window
  1315.     will pop up, and the emulator switches back to normal emulation mode.
  1316.  
  1317.     It is possible to pause the play-back at any time.  Do not do this
  1318.     while loading, since it will immediately result in a tape loading
  1319.     error.  It is also possible to start play-back without LOAD "", which
  1320.     is necessary for instance when the VOC file consists of a turbo-saved
  1321.     block.
  1322.  
  1323.     And finally, it is possible to wind and re-wind the VOC file, as if it
  1324.     were a tape.  The position is displayed in minutes, seconds and
  1325.     hundreds of seconds.
  1326.  
  1327.     Starting the emulator by "z80 -tv file.voc" will play that .VOC file to
  1328.     the EAR input as soon as the emulator starts.  It makes sense also to
  1329.     load a .Z80 snapshot file from the command line.  To make a snapshot
  1330.     file that starts loading right away, type LOAD "" <ENTER>, press F6
  1331.     (real mode), B (back to normal mode), F2 (save snapshot) and save it.
  1332.  
  1333.  
  1334.  
  1335.  
  1336. 2.9  Multi-load games
  1337.  
  1338.  
  1339.     Some games have several levels saved on the tape, to be loaded when a
  1340.     previous level is completed.  There are several ways to handle these
  1341.     programs.
  1342.  
  1343.     First, simply playing it, and loading next levels using a real
  1344.     tape-recorder seems a good solution.
  1345.  
  1346.     If the data blocks in which the level data is saved are written to tape
  1347.     in the standard format, you can convert them to .TAP files.  It is most
  1348.     likely that the program uses the usual ROM routine to load the blocks,
  1349.     and this routine is trapped by the emulator, so that instead of loading
  1350.     from tape, the blocks can be loaded from these .TAP files.  To convert
  1351.     the blocks to .TAP file, use a standard tape-to-tape copy program and,
  1352.     in the Tape menu (F7), specify that tape output should go to some file.
  1353.     If the blocks are just code blocks with header, simply enabling the
  1354.     Tape Mirroring option and loading the blocks at 16384 (ignore the
  1355.     crashes that most probably result; just reset the emulator and
  1356.     continue) will do the trick.  If the blocks are headerless, then go to
  1357.     the SamRam, press NMI (F5), D for Disassembler, and L:4000 (with tape
  1358.     mirroring enabled) to load and mirror each block.  Here also, ignore
  1359.     possible crashes which result if the block is too long.
  1360.  
  1361.     A general method is to store the level data blocks in .VOC sample
  1362.     files.  These files are huge, lengths of several megabytes are common,
  1363.     but they can be compressed very tightly (if you used READVOC or READSB
  1364.     to make them).  Then, if you need a block, simply shell to DOS,
  1365.     decompress it, and load it.
  1366.  
  1367.     Finally, if you want to hack into the program, you can also try to find
  1368.     the routine that is responsible for the loading of a level.  At the
  1369.     appropriate point, enter an ED FB instruction, with A containing the
  1370.     level number, and HL the address at which the block is to be loaded.
  1371.     The emulator will then try to load the data.  If loading failed, the
  1372.     carry flag is toggled; it is untouched if the data was loaded
  1373.     successfully.
  1374.  
  1375.     The level data can be stored in a .SLT file (Super Loader Trap file),
  1376.     which contains a snapshot and can contain data for several levels.  If
  1377.     the current program was not loaded from a .SLT file, the emulator will
  1378.     look for files with the .DAT extension.  The name is made from the
  1379.     snapshot last loaded, with the required level number appended in
  1380.     decimal; letters are dropped from the file name if necessary to make
  1381.     them at most 8 characters long. If the file is not found, the user is
  1382.     informed of the level number, and given the opportunity to specify a
  1383.     name.
  1384.  
  1385.     .SLT files can be produced using the ADDDAT utility.  See also section
  1386.     5.9, file formats, for more information.
  1387.  
  1388.     This ED FB feature first appeared in XZX 0.5.2, and was devised by
  1389.     Russell Marks.  It is now supported by many other emulators as well.
  1390.  
  1391.  
  1392.  
  1393.  
  1394. 2.10  Using the microdrive
  1395.  
  1396.  
  1397.     Compared to the tape, this is really simple.  Cartridges are emulated
  1398.     by files of 137923 bytes.  These files have the extension .MDR, and can
  1399.     contain up to 126K of data.  The emulator emulates 8 microdrives, the
  1400.     maximum amount the Interface I software can handle, and each of these
  1401.     cartridge files can be inserted in any of the 8 microdrives.  (Do not
  1402.     insert one file into more than one microdrive; this will cause problems
  1403.     with the buffering done by the emulator as well as the Interface I, and
  1404.     might result in data loss).
  1405.  
  1406.     Press F8 to enter the microdrive menu.  Press 1 to 8 to select a
  1407.     microdrive, and I to insert a microdrive cartridge.  You can select an
  1408.     existing one, or type a new name.  If the cartridge file isn't found,
  1409.     the emulator asks whether it should create it.  When created, you'll
  1410.     have to format it first; if you don't, you'll get a 'microdrive not
  1411.     present' error when you try to read it, just as happens with real
  1412.     unformatted cartridges.  To format a cartridge, type
  1413.  
  1414.         FORMAT "m";1;"name"
  1415.  
  1416.     After this the cartridge should have 126K of free space.
  1417.  
  1418.     The cartridge can be write protected; see the menu option in the F8
  1419.     menu.  This is a characteristic of the cartridge, and the write protect
  1420.     tab information is therefore stored in the cartridge file.
  1421.  
  1422.     As on the real Spectrum, you'll have to be careful with OUT's if a
  1423.     cartridge is inserted.  Try OUT 239,0 (on a real Spectrum, this turns
  1424.     on the microdrive motor) and wait a few seconds; most of your data will
  1425.     be lost!  You can stop the microdrive motor by typing STOP (or, more
  1426.     generally, generate an error).
  1427.  
  1428.     The microdrives are emulated at IN/OUT level.  This means that every
  1429.     utility or program that uses microdrives ought to work on the emulator.
  1430.     Most utilities use hook codes, and these will certainly work.
  1431.  
  1432.     The GAP line is emulated; this signal is activated if the interface I
  1433.     senses a piece of tape with no data on it.  If the checksum of the
  1434.     first header block of a microdrive header or data block is not correct,
  1435.     that block is considered to be a GAP.  This will only happen if some
  1436.     utility writes a bad block to microdrive deliberately, if the file is
  1437.     newly created and unformatted, or when you type OUT 239,0.
  1438.  
  1439.     To try the microdrive, load a Spectrum program, switch to Spectrum
  1440.     48K+If.1 mode if necessary, and turn on Multiface 128 emulation.  Press
  1441.     F8, I(nsert cartridge), enter some file name and create an unformatted
  1442.     cartridge, return to the Spectrum and press F5 (NMI), S(ave), enter
  1443.     some name, choose M(icrodrive), choose F(ormat) and wait a few seconds,
  1444.     then choose S(ave).  Then reset the Spectrum, and type LOAD
  1445.     *"m";1;"name" to re-load the snapshot you just made.
  1446.  
  1447.     Alternatively, switch to SamRam mode, make sure a formatted cartridge
  1448.     is present, press F5, S, M, S, name, and press ENTER twice to have the
  1449.     SamRam save a snapshot to microdrive.  This snapshot can only be loaded
  1450.     in SamRam mode.
  1451.  
  1452.  
  1453.  
  1454.  
  1455. 2.11  Using the DISCiPLE and Plus D interfaces
  1456.  
  1457.  
  1458.     For an explanation of the commands of the DISCiPLE and Plus D
  1459.     interfaces, see the relevant sections in chapter 4.
  1460.  
  1461.     The ROM of the DISCiPLE is supplied with the emulator, together with
  1462.     two version of the D.O.S. pre-loaded in RAM.  The ROM of the Plus D
  1463.     interface is not supplied, for copyright reasons.  The emulator will
  1464.     only emulate a Plus D interface if it can find a file PLUSDROM.BIN in
  1465.     the emulator's own directory.  If you have a Plus D yourself, you can
  1466.     transfer the ROM in the following way.  Load the operating system from
  1467.     a Plus D system diskette, and save the entire ROM, together with the
  1468.     operating system, to disk by entering SAVE d1"rom" CODE 0,16384.  Then,
  1469.     start the emulator and choose hardware mode Spectrum 48K + Disciple
  1470.     (not Plus D of course), then type LOAD d1"rom" CODE 32768 to load the
  1471.     rom at address 32768.  Then type
  1472.  
  1473.         POKE 48623,0
  1474.  
  1475.     to reset the 'open file' counter; failing to do so will result in data
  1476.     being overwritten when you use the Plus D snapshot feature as the Plus
  1477.     D system will not build up a used-sector-bitmap if this counter is
  1478.     non-zero.  You can check that this counter is 1 by typing PRINT PEEK
  1479.     48623; this one open file is the file "rom" itself.
  1480.  
  1481.     Finally, press F10, X, S for Save Data block, set start address and
  1482.     length to 32768 and 16384 (decimal) respectively, and save the ROM by
  1483.     the name PLUSDROM.BIN.  If you re-start the emulator now, it will
  1484.     emulate the Plus D too.
  1485.  
  1486.     (Aside: to use your own version of the DISCiPLE rom, proceed as above,
  1487.     but type
  1488.  
  1489.         POKE 40431,0
  1490.  
  1491.     Note that for this, the base of DISCiPLE's system variables must be
  1492.     #0298 = 664 decimal.  If it is different, change above address
  1493.     (corresponding to location #1DEF but displaced by #8000 bytes, i.e.
  1494.     relative position 6999 decimal).  Then use DEBUG or any flexible
  1495.     file cut-and-paste utility to put the 16K file in the correct position
  1496.     in the ROMS.BIN file; see file TECHINFO.DOC for the exact position.
  1497.     End of aside.)
  1498.  
  1499.     The emulation of the DISCiPLE or Plus D interfaces in turned on simply
  1500.     by choosing the right hardware mode in the F9 menu.  Changing the
  1501.     M.G.T. type will result in a Spectrum reset (unless you change with
  1502.     CTRL-ENTER), since a different ROM is switched in.
  1503.  
  1504.     By default, disks 1 and 2 refer to drives A: and B: respectively, but
  1505.     this can be changed in the F8 menu.
  1506.  
  1507.  
  1508.  
  1509.  
  1510. 2.12  Using the Multiface 128
  1511.  
  1512.  
  1513.     The following is an excerpt from the original Multiface 128
  1514.     documentation:
  1515.  
  1516.     MULTIFACE is a registered trademark af RORANTIC ROBOT.  Multiface 128
  1517.     is a true multi-purpose interface with
  1518.  
  1519.     1) fully universal and 100% automatic back-up facility for tape,
  1520.        microdrive, Discovery, Plus D or Disciple (although the Discovery is
  1521.        not emulated, so that that feature is not usable),
  1522.     2) 8K RAM extension - suitable for GENIE, LIFEGUARD, or as a buffer,
  1523.     3) MULTI TOOLKIT to study/modify/develop programs, POKE infinite lives,
  1524.        etc.
  1525.  
  1526.     Multiface 128 works on the Spectrum 48/128.  It can be used any time in
  1527.     any mode; it is immaterial what is inside the Spectrum at that moment
  1528.     or how or from what source (tape, disk, cartridge) it has been loaded
  1529.     (or typed in, etc.).  Multiface does not save programs, but computer
  1530.     contents (compressed RAM image).  Upon returning from the M128 or upon
  1531.     re-loading, the programs continue as if never frozen.  To use the M128:
  1532.  
  1533.     1) Push the NMI key (F5)
  1534.     2) Select the required option from the menu
  1535.  
  1536.     The MAIN MENU options are:
  1537.  
  1538.     Exit: to abandon the Multiface and exit to BASIC (provided BASIC is
  1539.       present).  By using exit, you come out of the Multiface entirely.
  1540.       All efforts are made to preserve the current program in the Spectrum
  1541.       intact.  The main condition is the existence of standard system
  1542.       variables - without these the Spectrum crashes.  A successful exit
  1543.       gives you full access to the program.  To restart it, if needed, you
  1544.       must know the starting line or address.  Exit is impossible in the
  1545.       128K mode when the edit ROM is paged and Spectrum ROM is off; in such
  1546.       cases it does not appear on the menu at all.  All in all, you can
  1547.       only exit to BASIC if it exists - it is like jumping into a pool: a
  1548.       joy if it's full of water, a crash if there is none.
  1549.  
  1550.     Return: to continue the program.
  1551.  
  1552.     Save: to proceed to the SAVE routines:
  1553.       a) input the name of the program.  Up to 9 characters (or just press
  1554.          ENTER to the input RUN automatically as a default)
  1555.       b) save to: Tape, Microdrive, Opus [does nothing], Disciple (use D
  1556.          for Plus D too).  You can save the entire program (including the
  1557.          screen), or the screen only.  Programs are compressed to take the
  1558.          minimal room possible and to load faster.  Screens saved on their
  1559.          own are left intact as standard Spectrum screens.
  1560.       c) Format microdrive cartridges.  Cartridges are automatically named
  1561.          after the programs to be saved.
  1562.  
  1563.     Tool: to access the MULTI TOOLKIT routines.
  1564.       quit - to return to the main menu
  1565.       Enter - to PEEK and scroll through addresses or to POKE
  1566.       Space - to allow you to type in a new address
  1567.       hex - to toggle between hexadecimal and decimal display format
  1568.       reg - to point to the Z80 registers as they were when the program was
  1569.         frozen
  1570.       window - to open a window with full on-screen editing using the
  1571.         cursor keys.  The flashing window address corresponds to the
  1572.         address in the bottom edit line.  The window display is by default
  1573.         in hex, but you can change it to
  1574.       text - to see the 128 bytes in the window as ASCII text.
  1575.       select - to inspect RAM banks 0-7 in 128K mode.  Press s + the bank
  1576.         number
  1577.  
  1578.     Print - to dump screen to printer.  For printer interfaces using COPY
  1579.       command.  You can POKE address 8200 (decimal) with the following
  1580.       values, if you wish to
  1581.       113 to turn the line feed on (cr+lf)
  1582.       112 to turn the line feed off (cr)
  1583.       17 to dump screen as text with the line feed on
  1584.       16 to dump screen as text with the line feed off
  1585.  
  1586.     Jump - not to return, but jump to another address.  Strictly for
  1587.       machine code users only.  Enter the address to jump at 8192/3
  1588.       (low/hi).  You can jump to Spectrum ROM/RAM and to M128 8K RAM.  As
  1589.       the M128 overshadows the ZX ROM (8192-16383), address 8194 determines
  1590.       the paging status: if it is 0, the M128 RAM remains paged, 1 pages
  1591.       out the RAM and any other value disables the jump command completely.
  1592.       [Note: if it is 0, also the M128 ROM (0-8191) remains paged.]
  1593.  
  1594.       You can jump from the main menu, and you can also pre-program M128 to
  1595.       jump directly upon NMI (F5) and by-pass the M128 ROM software
  1596.       entirely.  To program the direct jump, POKE 8192-3 with the jump
  1597.       address, and then also 8195-7 with a special identification word RUN
  1598.       (i.e. 82,85,87).  Whenever you press NMI now, you will jump to the
  1599.       predefined address and not see the M128 menu.  To return from your
  1600.       program to the program you stopped, use RST 0.  To revert back to the
  1601.       Multiface normal operation, press NMI and BREAK (shift+space)
  1602.       simultaneously.  This also cancels the code word RUN.
  1603.  
  1604.       In standard mode M128 uses 8192-11144 as a buffer (8192-13496 once
  1605.       you proceed to SAVE) and overwrites anything in there.  Using direct
  1606.       jump, you have 8257-16338 available.
  1607.  
  1608.     Clear - to clear the extra 64K RAM bank (in 128K mode only!).  You can
  1609.       clear any time, but it is only useful with 48K programs in 128K mode.
  1610.       However, you should save 48K programs in 48K mode anyway.  Also, for
  1611.       obvious reasons, clearing the banks in 128K programs is not a good
  1612.       idea.
  1613.  
  1614.  
  1615.     The actual M128 has a software on/off switch, so that it could be made
  1616.     completely invisible to programs until the NMI switch was pressed. This
  1617.     software switch is not emulated.  The M128 could be turned off by
  1618.     pressing 'O' in the main menu; this does not work on the emulator.  You
  1619.     can turn off the M128 in the Select Hardware (F9) menu.
  1620.  
  1621.     Using the extra 8K RAM - M128 has an 8K Rom containing its own
  1622.     software, and an 8K RAM used as a buffer.  You can use the 8K RAM for
  1623.     your own mcode routines or for data (but not for BASIC).  The RAM must
  1624.     be paged in machine code to be accessed: use IN A,(191) to page in, and
  1625.     IN A,(63) to page out.  The BASIC In and Out commands can not be used
  1626.     here (they work, but result in a crash).  The 8K RAM overshadows the
  1627.     Spectrum ROM and thus anything contained in the M128 RAM cannot make
  1628.     any calls to the Spectrum ROM, as they both occupy the same area. The
  1629.     M128 RAM routines should therefore be self-contained, independent of
  1630.     the Spectrum ROM.
  1631.  
  1632.     Poking infinite lives - To POKE, say 31000,0, first load the program as
  1633.     usual.  When it's loaded, press NMI (F5) and select the tool by
  1634.     pressing T.  When the toolkit menu appears, press SPACE and type 31000.
  1635.     Once you type 5 digits the cursor automatically moves to the value
  1636.     field (no need to press ENTER), so type 0 (value is 1-3 digits long)
  1637.     and this time press ENTER.  Finally press Q to quit the toolkit and R
  1638.     to return to the program.
  1639.  
  1640.  
  1641.     The Multiface 128 was designed by Romantic Robot UK Ltd, 54 Deanscroft
  1642.     Avenue, London NW9 8EN, tel. 081-200 8870.
  1643.  
  1644.  
  1645.  
  1646.  
  1647. 2.13  Using the RS232 channel
  1648.  
  1649.  
  1650.     This was the only Spectrum i/o channel that could be used in the early
  1651.     versions of the emulator.  Using .TAP files instead of the RS232
  1652.     channel is often easier, but sometimes using the RS232 channel can be
  1653.     very useful too, for instance if you've got a null-modem lead that
  1654.     connects a Spectrum with interface I to the PC you can use it to
  1655.     transfer data and programs easily.  Furthermore, the RS232 channel is
  1656.     the easiest way to let the emulator communicate with a PC printer.
  1657.  
  1658.     Several things send their output to the channel designated as 'RS232
  1659.     output channel'.  First of all the ordinary Interface I RS232 "B" and
  1660.     "T" channels.  Secondly the 128K printer "P" channel.  Thirdly, ZX
  1661.     Printer output is converted to a format appropriate for Epson or HP PCL
  1662.     printers (works for most dot matrix, and most laser/inkjet printers
  1663.     respectively) and also sent to this channel. Input from the 'RS232
  1664.     input channel' is sent to the Interface I's "B" and "T" channels.
  1665.  
  1666.     The Interface I RS232 port, the "B" or "T" channel, behave slightly
  1667.     differently.  The first, binary, channel is the raw channel.  It will
  1668.     let all data go through unchanged.  The "T" channel won't let all
  1669.     control codes through and will expand any keyword; useful for LISTing a
  1670.     program but otherwise annoying.
  1671.  
  1672.     The Spectrum 128 has its own RS232 port; it is called the "P" channel.
  1673.     Output to either the Interface I's or Spectrum 128's own RS232 port
  1674.     will all be processed as 'RS232 output'.
  1675.  
  1676.     The output to the RS232 channel can be routed to an LPT port, to a COM
  1677.     port or to a file on disk.  Input can come from either a file or a COM
  1678.     port.
  1679.  
  1680.     If you want to use the RS232 channel for printing using LPRINT and
  1681.     LLIST (shorthand for PRINT #3 and LIST #3), be sure to open that
  1682.     channel for output to RS232; by default it sends its output to the ZX
  1683.     Printer, which is not supported.  You can open the channel by typing
  1684.     OPEN #3,"B" (or "T" for listings, or "P" on a Spectrum 128).
  1685.  
  1686.     Input and output are buffered.  This is important to remember when
  1687.     you're transferring files using the SAVE and LOAD *"b" commands of the
  1688.     Interface I.  If the header is missed, for instance if you try to load
  1689.     the wrong file type, re-sending the file will not directly work because
  1690.     there will still be bytes in the buffer.  You have to clear the input
  1691.     buffer before re-sending the file.  When inputting from a disk file,
  1692.     the file pointer can be reset to point to the start of the file again
  1693.     to re-read the header.
  1694.  
  1695.     When inputting from or outputting to a disk file, the read or write
  1696.     position is displayed as a byte-count.  An <EOF> sign will appear if an
  1697.     input file is read completely through to the end.
  1698.  
  1699.     The RS232 redirection options are in the Change Settings (F4) menu.
  1700.  
  1701.     When using a COM port, make sure you have initialised it before
  1702.     starting the emulator with the Dos MODE command, for instance
  1703.  
  1704.         MODE com1:96,n,8,1
  1705.  
  1706.     initialises COM1 to send and receive at 9600 baud, no parity, 8 data
  1707.     bits and 1 stop bit, the default for the Interface I.
  1708.  
  1709.     Here is how to transfer programs from a Spectrum to the PC using the
  1710.     RS232 lead.  First, you need a null-modem lead.  I myself use the
  1711.     following cable:
  1712.  
  1713.           Spectrum                                  'AT'      'PC'
  1714.           (9 pins)                                (9 pins)  (25 pins)
  1715.  
  1716.             3 TxD   ───────────────────────── RxD     2         3
  1717.  
  1718.             4 DSR   ───────────────────────── DTR     4        20
  1719.  
  1720.                                         ┌──── CTS     7         4
  1721.                                         └──── RTS     8         5
  1722.  
  1723.             7 GND   ───────────────────────── GND     5         7
  1724.  
  1725.     (so CTS and RTS have to be connected!)  This is not a full null-modem
  1726.     lead; you can only send data from the Spectrum to a PC.  If you have an
  1727.     Interface I, you can use the LOAD *"b" and SAVE *"b" commands on both
  1728.     your real Spectrum and the emulator to transfer programs and data. It's
  1729.     best to first type LOAD *"b" and then SAVE instead of the other way
  1730.     around.  If you have problems with transferring data, try to lower the
  1731.     baud rate to 4800 or 2400 baud; this sometimes helps.
  1732.  
  1733.     If you don't have an Interface I, but do have a printer interface using
  1734.     RS232 leads, then you can transfer data using LPRINT on the Spectrum
  1735.     side, and INKEY$ #3 on the emulator side.  It needs a little bit of
  1736.     programming.
  1737.  
  1738.  
  1739.  
  1740.  
  1741. 2.14  On joysticks and mice
  1742.  
  1743.  
  1744.     The emulator support several joysticks and the Microsoft mouse, to
  1745.     control several Spectrum joystick interfaces, and the AMS Mouse
  1746.     interface.  First, joysticks are discussed.
  1747.  
  1748.     As was already said in the introduction, the emulated Spectrum joystick
  1749.     (Cursor, Interface 2, Kempston or user defined) is controlled by the PC
  1750.     cursor keys and 5/0/.  on the numeric keypad and TAB as fire keys.  The
  1751.     emulated joystick can also be controlled by a mouse, or by a real
  1752.     joystick, either analogue (PC standard) or digital.
  1753.  
  1754.     The analogue joystick support is rather straightforward.  If you've got
  1755.     one, it works - it couldn't be simpler.  The digital joystick support
  1756.     is less obvious, since PC's don't support these.
  1757.  
  1758.     To use digital joysticks, Ruud Zandbergen has made a device that uses
  1759.     the two inputs of a normal analogue joystickinterface to connect a
  1760.     digital joystick to a PC.  Here's the circuit diagram:
  1761.  
  1762.  
  1763.     15 pins male  (pc)                           9 pins male (joystick)
  1764.  
  1765.  
  1766.     1+9 <─────────┬───────────┬────────────┬─────────────┬──> 7 (5V)
  1767.                  ┌┴┐         ┌┴┐          ┌┴┐           ┌┴┐
  1768.         4 x 1 kΩ │ │ ¼ Watt  │ │          │ │           │ │
  1769.                  └┬┘         └┬┘          └┬┘           └┬┘
  1770.     3   <─────────┴──> 4 (up) │            │             │
  1771.                               │            │             │
  1772.     6   <─────────────────────┴──> 3 (dwn) │             │
  1773.                                            │             │
  1774.     13  <──────────────────────────────────┴──> 1 (rght) │
  1775.                                                          │
  1776.     11  <────────────────────────────────────────────────┴──> 2 (lft)
  1777.                        ┌────────────────────┐
  1778.     2   <──────────────┤    47 Ω ¼ Watt     ├───────────────> 6 (fire)
  1779.                        └────────────────────┘
  1780.     4+5+14 <────────────────────────────────────────────────> 8 (0V)
  1781.  
  1782.  
  1783.     4+5+14 means: connect pins 4, 5 and 14.  The same applies for pins 1 and
  1784.     9.  Here's the list of ingredients:
  1785.  
  1786.         1 x 9 pins D plug, male
  1787.         1 x 15 pins D plug, male
  1788.         4 x 1kΩ , ¼ Watt resistors
  1789.         1 x 47 Ω, ¼ Watt resistor
  1790.         piece of 7-wire flatcable
  1791.  
  1792.     Everything can be fitted into the 15-pins plug. Make sure the resistors
  1793.     don't touch the other blank connections! This interface can be used for
  1794.     all usual digital joysticks, with or without auto fire (that is every
  1795.     joystick that work with a Kempston joystick interface, or that work on
  1796.     a Commodore 64/Amiga or Atari). The joysticks for the Spectrum +2/+3
  1797.     will not work, however the pin layout is easy to change.
  1798.  
  1799.     This joystick interface needs an analogue PC-joystick interface on
  1800.     which you can connect TWO analogue joysticks (on one plug!).  Most
  1801.     cards can do this, but some multi-I/O cards support only one joystick.
  1802.     Check the documentation of your I/O card to see whether your
  1803.     joystickinterface is suitable.  The soundblaster joystick interface
  1804.     works fine.
  1805.  
  1806.     A number of PC games will behave strangely when the digital joystick
  1807.     interface is connected; they run very slow or crash.  When this
  1808.     happens, remove the joystick interface (not only the joystick!).
  1809.  
  1810.     With version 3, the Spectrum joystick (Cursor, Kempston, Sinclair 2 or
  1811.     user defined) can not only be controlled by the cursor keys or a real
  1812.     joystick, but also by a mouse.  Specify -km on the command line to have
  1813.     the mouse control the joystick too.  (By default, this switch is
  1814.     already in the Z80.INI file.)
  1815.  
  1816.     Finally, the Microsoft mouse can control the AMS Mouse interface, as
  1817.     supported for example by Art Studio.  Specify -ka on the command line
  1818.     to select this option.  The mouse will not control the joystick
  1819.     anymore.  Because of I/O address clashes, the AMS Mouse does not work
  1820.     with SamRam or an M.G.T. interface enabled.  Also, since the AMS
  1821.     interface must be initialized, and the state of the AMS interface is
  1822.     not saved in the .Z80 snapshot file, it may be necessary to make the
  1823.     snapshot before the point at which the Spectrum program initializes the
  1824.     AMS interface.  The program Art Studio re-initializes the AMS interface
  1825.     regularly, however, so with this program you don't have to worry about
  1826.     it.  You still need to customize the program to use the AMS mouse of
  1827.     course, so a snapshot of Art Studio will not automatically work; you
  1828.     need to load the original from tape again, and go through the
  1829.     customization procedure.
  1830.  
  1831.  
  1832.  
  1833.  
  1834. 2.15  The utility ConvZ80
  1835.  
  1836.  
  1837.     This program converts between various snapshot formats, and it can also
  1838.     convert various tape file formats to .TAP files.  Currently it supports
  1839.     .SNA format (used in various emulators, such as JPP, Peter McGavin's
  1840.     emulator on the Amiga, and XZX), the .SP format of VGASPEC and
  1841.     SPECTRUM, the .PRG format of SpecEm, and all old .Z80 file formats.
  1842.  
  1843.     If conversion is to a .Z80 file, the old (v1.45) format will be used.
  1844.     This is still supported by the emulator, and some other programs do not
  1845.     support the new format.  Note that, because of this, ConvZ80 will not
  1846.     convert .Z80 files containing snapshots of 128K or SamRam programs.
  1847.  
  1848.     CONVZ80 recognizes what it should do by the extension of the files you
  1849.     enter on the command line; to distinguish between VGASPEC's and
  1850.     SPECTRUM's .SP formats you can use the switch -o.  If the extension
  1851.     consists of digits only, it is taken to be a ZX tape file, and if it
  1852.     contains non-digits and is none of .SP, .Z80, .SNA, .PRG or .TAP it is
  1853.     regarded as a SpecEm tape file.
  1854.  
  1855.     SpecEm can load .PRG snapshot files, but cannot save them.  However, it
  1856.     emulates the Multiface I, which can save snapshots to tape.  SpecEm
  1857.     will save these blocks as tape files to disk.  If you convert these to
  1858.     a .TAP file (in the correct order!), you can load them into Z80 and
  1859.     save the program as a .Z80 file.
  1860.  
  1861.  
  1862.  
  1863.  
  1864. 2.16  Converting file formats - the utility CONVERT
  1865.  
  1866.  
  1867.     This section is about the utility CONVERT, which can convert some of
  1868.     the Spectrum's own format into each other, and also converts some of
  1869.     the emulator's formats into others.  It is not about converting files
  1870.     from other emulators; read section 2.15 if you want to know about that.
  1871.  
  1872.     CONVERT was useful when the emulator could only communicate with
  1873.     snapshot files and the RS232 link.  It has become less useful now, with
  1874.     .TAP files and the possibility to load and save blocks directly into
  1875.     and from Spectrum memory, but it still has some useful features.
  1876.  
  1877.     It can read three types of input files: pure ASCII, pure bytes (for
  1878.     instance a .SCR screen dump), and files produced by a SAVE *"b"
  1879.     command.
  1880.  
  1881.     Output is pure bytes, ASCII with either CR (Spectrum standard) or CR/LF
  1882.     (PC standard) for line breaks, SAVE *"b" files containing a Basic or
  1883.     code file, a .PCX or a .GIF file.
  1884.  
  1885.     So what can you do? Main uses are adding LF (10 hex) bytes to a text
  1886.     file produced by the Spectrum; converting a code block into a SAVE *"b"
  1887.     to load it into the Spectrum using LOAD *"b" (and the reverse of
  1888.     course: converting a SAVE *"b" file to pure bytes), and converting a
  1889.     screen dump to .PCX or .GIF graphics files.
  1890.  
  1891.     Less useful, but possible: LISTing a program (SAVE *"b" file) to
  1892.     produce readable ASCII, and the reverse: converting an ASCII listing to
  1893.     executable Basic again.
  1894.  
  1895.     If you want to make a .PCX or a .GIF file, input should be a SAVE *"b"
  1896.     file of a screen (length 6921 bytes exactly) or a bare .SCR screendump
  1897.     (length 6912 bytes).  You can make screendumps by selecting the X-Extra
  1898.     functions menu from the main menu.
  1899.  
  1900.  
  1901.  
  1902.  
  1903. 2.17  The utilities Z802TAP, TAP2TAPE and TAP2VOC
  1904.  
  1905.  
  1906.     The SamRam has built in it some snapshot software.  Using this software
  1907.     you can save any 48K Spectrum program to tape or to a .TAP file, as is
  1908.     explained in section 3.2 below.  But the SamRam software cannot handle
  1909.     a 128K program.  The Multiface 128 can also write a snapshot to tape,
  1910.     but in some cases it is still preferrable to use TAP2TAPE, since the
  1911.     latter produces less and shorter blocks, and doesn't corrupt the screen
  1912.     as much as the Multiface code does (on Spectrums without Multiface).
  1913.  
  1914.     The utility that can convert a 128K snapshot (and 48K ones for that
  1915.     matter) to a .TAP file is called Z802TAP.  The .TAP file includes a
  1916.     basic loader, and a loading screen if you want.  Z802TAP compresses the
  1917.     blocks it writes (using a better method than used in compressing .Z80
  1918.     files) to save loading time.  If you don't want it to compress the
  1919.     blocks, for instance when you want to take a look at the ram pages of
  1920.     the Spectrum 128, specify -u when you run Z802TAP.  You can load the
  1921.     converted program simply by executing
  1922.  
  1923.         Z80 -ti tapefile
  1924.  
  1925.     and typing LOAD "" (for a 48K program) or changing the hardware mode to
  1926.     Spectrum 128 and choose 'Tape Loader' in the menu.
  1927.  
  1928.     Of course you could also use Multiface 128 or the SamRam to convert a
  1929.     snapshot to a .TAP file.
  1930.  
  1931.     The program TAP2TAPE writes .TAP files back to tape.  The program
  1932.     consists of a batch file TAP2TAPE.BAT, which executes the TAP2TAPE.Z80
  1933.     file using the emulator.  The .TAP file is written to tape exactly as
  1934.     it is, so that if a block contains a tape error, it won't load
  1935.     correctly from tape either.  If the entire .TAP file has been saved the
  1936.     emulator will start loading from tape.  At that point, press space once
  1937.     to return to DOS.
  1938.  
  1939.     The TAP2VOC program converts the tape block in a .TAP file to the
  1940.     corresponding bips and clicks.  The resulting .VOC file will be rather
  1941.     large.  It can be loaded back into the emulator, which is rather silly
  1942.     since using the original .TAP file is better in all respects, or you
  1943.     can write the program to tape using a sample player.
  1944.  
  1945.  
  1946.  
  1947.  
  1948. 2.18  The utility OUT2VOC - and how to make .OUT files
  1949.  
  1950.  
  1951.     The emulator can log OUTs to any I/O port.  These OUTs are logged in a
  1952.     .OUT file, in which is stored what was written to which port at what
  1953.     time.  These log files are used for recording sounds the emulated
  1954.     Spectrum produces.
  1955.  
  1956.     The OUTs to port FE, which controls the internal beeper, and those to
  1957.     ports BFFD and FFFD, which control the soundchip of the Spectrum 128,
  1958.     are translated into a sample file by OUT2VOC.
  1959.  
  1960.     There are a number of command line switches.  The sample frequency can
  1961.     be chosen by specifying "-f frequency" on the command line.  By default
  1962.     a sampling frequency of 10 kHz is used.
  1963.  
  1964.     Ordinarily the OUT2VOC program filters out all frequencies above half
  1965.     the sampling frequency, so that no aliasing occurs when the signal is
  1966.     stored as a sequence of samples in a .VOC sample file.  For sample
  1967.     files containing tape data, these aliasing effects are not important.
  1968.     For these sample files you can use -d to produce 'digital' sample
  1969.     files, containing only 'high' and 'low' sample values, and nothing in
  1970.     between.  These sample files can be compressed much better.
  1971.  
  1972.     By default, the OUT2VOC program listens to the EAR output only.
  1973.     Specify -m to have it listen to the MIC output (only), and -a to have
  1974.     it listen to the AY-3-8912 soundchip of the Spectrum 128.  If you
  1975.     specify for example -e -a, the program will listen to both
  1976.     corresponding channels.
  1977.  
  1978.     Usually, not all registers of the AY soundchip are updated continually.
  1979.     Some registers are initialised and left at that value.  So it may be
  1980.     necessary to supply the initial values of the soundchip registers.  Do
  1981.     this by specifying '-i file', where 'file' is the snapshot taken just
  1982.     before you started recording the OUTs.
  1983.  
  1984.     Some Spectrum programs use extremely many OUTs to produce sounds.
  1985.     Fairlight for example OUTs about 70000 times a second, thereby indeed
  1986.     producing one of the finest music I've every heard coming out of an
  1987.     ordinary Spectrum.  The OUT2VOC program takes quite some time to
  1988.     compute the .VOC file from the raw .OUT output.  Use -q for a quick
  1989.     and little less precise conversion.  The difference seems to be barely
  1990.     audible.  This switch has no effect when converting AY soundchip music.
  1991.  
  1992.     If you specify -s, silences of longer than 1 second will be truncated
  1993.     to 1 second.
  1994.  
  1995.     Finally, use -r to produce a raw sample file, without any header or
  1996.     length info.
  1997.  
  1998.     To record a sample, go to the Extra Functions menu (F10, X), and select
  1999.     O.  Select the ports you want to log (by default only FE is logged) and
  2000.     enter a name for the log file.  OUTs will be logged until you specify
  2001.     an illegal name, or press ENTER on an empty line here.
  2002.  
  2003.     To save a block of data to a .OUT file, simply type the right SAVE
  2004.     command or use any (turbo-save) program to save it to tape.  Note that
  2005.     .OUT files tend to grow fast; one bit on the tape corresponds to two
  2006.     OUTs and therefore two 5-byte entries in the .OUT file; a 48K file will
  2007.     produce a .OUT file of at least 4 Megabytes.
  2008.  
  2009.     If you give a 16 bit address for an I/O port, only OUTs to this address
  2010.     will be logged.  If you give an address smaller than 100 hex, all
  2011.     addresses whose low byte equal this number are logged.  Note that it
  2012.     is not possible to log all OUTs to, say, an even port.  Although the
  2013.     MIC and EAR ports respond to all even port addresses, virtually no
  2014.     program uses a port different from FE, so this will be no problem in
  2015.     practice.
  2016.  
  2017.     Note that whereas the 'official' addresses of the register and
  2018.     value-port of the AY soundchip are FFFD and BFFD respectively, some
  2019.     programs use other ports that work too.  One particular program uses
  2020.     BEFD, heaven knows why.  For these programs, specify FD (or 00FD) as
  2021.     OUT port to log; this will ensure that all OUTs to any address with low
  2022.     byte FD is logged (which, alas, includes the much-used port 7FFD).
  2023.  
  2024.     A recent discussion on comp.sys.sinclair revealed that the AY
  2025.     conversion of OUT2VOC leaves much to be desired.  It is on my list of
  2026.     things-to-do.
  2027.  
  2028.  
  2029.  
  2030. 2.19  The utilities READVOC and READSB
  2031.  
  2032.  
  2033.     These programs can read samples from the LPT port or the SoundBlaster
  2034.     and store them in .VOC files, for later play-back to the emulator.
  2035.     This is useful when you use the SoundBlaster as input device, as direct
  2036.     loading is not very reliable then because Z80 does not filter its input
  2037.     appropriately; you can store level data of games on hard-disk and load
  2038.     them without having to play the actual tape again; thirdly, this allows
  2039.     you to try to load the program with different emulator settings easily.
  2040.  
  2041.     READVOC uses polling to read the sample.  This method does not allow
  2042.     for very high sample frequencies (even 20 kHz is too much sometimes),
  2043.     and does not work reliably in multi-tasking environments (DOS boxes of
  2044.     Windows (95) for example).  It is however the only way to take samples
  2045.     from the LPT interface, and works well under DOS.
  2046.  
  2047.     READSB has been written for taking samples from the SoundBlaster.  It
  2048.     uses DMA to read the sample, and applies a digital filtering algorithm
  2049.     for reliable loading.  It offers a number of command-line switches.
  2050.     Digital filtering is highly recommended: for programs that use the
  2051.     ordinary tape format, -n is appropriate; for turbo-save formats, use
  2052.     -d.  If neither of -d and -n are used, ordinary analogue sample files
  2053.     are produced, which will very often not load successfully when played
  2054.     back to Z80.  For low sample rates, say 10 kHz, it is a good thing to
  2055.     use two-times oversampling (switch -2).
  2056.  
  2057.     When READSB is started, it displays a signal level bar.  Set the volume
  2058.     so that a reasonable input level is reached; do not increase the volume
  2059.     too much above 50%.  Press any key to start sampling, and then 'p' to
  2060.     pause and display the signal level bar again, or any other key to save
  2061.     the sample and quit.
  2062.  
  2063.     READSB uses 0220 as default base SoundBlaster I/O address, and IRQ 7 as
  2064.     default interrupt level.  Be sure to set these to their appropriate
  2065.     values if your card is not set to these defaults.
  2066.  
  2067.     Both READVOC and READSB produce very large files.  Be sure to have
  2068.     several megabytes of free disk space available.  After sampling, these
  2069.     sample files can be compressed using ordinary compression programs to
  2070.     very small sizes.
  2071.  
  2072.  
  2073.  
  2074. 2.20  Quick overview of command line switches, and features
  2075.  
  2076.  
  2077.     In this section I will briefly explain all command line switches.  It
  2078.     is useful to at least once read this section carefully; there are a few
  2079.     small handy features that will otherwise be readily overlooked. Starred
  2080.     switches are by default put in the Z80.INI file.
  2081.  
  2082.        -h        Hercules graphics
  2083.        -c        CGA graphics
  2084.        -e        EGA graphics
  2085.        -v        VGA graphics
  2086.  
  2087.     Usually the emulator will by itself correctly determine which mode to
  2088.     use.  VGA mode is by far the best: it is the only mode in which all
  2089.     colours are correct (including the bright hues), and it is also the
  2090.     fastest mode.  Versions prior to v3.04 also had Plantronics and Extended
  2091.     Hercules as possible video modes; these are removed to save memory.
  2092.  
  2093.        -xv       400-line VGA (for some Tridents)
  2094.        -xb       Black-and-white VGA
  2095.  
  2096.     The black-and-white switch is useful on black-and-white monitors;
  2097.     sometimes those only display one component of the RGB signal instead of
  2098.     a weighted average, so that some colours become indistinguishable grey
  2099.     tones.
  2100.  
  2101.     Some Trident video adapters, as well as some others, have a bug in
  2102.     their video BIOS: they don't want to be put in 200-line mode.  To get
  2103.     around this, when -xv is specified 400-line mode is used with a double
  2104.     amount of lines.
  2105.  
  2106.        -n        Emulate Spectrum without Interface I
  2107.        -s        Emulate Spectrum with SamRam
  2108.        -1[28]    Emulate Spectrum 128 (can be used with -n)
  2109.        -xk       Emulate Multiface 128 interface  (can't be used with SamRam)
  2110.        -9        Default to M.G.T. interface instead of Interface I
  2111.        -0d       M.G.T. = DISCiPLE ROM (default)
  2112.        -0p       M.G.T. = Plus D
  2113.  
  2114.     These switches select the default start-up hardware configuration of
  2115.     the emulator.  This can all be changed in the Change Hardware menu
  2116.     under function key F9.
  2117.  
  2118.     *  -znnn.n   Emulate the Spectrum at speed nnn.n%
  2119.  
  2120.     The most sensible setting for this is -z100.  By default this is done
  2121.     in the Z80.INI file.
  2122.  
  2123.        -xx       Hi-resolution colour emulation
  2124.  
  2125.     This selects hi-res colour emulation by default, so that border effects
  2126.     and hi-res colour effects are visible.  This setting can be changed in
  2127.     the F4 menu.
  2128.  
  2129.        -r        Emulate the R register
  2130.  
  2131.     This is usually necessary in turbo loaders and otherwise protected
  2132.     programs, since they almost invariably use the R register to decode
  2133.     things.  The R register has to be updated every instruction, so that
  2134.     enabling the emulation of it reduces the emulation speed considerably,
  2135.     by some 30%.  Don't do it unless it proves to be necessary.  I don't
  2136.     know of any program that uses it on the run.  If the R register is not
  2137.     emulated, the R register acts as a random generator.
  2138.  
  2139.     *  -l        Better (but slower) LDIR/LDDR emulation
  2140.  
  2141.     Normally a 8086 MOVSB is used to emulate an LDIR or LDDR.  This is a
  2142.     fast instruction.  Programs that use them a lot, most notably Jetset
  2143.     Willy and Manic Miner, run very fast.  On slow computers these programs
  2144.     are the only ones that are really playable.  On fast computers they run
  2145.     much too fast, so it is a wise thing to use -l on fast computers.
  2146.     Secondly, without -l the LDIR instruction is not emulated correctly
  2147.     when it overwrites itself; with -l it is.
  2148.  
  2149.        -yl, -yh  Low, high video synchronization mode
  2150.  
  2151.     These switches control the phase between the 50 Hz interrupt and the
  2152.     screen refresh.  Some programs need a different setting in order to
  2153.     remove flickering of moving characters.  Enabling hi-resolution colour
  2154.     emulation also eliminates these problems.
  2155.  
  2156.        -2        Emulate an Issue-2 Spectrum
  2157.  
  2158.     Make the EAR line 1 when there's no signal, instead of 0 as it is on
  2159.     Issue 3 Spectrum's.  Some old programs need it (Spinads for example).
  2160.  
  2161.        -d        Double interrupt frequency (100 Hz)
  2162.  
  2163.     On slow computers this may help to get the keyboard to respond better.
  2164.  
  2165.        -aN       Redirect Spectrum RS232 output to LPTn
  2166.        -oN       Redirect Spectrum RS232 output to COMn
  2167.        -uF       Redirect file F to Spectrum RS232 input
  2168.        -iN       Redirect COMn to Spectrum RS232 input
  2169.        -wF       Redirect Spectrum RS232 output to file F
  2170.  
  2171.     All output to, and reading from, the Interface I's RS232 channel
  2172.     (channels "b" and "t"), the 128K printer channel (channel "p") will be
  2173.     sent to, respectively read from, the appropriate device.  Furthermore,
  2174.     output to the ZX Printer will be converted in a format suited for Epson
  2175.     matrix printers or HP Laserjet printers and also be sent to the 'RS232
  2176.     output' device or file.
  2177.  
  2178.        -g        No sound
  2179.        -xa       Do NOT use AdLib for 128 sound
  2180.        -xc       Use SoundBlaster CMS chips for noise
  2181.        -xi       Do NOT use internal PC speaker for '128 sound
  2182.  
  2183.     If no AdLib compatible card is detected, 128K sound output will be
  2184.     sent, as far as is possible, to the internal PC speaker.  Use -xa to
  2185.     hear 128K sound through the PC speaker when there is an AdLib card
  2186.     present.
  2187.  
  2188.     Without CMS chips, the 128K soundchip's noise cannot be faithfully
  2189.     reproduced.  If you have CMS chips installed, use -xc to use them.  If
  2190.     the SoundBlaster is on a different base address than 0220, use -xq to
  2191.     select it.
  2192.  
  2193.     *  -km       Use MS Mouse to control Spectrum joystick
  2194.        -ka       Emulate Spectrum AMS mouse interface controlled by MS Mouse
  2195.        -kz       Use digital Zandbergen joystick
  2196.        -kk       Do not look for analogue or Zandbergen joystick
  2197.        -k1       Do not use 2nd analogue joystick as Sinclair 1 (1,2,3,4,5)
  2198.        -k2       Use 2nd joystick as Sinclair 1 always
  2199.  
  2200.     The emulated joystick (Cursor, Kempston, Sinclair 2 or user defined) is
  2201.     controlled by the arrow keys and TAB, 5, INS (0) on the PC keyboard,
  2202.     and optionally also by a digital joystick, and analogue IBM joystick or
  2203.     a mouse.  Use -kk if the emulator erroneously detects either joystick.
  2204.     If -ka is specified, the PC mouse controls the emulated AMS mouse
  2205.     interface.  Because of I/O address clashes, this only works with SamRam
  2206.     and the M.G.T. interfaces disabled.  The AMS mouse is supported by e.g.
  2207.     Art Studio.
  2208.  
  2209.     A second analogue joystick will, when present, always be attached to
  2210.     keys 1 to 5, the Sinclair 1 joystick keys.  If neither -k1 nor -k2 is
  2211.     given, the emulator will look if the second joystick is in an
  2212.     acceptable neutral position (i.e. is attached) and if so will use it.
  2213.     This will usually work.  If it incorrectly recognizes the joystick use
  2214.     -k1.  If it doesn't recognize a joystick while it is connected, use
  2215.     -k2.
  2216.  
  2217.        -jc       Emulate Cursor joystick (default)
  2218.        -jk       Emulate Kempston joystick
  2219.        -j2       Emulate Sinclair joystick 2 (keys 6,7,8,9 and 0)
  2220.        -ju<lf><rt><up><dn><fire>  User defined joystick
  2221.  
  2222.     Also quite clear I think.  For instance, -juipqzm makes the joystick
  2223.     control the i,p,q,z and m keys, for instance to play those lovely
  2224.     Horace games.  Special characters are [ for shift, ] for symbol shift,
  2225.     / for enter and \ for space.
  2226.  
  2227.     *  -xs       Default to shifted cursor keys (NumLock) in '128 mode
  2228.  
  2229.     By default, the PC arrow keys control the cursor keys 5,6,7,8 and 0 of
  2230.     the Spectrum.  The Spectrum 128 had its arrow keys press the cursor
  2231.     keys plus shift, and the menu bar of the reset screen of the '128 only
  2232.     responds to shift+cursor key.
  2233.  
  2234.        -bN       Use LPTn for tape I/O
  2235.        -xo       Use SoundBlaster's A/D Converter for tape input
  2236.        -xq adr   Set base IO address for SoundBlaster (default 0220)
  2237.  
  2238.     Either the LPT tape interface of the SoundBlaster is used for tape
  2239.     input.  Only the LPT tape interface can be used for tape (MIC) output.
  2240.  
  2241.        -tv F     Play .VOC file F to 'ear' input
  2242.        -m N F    Insert cartridge file F{.MDR} into microdrive N
  2243.        -xm D     Select default directory D for .MDR files
  2244.        -td D     Select directory D for Multiple .TAP File mode
  2245.        -ts D     Specify default directory for Single .TAP File mode
  2246.        -ti F     Use F{.TAP} as tape input
  2247.        -to F     Use F{.TAP} as tape output (if exists, append)
  2248.        -tm       Mirror tape input to disk (Do also specify output file!)
  2249.        -te       Mirror tape input to disk in EXACT mode
  2250.        -tw       Don't wrap load pointer of tapefile at end
  2251.        -tp       Pause after loading .TAP block
  2252.  
  2253.     All quite clear I think.  If -tv is used, the VOC file starts playing
  2254.     immediately, so be sure there's an appropriate snapshot running to do
  2255.     something with the signal.  -tw makes the emulator load from physical
  2256.     tape when a .TAP file has been read to the end, instead of starting
  2257.     again from the beginning.  It is used in Tap2Tape.
  2258.  
  2259.        -xl N     Select LPTn for ZX-Printer output
  2260.        -xj       'Off-line=wait' instead of 'Off-line=No ZX Printer'
  2261.        -0e       Epson printer (for ZX PRINTER & M.G.T.)
  2262.        -0h       HP PCL printer (for ZX PRINTER & M.G.T.)
  2263.        -0f N     Issue a Form Feed every N ZX Printer lines when printing
  2264.                  to a HP PCL compatible printer
  2265.  
  2266.     Output to the ZX Printer will be converted into graphic data in Epson
  2267.     (most matrix printers) or HP PCL (most inkjet and laser printers)
  2268.     format.  Use -0e or -0h to select which format to use; default is Epson
  2269.     format (defaulted in Z80.INI).  Also, this selects the default DISCiPLE
  2270.     ROM to be used; the two ROMs have different screen dump routines
  2271.     pre-loaded.  If you're using a Laser printer, use -0f 103 to have Z80
  2272.     eject the page once in a while.  103 lines approximate one sheet A4.
  2273.     Select the LPT port to print the data to with -xl; default is LPT1.
  2274.  
  2275.     If the printer to which ZX Printer output is sent is absent, busy or
  2276.     off-line, the emulator tells the Spectrum program that the ZX Printer
  2277.     is not attached.  If you want the Spectrum program to wait in case of
  2278.     an off-line or busy printer, then put -xj in the Z80.INI file.  This
  2279.     switch is not defaulted because printers sometimes say they're merely
  2280.     busy or off-line when in fact they are not there at all.  Besides, some
  2281.     Spectrum programs do a COPY without asking, and with this switch the
  2282.     program would lock up (as versions 3.00 to 3.02 did; in v3.03 and above
  2283.     you can BREAK into such a loop).
  2284.  
  2285.        -0i       Disable Disciple interrupt
  2286.  
  2287.     Normally the Disciple and Plus D have their own interrupt routine being
  2288.     executed 50 times a second.  Because this involves many page swaps,
  2289.     this is quite slow on the emulator.  Since the interrupt is not really
  2290.     necessary anyway, it is reduced to once every two seconds.  On some
  2291.     computers this may still be too much, in which case -0i completely
  2292.     disables the Disciple and Plus D interrupts.  Do not try this in
  2293.     Unidos!  (which is not emulated [yet].)
  2294.  
  2295.        -xp D     Select default directory D for .Z80 snapshot files
  2296.  
  2297.     Clear.
  2298.  
  2299.        -xz       Assume AZERTY keyboard layout
  2300.  
  2301.     Assumes the Belgian and French AZERTY keyboard layout.
  2302.  
  2303.        -xr F     Use file F as standard Spectrum rom
  2304.  
  2305.     The ROM will be used in 48K modes only, and must be exactly 16K long.
  2306.  
  2307.        -xt       Use as little memory as possible with full functionality
  2308.        -xu       Use as little memory as possible; disable HRC emulation
  2309.  
  2310.     With -xt, all unnecessary buffers used for efficiency purposes only are
  2311.     reduced to minimum size.  Saves 47K, but can make all the difference
  2312.     sometimes.  With -xu, 83K is saved, but Hi Resolution Colour emulation
  2313.     won't work anymore.
  2314.  
  2315.        -tx       Do not display tape info window when loading or saving
  2316.        -00       Do not show intro screen, and don't pause at startup
  2317.  
  2318.     Some people seem to really hate either, or even both.  Don't know why.
  2319.     For better annoyance, -00 only works in the registered version.  Hehe.
  2320.  
  2321.        -xe       Do not use expanded memory
  2322.  
  2323.     Specifying this switch will result in the emulator using 240K more base
  2324.     memory (making a grand total of 564K).  Furthermore, all page swapping
  2325.     will be much slower, so especially the 128K emulation gets verrry slow.
  2326.  
  2327.        -xg       Log all outs to FE in OUT log file
  2328.        -xy       Dump trace of program in .OUT file
  2329.  
  2330.     By default, OUTs to port #FE that do not change the state of either MIC
  2331.     or EAR are not saved to the log file, to save disk space.  If, for some
  2332.     reason, you want all OUTs to be logged, -xg will do the trick.  The -xy
  2333.     option can be used for producing a somewhat crude trace; see section
  2334.     5.9 on the .OUT format for more details.
  2335.  
  2336.        -0m F     Build map of opcode locations in file F
  2337.  
  2338.     When this option is specified, Z80 keeps a map of the 65536 address
  2339.     locations in memory, and tags the address of each instruction that is
  2340.     emulated.  When the emulator is shut down, this map is written to disk
  2341.     as a 8192 byte file.  See section 5.9 of TECHINFO.DOC for an
  2342.     explanation of the file format, and remarks on how to use this feature.
  2343.  
  2344.        -xw       Run in Windows compatibility mode
  2345.  
  2346.     In this mode, the timer is not re-programmed.  The emulator counts T
  2347.     states to see when an interrupt has to be generated (so emulation will
  2348.     be slower).  In a Windows (3.1 or 95) DOS box, using -xw will turn
  2349.     Windows compatibility mode off (as Z80 is aware of Windows and has
  2350.     turned this switch on itself in that case) and the emulator will
  2351.     usually hang.  There is probably never a need to use this switch.
  2352.  
  2353.        -kxABCD   Press key #CD for scancode #AB.
  2354.  
  2355.     This can be used to re-map the keyboard, for instance if your C key is
  2356.     broken, you can re-map it to F11, or any other key for that matter.
  2357.     Combinations are hard-coded, so that a key pressing , also presses <
  2358.     when shifted.  The scan code is between #01 (ESC) and #58 (F12); a full
  2359.     list can be found in many places.  The format of the key byte is
  2360.     explained in section 2.3.
  2361.  
  2362.        -xf       Switch full 16K of Interface I ROM
  2363.  
  2364.     Useless.
  2365.  
  2366.  
  2367.  
  2368.  
  2369. 2.21  Miscellaneous remarks
  2370.  
  2371.  
  2372.     1. Problems at the Rom/Ram boundary
  2373.  
  2374.     There are a few Spectrum programs that have an odd stack pointer, and
  2375.     run over the ram/rom boundary, for instance Deep Strike, and Elite.
  2376.     This crashed version 1.45 of the emulator; the problem was circumvented
  2377.     somewhat in version 2.01, and has been removed in version 3: in most
  2378.     cases, a word read from or written to FFFF will be read or written as
  2379.     two bytes.  You can check this by typing CLEAR 65535: POKE 65535,0:
  2380.     RETURN in BASIC; this will lock up version 1.45 of the emulator, it
  2381.     will lock up version 2.01 if the 80386 is in virtual mode, and it will
  2382.     only crash the emulated Spectrum (as it should) on version 3.
  2383.  
  2384.     The check on FFFF is not done at every potentially problematic op-code,
  2385.     because this would make the emulator noticeably slower.  It is
  2386.     therefore still possible to 'hang' the emulator.  Not going to tell you
  2387.     how, though.  All existing programs seem to work okay now.
  2388.  
  2389.  
  2390.     2. Critical timings
  2391.  
  2392.     A few programs (the only examples known to me are Fireman and Thing,
  2393.     but there are more) are quite sensitive to the relative actual
  2394.     execution speed of emulated Z80 instructions, and crash if it isn't
  2395.     right.  They rely on this-or-that amount of instructions to be executed
  2396.     between interrupts.  If you slow down the emulator, these program will
  2397.     run fine, because then individual instructions are more carefully
  2398.     timed.  When running in Windows compatibility mode, loading .VOC files
  2399.     or when the Hi-Res Colour emulation is switched on, these problems
  2400.     disappear completely as the emulator is then counting off the exact
  2401.     number of T states to elapse between interrupts.
  2402.  
  2403.  
  2404.     3. Shifted cursor keys
  2405.  
  2406.     It may be annoying to have to press Num-Lock every time you use the
  2407.     Spectrum 128 (because otherwise you'll have to use Shift with the
  2408.     cursor keys to move the menu bar).  To make the emulator press shift by
  2409.     default every time you use the PC cursor keys in '128 mode, use the
  2410.     switch -xs. If you press Num-Lock now (in '128 mode), the shift-key
  2411.     won't be pressed.  The 48K modes are not affected by this switch.
  2412.  
  2413.  
  2414.     4. Running non-standard ROMs
  2415.  
  2416.     To run the emulator with a different rom than the standard one, you can
  2417.     specify a rom image file on the command line.  Use the switch -xr file,
  2418.     where 'file' is the name of the image file.  This file should be
  2419.     exactly 16384 bytes long.  It will of course not be used in Spectrum
  2420.     128 or SamRam mode.
  2421.  
  2422.     The emulator 'ZX' by Rindt and Bruckner comes with several roms, stored
  2423.     in their tape format.  You can convert these files to .TAP files, and
  2424.     then load them in the normal way (in RAM), and then save the 16K image
  2425.     from RAM directly.  You can also extract it from the files directly by
  2426.     using the DOS debug utility:
  2427.  
  2428.         C:\>debug rom.000       (or other rom file (of 16406 bytes))
  2429.         -m 115 L 4000,100       (move the rom down, overwrite header)
  2430.         -rcx                    (new length of exactly 16K bytes)
  2431.         CX 4016
  2432.         4000
  2433.         -n rom000.bin           (or some other name)
  2434.         -w                      (write it)
  2435.         Writing 04000 bytes
  2436.         -q                      (and quit)
  2437.  
  2438.  
  2439.     5. Printing with DISCiPLE and Plus D
  2440.  
  2441.     If, emulating a DISCiPLE/+D and by entering POKE @11,0 the parallel
  2442.     printer output has been selected, going back to a hardware mode without
  2443.     M.G.T. interface causes problems with printing to the ZX Printer, since
  2444.     the output addresses of the "p" channel have been changed by the M.G.T.
  2445.     ROM.  Use the "b" channel of the Interface I instead.  You can reset
  2446.     the channel to the ZX Printer by entering POKE @11,1 while still
  2447.     emulating the M.G.T. interface.
  2448.  
  2449.     Although by default channel #3 prints to the ZX Printer, in all
  2450.     hardware modes, if a DISCiPLE/+D is emulated output to the ZX Printer
  2451.     is ignored, as these interfaces use the ZX Printer I/O ports for their
  2452.     own purposes.
  2453.  
  2454.  
  2455.     6. Breakpoints
  2456.  
  2457.     A Breakpoint may be set in the Extra Functions menu, option B.  If it
  2458.     is set, the emulator will at the beginning of each instruction check
  2459.     whether the program counter is equal to the breakpoint address.  If
  2460.     this is the case, it notifies the user, and continues to the main menu.
  2461.     You could now save the snapshot and inspect register values using
  2462.     Z80Dump, for example.  You could change hardware mode to SamRam, and
  2463.     generate an NMI from the menu (using Extra Functions, N) to inspect the
  2464.     code around the breakpoint.
  2465.  
  2466.     Some fine points.  If a breakpoint is hit, the instruction at the
  2467.     breakpoint address is not yet executed.  It will be upon returning.  If
  2468.     you generate an NMI, and subsequently return from it, the first
  2469.     instruction that will be executed after the NMI is the instruction at
  2470.     the breakpoint; this will thus make the emulator go to the main menu
  2471.     once again.  Press ESC to continue emulating.
  2472.  
  2473.     For technical reasons, when counting T states, the time taken by the
  2474.     instruction directly preceding (in execution) the one at the breakpoint
  2475.     address is not taken into account.  When the emulator hits a
  2476.     breakpoint, the current frame will be a few T states longer.  Not that
  2477.     you'll notice, probably.  The R register is counted through properly
  2478.     (if it's emulated, that is.)
  2479.  
  2480.     If the breakpoint address happens to point to an operand instead of an
  2481.     opcode, the emulator will not respond.
  2482.  
  2483.  
  2484.  
  2485.  
  2486.  
  2487.  
  2488.  
  2489. 3.  THE SAMRAM
  2490.  
  2491.  
  2492.  
  2493.  
  2494. 3.1  Basic extensions
  2495.  
  2496.  
  2497.     The SamRam is a hardware device Johan and I built for our Spectrums. It
  2498.     consists of a 32K static RAM chip which contains a modified copy of the
  2499.     normal Basic ROM and a number of other useful routines, like a monitor
  2500.     and snapshot software.  You can compare it to a Multiface I interface,
  2501.     but it's more versatile.  Another useful feature was a simple hardware
  2502.     switch which allowed use of the shadow 32K Ram, present at 8000-FFFF in
  2503.     most Spectrums, but hardly ever actually used.
  2504.  
  2505.     For more details on the low-level hardware features of the SamRam read
  2506.     chapter 5.  In this chapter I'll explain the software features of the
  2507.     SamRam software, somewhat bombastically called the 'SamRam 32 Software
  2508.     System' or the 'Sam Operating System'.  By the way, all similarity
  2509.     between existing computers is in fact purely coincidental and has in no
  2510.     way been intended.  Really!
  2511.  
  2512.     The SamRam offers a few new Basic commands, and a lot of useful
  2513.     routines that are activated by an NMI, i.e.  by pressing F5.  First
  2514.     I'll discuss the Basic extension.
  2515.  
  2516.     Select the SamRam by starting the emulator with the -s switch, or by
  2517.     selecting it from the F9 menu.  Normal Basic functions as usual; the
  2518.     character set is different from the original one.  There are four new
  2519.     commands: *RS, *MOVE, *SAVE and *SPECTRUM, and two new functions, DEC
  2520.     and HEX, which have replaced ASN and ACS.  DEC takes a string argument
  2521.     containing a hexadecimal number, and returns the decimal value of it.
  2522.     HEX is the inverse of the DEC function, and yields a four-character
  2523.     string.
  2524.  
  2525.     *RS sends its arguments directly to the RS232 channel.  You don't have
  2526.     to open a "b" or "t" channel first.  You're right, it's of limited use.
  2527.     Example: *RS 13,10
  2528.  
  2529.     *MOVE is useful: it moves a block of memory to another place.  Example:
  2530.     *MOVE 50000,16384,6912 moves a screen-sized block from 50000 to the
  2531.     start of the screen memory.
  2532.  
  2533.     *SAVE works like *MOVE, except that it activates the shadow SamRam ROM
  2534.     before moving.  I used this command to update the shadow ROM, but on
  2535.     the emulator you can use it to move the shadow ROM to a convenient
  2536.     place in Ram where you can take a look at it, for instance by executing
  2537.     *SAVE 0,32768,16384.
  2538.  
  2539.     *SPECTRUM resets the SamRam Spectrum to a normal one.  You lose all
  2540.     data in memory.  By resetting the emulator by pressing ALT-F5, the
  2541.     SamRam is activated again.  Not very useful either.
  2542.  
  2543.     Then there's the Ramdisk, which is, like the Spectrum 128 ramdisk,
  2544.     accessed via the SAVE!, LOAD!, CAT!, ERASE! and FORMAT!.  The syntax is
  2545.     straightforward.  FORMAT! and CAT! need no parameters; ERASE! only
  2546.     needs a name.  If a file is not found, the SamRam will respond with a
  2547.     5-End of File error.  The Ramdisk has a capacity of 25K.
  2548.  
  2549.  
  2550.  
  2551.  
  2552. 3.2  The NMI software
  2553.  
  2554.  
  2555.     Select the SamRam (F9-3), and press F5.  A menu with eight icons pops
  2556.     up.  You can select each icon by moving the arrow to it (using the
  2557.     cursor keys or the Kempston joystick), and pressing '0' or fire.  The
  2558.     icons can also be selected by pressing the appropriate letter key.
  2559.  
  2560.     The eight icons are two arrows with N and E within them, a magnifying
  2561.     glass with the letters 'mc' in it (activated by pressing D), two
  2562.     screens (identified by 1 and 2), a printer (P), a cassette (S) and a
  2563.     box saying 'overig'.  The 'D' activates the monitor or disassembler;
  2564.     read section 3.3 for information on this program.
  2565.  
  2566.     Pressing N or E returns you to the Spectrum.  If you pressed N, the
  2567.     normal Spectrum rom will be selected when the NMI software returns; if
  2568.     you press E, the Rom with the Basic extensions will be selected.  Some
  2569.     games may crash if they see a different rom than the standard Spectrum
  2570.     one.
  2571.  
  2572.     Pressing 1 selects the tiny screen editor.  You can move a '+' shaped
  2573.     cursor about the screen using the cursor keys.  The following commands
  2574.     are available:
  2575.  
  2576.         H: Get the current ATTR colour from the screen at the cursor's
  2577.            current position, and store it in memory.  This colour will be
  2578.            used by the next command:
  2579.         Z: Put the colour on the screen
  2580.         G: Get a character from the screen
  2581.         P: Put the character on the screen
  2582.         R: Remove all screen data that is invisible by the ATTR colour
  2583.         L: Take a look at the bitmap below the ATTR colour codes
  2584.         T: Return to the main menu.  You can also return by pressing
  2585.            EDIT, or ESC in the emulator.
  2586.         B: Change border colour
  2587.         V: Clear the whole screen
  2588.  
  2589.     If you press 0, you can edit the current 8x8 character block at pixel
  2590.     level.  Again you control the cursor with the cursor keys.  Now 0
  2591.     toggles a pixel.  In this mode there are two commands: C clears the
  2592.     whole block, and I inverts it.  Pressing EDIT (ESC) returns you to the
  2593.     big screen again.
  2594.  
  2595.     The SamRam has two screen buffers.  Buffer 1 is used to hold the screen
  2596.     which was visible when you pressed NMI, to be able to restore it when
  2597.     returning.  This is the screen you edit with '1'.  The second screen
  2598.     buffer can be used to hold a screen for some time; it is not touched by
  2599.     the NMI software directly, and will not even be destroyed by a Reset.
  2600.     If you press '2', a menu appears with four Dutch entries:
  2601.  
  2602.         1: Scherm 1 opslaan        (Store screen 1 into buffer 2)
  2603.         2: Scherm 2 veranderen     (Edit screen 2)
  2604.         3: Schermen verwisselen    (Swap screens)
  2605.         4: Scherm 2 weghalen       (Remove screen 2)
  2606.  
  2607.     These four functions are rather obvious, I believe.
  2608.  
  2609.     Pressing 'P' pops up the printer menu.  The screendump program is
  2610.     written specifically for my printer, a Star SG-10.  It will probably
  2611.     work on some other printers, but not on most.  The output is sent to
  2612.     the RS232 channel, so you have to redirect it to an LPT output.
  2613.  
  2614.     Skipping the most interesting, 'S', for a moment, let's first discuss
  2615.     the final menu, 'O' for 'Overig', Dutch for miscellaneous.  There are
  2616.     five menu options, of which three are not useful.  The first gives a
  2617.     directory of the cartridge currently in Microdrive 1.  The last, 'E',
  2618.     returns you to Basic if this is anywhere possible: it resets some
  2619.     crucial system variables and generates a Break into Program.  You can
  2620.     use this for instance to break in a BEEP, or crack a not-so-very-well-
  2621.     protected program.  The three other options select normal or speed-
  2622.     save, and store the current setting in CMOS Ram.  Speed-save won't work
  2623.     properly on the emulator, because the speed-save routine toggles the
  2624.     upper 32K ram bank regularly, and this takes too much time on the
  2625.     emulator.  The setting is not important if you use the internal save
  2626.     routine (which will be used by default, unless you select Real Mode).
  2627.  
  2628.     Finally, the 'S' option.  This option allows you to save a snapshot to
  2629.     tape or microdrive.  I used it a lot on my real Spectrum, and it works
  2630.     just as well on the emulator.  It is very useful is you want to load a
  2631.     .Z80 program back into a real Spectrum again.  There are three
  2632.     'switches' you can toggle.  The active choice is indicated by a bright
  2633.     green box, inactive boxes are non-bright.  You have to use EGA or VGA
  2634.     to be able to see it...  The first switch lets you select whether the
  2635.     SamRam rom should be active if the program loads or not.  This is only
  2636.     meaningful is you load it back in a SamRam again.  Usually I want the
  2637.     SamRam rom to be active because I like the character set better.  The
  2638.     second switch indicates whether the SamRam should save a 'loading
  2639.     screen', which it takes from screen buffer 2.  If screen buffer 2
  2640.     contains a screen, this switch will by default be on.  Finally, the
  2641.     last switch lets you select the output media, tape or cartridge.
  2642.  
  2643.     If the program is loaded back into the SamRam, the only bytes that have
  2644.     been corrupted are four bytes down on the stack; this will virtually
  2645.     never be any problem.  If the program is loaded back to a normal
  2646.     Spectrum, these four bytes will also be corrupted, and the bottom two
  2647.     pixel lines of the screen will be filled with data.  (This is
  2648.     considerably less than any other snapshotter I've seen: for instance
  2649.     the Multiface I uses more than 35% of the screen!)
  2650.  
  2651.     The Microdrive BASIC loader needs code in the SamRam rom to start the
  2652.     program (the RANDOMIZE USR 43 calls it).  It won't be very difficult to
  2653.     write a standard BASIC loader that doesn't need this code, but I don't
  2654.     think many people desperately need it...  Anyway, using the Multiface
  2655.     128 you can write a compressed snapshot to cartridge which doesn't need
  2656.     the Multiface.
  2657.  
  2658.  
  2659.  
  2660.  
  2661. 3.3  The built-in monitor
  2662.  
  2663.  
  2664.     This is a really very convenient part of the emulator, and I use it a
  2665.     lot.  It is very MONS-like in its commands and visual appearance.  It
  2666.     cannot single-step however, but on the positive side it has some
  2667.     features MONS hasn't.  It is a part of the SamRam, and cannot therefore
  2668.     be used with Spectrum 128 programs.  If you want to take a look at a
  2669.     Spectrum 128 program, press F10, then change the hardware to SamRam
  2670.     without resetting, and finally generate an NMI in the Extra Functions
  2671.     menu.  You won't probably be able to continue to run the program, but
  2672.     at least you're able to see what it was doing.
  2673.  
  2674.     Press F5 for NMI, and D to enter the monitor/disassembler.  The first
  2675.     eight lines are the first eight instructions, starting at the Memory
  2676.     Pointer, from here on abbreviated by MP.  At first, MP is zero.  The
  2677.     disassembler knows all official instructions, and the SLL instruction.
  2678.     If another inofficial instruction (i.e.  starting with DD, FD or ED) is
  2679.     encountered, the first byte is displayed on a blank line.  The four
  2680.     lines below these display the value of PC and SP, the first nine words
  2681.     on the stack (including AF and the program counter, which have been
  2682.     pushed during NMI), and three MP-memories.  These can be used for
  2683.     temporary storage of the MP, for instance when you take a look at the
  2684.     body of a CALL, and want to return to the main procedure later.
  2685.  
  2686.     The bottom part of the screen displays 24 bytes around the memory
  2687.     pointer.
  2688.  
  2689.     Commands are one letter long; no ENTER needs to be given.  If one or
  2690.     more operands are needed, a colon will appear.  By default the monitor
  2691.     accepts hexadecimal input.  A leading $ denotes that the number is to
  2692.     be regarded as decimal.  If you give the # command, the default will
  2693.     toggle to decimal, and you need to explicitly put a # in front of a
  2694.     number which is to be interpreted as a hex number.  Also, after the #
  2695.     command all addresses on screen will be decimal.  A single character
  2696.     preceded by the " symbol evaluates to its ASCII code, and the single
  2697.     character M will evaluate to the current value of the memory pointer.
  2698.  
  2699.     The monitor commands:
  2700.  
  2701.         Q: Decrease the memory pointer by one.  You effectively shift one
  2702.            byte up.
  2703.         A: Increase the memory pointer, shifting one byte down.
  2704.         ENTER: Shift one instruction down: the memory pointer is
  2705.            increased by the length of first instruction displayed on
  2706.            screen.
  2707.         M: Change the value of the memory pointer.  For instance, M:M
  2708.            won't change it.
  2709.         P: Put.  The word operand supplied will be stored in the first MP
  2710.            memory, and the others will shift on place to the right.
  2711.            Usually, you'll want to store the memory pointer by P:M
  2712.         G: Get.  Typing G:1, G:2 or G:3 moves the value of one of the MP
  2713.            memories to the MP.
  2714.         B: Byte.  This command needs a byte operand; it will be poked
  2715.            into memory, and the memory pointer will move one up.
  2716.         I: Insert.  The same as B, except that you can poke more than one
  2717.            byte.  It continues to ask for bytes to poke until you type
  2718.            Enter on a blank line.
  2719.         #: Toggles the default number base between hexadecimal and
  2720.            decimal.
  2721.         F: Find.  You can enter up to ten bytes, which will be searched
  2722.            through memory.  Searching will stop at address 0, because
  2723.            since the search string is stored in shadow Ram, searching
  2724.            would otherwise not always terminate.  Typing Enter on a blank
  2725.            line starts the search.  Byte operands are entered as usual,
  2726.            but:
  2727.            - If a number bigger than 256 decimal is entered, it is
  2728.              treated as a word in the standard LSB/MSB format.  So, 1234
  2729.              will search for 34,12 hex in that order.  Note that 0012
  2730.              will search for 12, not 12,00.
  2731.            - A line starting with " decodes into the string of characters
  2732.              (up to ten) behind it.  Normally this would only be the
  2733.              first character.  So instead of typing "M "Y "N "A "M "E
  2734.              (space=enter here) you type "MYNAME.  Note that any
  2735.              terminating " will also be searched for!
  2736.            - An x is treated as a wildcard.  So if you search for CD x 80
  2737.              any call to a subroutine in the block 8000-80FF is a hit.
  2738.              If you search for x 8000, you'll see every one-byte
  2739.              instruction that has the address 8000 as operand.
  2740.         N: Continues the search started by F from the current MP.
  2741.         $: Displays one page of disassembly on screen.  In this mode,
  2742.            the following commands are possible:
  2743.            $: Back to the main screen
  2744.            7: [Shift 7 also works, cursor up]: Go to the previous page.
  2745.               The monitor stores the addresses of the previous eight
  2746.               pages only.
  2747.            Q: Go back one byte (decrease MP by one)
  2748.            A: Go one byte forward (increase MP by one)
  2749.            Z: Dump this screen to the printer, in ASCII format.  Redirect
  2750.               the RS232 output to a file, and run CONVERT on it to convert
  2751.               the CR's into CR/LF's before printing (or tell your printer
  2752.               to do the conversion).
  2753.            Every other key displays the next page of disassembly.
  2754.         K: List.  The same mode as with $ is entered, but instead of a
  2755.            disassembly the bytes with their ASCII characters are
  2756.            displayed.  Useful to look for text.
  2757.         C: Clear.  Fills blocks of memory with a specified value.  The
  2758.            monitor prompts with 'First', 'Last' and 'With'.  The 'Last'
  2759.            address is inclusive!
  2760.         D: Dump.  Prompts with 'First' and 'Last', and dumps a
  2761.            disassembly of the block between these addresses to the
  2762.            printer.  See remark at $-Z.  The 'Last' address is again
  2763.            inclusive.
  2764.         R: Registers.  If you press Enter after R, an overview of the
  2765.            registers contents is displayed.  If you type one of A,B,C,D,
  2766.            E,H,L,A',B',C',D',E',H',L',I,R,AF,BC,DE,HL,AF',BC',DE',HL',
  2767.            IX,IY,SP or PC, you can change the value of it.  Changing the
  2768.            value of SP also changes the PC and AF values by the way.  You
  2769.            cannot change the Interrupt mode or IFF.
  2770.         V: Verplaats.  (Move).  Prompts with 'From', 'To' and 'Length'.
  2771.            Obvious.
  2772.         S: Save.  Enter the start of the block you wish to save first.
  2773.            The monitor then prompts with 'Length'.  The block is saved
  2774.            without a header, as a normal data block (A, the flagbyte, is
  2775.            0FF)
  2776.         L: Load.  Loads a block of data from tape, at the specified
  2777.            address.  Normal data blocks, headers and blocks with non-
  2778.            standard flag bytes can be loaded.  The first byte in memory
  2779.            will contain the flag byte.  If the checksum isn't 0 after
  2780.            loading, indicating a tape error, you'll hear a beep.
  2781.         H: Header read.  Loads headers and displays the contents on
  2782.            screen.
  2783.  
  2784.  
  2785.     As you're reading this part, I assume you know something of machine
  2786.     code.  Probably you would be interested in peeking into the software of
  2787.     the SamRam, the Interface I, the Spectrum 128, the Disciple or the
  2788.     Multiface 128.  You'll first have to move these roms in ram to be able
  2789.     to look at them with the monitor.
  2790.  
  2791.     The Interface I rom can be moved into ram by saving it to microdrive or
  2792.     to the "b" channel, with SAVE *"m";1;"rom" CODE 0,8192 or SAVE *"b"
  2793.     CODE 0,8192, and loading it back again at 32768 for instance.  You can
  2794.     also put this small machine code routine at 23296 and run it: F3 21 0C
  2795.     5B E5 21 00 00 E5 C3 08 00 21 00 00 11 00 80 01 00 20 ED B0 FB C3 00
  2796.     07.  You ought to be able to disassemble this piece by heart.
  2797.  
  2798.     The two SamRam roms are easy.  The first you don't need to transfer;
  2799.     the monitor looks at the extended basic rom by default.  The second rom
  2800.     can be moved to 32768 by typing *SAVE 0,32768,16384.  (The SAVE is not
  2801.     the keyword SAVE!)
  2802.  
  2803.     The first '128 rom, the one which is active at reset and contains most
  2804.     of the new code, is moved up by typing SAVE!"rom"CODE 0,16384, then
  2805.     LOAD!"rom"CODE 32768.  The other rom is most conveniently moved by
  2806.     saving it to a .TAP file and loading it back again in ram.  To select
  2807.     the SamRam type SPECTRUM first, and then switch the hardware without
  2808.     resetting.
  2809.  
  2810.     The Disciple and Plus D roms can be transferred to RAM by simply saving
  2811.     them to disk and loading them back at say 32768.
  2812.  
  2813.     The Multiface ROM is paged by an IN from 191, and paged out again by
  2814.     INning from address 63.  Don't forget to disable interrupts in between,
  2815.     I'm not sure whether the M128 has a well-behaved interrupt routine.
  2816.     ROM is from 0-8191, RAM on top of that.
  2817.  
  2818.  
  2819.  
  2820.  
  2821.  
  2822.  
  2823. 4.  THE SPECTRUM
  2824.  
  2825.  
  2826.  
  2827.  
  2828. 4.1  The Spectrum
  2829.  
  2830.  
  2831.     This emulator supports the Interface I, the Multiface 128, the DISCiPLE
  2832.     and Plus D interfaces, and the Spectrum 128.  Many Spectrum users will
  2833.     have no experience with them, so some comments may be useful.  On the
  2834.     other hand, I don't think this is the right place to describe the
  2835.     Spectrum Basic in full detail.  If you want to know it all, read the
  2836.     official manuals!  Information on the Multiface 128 can be found in
  2837.     section 2.12.
  2838.  
  2839.     If you want to use Spectrum Basic, you will need the keywords.  You
  2840.     could by the way now also use the Spectrum 128 Basic where you can type
  2841.     the keywords in by full.
  2842.  
  2843.     If you press ALT-F1 in the emulator, the Spectrum keyboard layout will
  2844.     appear.  For completeness I include an alphabetical list of all
  2845.     keywords and their key-combination.  In the list below, K stands for
  2846.     Keyword mode, E for E-mode (type Shift-Alt of Shift-Ctrl to select
  2847.     E-mode), S for Symbol Shift, and SE for Symbol Shifted (Alt/Ctrl)
  2848.     E-mode: select E mode and type the letter while depressing Symbol
  2849.     Shift.
  2850.  
  2851.  
  2852.         Keyw.    Code | Keyw.    Code | Keyw.    Code | Keyw.    Code
  2853.  
  2854.         ABS      E g    DRAW     K w    MERGE    SE t   SAVE     K s
  2855.         ACS      SE w   ERASE    SE 7   MOVE     SE 6   SCREEN$  SE k
  2856.         AND      S y    EXP      E x    NEW      K a    SGN      E f
  2857.         ASN      SE q   FLASH    SE v   NEXT     K n    SIN      E q
  2858.         AT       S i    FN       SE 2   NOT      S s    SQR      E h
  2859.         ATN      SE e   FOR      K f    OPEN #   SE 4   STEP     S d
  2860.         ATTR     SE l   FORMAT   SE 0   OR       S u    STOP     S a
  2861.         BEEP     SE z   GO SUB   K h    OUT      SE o   STR$     E y
  2862.         BIN      E b    GO TO    K g    OVER     SE n   TAB      E p
  2863.         BORDER   K b    IF       K u    PAPER    SE c   TAN      E e
  2864.         BRIGHT   SE b   IN       SE i   PAUSE    K m    THEN     S g
  2865.         CAT      SE 9   INK      SE x   PEEK     E o    TO       S f
  2866.         CHR$     E u    INKEY$   E n    PI       E m    USR      E l
  2867.         CIRCLE   SE h   INPUT    K i    PLOT     K q    VAL      E j
  2868.         CLEAR    K x    INT      E r    POINT    SE 8   VAL$     SE j
  2869.         CLOSE #  SE 5   INVERSE  SE m   POKE     K o    VERIFY   SE r
  2870.         CLS      K v    LEN      E k    PRINT    K p    <=       S q
  2871.         CODE     E i    LET      K l    RANDOMIZE K t   >=       S e
  2872.         CONTINUE K c    LIST     K k    READ     E a    <>       S w
  2873.         COPY     K z    LINE     SE 3   REM      K e
  2874.         COS      E w    LLIST    E v    RESTORE  E s    DEC      SE q
  2875.         DATA     E d    LN       E z    RETURN   K y    HEX      SE w
  2876.         DEF FN   SE 1   LOAD     K j    RND      E t
  2877.         DIM      K d    LPRINT   E c    RUN      K r
  2878.  
  2879.  
  2880.         Character  Spectrum kbrd   On PC keyboard
  2881.  
  2882.         &          S 6             ALT (or CTRL) 6
  2883.         '          S 7             ALT 7 or '/"
  2884.         (          S 8             ALT 8
  2885.         )          S 9             ALT 9
  2886.         _          S 0             ALT 0 or SHFT _/-
  2887.         <          S r             ALT r or SHFT </,
  2888.         >          S t             ALT t or SHFT >/,
  2889.         ;          S o             ALT o or :/;
  2890.         "          S p             ALT p or SHFT "/'
  2891.         ^          S h             ALT h
  2892.         -          S j             ALT j or _/-
  2893.         +          S k             ALT k or SHFT +/= or GREY +
  2894.         =          S l             ALT l or +/=
  2895.         :          S z             ALT z or SFHT :/;
  2896.         ?          S c             ALT c or SHFT ?//
  2897.         /          S v             ALT v or ?//
  2898.         *          S b             ALT b or GREY PRTSC/*
  2899.         ,          S n             ALT n or </,
  2900.         .          S m             ALT m or >/.
  2901.  
  2902.  
  2903.  
  2904.  
  2905. 4.2  The Interface I
  2906.  
  2907.  
  2908.     If you want to use the microdrive, you'll need cartridge files.  The
  2909.     emulator can create an empty cartridge file for you.  You have to
  2910.     format it before you can use it.  Type
  2911.  
  2912.         FORMAT "m";1;"name"
  2913.  
  2914.     to format the cartridge currently in Microdrive 1 giving it the name
  2915.     'name'.  Next, type CAT 1 to get a catalogue of the files on it (none
  2916.     of course) and the number of kilobytes free.  You can save a file by
  2917.     typing for instance
  2918.  
  2919.         SAVE *"m";1;"screen"SCREEN$
  2920.  
  2921.     Instead of SCREEN$ you can use all other expressions that are permitted
  2922.     also when saving to tape, like LINE nnnn or CODE x,y etcetera.  To load
  2923.     a file back from cartridge, you type (you guessed it)
  2924.  
  2925.         LOAD *"m";1;"screen"SCREEN$
  2926.  
  2927.     If the file doesn't exist or is of the wrong type you'll get the
  2928.     appropriate error message.  To erase a file, type for instance
  2929.  
  2930.         ERASE "m";1;"screen"
  2931.  
  2932.     Note that no * is needed (or even permitted), and that only the name
  2933.     should be given.  There's another way to create a file on a cartridge,
  2934.     and that is by using a command like OPEN #3;"m";1;"name", and printing
  2935.     to that stream.  You can use MOVE to move data from stream to stream,
  2936.     but I'll not go into that --- it's not very much used anyway.
  2937.  
  2938.     Instead of to the microdrive, you can also 'save to the RS232 link'.
  2939.     For instance, type SAVE *"b"SCREEN$ (note: there's no name!) to save a
  2940.     screen.  On the emulator you can send the output to the RS232 channel
  2941.     to a printer (then SAVE *"b" is useless), to a file (can be useful) or
  2942.     to the COM port (very useful if you connect a real Spectrum to the PC's
  2943.     COM port!).  You can load the data back by typing LOAD *"b"SCREEN$ and
  2944.     making sure the RS232 channel is fed with the right input (from a COM
  2945.     port or a file).  See also section 2.13.
  2946.  
  2947.     If you want to use the RS232 channel for printing, open stream 3 for
  2948.     output to that channel by typing
  2949.  
  2950.         OPEN #3,"b"
  2951.  
  2952.     or
  2953.  
  2954.         OPEN #3,"t"
  2955.  
  2956.     The first will simply copy everything you send to stream 3 (using for
  2957.     instance LPRINT or LLIST) to the RS232 channel; the second converts
  2958.     CR's into CR/LF's, breaks off lines at 80 characters and translates
  2959.     keywords into character sequences.  "t" is useful for LLISTings, but
  2960.     not for anything else.
  2961.  
  2962.     Useful extra commands: CLS #, to clear the screen and reset the
  2963.     attributes to their reset defaults, and CLEAR # to do a CLS # and close
  2964.     all currently open streams (discarding all data that may still be
  2965.     buffered!)
  2966.  
  2967.     The Interface I uses its own system variables.  At the first error
  2968.     message you make (or RASP, or flashing question mark) and at the first
  2969.     Interface I statement you execute, it inserts them automatically.  Some
  2970.     programs will not run when the Interface I has inserted its system
  2971.     variables.  So if you load a game from tape, reset the Spectrum first
  2972.     and don't make an error typing LOAD "".  With a bit of exercise you
  2973.     should be able to do this.
  2974.  
  2975.  
  2976.  
  2977.  
  2978. 4.3  The DISCiPLE and Plus D Interfaces - Introduction
  2979.  
  2980.  
  2981.     The DISCiPLE and Plus D were two disk interfaces for the spectrum
  2982.     designed by M.G.T. (Miles Gordon Technology).  The first of these
  2983.     interfaces was the DISCiPLE, this interface consisted of a disk
  2984.     interface, microdrive network compatible interface, parallel printer
  2985.     interface, 2 joystick ports (emulating kempston, cursor, and Sinclair 1
  2986.     and 2).  The unit also had an inhibit button which disabled the
  2987.     interface hardware (except the joystick ports), and finally a snapshot
  2988.     button which when pressed stopped the computer to allow the program to
  2989.     be saved to disk or the screen to be printed.  This was made by
  2990.     Rockfort.
  2991.  
  2992.     The Plus D was the second of the interfaces, this was a cut-down
  2993.     version of the DISCiPLE, this interface only had a disk interface,
  2994.     parallel printer interface and a snapshot button.
  2995.  
  2996.     Both interfaces had a D.O.S. (Disk Operating System) which was partly
  2997.     ROM (8K) and partly RAM (8K).  When the spectrum was turned on, the ROM
  2998.     part of the D.O.S. was in control and whenever the command RUN was
  2999.     issued the ROM tries to load up the RAM part of the D.O.S. from floppy
  3000.     disk.  The advantage of this is that the D.O.S. can be upgraded without
  3001.     having to change chips over (unless of course it was a major upgrade!).
  3002.     Another advantage was that D.O.S. extensions could be incorporated or
  3003.     replace other systems (see later).
  3004.  
  3005.     With both interfaces, they extended the BASIC commands, but unlike the
  3006.     microdrives and several other types of drives available, the DISCiPLE
  3007.     and Plus D took up none of the spectrum's RAM, therefore it was the
  3008.     most invisible of the disk systems available, not only that, but the
  3009.     DISCiPLE and Plus D used the same type of disk drives as the BBC micro,
  3010.     therefore disk drives were both cheap and widely available, also the
  3011.     disks themselves were also standard, ie 5.25" (800K DS/DD), then later
  3012.     3.5" (800K DS/DD).
  3013.  
  3014.     The ROM of the DISCiPLE is supplied with the emulator, together with
  3015.     two version of the D.O.S. pre-loaded in RAM.  The ROM of the Plus D
  3016.     interface is not supplied, for copyright reasons.  The emulator will
  3017.     only emulate a Plus D interface if it can find a file PLUSDROM.BIN in
  3018.     the emulator's own directory.  If you have a Plus D yourself, you can
  3019.     transfer the ROM in the following way.  Load the operating system from
  3020.     a Plus D system diskette, and save the entire ROM, together with the
  3021.     operating system, to disk by entering SAVE d1"rom" CODE 0,16384.  Then,
  3022.     start the emulator and choose hardware mode Spectrum 48K + Disciple
  3023.     (not Plus D of course), then type LOAD d1"rom" CODE 32768.  Finally,
  3024.     press F10, X, S for Save Data block, set start address and length to
  3025.     8000 and 4000 (hexadecimal) respectively, and save the ROM under the
  3026.     name PLUSDROM.BIN.  If you re-start the emulator now, it will emulate
  3027.     the Plus D too.
  3028.  
  3029.  
  3030.  
  3031.  
  3032. 4.4  The DISCiPLE and Plus D Interfaces - The basic commands
  3033.  
  3034.  
  3035.     There are several levels of commands that can be used, these range from
  3036.     the most straightforward everyday use, to the more advanced, programmer
  3037.     type commands.
  3038.  
  3039.     I will first explain the most common commands, so that you can quickly
  3040.     and easily access DISCiPLE and Plus D disks.  Where a 1 is used in the
  3041.     following commands 2 could be used instead.  These commands are:-
  3042.  
  3043.      RUN -   when no D.O.S. (system file) is loaded it will cause this to
  3044.              be loaded. Otherwise it will just run the BASIC PROGRAM.  Please
  3045.              note that with the emulator the system file is already loaded,
  3046.              therefore this command is not required, although I have
  3047.              explained it for completeness.
  3048.  
  3049.      CAT 1 - will display a longhand catalogue of the disk drive selected.
  3050.              The form of this catalogue is as follows:-
  3051.  
  3052.                     program no., program name, sectors used, file type,
  3053.                     file size
  3054.  
  3055.      CAT * - will display a longhand catalogue of the currently selected disk
  3056.              drive in the same form as described above.
  3057.  
  3058.      CAT 1! - displays a shorthand catalogue of the disk drive selected.
  3059.               This catalogue consists of a 3 column list of the filename of
  3060.               the programs.
  3061.  
  3062.      CAT *! - displays a shorthand catalogue of the current disk drive.
  3063.  
  3064.      LOAD pn - p - letter p, n - number between 1 & 80.  This is the program
  3065.                number of the file on the disk, the program number is the
  3066.                number printed before the name in the longhand catalogue.
  3067.  
  3068.      LOAD d1"name" - load from drive 1 the program called name
  3069.  
  3070.      LOAD d*"name" - load from the current drive the program called name
  3071.  
  3072.      LOAD d1"name" S - load an 48K snapshot from drive 1 called name
  3073.  
  3074.      LOAD d1"name" K - load an 128K snapshot from drive 1 called name
  3075.  
  3076.      LOAD d1;a$ - load from drive 1 the program whose name is held in the
  3077.                   string a$
  3078.  
  3079.      LOAD d*;a$ - load from the current drive the program whose name is held
  3080.                   in the string a$
  3081.  
  3082.      FORMAT d1 -  format the disk in drive 1
  3083.  
  3084.  
  3085.  
  3086.  
  3087. 4.5  The DISCiPLE and Plus D Interfaces - More advanced commands
  3088.  
  3089.  
  3090.     In the previous section I explained enough of the commands so that you
  3091.     could get to use the floppy disks with DISCiPLE/Plus D software on. Now
  3092.     I am going to explain the commands that the more experienced user and
  3093.     those who want to do just a little bit more than just load the
  3094.     programs.
  3095.  
  3096.     First of all comes the simple commands of SAVE, MERGE, VERIFY and LOAD.
  3097.     All of these commands are the same as rge tape versions except that you
  3098.     have d1, d2 or d* after the LOAD, SAVE etc.  There are only two
  3099.     exceptions to this rule, the first is when you have a string for the
  3100.     filename, in this case the command becomes:-
  3101.  
  3102.              LOAD d1;n$ ....... etc
  3103.              LOAD d*;n$ ....... etc
  3104.  
  3105.     The second exception is actually an extension.  When you save a code
  3106.     block, you can actually get it to autorun when it is loaded by adding a
  3107.     third parameter to the SAVE command, e.g. if you had a code block from
  3108.     40000 to 45000 and the run address was 41023 and you wanted it to be
  3109.     called testcode to drive 1, you would save it as:-
  3110.  
  3111.              SAVE d1"testcode"CODE 40000,5001,41023
  3112.  
  3113.     Now for the extensions.
  3114.  
  3115.     Any sector on the disk may be loaded to any area of RAM from 16384 to
  3116.     65535-512. The sector may also be loaded into the RAM of the interface,
  3117.     however caution should be used at all times when doing this, as you may
  3118.     destroy the operating system or cause it to behave irrationally.
  3119.  
  3120.     The syntax of the command is:-
  3121.  
  3122.              LOAD @n,tr,sec,add
  3123.  
  3124.     Where:-
  3125.  
  3126.              n   = drive number, ie 1 or 2, note * may not be used!
  3127.              tr  = track number => 0->79=side 0, 128->207=side 1
  3128.              sec = sector number => 1->10 normally, may not be 0!  If you
  3129.                                     try and load a sector that is sector 0,
  3130.                                     then the operating system will crash!
  3131.  
  3132.     You may also save to disk in the same way, so if you wanted to write to
  3133.     Track 5, Side 0, Sector 3 with code from 32768 to 33279 to drive 1 you
  3134.     would type:-
  3135.  
  3136.              SAVE @1,5,3,32768
  3137.  
  3138.     To format a disk all you need to type is:-
  3139.  
  3140.              FORMAT d1       or       FORMAT d2
  3141.  
  3142.     This is not however as simple as it seems!  Although a disk formatted
  3143.     on the DISCiPLE/Plus D will work with the PC it does not work the other
  3144.     way round, i.e. a disk formatted on the PC with this emulator will not
  3145.     necessarily work on the DISCiPLE/Plus D. This is because of differences
  3146.     of the floppy disk controller chips.  With the PC, it puts a special
  3147.     byte at the beginning of each track to tell the controller whether the
  3148.     disk is Double Density or High Density, and the spectrum floppy disk
  3149.     controller does not understand this byte and therefore will not read
  3150.     the track!  If you find this otherwise, then please write and let us
  3151.     know about it.
  3152.  
  3153.     You can set some of the D.O.S. system variables using an extended POKE
  3154.     command. The syntax is:-
  3155.  
  3156.              POKE @address,value
  3157.  
  3158.     The address is the BASE address of the system variables of the
  3159.     interface concerned, the BASE address for each of the interfaces is
  3160.     different, but the address you use in the POKE command is the same.
  3161.  
  3162.  
  3163.  
  3164.  
  3165. 4.6  The DISCiPLE and Plus D Interfaces - The snapshot button
  3166.  
  3167.  
  3168.     The snapshot button is a button which is used to stop the processor
  3169.     from executing instructions and making it do something else. In the
  3170.     case of the DISCiPLE/PLUS D the button can do 5 different tasks
  3171.     initially. Later on I'll discuss how the fuctions can be altered so
  3172.     that it can do other tasks. Once these tasks are carried out, the
  3173.     processor is returned to it's original state and the program continues
  3174.     from where it left off from.
  3175.  
  3176.     There are 5 functions that can be carried out with the initial system
  3177.     file.
  3178.  
  3179.     To use the button, first you must get to a point in the program that
  3180.     you want to use the button at, then press the button on the emulator
  3181.     the snapshot button is F5 (NMI).  Once you do this the program will
  3182.     stop and the border of the computer will flash, this may also be
  3183.     accompanied with a buzzing noise on the speaker.  This is to tell you
  3184.     that the snapshot button has been activated.  The following functions
  3185.     can then be carried out:-
  3186.  
  3187.         1   - Print screen to printer in black/white screen size
  3188.         2   - Print screen to printer in grey scale A4 size
  3189.         3   - Snapshot screen to disk in SCREEN$ format
  3190.         4   - Snapshot program to disk in 48K SNAP format
  3191.         5   - Snapshot program to disk in 128K SNAP format
  3192.       SPACE - go back to program (ie if F5 was pressed by mistake)
  3193.  
  3194.     The printer options will print out to EPSON compatible printers,
  3195.     however the DISCiPLE code has been changed and it is now possible to
  3196.     print to HPGL printers (e.g. Deskjet and Laserjet printers).
  3197.  
  3198.     The Snapshot screen and snapshot 48K are very self explanatory and easy
  3199.     to use.
  3200.  
  3201.     The Snapshot 128K is slightly more complicated.  Once you select this
  3202.     option the disk drive will start up then after a slight pause the
  3203.     screen display may/may not change.  The border flashes again and you
  3204.     have to press y or n depending on whether the screen display changed or
  3205.     not.  If the screen stayed the same then press n, but if the screen
  3206.     changed type y.  This is because the 128K spectrum has 2 screens, and
  3207.     there is no way for the computer to determine which is being used by
  3208.     itself, therefore it needs the user's help.  After you press y or n the
  3209.     program will be saved onto disk.
  3210.  
  3211.     Seeing it is possible for you to load programs into the DISCiPLE/PLUS D
  3212.     RAM area it is possible to have these interfaces carry out other tasks.
  3213.     The snapshot button code is located in RAM, so you can therefore load a
  3214.     program into this part of the RAM and as soon as you press the snapshot
  3215.     button it will execute the new program.  There is one problem however,
  3216.     which is that the program must be written in assembly language and must
  3217.     also be compiled for running in that part of RAM, also it must take
  3218.     care of what it does because the SPECTRUM ROM is not paged in,
  3219.     therefore ROM calls are not easily carried out.
  3220.  
  3221.     There are several different commercial programs which use the snapshot
  3222.     button to carry out different tasks, some of these are:-
  3223.  
  3224.                         Snapshot compressing programs
  3225.                         Debugging tools
  3226.                         Cheat finders for games
  3227.                         Programs to allow snapshots back onto tape
  3228.  
  3229.     The list is endless, and if you are capable of writing a machine-code
  3230.     program and have the relevant information, then you too could write
  3231.     your own programs.
  3232.  
  3233.  
  3234.  
  3235.  
  3236. 4.7  The Spectrum 128
  3237.  
  3238.  
  3239.     The main new features of the Spectrum 128 are its larger memory, that
  3240.     can be used as a Ram drive in Basic, and music capabilities.
  3241.  
  3242.     The Ram drive is accessed via the LOAD!, SAVE!, ERASE! and CAT!
  3243.     commands.  They work as you would expect.  Examples:
  3244.  
  3245.         SAVE !"name"SCREEN$
  3246.         CAT!
  3247.         LOAD !"name"SCREEN$
  3248.         ERASE !"name"
  3249.  
  3250.     The 3 channel sound chip of the Spectrum 128 can be used in Basic with
  3251.     the PLAY command.  Example:
  3252.  
  3253.         PLAY "cde","efg","gAB"
  3254.  
  3255.     plays three chords.  You can program complex effects, melodies and
  3256.     rhythms with the play command; they require many commands in the three
  3257.     voice strings which I won't explain...  They are explained in the
  3258.     Spectrum 128's user guide.
  3259.  
  3260.  
  3261.  
  3262.