CCCCC CC CC CC CCCCC PPPPP PP An Amstrad CPC emulator PP PP Copyright 1991-1994 Bernd Schmidt PPPPP PP This program is public domain. You may PP distribute it freely, provided that you PP EEEEE do not charge a fee of more than DM 8,- EE EE or the equivalent in any other currency EEEEEE for copying the disk and provided that EE you always distribute the whole archive EEEEE V.4.7i including all the files. ----------------------------------------------------------------------------- 1. What is this then? This is a doc file. It belongs to a program called CPE, which can emulate an Amstrad CPC on your IBM compatible 386-AT. All files in this distribution are public domain, you may distribute them freely, but you may not charge more than a fee of DM 8,- for copying. You must preserve the original contents of the archive, you may not modify any of the files, you may not omit or add files if you distribute the package. There is no warranty on any of the included programs, you use them absolutely at your own risk. The author refuses to accept any responsibility for any damages whatsoever you or your computer system, or in fact anything may take from using any of the supplied programs. Be warned that you COULD in fact damage your monitor if you are careless!! Do not press F2 without reading this manual first! None of the programs or data supplied may be used for military purposes. I doubt that they CAN be used for military purposes, but anyway... If you don't agree with these terms, delete everything and forget about CPE. But you will miss a lot... Mind you, this is freeware, not shareware. I am not asking you for any payment, so don't send me money. But do write me if you like this program! Any comments, suggestions or bug reports are highly welcome. Share and Enjoy! und nocheinmal auf deutsch, damit niemand sagen kann, er haette die Passage nicht verstanden: Benutzung der Programme auf eigene Gefahr, der Autor uebernimmt keine Haftung fuer irgendwelche Schaeden, die durch die Benutzung des Programms entstehen, sei es durch sachgemaesse oder unsachgemaesse Verwendung. Druecken Sie nicht F2, ohne vorher diese Datei gelesen zu haben, Sie koennten Ihren Monitor unter Umstaenden beschaedigen. Um dummen Fragen vorzubeugen: Nein, auf dieser HP-Workstation gibt es KEINE Umlaute. 2. General information 2.1. The Amstrad CPC family A couple of years ago 8 bit homecomputers were very popular. The best seller among these was the Commodore 64, but another family of computers was also very successful in many countries. These were the Amstrad CPCs (they were distributed under other names in some countries, e.g. you may own a Schneider CPC if you live in Germany). There were three different models: - The CPC464. Released in 1984; it had 32K ROM, 64K RAM and a built-in cassette recorder, sitting next to the keyboard. The ROM included the Amstrad operating system and Locomotive BASIC 1.0, which was very good. You could buy external floppy drives, the one sold by Amstrad used 3-inch disks, which were incredibly expensive, since no other computer manufacturers used these for their own systems (apart from exotic models like one called "Einstein", for example). There were a couple of companies which sold floppy drives using 5.25-inch and 3.5-inch disks, but these never were of much importance. Included with Amstrad's disk drives was the at that time still very widely used disk operating system CP/M 2.2, so that many applications became available for the CPC; only the disks did not fit in the 3" drives... - The CPC664 was the next step in the development. It no longer had a cassette recorder to the right of the keyboard, but a 3" floppy disk drive instead. The operating system and BASIC ROMs were a little improved, BASIC now had a few extra commands and the version number 1.1. The 16K floppy ROM was of course already present, so that this computer had a total of 48K ROM. It was released in mid-1985. - Only a couple of months later, Amstrad presented the CPC6128. It was basically a CPC664 with the double amount of RAM: incredible 128K! There were minor changes in the ROMs, but the increased amount of memory was in no way supported by BASIC. To use it, you had to load special banking software from disk. Amstrad also supplied a new version of CP/M: CP/M Plus or 3.0, which could use the extra memory, so that the problems some programs had with the limited memory of the older models were history. After the release of the CPC6128, production of the CPC664 was abandoned. The differences between the systems are small compared to the features they all have in common: - the processor: a Zilog Z80A, an 8-bit CPU running at 4MHz, derived from INTeLs 8080. - the video chip: a Motorola CRTC 6845. Together with the Gate Array it is responsible for the generation of a video signal. The CPCs knew three video modes: mode 0: resolution 160x200 pixel, 16 out of 27 colors + border mode 1: resolution 320x200 pixel, 4 out of 27 colors + border mode 2: resolution 640x200 pixel, 2 out of 27 colors + border Needless to say, most games used modes 0 and 1. - the sound chip: An AY-3-8192; with three independent sound channels, and one noise generator. The same chip was later used in the Atari ST computers. Some mean people say it has FOUR noise generators. - the memory management: Although the Z80 CPU only has a 16 bit address bus, thus being merely able to address 65536 bytes of memory, you can (in theory) use hundreds of kilobytes of RAM and even thousands of kilobytes of ROM. This is made possible by the gate array chip, which implements RAM- and ROM-banking in the CPC. The 64K that are seen by the CPU are divided into 4 blocks of 16K each, and by programming the banking registers you can make the Z80 access different blocks of memory at the same address. So, the highest memory bank (addresses C000-FFFF) usually contains the video RAM, but you can als access the BASIC and floppy ROMs at the same addresses. - All models were only sold together with a monitor. You could either choose a color monitor (CTM 644) or, if you did not have THAT much money, a green monitor (GT65). These were not just monitors, they also included the mains adaptor. The CPC464 received its 5V supply from the monitor, the two later models also needed a 12V supply for the floppy disk. It was a very effective way of preventing the users to buy other monitors than those manufactured by Amstrad. - There was similar trouble with the printer port. Instead of fitting the usual 8 bit Centronics port, Amstrad invented something a LOT more useful: The 7 bit Centronics port! It was just another way to prevent users from buying external devices from other companies than Amstrad, since Amstrad alone built 7-bit printers. But Amstrad had less success here than in the case of the monitor; many users owned Żalien® printers. - the joystick port: Amstrad also produced joysticks, and of course they did not want CPC users to buy other (better) joysticks than their own, so they fitted the CPCs with only one joystick port instead of two. To use two joysticks, you had to plug an Amstrad joystick into the computer and plug the second joystick into the first - it was the only joystick ever with a built-in joystick port! 2.2. The emulator This is version 4.7i of the emulator; the i means INTeL. In fact, you get two emulators with this version, one is called CPE.EXE and the other one is called CPE2.EXE. If you have a fast machine (>=486DX2-66) you probably want to use CPE2.EXE, which can run at the exact speed of a real CPC and supports graphics a lot better (especially when it comes to multi-mode multi-color effects that many demos and games use). For programs using the high-res mode 2 of the CPCs, you probably want to use CPE.EXE, as CPE2.EXE always uses the 256 color 320x200 VGA mode and has to shrink two pixels into one when emulating a 640x200 screen. The algorithm which does this is not too dumb, so you can read text in mode 2, but it doesn't look terrific. There is also an Amiga version of CPE, but it is quite a bit less developed and is not going to be improved unless many people ask for it. I have released this one including source, so maybe someone else will work on it. 2.2.1. Hardware requirements You need: An IBM compatible AT with a 386 (or higher) processor, a VGA card, at least a diskdrive (better a hard disk), a keyboard, a monitor, ... If you have a Soundblaster or compatible sound card (possibly AdLib as well) you can also emulate the CPC sound. The beeper is not supported. Buy a sound card instead! For CPE2.EXE, replace 386 with 486DX2-66 and FAST video card... it runs on a 386, but you wouldn't want to use it. 2.2.2. What can it do? CPE can emulate all three CPC models on your PC. In fact, it always emulates 6128 hardware, but this will NEVER cause you any trouble. Which model you get is determined by the contents of the ROM files. More about that later. All hardware features are emulated more or less exactly. Of course, some things cannot be duplicated exactly on a totally different system. The PC's keyboard layout differs from that of the CPC keyboard, so you may have some trouble finding some keys when you start using CPE. More difficult to emulate is the video chip, you may only see trash when you try exotic screen formats used by some games, although this is much less likely to happen if you use CPE2.EXE. The sound chip's noise generator is not emulated correctly on a Soundblaster, it always generates noise of the same frequency. And finally, in CPE.EXE the Z80 instructions are not timed accurately - the faster your PC is, the faster the emulator will run CPC software. On a 486DX2-66 (my configuration), you get a CPC running at about 15MHz, on a 386DX40 you will have more or less original speed. There is an option that makes the system slow down to what is supposed to be the original 100% CPC speed, but it is not too exact. If you want really exact timing, get a fast computer and run CPE2.EXE. 2.3. Usage First of all, explode the archive into a directory called CPE. You will need some other directories as well: CPE\ main directory for executables CPE\ROMS for the ROM files, see below CPE\SNAP optional, for snapshot files CPE\TAPE optional, for tape support CPE\DISKS optional, for disk support This was the directory structure in V4.5. As of 4.6, there are a few other directories that you can optionally use: CPE\DISC for CPCEMU style .DSK images CPE\ROM for CPCEMU style .ROM files If you have CPE\ROM, you don't need to have CPE\ROMS and vice versa. Thus, if you already have CPCEMU, you can simply copy CPE into your CPCEMU directory and use all the files that are already there. .DSK files are currently emulated only write-protected. If you want to do any "real" work, you have to use uncompressed .CPD diskfiles. More about disk images in a later section. The second step is to run CPESETUP. This program enables you to adjust certain parameters to fit your system. There are several options (most of them require a hex number in 0x?? (C) format, or a yes/no decision). Options marked with an asterisk (*) have no meaning for CPE2.EXE, as this program handles graphics quite differently. - Soundblaster delay: Ignore this, if you do not have a sound card. Otherwise, you can experiment a bit. 0x23 is the "official" value which should work on any system, but if you set it lower, sound emulation may become faster (and even better). If sound does not work, try setting this higher. -*overscan graphics mode: many CPC programs use non-standard video modes with more than 200 lines. To show them in full, you can not use a standard VGA mode with 640x200 pixels, but have to switch to a mode with more lines. There are two possibilities. On every VGA card, you should be able to use mode 0x10 with a resolution of 640x350 pixels. If you have a SVGA card, you might use the 800x600 (16 colors) mode, which usually has a mode number of 0x6A. But you have to consult your manual for this information. 800x600 looks better (geometry is more exact) -*line doubling: switch this on if you use 800x600. It will change the resolution to 800x300, which fits the CPC's picture geometry far better. Switch it off if you use 640x350. - Soundblaster installed and - Use Sound: These two options decide whether sound emulation is turned on or off. Always turn sound off if you do not have a sound card. It probably will not harm your system, but it will slow down the emulation. - Soundblaster base address: This is usually 0x220. This value can be changed in the configuration of the sound card. Enter the correct value for your system, or you will not hear a thing. You might even cause damage, e.g. if another card uses this port address. - Printer port LPTx: For printer emulation, set this to the appropriate port where your printer is connected. Usually, this is LPT1. - Screen refresh frequency: This one affects CPE2.EXE only. If you set this to a higher value, the screen will not be redrawn 50 times a second, but in longer intervals. Animation and scrolling will therefore not be as smooth, but the emulator will run faster. Exact graphics animation will require this value to be set to one (meaning: draw the screen always), but this may slow down the emulation. On a 486DX2-66, you will probably be able to set this to one most of the time, and to two if the emulator runs slowly. - CPC model (464,664,6128): only effective if you use the CPCEMU style ROM directory. CPE will then load the appropriate ROM on startup. - Use EMS: Forget about this one if you don't use 6128 RAM banking and everything else works perfect. If CPE won't run, try disabling this. RAM banking is going to be a lot faster if this is enabled. In CPE2.EXE, EMS is always disabled, because of certain problems. -*Screen length in display mode 2: This allows you to fine-tune the 50Hz display mode that CPE offers. Since different graphics cards have different timing (they shouldn't have :-( ) you may have to experiment a little here. Get a program that displays colored stripes (I might include one in a later version of the emulator), and see if they are stable when you activate 50Hz mode (but read about the necessary precautions in this manual before you do!) If they are scrolling upwards, try setting this value higher (at least, I think you have to set it higher, but this ALWAYS confuses me.) -*Permit word access to video RAM: Turn this on experimentally and try to scroll the screen after starting the emulator. If the picture looks normal, leave this switch on. This works on OAK VGA cards, but probably on nothing else, since it requires a non-standard feature of these cards (16 bit latches). - Use german keyboard layout: Don't activate this for REAL emulation, but I think this is useful if you can accept minor differences between CPE and your CPC. -*More than 512K video RAM: Actually, it has got little to do with the size of your video RAM. Activate this if the VGA scrolling (see Options section for more information) looks broken. - Calibrate joystick: Joystick support may work in this version, or it may not. You can try it, it's improved, but it still has some problems. Before you activate joystick support, you must calibrate your joystick, because every PC joystick behaves differently. Follow the instructions on the screen. You can't use joystick support together with the joystick keys. Then you can start CPE - and it will exit immediately. Something important is missing: The ROMs! I can't include those in a freeware distribution, since they are copyrighted by Amstrad. I have asked for a written permission, but have not received one yet, so I am not going to include them. I have EMAIL permission to include the ROMs, but I don't feel comfortable about this. Sorry. But they have been made available on ftp by people more courageous than me. As mentioned above, you can use your CPCEMU ROM files for CPE as well. If you can't get the ROMs anywhere else, you have to transfer them yourself from your CPC to the PC. This is no easy task. You have to build a cable to transfer data and write transfer software for your PC and CPC. I am unable to help you with this, since I transferred the data from the CPC to my Amiga, and it is impossible to use the same cable with a PC. Instead, you might transfer data via a 5.25" disk drive connected to your CPC and special PC software to read disks written by the CPC. But all this requires some experience, which either you or a friend of yours must have to transfer ROMs and other software successfully. The emulator needs three files in CPE\ROMS: one called LROM, one called UROM and one called ROM7 (floppy ROM). Yes, it could be made to work without the last one, but if you manage to transfer the other two, you won't have trouble transferring ROM7 as well. Alternatively, use the CPCEMU \ROM directory with the files CPCADOS.ROM and CPC????.ROM. 2.4. When running the emulation... there are a couple of special keys to press. Again, those that have no effect in CPE2.EXE are marked with an asterisk: F1 will load a snapshot file from CPE\SNAP * F2 will toggle the video mode. ********************************* CAREFUL !!! *************************** Check your monitor's manual to see if it supports 50Hz refresh rate. If it doesn't (e.g., some NEC monitors can only display modes with refresh rates >=55Hz), you should NEVER press F2. If your monitor supports 50Hz, this option can be helpful for some games which use special tricks to display more than 4 colors in mode 1. If the colors flicker wildly on your screen, try activating the 50Hz mode F3 will save a snapshot file to CPE\SNAP. You will be prompted for a name. Sorry about the poooor input routine. F4 does not do ANYTHING (try it! :-) F5 will hard-reset the emulated CPC F6 will show you a directory of CPE\DISKS, you can move and select one diskfile, which will be inserted into the emulated drive A. F7 show you an OPTIONS screen. More about that later. * F8 toggles interrupt speed. You are only remotely in danger to need this if you are running CPE on a machine <=386DX-40. Otherwise, please ignore this key. (e.g. ELITE is a candidate that crashes slow machines if the interrupts come too fast.) * F9 scrolls multimodes. This MIGHT help for some software. But then, most likely it will not help. If CPE doesn't get the multimodes right at once, it probably never will. Multimodes are QUITE difficult for the emulator using the current display method, so don't be angry if it does not work at all for some programs. F10 exits. You really don't want to press that key. 2.5. The OPTIONS screen It is unlikely that you will need all of these options. Some of them are left in only for historical reasons. Experiment with them if you encounter graphics problems, sometimes it might help. Some of these options can also be set up permanently in CPESETUP. I am not going to describe those again. Here is a list of the remainder, those that are not present in CPE2.EXE... you know. *- Realtime CPC: This TRIES to keep the speed at exactly 100% of a real CPC. It is far from perfect (I am not sure about what to do for LDIR, for example). It does not time single instructions, instead, it adds up cyles, and if the right amount is reached, it just waits for the next interrupt to occur. So, if your program only needs to work at exact speed in 300Hz intervals, you are lucky, if your program uses nasty timing loops to do "copper" color effects, then you will not enjoy this. The cassette save routines would not work this way if redirected to a soundblaster/cassette deck combination. They need to be timed exactly at instruction level. You need a fast machine for this option. On a 486DX2-66 it works, it might also work on a 486DX-40, but for everything below I am pretty pessimistic. *- Frame fly asynchronous to vertical retrace: Err.. I think I forgot. As I said, experiment with these. *- Clear frame fly bit after read: If joystick cursors are way too fast or similar things happen, try this option. *- Permit double buffering: Some CPC software uses two memory banks to do a double buffering effect. If this option is enabled, the PC tries to do the same trick in VGA memory. Usually, it succeeds, and is a LOT faster than without. *- Double buffering, exchange pages: A hack. Use if your double-buffering software looks like it always shows the wrong page. Unfortunately, timing differs between VGA cards and CPCs, so this is sometimes needed to display the right screen page. *- Redraw scrolled areas: Disable this only if you are desperate for speed and do not mind to see junk in some screen areas (but, for some programs, it even works O.K.!) - Green monitor: I had to. :-) - Noisy sound: Activate this if you don't mind that the CPC's noise generator is not emulated perfectly. It might sound O.K., but sometimes, it is horrible. In CPE2.EXE, you also have the option - Wait for FFLY: Activating this will keep the speed at 100% of a CPC, or below. If this is deactivated, CPE2 will run faster, which might be an advantage if the program is too slow otherwise. But if you have a fast machine (>=486DX4-100, probably) there's not going to be any need to deactivate this option. Another way of speeding the program up is to disable the sound emulation, which is enormously time-consuming in some programs. You can also select a lower refresh rate in CPESETUP. 3. Technical information is not included in this manual. A rather large text about the internals of CPE is on Kevin Thackers WEB page (look in chapter "Pointers" to find out the address). Let me only say something about 3.1. File formats If you are already using Marco Vieth's CPCEMU, you will want to use your software with CPE as well. For tape files, there is no problem. Just copy these to CPE\TAPE. Same for snapshots, they go to CPE\SNAP. Currently, CPE does not support 128K snapshots. The ROMs are (almost) the same, CPCADOS.ROM from CPCEMU must be moved to a file called CPE\ROMS\ROM7, you must split CPC464.ROM (or CPC6*.ROM) in two halves and call them LROM (first half) and UROM (second half), both in CPE\ROMS. The diskfile format is completely incompatible, but I have included a program called CONVDISK.EXE which will do exactly what it says: Convert diskfiles. So, there will be no problems using your old software. 4. Final words... 4.1. Thanks and acknowledgements (in no particular order) to... - Amstrad for developing the CPC in the first place - Marco Vieth for providing me with software, bug reports and his own CPC emulator called CPCEMU, which is very good. It is also available as freeware, so try to get a copy. - Kevin Thacker, for making an excellent WEB homepage for Amstrad computers. - Emmanuel Roussin for sending me the FAQ. - Herman Dullink: for sending me his CPC emulator. - Zilog, Inc. for LOTS of undocumented opcodes. - Charlie Gibbs, who wrote a CP/M emulator for the Amiga. This emulator first made me think about writing a CPC emulator, and I derived some basic ideas from it. - everyone whom I've forgotten. 4.2. The author crux@pool.informatik.rwth-aachen.de or: Bernd Schmidt Schlossweiherstrasse 14 52072 Aachen Germany Contact me! If you have comments, bug reports, ideas for enhancements, or anything interesting, let me know! I can't promise that I will answer your letters, but I will do my best. Excuse me if I have insulted you with my English. It should not be too bad, but it's my second language, so this text is bound to contain mistakes. 4.3. Other emulators I have seen three emulators besides CPE. CPCEMU, which was written by Marco Vieth, is a very nice piece of software. It can do less to support eccentric video modes (although this has been improved in V1.2 by introducing multimodes), but it is usually a good deal faster than CPE. It is very useful to have both emulators, since it depends on what software you use which one is more suitable. Another very promising emulator is currently being developed by Herman Dullink. It's still in beta stage, but it is very fast and already quite compatible. I should expect a release version here relatively soon. The last one I have seen works, but that is about all you can say about it. It is called SIMCPC, features black and white graphics and does not run properly on fast machines, the poor thing. It is not of much use. There is allegedly a fifth one somewhere on the net, but I have yet to find it. 4.4. Todo This is my todo list, sorted from most probable that it will ever get done to least probable: - find the remaining bugs - fix the small timing problems that are left in CPE2.EXE. - emulate ALL of the CRTC capabilities in CPE2.EXE. This is going to be a lot of work. - speed the thing up - make a Linux version - finish my Amiga emulator for Linux under X - write a better .DOC file 4.5. Pointers If you have Internet access, you may want to check out the following: - There is a newsgroup for Amstrad 8 bit computers, it is called "comp.sys.amstrad.8bit". Information about new versions of CPC emulators and other interesting news are posted here. Maybe you'll also want to look at comp.os.cpm. But this is not Amstrad specific. - ftp.nvg.unit.no:pub/cpc sunshine.informatik.uni-wuerzburg.de:pub/joscho/cpcemu ftp.ibp.fr:pub/amstrad ftp.demon.co.uk:/pub/cpm oak.oakland.edu (or any SimTel mirror):SimTel/msdos/emulator All these are ftp sites that might me of interest if you are interested in CPC related stuff. On SimTel, you'll find the latest version of Marco Vieth's CPCEMU. The Wuerzburg site mirrors ftp.nvg.unit.no and has CPCEMU12.ZIP as well. - http://www.cm.cf.ac.uk/User/K.E.W.Thacker/Amstrad/index.html An *excellent* home page with loads of technical information. If you want to write an emulator, this is the place to look at. In fact, I just looked there again, and noticed that up to this minute I had NO idea what the CRTC is capable of. Seems like there's more work to do... ˙