(09-15-2010, 03:52 PM)Livy the pixie Wrote: Hello there. I'm a game enthusiasm and very interested in emulation. My school does not teach me C++. My teacher said that they did it several years ago, but no longer. They think C/C++ is out of date now, and teach us Java/asp.net instead. After seeing many famous PC software such as Windows and Office written in C++, and the majority of console emulators are written in C++ as well, I decide to study C++ by myself. And at last, I become a C++ programmer, although I am just a noob.
My school does the same thing. There is a strong focus on Java and very-little c/c++.
I learned c++ on my own outside of my schools curriculum.
(09-15-2010, 03:52 PM)Livy the pixie Wrote: I've got a job recently, which is 'bout a C++ project. I join the project as an apprentice, with the hope someday, when I master C++, I can write an emulator on my own. But when I ask the seniors in my company whether or not they can write an console emulator, they said that it is completely a different field -- maybe something related to embedded system or processing, and if the company has such project, even experienced programmers as them must study this from the beginning. I'm really disappointed.
most programmers are not good programmers. imo to become a good programmer you need to understand what your code does at a low-level and be able to "think in code" to figure out how to code your algorithm in a way your target architecture can run optimally.
there are many coders that never bother to understand what their code is doing. they just do stuff that works (or use code someone showed them) and continue doing so. these people don't have coding talent, they just are able to get-by.
i think you need 3 qualities to be a good programmer:
1) knowledge and understanding (of your programming language, target architecture, and general algorithms)
2) experience (with your current programming language and programming in general)
3) the love for programming
its a bit surprising, but i think some 'programmers' don't even have the 3rd quality. it seems some programmers just do it to get the job done, but think of programming as tedious (at least this is the impression i get from overhearing my classmates).
(09-15-2010, 03:52 PM)Livy the pixie Wrote: I know that writting an emulator is extremely difficult, depending on the complexity of the hardware to be emulated. Even a weak console as NES requires few developers working in 1 - 2 years. And one such as the PS2 requires many years with contribution of many people, and yet it isn't fully emulated -- many games are not playable. But it does not quench the hope in my breast. I still want to learn how, even if I am never be able to do it.
you're right that an emulator can be complex. The complexity of the emulator depends on the architecture you're emulating and the capabilities of the target platform your emulator will run on.
If for example your target platform does not support features that you're emulating, you have to come up with your own software solutions or work-arounds to simulate the behavior.
I think it is a misconception that just because a system is old, it is easier to emulate. The NES for example is pretty old, but it is pretty challenging to emulate correctly. Although there are 100's of NES emulators out, no NES emulator has 100% accuracy and the most popular NES emulators still fail many homebrew accuracy-tests.
However in order for an emulator to play games you don't need to be super-accurate, just accurate enough to get the results the game wants; this is the thinking that's needed with modern emulators, as we cannot afford to be 100% accurate with everything.
Instead we have to think about how games will use features of the system, and then emulate accordingly.
Of course we try to be as accurate as possible where it matters, but its just that its unrealistic to code something like a 100% accurate ps2; no-one will ever do-so.
I have a NES emu project
I'm working on, and it does take a while before your emulator is in a good enough state to run games. To get the basics coded so that you can run stuff probably takes around a month (part of that time is also spent reading and understanding the specifications of the system, as well as planning out the design of the system); but to get it working good with a handful of games takes much more time. And finally to get it working well with most-games can probably take 1~2 years as you mentioned. Part of the reason for this is that you not only need to emulate the NES console but different games have what we refer to as mappers, which essentially add new hardware which you need to emulate. (the reason for mappers is that the NES wasn't powerful enough to run a lot of the games it has, so game makers used additional hardware inside the actual NES cartridges to add more functionality to the NES; newer consoles don't have this problem since games are CD/DVD-based, and the systems are more powerful)
However there are some systems out there that are relatively easy to emulate. I was able to do the basics of a Chip-8 emulator in about 2 days, and fully finished the emulator in about a week (including Super Chip-8 support).
The Chip-8 is commonly emulated by beginners in order to learn the basics; since its kindof easy its probably a good place to start, but at the same time it never was a real system and thus has some design flaws that make games run weird even though you emulate things correctly. (the chip-8 was essentially a virtual machine that had its own instruction set including instructions to draw to screen and poll gamepad input; it didn't define any realistic cpu speed or screen refresh timings, so because of this you can have games run too fast or flicker a lot...)
(09-15-2010, 03:52 PM)Livy the pixie Wrote: I really want to know where PCSX2 programmers learned to write emulators. I do not think if there is any school that teaches them to do this. Still I don't even know where to begin, what to do in progess, and what I end up with. Can anyone give me some documentations, ebooks, tips... that help me in the first step? Any help would be very appreciated.
I started out by looking at simple parts of pcsx2's source-code and trying to understand how it worked. In the very beginning it was taking a look at pcsx2's frameskip, vu-skip, and framelimiter code, and then eventually rewriting it to work much better (this was ~2 years ago, and since then Jake has rewrote all that code again).
From there i moved on to fpu interpreters, then later vu interpreters, then the recompilers, then finally i knew enough to start my own recompiler project microVU.
This learning process takes time and its not something that happened overnight. When i first started i didn't even know c++, but i knew java and was able to guess how stuff worked.
What i will mention is that with pcsx2 as it is now, you can't really do what i did anymore. I was able to do what i did because back-then pcsx2 had a lot of crappy code; We've already rewritten most of the bad code so its hard to find small isolated crappy-code which you can improve little by little. Most of whats left are the 'hard parts' and require either big rewrites or lots of knowledge to fix.
So i suppose you might want to start out with a chip-8 emulator:
Then extend the chip-8 to be a super chip-8 emulator (its just a few more instructions you need to implement).
After that project, make your way over to a gameboy emulator. I haven't tried a gameboy emulator, but i think its a decent system to attempt after doing a super chip-8 emu.
at some point if you wish to truly extend your skills, you need to read other people's source code and preferably talk with other emu coders to get techniques on how to implement things optimally.
you may have for example implemented something some-way, then later learn there's a much-better way to do so.
but anyways you don't just become a good emulator coder overnight, its an experience that takes time and experience.