development:csdk:1.0:headers:drawing_funcs
                Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| development:csdk:1.0:headers:drawing_funcs [2024/11/08 01:57] – removed - external edit (Unknown date) 127.0.0.1 | development:csdk:1.0:headers:drawing_funcs [2024/11/08 01:57] (current) – ↷ Page moved from development:csdk:headers:drawing_funcs to development:csdk:1.0:headers:drawing_funcs clyde | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== 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 ==== | ||
| + | <code C> | ||
| + | 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" | ||
| + | <code C> | ||
| + | |||
| + | ==== load_big_spritesheet ==== | ||
| + | <code C> | ||
| + | #define load_big_spritesheet(NAME, | ||
| + | </ | ||
| + | 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", | ||
| + | * BANK - section number of Sprite RAM to load into | ||
| + | ==== clear_spritebank ==== | ||
| + | <code C> | ||
| + | void clear_spritebank(char bank); | ||
| + | </ | ||
| + | |||
| + | * bank - section number of Sprite RAM to zero out | ||
| + | |||
| + | Fill a 128x128 Sprite RAM bank with zero-value pixels. | ||
| + | ==== draw_sprite_frame ==== | ||
| + | <code C> | ||
| + | void draw_sprite_frame(const Frame *sprite_table, | ||
| + | </ | ||
| + | * 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 ==== | ||
| + | <code C> | ||
| + | #define draw_sprite(X, | ||
| + | </ | ||
| + | * 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 ==== | ||
| + | <code C> | ||
| + | #define draw_tile(X, | ||
| + | </ | ||
| + | * 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(), | ||
| + | Source data will repeat over a 16x16 square. | ||
| + | ==== draw_box ==== | ||
| + | <code C> | ||
| + | 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 ==== | ||
| + | <code C> | ||
| + | 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 ==== | ||
| + | <code C> | ||
| + | void await_draw_queue(); | ||
| + | </ | ||
| + | |||
| + | If the drawing queue is running then this function loops and returns when the drawing queue finishes. | ||
| + | ==== clear_border ==== | ||
| + | <code C> | ||
| + | void clear_border(char c); | ||
| + | </ | ||
| + | |||
| + | * c - the color to use | ||
| + | |||
| + | Draws a border color around the screen. Uses the draw queue. | ||
| + | ==== clear_screen ==== | ||
| + | <code C> | ||
| + | void clear_screen(char c); | ||
| + | </ | ||
| + | |||
| + | * c - color to use | ||
| + | |||
| + | Clear the screen to a background color. Uses the draw queue. | ||
| + | ==== draw_box_now ==== | ||
| + | <code C> | ||
| + | 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/ | ||
| + | ==== draw_sprite_now ==== | ||
| + | <code C> | ||
| + | void draw_sprite_now(char x, char y, char w, char h, char gx, char gy, char ramBank); | ||
| + | </ | ||
| + | |||
| + | Draw a sprite immediately, | ||
| + | ==== draw_tiles_now ==== | ||
| + | <code C> | ||
| + | void draw_tiles_now(char x, char y, char w, char h, char gx, char gy, char ramBank); | ||
| + | </ | ||
| + | ==== draw_fade ==== | ||
| + | <code C> | ||
| + | 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 ==== | ||
| + | <code C> | ||
| + | void printnum(int num); | ||
| + | </ | ||
| + | ==== print_hex_num ==== | ||
| + | <code C> | ||
| + | void print_hex_num(char num); | ||
| + | </ | ||
| + | ==== print ==== | ||
| + | <code C> | ||
| + | void print(char* str); | ||
| + | </ | ||
