PDA

View Full Version : where should I start writing a PS2 emu?


psycho_cyclone
November 14th, 2003, 00:21
Hi, I'm a visual C++ programmer, and I'm pretty good at DirectX and OpenGL programming, I really love to write a tiny PS2 emulator myself to run some demos, could you tell me where and how I should start? thanx.

_E_
November 14th, 2003, 00:27
Try getting some PS2 technical documentation from the net. Here is a site for homebrew PS2 demos
http://ps2dev.org/

Taking a look on PCSX2 source might also help
http://www.pcsx2.net

BTW: moving to misc PS2 discussion forum

Yours
-Elly

CpU MasteR
November 14th, 2003, 10:42
If you are really good at OpenGL or DirectX, I would recommend you start a GSplugin (Which is a graphics plugin) if you are that interested...

psycho_cyclone
November 14th, 2003, 22:35
But what good is a new GPU plugin when the emulator has problems? I've bought the FF-X game and I wanna work on it.
would you answer my question please, will i have the chance of getting something from FF-X by writing a great GPU plugin, althought the emulator can't make it work???

scottlc
November 14th, 2003, 23:10
No. But coding your own would take a long time just like PCSX2 is.

bcrew1375
November 15th, 2003, 07:21
Not to mention that the PCSX2 project has many team members working on it. Writing an emulator for a system like the PS2, even just to play demos, would be an incredibly big task for just one person.

Edit: Heh, just to stress my point a little, it's ALREADY an incredibly big task even for the PCSX2 team. :)

zenogais
November 15th, 2003, 07:29
PS2 is not a good place to start man. Start simple like Nintendo or Super Nintendo. It will make things much easier if you really wanna code an emulator, trust me.

RF
November 15th, 2003, 07:37
I say best of luck to you :)
I would have to agree with zenogais though, start with something a bit easier, or do some volunteer work for pcsx2 team and help them along. After if you decide its not for you, by all means go for your own emulator.

psycho_cyclone
November 16th, 2003, 02:31
thanx Reichfuher, thanx everyone,
if i start manage to write a, say, Nintendo emulator, will it help me in understanding and writing a PS2 one? coz i think i'm not really familiar with emulation concepts yet,
bytheway, where can find info on Nintendo, SNES, or maybe PSX systems? which one gives better information for me to start?
Thanxxx.

Clements
November 16th, 2003, 04:19
thanx Reichfuher, thanx everyone,
if i start manage to write a, say, Nintendo emulator, will it help me in understanding and writing a PS2 one? coz i think i'm not really familiar with emulation concepts yet,
bytheway, where can find info on Nintendo, SNES, or maybe PSX systems? which one gives better information for me to start?
Thanxxx.

http://www.zophar.net/tech/tech.phtml

..for tech docs on various systems inc. Snes, NES etc.

Phoenix Flame
November 16th, 2003, 06:13
Yes, it will help you somewhat. If you've never written an emulator before, then programming a PS2 emualtor is NOT the right place to start. A good analogy would be trying to build a bridge from Australia to New Zealand as the first bridge in your career - total insanity.

psycho_cyclone
November 16th, 2003, 23:23
Anyway, I'm going to work on PS2 and I've already got somethings out of it... I know it wouldn't be easy for me, but it's not impossible, is it? if you really think it's impossible tell me not to waste my time. I'm very optimistic about this, i believe i can do something.

zenogais
November 16th, 2003, 23:54
Anyway, I'm going to work on PS2 and I've already got somethings out of it... I know it wouldn't be easy for me, but it's not impossible, is it? if you really think it's impossible tell me not to waste my time. I'm very optimistic about this, i believe i can do something.

Well since your not even familiar with the concepts of emulation the learning curve would be steaper than you can imagine. The Playstation2 is an extremely complex machine, especially to just be learning emulation with. While its not impossible, chances are you'll be in WAY over your head. You may have experience with DirectX and OpenGL, but those really have no relevance to emulation programming unless you're planning on doing a GPU plugin or helping on one. I would still recommend NES or SNES.

RIVAL FORCE
November 17th, 2003, 06:05
yea i agree try doing a snes or nes im still trying todo a saturn emulator but im still stuck so i stopped for a while.now im doing a chip-8 emulator and sofar i managed to get somthing out of my programming skillz but i did get some huge help becouse some one helped me;)

Phoenix Flame
November 17th, 2003, 06:13
I really think you're trying to take on too much. I don't want to sound like a complete bastard but from your other threads you've posted you can't even config the PCSX2 plugins correctly ...

RIVAL FORCE
November 17th, 2003, 22:56
are u saying this to me or psycho_cyclone.:???:

psycho_cyclone
November 18th, 2003, 01:38
in reply to what Phoenix Flame said:

i don't think being not aware of compatability stuff of an emulator program has anything to do with my programming abilities.
thanx anyway,
soon i'll do something, maybe by writing a GPU plugin.

RIVAL FORCE
November 18th, 2003, 04:21
well i wish u the best of luck:)

Chrono Archangel
November 18th, 2003, 04:22
in reply to what Phoenix Flame said:

i don't think being not aware of compatability stuff of an emulator program has anything to do with my programming abilities.
thanx anyway,
soon i'll do something, maybe by writing a GPU plugin.

yeah best of luck. its great to see more people getting involved in the ps2 emulation scene

RF
November 18th, 2003, 04:23
Yep, good luck :)

Phoenix Flame
November 18th, 2003, 05:04
Best of luck to you ...

bcrew1375
November 19th, 2003, 01:28
I wish you the best of luck, I've been programming for 4 years, about 2 in C++. I've been trying to write a Gameboy emulator and I'm finding it very difficult. If you can write a PS2 emulator that does anything, my hat will be off to you.

psycho_cyclone
November 20th, 2003, 01:50
i believe it takes a long time without having a similar experience on emulator programming, so,
i've started programming a PSX emulator, i believe it won't take much time with the whole lot of info out there on PSX. if i manage to complete it, i'll certainly (hopefully!) manage the PS2.
i'll do my best. thank you all for wishing me luck! especially you PhoenixFlame. I wish you luck too. we will make it!

*Rini*
November 20th, 2003, 22:21
Lucky you! I've tried to learn programming a couple of times, it alwasy ends up the same way-I read two lines in a book, I get bored, and I give up.( Actually that's what always happens when I try to do something creative...)

psycho_cyclone
November 20th, 2003, 22:56
tonight i realized that even if i do manage to write a PSX emulator, it'll take a WHOLE lot of time. i've got no time to waste, i know it's dangerous(!!), but i'm switching to PS2 emulation.
i've been a programmer for 10 years. i started with GW-BASIC when i was 10, then QBASIC, Pascal, and now that I'm 20, it's about 4 years that i'm programming with C++ and i'm truly familiar with it.

GOOD NEWS! today i managed to seduce my cousin to get a PS2! he's getting it tomorrow! WOOOW! I'll get my butt glued to his house!!!

GiGaHeRz
November 21st, 2003, 14:38
why don't you try to help with pcsx2 instead of trying to build an emu? you will have to code all what they coded anyway...

psycho_cyclone
November 21st, 2003, 23:35
I'll be so glad if i can help.
but i know nothing about the current status of the project, like the parts that have remained unemulated or other data.
could you tell me what i can do?

Silvereyes
November 21st, 2003, 23:38
that is a good idea gigaherz

Chrono Archangel
November 21st, 2003, 23:45
I'll be so glad if i can help.
but i know nothing about the current status of the project, like the parts that have remained unemulated or other data.
could you tell me what i can do?

Well you should contact one of the PCSX2 author if you need to know where they are at. shadow shouldnt be hard to find he is here often

_E_
November 21st, 2003, 23:47
hrm,...I wouldnt really say that, unless he knows how to emulate using C ,since PCSX2 is written in C not C++

Yours,
-Elly

psycho_cyclone
November 22nd, 2003, 00:45
i've eaten C before starting C++!!
C++ is just an extended version of C, object-oriented and more powerful.
even if i do wanna help PCSX2, i'll have to go through all those hundreds of files, so i think i'd better go through it slowly and figure it out, that's why i'm writing an emu of my own with the help of the PCSX2 code.

BYTHEWAY, i searched everywhere but i couldn't find any info on the format and structure of "ELF Files", i just had to copy it down from the PCSX2 source, where the hell is this info anyway?

psycho_cyclone
November 22nd, 2003, 01:38
as i mentioned before, my cousin is getting a PS2,
i was wondering if i can extract any info from the PS2 and give it to the development team to help. do they need such info? coz i heard most of the problem is because they don't have a PS2 console.

GiGaHeRz
November 22nd, 2003, 01:59
That's why PCSX2 developers want donations: They need money to buy some PS2s to do tests...

AFAIK, there are some ppl that are helping the PCSX2 team doing tests with their ps2...

psycho_cyclone
November 22nd, 2003, 02:22
an off-topic question if you don't mind,
what does "AFAIK" stand for??

Phoenix Flame
November 22nd, 2003, 09:51
AFAIK = As far as I know

ector
November 22nd, 2003, 19:46
psycho_cyclone: Before you start wasting your time, there's no way in hell you are going to be able to write a PS2 emulator if you have never written any other emulator before or have serious amounts of low-level computer knowledge. And if you don't even know what .ELF files are, there's not a chance you know enough yet. Sorry to burst your bubble, but that's reality for ya..

psycho_cyclone
November 22nd, 2003, 22:45
thanx for your encouraging words, but since i was born a computer guy, and i've managed to learn anything in a few days, i'm still into this. i have no idea if i can make it or not, but i'm gonna give it a shot.
i'm such a stubborn kid when it comes to this stuff, you know.

i now know the structure of and "ELF file", but i wanted to know where those emu coders found the info about the file header. it can't be discovered without any info. that's what i wanted to know.

GiGaHeRz
November 23rd, 2003, 03:44
Anything can be reverse-engineered with a lot of time & patience. Or you can also get that info from the confidential docs. ( :p )

ector
November 23rd, 2003, 16:12
Start simple. Do a chip8 emulator, any coder worth his salt can make one in an afternoon (or max a couple of days depending on if you do some really stupid bug that you have to chase :) ). Full information on the chip8 is available on www.goldroad.co.uk (http://www.goldroad.co.uk) and on google (just search).

Exophase
November 24th, 2003, 22:13
... I've done a dynarec emulator for an academic machine named LC-2 (it's like chip8 in intent but it's a little more complicated) entirely in x86 assembly and the very prospect of PS2 emulation still vastly overwhelms me. For you to jump straight into it is ludicrous. ector is right, you're way out of your league.

I admire your enthusiasm but your arrogance can also be blinding. To do a PS2 emulator it's not simply about knowing the right information (and trust me, you'll probably never have adaquete documentation on all of the information), but you have to be very familiar with low level hardware in general. You also must know a lot about optimization techniques for emulation, that is, if you want your emulator to run at even a reasonable fraction of the speed of a PS2 on the very fastest desktop computers in existence.

You seem to expect that with some hard work and dedication you're going to get FFX running on your computer in a short matter of time. You probably won't.

Oh and, elf is a standard object file format. This is another one of those things that you're just kind of expected to know about if you want to get into this..

Anyway, ector is right; but if you don't want to start with something simpler at least talk to emu authors (be humble) and study as much as you can before even thinking to do this. Don't just ask "how do I start writing this" like you did here, either. That's the clearest indication that you're not ready to do this.

- Exo

psycho_cyclone
November 24th, 2003, 23:54
you were right, i just coded some more stuff, and i realized that i had been too optimistic. but i'm dying here with the FFX disk in my hands while i can't play it...
ector was also right, i haven't got a chance. i was just wondering if i can do something my own way, but i realized that even if i do manage to write an emu, i'll have to copy down 90% of the code from PCSX2 source, so actually i haven't done anything myself.
but i still want to know if i'm a good coder or not, so i'll give it shot with chip8 as ector advised.
but one thing that truly disappoints me is that i bought a DVD-ROM only and only for the hope of PS2 emulation, and now it's useless.
i guess all that i can do is to pray for the real coders' success. thanx for your advice anyway.

GiGaHeRz
November 25th, 2003, 00:18
you don't need to programa n emu to be a good coder...
emu writers are more than good coders... they are programming gods, like the OS programmers xD

psycho_cyclone
November 25th, 2003, 00:23
i just decided to write a NES emulator and see how quick i can do it, and i'm not gonna check on any source code, just information. i can't just sit back here doing nothing, maybe coding a simple emulator might help me understand the concepts of emulation.

psycho_cyclone
November 25th, 2003, 00:27
BYTHEWAY,
i did manage to run the BIOS with PCSX2 but i noticed that it's way too slow, i was just wondering,
isn't it possible to switch to a compiler instead of interpreter?
i mean, at least you can cut some slow parts by creating a, say, C++ file that straightly calls the necessary functions. i was only wondering if this can be done...

GiGaHeRz
November 25th, 2003, 00:46
1: there is an EDIT button so dont double-post.

2: the NES is a complex console, the CPU may be somewhat simple, but each cartridge has it's own mapper, so you will have to program hm... 1000 mappers? I don't actually know :p

EDIT: 3: If you disable the interpreter in the CPU config, you are using a Dynamic Recompiler (DYNAREC).

EDIT 2: 4: The ps2 can't be HLE'd because most games use their own "modules", because the libraries that sony made were crap.

EDIT 3: if you wanna make a simple emulator, then why don't you try to code some other simple machine? like the c64 (I have heard that it's a simple computer).

ector
November 25th, 2003, 15:02
Just like the NES the C64 is also a very complex beast..



From my knowledge, the easiest consoles/machines are:

Chip8, ZX Spectrum, Phoenix (arcade machine), probably some more old computers/arcades.

Standard B&W gameboy isn't extremely complex either but it's not trivial.

Exophase
November 27th, 2003, 02:35
BYTHEWAY,
i did manage to run the BIOS with PCSX2 but i noticed that it's way too slow, i was just wondering,
isn't it possible to switch to a compiler instead of interpreter?
i mean, at least you can cut some slow parts by creating a, say, C++ file that straightly calls the necessary functions. i was only wondering if this can be done...

I've never seen that kind of dynamic source generation/compilation done... while it might give you slight optimization advantage it'd be incredibly slow to compile and slow to translate to C for that matter (C++? Are you crazy?)

Most emulators of this level use dynamic recompilation. Technically it's more like dynamic binary translation, but some consider it compilation because it usually involves SOME very basic optimization (reg caching, const caching, flag look ahead optimizations, branch prediction.. etc). In a dynarec blocks of the host CPU's binary instructions are analyzed and converted to blocks of native x86 code which are then executed. In it's most raw form it's pretty straightforward, however x86 emitters still must be written, and then you realize several things that need to be taken care of (memory protection, memory mapped I/O, self modifying code) which screw the complexity/compile time speed/compiled code efficiency terribly. And yet it's still a necessary and complex beast that must be tackled to really get anywhere with something like PS2...

But even with the best dynarec in the world, I doubt most PS2 games will play that well on even top of the line hardware right now. Especially not FFX. Emulation just has a ton of overhead.

An NES emulator isn't necessarily a bad idea, but like others have said you shouldn't take it lightly. At least with NES you won't have to worry as much about optimization and you can start with a few simple games that don't require mappers. And you should definitely look at other people's source and documentation. This is how you learn. You're never going to do something like this on your own.

Right now it seems that you're dying to prove yourself as a programmer. If that's how you feel then emulation probably isn't what you should be looking for. Emulation is usually about working together with other people and involves a lot of trial and error and raw effort, often with little gains in the end. Usually only those that make the best emulators get any real recognition, but it doesn't really matter, because I don't think any emu authors in it for that.

GiGaHeRz, BIOS can be HLE'd with a decent level of success (as is being done.. at least to some extent right now). That's actually pretty substantial.

psycho_cyclone
November 28th, 2003, 01:19
I've started coding a simple emu just to emulate the PS2 Emotion Engine, and i use the TX79 instruction manual, but one thing that worries me is that, how similar IS this TX79 to the EE? i've heard that they're 95% similar, is it true?
i searched everywhere for a R5900 manual, but i couldn't find any, does that TX79 manual really suffice?

zenogais
November 28th, 2003, 01:54
I've started coding a simple emu just to emulate the PS2 Emotion Engine, and i use the TX79 instruction manual, but one thing that worries me is that, how similar IS this TX79 to the EE? i've heard that they're 95% similar, is it true?
i searched everywhere for a R5900 manual, but i couldn't find any, does that TX79 manual really suffice?

You seem to be changing your mind alot. I still think that the Emotion Engine is waaay too complex for a first-time emu author. Just stick with the NES emulator, its relatively simple and its a great project to start on because you can learn as you go and theres more documentation and source code on the internet than you'll ever need. Playstation2 is the wrong place to start, prove to yourself and if you want us that you can emulate anything first. Then move on to a more complex project, you'll be very glad that you started simple. Also I'm hoping that you know something about assembly language because it will make emulating anything much much easier. I read an entire book on assembly language after I had started my first emu and it was moving very fast, it made the project go so much faster, it was unbelievable(My first emu was a simple SNES emulator). We're all trying to help you, but please take our advice. Start small, its worked well for alot of other people.

Exophase
November 28th, 2003, 21:10
I've started coding a simple emu just to emulate the PS2 Emotion Engine, and i use the TX79 instruction manual, but one thing that worries me is that, how similar IS this TX79 to the EE? i've heard that they're 95% similar, is it true?
i searched everywhere for a R5900 manual, but i couldn't find any, does that TX79 manual really suffice?

It has an R5900 with MMI, looks close enough for you... :P

TX79 doesn't have vector units of course.

- Exo

psycho_cyclone
November 28th, 2003, 21:51
i know, i know it's too complicated, but i didn't say i'm gonna write a working PS2 emulator, i just loooove trying to code that beautiful instruction set, deal with registers and stuff! it's just so exciting for me, i can't resist! i'm just trying to code the full instruction set in my own way, and who knows? maybe i manage to do something more... i know it's way too optimistic, but i'm doing it for fun.
anyway, thanx for your advice fellas. hope we soon get to play those nasty PS2 games on our beloved PCs.