Ejemplo n.º 1
0
int oznkeyhit(void)
{
    static unsigned c;
    for(;;)
    {
      if(!ozkeyhit()) return 0;
      c=ozgetch();
      switch(c)
        {
            case KEY_POWER:
            case KEY_MAIN:
            case KEY_TELEPHONE:
            case KEY_SCHEDULE:
                ozexitto(c);
            case KEY_MYPROGRAMS:
                exit(0);
            case KEY_BACKLIGHT:
                oztogglelight();
                break;
            default:
                ozungetch(c);
                return 1;
        }
    }
}
Ejemplo n.º 2
0
int kbhit(void)
{
	static int k;
	static int l;
	while((k=ozkeyhit()) && (l=(NO_KEY==ozkeyread(0))));
	return k && !l;
}
Ejemplo n.º 3
0
pull()
{
	ozsetactivepage(1);
	ozcls();
	if(speed==0)
	{
		srand(ozmin()+60*ozsec());
		switch(rand()%3)
		{
			case 0: speed=1; break;
			case 1: speed=2501; break;
			case 2: speed=5001; break;
		}
	}
	srand(ozsec()+60*ozmin());
	switch(rand()%4)
	{
		case 0: house=LEFT; break;
		case 1: house=RIGHT; break;
		case 2: house=RIGHT; break;
		case 3: house=LEFT; break;
	}
	if(house==LEFT)
	{
		for(x=0, y=79 ; y>0 ; x++, y--)
		{
			if(ozkeyhit())
			{
				switch(ozngetch())
				{
					case KEY_LEFT: gunpos=LEFT; break;
					case KEY_RIGHT: gunpos=RIGHT; break;
					case 32:
					{
						if(shots>=1)
						{
							fire(gunpos);
						}
						break;
					}
					case KEY_LOWER_MENU:
					case 'h':
					{
						help();
						break;
					}
				}
			}
			ozcls();
			drawgun();
			ozdelay(speed);
			ozcircle(x,y,2,4|1);
			ozswapactivedisplay();
		}
	}
	if(house==RIGHT)
	{
		for(x=238, y=79 ; y>0 ; x--, y--)
		{
			if(ozkeyhit())
			{
				switch(ozngetch())
				{
					case KEY_LEFT: gunpos=LEFT; break;
					case KEY_RIGHT: gunpos=RIGHT; break;
					case 32:
					{
						if(shots>=1)
						{
							fire(gunpos);
						}
						break;
					}
					case KEY_LOWER_MENU:
					case 'h':
					{
						help();
						break;
					}
				}
			}
			ozcls();
			drawgun();
			ozdelay(speed);
			ozcircle(x,y,2,4|1);
			ozswapactivedisplay();
		}
	}
	if(random==1)
	{
		speed=0;
	}
}
Ejemplo n.º 4
0
static unsigned ozkeyread(byte read)
{
	static byte isshifted=0;
	static byte is2nded=0;
	static byte iscapslock=0;
	static byte shiftheld=0;
	static byte secondheld=0;
	static unsigned int c;
	static unsigned int origc;
/*	  termputch(isshifted?'+':'-'); */
	if(!read && !ozkeyhit()) return NO_KEY;
	origc=ozgetch();
	c=origc&0xF0FF;
	switch(c)
	{
		case KEY_LEFT_SHIFT & 0xF0FF:
		   if(is2nded)
		   {
              iscapslock^=1;
              is2nded=0;
			  return NO_KEY;
		   }
		case KEY_RIGHT_SHIFT:
/*			 termputch('!'); */
           isshifted^=1;
		   return NO_KEY;
		case KEY_2ND:
           is2nded^=1;
		   return NO_KEY;
		case KEY_DEL:
		   c=8;
		   break;
		case KEY_LOWER_ESC:
		   c=27;
		   break;
		case KEY_LOWER_ENTER:
		case KEY_UPPER_ENTER:
		case '\r':
           if(c=='\r' || enterisreturn)
           {
              if(mapreturn) c='\n'; else c='\r';
           }
		default:
		   if(!read) break;
		   if(isshifted || origc&MASKSHIFT) shiftheld=1; else shiftheld=0;
		   if(is2nded || origc&MASK2ND) secondheld=1; else secondheld=0;
		   c&=0xF0FF;
           if((shiftheld || iscapslock) && c<128 && isalpha(c)
               && !secondheld)
               {
                    if(shiftheld ^ iscapslock) c+='A'-'a';
               }
           else if((shiftheld /* || secondheld */) && c=='-')
			   c='_';
           else if(shiftheld && c<128 && isdigit(c))
			   c=")!@#$%^&*("[c-'0'];
           else if((/* secondheld || */ shiftheld) && c=='.')
			   c=':';
           else if((/* secondheld || */ shiftheld) && c==',')
               c='\'';
		   else if(secondheld)
		   {
			  switch(c)
			  {
				case 'e': c='*'; break;
				case 'i': c='?'; break;
				case 'o': c='"'; break;
				case 'p': c=';'; break;
				case 'q': c='+'; break;
				case 'r': c='/'; break;
				case 't': c='='; break;
				case 'w': c='-'; break;
                default: c|=MASK2ND; break;
			  }
              if(shiftheld) c|=MASKSHIFT;
		   }
           else if(shiftheld)
           {
               c|=MASKSHIFT;
           }
	 }
	if(!read)
		ozungetch(origc);
	else
        isshifted=is2nded=0;
	return c;
}