home *** CD-ROM | disk | FTP | other *** search
- Unit Beffects;
-
- Interface
-
- Uses VgaKern;
-
- { Beffects version 1.5 Copyright (C) 1992 Scott D. Ramsay }
-
- { This unit is specifically for Mode 13h (320x200x256). It is a }
- { lot faster than using the BGI drivers (VGA256.BGI). Majority of }
- { the code is written using BASM. This will work on 286 machines or }
- { higher. "I don't know about the P5 chip though." ;) }
- { This is my newest and most favorite unit. Inspired by }
- { Thunder Force III (I love Sega Genisis shoot-em ups), I wanted to }
- { write games with Paralax Scrolling. At first I thought PC's were }
- { to slow. But yet I finally did it. For full screen scrolling, }
- { (320x200) I recommend a 386sx 25mhz. But for smaller screens a }
- { 16mhz machine is fine. Even with 286 code. I did test this on a }
- { 486-50, (at work) but hell, what is slow on that machine. :> }
- { BEFFECTS.TPU can be used freely in commerical and non-commerical }
- { programs. As long as you don't give yourself credit for writing }
- { this portion of the code. When distributing it (free only), please }
- { include all files and samples so others may enjoy using the code. }
- { Enjoy. }
-
- { Please bear with my comments. I'm not a tech-writer. You're more }
- { than welcome to modify the comments in this file for people to }
- { understand. "Except for my name." :) }
-
- { Changes from version 1.0 }
- { Added new variables to Tcycle }
- { from_x,from_y source top-left positon of orig background }
- { cycley value for moveing vertical position }
- { scrolling now supports all directions }
- { Procedure CycleLine modified to wrap at specified width instead }
- { of a default of 320. }
- { Method TCycle.docycle improved. Can't tell you how. It is more }
- { efficent. }
-
- const
- wmax = 100; { max size for cosine table }
-
- type
- usercp = procedure(f,t,yline:longint);
- { type for user defined scrolling }
- Pcycle = ^Tcycle;
- Tcycle = object
- cyc_next, { internal use value }
- from_x,from_y, { top-left of source image }
- cyc_x,cyc_y, { window position, top-left }
- cyc_width, { window width }
- cyc_height, { window height }
- cycley, { value for moving vert }
- cyclex, { value for moving horiz }
- fr_size, { frequency size }
- am_size : word; { amplitude size }
- cycle_cos : array[0..wmax-1] of integer;
- { cosine table }
-
- constructor init(freq,size:integer);
- destructor done;virtual;
- procedure changewave(freq,size:integer);virtual;
- procedure docycle(from,too,mode:byte); virtual;
- procedure cycle_move; virtual;
- end;
-
- { See Implementation section for description of functions }
-
- var
- usercycle : usercp; { see Tcycle.docycle }
-
- procedure LineMove(s,d:longint;cnt:word);
- procedure WordMove(var source,dest;cnt:word);
- procedure cycleline(f,t:longint;cyclex,cycle_width:word);
-
- Implementation
-
- (***********************************************************************)
- procedure linemove(s,d:longint;cnt:word);
-
- Copies (cnt) pixels from (s) to (d)
- Moves in WORDS, cnt should be even and less than or equal to 320.
-
- (***********************************************************************)
- procedure wordmove(var source,dest;cnt:word);
-
- Same as LineMove, but source and dest can be of any type.
-
- (***********************************************************************)
- procedure cycleline(f,t:longint;cyclex,cycle_width:word);
-
- Copies a horizontal line length(cycle_width) a (f) to (t) at offset
- of cyclex. The overlapping pixels wraps to the other side on
- the same row. { This is one of the main meat code }
-
- (***********************************************************************)
- constructor Tcycle.init(freq,size:integer);
-
- freq : Cosine wave frequency
- size : wave amplitude
-
- Sets vaules. Calls Tcycle.changewave
-
- (***********************************************************************)
- destructor Tcycle.done;
-
- Doesn't really do much.
-
- (***********************************************************************)
- procedure Tcycle.changewave(freq,size:integer);
-
- Recalcs the cosine table with new frequency and amplit. values.
-
- (***********************************************************************)
- procedure Tcycle.cycle_move;
- begin
- cyclex := (cyclex+1)mod 320;
- end;
-
- Simple one-liner procedure. The above just moves cycles the image
- to the left. Decrementing cyclex moves it to the right.
-
-
- (***********************************************************************)
- procedure Tcycle.docycle(from,too,mode:byte);
-
- This is the procedure to call to do the cycling.
-
- from : is the page with the background.
- too : is the destination of the modified background.
- mode : is the type of scrolling;
-
- 0 : a straight page copy
- 1 : cycle left, right
- 2 : cycle left, right with cosine wave
- 3 : user defined cycle. { here is where you write you SFII
- scrolling type. My not OOP version has it. It takes
- more variables, e-mail me I'll send it to ya. }
-
- For mode 3, each row is sent to procedure "usercycle"
- example:
-
- procedure MyUserCycle(f,t,yline:longint);far;
- { must be far procedure }
- begin
- { do line stuff }
- end;
-
- .
- .
- .
-
- usercycle := MyUserCycle;
-
- .
- .
- .
- p^.docycle(4,2,3); { cycle page 4 to page 2, user mode 3 }
-
-
- { This is the other meaty procedure }
- (***********************************************************************)
-
-
- If you have any problems, e-mail at:
-
- ramsays@access.digex.com
-
- The TPU units can be used freely with in your programs. If you want
- the source code, more samples or swap-talk, just e-mail me. I'll
- give sample use-code for free. Actual TPU-source code prices can be
- discussed.
-
-
- Scott D. Ramsay