home *** CD-ROM | disk | FTP | other *** search
/ Photo CD Demo 1 / Demo.bin / cellsim / v2_5 / cm2 / rule_src / htbl256r.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-02-26  |  2.0 KB  |  67 lines

  1. /*
  2.  * File: heat.l256r2.c
  3.  *   By: Dave Hiebeler
  4.  *       hiebeler@turing.cs.rpi.edu
  5.  *       Feb. 1990
  6.  *
  7.  * The "heat" rule in the linear neighborhood.  parm2 is the increment
  8.  * added to each cell after it takes on the local average value.
  9.  *
  10.  * This rule is one where I accidentally set the context-flag on *all*
  11.  * processors before adding in the increment.  Normally, the context-flag
  12.  * should only be set on processors on the bottom row, for a linear rule.
  13.  * What this does is just make cells cycle through the colormap as they
  14.  * scroll up; no heat-diffusion occurs except on the bottom row.  But the
  15.  * rule looks so fascinating when running on the frame-buffer, that I
  16.  * figured I'd include it.
  17.  * It doesn't look like anything special when you run it on a Sun display,
  18.  * unfortunately -- you really need to see the dynamics for it to be
  19.  * interesting. (Hm, maybe Thinking Machines should give me a commission if
  20.  * they suddenly start selling more framebuffers...)
  21.  *
  22.  * A random starting config works with some settings of the parameters.
  23.  * For other settings, you may want to use a "hot array with a cold hole",
  24.  * as described in "heat.m256.c".  In this case, however, the "hole"
  25.  * should be on the bottom line of the array.
  26.  *
  27.  */
  28.  
  29.  
  30. #include "CMnborhood.h"
  31.  
  32. byte heat(), heat_exit();
  33. static CM_field_id_t heat_sum;
  34.  
  35.  
  36. void
  37. init_function()
  38. {
  39.  
  40.     update_function = heat;
  41.     parm2 = 2;
  42.     heat_sum = CM_allocate_heap_field(11);
  43. }
  44.  
  45.  
  46. byte
  47. heat()
  48. {
  49.     CM_u_move_zero_1L(heat_sum, 11);
  50.     CM_u_add_3_3L(heat_sum, heat_sum, LR2_LL, 11, 11, 8);
  51.     CM_u_add_3_3L(heat_sum, heat_sum, LR2_L, 11, 11, 8);
  52.     CM_u_add_3_3L(heat_sum, heat_sum, LR2_C, 11, 11, 8);
  53.     CM_u_add_3_3L(heat_sum, heat_sum, LR2_R, 11, 11, 8);
  54.     CM_u_add_3_3L(heat_sum, heat_sum, LR2_RR, 11, 11, 8);
  55.     CM_u_truncate_constant_3_1L(heat_sum, heat_sum, 5, 11);
  56.     CM_u_move_1L(cell, heat_sum, 8);
  57.     CM_set_context();
  58.     CM_u_add_constant_2_1L(cell, parm2, 8);
  59. }
  60.  
  61.  
  62. byte
  63. heat_exit()
  64. {
  65.     CM_deallocate_heap_field(heat_sum);
  66. }
  67.