ASCD

Author
Description
Last released version 1.6 in 2023.
http://www.keprt.cz/progs/#sam
Hardware requirements
There are almost no requirements. ASCD is written in C++ and compiled with Visual Studio 2005 and it can run on Windows 2000/XP/Vista/7/8/10. (Windows 11 was not tested.) It uses standard soundcard if a soundcard is present. The current version is intended for nowadays computers (old versions prior 0.98 run well on very old slow computers with low RAM). Minimum requirement is DirectX 6 (which is always present in all Windows), and DirectX 9 is recommended for better display with 3D acceleration.
Emulator display is always prepared in 640x240 pixels and then it can be rendered on screen in various ways. For old computers with old Windows and CRT monitors, the best is to switch physical display resolution to 640x480 and use DirectDraw with hardware-accelerated blits. But this is not good for current computers and later Windows, because flat display panels prefer to keep the same resolution and new Windows have problems with 2D graphics (it is slow, because Microsoft with Nvidia removed the support for 2D acceleration). It means for all computers since ca. year 2010, it is better to keep the same resolution and use Direct3D to display the image in the center of it. ASCD always do pixel-exact rendering, it means it zooms the image only to a whole multiple of the original resolution. (For example, if your display is 1920x1080, the image is displayed as 1280x960 with small black border above and below and a bigger black border on both sides.) A special exception is there for modes like 1280x800 or 1024x768 which are too small to display the whole zoomed image, but they can nicely display the whole "paper" area with a reduced or no border around. This solution is preferred, because otherwise the image would be very small in the center. The same is also done on bigger displays with resolutions above 1600x1200 etc. where the image is zoomed 3-times.
What is emulated
ASCD was originally written as a Sam Coupé emulator. Later, ZX Spectrum and ZX Spectrum 128 support was added. The CPU timings aren't 100% perfect, as those computers are different, but here they share the common Z80 CPU emulation core. You can select emulation mode with generic command line switch -zxmode, with specific command line switches -zx, -128 or -sam or in the main menu.
Sam Coupé mode
You can select Sam Coupé mode with -zxmode 0 or -sam switch or in the main menu. Emulated features are:
- Main memory 256 KB or 512 KB (-sam512/-nosam512)
- External memory 0-4 MB (-extmem 0/1/2/3/4)
- All graphics modes are supported in all known bitdepths and bit combinations of Windows desktop from 1 to 4 bytes per pixel
- Graphics is emulated per scanline, so text in border and similar effects are not visible
- SAA1099 sound (always on, output is 44100 Hz 16-bit stereo)
- Beeper bit audio with line accuracy (15625 Hz 1-bit mono)
- Sam mouse (-mouse 0/1/2 - the number 1 or 2 selects horizontal resolution of mouse)
- Two floppy disk drives (always on)
- Loading files from tape files (.tap and .tzx files are supported - can be selected from menu or entered on command line without switch)
- Saving files to tape file (-tape <file> selects filename where to write)
- Printer on parallel port (-printer <file> selects filename where to write printer output)
- Joystick is emulated using cursor keys and Ctrl key on PC keyboard, kempston joystick also supported
Note that ASCD supports digital speech on beeper bit and also external DAC with the scanline accuracy 15625 Hz. Also, both SAA1099 and ZX Spectrum's AY8910 audio can be used in Sam Coupé mode, but not all together. See more details below (or just go and try it).
ZX Spectrum mode
You can select ZX Spectrum mode with -zxmode 1 or -zx switch or in the main menu. Emulated features are:
- Always 48 KB memory (16 KB model not supported)
- Beeper bit audio with line accuracy (15625 Hz 1-bit mono)
- AY-3-8910 is always enabled even in 48 KB mode
- Fuller Box AY audio (always enabled, until program starts to use DAC on the same port)
- 3x8bit DAC audio using IC8255 (15625 Hz 8-bit stereo)
- Sinclair ZX Printer (graphics printing to printout.bmp file)
- Kempston/Sinclair/Cursor/Fuller joysticks are emulated using cursor keys and Ctrl key on PC keyboard
Note that the Fullerbox AY and 3x8bit DAC use the same output ports. This means that these two devices can't be used together. ASCD always starts in Fullerbox mode, and switches to DAC as soon as it detects that the running program uses the shared ports for DAC output. The emulation is switched back to Fullerbox mode on next reset. This way users can use both Fullerbox and DAC and don't need any manual configuration.
ZX Spectrum 128 mode
ZX Spectrum 128 is very similar to the original ZX Spectrum. The emulation is very similar as well, there are just a few new features in 128K mode. You can select this extended ZX Spectrum 128 mode with -zxmode 2 or -128 switch or in the main menu. Emulated features are the same as in ZX Spectrum mode, plus the following:
- CPU runs a bit faster and video synchronization is little bit different too
- 128 KB memory and paging, including video paging
Many games provide nice AY music even in 48 KB mode. That's why the AY emulation is always on even in 48 KB mode. Also, the paging disable bit of ZXS128 is ignored, and paging is always enabled when you run the emulator in ZXS128 mode. When you switch the emulator to ZXS48 mode (-zxmode 1 or -zx), then paging register is not available, memory is fixed to 48 KB, but AY audio is still available.
Note that ASCD supports digital speech on beeper bit and also external DAC, but not on AY-3-8910. AY's output is updated 50x per second, beeper bit and DAC are updated 15625x per second. (You can try MQM5 demo to hear the difference.)
Emulation of ZX80 and ZX81
ASCD does not emulate ZX80 or ZX81, but a sister project called Alyx81 exists which does exactly that.
Supported fileformats
ASCD supports several fileformats, and also brings some new fileformats where no standard fileformats do exist.
- .ZIP archives - other files (see below) can be inside ZIP archives (all ZIP-compressed files are read-only)
- .Z80 snapshots - all versions can be loaded (48 KB / 128 KB mode, compressed or uncompressed), 48 KB version can be saved
- .SNA snapshots both 48 KB and 128 KB versions can be loaded and saved
- .TAP tape files in both ZXS and Sam Coupé mode, both loading and saving (emulated using ROM hooks)
- .FUX snapshots from Fuxoft Emulator on Sam Coupé (you can load them and convert them to a standard .Z80/.SNA file)
- .DSK/.MGT disk image in Sam Coupé mode, both read and write
- .SAD disk images in Sam Coupé mode, both read and write, can be .GZ packed
- .SCS snapshots in all emulation modes (this is a new snapshot file format of ASCD)
- .HDF harddisk images for Atom / Atom Lite emulation in Sam Coupé mode
- .AIR keyboard input recordings can be written and played back (ASCD 0.98 uses a new OpenAir library with a new .AIR file format version)
- .BMP SCREEN$ files can be saved from the emulator in all modes
Note about TAP files on Sam Coupé: Sam Coupé has very advanced tape routines in ROM which support some features not present on ZX Spectrum. In order to keep the standard TAP file format on Sam Coupé, I had to solve one particular problem: Sam Coupé can have files larger than 48 KB in one uninterrupted tape block, but this is not possible in a regular TAP file. ASCD currently limits the file size on a tape to 65533 bytes, which is the maximum size possible in a standard TAP file. The resulting file is still a 100% standard TAP file and can be loaded on ZX Spectrum 128 using some 128KB copiers with paging support. You can test TAP files in Mr.Copy+ copier program, which is directly supported in ASCD (there is a special Mr.Copy+ hack in ASCD which make it work even without any low level EAR/MIC bit emulation).
New .SCS file format is fully documented, you can find the latest documentation version here.
OpenAir recording
OpenAir library is an open implementation of older famous AIR input recording system. The main difference between AIR and OpenAir is in encryption: AIR was intended for computer game tournaments and used a multilevel encryption system, the file format was closed, and the software was quite complicated. The new OpenAir library supports the same application programming interface (API) but uses new unencrypted simple file format.
AIR files record keyboard, and possibly digital joysticks, but not mouse. You must control the input recording from command line: -record <file.air> starts the emulation in recording mode. You must also specify the name of disk image or snapshot or tape as another parameter. Name of the disk/snap/tape file is stored to AIR file, so you can replay the recording later using the switch -playback <file.air>.
Audio-video recording
One of the features newly introduced in ASCD 0.98 is the ability to record audio-video to an AVI file. It is strongly recommended to install a good video codec prior to the video recording, because there is a 2.0 GB size limit on standard AVI files. (ASCD uses WfV library in Windows API to write AVI files and the 2.0 GB limit is in Windows.) Actually, ASCD can write up to 4 GB to a single file, but some players and editors won't be able to read it correctly.
The #1 codec for ASCD is SCLS, the #2 option is MSUD. Both these codecs are lossless, so they provide the best image quality. SCLS is superior to MSUD, because it is faster and has a significantly higher compression ratio. These two codecs and can be obtained at Moscow State University. (Enter MSU SCLS codec to Google, or click here: SCLS MSUD.) If neither of these codecs is present, ASCD tries to use MJPEG codec. MJPEG is a codec used by many personal camcorders, it is a native format on DV digital video cassettes. But MJPEG codec is usually not free. You need to obtain VfW codec (not DirectShow). I successfully tested ASCD with Morgan MJPEG codec, it is just necessary to set compression quality to 100%.
AVI video recording must be started from command line using switch -writeavi <file.avi>. Video is always recorded in resolution 320x240, it always contains the border, and it is compressed if a suitable video codec is found. Codecs are tried in this order: SCLS, MSUD, MJPG. If neither of these codecs is found, the video is written in RGB24 uncompressed form and you can record only 5.5 minutes of gameplay. Audio is always recorded in 44100 Hz stereo, even in ZX Spectrum mode (where audio is mono), and it is always compressed by Microsoft ADPCM codec. This audio codec is always present in Windows, so you don't need to install anything. The audio bitrate is always 384 kbps.
You should be able to replay AVI's created by ASCD in any standard video player. Successfully tested were: MPlayer and its clones, Media Player Classic, also VirtualDubMod editor work perfectly. The SCLS and MSUD aren't supported work in VLC player.
Quicksave/Quickload
Another interesting feature introduced in ASCD 0.98 is the ability to do a quicksave/quickload. The saved files reside in quicksave directory, so you can find them in there and make a copy of one particular quicksave if you wish, but the main goal of this feature is to let you play easily many games, because you can reload the game when you die etc. In other words, the quicksave feature is like rewinding the game to a prior point in time. :-) This powerful feature can be also combined with -record switch to record the game. ASCD record the optimum best gameplay, i.e. it skips all parts which you "rewind" by quickload. :-)
By pressing F9 Quickload button multiple times in 3 seconds, you can go further back in history. The "history" of quicksaves is deleted on emulator exit.
Advanced options
ASCD was originally controlled by command line switches only. Later an INI file was added. Now some options can be also controlled from a standard Windows' main menu, but not all. Some advanced options must be set in ascd.ini or can be set using command line switches. Command line uses the same set of switches as ascd.ini file, you just need to add - in front of it. (For example you write zxmode 1 in ascd.ini, but you write -zxmode 1 at the command line.)
Also note that some special command line switches aren't saved to ascd.ini and must be always entered on command line. You can see the list of all supported command line switches in menu Help - Command Line Switches.
Note that on the original Sam Coupe keyboard there are keys F0 to F9 in place where a PC has the numeric keypad. Beacuse of that Sam Coupé's F-keys are emulated with PC's numeric keypad. It means that if a program says "press F1", you need to press numpad-0, not F1. Real PC F-keys are used to control some emulator's settings on the fly. Also note that these keys can change from version to version. You can see the list of control keys in menu Help - Keyboard shortcuts.
Hardware Devices
Keyboard
Keyboard is emulated including special keys on PC keyboard. There is also a special code for handling CapsLock key, because that key is problematic on some hardware.
Joystick
Original MS-DOS version of ASCD supported real digital joysticks (those same joysticks as used on real ZXS/Sam), but this is not possible in Windows, so joysticks can be emulated only with a keyboard. Arrow keys + right ctrl are used for this purpose. You can press F8 to swich joystick emulation mode (it switches between Cursor and Kempston joystick in ZXS mode; it turns on/off Kempston emulation in Sam mode). You can also use autofire option on this pseudo-joystick. Press Ctrl+F8 to turn autofire on/off, you can also use command line switch -autofire to set it to a different speed.
You can select other joysticks (other than Kempston and Cursor) in configuration file. Note that Cursor and Fuller joysticks aren't supported in Sam Coupé mode.
Disk drives
Two standard floppy disk drives are supported in Sam Coupé mode. They are always connected. You can use DSK/MGT and SAD disk images, they also can be GZ or ZIP compressed. Note that ZIP-compressed files are read-only, while GZ-compressed files are also writable.
Tape
Tape emulation is available in all modes, including Sam Coupé, and is always on. It is implemented with ROM-hooks, which means that custom loaders and copy-protected tape images are not supported. (There are some exceptions to this, as some custom loaders do work because they use some ROM code.)
Tape files TAP and TZX can be loaded, these files are always read-only (i.e. never modified). You can also load GZ or ZIP compressed tape files. If you SAVE something to tape, it is written to a new file tape.tap in the current directory. If that file already exists, new content is appended at the end of it. (Name tape.tap can be changed in configuration file.)
Printer
ASCD emulates printers but it doesn't print on real printers. Instead, it saves the print output to files.
Standard parallel printer is emulated in Sam Coupé mode, and printed text is saved to printout.txt file. When a program uses graphic output, it is saved to that output file as a plain sequence of bytes without further processing. Sam Coupé printer is emulated on port level, so all programs work, not just ROM.
Sinclair ZX Printer is emulated in ZX Spectrum 48/128 mode. This is a graphics printer and its output is saved to zxprint.bmp file. It is saved as a monochrome (black on white) image, always 256 pixels wide. The ZX Printer is emulated on port level, so all programs work, not just ROM.
Memory
ASCD was designed in simplicity of usage in mind, so the ZX Spectrum memory is always fixed to 48/128K and no configuration is needed. When you are in 128K mode, the page-disable bit is ignored, so you can always switch to 48K Basic and get back to 128K mode even without reset. Sam Coupé can be configured in more detail. You can select 256K or 512K mode with -sam512/-nosam512 switch. You can also configure fast external memory in Sam Coupé mode with switch -extmem <num> where num is number of external megabytes (0 to 4). This external memory is always connected from higher banks to lower in order to let it be compatible with Master DOS.
Note that memory contention is emulated only partially and all emulated computer models share the same memory speed schema.
Audio emulation
ASCD emulates standard beeper of ZX Spectrum and Sam Coupé, AY8910 soundchip of ZX Spectrum 128, SAA1099 soundchip of Sam Coupé and also 3-way DAC based on IC 8255. AY and SAA cannot be active at once, because it would cause unwanted degradation in audio volume and sound quality due to limited bitwidth for each of it when both are active but unused most of time. Instead of this, ASCD keeps only one of these soundchips active at a time, and switches between them as needed.
Sam Coupé starts in SAA mode and switches to AY mode as soon as it detects significant activity on AY port. It goes back to SAA mode after reset (F12).
ZX Spectrum 48/128 starts in AY mode and switches to SAA mode as soon as it detects SAA port 28 is set to 1 on SAA ports 1FF and 0FF. It goes back to AY mode after reset (F12). It also goes back to AY mode after OUT FFFE,FE (bits D4-D7 are set, other bits ignored, as used by Russian soundcards). Note that Fullerbox AY ports can be also used to control the AY soundchip.
3x8bit DAC on ports 31,63,95 is normally off. It is activated with OUT 127,128 and when it is activated, beeper bit emulation is off until next reset. Both of these devices has sampling accuracy approximately 15625 Hz. AY and SAA cannot be used for digital music output, only beeper bit and this 3x8bit DAC. This device shares the same ports as Fullerbox AY audio. Fullerbox is normally on, it is switched off when DAC is active, and it's switched back on after next reset (F12). You can try this nice DAC for example in demo MQM 5.