home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Games / Prisoner's Dilemma 2.1 / Prisoner's Dilemma.c / GridCopy.c next >
Encoding:
C/C++ Source or Header  |  1997-03-02  |  1.2 KB  |  44 lines  |  [TEXT/CWIE]

  1. /*
  2. "GridCopy.c"    by Alexander M Kasprzyk
  3.             ©1996
  4.  
  5. This file is part of my CA toolkit. The GridCopy function
  6. allows very rapid copying from one location in memory
  7. to another, and was designed for use in Cellular Automata
  8. programs.
  9.  
  10. Please feel free to contact me at:
  11. alex@kasprzyk.demon.co.uk
  12. */
  13.  
  14. #include "GridCopyPr.h"
  15.  
  16. // SetRBlockData -    call to set the RBlockData structure
  17. void SetRBlockData( register RBlockDataPtr gridMove, register Size gridSize )
  18. {
  19. #ifdef powerc
  20.     gridMove->ndouble = gridSize/8;
  21.     gridSize -= gridMove->ndouble * 8;
  22. #endif
  23.     gridMove->nlong = gridSize/4;
  24.     gridSize -= gridMove->nlong * 4;
  25.     gridMove->nshort = gridSize/2;
  26.     gridSize -= gridMove->nshort * 2;
  27.     gridMove->nchar = gridSize;
  28. }
  29.  
  30. // RBlockMove -    special block move call
  31. void RBlockMove( register Ptr srcPos, register Ptr dstPos, register RBlockDataPtr data )
  32. {
  33.     register long                count;
  34. #ifdef powerc
  35.     for( count = 0; count < data->ndouble; count++ )
  36.         *((double *)dstPos)++ = *((double *)srcPos)++;
  37. #endif
  38.     for( count = 0; count < data->nlong; count++ )
  39.         *((long *)dstPos)++ = *((long *)srcPos)++;
  40.     for( count = 0; count < data->nshort; count++ )
  41.         *((short *)dstPos)++ = *((short *)srcPos)++;
  42.     for( count = 0; count < data->nchar; count++ )
  43.         *dstPos++ = *srcPos++;
  44. }