Revfan9
12-12-2006, 01:35 AM
I have Zasm down, and I am trying to figure out Zscript so my scripts will be more professional, more flexible, etc. So as my first Zscript, I tried to convert my "Moonwalk (Link walks backwards)" script from Zasm to Zscript... Here is what I have.
ffc script Link_Moonwalks
{
void run()
{
while (true)
{
if (Link->InputUp)
Link->Y+=2;
if (Link->InputDown)
Link->Y-=2;
if (Link->InputRight)
Link->X-=2;
if (Link->InputLeft)
Link->X+=2;
void Waitframe()
}
}
}
By everything I have read up on Zscript, it should work fine. However, it doesn't compile. However, my Zasm version worked fine:
SETR d0,linkx
SETR d1,linky
WAIT WAITFRAME
COMPAREV INPUTUP,1
GOTOFALSE A
SETR linky,d1
ADDV linky,2
SETR d1,linky
A COMPAREV INPUTDOWN,1
GOTOFALSE B
SETR linky,d1
SUBV linky,2
SETR d1,linky
B COMPAREV INPUTLEFT,1
GOTOFALSE C
SETR linkx,d0
ADDV linkx,2
SETR d0,linkx
C COMPAREV INPUTRIGHT,1
GOTOFALSE WAIT
SETR linkx,d0
SUBV linkx,2
SETR d0,linkx
GOTO WAIT
QUIT
What did I do wrong? A theory of mine is that I used a different method in the Zasm script (cancel input, then go the other way) and in the Zscript version I just had Link move backwards right on the button press.
But what mystifies me most of all is that it gets an error on void Waitframe().
ffc script Link_Moonwalks
{
void run()
{
while (true)
{
if (Link->InputUp)
Link->Y+=2;
if (Link->InputDown)
Link->Y-=2;
if (Link->InputRight)
Link->X-=2;
if (Link->InputLeft)
Link->X+=2;
void Waitframe()
}
}
}
By everything I have read up on Zscript, it should work fine. However, it doesn't compile. However, my Zasm version worked fine:
SETR d0,linkx
SETR d1,linky
WAIT WAITFRAME
COMPAREV INPUTUP,1
GOTOFALSE A
SETR linky,d1
ADDV linky,2
SETR d1,linky
A COMPAREV INPUTDOWN,1
GOTOFALSE B
SETR linky,d1
SUBV linky,2
SETR d1,linky
B COMPAREV INPUTLEFT,1
GOTOFALSE C
SETR linkx,d0
ADDV linkx,2
SETR d0,linkx
C COMPAREV INPUTRIGHT,1
GOTOFALSE WAIT
SETR linkx,d0
SUBV linkx,2
SETR d0,linkx
GOTO WAIT
QUIT
What did I do wrong? A theory of mine is that I used a different method in the Zasm script (cancel input, then go the other way) and in the Zscript version I just had Link move backwards right on the button press.
But what mystifies me most of all is that it gets an error on void Waitframe().