home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / pascal / spx10.zip / SPX_DOC.ZIP / SPX_EFF.DOC next >
Text File  |  1993-05-05  |  6KB  |  182 lines

  1. { SPX Library Version 1.0  Copyright 1993 Scott D. Ramsay }
  2.  
  3.   SPX_EFF is the background effects unit.  It allows for special effect
  4. for backgrounds.  Such as parallax scrolling and background panning.
  5.   In effect the unit SPX_EFF is an enhanced version of a page copy routine.
  6. It does a 'warped' or modified copy from one page to another.
  7.  
  8. See DEMO1.PAS for code example
  9.  
  10. ───────────────────────────────────────────────────────────────────────────
  11. type
  12.   Pcycle       = ^Tcycle;
  13.   Tcycle       = object
  14.  
  15.   Tcycle is the main effects object.  There are many variables that effect
  16. the way one can display a background.
  17.  
  18. VARIABLES:
  19.      cyc_next:   The current value of the frequency counter.  By defalt its
  20.                  resolution changes every line drawn from 0..wmax-1;
  21.      from_x:     Left (X) position of the source page to copy;
  22.      from_y:     Top (Y) position of the source page to copy;
  23.      cyc_x:      Left (X) position of the destination page;
  24.      cyc_y:      Top (Y) position of the destination page;
  25.      cyc_width:  Width of the region to copy;
  26.      cyc_height: Height of the region to copy;
  27.      cycley:     Pan (Y) offset position. Value should be 0..cyc_height-1;
  28.      cyclex:     Pan (X) offset position. Value should be 0..cyc_width-1;
  29.      fr_size:    Calcuated frequency size. (Used for cosine copies);
  30.      am_size:    Amplitude size of cosine wave;
  31.      cycle_cos:  Cosine table
  32.  
  33.      ---------------------------------------------------
  34.      constructor Tcycle.init(freq,size:integer);
  35.  
  36.      Sets up the object.
  37.  
  38.       FREQ:   Frequency for cosine wave;
  39.       SIZE:   Cosine wave height (Amplitude)
  40.  
  41.      DEFAULTS:
  42.         CYCLEX       0
  43.         CYCLEY       0
  44.         CYC_WIDTH    320
  45.         CYC_HEIGHT   200
  46.  
  47.      ---------------------------------------------------
  48.      destructor Tcycle.done;virtual;
  49.  
  50.      Preforms and deallocation of the object;
  51.  
  52.      ---------------------------------------------------
  53.      procedure Tcycle.changewave(freq,size:integer);virtual;
  54.  
  55.      Changes the cosine table.
  56.  
  57.       FREQ:   Frequency for cosine wave;
  58.       SIZE:   Cosine wave height (Amplitude)
  59.  
  60.      ---------------------------------------------------
  61.      procedure Tcycle.docycle(from,too,mode:byte); virtual;
  62.  
  63.      Preforms an effect copy.
  64.  
  65.      FROM:  Source page to copy;
  66.      TOO:   Destination page;
  67.      MODE:  Type of copy
  68.  
  69.                  0  Regular copy
  70.                  1  Regular copy with panning
  71.                  2  Cosine wave copy
  72.                  3  User defined copy
  73.  
  74.      When setting the mode to 3, a call to usercycle is made for each
  75.      iteration of a horzontal line copied.  See procedure "usercycle" below.
  76.  
  77.      ---------------------------------------------------
  78.      procedure Tcycle.cycle_move; virtual;
  79.  
  80.      Pan procedure.  Updates the cyclex and cycley variables.
  81.  
  82.      OVERRIDE: often
  83.  
  84.      Use this procedure to update the panning coordintes.  The pan
  85.      coordinates are often linked to the player's user position to
  86.      create background motion.
  87.  
  88.      ---------------------------------------------------
  89.      procedure Tcycle.adjustcyclenext; virtual;
  90.  
  91.      Modifies the cyc_next variable.
  92.  
  93.      OVERRIDE: seldom.
  94.  
  95. ───────────────────────────────────────────────────────────────────────────
  96.  
  97. type
  98.   usercp = procedure (f,t,yline:longint);
  99.  
  100. var
  101.   usercycle : usercp; { user cycle procedure }
  102.   
  103.   When Tcycle.docycle is called with mode=3,  usercycle is called.  You must
  104.   define your own procedure and assign it to usercycle so that docycle will
  105.   call your procedure.
  106.  
  107.      procedure MyCycleLine(f,t,yline:longint);far;
  108.      begin
  109.      end;
  110.          .
  111.          .
  112.          .
  113.  
  114.      usercycle := MyCycleLine;
  115.  
  116.   Note that MyCycleLine must be declared as a far procedure and has the
  117.  same parameter list as usercp type.
  118.  
  119.    usercycle takes three arguments:
  120.  
  121.       F:     Pointer to the source page
  122.       T:     Pointer to the destination page
  123.       YLINE: Current row being displayed.
  124.  
  125.    To use F or T, typecast it as as a pointer. e.g.
  126.  
  127.      move(pointer(f)^,pointer(t)^,20); { copy 20 bytes }
  128.  
  129. ───────────────────────────────────────────────────────────────────────────
  130. procedure linemove(s,d:longint;cnt:word);
  131.  
  132.   Copies a segment of bytes from S to D.
  133.  
  134.       S:    Pointer to source;
  135.       D:    Pointer to destination;
  136.       CNT:  Number of byte to move
  137.  
  138. ───────────────────────────────────────────────────────────────────────────
  139. procedure wordmove(var source,dest;cnt:word);
  140.  
  141.   Copies a segment of bytes from S to D.
  142.  
  143.       S:    Pointer to source;
  144.       D:    Pointer to destination;
  145.       CNT:  Number of byte to move
  146.  
  147.   Uses word copies, use only if cnt is an even number.
  148.  
  149. ───────────────────────────────────────────────────────────────────────────
  150. procedure cycleline(f,t:longint;cyclex,cycle_width:word);
  151.  
  152.   Copies a segment of bytes from F to T.  wraping the bytes if needed.
  153.  
  154.       F:           Pointer to source;
  155.       T:           Pointer to destination;
  156.       cyclex:      Offset in destination;
  157.       cycle_width  Width of destination
  158.  
  159.    Example:
  160.  
  161.      F=source   T=Destination   cyclex=4   cycle_width=8
  162.        ┌──┬──┬──┬──┬──┬──┬──┬──┐
  163.     F  │ 1│ 2│ 3│ 4│ 5│ 6│ 7│ 8│
  164.        └──┴──┴──┴──┴──┴──┴──┴──┘
  165.  
  166.        ┌──┬──┬──┬──┬──┬──┬──┬──┐
  167.     T  │ 5│ 6│ 7│ 8│ 1│ 2│ 3│ 4│
  168.        └──┴──┴──┴──┴──┴──┴──┴──┘
  169.  
  170.  
  171.      F=source   T=Destination   cyclex=0   cycle_width=8
  172.        ┌──┬──┬──┬──┬──┬──┬──┬──┐
  173.     F  │ 1│ 2│ 3│ 4│ 5│ 6│ 7│ 8│
  174.        └──┴──┴──┴──┴──┴──┴──┴──┘
  175.  
  176.        ┌──┬──┬──┬──┬──┬──┬──┬──┐
  177.     T  │ 1│ 2│ 3│ 4│ 5│ 6│ 7│ 8│
  178.        └──┴──┴──┴──┴──┴──┴──┴──┘
  179.  
  180. ───────────────────────────────────────────────────────────────────────────
  181.  
  182.