I ran into a problem with the program I'm making, where you move a dot around(the one from my last post). I was putting limits so you can't move past the screen, but now I can't move left or up. Right and down still work for me. Can anyone tell what's wrong?

code::

#include<stdio.h>
#include<math.h>
#include<stdlib.h>

#define ENTER '\r'
#define UP 72
#define DOWN 80
#define LEFT 75
#define RIGHT 77

main()
{
int key,xval,yval;

xval=40;
yval=12;

clrscr();
printf("Use the arrow keys to move the dot, ENTER to quit: ");
gotoxy(xval,yval);
printf("*");

while(key!=ENTER) {
key=getch();
if(key==0)
key=getch();
else
break;
gotoxy(xval,yval); /*added this line after finding it was the key*/
printf(" ");

switch(key) {
case UP:
while(yval>2) {
gotoxy(xval,--yval);
break;
}
case DOWN:
while(yval<25) {
gotoxy(xval,++yval);
break;
}
case LEFT:
while(xval>2) {
gotoxy(--xval,yval);
break;
}
case RIGHT:
while(xval<78) {
gotoxy(++xval,yval);
break;
}
}
printf("*");
}
}