! "W N, R=    @ #D  D ҃TP  B ы e@W 0 ,"& 7   0ߋp@E A Ze      |@7x@ eE "  ɋ -lɋ e-RNHɋ ^?ramsrc.adb@-Gramtek.docd M-@̪?pdemos/wine.ram$d "@@demos/READMEd @demos/car.ram$d @@rdemos/gob.ram$d "@@Vwdemos/bottle.ram$d "@@Ndemos/seethrumd ,@demos/graythrumd ,@ݡdemos/graymd 8&@demos/tower.ram$d "@@^demos/ramtekmd $@+ 2echarout.c@Sd #include "ramtek.h" charout(chrctr,flag) char chrctr,flag; { register int WT,n; register char chr; extern int XNOW,YNOW; chr= ((chrctr>='a')&&(chrctr<='z')? chrctr+'A'-'a':chrctr); WT= 06013; /* WT+RP+OF+DF */ if ((n=nargs())>1) { if ((flag>0) && (flag<4)) WT=| (flag<<4); } in_buf(WT); in_buf(START_POINT); in_buf(XNOW); in_buf(YNOW-9); in_buf(1); in_buf(chr); flush_buf(); in_buf(SET|OF); in_buf(START_POINT); in_buf((XNOW=+ 7)); in_buf(YNOW); flush_buf(); } color_table.c@Sd 5#include "/user/ramtek/ramtek.h" #define DEBUG 0 #define RGB 0 #define CMY 1 #define HCI 2 #define GRAY 3 #define GREY 3 /* so don't have to fart with correct spelling (if there is one) */ #define NUM_LEVELS 16 #define PI 3.14159 /* * * ****** color_table ******* * * purpose: loads color look-up table. * * calling sequence: color_table(color_space,start_loc,number,comp1,comp2) * * where: * color_space is one of the following * "rgb" - red,green,blue color space * "cmy" - cyan,magenta,yellow color space * "hci" - hue,saturation,lightness color space "gray" or "grey" - gray scale (last 2 components of comp1,comp2 ignored) * * start_loc is the entry in the color table to be * loaded first. (0 TABLE_SIZE) { printf("starting location not in color table \7"); exit(); } if(start_loc + number > TABLE_SIZE) { printf("color table size exceeded \7"); exit(); } if (number <= 0) { printf("illegal number of color table entries\7"); exit(); } for (i=0;i <=2; i++) { if( space==GRAY && i>0 ) break; /* only test first */ if(*pt1 < 0.0 || *pt1 > 1.0 ) { printf("color component out of range \7"); exit(); } if(number > 1) { if(*pt2 < 0.0 || *pt2 > 1.0) { printf("color component out of range \7"); exit(); } delta[i] = ( *pt2 - *pt1 )/(number - 1); /* compute change per entry */ } pt1++; pt2++; } in_buf(LAM); /* send instruction, starting location and number to device */ in_buf(start_loc); in_buf(2*number); pt1 = comp1; pt2 = comp2; comp[0] = *pt1; comp[1] = *(pt1 + 1); comp[2] = *(pt1 + 2); for(i=start_loc;i<(start_loc+number);i++) { switch(space) { case RGB: in_buf(rgb_cvt(comp)); break; case CMY: in_buf(cmy_cvt(comp)); break; case HCI: in_buf(hci_cvt(comp)); break; case GRAY: in_buf( gray_cvt(comp) ); break; } for(j=0;j<=2;j++)comp[j] = comp[j] + delta[j]; } flush_buf(DEBUG); } /* * * convert red blue green values 0-1 into values between * 1-16 and form data word * */ rgb_cvt(comp) float *comp; { int red,blue,green; register float *pt; /* pointer to incoming color vector */ pt = comp; /* pt is now an array base */ red = *pt * (NUM_LEVELS - 1) + 0.5; green = *(pt + 1) * (NUM_LEVELS - 1) + 0.5; blue = *(pt + 2) * (NUM_LEVELS - 1) + 0.5; return( 0 | blue | (green<<4) | (red<<8)); } /* * * transform cyan magenta yellow into red blue green * */ cmy_cvt(comp) float *comp; { int i; /* counter */ float newcomp[3]; /* transformed color vector */ register float *p; /* incoming color vector base */ p = comp; /* set pointer to first element */ for(i = 0;i <= 2;i++) { newcomp[i] = 1. - *p; p++; } return(rgb_cvt(newcomp)); } /* * * transform hue chroma intensity into red blue green * */ hci_cvt(comp) float *comp; { float newcomp[3]; /* transformed hci */ register int i,j; /* counters */ register float *ptr; /* color vector pointer */ float ang; /* temporary variable */ float cos(); /* determine rgb corresponding to hue */ ptr = comp; if(*ptr < 0.1666667 || *ptr > 0.833333)newcomp[0] = 1.0; else if(*ptr < 0.333333) newcomp[0] = 2.0 -6.0 * *ptr; else if( *ptr < 0.666667) newcomp[0] = 0.0; else newcomp[0] = 6.0 * *ptr - 4.; if(*ptr < 0.166667) newcomp[1] = 6.0 * *ptr; else if(*ptr < 0.5) newcomp[1] = 1.0; else if(*ptr < 0.666667) newcomp[1] = 4.0 - 6.0 **ptr; else newcomp[1] = 0.0; if(*ptr < 0.33333) newcomp[2] = 0.0; else if(*ptr < 0.5) newcomp[2] = 6.0 * *ptr - 2.0; else if(*ptr < 0.833333) newcomp[2] = 1.0; else newcomp[2] = 6.0 - 6.0 * *ptr; /* adjust new components to smooth discontinuities */ for(i = 0; i <= 2; i++) { ang = (1.0 - newcomp[i]) * PI; newcomp[i] = (1.0 + cos(ang))/2.0; } /* adjust new components for chroma and intensity */ for (i = 0; i <= 2;i++) { if (*(ptr + 2) < 0.5 ) { newcomp[i] = (0.5 + *(ptr + 1) * ( newcomp[i] - 0.5)) * 2.0 * *(ptr + 2); } else { newcomp[i] = 0.5 + *(ptr + 1) * (newcomp[i] - 0.5) + (0.5 - *(ptr + 1) * ( newcomp[i] - 0.5)) * (-1.0 + 2.0 * *(ptr + 2)); } } return(rgb_cvt(newcomp)); } /* * grey scale: */ gray_cvt(comp) float *comp; { register int j; j = 255.*(*comp) + 0.5; /* simply convert to an integer */ j=& 0377; /* be sure is in the range 0-255 */ return(j); } idraw.c@Sd #include "ramtek.h" draw(x,y,newcolor,iwid) float x,y; { int n,ix,iy; extern int XNOW,YNOW,COLORNOW,IWIDTH; ix=x*XFACT; iy=511-y*YFACT; n=nargs(); if (n>8) { foregrd(newcolor); COLORNOW=newcolor; } if (n>9) IWIDTH=iwid; if (IWIDTH==3) { in_buf(07001); in_buf(36); in_buf(XNOW-1); in_buf(YNOW); in_buf(ix-1); in_buf(iy); in_buf(ix); in_buf(iy-1); in_buf(XNOW); in_buf(YNOW-1); in_buf(XNOW+1); in_buf(YNOW); in_buf(ix+1); in_buf(iy); in_buf(ix); in_buf(iy+1); in_buf(XNOW); in_buf(YNOW+1); in_buf(XNOW); in_buf(YNOW); flush_buf(0); } in_buf(07001); in_buf(4); in_buf(ix); in_buf(iy); flush_buf(); XNOW=ix; YNOW=iy; } nfill.c@Sd # #define DEBUG 0 #include "/user/ramtek/ramtek.h" #define WI 05000 /* write-image */ /* * perform a scan-line color fill of a polygon: * * calling sequence: * fill(n,p[,t]) * int n; * struct { * float x , y; * int color; * } p[]; * double t; * * * last point will be joined with the first point. * * if given, t is transparency factor (0.0=perfectly opaque / 1.0=perfectly transparent) * if not given, t=0.0 * */ #define MAX 30 /* max expected edges */ struct { /* structure containing one scan-line of info */ int scanx; /* x position */ float color; int flag; /* 0=normal , >0=first of horizontal pair , <0=second of horizontal pair */ int next; /* array index of next point to the right (-1=end-of-list) */ } scanbuf[MAX] , dummy; struct vert { int x , y; int col; } ppt[MAX]; fill(nn , p , t) int nn; char *p; double t; { struct { float fx , fy; int kolor; } *pts; register struct vert *pt; register int j , n; int maxy , miny , y , ib , jp1 , jp2; int i , k , l , jj , maxcol , mincol , n_pixels; float ratio , delta , dcolor , color; extern int BUFFER[] , NWORDS; /* * default "t" if not given: */ if( nargs() != 6 ) t = 0.0; pt = &ppt[0]; n = nn; pts = p; /* * scan the data for maxy and miny and convert the LL user system to the UL ramtek system: */ maxy = maxcol = -1; miny=513; mincol = 2048; for(j=0;j 511 ) pt[j].y = 511; if( pt[j].y < 0 ) pt[j].y = 0; if( pt[j].y > maxy ) maxy = pt[j].y; if( pt[j].y < miny ) miny = pt[j].y; if( pt[j].col > maxcol ) maxcol = pt[j].col; if( pt[j].col < mincol ) mincol = pt[j].col; } /* * start the scan lines from the top to the bottom and from left to right: */ for(y=miny; y<=maxy; y++) { ib=0; /* scanbuf counter */ for(j=0;j 0 ) continue; /* scan line does not cross this vector */ if( pt[j].y==y && pt[jp1].y==y ) { /* horizontal! */ scanbuf[ib].scanx = pt[j].x; scanbuf[ib].color = pt[j].col; scanbuf[ib].flag = ib+1; scanbuf[ib].next = -1; scanbuf[++ib].scanx = pt[jp1].x; scanbuf[ib].color = pt[jp1].col; scanbuf[ib].flag = -1; scanbuf[ib].next = -1; ib++; continue; } if( pt[jp1].y==y ) { /* check for a singularity at pt[jp1] */ jp2 = j+2; if( j>=n-2 ) jp2=- n; if( (pt[j].y-pt[jp1].y) * (pt[jp2].y-pt[jp1].y) <= 0 ) continue; } /* otherwise, determine the intersection of the line (pt[j]-pt[jp1]) and the scan */ ratio = y - pt[j].y; ratio=/ (pt[jp1].y - pt[j].y); scanbuf[ib].scanx = pt[j].x + (pt[jp1].x-pt[j].x)*ratio; scanbuf[ib].color = pt[j].col + (pt[jp1].col-pt[j].col)*ratio; scanbuf[ib].flag = 0; scanbuf[ib++].next = -1; } /* j */ /* * now sort the scan line intersections: */ if( ib==0 ) continue; /* insurance */ j = sort( 0 , ib-1 ); /* j is the index of the first pt */ for(; j>=0; j=scanbuf[j].next) { if( scanbuf[j].next== -1 ) break; /* something out-of-wack! */ if( (i=scanbuf[j].flag) == 0) { /* normal */ i = scanbuf[j].next; n_pixels = scanbuf[i].scanx - scanbuf[j].scanx + 1; if( t != 0.0 ) { read_pix(&BUFFER[5] , n_pixels-1 , scanbuf[j].scanx , 511 - y); if( DEBUG ) printf("\n Read %d Pixels",n_pixels-1); } delta = scanbuf[i].color - scanbuf[j].color; dcolor = delta / n_pixels; color = scanbuf[j].color; BUFFER[0] = WI|DF|OF; BUFFER[1] = START_POINT; BUFFER[2] = scanbuf[j].scanx; BUFFER[3] = y; BUFFER[4] = (n_pixels-1)<<1; for(k=0; k=u ) return(l); /* same pt! */ return( merge( sort(l,mid) , sort(mid+1,u) ) ); } merge(ii,jj) { register int i , j; register char *last; i=ii; j=jj; last = &dummy; while( i>=0 && j>=0 ) { if( scanbuf[i].flag < 0 ) { /* ignore this pt */ i = scanbuf[i].next; continue; } if( scanbuf[j].flag<0 ) { j = scanbuf[j].next; continue; } if( scanbuf[i].scanx <= scanbuf[j].scanx ) { last->next = i; last = &scanbuf[i]; i = last->next; } else { last->next = j; last = &scanbuf[j]; j = last->next; } } /* * fill out remaining list: */ if( i >= 0 ) last->next = i; else last->next = j; return( dummy.next ); } /* * combine 2 colors: * (cf is foreground, cb is background) * (t=0 means all cf / t=1 means all cb) */ #define BLACK 0 #define WHITE 239 add(cf , cb , t) float t; { register int i; if( cf==BLACK || cb==WHITE ) t = 0.00; if( cb==BLACK ) t = 0.90; return( (i=(1.-t)*cf + t*cb) ); } fill2.c@Sd # #include "/user/ramtek/ramtek.h" #define WI 05000 /* write-image */ /* * perform a scan-line color fill of a polygon: * * calling sequence: * fill2(n,p,width) * int n; * struct { * int x , y , color#; * } p[]; * * * last point will be joined with the first point. * */ #define MAXSCAN 20 /* max expected intersections per scan line */ struct { /* structure containing one scan-line of info */ int scanx; /* x position */ float color; int flag; /* 0=normal , >0=first of horizontal pair , <0=second of horizontal pair */ int next; /* array index of next point to the right (-1=end-of-list) */ } scanbuf[MAXSCAN] , dummy; fill2(nn , p , width) int nn , width; char *p; { register struct { int x , y , col; /* form the argument list is in */ } *pt; register int j , n; int maxy , miny , y , ib , jp1 , jp2; int i , k , l , jj , maxcol , mincol , n_pixels; float ratio , delta , dcolor , color , rnd; n = nn; pt = p; /* * scan the data for maxy and miny and convert the LL user system to the UL ramtek system: */ maxy = maxcol = -1; miny=513; mincol = 2048; for(j=0;j 512 ) pt[j].y = 512; if( pt[j].y < 0 ) pt[j].y = 0; if( pt[j].y > maxy ) maxy = pt[j].y; if( pt[j].y < miny ) miny = pt[j].y; if( pt[j].col > maxcol ) maxcol = pt[j].col; if( pt[j].col < mincol ) mincol = pt[j].col; } /* * start the scan lines from the top to the bottom and from left to right: */ for(y=miny; y<=maxy; y++) { ib=0; /* scanbuf counter */ for(j=0;j 0 ) continue; /* scan line does not cross this vector */ if( pt[j].y==y && pt[jp1].y==y ) { /* horizontal! */ scanbuf[ib].scanx = pt[j].x; scanbuf[ib].color = pt[j].col; scanbuf[ib].flag = ib+1; scanbuf[ib].next = -1; scanbuf[++ib].scanx = pt[jp1].x; scanbuf[ib].color = pt[jp1].col; scanbuf[ib].flag = -1; scanbuf[ib].next = -1; ib++; continue; } if( pt[jp1].y==y ) { /* check for a singularity at pt[jp1] */ jp2 = j+2; if( j>=n-2 ) jp2=- n; if( (pt[j].y-pt[jp1].y) * (pt[jp2].y-pt[jp1].y) <= 0 ) continue; } /* otherwise, determine the intersection of the line (pt[j]-pt[jp1]) and the scan */ ratio = y - pt[j].y; ratio=/ (pt[jp1].y - pt[j].y); scanbuf[ib].scanx = pt[j].x + (pt[jp1].x-pt[j].x)*ratio; scanbuf[ib].color = pt[j].col + (pt[jp1].col-pt[j].col)*ratio; scanbuf[ib].flag = 0; scanbuf[ib++].next = -1; } /* j */ /* * now sort the scan line intersections: */ if( ib==0 ) continue; /* insurance */ j = sort( 0 , ib-1 ); /* j is the index of the first pt */ for(; j>=0; j=scanbuf[j].next) { if( scanbuf[j].next== -1 ) break; /* something out-of-wack! */ cop( scanbuf[j].scanx , y); /* start span */ if( (i=scanbuf[j].flag) == 0) { /* normal */ i = scanbuf[j].next; n_pixels = scanbuf[i].scanx - scanbuf[j].scanx + 1; delta = scanbuf[i].color - scanbuf[j].color; if( width==0 && delta==0.0 ) write_image(n_pixels , (jj=scanbuf[i].color) ); else { dcolor = delta / n_pixels; color = scanbuf[j].color; in_buf(WI|DF); /* write image + data flag */ in_buf(n_pixels<<1); /* # bytes */ for(k=0; k239 ) l=239; } in_buf(l); color=+ dcolor; } flush_buf(); } j = i; continue; } /* must be a horizontal line */ k = scanbuf[j].next; if( scanbuf[i].scanx <= scanbuf[k].scanx ) { /* ie, not overlapping horizontal lines */ n_pixels = scanbuf[i].scanx - scanbuf[j].scanx + 1; delta = scanbuf[i].color - scanbuf[j].color; if( delta==0.0 ) { write_image(n_pixels , (jj=scanbuf[i].color) ); } else { dcolor = delta / n_pixels; color = scanbuf[j].color; in_buf(WI|DF); /* write image + data flag */ in_buf(n_pixels<<1); /* # bytes */ for(k=0; k=u ) return(l); /* same pt! */ return( merge( sort(l,mid) , sort(mid+1,u) ) ); } merge(ii,jj) { register int i , j; register char *last; i=ii; j=jj; last = &dummy; while( i>=0 && j>=0 ) { if( scanbuf[i].flag < 0 ) { /* ignore this pt */ i = scanbuf[i].next; continue; } if( scanbuf[j].flag<0 ) { j = scanbuf[j].next; continue; } if( scanbuf[i].scanx <= scanbuf[j].scanx ) { last->next = i; last = &scanbuf[i]; i = last->next; } else { last->next = j; last = &scanbuf[j]; j = last->next; } } /* * fill out remaining list: */ if( i >= 0 ) last->next = i; else last->next = j; return( dummy.next ); } cop(x,y) { in_buf(04000|OF); in_buf(START_POINT); in_buf(x); in_buf(y); flush_buf(); } find_glitch.c@Sd main() { register int i , j , back; int iback , array[512]; ram_setup(); backgrd("blue"); erase(); read_pix(&iback , 1 , 511 , 256); back = iback; printf("\nback = %d",back); for(i=255; i>=0; i--) { printf("\n\ti = %d",i); read_pix(array , 512); for(j=0; j<511; j++) { if( array[j] != back ) { printf("\n%d , %d = %d (%o)",i,j,array[j],array[j]); } } } } ;graythru.c@Sd ( # #include "/user/ramtek/ramtek.h" #define DEBUG 0 #define MAXSIDES 20 /* max # sides */ #define NSQ 12 float one[] { 0.0 , 0.0 , 0.0 }; float two[] { 1.0 , 0.0 , 0.0 }; float xsq[] { 1. , 1. , 2. , 5. , 7.8 , 9. , 7.9 , 3.9 , 6.8 , 5.7 , 2.0 , 4.9}; float ysq[] { 1. , 3. , 5. , 2. , 5.8 , 5. , 2.5 , 3.5 , 4.0 , 4.5 , 6.5 , 5.4}; int csq[] { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0}; struct { char *next; int nsides; struct { int x , y , z , color; } side[]; } head; struct { float xx , yy; int col; } vertices[MAXSIDES]; char *memend; main(argc , argv) int argc; char *argv[]; { register char *cp , *last; register int j; char *now , *sbrk() , *alloc() , *before; int nsides , min , i , width; char iobuf[518]; float cosine , pow() , power , atof() , xx , yy; int c , cc; float i100 , j100; if( argc>3 || argc<2 ) { printf("\n syntax: ramtek filename [width]\n\7"); exit(1); } if( argc==3 ) { width = atoi(argv[2]); srand(1); } else width = 0; if( fopen(argv[1],iobuf) < 0 ) { printf("\n cannot open %s\n\7",argv[1]); exit(1); } memend = sbrk(0); memend++; memend=& 0177776; brk(0157776); last = &head; while( (nsides=getw(iobuf)) > 0) { if( nsides>MAXSIDES ) { printf("\n %d - need to increase MAXSIDES in ramtek.c\n\7",nsides); goto contin; } last = last->next = alloc(4+8*nsides); last->nsides = nsides; last->next=0; if( DEBUG ) printf("\n nsides = %d",nsides); for(j=0;jside[j].x = getw(iobuf); last->side[j].y = getw(iobuf); last->side[j].z = getw(iobuf); cosine = getw(iobuf); cosine=/ 250.; last->side[j].color = 180.*cosine + 30. + 0.5; if( DEBUG ) printf("\n\t%d %d %d %d",last->side[j].x,last->side[j].y,last->side[j].z,last->side[j].color); if( (i=last->side[j].x) <0 || i> 511) goto bad; if( (i=last->side[j].y) <0 || i>511) goto bad; if( (i=last->side[j].color) <0 || i>239 ) goto bad; continue; bad: last->nsides=0; } } /* * start the display: */ contin: printf("\7\7"); ram_setup(); color_table("gray",0,240,one,two); backgrd(239); erase(); for(j=0; jnext ) { if( cp->nsides <= 0 ) continue; for(j=0;jnsides;j++) if( cp->side[j].z < min ) { min = cp->side[j].z; now = cp; before = last; } } if( (cp=now) == 0 ) break; /* done */ before->next = cp->next; /* so will skip this one next time */ for(j=0;jnsides;j++) { vertices[j].xx = cp->side[j].x/XFACT; vertices[j].yy = cp->side[j].y/YFACT; vertices[j].col = cp->side[j].color; } fill(cp->nsides , &vertices[0] , 0.50); } close( iobuf[0] ); } char *alloc(nbytes) { register char *m; m=memend; memend=+ nbytes; if( memend > 0157776 ) { printf("\n out of memory!\7"); exit(1); } return(m); } lights.c@Sd #include "ramtek.h" /* * turn one of the console lights on or off: * * (tricky! they are labelled from R-L but accessed L-R) * */ on_light(i) int i; /* i corresponds to number printed on the console */ { register int ri; ri=i; ri=& 07; /* range = 0-7 */ ri = 7 - ri; /* now i corresponds to LEFT-RIGHT order */ in_buf(014000); in_buf(0300|ri); flush_buf(); } off_light(i) int i; { register int ri; ri=i; ri=& 07; ri = 7 - ri; in_buf(014000); in_buf(0200|ri); flush_buf(); } tline.c@Sd #include "ramtek.h" line(x,y,np,inc,newcolor) float x[],y[]; { register int n,ix,iy; extern int COLORNOW,XNOW,YNOW; n=nargs(); if (n>4) { foregrd(newcolor); COLORNOW=newcolor; } in_buf(07003); in_buf(0100000); ix=x[0]*XFACT; iy=511-y[0]*YFACT; in_buf(ix); in_buf(iy); in_buf(4*np-4); for (n=inc;n MAX ) { printf("\n need to increase MAX in polygon.c and fill.c!\7\n"); exit(1); } parg = &arg1; pt = &p[0]; for(j=0;jx = parg->xd; pt->y = parg->yd; pt->color = parg->col; pt++; parg++; } fill(n , &p[0] , 0.0); } ram_color.c@Sd n#include "/user/ramtek/ramtek.h" #define DEBUG 0 #define BLACK 00000 #define RED 07400 #define BLUE 00017 #define GREEN 00360 #define CYAN 00377 #define MAGENTA 07417 #define YELLOW 07760 #define WHITE 07777 #define BLACK_INDEX 248 #define RED_INDEX 249 #define BLUE_INDEX 250 #define GREEN_INDEX 251 #define CYAN_INDEX 252 #define MAGENTA_INDEX 253 #define YELLOW_INDEX 254 #define WHITE_INDEX 255 /* * * ****** foregrd ****** * * purpose: sets the foreground color for suceeding commands. * * calling sequence: foregrd(color) * * where color can be a nnamed color or an index * to the color look up table. named colors * include: * "black" "blue" "red" "green" "cyan" * "magenta" "yellow" "white" * */ foregrd(color) char *color; /* color name if color > 255 */ /* color index if 0<= color <= 255 */ { int index; /* entry in color look up table*/ int strcmp();/* string cmparison function */ /* 0 - no match */ /* 1 - match */ extern int COLORNOW; /* current color index setting */ /* check for legal index or name and if name */ /* convert to an index */ index = color_name(color); COLORNOW = index; in_buf(SET | OF); /* form command word */ in_buf(FOREGROUND); /* set operand flag word */ in_buf(index); /* set foreground color index */ flush_buf(DEBUG); /* flush buffer */ } /* * * determine if two strings are equal * */ strcmp(s,t) char *s, *t; /* strings to be compared */ { int i; /* index used in comparison */ for (; *s == *t; s++, t++) if (*s == '\0' )return(1); return(0); } /* * ***** table_init() ***** * * * purpose: load named colors into the color look table starting at * location BLACK_INDEX and set initial * background color to black and * foreground to red. * * */ table_init() { int word; /* variable used to form instructions */ in_buf(LAM); /* send opcode */ in_buf(BLACK_INDEX); /* set starting address where named entries are to be stored */ in_buf(020); /* set number of entries to be loaded */ in_buf(BLACK); /* send entries to ramtek */ in_buf(RED); in_buf(BLUE); in_buf(GREEN); in_buf(CYAN); in_buf(MAGENTA); in_buf(YELLOW); in_buf(WHITE); flush_buf(DEBUG); foregrd("red"); backgrd("black"); erase(); } /* * * ****** backgrd ****** * * purpose: sets background color for suceeding commands. * * calling sequence: backgrd(color) * * where color can be a named color or an index * to the color look up table. named colors * include: * "black" "blue" "red" "green" "cyan" * "magenta" "yellow" "white" * */ backgrd(color) char *color; /* color name if color > 255 */ /* color index if 0<= color <= 255 */ { int index; /* color index */ int word; /* used for forming instructions for the ramtek */ /* check for legal index or name and convert to index */ index = color_name(color); in_buf(SET | OF); /* send command word */ in_buf(BACKGROUND); /* send operand flag word */ in_buf(index); /* send new background color index */ flush_buf(DEBUG); /* flush buffer */ } /* * * ****** erase() ****** * * purpose: writes the current background color into refresh memory. * * calling sequence: erase() * */ erase() { in_buf(ERASE); flush_buf(DEBUG); } /* * * This routine checks for legal color index or name and if * name, it is converted to an index. * */ color_name(color) char *color; { int index; if(color > 255) /* determine if specified by name or index */ { if (strcmp(color,"black"))index = BLACK_INDEX; else if (strcmp(color,"red"))index = RED_INDEX; else if (strcmp(color,"blue")) index = BLUE_INDEX; else if (strcmp(color,"green")) index = GREEN_INDEX; else if (strcmp(color,"cyan")) index = CYAN_INDEX; else if (strcmp(color,"magenta"))index = MAGENTA_INDEX; else if (strcmp(color,"yellow")) index = YELLOW_INDEX; else if(strcmp(color,"white"))index = WHITE_INDEX; else { printf(" %s is an illegal color \7",color); exit(); } } else if (color >= 0)index = color; else { printf(" %d is an illegal color index \7",color); exit(); } return(index); } ram_cursor.c@Sd s# /* * routines to write to and read from the ramtek cursor: */ #include "ramtek.h" move_cursor(x,y) { int v[3]; extern int FDKB; if( FDKB <= 0 ) if( (FDKB=open("/dev/rmkb",2)) < 0 ) { printf("Cannot open /dev/rmkb!\7"); exit(1); } v[0] = x; v[1] = 511-y; v[2] = SETCUR; stty(FDKB , v); } /* * read ramtek cursor: if 4 args, wait for ENTER . */ read_cursor(xp , yp , sp) int *xp , *yp , *sp; { int v[3]; extern int FDKB; extern int RMFLAGS[3]; if( FDKB <= 0 ) if( (FDKB=open("/dev/rmkb",2)) < 0 ) { printf("Cannot open /dev/rmkb!\7"); exit(1); } if( nargs() > 3 ){ if( (RMFLAGS[2] & WAITEN) == 0){ RMFLAGS[2] =| WAITEN; stty( FDKB, RMFLAGS); } }else{ if( RMFLAGS[2] & WAITEN ){ RMFLAGS[2] =& ~WAITEN; stty( FDKB, RMFLAGS); } } gtty(FDKB , v); *xp = v[0] &0777; *yp = 511 - (v[1]& 0777); *sp = (v[1]>>9) & 0177; } ram_kb.c@Sd # /* * read ramtek keyboard. no arg = no wait; arg = wait. */ #include "ramtek.h" #define ND 020000 /* no data flag */ ram_kb() { int input; extern int FDKB; extern int RMFLAGS[3]; if( FDKB<=0 ) /* hasn't been opened yet */ if( (FDKB=open("/dev/rmkb",0)) < 0 ) { printf("Cannot open /dev/rmkb!\7"); exit(1); } if( nargs() > 0){ /* wait */ if( (RMFLAGS[2]&WAITKB)==0 ){ RMFLAGS[2] =| WAITKB; stty( FDKB, RMFLAGS); } }else{ if( RMFLAGS[2]&WAITKB ){ RMFLAGS[2] =& ~WAITKB; stty( FDKB, RMFLAGS); } } read(FDKB , &input , 2); if( input&ND ) return(0); /* nothing hit */ return( input&0377 ); } kram_move.c@Sd#include "ramtek.h" ram_move(x,y,newcolor,iwid) /*change current operating point and color */ float x,y; { int n; extern int COLORNOW,XNOW,YNOW,IWIDTH; XNOW=x*XFACT; YNOW=512-y*YFACT; n=nargs(); if (n>8) { foregrd(newcolor); COLORNOW=newcolor; } if (n>9) IWIDTH=iwid; in_buf(04002); /*set+operand flag */ in_buf(0100000); /* c o p change */ in_buf(XNOW); in_buf(YNOW); flush_buf(); } read_pix.c@SdS#include "../ramtek.h" read_pix(array , npix , ix , iy) int *array; { register int opcode , n , nbytes; opcode = 05400|DF; if( (n=nargs()) > 3 ) opcode=| OF; in_buf(opcode); if( n > 3 ) { in_buf(START_POINT); in_buf(ix); in_buf(511-iy); } nbytes = npix<<1; in_buf(nbytes); flush_buf(); ram_read(array , nbytes); } rread_vlt.c@Sdread_vlt(start,buffer,number) int start,number,*buffer; { extern FDRAM; in_buf(02000); in_buf(start); in_buf(number); flush_buf(); read(FDRAM,buffer,number*2); } urio.c@Sd# /* * This is the I/O for the "BAAL" UNIX-Ramtek package: * * Rick Adams * Sheldon Applegate * Greg Laib * Mike Bailey * * Computer Aided Design and Graphics Lab * School of Mechanical Engineering * Purdue University * W. Lafayette, Indiana 47907 * (317) 493-9385 * * Spring 1979 */ #include "../ramtek.h" #define DEBUG 0 /* * globals: */ int FDRAM, FDPIO, FDKB; int BUFFER[BUFSIZE] , NWORDS; /* word buffer and counter */ int XNOW , YNOW , COLORNOW , IWIDTH; /* current statuses */ int RMFLAGS[3] {0,0,0}; /* for stty/gtty */ /* * ram_setup - open port(s) and set some variables: */ ram_setup() { if( (FDRAM=open("/dev/rm",2)) < 0 ) { printf("\n Cannot open /dev/rm! \7\n"); exit(1); } /* comment out pio for now if( (FDPIO=open("/dev/rmpio",2)) < 0 ) { printf("\n Cannot open /dev/rmpio! \7\n"); exit(1); } */ NWORDS = XNOW = YNOW = 0; IWIDTH=1; in_buf( 02400 ); /* reset */ flush_buf(DEBUG); in_buf( 04000|OF ); /* "set" command and operand flag */ in_buf( START_POINT ); in_buf( 0 ); in_buf( 512 ); /* set current point to LL corner */ flush_buf(DEBUG); table_init(); /* initialize named colors in colortable */ } /* * place a word in the buffer: * (if buffer is full, send it) */ in_buf( word ) int word; { if( NWORDS > BUFSIZE-1 ) /* no more room */ flush_buf(DEBUG); /* send it and reset NWORDS to 0 */ BUFFER[NWORDS++] = word; } /* * send the entire buffer: * (eventually want to test whether it would be better to use FDRAM or FDRAM ) */ flush_buf(dump) int dump; /* 1 - print contents of buffer */ /* 0 (or no argument) - do not print contents of buffer */ { register int j; /* counter */ if( nargs() <= 0 ) dump=0; /* no args = no dump! */ if( NWORDS>0 ){ if( write(FDRAM,BUFFER,2*NWORDS)<0){ printf("Ramtek write error\7\n"); exit(1); } if( dump ) for(j=0; j3 || argc<2 ) { printf("\n syntax: ramtek filename [width]\n\7"); exit(1); } if( argc==3 ) { width = atoi(argv[2]); srand(1); } else width = 0; if( fopen(argv[1],iobuf) < 0 ) { printf("\n cannot open %s\n\7",argv[1]); exit(1); } memend = sbrk(0); memend++; memend=& 0177776; brk(0157776); last = &head; while( (nsides=getw(iobuf)) > 0) { if( nsides>MAXSIDES ) { printf("\n %d - need to increase MAXSIDES in ramtek.c\n\7",nsides); goto contin; } last = last->next = alloc(4+8*nsides); last->nsides = nsides; last->next=0; if( DEBUG ) printf("\n nsides = %d",nsides); for(j=0;jside[j].x = getw(iobuf); last->side[j].y = getw(iobuf); last->side[j].z = getw(iobuf); cosine = getw(iobuf); cosine=/ 250.; last->side[j].color = 180.*cosine + 30. + 0.5; if( DEBUG ) printf("\n\t%d %d %d %d",last->side[j].x,last->side[j].y,last->side[j].z,last->side[j].color); if( (i=last->side[j].x) <0 || i> 511) goto bad; if( (i=last->side[j].y) <0 || i>511) goto bad; if( (i=last->side[j].color) <0 || i>239 ) goto bad; continue; bad: last->nsides=0; } } /* * start the display: */ contin: printf("\7\7"); ram_setup(); color_table("hci",0,240,one,two); backgrd(239); erase(); for(j=0; jnext ) { if( cp->nsides <= 0 ) continue; for(j=0;jnsides;j++) if( cp->side[j].z < min ) { min = cp->side[j].z; now = cp; before = last; } } if( (cp=now) == 0 ) break; /* done */ before->next = cp->next; /* so will skip this one next time */ for(j=0;jnsides;j++) { vertices[j].xx = cp->side[j].x/XFACT; vertices[j].yy = cp->side[j].y/YFACT; vertices[j].col = cp->side[j].color; } fill(cp->nsides , &vertices[0] , 0.550); } close( iobuf[0] ); } char *alloc(nbytes) { register char *m; m=memend; memend=+ nbytes; if( memend > 0157776 ) { printf("\n out of memory!\7"); exit(1); } return(m); } asymbol.c@Sd l# #include "../ramtek.h" #define D2R 0.01745 char font[] { 022,024,004,000,040,044,024,022,022,024,014,003,001,010,030 , 041,043,034,024,022,022,024,000,040,024,022,022,024,020,022 , 002,042,022,022,004,040,022,044,000,022,022,024,002,020,042 , 024,022,022,002,024,042,022,024,020,022,022,004,044,022,000 , 022,040,022,022,044,004,070,040,000,022,022,004,022,044,022 , 020,022,022,044,033,013,004,013,011,000,011,031,040,031,033 , 022,022,004,040,022,044,000,022,024,020,022,002,042,022,022 , 004,044,000,040,022,022,024,020,022,040,003,043,000,024,040 , 002,042,024,020,024,020,011,031,020,020,024,033,013,024,000 , 040,070,002,042,070,004,044,002,042,033,031,042,003,013,014 , 004,003,070,000,044,070,040,041,031,030,040,002,044,006,070 , 001,041,000,024,040,001,041,070,003,043,070,034,010,011,031 , 070,022,024,023,033,013,020,010,001,003,014,024,033,031,020 , 013,024,020,010,030,014,034,032,012,010,030,014,034,012,032 , 030,010,014,012,042,032,034,030,034,014,012,032,030,010,027 , 024,070,022,012,011,012,022,015,017,070,027,025,010,026,070 , 036,020,070,002,042,070,044,004,002,011,031,042,043,004,005 , 016,036,045,070,020,027,026,016,015,025,026,070,047,000,070 , 021,031,032,022,021,040,015,016,027,036,035,002,001,010,020 , 042,027,024,020,011,016,027,020,031,036,027,021,025,023,003 , 043,023,001,045,023,005,041,021,025,023,003,043,031,021,022 , 032,031,020,003,043,031,021,022,032,031,000,047,037,017,006 , 001,010,030,041,046,037,070,022,030,010,020,027,016,005,006 , 017,037,046,044,002,000,040,006,017,037,046,045,034,014,034 , 043,041,030,010,001,007,003,043,033,030,037,002,001,010,030 , 041,043,034,004,007,047,001,003,014,034,043,041,030,010,001 , 006,017,037,046,006,007,047,046,020,001,003,014,005,006,017 , 037,046,045,034,014,034,043,041,030,010,001,046,044,033,013 , 004,006,017,037,046,041,030,010,001,025,024,034,035,025,070 , 031,021,022,032,031,025,024,034,035,025,070,031,021,022,032 , 031,020,042,004,046,004,044,070,001,041,002,044,006,006,006 , 017,037,046,045,034,024,023,070,022,012,011,021,022,031,021 , 012,013,024,034,031,041,045,036,016,005,001,010,040,000,003 , 043,003,006,017,037,046,040,000,007,037,046,045,034,004,034 , 043,041,030,000,041,030,010,001,006,017,037,046,000,007,037 , 046,041,030,000,047,007,004,034,004,000,040,047,007,004,034 , 004,000,023,043,041,030,010,001,006,017,037,046,045,007,000 , 004,044,040,047,030,010,020,027,017,037,002,001,010,030,041 , 047,007,000,003,025,047,070,025,040,040,000,007,000,007,023 , 047,040,000,007,040,047,025,047,037,017,006,001,010,030,041 , 046,037,000,007,037,046,045,034,004,037,017,006,001,010,030 , 041,046,037,070,022,040,000,000,007,037,046,045,034,004,024 , 040,002,001,010,030,041,043,034,014,005,006,017,037,046,020 , 027,007,047,007,002,001,010,030,041,047,007,006,020,046,047 , 007,000,024,040,047,000,047,070,007,040,007,023,020,023,047 , 007,047,000,040,070,014,044,040,000,007,047,007,040,007,047 , 040,000,006,027,046,000,040,000 }; int kct[] { 8,12, 6, 7, 7, 7, 8, 8, 7, 7,14,13, 6, 4, 6, 2, 2, 5, 5, 8, 5,14, 6, 3, 8, 8, 9, 5, 6, 6, 6, 6, 0, 8, 5,11,13,14,11, 2, 4, 4,11, 5, 6, 2, 5, 2, 11, 5, 9,13, 6,10,13, 5,17,13,11,12, 3, 5, 3,15, 15, 9,12, 8, 7, 7, 6,11, 6, 6, 6, 8, 3, 5, 4,11, 7,13, 9,13, 4, 7, 5, 5, 5, 5, 7, 4, 2, 4, 3, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; int koc[] { 0, 8, 20, 26, 33, 40, 47, 55, 63, 70, 77, 91,104,110,114,120, 122,124,129,134,142,147,161,167,170,178,186,195,200,206,212,218, 224,224,232,237,248,261,275,286,288,292,296,307,312,318,320,325, 327,338,343,352,365,371,381,394,399,416,429,440,452,455,460,463, 478,493,502,514,522,529,536,542,553,559,565,571,579,582,587,591, 602,609,622,631,644,648,655,660,665,670,675,682,686,688,692,695, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; symbol(x1,y1,h,str,theta) float x1,y1,h,theta; char *str; { float th , si , co , x , y , fact , xa , ya , xt , yt; float xx , yy , xn , yn; double sin() , cos() , fabs(); int nc , ic , ii , ict , loc , iy; int nchar , ixn , iyn; register int i , i1 , itsub; if( (nc=count_char(str)) == 0) return; nchar = nc; th = theta*D2R; /* radians */ si = sin(th); co = cos(th); x=x1; y=y1; if( nc>=1 ) goto L50; fact=h/4.0; x=x-2.0*fact*(co-si); y=y-2.0*fact*(co+si); nc=1; if( nchar >= -1 ) goto L60; ic=2; goto L70; L50: fact=h/7.0; L60: ic=3; L70: xa=fact*co; ya=fact*si; xt=xa*6.0; yt=ya*6.0; for(i1=0; i1>3) & 07; if( xx==7.0 ) { ic=3; continue; } yy = iy & 07; xn = x + xa*xx - ya*yy; yn = y + ya*xx + xa*yy; plot(xn,yn,ic); ic=2; } x=+ xt; y=+ yt; ic=3; } } /* * count the # of chars in a string: */ count_char(str) char *str; { register char *rcp; rcp = str; while(*rcp != 0) rcp++; return(rcp-str); } testvlt.c@Sdqmain() { int buffer[100],i; float comp1[3],comp2[3]; comp1[0] = 0.0; comp1[1] = 0.0; comp1[2] = 0.0; comp2[1] = 1.0; comp2[2] = 1.0; comp2[0] = 1.0; printf("assignment made\n"); color_table("rgb",0,100,comp1,comp2); printf("color table loaded\n"); read_vlt(0,buffer,100); printf("color table read\n"); for (i=0;i<100;i++) printf(" %d \n",buffer[i]); } atext.c@Sd C#include "ramtek.h" text(string,txtmod,x,y) char string[]; int txtmod; float x,y; { extern int XNOW,YNOW; int WT,i,j,n,ix,iy,buf[30]; char *c,*k; WT= 06013; /* WT|RP|OF|DF */ k= &buf[0]; k--; /* change to caps */ for (c= &string[0]; (*(++k) = *c) != '\0';c++) if ((*k>='a') && (*k<='z')) *k=+ 'A'-'a'; i= c- &string[0]; if ((n=nargs())>1) { /* AP or BK flags */ if ((txtmod>0) && (txtmod<4)) WT=| (txtmod<<4); } /* change style of output */ if (n>4) { ix= XFACT*x; iy= 502-YFACT*y; YNOW= iy+9; } else { ix= XNOW; iy= YNOW-9; } XNOW= ix+7*i; in_buf(WT); in_buf(START_POINT); in_buf(ix); in_buf(iy); n= (i+1)/2; in_buf(i); for (j=0;j511) x=511; /* limit ranges to 0-511 */ in_buf(x); /* by clipping high or low numbers */ y = YFACT*yt + 0.5; if (y<0) y=0; if (y>511) y=511; in_buf(511-y); x = XFACT*xr + 0.5; if (x<0) x=0; if (x>511) x=511; in_buf(x); y = YFACT*yb + 0.5; if (y<0) y=0; if (y>511) y=511; in_buf(511-y); flush_buf(); } write_image.c@Sd #include "ramtek.h" #define COLOR 1 /* use color #0 */ write_image(nn , col) { register int j , n , color; n=nn; color = col; in_buf(05000|DF); in_buf( n<<1 ); /* # bytes */ for(j=0;j3 || argc<2 ) { printf("\n syntax: ramtek filename [power]\n\7"); exit(1); } if( argc==3 ) power = atof( argv[2] ); else power = 2.0; if( fopen(argv[1],iobuf) < 0 ) { printf("\n cannot open %s\n\7",argv[1]); exit(1); } memend = sbrk(0); memend++; memend=& 0177776; brk(0157776); last = &head; while( (nsides=getw(iobuf)) > 0) { if( nsides>MAXSIDES ) { printf("\n %d - need to increase MAXSIDES in ramtek.c\n\7",nsides); goto contin; } last = last->next = alloc(4+8*nsides); last->nsides = nsides; last->next=0; if( DEBUG ) printf("\n nsides = %d",nsides); for(j=0;jside[j].x = getw(iobuf); last->side[j].y = getw(iobuf); last->side[j].z = getw(iobuf); cosine = getw(iobuf); cosine=/ 250.; if( power==2.0 ) cosine=* cosine; else if( power!=1.0 ) cosine = pow(cosine,power); last->side[j].color = 240.*cosine + 0.5; if( DEBUG ) printf("\n\t%d %d %d %d",last->side[j].x,last->side[j].y,last->side[j].z,last->side[j].color); if( (i=last->side[j].x) <0 || i> 511) goto bad; if( (i=last->side[j].y) <0 || i>511) goto bad; if( (i=last->side[j].color) <0 || i>239 ) goto bad; continue; bad: last->nsides=0; } } /* * start the display: */ contin: printf("\7\7"); ram_setup(); color_table("hci",2,250,backg,backg); backgrd(250); erase(); color_table("hci",0,240,one,two); for(;;) { now=0; min=32767; last= &head; for(cp=head.next; cp!=0; cp= (last=cp)->next ) { if( cp->nsides <= 0 ) continue; for(j=0;jnsides;j++) if( cp->side[j].z < min ) { min = cp->side[j].z; now = cp; before = last; } } if( (cp=now) == 0 ) break; /* done */ before->next = cp->next; /* so will skip this one next time */ for(j=0;jnsides;j++) { vertices[j].xx = cp->side[j].x; vertices[j].yy = cp->side[j].y; vertices[j].col = cp->side[j].color; } fill(cp->nsides , &vertices[0] ); } close( iobuf[0] ); } char *alloc(nbytes) { register char *m; m=memend; memend=+ nbytes; if( memend > 0157776 ) { printf("\n out of memory!\7"); exit(1); } return(m); } cram_plot.c@̤ #include "/user/ramtek/ramtek.h" plot(x,y,pen) float x,y; int pen; { switch ( abs(pen)) { case 2: draw(x,y); break; case 3: move(x,y); break; } } gray.cް d # #define DEBUG 0 #define MAXSIDES 20 /* max # sides */ float one[] { 0.0 , 0.0 , 0.0 }; float two[] {1. , 0. , 0.}; float backg[] {.4 , 0. , 0.}; struct { char *next; int nsides; struct { int x , y , z , color; } side[]; } head; struct { int xx , yy , col; } vertices[MAXSIDES]; main(argc , argv) int argc; char *argv[]; { register char *cp , *last; register int j; char *now , *sbrk() , *before; int nsides , min , i , width; char iobuf[518]; float cosine , rnd; if( argc>3 || argc<2 ) { printf("\n syntax: gray filename [width]\n\7"); exit(1); } if( argc==3 ) { width = atoi(argv[2]); srand(1); } else width = 0; if( fopen(argv[1],iobuf) < 0 ) { printf("\n cannot open %s\n\7",argv[1]); exit(1); } last = &head; while( (nsides=getw(iobuf)) > 0) { if( nsides>MAXSIDES ) { printf("\n %d - need to increase MAXSIDES in gray.c\n\7",nsides); goto contin; } last = last->next = sbrk(4+8*nsides); last->nsides = nsides; last->next=0; if( DEBUG ) printf("\n nsides = %d",nsides); for(j=0;jside[j].x = getw(iobuf); last->side[j].y = getw(iobuf); last->side[j].z = getw(iobuf); cosine = getw(iobuf); cosine=/ 250.; cosine=* cosine; last->side[j].color = 240.*cosine + 0.5; if( DEBUG ) printf("\n\t%d %d %d %d",last->side[j].x,last->side[j].y,last->side[j].z,last->side[j].color); if( (i=last->side[j].x) <0 || i> 511) goto bad; if( (i=last->side[j].y) <0 || i>511) goto bad; if( (i=last->side[j].color) <0 || i>239 ) goto bad; continue; bad: last->nsides=0; } } /* * start the display: */ contin: printf("\7\7"); ram_setup(); color_table("gray",250,2,backg,backg); backgrd(250); erase(); color_table("gray",0,240,one,two); for(;;) { now=0; min=32767; last= &head; for(cp=head.next; cp!=0; cp= (last=cp)->next ) { if( cp->nsides <= 0 ) continue; for(j=0;jnsides;j++) if( cp->side[j].z < min ) { min = cp->side[j].z; now = cp; before = last; } } if( (cp=now) == 0 ) break; /* done */ before->next = cp->next; /* so will skip this one next time */ for(j=0;jnsides;j++) { vertices[j].xx = cp->side[j].x; vertices[j].yy = cp->side[j].y; vertices[j].col = cp->side[j].color; } fill2(cp->nsides , &vertices[0] , width ); } close( iobuf[0] ); } p)->next ) { if( cp->nsides <= 0 ) continue; for(j=0;jnsides;j++) if( cp->side[j].z < min ) { min = cp->side[j].z; now = cp; B A A L Users' Manual Computer Aided Design and Graphics Laboratory School of Mechanical Engineering Purdue University INTRODUCTION: BAAL is a home-cooked package of C procedures to drive the Ramtek 9351. COMPILATION PROCEDURE: The library containing the BAAL object modules is "/lib/ramlib.a" and should be accessed when compiling as: % cc [-f] -O program.c /lib/ramlib.a % mv a.out program PROGRAMMING CONSIDERATIONS: 1. The dimensions of the screen are 14.0 inches in the x direction and 10.25 inches in the y direction. 2. The origin (0.,0.) is in the lower-left corner of the screen. 3. The procedure "ram_setup()" must be called before any other BAAL procedures. 4. As far as anyone can tell, there are no procedure name conflicts with the "grafic" library. Thus a program may do both Imlac and Ramtek graphics. BAAL PROCEDURES: backgrd(color) Purpose: To change background color for succeeding instructions. Arguments: color...may be one of the eight predefined named colors or an index of an entry in the color look-up table. Legal index values are in the range 0-255. The named colors are: "black","blue","red","green","cyan","magenta", "yellow", and "white". Notes: The named colors must be surrounded by double qutoes or a string which ends in \0. The backgrd instruction will have no immediate effect on the display. To actually change the background color displayed, an erase instruction must be executed. charout(character [, style]) Purpose: To write a single character to the Ramtek at the current beam location. Arguments: character ... the (ASCII) character to be sent style ... as in text, this controls addiive and backpaneled letters. see text Notes: Lower case letters will be written on the screen in upper case. color_table(color_space,start_loc,number,comp1,comp2) Purpose: To load the color look-up table. Arguments: color_space...color space in which comp1 and comp2 are defined. Legal color spaces include: "rgb" - red,green,blue "cmy" - cyan,magenta,yellow "hci" - hue,chroma,intensity "gray" or "grey" - gray scale start_loc.....entry in color table to be loaded first. (0<=start_loc<=255) number........number of entries in color table to load. (1<=number<=255) comp1,comp2...3 element, floating point vectors containing the components of the first and last colors respectively to be loaded into the table. The order of the components is the same as the order of the letters in the color space being used. All components must have a value between zero and one. Linear interpolation is performed between comp1 and comp2 to obtain the desired number of entries. Notes: The last two elements of comp1 and comp2 are ignored when "grey" or "gray" color space is specified. Eight predefined named colors reside in locations 248-255. If the user specifies colors to loaded in these locations, the predefined colors will be lost. (see "foregrd" and "backgrd") draw(x , y [,newcolor [,iwidth] ] ) Purpose: Draw a line from the current position to (x,y). Arguments: x,y ... floating point coordinates. newcolor ... either an integer vlt index or a quoted standard color. iwidth ... line width in pixels. Notes: Coordinate ranges: 0.0<=x<=14.0 , 0.0<=y<=10.25 . Color: 0<= newcolor <=255 or newcolor is one of the following strings: "white" , "blue" , "black" , "red" , "yellow" , "green" , "cyan" , or "magenta". Width: iwidth = 1 or 3 . If a newcolor is given, it becomes the current foreground color. If an iwidth is given, it becomes the current line width. erase() Purpose: Replaces every pixel in the currently defined window with the currently defined background color. Arguments: None. Notes: Everything in the current window(see "window") is lost when this instruction is executed. Plotting is done with respect to the current window, so generally the window should be reset to the full screen before plotting. fill( n , p ) Purpose: Fill a closed polygon by interpolating between the colors at each vertex. Arguments: n ... the number of vertices. p ... a pointer to a structure of the form: struct { float x , y; int color; } *p; Notes: "color" refers to a location in the VLT which should already be filled. "fill" is best used when the user is filling a polygon and is not sure what the number of sides is to be. If he does know, then probably "polygon" should be used. foregrd(color) Purpose: To change foreground color for succeeding instructions. Arguments: color...may be one of the eight predefined named colors or an index of an entry in the color look-up table. Legal index values are in the range 0-255. The named colors are: "black","blue","red","green","cyan","magenta", "yellow", and "white". Notes: The named colors must be surrounded by double quotes or a string which ends in \0. Any previous instructions executed which use the foreground color will remain unchanged. Only succeeding instructions will be effected. line(xararay , yarray , npoints , incr [,newcolor]) Purpose: Draws a line with npoints-1 segments. the x,y coordinate pairs are taken from xarray and yarray. there is a move to xarray[0],yarray[0] and a line drawn to successive x,y pairs. npoints-1 line segments are drawn using every incr th point from xarray and yarray. newcolor (if specified) changes the foreground color before the line drawing is done. Arguments: xarray , yarray ... floating point arrays. npoints ... integer number of points to be connected. incr ... integer increment used in stepping through xarray and yarray newcolor ... the new foreground color. Notes: npoints must be >= 2. incr must be >= 1 . The line width is one pixel. newcolor is specified as in "draw." 0.0 <= xarray[i] <= 14.00 0.0 <= yarray[i] <= 10.25 move(x , y [,newcolor [,iwidth] ]) Purpose: Changes the current beam position and possibly the current display parameters. Arguments: See "draw". Notes: See "draw". move_cursor( ix , iy ) Purpose: To move the Ramtek cursor. Arguments: ix,iy ... the integer location to which the cursor will be moved. Notes: The origin is lower left and the range is 0-511 for both ix and iy. off_light( i ) Purpose: Turn one of the Ramtek keyboard lights off. Argument: i ... the light # to turn off (left=7 / right=0). on_light( i ) Purpose: Turn one of the Ramtek keyboard lights on. Argument: i ... the light # to turn on (left=7 / right=0). polygon(x1,y1,col1 , x2,y2,col2 , ...) Purpose: Fill a closed polygon by interpolationg between the colors at each vertex. Arguments: xi ... floating point x coordinates. yi ... floating point y coordinates. coli ... integer indices into the VLT representing the color at that vertex. Notes: "polygon" should be used if one knows how many sides his polygon will have. If the number is not known, he should use "fill" instead. The VLT should already be filled prior to this call. ram_kb(flag) Purpose: Read the Ramtek keyboard. Arguments: flag ... if an argument is present, the program will go to sleep until the keyboard input is made (producing an interrupt.) If no argument is present ram_kb returns 0 (immediately). Notes: The optional argument obviates the necessity for the tight polling loops found in grafic programs. It also allows other users the use of the cpu until the keyboard is hit. ram_setup() Purpose: Setup the Ramtek and its interface. Arguments: None. Notes: This call MUST preceed all other Ramtek calls. read_cursor( xp , yp , status [, flag ] ) Purpose: Read the Ramtek cursor. Arguments: xp,yp ... pointers to integers. The x,y cursor location will be returned in *xp,*yp . status ... the status of the cursor switches. Additively, +2 for the visible switch +8 for the track switch +16 for the enter switch flag ... as in ram_kb, if flag is present the program goes to sleep until given an interrupt. The interrupt may come from the track or enter switches. Notes: xp and yp should point to integers. flag should normally be given. read_pix(array, nw [,ix , iy]) purpose: to read refresh memory data. the returned values are indices to the color table. arguments: array...the address of the integer array into which the values are to be read. nw......the (integer) number of values to be read. ix,iy...(optional) the starting pixel for the read. notes: ix and iy are integers designating the starting pixel for the read. the current COP is the default starting pixel. if the read runs into a window boundary it goes to the next row in the normal way (as a typewriter return). ix and iy assume a lower left origin. 0 <= ix,iy <= 511 symbol(x , y , ht , str , theta) Purpose: To plot a string on the Ramtek screen. Arguments: x,y ... the lower-left coordinates of the first character in the string (floating point). ht ... the height of the string in inches (fp). str ... a pointer to a character string. theta ... the angle (degrees) at which to plot the string (fp). Notes: The string must terminate in a '\0' . (strings passed in double quotes automatically do.) The string is drawn in the current foreground color. The string is drawn in the current line width. "symbol" only supports upper-case letters. Any lower-case letters passed are mapped to upper case. text(&string [,style [,x , y]]) Purpose: Write character strings on the screen. Arguments: string ... the address of an ASCII string, either as a quoted string or the address of a character array. style ... values 0-4 are accepted with the following results: 0 - foreground color character on background color panel. 1 - background color character on foreground color panel. 2 - additive foreground color character. 3 - additive background color character. x,y ... coordinates of the lower left corner of the first character. Notes: The default x,y pair is the current beam position. The beam is left at the lower right corner of the last character. No responsibility is maintained for beam updating if the string passes a window boundary or otherwise uses a carriage return and/or a line feed. window(xl , yb , xr , yt) Purpose: Declare a window on the Ramtek screen. Arguments: xl ... the left edge of the window (floating point). yb ... the bottom edge of the window (fp). xr ... the right edge of the window (fp). yt ... the top edge of the window (fp). Notes: Probably the best (and possible only) use for this routine is in the filling of a rectangle with one color. Rather than doing a time- consuming polygon fill, the user should set the window to the size of his rectangle, set the background color to the rectangle's color, and do an "erase." Afterwards, he should set the window back to full screen, or subsequent graphics instructions may be fubared. e right edge of the window (fp). yt ... the top edge of the window (fp). Notes: Probably the best (and possible only) use for this routine is in the filling of a rectanglD>> ADCE>E>DC MCF>F> MCVCG>G>VCZAG>> A';W&G^DCDC&G^U] MC MCU]``VCVC``f[ZA';W1=1M&G^&G^1M(]U]U](]i````ipf[1=4E%4V1M1M4V+f(](]+friiryp4E%5Y35j4V4V5j,y+f+f,yrry5Y36tD5&5j5j5&+,y,y+6tD3Y3<5&5&3<*++*3Y.p.V3<3<.V&<**&<''.p&{'e.V.V'e!O&<&<!O>''>3&{ z'e'ezj!O!Oj]>>]U3 KMzzM Pjj PR]]RSUK  MM  P PRRS                ^      p ^    pG>ZAY?G>G>Y?U?G>G>U?Q>F>F>Q>L;F>ZAf[fJY?Y?fJbAU?U?bAZ9Q>Q>Z9R%L;f[pqrfJfJqrmFbAbAmFdZ9Z9dX4R%py{}qrqr{}w%mFmFw%n:ddn:aX4yx{}{}x!w%w%!:n:n::tapxxp!!9::9tlppl:99:(qllq.E::.EE(30dqq0d55CL.E.ECLWE3USi0d0dSiW55WaJCLCLaJpWUSSoSiSiSoRWWRQDaJaJQDOpSwSoSowRRGQDQDGOgwwg7GG7ZggZ'77'p5ZZ5''[p55[F>L;F9E>E>F9<9D>D><93 9C>C>3 9.);C>L;R%FF9F9F8<9<98)43 93 9)4!A .);R%X4IGFFIG7'C887'C(AP)4)4(APQK!A X4aPIGIGP?07'C7'C?0/J(AP(AP/J$ZQKatdPPdS>?0?0S>DX/J/JDX:h$Zt/dd/oNS>S>oNahDXDXahWx:h(D//DboNoNb{ahah{Wx(E_DD_ybby{{EWn__nyyWpnn  pOLLJ  JHHFOLLJJHHF[n[nC>.);/'>C>C>/'>3 >C>C>3 >9>C>C>9>> AD>.);!A !A3/'>/'>!A3 '8<3 >3 > '8<1(D9>9>1(D';W> A!A QKS!A3!A3S"J1 '8< '8<"J1&.7\1(D1(D&.7\1=';WQK$Z"^dSS"^d'V"J1"J1'V*4BV&.7\&.7\*4BV4E%1=$Z:h7le"^d"^d7le=c 'V'V=c +IOQ*4BV*4BV+IOQ5Y34E%:hWxU|d7le7leU|d[r=c =c [r+f_I+IOQ+IOQ+f_I6tD5Y3Wx}eU|dU|d}e[r[r)qE+f_I+f_I)qE3Y6tDn}e}en$J)qE)qE$J.p3Yqnnq@$J$J@&{.pqqqqD@@D &{FFnqqFnGG HGDD HGK FqFnFnqGGN HG HGN K`qq`?NN?  S``S /?? / n1SS1   / /  ^n11     ^To run the demos in this directory: *.ram are datafiles gray file grayscale shading of object ramtek file color shading of object graythru file grayscale shading with transparency seethru file color shading with transparency n1SS1   / /  ^n11     ^v0vv 9v0%R%%%Rh(h&F&(&(&%"R./ ?"R & &!&?& 7! S7%% % S%(( 9( ( 9vv!=vv%%!_%!=%(2u!_(&(&2S&2u&./"Ru,|8"R?pu,?&!&s&p&!7os7 Sko S% %%k% ( 9(((v!=vi+vmGv!=%!_%f+%i+%!_2uk;f+2u&2S&n;&k;&|8u,[5`bA=u,pW'L[5`p&s&Z'/&W'L&soV!EZ'/okRaV!Ek%%#%Ra%((mG(#(mGvi+vP4KvT&vi+%f+%M4m%P4K%f+k;REM4mk;&n;&TEa&RE&bA=[5`B?IK[5`W'L>0B?W'L&Z'/&@0&>0&Z'/V!E<*@0V!ERa9&<*Ra%#%j&%9&%#(mG(T&(j&(T&vP4Kv7>v;/TvP4K%M4m%4>%7>%M4mRE9N 4>RE&TEa&;N&9N &IKB?)In0TKB?>0%:Z)In>0&@0&':<&%:Z&@0<*#4R':<<*9& 0o#4R9&%j&%Q01% 0o%j&(T&(;/T(Q01(;/Tv7>vGYv!9v7>%4>%G{%GY%4>9N XG{9N &;N&"Xo&X&0TK)InR^)In%:Z CR%:Z&':<&C& C&':<#4R =C#4R 0o9 = 0o%Q01%79%9%Q01(;/T(!9(79(F8B(8EP3BEEVLP3E:XTbMVL:,J,[ETb ,J,J^1j[EJ^jiuQs1jjiu_ jiQs_ 2TKt]jiTKCAL-t]CA1E;L-1E%q./q;(BDg ++Dg GI--GII+ /r/rI+ K 2SBP3SDg Dg SVGIGIVXI+ I+ XZK P3VLYSSY[VV[]XX]_ZVLTbMXE}YYXE}Z&[[Z&\]]\^_Tb [E^XE XE ^`Z&Z&`bb\\bbdC^[E1j+lnV^^+lnV%oOr``%oOrq1qbbbbq1qs\dC1jQsKv+lnV+lnVKvEx%oOr%oOrEx>zq1qq1q>z8}s\QsjidktKvKvdkt]nVExEx]nVWp8>z>zWp8Qr8}jit][gYQrt]L-hVO-[gYL-;uDShVO-;./q|8quDS2SK Un;K ZcAUZ_i"cA_^goi"^dCngodCs\}\ns\8}}\8}Qr8|Qr[gYBp8|[gYhVO-O_-BphVO-uDS[NO_-uDS|8qbA=q[Nn;Uw_TEaUcAmw_cAi"smi"goqsgonwQqn}\ \wQ}\ \8|'8|Bp(zg'BpO_-6i]-(zgO_-[NBWa6i]-[NbA=qIKqBWaTEaw_qaNGCNGCqajcHJ%HJ%jcdfBLBLdf^h;Nw_moqaqaorjcjcruodfdfuo|wP|^hmsuoouxmrrxmzO uouozO |0K|wP|sqtxuutxw{xmxmw{yzO zO yz}|0KqwQz3t t z3}w w }yyz}-wQ \Kz3z3KQ}}Qkk \KKiQQiKkkK,'  ii KK ,'(zg(zg6i]-r-6i]-BWa)ar-BWaIKq0TKq)a;N^hWj4Q4QWjOm]-TN-TNOm]Ip='V'VIp=Dq'"Xo^h|wP|ux-aWjWjux-an{ Om]Om]n{ g}Ip=Ip=g}c~Dq'|wP||0K} rux-aux-a} r~n{ n{ ~~\g}g}~\yc~|0Kz}zX} r} rzXx/=~~x/=w .~\~\w .uyz}-zXzXx/x/nw Uw UnVMutbbBnnB+jVM,  rbbrbBBb++j,a  ajfrrjfJbbJ5+t52r-|jtr-)akn|j)a0TKq^qknb3a(:k4z21x91x9z2.!9!9.09903:k4r|z2z2|..003r}||}"".$$.:0$$0'':F=00=3''3++&FRI==I?33?7++72&RdWIIWN??NG77GB2ds{]}WW]}QNNQJGGJCBs{ 7a=]}]}a=  JGQQ  JG:AJJ:A-<C 7FCga=a=Cg/7  JG  JG/7:A:A"-<FWDPhQCgCgPhQ82W/7/782W!T!T&J"WDg^lPhQPhQ^lC182W82WC1*!T!T*/&Jgul(y^l^ll(yM5:C1C1M5:$>**$>D/uJwVl(yl(ywVV`TM5:M5:V`T)g $>$>)g kD:34;;4<==<D??D~GlB3 44 0<<0nDDn}s~Gy  y 00 ~nn~}suyyu   D~~ D uuu uD D DDv u uv"EDD"E*&%vvv%v((.E"E"E.E6*&21v%v%v1v4((4:E.E.E:EB62B>1v1v>@*44@*F`:E:EF`SBBC<>><;,@*@*;,E:F`F`E:[BSC-<#:<<#:&%;,;,&%7 E:E:7 X[B-<"##:#:#!&%&%!x7 7 x]H X"&J';##';$(!!$(oxxoPD]H &J/1u';';1u-8$($(-8g& oog& DDXPD/DE1u1uEB9-8-8B9`;$g& g& `;$:1PDDXDkkEEki 5B9B9i 5Ze1,`;$`;$Ze1,0]j:1PlB~Go JapCapCo Jd$NeY8DeY8Dd$N\4K|D_D|D_D\4KUAI5xB~G}ss wo Jo Js wnd$Nd$Nnj \4K\4Kj g'UAI}ss ws wznnzwj j wu$g'&zz&-ww-2u$((2&&29--9>2*4((4>22>E99EJ>*6@44@J>>JQEEQVJ6BL@@LVJJV]QQ]bVBS`LL`iVVip]]pubS[BqF``qF}^ii}^XppXVu[BX{qFqF{ }^}^ XXVX]H Ny!{{Ny!R!  R!l!l! ]H PD@yNy!Ny!@yDR!R!D`l!l!` PDDDX1 @y@y1 4DD4R``R t DDX:1P#"1 1 #"#44#CRRC! t:1P0]jR#"#"RE##E67 CC67 }-@!5xBUAIPJF1~@1~@PJFQH>9q>9q>QH>Z76#KS<#KS<Z76k43a(:UAIg'c.zPJFPJFc.zc/>QH>QH>c/>h%Z76Z76h%rk4g'u$t(c.zc.zt(t'.c/>c/>t'.w Xh%h%w X}ru$24nt(t(4n1t'.t'.1+Mw Xw X+M"}2>@n4n4n@n=11=7M+M+M7M.">JLn@n@nLnI==ICM7M7MCM:.JVXoLnLnXoUIIUOMCMCMOMF:VbdoXoXodoaUUa[NOMOM[NRFbuxdodoxwaawq[N[NqdRuVNxxNwwwqqws{dVNN5ww5 7s{   5555F 7    D255D2WDF t-  -  SYD2D2SYgWD t!)O--)O+  +afSYSYafug!}-@*HY)O)O*HY507 ++507 o<fafafo<fJuD>> ADCE>E>DCMCF>F>MC VCG>G> VCZAG>> A6;W4G^DCDC4G^(U]MCMC(U]`` VC VC``f[ZA6;WC=CM4G^4G^CM7](U](U]7]#i````#i pf[C=HE%HVCMCMHV<f7]7]<f'r#i#i'r y pHE%IY3IjHVHVIj=y<f<f=y''r'r'  yIY3JtDI&IjIjI&<=y=y<''''  JtDGYF<I&I&F<:<<:%''%  GY?p@VF<F<@V5<::5<"'%%"'  ?p5{6e@V@V6e.O5<5<.O>"'"'>3 5{% 'z6e6e'z j.O.O j]>>]U3% KM'z'zMP j jP R]] RSUKMM PP  R RS      ^  p^  pG>ZAY?G>G>Y?U?G>G>U?Q>F>F>Q>L;F>ZAf[fJY?Y?fJbAU?U?bAZ9Q>Q>Z9R%L;f[ pqrfJfJqrmFbAbAmFdZ9Z9dX4R% p y{}qrqr{}w%mFmFw%n:ddn:aX4 y x{}{}x!w%w%!:n:n::ta  pxxp!!9::9t  lppl:99:(  qllq.E::.EE( 30dqq0d55CL.E.ECLWE3USi0d0dSiW55WaJCLCLaJpWUSSoSiSiSoRWWRQDaJaJQDOpSwSoSowRRGQDQDGOgwwg7GG7ZggZ'77'p5ZZ5''[p55[F>L;F9E>E>F9<9D>D><93 9C>C>3 9.);C>L;R%FF9F9F8<9<98)43 93 9)4!A .);R%X4IGFFIG7'C887'C(AP)4)4(APQK!A X4aPIGIGP?07'C7'C?0/J(AP(AP/J$ZQKatdPPdS>?0?0S>DX/J/JDX:h$Zt/dd/oNS>S>oNahDXDXahWx:h(D//DboNoNb{ahah{Wx(E_DD_ybby{{EWn__nyyWpnn  pOLLJ  JHHFOLLJJHHF[n[nC>.);/'>C>C>/'>3 >C>C>3 >9>C>C>9>> AD>.);!A !A3/'>/'>!A3'8<3 >3 >'8<*1(D9>9>*1(D6;W> A!A QKS!A3!A3S"J1'8<'8<"J15.7\*1(D*1(D5.7\C=6;WQK$Z"^dSS"^d'V"J1"J1'V:4BV5.7\5.7\:4BVHE%C=$Z:h7le"^d"^d7le=c 'V'V=c ;IOQ:4BV:4BV;IOQIY3HE%:hWxU|d7le7leU|d[r=c =c [r;f_I;IOQ;IOQ;f_IJtDIY3Wx}eU|dU|d}e[r[r8qE;f_I;f_I8qEGYJtDn}e}en2J8qE8qE2J?pGYqnnq)@2J2J)@5{?pqqqq  D)@)@D% 5{FFnqqFnG  GHGDDHGK% FqFnFnqGG NHGHG NK`qq` ? N N ?S``S/ ? ?/n1SS1  // ^n11    ^N(L & 6  %w J&.%%) $" %% @ 5 $(5 Ne@& $ @>) $"  % %7, ,E, %,Ne $5 %_Q) $" ) $" Z(N(& ) Ze   % _t5r(5t(t5(5( 5(N& & ff& & ff& Azf& & ffj'd'z& & ff\'V'zf& & ffJ'D'z& & ff<'6'zf& & ff& & ff eF @te  s N) $"  B-_Ne $Wt`1Ne $Wt`1Ne $Wt`1Ne $& ^$%ff& zDz& & ff& 4Dz6 6 & Bz6 6 & @z ,$t` t` t`&t`&t`&) $"et`5%t`5% t`5 %3  _*& & & $B& & & `B& & & & & & & & re 5 ,(  tap- ta55 - DV= =ta& "6 6 $$zWp ,,%ta& "6 6 & HCzWp ,,%Wp @Wtap , -$$z$t$,& Be _@ &w!w !(wm(%ߚ() $" %w!w v!, !% & & & &   .Bu55 _Wp Am& & ff^$X$z6 6 & @z !WpaWp Am& & ff& HCz6 6 & @z \!WpaWpfaeWp Am^WpfaeWpfaeWpa%WpaWpa Wpa1 Wpaq-WpauWpaq-WpauWpaq-WpauWpaq-Wpau _Bu_ 5  _  5 5 WpfaAWpa^"WpfaeAWpa^,_ AWpafNWpaAAVp_ Wpaq-jAWpaq-aAWp fe-Wpa^Wpaf XAWp --%AWp @A p-AWp - AWp fe-AWpa^AWpaf AWp --%AWp -AWp - _ AWpaq--e5e AWpafAWpaNAWpfaeWpaAVp_ fWpaN >%AWpafWpaN vvzAWpafWpaN ffz6 6 Wpaf z AWp -AWpafWpaN ffz6 6 Wpaf lzAWp --%AWp 1 -AWp - _ _ N & _ Wp u-Wp fe-AWp A- u& & & & ff f f NWp f-f / fe N ) $" AWp & & f-f-Wp f-f-z%& & fff Dz%Wp u-u- $$Wp w-$w$@ 7$5 G& & ff& @z & & & & ff f f ff f f@ &/f Ve 5@ p/ffffz @ @-@e7~% C_ Wp %-_ Wp u-_ Wp u-AWp fe-AWp ^,-_ Wp fe-AWp A- u& & & & ff f f NWp f-f / feAWp & & f-f-Wp f-f-z%& & fff Hz%Wp u-u- ""Wp w-"w"@ 7"5 G& & ff& @z & & & & ff f f ff f f@ &/f Ze 5@ p/ffffz @ @-@e7# Wp C- _ u-_ww DC` r w & %&  w \DC.;Wp D-5Wp C-/ /Wp -Wp -Wp fe-Wp ^,- 2Wp Be- Wp Be-  20 ww  % & & & &      & & & @6 6 f fz6 6 f z6 6 f 6 6 f fzz w w  , %U X% XN XN XB  X f  ww . "%; r %) $" %CeBe5  e e 5!& & & & fe& e ww u u R*f  5 8V*f  +Z*f  ^*f  c*f  h* $" % %~* $" @@m%* $"  * $"  % _.@& & && @& & &&& & & @ 8* $" d%C@& & && @@& & &&& & & @ + $" @& & &&@&&z6 6 f zt@a%ee % XN X@  Xu u @555555 D@  x *Ne " X %  @@m! ~wt@a& & &&t@a&&zt@a% Ne Ne vNe xw @D& & &&& pBz6 6 & @z & & &&& pBz6 6 & @z & & & && pBz6 6 & @z ` %D& & & && & &&& & &&&+ @eNff6+ $"e@tAWt@P@]wXw HD5 & & & @6 6 &&z@t@a%e %Ne "ww B& & |v & & pjd^ @5 Q& & LF@: & & & A6 6 & & & Azz$& &  z5 & & & Az6 6 & z%& &  (& & & Az%=& & & & & @ @*& & b\VP & & & A6 6 & & & Azz5 5 & &   p5 5 O& & & & & @ L& & & Az6 6 & z+& &  @& & & A6 6 & & & Azz% & &  & & & @ 3& & t@a& & &&& zz6 6 & @z6 6  z6 6 & Azl& & t@a& & &&& zz6 6 & & & @6 6 & & t@a& & &&& zzz6 6 & &  & Az6 6 & zzz6 6 & @zt@a% %_Ne "w w @& & &&& Dz6 6 & @z fEw w N 57T X XN X ~w w x wr  } w N  X X X X X X X X X X X ~F+ J+  :w w N 5 X XN X ~w w  X ~w w %_P+f  dV+f  WZ+f  J_+f  =e+f  0j+f  #r+f  y+f   N+ $" " @w uw + & 7&+ $" % 777  X ~ X X X X ~ w w % ~ p/w w t 5  ' /z %% + $" %   /+ $" -:7 4w w x Nf$ &%@-+ $" %wX w H  X@ X6 6 ffz6 6 & @z  % X& & & HC6 6 ffz6 6 & @z b  % XXRLF6 6 ffz6 6 & @z   % X& & & HC6 6 ff z6 6 & @z  % X w w DCed  x", . %e̋ww   % % %+ %-  w%9Wp Ce` %0 w J5 5  l% % %+ T%- F%0 %.[@5 O%9ff&  Bz&e Nvvz%92& & & & &  Bvvz6 6 &e zvvz %0 & & ff @><:w2& & ff7 7777  ӕ-ӕ0 C~ ӕ. ӕ0 ~ nC~7 7777 ӕ- <ӕ.X  ,C~ӕe ӕ- ӕ+ r e0e0S 0fw6w2w.w *w  8fw www w  }7 && !EU   "   8 83 &tEe0E!`383m& c `3 83eȐ9 ȕ0 83ȕ1  c `3 83083  83    w r &@r&@r(@rP r  vA `B A @ &&f  eB A @ eA @ e@ e B A @    w >~w<De2  , % *$w7 7 ׯ-  w7  .twe(,B J  ӕ-ׯd  z r f e0&   ԕ- \  vA W  ~e0fv  @ >< ҋ D~8T,X, ӕ0 $f v Le0 9e  7we&  m  *$~  *$  *$~ wB7 x n j0   VWp `e0fH ,>P 4 . @f  |37 \,|3-f 21 ~ 21  7n j f 7X 7 V fw~b,JA 7 , fAW,f B@ 8 @&61fA   @ @e71@h, 1wRfwmn,w6wmfwn,ww f@wwt,wf@fA w,pw"je"w"`ew"V@lw"NAlewA &@t`e @& BFfww,w<f@w( f@ww,w7P F L& z6 6 l X b` 6  L5 6 e]& z6 6 vEWtf6EUv   v6 z e e e  e  UUUt n &6xn7hf`Wp3e @7RE*@@*@@@@?̀@@AAABAyAAAffAÀ@@AAAAA A`AAAAA?9A?f@ffCG @ syntax: ramtek filename [width]  cannot open %s  %d - need to increase MAXSIDES in ramtek.c  nsides = %d %d %d %d %dhci out of memory!CGf@ff Read %d Pixels need to increase MAX in polygon.c and fill.c!  *?U@[U?*@*?*@?;U@[Urgbcmyhcigreygrayillegal color space starting location not in color table color table size exceeded illegal number of color table entriescolor component out of range color component out of range rgb1 %f %f %f rgb2 %d %d %d redblackblackredbluegreencyanmagentayellowwhite %s is an illegal color  %d is an illegal color index /dev/rm Cannot open /dev/rm!  Ramtek write error %o Ramtek read error CGCG"dN#oH#x#f#e&#c4#s"l"u#r|35 %ewvor table color table size exceeded illegal number of color table entriescolor component out of range color component out of range rgb1 %f %f %f rgb2 %d %d %d redblackblackredbluegreencyanmagentayellowwhite %s is an illegal color  %d is an illegal color index /dev/rm Cannot open /dev/rm!  Ramtek write eN(@ & 6  %w J&.%%) $" %% @ 5 $(5 Ne@& $ @2) $"  % %7, ,E, %,Ne $5 %_E) $" ) $" Z(N(& ) Ze   % _t5f(5h(t5(5( 5(N& & ff& & ff& Azf& & ff^'X'z& & ffP'J'zf& & ff>'8'z& & ff0'*'zf& & ff& & ff eF @te  s Nt) $"  B-_Ne $Wt`1Ne $Wt`1Ne $Wt`1Ne $& ^$%ff& zDz& & ff& 4Dz6 6 & Bz6 6 & @z ,$t` t` t`&t`&t`&) $"et`5%t`5% t`5 %3  _*& & & $B& & & `B& & & & & & & & re 5 ,(  tap- ta55 - DV= =ta& "6 6 $$zWp ,,%ta& "6 6 & HCzWp ,,%Wp @Wtap , -z$t$n$h$,& Be _@ &w!w !(wm(%ߎ() $" %w!w v!, !% & & & &   .Bu55 _Wp Am& & ffR$L$z6 6 & @z !WpaWp Am& & ff& HCz6 6 & @z \!WpaWpfaeWp Am^WpfaeWpfaeWpa%WpaWpa Wpa1 Wpaq-WpauWpaq-WpauWpaq-WpauWpaq-Wpau _Bu_ 5  _  5 5 WpfaAWpa^"WpfaeAWpa^,_ AWpafNWpaAAVp_ Wpaq-jAWpaq-aAWp fe-Wpa^Wpaf XAWp --%AWp @A p-AWp - AWp fe-AWpa^AWpaf AWp --%AWp -AWp - _ AWpaq--e5e AWpafAWpaNAWpfaeWpaAVp_ fWpaN >%AWpafWpaN vvzAWpafWpaN ffz6 6 Wpaf z AWp -AWpafWpaN ffz6 6 Wpaf lzAWp --%AWp 1 -AWp - _ _ N & _ Wp u-Wp fe-AWp A- u& & & & ff f f NWp f-f / fe N ) $" AWp & & f-f-Wp f-f-z%& & fff Dz%Wp u-u- $$Wp w-$w$@ 7$5 G& & ff& @z & & & & ff f f ff f f@ &/f Ve 5@ p/ffffz @ @-@e7r% C_ Wp %-_ Wp u-_ Wp u-AWp fe-AWp ^,-_ Wp fe-AWp A- u& & & & ff f f NWp f-f / feAWp & & f-f-Wp f-f-z%& & fff Hz%Wp u-u- ""Wp w-"w"@ 7"5 G& & ff& @z & & & & ff f f ff f f@ &/f Ze 5@ p/ffffz @ @-@e7v# Wp C- _ u-_ww DC` r w & %&  w \DC.;Wp D-5Wp C-/ /Wp -Wp -Wp fe-Wp ^,- 2Wp Be- Wp Be-  2$ ww  % & & & &      & & & @6 6 f fz6 6 f z6 6 f 6 6 f fzz w w  , %U X% XN XN XB  X f  ww . "%; r %) $" %CeBe5  e e 5!& & & & fe& e ww u u F*f  5 8J*f  +N*f  R*f  W*f  \* $" % %r* $" @@m%* $"  * $"  % _.@& & && @& & &&& & & @ 8* $" d%C@& & && @@& & &&& & & @ * $" @& & &&@&&z6 6 f zt@a%ee % XN X@  Xu u @555555 D@  x)Ne " X %  @@m! ~wt@a& & &&t@a&&zt@a% Ne Ne vNe xw @D& & &&& pBz6 6 & @z & & &&& pBz6 6 & @z & & & && pBz6 6 & @z ` %D& & & && & &&& & &&+ @eNff*+ $"e@tAWt@P@]wXw HD5 & & & @6 6 &&z@t@a%e %Ne "ww B& & |vpj & & d^XR @5 Q& & @:4. & & & A6 6 & & & Azz$& &  z5 & & & Az6 6 & z%& &  (& & & Az%=& & & & & @ @*& & VPJD & & & A6 6 & & & Azz5 5 & &  p5 5 O& & & & & @ L& & & Az6 6 & z+& &  @& & & A6 6 & & & Azz% & &  & & & @ 3& & t@a& & &&& zz6 6 & @z6 6  z6 6 & Azl& & t@a& & &&& zz6 6 & & & @6 6 & & t@a& & &&& zzz6 6 & &  & Az6 6 & zzz6 6 & @zt@a% %_Ne "w w @& & &&& Dz6 6 & @z fEw w N 57H X XN X ~w w x wr  } w N  X X X X X X X X X X X ~:+ >+  :w w N 5 X XN X ~w w  X ~w w %_D+f  dJ+f  WN+f  JS+f  =Y+f  0^+f  #f+f  m+f   Ns+ $" " @w uw + & 7+ $" % 7 77 X ~ X X X X ~ w w % ~ p~/w w t 5  |'v ~/n %% + $" %   ~/+ $" -.7 (w w x Nf &%@-+ $" %wX w H  X@ X6 6 ffz6 6 & @z  % X& & & HC6 6 ffz6 6 & @z b  % XLF@:6 6 ffz6 6 & @z   % X& & & HC6 6 ff z6 6 & @z  % X w w DCed  x, . %e̋ww   % % %+ %-  w%9Wp Ce` %0 w J5 5  l% % %+ T%- F%0 %.[@5 O%9ff&  Bz&e Nvvz%92& & & & &  Bvvz6 6 &e zvvz %0 & & ff 420.w2& & ff7 7777  ӕ-ӕ0 C~ ӕ. ӕ0 ~ nC~7~ t7777 ӕ- <ӕ.L  ,C~ӕe ӕ- ӕ+ r e0e0S 0fw*w&w"w w  8fwwww w  }7 && !EU   "   8 ,3 &tEe0E!T3,3m c T3 ,3eȐ9 ȕ0 ,3ȕ1  c T3 ,30,3  ,3    w r &@r&@r(@rP r  vA `B A @ &&f  eB A @ eA @ e@ e B A @    w >~w0De&   % *$w7 7 ׯ-  w7  .twe,B J  ӕ-ׯd  z r f e0&   ԕ- \  vA W  ~e0fv  @ >0 ҋ D~8H,L, ӕ0 $f v Le0 9e  7we&  m  *$~  *$  *$~ wB7 l b ^0   JWp `e0f< ,2P ( " @f  p37 P,p3-f &1z r &1  7b ^ Z 7L 7 J fwrV,JA 7 fAW,f B@ 8 @&61fA   @ @e71@\, 1wRfwmb,w6wmfwb,ww f@wwh,wf@fA w,dw"^e"w"Tew"J@lw"BAlew5 &@t`e @& BFfww,w<f@w( f@ww,w7D F L& z6 6 ` X VT 6  L5 6 e]& z6 6 vEWtf6EUv   v6 z e e e  e x UUUh b &6xb7\fTWp3e @7FE@@@AAABAyAAAffAÀ@@AAAAA A`AAAAA?9A?f@ffCG@ syntax: ramtek filename [width]  cannot open %s  %d - need to increase MAXSIDES in ramtek.c  nsides = %d %d %d %d %dgray out of memory!CGf@ff Read %d Pixels need to increase MAX in polygon.c and fill.c!  *?U@[U?*@*?*@?;U@[Urgbcmyhcigreygrayillegal color space starting location not in color table color table size exceeded illegal number of color table entriescolor component out of range color component out of range rgb1 %f %f %f rgb2 %d %d %d redblackblackredbluegreencyanmagentayellowwhite %s is an illegal color  %d is an illegal color index /dev/rm Cannot open /dev/rm!  Ramtek write error %o Ramtek read error CGCG"dN#oH#x#f#e&#c4#s"l"u#rp3t5 %ewor table color table size exceeded illegal number of color table entriescolor component out of range color component out of range rgb1 %f %f %f rgb2 %d %d %d redblackblackredbluegreencyanmagentayellowwhite %s is an illegal color  %d is an illegal color index /dev/rm Cannot open /dev/rm!  Ramtek write error %o "0 & 6  w %%#  % @ `5 "5 Ne@&  @>#   (&Ne 5 %XQ#  #  ###  e J #"& #  e5 (& %_ _ -_tap- ta55 @te . s N~#   B-Ne Wt`1Ne Wt`1Ne Wt`1Ne & %ff& zDzffffz& & ff& pDz6 6 & @z dt` t` t`&t`&t`&# et`5%t`5% t`5 %3  _ _"D4= "Wp@Wtap4&Wp@Wtap6&Wp@Wtap 8& -N4&& z%_ @ H!ww .BD55 kWpfaeWpfaeWpa%WpaWpa Wpa1 Wpaq-WpauWpaq-WpauWpaq-WpauWpaq-Wpau u_ 5  _~ 5 5 WpfaAWpa^"WpfaeAWpa^,_|AWpafNWpaAAVp_|Wpaq-jAWpaq-aAWp fe&Wpa^Wpaf 8AWp &&%AWp @A p&AWp & AWp fe&AWpa^AWpaf AWp &&%AWp &AWp & _|AWpaq--e5e AWpafAWpaNAWpfaeWpaAVp_|fWpaN %AWpafWpaN vvzAWpafWpaN ffz6 6 Wpaf z AWp &AWpafWpaN nffz6 6 Wpaf LzAWp &&%AWp 1 &AWp & _ _ N &   _ Wp %&_ NWp f& Wp u&_ Wp u&Wp fe&AWp A& uAWp & & f&f&Wp f&f&z%  & & ff @AWp & & f&f& L5f  _ & & fff z%Wp u&u& @  5 R& & ff& @z  . &e 6 6 & Gz%f hffz 5` 5 %N ffffz u- CWp C&_Wp u&AWp fe&AWp ^,&Wp fe&AWp A& uAWp & & f&f&Wp f&f&z%& & ff tAWp & & f&f& 5f  & & fff 0z%Wp u&u& @  5 !& & ff& @z N ffffz u- N _ u-_ww DC` r w  & %& H w DC(;Wp D&5Wp C&/ /Wp &Wp &Wp fe&Wp ^,& 2Wp Be& Wp Be&  2*w2w "  N N  ( ww u u #f  5 8#f  +#f  #f  $f  $  %$  @@m%C$   _$   % _ @& & && t@& & &&& & & @ &$  R%C@& & && .@& & &&& & & @ $  @& & &&@&&z6 6 f zt@a%ee % N @  u u @555555 D@  x#Ne   %  @@m! :wt@a& & &&t@a&&zt@a% Ne Ne 2Ne 4w .D& & &&& pBz6 6 & @z & & &&& pBz6 6 & @z z& & & && pBz6 6 & @z N %D& & & && & &&& & &&$ . eNff$ e@tAWt@P@]wFw 6D5 & & & @6 6 &&z@t@a%e %Ne ww B& & jd^X & & RLF@ @5 Q& & .(" & & & A6 6 & & & Azz$& &  h5 & & & Az6 6 & z%& &  & & & Az%=& & & & & @ @*& & D>82 & & & A6 6 & & & Azz5 5 & &  ^5 5 O& & & & & @ :& & & Az6 6 & z+& &  @& & & A6 6 & & & Azz% & &  & & & @ 3& & t@a& & &&& zz6 6 & @z6 6  z6 6 & Azl& & t@a& & &&& zz6 6 & & & @6 6 & & t@a& & &&& zzz6 6 & &  & Az6 6 & zzz6 6 & @zt@a% %_Ne w w @& & &&& Dz6 6 & @z T Ew w N 57  N  :wv w f w`  } w <             :$ n$ J :w w N 5  N  :w w   :w w v %_$f  d$f  W$f  J$f  =%f  0%f  #%f  %f   N%   @w uw n ^% *! 7`f%  777  :     : w w % : zp(w w b 5  \'V ( x % %    (%  -7 wv w f Nf^ ^!%@-%  wF w 6 CB       2w w DCed  x% . tnhb%e̋ww   % % %+ %-  w%9Wp Ce` %0 w J5 5  l% % %+ T%- F%0 %.[@5 O%9ff&  Bz&e Nvvz%92& & & & &  Bvvz6 6 &e zvvz %0 & & ff     w2& & ff7 7777  ӕ-ӕ0 C~ ӕ. ӕ0 ~ nC~7h ^7777 ӕ- <ӕ.6  ,C~ӕe ӕ- ӕ+ r e0e0S 0fwww w w  8fwwww w  }7 && !EU   "   8 + &tEe0E!++m c + +eȐ9 ȕ0 +ȕ1  c + +0+  +    w r &@r&@r(@rP r  vA `B A @ &&f  eB A @ eA @ e@ e B A @    w >~wDe   % w7 7 ׯ-  w7  .twe%B J  ӕ-ׯd  z r f e0&   ԕ- \  vA W  ~e0fv  @ > ҋ D~8%% ӕ0 $f v Le0 9e    7 we&  m   ~    ~ wB7 V  L H 0   4 Wp `e0f&  , P   @f  ,7  %,  -  f j )d \ )  7L H D 76 7 4 fwb%JA 7 fAW,f B@ 8 @&61fA   @ @e71@% 1wRfwm%w6wmfw%ww f@w~wz&wf@fA w,Tw"Ne"w"Dew":@lw"2Alew% &@t`e @& BFfww&w<f@w( f@ww &w7.F L& z6 6 J X @ >  6  L5 6 e]& z6 6   vEWtf6EUv   v6 z e e e r e b UUUR L &6xR7LfDWp3e @76E@? syntax: gray filename [width]  cannot open %s  %d - need to increase MAXSIDES in gray.c  nsides = %d %d %d %d %dgraygrayN*?U@[U?*@*?*@?;U@[Urgbcmyhcigreygrayillegal color space starting location not in color table color table size exceeded illegal number of color table entriescolor component out of range color component out of range rgb1 %f %f %f rgb2 %d %d %d redblackblackredbluegreencyanmagentayellowwhite %s is an illegal color  %d is an illegal color index /dev/rm Cannot open /dev/rm!  Ramtek write error %o Ramtek read error .X6Ddox4fBecsPl^uPr,. %ewation not in color table color table size exceeded illegal number of color table entriescolor component out of range color component out of range rgb1 %f %f %f rgb2 %d %d %d redblackblackredbluegreencyanmagentayellowwhite %s is an illegal color  %d is an illegal color index /dev/rm Cannot open /dev/rm!  Ramtek write error %o Ramtek read error .X6Ddox4fBecsPl^uPr,87~66~[yb{4b{4[y4Gt;+2;+24Gto07K~~V[y[yV.\4Gt4Gt.\ oKT~~SVVS,d.\.\,d TP~~USSU-`,d,d-`P?YUUY2P-`-`2P ?%URR`NYY`N96K2P2P96KH %URRhf`N`NhfA96K96KAHMJJpEHhfhfpEHIEAAIE%BMyJJyw)pEHpEHw)PIEIEP,~%Beyye|w)w)|UPPU1t,~\ee\~ ||~ WUUW3k1t`\\`}~ ~ }VWWV2p3kp``py }}y RVVR.2phdppds:ay y s:aL]RRL](Y.hddkZs:as:akZD L]L]D  (Y866b{4kZkZb{4;+2D D ;+20 8:22hh:PZk22kPZe}{kk{e}#{{{#{ v vvsvsEp2}/'#{#{/' v v Rvsvs REp2}>I;*/'/';*$$E R RE>IC A6U;*;*A6U* $$* NEEN) C FDR=A6UA6UDR=-* * -0lNN0l;+) FI.D+ DR=DR=D+ +CP--+CPU0l0lU_m;+I.;+'i4>2D+ D+ 4>2SP +CP+CPSP eUUen%_m;+'i9g DZ4>24>2 DZTTSP SP TTb3Oeeb3Oi In%9gEbHa DZ DZHaK`TTTTK`M`b3Ob3OM`O_i IhM h|~|~n Ep9p9p Sq Sq_t|~|~_tGxnEp9p9pz2 Sq Sqz2Qy_t_tQy4Gx!!v z2z2v J nQyQyJ n*4) +!!+s%"v v s%"GsJ nJ nGs&x*) ;+=++=r8=s%"s%"r8=E*GsGsE*$m&x;+_m`c==`csZr8=r8=sZCNE*E*CN"<?Z$m_mn%m`c`cm{gsZsZ{gK\CNCNK\-Oi"<?Zn%i IgImmgIb6K{g{gb6KeZfNK\K\eZfNQRW-Oii IO_O_gIgIO_N_b6Kb6KN_L`eZfNeZfNL`J`QRWMh)@)@H %U%UH `o??`oqPh {B)@)@{B|f[H H |f[~,`o`o~,q ndM{B{BdMe}|f[|f[e}vz~,~,vz{nGx=G}dMdM=G}De}e}D]vzvz]%{Gx4*D}=G}=G}*D}3{DD3{P{]]P{}Uz%4*Mk*D}*D}Mk'E3{3{'EF3P{P{F3xr}Uz*&xa2MkMka2'E'E@JfF3F3@Jfvxr&x$ma2a288<j@Jf@Jf<juv$m"<?Z%% 8f88 8f?<j<j?tu"<?Z-Oi'>]%%'>]5&@| 8f 8f5&@|S ??S yt-OiQRWRHc'>]'>]RHc_7#k5&@|5&@|_7#ku%trS S u%trzyQRWJ`GaRHcRHcGaDb_7#k_7#kDbAcu%tru%trAc@czPqyTTyscKKsc]<77]<:8q"yy"9scsc9R]<]<RPZ:{{""{|99|RRe}PZ{%2{{2||  e}%}Uz^x22^x;w;wy  y2}}Uzxr~^x^x~X;w;wX& yy& >I2}xrv~~vXXv+%Q& & +%QC >Ivuvv.Hm+%Q+%Q.HmFC ut0y.Hm.Hm0yI.Fty  #s0y0y#s;+'iI.yz{{&rx  &rx0As#s#s0As9g;+'iz@c?c{{?c@c&rx&rx@cBc0As0AsBcEb9g`!0 & 6  w V%%!  % @ 5 5 Ne@&  @!    7r$ n$Eh$ $Ne 5 %X!  "  x!x!" e  l!`!&  " e5 $V#_ _ -_tap- ta55 @te  s N!   B-Ne Wt`1Ne Wt`1Ne Wt`1Ne & %ff& zDzffffz& & ff& pDz6 6 & @z t` t` t`&t`&t`&! et`5%t`5% t`5 %3  _ _>D4= "Wp@Wtap$Wp@Wtap$Wp@Wtap $ -N$& %_(@ ww v!wmp!%j! "  ww .BD55 kWpfaeWpfaeWpa%WpaWpa Wpa1 Wpaq-WpauWpaq-WpauWpaq-WpauWpaq-Wpau u_6 5  _ 5 5 WpfaAWpa^"WpfaeAWpa^,_AWpafNWpaAAVp_Wpaq-jAWpaq-aAWp feF%Wpa^Wpaf AWp H%J%%AWp @A pL%AWp N% AWp feF%AWpa^AWpaf AWp H%J%%AWp L%AWp N% _AWpaq--e5e AWpafAWpaNAWpfaeWpaAVp_fWpaN h%AWpafWpaN @vvzAWpafWpaN ffz6 6 Wpaf z AWp F%AWpafWpaN ffz6 6 Wpaf zAWp H%J%%AWp 1 L%AWp N% _ _2 N & F  _2 Wp %N%_2 NWp fF% , Wp uL%_ Wp uN%Wp feF%AWp AF% uAWp & & fJ%fH%Wp fJ%fH%z%& & ff AWp & & fJ%fH% 5f X _ & & fff Jz%Wp uH%uJ% ~@  ~5 R& & ff& @z  . &e 6 6 & Gz%f ffz 5` 5 %N ~ffffz u- CWp CN%_Wp uN%AWp feF%AWp ^,F%Wp feF%AWp AF% uAWp & & fJ%fH%Wp fJ%fH%z%& & ff AWp & & fJ%fH% 5f X & & fff z%Wp uH%uJ% ~@  ~5 !& & ff& @z PN ~ffffz u- v _ u-_w8w (DC` r w F & %& w DCr&;Wp DN%5Wp CN%/ /Wp L%Wp L%Wp feF%Wp ^,F% 2Wp BeF% Wp BeF%  2RwRw B ~ ~N ~N ~ P w&w CB ~  ~  ~   ww u u h"f N 5 8l"f N +p"f N t"f N y"f N ~"   %"  @@m%"   "   % _b@& & && @& & &&& & & @ @"  <%C@& & && H@& & &&& & & @ #  @& & &&@&&z6 6 f zt@a%ee % ~N ~@  ~u u @555555 D@  x "Ne V ~ %  @@m! wt@a& & &&t@a&&zt@a% Ne NNe Ne w D& & &&& pBz6 6 & @z & & &&& pBz6 6 & @z & & & && pBz6 6 & @z h %D& & & && & &&& & &&<#  eNffL# e@tAWt@P@]w0w D5 & & & @6 6 &&z@t@a%e %Ne Vww B& & jd^X & & RLF@ @5 Q& & .(" & & & A6 6 & & & Azz$& &  5 & & & Az6 6 & z%& &  0& & & Az%=& & & & & @ @*& & D>82 & & & A6 6 & & & Azz5 5 & &  x5 5 O& & & & & @ T& & & Az6 6 & z+& &  @& & & A6 6 & & & Azz% & &  & & & @ 3& & t@a& & &&& zz6 6 & @z6 6  z6 6 & Azl& & t@a& & &&& zz6 6 & & & @6 6 & & t@a& & &&& zzz6 6 & &  & Az6 6 & zzz6 6 & @zt@a% %_&Ne Vw w @& & &&& Dz6 6 & @z n Ew w \# P 7e#   # P 7`#   777 ~  ~ ~ ~ ~  w w % ~ xp&w w Z 5  ZT & %   &#  - 7 w w r Nfr n%wh w X N >57 ~ ~N ~ w0 w w  } w   ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ # #  :ww |N >5 ~ ~N ~ wVw F ~ w@w 0 %_:#f N d#f N W#f N J#f N =#f N 0#f N ##f N #f N  N#  @wD u7 7777  ӕ-ӕ0 C~ ӕ. ӕ0 ~ nC~7~ t7777 ӕ- <ӕ.L  ,C~ӕe ӕ- ӕ+ r e0e0S 0fw*w&w"w w  8fwwww w  }7 && !EU   "   8 $( &tEe0E!L($(m c L( $(eȐ9 ȕ0 $(ȕ1  c L( $(0$(  $(    w  r &@ r&@r(@rP r  vA `B A @ &&f  eB A @ eA @ e@ e B A @    w R~w0 De&   % "w27 7 ׯ - w 7  .tw e$B J  ӕ-ׯ d  z r f e0&   ԕ- \  vA W  ~e0fv  @ >0  ҋ D~8J$N$  ӕ0 $f v Le0 9e    7 we&  m   "~  "  "~ wB7 l  b ^ 0   J Wp `e0f<  ,2 P ( "  @f  h(7  R$h(  -  f@wF fwX$JA 7 R fAW,f B@ 8 @&61fA   @ @e7*1@^$ 1wfw wd$w~f@wwj$w\fwmp$w<wmfwp$ww f@wwv$wf@fA w,fw"`e"w"Vew"L@lw"DAlew7 &@t`e @& BFw B 5  ʥ ʥ ʥ- ʥ9 Wp @@`eʥ0  w70F7fWp3e @7vE L& z6 6  X    6  L5 6 e]& z6 6   vEWtf6EUv   v6x z e e e D e 4 UUU$  &6x*@@*@@@@? syntax: gray filename [width]  cannot open %s  %d - need to increase MAXSIDES in gray.c  nsides = %d %d %d %d %dhcihci out of memory!2>J*?U@[U?*@*?*@?;U@[Urgbcmyhcigreygrayillegal color space starting location not in color table color table size exceeded illegal number of color table entriescolor component out of range color component out of range rgb1 %f %f %f rgb2 %d %d %d /dev/drb Cannot open /dev/drb!  /dev/drc Cannot open /dev/drc!  %o redblackblackredbluegreencyanmagentayellowwhite %s is an illegal color  %d is an illegal color index dFo@xfec,slurh(l* %ewte starting location not in color table color table size exceeded illegal number of color table entriescolor component out of range color component out of range rgb1 %f %f %f rgb2 %d %d %d /dev/drb Cannot open /dev/drb!  /dev/drc Cannot open /dev/drc!  %o redblackblackredbluegreencyanmagentayellowwhite %s is an ill"_ram_kb"&_read_cu"fisitod"#_fill"z_on_ligh"_off_lig"2_foregrd" _draw"cret""fltused"ac0$(_in_buf"t_flush_b"_move_cu"`_FDKB$0(_open"!_printf"h_stty"<"_gtty"!_read""_scanbuf$2(_dummy$^)_ppt$h)fisdtoi"B#_sort"< _cop""fiststf"$_write_i"N_merge" _strcmp"Dfiscmpf"#_rgb_cvt"L_cmy_cvt"D_hci_cvt"_gray_cv"_FDB$*_FDC$*_BUFFER$ *_NWORDS$+_XNOW$+_YNOW$+_COLORNO$+_IWIDTH$+_table_i"n_nargs""_write"Z"_ram_rea"_color_n"4pfloat"pscien"_ecvt"d_fcvt"_putchar"n!_flush"!_fout$,cerror" #_errno$+fisdtol"#fisltod"P#fisnegf"F$y"<"_gtty"!_read""_scanbuf$2(_dummy$^)_ppt$h)fisdtoi"B#_sort"< _cop""fiststf"$_write_i"N_merge" _strcmp"Dfiscmpf"#_rgb_cvt"L_cmy_cvt"D_hci_cvt"_gray_cv"_FDB$*_FDC$*_BUFFER$ *_NWORDS$+_XNOW$+_YNOW$+_COLORNO$+_IWIread_font(font,index,nchars) struct {int ix,iy,pc;} font[]; struct {int st,np,wid;} index[]; int *nchars; { extern char fin; char filen[20],c; register char *f; register int i,jj; printf("font file name?"); for (f= &filen;(c=getchar())!='\n';f++) *f=c; *f= '\0'; fin=open(&filen,0); if (fin<0) {printf("open failure on %s",&filen); abort();} scanf("d",nchars); printf(" nchars=%d\n", *nchars); for (i=0;i<*nchars;i++) { scanf("d,d,d",&index[i].st,&index[i].np,&index[i].wid); printf("stnpwid %d,%d,%d\n",index[i].st,index[i].np,index[i].wid); } for (i=0;i<*nchars;i++) { for (jj=index[i].st;jjt,&var->u,&var->v); } ask(str) char str[]; { char yy,dum; do { printf("%s ",str); yy=getchar();} while (yy!='y' && yy!='n'); do { dum=getchar();} while (!(empty())); return (yy=='y'?1:0); } inwin(xl,xr,yb,yt) float *xl,*xr,*yb,*yt; { if (ask("restricted window? ")) { printf("input xl, xr, yb, yt "); scanf("%f,%f,%f,%f",xl,xr,yb,yt); *xl= (*xl>0.0 && *xl<14.0? *xl:0.0); *xr= (*xr>*xl && *xr<=14.0? *xr:14.0); *yb= (*yb>0.0 && *yb<10.24? *yb:0.0); *yt= (*yt>*yb && *yt<=10.24? *yt:10.24); window(*xl,*yb,*xr,*yt); } else { *xl= (*yb=0.0); *xr= 14.; *yt= 10.24; } } inbkg() { register char *bcol; char acol[20],c; if (ask("new background color?")) { bcol= &acol; printf("input background color name "); do { /* until some color entered */ for (bcol= &acol;(c=getchar())!='\n';bcol++) *bcol=c; *bcol='\0'; } while (bcol== &acol); backgrd(&acol); erase(); } window(0.0,0.0,14.0,10.24); } (*xl,*yb,*xr,*yt); } else { *xl= (*yb=0.0); *xr= 14.; *yt= 10.24; } } inbkg() { register char *bcol; char acol[20],c; if (ask("new background color?")) { bcol= &acol; printf("input background color name "); do { /* until some color entered */ for (bcol= &acol;(c=getchar())!='\n';bcol++) *bcol=c; *bcol='\0'; } while (bcol== &acol); backgrd(&acol); erase(); } window(0.0,0.0,14 37 0 13 8 13 23 8 36 19 8 55 14 8 69 13 8 82 11 8 93 24 9 117 13 8 130 13 6 143 16 10 159 12 8 171 7 7 178 13 10 191 11 9 202 18 8 220 15 8 235 21 9 256 18 8 274 19 8 293 9 8 302 13 8 315 7 10 322 11 12 333 13 8 346 10 8 356 11 8 367 16 6 383 7 4 390 17 8 407 26 8 433 15 8 448 16 8 464 25 8 489 8 7 497 30 8 527 25 8 552 3 8 0 3 3 3 13 2 5 13 2 8 3 2 6 3 2 5 6 2 3 6 2 2 3 2 0 3 2 3 8 3 4 10 2 5 8 2 3 8 2 0 3 3 0 13 2 6 13 2 8 11 2 8 9 2 7 8 2 8 7 2 8 5 2 6 3 2 0 3 2 2 5 3 2 7 2 5 7 2 6 6 2 5 5 2 2 5 2 2 9 3 2 11 2 5 11 2 6 10 2 5 9 2 2 9 2 2 5 3 0 5 3 0 11 2 2 13 2 6 13 2 8 11 2 8 10 2 6 10 2 5 11 2 3 11 2 2 10 2 2 6 2 3 5 2 5 5 2 6 6 2 8 6 2 8 5 2 6 3 2 2 3 2 0 5 2 0 3 3 0 13 2 6 13 2 8 11 2 8 5 2 6 3 2 0 3 2 2 5 3 2 11 2 5 11 2 6 10 2 6 6 2 5 5 2 2 5 2 0 3 3 0 13 2 8 13 2 8 11 2 2 11 2 2 9 2 5 9 2 5 7 2 2 7 2 2 5 2 8 5 2 8 3 2 0 3 2 0 3 3 0 13 2 8 13 2 8 11 2 2 11 2 2 9 2 5 9 2 5 7 2 2 7 2 2 3 2 0 3 2 0 5 3 0 11 2 2 13 2 6 13 2 8 11 2 8 10 2 6 10 2 5 11 2 3 11 2 2 10 2 2 6 2 3 5 2 5 5 2 6 5 2 6 6 2 5 6 2 5 7 2 9 7 2 9 6 2 8 6 2 8 4 2 7 3 2 2 3 2 0 5 2 0 3 3 0 13 2 2 13 2 2 9 2 6 9 2 6 13 2 8 13 2 8 3 2 6 3 2 6 7 2 2 7 2 2 3 2 0 3 2 0 3 3 0 5 2 2 5 2 2 11 2 0 11 2 0 13 2 6 13 2 6 11 2 4 11 2 4 5 2 6 5 2 6 3 2 0 3 2 0 5 3 0 6 2 2 6 2 3 5 2 5 5 2 6 6 2 6 11 2 4 11 2 4 13 2 10 13 2 10 11 2 8 11 2 8 5 2 6 3 2 2 3 2 0 5 2 0 3 3 0 13 2 2 13 2 2 10 2 5 13 2 8 13 2 3 8 2 8 3 2 5 3 2 2 6 2 2 3 2 0 3 2 0 3 3 0 13 2 2 13 2 2 5 2 7 5 2 7 3 2 0 3 2 0 3 3 0 13 2 2 13 2 5 10 2 8 13 2 10 13 2 10 3 2 8 3 2 8 10 2 5 7 2 2 10 2 2 3 2 0 3 2 0 3 3 0 13 2 2 13 2 7 6 2 7 13 2 9 13 2 9 3 2 7 3 2 2 10 2 2 3 2 0 3 2 0 5 3 0 11 2 2 13 2 6 13 2 8 11 2 8 5 2 6 3 2 2 3 2 0 5 2 2 6 3 2 10 2 3 11 2 5 11 2 6 10 2 6 6 2 5 5 2 3 5 2 2 6 2 0 3 3 0 13 2 6 13 2 8 11 2 8 9 2 6 7 2 2 7 2 2 3 2 0 3 2 2 9 3 2 11 2 5 11 2 6 10 2 5 9 2 2 9 2 0 5 3 0 11 2 2 13 2 6 13 2 8 11 2 8 5 2 7 4 2 9 2 2 8 1 2 6 3 2 2 3 2 0 5 2 2 6 3 2 10 2 3 11 2 5 11 2 6 10 2 6 6 2 5 5 2 3 5 2 2 6 2 0 3 3 0 13 2 6 13 2 8 11 2 8 9 2 6 7 2 8 3 2 6 3 2 4 7 2 2 7 2 2 3 2 0 3 2 2 9 3 2 11 2 5 11 2 6 10 2 5 9 2 2 9 2 0 3 3 0 5 2 5 5 2 6 6 2 5 7 2 2 7 2 0 9 2 0 11 2 2 13 2 8 13 2 8 11 2 3 11 2 2 10 2 3 9 2 6 9 2 8 7 2 8 5 2 6 3 2 0 3 2 0 11 3 0 13 2 8 13 2 8 11 2 5 11 2 5 3 2 3 3 2 3 11 2 0 11 2 0 5 3 0 13 2 2 13 2 2 6 2 3 5 2 5 5 2 6 6 2 6 13 2 8 13 2 8 5 2 6 3 2 2 3 2 0 5 2 0 13 3 3 13 2 5 8 2 7 13 2 10 13 2 5 3 2 0 13 2 0 13 3 2 13 2 4 9 2 6 13 2 8 9 2 10 13 2 12 13 2 8 3 2 6 7 2 4 3 2 0 13 2 0 3 3 3 8 2 0 13 2 2 13 2 4 10 2 6 13 2 8 13 2 5 8 2 8 3 2 6 3 2 4 6 2 2 3 2 0 3 2 0 13 3 2 13 2 4 10 2 6 13 2 8 13 2 5 8 2 5 3 2 3 3 2 3 8 2 0 13 2 0 3 3 0 5 2 6 11 2 0 11 2 0 13 2 8 13 2 8 11 2 2 5 2 8 5 2 8 3 2 0 3 2 0 5 3 0 11 2 2 13 2 4 13 2 6 11 2 6 5 2 4 3 2 2 3 2 0 5 2 2 6 3 2 10 2 3 11 2 4 10 2 4 6 2 3 5 2 2 6 2 2 3 3 2 11 2 0 11 2 2 13 2 4 13 2 4 3 2 2 3 2 0 3 3 0 5 2 6 9 2 6 10 2 5 11 2 3 11 2 2 10 2 0 10 2 0 11 2 2 13 2 6 13 2 8 11 2 8 8 2 3 5 2 8 5 2 8 3 2 0 3 2 0 5 3 0 6 2 2 6 2 3 5 2 5 5 2 6 6 2 5 7 2 3 7 2 3 9 2 5 9 2 6 10 2 5 11 2 3 11 2 2 10 2 0 10 2 0 11 2 2 13 2 6 13 2 8 11 2 8 9 2 7 8 2 8 7 2 8 5 2 6 3 2 2 3 2 0 5 2 0 7 3 0 13 2 2 13 2 2 9 2 5 9 2 5 13 2 7 13 2 7 9 2 8 9 2 8 7 2 7 7 2 7 3 2 5 3 2 5 7 2 0 7 2 0 3 3 0 5 2 5 5 2 6 6 2 5 7 2 0 7 2 0 13 2 8 13 2 8 11 2 2 11 2 2 9 2 6 9 2 8 7 2 8 5 2 6 3 2 0 3 2 0 5 3 0 11 2 2 13 2 6 13 2 8 11 2 8 10 2 6 10 2 5 11 2 3 11 2 2 10 2 2 8 2 3 9 2 6 9 2 8 7 2 8 5 2 6 3 2 2 3 2 0 5 2 2 6 3 3 7 2 5 7 2 6 6 2 5 5 2 3 5 2 2 6 2 0 11 3 0 13 2 7 13 2 7 11 2 2 3 2 0 3 2 5 11 2 0 11 2 0 5 3 0 7 2 1 8 2 0 9 2 0 11 2 2 13 2 6 13 2 8 11 2 8 9 2 7 8 2 8 7 2 8 5 2 5 3 2 2 3 2 0 5 2 2 6 3 3 7 2 5 7 2 6 6 2 5 5 2 3 5 2 2 6 2 2 10 3 3 11 2 5 11 2 6 10 2 5 9 2 3 9 2 2 10 2 2 6 3 0 6 3 2 6 2 3 5 2 5 5 2 6 6 2 6 8 2 5 7 2 2 7 2 0 9 2 0 11 2 2 13 2 6 13 2 8 11 2 8 5 2 5 3 2 2 3 2 0 5 2 0 6 2 2 10 3 3 11 2 5 11 2 6 10 2 5 9 2 3 9 2 2 10 2 0 3 3 8 3 3 0 3 3 5 2 5 3 2 2 3 2 0 5 2 2 6 3 3 7 2 5 7 2 6 6 2 5 5 2 3 5 2 2 6 2 2 10 3 3 11 2 5 11 2 6 10 2 5 9 2 3 9 2 cc -f ramfont.o rfsubs.o /lib/scanf.o /lib/ramlib.a /lib/ramlib.a mv a.out ramf beep 2 7 2 2 7 2 0 9 2 0 11 2 2 13 2 6 13 2 8 11 2 8 5 2 5 3 2 2 3 2 0 5 2 0 6 2 2 10 3 3 11 2 5 11 2 6 10 2 5 9 2 3 9 2 2 10 2 0 3 3 8 3 3 0 3 3 5 2 5 3 2 2 3 2 0 5 2 2 6 3 3 7 2 5 7 2 6 6 2 5 5 2 3 5 2 2 6 2 2 10 3 3 11 2 5 11 2 6 10 2 5 9 2 3 9 2 cc -n -c ramfont.c beep /lib/scanf.o /lib/ramlib.a /lib/ramlib.a mv a.out ramf beep 2 7 2 2 7 2 0 9 2 0 11 2 2 13 2 6 13 2 8 11 2 8 5 2 5 3 2 2 3 2 0 5 2 0 6 2 2 10 3 3 11 2 5 11 2 6 10 2 5 9 2 3 9 2 2 10 2 0 3 3 8 3 3 0 3 3 5 2 5 3 2 2 3 2 0 5 2 2 6 3 3 7 2 5 7 2 6 6 2 5 5 2 3 5 2 2 6 2 2 10 3 3 11 2 5 11 2 6 10 2 5 9 2 3 9 2 #include "ramtek.h" float nn[]{.25,.25,.25},k[]{0.,0.,0.},n[]{.75,.75,.75},w[]{1.,1.,1.}, r[]{0.,1.,1.},g[]{1.,0.,1.},b[]{0.,1.,1.}, m[]{1.,0.,1.},c[]{0.,1.,1.},l[]{1.,1.,0.}; main() { int i , npts , ix , iy , st; float x,y; struct {float x,y; int color;} p[10]; ram_setup(); backgrd("blue"); erase(); ram_move(0.,0.,"red",3); color_table("rgb",0,17,k,n); color_table("cmy",16,17,nn,r); color_table("cmy",32,17,r,g); color_table("cmy",48,17,g,b); color_table("cmy",64,17,b,r); color_table("cmy",80,17,r,nn); color_table("rgb",96,17,n,w); color_table("rgb",112,17,w,n); color_table("rgb",128,17,n,m); color_table("rgb",144,17,m,l); color_table("rgb",160,17,l,c); color_table("rgb",176,17,c,m); color_table("rgb",192,17,m,n); color_table("rgb",208,17,n,k); do { i=0; while (i==0) { i=ram_kb(); read_cursor(&ix,&iy,&st); } x= ix/XFACT; y= iy/YFACT; switch (i) { case 0220: if (npts>1) { if (npts==2) { p[npts].x=x; p[npts].y=y; p[npts++].color=(i-1)*16; } fill(npts,p); npts=0; } break; case 0227: on_light(1); while ((i<0200)||(i>0216)) i=ram_kb(); backgrd((i-0200)*16); off_light(1); erase(); break; case 0226: on_light(0); while ((i<0200)||(i>0215)) i=ram_kb(); foregrd((i-0200)*16); off_light(0); break; case 0222: npts=0; break; case 0223: draw(x,y); break; case 0224: ram_move(x,y); break; default: if ((i>=0200) && (i<0217)) { p[npts].x=x; p[npts].y=y; p[npts++].color=(i-0200)*16; } } } while( i!= 0233 ); } light(1); while ((i<0200)||(i>0216)) i=ram_kb(); backgrd((i-0200)*16); off_light(1); erase(); break; case 0226: on_light(0); while ((i<0200)||(i>0215)) i=ram_kb(); foregrd((i-0200)*16); off_light(0); break; case 0222: npts=0; break; case 0223: draw(x,y); break; case 0224: ram_move(x,y); break; default: if ((i>=0200) && (i<0217)) { p[npts].x=x; p[npt 3 0 4 8 4 4 8 8 5 8 0 3 3 0 13 2 6 12 2 0 3 2 0 3 3 6 12 2 6 6 2 0 3 2 0 3 3 0 13 2 6 13 2 6 3 2 0 3 2 ; backgrd((i-0200)*16); off_light(1); erase(); break; case 0226: on_light(0); while ((i<0200)||(i>0215)) i=ram_kb(); foregrd((i-0200)*16); off_light(0); break; case 0222: npts=0; break; case 0223: draw(x,y); break; case 0224: ram_move(x,y); break; default: if ((i>=0200) && (i<0217)) { p[npts].x=x; p[npt#include "ramtek.h" draw(x,y,newcolor,iwid) float x,y; { int n,ix,iy; extern int XNOW,YNOW,COLORNOW,IWIDTH; ix=x*XFACT; iy=511-y*YFACT; n=nargs(); if (n>8) { foregrd(newcolor); COLORNOW=newcolor; } if (n>9) IWIDTH=iwid; if (IWIDTH==3) { in_buf(07001); in_buf(36); in_buf(XNOW-1); in_buf(YNOW); in_buf(ix-1); in_buf(iy); in_buf(ix); in_buf(iy-1); in_buf(XNOW); in_buf(YNOW-1); in_buf(XNOW+1); in_buf(YNOW); in_buf(ix+1); in_buf(iy); in_buf(ix); in_buf(iy+1); in_buf(XNOW); in_buf(YNOW+1); in_buf(XNOW); in_buf(YNOW); flush_buf(0); } in_buf(07001); in_buf(4); in_buf(ix); in_buf(iy); flush_buf(); XNOW=ix; YNOW=iy; } newcolor); COLORNOW=newcolor; } if (n>9) IWIDTH=iwid; if (IWIDTH==3) { in_buf(07001); in_buf(36); in_buf(XNOW-1); in_buf(YNOW); in_buf(ix-1); in_buf(iy); in_buf(ix); in_buf(iy-1); in_buf(XNOW); in_buf(YNOW-1); in_buf(XNOW+1); in_buf(YNOW); in_buf(ix+1); in_buf(iy); in_buf(ix); in_buf(iy+1); #include "ramtek.h" line(x,y,np,inc,newcolor) float x[],y[]; { register int n,ix,iy; extern int COLORNOW,XNOW,YNOW; n=nargs(); if (n>4) { foregrd(newcolor); COLORNOW=newcolor; } in_buf(07003); in_buf(0100000); ix=x[0]*XFACT; iy=511-y[0]*YFACT; in_buf(ix); in_buf(iy); in_buf(4*np-4); for (n=inc;n 2 ) ram_move(ix , iy); in_buf(05401); in_buf(nw<<1); flush_buf(); ram_read(array , nw<<1); } ); COLORNOW=newcolor; } in_buf(07003); in_buf(0100000); ix=x[0]*XFACT; iy=511-y[0]*YFACT; in_buf(ix); in_buf(iy); in_buf(4*np-4); for (n=inc;n BUFSIZE-1 ) /* no more room */ flush_buf(DEBUG); /* send it and reset NWORDS to 0 */ BUFFER[NWORDS++] = word; } /* * send the entire buffer: * (eventually want to test whether it would be better to use FDRAM or FDRAM ) */ flush_buf(dump) int dump; /* 1 - print contents of buffer */ /* 0 (or no argument) - do not print contents of buffer */ { register int j; /* counter */ if( nargs() <= 0 ) dump=0; /* no args = no dump! */ if( NWORDS>0 ){ if( write(FDRAM,BUFFER,2*NWORDS)<0){ printf("Ramtek write error\7\n"); exit(1); } if( dump ) for(j=0; j0 ){ if( write(FDRAM,BUFFER,2*NWORDS)<0){ printf("Ramtek write error\7\n"); exit(1); } if( dump ) for(j=0; j 0){ /* wait */ if( (RMFLAGS[2]&WAITKB)==0 ){ RMFLAGS[2] =| WAITKB; stty( FDKB, RMFLAGS); } }else{ if( RMFLAGS[2]&WAITKB ){ RMFLAGS[2] =& ~WAITKB; stty( FDKB, RMFLAGS); } } read(FDKB , &input , 2); if( input&ND ) return(0); /* nothing hit */ return( input&0377 ); } kb() { int input; extern int FDKB; extern int RMFLAGS[3]; if( FDKB<=0 ) /* hasn't been opened yet */ if( (FDKB=open("/dev/rmkb",0)) < 0 ) { printf("Cannot open /dev/rmkb!\7"); exit(1); } if( nargs() > 0){ /* wait */ if( (RMFLAGS[2]&WAITKB)==0 ){ RMFLAGS[2] =| WAITKB; stty( FDKB, RMFLAGS); } }else{ if( RMFLAGS[2]&WAITKB ){ RMFLAGS[2] =& ~WAITKB; #include "ramtek.h" ram_move(x,y,newcolor,iwid) /*change current operating point and color */ float x,y; { int n; extern int COLORNOW,XNOW,YNOW,IWIDTH; XNOW=x*XFACT; YNOW=512-y*YFACT; n=nargs(); if (n>8) { foregrd(newcolor); COLORNOW=newcolor; } if (n>9) IWIDTH=iwid; in_buf(04002); /*set+operand flag */ in_buf(0100000); /* c o p change */ in_buf(XNOW); in_buf(YNOW); flush_buf(); } } }else{ if( RMFLAGS[2]&WAITKB ){ RMFLAGS[2] =& ~WAITKB; # #include "../ramtek.h" #define D2R 0.01745 char font[] { 022,024,004,000,040,044,024,022,022,024,014,003,001,010,030 , 041,043,034,024,022,022,024,000,040,024,022,022,024,020,022 , 002,042,022,022,004,040,022,044,000,022,022,024,002,020,042 , 024,022,022,002,024,042,022,024,020,022,022,004,044,022,000 , 022,040,022,022,044,004,070,040,000,022,022,004,022,044,022 , 020,022,022,044,033,013,004,013,011,000,011,031,040,031,033 , 022,022,004,040,022,044,000,022,024,020,022,002,042,022,022 , 004,044,000,040,022,022,024,020,022,040,003,043,000,024,040 , 002,042,024,020,024,020,011,031,020,020,024,033,013,024,000 , 040,070,002,042,070,004,044,002,042,033,031,042,003,013,014 , 004,003,070,000,044,070,040,041,031,030,040,002,044,006,070 , 001,041,000,024,040,001,041,070,003,043,070,034,010,011,031 , 070,022,024,023,033,013,020,010,001,003,014,024,033,031,020 , 013,024,020,010,030,014,034,032,012,010,030,014,034,012,032 , 030,010,014,012,042,032,034,030,034,014,012,032,030,010,027 , 024,070,022,012,011,012,022,015,017,070,027,025,010,026,070 , 036,020,070,002,042,070,044,004,002,011,031,042,043,004,005 , 016,036,045,070,020,027,026,016,015,025,026,070,047,000,070 , 021,031,032,022,021,040,015,016,027,036,035,002,001,010,020 , 042,027,024,020,011,016,027,020,031,036,027,021,025,023,003 , 043,023,001,045,023,005,041,021,025,023,003,043,031,021,022 , 032,031,020,003,043,031,021,022,032,031,000,047,037,017,006 , 001,010,030,041,046,037,070,022,030,010,020,027,016,005,006 , 017,037,046,044,002,000,040,006,017,037,046,045,034,014,034 , 043,041,030,010,001,007,003,043,033,030,037,002,001,010,030 , 041,043,034,004,007,047,001,003,014,034,043,041,030,010,001 , 006,017,037,046,006,007,047,046,020,001,003,014,005,006,017 , 037,046,045,034,014,034,043,041,030,010,001,046,044,033,013 , 004,006,017,037,046,041,030,010,001,025,024,034,035,025,070 , 031,021,022,032,031,025,024,034,035,025,070,031,021,022,032 , 031,020,042,004,046,004,044,070,001,041,002,044,006,006,006 , 017,037,046,045,034,024,023,070,022,012,011,021,022,031,021 , 012,013,024,034,031,041,045,036,016,005,001,010,040,000,003 , 043,003,006,017,037,046,040,000,007,037,046,045,034,004,034 , 043,041,030,000,041,030,010,001,006,017,037,046,000,007,037 , 046,041,030,000,047,007,004,034,004,000,040,047,007,004,034 , 004,000,023,043,041,030,010,001,006,017,037,046,045,007,000 , 004,044,040,047,030,010,020,027,017,037,002,001,010,030,041 , 047,007,000,003,025,047,070,025,040,040,000,007,000,007,023 , 047,040,000,007,040,047,025,047,037,017,006,001,010,030,041 , 046,037,000,007,037,046,045,034,004,037,017,006,001,010,030 , 041,046,037,070,022,040,000,000,007,037,046,045,034,004,024 , 040,002,001,010,030,041,043,034,014,005,006,017,037,046,020 , 027,007,047,007,002,001,010,030,041,047,007,006,020,046,047 , 007,000,024,040,047,000,047,070,007,040,007,023,020,023,047 , 007,047,000,040,070,014,044,040,000,007,047,007,040,007,047 , 040,000,006,027,046,000,040,000 }; int kct[] { 8,12, 6, 7, 7, 7, 8, 8, 7, 7,14,13, 6, 4, 6, 2, 2, 5, 5, 8, 5,14, 6, 3, 8, 8, 9, 5, 6, 6, 6, 6, 0, 8, 5,11,13,14,11, 2, 4, 4,11, 5, 6, 2, 5, 2, 11, 5, 9,13, 6,10,13, 5,17,13,11,12, 3, 5, 3,15, 15, 9,12, 8, 7, 7, 6,11, 6, 6, 6, 8, 3, 5, 4,11, 7,13, 9,13, 4, 7, 5, 5, 5, 5, 7, 4, 2, 4, 3, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; int koc[] { 0, 8, 20, 26, 33, 40, 47, 55, 63, 70, 77, 91,104,110,114,120, 122,124,129,134,142,147,161,167,170,178,186,195,200,206,212,218, 224,224,232,237,248,261,275,286,288,292,296,307,312,318,320,325, 327,338,343,352,365,371,381,394,399,416,429,440,452,455,460,463, 478,493,502,514,522,529,536,542,553,559,565,571,579,582,587,591, 602,609,622,631,644,648,655,660,665,670,675,682,686,688,692,695, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; symbol(x1,y1,h,str,theta) float x1,y1,h,theta; char *str; { float th , si , co , x , y , fact , xa , ya , xt , yt; float xx , yy , xn , yn; double sin() , cos() , fabs(); int nc , ic , ii , ict , loc , iy; int nchar , ixn , iyn; register int i , i1 , itsub; if( (nc=count_char(str)) == 0) return; nchar = nc; th = theta*D2R; /* radians */ si = sin(th); co = cos(th); x=x1; y=y1; if( nc>=1 ) goto L50; fact=h/4.0; x=x-2.0*fact*(co-si); y=y-2.0*fact*(co+si); nc=1; if( nchar >= -1 ) goto L60; ic=2; goto L70; L50: fact=h/7.0; L60: ic=3; L70: xa=fact*co; ya=fact*si; xt=xa*6.0; yt=ya*6.0; for(i1=0; i1>3) & 07; if( xx==7.0 ) { ic=3; continue; } yy = iy & 07; xn = x + xa*xx - ya*yy; yn = y + ya*xx + xa*yy; plot(xn,yn,ic); ic=2; } x=+ xt; y=+ yt; ic=3; } } /* * count the # of chars in a string: */ count_char(str) char *str; { register char *rcp; rcp = str; while(*rcp != 0) rcp++; return(rcp-str); } */ itsub=+ ('A'-'a'); if( (ict=kct[itsub]) == 0) break; loc = koc[itsub]; for(i=0;i>3) & 07; if( xx==7.0 ) { ic=3; continue; } yy = iy & 07; xn = x + xa*xx - ya*yy; yn = y + ya*xx + xa*yy; plot(xn,yn,ic); ic=2; } x=+ xt; y=+ yt; ic=3; } } /* * count the # of chars in a string: */ co#include "/user/ramtek/ramtek.h" #define DEBUG 0 #define BLACK 00000 #define RED 07400 #define BLUE 00017 #define GREEN 00360 #define CYAN 00377 #define MAGENTA 07417 #define YELLOW 07760 #define WHITE 07777 #define BLACK_INDEX 248 #define RED_INDEX 249 #define BLUE_INDEX 250 #define GREEN_INDEX 251 #define CYAN_INDEX 252 #define MAGENTA_INDEX 253 #define YELLOW_INDEX 254 #define WHITE_INDEX 255 /* * * ****** foregrd ****** * * purpose: sets the foreground color for suceeding commands. * * calling sequence: foregrd(color) * * where color can be a nnamed color or an index * to the color look up table. named colors * include: * "black" "blue" "red" "green" "cyan" * "magenta" "yellow" "white" * */ foregrd(color) char *color; /* color name if color > 255 */ /* color index if 0<= color <= 255 */ { int index; /* entry in color look up table*/ int strcmp();/* string cmparison function */ /* 0 - no match */ /* 1 - match */ extern int COLORNOW; /* current color index setting */ /* check for legal index or name and if name */ /* convert to an index */ index = color_name(color); COLORNOW = index; in_buf(SET | OF); /* form command word */ in_buf(FOREGROUND); /* set operand flag word */ in_buf(index); /* set foreground color index */ flush_buf(DEBUG); /* flush buffer */ } /* * * determine if two strings are equal * */ strcmp(s,t) char *s, *t; /* strings to be compared */ { int i; /* index used in comparison */ for (; *s == *t; s++, t++) if (*s == '\0' )return(1); return(0); } /* * ***** table_init() ***** * * * purpose: load named colors into the color look table starting at * location BLACK_INDEX and set initial * background color to black and * foreground to red. * * */ table_init() { int word; /* variable used to form instructions */ in_buf(LAM); /* send opcode */ in_buf(BLACK_INDEX); /* set starting address where named entries are to be stored */ in_buf(020); /* set number of entries to be loaded */ in_buf(BLACK); /* send entries to ramtek */ in_buf(RED); in_buf(BLUE); in_buf(GREEN); in_buf(CYAN); in_buf(MAGENTA); in_buf(YELLOW); in_buf(WHITE); flush_buf(DEBUG); foregrd("red"); backgrd("black"); erase(); } /* * * ****** backgrd ****** * * purpose: sets background color for suceeding commands. * * calling sequence: backgrd(color) * * where color can be a named color or an index * to the color look up table. named colors * include: * "black" "blue" "red" "green" "cyan" * "magenta" "yellow" "white" * */ backgrd(color) char *color; /* color name if color > 255 */ /* color index if 0<= color <= 255 */ { int index; /* color index */ int word; /* used for forming instructions for the ramtek */ /* check for legal index or name and convert to index */ index = color_name(color); in_buf(SET | OF); /* send command word */ in_buf(BACKGROUND); /* send operand flag word */ in_buf(index); /* send new background color index */ flush_buf(DEBUG); /* flush buffer */ } /* * * ****** erase() ****** * * purpose: writes the current background color into refresh memory. * * calling sequence: erase() * */ erase() { in_buf(ERASE); flush_buf(DEBUG); } /* * * This routine checks for legal color index or name and if * name, it is converted to an index. * */ color_name(color) char *color; { int index; if(color > 255) /* determine if specified by name or index */ { if (strcmp(color,"black"))index = BLACK_INDEX; else if (strcmp(color,"red"))index = RED_INDEX; else if (strcmp(color,"blue")) index = BLUE_INDEX; else if (strcmp(color,"green")) index = GREEN_INDEX; else if (strcmp(color,"cyan")) index = CYAN_INDEX; else if (strcmp(color,"magenta"))index = MAGENTA_INDEX; else if (strcmp(color,"yellow")) index = YELLOW_INDEX; else if(strcmp(color,"white"))index = WHITE_INDEX; else { printf(" %s is an illegal color \7",color); exit(); } } else if (color >= 0)index = color; else { printf(" %d is an illegal color index \7",color); exit(); } return(index); } TA_INDEX; else if (strcmp(color,"yellow")) index = YELLOW_INDEX; else if(strcmp(color,"white"))index = WHITE_INDEX; else { printf(" %s is an illegal color \7",color); exit(); } } else if (color >= 0)index = color; else # /* * routines to write to and read from the ramtek cursor: */ #include "ramtek.h" move_cursor(x,y) { int v[3]; extern int FDKB; if( FDKB <= 0 ) if( (FDKB=open("/dev/rmkb",2)) < 0 ) { printf("Cannot open /dev/rmkb!\7"); exit(1); } v[0] = x; v[1] = 511-y; v[2] = SETCUR; stty(FDKB , v); } /* * read ramtek cursor: if 4 args, wait for ENTER . */ read_cursor(xp , yp , sp) int *xp , *yp , *sp; { int v[3]; extern int FDKB; extern int RMFLAGS[3]; if( FDKB <= 0 ) if( (FDKB=open("/dev/rmkb",2)) < 0 ) { printf("Cannot open /dev/rmkb!\7"); exit(1); } if( nargs() > 3 ){ if( (RMFLAGS[2] & WAITEN) == 0){ RMFLAGS[2] =| WAITEN; stty( FDKB, RMFLAGS); } }else{ if( RMFLAGS[2] & WAITEN ){ RMFLAGS[2] =& ~WAITEN; stty( FDKB, RMFLAGS); } } gtty(FDKB , v); *xp = v[0] &0777; *yp = 511 - (v[1]& 0777); *sp = (v[1]>>9) & 0177; } read_cursor(xp , yp , sp) int *xp , *yp , *sp; { int v[3]; extern int FDKB; extern int RMFLAGS[3]; if( FDKB <= 0 ) if( (FDKB=open("/#include "/user/ramtek/ramtek.h" #define DEBUG 0 #define RGB 0 #define CMY 1 #define HCI 2 #define GRAY 3 #define GREY 3 /* so don't have to fart with correct spelling (if there is one) */ #define NUM_LEVELS 16 #define PI 3.14159 /* * * ****** color_table ******* * * purpose: loads color look-up table. * * calling sequence: color_table(color_space,start_loc,number,comp1,comp2) * * where: * color_space is one of the following * "rgb" - red,green,blue color space * "cmy" - cyan,magenta,yellow color space * "hci" - hue,saturation,lightness color space "gray" or "grey" - gray scale (last 2 components of comp1,comp2 ignored) * * start_loc is the entry in the color table to be * loaded first. (0 TABLE_SIZE) { printf("starting location not in color table \7"); exit(); } if(start_loc + number > TABLE_SIZE) { printf("color table size exceeded \7"); exit(); } if (number <= 0) { printf("illegal number of color table entries\7"); exit(); } for (i=0;i <=2; i++) { if( space==GRAY && i>0 ) break; /* only test first */ if(*pt1 < 0.0 || *pt1 > 1.0 ) { printf("color component out of range \7"); exit(); } if(number > 1) { if(*pt2 < 0.0 || *pt2 > 1.0) { printf("color component out of range \7"); exit(); } delta[i] = ( *pt2 - *pt1 )/(number - 1); /* compute change per entry */ } pt1++; pt2++; } in_buf(LAM); /* send instruction, starting location and number to device */ in_buf(start_loc); in_buf(2*number); pt1 = comp1; pt2 = comp2; comp[0] = *pt1; comp[1] = *(pt1 + 1); comp[2] = *(pt1 + 2); for(i=start_loc;i<(start_loc+number);i++) { switch(space) { case RGB: in_buf(rgb_cvt(comp)); break; case CMY: in_buf(cmy_cvt(comp)); break; case HCI: in_buf(hci_cvt(comp)); break; case GRAY: in_buf( gray_cvt(comp) ); break; } for(j=0;j<=2;j++)comp[j] = comp[j] + delta[j]; } flush_buf(DEBUG); } /* * * convert red blue green values 0-1 into values between * 1-16 and form data word * */ rgb_cvt(comp) float *comp; { int red,blue,green; register float *pt; /* pointer to incoming color vector */ pt = comp; /* pt is now an array base */ red = *pt * (NUM_LEVELS - 1) + 0.5; green = *(pt + 1) * (NUM_LEVELS - 1) + 0.5; blue = *(pt + 2) * (NUM_LEVELS - 1) + 0.5; return( 0 | blue | (green<<4) | (red<<8)); } /* * * transform cyan magenta yellow into red blue green * */ cmy_cvt(comp) float *comp; { int i; /* counter */ float newcomp[3]; /* transformed color vector */ register float *p; /* incoming color vector base */ p = comp; /* set pointer to first element */ for(i = 0;i <= 2;i++) { newcomp[i] = 1. - *p; p++; } return(rgb_cvt(newcomp)); } /* * * transform hue chroma intensity into red blue green * */ hci_cvt(comp) float *comp; { float newcomp[3]; /* transformed hci */ register int i,j; /* counters */ register float *ptr; /* color vector pointer */ float ang; /* temporary variable */ float cos(); /* determine rgb corresponding to hue */ ptr = comp; if(*ptr < 0.1666667 || *ptr > 0.833333)newcomp[0] = 1.0; else if(*ptr < 0.333333) newcomp[0] = 2.0 -6.0 * *ptr; else if( *ptr < 0.666667) newcomp[0] = 0.0; else newcomp[0] = 6.0 * *ptr - 4.; if(*ptr < 0.166667) newcomp[1] = 6.0 * *ptr; else if(*ptr < 0.5) newcomp[1] = 1.0; else if(*ptr < 0.666667) newcomp[1] = 4.0 - 6.0 **ptr; else newcomp[1] = 0.0; if(*ptr < 0.33333) newcomp[2] = 0.0; else if(*ptr < 0.5) newcomp[2] = 6.0 * *ptr - 2.0; else if(*ptr < 0.833333) newcomp[2] = 1.0; else newcomp[2] = 6.0 - 6.0 * *ptr; /* adjust new components to smooth discontinuities */ for(i = 0; i <= 2; i++) { ang = (1.0 - newcomp[i]) * PI; newcomp[i] = (1.0 + cos(ang))/2.0; } /* adjust new components for chroma and intensity */ for (i = 0; i <= 2;i++) { if (*(ptr + 2) < 0.5 ) { newcomp[i] = (0.5 + *(ptr + 1) * ( newcomp[i] - 0.5)) * 2.0 * *(ptr + 2); } else { newcomp[i] = 0.5 + *(ptr + 1) * (newcomp[i] - 0.5) + (0.5 - *(ptr + 1) * ( newcomp[i] - 0.5)) * (-1.0 + 2.0 * *(ptr + 2)); } } return(rgb_cvt(newcomp)); } /* * grey scale: */ gray_cvt(comp) float *comp; { register int j; j = 255.*(*comp) + 0.5; /* simply convert to an integer */ j=& 0377; /* be sure is in the range 0-255 */ return(j); } i = 0; i <= 2;i++) { if (*(ptr + 2) < 0.5 ) { newcomp[i] = (0.5 + *(ptr + 1) * ( newcomp[i] - 0.5)) * 2.0 * *(ptr + 2); } else { newcomp[i] = 0.5 + *(ptr + 1) * (newcomp[i] - 0.5) + # #include "ramtek.h" #define WI 05000 /* write-image */ /* * perform a scan-line color fill of a polygon: * * calling sequence: * fill(n,p) * int n; * struct { * float x , y; * int color; * } p[]; * * * last point will be joined with the first point. * */ #define MAX 30 /* max expected edges */ struct { /* structure containing one scan-line of info */ int scanx; /* x position */ float color; int flag; /* 0=normal , >0=first of horizontal pair , <0=second of horizontal pair */ int next; /* array index of next point to the right (-1=end-of-list) */ } scanbuf[MAX] , dummy; struct vert { int x , y; int col; } ppt[MAX]; fill(nn , p) int nn; char *p; { struct { float fx , fy; int kolor; } *pts; register struct vert *pt; register int j , n; int maxy , miny , y , ib , jp1 , jp2; int i , k , l , jj , maxcol , mincol , n_pixels; float ratio , delta , dcolor , color; pt = &ppt[0]; n = nn; pts = p; /* * scan the data for maxy and miny and convert the LL user system to the UL ramtek system: */ maxy = maxcol = -1; miny=513; mincol = 2048; for(j=0;j 511 ) pt[j].y = 511; if( pt[j].y < 0 ) pt[j].y = 0; if( pt[j].y > maxy ) maxy = pt[j].y; if( pt[j].y < miny ) miny = pt[j].y; if( pt[j].col > maxcol ) maxcol = pt[j].col; if( pt[j].col < mincol ) mincol = pt[j].col; } /* * start the scan lines from the top to the bottom and from left to right: */ for(y=miny; y<=maxy; y++) { ib=0; /* scanbuf counter */ for(j=0;j 0 ) continue; /* scan line does not cross this vector */ if( pt[j].y==y && pt[jp1].y==y ) { /* horizontal! */ scanbuf[ib].scanx = pt[j].x; scanbuf[ib].color = pt[j].col; scanbuf[ib].flag = ib+1; scanbuf[ib].next = -1; scanbuf[++ib].scanx = pt[jp1].x; scanbuf[ib].color = pt[jp1].col; scanbuf[ib].flag = -1; scanbuf[ib].next = -1; ib++; continue; } if( pt[jp1].y==y ) { /* check for a singularity at pt[jp1] */ jp2 = j+2; if( j>=n-2 ) jp2=- n; if( (pt[j].y-pt[jp1].y) * (pt[jp2].y-pt[jp1].y) <= 0 ) continue; } /* otherwise, determine the intersection of the line (pt[j]-pt[jp1]) and the scan */ ratio = y - pt[j].y; ratio=/ (pt[jp1].y - pt[j].y); scanbuf[ib].scanx = pt[j].x + (pt[jp1].x-pt[j].x)*ratio; scanbuf[ib].color = pt[j].col + (pt[jp1].col-pt[j].col)*ratio; scanbuf[ib].flag = 0; scanbuf[ib++].next = -1; } /* j */ /* * now sort the scan line intersections: */ if( ib==0 ) continue; /* insurance */ j = sort( 0 , ib-1 ); /* j is the index of the first pt */ for(; j>=0; j=scanbuf[j].next) { if( scanbuf[j].next== -1 ) break; /* something out-of-wack! */ cop( scanbuf[j].scanx , y); /* start span */ if( (i=scanbuf[j].flag) == 0) { /* normal */ i = scanbuf[j].next; n_pixels = scanbuf[i].scanx - scanbuf[j].scanx + 1; delta = scanbuf[i].color - scanbuf[j].color; if( delta==0.0 ) { write_image(n_pixels , (jj=scanbuf[i].color) ); } else { dcolor = delta / n_pixels; color = scanbuf[j].color; in_buf(WI|DF); /* write image + data flag */ in_buf(n_pixels<<1); /* # bytes */ for(k=0; k=u ) return(l); /* same pt! */ return( merge( sort(l,mid) , sort(mid+1,u) ) ); } merge(ii,jj) { register int i , j; register char *last; i=ii; j=jj; last = &dummy; while( i>=0 && j>=0 ) { if( scanbuf[i].flag < 0 ) { /* ignore this pt */ i = scanbuf[i].next; continue; } if( scanbuf[j].flag<0 ) { j = scanbuf[j].next; continue; } if( scanbuf[i].scanx <= scanbuf[j].scanx ) { last->next = i; last = &scanbuf[i]; i = last->next; } else { last->next = j; last = &scanbuf[j]; j = last->next; } } /* * fill out remaining list: */ if( i >= 0 ) last->next = i; else last->next = j; return( dummy.next ); } cop(x,y) { in_buf(04000|OF); in_buf(START_POINT); in_buf(x); in_buf(y); flush_buf(); } i = scanbuf[i].next; continue; } if( scanbuf[j].flag<0 ) { j = scanbuf[j].next; continue; } if( scanbuf[i].scanx <= scanbuf[j].scanx ) { last->next = i; last = &scanbuf[i]; i = last->next; } else { last->next = j; last = &scanbuf[j];# #define MAX 30 /* assumed max # of points */ #include "ramtek.h" /* * fill a polygon: * * * polygon(x1,y1,color1 , x2,y2,color2 , ...); * (where xi,yi are floats and colori is an integer) * * * last point will be joined to the first point. */ polygon( arg1 ) { register int n; register struct { double xd , yd; int col; } *parg; struct vert { float x , y; int color; } p[MAX]; register struct vert *pt; int j; if( (n=nargs()) <= 8 ) return; n=/ 9; if( n > MAX ) { printf("\n need to increase MAX in polygon.c and fill.c!\7\n"); exit(1); } parg = &arg1; pt = &p[0]; for(j=0;jx = parg->xd; pt->y = parg->yd; pt->color = parg->col; pt++; parg++; } fill(n , &p[0]); } joined to the first point. */ polygon( arg1 ) { register int n; register struct { double xd , yd; int col; } *parg; struct vert { float x , y; int color; } p[MAX]; register struct vert *pt; int j; if( (n=nargs()) <= 8 ) return; n=/ 9; if( n > MAX ) { print# #include "../ramtek.h" #define SET 04000 window(xl,yb,xr,yt) float xl , yb , xr , yt; { register int x , y; in_buf(SET|OF); /* operand */ in_buf(WINDOW); x = XFACT*xl + 0.5; x=& 0777; /* limit to 0-511 */ in_buf(x); y = YFACT*yt + 0.5; y=& 0777; in_buf(511-y); x = XFACT*xr + 0.5; x=& 0777; in_buf(x); y = YFACT*yb + 0.5; y=& 0777; in_buf(511-y); flush_buf(); } nt color; } p[MAX]; register struct vert *pt; int j; if( (n=nargs()) <= 8 ) return; n=/ 9; if( n > MAX ) { print#include "ramtek.h" #define COLOR 1 /* use color #0 */ write_image(nn , col) { register int j , n , color; n=nn; color = col; in_buf(05000|DF); in_buf( n<<1 ); /* # bytes */ for(j=0;j MAX ) { print#include "ramtek.h" /* * turn one of the console lights on or off: * * (tricky! they are labelled from R-L but accessed L-R) * */ on_light(i) int i; /* i corresponds to number printed on the console */ { register int ri; ri=i; ri=& 07; /* range = 0-7 */ ri = 7 - ri; /* now i corresponds to LEFT-RIGHT order */ in_buf(014000); in_buf(0300|ri); flush_buf(); } off_light(i) int i; { register int ri; ri=i; ri=& 07; ri = 7 - ri; in_buf(014000); in_buf(0200|ri); flush_buf(); } print#include "ramtek.h" text(string,txtmod,x,y) char string[]; int txtmod; float x,y; { extern int XNOW,YNOW; int WT,i,j,n,ix,iy,buf[30]; char *c,*k; WT= 06013; /* WT|RP|OF|DF */ k= &buf[0]; k--; /* change to caps */ for (c= &string[0]; (*(++k) = *c) != '\0';c++) if ((*k>='a') && (*k<='z')) *k=+ 'A'-'a'; i= c- &string[0]; if ((n=nargs())>1) { /* AP or BK flags */ if ((txtmod>0) && (txtmod<4)) WT=| (txtmod<<4); } /* change style of output */ if (n>4) { ix= XFACT*x; iy= 502-YFACT*y; YNOW= iy+9; } else { ix= XNOW; iy= YNOW-9; } XNOW= ix+7*i; in_buf(WT); in_buf(START_POINT); in_buf(ix); in_buf(iy); n= (i+1)/2; in_buf(i); for (j=0;j1) { /* AP or BK flags */ if ((txtmod>0) && (txtmod<4)) WT=| (txtmod<<4); } /* change style of output */ if (n>4) { ix= XFACT*x; iy= 502-YFACT*y; YNOW= iecho $1 cp $1 ./c/$1 XNOW; iy= YNOW-9; } XNOW= ix+7*i; in_buf(WT); in_buf(START_POINT); in_buf(ix); in_buf(iy); n= (i+1)/2; in_buf(i); for (j=0;j1) { /* AP or BK flags */ if ((txtmod>0) && (txtmod<4)) WT=| (txtmod<<4); } /* change style of output */ if (n>4) { ix= XFACT*x; iy= 502-YFACT*y; YNOW= i#include "ramtek.h" draw(x,y,newcolor,iwid) float x,y; { int n,ix,iy; extern int XNOW,YNOW,COLORNOW,IWIDTH; ix=x*XFACT; iy=511-y*YFACT; n=nargs(); if (n>8) { foregrd(newcolor); COLORNOW=newcolor; } if (n>9) IWIDTH=iwid; if (IWIDTH==3) { in_buf(07001); in_buf(36); in_buf(XNOW-1); in_buf(YNOW); in_buf(ix-1); in_buf(iy); in_buf(ix); in_buf(iy-1); in_buf(XNOW); in_buf(YNOW-1); in_buf(XNOW+1); in_buf(YNOW); in_buf(ix+1); in_buf(iy); in_buf(ix); in_buf(iy+1); in_buf(XNOW); in_buf(YNOW+1); in_buf(XNOW); in_buf(YNOW); flush_buf(0); } in_buf(07001); in_buf(4); in_buf(ix); in_buf(iy); flush_buf(); XNOW=ix; YNOW=iy; } newcolor); COLORNOW=newcolor; } if (n>9) IWIDTH=iwid; if (IWIDTH==3) { in_buf(07001); in_buf(36); in_buf(XNOW-1); in_buf(YNOW); in_buf(ix-1); in_buf(iy); in_buf(ix); in_buf(iy-1); in_buf(XNOW); in_buf(YNOW-1); in_buf(XNOW+1); in_buf(YNOW); in_buf(ix+1); in_buf(iy); in_buf(ix); in_buf(iy+1); #include "/user/ramtek/ramtek.h" #define DEBUG 0 #define RGB 0 #define CMY 1 #define HCI 2 #define GRAY 3 #define GREY 3 /* so don't have to fart with correct spelling (if there is one) */ #define NUM_LEVELS 16 #define PI 3.14159 /* * * ****** color_table ******* * * purpose: loads color look-up table. * * calling sequence: color_table(color_space,start_loc,number,comp1,comp2) * * where: * color_space is one of the following * "rgb" - red,green,blue color space * "cmy" - cyan,magenta,yellow color space * "hci" - hue,saturation,lightness color space "gray" or "grey" - gray scale (last 2 components of comp1,comp2 ignored) * * start_loc is the entry in the color table to be * loaded first. (0 TABLE_SIZE) { printf("starting location not in color table \7"); exit(); } if(start_loc + number > TABLE_SIZE) { printf("color table size exceeded \7"); exit(); } if (number <= 0) { printf("illegal number of color table entries\7"); exit(); } for (i=0;i <=2; i++) { if( space==GRAY && i>0 ) break; /* only test first */ if(*pt1 < 0.0 || *pt1 > 1.0 ) { printf("color component out of range \7"); exit(); } if(number > 1) { if(*pt2 < 0.0 || *pt2 > 1.0) { printf("color component out of range \7"); exit(); } delta[i] = ( *pt2 - *pt1 )/(number - 1); /* compute change per entry */ } pt1++; pt2++; } in_buf(LAM); /* send instruction, starting location and number to device */ in_buf(start_loc); in_buf(2*number); pt1 = comp1; pt2 = comp2; comp[0] = *pt1; comp[1] = *(pt1 + 1); comp[2] = *(pt1 + 2); for(i=start_loc;i<(start_loc+number);i++) { switch(space) { case RGB: in_buf(rgb_cvt(comp)); break; case CMY: in_buf(cmy_cvt(comp)); break; case HCI: in_buf(hci_cvt(comp)); break; case GRAY: in_buf( gray_cvt(comp) ); break; } for(j=0;j<=2;j++)comp[j] = comp[j] + delta[j]; } flush_buf(DEBUG); } /* * * convert red blue green values 0-1 into values between * 1-16 and form data word * */ rgb_cvt(comp) float *comp; { int red,blue,green; register float *pt; /* pointer to incoming color vector */ pt = comp; /* pt is now an array base */ red = *pt * (NUM_LEVELS - 1) + 0.5; green = *(pt + 1) * (NUM_LEVELS - 1) + 0.5; blue = *(pt + 2) * (NUM_LEVELS - 1) + 0.5; printf("%d %d %d \n",red,green,blue); if(DEBUG) { pt = comp; printf("rgb1 %f %f %f \n",*pt,*(pt+1),*(pt+2)); printf("rgb2 %d %d %d\n",red,green,blue); } return( 0 | blue | (green<<4) | (red<<8)); } /* * * transform cyan magenta yellow into red blue green * */ cmy_cvt(comp) float *comp; { int i; /* counter */ float newcomp[3]; /* transformed color vector */ register float *p; /* incoming color vector base */ p = comp; /* set pointer to first element */ for(i = 0;i <= 2;i++) { newcomp[i] = 1. - *p; p++; } return(rgb_cvt(newcomp)); } /* * * transform hue chroma intensity into red blue green * */ hci_cvt(comp) float *comp; { float newcomp[3]; /* transformed hci */ register int i,j; /* counters */ register float *ptr; /* color vector pointer */ float ang; /* temporary variable */ double cos(); /* determine rgb corresponding to hue */ ptr = comp; if(*ptr < 0.1666667 || *ptr > 0.833333)newcomp[0] = 1.0; else if(*ptr < 0.333333) newcomp[0] = 2.0 -6.0 * *ptr; else if( *ptr < 0.666667) newcomp[0] = 0.0; else newcomp[0] = 6.0 * *ptr - 4.; if(*ptr < 0.166667) newcomp[1] = 6.0 * *ptr; else if(*ptr < 0.5) newcomp[1] = 1.0; else if(*ptr < 0.666667) newcomp[1] = 4.0 - 6.0 **ptr; else newcomp[1] = 0.0; if(*ptr < 0.33333) newcomp[2] = 0.0; else if(*ptr < 0.5) newcomp[2] = 6.0 * *ptr - 2.0; else if(*ptr < 0.833333) newcomp[2] = 1.0; else newcomp[2] = 6.0 - 6.0 * *ptr; /* adjust new components to smooth discontinuities */ /* for(i = 0; i <= 2; i++) { ang = (1.0 - newcomp[i]) * PI; newcomp[i] = (1.0 + cos(ang))/2.0; } */ /* adjust new components for chroma and intensity */ for (i = 0; i <= 2;i++) { if(*(ptr + 2) < 0.5 ) newcomp[i] = (0.5 + *(ptr + 1) * ( newcomp[i] - 0.5)) * 2.0 * *(ptr + 2); else newcomp[i] = 0.5 + *(ptr + 1) * (newcomp[i] - 0.5) + (0.5 - *(ptr + 1) * ( newcomp[i] - 0.5)) * (-1.0 + 2.0 * *(ptr + 2)); } return(rgb_cvt(newcomp)); } /* * grey scale: */ gray_cvt(comp) float *comp; { register int j; j = 255.*(*comp) + 0.5; /* simply convert to an integer */ j=& 0377; /* be sure is in the range 0-255 */ return(j); } <# #include "ramtek.h" #define WI 05000 /* write-image */ /* * perform a scan-line color fill of a polygon: * * calling sequence: * fill(n,p) * int n; * struct { * float x , y; * int color; * } p[]; * * * last point will be joined with the first point. * */ #define MAX 30 /* max expected edges */ struct { /* structure containing one scan-line of info */ int scanx; /* x position */ float color; int flag; /* 0=normal , >0=first of horizontal pair , <0=second of horizontal pair */ int next; /* array index of next point to the right (-1=end-of-list) */ } scanbuf[MAX] , dummy; struct vert { int x , y; int col; } ppt[MAX]; fill(nn , p) int nn; char *p; { struct { float fx , fy; int kolor; } *pts; register struct vert *pt; register int j , n; int maxy , miny , y , ib , jp1 , jp2; int i , k , l , jj , maxcol , mincol , n_pixels; float ratio , delta , dcolor , color; pt = &ppt[0]; n = nn; pts = p; /* * scan the data for maxy and miny and convert the LL user system to the UL ramtek system: */ maxy = maxcol = -1; miny=513; mincol = 2048; for(j=0;j 511 ) pt[j].y = 511; if( pt[j].y < 0 ) pt[j].y = 0; if( pt[j].y > maxy ) maxy = pt[j].y; if( pt[j].y < miny ) miny = pt[j].y; if( pt[j].col > maxcol ) maxcol = pt[j].col; if( pt[j].col < mincol ) mincol = pt[j].col; } /* * start the scan lines from the top to the bottom and from left to right: */ for(y=miny; y<=maxy; y++) { ib=0; /* scanbuf counter */ for(j=0;j 0 ) continue; /* scan line does not cross this vector */ if( pt[j].y==y && pt[jp1].y==y ) { /* horizontal! */ scanbuf[ib].scanx = pt[j].x; scanbuf[ib].color = pt[j].col; scanbuf[ib].flag = ib+1; scanbuf[ib].next = -1; scanbuf[++ib].scanx = pt[jp1].x; scanbuf[ib].color = pt[jp1].col; scanbuf[ib].flag = -1; scanbuf[ib].next = -1; ib++; continue; } if( pt[jp1].y==y ) { /* check for a singularity at pt[jp1] */ jp2 = j+2; if( j>=n-2 ) jp2=- n; if( (pt[j].y-pt[jp1].y) * (pt[jp2].y-pt[jp1].y) <= 0 ) continue; } /* otherwise, determine the intersection of the line (pt[j]-pt[jp1]) and the scan */ ratio = y - pt[j].y; ratio=/ (pt[jp1].y - pt[j].y); scanbuf[ib].scanx = pt[j].x + (pt[jp1].x-pt[j].x)*ratio; scanbuf[ib].color = pt[j].col + (pt[jp1].col-pt[j].col)*ratio; scanbuf[ib].flag = 0; scanbuf[ib++].next = -1; } /* j */ /* * now sort the scan line intersections: */ if( ib==0 ) continue; /* insurance */ j = sort( 0 , ib-1 ); /* j is the index of the first pt */ for(; j>=0; j=scanbuf[j].next) { if( scanbuf[j].next== -1 ) break; /* something out-of-wack! */ cop( scanbuf[j].scanx , y); /* start span */ if( (i=scanbuf[j].flag) == 0) { /* normal */ i = scanbuf[j].next; n_pixels = scanbuf[i].scanx - scanbuf[j].scanx + 1; delta = scanbuf[i].color - scanbuf[j].color; if( delta==0.0 ) { write_image(n_pixels , (jj=scanbuf[i].color) ); } else { dcolor = delta / n_pixels; color = scanbuf[j].color; in_buf(WI|DF); /* write image + data flag */ in_buf(n_pixels<<1); /* # bytes */ for(k=0; k=u ) return(l); /* same pt! */ return( merge( sort(l,mid) , sort(mid+1,u) ) ); } merge(ii,jj) { register int i , j; register char *last; i=ii; j=jj; last = &dummy; while( i>=0 && j>=0 ) { if( scanbuf[i].flag < 0 ) { /* ignore this pt */ i = scanbuf[i].next; continue; } if( scanbuf[j].flag<0 ) { j = scanbuf[j].next; continue; } if( scanbuf[i].scanx <= scanbuf[j].scanx ) { last->next = i; last = &scanbuf[i]; i = last->next; } else { last->next = j; last = &scanbuf[j]; j = last->next; } } /* * fill out remaining list: */ if( i >= 0 ) last->next = i; else last->next = j; return( dummy.next ); } cop(x,y) { in_buf(04000|OF); in_buf(START_POINT); in_buf(x); in_buf(y); flush_buf(); } i = scanbuf[i].next; continue; } if( scanbuf[j].flag<0 ) { j = scanbuf[j].next; continue; } if( scanbuf[i].scanx <= scanbuf[j].scanx ) { last->next = i; last = &scanbuf[i]; i = last->next; } else { last->next = j; last = &scanbuf[j];#include "ramtek.h" /* * turn one of the console lights on or off: * * (tricky! they are labelled from R-L but accessed L-R) * */ on_light(i) int i; /* i corresponds to number printed on the console */ { register int ri; ri=i; ri=& 07; /* range = 0-7 */ ri = 7 - ri; /* now i corresponds to LEFT-RIGHT order */ in_buf(014000); in_buf(0300|ri); flush_buf(); } off_light(i) int i; { register int ri; ri=i; ri=& 07; ri = 7 - ri; in_buf(014000); in_buf(0200|ri); flush_buf(); } buf[j];# #include "/user/ramtek/ramtek.h" #define WI 05000 /* write-image */ /* * perform a scan-line color fill of a polygon: * * calling sequence: * fill2(n,p,width) * int n; * struct { * int x , y , color#; * } p[]; * * * last point will be joined with the first point. * */ #define MAXSCAN 20 /* max expected intersections per scan line */ struct { /* structure containing one scan-line of info */ int scanx; /* x position */ float color; int flag; /* 0=normal , >0=first of horizontal pair , <0=second of horizontal pair */ int next; /* array index of next point to the right (-1=end-of-list) */ } scanbuf[MAXSCAN] , dummy; fill2(nn , p , width) int nn , width; char *p; { register struct { int x , y , col; /* form the argument list is in */ } *pt; register int j , n; int maxy , miny , y , ib , jp1 , jp2; int i , k , l , jj , maxcol , mincol , n_pixels; float ratio , delta , dcolor , color , rnd; n = nn; pt = p; /* * scan the data for maxy and miny and convert the LL user system to the UL ramtek system: */ maxy = maxcol = -1; miny=513; mincol = 2048; for(j=0;j 512 ) pt[j].y = 512; if( pt[j].y < 0 ) pt[j].y = 0; if( pt[j].y > maxy ) maxy = pt[j].y; if( pt[j].y < miny ) miny = pt[j].y; if( pt[j].col > maxcol ) maxcol = pt[j].col; if( pt[j].col < mincol ) mincol = pt[j].col; } /* * start the scan lines from the top to the bottom and from left to right: */ for(y=miny; y<=maxy; y++) { ib=0; /* scanbuf counter */ for(j=0;j 0 ) continue; /* scan line does not cross this vector */ if( pt[j].y==y && pt[jp1].y==y ) { /* horizontal! */ scanbuf[ib].scanx = pt[j].x; scanbuf[ib].color = pt[j].col; scanbuf[ib].flag = ib+1; scanbuf[ib].next = -1; scanbuf[++ib].scanx = pt[jp1].x; scanbuf[ib].color = pt[jp1].col; scanbuf[ib].flag = -1; scanbuf[ib].next = -1; ib++; continue; } if( pt[jp1].y==y ) { /* check for a singularity at pt[jp1] */ jp2 = j+2; if( j>=n-2 ) jp2=- n; if( (pt[j].y-pt[jp1].y) * (pt[jp2].y-pt[jp1].y) <= 0 ) continue; } /* otherwise, determine the intersection of the line (pt[j]-pt[jp1]) and the scan */ ratio = y - pt[j].y; ratio=/ (pt[jp1].y - pt[j].y); scanbuf[ib].scanx = pt[j].x + (pt[jp1].x-pt[j].x)*ratio; scanbuf[ib].color = pt[j].col + (pt[jp1].col-pt[j].col)*ratio; scanbuf[ib].flag = 0; scanbuf[ib++].next = -1; } /* j */ /* * now sort the scan line intersections: */ if( ib==0 ) continue; /* insurance */ j = sort( 0 , ib-1 ); /* j is the index of the first pt */ for(; j>=0; j=scanbuf[j].next) { if( scanbuf[j].next== -1 ) break; /* something out-of-wack! */ cop( scanbuf[j].scanx , y); /* start span */ if( (i=scanbuf[j].flag) == 0) { /* normal */ i = scanbuf[j].next; n_pixels = scanbuf[i].scanx - scanbuf[j].scanx + 1; delta = scanbuf[i].color - scanbuf[j].color; if( width==0 && delta==0.0 ) write_image(n_pixels , (jj=scanbuf[i].color) ); else { dcolor = delta / n_pixels; color = scanbuf[j].color; in_buf(WI|DF); /* write image + data flag */ in_buf(n_pixels<<1); /* # bytes */ for(k=0; k239 ) l=239; } in_buf(l); color=+ dcolor; } flush_buf(); } j = i; continue; } /* must be a horizontal line */ k = scanbuf[j].next; if( scanbuf[i].scanx <= scanbuf[k].scanx ) { /* ie, not overlapping horizontal lines */ n_pixels = scanbuf[i].scanx - scanbuf[j].scanx + 1; delta = scanbuf[i].color - scanbuf[j].color; if( delta==0.0 ) { write_image(n_pixels , (jj=scanbuf[i].color) ); } else { dcolor = delta / n_pixels; color = scanbuf[j].color; in_buf(WI|DF); /* write image + data flag */ in_buf(n_pixels<<1); /* # bytes */ for(k=0; k=u ) return(l); /* same pt! */ return( merge( sort(l,mid) , sort(mid+1,u) ) ); } merge(ii,jj) { register int i , j; register char *last; i=ii; j=jj; last = &dummy; while( i>=0 && j>=0 ) { if( scanbuf[i].flag < 0 ) { /* ignore this pt */ i = scanbuf[i].next; continue; } if( scanbuf[j].flag<0 ) { j = scanbuf[j].next; continue; } if( scanbuf[i].scanx <= scanbuf[j].scanx ) { last->next = i; last = &scanbuf[i]; i = last->next; } else { last->next = j; last = &scanbuf[j]; j = last->next; } } /* * fill out remaining list: */ if( i >= 0 ) last->next = i; else last->next = j; return( dummy.next ); } cop(x,y) { in_buf(04000|OF); in_buf(START_POINT); in_buf(x); in_buf(y); flush_buf(); } i = scanbuf[i].next; continue; } if( scanbuf[j].flag<0 ) { j = scanbuf[j].next; continue; } if( scanbuf[i].scanx <= scanbuf[j].scanx ) { last->next = i; last = &scanbuf[i]; i = last->next; } else# #include "/user/ramtek/ramtek.h" #define DEBUG 0 #define MAXSIDES 20 /* max # sides */ #define NSQ 12 float one[] { 0.667 , 1.0 , 0.0 }; float two[] { 0.667 , 1.0 , 1.0 }; float backg[] {0.0 , 1.0 , 0.40}; float xsq[] { 1. , 1. , 2. , 5. , 7.8 , 9. , 7.9 , 3.9 , 6.8 , 5.7 , 2.0 , 4.9}; float ysq[] { 1. , 3. , 5. , 2. , 5.8 , 5. , 2.5 , 3.5 , 4.0 , 4.5 , 6.5 , 5.4}; int csq[] { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0}; struct { char *next; int nsides; struct { int x , y , z , color; } side[]; } head; struct { float xx , yy; int col; } vertices[MAXSIDES]; char *memend; main(argc , argv) int argc; char *argv[]; { register char *cp , *last; register int j; char *now , *sbrk() , *alloc() , *before; int nsides , min , i , width; char iobuf[518]; float cosine , pow() , power , atof() , xx , yy; int c , cc; float i100 , j100; if( argc>3 || argc<2 ) { printf("\n syntax: ramtek filename [width]\n\7"); exit(1); } if( argc==3 ) { width = atoi(argv[2]); srand(1); } else width = 0; if( fopen(argv[1],iobuf) < 0 ) { printf("\n cannot open %s\n\7",argv[1]); exit(1); } memend = sbrk(0); memend++; memend=& 0177776; brk(0157776); last = &head; while( (nsides=getw(iobuf)) > 0) { if( nsides>MAXSIDES ) { printf("\n %d - need to increase MAXSIDES in ramtek.c\n\7",nsides); goto contin; } last = last->next = alloc(4+8*nsides); last->nsides = nsides; last->next=0; if( DEBUG ) printf("\n nsides = %d",nsides); for(j=0;jside[j].x = getw(iobuf); last->side[j].y = getw(iobuf); last->side[j].z = getw(iobuf); cosine = getw(iobuf); cosine=/ 250.; last->side[j].color = 180.*cosine + 30. + 0.5; if( DEBUG ) printf("\n\t%d %d %d %d",last->side[j].x,last->side[j].y,last->side[j].z,last->side[j].color); if( (i=last->side[j].x) <0 || i> 511) goto bad; if( (i=last->side[j].y) <0 || i>511) goto bad; if( (i=last->side[j].color) <0 || i>239 ) goto bad; continue; bad: last->nsides=0; } } /* * start the display: */ contin: printf("\7\7"); ram_setup(); color_table("hci",0,240,one,two); backgrd(239); erase(); for(j=0; jnext ) { if( cp->nsides <= 0 ) continue; for(j=0;jnsides;j++) if( cp->side[j].z < min ) { min = cp->side[j].z; now = cp; before = last; } } if( (cp=now) == 0 ) break; /* done */ before->next = cp->next; /* so will skip this one next time */ for(j=0;jnsides;j++) { vertices[j].xx = cp->side[j].x/XFACT; vertices[j].yy = cp->side[j].y/YFACT; vertices[j].col = cp->side[j].color; } fill(cp->nsides , &vertices[0] , 0.550); } close( iobuf[0] ); } char *alloc(nbytes) { register char *m; m=memend; memend=+ nbytes; if( memend > 0157776 ) { printf("\n out of memory!\7"); exit(1); } return(m); } ast; } } if( (cp=now) == 0 ) break; /* done */ before->next = cp->next; /* so will skip this one next time */ for(j=0;jnsides;j++) { vertices[j].xx = cp->side[j].x/XFACT; vertices[j].yy = cp->side[j].y/YFACT; vertices[j].col = cp->side[j].color; } fill(cp->nsides , &vertices[0] , 0.550); } close( iobuf[0] ); } char *alloc(nbytes) { register char *m; m=memend; memend=+ nbytes; if( meme# #include "/user/ramtek/ramtek.h" #define DEBUG 0 #define MAXSIDES 20 /* max # sides */ #define NSQ 12 float one[] { 0.0 , 0.0 , 0.0 }; float two[] { 1.0 , 0.0 , 0.0 }; float xsq[] { 1. , 1. , 2. , 5. , 7.8 , 9. , 7.9 , 3.9 , 6.8 , 5.7 , 2.0 , 4.9}; float ysq[] { 1. , 3. , 5. , 2. , 5.8 , 5. , 2.5 , 3.5 , 4.0 , 4.5 , 6.5 , 5.4}; int csq[] { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0}; struct { char *next; int nsides; struct { int x , y , z , color; } side[]; } head; struct { float xx , yy; int col; } vertices[MAXSIDES]; char *memend; main(argc , argv) int argc; char *argv[]; { register char *cp , *last; register int j; char *now , *sbrk() , *alloc() , *before; int nsides , min , i , width; char iobuf[518]; float cosine , pow() , power , atof() , xx , yy; int c , cc; float i100 , j100; if( argc>3 || argc<2 ) { printf("\n syntax: ramtek filename [width]\n\7"); exit(1); } if( argc==3 ) { width = atoi(argv[2]); srand(1); } else width = 0; if( fopen(argv[1],iobuf) < 0 ) { printf("\n cannot open %s\n\7",argv[1]); exit(1); } memend = sbrk(0); memend++; memend=& 0177776; brk(0157776); last = &head; while( (nsides=getw(iobuf)) > 0) { if( nsides>MAXSIDES ) { printf("\n %d - need to increase MAXSIDES in ramtek.c\n\7",nsides); goto contin; } last = last->next = alloc(4+8*nsides); last->nsides = nsides; last->next=0; if( DEBUG ) printf("\n nsides = %d",nsides); for(j=0;jside[j].x = getw(iobuf); last->side[j].y = getw(iobuf); last->side[j].z = getw(iobuf); cosine = getw(iobuf); cosine=/ 250.; last->side[j].color = 180.*cosine + 30. + 0.5; if( DEBUG ) printf("\n\t%d %d %d %d",last->side[j].x,last->side[j].y,last->side[j].z,last->side[j].color); if( (i=last->side[j].x) <0 || i> 511) goto bad; if( (i=last->side[j].y) <0 || i>511) goto bad; if( (i=last->side[j].color) <0 || i>239 ) goto bad; continue; bad: last->nsides=0; } } /* * start the display: */ contin: printf("\7\7"); ram_setup(); color_table("gray",0,240,one,two); backgrd(239); erase(); for(j=0; jnext ) { if( cp->nsides <= 0 ) continue; for(j=0;jnsides;j++) if( cp->side[j].z < min ) { min = cp->side[j].z; now = cp; before = last; } } if( (cp=now) == 0 ) break; /* done */ before->next = cp->next; /* so will skip this one next time */ for(j=0;jnsides;j++) { vertices[j].xx = cp->side[j].x/XFACT; vertices[j].yy = cp->side[j].y/YFACT; vertices[j].col = cp->side[j].color; } fill(cp->nsides , &vertices[0] , 0.50); } close( iobuf[0] ); } char *alloc(nbytes) { register char *m; m=memend; memend=+ nbytes; if( memend > 0157776 ) { printf("\n out of memory!\7"); exit(1); } return(m); } last; } } if( (cp=now) == 0 ) break; /* done */ before->next = cp->next; /* so will skip this one next time */ for(j=0;jnsides;j++) { vertices[j].xx = cp->side[j].x/XFACT; vertices[j].yy = cp->side[j].y/YFACT; vertices[j].col = cp->side[j].color; } fill(cp->nsides , &vertices[0] , 0.50); } close( iobuf[0] ); } char *alloc(nbytes) { register char *m; m=memend; memend=+ nbytes; if( memend > 0157776 ) { printf("\n out of me# #define DEBUG 0 #include "/user/ramtek/ramtek.h" #define WI 05000 /* write-image */ /* * perform a scan-line color fill of a polygon: * * calling sequence: * fill(n,p[,t]) * int n; * struct { * float x , y; * int color; * } p[]; * double t; * * * last point will be joined with the first point. * * if given, t is transparency factor (0.0=perfectly opaque / 1.0=perfectly transparent) * if not given, t=0.0 * */ #define MAX 30 /* max expected edges */ struct { /* structure containing one scan-line of info */ int scanx; /* x position */ float color; int flag; /* 0=normal , >0=first of horizontal pair , <0=second of horizontal pair */ int next; /* array index of next point to the right (-1=end-of-list) */ } scanbuf[MAX] , dummy; struct vert { int x , y; int col; } ppt[MAX]; fill(nn , p , t) int nn; char *p; double t; { struct { float fx , fy; int kolor; } *pts; register struct vert *pt; register int j , n; int maxy , miny , y , ib , jp1 , jp2; int i , k , l , jj , maxcol , mincol , n_pixels; float ratio , delta , dcolor , color; extern int BUFFER[] , NWORDS; /* * default "t" if not given: */ if( nargs() != 6 ) t = 0.0; pt = &ppt[0]; n = nn; pts = p; /* * scan the data for maxy and miny and convert the LL user system to the UL ramtek system: */ maxy = maxcol = -1; miny=513; mincol = 2048; for(j=0;j 511 ) pt[j].y = 511; if( pt[j].y < 0 ) pt[j].y = 0; if( pt[j].y > maxy ) maxy = pt[j].y; if( pt[j].y < miny ) miny = pt[j].y; if( pt[j].col > maxcol ) maxcol = pt[j].col; if( pt[j].col < mincol ) mincol = pt[j].col; } /* * start the scan lines from the top to the bottom and from left to right: */ for(y=miny; y<=maxy; y++) { ib=0; /* scanbuf counter */ for(j=0;j 0 ) continue; /* scan line does not cross this vector */ if( pt[j].y==y && pt[jp1].y==y ) { /* horizontal! */ scanbuf[ib].scanx = pt[j].x; scanbuf[ib].color = pt[j].col; scanbuf[ib].flag = ib+1; scanbuf[ib].next = -1; scanbuf[++ib].scanx = pt[jp1].x; scanbuf[ib].color = pt[jp1].col; scanbuf[ib].flag = -1; scanbuf[ib].next = -1; ib++; continue; } if( pt[jp1].y==y ) { /* check for a singularity at pt[jp1] */ jp2 = j+2; if( j>=n-2 ) jp2=- n; if( (pt[j].y-pt[jp1].y) * (pt[jp2].y-pt[jp1].y) <= 0 ) continue; } /* otherwise, determine the intersection of the line (pt[j]-pt[jp1]) and the scan */ ratio = y - pt[j].y; ratio=/ (pt[jp1].y - pt[j].y); scanbuf[ib].scanx = pt[j].x + (pt[jp1].x-pt[j].x)*ratio; scanbuf[ib].color = pt[j].col + (pt[jp1].col-pt[j].col)*ratio; scanbuf[ib].flag = 0; scanbuf[ib++].next = -1; } /* j */ /* * now sort the scan line intersections: */ if( ib==0 ) continue; /* insurance */ j = sort( 0 , ib-1 ); /* j is the index of the first pt */ for(; j>=0; j=scanbuf[j].next) { if( scanbuf[j].next== -1 ) break; /* something out-of-wack! */ if( (i=scanbuf[j].flag) == 0) { /* normal */ i = scanbuf[j].next; n_pixels = scanbuf[i].scanx - scanbuf[j].scanx + 1; if( t != 0.0 ) { read_pix(&BUFFER[5] , n_pixels-1 , scanbuf[j].scanx , 511 - y); if( DEBUG ) printf("\n Read %d Pixels",n_pixels-1); } delta = scanbuf[i].color - scanbuf[j].color; dcolor = delta / n_pixels; color = scanbuf[j].color; BUFFER[0] = WI|DF|OF; BUFFER[1] = START_POINT; BUFFER[2] = scanbuf[j].scanx; BUFFER[3] = y; BUFFER[4] = (n_pixels-1)<<1; for(k=0; k=u ) return(l); /* same pt! */ return( merge( sort(l,mid) , sort(mid+1,u) ) ); } merge(ii,jj) { register int i , j; register char *last; i=ii; j=jj; last = &dummy; while( i>=0 && j>=0 ) { if( scanbuf[i].flag < 0 ) { /* ignore this pt */ i = scanbuf[i].next; continue; } if( scanbuf[j].flag<0 ) { j = scanbuf[j].next; continue; } if( scanbuf[i].scanx <= scanbuf[j].scanx ) { last->next = i; last = &scanbuf[i]; i = last->next; } else { last->next = j; last = &scanbuf[j]; j = last->next; } } /* * fill out remaining list: */ if( i >= 0 ) last->next = i; else last->next = j; return( dummy.next ); } /* * combine 2 colors: * (cf is foreground, cb is background) * (t=0 means all cf / t=1 means all cb) */ #define BLACK 0 #define WHITE 239 add(cf , cb , t) float t; { register int i; if( cf==BLACK || cb==WHITE ) t = 0.00; if( cb==BLACK ) t = 0.90; return( (i=(1.-t)*cf + t*cb) ); } last->next; } else { wcoloriwidixiyfmulzfsubzfaddzfdivzrio.oD~ram_setD~in_bufword~flush_bjdump~ram_rea8npram_coloR~foregrdRindexcolor~strcmpist~table_iword~backgrd2indexcolorword~eraseh~color_n~indexcolorram_move~ram_movnxy newcoloriwidfmulzfsubzfaddzfdivzfltpr.ob _ndigit.ac0/fcvt!movedig&!ecvt!eflag.scaled!norm"mul10"div10"right,#buf.buftop/doneZ"left"#savedr1/printf.o8#formp/loopL#rjust/ndigit/gnum %width/ndfnd/swtab*decimal#octalb$hex\$float$scien$charac:$stringH$longorun#unsigned#remote$long#prbuf$prstr$putchr.o>%flx%close.o%open.o%read.o%write.o&exit.o&&nargs.o0&jsrsd+tsti+cmpi+addi+jmpi +bri+csv.o&fis.o&fsubzreturn"1cerror.o'savr5$._exit"&&_main"_k#(_n#(_w#(_r#((_g#4(_b#@(_m#L(_c#X(_l#d(csv"&_setup"Z_seg"_plot"_ram_set"D_backgrd"2_erase"h_ram_mov"_color_t"\_keyset"_mouse"_move"R_move_cu"(_fill"T _foregrd"R_draw"cret"&fltused"b ac0$+_functr"fisitod"&_FACTR$B+_parm"_map"6_funct"fisdtoi"&_FACT$F+_GFD$J+_GDEV#(_nargs"0&_close"%_open"%_dr11"_write"&_strng"6_read"%_in_buf"_flush_b"_read_cu"_ram_rea"8_scanbuf$L+_dummy$x,_ppt$,_sort"_cop"fiststf"'_write_i"&_merge"X_strcmp"_printf"8#fiscmpf"'_rgb_cvt"$_cmy_cvt"_hci_cvt"x_gray_cv"z_COLORNO$6-_IWIDTH$8-_XNOW$:-_YNOW$<-_FDB$>-_FDC$@-_BUFFER$B-_NWORDS$._table_i"_color_n"~pfloat"b pscien" _ecvt"4!_fcvt"^!_putchar">%_flush"l%_fout$/cerror"'fisdtol">'fisltod"&fisnegf"'_errno$.ng"6_read"%_in_buf"_flush_b"_read_cu"_ram_rea"8_scanbuf$L+_dummy$x,_ppt$,_sort"_cop"fiststf"'_write_i"&_merge"X_strcmp"_printf"8#fiscmpf"'_rgb_cvt"$_cmy_cvt"_hci_cvt"OI PNELA PNDHIBES I 1NTOI P C0 11 IS VS ZP2=ZP 09 1 S VI ZS2= Z 8 10 IS VS =YY2 07 1 S VI XS2= X 6 10 IS VS =LL2 05 1 S VI P2=ZP1 Z 4 10 IS V2 =ZZ1 03 1 S VI Y21= Y 2 10 IS V2 =XX1 01 1 S VI L21= L 0 10 IS V1 ZPS=ZP 99 S VI Z1S= Z 8 9 IS V1 =YYS 97 S VI X1S= X 6 9 IS V1 =LLS 95 S VI .NELA PHE TNDHIBE =M-1 PERCPT 65 GO TO 10 PERCPT 66 60 NINT=NINT+1 PERCPT 67 XI(NINT)=X2 PERCPT 68 YI(NINT)=Y2 PERCPT 69 ZI(NINT)=Z2 PERCPT 70 INT(NINT)=IPL PERCPT 71 GO TO 50 PERCPT 72 END PERCPT 73 SUBROUTINE PERSP PERSP 1 C THIS SUBROUTINE PLACES THE ROTATED COORDINATES IN PERSP 2 C PERSPECTIVE AND COMPUTES THE PICTURE PLANE MAXIMUM AND PERSP 3 C MINIMUM PERSP 4S I 1NTOI PATTHO STSINPOP WA S C4 9 IS V. NELA PHE TOF C 93 S VI NTRO FINR OONS I 1NTOI PE,ANPLE THD INEH BIS2 T INPO C 92 S VI 30 6TOO GN)MIIZ-SP2.ZGT2.(ZIF 91 S VI E.ANPLE THF ONTRO FINR OONS I 2 C0 9 IS VT INPOF ICKHE CE,ANPLE THF ONTRO FINR OONS I 1NTOI P C9 8 IS V0 7TOO GN)MIIZ-SP1.ZLT1.(ZIF 88 S VI E.ANPLE THD INEH BIS1 T INPOF ICKHE C C7 8 IS V) .3102F',2=ZPD AN1 ZP' T(MAOR F 5 6 COMMON /PRW1/ X(1000),Y(1000),Z(1000),IXYZ(1000) CPRW1 1 1,NPT,MXPT,NFPT,NLPT CPRW1 2 2,PL(1000),NPL,MXPL,NFPL,NLPL CPRW1 3 3,LA(1000),LB(1000),NLN,MXLN,NFLN,NLLN CPRW1 4 4,IERR CPRW1 5 COMMON /PRW2/ XO,YO,ZO,XL,YL,ZL,S,D,SD,F CPRW2 1 1,XPMAX,XPMIN,YPMAX,YPMIN,MAXS CPRW2 2 2,TX,TY,TZ,OX,OY,OZ,RX,RY,RZ CPRW2 3 INTEGER PL PERSP 7 N=NFPT-1 PERSP 8 10 N=N+1 PERS6 8 IS V2 ZP1,ZP) 656,E(ITWR) .1EQT.OU(IIF 85 S VI CC)/DD2-*YBB2-*XAA(-2=ZP 84 S VI CC)/DD1-*YBB1-*XAA(-1=ZP 83 S VI E.ANPLE TH C 82 S VI TOOND TEECOJPRE IN LHE TOFS TENADIORCOZ E THE UTMPCO C 81 S VI NELA PHE TNGDIUNROUR SEDIP PELLLRAPAE THD INEH BORN INELI C 80 S VI 30 6TOO GX)MALZ.PGEN.MINZ(LIF 79 S VI 30 6TOO GN)MILY.PLEX.MANY(LIF 78 S VI 30 6TOO GX)MALY.PGEN.MINY(LIF 77P 9 IF(N.GT.NLPT) RETURN PERSP 10 IF(IXYZ(N).LE.0) GO TO 10 PERSP 11 W=1.-Z(N)/D PERSP 12 X(N)=X(N)/W PERSP 13 Y(N)=Y(N)/W PERSP 14 Z(N)=Z(N)/W PERSP 15 C PERSP 16 C COMPUTE MAXIMUM AND MINIMUM PERSP 17 C FIRST POINT PERSP 18 IF(MAXS.EQ.0) GO TO 20 PERSP 19 XPMAX=AMAX1(XPMAX,X(N)) PERSP 20 XPMIN=AMIN1(XPMIN,X(N)) PERSP 21 YPMAX=AMAX1(YP S VI 30 6TOO GN)MILX.PLEX.MANX(LIF 76 S VI 30 6TOO GX)MALX.PGEN.MINX(LIF 75 S VI NELIN DEID H AOFY ITILIBSSPOE THR FOK ECCH C 74 S VI DSPEPIL LEALAR PNGBIRISCUMRCCIO TWE THG INARMPCO C 73 S VI 2),ZZ11(INAMN=MINZ L 2 7 IS V) Y21,(YN1MI=AINYMLN 71 S VI 2),YY11(AXAMX=MANY L 0 7 IS V) X21,(XN1MI=AINXMLN 69 S VI 2),XX11(AXAMX=MANX L 8 6 IS VM MUNIMID ANM MUXIMAE IN LTEPUOM C MAX,Y(N)) PERSP 22 YPMIN=AMIN1(YPMIN,Y(N)) PERSP 23 GO TO 10 PERSP 24 20 XPMAX=X(N) PERSP 25 XPMIN=X(N) PERSP 26 YPMAX=Y(N) PERSP 27 YPMIN=Y(N) PERSP 28 MAXS=1 PERSP 29 GO TO 10 PERSP 30 END PERSP 31 SUBROUTINE PLTOLN PLTOLN 1 C THIS SUBROUTINE ADDS ALL THE LINES FORMING PLANE PLTOLN 2 C BOUNDARIES TO LINE TABLES. IT AVOIDS ADDING REDUNDANT PLTO C7 6 IS V0 63O TGO 1 66 S VI N)MIIZ.SLT2.**2)-ZZ1+(*2)*Y21-(Y2+**2)-XX1((IF 65 S VI W.IE VNTOI PORT ORSHY ER VISE IN LIFK ECCH C 64 S VI 3)0.F1,3I23,0.F1,3I2',E=IN L('ATRMFO 62 63 S VI Z22,,YX22,,LZ11,,YX11, L2),6(6TERI W1)Q..EUTIOF( I 2 6 IS V) L2Z(2= Z 1 6 IS V) L2Y(2= Y 0 6 IS V) L2X(2= X 9 5 IS V) L1Z(1= Z 8 5 IS V) L1Y(1= Y 7 5 IS V) L1X(1= X 6 5 LN 3 C LINES. PLTOLN 4 COMMON /PRW1/ X(1000),Y(1000),Z(1000),IXYZ(1000) CPRW1 1 1,NPT,MXPT,NFPT,NLPT CPRW1 2 2,PL(1000),NPL,MXPL,NFPL,NLPL CPRW1 3 3,LA(1000),LB(1000),NLN,MXLN,NFLN,NLLN CPRW1 4 4,IERR CPRW1 5 COMMON /PRW3/ VERT(100),NV,MXV CPRW3 1 INTEGER PL,VERT PLTOLN 7 N=NFPL-1 PLTOLN 8 10 J=0 PLTOLN 9 20 J=J+4 PLTOLN 10 N=N+1 PLTOLN 11 IS V) (LLB2= L 5 5 IS V0 63O TGO) .0EQ1.(LIF 54 S VI L)A(=LL1 53 S VI NELIA K ACNP U C2 5 IS V0 64O TGO) LNNLT..G(LIF 50 51 S VI LNNFL= 40 50 S VI ERNTOU CNELIE IZALTINI I C9 4 IS V0 64O TGO) INZMSI.-LTC.(CIF 48 S VI CKBAN OISE ANPLF ICKHE CD,LISOX VEON COFT AR P C7 4 IS V0 4TOO G2)E..NND(IIF 46 S VI ALRMNOR TEOUR FOD REDEORS CETIER VTHWID LISO C 45 S VI  IF(N.GT.NLPL) RETURN PLTOLN 12 CALL UNPACK (PL(N),VERT(J-3),VERT(J-2),VERT(J-1),VERT(J), PLTOLN 13 1NVERT,IND) PLTOLN 14 IF(NVERT.GT.J) GO TO 20 PLTOLN 15 C WHOLE PLANE IS UNPACKED ADD LINES PLTOLN 16 IFST=VERT(1) PLTOLN 17 L=VERT(NVERT) PLTOLN 18 DO 70 I=1,NVERT PLTOLN 19 J=VERT(I) PLTOLN 20 C SEE IF POINT J ANY WHERE ELSE IN LIST PLTOLN 21 DO 60 K=1,NVERT PLTOLN 22 EXNVCOA F ORTPAS INELA PIFK ECCH C 44 S VI 40 6TOO GN)MIIZ.SLT).CCS(ABF( I 3 4 IS V) .3106F/,3,0.F1,4I5/,',N=MILZ PAXZMPL' 1 42 S VI N'MILY PAXYMPLN MILX PAXXMPLD DCCB BAAL IP' T(MAOR F 5 31 4 IS VN MILZ,PAXZMPLN,MILY,PAXYMPL1, 0 4 IS VN MILX,PAXXMPLD,,DCCB,,BAAL,IP) 356,E(ITWR) .1EQT.OU(IIF 39 S VI 40 6TOO G1)Q..EN)MIIZ,SDDC,,CBBA,,ANVT,ER(VEQPL(IIF 38 S VI W.IE VGEEDN AORL ALSMY ER V C7 3 IS V IF(VERT(K).NE.J) GO TO 60 PLTOLN 23 IF(K.EQ.I) GO TO 60 PLTOLN 24 IF(K.EQ.NVERT) GO TO 50 PLTOLN 25 IF(L.EQ.VERT(K+1)) GO TO 70 PLTOLN 26 GO TO 60 PLTOLN 27 50 IF(L.EQ.IFST) GO TO 70 PLTOLN 28 60 CONTINUE PLTOLN 29 C ADD LINE L-J PLTOLN 30 CALL ADDLN(L,J) PLTOLN 31 IF(IERR.EQ.1) RETURN PLTOLN 32 70 L=J PLTOLN 33 GO TO 10 PLTOLN 34 END PLTOLN 35 SUS INELA PIFK ECCHD ANS NTTANSCON IOATQU ENELA PTEPUOM C C6 3 IS V) NVT,ER,VINZMPL 1 35 S VI X,MALZ,PINYMPLX,MALY,PINXMPLX,MALX(PINXMMAL AL C 0 34 3 IS VS TENADIORCOM MUNIMI C 33 S VI ND AUMIMAX MTEPUOM CEDCKPAUNN EE BAS HNELA PALOT T C2 3 IS V0 2TOO G 1 3 IS V1 L+IPL=IP 30 S VI 30O TGO) NVT..G(IIF 29 S VI +4=I I 8 2 IS VE ANPLA S IRYNT E C7 2 IS V0 64O TGO) .2GTD.INF( I BROUTINE POLCLP POLCLP 1 C THIS SUBROUTINE PERFORMS POLYGON CLIPPING POLCLP 2 COMMON /PRW1/ X(1000),Y(1000),Z(1000),IXYZ(1000) CPRW1 1 1,NPT,MXPT,NFPT,NLPT CPRW1 2 2,PL(1000),NPL,MXPL,NFPL,NLPL CPRW1 3 3,LA(1000),LB(1000),NLN,MXLN,NFLN,NLLN CPRW1 4 4,IERR CPRW1 5 COMMON /PRW2/ XO,YO,ZO,XL,YL,ZL,S,D,SD,F CPRW2 1 1,XPMAX,XPMIN,YPMAX,YPMIN,MAXS CPRW2 2 2,TX,TY,TZ,OX,OY,OZ,RX,RY,RZ CPR 6 2 IS VE ANPLA S IRYNT EHE TIFK ECCH C 25 S VI D)INV,,N3)I+T(ER1V 4 2 IS V, 2)I+T(ER,V1)I+T(ER,VI)T(ER,VL)IPL((PCKPAUNL AL C 0 23 2 IS V1 I= 22 S VI RNTURE) PLNLT..GPL(IIF 10 21 S VI NEDOF ICKHE C C0 2 IS VL FP=NPL I 9 1 IS VY TRENY RAARL PSTIR FERIDNSCO C 18 S VI 0100.0 *N)MIYPX-MAYPN,MIXPX-MAXP1(INAMN=MIIZ S 7 1 IS VE IN LND ANELA POFE IZ SUMIMIN MONT MILIP UET S C6 1 W2 3 COMMON /PRW3/ VERT(100),NV,MXV CPRW3 1 INTEGER PL,OUT,VERT POLCLP 6 NN=NLPL POLCLP 7 NLPL=NFPL-1 POLCLP 8 N=NFPL-1 POLCLP 9 10 N=N+1 POLCLP 10 IF (N.GT.NN) RETURN POLCLP 11 L=1 POLCLP 12 20 CALL UNPACK(PL(N),VERT(L),VERT(L+1),VERT(L+2),VERT(L+3), POLCLP 13 1NV,IND) POLCLP 14 IF(NV.LE.L+3) GO TO 30 POLCLP 15 N=N+1 POLCLP 16 L=L+4 POLC IS V) IS VIN6H (UGEB DLLCA) .1EQT.OU(IIF 15 S VI INZMLNN,MINY,LAXYMLNN,MINX,LAXXMLNL EA R 4 1 IS V) 00(1NT IONSIENIM D 3 1 IS VT ER,VPLR GETEIN 1 7 RWCP UTIO/ W7PR /ONMMCO 1 6 RWCP INZMPLX,MALZ,PINYMPLX,MALY,PINXMPLX,MALX/PW6PRN/MOOM C 1 W5PR CD ,DCCB,,BAA/ W5PRN/MOOM C 1 W4PR C2 ZP2,,ZY22,,XL21,ZP1,,ZY11,,XL1/ W4PRN/MOOM C 1 W3PR CV MXV,,N0)10T(ER V3/RW/PN MOOM C 3 W2PR CZ ,RRYX,,R LP 17 GO TO 20 POLCLP 18 C SELECT CLIPPING PLANE POLCLP 19 30 I=0 POLCLP 20 40 I=I+1 POLCLP 21 IF(I.GT.6) GO TO 200 POLCLP 22 C TURN OFF OUTPUT FLAG POLCLP 23 OUT=0 POLCLP 24 C TURN ON FIRST VERTEX FLAG POLCLP 25 IF=1 POLCLP 26 J=1 POLCLP 27 45 IF(VERT(J)) 160,50,50 POLCLP 28 C EXISTING VERTEX OR NEW INTERSECTION POLCLP 29 50 K=VERT(J) POLCLP 30 XOZY,,OOXZ,,TTYX,,T 2 2 2 RWCP XSMAN,MIYPX,MAYPN,MIXPX,MAXP1, 1 W2PR CF D,,S,D,SZLL,,YXLO,,ZYOO, X2/RW/PN MOOM C 5 W1PR CR ER,I 4 4 1 RWCP LNNLN,FL,NLNMXN,NL),0010B(,L0)00(1LA3, 3 W1PR CL LP,NPLNFL,XP,MPL,N0)00(1PL2, 2 W1PR CT LP,NPTNFT,XP,MPT,N 1 1 1 RWCP 0)00(1YZIX),0010Z(),0010Y(),0010X(/ W1PR /ONMMCO 5 S VI N.NLN=LL N C4 IS VD TEXI EENWH L.LP NTOL FP NOMFRS NELA PTOE IVATEL R C3 V=X(K) POLCLP 31 YV=Y(K) POLCLP 32 ZV=Z(K) POLCLP 33 C CHECK IF FIRST POINT POLCLP 34 GO TO (60,170),IF POLCLP 35 C POLCLP 36 C FIRST POINT POLCLP 37 C POLCLP 38 60 IF=2 POLCLP 39 FX=XV POLCLP 40 FY=YV POLCLP 41 FZ=ZV POLCLP 42 70 SX=XV POLCLP 43 SY=YV POLCLP 44 SZ=ZV POLCLP 45 C CHECK IF POINT J ON VISIBLE SIDE OF PLANE 1 POLCLP 4 IS VD REDESION CENWHY LLIARTPAR OLEIBIS VRE ALNNLO TLNNF C 2 S VI ESIN LOFS NELIH ICWHS NEMIERET DNETIOUBRSUS HI T C1 IS VS VIE INUTROUB S 3 2 RTTA SD EN 22 T ARST RNTURE 21 T ARST UEINNTCO 20 20 T ARST =0I)A( L 9 1 RTTA SN XL=M I20O D 8 1 RTTA SE NUTION C 0 17 1 RTTA S0 )=(IYZIX 16 T ARST PTMX1,I=0 1DO 15 T ARST YSRAARE IN LND ANTOI PROZE C 14 T ARST 0/6 GO TO (80,90,100,110,120,130),I POLCLP 47 C FRONT POLCLP 48 80 IF(ZV.GT.0.) GO TO 150 POLCLP 49 GO TO 140 POLCLP 50 C REAR POLCLP 51 90 IF(F.EQ.0.) GO TO 140 POLCLP 52 IF(ZV.LT.F) GO TO 150 POLCLP 53 GO TO 140 POLCLP 54 C TOP POLCLP 55 100 IF(YV.GT.S-SD *ZV) GO TO 150 POLCLP 56 GO TO 140 POLCLP 57 C BOTTOM POLCLP 58 110 IF(YV.LT.-S+SD*ZV) GO TO 150 POLCLP 59 T/OU ITADA 13 T ARST 0/10V/MXA AT D 2 1 RTTA S/ /0XSMAA AT D 1 1 RTTA S/ /0RRIEA AT D 0 1 RTTA S/ ,1,1/1PLNFN,FL,NPTNFA AT D 9 RTTA S/ 00100,0,00,1,000100,N/XL,MLN,NPLMXL,NPT,XP,MPT NTADA 8 T ARST RTVEL, PEREGNT I 1 W7PR CT OU I7/RW/PN MOOM C 1 W3PR CV MXV,,N0)10T(ER V3/RW/PN MOOM C 3 W2PR CZ ,RRYX,,ROZY,,OOXZ,,TTYX,,T 2 2 2 RWCP XSMAN,MIYPX,MAYPN,MIXPX,MAXP1, 1 W2PR CF  GO TO 140 POLCLP 60 C LEFT POLCLP 61 120 IF(XV.LT.-S+SD*ZV) GO TO 150 POLCLP 62 GO TO 140 POLCLP 63 C RIGHT POLCLP 64 130 IF(XV.GT.S-SD*ZV) GO TO 150 POLCLP 65 C IN VISIBLE AREA POLCLP 66 140 OUT=1 POLCLP 67 GO TO 160 POLCLP 68 C OUT OF VISIBLE AREA POLCLP 69 150 VERT(J)=-K POLCLP 70 IXYZ(K)=IXYZ(K)-1 POLCLP 71 C POLCLP 72 C END OF VERTICE LOOP POLCLP 73 C D,,S,D,SZLL,,YXLO,,ZYOO, X2/RW/PN MOOM C 5 W1PR CR ER,I 4 4 1 RWCP LNNLN,FL,NLNMXN,NL),0010B(,L0)00(1LA3, 3 W1PR CL LP,NPLNFL,XP,MPL,N0)00(1PL2, 2 W1PR CT LP,NPTNFT,XP,MPT,N 1 1 1 RWCP 0)00(1YZIX),0010Z(),0010Y(),0010X(/ W1PR /ONMMCO 3 T ARST M.RAOGPRE IN LENDDHIE TH C 2 T ARST OR FNSIOATIZALTINI ILL AESDLAN HNETIOUBRSUS HI T C1 RTTA ST ARSTE INUTROUB S 6 5 N UTOL SD EN 55 TNLUSO RNTU POLCLP 74 160 J=J+1 POLCLP 75 IF(J.LE.NV) GO TO 45 POLCLP 76 C HAS ANY OUTPUT BEEN PRODUCED POLCLP 77 IF(OUT.EQ.0) GO TO 10 POLCLP 78 C YES, CHECK IF LINE CROSSES PLANE POLCLP 79 IF(ICROSS(FX,FY,FZ,SX,SY,SZ,XI,YI,ZI,I).EQ.0) GO TO 40 POLCLP 80 C YES, ADD POINT TO POINT TABLE POLCLP 81 CALL ADDPT(XI,YI,ZI,M) POLCLP 82 IF(IERR.NE.0) RETURN POLCLP 83 NV=NV+1 POLCLP 84 VERT(NV)=RE 54 TNLUSO E.LSFA=.TNOL S10 1 3 5 N UTOL S0 1TOO G 2 5 N UTOL SC )/-DY1B*1-*X-A=(II Z 1 5 N UTOL S0 11O TGO) INZMSIT..LC)S(ABF( I 0 5 N UTOL S1 =YII Y 9 4 N UTOL S1 =XII X00 1 8 4 N UTOL S. ZONE IZERETAMAR PREFOREHE T 0 = YTAEL D = XTAEL D C7 4 N UTOL S0 1TOO G 6 4 N UTOL S1 +Z*W1)-YII(YI=ZI 45 TNLUSO X1I=XI 44 TNLUSO W)C*B+/(D))-Z1W-1*(YC*1+*X-A=(II Y 3 4 N UTOL SV )/Z12-(ZW= 42 !M POLCLP 85 IXYZ(M)=IXYZ(M)+1 POLCLP 86 GO TO 40 POLCLP 87 C POLCLP 88 C NOT FIRST POINT POLCLP 89 C POLCLP 90 C CHECK IF LINE S-XV,YV,ZV CROSSES PLANE POLCLP 91 170 IF(ICROSS(SX,SY,SZ,XV,YV,ZV,XI,YI,ZI,I).EQ.0) GO TO 70 POLCLP 92 C YES INSERT POINT POLCLP 93 OUT=1 POLCLP 94 M=NV POLCLP 95 180 VERT(M+1)=VERT(M) POLCLP 96 IF(M.EQ.J) GO TO 190 POLCLP 97 M=M-1 POLCLP TNLUSO 00 1TOO GN)MIIZ.SLT).(VBS(AIF 41 TNLUSO Y12-=Y V90 0 4 N UTOL S. YONE IZERETAMAR PREFOREHE T 0 = XTAEL D C9 3 N UTOL SN URET R 8 3 N UTOL S. UETR=.TNOL S80 7 3 N UTOL S0 2TOO G2).ZGTI.ZIF( I70 6 3 N UTOL S0 2TOO G 5 3 N UTOL S0 8TOO G2).ZGTI.ZIF( I 4 3 N UTOL S0 7TOO G1).ZGTI.ZIF( I 3 3 N UTOL S0 8TOO GN)MIIZ.SLT).Z2I-ZIS(ABF( I 2 3 N UTOL S0 8TOO GN)MIIZ.SLT).Z1I-ZIS(ABF( I60 1 3 N UTOL% 98 GO TO 180 POLCLP 99 190 CALL ADDPT(XI,YI,ZI,M) POLCLP 100 IF(IERR.NE.0) RETURN POLCLP 101 VERT(J)=M POLCLP 102 IXYZ(M)=IXYZ(M)+1 POLCLP 103 J=J+1 POLCLP 104 NV=NV+1 POLCLP 105 GO TO 70 POLCLP 106 C POLCLP 107 C WRITE OUT DATA POLCLP 108 C POLCLP 109 200 IF(OUT.EQ.0) GO TO 10 POLCLP 110 C FIND NUMBER OF VERTICES LEFT POLCLP 111 M=0 POLCLP 112 DO 23 SS TENADIORCOZ E THK ECCH C 30 TNLUSO 20O TGO) Y2T..GII(YIF0 5 29 TNLUSO 20O TGO 28 TNLUSO 60O TGO) Y2T..GII(YIF 27 TNLUSO 50O TGO) Y1T..GII(YIF 26 TNLUSO 60O TGO) INZMSIT..L2)-YII(YBS(AIF 25 TNLUSO 60O TGO) INZMSIT..L1)-YII(YBS(AIF0 4 24 TNLUSO ESATINRDOO C YHE TCKHE C C3 2 N UTOL S0 2TOO G2).XGTI.XIF( I30 2 2 N UTOL SN URET R 1 2 N UTOL S. SEAL.FN=LTSO0 2 20 TNLUSO 40O TGO) X2T.)0 I=1,NV POLCLP 113 IF(VERT(I)) 230,220,220 POLCLP 114 220 M=M+1 POLCLP 115 230 CONTINUE POLCLP 116 J=1 POLCLP 117 DO 295 I=1,NV POLCLP 118 IF(VERT(I)) 295, 240,240 POLCLP 119 240 GO TO (250,260,270,280),J POLCLP 120 250 I1=VERT(I) POLCLP 121 GO TO 290 POLCLP 122 260 I2=VERT(I) POLCLP 123 GO TO 290 POLCLP 124 270 I3=VERT(I) POLCLP 125 GO TO 290 POLCLP 126 280 NLPL=NLP.GII(XIF 19 TNLUSO 30O TGO) X1T..GII(XIF 18 TNLUSO 40O TGO) INZMSIT..L2)-XII(XBS(AIF 17 TNLUSO 40O TGO) INZMSIT..L1)-XII(XBS(AIF0 1 16 TNLUSO S.TENADIORCOX E THK ECCH C 15 TNLUSO S.ITIM LNELIE THN HIIT WRE ATSINPOG INRCIE PHE TIFK ECCH C 14 TNLUSO Z1W+T*I=ZI 13 TNLUSO Y1U+T*I=YI 12 TNLUSO X1I-XIT= 11 TNLUSO W)C*U+B*A+/(D))-Z1W-1*(XC*)+Y1U-1*(XB*=(II X 0 1 N UTOL SV )/Z12-(ZW= 9-L+1 POLCLP 127 CALL PACK (PL(NLPL),I1,I2,I3,VERT(I),M,IND) POLCLP 128 J=0 POLCLP 129 290 J=J+1 POLCLP 130 295 CONTINUE POLCLP 131 GO TO (10,300,310,320),J POLCLP 132 300 I2=0 POLCLP 133 310 I3=0 POLCLP 134 320 I4=0 POLCLP 135 NLPL=NLPL+1 POLCLP 136 CALL PACK(PL(NLPL),I1,I2,I3,I4,M,IND) POLCLP 137 GO TO 10 POLCLP 138 END POLCLP 139 SUBROUTINE RDVIEW RDVIEW 1 C TNLUSO /V1)-YY2=( U 8 N UTOL S0 9TOO GN)MIIZ.SLT).(VBS(AIF 7 TNLUSO X12-=X V 6 N UTOL SN LTSOL CAGILO 5 TNLUSO S.ITIM LNELIE THN HIIT WRSCUOCT INPOG INRCIE P C4 N UTOL SE THF IE.RU.TO TAGFLN LTSOE THS ET SND A DC,, BA,E ANPL C 3 TNLUSO HE TESRCIE P-2 1NELIE THE ERWHT INPOE THS TEPUOM CNETIOUBRSUS HI T C2 N UTOL S) INZMSID,C,B,1, 1 N UTOL SA N,LTSOI,ZII,YII,XI2,,ZY22,,XZ11,,YX1N(UTOL SNETIOUBRSU 1THIS SUBROUTINE READS THE DATA FOR EACH VIEW RDVIEW 2 C CONSISTING OF THE VIEWING VECTOR,(XO,YO,ZO-XL,YL,ZL), RDVIEW 3 C THE DISPLAY SIZE,(S), THE VIEWING ANGLE(ANG), AND RDVIEW 4 C THE DEPTH OF FIELD,(F). IT ALSO READS THE OBJECT RDVIEW 5 C TRANSLATION (TX,TY,TZ), ORIGIN FOR ROTATION,(OX,OY,OZ), RDVIEW 6 C AND ROTATION ANGLES, (RX,RY,RZ). RDVIEW 7 COMMON /PRW1/ X(1000),Y(1000),Z(1000),IXYZ(1000) CPRW1 1 1,NPT,MXPT,NF41 T RO ND E 0 4 OT R0 1TOO G 9 3 OT RZ +OZI3*C3I+*Y32+CXI1*C3)=(N Z 8 3 OT RY +OZI3*C2I+*Y22+CXI1*C2)=(N Y 7 3 OT RX +OZI3*C1I+*Y12+CXI1*C1)=(N X 6 3 OT RZ -ON)Z(I= Z 5 3 OT RY -ON)Y(I= Y 4 3 OT RX -ON)X(I= X 3 3 OT RN GIRI OEW NTOT INPOE OV M C2 3 OT R0 1TOO G0)E..LN)Z(XY(IIF 31 T RO RNTURE) PTNLT..G(NIF 30 T RO +1=N N 0 19 2 OT R1 T-FP=N5PT,NLPT CPRW1 2 2,PL(1000),NPL,MXPL,NFPL,NLPL CPRW1 3 3,LA(1000),LB(1000),NLN,MXLN,NFLN,NLLN CPRW1 4 4,IERR CPRW1 5 COMMON /PRW2/ XO,YO,ZO,XL,YL,ZL,S,D,SD,F CPRW2 1 1,XPMAX,XPMIN,YPMAX,YPMIN,MAXS CPRW2 2 2,TX,TY,TZ,OX,OY,OZ,RX,RY,RZ CPRW2 3 DATA PI/3.14159265/ RDVIEW 10 READ(5,10) XO,YO,ZO,XL,YL,ZL,S,ANG,F RDVIEW 11 WRITE(6,10) XO,YO,ZO,XL,YL,ZL,S,ANG,F RDVIEW 12 10 FORMA N 8 2 OT RT OS*CSACO3=C3 27 T RO NTSIA*OS=C32 C 6 2 OT RA IN-S1=C3 25 T RO NTSIB*OS-CSTCOA*IN*SNBSI3=C2 24 T RO SBCOT*OS+CNTSIA*IN*SNBSI2=C2 23 T RO SACOB*IN=S21 C 2 2 OT RT IN*SNBSIT+OS*CNASIB*OS=C13 C 1 2 OT RT OS*CNBSIT-IN*SNASIB*OS=C12 C 0 2 OT RA OS*CSBCO1=C1 19 T RO B)S(COB=OS C 8 1 OT R) (BIN=SNBSI 17 T RO A)S(COA=OS C 6 1 9T(9F8.2) RDVIEW 13 IF(EOF,5)20,30 RDVIEW 14 20 IERR=1 RDVIEW 15 RETURN RDVIEW 16 30 READ(5,10)TX,TY,TZ,OX,OY,OZ,RX,RY,RZ RDVIEW 17 WRITE(6,10) TX,TY,TZ,OX,OY,OZ,RX,RY,RZ RDVIEW 18 IF(EOF,5)40,60 RDVIEW 19 40 WRITE(6,50) RDVIEW 20 50 FORMAT(43H NO OBJECT TRANSLATION OR MANIPULATION CARD ) RDVIEW 21 GO TO 20 RDVIEW 22 C THE DEPTH OF FIELD IS REALLY IN THE NEGATIVE Z RDVIEW 23 C DIR OT R) (AIN=SNASI 15 T RO T)S(COT=OS C 4 1 OT R) (TIN=SNTSI 13 T RO ADGRDEZ*=R B 2 1 OT RD RAEG*DRYA= 11 T RO ADGRDEX*=R T 0 1 OT R. 80/1PID=RAEG D 9 OT R/ 659215143.I/ PTADA 8 T RO PLR GETEIN 3 2 RWCP RZY,,RRXZ,,OOYX,,OTZY,,TTX2, 2 W2PR CS AX,MINPM,YAXPM,YINPM,XAXPM,X 1 1 2 RWCP ,FSDD,S,L,,ZYLL,,XZOO,,YXO/ W2PR /ONMMCO 5 1 RWCP RRIE4, =ECTION SO NEGATE F. RDVIEW 24 60 F=-F RDVIEW 25 C FIGURE THE DEFAULT VALUES FOR S,D, AND ANG RDVIEW 26 D=SQRT((XO-XL)**2+(YO-YL)**2+(ZO-ZL)**2) RDVIEW 27 IF(S.EQ.0.) GO TO 70 RDVIEW 28 S=S/2. RDVIEW 29 IF(ANG.LE.0.) GO TO 65 RDVIEW 30 C S AND ANG BOTH GIVEN COMPUTE D RDVIEW 31 ANG=ANG*PI /360. RDVIEW 32 D=S*COS(ANG)/SIN(ANG) RDVIEW 33 65 SD=S/D RDVIEW 34 RETURN RDVIEW 4 W1PR CN LL,NLNNFN,XL,MLN,N0)00(1LB),0010A(,L 3 3 1 RWCP PLNLL,FP,NPLMXL,NP),0010L(,P 2 2 1 RWCP PTNLT,FP,NPTMXT,NP1, 1 W1PR C) 0010Z(XY,I0)00(1,Z0)00(1,Y0)00(1 X1/RW/PN MOOM C 5 OT R. ZUTBO ALYALIN FND AY,N HE TSTIR F XUTBO AEDRMFOER P C4 OT RS IONTITAROE THD ANS EEGRDEN IENIV GRE AESGLANE TH C 3 T RO Z. RND,ARYX, RESGLANH UGROTHZ ,OOYX, ONTOI PGHOUHR T C2 OT RG INSSPAS XE AUTBO ATSECBJ OESATOT R35 C S EQUALS 0 RDVIEW 36 70 IF(ANG.LE.0.) GO TO 80 RDVIEW 37 C ANG IS NOT EQUAL TO 0 COMPUTE S RDVIEW 38 ANG=ANG*PI/360. RDVIEW 39 S=D*SIN(ANG)/COS(ANG) RDVIEW 40 GO TO 65 RDVIEW 41 C S AND ANG=0 OR ARE TOO LARGE. USE 45 DEGREES RDVIEW 42 C 1/2 ANGLE DEFAULT RDVIEW 43 80 S=D RDVIEW 44 GO TO 65 RDVIEW 45 END RDVIEW 46 SUBROUTINE ROT ROT 1 C THIS SUBROUTINE