home *** CD-ROM | disk | FTP | other *** search
/ Photo CD Demo 1 / Demo.bin / cellsim / v2_5 / src / nborhood.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-02-26  |  4.1 KB  |  167 lines

  1. /*****
  2.  *
  3.  * File: nborhood.h
  4.  *   By: Dave Hiebeler
  5.  *       Summer 1989
  6.  *
  7.  * Definitions of neighborhood-structures and macros for use with
  8.  * the 256-state computed-function updating.
  9.  *
  10.  *****/
  11.  
  12. /*
  13.  *
  14.  * Cellsim copyright 1989, 1990 by Chris Langton and Dave Hiebeler
  15.  * (cgl@lanl.gov, hiebeler@heretic.lanl.gov)
  16.  *
  17.  * This package may be freely distributed, as long as you don't:
  18.  * - remove this notice
  19.  * - try to make money by doing so
  20.  * - prevent others from copying it freely
  21.  * - distribute modified versions without clearly documenting your changes
  22.  *   and notifying us
  23.  *
  24.  * Please contact either of the authors listed above if you have questions
  25.  * or feel an exception to any of the above restrictions is in order.
  26.  *
  27.  * If you make changes to the code, or have suggestions for changes,
  28.  * let us know!  If we use your suggestion, you will receive full credit
  29.  * of course.
  30.  */
  31.  
  32. /*****
  33.  * Cellsim history:
  34.  *
  35.  * Cellsim was originally written on Apollo workstations by Chris Langton.
  36.  *
  37.  * Sun versions:
  38.  *
  39.  * - version 1.0
  40.  *   by C. Ferenbaugh and C. Langton
  41.  *   released 09/02/88
  42.  *
  43.  * - version 1.5
  44.  *   by Dave Hiebeler and C. Langton  May - June 1989
  45.  *   released 07/03/89
  46.  *
  47.  * - version 2.0
  48.  *   by Dave Hiebeler and C. Langton  July - August 1989
  49.  *   never officially released (unofficially released 09/08/89)
  50.  *
  51.  * - version 2.5
  52.  *   by Dave Hiebeler and C. Langton  September '89 - February 1990
  53.  *   released 02/26/90
  54.  *****/
  55.  
  56.  
  57.  
  58. typedef unsigned char byte;
  59.  
  60.  
  61. /* Use integers, because when you do arithmetic with unsigned
  62.  * characters overflow is a pain.
  63.  */
  64. typedef int cell_value;
  65.  
  66.  
  67. typedef struct {
  68.     cell_value tl, l, bl, t, c, b, tr, r, br,
  69.     x, y, time, parm1, parm2;
  70. } moore_nbors;
  71.  
  72. typedef struct {
  73.     cell_value l, t, c, b, r,
  74.     x, y, time, parm1, parm2;
  75. } vonn_nbors;
  76.  
  77. typedef struct {
  78.     cell_value c, ccw, opp, cw, phase,
  79.     x, y, time, parm1, parm2;
  80. } margolus_nbors;
  81.  
  82. typedef struct {
  83.     cell_value l, c, r,
  84.     x, time, parm1, parm2;
  85. } lr1_nbors;
  86.  
  87. typedef struct {
  88.     cell_value ll, l, c, r, rr,
  89.     x, time, parm1, parm2;
  90. } lr2_nbors;
  91.  
  92. typedef struct {
  93.     cell_value lll, ll, l, c, r, rr, rrr,
  94.     x, time, parm1, parm2;
  95. } lr3_nbors;
  96.  
  97. typedef struct {
  98.     unsigned char *array;
  99.     int time;
  100.     int size;
  101.     int parm1, parm2;
  102. } array_info_struct;
  103.  
  104.  
  105. cell_value
  106.     tl, l, bl, t, c, b, tr, r, br, ll, rr, lll, rrr, cw, ccw, opp, phase,
  107.     x, y, time, parm1, parm2;
  108.  
  109. #define Get_moore_nbors \
  110.     tl = nbors->tl; l = nbors->l; bl = nbors->bl; \
  111.     t = nbors->t; c = nbors->c; b = nbors->b; \
  112.     tr = nbors->tr; r = nbors->r; br = nbors->br; \
  113.     parm1 = nbors->parm1; parm2 = nbors->parm2 ; \
  114.     x = nbors->x ; y = nbors->y ; time = nbors->time;
  115.  
  116. #define Get_vonn_nbors \
  117.     l = nbors->l; c = nbors->c; r = nbors->r; t = nbors->t; b = nbors->b; \
  118.     parm1 = nbors->parm1; parm2 = nbors->parm2 ; \
  119.     x = nbors->x ; y = nbors->y ; time = nbors->time;
  120.  
  121. #define Get_margolus_nbors \
  122.     c = nbors->c; ccw = nbors->ccw; opp = nbors->opp; cw = nbors->cw; \
  123.     phase = nbors->phase; \
  124.     parm1 = nbors->parm1; parm2 = nbors->parm2 ; \
  125.     x = nbors->x ; y = nbors->y ; time = nbors->time;
  126.  
  127. #define Get_l_nbors \
  128.     l = nbors->l; c = nbors->c; r = nbors->r; \
  129.     parm1 = nbors->parm1; parm2 = nbors->parm2 ; \
  130.     x = nbors->x ; time = nbors->time;
  131.  
  132. #define Get_lr1_nbors Get_l_nbors
  133.  
  134. #define Get_lr2_nbors \
  135.     ll = nbors->ll; l = nbors->l; c = nbors->c; r = nbors->r; rr = nbors->rr; \
  136.     parm1 = nbors->parm1; parm2 = nbors->parm2 ; \
  137.     x = nbors->x ; time = nbors->time;
  138.  
  139. #define Get_lr3_nbors \
  140.     lll = nbors->lll; ll = nbors->ll; l = nbors->l; c = nbors->c; \
  141.     r = nbors->r; rr = nbors->rr; rrr = nbors->rrr; \
  142.     parm1 = nbors->parm1; parm2 = nbors->parm2 ; \
  143.     x = nbors->x ; time = nbors->time;
  144.  
  145.  
  146. /* Some aliases */
  147. #define center c
  148. #define north t
  149. #define south b
  150. #define east r
  151. #define west l
  152. #define northeast tr
  153. #define southeast br
  154. #define northwest tl
  155. #define southwest bl
  156. #define clockwise cw
  157. #define counterclockwise ccw
  158. #define opposite opp
  159.  
  160.  
  161. typedef unsigned char ((*func_ptr)());
  162. typedef void ((*void_func_ptr)());
  163.  
  164. extern func_ptr update_function;
  165. extern void_func_ptr before_function, after_function;
  166.  
  167.