Emuforums.com

Go Back   Emuforums.com > PSX Emulation > Misc PSX Discussion
Home Register Downloads FAQ Members List Calendar Arcade Mark Forums Read

Reply
 
Thread Tools Display Modes
Old May 31st, 2003, 17:40   #1
null_pointer
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:
  • P.E.Op.S plugin sources
  • Pete's docs on the PSEmuPro plugin interfaces
  • pSyChOjAk & Shunt's PSinex R3000A.c interpreter source file
  • Joshua Walker's Everything You Wanted to Know about the Playstation...
  • IDT MIPS Reference Manual (for the R3000A)
A few days ago I set up a Visual C++ project and began work on a simple interpreter based on the references and some previous experience with a SNES emulator (which never made it past the CPU interpreter stage, so don't ask).

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!
null_pointer is offline   Reply With Quote

Advertisement [Remove Advertisement]

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT +1. The time now is 22:51.

© 2006 - 2012 Emu Forums | About Emu Forums | Advertisers | Investors | Legal | A member of the Crowdgather Forum Community


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.