/********************************************************************** * * * name of this file : p.c * * function: Accepts a string of arbitrary length * * from the terminal via the windowing * * program visdrv and prints it to the * * frame buffer in choice of two sizes. * * * **********************************************************************/ #include #include #include #define VCHAR '|' #define HCHAR '-' /*====================================================================* * * * a l p h * * * *--------------------------------------------------------------------*/ alph ( string, size, x, y ) char *string, size; int x, y; { int index, k; static int character[10][8], bigbuf[20][16], smallbuf[11][8]; static int alphabet[59][11] = { /* space */ {' ',0,0,0,0,0,0,0,0,0,0}, {'!',8,8,8,8,8,8,8,0,0,8}, {'"',20,20,0,0,0,0,0,0,0,0}, {'#',0,20,20,62,20,62,20,20,0,0}, {'$',8,62,73,40,28,10,73,42,28,8}, {'%',33,82,34,4,8,8,16,34,37,66}, {'&',8,20,20,8,24,37,66,66,60,2}, /* apostrophe */ {' ', 12,12,4,0,0,0,0,0,0,0}, {'(',4,8,8,16,16,16,16,8,8,4}, {')',16,8,8,4,4,4,4,8,8,16}, {'*',0,0,8,42,28,42,8,0,0,0}, {'+',0,0,8,8,8,127,8,8,8,0}, {',',0,0,0,0,0,0,0,12,12,24}, {'-',0,0,0,0,0,126,0,0,0,0}, {'.',0,0,0,0,0,0,0,0,24,24}, {'/',2,2,4,4,8,8,16,16,32,32}, {'0',24,36|2,66|4,66|4,66|8,66|8,66|16,66|16,36|32,24|32}, {'1',8,24,8,8,8,8,8,8,8,62}, {'2',28,34,65,1,2,12,16,32,64,127}, {'3',28,34,65,2,28,2,1,65,34,28}, {'4',2,6,10,18,34,127,2,2,2,7}, {'5',127,64,64,124,2,1,1,65,34,28}, {'6',28,34,65,64,92,98,65,65,34,28}, {'7',127,65,1,2,2,4,4,8,8,8}, {'8',28,34,65,34,28,34,65,65,34,28}, {'9',28,34,65,65,35,29,1,65,34,28}, {':',0,0,0,8,0,0,8,0,0,0}, {';',0,0,0,8,0,0,8,16,0,0}, {'<',0,0,2,4,8,16,8,4,2,0}, {'=',0,0,0,0,62,0,62,0,0,0}, {'>',0,0,32,16,8,4,8,16,32,0}, {'?',12,18,33,1,2,4,8,0,0,8}, {'@',0,28,34,73,85,85,79,32,30,0}, {'A',8,20,34,65,65,127,65,65,65,65}, {'B',124,66,66,66,124,66,65,65,65,126}, {'C',28,34,66,64,64,64,64,66,34,28}, {'D',124,66,65,65,65,65,65,65,66,124}, {'E',127,64,64,64,126,64,64,64,64,127}, {'F',127,64,64,64,126,64,64,64,64,64}, {'G',62,65,64,64,79,73,65,65,65,62}, {'H',65,65,65,65,127,65,65,65,65,65}, {'I',28,8,8,8,8,8,8,8,8,28}, {'J',2,2,2,2,2,2,66,66,66,60}, {'K',65,66,68,72,96,80,72,68,66,65}, {'L',64,64,64,64,64,64,64,64,64,127}, {'M',65,99,85,73,73,65,65,65,65,65}, {'N',65,65,97,81,73,69,67,67,65,65}, {'O',62,65,65,65,65,65,65,65,65,62}, {'P',126,65,65,65,126,64,64,64,64,64}, {'Q',62,65,65,65,65,65,73,69,67,62}, {'R',124,66,65,66,124,72,68,66,65,65}, {'S',28,34,64,64,60,2,1,65,34,28}, {'T',127,8,8,8,8,8,8,8,8,8}, {'U',65,65,65,65,65,65,65,65,65,62}, {'V',65,65,65,65,65,65,65,34,20,8}, {'W',65,65,65,65,73,85,85,99,99,65}, {'X',65,65,34,20,8,20,34,65,65,65}, {'Y',65,65,65,34,20,8,8,8,8,8}, {'Z',127,1,2,4,8,16,32,64,64,127} }; for( k = 0; *string != '\0'; string++ ) { index = get_index( *string ); if ( size == 'b' || size == 'B' ) { readbkg( bigbuf, x+k*18, y ); transform( alphabet, character, bigbuf, index ); writebuf( bigbuf, x+k*18, y ); k++; } else { readsmall( smallbuf, x+k*9, y ); /* RWW*/ transmall( alphabet, character, smallbuf, index ); writesmall( smallbuf, x+k*9, y ); k++; } } } /*====================================================================* * * * g e t _ i n d e x * * * *--------------------------------------------------------------------*/ static int get_index( ch ) char ch; { int index; if ( ch >= 32 && ch <= 91 ) index = ch - ' '; else if ( ch >= 97 && ch <= 122 ) index = toupper( ch ) - ' '; else index = 0; return( index ); } /*====================================================================* * * * t r a n s f o r m * * * *--------------------------------------------------------------------*/ static int transform( alph, chr, outbuf, lindex ) int (*alph)[11], (*chr)[8], (*outbuf)[16], lindex; { unsigned i,j,mask,shift,lcolor; /* The following converts letter from a bit matrix to a byte matrix */ for ( i=0; i <= 9; i++ ) for ( j=0; j <= 7; j++ ) { mask = 128; /* 1000 0000 in binary */ shift = mask >> j; chr[i][j] = ( shift & (alph[lindex][i+1])) ? 0 : 255 /*RWW*/; /* Now outbuf is filled with background plus character: */ /* Lcolor gets white if background is 0..127 (black to mid gray) */ lcolor = ( outbuf[2*i][2*j] >= 0 ) ? 255 : 0; outbuf[2*i][2*j] = chr[i][j] ? outbuf[2*i][2*j] : lcolor; lcolor = ( outbuf[2*i][2*j+1] >= 0 ) ? 255 : 0; outbuf[2*i][2*j+1] = chr[i][j] ? outbuf[2*i][2*j+1] : lcolor; lcolor = ( outbuf[2*i+1][2*j] >= 0 ) ? 255 : 0; outbuf[2*i+1][2*j] = chr[i][j] ? outbuf[2*i+1][2*j] : lcolor; lcolor = ( outbuf[2*i+1][2*j+1] >= 0 ) ? 255 : 0; outbuf[2*i+1][2*j+1] = chr[i][j] ? outbuf[2*i+1][2*j+1] : lcolor; } } /*====================================================================* * * * t r a n s m a l l * * * *--------------------------------------------------------------------*/ static int transmall( alph, chr, outbuf, lindex ) int (*alph)[11], (*chr)[8], (*outbuf)[8], lindex; { unsigned i,j,mask,shift,lcolor; /* The following converts letter from a bit matrix to a byte matrix */ for ( i=0; i <= 9; i++ ) for ( j=0; j <= 7; j++ ) { mask = 128; /* 1000 0000 in binary */ shift = mask >> j; chr[i][j] = ( shift & (alph[lindex][i+1])) ? 0 : 255; /* Now outbuf is filled with background shades */ /* The following puts character of color lcolor into outbuf */ /* Lcolor gets white if background is 0..127 (black to mid gray) */ lcolor = ( outbuf[i][j] >= 0 ) ? 255 : 0; outbuf[i][j] = (chr[i][j]) ? outbuf[i][j] : lcolor; } } /*====================================================================* * * * w r i t e b u f * * * *--------------------------------------------------------------------*/ static int writebuf( bigchar, x, y ) int (*bigchar)[16], x, y; { int i,j; char buf[16]; for ( i=0; i<=19; i++ ) { #ifdef ROGER for ( j=0; j<=15; j++ ) { buf[j] = bigchar[i][j]; VIS$SET_PIXEL(x+j,y+i,buf[j]); } #endif VIS$WRITE_HORIZONTAL_LINE (x, i+y, 16, bigchar[i]); } } /************************************************************** * * * w r i t e s m a l l * * * **************************************************************/ static int writesmall( smallchar, x, y ) int (*smallchar)[8], x, y; { int i,j; char buf[8]; for ( i=0; i<=9; i++ ) { for ( j=0; j<=7; j++ ) { buf[j] = smallchar[i][j]; VIS$SET_PIXEL(x+j,y+i,buf[j]); } #ifdef ROGER VIS$WRITE_HORIZONTAL_LINE (x, i+y, 8, smallchar[i]); #endif } } /*====================================================================* * * * r e a d b k g * * * *--------------------------------------------------------------------*/ static int readbkg( bigchar, x, y ) int (*bigchar)[16], x, y; { int i,j,k; int buf[20]; for ( i=0; i<=19; i++ ) { VIS$READ_HORIZONTAL_LINE (x, i+y, 16, buf); for ( j=0; j<=15; j++ ) { bigchar[i][j] = buf[j]; } } #ifdef ROGER for ( i=0; i<=19; i++ ) { for (k = 0; k<=15; k++ ) buf[k] = VIS$GET_PIXEL(x+k,y+i); for ( j=0; j<=15; j++ ) { bigchar[i][j] = buf[j]; } } #endif } /*====================================================================* * * * r e a d s m a l l * * * *--------------------------------------------------------------------*/ static int readsmall( smachar, x, y ) int (*smachar)[8], x, y; { int i,j,k; int buf[10]; for ( i=0; i<=9; i++ ) { VIS$READ_HORIZONTAL_LINE (x, i+y, 8, buf); for ( j=0; j<=7; j++ ) { smachar[i][j] = buf[j]; } } }