Description: add pause key Add a pause key to the game. Since this violates the spirit of the game, this patch should not be enabled. Author: Jochen Voss Reviewd-by: Christian T. Steigies Last-Update: 2017-12-30 Index: moon-buggy-1.0.51/game.c =================================================================== --- moon-buggy-1.0.51.orig/game.c +++ moon-buggy-1.0.51/game.c @@ -117,6 +117,15 @@ key_handler (game_time t, int val) print_message ("aborted at user's request"); mode_change (crash_mode, 0); break; + case 4: + clock_freeze (); + wnoutrefresh (moon); + print_message ("PAUSED (press any key to continue)"); + doupdate (); + wait_for_key (); + mode_redraw (); + clock_thaw (); + break; } } @@ -214,6 +223,7 @@ setup_game_mode (void) mode_add_key (game_mode, mbk_jump, "jump", 1); mode_add_key (game_mode, mbk_fire, "fire", 2); mode_add_key (game_mode, mbk_end, "abort game", 3); + mode_add_key (game_mode, mbk_pause, "pause", 4); mode_complete (game_mode); crash_mode = new_mode (); Index: moon-buggy-1.0.51/keyboard.c =================================================================== --- moon-buggy-1.0.51.orig/keyboard.c +++ moon-buggy-1.0.51/keyboard.c @@ -124,6 +124,8 @@ install_keys (void) add_key ('s', mbk_scores, 100); + add_key ('p', mbk_pause, 100); + add_key ('r', mbk_redraw, 20); add_key (12, mbk_redraw, 10); /* \C-l */ } Index: moon-buggy-1.0.51/moon-buggy.h =================================================================== --- moon-buggy-1.0.51.orig/moon-buggy.h +++ moon-buggy-1.0.51/moon-buggy.h @@ -42,6 +42,7 @@ typedef void (*callback_fn) (game_time, extern game_time current_time (void); +extern void wait_for_key (void); extern void clock_reset (void); extern void clock_thaw (void); extern void clear_queue (void); @@ -149,8 +150,9 @@ enum mb_key { mbk_copyright = 1, mbk_down = 2, mbk_end = 4, mbk_fire = 8, mbk_first = 16, mbk_jump = 32, mbk_last = 64, mbk_pagedown = 128, mbk_pageup = 256, mbk_start = 512, mbk_up = 1024, mbk_warranty = 2048, mbk_scores = 4096, + mbk_pause = 8192, - mbk_redraw = 8192 /* specially handled in `mode_keypress' */ + mbk_redraw = 16384 /* specially handled in `mode_keypress' */ }; struct binding { int meanings; Index: moon-buggy-1.0.51/queue.c =================================================================== --- moon-buggy-1.0.51.orig/queue.c +++ moon-buggy-1.0.51/queue.c @@ -120,7 +120,7 @@ key_ready (void) return res; } -static void +void wait_for_key (void) { int res;