diff options
Diffstat (limited to 'engines/kyra/screen_eob.cpp')
-rw-r--r-- | engines/kyra/screen_eob.cpp | 418 |
1 files changed, 144 insertions, 274 deletions
diff --git a/engines/kyra/screen_eob.cpp b/engines/kyra/screen_eob.cpp index ae75c111b4..ae62e522e7 100644 --- a/engines/kyra/screen_eob.cpp +++ b/engines/kyra/screen_eob.cpp @@ -52,10 +52,10 @@ Screen_EoB::Screen_EoB(EoBCoreEngine *vm, OSystem *system) : Screen(vm, system, _cgaScaleTable = 0; _gfxMaxY = 0; _egaDitheringTable = 0; - _egaPixelValueTable = 0; + _egaDitheringTempPage = 0; _cgaMappingDefault = 0; _cgaDitheringTables[0] = _cgaDitheringTables[1] = 0; - _useLoResEGA = _useHiResEGADithering = false; + _useHiResEGADithering = false; } Screen_EoB::~Screen_EoB() { @@ -63,18 +63,12 @@ Screen_EoB::~Screen_EoB() { delete[] _dsTempPage; delete[] _cgaScaleTable; delete[] _egaDitheringTable; - delete[] _egaPixelValueTable; + delete[] _egaDitheringTempPage; delete[] _cgaDitheringTables[0]; delete[] _cgaDitheringTables[1]; } bool Screen_EoB::init() { - // Define hi-res pages for EGA mode in EOB II - if (_vm->gameFlags().useHiRes) { - for (int i = 0; i < 8; i++) - _pageScaleFactor[i] = 2; - } - if (Screen::init()) { int temp; _gfxMaxY = _vm->staticres()->loadRawData(kEoBBaseExpObjectY, temp); @@ -98,13 +92,9 @@ bool Screen_EoB::init() { if (_vm->gameFlags().useHiRes && _renderMode == Common::kRenderEGA) { _useHiResEGADithering = true; _egaDitheringTable = new uint8[256]; - _egaPixelValueTable = new uint8[256]; - for (int i = 0; i < 256; i++) { - _egaDitheringTable[i] = i & 0x0f; - _egaPixelValueTable[i] = i & 0x0f; - } - } else if (_renderMode == Common::kRenderEGA) { - _useLoResEGA = true; + _egaDitheringTempPage = new uint8[SCREEN_W * 2 * SCREEN_H * 2]; + for (int i = 0; i < 256; i++) + _egaDitheringTable[i] = i & 0x0F; } else if (_renderMode == Common::kRenderCGA) { _cgaMappingDefault = _vm->staticres()->loadRawData(kEoB1CgaMappingDefault, temp); _cgaDitheringTables[0] = new uint16[256]; @@ -115,7 +105,7 @@ bool Screen_EoB::init() { _cgaScaleTable = new uint8[256]; memset(_cgaScaleTable, 0, 256 * sizeof(uint8)); for (int i = 0; i < 256; i++) - _cgaScaleTable[i] = ((i & 0xf0) >> 2) | (i & 0x03); + _cgaScaleTable[i] = ((i & 0xF0) >> 2) | (i & 0x03); } return true; @@ -144,14 +134,20 @@ void Screen_EoB::setMouseCursor(int x, int y, const byte *shape, const uint8 *ov int mouseH = (shape[3]); int colorKey = (_renderMode == Common::kRenderCGA) ? 0 : _cursorColorKey; - uint8 *cursor = new uint8[mouseW * _pageScaleFactor[6] * mouseH * _pageScaleFactor[6]]; + int scaleFactor = _useHiResEGADithering ? 2 : 1; + + uint8 *cursor = new uint8[mouseW * scaleFactor * mouseH * scaleFactor]; // We use memset and copyBlockToPage instead of fillRect to make sure that the // color key 0xFF doesn't get converted into EGA color - memset(cursor, colorKey, mouseW * _pageScaleFactor[6] * mouseH * _pageScaleFactor[6]); - copyBlockToPage(6, 0, 0, mouseW, mouseH, cursor); + memset(cursor, colorKey, mouseW * scaleFactor * mouseH * scaleFactor); + copyBlockToPage(6, 0, 0, mouseW * scaleFactor, mouseH * scaleFactor, cursor); drawShape(6, shape, 0, 0, 0, 2, ovl); CursorMan.showMouse(false); - copyRegionToBuffer(6, 0, 0, mouseW, mouseH, cursor); + + if (_useHiResEGADithering) + ditherRect(getCPagePtr(6), cursor, mouseW * scaleFactor, mouseW, mouseH, colorKey); + else + copyRegionToBuffer(6, 0, 0, mouseW, mouseH, cursor); // Mouse cursor post processing for CGA mode. Unlike the original (which uses drawShape for the mouse cursor) // the cursor manager cannot know whether a pixel value of 0 is supposed to be black or transparent. Thus, we @@ -176,7 +172,7 @@ void Screen_EoB::setMouseCursor(int x, int y, const byte *shape, const uint8 *ov } } - CursorMan.replaceCursor(cursor, mouseW * _pageScaleFactor[6], mouseH * _pageScaleFactor[6], x, y, colorKey); + CursorMan.replaceCursor(cursor, mouseW * scaleFactor, mouseH * scaleFactor, x, y, colorKey); if (isMouseVisible()) CursorMan.showMouse(true); delete[] cursor; @@ -192,19 +188,6 @@ void Screen_EoB::loadFileDataToPage(Common::SeekableReadStream *s, int pageNum, s->read(_pagePtrs[pageNum], size); } -void Screen_EoB::printText(const char *str, int x, int y, uint8 color1, uint8 color2) { - if (_useHiResEGADithering) { - // This is sort of an abuse of the text color map. But since EOB doesn't use it anyway - // and the font drawing code needs access to both the original color values and the - // EGA dithering colors we pass them on like this. - uint8 cmap[2]; - cmap[0] = _egaDitheringTable[color2]; - cmap[1] = _egaDitheringTable[color1]; - setTextColor(cmap, 2, 3); - } - Screen::printText(str, x, y, color1, color2); -} - void Screen_EoB::printShadedText(const char *string, int x, int y, int col1, int col2) { printText(string, x - 1, y, 12, col2); printText(string, x, y + 1, 12, 0); @@ -272,32 +255,19 @@ void Screen_EoB::convertPage(int srcPage, int dstPage, const uint8 *cgaMapping) if (cgaMapping) generateCGADitheringTables(cgaMapping); - uint16 *d = (uint16*)dst; + uint16 *d = (uint16 *)dst; uint8 tblSwitch = 0; for (int height = SCREEN_H; height; height--) { const uint16 *table = _cgaDitheringTables[(tblSwitch++) & 1]; for (int width = SCREEN_W / 2; width; width--) { - WRITE_LE_UINT16(d++, table[((src[1] & 0x0f) << 4) | (src[0] & 0x0f)]); + WRITE_LE_UINT16(d++, table[((src[1] & 0x0F) << 4) | (src[0] & 0x0F)]); src += 2; } } - - } else if (_useHiResEGADithering) { - for (int height = SCREEN_H; height; height--) { - uint8 *dst2 = dst + SCREEN_W * 2; - for (int width = SCREEN_W; width; width--) { - uint8 in = _egaDitheringTable[*src++]; - *dst++ = *dst2++ = in >> 4; - *dst++ = *dst2++ = in & 0x0f; - } - dst += (SCREEN_W * 2); - } - - } else if (_renderMode == Common::kRenderEGA) { + } else if (_renderMode == Common::kRenderEGA && !_useHiResEGADithering) { uint32 len = SCREEN_W * SCREEN_H; while (len--) - *dst++ = *src++ & 0x0f; - + *dst++ = *src++ & 0x0F; } else { copyPage(srcPage, dstPage); } @@ -306,111 +276,6 @@ void Screen_EoB::convertPage(int srcPage, int dstPage, const uint8 *cgaMapping) _forceFullUpdate = true; } -void Screen_EoB::fillRect(int x1, int y1, int x2, int y2, uint8 color, int pageNum, bool xored) { - if (!_useHiResEGADithering) { - Screen::fillRect(x1, y1, x2, y2, color, pageNum, xored); - return; - } - - assert(x2 < SCREEN_W && y2 < SCREEN_H); - if (pageNum == -1) - pageNum = _curPage; - - uint16 pitch = (SCREEN_W - (x2 - x1 + 1)) * _pageScaleFactor[pageNum]; - uint8 col1 = (_egaDitheringTable[color] >> 4); - uint8 col2 = (_egaDitheringTable[color] & 0x0f); - - x1 *= _pageScaleFactor[pageNum]; - y1 *= _pageScaleFactor[pageNum]; - x2 *= _pageScaleFactor[pageNum]; - y2 *= _pageScaleFactor[pageNum]; - uint16 w = x2 - x1 + _pageScaleFactor[pageNum]; - uint16 h = y2 - y1 + _pageScaleFactor[pageNum]; - - uint8 *dst = getPagePtr(pageNum) + y1 * SCREEN_W * _pageScaleFactor[pageNum] + x1; - if (pageNum == 0 || pageNum == 1) - addDirtyRect(x1, y1, w, h); - - while (h--) { - for (uint16 w1 = w; w1; w1 -= 2) { - *dst++ = col1; - *dst++ = col2; - } - dst += pitch; - } -} - -void Screen_EoB::drawLine(bool vertical, int x, int y, int length, int color) { - if (!_useHiResEGADithering) { - Screen::drawLine(vertical, x, y, length, color); - return; - } - - uint16 pitch = (SCREEN_W - 1) * _pageScaleFactor[_curPage]; - uint8 col1 = (_egaDitheringTable[color] >> 4); - uint8 col2 = (_egaDitheringTable[color] & 0x0f); - - x *= _pageScaleFactor[_curPage]; - y *= _pageScaleFactor[_curPage]; - length *= _pageScaleFactor[_curPage]; - uint8 *ptr = getPagePtr(_curPage) + y * SCREEN_W * _pageScaleFactor[_curPage] + x; - uint8 *ptr2 = ptr + SCREEN_W * _pageScaleFactor[_curPage]; - - if (vertical) { - assert((y + length) <= SCREEN_H * _pageScaleFactor[_curPage]); - int currLine = 0; - while (currLine < length) { - *ptr++ = col1; - *ptr++ = col2; - ptr += pitch; - currLine++; - } - } else { - assert((x + length) <= SCREEN_W * _pageScaleFactor[_curPage]); - int currLine = 0; - while (currLine < length) { - *ptr++ = *ptr2++ = col1; - *ptr++ = *ptr2++ = col2; - currLine += 2; - } - } - - if (_curPage == 0 || _curPage == 1) - addDirtyRect(x, y, (vertical) ? _pageScaleFactor[_curPage] : length, (vertical) ? length : _pageScaleFactor[_curPage]); -} - -uint8 Screen_EoB::getPagePixel(int pageNum, int x, int y) { - if (!_useHiResEGADithering) - return Screen::getPagePixel(pageNum, x, y); - - x *= _pageScaleFactor[_curPage]; - y *= _pageScaleFactor[_curPage]; - uint8 *pos = &_pagePtrs[pageNum][y * SCREEN_W * _pageScaleFactor[_curPage] + x]; - - return _egaPixelValueTable[(pos[0] << 4) | (pos[1] & 0x0f)]; -} - -void Screen_EoB::setPagePixel(int pageNum, int x, int y, uint8 color) { - if (!_useHiResEGADithering) { - Screen::setPagePixel(pageNum, x, y, color); - return; - } - - assert(pageNum < SCREEN_PAGE_NUM); - assert(x >= 0 && x < SCREEN_W && y >= 0 && y < SCREEN_H); - - x *= _pageScaleFactor[_curPage]; - y *= _pageScaleFactor[_curPage]; - - if (pageNum == 0 || pageNum == 1) - addDirtyRect(x, y, _pageScaleFactor[pageNum], _pageScaleFactor[pageNum]); - - uint8 *pos = &_pagePtrs[pageNum][y * SCREEN_W * _pageScaleFactor[_curPage] + x]; - uint8 *pos2 = pos + SCREEN_W * _pageScaleFactor[_curPage]; - pos[0] = pos2[0] = _egaDitheringTable[color] >> 4; - pos[1] = pos2[1] = _egaDitheringTable[color] & 0x0f; -} - void Screen_EoB::setScreenPalette(const Palette &pal) { if (_useHiResEGADithering && pal.getNumColors() != 16) { generateEGADitheringTable(pal); @@ -444,7 +309,7 @@ uint8 *Screen_EoB::encodeShape(uint16 x, uint16 y, uint16 w, uint16 h, bool enco uint8 *srcLineStart = getPagePtr(_curPage | 1) + y * 320 + (x << 3); uint8 *src = srcLineStart; - if (_useLoResEGA) + if (_renderMode == Common::kRenderEGA && !_useHiResEGADithering) encode8bit = false; if (_renderMode == Common::kRenderCGA) { @@ -456,9 +321,9 @@ uint8 *Screen_EoB::encodeShape(uint16 x, uint16 y, uint16 w, uint16 h, bool enco uint8 *dst = shp; *dst++ = 4; - *dst++ = (h & 0xff); - *dst++ = (w & 0xff); - *dst++ = (h & 0xff); + *dst++ = (h & 0xFF); + *dst++ = (w & 0xFF); + *dst++ = (h & 0xFF); uint8 *dst2 = dst + (h * (w << 1)); @@ -469,8 +334,8 @@ uint8 *Screen_EoB::encodeShape(uint16 x, uint16 y, uint16 w, uint16 h, bool enco const uint16 *table = _cgaDitheringTables[(tblSwitch++) & 1]; while (w1--) { - uint16 p0 = table[((src[1] & 0x0f) << 4) | (src[0] & 0x0f)]; - uint16 p1 = table[((src[3] & 0x0f) << 4) | (src[2] & 0x0f)]; + uint16 p0 = table[((src[1] & 0x0F) << 4) | (src[0] & 0x0F)]; + uint16 p1 = table[((src[3] & 0x0F) << 4) | (src[2] & 0x0F)]; *dst++ = ((p0 & 0x0003) << 6) | ((p0 & 0x0300) >> 4) | ((p1 & 0x0003) << 2) | ((p1 & 0x0300) >> 8); @@ -515,9 +380,9 @@ uint8 *Screen_EoB::encodeShape(uint16 x, uint16 y, uint16 w, uint16 h, bool enco uint8 *dst = shp; *dst++ = 8; - *dst++ = (h & 0xff); - *dst++ = (w & 0xff); - *dst++ = (h & 0xff); + *dst++ = (h & 0xFF); + *dst++ = (w & 0xFF); + *dst++ = (h & 0xFF); srcLineStart = getPagePtr(_curPage | 1) + y * 320 + (x << 3); src = srcLineStart; @@ -540,7 +405,7 @@ uint8 *Screen_EoB::encodeShape(uint16 x, uint16 y, uint16 w, uint16 h, bool enco *dst++ = 0; numZero -= 255; } - val = numZero & 0xff; + val = numZero & 0xFF; } *dst++ = val; } while (src != lineEnd); @@ -555,7 +420,7 @@ uint8 *Screen_EoB::encodeShape(uint16 x, uint16 y, uint16 w, uint16 h, bool enco if (_renderMode != Common::kRenderEGA || _useHiResEGADithering) { colorMap = new uint8[0x100]; - memset(colorMap, 0xff, 0x100); + memset(colorMap, 0xFF, 0x100); } shapesize = h * (w << 2) + 20; @@ -564,15 +429,15 @@ uint8 *Screen_EoB::encodeShape(uint16 x, uint16 y, uint16 w, uint16 h, bool enco uint8 *dst = shp; *dst++ = 2; - *dst++ = (h & 0xff); - *dst++ = (w & 0xff); - *dst++ = (h & 0xff); + *dst++ = (h & 0xFF); + *dst++ = (w & 0xFF); + *dst++ = (h & 0xFF); - if (_useLoResEGA) { + if (_renderMode != Common::kRenderEGA || _useHiResEGADithering) { + memset(dst, 0xFF, 0x10); + } else { for (int i = 0; i < 16; i++) dst[i] = i; - } else { - memset(dst, 0xff, 0x10); } uint8 *pal = dst; @@ -584,15 +449,13 @@ uint8 *Screen_EoB::encodeShape(uint16 x, uint16 y, uint16 w, uint16 h, bool enco uint16 w1 = w << 3; while (w1--) { uint8 s = *src++; - uint8 c = s & 0x0f; + uint8 c = s & 0x0F; if (colorMap) { c = colorMap[s]; - if (c == 0xff) { + if (c == 0xFF) { if (col < 0x10) { *pal++ = s; c = colorMap[s] = col++; - if (!col) - c = 0; } else { c = 0; } @@ -632,7 +495,7 @@ void Screen_EoB::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, y += _dsY1; } - dst += (_dsX1 << 3) * _pageScaleFactor[pageNum]; + dst += (_dsX1 << 3); int16 dX = x - (_dsX1 << 3); int16 dY = y; int16 dW = _dsX2 - _dsX1; @@ -704,11 +567,11 @@ void Screen_EoB::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, marginRight = w2 - marginLeft - width; } - dst += (dY * SCREEN_W * _pageScaleFactor[pageNum] * _pageScaleFactor[pageNum] + dX * _pageScaleFactor[pageNum]); + dst += (dY * SCREEN_W + dX); uint8 *dstL = dst; if (pageNum == 0 || pageNum == 1) - addDirtyRect(rX * _pageScaleFactor[pageNum], rY * _pageScaleFactor[pageNum], rW * _pageScaleFactor[pageNum], rH * _pageScaleFactor[pageNum]); + addDirtyRect(rX, rY, rW, rH); while (dH--) { int16 xpos = (int16) marginLeft; @@ -743,7 +606,7 @@ void Screen_EoB::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, } while (xpos > 0); } - dst -= (xpos * _pageScaleFactor[pageNum]); + dst -= xpos; xpos += width; while (xpos > 0) { @@ -752,12 +615,12 @@ void Screen_EoB::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, src += pixelStep; if (m) { - drawShapeSetPixel(dst, c, SCREEN_W * _pageScaleFactor[pageNum]); - dst += _pageScaleFactor[pageNum]; + drawShapeSetPixel(dst, c); + dst++; xpos--; } else { uint8 len = (flags & 1) ? src[1] : src[0]; - dst += (len * _pageScaleFactor[pageNum]); + dst += len; xpos -= len; src += pixelStep; } @@ -783,7 +646,7 @@ void Screen_EoB::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, } while (xpos > 0); } - dstL += SCREEN_W * _pageScaleFactor[pageNum] * _pageScaleFactor[pageNum]; + dstL += SCREEN_W; dst = dstL; if (flags & 1) src = src2 + 1; @@ -797,7 +660,7 @@ void Screen_EoB::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, pal = ovl ? ovl : src; src += 16; } else { - static const uint8 cgaDefOvl[] = { 0x00, 0x55, 0xaa, 0xff }; + static const uint8 cgaDefOvl[] = { 0x00, 0x55, 0xAA, 0xFF }; pal = ovl ? ovl : cgaDefOvl; for (int i = 0; i < 4; i++) cgaPal[i] = pal[i] & 3; @@ -851,12 +714,12 @@ void Screen_EoB::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, if (d < width) width = d; - dst += (dY * _pageScaleFactor[pageNum] * SCREEN_W * _pageScaleFactor[pageNum] + dX * _pageScaleFactor[pageNum]); + dst += (dY * SCREEN_W + dX); if (pageNum == 0 || pageNum == 1) - addDirtyRect(rX * _pageScaleFactor[pageNum], rY * _pageScaleFactor[pageNum], rW * _pageScaleFactor[pageNum], rH * _pageScaleFactor[pageNum]); + addDirtyRect(rX, rY, rW, rH); - int pitch = SCREEN_W * _pageScaleFactor[pageNum] * _pageScaleFactor[pageNum] - width * _pageScaleFactor[pageNum]; + int pitch = SCREEN_W - width; int16 lineSrcStep = (w2 - width) / pixelsPerByte; uint8 lineSrcStepRemainder = (w2 - width) % pixelsPerByte; @@ -899,8 +762,8 @@ void Screen_EoB::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, } uint8 col = (pixelsPerByte == 2) ? pal[(in >> shift) & pixelPackingMask] : (*dst & ((trans >> shift) & (pixelPackingMask))) | pal[(in >> shift) & pixelPackingMask]; if (col || pixelsPerByte == 4) - drawShapeSetPixel(dst, col, SCREEN_W * _pageScaleFactor[pageNum]); - dst += _pageScaleFactor[pageNum]; + drawShapeSetPixel(dst, col); + dst++; shift = ((shift - (pixelStep * pixelPacking)) & 7); } src += lineSrcStep; @@ -922,7 +785,7 @@ const uint8 *Screen_EoB::scaleShapeStep(const uint8 *shp) { uint8 *dst = (shp != _dsTempPage) ? _dsTempPage : _dsTempPage + 6000; uint8 *d = dst; uint8 pixelsPerByte = *d++ = *shp++; - assert (pixelsPerByte > 1); + assert(pixelsPerByte > 1); uint16 h = shp[0] + 1; d[0] = d[2] = (h << 1) / 3; @@ -952,7 +815,7 @@ const uint8 *Screen_EoB::scaleShapeStep(const uint8 *shp) { else i = -i; - _dsScaleTrans = (i << 4) | (i & 0x0f); + _dsScaleTrans = (i << 4) | (i & 0x0F); for (int ii = 0; ii < 16; ii++) *d++ = *shp++; } @@ -976,7 +839,7 @@ const uint8 *Screen_EoB::scaleShapeStep(const uint8 *shp) { shp += w2; } - return (const uint8*)dst; + return (const uint8 *)dst; } const uint8 *Screen_EoB::generateShapeOverlay(const uint8 *shp, int paletteOverlayIndex) { @@ -1328,14 +1191,14 @@ void Screen_EoB::createFadeTable(uint8 *palData, uint8 *dst, uint8 rootColor, ui for (uint8 i = 1; i; i++) { uint16 tmp = (uint16)((*src - r) * weight) << 1; - tr = *src++ - ((tmp >> 8) & 0xff); + tr = *src++ - ((tmp >> 8) & 0xFF); tmp = (uint16)((*src - g) * weight) << 1; - tg = *src++ - ((tmp >> 8) & 0xff); + tg = *src++ - ((tmp >> 8) & 0xFF); tmp = (uint16)((*src - b) * weight) << 1; - tb = *src++ - ((tmp >> 8) & 0xff); + tb = *src++ - ((tmp >> 8) & 0xFF); uint8 *d = palData + 3; - uint16 v = 0xffff; + uint16 v = 0xFFFF; uint8 col = rootColor; for (uint8 ii = 1; ii; ii++) { @@ -1367,15 +1230,55 @@ const uint8 *Screen_EoB::getEGADitheringTable() { return _egaDitheringTable; } -void Screen_EoB::drawShapeSetPixel(uint8 *dst, uint8 col, uint16 pitch) { +void Screen_EoB::updateDirtyRects() { + if (!_useHiResEGADithering) { + Screen::updateDirtyRects(); + return; + } + + if (_forceFullUpdate) { + ditherRect(getCPagePtr(0), _egaDitheringTempPage, SCREEN_W * 2, SCREEN_W, SCREEN_H); + _system->copyRectToScreen(_egaDitheringTempPage, SCREEN_W * 2, 0, 0, SCREEN_W * 2, SCREEN_H * 2); + } else { + const byte *page0 = getCPagePtr(0); + Common::List<Common::Rect>::iterator it; + for (it = _dirtyRects.begin(); it != _dirtyRects.end(); ++it) { + ditherRect(page0 + it->top * SCREEN_W + it->left, _egaDitheringTempPage, SCREEN_W * 2, it->width(), it->height()); + _system->copyRectToScreen(_egaDitheringTempPage, SCREEN_W * 2, it->left * 2, it->top * 2, it->width() * 2, it->height() * 2); + } + } + _forceFullUpdate = false; + _dirtyRects.clear(); +} + +void Screen_EoB::ditherRect(const uint8 *src, uint8 *dst, int dstPitch, int srcW, int srcH, int colorKey) { + while (srcH--) { + uint8 *dst2 = dst + dstPitch; + for (int i = 0; i < srcW; i++) { + int in = *src++; + if (in != colorKey) { + in = _egaDitheringTable[in]; + *dst++ = *dst2++ = in >> 4; + *dst++ = *dst2++ = in & 0x0F; + } else { + dst[0] = dst[1] = dst2[0] = dst2[1] = colorKey; + dst += 2; + dst2 += 2; + } + } + src += (SCREEN_W - srcW); + dst += ((dstPitch - srcW) * 2); + } +} + +void Screen_EoB::drawShapeSetPixel(uint8 *dst, uint8 col) { if ((_renderMode != Common::kRenderCGA && _renderMode != Common::kRenderEGA) || _useHiResEGADithering) { if (_shapeFadeMode[0]) { if (_shapeFadeMode[1]) { - col = _useHiResEGADithering ? _egaPixelValueTable[(dst[0] << 4) | (dst[1] & 0x0f)] : *dst; + col = *dst; } else { _shapeFadeInternal &= 7; - col = _useHiResEGADithering ? _egaPixelValueTable[(dst[_shapeFadeInternal] << 4) | (dst[_shapeFadeInternal + 1] & 0x0f)] : dst[_shapeFadeInternal]; - _shapeFadeInternal++; + col = *(dst + _shapeFadeInternal++); } } @@ -1386,21 +1289,15 @@ void Screen_EoB::drawShapeSetPixel(uint8 *dst, uint8 col, uint16 pitch) { } } - if (_useHiResEGADithering) { - col = _egaDitheringTable[col]; - dst[0] = dst[pitch] = col >> 4; - dst[1] = dst[pitch + 1] = col & 0x0f; - } else { - *dst = col; - } + *dst = col; } void Screen_EoB::scaleShapeProcessLine2Bit(uint8 *&shpDst, const uint8 *&shpSrc, uint32 transOffsetDst, uint32 transOffsetSrc) { for (int i = 0; i < _dsDiv; i++) { shpDst[0] = (_cgaScaleTable[shpSrc[0]] << 2) | (shpSrc[1] >> 6); - shpDst[1] = ((shpSrc[1] & 0x0f) << 4) | ((shpSrc[2] >> 2) & 0x0f); + shpDst[1] = ((shpSrc[1] & 0x0F) << 4) | ((shpSrc[2] >> 2) & 0x0F); shpDst[transOffsetDst] = (_cgaScaleTable[shpSrc[transOffsetSrc]] << 2) | (shpSrc[transOffsetSrc + 1] >> 6); - shpDst[transOffsetDst + 1] = ((shpSrc[transOffsetSrc + 1] & 0x0f) << 4) | ((shpSrc[transOffsetSrc + 2] >> 2) & 0x0f); + shpDst[transOffsetDst + 1] = ((shpSrc[transOffsetSrc + 1] & 0x0F) << 4) | ((shpSrc[transOffsetSrc + 2] >> 2) & 0x0F); shpSrc += 3; shpDst += 2; } @@ -1409,15 +1306,15 @@ void Screen_EoB::scaleShapeProcessLine2Bit(uint8 *&shpDst, const uint8 *&shpSrc, shpDst[0] = _cgaScaleTable[shpSrc[0]] << 2; shpDst[1] = 0; shpDst[transOffsetDst] = (_cgaScaleTable[shpSrc[transOffsetSrc]] << 2) | 3; - shpDst[transOffsetDst + 1] = 0xff; + shpDst[transOffsetDst + 1] = 0xFF; shpSrc++; shpDst += 2; } else if (_dsRem == 2) { shpDst[0] = (_cgaScaleTable[shpSrc[0]] << 2) | (shpSrc[1] >> 6); - shpDst[1] = (shpSrc[1] & 0x3f) << 2; + shpDst[1] = (shpSrc[1] & 0x3F) << 2; shpDst[transOffsetDst] = (_cgaScaleTable[shpSrc[transOffsetSrc]] << 2) | (shpSrc[transOffsetSrc + 1] >> 6); - shpDst[transOffsetDst + 1] = ((shpSrc[transOffsetSrc + 1] & 0x3f) << 2) | 3; + shpDst[transOffsetDst + 1] = ((shpSrc[transOffsetSrc + 1] & 0x3F) << 2) | 3; shpSrc += 2; shpDst += 2; } @@ -1426,7 +1323,7 @@ void Screen_EoB::scaleShapeProcessLine2Bit(uint8 *&shpDst, const uint8 *&shpSrc, void Screen_EoB::scaleShapeProcessLine4Bit(uint8 *&dst, const uint8 *&src) { for (int i = 0; i < _dsDiv; i++) { *dst++ = *src++; - *dst++ = (READ_BE_UINT16(src) >> 4) & 0xff; + *dst++ = (READ_BE_UINT16(src) >> 4) & 0xFF; src += 2; } @@ -1434,7 +1331,7 @@ void Screen_EoB::scaleShapeProcessLine4Bit(uint8 *&dst, const uint8 *&src) { *dst++ = *src++; *dst++ = _dsScaleTrans; } else if (_dsRem == 2) { - *dst++ = (src[0] & 0xf0) | (src[1] >> 4); + *dst++ = (src[0] & 0xF0) | (src[1] >> 4); src += 2; *dst++ = _dsScaleTrans; *dst++ = _dsScaleTrans; @@ -1463,7 +1360,7 @@ void Screen_EoB::generateEGADitheringTable(const Palette &pal) { for (int ii = 256; ii; ii--) { const uint8 *palEntry = _egaMatchTable + (ii - 1) * 3; - if (*palEntry == 0xff) + if (*palEntry == 0xFF) continue; int e_r = palEntry[0] - r; @@ -1479,16 +1376,12 @@ void Screen_EoB::generateEGADitheringTable(const Palette &pal) { } *dst++ = col; } - - memset(_egaPixelValueTable, 0, 256); - for (int i = 0; i < 256; i++) - _egaPixelValueTable[_egaDitheringTable[i]] = i; } void Screen_EoB::generateCGADitheringTables(const uint8 *mappingData) { for (int i = 0; i < 256; i++) { - _cgaDitheringTables[0][i] = (mappingData[(i >> 4) + 16] << 8) | mappingData[i & 0x0f]; - _cgaDitheringTables[1][i] = (mappingData[i >> 4] << 8) | mappingData[(i & 0x0f) + 16]; + _cgaDitheringTables[0][i] = (mappingData[(i >> 4) + 16] << 8) | mappingData[i & 0x0F]; + _cgaDitheringTables[1][i] = (mappingData[i >> 4] << 8) | mappingData[(i & 0x0F) + 16]; } } @@ -1546,11 +1439,10 @@ const uint8 Screen_EoB::_egaMatchTable[] = { uint16 *OldDOSFont::_cgaDitheringTable = 0; int OldDOSFont::_numRef = 0; -OldDOSFont::OldDOSFont(Common::RenderMode mode, bool useHiResEGADithering) : _renderMode(mode), _useHiResEGADithering(useHiResEGADithering) { +OldDOSFont::OldDOSFont(Common::RenderMode mode) : _renderMode(mode) { _data = 0; _width = _height = _numGlyphs = 0; _bitmapOffsets = 0; - _useLoResEGA = (_renderMode == Common::kRenderEGA && !_useHiResEGADithering); _numRef++; if (!_cgaDitheringTable && _numRef == 1) { @@ -1615,42 +1507,42 @@ void OldDOSFont::drawChar(uint16 c, byte *dst, int pitch) const { if (_width == 6) { switch (c) { case 0x81: - case 0x9a: - c = 0x5d; + case 0x9A: + c = 0x5D; break; case 0x84: - case 0x8e: - c = 0x5b; + case 0x8E: + c = 0x5B; break; case 0x94: case 0x99: c = 0x40; - case 0xe1: + case 0xE1: // TODO: recheck this: no conversion for 'ß' ? break; } } else if (_width == 8) { switch (c) { case 0x81: - case 0x9a: - case 0x5d: - c = 0x1d; + case 0x9A: + case 0x5D: + c = 0x1D; break; case 0x84: - case 0x5b: - c = 0x1e; + case 0x5B: + c = 0x1E; break; case 0x94: case 0x40: - c = 0x1f; + c = 0x1F; break; - case 0x8e: - c = 0x1b; + case 0x8E: + c = 0x1B; break; case 0x99: - c = 0x1c; + c = 0x1C; break; - case 0xe1: + case 0xE1: c = 0x19; break; } @@ -1662,24 +1554,16 @@ void OldDOSFont::drawChar(uint16 c, byte *dst, int pitch) const { int w = (_width - 1) >> 3; pitch -= _width; - if (_useHiResEGADithering) - pitch *= 2; - uint8 color1 = _colorMap[1]; uint8 color2 = _colorMap[0]; - uint8 colEGA11 = _colorMap[3] >> 4; - uint8 colEGA12 = _colorMap[3] & 0x0f; - uint8 colEGA21 = _colorMap[2] >> 4; - uint8 colEGA22 = _colorMap[2] & 0x0f; - static const uint16 cgaColorMask[] = { 0, 0x5555, 0xAAAA, 0xFFFF }; uint16 cgaMask1 = cgaColorMask[color1 & 3]; uint16 cgaMask2 = cgaColorMask[color2 & 3]; - if (_renderMode == Common::kRenderCGA || _useLoResEGA) { - color1 &= 0x0f; - color2 &= 0x0f; + if (_renderMode == Common::kRenderCGA || _renderMode == Common::kRenderEGA) { + color1 &= 0x0F; + color2 &= 0x0F; } int cH = _height; @@ -1710,7 +1594,7 @@ void OldDOSFont::drawChar(uint16 c, byte *dst, int pitch) const { uint8 sh = 6; for (int i = 0; i < _width; i++) { cDst |= ((dst[i] & 3) << sh); - sh = (sh - 2) & 0x0f; + sh = (sh - 2) & 0x0F; } uint16 out = (~(cmp1 | cmp2) & cDst) | (cmp1 & cgaMask1) | (cmp2 & cgaMask2); @@ -1718,7 +1602,7 @@ void OldDOSFont::drawChar(uint16 c, byte *dst, int pitch) const { sh = 6; for (int i = 0; i < _width; i++) { *dst++ = (out >> sh) & 3; - sh = (sh - 2) & 0x0f; + sh = (sh - 2) & 0x0F; } last = s; @@ -1734,27 +1618,13 @@ void OldDOSFont::drawChar(uint16 c, byte *dst, int pitch) const { break; } - if (_useHiResEGADithering) { - if (s & i) { - if (color1) { - dst[0] = dst2[0] = colEGA11; - dst[1] = dst2[1] = colEGA12; - } - } else if (color2) { - dst[0] = dst2[0] = colEGA21; - dst[1] = dst2[1] = colEGA22; - } - dst += 2; - dst2 += 2; - } else { - if (s & i) { - if (color1) - *dst = color1; - } else if (color2) { - *dst = color2; - } - dst++; + if (s & i) { + if (color1) + *dst = color1; + } else if (color2) { + *dst = color2; } + dst++; } if (cW) |