Data Structures | Macros | Enumerations | Functions
graphx.h File Reference

Contains optimized graphics operations and routines. More...

#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>

Go to the source code of this file.

Data Structures

struct  gfx_sprite_t
 Sprite (image) type. More...
 
struct  gfx_rletsprite_t
 Sprite (image) type with RLE transparency. More...
 
struct  gfx_point_t
 A simple structure for working with 2D points. More...
 
struct  gfx_region_t
 Defines a rectangular graphics region. More...
 
struct  gfx_tilemap_t
 Defines tilemap structure. More...
 

Macros

#define gfx_MallocSprite(width, height)
 
#define gfx_UninitedSprite(name, width, height)
 
#define gfx_TempSprite(name, width, height)
 
#define gfx_AllocRLETSprite(data_size, malloc_routine)
 
#define gfx_MallocRLETSprite(data_size)
 
#define gfx_UninitedRLETSprite(name, data_size)
 
#define gfx_palette
 
#define gfx_vram
 
#define gfx_vbuffer
 
#define gfx_SetTile(tilemap, x_offset, y_offset, value)
 
#define gfx_GetTile(tilemap, x_offset, y_offset)
 
#define gfx_SetTileMapped(tilemap, row, col, value)
 
#define gfx_GetTileMapped(tilemap, row, col)
 
#define gfx_Circle_NoClip(x, y, radius)
 
#define gfx_SetDrawBuffer()
 
#define gfx_SetDrawScreen()
 
#define gfx_BlitScreen()
 
#define gfx_BlitBuffer()
 
#define gfx_GetSprite_NoClip(sprite_buffer, x, y)
 
#define gfx_RotatedTransparentSprite_NoClip(sprite, x, y, angle)
 
#define gfx_RotatedSprite_NoClip(sprite, x, y, angle)
 
#define gfx_RotateSprite(sprite_in, sprite_out, angle)
 
#define gfx_ConvertMallocRLETSprite(sprite_in)
 
#define gfx_RGBTo1555(r, g, b)
 
#define gfx_CheckRectangleHotspot(master_x, master_y, master_width, master_height, test_x, test_y, test_width, test_height)
 

Enumerations

enum  gfx_mode_t { gfx_8bpp }
 Stores operating modes of this library. More...
 
enum  gfx_tilemap_type_t {
  gfx_tile_no_pow2, gfx_tile_2_pixel, gfx_tile_4_pixel, gfx_tile_8_pixel,
  gfx_tile_16_pixel, gfx_tile_32_pixel, gfx_tile_64_pixel, gfx_tile_128_pixel
}
 Used for defining tile types. More...
 
enum  gfx_location_t { gfx_screen, gfx_buffer }
 Different locations routines can be drawn to. More...
 
enum  gfx_text_options_t { gfx_text_clip, gfx_text_noclip }
 Different available text modes. More...
 

Functions

gfx_sprite_tgfx_AllocSprite (uint8_t width, uint8_t height, void *(*malloc_routine)(size_t))
 
int gfx_Begin ()
 
void gfx_End (void)
 
void gfx_Tilemap (gfx_tilemap_t *tilemap, uint24_t x_offset, uint24_t y_offset)
 
void gfx_Tilemap_NoClip (gfx_tilemap_t *tilemap, uint24_t x_offset, uint24_t y_offset)
 
void gfx_TransparentTilemap (gfx_tilemap_t *tilemap, uint24_t x_offset, uint24_t y_offset)
 
void gfx_TransparentTilemap_NoClip (gfx_tilemap_t *tilemap, uint24_t x_offset, uint24_t y_offset)
 
uint8_t * gfx_TilePtr (gfx_tilemap_t *tilemap, uint24_t x_offset, uint24_t y_offset)
 
uint8_t * gfx_TilePtrMapped (gfx_tilemap_t *tilemap, uint8_t row, uint8_t col)
 
uint8_t gfx_SetColor (uint8_t index)
 
uint8_t gfx_SetTransparentColor (uint8_t index)
 
void gfx_SetDefaultPalette (gfx_mode_t mode)
 
void gfx_SetPalette (uint16_t *palette, uint24_t size, uint8_t offset)
 
void gfx_FillScreen (uint8_t index)
 
void gfx_ZeroScreen (void)
 
void gfx_SetPixel (uint24_t x, uint8_t y)
 
uint8_t gfx_GetPixel (uint24_t x, uint8_t y)
 
void gfx_Line (int x0, int y0, int x1, int y1)
 
void gfx_Line_NoClip (uint24_t x0, uint8_t y0, uint24_t x1, uint8_t y1)
 
bool gfx_CohenSutherlandClip (int *x0, int *y0, int *x1, int *y1)
 
void gfx_HorizLine (int x, int y, int length)
 
void gfx_HorizLine_NoClip (uint24_t x, uint8_t y, uint24_t length)
 
void gfx_VertLine (int x, int y, int length)
 
void gfx_VertLine_NoClip (uint24_t x, uint8_t y, uint24_t length)
 
void gfx_Rectangle (int x, int y, int width, int height)
 
void gfx_Rectangle_NoClip (uint24_t x, uint8_t y, uint24_t width, uint8_t height)
 
void gfx_FillRectangle (int x, int y, int width, int height)
 
void gfx_FillRectangle_NoClip (uint24_t x, uint8_t y, uint24_t width, uint8_t height)
 
void gfx_Circle (int x, int y, unsigned radius)
 
void gfx_FillCircle (int x, int y, unsigned radius)
 
void gfx_FillCircle_NoClip (uint24_t x, uint8_t y, unsigned radius)
 
void gfx_Polygon (int *points, unsigned num_points)
 
void gfx_Polygon_NoClip (int *points, unsigned num_points)
 
void gfx_FillTriangle (int x0, int y0, int x1, int y1, int x2, int y2)
 
void gfx_SetDraw (uint8_t location)
 
uint8_t gfx_GetDraw (void)
 
void gfx_SwapDraw (void)
 
void gfx_Wait (void)
 
void gfx_Blit (gfx_location_t src)
 
void gfx_BlitLines (gfx_location_t src, uint8_t y_loc, uint8_t num_lines)
 
void gfx_BlitRectangle (gfx_location_t src, uint24_t x, uint8_t y, uint24_t width, uint24_t height)
 
void gfx_CopyRectangle (gfx_location_t src, gfx_location_t dst, uint24_t src_x, uint8_t src_y, uint24_t dst_x, uint8_t dst_y, uint24_t width, uint8_t height)
 
void gfx_SetTextScale (uint8_t width_scale, uint8_t height_scale)
 
void gfx_PrintChar (const char c)
 
void gfx_PrintInt (int n, uint8_t length)
 
void gfx_PrintUInt (unsigned int n, uint8_t length)
 
void gfx_PrintString (const char *string)
 
void gfx_PrintStringXY (const char *string, int x, int y)
 
int gfx_GetTextX (void)
 
int gfx_GetTextY (void)
 
void gfx_SetTextXY (int x, int y)
 
void gfx_SetTextConfig (uint8_t config)
 
uint8_t gfx_SetTextFGColor (uint8_t color)
 
uint8_t gfx_SetTextBGColor (uint8_t color)
 
uint8_t gfx_SetTextTransparentColor (uint8_t color)
 
void gfx_Sprite (gfx_sprite_t *sprite, int x, int y)
 
void gfx_Sprite_NoClip (gfx_sprite_t *sprite, uint24_t x, uint8_t y)
 
void gfx_TransparentSprite (gfx_sprite_t *sprite, int x, int y)
 
void gfx_TransparentSprite_NoClip (gfx_sprite_t *sprite, uint24_t x, uint8_t y)
 
gfx_sprite_tgfx_GetSprite (gfx_sprite_t *sprite_buffer, int x, int y)
 
void gfx_ScaledSprite_NoClip (gfx_sprite_t *sprite, uint24_t x, uint8_t y, uint8_t width_scale, uint8_t height_scale)
 
void gfx_ScaledTransparentSprite_NoClip (gfx_sprite_t *sprite, uint24_t x, uint8_t y, uint8_t width_scale, uint8_t height_scale)
 
uint8_t gfx_RotatedScaledTransparentSprite_NoClip (gfx_sprite_t *sprite, uint24_t x, uint8_t y, uint8_t angle, uint8_t scale)
 
uint8_t gfx_RotatedScaledSprite_NoClip (gfx_sprite_t *sprite, uint24_t x, uint8_t y, uint8_t angle, uint8_t scale)
 
gfx_sprite_tgfx_FlipSpriteX (gfx_sprite_t *sprite_in, gfx_sprite_t *sprite_out)
 
gfx_sprite_tgfx_FlipSpriteY (gfx_sprite_t *sprite_in, gfx_sprite_t *sprite_out)
 
gfx_sprite_tgfx_RotateSpriteC (gfx_sprite_t *sprite_in, gfx_sprite_t *sprite_out)
 
gfx_sprite_tgfx_RotateSpriteCC (gfx_sprite_t *sprite_in, gfx_sprite_t *sprite_out)
 
gfx_sprite_tgfx_RotateSpriteHalf (gfx_sprite_t *sprite_in, gfx_sprite_t *sprite_out)
 
gfx_sprite_tgfx_ScaleSprite (gfx_sprite_t *sprite_in, gfx_sprite_t *sprite_out)
 
gfx_sprite_tgfx_RotateScaleSprite (gfx_sprite_t *sprite_in, gfx_sprite_t *sprite_out, uint8_t angle, uint8_t scale)
 
gfx_sprite_tgfx_GetSpriteChar (char c)
 
uint8_t * gfx_SetFontData (uint8_t *data)
 
uint8_t * gfx_SetCharData (uint8_t index, uint8_t *data)
 
void gfx_SetFontSpacing (uint8_t *spacing)
 
uint8_t gfx_SetFontHeight (uint8_t height)
 
void gfx_SetMonospaceFont (uint8_t spacing)
 
unsigned int gfx_GetStringWidth (const char *string)
 
unsigned int gfx_GetCharWidth (const char c)
 
void gfx_SetClipRegion (int xmin, int ymin, int xmax, int ymax)
 
bool gfx_GetClipRegion (gfx_region_t *region)
 
void gfx_ShiftDown (uint8_t pixels)
 
void gfx_ShiftUp (uint8_t pixels)
 
void gfx_ShiftLeft (uint24_t pixels)
 
void gfx_ShiftRight (uint24_t pixels)
 
uint16_t gfx_Lighten (uint16_t color, uint8_t amount)
 
uint16_t gfx_Darken (uint16_t color, uint8_t amount)
 
void gfx_FloodFill (unsigned int x, uint8_t y, uint8_t color)
 
void gfx_RLETSprite (gfx_rletsprite_t *sprite, int x, int y)
 
void gfx_RLETSprite_NoClip (gfx_rletsprite_t *sprite, uint24_t x, uint8_t y)
 
gfx_sprite_tgfx_ConvertFromRLETSprite (gfx_rletsprite_t *sprite_in, gfx_sprite_t *sprite_out)
 
gfx_rletsprite_tgfx_ConvertToRLETSprite (gfx_sprite_t *sprite_in, gfx_rletsprite_t *sprite_out)
 
gfx_rletsprite_tgfx_ConvertToNewRLETSprite (gfx_sprite_t *sprite_in, void *(*malloc_routine)(size_t))
 

Detailed Description

Contains optimized graphics operations and routines.

Example program template with best graphx buffer usage pattern:

// Standard #includes omitted
bool partial_redraw;
// Implement us!
void begin();
void end();
bool step();
void draw();
void main() {
begin(); // No rendering allowed!
gfx_SetDrawBuffer(); // Draw to the buffer to avoid rendering artifats
while (step()) { // No rendering allowed in step!
if (partial_redraw) // Only want to redraw part of the previous frame?
gfx_BlitScreen(); // Copy previous frame as a base for this frame
draw(); // As little non-rendering logic as possible
gfx_SwapDraw(); // Queue the buffered frame to be displayed
}
end();
}
Authors
Matt "MateoConLechuga" Waltz
Jacob "jacobly" Young
Zachary "Runer112" Wassall
Patrick "tr1p1ea" Prendergast
"grosged"

Macro Definition Documentation

◆ gfx_AllocRLETSprite

#define gfx_AllocRLETSprite (   data_size,
  malloc_routine 
)

Dynamically allocates memory for a sprite with RLE transpareny.

Allocates the memory with malloc_routine. Returns NULL upon allocation failure.

data_size is the maximum predicted/calculated size of the sprite data (excuding the width and height bytes) that will be stored in the allocated sprite. Sprite data size could be up to (width + 1) * height * 3 / 2 bytes in the worst case, in which pixels horizontally alternate between non-transparent and transparent and each row begins with a non-transparent pixel. But if the average length of a horizontal transparent run is at least 2, then the sprite data will be no larger than (width + 1) * height bytes. The exact data size necessary is 2 * num_horizontal_transparent_runs + num_non_transparent_pixels + num_rows_beginning_with_non_transparent_pixel - num_rows_ending_with_transparent_pixel bytes.

Note
If not used in a dynamic context and data_size is static, consider statically allocating the sprite instead with gfx_UninitedRLETSprite() or gfx_TempRLETSprite().
Remarks
If using malloc as the malloc_routine, gfx_MallocRLETSprite() can be used as a shortcut.
Parameters
data_size(maximum) sprite data size
malloc_routinemalloc implementation to use
Returns
pointer to the allocated sprite

◆ gfx_BlitBuffer

#define gfx_BlitBuffer ( )

Copies the buffer to the screen

◆ gfx_BlitScreen

#define gfx_BlitScreen ( )

Copies the screen to the buffer

◆ gfx_CheckRectangleHotspot

#define gfx_CheckRectangleHotspot (   master_x,
  master_y,
  master_width,
  master_height,
  test_x,
  test_y,
  test_width,
  test_height 
)

Checks if we are currently in a rectangular hotspot area

◆ gfx_Circle_NoClip

#define gfx_Circle_NoClip (   x,
  y,
  radius 
)

Draws an unclipped circle outline

This is measured from the top left origin of the screen.

Parameters
xX coordinate
yY coordinate
radiusThe radius of the circle

◆ gfx_ConvertMallocRLETSprite

#define gfx_ConvertMallocRLETSprite (   sprite_in)

Converts a sprite with normal transpareny to a sprite with RLE transparency, allocating the exact amount of necessary space for the converted sprite using malloc.

Width and height will be set in the converted sprite. Returns NULL upon allocation failure.

The transparent color index in the input sprite is controlled by gfx_SetTransparentColor().

Remarks
A gfx_sprite_t can be converted into an appropriately large, already-allocated gfx_rletsprite_t using gfx_ConvertToRLETSprite().
Parameters
sprite_ininput sprite with normal transparency
malloc_routinemalloc implementation to use
Returns
a newly allocated converted sprite with RLE transparency
See also
gfx_ConvertFromRLETSprite

◆ gfx_GetSprite_NoClip

#define gfx_GetSprite_NoClip (   sprite_buffer,
  x,
 
)

Grabs the background behind an unclipped sprite

This is useful for partial redraw.

Parameters
sprite_bufferBuffer used to store grabbed sprite
xX coordinate to grab sprite
yY coordinate to grab sprite
Returns
A pointer to sprite_buffer
Note
sprite_buffer must be pointing to a large enough buffer to hold width*height number of bytes

◆ gfx_GetTile

#define gfx_GetTile (   tilemap,
  x_offset,
  y_offset 
)

Gets a particular tile's value given an initialized tilemap structure and pixel offsets

Parameters
tilemapPointer to initialized tilemap structure
x_offsetOffset in pixels from the left of the tilemap
y_offsetOffset in pixels from the top of the tilemap

◆ gfx_GetTileMapped

#define gfx_GetTileMapped (   tilemap,
  row,
  col 
)

Gets a particular tile's value given an initialized tilemap structure and mapped offsets

Parameters
tilemapPointer to initialized tilemap structure
rowOffset in bytes in the row
colOffset in bytes in the column

◆ gfx_MallocRLETSprite

#define gfx_MallocRLETSprite (   data_size)

Dynamically allocates memory for a sprite with RLE transparency using malloc.

data_size is the size to allocate for sprite data; see gfx_AllocRLETSprite() for information. Returns NULL upon allocation failure.

Note
If not used in a dynamic context and data_size is static, consider statically allocating the sprite instead with gfx_UninitedRLETSprite() or gfx_TempRLETSprite().
Parameters
data_size(maximum) sprite data size
Returns
pointer to the allocated sprite
See also
gfx_AllocRLETSprite

◆ gfx_MallocSprite

#define gfx_MallocSprite (   width,
  height 
)

Dynamically allocates memory for a sprite using malloc.

width and height will be set in the sprite. Returns NULL upon allocation failure.

Note
If not used in a dynamic context and width and height are static, consider statically allocating the sprite instead with gfx_UninitedSprite() or gfx_TempSprite().
Parameters
widthsprite width
heightsprite height
Returns
pointer to the allocated sprite
See also
gfx_AllocSprite

◆ gfx_palette

#define gfx_palette

Used for accessing the lcd palette directly

This consists of 256 entries, each 2 bytes in size for a total of 512 bytes

◆ gfx_RGBTo1555

#define gfx_RGBTo1555 (   r,
  g,
 
)

Converts an RGB value to a palette color

Conversion is not 100% perfect, but is quite close

◆ gfx_RotatedSprite_NoClip

#define gfx_RotatedSprite_NoClip (   sprite,
  x,
  y,
  angle 
)

Helper macro to only perform rotation using gfx_RotatedScaledSprite_NoClip

Parameters
sprite_inInput sprite to rotate
sprite_outPointer to where rotated sprite will be stored
angle256 position angular integer
See also
gfx_RotatedScaledTransparentSprite_NoClip

◆ gfx_RotatedTransparentSprite_NoClip

#define gfx_RotatedTransparentSprite_NoClip (   sprite,
  x,
  y,
  angle 
)

Helper macro to only perform rotation using gfx_RotatedScaledTransparentSprite_NoClip

Parameters
sprite_inInput sprite to rotate
sprite_outPointer to where rotated sprite will be stored
angle256 position angular integer
See also
gfx_RotatedScaledTransparentSprite_NoClip

◆ gfx_RotateSprite

#define gfx_RotateSprite (   sprite_in,
  sprite_out,
  angle 
)

Helper macro to only perform rotation using gfx_RotateScaleSprite

Parameters
sprite_inInput sprite to rotate
sprite_outPointer to where rotated sprite will be stored
angle256 position angular integer
Returns
A pointer to sprite_out
See also
gfx_RotateScaleSprite

◆ gfx_SetDrawBuffer

#define gfx_SetDrawBuffer ( )

Makes the subsequent GraphX drawing routines act on the buffer

◆ gfx_SetDrawScreen

#define gfx_SetDrawScreen ( )

Makes the subsequent GraphX drawing routines act on the screen

◆ gfx_SetTile

#define gfx_SetTile (   tilemap,
  x_offset,
  y_offset,
  value 
)

Sets a particular tile's value given an initialized tilemap structure and pixel offsets

Parameters
tilemapPointer to initialized tilemap structure
x_offsetOffset in pixels from the left of the tilemap
y_offsetOffset in pixels from the top of the tilemap
valueValue to set tile to

◆ gfx_SetTileMapped

#define gfx_SetTileMapped (   tilemap,
  row,
  col,
  value 
)

Sets a particular tile's value given an initialized tilemap structure and mapped offsets

Parameters
tilemapPointer to initialized tilemap structure
rowOffset in bytes in the row
colOffset in bytes in the column
valueValue to set tile to

◆ gfx_TempSprite

#define gfx_TempSprite (   name,
  width,
  height 
)

Statically allocates memory for a sprite.

Declares a gfx_sprite_t * with the given name pointing to the allocated memory. width and height will be set in the sprite, unlike gfx_UninitedSprite().

Attention
Due to width and height being set, the memory will be allocated in the initialized data segment. If the compiled program is not compressed, then this could be a serious source of bloat and gfx_UninitedSprite() should be preferred.
Parameters
namename of declared gfx_sprite_t *
widthsprite width
heightsprite height
See also
gfx_MallocSprite

◆ gfx_UninitedRLETSprite

#define gfx_UninitedRLETSprite (   name,
  data_size 
)

Statically allocates unitialized memory for a sprite with RLE transparency.

Declares a gfx_rletsprite_t * with the given name pointing to the allocated memory. data_size is the size to allocate for sprite data; see gfx_AllocRLETSprite() for information.

Warning
If used outside of a function body, the memory will be allocated in the global unitialized data segment (BSS). If used inside a function body, the memory will be allocated on the stack. If the sprite is sufficiently large, usage inside a function body will overflow the stack, so it is recommended that this normally be used outside of a function body.
Parameters
namename of declared gfx_rletsprite_t *
data_size(maximum) sprite data size
See also
gfx_MallocRLETSprite

◆ gfx_UninitedSprite

#define gfx_UninitedSprite (   name,
  width,
  height 
)

Statically allocates unitialized memory for a sprite.

Declares a gfx_sprite_t * with the given name pointing to the allocated memory. width and height will not be set in the sprite, unlike gfx_TempSprite().

Warning
If used outside of a function body, the memory will be allocated in the global unitialized data segment (BSS). If used inside a function body, the memory will be allocated on the stack. If the sprite is sufficiently large, usage inside a function body will overflow the stack, so it is recommended that this normally be used outside of a function body.
Parameters
namename of declared gfx_sprite_t *
widthsprite width
heightsprite height
See also
gfx_MallocSprite

◆ gfx_vbuffer

#define gfx_vbuffer

Array of the current drawing buffer

Total of 76800 bytes in size

See also
gfx_vram

◆ gfx_vram

#define gfx_vram

Array of the LCD RAM

Total of 153600 bytes in size

See also
gfx_vbuffer

Enumeration Type Documentation

◆ gfx_location_t

Different locations routines can be drawn to.

Enumerator
gfx_screen 

Screen

gfx_buffer 

Buffer

◆ gfx_mode_t

enum gfx_mode_t

Stores operating modes of this library.

See also
gfx_Begin
Enumerator
gfx_8bpp 

Enable 8 bits per pixel mode

◆ gfx_text_options_t

Different available text modes.

Enumerator
gfx_text_clip 

Text routines will clip against the defined clip window

gfx_text_noclip 

Default, text routines do not clip (much faster)

◆ gfx_tilemap_type_t

Used for defining tile types.

See also
gfx_tilemap_t
Enumerator
gfx_tile_no_pow2 

Use when the tile width/height is not a power of 2

gfx_tile_2_pixel 

Use when the tile width/height is 2 pixels

gfx_tile_4_pixel 

Use when the tile width/height is 4 pixels

gfx_tile_8_pixel 

Use when the tile width/height is 8 pixels

gfx_tile_16_pixel 

Use when the tile width/height is 16 pixels

gfx_tile_32_pixel 

Use when the tile width/height is 32 pixels

gfx_tile_64_pixel 

Use when the tile width/height is 64 pixels

gfx_tile_128_pixel 

Use when the tile width/height is 128 pixels

Function Documentation

◆ gfx_AllocSprite()

gfx_sprite_t* gfx_AllocSprite ( uint8_t  width,
uint8_t  height,
void *(*)(size_t)  malloc_routine 
)

Dynamically allocates memory for a sprite.

Allocates the memory with malloc_routine. width and height will be set in the allocated sprite. Returns NULL upon allocation failure.

Note
If not used in a dynamic context and width and height are static, consider statically allocating the sprite instead with gfx_UninitedSprite() or gfx_TempSprite().
Remarks
If using malloc as the malloc_routine, gfx_MallocSprite() can be used as a shortcut.
Parameters
widthsprite width
heightsprite height
malloc_routinemalloc implementation to use
Returns
pointer to the allocated sprite

◆ gfx_Begin()

int gfx_Begin ( )

Initializes the graphics library setup

◆ gfx_Blit()

void gfx_Blit ( gfx_location_t  src)

Copies the input buffer to the opposite buffer

No clipping is performed; as it is a copy not a draw

Parameters
srcdrawing location to copy from
See also
gfx_location_t

◆ gfx_BlitLines()

void gfx_BlitLines ( gfx_location_t  src,
uint8_t  y_loc,
uint8_t  num_lines 
)

Copies lines from the input buffer to the opposite buffer

No clipping is performed; as it is a copy not a draw

Parameters
srcdrawing location to copy from
y_locY Location to begin copying at
num_linesNumber of lines to copy
See also
gfx_location_t

◆ gfx_BlitRectangle()

void gfx_BlitRectangle ( gfx_location_t  src,
uint24_t  x,
uint8_t  y,
uint24_t  width,
uint24_t  height 
)

Transfers a rectangle from the source graphics buffer to the opposite buffer.

No clipping is performed; as it is a copy not a draw

Parameters
srcdrawing location to copy from
xX coordinate
yY coordinate
widthWidth of rectangle
heightHeight of rectangle
See also
gfx_location_t

◆ gfx_Circle()

void gfx_Circle ( int  x,
int  y,
unsigned  radius 
)

Draws a circle outline

This is measured from the top left origin of the screen.

Parameters
xX coordinate
yY coordinate
radiusThe radius of the circle

◆ gfx_CohenSutherlandClip()

bool gfx_CohenSutherlandClip ( int *  x0,
int *  y0,
int *  x1,
int *  y1 
)

Clips the points in a window region

This is measured from the top left origin of the screen.

Parameters
x0First X coordinate
y0First Y coordinate
x1Second X coordinate
y1Second Y coordinate
Returns
False if not within window, true otherwise

◆ gfx_ConvertFromRLETSprite()

gfx_sprite_t* gfx_ConvertFromRLETSprite ( gfx_rletsprite_t sprite_in,
gfx_sprite_t sprite_out 
)

Converts a sprite with RLE transpareny to a sprite with normal transparency.

Width and height will be set in the converted sprite.

The transparent color index in the converted sprite is controlled by gfx_SetTransparentColor().

Attention
The output sprite must have been allocated with a large enough data field to hold the converted sprite data, which will be width * height bytes large.
Parameters
[in]sprite_ininput sprite with RLE transparency
[out]sprite_outconverted sprite with normal transparency
Returns
the converted sprite
See also
gfx_ConvertMallocRLETSprite
gfx_ConvertToRLETSprite

◆ gfx_ConvertToNewRLETSprite()

gfx_rletsprite_t* gfx_ConvertToNewRLETSprite ( gfx_sprite_t sprite_in,
void *(*)(size_t)  malloc_routine 
)

Converts a sprite with normal transpareny to a sprite with RLE transparency, allocating the exact amount of necessary space for the converted sprite.

Allocates the memory with malloc_routine. Width and height will be set in the converted sprite. Returns NULL upon allocation failure.

The transparent color index in the input sprite is controlled by gfx_SetTransparentColor().

Remarks
If using malloc as the malloc_routine, gfx_ConvertMallocRLETSprite() can be used as a shortcut.
A gfx_sprite_t can be converted into an appropriately large, already-allocated gfx_rletsprite_t using gfx_ConvertToRLETSprite().
Parameters
sprite_ininput sprite with normal transparency
malloc_routinemalloc implementation to use
Returns
a newly allocated converted sprite with RLE transparency
See also
gfx_ConvertFromRLETSprite

◆ gfx_ConvertToRLETSprite()

gfx_rletsprite_t* gfx_ConvertToRLETSprite ( gfx_sprite_t sprite_in,
gfx_rletsprite_t sprite_out 
)

Converts a sprite with normal transpareny to a sprite with RLE transparency.

Width and height will be set in the converted sprite.

The transparent color index in the input sprite is controlled by gfx_SetTransparentColor().

Attention
The output sprite must have been allocated with a large enough data field to hold the converted sprite data; see gfx_AllocRLETSprite() for information.
Note
To avoid needing to predict the output size and risking either the prediction being too high and wasting space, or being too low and corrupting memory, gfx_ConvertMallocRLETSprite() can be used instead to allocate the exact amount of necessary space for the converted sprite.
Parameters
[in]sprite_ininput sprite with normal transparency
[out]sprite_outconverted sprite with RLE transparency
Returns
the converted sprite
See also
gfx_ConvertFromRLETSprite

◆ gfx_CopyRectangle()

void gfx_CopyRectangle ( gfx_location_t  src,
gfx_location_t  dst,
uint24_t  src_x,
uint8_t  src_y,
uint24_t  dst_x,
uint8_t  dst_y,
uint24_t  width,
uint8_t  height 
)

Copies a rectangle between graphics buffers or to the same graphics buffer.

No clipping is performed; as it is a copy not a draw.

Parameters
srcGraphics buffer to copy from.
dstGraphics buffer to copy to.
src_xX coordinate on src.
src_yY coordinate on src.
dst_xX coordinate on dst.
dst_yY coordinate on dst.
widthWidth of rectangle.
heightHeight of rectangle.
See also
gfx_location_t

◆ gfx_Darken()

uint16_t gfx_Darken ( uint16_t  color,
uint8_t  amount 
)

Darkens a given 1555 color; useful for palette color conversions.

Parameters
colorOriginal color input in 1555 format
amountAmount to darken by
Returns
Darkened color
Note
0 returns full black, 255 returns original color

◆ gfx_End()

void gfx_End ( void  )

Closes the graphics setup

Restores the LCD to 16bpp prefered by the OS and clears the screen.

◆ gfx_FillCircle()

void gfx_FillCircle ( int  x,
int  y,
unsigned  radius 
)

Draws a filled circle

This is measured from the top left origin of the screen.

Parameters
xX coordinate
yY coordinate
radiusThe radius of the circle

◆ gfx_FillCircle_NoClip()

void gfx_FillCircle_NoClip ( uint24_t  x,
uint8_t  y,
unsigned  radius 
)

Draws an unclipped filled circle

This is measured from the top left origin of the screen.

Parameters
xX coordinate
yY coordinate
radiusThe radius of the circle

◆ gfx_FillRectangle()

void gfx_FillRectangle ( int  x,
int  y,
int  width,
int  height 
)

Draws a filled rectangle

This is measured from the top left origin of the screen.

Parameters
xX coordinate
yY coordinate
widthWidth of rectangle
heightHeight of rectangle

◆ gfx_FillRectangle_NoClip()

void gfx_FillRectangle_NoClip ( uint24_t  x,
uint8_t  y,
uint24_t  width,
uint8_t  height 
)

Draws an unclipped filled rectangle

This is measured from the top left origin of the screen.

Parameters
xX coordinate
yY coordinate
widthWidth of rectangle
heightHeight of rectangle

◆ gfx_FillScreen()

void gfx_FillScreen ( uint8_t  index)

Fills the screen with a given palette index

Parameters
indexColor index to fill with

◆ gfx_FillTriangle()

void gfx_FillTriangle ( int  x0,
int  y0,
int  x1,
int  y1,
int  x2,
int  y2 
)

Draws a filled triangle

Points are measured from the top left origin of the screen.

Parameters
x0First X coordinate
y0First Y coordinate
x1Second X coordinate
y1Second Y coordinate
x2Third X coordinate
y2Third Y coordinate

◆ gfx_FlipSpriteX()

gfx_sprite_t* gfx_FlipSpriteX ( gfx_sprite_t sprite_in,
gfx_sprite_t sprite_out 
)

Flips a sprite along the X axis

Parameters
sprite_inInput sprite to flip
sprite_outPointer to where flipped sprite will be stored
Returns
A pointer to sprite_out
Note
sprite_in and sprite_out cannot be the same

◆ gfx_FlipSpriteY()

gfx_sprite_t* gfx_FlipSpriteY ( gfx_sprite_t sprite_in,
gfx_sprite_t sprite_out 
)

Flips a sprite along the Y axis

Parameters
sprite_inInput sprite to flip
sprite_outPointer to where flipped sprite will be stored
Returns
A pointer to sprite_out
Note
sprite_in and sprite_out cannot be the same

◆ gfx_FloodFill()

void gfx_FloodFill ( unsigned int  x,
uint8_t  y,
uint8_t  color 
)

Fills an area with a color

Parameters
xX coordinate to begin filling at
yY coordinate to begin filling at
colorNew color to fill with
Note
This routine performs clipping to stay within the window, but you must ensure it starts in the window.

◆ gfx_GetCharWidth()

unsigned int gfx_GetCharWidth ( const char  c)

Gets the pixel width of the given character

Parameters
cCharacter to get width of
Returns
Width in pixels of character
Note
Takes into account monospacing flag

◆ gfx_GetClipRegion()

bool gfx_GetClipRegion ( gfx_region_t region)

Clips a region to fit within the drawing window using Cohen-Sutherland

Returns
False if offscreen, true if onscreen

◆ gfx_GetDraw()

uint8_t gfx_GetDraw ( void  )

Gets current draw location

Returns
Location type enumeration
See also
gfx_location_t

◆ gfx_GetPixel()

uint8_t gfx_GetPixel ( uint24_t  x,
uint8_t  y 
)

Gets a pixel's color index

This is measured from the top left origin of the screen. Pixels are only clipped within the screen boundaries

Parameters
xX coordinate location
yY coordinate location

◆ gfx_GetSprite()

gfx_sprite_t* gfx_GetSprite ( gfx_sprite_t sprite_buffer,
int  x,
int  y 
)

Grabs the background behind a sprite

This is useful for partial redraw.

Parameters
sprite_bufferBuffer used to store grabbed sprite
xX coordinate to grab sprite
yY coordinate to grab sprite
Returns
A pointer to sprite_buffer
Note
sprite_buffer must be pointing to a large enough buffer to hold width*height number of bytes

◆ gfx_GetSpriteChar()

gfx_sprite_t* gfx_GetSpriteChar ( char  c)

Creates a temporary character sprite

This may be useful for performing rotations and other operations on characters. The sprite returned is always 8x8 pixels.

Parameters
cCharacter to generate
Returns
A sprite of the character data

◆ gfx_GetStringWidth()

unsigned int gfx_GetStringWidth ( const char *  string)

Gets the pixel width of the given string

Parameters
stringPointer to a string
Note
Takes into account monospacing flag

◆ gfx_GetTextX()

int gfx_GetTextX ( void  )
Returns
The current text cursor X position

◆ gfx_GetTextY()

int gfx_GetTextY ( void  )
Returns
The current text cursor Y position

◆ gfx_HorizLine()

void gfx_HorizLine ( int  x,
int  y,
int  length 
)

Draws a horizontal line

This is measured from the top left origin of the screen. Performs faster than using gfx_Line

Parameters
xX coordinate
yY coordinate
lengthLength of line

◆ gfx_HorizLine_NoClip()

void gfx_HorizLine_NoClip ( uint24_t  x,
uint8_t  y,
uint24_t  length 
)

Draws an unclipped horizontal line

This is measured from the top left origin of the screen. Performs faster than using gfx_Line

Parameters
xX coordinate
yY coordinate
lengthLength of line

◆ gfx_Lighten()

uint16_t gfx_Lighten ( uint16_t  color,
uint8_t  amount 
)

Lightens a given 1555 color; useful for palette color conversions.

Parameters
colorOriginal color input in 1555 format
amountAmount to lighten by
Returns
Lightened color
Note
0 returns full white, 255 returns original color

◆ gfx_Line()

void gfx_Line ( int  x0,
int  y0,
int  x1,
int  y1 
)

Draws a line

This is measured from the top left origin of the screen.

Parameters
x0First X coordinate
y0First Y coordinate
x1Second X coordinate
y1Second Y coordinate

◆ gfx_Line_NoClip()

void gfx_Line_NoClip ( uint24_t  x0,
uint8_t  y0,
uint24_t  x1,
uint8_t  y1 
)

Draws an unclipped line

This is measured from the top left origin of the screen.

Parameters
x0First X coordinate
y0First Y coordinate
x1Second X coordinate
y1Second Y coordinate

◆ gfx_Polygon()

void gfx_Polygon ( int *  points,
unsigned  num_points 
)

Draws a polygon outline

Points are measured from the top left origin of the screen.

int points[6] = {
160, 1, // (x0, y0)
1, 238, // (x1, y1)
318,238, // (x2, y2)
};
num_points = 3;
gfx_Polygon(points, num_points)
Parameters
pointsPointer to x and y pairs
num_pointsNumber of x and y pairs

◆ gfx_Polygon_NoClip()

void gfx_Polygon_NoClip ( int *  points,
unsigned  num_points 
)

Draws an unclipped polygon outline

Points are measured from the top left origin of the screen.

int points[6] = {
160, 1, // (x0, y0)
1, 238, // (x1, y1)
318,238, // (x2, y2)
};
num_points = 3;
gfx_Polygon_NoClip(points, num_points)
Parameters
pointsPointer to x and y pairs
num_pointsNumber of x and y pairs

◆ gfx_PrintChar()

void gfx_PrintChar ( const char  c)

Prints a character

Outputs a character at the current cursor position.

Parameters
cCharacter to print
Note
By default, no text clipping is performed (configurable with gfx_SetTextConfig)

◆ gfx_PrintInt()

void gfx_PrintInt ( int  n,
uint8_t  length 
)

Prints a signed integer

Outputs at the current cursor position. Padded with leading zeros if necessary to satisfy the specified minimum length.

Parameters
nInteger to print
lengthMinimum number of characters to print
Note
By default, no text clipping is performed (configurable with gfx_SetTextConfig)
length must be between 1 and 8, inclusive

◆ gfx_PrintString()

void gfx_PrintString ( const char *  string)

Prints a string

Outputs a string at the current cursor position.

Parameters
stringPointer to string to print
Note
By default, no text clipping is performed (configurable with gfx_SetTextConfig)

◆ gfx_PrintStringXY()

void gfx_PrintStringXY ( const char *  string,
int  x,
int  y 
)

Prints a string at coordinates

Outputs a string at the supplied coordinates Posistion is measured from top left origin of screen.

Parameters
stringPointer to string to print
xX coordinate
yY coordinate
Note
By default, no text clipping is performed (configurable with gfx_SetTextConfig)

◆ gfx_PrintUInt()

void gfx_PrintUInt ( unsigned int  n,
uint8_t  length 
)

Prints an unsigned integer

Outputs at the current cursor position. Padded with leading zeros if necessary to satisfy the specified minimum length.

Parameters
nUnsigned integer to print
lengthMinimum number of characters to print
Note
By default, no text clipping is performed (configurable with gfx_SetTextConfig)
length must be between 1 and 8, inclusive

◆ gfx_Rectangle()

void gfx_Rectangle ( int  x,
int  y,
int  width,
int  height 
)

Draws a rectangle outline

This is measured from the top left origin of the screen.

Parameters
xX coordinate
yY coordinate
widthWidth of rectangle
heightHeight of rectangle

◆ gfx_Rectangle_NoClip()

void gfx_Rectangle_NoClip ( uint24_t  x,
uint8_t  y,
uint24_t  width,
uint8_t  height 
)

Draws an unclipped rectangle outline

This is measured from the top left origin of the screen.

Parameters
xX coordinate
yY coordinate
widthWidth of rectangle
heightHeight of rectangle

◆ gfx_RLETSprite()

void gfx_RLETSprite ( gfx_rletsprite_t sprite,
int  x,
int  y 
)

Draws a sprite with RLE transparency.

Parameters
spritesprite to draw
xx-coordinate
yy-coordinate

◆ gfx_RLETSprite_NoClip()

void gfx_RLETSprite_NoClip ( gfx_rletsprite_t sprite,
uint24_t  x,
uint8_t  y 
)

Draws an unclipped sprite with RLE transparency.

Parameters
spritesprite to draw
xx-coordinate
yy-coordinate

◆ gfx_RotatedScaledSprite_NoClip()

uint8_t gfx_RotatedScaledSprite_NoClip ( gfx_sprite_t sprite,
uint24_t  x,
uint8_t  y,
uint8_t  angle,
uint8_t  scale 
)

Fixed Rotation with scaling fator for sprites without transparency

Note
A scale factor of 64 represents 100% scaling
Warning
This routine only accepts square input sprites
Parameters
spriteInput sprite to rotate/scale
xX coordinate position
xY coordinate position
angle256 position angular integer
scaleScaling factor; range is about 1% to 400% scale
Returns
The size of the sprite after scaling. This can be used for centering purposes.

◆ gfx_RotatedScaledTransparentSprite_NoClip()

uint8_t gfx_RotatedScaledTransparentSprite_NoClip ( gfx_sprite_t sprite,
uint24_t  x,
uint8_t  y,
uint8_t  angle,
uint8_t  scale 
)

Fixed Rotation with scaling fator for sprites

Note
A scale factor of 64 represents 100% scaling
Warning
This routine only accepts square input sprites
Parameters
spriteInput sprite to rotate/scale
xX coordinate position
xY coordinate position
angle256 position angular integer
scaleScaling factor; range is about 1% to 400% scale
Returns
The size of the sprite after scaling. This can be used for centering purposes.

◆ gfx_RotateScaleSprite()

gfx_sprite_t* gfx_RotateScaleSprite ( gfx_sprite_t sprite_in,
gfx_sprite_t sprite_out,
uint8_t  angle,
uint8_t  scale 
)

Fixed Rotation with scaling factor for sprites

The output sprite is updated with the dimensions required for the implemented scaling factor. You must make sure that sprite_out has enough memory to store the needed output sprite. This can be found with the following formula: size = (max_scale / 64) * width * height + 2;

Note
A scale factor of 64 represents 100% scaling
Warning
This routine only accepts square input sprites
Parameters
sprite_inInput sprite to rotate/scale
sprite_outPointer to where rotated/scaled sprite will be stored
angle256 position angular integer
scaleScaling factor; range is about 1% to 400% scale
Returns
A pointer to sprite_out

◆ gfx_RotateSpriteC()

gfx_sprite_t* gfx_RotateSpriteC ( gfx_sprite_t sprite_in,
gfx_sprite_t sprite_out 
)

Rotates a sprite 90 degrees clockwise

Parameters
sprite_inInput sprite to rotate
sprite_outPointer to where rotated sprite will be stored
Returns
A pointer to sprite_out
Note
sprite_in and sprite_out cannot be the same

◆ gfx_RotateSpriteCC()

gfx_sprite_t* gfx_RotateSpriteCC ( gfx_sprite_t sprite_in,
gfx_sprite_t sprite_out 
)

Rotates a sprite 90 degrees counter clockwise

Parameters
sprite_inInput sprite to rotate
sprite_outPointer to where rotated sprite will be stored
Returns
A pointer to sprite_out
Note
sprite_in and sprite_out cannot be the same

◆ gfx_RotateSpriteHalf()

gfx_sprite_t* gfx_RotateSpriteHalf ( gfx_sprite_t sprite_in,
gfx_sprite_t sprite_out 
)

Rotates a sprite 180 degrees

Parameters
sprite_inInput sprite to rotate
sprite_outPointer to where rotated sprite will be stored
Returns
A pointer to sprite_out

◆ gfx_ScaledSprite_NoClip()

void gfx_ScaledSprite_NoClip ( gfx_sprite_t sprite,
uint24_t  x,
uint8_t  y,
uint8_t  width_scale,
uint8_t  height_scale 
)

Scales an unclipped sprite

Scaling factors must be greater than or equal to 1, and an integer factor

Parameters
spritePointer to initialized sprite structure
xX coordinate
yY coordinate
width_scaleWidth scaling factor
height_scaleHeight scaling factor
Note
Useable with gfx_GetSprite in order to create clipped versions

◆ gfx_ScaledTransparentSprite_NoClip()

void gfx_ScaledTransparentSprite_NoClip ( gfx_sprite_t sprite,
uint24_t  x,
uint8_t  y,
uint8_t  width_scale,
uint8_t  height_scale 
)

Scales an unclipped transparent sprite

Scaling factors must be greater than or equal to 1, and an integer factor

Parameters
spritePointer to initialized sprite structure
xX coordinate
yY coordinate
width_scaleWidth scaling factor
height_scaleHeight scaling factor
Note
Useable with gfx_GetSprite in order to create clipped versions

◆ gfx_ScaleSprite()

gfx_sprite_t* gfx_ScaleSprite ( gfx_sprite_t sprite_in,
gfx_sprite_t sprite_out 
)

Resizes a sprite to new dimensions

Place new image dimensions in sprite_out; i.e. sprite_out->width = 80; sprite_out->height = 20.

Parameters
sprite_inInput sprite to scale
sprite_outPointer to where scaled sprite will be stored
Returns
A pointer to sprite_out

◆ gfx_SetCharData()

uint8_t* gfx_SetCharData ( uint8_t  index,
uint8_t *  data 
)

Sets the font data for a specific character

Parameters
indexCharacter index to modify (if using default font, values range from 0-127, custom font can have indexes 0-255)
dataPointer to formated 8x8 pixel font
Returns
Pointer to current character data if data is NULL, otherwise a pointer to next character data
Note
Format of font data is 8 bytes horizontally aligned.
See also
gfx_SetFontData

◆ gfx_SetClipRegion()

void gfx_SetClipRegion ( int  xmin,
int  ymin,
int  xmax,
int  ymax 
)

Sets the dimensions of the drawing window for all clipped routines

Parameters
xminMinimum x coordinate, inclusive (default 0)
yminMinimum y coordinate, inclusive (default 0)
xmaxMaximum x coordinate, exclusive (default 320)
ymaxMaximum y coordinate, exclusive (default 240)

◆ gfx_SetColor()

uint8_t gfx_SetColor ( uint8_t  index)

Sets the color index that drawing routines will use

This applies to lines, rectangles, circles, etc

Parameters
indexColor index to set
Returns
Previous set color index

◆ gfx_SetDefaultPalette()

void gfx_SetDefaultPalette ( gfx_mode_t  mode)

Sets up the default palette for the given mode

Parameters
modePalette to use

◆ gfx_SetDraw()

void gfx_SetDraw ( uint8_t  location)

Forces all graphics routines draw location

Parameters
locationLocation routines should draw to
See also
gfx_location_t

◆ gfx_SetFontData()

uint8_t* gfx_SetFontData ( uint8_t *  data)

Sets the font's character data

Fonts can be created manually or and exported to a C-style format using 8x8 Pixel ROM Font Editor. (https://www.min.at/prinz/o/software/pixelfont/#download)

Parameters
dataPointer to formated 8x8 pixel font
Returns
Pointer to previous font data
Note
Format of font data is 8 bytes horizontally aligned.

◆ gfx_SetFontHeight()

uint8_t gfx_SetFontHeight ( uint8_t  height)

Sets the height in pixels of each character

The default value is 8 pixels

Parameters
heightNew font height in pixels
Returns
Previous height of font in pixels

◆ gfx_SetFontSpacing()

void gfx_SetFontSpacing ( uint8_t *  spacing)

Sets the font spacing

Parameters
spacingPointer to array of character spacing

◆ gfx_SetMonospaceFont()

void gfx_SetMonospaceFont ( uint8_t  spacing)

Sets a monospaced font width

Parameters
spacingDistance between characters
Note
To disable monospaced font, set to 0

◆ gfx_SetPalette()

void gfx_SetPalette ( uint16_t *  palette,
uint24_t  size,
uint8_t  offset 
)

Sets entries in the palette

Parameters
palettePointer to palette to use
sizeSize of palette to store
offsetOffset in bytes to start at (Generally set to 0)

◆ gfx_SetPixel()

void gfx_SetPixel ( uint24_t  x,
uint8_t  y 
)

Sets a pixel to the global color index

This is measured from the top left origin of the screen. Pixels are only clipped within the screen boundaries

Parameters
xX coordinate location
yY coordinate location
See also
gfx_SetColor

◆ gfx_SetTextBGColor()

uint8_t gfx_SetTextBGColor ( uint8_t  color)

Sets text background color

Parameters
colorColor index to set
Returns
Previous text background color index
Note
Default text background color index: 255

◆ gfx_SetTextConfig()

void gfx_SetTextConfig ( uint8_t  config)

Sets the configuration for the text routines

Parameters
configSet the options for the text mode
See also
gfx_text_options_t
Note
Scaled text does not clip

◆ gfx_SetTextFGColor()

uint8_t gfx_SetTextFGColor ( uint8_t  color)

Sets text foreground color

Parameters
colorColor index to set
Returns
Previous text foreground color index
Note
Default text foreground color index: 0

◆ gfx_SetTextScale()

void gfx_SetTextScale ( uint8_t  width_scale,
uint8_t  height_scale 
)

Sets the scaling for text

Values in the range from 1-5 are preferred.

Parameters
width_scaleText width scaling
height_scaleText height scaling

◆ gfx_SetTextTransparentColor()

uint8_t gfx_SetTextTransparentColor ( uint8_t  color)

Sets text transparency color

Parameters
colorColor index to set
Returns
Previous text transparency color index
Note
Default text transparency color index: 255

◆ gfx_SetTextXY()

void gfx_SetTextXY ( int  x,
int  y 
)

Sets the text cursor XY position

Parameters
xX coordinate
yY coordinate

◆ gfx_SetTransparentColor()

uint8_t gfx_SetTransparentColor ( uint8_t  index)

Sets the transparent index that drawing routines will use

This currently applies to transparent sprites, both scaled and unscaled

Parameters
indexTransparent color index to set
Returns
The previous transparent color index

◆ gfx_ShiftDown()

void gfx_ShiftDown ( uint8_t  pixels)

Shifts/Slides the drawing window down

Parameters
pixelsNumber of pixels to shift
Note
Remnant data after a shift is undefined

◆ gfx_ShiftLeft()

void gfx_ShiftLeft ( uint24_t  pixels)

Shifts/Slides the drawing window left

Parameters
pixelsNumber of pixels to shift
Note
Remnant data after a shift is undefined

◆ gfx_ShiftRight()

void gfx_ShiftRight ( uint24_t  pixels)

Shifts/Slides the drawing window right

Parameters
pixelsNumber of pixels to shift
Note
Remnant data after a shift is undefined

◆ gfx_ShiftUp()

void gfx_ShiftUp ( uint8_t  pixels)

Shifts/Slides the drawing window up

Parameters
pixelsNumber of pixels to shift
Note
Remnant data after a shift is undefined

◆ gfx_Sprite()

void gfx_Sprite ( gfx_sprite_t sprite,
int  x,
int  y 
)

Draws a sprite

Parameters
spritePointer to initialized sprite structure
xX coordinate
yY coordinate

◆ gfx_Sprite_NoClip()

void gfx_Sprite_NoClip ( gfx_sprite_t sprite,
uint24_t  x,
uint8_t  y 
)

Draws an unclipped sprite

Parameters
spritePointer to initialized sprite structure
xX coordinate
yY coordinate

◆ gfx_SwapDraw()

void gfx_SwapDraw ( void  )

Swaps the roles of the screen and drawing buffers.

Does not wait for the old screen buffer to finish being displayed. Instead, the next invocation of a graphx drawing function will block, waiting for this event. To block and wait explicitly, use gfx_Wait().

The LCD driver maintains its own screen buffer pointer for the duration of a refresh. The swap performed by this function will only be picked up at a point between refreshes.

Remarks
In practice, this function should be invoked immediately after finishing drawing a frame to the drawing buffer, and invocation of the first graphx drawing function for the next frame should be scheduled as late as possible relative to non-drawing logic. Non-drawing logic can execute during time when a drawing function may otherwise block.

◆ gfx_Tilemap()

void gfx_Tilemap ( gfx_tilemap_t tilemap,
uint24_t  x_offset,
uint24_t  y_offset 
)

Draws a tilemap given an initialized tilemap structure

Parameters
tilemapPointer to initialized tilemap structure
x_offsetOffset in pixels from the left of the tilemap
y_offsetOffset in pixels from the top of the tilemap
See also
gfx_tilemap_t

◆ gfx_Tilemap_NoClip()

void gfx_Tilemap_NoClip ( gfx_tilemap_t tilemap,
uint24_t  x_offset,
uint24_t  y_offset 
)

Draws an unclipped tilemap given an initialized tilemap structure

Parameters
tilemapPointer to initialized tilemap structure
x_offsetOffset in pixels from the left of the tilemap
y_offsetOffset in pixels from the top of the tilemap
See also
gfx_tilemap_t

◆ gfx_TilePtr()

uint8_t* gfx_TilePtr ( gfx_tilemap_t tilemap,
uint24_t  x_offset,
uint24_t  y_offset 
)

Gets a pointer to a particular tile given an initialized tilemap structure and pixel offsets

Parameters
tilemapPointer to initialized tilemap structure
x_offsetOffset in pixels from the left of the tilemap
y_offsetOffset in pixels from the top of the tilemap

◆ gfx_TilePtrMapped()

uint8_t* gfx_TilePtrMapped ( gfx_tilemap_t tilemap,
uint8_t  row,
uint8_t  col 
)

Gets a pointer to a particular tile given an initialized tilemap structure and mapped offsets

Parameters
tilemapPointer to initialized tilemap structure
rowOffset in bytes in the row
colOffset in bytes in the column

◆ gfx_TransparentSprite()

void gfx_TransparentSprite ( gfx_sprite_t sprite,
int  x,
int  y 
)

Draws a transparent sprite

Parameters
spritePointer to initialized sprite structure
xX coordinate
yY coordinate

◆ gfx_TransparentSprite_NoClip()

void gfx_TransparentSprite_NoClip ( gfx_sprite_t sprite,
uint24_t  x,
uint8_t  y 
)

Draws an unclipped transparent sprite

Parameters
spritePointer to initialized sprite structure
xX coordinate
yY coordinate

◆ gfx_TransparentTilemap()

void gfx_TransparentTilemap ( gfx_tilemap_t tilemap,
uint24_t  x_offset,
uint24_t  y_offset 
)

Draws a transparent tilemap given an initialized tilemap structure

Parameters
tilemapPointer to initialized tilemap structure
x_offsetOffset in pixels from the left of the tilemap
y_offsetOffset in pixels from the top of the tilemap
See also
gfx_tilemap_t

◆ gfx_TransparentTilemap_NoClip()

void gfx_TransparentTilemap_NoClip ( gfx_tilemap_t tilemap,
uint24_t  x_offset,
uint24_t  y_offset 
)

Draws an unclipped transparent tilemap given an initialized tilemap structure

Parameters
tilemapPointer to initialized tilemap structure
x_offsetOffset in pixels from the left of the tilemap
y_offsetOffset in pixels from the top of the tilemap
See also
gfx_tilemap_t

◆ gfx_VertLine()

void gfx_VertLine ( int  x,
int  y,
int  length 
)

Draws a vertical line

This is measured from the top left origin of the screen. Performs faster than using gfx_Line

Parameters
xX coordinate
yY coordinate
lengthLength of line

◆ gfx_VertLine_NoClip()

void gfx_VertLine_NoClip ( uint24_t  x,
uint8_t  y,
uint24_t  length 
)

Draws an unclipped vertical line

This is measured from the top left origin of the screen. Performs faster than using gfx_Line

Parameters
xX coordinate
yY coordinate
lengthLength of line

◆ gfx_Wait()

void gfx_Wait ( void  )

Waits for the screen buffer to finish being displayed after gfx_SwapDraw().

Remarks
In practice, this function should not need to be invoked by user code. It should be invoked by custom drawing functions (as late as reasonably possible) before writing to the drawing buffer, gfx_vbuffer.

◆ gfx_ZeroScreen()

void gfx_ZeroScreen ( void  )

Implements a faster version of gfx_FillScreen(0)

See also
gfx_FillScreen