I’m afraid I’ve been rather wrapped up in the organisation of next month’s XBlig-UK meeting, and the launch of Windows 7 didn’t help matters much by absorbing the remainder of my free time. However I am now typing on my fully 64-bit laptop - finally!
Obviously the first thing a person of my age does when they fire up their spanking new 64-bit machine is reminisce about their first 8-bit machine!
It was while wallowing in this sense of nostalgia that I came across this presentation by Chris Hay from last year’s PDC where he has a full-on ZX Spectrum up and running under Silverlight 3 (I think you might have done Silverlight Manic Miner the hard way Rich!). However it turns out that this is built on an earlier project by Jan Jones who has released the source for a fully deployable XBox360-based Spectrum emulator running under XNA! I tracked down Jan via YouTube and he has very kindly resurrected the original project on Codeplex this week, for us to get hold of it. Jan happily acknowledges that this project remains in the early stages of development, but it is nicely structured (using a C# port of Jasper by Adam Davidson & Andrew Pollard) and all ready for getting amongst it, and starting to add some more features.
What could be more UK & XNA than an XNA ZX Spectrum guys!
If you’re up and running under Game Studio 3.1 you’ll probably going to need to recreate the project under the new framework. I just added one extra sub-project to the default windows game template to hold the core speccy elements – Z80.cs, Bitmap.cs & Spectrum.cs. You will then need to make some minor modifications to the Main.cs (which replaces game1.cs if you’re using the default class names from the template), the most significant of these is in the Draw method. The original version calls SetData in a 2DTexture that is set to the Graphics device. This is no longer allowed and will throw an exception – in fact MSDN says we shouldn’t really do this at all because we can potentially screw up predicated tiling on the XBox under some circumstances. However for the time being you can resolve this exception by modifying the draw code thus:
GraphicsDevice.Textures[0] = null;
m_targetTexture.SetData<uint>(
m_spectrum.ScreenBuffer,
0,
m_targetTexture.Width * m_targetTexture.Height,
SetDataOptions.None
);
GraphicsDevice.Textures[0] = m_targetTexture;
This unsets the texture from the Graphics Device before injecting its content from the emulator, then you can stick it back. I’m sure there is a cleaner way of doing this, so please add a comment if you have a suggestion. While MSDN says don’t do it, it doesn’t suggest a better alternative!
The big areas that could do with some improvement are the keyboard mappings (which really need to editable & stored/restored for each specific game) and sound support. I’ve started adding both these – but got horribly distracted once I had Elite playable… ;)
Anyway I hope others have as much fun tinkering with this project as I have. If Jan gives me the thumbs up, I’ll post my Game Studio 3.1 project here or on codeplex to get everyone started.
Don’t forget XBlig-UK next month – currently more than 50 registered attendees and we’ll have to start limiting registrations once we get up to around 70 so don’t miss out…
E
Files
Please find my Game Studio 3.1 update of Jan’s project here. There are lots of places to get hold of SNA files on the web and you can drop them into the ROMs folder in the project root. I’ve added full keyboard mapping, because my kids got well into The Hobbit over the weekend. You need to plug a conventional USB PC keyboard into your Xbox 360 then you’re away, with F1 to cycle through the available SNA files. I’ve also simplified Jan’s project a bit by replacing the XACT project with the newer SoundEffect class (which handles WAVs through the standard content pipeline) but I’m afraid I still can’t get any functional sound support :(
Thought some of you might like to see this picture of my kids playing The Hobbit on the ZX360. It’s deployed to the 360 in our living room and you can just make out the USB keyboard being put to good use for this classic text-based adventure.

Posted
Fri, Nov 13 2009 12:26 PM
by
VeraShackle