home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / GAMETP.ZIP / BEFFECTS.INT next >
Encoding:
Text File  |  1992-10-29  |  7.3 KB  |  193 lines

  1. Unit Beffects;
  2.  
  3. Interface
  4.  
  5. Uses VgaKern;
  6.  
  7. { Beffects version 1.0 Copyright (C) 1992 Scott D. Ramsay }
  8.  
  9. {   This unit is specifically for Mode 13h (320x200x256).  It is a    }
  10. { lot faster than using the BGI drivers (VGA256.BGI).  Majority of    }
  11. { the code is written using BASM.  This will work on 286 machines or  }
  12. { higher. "I don't know about the P5 chip though." ;)                 }
  13. {   This is my newest and most favorite unit.     Inspired by         }
  14. { Thunder Force III (I love Sega Genisis shoot-em ups), I wanted to   }
  15. { write games with Paralax Scrolling.  At first I thought PC's were   }
  16. { to slow. But yet I finally did it.  For full screen scrolling,      }
  17. { (320x200) I recommend a 386sx 25mhz.  But for smaller screens a     }
  18. { 16mhz machine is fine.  Even with 286 code.  I did test this on a   }
  19. { 486-50, (at work) but hell, what is slow on that machine. :>        }
  20. {   You'll need some sort of understanding of OOP programming for     }
  21. { this.  I'm really just starting to get into object oriented stuff.  }
  22. {   BEFFECTS.TPU can be used freely in commerical and non-commerical  }
  23. { programs.  As long as you don't give yourself credit for writing    }
  24. { this portion of the code.  When distributing it (free only), please }
  25. { include all files and samples so others may enjoy using the code.   }
  26. { Enjoy.                                                              }
  27.  
  28. { Please bear with my comments.  I'm not a tech-writer.  You're more }
  29. { than welcome to modify the comments in this file for people to     }
  30. { understand.                                                        }
  31.  
  32. const
  33.   wmax = 100;                           { max size for cosine table }
  34.  
  35. type
  36.   usercp       = procedure(f,t,yline:longint);
  37.                                        { type for user defined scrolling }
  38.   Pcycle       = ^Tcycle;
  39.   Tcycle       = object
  40.                    cyc_next,               { internal use value }
  41.                    cyc_x,cyc_y,            { window position, top-left }
  42.                    cyc_width,              { window width  }
  43.                    cyc_height,             { window height }
  44.                    cyclex,                 { value for moving horiz }
  45.                    fr_size,                { frequency size }
  46.                    am_size         : word; { amplitude size }
  47.                    cycle_cos       : array[0..wmax-1] of integer;
  48.                                            { cosine table }
  49.                    
  50.                    constructor init(freq,size:integer);
  51.                    destructor done;virtual;
  52.                    procedure changewave(freq,size:integer);virtual;
  53.                    procedure docycle(from,too,mode:byte); virtual;
  54.                    procedure cycle_move; virtual;
  55.                  end;
  56.  
  57. { See Implementation section for description of functions }
  58.  
  59. var
  60.   usercycle : usercp;           { see Tcycle.docycle }
  61.  
  62. procedure LineMove(s,d:longint;cnt:word);
  63. procedure WordMove(var source,dest;cnt:word);
  64. procedure CycleLine(f,t:longint;cyclex:word);
  65.  
  66. Implementation
  67.  
  68. (***********************************************************************)
  69. procedure linemove(s,d:longint;cnt:word);
  70.  
  71.    Copies (cnt) pixels from (s) to (d)
  72.      Moves in WORDS, cnt should be even and less than or equal to 320.
  73.  
  74. (***********************************************************************)
  75. procedure wordmove(var source,dest;cnt:word);
  76.  
  77.    Same as LineMove, but source and dest can be of any type.
  78.  
  79. (***********************************************************************)
  80. procedure cycleline(f,t:longint;cyclex:word);
  81.  
  82.    Copies a horizontal line length(320) a (f) to (t) at offset
  83.    of cyclex.  The overlapping pixels  wraps to the other side on
  84.    the same row.  { This is one of the main meat code }
  85.  
  86. (***********************************************************************)
  87. constructor Tcycle.init(freq,size:integer);
  88.  
  89.    freq : Cosine wave frequency
  90.    size : wave amplitude
  91.  
  92.    Sets vaules.  Calls  Tcycle.changewave
  93.  
  94. (***********************************************************************)
  95. destructor Tcycle.done;
  96.  
  97.   Doesn't really do much.
  98.  
  99. (***********************************************************************)
  100. procedure Tcycle.changewave(freq,size:integer);
  101.  
  102.    Recalcs the cosine table with new frequency and amplit. values.
  103.  
  104. (***********************************************************************)
  105. procedure Tcycle.cycle_move;
  106. begin
  107.   cyclex := (cyclex+1)mod 320;
  108. end;
  109.  
  110.   Simple one-liner procedure.  The above just moves cycles the image
  111.   to the left.  Decrementing cyclex moves it to the right.
  112.  
  113.  
  114. (***********************************************************************)
  115. procedure Tcycle.docycle(from,too,mode:byte);
  116.  
  117.    This is the procedure to call to do the cycling.
  118.  
  119.    from  : is the page with the background.
  120.    too   : is the destination of the modified background.
  121.    mode  : is the type of scrolling;
  122.  
  123.            0 : a straight page copy
  124.            1 : cycle left, right
  125.            2 : cycle left, right with cosine wave
  126.            3 : user defined cycle. { here is where you write you SFII
  127.                  scrolling type.  My not OOP version has it.  It takes
  128.                  more variables, e-mail me I'll send it to ya. }
  129.  
  130.    For mode 3,  each row is sent to procedure "usercycle"
  131.      example:
  132.  
  133.         procedure MyUserCycle(f,t,yline:longint);far;
  134.         { must be far procedure }
  135.         begin
  136.           { do line stuff }
  137.         end;
  138.  
  139.           .
  140.           .
  141.           .
  142.  
  143.         usercycle := MyUserCycle;
  144.  
  145.           .
  146.           .
  147.           .
  148.         p^.docycle(4,2,3); { cycle page 4 to page 2, user mode 3 }
  149.  
  150.  
  151.   { This is the other meaty procedure }
  152. (***********************************************************************)
  153.  
  154.  
  155. If you have any problems, e-mail at:
  156.  
  157.     ramsays@express.digex.com
  158.  
  159.   Sorry, I don't have permanent snail-mail address yet.  I just moved
  160.    to the Washington DC area.
  161.  
  162.   The TPU units can be used with in your programs.  With out giving
  163.    me credit.  If you want the source code, more samples or swap-talk,
  164.    just e-mail me.  I'll give sample use-code for free.  Actual TPU-source
  165.    code prices can be discussed.
  166.  
  167.   Also,  I have completed the following programs.
  168.  
  169.      GEOMAKER        Makes tile-maps quickly.
  170.      VSPMAKER        Makes the VSP files.
  171.      BKMAKER         A drawing program that can read
  172.                       VEW files (my own raw format)
  173.                       PTR files (my own compressed format)
  174.                       GIF files
  175.                       PCX files
  176.  
  177.   The three above programs are specifically designed for the 320x200x256
  178.   (game development).  I'll upload them when I think they are ready
  179.   to go. (Bout a week)
  180.  
  181.   (Artwork samples done by me.  Freeware.  Knock your-self out.
  182.    Plug.  Highly recommended.  For game programmers, try to get
  183.    Animator Pro by Autodesk.  This is an excellent program for
  184.    imaging, sprites and so forth. Very similar to the Animator,
  185.    but has better graphic features.  The 3D models are created
  186.    with 3D studio by Autodesk then ported to Animator Pro, then
  187.    scaled down/converted to my VSP files.  If you can blow a
  188.    few thousand bucks, buy the 3D studio.  You can do some
  189.    amazing 3D animations.  I can't afford it, I use it at
  190.    work.)
  191.  
  192.  
  193.    Scott D. Ramsay