diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/glk/conf.cpp | 48 | ||||
-rw-r--r-- | engines/glk/conf.h | 10 | ||||
-rw-r--r-- | engines/glk/fonts.cpp | 15 | ||||
-rw-r--r-- | engines/glk/fonts.h | 6 | ||||
-rw-r--r-- | engines/glk/glk_api.cpp | 28 | ||||
-rw-r--r-- | engines/glk/screen.cpp | 15 | ||||
-rw-r--r-- | engines/glk/screen.h | 16 | ||||
-rw-r--r-- | engines/glk/streams.cpp | 28 | ||||
-rw-r--r-- | engines/glk/window_graphics.cpp | 18 | ||||
-rw-r--r-- | engines/glk/window_graphics.h | 2 | ||||
-rw-r--r-- | engines/glk/window_text_buffer.cpp | 4 | ||||
-rw-r--r-- | engines/glk/window_text_grid.cpp | 2 | ||||
-rw-r--r-- | engines/glk/windows.cpp | 74 | ||||
-rw-r--r-- | engines/glk/windows.h | 49 |
14 files changed, 155 insertions, 160 deletions
diff --git a/engines/glk/conf.cpp b/engines/glk/conf.cpp index e8362e1338..5c6bc761bc 100644 --- a/engines/glk/conf.cpp +++ b/engines/glk/conf.cpp @@ -33,7 +33,7 @@ const byte BLUE[3] = { 0x00, 0x00, 0x60 }; const byte SCROLL_BG[3] = { 0xb0, 0xb0, 0xb0 }; const byte SCROLL_FG[3] = { 0x80, 0x80, 0x80 }; -WindowStyle T_STYLES[style_NUMSTYLES] = { +WindowStyleStatic T_STYLES[style_NUMSTYLES] = { { PROPR, { 0xff, 0xff, 0xff }, { 0x00, 0x00, 0x00 }, 0 }, ///< Normal { PROPI, { 0xff, 0xff, 0xff }, { 0x00, 0x00, 0x00 }, 0 }, ///< Emphasized { MONOR, { 0xff, 0xff, 0xff }, { 0x00, 0x00, 0x00 }, 0 }, ///< Preformatted @@ -47,7 +47,7 @@ WindowStyle T_STYLES[style_NUMSTYLES] = { { MONOR, { 0xff, 0xff, 0xff }, { 0x00, 0x00, 0x00 }, 0 } ///< User2 }; -WindowStyle G_STYLES[style_NUMSTYLES] = { +WindowStyleStatic G_STYLES[style_NUMSTYLES] = { { MONOR, { 0xff, 0xff, 0xff }, { 0x60, 0x60, 0x60 }, 0 }, ///< Normal { MONOI, { 0xff, 0xff, 0xff }, { 0x60, 0x60, 0x60 }, 0 }, ///< Emphasized { MONOR, { 0xff, 0xff, 0xff }, { 0x60, 0x60, 0x60 }, 0 }, ///< Preformatted @@ -69,8 +69,8 @@ Conf::Conf(InterpreterType interpType) { _imageH = g_system->getHeight(); get("moreprompt", _propInfo._morePrompt, "\207 more \207"); - get("morecolor", _propInfo._moreColor); - get("morecolor", _propInfo._moreSave); + get("morecolor", _propInfo._moreColor, nullptr); + get("morecolor", _propInfo._moreSave, nullptr); get("morefont", _propInfo._moreFont, PROPB); get("morealign", _propInfo._moreAlign); get("monoaspect", _monoInfo._aspect, 1.0); @@ -113,16 +113,16 @@ Conf::Conf(InterpreterType interpType) { get("gamma", _gamma, 1.0); get("linkcolor", _propInfo._linkColor, BLUE); - Common::copy(&_propInfo._linkColor[0], &_propInfo._linkSave[3], &_monoInfo._linkColor[0]); - Common::copy(&_propInfo._linkColor[0], &_propInfo._linkSave[3], &_propInfo._linkSave[0]); + _monoInfo._linkColor = _propInfo._linkColor; + _propInfo._linkSave = _propInfo._linkColor; - get("bordercolor", _borderColor); - get("bordercolor", _borderSave); + get("bordercolor", _borderColor, nullptr); + get("bordercolor", _borderSave, nullptr); get("windowcolor", _windowColor, WHITE); get("windowcolor", _windowSave, WHITE); get("lcd", _lcd, 1); - get("caretcolor", _propInfo._caretColor); - get("caretcolor", _propInfo._caretSave); + get("caretcolor", _propInfo._caretColor, nullptr); + get("caretcolor", _propInfo._caretSave, nullptr); get("caretshape", _propInfo._caretShape, 2); _propInfo._linkStyle = _monoInfo._linkStyle = ConfMan.hasKey("linkstyle") @@ -165,11 +165,11 @@ Conf::Conf(InterpreterType interpType) { char *bg = strtok(nullptr, "\r\n\t "); if (tg == 0) { - parseColor(fg, _tStyles[style].fg); - parseColor(bg, _tStyles[style].bg); + _tStyles[style].fg = parseColor(fg); + _tStyles[style].bg = parseColor(bg); } else { - parseColor(fg, _gStyles[style].fg); - parseColor(bg, _gStyles[style].bg); + _gStyles[style].fg = parseColor(fg); + _gStyles[style].bg = parseColor(bg); } } } @@ -201,13 +201,13 @@ void Conf::get(const Common::String &key, Common::String &field, const char *def field.trim(); } -void Conf::get(const Common::String &key, byte *color, const byte *defaultColor) { +void Conf::get(const Common::String &key, uint &color, const byte *defaultColor) { if (ConfMan.hasKey(key)) { - parseColor(ConfMan.get(key), color); + color = parseColor(ConfMan.get(key)); } else if (defaultColor) { - Common::copy(defaultColor, defaultColor + 3, color); + color = g_system->getScreenFormat().RGBToColor(defaultColor[0], defaultColor[1], defaultColor[2]); } else { - Common::fill(color, color + 3, 0); + color = 0; } } @@ -227,8 +227,9 @@ void Conf::get(const Common::String &key, double &field, double defaultVal) { field = ConfMan.hasKey(key) ? atof(ConfMan.get(key).c_str()) : defaultVal; } -void Conf::parseColor(const Common::String &str, byte *color) { +uint Conf::parseColor(const Common::String &str) { char r[3], g[3], b[3]; + uint rv, gv, bv; if (str.size() == 6) { r[0] = str[0]; @@ -241,10 +242,13 @@ void Conf::parseColor(const Common::String &str, byte *color) { b[1] = str[5]; b[2] = 0; - color[0] = strtol(r, nullptr, 16); - color[1] = strtol(g, nullptr, 16); - color[2] = strtol(b, nullptr, 16); + rv = strtol(r, nullptr, 16); + gv = strtol(g, nullptr, 16); + bv = strtol(b, nullptr, 16); + return g_system->getScreenFormat().RGBToColor(rv, gv, bv); } + + return 0; } } // End of namespace Glk diff --git a/engines/glk/conf.h b/engines/glk/conf.h index 4b4a013f2b..b12b46ab38 100644 --- a/engines/glk/conf.h +++ b/engines/glk/conf.h @@ -42,7 +42,7 @@ private: /** * Get a color */ - void get(const Common::String &key, byte *color, const byte *defaultColor = nullptr); + void get(const Common::String &key, uint &color, const byte *defaultColor); /** * Get a font name into a font Id @@ -67,7 +67,7 @@ private: /** * Parse a color */ - void parseColor(const Common::String &str, byte *color); + uint parseColor(const Common::String &str); public: MonoFontInfo _monoInfo; PropFontInfo _propInfo; @@ -79,11 +79,11 @@ public: int _wBorderX, _wBorderY; int _tMarginX, _tMarginY; double _gamma; - byte _borderColor[3], _borderSave[3]; - byte _windowColor[3], _windowSave[3]; + uint _borderColor, _borderSave; + uint _windowColor, _windowSave; int _lcd; int _scrollWidth; - byte _scrollBg[3], _scrollFg[3]; + uint _scrollBg, _scrollFg; bool _graphics; bool _sound; bool _speak; diff --git a/engines/glk/fonts.cpp b/engines/glk/fonts.cpp index 60eb116a90..cdac7c0b2b 100644 --- a/engines/glk/fonts.cpp +++ b/engines/glk/fonts.cpp @@ -28,26 +28,21 @@ namespace Glk { FontInfo::FontInfo() : _size(0), _aspect(0), _cellW(0), _cellH(0), _leading(0), _baseLine(0), - _linkStyle(0), _moreFont(PROPB), _moreAlign(0), _caps(0) { - Common::fill(&_linkColor[0], &_linkColor[3], 0); - Common::fill(&_linkSave[0], &_linkSave[3], 0); - Common::fill(&_moreColor[0], &_moreColor[3], 0); - Common::fill(&_moreSave[0], &_moreSave[3], 0); + _linkStyle(0), _moreFont(PROPB), _moreAlign(0), _caps(0), _linkColor(0), _linkSave(0), + _moreColor(0), _moreSave(0) { } /*--------------------------------------------------------------------------*/ -PropFontInfo::PropFontInfo() : _justify(0), _quotes(0), _dashes(0), _spaces(0), _caretShape(0), _lineSeparation(2) { - Common::fill(&_caretColor[0], &_caretColor[3], 0); - Common::fill(&_caretSave[0], &_caretSave[3], 0); +PropFontInfo::PropFontInfo() : _justify(0), _quotes(0), _dashes(0), _spaces(0), _caretShape(0), + _lineSeparation(2), _caretColor(0), _caretSave(0) { } /*--------------------------------------------------------------------------*/ void PropFontInfo::drawCaret(const Point &pos) { - const byte *rgb = _caretColor; + uint color = _caretColor; Graphics::Screen &s = *g_vm->_screen; - uint color = s.format.RGBToColor(rgb[0], rgb[1], rgb[2]); int x = pos.x / GLI_SUBPIX, y = pos.y; switch (_caretShape) { diff --git a/engines/glk/fonts.h b/engines/glk/fonts.h index 9f0dc207e1..4a9253023c 100644 --- a/engines/glk/fonts.h +++ b/engines/glk/fonts.h @@ -41,8 +41,8 @@ struct FontInfo { int _cellW, _cellH; int _leading; int _baseLine; - byte _linkColor[3], _linkSave[3]; - byte _moreColor[3], _moreSave[3]; + uint _linkColor, _linkSave; + uint _moreColor, _moreSave; int _linkStyle; FACES _moreFont; int _moreAlign; @@ -65,7 +65,7 @@ struct MonoFontInfo : public FontInfo { * Font info for proportional (variable size) fonts */ struct PropFontInfo : public MonoFontInfo { - byte _caretColor[3], _caretSave[3]; + uint _caretColor, _caretSave; int _caretShape; int _justify; int _quotes; diff --git a/engines/glk/glk_api.cpp b/engines/glk/glk_api.cpp index 329f4e9b08..21640afe62 100644 --- a/engines/glk/glk_api.cpp +++ b/engines/glk/glk_api.cpp @@ -465,15 +465,11 @@ void GlkAPI::glk_stylehint_set(uint wintype, uint style, uint hint, int val) { switch (hint) { case stylehint_TextColor: - styles[style].fg[0] = (val >> 16) & 0xff; - styles[style].fg[1] = (val >> 8) & 0xff; - styles[style].fg[2] = (val) & 0xff; + styles[style].fg = val; break; case stylehint_BackColor: - styles[style].bg[0] = (val >> 16) & 0xff; - styles[style].bg[1] = (val >> 8) & 0xff; - styles[style].bg[2] = (val) & 0xff; + styles[style].bg = val; break; case stylehint_ReverseColor: @@ -505,12 +501,12 @@ void GlkAPI::glk_stylehint_set(uint wintype, uint style, uint hint, int val) { } if (wintype == wintype_TextBuffer && style == style_Normal && hint == stylehint_BackColor) { - memcpy(g_conf->_windowColor, styles[style].bg, 3); + g_conf->_windowColor = styles[style].bg; } if (wintype == wintype_TextBuffer && style == style_Normal && hint == stylehint_TextColor) { - memcpy(g_conf->_propInfo._moreColor, styles[style].fg, 3); - memcpy(g_conf->_propInfo._caretColor, styles[style].fg, 3); + g_conf->_propInfo._moreColor = styles[style].fg; + g_conf->_propInfo._caretColor = styles[style].fg; } } @@ -539,15 +535,11 @@ void GlkAPI::glk_stylehint_clear(uint wintype, uint style, uint hint) { switch (hint) { case stylehint_TextColor: - styles[style].fg[0] = defaults[style].fg[0]; - styles[style].fg[1] = defaults[style].fg[1]; - styles[style].fg[2] = defaults[style].fg[2]; + styles[style].fg = defaults[style].fg; break; case stylehint_BackColor: - styles[style].bg[0] = defaults[style].bg[0]; - styles[style].bg[1] = defaults[style].bg[1]; - styles[style].bg[2] = defaults[style].bg[2]; + styles[style].bg = defaults[style].bg; break; case stylehint_ReverseColor: @@ -608,13 +600,11 @@ bool GlkAPI::glk_style_measure(winid_t win, uint style, uint hint, uint *result) break; case stylehint_TextColor: - *result = - (styles[style].fg[0] << 16) | (styles[style].fg[1] << 8) | (styles[style].fg[2]); + *result = styles[style].fg; break; case stylehint_BackColor: - *result = - (styles[style].bg[0] << 16) | (styles[style].bg[1] << 8) | (styles[style].bg[2]); + *result = styles[style].bg; break; case stylehint_ReverseColor: diff --git a/engines/glk/screen.cpp b/engines/glk/screen.cpp index 465adab082..c460a216f1 100644 --- a/engines/glk/screen.cpp +++ b/engines/glk/screen.cpp @@ -59,16 +59,13 @@ void Screen::initialize() { } } -void Screen::fill(const byte *rgb) { - uint color = format.RGBToColor(rgb[0], rgb[1], rgb[2]); +void Screen::fill(uint color) { clear(color); } -void Screen::fillRect(const Rect &box, const byte *rgb) { - if (rgb[0] != TRANSPARENT_RGB || rgb[1] != TRANSPARENT_RGB || rgb[2] != TRANSPARENT_RGB) { - uint color = format.RGBToColor(rgb[0], rgb[1], rgb[2]); +void Screen::fillRect(const Rect &box, uint color) { + if (color != zcolor_Transparent) Graphics::Screen::fillRect(box, color); - } } bool Screen::loadFonts() { @@ -145,22 +142,20 @@ FACES Screen::getFontId(const Common::String &name) { return MONOR; } -int Screen::drawString(const Point &pos, int fontIdx, const byte *rgb, const Common::String &text, int spw) { +int Screen::drawString(const Point &pos, int fontIdx, uint color, const Common::String &text, int spw) { int baseLine = (fontIdx >= PROPR) ? g_conf->_propInfo._baseLine : g_conf->_monoInfo._baseLine; Point pt(pos.x / GLI_SUBPIX, pos.y - baseLine); const Graphics::Font *font = _fonts[fontIdx]; - const uint32 color = format.RGBToColor(rgb[0], rgb[1], rgb[2]); font->drawString(this, text, pt.x, pt.y, w - pt.x, color); pt.x += font->getStringWidth(text); return MIN((int)pt.x, (int)w) * GLI_SUBPIX; } -int Screen::drawStringUni(const Point &pos, int fontIdx, const byte *rgb, const Common::U32String &text, int spw) { +int Screen::drawStringUni(const Point &pos, int fontIdx, uint color, const Common::U32String &text, int spw) { int baseLine = (fontIdx >= PROPR) ? g_conf->_propInfo._baseLine : g_conf->_monoInfo._baseLine; Point pt(pos.x / GLI_SUBPIX, pos.y - baseLine); const Graphics::Font *font = _fonts[fontIdx]; - const uint32 color = format.RGBToColor(rgb[0], rgb[1], rgb[2]); font->drawString(this, text, pt.x, pt.y, w - pt.x, color); pt.x += font->getStringWidth(text); diff --git a/engines/glk/screen.h b/engines/glk/screen.h index 85c99ea75d..f697b55e1e 100644 --- a/engines/glk/screen.h +++ b/engines/glk/screen.h @@ -83,34 +83,34 @@ public: void initialize(); /** - * Fills the screen with a given rgb color + * Fills the screen with a given color */ - void fill(const byte *rgb); + void fill(uint color); /** - * Fill a given area of the screen with an rgb color + * Fill a given area of the screen with a given color */ - void fillRect(const Rect &box, const byte *rgb); + void fillRect(const Rect &box, uint color); /** * Draws a string using the specified font at the given co-ordinates * @param pos Position for the bottom-left corner the text will be drawn with * @param fontIdx Which font to use - * @param rgb RGB tuplet specifying the text color + * @param color Text color * @param text The text to draw * @param spw ?? */ - int drawString(const Point &pos, int fontIdx, const byte *rgb, const Common::String &text, int spw = 0); + int drawString(const Point &pos, int fontIdx, uint color, const Common::String &text, int spw = 0); /** * Draws a unicode string using the specified font at the given co-ordinates * @param pos Position for the bottom-left corner the text will be drawn with * @param fontIdx Which font to use - * @param rgb RGB tuplet specifying the text color + * @param color Text color * @param text The text to draw * @param spw ?? */ - int drawStringUni(const Point &pos, int fontIdx, const byte *rgb, const Common::U32String &text, int spw = 0); + int drawStringUni(const Point &pos, int fontIdx, uint color, const Common::U32String &text, int spw = 0); /** * Get the width in pixels of a string diff --git a/engines/glk/streams.cpp b/engines/glk/streams.cpp index 5776a79de1..f05cc55f88 100644 --- a/engines/glk/streams.cpp +++ b/engines/glk/streams.cpp @@ -236,13 +236,7 @@ void WindowStream::setZColors(uint fg, uint bg) { if (!_writable || !g_conf->_styleHint) return; - byte fore[3], back[3]; - fore[0] = (fg >> 16) & 0xff; - fore[1] = (fg >> 8) & 0xff; - fore[2] = (fg) & 0xff; - back[0] = (bg >> 16) & 0xff; - back[1] = (bg >> 8) & 0xff; - back[2] = (bg) & 0xff; + uint fore = fg, back = bg; if (fg != zcolor_Transparent && fg != zcolor_Cursor) { PropFontInfo *info = &g_conf->_propInfo; @@ -253,18 +247,18 @@ void WindowStream::setZColors(uint fg, uint bg) { Windows::_overrideFgSet = false; Windows::_overrideFgVal = 0; - Common::copy(info->_moreSave, info->_moreSave + 3, info->_moreColor); - Common::copy(info->_caretSave, info->_caretSave + 3, info->_caretColor); - Common::copy(info->_linkSave, info->_linkSave + 3, info->_linkColor); + info->_moreColor = info->_moreSave; + info->_caretColor = info->_caretSave; + info->_linkColor = info->_linkSave; } else if (fg != zcolor_Current) { _window->_attr.fgset = 1; _window->_attr.fgcolor = fg; Windows::_overrideFgSet = true; Windows::_overrideFgVal = fg; - Common::copy(fore, fore + 3, info->_moreColor); - Common::copy(fore, fore + 3, info->_caretColor); - Common::copy(fore, fore + 3, info->_linkColor); + info->_moreColor = fore; + info->_caretColor = fore; + info->_linkColor = fore; } } @@ -275,16 +269,16 @@ void WindowStream::setZColors(uint fg, uint bg) { Windows::_overrideBgSet = false; Windows::_overrideBgVal = 0; - Common::copy(g_conf->_windowSave, g_conf->_windowSave + 3, g_conf->_windowColor); - Common::copy(g_conf->_borderSave, g_conf->_borderSave + 3, g_conf->_borderColor); + g_conf->_windowColor = g_conf->_windowSave; + g_conf->_borderColor = g_conf->_borderSave; } else if (bg != zcolor_Current) { _window->_attr.bgset = 1; _window->_attr.bgcolor = bg; Windows::_overrideBgSet = true; Windows::_overrideBgVal = bg; - Common::copy(back, back + 3, g_conf->_windowColor); - Common::copy(back, back + 3, g_conf->_borderColor); + g_conf->_windowColor = back; + g_conf->_borderColor = back; } } diff --git a/engines/glk/window_graphics.cpp b/engines/glk/window_graphics.cpp index d0f721d5c1..b481aa5ab5 100644 --- a/engines/glk/window_graphics.cpp +++ b/engines/glk/window_graphics.cpp @@ -30,7 +30,7 @@ namespace Glk { GraphicsWindow::GraphicsWindow(Windows *windows, uint rock) : Window(windows, rock), _w(0), _h(0), _dirty(false), _surface(nullptr) { _type = wintype_Graphics; - Common::copy(&_bgColor[0], &_bgColor[3], _bgnd); + _bgColor = _bgnd; } GraphicsWindow::~GraphicsWindow() { @@ -62,9 +62,10 @@ void GraphicsWindow::rearrange(const Rect &box) { if (newhgt < bothhgt) bothhgt = newhgt; + // Create it Graphics::PixelFormat pixelFormat = g_system->getScreenFormat(); newSurface = new Graphics::ManagedSurface(newwid, newhgt, pixelFormat); - newSurface->clear(pixelFormat.RGBToColor(_bgnd[0], _bgnd[1], _bgnd[2])); + newSurface->clear(_bgnd); // If the new surface is equal or bigger than the old one, copy it over if (_surface && bothwid && bothhgt) @@ -147,19 +148,14 @@ void GraphicsWindow::eraseRect(bool whole, const Rect &box) { // zero out hyperlinks for these coordinates g_vm->_selection->putHyperlink(0, hx0, hy0, hx1, hy1); - _surface->fillRect(Rect(x0, y0, x1, y1), _surface->format.RGBToColor(_bgnd[0], _bgnd[1], _bgnd[2])); + _surface->fillRect(Rect(x0, y0, x1, y1), _bgnd); touch(); } void GraphicsWindow::fillRect(uint color, const Rect &box) { - unsigned char col[3]; int x0 = box.left, y0 = box.top, x1 = box.right, y1 = box.bottom; int hx0, hx1, hy0, hy1; - col[0] = (color >> 16) & 0xff; - col[1] = (color >> 8) & 0xff; - col[2] = (color >> 0) & 0xff; - if (x0 < 0) x0 = 0; if (y0 < 0) y0 = 0; if (x1 < 0) x1 = 0; @@ -177,7 +173,7 @@ void GraphicsWindow::fillRect(uint color, const Rect &box) { // zero out hyperlinks for these coordinates g_vm->_selection->putHyperlink(0, hx0, hy0, hx1, hy1); - _surface->fillRect(Rect(x0, y0, x1, y1), MKTAG(col[0], col[1], col[2], 0)); + _surface->fillRect(Rect(x0, y0, x1, y1), color); touch(); } @@ -241,9 +237,7 @@ void GraphicsWindow::getSize(uint *width, uint *height) const { } void GraphicsWindow::setBackgroundColor(uint color) { - _bgnd[0] = (color >> 16) & 0xff; - _bgnd[1] = (color >> 8) & 0xff; - _bgnd[2] = (color >> 0) & 0xff; + _bgnd = color; } void GraphicsWindow::click(const Point &newPos) { diff --git a/engines/glk/window_graphics.h b/engines/glk/window_graphics.h index 4d8f1a31c6..a3fe6db856 100644 --- a/engines/glk/window_graphics.h +++ b/engines/glk/window_graphics.h @@ -37,7 +37,7 @@ private: void drawPicture(Picture *src, int x0, int y0, int width, int height, uint linkval); public: - unsigned char _bgnd[3]; + uint _bgnd; bool _dirty; uint _w, _h; Graphics::ManagedSurface *_surface; diff --git a/engines/glk/window_text_buffer.cpp b/engines/glk/window_text_buffer.cpp index 4332a5c595..b27fb36661 100644 --- a/engines/glk/window_text_buffer.cpp +++ b/engines/glk/window_text_buffer.cpp @@ -382,7 +382,7 @@ void TextBufferWindow::putCharUni(uint32 ch) { int saved; int i; int linelen; - byte *color; + uint color; gli_tts_speak(&ch, 1); @@ -788,7 +788,7 @@ void TextBufferWindow::redraw() { int a, b; uint link; int font; - const byte *color; + uint color; int i; int hx0, hx1, hy0, hy1; int selrow, selchar, sx0, sx1, selleft, selright; diff --git a/engines/glk/window_text_grid.cpp b/engines/glk/window_text_grid.cpp index c32139019b..971d35a0bb 100644 --- a/engines/glk/window_text_grid.cpp +++ b/engines/glk/window_text_grid.cpp @@ -572,7 +572,7 @@ void TextGridWindow::redraw() { int i, a, b, k, o; uint link; int font; - const byte *fgcolor, *bgcolor; + uint fgcolor, bgcolor; Screen &screen = *g_vm->_screen; Window::redraw(); diff --git a/engines/glk/windows.cpp b/engines/glk/windows.cpp index 624defa9f5..ff3a57b980 100644 --- a/engines/glk/windows.cpp +++ b/engines/glk/windows.cpp @@ -40,14 +40,14 @@ bool Windows::_overrideBgSet; bool Windows::_forceRedraw; bool Windows::_claimSelect; bool Windows::_moreFocus; -int Windows::_overrideFgVal; -int Windows::_overrideBgVal; -int Windows::_zcolor_fg; -int Windows::_zcolor_bg; -byte Windows::_zcolor_LightGrey[3]; -byte Windows::_zcolor_Foreground[3]; -byte Windows::_zcolor_Background[3]; -byte Windows::_zcolor_Bright[3]; +uint Windows::_overrideFgVal; +uint Windows::_overrideBgVal; +uint Windows::_zcolor_fg; +uint Windows::_zcolor_bg; +uint Windows::_zcolor_LightGrey; +uint Windows::_zcolor_Foreground; +uint Windows::_zcolor_Background; +uint Windows::_zcolor_Bright; /*--------------------------------------------------------------------------*/ @@ -64,10 +64,9 @@ Windows::Windows(Graphics::Screen *screen) : _screen(screen), _windowList(nullpt _zcolor_fg = _zcolor_bg = 0; _drawSelect = false; - _zcolor_LightGrey[0] = _zcolor_LightGrey[1] = _zcolor_LightGrey[2] = 181; - _zcolor_Foreground[0] = _zcolor_Foreground[1] = _zcolor_Foreground[2] = 0; - _zcolor_Background[0] = _zcolor_Background[1] = _zcolor_Background[2] = 0; - _zcolor_Bright[0] = _zcolor_Bright[1] = _zcolor_Bright[2] = 0; + _zcolor_LightGrey = g_system->getScreenFormat().RGBToColor(181, 181, 181); + _zcolor_Foreground = _zcolor_Background = 0; + _zcolor_Bright = 0; } Windows::~Windows() { @@ -437,11 +436,16 @@ void Windows::repaint(const Rect &box) { g_vm->_events->redraw(); } -byte *Windows::rgbShift(byte *rgb) { - _zcolor_Bright[0] = (rgb[0] + 0x30) < 0xff ? (rgb[0] + 0x30) : 0xff; - _zcolor_Bright[1] = (rgb[1] + 0x30) < 0xff ? (rgb[1] + 0x30) : 0xff; - _zcolor_Bright[2] = (rgb[2] + 0x30) < 0xff ? (rgb[2] + 0x30) : 0xff; +uint Windows::rgbShift(uint color) { + uint8 r, g, b; + Graphics::PixelFormat pf = g_system->getScreenFormat(); + pf.colorToRGB(color, r, g, b); + r = ((uint)r + 0x30) < 0xff ? ((uint)r + 0x30) : 0xff; + g = ((uint)g + 0x30) < 0xff ? ((uint)g + 0x30) : 0xff; + b = ((uint)b + 0x30) < 0xff ? ((uint)b + 0x30) : 0xff; + + _zcolor_Bright = pf.RGBToColor(r, g, b); return _zcolor_Bright; } @@ -510,8 +514,8 @@ Window::Window(Windows *windows, uint rock) : _windows(windows), _rock(rock), _attr.bgcolor = 0; _attr.hyper = 0; - Common::copy(&g_conf->_windowColor[0], &g_conf->_windowColor[3], &_bgColor[0]); - Common::copy(&g_conf->_propInfo._moreColor[0], &g_conf->_propInfo._moreColor[3], _fgColor); + _bgColor = g_conf->_windowColor; + _fgColor = g_conf->_propInfo._moreColor; _dispRock.num = 0; Streams &streams = *g_vm->_streams; @@ -598,7 +602,7 @@ void Window::requestLineEventUni(uint32 *buf, uint maxlen, uint initlen) { void Window::redraw() { if (Windows::_forceRedraw) { - unsigned char *color = Windows::_overrideBgSet ? g_conf->_windowColor : _bgColor; + uint color = Windows::_overrideBgSet ? g_conf->_windowColor : _bgColor; int y0 = _yAdj ? _bbox.top - _yAdj : _bbox.top; g_vm->_screen->fillRect(Rect(_bbox.left, y0, _bbox.right, _bbox.bottom), color); } @@ -720,6 +724,14 @@ BlankWindow::BlankWindow(Windows *windows, uint rock) : Window(windows, rock) { /*--------------------------------------------------------------------------*/ +WindowStyle::WindowStyle(const WindowStyleStatic &src) : font(src.font), reverse(src.reverse) { + Graphics::PixelFormat pf = g_system->getScreenFormat(); + fg = pf.RGBToColor(src.fg[0], src.fg[1], src.fg[2]); + bg = pf.RGBToColor(src.bg[0], src.bg[1], src.bg[1]); +} + +/*--------------------------------------------------------------------------*/ + void Attributes::clear() { fgset = 0; bgset = 0; @@ -730,7 +742,7 @@ void Attributes::clear() { style = 0; } -const byte *Attributes::attrBg(const WindowStyle *styles) { +uint Attributes::attrBg(const WindowStyle *styles) { int revset = reverse || (styles[style].reverse && !Windows::_overrideReverse); int zfset = fgset ? fgset : Windows::_overrideFgSet; @@ -740,16 +752,12 @@ const byte *Attributes::attrBg(const WindowStyle *styles) { int zback = bgset ? bgcolor : Windows::_overrideBgVal; if (zfset && zfore != Windows::_zcolor_fg) { - Windows::_zcolor_Foreground[0] = (zfore >> 16) & 0xff; - Windows::_zcolor_Foreground[1] = (zfore >> 8) & 0xff; - Windows::_zcolor_Foreground[2] = (zfore) & 0xff; + Windows::_zcolor_Foreground = zfore; Windows::_zcolor_fg = zfore; } if (zbset && zback != Windows::_zcolor_bg) { - Windows::_zcolor_Background[0] = (zback >> 16) & 0xff; - Windows::_zcolor_Background[1] = (zback >> 8) & 0xff; - Windows::_zcolor_Background[2] = (zback) & 0xff; + Windows::_zcolor_Background = zback; Windows::_zcolor_bg = zback; } @@ -764,14 +772,14 @@ const byte *Attributes::attrBg(const WindowStyle *styles) { return Windows::rgbShift(Windows::_zcolor_Foreground); else return Windows::_zcolor_Foreground; - else if (zbset && !memcmp(styles[style].fg, Windows::_zcolor_Background, 3)) + else if (zbset && styles[style].fg == Windows::_zcolor_Background) return Windows::_zcolor_LightGrey; else return styles[style].fg; } } -const byte *Attributes::attrFg(const WindowStyle *styles) { +uint Attributes::attrFg(const WindowStyle *styles) { int revset = reverse || (styles[style].reverse && !Windows::_overrideReverse); int zfset = fgset ? fgset : Windows::_overrideFgSet; @@ -781,16 +789,12 @@ const byte *Attributes::attrFg(const WindowStyle *styles) { int zback = bgset ? bgcolor : Windows::_overrideBgVal; if (zfset && zfore != Windows::_zcolor_fg) { - Windows::_zcolor_Foreground[0] = (zfore >> 16) & 0xff; - Windows::_zcolor_Foreground[1] = (zfore >> 8) & 0xff; - Windows::_zcolor_Foreground[2] = (zfore) & 0xff; + Windows::_zcolor_Foreground = zfore; Windows::_zcolor_fg = zfore; } if (zbset && zback != Windows::_zcolor_bg) { - Windows::_zcolor_Background[0] = (zback >> 16) & 0xff; - Windows::_zcolor_Background[1] = (zback >> 8) & 0xff; - Windows::_zcolor_Background[2] = (zback) & 0xff; + Windows::_zcolor_Background = zback; Windows::_zcolor_bg = zback; } @@ -800,7 +804,7 @@ const byte *Attributes::attrFg(const WindowStyle *styles) { return Windows::rgbShift(Windows::_zcolor_Foreground); else return Windows::_zcolor_Foreground; - else if (zbset && !memcmp(styles[style].fg, Windows::_zcolor_Background, 3)) + else if (zbset && styles[style].fg == Windows::_zcolor_Background) return Windows::_zcolor_LightGrey; else return styles[style].fg; diff --git a/engines/glk/windows.h b/engines/glk/windows.h index c917d2f04b..acb727e39e 100644 --- a/engines/glk/windows.h +++ b/engines/glk/windows.h @@ -137,15 +137,15 @@ public: static bool _forceRedraw; static bool _claimSelect; static bool _moreFocus; - static int _overrideFgVal; - static int _overrideBgVal; - static int _zcolor_fg, _zcolor_bg; - static byte _zcolor_LightGrey[3]; - static byte _zcolor_Foreground[3]; - static byte _zcolor_Background[3]; - static byte _zcolor_Bright[3]; - - static byte *rgbShift(byte *rgb); + static uint _overrideFgVal; + static uint _overrideBgVal; + static uint _zcolor_fg, _zcolor_bg; + static uint _zcolor_LightGrey; + static uint _zcolor_Foreground; + static uint _zcolor_Background; + static uint _zcolor_Bright; + + static uint rgbShift(uint color); public: /** * Constructor @@ -240,13 +240,33 @@ public: }; /** - * Window styles + * Used for the static definition of default styles */ -struct WindowStyle { +struct WindowStyleStatic { FACES font; byte bg[3]; byte fg[3]; bool reverse; +}; + +/** + * Window styles + */ +struct WindowStyle { + FACES font; + uint bg; + uint fg; + bool reverse; + + /** + * Constructor + */ + WindowStyle() : font(MONOR), fg(0), bg(0), reverse(false) {} + + /** + * Constructor + */ + WindowStyle(const WindowStyleStatic &src); /** * Equality comparison @@ -345,12 +365,12 @@ struct Attributes { /** * Return the background color for the current font style */ - const byte *attrBg(const WindowStyle *styles); + uint attrBg(const WindowStyle *styles); /** * Return the foreground color for the current font style */ - const byte *attrFg(const WindowStyle *styles); + uint attrFg(const WindowStyle *styles); /** * Get the font for the current font style @@ -392,8 +412,7 @@ public: uint _termCt; Attributes _attr; - byte _bgColor[3]; - byte _fgColor[3]; + uint _bgColor, _fgColor; gidispatch_rock_t _dispRock; public: |