Table of Contents
drawing_funcs.h
drawing_funcs.h provides functions and macros related to putting stuff on the screen!
Defines
Sprite flips
- SPRITE_FLIP_NONE - Apply no sprite flip
- SPRITE_FLIP_X - Apply horizontal sprite flipping
- SPRITE_FLIP_Y - Apply vertical sprite flipping
- SPRITE_FLIP_BOTH - Apply sprite flipping on both axes
Sprite RAM Sections
- QUADRANT_0 - Upper left quadrant of Sprite RAM page
- QUADRANT_1 - Upper right quadrant of Sprite RAM page
- QUADRANT_2 - Bottom left quadrant of Sprite RAM page
- QUADRANT_3 - Bottom right quadrant of Sprite RAM page
Functions
load_spritesheet
void load_spritesheet(char* spriteData, char srcBank, char ramBank);
Decompresses sprite data and places it into Sprite RAM.
- spriteData - pointer to start of compressed sprite data
- srcBank - bank number on flash cartridge
- ramBank - section number of Sprite RAM to load into
Can also be use with only two apparent arguments, using the asset macros generated by “make import”.
load_spritesheet(&ASSET__gfx__mysprite_bmp, 0);
load_big_spritesheet
#define load_big_spritesheet(NAME,BANK)
Macro that calls load_spritesheet four times to load an images that spans a full Sprite RAM page.
- NAME - Use a generated asset macro from “make import”, assumed to be larger than 128 pixels in both width and height.
- BANK - section number of Sprite RAM to load into
clear_spritebank
void clear_spritebank(char bank);
* bank - section number of Sprite RAM to zero out
Fill a 128×128 Sprite RAM bank with zero-value pixels.
draw_sprite_frame
void draw_sprite_frame(const Frame *sprite_table, char sprite_table_bank, char x, char y, char frame, char flip, char bank);
- sprite_table - pointer to frame bounding boxes array
- sprite_table_bank - bank number where sprite_table is stored
- x - location on screen to place sprite center
- y - location on screen to place sprite center
- frame - frame number in bounding boxes list
- flip - bitmask for sprite flipping
- bank - (bitmask) which framebuffer page to draw on and which Sprite RAM page to use
Draws a packed sprite as exported from Aseprite with a given X,Y position and frame number. Drawing operation is added to the drawing queue if a drawing is already in progress.
draw_sprite
#define draw_sprite(X,Y,W,H,GX,GY,RAMBANK)
- X, Y - position on screen to draw (upper left corner)
- W, H - width and height to draw
- GX,GY - position (upper left corner) of source in Sprite RAM
- RAMBANK - Which Sprite RAM bank to use
Macro that sets a temporary rect variable and then calls draw_sprite_rect();
draw_tile
#define draw_tile(X,Y,W,H,GX,GY,RAMBANK)
- X, Y - position on screen to draw (upper left corner)
- W, H - width and height to draw
- GX,GY - position (upper left corner) of source in Sprite RAM
- RAMBANK - Which Sprite RAM bank to use
Macro that sets a temporary rect variable and then calls draw_sprite_rect(), with tiling mode enabled. Source data will repeat over a 16×16 square.
draw_box
void draw_box(unsigned char x, unsigned char y, unsigned char w, unsigned char h, unsigned char c);
- x, y - position on screen to draw (upper left corner)
- w, h - width and height to draw
- c - color byte to use
Draws a solid color box, submitting the operation to the drawing queue and starting it if the queue isn't already processing.
next_draw_queue
void next_draw_queue();
If there are draw operations in the queue but the queue is not running, this function starts the queue processing.
await_draw_queue
void await_draw_queue();
If the drawing queue is running then this function loops and returns when the drawing queue finishes.
clear_border
void clear_border(char c);
- c - the color to use
Draws a border color around the screen. Uses the draw queue.
clear_screen
void clear_screen(char c);
- c - color to use
Clear the screen to a background color. Uses the draw queue.
draw_box_now
void draw_box_now(char x, char y, char w, char h, char c);
Draws a colored box the same way as draw_box but skips/ignores/interrupts the draw queue.
draw_sprite_now
void draw_sprite_now(char x, char y, char w, char h, char gx, char gy, char ramBank);
Draw a sprite immediately, skipping/ignoring/interrupting the draw queue.
draw_tiles_now
void draw_tiles_now(char x, char y, char w, char h, char gx, char gy, char ramBank);
draw_fade
void draw_fade(unsigned char opacity);
Draws a repeated dither fade pattern across the whole screen. (Makes some very particular assumptions about what sprite data you've loaded and where? Need to check this)
printnum
void printnum(int num);
print_hex_num
void print_hex_num(char num);
void print(char* str);