summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFranklin Wei <git@fwei.tk>2017-01-01 14:57:30 -0500
committerFranklin Wei <git@fwei.tk>2017-01-01 15:00:09 -0500
commit6e5f287606a3039ee26eb4fc8c8f7a05deebe9f0 (patch)
treea5bb5bc9ec91b2fd8630c082f362952393f71bdb
parent985f6e6935357b13a43b6c30f0f1e99786b185b0 (diff)
downloadrockbox-6e5f287606a3039ee26eb4fc8c8f7a05deebe9f0.tar.gz
rockbox-6e5f287606a3039ee26eb4fc8c8f7a05deebe9f0.zip
Fixes and re-sync for puzzles
- Updates to latest upstream (7cae89fb4b22c305b3fd98b4e1be065ad527a9f7). - Also fixes a bug relating to updating parts of the display. - Adds some docs. Change-Id: Idfcce66e0cf3c59e467bab42eafc161df2e495bb
-rw-r--r--apps/plugins/puzzles/README.rockbox21
-rw-r--r--apps/plugins/puzzles/cube.c1
-rw-r--r--apps/plugins/puzzles/gtk.c35
-rw-r--r--apps/plugins/puzzles/pearl.c2
-rw-r--r--apps/plugins/puzzles/puzzles.make1
-rw-r--r--apps/plugins/puzzles/rockbox.c80
-rw-r--r--apps/plugins/puzzles/signpost.c2
-rw-r--r--apps/plugins/puzzles/tracks.c2
-rw-r--r--apps/plugins/puzzles/unequal.c2
9 files changed, 115 insertions, 31 deletions
diff --git a/apps/plugins/puzzles/README.rockbox b/apps/plugins/puzzles/README.rockbox
new file mode 100644
index 0000000000..e11025dbec
--- /dev/null
+++ b/apps/plugins/puzzles/README.rockbox
@@ -0,0 +1,21 @@
1This is the readme for the Rockbox port of Simon Tatham's Portable
2Puzzle Collection.
3
4Upstream version used is 7cae89fb4b22c305b3fd98b4e1be065ad527a9f7 from
5December 2016. It should be relatively trivial to update it to a newer
6version, and should probably be done periodically as changes are made.
7
8Most of the upstream files are essentially untouched, apart from some
9minor adjustments to make it compile happily on Rockbox. Some games
10still don't work due to issues with their cursor-only control scheme
11(untangle being the big culprit here) but the ones that don't are
12commented out in SOURCES.games. I'll get around to fixing them
13eventually.
14
15Building is done rather hackily, with a rule for every puzzle to be
16built... almost 40 at the time of writing. Mr. Someone ought to figure
17out how to do that with a wildcard or something.
18
19Kudos to Simon (duh), and Frank, for telling me about it.
20
21Franklin Wei (__builtin)
diff --git a/apps/plugins/puzzles/cube.c b/apps/plugins/puzzles/cube.c
index 5a09648226..d0d9525130 100644
--- a/apps/plugins/puzzles/cube.c
+++ b/apps/plugins/puzzles/cube.c
@@ -361,7 +361,6 @@ static void enum_grid_squares(const game_params *params, egc_callback callback,
361 } else { 361 } else {
362 int row, rowlen, other, i, firstix = -1; 362 int row, rowlen, other, i, firstix = -1;
363 float theight = (float)(sqrt(3) / 2.0); 363 float theight = (float)(sqrt(3) / 2.0);
364 //float theight = 0.8660254037844386467;
365 364
366 for (row = 0; row < params->d1 + params->d2; row++) { 365 for (row = 0; row < params->d1 + params->d2; row++) {
367 if (row < params->d2) { 366 if (row < params->d2) {
diff --git a/apps/plugins/puzzles/gtk.c b/apps/plugins/puzzles/gtk.c
index aa3ba06eed..e132c3db58 100644
--- a/apps/plugins/puzzles/gtk.c
+++ b/apps/plugins/puzzles/gtk.c
@@ -1935,6 +1935,24 @@ static gint configure_window(GtkWidget *widget,
1935 return FALSE; 1935 return FALSE;
1936} 1936}
1937 1937
1938#if GTK_CHECK_VERSION(3,0,0)
1939static int window_extra_height(frontend *fe)
1940{
1941 int ret = 0;
1942 if (fe->menubar) {
1943 GtkRequisition req;
1944 gtk_widget_get_preferred_size(fe->menubar, &req, NULL);
1945 ret += req.height;
1946 }
1947 if (fe->statusbar) {
1948 GtkRequisition req;
1949 gtk_widget_get_preferred_size(fe->statusbar, &req, NULL);
1950 ret += req.height;
1951 }
1952 return ret;
1953}
1954#endif
1955
1938static void resize_fe(frontend *fe) 1956static void resize_fe(frontend *fe)
1939{ 1957{
1940 int x, y; 1958 int x, y;
@@ -1942,7 +1960,7 @@ static void resize_fe(frontend *fe)
1942 get_size(fe, &x, &y); 1960 get_size(fe, &x, &y);
1943 1961
1944#if GTK_CHECK_VERSION(3,0,0) 1962#if GTK_CHECK_VERSION(3,0,0)
1945 gtk_window_resize_to_geometry(GTK_WINDOW(fe->window), x, y); 1963 gtk_window_resize(GTK_WINDOW(fe->window), x, y + window_extra_height(fe));
1946#else 1964#else
1947 fe->drawing_area_shrink_pending = FALSE; 1965 fe->drawing_area_shrink_pending = FALSE;
1948 gtk_drawing_area_size(GTK_DRAWING_AREA(fe->area), x, y); 1966 gtk_drawing_area_size(GTK_DRAWING_AREA(fe->area), x, y);
@@ -1970,6 +1988,7 @@ static void menu_preset_event(GtkMenuItem *menuitem, gpointer data)
1970 midend_new_game(fe->me); 1988 midend_new_game(fe->me);
1971 changed_preset(fe); 1989 changed_preset(fe);
1972 resize_fe(fe); 1990 resize_fe(fe);
1991 midend_redraw(fe->me);
1973} 1992}
1974 1993
1975GdkAtom compound_text_atom, utf8_string_atom; 1994GdkAtom compound_text_atom, utf8_string_atom;
@@ -2213,6 +2232,7 @@ static void menu_load_event(GtkMenuItem *menuitem, gpointer data)
2213 2232
2214 changed_preset(fe); 2233 changed_preset(fe);
2215 resize_fe(fe); 2234 resize_fe(fe);
2235 midend_redraw(fe->me);
2216 } 2236 }
2217} 2237}
2218 2238
@@ -2250,6 +2270,7 @@ static void menu_config_event(GtkMenuItem *menuitem, gpointer data)
2250 2270
2251 midend_new_game(fe->me); 2271 midend_new_game(fe->me);
2252 resize_fe(fe); 2272 resize_fe(fe);
2273 midend_redraw(fe->me);
2253} 2274}
2254 2275
2255static void menu_about_event(GtkMenuItem *menuitem, gpointer data) 2276static void menu_about_event(GtkMenuItem *menuitem, gpointer data)
@@ -2648,15 +2669,23 @@ static frontend *new_window(char *arg, int argtype, char **error)
2648#endif 2669#endif
2649 { 2670 {
2650 GdkGeometry geom; 2671 GdkGeometry geom;
2651 geom.base_width = geom.base_height = 0; 2672 geom.base_width = 0;
2673#if GTK_CHECK_VERSION(3,0,0)
2674 geom.base_height = window_extra_height(fe);
2675 gtk_window_set_geometry_hints(GTK_WINDOW(fe->window), NULL,
2676 &geom, GDK_HINT_BASE_SIZE);
2677#else
2678 geom.base_height = 0;
2652 gtk_window_set_geometry_hints(GTK_WINDOW(fe->window), fe->area, 2679 gtk_window_set_geometry_hints(GTK_WINDOW(fe->window), fe->area,
2653 &geom, GDK_HINT_BASE_SIZE); 2680 &geom, GDK_HINT_BASE_SIZE);
2681#endif
2654 } 2682 }
2655 fe->w = -1; 2683 fe->w = -1;
2656 fe->h = -1; 2684 fe->h = -1;
2657 get_size(fe, &x, &y); 2685 get_size(fe, &x, &y);
2658#if GTK_CHECK_VERSION(3,0,0) 2686#if GTK_CHECK_VERSION(3,0,0)
2659 gtk_window_set_default_geometry(GTK_WINDOW(fe->window), x, y); 2687 gtk_window_set_default_size(GTK_WINDOW(fe->window),
2688 x, y + window_extra_height(fe));
2660#else 2689#else
2661 fe->drawing_area_shrink_pending = FALSE; 2690 fe->drawing_area_shrink_pending = FALSE;
2662 gtk_drawing_area_size(GTK_DRAWING_AREA(fe->area), x, y); 2691 gtk_drawing_area_size(GTK_DRAWING_AREA(fe->area), x, y);
diff --git a/apps/plugins/puzzles/pearl.c b/apps/plugins/puzzles/pearl.c
index 59effeda40..1f41f65af2 100644
--- a/apps/plugins/puzzles/pearl.c
+++ b/apps/plugins/puzzles/pearl.c
@@ -1610,8 +1610,6 @@ static void check_completion(game_state *state, int mark)
1610 */ 1610 */
1611 for (i = 0; i < w*h; i++) { 1611 for (i = 0; i < w*h; i++) {
1612 int comp = dsf_canonify(dsf, i); 1612 int comp = dsf_canonify(dsf, i);
1613 if (component_state[comp] == COMP_PATH)
1614 comp = -1; /* part of the 'all paths' quasi-component */
1615 if ((component_state[comp] == COMP_PATH && 1613 if ((component_state[comp] == COMP_PATH &&
1616 -1 != largest_comp) || 1614 -1 != largest_comp) ||
1617 (component_state[comp] == COMP_LOOP && 1615 (component_state[comp] == COMP_LOOP &&
diff --git a/apps/plugins/puzzles/puzzles.make b/apps/plugins/puzzles/puzzles.make
index 054e53eeb1..4e1f3a1001 100644
--- a/apps/plugins/puzzles/puzzles.make
+++ b/apps/plugins/puzzles/puzzles.make
@@ -42,6 +42,7 @@ PUZZLES_ROCKS := $(addprefix $(PUZZLES_OBJDIR)/sgt-, $(notdir $(PUZZLES_GAMES_SR
42ROCKS += $(PUZZLES_ROCKS) 42ROCKS += $(PUZZLES_ROCKS)
43endif 43endif
44 44
45# Hack to suppress all warnings:
45PUZZLESFLAGS = $(filter-out -O%,$(PLUGINFLAGS)) -Os \ 46PUZZLESFLAGS = $(filter-out -O%,$(PLUGINFLAGS)) -Os \
46 -Wno-unused-parameter -Wno-sign-compare -Wno-strict-aliasing -w \ 47 -Wno-unused-parameter -Wno-sign-compare -Wno-strict-aliasing -w \
47 -DFOR_REAL 48 -DFOR_REAL
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;
diff --git a/apps/plugins/puzzles/signpost.c b/apps/plugins/puzzles/signpost.c
index a2e431e746..ce27da1a9d 100644
--- a/apps/plugins/puzzles/signpost.c
+++ b/apps/plugins/puzzles/signpost.c
@@ -284,7 +284,7 @@ static int check_nums(game_state *orig, game_state *copy, int only_immutable)
284 int i, ret = 1; 284 int i, ret = 1;
285 assert(copy->n == orig->n); 285 assert(copy->n == orig->n);
286 for (i = 0; i < copy->n; i++) { 286 for (i = 0; i < copy->n; i++) {
287 if (only_immutable && !copy->flags[i] & FLAG_IMMUTABLE) continue; 287 if (only_immutable && !(copy->flags[i] & FLAG_IMMUTABLE)) continue;
288 assert(copy->nums[i] >= 0); 288 assert(copy->nums[i] >= 0);
289 assert(copy->nums[i] <= copy->n); 289 assert(copy->nums[i] <= copy->n);
290 if (copy->nums[i] != orig->nums[i]) { 290 if (copy->nums[i] != orig->nums[i]) {
diff --git a/apps/plugins/puzzles/tracks.c b/apps/plugins/puzzles/tracks.c
index dd00e32b9a..3dfbf62d6a 100644
--- a/apps/plugins/puzzles/tracks.c
+++ b/apps/plugins/puzzles/tracks.c
@@ -1072,7 +1072,7 @@ static int solve_check_single_sub(game_state *state, int si, int id, int n,
1072 x = i%w; 1072 x = i%w;
1073 y = i/w; 1073 y = i/w;
1074 if (abs(ox-x) > 1 || abs(oy-y) > 1) { 1074 if (abs(ox-x) > 1 || abs(oy-y) > 1) {
1075 if (!state->sflags[i] & S_TRACK) 1075 if (!(state->sflags[i] & S_TRACK))
1076 did += solve_set_sflag(state, x, y, S_NOTRACK, what); 1076 did += solve_set_sflag(state, x, y, S_NOTRACK, what);
1077 } 1077 }
1078 } 1078 }
diff --git a/apps/plugins/puzzles/unequal.c b/apps/plugins/puzzles/unequal.c
index 457965b4ff..1293de28e8 100644
--- a/apps/plugins/puzzles/unequal.c
+++ b/apps/plugins/puzzles/unequal.c
@@ -1214,7 +1214,7 @@ static game_state *load_game(const game_params *params, const char *desc,
1214 why = "Too much data to fill grid"; goto fail; 1214 why = "Too much data to fill grid"; goto fail;
1215 } 1215 }
1216 1216
1217 if (*p < '0' && *p > '9') { 1217 if (*p < '0' || *p > '9') {
1218 why = "Expecting number in game description"; goto fail; 1218 why = "Expecting number in game description"; goto fail;
1219 } 1219 }
1220 n = atoi(p); 1220 n = atoi(p);