What's new

GBA emulator in C#

OP
G

gladius

New member
My goal was to use completely managed code for this as I was going to test out a ClickOnce version (essentially like a java applet) that could run from a webpage. Unsafe code requires higher permissions so I stayed away from it.

As for the DirectX usage, that could easily be stripped out and use C# SDL or an equivalent, I just used Managed DX as it was what I was familar with (and I wanted to play around with pixel shaders :).
 

swtrse

New member
Ok, if the goal was to make it usable over the web using no unsafe is understandable code since it requires SkipVerification CAS meta-permission.
However this permission could be set with (poweruser may set it manualy) via an certificate.
Anyway the Register-struct works without unsafe code :matrix:.

Ok, I'm motivited to code an C# emulator with the goal...beat the native code emulators *g*. Since I never write one I think I should start with an ordinary GB-Emulator....last problem...the time to do so, work sucks...sometimes
 
Last edited:

Doomulation

?????????????????????????
You can't beat a native emulator with C# and managed. Not until vista, anyway, and still, native emulators can probably do things more effciently than C#, but I am merely guessing.
 

Toasty

Sony battery
I agree with you. IMO, it's not really a matter of when compilation takes place, but a matter of how accurately the language or platform allows you to 'express yourself' to hardware. C and C++ allow more flexibility where it counts in emulation.
 
OP
G

gladius

New member
C/C++ if coded correctly can certainly beat the performance of managed code for emulators. Asm can do even better because you get the flag updates for mostly free and can do a bunch of crazy optimizations the compiler normally won't do.

If you use unsafe C# you could probably get a lot closer to normal speed. For example, every one of my u32 memory reads is four byte reads, with the or's and shift's to put them together. C/C++ or unsafe C# can do this with a (not endian safe) pointer access. Also, my registers are stored in an array, and every access to that array is bounds checked. Things like that add up pretty quick.
 

Danny

Programmer | Moderator
Great job. Was this your first coding project or have you a lot of experience with coding?
 
OP
G

gladius

New member
I've been coding for quite a while now, this was my first semi-large personal c# project though, which was the reason I started it.

I actually had an old c++ gba emulator that was very unfinished, but could emulate a few of the very early demos. I've also taken stabs at GB, PS and N64 emulators back in the day, but never made it incredibly far on any of them. Emulators are too much work ;).
 

Top