diff --git a/Docs/lifegard.txt b/Docs/lifegard.txt deleted file mode 100644 index 3f21d76..0000000 --- a/Docs/lifegard.txt +++ /dev/null @@ -1,123 +0,0 @@ - -Instructions for: Lifeguard by Romantic Robot ----------------------------------------------- - - -Introduction. -------------- - -The Lifeguard is a unique utility designed to automate the process of -discovering unlimited lives. The Lifeguard is for the exclusive use with -any ZX Spectrum and a corresponding Multiface. It loads into the Multiface's -own 8K RAM extension and does not take any Spectrum RAM. Thus you can run -a game as usual, STOP it with the Multiface RED button and use the Lifeguard -to search and disable the algorithm keeping track of the number of lives, -bullets, ammo etc. - - -Installing the Lifeguard in Multiface. --------------------------------------- - -This section originally went on about how to install the program in the -Multiface. For Z80 Emulator users, simply use the .TAP file included with -the emulator, or a snapshot of it. Enuring you are running the Multiface -with Z80, press any key, the program will reset and upon pressing key F5 -will be presented with the Lifeguard menu. All references to the 'red -button' or STOP button have been replaced with F5, the key used to activate -the Lifeguard software. - - -Using The Lifeguard. --------------------- - -Once you load your game in the usual way, make a note of the CURRENT -number of lives (not displayed on screen, but physically COUNT them!). - -Eg. If your game starts with 10 lives, and you have already lost 2, -the number to note is 10-2=8 ! - -Press F5 and you will see the following menu:- - - +----------------------------------------+ - | (S)earch : (C)ustom: 00 | - | (F)lip : DEC A / DEC HL / CUSTOM | - | (L)ives=003 : 1 = up 2 = down 3 = set | - | (N)ext poke | - | Number of pokes = 000 | - | Counter = 000 00000 | - +----------------------------------------+ - -To call up an option, press the letter in brackets. To quit, press -and you will be returned will be returned to your game. - -To give yourself unlimited lives, you will first have to enter the current -number of lives into the LIVES counter, decide (FLIP) which instruction -or CUSTOM you wish to test out. SEARCH for the poke and then try it out -with NEXT. See below for these stages in greater detail. - -LIVES: Having pressed '1' or '2' to increase/decrease the CURRENT value of -lives (or bullets, ammo etc.), press key '3' to set this value. - -FLIP: Nearly all games use the DEC A or DEC (HL) to decrease the value of -lives etc. If DEC A does not work in a particular game, press F to FLIP -to DEC (HL). You can also FLIP to search for a CUSTOMised value if you -wish. - -CUSTOM: Pressing 'C' will allow you to enter a value into a special location -which can be used as described above. Use '1' or '2' to increase or decrease -the value and '3' to set it. This option enables you to search for all -manners of things. For example, INC A (dec: 60) can be used to increase -the number of aliens you have to shoot. So if you put 60 on the 'C' -counter and have the right value on the LIVES counter, you could stop the -aliens increasing, or stop a clock etc. - -SEARCH: This option searches through the program looking for either -DEC A, DEC (HL) or CUSTOM, depending on what you have chosen with 'FLIP'. -After a search has been completed, the number of possible locations is -stored and displayed in 'Number Of Pokes'. - -NEXT: Once the Lifeguard has found some potential POKEs, you can try -them out with 'Next'. The number of pokes is shown and so is the Counter -below, displaying which one is being tested. Finally, and most importantly, -there is also the relevant current ADDRESS which the Lifeguard tests by -POKEing it with '0' and then automatically jumping back into the game. Now -try the game and see if you succeeded in doing whatever you wanted to do! - -If yes, then make a note of the address (if you press F5 it will still -be there) and perhaps you can use the 'Toolkit' in Multiface next time -and POKE this address with '0'. - -If not, then re-enter Lifeguard with F5 and press 'N'ext again - so long -as the Counter did not reach the number of pokes available. If you have -test out ALL the pokes available, then FLIP to the other DEC instruction -or try out the CUSTOMised instruction and SEARCH again. - -It is a good idea to test just before losing a life, as you can see the -effect quickly: if you lose a life and the number of lives DOES decrease -then there is more work for the Lifeguard. - -As an example, here are a couple of games with their pokes: - -+------------------------------------------------------------+ -| GAME | FLIP | LIVES | COUNTER | ADDRESS | -+------------------------------------------------------------+ -| Kinetik | DEC A | = 4 men | 4th POKE | 49165 | -+------------------------------------------------------------+ -| Gyroscope | DEC (HL) | = 3 men | 1st POKE | 33922 | -+------------------------------------------------------------+ - - -A message from the typer of these instructions .... ----------------------------------------------------- - -I have copied these instructions out perfectly from the original photocopy -and verified the above addresses with the person who sent me the copy and -the addresses above DO NOT WORK ! The correct ones are as follows: - -Kinetik - could not find it ! - -Gyroscope - Infinite Lives = 53922 - Infinite Time = 59146 (clock is stuck on 59!) - -I do not know whether this is a misprint or a cockup on the emulators behalf -and I do not wish to speculate either ! diff --git a/Docs/new.doc b/Docs/new.doc deleted file mode 100644 index 5be178d..0000000 --- a/Docs/new.doc +++ /dev/null @@ -1,465 +0,0 @@ -Sinclair ZX Spectrum Emulator 'Z80' v4.00 - 6/3/99 - by G.A. Lunter - - - -Additions to the Spectrum Emulator, from the the first version that -was released, version 1.20. (*) = only available to registered users. -Names between brackets are games that first indicated the presence of -the corresponding bug in the emulator, or the person that spotted the bug. - - - -6/3/1999 Version 4.00 of Z80 and WinZ80 released - - - WinZ80: - - First release. - - - Z80: - - - TZX v1.12 file support. Added switch -tz, modified switch - -td. (TZX=general tape file format, mainly by Tomaz Kac). - - Added true VGA graphics mode; this mode works fine in - Windows' DOS boxes, and solves problems for several laptop - computers and incompatible video adapters. This mode is - default in DOS boxes (even full-screen ones). Switch -g - added (switch 'no sound' moved to -0g). - - Changed speed code; ran into bounds on 200 MHz 80686. - Switch -z changed slightly. (Ian Lowndes) - - Better Issue2/Issue3 emulation (Using info from Technical - FAQ by Philip Kendall / Pera Putnik) - - Better AY soundchip emulation, using square waves if - possible. (Thanks to Luca Bisti) (Added switch -0o) - - "ACB" stereo for AY sound implemented (suggested by Luca - Bisti) (Added switch -0w) - - Removed snow in VGA modes (solution by Wim Oudshoorn) - (*) - Disk drive is now reset to 720K DD when using Disciple/+D - (Brian Cavers) - - Pressing ENTER at empty line when saving snapshot pops - up previous name (Suggested by Christopher Heys) - - SLT level loading doesn't need extra memory anymore; used - to fail sometimes when no EMS memory was present. - - Included precise definition of R register field in Z80 file - format definition. - - Added information on XZX's and Warajevo's .Z80 format - extensions (Philip Kendall) - - Correctly handles new 'ECP' LPT cards (Martijn vd Heide) - - Bugfix: Saving a snap directly after loading it changed - border colour (Bernhard Lutz) - - Bugfix: Shuttle shock guy couldn't move (reads port #FEFC; - Lee Tonks) - - Bugfix: Z80 now sets border colour when loading .SNA files - (Philip Kendall) - - Bugfix: Z80 didn't open or read from read-only .TAP files - (Martin Jaros) - - Bugfix: Deleting blocks from .TAP file now also works - correctly if same file is used for both input and output. - (Martin Jaros) - - Bugfix: RS232 input redirection menu didn't work (Wojtek - Wasilewski) - - Bugfix: video routines slightly faster (Flashing - attributes were refreshed too often). - - Bugfix: Time is displayed correctly of long .VOC files (of - about 10 minutes). (Martin Jaros) - - Typo: -xs changed into -ts in z80.doc (Niccolo Rigacci) - - Bugfix: Small inconsistencies between Z80 / Winz80 / - Z80Dump / docs (timing, header bytes 60/61) fixed (Philip - Kendall) - - -11/11/96 Version 3.05 released - - - Disciple/+D Centronics printer bug fixed. - - Disciple COPY SCREEN$ bug fixed. - - RLD and RRD could change ROM (Soldier of Light; James McKay - and Lee Tonks aka Blood told me about this) - - RES/SET IX/IY could change ROM (Red Scorpion; bug reported - by Robert Zmyslowicz) - - Z80 again works on all processors, including 8088/8086. - - ALT-F7 shortcut to playing .TAP files works more - intuitively, following suggestions by Einar Gattoni Saukas. - - Added switches -tx and -tp, to suppress tape info window - and to pause after each block respectively. These setting - can be changed at runtime. (Suggestion by Blood) - - Extended switch -d (double interrupt frequency) to allow - both higher and lower interrupt frequencies than 50 Hz. - (Suggested by Cristian Secara) - - Added switch -0sND to select physical drives for MGT drives - (Suggested by Einar Gattoni Saukas) - - Switch -ti now looks for .TAP file in both current and - default .TAP file directory. (Einar Gattoni Saukas) - - Function keys now work when tape info window pops up. - (Einar Gattoni Saukas) - - The combination LD SP,#FFFF/RET and ../RST cc caused a - General Protection Violation. (Robert Zmyslowicz) - - Bugfix: long OTIR to #FE in Hi Res Color mode crashed Z80 - (Confuzion; Bernhard Lutz) - - Bugfix in OUT #FE routine when sound was turned off; caused - Z80 to run very slowly sometimes (Christopher Heys) - - Floating bus emulation improved in HRC mode (Ricochet; Lee - Tonks noticed the problem) - - Bug in filename-selection-by-typing-initials, introduced in - v3.04, fixed. (Bernhard Lutz, Einar Gattoni Saukas) - - Z80 now runs under Windows 95 in DOS boxes. (v3.04 already - did, in fact, but this list didn't say so) - - Bugfix: Z80 sometimes 'compressed' 16K blocks into more - than 16K, and refused to load the resulting file. Z80 file - format has been changed. (Robert Zmyslowicz, Erik Kunze) - - Bugfix: IN to page Multiface rom/ram in or out corrupted A - register (Genie 128; James McKay and Blood) - (*) - Bugfix: Z80 didn't swallow read-only VOC files, and TAP2VOC - produced those for no reason. (Einar Gattoni Saukas) - (*) - Out2Voc of v3.04 registered distribution didn't work, - because wrong memory model was chosen. (Wojtek Wasilewski) - (*) - Bugfix: playing a .VOC file and then loading a .TAP file - caused Z80 to crash. (Wojtek Wasilewski) - (*) - Bugfix: loading a +D .Z80 snapshot with no PLUSDROM.BIN - file present now causes Z80 to select Disciple mode - automatically, instead of printing error message and quit. - (Robert Zmyslowicz) - - Bugfix: Level numbers were sometimes incorrectly appended - when forming name of .DAT file. (Robert Zmyslowicz) - - Bugfix: When two snapshots of the same name existed, the - .SNA one was loaded, and never the poor .Z80 one. (Blood) - - The AMX mouse was called AMS mouse everywhere. (Erik Kunze) - - Some errors in the tech doc fixed. (Einar Gattoni Saukas) - - Added list of Disciple/+D system variables to Z80.DOC. - - - -10/8/96 Version 3.04 released - - - Supports .SLT 'Super Loader Trap' files with level data and - loading screens. Added utility ADDDAT. - - Much better keyboard handling and speed measuring in DOS - boxes running under Windows (95) - (*) - Added utility READSB to read .VOC sample files from - SoundBlaster compat. sound card, and digitally filter them. - This finally enables reliable loading via a SoundBlaster. - (*) - Bugfix: Disciple snapshots don't overwrite old data anymore - - Needs 16K less memory: fast/full/minimal (default,-xt,-xu): - 564K, 517K, 481K; uses 240K less base memory if Extended - Memory is present. No support anymore for Extended - Hercules and Plantronics video modes. - (*) - Switch -00 added, to suppress pause at intro screen - - Z80 now ejects paper from laserprinters when ZX Printing. - (switch -0f N) - - Added tech info about ZX Printer, AY-3-8912 sound chip, and - Spectrum 128 internals. (Info on AY chip due to Alastair - Booker and Ian Collier.) - (*) - VOC files are high-pass filtered when played back, to make - loading less sensitive to 50 Hz component. - - Support for 2nd analogue joystick as Sinclair 1 joystick - added. - - The emulator returns 'No ZX Printer attached' if the output - printer is not there or off-line; previously the emulator - hang on a COPY with no printer to print to. Switch -xj - added. (Lords of Midnight, SuperSpy) - - Added -xy trace feature - - Added -0m opcode mapping feature, for use with (a future - version of) Leslie Styles' disassembler DSNA - - Switch -kx added, for custom remapping of keyboard. - - Addresses are entered as decimal numbers by default now; - hex can be used by prefixing the address with a # or $ - sign. - - Added explanation of Break Points in documentation (section - 2.21) (Douglas Paulley) - - Novell broadcasts are disabled (Damion Yates) - - Timer routine made faster. - (*) - Bugfix: Disciple/+D track buffer bug fixed. - - Bugfix: SoundBlaster is properly turned off at exit - - Bugfix: RES/SET opcodes can't change ROM anymore (Catch23 - and Batman, the Capped Crusade; thanks to Gerardo Oporto - Jorrin) - - Bugfix: CTRL-ENTER when loading snapshot now also keeps - part of hardware mode fixed. - - Opcode for loading levels is ED FB, not ED F6 as the - documentation said previously. (Russell Marks) - - Bugfix: Loading snapshot saved in +D hardware mode with no - PLUSDROM.BIN file present does not return Z80 to DOS - anymore. - - Bugfix: settings are read correctly from snapshot file - specified on command line. - - Bugfix: '128 I/O ports are decoded properly (Three Weeks in - Paradise 128; Tomaz Kac) - - - -29/12/94 Version 3.03 released - - (*) - OUT2VOC now also handles 128k soundchip output. - (*) - TAP2VOC can now produce raw sample files. - - Bugfix: Mouse and analogue joystick work together and - properly. (Niccolo Rigacci) - - Improved Hi Resolution Color emulation; the emulator uses - different timings in 128K modes, and locks in on memory - pushes to synchronise. Most programs that use HRC effects - work correctly now. - - Bugfix: Without EMS memory, Multiface 128 did not work. - - Small error fixed and explanation added in DOC about new - .Z80 file headers (Arnt Gulbrandsen). - - Added: Switch to turn off Hi Resolution Color emulation - completely; this saves another 40K over -xt. - - Added: Program counter tracing feature. - - Added: Information in documentation on Spectrum 128 video - timings, and interrupt timings. - - In 128 mode, out address 7FFD is decoded using only A15 - (and low order byte), making at least one problem program - run. (Igor 'Iggy' Eged) - - - -3/11/94 Version 3.02 released - - - Bugfix: Without EMS memory, a Spectrum error with IF1 on - locked the emulator or generated an 'IN 0 crash'. - (*) - Bugfix: OUT2VOC did not work properly for long samples. - - - -28/10/94 Version 3.01 released - - - Bugfix: The ZX Printer code for Epson printer was faulty. - - The phone number for B.G. Services in Z80.DOC was wrong. - - The emulator can now log Z80 OUTs to any I/O port in a .OUT - file, with timing information. - (*) - Added utility (OUT2VOC) to translate .OUT log files into - .VOC sound sample files, for recording music and SAVEing - directly to a .VOC file. - - Added a new section to the documentation about the Disciple - and +D interfaces. - - Added section about the OUT2VOC utility. - - - -20/10/94 Version 3.00 released - - (*) - Disciple and Plus D disk interface emulation - - ZX Printer support, for Epson and HP Laserjet compatibles - - Emulation of hi-resolution color and border effects, using - exact timing. - - Multiface 128 emulation; useful to load M128 snaps without - corrupting the screen - - Mouse support, controlling either Spectrum joysticks or the - AMX Mouse interface (supported by e.g. Art Studio) - - A number of improvements and bugfixes of the Z80 processor - emulation code, solving several problems with turbo - loaders, most notably Ocean's. - - All instructions emulated, including unofficial DDCB and - FDCB ones, and all unofficial ED instructions. Most - unofficial flags emulated. - - User defined joystick support - (*) - VOC file support - read programs stored in sound sample files - (*) - Emulator can read in real mode from SoundBlaster port - - Faster code using 386+ instructions for VGA mode - - Switch to remove info window when saving or loading - - Emulator can set breakpoints at any address, invisible to - the running program. - - Can save any part of Spectrum memory to disk, and load it - back in memory. - (*) - Utility to read a sound sample from the standard LPT tape - interface, or the SoundBlaster, in a .VOC file - (*) - Utility to convert .TAP files to .VOC files - - One-key joystick mode change, with ALT F4. - - Improved emulation of 'floating bus' (try Arkanoid) - (*) - Bugfix Z802TAP; sometimes blocks got corrupted. - - Bugfix: Digital Zandbergen joystick didn't work. - - Multi-level support, in the same way as implemented in XZX - version 0.5.2 - - Bugfix: MOVE from cartridge to another cartridge didn't - work, due to buffering problems. (Martin Smith) - - Bugfix: Several problems with the keyboard when running - under Windows are solved. - - Bugfix: R register doesn't change when going to main menu. - - Better sound quality, and no border interference anymore in - Real Mode when playing music. - - - -20/5/93 Version 2.01a released (registered users only) - - (*) - Fixed bugs in DISCiPLE disk read utility, and added option - to copy all files at once. - - Fixed typing error in Z80.EXE - - Fixed small errors in Z80FAQ.DOC - - - -3/5/93 Version 2.01 released. - - - Added LaTeX and PostScript doc, by Lars K\"oller, - - Added Windows icon - - Added -xb switch (black and white VGA) - - Added remark about Czech registration to doc - - Added various other things to doc - - Fixed bug in (X-)Hercules border dithering - - - -16/4/93 Version 2.00 released. - - - Z80 now supports the Spectrum 128, including '128 sound - through PC speaker or AdLib compatible sound card, - - Dutch documentation rewritten in English, - - Much better tape support, with tape files on disk, support - of headerless files and more difficult formats, easy access - to programs using LOAD "name", multiple files in a single - tape file, automatic mirroring of loaded blocks to tape - files, - - Microdrive support, 8 microdrives with cartridge-files - holding up to 126K of data, low-level I/O compatibility, - - VGA support, fast screen update and accurate colours - including bright, - - Z80 emulation nearly perfect, including emulation of - unofficial flags and undocumented features. Timing of - individual instructions is made much more accurate on fast - computers, while maintaining maximum possible speed on slow - ones, - - Spectrum keyboard layout help-screen under ALT-F1, - (*) - Disciple/+D disk read utility can translate 48K and 128K - snapshots to .Z80 files, and screen snapshots and normal - files to .TAP files. It will now also read 5.25'' (720K - 80 track double density) disks, and some bugs have been - fixed, - - Z80 now reads a .INI file at startup for default settings, - - Changing the hardware (SamRam, Spectrum 128) now possible - on-the-fly, - - The R register and LDIR emulation flags are saved in .Z80 - snapshots, - (*) - The emulation speed slowdown is now accurate from 8 MHz PC's - to the fastest available 486 machines. The emulation speed - can be brought back to 7%, - (*) - Source files now include source of SamRam software, - - Support of AZERTY keyboards, - - The emulator can now run under Windows, - - Emulator can use other default 16K rom (switch -xr), - - The program uses EMS if available, for fast bank switching, - (*) - CONVERT utility can now also convert a screen to a .PCX file, - (*) - CONVZ80 now also supports the .PRG and tape files of SpecEm - (Kevin J. Phair) and tape files of ZX (Rindt and Brukner), - (*) - New utility: Z802TAP, to convert a .Z80 snapshot to a .TAP - tap file, - (*) - New utility: TAP2TAPE, to write a .TAP file back to tape, - - Fixed CGA colours bug, - - Fixed CTRL-BREAK bug, - - Fixed several other bugs, and - - a nice new intro screen. - - - -14/8/92 Version 1.45 released. - - - Z80 emulator is now about 5% faster. Arnt Gulbrandsen, - the author of JPP, pointed out to me that I was clearing - the BL register too often. - - The analogue joystick now really works - (*) - SAVEing programs to tape now really works (if you're a - registered user) - - You can now load .SNA files (commonly used snapshot format) - directly into the emulator, without having to convert them - with ConvZ80. - - The Interface-I RS232 channel can now also be attached to - COM3 and COM4. - (*) - ConvZ80 now also supports the .SP format used by a Spectrum - emulator called 'SPECTRUM', written by Pedro Gimeno. - - A capacitor in DIAGRAMS.Z80 had the wrong value (17-8-92) - - .SNA files that were loaded were not properly closed, - resulting in a FILE NOT FOUND error. (17-8-92) - - - -27/7/92 Version 1.41 released. The 1.40 version of Z80.EXE was - packed with COMPACK (sort of PKLITE), which was bugged: - it didn't run on some '386s and '486s. This version isn't - packed anymore. - - - -16/7/92 Version 1.40 released, Shareware and for registered - users. - - (*) - Full tape support! A program DIAGRAMS.Z80 is supplied, - that consists of two diagrams of tape-adapters for PC's, - and a test-program useful for calibration of the - adapters. - (*) - A utility to read DISCiPLE floppies. - - The analogue IBM joystick and a special interface for - digital (Spectrum) joysticks are supported. In the - documentation file is a diagram for the digital joystick - interface. - - A more extensive manual, and a summary for English- - speaking users. - - Speed measurement of the Z80 emulator is more accurate. - (V1.20 overestimated the speed.) - - Function keys F1-F7 and F10 are now used. - - The Emulator can run in 'Real'-mode, for better sound - and for tape (speed-)load and save. - - R register emulation is now perfect, so that protected - games (e.g. lenslock games) can be loaded. - - Video routines are faster. - - Several bugfixes concerning writes in ROM. (Strong Man) - - The settings of Issue 2 emulation, Double Interrupt - frequency, Video synchronisation mode and joystick are - stored in .Z80 files. - - - -6/11/91 Version 1.30, for registered users only: - - - It is now much easier to choose a file from the main - menu: the cursor keys, PgUp and PgDn can be used to - browse through the list of files, and letter-keys make - the bar jump to the first file that starts with that - letter. The files are now alphabetically ordered. - - Sinclair joystick 1 added (keys 1-5) - - If a path is entered at the command line, the Emulator - automatically jumps to the main menu, option 'load - program', and changes to the specified directory. - - If a file is attached to the RS232 in- or output - channel, the read- or write-position is shown (main - menu, options I and O) - - Switches -yl and -yh are added, for Low and High video - synchronisation. With these switches, the flickering of - sprites of some games can be reduced. (Ghost 'n Goblins, - Uridium) - - Bugfix: DOS-clock ran too fast in version 1.25 - - Bugfix: On AT's the Emulator crashed if Spectrum programs - used interrupt mode 2 while the I register was 255. - (Full Throttle) - - Unofficial flags are now emulated better. (Ghost'n Goblins) - (*) - Extra utility CONVZ80, converts .Z80 files in .SP and - .SNA files, the snapshot formats of the Spanish Spectrum - emulator VGASPEC and the Norwegian Spectrum emulator JPP - respectively, and vice versa. - (*) - Utility Z80DUMP; displays the header of .Z80 files. - - - -4/10/91 Version 1.25, for registered users only: - - - Bugfix of instructions CB30 to CB37 (Bounder) - - 50 Hz interrupt and video update run 180 degrees out of - phase (BC Quest for Tires) - - SLA, SRA, SRL sped up. - (*) - Switch -z added: the Emulator now can be slowed down to - about a factor 4. - - Bugfix sound: some computers only produced sound after a - OUT 31,13. - - Switch -2 added for Issue-2 emulation (Spinads) - - Bugfix GETRS: now reading from COM2 works, and an - on-screen counter shows the progress. - (*) - CONVERT extended: GIF-files can be made directly from - .Z80 files - - - -30/7/91 Version 1.20 released. Eerste, geheel Nederlandse versie. - - - -11/11/88 First line of code written. - - - diff --git a/Docs/register.doc b/Docs/register.doc deleted file mode 100644 index 59961b2..0000000 --- a/Docs/register.doc +++ /dev/null @@ -1,179 +0,0 @@ -Sinclair ZX Spectrum Emulator 'Z80' v4.00 - 6/3/99 - by G.A. Lunter - - - - 'Z80' is a shareware program. The program is not completely - functional, and the parts which are left out are included when you - register. You are encouraged to give this demo version to friends, but - DO NOT change the original archive in any way, please. The shareware - version of the emulator consists of the Z80-400.ZIP archive file, which - should contain the following 3 files: - - INSTALL.EXE - installation program - INSTALL.000 - installation data file - README.TXT - short description of the program - - The shareware version includes WinZ80, the Windows version of Z80, - The registered versions of Z80 and WinZ80 feature the following extras: - - Z80: - - * Full DISCiPLE disk interface emulation - * Direct loading of tapes via SoundBlaster or LPT-interface - * No time restrictions, adjustable emulation speed at all times - - WinZ80: - - * Direct loading of tapes through any Windows wave input device - (e.g. SoundBlaster) - * No time restrictions, no intro window. - - If you register, you get the fully working versions, and the following - utilities: - - - CONVERT - a general conversion program: can list out BASIC and - translate it back, produce .GIF or .PCX files from - screen dumps, translate Spectrum ASCII (CR) to PC ASCII - (CR/LF), and some other things. - CONVZ80 - Translates various snapshot and tape formats of other - Spectrum emulators into each other. Can handle the - familiar .SNA format use by several emulators (JPP, - XZX,...), and also Pedro Gimeno's (VGASPEC and SPECTRUM) - .SP format and Kevin J. Phairs' (SPECEM) .PRG format. - It can also handle tape files of SPECEM and L. Rindt and - E. Brukner's emulator ZX. - DISCIPLE - Reads DISCiPLE and Plus D diskettes, both 3.5'' and - 5.25''. It translates the 48K and 128K snapshot files - to .Z80 snapshots, and ordinary files and screen - snapshots to .TAP tape files. (Not necessary for the - fully registered version, but handy for the cheaper - one.) - ADDDAT - Utility to edit the additional data part of .SLT - snapshot files, which contain loading screens and level - data. - Z802TAP - Converts a .Z80 snapshot, 48K or 128K, to a .TAP file - which can be loaded into the emulator and saved to tape - by the next utility: - TAP2TAPE - Saves the contents of a .TAP file back to tape, to load - it into an ordinary Spectrum. - TAP2VOC - Converts a .TAP file to a .VOC sound sample file, to - write to tape, or to load into the emulator. - READVOC - Reads in a long, 'digital' .VOC sound sample, to be used - as input to the emulator, from the LPT tape interface or - a SoundBlaster. - READSB - Reads .VOC sound samples from SoundBlaster using DMA, - and applies a digital filtering and oversampling algo- - rithm tuned for Spectrum tapes. - OUT2VOC - Converts .OUT log files into .VOC or raw sound sample - files, so that you can easily extract music samples from - Spectrum/Spectrum 128 games, or SAVE directly to a .VOC - or raw sample file. - Z80DUMP - Shows the header and the contents of a .Z80 file. - - - You will also receive the source files of both emulators, the above - utilities and the SamRam. You will also be kept informed about future - (major) updates. - - - - How to register: - ================ - - - You can register either Z80 (the DOS program), or WinZ80, or both. - Registration of Z80 or WinZ80 is BP 15; registration of both programs - at once is BP 20. If you register just one program, please indicate - clearly whether you want Z80 or WinZ80. If you specify neither, we - will assume you want the DOS program. - - For those who sent their registration fee upon reading the information - that comes with the now obsolete version 3.05, note that Z80 v4.00 - emulates the DISCiPLE in all cases; if you sent the BP 20 fee you will - receive both Z80 with DISCiPLE emulation and WinZ80. - - Please send the money in cash in British currency, or as a cheque made - payable to Chezron Software, to: - - Chezron Software - 34 Saltersgate Drive - Birstall - LEICESTER LE4 3FF - England - Email: outletmag@yahoo.com - WWW: http://www.geocities.com/SiliconValley/Orchard/3420/ - Phone/Fax: 0116 220 9651 - From abroad: +44 116 220 9651 - - If this is inconvenient, you can also send US$ 20 / US$ 25, or DM 35 / - DM 50 in cash. Please do NOT send cheques in currencies other than - British Pounds. - - - - If you are living in the Czech Republic: - ======================================== - - - Then it is probably more convenient to register with JIMAZ. Also from - neighbouring countries it may be quicker and/or cheaper to register - with them. The address is: - - JIMAZ s.r.o. - Hermanova 37 - 170 00 Praha 7 - Czech Republic - Phone: +42 2 379 498 - Fax: +42 2 378 103 - Email: jimaz@jimaz.cz - - The registration fee is Cz 500 for either program, Cz 650 for both. - - - - Are you a registered user already? - ================================== - - In that case you can obtain Z80 version 4.00 with DISCiPLE emulation, - the full WinZ80 package, and all utilities and sources, by sending BP - 10 (US$ 15, DM 25) to Chezron Software or Jimaz (see the addresses - above). Please clearly indicate the following: - - * That you apply for an update, - * Your name, - * Your current address and home country, - * If different, the address under which you registered, or last - updated, your version of Z80, - * The version of Z80 you own (e.g. 3.05 or 2.01 or ...), and - whether it emulates the DISCiPLE - - - - - All sites reserve the right to ignore any order which does not comply - with the conditions above. - - - - The tape interface - ================== - - The interface described by the circuit diagram in DIAGRAM.Z80 provides - a reliable means for loading any Spectrum program into Z80. If you - don't want to make this interface yourself, a ready built one can be - obtained through B G Services, for BP 14.50. These are professional - quality items built into 25W 'D' connectors. The address is: - - B G Services - 64 Roebuck Road - Chessington - Surrey KT9 1JX - United Kingdom - Phone: (0181) 287 4180 (from abroad: +44 181 287 4180) - Fax: (0181) 391 0744 (from abroad: +44 181 391 0744) - Email: briang@bgserv.demon.co.uk - - - - diff --git a/Docs/techinfo.doc b/Docs/techinfo.doc deleted file mode 100644 index 5530e6e..0000000 --- a/Docs/techinfo.doc +++ /dev/null @@ -1,1775 +0,0 @@ -Sinclair ZX Spectrum Emulator 'Z80' v4.00 - 6/3/99 - by G.A. Lunter - - - -5. TECHNICAL INFORMATION - - -Contents: - - 5.0 Where to find more technical info - 5.1 The Spectrum 48K - 5.2 The Spectrum 128K - 5.3 The AY-3-8912 sound chip - 5.4 The ZX Printer - 5.5 The Interface I - 5.6 The SamRam - 5.7 The Multiface 128 - 5.8 The AMX mouse interface - 5.9 The Z80 microprocessor - 5.10 File formats - - - - - - -5.0 Where to find more technical info - - - This document covers some hardware details of the Spectrum 48k and 128k - and some peripherals, and most of the file formats used Z80. If you - need something not covered in this document, it is worth checking the - Web. The comp.sys.sinclair FAQ (see z80.doc for URLs) is a good - starting point. In particular, the .TZX format description, which is - the only file format supported by Z80 which is not described in this - document, can be found at http://www.void.demon.nl/TZXformat.html. For - information on the behaviour of the Z80 from a programmer's point of - view, the document - - http://www.msxnet.org/tech/Z80/z80undoc.txt - - by Sean Young (sean@msxnet.org) is highly recommended. - - - - -5.1 The Spectrum 48K - - - In this section, the hardware of the 48K Spectrum is discussed. In this - section, 'Spectrum' by itself refers to the 48K machine only. - - The Spectrum is at the hardware level a very simple machine. There's - the 16K ROM which occupies the lowest part of the address space, and - 48K of RAM which fills up the rest. An ULA which reads the lowest 6912 - bytes of RAM to display the screen, and contains the logic for just one - I/O port completes the machine, from a software point of view at least. - - Every even I/O address will address the ULA, but to avoid problems with - other I/O devices only port FE should be used. If this port is written - to, bits have the following meaning: - - - Bit 7 6 5 4 3 2 1 0 - ┌───┬───┬───┬───┬───┬───┬───┬───┐ - │ │ │ │ E │ M │ Border │ - └───┴───┴───┴───┴───┴───┴───┴───┘ - - - The lowest three bits specify the border colour; a zero in bit 3 - activates the MIC output, and a one in bit 4 activates the EAR output - (which sounds the internal speaker). The real Spectrum also activates - the MIC when the ear is written to; the emulator doesn't. This is no - problem; MIC is only used for saving, and when saving the Spectrum - never sounds the internal speaker. The upper three bits are unused. - - If port FE is read from, the highest eight address lines are important - too. A zero on one of these lines selects a particular half-row of - five keys: - - IN: Reads keys (bit 0 to bit 4 inclusive, in that order) - - #FEFE SHIFT, Z, X, C, V #EFFE 0, 9, 8, 7, 6 - #FDFE A, S, D, F, G #DFFE P, O, I, U, Y - #FBFE Q, W, E, R, T #BFFE ENTER, L, K, J, H - #F7FE 1, 2, 3, 4, 5 #7FFE SPACE, SYM SHFT, M, N, B - - A zero in one of the five lowest bits means that the corresponding key - is being pressed. If more than one address line is made low, the - result is the logical AND of all single inputs, so a zero in a bit - means that at least one of the corresponding keys are pressed. For - example, only if each of the five lowest bits of the result from - reading from port 00FE (for instance by XOR A/IN A,(FE)) is one, no key - is pressed. - - A final remark about the keyboard. It is connected in a matrix-like - fashion, with 8 rows of 5 columns, as is obvious from the above - remarks. Any two keys pressed simultaneously can be uniquely decoded - by reading from the IN ports; however, if more than two keys are - pressed decoding may not be uniquely possible. For instance, if you - press Caps shift, B and V, the Spectrum will think also the Space key - is pressed, and reacts by giving the 'Break into Program' report. This - matrix behaviour is also emulated - without it, Zynaps for instance - won't pause when you press 5,6,7,8 and 0 simultaneously. - - Bit 6 (value 64) of IN-port FE is the ear input bit. When the line is - silent, its value is zero, except in the early Model 2 of the Spectrum, - where it was one. When there is a signal, this bit toggles - accordingly. The Spectrum loading software is not sensitive to the - polarity of this bit (which it definitely should not be, not only - because of this model difference, but also because one cannot be sure - the tape recorder does not change the polarity of the recorded signal!) - Some old programs rely on the fact that bit 6 is always one (for - instance Spinads); for these programs the emulator can mimic a Model 2 - Spectrum. - - Bits 5 and 7 are always one (except in some clones; Einar Gattoni - Saukas told me that the TK-90X sets bit 7 to 0.) - - The ULA with the lower 16K of RAM, and the processor with the upper 32K - RAM and 16K ROM are working independently of each other. The data and - address buses of the Z80 and the ULA are connected by small resistors; - normally, these effectively decouple the buses. However, if the Z80 - wants to read of write the lower 16K, the ULA halts the processor if it - is busy reading, and after it's finished it lets the processor access - lower memory through the resistors. A very fast, cheap and neat design - indeed! - - If you run a program in the lower 16K of RAM, or read or write in that - memory, the processor is halted sometimes. This part of memory is - therefore somewhat slower than the upper 32K block. This is also the - reason that you cannot write a sound- or save-routine in lower memory; - the timing won't be exact, and the music will sound harsh. Also, - INning from port FE will halt the processor, because the ULA has to - supply the result. Therefore, INning from port FE is a tiny bit slower - on average than INning from other ports; whilst normally an IN A,(nn) - instruction would take 11 T states, it takes 12.15 T states on average - if nn=FE. See below for more exact information. - - If the processor reads from a non-existing IN port, for instance FF, - the ULA won't stop, but nothing will put anything on the data bus. - Therefore, you'll read a mixture of FF's (idle bus), and screen and - ATTR data bytes (the latter being very scarce, by the way). This will - only happen when the ULA is reading the screen memory, 61.5% (192/312) - of the 1/50th second time slice in which a frame is generated. The - other 38.5% of the time the ULA is building the border or generating a - vertical retrace. This behaviour is actually used in some programs, - for instance by Arkanoid, and Z80 also emulates this. - - Finally, there is an interesting bug in the ULA which also has to do - with this split bus. After each instruction fetch cycle of the - processor, the processor puts the I-R register 'pair' (not the 8 bit - internal Instruction Register, but the Interrupt and R registers) on - the address bus. The lowest 7 bits, the R register, are used for - memory refresh. However, the ULA gets confused if I is in the range - 64-127, because it thinks the processor wants to read from lower 16K - ram very, very often. The ULA can't cope with this read-frequency, and - regularly misses a screen byte. Instead of the actual byte, the byte - previously read is used to build up the video signal. The screen seems - to be filled with 'snow'; however, the Spectrum won't crash, and - program will continue to run normally. There's one program I know of - that uses this to generate a nice effect: Vectron. (which has very - nice music too by the way). This effect has not been implemented - however - it's a bit useless (but maybe I'll include it in the future). - - The processor has three interrupt modes, selected by the instructions - IM 0, IM 1 and IM 2. In mode 1, the processor simply executes a RST - #38 instruction if an interrupt is requested. This is the mode the - Spectrum is normally in. The other mode that is commonly used is IM 2. - If an interrupt is requested, the processor first builds a 16 bit - address by combining the I register (as the high byte) with whatever - the interrupting device places on the data bus. The processor then - fetches the 16-bit address at this interrupt table entry, and finally - CALLs the subroutine at that address. Rodnay Zaks in his book - 'Programming the Z80' states that only even bytes are allowed as low - index byte, but that isn't true. The normal Spectrum contains no - hardware to place a byte on the bus, and the bus will therefore always - read FF (because the ULA also doesn't read the screen if it generates - an interrupt), so the resulting index address is 256*I+0FF. However, - some not-so-neat hardware devices put things on the data bus when they - shouldn't, so later programs didn't assume the low index byte was 0FF. - These programs contain a 257 byte table of equal bytes starting at - 256*I, and the interrupt routine is placed at an address that is a - multiple of 257. A useful but not so much used trick is to make the - table contain FF's (or use the ROM for this) and put a byte 18 hex, the - opcode for JR, at FFFF. The first byte of the ROM is a DI, F3 hex, so - the JR will jump to FFF4, where a long JP to the actual interrupt - routine is put. - - In interrupt mode 0, the processor executes the instruction that the - interrupting device places on the data bus. On a standard Spectrum - this will be the byte FF, coincidentally (...) the opcode for RST #38. - But for the same reasons as above, this is not really reliable. - - The 50 Hz interrupt is synchronized with the video signal generation by - the ULA; both the interrupt and the video signal are generated by it. - Many programs use the interrupt to synchronize with the frame cycle. - Some use it to generate fantastic effects, such as full-screen - characters, full-screen horizon (Aquaplane) or pixel colour (Uridium - for instance). Many modern programs use the fact that the screen is - 'written' (or 'fired') to the CRT in a finite time to do as much - time-consuming screen calculations as possible without causing - character flickering: although the ULA has started displaying the - screen for this frame already, the electron beam will for a moment not - 'pass' this-or-that part of the screen so it's safe to change something - there. So the exact time in the 1/50 second time-slice at which the - screen is updated is very important. Normally the emulator updates the - entire screen at once (50 times a second), and no best solution can be - given as to when exactly the screen should be updated. The user can - select one of three possibilities (low, normal and high video - synchronisation, corresponding to a screen update after 1/200, 2/200 or - 3/200 of a (relative) second after a Z80 interrupt) to try to get the - best results. Try for instance Zynaps; with normal video - synchronisation the top four or five lines of the background move - out-of-phase with the rest, and your space-ship flickers in that - region. With low video synchronisation the background moves smoothly - but the sprites flicker in all parts of the screen. Only with high - video sync everything moves smoothly and doesn't flicker. - - In Hi-resolution colour emulation mode, however, the emulator makes a - copy of every screen- and attribute-line in a buffer at the exact time - the ULA would display it. Also, the exact times the border colour is - changed is stored. Using this information the emulator builds the - screen; in this way, what you see on your PC monitor is exactly what a - real Spectrum would display on a television. Remember Aquaplane, with - its full-width horizon? - - Each line takes exactly 224 T states. After an interrupt occurs, 64 - line times pass before the byte 16384 is displayed. At least the last - 48 of these are actual border-lines. I could not determine whether my - monitor didn't display the others or whether it was in vertical - retrace, but luckily that's not really important. Then the 192 - screen+border lines are displayed, followed by 56 border lines again. - This makes a total of 312 lines of 224 T states, or 69888 T states, - which is, at 3.5 MHz, very nearly 1/50th of a second. - - Now for the timings of each line itself. Let's define a screen line to - start with 256 screen pixels, then border, then horizontal retrace, and - then border again. All this takes 224 T states. Every half T state a - pixel is written to the CRT, so if the ULA is reading bytes it does so - each 4 T states (and then it reads two: a screen and an ATTR byte). The - border is 48 pixels wide at each side. A video screen line is - therefore timed as follows: 128 T states of screen, 24 T states of - right border, 48 T states of horizontal retrace and 24 T states of left - border. - - When an interrupt occurs, the running instruction has to be completed - first. The Z80 samples the state of its interrupt request line at the - start of the last T state of each instruction. The Z80 starts to act - upon an interrupt request at least 1, and at most 1+23 T states after - it is made active, as the slowest instructions (e.g. INC (IX+d), RL - (IX+d), EX (SP),IX) take 23 T states). This difference, which may be - hard to control, is sometimes significant in practice for hi-resolution - colour effects. When the Z80 is executing a HALT instruction, it is - effectively executing NOPs and not incrementing the PC until an - interrupt is received (and interrupts are enabled). As a NOP takes 4 - clocks to execute, in this case the start of the interrupt is fixed up - to 4 T states. - - In all interrupt modes, the interrupt acknowledge cycle is basically an - ordinary M1 instruction fetch cycle with two wait states added, taking - up 5 T states. Then, in mode 0, any instruction that is placed on the - bus in the acknowledge cycle is executed, whereas in mode 1 this is - always RST #38. The Spectrum ordinarily leaves the bus floating at - interrupt time, so that in mode 0 also a RST #38 (opcode #FF) is - executed. A RST #38 normally takes 11 T states, so that the complete - mode 0 or 1 (or 0/1) interrupt takes 13 T states. (Thanks to Ian - Collier for correcting me here the FAQ version.) - - A mode 2 interrupt starts off with a 7 T state M1 cycle in which the - interrupt vector is read, followed by two stack-write cycles of 3 T - states each in which the program counter is pushed, and two memory-read - cycles of 3 T's each that read the interrupt address. That is 19 T's. - - Ian Collier states that an NMI cycle takes 15 T states. My reference - (Mostek Technical Manual of the Z80) breaks it down as follows: a 5 T - M1 cycle in which the opcode is ignored, then two 3-T stack-write - cycles to push the program counter, which adds up to 11 T states. I - haven't done any testing, so I cannot say anything definite here. - - The ZX81 hardware generates a WAIT only 16 T states before it generates - an NMI, which, by some combined hardware and software wizardry, - generates one scanline on the television screen. It seems therefore - that by executing a whole lot of slow instructions in a block, it is - possible to jam the horizontal synchonisation of the ZX81 video signal. - Has this ever been tried? - - Now when to OUT to the border to change it at the place you want? - First of all, you cannot change the border within a 'byte', an 8-pixel - chunk. If we forget about the screen for a moment, if you OUT to port - FE after 14326 to 14329 T states (including the OUT) from the start of - the IM 2 interrupt routine, the border will change at exactly the - position of byte 16384 of the screen. The other positions can be - computed by remembering that 8 pixels take 4 T states, and a line takes - 224 T states. You would think that OUTing after 14322 to 14325 T - states, the border would change at 8 pixels left of the upper left - corner of the screen. This is right for 14322, 14323 and 14324 T - states, but if you wait 14325 T states the ULA happens to be reading - byte 16384 (or 22528, or both) and will halt the processor for a while, - thereby making you miss the 8 pixels. This exception happens again - after 224 T states, and again after 448, an so forth. These 192 - exceptions left of the actual screen rectangle are the only ones; - similar things don't happen at the right edge because the ULA don't - need to read things there - it has just finished! - - As noted above, reading or writing in low ram (or OUTing to the ULA!) - causes the ULA to halt the processor. When and how much? The - processor is halted each time you want to access the ULA or low memory - and the ULA is busy reading. Of the 312 'lines' the ULA generates, - only 192 contain actual screen pixels, and the ULA will only read bytes - during 128 of the 224 T states of each screen line. But if it does, - the processor seems to be halted for 64 T states. It is not clear to - me when, and for how long exactly, the ULA halts the processor. - Sometimes the ULA even stops the processor when it is not interfering - with it (when it is busy making the border left or right of the screen - rectangle). - - For 128K timings, which are slightly different, see the next section. - - - - -5.2 The Spectrum 128K - - - In comparison to the Spectrum 48K, and on the hardware side, the - Spectrum 128 offers more RAM (128K, you guessed it), more ROM (32K - instead of 16K), a soundchip, and a serial printer port. Nothing - really spectacular. - - Another difference with the 48K Spectrum is in the timing of the video - signals. You can see this if you save something: the bars in the - border move differently. The really important difference of the 128K - with respect to the video is that the 128K ULA is more relaxed in - giving the Z80 access to (screen) memory. This allows programs to make - hi-resolution colour effects not only in the border, but also on the - screen itself. Many 128K programs use this effect. Note however that, - although the 128K ULA is more relaxed towards memory access, it does - still halt the Z80 occasionally. Partly for this reason it is - impossible to have hi-res colour effect over the entire screen; there is - only time to change approximately half of it. (This does not seem to - be true; the Shock Megademo manages to move 1-pixel thick lines up on - the screen one pixel per frame on the whole screen. Very well done - indeed! This is the only program I know to feature hi-res colour effect - over the entire width of the screen. It might be, however, that this - program only changes the entire ATTR line every two scan line times.) - - The basic video timings, with the Z80 out of the way, are as follows. - Each video line takes 228 T states, 4 T states more than on the 48K - Spectrum. It starts with 128 T states of screen pixels (or border). - Then there's border, horizontal retrace and border again, of 100 T - states. A complete '50 Hz' frame consists of 311 video lines (of which - a few are vertical retraces), that is, 1 less than for 48K models. A - complete frame is 311 x 228 = 70908 T states long. - - I don't know whether the 128K model uses a different crystal. If not, - one frame on the Spectrum 128K is 1.5% longer than a 48K frame. - - A quote from the +2 manual, page 279; Cliff Lawson writes: "For the - contended RAM [pages 4-7] (which shares time between the video - circuitry and the processor), during 128 out of every 228 CPU T states - (1 TV line), and during 192 out of every 311 TV lines (1 frame) the CPU - is allowed only 1 access to contended RAM in every 8 T states. The CPU - is controlled by introducing wait states". My guess is this holds true - for the 128K too. - - Directly after an interrupt is generated by the ULA (so slightly before - the Z80 acts upon it), 63 video lines are written to the CRT. A first - few may be verical retraces; this is difficult to find out without an - oscilloscope, but luckily we don't need this information. Then 192 - screen lines are written, and then 56 border lines and (possibly) - vertical retrace lines. The first screen byte is written to the screen - 14364 T states after the interrupt was generated. - - Then the other things. Memory is arranged in banks of 16K. The bank - at 0000-3FFF contains either the original 48K ROM or the new 128K ROM. - The latter is active at reset. The bank at 4000-7FFF always contains - RAM page 5. The bank at 8000-BFFF is always page 2. The bank at - C000-FFFF contains any page from 0-7, including page 2 and 5. If page - 2 or 5 is enabled in the high bank, every byte written in this bank is - mirrored in the other bank at 4000 or at 8000, and vice versa. The - screen information is read, by the ULA, from the first 6912 bytes of - either page 5 or page 7. - - All this is controlled by writing to port 7FFD (or, in fact, by writing - to any address with bit 15 and 1 zero; don't use this fact, though; it - does not work on the +3, where there's another port 1FFD, and neither - will this work in full generality on the emulator.) - - - Port #7FFD: - - Bit 7 6 5 4 3 2 1 0 - ┌───┬───┬───┬───┬───┬───┬───┬───┐ - WRITE│ │ │ P │ R │ S │ page no │ - └───┴───┴───┴───┴───┴───┴───┴───┘ - - - Bits 0-2 determine which page is to appear in bank C000-FFFF. If S=0, - the ULA reads the screen from page 5, otherwise it reads page 7. If - R=0, the 128K Rom is selected in bank 0000-3FFF; otherwise the 48K Rom. - If P=1, port #7FFD will be disabled and keep its value until the - computer is reset. This bit is set if you select 48K Spectrum in the - 128K startup menu, so that no 48K program is able to (accidentally) - swap itself into oblivion. - - The sound chip of the Spectrum 128 is described in the next section. - - - - -5.3 The AY-3-8912 sound chip. - - - The following section was put together using information collected from - comp.sys.sinclair. Thanks, and large parts of the information below, - are due to Alastair Booker, who put a detailed description on the net - in April '95, and to Ian Collier who recently carried out some thorough - investigations on the AY chip. - - This chip is used in for instance the Sinclair ZX Spectrum 128/+2/+3, - Amstrad CPC 464/664/6128, Mattel Intellivision, Atari ST, Sega Master - System and the MSX. - - The AY has 16 internal registers. A register is selected by OUTing the - register number in bits 0-3 to port #FFFD (only A15, A14 and A1 are - decoded). Then write to a register by OUTing to #BFFD, read it by - INning from #FFFD. When reading from a register, unused bits are - always 0. Reading always yields the value last written to the - register, except for R14 and R15 when bit 6 or 7 of R7 are reset (R14 / - R15 used for input). On the AY-3-8912, when R7 bit 7 is reset, R15 - always reads 255. Writing to R14 or R15 when they are selected for - input does load the output register. - - Here are the names of the AY registers: - - Register Name Bits used: - - R0 Fine tone control (FTC) channel A 0-7 - R1 Coarse tone control (CTC) channel A 0-3 - R2 FTC channel B 0-7 - R3 CTC channel B 0-3 - R4 FTC channel C 0-7 - R5 CTC channel C 0-3 - R6 Noise generator pitch control 0-4 - R7 Mixer and I/O control 0-7 - R8 Amplitude channel A 0-4 - R9 Amplitude channel B 0-4 - R10 Amplitude channel C 0-4 - R11 Envelope fine period control 0-7 - R12 Envelope coarse period control 0-7 - R13 Envelope control 0-3 - R14 RS232 i/o 0-7 - R15 I/O port 2 0-7 - - The AY chip consists of three tone generators, one noise generator, an - envelope generator, three mixers, and three volume generators. - - Tone generator A is controlled by R0 and R1. It contains a 12 bit up - counter which is reset to 0 whenever it is larger than or equal to the - value of R1R0 (most significant bits are in R1), and is counted up at a - frequency of 221660 Hz (which is the driving frequency of the chip - divided by 8). Loading R0 or R1 takes effect directly. If the internal - counter is below the new value, it simply continues; if it is above, it - immediately resets to 0. Every time the internal counter is reset, the - tone generator changes it output from 0 to 1 or vice versa, so the - frequency of the tone generated is 110830/R1R0 Hz (one period consists - of two transitions). If R1R0 contains 0, the counter behaves as if R1R0 - contained 1. - - The noise generator contains a 5 bit up counter, which is reset to 0 - whenever it is >= R6. It is counted up at a frequency of 110830 Hz - (driving frequency divided by 16) [1]. Every time it reaches zero, it - randomly chooses 0 or 1 as its new output [2]. When R6 is zero, the - noise generated is the same as when R6 is 1. Changes to R6 take effect - only when the internal counter reaches 0. - - - Bit 7 6 5 4 3 2 1 0 - ┌────┬────┬────┬────┬────┬────┬────┬────┐ - R7 │ D2 │ D1 │ Nc │ Nb │ Na │ Tc │ Tb │ Ta │ - └────┴────┴────┴────┴────┴────┴────┴────┘ - - - If D1 is 1, R14 acts as output register (RS232 output: bit 2 is CTS, - bit 3 is data output); when it is 0 R14 acts as input register (bit 6 - is DTR [3]). D2 is ignored as the AY chip has only one I/O register; - the bit and its corresponding register are present however. Reading - R15 in input mode always yields 255. Changes made to R7 take effect - immediately. - - The noise and tone output of a channel is combined in the mixer in the - following way: - - Output_A = (Tone_A OR Ta) AND (Noise OR Na) - - Here Tone_A is the binary output of tone generator A, and Noise is the - binary output of the noise generator. Note that setting both Ta and Na - to 1 produces a constant 1 as output. Also note that setting both Ta - and Na to 0 produces bursts of noise and half-periods of constant - output 0. - - Each binary tone channel output is fed to a separate volume generator. - Each volume generator is controlled by its amplitude register (R8 for - channel A) and the 4-bit output of the envelope controller. - - - Bit 7 6 5 4 3 2 1 0 - ┌────┬────┬────┬────┬────┬────┬────┬────┐ - R8 │ │ │ │ Ev │ V3 │ V2 │ V1 │ V0 │ - └────┴────┴────┴────┴────┴────┴────┴────┘ - - - If Ev=0, the current volume is given by V3V2V1V0. If Ev=1, the current - volume is given by the output of the envelope generator. The volume - controller produces an output voltage proportional to its channel's - binary output value times the current volume. These analogue outputs - are then added together to give the final output (this is done outside - the chip actually). Note that even when a channel is disabled (say Ta - = Na = 1), changing the volume level changes the final output, as the - binary tone channel output is constant and equal to 1, not 0. Changes - to the amplitude registers take effect immediately. - - The envelope generator is controlled by R11, R12 and R13. - - - Bit 7 6 5 4 3 2 1 0 - ┌──┬──┬──┬──┬──────────┬────────┬───────────┬──────┐ - R13 │ │ │ │ │ Continue │ Attack │ Alternate │ Hold │ - └──┴──┴──┴──┴──────────┴────────┴───────────┴──────┘ - - - The envelope generator contains a 16-bit up counter, operated at a - frequency of 110830 Hz. The lowest frequency attainable by the - envelope clock is therefore 1.7 Hz. If R12R11 contains 0, the clock - runs at 110830 Hz; otherwise it runs at 110830/R12R11 Hz. The envelope - generator is reset by writing to R13 (but not by writing to R11 or - R12); otherwise it works just as the other counters. - - Each time the envelope generator up counter is reset, it produces a - envelope clock tick. A 'period' is the time taken by 16 clock ticks. - The output of the envelope generator during the first period is as - follows. If Attack = 1, the output starts off at 0 and at each clock - tick is increased by 1 until it reaches 15. If Attack = 0, the output - starts off at 15 and is falls to 0. - - The output in the subsequent periods is 0 if Continue = 0. Otherwise, - first the (internal) 'Attack' bit is toggled if Alternate is set, - otherwise it doesn't change. How if Hold = 1, the output is a constant - 15 in this and subsequent periods if Attack = 1, otherwise it is a - constant 0. If Hold = 0, the envelope generator behaves just as in the - first period (except that Attack has possibly changed). To sum it up: - - - 0,1,2,3 \__________ single decay then off - - 4,5,6,7 /|_________ single attack then off - - 8 \|\|\|\|\|\ repeated decay - - 9 \__________ single decay then off - - 10 \/\/\/\/\/\ repeated decay-attack - _________ - 11 \| single decay then hold - - 12 /|/|/|/|/|/ repeated attack - __________ - 13 / single attack then hold - - 14 /\/\/\/\/\/ repeated attack-decay - - 15 /|_________ single attack then off - - - If the envelope generator is used to generate a tone, its frequency is - either 110830/(16*R12R11) Hz (R13 = 8 or 12) or 110830/(32*R12R11) Hz - (R13 = 10 or 14). - - - [1] This has been checked by Pierre Guerrier using an oscilloscope. - [2] The algorithm used for the pseudo random output is not known. It - seems not to be too good, as sounds vaguely similar to tape loading - sounds are audible if you set R6 to 31. - [3] I don't know which bit is data input; it is probably not bit 3. - - - - -5.4 The ZX Printer - - - As always, how very Sinclair, this is a simple but ingenious piece of - equipment. The ZX Printer is controlled through one I/O port, namely - #FB. It is decoded using A2 only. Port #FB: - - - Bit 7 6 5 4 3 2 1 0 - ┌────┬────┬────┬────┬────┬────┬────┬────┐ - READ │styl│ 0 │ │ │ │ │ │ enc│ - └────┴────┴────┴────┴────┴────┴────┴────┘ - - ┌────┬────┬────┬────┬────┬────┬────┬────┐ - WRITE │Data│ │ │ │ │ Mot│Slow│ │ - └────┴────┴────┴────┴────┴────┴────┴────┘ - - - To print, first read port #FB and check that bit 6 is 0 to make sure - that the printer is attached. The printer motor is started by writing - a byte 0 to #FB (Mot=0). Then check bit 7 until it goes high; this - means that the printer head is in the starting position. A line is - printed as follows. Wait for bit 0 (encoder) to go high, and write a - bit of data (1=black dot), and do this 256 times. The Spectrum ROM - makes the 'Slow' bit 1 in the last two lines; this ensures that the - printer head stops at the start of the new line, instead of halfway - into it. Stop the printer by writing a byte 4. See #0EF4 in the ROM - for the relevant routine. - - The emulator returns #FF on a port #FB IN if there is no printer - attached to the LPT port selected for ZX Printer output. If the - printer is off-line, busy, or out of paper, the emulator will usually - return #FF too, so that the Spectrum program will not even consider to - print, unless you set option -xj. In that case the emulator returns 1 - so that the program will try to print, and will wait for the printer to - go on line. The reason for including the -xj switch is that usually - the status lines of the printer are not too reliable, so that a - Spectrum program may halt on a COPY statement even if there's no - printer attached (e.g. with SuperSpy, which makes screendumps on the ZX - Printer without asking). In the inner printing loop, the ROM does not - check for BREAKs, so that the encoder bit is always high to prevent - locking the emulated Spectrum. If the printer is happy to accept data, - the emulator returns #81. - - - - -5.5 The Interface I - - - The Interface I is quite complicated. It uses three different I/O - ports, and contains logic to page and unpage an 8K ROM if new commands - are used. I won't be very detailed here; you could refer to the source - code of the emulator if you want to know some details, or read the - 'Spectrum Shadow ROM Disassembly' by Gianlura Carri, published by - Melbourne House - but don't expect the same level of detail as of Ian - Logan and Frank O'Hara in their Rom disassembly book. - - The ROM is paged if the processor executes the instruction at ROM - address 0008 or 1708 hexadecimal, the error and close# routines. It is - inactivated when the Z80 executes the RET at address 0700. - - I/O Port E7 is used to send or receive data to and from the microdrive. - Accessing this port will halt the Z80 until the Interface I has - collected 8 bits from the microdrive head; therefore, it the microdrive - motor isn't running, or there is no formatted cartridge in the - microdrive, the Spectrum hangs. This is the famous 'IN 0 crash'. - - Port EF is used for several things: - - - Bit 7 6 5 4 3 2 1 0 - ┌───┬───┬────┬────┬─────┬───┬─────┬─────┐ - READ│ │ │ │busy│ dtr │gap│ sync│write│ - │ │ │ │ │ │ │ │prot.│ - ├───┼───┼────┼────┼─────┼───┼─────┼─────┤ - WRITE│ │ │wait│ cts│erase│r/w│comms│comms│ - │ │ │ │ │ │ │ clk │ data│ - └───┴───┴────┴────┴─────┴───┴─────┴─────┘ - - - Bits DTR and CTS are used by the RS232 interface. The WAIT bit is used - by the Network to synchronise, GAP, SYNC, WR_PROT, ERASE, R/_W, COMMS - CLK and COMMS DATA are used by the microdrive system. If the - microdrive is not being used, the COMMS DATA output selects the - function of bit 0 of out-port F7: - - - Bit 7 6 5 4 3 2 1 0 - ┌──────┬───┬───┬───┬───┬───┬───┬───────────┐ - READ│txdata│ │ │ │ │ │ │ net │ - │ │ │ │ │ │ │ │ input │ - ├──────┼───┼───┼───┼───┼───┼───┼───────────┤ - WRITE│ │ │ │ │ │ │ │net output/│ - │ │ │ │ │ │ │ │ rxdata │ - └──────┴───┴───┴───┴───┴───┴───┴───────────┘ - - - TXDATA and RXDATA are the input and output of the RS232 port. COMMS - DATA determines whether bit 0 of F7 is output for the RS232 or the - network. - - - - -5.6 The SamRam - - - The SamRam contains a 32K static CMOS Ram chip, and some I/O logic for - port 31. If this port is read, it returns the position of the - joystick, as a normal Kempston joystickinterface would. If written to, - the port controls a programmable latch chip (the 74LS259) which - contains 8 latches: - - - Bit 7 6 5 4 3 2 1 0 - ┌───┬───┬───┬───┬───┬───┬───┬───┐ - WRITE│ │ │ │ │ address │bit│ - └───┴───┴───┴───┴───┴───┴───┴───┘ - - - The address selects on of the eight latches; bit 0 is the new state of - the latch. The 16 different possibilities are collected in the diagram - below: - - OUT 31, │ Latch │ Result - ──────────┼─────────┼──────────────────────────────────────── - 0 │ 0 │ Switch on write protect of CMOS RAM - 1 │ " │ Writes to CMOS RAM allowed - 2 │ 1 │ turn on CMOS RAM (see also 6/7) - 3 │ " │ turn off CMOS RAM (standard Spec. ROM) - 4 │ 2 │ - - 5 │ " │ Ignore all OUT's to 31 hereafter - 6 │ 3 │ Select CMOS bank 0 (Basic ROM) - 7 │ " │ Select CMOS bank 1 (Monitor,...) - 8 │ 4 │ Select interface 1 - 9 │ " │ Turn off IF 1 (IF1 rom won't be paged) - 10 │ 5 │ Select 32K ram bank 0 (32768-65535) - 11 │ " │ Select 32K ram bank 1 (32768-65535) - 12 │ 6 │ Turn off beeper - 13 │ " │ Turn on beeper - 14 │ 7 │ - - 15 │ " │ - - - At reset, all latches are 0. If an OUT 31,5 is issued, only a reset - will give you control over the latches again. The write protect latch - is not emulated; you're never able to write the emulated CMOS ram in - the emulator. Latch 4 pulls up the M1 output at the expansion port of - the Spectrum. The Interface I won't page its ROM anymore then. - - - - -5.7 The Multiface 128 - - - This device consists of an 8K rom, paged into the area 0-8191, and 8K - of ram, paged into 8192-16383, and a latch storing the screen select - bit of the Spectrum 128K (bit 3 of OUT-port #7FFD), which would - otherwise be impossible get hold of (the Disciple requires the user to - press Y or N according to whether the screen changed at some point of - the snapshot procedure, in order to get hold of this bit.) The - Multiface 128 also works on 48K machines. - - The Multiface rom and ram pages have highest priority, higher than both - the ordinary rom (48K or 128K) or the Interface 1, Disciple or Plus D - roms. If the Multiface rom is selected, the Spectrum and peripherals - behave as they did before, but the bytes the Z80 sees are always the - Multiface rom+ram. - - The Multiface memory is paged in when an NMI occurs, or when the - processor reads from IN address #BF. Bit 7 of the returned byte is the - screen select bit (or, on 48K machines, the value of bit 3 of the byte - last written to port #7FFD - unlikely to be useful.) Other bits follow - the floating bus. - - Note that an NMI also pages the Disciple rom, but as the Multiface - takes precedence, the Multiface routines are executed. In fact, it - seems that the Disciple rom is not paged at all (but possibly the - Multiface routines page it out themselves). - - The Multiface memory is paged out by reading from port #3F. The - Multiface does not put bits on the bus. - - - -5.8 The AMX mouse interface - - - The only program I know of that uses the AMX mouse is Art Studio, but - it's so good that it by itself is enough reason for implementing the - AMX mouse interface. - - The AMX interface uses a Z80-PIO (programmable In/Out Interface). - This chip is fairly complicated, and can operate in several modes. The - AMX interface only uses mode 1 (no connection with IM 1 by the way), so - this is the only mode that is emulated. The following discussion - applies to mode 1 only, and refers to the I/O addresses as used by the - AMX mouse interface. - - The PIO contains two 8-bit interrupt vector registers (VECA and VECB), - two 2-bit mode registers (MODEA and MODEB), two 8-bit data registers - (DATAA and DATAB), and two 1-bit interrupt-enable latches (IEA and - IEB). The data registers can be read at any time through IN ports #1F - and #3F respectively. (Note that #1F is also used by the Kempston - joystick interface, and also by the Disciple interface, and that #3F is - also used by the Multiface.) The other registers cannot be read, only - set, through the write-only control register CTRLA and CTRLB, accessed - via OUT port #5F and #7F respectively: - - - Bit 7 6 5 4 3 2 1 0 - ┌───┬───┬───┬───┬───┬───┬───┬───┐ - WRITE│ interrupt vector │ 0 │ Set interrupt vector - └───┴───┴───┴───┴───┴───┴───┴───┘ - - - Bit 7 6 5 4 3 2 1 0 - ┌────┬───┬───┬───┬───┬───┬───┬───┐ - WRITE│ IE │ x │ x │ x │ 0 │ x │ x │ 1 │ Set IE latch - └────┴───┴───┴───┴───┴───┴───┴───┘ - - - Bit 7 6 5 4 3 2 1 0 - ┌───┬───┬───┬───┬───┬───┬───┬───┐ - WRITE│ MODE │ x │ x │ 1 │ 1 │ 1 │ 1 │ Set PIO mode - └───┴───┴───┴───┴───┴───┴───┴───┘ - - - If IEA or IEB are set (1), the corresponding interrupt sequences will - generate interrupts when prompted by the hardware, and put the - corresponding interrupt vector on the data bus at interrupt time. In - Z80 Interrupt mode 2, this will then be used as a vector. Note that - bit 0 of the vector byte is always 0. Z80 only emulates PIO mode 1 - behaviour (bit 7=0, bit 6=1 when setting PIO mode), and won't do - anything if the mode is set differently. - - The AMX interface generates an A interrupt for each 'mickey' the mouse - produces in the X direction, and a B interrupt for each mickey in the - Y direction. The sign of the direction is stored as a 0 (positive) or - 1 (negative) in the respective data registers. - - One additional port, IN port #DF, reads out the mouse button status. - It returns #FF or #00. - - The AMX is emulated as follows. At every 50 Hz frame, the mouse status - is checked, and a PIO interrupt is emulated if necessary. The IRET - instruction is trapped, and if caught, more PIO interrupts are emulated - if necessary, after actually executing the IRET, with a maximum of 32 - interrupts per frame per coordinate. Care is taken to execute the 50 - Hz frame interrupt as well. This latter interrupt can be distinguished - from PIO interrupts by the fact that it puts a #FF on the bus. It was - also necessary to take care of cases where the first instruction - executed after a RETI was a HALT, which is then skipped. It seems - that the PIO leaves the Z80 in peace for a few clock cycles after - seeing a RETI, before generating another interrupt. - - A reset signal causes the IE latches of the PIO to reset. - - - -5.9 The Z80 microprocessor - - - The Z80 processor is quite straightforward, and contains to my - knowledge no interesting bugs or quirks. However, it has some - undocumented features. Some of these are quite useful, and some are - not, but since many programs use the useful ones, and a few programs - use the weird ones, I tried to figure them out and emulate them as best - as I could. There is a Z80 emulator around, intended as a CP/M - emulator, which halts the program if an undocumented opcode is - encountered. I don't think this makes sense. ZiLOG doesn't dictate - the law, the programs which use the processor's features do! - - In section 5.1 there is some information on Z80 interrupt timings in - different modes. - - Most Z80 opcodes are one byte long, not counting a possible byte or - word operand. The four opcodes CB, DD, ED and FD are 'shift' opcodes: - they change the meaning of the opcode following them. - - There are 248 different CB opcodes. The block CB 30 to CB 37 is - missing from the official list. These instructions, usually denoted by - the mnemonic SLL, Shift Left Logical, shift left the operand and make - bit 0 always one. Bounder and Enduro Racer use them, to name just two. - The SamRam monitor can disassemble these and uses the mnemonic SLL. - These instructions are quite commonly used. - - The DD and FD opcodes precede instructions using the IX and IY - registers. If you look at the instructions carefully, you see how they - work: - - 2A nn LD HL,(nn) - DD 2A nn LD IX,(nn) - 7E LD A,(HL) - DD 7E d LD A,(IX+d) - - A DD opcode simply changes the meaning of HL in the next instruction. - If a memory byte is addressed indirectly via HL, as in the second - example, a displacement byte is added. Otherwise the instruction - simply acts on IX instead of HL. (A notational awkwardness, that will - only bother assembler and disassembler writers: JP (HL) is not - indirect; it should have been denoted by JP HL.) If a DD opcode - precedes an instruction that doesn't use the HL register pair at all, - the instruction is executed as usual. However, if the instruction uses - the H or L register, it will now use the high or low halves of the IX - register! Example: - - 44 LD B,H - FD 44 LD B,IYh - - These types of unofficial instructions are used in many programs. By - the way, many DD or FD opcodes after each other will effectively be - NOPs, doing nothing except repeatedly setting the flag 'treat HL as IX' - (or IY) and taking up 4 T states. Note that the FD or DD 'opcode' is - treated as part of an instruction, so that the Z80 cannot be interrupted - during execution of such a block. (This last remark was not checked; - it was remarked by someone on comp.sys.sinclair) - - When (parts of) HL are used both as source and target, above rule is - ambiguous. The special cases are: LD H,(IX+d) and LD L,(IX+d), and - LD IXl,IXl / LD IXl,IXh / LD IXh,IXl / LD IXh,IXh. Things like - LD IXh,(IX+d) or LD H,IXh do not exist. - - Two instructions do not obey the DD/FD rule. They are EX DE,HL and - EXX. These instructions take 4 T states to execute, and are therefore - most probably implemented by toggling a flag that changes the reference - to the registers; no data is actually being moved, which explains why - they cannot operate on IX or IY. - - The doubly-shifted opcodes that start with DD CB and DD ED also do not - follow the standard rule. If a DD or FD precedes an ED instruction, - it is ignored. ED instructions never operate on the IX or IY register. - With CB instructions, the situation is more interesting. Every DD CB - instruction operates on (IX+nn), but also copies the result to the - specified register, except when it is (HL). For example, - - CB CE SET 0,(HL) - CB C0 SET 0,B - DD CB nn CE SET 0,(IX+nn) - DD CB nn C0 SET 0,(IX+nn) ; copy result to B - - (The information about the unofficial CB instructions was given to me - by Arnt Gulbrandsen, and originated from David Librik.) - - There are a number of unofficial ED instructions, but none of them are - very useful. The ED opcodes in the range 00-3F and 80-FF (except for - the block instructions of course) do nothing at all but taking up 8 T - states and incrementing the R register by 2. Most of the unlisted - opcodes in the range 40-7F do have an effect, however. The complete - list: (* = not official) - - ED40 IN B,(C) ED60 IN H,(C) - ED41 OUT (C),B ED61 OUT (C),H - ED42 SBC HL,BC ED62 SBC HL,HL - ED43 LD (nn),BC ED63 # LD (nn),HL - ED44 NEG ED64 * NEG - ED45 RETN ED65 * RET - ED46 IM 0 ED66 * IM 0 - ED47 LD I,A ED67 RRD - ED48 IN C,(C) ED68 IN L,(C) - ED49 OUT (C),C ED69 OUT (C),L - ED4A ADC HL,BC ED6A ADC HL,HL - ED4B LD BC,(nn) ED6B # LD HL,(nn) - ED4C * NEG ED6C * NEG - ED4D RETI ED6D * RET - ED4E * IM 0 ED6E * IM 0 - ED4F LD R,A ED6F RLD - ED50 IN D,(C) ED70 # IN (C) - ED51 OUT (C),D ED71 * OUT (C),0 - ED52 SBC HL,DE ED72 SBC HL,SP - ED53 LD (nn),DE ED73 LD (nn),SP - ED54 * NEG ED74 * NEG - ED55 * RET ED75 * RET - ED56 IM 1 ED76 * IM 1 - ED57 LD A,I ED77 * NOP - ED58 IN E,(C) ED78 IN A,(C) - ED59 OUT (C),E ED79 OUT (C),A - ED5A ADC HL,DE ED7A ADC HL,SP - ED5B LD DE,(nn) ED7B LD SP,(nn) - ED5C * NEG ED7C * NEG - ED5D * RET ED7D * RET - ED5E IM 2 ED7E * IM 2 - ED5F LD A,R ED7F * NOP - - Guenter Woigk remarked that the three instructions marked # (which were - previously marked *) are documented by ZiLog, though not normally used. - The ED63 and ED6B instructions have shorter and faster equivalents. - - The ED70 instruction reads from port (C), just like the other - instructions, but throws away the result. It does change the flags in - the same way as the other IN instructions, however. The ED71 - instruction OUTs a byte zero to port (C), interestingly. These - instructions 'should', by regularity of the instruction set, use (HL) - as operand, but since from the processor's point of view accessing - memory or accessing I/O devices is the same thing except for activation - of the /IORQ line instead of the /MREQ line, and since the Z80 does not - access memory twice in one instruction (disregarding instruction fetch - of course) it can't fetch or store the data byte. (A hint in this - direction is that, even though the NOP-synonyms LD B,B, LD C,C etcetera - do exist, LD (HL),(HL) is absent and replaced by the HALT instruction.) - - The instructions ED 4E and ED 6E are IM 0 equivalents: when FF was put - on the bus (physically) at interrupt time, the Spectrum continued to - execute normally, whereas when an EF (RST #28) was put on the bus it - crashed, just as it does in that case when the Z80 is in the official - interrupt mode 0. In IM 1 the Z80 just executes a RST #38 (opcode FF) - no matter what is on the bus. - - The RETI instruction is functionally exactly equivalent to the RET - instruction. It is used only to signify the end of an interrupt - routine to an external hardware device (read: the Z80 PIO). The RETN - however is different from RET in that it resets IFF1 to the current - value of IFF2. Now IFF1 and IFF2 are usually equal (and become equal - after DI and EI and after a maskable interrupt has been accepted). - They're different only if an NMI occurs when interrupts are enabled; - then IFF1 is off, and IFF2, holding the previous state of the interrupt - flip flop, is on, signifying that interrupts were enabled before the - non-maskable interrupt. Since the state of IFF2 can be read by using - LD A,R and LD A,I, the RETN instruction is not used much in Spectrum - ROM software, and it is utterly useless in normal software. In other - words, I have not tried to figure out whether the unofficial RET's are - RETI's or RETN's. One can make an educated guess though. - - About the R register. This is not really an undocumented feature, - although precise explanations were hard to find. The R register is a - counter that is updated every instruction, where DD, FD, ED and CB are - to be regarded as separate instructions. So shifted instructions will - increase R by two. There's an exception: doubly-shifted opcodes, the - DDCB and FDCB ones, increase R by two too. LDI increases R by two, - LDIR increases it by 2 times BC, as does LDDR etcetera. The sequence - LD R,A / LD A,R increases A by two. The highest bit of the R register - is never changed (except possibly by LD R,A of course). This is - because in the old days everyone used 16 Kbit chips. Inside the chip - the bits were arranged in a 128x128 matrix, and needed a 7 bit refresh - cycle. Probably for this reason ZiLOG decided to count only the lowest - 7 bits. If the R register emulation is switched on the R register will - behave as is does on a real Spectrum; if it is off it will (except for - the upper bit) act as a random generator. - - You can easily check that the R register is really crucial to memory - refresh. Assemble this program: - - ORG 32768 - DI - LD B,0 - L1 XOR A - LD R,A - DEC HL - LD A,H - OR L - JR NZ,L1 - DJNZ L1 - EI - RET - - It will take about three minutes to run. Look at the upper 32K of - memory, for instance the UDG graphics. It will have faded. Only the - first few bytes of each 256 byte block will still contain zeros, - because they were refreshed during the execution of the loop. The ULA - took care of the refreshing of the lower 16K. (This example won't work - on the emulator of course!) - - Then there's one other dark corner of the Z80 which has its effect on - programs like Sabre Wulf, Ghosts'n Goblins and Speedlock. The Mystery - of the Undocumented Flags! - - Bit 3 and 5 of the F register are not used. They can contain - information, as you can readily figure out by using PUSH AF and POP AF. - Furthermore, sometimes their values change. I found the following - empirical rule: - - The values of bit 7, 5 and 3 follow the values of the - corresponding bits of the last 8 bit result of an instruction - that changed the usual flags. - - For instance, after an ADD A,B those bits will be identical to the bits - of the A register. (Bit 7 of F is the sign flag, and fits the rule - exactly). An exception is the CP x instruction (x=register, (HL) or - direct argument). In that case the bits are copied from the argument. - - If the instruction is one that operates on a 16 bit word, the 8 bits of - the rule are the highest 8 bits of the 16 bit result - that was to be - expected since the S flag is extracted from bit 15. - - Ghosts'n Goblins use the undocumented flag due to a programming error. - The rhino in Sabre Wulf walks backward or keeps running in little - circles in a corner, if the (in this case undocumented) behaviour of - the sign flag in the BIT instruction isn't right. I quote: - - AD86 DD CB 06 7E BIT 7,(IX+6) - AD8A F2 8F AD JP P,#AD8F - - An amazing piece of code! Speedlock does so many weird things that - everything must be exactly right for it to run. Finally, the '128 rom - uses the AF register to hold the return address of a subroutine for a - while. To keep all programs happy, and still have a fast emulator, I - had to make a compromise. The undocumented flags are not always - emulated right, but they are most of the time. Not telling you when - not. - - Now for the emulated Z80. I have added eight instructions, to speed up - the RS232 input and output of the Interface I and several things of the - SamRam. These opcodes, ED F8 to ED FE are of little use to any other - program. ED FF is a nice one: it returns you to DOS immediately. I - used it for debugging purposes, and it is also used in TAP2TAPE and - SAMLIST. - - The opcode ED FB, which is used by the SamRam, is now also used to use - multi-load games on the emulator. If the emulator encounters the - opcode ED FB in RAM (above 16384), it loads a block of code into memory - at address HL. The data is first looked for in the .Z80 or .SLT - snapshot file last loaded (see description of the .Z80 file format); if - it is not found there, the emulator looks for a .DAT file with the same - name as the snapshot last loaded, and the decimal value of the A - register appended to it (dropping letters from the snapshot name if - required to make it at most 8 characters long). If this file is not - found either, a window is popped up to inform the user of the value of - the A register, and allow him to supply a .DAT file (or .Z80/.SLT file) - himself. - - When the emulator fails to load a block, it complements the carry flag, - so that the running Spectrum program can decide what to do. Note that - versions of Z80 prior to v3.04 did not change the flags, so that on old - versions (and on other emulators) loading will always seem to succeed. - - - - -5.10 File formats - - - This section describes the format of the files used by the emulator. - - - - ROMS.BIN: - --------- - - 00000-03fff Ordinary Spectrum rom - 04000-05fff Interface I rom (8K) - 06000-09fff First SamRam rom (contains BASIC) - 0a000-0dfff Second SamRam rom (contains monitor,...) - 0e000-11fff First Spectrum 128K rom (active at RESET) - 12000-15fff Second Spectrum 128K rom (contains BASIC) - 16000-19fff Disciple rom, system file 3b, Epson printer code - 1a000-1dfff Disciple rom, system file 3b, HP printer code - 1e000-1ffff Multiface rom (8K) - 20000-207ff Currah microspeech rom (2K) - - The ordinary rom has not been modified. In the roms.bin file of - previous version of Z80, the interface I rom was modified, to make the - "b" and "t" RS232 channels faster. This modification is removed. It - is now wise to make the baud-rate as high as possible, say FORMAT - "b",19200. If you want faster RS232 emulation, make the following - changes to the roms.bin file: - - Address: Old: New: Address: Old: New: - - 04B9E ED ED 04D20 FB 00 - 04B9F 5B FC 04D2A 37 ED - 04BA0 C3 F5 04D2B F3 FD - 04BA1 5C C3 04D2C CE 18 - 04BA2 21 34 04D2D 00 10 - 04BA3 20 0C 04D4C FB 00 - - The first and second SamRam rom have been modified more extensively. - The biggest problem was that switching the upper 32K ram bank is very - fast in reality, but on the PC two blocks of 32K bytes had to be REP - MOVSWded (or the EMS emulator be called). But since no programs know - of the SamRam code anyway, this won't cause any more problems it - wouldn't already cause either. - - The two Spectrum 128 roms have not been modified, and neither have the - Disciple roms or the Multiface rom. The Disciple roms, as they appear - in the ROMS.BIN file, do have system files pre-loaded however. - - The Currah microspeech rom is not used by Z80. It is included so that - Z80 and WinZ80 can share the same rom-file. - - - - .TAP FILES: - ----------- - - The .TAP files contain blocks of tape-saved data. All blocks start - with two bytes specifying how many bytes will follow (not counting the - two length bytes). Then raw tape data follows, including the flag and - checksum bytes. The checksum is the bitwise XOR of all bytes including - the flag byte. For example, when you execute the line SAVE "ROM" CODE - 0,2 this will result: - - - |------ Spectrum-generated data -------| |---------| - - 13 00 00 03 52 4f 4d 7x20 02 00 00 00 00 80 f1 04 00 ff f3 af a3 - - ^^^^^...... first block is 19 bytes (17 bytes+flag+checksum) - ^^... flag byte (A reg, 00 for headers, ff for data blocks) - ^^ first byte of header, indicating a code block - - file name ..^^^^^^^^^^^^^ - header info ..............^^^^^^^^^^^^^^^^^ - checksum of header .........................^^ - length of second block ........................^^^^^ - flag byte ............................................^^ - first two bytes of rom .................................^^^^^ - checksum (checkbittoggle would be a better name!).............^^ - - - The emulator will always start reading bytes at the beginning of a - block. If less bytes are loaded than are available, the other bytes - are skipped, and the last byte loaded is used as checksum. If more - bytes are asked for than exist in the block, the loading routine will - terminate with the usual tape-loading-error flags set, leaving the - error handling to the calling Z80 program. - - Note that it is possible to join .TAP files by simply stringing them - together, for example COPY /B FILE1.TAP + FILE2.TAP ALL.TAP - - For completeness, I'll include the structure of a tape header. A - header always consists of 17 bytes: - - Byte Length Description - 0 1 Type (0,1,2 or 3) - 1 10 Filename (padded with blanks) - 11 2 Length of data block - 13 2 Parameter 1 - 15 2 Parameter 2 - - The type is 0,1,2 or 3 for a Program, Number array, Character array or - Code file. A screen$ file is regarded as a Code file with start - address 16384 and length 6912 decimal. If the file is a Program file, - parameter 1 holds the autostart line number (or a number >=32768 if no - LINE parameter was given) and parameter 2 holds the start of the - variable area relative to the start of the program. If it's a Code - file, parameter 1 holds the start of the code block when saved, and - parameter 2 holds 32768. For data files finally, the byte at position - 14 decimal holds the variable name. - - - - .TZX FILES: - ----------- - - - This file format is designed as an extension of the .TAP format, - storing tape data in small files but with the versatility of .VOC - files. Practically all turbo loaders can be converted to .TZX files, - and these files are ususally about as small as .TAP files. In addition - to this, .TZX files can contain text-info and other things. - - The .TZX file format is rather complex, and features will probably be - added in the future, so I refer you to the net for the most current - information. Z80 supports .TZX file format version 1.10. - - You can recognize .TZX files by executing "type file.tzx", it should - say "ZXTape!". - - A handy feature is that .TZX files can be concatenated just as .TAP - files, by executing e.g. "copy /b file1.tzx + file2.tzx both.tzx". - - - - .MDR FILES: - ----------- - - The emulator uses a cartridge file format identical to the 'Microdrive - File' format of Carlo Delhez' Spectrum emulator Spectator for the QL, - who devised the format. This format is now also supported by XZX of - Des Harriot. The following information is adapted from Carlo's - documentation. It can also be found in the 'Spectrum Microdrive Book', - by Ian Logan (co-writer of the excellent 'Complete Spectrum ROM - Disassembly'). - - A cartridge file contains 254 'sectors' of 543 bytes each, and a final - byte flag which is non-zero is the cartridge is write protected, so the - total length is 137923 bytes. On the cartridge tape, after a GAP of - some time the Interface I writes 10 zeros and 2 FF bytes (the - preamble), and then a fifteen byte header-block-with-checksum. After - another GAP, it writes a preamble again, with a 15-byte record- - descriptor-with-checksum (which has a structure very much like the - header block), immediately followed by the data block of 512 bytes, and - a final checksum of those 512 bytes. The preamble is used by the - Interface I hardware to synchronise, and is not explicitly used by the - software. The preamble is not saved to the microdrive file: - - offset length name contents - - 0 1 HDFLAG Value 1, to indicate header block - 1 1 HDNUMB sector number (values 254 down to 1) - 2 2 not used - 4 10 HDNAME microdrive cartridge name (blank padded) - 14 1 HDCHK header checksum (of first 14 bytes) - - 15 1 RECFLG - bit 0: always 0 to indicate record block - - bit 1: set for the EOF block - - bit 2: reset for a PRINT file - - bits 3-7: not used (value 0) - 16 1 RECNUM data block sequence number (value starts at 0) - 17 2 RECLEN data block length (<=512, LSB first) - 19 10 RECNAM filename (blank padded) - 29 1 DESCHK record descriptor checksum (of previous 14 bytes) - 30 512 data block - 542 1 DCHK data block checksum (of all 512 bytes of data - block, even when not all bytes are used) - --------- - 254 times - - - (Actually, this information is 'transparent' to the emulator. All it - does is store 2 times 254 blocks in the .MDR file as it is OUTed, - alternatingly of length 15 and 528 bytes. The emulator does check - checksums, see below; the other fields are dealt with by the emulated - Interface I software.) - - A used record block is either an EOF block (bit 1 of RECFLG is 1) or - contains 512 bytes of data (RECLEN=512, i.e. bit 1 of MSB is 1). An - empty record block has a zero in bit 1 of RECFLG and also RECLEN=0. An - unusable block (as determined by the FORMAT command) is an EOF block - with RECLEN=0. - - The three checksums are calculated by adding all the bytes together - modulo 255; this will never produce a checksum of 255. Possibly, this - is the value that is read by the Interface I if there's no or bad data - on the tape. - - In normal operation, all first-fifteen-byte blocks of each header or - record block will have the right checksum. If the checksum is not - right, the block will be treated as a GAP. For instance, if you type - OUT 239,0 on a normal Spectrum with interface I, the microdrive motor - starts running and the cartridge will be erased completely in 7 - seconds. CAT 1 will respond with 'microdrive not ready'. Try it on the - emulator... - - - - - .OUT FILES: - ----------- - - These files are produced when logging OUTs; see menu option O in the - Extra Functions menu. For the specified I/O ports, all OUTs to these - ports are recorded in the .OUT file, together with the exact time at - which the OUTs were executed. - - An .OUT file consists of a string of 5-byte blocks. The first word is - the timing word; it has a value between 0 and 17471 inclusive (or - between 0 and 17726 inclusive when a 128K Spectrum is emulated), and a - unit value corresponds to 1 T state (=1/3494400 s). After this, the - OUT port that was written to follows, then the value OUTed itself: - - Offset Length Description - - 0 2 Time (0-17471 or 0-17726) - 2 2 Port address - 4 1 Value - - Every 1/200th of an emulated second, that is, every 69888/4=17472 T - states (or 70908/4=17727 T states on 128K Spectrums), a time-wraparound - block is written to the .OUT file: - - Offset Length Description - - 0 2 Flag word #FFFF indicating wraparound-block - 2 2 Length of preceding block (17472 or 17727 T) - 4 1 Not used - - So even when the Spectrum does not OUT to the logged ports at all, 1000 - bytes get written to the log file every second. - - By default, an OUT to an even I/O address which does not change the - state of the MIC and EAR outputs is not written to the .OUT file, to - save disk space when recording music. If you want all OUTs, specify - -xg on the command line. - - The .OUT files are also used to make a simple trace of a running - Spectrum program. Specify -xy on the command line; as soon as you - activate OUT logging, a trace is dumped also. For each instruction - encountered during emulation, the following block is written to the - .OUT file: - - Offset Length Description - - 0 2 Flag word (#FFFE) - 2 2 Program counter - 5 1 A register - - Furthermore, no time-wraparound blocks are written to the .OUT file - when tracing. HALT instructions (118 decimal) are special in that they - do not generate a block in the log file; this is to make comparisons - between different logs of the same program easier. Admittedly, this is - a very crude way of tracing a program, but it's better than nothing, - and very useful very occasionally. - - - - - Map files - --------- - - Map files are those that are produced via option -0m; see section 2.19 - in Z80.DOC. These files have no default extension; .MAP seems a natural - suggestion. These files are meant to be used with a future version of - Leslie Styles' DSNA (a snapshot disassembler; you can find it on - ftp.nvg.unit.no). - - Map files are 8192 bytes long. Each byte represents 8 addresses in - Spectrum memory, from #0000 to #FFFF. Note that the rom is also - mapped. A one at bit-position k in byte n means that at least once - during the time the emulator emulated, it emulated the opcode it found - at address 8n+k. The shifted opcodes will only have the shift code - marked (though the Z80 chip is, I think, in machine cycle 1, M1, during - both the shift fetch and the secondary opcode fetch). Due to the way - unofficial DD and FD instructions are implemented, a sequence of DD's - is considered as one very long instruction, and will result in only the - address of the first DD that was executed being tagged. - - You should not use Hi-res color emulation during opcode mapping; they - use the same buffer area. HRC emulation still works, but destroys the - mapping buffer. Also, option -xu (disable HCR emulation to use less - memory) will disable opcode mapping. Finally, the mapping procedure - does not take memory paging into account, and it is therefore not very - practical in 128K modes, in SamRam mode, and for mapping the execution - of the shadow roms (128K, SamRam, Interface I, Multiface). It works - best for mapping the ordinary rom and ordinary 48K Spectrum programs. - Also note that the map is never cleared, not even when another snapshot - is loaded. - - The best way to use this feature is the following. Load the program - you want to disassemble, and let it run to the main starting point, so - that all decoding, decompressing, and moving around has probably been - done. Then save the snapshot ('program.z80'), and start the emulator - with 'z80 -0m program.map program.z80'. Run it for a while, but be - sure never to reset the Spectrum, or to enter the SamRam or Multiface, - or load another snapshot. After a while, quit the emulator - (Ctrl-Break), and you'll find the file 'program.map' contain the - locations of the opcodes executed. By tracing the code blocks found, - and also taking the conditional branches that were left alone during - execution, most of the code can probably be found. - - This option has been added after reading a remark of Leslie Styles - (lsm@soton.ac.uk), who had been trying to make his disassembler figure - out which parts of memory were actual code, and which were data. It - seemed to me that the only reliable way was to actually emulate the - code. For almost all programs this will be sufficient. It however - still does not take into account the possibility of self-modifying - code. For completely general programs, the approach that Arnt - Gulbrandsen followed in his JPP (also keeping a map of executed opcode - locations, but invalidating these if necessary when data is written to - memory) is the only right solution. The current approach however was - so simple to implement that I thought it to be worthwhile. - - - - - .SCR FILES: - ----------- - - .SCR files are memory dumps of the first 6912 bytes of the Spectrum - memory. The first 6144 bytes contain the bitmap, of 256x192 bits. - The ordering is a bit particular. The first 32 bytes form the 256 bits - of line 0 (most significant bit leftmost), then line 8,16,...,56,1, - 9,...,57,2,.....,63. Then, in the same ordering the second one-third - is build up, up to line 127. The final 2048 bytes form the third - one-third up to line 191. - - The attribute data, of 768 bytes (32x24 8-by-8 blocks) follow - immediately after the bitmap. The lowest three bits of an attribute - byte control the foreground colour (the colour of the pixel if the - corresponding bit in the bitmap is set), bits 3-5 control the - background colour, bit 6 is the bright bit and bit 7 is the flash bit - - if it is set, every 16/50th of a second the ULA effectively flips the - foreground and background colours. - - - - .DAT files: - ----------- - - These files are used to store level data; blocks of memory that are - loaded when the opcode ED FB is executed. The block is loaded at the - address pointed to by the HL register. The level number is in the A - register. If the emulator fails to load a level data block, it - complements the carry flag. Versions of the emulator prior to v3.04 - did not do this. - - When an ED FB opcode is encountered, the emulator first looks for the - snapshot file last loaded, and checks whether it contains the level - requested (see the description of the .Z80 format below). If this - fails, it looks for a .DAT file of the level; the name of this file is - derived from the name of the last snapshot loaded by appending the - (decimal) value of the A register to the name of the snapshot file, - dropping characters from the original snapshot name to make the total - length 8 characters if necessary. .DAT files simply contain the plain - level data (in contrast to the level data in .Z80 files, which are - compressed). - - - - .Z80 and .SLT files: - -------------------- - - The old .Z80 snapshot format (for version 1.45 and below) looks like - this: - - Offset Length Description - - 0 1 A register - 1 1 F register - 2 2 BC register pair (LSB, i.e. C, first) - 4 2 HL register pair - 6 2 Program counter - 8 2 Stack pointer - 10 1 Interrupt register - 11 1 Refresh register (Bit 7 is not significant!) - 12 1 Bit 0 : Bit 7 of the R-register - Bit 1-3: Border colour - Bit 4 : 1=Basic SamRom switched in - Bit 5 : 1=Block of data is compressed - Bit 6-7: No meaning - 13 2 DE register pair - 15 2 BC' register pair - 17 2 DE' register pair - 19 2 HL' register pair - 21 1 A' register - 22 1 F' register - 23 2 IY register (Again LSB first) - 25 2 IX register - 27 1 Interrupt flipflop, 0=DI, otherwise EI - 28 1 IFF2 (not particularly important...) - 29 1 Bit 0-1: Interrupt mode (0, 1 or 2) - Bit 2 : 1=Issue 2 emulation - Bit 3 : 1=Double interrupt frequency - Bit 4-5: 1=High video synchronisation - 3=Low video synchronisation - 0,2=Normal - Bit 6-7: 0=Cursor/Protek/AGF joystick - 1=Kempston joystick - 2=Sinclair 2 Left joystick (or user - defined, for version 3 .Z80 files) - 3=Sinclair 2 Right joystick - - Because of compatibility, if byte 12 is 255, it has to be regarded as - being 1. Following this header block of 30 bytes the 48K bytes of - Spectrum memory are stored, in a compressed format (if bit 5 of byte 12 - is set). - - Field 11 contains the actual current value of R plus 1. For example if - this field contains 20 and PC points to a LD A,R instruction, A will - hold 21 after execution, since R is incremented from 19 to 21 during - instruction fetch before LD A,R gets executed. [Note: Z80Dump displays - field 11, not the actual current value of R.] - - The compression method is this. Repetitions of at least five equal - bytes are replaced by the four-byte code ED ED xx yy, which stands for - "byte yy repeated xx times". Only sequences of length at least 5 are - coded. The exception is sequences consisting of ED's; if they are - encountered, even two ED's are encoded into ED ED 02 ED. Finally, every - byte directly following a single ED is not taken into a block, for - example ED 6*00 is not encoded into ED ED ED 06 00 but into ED 00 ED ED - 05 00. The block is terminated by an end marker, 00 ED ED 00. - - That's the format of .Z80 files as used by versions up to 1.45. - Starting from version 2.0, a different format is used, since from then - on also 128K snapshots had to be supported. This new format is used - for all snapshots (48K or 128K). - - Version 2.01 and 3.0x .Z80 files start with the same 30 byte header - that old .Z80 files used. Bit 4 and 5 of the flag byte (offset 12) - have no meaning anymore, and the program counter (offset 6 and 7) are - zero to signal a version 2.01 (or later) snapshot file. - - Starting from version 3.05, Z80 ignores the setting of byte 29, bit 3 - (Double Interrupt frequency) when loading snapshots, and resets the bit - when saving, because of the altered behaviour of the -d switch. - - After the first 30 bytes, the additional header follows: - - - Offset Length Description - - * 30 2 Length of additional header block (see below) - * 32 2 Program counter - * 34 1 Hardware mode (see below) - * 35 1 If in SamRam mode, bitwise state of 74ls259. - For example, bit 6=1 after an OUT 31,13 (=2*6+1) - If in 128 mode, contains last OUT to 7ffd - * 36 1 Contains 0FF if Interface I rom paged - * 37 1 Bit 0: 1 if R register emulation on - Bit 1: 1 if LDIR emulation on - * 38 1 Last OUT to fffd (soundchip register number) - * 39 16 Contents of the sound chip registers - 55 2 Low T state counter - 57 1 Hi T state counter - 58 1 Flag byte used by Spectator (QL spec. emulator) - Ignored by Z80 when loading, zero when saving - 59 1 0FF if MGT Rom paged - 60 1 0FF if Multiface Rom paged. Should always be 0. - 61 1 0FF if 0-8191 is ROM, 0 if RAM - 62 1 0FF if 8192-16383 is ROM, 0 if RAM - 63 10 5x keyboard mappings for user defined joystick - (Default values: 0x0103,0x0203,0x0403,0x0803,0x1003) - 73 10 5x ascii word: keys corresponding to mappings above - (Default values: 0x0031,0x0032,0x0033,0x0034,0x0035) - 83 1 MGT type: 0=Disciple+Epson,1=Discipls+HP,16=Plus D - 84 1 Disciple inhibit button status: 0=out, 0ff=in - 85 1 Disciple inhibit flag: 0=rom pageable, 0ff=not - - - The value of the word at position 30 is 23 for version 2.01 files, and - 54 for version 3.0x files. The starred fields are the ones that - constitute the version 2.01 header, and their interpretation has - remained unchanged except for offset 34 (Hardware mode): - - Value: Meaning in v2.01 Meaning in v3.0x - - 0 48k 48k - 1 48k + If.1 48k + If.1 - 2 SamRam SamRam - 3 128k 48k + M.G.T. - 4 128k + If.1 128k - 5 - 128k + If.1 - 6 - 128k + M.G.T. - - Fields 30-34, 36-37, 55-82 are valid in all modes. Field 35 is valid - in mode 2,4,5,6. Fields 38-54 are valid in modes 4-6. Fields 83-85 - are valid in modes 3 and 6 (all mode codes are as in v3.0x files). - "Invalid" fields are "don't care" for Z80 when loading, and "undefined" - when saving. - - The hi T state counter counts up modulo 4. Just after the ULA - generates its once-in-every-20-ms interrupt, it is 3, and is increased - by one every 5 emulated milliseconds to take the values 0,1,2 and 3 - again respectively. In these 1/200s intervals, the low T state counter - counts down from 17471 to 0 inclusive (or 17726 to 0 in 128K modes), - which make a total of 69888 T states (70908 T states) per frame. - - The 5 ascii words (high byte always 0) at 73-82 are the keys - corresponding to the joystick directions left, right, down, up, fire - respectively. Shift, Symbol Shift, Enter and Space are denoted by - [,],/,\ respectively. The ascii values are used only to display the - joystick keys; the information in the 5 keyboard mapping words - determine which key is actually pressed (and should correspond to the - ascii values). The low byte is in the range 0-7 and determines the - keyboard row. The high byte is a mask byte and determines the column. - Enter for example is stored as 0x0106 (row 6 and column 1) and 'g' as - 0x1001 (row 1 and column 4). The default values correspond to the Left - Sinclair Interface 2 joystick. - - Byte 60 must be zero, because the contents of the Multiface RAM is not - saved in the snapshot file. If the Multiface was paged when the - snapshot was saved, the emulated program will most probably crash when - loaded back. - - Bytes 61 and 62 are a function of the other flags, such as byte 34, 59, - 60 and 83. - - Hereafter a number of memory blocks follow, each containing the - compressed data of a 16K block. The compression is according to the - old scheme, except for the end-marker, which is now absent. The - structure of a memory block is: - - - Offset Length Description - - 0 2 Length of data (without this 3-byte header) - 2 1 Page number of block - 3 [0] Compressed data - - Starting with version 3.05, a length field of 65535 (-1) means that the - block is not compressed and exactly 16384 bytes long, and the length - field will never hold values larger than 16383. (Previous versions of - Z80 could produce 'compressed' blocks of more than 16384 bytes, but - would refuse to load those.) - - The pages are numbered, depending on the hardware mode, in the - following way: - - - Page In '48 mode In '128 mode In SamRam mode - - 0 48K rom rom (basic) 48K rom - 1 Interface I, Disciple or Plus D rom, according to setting - 2 - rom (reset) samram rom (basic) - 3 - page 0 samram rom (monitor,..) - 4 8000-bfff page 1 Normal 8000-bfff - 5 c000-ffff page 2 Normal c000-ffff - 6 - page 3 Shadow 8000-bfff - 7 - page 4 Shadow c000-ffff - 8 4000-7fff page 5 4000-7fff - 9 - page 6 - - 10 - page 7 - - 11 Multiface rom Multiface rom - - - - In 48K mode, pages 4,5 and 8 are saved. In SamRam mode, pages 4 to 8 - are saved. In '128 mode, all pages from 3 to 10 are saved. This - version saves the pages in numerical order. There is no end marker. - - - Other branches of the .Z80 format - --------------------------------- - - The emulators Warajevo and XZX support more hardware than Z80 does. - These programs store snapshots in .Z80 files that differ slightly from - the standard format: - - Offset Length Description - - Warajevo: 34 1 128 = Times 2068 emulation active - 35 1 Last out to 244 (if Timex emulation active) - 36 1 Last out to 255 (if Timex emulation active) - - XZX: 30 2 55 (second header has 1 extra byte) - 35 1 7 = +3, 8 = +3 with Interface I - 86 1 (extra byte:) Last out to #1ffd (in +3 snaps) - - - .SLT files - ---------- - - This concludes the specification of .Z80 files. .SLT files (which - stands for 'super level loader trap files') are like .Z80 files except - that after the ordinary data another section follows, containing things - like level data (previously stored in .DAT files, and giving .SLT files - their name) or loading screens. The ".Z80"-file preceding the SLT must - conform the format of v2.01 or v3.0x files (long header). - - Though it is agreed that .Z80 files will not contain SLT data, and - files with SLT data will always have extension .SLT, Z80 does in fact - not distinguish between the extensions. - - The SLT format was cooked up by Damien Burke, James McKay and yours - truly. It starts as an ordinary >= v2.01 .Z80 file. Directly - following this comes a - - - Offset Length Description - - 0 6 Separator (0,0,0,'S','L','T') - - - Then a table follows, each entry describing a piece of data. The - format of a single table entry is: - - - Offset Length Description - - 0 2 Data type: 1=level data, 3=loading screen - 2 2 Id word: Level number (between 0 and 255 inclusive) - for type 1, border colour (between 0 and 7) for - type 3. - 4 4 Length of data block in bytes (Note: long word) - - - Data types other than type 1 and 3 are not supported by Z80 v3.04, and - are ignored. The table ends with an all-zero end marker: - - - Offset Length Description - - 0 8 End marker (all zeroes) - - - Finally, the data blocks follow. The blocks are stored in the order in - which they appear in the table, i.e. the offset of a particular data - block is the sum of the lengths of the blocks that precede it. The - internal format of these blocks depend on the data type: - - - Type: Format: - - 0 (no data) - 1 Compressed data (ED ED xx yy scheme, see above) expanding - to anything up to 48K - 3 Compressed data expanding to exactly 6912 bytes of data - - - See the end of section 5.9 for an explanation how to load these blocks - using the ED FB opcode, and error handling. - - All words in the format have the least significant byte first. - - - diff --git a/Docs/z80.doc b/Docs/z80.doc deleted file mode 100644 index 4501f4b..0000000 --- a/Docs/z80.doc +++ /dev/null @@ -1,3384 +0,0 @@ -Sinclair ZX Spectrum Emulator 'Z80' v4.00 - 6/3/99 - by G.A. Lunter - - - -Contents: - - 1. INTRODUCTION, REGISTRATION, GENERAL INFORMATION - 1.1 Some general remarks - 1.2 Registration - 1.3 Other emulators - 1.4 Acknowledgements - 1.5 Disclaimers - 1.6 Copyright notices - - 2. THE EMULATOR - 2.1 Starting the emulator - 2.2 Using the emulator - 2.3 Keyboard emulation - 2.4 Screen emulation - 2.5 Sound emulation - 2.6 Loading programs from tape - 2.7 Using .TAP files - 2.8 Using .VOC files - 2.9 Multi-load games - 2.10 Using the Microdrive - 2.11 Using the Disciple and Plus D interfaces - 2.12 Using the Multiface - 2.13 Using the RS232 channel - 2.14 On joysticks and mice - 2.15 The utility ConvZ80 - 2.16 Converting file formats - the utility CONVERT - 2.17 The utilities Z802TAP, TAP2TAPE and TAP2VOC - 2.18 The utility OUT2VOC - and how to make .OUT files - 2.19 The utilities READVOC and READSB - 2.20 Quick overview of command line switches, and features - 2.21 Miscellaneous remarks - - 3. THE SAMRAM - 3.1 Basic extensions - 3.2 NMI software - 3.3 The built-in monitor - - 4. THE SPECTRUM - 4.1 The Spectrum - 4.2 The Interface I - 4.3 The DISCiPLE and Plus D Interfaces - Introduction - 4.4 The DISCiPLE and Plus D Interfaces - Basic commands - 4.5 The DISCiPLE and Plus D Interfaces - More advanced commands - 4.6 The DISCiPLE and Plus D Interfaces - The snapshot button - 4.7 The DISCiPLE and Plus D Interfaces - The system variables - 4.8 The Spectrum 128 - - 5. TECHNICAL INFORMATION (in file TECHINFO.DOC) - 5.1 The Spectrum 48K - 5.2 The Spectrum 128K - 5.3 The AY-3-8912 sound chip - 5.4 The ZX Printer - 5.5 The Interface I - 5.6 The SamRam - 5.7 The Multiface 128 - 5.8 The AMX mouse interface - 5.9 The Z80 microprocessor - 5.10 File formats - - - - - -1. INTRODUCTION, REGISTRATION, GENERAL INFORMATION - - - - -1.1 Some general remarks - - - This is the documentation for 'Z80', a Sinclair ZX Spectrum 48/128 - emulator. The program turns your PC into a Spectrum. This is what it - can do: - - - Emulates ZX Spectrum 48K model 2 or 3, and Spectrum 128K. - - Excellent compatibility with real Spectrum, probably best of - current existing emulators. - - Emulates Interface I and Microdrive (cartridge in cartridge file), - Disciple and Plus D disk interfaces, Multiface 128. - - Full tape support: loads both normal and turbo-saved programs using - either tape interface on LPT port, SoundBlaster AD converter or - .VOC sound sample files; can also use .TAP binary tape image files - by trapping ROM save/load routines. Starting from version 4, Z80 - supports .TZX compressed tape image files. Saving back to tape is - also possible, either directly to tape or to a .VOC sound sample - file. - - Full emulation of Spectrum screen, including all colour effects. - Border, and timing-sensitive border and attribute effects are also - emulated. - - Emulation of ZX Printer, for Epson and HP Laserjet compatible - printers. - - Emulation of beeper through PC beeper, and of 128K sound through - either PC beeper or AdLib (SoundBlaster) compatible cards. - Emulation of "ACB" stereo effects. - - Supports digital and analogue joysticks, and mouse, controlling - Cursor, Sinclair, Kempston or user-defined joystick. - - Emulates Spectrum AMX Mouse interface (used by e.g. Art Studio) - - Runs on any PC, an 8088/8086 will do. Some time-critical sections - use features of '386 processors if available. - - Emulator runs just above 100% of actual Spectrum speed on 20 MHz - 286 and 25 MHz 386SX; can be slowed down on faster machines. - - Z80 emulation includes emulation of R register, all unofficial - instruction codes, and unofficial flags; interrupts once every - 1/50th emulated second; I have tried to make each instruction - execute in a time proportional to the time taken on a real Z80. - In some modes T-states are counted, and 'virtual' time is exact. - - Registered package includes all source files. - - Interface I and Spectrum 128's "p" channel input/output can be - re-routed to LPT or COM port, or to a file. - - Includes several utilities; to convert from and to other snapshot - and tape file formats, to convert snapshots into tape files, tape - files into sound sample files, to display contents of snapshot - files, to convert screen snapshots to .PCX and .GIF files, to read - .VOC sound sample files from the LPT tape interface or - SoundBlaster. - - A program is included which makes .VOC or raw sound sample files - of sounds produces by the Spectrum, either by the beeper, the - soundchip of the Spectrum 128, or the MIC port. - - OUTs to any port can be logged, and stored in a log file with - timing information. This log file can be translated into a .VOC - sound sample file using OUT2VOC, for both ear and AY soundchip - output. - - Simple tracing feature - - Opcode mapping feature, tags bytes that are executed during - emulation; useful for debugging and disassembling purposes. - (It can be used with the disassembler program DNSA by Leslie Styles, - lms@soton.ac.uk) - - Multi-level (LLT) support as in XZX 0.5.2; also support of .SLT - files. - - Emulator can set a breakpoint, invisible to the running program. - - Emulator can load and save blocks of Spectrum memory to disk - directly. - - Emulator can run under Windows (95). Starting from version 4, - it can run windows in VGA mode. - - Supports VGA, EGA, CGA and Hercules video adapters including - monochrome VGA. (No support for Plantronics anymore.) - - There is quite a lot to explain in this documentation. First of all - the emulator itself requires some of your PC's resources. It is not - really a demanding program, but there are some things that need - attention. These technicalities are dealt with in section 2.1. - - - Some general things about the emulator are explained in section 2.2. - After reading sections 2.1 and 2.2, you will know most of the basics. - The details can be found in subsequent sections. - - The Spectrum has a number of ways to communicate with the outside - world, like the obvious keyboard and the screen, but also the - microdrives, the DISCiPLE/Plus D disk interfaces, the tape interface, - the beeper, the sound chip of the Spectrum 128, the Kempston joystick, - the AMX Mouse, the ZX Printer interface, and the RS232 channel of the - Interface I and Spectrum 128 can be used to communicate with PC - channels in some way. For instance, the keyboard is connected to the PC - keyboard, and the tape I/O can be routed to a file, as well as to a - physical tape recorder, or it can come from a .VOC sound sample file. - All these things are explained in the rest of chapter 2. - - For our own Spectrums Johan Muizelaar and I built a piece of hardware - we called the SamRam (which has nothing to do with the SAM Coupe, by - the way!). It contains a monitor program and software to make - snapshots of programs. It's still very useful and I still use it a - lot. An explanation of its functions is to be found in chapter 3. - - Some things peculiar to the Spectrum or its interfaces, not specific to - this program but useful to know, are collected in chapter 4. It - contains for instance a table of Spectrum keywords and the key - combination to get them; unfortunately this information is not printed - on standard PC keyboards! More importantly, in this chapter it is - explained how to use the Microdrive and DISCiPLE interfaces, both of - which are probably unfamiliar to many former Spectrum users. - - There are some interesting technical facts about the Spectrum that I - discovered while debugging the emulator. As much as I could think of - is contained in the final chapter, which can be found in the separate - file TECHINFO.DOC. You don't need to read this chapter to use the - emulator. A specification of the file formats used by the emulator is - also included there. - - Please note that the Tatort BBS, which used to be the 'Spectrum - emulator support BBS', has ceased to exist. - - There is by now a great lot of Spectrum-related information and - software available on the net. A good starting point is the FAQ - (Frequently Asked Questions) list originally started by Marat - Fayzullin, maintained by Damien Burke for a long time, and now in the - hands of Philip Kendall. It can be found at - - http://www.kendalls.demon.co.uk/cssfaq/index.html, or - http://www.void.demon.nl/faq/index.html, and - ftp://ftp.gns.getronics.nl/pub/os/sinclair/specfaq/ - - The latter site is also the home of "World of Sinclair", or WOS for - friends. The url is: - - http://www.void.demon.nl/spectrum.html - - It carries enormous amounts of snapshots, tape-files and sinclair- - related programs, emulators and information, and links to other sites, - including that of Sinclair Research itself. The other main Sinclair - FTP site, where many a beautiful thing started, is - - ftp://ftp.nvg.ntnu.no/pub/sinclair/ - - A long list of other FTP sites can be found in the aforementioned FAQ - list. - - If you have access to internet newsgroups, take a look at - comp.sys.sinclair, where many Sinclair enthousiasts meet and share - thoughts. At the moment it is a very active group, and lots of - well-informed people participate. Please read the FAQ list before - asking questions. IMPORTANT NOTICE: Please do NOT post binaries to - this newsgroup! - - - - -1.2 Registration - - - 'Z80' is a shareware program. The program is not completely - functional, and the parts which are left out are included when you - register. You are encouraged to give this demo version to friends, but - DO NOT change the original archive in any way, please. The shareware - version of the emulator consists of the Z80-400.ZIP archive file, which - should contain the following 3 files: - - INSTALL.EXE - installation program - INSTALL.000 - installation data file - README.TXT - short description of the program - - The shareware version includes WinZ80, the Windows version of Z80, - The registered versions of Z80 and WinZ80 feature the following extras: - - Z80: - - * Full DISCiPLE disk interface emulation - * Direct loading of tapes via SoundBlaster or LPT-interface - * No time restrictions, adjustable emulation speed at all times - - WinZ80: - - * Direct loading of tapes through any Windows wave input device - (e.g. SoundBlaster) - * No time restrictions, no intro window. - - If you register, you get the fully working versions, and the following - utilities: - - - CONVERT - a general conversion program: can list out BASIC and - translate it back, produce .GIF or .PCX files from - screen dumps, translate Spectrum ASCII (CR) to PC ASCII - (CR/LF), and some other things. - CONVZ80 - Translates various snapshot and tape formats of other - Spectrum emulators into each other. Can handle the - familiar .SNA format use by several emulators (JPP, - XZX,...), and also Pedro Gimeno's (VGASPEC and SPECTRUM) - .SP format and Kevin J. Phairs' (SPECEM) .PRG format. - It can also handle tape files of SPECEM and L. Rindt and - E. Brukner's emulator ZX. - DISCIPLE - Reads DISCiPLE and Plus D diskettes, both 3.5'' and - 5.25''. It translates the 48K and 128K snapshot files - to .Z80 snapshots, and ordinary files and screen - snapshots to .TAP tape files. (Not necessary for the - fully registered version, but handy for the cheaper - one.) - ADDDAT - Utility to edit the additional data part of .SLT - snapshot files, which contain loading screens and level - data. - Z802TAP - Converts a .Z80 snapshot, 48K or 128K, to a .TAP file - which can be loaded into the emulator and saved to tape - by the next utility: - TAP2TAPE - Saves the contents of a .TAP file back to tape, to load - it into an ordinary Spectrum. - TAP2VOC - Converts a .TAP file to a .VOC sound sample file, to - write to tape, or to load into the emulator. - READVOC - Reads in a long, 'digital' .VOC sound sample, to be used - as input to the emulator, from the LPT tape interface or - a SoundBlaster. - READSB - Reads .VOC sound samples from SoundBlaster using DMA, - and applies a digital filtering and oversampling algo- - rithm tuned for Spectrum tapes. - OUT2VOC - Converts .OUT log files into .VOC or raw sound sample - files, so that you can easily extract music samples from - Spectrum/Spectrum 128 games, or SAVE directly to a .VOC - or raw sample file. - Z80DUMP - Shows the header and the contents of a .Z80 file. - - - You will also receive the source files of both emulators, the above - utilities and the SamRam. You will also be kept informed about future - (major) updates. - - - - How to register: - ================ - - - You can register either Z80 (the DOS program), or WinZ80, or both. - Registration of Z80 or WinZ80 is BP 15; registration of both programs - at once is BP 20. If you register just one program, please indicate - clearly whether you want Z80 or WinZ80. If you specify neither, we - will assume you want the DOS program. - - For those who sent their registration fee upon reading the information - that comes with the now obsolete version 3.05, note that Z80 v4.00 - emulates the DISCiPLE in all cases; if you sent the BP 20 fee you will - receive both Z80 with DISCiPLE emulation and WinZ80. - - Please send the money in cash in British currency, or as a cheque made - payable to Chezron Software, to: - - Chezron Software - 34 Saltersgate Drive - Birstall - LEICESTER LE4 3FF - England - Email: outletmag@yahoo.com - WWW: http://www.geocities.com/SiliconValley/Orchard/3420/ - Phone/Fax: 0116 220 9651 - From abroad: +44 116 220 9651 - - If this is inconvenient, you can also send US$ 20 / US$ 25, or DM 35 / - DM 50 in cash. Please do NOT send cheques in currencies other than - British Pounds. - - - - If you are living in the Czech Republic: - ======================================== - - - Then it is probably more convenient to register with JIMAZ. Also from - neighbouring countries it may be quicker and/or cheaper to register - with them. The address is: - - JIMAZ s.r.o. - Hermanova 37 - 170 00 Praha 7 - Czech Republic - Phone: +42 2 379 498 - Fax: +42 2 378 103 - Email: jimaz@jimaz.cz - - The registration fee is Cz 500 for either program, Cz 650 for both. - - - - Are you a registered user already? - ================================== - - In that case you can obtain Z80 version 4.00 with DISCiPLE emulation, - the full WinZ80 package, and all utilities and sources, by sending BP - 10 (US$ 15, DM 25) to Chezron Software or Jimaz (see the addresses - above). Please clearly indicate the following: - - * That you apply for an update, - * Your name, - * Your current address and home country, - * If different, the address under which you registered, or last - updated, your version of Z80, - * The version of Z80 you own (e.g. 3.05 or 2.01 or ...), and - whether it emulates the DISCiPLE - - - - - The tape interface - ================== - - The interface described by the circuit diagram in DIAGRAM.Z80 provides - a reliable means for loading any Spectrum program into Z80. If you - don't want to make this interface yourself, a ready built one can be - obtained through B G Services, for BP 14.50. These are professional - quality items built into 25W 'D' connectors. The address is: - - B G Services - 64 Roebuck Road - Chessington - Surrey KT9 1JX - United Kingdom - Phone: (0181) 287 4180 (from abroad: +44 181 287 4180) - Fax: (0181) 391 0744 (from abroad: +44 181 391 0744) - Email: briang@bgserv.demon.co.uk - - - - - All sites reserve the right to ignore any order which does not comply - with the conditions above. - - - - - -1.3 Other emulators - - - I used to have a list of other emulators for the PC and other computers - here, but the list in Marat Fayzullin/Damien Burke's/Philip Kendall's - FAQ was much more complete and detailed, so I deleted mine. Philip's - latest count is: - - 32 emulators for PC's (DOS or Windows), - 9 for the Commodore Amiga, - 7 for UNIX platforms, - 4 for the Acorn Archimedes, - 4 for the Sinclair QL, - 4 for the Macintosh, - 3 for the Atari ST, - 3 written in Java, - 2 for the PlayStation, - 2 for OS/2, - 1 for the NeXTStep, - 1 for the Psion palmtop computer, - 1 for the MSX, - 1 for the Sam Coupe, and - 1 very old one for the Commodore 64 - - This probably makes the Sinclair ZX Spectrum the most often emulated - computer ever! - - There are also emulators available for the ZX81. Carlo Delhez, who - also wrote a Spectrum emulator for the QL, wrote the ZX81 emulators - XTricator (for the QL) and XTender (for PC's). There are probably - more. For more information, take a look at the FAQ of the newsgroup - comp.sys.emulators.misc. - - - - -1.4 Acknowledgements - - - From the very first beginning in november 1988, when I wrote the first - lines of code for the emulator, Johan Muizelaar has been a very - demanding and critical user, and hard to satisfy. Besides, there are - quite a few things I would never have started working on if he hadn't - insisted that I would! - - I have also profited much from the fine cooperation with Brian Gaff, - who, besides handling the UK registrations, also generates a continual - stream of suggestions, remarks and bug reports. He also brought me - into contact with many people that contributed to the emulator in - several ways. - - A major part of the things new to version 3 of the emulator have been - written by Hugh McLenaghan. He wrote all code for the Disciple/Plus D - emulation, and for the ZX Printer emulation (where I subsequently - introduced bugs...) Also, Hugh wrote much of the documentation for the - Disciple and Plus D interfaces in this file. - - - Finally, many thanks are due to - - o John Elliott, Gerardo Oporto Jorrin, Tomaz Kac, Philip Kendall, - Bernard Lutz, Lee Tonks and Wojtek Wasilewski for their - testing of (Win)Z80 version 4.00, - o Carlo Delhez for information on the '128 and several other things, - o Andre Mostert for some more '128 info and info on EMS memory, - o Walter Prins for many '128 programs, - o Marco Holmer for making the program such a big hit at the HCC dagen, - o Henk de Groot, for finding a solution to a bug in A86 v3.22, - o Arnt Gulbrandsen for a suggestion which made the emulator faster, - and information on a group of unofficial Z80 opcodes, - o Ruud Zandbergen for his digital joystick interface, - o Jan Garnier for providing the chips to reanimate my real Spectrum, - o Ettore de Simone for finding a noisy bug, - o Rudy Biesma and Tonnie Stap for providing info on the DISCiPLE disk - formats, - o Burkhard Taige for various bug reports on it, - o Ian Cull for enhancing the DISCiPLE program and two bugfixes, - o Bert Lenaerts for information on the AZERTY keyboard, - o Chris Lemon for fixing a bug in the CALL instruction, - o Robert Zmyslowicz, Einar Gattoni Saukas, Bernhard Lutz, Erik Kunze - and Lee Tonks aka Blood for their thorough beta-testing of - v3.05. - o Tomaz Kac for developing the .TZX format, - o Ian Lowndes for telling me about the speed bug in Z80 v3.05, - o Luca Bisti for suggesting to use the OPL3 sound chip, and writing - some code to implement this, - o Wim Oudshoorn for suggesting how to remove video snow in VGA modes, - o Brian Cavers for suggesting a bugfix regarding the Disciple, - o Christopher Heys for some good ideas to improve the user-interface, - o Bernard Lutz for many bug reports and ideas, - o Martin Jaroz for bug reports on .TAP/.VOC file loading and saving, - o Wojtek Wasilewski for bug reports on the RS232 redirection, - o Niccolo Rigacci for spotting a number of errors in the docs, - o James McKay for spotting a bug in the emulation core, - o Cristian Secara for his idea for the interrupt frequency switch, - o Einar Gattoni Saukas for half a dozen good ideas, - o Erik Kunze for solving a bug in the snapshot save routines, - o Alastair Booker for his thorough information on the AY chip, - o Ian Collier for precise information on Z80 timings, and for some - important experiments on the AY chip, - o Damion Yates for a solution of a problem on Novell networks, - o Gerardo Oporto Jorrin for a bug report on the RES/SET instructions, - o Igor Eged for noting a bug in the '128 OUT-port emulation, - o The people from comp.sys.sinclair, for making lots of suggestions, - telling me that they like the program, and generally for - keeping the Spectrum alive - - - - - -1.5 Disclaimers - - - The Disciple part still contains bugs, most notably one connected to - writing to an OPEN-type file. Depending on the floppy drive system, - Disciple disks may give problems reading, writing or formatting. Apart - from these problems, the system works quite well since version 3.05. - - Hi-color resolution emulation, or "rainbowing", is not perfect. What - lacks is complete emulation of ULA bus contention. This is the only - part of the emulation that is (deliberatly) imperfect. Making this - exact would make the emulation speed two times as slow. - - Many people have sent me bug reports, for which I am very grateful. I - have removed most of those, but have not been able to remove them all, - sometimes because the report was too vague and/or irreproducible on my - machine, or because of a mixture of reasons like: difficult to find, - not a problem to most people, easily circumvented, or laziness on my - part. - - - - -1.6 Copyrights etc. - - - Amstrad still holds the copyright on the 48K and 128K rom. However, - they have kindly allowed free use of them. - - The Disciple ROM is (c) Bruce Gordon / Format Publications. - - The Plus D ROM is copyright Datel / Format Publications. - - Multiface and Lifeguard are registered trademarks of Romantic Robot. - They are licensed from Romantic Robot for use in Z80. - - The registered version of the Spectrum emulator 'Z80', and the version - distributed with PC Format, may NOT be further distributed. The source - codes, which are part of the registered package, may NOT be used in - other Spectrum emulators running on PC's. In principle, it is okay to - use the Z80 emulator code in an emulator for another Z80-based - computer; however, please do contact me if you want to use it. - - - - - - -2. THE EMULATOR - - - - -2.1 Starting the emulator - - - The emulator will work on any PC with 640K memory and at least a 8086 - processor, with a VGA, EGA, Hercules or CGA video adapter. If - available, it will also use EMS memory, an Adlib (SoundBlaster) - compatible soundcard, the SoundBlaster card, a mouse, and an analogue - or digital joystick. - - The emulator will first read in the switches that are given in the - Z80.INI file. See comments in the file itself for instructions. - - The emulator tries to figure out what hardware is available, and uses - things as it finds them. Most of the time this will work without you - having to tell it anything, but if you have to, you can override the - defaults by putting switches on the command line. Switches that you - use often can be put in the Z80.INI file. If you give a switch a - second time, for instance if it is also in the Z80.INI file, it will - disable it again. - - After any switches, you may specify a snapshot file on the command - line. This file will then be loaded and executed directly. The - extension .Z80 is not necessary. The emulator also reads .SNA snapshot - files, and .SLT files (which contain snapshots together with data, for - programs that have multiple levels that originally were loaded from - tape). - - If you're using a Trident VGA with version 3 BIOS, you may see the - picture compressed at the top of the screen, while the bottom half - contains vertical white lines. This is due to a bug in the Trident VGA - Bios. Start the emulator with the switch -xv to get a full picture. - - Some VGA adapters do not produce a stable picture when Z80 is using the - standard VGA mode. If your monitor doesn't sync, try switch -xv. - - Some black-and-white VGA monitors only display one of the three RGB - colours (green most of the times), resulting in several Spectrum - colours becoming indistinguishable. Use -xb to use grey tones instead - of colours. - - It is highly recommended to have EMS memory available when running Z80. - Use e.g. EMM386.SYS for this. If there is no EMS memory, the page - swapping of the Spectrum 128 is emulated imperfectly, and very slowly. - (The emulator warns for this at startup.) Moreover, with no EMS - memory, the emulator needs lots of base memory: 578K instead of 338K. - If this causes problems, use switch -xt, which reduces several buffers - to a bare minimum, saving 51K. If this is not enough, use -xu which - saves 86K, but then hi-resolution color emulation does not work - anymore. - - The Spectrum 128 has a built-in sound chip. If you have an Adlib - compatible soundcard installed, the Spectrum 128 sound will be played - through the Adlib card. If you haven't, the loudest of the three sound - channels will be played through the internal PC speaker. Sometimes the - effect is quite nice, sometimes it is horrible, but it's all I can do - on a standard PC. If you don't want to have the Spectrum 128 sound - played through the internal speaker, use the switch -xi. If you don't - want the Adlib card to be used (for instance to hear the sound through - the internal speaker) use -xa. - - If you're using the Pro-Audio Spectrum 16 sound card, do not install - the resident FM.EXE program; it causes problems with the emulator. Do - make sure that MVSOUND.SYS is installed in your CONFIG.SYS file, to - make the Pro-Audio Spectrum 16 Adlib compatible. - - The noise channels of the Spectrum 128 sound chip can work on different - frequencies, whereas the FM chips of the Adlib card cannot. However, - if your Soundblaster is equipped with CMS chips, the noise frequency - can be programmed. Specify -xc to use the CMS chips. (These chips are - not available on Soundblaster Pro cards, and neither on most - Soundblaster clones). - - If you're living in Belgium or France, you are probably using an AZERTY - keyboard. Specifying -xz on the command line will make all letter keys - and many punctuation keys work in the right way. - - If the emulator erroneously detects an analogue or digital joystick, - use the switch -kk. - - The emulator is best run in a true DOS environment, but also works in a - Windows (95) DOS box. However, you cannot use the tape interface or - Real Mode under Windows: these are inherently non-multitasking - functions. From version 3.04, keyboard handling under Windows is much - improved. In version 4.00, Z80 by default chooses a standard graphics - mode (instead of a non-standard text mode) on VGA cards, which Windows - (95) is able to convert and show inside a window. However if you run - Z80 full-screen, it is better to use the text mode, which is selected - by switch -v. This mode is faster, and displays those loading stripes - in the border better. The virtual video driver of Windows 95 - unfortunately does not understand this mode. - - At startup, the emulator measures the speed of the computer it runs on. - Under Windows 95 this gives reliable results; however, Windows 3.1 - causes Z80 to run about 3 to 4 times slower than normal. You may have - to tinker with the speed setting to get it to run at a reasonable - speed. - - The emulator will automatically detect whether Windows is running, and - act appropriately. To run the emulator in Windows compatibility mode - in a normal DOS environment, use -xw. If you use this switch under - Windows, it turns windows compatibility mode OFF, and hangs unless you - use Hi Resolution Colour emulation (which doesn't rely on the timer). - - When running the emulator under Desqview, use -e for EGA mode display. - - At present running under OS/2 is not a good idea as it will crash if - the speed is altered. As nobody is using OS/2 anyway, I'm probably not - going to try to fix this bug. - - So that are are the most important switches that you have to specify - when you start the emulator. Most of the other switches are used to - select default values for various things which can also be changed when - the emulator is running. Some useful things to select are default - directories for .Z80/.SNA/.SLT, .TAP/.TZX/.VOC and .MDR files; these - will be explained below. - - - - -2.2 Using the emulator - - - In this section, the basic functions of the emulator, residing under - the function keys F1-F10, are explained. - - When the emulator starts, you'll see the usual Spectrum copyright - message appear on screen. Pressing F1 will pop up a small help screen - that explains the function of the function keys and various other - special keys. - - By pressing F10, you enter the main menu of the emulator. Most of the - menu options can be chosen directly by pressing another function key; a - small help screen pops up if you press F1. If you're somewhere deep in - the menu structure from the main menu, pressing ESC will get you one - level higher most of the time. Pressing F10 will get you back to the - main menu. - - The 'Select Hardware' menu option sits under function key F9. There - are seven major configuration to choose from: - - Spectrum 48K - Spectrum 48K + Interface I - Spectrum 48K + SamRam + Interface I - Spectrum 48K + M.G.T. Interface (i.e. DISCiPLE or Plus D) - Spectrum 128K - Spectrum 128K + Interface I - Spectrum 128K + M.G.T. - - This menu also allows to choose the M.G.T. type, +D, Disciple with a - pre-loaded operating system supporting graphics output using the Epson - format, and one supporting HP-PCL format graphics output. - - In all configurations except the one with SamRam, the Multiface 128 can - be emulated too. The Multiface 128 software is aware of, and can read - and write to, the Microdrive of the Interface I and the Disciple and +D - disk drive. - - After a change has been made, pressing ENTER switches to that mode and - resets the Spectrum. If you don't want the Spectrum to reset, pressing - CTRL-ENTER will switch to the new mode while preserving as much of the - runninge program as possible. Switching from 128K mode to 48K mode - will almost always crash the program, except if you enter the SPECTRUM - command before switching. Be careful when you change the disk drive - emulation; when switching an MGT interface (Disciple or +D) on or off, - it is wise always to reset the emulator, as otherwise the hardware will - often not match the system variables. - - To use SamRam's monitor on a 128 program, switch the hardware from the - main menu, and generate an NMI (Extra functions - N) before returning - to the emulator. This will often work, but you can't return to the - program without crashing it. - - On a real Spectrum 128, the menu bar of the startup screen is moved - using the cursor keys on the '128 keyboard. These keys simultaneously - press a normal cursor key (5,6,7 or 8) and shift. So you can shift the - menu bar with shift-6 and shift-7. It is possible to use the PC cursor - keys for this; you have to select Cursor joystick emulation (which is - selected by default) and press Num-Lock once to have the PC-cursor keys - press the Spectrum Shift key too. You could also specify -xs on the - command line (or put it in the Z80.INI file) to make the PC cursor keys - by default press shift for you in '128 mode; see also the Miscellaneous - remarks section. - - The Save and Load Program options (F2 and F3) will save the whole state - of the Spectrum and some of the emulators' settings to a .Z80 snapshot - file. It will pack the data somewhat, so that the length of the file - varies. The amount of memory saved depends on the current hardware - mode; 48K for normal Spectrum, 80K for SamRam, and 128K for Spectrum - 128. (Note that the RAM contents of the M.G.T. interface or the - Multiface 128 are not saved.) The settings that are saved are those - that are program dependent, for instance which joystick emulation is - used, and more technical settings like those of the R register, LDIR - and Issue 2 emulation and video synchronisation. These are explained - below. - - Loading a .Z80 file will cause several settings to be changed. - Resetting the Spectrum will not reset these settings to their default - values! Especially the joystick emulation setting change can be - confusing. - - All settings can be checked and changed in the Change Settings menu, - which pops up if you press F4. You can do many things here. The I and - O options can be used to redirect the RS232 output; see section 2.13 - for information on this. R - R register emulation, and L - LDIR - emulation are usually only necessary when loading programs; for - remarks on these options see section 2.6, and section 5.1 for more - technical details. Other settings and switches are: - - H - Hi resolution colour emulation, also called 'coppering' or - 'rainbowing'. To eliminate flickering of moving characters, and to see - some colour effects otherwise not visible. Also, this allows you to - see the famous loading stripes in the border. See section 2.4 for more - information. - - 2 - Issue 2 emulation will turn the emulated Spectrum in an Issue 2 - Spectrum. (This option also works, but is out of place, in Spectrum - 128 mode). Some very old programs (Blue Ribband, Spinads) will not - respond to the keyboard properly on Issue 3 Spectrums, and for these - programs this option was added. Seldom needed. - - S - sound enables you to turn off all sound, useful for late-night - playing. - - F - toggle between 50 Hz frame interrupt rate (the standard value) and - some value defined via the switch -dN, setting the frame rate to 100/N - Hz. Without switches, the alternate rate is 100 Hz. If -dN is used - the default rate is set to 100/N Hz and alternate rate to 50 Hz; is -dN - is specified twice (with the same divisor N) then default and alternate - rate are swapped. - - Doubling the interrupt frequency is useful for slow machines, as - some programs will run faster when this option is on. If you're typing - in a BASIC program on a slow machine, always turn this on, since the - keyboard, which is polled by an interrupt routine, will respond much - better. On fast machines, this feature is useful for running Spectrum - programs quickly while keeping a normal keyboard response. Some - programs will crash with a frame interrupt rate different from 50 Hz. - - V - video synchronisation is used to remove the flickering of moving - characters in some programs. You can choose between Normal, High and - Low. Normal works well for almost all programs; Ghosts and Goblins and - Zynaps look much better when this is turned to High. If you see - characters not moving smoothly or flicker, or a background not moving - as a whole, experiment a little bit with this setting, and re-save the - snapshot when you've found the best setting. On fast computers, try to - use Hi res colour emulation instead. This setting has no effect when - Hi res colour emulation is on. (For a more detailed discussion of this - option see section 2.4 and section 5.1) - - J - joystick emulation specifies which Spectrum joystick the PC cursor - keys (and mouse, and analogue or digital joystick, if available) - control. You can choose from Cursor (default), Kempston, Interface 2 - and user-defined. As already said above, if Cursor joystick is chosen, - the Num-Lock key controls whether Shift is pressed too with a joystick - movement. (Since the shift and number keys are pressed exactly - simultaneously, it is possible that the Spectrum has already read the - Shift key, but not yet the others, when you press both keys down. - Sometimes you will therefore get the number 5,6,7 or 8 instead of a - cursor movement. If you have used a +3 or +2A Spectrum, you will be - familiar with this!) - - Finally, C - Change speed lets you control the speed of the emulator. - As a side effect, slowing down the emulator makes the timing of the - various opcodes correspond more exactly to the actual timing on a real - processor. (Remember this is not possible on slow PCs!) - - That concludes the discussion of the F4-'change settings' menu. Let's - continue with the other function keys. - - F5 generates an NMI. This is used to activate the Samram, Multiface - 128, or start the Disciple/+D Snapshot facility. If none of these are - active it may reset the Spectrum or do nothing. - - ALT-F5 or CTRL-F5 resets the Spectrum. - - F6 turns on Real Mode. Try this when the emulator is playing a tune - and sounds a little harsh. This mode is needed when you want to load - turbo-saved games from tape; see below for more information. - - F7 and F8 activate the tape and Microdrive/M.G.T. menus. Again, see - below for more information. - - Resetting the Spectrum, or generating an NMI can be done from the main - menu too, in the X - Extra Functions menu. This is useful if you want - to activate the NMI software of the SamRam for instance just after - loading a snapshot file, or just after you changed the hardware mode. - - In this menu it is also possible to save or load a memory block or - screen snapshot; to set a breakpoint (see section 2.21) or to - temporarily shell to DOS. Furthermore, here you can find another - sub-menu for the OUT logging feature. If port FE is logged, such a log - file can be translated into a .VOC sound sample file using the OUT2VOC - utility. - - When you're typing BASIC-programs in 48K mode, you'll probably have to - look up some Spectrum keywords. Further down in this documentation - there is an alphabetical list of all keywords and their - key-combination. For 'on-line' help, press ALT-F1 to see the Spectrum - keyboard layout. - - - - -2.3 Keyboard emulation - - - The keyboard. Letter keys are mapped to the Spectrum's letter keys. - The ALT and CTRL keys can both be used for Symbol Shift. Then, there - are a lot of keys on the PC keyboard which don't exist on the Spectrum - keyboard. Many of them are used, to make things easier: - - The function keys have several special functions. See the previous - section. - - CTRL-Break quits the emulator. Better use F10-Q-Y though. - - The punctuation keys - = ; ' , . / and their shifts: _ + : " < > ? - have the effect of pressing Symbol Shift and the corresponding letter - key, so you can use these in the straightforward way. - - The ESC key presses Shift-1, EDIT, used as a sort of ESC key in many - Spectrum programs. The Backspace key presses Shift-0, the Delete of - the Spectrum. CapsLock presses Shift-2, Spectrum's capslock key. - - The PC-cursor keys and the numeric keypad keys 8,4,6 and 2 control the - Cursor, Interface 2, Kempston or user-defined joystick. The TAB key, - and 0,5 and ./DEL on the numeric keypad control the fire button. If - the Cursor joystick is selected, you can select whether Shift should - also be pressed with the NumLock key (but see the discussion above of - the -xs switch). - - If you're running the emulator on a slow computer, try doubling the - interrupt frequency (switch -d). Most programs poll the keyboard by - interrupt, in any case the ROM does, and doubling the frequency with - which this happens will make the emulated Spectrum react much more - quickly on your keystrokes. - - If you've got an AZERTY keyboard, the standard mappings of the keys - won't work at all properly. Include the switch -xz in your Z80.INI - file in this case; many punctuation keys will now also work properly. - There is no support for other non-US keyboard layouts; sorry! - - You can re-map the keyboard by yourself by using the -kx switch. It - has the format - - -kxABCD - - where #AB denoted the scan-code (in hex, between #01 and #58) and #CD - the key that should be pressed when the emulator sees this scan code. - Normal keys are coded by bytes below #40; the lower three bits denote - the row number (0-7), and the upper three bits the column number (1-5). - Column 1 of rows 0-7 are respectively Shift,A,Q,1,0,P,Enter and Space. - Column 2 to 5 are the keys on the same line, but more toward the - center. For instance, C is on row 0, column 4, and has code 0+8*4=32= - #20. Function key F11 has scan code #57, so to map F11 to C use - -kx5720. Code keys '#CD' in the range #C0 - #DD are used to code for - special keys. Here is the list of codes in this range: - - #C0 Edit #CF Joystick left - #C1 - or _ #D0 Joystick right - #C2 + or = #D1 + or = - #C3 Delete #D2 Joystick down - #C4 ; or : #D3 Joystick fire - #C5 " or ' #D4 F1 - #C6 , or < #D5 F2 - #C7 . or > #D6 F3 - #C8 / or ? #D7 F4 - #C9 * #D8 F5 - #CA Capslock #D9 F10 - #CB Numlock (Shift toggle) #DA F6 - #CC Scroll lock (+CTRL=Quit) #DB F7 - #CD Joystick up #DC F8 - #CE - or _ (for grey -) #DD F9 - - Simultaneous keypresses on the PC keyboard are only transmitted to the - PC to a certain extent, depending on the particular keyboard. My old - keyboard could handle TAB and the keys on the numerical keypad - simultaneously, but my new keyboard can't; pressing TAB blocks the - numeric keypad. Therefore, Z80 does not respond to (simultaneous) - keypresses the same way as the Spectrum does. This is not a bug, and - there's nothing to be done about it. All information sent by the - keyboard is used. - - - - -2.4 Screen emulation - - - There are two different ways the emulator can emulate the screen. The - standard way, in which 50 times an emulated second the screen is - checked for changes, and they are subsequently displayed on the - monitor. This works fine, and was the only mode available in previous - versions. It works basically the same with all video modes; however, - some are much slower than others. EGA is notoriously slow, due to the - ugly way it has to be addressed. VGA is definetely the fastest. EGA and - VGA are the only video modes in which the colour of the overscan can be - controlled; in these modes, some emulation of border effects (loading - stripes, for example) can be done. You don't see these effects in the - other video modes. - - Changing the overscan colour results in 'snow' lines appearing on the - screen. It is possible to eliminate these by waiting until the video - adapter is in horizontal retrace. This takes some time, therefore the - emulator doesn't do this in Real Mode. Real time loading requires - minimum delay, so the screen does not update. You can select the update - option, but you risk Tape Loading errors! - - In the standard mode, the point (relative to the 50 Hz interrupt) at - which the screen is displayed can be controlled by setting the 'Video - Synchronisation Mode' to normal, high or low. If you see moving - characters flickering excessively, try changing this setting. For - instance, BC's Quest for Tires won't look at all good with a wrong - setting; many programs display subtle differences in different modes. - - In the Hercules and CGA modes not all colours can be displayed. In EGA - mode, all colours can be displayed, but some colours have the same - intensity in Bright 1 as in in Bright 0. Only in VGA mode the colours - resemble closely the Spectrum originals. - - The other video emulation mode is called Hi-resolution colour emulation - mode. In this mode great care is taken to display each video line at - exactly the right time, and also the precise times the border colour is - changed is used to build the border pattern. In this mode, every - hi-resolution colour effect is visible; all flickering problems are - also eliminated (provided they weren't already there on a real - Spectrum!), so no need to adjust the Video Synchronisation Mode. - - The drawback of using this mode is that it is much slower, since the - emulator has to keep track of the number of T states passed, and also - has to grab a line from screen memory and put it in a buffer 192 times, - 50 times a second. But on fast computers, 486's and up, the emulator - can still easily emulate at 100%. - - HRC mode only works with a VGA video adapter. - - Finally, when loading turbo-saved programs in Real mode, screen updates - are suspended because they take too much time (even on fast computers). - You can refresh the screen by pressing U - Update in Real mode, but you - should do this only if you're sure that the emulated program is not - loading a block, for pressing U during loading is a sure way to get a - tape loading error. - - - - -2.5 Sound emulation - - - The Spectrum beeper is emulated by the PC's internal beeper. Because - every 1/50th of a second the screen has to be updated, and this takes a - little time even if there are no changes, the sound is a bit harsh. If - you select real mode, the emulator won't update the screen and music - will sound good. If you select HRC mode, the sound will be even - harsher than it is in normal mode. - - The sound of the Spectrum 128's sound chip is played through the Adlib - card; if you haven't got such a card some notes are played through the - internal speaker. That sound will be turned off, however, as soon as - the program makes a sound through the normal speaker of the Spectrum. - Some Spectrum 128 programs use the sound chip and the beeper at the - same time, and this won't work properly without an Adlib card. - - - - -2.6 Loading programs from tape - - - This emulator can load programs that are saved to tape in the usual - way, but also turbo-saved programs can be loaded. Furthermore, you can - make a disk file act as an 'emulated tape', so that the normal SAVE and - LOAD commands can be used to transfer data to and from disk easily. - - The emulator can load programs from .VOC sound sample files. This is - very useful for multi level games; the levels on the tape can be put in - .VOC samples, and loaded when needed without having to re-install the - tape recorder. How to use .VOC files is described in section 2.8 - below. The current section is about loading programs directly from - tape. - - First of all, you need an interface to connect the tape recorder to the - PC. There are two ways of doing this. You can use a tape interface on - the LPT port. A circuit diagram is in the DIAGRAM.Z80 program, or you - can obtain a ready-made interface from B G Services, see section 1.2 - for more details. - - Version 3 can also use the SoundBlaster for tape input. This is easier - since no additional interface is needed. The LPT tape interface - however is more robust in loading. When using the SoundBlaster, you - have to be careful not to put the volume level too high, since - otherwise the SoundBlaster will clip, which is a sure way to producing - tape loading errors. The LPT tape interface is not sensitive to this. - - It has proven very difficult to load programs directly via - SoundBlaster. This is due to the fact that the emulator does not have - time to filter the SoundBlaster input (except for a trivial hi-pass - filter to remove a 50 Hz hum) in Real mode. For direct loading, the - LPT interface is strongly recommended. For loading via the - SoundBlaster, the utility READSB (see section 2.19) will read in and - filter the sample. Loading via READSB is, I think, as reliable as - loading via the LPT interface. - - If you want to save programs back to tape, you have to use the LPT - interface; it is not possible to use the SoundBlaster for this. (There - is a way to save programs in standard format to tape though; put them - in a .TAP file - see below - convert it to a .VOC file and play this - sample to a tape. Use a good sample player, one that doesn't halt for - half a millisecond between blocks!) - - In the program DIAGRAM.Z80 a tape tester is present. The LPT tape - interface has to be calibrated, and this program can also be used to - check the volume level when using the SoundBlaster as input device. The - variable resistor of the LPT tape interface has to be adjusted so that - the bar, which should go to 0% when the volume is down, points just - below 50% at normal volume. In the case of the SoundBlaster, when the - volume is turned up, the bar first goes from 0% to 50% and over, and - then saturates and drops below 50% again. The volume has to be set - such that it is just 50% in the non-saturated zone. - - You have to tell the emulator which LPT port you use for tape I/O. Use - command line switch -b2 for example to select LPT2 for tape input (or - put it in the Z80.INI file). Use -xo to select the SoundBlaster for - tape input. It uses base address 0220 by default; if this is not - correct, use for instance -xq 0240 to specify address 0240. The - emulator does not use the SoundBlaster interrupts. - - There are two ways to load programs: in 'real' or normal mode. In real - mode, the emulator doesn't update the screen or scan the keyboard, so - that the emulated Spectrum program can run smoothly. The emulator has - to run at about 100%, but then you're able to load everything a normal - Spectrum would load, including turbo-saved programs. The only thing - you see on screen are the loading bars in the border (on EGA or VGA - screens). Real mode is selected by pressing F6. Saving programs in - real mode is a bit useless but it works; enter the SAVE command, press - a key to start saving and quickly press F6 when the saving starts. It - will continue in real mode. - - Please note that in real mode, the PC clock is not updated. It will - run behind for as many minutes as real mode has been switched on. The - CMOS clock won't be affected, so the next time you start up your - computer things will be normal again. - - If your computer is just fast enough, don't slow the emulator down too - much. Because the IN instruction is relatively slow, the emulator has - to run at about 110% for the best results. If your computer is really - fast, you can best slow it down to exactly 100%. If your computer is - just a bit too slow, you can try to make your tape recorder run slower - too (usually you can do this by adjusting a little screw at the back of - the motor), I successfully loaded several speed-saved programs at 90%. - - In normal mode, the standard ROM loading and saving routines are - 'trapped' (at addresses 04d8 and 056a) when they're about to start - saving or loading. A routine in the emulator itself then takes over, - and loads or saves a block to tape (or a disk file, see below). - - When you enter LOAD "", the emulator starts loading using its internal - loading routine. You'll see a blue window appear. Pressing F6 now - will switch to Real mode, and the emulated Spectrum program will - continue the loading process (if it is running at 100%). - - Every time a block is loaded or saved, a window containing some - information of the block to be loaded or saved appears. If you don't - want this, for example because you want to enjoy the loading screen, - specify -tx on the command line. - - Using these SAVE and LOAD routines has a great advantage as well as a - disadvantage compared to using the Spectrum's own routines in real - mode. The advantage is that the internal routines work on every - machine, no matter how slow or fast, without having to make the - emulator run at 100%. The disadvantage at using them is that they - obviously won't understand turbo-saved files. For normal use, these - internal routines work much easier, and real mode loading is only - necessary for turbo-saved and well protected programs. - - Today, most programs are protected. The emulation of the Z80 processor - has to be exactly right, or those strange decoding routines that use - all features of the processor the programmer could think of, will - definitely crash. It is most important to switch the R-register and - LDIR emulation on, as virtually all protected programs use at least the - R register. Sometimes programs are real sensitive to the timing of the - interrupts; if programs refuse to load, try sampling the first few - blocks in a .VOC file (see below) and load it from there (of course - with R register and LDIR emulation on); when loading from VOC files, - interrupt timings are exact. - - - - -2.7 Using .TAP files - - - The emulator uses files with the extension .TAP to hold a piece of - 'tape', with several blocks on it. Each block is usually either a - header or a data block; a normal file thus consists of two blocks. - There are two modes of operation when loading and saving to disk files, - single and multiple .TAP file mode. - - In single .TAP file mode, each block saved is appended to the end of - the .TAP file, like what would happen if you were actually saving to - tape. In the same way, when loading in single file mode, each time the - ROM wants to load a block, it is presented the next block in the .TAP - file. It is handled as it would if the block was loaded from tape, so - that if the ROM needs a header and is presented a data block, it will - skip it. The header will however be considered to be read. So, - entering LOAD "rubbish" will show all headers in the .TAP file, just as - an actual Spectrum would show all headers on the tape if you left the - tape running. - - If the last block is loaded, the file pointer is moved to the start - again. So a .TAP file can be considered to be an infinite tape. Single - .TAP file mode is useful to save whole programs to disk, or for - multi-load games that need to load in levels as you play. - - A sort of 'random access' file management is also useful, for instance - when you're developing a program and need to save several pieces of - data to disk and later load back a specific one. This can be done in - single .TAP file mode (by positioning the file pointer using the Browse - function), but there's a different mode of operation that makes things - easier: multiple .TAP file mode. In fact, by default the emulator is - in this mode. - - When the emulator is in multiple .TAP file mode, it will read all - blocks from all .TAP files in a specified directory, one after the - other. When it has finished reading the last one, it will start all - over again. - - When saving, the emulator will put the two blocks of a normal file, the - header and the data block, in one .TAP file with a unique name made up - of the printable letters of the file name and a two-digit number. The - name of the .TAP file is irrelevant to the emulator, but to have it - resemble the name of the actual Spectrum file you saved is simply - convenient. If the Spectrum program saves a data block to tape without - first saving a header, the .TAP file produced will contain only this - data block, and the DOS file name will be HDRLES, with a two-digit - number appended to make it unique. The format of the .TAP files saved - in multiple .TAP file mode is exactly the same as the format used in - single .TAP file mode. - - You can easily string together .TAP files; for instance a number of - .TAP files created in multiple .TAP file mode can be put into one big - .TAP file simply by concatenating them, e.g. - - COPY /B FILE1.TAP + FILE2.TAP ALL.TAP. - - Now you know what you can do, but how to get the emulator to do it? - That's what the final section is about: the tape menu. - - Press F7 to enter the tape menu. Pressing S will select or de-select - single file mode. As a default, multiple .TAP file mode is selected. - In this mode there are three other possible choices in the menu. First - of all, D selects a tape-file directory where the .TAP files will be - saved into and loaded from. A default directory can be selected by - putting the -ts switch on the command line or in the Z80.INI file; for - example -ts c:\spectrum\taps. - - The I and O options are used to select the source and destination of - the saving and loading: the LPT port (in/out) or SoundBlaster port - (only input) for a physical tape recorder, or 'disk' for disk files. - Input and output are directed to disk by default if a default tape file - directory is given by means of a switch on the command line or .INI - file. - - If Single .TAP file mode is selected, different and more menu options - appear. With R and W, the input and output tape files can be selected. - They may be the same. If a specified output file already exists, you - may choose to append to or overwrite this old file. Saving is always - at the end of the file; loading always starts at the beginning of the - .TAP file. - - A useful shortcut is ALT-F7: it will automatically select single file - mode, and prompt for an input .TAP file. - - With the B option - Browse - the position of the file pointer into the - input .TAP file can be changed. If you, for instance, type LOAD"" - instead of LOAD "" CODE, the first header is read, and you would have - to read all other headers before trying to load the file again. With - the browse option you can conveniently change the file pointer. Of - every header (that is, every block with flag byte 0 and length exactly - 17) the name and type, and of every data block the length is shown. - - The option B can also be used to delete specific blocks from a .TAP - file. Make sure you do not only delete a data block or a header, or - the ROM may get confused. (Double data blocks will be skipped, but - double headers can generate Tape Loading errors). - - As in multiple .TAP file mode, I and O are used to specify the source - and destination for saving and loading. If you enter a .TAP file name - with R or W, this will automatically be set correctly. You can then - always reset the input or output back to physical i/o again, of course. - - Finally, in Single .TAP file mode you can use 'tape mirroring': loading - programs from tape (in normal mode, i.e. not using Real mode) and at - the same time saving a copy of each block loaded into a .TAP file. This - .TAP file can later be used to load the program again, in case - something goes wrong. There are two ways of mirroring: normal - mirroring and exact mirroring. The last one must be used only in - exceptional cases; it will always make a copy of a block, even if it - had a tape error (the corresponding block in the .TAP file will also - have a tape error). This causes ticks in leader tones to make 0-byte - blocks, so the .TAP file may get messy. Do not use exact mirroring if - you don't really have to; I think normal mirroring will always work in - practice. - - If you try to leave the tape menu when for instance tape mirroring is - selected, and no output filename is given, the emulator will warn you - and will insist that the error be corrected. Yes, it's stubborn! - - One final point about multiple .TAP file mode. If you select a - directory that contains no .TAP files at all, and try to load from the - directory, the emulator will reset itself to physical tape I/O. Select - a different directory and try again. Note that simply putting a .TAP - file in the directory does not reset the emulator to multiple .TAP file - mode, as it will not look in the directory again as soon as it uses - physical tape I/O. - - - - -2.8 Using .VOC files - - - .VOC files contain sound samples, so they can also contain the sound of - a computer tape. The emulator can load programs from these sound - sample files, by keeping track of exactly how much time elapses during - the emulation of a program, and every time the emulated Spectrum - program reads the EAR port, supplying it with the right sample. Via an - intermediate file, a .OUT log file, the emulator can also SAVE and - produce a .VOC file with the right sounds in it. - - In this section .VOC file playback is discussed. For a discussion of - how to SAVE to a .VOC file, or how to produce a .VOC file of - Spectrum-generated music, please read section 2.18 about the OUT2VOC - utility. - - Because the emulator has to keep track of the emulated time, and also - has to do some calculation every time the EAR port is read (which a - program does rather often when loading), the emulation speed drops - considerably (by a factor of two, roughly) when playing back .VOC - sample files. So loading programs using VOC files may take longer than - loading them directly. On the other hand, it is not at all necessary - to have the emulator run at 100% now, so that even slow computers can - load turbo-saved programs, provided that they can read samples. And on - fast computers, the emulator can be set at the maximum speed, to load - programs much faster than usual. - - Using .VOC files is sensible for instance when you have a multi level - game, where subsequent levels are saved in a non-standard format, so - that they cannot be stored in .TAP files. The higher levels can be - stored in .VOC files, and loaded when needed, without having to - re-install the cassette player. - - You can take a sample with any sampler program. The emulator supports - most VOC block types. It does not support compressed blocks, though; - use full 8 bit samples. The problem with some samplers is that they - leave a small gap between subsequent blocks within the .VOC file. - These gaps are usually inaudible, but do cause tape loading errors. It - is very important that the sample is taken without any gaps. The - READVOC program reads samples from the LPT tape interface or the - SoundBlaster, and can take long continuous samples without gaps. - Because the emulator converts the 8-bit sample to a simple High or Low - value, READVOC also uses only two values for the signal height. This - results in highly compressible .VOC files; compression factors of about - 25 are no exception. - - READVOC is good at taking samples from the LPT tape interface, but it - performs worse when used to take samples from sound cards. You'll be - better off using samplers provided with the card. - - It is also possible to convert .TAP files to .VOC files, with the - utility TAP2VOC. This was useful to test the .VOC playback feature, - and also makes it possible to write .TAP files back to tape using a - sample player. - - To play back a VOC file, press F7 to go to the tape menu, and press P - to select the VOC file playback menu, and enter the name of the VOC - file to be played. The VOC file is now in stand-by. Just for - convenience, the emulator starts playing back the VOC file as soon as - the ROM loading routine is hit; that is, as soon as you type LOAD "" - and ENTER. The emulator will now play the VOC file to the end - (irrespective of what the emulated Spectrum program is doing with the - sound supplied to the EAR port!). When the end is reached, a window - will pop up, and the emulator switches back to normal emulation mode. - - It is possible to pause the play-back at any time. Do not do this - while loading, since it will immediately result in a tape loading - error. It is also possible to start play-back without LOAD "", which - is necessary for instance when the VOC file consists of a turbo-saved - block. - - And finally, it is possible to wind and re-wind the VOC file, as if it - were a tape. The position is displayed in minutes, seconds and - hundreds of seconds. - - Starting the emulator by "z80 -tv file.voc" will play that .VOC file to - the EAR input as soon as the emulator starts. It makes sense also to - load a .Z80 snapshot file from the command line. To make a snapshot - file that starts loading right away, type LOAD "" , press F6 - (real mode), B (back to normal mode), F2 (save snapshot) and save it. - - - - -2.9 Multi-load games - - - Some games have several levels saved on the tape, to be loaded when a - previous level is completed. There are several ways to handle these - programs. - - First, simply playing it, and loading next levels using a real - tape-recorder seems a good solution. - - If the data blocks in which the level data is saved are written to tape - in the standard format, you can convert them to .TAP files. It is most - likely that the program uses the usual ROM routine to load the blocks, - and this routine is trapped by the emulator, so that instead of loading - from tape, the blocks can be loaded from these .TAP files. To convert - the blocks to .TAP file, use a standard tape-to-tape copy program and, - in the Tape menu (F7), specify that tape output should go to some file. - If the blocks are just code blocks with header, simply enabling the - Tape Mirroring option and loading the blocks at 16384 (ignore the - crashes that most probably result; just reset the emulator and - continue) will do the trick. If the blocks are headerless, then go to - the SamRam, press NMI (F5), D for Disassembler, and L:4000 (with tape - mirroring enabled) to load and mirror each block. Here also, ignore - possible crashes which result if the block is too long. - - A general method is to store the level data blocks in .VOC sample - files. These files are huge, lengths of several megabytes are common, - but they can be compressed very tightly (if you used READVOC or READSB - to make them). Then, if you need a block, simply shell to DOS, - decompress it, and load it. - - Finally, if you want to hack into the program, you can also try to find - the routine that is responsible for the loading of a level. At the - appropriate point, enter an ED FB instruction, with A containing the - level number, and HL the address at which the block is to be loaded. - The emulator will then try to load the data. If loading failed, the - carry flag is toggled; it is untouched if the data was loaded - successfully. - - The level data can be stored in a .SLT file (Super Loader Trap file), - which contains a snapshot and can contain data for several levels. If - the current program was not loaded from a .SLT file, the emulator will - look for files with the .DAT extension. The name is made from the - snapshot last loaded, with the required level number appended in - decimal; letters are dropped from the file name if necessary to make - them at most 8 characters long. If the file is not found, the user is - informed of the level number, and given the opportunity to specify a - name. - - .SLT files can be produced using the ADDDAT utility. See also section - 5.10, file formats, for more information. - - This ED FB feature first appeared in XZX 0.5.2, and was devised by - Russell Marks. It is now supported by many other emulators as well. - - - - -2.10 Using the microdrive - - - Compared to the tape, this is really simple. Cartridges are emulated - by files of 137923 bytes. These files have the extension .MDR, and can - contain up to 126K of data. The emulator emulates 8 microdrives, the - maximum amount the Interface I software can handle, and each of these - cartridge files can be inserted in any of the 8 microdrives. (Do not - insert one file into more than one microdrive; this will cause problems - with the buffering done by the emulator as well as the Interface I, and - might result in data loss). - - Press F8 to enter the microdrive menu. Press 1 to 8 to select a - microdrive, and I to insert a microdrive cartridge. You can select an - existing one, or type a new name. If the cartridge file isn't found, - the emulator asks whether it should create it. When created, you'll - have to format it first; if you don't, you'll get a 'microdrive not - present' error when you try to read it, just as happens with real - unformatted cartridges. To format a cartridge, type - - FORMAT "m";1;"name" - - After this the cartridge should have 126K of free space. - - The cartridge can be write protected; see the menu option in the F8 - menu. This is a characteristic of the cartridge, and the write protect - tab information is therefore stored in the cartridge file. - - As on the real Spectrum, you'll have to be careful with OUT's if a - cartridge is inserted. Try OUT 239,0 (on a real Spectrum, this turns - on the microdrive motor) and wait a few seconds; most of your data will - be lost! You can stop the microdrive motor by typing STOP (or, more - generally, generate an error). - - The microdrives are emulated at IN/OUT level. This means that every - utility or program that uses microdrives ought to work on the emulator. - Most utilities use hook codes, and these will certainly work. - - The GAP line is emulated; this signal is activated if the interface I - senses a piece of tape with no data on it. If the checksum of the - first header block of a microdrive header or data block is not correct, - that block is considered to be a GAP. This will only happen if some - utility writes a bad block to microdrive deliberately, if the file is - newly created and unformatted, or when you type OUT 239,0. - - To try the microdrive, load a Spectrum program, switch to Spectrum - 48K+If.1 mode if necessary, and turn on Multiface 128 emulation. Press - F8, I(nsert cartridge), enter some file name and create an unformatted - cartridge, return to the Spectrum and press F5 (NMI), S(ave), enter - some name, choose M(icrodrive), choose F(ormat) and wait a few seconds, - then choose S(ave). Then reset the Spectrum, and type LOAD - *"m";1;"name" to re-load the snapshot you just made. - - Alternatively, switch to SamRam mode, make sure a formatted cartridge - is present, press F5, S, M, S, name, and press ENTER twice to have the - SamRam save a snapshot to microdrive. This snapshot can only be loaded - in SamRam mode. - - - - -2.11 Using the DISCiPLE and Plus D interfaces - - - For an explanation of the commands of the DISCiPLE and Plus D - interfaces, see the relevant sections in chapter 4. - - The ROM of the DISCiPLE is supplied with the emulator, together with - two version of the D.O.S. pre-loaded in RAM. The ROM of the Plus D - interface is not supplied, for copyright reasons. The emulator will - only emulate a Plus D interface if it can find a file PLUSDROM.BIN in - the emulator's own directory. If you have a Plus D yourself, you can - transfer the ROM in the following way. Load the operating system from - a Plus D system diskette, and save the entire ROM, together with the - operating system, to disk by entering SAVE d1"rom" CODE 0,16384. Then, - start the emulator and choose hardware mode Spectrum 48K + Disciple - (not Plus D of course), then type LOAD d1"rom" CODE 32768 to load the - rom at address 32768. Then type - - POKE 48623,0 - - to reset the 'open file' counter; failing to do so will result in data - being overwritten when you use the Plus D snapshot feature as the Plus - D system will not build up a used-sector-bitmap if this counter is - non-zero. You can check that this counter is 1 by typing PRINT PEEK - 48623; this one open file is the file "rom" itself. - - Finally, press F10, X, S for Save Data block, set start address and - length to 32768 and 16384 (decimal) respectively, and save the ROM by - the name PLUSDROM.BIN. If you re-start the emulator now, it will - emulate the Plus D too. - - (Aside: to use your own version of the DISCiPLE rom, proceed as above, - but type - - POKE 40431,0 - - Note that for this, the base of DISCiPLE's system variables must be - #0298 = 664 decimal. If it is different, change above address - (corresponding to location #1DEF but displaced by #8000 bytes, i.e. - relative position 6999 decimal). Then use DEBUG or any flexible - file cut-and-paste utility to put the 16K file in the correct position - in the ROMS.BIN file; see file TECHINFO.DOC for the exact position. - End of aside.) - - The emulation of the DISCiPLE or Plus D interfaces in turned on simply - by choosing the right hardware mode in the F9 menu. Changing the - M.G.T. type will result in a Spectrum reset (unless you change with - CTRL-ENTER), since a different ROM is switched in. - - By default, disks 1 and 2 refer to drives A: and B: respectively, but - this can be changed in the F8 menu. - - - - -2.12 Using the Multiface 128 - - - The following is an excerpt from the original Multiface 128 - documentation: - - MULTIFACE is a registered trademark af RORANTIC ROBOT. Multiface 128 - is a true multi-purpose interface with - - 1) fully universal and 100% automatic back-up facility for tape, - microdrive, Discovery, Plus D or Disciple (although the Discovery is - not emulated, so that that feature is not usable), - 2) 8K RAM extension - suitable for GENIE, LIFEGUARD, or as a buffer, - 3) MULTI TOOLKIT to study/modify/develop programs, POKE infinite lives, - etc. - - Multiface 128 works on the Spectrum 48/128. It can be used any time in - any mode; it is immaterial what is inside the Spectrum at that moment - or how or from what source (tape, disk, cartridge) it has been loaded - (or typed in, etc.). Multiface does not save programs, but computer - contents (compressed RAM image). Upon returning from the M128 or upon - re-loading, the programs continue as if never frozen. To use the M128: - - 1) Push the NMI key (F5) - 2) Select the required option from the menu - - The MAIN MENU options are: - - Exit: to abandon the Multiface and exit to BASIC (provided BASIC is - present). By using exit, you come out of the Multiface entirely. - All efforts are made to preserve the current program in the Spectrum - intact. The main condition is the existence of standard system - variables - without these the Spectrum crashes. A successful exit - gives you full access to the program. To restart it, if needed, you - must know the starting line or address. Exit is impossible in the - 128K mode when the edit ROM is paged and Spectrum ROM is off; in such - cases it does not appear on the menu at all. All in all, you can - only exit to BASIC if it exists - it is like jumping into a pool: a - joy if it's full of water, a crash if there is none. - - Return: to continue the program. - - Save: to proceed to the SAVE routines: - a) input the name of the program. Up to 9 characters (or just press - ENTER to the input RUN automatically as a default) - b) save to: Tape, Microdrive, Opus [does nothing], Disciple (use D - for Plus D too). You can save the entire program (including the - screen), or the screen only. Programs are compressed to take the - minimal room possible and to load faster. Screens saved on their - own are left intact as standard Spectrum screens. - c) Format microdrive cartridges. Cartridges are automatically named - after the programs to be saved. - - Tool: to access the MULTI TOOLKIT routines. - quit - to return to the main menu - Enter - to PEEK and scroll through addresses or to POKE - Space - to allow you to type in a new address - hex - to toggle between hexadecimal and decimal display format - reg - to point to the Z80 registers as they were when the program was - frozen - window - to open a window with full on-screen editing using the - cursor keys. The flashing window address corresponds to the - address in the bottom edit line. The window display is by default - in hex, but you can change it to - text - to see the 128 bytes in the window as ASCII text. - select - to inspect RAM banks 0-7 in 128K mode. Press s + the bank - number - - Print - to dump screen to printer. For printer interfaces using COPY - command. You can POKE address 8200 (decimal) with the following - values, if you wish to - 113 to turn the line feed on (cr+lf) - 112 to turn the line feed off (cr) - 17 to dump screen as text with the line feed on - 16 to dump screen as text with the line feed off - - Jump - not to return, but jump to another address. Strictly for - machine code users only. Enter the address to jump at 8192/3 - (low/hi). You can jump to Spectrum ROM/RAM and to M128 8K RAM. As - the M128 overshadows the ZX ROM (8192-16383), address 8194 determines - the paging status: if it is 0, the M128 RAM remains paged, 1 pages - out the RAM and any other value disables the jump command completely. - [Note: if it is 0, also the M128 ROM (0-8191) remains paged.] - - You can jump from the main menu, and you can also pre-program M128 to - jump directly upon NMI (F5) and by-pass the M128 ROM software - entirely. To program the direct jump, POKE 8192-3 with the jump - address, and then also 8195-7 with a special identification word RUN - (i.e. 82,85,87). Whenever you press NMI now, you will jump to the - predefined address and not see the M128 menu. To return from your - program to the program you stopped, use RST 0. To revert back to the - Multiface normal operation, press NMI and BREAK (shift+space) - simultaneously. This also cancels the code word RUN. - - In standard mode M128 uses 8192-11144 as a buffer (8192-13496 once - you proceed to SAVE) and overwrites anything in there. Using direct - jump, you have 8257-16338 available. - - Clear - to clear the extra 64K RAM bank (in 128K mode only!). You can - clear any time, but it is only useful with 48K programs in 128K mode. - However, you should save 48K programs in 48K mode anyway. Also, for - obvious reasons, clearing the banks in 128K programs is not a good - idea. - - - The actual M128 has a software on/off switch, so that it could be made - completely invisible to programs until the NMI switch was pressed. This - software switch is not emulated. The M128 could be turned off by - pressing 'O' in the main menu; this does not work on the emulator. You - can turn off the M128 in the Select Hardware (F9) menu. - - Using the extra 8K RAM - M128 has an 8K Rom containing its own - software, and an 8K RAM used as a buffer. You can use the 8K RAM for - your own mcode routines or for data (but not for BASIC). The RAM must - be paged in machine code to be accessed: use IN A,(191) to page in, and - IN A,(63) to page out. The BASIC In and Out commands can not be used - here (they work, but result in a crash). The 8K RAM overshadows the - Spectrum ROM and thus anything contained in the M128 RAM cannot make - any calls to the Spectrum ROM, as they both occupy the same area. The - M128 RAM routines should therefore be self-contained, independent of - the Spectrum ROM. - - Poking infinite lives - To POKE, say 31000,0, first load the program as - usual. When it's loaded, press NMI (F5) and select the tool by - pressing T. When the toolkit menu appears, press SPACE and type 31000. - Once you type 5 digits the cursor automatically moves to the value - field (no need to press ENTER), so type 0 (value is 1-3 digits long) - and this time press ENTER. Finally press Q to quit the toolkit and R - to return to the program. - - - The Multiface 128 was designed by Romantic Robot UK Ltd, 54 Deanscroft - Avenue, London NW9 8EN, tel. 081-200 8870. - - - - -2.13 Using the RS232 channel - - - This was the only Spectrum i/o channel that could be used in the early - versions of the emulator. Using .TAP files instead of the RS232 - channel is often easier, but sometimes using the RS232 channel can be - very useful too, for instance if you've got a null-modem lead that - connects a Spectrum with interface I to the PC you can use it to - transfer data and programs easily. Furthermore, the RS232 channel is - the easiest way to let the emulator communicate with a PC printer. - - Several things send their output to the channel designated as 'RS232 - output channel'. First of all the ordinary Interface I RS232 "B" and - "T" channels. Secondly the 128K printer "P" channel. Thirdly, ZX - Printer output is converted to a format appropriate for Epson or HP PCL - printers (works for most dot matrix, and most laser/inkjet printers - respectively) and also sent to this channel. Input from the 'RS232 - input channel' is sent to the Interface I's "B" and "T" channels. - - The Interface I RS232 port, the "B" or "T" channel, behave slightly - differently. The first, binary, channel is the raw channel. It will - let all data go through unchanged. The "T" channel won't let all - control codes through and will expand any keyword; useful for LISTing a - program but otherwise annoying. - - The Spectrum 128 has its own RS232 port; it is called the "P" channel. - Output to either the Interface I's or Spectrum 128's own RS232 port - will all be processed as 'RS232 output'. - - The output to the RS232 channel can be routed to an LPT port, to a COM - port or to a file on disk. Input can come from either a file or a COM - port. - - If you want to use the RS232 channel for printing using LPRINT and - LLIST (shorthand for PRINT #3 and LIST #3), be sure to open that - channel for output to RS232; by default it sends its output to the ZX - Printer, which is not supported. You can open the channel by typing - OPEN #3,"B" (or "T" for listings, or "P" on a Spectrum 128). - - Input and output are buffered. This is important to remember when - you're transferring files using the SAVE and LOAD *"b" commands of the - Interface I. If the header is missed, for instance if you try to load - the wrong file type, re-sending the file will not directly work because - there will still be bytes in the buffer. You have to clear the input - buffer before re-sending the file. When inputting from a disk file, - the file pointer can be reset to point to the start of the file again - to re-read the header. - - When inputting from or outputting to a disk file, the read or write - position is displayed as a byte-count. An sign will appear if an - input file is read completely through to the end. - - The RS232 redirection options are in the Change Settings (F4) menu. - - When using a COM port, make sure you have initialised it before - starting the emulator with the Dos MODE command, for instance - - MODE com1:96,n,8,1 - - initialises COM1 to send and receive at 9600 baud, no parity, 8 data - bits and 1 stop bit, the default for the Interface I. - - Here is how to transfer programs from a Spectrum to the PC using the - RS232 lead. First, you need a null-modem lead. I myself use the - following cable: - - Spectrum 'AT' 'PC' - (9 pins) (9 pins) (25 pins) - - 3 TxD ───────────────────────── RxD 2 3 - - 4 DSR ───────────────────────── DTR 4 20 - - ┌──── CTS 7 4 - └──── RTS 8 5 - - 7 GND ───────────────────────── GND 5 7 - - (so CTS and RTS have to be connected!) This is not a full null-modem - lead; you can only send data from the Spectrum to a PC. If you have an - Interface I, you can use the LOAD *"b" and SAVE *"b" commands on both - your real Spectrum and the emulator to transfer programs and data. It's - best to first type LOAD *"b" and then SAVE instead of the other way - around. If you have problems with transferring data, try to lower the - baud rate to 4800 or 2400 baud; this sometimes helps. - - If you don't have an Interface I, but do have a printer interface using - RS232 leads, then you can transfer data using LPRINT on the Spectrum - side, and INKEY$ #3 on the emulator side. It needs a little bit of - programming. - - - - -2.14 On joysticks and mice - - - The emulator support several joysticks and the Microsoft mouse, to - control several Spectrum joystick interfaces, and the AMX Mouse - interface. First, joysticks are discussed. - - As was already said in the introduction, the emulated Spectrum joystick - (Cursor, Interface 2, Kempston or user defined) is controlled by the PC - cursor keys and 5/0/. on the numeric keypad and TAB as fire keys. The - emulated joystick can also be controlled by a mouse, or by a real - joystick, either analogue (PC standard) or digital. - - The analogue joystick support is rather straightforward. If you've got - one, it works - it couldn't be simpler. The digital joystick support - is less obvious, since PC's don't support these. - - To use digital joysticks, Ruud Zandbergen has made a device that uses - the two inputs of a normal analogue joystickinterface to connect a - digital joystick to a PC. Here's the circuit diagram: - - - 15 pins male (pc) 9 pins male (joystick) - - - 1+9 <─────────┬───────────┬────────────┬─────────────┬──> 7 (5V) - ┌┴┐ ┌┴┐ ┌┴┐ ┌┴┐ - 4 x 1 kΩ │ │ ¼ Watt │ │ │ │ │ │ - └┬┘ └┬┘ └┬┘ └┬┘ - 3 <─────────┴──> 4 (up) │ │ │ - │ │ │ - 6 <─────────────────────┴──> 3 (dwn) │ │ - │ │ - 13 <──────────────────────────────────┴──> 1 (rght) │ - │ - 11 <────────────────────────────────────────────────┴──> 2 (lft) - ┌────────────────────┐ - 2 <──────────────┤ 47 Ω ¼ Watt ├───────────────> 6 (fire) - └────────────────────┘ - 4+5+14 <────────────────────────────────────────────────> 8 (0V) - - - 4+5+14 means: connect pins 4, 5 and 14. The same applies for pins 1 and - 9. Here's the list of ingredients: - - 1 x 9 pins D plug, male - 1 x 15 pins D plug, male - 4 x 1kΩ , ¼ Watt resistors - 1 x 47 Ω, ¼ Watt resistor - piece of 7-wire flatcable - - Everything can be fitted into the 15-pins plug. Make sure the resistors - don't touch the other blank connections! This interface can be used for - all usual digital joysticks, with or without auto fire (that is every - joystick that work with a Kempston joystick interface, or that work on - a Commodore 64/Amiga or Atari). The joysticks for the Spectrum +2/+3 - will not work, however the pin layout is easy to change. - - This joystick interface needs an analogue PC-joystick interface on - which you can connect TWO analogue joysticks (on one plug!). Most - cards can do this, but some multi-I/O cards support only one joystick. - Check the documentation of your I/O card to see whether your - joystickinterface is suitable. The soundblaster joystick interface - works fine. - - A number of PC games will behave strangely when the digital joystick - interface is connected; they run very slow or crash. When this - happens, remove the joystick interface (not only the joystick!). - - With version 3, the Spectrum joystick (Cursor, Kempston, Sinclair 2 or - user defined) can not only be controlled by the cursor keys or a real - joystick, but also by a mouse. Specify -km on the command line to have - the mouse control the joystick too. (By default, this switch is - already in the Z80.INI file.) - - Finally, the Microsoft mouse can control the AMX Mouse interface, as - supported for example by Art Studio. Specify -ka on the command line - to select this option. The mouse will not control the joystick - anymore. Because of I/O address clashes, the AMX Mouse does not work - with SamRam or an M.G.T. interface enabled. Also, since the AMX - interface must be initialized, and the state of the AMX interface is - not saved in the .Z80 snapshot file, it may be necessary to make the - snapshot before the point at which the Spectrum program initializes the - AMX interface. The program Art Studio re-initializes the AMX interface - regularly, however, so with this program you don't have to worry about - it. You still need to customize the program to use the AMX mouse of - course, so a snapshot of Art Studio will not automatically work; you - need to load the original from tape again, and go through the - customization procedure. - - - - -2.15 The utility ConvZ80 - - - This program converts between various snapshot formats, and it can also - convert various tape file formats to .TAP files. Currently it supports - .SNA format (used in various emulators, such as JPP, Peter McGavin's - emulator on the Amiga, and XZX), the .SP format of VGASPEC and - SPECTRUM, the .PRG format of SpecEm, and all old .Z80 file formats. - - If conversion is to a .Z80 file, the old (v1.45) format will be used. - This is still supported by the emulator, and some other programs do not - support the new format. Note that, because of this, ConvZ80 will not - convert .Z80 files containing snapshots of 128K or SamRam programs. - - CONVZ80 recognizes what it should do by the extension of the files you - enter on the command line; to distinguish between VGASPEC's and - SPECTRUM's .SP formats you can use the switch -o. If the extension - consists of digits only, it is taken to be a ZX tape file, and if it - contains non-digits and is none of .SP, .Z80, .SNA, .PRG or .TAP it is - regarded as a SpecEm tape file. - - SpecEm can load .PRG snapshot files, but cannot save them. However, it - emulates the Multiface I, which can save snapshots to tape. SpecEm - will save these blocks as tape files to disk. If you convert these to - a .TAP file (in the correct order!), you can load them into Z80 and - save the program as a .Z80 file. - - - - -2.16 Converting file formats - the utility CONVERT - - - This section is about the utility CONVERT, which can convert some of - the Spectrum's own format into each other, and also converts some of - the emulator's formats into others. It is not about converting files - from other emulators; read section 2.15 if you want to know about that. - - CONVERT was useful when the emulator could only communicate with - snapshot files and the RS232 link. It has become less useful now, with - .TAP files and the possibility to load and save blocks directly into - and from Spectrum memory, but it still has some useful features. - - It can read three types of input files: pure ASCII, pure bytes (for - instance a .SCR screen dump), and files produced by a SAVE *"b" - command. - - Output is pure bytes, ASCII with either CR (Spectrum standard) or CR/LF - (PC standard) for line breaks, SAVE *"b" files containing a Basic or - code file, a .PCX or a .GIF file. - - So what can you do? Main uses are adding LF (10 hex) bytes to a text - file produced by the Spectrum; converting a code block into a SAVE *"b" - to load it into the Spectrum using LOAD *"b" (and the reverse of - course: converting a SAVE *"b" file to pure bytes), and converting a - screen dump to .PCX or .GIF graphics files. - - Less useful, but possible: LISTing a program (SAVE *"b" file) to - produce readable ASCII, and the reverse: converting an ASCII listing to - executable Basic again. - - If you want to make a .PCX or a .GIF file, input should be a SAVE *"b" - file of a screen (length 6921 bytes exactly) or a bare .SCR screendump - (length 6912 bytes). You can make screendumps by selecting the X-Extra - functions menu from the main menu. - - - - -2.17 The utilities Z802TAP, TAP2TAPE and TAP2VOC - - - The SamRam has built in it some snapshot software. Using this software - you can save any 48K Spectrum program to tape or to a .TAP file, as is - explained in section 3.2 below. But the SamRam software cannot handle - a 128K program. The Multiface 128 can also write a snapshot to tape, - but in some cases it is still preferrable to use TAP2TAPE, since the - latter produces less and shorter blocks, and doesn't corrupt the screen - as much as the Multiface code does (on Spectrums without Multiface). - - The utility that can convert a 128K snapshot (and 48K ones for that - matter) to a .TAP file is called Z802TAP. The .TAP file includes a - basic loader, and a loading screen if you want. Z802TAP compresses the - blocks it writes (using a better method than used in compressing .Z80 - files) to save loading time. If you don't want it to compress the - blocks, for instance when you want to take a look at the ram pages of - the Spectrum 128, specify -u when you run Z802TAP. You can load the - converted program simply by executing - - Z80 -ti tapefile - - and typing LOAD "" (for a 48K program) or changing the hardware mode to - Spectrum 128 and choose 'Tape Loader' in the menu. - - Of course you could also use Multiface 128 or the SamRam to convert a - snapshot to a .TAP file. - - The program TAP2TAPE writes .TAP files back to tape. The program - consists of a batch file TAP2TAPE.BAT, which executes the TAP2TAPE.Z80 - file using the emulator. The .TAP file is written to tape exactly as - it is, so that if a block contains a tape error, it won't load - correctly from tape either. If the entire .TAP file has been saved the - emulator will start loading from tape. At that point, press space once - to return to DOS. - - The TAP2VOC program converts the tape block in a .TAP file to the - corresponding bips and clicks. The resulting .VOC file will be rather - large. It can be loaded back into the emulator, which is rather silly - since using the original .TAP file is better in all respects, or you - can write the program to tape using a sample player. - - - - -2.18 The utility OUT2VOC - and how to make .OUT files - - - The emulator can log OUTs to any I/O port. These OUTs are logged in a - .OUT file, in which is stored what was written to which port at what - time. These log files are used for recording sounds the emulated - Spectrum produces. - - The OUTs to port FE, which controls the internal beeper, and those to - ports BFFD and FFFD, which control the soundchip of the Spectrum 128, - are translated into a sample file by OUT2VOC. - - There are a number of command line switches. The sample frequency can - be chosen by specifying "-f frequency" on the command line. By default - a sampling frequency of 10 kHz is used. - - Ordinarily the OUT2VOC program filters out all frequencies above half - the sampling frequency, so that no aliasing occurs when the signal is - stored as a sequence of samples in a .VOC sample file. For sample - files containing tape data, these aliasing effects are not important. - For these sample files you can use -d to produce 'digital' sample - files, containing only 'high' and 'low' sample values, and nothing in - between. These sample files can be compressed much better. - - By default, the OUT2VOC program listens to the EAR output only. - Specify -m to have it listen to the MIC output (only), and -a to have - it listen to the AY-3-8912 soundchip of the Spectrum 128. If you - specify for example -e -a, the program will listen to both - corresponding channels. - - Usually, not all registers of the AY soundchip are updated continually. - Some registers are initialised and left at that value. So it may be - necessary to supply the initial values of the soundchip registers. Do - this by specifying '-i file', where 'file' is the snapshot taken just - before you started recording the OUTs. - - Some Spectrum programs use extremely many OUTs to produce sounds. - Fairlight for example OUTs about 70000 times a second, thereby indeed - producing one of the finest music I've every heard coming out of an - ordinary Spectrum. The OUT2VOC program takes quite some time to - compute the .VOC file from the raw .OUT output. Use -q for a quick - and little less precise conversion. The difference seems to be barely - audible. This switch has no effect when converting AY soundchip music. - - If you specify -s, silences of longer than 1 second will be truncated - to 1 second. - - Finally, use -r to produce a raw sample file, without any header or - length info. - - To record a sample, go to the Extra Functions menu (F10, X), and select - O. Select the ports you want to log (by default only FE is logged) and - enter a name for the log file. OUTs will be logged until you specify - an illegal name, or press ENTER on an empty line here. - - To save a block of data to a .OUT file, simply type the right SAVE - command or use any (turbo-save) program to save it to tape. Note that - .OUT files tend to grow fast; one bit on the tape corresponds to two - OUTs and therefore two 5-byte entries in the .OUT file; a 48K file will - produce a .OUT file of at least 4 Megabytes. - - If you give a 16 bit address for an I/O port, only OUTs to this address - will be logged. If you give an address smaller than 100 hex, all - addresses whose low byte equal this number are logged. Note that it - is not possible to log all OUTs to, say, an even port. Although the - MIC and EAR ports respond to all even port addresses, virtually no - program uses a port different from FE, so this will be no problem in - practice. - - Note that whereas the 'official' addresses of the register and - value-port of the AY soundchip are FFFD and BFFD respectively, some - programs use other ports that work too. One particular program uses - BEFD, heaven knows why. For these programs, specify FD (or 00FD) as - OUT port to log; this will ensure that all OUTs to any address with low - byte FD is logged (which, alas, includes the much-used port 7FFD). - - A recent discussion on comp.sys.sinclair revealed that the AY - conversion of OUT2VOC leaves much to be desired. It is on my list of - things-to-do. - - - -2.19 The utilities READVOC and READSB - - - These programs can read samples from the LPT port or the SoundBlaster - and store them in .VOC files, for later play-back to the emulator. - This is useful when you use the SoundBlaster as input device, as direct - loading is not very reliable then because Z80 does not filter its input - appropriately; you can store level data of games on hard-disk and load - them without having to play the actual tape again; thirdly, this allows - you to try to load the program with different emulator settings easily. - - READVOC uses polling to read the sample. This method does not allow - for very high sample frequencies (even 20 kHz is too much sometimes), - and does not work reliably in multi-tasking environments (DOS boxes of - Windows (95) for example). It is however the only way to take samples - from the LPT interface, and works well under DOS. - - READSB has been written for taking samples from the SoundBlaster. It - uses DMA to read the sample, and applies a digital filtering algorithm - for reliable loading. It offers a number of command-line switches. - Digital filtering is highly recommended: for programs that use the - ordinary tape format, -n is appropriate; for turbo-save formats, use - -d. If neither of -d and -n are used, ordinary analogue sample files - are produced, which will very often not load successfully when played - back to Z80. For low sample rates, say 10 kHz, it is a good thing to - use two-times oversampling (switch -2). - - When READSB is started, it displays a signal level bar. Set the volume - so that a reasonable input level is reached; do not increase the volume - too much above 50%. Press any key to start sampling, and then 'p' to - pause and display the signal level bar again, or any other key to save - the sample and quit. - - READSB uses 0220 as default base SoundBlaster I/O address, and IRQ 7 as - default interrupt level. Be sure to set these to their appropriate - values if your card is not set to these defaults. - - Both READVOC and READSB produce very large files. Be sure to have - several megabytes of free disk space available. After sampling, these - sample files can be compressed using ordinary compression programs to - very small sizes. - - - -2.20 Quick overview of command line switches, and features - - In this section I will briefly explain all command line switches. It - is useful to at least once read this section carefully; there are a few - small handy features that will are easily missed. Starred switches are - by default put in the Z80.INI file. - - -h Hercules graphics - -c CGA graphics - -e EGA graphics - -g VGA graphics - 320x200x256 graphics mode 0x13 - -v VGA graphics - text mode (fast; default) - - Usually the emulator will by itself correctly determine which mode to - use. VGA mode -v is the best: it is the only mode in which all colours - are correct (including the bright hues), has the best border emulation, - and it is also the fastest mode. However, those programmers of Windows - did not implement a full VGA emulation, and in a Windows DOS-box, mode - -v will only work correctly in full-screen mode. In windowed mode, - mode -g does work. In a DOS box, Z80 by default chooses -g. - - Versions prior to v3.04 also had Plantronics and Extended Hercules as - possible video modes; these were removed to save memory. - - -xv 400-line VGA (for some Tridents) - -xb Black-and-white VGA - - The black-and-white switch is useful on black-and-white monitors; - sometimes those only display one component of the RGB signal instead of - a weighted average, so that some colours become indistinguishable grey - tones. - - Some Trident video adapters, as well as some others, have a bug in - their video BIOS: they don't want to be put in 200-line mode. To get - around this, when -xv is specified 400-line mode is used with a double - amount of lines. - - -n Emulate Spectrum without Interface I - -s Emulate Spectrum with SamRam - -1[28] Emulate Spectrum 128 (can be used with -n) - -xk Emulate Multiface 128 interface (can't be used with SamRam) - -9 Default to M.G.T. interface instead of Interface I - -0d M.G.T. = DISCiPLE ROM (default) - -0p M.G.T. = Plus D - - These switches select the default start-up hardware configuration of - the emulator. This can all be changed in the Change Hardware menu - under function key F9. - - * -znnn.n Emulate the Spectrum at speed nnn.n% - - The most sensible setting for this is -z100. By default this is done - in the Z80.INI file. - - -xx Hi-resolution colour emulation - - This selects hi-res colour emulation by default, so that border effects - and hi-res colour effects are visible. This setting can be changed in - the F4 menu. - - -r Emulate the R register - - This is usually necessary in turbo loaders and otherwise protected - programs, since they almost invariably use the R register to decode - things. The R register has to be updated every instruction, so that - enabling the emulation of it reduces the emulation speed considerably, - by some 30%. Don't do it unless it proves to be necessary. I don't - know of any program that uses it on the run. If the R register is not - emulated, the R register acts as a random generator. - - * -l Better (but slower) LDIR/LDDR emulation - - Normally a 8086 MOVSB is used to emulate an LDIR or LDDR. This is a - fast instruction. Programs that use them a lot, most notably Jetset - Willy and Manic Miner, run very fast. On slow computers these programs - are the only ones that are really playable. On fast computers they run - much too fast, so it is a wise thing to use -l on fast computers. - Secondly, without -l the LDIR instruction is not emulated correctly - when it overwrites itself; with -l it is. - - -yl, -yh Low, high video synchronization mode - - These switches control the phase between the 50 Hz interrupt and the - screen refresh. Some programs need a different setting in order to - remove flickering of moving characters. Enabling hi-resolution colour - emulation also eliminates these problems. - - -2 Emulate an Issue-2 Spectrum - - The EAR input line depends on the EAR and MIC output, and the signal - fed in to the Spectrum's EAR plug, and this dependence differs between - model 2 and model 3 Spectrums. Some old programs only work on Issue 2 - Spectrums. The problem is usually that the program does not respond to - the keyboard. Try Spinads for example. - - -dN Set frame interrupt frequency to 100/N Hz - - There used to be an option -d which set the frame interrupt frequency - to 100 Hz; therefore now -d is equivalent to -d1. -d2 is the default - setting, 50 Hz. On slow computers, -d helps to get a better keyboard - response. On the other hand, setting for instance -z350 -d7 makes Z80 - emulate a Spectrum 3.5 times as fast while maintaining normal keyboard - response. At run time, the frame interrupt rate may be toggled between - 50 Hz and the value set by this switch. If you set -dN twice, then the - emulator starts off with a 50 Hz frame rate, with alternate rate set to - 100/N Hz. - - -aN Redirect Spectrum RS232 output to LPTn - -oN Redirect Spectrum RS232 output to COMn - -uF Redirect file F to Spectrum RS232 input - -iN Redirect COMn to Spectrum RS232 input - -wF Redirect Spectrum RS232 output to file F - - All output to, and reading from, the Interface I's RS232 channel - (channels "b" and "t"), the 128K printer channel (channel "p") will be - sent to, respectively read from, the appropriate device. Furthermore, - output to the ZX Printer will be converted in a format suited for Epson - matrix printers or HP Laserjet printers and also be sent to the 'RS232 - output' device or file. - - -g No sound - -xa Do NOT use AdLib for 128 sound - -xc Use SoundBlaster CMS chips for noise - -xi Do NOT use internal PC speaker for '128 sound - - If no AdLib compatible card is detected, 128K sound output will be - sent, as far as is possible, to the internal PC speaker. Use -xa to - hear 128K sound through the PC speaker when there is an AdLib card - present. - - Without CMS chips, the 128K soundchip's noise cannot be faithfully - reproduced. If you have CMS chips installed, use -xc to use them. If - the SoundBlaster is on a different base address than 0220, use -xq to - select it. - - * -km Use MS Mouse to control Spectrum joystick - -ka Emulate Spectrum AMX mouse interface controlled by MS Mouse - -kz Use digital Zandbergen joystick - -kk Do not look for analogue or Zandbergen joystick - -k1 Do not use 2nd analogue joystick as Sinclair 1 (1,2,3,4,5) - -k2 Use 2nd joystick as Sinclair 1 always - - The emulated joystick (Cursor, Kempston, Sinclair 2 or user defined) is - controlled by the arrow keys and TAB, 5, INS (0) on the PC keyboard, - and optionally also by a digital joystick, and analogue IBM joystick or - a mouse. Use -kk if the emulator erroneously detects either joystick. - If -ka is specified, the PC mouse controls the emulated AMX mouse - interface. Because of I/O address clashes, this only works with SamRam - and the M.G.T. interfaces disabled. The AMX mouse is supported by e.g. - Art Studio. - - A second analogue joystick will, when present, always be attached to - keys 1 to 5, the Sinclair 1 joystick keys. If neither -k1 nor -k2 is - given, the emulator will look if the second joystick is in an - acceptable neutral position (i.e. is attached) and if so will use it. - This will usually work. If it incorrectly recognizes the joystick use - -k1. If it doesn't recognize a joystick while it is connected, use - -k2. - - -jc Emulate Cursor joystick (default) - -jk Emulate Kempston joystick - -j2 Emulate Sinclair joystick 2 (keys 6,7,8,9 and 0) - -ju User defined joystick - - Also quite clear I think. For instance, -juipqzm makes the joystick - control the i,p,q,z and m keys, for instance to play those lovely - Horace games. Special characters are [ for shift, ] for symbol shift, - / for enter and \ for space. - - * -xs Default to shifted cursor keys (NumLock) in '128 mode - - By default, the PC arrow keys control the cursor keys 5,6,7,8 and 0 of - the Spectrum. The Spectrum 128 had its arrow keys press the cursor - keys plus shift, and the menu bar of the reset screen of the '128 only - responds to shift+cursor key. - - -bN Use LPTn for tape I/O - -xo Use SoundBlaster's A/D Converter for tape input - -xq adr Set base IO address for SoundBlaster (default 0220) - - Either the LPT tape interface of the SoundBlaster is used for tape - input. Only the LPT tape interface can be used for tape (MIC) output. - - -tv F Play .VOC file F to 'ear' input - -m N F Insert cartridge file F{.MDR} into microdrive N - -xm D Select default directory D for .MDR files - -td D Select directory D for Multiple .TAP File mode - -ts D Specify default directory for Single .TAP File mode - -ti F Use F{.TAP} as tape input - -to F Use F{.TAP} as tape output (if exists, append) - -tm Mirror tape input to disk (Do also specify output file!) - -te Mirror tape input to disk in EXACT mode - -tw Don't wrap load pointer of tapefile at end - -tp Pause after loading .TAP block - - All quite clear I think. If -tv is used, the VOC file starts playing - immediately, so be sure there's an appropriate snapshot running to do - something with the signal. -tw makes the emulator load from physical - tape when a .TAP file has been read to the end, instead of starting - again from the beginning. It is used in Tap2Tape. - - -xl N Select LPTn for ZX-Printer output - -xj 'Off-line=wait' instead of 'Off-line=No ZX Printer' - -0e Epson printer (for ZX PRINTER & M.G.T.) - -0h HP PCL printer (for ZX PRINTER & M.G.T.) - -0f N Issue a Form Feed every N ZX Printer lines when printing - to a HP PCL compatible printer - - Output to the ZX Printer will be converted into graphic data in Epson - (most matrix printers) or HP PCL (most inkjet and laser printers) - format. Use -0e or -0h to select which format to use; default is Epson - format (defaulted in Z80.INI). Also, this selects the default DISCiPLE - ROM to be used; the two ROMs have different screen dump routines - pre-loaded. If you're using a Laser printer, use -0f 103 to have Z80 - eject the page once in a while. 103 lines approximate one sheet A4. - Select the LPT port to print the data to with -xl; default is LPT1. - - If the printer to which ZX Printer output is sent is absent, busy or - off-line, the emulator tells the Spectrum program that the ZX Printer - is not attached. If you want the Spectrum program to wait in case of - an off-line or busy printer, then put -xj in the Z80.INI file. This - switch is not defaulted because printers sometimes say they're merely - busy or off-line when in fact they are not there at all. Besides, some - Spectrum programs do a COPY without asking, and with this switch the - program would lock up (as versions 3.00 to 3.02 did; in v3.03 and above - you can BREAK into such a loop). - - If a printer becomes off-line or unavailable during printing, Z80 will - try to finish its job anyhow, and the program may appear to hang. - Pressing the space bar will make Z80 break the printing loop, and - signal to the Spectrum program that the ZX Printer does not exist. - This, in turn, will cause the ROM printer routines to just skip - printing. Z80 will periodically check the printer status, and when it - becomes available again will make the ZX Printer appear again. - - -0i Disable Disciple interrupt - - Normally the Disciple and Plus D have their own interrupt routine being - executed 50 times a second. Because this involves many page swaps, - this is quite slow on the emulator. Since the interrupt is not really - necessary anyway, it is reduced to once every two seconds. On some - computers this may still be too much, in which case -0i completely - disables the Disciple and Plus D interrupts. Do not try this in - Unidos! (which is not emulated [yet].) - - -0sND Set Disciple/+D drive N to D: - - By default, the Disciple/+D drive 1 controls drive A: while 2 controls - B:. If, for example, your B: drive is your only 3.5'' drive, you might - want to map both 1 and 2 to B: which is accomplished by putting -0s1b - in the Z80.INI file. - - -xp D Select default directory D for .Z80 snapshot files - - Clear. - - -xz Assume AZERTY keyboard layout - - Assumes the Belgian and French AZERTY keyboard layout. - - -xr F Use file F as standard Spectrum rom - - The ROM will be used in 48K modes only, and must be exactly 16K long. - - -xt Use as little memory as possible with full functionality - -xu Use as little memory as possible; disable HRC emulation - - With -xt, all unnecessary buffers used for efficiency purposes only are - reduced to minimum size. Saves 47K, but can make all the difference - sometimes. With -xu, 83K is saved, but Hi Resolution Colour emulation - won't work anymore. - - -tx Do not display tape info window when loading or saving - -00 Do not show intro screen, and don't pause at startup - - Some people seem to really hate either, or even both. Don't know why. - For better annoyance, -00 only works in the registered version. Hehe. - - -xe Do not use expanded memory - - Specifying this switch will result in the emulator using 240K more base - memory (making a grand total of 564K). Furthermore, all page swapping - will be much slower, so especially the 128K emulation gets verrry slow. - - -xg Log all outs to FE in OUT log file - -xy Dump trace of program in .OUT file - - By default, OUTs to port #FE that do not change the state of either MIC - or EAR are not saved to the log file, to save disk space. If, for some - reason, you want all OUTs to be logged, -xg will do the trick. The -xy - option can be used for producing a somewhat crude trace; see section - 5.10 on the .OUT format for more details. - - -0m F Build map of opcode locations in file F - - When this option is specified, Z80 keeps a map of the 65536 address - locations in memory, and tags the address of each instruction that is - emulated. When the emulator is shut down, this map is written to disk - as a 8192 byte file. See section 5.10 of TECHINFO.DOC for an - explanation of the file format, and remarks on how to use this feature. - - -xw Run in Windows compatibility mode - - In this mode, the timer is not re-programmed. The emulator counts T - states to see when an interrupt has to be generated (so emulation will - be slower). In a Windows (3.1 or 95) DOS box, using -xw will turn - Windows compatibility mode off (as Z80 is aware of Windows and has - turned this switch on itself in that case) and the emulator will - usually hang. There is probably never a need to use this switch. - - -kxABCD Press key #CD for scancode #AB. - - This can be used to re-map the keyboard, for instance if your C key is - broken, you can re-map it to F11, or any other key for that matter. - Combinations are hard-coded, so that a key pressing , also presses < - when shifted. The scan code is between #01 (ESC) and #58 (F12); a full - list can be found in many places. The format of the key byte is - explained in section 2.3. - - -xf Switch full 16K of Interface I ROM - - Useless. - - - - -2.21 Miscellaneous remarks - - - 1. Problems at the Rom/Ram boundary - - There are a few Spectrum programs that have an odd stack pointer, and - run over the ram/rom boundary, for instance Deep Strike, and Elite. - This crashed version 1.45 of the emulator; the problem was circumvented - somewhat in version 2.01, and has been removed in version 3: in most - cases, a word read from or written to FFFF will be read or written as - two bytes. You can check this by typing CLEAR 65535: POKE 65535,0: - RETURN in BASIC; this will lock up version 1.45 of the emulator, it - will lock up version 2.01 if the 80386 is in virtual mode, and it will - only crash the emulated Spectrum (as it should) on version 3. - - The check on FFFF is not done at every potentially problematic op-code, - because this would make the emulator noticeably slower. It is - therefore still possible to 'hang' the emulator. Not going to tell you - how, though. All existing programs seem to work okay now. - - - 2. Critical timings - - A few programs (the only examples known to me are Fireman and Thing, - but there are more) are quite sensitive to the relative actual - execution speed of emulated Z80 instructions, and crash if it isn't - right. They rely on this-or-that amount of instructions to be executed - between interrupts. If you slow down the emulator, these program will - run fine, because then individual instructions are more carefully - timed. When running in Windows compatibility mode, loading .VOC files - or when the Hi-Res Colour emulation is switched on, these problems - disappear completely as the emulator is then counting off the exact - number of T states to elapse between interrupts. - - - 3. Shifted cursor keys - - It may be annoying to have to press Num-Lock every time you use the - Spectrum 128 (because otherwise you'll have to use Shift with the - cursor keys to move the menu bar). To make the emulator press shift by - default every time you use the PC cursor keys in '128 mode, use the - switch -xs. If you press Num-Lock now (in '128 mode), the shift-key - won't be pressed. The 48K modes are not affected by this switch. - - - 4. Running non-standard ROMs - - To run the emulator with a different rom than the standard one, you can - specify a rom image file on the command line. Use the switch -xr file, - where 'file' is the name of the image file. This file should be - exactly 16384 bytes long. It will of course not be used in Spectrum - 128 or SamRam mode. - - The emulator 'ZX' by Rindt and Bruckner comes with several roms, stored - in their tape format. You can convert these files to .TAP files, and - then load them in the normal way (in RAM), and then save the 16K image - from RAM directly. You can also extract it from the files directly by - using the DOS debug utility: - - C:\>debug rom.000 (or other rom file (of 16406 bytes)) - -m 115 L 4000,100 (move the rom down, overwrite header) - -rcx (new length of exactly 16K bytes) - CX 4016 - 4000 - -n rom000.bin (or some other name) - -w (write it) - Writing 04000 bytes - -q (and quit) - - - 5. Printing with DISCiPLE and Plus D - - If, emulating a DISCiPLE/+D and by entering POKE @11,0 the parallel - printer output has been selected, going back to a hardware mode without - M.G.T. interface causes problems with printing to the ZX Printer, since - the output addresses of the "p" channel have been changed by the M.G.T. - ROM. Use the "b" channel of the Interface I instead. You can reset - the channel to the ZX Printer by entering POKE @11,1 while still - emulating the M.G.T. interface. Note however that the printer OUT port - #FB of the ZX Printer is used by the Disciple printer interface, so - that using the ordinary ZX Printer code of the ROM results in rubbish - coming out of the printer. The +D can use the Centronics interface and - the old ZX Printer at the same time. - - Although by default channel #3 prints to the ZX Printer, in all - hardware modes, if a DISCiPLE/+D is emulated output to the ZX Printer - is ignored, as these interfaces use the ZX Printer I/O ports for their - own purposes. - - - 6. Breakpoints - - A Breakpoint may be set in the Extra Functions menu, option B. If it - is set, the emulator will at the beginning of each instruction check - whether the program counter is equal to the breakpoint address. If - this is the case, it notifies the user, and continues to the main menu. - You could now save the snapshot and inspect register values using - Z80Dump, for example. You could change hardware mode to SamRam, and - generate an NMI from the menu (using Extra Functions, N) to inspect the - code around the breakpoint. - - Some fine points. If a breakpoint is hit, the instruction at the - breakpoint address is not yet executed. It will be upon returning. If - you generate an NMI, and subsequently return from it, the first - instruction that will be executed after the NMI is the instruction at - the breakpoint; this will thus make the emulator go to the main menu - once again. Press ESC to continue emulating. - - For technical reasons, when counting T states, the time taken by the - instruction directly preceding (in execution) the one at the breakpoint - address is not taken into account. When the emulator hits a - breakpoint, the current frame will be a few T states longer. Not that - you'll notice, probably. The R register is counted through properly - (if it's emulated, that is.) - - If the breakpoint address happens to point to an operand instead of an - opcode, the emulator will not respond. - - - 7. Emulation of floating bus - - Reading from e.g. port #FE accesses the ULA bus which is used to read - the screen memory. While the ULA is generating the border or - horizontal or vertical retrace signals, this will result in #FF; - otherwise, the value returned is the ATTR or screen byte the ULA is - currently reading. Some programs use this to check whether the ULA is - in vertical retrace (Arkanoid), some use it to actually wait for - specific bytes to pass, which signals that a certain part of the screen - is being generated (Ricochet). Only in Hi Res Color mode will the - emulation of this effect be reasonably accurate to get Ricochet running - correctly. Arkanoid runs reasonably well, but due to the way it is - implemented it produces 'ticks' in the speaker when it is not run in - HRC mode. - - - - - - -3. THE SAMRAM - - - - -3.1 Basic extensions - - - The SamRam is a hardware device Johan and I built for our Spectrums. It - consists of a 32K static RAM chip which contains a modified copy of the - normal Basic ROM and a number of other useful routines, like a monitor - and snapshot software. You can compare it to a Multiface I interface, - but it's more versatile. Another useful feature was a simple hardware - switch which allowed use of the shadow 32K Ram, present at 8000-FFFF in - most Spectrums, but hardly ever actually used. - - For more details on the low-level hardware features of the SamRam read - chapter 5. In this chapter I'll explain the software features of the - SamRam software, somewhat bombastically called the 'SamRam 32 Software - System' or the 'Sam Operating System'. By the way, all similarity - between existing computers is in fact purely coincidental and has in no - way been intended. Really! - - The SamRam offers a few new Basic commands, and a lot of useful - routines that are activated by an NMI, i.e. by pressing F5. First - I'll discuss the Basic extension. - - Select the SamRam by starting the emulator with the -s switch, or by - selecting it from the F9 menu. Normal Basic functions as usual; the - character set is different from the original one. There are four new - commands: *RS, *MOVE, *SAVE and *SPECTRUM, and two new functions, DEC - and HEX, which have replaced ASN and ACS. DEC takes a string argument - containing a hexadecimal number, and returns the decimal value of it. - HEX is the inverse of the DEC function, and yields a four-character - string. - - *RS sends its arguments directly to the RS232 channel. You don't have - to open a "b" or "t" channel first. You're right, it's of limited use. - Example: *RS 13,10 - - *MOVE is useful: it moves a block of memory to another place. Example: - *MOVE 50000,16384,6912 moves a screen-sized block from 50000 to the - start of the screen memory. - - *SAVE works like *MOVE, except that it activates the shadow SamRam ROM - before moving. I used this command to update the shadow ROM, but on - the emulator you can use it to move the shadow ROM to a convenient - place in Ram where you can take a look at it, for instance by executing - *SAVE 0,32768,16384. - - *SPECTRUM resets the SamRam Spectrum to a normal one. You lose all - data in memory. By resetting the emulator by pressing ALT-F5, the - SamRam is activated again. Not very useful either. - - Then there's the Ramdisk, which is, like the Spectrum 128 ramdisk, - accessed via the SAVE!, LOAD!, CAT!, ERASE! and FORMAT!. The syntax is - straightforward. FORMAT! and CAT! need no parameters; ERASE! only - needs a name. If a file is not found, the SamRam will respond with a - 5-End of File error. The Ramdisk has a capacity of 25K. - - - - -3.2 The NMI software - - - Select the SamRam (F9-3), and press F5. A menu with eight icons pops - up. You can select each icon by moving the arrow to it (using the - cursor keys or the Kempston joystick), and pressing '0' or fire. The - icons can also be selected by pressing the appropriate letter key. - - The eight icons are two arrows with N and E within them, a magnifying - glass with the letters 'mc' in it (activated by pressing D), two - screens (identified by 1 and 2), a printer (P), a cassette (S) and a - box saying 'overig'. The 'D' activates the monitor or disassembler; - read section 3.3 for information on this program. - - Pressing N or E returns you to the Spectrum. If you pressed N, the - normal Spectrum rom will be selected when the NMI software returns; if - you press E, the Rom with the Basic extensions will be selected. Some - games may crash if they see a different rom than the standard Spectrum - one. - - Pressing 1 selects the tiny screen editor. You can move a '+' shaped - cursor about the screen using the cursor keys. The following commands - are available: - - H: Get the current ATTR colour from the screen at the cursor's - current position, and store it in memory. This colour will be - used by the next command: - Z: Put the colour on the screen - G: Get a character from the screen - P: Put the character on the screen - R: Remove all screen data that is invisible by the ATTR colour - L: Take a look at the bitmap below the ATTR colour codes - T: Return to the main menu. You can also return by pressing - EDIT, or ESC in the emulator. - B: Change border colour - V: Clear the whole screen - - If you press 0, you can edit the current 8x8 character block at pixel - level. Again you control the cursor with the cursor keys. Now 0 - toggles a pixel. In this mode there are two commands: C clears the - whole block, and I inverts it. Pressing EDIT (ESC) returns you to the - big screen again. - - The SamRam has two screen buffers. Buffer 1 is used to hold the screen - which was visible when you pressed NMI, to be able to restore it when - returning. This is the screen you edit with '1'. The second screen - buffer can be used to hold a screen for some time; it is not touched by - the NMI software directly, and will not even be destroyed by a Reset. - If you press '2', a menu appears with four Dutch entries: - - 1: Scherm 1 opslaan (Store screen 1 into buffer 2) - 2: Scherm 2 veranderen (Edit screen 2) - 3: Schermen verwisselen (Swap screens) - 4: Scherm 2 weghalen (Remove screen 2) - - These four functions are rather obvious, I believe. - - Pressing 'P' pops up the printer menu. The screendump program is - written specifically for my printer, a Star SG-10. It will probably - work on some other printers, but not on most. The output is sent to - the RS232 channel, so you have to redirect it to an LPT output. - - Skipping the most interesting, 'S', for a moment, let's first discuss - the final menu, 'O' for 'Overig', Dutch for miscellaneous. There are - five menu options, of which three are not useful. The first gives a - directory of the cartridge currently in Microdrive 1. The last, 'E', - returns you to Basic if this is anywhere possible: it resets some - crucial system variables and generates a Break into Program. You can - use this for instance to break in a BEEP, or crack a not-so-very-well- - protected program. The three other options select normal or speed- - save, and store the current setting in CMOS Ram. Speed-save won't work - properly on the emulator, because the speed-save routine toggles the - upper 32K ram bank regularly, and this takes too much time on the - emulator. The setting is not important if you use the internal save - routine (which will be used by default, unless you select Real Mode). - - Finally, the 'S' option. This option allows you to save a snapshot to - tape or microdrive. I used it a lot on my real Spectrum, and it works - just as well on the emulator. It is very useful is you want to load a - .Z80 program back into a real Spectrum again. There are three - 'switches' you can toggle. The active choice is indicated by a bright - green box, inactive boxes are non-bright. You have to use EGA or VGA - to be able to see it... The first switch lets you select whether the - SamRam rom should be active if the program loads or not. This is only - meaningful is you load it back in a SamRam again. Usually I want the - SamRam rom to be active because I like the character set better. The - second switch indicates whether the SamRam should save a 'loading - screen', which it takes from screen buffer 2. If screen buffer 2 - contains a screen, this switch will by default be on. Finally, the - last switch lets you select the output media, tape or cartridge. - - If the program is loaded back into the SamRam, the only bytes that have - been corrupted are four bytes down on the stack; this will virtually - never be any problem. If the program is loaded back to a normal - Spectrum, these four bytes will also be corrupted, and the bottom two - pixel lines of the screen will be filled with data. (This is - considerably less than any other snapshotter I've seen: for instance - the Multiface I uses more than 35% of the screen!) - - The Microdrive BASIC loader needs code in the SamRam rom to start the - program (the RANDOMIZE USR 43 calls it). It won't be very difficult to - write a standard BASIC loader that doesn't need this code, but I don't - think many people desperately need it... Anyway, using the Multiface - 128 you can write a compressed snapshot to cartridge which doesn't need - the Multiface. - - - - -3.3 The built-in monitor - - - This is a really very convenient part of the emulator, and I use it a - lot. It is very MONS-like in its commands and visual appearance. It - cannot single-step however, but on the positive side it has some - features MONS hasn't. It is a part of the SamRam, and cannot therefore - be used with Spectrum 128 programs. If you want to take a look at a - Spectrum 128 program, press F10, then change the hardware to SamRam - without resetting, and finally generate an NMI in the Extra Functions - menu. You won't probably be able to continue to run the program, but - at least you're able to see what it was doing. - - Press F5 for NMI, and D to enter the monitor/disassembler. The first - eight lines are the first eight instructions, starting at the Memory - Pointer, from here on abbreviated by MP. At first, MP is zero. The - disassembler knows all official instructions, and the SLL instruction. - If another unofficial instruction (i.e. starting with DD, FD or ED) is - encountered, the first byte is displayed on a blank line. The four - lines below these display the value of PC and SP, the first nine words - on the stack (including AF and the program counter, which have been - pushed during NMI), and three MP-memories. These can be used for - temporary storage of the MP, for instance when you take a look at the - body of a CALL, and want to return to the main procedure later. - - The bottom part of the screen displays 24 bytes around the memory - pointer. - - Commands are one letter long; no ENTER needs to be given. If one or - more operands are needed, a colon will appear. By default the monitor - accepts hexadecimal input. A leading $ denotes that the number is to - be regarded as decimal. If you give the # command, the default will - toggle to decimal, and you need to explicitly put a # in front of a - number which is to be interpreted as a hex number. Also, after the # - command all addresses on screen will be decimal. A single character - preceded by the " symbol evaluates to its ASCII code, and the single - character M will evaluate to the current value of the memory pointer. - - The monitor commands: - - Q: Decrease the memory pointer by one. You effectively shift one - byte up. - A: Increase the memory pointer, shifting one byte down. - ENTER: Shift one instruction down: the memory pointer is - increased by the length of first instruction displayed on - screen. - M: Change the value of the memory pointer. For instance, M:M - won't change it. - P: Put. The word operand supplied will be stored in the first MP - memory, and the others will shift on place to the right. - Usually, you'll want to store the memory pointer by P:M - G: Get. Typing G:1, G:2 or G:3 moves the value of one of the MP - memories to the MP. - B: Byte. This command needs a byte operand; it will be poked - into memory, and the memory pointer will move one up. - I: Insert. The same as B, except that you can poke more than one - byte. It continues to ask for bytes to poke until you type - Enter on a blank line. - #: Toggles the default number base between hexadecimal and - decimal. - F: Find. You can enter up to ten bytes, which will be searched - through memory. Searching will stop at address 0, because - since the search string is stored in shadow Ram, searching - would otherwise not always terminate. Typing Enter on a blank - line starts the search. Byte operands are entered as usual, - but: - - If a number bigger than 256 decimal is entered, it is - treated as a word in the standard LSB/MSB format. So, 1234 - will search for 34,12 hex in that order. Note that 0012 - will search for 12, not 12,00. - - A line starting with " decodes into the string of characters - (up to ten) behind it. Normally this would only be the - first character. So instead of typing "M "Y "N "A "M "E - (space=enter here) you type "MYNAME. Note that any - terminating " will also be searched for! - - An x is treated as a wildcard. So if you search for CD x 80 - any call to a subroutine in the block 8000-80FF is a hit. - If you search for x 8000, you'll see every one-byte - instruction that has the address 8000 as operand. - N: Continues the search started by F from the current MP. - $: Displays one page of disassembly on screen. In this mode, - the following commands are possible: - $: Back to the main screen - 7: [Shift 7 also works, cursor up]: Go to the previous page. - The monitor stores the addresses of the previous eight - pages only. - Q: Go back one byte (decrease MP by one) - A: Go one byte forward (increase MP by one) - Z: Dump this screen to the printer, in ASCII format. Redirect - the RS232 output to a file, and run CONVERT on it to convert - the CR's into CR/LF's before printing (or tell your printer - to do the conversion). - Every other key displays the next page of disassembly. - K: List. The same mode as with $ is entered, but instead of a - disassembly the bytes with their ASCII characters are - displayed. Useful to look for text. - C: Clear. Fills blocks of memory with a specified value. The - monitor prompts with 'First', 'Last' and 'With'. The 'Last' - address is inclusive! - D: Dump. Prompts with 'First' and 'Last', and dumps a - disassembly of the block between these addresses to the - printer. See remark at $-Z. The 'Last' address is again - inclusive. - R: Registers. If you press Enter after R, an overview of the - registers contents is displayed. If you type one of A,B,C,D, - E,H,L,A',B',C',D',E',H',L',I,R,AF,BC,DE,HL,AF',BC',DE',HL', - IX,IY,SP or PC, you can change the value of it. Changing the - value of SP also changes the PC and AF values by the way. You - cannot change the Interrupt mode or IFF. - V: Verplaats. (Move). Prompts with 'From', 'To' and 'Length'. - Obvious. - S: Save. Enter the start of the block you wish to save first. - The monitor then prompts with 'Length'. The block is saved - without a header, as a normal data block (A, the flagbyte, is - 0FF) - L: Load. Loads a block of data from tape, at the specified - address. Normal data blocks, headers and blocks with non- - standard flag bytes can be loaded. The first byte in memory - will contain the flag byte. If the checksum isn't 0 after - loading, indicating a tape error, you'll hear a beep. - H: Header read. Loads headers and displays the contents on - screen. - - - As you're reading this part, I assume you know something of machine - code. Probably you would be interested in peeking into the software of - the SamRam, the Interface I, the Spectrum 128, the Disciple or the - Multiface 128. You'll first have to move these roms in ram to be able - to look at them with the monitor. - - The Interface I rom can be moved into ram by saving it to microdrive or - to the "b" channel, with SAVE *"m";1;"rom" CODE 0,8192 or SAVE *"b" - CODE 0,8192, and loading it back again at 32768 for instance. You can - also put this small machine code routine at 23296 and run it: F3 21 0C - 5B E5 21 00 00 E5 C3 08 00 21 00 00 11 00 80 01 00 20 ED B0 FB C3 00 - 07. You ought to be able to disassemble this piece by heart. - - The two SamRam roms are easy. The first you don't need to transfer; - the monitor looks at the extended basic rom by default. The second rom - can be moved to 32768 by typing *SAVE 0,32768,16384. (The SAVE is not - the keyword SAVE!) - - The first '128 rom, the one which is active at reset and contains most - of the new code, is moved up by typing SAVE!"rom"CODE 0,16384, then - LOAD!"rom"CODE 32768. The other rom is most conveniently moved by - saving it to a .TAP file and loading it back again in ram. To select - the SamRam type SPECTRUM first, and then switch the hardware without - resetting. - - The Disciple and Plus D roms can be transferred to RAM by simply saving - them to disk and loading them back at say 32768. - - The Multiface ROM is paged by an IN from 191, and paged out again by - INning from address 63. Don't forget to disable interrupts in between, - I'm not sure whether the M128 has a well-behaved interrupt routine. - ROM is from 0-8191, RAM on top of that. - - - - - - -4. THE SPECTRUM - - - - -4.1 The Spectrum - - - This emulator supports the Interface I, the Multiface 128, the DISCiPLE - and Plus D interfaces, and the Spectrum 128. Many Spectrum users will - have no experience with them, so some comments may be useful. On the - other hand, I don't think this is the right place to describe the - Spectrum Basic in full detail. If you want to know it all, read the - official manuals! Information on the Multiface 128 can be found in - section 2.12. - - If you want to use Spectrum Basic, you will need the keywords. You - could by the way now also use the Spectrum 128 Basic where you can type - the keywords in by full. - - If you press ALT-F1 in the emulator, the Spectrum keyboard layout will - appear. For completeness I include an alphabetical list of all - keywords and their key-combination. In the list below, K stands for - Keyword mode, E for E-mode (type Shift-Alt of Shift-Ctrl to select - E-mode), S for Symbol Shift, and SE for Symbol Shifted (Alt/Ctrl) - E-mode: select E mode and type the letter while depressing Symbol - Shift. - - - Keyw. Code | Keyw. Code | Keyw. Code | Keyw. Code - - ABS E g DRAW K w MERGE SE t SAVE K s - ACS SE w ERASE SE 7 MOVE SE 6 SCREEN$ SE k - AND S y EXP E x NEW K a SGN E f - ASN SE q FLASH SE v NEXT K n SIN E q - AT S i FN SE 2 NOT S s SQR E h - ATN SE e FOR K f OPEN # SE 4 STEP S d - ATTR SE l FORMAT SE 0 OR S u STOP S a - BEEP SE z GO SUB K h OUT SE o STR$ E y - BIN E b GO TO K g OVER SE n TAB E p - BORDER K b IF K u PAPER SE c TAN E e - BRIGHT SE b IN SE i PAUSE K m THEN S g - CAT SE 9 INK SE x PEEK E o TO S f - CHR$ E u INKEY$ E n PI E m USR E l - CIRCLE SE h INPUT K i PLOT K q VAL E j - CLEAR K x INT E r POINT SE 8 VAL$ SE j - CLOSE # SE 5 INVERSE SE m POKE K o VERIFY SE r - CLS K v LEN E k PRINT K p <= S q - CODE E i LET K l RANDOMIZE K t >= S e - CONTINUE K c LIST K k READ E a <> S w - COPY K z LINE SE 3 REM K e - COS E w LLIST E v RESTORE E s DEC SE q - DATA E d LN E z RETURN K y HEX SE w - DEF FN SE 1 LOAD K j RND E t - DIM K d LPRINT E c RUN K r - - - Character Spectrum kbrd On PC keyboard - - & S 6 ALT (or CTRL) 6 - ' S 7 ALT 7 or '/" - ( S 8 ALT 8 - ) S 9 ALT 9 - _ S 0 ALT 0 or SHFT _/- - < S r ALT r or SHFT S t ALT t or SHFT >/, - ; S o ALT o or :/; - " S p ALT p or SHFT "/' - ^ S h ALT h - - S j ALT j or _/- - + S k ALT k or SHFT +/= or GREY + - = S l ALT l or +/= - : S z ALT z or SFHT :/; - ? S c ALT c or SHFT ?// - / S v ALT v or ?// - * S b ALT b or GREY PRTSC/* - , S n ALT n or /. - - - - -4.2 The Interface I - - - If you want to use the microdrive, you'll need cartridge files. The - emulator can create an empty cartridge file for you. You have to - format it before you can use it. Type - - FORMAT "m";1;"name" - - to format the cartridge currently in Microdrive 1 giving it the name - 'name'. Next, type CAT 1 to get a catalogue of the files on it (none - of course) and the number of kilobytes free. You can save a file by - typing for instance - - SAVE *"m";1;"screen"SCREEN$ - - Instead of SCREEN$ you can use all other expressions that are permitted - also when saving to tape, like LINE nnnn or CODE x,y etcetera. To load - a file back from cartridge, you type (you guessed it) - - LOAD *"m";1;"screen"SCREEN$ - - If the file doesn't exist or is of the wrong type you'll get the - appropriate error message. To erase a file, type for instance - - ERASE "m";1;"screen" - - Note that no * is needed (or even permitted), and that only the name - should be given. There's another way to create a file on a cartridge, - and that is by using a command like OPEN #3;"m";1;"name", and printing - to that stream. You can use MOVE to move data from stream to stream, - but I'll not go into that --- it's not very much used anyway. - - Instead of to the microdrive, you can also 'save to the RS232 link'. - For instance, type SAVE *"b"SCREEN$ (note: there's no name!) to save a - screen. On the emulator you can send the output to the RS232 channel - to a printer (then SAVE *"b" is useless), to a file (can be useful) or - to the COM port (very useful if you connect a real Spectrum to the PC's - COM port!). You can load the data back by typing LOAD *"b"SCREEN$ and - making sure the RS232 channel is fed with the right input (from a COM - port or a file). See also section 2.13. - - If you want to use the RS232 channel for printing, open stream 3 for - output to that channel by typing - - OPEN #3,"b" - - or - - OPEN #3,"t" - - The first will simply copy everything you send to stream 3 (using for - instance LPRINT or LLIST) to the RS232 channel; the second converts - CR's into CR/LF's, breaks off lines at 80 characters and translates - keywords into character sequences. "t" is useful for LLISTings, but - not for anything else. - - Useful extra commands: CLS #, to clear the screen and reset the - attributes to their reset defaults, and CLEAR # to do a CLS # and close - all currently open streams (discarding all data that may still be - buffered!) - - The Interface I uses its own system variables. At the first error - message you make (or RASP, or flashing question mark) and at the first - Interface I statement you execute, it inserts them automatically. Some - programs will not run when the Interface I has inserted its system - variables. So if you load a game from tape, reset the Spectrum first - and don't make an error typing LOAD "". With a bit of exercise you - should be able to do this. - - - - -4.3 The DISCiPLE and Plus D Interfaces - Introduction - - - The DISCiPLE and Plus D were two disk interfaces for the spectrum - designed by M.G.T. (Miles Gordon Technology). The first of these - interfaces was the DISCiPLE, this interface consisted of a disk - interface, microdrive network compatible interface, parallel printer - interface, 2 joystick ports (emulating kempston, cursor, and Sinclair 1 - and 2). The unit also had an inhibit button which disabled the - interface hardware (except the joystick ports), and finally a snapshot - button which when pressed stopped the computer to allow the program to - be saved to disk or the screen to be printed. This was made by - Rockfort. - - The Plus D was the second of the interfaces, this was a cut-down - version of the DISCiPLE, this interface only had a disk interface, - parallel printer interface and a snapshot button. - - Both interfaces had a D.O.S. (Disk Operating System) which was partly - ROM (8K) and partly RAM (8K). When the spectrum was turned on, the ROM - part of the D.O.S. was in control and whenever the command RUN was - issued the ROM tries to load up the RAM part of the D.O.S. from floppy - disk. The advantage of this is that the D.O.S. can be upgraded without - having to change chips over (unless of course it was a major upgrade!). - Another advantage was that D.O.S. extensions could be incorporated or - replace other systems (see later). - - With both interfaces, they extended the BASIC commands, but unlike the - microdrives and several other types of drives available, the DISCiPLE - and Plus D took up none of the spectrum's RAM, therefore it was the - most invisible of the disk systems available, not only that, but the - DISCiPLE and Plus D used the same type of disk drives as the BBC micro, - therefore disk drives were both cheap and widely available, also the - disks themselves were also standard, ie 5.25" (800K DS/DD), then later - 3.5" (800K DS/DD). - - The ROM of the DISCiPLE is supplied with the emulator, together with - two version of the D.O.S. pre-loaded in RAM. The ROM of the Plus D - interface is not supplied, for copyright reasons. The emulator will - only emulate a Plus D interface if it can find a file PLUSDROM.BIN in - the emulator's own directory. If you have a Plus D yourself, you can - transfer the ROM in the following way. Load the operating system from - a Plus D system diskette, and save the entire ROM, together with the - operating system, to disk by entering SAVE d1"rom" CODE 0,16384. Then, - start the emulator and choose hardware mode Spectrum 48K + Disciple - (not Plus D of course), then type LOAD d1"rom" CODE 32768. Finally, - press F10, X, S for Save Data block, set start address and length to - 8000 and 4000 (hexadecimal) respectively, and save the ROM under the - name PLUSDROM.BIN. If you re-start the emulator now, it will emulate - the Plus D too. - - - - -4.4 The DISCiPLE and Plus D Interfaces - The basic commands - - - There are several levels of commands that can be used, these range from - the most straightforward everyday use, to the more advanced, programmer - type commands. - - I will first explain the most common commands, so that you can quickly - and easily access DISCiPLE and Plus D disks. Where a 1 is used in the - following commands 2 could be used instead. These commands are:- - - RUN - when no D.O.S. (system file) is loaded it will cause this to - be loaded. Otherwise it will just run the BASIC PROGRAM. Please - note that with the emulator the system file is already loaded, - therefore this command is not required, although I have - explained it for completeness. - - CAT 1 - will display a longhand catalogue of the disk drive selected. - The form of this catalogue is as follows:- - - program no., program name, sectors used, file type, - file size - - CAT * - will display a longhand catalogue of the currently selected disk - drive in the same form as described above. - - CAT 1! - displays a shorthand catalogue of the disk drive selected. - This catalogue consists of a 3 column list of the filename of - the programs. - - CAT *! - displays a shorthand catalogue of the current disk drive. - - LOAD pn - p - letter p, n - number between 1 & 80. This is the program - number of the file on the disk, the program number is the - number printed before the name in the longhand catalogue. - - LOAD d1"name" - load from drive 1 the program called name - - LOAD d*"name" - load from the current drive the program called name - - LOAD d1"name" S - load an 48K snapshot from drive 1 called name - - LOAD d1"name" K - load an 128K snapshot from drive 1 called name - - LOAD d1;a$ - load from drive 1 the program whose name is held in the - string a$ - - LOAD d*;a$ - load from the current drive the program whose name is held - in the string a$ - - FORMAT d1 - format the disk in drive 1 - - - - -4.5 The DISCiPLE and Plus D Interfaces - More advanced commands - - - In the previous section I explained enough of the commands so that you - could get to use the floppy disks with DISCiPLE/Plus D software on. Now - I am going to explain the commands that the more experienced user and - those who want to do just a little bit more than just load the - programs. - - First of all comes the simple commands of SAVE, MERGE, VERIFY and LOAD. - All of these commands are the same as rge tape versions except that you - have d1, d2 or d* after the LOAD, SAVE etc. There are only two - exceptions to this rule, the first is when you have a string for the - filename, in this case the command becomes:- - - LOAD d1;n$ ....... etc - LOAD d*;n$ ....... etc - - The second exception is actually an extension. When you save a code - block, you can actually get it to autorun when it is loaded by adding a - third parameter to the SAVE command, e.g. if you had a code block from - 40000 to 45000 and the run address was 41023 and you wanted it to be - called testcode to drive 1, you would save it as:- - - SAVE d1"testcode"CODE 40000,5001,41023 - - Now for the extensions. - - Any sector on the disk may be loaded to any area of RAM from 16384 to - 65535-512. The sector may also be loaded into the RAM of the interface, - however caution should be used at all times when doing this, as you may - destroy the operating system or cause it to behave irrationally. - - The syntax of the command is:- - - LOAD @n,tr,sec,add - - Where:- - - n = drive number, ie 1 or 2, note * may not be used! - tr = track number => 0->79=side 0, 128->207=side 1 - sec = sector number => 1->10 normally, may not be 0! If you - try and load a sector that is sector 0, - then the operating system will crash! - - You may also save to disk in the same way, so if you wanted to write to - Track 5, Side 0, Sector 3 with code from 32768 to 33279 to drive 1 you - would type:- - - SAVE @1,5,3,32768 - - To format a disk all you need to type is:- - - FORMAT d1 or FORMAT d2 - - This is not however as simple as it seems! Although a disk formatted - on the DISCiPLE/Plus D will work with the PC it does not work the other - way round, i.e. a disk formatted on the PC with this emulator will not - necessarily work on the DISCiPLE/Plus D. This is because of differences - of the floppy disk controller chips. With the PC, it puts a special - byte at the beginning of each track to tell the controller whether the - disk is Double Density or High Density, and the spectrum floppy disk - controller does not understand this byte and therefore will not read - the track! If you find this otherwise, then please write and let us - know about it. - - You can set some of the D.O.S. system variables using an extended POKE - command. The syntax is:- - - POKE @address,value - - The address is the BASE address of the system variables of the - interface concerned, the BASE address for each of the interfaces is - different, but the address you use in the POKE command is the same. - - - - -4.6 The DISCiPLE and Plus D Interfaces - The snapshot button - - - The snapshot button is a button which is used to stop the processor - from executing instructions and making it do something else. In the - case of the DISCiPLE/PLUS D the button can do 5 different tasks - initially. Later on I'll discuss how the fuctions can be altered so - that it can do other tasks. Once these tasks are carried out, the - processor is returned to it's original state and the program continues - from where it left off from. - - There are 5 functions that can be carried out with the initial system - file. - - To use the button, first you must get to a point in the program that - you want to use the button at, then press the button on the emulator - the snapshot button is F5 (NMI). Once you do this the program will - stop and the border of the computer will flash, this may also be - accompanied with a buzzing noise on the speaker. This is to tell you - that the snapshot button has been activated. The following functions - can then be carried out:- - - 1 - Print screen to printer in black/white screen size - 2 - Print screen to printer in grey scale A4 size - 3 - Snapshot screen to disk in SCREEN$ format - 4 - Snapshot program to disk in 48K SNAP format - 5 - Snapshot program to disk in 128K SNAP format - SPACE - go back to program (ie if F5 was pressed by mistake) - - The printer options will print out to EPSON compatible printers, - however the DISCiPLE code has been changed and it is now possible to - print to HPGL printers (e.g. Deskjet and Laserjet printers). - - The Snapshot screen and snapshot 48K are very self explanatory and easy - to use. - - The Snapshot 128K is slightly more complicated. Once you select this - option the disk drive will start up then after a slight pause the - screen display may/may not change. The border flashes again and you - have to press y or n depending on whether the screen display changed or - not. If the screen stayed the same then press n, but if the screen - changed type y. This is because the 128K spectrum has 2 screens, and - there is no way for the computer to determine which is being used by - itself, therefore it needs the user's help. After you press y or n the - program will be saved onto disk. - - Seeing it is possible for you to load programs into the DISCiPLE/PLUS D - RAM area it is possible to have these interfaces carry out other tasks. - The snapshot button code is located in RAM, so you can therefore load a - program into this part of the RAM and as soon as you press the snapshot - button it will execute the new program. There is one problem however, - which is that the program must be written in assembly language and must - also be compiled for running in that part of RAM, also it must take - care of what it does because the SPECTRUM ROM is not paged in, - therefore ROM calls are not easily carried out. - - There are several different commercial programs which use the snapshot - button to carry out different tasks, some of these are:- - - Snapshot compressing programs - Debugging tools - Cheat finders for games - Programs to allow snapshots back onto tape - - The list is endless, and if you are capable of writing a machine-code - program and have the relevant information, then you too could write - your own programs. - - - -4.7 The DISCiPLE and Plus D Interfaces - The system variables - - - The system variables reside in the RAM of the interface, and cannot be - read of changed by using the normal POKE statement. For access to - these locations the designer of the Disciple and +D ROM has implemented - the POKE @x,y command. It changes the value at address (#0298+x) in - the interface's RAM. Here are the system variables, with their - meaning. Default values are between brackets. - - Note that when y (the second argument) of a POKE @ command is larger - than 255, it is interpreted as a word, and it is poked at locations x - and x+1. Handy for locations 14 and 16. - - POKE @0: (7) Border change mask when reading/writing disks - POKE @1: (80+128=208) Number of tracks of drive 1. 128 means DS - POKE @2: (208) Same for drive 2 - POKE @3: (6) Step rate in ms (may not be lower than 6) - POKE @4: (1) Network (0=off, 1=master, 2..10=assistant, 11..63=slave) - POKE @5: (80) Printer line width (# of chars printed before CR is - inserted) - POKE @6: (0) Control code conversion (0=on, 1=off) - POKE @7: (12) Printer line feed when printing graphics (1/72th inches) - POKE @8: (1) Number of Line Feeds (10) inserted after each CR (13) - POKE @9: (0) Left margin: number of spaces printed after each CR - POKE @10:(0) Convert some characters into graphics (0=off, 1=on) - POKE @11:(0) Enable MGT Centronics printer interface (0=yes, - 1=route to standard "p" channel, i.e. ZX Printer) - POKE @12:(word 0) Unused - POKE @14:(word 0) Basic extension call vector - POKE @16:(word #3b0) Basic extension call vector (I think) - - The default value of variable 10 was changed to 0. Previous rom images - supplied with Z80 had @11 set to 1 (printer disabled) and @8 to 0 - (don't add line feeds), but these were not Disciple/+D defaults, so - they were changed back in version 3.05. - - - -4.8 The Spectrum 128 - - - The main new features of the Spectrum 128 are its larger memory, that - can be used as a Ram drive in Basic, and music capabilities. - - The Ram drive is accessed via the LOAD!, SAVE!, ERASE! and CAT! - commands. They work as you would expect. Examples: - - SAVE !"name"SCREEN$ - CAT! - LOAD !"name"SCREEN$ - ERASE !"name" - - The 3 channel sound chip of the Spectrum 128 can be used in Basic with - the PLAY command. Example: - - PLAY "cde","efg","gAB" - - plays three chords. You can program complex effects, melodies and - rhythms with the play command; they require many commands in the three - voice strings which I won't explain... They are explained in the - Spectrum 128's user guide. - - - diff --git a/Docs/z80.tex b/Docs/z80.tex deleted file mode 100644 index 7df3971..0000000 --- a/Docs/z80.tex +++ /dev/null @@ -1,2897 +0,0 @@ - -% -% #### The document starts #### -% -\documentstyle[12pt,twoside]{article} - -% -% #### Corrections for DIN A4 Paper #### -% #### Corrections for double side printing on HP LJ-III-SI #### -% -\addtolength{\textheight}{68pt} - -\setlength{\voffset}{-4.0mm} -\addtolength{\oddsidemargin}{6.0mm} -\addtolength{\evensidemargin}{-18.0mm} - - -% #### Zeilenabstand: 1 normal, 2 double #### - -\renewcommand{\baselinestretch}{1} - -% -% #### Thats the real beginning ! #### -% -\begin{document} - -% -% #### Titelpages #### -% -\pagestyle{empty} - -\begin{center} - \large - Documentation for the ZX Spectrum emulator\\[2.0cm] - \Huge - `Z80'\large~~version~~\huge 2.01a\\ - \large - (20/5/93)\\ - \large - \vspace{2.5cm} - by\\ - \vspace{7.5cm} - \LARGE - Gerton Lunter \\ - \large - P.O. Box 2535 \\ - NL-9704 CM Groningen \\ - The Netherlands \\ - \vspace{2.5cm} - \LaTeX~conversion by Lars K\"oller \\ -\end{center} - -\cleardoublepage - - -% -% #### Contents #### -% -\pagenumbering{roman} -\pagestyle{headings} - -\tableofcontents -\cleardoublepage - - -% -% #### The real work begins #### -% -\pagenumbering{arabic} - - -\section{INTRODUCTION, REGISTRATION,\protect \newline GENERAL INFORMATION} - - -\subsection{Some general remarks} - - - This is the documentation for `Z80', a Sinclair ZX Spectrum 48/128 - emulator. This program turns your PC into a Spectrum. To make you - read on\ldots -\begin{itemize} - \item[] - The program emulates a Spectrum 48K model 2 or 3 or Spectrum 128K, - is highly compatible with the real machines, includes the - Interface I, supports Microdrives, tape files, the RS232 channel, - '128 sound through internal speaker or Adlib compatible soundcard, - able to save and load every Spectrum program directly to and from - tape, even able to load speed-saved programs, supporting digital - and analogue PC joysticks and four common Spectrum joysticks, Z80 - processor emulation including the R register, inofficial opcodes - and flags, accurate timing of individual instructions, control - over the emulated Spectrum's speed, and all that while requiring - only a PC-XT with 512K with CGA, Hercules, EGA or VGA; offering - conversion programs to convert between various emulators' Snapshot - formats and to read from Disciple and Plus D diskettes, to create - .PCX and .GIF files of Spectrum screen dumps, an English - manual,\ldots -\end{itemize} - -\noindent - There is much to tell and explain in this documentation. First of all - the emulator itself must run, and uses your PC's resources. It is not - really a demanding program, but there are some things that need - attention. These technicalities are dealt with in section 2.1. - - Some general things about the emulator are explained in section 2.2. If - you read 2.1 and 2.2, you'll be able to do most of the things you - probably ever want to do. But to exploit all of its possibilities (and - oh, it can do so much!), you will really have to read it all. - - The Spectrum has a number of ways to communicate with the outside world, - like the obvious keyboard and the screen, but also the microdrives, the - tape interface, the beeper, the sound chip of the Spectrum 128, the - Kempston joystick, and the RS232 channel of the Interface I and Spectrum - 128. All these channels can be used to communicate with PC channels in - some way; for instance the keyboard is connected to the PC keyboard - (sounds obvious) and the tape I/O can be routed to a file, as well as to - a physical tape recorder. All these things are explained in the rest of - chapter 2. Paragraph 8 of that chapter contains a number of suggestions - how to transfer Spectrum programs to the PC. - - For our own Spectrums Johan Muizelaar and I built a piece of hardware we - called the SamRam (which has nothing to do with the SAM coupe, by the - way!). It contains a monitor program and software to make snapshots of - programs. It's still very useful and I still use it a lot, although the - physical SamRam doesn't work anymore. An explanation of its functions - is to be found in chapter 3. - - Some things peculiar to the Spectrum, not specific to this program but - useful to know are collected in chapter 4. It contains for instance a - table of Spectrum keywords and the key combination to get it; - unfortunately this information is not printed on standard PC keyboards! - - There are some interesting, rather unknown technical facts about the - Spectrum that I discovered while debugging the emulator. As much as I - could think of is contained in the final chapter. You don't need to - read this chapter to use the emulator; if you don't find it interesting - then skip it, but I think programmers will like it. - - A remark about copyrights. The source files are not public domain, and - you may not use them in other PC-based Spectrum emulators. Also, the - information in this documentation file, especially the info in the final - chapter (except for the file-format info in the final section) may not - be used for that purpose. But you're free to use the info for Spectrum - emulators for other machines, provided that whenever you do so you - should name the source. - - For Spectrum software, utilities, other emulators for PC's as well as - other computers, and other Spectrum related software, you can call the - Spectrum Emulator support BBS in Groningen: -\begin{itemize} - \item[] - Tatort BBS Groningen \\ - 050-264840 \\ - (+31-50-264840) \\ - v22, v22bis, v32, v32bis, MNP2-5, v42, v42bis (300-14400 baud) -\end{itemize} - At the time of writing the BBS is open 24 hours a day, but this is - subject to change. Please try calling between 22:00 and 9:00 local time - first. - - If you have access to Internet, you can find several Spectrum emulators - in a directory of for instance wuarchive.wustl.edu (take a look in - \ldots/systems/sinclair and \ldots/msdos/emulators) or nic.funet.fi. - And if you want to get in touch with me, my email address is - gerton@rcondw.rug.nl. - - - - -\subsection{Registering - sounds interesting!} - - First of all, this program is shareware. That means that you're - encouraged to give it away to others, but if you do be sure not to alter - the files. Also please don't add things to the archive file. Shareware - means that you may try the program some time; if you like it you should - register for it. -\noindent - The shareware version of the emulator consists of the following files:\\ - -\begin{tabular}{l@{ -- }l} - Z80.EXE & The emulator \\ - Z80.INI & Default initialisation file \\ - Z80.DOC & The documentation file \\ - Z80.TEX & \LaTeX~documentation file, by Lars K\"oller \\ - Z80.PS & PostScript documentation file, from the .TEX one \\ - Z80.PIF & Program Info File to run `Z80' under Windows 3.1 \\ - Z80.ICO & Windows icon \\ - ROMS.BIN & Various ROM images \\ - LAYOUT.SCR & Keyboard lay-out help screen \\ - GETRS.COM & Utility to receive blocks through RS232 lead \\ - SAVESPEC.Z80 & Utility to send .Z80 files from Spectrum to PC \\ - DIAGRAM.Z80 & Circuit diagram for tape interface, and calibration \\ - Z80FAQ.DOC & Frequently asked questions - and answers! \\ - NEW.DOC & The What's New file \\ -\end{tabular}\\ - -\noindent - The shareware version of the emulator program is not fully functional. - It cannot be slowed down, and it can't load programs from tape. All - other functions work the same in both versions. If you register, you - will receive the fully functional emulator together with the following - utilities:\\ - -\begin{tabular}{l@{ -- }p{10cm}} - CONVERT & a general conversion program: can list out BASIC and - tranlate it back, produce .GIF or .PCX files from - screendumps, translate Spectrum ASCII (CR) to PC ASCII - (CR/LF), and some other things. \\ - CONVZ80 & Translates various snapshot and tape formats of other - Spectrum emulators into each other. Can handle Arnt - Gulbrandsen's (JPP) .SNA format, Pedro Gimeno's - (VGASPEC and SPECTRUM) .SP format and Kevin J. Phairs' - (SPECEM) .PRG format. It can also handle tape files - of SPECEM and L. Rindt and E. Brukner's emulator ZX\@. \\ - DISCIPLE & Reads DISCiPLE and Plus D diskettes, both 3.5'' and - 5.25''. It translates the 48K and 128K snapshot files - to .Z80 snapshots, and ordinary files and screen - snapshots to .TAP tape files. \\ -\end{tabular}\\ -\newpage -\begin{tabular}{l@{ -- }p{10cm}} - Z802TAP & Converts a .Z80 snapshot, 48K or 128K, to a .TAP file - which can be loaded into the emulator and saved to tape - by the next utility: \\ - TAP2TAPE & Saves the contents of a .TAP file back to tape, to - load it into an ordinary Spectrum. \\ - Z80DUMP & Shows the contents of the header of a .Z80 file.\\ -\end{tabular} \\[.5cm] - -\noindent - You will also receive the source files of the emulator, the above - utilities and the SamRam, and you'll be kept informed about future - updates. - - The registration fee is 20 US\$, or 15 British pounds, or 35 German - Marks, or 35 Dutch guilders, or some of your local (hard) currency of - about that amount. Now there are several way to get the money to me. In - order of preference: - -\begin{itemize} - \item[1.] Simply send banknotes. - \item[2.] From Europe, send a Eurocheque of HFL 35,-- - \item[3.] Send a postal money-order (Works fine from e.g. Italy and Spain) - \item[4.] Send a bank cheque. Please add the equivalent of 20 Dutch - guilders, for that's the amount the banks charge for drawing - foreign cheques. -\end{itemize} - - If you're sending a Eurocheque, make sure you fill it in completely - (don't forget the number at the back!) and fill in `Groningen' for the - place. If you don't send Dutch currency, or don't fill it in - completely, or fill in a foreign city, the banks charge me fifteen to - twenty guilders to cash the cheque. - - For Dutch users, the fee is HFL 25,--. In Nederland gaat het betalen - het gemakkelijkst via de giro. Maak het bedrag over op giro 59.45.263 - t.n.v. G.A. Lunter, Groningen. Zorg er wel voor dat uw naam en adres - vermeld staan! (vooral als u Girotel gebruikt) - - Send the money, together with your name and address to: - -\begin{itemize} - \item[] - Gerton Lunter \\ - P.O. Box 2535 \\ - NL-9704 CM Groningen \\ - The Netherlands \\ -\end{itemize} - You'll get the files on a 3.5'' DD disk by default, but you can also get - in on 5.25 inch disks if you want. - - Registrations can also be handled by B G Services in the UK if this is - more convenient. The cost is the same (15 British pounds). Payment can - be by cheque or postal order made payable to B G Services. The address - is: - -\begin{itemize} - \item[] - B G Services \\ - 64 Roebuck Road \\ - Chessington \\ - Surrey KT9 1JX \\ -\end{itemize} - Telephone enquiries on 081 397 0763, Fax 081 391 0744. - - For registrations in the Czech Republic, I recommend to contact JIMAZ, - who will provide details on registering in the local currency: - -\begin{itemize} - \item[] - JIMAZ s.r.o.\\ - Hermanova 37\\ - 170 00 Praha 7\\ - phone: +42 2 379 498\\ - fax: +42 2 378 103\\ -\end{itemize} -\vfill - - - -\subsection{Other emulators} - - There are several other Spectrum emulators, both for the PC and other - computers. The list below is partly due to Carlo Delhez (the QL - emulators) and partly copied from Arnt Gulbrandsen's documentation of - his JPP\@. I don't think the list is complete, so if you know more - Spectrum emulators, for any computer, please let me know. - -\noindent - For the PC: -\begin{itemize} - \item[--] JPP, by Arnt Gulbrandsen (Norway). Faster than mine (but according - to an OUTLET review slower on some boards), by using a very smart - decoding technique, but requires a 80386 or '486 processor. Is less - compatible than Z80. Uses the .SNA snapshot format. Needs VGA\@. - Not many extra features. - \item[--] VGASPEC, by Alberto Olloqui (Spain). Needs VGA and 80286. Quite - slow, and crashes on quite a lot of programs. Uses the .SP snapshot - format. Allows ROM pokes. This program is an illegal pre-release - of SPECTRUM, by Pedro Gimeno. - \item[--] SPECTRUM, by Pedro Gimeno (Spain). Uses another .SP snapshot - format. Has a tape interface. Also quite slow. Allows changing - the rom. - \item[--] SP, by J. Swiatek and K. Makowski (Poland). Cannot load or save - snapshots, but can load programs using \verb|LOAD ""| via a file called - TAPE\_ZX.SPC\@. Crashes many programs; even basic behaves weird - sometimes. Has a built-in monitor, but no documentation. No - border. - \item[--] SPECEM, by Kevin J. Phair (Ireland). Also allows rom changes. - Displays the registers on screen. Can save and load directly - from disk using LOAD/SAVE~"filename" in BASIC\@. Loads .PRG - snapshots, but cannot save them. Emulates a Multiface~I. - \item[--] ZX, by L. Rindt and E. Brukner (Czech Republic). Haven't tested - its compatibility thoroughly, but one of the games supplied didn't - respond well to the keyboard, while it did work on Z80 after - conversion. Good tape file support including headerless files, - almost identical to the multiple .TAP file mode of Z80. Somewhat - slower than Z80. Includes program to load from tape and convert - to tape file. No documentation at all. -\end{itemize} -\newpage -\noindent - For the Sinclair QL: -\begin{itemize} - \item[--] SPECTATOR by Carlo Delhez, The Netherlands; shareware; supports - tape-files, Microdrives, RS232, Z80 snapshots, MBF snapshots and - Disciple (SNP) snapshots; utilities to convert Disciple, Beta and - Opus disks enclosed. - \item[--] ZM-1/2/3/4 by Ergon Development, Italy; ZM-1 is shareware, ZM-2/3/4 - are commercial. They all support tape-files and Z80 snapshots, some - support Microdrives and RS232; contain a utility to transfer programs - from tape via a Spectrum to the QL. - \item[--] ZX by Andew Lavrov, CIS; shareware; supports tape-files, MBF - snapshots en Z80 snapshots; utility to read from Spectrum tapes - (and write them). - -\end{itemize} - Spectator, ZM-1 and ZX are all about as fast (approximately 30 to 40% - on a 16 MHz MC68000 machine). ZM-2/3 are faster, but this at the cost - of compatibility. ZM-4 is not an emulator, but a real-time Z80-compiler: - very fast and seems to be compatible as well.\\ - - For the Amiga: -\begin{itemize} - \item[--] Spectrum, by Peter McGavin. Very good, JPP is based to a large - extent on it. Needs about a 25MHz machine to run at full speed. - Has tape support. - \item[--] KGB\@. I haven't seen it. A bit slower than Peter's, and the - version Peter saw wouldn't work on the Amiga 3000. - \item[--] An Italian emulator which I don't know the name of. Excellent - compatibility, rather fast. May be shareware. - \item[--] Several unreleased emulators. Peter knows more about them. -\end{itemize} -\noindent - For the Atari ST/TT: -\begin{itemize} - \item[--] One, called Spectrum. Don't know anything about it, but the doc - file is written in quite the worst English I've seen. [This is - Arnt speaking --- I've seen worse! GAL] Available by anonymous - ftp from terminator.cc.umich.edu. - \item[--] There's another one in the make, to be released very soon as one of - the programmers told me, written by Markus Oberhumer and other(s). -\end{itemize} -\newpage -\noindent - For the Acorn Archimedes: -\begin{itemize} - \item[--] A company called Arxe wrote one, intended to be commercial but - never released because Amstrad wouldn't permit Arxe to enclose the - ROM. - \item[--] Someone called D. Lawrence wrote another, or maybe the same. - This one is floating around but nobody has any documentation. I - don't know what its status is. Runs at about 70\% of Spectrum speed on - an ARM2, not quite perfect graphics emulation. -\end{itemize} -\noindent - For the Commodore 64: -\begin{itemize} - \item[--] The Whitby Software Spectrum simulator is a rewrite of the - Spectrum Basic. It will not run machine-code programs. I don't - know whether it's PD, shareware, or commercial. Quite good. - (Responds nicely to a POKE 23659,0) -\end{itemize} - All emulators for PC, and some for the Atari, Amiga and QL are available - on the support BBS. - - There are also emulators available for the ZX81. Carlo Delhez, who also - wrote a Spectrum emulator for the QL, wrote the ZX81 emulators XTricator - (for the QL) and XTender (for PC's). These programs can also be - downloaded from the support BBS. - -\subsection{Thanks} - - From the very first beginning in november 1988, when I wrote the first - lines of code, Johan Muizelaar has been a very demanding and critical - user, being only satisfied when it was perfect. And quite a few things - I would never have started working on if he hadn't insisted that I - would\ldots - - Secondly, I have to thank Brian Gaff, who is now handling the UK - registrations for nearly a year, and besides doing lots of PR for my - program there helped me with many things, especially with the DISCiPLE - conversion program. - - Finally, I'd like to thank - -\begin{itemize} - \item[$\bullet$] Lars K\"oller for transforming the plain ASCII doc to \LaTeX, - \item[$\bullet$] Thomas Franke for translating the entire Dutch v1.45 manual into - German, - \item[$\bullet$] Carlo Delhez for information on the '128 and several other things, - \item[$\bullet$] Andre Mostert for some more '128 info and info on EMS memory, - \item[$\bullet$] Walter Prins for many '128 programs and a nice African chat, - \item[$\bullet$] Marco Holmer for making the program such a big hit at the HCC dagen, - \item[$\bullet$] Henk de Groot, for finding and helping me work around a bug in A86 - version 3.22, - \item[$\bullet$] Arnt Gulbrandsen for pointing out to me that it is not necessary to - clear a register when it contains 0, - \item[$\bullet$] Ruud Zandbergen for his digital joystick interface, - \item[$\bullet$] Ettore de Simone for finding a noisy bug, and for some very wise - remarks about theological issues, - \item[$\bullet$] Jan Garnier for providing the chips to reanimate my real Spectrum, - \item[$\bullet$] Rudy Biesma and Tonnie Stap for providing info on the DISCiPLE disk - formats, - \item[$\bullet$] Hugh McLenaghan for his very valuable help on the DISCiPLE program, - \item[$\bullet$] Burkhard Taige for various bug reports on it, - \item[$\bullet$] Ian Cull for enhancing the DISCiPLE program and fixing two early - bugs, - \item[$\bullet$] Bert Lenarts for information on the AZERTY keyboard, and - \item[$\bullet$] Andre Brus for writing the most enthousiastic letter I've ever - read! -\end{itemize} - - -\newpage - -\section{THE EMULATOR} - - -\subsection{Starting the emulator} - - The emulator will work on any PC with at least 512K memory, with a VGA, - EGA, Hercules, CGA or Plantronics video adapter. If available, it will - also use EMS memory, an Adlib compatible soundcard, and an analogue or - digital joystick. - - The emulator will first read in the switches that are given in the - Z80.INI file. You can enter switches there in the same way you would on - the command line. Lines starting with a \% sign will be ignored. - - After any switches, you may specify a snapshot file on the command line. - This file will then be loaded and executed directly. The extension .Z80 - is not necessary. The emulator will also read .SNA files (the snapshot - format of, amongst others, Arnt Gulbrandsen's JPP); you don't have to - convert them to .Z80 files (but you may want to to save disk space). - - The emulator tries to figure out what hardware is available, and uses - things as it finds it. Most of the time this will work without you - having to tell it anything, but if you have to you can override the - defaults by putting switches on the command line. Switches that you use - often can be put in the Z80.INI file. If you give a switch a second - time, for instance if it is also in the Z80.INI file, it will disable it - again. - - If you are using Hercules, try starting the emulator with -xh on the - command line. The emulator will use a non-standard Hercules mode to - display a full-screen Spectrum picture. You may need to calibrate your - monitor to make the image steady. - - If you're using Plantronics, try -p and -q to see which gives the best - result. - - Some black-and-white VGA monitors only display one of the three RGB - colours (green most of the times), resulting in several Spectrum colours - becoming indistinguishable. Use -xb to use grey tones instead of - colours. - - If you're using a Trident VGA with version 3 BIOS, you may see the - picture compressed at the top of the screen, while the bottom half - contains vertical white lines. This is due to a bug in the Trident VGA - Bios. Start the emulator with the switch -xv to get a full picture. - - If you haven't got EMS memory, the page swapping of the Spectrum 128 - cannot be emulated exactly. Most programs will work - although quite - slowly because page swapping will take much time without EMS - but some - may crash. On 386 and 486 machines you can emulate EMS by software, - using EMM386 for instance. Of all the EMS emulators I've tried (that's - three or four) QEMM was by far the fastest, but the EMM386 supplied with - the new DOS 6 seems to be about as fast. A slow EMS emulator can - degrade the performance of the '128 emulation significantly! Some - computers have hardware EMS capabilities, some '286 boards for instance. - Refer to your own documentation for details. - - And don't use hard disk based EMS emulators: the Spectrum emulator will - drive your hard disk nuts! - - There are a few Spectrum programs that have an odd stack pointer, and - run over the ram/rom boundary, for instance Deep Strike. This crashed - version 1.45 of the emulator. The bug has been removed in version 2: if - the emulator tries to read a word at FFFF, the processor generates an - INT 0D interrupt and the emulator will handle it correctly. However, - this won't work when an EMS emulator is installed that puts the 386 or - 486 processor in virtual 8086 mode. You can test all this by typing -\begin{itemize} - \item[] \verb|CLEAR 65535:POKE 65535,0: RETURN| -\end{itemize} - in Basic, and the emulator will lock up - if it runs in virtual mode. There is no simple solution to this - problem, but luckily it doesn't happen often. If it does, the easiest - way to to solve it is to change the Spectrum program so that it uses an - even SP --- this is always possible, but not always easy! - - A very few programs (the only examples known to me are Fireman and - Thing) are quite sensitive to the relative actual execution speed of - emulated Z80 instructions, and crash if it isn't exactly right. If you - slow down the emulator, these program will run fine, because then - individual instructions are more carefully timed. - - The Spectrum 128 has a built-in sound chip. If you have an Adlib - compatible soundcard installed, the Spectrum 128 sound will be played - through the Adlib card. If you haven't, the loudest of the three sound - channels will be played through the internal PC speaker. Sometimes the - effect is quite nice, sometimes it is horrible, but it's all I can do on - a standard PC\@. If you don't want to have the Spectrum 128 sound played - through the internal speaker, use the switch -xi. If you don't want the - Adlib card to be used (for instance to hear the sound through the - internal speaker) use -xa. - - If you're using the Pro-Audio Spectrum 16 sound card, do not install the - resident FM.EXE program; it causes problems with the emulator. Do make - sure that MVSOUND.SYS is installed in your CONFIG.SYS file, to make the - Pro-Audio Spectrum 16 Adlib compatible. - - The noise channels of the Spectrum 128 sound chip can work on different - frequencies, whereas the FM chips of the Adlib card cannot. However, if - your Soundblaster is equipped with CMS chips, the noise frequency can be - programmed. Specify -xc to use the CMS chips. (These chips are not - available on Soundblaster Pro cards, and neither on most Soundblaster - clones). - - If you're living in Belgium or France, you are probably using an AZERTY - keyboard. Specifying -xz on the command line will make all letter keys - and many punctuation keys work in the right way. - - If the emulator erroneously detects an analogue or digital joystick, use - the switch -kk. - - It may be annoying to have to press Num-Lock every time you use the - Spectrum 128 (because otherwise you'll have to use Shift with the cursor - keys to move the menu bar). To make the emulator press shift by default - every time you use the PC cursor keys in '128 mode, use the switch -xs. - If you press Num-Lock now (in '128 mode), the shift-key won't be - pressed. The 48K modes are not affected by this switch. - - The emulator can now also be run under Windows 3.1! However, you cannot - use the tape interface, Real mode doesn't work anymore, and the keyboard - is not emulated as well as usual, because I have to scan it using BIOS - calls. Be sure not to set the keyboard repeat rate too low; an initial - delay of 250 ms followed by 10 keys a second will do, but don't make it - slower. Some key combinations may not work, such as ALT 4 for \$. So if - you want to use the emulator seriously then you shouldn't run it under - Windows, but it's nice to see three Spectrums run simultaneously\ldots If - you let the emulator run full-screen you may use EGA or VGA, if you want - to run it windowed you'll probably have to use CGA, because the virtual - video display driver of Windows cannot handle the VGA mode I use - (although it's only a standard text mode!). You'll probably want other - default settings of some parameters (such as the video mode) if you run - the emulator under Windows; the emulator will always use the .INI file - in the directory of the Z80.EXE file so the other switches must be put - on the command line, in a .PIF file. An example .PIF file (which runs - the emulator in windowed CGA mode) is supplied. - - Since the execution speed of a program running under Windows heavily - depends on other processes, the emulator doesn't try to measure how fast - it is running under Windows. It says it runs at 100\%, and you can slow - it down in the usual way, but the percentage is now relative to the - maximum speed, and has nothing to do with the actual execution speed. - - The emulator will automatically detect whether Windows is running, and - act appropriately. To run the emulator in Windows compatibility mode in - a normal DOS environment, use -xw. - - When running the emulator under Desqview, use -e for EGA mode display. - - To run the emulator with a different rom than the standard one, you can - specify a rom image file on the command line. Use the switch -xr file, - where `file' is the name of the image file. This file should be exactly - 16384 bytes long. It will of course not be used in Spectrum 128 or - SamRam mode. - - The emulator `ZX' by Rindt and Bruckner comes with several roms, stored - in their tape format. You can convert these files to .TAP files, and - then load them in the normal way, but to run the emulator with these - roms you need the bare 16K binary image file. To extract it from the - rom files, type the following at the DOS prompt:\\ - -\begin{tabular}{ll} - \verb|C:\debug rom.000| & (or other rom file (of 16406 bytes)) \\ - \verb|-m 115 L 4000,100| & (move the rom down, overwrite header) \\ - \verb|-rcx| & (new length of exactly 16K bytes) \\ - \verb|CX 4016| & \\ - \verb|4000| & \\ - \verb|-n rom000.bin| & (or some other name) \\ - \verb|-w| & (write it) \\ - \verb|Writing 04000 bytes| & \\ - \verb|-q| & (and quit) \\ -\end{tabular}\\ - - Then start the emulator with \verb|-xr rom000.bin| on the command line to use - the rom. It will only affect the normal 48K modes; the SamRam and 128K - modes will always use their own roms. - - These are the most important switches that you have to specify when you - start the emulator. Most of the other switches are used to select - default values for various things which can also be changed when the - emulator is started. Some useful things to select are default - directories for .Z80, .TAP and .MDR files; these will be explained - below. - - - -\subsection{Using the emulator} - - When the emulator starts, you'll see the usual Spectrum copyright - message appear on screen. Pressing F1 will pop up a small help screen - that explains the function of the function keys and various other - special keys. - - By pressing F10, you enter the main menu of the emulator. Most of the - menu options can be chosen directly by pressing another function key. - The only exception is X, Extra functions, for which no function keys - were available anymore. If you're somewhere deep in the menu structure - of the main menu, pressing ESC will get you one level higher most of the - time. Pressing F10 will get you back to the main menu. - - The `Select Hardware' menu option sits under function key F9. There are - five configurations you can choose: a normal Spectrum 48K with or - without Interface I, a Spectrum 128K with or without Interface I, and a - Spectrum with Interface I and SamRam. Switching to another mode will by - default reset the Spectrum. If you don't want this to happen, press - CTRL-ENTER instead of ENTER when you've made your choice. It cannot be - guaranteed however that the Spectrum won't crash or behave weirdly, for - obvious reasons. Going from a Spectrum 128 to a normal Spectrum will - almost always crash it, except if you enter the SPECTRUM command before - switching. - - To use SamRam's monitor on a 128 program, switch the hardware from the - main menu, and generate an NMI (Extra functions - N) before returning to - the emulator. This will often work, but you can't return to the program - without crashing it. - - On a real Spectrum 128, the menu bar of the startup screen is moved - using the cursor keys on the '128 keyboard. These keys simultaneously - press a normal cursor key (5,6,7 or 8) and shift. So you can shift the - menu bar with shift-6 and shift-7. As is already said above, it is - possible to use the PC cursor keys for this; you have to select Cursor - joystick emulation (which is selected by default) and press Num-Lock - once to have the PC-cursor keys press the Spectrum Shift key too. You - could also specify -xs on the command line (or put it in the Z80.INI - file) to make the PC cursor keys by default press shift for you in '128 - mode. - - The Save and Load Program options (F2 and F3) will save the whole state - of the Spectrum and some of the emulators' settings to a .Z80 snapshot - file. It will pack the data somewhat, so that the length of the file - varies. The amount of memory saved depends on the current hardware - mode; 48K for normal Spectrum, 80K for SamRam, and 128K for Spectrum - 128. The settings that are saved are those that are program dependent, - for instance which joystick emulation is used, and more technical - settings like those of the R register, LDIR and Issue 2 emulation, - double interrupt frequency and video synchronisation. These are - explained below. - - Loading a .Z80 file will cause several settings to be changed. Resetting - the Spectrum will not reset these settings to their default values! - Especially the joystick emulation setting change can be confusing, so - keep track of that. - - The Change Settings menu pops up if you press F4. You can do many - things here, and I won't explain them all here. The I and O options can - be used to redirect the RS232 output; see paragraph 2.6 for information - on this. -\begin{itemize} - \item[R:] R - register emulation, and - \item[L:] LDIR emulation -\end{itemize} - are seldom needed. For remarks on these options see chapter 5, and - paragraph 2.8. -\begin{itemize} - \item[2:] Issue 2 emulation will turn the emulated Spectrum in an Issue 2 - Spectrum. (This option also works, but is ridiculous, in Spectrum 128 - mode). Some very old programs (Spinads) will not respond to the - keyboard properly on Issue 3 Spectrums, and for these programs this - option was added. Seldom needed. - \item[F:] fast flash makes flashing go twice as fast. Not very useful. - \item[S:] sound enables you to turn off all sound, useful for late-night - playing. - \item[D:] double interrupt frequency is useful for slow machines, as some - programs will run faster when this option is on. If you're typing in a - BASIC program on a slow machine, always turn this on, since the - keyboard, which is polled by an interrupt routine, will respond much - better. On the other hand, some programs will crash with this option - active. - \item[V:] video synchronisation is used to remove the flickering of moving - characters in some programs. You can choose between Normal, High and - Low. Normal works well for almost all programs; Ghosts and Goblins and - Zynaps look much better when this is turned to High. If you see - characters not moving smoothly or flicker, or a background not moving as - a whole, experiment a little bit with this setting, and re-save the - snapshot when you've found the best setting. (For a slightly more - detailed discussion of this option see section 5.1) - \item[J:] joystick emulation specifies which Spectrum joystick the PC cursor - keys (and analogue or digital joystick, if it is available) control. You - can choose from Cursor (default), Kempston, Interface 1 and 2. As I - already said above, if Cursor joystick is chosen, the Num-Lock key - controls whether Shift is pressed too if the PC cursor keys are pressed. - (Since the shift and number keys are pressed exactly simultaneously, it - is possible that the Spectrum has already read the Shift key, but not - yet the others, when you press both keys down. Sometimes you will - therefore get the number 5,6,7 or 8 instead of a cursor movement.) - \item[C:] Change speed lets you control the speed of the emulator. As - a side effect, slowing down the emulator makes the timing of the various - opcodes correspond more exactly to the actual timing on a real - processor. -\end{itemize} - That concludes the discussion of the F4-'change settings' menu. Let's - continue with the other function keys. - -\noindent - F5 generates an NMI\@. Only useful if in SamRam mode; otherwise it may - reset the Spectrum or (sometimes) crash a program. ALT-F5 or CTRL-F5 - resets the Spectrum. - -\noindent - F6 turns on Real Mode. Try this when the emulator is playing a tune and - sounds a little harsh. This mode is needed when you want to load - speed-saved games from tape; see below for more information. - -\noindent - F7 and F8 activate the tape- and microdrive-menus. Again, see below for - more information. - -\noindent - Resetting the Spectrum, or generating an NMI can be done from the main - menu too, in the X - Extra Functions menu. This is useful if you want - to activate the NMI software of the SamRam for instance just after - loading a snapshot file, or just after you changed the hardware mode. - From this menu you can also shell to DOS, and save or load a screen - snapshot: a 6912 byte file with extension .SCR that contains a dump of - the screen information. This enables you to very easily transfer - screens from one Spectrum program to another. The .SCR files can be - converted to .GIF or .PCX files by the CONVERT program, available to - registered users. - - When you're typing BASIC-programs in 48K mode, you'll probably have to - look up some Spectrum keywords. Further down in this documentation - there is an alphabetical list of all keywords and their key-combination. - For `on-line' help, press ALT-F1 to see the Spectrum keyboard layout. - - - -\subsection{Emulation of the Keyboard, Screen and Beeper} - - The keyboard. Letter keys are mapped to the Spectrum's letter keys. The - ALT and CTRL keys can both be used for Symbol Shift. Then, there are a - lot of keys on the PC keyboard which don't exist on the Spectrum - keyboard. Many of them are used, to make things easier: -\begin{itemize} - \item The function keys have several special functions. See the previous - paragraph. - \item - CTRL-Break and CTRL-ALT-DEL quit the emulator. - \item - The punctuation keys -- = ; ' , . / and their shifts: \_ + : " $<$ $>$ ? - have the effect of pressing Symbol Shift and the corresponding letter key, - so you can use these in the straightforward way. - \item - The ESC key presses Shift-1, EDIT, used as a sort of ESC key in many - Spectrum programs. The Backspace key presses Shift-0, the Delete of the - Spectrum. CapsLock presses Shift-2, Spectrum's capslock key. - \item - The PC-cursor keys and the numeric keypad keys 8,4,6 and 2 control the - Cursor, Interface 2 or Kempston joystick. The TAB key, and 0,5 and - ./DEL on the numeric keypad control the fire button. If the Cursor - joystick is selected, you can select whether Shift should also be - pressed with the NumLock key (but see the discussion above of the -xs - switch). -\end{itemize} - If you're running the emulator on a slow computer, try selecting double - interrupt frequency. Most programs poll the keyboard by interrupt, in - any case the ROM does, and doubling the frequency with which this - happens will make the emulated Spectrum react much more quickly on your - keystrokes. - - If you've got an AZERTY keyboard, the standard mappings of the keys - won't work at all properly. Include the switch -xz in your Z80.INI file - in this case; many punctuation keys will now also work properly. There - is no support for other non-US keyboard layouts; sorry! - - - Now about the screen emulation. Fifty times an (emulated) second, the - screen is checked for changes. If anything has changed, the change is - displayed on the PC screen. It turned out that this was the fastest - method of updating the screen. - - I tried to update the screen at about the same time the real Spectrum - shows it on the TV screen, relative to the 50 Hz interrupt. There is a - problem; the Spectrum takes about 1/100th of a second to generate the - whole picture, while I stop the emulator at some point in the 1/50th- - of-a-second cycle and display the whole screen at once. Usually this - makes little difference, but with some programs it does: characters may - flicker heavily or disappear entirely (see for instance BC's Quest for - Tires). By selecting the `video synchronisation mode', you have some - control over the exact point of the cycle at which the screen is - updated. - - In the Hercules, CGA and Plantronics modes, not all colours can be - displayed. In the EGA mode, all colours can be displayed, but some - colours have the same intensity in bright 1 as in bright 0. In VGA - mode, all colours closely resemble the original Spectrum colours, and - furthermore in this mode the screen updating is the fastest of all - modes. - - The border updated every 1/50th of a second, so you cannot see the - familiar stripes when saving. However, in real mode the emulator uses - the overscan of EGA to display the border, and you can see some stripes - there, and in VGA mode the border can be shown full-size. The only - drawback of the border emulation in real mode is that there appears some - `snow' on the screen at each OUT - I don't know a way around this. - - - Finally, the sound emulation. The Spectrum beeper is emulated by the - PC's internal beeper. Because every 1/50th of a second the screen has - to be updated, and this takes a little time even if there are no - changes, the sound is a bit harsh. If you select real mode, the - emulator won't update the screen anymore and the sound will sound - better. - - The sound of the Spectrum 128's sound chip is played through the Adlib - card; if you haven't got such a card some notes are played through the - internal speaker. That sound will be turned off, however, as soon as - the program makes a sound through the normal speaker of the Spectrum. - Some Spectrum 128 programs use the sound chip and the beeper at the same - time, and this won't work properly without an Adlib card. - - - -\subsection{Using the tape} - - This emulator can load programs that are saved to tape in the usual way, - but also speed-saved programs can be loaded. Furthermore, you can also - make a disk file act as an `emulated tape', so that the normal SAVE and - LOAD commands can be used to transfer data to and from disk easily. - - Let's first discuss the saving and loading of programs using a tape - recorder---that'll be the first thing you want to do, to transfer your - programs to the PC\@. First of all, you need an interface to connect the - tape recorder to the PC\@. The parallel printer interface is used for - this. All you need is a very simple and cheap piece of electronics to - get the input and output signals at the appropriate and safe levels; the - circuit diagram is in the program DIAGRAM.Z80. The interface has to be - calibrated; a program to help doing this is contained in the snapshot - file. Adjust the variable resistor so that when the tape recorder is - played at normal volume, the bar points just below 50\%. When the tape - recorder is turned off, the bar should go to 0\%. - - You have to tell the emulator which LPT port you use for tape I/O. This - can be selected in the tape menu, but it can also be specified on the - command line or in the Z80.INI file with the -b switch; for instance - -b2 selects LPT2. Default is LPT1. - - There are two ways to load programs: in `real' or normal mode. In real - mode, the emulator doesn't update the screen or scan the keyboard - anymore, so that the emulated Spectrum program can run smoothly. The - emulator has to run at about 100\%, but then you're able to load - everything a normal Spectrum would load, including speed-saved programs. - The only thing you see on screen are the loading bars in the border (on - EGA or VGA screens). Real mode is selected by pressing F6. Saving - programs in real mode is a bit useless but it works; enter the SAVE - command, press a key to start saving and quickly press F6 when the - saving starts. It will continue in real mode. - - If your computer is just fast enough, don't slow the emulator down too - much. Because the IN instruction is relatively slow, the emulator has - to run at about 110\% for the best results. If your computer is really - fast, you can best slow it down to exactly 100\%. If your computer is - just a bit too slow, you can try to make your tape recorder run slower - too (usually you can do this by adjusting a little screw at the back of - the motor), I successfully loaded several speed-saved programs at 90\%. - - In normal mode, the standard ROM loading and saving routines are - `trapped' (at addresses 04D8 and 056A) when they're about to start - saving or loading. A routine in the emulator itself then takes over, - and loads or saves a block to tape or a disk file. By default, this - routine uses the tape instead of a file, and I'll discuss that mode of - operation first. - - Using these SAVE and LOAD routines has a great advantage as well as a - disadvantage compared to using the Spectrum's own routines in real mode. - The advantage is that the internal routines work on every machine, no - matter how slow or fast, without having to make the emulator run at - 100\%. The disadvantage at using them is that they obviously won't - understand speed-saved files. For normal use, these internal routines - work much easier, and real mode loading is only necessary for - speed-saved and very well protected programs. - - So far for the general information about tape loading. - - The emulator uses files with the extension .TAP to hold a piece of - `tape', with several blocks on it. Each block is usually either a - header or a data block; a normal file thus consists of two blocks. There - are two modes of operation when loading and saving to disk files, single - and multiple .TAP file mode. - - In single .TAP file mode, each block saved is appended to the end of the - .TAP file, like would happen if you were actually saving to tape. In the - same way, when loading in single file mode, each time the ROM wants to - load a block, it is presented the next block in the .TAP file. It is - handled as it would if the block was loaded from tape, that is, if the - ROM needs a header and is presented a data block, it will skip it. The - header will however be considered to be read. So, entering - \verb|LOAD "rubbish"| - will show all headers in the .TAP file, just as an ordinary - Spectrum would show all headers on the tape if you left the tape - running. - - If the last block is loaded, the file pointer is moved to the start - again. So a .TAP file can be considered to be an infinite tape. Single - .TAP file mode is useful to save whole programs to disk, or for - multi-load games that need to load in levels as you play. - - A sort of `random access' file management would also be useful, for - instance when you're developing a program and need to save several - pieces of data to disk and later load back a specific one. This can be - done in single .TAP file mode (by positioning the file pointer using the - Browse function), but there's a different mode of operation that makes - things easier: multiple .TAP file mode. In fact, by default the - emulator is in this mode. - - When the emulator is in multiple .TAP file mode, it will read all blocks - from all .TAP files in a specified directory, one after the other. When - it has finished reading the last one, it will start all over again. - - When saving, the emulator will put the two blocks of a normal file, the - header and the data block, in one .TAP file with a unique name made up - of the printable letters of the file name and a two-digit number. The - name of the .TAP file is irrelevant to the emulator, but to have it - resemble the name of the actual Spectrum file you saved is simply - convenient. If the Spectrum program saves a data block to tape without - first saving a header, the .TAP file will contain only this data block, - and the DOS file name will be HDRLES, with a two-ditit number appended - to make it unique. The format of the .TAP files saved in multiple .TAP - file mode is exactly the same as the format used in single .TAP file - mode. - - You can easily string together .TAP files; for instance a number of .TAP - files created in multiple .TAP file mode can be put into one big .TAP - file simply by copying them together, e.g. -\begin{itemize} - \item[] \verb|COPY /B FILE1.TAP + FILE2.TAP ALL.TAP| -\end{itemize} - (Note: in some versions of DR~DOS the /B switch, necessary because - otherwise copying stops after a CTRL-Z character, doesn't work properly; - load your old COMMAND.COM to copy the files). - - Now you know what you can do, but how to get the emulator to do it? - That's what the final section is about: the tape menu.\\[.3cm] - - Press F7 to enter the tape menu. Pressing S will select or de-select - single file mode. By default, multiple .TAP file mode is selected. In - this case, there are three other possible choices in this menu. First - of all, D selects a tape-file directory where the .TAP files will be - saved into and loaded from. A default directory can be selected by - putting the -xs switch on the command line or in the Z80.INI file; for - example -xs c:$\backslash$spectrum$\backslash$taps selects that directory. - - The I and O options are used to select the source and destination of the - saving and loading: the LPT port for a physical tape recorder, or `disk' - for disk files. By default LPT1 is selected; another LPT port can be - selected with for instance -b2 or by pressing I and O. Input and output - are directed to disk by default if a default tape file directory is - given by means of a switch on the command line or .INI file. - - If Single .TAP file mode is selected, different and more menu options - appear. With G and P, the input and output tape files can be selected. - They may be the same. If a specified output file already exists, you - may choose to append to or overwrite this old file. Saving is always at - the end of the file; loading always starts at the beginning of the .TAP - file. - - With the B option - Browse - the position of the file pointer into the - input .TAP file can be changed. If you, for instance, type \verb|LOAD""| - instead of \verb|LOAD "" CODE|, the first header is read, and you would - have to - read all other headers before trying to load the file again. With the - browse option you can conveniently change the file pointer. Of every - header (that is, every block with flag byte 0 and length exactly 17) the - name and type, and of every data block the length is shown. - - The option B can also be used to delete specific blocks from a .TAP - file. Make sure you do not only delete a data block or a header, or the - ROM may get confused! (Double data blocks will be skipped, but double - headers can generate Tape Loading errors). - - As in multiple .TAP file mode, I and O are used to specify the source - and destination for saving and loading. If you enter a .TAP file name - with G or P, this will automatically be set correctly. You can then - always reset the input or output back to LPTn again, of course. - - Finally, in Single .TAP file mode you can use `tape mirroring': loading - programs from tape (in normal mode, i.e.\ not using Real mode) and at - the same time saving a copy of each block loaded into a .TAP file. This - .TAP file can later be used to load the program again, might anything go - wrong. There are two ways of mirroring: normal mirroring and exact - mirroring. The last one must be used only in exceptional cases; it will - always make a copy of a block, even if it had a tape error (the - corresponding block in the .TAP file will also have a tape error). This - causes ticks in leader tones to make 0-byte blocks, so the .TAP file may - get messy. Do not use exact mirroring if you don't really have to; I - think normal mirroring will always work in practice. - - If you try to leave the tape menu when for instance tape mirroring is - selected, and no output filename is given, the emulator will warn you - and will insist that the error be corrected. Yes, it's stubborn! - - - -\subsection{Using the microdrive} - - Compared to the tape, this is really simple. Cartridges are emulated by - files of 137923 bytes. These files have the extension .MDR, and can - contain up to 126K of data. The emulator emulates 8 microdrives, the - maximum amount the Interface I software can handle, and each of these - cartridge files can be inserted in any of the 8 microdrives. (Do not - insert one file into more than one microdrive; this will cause problems - with the buffering done by the emulator as well as the Interface I, and - might result in data loss). - - Press F8 to enter the microdrive menu. Press 1 to 8 to select a - microdrive, and I to insert a microdrive cartridge. You can select an - existing one, or type a new name. If the cartridge file isn't found, - the emulator asks whether it should create it. When created, you'll - have to format it first; if you don't, you'll get a `microdrive not - present' error when you try to read it, just as happens with real - unformatted cartridges. To format a cartridge, type -\begin{itemize} - \item[] \verb|FORMAT "m";1;"name"| -\end{itemize} - After this the cartridge should have 126K of free space. - - The cartridge can be write protected; see the menu option in the F8 - menu. This is a characteristic of the cartridge, and the write protect - tab information is therefore stored in the cartridge file. - - As on the real Spectrum, you'll have to be careful with OUT's if a - cartridge is inserted. Try \verb|OUT 239,0| - (on a real Spectrum, this turns on - the microdrive motor) and wait a few seconds; most of your data will be - lost! You can stop the microdrive motor by typing STOP (or, more - generally, generate an error). - - The microdrives are emulated at IN/OUT level. This means that every - utility or program that uses microdrives ought to work on the emulator. - Most utilities use hook codes, and these will certainly work. - - The GAP line is emulated; this signal is activated if the interface I - senses a piece of tape with no data on it. If the checksum of the first - header block of a microdrive header or data block is not correct, that - block is considered to be a GAP\@. This will only happen if some utility - writes a bad block to microdrive deliberately, if the file is newly - created and unformatted, or when you type \verb|OUT 239,0|. - - - -\subsection{Using the RS232 channel} - - This was the only Spectrum i/o channel that could be used in the early - versions of the emulator. Using .TAP files instead of the RS232 channel - is often easier, but sometimes using the RS232 channel can be very - useful too, for instance if you've got a null-modem lead that connects a - Spectrum with interface I to the PC you can use it to transfer data and - programs easily. Furthermore, the RS232 channel is the easiest way to - let the emulator communicate with a PC printer. - - The Interface I RS232 port is called the "B" or "T" channel. The first - is the binary channel, the "T" channel won't let all control codes - through and will expand any keyword; useful for LISTing a program but - otherwise annoying. - - The Spectrum 128 has its own RS232 port; it is called the "P" channel. - Output to either the Interface I's or Spectrum 128's own RS232 port will - all be processed as `RS232 output', and input will go to both (that is, - to the one you happen to read from). - - The output to the RS232 channel can be routed to an LPT port, to a COM - port or to a file on disk. Input can come from either a file or a COM - port. - - If you want to use the RS232 channel for printing using \verb|LPRINT| - and \verb|LLIST| (shorthand for \verb|PRINT #3| and \verb|LIST #3|), - be sure to open that channel for - output to RS232; by default it sends its output to the ZX Printer, which - is not supported. You can open the channel by typing - \verb|OPEN #3,"B"| (or "T" for listings, or "P" on a Spectrum 128). - - Input and output are buffered. This is important to remember when - you're transferring files using the \verb|SAVE| and \verb|LOAD *"b"| - commands of the - Interface I. If the header is missed, for instance if you try to load - the wrong file type, re-sending the file will not directly work because - there will still be bytes in the buffer. You have to clear the input - buffer before re-sending the file. When inputting from a disk file, the - file pointer can be reset to point to the start of the file again to - re-read the header. - - When inputting or outputting from or to a disk file, the read or write - position is displayed as a byte-count. An $<$EOF$>$ sign will appear if an - input file is read completely through to the end. - - The RS232 redirection options are in the Change Settings (F4) menu. The - menu options are pretty obvious if you keep above remarks in mind, so I - won't go into that. - - When using a COM port, make sure you have initialised it before starting - the emulator with the Dos MODE command, for instance -\begin{itemize} - \item[] \verb|MODE com1:96,n,8,1| -\end{itemize} - initialises COM1 to send and receive at 9600~baud, no parity, 8 data - bits and 1 stop bit, the default for the Interface I. - - Here is how to transfer programs from a Spectrum to the PC using the - RS232 lead. First, you need a null-modem lead. I myself use the - following cable:\\ - -\begin{tabular}{crcc} - Spectrum & & AT & PC \\ - (9 pins) & & (9 pins) & (25 pins) \\ - & & & \\ - 3 & TxD ----------------------- RxD & 2 & 3 \\ - & & & \\ - 4 & DSR ----------------------- DTR & 4 & 20 \\ - & & & \\ - & CTS & 7 & 4 \\ - & $|$~~~ & & \\ - & RTS & 8 & 5 \\ - & & & \\ - 7 & GND ----------------------- GND & 5 & 7 \\ -\end{tabular}\\ - -\noindent - (so CTS and RTS have to be connected!) This is not a full null-modem - lead; you can only send data from the Spectrum to a PC\@. Here's how to - transfer: load the program SAVESPEC.Z80 in the emulator and type the - basic program over into the real Spectrum, and run it. It saves a short - piece of code to tape. - - Now load the program you want to transfer, and stop it. (This may be - tricky!) Load the code back into memory at address 16384 (the code is - relocatable but this is the safest place): -\begin{itemize} - \item[] \verb|LOAD "RS232" CODE 16384| -\end{itemize} - Now open channel three for output to RS232; on a Spectrum with Interface - I this would be \verb|OPEN #3,"b"|, on a Spectrum~128 it would be - \verb|OPEN #3,"p"|, - and with other interfaces you'll probably know what to do. Select the - right baud rate on the Spectrum (probably \verb|FORMAT "b",9600| - or something like that). - Now initialise the appropriate COM port on the PC and type -\begin{itemize} - \item[] \verb|GETRS /n filename.z80| \qquad (n=COM port used) -\end{itemize} - at the DOS prompt, and then type \verb|RANDOMIZE USR 16384| - to send the whole - memory over to the PC\@. The resulting .Z80 file should now be exactly - 49182 bytes long (that is 48K+30 bytes), if not try again or try a lower - baud-rate. Voila, transferred! - - To transfer short blocks of data it's often easier to use the - \verb|LOAD *"b"| and \verb|SAVE *"b"| - commands of the Interface~I. When the right options have - been selected in the RS232 i/o redirection menu, you should just follow - the instructions of the Interface I user manual and all should work as - expected. - - - -\subsection{Joysticks} - - As was already said in the introduction, the emulated Spectrum joystick - (Cursor, Interface 2 or Kempston) is controlled by the PC cursor keys - and 5/0/. on the numeric keypad and TAB as fire keys. The emulated - joystick can also be controlled by a real joystick, both an analogue (PC - standard) or a digital one. - - The analogue joystick support is rather straightforward. If you've got - one, it works - it couldn't be simpler. The digital joystick support is - less obvious, since PC's don't support these. - - To use digital joysticks, Ruud Zandbergen has made a device that uses - the two inputs of a normal analogue joystickinterface to connect a - digital joystick to a PC\@. Here's the circuit diagram: -\newpage - - 15 pins male (pc) \hspace{4.0cm} 9 pins male (joystick) \\ - -\unitlength=1.0cm -\begin{picture}(9,8) -\unitlength=1.0pt -\begin{picture}(300.18,220.22)(70.00,490.00) -\put(230.00,690.00){\line(0,1){20.00}} -\put(300.00,690.00){\line(0,1){20.00}} -\put(160.00,630.00){\line(0,-1){20.00}} -\put(300.00,630.00){\line(0,-1){60.00}} -\put(370.00,630.00){\line(0,-1){80.00}} -\put(130.00,710.00){\line(1,0){270.00}} -\put(130.00,610.00){\line(1,0){41.00}} -\put(130.00,590.00){\line(1,0){110.00}} -\put(130.00,570.00){\line(1,0){181.00}} -\put(130.00,550.00){\line(1,0){270.00}} -\put(130.00,490.00){\line(1,0){270.00}} -\put(130.00,520.00){\line(1,0){30.00}} -\put(300.00,520.00){\line(1,0){100.00}} -\put(160.00,690.00){\line(0,1){20.00}} -\put(369.96,690.06){\line(0,1){19.96}} -\put(229.98,630.04){\line(0,-1){39.92}} -\put(150.00,630.00){\framebox(20.00,60.00)[cc]{}} -\put(220.00,630.00){\framebox(20.00,60.00)[cc]{}} -\put(290.00,630.00){\framebox(20.00,60.00)[cc]{}} -\put(360.00,630.00){\framebox(20.00,60.00)[cc]{}} -\put(160.00,510.00){\framebox(140.00,20.00)[cc]{47 $\Omega$, 1/4 Watt}} -\put(109.98,710.16){\makebox(0,0)[rc]{1+9}} -\put(110.09,610.10){\makebox(0,0)[rc]{3}} -\put(110.00,590.04){\makebox(0,0)[rc]{6}} -\put(110.01,569.94){\makebox(0,0)[rc]{13}} -\put(109.98,550.02){\makebox(0,0)[rc]{11}} -\put(109.88,520.08){\makebox(0,0)[rc]{2}} -\put(109.83,489.94){\makebox(0,0)[rc]{4+5+14}} -\put(410.01,709.93){\makebox(0,0)[lc]{7 (5V)}} -\put(390.04,680.08){\makebox(0,0)[lc]{4 * 1k $\Omega$}} -\put(389.72,659.98){\makebox(0,0)[lc]{1/4 Watt}} -\put(179.90,610.01){\makebox(0,0)[lc]{4 (up)}} -\put(249.90,589.92){\makebox(0,0)[lc]{3 (dwn)}} -\put(319.99,570.04){\makebox(0,0)[lc]{1 (rght)}} -\put(409.81,550.06){\makebox(0,0)[lc]{2 (lft)}} -\put(410.01,519.92){\makebox(0,0)[lc]{6 (fire)}} -\put(409.91,489.98){\makebox(0,0)[lc]{8 (GND)}} -\end{picture} -\end{picture}\\[0.5cm] - -\noindent - 4+5+14 means: connect pins 4, 5 and 14. The same applies for pins 1 and - 9. Here's the list of ingredients: -\begin{itemize} - \item[--] 1 x 9 pins D plug, male - \item[--] 1 x 15 pins D plug, male - \item[--] 4 x 1k $\Omega$ , 1/4 Watt resistors - \item[--] 1 x 47 $\Omega$, 1/4 Watt resistor - \item[--] piece of 7-wire flatcable -\end{itemize} - Everything can be fit into the 15-pins plug. Make sure the resistors - don't touch the other blank connections! This interface can be used for - all usual digital joysticks, with or without auto fire (that is every - joystick that work with a Kempston joystick interface, or that work on a - Commodore 64/Amiga or Atari). The joysticks for the Spectrum +2/+3 will - not work, however the pin layout is easy to change. - - This joystickinterface needs an analogue PC-joystickinterface on which - you can connect TWO analogue joysticks (on one plug!). Most cards can - do this, but some multi-I/O cards support only one joystick. Check the - documentation of your I/O card to see whether your joystickinterface is - suitable. The soundblaster joystick interface works fine. - - A number of PC games will behave strange when the digital joystick - interface is connected; they run very slow or crash. When this happens, - remove the joystick interface (not only the joystick!). - - - -\subsection{Transferring programs} - - There are a number of ways to transfer programs from the Spectrum to the - PC: loading them directly from tape, using the RS232 lead or - transferring from disks of Spectrum disk interfaces. And then you might - have snapshot files from other emulators that you want to convert to - .Z80 files. I'll discuss these cases one after the other. - - Converting using the COM port is not so easy most of the times, but if - you've got a null-modem lead waiting to do something you could read - section 2.6. Luckily, there are easier ways. - - First of all, you can use the tape. If you want to do this, then the - first thing to do is to read section 2.4 carefully - now you know almost - everything you need. Most programs you have probably use the normal - tape format; you will find that these usually load right away. If the - programs use speed-load, using real mode will probably load most of - these right away too. - - But some programs are really cleverly protected, and use obscure - features of the Z80 processor. To run these programs, turn on LDIR - emulator and R register emulation (see the `Change Settings' menu, F4). - Note that the emulator will slow down a bit when R register emulation is - selected; if you need to use real mode then make sure you speed the - emulator up again to 100\%. After the program has loaded successfully, - you may try to turn R register emulation off again; I don't know any - program that needs R register emulation after loading. Read chapter 5 - for more technical information about these options. - - If you've got Spectrum disks, you will probably be able to convert the - programs on them to a useful format and use them in the emulator. The - registered package of this emulator contains a program DISCIPLE, that - can read DISCiPLE and Plus D disks and convert the snapshots and other - files on it to .TAP and .Z80 files. The previous version of this - program could only read 3.5'' Disciple disks, and had several bugs in - the file and snapshot translation routines. So if you transferred - programs with the old DISCIPLE program and they don't work, don't blame - the emulator but try to transfer them again with the new program. - - The current version of the DISCIPLE program reads 3.5'' as well as - 5.25'' DISCiPLE disks, will translate 48K, 128K and screen snapshots, - and other normal files. The previous version used the .SAV file format - for normal files, which could be loaded into the emulator using LOAD - *"b"; this version converts them into .TAP files which can be loaded - simply by using the normal tape LOAD statements (see 2.4). - - The DISCiPLE interface modifies the Spectrum system variables in such a - way that LPRINT sends its output to DISCiPLE's own printer interface. - When you transfer a snapshot that uses the printer, you'll have to tell - it to use the Interface I's RS232 printer output instead, by breaking - the program and typing \verb|OPEN #3,"b"|. If you don't, you'll get strange - results. - - If you have got a Beta disk interface, your problem is solved too. J.L. - Bezemer wrote a program called BDDE that reads Beta disks. The program - can be downloaded from the Spectrum emulator support BBS. - - Finally, maybe you were using another Spectrum emulator for the PC - before using this one, and you may have already got a collection of - snapshot or other files. CONVZ80, another utility for registered users, - can convert between several snapshot formats, namely the .SNA format of - JPP, the .SP formats of VGASPEC and SPECTRUM, the .PRG files of SpecEm, - and the .Z80 format of course. (It is by the way not necessary to - convert .SNA files, the emulator can read them as they are.) CONVZ80 - can also convert the tape files used by SpecEm and ZX to .TAP files. - CONVZ80 recognizes what it should do by the extension of the files you - enter on the command line; to distinguish between VGASPEC's and - SPECTRUM's .SP formats you can use the switch -o. If the extension - consists of digits only, it is taken to be a ZX tape file, and if it - contains non-digits and is none of .SP, .Z80, .SNA, .PRG or .TAP it is - regarded as a SpecEm tape file. - - SpecEm can load .PRG snapshot files, but cannot save them. However, it - emulates the Multiface I, which can save snapshots to tape. SpecEm will - save these blocks as tape files to disk. If you convert these to a .TAP - file (in the correct order!), you can load them into Z80 and save the - program as a .Z80 file. - - - -\subsection{Converting file formats -- the utility CONVERT} - - This section is about the utility CONVERT, which can convert some of the - Spectrum's own format into each other, and also converts some of the - emulator's formats into others. It is not about converting files from - other emulators; read section 2.8 if you want to know about that. - - CONVERT was useful when the emulator could only communicate with - snapshot files and the RS232 link. It has become less useful now, with - .TAP files, but it still has some useful features. - - It can read three types of input files: pure ASCII, pure bytes (for - instance a .SCR screen dump), and files produced by a \verb|SAVE *"b"| - command. - - Output is pure bytes, ASCII with either CR (Spectrum standard) or CR/LF - (PC standard) for line breaks, \verb|SAVE *"b"| files containing a Basic or - code file, a .PCX or a .GIF file. - - So what can you do? Main uses are adding LF (10 hex) bytes to a text - file produced by the Spectrum; converting a code block into a SAVE~*"b" - to load it into the Spectrum using \verb|LOAD *"b"| - (and the reverse of course: converting a - \verb|SAVE *"b"| file to pure bytes), and converting a screen dump - to .PCX or .GIF graphics files. - - Less useful, but possible: LISTing a program (\verb|SAVE *"b"| file) - to produce readable ASCII, and the reverse: converting an ASCII listing to - executable Basic again. - - If you want to make a .PCX or a .GIF file, input should be a - \verb|SAVE *"b"| - file of a screen (length 6921 bytes exactly) or a bare .SCR screendump - (length 6912 bytes). You can make screendumps by selecting the X-Extra - functions menu from the main menu. - - - -\subsection{The utilities Z802TAP and TAP2TAPE} - - The SamRam has built in it some snapshot software. Using this software - you can save any 48K Spectrum program to tape or to a .TAP file, as is - explained in section 3.2 below. But the SamRam software cannot handle a - 128K program. - - The utility that can convert a 128K snapshot (and 48K ones for that - matter) to a .TAP file is called Z802TAP\@. The .TAP file includes a - basic loader, and a loading screen if you want. Z802TAP compresses the - blocks it writes (using a better method than used in compressing .Z80 - files) to save loading time. If you don't want it to compress the - blocks, for instance when you want to take a look at the ram pages of - the Spectrum 128, specify -u when you run Z802TAP\@. You can load the - converted program simply by executing -\begin{itemize} - \item[] \verb|Z80 -ti tapefile| -\end{itemize} - and typing \verb|LOAD ""| (for a 48K program) or changing the hardware - mode to Spectrum 128 and choose `Tape Loader' in the menu. - - The program TAP2TAPE writes .TAP files back to tape. The program - consists of a batch file TAP2TAPE.BAT, which executes the TAP2TAPE.Z80 - file using the emulator. The .TAP file is written to tape exactly as it - is, so that if a block contains a tape error, it won't load correctly - from tape either. If the entire .TAP file has been saved the emulator - will start loading from tape. At that point, press space once to return - to DOS. - -\newpage - - -\section{THE SAMRAM} - - -\subsection{Basic extensions} - - The SamRam is a hardware device Johan and I built for our Spectrums. It - consists of a 32K static RAM chip which contains a modified copy of the - normal Basic ROM and a number of other useful routines, like a monitor - and snapshot software. You can compare it to a Multiface I interface, - but it's more versatile. Another useful feature was a simple hardware - switch which allowed use of the shadow 32K Ram, present at 8000-FFFF in - most Spectrums, but hardly ever actually used. - - For more details on the low-level hardware features of the SamRam read - chapter 5. In this chapter I'll explain the software features of the - SamRam software, somewhat bombastically called the `SamRam 32 Software - System' or the `Sam Operating System'. By the way, all similarity - between existing computers is in fact purely coincidental and has in no - way been intended. Really! - - The SamRam offers a few new Basic commands, and a lot of useful routines - that are activated by an NMI, i.e.\ by pressing F5. First I'll discuss - the Basic extension. - - Select the SamRam by starting the emulator with the -s switch, or by - selecting it from the F9 menu. Normal Basic functions as usual; the - character set is different from the original one. There are four new - commands: -\begin{itemize} - \item[] \verb|*RS, *MOVE, *SAVE| and \verb|*SPECTRUM|, -\end{itemize} - and two new functions, \verb|DEC| and \verb|HEX|, which have replaced - \verb|ASN| and \verb|ACS|\@. DEC takes a string argument - containing a hexadecimal number, and returns the decimal value of it. - \verb|HEX| is the inverse of the \verb|DEC| function, and yields a - four-character string. -\begin{itemize} - \item - \verb|*RS| sends its arguments directly to the RS232 channel. - You don't have - to open a "b" or "t" channel first. You're right, it's of limited use. - Example: \verb|*RS 13,10| - \item - \verb|*MOVE| is useful: it moves a block of memory to another place. - Example: \verb|*MOVE 50000,16384,6912| moves a screen-sized block from - 50000 to the start of the screen memory. - \item - \verb|*SAVE| works like \verb|*MOVE|, except that it activates the shadow - SamRam ROM - before moving. I used this command to update the shadow ROM, but on the - emulator you can use it to move the shadow ROM to a convenient place in - Ram where you can take a look at it, for instance by executing - \verb|*SAVE 0,32768,16384|. - \item - \verb|*SPECTRUM| resets the SamRam Spectrum to a normal one. You lose - all data - in memory. By resetting the emulator by pressing ALT-F5, the SamRam is - activated again. Not very useful either. - \item - Then there's the Ramdisk, which is, like the Spectrum 128 ramdisk, - accessed via the \verb|SAVE!|, \verb|LOAD!|, \verb|CAT!|, \verb|ERASE!| - and \verb|FORMAT!|. The syntax is - straightforward. \verb|FORMAT!| and \verb|CAT!| need no parameters; - \verb|ERASE!| only needs - a name. If a file is not found, the SamRam will respond with a 5-End of - File error. The Ramdisk has a capacity of 25K. -\end{itemize} - - -\subsection{The NMI software} - - Select the SamRam (F9-3), and press F5. A menu with eight icons pops - up. You can select each icon by moving the arrow to it (using the - cursor keys or the Kempston joystick), and pressing `0' or fire. The - icons can also be selected by pressing the appropriate letter key. - - The eight icons are two arrows with N and E within them, a magnifying - glass with the letters `mc' in it (activated by pressing D), two screens - (identified by 1 and 2), a printer (P), a cassette (S) and a box saying - `overig'. The `D' activates the monitor or disassembler; read section - 3.3 for information on this program. - - Pressing N or E returns you to the Spectrum. If you pressed N, the - normal Spectrum rom will be selected when the NMI software returns; if - you press E, the Rom with the Basic extensions will be selected. Some - games may crash if they see a different rom than the standard Spectrum - one. - - Pressing 1 selects the tiny screen editor. You can move a `+' shaped - cursor about the screen using the cursor keys. The following commands - are available: -\begin{itemize} - \item[H:] Get the current ATTR color from the screen at the cursor's - current position, and store it in memory. This color will be - used by the next command: - \item[Z:] Put the color on the screen - \item[G:] Get a character from the screen - \item[P:] Put the character on the screen - \item[R:] Remove all screen data that is invisible by the ATTR color - \item[L:] Take a look at the bitmap below the ATTR color codes - \item[T:] Return to the main menu. You can also return by pressing - EDIT, or ESC in the emulator. - \item[B:] Change border color - \item[V:] Clear the whole screen -\end{itemize} - If you press 0, you can edit the current 8x8 character block at pixel - level. Again you control the cursor with the cursor keys. Now 0 - toggles a pixel. In this mode there are two commands: C clears the - whole block, and I inverts it. Pressing EDIT (ESC) returns you to the - big screen again. - - The SamRam has two screen buffers. Buffer 1 is used to hold the screen - which was visible when you pressed NMI, to be able to restore it when - returning. This is the screen you edit with `1'. The second screen - buffer can be used to hold a screen for some time; it is not touched by - the NMI software directly, and will not even be destroyed by a Reset. If - you press `2', a menu appears with four Dutch entries: -\begin{itemize} - \item[1:] Scherm 1 opslaan (Store screen 1 into buffer 2) - \item[2:] Scherm 2 veranderen (Edit screen 2) - \item[3:] Schermen verwisselen (Swap screens) - \item[4:] Scherm 2 weghalen (Remove screen 2) -\end{itemize} - These four functions are rather obvious, I believe. - - Pressing `P' pops up the printer menu. The screendump program is - written specifically for my printer, a Star SG-10. It will probably - work on some other printers, but not on most. The output is sent to the - RS232 channel, so you have to redirect it to an LPT output. - - Skipping the most interesting, `S', for a moment, let's first discuss - the final menu, `O' for `Overig', Dutch for miscellaneous. There are - five menu options, of which three are not useful. The first gives a - directory of the cartridge currently in Microdrive 1. The last, `E', - returns you to Basic if this is anywhere possible: it resets some - crucial system variables and generates a Break into Program. You can - use this for instance to break in a \verb|BEEP|, or crack a - not-so-very-well-protected program. - The three other options select normal or speed-save, and store - the current setting in CMOS Ram. Speed-save won't work - properly on the emulator, because the speed-save routine toggles the - upper 32K ram bank regularly, and this takes too much time on the - emulator. The setting is not important if you use the internal save - routine (which will be used by default, unless you select Real Mode). - - Finally, the `S' option. This option allows you to save a snapshot to - tape or microdrive. I used it a lot on my real Spectrum, and it works - just as well on the emulator. It is very useful is you want to load a - .Z80 program back into a real Spectrum again. There are three - `switches' you can toggle. The active choice is indicated by a bright - green box, inactive boxes are non-bright. You have to use EGA or VGA to - be able to see it\ldots The first switch lets you select whether the - SamRam rom should be active if the program loads or not. This is only - meaningful is you load it back in a SamRam again. Usually I want the - SamRam rom to be active because I like the character set better. The - second switch indicates whether the SamRam should save a `loading - screen', which it takes from screen buffer 2. If screen buffer 2 - contains a screen, this switch will by default be on. Finally, the last - switch lets you select the output media, tape or cartridge. - - If the program is loaded back into the SamRam, the only bytes that have - been corrupted are four bytes down on the stack; this will virtually - never be any problem. If the program is loaded back to a normal - Spectrum, these four bytes will also be corrupted, and the bottom two - pixel lines of the screen will be filled with data. (This is - considerably less than any other snapshotter I've seen: for instance the - Multiface I uses more than 35\% of the screen!) - - The Microdrive BASIC loader needs code in the SamRam rom to start the - program (the \verb|RANDOMIZE USR 43| calls it). - It won't be very difficult to - write a standard BASIC loader that doesn't need this code, but I don't - think many people desperately need it\ldots - - - -\subsection{The built-in monitor} - - This is a really very convenient part of the emulator, and I use it a - lot. It is very MONS-like in its commands and visual appearance. It - cannot single-step however, but on the positive side it has some - features MONS hasn't. It is a part of the SamRam, and cannot therefore - be used with Spectrum 128 programs. If you want to take a look at a - Spectrum 128 program, press F10, then change the hardware to SamRam - without resetting, and finally generate an NMI in the Extra Functions - menu. You won't probably be able to continue to run the program, but at - least you're able to see what it was doing. - - Press F5 for NMI, and D to enter the monitor/disassembler. The first - eight lines are the first eight instructions, starting at the Memory - Pointer, from here on abbreviated by MP\@. At first, MP is zero. The - disassembler knows all official instructions, and the SLL instruction. - If another inofficial instruction (i.e.\ starting with DD, FD or ED) is - encountered, the first byte is displayed on a blank line. The four - lines below these display the value of PC and SP, the first nine words - on the stack (including AF and the program counter, which have been - pushed during NMI), and three MP-memories. These can be used for - temporary storage of the MP, for instance when you take a look at the - body of a CALL, and want to return to the main procedure later. - - The bottom part of the screen displays 24 bytes around the memory - pointer. - - Commands are one letter long; no ENTER needs to be given. If one or - more operands are needed, a colon will appear. By default the monitor - accepts hexadecimal input. A leading \$ denotes that the number is to be - regarded as decimal. If you give the \# command, the default will toggle - to decimal, and you need to explicitly put a \# in front of a number - which is to be interpreted as a hex number. Also, after the \# command - all addresses on screen will be decimal. A single character preceded by - the " symbol evaluates to its ASCII code, and the single character M - will evaluate to the current value of the memory pointer. -\noindent - The monitor commands: - -\begin{itemize} - \item[Q:] Decrease the memory pointer by one. You effectively shift one - byte up. - \item[A:] Increase the memory pointer, shifting one byte down. - \item[ENTER:] Shift one instruction down: the memory pointer is - increased by the length of first instruction displayed on - screen. - \item[M:] Change the value of the memory pointer. For instance, M:M - won't change it. - \item[P:] Put. The word operand supplied will be stored in the first MP - memory, and the others will shift on place to the right. - Usually, you'll want to store the memory pointer by P:M - \item[G:] Get. Typing G:1, G:2 or G:3 moves the value of one of the MP - memories to the MP\@. - \item[B:] Byte. This command needs a byte operand; it will be poked - into memory, and the memory pointer will move one up. - \item[I:] Insert. The same as B, except that you can poke more than one - byte. It continues to ask for bytes to poke until you type - Enter on a blank line. - \item[\#:] Toggles the default number base between hexadecimal and - decimal. - \item[F:] Find. You can enter up to ten bytes, which will be searched - through memory. Searching will stop at address 0, because - since the search string is stored in shadow Ram, searching - would otherwise not always terminate. Typing Enter on a blank - line starts the search. Byte operands are entered as usual, - but: - \begin{itemize} - \item[--] If a number bigger than 256 decimal is entered, it is - treated as a word in the standard LSB/MSB format. So, 1234 - will search for 34,12 hex in that order. Note that 0012 - will search for 12, not 12,00. - \item[--] A line starting with " decodes into the string of characters - (up to ten) behind it. Normally this would only be the - first character. So instead of typing "M "Y "N "A "M "E - (space=enter here) you type "MYNAME\@. Note that any - terminating " will also be searched for! - \item[--] An x is treated as a wildcard. So if you search for CD x 80 - any call to a subroutine in the block 8000-80FF is a hit. - If you search for x 8000, you'll see every one-byte - instruction that has the address 8000 as operand. - \end{itemize} - \item[N:] Continues the search started by F from the current MP. - \item[\$:] Displays one page of disassembly on screen. In this mode, - the following commands are possible: - \begin{itemize} - \item[\$:] Back to the main screen - \item[7:] [Shift 7 also works, cursor up]: Go to the previous page. - The monitor stores the addresses of the previous eight - pages only. - \item[Q:] Go back one byte (decrease MP by one) - \item[A:] Go one byte forward (increase MP by one) - \item[Z:] Dump this screen to the printer, in ASCII format. Redirect - the RS232 output to a file, and run CONVERT on it to convert - the CR's into CR/LF's before printing (or tell your printer - to do the conversion). - \item[] Every other key displays the next page of disassembly. - \end{itemize} - \item[K:] List. The same mode as with \$ is entered, but instead of a - disassembly the bytes with their ASCII characters are - displayed. Useful to look for text. - \item[C:] Clear. Fills blocks of memory with a specified value. The - monitor prompts with `First', `Last' and `With'. The `Last' - address is inclusive! - \item[D:] Dump. Prompts with `First' and `Last', and dumps a - disassembly of the block between these addresses to the - printer. See remark at \$-Z. The `Last' address is again - inclusive. - \item[R:] Registers. If you press Enter after R, an overview of the - registers contents is displayed. If you type one of A, B, C, - D, E, H, L, A', B', C', D', E', H', L', I, R, AF, BC, DE, HL, - AF', BC', DE', HL', IX, IY, SP or PC, you can change the value - of it. Changing the value of SP also changes the PC and AF - values by the way. You cannot change the Interrupt mode or IFF\@. - \item[V:] Verplaats (Move). Prompts with `From', `To' and `Length'. - Obvious. - \item[S:] Save. Enter the start of the block you wish to save first. - The monitor then prompts with `Length'. The block is saved - without a header, as a normal data block (A, the flagbyte, is - 0FF) - \item[L:] Load. Loads a block of data from tape, at the specified - address. Normal data blocks, headers and blocks with non- - standard flag bytes can be loaded. The first byte in memory - will contain the flag byte. If the checksum isn't 0 after - loading, indicating a tape error, you'll hear a beep. - \item[H:] Header read. Loads headers and displays the contents on - screen. -\end{itemize} - - -\noindent - As you're reading this part, I assume you know something of machine - code. Probably you would be interested in peeking into the software of - the SamRam, the Interface I or the Spectrum 128. You'll first have to - move these roms in ram to be able to look at them with the monitor. - - The Interface I rom can be moved into ram by saving it to microdrive or - to the "b" channel, with:\\ - \verb|SAVE *"m";1;"rom" CODE 0,8192| or \verb|SAVE *"b" CODE 0,8192|, - and loading it back again at 32768 for instance. You can also - put this small machine code routine at 23296 and run it: F3 21 0C 5B E5 - 21 00 00 E5 C3 08 00 21 00 00 11 00 80 01 00 20 ED B0 FB C3 00 07. - - The two SamRam roms are easy. The first you don't need to transfer; the - monitor looks at the extended basic rom by default. The second rom can - be moved to 32768 by typing \verb|*SAVE 0,32768,16384|. - (The SAVE is not the keyword SAVE!) - - The first '128 rom, the one which is active at reset and contains most - of the new code, is moved up by typing \verb|SAVE!"rom"CODE 0,16384|, then - \verb|LOAD!"rom"CODE 32768|. The other rom is most conveniently moved by - saving it to a .TAP file and loading it back again in ram. To select - the SamRam type SPECTRUM first, and then switch the hardware without - resetting. - -\newpage - - -\section{THE SPECTRUM} - - -\subsection{The Spectrum} - - This emulator supports the Interface~I and the Spectrum~128. Many - Spectrum users will have no experience with them, so some comments may - be useful. On the other hand, I don't think this is the right place to - describe the Spectrum Basic in full detail. If you want to know it all, - read the official manuals! - - If you want to use Spectrum Basic, you will need the keywords. You - could by the way now also use the Spectrum~128 Basic where you can type - the keywords in by full. - - If you press ALT-F1 in the emulator, the Spectrum keyboard layout will - appear. For completeness I include an alphabetical list of all keywords - and their key-combination. In the list below, K stands for Keyword - mode, E for E-mode (type Shift-Alt of Shift-Ctrl to select E-mode), S - for Symbol Shift, and SE for Symbol Shifted (Alt/Ctrl) E-mode: select E - mode and type the letter while depressing Symbol Shift. - -\begin{tabular}{|l|l|l|} - \hline - Character & Spectrum-Keyb. & PC-Keyboard \\ - \hline - \hline - \& & S 6 & ALT (or CTRL) 6 \\ - ' & S 7 & ALT 7 or '/" \\ - ( & S 8 & ALT 8 \\ - ) & S 9 & ALT 9 \\ - \_\_ & S 0 & ALT 0 or SHIFT \_\_/- \\ - $<$ & S r & ALT r or SHIFT $<$/, \\ - $>$ & S t & ALT t or SHIFT $>$/, \\ - ; & S o & ALT o or :/; \\ - '' & S p & ALT p or SHIFT "/' \\ - \^\ & S h & ALT h \\ - - & S j & ALT j or \_/- \\ - + & S k & ALT k or SHIFT +/= oder GREY + \\ - = & S l & ALT l or +/= \\ - : & S z & ALT z or SHIFT :/; \\ - ? & S c & ALT c or SHIFT ?// \\ - / & S v & ALT v or ?// \\ - $*$ & S b & ALT b or GREY PRTSC/* \\ - , & S n & ALT n or $<$/, \\ - . & S m & ALT m or $>$/. \\ - \hline -\end{tabular} - -\begin{tabular}{|ll|ll|ll|} - \hline - Keyword & Code & Keyword & Code & Keyword & Code \\ - \hline - \hline - ABS & E g & GO TO & K g & PRINT & K p \\ - ACS & SE w & IF & K u & RANDOMIZE& K t \\ - AND & S y & IN & SE i & READ & E a \\ - ASN & SE q & INK & SE x & REM & K e \\ - AT & S i & INKEY\$ & E n & RESTORE & E s \\ - ATN & SE e & INPUT & K i & RETURN & K y \\ - ATTR & SE l & INT & E r & RND & E t \\ - BEEP & SE z & INVERSE & SE m & RUN & K r \\ - BIN & E b & LEN & E k & RAVE & K s \\ - BORDER & K b & LET & K l & SCREEN\$& SE k \\ - BRIGHT & SE b & LIST & K k & SGN & E f \\ - CAT & SE 9 & LINE & SE 3 & SIN & E q \\ - CHR\$ & E u & LLIST & E v & SQR & E h \\ - CIRCLE & SE h & LN & E z & STEP & S d \\ - CLEAR & K x & LOAD & K j & STOP & S a \\ - CLOSE~\# & SE 5 & LPRINT & E c & STR\$ & E y \\ - CLS & K v & MERGE & SE t & TAB & E p \\ - CODE & E i & MOVE & SE 6 & TAN & E e \\ - CONTINUE & K c & NEW & K a & THEN & S g \\ - COPY & K z & NEXT & K n & TO & S f \\ - COS & E w & NOT & S s & USR & E l \\ - DATA & E d & OPEN~\# & SE 4 & VAL & E j \\ - DEF FN & SE 1 & OR & S u & VAL\$ & SE j \\ - DIM & K d & OUT & SE o & VERIFY & SE r \\ - DRAW & K w & OVER & SE n & $<=$ & S q \\ - ERASE & SE 7 & PAPER & SE c & $>=$ & S e \\ - EXP & E x & PAUSE & K m & $<>$ & S w \\ - FLASH & SE v & PEEK & E o & & \\ - FN & SE 2 & PI & E m & & \\ - FOR & K f & PLOT & K q & & \\ - FORMAT & SE 0 & POINT & SE 8 & DEC & SE q \\ - GO SUB & K h & POKE & K o & HEX & SE w \\ -\hline -\end{tabular} - - - - -\subsection{The Interface~I} - - If you want to use the microdrive, you'll need cartridge files. The - emulator can create an empty cartridge file for you. You have to format - it before you can use it. Type -\begin{itemize} - \item[] \verb|FORMAT "m";1;"name"| -\end{itemize} - to format the cartridge currently in Microdrive 1 giving it the name - `name'. Next, type \verb|CAT 1| to get a catalogue of the files on it - (none of - course) and the number of kilobytes free. You can save a file by typing - for instance -\begin{itemize} - \item[] \verb|SAVE *"m";1;"screen"SCREEN$| -\end{itemize} - Instead of \verb|SCREEN$| you can use all other expressions that are - permitted - also when saving to tape, like \verb|LINE nnnn| or \verb|CODE x,y| - etcetera. To load a file back from cartridge, you type (you guessed it) -\begin{itemize} - \item[] \verb|LOAD *"m";1;"screen"SCREEN$| -\end{itemize} - If the file doesn't exist or is of the wrong type you'll get the - appropriate error message. To erase a file, type for instance -\begin{itemize} - \item[] \verb|ERASE "m";1;"screen"| -\end{itemize} - Note that no * is needed (or even permitted), and that only the name - should be given. There's another way to create a file on a cartridge, - and that is by using a command like \verb|OPEN #3;"m";1;"name"|, - and printing to that stream. You can use \verb|MOVE| to move - data from stream to stream, - but I'll not go into that --- it's not very much used anyway. - - Instead of to the microdrive, you can also `save to the RS232 link'. For - instance, type \verb|SAVE *"b"SCREEN$| (note: there's no name!) to save a - screen. On the emulator you can send the output to the RS232 channel to - a printer (then \verb|SAVE *"b"| is useless), to a file (can be useful) - or to - the COM port (very useful if you connect a real Spectrum to the PC's COM - port!). You can load the data back by typing \verb|LOAD *"b"SCREEN$| and - making sure the RS232 channel is fed with the right input (from a COM - port or a file). See also paragraph 2.6. - - If you want to use the RS232 channel for printing, open stream 3 for - output to that channel by typing -\begin{itemize} - \item[] \verb|OPEN #3,"b"| -\end{itemize} - or -\begin{itemize} - \item[] \verb|OPEN #3,"t"| -\end{itemize} - The first will simply copy everything you send to stream 3 (using for - instance \verb|LPRINT| or \verb|LLIST|) to the RS232 channel; the - second converts CR's - into CR/LF's, breaks off lines at 80 characters and translates keywords - into character sequences. "t" is useful for LLISTings, but not for - anything else. - - Useful extra commands: \verb|CLS #|, to clear the screen and reset the - attributes to their reset defaults, and \verb|CLEAR #| to do a - \verb|CLS #| and close - all currently open streams (discarding all data that may still be - buffered!) - - The Interface I uses its own system variables. At the first error - message you make (or RASP, or flashing question mark) and at the first - Interface I statement you execute, it inserts them automatically. Some - programs will not run when the Interface I has inserted its system - variables. So if you load a game from tape, reset the Spectrum first - and don't make an error typing \verb|LOAD ""|. With a bit of exercise you - should be able to do this. - - - -\subsection{The Spectrum~128} - - The main new features of the Spectrum~128 are its larger memory, that - can be used as a Ram drive in Basic, and music capabilities. - - The Ram drive is accessed via the \verb|LOAD!|, \verb|SAVE!|, - \verb|ERASE!| and \verb|CAT!| - commands. They work as you would expect. Examples: -\begin{itemize} - \item[] \verb|SAVE!"name"SCREEN$| - \item[] \verb|CAT!| - \item[] \verb|LOAD!"name"SCREEN$| - \item[] \verb|ERASE!"name"| -\end{itemize} - The 3 channel sound chip of the Spectrum~128 can be used in Basic with - the \verb|PLAY| command. Example: -\begin{itemize} - \item[] \verb|PLAY "cde","efg","gAB"| -\end{itemize} - plays three chords. You can program complex effects, melodies and - rhythms with the play command; they require many commands in the three - voice strings which I won't explain\ldots They are explained in the - Spectrum~128's user guide. - -\newpage - - - -\section{TECHNICAL INFORMATION} - - -\subsection{The Spectrum} - - The Spectrum is at the hardware level a very simple machine. There's - the 16K ROM which occupies the lowest part of the address space, and 48K - of RAM which fills up the rest. An ULA which reads the lowest 6912 - bytes of RAM to display the screen, and contains the logic for just one - I/O port completes the machine, from a software point of view at least. - - Every even I/O address will address the ULA, but to avoid problems with - other I/O devices only port FE should be used. If this port is written - to, bits have the following meaning:\\ - -\begin{tabular}{|r||c|c|c|c|c|c|c|c|} - \hline - Bit & 7 & 6 & 5 & 4 & 3 & 2 & 1 & 0\\ - \hline - \hline - & & & & E & M & \multicolumn{3}{c|}{Border}\\ - \hline -\end{tabular}\\ - -\noindent - The lowest three bits specify the border colour; a zero in bit 3 - activates the MIC output, and a one in bit 4 activates the EAR output - (which sounds the internal speaker). The real Spectrum also activates - the MIC when the ear is written to; the emulator doesn't. This is no - problem; MIC is only used for saving, and when saving the Spectrum never - sounds the internal speaker. The upper three bits are unused. - - If port FE is read from, the highest eight address lines are important - too. A zero on one of these lines selects a particular half-row of five - keys: -\begin{itemize} - \item[] IN Reads keys (bit 0 to bit 4 inclusive) - \begin{itemize} - \item[] \#FEFE: SHIFT, Z, X, C, V - \item[] \#FDFE: A, S, D, F, G - \item[] \#FBFE: Q, W, E, R, T - \item[] \#F7FE: 1, 2, 3, 4, 5 - \item[] - \item[] \#EFFE: 0, 9, 8, 7, 6 - \item[] \#DFFE: P, O, I, U, Y - \item[] \#BFFE: ENTER, L, K, J, H - \item[] \#7FFE: SPACE, SYM SHIFT, M, N - \end{itemize} -\end{itemize} - A zero in one of the five lowest bits means that the corresponding key - is being pressed. If more than one address line is made low, the result - is the logical AND of all single inputs, so a zero in a bit means that - at least one of the appropriate keys is pressed. For example, only if - each of the five lowest bits of the result from reading from port 00FE - (for instance by XOR~A/IN~A,(FE)) is one, no key is pressed. - - A final remark about the keyboard. It is connected in a matrix-like - fashion, with 8 rows of 5 columns, as is obvious from the above remarks. - Any two keys pressed simultaneously can be uniquely decoded by reading - from the IN ports, however, if more than two keys are pressed decoding - may not be uniquely possible. For instance, if you press Caps shift, B - and V, the Spectrum will think also the Space key is pressed, and react - by giving the `Break into Program' report. This matrix behaviour is - also emulated - without it, Zynaps for instance won't pause when you - press 5,6,7,8 and 0 simultaneously. - - Bit 5 (value 64) of IN-port FE is the ear input bit. When the line is - silent, its value is zero, except in the early Model 2 of the Spectrum, - where it was one. When there is a signal, this bit toggles. The - Spectrum loading software is not sensitive to the polarity of this bit - (which it definitely should not be, not only because of this model - difference, but also because you cannot be sure the tape recorder - doesn't change the polarity of the signal recorded!) Some old programs - rely on the fact that bit 5 is always one (for instance Spinads); for - these programs the emulator can mimic a Model 2 Spectrum. - - Bits 6 and 7 are always one. - - The ULA with the lower 16K of RAM, and the processor with the upper 32K - RAM and 16K ROM are working independently of each other. The data and - address buses of the Z80 and the ULA are connected by small resistors; - normally, these do effectively decouple the buses. However, if the Z80 - wants to read of write the lower 16K, the ULA halts the processor if it - is busy reading, and after it's finished it lets the processor access - lower memory through the resistors. A very fast, cheap and neat design - indeed! - - If you run a program in the lower 16K of RAM, or read or write in that - memory, the processor is halted sometimes. This part of memory is - therefore somewhat slower than the upper 32K block. This is also the - reason that you cannot write a sound- or save-routine in lower memory; - the timing won't be exact, and the music will sound harsh. Also, INning - from port FE will halt the processor, because the ULA has to supply the - result. Therefore, INning from port FE is a tiny bit slower on average - than INning from other ports; whilst normally an IN A,(nn) instruction - would take 11 T states, it takes 12.15 T states on average if nn=FE\@. See - below for more exact information. - - If the processor reads from a non-existing IN port, for instance FF, the - ULA won't stop, but nothing will put anything on the data bus. - Therefore, you'll read a mixture of FF's (idle bus), and screen and ATTR - data bytes (the latter being very scarce, by the way). This will only - happen when the ULA is reading the screen memory, about 60\% of the - 1/50th second time slice in which a frame is generated. The other 40\% - the ULA is building the border or generating a vertical retrace. This - behaviour is actually used in some program, for instance by Arkanoid, - and the emulator also emulates this behaviour. - - Finally, there is an interesting bug in the ULA which also has to do - with this split bus. After each instruction fetch cycle of the - processor, the processor puts the I-R register `pair' (not the 8 bit - internal Instruction Register, but the Interrupt and R registers) on the - address bus. The lowest 7 bits, the R register, are used for memory - refresh. However, the ULA gets confused if I is in the range 64-127, - because it thinks the processor wants to read from lower 16K ram very, - very often. The ULA can't cope with this read-frequency, and regularly - misses a screen byte. Instead of the actual byte, the byte previously - read is used to build up the video signal. The screen seems to be - filled with `snow'; however, the Spectrum won't crash, and program will - continue to run normally. There's one program I know of that uses this - to generate a nice effect: Vectron. (which has very nice music too by - the way). This effect has not been implemented however - it's a bit - useless (but maybe I'll include it in the future). - - The processor has three interrupt modes, selected by the instructions IM - 0, IM 1 and IM 2. In mode 1, the processor simply executes a RST \#38 - instruction if an interrupt is requested. This is the mode the Spectrum - is normally in. The other mode that is commonly used is IM 2. If an - interrupt is requested, the processor first builds a 16 bit address by - combining the I register (as the high byte) with whatever the - interrupting device places on the data bus. The word at this address is - then called. Rodnay Zaks in his book `Programming the Z80' states that - only even bytes are allowed as low index byte, but that isn't true. The - normal Spectrum contains no hardware to place a byte on the bus, and the - bus will therefore always read FF (because the ULA also doesn't read the - screen if it generates an interrupt), so the resulting index address is - 256*I+0FF\@. However, some not-so-neat hardware devices put things on the - data bus when they shouldn't, so later programs didn't assume the low - index byte was 0FF\@. These programs contain a 257 byte table of equal - bytes starting at 256*I, and the interrupt routine is placed at an - address that is a multiple of 257. A useful but not so much used trick - is to make the table contain FF's (or use the ROM for this) and put a - byte 18 hex, the opcode for JR, at FFFF\@. The first byte of the ROM is a - DI, F3 hex, so the JR will jump to FFF4, where a long JP to the actual - interrupt routine is put. - - In interrupt mode 0, the processor executes the instruction that the - interrupting device places on the data bus. On a standard Spectrum this - will be the byte FF, coincidentally (\ldots) the opcode for RST~\#38. But - for the same reasons as above, this is not really reliable. - - The 50 Hz interrupt is synchronized with the video signal generation by - the ULA; both the interrupt and the video signal are generated by it. - Many programs use the interrupt to synchronize with the frame cycle. - Some use it to generate fantastic effects, such as full-screen - characters, full-screen horizon (Aquaplane) or pixel colour (Uridium for - instance). Very many modern programs use the fact that the screen is - `written' (or `fired') to the CRT in a finite time to do as much - time-consuming screen calculations as possible without causing character - flickering: although the ULA has started displaying the screen for this - frame already, the electron beam will for a moment not `pass' - this-or-that part of the screen so it's safe to change something there. - So the exact time in the 1/50 second time-slice at which the screen is - updated is very important. Because the emulator updates the screen at - once, no single best solution can be given, and therefore the user can - select one of three possibilities (low, normal or high video - synchronisation, corresponding to a screen update after 1/200, 2/200 or - 3/200 of a (relative) second after a Z80 interrupt) which gives the best - results. Try for instance Zynaps; with normal video synchronisation the - top four or five lines of the background move out-of-phase with the - rest, and your space-ship flickers in that region. With low video - synchronisation the background moves smoothly but the sprites flicker in - all parts of the screen. Only with high video sync everything moves - smoothly and doesn't flicker. - - This emulator does not try to emulate the really time-critical border - pattern effects (except when loading, but the width of the loading - stripes are not quite right because also PC video timings come into - play), but maybe I'll include it in the future. I will need some hard - data on video timings then, and I've figured these out recently. Here - they are. - - Each line takes exactly 224 T states. After an interrupt occurs, 64 - line times pass before the byte 16384 is displayed. At least the last - 48 of these are actual border-lines. I could not determine whether my - monitor didn't display the others or whether it was in vertical retrace, - but luckily that's not really important. Then the 192 screen+border - lines are displayed, followed by about 56 border lines again. 56.5 - border lines would make up exactly 70000 T states, 1/50th of 3500000. - However, I noticed that the frequency of the 50 Hz interrupt (measured - in 1/T states!) changes very slightly when my Spectrum gets hot (I think - it has something to do with the relative change of the frequencies of - the two crystals in the Spectrum), so the time between interrupts will - probably not be exactly 70000 T states. Anyway, whether the final border - block is of fixed or variable length doesn't concern us either, the - timings of the start and end of the screen, which are the timings of - real interest, are fixed. - - Now for the timings of each line itself. I define a screen line to - start with 256 screen pixels, then border, then horizontal retrace, and - then border again. All this takes 224 T states. Every half T state a - pixel is written to the CRT, so if the ULA is reading bytes it does so - each 4 T states (and then it reads two: a screen and an ATTR byte). The - border is 48 pixels wide at each side. A video screen line is therefore - timed as follows: 128 T states of screen, 24 T states of right border, - 48 T states of horizontal retrace and 24 T states of left border. - - When an interrupt occurs, the running instruction has to be completed - first. So the start of the interrupt is fixed relative to the start of - the frame up to the length of the last instruction in T states. If the - processor was executing a HALT (which, according to the Z80 books I - read, is effectively many NOPs), the interrupt routine starts at most 3 - T states away from the start of the frame. Of course the processor also - needs some T states to store the program counter on the stack, read the - interrupt vector and jump to the routine, but since I cannot determine - that by only using the Spectrum, it is useless information by that very - reason alone! - - Now when to OUT to the border to change it at the place you want? First - of all, you cannot change the border within a `byte', an 8-pixel chunk. - If we forget about the screen for a moment, if you OUT to port FE after - 14326 to 14329 T states (including the OUT) from the start of the IM 2 - interrupt routine, the border will change at exactly the position of - byte 16384 of the screen. The other positions can be computed by - remembering that 8 pixels take 4 T states, and a line takes 224 T - states. You would think that OUTing after 14322 to 14325 T states, the - border would change at 8 pixels left of the upper left corner of the - screen. This is right for 14322, 14323 and 14324 T states, but if you - wait 14325 T states the ULA happens to be reading byte 16384 (or 22528, - or both) and will halt the processor for a while, thereby making you - miss the 8 pixels. This exception happens again after 224 T states, and - again after 448, an so forth. These 192 exceptions left of the actual - screen rectangle are the only ones; similar things don't happen at the - right edge because the ULA don't need to read things there - it has just - finished! - - As noted above, reading or writing in low ram (or OUTing to the ULA) - causes the ULA to halt the processor. When and how much? The processor - is halted each time you want to access the ULA or low memory and the ULA - is busy reading. Of the 312.5 `lines' the ULA generates, only 192 - contain actual screen pixels, and the ULA will only read bytes during - 128 of the 224 T states of each screen line. But if it does, the - processor is halted for exactly 4 T states. - - - -\subsection{The Interface~I} - - The Interface I is quite complicated. It uses three different I/O - ports, and contains logic to page and unpage an 8K ROM if new commands - are used. I won't be very detailed here; you could refer to the source - code of the emulator if you want to know some details, or read the - `Spectrum Shadow ROM Disassembly' by Gianlura Carri, published by - Melbourne House - but don't expect the same level of detail as of Ian - Logan and Frank O'Hara in their Rom disassembly book. - - The ROM is paged if the processor executes the instruction at ROM - address 0008 or 1708 hexadecimal, the error and close\# routines. It is - inactivated when the Z80 executes the RET at address 0700. - - I/O Port E7 is used to send or receive data to and from the microdrive. - Accessing this port will halt the Z80 until the Interface I has - collected 8 bits from the microdrive head; therefore, it the microdrive - motor isn't running, or there is no formatted cartridge in the - microdrive, the Spectrum hangs. This is the famous `IN 0 crash'.\\ -\noindent - Port EF is used for several things:\\ - -\begin{tabular}{|r||c|c|c|c|c|c|c|c|} - \hline - Bit & 7 & 6 & 5 & 4 & 3 & 2 & 1 & 0\\ - \hline - \hline - READ & & & & busy & dtr & gap & sync & write\\ - & & & & & & & & prot.\\ - \hline - WRITE & & & wait & cts & erase & r/$\overline{\mbox{w}}$ & comms & comms\\ - & & & & & & & clk & data\\ - \hline -\end{tabular}\\ - -\noindent - Bits DTR and CTS are used by the RS232 interface. The WAIT bit is used - by the Network to synchronise, GAP, SYNC, WR\_PROT, ERASE, R/\_W, COMMS - CLK and COMMS DATA are used by the microdrive system. If the microdrive - is not being used, the COMMS DATA output selects the function of bit 0 - of out-port F7:\\ - -\begin{tabular}{|r||c|c|c|c|c|c|c|c|} - \hline - Bit & 7 & 6 & 5 & 4 & 3 & 2 & 1 & 0\\ - \hline - \hline - READ & txdata & & & & & & & net\\ - & & & & & & & & input\\ - \hline - WRITE & & & & & & & & net output\\ - & & & & & & & & rxdata\\ - \hline -\end{tabular}\\ - -\noindent - TXDATA and RXDATA are the input and output of the RS232 port. COMMS - DATA determines whether bit 0 of F7 is output for the RS232 or the - network. - - - -\subsection{The SamRam} - - The SamRam contains a 32K static CMOS Ram chip, and some I/O logic for - port 31. If this port is read, it returns the position of the joystick, - as a normal Kempston joystickinterface would. If written to, the port - controls a programmable latch chip (the 74LS259) which contains 8 - latches:\\ - -\begin{tabular}{|r||c|c|c|c|c|c|c|c|} - \hline - Bit & 7 & 6 & 5 & 4 & 3 & 2 & 1 & 0\\ - \hline - WRITE & & & & & \multicolumn{3}{c|}{address} & bit\\ - \hline -\end{tabular}\\ - -\noindent - The address selects on of the eight latches; bit 0 is the new state of - the latch. The 16 different possibilities are collected in the diagram - below:\\ - -\begin{tabular}{|c|c|l|} - \hline - OUT 31, & OUTPUT & RESULT\\ - \hline - \hline - 0 & 0 & Switch on write protect of CMOS RAM\\ - 1 & 0 & Write to CMOS RAM allowed\\ - 2 & 1 & Turn on CMOS RAM (see also 6/7)\\ - 3 & 1 & Turn off CMOS RAM (standard Spec. ROM)\\ - 4 & 2 & ---\\ - 5 & 2 & Ignore all OUT's to 31 hereafter\\ - 6 & 3 & Select CMOS bank 0 (Basic ROM)\\ - 7 & 3 & Select CMOS bank 1 (Monitor,\ldots)\\ - 8 & 4 & Select interface~1\\ - 9 & 4 & Turn off IF~1 (IF1 ROM won't be paged)\\ - 10 & 5 & Select 32K RAM bank 0 (32768-65535)\\ - 11 & 5 & Select 32K RAM bank 1 (32768-65535)\\ - 12 & 6 & Turn off beeper\\ - 13 & 6 & Turn on beeper\\ - 14 & 7 & ---\\ - 15 & 7 & ---\\ - \hline -\end{tabular}\\ - -\noindent - At reset, all latches are 0. If an \verb|OUT 31,5| is issued, only a reset - will give you control over the latches again. The write protect latch - is not emulated; you're never able to write the emulated CMOS ram in the - emulator. Latch 4 will pull up the M1 output of the Z80. The Interface - I won't page the ROM anymore then. - - - -\subsection{The Z80 microprocessor} - - The Z80 processor is quite straightforward, and contains to my knowledge - no interesting bugs or quirks. However, it has some undocumented - features. Some of these are quite useful, and some are not, but since - many programs use the useful ones, and a few programs use the weird - ones, I tried to figure them out and emulate them as best as I could. - There is a Z80 emulator around, intended as a CP/M emulator, which halts - the program if an undocumented opcode is encountered. I don't think - this makes sense. ZiLOG doesn't dictate the law, the programs which use - the processor's features do! - - Most Z80 opcodes are one byte long, not counting a possible byte or word - operand. The four opcodes CB, DD, ED and FD are shift opcodes: they - change the meaning of the opcode following them. - - There are 248 different CB opcodes. The block CB 30 to CB 37 is missing - from the official list. These instructions, usually denoted by the - mnemonic SLL, Shift Left Logical, shift left the operand and make bit 0 - always one. Bounder and Enduro Racer use them. The SamRam monitor can - disassemble these and uses the mnemonic SLL\@. These instructions are - quite commonly used. - - The DD and FD opcodes precede instructions using the IX and IY - registers. If you look at the instructions carefully, you see how they - work:\\ - -\begin{tabular}{ll} - \makebox[4cm][l]{2A~nn} & LD HL,(nn) \\ - \makebox[4cm][l]{DD~2A~nn} & LD IX,(nn) \\ - \makebox[4cm][l]{7E} & LD A,(HL) \\ - \makebox[4cm][l]{DD~7E~d} & LD A,(IX+d) \\ -\end{tabular}\\ - -\noindent - A DD opcode simply changes the meaning of HL in the next instruction. - If a memory byte is addressed indirectly via HL, as in the second - example, a displacement byte is added. Otherwise the instruction simply - acts on IX instead of HL\@. (A notational awkwardness, that will only - bother assembler and disassembler writers: JP (HL) is not indirect; it - should have been denoted by JP HL) If a DD opcode precedes an - instruction that doesn't use the HL register pair at all, the - instruction is executed as usual. However, if the instruction uses the - H or L register, it will now use the high or low halves of the IX - register! Example:\\ - -\begin{tabular}{ll} - \makebox[4cm][l]{44} & LD B,H \\ - \makebox[4cm][l]{FD~44} & LD B,IYh \\ -\end{tabular}\\ - -\noindent - These types of inofficial instructions are used by very many programs. - By the way, many DD or FD opcodes after each other will effectively be - NOPs, doing nothing except repeatedly setting the flag `treat HL as IX' - (or IY) and taking up 4 T states. (But try to let MONS disassemble such - a block.) - - I've never seen a program using inofficial ED instructions, and except - for ED 6B nn, a long version of 2A nn, LD HL,(nn) I don't know any. I - am pretty sure however that they exist, but I never took the trouble to - test them all. - - About the R register. This is not really an undocumented feature, - although I have never seen any thorough description of it anywhere. The - R register is a counter that is updated every instruction, where DD, FD, - ED and CB are to be regarded as separate instructions. So shifted - instruction will increase R by two. There's an interesting exception: - doubly-shifted opcodes, the DDCB and FDCB ones, increase R by two too. - LDI increases R by two, LDIR increases it by 2 times BC, as does LDDR - etcetera. The sequence LD R,A / LD A,R increases A by two, except for - the highest bit: this bit of the R register is never changed. This is - because in the old days everyone used 16 Kbit chips. Inside the chip - the bits where grouped in a 128x128 matrix, needing a 7 bit refresh - cycle. Therefore ZiLOG decided to count only the lowest 7 bits. Anyway, - if the R register emulation is switched on the R register will behave as - is does on a real Spectrum; if it is off it will (except for the upper - bit) act as a random generator. - - You can easily check that the R register is really crucial to memory - refresh. Assemble this program:\\ - -\begin{tabular}{ll} - & ORG 32768 \\ - & DI \\ - & LD B,0 \\ - L1 & XOR A \\ - & LD R,A \\ - & DEC HL \\ - & LD A,H \\ - & OR L \\ - & JR NZ,L1 \\ - & DJNZ L1 \\ - & EI \\ - & RET \\ -\end{tabular}\\ - -\noindent - It will take about three minutes to run. Look at the upper 32K of - memory, for instance the UDG graphics. It will have faded. Only the - first few bytes of each 256 byte block will still contain zeros, because - they were refreshed during the execution of the loop. The ULA took care - of the refreshing of the lower 16K. (This example won't work on the - emulator of course!) - - Then there's one other dark corner of the Z80 which has its effect on - programs like Sabre Wulf, Ghosts'n Goblins and Speedlock. The Mystery - of the Undocumented Flags! - - Bit 3 and 5 of the F register are not used. They can contain - information, as you can readily figure out by using PUSH AF and POP AF\@. - Furthermore, sometimes their values change. I found the following - empirical rule:\\ - -\newpage -\begin{itemize} - \item[] The values of bit 7, 5 and 3 follow the values of the - corresponding bits of the last 8 bit result of an instruction - that changed the usual flags. -\end{itemize} - - -\noindent - For instance, after an ADD A,B those bits will be identical to the bits - of the A register. (Bit 7 of F is the sign flag, and fits the rule - exactly). An exception is the CP x instruction (x=register, (HL) or - direct argument). In that case the bits are copied from the argument. - - If the instruction is one that operates on a 16 bit word, the 8 bits of - the rule are the highest 8 bits of the 16 bit result - that was to be - expected since the S flag is extracted from bit 15. - - Ghosts'n Goblins use the undocumented flag due to a programming error. - The rhino in Sabre Wulf walks backward or keeps running in little - circles in a corner, if the (in this case undocumented) behaviour of the - sign flag in the BIT instruction isn't right. I quote:\\ - -\begin{tabular}{ll} - \makebox[6cm][l]{AD86 \quad DD~CB~06~7E} & BIT 7,(IX+6) \\ - \makebox[6cm][l]{AD89 \quad F2~8F~AD} & JP P,\#AD8F \\ -\end{tabular}\\ - -\noindent - An amazing piece of code! Speedlock does so many weird things that all - must be exactly right for it to run. Finally, the '128 rom uses the AF - register to hold the return address of a subroutine for a while. To - keep all programs happy and still have a fast emulator, I had to make a - compromise. The undocumented flags are not always emulated right, but - they are most of the time. - - Finally, a remark about the interrupt flip flops IFF1 and IFF2. There - seems to be a little confusion about these. These flip flops are - simultaneously set or reset by the EI and DI instructions. IFF1 - determines whether interrupts are allowed, but its value cannot be read. - The value of IFF2 is copied to the P/V flag by LD A,I and LD A,R. When - an NMI occurs, IFF1 is reset, thereby disallowing further (maskable) - interrupts, but IFF2 is left unchanged. This enables the NMI service - routine to check whether the interrupted program had enabled or disabled - maskable interrupts. So, Spectrum snapshot software can only read IFF2, - but most emulators will emulate both, and then the one that matters most - is IFF1. - - Now for the emulated Z80\@. I have added eight instructions, to speed up - the RS232 input and output of the Interface I and several things of the - SamRam. These opcodes, ED F8 to ED FE are of little use to any other - program. ED FF is a nice one: it returns you to DOS immediately. I - used it for debugging purposes.\\ - - -\newpage -\subsection{File formats} - - This sections describes the formats of the files used by - the emulator.\\ - -\noindent -\underline{ROMS.BIN:}\\ - -\begin{tabular}{ll} - 00000-03fff & Ordinary Spectrum rom \\ - 04000-05fff & Interface I rom (8K) \\ - 06000-09fff & First SamRam rom (contains BASIC) \\ - 0a000-0dfff & Second SamRam rom (contains monitor,\ldots) \\ - 0e000-11fff & First Spectrum 128K rom (active at RESET) \\ - 12000-15fff & Second Spectrum 128K rom (contains BASIC) \\ -\end{tabular}\\ - -\noindent - The ordinary rom has not been modified. The Interface I rom has - undergone some modifications, to speed up the RS232 input/output - routines. If you don't like this, or want to use another version of the - Interface I, you could put that code at the right place in the ROMS.BIN - file. The interface I should work properly, although the RS232 will be - slower (always FORMAT the "b" or "t" channel at 19200 baud, by the way, - if you replace the rom code, there's no point in waiting for nothing!) - The microdrive routines have not been modified in any way. Here are the - changes of the Interface I rom:\\ - -\begin{tabular}{|c|c|c||c|c|c|} - \hline - Address & Old & New & Address & Old & New\\ - \hline - \hline - 0B9E & ED & ED & 0D20 & FB & 00\\ - 0B9F & 5B & FC & 0D2A & 37 & ED\\ - 0BA0 & C3 & F5 & 0D2B & F3 & FD\\ - 0BA1 & 5C & C3 & 0D2C & CE & 18\\ - 0BA2 & 21 & 34 & 0D2D & 00 & 10\\ - 0BA3 & 20 & 0C & 0D4C & FB & 00\\ - \hline -\end{tabular}\\ - -\noindent - These changes are not likely to cause problems; there are several - versions of the Interface I rom around, and program developers know - this. It is also a bit pointless to check whether the Interface I rom - hasn't been modified; who would put his snapshot software in there - anyway, and that's what those people are afraid of. - - The first and second SamRam rom have been modified more extensively. The - biggest problem was that switching the upper 32K ram bank is very fast - in reality, but on the PC two blocks of 32K bytes had to be REP - MOVSWded. But since no programs know of the SamRam code anyway, this - won't cause any more problems it wouldn't already cause either. - The two Spectrum 128 roms have not been modified.\\ - -\newpage -\noindent - \underline{.TAP FILES:}\\ - - The .TAP files contain blocks of tape-saved data. All blocks start with - two bytes specifying how many bytes will follow (not counting the two - length bytes). Then raw tape data follows, including the flag and - checksum bytes. The checksum is the bitwise XOR of all bytes including - the flag byte. For example, when you execute the line - \verb|SAVE "ROM" CODE 0,2| this will result: - -\[ - \underbrace{13~00}_1 - \overbrace{ - \underbrace{00}_2 \underbrace{03}_3 - \underbrace{52~\mbox{4F~4D~7x20}}_4 - \underbrace{02~00~00~00~00~80}_5 - \underbrace{\mbox{F1}}_6}^{\mbox{Spectrum-generated data}} - \underbrace{04~00}_7 - \overbrace{ - \underbrace{\mbox{FF}}_8 \underbrace{\mbox{F3~AF}}_9 - \underbrace{\mbox{A3}}_{10}} -\]\\ -{\footnotesize -\indent with the following meaning: -\begin{itemize} - \begin{itemize} - \item[1:] First block is 19 bytes (17 bytes+flag+checksum) - \item[2:] flag byte (A reg, 00 for headers, FF for datablocks) - \item[3:] first byte of header, indicating a code block - \item[4:] filename - \item[5:] header info - \item[6:] checksum of header - \item[7:] length of second block - \item[8:] flag byte - \item[9:] first two bytes of rom - \item[10:] checksum (`checkbittoggle' would be better) - \end{itemize} -\end{itemize} -} - -\noindent - The emulator will always start reading bytes at the beginning of a - block. If less bytes are loaded than are available, the other bytes are - skipped, and the last byte loaded is used as checksum. If more bytes - are asked for than exist in the block, the loading routine will - terminate with the usual tape-loading-error flags set, leaving the error - handling to the calling Z80 program. - - Note that it is possible to join .TAP files by simply stringing them - together, for example:\\ - - \verb|COPY /B FILE1.TAP + FILE2.TAP ALL.TAP|\\ - -\noindent - For completeness, I'll include the structure of a tape header. A header - always consists of 17 bytes:\\ - -\begin{tabular}{|r|r|l|} - \hline - Byte & Length & Description \\ - \hline - \hline - 0 & 1 & Type (0,1,2 or 3) \\ - 1 & 10 & Filename (padded with blanks) \\ - 11 & 2 & Length of data block \\ - 13 & 2 & Parameter 1 \\ - 15 & 2 & Parameter 2 \\ - \hline -\end{tabular}\\ - -\noindent - The type is 0,1,2 or 3 for a Program, Number array, Character array or - Code file. A screen\$ file is regarded as a Code file with start address - 16384 and length 6912 decimal. If the file is a Program file, parameter - 1 holds the autostart line number (or a number $>=$32768 if no LINE - parameter was given) and parameter 2 holds the start of the variable - area relative to the start of the program. If it's a Code file, - parameter 1 holds the start of the code block when saved, and parameter - 2 holds 32768. For data files finally, the byte at position 14 decimal - holds the variable name.\\ - -\newpage -\noindent -\underline{.MDR FILES:}\\ - - The emulator uses a cartridge file format identical to the `Microdrive - File' format of Carlo Delhez' Spectrum emulator Spectator for the QL\@. - The following information is adapted from Carlo's documentation. It can - also be found in the `Spectrum Microdrive Book', by Ian Logan (co-writer - of the excellent `Complete Spectrum ROM Disassembly'). - - A cartridge file contains 254 `sectors' of 543 bytes each, and a final - byte flag which is non-zero is the cartridge is write protected, so the - total length is 137923 bytes. On the cartridge tape, after a GAP of - some time the Interface I writes 10 zeros and 2 FF bytes (the preamble), - and then a fifteen byte header-block-with-checksum. After another GAP, - it writes a preamble again, with a 15-byte record- - descriptor-with-checksum (which has a structure very much like the - header block), immediately followed by the data block of 512 bytes, and - a final checksum of those 512 bytes. The preamble is used by the - Interface I hardware to synchronise, and is not explicitly used by the - software. The preamble is not saved to the microdrive file:\\ - -\begin{tabular}{|r|r|l|l|} - \hline - offset & length & name & contents \\ - \hline - \hline - 0 & 1 & HDFLAG & Value 1, to indicate header block \\ - 1 & 1 & HDNUMB & sector number (values 254 down to 1) \\ - 2 & 2 & & not used \\ - 4 & 10 & HDNAME & microdrive cartridge name (blank padded) \\ - 14 & 1 & HDCHK & header checksum (of first 14 bytes) \\ - & & & \\ - 15 & 1 & RECFLG & - bit 0: always 0 to indicate record block \\ - & & & - bit 1: set for the EOF block \\ - & & & - bit 2: reset for a PRINT file \\ - & & & - bits 3-7: not used (value 0) \\ - 16 & 1 & RECNUM & data block sequence number (value starts at 0) \\ - 17 & 2 & RECLEN & data block length ($<=$512, LSB first) \\ - 19 & 10 & RECNAM & filename (blank padded) \\ - 29 & 1 & DESCHK & record descriptor checksum (of previous 14 bytes)\\ - 30 & 512 & & data block \\ - 542 & 1 & DCHK & data block checksum (of all 512 bytes of data \\ - & & & block, even when not all bytes are used) \\ - \hline -\end{tabular} - - repeated 254 times\\ - -\noindent - (Actually, this information is `transparent' to the emulator. All it - does is store 2 times 254 blocks in the .MDR file as it is OUTed, - alternatingly of length 15 and 528 bytes. The emulator does check - checksums, see below; the other fields are dealt with by the emulated - Interface I software.) - - A used record block is either an EOF block (bit 1 of RECFLG is 1) or - contains 512 bytes of data (RECLEN=512, i.e.\ bit 1 of MSB is 1). An - empty record block has a zero in bit 1 of RECFLG and also RECLEN=0. An - unusable block (as determined by the FORMAT command) is an EOF block - with RECLEN=0. - - The three checksums are calculated by adding all the bytes together - modulo 255; this will never produce a checksum of 255. Possibly, this - is the value that is read by the Interface I if there's no or bad data - on the tape. - - In normal operation, all first-fifteen-byte blocks of each header or - record block will have the right checksum. If the checksum is not - right, the block will be treated as a GAP\@. For instance, if you type - OUT 239,0 on a normal Spectrum with interface I, the microdrive motor - starts running and the cartridge will be erased completely in 7 seconds. - CAT 1 will respond with `microdrive not ready'. Try it on the - emulator\ldots\\ - -\newpage -\noindent -\underline{.SCR FILES:}\\ - -\noindent - .SCR files are memory dumps of the first 6912 bytes of the Spectrum - memory. A coordinate (x,y), x between 0 and 255 and y between 0 and - 192, (0,0) being the upper left corner of the screen, corresponds to the - pixel address -\begin{itemize} - \item[] 16384+INT (x/8)+1792*INT (y/64)-2016*INT (y/8)+256*y -\end{itemize} - -\noindent - The lowest three bits of x determine which bit of this address - corresponds to the pixel (x,y). This bit-map constitutes the larger - part of the screen memory, 256*192/8=6144 bytes. The final 768 bytes - are attribute bytes. The address of the attribute byte corresponding to - pixel (x,y) is -\begin{itemize} - \item[] 22528+INT (x/8)+32*INT (y/8) -\end{itemize} - The lowest three bits of the attribute byte control the foreground color - (the color of the pixel if the corresponding bit is set), bits 3-5 - control the background color, bit 6 is the bright bit and bit 7 is the - flash bit: if it is set, every 16/50th of a second the ULA - effectively flips the foreground and background colours. - -\newpage -\noindent -\underline{.Z80 FILES:}\\ - - The old .Z80 snapshot format (for version 1.45 and below) looks like - this: \\ - -\begin{tabular}{|c|c|l|} - \hline - Byte & Length & Description\\ - \hline - \hline - 0 & 1 & A-register\\ - 1 & 1 & F-register\\ - 2 & 2 & BC-register pair (LSB, i.e.\ C, first)\\ - 4 & 2 & HL-register pair\\ - 6 & 2 & Program counter\\ - 8 & 2 & Stack pointer\\ - 10 & 1 & Interrupt register\\ - 11 & 1 & Refresh register (Bit 7 is not significant!)\\ - 12 & 1 & \makebox[1.5cm][l]{Bit 0 }: Bit 7 of the R-registers\\ - & & \makebox[1.5cm][l]{Bit 1-3}: Border colour\\ - & & \makebox[1.5cm][l]{Bit 4 }: 1=Basic SamRom switched in\\ - & & \makebox[1.5cm][l]{Bit 5 }: 1=Block of data is compressed\\ - & & \makebox[1.5cm][l]{Bit 6-7}: No meaning\\ - 13 & 2 & DE-register pair\\ - 15 & 2 & BC'-register pair\\ - 17 & 2 & DE'-register pair\\ - 19 & 2 & HL'-register pair\\ - 21 & 1 & A'-register\\ - 22 & 1 & F'-register\\ - 23 & 2 & IY-register\\ - 25 & 2 & IX-register\\ - 27 & 1 & Interrupt flipflop (0=DI, otherwise EI)\\ - 28 & 1 & IFF2 (not particiulary important\ldots)\\ - 29 & 1 & \makebox[1.5cm][l]{Bit 0-1}: Interrupt mode (0, 1 oder 2)\\ - & & \makebox[1.5cm][l]{Bit 2 }: 1 = Issue-2-Emulation\\ - & & \makebox[1.5cm][l]{Bit 3 }: 1 = Double interrupt frequency\\ - & & \makebox[1.5cm][l]{Bit 4-5}: 1 = High video synchronisation\\ - & & \makebox[1.5cm][l]{ }: 3 = Low video synchronisation\\ - & & \makebox[1.5cm][l]{ }: 0,2 = Normal\\ - & & \makebox[1.5cm][l]{Bit 6-7}: 0 = Cursor/Protek/AGF Joyst -ick\\ - & & \makebox[1.5cm][l]{ }: 1 = Kempston joystick\\ - & & \makebox[1.5cm][l]{ }: 2 = Sinclair 1 joystick\\ - & & \makebox[1.5cm][l]{ }: 3 = Sinclair 2 joystick\\ - \hline -\end{tabular} -\\*[.5cm] - -\noindent - Because of compatibility, if byte 12 is 255, it has to be regarded as - being 1. After this header block of 30 bytes the 48K bytes of Spectrum - memory follows in a compressed format (if bit 5 of byte 12 is one). The - compression method is very simple: it replaces repetitions of at least - five equal bytes by a four-byte code ED ED xx yy, which stands for "byte - yy repeated xx times". Only sequences of length at least 5 are coded. - The exception is sequences consisting of ED's; if they are encountered, - even two ED's are encoded into ED ED 02 ED\@. Finally, every byte - directly following a single ED is not taken into a block, for example - ED 6*00 is not encoded into ED ED ED 06 00 but into ED 00 ED ED 05 00. - The block is terminated by an end marker, 00 ED ED 00. - - That's the format of .Z80 files as used by versions up to 1.45. Since - starting from version 2.0 the program emulates the Spectrum 128 too, - there was a need for a new format. - - The first 30 bytes are almost the same as the old versions' header. Of - the flag byte, bit 4 and 5 have got no meaning anymore, and the program - counter (bytes 6 and 7) are zero to signal a version 2.0 .Z80 file. So - loading a new style .Z80 file into an old emulator will cause an error - or a reset at the most.\\ - After the first 30 bytes, an additional header follows:\\ - -\begin{tabular}{|r|r|l|} - \hline - Byte & Length & Description \\ - \hline - \hline - 30 & 2 & Length of additional header block (contains 23) \\ - 32 & 2 & Program counter \\ - 34 & 1 & Hardware mode: 0=Spectrum 48K, 1=0+interface I, \\ - & & 2=SamRam, 3=Spectrum 128K, 4=3+interface I. \\ - 35 & 1 & If in SamRam mode, bitwise state of 74ls259. \\ - & & For example, bit 6=1 after an \verb|OUT 31,13| - (=2*6+1) \\ - & & If in 128 mode, contains last OUT to 7ffd \\ - 36 & 1 & Contains 0FF if Interface I rom paged \\ - 37 & 1 & Bit 0: 1 if R register emulation on \\ - & & Bit 1: 1 if LDIR emulation on \\ - 38 & 1 & Last OUT to fffd (soundchip register number) \\ - 39 & 16 & Contents of the sound chip registers \\ - \hline -\end{tabular}\\ - -\noindent - Hereafter a number of memory blocks follow, each containing the - compressed data of a 16K block. The compression is according to the old - scheme, except for the end-marker, which is now absent. The structure - of a memory block is:\\ - -\begin{tabular}{|r|r|l|} - \hline - Byte & Length & Description \\ - \hline - \hline - 0 & 2 & Length of data (without this 3-byte header) \\ - 2 & 1 & Page number of block \\ - 3 & [0] & Compressed data \\ - \hline -\end{tabular}\\ - -\noindent - The pages are numbered, depending on the hardware mode, in the following - way: \\ - -\begin{tabular}{|r|l|l|l|} - \hline - Page & In '48 mode & In '128 mode & In SamRam mode \\ - \hline - \hline - 0 & 48K rom & rom (basic) & 48K rom \\ - 1 & Interf. I rom & Interf. I rom & Interf. I rom \\ - 2 & - & rom (reset) & samram rom (basic) \\ - 3 & - & page 0 & samram rom (monitor, \ldots)\\ - 4 & 8000-bfff & page 1 & Normal 8000-bfff \\ - 5 & c000-ffff & page 2 & Normal c000-ffff \\ - 6 & - & page 3 & Shadow 8000-bfff \\ - 7 & - & page 4 & Shadow c000-ffff \\ - 8 & 4000-7fff & page 5 & 4000-7fff \\ - 9 & - & page 6 & - \\ - 10 & - & page 7 & - \\ - \hline -\end{tabular}\\ - -\noindent - In 48K mode, pages 4,5 and 8 are saved. In SamRam mode, pages 4 to 8 - are saved. In 128 mode, all pages from 3 to 10 are saved. This - version saves the pages in numerical order. There is no end marker. - -\end{document} - - diff --git a/Docs/z80faq.doc b/Docs/z80faq.doc deleted file mode 100644 index 80369f4..0000000 --- a/Docs/z80faq.doc +++ /dev/null @@ -1,360 +0,0 @@ -Sinclair ZX Spectrum Emulator 'Z80' v4.00 - 6/3/99 - by G.A. Lunter - - - -──────────────────────────────────────────────────────────────────── - -Z80 - Frequently Asked Questions - - -1 - How to print the diagram of the tape-interface - as shown in DIAGRAM.Z80, or make other screendumps. -2 - How to LLIST and LPRINT to a printer -3 - How to build the tape-interface -4 - What to do if the Zandbergen joystick doesn't work correctly -5 - How to contact the author -6 - Manic Miner and Jetset Willy run too fast! -7 - How to save a .SCR snapshot to tape or .TAP file -8 - Printing problems with Tasword 128 -9 - What to do about an IN 0 crash? -10 - I have a .TAP file, but it doesn't work -11 - Z80 complains about lack of memory -12 - 'OPENTYPE' bug of DISCiPLE/+D - -──────────────────────────────────────────────────────────────────── - - - -ad 1. How to make a screen dump on a printer - - -When the Interface 1 appeared, it was possible to attach a serial printer -to the RS232 port of the Interface 1. The emulator can redirect the RS232 -to the serial port of the PC, a file or a parallel (printer) port. - -The SamRam can make a screen-dump on a dot-matrix printer. It is programmed -for a Star SG-10. The Spectrum 128's COPY command sends its output to the -"p" printer channel, also an RS232 channel. This will work for -Epson-compatible printers. The ZX Printer's COPY output can be translated -into graphics data understandable for Epson and HP-PCL compatible printers, -and finally, the DISCiPLE has also on-board screen dump routines. - - -Example 1: Screen dump for Epson or HP-PCL compatible printers, via - the standard COPY command. - - Select the printer port to use for output with -XL 2 for example, to - select LPT2 for output. Select Epson or HP-PCL output format with -0e - or -0h. Then simply type COPY (in 48K or SamRam mode, not in 128K - mode, and neither in DISCiPLE mode; it works in +D mode though). - - -Example 1: Screen dump for Star SG-10 compatible matrix printer using - the SamRam. - - Redirect the Spectrum Interface 1 RS232 output to LPT1 by pressing F4, - O, L, 1. - Load a .Z80 file, and wait for the picture you want to print to appear. - Switch to SamRam mode by pressing F10, H, 3, CTRL-ENTER, and generate an - NMI by pressing X, N. If you're already in SamRam mode you can - simply press F5. - Press P, then 1 to print the screen. - - -Example 2: Screen dump for EPSON compatible matrix printer using the - COPY command of the Spectrum 128 - - Redirect the RS232 output to LPT1 by pressing F4, O, L, 1. - Load a .Z80 file, and wait for the picture you want to print to appear. - Save it as a .SCR screendump by pressing F10, X, S, name - Switch to Spectrum 128K mode (F9, 5, ENTER) - Choose '128K BASIC' from the menu, and type PAUSE 0:COPY, and press - ENTER once. - Press F10, X, L, name, to load the screen snapshot back into memory. - Go back to the emulator (ESC, ESC) and press any key to start printing. - - -Example 3: Screen dump for all other printers, using DOS utilities - - Follow the steps from example 2 up to the saving of the .SCR - screen snapshot. - Leave the emulator. - Run CONVERT on the .SCR file to generate a .GIF or a .PCX file, for - example - CONVERT b g screen.scr screen.gif, or - CONVERT b x screen.scr screen.pcx - Find another program that can print the .GIF or .PCX file - - -Example 4: Screen dump for Epson or HP PCL compatible printers using - the routines of the DISCiPLE - - Redirect RS232 output to LPT1. - - Switch to 48K + DISCiPLE mode (or 128K + DISCiPLE) and select the ROM - with the pre-loaded D.O.S. for Epson or HP PCL compatible printers - Type COPY SCREEN$ 1 for a small screen-dump (black/white but with regard - to colors) - Type COPY SCREEN$ 2 for an A4 dump with dithered grey-tones. - - -Example 5: Screen dump for Epson or HP PCL compatible printers using - the ZX Printer emulation and the ordinary COPY command - - At startup, use a combination of the switches -xl, -xj, -0e, -0h and - -0f to select the proper set-up for your printer configuration. These - switches are best defaulted in Z80.INI. - - Make sure the emulator is in a 48K mode, SamRam is OK, or in a 128K mode - but 48K BASIC, and make sure the Disciple is not turned on (+D is fine - though). Then, the ordinary COPY command works. - - - -──────────────────────────────────────────────────────────────────── - -ad 2. How to LLIST and LPRINT to a printer - - -There are several ways to print things. The standard ZX Printer output can -be converted to graphics output in Epson or HP-PCL format; for this, select -output port with -xl and output mode with -0e or -0h, then simply use -LPRINT, LLIST and COPY to output to the "p" stream (on 48K Spectrum or -SamRam; not on the Spectrum 128K). - -Note that (without the -xj switch) when the actual printer goes off-line or -out-of-paper or whatever, Z80 will report to the Spectrum program that the -ZX Printer is non-existent. This will prevent programs from trying to -print things - some print without being asked to. However, when this -happens during printing, Z80 will try to finish its job. The program -appears to hang, but pressing the space bar once causes Z80 to stop waiting -and report the ZX Printer as non-existent. When the printer goes on-line, -the ZX Printer will appear again. - -All output to the Interface I's RS232 channel "b" and "t" (for raw and text -output respectively; use "t" for listings) and the Spectrum 128's RS232 -channel "p", and the DISCiPLE/+D's centronics "p" channel can be routed to -the printer port, a serial port or a disk file. Thus, by OPEN #3,"b", "t" -on the 48K Spectrum with Interface 1, or OPEN #3,"p" on the Spectrum 128, -all data sent to channel 3 (i.e. printed by LPRINT or LLIST) can be routed -directly to a printer. The menu that controls this is accessed by F4, O. - -The normal ZX Printer "p" channel is automatically (by an interrupt -routine) converted into the DISCiPLE/+D parallel printer output channel. -The DISCiPLE rom's in ROMS.BIN are set to Centronics interface by default, -so LPRINT works straight away. When a +D ROM is used, POKE @11,0 may be -necessary. The +D's "p" channel can be reset to ZX Printer output by -typing POKE @11,1. In principle, this is also possible with the DISCiPLE, -but the ZX Printer port #FB is used by the DISCiPLE already, and the -emulated ZX Printer will not respond to it in DISCiPLE mode. - -The following POKE @'s are useful: POKE @6,0 to switch on control code -conversion, POKE @8,1 to have CR's converted to CR/LF's, POKE @10,0 to -switch off automatic conversion into graphics of some ascii characters. - -As said above, you have to redirect the output of the Interface 1 RS232. -As on a real spectrum with Interface 1, if you want to print to the -Interface 1 RS232, you have to open the #3 channel. In Spectrum Basic, -type: OPEN #3,"b" (or OPEN #3,"t" for basic listings). Press SHIFT-ALT 4 -for OPEN #. - -In this way you can print anything as long as your spectrum program -supports printing to the Interface 1 RS232 and your printer type, or to the -ZX printer. For example, it is perfecty possible to print a textfile on -your printer with Tasword 3, or make a printout with Art Studio. - - -─────────────────────────────────────────────────────────────────── - -ad 3. How to build the tape interface. - - -The diagram of the tape interface is in the program DIAGRAM.Z80. It is easy -to build, and inexpensive, since only passive components are used. - -If you do not want to build the interface yourself, you can order one for -BP 14.50 with B G Services. For the address, see the Registering section -in the documentation file, or the REGISTER.DOC file. - - -─────────────────────────────────────────────────────────────────── - -ad 4. What to do if the Zandbergen joystick doesn't work correctly - - -The Zandbergen joystick interface did not work at all in version 2.01. It -works properly in V3 again. Sorry to have kept you waiting so long... - -To a fully implemented pc-joystick port, two analogue joysticks can be -attached (on one plug!). A number of multi-io cards can handle only one -analogue joystick. However, the Zandbergen joystick needs a fully -implemented joystick port. If only two directions (out of four) work, your -joystick port is not usable. Use an analogue pc-joystick instead. - -The joystick port of a Sounblaster is fully implemented and ok to use. - -If you have more than one joystick port in your pc, you have to disable -one. - - -─────────────────────────────────────────────────────────────────── - -ad 5. How to contact the author. - - -Send E-mail to outletmag@yahoo.com or write a letter to - - Chezron Software - 34 Saltersgate Drive - Birstall - LEICESTER - LE4 3FF - England - -and they will forward the mail to me. - - - -─────────────────────────────────────────────────────────────────── - -ad 6. Manic Miner and Jetset Willy run too fast! - - -True. Most of the time these games are either producing sound or executing -an LDIR instruction to update the screen. Since this instruction can be -emulated with a single REP MOVSB instruction of the 8086, emulation is -suddenly very fast. Without sound, Manic Miner and Jetset Willy were two of -very few games that were actually playable on a 8 MHz PC, and of course I -don't want to slow down the emulator on slow machines! - -If you turn the LDIR emulation switch on, the LDIR instruction will behave -somewhat differently, important for well-protected programs. As a side -effect, it will then also run at the right speed. - - -─────────────────────────────────────────────────────────────────── - -ad 7. How to save a .SCR snapshot to tape or .TAP file - - -First make the appropriate choises in the tape menu, F7. Then type SAVE -"name" SCREEN$. Press ENTER, and then press F10 in the one second gap -between header and data block. When saving to tape you can easily see it; -when saving to disk, after pressing ENTER give the emulator a split second -to save the header to disk before pressing F10. - -Now load the .SCR snapshot into memory, and continue saving. - - -─────────────────────────────────────────────────────────────────── - -ad 8. Printing problems with Tasword 128 - - -Tasword 128 does not print correctly via the "p" channel; at least, my -version of Tasword 128 doesn't. The problems can be circumvented easily by -opening stream 3 for output to channel "b", i.e. OPEN #3,"b", instead of -using channel "p". A better solution is to remove the bug. Load Tasword -128, turn on Microface 128 emulation, hit NMI (F5), choose T, then H for -Hex, address 9DD3, and poke the values 01 FD 7F ED 79 32 5C 5B FB C9 into -the respective addresses (pressing ENTER twice after each value); then Q -and R. - - -─────────────────────────────────────────────────────────────────── - -ad 9. What to do about an IN 0 crash? - - -The Interface I often crashes if the 'Microdrive Data' port is accessed -when the microdrive is not running. Entering PRINT IN 0 in Basic will -usually hang the Spectrum. So, if a program reads from the 'Microdrive -Data' port when it shouldn't, the emulator lets the user know that an -ordinary Spectrum would have crashed at that point. - -Some programs did indeed crash if an Interface I was attached; JetSet Willy -is an example (just wait until it pauses, then press a key). To use these -programs, simply select the hardware mode 48K (or 128K) Spectrum without -Interface 1. In this mode the emulator won't bother about programs reading -from port 0. - - -──────────────────────────────────────────────────────────────────── - -ad 10. I have a .TAP file, but it doesn't work - - -Could be different things. The Warajevo emulator uses a tape file format -different from Z80's, but uses files with the same .TAP extension. Check -this first. Wavajevo comes with a utility to translate its .TAP format to -Z80's. - -Some programs need the R register emulation to be switched on. Some -programs will not load with an Interface 1 emulated. Some programs are -Spectrum 128K programs without saying so when loaded in an 48K machine. -Switch to 128K mode (without Interface 1 to avoid troubles there) and try -again. - -Some programs use the standard format on tape, but use their own load -routine. Because Z80 traps the ROM and does not emulate the bips and -clicks of the data, this will not work. Convert the .TAP file to a .VOC -file using TAP2VOC, and play this file back to the emulator. - - -─────────────────────────────────────────────────────────────────── - -ad 11. Z80 complains about lack of memory - - -Z80 itself suggests using -xt or -xu to reduce the amount of memory. Using --xt reduces execution speed only slightly in some situations, so if this -works, you might as well put -xt in the Z80.INI file as a permanent -solution. Most probably shelling to DOS will not work in this case, as DOS -needs quite a bit of free memory. - -The switch -xu disables Hi-res color emulation, which can be undesirable. - -Z80 needs far less conventional memory if EMS memory is present. In a -Windows (95) DOS box the amount of EMS memory available can be pre-set. -Use the PIF editor (Windows 3.1) or go to Properties, Memory, to set the -amount of available EMS memory to about any non-zero value (Z80 needs less -than 256 Kb). This will most probably solve your memory problem in DOS -boxes. - -If this still doesn't work, then most probably resident programs take up -much space and leave very little conventional memory to ordinary programs. -See your autoexec.bat file and remove unneccessary programs. If you do -need them, try using e.g. Quarterdeck's QEMM to load as much as possible -resident programs into high memory. - - -─────────────────────────────────────────────────────────────────── - -ad 12. The 'OPENTYPE' bug of the DISCiPLE/+D - - -The following two small programs explain, by example, how to OPEN files -directly on the DISCiPLE/+D system, and how to read from and write to them: - -10 OPEN #5"m";1;"Filename": REM it is assumed such a file exists -20 FOR a=1 TO 10: LET b=CODE INKEY$#5: PRINT b: NEXT a -30 MOVE #5 TO #2 -40 CLOSE #*5 - -10 OPEN #5"m";1;"NewFile" -20 FOR a=32 TO 255: PRINT #5;CHR$ a;: NEXT a -30 CLOSE #*5 - -The important thing to note here is that one should NOT write "CLOSE #5", -but include an asterix (*) between the keyword CLOSE # and the stream -number, 5 in this example. The technical reason for this is that CLOSE #5 -is syntactically correct for the standard ROM, so that no syntax error is -generated. The DISCiPLE ROM is not paged, and the closing of the stream is -left to the standard ROM. The standard Spectrum ROM routine cannot handle -any other stream than "K", "S" or "P" streams, partly because the ROM -programmers forgot to include an end marker to the table at address #1716 -(See Ian Logan, Frank O'Hara, The Complete Spectrum ROM Disassembly, page -71). - -If the asterix is left out, the (emulated) Spectrum crashes horribly. -