The SGADE Documentation

the SGADE The Socrates Gameboy Advance Development Engine

The SGADE is a development library for the Nintendo Gameboy Advance. It's free for all uses and is distributed without guarantees. For more information visit the SGADE page.


Main Page   Modules   Data Structures   File List   Data Fields   Globals   Related Pages  

SoMode4Renderer

Handles all basic mode 4 rendering. More...

Files

file  SoMode4Renderer.c
file  SoMode4Renderer.h

Functions

void SoMode4RendererEnable (void)
 Switches the Gameboy Advance to mode 4.

void SoMode4RendererFlip (void)
 Flips the two mode 4 buffers.

void SoMode4RendererClearFrontAndBackBuffer (void)
 This function clears both the front and the back buffer.

void * SoMode4RendererGetBuffer (void)
 Returns a pointer to the current backbuffer;.

void SoMode4RendererDrawImage (const SoImage *a_Image)
 Draws the given image in the current backbuffer.

void SoMode4RendererDrawTransparentImage (const SoImage *a_Image)
 Draws a transparent image into the current backbuffer.

void SoMode4RendererDrawCrossFadeImage (const SoImage *a_Image0, const SoImage *a_Image1, u32 a_Fade)
 Draws a crossfaded version of two images into the backbuffer.

void SoMode4RendererDrawPixel (u32 a_X, u32 a_Y, u32 a_PalIndex)
 Plots a single pixel into the backbuffer.

void SoMode4RendererDrawNumber (u32 a_LeftX, u32 a_RightX, u32 a_TopY, s32 a_Number, const SoImage *a_Font)
 Draws a number with the given font in the current backbuffer;.

void SoMode4RendererDrawString (u32 a_LeftX, u32 a_RightX, u32 a_TopY, char *a_String, const SoImage *a_Font)
 Draws a string with the given font into the current backbuffer.

void SoMode4RendererClear (void)
 Clears the current mode4 backbuffer to palette index zero.


Detailed Description

Handles all basic mode 4 rendering.

Singleton

For polygon rendering use the SoMode4PolygonRenderer


Function Documentation

void SoMode4RendererClear void   
 

Clears the current mode4 backbuffer to palette index zero.

Remember, it's always better to just draw on the entire backbuffer, so you won't have to clear it.

void SoMode4RendererDrawCrossFadeImage const SoImage   a_Image0,
const SoImage   a_Image1,
u32    a_Fade
 

Draws a crossfaded version of two images into the backbuffer.

Parameters:
a_Image0  An 240 by 160 palettized SoImage instance.
a_Image1  An 240 by 160 palettized SoImage instance.
a_Fade  Value you want to crossfade with. Anything in between 0 and (SO_FADE_MAX-1).
Draws the the faded version of two images. The pixel is drawn with the following formula.

        destPixel = srcPixel0 *      (a_Fade / SO_FADE_MAX) 
                  + srcPixel1 * (1 - (a_Fade / SO_FADE_MAX));

void SoMode4RendererDrawImage const SoImage   a_Image
 

Draws the given image in the current backbuffer.

Parameters:
a_Image  An 240 by 160 palettized SoImage instance.

void SoMode4RendererDrawNumber u32    a_LeftX,
u32    a_RightX,
u32    a_TopY,
s32    a_Number,
const SoImage   a_Font
 

Draws a number with the given font in the current backbuffer;.

Parameters:
a_LeftX  Left X of the rectangle where the string is drawn, due to hardware reasons this must be an even number.
a_RightX  Right X of the rectangle where the string is drawn. Must also be an even number.
a_TopY  Top Y position of the rectangle where the string is drawn.
a_Number  Number you want to draw.
a_Font  Font you want to use for the string.

void SoMode4RendererDrawPixel u32    a_X,
u32    a_Y,
u32    a_PalIndex
 

Plots a single pixel into the backbuffer.

Parameters:
a_X  X position of the pixel in the range 0 to 239.
a_Y  Y position of the pixel in the ragen 0 to 159
a_PalIndex  Index into the screenpalette, containing the requested color.
This is a rather slow routine, because of the strange way we have to acces mode 4 pixels (two pixels at a time). Do not use this routine if you need speed.

void SoMode4RendererDrawString u32    a_LeftX,
u32    a_RightX,
u32    a_TopY,
char *    a_String,
const SoImage   a_Font
 

Draws a string with the given font into the current backbuffer.

Parameters:
a_LeftX  Left X of the rectangle where the string is drawn, due to hardware reasons this must be an even number.
a_RightX  Right X of the rectangle where the string is drawn. Must also be an even number.
a_TopY  Top Y position of the rectangle where the string is drawn.
a_String  String you want to draw.
a_Font  Font you want to use for the string.

void SoMode4RendererDrawTransparentImage const SoImage   a_Image
 

Draws a transparent image into the current backbuffer.

Parameters:
a_Image  An 240 by 160 palettized SoImage instance.
Warning:
Only pixelduo's are considered to be transparent. This means that only if a single u16 value (two pixels) equals zero it is not drawn.

void SoMode4RendererEnable void   
 

Switches the Gameboy Advance to mode 4.

Use this method before you are going to use any other mode 4 rendering function. This also applies to all SoMode4PolygonRasterizer functions.

Make sure you have already called SoDisplayInitialize too.

void SoMode4RendererFlip void   
 

Flips the two mode 4 buffers.

If buffer 0 is visible then buffer 1 becomes visible, and vice versa.

void* SoMode4RendererGetBuffer void   
 

Returns a pointer to the current backbuffer;.

Note that if you call SoMode4RendererFlip after using this function, the pointer you have suddenly becomes the frontbuffer.


Copyright 2002 by the SGADE authors. See SoLicense.h or Visit the SGADE page for more information.