what type of processor emulation does ppsspp use?
|
02-06-2016, 11:09 PM
Post: #1
|
|||
|
|||
what type of processor emulation does ppsspp use?
from what i know there are 3 types :
Interpretation Dynamic recompilation Static recompilation anyway, im curious as to which of these ppsspp uses, and which would be the best if im interested in starting my own psp emulation project thanks in advance |
|||
02-07-2016, 06:27 AM
Post: #2
|
|||
|
|||
RE: what type of processor emulation does ppsspp use?
Dynamic recompilation. The problem with static recompilation is that some games modify their own code. Static recompilation really only works if you know you have all the code upfront and know it can't change.
Static recompilation with some degree of dynamic recompilation is possible, though. You might even be able to get away with only doing it when the icache is cleared, but I'm not sure that'd be safe all the time. We also have an interpreter. It's used on platforms (like iOS) where the jit cannot be used. Note that on most devices, performance issues are not processor emulation related - they're typically graphics emulation related. That doesn't mean it won't be great to find a more efficient way to emulate the processor - but don't expect that to be enough to make e.g. God of War run at full speed on old devices. If you're concerned about accuracy - PPSSPP generally times each cycle, but doesn't get interlock delays right (it doesn't even try.) But ultimately, if you're writing your own emulator, you might want to start with an interpreter. It's the easiest way to tell if you've messed up. Jits will crash in hard to debug ways when you mess up, and so will statically recompiled code. I also recommend using pspautotests as a reference. -[Unknown] |
|||
02-12-2016, 05:49 AM
(This post was last modified: 02-12-2016 05:57 AM by grief3r.)
Post: #3
|
|||
|
|||
RE: what type of processor emulation does ppsspp use?
(02-07-2016 06:27 AM)[Unknown] Wrote: Dynamic recompilation. The problem with static recompilation is that some games modify their own code. Static recompilation really only works if you know you have all the code upfront and know it can't change. I've got another question, ive been looking through a few games ISO's to see how they are structured, and i stumbled upong this "modules" folder, with libraries that seem to be compressed using some kind of sce header (ie libmt19937.prx ), they seem to be static libraries that get linked during run time, was wondering if there's any source code that deals with this decompression i think that should make it possible to interpret any given instruction from any given game, since you have the eboot which contains some code, a bunch other prx on some other directory with more code ( not all games seem to have this but some do) , and these libraries under the modules directory that i can't seem to figure out how to find what code they contain as far as games self extracting code goes , i imagine that's already handled by the instructions already hard coded into the game |
|||
02-12-2016, 06:30 AM
Post: #4
|
|||
|
|||
RE: what type of processor emulation does ppsspp use?
I can't really help with the library decryption.
But, I can tell you some of them are kernel libraries and some are user libraries. Additionally, most of these are libraries that are shared (to some degree) across games - sometimes different versions (e.g. the mpeg libraries come in a few different variants.) All of the libraries are dynamic, though, as far as I'm aware. They (like game binary) are relocated on load, and can dynamically link to each other - functions and variable references. Some games (like God Eater games, Metal Gear games, Yu Gi Oh games, and Valkyrie Profile off the top of my head) will load and unload modules for different sections of the game, dynamically. For example, I think one game even uses a different prx for each enemy or group thereof. Note that games can (and DO) also load files (or portions thereof) in directly, for "static libraries" that don't need relocating. It's just that prx files go through the firmware and get relocated. Just think of it this way as far as static recompilation / self modifying code - Let's say that I have mips code that looks like this: lui a0, 0x4013 ori a0, a0, 0x3333 mtc1 f12, a0 That's basically the code for C: float f = 2.3f; On x86, it's going to look different. It might end up: mov eax, 0x40133333 movd xmm0, eax Now let's say that the game says, "the player has moved, so my constant should be 2.31 instead of 2.3 now." So it modifies the second instruction only, changing it to: ori a0, a0, 0xD70A How does that modify the Intel code? That's easy, you say, it translates to modifying the constant. But, how does it do this? You need a compiler to understand how the change in the mips code will change the different code generated by static recompilation. And my simple example above isn't the only case. It could even change which register the constant is loaded into. -[Unknown] |
|||
02-12-2016, 04:39 PM
Post: #5
|
|||
|
|||
RE: what type of processor emulation does ppsspp use?
what is the point of importing a kernel library tho? unless it's some kind of patch, as far as i know all the kernel related stuff is already implemented in the PSP internals
and also curious, if some of these are kernel, if they have their own NID and all that fancy stuff |
|||
02-12-2016, 05:51 PM
Post: #6
|
|||
|
|||
RE: what type of processor emulation does ppsspp use?
(02-12-2016 04:39 PM)grief3r Wrote: what is the point of importing a kernel library tho? unless it's some kind of patch, as far as i know all the kernel related stuff is already implemented in the PSP internalsHi there, The Kernel or any of the libraries are all copyright of Sony, and so are illegal to copy or use, in any way or form. Hence why the PSP's Fonts are not used as even those are copyrighted. |
|||
02-12-2016, 06:17 PM
(This post was last modified: 02-12-2016 06:33 PM by grief3r.)
Post: #7
|
|||
|
|||
RE: what type of processor emulation does ppsspp use?
(02-12-2016 05:51 PM)KingPepper Wrote:(02-12-2016 04:39 PM)grief3r Wrote: what is the point of importing a kernel library tho? unless it's some kind of patch, as far as i know all the kernel related stuff is already implemented in the PSP internalsHi there, oh i can assure you i haven't messed with these libraries at all, in fact i could care less how sony implements them, i just happen to have read this information on the internet ( nids,etc) and am curious about the internals since i do plan to start a psp emulation project in the future, and there has to be a way to bypass this restriction if they are illegal to use tho, then how can it be legal to emulate them? |
|||
02-12-2016, 08:02 PM
(This post was last modified: 02-12-2016 08:10 PM by Bigpet.)
Post: #8
|
|||
|
|||
RE: what type of processor emulation does ppsspp use?
(02-12-2016 06:17 PM)grief3r Wrote: if they are illegal to use tho, then how can it be legal to emulate them? Well people were allowed to make "IBM compatible PC"s. You can implement hardware or software to emulate the behavior of existing systems. But you can not just copy the existing software like the firmware verbatim since you'd be violating the copyright of the original author. Just copying the firmware is no different than pirating any other software. You can't just copy Microsoft Office and distribute it to people, but you can make software like Open Office that emulate its behavior and open its files. I guess a better comparison is: Imagine you write a virtual machine software. You can't just ship your virtual machine with a copy of Microsoft Windows, but you could write your own OS that runs software written for windows like ReactOS does. |
|||
02-13-2016, 12:44 AM
Post: #9
|
|||
|
|||
RE: what type of processor emulation does ppsspp use?
As far as kernel modules, these are modules the kernel loads in. They still require memory, so the code is not always loaded - keep in mind, the PSP is a fairly memory constrained system. So for example, games will often load various modules before playing a video, and then unload them once done - playing a video consumes a good chunk of memory.
The kernel modules are dynamic, that is, they are not all just part of the kernel. PPSSPP acts as if they are, though, and does only some basic tracking of when the dynamic load/unload happens. Technically this is incorrect. Bigpet's examples are great. I just want to add one: imagine you read a book, and it really moved you. Because of this, you decided to write books to move other people in the same way. Although that's very much simplifying the issue, in general it seems like the most basic example of "emulation": trying to accomplish the same goal as something else - but with your own, completely different content (in this case, code.) After all, all books seem to have settings, premises, characters, and the like. How is it legal for them to copy that structure off each other? -[Unknown] |
|||
02-13-2016, 05:59 AM
(This post was last modified: 02-13-2016 07:01 AM by grief3r.)
Post: #10
|
|||
|
|||
RE: what type of processor emulation does ppsspp use?
(02-13-2016 12:44 AM)[Unknown] Wrote: As far as kernel modules, these are modules the kernel loads in. They still require memory, so the code is not always loaded - keep in mind, the PSP is a fairly memory constrained system. So for example, games will often load various modules before playing a video, and then unload them once done - playing a video consumes a good chunk of memory. does ppssp ( or the psp even) ever allocate memory in usermode adress space for these kernel imports then? if a module imported by a game is kernel , it probably shouldn't be allocated near user adress space sch module should still be decrypted tho, how one would emulate encrypted data is beyond me, and it is required for the game to run, as i said before i could care less what the module itself contains ( as in, copy or use is not my motive, but rather, emulate it's mip code using an x86 interpreter), of course this won't be the only barrier, as the journy will be long, but i see light at the end of the tunel |
|||
02-13-2016, 01:38 PM
Post: #11
|
|||
|
|||
RE: what type of processor emulation does ppsspp use?
Not for importing them, typically, although of course the code in these kernel modules can allocate user memory.
Technically, I believe the prx loader can take a partition to load the text and data segments separately, so the data could be loaded in userspace maybe. I don't think this is ever done, if it would even work. -[Unknown] |
|||
« Next Oldest | Next Newest »
|