Project64 Dev Forum

W.I.P Dev => Core => Project 64 1.6.1 Dev => Cheat Development => Topic started by: RadeonUser on October 08, 2020, 02:31:44 am

Title: Cheat History and Undo
Post by: RadeonUser on October 08, 2020, 02:31:44 am
Cheats are something that have always plagued us in PJ64.
I know I'll get a nasty look from Gent for that but it's simply true.

We have had countless users on the forums complaining about how unstable the emulator is or that it stops working at a certain point.
Rarely do we find it's a problem in the emulation but rather a cheat that was turned on and whose value needs to be set (manually, mind you) to a different value to make forward progress.

The "Always Remember Cheats" option is insufficient for this purpose and it is my belief the option has no reason to exist.
Instead what I propose is to keep track of what cheats have been enabled and what values are being changed on a per game basis.

In order to accomplish this we will be adding an additional file to static and native saves.
This file will keep track of enabled cheats, the format will be something like
Cheat Name
Previous Written Value

So, for example Infinite Lives 80053204 04 03
Currently that would be saved as Infinite Lives=True
That method is not sufficient because enabled cheats must travel with the save itself, regardless if they exist within the cheat file or not.
Unticking that cheat would set memory address 053204 to 03 and the cheat would disappear if it is not within the cheat menu.

Now the problem I foresee is having to keep track of the memory address before and after things are executed, to note when the game itself was setting a value and not when the cheat was being set.
In the example I provided we activated Infinite Lives when we had only 3 but the cheat sets it to 4.
If you gain another life the game would try to write a 4 and then the cheat would write over it with a 4.
I would like to keep track of when the game is trying to do things, it's important for a proper undo.

The reason I want that is for a more proper cheat undo.
This is the scenario.
You turned on a cheat to gain an upgraded item.
You did this at the start when you had the regular item.
A simple cheat undo would leave you with the regular item.
However, what if you advanced enough into the story that you should have an intermediate version of the item?
It would be nice to be able to instead "undo" the cheat and be left with the item the game should have given you from the story advancement.

Obviously this is only the case when the item shares the same memory address and only the value differentiates the upgrade.
Maybe I'm thinking too much into this and a normal undo (Set the value before the cheat was enabled) would be sufficient.

What are your thoughts Gent?

Also, I may have missed typing everything out... I had to get up and my mind wandered off several times when writing this.
As does my will to stay awake.