NeoDS1.jpg['Quiz Me Quik' is a new weekly GameSetWatch column by journalist Alistair Wallis, in which he picks offbeat subjects in the game business and interviews them about their business, their perspective, and their unique view of life. This time, an examination of Nintendo's portable system running a much more heavyweight vintage console.]

There’s kind of a weird mythical nature to the Neo Geo – in my mind, at the very least. I think it applies to other people, though, simply because of the price associated with the console throughout its lifetime: US$649 at launch, with games going for $200 or more.

And as time has gone on, it hasn’t got much better. Games for the system – rare ones, that is – have a tendency to go for over $1,000 on eBay. I’ve always thought of it as a highly regarded system, though it’s obviously one that was never hugely successful in a commercial sense.

I’ve only played one – only even seen one – in the wild once, and that was at an import store on Melbourne’s notoriously expensive Toorak Rd. I can’t remember what I played, as I think I was about 12 at the time. I know it had grenades in it, but that really doesn’t narrow it down for the Neo Geo, does it?

I do remember the controller, though; that thing was super sturdy, and really a joy to use. And I think that I knew from reading GamePro that it was a far more powerful machine than what I was used to (although given I was used to a 286 at the time, that’s not saying much).

And now Neo Geo games are playable on DS, with Ben Ingram’s NeoDS emulator, which has just been released, and is currently at version 0.1.0. It's funny how quickly technology moves. I've just replayed Monkey Island 2 on my mobile, for example. That game wouldn't even run on my 286 growing up.

Naturally, there’s a few bugs with it right now, but that makes for some interesting discussion – how many people really know about the processes involved in writing emulation software, and how to deal with strange issues? There’s no better time, then, to actually talk with Ben and ask about the emulator as he works to iron out the bugs and implement new features.

GSW: What made you think, initially, that the DS would be powerful enough to support a Neo Geo emulator?

Ben Ingram: I didn't know if it would work initially, but looking at the Neo Geo specs, it seemed like if I can stream data fast enough, everything else would be doable. So I gave it a shot.

GSW: What made you want to play Neo Geo games on the DS?

BI: I have always gotten a kick out of emulators running on embedded systems. I'm not the world's biggest Neo Geo fan, but I do have fond memories of playing Metal Slug at the local arcade. And it hadn't been done yet, so the opening was there.

GSW: How did you start with the emulation? I'm curious about the order that you use when writing an emulator - what's the first thing you do?

BI: First I got the cyclone CPU core compiling with devkitPro, and hooked up a very simple disassembler, where I could step through and watch the CPU execute instructions. I wrote some initial memory handlers in C, and a quick and dirty ROM converter in C#, and loaded up the Neo Geo bios.

Once I had verified that [68K interpreter] Cyclone was in fact executing the bios instructions properly, I added a very slow and limited software renderer, and then kept adding memory handlers and fixing bugs until the bios logo appeared.

At this point, I started adding all the graphics caching code, audio code, and optimizations. And here we are.

GSW: Did you work on the emulator alone for the whole development?

BI: Yes, although I use Cyclone for M68k emulation, and DrZ80 for Z80 emulation, which are written by finaldave and Reesy respectively.

GSW: What were the first games you managed to get working?

BI: Metal Slug 2 was the first game I loaded – and which is ironically broken in the first release. Samurai Showdown 2, Metal Slug 1, and Last Blade 2 were some of the next. Basically, games that I like.

GSW: How do you go about fixing issues?

BI: I haven't had much luck getting NeoDS running in any DS emulators, so I've done all development on the real hardware. There are lots and lots of ASSERTs in the code, and there is also a debug log that is disabled in the release version. This is a crude way to debug, but it's worked so far. Starting with working CPU cores has also helped a lot.

NeoDS1.jpgI learned to program on TI calculators that didn't have any debugging available, so working without a debugger has some amount of twisted nostalgia for me.

GSW: Were there any really unexpected game-specific issues that cropped up?

BI: A few games have audio drivers that are very picky about the timing between the two CPUs. The Shock Troopers games both are like this. I'm sure there are others as well.

The Neo Geo video hardware has a few quirks that don't make much sense to me, but that some games take advantage of. Luckily there is plenty of reference source code for Neo Geo video.

Overall though, the NeoGeo is a remarkably straight forward system.

GSW: What's stopping you from emulating FM sound effectively at the moment?

BI: FM sound is complicated and expensive to emulate. It's also not used extensively by many NeoGeo games. My feeling is it can probably be squeezed onto the arm7 core, next to the Z80 interpreter. But I think the Z80 core will need to be optimized some for this to work. I know that [Mega Drive/ Genesis emulator] jEnesisDS emulates 6 FM channels on the ARM7, but it runs the Z80 on the ARM9. The Neo Geo only has 4 FM channels, but it will definitely be tight.

GSW: And what's the problem with raster effects?

BI: The Neo Geo graphics hardware is different than most other 2D console hardware. It doesn't have dedicated 2D tile layers. Instead, it can render lots of strips of 16x16 sprites. NeoDS renders each sprite as a textured quad with the DS 3D hardware. To make raster effects work, the screen needs to be draw in sections as the hardware triggers hblank interrupts.

NeoDS could do this in theory, but the DS can only handle around 1500 quads per frame. Most games that use raster effects change per scanline, and this would create too many quads for the DS to handle.

So in order to get raster effects, I think a different approach must be used. The DS can render far less 2d sprites than the NeoGeo, but DS sprites could be swapped by a hblank handler. If you can load in enough new sprites on each scanline, you would be able to render as many sprites as needed, and get raster effects as well. DS sprites can only address half the VRAM of quads though, which would cause games to thrash the file system even more. It might even be possible to detect large clumps of NeoGeo sprites and map them onto DS background layers.

All of this is likely to be slower than textured quads though, and most NeoGeo games run fine the way it is now. You'd also lose the nice screen scaling by going with the 2d hardware. So this is not something that's likely to change anytime soon.

GSW: What are the timings that are causing problems at the moment?

BI: There's the audio issue that I've already mentioned. Some games may be having trouble because hblank interrupts aren't really implemented at the moment. And a few games don't work and I don't know why, so I can only assume that there are a few issues left that I haven't figured out.

GSW: Have you learnt anything interesting about the DS during the time working on the emulator? Is it more or less powerful and flexible than expected?

BI: Memory latency is very important on the DS - and most other platforms it seems. I've learned ARM assembly, but that's not really DS specific. There's a lot of neat stuff the DS 3D hardware can do, but NeoDS doesn't make use of most of it.

GSW: How possible is your goal to include wi-fi multiplayer in future builds? Have you had any luck at all with testing this outside of the released version?

BI: I think the only way to do multiplayer is to swap key presses, and syncronize both systems every frame. I don't know much about the DS wireless latency, and I certainly haven't tried anything yet, so I'm not sure how slow this would be. Also, I'd have to squeeze the wireless driver onto the arm7, next to the z80 core, and maybe the FM emulator. Not going to be easy. But - almost? - all Neo Geo games support two players, so I think it's worth trying at some point.

GSW: How does the conversion software work, and why is it necessary?

BI: Neo Geo ROMs are traditionally zip compressed. NeoDS needs to stream data from the flash card in real time, so decompression is not feasible. So the first reason for conversion is to remove the zip compression, and pack everything in the zip file together into a single file.

Many Neo Geo games are also encrypted and scrambled, and it's better to deal with this on the PC rather than the DS. The converter itself is basically a stripped down version of the MAME ROM loading code. It loads the ROM into memory just like MAME, but then writes the converted data into a file. This is why only MAME compatible ROMs are supported.

GSW: How many downloads would you estimate there have been so far? Do you think there are people that will be buying flash carts just for this?

BI: I really have no way to track this, but the response has been great so far. There are far too many forum posts for me to keep track of. My feeling is that most people who are excited by NeoDS are already fans of portable emulation, so they probably already have flash cards. If anyone wants to prove me wrong, feel free!

GSW: Are you involved in other areas of DS homebrew at all? How healthy do you think the scene is?

BI: My only other public release besides NeoDS is gb68k, which is a Game Boy emulator for TI graphing calculators. I'm certainly interested in other types of homebrew, and have several partially finished games for a variety of platforms. Emulators are easier for me to finish than games it seems.

From what I can tell, the DS homebrew scene itself is pretty strong. There are cool apps like Colors and PocketPhysics, being actively developed, along with other nice emulators like jEnesisDS. QuakeDS 1 and 2 are also really cool.

The DS is a really fun platform to work with. I still think it has a lot of unrealized potential.

GSW: How do people in the scene interact with you because of NeoDS - do you find that you've become a kind of trouble-shooter for some people?

BI: It's actually been pretty nice. Most forums where people are discussing NeoDS seems to have plenty of people who have figured it out, and are willing to help others. The same goes for the Google group I set up. I haven't felt too overwhelmed with questions.

GSW: And what kinds of feedback are you getting from those people?

BI: There has been a lot of feedback - more than I was expecting - and it has been really positive. Obviously there are things that don't work, and things that don't work particularly well, but even when reporting problems, people seem to be very polite. It's certainly made things nicer for me.