home *** CD-ROM | disk | FTP | other *** search
- Unit Beffects;
-
- Interface
-
- Uses VgaKern;
-
- { Beffects version 1.0 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. :> }
- { You'll need some sort of understanding of OOP programming for }
- { this. I'm really just starting to get into object oriented stuff. }
- { 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. }
-
- 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 }
- cyc_x,cyc_y, { window position, top-left }
- cyc_width, { window width }
- cyc_height, { window height }
- 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: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:word);
-
- Copies a horizontal line length(320) 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@express.digex.com
-
- Sorry, I don't have permanent snail-mail address yet. I just moved
- to the Washington DC area.
-
- The TPU units can be used with in your programs. With out giving
- me credit. 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.
-
- Also, I have completed the following programs.
-
- GEOMAKER Makes tile-maps quickly.
- VSPMAKER Makes the VSP files.
- BKMAKER A drawing program that can read
- VEW files (my own raw format)
- PTR files (my own compressed format)
- GIF files
- PCX files
-
- The three above programs are specifically designed for the 320x200x256
- (game development). I'll upload them when I think they are ready
- to go. (Bout a week)
-
- (Artwork samples done by me. Freeware. Knock your-self out.
- Plug. Highly recommended. For game programmers, try to get
- Animator Pro by Autodesk. This is an excellent program for
- imaging, sprites and so forth. Very similar to the Animator,
- but has better graphic features. The 3D models are created
- with 3D studio by Autodesk then ported to Animator Pro, then
- scaled down/converted to my VSP files. If you can blow a
- few thousand bucks, buy the 3D studio. You can do some
- amazing 3D animations. I can't afford it, I use it at
- work.)
-
-
- Scott D. Ramsay