Expressions: Add support for algebra expressions that can replace text.#14515
Expressions: Add support for algebra expressions that can replace text.#14515TryTwo wants to merge 1 commit intodolphin-emu:masterfrom
Conversation
|
I'm still deciding what the best approach is for the new mod system. I was initially thinking If this gets merged, I will be curious to see how it is used! Thanks for tackling this @TryTwo . |
|
There are potential issues in having the variable included in the cheat code itself:
I apologize for critiquing this when I previously gave it a thumbs up. Footnotes
|
When you change the variable, the code will be edited with an updated variable. There's no copying. Each code is given a new member variable raw_code, so it can hold both the expression and the gecko version that is applied.
I don't know anything about RA whitelisting. You'd have to explain more. Are you talking about Dolphin options being linked to a gecko code, or just locking everything in the gecko code except for variables? You could probably do that second one, so variables have to affect a code in a defined way. Looking at it again, it may be better for me to have variables use the ini system key, value pairs. Then the raw code becomes constant and can use the ini key/values. |
|
This feels like a convenience capability, nothing more and that's why I was ok with it. I see it as being useful to simplify things for end users before a more generic system comes along. So for example a FPS code that used this table would instead just have a variable to tweak. Full end to end FPS mods like what @SuperSamus wants need a more complex system. Like what I have outlined with the mod system which will have setting interaction, a convenient UI, and the state stored independently from the code itself. |
41ac5ff to
d587fa0
Compare
I added a new Math Expressions class that can do algebra from a text string, then replaces itself with the answer in string format. The idea is to make gecko codes with user-modifiable values easier to modify. This uses the expr.h file, which always processes values as double, then converts it to the desired value.
For example ( Thanks to @SuperSamus ):
{ FPS = 60 }
04111111 { float 1 / FPS }
00222222 000000{ u8 FPS / 60 * 7 - 1 }
The first line is optional and always resolves into variables.
I can adjust the syntax if desired. I also wasn't sure if it should be in its own file, or the Expression.h file (made for breakpoints).
I've also done work on the gecko cheat side of things. It can save/load/work correctly, and saves the expression-style code to the ini, so it can be loaded back into the UI later and adjusted by users.
I was speaking with @iwubcode and wasn't sure if this idea could be leverage later for other mod customizations. I wrote it for this specific use case for now, but shouldn't be hard to extend. If we get a more robust mod system, maybe the gecko code itself can be more hidden with just user-facing options being presented.
Can be tested with this PR (use portable mode): #14518