home *** CD-ROM | disk | FTP | other *** search
- Path: uunet!cs.utexas.edu!swrinde!mips!msi!dcmartin
- From: lfernand@ee.ryerson.ca (luis fernandes)
- Newsgroups: comp.sources.x
- Subject: v16i045: X abacus, Part04/04
- Message-ID: <1992Feb5.150000.21043@msi.com>
- Date: 5 Feb 92 15:00:00 GMT
- References: <csx-16i042-xabacus@uunet.UU.NET>
- Sender: dcmartin@msi.com (David C. Martin - Moderator)
- Organization: Molecular Simulations, Inc.
- Lines: 392
- Approved: dcmartin@msi.com
- Originator: dcmartin@fascet
-
- Submitted-by: lfernand@ee.ryerson.ca (luis fernandes)
- Posting-number: Volume 16, Issue 45
- Archive-name: xabacus/part04
-
- # into a shell via "sh file" or similar. To overwrite existing files,
- # type "sh file -c".
- # The tool that generated this appeared in the comp.sources.unix newsgroup;
- # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
- # If this archive is complete, you will see the following message at the end:
- # "End of archive 4 (of 4)."
- # Contents: Imakefile Lesson2.cmd Lesson3.cmd demo.c maindefs.h
- # patchlevel.h
- # Wrapped by dcmartin@snoopy on Mon Jan 13 16:06:32 1992
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'Imakefile' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'Imakefile'\"
- else
- echo shar: Extracting \"'Imakefile'\" \(1026 characters\)
- sed "s/^X//" >'Imakefile' <<'END_OF_FILE'
- X#
- X# run makedepend for dependancies
- X# -g enable dbx debugging info;
- XCDEBUGFLAGS = -g
- X
- X#-DDEBUG will '#define DEBUG' statements (trace)
- X#CDEBUGFLAGS = -DDEBUG
- X
- X#Optimize
- X#CDEBUGFLAGS = -O
- X
- X# -lm enables the math lib (needed if you #include <math.h>)
- X#EXTRA_LOAD_FLAGS = -lm
- X
- XSRCS= main.c Xinit.c aba.c demo.c
- XOBJS= main.o Xinit.o aba.o demo.o
- X
- XLOCAL_LIBRARIES = $(XLIB) $(XTOOLLIB)
- X
- XComplexProgramTarget(xabacus)
- X
- X# Distribution: Make the shar-files ~no bigger than 64K
- Xshar: main.c Xinit.c aba.c demo.c Imakefile Makefile README xabacus.man XAbacus.ad icon.bm Lesson1.cmd Lesson2.cmd Lesson3.cmd xabacus.man XAbacus.ad
- X shar -s 64000 README *.[ch] xabacus.man I* Makefile icon.bm *.cmd XAbacus.ad
- X# Distribution: split the PS file into 2 files & shar them assuming the source
- X# can be contained in shar1 & shar2
- Xpsshar: abacus.ps
- X split -2500 abacus.ps abacus.ps
- X shar -h shar3 abacus.psaa
- X shar -h shar4 abacus.psab
- X
- X# join 2 PS files to create Abacus.ps
- Xps:
- X cat abacus.psaa abacus.psab >Abacus.ps
- X rm -f abacus.ps??
- X
- END_OF_FILE
- if test 1026 -ne `wc -c <'Imakefile'`; then
- echo shar: \"'Imakefile'\" unpacked with wrong size!
- fi
- # end of 'Imakefile'
- fi
- if test -f 'Lesson2.cmd' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'Lesson2.cmd'\"
- else
- echo shar: Extracting \"'Lesson2.cmd'\" \(1707 characters\)
- sed "s/^X//" >'Lesson2.cmd' <<'END_OF_FILE'
- X16
- X-1 6 4
- XLesson 2: Addition
- XThis Lesson demonstrates 2 addition problems:
- X6+5 & 23+9
- XPress Space-bar to Begin
- X1 6 4
- XLesson 2: Addition (6+5)
- XWe Represent 6 by Adding 5...
- X(pending operation)
- XPress Space-bar to Continue
- X4 6 4
- XLesson 2: Addition (6+5)
- X...and 1.
- X(This is 6)
- XPress Space-bar to Continue
- X0 6 4
- XLesson 2: Addition (6+5)
- XAdding the 5...
- X(Requires a Carry)...
- XPress Space-bar to Continue
- X4 5 4
- XLesson 2: Addition (6+5)
- X...So We Carry to the Previous Column...
- X(The 10's Column)
- XPress Space-bar to Continue
- X2 6 4
- XLesson 2: Addition (6+5)
- X...We Reset The Upper-deck and Obtain The Answer.
- X10 in the Previous Column + 1 in the Current= 11.
- XPress Space-bar to Continue
- X3 5 4
- XLesson 2: Addition
- XThat was a Straight-forward Example...
- X
- XPress Space-bar
- X3 6 4
- XLesson 2: Addition
- XThe following one is a bit more complicated.
- XSo, pay attention...
- XPress Space-bar to Begin
- X5 5 4
- XLesson 2: Addition (23+9)
- X20... (begin to represent 23)
- X
- XPress Space-bar
- X6 6 4
- XLesson 2: Addition (23+9)
- X...+3, represents 23.
- X
- XPress Space-bar
- X0 6 4
- XLesson 2: Addition (23+9)
- XRepresent 9 as +10 -1. So, 2 Beads on upper-deck= 10...
- X(pending carry to the 10's column)
- XPress Space-bar
- X6 5 4
- XLesson 2: Addition (23+9)
- X...carry to 10's column...
- X
- XPress Space-bar
- X2 6 4
- XLesson 2: Addition (23+9)
- XReset Upper-deck of Current-column...
- X(Pending the `-1' of +10-1= +9)
- XPress Space-bar
- X5 6 4
- XLesson 2: Addition (23+9)
- X... -1 (Current-column) completes +9
- XResulting in the answer: 32
- XPress Space-bar
- X-5 6 4
- XConclusion: (continued)
- XTo perform addition, move beads towards the
- Xmid-beam; to subtract, move beads away from it.
- XPress Space-bar
- X-5 6 4
- XConclusion: (End)
- XTo gain profiency in using the abacus, practice !
- X
- XPress Space-bar
- END_OF_FILE
- if test 1707 -ne `wc -c <'Lesson2.cmd'`; then
- echo shar: \"'Lesson2.cmd'\" unpacked with wrong size!
- fi
- # end of 'Lesson2.cmd'
- fi
- if test -f 'Lesson3.cmd' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'Lesson3.cmd'\"
- else
- echo shar: Extracting \"'Lesson3.cmd'\" \(725 characters\)
- sed "s/^X//" >'Lesson3.cmd' <<'END_OF_FILE'
- X7
- X-4 5 4
- XLesson 3: Subtraction
- XThis Lesson demonstrates subtracting 7 from 11
- X
- XPress Space-bar to Begin
- X4 5 4
- XLesson 3: Subtraction (11-7)
- XFirst Represent 11 as 10...
- X(pending operation)
- XPress Space-bar to Continue
- X4 6 4
- XLesson 3: Subtraction (11-7)
- X...and 1.
- X(This is 11)
- XPress Space-bar to Continue
- X-3 5 4
- XLesson 3: Subtraction (11-7)
- XWe Represent -7 as -10+3, so...
- X
- XPress Space-bar to Continue
- X3 5 4
- XLesson 3: Subtraction (11-7)
- X-10 ...
- X(pending operation +3)
- XPress Space-bar to Continue
- X7 6 4
- XLesson 3: Subtraction (11-7)
- X...+3 Completes The Operation
- XThe Answer is +4.
- XPress Space-bar
- X-7 6 4
- XConclusion: (End)
- XTo perform addition, move beads towards the
- Xmid-beam; to subtract, move beads away from it.
- XPress Space-bar
- END_OF_FILE
- if test 725 -ne `wc -c <'Lesson3.cmd'`; then
- echo shar: \"'Lesson3.cmd'\" unpacked with wrong size!
- fi
- # end of 'Lesson3.cmd'
- fi
- if test -f 'demo.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'demo.c'\"
- else
- echo shar: Extracting \"'demo.c'\" \(1568 characters\)
- sed "s/^X//" >'demo.c' <<'END_OF_FILE'
- X#include <stdio.h>
- X#include <string.h>
- X#include "main.h"
- X
- X#define drawText(x,y,str) XDrawString(display,demobase,gc[FRAME],x,y,str,strlen(str));
- X
- X
- X/* This array represents 4 lines of text that are to be displayed in the
- X * demo window; the module drawDemoWindow() will be passed a pointer to this
- X * array */
- Xchar displaytext[4][64];
- X
- Xchar *introtext[]={
- X "Place this window below the abacus, then click & leave",
- X "the pointer in the abacus window to begin the demo.",
- X "During the demo, use the Space-bar to step.",
- X "Type `q' to quit the demo.",
- X};
- X
- Xchar *querytext[]={
- X "Type:",
- X " `c' to continue to next lesson",
- X /*" ",*/
- X " `r' to repeat previous lesson",
- X " `q' to quit the demo",
- X};
- X
- Xint font_height;
- X
- XdrawIntro()
- X{
- Xint i;
- X
- X#ifdef DEBUG
- X (void)fprintf(stderr," DEBUG drawIntro():\n");
- X#endif
- X
- X font_height = font_info->max_bounds.ascent + font_info->max_bounds.descent;
- X
- X for(i=0; i<4; i++){
- X drawText(1,font_height+(font_height*i),introtext[i]);
- X XFlush(display);
- X }
- X
- X}/*drawIntro*/
- X
- X/* drawQuery & drawDemoWindow do look identical. Why, I hear you asking, didn't
- X * he just pass a pointer to the text that needs to be displayed ?
- X * Good question.
- X */
- XdrawQuery()
- X{
- Xint i;
- X
- X XClearWindow(display,demobase);
- X
- X for(i=0; i<4; i++){
- X drawText(1,font_height+(font_height*i),querytext[i]);
- X XFlush(display);
- X }
- X
- X}/* draw_Query */
- X
- XdrawDemoWindow()
- X{
- Xint i;
- X
- X XClearWindow(display,demobase);
- X
- X for(i=0; i<4; i++){
- X drawText(1,font_height+(font_height*i),displaytext[i]);
- X XFlush(display);
- X }
- X
- X}/*drawDemoWindow*/
- X
- END_OF_FILE
- if test 1568 -ne `wc -c <'demo.c'`; then
- echo shar: \"'demo.c'\" unpacked with wrong size!
- fi
- # end of 'demo.c'
- fi
- if test -f 'maindefs.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'maindefs.h'\"
- else
- echo shar: Extracting \"'maindefs.h'\" \(1745 characters\)
- sed "s/^X//" >'maindefs.h' <<'END_OF_FILE'
- X#include <X11/Xlib.h>
- X#include <X11/Xutil.h>
- X#include <X11/Xos.h>
- X#include <X11/Intrinsic.h>
- X#include <X11/StringDefs.h>
- X
- X/* name of the application when iconified & on window*/
- X#define APPNAME "xabacus"
- X#define DEMOWINAME "xabacus-demo"
- X#define DEMOCOL 6
- X
- X#define KEYBUFFERSIZE 10
- X/* size of windows*/
- X#define SMALL 1
- X#define OK 0
- X
- X#define MAXCOLORS 4 /* the number of colors (GC's) required*/
- X#define COLORSTRLEN 32 /* length of a color name */
- X
- X#define BDWINCOLOR "white" /* border color for windows*/
- X
- X/* attributes of topLevel window for bogus WM's*/
- X#define INITPOSX 15
- X#define INITPOSY 15
- X
- X/* initial attributes of the abacus, in pixels*/
- X#define BEADHEIGHT 20
- X#define BEADWIDTH 30
- X#define FRAMEWIDTH 10 /* thickness of the frame*/
- X
- X#define COLGAP 2 /* gap between 2 cols*/
- X#define ROWGAP 2 /* gap between 2 cols*/
- X
- X#define NTOPROWS 3 /*(2 beads, 1 gap on top-deck)*/
- X#define NBOTROWS 6 /*(5 beads, 1 gap on top-deck)*/
- X
- X#define MAXCOLS 100 /* maximum number of columns*/
- X#define NCOLS 13 /* number of columns*/
- X#define NROWS (NTOPROWS+NBOTROWS)
- X
- X#define MIDFRAME (FRAMEWIDTH+(NTOPROWS*BEADHEIGHT)+((NTOPROWS+1)*ROWGAP))
- X
- X/* width/height of window depends on attributes of the abacus*/
- X#define INITWIDTH ((2*FRAMEWIDTH)+(NCOLS*BEADWIDTH)+((NCOLS+1)*COLGAP))
- X#define INITHEIGHT ((3*FRAMEWIDTH)+(NROWS*BEADHEIGHT)+((NROWS+1)*ROWGAP))
- X
- X#define DEMOINITWIDTH INITWIDTH
- X#define DEMOINITHEIGHT 100
- X
- X#define MINWIDTH INITWIDTH /* minimum size of application */
- X#define MINHEIGHT INITHEIGHT
- X
- Xenum { FRAME,BACKGROUND,BEADS,RAILS}; /* for referring to the gc's*/
- X
- X/*return TRUE if row 'r' in col 'c' is occupied by a bead*/
- X#define RowOccupied(r,c) ((c & 1<<(r))?1:0)
- X
- END_OF_FILE
- if test 1745 -ne `wc -c <'maindefs.h'`; then
- echo shar: \"'maindefs.h'\" unpacked with wrong size!
- fi
- # end of 'maindefs.h'
- fi
- if test -f 'patchlevel.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'patchlevel.h'\"
- else
- echo shar: Extracting \"'patchlevel.h'\" \(88 characters\)
- sed "s/^X//" >'patchlevel.h' <<'END_OF_FILE'
- X/* xabacus: Begun on Mon Jun 24 1991 */
- X
- X#define RELEASENUM "1.0"
- X#define PATCHLEVEL 0
- X
- END_OF_FILE
- if test 88 -ne `wc -c <'patchlevel.h'`; then
- echo shar: \"'patchlevel.h'\" unpacked with wrong size!
- fi
- # end of 'patchlevel.h'
- fi
- echo shar: End of archive 4 \(of 4\).
- cp /dev/null ark4isdone
- MISSING=""
- for I in 1 2 3 4 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 4 archives.
- rm -f ark[1-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
- --
- Molecular Simulations, Inc. mail: dcmartin@msi.com
- 796 N. Pastoria Avenue uucp: uunet!dcmartin
- Sunnyvale, California 94086 at&t: 408/522-9236
-