WiiRd forum

Wii & Gamecube Hacking => Wii Game hacking help => Topic started by: biolizard89 on April 17, 2013, 08:06:45 AM

Title: Goto/Gosub + If
Post by: biolizard89 on April 17, 2013, 08:06:45 AM
If I have a GoTo or GoSub inside an if, what happens to the execution status in the code handler after the GoTo/GoSub takes place?  Is the following pseudocode for Gecko codes acceptable?

If condition
GoSub x
EndIf
More commands...
x:
More commands...

Since we never executed the EndIf directly, does the code handler still think it's inside an If when it reaches x:?
Title: Re: Goto/Gosub + If
Post by: dcx2 on April 17, 2013, 01:55:34 PM
Gosub code type 68 is meant to be used with Return code type 64, so the end-if would be executed in this case.

For Goto code type 66, you will still be "inside" the if.

Being inside an active if probably isn't a big deal, although I'm sure there are some corner cases where things can go wrong.  The bigger problem is that you must protect your Gosub destination with something so that the code handler doesn't execute it when your if condition is false (or after it Returns)