174 points · by eatonphil · 7y ago · 58 comments
Very impressive. This makes it more interesting to see how the drawing code and the controls were implemented in addition to the possibility of it being cross-platform if it using .NET Core.
Should be straightforward to port to GTK# or Eto.Forms or something, if one had the inclination.
(As long as you have Windows or Linux, that is...)
- Do you ever find that the Garbage Collector causes noticeable pausing in the emulator?
- Did you do this with 100% managed memory, or do you need to use unsafe code / real pointers?
(Apologies that I didn't read the source code.)
- Do you ever find that the Garbage Collector causes noticeable pausing in the emulator?
The GC dosn't cause noticeable pausing on my setup. Even tho it could allocate less.
- Did you do this with 100% managed memory, or do you need to use unsafe code / real pointers?
In fact it was done without unsafe code or pointers till some of the latest commits. Where i switched to unsafe because performance reasons. On my setup that was arround 10 fps more.
Another thing you can do in C# is leverage stack allocation using structs.
Otherwise, everything looks statically allocated. So there should be no GC collections at all.
There's also managed ways to do that, but they are slower and involve copying memory.
However, for an ancient platform on modern hardware I guess the per-frame budget is plentiful even for an emulator.
The .Net garbage collector is a highly optimized generational garbage collector. Practices like pre-allocating and pooling are discouraged, because most of the time they are premature optimization.
In general, the best way to think about it is to pretend that the garbage collector is a built-in library for pooling and reusing objects.
If, early in your project's lifecycle, you suspect that you'll need to implement your own object pool, just start with stub "Get/Recycle" methods that call new / no-op. You can always swap in a pool later.
(1) instead it could be a runtime that just gives you an interface to the frame buffer somehow and it's up to the integrator to use WinForms/WPF/Qt etc.
There was a time when i had a SDL multiplatform branch but it was noticeably slower so i didn't put much effort on it and it ended deleted.
I mainly focused on the core PSX things and not much on the program itself like the emulator window itself...
As you should. Core functionality always comes first. UI can always be messed about with after, when it 'just works'.
Also, fantastic work, here! :)
> ProjectPSX dosn't use any external dependency and uses rather simplistic C# code.
And for a learning project I think the ability to download the code and get it to run immediately without hunting for dependencies, is a very important property. More important I'd say than complicating the code to make it run everywhere.
Super nice and simple to read - e.g. cpu.cs has the thing that does the actual "MUL" and "MOV" etc op codes. Nice :-)
Thanks :-)
PSX.NET or PSX# would be good.
This might sound weird, but make sure .NET is capitalized otherwise people might mistake your project for a website.