From eb20ed46486594681a1aeb3642ecd093479e90be Mon Sep 17 00:00:00 2001 From: Charlie Birks Date: Mon, 12 Aug 2024 19:47:49 +0100 Subject: [PATCH] Support double-buffered hires, enable by default on RP2350 --- 32blit-pico/config.h | 8 ++++++++ 32blit-pico/display.cpp | 12 +++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/32blit-pico/config.h b/32blit-pico/config.h index 67a6d26da..a7ba2d7fb 100644 --- a/32blit-pico/config.h +++ b/32blit-pico/config.h @@ -10,6 +10,14 @@ #define ALLOW_HIRES 1 #endif +#ifndef DOUBLE_BUFFERED_HIRES +#ifdef PICO_RP2350 +#define DOUBLE_BUFFERED_HIRES 1 +#else +#define DOUBLE_BUFFERED_HIRES 0 +#endif +#endif + #ifndef BUTTON_LEFT_PIN #define BUTTON_LEFT_PIN -1 #define BUTTON_LEFT_BI_DECL diff --git a/32blit-pico/display.cpp b/32blit-pico/display.cpp index 8f72ac20b..fafd4570e 100644 --- a/32blit-pico/display.cpp +++ b/32blit-pico/display.cpp @@ -8,16 +8,22 @@ using namespace blit; // this is in bytes static const int lores_page_size = (DISPLAY_WIDTH / 2) * ((DISPLAY_HEIGHT + 1) / 2) * 2; +#if ALLOW_HIRES && DOUBLE_BUFFERED_HIRES +static const int fb_size = DISPLAY_WIDTH * DISPLAY_HEIGHT * 2; +#elif ALLOW_HIRES +static const int fb_size = DISPLAY_WIDTH * DISPLAY_HEIGHT; +#else +static const int fb_size = lores_page_size; // double-buffered +#endif + SurfaceInfo cur_surf_info; bool fb_double_buffer = true; #if defined(BLIT_BOARD_PIMORONI_PICOVISION) static const uint16_t *screen_fb = nullptr; -#elif ALLOW_HIRES -uint16_t screen_fb[DISPLAY_WIDTH * DISPLAY_HEIGHT]; #else -uint16_t screen_fb[lores_page_size]; // double-buffered +uint16_t screen_fb[fb_size]; #endif static const Size lores_screen_size(DISPLAY_WIDTH / 2, DISPLAY_HEIGHT / 2);