diff options
Diffstat (limited to 'engines/glk')
-rw-r--r-- | engines/glk/frotz/glk_interface.cpp | 11 | ||||
-rw-r--r-- | engines/glk/frotz/glk_interface.h | 6 | ||||
-rw-r--r-- | engines/glk/frotz/processor.cpp | 5 | ||||
-rw-r--r-- | engines/glk/frotz/processor.h | 4 | ||||
-rw-r--r-- | engines/glk/frotz/processor_screen.cpp | 90 | ||||
-rw-r--r-- | engines/glk/frotz/windows.cpp | 80 | ||||
-rw-r--r-- | engines/glk/frotz/windows.h | 21 |
7 files changed, 119 insertions, 98 deletions
diff --git a/engines/glk/frotz/glk_interface.cpp b/engines/glk/frotz/glk_interface.cpp index 4d60fe7ac7..f6e01db955 100644 --- a/engines/glk/frotz/glk_interface.cpp +++ b/engines/glk/frotz/glk_interface.cpp @@ -32,12 +32,11 @@ namespace Glk { namespace Frotz { GlkInterface::GlkInterface(OSystem *syst, const GlkGameDescription &gameDesc) : - GlkAPI(syst, gameDesc), - _pics(nullptr), oldstyle(0), curstyle(0), curr_font(1), prev_font(1), temp_font(0), - curr_status_ht(0), mach_status_ht(0), gos_status(nullptr), gos_linepending(0), gos_linebuf(nullptr), - gos_linewin(nullptr), gos_channel(nullptr), mwin(0), mouse_x(0), mouse_y(0), fixforced(0), menu_selected(0), - enable_wrapping(false), enable_scripting(false), enable_scrolling(false), enable_buffering(false), - next_sample(0), next_volume(0), _soundLocked(false), _soundPlaying(false), _reverseVideo(false) { + GlkAPI(syst, gameDesc), _pics(nullptr), curr_status_ht(0), mach_status_ht(0), gos_status(nullptr), + gos_linepending(0), gos_linebuf(nullptr), gos_linewin(nullptr), gos_channel(nullptr), mwin(0), + mouse_x(0), mouse_y(0), fixforced(0), menu_selected(0), enable_wrapping(false), enable_scripting(false), + enable_scrolling(false), enable_buffering(false), next_sample(0), next_volume(0), _soundLocked(false), + _soundPlaying(false), _reverseVideo(false) { Common::fill(&statusline[0], &statusline[256], '\0'); Common::fill(&zcolors[0], &zcolors[zcolor_NUMCOLORS], 0); } diff --git a/engines/glk/frotz/glk_interface.h b/engines/glk/frotz/glk_interface.h index 5d47308070..df176afef5 100644 --- a/engines/glk/frotz/glk_interface.h +++ b/engines/glk/frotz/glk_interface.h @@ -62,14 +62,8 @@ public: Pics *_pics; zchar statusline[256]; uint zcolors[zcolor_NUMCOLORS]; - int oldstyle; - int curstyle; int fixforced; - int curr_font; - int prev_font; - int temp_font; - int curr_status_ht; int mach_status_ht; diff --git a/engines/glk/frotz/processor.cpp b/engines/glk/frotz/processor.cpp index fdfafaa3bd..b253510d79 100644 --- a/engines/glk/frotz/processor.cpp +++ b/engines/glk/frotz/processor.cpp @@ -198,11 +198,6 @@ void Processor::initialize() { op0_opcodes[9] = &Processor::z_catch; op1_opcodes[15] = &Processor::z_call_n; } - - PropFontInfo &pi = g_conf->_propInfo; - _quotes = pi._quotes; - _dashes = pi._quotes; - _spaces = pi._spaces; } void Processor::load_operand(zbyte type) { diff --git a/engines/glk/frotz/processor.h b/engines/glk/frotz/processor.h index 15b8c512e7..dddcc7609a 100644 --- a/engines/glk/frotz/processor.h +++ b/engines/glk/frotz/processor.h @@ -95,10 +95,6 @@ private: bool istream_replay; bool message; Common::FixedStack<Redirect, MAX_NESTING> _redirect; - - int _quotes; - int _dashes; - int _spaces; protected: /** * \defgroup General support methods diff --git a/engines/glk/frotz/processor_screen.cpp b/engines/glk/frotz/processor_screen.cpp index a3134d3c35..1ce0f91099 100644 --- a/engines/glk/frotz/processor_screen.cpp +++ b/engines/glk/frotz/processor_screen.cpp @@ -29,20 +29,22 @@ namespace Glk { namespace Frotz { void Processor::screen_mssg_on() { - if (_wp.currWin() == _wp._lower) { - oldstyle = curstyle; + Window &w = _wp.currWin(); + + if (w == _wp._lower) { + w._oldStyle = w._currStyle; glk_set_style(style_Preformatted); glk_put_string("\n "); } } void Processor::screen_mssg_off() { - if (_wp.currWin() == _wp._lower) { + Window &w = _wp.currWin(); + + if (w == _wp._lower) { glk_put_char('\n'); - zargs[0] = 0; - z_set_text_style(); - zargs[0] = oldstyle; - z_set_text_style(); + w.setStyle(0); + w.setStyle(w._oldStyle); } } @@ -101,7 +103,8 @@ uint32 Processor::zchar_to_unicode_rune(zchar c) { } void Processor::screen_char(zchar c) { - if (gos_linepending && (_wp.currWin() == gos_linewin)) { + Window &w = _wp.currWin(); + if (gos_linepending && (w == gos_linewin)) { gos_cancel_pending_line(); if (_wp.currWin() == _wp._upper) { _wp._upper.setCursor(Point(1, _wp._upper[Y_CURSOR] + 1)); @@ -112,14 +115,12 @@ void Processor::screen_char(zchar c) { // check fixed flag in header, game can change it at whim int forcefix = ((h_flags & FIXED_FONT_FLAG) != 0); - int curfix = ((curstyle & FIXED_WIDTH_STYLE) != 0); + int curfix = ((w._currStyle & FIXED_WIDTH_STYLE) != 0); if (forcefix && !curfix) { - zargs[0] = 0xf000; // tickle tickle! - z_set_text_style(); + w.setStyle(); fixforced = true; } else if (!forcefix && fixforced) { - zargs[0] = 0xf000; // tickle tickle! - z_set_text_style(); + w.setStyle(); fixforced = false; } @@ -156,11 +157,11 @@ void Processor::screen_char(zchar c) { curx++; } } - } else if (_wp.currWin() == _wp._lower) { + } else if (w == _wp._lower) { if (c == ZC_RETURN) glk_put_char('\n'); else { - if (curr_font == GRAPHICS_FONT) { + if (w._currFont == GRAPHICS_FONT) { uint32 runic_char = zchar_to_unicode_rune(c); if (runic_char != 0) { glk_set_style(style_User2); @@ -365,46 +366,7 @@ void Processor::z_set_colour() { void Processor::z_set_font() { zword font = zargs[0]; - switch (font) { - case PREVIOUS_FONT: - // previous font - temp_font = curr_font; - curr_font = prev_font; - prev_font = temp_font; - zargs[0] = 0xf000; // tickle tickle! - z_set_text_style(); - store(curr_font); - break; - - case TEXT_FONT: - case GRAPHICS_FONT: - case FIXED_WIDTH_FONT: - prev_font = curr_font; - curr_font = font; - zargs[0] = 0xf000; // tickle tickle! - z_set_text_style(); - store(prev_font); - break; - - case PICTURE_FONT: // picture font, undefined per 1.1 - default: // unavailable - store(0); - break; - } - - PropFontInfo &pi = g_conf->_propInfo; - if (curr_font == GRAPHICS_FONT) { - _quotes = pi._quotes; - _dashes = pi._dashes; - _spaces = pi._spaces; - pi._quotes = 0; - pi._dashes = 0; - pi._spaces = 0; - } else { - pi._quotes = _quotes; - pi._dashes = _dashes; - pi._spaces = _spaces; - } + store(_wp.currWin().setFont(font)); } void Processor::z_set_cursor() { @@ -424,23 +386,7 @@ void Processor::z_set_cursor() { } void Processor::z_set_text_style() { - int style; - - if (zargs[0] == 0) - curstyle = 0; - else if (zargs[0] != 0xf000) - // not tickle time - curstyle |= zargs[0]; - - if (h_flags & FIXED_FONT_FLAG || curr_font == FIXED_WIDTH_FONT || curr_font == GRAPHICS_FONT) - style = curstyle | FIXED_WIDTH_STYLE; - else - style = curstyle; - - if (gos_linepending && _wp.currWin() == gos_linewin) - return; - - _wp[_wp._cwin].setStyle(style); + _wp[_wp._cwin].setStyle(zargs[0]); } void Processor::z_set_window() { diff --git a/engines/glk/frotz/windows.cpp b/engines/glk/frotz/windows.cpp index 0ff92bc1f7..bacd6e3f2f 100644 --- a/engines/glk/frotz/windows.cpp +++ b/engines/glk/frotz/windows.cpp @@ -75,6 +75,12 @@ void Windows::setup(bool isVersion6) { w._index = idx; w[FONT_NUMBER] = TEXT_FONT; w[FONT_SIZE] = (mi._cellH << 8) | mi._cellW; + + + PropFontInfo &pi = g_conf->_propInfo; + w._quotes = pi._quotes; + w._dashes = pi._quotes; + w._spaces = pi._spaces; } } @@ -87,7 +93,8 @@ void Windows::setWindow(int win) { /*--------------------------------------------------------------------------*/ -Window::Window() : _windows(nullptr), _win(nullptr) { +Window::Window() : _windows(nullptr), _win(nullptr), _quotes(0), _dashes(0), _spaces(0), + _currFont(TEXT_FONT), _prevFont(TEXT_FONT), _tempFont(TEXT_FONT), _currStyle(0), _oldStyle(0) { Common::fill(_properties, _properties + TRUE_BG_COLOR + 1, 0); _properties[Y_POS] = _properties[X_POS] = 1; _properties[Y_CURSOR] = _properties[X_CURSOR] = 1; @@ -184,7 +191,72 @@ void Window::updateColors(uint fore, uint back) { updateColors(); } -void Window::setStyle(uint style) { +uint Window::setFont(uint font) { + int result = 0; + + switch (font) { + case PREVIOUS_FONT: + // previous font + _tempFont = _currFont; + _currFont = _prevFont; + _prevFont = _tempFont; + setStyle(); + result = _currFont; + break; + + case TEXT_FONT: + case GRAPHICS_FONT: + case FIXED_WIDTH_FONT: + _prevFont = _currFont; + _currFont = font; + setStyle(); + result = _prevFont; + break; + + case PICTURE_FONT: // picture font, undefined per 1.1 + default: // unavailable + result = 0; + break; + } + + PropFontInfo &pi = g_conf->_propInfo; + if (_currFont == GRAPHICS_FONT) { + _quotes = pi._quotes; + _dashes = pi._dashes; + _spaces = pi._spaces; + pi._quotes = 0; + pi._dashes = 0; + pi._spaces = 0; + } else { + pi._quotes = _quotes; + pi._dashes = _dashes; + pi._spaces = _spaces; + } + + return result; +} + +void Window::setStyle(int style) { + if (style == 0) + _currStyle = 0; + else if (style != -1) + // not tickle time + _currStyle |= style; + + if (g_vm->h_flags & FIXED_FONT_FLAG || _currFont == FIXED_WIDTH_FONT || _currFont == GRAPHICS_FONT) + style = _currStyle | FIXED_WIDTH_STYLE; + else + style = _currStyle; + + if (g_vm->gos_linepending && _windows->currWin() == g_vm->gos_linewin) + return; + + updateStyle(); +} + +void Window::updateStyle() { + uint style = _currStyle; + /* if (style & REVERSE_STYLE) { os_set_reverse_video(true); @@ -194,7 +266,7 @@ void Window::setStyle(uint style) { createGlkWindow(); if (style & FIXED_WIDTH_STYLE) { - if (g_vm->curr_font == GRAPHICS_FONT) + if (_currFont == GRAPHICS_FONT) _win->_stream->setStyle(style_User1); // character graphics else if (style & BOLDFACE_STYLE && style & EMPHASIS_STYLE) _win->_stream->setStyle(style_BlockQuote); // monoz @@ -216,7 +288,7 @@ void Window::setStyle(uint style) { } /* - if (curstyle == 0) { + if (_currStyle == 0) { os_set_reverse_video(false); } */ diff --git a/engines/glk/frotz/windows.h b/engines/glk/frotz/windows.h index 0f2bdff772..8b971cc9c4 100644 --- a/engines/glk/frotz/windows.h +++ b/engines/glk/frotz/windows.h @@ -105,6 +105,20 @@ private: * Creates a new Glk window to attach to the window */ void createGlkWindow(); + + /** + * Updates the current font/style + */ + void updateStyle(); +public: + int _currFont; + int _prevFont; + int _tempFont; + int _currStyle; + int _oldStyle; + int _quotes; + int _dashes; + int _spaces; public: /** * Constructor @@ -170,9 +184,14 @@ public: void updateColors(uint fore, uint back); /** + * Set the font + */ + uint setFont(uint font); + + /** * Set the textstyle */ - void setStyle(uint style); + void setStyle(int style = -1); }; /** |