# HG changeset patch # User Karl Heuer # Date 822522788 0 # Node ID 0eaecdc1314298b2bb88cdd62bc747c57626c96b # Parent b747e836963969ca474c77cef6d36da23aa5cf1d (dos_set_window_size): New function; switches the screen to the size as close as possible to requested frame dimensions. diff -r b747e8369639 -r 0eaecdc13142 src/msdos.c --- a/src/msdos.c Wed Jan 24 22:02:17 1996 +0000 +++ b/src/msdos.c Wed Jan 24 22:33:08 1996 +0000 @@ -331,6 +331,130 @@ #ifndef HAVE_X_WINDOWS +/* Set the screen dimensions so that it can show no less than + ROWS x COLS frame. */ +void +dos_set_window_size (rows, cols) + int *rows, *cols; +{ + char video_name[30]; + Lisp_Object video_mode; + int video_mode_value; + int have_vga = 0; + union REGS regs; + int current_rows = ScreenRows (), current_cols = ScreenCols (); + + if (*rows == current_rows && *cols == current_cols) + return; + + /* Do we have a VGA? */ + regs.x.ax = 0x1a00; + int86 (0x10, ®s, ®s); + if (regs.h.al == 0x1a && regs.h.bl > 5 && regs.h.bl < 13) + have_vga = 1; + + mouse_off (); + + /* If the user specify a special video mode for these dimensions, + use that mode. */ + sprintf (video_name, "screen-dimensions-%dx%d", *rows, *cols); + video_mode = XSYMBOL (Fintern_soft (build_string (video_name), + Qnil))-> value; + + if (INTEGERP (video_mode) + && (video_mode_value = XINT (video_mode)) > 0) + { + regs.x.ax = video_mode_value; + int86 (0x10, ®s, ®s); + regs.h.bl = 0; + regs.x.ax = 0x1003; + int86 (0x10, ®s, ®s); + } + + /* Find one of the dimensions supported by standard EGA/VGA + which gives us at least the required dimensions. */ + +#if __DJGPP__ > 1 + + else + { + static struct { + int rows; + int need_vga; + } std_dimension[] = { + {25, 0}, + {28, 1}, + {35, 0}, + {40, 1}, + {43, 0}, + {50, 1} + }; + int i = 0; + + while (i < sizeof (std_dimension) / sizeof (std_dimension[0])) + { + if (std_dimension[i].need_vga <= have_vga + && std_dimension[i].rows >= *rows) + { + if (std_dimension[i].rows != current_rows + || *cols != current_cols) + _set_screen_lines (*rows); + break; + } + } + } + +#else /* not __DJGPP__ > 1 */ + + else if (*rows <= 25) + { + if (current_rows != 25 || current_cols != 80) + { + regs.x.ax = 3; + int86 (0x10, ®s, ®s); + regs.x.ax = 0x1101; + regs.h.bl = 0; + int86 (0x10, ®s, ®s); + regs.x.ax = 0x1200; + regs.h.bl = 32; + int86 (0x10, ®s, ®s); + regs.x.ax = 3; + int86 (0x10, ®s, ®s); + } + } + else if (*rows <= 50) + if (have_vga && (current_rows != 50 || current_cols != 80) + || *rows <= 43 && (current_rows != 43 || current_cols != 80)) + { + regs.x.ax = 3; + int86 (0x10, ®s, ®s); + regs.x.ax = 0x1112; + regs.h.bl = 0; + int86 (0x10, ®s, ®s); + regs.x.ax = 0x1200; + regs.h.bl = 32; + int86 (0x10, ®s, ®s); + regs.x.ax = 0x0100; + regs.x.cx = 7; + int86 (0x10, ®s, ®s); + } +#endif /* not __DJGPP__ > 1 */ + + if (have_mouse) + { + /* Must hardware-reset the mouse, or else it won't update + its notion of screen dimensions. */ + regs.x.ax = 0; + int86 (0x33, ®s, ®s); + mouse_init (); + mouse_on (); + } + + /* Tell the caller what dimensions have been REALLY set. */ + *rows = ScreenRows (); + *cols = ScreenCols (); +} + /* * If we write a character in the position where the mouse is, * the mouse cursor may need to be refreshed.