RATools icon indicating copy to clipboard operation
RATools copied to clipboard

disable_when() not generating ResetNextIf

Open BacklogOdyssey opened this issue 2 years ago • 2 comments

Hello!

I'm utilizing the disable_when() function to pause lock an achievement with the hopes that defining the "until" comparison would generate a ResetNextIf to reset the pause. However, when the code is generated, it's instead adding the reset to an alt group:

e.g. trigger = completedArea(gameArea_OilArea) && disable_when(lostLives(), notInLevel())

image

Here is the desired logic:

image

Also, is there a way to explicitly define an AndNext/OrNext chain?

BacklogOdyssey avatar Jun 20 '23 22:06 BacklogOdyssey

That's just the optimizer being helpful. The only hit is on the Pause If, so the Reset Next If can be replaced with a Reset If, but then it has to be in a separate group to prevent being affected by the Pause If.

Similarly, the And Nexts on lines 1 and 3 are completely unnecessary. Unless the final line in an And Next chain has a hit count or a behavioral flag (like Reset If), then the And Next serves no purpose.

The optimizer has restructured your requirements so they'll run on really old versions of RetroArch (And Next was added in 1.7.7, and Reset Next If was added in 1.9.4). The result is still logically the same.

There currently isn't any way to force an And Next or Reset Next If if the compiler deems them unnecessary. An Or Next can be forced using the __ornext(...) hint function to prevent creating alt groups in that scenario, but I have yet to find a case where it's preferable to force an And Next that the optimizer has eliminated. As for the Reset Next If, I'll have to think about that. RetroArch 1.9.4 is two years old now, so it could be reasonable to not be quite as aggressive in the backwards compatility optimizations.

Jamiras avatar Jun 26 '23 04:06 Jamiras

That makes sense, and I appreciate the clarification! With regards to the AndNext, it might just be me being overly cautious, especially when two separate addresses are related and specific combinations translate to specific game states.

BacklogOdyssey avatar Jun 26 '23 16:06 BacklogOdyssey