Emulation Explanation


johncross85

Startled By Midgets
Joined
Nov 3, 2003
Messages
341
Location
Newton, UK
Website
Visit site
I'm a newbie so I've gotta start off by apologising for 1) what may turn into a long post and 2) if I'm repeating what's gone before...

I've had my GP32 for about a week and have been surprised by how much difference in performance there is beween the various emulators. As a programming novice I no doubt have been underestimating the complexities of emulation :D but I really expected a 132mhz 32bit processor based system like the GP32 to have no problem emulating a 8mhz 16bit computer like the ST or a 4mhz 8bit computer like the Spectrum. I know both Castaway and SpeccyAl run at nearly full speed, I just expected the GP32 to emulate them without even breaking a sweat. Is this just an issue of optimization?

This isn't meant to be a stab at the hard working coders who've laboured over the emulators. I wish I was a programming god so I could have a crack at it myself, but sadly I'm not. I am, however, a graphic designer and keen as I am to do my bit I'll cheerfully help out on the graphics front - just gimme a shout.
 
Well, although the processor only has 8 MHz or so, the GP32 has to emulate the WHOLE SYSTEM, not just the processor, i.e. various graphic chips, sound chips, etc.
And that takes up a lot of processor power...
 
Technically, you could probably even get the N64 emulated on the GP32 with serious compression / decompression algorithms and professional ASM optimization, but it's not going to happen for the simple reason: time. All of the emulator authors are doing this out of their spare time and goodness of their hearts - many like the challenge.

Take the 16-bit systems SNES and Genesis - there is no reason they shouldn't run well on GP32, the sole reason is almost complete lack of optimization. But I would rather have an unoptimized emulator now and an optimized emulator later then just an optimized emulator later.

Optimization is 10% Inspiration and 90% Persperation. After the relatively small amount of intuitive optimization is done, we are left with just hacking code and "seeing what happens", or researching better algorithms.

Now, for a little of what emulators tick: They are basically command interpretors. The ROMs contain machine code which the emulators try to interpret based on the original machine's specs. In general, interpreting anything is rather slow - why do you think Java is so much slower then C++, and Perl even slower?
 
Ahhh, that makes a lot of sense...

There seems to be a lot of crossover between consoles and computers in terms of processors used - eg (if memory serves) the GB and Spectrum both use the Z80, the ST and Genesis both use the 68000, and all three (in the case of the Speccy +2 anyway) use the same sound chip.

Could the same core code be used for different systems where the cpu was the same? If so, would it be worth doing some sort of communal project where anyone can have a go at optimising the core code for ARM? Once the code was as good as it could get, it could then be used by anyone for different emulators - (in the case of the 68000) someone has a go at an ST, couple more people try the Amiga, more still working on Genesis emulators etc.

Or am I just talking rubbish?
 
You're not talking rubbish, but you're missing a few key things :)

Firstly, emulation is by definition very tough work for a machine to do; the rule of thumb was always "10 times performance needed to do the job halfway right", but it really depends on what needs doing; the ST was approx 8MHz, but one must factor other components in (memory model, blitter, etc etc).. you're emulating a processor, plus other stuff. The reason Castaway worksd as well as it does is because its fairly tightly optimized, though still portable C, and the ST is basicly a pretty simple machine. Emulating a SNES is much more work due to the SNES having some funky hardware... not only are you emulating the processor, but you're emulating what the hardware does. So having software do what hardware does for a totally different platform.. now thats a lot of work to do, and it cannot run fast, just by definition. ie: A SNES can do scaling and rotation with minimal investment by the SNES developer.. its just fast, no worries, so they can rotate a picture around 60 frames a second with no real overhead; but to emulate that piece of rotation or scaling hardware, imagine rotating every pixel on a 320x200 screen 60 frames a second.. millions of operations. Bam, hard to do fast in software :)

So emulators vary by speed based on the hardware they're trying to emulate, and the time invested in the emulator, which of course is directly proportional to the skills and available manpower. Niche platform here, so there you go.

So.. Castaway again, is written entiwrely in C; early versions had bunch of ARM assembly put in to speed it up, but then I tossed all that as I work cross platform and didn'r want to tie myself to ARM specifics, or even GP32 specifics (notice now that I've got Castaway running on Palm OS). Its pretty well optimized C code, but could be topimzied more still.. and runs fast. Rewriting it all in assembly for the GP32/ARM would make it much faster still.. but there inlines another issue. Writing an emu in C is measured in weeks for simple projects (like a Galaxian emu, say), but in assembly.. months. (assuming from scratch). So I built and got Castaway for GP32 done over a couple of months (and I'm a very experienced coder and emu coder), and hence it does a lot of thigns very well. But if it was written in assembly, you'd still be waiting for it ;)

Writing it in C is one thing; wiriting it in assembly is a huge huge huge task, and the output is few things. 1) Fast running, and 2) Incomprehensivble to most, and 3) Not portable. So does someone want to work their bones of like mad for many months, only to come up with something that has very limited portability and lifespan, or they can work on somethign less, and get much more out of it.. something for many machines that lasts forever. The answer is.. sure, you build emus out of love for the machine, so you'll do it.... maybe. People like me work on a half dozen platforms each day, so woudlnt' go near such a thing. I routinely port code I wrote a decade ago to new platforms.. thats nice. (ie: Thats why you have XCade for GP32; it took 2 days ot get half working, and another week to make it more pollished. So theres 10 year old code brought to GP32 in a week! Thats why I make things portable.... yet if XCade was assembly, it woudln't have been ported to the half dozen platforms it runs on today)

Now, if you have a sufficiently large developer base, there'll be people who don't mind to do the assembly or have the time; like on the PC intel platform.. theres Z80 processor emus in C, assembly, java, you name it.. millions of developers, everything gets done many ways. Cool. But for the GP32 and ARM, you have so many fewer developers that you're relying on a vital few.. and thus they usually don't have the time to go writing things in assembly all day time.

As it is, theres almost no Emu coders for GP32 -- theres mostly emu porters, porting code from other platforms. They're going for high speed delivery and glory and fun, but likely don't have the skills or time to go writing an emu from scratch. Like MAME.. MAME is a pretty darned successfull project, with thousands of people donating time. Its obviosuly not optimized for any platform, let alone small ones like the GP32 (small in architectural sense); so rewriting somethign like MAME.. forget it -- if thousands of peopel wrote it, you know it'd take 1 person a few lifetimes :) But porting it is conceivable. So no way you're going to see an assembly version of MAME. Take the same for most other emus on GP32...

(Of course, a lot of the emus have a little assembly and lots of GP32 specific optimization in them, of course. Pieces of the puzzle.)

Anyway, withoru going into the whole development cycle.. emulation is itself a niche-ish thing, and you'r e on a niche platform, and thus you're not going to get too many devvers with so much time they can waste it making an ASM version of something, when they can instead make use of whats already there and get you something to play with now, rather than a year later :)

jeff
 
Now that's what I call a full and well thought out explanation - cheers. :D

What sparked my whole train of thought off was that when thinking about buying a GP32 I saw posts saying that ST and PC Engine emulation were pretty much spot on. I kind of then assumed that less powerful systems like the GB and Speccy would have perfect emulation too (mainly thinking about my CD containing a couple of thousand Speccy games and grinning).

So I suppose I have 3 options:

1 - Learn how to program emulation using assembly.
2 - Convince everyone in the world to buy a GP32 thus expanding the base of developers (slightly more likely than option 1).
3 - Patiently wait until existing emulators improve a bit.

Somehow I think it'll be option 3...
 
Now that's what I call a full and well thought out explanation - cheers. :D

What sparked my whole train of thought off was that when thinking about buying a GP32 I saw posts saying that ST and PC Engine emulation were pretty much spot on. I kind of then assumed that less powerful systems like the GB and Speccy would have perfect emulation too (mainly thinking about my CD containing a couple of thousand Speccy games and grinning).

So I suppose I have 3 options:

1 - Learn how to program emulation using assembly.
2 - Convince everyone in the world to buy a GP32 thus expanding the base of developers (slightly more likely than option 1).
3 - Patiently wait until existing emulators improve a bit.

Somehow I think it'll be option 3...
The GB should be perfectly emulated, as its really nothign special; GBC too. Now GBA is rough due to all the fancy hardware et al, but theresno reaosn the GP32 doens't have good GB and GBC emulators, except that no one really cares about the GB (and to some extent the GBC) .. why play GB when you can play better versions of the game son other emulated systems :) (ie: PCEngine...)

I never had a Speccy, but I imagine it can't be overly much to emulate well either.

(ie: Look at Frodo on the GP32.. its quite stunning; if Frodo can be done, the GB/GBC and Speccy can be done for sure)

Learnign to write an emualtor is certainly possible.. its more tedium than difficulty for well documented systems :)

jeff
 
Last edited by a moderator:
Speccyal'K v0.6 is almost there in terms of near-perfect Speccy emulation. It runs most games and is easy to use.

Jeff, if you've never tried a Spectrum game - have a pop at JetPac, Knightlore, Manic Minor or Jetset Willy, you won't regret it.

Otherwise I'm sure the good folk at comp.sys.sinclair will be able to convince you give the platform a whirl.

Mark.
 
Now THAT was a good guide as to gp32 emulation. I think it should be pinned ;)
 
Hi, I am considering buying a GP32 but am a bit concerned about the emulators available. It seems that most of them run at half speed or without sound and such. I know that the guys who program them do them on their own time and I do appreciate this (especially since I don't program myself :blink: ), I just don't want to spend all that money on a new system to find that I'll never use it. Mainly I'd like to be able to play NES, ST, Atari (2600, 7800, 8-Bit, ST), SNES and Megadrive games. Can anyone advise me what state the emulators are in for these, and others as well if you have time and the inclination to do so. Any help would be much appreciated. Stay frosty, Sokki.
 
Everything you mentioned up to Snes and Genesis is perfect. As for the latter two, they are improving all of the time, currently OpenSnes9X runs near perfect without sound and at about 70-80% with sound depending on the game and the speed at which you can overclock your GP32. Genesis runs at about 70-80% without sound again depending on the game and the overclock rate.
 
Thanks for the reply. Also, if you can indulge me in a couple more questions that would be excellent :) . Does the GP32 only run on batteries or can it be run off a mains power supply. I am in the UK, would I need some kind of transformer to run it off mains?

Also, can anyone suggest sites where I can get roms from. I own all of the systems I mentioned as I am a bit of a retro collector, I'd just like to be able to play a lot of my old games on the move.

Thanks again, Sokki.
 
It can be run off a mains adapter running at 3V DC with an inversed polarity. Buying one of those multi adapters will take care of that but you just have to find the right connector on the end.

As for roms, well you're not supposed to ask where to get them from Unless you PM people and ask them privately, the site just doesn't want to get in trouble, also some people have a bit of a moral issue with them. Obviously we all have them, we're just not allowed to disclose where from.
 
Back
Top