diff options
Diffstat (limited to 'apps/plugins')
-rw-r--r-- | apps/plugins/puzzles/README.rockbox | 3 | ||||
-rw-r--r-- | apps/plugins/puzzles/puzzles.make | 2 | ||||
-rw-r--r-- | apps/plugins/puzzles/rockbox.c | 69 |
3 files changed, 41 insertions, 33 deletions
diff --git a/apps/plugins/puzzles/README.rockbox b/apps/plugins/puzzles/README.rockbox index c69c4da50d..3adce72412 100644 --- a/apps/plugins/puzzles/README.rockbox +++ b/apps/plugins/puzzles/README.rockbox | |||
@@ -17,6 +17,9 @@ from some minor adjustments to make them compile and run happily on | |||
17 | Rockbox. The majority of the rockbox-specific code is found in | 17 | Rockbox. The majority of the rockbox-specific code is found in |
18 | rockbox.c, with some minor stuff in rbwrappers.c and rbmalloc.c. | 18 | rockbox.c, with some minor stuff in rbwrappers.c and rbmalloc.c. |
19 | 19 | ||
20 | NOTE: the build makefile (puzzles.make) automatically includes | ||
21 | `rbcompat.h` when compiling! Check there when things break. | ||
22 | |||
20 | Help feature | 23 | Help feature |
21 | ============ | 24 | ============ |
22 | 25 | ||
diff --git a/apps/plugins/puzzles/puzzles.make b/apps/plugins/puzzles/puzzles.make index 45f591d544..b3f929ded4 100644 --- a/apps/plugins/puzzles/puzzles.make +++ b/apps/plugins/puzzles/puzzles.make | |||
@@ -40,7 +40,7 @@ PUZZLESFLAGS = -I$(PUZZLES_SRCDIR)/dummy $(filter-out \ | |||
40 | -Wno-strict-aliasing -DFOR_REAL \ | 40 | -Wno-strict-aliasing -DFOR_REAL \ |
41 | -I$(PUZZLES_SRCDIR)/src -I$(PUZZLES_SRCDIR) -include \ | 41 | -I$(PUZZLES_SRCDIR)/src -I$(PUZZLES_SRCDIR) -include \ |
42 | $(PUZZLES_SRCDIR)/rbcompat.h -ffunction-sections \ | 42 | $(PUZZLES_SRCDIR)/rbcompat.h -ffunction-sections \ |
43 | -fdata-sections -w | 43 | -fdata-sections -w -Wl,--gc-sections |
44 | 44 | ||
45 | $(PUZZLES_OBJDIR)/sgt-%.rock: $(PUZZLES_OBJDIR)/src/%.o $(PUZZLES_OBJDIR)/help/%.o $(PUZZLES_SHARED_OBJ) $(TLSFLIB) | 45 | $(PUZZLES_OBJDIR)/sgt-%.rock: $(PUZZLES_OBJDIR)/src/%.o $(PUZZLES_OBJDIR)/help/%.o $(PUZZLES_SHARED_OBJ) $(TLSFLIB) |
46 | $(call PRINTS,LD $(@F))$(CC) $(PLUGINFLAGS) -o $(PUZZLES_OBJDIR)/$*.elf \ | 46 | $(call PRINTS,LD $(@F))$(CC) $(PLUGINFLAGS) -o $(PUZZLES_OBJDIR)/$*.elf \ |
diff --git a/apps/plugins/puzzles/rockbox.c b/apps/plugins/puzzles/rockbox.c index 8a25038255..ddcad4fa59 100644 --- a/apps/plugins/puzzles/rockbox.c +++ b/apps/plugins/puzzles/rockbox.c | |||
@@ -1915,7 +1915,7 @@ static void zoom(void) | |||
1915 | zoom_fb = smalloc(zoom_w * zoom_h * sizeof(fb_data)); | 1915 | zoom_fb = smalloc(zoom_w * zoom_h * sizeof(fb_data)); |
1916 | if(!zoom_fb) | 1916 | if(!zoom_fb) |
1917 | { | 1917 | { |
1918 | rb->splash(HZ, "OOM"); | 1918 | rb->splash(HZ, "Out of memory. Cannot zoom in."); |
1919 | return; | 1919 | return; |
1920 | } | 1920 | } |
1921 | 1921 | ||
@@ -2412,6 +2412,8 @@ static int do_preset_menu(struct preset_menu *menu, char *title, int selected) | |||
2412 | } | 2412 | } |
2413 | } | 2413 | } |
2414 | 2414 | ||
2415 | /* Let user choose from game presets. Returns true if the user chooses | ||
2416 | * one (in which case the caller should start a new game. */ | ||
2415 | static bool presets_menu(void) | 2417 | static bool presets_menu(void) |
2416 | { | 2418 | { |
2417 | /* figure out the index of the current preset | 2419 | /* figure out the index of the current preset |
@@ -2692,6 +2694,17 @@ static void reset_drawing(void) | |||
2692 | rb->lcd_set_background(BG_COLOR); | 2694 | rb->lcd_set_background(BG_COLOR); |
2693 | } | 2695 | } |
2694 | 2696 | ||
2697 | /* Make a new game, but tell the user through a splash so they don't | ||
2698 | * think we're locked up. Also performs new-game initialization | ||
2699 | * specific to Rockbox. */ | ||
2700 | static void new_game_notify(void) | ||
2701 | { | ||
2702 | rb->splash(0, "Please wait..."); | ||
2703 | midend_new_game(me); | ||
2704 | fix_size(); | ||
2705 | rb->lcd_update(); | ||
2706 | } | ||
2707 | |||
2695 | static int pause_menu(void) | 2708 | static int pause_menu(void) |
2696 | { | 2709 | { |
2697 | #define static auto | 2710 | #define static auto |
@@ -2733,8 +2746,7 @@ static int pause_menu(void) | |||
2733 | quit = true; | 2746 | quit = true; |
2734 | break; | 2747 | break; |
2735 | case 1: | 2748 | case 1: |
2736 | midend_new_game(me); | 2749 | new_game_notify(); |
2737 | fix_size(); | ||
2738 | quit = true; | 2750 | quit = true; |
2739 | break; | 2751 | break; |
2740 | case 2: | 2752 | case 2: |
@@ -2779,8 +2791,7 @@ static int pause_menu(void) | |||
2779 | case 10: | 2791 | case 10: |
2780 | if(presets_menu()) | 2792 | if(presets_menu()) |
2781 | { | 2793 | { |
2782 | midend_new_game(me); | 2794 | new_game_notify(); |
2783 | fix_size(); | ||
2784 | reset_drawing(); | 2795 | reset_drawing(); |
2785 | clear_and_draw(); | 2796 | clear_and_draw(); |
2786 | quit = true; | 2797 | quit = true; |
@@ -2794,8 +2805,7 @@ static int pause_menu(void) | |||
2794 | case 12: | 2805 | case 12: |
2795 | if(config_menu()) | 2806 | if(config_menu()) |
2796 | { | 2807 | { |
2797 | midend_new_game(me); | 2808 | new_game_notify(); |
2798 | fix_size(); | ||
2799 | reset_drawing(); | 2809 | reset_drawing(); |
2800 | clear_and_draw(); | 2810 | clear_and_draw(); |
2801 | quit = true; | 2811 | quit = true; |
@@ -2948,12 +2958,14 @@ static void tune_input(const char *name) | |||
2948 | input_settings.numerical_chooser = string_in_list(name, number_chooser_games); | 2958 | input_settings.numerical_chooser = string_in_list(name, number_chooser_games); |
2949 | } | 2959 | } |
2950 | 2960 | ||
2951 | static const char *init_for_game(const game *gm, int load_fd, bool draw) | 2961 | static const char *init_for_game(const game *gm, int load_fd) |
2952 | { | 2962 | { |
2953 | me = midend_new(NULL, gm, &rb_drawing, NULL); | 2963 | me = midend_new(NULL, gm, &rb_drawing, NULL); |
2954 | 2964 | ||
2955 | if(load_fd < 0) | 2965 | if(load_fd < 0) |
2956 | midend_new_game(me); | 2966 | { |
2967 | new_game_notify(); | ||
2968 | } | ||
2957 | else | 2969 | else |
2958 | { | 2970 | { |
2959 | const char *ret = midend_deserialize(me, read_wrapper, (void*) load_fd); | 2971 | const char *ret = midend_deserialize(me, read_wrapper, (void*) load_fd); |
@@ -2966,17 +2978,10 @@ static const char *init_for_game(const game *gm, int load_fd, bool draw) | |||
2966 | mouse_x = LCD_WIDTH / 2; | 2978 | mouse_x = LCD_WIDTH / 2; |
2967 | mouse_y = LCD_HEIGHT / 2; | 2979 | mouse_y = LCD_HEIGHT / 2; |
2968 | 2980 | ||
2969 | fix_size(); | ||
2970 | |||
2971 | init_colors(); | 2981 | init_colors(); |
2972 | 2982 | ||
2973 | reset_drawing(); | 2983 | reset_drawing(); |
2974 | 2984 | ||
2975 | if(draw) | ||
2976 | { | ||
2977 | clear_and_draw(); | ||
2978 | } | ||
2979 | |||
2980 | return NULL; | 2985 | return NULL; |
2981 | } | 2986 | } |
2982 | 2987 | ||
@@ -3160,7 +3165,7 @@ static bool load_game(void) | |||
3160 | 3165 | ||
3161 | if(!strcmp(game, thegame.name)) | 3166 | if(!strcmp(game, thegame.name)) |
3162 | { | 3167 | { |
3163 | ret = init_for_game(&thegame, fd, false); | 3168 | ret = init_for_game(&thegame, fd); |
3164 | if(ret) | 3169 | if(ret) |
3165 | { | 3170 | { |
3166 | rb->splash(HZ, ret); | 3171 | rb->splash(HZ, ret); |
@@ -3254,7 +3259,7 @@ static void puzzles_main(void) | |||
3254 | if(!load_success) | 3259 | if(!load_success) |
3255 | { | 3260 | { |
3256 | /* our main menu expects a ready-to-use midend */ | 3261 | /* our main menu expects a ready-to-use midend */ |
3257 | init_for_game(&thegame, -1, false); | 3262 | init_for_game(&thegame, -1); |
3258 | } | 3263 | } |
3259 | 3264 | ||
3260 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | 3265 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ |
@@ -3294,14 +3299,17 @@ static void puzzles_main(void) | |||
3294 | switch(rb->do_menu(&menu, &sel, NULL, false)) | 3299 | switch(rb->do_menu(&menu, &sel, NULL, false)) |
3295 | { | 3300 | { |
3296 | case 0: | 3301 | case 0: |
3297 | clear_and_draw(); | 3302 | /* Loaded. Run the game! */ |
3298 | goto game_loop; | 3303 | goto game_loop; |
3299 | case 1: | 3304 | case 1: |
3300 | if(!load_success) | 3305 | if(!load_success) |
3301 | { | 3306 | { |
3302 | clear_and_draw(); | 3307 | /* Failed to load (so midend is already initialized |
3308 | * with new game) */ | ||
3303 | goto game_loop; | 3309 | goto game_loop; |
3304 | } | 3310 | } |
3311 | |||
3312 | /* Otherwise we need to generate a new game. */ | ||
3305 | quit = true; | 3313 | quit = true; |
3306 | break; | 3314 | break; |
3307 | case 2: | 3315 | case 2: |
@@ -3316,22 +3324,14 @@ static void puzzles_main(void) | |||
3316 | case 5: | 3324 | case 5: |
3317 | if(presets_menu()) | 3325 | if(presets_menu()) |
3318 | { | 3326 | { |
3319 | midend_new_game(me); | 3327 | new_game_notify(); |
3320 | fix_size(); | ||
3321 | init_colors(); | ||
3322 | reset_drawing(); | ||
3323 | clear_and_draw(); | ||
3324 | goto game_loop; | 3328 | goto game_loop; |
3325 | } | 3329 | } |
3326 | break; | 3330 | break; |
3327 | case 6: | 3331 | case 6: |
3328 | if(config_menu()) | 3332 | if(config_menu()) |
3329 | { | 3333 | { |
3330 | midend_new_game(me); | 3334 | new_game_notify(); |
3331 | fix_size(); | ||
3332 | init_colors(); | ||
3333 | reset_drawing(); | ||
3334 | clear_and_draw(); | ||
3335 | goto game_loop; | 3335 | goto game_loop; |
3336 | } | 3336 | } |
3337 | break; | 3337 | break; |
@@ -3350,16 +3350,19 @@ static void puzzles_main(void) | |||
3350 | 3350 | ||
3351 | while(1) | 3351 | while(1) |
3352 | { | 3352 | { |
3353 | init_for_game(&thegame, -1, true); | 3353 | init_for_game(&thegame, -1); |
3354 | game_loop: | ||
3355 | reset_drawing(); | ||
3356 | clear_and_draw(); | ||
3354 | 3357 | ||
3355 | last_keystate = 0; | 3358 | last_keystate = 0; |
3356 | accept_input = true; | 3359 | accept_input = true; |
3357 | 3360 | ||
3358 | game_loop: | ||
3359 | while(1) | 3361 | while(1) |
3360 | { | 3362 | { |
3361 | int button = process_input(timer_on ? TIMER_INTERVAL : -1, true); | 3363 | int button = process_input(timer_on ? TIMER_INTERVAL : -1, true); |
3362 | 3364 | ||
3365 | /* special codes are < 0 */ | ||
3363 | if(button < 0) | 3366 | if(button < 0) |
3364 | { | 3367 | { |
3365 | rb_unclip(NULL); | 3368 | rb_unclip(NULL); |
@@ -3393,6 +3396,7 @@ static void puzzles_main(void) | |||
3393 | } | 3396 | } |
3394 | } | 3397 | } |
3395 | 3398 | ||
3399 | /* we have a game input */ | ||
3396 | if(button) | 3400 | if(button) |
3397 | midend_process_key(me, 0, 0, button); | 3401 | midend_process_key(me, 0, 0, button); |
3398 | 3402 | ||
@@ -3403,6 +3407,7 @@ static void puzzles_main(void) | |||
3403 | 3407 | ||
3404 | draw_title(true); /* will draw to fb */ | 3408 | draw_title(true); /* will draw to fb */ |
3405 | 3409 | ||
3410 | /* Blit mouse but immediately clear it. */ | ||
3406 | if(mouse_mode) | 3411 | if(mouse_mode) |
3407 | draw_mouse(); | 3412 | draw_mouse(); |
3408 | 3413 | ||