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  

SoMode4PolygonRasterizer.c File Reference

#include "SoSystem.h"
#include "SoMode4Renderer.h"
#include "SoTables.h"
#include "SoMath.h"
#include "SoVector.h"
#include "SoMode4PolygonRasterizer.h"
#include "SoDisplay.h"
#include "SoFont.h"
#include "SoDebug.h"
#include "SoPalette.h"

Data Structures

struct  SoEdgeTableEntry
 Structure to contain starting or ending values for a horizontal scanline slice of a polygon. More...


Functions

void SoMode4PolygonRasterizerDrawTexturedPolygonFromEdgeTables (void)
 Draws a textured polygon from the information in the edge tables.

void SoMode4PolygonRasterizerDrawSolidPolygonFromEdgeTables (u32 a_PaletteIndex)
 Draws a solid polygon from the information in the edge tables.

void SoMode4PolygonRasterizerDraw4x4TriangleFromCode (void *a_4x4WordAddress, u32 a_WordOffset, u32 a_QuadPaletteIndex, u32 a_TriangleCode)
 Draws a 4 by 4 triangle from the given 10 bit code.

void SoMode4PolygonRasterizerSetBuffer (void *a_Buffer)
 Sets the backbuffer the rasterizer will render to.

void SoMode4PolygonRasterizerSetTexture (SoImage *a_Texture)
 Sets the texture the rasterizer should use for textured polygons.

void SoMode4PolygonRasterizerInitialize (void)
 Initializes the rasterizer.

void SoMode4PolygonRasterizerDrawTexturedPolygon (u32 a_NumVertices, SoVector2 *a_ScreenCoordinates, SoVector2 *a_TextureCoordinates)
 Draws a textured polygon.

void SoMode4PolygonRasterizerDrawSolidPolygon (u32 a_NumVertices, SoVector2 *a_ScreenCoordinates, u32 a_PaletteIndex)
 Draws a solid single color polygon.

void SoMode4PolygonRasterizerDrawSolidTriangleC (SoVector2 a_Triangle[3], u32 a_PaletteIndex)
 C version of the assembly solid triangle rasterizer;.


Variables

u8s_TextureData
 Current texture data used to draw a polygon.

s32 s_TextureUShift
 2log( texture width )

s32 s_TextureVShift
 2log( texture height )

s32 s_TextureUMask
 Used for texture coord wrapping;.

s32 s_TextureVMask
 Used for texture coord wrapping;.

s32 s_PolygonMinY
 Maximum screen Y of a polygon.

s32 s_PolygonMaxY
 Minimum screen Y of a polygon.

SoEdgeTableEntry s_EdgeTableL [SO_SCREEN_HEIGHT]
 Table containing the info of the left side.

SoEdgeTableEntry s_EdgeTableR [SO_SCREEN_HEIGHT]
bool s_Initialized
 True once SoMode4PolygonRasterizerInitialize is called.

u16g_SoMode4PolygonRasterizerBuffer
 Pointer the polygon routines will render to.


Detailed Description

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

Author:
Jaap Suter
Date:
Jun 5 2001
See the SoMode4PolygonRasterizer module for more information.


Function Documentation

void SoMode4PolygonRasterizerDraw4x4TriangleFromCode void *    a_4x4WordAddress,
u32    a_WordOffset,
u32    a_QuadPaletteIndex,
u32    a_TriangleCode
 

Draws a 4 by 4 triangle from the given 10 bit code.

For internal use only.

Only called from within SoMode4PolygonRasterizerDraw4x4Triangle

Parameters:
a_4x4WordAddress  Word (32 bits aligned) address of the top left corner of the 4 by 4 pixel rectangle.
a_WordOffset  Offset (0, 1, 2 or 3) in the above 32 bits word of the top left corder of the rectangle.
a_QuadPaletteIndex  Quadrupled palette index of the color of the triangle. This means that a palette index of 0xAB becomes 0xABABABAB.
a_TriangleCode  10 bits code of the triangle you want to draw.
Check the documentation for the SoMode4PolygonRasterizerDraw4x4Triangle function for more information.

void SoMode4PolygonRasterizerDrawSolidPolygonFromEdgeTables u32    a_PaletteIndex
 

Draws a solid polygon from the information in the edge tables.

For internal use only.

This function is called by SoMode4PoygonRasterizerDrawSolidPolygon after that function has filled the edge tables.

void SoMode4PolygonRasterizerDrawTexturedPolygonFromEdgeTables void   
 

Draws a textured polygon from the information in the edge tables.

For internal use only.

This function is called by SoMode4PoygonRasterizerDrawTexturedPolygon after that function has filled the edge tables.


Variable Documentation

SoEdgeTableEntry s_EdgeTableL[ SO_SCREEN_HEIGHT ] [static]
 

Table containing the info of the left side.

For internal use only.

SoEdgeTableEntry s_EdgeTableR[ SO_SCREEN_HEIGHT ] [static]
 

For internal use only.

Table containing the info of the right side of the polygon for every horizontal scanline.

s32 s_PolygonMaxY [static]
 

Minimum screen Y of a polygon.

For internal use only.

s32 s_PolygonMinY [static]
 

Maximum screen Y of a polygon.

For internal use only.

u8* s_TextureData [static]
 

Current texture data used to draw a polygon.

For internal use only.

s32 s_TextureUMask [static]
 

Used for texture coord wrapping;.

For internal use only.

s32 s_TextureUShift [static]
 

2log( texture width )

For internal use only.

s32 s_TextureVMask [static]
 

Used for texture coord wrapping;.

For internal use only.

s32 s_TextureVShift [static]
 

2log( texture height )

For internal use only.


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