Next Generation Emulation banner

1 - 9 of 9 Posts

·
Registered
Joined
·
14 Posts
Discussion Starter · #1 ·
Well, okay first i'm going to say this. I'm a programmer. I've been programming for 8 years or so now. In the scheme of things, i realize this doesn't mean much, but i have programmed games, so i know a decent amount about optimizing code.

So please don't flame me too quick before you think.

The way almost any emulator works, is as an interpreter. Its constantly running, in order to basically translate (and i use that in a very loose way) the PSX instruction sets and therefore the data from the discs into a form that can use for windows.

Now, like i think i've said before on other threads in this forum, i have no experience when it comes to emulation. I can create complicated things like encryption and decryption programs, 3d games, etc... And i've been wanting to start my own emulator for a while now, right now i have my eyes set on the DS, but am having a little bit of difficulty finding the resources (I'd rather not rip apart my DS and do several evil things to its circuits to find out the things i don't know quite yet) i know when i'm on to something though, and i think i am with this... idea.

And, maybe i'm wrong... but without further ado.

I am 98.9% sure that it would be possible to make an emulator, that would actually take an image of the game, and convert it directly to an x86 executable program. mostly i'm just seeking the extreme tech savvy opinions on this, but regardless of whats said, i'm going to try for it. I just wanted to share in case it puts any ideas into the authors of PCSX2.

Certain code the playstation 2 uses to get information from games requires way to much processing time on PC. 128bit registers & 64bit registers especially. So why not convert the game ahead of time to only use the 32 bit registers on our x86 system?

For the most part no singular value or number will ever need 128 bits... Unless your calculating the speed of light, the 11 dimensions of string theory and how many hairs are on your pet monkey bobo all within the same number, 128bits is a huge huge amount... which is mostly why archetecture hasn't been moved to the 64bit platform for PCs until recently. 9223372036854775808 is a big number, and thats just the big 64 bit number :p... or 9223372036854775807 when considering 0 as a value... but anyways....

Without the overhead, the amount of processing time that would be more open to the games code itself would be increased, potentially drastically depending on the architecture (once again, i'm planning on a DS emu, not PS2, but i like to spread my wealth of creativity)

point being...
I'm onto something unlike Mr.USE-DOS! right?
Someone quickly validate me...
And also, tell me its not illegal! :)

because i have a question about that too... is it legal? i certainly don't like jail.... let me know...
-shan
 

·
PCSX2 Coder
Joined
·
10,122 Posts
what youve just described is a static recompiler :p


yes they are possible, all the code can be converted before it is run, but with this comes big drawbacks...

The first big drawback is the amount of RAM it would require to load the game into memory, with the N64 which static recompilers were common, it wasnt so bad, but with PS2 you are talking GIGS of data!

The second problem with that is static recompilers are very uncompatable in comparison to other methods, and due to the complexity of the ps2 this would make things very hard to emulate correctly.


As a programmer you should look at the code, you will notice apart from the interpreter we also have a Dynamic recompiler which works like a static recompiler, but converts the code to x86 as it needs to rather than all at once, this way its a nice comprimise between speed and compatability
 

·
Heretic
Joined
·
2,766 Posts
I am 98.9% sure that it would be possible to make an emulator, that would actually take an image of the game, and convert it directly to an x86 executable program.
I guess it might be possible in theory... but its not really an effecient way of emulation... you would have to patch each game seperately (they're all written so differently) and that could be costly. In the long term I think it would be better to try to write an emulator that doesn't 'cheat'.

refraction: I'm not sure, but I think he was suggesting a permanent conversion rather than the on-the-fly recompiler PCSX2 already has.
 

·
PCSX2 Coder
Joined
·
10,122 Posts
Vanit said:
refraction: I'm not sure, but I think he was suggesting a permanent conversion rather than the on-the-fly recompiler PCSX2 already has.
thats basically what a static recompiler does, altho its not saved to an exe on the hard drive.

altho writing to an executable on the hard drive would require extensive knowledge on a 3d engine and making a compiler
 

·
Registered
Joined
·
14 Posts
Discussion Starter · #5 ·
Actually vanit, in theory it would be the most efficient form of emulation possible.... but... i have a theory that refraction knows exactly where i'm going with this, and is probably right about the drawbacks... (actually, i know he is right)

and its nice to know what VuRec and DynaRec do :p

And to avoid the most troubles, it would be wise to have a full, or near full, emulator before even attempting to "compile" the game image into a 32bit exe...

sorry... brainstorming out loud heh... anyways thanks for the feedback refraction... i think since DS games are smaller it might still work...

any other cool opinions would be welcome too...

and i'll take your advice and check out the source... but for the most part other peoples code generally confuses me with things this complicated lol... but i'll see what i can get out of it... hundreds of pages of stuff here i come! heh...

anyone willing to help, can give me some cool links or info about where to get started, please send me info, if i can actually get my lazy bum off the ground with this one (and i've been brainstorming enough its likely) will have due credit given both on my website (coming soon) and in the program itself.

[email protected] is my email

Any advice, good sites on optimisation... etc etc...

oh btw, i chose this forum because its the only one i know of where smart people actually post enough for me to read it( cept for Mr.USE-DOS... but i'll stop bashing him now lol), and within moments i got an intelligent answer... simply amazing...

I'll be checking the Darwin Awards for that guy :p oh wait... i was supposed to stop bashing him

DOH...
 

·
PCSX2 Coder
Joined
·
10,122 Posts
you're welcome, its nice to know somebody has their head screwed on and comes out with "realistic" suggestions :p Yes the DS would be more than possible to put a Static Recompiler too as with most other consoles where the games are under 100mb, it should be very possible, but id read up on them and understand it fully before you attempt it, programming a recompiler is not a very easy job, i daren't even touch the recompilers in pcsx2, they are way to complex for me :p

Optimisation tips hmm, well i cant really tell you much you wont already know having 8 years behind you, all i can say is, use memcpy where you can, its much faster than copying arrays via a loop, use function pointers and function tables, these are faster than switch statements, altho most compilers these days should do it anyway and lastly all that i can think of, program the emulator by the documents as closely as possible, then when youve done that or most of it, look for faster ways to do things, maybe learn some assembly and replace chunks of code with pure assembly, as this will give you much faster code.

other than that, good luck :D
 

·
Registered
Joined
·
14 Posts
Discussion Starter · #7 ·
*sigh* the joys of inline assembly...

Hopefully i won't have to put but a few inline functions of that in my code... Mostly i just want an emu that will run on my comp at work so i can hide my DS behind some random screen heh... right next to aim... Well, i'm going to head out and google up some info about the arm9 etc, take some notes, then call it a night...
 

·
!!!METAL UNCLE!!!
Joined
·
1,951 Posts
Hmmm... There is already one DS emulator in progress. You could probaply ask them where to get started + plus some info and documents? And perhaps with your programming experience, might join them unless you want to make one totally yourself?
 

·
A Square Fan!
Joined
·
592 Posts
In theory is posible. But it's not practical.
The PS2 is TOO complicated. I prefer the actual type of emulation.

EDIT: And that theory would need a first time pass to the data. To translate it to x86. Pufff....... Were would you save this data?. Too much space and too much work. Trust refraction, in DS posible, but in PS2 ............
 
1 - 9 of 9 Posts
Top