Speculator

Written by Dean Edis on .

Speculator In my years a software developer I've set myself many projects and goals. Writing a ray-tracer was particularly enjoyable - You'd be surprised how easy it is to get some quite impressive results. (I might even release my source code at some point. Watch this space!) Another one of my 'projects' was to write a ZX Spectrum (48K) emulator. That's the machine I first learnt to code on, spending hours and hours typing in BASIC code from a book, and then tweaking the result to change how the program ran. Reminiscing about the 'good old days' is one of the factors which motivated a few of us to get together to form Gimpy Software!

So 'write an emulator' I did! My goal was to get it to the point where games such as Manic Minor, Jet Set Willy, and Horace and the Spiders would work, plus have support for BASIC. I chose to write it in C# because I wanted to become more proficient in that language, having previously focused mainly on C and C++. I think that shows in the coding style I used - I've since learnt much more about C# so if I were to do it again there's definitely some changes I'd make.

You can download my code from this site, build it using Visual Studio, and use it more-or-less as you see fit. The sound emulation was quite tricky to implement, and wasn't quite 100% perfect, so I have excluded much of it from the download. The code hooks are still there, so if you're up for a challenge and want to implement it yourself feel free, and let us know how you get on! The Z80 CPU emulation is (in my opinion) fairly accurate! Some of the less used interrupt modes are in a 'TODO' state, but for most purposes the emulator as it stands works fine. There is also a built-in CPU debugger available, as with most of the functionality, using a right-click menu in the application.

To avoid any legal issues I've deliberately not included the Spectrum's 48K 'ROM' file. It is, however, a quick 'Google' away and can be downloaded from many sources easily. If we get much interest I'll write another blog going into some detail about how emulation works. In the meantime I recommend reading this site for an intro into writing an emulator (in Java): http://www2.sys-con.com/itsg/virtualcd/java/archives/0707/surdulescu/index.html