EmuNewz Network

Full Version: What is the Best Programming language for emulating a console (like PSP)?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
im really curious on how do people make those programs like JPCSP or PCSx2 and want to know how do they make it, and what is the best Programming language out there for emulating. Please tell me the BEST answer. Now i know Jpcsp is created with java programming - language. but what about PCSx2. Pcsx2 is (in my opinion) better in performance and FPS, so is Pcsx2 created with java language too? or is it created with .. say uh C# or C++ or C or what ever? Please tell me the best answer, I wanna learn those programming languages ( I heard that PCSx2 is made with C, is that true?).... thanks a bunch
pcsx2 is c++, some c# and ASM here and there, pcsx2 really has a few advantages, one being that the plugins are developed by a whole set of different people (some people think the plugin system is a downside though), then there is the pcsx2 core (considered the official team), so when you put it all together pcsx2 has/had a huge team, each person works on their area of specialty and sometimes re-written or improved by new members for example the SuperVU/MicroVU.
That being said pcsx2 has been in development since 2004-2005ish, when it was around Jpcsp's age in development it only ran 2-11fps as you can see in this old screen shot I have ((this was when first discovered the NLOOP hack) and we were testing it in very early betas)
[attachment=9202]

As for developing an emu I would assume it takes a lot of reverse engineering when there is little information on the system, the first thing is to find out what each component does, see if there are any public docs available, if not then you have to figure out how / why it does what it does and how to get the PC to reproduce that usually with a very slow interpreter (then later add in a recompiler) , luckily in pcsx2's case the SPU or sound card was basically the same as the old psx console, the rest of the system was a nightmare though since the ps2 was a powerhouse compared to most PC's in its time (even now it would be impossible for the top of the line modern pc to emulate the ps2 in realtime), the ps2 also had very little documentation and had to be parted together usually by trial and error.

Same goes for Jpcsp, since console makers are getting smarter and using all kinds of encryption that adds an extra step to finding out the workings, I'm not sure why the devs choose Java, but I assume it's because it's what programming language they understand (in human terms, you can't speak/write Japanese/Chinese if you haven't learned them first), or perhaps Java was just the best way to quickly emulate the system because of the JVM, Java does have some advantages though since it can take advantage of dual/quad core processors, without as much work, where in emulators like pcsx2/dolphin multi-threading is quite difficult to add and difficult to sync, so usually they only use one or two processor cores, one for the GS system and one for the emulator, (MTVU has recently added a ability to use a 3rd core in pcsx2).

Jpcsp would probably be faster in c++ but I assume it would be extremely difficult to port it over in this stage of development. Tongue, but really the first goal of any emulator is compatibility getting it to emulate the system first then after it works good and stable then speed and other improvements can be made to fine tune it.

I think jpcsp works great though gid15, hykem and the other devs have done a great job, jpcsp runs much better then I ever thought it would run when I first joined here, I only have a middle grade PC, and I can get full speed on many of my games now, so speed is really only a issue on lower end computers and some brand video cards and perhaps some of the more demanding games that even have trouble on the real psp.
I am not a programming, but once you understand how computer work you may understand the emulation work. Here is an example:
A PC works like a building; imagine it is the mayor one of a town called PC and the Mayor is the CPU.

First, the building of the Mayor need some corridors where people can walk. Logically, those corridors toke people some place; and on every office buildings exist different departments where each one have some work to do. Those workers are the process. So, those corridors connect all departments and the building it self; this is the motherboard.

So, after one department got job to do, it have to inform the mayor waiting for his approval. Remember that on the motherboard exist different pieces and every one need the Mayor approval; what they do? they must go to the mayor office but for that they need to wait they turn on a lobby called RAM.

After every person is seen by the Mayor they are considered done.

This is a very superficial and simple look of the main work on a computer cause it is much more complex; either way, that example is the most important thing about the computer and how it work.

So about the main question; how do people make those programs like JPCSP or PCSx2?.
First, they have to understand how does work the console they are trying to emulate (PS:1, PS:2, PSP, etc).

Second, start the emulation process; this means make an computer language that toke the game process (Different to a PC process due the different machine are going on) and delivery it to the correct part of the PC that will work it. E.g: Toke the sounds and redirect it to the sound car.

Third, decide on what language emulate it cause the process are on a binary code (That is the language of most CPU) and depending of the OS (Which is the one that communicate whit the CPU) they must work on hexadecimal code, Java, C++, etc.

As i say, this is a very simple concept of the whole subject cause it is much complex. The tip for make a working emulator? Understand how work the console cause you will know about programming but if you don't know how make the console process work on a PC, you are on zero.
Pure assembly if you want speed.
(08-01-2012 09:56 PM)montcer9012 Wrote: [ -> ]I am not a programming, but once you understand how computer work you may understand the emulation work. Here is an example:
A PC works like a building; imagine it is the mayor one of a town called PC and the Mayor is the CPU.

First, the building of the Mayor need some corridors where people can walk. Logically, those corridors toke people some place; and on every office buildings exist different departments where each one have some work to do. Those workers are the process. So, those corridors connect all departments and the building it self; this is the motherboard.

So, after one department got job to do, it have to inform the mayor waiting for his approval. Remember that on the motherboard exist different pieces and every one need the Mayor approval; what they do? they must go to the mayor office but for that they need to wait they turn on a lobby called RAM.

After every person is seen by the Mayor they are considered done.

This is a very superficial and simple look of the main work on a computer cause it is much more complex; either way, that example is the most important thing about the computer and how it work.

So about the main question; how do people make those programs like JPCSP or PCSx2?.
First, they have to understand how does work the console they are trying to emulate (PS:1, PS:2, PSP, etc).

Second, start the emulation process; this means make an computer language that toke the game process (Different to a PC process due the different machine are going on) and delivery it to the correct part of the PC that will work it. E.g: Toke the sounds and redirect it to the sound car.

Third, decide on what language emulate it cause the process are on a binary code (That is the language of most CPU) and depending of the OS (Which is the one that communicate whit the CPU) they must work on hexadecimal code, Java, C++, etc.

As i say, this is a very simple concept of the whole subject cause it is much complex. The tip for make a working emulator? Understand how work the console cause you will know about programming but if you don't know how make the console process work on a PC, you are on zero.

Thx for the comment, but what if I want to Understand those log thingies that always appear when jpcsp crashes? if I understand Java, am i going to understand those logs? or is it far more complex than that?
(08-01-2012 10:43 PM)abood555 Wrote: [ -> ]If I understand Java, am i going to understand those logs?
I make the same question to my self hahahaha.
The only language of "programming" i can handle is the batch one on Windows OS. And i say "programming" cause it is just some english words that an already assembly language use to simplify some stuff. Either way, look at this:
I can handle this: (A batch file to erase some games whitout the installer)
Code:
:UNINSTALLx
IF EXIST unINST.CES ATTRIB -H -S unINST.CES && DEL unINST.CES  || GOTO UNINSTALLx
:REGEDE
ECHO Windows Registry Editor Version 5.00>Del_X.reg
ECHO.>>Del_X.reg
ECHO [-HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\X]
REGEDIT /S "%~DP0Del_X.reg">NUL && ECHO Entries deleted . . .>"%TEMP%\Del_X.CES" || ECHO Registry cant be access . . .>"%TEMP%\Del_X.CES"
DEL Del_X.reg || GOTO REGEDE

But this is like chinese for me: (A batch to compress some files)
Code:
:Data1
set arc=Data1.bin
arc a -ep1 -r -w.\ .\Disk1\%arc% -mprecomp:zl98:d1+srep+lzma:a1:mfbt4:d256m:fb128:mc1000:lc8 "%choice1%\pc\models\*"
if ERRORLEVEL 1 goto arcfail
:Data2
set arc=Data2.bin
arc a -ep1 -ed -r -w.\ -mprecomp:t-jnf:zl98:d1+srep+lzma:a1:mfbt4:d256m:fb128:mc1000:lc8 -dp"%choice1%\pc\levels" .\Disk1\%arc% -x@levels1.lst
if ERRORLEVEL 1 goto arcfail

I can understand some commands like "SET" or "arc"; but the usage of ARC (Is a compressor) on the command line is kind of complicated for me. There's one thing i can told you: If you really want to know about this stuff, you must study it; let your brain do the rest and you will see it is not so complicated.
Reference URL's