Пример #1
0
int tty_getchar(void)
{
#if !defined(__DJGPP__) && !defined(__MINGW32__) && !defined (_MSC_VER)
	int c;
#ifdef __CYGWIN32__
	fd_set set;
	struct timeval tv;
#endif

	if (tty_fd >= 0) {
#ifdef __CYGWIN32__
		FD_ZERO(&set); FD_SET(tty_fd, &set);
		tv.tv_sec = 0; tv.tv_usec = 0;
		if (select(tty_fd + 1, &set, NULL, NULL, &tv) <= 0)
			return -1;
#endif
		c = 0;
		if (read(tty_fd, &c, 1) > 0) return c;
	}
#elif defined(__DJGPP__)
	if (_bios_keybrd(_KEYBRD_READY))
		return _bios_keybrd(_KEYBRD_READ);
#else /* defined(__MINGW32__) or _MSC_VER */
	if (_kbhit())
		return _getch();
#endif

	return -1;
}
Пример #2
0
//#include <stdio.h>
void TEvent::getKeyEvent() {
  if ( TSystemError::ctrlBreakHit == Boolean(1) ) {
    _bios_keybrd(_KEYBRD_READ);
    TSystemError::ctrlBreakHit = Boolean(2);
  }
  if ( _bios_keybrd(_KEYBRD_READY) == 0 ) {
        what = evNothing;
  } else {
        what = evKeyDown;
        keyDown.keyCode = _bios_keybrd(_KEYBRD_READ);
//printf("keyCode=%04X\n",keyDown.keyCode);
    switch (     keyDown.charScan.scanCode ) {
      case scSpaceKey:
        if ( getShiftState() & kbAltShift )     keyDown.keyCode = kbAltSpace;
        break;
      case scInsKey:
        {
          unsigned char state = getShiftState();
          if ( state & kbCtrlShift )     keyDown.keyCode = kbCtrlIns;
          else if ( state & (kbLeftShift|kbRightShift) )     keyDown.keyCode = kbShiftIns;
        }
        break;
      case scDelKey:
        {
          unsigned char state = getShiftState();
          if ( state & kbCtrlShift )     keyDown.keyCode = kbCtrlDel;
          else if ( state & (kbLeftShift|kbRightShift) )     keyDown.keyCode = kbShiftDel;
        }
        break;
    }
  }
}
Пример #3
0
void keyboard(EVENT_MSG *msg,void *user_data)
  {
  int i;
  static char cz_mode=0;
  char c,d;

  msg;user_data;
  if (msg->msg==E_WATCH)
     {
     *otevri_zavoru=1;
     if (!_bios_keybrd(_KEYBRD_READY)) return;
     i=_bios_keybrd(_KEYBRD_READ);
     d=i>>8;
     c=i & 0xff;
     if (c=='+' && d<55 && !cz_mode) cz_mode=2;
     else if (c=='=' && d<55 && !cz_mode) cz_mode=1;
     else if (c>32 && c<127 && d<=53)
              {
              c=cz_key_tabs[cz_mode][c-32];
              i=d;
              i=(i<<8)+c;
              send_message(E_KEYBOARD,i);
              cz_mode=0;
              }
     else
       send_message(E_KEYBOARD,i);

     }
Пример #4
0
int tty_getchar(void)
{
#ifndef __DJGPP__
	int c;
#ifdef __CYGWIN32__
	fd_set set;
	struct timeval tv;
#endif

	if (tty_fd >= 0) {
#ifdef __CYGWIN32__
		FD_ZERO(&set); FD_SET(tty_fd, &set);
		tv.tv_sec = 0; tv.tv_usec = 0;
		if (select(tty_fd + 1, &set, NULL, NULL, &tv) <= 0)
			return -1;
#endif
		c = 0;
		if (read(tty_fd, &c, 1) > 0) return c;
	}
#else
	if (_bios_keybrd(_KEYBRD_READY))
		return _bios_keybrd(_KEYBRD_READ);
#endif

	return -1;
}
Пример #5
0
void chozeni2(EVENT_MSG *msg,OBJREC *o)
  {
  word s2,s1;
  char ok=1;

  if (msg->msg==E_INIT) return ;
  if (msg->msg==E_DONE) return ;
  if (msg->msg==E_KEYBOARD)
     {
     if (o_aktual==NULL || o_aktual->events[3]!=chozeni2) return;
     if (waktual->id==map_win || waktual->id==tool_bar)
        select_window(sektor_win);
     if (waktual->id!=sektor_win) return;
     s2=vals(5);s1=s2;
     if (s2>maplen) return;
     if (!(*(char *)msg->data))
     switch (*(int *)msg->data>>8)
        {
        case 'H':s1=mapa.sectordef[s2].step_next[0];break;
        case 'P':s1=mapa.sectordef[s2].step_next[2];break;
        case 'M':s1=mapa.sectordef[s2].step_next[1];break;
        case 'K':s1=mapa.sectordef[s2].step_next[3];break;
        default:ok=0;
        }
     else if (*(char *)msg->data!=13) ok=0;
     if (ok)
        {
        if (s1>maplen) return;
        jdi_na_sektor(s1);
        while (_bios_keybrd(_KEYBRD_READY)) _bios_keybrd(_KEYBRD_READ);
        msg->msg=-1;
        }
     }
Пример #6
0
BOOL Keyboard::getkey(char &scancode, char &keycode) { // get next key or NULL
	if (!_bios_keybrd(_KEYBRD_READY))
		return FALSE;	// No key was pressed
	unsigned short key = _bios_keybrd(_KEYBRD_READ); // Fetch the key
	scancode = key >> 8;
	keycode = key & 0xff;
	return TRUE;	// a key was pressed and fetched
}
Пример #7
0
void *nice_input(char *t, char *p, char *d)
{  

  int x1=0,y1=0,x2=79,y2=25;
  bar(x1,y1+1,x2,y2,176,0x01);
  put_title(t);

  box(x1,(y1+y2)/2-1,x2,(y1+y2)/2+1,0x17);
  bar(x1+1,(y1+y2)/2,x2-1,(y1+y2)/2,' ',0x17);

  put_string(x1+1,(y1+y2)/2,p,0x17);
  bar       (x1+1+strlen(p)+1,(y1+y2)/2,x2-1,(y1+y2)/2,' ',0x0f);
  put_string(x1+1+strlen(p)+1,(y1+y2)/2,d,0x70);
  set_cursor(x1+1+strlen(p)+1,(y1+y2)/2);
  while (!_bios_keybrd(_KEYBRD_READY));
  if (_bios_keybrd(_KEYBRD_READY)==7181)
  {
    getch();
    cls();
    char ln[100];
    strcpy(ln,d);                  // d might get collect in next new
    return new_lisp_string(ln);
  }
  else
  {
    bar       (x1+1+strlen(p)+1,(y1+y2)/2,x2-1,(y1+y2)/2,' ',0x0f);
    int key;
    char ln[100];
    ln[0]=0;
    do
    {
      key=getch();
      if (key==8 && ln[0]) 
      {
	ln[strlen(ln)-1]=0;
	bar(x1+1+strlen(p)+1,(y1+y2)/2,x2-1,(y1+y2)/2,' ',0x0f);
	put_string(x1+1+strlen(p)+1,(y1+y2)/2,ln,0x0f);
      }
      else if (isprint(key))
      {
	ln[strlen(ln)+1]=0;
	ln[strlen(ln)]=key;

	put_string(x1+1+strlen(p)+1,(y1+y2)/2,ln,0x0f);
      }      
      set_cursor(x1+1+strlen(p)+1+strlen(ln),(y1+y2)/2);
    } while (key!=13 && key!=27);

    cls();
    if (key==27) return NULL;
    return new_lisp_string(ln);          
  }
}
Пример #8
0
char get_filename(int x,int y)
{
	char text[2],ch,sp,i=0;
	setcolor(BLACK);
	settextstyle(0,0,1);
	if(!(_bios_keybrd(_KEYBRD_READY)==0))
	delay(100);
	setcolor(BLACK);
	ch=_bios_keybrd(_KEYBRD_READ);
	text[0]=ch;
	text[1]='\0';
	settextstyle(0,0,1);
	if(!(ch==13||ch==27))
	outtextxy(x,y,text);
	return ch;
}
Пример #9
0
int GetKey (void)
{
#if defined(UNIX) || defined(RISCOS)
        return getchar ();
#else
	return _bios_keybrd (_KEYBRD_READ)&0xff;
#endif
}
Пример #10
0
SNAKES::move_left()
{
	while(!kbhit())
	{       if(snake.head.x==game.left_boundry)
			snake.head.x=game.right_boundry-1;
		if(getpixel(snake.head.x, snake.head.y)==snake.head.color)
			game.over();

		/* moving snake ahead */
		putpixel(snake.head.x, snake.head.y, snake.head.color);
		snake.head.x--;
		delay(snake.speed);
		/* erasing snakes trailing path */
		putpixel(snake.tail.x, snake.tail.y, snake.tail.color);
		snake.update();
	}
	game.key_pressed=_bios_keybrd(_KEYBRD_READ);
}
Пример #11
0
SNAKES::move_down()
{
	while(!kbhit())
	{       if(snake.head.y==game.bottom_boundry)
			snake.head.y=game.top_boundry+1;
		if(getpixel(snake.head.x, snake.head.y)==snake.head.color)
			game.over();

		/* moving snake ahead */
		putpixel(snake.head.x, snake.head.y, snake.head.color);
		snake.head.y++;
		delay(snake.speed);
		/* erasing snakes trailing path */
		putpixel(snake.tail.x, snake.tail.y, snake.tail.color);
		snake.update();
	}
	game.key_pressed=_bios_keybrd(_KEYBRD_READ);

}
Пример #12
0
static int inkey(void)     // Inputs a character using system level calls.
{
   return (_bios_keybrd( _KEYBRD_READ ) & 0xff );
}
Пример #13
0
int main(int argc, char **argv)
{
	char str[81],compiler[32],*p;
	int i,file;
	FILE *stream;

	node_dir[0]=0;
	for(i=1;i<argc;i++)
		if(!stricmp(argv[i],"/L"))
			logit=1;
		else if(!stricmp(argv[i],"/T"))
			tutor=2;
		else if(!stricmp(argv[i],"/S"))
			tutor=1;
		else strcpy(node_dir,argv[i]);

	p=getenv("SBBSNODE");
	if(!node_dir[0] && p)
		strcpy(node_dir,p);

	if(!node_dir[0]) {	  /* node directory not specified */
		printf("usage: sbj <node directory> [/options]\r\n");
		printf("\r\noptions: L = log wins/losses for each day\r\n");
		getch();
		return(1); }

	if(node_dir[strlen(node_dir)-1]!='\\'
		&& node_dir[strlen(node_dir)-1]!='/')  /* make sure node_dir ends in '\' */
		strcat(node_dir,"/");

	initdata(); 								/* read XTRN.DAT and more */
	credits=user_cdt;
	total_nodes=sys_nodes;

	remove("debug.log");

	if((file=nopen("sbj.cfg",O_RDONLY))==-1) {  /* open config file */
		bputs("Error opening sbj.cfg\r\n");
		pause();
		return(1); }
	if((stream=fdopen(file,"rb"))==NULL) {      /* convert to stream */
		bputs("Error converting sbj.cfg handle to stream\r\n");
		pause();
		return(1); }
	fgets(str,81,stream);						/* number of decks in shoe */
	total_decks=sys_decks=atoi(str);
	fgets(str,81,stream);						/* min bet (in k) */
	min_bet=atoi(str);
	fgets(str,81,stream);						/* max bet (in k) */
	max_bet=atoi(str);
	fgets(str,81,stream);						/* default bet (in k) */
	ibet=atoi(str);
	fclose(stream);
	if(!total_decks || total_decks>MAX_DECKS) {
		bputs("Invalid number of decks in sbj.cfg\r\n");
		pause();
		return(1); }
	if(!max_bet) {
		bputs("Invalid max bet in sbj.cfg\r\n");
		pause();
		return(1); }
	if(min_bet>max_bet) {
		bputs("Invalid min bet in sbj.cfg\r\n");
		pause();
		return(1); }
	if(ibet>max_bet || ibet<min_bet) {
		bputs("Invalid default bet in sbj.cfg\r\n");
		pause();
		return(1); }

	if(!fexist("card.dab")) {
		cur_card=0;
		dc=0;
		memset(dealer,0,sizeof(dealer));
		memset(card,0,sizeof(card));
		putcarddat(); }
	else {
		getcarddat();
		if(total_decks!=sys_decks) {
			remove("card.dab");
			total_decks=sys_decks;
			putcarddat(); } }

	if(!fexist("game.dab"))         /* File's not there */
		create_gamedab();

	open_gamedab();

	getgamedat(0);
	if(total_nodes!=sys_nodes) {  /* total nodes changed */
		close(gamedab);
		total_nodes=sys_nodes;
		create_gamedab();
		open_gamedab(); }

	srand((unsigned)time(NULL));

#ifdef __16BIT__
	while(_bios_keybrd(1))	 /* clear input buffer */
		_bios_keybrd(0);
#endif

	putchar(5); /* ctrl-e */
	mswait(500);
	if(keyhit()) {
#ifdef __16BIT__
		while(_bios_keybrd(1))
			_bios_keybrd(0);
#else
		getkey(0);
#endif
		bputs("\r\n\1r\1h\1i*** ATTENTION ***\1n\1h\r\n");
		bputs("\r\nSynchronet Blackjack uses Ctrl-E (ENQ) for the 'club' card "
			"symbol.");
		bputs("\r\nYour terminal responded to this control character with an "
			"answerback string.");
		bputs("\r\nYou will need to disable all Ctrl-E (ENQ) answerback "
			"strings (Including \r\nCompuserve Quick B transfers) if you wish to "
			"toggle card symbols on.\r\n\r\n");
		symbols=0;
		pause(); }

	getgamedat(1);
	node[node_num-1]=0;
	putgamedat();

	/* Override default mnemonic colors */
	mnehigh=RED|HIGH;
	mnelow=CYAN|HIGH;

	/* Override default inactivity timeout values */
	sec_warn=120;	
	sec_timeout=180;

	COMPILER_DESC(compiler);

#define SBJ_INDENT "                                "
	while(1) {
		cls();
		sprintf(str,"\1n\1h\1cSynchronet \1rBlackjack! \1cv3.20 for %s\r\n"
			,PLATFORM_DESC);
		center(str);
		sprintf(str,"\1w(XSDK v%s %s %s)\r\n\r\n"
            ,xsdk_ver,compiler,__DATE__);
		center(str);

		aborted=0;
		mnemonics(SBJ_INDENT"~Instructions\r\n");
		mnemonics(SBJ_INDENT"~Join/Begin Game\r\n");
		mnemonics(SBJ_INDENT"~List Players\r\n");
		mnemonics(SBJ_INDENT"~Rules of the Game\r\n");
		mnemonics(SBJ_INDENT"~Toggle Card Symbols\r\n");
		sprintf(str,SBJ_INDENT"~Quit to %s\r\n",sys_name);
		mnemonics(str);
		nodesync();
		bprintf("\1_\r\n"SBJ_INDENT"\1y\1hWhich: \1n");
		switch(getkeys("IJBLRTQ|!",0)) {
			#if DEBUG
			case '!':
				if(!com_port)
					autoplay=1;
				break;
			case '|':
				debug();
				break;
			#endif
			case 'I':
				cls();
				printfile("sbj.msg");
				break;
			case 'L':
				listplayers();
				bprintf(ShoeStatus,cur_card,total_decks*52);
				break;
			case 'R':
				bprintf("\1n\1c\r\nMinimum bet: \1h%uk",min_bet);
				bprintf("\1n\1c\r\nMaximum bet: \1h%uk\r\n",max_bet);
				bprintf("\1w\1h\r\nCard decks in shoe: \1h%u\r\n",sys_decks);
				break;
			case 'T':
				symbols=!symbols;
				bprintf("\1_\1w\r\nCard symbols now: %s\r\n",symbols ? "ON":"OFF");
				break;
			case 'Q':
				exit(0);
			case 'J':
			case 'B':
				sec_warn=60;	/* Override default inactivity timeout values */
				sec_timeout=90;
				play();
				sec_warn=120;
				sec_timeout=180;
				break; 
		} 
	}
}
Пример #14
0
int main(void)
{

   int gdriver = DETECT, gmode, errorcode;


   initgraph(&gdriver, &gmode, "");


   errorcode = graphresult();


   if (errorcode != grOk)
   {
      printf("Graphics error: %s\n", grapherrormsg(errorcode));
      printf("Press any key to halt:");
      getch();

      exit(1);
   }

   int choice;



   while(!kbhit())
   {
   setcolor(WHITE);
   setbkcolor(2);


   setcolor(YELLOW);
   circle(300,100,30);
   setfillstyle(SOLID_FILL,YELLOW);
   floodfill(300,100,YELLOW);

   setcolor(BLACK);
   setfillstyle(SOLID_FILL,BLACK);
   fillellipse(292,88,2,6);
   fillellipse(308,88,2,6);

   ellipse(300,103,185,355,20,8);
   ellipse(300,103,185,355,20,9);
   ellipse(300,103,185,355,20,10);

   setcolor(WHITE);
   settextstyle(0, HORIZ_DIR,6);
   outtextxy(180,200,"HIT IT");
   settextstyle(DEFAULT_FONT, HORIZ_DIR,2);
   outtextxy(130,400,"(Press any key to start)");
   settextstyle(DEFAULT_FONT, HORIZ_DIR, 1);
   rectangle(0,0,639,479);
   }
   sound(500);
   delay(100);
   nosound();
   clearviewport();
   setcolor(WHITE);

   getch();

   do
   {
   settextstyle(DEFAULT_FONT, HORIZ_DIR, 5);
   outtextxy(200,50,"HIT IT");
   settextstyle(DEFAULT_FONT, HORIZ_DIR, 2);
   outtextxy(200,150,"1.NEW GAME");
   outtextxy(200,200,"2.INSTRUCTIONS");
   outtextxy(200,250,"3.CREDITS");
   outtextxy(200,300,"4.EXIT");
   rectangle(0,0,639,479);
   settextstyle(DEFAULT_FONT, HORIZ_DIR, 1);
   outtextxy(175,372,"PLEASE ENTER YOUR CHOICE(1-4):");
   gotoxy(53,24);


   choice = _bios_keybrd(_KEYBRD_READ);

   switch(choice)
   {
   case 561:sound(500);
	   delay(100);
	   nosound();
	   clearviewport();

	   for(int i=1,r=10;;i++,r+5)
	   {
	   game(i);

	   if(score>=r)
	   {
	   setcolor(RED);
	   setfillstyle(SOLID_FILL,BROWN);
	   bar(130,200,390,300);
	   rectangle(130,200,390,300);
	   settextstyle(DEFAULT_FONT, HORIZ_DIR, 2);
	   setcolor(WHITE);
	   outtextxy(145,240,"CONGRATULATIONS");
	   delay(2000);
	   clearviewport();
	   setcolor(RED);
	   setfillstyle(SOLID_FILL,BROWN);
	   bar(100,200,500,300);
	   rectangle(100,200,500,300);
	   settextstyle(DEFAULT_FONT, HORIZ_DIR, 2);
	   setcolor(WHITE);
	   outtextxy(110,240,"GET READY FOR NEXT LEVEL");
	   delay(2000);
	   clearviewport();
	   score=0;
	   }


	   else
	   {
	   setcolor(RED);
	   setfillstyle(SOLID_FILL,BROWN);
	   bar(130,200,390,300);
	   rectangle(130,200,390,300);
	   settextstyle(DEFAULT_FONT, HORIZ_DIR, 2);
	   setcolor(WHITE);
	   outtextxy(190,240,"TRY AGAIN");
	   delay(2000);
	   score=0;
	   clearviewport();
	   break;
	   }
	   }
	   break;


   case 818: sound(500);
	     delay(100);
	     nosound();
	     clearviewport();
	     settextstyle(DEFAULT_FONT, HORIZ_DIR, 4);
	     outtextxy(119,50,"INSTRUCTIONS");
	     settextstyle(DEFAULT_FONT, HORIZ_DIR, 2);
	     outtextxy(200,200,"HIT THE BUTTON");
	     outtextxy(200,250,"CORRESPONDING");
	     outtextxy(200,300,"TO THE BOX");
	     outtextxy(200,350,"NUMBERED FROM");
	     outtextxy(200,400,"1 TO 9.");
	     rectangle(0,0,639,479);
	     getch();
	     clearviewport();
	     break;

   case 1075:sound(500);
	    delay(100);
	    nosound();
	    clearviewport();
	    for(int j=0;j<4;j++)
	    {
	    clearviewport();
	    rectangle(0,0,639,479);
	    settextstyle(DEFAULT_FONT, HORIZ_DIR, 1+j);
	    outtextxy(260-50*j,480-150*j,"Pawneet Singh");
	    outtextxy(260-50*j,580-150*j," Ajay Dahiya");
	    outtextxy(260-50*j,680-150*j,"Rahul Bansal");
	    outtextxy(260-50*j,780-150*j," Keshav Goel");
	    delay(1000);
	    }
	    delay(2000);;
	    clearviewport();
	    break;

   case 1332:sound(500);
	     delay(100);
	     nosound();
	     exit(0);

   default: clearviewport();
	    break;

   }
   }while(choice!=4);

   getch();
   closegraph();
   return 0;
}
Пример #15
0
 void game(int level)
 {
    label:

    int left=62, top=95, area, a[9], b[9],i ,j;
    int  key;
    void *p;


    rectangle(10,10,500,60);
    rectangle(11,11,501,61);
    settextstyle(DEFAULT_FONT, HORIZ_DIR, 2);
    outtextxy(215,25,"HIT IT");


    settextstyle(DEFAULT_FONT, HORIZ_DIR, 2);
    outtextxy(535,25,"MENU");
    settextstyle(DEFAULT_FONT, HORIZ_DIR, 1);
    outtextxy(530,76,"HIGH SCORE");
    outtextxy(520,131,"CURRENT SCORE");
    outtextxy(545,181,"LEVEL");
    outtextxy(530,231,"TIME LEFT");
    outtextxy(520,305,"INSTRUCTIONS");
    line(505,290,630,290);
    line(506,291,631,291);
    outtextxy(510,330,"HIT THE BUTTON");
    outtextxy(510,345,"CORRESPONDING");
    outtextxy(510,360,"TO THE BOX");
    outtextxy(510,375,"NUMBERED FROM");
    outtextxy(510,390,"1 TO 9.");
    outtextxy(510,420,"PRESS ESC KEY");
    outtextxy(510,435,"TO EXIT");

    rectangle(10,62,500,470);
    rectangle(11,63,501,471);
    line(170,62,170,470);
    line(171,63,171,471);
    line(340,62,340,470);
    line(341,63,341,471);
    line(10,198,500,198);
    line(11,199,501,199);
    line(10,334,500,334);
    line(11,335,501,335);
    rectangle(505,10,630,470);
    rectangle(506,11,631,471);
    outtextxy(160,188,"7");
    outtextxy(330,188,"8");
    outtextxy(490,188,"9");
    outtextxy(160,324,"4");
    outtextxy(330,324,"5");
    outtextxy(490,324,"6");
    outtextxy(160,460,"1");
    outtextxy(330,460,"2");
    outtextxy(490,460,"3");

    setcolor(YELLOW);
    circle(92,125,30);
    setfillstyle(SOLID_FILL,YELLOW);
    floodfill(92,125,YELLOW);

    setcolor(BLACK);
    setfillstyle(SOLID_FILL,BLACK);
    fillellipse(84,113,2,6);
    fillellipse(100,113,2,6);

    ellipse(92,128,185,355,20,8);
    ellipse(92,128,185,355,20,9);
    ellipse(92,128,185,355,20,10);


    a[0]= 252;
    b[0]= 120;
    a[1]= 252;
    b[1]= 265;
    a[2]= 252;
    b[2]= 410;
    a[3]= 412;
    b[3]= 120;
    a[4]= 412;
    b[4]= 265;
    a[5]= 412;
    b[5]= 410;
    a[6]= 92;
    b[6]= 265;
    a[7]= 92;
    b[7]= 410;
    a[8]= 92;
    b[8]= 120;


    area = imagesize(left, top, left + 60, top + 60);
    p = malloc(area);
    getimage(left, top, left + 60, top + 60, p);
    gotoxy(71,13);
    cout<<level;

    randomize();
    i= random(9);
    putimage(left, top, p, XOR_PUT);
    putimage(a[i]-30 ,b[i]-30 , p, XOR_PUT);
    left=a[i]-30;
    top=b[i]-30;


    gotoxy(71,10);
    cout<<score;

    time_t t, t1, t2, t3;

    t=time(NULL);

    int test=0;

    do
    {
     int x;
     while (bioskey(1) == 0)
     {
       t1=time(NULL);
       x=difftime(t1,t);
       gotoxy(70,16);
       printf("%2d",30-x);

       if(x>=30)
       break;

       i= random(9);
       putimage(left, top, p, XOR_PUT);
       putimage(a[i]-30 ,b[i]-30 , p, XOR_PUT);
       left=a[i]-30;
       top=b[i]-30;
       delay(500);
       test++;
     }

    if(x>=30)
    break;
    key=bioskey(0);

     switch(key)
     {
       case 561:
       if(i==7)
       {
       sound(1000);
       score++;
       delay(50);
       nosound();
       }
       else
       {
       sound(100);
       delay(50);
       nosound();
       }
       break;

       case 818:
       if(i==2)
       {
       sound(1000);
       score++;
       delay(50);
       nosound();
       }
       else
       {
       sound(100);
       delay(50);
       nosound();
       }
       break;

       case 1075:
       if(i==5)
       {
       sound(1000);
       score++;
       delay(50);
       nosound();
       }
       else
       {
       sound(100);
       delay(50);
       nosound();
       }
       break;

       case 1332:
       if(i==6)
       {
       sound(1000);
       score++;
       delay(50);
       nosound();
       }
       else
       {
       sound(100);
       delay(50);
       nosound();
       }
       break;

       case 1589:
       if(i==1)
       {
       sound(1000);
       score++;
       delay(50);
       nosound();
       }
       else
       {
       sound(100);
       delay(50);
       nosound();
       }
       break;

       case 1846:
       if(i==4)
       {
       sound(1000);
       score++;
       delay(50);
       nosound();
       }
       else
       {
       sound(100);
       delay(50);
       nosound();
       }
       break;

       case 2103:
       if(i==8)
       {
       sound(1000);
       score++;
       delay(50);
       nosound();
       }
       else
       {
       sound(100);
       delay(50);
       nosound();
       }
       break;

       case 2360:
       if(i==0)
       {
       sound(1000);
       score++;
       delay(50);
       nosound();
       }
       else
       {
       sound(100);
       delay(50);
       nosound();
       }
       break;

       case 2617:
       if(i==3)
       {
       sound(1000);
       score++;
       delay(50);
       nosound();
       }
       else
       {
       sound(100);
       delay(50);
       nosound();
       }
       break;

       case 283:
       void start();
       char ch;
       again:
       setcolor(RED);
       setfillstyle(SOLID_FILL,BROWN);
       bar(100,200,440,300);
       rectangle(100,200,440,300);
       settextstyle(DEFAULT_FONT, HORIZ_DIR, 2);
       setcolor(WHITE);
       settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
       outtextxy(110,250,"ARE YOU SURE YOU WANT TO EXIT (Y/N)");
       gotoxy(1,1);

       ch = _bios_keybrd(_KEYBRD_READ);

	 if(ch=='y'||ch=='Y')
	 {
	   outtextxy(400,250,"Y");
	   delay(500);
	   exit(0);
	 }

	 if(ch=='n'||ch=='N')
	 {
	 outtextxy(400,250,"N");
	 delay(500);
	 clearviewport();
	 goto label;
	 }
	 else
	 goto again;
      }

    gotoxy(71,10);
    cout<<score;
    i= random(9);
    putimage(left, top, p, XOR_PUT);
    putimage(a[i]-30 ,b[i]-30 , p, XOR_PUT);
    left=a[i]-30;
    top=b[i]-30;
    setcolor(WHITE);

    }while(test<30);

    }
Пример #16
0
void *nice_menu(void *main_title, void *menu_title, void *list)
{
  int x1=0,y1=0,x2=79,y2=25;

  p_ref r1(main_title),r2(menu_title),r3(list);
  main_title=eval(main_title);
  menu_title=eval(menu_title);
  char *t=lstring_value(main_title);
  put_title(t);

  bar(x1,y1+1,x2,y2,176,0x01);

  void *l=eval(list);
  p_ref r4(l);
  int menu_height=list_length(l),menu_length=0;
  void *m;
  for (m=l;m;m=CDR(m))
  { long l=strlen(lstring_value(CAR(m)));
    if (l>menu_length) menu_length=l;
  }

  char *mt=lstring_value(menu_title);
  if (strlen(mt)>menu_length) menu_length=strlen(mt);

  int mx=(x2+x1)/2-menu_length/2-1,my=(y2+y1)/2-menu_height/2-2;
  box(mx,my,mx+menu_length+2,my+menu_height+3,0x17);
  bar(mx+1,my+1,mx+menu_length+1,my+menu_height+2,' ',0x17);
  put_string(mx+1+menu_length/2-strlen(mt)/2,my,mt,0x1f);       // draw menu title
  set_cursor(0,25);

  int cur_sel=0;
  int key;
  do
  {
    int y=0;
    for (m=l;m;m=CDR(m),y++)
    {
      char *s=lstring_value(CAR(m));
      if (y==cur_sel)
      {
	bar(mx+1,my+2+y,mx+1+menu_length,my+2+y,' ',0x0f);
	put_string(mx+1+menu_length/2-strlen(s)/2,my+2+y,s,0x0f);
      }
      else
      {
	bar(mx+1,my+2+y,mx+1+menu_length,my+2+y,' ',0x1f);
	put_string(mx+1+menu_length/2-strlen(s)/2,my+2+y,s,0x1f);
      }
    }

    key=_bios_keybrd(_KEYBRD_READ);

    if (key==18432) 
    { cur_sel--; if (cur_sel==-1) cur_sel=menu_height-1; }
    if (key==20480)
    { cur_sel++; if (cur_sel==menu_height) cur_sel=0; }

  } while (key!=283 && key!=7181);
  cls();
  if (key==283) 
    return new_lisp_number(-1);

  return new_lisp_number(cur_sel);
}
Пример #17
0
static int khit(void)     // Inputs a character using system level calls.
{
   return (_bios_keybrd( _KEYBRD_READY ));
}
Пример #18
0
int keyhit()
{
   /* function 1 returns 0 until a key is pressed */
   //int wxmax=80;//user setting max x value
   //int wymax=25;//user setting max y value
   //float xunit;//horixontal unit(scaling ratio) step =1 for 80,25
   //float yunit;//vertical unit(scaling ratio) step =1 for 80,25
   //int flag;// flag for local purpose

   /* function 0 returns the key that is waiting */
   /* function 1 returns 0 until a key is pressed */

   if (_bios_keybrd(_KEYBRD_READY) != 0)  //while (!kbhit () )
   {
   //do{
   key = _bios_keybrd(_KEYBRD_READ);

   /* use function 2 to determine if shift keys were used */
   /*modifiers = _bios_keybrd(_KEYBRD_SHIFTSTATUS);
   if (modifiers)
   {
      printf("[");
      if (modifiers & RIGHT) printf("RIGHT");
      if (modifiers & LEFT)  printf("LEFT");
      if (modifiers & CTRL)  printf("CTRL");
      if (modifiers & ALT)   printf("ALT");
      printf("]");
   }
   // print out the character read
   printf("%#02x\n", key);         */

   hidemouse();
   switch (key)//detecting the function keys
   {
     case 0x3b00://Fn1 key is pressed
	help();
	//getch();
	break;
     case 0x3c00://Fn2 key is pressed
	curnt_fn=billmain;
	tbldisp();
	break;
     case 0x3d00://Fn3 key is pressed
	  curnt_fn=menu_cur;
	  menu();
	  break;
     case 0x3e00:
	  curnt_fn=get_psswd;//assigning the current function as the main of the billing part
	  psswd_disp();//initial display for the table of the bill
	  break;
     case 0x4400:

	  //psswd_disp();//initial display for the table of the bill
	  //curnt_fn=get_psswd;//assigning the current function as the main of the billing part
	  psswd_main();
	break;
   }
   curnt_fn(key);
   //}while (detect ()!=0x11b);
   }
   //getch();
   showmouse();
   return key;
}
Пример #19
0
void user_text(int x,int y)
{
	char text[2],ch,sp,bg;
	int i=0,ind;
	int flag=1;
	hidemouseptr();
	x=x/16;
	x=x*16;
	y=y/16;
	y=y*16;
	while(flag)
	{
		while((_bios_keybrd(_KEYBRD_READY)==0))
		{
			setcolor(BLACK);
			line(x-1,y-1,x-1,y+10);
			i=1;
		}
		setcolor(WHITE);
		line(x-1,y-1,x-1,y+10);
		setfillstyle(12,WHITE);
		ch=_bios_keybrd(_KEYBRD_READ);
		if(i==0)
			continue;
		if(x>xmax-16)
			{
			x=0;
			y+=16;
			}
		if(y>ymax-16)
			break;
		else
		{
			i=0;
			switch(ch)
			{
				case 27:
					flag=0;
					break;
				case 13:
					y+=16;
					x=0;
					break;
				case 32:
					x+=16;
					break;
				case 8:
					x-=16;
					setfillstyle(1,WHITE);
					bar(x,y,x+7,y+7);
					break;
				default:
					if((ch>=65&&ch<=90)||(ch>=97&&ch<=122)||(ch>=48&&ch<=57))
					{
						if(ch<58)
						ind=(ch-'0')+26;
						else if(ch<91)
						ind=(ch-'A');
						else if(ch<123)
						ind=(ch-'a');
						bg=getpixel(x,y);
						setfillpattern(pat[ind],RED);
						bar(x,y,x+7,y+7);
						adjust(x,y,x+7,y+7,bg);
						x+=16;
					}
					else
					{
						text[0]=ch;
						text[1]='\0';
						setcolor(cur_color);
						settextstyle(0,0,1);
						outtextxy(x,y,text);
						x+=16;
					}
			}
		}	
	}
	showmouseptr();
 }