Skip to content

Commit

Permalink
rg_display: Added a way for targets to disable partial updates
Browse files Browse the repository at this point in the history
Defining `RG_SCREEN_PARTIAL_UPDATES` to `0`/`false` will disable partial updates.
  • Loading branch information
ducalex committed Sep 3, 2024
1 parent da9c8bf commit 5f0e9e8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions components/retro-go/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,7 @@
#else
#define RG_ZIP_SUPPORT 0
#endif

#ifndef RG_SCREEN_PARTIAL_UPDATES
#define RG_SCREEN_PARTIAL_UPDATES 1
#endif
7 changes: 4 additions & 3 deletions components/retro-go/rg_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,12 @@ static inline void write_update(const rg_surface_t *update)
const void *data = update->data + update->offset + (crop_top * stride) + (crop_left * RG_PIXEL_GET_SIZE(format));
const uint16_t *palette = update->palette;

const bool partial_update = RG_SCREEN_PARTIAL_UPDATES;

int lines_per_buffer = LCD_BUFFER_LENGTH / draw_width;
int lines_remaining = draw_height;
int lines_updated = 0;
int window_top = -1;
bool partial = true;

for (int y = 0; y < draw_height;)
{
Expand All @@ -112,7 +113,7 @@ static inline void write_update(const rg_surface_t *update)
uint16_t *line_buffer_ptr = line_buffer;

uint32_t checksum = 0xFFFFFFFF;
bool need_update = !partial;
bool need_update = !partial_update;

for (int i = 0; i < lines_to_copy; ++i)
{
Expand All @@ -137,7 +138,7 @@ static inline void write_update(const rg_surface_t *update)
else
RENDER_LINE(uint16_t, buffer[x])

if (partial)
if (partial_update)
{
checksum = rg_hash((void*)(line_buffer_ptr - draw_width), draw_width * 2);
}
Expand Down

0 comments on commit 5f0e9e8

Please sign in to comment.