48#define POOL_IMG_SIZE 15
51#define MAX_STRING_SIZE MAX_FILENAME_LEN + 1
64 return joypad_get_inputs(port);
91 strncpy(sbuf,
"rom:/", 6);
92 if (dfs_dir_findfirst(
".", sbuf+5) == FLAGS_FILE) {
100 assert(new_node != NULL);
102 new_node->
prev = node;
103 new_node->
next = start_node;
117 }
while (dfs_dir_findnext(sbuf+5) == FLAGS_FILE);
120 assert(
"No files found in ROM.");
125static inline void init_program() {
129 console_set_debug(
true);
134 dfs_init(DFS_DEFAULT_LOCATION);
150 rdpq_set_mode_standard();
158 printf(
"QOI Image Viewer\n");
160 printf(
"Revision Date: %s\n", QOI_DEC_REVISION_DATE);
163 "Decoded %s in %f ms!\n",
169 "First pixel of %s: %i %i %i %i\n",
183 int index = 0, prev_index = 0;
231 font = rdpq_font_load_builtin(FONT_BUILTIN_DEBUG_MONO);
232 rdpq_text_register_font(1, font);
239 while(!(disp = display_try_get())) {;}
240 joypad_port_t port = JOYPAD_PORT_1;
243 joypad_buttons_t pressed = joypad_get_buttons_pressed(port);
246 if (pressed.start || pressed.z) {
256 joypad_get_axis_pressed(port, JOYPAD_AXIS_STICK_X) == -1
273 joypad_get_axis_pressed(port, JOYPAD_AXIS_STICK_X) == 1
283 if (prev_index != index) {
#define MAX_STRING_SIZE
Maximum length of a string. File names are limited by libdragon to 243 characters.
#define POOL_IMG_SIZE
How many names can fit in a block.
void readNames(name_node_pool_t *start_node)
Reads the names of QOI images from ROM.
void start_viewer()
This function starts QOI viewer to display first QOI image decoded.
uint8_t buffer1[IMG_BUFFER_SIZE]
second raw image buffer that decoded from qoi image file
int main(void)
This function is the entry point for QOI Viewer.
void printFirstDecodedValues(qoi_img_info_t *info)
Prints the first values of the pixel decoded by the QOI Decoder.
joypad_inputs_t joypad_poll_port(joypad_port_t port)
Poll controller and get input from a specific port.
uint8_t buffer0[IMG_BUFFER_SIZE]
Raw image buffer that decoded from qoi image file.
void draw_image(surface_t *disp, qoi_img_info_t info)
This function draws image decoded from QOI.
void openQOIFile(const char *filename, uint8_t *bytes, qoi_img_info_t *info)
This function decodes QOI file from from into the framebuffer.
This header contains declaration of functions related to QOI viewer.
void toggleDebugText(qoi_img_info_t *info)
Toggles printing debugging text.
@ QOI_NOT_INITIALIZED
QOI Image not yet decoded.
@ QOI_OK
QOI Image decoded successfully.
struct qoi_img_info qoi_img_info_t
Metadata about the QOI image and the QOI image viewer.
#define IMG_BUFFER_SIZE
Image buffer size: 320 pixels in width * 240 pixels in height * 4 channels.
A container for holding a bunch of names.
name_node_pool_t * prev
A pointer to the previous block of names.
int num_images
Number of images occupied in the block. 32 bit integer for word alignment purposes.
name_node_pool_t * next
A pointer to the next block of names.
char name[POOL_IMG_SIZE][MAX_STRING_SIZE]
A list of names in a block.
char name[256]
Names of QOI file.
float decodeTime
Decoding time in seconds.
bool renderDebugFont
Whether to toggle displaying debug text upon pressing the Start button on the N64 controller.
qoi_error_code error
Error code as the result of decoding.