vbSpec Frequently Asked
By Chris Cowley, Grok Developments Ltd.
Last Updated: 25/Aug/2002 -- Covers vbSpec version 1.50
Q1. What is vbSpec?
vbSpec is a program that runs on Windows 95/98/Me, Windows NT/2000 or Windows XP, and emulates a Sinclair ZX Spectrum computer (both 48K and 128K models are emulated, as is the Timex Colour TC2048). The ZX Spectrum is a simple, beautifully-designed little computer based around a Zilog Z80A CPU running at 3.5MHz. It was hugely popular in the 1980's, and has a strong and dedicated following to this day. Very unusually for an emulator, vbSpec is written entirely in Visual Basic.
Q2. Why on earth would anyone want to write an emulator in Visual
There are lots of reasons why you wouldn't want to write an emulator in VB - the lack of any bitwise rotation operators means that relatively expensive (in terms of CPU time) integer division and multiplication has to be used instead of simple bit-shifts, there's no unsigned 16-bit integer type in VB which is inconvenient when it comes to emulating a Z80, VB is not very portable, and perhaps most importantly of all:- even compiled, optimised VB code calls DLL routines for many BASIC statements and functions as they are executed. The overhead of all of these DLL function calls, coupled with various other things such as intense parameter checking, means that code written in VB executes quite slowly when compared to equivalent algorithms written and compiled with, say, Visual C++ or Borland Delphi. So, to actually get on and answer the question "Why VB?", the three simple reasons are:-
Although this project was originally intended simply as an exercise in seeing what was possible with VB, it has gradually become quite a well-featured emulator in it's own right. This is quite embarrassing to me, as I really would have written it in C or Delphi if I'd have realised people were actually going to use it!
Q3. How fast is it?
Version 1.40, with its support for Spectrum 128K memory paging and full sound emulation (beeper and AY-3-8912) and the additional Timex video modes, manages full 3.5MHz Spectrum speed on a 266MHz Pentium-MMX when used with a fairly fast display card.
As of version 1.40, I have removed the "USE_WINAPI" compiler directive as it was becoming increasingly difficult to maintain source code for producing a 100% native VB version (in other words, a version that does not explicitly call any Windows API functions itself). With the new features that have recently been added, I've decided it's okay just to go ahead and include WinAPI function calls in the code although I would discourage this in situations where it is possible to use native VB code without any performance degradation. I guess this reflects that fact that vbSpec is increasingly being used as a "serious" emulator rather than the programmer's folly it was originally intended to be.
Q4. What features does it have?
The Z80 emulation supports all of the undocumented opcodes that are in common use, and bits 3 and 5 of the Flags register are correctly emulated (the rhino in Ultimate's "Sabre Wulf" walks around properly!). The colour display is fully emulated, including bright and flashing attributes, and as of v1.40 the display is painted on a scanline-basis so programs which use subtle tricks to display more than two colours per attribute square should look right. There is full sound emulation, using the Windows waveOut* API functions to emulate both the 48K Spectrum's beeper and the 3 channel sound of the 128K Spectrum models. Support for loading and saving of .Z80 and .SNA snapshot images is included, and .TAP tape images and raw 16K ROM images can also be loaded (no patches are made to the ROM by vbSpec, so any image that would work with a real Spectrum should work with vbSpec too).
Q5. Can anything be done to make it run faster?
I've done as much optimization as I can, but I don't doubt that there is some room for further improvement. When I released vbSpec v1.00, a number of people sent in suggestions for optimizing various parts of the code (most notably Miguel Santos, whose suggestions resulted in 2- to 3-fold increase in the overall performance of vbSpec!). A lot of these initial optimizations have been gradually eaten up by the additional overhead of the new features such as 128K paged memory, AY-3-8912 sound, scanline display code, so if anyone has any suggestions for further improving the performance without resorting to using external libraries, I'd be very pleased to hear about them!
Q6. I think I found a bug! Are you interested?
Yes, most definitely. If you find a bug, please e-mail the details to me at <email@example.com>. However, please note that this is a personal project and I spend at least 80% of my working day writing and debugging code and answering e-mail -- in the event that I have trouble finding sufficient time or motivating myself to do the same thing in my spare time, I hope you'll be able to forgive me. That said, I'll try my best to respond to as much vbSpec related mail as I can!
Q7. Are there any plans to add new features to vbSpec?
I have no firm plans to go on developing vbSpec, but I expect to revisit the code from time to time to 'play' with it. Also, if I receive any patches that contain interesting new features or optimizations, then I'll almost certainly take some time out to add them into my development copy!
Q8. I've just added this cool new feature to vbSpec, will you include it
in the main distribution?
For the most part, the answer to this question is "Yes". But there are a few exceptions, the main one being that any new code must work reliably and not interfere unduly with the rest of the emulation. If possible, please also try to avoid code that relies on third-party components. As of vbSpec version 1.20, performance is becoming a limiting factor on adding new features. I want to try to keep the minimum required hardware down to a 266MHz PII, so patches that significantly degrade the overall performance might not make it into the main distribution unless I can come up with a way of optimizing everything a bit more.
Q9. Are there plans for any other VB emulators?
I've also written a Sinclair ZX81 emulator, called vb81, that uses essentially the same Z80 core as vbSpec. I'd be interested in hearing from anyone who is planning to use the Z80 core from vbSpec to produce other VB emulators -- Visual Basic GameBoy, Amstrad CPC, and Jupiter ACE emulators would be good to see!
Q10. Where can I download games to play on vbSpec?
World of Spectrum contains a huge searchable archive of Spectrum games and related information. There are other sites too, such as The Spectrum Archive. Many of the authors, publishers and copyright holders of original Spectrum games have given their permission for their games to be distributed freely for use with emulators such as vbSpec. Amstrad plc, who bought Sinclair Research Ltd in the 1980s, have kindly given permission for the ZX Spectrum ROM images to be distributed with freeware emulators such as vbSpec.
Q11. When I load games from TZX tape files, why doesn't the border look
For performance reasons, the border in vbSpec is only updated 50 times per second. On a real spectrum the border is updated much more frequently to create the familiar effect of the border "stripes" that can be seen when a program is loading from tape. Don't worry, the game will load into vbSpec without problems, despite the non-stripey border!
Copyright ©2000-2002 Grok Developments Ltd