int objectlibrary::checkall() { int loop,temp,clicked; mouse(); mousestatus(clicked); if(clicked) { for(loop=0;loop<numbuttons;loop++) { if(buttons[loop]->mouseover()) { if(SHOWMOUSE) hidemouse(); buttons[loop]->click(); if(SHOWMOUSE) showmouse(); return buttons[loop]->getindex(); } } for(loop=0;loop<numtables;loop++) { if(tables[loop]->mouseover()) { if(SHOWMOUSE) hidemouse(); tables[loop]->click(); if(SHOWMOUSE) showmouse(); return -1; } } } return -1; }
void runner() { clearviewport(); fstream f3; f3.open("product",ios::app|ios::nocreate); f3.seekg(0); if(f3.fail()) { cmpdtls(); staff(); //outtextxy(40,40,"This is a deault file"); } int val; int x,y,btn; int cnr; showmouse(); int whcnt=0; do { pro[whcnt].getdata(); rep: showmouse(); draw(); getmouse(btn,x,y); draw(); while(!(btn&1)==1) { getmouse(btn,x,y); if(cnr==0) draw(); cnr++; } while((btn&1)==1) getmouse(btn,x,y); f3.write((char*)&pro[whcnt],sizeof(product)); whcnt++; if(!((x>450&&x<500&&y>450&&y<460)||(x>550&&x<600&&y>450&&y<460))) goto rep; }while((x>450&&x<500&&y>450&&y<460)); f3.close(); clearviewport(); }
void product:: display() { char txt1[20],txt2[20],txt3[20]; hidemouse(); clearviewport(); outtextxy(25,40," "); outtextxy(25,40,"name of product"); outtextxy(25,50,name); outtextxy(25,60," "); outtextxy(25,60,"price"); sprintf(txt1,"%g",price); outtextxy(25,70,txt1); outtextxy(25,80," "); outtextxy(25,80,"quantity"); sprintf(txt2,"%d",qty); outtextxy(25,90,txt2); sprintf(txt3,"%d",prno); outtextxy(25,100," "); outtextxy(25,100,"product no"); outtextxy(25,110,txt3); showmouse(); }
int main() { int xi,yi,xo,yo,x,y; int gdriver=DETECT,gmode; initgraph(&gdriver,&gmode,"D:\\BORLANDC\\BGI"); // int xmax=getmaxx(); // int ymax=getmaxy(); initmouse(); showmouse(); getmouse(&xi,&yi); getmouse(&xo,&yo); int h,r ; float m=pow((xo-xi),2); float n=pow((yo-yi),2); r=sqrt(m+n); xi=xi + ((xo-xi)/2); yi=yi +((yo-yi)/2); // circle(xi,yi,10); h=1-r; x=0;y=r; while(x<=y) { crc(x,y,xi,yi); if(h<0) { h=h+(2*x)+1 ; } else { h=h+(2*(x-y))+1 ; y=y-1; } x++; } getch(); closegraph(); return 0; }
void data(int a,int b) { setcolor(4); settextstyle(1,0,1); outtextxy(a,b, " A COMPLETE SOLUTION TO "); outtextxy(a,b+20, " BILLING AND MANAGEMENT "); outtextxy(a,b+40, " OF LARGE OR SMALL SCALE "); outtextxy(a,b+60, " DEPTARTMENTAL STORE... "); outtextxy(a,b+80, ""); outtextxy(a,b+100,""); setcolor(14); outtextxy(a,b+120," SUPER MARKET SUPERVISOR"); outtextxy(a,b+140," --version--2-r "); outtextxy(a,b+160," ADMINISTRATOR "); outtextxy(a,b+180,""); moveto(a,b+240); setcolor(4); outtext("By Sadanandh"); outtextxy(a,b+260,"PROFITZ SOLUTIONS"); showmouse(); Button F1,F2; F1.init(a+100,b+200," OK ",NORMAL,0,-2); F1.show( ); selc(F1,F2,24,8); restore_previous_settings( ); }
// 主函数 int main( int argc, char* argv[] ) { int i, ms_x = -1024, ms_y = -1024, exitflag = 0; int fps = 60; double dtime; int mode = preinit( argc, argv ); // 记录初始化模式 if ( mode < 0 ) return 0; randomize(); // 初始化随机种子 initgraph( -1, -1 ); // 打开图形窗口,以全屏模式 showmouse( mode ); sc_width = getwidth(); sc_heigh = getheight(); // 初始化所有星星 for ( i = 0; i < g_max; i++ ) { InitStar( i ); star[i].x = randomf(); } // 绘制星空,按任意键或移动鼠标退出 setfont( 12, 6, "宋体" ); setrendermode( RENDER_MANUAL ); dtime = fclock(); while ( kbmsg() ) getkey(); for ( ; !exitflag && is_run() && kbmsg() == 0; delay_fps( fps ) ) { //每秒画120帧,kbhit(1)是获取键盘任意键的消息,详见pdf // 如果有鼠标消息 while ( mousemsg() ) { mouse_msg msg = getmouse(); if ( ms_x <= -1024 ) { ms_x = msg.x; ms_y = msg.y; } // 处理鼠标,移动超出范围就退出 if ( mode == 0 ) { // 仅全屏模式才处理鼠标 int x = msg.x, y = msg.y; x -= ms_x; y -= ms_y; if ( x * x + y * y > 400 ) exitflag = 1; } } // 显示星星 double dt = 1.0 / fps; //fclock() - dtime; dtime += dt; for ( int i = 0; i < g_max; i++ ) { MoveStar( i, dt ); } // 显示FPS { char str[60]; sprintf( str, "%8.2f FPS", getfps()); outtextxy( 0, 0, str ); //显示fps } } closegraph(); // 关闭图形窗口 return 0; }
static JSBool js_conio_showmouse(JSContext *cx, uintN argc, jsval *arglist) { jsrefcount rc; rc=JS_SUSPENDREQUEST(cx); JS_SET_RVAL(cx, arglist, INT_TO_JSVAL(showmouse())); JS_RESUMEREQUEST(cx, rc); return(JS_TRUE); }
void data1() { hidemouse(); Panel modify; modify.init(6,56,getmaxx()-5,getmaxy()-7,THIN,IN);; modify.show(); modify.shape("MODIFY"); Panel move; move.init(220,120,525,455,OUT,THIN); move.show( ); move.shape("MODIFY"); showmouse(); settextstyle(0,0,1); ifstream fio("pro//product",ios::app); ofstream file("pro//temp",ios::out); fio.seekg(0); product s1,s2; int rno; char found='f'; char confirm='y'; outtextxy(240,202,"enter prno to append"); boxx(rno,240,222); while(!fio.eof()) { fio.read((char*)&s1,sizeof(product)); if(s1.no()==rno) { found='t'; if(confirm=='y') { s1.display(); s2.appm(s1); file.write((char*)&s2,sizeof(product));} confirm='n'; } else file.write((char*)&s1,sizeof(product)); } if(found=='f') outtextxy(240,242,"record not found"); fio.close(); file.close(); remove("pro//product"); rename("pro//temp","pro//product"); fio.close(); file.close(); }
static void mousehandler() { for (;;) { MOUEVENTINFO m; unsigned short status; clock_t start; #if 0 if (MouGetDevStatus((PUSHORT) &status, mousenum) != 0 || (status & (MOUSE_UNSUPPORTED_MODE | MOUSE_DISABLED)) ) { hidemouse(); (void) MouClose(mousenum); DosExit(EXIT_THREAD, 0); } #endif status = MOU_WAIT; MouReadEventQue((PMOUEVENTINFO) &m, (PUSHORT) &status, mousenum); /* * If we don't get the control semaphore immediately, * we do nothing. Delayed responses to mouse button * presses could be confusing. */ #if 0 start = clock(); #endif if (DosSemRequest(control, SEM_IMMEDIATE_RETURN) != 0) continue; #if 0 if (clock() != start) { (void) fprintf(stderr, "mouse thread: %d\n", __LINE__); DosSemClear(control); continue; } #endif /* * Start of critical section. */ if (++keystrokes >= PSVKEYS) lastevent = clock(); if (State == NORMAL && (m.fs & (MOUSE_BN1_DOWN | MOUSE_BN2_DOWN | MOUSE_BN3_DOWN))) { hidemouse(); mouseclick(m.row, m.col); showmouse(); } /* * End of critical section. */ DosSemClear(control); } }
void main(){char c=' ';int x,y,b=0; window(1,1,80,25); textbackground(0); textcolor(15); clrscr(); gotoxy(1,1);cout << 'Q'; if(ifmouse())showmouse(); while(c!='q') { while(!kbhit()) { readmouse(); b=mouseb;x=(mousex>>3)+1;y=(mousey>>3)+1; if(mouseb!=0) { gotoxy(x,y); switch(b) { case 1:hidemouse(); cout<<c; showmouse(); break; case 2:gettext(x,y,x,y,&c);break; } gotoxy(x,y); } if(b==1&&x==1) { if(y==1){c='q';break;} } } if(c!='q')c=getch(); hidemouse(); cout << c; showmouse(); } }
void modify() { showmouse(); tappend(); refresh(); int cnt=0; while((!kbhit())&&(!(leftmousekeypressed()))) cnt++; Panel scribble; scribble.init(6,56,getmaxx()-5,getmaxy()-7,THIN,IN); scribble.show(); }
//------------------------------------------------------------ void Control() { do { _1.button_effect();_2.button_effect();_3.button_effect(); _4.button_effect();_5.button_effect();_6.button_effect(); _7.button_effect();_8.button_effect();_9.button_effect(); _ER.button_effect();_1.higlt(curr); restrictmouse(); showmouse(); get_mouse(); getmousepos(); wait_mouse(); hide_mouse(); } while(1); }
int main() { int xi,yi; int gdriver=DETECT,gmode; initgraph(&gdriver,&gmode,"d:\\borlandc\\BGI"); // int xmax=getmaxx(); // int ymax=getmaxy(); int rx , ry ; printf("Enter value or rx :") ; scanf("%d",&rx); printf("\nEnter value or ry :") ; scanf("%d",&ry); initmouse(); showmouse(); getmouse(&xi,&yi); putpixel(xi,yi,11); ellipse(xi,yi,rx,ry); getch(); return 0; }
void startInf() { inf.screen_x=200; inf.screen_y=150; inf.CS_x = GetSystemMetrics(SM_CXSCREEN)-300; inf.CS_y = GetSystemMetrics(SM_CYSCREEN); setinitmode(INIT_TOPMOST|INIT_NOBORDER,inf.CS_x,0); initgraph(inf.screen_x,inf.screen_y); setcaption("easyNote"); setbkmode(1); setbkcolor(YELLOW); setfont(20,0,"宋体"); showmouse(0); th[0].num=0; inf.page=1; inf.box_y=20; inf.color_top=YELLOW; inf.color_btm=RGB(199,233,131); inf.mouse_speed=200; }
void drawgrid() { if(selectedwindow()==3) { hidemouse(); //setcolor(15); int x1,x2,y1,y2; for(int loopx=0;loopx<maxx;loopx++) { for(int loopy=0;loopy<maxy;loopy++) { x1=windows[3].x1+4+(loopx*size); x2=x1+size-1; y1=windows[3].y1+17+(loopy*size); y2=y1+size-1; if(graph[loopx][loopy]==16) { setfillstyle(1,7); bar(x1,y1,x2,y2); setcolor(8); line(x1,y1,x2,y2); line(x1,y2,x2,y1); } else { setfillstyle(1,graph[loopx][loopy]); bar(x1,y1,x2,y2); } setcolor(0); rectangle(x1,y1,x2+1,y2+1); } } thumb(); showmouse(); } }
void drawpixel(int x, int y) { hidemouse(); int x1=windows[3].x1+4+(x*size); int x2=x1+size-1; int y1=windows[3].y1+17+(y*size); int y2=y1+size-1; setfillstyle(1,graph[x][y]); if(graph[x][y]==16) { setfillstyle(1,7); bar(x1,y1,x2,y2); setcolor(8); line(x1,y1,x2,y2); line(x1,y2,x2,y1); } else bar(x1,y1,x2,y2); setcolor(0); rectangle(x1,y1,x2+1,y2+1); thumb(); showmouse(); }
void sscreen( ) { cleardevice( ); Panel main_bar,Screen,tool; main_bar.init(0,0,getmaxx( ),getmaxy( ),IN,THIN); main_bar.show(); char*txt="SUPER MARKET SUPERVISOR..ver-2r"; { int x1=0; int y1=0; int x2=getmaxx( ); int y2=getmaxy( ); int x=x1+13; int y=y1-1; setcolor(8); rectangle(x1+4,y1+4,x2-5,y+41); rectangle(x1+4,y+48,x2-5,y2-5); setcolor(15); rectangle(x1+5,y+6,x2-4,y+42); rectangle(x1+5,y+ 49,x2-4,y2-4); setfillstyle(1,9); bar(x1+8,y1+8,x2-8,y+38); settextstyle(8,0,4); setcolor(0); outtextxy(x,y,txt); outtextxy(x+1,y,txt); setcolor(14); outtextxy(x+2,y-1,txt); outtextxy(x+3,y-1,txt); outtextxy(x+4,y-1,txt); } tool.init(0,35,getmaxx(),55,IN,THIN); tool.show(); Button Add,Delete,Modify,Search,About,Exit; Add.init(6,35,"Add ",FLAT); Add.show( ); Delete.init(111,35,"Delete ",FLAT); Delete.show( ); Modify.init(221,35,"Modify ",FLAT); Modify.show( ); Search.init(331,35,"Search ",FLAT); Search.show( ); About.init(441,35,"About ",FLAT,0,0,7,1); About.show( ); Exit.init(551,35,"Exit ",FLAT); Exit.show( ); Screen.init(5,53,632,467,IN,THICK,0); Screen.show( ); setcolor(8); rectangle(4,53,633,471); setcolor(15); rectangle(5,54,634,472); initmouse(); while(1) { showmouse(); int ch=selc(Add,Delete,Modify,Search,About,Exit,30,32,50,31,48,18); hidemouse(); wrkng(ch); } }
void makeoptions() { showmouse(); createwindows(0,5,5,150,75,0,4,"BrUsH CoLoR"); createlist(0,0,15,25); additem(0,0,"Black"); additem(0,0,"Blue"); additem(0,0,"Green"); additem(0,0,"Cyan"); additem(0,0,"Red"); additem(0,0,"Magenta"); additem(0,0,"Brown"); additem(0,0,"Lt. Gray"); additem(0,0,"Gray"); additem(0,0,"Lt. Blue"); additem(0,0,"Lt. Green"); additem(0,0,"Lt. Cyan"); additem(0,0,"Pink"); additem(0,0,"Lt. Magenta"); additem(0,0,"Yellow"); additem(0,0,"White"); additem(0,0,"Transparent"); createwindows(1,5,80,175,220,0,4,"BrUsH aTTrIbUtEs"); createlist(1,0,15,115); createlist(1,1,15,185); createlabel(1,0,15,100,125,112,4); createlabel(1,1,15,170,125,182,4); changelabel(1,0,"Brush Type"); changelabel(1,1,"Brush Width"); additem(1,0,"Freehand"); additem(1,0,"Flood Fill"); additem(1,0,"Line"); additem(1,0,"Rectangle"); //additem(1,0,"Circle"); //additem(1,0,"Filled Circle"); //additem(1,0,"Filled Rectangle"); additem(1,1,"1"); additem(1,1,"2"); additem(1,1,"3"); additem(1,1,"4"); additem(1,1,"5"); createwindows(2,5,225,290,375,0,4,"FiLe oPtIoNs"); createtext(2,0,20,265,280,285); createlabel(2,0,20,250,170,262,5); changelabel(2,0,"Filename:"); createbutton(2,0,20,290,90,330,3,"Save"); createbutton(2,1,100,290,170,330,3,"Load"); createbutton(2,2,20,340,170,360,4,"Quit"); createwindows(3,300,10,610,400,0,4,"DrAwInG gRiD"); createbutton(3,0,310,375,410,397,5,"Clear Grid"); cleargrid(); }
void ccoc() { int rn,q; fstream f3; f3.open("pro//product",ios::app); f3.seekg(0); if(f3.fail()) { outtextxy(40,40,"This is a deault file"); } int whcnt=0; do { pro[whcnt].getdata(); rn=pro[whcnt].no(); if(rn==0) { goto last; } q=chkred(rn); if(q==1) { f3.seekg(ios::end); f3.write((char*)&pro[whcnt],sizeof(product)); } Panel Check; Check.init(220,120,525,455,OUT,THIN); Check.show( ); Check.shape("Choice Box"); Button Next; Button Cancel; Next.init(265,260,"Next ",NORMAL,0,-2); Next.show( ); Cancel.init(385,260,"Halt",NORMAL,0,-2); Cancel.show( ); initmouse(); showmouse(); int i= selc(Next,Cancel,49,35); if(i!=1) { break; } Check.modify(220,120,525,455,OUT,THIN); Check.show(); Check.shape("Add"); whcnt++; } while(1); last: f3.close(); }
void run(double *accum, int *cur_loc, mem_array mem) { int prg_counter = 0, // mem cell location of the command being executed next_loc = 0, // mem cell location of the next command to be executed run_flag = CONTINUE; // flag for when to stop the execution of the // user's program. Values are CONTINUE, STOP // and RUN_ERR char cmdtrans[80]; // an English translation of the current command enum speed run_speed; // the run mode hidemouse(); // if they want to run if(get_speed(&run_speed) == CONTINUE) { // set up screen for running put_accum(accum); clear_monitor(); clear_keyboard(); clear_keys(); /* user's program loop */ do { // execute at the next location prg_counter = next_loc; // THF patch, was +2 put_prg_counter(prg_counter + 1); put_instruct(mem[prg_counter]); bright_cell(prg_counter, mem[prg_counter]); // case statement for run mode switch(run_speed) { case SLOW: delay(SLOW_DELAY_TIME); break; case FAST: delay(FAST_DELAY_TIME); } /// if there is a command in the cell if(mem[prg_counter].entry_type == CMD) { // command type case statement switch(mem[prg_counter].cmd_type) { case LDC: run_flag = ldc(accum, mem, cmdtrans, prg_counter, &next_loc); break; case ADC: run_flag = adc(accum, mem, cmdtrans, prg_counter, &next_loc); break; case LDA: run_flag = lda(accum, mem, cmdtrans, prg_counter, &next_loc); break; case STA: run_flag = sta(accum, mem, cmdtrans, prg_counter, &next_loc); break; case ADD: run_flag = add(accum, mem, cmdtrans, prg_counter, &next_loc); break; case SUB: run_flag = sub(accum, mem, cmdtrans, prg_counter, &next_loc); break; case MUL: run_flag = mul(accum, mem, cmdtrans, prg_counter, &next_loc); break; case DIV: run_flag = div(accum, mem, cmdtrans, prg_counter, &next_loc); break; case INP: run_flag = inp(mem, cmdtrans, prg_counter, &next_loc); break; case OUT: run_flag = out(mem, cmdtrans, prg_counter, &next_loc); break; case BPA: run_flag = bpa(accum, mem, cmdtrans, prg_counter, &next_loc); break; case BNA: run_flag = bna(accum, mem, cmdtrans, prg_counter, &next_loc); break; case BZA: run_flag = bza(accum, mem, cmdtrans, prg_counter, &next_loc); break; case BRU: run_flag = bru(mem, cmdtrans, prg_counter, &next_loc); break; case STP: run_flag = stp(cmdtrans, prg_counter, &next_loc); if(run_speed == CYCLE) { display_cmdtrans(cmdtrans); } break; default: run_err_message("ERROR: Unkown command at this location."); run_flag = RUN_ERR; break; } } else { run_err_message("ERROR: Unkown command at this location."); run_flag = RUN_ERR; } // check to see if the user wants to stop if(kbhit()) { if(getch() == EscKey) { run_flag = STOP; } } if((run_speed == CYCLE) && (run_flag == CONTINUE)) { run_flag = display_cmdtrans(cmdtrans); } dim_cell(prg_counter, mem[prg_counter]); } while((run_flag == CONTINUE) && (mem[prg_counter].cmd_type != STP)); // clear the registers when program is done clear_instruct(); clear_prg_counter(); } showmouse(); if(run_flag == RUN_ERR) { *cur_loc = prg_counter; } display_keys(); }
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; }
void main() { clrscr(); /* mat3 x,y,z; for(int i=0; i<3; i++) { for(int j=0; j<3; j++) { cout<<i+j<<"\t"; x.value[i][j]=i+j; y.value[i][j]=i+j; } cout<<endl; } z=x*y; cout<<endl; for(i=0; i<3; i++) { for(int j=0; j<3; j++) { cout<<z.value[i][j]<<"\t"; } cout<<endl; } vec3 v, r; v.value[0]=1; v.value[1]=2; v.value[2]=3; r=x*v; cout<<endl<<r.value[0]<<"\t"<<r.value[1]<<"\t"<<r.value[2]; */ int gdriver=DETECT, gmode, errorcode; initgraph(&gdriver, &gmode, "d:\\borlandc\\bgi"); initmouse(); showmouse(); int maxx = getmaxx(); int maxy = getmaxy(); int midx = maxx / 2; int midy = maxy / 2; line(midx, 0, midx, maxy); line(0, midy, maxx, midy); int n ; cout<<"Enter number of lines :" ; cin>> n; vec3 pos[100]; for(int i=0; i<2*n; i++) { getmouse(&pos[i].value[0], &pos[i].value[1]); pos[i].value[0]-=midx; pos[i].value[1]-=midy; pos[i].value[2]=1 ; if(i%2!=0) { line(midx+pos[i-1].value[0],midy+pos[i-1].value[1],midx+pos[i].value[0],midy+pos[i].value[1]); } } cout<<"\nEnter general pivot point :"; vec3 pivot; getmouse(&pivot.value[0], &pivot.value[1]); for(i=0; i<2*n; i++) { pos[i].value[0]-=pivot.value[0]; pos[i].value[1]-=pivot.value[1]; } mat3 rotate; vec3 rotated[14]; float d = 180 ; rotate.value[0][0]=cos(d*3.14/180) ; rotate.value[0][1]=-sin(d*3.14/180) ; rotate.value[0][2]=0 ; rotate.value[1][0]=sin(d*3.14/180) ; rotate.value[1][1]=cos(d*3.14/180) ; rotate.value[1][2]=0 ; rotate.value[2][0]=0 ; rotate.value[2][1]=0 ; rotate.value[2][2]=1 ; getch(); cleardevice(); line(midx, 0, midx, maxy); line(0, midy, maxx, midy); for(i=0;i<2*n;i++) { rotated[i]= rotate*pos[i]; if(i%2!=0) { line(midx+rotated[i-1].value[0], midy+rotated[i-1].value[1], midx+rotated[i].value[0], midy+rotated[i].value[1]); //line(pivot.value[0]+midx+rotated[i-1].value[0],pivot.value[1]+midy+rotated[i-1].value[1],pivot.value[0]+midx+rotated[i].value[0],pivot.value[1]+midy+rotated[i].value[1]); } } getch(); }
void grf_writestr(int grf, int len, unsigned char *s, int x, int y, int attr, int color) { struct grf_softc *gp; register u_char *uc, ul; /* u_char *sc, *ssc; */ u_char bitmask[20]; register int i; int fbrowbytes, reverse; int width, height, numleft; struct font *f; u_long buf[32 * 16]; int startx, endx, longstartx, longendx; int numlongs, sh, startchar, endchar; register u_long *bufp; register int j; if (grf == -1) { return; } gp = &grf_Softc[grf]; if (x < 0) { i = -x; x += i; s += i; len -= i; } i = gp->g_term.numtcols - x; if (len > i) { len = i; } if (len <= 0 || y < 0 || y >= gp->g_term.numtrows) { return; } hidemouse(gp); #ifdef UNDERLINE if (attr & T_BOLD) { #else if (attr & T_BOLD || attr & T_UNDERLINE) { #endif /* UNDERLINE */ f = &gp->g_term.bold; } else { f = &gp->g_term.font; } width = f->width; height = f->height; reverse = (!(attr & T_REVERSE) != !(attr & T_SELECTED)); #ifdef INVERSE reverse = !reverse; #endif /* INVERSE */ fbrowbytes = gp->g_display.rowbytes; startx = x * width; endx = (x + len) * width; y *= height; bitmask[0] = (1 << width) - 1; for (i = 1; i < height; i++) { bitmask[i] = bitmask[0]; } ul = 255 & bitmask[0]; /* * Blit the beginning and end independently from middle */ longstartx = (startx + 31) & ~31; longendx = endx & ~31; numleft = (longstartx - startx + width - 1) / width; if (numleft > len) { numleft = len; } for (i = 0; i < numleft; i++) { uc = f->data + height * s[i]; #ifdef UNDERLINE if (attr & T_UNDERLINE) *(uc + height - 1) ^= ul; #endif /* UNDERLINE */ blitWrite(gp, startx + i * width, y, width, height, uc, bitmask, reverse); #ifdef UNDERLINE if (attr & T_UNDERLINE) *(uc + height - 1) ^= ul; #endif /* UNDERLINE */ } /* * Blit middle in one chunk */ numlongs = (longendx - longstartx) / 32; if (numlongs <= 0) { goto nomiddle; /* Yes boys, LAK did a goto */ } for (i = numlongs * height - 1; i >= 0; i--) { buf[i] = 0; } for (j = 0; j < numlongs; j++) { startchar = (j * 32 + longstartx - startx) / width; endchar = (j * 32 + 31 + longstartx - startx) / width; sh = 32 - width - startchar * width + longstartx - startx + j * 32; for (i = startchar; i <= endchar; i++, sh -= width) { #ifdef UNDERLINE if (s[i] == ' ' && !(attr & T_UNDERLINE)) { #else if (s[i] == ' ') { #endif /* UNDERLINE */ continue; } uc = f->data + height * s[i]; #ifdef UNDERLINE if (attr & T_UNDERLINE) *(uc + height - 1) ^= ul; #endif /* UNDERLINE */ bufp = &buf[j]; if (sh < 0) { sh = -sh; UNROLL(height, *bufp |= *uc++ >> sh; bufp += numlongs); sh = -sh; } else { UNROLL(height, *bufp |= *uc++ << sh; bufp += numlongs); } #ifdef UNDERLINE if (attr & T_UNDERLINE) *(uc - 1) ^= ul; #endif /* UNDERLINE */ } } blitWriteAligned(gp, longstartx, y, numlongs * 32, height, buf, reverse); nomiddle: if (longendx >= longstartx) { numleft = (endx - longendx + width - 1) / width; if (numleft > len) { numleft = len; } for (i = len - numleft; i < len; i++) { uc = f->data + height * s[i]; #ifdef UNDERLINE if (attr & T_UNDERLINE) *(uc + height - 1) ^= ul; #endif /* UNDERLINE */ blitWrite(gp, startx + i * width, y, width, height, uc, bitmask, reverse); #ifdef UNDERLINE if (attr & T_UNDERLINE) *(uc + height - 1) ^= ul; #endif /* UNDERLINE */ } } showmouse(gp); }
void grf_eraserect(int grf, int x1, int y1, int x2, int y2, int color) { struct grf_softc *gp; u_long *start, *end, longsperline, longspertline, x, y; register u_long *ptr, c; register int len, i; u_char *sc; struct font *f; if (grf == -1) { return; } grf_flush(grf); gp = &grf_Softc[grf]; f = &gp->g_term.font; hidemouse(gp); if (x1 < 0) { x1 = 0; } if (y1 < 0) { y1 = 0; } if (x2 > gp->g_term.numtcols - 1) { x2 = gp->g_term.numtcols - 1; } if (y2 > gp->g_term.numtrows - 1) { y2 = gp->g_term.numtrows - 1; } #ifdef INVERSE c = ~0L; #else c = 0; /* BG 04/15/94 - I'm not sure what the above * is supposed */ /* to be, but it's 0x7fffffff, which isn't quite right. */ #endif /* INVERSE */ longsperline = gp->g_display.rowbytes / sizeof(long); longspertline = longsperline * gp->g_term.font.height; ptr = (u_long *) (gp->g_display.fbbase); start = ptr + y1 * longspertline; end = ptr + (y2 + 1) * longspertline; if (x1 == 0 && x2 == gp->g_term.numtcols - 1) { len = end - start; ptr = start; for (i = len / 8; i > 0; i--) { UNROLL(8, *ptr++ = c); } UNROLL(len % 8, *ptr++ = c); } else { if (gp->g_display.psize == 1) { if (gp->g_term.font.width == 8) { while (start < end) { sc = (u_char *) start + x1; for (x = x1; x <= x2; x++) { *sc++ = c; } start += longsperline; } } else { for (y = y1; y <= y2; y++) { for (x = x1; x <= x2; x++) { grf_writestr(grf, 1, " ", x, y, T_NORMAL, color); } } } } else { for (y = y1; y <= y2; y++) { for (x = x1; x <= x2; x++) { grf_writestr(grf, 1, " ", x, y, T_NORMAL, color); } } } } showmouse(gp); }
pullmenu() { char scr[1200],s[80]; int x,y,i,goon,c; goon=1; onwait(); x=wherex(); y=wherey(); hidemouse(); gettext(13,5,61,16,scr); puttext(13,5,61,16,USERED); showmouse(); while(goon) { gotoxy(23,12); cprintf(" "); gotoxy(23,12); textcolor(LIGHTCYAN); inputlocal(s,30); strupr(s); switch(s[0]) { case 'Q': goon=0; break; case '1': gotoxy(15,14); textcolor(LIGHTBLUE); cprintf("Old Name: "); textcolor(LIGHTGRAY); cprintf("%s",user.name); gotoxy(15,15); textcolor(LIGHTGREEN); cprintf("New Name: "); inputlocal(s,40); gotoxy(15,14); cprintf(" "); gotoxy(15,15); cprintf(" "); if(s[0]!=0 || stricmp(user.name,s)==0) { if(!ver_user(s)) strcpy(user.name,s); } break; case '2': gotoxy(15,14); textcolor(LIGHTBLUE); cprintf("Old User SL: "); textcolor(LIGHTGRAY); cprintf("%d",user.sl); gotoxy(15,15); textcolor(LIGHTGREEN); cprintf("New User SL: "); textcolor(LIGHTGRAY); inputlocal(s,20); gotoxy(15,14); cprintf(" "); gotoxy(15,15); cprintf(" "); i=atoi(s); if(i >= 0 || i <= 255) user.sl=i; break; case '3': gotoxy(15,14); textcolor(LIGHTBLUE); cprintf("Old File SL: "); textcolor(LIGHTGRAY); cprintf("%d",user.filesl); gotoxy(15,15); textcolor(LIGHTGREEN); cprintf("New File SL: "); textcolor(LIGHTGRAY); inputlocal(s,20); gotoxy(15,14); cprintf(" "); gotoxy(15,15); cprintf(" "); i=atoi(s); if(i >= 0 || i <= 255) user.filesl=i; break; case '4': gotoxy(15,14); textcolor(LIGHTBLUE); cprintf("Old Note: "); textcolor(LIGHTGRAY); cprintf("\"%s\"",user.note); gotoxy(15,15); textcolor(LIGHTGREEN); cprintf("New Note: "); textcolor(LIGHTGRAY); inputlocal(s,40); gotoxy(15,14); cprintf(" "); gotoxy(15,15); cprintf(" "); if(s[0]!=0) strcpy(user.note,s); break; case '5': gotoxy(15,14); textcolor(LIGHTBLUE); cprintf("Old Time: "); textcolor(LIGHTGRAY); cprintf("%d",print_time()/60); gotoxy(15,15); textcolor(LIGHTGREEN); cprintf("New Time: "); textcolor(LIGHTGRAY); inputlocal(s,20); gotoxy(15,14); cprintf(" "); gotoxy(15,15); cprintf(" "); if(s[0]!=0) { user.timeall=atoi(s)*60; timeleft=atoi(s)*60; } break; case '6': i=1; gotoxy(15,14); textcolor(LIGHTBLUE); cprintf("User Flags: "); while(i) { goon=0; while(goon < 10) { gotoxy(27+goon,14); if(user.flags[goon]) { textcolor(LIGHTRED); cprintf("%d",goon); } else { textcolor(LIGHTGRAY); cprintf("%d",goon); } goon++; } gotoxy(15,15); textcolor(LIGHTGREEN); cprintf("Enter flag to toggle [Q/Quit]: "); do { c=getch(); if(c=='Q' || c=='q') { gotoxy(15,14); cprintf(" "); gotoxy(15,15); cprintf(" "); i=0; } } while(c < '0' || c > '10'); gotoxy(37,15); cprintf("%c",c); if(user.flags[c-48]) user.flags[c-48]=0; else user.flags[c-48]=1; gotoxy(37,15); cprintf(" "); } break; case '7': gotoxy(15,14); textcolor(LIGHTBLUE); cprintf("Old Password: "******"%s",user.pass); gotoxy(15,15); textcolor(LIGHTGREEN); cprintf("New Password: "******" "); gotoxy(15,15); cprintf(" "); if(s[0]!=0) strcpy(user.pass,s); break; case '8': gotoxy(15,14); textcolor(LIGHTBLUE); cprintf("Old Filepoints: "); textcolor(LIGHTGRAY); cprintf("%d",user.filepoints); gotoxy(15,15); textcolor(LIGHTGREEN); cprintf("New Filepoints: "); inputlocal(s,40); gotoxy(15,14); cprintf(" "); gotoxy(15,15); cprintf(" "); if(s[0]!=0) user.filepoints=atoi(s); break; } } writeuser(); puttext(13,5,61,16,scr); gotoxy(x,y); offwait(); }
///////////////////////////////////////////////// // 主函数 ///////////////////////////////////////////////// int main(int argc, char* argv[]) { // 初始化绘图窗口及颜色 setinitmode(0x005, 0, 0); if (argc < 2) { MessageBoxW(NULL, L"本屏幕保护程序无配置", L"JuliaSet", MB_OK); return 0; } else if (stricmp(argv[1], "/p") == 0) { HWND hwnd; sscanf(argv[2], "%d", &hwnd); attachHWND(hwnd); setinitmode(0x107, 0, 0); } else if (stricmp(argv[1], "/s")) { MessageBoxW(NULL, L"本屏幕保护程序无配置", L"JuliaSet", MB_OK); return 0; } //initgraph(320, 240); initgraph(-1, -1); randomize(); showmouse(0); FlushMouseMsgBuffer(); while(kbhit()) getch(); //InitColor(); InitLog(); g_w = getwidth(NULL); g_h = getheight(NULL); g_st = (state*)malloc(g_w * g_h * sizeof(state)); COMPLEX c = {0.262, 0.002}, z = {0, 0}; double r = 1.5, d = g_w / (double)g_h, rotate = 0, sr = sin(rotate), cr = cos(rotate); init_st(g_w, g_h); int n_update = 0; double ftime = fclock(); { double dc = 64, dca = 128, db = 16; col_r = randomf() * dc + db; col_g = randomf() * dc + db; col_b = randomf() * dc + db; col_ar = randomf() * dca; col_ag = randomf() * dca; col_ab = randomf() * dca; rotate = randomf() * 360; sr = sin(rotate), cr = cos(rotate); } setrendermode(RENDER_MANUAL); for (int loop = 1; kbmouhit() == 0; ++loop) { int ret; if (loop <= 4) { ret = JDraw(c, z.re - r * d, z.im - r, z.re + r * d, z.im + r, sr, cr); if (loop == 4) { g_udlist.swap(); for(int y=0; y<g_h; y++) { for(int x=0; x<g_w; x++) { if (g_st[y * g_w + x].ed == 0) { g_udlist.push(x, y); } } } g_udlist.swap(); } } else { static int t = 0; ret = JDrawA(c, z.re - r * d, z.im - r, z.re + r * d, z.im + r); if (clock() - t > 30) { delay(1); t = clock(); } } if (g_updatepoint == 0) { n_update++; } else { n_update = 0; } if (0) { char str[500]; sprintf(str, "%d %d %f %f", g_w, g_h, r, d); outtextxy(0, 0, str); } if (ret == 0 || n_update > 8 || loop > 1000) { loop = 0; if (g_mi[0][0] == 0) { delay(1); memset(pMap, 0, BF_W * BF_H * sizeof(state)); g_udlist.clear(); for (int i = 0; i < BF_W; ++i) { addpoint(i, 0); addpoint(i, BF_H - 1); } for (int i = 0; i < 4; ) { if (MDraw(-1.9, -1.2, 0.5, 1.2) == 0) { ++i; } else { i = 0; } if (kbmouhit()) return 0; } } double dc = 64, dca = 128, db = 16; col_r = randomf() * dc + db; col_g = randomf() * dc + db; col_b = randomf() * dc + db; col_ar = randomf() * dca; col_ag = randomf() * dca; col_ab = randomf() * dca; rotate = randomf() * 360; sr = sin(rotate), cr = cos(rotate); do { c.re = randomf() * 2.4 - 1.9; c.im = randomf() * 2.4 - 1.2; int ir = (int)((c.re - (-1.9)) / (0.5 - (-1.9)) * BF_W); int im = (int)((c.im - (-1.2)) / (1.2 - (-1.2)) * BF_H); if (g_mi[im][ir] >= 16) { break; } } while (1); init_st(g_w, g_h); n_update = 0; if (fclock() - ftime < 3) { delay_ms((int)((3 - (fclock() - ftime)) * 1000)); } else { delay(1); } ftime = fclock(); } } closegraph(); return 0; }
//--------------------------------------------------------------- void wait_mouse() { // quit via menu if(code==44) { if(o.x.cx>=215 && o.x.dx>=260 && o.x.cx<=285 && o.x.dx<=280) { frame(215,260,285,280,DARKGRAY,LIGHTGRAY,WHITE); outtextxy(240,265,"YES");delay(200); closegraph();exit(0); } if(o.x.cx>=328 && o.x.dx>=260 && o.x.cx<=403 && o.x.dx<=280) { frame(328,260,403,280,DARKGRAY,LIGHTGRAY,WHITE); outtextxy(357,265,"NO");delay(200); code = 0; Message_Box(); } return; } // quit via corner button if(o.x.cx>=613 && o.x.dx>=7 && o.x.cx<=638 && o.x.dx<=27) { code = 44; // quit fill_maze(); frame(190,180,430,300,LIGHTBLUE,LIGHTBLUE,WHITE); frame(193,183,427,297,LIGHTBLUE,LIGHTBLUE,WHITE); frame(196,186,424,200,BLUE,BLUE,BLUE); settextstyle(0,0,1); setcolor(WHITE); outtextxy(280,190,"MESSAGE"); setcolor(BLACK); outtextxy(203,216,"DO YOU REALLY WANT TO "); outtextxy(203,231,"EXIT ?"); frame(215,260,285,280,LIGHTGRAY,DARKGRAY,WHITE); frame(328,260,403,280,LIGHTGRAY,DARKGRAY,WHITE); outtextxy(240,265,"YES"); outtextxy(357,265,"NO"); frame(5,31,260,90,BLUE,BLUE,BLUE); menubar(); return; } /////////////////////////////////////////// if(code == 47) // load a game from file { if(o.x.cx>=215 && o.x.dx>=260 && o.x.cx<=285 && o.x.dx<=280) { frame(215,260,285,280,DARKGRAY,LIGHTGRAY,WHITE); outtextxy(235,265,"OPEN"); delay(200); load(); Message_Box(); frame(5,31,260,90,BLUE,BLUE,BLUE); code = 0; fill_maze(); while(o.x.cx>=45 && o.x.dx>=31 && o.x.cx<=105 && o.x.dx<=70) { frame(45,31,105,70,BLUE,BLUE,BLUE); showmouse();getmousepos(); } menubar(); } //-------------------------------------------------------- if(o.x.cx>=328 && o.x.dx>=260 && o.x.cx<=403 && o.x.dx<=280) { frame(328,260,403,280,DARKGRAY,LIGHTGRAY,WHITE); outtextxy(343,265,"CANCEL");delay(200); code = 0; Message_Box(); frame(5,31,260,90,BLUE,BLUE,BLUE); menubar(); } return; } /////////////////////////////////////////// if(code == 48) // save a game to file { if(o.x.cx>=215 && o.x.dx>=260 && o.x.cx<=285 && o.x.dx<=280) { frame(215,260,285,280,DARKGRAY,LIGHTGRAY,WHITE); outtextxy(245,265,"OK"); delay(200); save(); code = 0; Message_Box(); frame(5,31,260,90,BLUE,BLUE,BLUE); menubar(); fill_maze(); while(o.x.cx>=45 && o.x.dx>=31 && o.x.cx<=105 && o.x.dx<=70) { frame(45,31,105,70,BLUE,BLUE,BLUE); showmouse();getmousepos(); } menubar(); } //-------------------------------------------------------- if(o.x.cx>=328 && o.x.dx>=260 && o.x.cx<=403 && o.x.dx<=280) { frame(328,260,403,280,DARKGRAY,LIGHTGRAY,WHITE); outtextxy(343,265,"CANCEL"); delay(200); code = 0; Message_Box(); frame(5,31,260,90,BLUE,BLUE,BLUE); menubar(); } return; } /////////////////////////////////////////// ////////////////////////////////////////// if(code == 42) // resign { if(o.x.cx>=215 && o.x.dx>=260 && o.x.cx<=285 && o.x.dx<=280) { frame(215,260,285,280,DARKGRAY,LIGHTGRAY,WHITE); outtextxy(240,265,"YES"); delay(200); Message_Box(); frame(5,31,260,90,BLUE,BLUE,BLUE); menubar(); for(int i=0;i<9;i++) for(int j=0;j<9;j++) { arr[i][j] = puzz[i][j]; } Message_Box(); for( i=0;i<9;i++) for( j=0;j<9;j++) { arr[i][j] = stat[i][j] = puzz[i][j] = hnt[i][j] = 0; } code = 0; puz_typ = 0; frame(5,31,260,90,BLUE,BLUE,BLUE); frame(45,31,105,70,BLUE,BLUE,BLUE); menubar(); return; } //------------------------------------------------------------- if(o.x.cx>=328 && o.x.dx>=260 && o.x.cx<=403 && o.x.dx<=280) { frame(328,260,403,280,DARKGRAY,LIGHTGRAY,WHITE); outtextxy(357,265,"NO"); delay(200); code = 0; Message_Box(); frame(5,31,260,90,BLUE,BLUE,BLUE); menubar(); } return; } if(menu_bar_effect()) { return; } if( o.x.cx>=127 && o.x.dx>=27 && o.x.cx<=191 && o.x.dx<=85 && men_stat == 4 && puz_typ != 0) { men_stat = 0; if( o.x.dx<=42 ) { if(code != 41) // pause { code = 41;fill_maze(); } else if(code == 41) // resume { code = 0; fill_maze(); while(o.x.cx>=127 && o.x.dx>=27 && o.x.cx<=191 && o.x.dx<=72) { frame(5,31,260,90,BLUE,BLUE,BLUE); showmouse(); getmousepos(); } menubar(); return; } } else if( o.x.dx<=55 ) // Resign(); { if(code != 41) // not pause { code = 42; fill_maze(); frame(190,180,430,300,LIGHTBLUE,LIGHTBLUE,WHITE); frame(193,183,427,297,LIGHTBLUE,LIGHTBLUE,WHITE); frame(196,186,424,200,BLUE,BLUE,BLUE); setcolor(WHITE); settextstyle(0,0,1); outtextxy(280,190,"MESSAGE"); setcolor(BLACK); outtextxy(203,216,"DO YOU REALLY WANT TO "); outtextxy(203,231,"RESIGN ?"); frame(215,260,285,280,LIGHTGRAY,DARKGRAY,WHITE); frame(328,260,403,280,LIGHTGRAY,DARKGRAY,WHITE); outtextxy(240,265,"YES"); outtextxy(357,265,"NO"); } } else if( o.x.dx<=72 ) // Hint { if(code != 41) { char *an; int i,j,curr,flag=1; settextstyle(6,0,4); for(i=0;i<9;i++) for(j=0;j<9;j++) if(arr[i][j] != puzz[i][j]) { flag = 0; break; } if(flag == 0 && cnt != 81) { while(1) { i = abs(rand() % 9),j = abs(rand() % 9); if(stat[i][j]==0 && (arr[i][j]==0 || arr[i][j]!=puzz[i][j] )) break; } curr = puzz[i][j]; stat[i][j] = arr[i][j] = hnt[i][j] = curr; cnt++; switch(curr) { case 1: an="1"; break; case 2: an="2"; break; case 3: an="3"; break; case 4: an="4"; break; case 5: an="5"; break; case 6: an="6"; break; case 7: an="7"; break; case 8: an="8"; break; case 9: an="9"; break; case 10: an=" "; break; } int l=((i*40)+150); int t=((j*40)+100); setcolor(BLACK); for(int k=l+4;k<l+40-4;k++) line(k,t+4,k,t+40-4); setcolor(YELLOW); outtextxy((i*40)+165 ,(j*40)+95 ,an); }}} else if( o.x.dx<=85 ) // Submit { Usr_Submit(); } while(o.x.cx>=127 && o.x.dx>=27 && o.x.cx<=191 && o.x.dx<=72) { frame(5,31,260,90,BLUE,BLUE,BLUE); showmouse(); getmousepos(); } menubar(); return; } /////////////////////////////////////////////////////////////////////////// if( o.x.cx>=86 && o.x.dx>=27 && o.x.cx<=130 && o.x.dx<=60 && men_stat == 3 && puz_typ != 0) // reset { men_stat = 0; if(o.x.dx<=42) // reset { for(int i=0; i<9 ; i++) for(int j=0; j<9 ; j++) { if( stat[i][j] == 0 && arr[i][j] != 0 ) { arr[i][j] = 0; } } code = 41;fill_maze(); code = 0;fill_maze(); } else if( o.x.dx<=55 ) // Timer { } while(o.x.cx>=86 && o.x.dx>=27 && o.x.cx<=130 && o.x.dx<=72) { frame(5,31,260,90,BLUE,BLUE,BLUE); showmouse(); getmousepos(); } menubar(); return; } ////////////////////////////////////////////////////////////////////////// else if( o.x.cx>=5 && o.x.dx>=27 && o.x.cx<=66 && o.x.dx<=70 && men_stat == 1) { men_stat = 0; if( o.x.dx<=42 ) // save game to a file { if( puz_typ <= 0) { fill_maze(); frame(190,180,430,300,LIGHTBLUE,LIGHTBLUE,WHITE); frame(193,183,427,297,LIGHTBLUE,LIGHTBLUE,WHITE); frame(196,186,424,200,BLUE,BLUE,BLUE); setcolor(WHITE); settextstyle(0,0,1); outtextxy(270,190,"SAVE GAME"); setcolor(BLACK); outtextxy(230,231," NO GAME TO SAVE"); delay(900); Message_Box(); } else { code = 48; File_name[0] = '\0'; nam_siz = 0; fill_maze(); frame(190,180,430,300,LIGHTBLUE,LIGHTBLUE,WHITE); frame(193,183,427,297,LIGHTBLUE,LIGHTBLUE,WHITE); frame(196,186,424,200,BLUE,BLUE,BLUE); setcolor(WHITE); settextstyle(0,0,1); outtextxy(270,190,"SAVE GAME"); setcolor(BLACK); outtextxy(203,211,"ENTER THE FILE NAME : "); frame(207,225,410,245,LIGHTGRAY,LIGHTGRAY,BLACK); frame(215,260,285,280,LIGHTGRAY,DARKGRAY,WHITE); frame(328,260,403,280,LIGHTGRAY,DARKGRAY,WHITE); outtextxy(245,265,"OK"); outtextxy(343,265,"CANCEL"); } } else if( o.x.dx>=42 && o.x.dx<=55 ) // load { code = 47; // load File_name[0] = '\0'; nam_siz = 0; fill_maze(); frame(190,180,430,300,LIGHTBLUE,LIGHTBLUE,WHITE); frame(193,183,427,297,LIGHTBLUE,LIGHTBLUE,WHITE); frame(196,186,424,200,BLUE,BLUE,BLUE); setcolor(WHITE); settextstyle(0,0,1); outtextxy(260,190,"OPEN A FILE"); setcolor(BLACK); outtextxy(203,211,"ENTER THE FILE NAME : "); frame(207,225,410,245,LIGHTGRAY,LIGHTGRAY,BLACK); frame(215,260,285,280,LIGHTGRAY,DARKGRAY,WHITE); frame(328,260,403,280,LIGHTGRAY,DARKGRAY,WHITE); outtextxy(235,265,"OPEN"); outtextxy(343,265,"CANCEL"); } else if( o.x.dx<=72 ) { code = 44; // quit fill_maze(); frame(190,180,430,300,LIGHTBLUE,LIGHTBLUE,WHITE); frame(193,183,427,297,LIGHTBLUE,LIGHTBLUE,WHITE); frame(196,186,424,200,BLUE,BLUE,BLUE); setcolor(WHITE); settextstyle(0,0,1); outtextxy(280,190,"MESSAGE"); setcolor(BLACK); outtextxy(203,216,"DO YOU REALLY WANT TO "); outtextxy(203,231,"EXIT ?"); frame(215,260,285,280,LIGHTGRAY,DARKGRAY,WHITE); frame(328,260,403,280,LIGHTGRAY,DARKGRAY,WHITE); outtextxy(240,265,"YES"); outtextxy(357,265,"NO"); } } // new puzzle :- else if( o.x.cx>=45 && o.x.dx>=31 && o.x.cx<=105 && o.x.dx<=70 && men_stat == 2) { men_stat = 0; for(int i=0;i<9;i++) for(int j=0;j<9;j++) arr[i][j] = stat[i][j] = puzz[i][j] = hnt[i][j] = 0; cnt = 0; Message_Box(); // clears the board if( o.x.dx<=42 ) puz_typ = 1; // EASY else if(o.x.dx<=55) puz_typ = 2; // MEDIUM else if(o.x.dx<=72) puz_typ = 3; // HARD generate_puzzle(puz_typ); fill_maze(); while(o.x.cx>=45 && o.x.dx>=31 && o.x.cx<=105 && o.x.dx<=70) { frame(45,31,105,70,BLUE,BLUE,BLUE); showmouse();getmousepos(); } menubar(); return; } // help else if( o.x.cx>=175 && o.x.dx>=31 && o.x.cx<=250 && o.x.dx<=60 && men_stat == 5) { men_stat = 0; if( o.x.dx<=42 ) // about { fill_maze(); frame(190,180,430,300,LIGHTBLUE,LIGHTBLUE,WHITE); frame(193,183,427,297,LIGHTBLUE,LIGHTBLUE,WHITE); frame(196,186,424,200,BLUE,BLUE,BLUE); setcolor(WHITE); settextstyle(0,0,1); outtextxy(280,190,"ABOUT"); setcolor(BLACK); outtextxy(203,211,"Puzzle Sudoku ver. 1.3"); outtextxy(203,235,"For more details contact"); outtextxy(203,256," [email protected] "); delay(3000); } else if( o.x.dx<=55 ) // credit { fill_maze(); frame(190,180,430,300,LIGHTBLUE,LIGHTBLUE,WHITE); frame(193,183,427,297,LIGHTBLUE,LIGHTBLUE,WHITE); frame(196,186,424,200,BLUE,BLUE,BLUE); setcolor(WHITE); settextstyle(0,0,1); outtextxy(270,190,"CREDITS"); setcolor(BLACK); outtextxy(203,211," Made by : "); outtextxy(203,225," Tejas. A. Patil "); outtextxy(203,236," SE I.T MIT , Pune "); outtextxy(203,249,"I am thankful to my "); outtextxy(203,260,"Parents , Teachers and"); outtextxy(203,271,"Friends for their support"); outtextxy(203,282," and help."); delay(3000); } Message_Box(); frame(5,31,260,90,BLUE,BLUE,BLUE); frame(45,31,105,70,BLUE,BLUE,BLUE); menubar(); } // board if(o.x.cx>=150 && o.x.dx>=100 && o.x.cx<=510 && o.x.dx<=460) { int xr = (o.x.cx-150)/40, yr = (o.x.dx-100)/40; if(code > 40 ) return; if(puz_typ == 0 ) return; if(curr != 10 && arr[xr][yr] != 0) Number_Pad(arr[xr][yr]-1); if(stat[xr][yr] != 0 ) return; if(cnt == 81 && curr != 10) return; else { char *an; settextstyle(6,0,4); setcolor(LIGHTCYAN); switch(curr) { case 1: an="1"; break; case 2: an="2"; break; case 3: an="3"; break; case 4: an="4"; break; case 5: an="5"; break; case 6: an="6"; break; case 7: an="7"; break; case 8: an="8"; break; case 9: an="9"; break; case 10: an=" "; break; } do { if(curr != 10 && arr[xr][yr] == 0 && cnt != 81) { outtextxy((xr*40)+165, (yr*40)+95, an); } else if (curr == 10) { int l=((xr*40)+150); int t=((yr*40)+100); setcolor(BLACK); for(int k=l+4;k<l+40-4;k++) line(k,t+4,k,t+40-4); setcolor(WHITE); } restrictmouse(); showmouse(); getmousepos(); } while(o.x.cx>=((xr*40)+150) && o.x.dx>=((yr*40)+100) && o.x.cx<=((xr*40)+190) && o.x.dx<=((yr*40)+140) ); if(curr != 10 && arr[xr][yr] == 0 && cnt != 81) cnt++; else if(curr == 10 && arr[xr][yr] != 0) cnt--; arr[xr][yr] = (curr%10); } } if(o.x.cx>=40 && o.x.dx>=130 && o.x.cx<=70 && o.x.dx<=430 && code < 40 && puz_typ != 0) { int p = (o.x.dx-130)/30; Number_Pad(p); } if(men_stat != 0) { men_stat = 0; frame(5,31,260,90,BLUE,BLUE,BLUE); menubar(); } }
/* * inchar() - get a character from the keyboard. * * Timeout not implemented yet for OS/2. */ int inchar(long mstimeout) { for (;;) { KBDKEYINFO k; bool_t mstatus, psvstatus; flush_output(); mstatus = (usemouse && State == NORMAL); psvstatus = (keystrokes >= PSVKEYS); /* * We don't have to give control to any other thread * if neither of these conditions is true. */ if (mstatus || psvstatus) { #ifndef NOMOUSE if (mstatus) showmouse(); #endif if (psvstatus && DosSemWait(psvsema, SEM_IMMEDIATE_RETURN) == ERROR_SEM_TIMEOUT) { /* * If psvsema is set, clear it. */ DosSemClear(psvsema); } DosSemClear(control); } /* * Start of non-critical section. * * Wait for character from keyboard. */ KbdCharIn((PKBDKEYINFO) &k, IO_WAIT, 0); /* * End of non-critical section. */ if (mstatus || psvstatus) { DosSemRequest(control, SEM_INDEFINITE_WAIT); #ifndef NOMOUSE if (mstatus) hidemouse(); #endif } if (++keystrokes >= PSVKEYS) lastevent = clock(); /* * Now deal with the keypress information. */ if ((unsigned char) k.chChar == (unsigned char) 0xe0) { /* * It's (probably) a function key. */ if (k.chScan == 0x53) /* * It's the delete key. */ return State == NORMAL ? 'x' : '\b'; /* else */ if (State == NORMAL) { /* * Assume it must be a function key. */ switch (k.chScan) { case 0x3b: return(K_HELP); /* F1 key */ case 0x47: return(K_HOME); /* home key */ case 0x48: return(K_UARROW); /* up arrow key */ case 0x49: return(K_PGUP); /* page up key */ case 0x4b: return(K_LARROW); /* left arrow key */ case 0x4d: return(K_RARROW); /* right arrow key */ case 0x4f: return(K_END); /* end key */ case 0x50: return(K_DARROW); /* down arrow key */ case 0x51: return(K_PGDOWN)); /* page down key */ case 0x52: return(K_INSERT); /* insert key */ default: /* just ignore it ... */ continue; } /* * If we aren't in command mode, 0xe0 * is a perfectly legitimate * character, & we can't really tell * whether or not it's supposed to be * a function key, so we just have to * return it as is. */ } } return (unsigned char) k.chChar; } }
void loading() { int l_x=20,l_y=20,l_w=20; int dly=100; textcolor(7); tbox(l_x,l_y,l_w); gotoxy(l_x,l_y-1); delay(dly); printf("loading..."); delay(dly); textbackground(0); gotoxy(l_x,l_y); printf("%c",219); delay(dly); printf("%c",219); delay(dly); detectmouse ();//detecting and initializing mouse gotoxy(l_x+2,l_y); printf("%c",219); delay(dly); printf("%c",219); delay(dly); showmouse ();//assigning the flaag interrupt for showing mouse as true // curnt_fn=filmain; gotoxy(l_x+4,l_y); delay(dly); printf("%c",219); delay(dly); printf("%c",219); fp=fopen("settings.txt","r"); fscanf(fp,"%d %d %d %d %d",&read_flag.fil,&read_flag.name,&read_flag.name,&read_flag.price,&read_flag.st); fcloseall(); delay(dly); gotoxy(l_x+6,l_y); printf("%c",219); delay(dly); gotoxy(l_x+7,l_y); printf("%c",219); delay(dly); gotoxy(l_x+8,l_y); printf("%c",219); delay(dly); gotoxy(l_x+9,l_y); printf("%c",219); gotoxy(l_x+10,l_y); printf("%c",219); fopen ("File.txt","a"); gotoxy(l_x+11,l_y); printf("%c",219); gotoxy(l_x+12,l_y); printf("%c",219); if (!fopen("Psswd.txt","r")) { fp=fopen("Psswd.txt","w"); fprintf(fp," "); fcloseall(); } gotoxy(l_x+13,l_y); printf("%c",219); gotoxy(l_x+14,l_y); printf("%c",219); gotoxy(l_x+15,l_y); printf("%c",219); gotoxy(l_x+16,l_y); printf("%c",219); fcloseall(); gotoxy(l_x+17,l_y); printf("%c",219); delay(dly); gotoxy(l_x+18,l_y); printf("%c",219); gotoxy(l_x+19,l_y); printf("%c",219); //getch(); //if (fopen()) tbldisp();//initial display for the table of the bill curnt_fn=billmain;//assigning the current function as the main of the billing part //billmain contorlls the event hanling in the bill }
void grf_scrollup(int grf, int x1, int y1, int x2, int y2, int numlines, int color) { struct grf_softc *gp; register u_long *ptr1, *ptr2; u_long longspertline /* , numlongs */ ; /* MBW -- added the following line for the efficiency fix below */ u_long rowbytes, bytecount; long rowcnt; if (grf == -1) { return; } grf_flush(grf); gp = &grf_Softc[grf]; if (x1 < 0) { x1 = 0; } if (y1 < 0) { y1 = 0; } if (x2 > gp->g_term.numtcols - 1) { x2 = gp->g_term.numtcols - 1; } if (y2 > gp->g_term.numtrows - 1) { y2 = gp->g_term.numtrows - 1; } if (numlines >= y2 - y1 + 1) { grf_eraserect(grf, x1, y1, x2, y2, color); return; } hidemouse(gp); longspertline = gp->g_display.rowbytes * gp->g_term.font.height / sizeof(long); /* MBW -- divide by 4 because it will be added to a (long*) */ rowbytes = gp->g_display.rowbytes / sizeof(long); if (numlines > 0) { if (x1 == 0 && x2 == gp->g_term.numtcols - 1) { rowcnt = (y2 - y1 + 1 - numlines) * gp->g_term.font.height; if (rowcnt < 0) { grf_eraserect(grf, x1, y1, x2, y2, color); showmouse(gp); return; } bytecount = (7 + gp->g_term.font.width * gp->g_term.numtcols) >> 3; ptr1 = (u_long *) (gp->g_display.fbbase) + y1 * longspertline; ptr2 = ptr1 + longspertline * numlines; while (rowcnt--) { bcopy(ptr2, ptr1, bytecount); ptr1 += rowbytes; ptr2 += rowbytes; } } else { /* XXX */ }