PDA

View Full Version : Rts-like Command Please



Revfan9
03-09-2007, 11:35 PM
I think that the general command we need the most in Zasm is some sort of RTS-like command, like RETURN, RETURNTRUE, RETURNFALSE, RETURNMORE, RETURNLESS. What this does is simple.


if there is a GOTO command, Zasm stores which line number that GOTO command is internally. When RETURN is used, the script goes to the line number right after that last GOTO. RETURNTRUE, RETURNFALSE, RETURNMORE, RETURNLESS could be used with COMPAREV and COMPARER.

How would this be useful? Well, say there is a function where you need to cycle through all 10 enemies on the screen. You can do this now by setting REFNPC to the next enemy, then running the function for that enemy. But, because GOTO will have to be set differently depending on whether the NPC exists or not, that means every enemy will have to have it's own function... If the function is really long and complicated, then that could increase the neccessary size of a Zasm script literally by tenfold.

Not only that, but it's very convenient to use instead of keeping track of lots of line positions or using lots of labels everywhere.

DarkDragon
03-10-2007, 12:25 AM
You can already do this. Save the return address somewhere (such as on the stack) and then use GOTOR when you want to return.

Revfan9
03-10-2007, 01:21 AM
Like I said, for convenience. I know it can be done by keeping track of the address, but it's just simpler to have a RETURN command.