What's new

What libraries do you use for cross platform emu development?

Garstyciuks

New member
Hey, I recently got interested in cross platform development. I have rewritten my chip8 emulator using wxWidgets and SDL. It compiles and runs fine on Windows and Linux, but I can't test it on Mac :p. Anyway, I wonder how do you get accurate timing and what libraries do you use?
 

Exophase

Emulator Developer
I just use SDL generally, but using timing (I assume you mean functions to get clock counts and delay for periods) functions are usually so simple that it's worthwhile to define some alternatives for the platform and fall back on SDL otherwise.

Just out of curiosity, what kind of timing are you looking at? And for what application?
 

Exophase

Emulator Developer
I meant about timing emulators. Like how do you get accurate speed of the emulated machines?

Usually you just have to keep things timed roughly to one frame, which will usually be at 60Hz or 50Hz. So you emulate the console for roughly N virtual clock cycles, update the video, sound, input, and what have you, then wait until it has been however many milliseconds (or microseconds, if your timing allows them, or whatever denomination it does) since the last update. You can also have it wait if the audio buffer gets too far ahead of the emulated machine. Or you can synchronize to actual vsync if you have them and the platform you're on is at the right rate (I do this on PSP).

I've seen some advice on this board that you should run each instruction so that it takes roughly what a clock cycle would on the real machine. This isn't practical or very useful advice; for pretty much any machine you'll emulate that amount of time for one cycle is too small to hit precisely with any timing mechanism and you'll spend a huge amount of overhead on this. Synchronizing on video is good because that's basically the most noticeable thing to the player, although it's probably a good idea to have it on video and sound. Both of these things are relatively long cycle periods so there's not a lot of overhead involved.
 

Top