DrilNES - This Space Intentionally Left AWESOME

Published February 06, 2008
Advertisement
HERE COMES A NEW CHALLENGER!

Inspired by Scet's Tub of Awesome, I opted to continue work on my old emulator, DrilNES.
And here it is! DrilNES in all its glory! Note that it does not support PAL NES timing, it only runs NTSC games (so US and Japanese games only).





A Brief History of the World

I first attempted to tackle NES emulation back in 1999. I had the goal of getting three games to be playable: Castlevania 3, Startropics, and Crystalis. Turns out, these three games are some of the harder games to emulate, due to the tricky nature of the cartridge hardware that they run on. However well it ran at the time, it was woefully inaccurate, and this bothered me. In mid-2004, I apparently decided to try again.


Emulator Action

The great thing about having started this project over in 2004 is that I have the entire history of the emulator's development in SVN, so I can see exactly what I did, and in what order. Here's a quick list of the hilights:

  • Wrote the CPU emulation code (runs opcodes, etc).
  • Got the PPU (pixel processing unit) up and running
  • Rewrote the CPU emulation code to be more accurate with regards to instruction length counting (all instructions now emulate every read and write of the instruction, even the unnecessary ones, and the CPU cycle is clocked on each memory access).
  • Added input and mappers. Mappers are emulators of the hardware that came IN the various cartridges. Originally mappers were just for memory mapping, but the hardware eventually added additional graphical, sound, and interrupt capabilities as well.
  • Added more mapper support
  • Added support for the color emphasis bits which...tweak the output color from the NES in various ways.
  • Added sound output.
  • Got various IRQs running (for interrupting the CPU at certain points in the audio playback or at certain scanlines)
  • Added savestates.
  • Added a custom rom open dialog, with a treeview and stuff
  • Even more mappers
  • Two-player support
  • Rewrote the MMC3 mapper from scratch, because the MMC3 code was nasty and ugly and I hated it. And it insulted my mother. And your mother.
  • IRQ fixes. At this point, judging from some...colorful SVN log comments, I was starting to hate IRQ work.
  • Set down the code for a year.
  • Complete PPU rewrite to be way more accurate. This was the point at which I was starting to hate Battletoads, which is probably the most touchy game when it comes to accurate timing.
  • Complete PPU rewrite. Yes, I know that is also on the previous line. I rewrote it again. Seriously.
  • Rewrote the PPU's sprite access logic. STOP REWRITING ALREADY SERIOUSLY WHAT THE HELL
  • Rewrote the IRQ logic again. Ugh.
  • Rewrote the CPU. This time the CPU is awesome and infallible and will never need to be rewritten or even fixed ever again. Also, I think I was slowly losing my sanity.
  • Added a faster read of guaranteed in-ROM memory, without going through all of the IO handling code. I didn't notice for over a year and a half, but this totally broke the accurate CPU timing that I had going for me.
  • Rewrote the CPU again. Apparently last time I was wrong. Boy this is awesome!
  • Stopped working on DrilNES for a year and a half. I'm not sure but I think I'd had enough.
  • Started last weekend! Multithreaded the emulator.
  • Added a whole bunch of GUI features (including ripping out the now-hideous custom rom open dialog that I added back in early 2005)
  • Added XInput support for 360 gamepads
  • Added the VRC6 mapper (with its additional sound channels) so that Akumajou Densetsu (Castlevania 3 Japanese) works!

As you can see, development was a tortured path, filled with rewrite...after rewrite...after rewrite...

The upside is that now it's pretty accurate. It's not perfect, I'm sure, but it's pretty good and better than a large majority of emulators out there.


Vista-Specific Functionality

One thing that was fun to add was some Windows Vista-specific functionality. Mainly, when you load roms or save state, there are little popup windows that notify you. In Vista, they look like this:

instead of just a generic yellow-on-black window. It's nice to be able to see through them.

Also custom is the Rom load dialog (link to the screenshot, I was too lazy to make a thumbnail for this screenshot), though there is a custom one in XP as well. Basically, it lets you see relevant information about a ROM before you load it (and will also prevent you from loading unsupported ROMs).

But, in general, it's nice to be "done" with it (though there are tons of things that I would like to do with it still).
Previous Entry Seriously, I Was Bored
Next Entry One Year Later
0 likes 3 comments

Comments

benryves
Great work, and I like the extra info on the Vista open dialog. [smile]

How do you extract data about things like mapper chip type with NES ROMs? I found with my SMS work that there are a large number of bad dumps (overdumps, headered/footered dumps, dumps with bad bytes) and for those I use a database; by looking up the CRC I can identify known problematic dumps and attempt to patch them. My intention was to turn this into a web service and to also add information about hardware profiles (ie, mapper type, this game is PAL, this game is a Game Gear game that uses the Master System mode) as well as other "interesting" information (release date, developer) but that never really took off. A searchable version of the database is here.

I share your sentiments on IRQ work. [grin]
February 06, 2008 09:30 AM
Drilian
I, too, have a database, though it's not as full-featured as I'd like. Essentially, I do a lookup using a CRC, and the database contains accurate header information as well as the title of the game (which contains information on whether it's a bad dump or not). Sadly, there's no information as to whether it's a PAL or NTSC rom (which would have been superhandy) or any other information beyond crc, rom name, and corrected header.

However, this has been good enough to dodge all of those pesky issues (such as the wonderful 'DiskDude!' corrupt headers) for running the ROMs that I do have.

And yes, IRQs are full of pain.
February 06, 2008 03:08 PM
Scet
Wow, I totally missed this entry, awesome stuff.

Quote:
Rewrote the CPU. This time the CPU is awesome and infallible and will never need to be rewritten or even fixed ever again.


Yeah right, that's what I said during the third rewrite. I've lost track of which one I'm on now. [crying]
February 07, 2008 10:03 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement