What's new

What do you need to know before starting on a Emulator (NES or something?)

vidiware

New member
Hi i want to develop a NES emulator (in VB.NET or sometihng...) what do i need to know before im starting on this project ???
 

Trotterwatch

New member
It is nigh on essential to be knowledgable in a language such as C++ or ASM - whilst it may be possible to do a Nes Emulator in VB (I would have thought it unlikely, certainly not at any kind of speed or compatability).
 

Eagle

aka Alshain
Moderator
I'm VB 6 certified adn I hve to say, it would be extremely difficult to program an emu in VB. VB has little graphics rendering capability. You would have to program an active X component to do it which would still be difficult cause you would mostly be using Windows API's.
 

Warcon

New member
You will need informations on the NES (CPU opcodes, memory layout, etc). Someone else might be able to tell you more, I don't really know much about the NES.

As for the langage, I would suggest you to use C# instead of VB.NET. Both langage are about as easy to use but C# is more adapted for low level coding. By example, VB.NET doesn't support unsigned type (ushort, ulong, etc) and CPU often have opcodes that work on unsigned type. You would need to 'emulate' the unsigned value if you use VB.Net, that would be a bit more complicated and also slower. C# also have some advanced features that you might want to use in the future, when you are more confortable with .NET.

Only reason you might 'absolutly' need C++ at some point is if your .NET application need to interact with C/C++ dll. By example, if there is a 'C/C++' graphic plugin you need to use. If this is not the case then you don't need to know C++ at all. Learning C++ is not bad or anything but I can assure you that you can make an emulator in .NET that will be as fast as if it was done in C++ or ASM.

<More advanced stuff following, you should not use this at first but its good to know that its there... 8) >

If, at some point, you want to use 'dynamic recompilation' in your emulator, learning intel ASM would not be the way to go. There is an easier way to do dynamic recompilation in .NET.

In the .NET environnment (JAVA is like this also), there is a few stages to the compilation of an application:
- You compile your VB.Net, C#, or Managed C++ application ==> .NET generate an assembly that contain MSIL (Microsoft Intermediate Langage).
- When someone execute your assembly, .NET take the MSIL and create highly optimized Intel ASM 'on the fly', then execute the intel ASM. Some of the optimization done: registers caching, loop unrolling, method inlining, constant folding, etc.

MSIL is a stack based assembler, which is a lot easier to learn then intel ASM. By example, to execute:

X = (13 + 5) * 2

you would emit something like this:

- Load(13) // STACK: 13
- Load(5) // STACK: 13, 5
- Add // STACK: 18
- Load(2) // STACK: 18, 2
- Mult // STACK: 36
- Store(X) // X=36, STACK: <empty>

All this to say that there is a way to create MSIL dynamically in your code, and then execute the MSIL. You can then take NES "opcodes block", write 'easier to understand' MSIL that emulate the block, then execute it and get execution speed of highly optimized Intel ASM.

FYI, I know this work because I have done a 'proof of concept' N64 emulator in C#, using dynamic recompilation.

Warcon

PS. No, I'm not working for MS or anything but after using C/C++ for years, I'm really impressed by the speed and features of .NET... 8)
 

Warcon

New member
First of all, the goal of .NET is not really to be faster then C++/C. Usually, .NET application will be a little bit slower then C++ since the .NET environnment does more "safety check" at run-time (null pointer check, out of bound array, etc). What make it fast for making 'dynamic recompiled' emulator is that you can use the recompiler done by MS. MS have spent years optimizing their recompiler, and will continue to optimize it in the future.

In general, its a lot easier and faster to write a secure and stable application in .NET then in C++/C because you have access to a framework of classes that is a lot more complete and easy to use then STL or MFC. It include stuff like: String, Collection (ArrrayList, Hashtable, Stack), Stream, Socket, Security, Encryption, Remoting, Threading, GDI+ (Graphic), Regular expression, File access, Windows Form, etc. By example, making a GUI in C# or VB.Net is as easy as it is in VB6. This couldn't be said about MFC.

Your application also run in a managed environment that will take care of all the memory allocation (i.e. no more memory leak), it will also detect common error like using a null pointer, accessing invalid memory space, etc.

BTW, most of the thing I said is true for Java also. I'm just not sure if it would be possible to use the Java recompiler to do an emulator like I did in .NET.

Warcon
 

Doomulation

?????????????????????????
Geez, sounds like a damn good thing. But .net is completly unfamiliar to those using c/c++ 6 or earlier. Even the gui has been completly re-designed... :plain:
 

decription

New member
If you wanna make an emulator, emulate the CHIP 8. It plays games which are now PD such as snake and pacman. It is well documented and real simple. Search in google, best of luck.
 

Top