Project64 Dev Forum

W.I.P Dev => Project 64 1.6.1 Dev => Topic started by: RadeonUser on January 01, 2018, 09:15:03 pm

Title: Goal for 2018
Post by: RadeonUser on January 01, 2018, 09:15:03 pm
Hey everyone!

Just leaving a message here to let everyone know what I plan to do this coming year (Likely 3-4 months but hopefully less!)
I've been going through the code trying to make it less crash-prone for plugins like Icepir8's and have been finding code that isn't acceptable.

So I am going into code-review mode and will try to fix up things I notice are wrong.
This doesn't mean I won't look at posts or put out small fixes here and there but it means the majority of my energy will be going into reading, understanding, and replacing code as needed.
This may be as simple as making very similar code into a function (There's a lot of code copied and pasted around) or may involve more of an overhaul than I want to do.

The end-goal? Stability.
It is my vision to have PJ64 never crash to desktop.
If it ever runs into a problem (It can't be helped after all!) it should fall back into a stable state (The rom browser for example) without losing everything.

I will periodically add to this thread when I have time or have actually accomplished something.
Title: Re: Goal for 2018
Post by: RadeonUser on March 07, 2018, 08:15:49 am
I think I'm going to have to redo the settings as a whole very soon.
I've been trying to keep old behavior as much as possible to prevent problems but this in itself is revealing issues with the coding style.

So I'll have to rewrite quite a bit of the settings code for it to play nice.
I may just buckle down and take the easy route of doing things in C++

That's not to say it can't be done in C, it's just that a lot of this is already done for me in higher level languages.
C# would be a dream for example  ;;)
The only potential issue is that C is a lot faster in terms of file i/o
Now, if I were using a newer compiler that'd be less of an issue but we're sticking to VS2010 for the foreseeable future.

So Gent -- Catalog but stow any issues you're having with the files (Cheats, etc...)
I'm in it for the long haul it seems.
Title: Re: Goal for 2018
Post by: RadeonUser on March 09, 2018, 03:04:47 pm
One of the first things that bears fruit from a deeper understanding.

OpenGL plugins should no longer crash (At least on start emulation/end emulation).
Sadly I've not yet had time to work on settings so you'll see crashes from that (It's cheat related, you might be able to suppress them by turning on Remember Cheats)

I've not looked to see if this would fix state loads, resolution changes, etc... yet.
Gent that's for you to test  :-bd

Edit: Added a timeout and a message for when the emulation thread has to be force closed on End Emulation.
For those times when the emulation thread is unresponsive due to plugins or emulation issues.
Title: Re: Goal for 2018
Post by: Gent on March 09, 2018, 04:58:33 pm
Ok last few build have had this Failed to save settings nightmare.

So i have done a quick video showing how once you get it, terminal fek over.

Title: Re: Goal for 2018
Post by: Gent on March 09, 2018, 05:05:32 pm
Even quicker route is to try to use cheats via cheat menu

Title: Re: Goal for 2018
Post by: RadeonUser on March 13, 2018, 05:32:24 am
There were some logic snafus from my part, however while it is better it is not usable quite yet.

The problem I'm running into is that I didn't anticipate the nature of 1.6's cheat implementation.
I truly hope this has been changed in the later versions of PJ64.

1.6 uses the registry to act as a hold/store/general go to for just about anything cheats.
Project64 has two threads, the main thread (The window), and the emulation thread (Where the game runs).
Both access the same area pretty much simultaneously, thankfully accessing the registry is thread safe.
What I created isn't thread safe whatsoever so there's problems opening the file while a write is happening.

So there's two ways I can fix this.
1) Make the thread(s) yield if the file is already in use
2) Redo the logic so reads and writes are only performed by the main thread (Start Emulation and End Emulation for example).

Number 2 will come with the possible benefit of increasing the maximum number of cheats that can be applied.
Why's that? Because accessing the registry as many times as 1.6 was is costly.
This is where I believe Gent came up with the limit of 500 cheats and 100 GS cheats (I'll be honest I don't know the difference, thankfully I don't have to, we have Gent).

So I will be doing my best to come up with a solution that is not bogged down by constant file reads and writes (registry included, because even if it's cached by the operating system this is still costly)

This isn't the only place where I need to make changes either.
Changing the size of the window, moving it around, etc... is all written to file/registry as it occurs.
I won't go into how much this makes my head hurt -- Honestly, you don't need to know!

So this is my current project, STILL working on the settings overhaul!
Gent - Kill me now  :'(
Title: Re: Goal for 2018
Post by: RadeonUser on March 15, 2018, 02:29:55 am
Well, a deeper look at cheats reveals I misunderstood how they work.
That was a good thing since I was dreading the nightmare.

So yes I made some assumptions, dreaded the worst, and found out the world isn't quite as bleak as I thought it was.
Title: Re: Goal for 2018
Post by: RadeonUser on March 15, 2018, 04:38:02 am
I... will not go into what the problem was.
Simply know as I programmer I am deeply embarrassed.

I've decided to keep a simple error message for when things go bad, that way I can be told what file was creating an error.
I will upload a build into the untested section of the forums at some point.