From 33cdddb7ec48f208d8873120c93aca1c17d7026f Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Fri, 7 Sep 2012 00:19:23 +0200 Subject: CINE: Implement proper text coloring in selection menus for Amiga. Tested with FW Amiga. --- engines/cine/gfx.cpp | 47 ++++++++++++++++++++++++++++++++++++++++------- engines/cine/gfx.h | 1 + 2 files changed, 41 insertions(+), 7 deletions(-) (limited to 'engines/cine') diff --git a/engines/cine/gfx.cpp b/engines/cine/gfx.cpp index 7a988227f6..b5b427207b 100644 --- a/engines/cine/gfx.cpp +++ b/engines/cine/gfx.cpp @@ -471,6 +471,38 @@ int FWRenderer::drawChar(char character, int x, int y) { return x; } +/** + * Clears the character glyph to black + * @param character Character to undraw + * @param x Character coordinate + * @param y Character coordinate + */ +int FWRenderer::undrawChar(char character, int x, int y) { + int width, idx; + + if (character == ' ') { + x += 5; + } else if ((width = g_cine->_textHandler.fontParamTable[(unsigned char)character].characterWidth)) { + idx = g_cine->_textHandler.fontParamTable[(unsigned char)character].characterIdx; + const byte *sprite = g_cine->_textHandler.textTable[idx][FONT_DATA]; + for (uint i = 0; i < FONT_HEIGHT; ++i) { + byte *dst = _backBuffer + (y + i) * 320 + x; + for (uint j = 0; j < FONT_WIDTH; ++j, ++dst) { + // The original does this based on whether bit 1 of the pixel + // is set. Since that's the only bit ever set in (FW) this + // check should be fine. + // TODO: Check how Operation Stealth Amiga works + if (*sprite++) { + *dst = 0; + } + } + } + x += width + 1; + } + + return x; +} + int FWRenderer::getStringWidth(const char *str) { const char *p = str; int width = 0; @@ -970,19 +1002,20 @@ void SelectionMenu::drawMenu(FWRenderer &r, bool top) { if (i == _selection) { if (isAmiga) { - // The original Amiga version is using a different highlight color here, - // but with our current code it is not possible to change the text color, - // thus we can not use the Amiga's color, since otherwise the text - // wouldn't be visible anymore. - r.drawPlainBox(charX, lineY, _width - 8, FONT_HEIGHT, top ? r._messageBg/*2*/ : 18); + r.drawPlainBox(charX, lineY, _width - 8, FONT_HEIGHT, top ? 2 : 18); } else { r.drawPlainBox(charX, lineY, _width - 8, 9, 0); } } const int size = _elements[i].size(); - for (int j = 0; j < size; ++j) - charX = r.drawChar(_elements[i][j], charX, lineY); + for (int j = 0; j < size; ++j) { + if (isAmiga && i == _selection) { + charX = r.undrawChar(_elements[i][j], charX, lineY); + } else { + charX = r.drawChar(_elements[i][j], charX, lineY); + } + } } } diff --git a/engines/cine/gfx.h b/engines/cine/gfx.h index 3434cf9fc2..10bf27312c 100644 --- a/engines/cine/gfx.h +++ b/engines/cine/gfx.h @@ -152,6 +152,7 @@ protected: void drawBorder(int x, int y, int width, int height, byte color); void drawDoubleBorder(int x, int y, int width, int height, byte color); virtual int drawChar(char character, int x, int y); + virtual int undrawChar(char character, int x, int y); void drawLine(int x, int y, int width, int height, byte color); void remaskSprite(byte *mask, Common::List::iterator it); virtual void drawBackground(); -- cgit v1.2.3 From da4e3c4f2aa2f426971f9213f98486d8e484e2b8 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Fri, 7 Sep 2012 00:40:42 +0200 Subject: CINE: Make selection menu focus rectangle match the original size. Compared against real FW Amiga under UAE and FW Dos under DOSBox. --- engines/cine/gfx.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'engines/cine') diff --git a/engines/cine/gfx.cpp b/engines/cine/gfx.cpp index b5b427207b..030bee4fad 100644 --- a/engines/cine/gfx.cpp +++ b/engines/cine/gfx.cpp @@ -1001,11 +1001,19 @@ void SelectionMenu::drawMenu(FWRenderer &r, bool top) { charX = x + 4; if (i == _selection) { + int color; + if (isAmiga) { - r.drawPlainBox(charX, lineY, _width - 8, FONT_HEIGHT, top ? 2 : 18); + if (top) { + color = 2; + } else { + color = 18; + } } else { - r.drawPlainBox(charX, lineY, _width - 8, 9, 0); + color = 0; } + + r.drawPlainBox(x + 2, lineY - 1, _width - 3, 9, color); } const int size = _elements[i].size(); -- cgit v1.2.3 From 855a0d331fa7d0ba8745c43e0e2311717987e33d Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Fri, 7 Sep 2012 00:52:59 +0200 Subject: CINE: Explain the name "undrawChar" and add a possible TODO. --- engines/cine/gfx.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'engines/cine') diff --git a/engines/cine/gfx.cpp b/engines/cine/gfx.cpp index 030bee4fad..6e313ab224 100644 --- a/engines/cine/gfx.cpp +++ b/engines/cine/gfx.cpp @@ -473,6 +473,9 @@ int FWRenderer::drawChar(char character, int x, int y) { /** * Clears the character glyph to black + * This function is called "undrawChar", because the original only applies + * this drawing after the original glyph has been drawn. + * Possible TODO: Find a better name. * @param character Character to undraw * @param x Character coordinate * @param y Character coordinate -- cgit v1.2.3