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 erase_backward(uint8_t count) { cclear(1); /* Erase cursor */ gotox(wherex() - (count + 1)); cclear(count); gotox(wherex() - count); }
char interactively_read_char() { unsigned char x; char c; x = wherex(); revers(true); cputc(' '); gotox(x); c = cgetc(); revers(false); cputc(' '); gotox(x); return c; }
void plantilla::mover(char _char){ gotox(x,y);cout<<" "; x--; if(x<2){ y=rand()%30+4; x=99; } imp(_char); }
static void draw_field(U8 field_it) { const Field* field = &fields[field_it]; U8 col_x = (field->column == CRight) ? XPOS + COL2X : XPOS; textcolor(field->enabled ? COLOR_WHITE : COLOR_GRAY1); print_value(field); gotox(col_x); cputs(field->desc); }
void extralife::colision(navep &naveaux){ if(y>=naveaux.y and y<=naveaux.y+4 and x>=naveaux.x and x<=naveaux.x+11){ naveaux.corazon++; naveaux.impnav(); naveaux.corazones(); enpantalla=false; gotox(x,y);cout<<" "; y=rand()%30+4; x=99; } }
/** * Return the string entered. The maximal length of the string is * FILENAME_MAX, i.e. 16+1. */ const char* __fastcall__ screenReadInput(const char* pStrTitle, const char* pStrDefault) { uint8_t len; static char strInput[FILENAME_MAX]; char c; screenBing(); strcpy(strInput, pStrDefault); len = strlen(strInput); screenPrintBox(2, 6, 36, 12); screenPrintSepLine(2, 37, 8); cputsxy(3, 7, pStrTitle); // the input field textcolor(COLOR_LIGHTFRAME); screenPrintBox(4, 10, 32, 3); textcolor(COLOR_FOREGROUND); screenPrintButton(30, 14, "Enter"); cursor(1); do { cputsxy(5, 11, strInput); cputc(' '); gotox(5 + len); c = cgetc(); if (len < sizeof(strInput) - 1 && ((c >= 32 && c < 128) || (c >= 192 && c < 224)) ) { strInput[len++] = c; strInput[len] = '\0'; } else if (c == CH_DEL) { if (len) strInput[--len] = '\0'; } } while (c != CH_ENTER); cursor(0); refreshMainScreen(); return strInput; }
// putscreen(*screen, x1, y1, x2, y2) // copys characters stored at location *screen a pointer to a buffer of characters // to the screen area defined by corners x1, y1 and x2, y2 void putscreen(char* screen, unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2){ char wide = *screen++; unsigned char row; unsigned char lowoffset, hioffset, lowcols, hicols; if (wide==0) { // 40 column screen lowoffset=x1; lowcols = x2-x1+1; } else { // 80 column screen if (x1%2 == 0 ){ lowoffset = x1/2; hioffset = x1/2; } else { lowoffset = (x1-1)/2; hioffset = (x1+1)/2; } if (x2%2 == 0) { lowcols = (x2/2)-1 -lowoffset + 1; hicols = (x2/2) - hioffset + 1; } else{ lowcols = (x2-1)/2 - lowoffset + 1; hicols = (x2-1)/2 - hioffset + 1; } } for (row = y1; row <= y2; ++row) { gotoy(row); memcpy((*(char**)BASL)+lowoffset, screen, lowcols); screen += lowcols; if (wide) { *(char*)HISCR = 0; memcpy((*(char**)BASL)+hioffset, screen, hicols); screen += hicols; *(char*)LOWSCR = 0; } } gotoy(*screen++); gotox(*screen); } // end of putscreen
/** * Draw an empty box. * * The size is incl. border */ void screenPrintBorder(uint8_t x, uint8_t y, uint8_t w, uint8_t h) { uint8_t i, x_end; --w; x_end = x + w; // Top line screenPrintTopLine(x, x_end, y); for (i = h - 2; i; --i) { ++y; cputcxy(x, y, 0x7d); gotox(x_end); cputc(0x7d); } // Bottom line screenPrintBottomLine(x, x_end, ++y); }
void plantilla::imp(char _char){ gotox(x,y);cout<<_char; }
/** * Show or refresh the Screen which reports the Flash IDs. */ void refreshMainScreen(void) { const char* str; screenPrintFrame(); // menu entries gotoxy (1, 1); textcolor(COLOR_EXTRA); cputc('M'); textcolor(COLOR_FOREGROUND); cputs("enu "); textcolor(COLOR_EXTRA); cputc('O'); textcolor(COLOR_FOREGROUND); cputs("ptions "); textcolor(COLOR_EXTRA); cputc('E'); textcolor(COLOR_FOREGROUND); cputs("xpert "); textcolor(COLOR_EXTRA); cputc('H'); textcolor(COLOR_FOREGROUND); cputs("elp"); textcolor(COLOR_LIGHTFRAME); screenPrintBox(16, 4, 23, 11); screenPrintSepLine(16, 38, 6); screenPrintSepLine(16, 38, 8); screenPrintSepLine(16, 38, 10); screenPrintSepLine(16, 38, 12); textcolor(COLOR_FOREGROUND); gotoxy(6, 5); cputs("File name:"); gotox(17); cputs(g_strFileName); gotoxy(7, 7); cputs("CRT Type:"); gotox(17); cputs(aStrInternalCartTypeName[internalCartType]); gotoxy(3, 9); cputs("Flash Driver:"); gotox(17); cputs(pStrFlashDriver); gotoxy(10, 11); cputs("Slots:"); gotox(17); cputs(strMemSize); gotoxy(3, 13); cputs("Time elapsed:"); refreshElapsedTime(); progressShow(); refreshStatusLine(); }
int Barcode_pcl_print(struct Barcode_Item *bc, FILE *f) { int i, j, barlen; double f1, f2, fsav=0; int mode = '-'; /* text below bars */ double scalef=1, xpos, xabs, yabs, yr; double textyoffset; char *ptr; char c; char font_id[6]; /* default font, should be "scalable" */ /* 0 Line printer, use on older LJet II, isn't scalable */ /* 4148 Univers, use on LJet III series, and Lj 4L, 5L */ /* 16602 Arial, default LJ family 4, 5, 6, Color, Djet */ if (!bc->partial || !bc->textinfo) { bc->error = EINVAL; return -1; } /* * Maybe this first part can be made common to several printing back-ends, * we'll see how that works when other ouput engines are added */ /* First, calculate barlen */ barlen = bc->partial[0] - '0'; for (ptr = bc->partial+1; *ptr; ptr++) if (isdigit(*ptr)) barlen += (*ptr - '0'); else if (islower(*ptr)) barlen += (*ptr - 'a'+1); /* The scale factor depends on bar length */ if (!bc->scalef) { if (!bc->width) bc->width = barlen; /* default */ scalef = bc->scalef = (double)bc->width / (double)barlen; } /* The width defaults to "just enough" */ if (!bc->width) bc->width = barlen * scalef +1; /* But it can be too small, in this case enlarge and center the area */ if (bc->width < barlen * scalef) { int wid = barlen * scalef + 1; bc->xoff -= (wid - bc->width)/2 ; bc->width = wid; /* Can't extend too far on the left */ if (bc->xoff < 0) { bc->width += -bc->xoff; bc->xoff = 0; } } /* The height defaults to 80 points (rescaled) */ if (!bc->height) bc->height = 80 * scalef; #if 0 /* If too small (5 + text), enlarge and center */ i = 5 + 10 * ((bc->flags & BARCODE_NO_ASCII)==0); if (bc->height < i * scalef ) { int hei = i * scalef; bc->yoff -= (hei-bc->height)/2; bc->height = hei; if (bc->yoff < 0) { bc->height += -bc->yoff; bc->yoff = 0; } } #else /* If too small (5 + text), reduce the scale factor and center */ i = 5 + 10 * ((bc->flags & BARCODE_NO_ASCII)==0); if (bc->height < i * scalef ) { double scaleg = ((double)bc->height) / i; int wid = bc->width * scaleg / scalef; bc->xoff += (bc->width - wid)/2; bc->width = wid; scalef = scaleg; } #endif /* * deal with PCL output */ textyoffset = (mode != '-' ? ((double)8*scalef) : ((double)bc->height)); xabs = - bc->xoff; yabs = - bc->yoff; if (!streaming) { fprintf(f, "%c&a0H", 27); fprintf(f, "%c&a0V", 27); } xpos = bc->margin + (bc->partial[0]-'0') * scalef; for (ptr = bc->partial+1, i=1; *ptr; ptr++, i++) { double x0, y0; /* special cases: '+' and '-' */ if (*ptr == '+' || *ptr == '-') { mode = *ptr; /* don't count it */ i++; continue; } /* j is the width of this bar/space */ if (isdigit (*ptr)) j = *ptr-'0'; else j = *ptr-'a'+1; if (i%2) { /* bar */ x0 = xpos + SHRINK_AMOUNT/2.0; y0 = 0; yr = bc->height; if (!(bc->flags & BARCODE_NO_ASCII)) { /* leave space for text */ if (mode == '-') { /* text below bars: 10 points or five points */ yr -= (isdigit(*ptr) ? 10 : 5) * scalef; } else { /* '+' */ /* text above bars: 10 or 0 from bottom, and 10 from top */ y0 += (isdigit(*ptr) ? 10 : 0) * scalef; yr -= (isdigit(*ptr) ? 20 : 10) * scalef; } } gotox(f,&xabs,x0); if (streaming) gotoy(f, &yabs, y0 - textyoffset); else gotoy(f, &yabs, y0); fprintf(f,"%c*c%.1fH", 27, ((j*scalef)-SHRINK_AMOUNT) * 10.0); fprintf(f,"%c*c%.1fV", 27, yr * 10.0); fprintf(f,"%c*c0P", 27); } xpos += j * scalef; } /* the text */ if (streaming) gotoy(f, &yabs, 0); else gotoy(f, &yabs, textyoffset); mode = '-'; /* reinstantiate default */ if (!(bc->flags & BARCODE_NO_ASCII)) { for (ptr = bc->textinfo; ptr; ptr = strchr(ptr, ' ')) { while (*ptr == ' ') ptr++; if (!*ptr) break; if (*ptr == '+' || *ptr == '-') { mode = *ptr; continue; } if (sscanf(ptr, "%lf:%lf:%c", &f1, &f2, &c) != 3) { fprintf(stderr, _("barcode: impossible data: %s\n"), ptr); continue; } /* select a Scalable Font */ if (fsav != f2 && !streaming) { if ((bc->flags & BARCODE_OUT_PCL_III) == BARCODE_OUT_PCL_III) strcpy(font_id, "4148"); /* font Univers */ else strcpy(font_id, "16602"); /* font Arial */ fprintf(f,"%c(8U", 27); fprintf(f,"%c(s1p%5.2fv0s0b%sT", 27, f2 * scalef, font_id); } fsav = f2; gotox(f, &xabs, f1 * scalef + bc->margin); /* print the char, reverse print direction by 180, print it again but invisibly, restore print direction, transparency, opacity. After that we are at the original position again, so we know exactly where we are without having to account for the character width */ fprintf(f, "%c%c&a180P%c*vo1T%c%c&a0P%c*v1oT", c, 27, 27, c, 27, 27); } } if (streaming) { gotox(f, &xabs, xpos + bc->margin); gotoy(f, &yabs, - bc->yoff); } return 0; }
static void replaceCursor(char ch) { gotox(wherex() - 1); cputc(ch); }