07-26-2010, 12:16 AM
DangerousD: What you're describing is a static recompiler. That's exactly what it does. The translation unit grabs insctuctions, translates them into C code, and then compiles it. The flaw in your mentality is that its easy to port things from one architecture to another. It's not. at all. Especially when you don't have the code for the original game. Translated code from assembly and code a programmer would write look COMPLETELY different. The translated code will be a gigantic goto block that emulates every instruction based on where it is in memory. Normal C code you would write looks like this
the translated code looks like this
Or something like that. That's hard to port. Plus a static sweep is impossible to accomplish because you will translate data into code and then execute data. And you can't execute that because first of all, you can't input with it so youll probably hit an infinite loop. Second, and memory access will be screwed up because you translated data into code. Your idea of porting is much too simplistic. My other post on the last page outlines a few more problems with static recompilation.
And also, pcsx2 has a compiler. And someone that knows about ps2 code won't do any good for a ps2 emulator. It's true. Sony couldn't make an emulator any better than the dev team has. It's all about x86. NOT MIPS ASSEMBLY. EVERYTHING ABOUT EMULATION IS BASED ON UNDERSTANDING THE ARCHITECTURE YOU ARE EMULATING TO NOT FROM AHHHHH!!!!!!!!.
Sorry. I get *really* pissy when people think its as easy as getting a ps2 dev to write an emulator. It's not that easy. Writing a recompiler is all about the emitter into native code for your platform. Take for example the R5900 interpreter. It's in one file. Maybe 25kb. That's small and takes no work. I have an R4000 interpreter that's less than a thousand lines. The emitter is the problem. Theres a huge x86 emitter folder in the pcsx2 common folder that shows just how complicated it is. No having to worry about instruction encoding in an interpreter. There's hundreds on lines in the emitter dedicated to fixing the mod r/m byte for the compiler. No worrying about that in an interpreter. I guarantee you that no MIPS architect will be able to help you with that. Or instruction encoding, prefixes, the problems with variable instruction length, addressing, a thousand other things.
Emulation is not easy. Period. You can't "just write a compiler" or a dynarec. or an interpreter. Or a GS, SIF, SIO, VU0, VU1, FPU, VFPU (***** to emulate, i swear) DMAC, RDRAM SDRAM scratchpad ram graphics swizzle floating points conversions data lengths data conversions memory addressing addressing modes register usage jumps branches pipelines input output data buses....
Code:
for(int i = 0; i < 10; i++) prinf("hi");
the translated code looks like this
Code:
L_0x8000:
MOV( Reg_01, 0);
doFlagAndWhateverElseStuff();
L_0x8003:
call _printf (hello);
doFlagStuffAndWateverElse();
L_0x8005:
cmp (Reg_01, 10);
L_0x8007:
goto *some label*
L_0x8009:
goto L_0x8003;
Or something like that. That's hard to port. Plus a static sweep is impossible to accomplish because you will translate data into code and then execute data. And you can't execute that because first of all, you can't input with it so youll probably hit an infinite loop. Second, and memory access will be screwed up because you translated data into code. Your idea of porting is much too simplistic. My other post on the last page outlines a few more problems with static recompilation.
And also, pcsx2 has a compiler. And someone that knows about ps2 code won't do any good for a ps2 emulator. It's true. Sony couldn't make an emulator any better than the dev team has. It's all about x86. NOT MIPS ASSEMBLY. EVERYTHING ABOUT EMULATION IS BASED ON UNDERSTANDING THE ARCHITECTURE YOU ARE EMULATING TO NOT FROM AHHHHH!!!!!!!!.
Sorry. I get *really* pissy when people think its as easy as getting a ps2 dev to write an emulator. It's not that easy. Writing a recompiler is all about the emitter into native code for your platform. Take for example the R5900 interpreter. It's in one file. Maybe 25kb. That's small and takes no work. I have an R4000 interpreter that's less than a thousand lines. The emitter is the problem. Theres a huge x86 emitter folder in the pcsx2 common folder that shows just how complicated it is. No having to worry about instruction encoding in an interpreter. There's hundreds on lines in the emitter dedicated to fixing the mod r/m byte for the compiler. No worrying about that in an interpreter. I guarantee you that no MIPS architect will be able to help you with that. Or instruction encoding, prefixes, the problems with variable instruction length, addressing, a thousand other things.
Emulation is not easy. Period. You can't "just write a compiler" or a dynarec. or an interpreter. Or a GS, SIF, SIO, VU0, VU1, FPU, VFPU (***** to emulate, i swear) DMAC, RDRAM SDRAM scratchpad ram graphics swizzle floating points conversions data lengths data conversions memory addressing addressing modes register usage jumps branches pipelines input output data buses....