/* * drawtetra * * generate a tetraedron as a series of move draws */ drawtetra() { move(-0.5, 0.866, -0.5); draw(-0.5, -0.866, -0.5); draw( 1.0, 0.0, -0.5); draw(-0.5, 0.866, -0.5); draw( 0.0, 0.0, 1.5); draw(-0.5, -0.866, -0.5); move( 1.0, 0.0, -0.5); draw( 0.0, 0.0, 1.5); /* * Label the vertices. */ color(WHITE); textsize(0.3, 0.5); /* set the text size */ move(-0.5, 0.866, -0.5); drawchar('a'); move(-0.5, -0.866, -0.5); drawchar('b'); move( 1.0, 0.0, -0.5); drawchar('c'); move( 0.0, 0.0, 1.5); drawchar('d'); }
size_t PCD8544::write(uint8_t c) { #else void PCD8544::write(uint8_t c) { #endif if (c == '\n') { cursor_y += textsize*8; cursor_x = 0; } else if (c == '\r') { // skip em } else { drawchar(cursor_x, cursor_y, c); cursor_x += textsize*6; if (cursor_x >= (LCDWIDTH-5)) { cursor_x = 0; cursor_y+=8; } if (cursor_y >= LCDHEIGHT) cursor_y = 0; } } void PCD8544::setCursor(uint8_t x, uint8_t y){ cursor_x = x; cursor_y = y; }
static int Font_InternalWrite ( int x, int y, const char *text, int count ) { int n; int len = 0; int a; for ( n = 0; n < count; ) { int charId = Font_GetTextChar ( text, n, &n ); SCharDescr *ch = Font_GetChar ( charId ); if ( ch == 0 ) { //debugprintf ( "Unknown Character %d\r\n", charId ); a = 0; } else { if ( cur_pFont->bAutoKerning ) a = ( ch->xAdv ); else a = cur_pFont->fontsize; //rendering drawchar ( x, y, ch ); } x += a + cur_pFont->kerning; len += a + cur_pFont->kerning; } return len; }
//******************************************************************************* void MatrixDisplay(int topOffset, int iterations) { //int ii,jj; int cc; int xx, yy; char myChar; char myString[4]; fill(0); cc = 0; while (cc < iterations) { //* this gives 1 pixel between columns xx = random(kSCREEN_X_size / 12) * 13; yy = topOffset; while (yy < kSCREEN_Y_size) { stroke(0, 50 + random(200), 0); myChar = random(33, 72); drawchar(xx, yy, myChar); // myString[0] = myChar; // myString[1] = 0; // drawstring(xx, yy, myString); yy += 10; } cc++; } }
void drawstring(char * s, int x, int y) { while (*s) { x += drawchar(*s, x, y); if (*s == 32) x += 3; s++; } }
void swputc(char c) { if (isprint(c)) { drawchar(cur_x * 8, cur_y * 8, c); } ++cur_x; if (c == '\n') { cur_x = 0; ++cur_y; } }
void drawstring(uint8_t *buff, uint8_t x, uint8_t line, char *c) { while (c[0] != 0) { drawchar(buff, x, line, c[0]); c++; x += 6; // 6 pixels wide if (x + 6 >= LCDWIDTH) { x = 0; // ran out of this line line++; } if (line >= (LCDHEIGHT/8)) return; // ran out of space :( } }
void drawstring_P(unsigned char *buff, unsigned char x, unsigned char line, unsigned char *c){ while (pgm_read_byte ( c ) != 0x00) { drawchar(buff, x, line, pgm_read_byte ( c )); c++; x += 6; // 6 pixels wide if (x + 6 >= LCDWIDTH) { x = 0; // ran out of this line line++; } if (line >= (LCDHEIGHT/8)) return; // ran out of space :( } }
void drawtext(bc *bc, int x, int y, Uint32 fgcolor, Uint32 bgcolor, char *str) { unsigned char c; taint(bc); while((c=*str++)) { c-=' '; if(c>=96) c=0; drawchar(bc, x, y, fontdata[c], fgcolor, bgcolor); x+=6; } }
void ST7565::drawstring(uint8_t x, uint8_t line, char *c, uint8_t color) { while (c[0] != 0) { drawchar(x, line, c[0], color); c++; x += 6; // 6 pixels wide if (x + 6 >= LCDWIDTH) { x = 0; // ran out of this line line++; } if (line >= (LCDHEIGHT/8)) return; // ran out of space :( } }
void ST7565::drawstring_P(uint8_t x, uint8_t line, const char *str) { while (1) { char c = pgm_read_byte(str++); if (! c) return; drawchar(x, line, c); x += 6; // 6 pixels wide if (x + 6 >= LCDWIDTH) { x = 0; // ran out of this line line++; } if (line >= (LCDHEIGHT/8)) return; // ran out of space :( } }
void drawstring(unsigned char *buff, unsigned char x, unsigned char line, unsigned char *c) { while (c[0] != 0) { //uart0_putchar(c[0]); drawchar(buff, x, line, c[0]); c++; x += 6; // 6 pixels wide if (x + 6 >= LCDWIDTH) { x = 0; // ran out of this line line++; } if (line >= (LCDHEIGHT/8)) return; // ran out of space :( } }
void drawstring_p(uint8_t *buff, uint8_t x, uint8_t line, PGM_P loc) { char c; while ((c = pgm_read_byte(loc++)) != 0) { drawchar(buff, x, line, c); x += 6; // 6 pixels wide if (x + 6 >= LCDWIDTH) { x = 0; // ran out of this line line++; } if (line >= (LCDHEIGHT/8)) return; // ran out of space :( } }
void rect_drawtext(rect_t r, ALLEGRO_COLOR c, const char *s) { int i, len; int sx, fw = uistyle.fontw; int sy, fh = uistyle.fonth; if (s == NULL) return; len = strlen(s); /* make text and rect with the same center. */ /* Sbegin = Rcenter - Ssize */ sx = (r.x + r.w/2) - (fw * len)/2; sy = (r.y + r.h/2) - (fh)/2; rect_draw(r, c); glBindTexture(GL_TEXTURE_2D, al_get_opengl_texture(uistyle.font12)); for (i=0; i<len; i++) drawchar(sx+i*fw, sy, s[i]); }
void Graphics::draw_icon(int x, int y, Icon icon, unsigned char alpha, bool invert) { y--; switch(icon) { case IconOpen: if(invert) drawchar(x, y, 0x81, 0, 0, 0, alpha); else drawchar(x, y, 0x81, 255, 255, 255, alpha); break; case IconReload: if(invert) drawchar(x, y, 0x91, 0, 0, 0, alpha); else drawchar(x, y, 0x91, 255, 255, 255, alpha); break; case IconSave: if(invert) drawchar(x, y, 0x82, 0, 0, 0, alpha); else drawchar(x, y, 0x82, 255, 255, 255, alpha); break; case IconVoteUp: if(invert) drawchar(x, y+1, 0xCB, 0, 100, 0, alpha); else drawchar(x, y+1, 0xCB, 0, 187, 18, alpha); break; case IconVoteDown: if(invert) drawchar(x, y, 0xCA, 100, 10, 0, alpha); else drawchar(x, y, 0xCA, 187, 40, 0, alpha); break; case IconTag: if(invert) drawchar(x, y, 0x83, 0, 0, 0, alpha); else drawchar(x, y, 0x83, 255, 255, 255, alpha); break; case IconNew: if(invert) drawchar(x, y, 0x92, 0, 0, 0, alpha); else drawchar(x, y, 0x92, 255, 255, 255, alpha); break; case IconLogin: if(invert) drawchar(x, y+1, 0x84, 0, 0, 0, alpha); else drawchar(x, y+1, 0x84, 255, 255, 255, alpha); break; case IconSimulationSettings: if(invert) drawchar(x, y+1, 0xCF, 0, 0, 0, alpha); else drawchar(x, y+1, 0xCF, 255, 255, 255, alpha); break; case IconRenderSettings: if(invert) { drawchar(x, y+1, 0xD8, 255, 0, 0, alpha); drawchar(x, y+1, 0xD9, 0, 255, 0, alpha); drawchar(x, y+1, 0xDA, 0, 0, 255, alpha); } else { addchar(x, y+1, 0xD8, 255, 0, 0, alpha); addchar(x, y+1, 0xD9, 0, 255, 0, alpha); addchar(x, y+1, 0xDA, 0, 0, 255, alpha); } break; case IconPause: if(invert) drawchar(x, y, 0x90, 0, 0, 0, alpha); else drawchar(x, y, 0x90, 255, 255, 255, alpha); break; case IconFavourite: if(invert) drawchar(x, y, 0xCC, 100, 80, 32, alpha); else drawchar(x, y, 0xCC, 192, 160, 64, alpha); break; case IconReport: if(invert) drawchar(x, y, 0xE3, 140, 140, 0, alpha); else drawchar(x, y, 0xE3, 255, 255, 0, alpha); break; case IconUsername: if(invert) { drawchar(x, y, 0x8B, 32, 64, 128, alpha); drawchar(x, y, 0x8A, 0, 0, 0, alpha); } else { drawchar(x, y, 0x8B, 32, 64, 128, alpha); drawchar(x, y, 0x8A, 255, 255, 255, alpha); } break; case IconPassword: if(invert) { drawchar(x, y, 0x8C, 160, 144, 32, alpha); drawchar(x, y, 0x84, 0, 0, 0, alpha); } else { drawchar(x, y, 0x8C, 160, 144, 32, alpha); drawchar(x, y, 0x84, 255, 255, 255, alpha); } break; case IconClose: if(invert) drawchar(x, y, 0xAA, 20, 20, 20, alpha); else drawchar(x, y, 0xAA, 230, 230, 230, alpha); break; case IconVoteSort: if (invert) { drawchar(x, y, 0xA9, 44, 48, 32, alpha); drawchar(x, y, 0xA8, 32, 44, 32, alpha); drawchar(x, y, 0xA7, 128, 128, 128, alpha); } else { drawchar(x, y, 0xA9, 144, 48, 32, alpha); drawchar(x, y, 0xA8, 32, 144, 32, alpha); drawchar(x, y, 0xA7, 255, 255, 255, alpha); } break; case IconDateSort: if (invert) { drawchar(x, y, 0xA6, 32, 32, 32, alpha); } else { drawchar(x, y, 0xA6, 255, 255, 255, alpha); } break; case IconMyOwn: if (invert) { drawchar(x, y, 0x94, 192, 160, 64, alpha); drawchar(x, y, 0x93, 32, 32, 32, alpha); } else { drawchar(x, y, 0x94, 192, 160, 64, alpha); drawchar(x, y, 0x93, 255, 255, 255, alpha); } break; case IconSearch: drawchar(x, y, 0x8E, 30, 30, 180, alpha); drawchar(x, y, 0x8F, 255, 255, 255, alpha); break; case IconDelete: if(invert) { drawchar(x, y, 0x86, 159, 47, 31, alpha); drawchar(x, y, 0x85, 0, 0, 0, alpha); } else { drawchar(x, y, 0x86, 159, 47, 31, alpha); drawchar(x, y, 0x85, 255, 255, 255, alpha); } break; case IconAdd: if(invert) { drawchar(x, y, 0x86, 32, 144, 32, alpha); drawchar(x, y, 0x89, 0, 0, 0, alpha); } else { drawchar(x, y, 0x86, 32, 144, 32, alpha); drawchar(x, y, 0x89, 255, 255, 255, alpha); } break; case IconVelocity: drawchar(x+1, y, 0x98, 128, 160, 255, alpha); break; case IconPressure: if(invert) drawchar(x+1, y+1, 0x99, 180, 160, 16, alpha); else drawchar(x+1, y+1, 0x99, 255, 212, 32, alpha); break; case IconPersistant: if(invert) drawchar(x+1, y+1, 0x9A, 20, 20, 20, alpha); else drawchar(x+1, y+1, 0x9A, 212, 212, 212, alpha); break; case IconFire: drawchar(x+1, y+1, 0x9B, 255, 0, 0, alpha); drawchar(x+1, y+1, 0x9C, 255, 255, 64, alpha); break; case IconBlob: if(invert) drawchar(x+1, y, 0xBF, 55, 180, 55, alpha); else drawchar(x+1, y, 0xBF, 55, 255, 55, alpha); break; case IconHeat: drawchar(x+3, y, 0xBE, 255, 0, 0, alpha); if(invert) drawchar(x+3, y, 0xBD, 0, 0, 0, alpha); else drawchar(x+3, y, 0xBD, 255, 255, 255, alpha); break; case IconBlur: if(invert) drawchar(x+1, y, 0xC4, 50, 70, 180, alpha); else drawchar(x+1, y, 0xC4, 100, 150, 255, alpha); break; case IconGradient: if(invert) drawchar(x+1, y+1, 0xD3, 255, 50, 255, alpha); else drawchar(x+1, y+1, 0xD3, 205, 50, 205, alpha); break; case IconLife: if(invert) drawchar(x, y+1, 0xE0, 0, 0, 0, alpha); else drawchar(x, y+1, 0xE0, 255, 255, 255, alpha); break; case IconEffect: drawchar(x+1, y, 0xE1, 255, 255, 160, alpha); break; case IconGlow: drawchar(x+1, y, 0xDF, 200, 255, 255, alpha); break; case IconWarp: drawchar(x+1, y, 0xDE, 255, 255, 255, alpha); break; case IconBasic: if(invert) drawchar(x+1, y+1, 0xDB, 50, 50, 0, alpha); else drawchar(x+1, y+1, 0xDB, 255, 255, 200, alpha); break; case IconAltAir: if(invert) { drawchar(x+1, y+1, 0xD4, 180, 55, 55, alpha); drawchar(x+1, y+1, 0xD5, 55, 180, 55, alpha); } else { drawchar(x+1, y+1, 0xD4, 255, 55, 55, alpha); drawchar(x+1, y+1, 0xD5, 55, 255, 55, alpha); } break; default: if(invert) drawchar(x, y, 't', 0, 0, 0, alpha); else drawchar(x, y, 't', 255, 255, 255, alpha); break; } }
void dopage P1H(void) { register shalfword cmd ; register integer p ; register chardesctype *cd ; register integer h ; register fontmaptype *cfnt ; register frametype *frp = frames ; integer fnt ; #ifdef Omega integer mychar; #endif int charmove ; struct dvistack *sp = stack ; integer v, w, x, y, z ; integer roundpos ; integer thinspace ; integer vertsmallspace ; #ifdef XENIX integer iconv ; integer viconv ; iconv = (integer)(1.0 / conv + 0.5) ; viconv = (integer)(1.0 / vconv + 0.5) ; #else #ifdef __THINK__ integer iconv ; integer viconv ; iconv = (integer)(1.0 / conv + 0.5) ; viconv = (integer)(1.0 / vconv + 0.5) ; #endif #endif #ifdef EMTEX emclear() ; #endif pageinit() ; bopcolor(1) ; thinspace = (integer)(0.025*DPI/conv) ; /* 0.025 inches */ vertsmallspace = (integer)(0.025*VDPI/vconv) ; /* 0.025 inches */ #ifdef HPS if (HPS_FLAG) pagecounter++ ; H_BREAK = (30 * DPI / 400 ) ; /* 30 seems to have worked well at 400 dpi */ #endif w = x = y = z = 0 ; h = (integer) (DPI / conv * hoff / 4736286.72) ; v = (integer) (DPI / conv * voff / 4736286.72) ; hh = PixRound(h) ; vv = PixRound(v) ; curfnt = NULL ; curpos = NULL ; charmove = 0 ; beginloop: switch (cmd=dvibyte()) { case 138: goto beginloop ; /* nop command does nuttin */ /* * For put1 commands, we subtract the width of the character before * dropping through to the normal character setting routines. This */ #ifdef Omega case 134: /* put2 */ mychar = dvibyte() ; mychar = (mychar << 8) + dvibyte() ; charmove = 0 ; goto dochar ; case 133: /* put1 */ mychar = dvibyte() ; charmove = 0 ; goto dochar ; case 129: /* set2 */ mychar = dvibyte() ; mychar = (mychar << 8) + dvibyte() ; charmove = 1 ; goto dochar ; case 128: /* set1 */ mychar = dvibyte() ; charmove = 1 ; goto dochar ; default: /* these are commands 0 (setchar0) thru 127 (setchar127) */ mychar = cmd ; charmove = 1 ; dochar: #else case 133: /* put1 */ cmd = dvibyte() ; charmove = 0 ; goto dochar ; case 128: cmd = dvibyte() ; /* set1 command drops through to setchar */ default: /* these are commands 0 (setchar0) thru 127 (setchar127) */ charmove = 1 ; dochar: #endif #ifdef HPS if (HPS_FLAG && PAGEUS_INTERUPPTUS) { HREF_COUNT-- ; start_new_box() ; PAGEUS_INTERUPPTUS = 0 ; } if (HPS_FLAG && NEED_NEW_BOX) { vertical_in_hps(); NEED_NEW_BOX = 0; } #endif #ifdef Omega cd = &(curfnt->chardesc[mychar]) ; #else cd = &(curfnt->chardesc[cmd]) ; #endif if (cd->flags & EXISTS) { if (curfnt->loaded == 2) { /* virtual character being typeset */ if (charmove) { sp->hh = hh + cd->pixelwidth ; sp->h = h + cd->TFMwidth ; } else { sp->hh = hh ; sp->h = h ; } sp->vv = vv ; sp-> v = v ; sp->w = w ; sp->x = x ; sp->y = y ; sp->z = z ; if (++sp >= &stack[STACKSIZE]) error("! Out of stack space") ; w = x = y = z = 0 ; /* will be in relative units at new stack level */ frp->curp = curpos ; frp->curl = curlim ; frp->ff = ffont ; frp->curf = curfnt ; if (++frp == &frames[MAXFRAME] ) error("! virtual recursion stack overflow") ; curpos = cd->packptr + 2 ; curlim = curpos + (256*(long)(*cd->packptr)+(*(cd->packptr+1))) ; ffont = curfnt->localfonts ; if (ffont) { curfnt = ffont->desc ; thinspace = curfnt->thinspace ; } else { curfnt = NULL ; thinspace = vertsmallspace ; } goto beginloop ; } #ifdef Omega drawchar(cd, mychar) ; #else drawchar(cd, cmd) ; #endif } if (charmove) { h += cd->TFMwidth ; hh += cd->pixelwidth ; } goto setmotion ; #ifdef Omega case 130: case 131: case 135: case 136: case 139: #else case 129: case 130: case 131: case 134: case 135: case 136: case 139: #endif case 247: case 248: case 249: case 250: case 251: case 252: case 253: case 254: case 255: /* unimplemented or illegal commands */ error("! synch") ; case 132: case 137: /* rules */ { integer ry, rx , rxx, ryy ; ry = signedquad() ; rx = signedquad() ; if (rx>0 && ry>0) { if (curpos) { rx = scalewidth(rx, (frp-1)->curf->scaledsize) ; ry = scalewidth(ry, (frp-1)->curf->scaledsize) ; } rxx = (int)(conv * rx + 0.9999999) ; ryy = (int)(vconv * ry + 0.9999999) ; drawrule(rxx, ryy) ; } else rxx = 0 ; if (cmd == 137) goto beginloop ; h += rx ; hh += rxx ; goto setmotion ; } case 141: /* push */ #ifdef HPS if (HPS_FLAG) pushcount++ ; /* if (HPS_FLAG && PAGEUS_INTERUPPTUS) { HREF_COUNT-- ; start_new_box() ; PAGEUS_INTERUPPTUS = 0 ; } */ if (HPS_FLAG && NEED_NEW_BOX) { vertical_in_hps(); NEED_NEW_BOX = 0; } /* printf("push %i, %i\n", pushcount, inHTMLregion) ; */ #endif sp->hh = hh ; sp->vv = vv ; sp->h = h ; sp->v = v ; sp->w = w ; sp->x = x ; sp->y = y ; sp->z = z ; if (++sp >= &stack[STACKSIZE]) error("! Out of stack space") ; goto beginloop ; case 140: /* eop or end of virtual character */ if (curpos == NULL) { /* eop */ #ifdef HPS if (HPS_FLAG && inHTMLregion) PAGEUS_INTERUPPTUS = 1 ; /* printf("Page interrupted"); */ #endif break; } --frp ; curfnt = frp->curf ; thinspace = (curfnt) ? curfnt->thinspace : vertsmallspace ; ffont = frp->ff ; curlim = frp->curl ; curpos = frp->curp ; if (hh < (sp-1)->hh+2 && hh > (sp-1)->hh-2) (sp-1)->hh = hh; /* retain `intelligence' of pixel width, if close */ /* falls through */ case 142: /* pop */ #ifdef HPS pushcount-- ; /* printf("pop %i\n", pushcount) ; */ #endif if (--sp < stack) error("! More pops than pushes") ; #ifdef HPS if (HPS_FLAG) { hhmem = hh ; vvmem = vv ; } #endif hh = sp->hh ; vv = sp->vv ; h = sp->h ; v = sp->v ; w = sp->w ; x = sp->x ; y = sp->y ; z = sp->z ; #ifdef HPS if (HPS_FLAG && inHTMLregion && (hhmem - hh > H_BREAK) && (pushcount > 0) && (pushcount < current_pushcount)) end_current_box() ; #endif goto beginloop ; case 143: /* right1 */ p = signedbyte() ; goto horizontalmotion ; case 144: /* right2 */ p = signedpair() ; goto horizontalmotion ; case 145: /* right3 */ p = signedtrio() ; goto horizontalmotion ; case 146: /* right4 */ p = signedquad() ; goto horizontalmotion ; case 147: /* w0 */ p = w ; goto horizontalmotion ; case 148: /* w1 */ p = w = signedbyte() ; goto horizontalmotion ; case 149: /* w2 */ p = w = signedpair() ; goto horizontalmotion ; case 150: /* w3 */ p = w = signedtrio() ; goto horizontalmotion ; case 151: /* w4 */ p = w = signedquad() ; goto horizontalmotion ; case 152: /* x0 */ p = x ; goto horizontalmotion ; case 153: /* x1 */ p = x = signedbyte() ; goto horizontalmotion ; case 154: /* x2 */ p = x = signedpair() ; goto horizontalmotion ; case 155: /* x3 */ p = x = signedtrio() ; goto horizontalmotion ; case 156: /* x4 */ p = x = signedquad() ; goto horizontalmotion ; case 157: /* down1 */ p = signedbyte() ; goto verticalmotion ; case 158: /* down2 */ p = signedpair() ; goto verticalmotion ; case 159: /* down3 */ p = signedtrio() ; goto verticalmotion ; case 160: /* down4 */ p = signedquad() ; goto verticalmotion ; case 161: /* y0 */ p = y ; goto verticalmotion ; case 162: /* y1 */ p = y = signedbyte() ; goto verticalmotion ; case 163: /* y2 */ p = y = signedpair() ; goto verticalmotion ; case 164: /* y3 */ p = y = signedtrio() ; goto verticalmotion ; case 165: /* y4 */ p = y = signedquad() ; goto verticalmotion ; case 166: /* z0 */ p = z ; goto verticalmotion ; case 167: /* z1 */ p = z = signedbyte() ; goto verticalmotion ; case 168: /* z2 */ p = z = signedpair() ; goto verticalmotion ; case 169: /* z3 */ p = z = signedtrio() ; goto verticalmotion ; case 170: /* z4 */ p = z = signedquad() ; goto verticalmotion ; case 171: case 172: case 173: case 174: case 175: case 176: case 177: case 178: case 179: case 180: case 181: case 182: case 183: case 184: case 185: case 186: case 187: case 188: case 189: case 190: case 191: case 192: case 193: case 194: case 195: case 196: case 197: case 198: case 199: case 200: case 201: case 202: case 203: case 204: case 205: case 206: case 207: case 208: case 209: case 210: case 211: case 212: case 213: case 214: case 215: case 216: case 217: case 218: case 219: case 220: case 221: case 222: case 223: case 224: case 225: case 226: case 227: case 228: case 229: case 230: case 231: case 232: case 233: case 234: case 235: case 236: case 237: case 238: /* font selection commands */ if (cmd < 235) fnt = cmd - 171 ; /* fntnum0 thru fntnum63 */ else { fnt = dvibyte() ; while (cmd-- > 235) fnt = (fnt << 8) + dvibyte() ; } if (curpos || fnt > 255) { for (cfnt=ffont; cfnt; cfnt = cfnt->next) if (cfnt->fontnum == fnt) break ; curfnt = cfnt->desc ; } else curfnt = baseFonts[fnt] ; thinspace = curfnt->thinspace ; goto beginloop ; case 243: case 244: case 245: case 246: /*fntdef1 */ skipover(cmd - 230) ; skipover(dvibyte() + dvibyte()) ; goto beginloop ; case 239: /* xxx1 */ p = dvibyte() ; dospecial(p) ; goto beginloop ; case 240: /* xxx2 */ p = twobytes() ; dospecial(p) ; goto beginloop ; case 241: /* xxx3 */ p = threebytes() ; dospecial(p) ; goto beginloop ; case 242: /* xxx4 */ p = signedquad() ; dospecial(p) ; goto beginloop ; /* * The calculations here are crucial to the appearance of the document. * If the motion is small, we round the amount of relative motion; otherwise, * we update the position and round the new position. Then we check to * insure that the rounded position didn't accumulate an error that was * greater than maxdrift. */ verticalmotion: /* vertical motion cases */ if (curpos) p = scalewidth(p, (frp-1)->curf->scaledsize) ; v += p ; if (p >= vertsmallspace) vv = VPixRound(v) ; else if (p <= -vertsmallspace) vv = VPixRound(v) ; else { vv += VPixRound(p) ; roundpos = VPixRound(v) ; if (roundpos - vv > vmaxdrift) vv = roundpos - vmaxdrift ; else if (vv - roundpos > vmaxdrift) vv = roundpos + vmaxdrift ; } #ifdef HPS /* printf("Doing vertical motion: p = %i, v = %i, vv = %i\n",p,v,vv); */ /* printf("inHTMLregion %i\n", inHTMLregion) ; */ if (HPS_FLAG && inHTMLregion) NEED_NEW_BOX = 1 /* vertical_in_hps() */; #endif goto beginloop ; /* * Horizontal motion is analogous. We know the exact width of each * character in pixels. Kerning is distinguished from space between * words if it's less than a thinspace and not more negative than would * occur when an accent is being positioned by backspacing. */ horizontalmotion: /* horizontal motion cases */ if (curpos) p = scalewidth(p, (frp-1)->curf->scaledsize) ; h += p ; if (p >= thinspace || p <= -6 * thinspace) { hh = PixRound(h) ; goto beginloop ; } else hh += PixRound(p) ; #ifdef HPS /* printf("Doing horizontal motion: p = %i, h = %i, hh = %i\n",p,h,hh); */ #endif setmotion: roundpos = PixRound(h) ; if (roundpos - hh > maxdrift) { hh = roundpos - maxdrift ; } else if (hh - roundpos > maxdrift) { hh = roundpos + maxdrift ; } goto beginloop ; } /* end of the big switch */ pageend() ; }
int main(void) { char dpage=0; unsigned char i=0; unsigned char j=0; comm_ioctl_parms_t commparm = {38400,0}; hires=0; /* Disable JTAG port */ MCUCR |= _BV(JTD); MCUCR |= _BV(JTD); DDRA=0; //all input PORTA=0xff; //pullup xram_init(); //enable external ram dev_comm.ioctl(COMM_IOCTL_INITBAUD, &commparm); // dev_key.ioctl(KEY_IOCTL_INIT, NULL); // // dev_key.ioctl(KEY_IOCTL_INTERRUPT_DISABLE, NULL); /*disable keyboard interrupt */ vga_init(); sei(); //enable interrupts VGA_DISPLAY(0); vga_slow(); SELECT_RAM_BANK(0); clearscreen(0); SELECT_RAM_BANK(1); clearscreen(0); { char x=0; char y=0; char pos[] = {0,0}; char dir=1; char scr=0; char cposr[]={100,100}; char cpos=100; while(1) { VGA_DISPLAY(scr); //show 1 page SELECT_RAM_BANK(scr^1); //draw on other page; //undraw what we drew on this page last time for (x=30+pos[scr^1];x<100+pos[scr^1];x+=12) { for (y=10;y<80;y+=12) { drawchar(x,y, ' ', BLACK, BLACK); } } //undraw player position drawchar(cposr[scr^1], 210, '^', BLACK, TRANSPARENT); //incrment positions pos[scr^1] = pos[scr]+dir; if(pos[scr^1] > 100) dir=-1; if (pos[scr^1] < 1) dir = 1; if(dev_multi_input.kbhit()) { char c = dev_multi_input.getc(); if (c =='a' ) cpos-=5; if (c =='d' ) cpos+=5; } //draw new stuff for (x=30+pos[scr^1];x<100+pos[scr^1];x+=12) { for (y=10;y<80;y+=12) { drawchar(x,y,0xea, YELLOW, TRANSPARENT); drawchar(x,y, '^' , RED, TRANSPARENT); } } //draw player position cposr[scr^1] = cpos; drawchar(cpos, 210, '^', GREEN, TRANSPARENT); scr ^=1; //flip roles } while(1){ drawsprite( x, y, catsprite, 16, 16); drawsprite( x, y+20, catsprite, 16, 16); drawsprite( x, y+40, catsprite, 16, 16); drawsprite( x, y+60, catsprite, 16, 16); drawsprite( x, y+80, catsprite, 16, 16); drawsprite( x, y+100, catsprite, 16, 16); drawsprite( x, y+120, catsprite, 16, 16); drawsprite( x, y+140, catsprite, 16, 16); drawsprite( x, y+160, catsprite, 16, 16); x+=1; if (x==0) y+=1; } } #if 1 { prints(&dev_keyincommout, "pressenter"); dev_keyincommout.getc(); SELECT_RAM_BANK(0); START_FAST_WRITE; for(i=0;i<240;i++) { SELECT_RAM_PAGE(i); for(j=0;j<240;j++) { FAST_WRITE(j,7); } } vga_fast(); prints(&dev_keyincommout, "pressenter2"); dev_keyincommout.getc(); vga_mode(VGA_512); SELECT_RAM_BANK(1); START_FAST_WRITE; for(i=0;i<240;i++) { SELECT_RAM_PAGE(i); for(j=0;j<240;j++) { FAST_WRITE(j,63); FAST_WRITE(j,63); FAST_WRITE(j,63); FAST_WRITE(j,63); FAST_WRITE(j,63); FAST_WRITE(j,63); FAST_WRITE(j,63); } } END_FAST_WRITE; } prints(&dev_keyincommout, "pressenter3"); dev_keyincommout.getc(); prints(&dev_keyincommout, "pressenter3"); dev_keyincommout.getc(); vga_mode(VGA_256); #endif VGA_BEGIN_DRAW; for (i=20;i<200;i++) { j=i>>1; VGA_DOT(i,j,i); } VGA_END_DRAW; vga_slow(); //keyboard/comm test while (1){ /* prints(&dev_comm, "This is a test comm>"); readline(&dev_comm, str, sizeof(str), 1); prints(&dev_comm, "You said "); prints(&dev_comm, str); while (! dev_comm.kbhit()) prints(&dev_comm, "."); */ prints(&dev_keyincommout, "This is a test keyb>"); readline(&dev_keyincommout, str, sizeof(str), 1); prints(&dev_keyincommout, "You said "); prints(&dev_keyincommout, str); while (! dev_keyincommout.kbhit()) prints(&dev_keyincommout, "."); VGA_DISPLAY(dpage); //SELECT_RAM_BANK(dpage); sprintf(str, "dpage:%d", dpage); prints(&dev_comm, str); dpage++; if (dpage==2) dpage=0; } };
void drawstring(int x,int y,std::string s,Uint32 fg,Uint32 bg){ for(auto c : s){ drawchar(x++,y,c,fg,bg); } }
void drawchar(int x,int y,unsigned char c,Ecrayola fg,Ecrayola bg){ drawchar(x,y,c,crayola[fg],crayola[bg]); }
void drawstring(struct rgbData data[][WIDTH], int x0, int y0, const char* d, struct rgbData color) { for (int i = 0; i < strlen(d); ++i) drawchar(data, x0 + i * 8, y0, d[i], color); }
void testdrawchar(uint8_t *buff) { for (uint8_t i=0; i < 168; i++) { drawchar(buffer, (i % 21) * 6, i/21, i); } }