home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Games / Life 1.0d2 / LifeModules.h < prev    next >
Encoding:
Text File  |  1995-07-11  |  2.2 KB  |  74 lines  |  [TEXT/MMCC]

  1. // LifeModules.h
  2. // Interface to routines to handle the Life Implementation Modules for Mike's Life.
  3. // Copyright ©1995 Michael D. Crawford.  All Rights Reserved.
  4. // 23 Jun 95 Mike Crawford crawford@scruznet.com
  5. //
  6. // Revision History:
  7. // 23 Jun 95    MDC    New today
  8.  
  9. typedef struct{
  10.     long    top;
  11.     long    left;
  12.     long    right;
  13.     long    bottom;
  14. }tLongRect;
  15.  
  16. enum{
  17.     kBuiltIn,
  18.     k68kCodeResource,
  19.     kPPCCodeFrag
  20. };
  21.  
  22. // Allocate the memory for a life world
  23. typedef OSErr (*tLifeAllocProc)( tLifeWorldPtr worldPtr, long height, long width );
  24.  
  25. // Clear a rectangle of cells
  26. typedef OSErr (*tClearRectProc)( tLifeWorldPtr worldPtr, tLongRect *theRectPtr );
  27.  
  28. // Free a life world when one is through with it.
  29. typedef OSErr (*tFreeProc)( tLifeWorldPtr worldPtr );
  30.  
  31. // Draw a single cell; used while interactively sketching
  32. typedef OSErr (*tDrawCellProc)( tLifeWorldPtr worldPtr, long h, long v );
  33.  
  34. // Switch the state of a cell
  35. typedef OSErr (*tToggleCellProc)( tLifeWorldPtr worldPtr, long h, long v );
  36.  
  37. // Step a single generation.  This might include a blit to the screen
  38. typedef OSErr (*tStepProc)( tLifeWorldPtr );
  39.  
  40. // Draw to the window in a normal, QuickDraw way, as for handling an update
  41. typedef OSErr (*tDrawWinProc)( tLifeWorldPtr worldPtr );
  42.  
  43. typedef struct {
  44.     tStepProc        stepProc;
  45.     tLifeAllocProc    allocProc;
  46.     tClearRectProc    clearPixProc;
  47.     tFreeProc        freeProc;
  48.     tToggleCellProc    toggleProc;
  49.     tDrawCellProc    drawCellProc;
  50.     tDrawWinProc    drawProc;
  51.     FSSpec            fileSpec;        // vRef is 0 for built-ins
  52.     short            procType;
  53. }tLifeProcRecord, *tLifeProcsPtr;
  54.  
  55. OSErr InitModules( void );
  56.  
  57. OSErr AddLifeProcs( tLifeProcsPtr lifeProcPtr,
  58.                         short procType,
  59.                         StringPtr menuStr,
  60.                         tStepProc stepProc,
  61.                         tLifeAllocProc allocProc,
  62.                         tClearRectProc clearPixProc,
  63.                         tFreeProc freeProc,
  64.                         tToggleCellProc toggleProc,
  65.                         tDrawCellProc drawCellProc,
  66.                         tDrawWinProc drawProc,
  67.                         FSSpecPtr specPtr );
  68.                         
  69. void *GetModuleProcs( short moduleNumber );            // Returns pointer to life procs rec
  70.  
  71. OSErr AllocLifeWorld( tLifeWorldPtr worldPtr, long height, long width );
  72. OSErr LifeStep( tLifeWorldPtr worldPtr );
  73. OSErr ClearCells( tLifeWorldPtr worldPtr, tLongRect *rPtr );
  74. OSErr DrawLifeWorld( tLifeWorldPtr worldPtr );