lenny@icus.UUCP (Lenny Tropiano) (07/15/88)
This has been talked about on the net for a few weeks. It was small enough to just post... --- cut here --- --- cut here --- --- cut here --- --- 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 <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of shell archive." # Contents: Makefile README array.c dobits.c grid.c main.c makecprog.c # startup.c testit.c # Wrapped by lenny@icus on Fri Jul 15 08:05:51 1988 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'Makefile' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Makefile'\" else echo shar: Extracting \"'Makefile'\" \(246 characters\) sed "s/^X//" >'Makefile' <<'END_OF_FILE' Xinclude $(MAKEINC)/Makepre.h X XOBJ=main.o grid.o startup.o dobits.o makecprog.o X Xall: $(OBJ) X $(LD) $(LDFLAGS) $(SHAREDLIB) $(OBJ) -o fatbit X Xtestit: testit.o X $(LD) $(LDFLAGS) $(SHAREDLIB) testit.o -o testit X Xinclude $(MAKEINC)/Makepost.h X X X END_OF_FILE if test 246 -ne `wc -c <'Makefile'`; then echo shar: \"'Makefile'\" unpacked with wrong size! fi # end of 'Makefile' fi if test -f 'README' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'README'\" else echo shar: Extracting \"'README'\" \(1377 characters\) sed "s/^X//" >'README' <<'END_OF_FILE' X XWelcome to the fatbit editor .... a combination programming X tool and programming example hacked together by Fred X Hicinbothem in June of 1985. X XThe fatbit editor is used to create a static array which can X be used in your C programs to incorporate pictures into X your application. With some enhancement it could be X used for font or icon creation as well. X XThe tool is used as follows: X X 1. execute fatbit X 2. pick a grid size and use the mouse to light or X erase pixels until you have a picture you like. X 3. use the MAKE C-PROG labelled key to create a file X in the current directory called array.c X 4. exit fatbit X 5. edit the array.c file to name the ARRAY whatever you X please (for use in your program) X 6. stick the array.c file into your application and use X the data array as you please with wrastops or X the like (note the file testit.c which is X provided as an example) X XAs of this date I have not experimented with the use of fatbit Xfor icon or font creation but the concepts are identical - maybe Xsome energetic programmer will define some SLKs for MAKE ICON Xor MAKE FONT. X XAlso, another enhancement would be to load existing "pictures" Xinto the fatbit editor for modification. X XIn the meantime, if you have a development set, enjoy playing Xwith it. If you don't, this is probably a fairly useless tool. X XQuestions, bugs, enhancements to mtuxn!4341fah END_OF_FILE if test 1377 -ne `wc -c <'README'`; then echo shar: \"'README'\" unpacked with wrong size! fi # end of 'README' fi if test -f 'array.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'array.c'\" else echo shar: Extracting \"'array.c'\" \(657 characters\) sed "s/^X//" >'array.c' <<'END_OF_FILE' X/* array ARRAY contains a picture 48 pixels wide and 19 pixels high. X for wrastop calls use srcwidth = 6, width = 48, and height = 19. */ Xstatic unsigned short ARRAY[57] = { X 0x0000, 0x0000, 0x0000, 0x0000, 0x0800, 0x0000, 0x0000, 0x1000, X 0x0000, 0xfffc, 0x3fff, 0x0000, 0xfffc, 0x3fff, 0x0000, 0x1800, X 0x1000, 0x0000, 0x1800, 0x0800, 0x0000, 0x1800, 0x0000, 0x0004, X 0x1800, 0x0000, 0x0008, 0x9800, 0xfde7, 0x001f, 0x9800, 0x2024, X 0x0008, 0x9800, 0x2024, 0x0004, 0x9800, 0x21e7, 0x0000, 0x9800, X 0x2100, 0x0000, 0x9800, 0x2100, 0x0000, 0x9800, 0x210f, 0x0000, X 0x0000, 0x0100, 0x0000, 0xfff8, 0x01ff, 0x0000, 0x0000, 0x0000, X 0x0000 }; END_OF_FILE if test 657 -ne `wc -c <'array.c'`; then echo shar: \"'array.c'\" unpacked with wrong size! fi # end of 'array.c' fi if test -f 'dobits.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'dobits.c'\" else echo shar: Extracting \"'dobits.c'\" \(922 characters\) sed "s/^X//" >'dobits.c' <<'END_OF_FILE' X#include <tam.h> X#include <sys/mouse.h> Xextern unsigned short patblack[]; Xextern unsigned short patwhite[]; Xextern int wp; Xstruct umdata um; Xextern int OFFSET,HORBITS,VERBITS,ROWS,COLMS; Xdobits(wn,button,x,y) Xint wn,button,x,y; X X{ Xunsigned short *pattern; Xint flags; Xint xnew,ynew; Xint xras,yras; X Xif(button==MBUTM) pattern=patblack; Xelse pattern=patwhite; X Xxras=x/HORBITS; Xxnew=xras*HORBITS+1; Xyras=y/VERBITS; Xynew=yras*VERBITS+1; X Xif(button) X{ Xwrastop(wn,0,0,0,0,0,0,xnew,ynew,HORBITS-1,VERBITS-1,SRCPAT,DSTSRC,pattern); X/* change the pixel in the real image in upper left */ Xwrastop(wp,0,0,0,0,0,0,xras,yras,1,1,SRCPAT,DSTSRC,pattern); X X} X X X Xif(button) flags=MSDOWN|MSUP|MSOUT; X else flags=MSDOWN; X resetmouse(wn,xnew,ynew,flags); X X} Xresetmouse(wn,xnew,ynew,flags) Xint wn,xnew,ynew,flags; X{ X um.um_flags = flags; X um.um_x = xnew; X um.um_y = ynew; X um.um_w = HORBITS; X um.um_h = VERBITS; X wsetmouse (wn, &um); X} END_OF_FILE if test 922 -ne `wc -c <'dobits.c'`; then echo shar: \"'dobits.c'\" unpacked with wrong size! fi # end of 'dobits.c' fi if test -f 'grid.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'grid.c'\" else echo shar: Extracting \"'grid.c'\" \(559 characters\) sed "s/^X//" >'grid.c' <<'END_OF_FILE' X#include <tam.h> Xint OFFSET,HORBITS,VERBITS,ROWS,COLMS; Xextern unsigned short patblack[]; Xextern unsigned short patwhite[]; Xextern int box; Xgrid(wn) Xint wn; X{ X register int i; X unsigned short *pattern; X pattern = patwhite; X for ( i=0;i<=COLMS;i++) X wrastop(wn,0,0,0,0,(HORBITS*i)+OFFSET,1,(HORBITS*i)+OFFSET,1,1,(VERBITS*ROWS)-1,SRCPAT,DSTSRC,pattern); X for ( i=0;i<=ROWS;i++) X wrastop(wn,0,0,0,0,OFFSET+1,(VERBITS*i),OFFSET+1,(VERBITS*i),(HORBITS*COLMS)-1,1,SRCPAT,DSTSRC,pattern); X X wprompt(wn,"Left or Right button fills in, middle button erases"); X X} END_OF_FILE if test 559 -ne `wc -c <'grid.c'`; then echo shar: \"'grid.c'\" unpacked with wrong size! fi # end of 'grid.c' fi if test -f 'main.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'main.c'\" else echo shar: Extracting \"'main.c'\" \(905 characters\) sed "s/^X//" >'main.c' <<'END_OF_FILE' X#include <tam.h> X Xextern int wp; Xint OFFSET,HORBITS,VERBITS,ROWS,COLMS; Xchar gridon=0; Xextern unsigned short patblack[]; X X Xmain(argc,argv) Xint argc; Xchar *argv[]; X{ X int wn; X X int key; X int mousex, mousey, mouseb, mouser; X int mouse; X Xwn=startup(); X X Xwhile (1) { Xkey = wgetc(wn); X Xswitch(key) { Xcase Mouse: X wreadmouse(wn,&mousex,&mousey,&mouseb,&mouser); X if(gridon) X { mouse=1; dobits(wn,mouseb,mousex,mousey); } X break; Xcase F1: X HORBITS=9; COLMS=54; X VERBITS=6; ROWS=40; X clearit(wn,wp); X grid(wn); X gridon=1; X break; Xcase F2: X makecprog(wn); X break; Xcase F7: X clearit(wn,wp); X gridon=0; X break; Xcase F8: X HORBITS=3; COLMS=162; X VERBITS=3; ROWS=80; X clearit(wn,wp); X grid(wn); X gridon=1; X break; Xcase Exit: X exit(0); X } X} X} X Xclearit(wn,wp) Xint wn,wp; X{ X wrastop(wp,0,0,0,0,0,0,0,0,162,84,SRCPAT,DSTSRC,patblack); X wrastop(wn,0,0,0,0,0,0,0,0,486,240,SRCPAT,DSTSRC,patblack); X} END_OF_FILE if test 905 -ne `wc -c <'main.c'`; then echo shar: \"'main.c'\" unpacked with wrong size! fi # end of 'main.c' fi if test -f 'makecprog.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'makecprog.c'\" else echo shar: Extracting \"'makecprog.c'\" \(2407 characters\) sed "s/^X//" >'makecprog.c' <<'END_OF_FILE' X#include <kcodes.h> X#include <tam.h> Xextern int OFFSET,HORBITS,VERBITS,ROWS,COLMS; Xextern unsigned short patwhite[]; Xextern int wp; Xmakecprog(wn) Xint wn; X{ X char *filename; X unsigned short ARRAY[960]; X int mousex, mousey, mouseb, mouser; X int xfirst, yfirst, xnew, ynew; X int xsecond, ysecond; X int lim; X int ii,jj; X char *fd, *fopen(); X int shorts,width,height; X int key; X Xwprompt(wn,"Use left mouse key to highlight upper left pixel of array."); X X while (1) { X key = wgetc(wn); X X switch(key) { X case Mouse: X wreadmouse(wn,&mousex,&mousey,&mouseb,&mouser); X goto program1; X case Cancl: X case Exit: X return(0); X default: X break; X } X } X X Xprogram1: X Xxfirst=mousex/HORBITS; Xyfirst=mousey/VERBITS; X Xxnew=xfirst*HORBITS+1; Xynew=yfirst*VERBITS+1; X Xwrastop(wn,0,0,0,0,0,0,xnew,ynew,HORBITS-1,VERBITS-1,SRCPAT,DSTSRC,patwhite); X X Xwprompt(wn,"Use left mouse key to highlight lower right pixel of array."); X X while (1) { X key = wgetc(wn); X X switch(key) { X case Mouse: X wreadmouse(wn,&mousex,&mousey,&mouseb,&mouser); X goto program2; X case Cancl: X case Exit: X return(0); X default: X break; X } X } X Xprogram2: X Xxsecond=mousex/HORBITS; Xysecond=mousey/VERBITS; Xxnew=xsecond*HORBITS+1; Xynew=ysecond*VERBITS+1; X Xwrastop(wn,0,0,0,0,0,0,xnew,ynew,HORBITS-1,VERBITS-1,SRCPAT,DSTSRC,patwhite); X X/* we now have the upper left and lower right corners - since the array X must be 16*N pixels (bits) wide - we compute that */ X Xshorts=(xsecond-xfirst)/16 + 1; /* number of shorts wide */ Xwidth=shorts*16; Xheight=ysecond-yfirst+1; X X X/* put the chosen segment into the ARRAY array */ X Xwrastop(wp,0,0,ARRAY,shorts*2,xfirst,yfirst,0,0,width,height,SRCSRC,DSTSRC,0); X X Xwprompt(wn,""); X X/* open the file and stick the program in there */ X Xfilename="array.c"; Xfd=fopen(filename,"a"); Xfprintf(fd,"/* array ARRAY contains a picture %d pixels wide and %d pixels high.\n for wrastop calls use srcwidth = %d, width = %d, and height = %d. */\n",width,height,shorts*2,width,height); Xfprintf(fd,"static unsigned short ARRAY[%d] = { \n",height*shorts); Xfor (ii=0;ii<height;ii++) X{ X for(jj=0;jj<shorts;jj++) X { X lim=ii*shorts+jj; X X if(lim<height*shorts-1) X fprintf(fd," 0x%04x,",ARRAY[lim]); X else fprintf(fd," 0x%04x ",ARRAY[lim]); X if((ii*shorts+jj+1)%8 == 0) X fprintf(fd," \n"); X } X} Xfprintf(fd," };\n"); Xfclose(fd); Xwprompt(wn,"Left or Right button fills in, middle button erases"); X} END_OF_FILE if test 2407 -ne `wc -c <'makecprog.c'`; then echo shar: \"'makecprog.c'\" unpacked with wrong size! fi # end of 'makecprog.c' fi if test -f 'startup.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'startup.c'\" else echo shar: Extracting \"'startup.c'\" \(1156 characters\) sed "s/^X//" >'startup.c' <<'END_OF_FILE' X#include <tam.h> Xstruct umdata um; Xint wp; Xstartup() X{ X int wn; X int i; X struct uwdata uw; X X /* Make sure we're on a bitmap display! */ X if ( ioctl(1,WIOCGETD, &uw) != 0 ) { X fprintf(2,"You must run the fatbit artist on a bitmap display\n"); X exit(1); X } X /* Dump stdin, stdout, stderr, open a new window, dup to all three. */ X close(0); X close(1); X close(2); X wn = open("/dev/window",2); X dup(wn); /* dup to 1 */ X dup(wn); /* dup to 2 */ X winit(); X keypad(0,1); X wn = wcreate(1,0,20,54,BORDCANCEL); X wp = wcreate(14,58,7,18,BORDCANCEL); X wselect(wn); X wputs(wp,"\033[2J\033[=1C"); X wputs(wn,"\033[2J\033[=1C"); X wlabel(wn,"Experimental Fatbit Artist"); X wuser(wn,"Fatbit Artist"); X wprompt(wn,"Choose an action from among the function keys ....."); X wuser(wp,"Fatbit Image"); X wlabel(wp,"Real Image"); X wprompt(wp,"THIS IS THE ACTUAL IMAGE "); X um.um_flags = MSDOWN; X um.um_x = 0; X um.um_y = 0; X um.um_w = 1; X um.um_h = 1; X wsetmouse (wn, &um); X X X wslk(wn,0," 48x40 MAKE CLEAR 160x80 " ," GRID C-CODE GRID GRID ",0); X return(wn); X} X END_OF_FILE if test 1156 -ne `wc -c <'startup.c'`; then echo shar: \"'startup.c'\" unpacked with wrong size! fi # end of 'startup.c' fi if test -f 'testit.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'testit.c'\" else echo shar: Extracting \"'testit.c'\" \(1107 characters\) sed "s/^X//" >'testit.c' <<'END_OF_FILE' X/* array ARRAY contains a picture 48 pixels wide and 19 pixels high. X for wrastop calls use srcwidth = 6, width = 48, and height = 19. */ Xstatic unsigned short ARRAY[57] = { X 0x0000, 0x0000, 0x0000, 0x0000, 0x0800, 0x0000, 0x0000, 0x1000, X 0x0000, 0xfffc, 0x3fff, 0x0000, 0xfffc, 0x3fff, 0x0000, 0x1800, X 0x1000, 0x0000, 0x1800, 0x0800, 0x0000, 0x1800, 0x0000, 0x0004, X 0x1800, 0x0000, 0x0008, 0x9800, 0xfde7, 0x001f, 0x9800, 0x2024, X 0x0008, 0x9800, 0x2024, 0x0004, 0x9800, 0x21e7, 0x0000, 0x9800, X 0x2100, 0x0000, 0x9800, 0x2100, 0x0000, 0x9800, 0x210f, 0x0000, X 0x0000, 0x0100, 0x0000, 0xfff8, 0x01ff, 0x0000, 0x0000, 0x0000, X 0x0000 }; X X X#include <tam.h> X Xmain() X{ X Xint srcwidth,width,height,wn; Xint i; X X/* The following parameters depend on the size of ARRAY */ Xsrcwidth=6; width=48; height=19; X X X/* Xclose(0);close(1);close(2); Xwn=open("/dev/window",2); Xdup(wn);dup(wn); X*/ Xwinit(); Xwn=wcreate(10,10,12,50,0); Xfor (i=0;i<height*width/16;i++) X wprintf(wn," ARRAY[%d]=%d\n",i,ARRAY[i]); X X X Xwrastop(wn,ARRAY,srcwidth,0,0,0,0,0,0,width,height,SRCSRC,DSTSRC,0); X Xsleep(10); Xwexit(); X X} END_OF_FILE if test 1107 -ne `wc -c <'testit.c'`; then echo shar: \"'testit.c'\" unpacked with wrong size! fi # end of 'testit.c' fi echo shar: End of shell archive. exit 0 -- Paper-net: Lenny Tropiano | @-net: lenny@icus.UUCP ICUS Software Systems | !-net: ...att \ PO Box 1 | boulder \ Islip Terrace, NY 11752 | talcott !icus!lenny Vocal-net: (516) 582-5525 [work] | pacbell / (516) 968-8576 [home] | sbcs / Telex-net: 154232428 ICUS | Another-net: attmail!icus!lenny