woud like to start NES emulator project in C# language, possible?

triple7

New member
Hello and greetings to all,

This is my first post on this forum so I will try my best to describe my post. I am currently a student programmer and I'm learning C# as the language. I would like to start an emulator project of a nintendo emulator. I know, that most emulators are mostly written in C++ or some other language, however, I am asking whether an emulator can be pulled off C#? And if so, what kind of difficulty would I expect?

-Karim
 

Mupen64 Man

Big fan of Mupen64
Staff member
Its very possible, but you can expect it to be very difficult. It takes years to make a good emulator, but if you know what you are doing and know enough about the system you are trying to emulate, then its pretty much smooth sailing. :)
 

ulaoulao

Controller Man
Staff member
I have worked with c++++ ( c#) before and I'm no fan at all. But I am a c++ guy so I'm sure that why, plus I hate m$. Though I have to admit I'm stuck using windows. Linux is just not as popular yet.

ok on topic... Yes c# will do just fine. I think you will loose some of the ASM short cuts ( not sure ) and c++++ is further from machine assembly( I think ) but I'm sure you can do it. There are a few emulators using J so why not. However that being said, have you studied ASM much? As you know ( I hope ) ROMS are compiled machine line instructions. Your job as a emulator author is to interpret this lines and wrap then to DX or OPGL calls. So the closer to machine code you are, the better. Many people have used HI-level emulation to cheat and done quite well. (i.e ULTRA-HLE ). In this case they read the rom and wrap to the gfx. Seems to be the going trend and I dont see why c++++ wot work there. The down fall here is speed. n64, no problem, but anything newer and you will see the speed hit.
 
Last edited:

triple7

New member
Like I said earlier all I want to do is a basic NES classic emulator, basic meaning, it has limited functionality (load rom, reset, exit) but plays NES ROMS. Remember that I do not want to make anything big here like the N64 here. The main idea I still do not understand quite well enough is how to-- as you quoted: "to interpret this lines and wrap then to DX or OPGL calls."

Can you please describe this process?
 

ulaoulao

Controller Man
Staff member
Wow, your asking me to type up a book here. I'm afraid there is a lot of learning you need to do if that does not make sense to you. And yes you will need to learn it for "plays NES ROMS". I think there are a couple of emulator projects that have SDK'd there work. I dont recall what ones but check out bNes. SDK, meaning all you need to do is include it and do a myObject->loadRom();

Just a tid bit about reading the instruction lines. Most people that do this have been for many years. I have done this very thing since I was 12 ( 36 now ) and I would not think of attempting an emulator. I just no better ;) If you really want to do this, start reading up on assembly. Get a feel for how this works and what it means. Then try to take a very small assembly written code and understand it. After you get good at it, try to take an EXE that you know what it does and look in to a decompiler and build en emulator for it. Once you emulate a dos app in dos you can move on to something harder. Emulate a dos app in windows, or a mac app in windows. These examples are far more easier then any console rom. Than when you are ready try something simple like atari, or may jump to nes. Or like I said look for an SDK/DDK where someone did the hard stuff for you.
 
Last edited:

triple7

New member
Fair enough, all I needed was a bit more clarification on what you meant earlier. So my question this time is: where can I read up on starting to do this kind of work?

I would also like to add, has there been any emulator made with C# ? Because it seems to me that any emulator that has been made is al C++ or Java.
 

ulaoulao

Controller Man
Staff member
Well AFAIK no. And I think that is the case for the reasons I highlighted above. Your best resource ( other then google ) is IIRC chat. Get in with the people that do this and get buddy buddy. Remember its not illegal but its not exactly public known info. Pay attention to what I said above, there's no book or resource on "how to emulate" you need the skills to decompile and understand ASM and machine code. Writing an emulator comes from putting those elements together.
 

GHDpro

Administrator
Staff member
Sorry for this a bit late response.

Yes, you can write an emulator in almost any language, C# included. Heck, some guy is writing a GB emulator in Javascript! Having said that, writing an emulator in C# will not result in the fastest emulator possible. But as you're still learning to write an emulator, that's fine -- concentrate on the difficult stuff (actually writing the emulator) rather than messing with a programming language you may not be familiar with.

There are resources out there for writing emulators, but don't expect them to be geared towards C#. You may need to be able to read examples written in other languages and convert them to C#. Also don't forget to check the source code of existing NES emulators, especially those that didn't get very far yet (so not many advanced features and optimizations, making the source code easier to read). Don't worry if some of the resources are quite old - NES emulation has been done for a while now, so don't worry about reading documents about creating emulators written 10 years ago.

Anyway, just start with Googling "how to write an emulator" :)
 
Top