|
|
|||||||
| About Us | Register | FAQ | Members List | Calendar | Mark Forums Read |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
Registered User
Join Date: Jun 2001
Posts: 14
|
Writing an emulator from scratch
I have been interested in writing my own PSX emulator for some time, but I am not sure where to start. Perhaps the community could at least point me in the right direction.
I have Visual C++ and know something about C++ programming and a little of x86 assembly. Naturally, I began searching on the 'net for docs about the PSX hardware and of course any emulator sources I could get my hands on. I have the following:
There are a few big questions that need to be answered before I can finish the CPU core and begin hooking up the PSEmuPro plugin interfaces and other miscellaneous hardware code. Can't really test games until this is done, and I can't find out the answers to these important questions until I can test games... How much of the CPU does an emulator actually attempt to emulate in order to play most commercial games? Does an emulator really need to worry about all the cycle counts and how they are modified by caching/pipelining? What about exceptions on unaligned memory accesses - do we really need to emulate those exceptions or do they never occur in most PSX games? Also, I want to do this correctly from the beginning. I want the emulator including the CPU core to be portable. The only thing is that I don't know enough about the C bit operations and about how CPU cores are written in machines whose endian-ness is opposite the thing they are emulating. When setting up the project, I created a sort of hierarchy within the project of separate files whose sole purpose is to contain all the non-portable code from the project. So whenever some non-portable code needs to be executed in the CPU core, the core would call the function from the portability headers whose definition differs depending on the platform on which the emulator is being compiled. That's pretty obvious, of course, but the question is which functions need to be placed into those portability headers. I know that the byte array representing the PSX's main memory needs to have the same values for any given point of any given game regardless of what byte format, integer representation, and so on the PC that's running the emulator is using. So how do I maintain this state? Do bit shift operations produce identical results regardless of the endian-ness of the hardware running the emulator? Or do I need to shift the individual bytes according to the byte order of the hardware running the emulator? Do I really need to convert every value read using lh, lhu, and lw before doing the operations (e.g., multiplication) on a big endian machine and then convert the results back into little endian format before saving them back into the registers? Or would it be simpler and more efficient to just code special versions of each operation using the C bit operators instead of the C non-binary math operators? Anyway, I'll probably end up finding many of these things on the 'net and through my own experiences, but if you can contribute any tips or corrections - or even additional source code - I would be very grateful. I'm not looking to copy or port any code; I just want it so I can figure out some things about the PSX. Thanks for your time! |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|