int dGetLineBox (char * s,int max,int width,int x,int y) { int pos = strlen(s); int refresh = 1; uint key; char c; while(1) { if (refresh) { dAreaClear(x,y,x+width*6+2,y+10,2); if (pos<width-1) { PrintXY (x+1,y+2,(uchar*)s,0); PrintXY (x+1+pos*6,y+2,(uchar*)"_",0); } else { PrintXY (x+1,y+2,(uchar*)(s+pos-width+1),0); PrintXY (x+1+(width-1)*6,y+2,(uchar*)"_",0); } refresh = 0; } GetKey(&key); if ((c=dGetKeyChar(key))!=0) { if (pos>=max) continue; s[pos++] = c;s[pos] = '\0'; refresh = 1; } else { if (key==KEY_CTRL_DEL) { if (pos<=0) continue; s[--pos] = '\0'; refresh = 1; } else if (key==KEY_CTRL_AC) { *s = 0; pos = 0; refresh = 1; } else if (key==KEY_CTRL_EXE) return 1; else if (key==KEY_CTRL_EXIT) return 0; } } }
void DrawKeyboard(Image *Img,unsigned int CurKey) { unsigned int X,Y,J,I,K,L; char S[2]; pixel *P; /* Keyboard in the right-bottom corner by default */ X=Img->W-KEYSTEP*XKEYS-8; Y=Img->H-KEYSTEP*YKEYS-8; /* Draw modifiers */ if(CurKey&CON_MODES) { J=X; if(CurKey&CON_SHIFT) { PrintXY(Img,"SHIFT",J,Y-8,CLR_ACTIVEB,-1);J+=48; } if(CurKey&CON_CONTROL) { PrintXY(Img,"CTRL",J,Y-8,CLR_ACTIVEB,-1);J+=40; } if(CurKey&CON_ALT) { PrintXY(Img,"ALT",J,Y-8,CLR_ACTIVEB,-1);J+=32; } } /* Draw keys */ for(I=J=0,S[1]='\0';KBDLines[I];++I,Y+=KEYSTEP,X+=KBDOffsets[I]-J*KEYSTEP) for(J=0;KBDLines[I][J];++J,X+=KEYSTEP) { /* Draw key frame */ P = (pixel *)Img->Data + Img->L*(Y+(KEYSTEP-KEYSIZE)/2) + X+(KEYSTEP-KEYSIZE)/2; /* Highlight current key */ if(KBDKeys[I][J]==(CurKey&CON_KEYCODE)) { for(K=1;K<KEYSIZE-1;++K) P[K]=CLR_ACTIVEB; for(K=1,P+=Img->L;K<KEYSIZE-1;++K,P+=Img->L) for(L=0;L<KEYSIZE;++L) P[L]=CLR_ACTIVEB; for(K=1;K<KEYSIZE-1;++K) P[K]=CLR_ACTIVEB; K=CLR_ACTIVEF; } else { for(K=1;K<KEYSIZE-1;++K) P[K]=CLR_NORMALF; for(K=1,P+=Img->L;K<KEYSIZE-1;++K,P+=Img->L) { for(L=1;L<KEYSIZE-1;++L) P[L]=CLR_NORMALB; P[0]=P[KEYSIZE-1]=CLR_NORMALF; } for(K=1;K<KEYSIZE-1;++K) P[K]=CLR_NORMALF; K=CLR_NORMALF; } /* Draw key label */ S[0]=KBDLines[I][J]; PrintXY(Img,S,X+(KEYSTEP-8)/2,Y+(KEYSTEP-8)/2,K,-1); } }
/** Do the platform specific action after the console is connected. Such as: Dynamically switch output mode; Signal console ready platform customized event; Run diagnostics like memory testing; Connect certain devices; Dispatch aditional option roms. **/ VOID EFIAPI PlatformBootManagerAfterConsole ( VOID ) { EFI_GRAPHICS_OUTPUT_BLT_PIXEL Black; EFI_GRAPHICS_OUTPUT_BLT_PIXEL White; EFI_INPUT_KEY Enter; EFI_INPUT_KEY F2; EFI_INPUT_KEY F7; EFI_BOOT_MANAGER_LOAD_OPTION BootOption; UINTN OptionNumber; Black.Blue = Black.Green = Black.Red = Black.Reserved = 0; White.Blue = White.Green = White.Red = White.Reserved = 0xFF; EfiBootManagerConnectAll (); EfiBootManagerRefreshAllBootOption (); // // Register ENTER as CONTINUE key // Enter.ScanCode = SCAN_NULL; Enter.UnicodeChar = CHAR_CARRIAGE_RETURN; EfiBootManagerRegisterContinueKeyOption (0, &Enter, NULL); // // Map F2 to Boot Manager Menu // F2.ScanCode = SCAN_F2; F2.UnicodeChar = CHAR_NULL; EfiBootManagerGetBootManagerMenu (&BootOption); EfiBootManagerAddKeyOptionVariable (NULL, (UINT16) BootOption.OptionNumber, 0, &F2, NULL); // // 3. Boot Device List menu // F7.ScanCode = SCAN_F7; F7.UnicodeChar = CHAR_NULL; OptionNumber = GetBootManagerMenuAppOption (); EfiBootManagerAddKeyOptionVariable (NULL, (UINT16)OptionNumber, 0, &F7, NULL); // // Make Shell as the first boot option // EfiBootManagerSortLoadOptionVariable (LoadOptionTypeBoot, (SORT_COMPARE) CompareBootOption); PlatformBootManagerDiagnostics (QUICK, TRUE); PrintXY (10, 10, &White, &Black, L"F2 to enter Setup. "); PrintXY (10, 30, &White, &Black, L"F7 to enter Boot Manager Menu."); PrintXY (10, 50, &White, &Black, L"Enter to boot directly."); }
/* Limited length prints. */ VOID LPrintXY(WCHAR *Text,INT LenghtLimit,INT x,INT y){ INT i; WCHAR Temp[MAX_PATH]; if(wcslen(Text) <= (size_t)LenghtLimit) PrintXY(Text,x,y); else{ for(i=0;i<LenghtLimit - 3;++i) Temp[i] = Text[i]; Temp[i]='\0'; wcscat(Temp,TEXT("...")); PrintXY(Temp,x,y); } }
int Input_Regcode() { unsigned int key ; BYTE pos = 0 ; BYTE str_flag = FALSE ; int x = 58 ; int y = 26 ; int ptr = -1 ; PopUpWin(3) ; locatestr(15,22); printf("机器码%s",(unsigned char*)m_id) ; GetKey(&key) ; Bdisp_AllClr_DDVRAM() ; PopUpWin(3) ; printf("注册码 ") ; DrawRect(56,23,12,53) ; while(str_flag != TRUE) { GetKey(&key) ; switch (key) { case KEY_CTRL_EXE: regstr[pos] = '\0' ; str_flag =TRUE ; break ; case KEY_CTRL_ALPHA: break ; case KEY_CTRL_DEL: if (pos) regstr[--pos] = '\0' ; PrintXY(x, y, (unsigned char *)" ", 0) ; break ; default: break ; } /* Numbers and characters */ if ( (pos < 8) && ((key >= KEY_CHAR_0 && key <= KEY_CHAR_9) || (key >= KEY_CHAR_A && key <= KEY_CHAR_Z)) ) { regstr[pos] = (char)key ; ++pos ; } PrintXY(x, y, (unsigned char *)regstr, 0) ; } return ; }
void GoL_editRules(settings* sets) { unsigned char cursor_y = 0; unsigned char cursor_x = 0; while(!KeyDown(31)){ if(KeyDown(28) && cursor_y){//up if(cursor_y == 1) cursor_x = 0; cursor_y--; } if(KeyDown(37) && cursor_y < 2) {//down if(cursor_x == 0) cursor_x = 0; cursor_y++; } if(KeyDown(38) && cursor_x) {//left cursor_x--; } if(KeyDown(27) && cursor_x < (cursor_y == 0 ? sets->col_num -1 : 8)) {//right cursor_x++; } if(KeyDown(78)) { switch(cursor_y) { case 0: break; case 1: sets->gol_neighbour_num_survive[cursor_x] ^= 1; break; case 2: sets->gol_neighbour_num_born[cursor_x] ^= 1; break; } } GoL_showRules(sets); if(cursor_y == 0) { Rectangle(18 + 20*cursor_x, 18, 32 + 20*cursor_x, 32, 1, COLOR_RED); }else{ unsigned char check[] = " \xE6\xA5"; //Check box unsigned char box = cursor_y == 1 ?sets->gol_neighbour_num_survive[cursor_x] : sets->gol_neighbour_num_born[cursor_x]; check[3] = box? 0xA9 : 0xA5; PrintXY( cursor_x+4, 3*cursor_y, check, TEXT_MODE_NORMAL, TEXT_COLOR_RED ); Print_OS(check, TEXT_MODE_NORMAL, TEXT_COLOR_RED); } Bdisp_PutDisp_DD(); int time = RTC_GetTicks(); while(RTC_GetTicks() - time < 16); } }
/* Limited length number prints. */ VOID LNPrintXY(SIZE_T Num,INT LenghtLimit,INT x,INT y){ INT i; WCHAR Temp[MAX_PATH]; WCHAR Text[LONGEST_64BIT_NUM]; for(i=0;Num>0;++i,Num/=10) Text[i] = Num%10 + '0'; if(i==0) Text[i++]='0'; Text[i]='\0'; _wcsrev(Text); if(wcslen(Text) <= (size_t)LenghtLimit) PrintXY(Text,x,y); else{ for(i=0;i<LenghtLimit - 3;++i) Temp[i] = Text[i]; Temp[i]='\0'; wcscat(Temp,TEXT("...")); PrintXY(Temp,x,y); } }
/* Converts a long number to string. then prints it in the given position using PrintXY function. */ VOID NPrintXY(ULONG64 Num,INT x,INT y){ INT i; WCHAR Text[LONGEST_64BIT_NUM]; for(i=0;Num>0;++i,Num/=10) Text[i] = Num%10 + '0'; if(i==0) Text[i++]='0'; Text[i]='\0'; wcsrev(Text); PrintXY(Text,x,y); }
Exec_info play_game() { static int delay_t, sound_t; char pc_s[10]; uint16_t next_instruction; int id_opcode; int debug = 0, key_menu = 0; Exec_info exec_info = {0,0,0}; exec_info.tick_start = time_getTicks(); while(!keydown(47)) { if(debug) { memset(pc_s, '*', 10); itoa(machine.pc, pc_s + 3); PrintXY(2, 8, pc_s, 0, 0); Bdisp_PutDisp_DD(); OS_InnerWait_ms(800); } if(keydown(78)) debug ^= 1; if(keydown(48)) { while(key_menu != KEY_CTRL_MENU) { GetKey(&key_menu); } } next_instruction = (machine.memory[machine.pc])<<8 | machine.memory[machine.pc+1]; id_opcode = get_opcode(next_instruction); (*do_opcode[id_opcode])(next_instruction); exec_info.cycles_count++; if(machine.delay > 0 && time_getTicks() - delay_t > TIMER_TICKS_PERIOD) { machine.delay --; delay_t = time_getTicks(); } if(machine.sound > 0 && time_getTicks() - sound_t > TIMER_TICKS_PERIOD) { machine.sound --; sound_t = time_getTicks(); } if(id_opcode == 28) delay_t == time_getTicks(); else if(id_opcode == 29) sound_t == time_getTicks(); if(machine.draw_state) { display(); machine.draw_state = 0; } } exec_info.tick_end = time_getTicks(); return exec_info; }
static void askQ(const char*msg,char*buf,int n){ //Clear areas from old question. struct display_fill fill; fill.x1=0; fill.x2=383; fill.y1=144; fill.y2=168; fill.mode=0; Bdisp_AreaClr(&fill,1,0); PrintXY(1,6,msg,0,0); getStrn(1,7,n,buf); }
void PrintLayoutDual(){ /* I.S. */ /* F.S. */ /* Proses: */ /* Kamus Lokal */ /* Algoritma */ PrintXY(33, 1, FontBlue Bold " _ _ _ _ ______ \n"); //ASCI Art - Judul PrintXY(33, 2, " | || || | | | _ / __ |\n"); PrintXY(33, 3, " | || || | ___ ____ _ | | ____ ____ ____ ____ | |_ ___| | //| |\n"); PrintXY(33, 4, " | ||_|| |/ _ \\ / ___) || |/ _ | \\ / _ ) _ \\| _|___) |// | |\n"); PrintXY(33, 5, " | |___| | |_| | | ( (_| ( ( | | | | ( (/ /| | | | |__ | /__| |\n"); PrintXY(33, 6, " \\______|\\___/|_| \\____|\\_||_|_|_|_|\\____)_| |_|\\___) \\_____/\n" Reset); PrintXY(33, 7, "\t\t\t\t\t\t\tby AnakGajah\n"); //Nama Team printf("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n"); PrintXY(1, 9, "╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮\n"); //Border PrintXY(1, 27, "╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n"); }
/**** Draw on terminal ****/ void PrintLayout(){ /* I.S. */ /* F.S. */ /* Proses: */ /* Kamus Lokal */ int i; /* Algoritma */ printf(FontBlue Bold " _ _ _ _ ______ \n"); //ASCI Art - Judul printf(" | || || | | | _ / __ |\n"); printf(" | || || | ___ ____ _ | | ____ ____ ____ ____ | |_ ___| | //| |\n"); printf(" | ||_|| |/ _ \\ / ___) || |/ _ | \\ / _ ) _ \\| _|___) |// | |\n"); printf(" | |___| | |_| | | ( (_| ( ( | | | | ( (/ /| | | | |__ | /__| |\n"); printf(" \\______|\\___/|_| \\____|\\_||_|_|_|_|\\____)_| |_|\\___) \\_____/\n" Reset); printf("\t\t\t\t\t\t\tby AnakGajah\n"); //Nama Team printf("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n"); PrintXY(1, 9, "╭──────────────────────────────────────────────────────────────────╮\n"); //Border for (i = 1; i <= 17; i++){ PrintXY(1, 9 + i, "│ │\n"); } PrintXY(1, 27, "╰──────────────────────────────────────────────────────────────────╯\n"); }
void main(void){ int x,y; char buf[1024];//In this example nothing is done with the buffer, I leave it as an exercise to the reader to do something with the inputted text. Bdisp_EnableColor(0); Bdisp_AllClr_VRAM(); //Print the "explanation" PrintXY(1,1," Stop!",0,0); x=0; y=32; PrintMini(&x,&y,"Who would cross the Bridge of Death",0,0xFFFFFFFF,0,0,0,0xFFFF,1,0); x=0; y=56; PrintMini(&x,&y,"must answer me these questions three,",0,0xFFFFFFFF,0,0,0,0xFFFF,1,0); x=0; y=80; PrintMini(&x,&y,"ere the other side he see.",0,0xFFFFFFFF,0,0,0,0xFFFF,1,0); PrintXY(1,5," What... is",0,0); for(;;){ askQ(" your name?",buf,1024); askQ(" your quest?",buf,1024); askQ(" your favorite color?",buf,1024);//The text fits by using American spelling. Yes I know Monty Python is a British show. } }
void PrintStatistik(){ /* I.S. */ /* F.S. */ /* Proses: */ /* Kamus Lokal */ int i; /* Algoritma */ PrintXY(3, 12, " Statistik Board [ ] "); //Container Statistik PrintXY(3, 13, "╔═══════════════════════════════════╗"); for (i = 1; i <= 10; i++){ PrintXY(3, 13+i, "║ ║"); } PrintXY(5, 15, FontBlue "TOTAL PEMAIN"); PrintXY(5, 18, "RATA-RATA SELURUH SCORE"); PrintXY(5, 21, "RANKING KESULITAN BOARD" Reset); PrintXY(3, 24, "╚═══════════════════════════════════╝"); }
void PrintMatriks(){ /* I.S. */ /* F.S. */ /* Proses: */ /* Kamus Lokal */ int i, j; /* Algoritma */ PrintXY(3, 10, "╭───────┬───────┬───────┬───────╮"); //Matrix Border for (i = 1; i <= 12; i += 4){ PrintXY(3, 13 + i, "├───────┼───────┼───────┼───────┤"); } for(i = 1; i <= 33; i += 8){ for (j = 1; j <= 13; j += 4){ PrintXY(2 + i, 10 + j, "│"); PrintXY(2 + i, 11 + j, "│"); PrintXY(2 + i, 12 + j, "│"); } } PrintXY(3, 26, "╰───────┴───────┴───────┴───────╯"); }
void doTextArea(textArea* text) { int scroll = 0; int key; while(1) { drawRectangle(text->x, text->y+24, text->width, LCD_HEIGHT_PX-24, COLOR_WHITE); int cur = 0; int textX = text->x; int textY = scroll+(text->showtitle ? 24 : 0); // 24 pixels for title (or not) int temptextY = 0; int temptextX = 0; while(cur <= text->numelements-1) { if(text->elements[cur].newLine) { textX=text->x; textY=textY+text->lineHeight+text->elements[cur].lineSpacing; } unsigned char* singleword = (unsigned char*)malloc(strlen(text->elements[cur].text)); // because of this, a single text element can't have more bytes than malloc can provide unsigned char* src = (unsigned char*)text->elements[cur].text; while(*src) { temptextX = 0; src = toksplit(src, ' ', (unsigned char*)singleword, strlen(text->elements[cur].text)); //break into words; next word //check if printing this word would go off the screen, with fake PrintMini drawing: PrintMini(&temptextX, &temptextY, (unsigned char*)singleword, 0, 0xFFFFFFFF, 0, 0, text->elements[cur].color, COLOR_WHITE, 0, 0); if(temptextX + textX > text->width-6) { //time for a new line textX=text->x; textY=textY+text->lineHeight; PrintMini(&textX, &textY, (unsigned char*)singleword, 0, 0xFFFFFFFF, 0, 0, text->elements[cur].color, COLOR_WHITE, 1, 0); } else { //still fits, print new word normally PrintMini(&textX, &textY, (unsigned char*)singleword, 0, 0xFFFFFFFF, 0, 0, text->elements[cur].color, COLOR_WHITE, 1, 0); } //add a space, since it was removed from token if(*src || text->elements[cur].spaceAtEnd) PrintMini(&textX, &textY, (unsigned char*)" ", 0, 0xFFFFFFFF, 0, 0, COLOR_BLACK, COLOR_WHITE, 1, 0); } free(singleword); cur++; } if(text->showtitle) { unsigned char buffer[50] = ""; unsigned char buffer2[50] = ""; strcpy((char*)buffer, " "); strcpy((char*)buffer2, ""); strcat((char*)buffer, (char*)text->title); PrintXY(1, 1, (char*)" ", TEXT_MODE_NORMAL, TEXT_COLOR_BLUE); PrintXY(1, 1, (char*)buffer, TEXT_MODE_TRANSPARENT_BACKGROUND, TEXT_COLOR_BLUE); } //draw a scrollbar: if(text->scrollbar) { TScrollbar sb; sb.I1 = 0; sb.I5 = 0; sb.indicatormaximum = (textY-scroll); sb.indicatorheight = 10*17; sb.indicatorpos = -scroll; sb.barheight = LCD_HEIGHT_PX-24*(text->showtitle ? 2 : 1); sb.bartop = (text->showtitle ? 24 : 0); sb.barleft = text->width - 6; sb.barwidth = 6; Scrollbar(&sb); } GetKey(&key); switch(key) { case KEY_CTRL_UP: if (scroll < 0) { scroll = scroll + 17; } break; case KEY_CTRL_DOWN: if (textY > LCD_HEIGHT_PX-24*2) { scroll = scroll - 17; } break; case KEY_CTRL_EXIT: return; break; } } }
int ProjSet() { unsigned int key = 0 ; unsigned int back_key = 0 ; BYTE row = 0 ; BYTE exit_flag = FALSE ; Bdisp_AllClr_DDVRAM() ; /* clear screen */ Print_zh(" 设置 ", 2, 0, VERT_REV) ; PrintMini(2, 58, (unsigned char*)" F1 ", MINI_REV) ; PrintMini(21, 58, (unsigned char*)" F2 ", MINI_REV) ; //PrintMini(40, 58, (unsigned char*)" F3 ", MINI_REV) ; PrintMini(105, 58, (unsigned char*)" EXIT ", MINI_REV) ; while (exit_flag != TRUE) { switch (key) { case KEY_CTRL_F1: default: back_key = key ; Bdisp_AreaClr_DDVRAM(&clear_area) ; locatestr(27,2) ;printf("放样:增减桩距 ") ; locatestr(67,16) ;printf("%.3f", allset.stake_d) ; locatestr(27,29) ;printf("反算:最大路宽 ") ; locatestr(67,43) ;printf("%.3f", allset.width_max) ; PrintXY(120, 6, (unsigned char*)"\xE6\x9C ", 0) ; PrintXY(120, 49, (unsigned char*)"\xE6\x9D ", 0) ; if (row > 1) { /* 判断是否进入下一个菜单 */ key = KEY_CTRL_F2 ; row = 0 ; break ; } key = InputVal(53, 17+row*27) ; switch (row) { case 0: allset.stake_d = number ? number : allset.stake_d ;break ; case 1: allset.width_max = number ? number : allset.width_max ;break ; default: break ; } break ; case KEY_CTRL_F2: back_key = key ; Bdisp_AreaClr_DDVRAM(&clear_area) ; locatestr(27,2) ;printf("1=交点 2=线元 ") ; locatestr(77,16) ;printf("%.3f", allset.xl_type) ; locatestr(27,29) ;printf("1=正交 2=任意 ") ; locatestr(77,43) ;printf("%.3f", allset.pj_mode) ; PrintXY(120, 6, (unsigned char*)"\xE6\x9C ", 0) ; PrintXY(120, 46, (unsigned char*)"\xE6\x9D ", 0) ; if (row > 1) { /* 判断是否进入下一个菜单 */ if ( SaveProj() != -1 ) Warning("设置成功 ", 2) ; else Warning("设置失败 ", 2) ; exit_flag = TRUE ; break; } key = InputVal(53, 17+row*27) ; switch (row) { case 0: allset.xl_type = (number==1 || number==2) ? number : allset.xl_type ;break ; case 1: allset.pj_mode = (number==1 || number==2) ? number : allset.pj_mode ;break ; default: break ; } break ; case KEY_CTRL_UP: if (row > 0) --row ; key = back_key ; break ; case KEY_CTRL_DOWN: case KEY_CTRL_EXE: ++row ; key = back_key ; break ; case KEY_CTRL_DEL: key = back_key ; break ; case KEY_CTRL_EXIT : exit_flag = TRUE ; break ; } } }
int Explorer( int size, char *folder ) { int top, redraw; int i; unsigned int key; redraw = 1; top = index; while(1) { if( redraw ) { Bdisp_AllClr_VRAM(); //DrawPicture( 1, 56, 61, 8, graph_bar ); PrintMini(1, 58, (unsigned char*)" EXE ", MINI_REV) ; PrintMini(105, 58, (unsigned char*)" EXIT ", MINI_REV) ; locate(1, 1);Print((unsigned char*)"File List [ ]"); locate(13, 1);Print( strlen(folder) ? (unsigned char*)folder : (unsigned char*)"Root"); if( size < 1 ){ locate( 8, 4 ); Print( (unsigned char*)"No Data" ); } else{ if( top > index ) top = index; if( index > top + N_LINE - 1 ) top = index - N_LINE + 1; if( top < 0 ) top = 0; for(i = 0;i < N_LINE && i + top < size; ++i ){ locate( 1, i + 2 ); if( files[i + top].filesize == -1 ) pPrintf( " [%s]", files[i + top].filename ); else pPrintf( " %-12s:%6u ", files[i + top].filename, files[i + top].filesize ); } Bdisp_AreaReverseVRAM( 0, (index-top+1)*8 , 127, (index-top+2)*8-1 ); if( top > 0 ) PrintXY( 120, 8, (unsigned char*)"\xE6\x92", top == index ); if( top + N_LINE < size ) PrintXY( 120, N_LINE*8, (unsigned char*)"\xE6\x93" , top + N_LINE - 1 == index ); } redraw = 0; } GetKey(&key); if( key==KEY_CTRL_UP ){ if( --index < 0 ) index = size - 1; redraw = 1; } else if( key==KEY_CTRL_DOWN ){ if( ++index > size - 1 ) index = 0; redraw = 1; } else if( key==KEY_CTRL_EXE || key == KEY_CTRL_F1) break; else if( key == KEY_CTRL_F2 ){ //Help(); redraw = 1; } else if( key == KEY_CTRL_F3 ){ //About(); redraw = 1; } else if( key==KEY_CTRL_EXIT){ index = size; break; } } }
void DrawPenCues(Image *Img,int ShowDialpad,pixel Color) { pixel *P; int W,H,W9,W3,H3; P = (pixel *)Img->Data; W = Img->W; H = Img->H; W9 = W/9; W3 = W/3; H3 = H/3; /* Vertical edges */ DrawVLine(Img,W3,0,H-1,Color); DrawVLine(Img,W-W3,0,H-1,Color); /* Corner buttons */ DrawHLine(Img,0,W3,H>>4,Color); DrawHLine(Img,W-W3,W-1,H>>4,Color); DrawHLine(Img,0,W3,H-(H>>4),Color); DrawHLine(Img,W-W3,W-1,H-(H>>4),Color); /* Fire buttons (with overlap) */ DrawHLine(Img,W-W3,W-1,(H>>1)-(H>>4),Color); DrawHLine(Img,W-W3,W-1,(H>>1)+(H>>4),Color); /* Directional buttons */ DrawVLine(Img,W9,H>>4,H-(H>>4),Color); DrawVLine(Img,W3-W9,H>>4,H-(H>>4),Color); DrawHLine(Img,0,W3,H3,Color); DrawHLine(Img,0,W3,H-H3,Color); /* Button labels */ PrintXY(Img,"L",2,2,Color,-1); PrintXY(Img,"R",W-W3+2,2,Color,-1); PrintXY(Img,"B",W-W3+2,(H>>4)+2,Color,-1); PrintXY(Img,"A+B",W-W3+2,(H>>1)-(H>>4)+2,Color,-1); PrintXY(Img,"A",W-W3+2,(H>>1)+(H>>4)+2,Color,-1); PrintXY(Img,"SELECT",2,H-(H>>4)+2,Color,-1); PrintXY(Img,"START",W-W3+2,H-(H>>4)+2,Color,-1); /* If requested, show on-screen dialpad */ if(ShowDialpad) { DrawHLine(Img,W3,W-W3,H>>2,Color); DrawHLine(Img,W3,W-W3,H>>1,Color); DrawHLine(Img,W3,W-W3,H-(H>>2),Color); DrawVLine(Img,W3+W9,0,H-1,Color); DrawVLine(Img,W-W3-W9,0,H-1,Color); PrintXY(Img,"1",W3+2,2,Color,-1); PrintXY(Img,"2",W3+W9+2,2,Color,-1); PrintXY(Img,"3",W-W3-W9+2,2,Color,-1); PrintXY(Img,"4",W3+2,(H>>2)+2,Color,-1); PrintXY(Img,"5",W3+W9+2,(H>>2)+2,Color,-1); PrintXY(Img,"6",W-W3-W9+2,(H>>2)+2,Color,-1); PrintXY(Img,"7",W3+2,(H>>1)+2,Color,-1); PrintXY(Img,"8",W3+W9+2,(H>>1)+2,Color,-1); PrintXY(Img,"9",W-W3-W9+2,(H>>1)+2,Color,-1); PrintXY(Img,"*",W3+2,H-(H>>2)+2,Color,-1); PrintXY(Img,"0",W3+W9+2,H-(H>>2)+2,Color,-1); PrintXY(Img,"#",W-W3-W9+2,H-(H>>2)+2,Color,-1); } }
int detailsElement(a) { const char buffer[50]; char descente=-9; while (1) { Bdisp_AllClr_DDVRAM(); PrintXY(20,descente+13,elements[a].symbol,0); sprintf(buffer,"%s",elements[a].nom); PrintMini(40,descente+13,buffer,0); sprintf(buffer,"%d",a+1); // détail des éléments PrintMini((10-a/25),descente+15,buffer,0); sprintf(buffer,"masse molaire %.3f g/mol",elements[a].masse_mol); PrintMini(1,descente+23,buffer,0); PrintMini(20,descente+40,"propriete de base :",0); // if (elements[a].groupe>=1) { sprintf(buffer,"groupe : %d ",elements[a].groupe); PrintMini(1,descente+50,buffer,0); } if ((a>55 && a<71) || (a>87 && a<103)) PrintMini(1,descente+50,"pas de groupe",0); sprintf(buffer,"periode : %d ",elements[a].periode); PrintMini(1,descente+60,buffer,0); sprintf(buffer,"couch electro %s",elements[a].config_electro); PrintMini(1,descente+70,buffer,0); sprintf(buffer,"famille %s",family[ajout[a].famille]); PrintMini(1,descente+80,buffer,0); sprintf(buffer,"decouvert en %d",ajout[a].annee); PrintMini(1,descente+90,buffer,0); sprintf(buffer,"etat a 293.15 K : %s",etat[ajout[a].etat]); PrintMini(1,descente+100,buffer,0); PrintMini(20,descente+120,"reactivite :",0); // if (elements[a].electro_neg==0) { PrintMini(1,descente+130,"electro neg inconnue",0); } else { sprintf(buffer,"electro neg : %f ",elements[a].electro_neg); PrintMini(1,descente+130,buffer,0); } if (elements[a].valence>=0) { sprintf(buffer,"valence : %d ",elements[a].valence); PrintMini(1,descente+140,buffer,0); } else { PrintMini(1,descente+140,"valence inconnue",0); } Mini("ret",5); GetKey(&key); switch (key) { case 38 : a-=1,descente=-9; break; case 27 : a+=1,descente=-9; break; case 37 : descente-=4; break; case 28 : descente+=4; break; case 29 : case 31 : case 47 : return a; } a=(a<0 ? 117 : a>117 ? 0 : a); descente=(descente>-9 ? -9 : descente<-85 ? -85 : descente); // on fixe les limites de la page } }
int tableauEleMini(chang) { char buffer[50]; char y; char menu=0; char choix=-1; while(1) { Bdisp_AllClr_DDVRAM(); ML_bmp_or(TABLEAU_MINI,0,0,91,48); choix_famille(choix); // on met en place le choix sur les familles chang=(chang>=118 ? 0 : chang<=-1 ? 117 : chang); y=(chang>55 && chang<71 ? 9 : chang>87 && chang<103 ? 10 : elements[chang].periode); if (chang>55 && chang<71 || chang>87 && chang<103) { ML_rectangle(5*elements[chang].groupe-4,5*y-7,5*elements[chang].groupe-1,5*y-4,0,1,2); } else { ML_rectangle(5*elements[chang].groupe-4,5*y-4,5*elements[chang].groupe-1,5*y-1,0,1,2); } PrintXY(110-3*strlen(elements[chang].symbol),13,elements[chang].symbol,0); sprintf(buffer,"%d",chang+1); // détail des éléments sur la droite PrintMini(110-2*strlen(buffer),5,buffer,0); sprintf(buffer,"%.3f",elements[chang].masse_mol); PrintMini(110-2*strlen(buffer),23,buffer,0); if(menu==0) { Mini("maxi",0); Mini("find",1); Mini("mol",2); Mini("fami",4); Mini("det",5); GetKey(&key); switch(key) { case 79 : case 47 : return chang; case 69 : chang=find(chang); break; case 59 : calcul_mole(); break; case 39 : menu=1; break; case 29 : chang=detailsElement(chang); break; } } else if (menu==1) { Mini("n-me",0); Mini("halo",1); Mini("g-ra",2); Mini("m-ti",3); Mini("m-al",4); Mini(" -->",5); GetKey(&key); switch(key) { case 47 : menu=0; choix=-1; break; case 79 : choix=0; break; case 69 : choix=1; break; case 59 : choix=2; break; case 49 : choix=3; break; case 39 : choix=4; break; case 29 : menu=2; break; // on change dans les 2 menus } } else if (menu==2) { Mini("m-at",0); Mini("lant",1); Mini("acta",2); Mini("m-tr",3); Mini("p-tr",4); Mini(" -->",5); GetKey(&key); switch(key) { case 47 : menu=0; choix=-1;break; case 79 : choix=5; break; case 69 : choix=6; break; case 59 : choix=7; break; case 49 : choix=8; break; case 39 : choix=9; break; case 29 : menu=1; break; // on change dans les 2 menus } } switch(key) // pour les touches principales à chaque fois { case 27 : chang+=1; break; case 38 : chang-=1; break; case 37 : chang=elements[chang].dessous; break; case 28 : chang=elements[chang].dessus; break; case 31 : case 78 : chang=detailsElement(chang); break; } } }
int computeFS () { uint refresh = 2,key; int index = 0,i,hcs; char ch; double ht,hz,v,bh,hd; double value[4] = {0.0,0.0,0.0,0.0}; const char * context[] = {"","","",""}; while(1){ if (refresh == REFRESH_ALL){ refresh = REFRESH_PART; Bdisp_AllClr_VRAM(); SetMyFont(&stHz12x12,&stAsc6x12); //¶¨Òå×ÖÌå´óС DispStr(2,1, "Ïß "); DispStr(2,12,"· "); DispStr(2,25,"·´ "); DispStr(2,38,"Ëã "); ShowTitle(TITLE); DispStr(17,0, "×ø±êX: "); DispStr(17,13,"×ø±êY: "); DispStr(17,26,"×ø±êZ: "); //DispStr(17,39,"×ø±êZ: "); for (i=0;i<4;++i){ PrintXY(50,2+i*12,(uchar*)context[i],0); } PrintIcon (0,"Rou",0); PrintIcon (1,"Set",0); PrintIcon (2,"Disp",0); PrintIcon (3,"=0=",1); PrintIcon (4,"Save",1); PrintIcon (5,"?",0); } if (refresh == REFRESH_PART){ for (i=0;i<4;++i){ PrintFloat(value[i],48,0+i*12,index==i,4); //ÊäÈë¿òλÖà } refresh = 0; } GetKey(&key); switch(key){ case KEY_CTRL_F1 : SET(); refresh=REFRESH_ALL; break; case KEY_CTRL_F2 : ZSSET(); refresh=REFRESH_ALL; break; case KEY_CTRL_F3 : RestoreDisp(SAVEDISP_PAGE1);refresh=REFRESH_ALL;WaitKey();break; case KEY_CTRL_F4 : case KEY_CTRL_F5 : Nodata(); refresh=REFRESH_ALL; break; case KEY_CTRL_F6 : About(); refresh=REFRESH_ALL; break; case KEY_CTRL_UP : refresh=REFRESH_PART; --index; break; case KEY_CTRL_DOWN : refresh=REFRESH_PART; ++index; break; case KEY_CTRL_EXE: if (index<3){ refresh = REFRESH_PART; index++; }else{ yscs.x1 = value[0]; yscs.y1 = value[1]; hz = value[2]; ht = value[3]; refresh=REFRESH_ALL; //yscs.k=0.0; yscs.k=xy_to_sdSrd( yscs.x1, yscs.y1, 0); yscs.d=xy_to_sdSrd( yscs.x1, yscs.y1, 1); //yscs.k=xy_to_sd( yscs.x1, yscs.y1, 0); //yscs.d=xy_to_sd( yscs.x1, yscs.y1, 1); //FS(); GC(); HP(); if (yscs.d<0) hcs=-1; //Æ«¾à×ó²à if (yscs.d>=0) hcs=1; //Æ«¾àÓÒ²à if (yscs.d*hcs<=zfset.zsp) hd=0; // if (zfset.zsh==0) hd=0; if (yscs.d*hcs>zfset.zsp && yscs.d*hcs-zfset.zsp<zfset.zsh) hd=(yscs.d*hcs-zfset.zsp)*hcs; if (yscs.d*hcs-zfset.zsp>=zfset.zsh) hd=zfset.zsh*hcs; bh=yscs.gch+(yscs.hpd*hd)-ht; Bdisp_AllClr_VRAM(); DispStr(2,0, "¼Æ "); DispStr(2,12,"Ëã "); DispStr(2,26,"½á "); DispStr(2,39,"¹û "); ShowTitle(TITLE); DispStr(17,0,"×®ºÅ "); DispStr(17,13,"Æ«¾à "); DispStr(17,26,"ÌîÍÚ: "); DispStr(17,39,"»ù¸ß: "); PrintfXY (48,2.5,0,"%.4f",yscs.k); PrintfXY (48,15,0,"%.4f",yscs.d); PrintfXY (48,28,0,"%.4f",yscs.gch); PrintfXY (48,42,0,"%.4f",yscs.hpd); //PrintfXY (22,40,0," H= %.3f",bh); //PrintfXY (22,48,0," H-Z= %.3f",hz-bh); SaveDisp(SAVEDISP_PAGE1); WaitKey(); ++index; }break; case KEY_CTRL_EXIT: return 0; default: if ((ch=GetPressNumChar(key))!=0){ char buf[14]; int r; refresh = REFRESH_PART; buf[0] = ch; buf[1] = '\0'; r = InputString (48,0+index*12,buf,0,12); //ÊäÈë¿òλÖà if (r != KEY_CTRL_EXIT){ value[index] = atof(buf); if (r==KEY_CTRL_DOWN) ++index; if (r==KEY_CTRL_UP) --index; if (r==KEY_CTRL_EXE && index<3) ++index; } break; } } if (index >=4) index = 2; if (index < 0) index = 3; } }
int find(chang) { char *numero=NULL; char i=0,j; const char buffer[50]; Bdisp_AllClr_DDVRAM(); PrintXY(10,1,"Vous cherchez :",0); PrintMini(10,15,"1. numero de l'element",0); PrintMini(10,25,"2. masse molaire",0); PrintMini(10,35,"3. Symbole de l'element",0); PrintMini(10,45,"4. Nom de l'element",0); while (1) { EI_init(); EI_manage_config(EI_SET_COLUMN, 1); EI_manage_config(EI_SET_ROW, 3); EI_manage_config(EI_SET_START_MODE, EI_NORMAL); GetKey(&key); switch(key) { case 72 : { while(1) { Bdisp_AllClr_DDVRAM(); PrintMini(1,1,"Vous cherchez l'element n :",0); numero=EI_input_string(3,(const char*)"0123456789"); // ça coupe ici if (atoi(numero)>0 && atoi(numero)<119) // ça arrête le curseur { return atoi(numero)-1; } } } case 62 : { while(1) { Bdisp_AllClr_DDVRAM(); PrintMini(1,1,"Vous cherchez une masse",0); PrintMini(1,7,"molaire de :",0); numero=EI_input_string(3,(const char*)"0123456789"); for (i=0;i<118;i++) { if (atoi(numero)==floor(elements[i].masse_mol+0.5)) { return i; } } } } case 52 : { while(1) { Bdisp_AllClr_DDVRAM(); PrintMini(1,1,"Vous cherchez le symbole ?",0); EI_manage_config(EI_SET_START_MODE, EI_ALPHA_LOCKED); numero=EI_input_string(3,(const char*)"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"); numero[0]=toupper (numero[0]); // on met le 1er caractère en majuscule for (i=0;i<118;i++) { for (j = 1 ; numero[j] != '\0' ; j++) { numero[j] = tolower(numero[j]); // on met certains caractères en minuscule pour la recherche } if (!strcmp(numero,elements[i].symbol)) { return i; } } } } case 73 : { while(1) { Bdisp_AllClr_DDVRAM(); PrintMini(1,1,"Vous cherchez le nom ?",0); EI_manage_config(EI_SET_START_MODE, EI_ALPHA_LOCKED); numero=EI_input_string(13,(const char*)"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"); numero[0]=toupper(numero[0]); // on met le 1er caractère en majuscule for (i=0;i<118;i++) { for (j = 1 ; numero[j] != '\0' ; j++) { numero[j] = tolower(numero[j]);// on met certains caractères en minuscule pour la recherche } if (!strcmp(numero,elements[i].nom)) { return i; } } } } case 47 : return chang; } } }
int memory_user_select(char **files, int n, int extension, int exit) { const unsigned char icons[7][32] = { { 0x0,0x3c,0xf,0xc4,0xf0,0x4,0x80,0x4,0x80,0x2,0x80,0x2,0x40,0x2,0x40,0x2,0x40,0x2,0x40,0x2,0x40,0x1,0x40,0x1,0x20,0x1,0x20,0xf,0x23,0xf0,0x3c,0x0 }, { 0x0,0x3c,0xf,0xc4,0xf0,0x4,0x80,0x74,0x87,0x82,0x98,0x2,0x40,0x2,0x40,0x3a,0x43,0xc2,0x5c,0x2,0x40,0x39,0x43,0xc1,0x2c,0x1,0x20,0xf,0x23,0xf0,0x3c,0x0 }, { 0x0,0x3c,0xf,0xc4,0xf0,0x74,0x87,0x94,0xb8,0x12,0xa0,0xa,0x63,0x8a,0x52,0x8a,0x54,0x4a,0x54,0x66,0x54,0x25,0x48,0x1d,0x29,0xe1,0x2e,0xf,0x23,0xf0,0x3c,0x0 }, { 0x0,0x3c,0xf,0xc4,0xf0,0x4,0x87,0xc4,0x88,0x22,0x8c,0x62,0x4b,0xa2,0x44,0x42,0x42,0x82,0x42,0x82,0x42,0x81,0x44,0x41,0x2f,0xe1,0x20,0xf,0x23,0xf0,0x3c,0x0 }, { 0x0,0x3c,0xf,0xc4,0xf0,0x4,0x87,0xe4,0x88,0x12,0x88,0x12,0x48,0x12,0x47,0xe2,0x44,0x22,0x44,0x22,0x44,0x21,0x44,0x21,0x23,0xc1,0x20,0xf,0x23,0xf0,0x3c,0x0 }, { 0x0,0x3c,0xf,0xc4,0xf0,0x4,0x80,0x64,0x87,0xb2,0x98,0x52,0x51,0xb2,0x57,0x52,0x51,0xd2,0x4b,0xa,0x48,0x19,0x49,0xe1,0x2e,0x1,0x20,0xf,0x23,0xf0,0x3c,0x0 }, { 0x0,0x3c,0xf,0xc4,0xf0,0x4,0x80,0xe4,0x9c,0xa2,0x90,0xa2,0x58,0xe2,0x50,0x2,0x40,0x12,0x4a,0x2a,0x4a,0x39,0x4e,0x29,0x22,0x1,0x20,0xf,0x23,0xf0,0x3c,0x0 } }; char *exts[19] = { ".txt", ".c", ".h", ".cpp", ".hpp", ".bmp",".jpg",".png",".gif", ".sav", ".g1m",".g2m",".g1r",".g2r", ".g1e",".g2e",".g1a", ".hex",".bin" }; unsigned char indexs[19] = { 1,1,1,1,1, 2,2,2,2, 3, 4,4,4,4, 5,5,5, 6,6 }; unsigned char *icoind = malloc(n); unsigned int key; int i,j,k,t; int p=0, offset=0; if(!icoind) { memory_error("user_sele.()","malloc()",1); return -2; } for(i=0;i<n;i++) { for(t=-1,j=0;*(*(files+i)+j);j++) if(*(*(files+i)+j) == '.') t = j; icoind[i] = (t==-1?1:0); for(k=0;k<19;k++) if(!strcmp(*(files+i)+t,exts[k])) { icoind[i]=indexs[k]; break; } if(!extension && t+1) *(*(files+i)+t) = 0; } while(1) { Bdisp_AllClr_VRAM(); for(t=0;t<(n>3?3:n);t++) { if(icoind[offset+i]!=255) for(i=0;i<32;i++) { k = icons[icoind[offset+t]][i]; for(j=0;j<8;j++) { if(k&1) Bdisp_SetPoint_VRAM(11-j+8*(i&1),20*t+4+(i>>1),1); k >>= 1; } } PrintXY(24,20*t+9,(const unsigned char *)*(files+offset+t),0); } Bdisp_DrawLineVRAM(2,20*p+3,2,20*p+20); Bdisp_DrawLineVRAM(3,20*p+2,99,20*p+2); Bdisp_DrawLineVRAM(3,20*p+21,99,20*p+21); Bdisp_DrawLineVRAM(100,20*p+3,100,20*p+20); if(offset>0) PrintXY(114,6,(const unsigned char *)"\346\234",0); if(offset+3<n) PrintXY(114,51,(const unsigned char *)"\346\235",0); while(1) { GetKey(&key); if(key==30002 && exit) { free(icoind); return -1; } if(key==30004) break; if(key==30018 && (offset||p)) { if(p==2) p--; else if(offset) offset--; else p--; break; } if(key==30023 && (offset+p+1<n)) { if(p==0) p++; else if(offset+3<n) offset++; else p++; break; } } if(key==30004) break; } free(icoind); return offset+p; }
int PM_parameter() { char * table_label[]= {"DH","QDZH","ZDZH","X","Y","FWJ","ZX","QDBJ","ZDBJ"}; char * icons[] = {"","","","",""}; char * ch_text[] = {"\xb5\xe3\xc3\xfb", "起点桩号", "终点桩号", "X坐标 ", "Y坐标 ", "方位角 ", "转向 ", "起点半径", "终点半径"}; int x = 0,y = 0,i,j,t; int left = 0,top = 0; int refresh = REDRAW_ALL; int enter,suc; char str[13]=""; char c; PMproduce(); //打开交点参数转换平面参数 InsertLine(l_pqx.length,&y,&refresh); GetListq(); //取链表链表线元参数 while(1){ if (refresh==REDRAW_ALL){ Bdisp_AllClr_VRAM(); for (i=0;i<4;++i) PrintTablesPM(i,0,table_label[left+i],1,1); t = pmroute.size<= 1 ? 2 : 5; //如果交点个数小于等于1 那么T=2 否则等于5 if (t>=2){ SetMyFont(&stHz8x8,&stAsc6x12); DispStr(2,56,"\xCE\xC4\xBC\xFE"); DispStr(23,56,"添加"); } if (t>2){ SetMyFont(&stHz8x8,&stAsc6x12); DispStr(45,56,"插入 "); DispStr(65,56,"删行 "); DispStr(86,56,"清空 "); } for (i=0;i< t;++i) // i<2 或 i<5 PrintIcon(i,icons[i],0); //打印下标 PrintIcon(5,"?",0); //固定打印下标 refresh = REDRAW_PART; // 重画部分 } if (refresh==REDRAW_PART){ //如果画部分 double * sd; for (i=top;i<top+4 && i<pmroute.size;++i){ sd = & (pmroute.set[i].pm_qk); for (j=(left==0 ? 1:0);j<4;++j){ //if (i==0 && j+left>3) ////////////////////////////////////////// //PrintTablesPM(j,i+1-top,"",y==i && x-left==j,0);/////////////// //else///////// PrintTableFormatPM(j,i+1-top,y==i && x-left==j,0,"%lf",sd[j+left-1]); } if (left==0) PrintTableFormatPM(0,i+1-top,y==i && x-left==0,0,"%s",pmroute.set[i].name); PrintTableIndexPM(i-top+1,i); } SetMyFont(&stHz12x12,&stAsc6x12); if(x>0){ //if (!(y==0 && x>2)){ sd = & (pmroute.set[y].pm_qk); //取地址的值*************** DispStr(0,42,ch_text[x]); PrintFloat(sd[x-1],49,42,0,setup_data.point); //打印 //} }else{ DispStr(0,42,ch_text[x]); PrintXY(51,44,pmroute.set[y].name,0); } refresh = 0; } GetKey(&key); switch (key){ case KEY_CTRL_UP: y--;refresh = REDRAW_ALL;break; case KEY_CTRL_DOWN: y++;refresh = REDRAW_ALL;break; case KEY_CTRL_LEFT: x--;refresh = REDRAW_ALL;break; case KEY_CTRL_RIGHT: x++;refresh = REDRAW_ALL;break; case KEY_CTRL_EXIT: pmroute_initial(&pmroute); InitList(&l_pqx); return 0 ; case KEY_CTRL_F1: /* Set */ refresh = REDRAW_ALL; SelectfilePM(); break; case KEY_CTRL_F2: /* Add */ pmroute_push_back (&pmroute); y = pmroute.size - 1; refresh = REDRAW_ALL; break; case KEY_CTRL_F3: /* ins */ //if (y==0) break; pmroute_insert (&pmroute,y); y++; refresh = REDRAW_ALL; break; case KEY_CTRL_F4: /* Del a point */ //if (y==0) break; refresh = REDRAW_ALL; PopUpWin(4);DispStr(25,10,"删 除 一 行?"); locate(3,5);Print("[F1]Yes [F6]No"); GetKey(&key); if (key==KEY_CTRL_F1){ pmroute_del(&pmroute,y);y--; } break; case KEY_CTRL_F5: /* Del All */ refresh = REDRAW_ALL; PopUpWin(4);DispStr(25,10,"清 空 所 有 ?"); locate(3,5);Print("[F1]Yes [F6]No"); GetKey(&key); if (key==KEY_CTRL_F1){ pmroute_initial(&pmroute); pmroute_push_back(&pmroute); } break; case KEY_CTRL_F6: refresh = REDRAW_ALL; //PrintfXY (70,30,0,"%.3f",route.set[0].xy_zr); //DispStr(15,10,"线路名称"); //if(setup_data.pmroute_name[0]==0) //{ //DispStr(25,27,"请保存线路文件 "); //} //else //{ //DispStr(25,27,setup_data.zdmroute_name); //} break; default: /*other things*/ if (x>0 && (c=GetPressNumChar(key))!=0){ char buffer[14]; int r; //if (y==0 && x > 3)break; buffer[0] = c; buffer[1] = '\0'; r = InputString(49,42,buffer,0,12); if (r!=KEY_CTRL_EXIT){ double * sd; sd = (double*)&(pmroute.set[y].pm_qk); sd[x-1] = atof(buffer); switch(r){ case KEY_CTRL_UP: y--;break; case KEY_CTRL_DOWN: y++;break; case KEY_CTRL_EXE: x++;break; } } refresh = REDRAW_ALL; } else if (x==0 && (c=GetPressChar(key))!=0){ char buffer[14]; int r; buffer[0] = c; buffer[1] = '\0'; r = InputString(49,42,buffer,1,12); if (r!=KEY_CTRL_EXIT){ strncpy(pmroute.set[y].name,buffer,12); switch(r){ case KEY_CTRL_UP: y--;break; case KEY_CTRL_DOWN: y++;break; case KEY_CTRL_EXE: x++;break; } } refresh = REDRAW_ALL; } break; } if (x<0) x = 8,y--; if (x>8) x = 0,y++; if (y<0) y = 0; if (y>=pmroute.size) y = pmroute.size - 1; if (y>top + 3) top = y - 3; if (y<top) top = y; if (x>left +3) left = x - 3; if (x<left) left = x; } }
void calcul_mole() { char *str = NULL, *p=str; char characts[20]={'\0'}; char i=0; float result=0, masse; const char buffer[50]={0}; char cap; while(1) { Bdisp_AllClr_DDVRAM(); PrintMini(1,1,"Entrez votre formule : ",0); Mini("A a",0); EI_init(); EI_manage_config(EI_SET_COLUMN, 1); EI_manage_config(EI_SET_ROW, 2); EI_manage_config(EI_SET_START_MODE, EI_NORMAL); str=EI_input_string(25,(const char*)"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"); Bdisp_AllClr_DDVRAM(); sprintf(buffer,"%s",str); PrintXY(64-3*strlen(str),10,buffer,36); while(*str) // on va jusqu'a la fin de la chaine { i=0; while(isalpha(*str)) // on prends seulement les lettres { characts[i]=tolower(*str); // on copie la lettre en minuscule directement dans characts ++i; ++str; } characts[0]=toupper(characts[0]); // on met le 1er caractère en majuscule for(i=0;i<118;i++) // on se déplace dans les éléments de la structure { if(!strcmp(characts,elements[i].symbol)) { masse=elements[i].masse_mol; // on a la masse molaire break; } } for(i=0;i<20;++i) // on remet tout à zéro : évite les erreurs characts[i]='\0'; i=0; while(isdigit(*str)) // on prends seulement les chiffres { characts[i]=*str; // on copie la lettre dans characts ++i; ++str; } result += atoi(characts)*masse; for(i=0;i<4;++i) // on remet tout à zéro : évite les erreurs characts[i]='\0'; } free(p); PrintMini(1,30,"la masse molaire est de",0); sprintf(buffer,"%.3f g/mol",result); PrintMini(1,40,buffer,0); Mini("calc",0); Mini("ret",5); GetKey(&key); switch(key) { case 29 : return; } } }
int ShowVideo(void) { Image *Output; int SX,SY; /* Must have active video image, X11 display */ if(!VideoImg||!VideoImg->Data) return(0); /* Allocate image buffer if none */ if(!OutImg.Data&&!NewImage(&OutImg,XSize,YSize)) return(0); /* Count framerate */ if((Effects&EFF_SHOWFPS)&&(++FrameCount>=120)) { struct timeval NewTS; int Time; gettimeofday(&NewTS,0); Time = (NewTS.tv_sec-TimeStamp.tv_sec)*1000 + (NewTS.tv_usec-TimeStamp.tv_usec)/1000; FrameRate = 1000*FrameCount/(Time>0? Time:1); TimeStamp = NewTS; FrameCount = 0; FrameRate = FrameRate>999? 999:FrameRate; } /* If not scaling or post-processing image, avoid extra work */ if(!(Effects&(EFF_SOFTEN|EFF_SCALE|EFF_TVLINES))) { /* Show framerate if requested */ if((Effects&EFF_SHOWFPS)&&(FrameRate>0)) { char S[8]; sprintf(S,"%02dfps",FrameRate); PrintXY(VideoImg,S, 8,8, FPS_COLOR,PIXEL(255,255,255) ); } screen_buffer_t screen_buf[1]; screen_get_window_property_pv(window, SCREEN_PROPERTY_RENDER_BUFFERS, (void **)screen_buf); int bg[] = { SCREEN_BLIT_END }; screen_blit(ctxt, screen_buf[0], VideoImg->pbuf, bg); screen_post_window(window, screen_buf[0], 1, rect, 0); return 1; } /* By default, we will be showing OutImg */ Output = &OutImg; SX = 0; SY = 0; if(Effects&EFF_SOFTEN) { /* Apply softening */ SoftenImage(&OutImg,VideoImg,VideoX,VideoY,VideoW,VideoH); /* Apply TV scanlines, if needed */ if(Effects&EFF_TVLINES) TelevizeImage(&OutImg,0,0,OutImg.W,OutImg.H); } else if(Effects&EFF_TVLINES) { if(Effects&EFF_SCALE) { /* Scale VideoImg into OutImg */ ScaleImage(&OutImg,VideoImg,VideoX,VideoY,VideoW,VideoH); /* Apply TV scanlines */ TelevizeImage(&OutImg,0,0,OutImg.W,OutImg.H); } else { /* Center VideoImg in OutImg */ IMGCopy(&OutImg,(OutImg.W-VideoW)>>1,(OutImg.H-VideoH)>>1,VideoImg,VideoX,VideoY,VideoW,VideoH,-1); /* Apply TV scanlines */ TelevizeImage(&OutImg,(OutImg.W-VideoW)>>1,(OutImg.H-VideoH)>>1,VideoW,VideoH); } } else if((OutImg.W==VideoW)&&(OutImg.H==VideoH))
/** Perform the memory test base on the memory test intensive level, and update the memory resource. @param Level The memory test intensive level. @retval EFI_STATUS Success test all the system memory and update the memory resource **/ EFI_STATUS EFIAPI BdsMemoryTest ( IN EXTENDMEM_COVERAGE_LEVEL Level ) { EFI_STATUS Status; EFI_STATUS KeyStatus; EFI_STATUS InitStatus; EFI_STATUS ReturnStatus; BOOLEAN RequireSoftECCInit; EFI_GENERIC_MEMORY_TEST_PROTOCOL *GenMemoryTest; UINT64 TestedMemorySize; UINT64 TotalMemorySize; UINTN TestPercent; UINT64 PreviousValue; BOOLEAN ErrorOut; BOOLEAN TestAbort; EFI_INPUT_KEY Key; CHAR16 StrPercent[80]; CHAR16 *StrTotalMemory; CHAR16 *Pos; CHAR16 *TmpStr; EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground; EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background; EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color; BOOLEAN IsFirstBoot; UINT32 TempData; UINTN StrTotalMemorySize; ReturnStatus = EFI_SUCCESS; ZeroMem (&Key, sizeof (EFI_INPUT_KEY)); StrTotalMemorySize = 128; Pos = AllocateZeroPool (StrTotalMemorySize); if (Pos == NULL) { return ReturnStatus; } StrTotalMemory = Pos; TestedMemorySize = 0; TotalMemorySize = 0; PreviousValue = 0; ErrorOut = FALSE; TestAbort = FALSE; SetMem (&Foreground, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0xff); SetMem (&Background, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0x0); SetMem (&Color, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0xff); RequireSoftECCInit = FALSE; Status = gBS->LocateProtocol ( &gEfiGenericMemTestProtocolGuid, NULL, (VOID **) &GenMemoryTest ); if (EFI_ERROR (Status)) { FreePool (Pos); return EFI_SUCCESS; } InitStatus = GenMemoryTest->MemoryTestInit ( GenMemoryTest, Level, &RequireSoftECCInit ); if (InitStatus == EFI_NO_MEDIA) { // // The PEI codes also have the relevant memory test code to check the memory, // it can select to test some range of the memory or all of them. If PEI code // checks all the memory, this BDS memory test will has no not-test memory to // do the test, and then the status of EFI_NO_MEDIA will be returned by // "MemoryTestInit". So it does not need to test memory again, just return. // FreePool (Pos); return EFI_SUCCESS; } if (!FeaturePcdGet(PcdBootlogoOnlyEnable)) { TmpStr = GetStringById (STRING_TOKEN (STR_ESC_TO_SKIP_MEM_TEST)); if (TmpStr != NULL) { PrintXY (10, 10, NULL, NULL, TmpStr); FreePool (TmpStr); } } else { DEBUG ((EFI_D_INFO, "Enter memory test.\n")); } do { Status = GenMemoryTest->PerformMemoryTest ( GenMemoryTest, &TestedMemorySize, &TotalMemorySize, &ErrorOut, TestAbort ); if (ErrorOut && (Status == EFI_DEVICE_ERROR)) { TmpStr = GetStringById (STRING_TOKEN (STR_SYSTEM_MEM_ERROR)); if (TmpStr != NULL) { PrintXY (10, 10, NULL, NULL, TmpStr); FreePool (TmpStr); } ASSERT (0); } if (!FeaturePcdGet(PcdBootlogoOnlyEnable)) { TempData = (UINT32) DivU64x32 (TotalMemorySize, 16); TestPercent = (UINTN) DivU64x32 ( DivU64x32 (MultU64x32 (TestedMemorySize, 100), 16), TempData ); if (TestPercent != PreviousValue) { UnicodeValueToString (StrPercent, 0, TestPercent, 0); TmpStr = GetStringById (STRING_TOKEN (STR_MEMORY_TEST_PERCENT)); if (TmpStr != NULL) { // // TmpStr size is 64, StrPercent is reserved to 16. // StrCatS (StrPercent, sizeof (StrPercent) / sizeof (CHAR16), TmpStr); PrintXY (10, 10, NULL, NULL, StrPercent); FreePool (TmpStr); } TmpStr = GetStringById (STRING_TOKEN (STR_PERFORM_MEM_TEST)); if (TmpStr != NULL) { PlatformBdsShowProgress ( Foreground, Background, TmpStr, Color, TestPercent, (UINTN) PreviousValue ); FreePool (TmpStr); } } PreviousValue = TestPercent; } else { DEBUG ((EFI_D_INFO, "Perform memory test (ESC to skip).\n")); } if (!PcdGetBool (PcdConInConnectOnDemand)) { KeyStatus = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key); if (!EFI_ERROR (KeyStatus) && (Key.ScanCode == SCAN_ESC)) { if (!RequireSoftECCInit) { if (!FeaturePcdGet(PcdBootlogoOnlyEnable)) { TmpStr = GetStringById (STRING_TOKEN (STR_PERFORM_MEM_TEST)); if (TmpStr != NULL) { PlatformBdsShowProgress ( Foreground, Background, TmpStr, Color, 100, (UINTN) PreviousValue ); FreePool (TmpStr); } PrintXY (10, 10, NULL, NULL, L"100"); } Status = GenMemoryTest->Finished (GenMemoryTest); goto Done; } TestAbort = TRUE; } } } while (Status != EFI_NOT_FOUND); Status = GenMemoryTest->Finished (GenMemoryTest); Done: if (!FeaturePcdGet(PcdBootlogoOnlyEnable)) { UnicodeValueToString (StrTotalMemory, COMMA_TYPE, TotalMemorySize, 0); if (StrTotalMemory[0] == L',') { StrTotalMemory++; StrTotalMemorySize -= sizeof (CHAR16); } TmpStr = GetStringById (STRING_TOKEN (STR_MEM_TEST_COMPLETED)); if (TmpStr != NULL) { StrCatS (StrTotalMemory, StrTotalMemorySize / sizeof (CHAR16), TmpStr); FreePool (TmpStr); } PrintXY (10, 10, NULL, NULL, StrTotalMemory); PlatformBdsShowProgress ( Foreground, Background, StrTotalMemory, Color, 100, (UINTN) PreviousValue ); } else { DEBUG ((EFI_D_INFO, "%d bytes of system memory tested OK\r\n", TotalMemorySize)); } FreePool (Pos); // // Use a DynamicHii type pcd to save the boot status, which is used to // control configuration mode, such as FULL/MINIMAL/NO_CHANGES configuration. // IsFirstBoot = PcdGetBool(PcdBootState); if (IsFirstBoot) { PcdSetBool(PcdBootState, FALSE); } return ReturnStatus; }
/** Show progress bar with title above it. It only works in Graphics mode. @param TitleForeground Foreground color for Title. @param TitleBackground Background color for Title. @param Title Title above progress bar. @param ProgressColor Progress bar color. @param Progress Progress (0-100) @param PreviousValue The previous value of the progress. @retval EFI_STATUS Success update the progress bar **/ EFI_STATUS PlatformBdsShowProgress ( IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL TitleForeground, IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL TitleBackground, IN CHAR16 *Title, IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL ProgressColor, IN UINTN Progress, IN UINTN PreviousValue ) { EFI_STATUS Status; EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput; EFI_UGA_DRAW_PROTOCOL *UgaDraw; UINT32 SizeOfX; UINT32 SizeOfY; UINT32 ColorDepth; UINT32 RefreshRate; EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color; UINTN BlockHeight; UINTN BlockWidth; UINTN BlockNum; UINTN PosX; UINTN PosY; UINTN Index; if (Progress > 100) { return EFI_INVALID_PARAMETER; } UgaDraw = NULL; Status = gBS->HandleProtocol ( gST->ConsoleOutHandle, &gEfiGraphicsOutputProtocolGuid, (VOID **) &GraphicsOutput ); if (EFI_ERROR (Status) && FeaturePcdGet (PcdUgaConsumeSupport)) { GraphicsOutput = NULL; Status = gBS->HandleProtocol ( gST->ConsoleOutHandle, &gEfiUgaDrawProtocolGuid, (VOID **) &UgaDraw ); } if (EFI_ERROR (Status)) { return EFI_UNSUPPORTED; } SizeOfX = 0; SizeOfY = 0; if (GraphicsOutput != NULL) { SizeOfX = GraphicsOutput->Mode->Info->HorizontalResolution; SizeOfY = GraphicsOutput->Mode->Info->VerticalResolution; } else if (UgaDraw != NULL) { Status = UgaDraw->GetMode ( UgaDraw, &SizeOfX, &SizeOfY, &ColorDepth, &RefreshRate ); if (EFI_ERROR (Status)) { return EFI_UNSUPPORTED; } } else { return EFI_UNSUPPORTED; } BlockWidth = SizeOfX / 100; BlockHeight = SizeOfY / 50; BlockNum = Progress; PosX = 0; PosY = SizeOfY * 48 / 50; if (BlockNum == 0) { // // Clear progress area // SetMem (&Color, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0x0); if (GraphicsOutput != NULL) { Status = GraphicsOutput->Blt ( GraphicsOutput, &Color, EfiBltVideoFill, 0, 0, 0, PosY - EFI_GLYPH_HEIGHT - 1, SizeOfX, SizeOfY - (PosY - EFI_GLYPH_HEIGHT - 1), SizeOfX * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) ); } else if (FeaturePcdGet (PcdUgaConsumeSupport)) { Status = UgaDraw->Blt ( UgaDraw, (EFI_UGA_PIXEL *) &Color, EfiUgaVideoFill, 0, 0, 0, PosY - EFI_GLYPH_HEIGHT - 1, SizeOfX, SizeOfY - (PosY - EFI_GLYPH_HEIGHT - 1), SizeOfX * sizeof (EFI_UGA_PIXEL) ); } else { return EFI_UNSUPPORTED; } } // // Show progress by drawing blocks // for (Index = PreviousValue; Index < BlockNum; Index++) { PosX = Index * BlockWidth; if (GraphicsOutput != NULL) { Status = GraphicsOutput->Blt ( GraphicsOutput, &ProgressColor, EfiBltVideoFill, 0, 0, PosX, PosY, BlockWidth - 1, BlockHeight, (BlockWidth) * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) ); } else if (FeaturePcdGet (PcdUgaConsumeSupport)) { Status = UgaDraw->Blt ( UgaDraw, (EFI_UGA_PIXEL *) &ProgressColor, EfiUgaVideoFill, 0, 0, PosX, PosY, BlockWidth - 1, BlockHeight, (BlockWidth) * sizeof (EFI_UGA_PIXEL) ); } else { return EFI_UNSUPPORTED; } } PrintXY ( (SizeOfX - StrLen (Title) * EFI_GLYPH_WIDTH) / 2, PosY - EFI_GLYPH_HEIGHT - 1, &TitleForeground, &TitleBackground, Title ); return EFI_SUCCESS; }
/////////////////////////////////////////////////////////////// // File List /////////////////////////////////////////////////////////////// int SelectFiles3 (char * file_name) // -1 no file , 1 complate ,0 cancel { int key; char str[50]; //字符数组长度下标从0开始,共50个元素 FONTCHARACTER find_path[50]; //获得路径 FONTCHARACTER find_name[50]; //获得名字 int find_h; int size = 0; int top = 0; int buttom = 0; int index,r,y; char *files; FILE_INFO file_info; // CharToFont("\\\\fls0\\ZDM\\*.zdm",find_path); sprintf(str,"%s\\*.zdm",szSrdDir3); CharToFonts3(str,find_path); if(Bfile_FindFirst (find_path,&find_h,find_name,&file_info)==0) //函数搜索目录中文件的名称符合指定的文件名 { int i=0,ret; BOOL bFindFirst=TRUE; //定义一个布尔型变量初始化为真(true),对于bool类型,值只要不是0就是为真,即true;当值为0时为假,即false; size ++; //使用size之后再加一(先计算再操作) while(Bfile_FindNext(find_h,find_name,&file_info)==0) //Bfile_FindNext 函数使用搜索处理定位匹配一个给定名称的文件名称。 size++; Bfile_FindClose(find_h); //Bfile_FindClose 关闭搜索指定处理函数 files = (char*)malloc(size*13); index = 0; for(;;) { if(bFindFirst) //if 值为真 ret=Bfile_FindFirst (find_path,&find_h,find_name,&file_info); else ret=Bfile_FindNext(find_h,find_name,&file_info); if(ret!=0) //if break; strncpy((files+13*i),FontToChars3(find_name,str),13); if(strcmp((files+13*i),setup_data.zdmroute_name)==0) //文件选中后,现在记忆位置 index=i; i++; bFindFirst=FALSE; //令值为假 即=0 } Bfile_FindClose(find_h); //Bfile_FindClose 关闭搜索指定处理函数 r = 1; top = 0; buttom = 4; while(1) { if (r) { Bdisp_AllClr_VRAM(); //PopUpWin(6); DispStr(20,8,"纵断面文件: "); if (buttom-top>3)buttom = top + 3; if(top>index) { top = index; buttom = index + 3; } if (index>buttom) { buttom = index; top = buttom - 3; } if(buttom>size - 1)buttom = size - 1; if(top<0) top = 0; for (i=top;i<=buttom;++i) { //sprintf(str,"%13.13s",(files+13*i)); //y=2+(i-top)*13; //顶部文件位置 //SetMyFont(&stHz12x12,&stAsc6x12); //DispStr(18,y,str); //str[]是字符串 //if(index==i) //Bdisp_AreaReverseVRAM(15,y,20+13*6,y+11); PrintfXY(20,22+(i-top)*8,index==i,"%13.13s",(files+13*i)); } PrintXY(100,22,top>0?"\xE6\x92":" ",0); PrintXY(100,46,buttom<size-1?"\xE6\x93":" ",0); r = 0; } GetKey(&key); if (key==KEY_CTRL_UP) {if(--index<0) index = size - 1;r = 1;} if (key==KEY_CTRL_DOWN) {if(++index>size - 1) index = 0;r = 1;} if (key==KEY_CTRL_EXE) { strcpy(file_name,(files+13*index)); free (files); return 1; } if (key==KEY_CTRL_EXIT) { free (files); return 0; } } } else return -1; }