home *** CD-ROM | disk | FTP | other *** search
- 18-Jun-88 14:42:50-MDT,8714;000000000000
- Return-Path: <u-lchoqu%sunset@cs.utah.edu>
- Received: from cs.utah.edu by SIMTEL20.ARPA with TCP; Sat, 18 Jun 88 14:42:38 MDT
- Received: by cs.utah.edu (5.54/utah-2.0-cs)
- id AA22619; Sat, 18 Jun 88 14:42:32 MDT
- Received: by sunset.utah.edu (5.54/utah-2.0-leaf)
- id AA24776; Sat, 18 Jun 88 14:42:29 MDT
- Date: Sat, 18 Jun 88 14:42:29 MDT
- From: u-lchoqu%sunset@cs.utah.edu (Lee Choquette)
- Message-Id: <8806182042.AA24776@sunset.utah.edu>
- To: rthum@simtel20.arpa
- Subject: Slide.c.shar
-
- #! /bin/sh
- #
- # This is a shell archive. Save this into a file, edit it
- # and delete all lines above this comment. Then give this
- # file to sh by executing the command "sh file". The files
- # will be extracted into the current directory owned by
- # you with default permissions.
- #
- # The files contained herein are:
- #
- # 5 Slide.c
- # 2 Slide.rc
- # 1 Makefile
- #
- echo 'Extracting Slide.c'
- if test -f Slide.c; then echo 'shar: will not overwrite Slide.c'; else
- cat << '________This_Is_The_END________' > Slide.c
- /* Simple slide showing program.
- *
- * Copyright (C) 1985, Stanford Univ. SUMEX project.
- * May be used but not sold without permission.
- */
-
- /*
- * history
- * 02/05/85 croft created.
- */
-
-
- /*
- *
- * The slides that are used are MacPaint files. Your drawing must be
- * positioned in the upper left corner of the physical page image.
- * The accompanying MacPaint file 'slide.blank' is a blank slide with
- * tiny guide marks at the corners to show you this area. It also
- * contains a guide dot that you can use to align your first line of
- * text.
- *
- * The slide order is determined by the file names. Only one slide show
- * can be stored per disk. The file names have the form "NumberName",
- * for example "1title", "2overview", "3goals", etc. Only the number
- * part of the file name determines the slide order. You can use numbers
- * as large as you like; you can also use fractions to "insert" slides,
- * e.g.: "1.2credits".
- *
- * The mouse can be used to sketch on the screen. Spacebar advances
- * to the next slide. Backspace reverses.
- */
-
- #include "mac/quickdraw.h"
- #include "mac/osintf.h"
- #include "mac/toolintf.h"
-
- int pensz = 2;
- GrafPort *myPort;
- int wasevent,mouse;
- Point p,pold;
- EventRecord er;
-
- #define NIL 0
-
- #define NFILES 64 /* number of files */
- #define LFILES 32 /* length of file names */
-
- char *files; /* pointer to array, files[NFILES][LFILES] */
- int filescount;
- int filesindex;
- VolumeParam vp;
- FileParam fp;
- char fpname[LFILES]; /* output of PBGetFInfo */
-
- main()
- {
- struct QDVar QDVar;
- GrafPort gp;
-
- QD = &QDVar;
- InitGraf(&thePort);
- InitCursor();
- InitFonts();
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs((ProcPtr)NIL);
- myPort = &gp;
- OpenPort(myPort);
- PenSize(pensz,pensz);
- MoveTo(256,256);
- files = NewPtr(NFILES*LFILES);
- sortfiles();
- showfile(0);
-
- for (;;) {
- SystemTask();
- wasevent = GetNextEvent(everyEvent, &er);
- event();
- }
- }
-
-
- event() /* look for events */
- {
- if (!wasevent)
- goto out;
- switch (er.what) {
- case keyDown:
- case autoKey:
- switch (er.message & 0xff) {
- case 'q':
- ExitToShell();
-
- case ' ':
- if (++filesindex >= filescount)
- ExitToShell();
- showfile(filesindex);
- break;
-
- case '\b':
- if (--filesindex < 0)
- filesindex = 0;
- showfile(filesindex);
- break;
-
- case 'f': pensz += 1; goto setpen;
- case 't': pensz -= 1; goto setpen;
- case 'F': pensz += 16; goto setpen;
- case 'T': pensz -= 16; goto setpen;
-
- setpen:
- PenSize(pensz,pensz);
- break;
-
- case 'b':
- PenPat(&QD->black);
- break;
-
- case 'w':
- PenPat(&QD->white);
- break;
-
- case 'g':
- PenPat(&QD->gray);
- break;
-
- }
- break;
-
- case mouseDown:
- mouse = 1;
- break;
-
- case mouseUp:
- mouse = 0;
- break;
- }
- out:
- GetMouse(&p);
- if (!EqualPt(&p, &pold)) {
- pold = p;
- if (mouse)
- LineTo(p.h,p.v);
- else
- MoveTo(p.h,p.v);
- }
- }
-
-
- sortfiles()
- {
- register i;
- int compare();
-
- if (PBGetVInfo(&vp, 0) != noErr)
- abort("no volinfo?");
- fp.ioNamePtr = fpname;
- for (i = 1 ; i <= vp.ioVNmFls ; i++) {
- fp.ioFDirIndex = i;
- if (PBGetFInfo(&fp, 0) != noErr)
- abort("getfinfo error");
- if (strncmp((char *)&fp.ioFlFndrInfo.fdType, "PNTG", 4) !=0 )
- continue;
- if (fpname[0] <= 0 || fpname[1] < '0' || fpname[1] > '9')
- continue;
- fpname[fpname[0]+1] = 0;
- BlockMove(fpname, &files[LFILES*(filescount++)], LFILES);
- }
- if (filescount <= 0)
- abort("can't find any numbered MacPaint files");
- qsort(files, filescount, LFILES, compare);
- }
-
-
- convert(s)
- char *s;
- {
- register char *cp;
- register i, w, sawfrac;
-
- i = w = sawfrac = 0;
- for (cp = s + 1 ; *cp ; cp++) {
- if (*cp == '.') {
- w = i;
- i = 0;
- sawfrac++;
- continue;
- }
- if (*cp < '0' || *cp > '9')
- break;
- i = (i * 10) + (*cp - '0');
- }
- if (sawfrac)
- return ((w<<16) | i);
- else
- return (i<<16);
- }
-
-
- compare(a,b)
- char *a,*b;
- {
- int an,bn;
-
- an = convert(a);
- bn = convert(b);
- if (an == bn)
- return (0);
- if (an > bn)
- return (1);
- else
- return (-1);
- }
-
-
- #define srcBlocks 2
- #define srcSize 512*srcBlocks
-
- #define SCREEN 0x7A700
- #define SWIDE 512
- #define SHI 342
- #define PWIDE 576 /* MacPaint width */
-
- showfile(i)
- {
- char srcBuf[srcSize];
- char lineBuf[PWIDE/8];
- char *srcPtr,*dstPtr,*linePtr;
- int rn, count;
-
- if (FSOpen(&files[i*LFILES+1], 0, &rn) != noErr)
- abort("fsopen");
- count = 512;
- FSRead(rn, &count, srcBuf); /* skip header */
- count = srcSize;
- FSRead(rn, &count, srcBuf); /* prime buffer */
- srcPtr = srcBuf;
- HideCursor();
- dstPtr = (char *)SCREEN;
- for (i = 0 ; i < SHI-1 ; i++) { /* read 341 lines */
- linePtr = lineBuf;
- UnPackBits(&srcPtr, &linePtr, PWIDE/8);
- BlockMove(lineBuf, dstPtr, SWIDE/8);
- dstPtr += (SWIDE/8);
- if (srcPtr > (srcBuf + srcSize - 512)) {
- BlockMove(&srcBuf[srcSize-512], &srcBuf[0], 512);
- count = srcSize-512;
- FSRead(rn, &count, &srcBuf[512]);
- srcPtr = srcPtr - srcSize + 512;
- }
- }
- FSClose(rn);
- ShowCursor();
- }
-
-
- abort(s)
- char *s;
- {
- ParamText(s, "", "", "");
- StopAlert(257, (ProcPtr)NIL);
- ExitToShell();
- }
- ________This_Is_The_END________
- if test `wc -l < Slide.c` -ne 264; then
- echo 'shar: Slide.c was damaged during transit'
- echo ' (should have been 264 bytes)'
- fi
- fi ; : end of overwriting check
- echo 'Extracting Slide.rc'
- if test -f Slide.rc; then echo 'shar: will not overwrite Slide.rc'; else
- cat << '________This_Is_The_END________' > Slide.rc
- * input for resource compiler
- *
-
- slide.rsrc
-
- Type CCOM = STR
- ,0
- Slide Version 1.0 -- Feb 85
-
- Type ICN# = HEXA
- ,128(32)
- * little picture of the C
- 00000e00 00001000 00001000 00001000 00000e00 00e00000 1fbe001e f003f0e0
- 80001f80 00000000 00000000 00008000 0300803e 3cf0c3c0 c01ce000 0000f000
- 0000f800 00008000 0003fc00 0001f800 3fc0000e e0780078 000fffc0 00000000
- 00000000 00000000 1fc0007e 303c03c0 e007fe00 00000000 00000000 00000000
- * mask
- ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff
- ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff
- ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff
- ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff
-
- Type FREF = HEXA
- ,128(32)
- * APPL uses loc icon 0, no tagalongs
- 4150504c
- 0000
- 00
-
- Type BNDL = HEXA
- ,128(32)
- * owner CCOM 0
- 43434F4D0000
- * 2 types
- 0001
- * ICN#, 1 entry, loc 0 to glob 128
- 49434e230000
-
- Type ALRT
- ,257
- 60 81 180 431
- 258
- 5555
-
- * DITL for the ALRT
- * First the ID (DITL,258), then the number of items which follow.
-
- Type DITL
- ,258
- 2
- * These buttons are 20 hi by 70 wide
- BtnItem Enabled
- 90 13 110 83
- Abort
-
- StatText Disabled
- 10 60 70 350
- ^0^1^2^3
-
- Type CODE
- b.out,0
- ________This_Is_The_END________
- if test `wc -l < Slide.rc` -ne 61; then
- echo 'shar: Slide.rc was damaged during transit'
- echo ' (should have been 61 bytes)'
- fi
- fi ; : end of overwriting check
- echo 'Extracting Makefile'
- if test -f Makefile; then echo 'shar: will not overwrite Makefile'; else
- cat << '________This_Is_The_END________' > Makefile
- .SUFFIXES: .rsrc .b
-
- .c.b:
- cc68 -z -c $<
-
- .s.b:
- cc68 -c $<
-
- .b.rsrc:
- cc68 -z -m $<
- rmaker $*.rc
- # tohex <$*.rsrc >$*.dl
-
- all: slide.rsrc
-
- slide.rsrc: slide.b slide.rc
-
- clean:
- rm *.b *.rsrc b.out *.dl
- ________This_Is_The_END________
- if test `wc -l < Makefile` -ne 19; then
- echo 'shar: Makefile was damaged during transit'
- echo ' (should have been 19 bytes)'
- fi
- fi ; : end of overwriting check
- exit 0
-