README.TXT and DOCUMENTATION
USE EDIT or the QB IDE(Edit Mode) to view this document.
May 22,2002


*** DEVELOPER ***


Name: Richard Eric M. Lope aka RelSoft
Degree: BS Nursing
Country: Philippines
Email: vic_viperph@yahoo.com
SMS: +639192195056
Address: Block 36,Lot 8, Florvel Homes Subd,Buray,Oton, Iloilo, Philippines

Game Programming Group: AuraFlow

AuraFlow Site:
Http://AuraFlow.Curvehead.Com

Members:

Eero Pitkanen aka Eebro/Ebr             
Adigun Polack
Bobby Leigh aka Beta_SS
Achmad Aulia aka L_O_J
Richard Eric M. Lope aka Relsoft


*** ARCHIVE NOTES ***

RelGFX.BAS
        >Contains the WHOLE SUB and FUNCTIONS to be used.  Cut and Paste to
        use in your programs.
MiniRPG.BAS(MINIRPG Folder)
MiniRPG.EXE
All the PUT/PAL File
        >All the Files needed to use the MiniRPG demo.
        >Try to walk on the FIRST column of the map to see how collison
        >detection is implemeted
        >Press TAB to change the player.
GFXSAMP.BAS
        >a cheesy example on howe to use the routines.
PP256.PAL made by darkdread.
        >A gradient pp256 Pal format which you can load to pp256 for
        editing your tiles.  RelPal is a 768 byte Pal file converted from
        PP256.PAL for memory issues. You can use your own gradient palette as
        long as its in 16 color blocks.


*** DISCLAIMER ***

        Do we need this?? Okay, I'm not responsible for anything. Use or
Abuse this routines as much as you want and you don't have to credit me for
as long as you understand the concepts that make these things work.
        My only request is that you put the address of our site(Auraflow)
<AuraFlow.Curvehead.Com> somewhere on your program.
        If you decide to use the TILES from the MINIRPG, pls contact Achmad
Aulia first.  If you also want to use the Fonts, pls contact Adigun A. Polack.
Both of them are members of Auraflow and email addresses are provided at
our site.
        For any additional questions, pls post it at the auraflow forum site.
        There are some example files for you to enjoy. So enjoy and happy
coding!!!! Blah,blah,blah................

*** INTRODUCTION ***


        These are Some Pure QB pageing, drawing, sprite, etc. routines I made
for people want their games or utilities in pure QB.  These are not fast but
they are not slow either.  Gauging from tests, all of the people who had the
opportunity to see the demos are very much impressed by the speed of these
routines considering that they are in pure QB.  The miniRpg engine I made
using this routines is playable on my 486!!! About 17-20 FPS on a 2 layered
map and about 26-30 on a single layered map all with tile by tile collision!

        I can make this faster but it would mean less FLEXIBILITY.  This is
in my opinion the more "BALANCED" of all the routines I made(Speed VS ease
of use/Memory consumption, etc.)  If you want the "for speed" version, we at
Auraflow, can give it to anyone who wants it as we are developing an RPG using
that version.

I and one member L_O_J, are using templates for our sprites(Still QB Get/Put
compatible but a little harder to use and understand.  Still there is another
way I developed that uses INTEGERS for our Get/Put array and its a hell lot
faster that this one or the templated one(about 2-3x) but it would mean that
your array will use-up about twice the memory required for your sprites.
Nonetheless, I included a pp256 to integer array converter(Rel.ConvertPP256)
for you to use if you wanted sheer speed. L_O_J even has made his own special
index to gain more speed.

        I used the normal method of multiple DEF SEGs because its the most
flexible and the most linear method that I found and it could also be trans-
lated well to any language of your choice, be it Pascal,C or Assembly. In
fact, you can see here how I did my clipping algorithm (Particularly the
Sprites!!!) in my ASM RelLib. :*) And yes, this does GAMMA and TRANSLUCENCY
with no look-up tables and does it fast enough. :*)

        Lastly, I AM NOT A LIB HATER. In fact, I have an ASM lib running
around the Qmunity and is used by a lot of people including me.  Its called
RELLIB and its extremely fast!  Then again, you ask, "Why are you making this
when you have a very fast LIB around?". The answer lies to the fact that there
are still purists who like to pursue coding in PureQB. That's why I'm giving
them a choice....."To be or not to be.", Hamlet by you-know-who. :*)
        


*** SUB AND FUNCTION SUMMARY ***




*** SUBS ***
*** SUBS ***
*** SUBS ***





*** PAGEING ROUTINES ***





SUB Rel.PageClear (VideoBuf() AS INTEGER) STATIC

        Parameters:
                VideoBuf()=the buffer to clear to color zero(0)
        Description:
                Clears the page to color zero
        How to use:
                Rel.PageClear Vpage()
                *Clears the current page to 0
        Notes:
                Use this instead of Rel.PageCls if you just want to clear the
                page to zero.

SUB Rel.PageCls (VideoBuf(), CLR) STATIC

        Parameters:
                VideoBuf()=the buffer to clear to color Clr
        Description:
                Clears the page to color Clr
        How to use:
                Rel.PageCls Vpage(),15
                *Clears the current page to 15
        Notes:
                *Use this for a colored cls of your page.

SUB Rel.PageInit (VideoBuf(), Xmax, Ymax) STATIC

        Parameters:
                VideoBuf()=the buffer to initialize
                Xmax=the maximum number of x-pixels
                Ymax=the maximum number of y-pixels
        Description:
                Initializes the page and the static Look-up table(Speed) for
                use afterwards.
        How to use:
                Rel.PageInit VPage()
                *Initializes the page
        Notes:
                *Use this before writing to the page that you want to write
                to. You can set the maximum y to 199 and maximum of x to
                319. Using this method can greatly save memory as the memory
                required by a particular page is determined by its dimension.
                You can also set this as less than 319 1nd 199 for clipping.
                *Only call this ONCE for every page.

SUB Rel.PageVideoCopy (X, Y, VideoBuf(), Action) STATIC

        Parameters:
                X=\ the upper left corners of the
                Y=/ page to be blitted to screen
                VideoBuf()=the buffer to copy to the screen
                Action: could be 1,2,3,4(anything else will default to 1)
                        1= PSET (Solid)
                        2= AND
                        3= OR
                        4= XOR
        Description:
                Blits the buffer to the screen in a very fast manner as this
                uses the normal QB put routine.                        
        How to use:
                Rel.PageVideoCopy 0,0,VPage()
                *Blits the page to the upper left corner of the screen(0,0)
        Notes:
                *Be sure that the page x-wise or y-wise will fit the screen
                as this uses the normal PUT routine.

SUB Rel.SetActivePage (VideoBuf())

        Parameters:
                VideoBuf()=the buffer to write to
        Description:
                Reinitializes the Lookup table and sets the current buffer
                as the default page to write to.
        How to use:
                Rel.SetActivePage VPage()
                *Sets Vpage as the current default page.
        Notes:
                *The good thing about this is you can have multiple pages and
                the page size are dynamic. Meaning that the amount of memory
                the page requires is directly proportional to its size. Also
                you could write to the buffer and VideoCopy it to screen to
                stay there so no time is wasted farting around drawing static
                and non-changing tiles per frame. See the MINI RPG demo for
                more info on how to use this effectively.

SUB Rel.CopyPage (DestBuffer(), SrcBuffer())

        Parameters:
                DestBuffer()=the buffer to write to
                SrcBuffer() =the buffer to copy from
        Description:
                This works like Rel.PageVideoCopy but copies the contents of
                DestBuffer to SrcBuffer instead. Much like how you would use
                PCOPY.
        How to use:
                Rel.CopyPage VPage(),Vpage2()
                *Copies the value of Vpage2() to Vpage()
        Notes:
                *This is used to copy any background that you previously
                wrote to Vpage2 for games with backgrounds. This is very fast
                as this moves Words. LOL





*** DRAWING PRIMITIVES ***




SUB Rel.Box (VideoBuf(), X1, Y1, X2, Y2, CLR)

        Parameters:
                VideoBuf()=the buffer to write to
                X1=Left Coord
                Y1=Top Coord
                X2=Right Coord
                Y2=Bottom Coord
                Clr=Color of Box
        Description:
                Draws a box defined by the coords X1,Y1,X2,Y2 with color clr.
        How to use:
                Rel.Box VPage(),10,10,100,100,15
                *Draws a box at Vpage() colored 15
        Notes:
                *Clipping is supported so no errors would occur.  You can even
                have negative values for the coords.

SUB Rel.BoxF (VideoBuf(), X1, Y1, X2, Y2, CLR)

        Parameters:
                VideoBuf()=the buffer to write to
                X1=Left Coord
                Y1=Top Coord
                X2=Right Coord
                Y2=Bottom Coord
                Clr=Color of Box
        Description:
                Draws a FILLED box defined by the coords X1,Y1,X2,Y2 with
                color clr.
        How to use:
                Rel.BoxF VPage(),10,10,100,100,15
                *Draws a FILLED box at Vpage() colored 15
        Notes:
                *Clipping is supported so no errors would occur.  You can even
                have negative values for the coords.

SUB Rel.BoxFT (VideoBuf(), X1, Y1, X2, Y2, CLR)

        Parameters:
                VideoBuf()=the buffer to write to
                X1=Left Coord
                Y1=Top Coord
                X2=Right Coord
                Y2=Bottom Coord
                Clr=Color of Box
        Description:
                Draws a FILLED box defined by the coords X1,Y1,X2,Y2 with
                color clr. Translucently!!!!
        How to use:
                Rel.BoxFT VPage(),10,10,100,100,15
                *Draws a Translucent Filled box at Vpage() colored 15
        Notes:
                *Clipping is supported so no errors would occur.  You can even
                have a negative values for the coords. Uses a 16 color
                gradient Palette to work.

SUB Rel.BoxT (VideoBuf(), X1, Y1, X2, Y2, CLR)

        Parameters:
                VideoBuf()=the buffer to write to
                X1=Left Coord
                Y1=Top Coord
                X2=Right Coord
                Y2=Bottom Coord
                Clr=Color of Box
        Description:
                Draws a box defined by the coords X1,Y1,X2,Y2 with
                color clr. Translucently!!!!
        How to use:
                Rel.BoxT VPage(),10,10,100,100,15
                *Draws a Translucent box at Vpage() colored 15
        Notes:
                *Clipping is supported so no errors would occur.  You can even
                have a negative values for the coords. Uses a 16 color
                gradient Palette to work.

SUB Rel.Ellipse (VideoBuf(), Xcenter, Ycenter, Xrad, Yrad, CLR)

        Parameters:
                VideoBuf()=the buffer to write to
                Xcenter=\ center coords of
                Ycenter=/ the ellipse
                Xrad=X radius if the ellipse
                Yrad=Y radius if the ellipse
                Clr=Color of the ellipse
        Description:
                Draws an ellipse(oval) defined by the above parameters
        How to use:
                Rel.Ellipse VPage(),100,100,10,20,200
                *Draws an ellipse at (100,100) with an Xrad of 10 and a
                Yrad of 20 with color 200
        Notes:
                *Clipping is supported so no errors would occur. To draw a
                circle, use the same values for Xrad and Yrad.

SUB Rel.EllipseF (VideoBuf(), Xcenter, Ycenter, Xrad, Yrad, CLR)

        Parameters:
                VideoBuf()=the buffer to write to
                Xcenter=\ center coords of
                Ycenter=/ the ellipse
                Xrad=X radius if the ellipse
                Yrad=Y radius if the ellipse
                Clr=Color of the ellipse
        Description:
                Draws a FILLED ellipse(oval) defined by the above parameters
        How to use:
                Rel.EllipseF VPage(),100,100,10,20,200
                *Draws a Filled ellipse at (100,100) with an Xrad of 10 and a
                Yrad of 20 with color 200
        Notes:
                *Clipping is supported so no errors would occur. To draw a
                circle, use the same values for Xrad and Yrad.

SUB Rel.EllipseFT (VideoBuf(), Xcenter, Ycenter, Xrad, Yrad, CLR)

        Parameters:
                VideoBuf()=the buffer to write to
                Xcenter=\ center coords of
                Ycenter=/ the ellipse
                Xrad=X radius if the ellipse
                Yrad=Y radius if the ellipse
                Clr=Color of the ellipse
        Description:
                Draws a FILLED ellipse(oval) defined by the above parameters
                Translucently!!!!
        How to use:
                Rel.EllipseFT VPage(),100,100,10,20,200
                *Draws a Filled ellipse at (100,100) with an Xrad of 10 and a
                Yrad of 20 with color 200
        Notes:
                *Clipping is supported so no errors would occur. To draw a
                circle, use the same values for Xrad and Yrad. Needs a
                gradient palette to work.

SUB Rel.EllipseT (VideoBuf(), Xcenter, Ycenter, Xrad, Yrad, CLR)

        Parameters:
                VideoBuf()=the buffer to write to
                Xcenter=\ center coords of
                Ycenter=/ the ellipse
                Xrad=X radius if the ellipse
                Yrad=Y radius if the ellipse
                Clr=Color of the ellipse
        Description:
                Draws an ellipse(oval) defined by the above parameters
                Translucently!!!!
        How to use:
                Rel.Ellipse VPage(),100,100,10,20,200
                *Draws an ellipse at (100,100) with an Xrad of 10 and a
                Yrad of 20 with color 200
        Notes:
                *Clipping is supported so no errors would occur. To draw a
                circle, use the same values for Xrad and Yrad. Needs a
                gradient palette to work.

SUB Rel.Line (VideoBuf(), X, Y, X2, Y2, CLR)

        Parameters:
                VideoBuf()=the buffer to write to
                X1=Left Coord
                Y1=Top Coord
                X2=Right Coord
                Y2=Bottom Coord
                Clr=Color of Line
        Description:
                Draws a ddiagonal line using the above coordinates and color.
                Works like QB's LINE statement.
        How to use:
                Rel.Line VPage(),10,10,120,190,31
                *Draws a line with color 31
        Notes:
                *Clipping is supported so no errors would occur. 

SUB Rel.LineT (VideoBuf(), X, Y, X2, Y2, CLR)

        Parameters:
                VideoBuf()=the buffer to write to
                X1=Left Coord
                Y1=Top Coord
                X2=Right Coord
                Y2=Bottom Coord
                Clr=Color of Line
        Description:
                Draws a ddiagonal line using the above coordinates and color.
                Works like QB's LINE statement. Translucent line.
        How to use:
                Rel.Line VPage(),10,10,120,190,31
                *Draws a line with color 31
        Notes:
                *Clipping is supported so no errors would occur. 
                Needs a gradient palette to work.

SUB Rel.Pset (VideoBuf(), X, Y, CLR) STATIC

        Parameters:
                VideoBuf()=the buffer to write to
                X=\ coords of the 
                Y=/ point to pset
                Clr=Color of the pixel
        Description:
                Draws a pixel at coords(X,Y) in color clr
        How to use:
                Rel.Pset VPage(),10,10,120
                *Draws a pixel with color 120
        Notes:
                *Clipping is supported so no errors would occur. 





*** SPRITE ROUTINES ***






SUB Rel.Sprite (VideoBuf(), X, Y, Sprite(), SpriteOffSet)

        Parameters:
                VideoBuf()=the buffer to write to
                X=\ Top left coords of the 
                Y=/ Sprite to draw
                Sprite()= the array for the sprite which was made either
                        by PP256, QB's GET or Rel.GET
                SpriteOffset = an integer offset(index) of the sprite for
                        multiple tiles in one array.
        Description:
                Draws a sprite at coordinates X,Y skipping color 0 so there
                is no need for masks.
        How to use:
                Rel.Sprite VPage(),10,10,SprArray(),0
                *Draws a sprite at 10,10, using SprArray at offset 0

                Rel.Sprite VPage(),100,100,SprArray(),SprIndex(5)
                *Draws a sprite at 100,100, using SprArray at offset 5. This
                example uses pp256 array index which means it draws the
                5th(Fifth) tile in SprArray.
        Notes:
                *Clipping is supported so no errors would occur. 

SUB Rel.SpriteC (VideoBuf(), X, Y, Sprite(), SpriteOffSet, CLR)

        Parameters:
                VideoBuf()=the buffer to write to
                X=\ Top left coords of the 
                Y=/ Sprite to draw
                Sprite()= the array for the sprite which was made either
                        by PP256, QB's GET or Rel.GET
                SpriteOffset = an integer offset(index) of the sprite for
                        multiple tiles in one array.
                Clr=the color of the sprite to draw.
        Description:
                Draws an outline of the sprite at coordinates X,Y skipping
                color 0 so there is no need for masks.
        How to use:
                Rel.SpriteC VPage(),10,10,SprArray(),0,15
                *Draws a sprite at 10,10, using SprArray at offset 0 with
                color 15

                Rel.SpriteC VPage(),100,100,SprArray(),SprIndex(5),31
                *Draws a sprite at 100,100, using SprArray at offset 5. This
                example uses pp256 array index which means it draws the
                5th(Fifth) tile in SprArray. With color 31
        Notes:
                *Clipping is supported so no errors would occur. Used for
                effects like when the player gets hit.

SUB Rel.SpriteCT (VideoBuf(), X, Y, Sprite(), SpriteOffSet, CLR)

        Parameters:
                VideoBuf()=the buffer to write to
                X=\ Top left coords of the 
                Y=/ Sprite to draw
                Sprite()= the array for the sprite which was made either
                        by PP256, QB's GET or Rel.GET
                SpriteOffset = an integer offset(index) of the sprite for
                        multiple tiles in one array.
                Clr=the color of the sprite to draw.
        Description:
                Draws an outline of the sprite at coordinates X,Y skipping
                color 0 so there is no need for masks. Translucently!!!!
        How to use:
                Rel.SpriteCT VPage(),10,10,SprArray(),0,15
                *Draws a sprite at 10,10, using SprArray at offset 0 with
                color 15 in Translucent mode.

                Rel.SpriteCT VPage(),100,100,SprArray(),SprIndex(5),31
                *Draws a sprite at 100,100, using SprArray at offset 5. This
                example uses pp256 array index which means it draws the
                5th(Fifth) tile in SprArray. With color 31 in translucent mode.
        Notes:
                *Clipping is supported so no errors would occur. Used for
                effects like shadows. Needs a gradient palette to work.

SUB Rel.SpriteG (VideoBuf(), X, Y, Sprite(), SpriteOffSet, GammaVal)

        Parameters:
                VideoBuf()=the buffer to write to
                X=\ Top left coords of the 
                Y=/ Sprite to draw
                Sprite()= the array for the sprite which was made either
                        by PP256, QB's GET or Rel.GET
                SpriteOffset = an integer offset(index) of the sprite for
                        multiple tiles in one array.
                GammaVal=the gamma displacement of the sprite's colors
                        *Negative(-) values darken
                        *Positive(+) values lighten
        Description:
                Draws a lightened ot darkened sprite depending on the
                value of GammaVal
        How to use:
                Rel.SpriteG VPage(),10,10,SprArray(),0,-6
                *Draws a sprite at 10,10, using SprArray at offset 0 DARKENING
                it by 6 color displacement.

                Rel.SpriteG VPage(),100,100,SprArray(),SprIndex(5),31,+4
                *Draws a sprite at 100,100, using SprArray at offset 5. This
                example uses pp256 array index which means it draws the
                5th(Fifth) tile in SprArray. LIGHTENING it with 4 gamma
                displacement.
        Notes:
                *Clipping is supported so no errors would occur. Used for
                effects like shadows and light FX.

SUB Rel.SpriteN (VideoBuf(), X, Y, Sprite(), SpriteOffSet)

        Parameters:
                VideoBuf()=the buffer to write to
                X=\ Top left coords of the 
                Y=/ Sprite to draw
                Sprite()= the array for the sprite which was made either
                        by PP256, QB's GET or Rel.GET
                SpriteOffset = an integer offset(index) of the sprite for
                        multiple tiles in one array.
        Description:
                Draws a sprite at coordinates X,Y SOLIDLY. So this in effect
                is FASTER than all the other sprite routines here.
        How to use:
                Rel.SpriteN VPage(),10,10,SprArray(),0
                *Draws a sprite at 10,10, using SprArray at offset 0

                Rel.SpriteN VPage(),100,100,SprArray(),SprIndex(5)
                *Draws a sprite at 100,100, using SprArray at offset 5. This
                example uses pp256 array index which means it draws the
                5th(Fifth) tile in SprArray.
        Notes:
                *Clipping is supported so no errors would occur. Use this
                for you farthest layer.

SUB Rel.SpriteT (VideoBuf(), X, Y, Sprite(), SpriteOffSet)

        Parameters:
                VideoBuf()=the buffer to write to
                X=\ Top left coords of the 
                Y=/ Sprite to draw
                Sprite()= the array for the sprite which was made either
                        by PP256, QB's GET or Rel.GET
                SpriteOffset = an integer offset(index) of the sprite for
                        multiple tiles in one array.
        Description:
                Draws a sprite at coordinates X,Y. Skipping color 0.
                Translucently!!!
        How to use:
                Rel.SpriteT VPage(),10,10,SprArray(),0
                *Draws a sprite at 10,10, using SprArray at offset 0

                Rel.SpriteT VPage(),100,100,SprArray(),SprIndex(5)
                *Draws a sprite at 100,100, using SprArray at offset 5. This
                example uses pp256 array index which means it draws the
                5th(Fifth) tile in SprArray.
        Notes:
                *Clipping is supported so no errors would occur. Used for
                Ghosts, and some FX I can't even think of right now. :*)

SUB Rel.Get (VideoBuf(), X1, Y1, X2, Y2, Sprite(), SpriteOffSet)

        Parameters:
                VideoBuf()=the buffer to COPY from.
                X1=\ Top left coords of the 
                Y1=/ Sprite to draw
                X2=\ Bottom Right coords of the 
                Y2=/ Sprite to draw
                Sprite()= Array to write to.
                SpriteOffset = an integer offset(index) of the sprite for
                        multiple tiles in one array.
        Description:
                Works like QB's GET statement only that it GET's the image
                for the buffer instead of the screen.
        How to use:
                Size=Rel.Size(0,0,15,15)        'Determine the size we need
                Dim Array(Size)                 'Dim it
                Rel.GET Vpage(),0,0,15,15,Array(),0
                *Copies the contents of the VPAGE at coords 0,0,15,15 and
                puts it to a 16*16 Array stating at offset 0.
        Notes:
                *Clipping is supported so no errors would occur. Use Rel.Size
                to determine the size of the array.





*** PALETTE ROUTINES ***





SUB Rel.LoadPal (File$, PalString$, Switch) STATIC

        Parameters:
                File$=The Disk File to load the palette from
                PalString$= a 768 byte string that holds the RGB values
                Switch= if TRUE(not zero) then switches the current pal to
                        the one held by palstring$.
        Description:
                Loads a palette previously saved by Rel.SavePal
        How to use:
                Dim Shared RGBpal as String*768                
                Rel.LoadPal "RelPal.Pal",RGBpal,-1
                *Loads Relpal to RGBpal and switches to the new pal
        Notes:
                *Be sure to DIM a 768 string byte and use it for your Pal
                variable as a non-Fixed length string might not work.

SUB Rel.LoadPalPp256 (File$) STATIC

        Parameters:
                File$=The Disk File to load the palette from
        Description:
                Loads a palette made by pp256(1024 pal format file). Its only
                because pp256's pal loader has a bug in it that prevents it
                from being compiled. Kackurot gets credit for this one.
        How to use:
                Rel.LoadPal "Gradientl.Pal"
                *Loads pp256's standard gradient pal and switches the
                current pal to the new one.
        Notes:
                *Be sure to set your Paths right.

SUB Rel.NegativePal STATIC

        Parameters:
                NONE
        Description:
                Gives a negative effect on the current palette which is
                very cool to see.
        How to use:
                Rel.NegativePal
        Notes:

SUB Rel.Fade (R, G, B, Counts) STATIC

        Parameters:
                R=Ending RED value to fade to
                G=Ending GREEN value to fade to
                B=Ending BLUE value to fade to
                Counts=is the number of ITERATIONS before the fade ends
        Description:
                Uses Unit/Normalized vectors to acheive its fadeout so
                it doesn't care whether the RGB difference is 0 or 63 as
                all values will arrive at the same time to their ending
                RGB values.
        How to use:
                Rel.Fade 0,0,0,100
                *Fades to black in 100 counts
                Rel.Fade 0,0,0,0
                *Fades to black instantaneously
                Rel.Fade 63,0,63,200
                *Fades to Purple in 200 counts
        Notes:
                *Fades all the attributes to its ending RGB values

SUB Rel.FadeStep (StartCol, EndCol, R%, G%, B%) STATIC

        Parameters:
                StartCol\ Color block to fade 
                EndCol  / selectively
                R\
                G > the ending RGB values
                B/
        Description:
                Fades the block of colors in Steps of 1. So to fade
                completely, call this sub 64 times.
        How to use:
                Rel.FadeStep 100,150,0,10,20
        Notes:
                *Not as good looking as Vector Fades but this can be used for
                Night and Day FX while the player is moving.

SUB Rel.FadeToPal (PalString$, Counts) STATIC

        Parameters:
                PalString$=The 768 byte string that holds the RGB values
                        of a pal loaded using Rel.LoadPal ot Rel.ReadPal
                Counts=is the number of ITERATIONS before the fade ends
        Description:
                Uses Unit/Normalized vectors to acheive its fadeout so
                it doesn't care whether the RGB difference is 0 or 63 as
                all values will arrive at the same time to their ending
                RGB values.
        How to use:
                'Using the standard 768 byte pal
                Dim Pal as String * 768
                Rel.LoadPal "RelPal.Pal",Pal,FALSE
                Rel.FadeToPal Pal,100
                'Using pp256's pal format
                Dim Pal as String * 768
                Rel.LoadPalPP256 "Gradient.Pal"
                Rel.ReadPal Pal                         'Read the current pal
                Rel.FadeToPal Pal,100
        Notes:
                *Fades all the attributes to its ending RGB values

SUB Rel.FadeToPalStep (StartCol, EndCol, PalString$) STATIC

        Parameters:
                StartCol\ Color block to fade 
                EndCol  / selectively
                PalString$=the 768 string pal to read from.
        Description:
                Fades the block of colors in Steps of 1. So to fade
                completely, call this sub 64 times.
        How to use:
                Dim Pal as String * 768
                Rel.LoadPal "RelPal.Pal",Pal,FALSE
                Rel.FadeToPalStep 100,Pal
        Notes:
                *Not as good looking as Vector Fades but this can be used for
                Night and Day FX while the player is moving.

SUB Rel.FadeToPalX (StartCol, EndCol, PalString$, Counts) STATIC

        Parameters:
                StartCol\ the Block of colors
                EndCol  / that will be used/Affected
                PalString$=The 768 byte string that holds the RGB values
                        of a pal loaded using Rel.LoadPal ot Rel.ReadPal
                Counts=is the number of ITERATIONS before the fade ends
        Description:
                Uses Unit/Normalized vectors to acheive its fadeout so
                it doesn't care whether the RGB difference is 0 or 63 as
                all values will arrive at the same time to their ending
                RGB values.
        How to use:
                'Using the standard 768 byte pal
                Dim Pal as String * 768
                Rel.LoadPal "RelPal.Pal",Pal,FALSE
                Rel.FadeToPalX 20,245,Pal,100
                'Using pp256's pal format
                Dim Pal as String * 768
                Rel.LoadPalPP256 "Gradient.Pal"
                Rel.ReadPal Pal                         'Read the current pal
                Rel.FadeToPalX 100,200,Pal,100
        Notes:
                *Selective fade.  The colors affected is determined by
                StartCol and end col

SUB Rel.FadeX (StartCol, EndCol, R, G, B, Counts) STATIC

        Parameters:
                StartCol\ the Block of colors
                EndCol  / that will be used/Affected
                R=Ending RED value to fade to
                G=Ending GREEN value to fade to
                B=Ending BLUE value to fade to
                Counts=is the number of ITERATIONS before the fade ends
        Description:
                Uses Unit/Normalized vectors to acheive its fadeout so
                it doesn't care whether the RGB difference is 0 or 63 as
                all values will arrive at the same time to their ending
                RGB values.
        How to use:
                Rel.FadeX 20,45,0,0,0,100
                *Fades to black in 100 counts
                Rel.FadeX 100,200,0,0,0,0
                *Fades to black instantaneously
                Rel.FadeX 12,13,63,0,63,200
                *Fades to Purple in 200 counts
        Notes:
                *Selective fade.  The colors affected is determined by
                StartCol and end col

SUB Rel.ReadPal (PalString$) STATIC

        Parameters:
                PalString$= 768 byte string pal to hold the RGB values
        Description:
                Directly reads from the Video ports the RGB values of each
                color and puts the values in PalString$
        How to use:
                'Using pp256's pal format
                Dim Pal as String * 768
                Rel.LoadPalPP256 "Gradient.Pal"
                Rel.ReadPal Pal                         'Read the current pal
                Rel.FadeToPal Pal,100
        Notes:
                *Use this if your saved pal is in pp256 format then you
                can use the pal effects afterwards.  Use this also before
                saving the current palette to file using Rel.SavePal.

SUB Rel.ReadRGB (ColorVal, R, G, B) STATIC

        Parameters:
                ColorVal=Color number to read values from
                R\
                G > RGB values that are returned after the call
                B/
        Description:
                Directly reads from the Video ports the RGB values of each
                color and puts the values in R,G, and B.
        How to use:
                Rel.ReadRGB 100,R,G,B
                *Puts the RGB values of color 100 to R,G and B.
        Notes:
                *Do not erase this sub as this is used by some of the
                Palette tricks here. :*)

SUB Rel.RotatePalB (StartCol, EndCol) STATIC

        Parameters:
                StartCol\ the block of colors
                EndCol  / that will be affected
        Description:
                Rotates the palette backwards from StartCol to EndCol giving
                a motion effect.
        How to use:
                Rel.RotatePalB 100,200
                *Rotates the colors 100-200 backwards.
        Notes:
                *See the demo.

SUB Rel.RotatePalF (StartCol, EndCol) STATIC

        Parameters:
                StartCol\ the block of colors
                EndCol  / that will be affected
        Description:
                Rotates the palette Forward from StartCol to EndCol giving
                a motion effect.
        How to use:
                Rel.RotatePalB 100,200
                *Rotates the colors 100-200 Forward.
        Notes:
                *See the demo.

SUB Rel.SavePal (File$) STATIC

        Parameters:
                File$=The Filename of the pal to save to.
        Description:
                Saves the current pal to a disk file.
        How to use:
                'Using pp256's pal format
                Dim Pal as String * 768
                Rel.LoadPalPP256 "Gradient.Pal"
                Rel.ReadPal Pal                         'Read the current pal
                Rel.SavePal "Grad768.Pa1"               'save to disk
                *Loads the PP256 Gradient pal and saves it as a 768 pal file
                called Grad768.pal.
        Notes:
                *Use this to convert any pal to the standard 768 byte format.

SUB Rel.SwitchToPal (PalString$) STATIC

        Parameters:
                PalString$=768 byte string to switch to.
        Description:
                Instantly switches the current pal to the RGB values held
                by PalString$
        How to use:
                Dim RGBpal as String * 768
                Rel.LoadPal "RelPal.Pal",RGBpal,FALSE
                Rel.SwitchToPal RGBpal
        Notes:
                *Useless as RelFade can do it also. I don't know why I
                included it here.

SUB Rel.WriteRGB (ColorNum, R, G, B) STATIC

        Parameters:
                ColorVal=Color number to write values to.
                R\
                G > RGB values that are directly written to video
                B/
        Description:
                Directly writes to the Video ports the R,G, and B values 
        How to use:
                R=63
                G=63
                B=63
                Rel.WriteRGB 100,R,G,B
                *Changes the palette of color 100 to bright white
        Notes:
                *Do not erase this sub as this is used by some of the
                Palette tricks here. :*)





*** FONT ROUTINES ***





SUB Rel.Font (VideoBuf(), X%, Y%, Text$, Centered%, FontArray(), FontArrayIndex())

        Parameters:
                VideoBuf()=the page to write to
                X\ the top left coords
                Y/ of the text to print
                Text$=The string to print
                Centered= if TRUE(-1) centers the text to the page
                        if FALSE(0) uses the X parameter.
                FontArray()=is the array that holds the font sprite
                FontArrayIndex=the index made by pp256's makeimageIndex SUB
        Description:
                Draws a text using a set of font made by pp256 in a non-fixed
                spacing so the text looks cleaner.
        How to use:
                Rel.Font Vpage(),10,10,"AuraFlow",TRUE,Font(),FontIndex()
                *Prints a centered text at pixel row 10
                Rel.Font Vpage(),10,10,"Anya Therese",FALSE,Font(),FontIndex()
                *Prints a Non centered text at 10,10.
        Notes:
                *Doesn't destroy the background. Uses Rel.Sprite so do not
                Erase the Rel.Sprite SUB.

SUB Rel.KgenFont (VideoBuf(), X, Y, Font$, MinColor, Italic)

        Parameters:
                VideoBuf()=the page to write to
                X\ the top left coords
                Y/ of the text to print
                Font$=The string to print
                MinColor=the first color of the top row ot pixels in each
                        letter.
                Italic=???? Duh?
        Description:
                Draws a standard BIOS font(&HFFA6) and prints it to the
                page.
        How to use:
                Rel.KgenFont Vpage(),10,10,"AuraFlow",24,TRUE
                *Prints "AuraFlow" starting from color 24 to 24+7, printing
                it in Italic
        Notes:
                *Doesn't destroy the background.




*** MISC ROUTINES ***





SUB Rel.AddByte (IntVal, LowByte, HiByte, ByteFlag) STATIC

        Parameters:
                IntVal=The INTEGER value to play with
                LowByte=The value of the Lowbyte to add to intval(-128 to 127)
                HiByte=The value of the Hibyte to add to intval(-128 to 127)
                ByteFlag=The value that determines whether to add to Both
                        Bytes or just one of either Low or Hi byte.
                        0 = Add both bytes
                        1 = Add only the LowByte
                        2 = Add only the HighByte
        Description:
                Adds either Lowbyte, Hibyte or Both to an Integer value.
        How to use:
                (1)
                Dim A as Integer
                A=0
                Low=125
                High=45
                Rel.AddByte A,Low,High,0                'Add both Bytes
                'to get the Bytes use this:
                LowByte=A and 255
                HighByte=A\256
                (2)
                'You can even Play around with Types
                Type MapType
                        Layer as Integer
                        Script as String*20
                End type
                Dim Map(100) as MapType
                For I=0 to 100
                Layer1=Int(Rnd*100)
                Layer2=Int(Rnd*100)
                        Rel.Addbyte Map(I).Layer,Layer1,Layer2,0
                Next I

                'To get each byte....
                LowByte=Map(I).Layer and 255
                HighByte=Map(I).Layer \ 256
        Notes:
                *This is a memory saving sub so its very useful. In fact
                I already made this a standard on all my maps.  You could
                represent twice the number of layers without a single byte
                more of memory.  Pls see RelLib, Frantic Journey or the
                example for more details.....






*** FUNCTIONS ***
*** FUNCTIONS ***
*** FUNCTIONS ***



FUNCTION Rel.Collide (VideoBuf(), X, Y, Sprite(), SpriteOffSet)

        Return:
                The color of the pixel collided with or 0 if there is
                no collision.
        Parameters:
                VideoBuf()=the page to write to
                X\ the top left coords
                Y/ of the Sprite
                Sprite()= the array for the sprite which was made either
                        by PP256, QB's GET or Rel.GET
                SpriteOffset = an integer offset(index) of the sprite for
                        multiple tiles in one array.
        Description:
                Used for a pixel perfect collision detection.
        How to use:
                C=Rel.Collide(VPage(),100,100,SprArray(),SprIndex(5))
                *Checks if the sprite collides with a particular color
                other than 0.
        Notes:
                *Clipping is supported.


FUNCTION Rel.FastKB STATIC

        Return:
                The Scancode of the key pressed.
        Parameters:
                None
        Description:
                A very simplistic pure QB key handler.  Not a multikey but
                is FASTER and better than INKEY$.
        How to use:
                *Note KEYESC,etc are constants defined at the module level
                of your prog. Pls refer to the QB online Help for more
                Scancodes...

                SELECT CASE Rel.FastKB
                        CASE KEYESC
                                Finished = TRUE
                        CASE KEYUP
                                'Go up
                        CASE KEYDOWN
                                'Go down
                        CASE KEYRIGHT
                                'Go right
                        CASE KEYLEFT
                                'Go left
                        CASE ELSE
                END SELECT
                
        Notes:
                *Values above 215(Break values) are ignored.

FUNCTION Rel.Point (VideoBuf(),X, Y)

        Return:
                The color of the coordinates in VideoBuf defined by X and Y.
        Parameters:
                VideoBuff()= the page
                X\ Coordinates to look
                Y/ a pixel for
        Description:
                *Works like QB's POINT statement only that instead of the
                screen, it uses the buffer
        How to use:
                Rel.Pset Vpage(),100,100,15
                C=Rel.Point(Vpage(),100,100)
                *C=15 as we Pset'ed there previously.
        Notes:
                *Clipping is supported and some times used for a faster
                collision detection. ie, you could divide your palette in half
                and make the Top half collidable and the other half not.
                EX:
                'Assuming that colors 128-255 are collidable
                if Rel.Point(Vpage(),X,Y)>127 then
                        Collide=-1
                else
                        Collide=0
                end if

FUNCTION Rel.Size (X1, Y1, X2, Y2)

        Return:
                The size in WORDS(Integers) needed to DIM a sprite array
                with the size of X1,Y1,X2,Y2
        Parameters:
                X1\
                Y1 \    The bounding box coordinates of the bitmap to get
                X2 /    from.
                Y2/
        Description:
                *Uses this formula to get the size:
                Size=((((X2 - X1) + 1) * ((Y2 - Y1) + 1)) + 4) \ 2
                *For easy calculations of the needed array size.
        How to use:
                '16*16 Sprite
                Size=Rel.Size(0,0,15,15)        'Determine the size we need
                Dim Array(Size)                 'Dim it
                Rel.GET Vpage(),0,0,15,15,Array(),0
                *Copies the contents of the VPAGE at coords 0,0,15,15 and
                puts it to a 16*16 Array stating at offset 0.

                *just to show that QB' sGET works.....
                '20*20 Sprite
                Size=Rel.Size(0,0,19,19)        'Determine the size we need
                Dim Array(Size)                 'Dim it
                GET (0,0)-(19,19),Array
                *Copies the contents of the VPAGE at coords 0,0,19,19 and
                puts it to a 20*20 Array starting at offset 0.
        Notes:
                *Do not erase this SUB as this is used by some pageing
                routines such as Rel.PageInit. See the example files.







*** CREDITS ***


        I would like to extend my warmest thanks to:

GOD
        For always giving me ideas to improve things. And for giving me LIFE.

Anya Therese Lope (My daughter)
Rosmelly B. Lope (The wife)

My Family:
Pedro and Lily Lope(my Parents)       
Marie Cristina and Cristina Marie Lope

The AuraFlow Team:
Eero Pitkanen(eebro/ebr)\
Adigun Polack            \      The hippest QB progging team
Bobby Leigh(beta_ss)     /      of the Qmunity
Achmad Aulia(L_O_J)     /

        

Brendan Urquhart(Wildcard)
Jason Earl(MiiJaySung???)
Toshi Horie
Francisco Soto(Bobby3999)
Glenn Stumpff
Piptol Productions
Dean Janjic(Lachie Dazdarian)
Joakim Anfelt Ronne(Joakim AR)
Flingmaster
Rich Geldreich(Ellipse routines)
Kurt Kuzba(Line Algo)
Andre Brown(Kack)
Alan O'Hagan(CGI Joe)
DarkDread
Mr. Moose
Jake
ChaoTic
Nory-B
Brett Philips(InsaneLogic)
Giancarlo Berardi(GBgames)
Danny WilFong(Across the Sea/Xchaser)
John Millard(JtM)
Jocke The Beast
Nathan Asshanti
AetherFox
Jorden Chamid
James Robert Osborne(WisdomDude)
Luis Espinoza(Laffin)
Andrew Ayers
Robert Lee
Engr. Marino Osorio


=================END OF FILE==================================================
