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  

SoBkg.c File Reference

#include "SoSystem.h"
#include "SoBkg.h"
#include "SoBkgMap.h"
#include "SoBkgFont.h"
#include "SoBkgMemManager.h"
#include "SoDisplay.h"
#include "SoMath.h"
#include "SoDebug.h"
#include "SoVector.h"
#include "SoDMA.h"

Defines

#define SO_REG_BKG_CNT
#define SO_BKG_DATA
 this is BKG Video Ram where the screens and tiles are stored for display

#define SO_BKG_PRIORITY_MASK
#define SO_BKG_CHARBASE_MASK
#define SO_REG_BG0HOFS
#define SO_REG_BG1HOFS
#define SO_REG_BG2HOFS
#define SO_REG_BG3HOFS
#define SO_REG_BG0VOFS
#define SO_REG_BG1VOFS
#define SO_REG_BG2VOFS
#define SO_REG_BG3VOFS
#define OPTION_BITS

Functions

void SoBkgSetup (u32 a_Index, u32 a_Options)
 Prepares a background for use.

void SoBkgEnable (u32 a_Index, bool a_Enable)
 Turns off the given background.

bool SoBkgIsEnabled (u32 a_Index)
 Tests to see if a background is enabled.

void SoBkgSetMosaicEnable (u32 a_Index, bool a_Enable)
 Enables or disables the mosaic effect for a particular background.

void SoBkgSetPriority (u32 a_Index, u32 a_Priority)
 changes the display priority for a particular background

void SoBkgSetOffset (u16 a_Index, u16 a_XPos, u16 a_YPos)
 Sets the display offset of a background.

u16SoBkgGetData (u32 a_Index)
 brief Gets a pointer to the BKG data in VRAM

void SoBkgLoadSolidColorTile (u16 a_Index, u32 a_Tilenum, u16 a_ColorIndex)
 Loads data for a single solid color tile into background VRAM.

void SoBkgFill (u16 a_Index, u16 a_Data)
 Fills the contents of a background.

void SoBkgFillBlock (u16 a_Index, u16 a_XIndex, u16 a_YIndex, u16 a_Width, u16 a_Height, u16 a_Data)
 Fills a rectangular block of a background.

void SoBkgWrite (u16 a_Index, u16 a_XIndex, u16 a_YIndex, u16 a_Len, u16 *a_buffer)
 Writes a horizontal strip of data to a background.

void SoBkgWriteV (u16 a_Index, u16 a_XIndex, u16 a_YIndex, u16 a_Len, u16 *a_buffer)
 Writes a vertical strip of data to a background.

void SoBkgWriteBlock (u16 a_Index, u16 a_XIndex, u16 a_YIndex, u16 a_Width, u16 a_Height, u16 a_Pitch, u16 *a_buffer)
 Writes a block of data to a background.

void SoBkgWriteBlock16Color (u16 a_Index, u16 a_XIndex, u16 a_YIndex, u16 a_Width, u16 a_Height, u16 a_Pitch, u16 a_PalIndex, u16 *a_buffer)
 Writes a block of data to a background while translating the data to use a specific background palette.

void SoBkgClearIndirect (u16 a_Index)
 Clears the contents of an indirectly loaded background.

void SoBkgWriteIndirect (u16 a_Index, u16 a_XIndex, u16 a_YIndex, u16 a_Len, u16 *a_buffer)
 Writes a horizontal strip of data to a background.

void SoBkgWriteVIndirect (u16 a_Index, u16 a_XIndex, u16 a_YIndex, u16 a_Len, u16 *a_buffer)
 Writes a vertical strip of data to a background.

void SoBkgWriteBlockIndirect (u16 a_Index, u16 a_XIndex, u16 a_YIndex, u16 a_Width, u16 a_Height, u16 a_Pitch, u16 *a_buffer)
 Writes data to a background.

void SoBkgSetTextCursor (u16 a_Index, u16 a_X, u16 a_Y)
 Sets the position that the next print will occur.

const SoVector2SoBkgGetTextCursor (u16 a_Index)
 Gets the position that the next print will occur.

void SoBkgSetFont (u16 a_Index, const SoBkgFont *a_Font)
 Sets the font associated with a background.

const SoBkgFontSoBkgGetFont (u16 a_Index)
 Gets the font associated with a background.

void SoBkgSetTextWrapping (u16 a_Index, bool a_DoWrapping)
 enables or disables text wrapping

void SoBkgSetTextWindow (u16 a_Index, u16 a_UpperLeftX, u16 a_UpperLeftY, u16 a_LowerRightX, u16 a_LowerRightY)
 Sets the window in which printing is restricted.

void SoBkgPrint (u16 a_Index, const char *a_String)
 Draws a string to a background.

void SoBkgPrintf (u16 a_Index, const char *a_Format,...)
 Formatted print routine.


Variables

struct {
   const SoBkgFont *   m_Font
   SoVector2   m_TextCursor
   bool   m_TextWrapping
   u16   m_TextWindowLeft
   u16   m_TextWindowRight
   u16   m_TextWindowTop
   u16   m_TextWindowBottom
   u16 *   m_Screen
   u16   m_Width
   u16   m_Height
s_Bkg [SO_BKG_MAX_NUM_BACKGROUNDS]
 Holds current state of each background.


Detailed Description

Copyright (C) 2002 by the SGADE authors For conditions of distribution and use, see copyright notice in SoLicense.txt

Author:
Mark T. Price, Jaap Suter, Raleigh Cross
Date:
June 16, 2003
See the SoBkg module for more information.


Define Documentation

#define SO_BKG_CHARBASE_MASK
 

For internal use only.

#define SO_BKG_DATA
 

this is BKG Video Ram where the screens and tiles are stored for display

For internal use only.

#define SO_BKG_PRIORITY_MASK
 

For internal use only.

#define SO_REG_BG0HOFS
 

For internal use only.

#define SO_REG_BG0VOFS
 

For internal use only.

#define SO_REG_BG1HOFS
 

For internal use only.

#define SO_REG_BG1VOFS
 

For internal use only.

#define SO_REG_BG2HOFS
 

For internal use only.

#define SO_REG_BG2VOFS
 

For internal use only.

#define SO_REG_BG3HOFS
 

For internal use only.

#define SO_REG_BG3VOFS
 

For internal use only.

#define SO_REG_BKG_CNT
 

For internal use only.

Array of the four background control registers. Use like SO_REG_BKG_CNT[ 1 ], to access the control register for background number one.


Variable Documentation

const SoBkgFont* m_Font
 

active font for this background

For internal use only.

u16 m_Height
 

height of the BG's screen memory, in tiles

For internal use only.

u16* m_Screen
 

points to the BG's screen memory (here for convenience only)

For internal use only.

SoVector2 m_TextCursor
 

the location that the next print will occur

For internal use only.

bool m_TextWrapping
 

flag: text wrapping is enabled

For internal use only.

u16 m_Width
 

width of the BG's screen memory, in tiles

For internal use only.

struct { ... } s_Bkg[SO_BKG_MAX_NUM_BACKGROUNDS] [static]
 

Holds current state of each background.

For internal use only.

This array is used to hold the current state information of each background. Most of these values could be calculated by reading the GBA control registers, but it's faster and more convenient to keep them here.


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