#define BLUE 1
#define GREEN 2
#define RED  4

main()
    {
     int X;
     int Y;
     int ch;
     int color;
     int mode;
     int columns;
     int page;
     int adapter;

     X = 40;
     Y = 12;

     sccurset(0,0);
     scclear();
     color = 0;

     adapter = scmode(&mode,&columns,&page);
     sccurset(1,0);
     printf("mode = %d, columns = %d, page = %d",mode,columns,page);
     if(adapter)
	screset(3);	/* set in color mode */

     while(1)
        { /* play */
	 char chxy;
	 int fore;
	 int back;

	 sccurset(Y,X);
	 chxy = scread(&fore,&back);
	 sccurset(0,0);
printf("X = %d, Y = %d, char = '%c', >fore = %x, <back = %x; <>=%x                ",
	 		X,Y,chxy,fore,back,color);
			
	 sccurset(Y,X);
	 utinkey(&ch);
	 switch(ch)
	    { /* decode */
	     case '': Y--;
	     	      if(Y<0) Y = 0;
		      break;
	     case '': Y++;
	     	      if(Y>24) Y = 24;
		      break;
	     case '': X--;
	     	      if(X<0) X = 0;
		      break;
             case '': X++;
	     	      if(X>79) X = 79;
		      break;
	     case 'R': color |= RED;
	     	      break;
	     case 'r': color &= ~RED;
	              break;
             case 'G': color |= GREEN;
	              break;
             case 'g': color &= ~GREEN;
	     	      break;
             case 'B': color |= BLUE;
	     	      break;
             case 'b': color &= ~BLUE;
	     	      break;
	     case 'W':
	     case 'w':
	     	      color = 7;
		      break;
             case 'X':
	     	      color = 0;
		      break;
             case '<':
	     	      scattrib(fore,color,chxy,1);
		      break;
	     case '>':
	     	      scattrib(color,back,chxy,1);
		      break;
	     case '0':
	     case '1':
	     case '2':
	     case '3':
	     case '4':
	     case '5':
	     case '6':
	     case '7':
	     case '8':
	     case '9':
	     		color = color * 10 + (ch - '0');
			break;
	     case 'Q':
	     		return;
	     default:
	     		scattrib(fore,back,ch,1);
			break;
	    } /* decode */
	} /* play */
    }