Xref: utzoo unix-pc.sources:331 comp.sys.att:6854 Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!att!icus!limbic!gil From: gil@limbic.UUCP (Gil Kloepfer Jr.) Newsgroups: unix-pc.sources,comp.sys.att Subject: Repost: FaceSaver display for UNIX-pc (1 of 2) Message-ID: <516@limbic.UUCP> Date: 30 Jun 89 03:54:55 GMT Followup-To: unix-pc.sources Organization: ICUS Software Systems, Islip, NY Lines: 859 I sent out a cancel message for the last posting of this program, although some may have leaked by. The last posting was truncated by some internet sites. This one should get through OK. Those that were at the Summer USENIX conference probably participated in the FaceSaver project, which digitized lots of our faces and put them in an archive on uunet. This is a program for the UNIX-pc which allows you to display those files. Enjoy. COMING SOON: UNIX-pc utility to simplify the use of on-line manual pages ====== | Gil Kloepfer, Jr. | ICUS Software Systems/Bowne Management Systems (depending on where I am) | ...icus!limbic!gil or gil@icus.islp.ny.us -----Cut Here---- #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh 122.ft.uue <<'END_OF_122.ft.uue' Xbegin 644 122.ft XM !C@ &"@@ &"P#W!@ "^@$( _@& XM ,( P,"^ 8 Q %" 'X!@ ##@0* ?@& ,6! @!^ 8 R(%" 'X!@ #*@$# XM _@& ,R PD"^ 8 S #"0'X!@ #.@4% ?H& -$!04!^@8 T8"! +^!@ # XM2 0! ?P& -( @("_@8 T($" 'X!@ #/@0' ?D& -& P! ,!^P8 XM Z0$!P'Y!@ #H@0( ?@& .H!0D!^ 8 [ $" 'X!@ #N@4( ?@& /"! @! XM^ 8 \H$" 'X!@ #T@0( ?@& /:! @!^ 8 ^($" 'X!@ #Z@0( ?@& /R XM P@"^ 8 _H$" 'X!@ $ @4( ?@& 0*! @!^ 8 !!(%" 'X!@ $&@4( ?@& XM 0B! @!^ 8 !"H$" 'X!@ $,@4) ?@& 0Z!0@!^ 8 !$0$" 'X!@ $3 4( XM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0 ) D "0 ' ( @ " ( XM @ " < " ( @ " ) D "0 & D "0 % 4 P % D $0 ! $ 0 ! XM $ 0 ! \ $0 1 !L %0 5 !$ $0 1 !$ $P 5 !D $0 1 !$ $0 & D XM"0 ) D "0 ) 8 !P ) D "0 ' $ 0 ! 8 "0 ) D "0 ) 4 "@ 0 XM < "0 ) D !P % D $0 . $ 0 " 0 " ( < 'P $ 0 ! $ 0 XM! $ D "0 ) D "0 ) D !@ 1 !$ $0 1 H "@ $ 0 $0 1 !$ %0 5 XM !4 "@ * !$ $0 * 0 ! * !$ $0 1 !$ "@ * 0 ! $ 0 #P ( 0 XM! " ( 0 / < 0 ! $ 0 ! $ 0 ' $ 0 " ( ! $ @ " ' XM 0 ! $ 0 ! $ 0 !P $ H $0 _ , @ $ < " . D "0 . $ XM 0 ' D "0 ) D !P . $ 0 ! $ #@ ( @ #@ ) D "0 ) X !@ ) XM \ 0 ! X ' " ( #P " ( @ " X "0 ) D #@ ( @ !P ! $ XM!P ) D "0 ) D !@ 8 ! $ 0 ! / 8 ' 0 ! $ 0 ! $ XM , 0 ! D "0 % < "0 1 8 ! $ 0 ! $ 0 #P + !4 %0 5 !4 XM$0 ' D "0 ) D "0 & D "0 ) D !@ ' D "0 ) D !P ! $ #@ ) XM D "0 ) X " ( T P ! $ 0 ! X 0 " 0 " ' ( @ / ( XM @ " ( # ) D "0 ) D #@ 1 !$ $0 * H ! 1 !4 %0 5 H "@ 1 XM H ! $ H $0 1 !$ "@ * 0 ! $ , #P $ 0 @ " \ " $ 0 XM! # 0 ! $ @ 0 ! $ 0 ! 0 ! $ 0 ! $ @ " ( # " XB ( @ ! !( %0 ) #\ /P _ #\ /P _ #\ /P _ #\ /P$ X Xend END_OF_122.ft.uue if test 3049 -ne `wc -c <122.ft.uue`; then echo shar: \"122.ft.uue\" unpacked with wrong size! fi # end of overwriting check fi if test -f Makefile -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"Makefile\" else echo shar: Extracting \"Makefile\" \(781 characters\) sed "s/^X//" >Makefile <<'END_OF_Makefile' X# X# Makefile for facedisp version 1.0 X# By Gil Kloepfer, Jr. ICUS Software Systems 6/23/89 X# X XCFLAGS=-v -O XLDFLAGS=-s XSHAREDLIB=/lib/shlib.ifile /lib/crt0s.o XDESTDIR=/usr/lbin XMANDIR=/usr/man/man1 X Xfacedisp: facedisp.o raster.o X $(LD) $(LDFLAGS) -o facedisp facedisp.o raster.o $(SHAREDLIB) X Xinstall: facedisp X /bin/mv facedisp $(DESTDIR) X /bin/chmod 755 $(DESTDIR)/facedisp X /bin/chown bin $(DESTDIR)/facedisp X /bin/chgrp bin $(DESTDIR)/facedisp X /bin/mv facedisp.1 $(MANDIR) X /bin/chmod 644 $(MANDIR)/facedisp.1 X /bin/chown bin $(MANDIR)/facedisp.1 X /bin/chgrp bin $(MANDIR)/facedisp.1 X /bin/mv 122.ft /usr/lib/wfont X /bin/chmod 644 /usr/lib/wfont/122.ft X /bin/chown bin /usr/lib/wfont/122.ft X /bin/chgrp bin /usr/lib/wfont/122.ft X Xclean: X rm -f facedisp.o raster.o core END_OF_Makefile if test 781 -ne `wc -c README <<'END_OF_README' X"README" file for facedisp v1.0 Last update: 6/27/1989 X XThis "shar" file contains a program which allows a FaceSaver file to be Xdisplayed on the UNIX-pc's single-intensity monochrome bitmapped display. XMuch of the theory necessary to write the program was obtained from the X"sunfaced" program by D. Murali Raju. X XInstallation is easy. The makefile is set so that you can "make facedisp" Xto make the program alone, or "make install" to install it on your system. XYou should uudecode the font file BEFORE invoking "make install." The Xmakefile should execute without modification on your UNIX-pc, but it would Xbe a good idea to check it first. Again, if you don't uudecode the font Xfile before you perform the make, the font file will not be placed in X/usr/lib/wfont, and you won't get the headers in smaller print. X XYou may check your installation by invoking facedisp on file "gil," which Xis the FaceSaver file for the author of this program (me!). X XThe program works by reading the face file in its entirety, then formatting Xand coding the bitmap intensity data into a format close to what the XUNIX-pc requires. This bitmap is then pasted to the screen and the Xheader information is displayed over a blank section of the bitmapped Xdisplay. X XIntensities are coded by using a 3x3 dither matrix. The dither matrix Xis a codification and grouping of pixels which are grouped in such a way Xthat they appear on the display as "one" multi-intensity pixel. This X3x3 matrix gives a total of nine different shades of "grey." I have chosen Xthe values so that the grey scales increase in a linear fashion. I don't Xsuggest fooling with the values. It took a good deal of work to find ones Xthat seemed to look good for a majority of faces. X XOne major advantage of this program over sunfaced is that it can be modified Xfairly easily to work on a wide range of different machines. One should Xlook at the file "raster.c" to find the names of all the raster routines, Xand then write equivalent routines for their favorite monitor. There is Xa #define which sets the pixel ratio (width to height) which should be Xdefined for your particular system. I used a ruler to measure a NxN pixel Xarray and computed the value using "bc." Your mileage may vary. On the XUNIX-pc, the pixels are taller than wider, so the "y" values are all Xmultiplied by 0.64. Also note the direct writes to the window will Xmore than likely need to be changed. The escape sequences do font Xchanges and cursor addressing. X XThe format of the face files can be obtained by writing sending a request Xto the FaceSaver daemon at uunet!faceserver ("send format"), while help Xcan be requested using "send help." The full index is rather lengthy... Xbe forewarned. X XI would appreciate hearing any comments or improvements that you may have Xfor this program. Please mail a copy of all modifications or ports that Xyou make to the code so I can keep an up-to-date copy here. I will do Xmy best to keep an up-to-date version posted as changes come in. X XAgain, my thanks to D. Murali Raju for the theory in his program, to Helen Xand Jeff for discussing with me their ideas at USENIX, and to Lenny for Xlending a hand and beta testing this beast. Finally, thanks to Muhammad XBenten for his 122x28 font that he posted a while ago, and which appeared Xin some recent postings. X XPlease send any correspondence regarding this program to me at icus!limbic!gil. X XGil Kloepfer, Jr. XICUS Software Systems, Western Development Center XEast Meadow, Long Island, NY Xicus!limbic!gil END_OF_README if test 3525 -ne `wc -c facedisp.c <<'END_OF_facedisp.c' X/***************************************************************************\ X * File name: facedisp.c * X * * X * Purpose: Display a face file that is generated by the folks * X * at the FaceSaver project on the UNIX-pc video * X * display. * X * * X * Programmer: Gil Kloepfer, Jr. ICUS Software Systems * X * * X * Revision history: 22-Jun-89 1.0 Program created * X * 28-Jun-89 1.1 Multiple files on argument line * X * (Lenny Tropiano ) * X * * X * Restrictions: This program is specifically written for the * X * UNIX-pc (7300 or 3B1) * X * * X * This program requires the use of the ICUS raster * X * function library (raster.c). * X * * X * Usage: This program takes one argument, that is the name * X * of a FaceSaver file to be displayed. If this arg * X * is missing, it will attempt to read this file from * X * stdin. All errors are displayed on stderr, and * X * all output is displayed on another window. * X * * X * Other credits: Thanks to D. Murali Raju for his insight which I * X * obtained from his sunfaced program. Thanks also * X * to Lenny, Helen, and Jeff for their encouragement * X * and suggestions. * X * * X * Copyright/ (C) 1989 Gil Kloepfer, Jr., ICUS Software Systems * X * Disclaimer: All Rights Reserved * X * Permission is granted to use, copy, or redistribute* X * this software provided that this header in its * X * entirety is kept in the source code, that all * X * copyright notices are left intact, and that it is * X * not distributed or used for monetary gain of any * X * kind without the express, written permission of * X * the copyright holder(s). Furthermore, if this * X * software is modified, all changes should be mailed * X * to icus!gil. * X * * X * The user of this program agrees and understands * X * that this software is distributed on an "as-is" * X * basis, and shall not use this program as the basis * X * for any claims, now or in the future, against * X * any individual, organization, or entity. * X\***************************************************************************/ X X#include X#include X#include X X#define XWLIMIT 700 /* Horiz size so we can add text */ X#define YWLIMIT 180 /* Vert size so we can add text */ X#define S_RATIO 0.64 /* Pixel size ratio horizontal/vertical */ X#define DITHER 3 /* Dither matrix size (do not change!) */ X#define MAX_INFO 20 /* Maximum header lines in face file */ X X#ifndef TINYFONT X# define TINYFONT "/usr/lib/wfont/122.ft" X#endif X Xchar *progname; /* Keep the name of this program global */ X X/* X * Variables which originate from the read_face() routine and are used in X * various places throughout the program X */ X Xchar *infoline[MAX_INFO]; /* Up to 20 pointers to header information strings */ Xint xpixels; /* Number of x pixels as read from the face file */ Xint ypixels; /* Number of y pixels as read from the face file */ Xint *picdata; /* Picture data array */ X X X/* X * Subroutine "main" ... we all know what this does... X */ X Xmain(argc,argv) Xint argc; Xchar *argv[]; X{ X int curarg, i; X X /* Initialize some of the variables */ X X infoline[0]=NULL; /* End of headers marker */ X progname=argv[0]; X X /* Read the face file */ X X curarg = 1; /* if nothing there, it's NULL */ X X do { X X read_face(argv[curarg]); X X /* Display the picture */ X X disp_picture(); X X free(picdata); /* do some memory housekeeping */ X for (i=0; i 0) { X for (i=0; i= 93) rast_point(px,py+2,1); X if (inten >= 31) rast_point(px+1,py+2,1); X if (inten >= 186) rast_point(px+2,py+2,1); X if (inten >= 217) rast_point(px,py+1,1); X if (inten >= 0) rast_point(px+1,py+1,1); X if (inten >= 248) rast_point(px+2,py+1,1); X if (inten >= 124) rast_point(px,py,1); X if (inten >= 62) rast_point(px+1,py,1); X if (inten >= 155) rast_point(px+2,py,1); X} X X X/* X * This subroutine is called after the size of the window is determined X * and will make a border around the window and picture X */ X Xdraw_border() X{ X int x, y, xedge, xpedge, yedge; X X rast_getlim(&xedge,&yedge); X xpedge=(DITHER*xpixels)-1; X X for (x=0; x<=xedge; x++) { X rast_point(x,0,1); X rast_point(x,yedge,1); X } X X for (y=0; y<=yedge; y++) { X rast_point(0,y,1); X rast_point(xpedge,y,1); X rast_point(xedge,y,1); X } X} X X X/* X * Write some data to the window. Note that this data doesn't get saved, X * so if you repaste the display you will lose what you displayed! X */ X Xwin_write(wfd,line,col,slot,text) Xint wfd, line, col, slot; Xchar *text; X{ X char string[128]; X X sprintf(string,"\033[%d;%dH\033[1%1dm%s", line, col, slot, text); X write(wfd,string,strlen(string)); X} X X X/* X * Load a font into a slot number (thanks Lenny) X */ X Xload_font(window,slot,font) Xint window, slot; Xchar *font; X{ X struct ufdata ufd; X X ufd.uf_slot = slot; X strcpy(ufd.uf_name,font); X ioctl(window,WIOCUFONT,&ufd); /* unload any previous font */ X X if (ioctl(window,WIOCLFONT,&ufd) < 0) { X fprintf(stderr,"%s: cannot load font %s -- continuing\n", X progname, font); X } X} END_OF_facedisp.c if test 9424 -ne `wc -c raster.c <<'END_OF_raster.c' X/***************************************************************************\ X * File name: raster.c * X * * X * Purpose: Library of functions used to address individual * X * pixels in the UNIX-pc video display using raster * X * operations. * X * * X * rast_init() - Startup raster functions and open * X * a window to work with. * X * rast_clear() - Clear the raster bitmap. Called * X * automatically when rast_init() is called. * X * rast_point() - Set or reset a point in the bitmap * X * rast_paste() - Paste the bitmap to the display * X * rast_close() - Close and stop the raster functions * X * rast_getwin() - Return file descriptor of window * X * rast_getlim() - Return X and Y screen limits * X * * X * Programmer: Gil Kloepfer, Jr. ICUS Software Systems * X * * X * Revision history: 22-Jun-89 1.0 Program created * X * * X * Restrictions: This program is specifically written for the * X * UNIX-pc (7300 or 3B1) * X * * X * Copyright/ (C) 1989 Gil Kloepfer, Jr., ICUS Software Systems * X * Disclaimer: All Rights Reserved * X * Permission is granted to use, copy, or redistribute* X * this software provided that this header in its * X * entirety is kept in the source code, that all * X * copyright notices are left intact, and that it is * X * not distributed or used for monetary gain of any * X * kind without the express, written permission of * X * the copyright holder(s). Furthermore, if this * X * software is modified, all changes should be mailed * X * to icus!gil. * X * * X * The user of this program agrees and understands * X * that this software is distributed on an "as-is" * X * basis, and shall not use this program as the basis * X * for any claims, now or in the future, against * X * any individual, organization, or entity. * X\***************************************************************************/ X X#include X#include X#include X X/* X * The following 2 defines define some limits of the screen which don't X * changed, but are defined in lieu of hard coding some cryptic numbers X */ X X#define X_LIMIT 60 /* Max X chunks display can handle */ X#define Y_LIMIT 288 /* Max Y chunks display can handle */ X X/* X * The following variables are control variables for use with the raster X * display routines only and should not be accessed or modified directly X * by a user program. X */ X Xstatic unsigned short r_image[X_LIMIT][Y_LIMIT]; X Xstatic unsigned short r_masks[16] = { X 0x0001,0x0002,0x0004,0x0008, X 0x0010,0x0020,0x0040,0x0080, X 0x0100,0x0200,0x0400,0x0800, X 0x1000,0x2000,0x4000,0x8000 }; X Xstatic int r_window; /* Window channel for raster operations */ Xstatic int r_xsize; /* X-size (in pixels) of the current window */ Xstatic int r_ysize; /* Y-size (in pixels) of the current window */ Xstatic struct uwdata r_wcntl; /* Window control structure */ Xstatic struct urdata r_rast; /* Rastop control structure */ Xstatic unsigned short r_data[16]; /* Rastop temp data area */ X X X/* X * Initialize the raster display function package. This function must X * be called before the other functions are invoked. X * X * xsize and ysize are the size to open the window in pixels X */ X Xrast_init(xsize,ysize) Xint xsize, ysize; X{ X X /* Assign xsize and ysize to their corresponding internal vars */ X X r_xsize=xsize; X r_ysize=ysize; X X /* Complain if the x or y sizes are outside the legal ranges */ X X if (r_xsize > 720 || r_ysize > 288 || r_xsize <1 || r_ysize < 1) { X fprintf(stderr,"(rast_init): xs=%d ys=%d size out of range\n", X r_xsize, r_ysize); X exit(2); X } X X /* Open the window for raster I/O */ X X if ((r_window=open("/dev/window",O_RDWR)) < 0) { X perror("window device"); X exit(2); X } X X /* Shut off the cursor so we aren't bothered by the flashing */ X X write(r_window,"\033[=1C",5); X X /* Set-up some window parameters, including the size */ X X ioctl(r_window,WIOCGETD,&r_wcntl); X r_wcntl.uw_x = 0; X r_wcntl.uw_y = 0; X r_wcntl.uw_width = r_xsize+16; X r_wcntl.uw_height = r_ysize+16; X r_wcntl.uw_uflags = NBORDER; X ioctl(r_window,WIOCSETD,&r_wcntl); X X /* Setup raster operation data structure */ X X r_rast.ur_srcbase=NULL; X r_rast.ur_srcwidth=0; X r_rast.ur_dstbase=NULL; X r_rast.ur_dstwidth=0; X r_rast.ur_width=16; X r_rast.ur_height=16; X r_rast.ur_srcop=SRCPAT; X r_rast.ur_dstop=DSTSRC; X r_rast.ur_pattern=r_data; X X /* Clear out the bitmap */ X X rast_clear(); X} X X X/* X * Clear the raster image arrays X */ X Xrast_clear() X{ X register int i, j; X X for (i=0; i= r_xsize || x < 0 || y >= r_ysize || y < 0) { X fprintf(stderr,"(rast_point): x=%d y=%d xm=%d ym=%d -- out of bounds\n", X x, y, r_xsize, r_ysize); X exit(2); X } X X /* Get the chunk coordinates for this pair */ X X xchnk=x>>4; /* This divides 16 and tosses the remainder */ X ychnk=r_ysize-y-1; /* Keep it in cartesian direction */ X X /* Set the bit offset within the chunk to the value */ X X if (val) X r_image[xchnk][ychnk] |= r_masks[x%16]; X else X r_image[xchnk][ychnk] &= ~r_masks[x%16]; X} X X X/* X * Flush out the raster buffer to the screen. This will draw the whole X * raster image that could possibly be stored. Not the most efficient X * method in the world, but useful. X */ X Xrast_paste() X{ X register int i, j, k; X int xchnk; X X xchnk=(r_xsize>>4) + (r_xsize%16 ? 1:0); X for (i=0; i