244 bool showInfo =
true;
245 bool showLogo =
true;
249 float encodedTime = 0.0f;
254 bool successfulSave =
false;
255 surface_t lastSavedFrame = surface_alloc(FMT_RGBA16, 320, 240);
257 uint32_t bytesWritten = 0;
260 sprite_t* background, *logo;
277 dfs_init(DFS_DEFAULT_LOCATION);
279 display_init(RESOLUTION_320x240, DEPTH_16_BPP, 2, GAMMA_NONE, FILTERS_RESAMPLE);
283 font = rdpq_font_load_builtin(FONT_BUILTIN_DEBUG_MONO);
284 rdpq_text_register_font(1, font);
286 logo = sprite_load(
"rom:/n64brew.sprite");
287 background = sprite_load(
"rom:/pm5544.sprite");
288 start = timer_ticks(), end = timer_ticks();
290 sdCardExists = debug_init_sdfs(
"sd:/", -1);
296 joypad_port_t port = JOYPAD_PORT_1;
297 joypad_buttons_t pressed, held;
301 pressed = joypad_get_buttons_pressed(port);
302 held = joypad_get_buttons_held(port);
305 delta = TIMER_MICROS(end - start) / 1000.0f;
308 while(!(disp = display_try_get())) {;}
315 if (y < 240.0f - (logo->height * 0.5f)) {
332 if (x < 320.0f - (logo->width * 0.5f)) {
350 rdpq_attach(disp, NULL);
352 rdpq_set_mode_copy(
true);
353 rdpq_sprite_blit(background, 0, 0, NULL);
356 rdpq_set_mode_copy(
true);
357 rdpq_sprite_blit(logo, (
int)x, (
int)y, &( rdpq_blitparms_t ) {
364 rdpq_set_mode_standard();
369 rdpq_text_printf(&(rdpq_textparms_t) {
373 }, 1, 32, 32,
"Encoded in %.8f ms\nBytes written: %lu bytes", encodedTime, bytesWritten);
375 rdpq_text_printf(&(rdpq_textparms_t) {
388 rdpq_text_printf(&(rdpq_textparms_t) {
392 }, 1, 32, 72,
"Save successful: %s", successfulSave ?
"Yes" :
"No");
394 rdpq_text_printf(&(rdpq_textparms_t) {
398 }, 1, 32, 200,
"Version: %s\nRevision date: %s",
407 if (pressed.d_down) {
414 rdpq_attach(&lastSavedFrame, NULL);
415 rdpq_set_mode_copy(
false);
416 rdpq_tex_blit(disp, 0, 0, NULL);
422 successfulSave =
true;
429 rdpq_set_mode_copy(
true);
430 rdpq_tex_blit(&lastSavedFrame, 0, 0, NULL);
440 successfulSave =
false;
445 surface_t img = surface_alloc(FMT_RGBA16, 320, 240);
447 float startEncode, endEncode;
450 rdpq_attach(&img, NULL);
451 rdpq_set_mode_copy(
false);
452 rdpq_tex_blit(disp, 0, 0, NULL);
455 startEncode = timer_ticks();
461 endEncode = timer_ticks();
467 encodedTime = TIMER_MICROS(endEncode - startEncode) / 1000.0f;
478 else if (pressed.a) {
486 successfulSave =
false;
491 surface_t img = surface_alloc(FMT_RGBA16, 320, 240);
493 float startEncode, endEncode;
496 rdpq_attach(&img, NULL);
497 rdpq_set_mode_copy(
false);
498 rdpq_tex_blit(disp, 0, 0, NULL);
501 startEncode = timer_ticks();
504 successfulSave =
save_screenshot(&img,
"sd:/screenshot.qoi", &bytesWritten);
507 endEncode = timer_ticks();
513 encodedTime = TIMER_MICROS(endEncode - startEncode) / 1000.0f;
522 else if (pressed.d_up) {
523 surface_t img = surface_alloc(FMT_RGBA16, 320, 240);
525 float startEncode, endEncode;
528 rdpq_attach(&img, NULL);
529 rdpq_set_mode_copy(
false);
530 rdpq_tex_blit(disp, 0, 0, NULL);
533 startEncode = timer_ticks();
536 endEncode = timer_ticks();
543 encodedTime = TIMER_MICROS(endEncode - startEncode) / 1000.0f;
int main(void)
Entry point for this N64 ROM.
bool save_screenshot_null(surface_t *disp, uint32_t *bytesWritten)
Saves the screenshot to null, which is used for testing the performance of the encoder without the bo...
bool save_screenshot_raw(surface_t *disp, const char *filename, uint32_t *bytesWritten)
Saves the raw screenshot to the SD card if it somehow exists.
#define ENC_BUFFER_SIZE
Small buffer size for encoder because of memory constrant of 4MB for N64 without the 4MB Expansion Pa...
whichScreenshotType
Checks what type of screenshot was taken to perform different actions based on the type of screenshot...
@ SCREENSHOT_TYPE_RAW
The screenshot was saved as a raw file, which is used for testing the performance of writing to the S...
@ SCREENSHOT_TYPE_NULL
The screenshot was saved to null, which is used for testing the performance of the encoder without th...
@ SCREENSHOT_NO_SD_CARD
The screenshot was not saved because the SD card doesn't exist, which is used for testing the perform...
@ SCREENSHOT_NEVER_TAKEN
No screenshot has been taken yet.
@ SCREENSHOT_TYPE_QOI
The screenshot was saved as a QOI file, which is the main functionality of this project.
@ SCREENSHOT_FRAME_CAPTURED
The screenshot was captured into a buffer but not saved, which is used for testing the performance of...
bool save_screenshot(surface_t *disp, const char *filename, uint32_t *bytesWritten)
Saves the screenshot to the SD card if it somehow exists.