[A89] switch/case and KEY_(arrow)s
[Prev][Next][Index][Thread]
[A89] switch/case and KEY_(arrow)s
-
To: <assembly-89@lists.ticalc.org>
-
Subject: [A89] switch/case and KEY_(arrow)s
-
From: "Miles Raymond" <m_rayman@bigfoot.com>
-
Date: Sun, 15 Jul 2001 21:28:58 -0500
-
Organization: HomeTech
-
References: <5.1.0.14.0.20010520173132.03758d78@mail.passagen.se> <5.1.0.14.0.20010520183237.03d34ec8@mail.passagen.se> <5.1.0.14.0.20010520232947.03c54930@mail.passagen.se>
-
Reply-To: assembly-89@lists.ticalc.org
I only program for the 89. I was using a switch case structure:
switch(in_key)
case KEY_DOWNLEFT:
if(y<15)
y++;
case KEY_LEFT:
if(x>0)
x--;
break;
case KEY_UPLEFT:
if(x>0)
x--;
case KEY_UP:
if(y>0)
y--;
break;
case KEY_UPRIGHT:
if(y>0)
y--;
case KEY_RIGHT:
if(x<15)
x++;
break;
case KEY_DOWNRIGHT:
if(x<15)
x++;
case KEY_DOWN:
if(y<15)
y++;
break;
case KEY_F1:
ChangeBlock(x,y,A_REVERSE,A_REVERSE);
break;
case KEY_F2:
ChangeBlock(x,y,A_NORMAL,A_REVERSE);
break;
case KEY_F3:
ChangeBlock(x,y,A_REVERSE,A_NORMAL);
break;
case KEY_F4:
ChangeBlock(x,y,A_NORMAL,A_NORMAL);
break;
default:
Anyway, I kept getting a lot of compiler errors and eventually found in the
docs that the arrow keys such as KEY_LEFT aren't really constants and can't
be used in a switch/case structure. My question is, since I only specify
that I want an 89 program output, can't the compiler insert the constants
for the 89 instead of using the macros or whatever it uses now?
Since the way I set up the switch/case statement is a lot nicer than an
if/elseif structure:
if(in_key==KEY_DOWNLEFT)
{
if(y<15)
y++;
if(x>0)
x--;
}
else if(in_key==KEY_LEFT)
{
if(x>0)
x--;
}
else if(in_key==KEY_UPLEFT)
{
if(x>0)
x--;
if(y>0)
y--;
}
else if(in_key==KEY_UP)
{
if(y>0)
y--;
}
else if(in_key==KEY_UPRIGHT)
{
if(y>0)
y--;
if(x<15)
x++;
}
else if(in_key==KEY_RIGHT)
{
if(x<15)
x++;
}
else if(in_key==KEY_DOWNRIGHT)
{
if(x<15)
x++;
if(y<15)
y++;
}
else if(in_key==KEY_DOWN)
{
if(y<15)
y++;
}
else if(in_key==KEY_F1)
{
ChangeBlock(x,y,A_REVERSE,A_REVERSE);
}
else if(in_key==KEY_F2)
{
ChangeBlock(x,y,A_NORMAL,A_REVERSE);
}
else if(in_key==KEY_F3)
{
ChangeBlock(x,y,A_REVERSE,A_NORMAL);
}
else if(in_key==KEY_F4)
{
ChangeBlock(x,y,A_NORMAL,A_NORMAL);
}
And now I get errors for KEY_UPLEFT and KEY_DOWNRIGHT!? Why aren't these in
the docs?
-Miles Raymond EML: m_rayman@bigfoot.com
AIM: Killer2Ray ICQ: 13217756 IRC: Killer2
WWW: http://www.bigfoot.com/~m_rayman