Skip to content

Commit 6748895

Browse files
committed
rg_display: Clarified a few things in the new OSD drawing
1 parent 32765d2 commit 6748895

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
- Launcher: Diacritics now display correctly in filenames
44
- GEN/MD: Improved performance
55
- SNES: Improved performance
6+
- All: On-screen low battery indicator
67
- All: German translations added
78
- New device support: ESP32-P4 on a breadboard
89

components/retro-go/rg_display.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,36 +44,36 @@ static inline void lcd_send_buffer(uint16_t *buffer, size_t length);
4444
#include "drivers/display/dummy.h"
4545
#endif
4646

47-
static inline bool draw_on_screen_display(int y1, int y2)
47+
static int draw_on_screen_display(int region_start, int region_end)
4848
{
49-
static unsigned area_dirty = 0;
49+
static unsigned int area_dirty = 0;
5050
rg_margins_t margins = rg_gui_get_safe_area();
5151
int left = display.screen.width - margins.right - 28;
5252
int top = margins.top + 4;
5353
int border = 3;
5454
int width = 20;
5555
int height = 14;
5656

57-
// Check if the region contains OSD to draw
58-
if (y2 < top || y1 > top + height)
59-
return false;
57+
if (region_end < top + height)
58+
return top + height;
6059

6160
// Low battery indicator
6261
if (rg_system_get_indicator(RG_INDICATOR_POWER_LOW) && ((counters.totalFrames / 20) & 1))
6362
{
6463
rg_display_clear_rect(left, top, width, height, C_RED); // Main body
6564
rg_display_clear_rect(left + width, top + height / 4, border, height / 2, C_RED); // The tab
6665
rg_display_clear_rect(left + border, top + border, width - border * 2, height - border * 2, C_BLACK); // The fill
67-
area_dirty |= 1 << RG_INDICATOR_POWER_LOW;
66+
// memset(&screen_line_checksum[top], 0, sizeof(uint32_t) * height);
67+
area_dirty |= (1 << RG_INDICATOR_POWER_LOW);
6868
}
6969
else if (area_dirty)
7070
{
71-
if (display.viewport.left || display.viewport.top)
71+
if (display.viewport.width < display.screen.width || display.viewport.height < display.screen.height)
7272
rg_display_clear_rect(left, top, width + border, height, C_BLACK);
7373
memset(&screen_line_checksum[top], 0, sizeof(uint32_t) * height);
7474
area_dirty = 0;
7575
}
76-
return true;
76+
return 0;
7777
}
7878

7979
static inline unsigned blend_pixels(unsigned a, unsigned b)
@@ -133,7 +133,7 @@ static inline void write_update(const rg_surface_t *update)
133133
int lines_remaining = draw_height;
134134
int lines_updated = 0;
135135
int window_top = -1;
136-
int osd_threshold = 24;
136+
int osd_next_call = 20;
137137

138138
for (int y = 0; y < draw_height;)
139139
{
@@ -243,10 +243,10 @@ static inline void write_update(const rg_surface_t *update)
243243
lcd_send_buffer(line_buffer, 0);
244244
}
245245

246-
// if (draw_on_screen_display(draw_top + y - lines_to_copy, draw_top + y))
247-
if (draw_top + y > osd_threshold && draw_on_screen_display(0, draw_top + y))
246+
// Drawing the OSD as we progress reduces flicker compared to doing it once at the end
247+
if (osd_next_call && draw_top + y >= osd_next_call)
248248
{
249-
osd_threshold = 9999;
249+
osd_next_call = draw_on_screen_display(0, draw_top + y);
250250
window_top = -1;
251251
}
252252

0 commit comments

Comments
 (0)