Table of Contents

draw_queued.h

draw_queued.h provides a queued drawing API, so that draw operations can be set even while a previous draw is still running. The queue is interrupt-driven, meaning that the interrupt handler will check the queue and start the next draw operation if there is one in the list.

The programmer may switch between using Queued and Direct drawing methods at runtime, but care must be taken to transition between the modes so they don't interfere with each other in unpredictable ways.

Namely, await_drawing() should be used when changing from Direct to Queued drawing; and await_draw_queue() should be used before switching back to Direct drawing.

Drawing Example

//Draw a red box next to a green box
queue_draw_box(23, 32, 16, 16, 29);
queue_draw_box(39, 32, 16, 16, 124);
 
//do other stuff while drawing is happening
 
//wait for it to finish before flipping the frame
await_draw_queue();
await_vsync();
flip_pages();

Functions

queue_draw_box

void queue_draw_box(unsigned char x, unsigned char y, unsigned char w, unsigned char h, unsigned char c);

Subimit a box with the top corner at X,Y with size WxH and color C to the draw queue

queue_draw_sprite_rect

void queue_draw_sprite_rect();

Submits the temp variable “rect” to the draw queue. See macro “queue_draw_sprite” below.

queue_draw_sprite_frame

void queue_draw_sprite_frame(SpriteSlot sprite, char x, char y, char frame, char flip);

Draws a packed sprite as exported from Aseprite with a given X,Y position and frame number. Uses a SpriteSlot handle given by allocate_sprite from “sprites.h”.

queue_clear_border

void queue_clear_border(char c);

Draws a border around the screen with the provided color by submitting four queued box draws.

queue_clear_screen

void queue_clear_screen(char c);

Draws a full screen box with the given color.

await_draw_queue

void await_draw_queue();

Wait for all draw operations in the queue to finish.

Macros

queue_draw_sprite

#define queue_draw_sprite(X,Y,W,H,GX,GY,SPRITESLOT)

Set the parameters of the temp variable “rect” and submit a queued rectangle draw. Made a macro because a seven-argument function call would incur slow stack reads.