summaryrefslogtreecommitdiff
path: root/apps/plugins/puzzles/rockbox.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/puzzles/rockbox.c')
-rw-r--r--apps/plugins/puzzles/rockbox.c80
1 files changed, 58 insertions, 22 deletions
diff --git a/apps/plugins/puzzles/rockbox.c b/apps/plugins/puzzles/rockbox.c
index 3a1c00e615..aac2781c5d 100644
--- a/apps/plugins/puzzles/rockbox.c
+++ b/apps/plugins/puzzles/rockbox.c
@@ -7,7 +7,7 @@
7 * \/ \/ \/ \/ \/ 7 * \/ \/ \/ \/ \/
8 * $Id$ 8 * $Id$
9 * 9 *
10 * Copyright (C) 2016 Franklin Wei 10 * Copyright (C) 2017 Franklin Wei
11 * 11 *
12 * This program is free software; you can redistribute it and/or 12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License 13 * modify it under the terms of the GNU General Public License
@@ -62,36 +62,34 @@ static long last_keystate = 0;
62 62
63static void fix_size(void); 63static void fix_size(void);
64 64
65static void rb_start_draw(void *handle)
66{
67 (void) handle;
68}
69
70static struct viewport clip_rect; 65static struct viewport clip_rect;
71static bool clipped = false; 66static bool clipped = false;
72 67
73static struct settings_t { 68static struct settings_t {
74 int slowmo_factor; 69 int slowmo_factor;
75 bool bulk, timerflash; 70 bool bulk, timerflash, clipoff;
76} settings; 71} settings;
77 72
78/* clipping is implemented through viewports and offsetting 73/* clipping is implemented through viewports and offsetting
79 * coordinates */ 74 * coordinates */
80static void rb_clip(void *handle, int x, int y, int w, int h) 75static void rb_clip(void *handle, int x, int y, int w, int h)
81{ 76{
82 LOGF("rb_clip(%d %d %d %d)", x, y, w, h); 77 if(!settings.clipoff)
83 clip_rect.x = x; 78 {
84 clip_rect.y = y; 79 LOGF("rb_clip(%d %d %d %d)", x, y, w, h);
85 clip_rect.width = w; 80 clip_rect.x = x;
86 clip_rect.height = h; 81 clip_rect.y = y;
87 clip_rect.font = FONT_UI; 82 clip_rect.width = w;
88 clip_rect.drawmode = DRMODE_SOLID; 83 clip_rect.height = h;
84 clip_rect.font = FONT_UI;
85 clip_rect.drawmode = DRMODE_SOLID;
89#if LCD_DEPTH > 1 86#if LCD_DEPTH > 1
90 clip_rect.fg_pattern = LCD_DEFAULT_FG; 87 clip_rect.fg_pattern = LCD_DEFAULT_FG;
91 clip_rect.bg_pattern = LCD_DEFAULT_BG; 88 clip_rect.bg_pattern = LCD_DEFAULT_BG;
92#endif 89#endif
93 rb->lcd_set_viewport(&clip_rect); 90 rb->lcd_set_viewport(&clip_rect);
94 clipped = true; 91 clipped = true;
92 }
95} 93}
96 94
97static void rb_unclip(void *handle) 95static void rb_unclip(void *handle)
@@ -407,6 +405,7 @@ static void rb_blitter_free(void *handle, blitter *bl)
407 return; 405 return;
408} 406}
409 407
408/* originally from emcc.c */
410static void trim_rect(int *x, int *y, int *w, int *h) 409static void trim_rect(int *x, int *y, int *w, int *h)
411{ 410{
412 int x0, x1, y0, y1; 411 int x0, x1, y0, y1;
@@ -476,18 +475,51 @@ static void rb_blitter_load(void *handle, blitter *bl, int x, int y)
476 rb->lcd_bitmap((fb_data*)bl->bmp.data, x, y, w, h); 475 rb->lcd_bitmap((fb_data*)bl->bmp.data, x, y, w, h);
477} 476}
478 477
478static bool need_draw_update = false;
479
480static int ud_l = 0, ud_u = 0, ud_r = LCD_WIDTH, ud_d = LCD_HEIGHT;
481
479static void rb_draw_update(void *handle, int x, int y, int w, int h) 482static void rb_draw_update(void *handle, int x, int y, int w, int h)
480{ 483{
481 LOGF("rb_draw_update(%d, %d, %d, %d)", x, y, w, h); 484 LOGF("rb_draw_update(%d, %d, %d, %d)", x, y, w, h);
482 if(!settings.bulk) 485
483 rb->lcd_update_rect(x, y, w, h); 486 /* It seems that the puzzles use a different definition of
484 else 487 * "updating" the display than Rockbox does; by calling this
485 rb->lcd_update(); 488 * function, it tells us that it has either already drawn to the
489 * updated area (as rockbox assumes), or that it WILL draw to the
490 * said area. Thus we simply remember a rectangle that contains
491 * all the updated regions and update it at the very end. */
492
493 /* adapted from gtk.c */
494 if (!need_draw_update || ud_l > x ) ud_l = x;
495 if (!need_draw_update || ud_r < x+w) ud_r = x+w;
496 if (!need_draw_update || ud_u > y ) ud_u = y;
497 if (!need_draw_update || ud_d < y+h) ud_d = y+h;
498
499 need_draw_update = true;
500}
501
502static void rb_start_draw(void *handle)
503{
504 (void) handle;
505
506 /* ... mumble mumble ... not ... reentrant ... mumble mumble ... */
507
508 need_draw_update = false;
509 ud_l = 0;
510 ud_r = LCD_WIDTH;
511 ud_u = 0;
512 ud_d = LCD_HEIGHT;
486} 513}
487 514
488static void rb_end_draw(void *handle) 515static void rb_end_draw(void *handle)
489{ 516{
517 (void) handle;
518
490 LOGF("rb_end_draw"); 519 LOGF("rb_end_draw");
520
521 if(need_draw_update)
522 rb->lcd_update_rect(ud_l, ud_u, ud_r - ud_l, ud_d - ud_u);
491} 523}
492 524
493static char *titlebar = NULL; 525static char *titlebar = NULL;
@@ -893,6 +925,7 @@ static void debug_menu(void)
893 "Randomize colors", 925 "Randomize colors",
894 "Toggle bulk update", 926 "Toggle bulk update",
895 "Toggle flash pixel on timer", 927 "Toggle flash pixel on timer",
928 "Toggle clip",
896 "Back"); 929 "Back");
897 bool quit = false; 930 bool quit = false;
898 int sel = 0; 931 int sel = 0;
@@ -920,6 +953,9 @@ static void debug_menu(void)
920 settings.timerflash = !settings.timerflash; 953 settings.timerflash = !settings.timerflash;
921 break; 954 break;
922 case 4: 955 case 4:
956 settings.clipoff = !settings.clipoff;
957 break;
958 case 5:
923 default: 959 default:
924 quit = true; 960 quit = true;
925 break; 961 break;