Exemplo n.º 1
0
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);
    }
}
Exemplo n.º 2
0
// 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
Exemplo n.º 3
0
/*-----------------------------------------------------------------------------------*/
static void
scrninit(void)
{
  static int i;
  
  /* Make sine tables */
  for(i = 0; i < 256; ++i) {
    sinetab2[(unsigned char)i] = sinetab1[(unsigned char)i] / 2;
    sinetab3[(unsigned char)i] = sinetab1[(unsigned char)i] / 4;    
  }
    
  /* Make color table */
  for(i = 0; i < 256; ++i) {
    colortab[(unsigned char)i] = colors[(unsigned char)i / 16];
  }
    
  *(char *)0xC056 = 0;
  *(char *)0xC054 = 0;
  *(char *)0xC052 = 0;
  *(char *)0xC050 = 0;

  for(ycnt = 0; ycnt < 24; ++ycnt) {
    gotoy(ycnt);
    for(xcnt = 0; xcnt < 40; ++xcnt) {
      (*(unsigned char **)0x28)[xcnt] = 0x00;
    }
  }
}
Exemplo n.º 4
0
void  retrieveScreen(void)
{
	unsigned char i;

	for(i=0; i<24; ++i)
	{
		gotoy(i);
		memcpy(*(char **)0x28, SCREEN_BUFFER[0][i], 40);
#ifdef __APPLE2ENH__
		if(size_x == 80)
		{
			*(char *)0xC055 = 0;
			memcpy(*(char **)0x28, SCREEN_BUFFER[1][i], 40);
			*(char *)0xC054 = 0;
		}
#endif
	}
}
Exemplo n.º 5
0
char* getscreen(unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2){

char wide = *(signed char*)RD80VID < 0;
unsigned char x = wherex();
unsigned char y = wherey();
unsigned char row;
char* screen;
char* buffer;

unsigned char numrows = y2-y1+1;
unsigned char numcols, lowoffset, hioffset, lowcols, hicols;


    if (wide==0) {            // 40 column mode - screen memory for each row is contigous
        lowoffset=x1;
        lowcols = x2-x1+1;
	    hicols=0;
    }
    else {                     // 80 column mode - have to get offsets and number of columns
        if (x1%2 == 0 ){       // because alternating screen positions are in hi/low memory
	        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;
	    }
    }

    numcols = lowcols + hicols;



    screen = buffer = malloc(1 + (numrows * numcols) + 2);
    *screen++ = wide;

    for (row = y1; row <= y2; ++row) {
        gotoy(row);
        memcpy(screen, (*(char**)BASL)+lowoffset, lowcols);
        screen += lowcols;

		if (wide){
            *(char*)HISCR = 0;
            memcpy(screen, (*(char**)BASL)+hioffset, hicols);
            screen += hicols;
            *(char*)LOWSCR = 0;
        }
    }

    *screen++ = y;
    *screen   = x;

    gotoy(y);
    return buffer;

}  // end of getscreen
Exemplo n.º 6
0
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;
}