Possible Duplicate:
How do emulators work and how are they written?
I'd like to try writing a basic gameboy emulator, or maybe even NES. I know the basics of C and I'm fairly good at Java, so I know the necessary basics of programming. What I don't know though, is how people process all the data into a C program and create an emulator out of it. I know I should learn from source, but it's kind of hard to see a bunch of lines of code without knowing why they're there and what they're supposed to do. Where am I supposed to start if I wanted to learn how to write such an emulator?
I've searched the internet, but I've only found unclear tutorials that contain too many errors to figure out by myself. Where am I supposed to start?
You don't. You emulate the HARDWARE. You don't have to "process" the program data at all, you would need to write code that mimics the CPU, graphics hardware, input devices, etc.
A good first step would probably be to write a Z-Machine emulator, which while not a console it was actually the first widespread "emulator". It was used for all the infocom text adventures (zork, etc). Since it's a text oriented game format, there isn't much to emulate in terms of graphics or sound, the only input device is the keyboard, and you don't have to worry about execution speed/sync.
It's very well documented here: http://www.gnelson.demon.co.uk/zspec/preface.html
It's actually a project I mean to undertake myself one of these days, just have never quite found the time.