Live data from Hacker News

ProjectPSX – A C# coded emulator of the original Playstation

github.com

51–60 of 62 posts

Re: ProjectPSX – A C# coded emulator of the original Playstation

#51
post #32

Earlier quoted context omitted.

A rather useful pattern in C# is to load a blob into a byte array, then inside unsafe code, typecast it to a pointer to well-defined struct. There's also managed ways to do that, but they are slower and involve copying memory.

Any chance you have an example of this pattern you can point to? Also, would the use of Span make it possible to do this without unsafe code?

I use it with DeviceIOControl for interoperating with a driver.

I didn't learn by following someone's example, in my case, I have to work with so many different structs in a high performance use case that I took the time to re-learn pointers. (Haven't used them in years.)

1: Memory is allocated using new byte[bufferSize]

2: That byte[] is pinned to a byte* or void* via fixed

3: The pointer is passed to DeviceIOControl

4: Traditional c-style typecasting inside of fixed

5: Traditional GC cleans up your byte[]. This avoids problems with managed programs that allocate lots of native memory.

I don't know how to use pointers with Span...

BUT: I do similar things with ArraySegment. All that's needed is pointer arithmetic:

ArraySegment arraySegment = ...

fixed (byte* dataArrayPtr = arraySegment.Array)

{

   var dataPtr = dataArrayPtr + arraySegment.Offset;

   var ptr = (SomeStruct*)dataPtr;

}

Re: ProjectPSX – A C# coded emulator of the original Playstation

#52
post #12

Earlier quoted context omitted.

It would conflict with this, though: > 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.

A platform independent desktop UI framework really is the biggest gap in the .NET platform right now, and I think Microsoft knows it. We'll probably see something new on that front soon, I'd wager.

Microsoft for two BUILD conferences now has stated putting more weight into Xamarin tooling for desktop as well as mobile (WPF, Cocoa, and Gtk renderers for Xamarin) is an end goal. They exist as community projects already (find them all on GitHub), and it continues to sound like Microsoft only expects to invest in them so much as they find community interests, and maybe a reason we don't hear a lot of people talking about those projects is there sadly isn't enough non-Microsoft community interest in such tools.

Re: ProjectPSX – A C# coded emulator of the original Playstation

#54
post #38

Earlier quoted context omitted.

It uses System.Windows.Forms and friends. It is a Windows app.

https://www.mono-project.com/docs/gui/winforms/ might allow this to be ported easily though.

While I'm a novice - Looking at this, it doesn't appear to require any porting.

Re: ProjectPSX – A C# coded emulator of the original Playstation

#55
Very, very cool. Good job! I remember tackling emulating the 6502 was a crazy learning experience, but I did that in C++, but definitely there is value in emulating something this complex in C#. Did you choose emulation because it was interesting or it just seemed to provide the best learning environment for what you were looking for? And have you ever dabbled in PSP emulation? I tried my hands years ago and still have a PSP sitting around with some homebrew I made.

Re: ProjectPSX – A C# coded emulator of the original Playstation

#56
post #38

Earlier quoted context omitted.

It uses System.Windows.Forms and friends. It is a Windows app.

https://www.mono-project.com/docs/gui/winforms/ might allow this to be ported easily though.

winforms on mono never really worked, and hasn't been updated in about 12 years https://github.com/mono/winforms

Re: ProjectPSX – A C# coded emulator of the original Playstation

#57

Earlier quoted context omitted.

> We'll probably see something new on that front soon MS has no interest in this space [0]. Your best bet at this moment is Electron or other open source alternates like eto forms. [0] - Scott hunter's .net rocks podcast. The related commentary is past 30 mins from beginning of the show - https://www.dotnetrocks.com/?show=1634

I wouldn't be surprised, now that Microsoft owns Electron, if the new UI framework took a form similar to Electron, but I am sure Microsoft will need to have something with close integration for C#/VB development.

What do you mean microsoft owns Electron, looks all open source https://github.com/ElectronNET/Electron.NET the guy happens to work at microsoft?? can you clarify?

Re: ProjectPSX – A C# coded emulator of the original Playstation

#58

Earlier quoted context omitted.

I wouldn't be surprised, now that Microsoft owns Electron, if the new UI framework took a form similar to Electron, but I am sure Microsoft will need to have something with close integration for C#/VB development.

What do you mean microsoft owns Electron, looks all open source https://github.com/ElectronNET/Electron.NET the guy happens to work at microsoft?? can you clarify?

That is someone's port of Electron to .NET, the official Electron uses JS (and Chrome). Electron is open source, but was created by GitHub, which Microsoft bought.

https://en.wikipedia.org/wiki/Electron_(software_framework)

Re: ProjectPSX – A C# coded emulator of the original Playstation

#59

Earlier quoted context omitted.

What do you mean microsoft owns Electron, looks all open source https://github.com/ElectronNET/Electron.NET the guy happens to work at microsoft?? can you clarify?

That is someone's port of Electron to .NET, the official Electron uses JS (and Chrome). Electron is open source, but was created by GitHub, which Microsoft bought. https://en.wikipedia.org/wiki/Electron_(software_framework)

Ahh ok, thank you for clarifying that, I was rather confused about it all. I didn't know much about the project by I managed to invent a wrong memory that it was always a C# thing, not that insanely bonkers js, node, applications are webpages thing :)

Re: ProjectPSX – A C# coded emulator of the original Playstation

#60
post #4

> ProjectPSX dosn't use any external dependency and uses rather simplistic C# code. 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.

Mesen (for NES) is a good example of a cross-platform C# emulator with a comprehensive debugger UI: https://www.mesen.ca/

(As long as you have Windows or Linux, that is...)

Post reply on HN