Initial attempt at resizing the screen.
authorDavid Griffith <dave@661.org>
Wed, 8 Mar 2017 13:25:15 +0000 (05:25 -0800)
committerDavid Griffith <dave@661.org>
Wed, 8 Mar 2017 13:25:15 +0000 (05:25 -0800)
Essentially I just copied stuff from FrotzWnd.cpp from David Kinder's
Windows Frotz codebase.  I don't understand how he's getting the screen
contents to reprint.

src/common/fastmem.c
src/common/screen.c
src/curses/ux_frotz.h
src/curses/ux_init.c
src/curses/ux_screen.c

index 1e7879068953ec8a789baa9e7267e5235d4f3f75..56e5e7b18b2ab79caa08f1e1f3d37bae31714883 100644 (file)
@@ -51,6 +51,7 @@
 
 extern void seed_random (int);
 extern void restart_screen (void);
+extern void resize_screen (void);
 extern void refresh_text_style (void);
 extern void call (zword, int, zword *, int);
 extern void split_window (zword);
index 6d3e4f5e1e3c4b90b8102b7126879dd5fee3d268..c147f6bfd32d6b46199686aceb2e1254da034a4d 100644 (file)
@@ -673,8 +673,6 @@ static void erase_screen (zword win)
 
 }/* erase_screen */
 
-/* #ifdef AMIGA */
-
 
 /*
  * resize_screen
@@ -692,13 +690,10 @@ void resize_screen (void)
        wp[7].x_size = h_screen_width;
 
        wp[0].y_size = h_screen_height - wp[1].y_size - wp[7].y_size;
-
     }
 
 }/* resize_screen */
 
-/* #endif */
-
 
 /*
  * restart_screen
index d3248db00e43fd8d41d36ee6d5ecde278d2f5eb2..dec8f8c36e233048ed5602adb0b4339b1d146679 100644 (file)
@@ -86,6 +86,8 @@ bool unix_init_pictures(void);                /* ux_pic.c */
 void unix_init_scrollback(void);       /* ux_screen.c */
 void unix_save_screen(int);            /* ux_screen.c */
 void unix_do_scrollback(void);         /* ux_screen.c */
+void unix_resize_display(void);                /* ux_screen.c */
+
 
 #ifdef NO_STRRCHR
 char *strrchr(const char *, int);
index e08e2b4825ae427c57c157b2f6ac5bc02b2065ce..82949ca75907f94ea6ccce687898a2f88ae7de8c 100644 (file)
@@ -53,10 +53,8 @@ static int geterrmode(char *);
 static int getcolor(char *);
 static int getbool(char *);
 
-/* static void sigwinch_handler(int); */
+static void sigwinch_handler(int);
 static void sigint_handler(int);
-/* static void redraw(void); */
-
 
 #define INFORMATION "\
 An interpreter for all Infocom and other Z-Machine games.\n\
@@ -91,7 +89,6 @@ static int    getconfig(char *);
 static int     getbool(char *);
 static int     getcolor(char *);
 static int     geterrmode(char *);
-/* static void redraw(void); */
 /* static FILE *pathopen(const char *, const char *, const char *, char *); */
 
 
@@ -214,10 +211,9 @@ void os_process_arguments (int argc, char *argv[])
  *
  */
 
-/*
-    if (signal(SIGWINCH, SIG_IGN) != SIG_IGN)
+
+//    if (signal(SIGWINCH, SIG_IGN) != SIG_IGN)
        signal(SIGWINCH, sigwinch_handler);
-*/
 
     if (signal(SIGINT, SIG_IGN) != SIG_IGN)
        signal(SIGINT, sigint_handler);
@@ -971,17 +967,12 @@ static int geterrmode(char *value)
  * cleanly resize the window.
  *
  */
-// FIXME: figure out what to do with this
-//static void sigwinch_handler(int UNUSED(sig))
-//{
-/*
-There are some significant problems involved in getting resizes to work
-properly with at least this implementation of the Z Machine and probably
-the Z-Machine standard itself.  See the file BUGS for a detailed
-explaination for this.  Because of this trouble, this function currently
-does nothing.
-*/
-//}
+static void sigwinch_handler(int UNUSED(sig))
+{
+  signal(SIGWINCH, SIG_IGN);
+  unix_resize_display();
+  signal(SIGWINCH, sigwinch_handler);
+}
 
 
 /*
@@ -1002,11 +993,6 @@ static void sigint_handler(int dummy)
     exit(1);
 }
 
-/*
-void redraw(void)
-{
-}
-*/
 
 void os_init_setup(void)
 {
index 62c58424afa93183a20d6afb39517f376de9bc01..eb5bc2aee1ca8c4909b44dc1f9a311c0d8093c5e 100644 (file)
@@ -33,6 +33,8 @@
 
 #include "ux_frotz.h"
 
+extern void resize_screen(void);
+extern void restart_header(void);
 
 /*
  * os_erase_area
@@ -131,3 +133,39 @@ void os_scroll_area (int top, int left, int bottom, int right, int units)
   else if (units < 0)
     os_erase_area(top + 1, left + 1, top - units, right + 1, 0);
 }/* os_scroll_area */
+
+
+/*
+ * unix_resize_display
+ *
+ * Resize the display and redraw.
+ *
+ */
+void unix_resize_display(void)
+{
+    int x, y;
+
+    /* Notify the game that the display needs refreshing */
+    if (h_version == V6)
+       h_flags |= REFRESH_FLAG;
+
+    /* Get new terminal dimensions */
+    getmaxyx(stdscr, y, x);
+
+    /* Update the game's header */
+    h_screen_width  = (zword) x;
+    h_screen_height = (zword) y;
+    h_screen_cols   = (zbyte) (h_screen_width / h_font_width);
+    h_screen_rows   = (zbyte)(h_screen_height / h_font_height);
+
+    if (zmp != NULL) {
+       resize_screen();
+       restart_header();
+    }
+
+    clearok(stdscr, 1);
+    redrawwin(stdscr);
+    refresh();
+    clearok(stdscr, 0);
+
+}/* unix_redraw_display */