# This is a shell archive. # Remove everything above and including the cut line. # Then run the rest of the file through sh. #----cut here-----cut here-----cut here-----cut here----# #!/bin/sh # shar: Shell Archiver # Run the following text with /bin/sh to create: # dt1451.h # fgLib.c # fgLib.h # pbLib.h # This archive created: Tue Aug 29 13:44:16 1989 sed 's/^X//' << \SHAR_EOF > dt1451.h X/* dt1451.h - header file for data translation frame grabber board */ X X/* registers in short i/o space (specific to mz7122 - sorry!) */ Xshort *fgControlRegBase; X X#define CONTROL_REG_BASE fgControlRegBase X#define INCSR1 ((short *)(CONTROL_REG_BASE + 0)) X#define INCSR2 ((short *)(CONTROL_REG_BASE + 1)) X#define OUTCSR ((short *)(CONTROL_REG_BASE + 2)) X#define CURSOR ((short *)(CONTROL_REG_BASE + 3)) X#define INDEX_REG ((short *)(CONTROL_REG_BASE + 4)) X#define INLUT_REG ((short *)(CONTROL_REG_BASE + 5)) X#define REDGRN_REG ((short *)(CONTROL_REG_BASE + 6)) X#define BLUE_REG ((short *)(CONTROL_REG_BASE + 7)) X X/* bits in INCSR1 */ X#define INCSR1_BUSY 0x0080 X#define INCSR1_DONE_INT_EN 0x0040 X#define INCSR1_SCAN_TRIG 0x0020 X#define INCSR1_FRAME_PROC 0x0010 X#define INCSR1_PASS_THRU 0x0008 X#define INCSR1_INP_LUT_SEL 0x0007 X X/* bits in INCSR2 */ X X#define INCSR2_CI 0x8000 X#define INCSR2_ALU_MODE 0x4000 X#define INCSR2_ALU_FUNC 0x3c00 X#define INCSR2_VID_CH_SEL 0x0300 X#define INCSR2_BUF_SEL 0x0080 X#define INCSR2_MODE 0x0070 X#define INCSR2_WP_3 0x0008 X#define INCSR2_WP_2 0x0004 X#define INCSR2_WP_1 0x0002 X#define INCSR2_WP_0 0x0001 X X/* values for INCSR2_MODE */ X X#define NORMAL 0x0 X#define NORMALC 0x1 X#define LUT_ACCESS 0x3 X#define SLOW_SCAN 0x4 X X X/* bits in OUTCSR */ X X#define OUTCSR_VSYNC 0x8000 X#define OUTCSR_INT_ON_SYNC 0x4000 X#define OUTCSR_FIELD 0x2000 X#define OUTCSR_SCAN_TRIG 0x1000 X#define OUTCSR_DISPLAY 0x0080 X#define OUTCSR_CURSOR 0x0040 X#define OUTCSR_EXT_TIME 0x0020 X#define OUTCSR_OUT_BUF_SEL 0x0010 X#define OUTCSR_OUT_LUT_SEL 0x0007 X X#define SET_BITS(reg, mask, bits) *reg = ((*reg & (~mask)) | (bits & mask)) X#define FG_MEM_BASE 0x800000 SHAR_EOF sed 's/^X//' << \SHAR_EOF > fgLib.c X/* fgLib.c - utility routines for the data translation dt1451 frame grabber */ X X/* Copyright 1984,1985,1986,1987,1988,1989 Wind River Systems, Inc. */ X X/* X X COPYING POLICIES X X Permission is hereby granted for copying and distribution of copies of X the fgLib source files, and that of any part thereof, subject to the following X license conditions: X X 1. You may, without additional permission from the authors, distribute X fgLib or components of fgLib, with or without additions developed by X you or by others at no charge. You may also distribute fgLib along X with any other product for sale, provided that the cost of the X bundled package is the same regardless of whether fgLib is included, X and provided that those interested only in fgLib must be notified X that it is a product freely available from Wind River Systems. X X 2. Furthermore, if you distribute fgLib or parts of fgLib, with X or without additions developed by you or others, then you must X either make available the source to all portions of fgLib X (exclusive of any additions made by you or by others) upon request, X or instead you may notify anyone requesting source that it is X freely available from Wind River Systems. X X 3. In addition, you may not omit any of the copyright notices X on either the source files, the executable file, or the X documentation, and X X 4. Also, you may not omit transmission of this License agreement with X whatever portions of fgLib that are distributed. X X 5. Lastly, any users of this software must be notified that it is X without warrantee or guarantee of any nature, express or implied, X nor is there any fitness for use represented. X XSoftware is a malleable thing and the authors can in no Xway guarantee that using this program will not cause grevious damage to your Xsystem. Of course this isn't anticipated, but if it does happen, the authors Xcannot be held liable for any damages either directly or indirectly caused Xby this event. X XNOTE that it is not permitted to copy, sublicense, distribute or transfer any Xof fgLib except as expressly indicated herein. Any attempts to Xdo otherwise will be considered a violation of this license and your rights Xto fgLib will be voided. X X XComments on the system and/or this licensing agreement is encouraged. Send Xelectronic mail to "bob@wrs.com". This license was copyed directly from Xthe Elm software agreement. Thank you, Thank you, Thank you! X X---- X X*/ X X/* Xmodification history X-------------------- X01a,01may89,rdc spruced up a bit for public consumption. X*/ X X/* XDESCRIPTION XfgLib.c evolved during the development of the vxWorks pinball demo. Many Xof the routines are specific to the demo, but may be of interest to you. XIf nothing else, you can use these routines as a starting point for your Xown application. X XNB - This module is being placed in the VxWorks Users Group archive with Xthe understanding that this is unsupported code. X X*/ X X#include "/usr/vw/h/vxWorks.h" X#include "dt1451.h" X#include "fgLib.h" X#include "/usr/vw/h/semLib.h" X X#include X#include "pbLib.h" X#include "vme.h" X Xdouble exp (); X Xunsigned char lutData [256]; X Xchar *frameBufMem; X X/***************************************************************************** X* X* fgInit - intitialize the frame grabber X* X* fgInit should be called before any other routine in fgLib X*/ X XVOID fgInit () X { X /* set the frame buffer memory address to 0xf00000 */ X X /* XXX Hmmmm... mizar mz7122 sysBusToLocalAdrs routine seems to be wierd... X /* XXX we'll just fake this for now. X /* XXX fgSetMemBase (0xf00000); */ X frameBufMem = (char *) 0xfff00000; /* XXX KLUDGE! */ X fgSetContRegBase (0x1230); X X fgInpLutInit (); X fgOutLutInit (); X fgGrab (0,0); X taskDelay (5); X fgGrab (0,0); X taskDelay (5); X fgGrab (0,0); X X X } X X/***************************************************************************** X* X* fgSetContRegBase - set the base address of the frame grabber's control regs X* X*/ X XfgSetContRegBase (addr) X short *addr; X { X X if (sysBusToLocalAdrs (VME_AM_SUP_SHORT_IO, addr, &fgControlRegBase) == ERROR) X { X printf ("fgSetContRegBase: %x is not accessable\n", addr); X return (ERROR); X } X X return (OK); X } X X/***************************************************************************** X* X* fgSetMemBase - define the vme address of the frame buffer's memory. X* X*/ X XSTATUS fgSetMemBase (addr) X char *addr; /* vme bus address of frame buffer memory */ X { X X if (sysBusToLocalAdrs (VME_AM_STD_SUP_DATA, addr, &frameBufMem) == ERROR) X { X printf ("fgSetBase: %x is not accessable\n", addr); X return (ERROR); X } X X return (OK); X } X X X X/***************************************************************************** X* X* fgContinuous - put the frame grabber in continuous mode X* X*/ X XVOID fgContinuous () X { X X /* check the BUSY bit */ X X if (*INCSR1 & INCSR1_BUSY) X { X printf ("fgContinuous: board is busy\n"); X return (ERROR); X } X X /* turn the display off */ X X SET_BITS(OUTCSR, OUTCSR_DISPLAY, 0); X X *INCSR2 = 0x0100; X X *INCSR1 = 0x88; X X *OUTCSR = 0xe0; X } X X/***************************************************************************** X* X* fgStop - take the frame grabber out of continous mode X* X*/ X XVOID fgStop () X { X SET_BITS (INCSR1, INCSR1_PASS_THRU, 0); X } X X/***************************************************************************** X* X* fgDiffLutInit - initialize the input lookup tables for difference mode X* X*/ X XVOID fgDiffLutInit () X { X unsigned char data [256]; X unsigned int i; X X for (i = 0; i < 256; i++) X data [i] = i; X X fgInpLutSet (1, data); X X for (i = 0; i < 256; i++) X data [i] = ~i + 1; X X fgInpLutSet (0, data); X } X X/***************************************************************************** X* X* fgCopyIn - copy a rectangular region into the frame grabber memory X* X* NB - this routine copies only even scan lines - an optimization used X* in the pinball demo. X*/ X XVOID fgCopyIn (bufNum, pRegion, buf) X int bufNum; /* 0 or 1 */ X REGION *pRegion; /* destination region */ X char *buf; /* source data */ X { X X FAST short *pSrc; X FAST short *pDest = (bufNum == 0) ? X (short *) frameBufMem : X (short *)( frameBufMem + (512 * 512)); X FAST unsigned int regionEnd; X FAST short *pDestLineStart; X FAST short *pDestLineEnd; X FAST unsigned int srcLineStart; X FAST int regionWidth = pRegion->width; X X regionEnd = X (unsigned int)((int) pDest + (pRegion->yLower + pRegion->height) * 512 X + pRegion->xLeft); X pDest = (short *)((int) pDest + pRegion->yLower * 512 + pRegion->xLeft); X pDestLineStart = pDest; X X pSrc = (short *)((int) buf + pRegion->yLower * 512 + pRegion->xLeft); X srcLineStart = (unsigned int) pSrc; X X while ((unsigned int) pDest < regionEnd) X { X pDestLineEnd = X (short *) ((int) pDestLineStart + regionWidth); X X while (pDest < pDestLineEnd) X *(pDest++) = *(pSrc++); X X pDest = pDestLineStart = (short *)((int) pDestLineStart + 1024); X srcLineStart += 1024; X pSrc = (short *) srcLineStart; X } X } X X/***************************************************************************** X* X* fgCopyOut - copy a rectangular region out of the frame grabber memory X* X* NB - this routine copies only even scan lines - an optimization used X* in the pinball demo. X*/ X XVOID fgCopyOut (bufNum, pRegion, buf) X int bufNum; /* 0 or 1 */ X REGION *pRegion; /* source region */ X unsigned char *buf; /* destination buffer */ X { X X FAST short *pDest; X FAST short *pSrc = (bufNum == 0) ? X (short *) frameBufMem : X (short *)( frameBufMem + (512 * 512)); X FAST unsigned int regionEnd; X FAST short *pSrcLineStart; X FAST short *pSrcLineEnd; X FAST unsigned int destLineStart; X FAST int regionWidth = pRegion->width; X X regionEnd = X (unsigned int)((int) pSrc + (pRegion->yLower + pRegion->height) * 512 + pRegion->xLeft); X pSrc = (short *)((int) pSrc + pRegion->yLower * 512 + pRegion->xLeft); X pSrcLineStart = pSrc; X X pDest = (short *)((int) buf + pRegion->yLower * 512 + pRegion->xLeft); X destLineStart = (unsigned int) pDest; X X while ((unsigned int) pSrc < regionEnd) X { X pSrcLineEnd = X (short *) ((int) pSrcLineStart + regionWidth); X X while (pSrc < pSrcLineEnd) X *(pDest++) = *(pSrc++); X X pSrc = pSrcLineStart = (short *)((int) pSrcLineStart + 1024); X destLineStart += 1024; X pDest = (short *) destLineStart; X } X } X X/***************************************************************************** X* X* fgGrab - grab a frame X* X*/ X XSTATUS fgGrab (bufNum, inpLutNum) X int bufNum; /* 0 or 1 */ X int inpLutNum; /* 0 or 1 */ X { X X /* check the BUSY bit */ X X if (*INCSR1 & INCSR1_BUSY) X { X printf ("fgGrab: board is busy\n"); X return (ERROR); X } X X /* turn the display off */ X X /* XXX SET_BITS(OUTCSR, OUTCSR_DISPLAY, 0); */ X X *INCSR2 = 0x0100 | (bufNum << 7); X X *INCSR1 = 0x80 | inpLutNum; X X /* XXX *OUTCSR = 0xe0; */ X return (OK); X } X X/***************************************************************************** X* X* fgGrabDiff - grab a frame in difference mode X* X*/ X XSTATUS fgGrabDiff (bufNum, intWhenDone) X int bufNum; X BOOL intWhenDone; X { X X /* check the BUSY bit */ X X if (*INCSR1 & INCSR1_BUSY) X { X printf ("fgGrabDiff: board is busy\n"); X return (ERROR); X } X X /* turn the display off */ X /* display out buf also selects the feedback path */ X X *OUTCSR = (bufNum << 4) | OUTCSR_EXT_TIME | OUTCSR_CURSOR | OUTCSR_DISPLAY; X X *INCSR2 = 0x0110 | (6 << 10) | (bufNum << 7); /*NORMALC mode */ X X if (intWhenDone) X *INCSR1 = INCSR1_BUSY | INCSR1_DONE_INT_EN | 1; X else X *INCSR1 = INCSR1_BUSY | 1; X X return (OK); X X } X X X/***************************************************************************** X* X* fgDisplay - tell the frame grabber to display either buffer 0 or 1. X* X*/ X XVOID fgDisplay (bufNum) X int bufNum; /* 0, 1 or -1 (display off) */ X { X X if (bufNum == -1) X SET_BITS (OUTCSR, OUTCSR_DISPLAY, 0); X else X { X SET_BITS (OUTCSR, OUTCSR_OUT_BUF_SEL, (bufNum << 4)); X SET_BITS (OUTCSR, OUTCSR_DISPLAY, OUTCSR_DISPLAY); X } X X } X X/***************************************************************************** X* X* fgWrite - copy the digitized image in buffer 0 to a file in sun rasterfile X* format. X* X*/ X XVOID fgWrite (file) X char *file; X { X X int fd; X struct rasterfile myRas; X int bytesLeft; X int bytesWritten; X int index; X char *buf; X FAST int i; X FAST int j; X X fd = creat (file, 2); X X if (fd == ERROR) X { X printf ("fgWrite: error opening file: %x\n", errnoGet ()); X return; X } X X /* create header */ X X myRas.ras_magic = RAS_MAGIC; X myRas.ras_width = 512; X myRas.ras_height = 480; X myRas.ras_depth = 8; X myRas.ras_length = 0; X myRas.ras_type = RT_OLD; X myRas.ras_maptype = RMT_NONE; X myRas.ras_maplength = 0; X X /* write the header */ X X if (write (fd, &myRas, sizeof (myRas)) != sizeof (myRas)) X { X printf ("fgWrite: error writing header : %x\n", errnoGet ()); X close (fd); X return; X } X X /* write image data */ X X buf = (char *) malloc (480 * 512); X X if (buf == NULL) X { X printf ("fgWrite: couldn't allocate buf\n"); X close (fd); X return; X } X X/* XXX bcopyBytes (0xfff00000, buf, 480 * 512); */ X X /* copy the buffer backwards */ X X for (i = 0, j = (480 * 512) - 1; i < (480 * 512); i++, j--) X buf [j] = ((char *) frameBufMem) [i]; X X bytesLeft = 480 * 512; X index = 0; X X while (bytesLeft > 0) X { X bytesWritten = write (fd, buf + index, bytesLeft); X if (bytesWritten == ERROR) X { X printf ("fgWrite: error writing data : %x index = %x\n", X errnoGet (), index); X free (buf); X close (fd); X return; X } X bytesLeft -= bytesWritten; X index += bytesWritten; X } X X close (fd); X free (buf); X } X X/***************************************************************************** X* X* fgOutLutInit - initialize the output lookup tables X* X*/ X XVOID fgOutLutInit () X { X unsigned char data [256]; X unsigned int i; X X for (i = 0; i < 256; i++) X data [i] = i; X X fgOutLutSet (BOTH, 0, data); X fgOutLutSet (BOTH, 1, data); X fgOutLutSet (BOTH, 2, data); X fgOutLutSet (BOTH, 3, data); X fgOutLutSet (BOTH, 4, data); X fgOutLutSet (BOTH, 5, data); X fgOutLutSet (BOTH, 6, data); X fgOutLutSet (BOTH, 7, data); X } X X/***************************************************************************** X* X* fgInpLutInit - initialize the frame grabber's input lookup tables X* X*/ X XVOID fgInpLutInit () X { X unsigned char data [256]; X unsigned int i; X X for (i = 0; i < 256; i++) X data [i] = i; X X fgInpLutSet (0, data); X X fgInpLutSet (2, data); X fgInpLutSet (3, data); X fgInpLutSet (4, data); X fgInpLutSet (5, data); X fgInpLutSet (6, data); X fgInpLutSet (7, data); X for (i = 0; i < 256; i++) X if (i < 127) X data [i] = i; X else X data [i] = 0; X X fgInpLutSet (1, data); X } X X/***************************************************************************** X* X* fgBinLut - initialize an input lut in a binary fashion in an attempt to do X* some simple threshholding. X* X* NB - this was an experimental routine. X*/ X XVOID fgBinLut (start, stop, lutNum) X int start; X int stop; X int lutNum; X { X int i; X X for (i = 0; i < 255; i++) X if ((i > start) && (i < stop)) X lutData [i] = 255; X else X lutData [i] = 0; X X fgInpLutSet (lutNum, lutData); X } X X/***************************************************************************** X* X* fgExpLut - initialize an input lut in an exponetial fashion in an attempt to X* do some more complex threshholding. X* X* NB - this was an experimental routine. X* X*/ X XVOID fgExpLut () X { X X X double start = 0.0; X double stop = 0.1; X double incr; X double scale; X int i; X X printf ("start = %g stop = %g\n", start, stop); X X scale = exp (stop) - 1.0; X incr = (stop - start) / 127.0; X X for (i = 0; i < 256; i++) X { X /* printf ("start = %g stop = %g incr = %g\n", start, stop, incr); */ X if (i < 127) X lutData [i] = i * ((exp (start) - 1.0) / scale); X else X lutData [i] = 0; X start += incr; X } X } X X/***************************************************************************** X* X* fgOutLutSet - set up an output lookup table X* X*/ X XSTATUS fgOutLutSet (color, lutNum, pdata) X int color; /* 0 = REDGREEN, 1 = BLUE 2 = BOTH */ X int lutNum; /* lookup Table number (0 - 7) */ X unsigned char *pdata; /* pointer to array of 256 values */ X { X X short oldOutCSR = *OUTCSR; X unsigned int i; X X SET_BITS(INCSR2, (INCSR2_MODE | INCSR2_ALU_FUNC), X ((LUT_ACCESS << 4) | (0x1a << 8))); X X SET_BITS(OUTCSR, OUTCSR_DISPLAY, 0); X SET_BITS(OUTCSR, OUTCSR_OUT_LUT_SEL, lutNum); X X for (i = 0; i < 256; i++) X { X *INDEX_REG = (unsigned short) i; X switch (color) X { X case REDGREEN: X *REDGRN_REG = (unsigned short) pdata [i]; X case BLUE: X *BLUE_REG = (unsigned short) pdata [i]; X case BOTH: X *REDGRN_REG = (unsigned short) pdata [i]; X *BLUE_REG = (unsigned short) pdata [i]; X } X } X X *OUTCSR = oldOutCSR; X return (OK); X } X X/***************************************************************************** X* X* fgInpLutSet - set up an input lookup table X* X*/ X XSTATUS fgInpLutSet (lutNum, pdata) X int lutNum; /* lookup Table number (0 - 7) */ X unsigned char *pdata; /* pointer to array of 256 values */ X { X X short oldOutCSR = *OUTCSR; X unsigned int i; X X /* check the BUSY bit */ X X if (*INCSR1 & INCSR1_BUSY) X { X printf ("fgInpLutSet: board is busy\n"); X return (ERROR); X } X X SET_BITS(INCSR1, INCSR1_INP_LUT_SEL, lutNum); X X SET_BITS(INCSR2, (INCSR2_MODE | INCSR2_ALU_FUNC | INCSR2_ALU_MODE), X ((LUT_ACCESS << 4) | (0x1a << 10))); X X /* turn the display off */ X X SET_BITS(OUTCSR, OUTCSR_DISPLAY, 0); X X X for (i = 0; i < 256; i++) X { X *INDEX_REG = (unsigned short) i; X *INLUT_REG = (unsigned short) pdata [i]; X } X X *OUTCSR = oldOutCSR; X return (OK); X } X X/***************************************************************************** X* X* fgInpLutGet - retreive an input look up table X* X*/ X XSTATUS fgInpLutGet (lutNum, pdata) X int lutNum; /* lookup Table number (0 - 7) */ X unsigned char *pdata; /* pointer to array of 256 values */ X { X X short oldOutCSR = *OUTCSR; X unsigned int i; X X /* check the BUSY bit */ X X if (*INCSR1 & INCSR1_BUSY) X { X printf ("fgInpLutGet: board is busy\n"); X return (ERROR); X } X X SET_BITS(INCSR1, INCSR1_INP_LUT_SEL, lutNum); X X SET_BITS(INCSR2, (INCSR2_MODE | INCSR2_ALU_FUNC | INCSR2_ALU_MODE), X ((LUT_ACCESS << 4) | (0x1a << 10))); X X /* turn the display off */ X X SET_BITS(OUTCSR, OUTCSR_DISPLAY, 0); X X X for (i = 0; i < 256; i++) X { X short shortBuf; X *INDEX_REG = (unsigned short) i; X shortBuf = *INLUT_REG; X pdata [i] = shortBuf; X } X X *OUTCSR = oldOutCSR; X return (OK); X } X X/***************************************************************************** X* X* fgCalc - report some simple statistics about the data in the given buffer. X* X*/ X XVOID fgCalc (bufNum) X int bufNum; X { X X FAST unsigned char *charPtr = (bufNum == 0) ? X (unsigned char *) frameBufMem : X (unsigned char *)( frameBufMem + (512 * 512)); X FAST unsigned char *end = (charPtr + (512 * 480) ); X FAST unsigned int sum = 0; X FAST unsigned char biggest = 0; X FAST unsigned char charBuf; X X while (charPtr < end) X { X charBuf = *(charPtr++); X sum += charBuf; X if (charBuf > biggest) X biggest = charBuf; X } X printf ("biggest = %d average = %d\n", biggest, sum / (512 * 480)); X } X XfgINCSR1Get () X { X return (*INCSR1); X } XfgINCSR2Get () X { X return (*INCSR2); X } XfgOUTCSRGet () X { X return (*OUTCSR); X } X XfgINDEXGet () X { X return (*INDEX_REG); X } X XfgINLUTGet () X { X return (*INLUT_REG); X } X X/***************************************************************************** X* X* fgCursor - put the cross hair cursor on the given coordinates X* X*/ X XVOID fgCursor (x,y) X unsigned int x; X unsigned int y; X { X X *CURSOR = (short) (((y/2 ) << 8) | (x/2)); X X SET_BITS (OUTCSR, OUTCSR_CURSOR, OUTCSR_CURSOR); X } X X/***************************************************************************** X* X* fgCursorOff - turn off the cross hair cursor X* X*/ X XVOID fgCursorOff () X { X SET_BITS (OUTCSR, OUTCSR_CURSOR, 0); X } X X/***************************************************************************** X* X* fgOutlineRegion - draw a box around a rectangular region X* X*/ X XVOID fgOutlineRegion (pRegion, bufNum) X FAST REGION *pRegion; X int bufNum; X { X X FAST char *pPixel; X FAST char *pEndPixel; X FAST char *frameBuf = (bufNum == 0) ? (char *) frameBufMem : (char *) frameBufMem + (512 * 512); X X /* draw the upper horizontal line */ X X pPixel = (char *) (frameBuf + (pRegion->yLower + pRegion->height) * 512 + X pRegion->xLeft); X pEndPixel = (char *) (pPixel + pRegion->width); X X while (pPixel <= pEndPixel) X *(pPixel++) = 255; X X /* draw the lower horizontal line */ X X pPixel = (char *)(frameBuf + pRegion->yLower * 512 + pRegion->xLeft); X pEndPixel = (char *) (pPixel + pRegion->width); X X while (pPixel <= pEndPixel) X *(pPixel++) = 255; X X /* draw the left vertical line */ X X pPixel = (char *)(frameBuf + pRegion->yLower * 512 + pRegion->xLeft); X pEndPixel = (char *)(pPixel + pRegion->height * 512); X X while (pPixel <= pEndPixel) X { X *pPixel = 255; X pPixel += 512; X } X X /* draw the right vertical line */ X X pPixel = (char *)(frameBuf + pRegion->yLower * 512 + pRegion->xLeft + X pRegion->width); X pEndPixel = pPixel + pRegion->height * 512; X X while (pPixel <= pEndPixel) X { X *pPixel = 255; X pPixel += 512; X } X } X X X/***************************************************************************** X* X* fgDrawLine - draw a line X* X*/ X XVOID fgDrawLine (x1, y1, x2, y2, intensity, bufNum) X int x1; X int y1; X int x2; X int y2; X FAST int intensity; X int bufNum; X { X FAST char *pPixel; X FAST char *frameBuf = (bufNum == 0) ? (char *) frameBufMem : (char *) frameBufMem + (512 * 512); X double slope; X double yIntercept; X FAST int xIndex; X FAST int xMax; X FAST int y; X X X slope = (y1 * 1.0 - y2 * 1.0) / (x1 * 1.0 - x2 * 1.0); X yIntercept = y1 * 1.0 - slope * x1; X xIndex = min (x1, x2); X xMax = max (x1, x2); X X while (xIndex <= xMax) X { X y = slope * xIndex + yIntercept; X pPixel = frameBuf + y * 512 + xIndex++; X *pPixel = intensity; X } X X } X X/***************************************************************************** X* X* fgBusy - poll the frame grabber to see if it's done grabbing a frame X* X*/ X XBOOL fgBusy () X { X if (*INCSR1 & INCSR1_BUSY) X return (TRUE); X else X return (FALSE); X } SHAR_EOF sed 's/^X//' << \SHAR_EOF > fgLib.h X X#define REDGREEN 0 X#define BLUE 1 X#define BOTH 2 SHAR_EOF sed 's/^X//' << \SHAR_EOF > pbLib.h X X/* pbLib.h - pinball machine application header file */ X X/* Xmodification history X-------------------- X01a,16aug88,rdc written. X*/ X Xtypedef struct X { X int xLeft; X int width; X int yLower; X int height; X } REGION; X X Xtypedef struct X { X REGION region; X int numPixels; X int sumPixels; X } OBJECT; X X X/* this intersection includes contiguity (i hope )*/ X X#define LINE_X_REGION(region, lineXLeft, lineXRight, y) \ X ( \ X (((y - 2) <= (region.yLower + region.height)) && ((y + 2) >= region.yLower )) \ X && \ X ( \ X (((lineXRight - 1) <= (region.xLeft + region.width)) && ((lineXRight + 1) >= region.xLeft)) \ X || \ X (((lineXLeft - 1) <= (region.xLeft + region.width)) && ((lineXLeft + 1) >= region.xLeft)) \ X ) \ X ) X X#define VALUE_IN_RANGE(value, lowerRange, upperRange) \ X ((value <= upperRange) && (value >= lowerRange)) X X/* fuzzy comparison macros */ X Xint tolerence = 5; X X#define FUZZY_POINT_INTERSECT(x1,y1,x2,y2) \ X ((VALUE_IN_RANGE ((x2 - tolerence), (x1 - tolerence), (x1 + tolerence)) || \ X VALUE_IN_RANGE ((x2 + tolerence), (x1 - tolerence), (x1 + tolerence))) &&\ X \ X (VALUE_IN_RANGE ((y2 - tolerence), (y1 - tolerence), (y1 + tolerence)) ||\ X VALUE_IN_RANGE ((y2 + tolerence), (y1 - tolerence), (y1 + tolerence))) \ X ) SHAR_EOF # End of shell archive exit 0