aboutsummaryrefslogtreecommitdiff
path: root/engines/cine/gfx.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/cine/gfx.cpp')
-rw-r--r--engines/cine/gfx.cpp87
1 files changed, 66 insertions, 21 deletions
diff --git a/engines/cine/gfx.cpp b/engines/cine/gfx.cpp
index 7a988227f6..636c0cf8d9 100644
--- a/engines/cine/gfx.cpp
+++ b/engines/cine/gfx.cpp
@@ -113,7 +113,7 @@ FWRenderer::FWRenderer() : _background(NULL), _backupPal(), _cmd(""),
assert(_backBuffer);
memset(_backBuffer, 0, _screenSize);
- memset(_bgName, 0, sizeof (_bgName));
+ memset(_bgName, 0, sizeof(_bgName));
}
@@ -249,7 +249,7 @@ void FWRenderer::drawCommand() {
unsigned int i;
int x = 10, y = _cmdY;
- if(disableSystemMenu == 0) {
+ if (disableSystemMenu == 0) {
drawPlainBox(x, y, 301, 11, 0);
drawBorder(x - 1, y - 1, 302, 12, 2);
@@ -307,7 +307,7 @@ void FWRenderer::drawMessage(const char *str, int x, int y, int width, int color
i++;
line = fitLine(str + i, tw, words, cw);
- if ( str[i + line] != '\0' && str[i + line] != 0x7C && words) {
+ if (str[i + line] != '\0' && str[i + line] != 0x7C && words) {
space = (tw - cw) / words;
extraSpace = (tw - cw) % words;
} else {
@@ -471,6 +471,41 @@ int FWRenderer::drawChar(char character, int x, int y) {
return x;
}
+/**
+ * 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
+ */
+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;
@@ -969,20 +1004,29 @@ void SelectionMenu::drawMenu(FWRenderer &r, bool top) {
charX = x + 4;
if (i == _selection) {
+ int color;
+
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);
+ 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();
- 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);
+ }
+ }
}
}
@@ -1244,6 +1288,7 @@ void OSRenderer::renderOverlay(const Common::List<overlay>::iterator &it) {
sprite = &g_cine->_animDataTable[g_cine->_objectTable[it->objIdx].frame];
drawSprite(&(*it), sprite->data(), sprite->_realWidth, sprite->_height, _backBuffer, g_cine->_objectTable[it->objIdx].x, g_cine->_objectTable[it->objIdx].y, g_cine->_objectTable[it->objIdx].part, sprite->_bpp);
break;
+
// game message
case 2:
if (it->objIdx >= g_cine->_messageTable.size()) {
@@ -1300,7 +1345,7 @@ void OSRenderer::renderOverlay(const Common::List<overlay>::iterator &it) {
height = obj->costume;
drawPlainBox(obj->x, obj->y, width, height, color);
debug(5, "renderOverlay: type=%d, x=%d, y=%d, width=%d, height=%d, color=%d",
- it->type, obj->x, obj->y, width, height, color);
+ it->type, obj->x, obj->y, width, height, color);
break;
// something else
@@ -1424,7 +1469,7 @@ void OSRenderer::selectBg(unsigned int idx) {
if (_bgTable[idx].bg) {
assert(_bgTable[idx].pal.isValid() && !(_bgTable[idx].pal.empty()));
- _currentBg = idx;
+ _currentBg = idx;
} else
warning("OSRenderer::selectBg(%d) - attempt to select null background", idx);
reloadPalette();
@@ -1750,23 +1795,23 @@ void OSRenderer::drawSprite(overlay *overlayPtr, const byte *spritePtr, int16 wi
// draw the mask based on next objects in the list
Common::List<overlay>::iterator it;
- for (it = g_cine->_overlayList.begin(); it != g_cine->_overlayList.end(); ++it) {
- if(&(*it) == overlayPtr) {
+ for (it = g_cine->_overlayList.begin(); it != g_cine->_overlayList.end(); ++it) {
+ if (&(*it) == overlayPtr) {
break;
}
}
- while(it != g_cine->_overlayList.end()) {
+ while (it != g_cine->_overlayList.end()) {
overlay *pCurrentOverlay = &(*it);
if ((pCurrentOverlay->type == 5) || ((pCurrentOverlay->type == 21) && (pCurrentOverlay->x == overlayPtr->objIdx))) {
AnimData *sprite = &g_cine->_animDataTable[g_cine->_objectTable[it->objIdx].frame];
if (pMask == NULL) {
- pMask = new byte[width*height];
+ pMask = new byte[width * height];
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
- byte spriteColor= spritePtr[width * i + j];
+ byte spriteColor = spritePtr[width * i + j];
pMask[width * i + j] = spriteColor;
}
}
@@ -1777,7 +1822,7 @@ void OSRenderer::drawSprite(overlay *overlayPtr, const byte *spritePtr, int16 wi
int inMaskX = (g_cine->_objectTable[it->objIdx].x + i) - x;
int inMaskY = (g_cine->_objectTable[it->objIdx].y + j) - y;
- if (inMaskX >=0 && inMaskX < width) {
+ if (inMaskX >= 0 && inMaskX < width) {
if (inMaskY >= 0 && inMaskY < height) {
if (sprite->_bpp == 1) {
if (!sprite->getColor(i, j)) {
@@ -1793,7 +1838,7 @@ void OSRenderer::drawSprite(overlay *overlayPtr, const byte *spritePtr, int16 wi
}
// now, draw with the mask we created
- if(pMask) {
+ if (pMask) {
spritePtr = pMask;
}
@@ -1808,7 +1853,7 @@ void OSRenderer::drawSprite(overlay *overlayPtr, const byte *spritePtr, int16 wi
destPtr += i * 320;
for (int j = 0; j < width; j++) {
- byte color= *(spritePtr++);
+ byte color = *(spritePtr++);
if ((transparentColor != color) && x + j >= 0 && x + j < 320 && i + y >= 0 && i + y < 200) {
*(destPtr++) = color;
} else {