/*************************СОРТИРОВКА ПА АЛФАВИТУ*************************/ void alf(void) { FILE *f,*f1; char filename[14],nameoffile[14]; char c; int i,n=0,j,k,fl; instr smass[100],old; window(1,1,80,25); textbackground(0); textcolor(3); clrscr(); cputs("Введите имя файла-источника данных..."); scanf("%s",filename); cputs("Введите имя файла,в который будут записаны данные..."); scanf("%s",nameoffile); f=fopen(filename,"r"); f1=fopen(nameoffile,"aw"); fseek(f,0,SEEK_SET); while(!feof(f)) { fread(&smass[n],sizeof(old),1,f); n++; } n--; for (i=n-1;i>0;i--) { for (j=0;j<i;j++) { fl=TRUE; k=0; while ((k<10)AND(fl==TRUE)) { if (smass[j].name[k]>smass[j+1].name[k]) { old=smass[j]; smass[j]=smass[j+1]; smass[j+1]=old; fl=FALSE; } if (smass[j].name[k]<smass[j+1].name[k]) fl=FALSE; k++; } } } printf("Мнемокод Длина Машинный код\n"); for (i=0;i<n;i++) { fwrite (&smass[i],sizeof(old),1,f1); printf("%s",&smass[i].name); gotoxy(15,wherey()); printf("%s",&smass[i].size); gotoxy(18,wherey()); printf("%s\n",&smass[i].hex); } fcloseall(); cputs("Обработка завершена..."); getch(); }
int main() { clrscr(); bordercolor(0); bgcolor(6); renderMenu(100); textcolor(7); gotoxy(0, 1); updateStatus(' '); cursor(1); while(1) { char c; /* uint8_t row; uint8_t col; for (row = 0; row < 16; row++) { gotoxy(0, row + 3); cprintf("%3d ", row * 16); for (col = 0; col < 16; col++) { cputc(row * 16 + col); cputc(' '); } } */ c = cgetc(); if (c == 20) { // backspace } else if (c == 13) { // Return } else if (c == 157) { // Left uint8_t xpos = wherex() - 1; gotox(xpos); } else if (c == 29) { // Right uint8_t xpos = wherex() + 1; gotox(xpos); } else if (c == 17) { // Down uint8_t ypos = wherey() + 1; gotoy(ypos); } else if (c == 145) { // Up uint8_t ypos = wherey() - 1; gotoy(ypos); } else if (c == 19) { // Pos1 } else if (c == 3) { // ESC -> Menu processMenu(); } else { cputc(c); } updateStatus(c); } }
/**********************СОРТИРОВКА ПО ДЛИНЕ***************************/ void length(void) { FILE *f,*f1; char filename[14],nameoffile[14]; char c; int i,n=0,k; instr com; window(1,1,80,25); textbackground(0); textcolor(2); clrscr(); cputs("Введите имя файла-источника данных..."); scanf("%s",filename); cputs("Введите имя файла,в который будут записаны данные..."); scanf("%s",nameoffile); f=fopen(filename,"r"); f1=fopen(nameoffile,"aw"); fseek(f,0,SEEK_SET); while(!feof(f)) { fread(&com,sizeof(com),1,f); n++; } printf("Мнемокод Длина Машинный код\n"); n--; for(k=49;k<=57;k++) { fseek(f,0,SEEK_SET); for(i=0;i<n;i++) { c=toascii(k); fread(&com.name,sizeof(com.name),1,f); fread(&com.size,sizeof(com.size),1,f); fread(&com.hex,sizeof(com.hex),1,f); if(com.size[0]==c) { fwrite(&com,sizeof(com),1,f1); printf("%s",&com.name); gotoxy(15,wherey()); printf("%s",&com.size); gotoxy(18,wherey()); printf("%s\n",com.hex); } } } fcloseall(); cputs("Обработка завершена..."); getch(); }
void insline() { int y=wherey() ; HANDLE hScreen = GetStdHandle(STD_OUTPUT_HANDLE) ; CONSOLE_SCREEN_BUFFER_INFO Info ; GetConsoleScreenBufferInfo(hScreen, &Info) ; { COORD dwBufferSize={Info.dwSize.X, Info.dwSize.Y - y} ; COORD dwBufferCoord={0,0} ; COORD coord={0, y-1} ; // pour FillConsoleOutputCharacter CHAR_INFO Buffer[dwBufferSize.Y][dwBufferSize.X] ; DWORD dwWritten; SMALL_RECT ReadRegion[2] ; ReadRegion[0].Left = 0 ; ReadRegion[0].Right = Info.dwSize.X-1 ; ReadRegion[0].Top = y-1 ; ReadRegion[0].Bottom = Info.dwSize.Y-2 ; ReadConsoleOutput(hScreen, (CHAR_INFO*)Buffer, dwBufferSize, dwBufferCoord, ReadRegion) ; ReadRegion[0].Top = y ; ReadRegion[0].Bottom = Info.dwSize.Y-1 ; WriteConsoleOutput(hScreen, (CHAR_INFO*)Buffer, dwBufferSize, dwBufferCoord, ReadRegion) ; FillConsoleOutputCharacter (hScreen, ' ', Info.dwSize.X, coord, &dwWritten); // Effacer ligne FillConsoleOutputAttribute (hScreen, Info.wAttributes, Info.dwSize.X, coord, &dwWritten); } }
Boolean aceptar_cancelar(){ int i = 0, lasti = 0, key, fila = wherey(), x = wherex(); char *buttons[] = {" Aceptar ", " Cancelar "}; gotoxy(x + 1, fila); cputs(" Aceptar Cancelar "); gotoxy(x + calculate_xpos(buttons, i), fila); marcar_texto(buttons[i], strlen(buttons[i])); msg_snd(); do{ key = bioskey(0); if((key & SC_IZQ) == SC_IZQ){ i--; if((i>=0)&&(i<=1))JVGtecla(); } if((key & SC_DER) == SC_DER){ i++; if((i>=0)&&(i<=1))JVGtecla(); } if(i >= 2) i = 1; if(i < 0) i = 0; gotoxy(x + calculate_xpos(buttons, lasti), fila); desmarcar_texto(buttons[lasti], strlen(buttons[lasti])); gotoxy(x + calculate_xpos(buttons, i), fila); marcar_texto(buttons[i], strlen(buttons[i])); lasti = i; }while(((key & SC_ENTER)!= SC_ENTER) && ((key & SC_ABAJO) != SC_ABAJO)); gotoxy(x + calculate_xpos(buttons, i), fila); desmarcar_texto(buttons[i], strlen(buttons[i])); _setcursortype(_NORMALCURSOR); if(i == 0) return Verdadero; return Falso; }
/* * get_input_terminated_by() reads input (handling backspace correctly) until * a terminator of |terminators| is encountered or |out| is full (outlen-1 * characters were read). * * get_input_terminated_by() returns the terminator it encountered. * */ input_terminator_t get_input_terminated_by(input_terminator_mask_t terminators, char *out, BYTE outlen) { BYTE i = strlen(out); BYTE c, x, y; x = wherex() - i; y = wherey(); while (1) { c = cgetc(); if (((terminators & INPUT_TERMINATOR_RETURN) == INPUT_TERMINATOR_RETURN) && (c == PETSCII_CR)) { return INPUT_TERMINATOR_RETURN; } else if (((terminators & INPUT_TERMINATOR_SPACE) == INPUT_TERMINATOR_SPACE) && (c == PETSCII_SP)) { return INPUT_TERMINATOR_SPACE; } else if (c == PETSCII_DEL) { /* If you are at the left-most position, do nothing */ if (i == 0) continue; out[--i] = '\0'; cputcxy(x+i, y, ' '); gotoxy(x+i, y); continue; } if (i == (outlen-1)) { continue; } cputc(c); out[i++] = c; } }
void Zolw::rysowanie(){ int x = wherex(); int y = wherey(); gotoxy(this->x, this->y); cputs("Z"); gotoxy(x, y); }
void Mlecz::rysowanie(){ int x = wherex(); int y = wherey(); gotoxy(this->x, this->y); cputs("M"); gotoxy(x, y); }
void view() { int wy; while (!feof(file1)||feof(file1)) { for (i=0; i<24; i++) { fgets(line,k,file1); if (feof(file1)) ende(); len=strlen(line); if (z==1) { printf ("%d %s",zeile,line); if (len>=77) { wy=wherey(); gotoxy(1,wy-1); } } else printf("%s",line); zeile++; } bild=1; printf("Taste..."); c=getch(); clrscr(); } ende(); }
void Guarana::rysowanie(){ int x = wherex(); int y = wherey(); gotoxy(this->x, this->y); cputs("G"); gotoxy(x, y); }
void screen_draw_border(char *help_msg) { int px, py; int i, msg_len; trim(help_msg); px = wherex(); py = wherey(); gotoxy(0, 0); for (i = 0;i <= WIN_WIDTH;i++) cprintf("%c", BORDER_HOR); for (i = 1;i < WIN_HEIGHT;i++) { gotoxy(0, i); cprintf("%c", BORDER_VER); gotoxy(WIN_WIDTH, i); cprintf("%c", BORDER_VER); } gotoxy(0, WIN_HEIGHT); for (msg_len = strlen(help_msg), i = 0;i < (WIN_WIDTH - msg_len) / 2;i++) cprintf("%c", BORDER_HOR); cprintf("%s", help_msg); for (i += msg_len;i <= WIN_WIDTH;i++) cprintf("%c", BORDER_HOR); gotoxy(px, py); }
/***************************ОБРАБОТКА ФАЙЛА****************************/ void kb(void) { instr com; char filename[14],nameoffile[14]; FILE *f,*f1; char size[2]; int i,n=0; window(1,1,80,25); textbackground(0); textcolor(3); clrscr(); cputs("Введите имя файла, который будете обрабатывать..."); scanf("%s",filename); cputs("Введите имя файла, в который будет записан результат..."); scanf("%s",nameoffile); f=fopen(filename,"r"); f1=fopen(nameoffile,"aw"); cputs("Введите длину команды..."); scanf("%s",size); fseek(f,0,SEEK_SET); while(!feof(f)) { fread(&com,sizeof(com),1,f); n++; } n--; fseek(f,0,SEEK_SET); printf("Мнемокод Длина Машинный код\n"); for(i=0;i<n;i++) { fread(&com.name,sizeof(com.name),1,f); fread(&com.size,sizeof(com.size),1,f); fread(&com.hex,sizeof(com.hex),1,f); if(com.size[0]==size[0]) { fwrite(&com,sizeof(com),1,f1); printf("%s",&com.name); gotoxy(15,wherey()); printf("%s",&com.size); gotoxy(18,wherey()); printf("%s\n",&com.hex); } } fcloseall(); getch(); }
unsigned int _8254CounterIEN(unsigned Base, unsigned irq, unsigned F96,int df) { unsigned int CBase; int t; ADDRESS = Base; CBase = Base + 0x10; if(F96==1){ flag2 = 1; //for setcountflag isr CtrMode(CBase,0,2); CtrLoad(CBase,0,0x10); } do{ CtrMode(CBase,1,2); CtrLoad(CBase,1,0x10); CtrMode(CBase,2,2); CtrLoad(CBase,2,0x10); initirq(irq,setcountflag); outportb(Base+0x0E,0x02);//enable COUNTER IRQ on PCIe-DIO-24DCS if(F96==1){ outportb(Base+0x1E, 0x00); //enable interrupt for dio-96CT outportb(Base+0x1F, 0x00); //clear interrupt latch for dio-96CT } outportb(Base+0xF, 0x00); // clear interrupt latch for dio-24 isrflag = 0; outportb(0x20, 0x20); outportb(0xA0, 0x20); delay(1000); outportb(Base+0xD, 0x00); // turn off interrupt for dio-24 outportb(Base+0x0f, 0); // clear left over IRQs if(F96==1) outportb(Base+0x1E, 0x00); //disable interrupt for dio-96CT outportb(0x20, 0x20); outportb(0xA0, 0x20); restoreirq(irq); t = isrflag; textcolor(t?GREEN:RED); cprintf("%s",t?"IRQ ":"NoIRQ "); if((80 - wherex()) < 10) gotoxy(1,wherey()); t = 0; }while((!kbhit()) && (df)); //exit after running once if !Debug mode if (df) { getch(); printf("\n"); } if(F96==1){ CtrMode(CBase,0,2); //stop counters counting CtrMode(CBase,1,2); CtrMode(CBase,2,2); outportb(Base+0x1E,0x00); //disable interrupt for dio-96CT } if (isrflag) return 0; else return 1; }
void gettextinfo(struct text_info *info) { info->curx = wherex(); info->cury = wherey(); info->attribute = thData.attrib; info->normattr = 0x07; info->screenwidth = thData.width; info->screenheight = thData.height; };
int _8254Test(unsigned Base,int df) { unsigned cntr1 = 0; unsigned cntr2 = 0; unsigned cntr1Read = 0; unsigned cntr2Read = 0; int x,y; x=wherex()+10; y=wherey()+2; outportb(Base+0xE,0x00); //disable interrupt for dio-96CT CtrMode(Base,0,2); CtrLoad(Base,0,0x10); CtrMode(Base,1,2); CtrLoad(Base,1,0x100); CtrMode(Base,2,2); CtrLoad(Base,2,0xFFFF); delay(1); cntr1 = CtrRead(Base,1); cntr2 = CtrRead(Base,2); delay(200); cntr1Read = CtrRead(Base,1); cntr2Read = CtrRead(Base,2); if(df){ textcolor(LIGHTGRAY); gotoxy(x,wherey()); cprintf("Counter 1 Value Counter 2 Value\n"); do{ cntr1Read = CtrRead(Base,1); delay(200); cntr2Read = CtrRead(Base,2); gotoxy(10,wherey()); textcolor((cntr1!=cntr1Read)?GREEN:RED);//base color on initial results cprintf(" %4x %4x ",cntr1Read,cntr2Read); // gotoxy(x,y-1); }while(!kbhit()); printf("\n"); getch(); } outportb(Base+0xE,0x00); //disable interrupt for dio-96CT if((cntr1!=cntr1Read)&&(cntr2!=cntr2Read)) return 0; else return 1; }
void DisplayOutput (char* File, char* Rights, char* Trustee, int Errcode, FILE* Logfile) { if (stricmp (Trustee, "/f") == 0) printf ("%s\t%s\t%s", File, Rights, Trustee); else printf ("%s\t%s\t/NAME=%s", File, Rights, Trustee); if (Logfile) fprintf (Logfile, "%s %s %s", File, Rights, Trustee); switch (Errcode) { case SUCCESS: printf ("\n"); if (Logfile) fprintf (Logfile, "\n"); break; case ERR_FILE_INFO: printf (" - Error getting file information\n"); if (Logfile) fprintf (Logfile, " - Error getting file information\n"); break; case ERR_TRUSTEE_TO_NDS_OBJ: printf (" - Error mapping trustee to NDS object\n"); if (Logfile) fprintf (Logfile, " - Error mapping trustee to NDS object\n"); break; case ERR_NDS_OBJ_TO_TRUSTEE: printf (" - Error mapping NDS object to trustee\n"); if (Logfile) fprintf (Logfile, " - Error mapping NDS object to trustee\n"); break; case ERR_CANT_ASSIGN_RIGHTS: printf (" - Error assigning rights\n"); if (Logfile) fprintf (Logfile, " - Error assigning rights\n"); break; case ERR_CANT_SET_FILTER: printf (" - Error setting filter\n"); if (Logfile) fprintf (Logfile, " - Error setting filter\n"); break; } if (Pause != 0 && wherey () >= 22) { AwaitingInput = TRUE; PressAnyKeyToContinue (); AwaitingInput = FALSE; clrscr (); } }
/*---------------------------------------------------------------------* Name gettextinfo - give the user information on video mode, window coordinates and video attributes Usage #include <conio.h> void gettextinfo(struct text_info *r); Prototype in conio.h Description fills the text_info structure with the current video information. Return value None NOTE: text_info structure is partial prefix of _video structure *---------------------------------------------------------------------*/ void gettextinfo(struct text_info *r) { *r = *(struct text_info *)& _video; /* move data all at once */ r->winleft += 1; /* 1,1 origin */ r->wintop += 1; r->winright += 1; r->winbottom += 1; r->curx = wherex(); r->cury = wherey(); }
int main(void) { init(); /* start_sound(sound[0], 0, ON);*/ /* Start up the jet engine */ printf("Press:\n"); printf(" 1) Machine Gun\n"); printf(" 2) Crash\n"); printf(" 3) Cannon\n"); printf(" 4) Laser\n"); printf(" 5) Breaking glass\n"); printf(" Q) Quit\n"); stop = FALSE; counter = 0; do { /* Increment and display counters */ counter++; cprintf("%8lu %8lu %4u", counter, intcount, voicecount); gotoxy(1, wherey()); /* Maybe start a random sound */ if (!random(10000)) { num = (random(NUMSOUNDS-1))+1; start_sound(sound[num], num, OFF); } /* Start a sound if a key is pressed */ if (kbhit()) { inkey = getch(); if ((inkey >= '0') && (inkey <= '9')) { num = inkey - '0'; /* Convert to integer */ if (num < NUMSOUNDS) start_sound(sound[num], num, FALSE); } else stop = TRUE; } } while (!stop); printf("\n"); stop_sound(1); /* Stop the jet engine */ shutdown(); return(EXIT_SUCCESS); }
int LireNbreFilmValide(void) { int NbrFilms; cout << "Nombre de film lou\x82s (1 \x85 3) : "; int CurrX = wherex(); int CurrY = wherey(); do { gotoxy(CurrX,CurrY); NbrFilms = ConvertireUnCharEnInt(_getche()); } while(NbrFilms > 3 || NbrFilms < 1); return NbrFilms; }
void save_curs(POINT * p){ ///\fn void save_curs(POINT * p) ///\brief Salvarea pozitiei cursorului. ///\param p Variabila tip POINT care stocheaza pozitia cursorului /// ///Implementarea salvarii pozitiei cursorului. p->x = wherex(); p->y = wherey(); }
int chatchar(WINDOW *win, int ch) { window(win->left,win->top,win->right,win->bottom); gotoxy(win->x,win->y); textcolor(win->colour); putch(ch); if(ch=='\r') putch('\n'); win->x=wherex(); win->y=wherey(); return(0); }
void Screen::myCprintf( uint8_t attr, char *fmt, ... ) { int x = wherex( ); int y = wherey( ); va_list ap; va_start( ap, fmt ); myCprintf_internal( x, y, attr, fmt, ap ); va_end( ap ); }
void GetCurs(int *x, int *y) { #ifdef UNIX getsyx(*y, *x); #else /* X and Y are zero-based */ *x = wherex() - 1; *y = wherey() - 1; #endif }
void Text(char text[50], int make_center,int style, float speed, int goto_next_line) { //Style 1 Decl int i; //Style 2 Decl int posl,posr,printl,printr; speed=speed*1000; //convert to milliseconds if(make_center==1) gotoxy(40-(strlen(text)/2),wherey()); if(style==2) { posl=40-strlen(text)/2; posr=40+strlen(text)/2; printl=0; printr=strlen(text)-1; for(;posl<=40;++posl,--posr,++printl,--printr) { delay(speed); gotoxy(posl,wherey()); cout<<text[printl]; gotoxy(posr,wherey()); cout<<text[printr]; } } else //style=1 { for(i=0;text[i]!='\0';++i) { if(text[i]!=' ') delay(speed); cout<<text[i]; } } if(goto_next_line==1) cout<<"\n"; }
void clreol (void) { int X, Y; char Spaces[100]; memset (Spaces, ' ', sizeof (Spaces)); X = wherex (); Y = wherey (); Spaces[80-X] = 0; printf ("%s", Spaces); gotoxy (X, Y); }
/* Output a vertical line with the given length at the current cursor * position. */ void __fastcall__ cvline( unsigned char length ) { // FIXME: Optimize me. unsigned char x = wherex(); unsigned char y = wherey(); unsigned char i; for( i=0; i<length; i++ ) { gotoxy( x, y+i ); cputc( 1 ); } }
void GetPass (char *Pass, int Len) { int index = 0; WORD x,y; // Get the y co-ordinate y = wherey (); do { // get the current x co-ordinate x = wherex (); // get the next character from the input buffer Pass [index] = (char) getch (); // if its an enter, terminate the string if (Pass [index] == 0x0D) Pass [index] = '\0'; // if its a delete move the cursor back, and remove the last character from the string else if (Pass [index] == 0x08) { if (index-1 >= 0) { index -= 2; // blank out the last * gotoxy ((WORD) (x-1), y); putch (' '); gotoxy ((WORD) (x-1), y); } else { index = -1; } } else // display a * for the character putch ('*'); // move to the next character in the array index++; } while (Pass [index-1] && index < Len); // apply a newline character if needed if (Pass [index-1]) Pass [index-1] = NULL; putch ('\n'); }
void main (void) { int linha, coluna; clrscr (); cprintf ("Esta e a linha 1\r\n"); cprintf ("A linha 2 e um pouco mais longa\r\n"); cprintf ("Esta e a ultima linha"); linha = wherey(); coluna = wherex (); cprintf ("\r\nA posicao do cursor era linha %d coluna %d\n", linha, coluna); }
void updateStatus(uint8_t c) { uint8_t xpos = wherex(); uint8_t ypos = wherey(); gotoxy(0, 24); textcolor(1); revers(1); cprintf("Ln: %-2d Col: %-2d %3d INS ", ypos, xpos, c); textcolor(7); revers(0); gotoxy(xpos, ypos); }
/* move cursor forth one char with ** recognition of row change */ void chForth(void){ signed char x, y; x = wherex(); y = wherey(); x+=1; if (x >= 40) { x=0; y+=1; } gotoxy(x,y); }