From 08414b4a3bd89f8f1f16f9d04ce65ca31c69b705 Mon Sep 17 00:00:00 2001 From: David Griffith Date: Wed, 8 Mar 2017 05:25:15 -0800 Subject: [PATCH] Initial attempt at resizing the screen. 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 | 1 + src/common/screen.c | 5 ----- src/curses/ux_frotz.h | 2 ++ src/curses/ux_init.c | 32 +++++++++----------------------- src/curses/ux_screen.c | 38 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 50 insertions(+), 28 deletions(-) diff --git a/src/common/fastmem.c b/src/common/fastmem.c index 1e78790..56e5e7b 100644 --- a/src/common/fastmem.c +++ b/src/common/fastmem.c @@ -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); diff --git a/src/common/screen.c b/src/common/screen.c index 6d3e4f5..c147f6b 100644 --- a/src/common/screen.c +++ b/src/common/screen.c @@ -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 diff --git a/src/curses/ux_frotz.h b/src/curses/ux_frotz.h index d3248db..dec8f8c 100644 --- a/src/curses/ux_frotz.h +++ b/src/curses/ux_frotz.h @@ -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); diff --git a/src/curses/ux_init.c b/src/curses/ux_init.c index e08e2b4..82949ca 100644 --- a/src/curses/ux_init.c +++ b/src/curses/ux_init.c @@ -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) { diff --git a/src/curses/ux_screen.c b/src/curses/ux_screen.c index 62c5842..eb5bc2a 100644 --- a/src/curses/ux_screen.c +++ b/src/curses/ux_screen.c @@ -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 */ -- 2.34.1