				 -=========================-
				== GBALib Reference Manual ==
				==     Version 001128      ==
				==       Mic, 2000         ==
				== stabmaster_@hotmail.com ==
				 -=========================-




Limitations
~~~~~~~~~~~
This could be a long section.. But I think I'm just going to say that this library
is ment to be used with the bitmap modes only (mode 3, 4 & 5) and that it's very
much in alpha-stage, so expect things to change.



Defined types
~~~~~~~~~~~~~

unsigned char u8

unsigned short u16

unsigned long u32

struct POINT
{
 long x, y
 long c
 long u,v
}POINT




Variables & constants
~~~~~~~~~~~~~~~~~~~~~

VRAM	-	0x06000000
FRONT	-	(u8 *). Points to the front buffer (the visible one).
BACK	-	(u8 *). Points to the back buffer (the hidden one).




The routines
~~~~~~~~~~~~

void gbalSetMode(u8 mode)
  Set the desired graphics mode. 'mode' may be 0-5.
  You can use these constants:
   _240x160x0x32k_	(mode 3)
   _240x160x1x256_	(mode 4)	
   _160x128x0x32k_	(mode 5)



void gbalRContext(void *dest, u32 width, u32 height, u8 bitcount)
  Sets the desired rendering context. The rendering context, hereby called 'RC',
  is the area on wich all drawing functions will operate. The default RC is
  always {BACK, mode_width, mode_height, mode_bitcount}. If you wish to draw
  elsewhere, or alter the size of the RC you must call gbalRContext() and set
  the parameters "manually". Note that calls to gbalSwapBuffers() will change the
  'dest' parameter of the RC. If you don't want this to happend you must call
  gbalRContext() whenever you call gbalSwapBuffers().
  (see gbalSwapBuffers())



void gbalSwapBuffers()
  Swaps the front and back buffers, and updates the FRONT and BACK pointers.
  Only ment to be used in modes 4 & 5, since mode 3 only has enough memory for
  a single buffer.



void gbalVSync()
  Waits for the vertical retrace to finish.



void gbalClearBuffer(u16 color)
  Clears the buffer specified in the RC.
  In mode 4, only the lower 8 bits of 'color' is used.
  Note: this will only work correctly if you call gbalDisable(GBAL_DMA_CLEAR).


void gbalEnable(u16 what)
  Enables a GBALib feature.
  'what' may be any of the following:
   GBAL_DMA_CLEAR	-	Let GBALib use DMA3 to clear the backbuffer (default).



void gbalDisable(u16 what)
  Disables a GBALib feature.
  'what' may be any of the following:
   GBAL_DMA_CLEAR	-	Don't let GBALib use DMA3 to clear the backbuffer.



u16 gbalMakeColor(int r, int g, int b)
  Returns a 555-format color.
  'r', 'g' and 'b' should be in the range 0-255.



void gbalSetColor(long wich_palette, long wich_color, u16 color)
  Sets color number 'wich_color' in palette 'wich_palette' to 'color'.
  'wich_palette' may be BACKGROUND or OBJECT.
  'wich_color' can only be 0-255.
  'color' should be a 555-format color (0BBBBBGG GGGRRRRR).



void gbalSetPalette(long wich_palette, u16 *color_array, int num_of_colors)
  Sets 'num_of_colors' number of colors in the palette (starting at 0) to the
  values if 'color_array'.
  This is pretty much the same as gbalSetColor(), except that you can set multiple
  colors with this function.



void gbalShadeModel(u8 model)
  Tells gbalTriangle() how to draw the triangles.
  'mode' can be either GBAL_FLAT or GBAL_SMOOTH.



void gbalTriangle(POINT p1, POINT p2, POINT p3)
  Draws a triangle between the 3 points.



srccopy8(long x, long y, long xdim, long ydim, void *source)
  Copies 'xdim'*'ydim' number of bytes (pixels) to the RC.



notnullcopy8(long x, long y, long xdim, long ydim, void *source)
  Same as srccopy8() except it only copies non-zero pixels.




to be continued..
	

