/*---------------------------------------------------------------------- hbInkey ----------------------------------------------------------------------*/ int hbInkey(int Tijdsduur) { int Toets; time_t BeginTijd=0; char HuidigeTijd[9]; Tijdsduur++; /* WEGHALEN !!!!! alleen om warning te vermijden. */ /* BeginTijd=time(NULL); */ for(;;) { /* Doe van alles en nog wat. */ /* Kijk of er een muistoets is ingedrukt etc. */ if ((time(NULL)-BeginTijd) >= 1) { _strtime(HuidigeTijd); hbPrint(TijdY,TijdX,HuidigeTijd,Kleur); BeginTijd=time(NULL); } if (bioskey(1)>0) { Toets=bioskey(0); Toets=((Toets & 0xff)==0 ? -(Toets>>8) : (Toets & 0xff)); if (Toets==K_F1) Help(); else break; } }
void main(void) { int key,time=0; SetTimer(newhandler); /* 修改时钟中断 */ for (;;) { if (bioskey(1)) { key=bioskey(0); if (key==VK_ESC) /* 按escape键提前退出程序 */ { printf("User cancel!\n"); break; } } if (TimerCounter>18) /* 1秒钟处理一次 */ { /* 恢复计时变量 */ TimerCounter=0; time++; printf("%d\n",time); if (time==10) /* 10秒钟后结束程序 */ { printf("Program terminated normally!\n"); break; } } } KillTimer(); /* 恢复时钟中断 */ }
main() { randomize(); fill_maze_with_wall(); build_maze(1, 1, RIGHT_BOUND, BOTTOM_BOUND); search_target_xy(&tx, &ty); memset(mark, 0, sizeof(mark)); show_maze(0, 0, RIGHT_BOUND+1, BOTTOM_BOUND+1); save_sth_under_target(); draw_target(); bioskey(0); init_bug(1, 1, 0); old_8h = getvect(8); old_9h = getvect(9); setvect(8, int_8h); setvect(9, int_9h); while(!stop) { if(move_bug(bug[0].x, bug[0].y, tx, ty) == 1) /* target has been reached */ { bug_cry(); break; } } setvect(8, old_8h); setvect(9, old_9h); bioskey(0); }
void ModemResponse (char *resp) { int c; int respptr; do { printf (STR_MODEMRESP); respptr=0; do { while ( bioskey(1) ) { if ( (bioskey (0) & 0xff) == 27) Error ("\n"STR_RESPABORT); } c = read_byte (); if (c==-1) continue; if (c=='\n' || respptr == 79) { response[respptr] = 0; printf ("%s\n",response); break; } if (c>=' ') { response[respptr] = c; respptr++; } } while (1); } while (strncmp(response,resp,strlen(resp))); }
int welcomePage() { int mode = 0; int key; drawWelcomePage(mode); while (1) { if (bioskey(2)) key = bioskey(0); else key = 0; switch (key) { case VK_UP: mode--; if (mode < 0) mode = 2; break; case VK_DOWN: mode = (mode + 1) % 3; break; case VK_ENTER: return mode; case VK_ESC: global.gameover = 1; return mode; } drawWelcomePage(mode); } }
void demo() { uchar* p = music; uint x, s; uchar d; APOGEY_SCREEN_END(((int)startScreen), 64, 0x33, (52*94+7*2+1)*2, 1, 1); VG75[1] = 0x80; VG75[0] = 0xFF; VG75[0] = 0xFF; while(d = * p) { ++p; s = musicFreq[d-1]; SET_SOUND(0, s); s += 10; SET_SOUND(1, s); s += 15; SET_SOUND(2, s); d = *p; ++p; d >>= 1; delayHS(d); MUTE_SOUND(2); d <<= 1; delayHS(d); MUTE_SOUND(1); d <<= 1; delayHS(d); MUTE_SOUND(0); delayHS(2); if(bioskey()!=255) return; } while(bioskey()==255); }
void keyPress() { int key, x = pacman.mapX, y = pacman.mapY; if (bioskey(1)) key = bioskey(0); else key = 0; switch (key) { case VK_LEFT: pacman.operation = LEFT; if (pacman.dir == RIGHT) pacman.dir = pacman.operation; //如果方向相反则立即掉头 break; case VK_RIGHT: pacman.operation = RIGHT; if (pacman.dir == LEFT) pacman.dir = pacman.operation; break; case VK_UP: pacman.operation = UP; if (pacman.dir == DOWN) pacman.dir = pacman.operation; break; case VK_DOWN: pacman.operation = DOWN; if (pacman.dir == UP) pacman.dir = pacman.operation; break; case VK_ESC: global.gameover = 1; } }
int horizmenu(int itemnum,int curitem,int y,...) /* Dots are start of each item */ { int selected=FALSE; int mx,my,mbut; int inkey; char upkey,lowkey; int *lens; register int l; /* Loop variable */ #ifdef USEJOYSTICK int joypos=0,joybut=0; #endif lens=&y; lens++; /* Lens now points to the x coord of the first item */ if (curitem==0) curitem++; curitem--; moucur(0); setmoupos( (lens[curitem]+lens[curitem+1])/2,y); moustats(&mx,&my,&butstat); drawcursor(lens[curitem],y,lens[curitem+1]-1,CURATTR); do { if (bioskey(1)) { inkey = bioskey (0); lowkey = inkey&255; if (lowkey==0) { upkey = inkey>>8; switch (upkey) { case 77: /* right arrow */ erasecursor(); curitem++; if (curitem>=itemnum) curitem=0; setmoupos(lens[curitem+1]-1,y); drawcursor(lens[curitem],y,lens[curitem+1]-1,CURATTR); break; case 75: /* left arrow */ erasecursor(); curitem--; if (curitem<0) curitem=itemnum-1; setmoupos(lens[curitem]+1,y); drawcursor(lens[curitem],y,lens[curitem+1]-1,CURATTR); break; case 72: /* up arrow */ lowkey = 27; /* escape is the same as up arrow */ break; case 80: /* down arrow */ lowkey = 13; /* return is the same as dn arrow */ break; } } if ((lowkey==13)||(lowkey==27)) selected = TRUE; }
/*获取按键值*/ int GetKey(void) { char lowbyte; int press; while (bioskey(1) == 0) ;/*如果用户没有按键,空循环*/ press=bioskey(0); lowbyte=press&0xff; press=press&0xff00 + toupper(lowbyte); return(press); }
void main(int argc, char *argv[]) { size_t nitem = 0; char *tok; FILE *fp; char str[256]; struct wcount wc, *wcp; int i; if (argc < 2) { printf("\n Usage : wcount [filename]"); exit(1); } init_tree(&head); if ((fp = fopen(argv[1], "rt")) == NULL) { printf("\n Can't find that file."); exit(1); } fgets(str, 255, fp); while (!feof(fp)) { tok = strtok(str, delim); while (tok) { for (i = 0; i < strlen(tok); i++) tok[i] = tolower(tok[i]); strcpy(wc.word, tok); wcp = rbtr_search(&wc, head, &nitem, sizeof(wc), wcount_cmp); if (wcp == NULL) { wc.count = 1; rbtr_insert(&wc, head, &nitem, sizeof(wc), wcount_cmp); } else (wcp->count)++; tok = strtok(NULL, delim); } fgets(str, 256, fp); } printf("\n"); rbtr_sort(head->left, print_wcount); bioskey(0); printf("\n"); rbtr_list(head->left, print_wcount); bioskey(0); rbtr_draw(head->left, LINK|NODE|TAIL, make_str); rbtr_deleteall(head, &nitem); }
//获取用户输入,检测Esc退出 void End() { long key; while(bioskey(1)!=0) { key=bioskey(0); key=key&0x00FF; if(key==27) { setvect(0x1C,old); exit(0); } } }
int getch(void) { int c; static int extend = -1; /* If a previous ungetch() call has been performed, return * the key that it saved. */ if (_cFlag) /* Previous ungetch? */ { _cFlag = 0; /* Reset the flag */ return (_cChar & 0xff); /* Get the un-got char */ } /* If a previous call returned an extended code, return * the scan code for the key. */ if (extend != -1) { c = extend; extend = -1; /* Reset the flag */ return c; /* Return the extended scancode */ } int bk = bioskey(0); c = bk & 0x00FF; if (c == 0) { extend = (bk >> 8) & 0x00FF; }
void rotmain() { int a,b,driver=VGA,mode=2; initgraph(&driver,&mode,"d:\\tc1\\bgi"); a=getmaxx(); b=getmaxy(); int x=40; int n=15; outtextxy(a/2-35,b/2-30,"Welcome to"); outtextxy(a/2-25,b/2-15,"Rotation!"); outtextxy(a/2-50,b/2-5,"1.Vertical axis"); outtextxy(a/2-65,b/2+5,"2.Horizontal axis"); outtextxy(a/2-25,b/2+15,"3.Exit"); for(int j=0;j<200&&!kbhit();j++) { x=75; for(int i=0;i<400&&!kbhit();i++) { randomize(); if(i%10==0)setcolor(random(n)); ellipse(a/2,b/2,0,360,x,x); x++; n++; delay(0); } delay(10); } int t=bioskey(0); if(t==561||t==20273)rtltrot(); else if(t==818||t==20530)updnrot(); }
static int near edhorizontal (void) //************************************************************************* // // Zeileneditor, in dem alle horizontalen Cursorbewegungen und Eingaben // verarbeitet werden. Die Zeile wird komplett in einem Puffer bearbeitet // // Vertikale Aktionen werden an den Aufrufer zurueckgegeben // //************************************************************************* { int retwert = OK; int i = strlen(e->linbuf); unsigned a; memset(e->linbuf+i, ' ', LINLEN-i); // Rest der Zeile mit Blanks vorbesetzen e->linbuf[LINLEN] = 0; while (((a = (unsigned) waitkey()) & 255) != ESC) { retwert = a & 255; if ((bioskey(2) & 3) == 0) shiftgedrueckt = 0; if ((a & 255) == 0) { a >>= 8; retwert = (unsigned) a; if (horizontalswitch(a)) goto ende; } else {
void PicturePause (void) { int y; unsigned source; source = displayofs+panadjust; // VW_ColorBorder (15); VW_SetLineWidth (40); VW_SetScreen (0,0); if (source<0x10000l-200*64) { // // copy top line first // for (y=0;y<200;y++) VW_ScreenToScreen (source+y*64,y*40,40,1); } else { // // copy bottom line first // for (y=199;y>=0;y--) VW_ScreenToScreen (source+y*64,y*40,40,1); } IN_Shutdown (); VW_WaitVBL(70); bioskey(0); VW_WaitVBL(70); Quit (NULL); }
void main() { int gdriver = DETECT, gmode; registerbgidriver(EGAVGA_driver); initgraph(&gdriver, &gmode, ""); /** BLACK, BLUE, RED, WHITE, CYAN, GREEN, BROWN, LIGHTGRAY, YELLOW, DARKGREY, LIGHTBLUE, */ setbkcolor(BLUE); // 设置背景颜色 setcolor(WHITE); // 设置文本等图形的颜色 outtextxy(10, 10, "Welcome!"); rectangle(50, 50, 130, 130);// 输出矩形 int key = bioskey(0); printf("%x\n", key); if(key == KEY_UP) { printf("up"); } getch(); closegraph();// /** bgiobj egavga 把生成的egavga.obj复制到tlib同级目录中 tlib lib\graphics.lib+egavga */ }
void fire() /********火焰动画********/ { unsigned int x,y,c; setmode(); for (x=1;x<=32;x++) { setpal(x, x*2-1, 0, 0 ); setpal(x+32, 63, x*2-1, 0 ); setpal(x+64, 63, 63, x*2-1); setpal(x+96, 63, 63, 63 ); } while(bioskey(1)==0) { for (x=0;x<320;x+=2) { for (y=1;y<=202;y+=2) { c=(point(x,y)+point(x+2,y)+point(x,y+2)+point(x+2,y+2))>>2; if (c--) { poke(0xa000,(y-2)*320+x,(c<<8)+c); poke(0xa000,(y-1)*320+x,(c<<8)+c); } } y-=2; pset(x,y,random(320)); } } getch(); closemode(); }
Boolean aceptar_cancelar(){ int i = 0, lasti = 0, key, fila = wherey(), x = wherex(); char *buttons[] = {" Aceptar ", " Cancelar "}; gotoxy(x + 1, fila); cputs(" Aceptar Cancelar "); gotoxy(x + calculate_xpos(buttons, i), fila); marcar_texto(buttons[i], strlen(buttons[i])); msg_snd(); do{ key = bioskey(0); if((key & SC_IZQ) == SC_IZQ){ i--; if((i>=0)&&(i<=1))JVGtecla(); } if((key & SC_DER) == SC_DER){ i++; if((i>=0)&&(i<=1))JVGtecla(); } if(i >= 2) i = 1; if(i < 0) i = 0; gotoxy(x + calculate_xpos(buttons, lasti), fila); desmarcar_texto(buttons[lasti], strlen(buttons[lasti])); gotoxy(x + calculate_xpos(buttons, i), fila); marcar_texto(buttons[i], strlen(buttons[i])); lasti = i; }while(((key & SC_ENTER)!= SC_ENTER) && ((key & SC_ABAJO) != SC_ABAJO)); gotoxy(x + calculate_xpos(buttons, i), fila); desmarcar_texto(buttons[i], strlen(buttons[i])); _setcursortype(_NORMALCURSOR); if(i == 0) return Verdadero; return Falso; }
void move() { setfillstyle(1, 1); bar(0, 0, 640, 480); for (dxx = - 190; !bioskey(1); dxx++) { setfillstyle(1, 1); bar(0, 0, 640, 300); for (i = 0; i <= pn; i++) { j = ld[i]; x = x0 - (0.71 * dx[j] - 0.71 * dy[j]); y = y0 - (0.82 * dz[j] - 0.41 * dx[j] - 0.41 * dy[j]); dyy = 20; x = x + dxx; y = y + dyy; if (tl[i] == 0) { moveto(x, y); } lineto(x, y); if (x >= 640) { dxx = -200; } } delay(1000); } }
BOOLEAN check_ibm_stop(void) { int key; int __ss *p; /* if (kbhit()) getch(); */ /* allow DOS to test for control-C */ p = &key; if ((int)p < 500) { err_logo(STACK_OVERFLOW, NIL); return(1); } if (((key = bioskey(1)) == (4113)) || ctrl_c_count > 0) { /* control-q */ if (ctrl_c_count == 0) getch(); ctrl_c_count = 0; err_logo(STOP_ERROR,NIL); return(1); } if (key == (4375)) { /* control-w */ getch(); to_pending = 0; lpause(NIL); } return (0); }
void keyboard(void) { if(bioskey(1)==0) return; else quit_pgm(); }
/* ---- Read a keystroke ---- */ int getkey(void) { int c; while (keyhit() == FALSE) ; if (((c = bioskey(0)) & 0xff) == 0) c = (c >> 8) | 0x1080; else
static int KBD_Poll(void) { if (bioskey(1)!=0) return 1; else return 0; }
/* * This reads one keystroke from the keyboard, and the current state of * the mode keys (ALT, SHIFT, CTRL). Returns -1 on error, 0 if no data * is ready, and 1 if data was read. This is a non-blocking call. */ static int KBD_Read(MWUCHAR *buf, int *modifiers) { /* wait until a char is ready*/ if(!bioskey(1)) return 0; /* read keyboard shift status*/ *modifiers = bioskey(2); /* read keyboard character*/ *buf = bioskey(0); if(*buf == 0x1b) /* special case ESC*/ return -2; return 1; }
int get_resp( int x, int y, int count, char* menu[], char* keys ) /*获得用户的响应*/ { union inkey { char ch[2]; int i ; } c ; int arrow_choice = 0, key_choice; y++; goto_xy(x, y); chineseputs( y, x, menu[0], REV_VID); for(;;) { while(!bioskey(1)); c.i = bioskey(0); goto_xy( x + arrow_choice, y); chineseputs( y, x+arrow_choice, menu[arrow_choice], NORM_VID ); if( c.ch[0] ) { key_choice = is_in( keys, tolower( c.ch[0] )); if( key_choice ) return key_choice - 1; switch( c.ch[0] ) { case '\r': return arrow_choice; case ' ': arrow_choice++; break; case ESC : return -1; } } else { switch( c.ch[1] ) { case 72: arrow_choice--; break; case 80: arrow_choice++; break; } } if( arrow_choice == count ) arrow_choice = 0; if( arrow_choice < 0 ) arrow_choice = count - 1; goto_xy( x + arrow_choice, y ); chineseputs( y, x+arrow_choice, menu[ arrow_choice ], REV_VID ); } }
/* Uses the BIOS to read the next keyboard character */ int getkey(void) { int key, lo, hi; key = bioskey(0); if (key==12) refreshscreen(); lo = key & 0X00FF; hi = (key & 0XFF00) >> 8; return((lo == 0) ? hi + 256 : lo); } /* getkey */
/* 设定游戏等级函数 */ void Set_Level(void) { int key,pass=0,i=0; clock_t front_time,current_time; front_time=clock(); setfillstyle(1,WHITE); bar(180,150,460,300); setcolor(LIGHTRED); rectangle(182,152,458,298); setcolor(BLACK); rectangle(184,154,456,174); rectangle(184,176,456,296); setcolor(RED); outtextxy(260,160,"Level Setting"); setcolor(BLACK); outtextxy(190,200,"Here have three level:"); outtextxy(190,260,"Please input a number[0,1,2]:"); setcolor(BLUE); outtextxy(200,220,"0: fast"); outtextxy(200,230,"1: normal"); outtextxy(200,240,"2: slow"); while(pass==0) { if(bioskey(1)) { key=GetKey(); if(key=='0' || key=='1' || key=='2') /* 通过设置全局变量Timeout来确定游戏速度 */ { pass=1; if(key=='0') Timeout=0; else if(key=='1') Timeout=1; else Timeout=2; } else { setcolor(LIGHTRED); outtextxy(190,280,"Please input 0,1,2!"); } } else { current_time=clock(); if(current_time-front_time>6) /* 光标闪动效果,不知谁有更有效的方法? */ { front_time=current_time; i=(i+1)%2; if(i==0) setcolor(BLACK); else setcolor(WHITE); outtextxy(420,260,"_"); } } } }
void runkernel(void) { cleardevice(); setbkcolor(0); int id,l,count=0; Control.First=0; Control.Free=50; id=Number+1; while((Control.Free<50)||(Number==-1)) { while(bioskey(1)!=0) { count++; bioskey(0); biuldwait(id); id++; Number++; } if((wt==wh&&wh==0)||(wt!=wh)) biuldmem();/*Biuld all can*/ cleardevice(); setbkcolor(0); drawgrid(); run(); finish(); compress(); display(); delay(2000); } setcolor(0); for(int a=0;a<629;a++) { moveto(a,390); lineto(a,425); moveto(a,445); lineto(a,460); } setcolor(YELLOW); outtextxy(180,450,"All the processes have been done!"); getch(); }
/* 获取按键,如果低八位非0则为ASCII码,如为0则为控制键 */ int GetKey(void) { int key; key=bioskey(0); if(key<<8) { key=key&0x00ff; if(isalpha(key)) /* 如果为字母则转换为大写 */ key=toupper(key); } return key; }
double energy() { int i = 0; int flag=1,kk=0; setcolor(WHITE); setlinestyle(0,0,0); setwritemode(COPY_PUT); rectangle(maxx/2-LENTH/2-2,50,maxx/2+LENTH/2+2,60); settextstyle(4,0,3); setcolor(BLUE); outtextxy(170,25,"MIN"); outtextxy(420,25,"MAX"); do { while(bioskey(1)!=0) getch(); if (0<=(i+flag)&&(i+flag)<=LENTH) i+=flag; else flag=-flag; setcolor(BLUE); setwritemode(XOR_PUT); line(maxx/2-LENTH/2+i,52,maxx/2-LENTH/2+i,58); if (Music_on) { sound(15*i); delay(400); nosound(); } else delay(600); }while((kk=bioskey(1))!=ESC && kk!=SPACE); setfillstyle(SOLID_FILL,BLACK); floodfill(maxx/2-LENTH/2,52,WHITE); if (bioskey(0)==ESC) return -1; return 4.0*i/LENTH; }