From 3a64d35dfd9126d7912c4d4496030f7ed120d660 Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Thu, 4 Jun 2009 01:05:47 +0000 Subject: Add 16bit color support for later HE games. svn-id: r41153 --- engines/scumm/actor.cpp | 2 +- engines/scumm/akos.cpp | 81 ++++++--- engines/scumm/akos.h | 2 +- engines/scumm/base-costume.cpp | 2 +- engines/scumm/charset.cpp | 4 +- engines/scumm/gfx.cpp | 245 +++++++++++++++---------- engines/scumm/gfx.h | 4 +- engines/scumm/he/animation_he.cpp | 31 +++- engines/scumm/he/animation_he.h | 1 + engines/scumm/he/intern_he.h | 3 +- engines/scumm/he/palette_he.cpp | 217 ++++++++++++++++------ engines/scumm/he/script_v100he.cpp | 43 +++-- engines/scumm/he/script_v60he.cpp | 2 + engines/scumm/he/script_v80he.cpp | 8 +- engines/scumm/he/script_v90he.cpp | 44 +++-- engines/scumm/he/wiz_he.cpp | 364 ++++++++++++++++++++++--------------- engines/scumm/he/wiz_he.h | 33 ++-- engines/scumm/palette.cpp | 13 -- engines/scumm/saveload.cpp | 2 +- engines/scumm/scumm.cpp | 20 +- engines/scumm/scumm.h | 6 +- 21 files changed, 726 insertions(+), 401 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/actor.cpp b/engines/scumm/actor.cpp index cf90094112..eea1ec070b 100644 --- a/engines/scumm/actor.cpp +++ b/engines/scumm/actor.cpp @@ -2384,7 +2384,7 @@ void ScummEngine_v71he::postProcessAuxQueue() { uint8 *dst2 = pvs->getBackPixels(0, pvs->topline); switch (comp) { case 1: - Wiz::copyAuxImage(dst1, dst2, axfd + 10, pvs->w, pvs->h, x, y, w, h); + Wiz::copyAuxImage(dst1, dst2, axfd + 10, pvs->pitch, pvs->h, x, y, w, h, _bitDepth); break; default: error("unimplemented compression type %d", comp); diff --git a/engines/scumm/akos.cpp b/engines/scumm/akos.cpp index ab7db2c4a7..edfbe5730d 100644 --- a/engines/scumm/akos.cpp +++ b/engines/scumm/akos.cpp @@ -299,22 +299,23 @@ void AkosRenderer::setPalette(byte *new_palette) { if (size > 256) error("akos_setPalette: %d is too many colors", size); - if (_vm->_game.heversion >= 99 && _paletteNum) { - for (i = 0; i < size; i++) - _palette[i] = (byte)_vm->_hePalettes[_paletteNum * 1024 + 768 + akpl[i]]; - } else if ((_vm->_game.features & GF_16BIT_COLOR) && rgbs) { - for (i = 0; i < size; i++) { - if (new_palette[i] == 0xFF) { - uint8 col = akpl[i]; - uint8 r = rgbs[col * 3 + 0]; - uint8 g = rgbs[col * 3 + 1]; - uint8 b = rgbs[col * 3 + 2]; - - _palette[i] = _vm->remapPaletteColor(r, g, b, -1); - } else { - _palette[i] = new_palette[i]; + if (_vm->_game.features & GF_16BIT_COLOR) { + if (_paletteNum) { + for (i = 0; i < size; i++) + _palette[i] = READ_LE_UINT16(_vm->_hePalettes + _paletteNum * _vm->_hePaletteSlot + 768 + akpl[i] * 2); + } else if (rgbs) { + for (i = 0; i < size; i++) { + if (new_palette[i] == 0xFF) { + uint8 col = akpl[i]; + _palette[i] = _vm->get16BitColor(rgbs[col * 3 + 0], rgbs[col * 3 + 1], rgbs[col * 3 + 2]); + } else { + _palette[i] = new_palette[i]; + } } } + } else if (_vm->_game.heversion >= 99 && _paletteNum) { + for (i = 0; i < size; i++) + _palette[i] = (byte)_vm->_hePalettes[_paletteNum * _vm->_hePaletteSlot + 768 + akpl[i]]; } else { for (i = 0; i < size; i++) { _palette[i] = new_palette[i] != 0xFF ? new_palette[i] : akpl[i]; @@ -545,7 +546,7 @@ void AkosRenderer::codec1_genericDecode(Codec1 &v1) { byte *dst; byte len, maskbit; int y; - uint color, height, pcolor; + uint16 color, height, pcolor; const byte *scaleytab; bool masked; bool skip_column = false; @@ -589,7 +590,11 @@ void AkosRenderer::codec1_genericDecode(Codec1 &v1) { } else if (_shadow_mode == 2) { error("codec1_spec2"); // TODO } else if (_shadow_mode == 3) { - if (_vm->_game.heversion >= 90) { + if (_vm->_game.features & GF_16BIT_COLOR) { + uint16 srcColor = (pcolor >> 1) & 0x7DEF; + uint16 dstColor = (READ_UINT16(dst) >> 1) & 0x7DEF; + pcolor = srcColor + dstColor; + } else if (_vm->_game.heversion >= 90) { pcolor = (pcolor << 8) + *dst; pcolor = xmap[pcolor]; } else if (pcolor < 8) { @@ -597,7 +602,11 @@ void AkosRenderer::codec1_genericDecode(Codec1 &v1) { pcolor = _shadow_table[pcolor]; } } - *dst = pcolor; + if (_vm->_bitDepth == 2) { + WRITE_UINT16(dst, pcolor); + } else { + *dst = pcolor; + } } } dst += _out.pitch; @@ -617,7 +626,7 @@ void AkosRenderer::codec1_genericDecode(Codec1 &v1) { if (v1.x < 0 || v1.x >= v1.boundsRect.right) return; maskbit = revBitMask(v1.x & 7); - v1.destptr += v1.scaleXstep; + v1.destptr += v1.scaleXstep * _vm->_bitDepth; skip_column = false; } else skip_column = true; @@ -987,7 +996,7 @@ byte AkosRenderer::codec1(int xmoveCur, int ymoveCur) { if (_draw_bottom < rect.bottom) _draw_bottom = rect.bottom; - v1.destptr = (byte *)_out.pixels + v1.y * _out.pitch + v1.x; + v1.destptr = (byte *)_out.pixels + v1.y * _out.pitch + v1.x * _vm->_bitDepth; codec1_genericDecode(v1); @@ -1056,7 +1065,12 @@ byte AkosRenderer::codec5(int xmoveCur, int ymoveCur) { bdd.shadowMode = _shadow_mode; bdd.shadowPalette = _vm->_shadowPalette; - bdd.actorPalette = _useBompPalette ? _palette : 0; + bdd.actorPalette = 0; + if (_useBompPalette) { + for (uint i = 0; i < 256; i++) + bdd.actorPalette[i] = _palette[i]; + } + bdd.mirror = !_mirror; drawBomp(bdd); @@ -1176,6 +1190,8 @@ void AkosRenderer::akos16Decompress(byte *dest, int32 pitch, const byte *src, in } byte AkosRenderer::codec16(int xmoveCur, int ymoveCur) { + assert(_vm->_bitDepth == 1); + Common::Rect clip; int32 minx, miny, maxw, maxh; int32 skip_x, skip_y, cur_x, cur_y; @@ -1278,13 +1294,15 @@ byte AkosRenderer::codec16(int xmoveCur, int ymoveCur) { int32 numskip_before = skip_x + (skip_y * _width); int32 numskip_after = _width - cur_x; - byte *dst = (byte *)_out.pixels + width_unk + height_unk * _out.pitch; + byte *dst = (byte *)_out.pixels + height_unk * _out.pitch + width_unk * _vm->_bitDepth; akos16Decompress(dst, _out.pitch, _srcptr, cur_x, out_height, dir, numskip_before, numskip_after, transparency, clip.left, clip.top, _zbuf); return 0; } byte AkosRenderer::codec32(int xmoveCur, int ymoveCur) { + return 0; + #ifdef ENABLE_HE Common::Rect src, dst; @@ -1335,18 +1353,27 @@ byte AkosRenderer::codec32(int xmoveCur, int ymoveCur) { _draw_bottom = dst.bottom; const uint8 *palPtr = NULL; - if (_vm->_game.heversion >= 99) { - palPtr = _vm->_hePalettes + 1792; + if (_vm->_game.features & GF_16BIT_COLOR) { + palPtr = _vm->_hePalettes + _vm->_hePaletteSlot + 768; + if (_paletteNum) { + palPtr = _vm->_hePalettes + _paletteNum * _vm->_hePaletteSlot + 768; + } else if (rgbs) { + for (uint i = 0; i < 256; i++) + _palette[i] = _vm->get16BitColor(rgbs[i * 3 + 0], rgbs[i * 3 + 1], rgbs[i * 3 + 2]); + palPtr = (uint8 *)_palette; + } + } else if (_vm->_game.heversion >= 99) { + palPtr = _vm->_hePalettes + _vm->_hePaletteSlot + 768; } - byte *dstPtr = (byte *)_out.pixels + dst.left + dst.top * _out.pitch; + byte *dstPtr = (byte *)_out.pixels + dst.top * _out.pitch + dst.left * _vm->_bitDepth; if (_shadow_mode == 3) { - Wiz::decompressWizImage(dstPtr, _out.pitch, _srcptr, src, 0, palPtr, xmap); + Wiz::decompressWizImage(dstPtr, _out.pitch, kDstScreen, _srcptr, src, 0, palPtr, xmap, _vm->_bitDepth); } else { if (palPtr != NULL) { - Wiz::decompressWizImage(dstPtr, _out.pitch, _srcptr, src, 0, palPtr); + Wiz::decompressWizImage(dstPtr, _out.pitch, kDstScreen, _srcptr, src, 0, palPtr, NULL, _vm->_bitDepth); } else { - Wiz::decompressWizImage(dstPtr, _out.pitch, _srcptr, src, 0); + Wiz::decompressWizImage(dstPtr, _out.pitch, kDstScreen, _srcptr, src, 0, NULL, NULL, _vm->_bitDepth); } } #endif diff --git a/engines/scumm/akos.h b/engines/scumm/akos.h index be532b804d..17576e5869 100644 --- a/engines/scumm/akos.h +++ b/engines/scumm/akos.h @@ -60,7 +60,7 @@ protected: uint16 _codec; // actor _palette - byte _palette[256]; + uint16 _palette[256]; bool _useBompPalette; // pointer to various parts of the costume resource diff --git a/engines/scumm/base-costume.cpp b/engines/scumm/base-costume.cpp index 795abb8685..ef706afaac 100644 --- a/engines/scumm/base-costume.cpp +++ b/engines/scumm/base-costume.cpp @@ -40,7 +40,7 @@ byte BaseCostumeRenderer::drawCostume(const VirtScreen &vs, int numStrips, const _out.pixels = vs.getPixels(0, 0); _actorX += _vm->_virtscr[kMainVirtScreen].xstart & 7; - _out.w = _out.pitch; + _out.w = _out.pitch / _vm->_bitDepth; _out.pixels = (byte *)_out.pixels - (_vm->_virtscr[kMainVirtScreen].xstart & 7); _numStrips = numStrips; diff --git a/engines/scumm/charset.cpp b/engines/scumm/charset.cpp index 193fc434e4..d6dfa4c5bb 100644 --- a/engines/scumm/charset.cpp +++ b/engines/scumm/charset.cpp @@ -819,9 +819,9 @@ void CharsetRendererClassic::printCharIntern(bool is2byte, const byte *charPtr, byte imagePalette[256]; memset(imagePalette, 0, sizeof(imagePalette)); memcpy(imagePalette, _vm->_charsetColorMap, 4); - Wiz::copyWizImage(dstPtr, charPtr, vs->w, vs->h, _left, _top, origWidth, origHeight, &rScreen, 0, imagePalette); + Wiz::copyWizImage(dstPtr, charPtr, vs->pitch, kDstScreen, vs->w, vs->h, _left, _top, origWidth, origHeight, &rScreen, 0, imagePalette, NULL, _vm->_bitDepth); } else { - Wiz::copyWizImage(dstPtr, charPtr, vs->w, vs->h, _left, _top, origWidth, origHeight, &rScreen); + Wiz::copyWizImage(dstPtr, charPtr, vs->pitch, kDstScreen, vs->w, vs->h, _left, _top, origWidth, origHeight, &rScreen, 0, NULL, NULL, _vm->_bitDepth); } if (_blitAlso && vs->hasTwoBuffers) { diff --git a/engines/scumm/gfx.cpp b/engines/scumm/gfx.cpp index 62e18561d3..a141d51735 100644 --- a/engines/scumm/gfx.cpp +++ b/engines/scumm/gfx.cpp @@ -43,12 +43,12 @@ extern "C" void asmCopy8Col(byte* dst, int dstPitch, const byte* src, int height namespace Scumm { -static void blit(byte *dst, int dstPitch, const byte *src, int srcPitch, int w, int h); -static void fill(byte *dst, int dstPitch, byte color, int w, int h); +static void blit(byte *dst, int dstPitch, const byte *src, int srcPitch, int w, int h, uint8 bitDepth); +static void fill(byte *dst, int dstPitch, uint16 color, int w, int h, uint8 bitDepth); #ifndef USE_ARM_GFX_ASM -static void copy8Col(byte *dst, int dstPitch, const byte *src, int height); +static void copy8Col(byte *dst, int dstPitch, const byte *src, int height, uint8 bitDepth); #endif -static void clear8Col(byte *dst, int dstPitch, int height); +static void clear8Col(byte *dst, int dstPitch, int height, uint8 bitDepth); static void ditherHerc(byte *src, byte *hercbuf, int srcPitch, int *x, int *y, int *width, int *height); static void scale2x(byte *dst, int dstPitch, const byte *src, int srcPitch, int w, int h); @@ -341,8 +341,8 @@ void ScummEngine::initVirtScreen(VirtScreenNumber slot, int top, int width, int vs->hasTwoBuffers = twobufs; vs->xstart = 0; vs->backBuf = NULL; - vs->bytesPerPixel = 1; - vs->pitch = width; + vs->bytesPerPixel = (_game.features & GF_16BIT_COLOR) ? 2 : 1; + vs->pitch = width * vs->bytesPerPixel; if (_game.version >= 7) { // Increase the pitch by one; needed to accomodate the extra screen @@ -586,7 +586,7 @@ void ScummEngine::drawStripToScreen(VirtScreen *vs, int x, int width, int top, i vsPitch = _screenWidth * m - width * m; } else { - vsPitch = vs->pitch - width; + vsPitch = vs->pitch - width * vs->bytesPerPixel; } @@ -612,36 +612,49 @@ void ScummEngine::drawStripToScreen(VirtScreen *vs, int x, int width, int top, i #else // We blit four pixels at a time, for improved performance. const uint32 *src32 = (const uint32 *)src; - const uint32 *text32 = (const uint32 *)text; uint32 *dst32 = (uint32 *)_compositeBuf; vsPitch >>= 2; - const int textPitch = (_textSurface.pitch - width * m) >> 2; - for (int h = height * m; h > 0; --h) { - for (int w = width*m; w > 0; w-=4) { - uint32 temp = *text32++; - - // Generate a byte mask for those text pixels (bytes) with - // value CHARSET_MASK_TRANSPARENCY. In the end, each byte - // in mask will be either equal to 0x00 or 0xFF. - // Doing it this way avoids branches and bytewise operations, - // at the cost of readability ;). - uint32 mask = temp ^ CHARSET_MASK_TRANSPARENCY_32; - mask = (((mask & 0x7f7f7f7f) + 0x7f7f7f7f) | mask) & 0x80808080; - mask = ((mask >> 7) + 0x7f7f7f7f) ^ 0x80808080; - - // The following line is equivalent to this code: - // *dst32++ = (*src32++ & mask) | (temp & ~mask); - // However, some compilers can generate somewhat better - // machine code for this equivalent statement: - *dst32++ = ((temp ^ *src32++) & mask) ^ temp; + + if (_bitDepth == 2) { + // Sprites always seem to be used for subtitles in 16Bit color HE games, and not + // the charset renderer, so charset masking isn't required. + for (int h = height * m; h > 0; --h) { + for (int w = width * m; w > 0; w -= 4) { + *dst32++ = *src32++; + *dst32++ = *src32++; + } + src32 += vsPitch; + } + } else { + const uint32 *text32 = (const uint32 *)text; + const int textPitch = (_textSurface.pitch - width * m) >> 2; + for (int h = height * m; h > 0; --h) { + for (int w = width * m; w > 0; w -= 4) { + uint32 temp = *text32++; + + // Generate a byte mask for those text pixels (bytes) with + // value CHARSET_MASK_TRANSPARENCY. In the end, each byte + // in mask will be either equal to 0x00 or 0xFF. + // Doing it this way avoids branches and bytewise operations, + // at the cost of readability ;). + uint32 mask = temp ^ CHARSET_MASK_TRANSPARENCY_32; + mask = (((mask & 0x7f7f7f7f) + 0x7f7f7f7f) | mask) & 0x80808080; + mask = ((mask >> 7) + 0x7f7f7f7f) ^ 0x80808080; + + // The following line is equivalent to this code: + // *dst32++ = (*src32++ & mask) | (temp & ~mask); + // However, some compilers can generate somewhat better + // machine code for this equivalent statement: + *dst32++ = ((temp ^ *src32++) & mask) ^ temp; + } + src32 += vsPitch; + text32 += textPitch; } - src32 += vsPitch; - text32 += textPitch; } #endif src = _compositeBuf; - pitch = width; + pitch = width * vs->bytesPerPixel; if (_renderMode == Common::kRenderHercA || _renderMode == Common::kRenderHercG) { ditherHerc(_compositeBuf, _herculesBuf, width, &x, &y, &width, &height); @@ -976,13 +989,13 @@ void ScummEngine::restoreBackground(Common::Rect rect, byte backColor) { return; if (vs->hasTwoBuffers && _currentRoom != 0 && isLightOn()) { - blit(screenBuf, vs->pitch, vs->getBackPixels(rect.left, rect.top), vs->pitch, width, height); + blit(screenBuf, vs->pitch, vs->getBackPixels(rect.left, rect.top), vs->pitch, width, height, vs->bytesPerPixel); if (vs->number == kMainVirtScreen && _charset->_hasMask) { byte *mask = (byte *)_textSurface.getBasePtr(rect.left, rect.top - _screenTop); - fill(mask, _textSurface.pitch, CHARSET_MASK_TRANSPARENCY, width, height); + fill(mask, _textSurface.pitch, CHARSET_MASK_TRANSPARENCY, width, height, _textSurface.bytesPerPixel); } } else { - fill(screenBuf, vs->pitch, backColor, width, height); + fill(screenBuf, vs->pitch, backColor, width, height, vs->bytesPerPixel); } } @@ -1011,7 +1024,7 @@ void ScummEngine::restoreCharsetBg() { if (vs->number != kMainVirtScreen) { // Restore from back buffer const byte *backBuf = vs->getBackPixels(0, 0); - blit(screenBuf, vs->pitch, backBuf, vs->pitch, vs->w, vs->h); + blit(screenBuf, vs->pitch, backBuf, vs->pitch, vs->w, vs->h, vs->bytesPerPixel); } } else { // Clear area @@ -1047,34 +1060,42 @@ byte *Gdi::getMaskBuffer(int x, int y, int z) { #pragma mark --- Misc --- #pragma mark - -static void blit(byte *dst, int dstPitch, const byte *src, int srcPitch, int w, int h) { +static void blit(byte *dst, int dstPitch, const byte *src, int srcPitch, int w, int h, uint8 bitDepth) { assert(w > 0); assert(h > 0); assert(src != NULL); assert(dst != NULL); - if (w == srcPitch && w == dstPitch) { - memcpy(dst, src, w*h); + if ((w * bitDepth == srcPitch) && (w * bitDepth == dstPitch)) { + memcpy(dst, src, w * h * bitDepth); } else { do { - memcpy(dst, src, w); + memcpy(dst, src, w * bitDepth); dst += dstPitch; src += srcPitch; } while (--h); } } -static void fill(byte *dst, int dstPitch, byte color, int w, int h) { +static void fill(byte *dst, int dstPitch, uint16 color, int w, int h, uint8 bitDepth) { assert(h > 0); assert(dst != NULL); - if (w == dstPitch) { - memset(dst, color, w*h); - } else { + if (bitDepth == 2) { do { - memset(dst, color, w); + for (int i = 0; i < w; i++) + WRITE_UINT16(dst + i * 2, color); dst += dstPitch; } while (--h); + } else { + if (w == dstPitch) { + memset(dst, color, w * h); + } else { + do { + memset(dst, color, w); + dst += dstPitch; + } while (--h); + } } } @@ -1084,14 +1105,18 @@ static void fill(byte *dst, int dstPitch, byte color, int w, int h) { #else -static void copy8Col(byte *dst, int dstPitch, const byte *src, int height) { +static void copy8Col(byte *dst, int dstPitch, const byte *src, int height, uint8 bitDepth) { do { #if defined(SCUMM_NEED_ALIGNMENT) - memcpy(dst, src, 8); + memcpy(dst, src, 8 * bitDepth); #else ((uint32 *)dst)[0] = ((const uint32 *)src)[0]; ((uint32 *)dst)[1] = ((const uint32 *)src)[1]; + if (bitDepth == 2) { + ((uint32 *)dst)[2] = ((const uint32 *)src)[2]; + ((uint32 *)dst)[3] = ((const uint32 *)src)[3]; + } #endif dst += dstPitch; src += dstPitch; @@ -1100,13 +1125,17 @@ static void copy8Col(byte *dst, int dstPitch, const byte *src, int height) { #endif /* USE_ARM_GFX_ASM */ -static void clear8Col(byte *dst, int dstPitch, int height) { +static void clear8Col(byte *dst, int dstPitch, int height, uint8 bitDepth) { do { #if defined(SCUMM_NEED_ALIGNMENT) - memset(dst, 0, 8); + memset(dst, 0, 8 * bitDepth); #else ((uint32 *)dst)[0] = 0; ((uint32 *)dst)[1] = 0; + if (bitDepth == 2) { + ((uint32 *)dst)[2] = 0; + ((uint32 *)dst)[3] = 0; + } #endif dst += dstPitch; } while (--height); @@ -1171,41 +1200,41 @@ void ScummEngine::drawBox(int x, int y, int x2, int y2, int color) { if (color == -1) { if (vs->number != kMainVirtScreen) error("can only copy bg to main window"); - blit(backbuff, vs->pitch, bgbuff, vs->pitch, width, height); + blit(backbuff, vs->pitch, bgbuff, vs->pitch, width, height, vs->bytesPerPixel); if (_charset->_hasMask) { byte *mask = (byte *)_textSurface.getBasePtr(x * _textSurfaceMultiplier, (y - _screenTop) * _textSurfaceMultiplier); - fill(mask, _textSurface.pitch, CHARSET_MASK_TRANSPARENCY, width * _textSurfaceMultiplier, height * _textSurfaceMultiplier); + fill(mask, _textSurface.pitch, CHARSET_MASK_TRANSPARENCY, width * _textSurfaceMultiplier, height * _textSurfaceMultiplier, _textSurface.bytesPerPixel); } } else if (_game.heversion >= 72) { // Flags are used for different methods in HE games uint32 flags = color; if ((flags & 0x2000) || (flags & 0x4000000)) { - blit(backbuff, vs->pitch, bgbuff, vs->pitch, width, height); + blit(backbuff, vs->pitch, bgbuff, vs->pitch, width, height, vs->bytesPerPixel); } else if ((flags & 0x4000) || (flags & 0x2000000)) { - blit(bgbuff, vs->pitch, backbuff, vs->pitch, width, height); + blit(bgbuff, vs->pitch, backbuff, vs->pitch, width, height, vs->bytesPerPixel); } else if ((flags & 0x8000) || (flags & 0x1000000)) { flags &= (flags & 0x1000000) ? 0xFFFFFF : 0x7FFF; - fill(backbuff, vs->pitch, flags, width, height); - fill(bgbuff, vs->pitch, flags, width, height); + fill(backbuff, vs->pitch, flags, width, height, vs->bytesPerPixel); + fill(bgbuff, vs->pitch, flags, width, height, vs->bytesPerPixel); } else { - fill(backbuff, vs->pitch, flags, width, height); + fill(backbuff, vs->pitch, flags, width, height, vs->bytesPerPixel); } } else if (_game.heversion >= 60) { // Flags are used for different methods in HE games uint16 flags = color; if (flags & 0x2000) { - blit(backbuff, vs->pitch, bgbuff, vs->pitch, width, height); + blit(backbuff, vs->pitch, bgbuff, vs->pitch, width, height, vs->bytesPerPixel); } else if (flags & 0x4000) { - blit(bgbuff, vs->pitch, backbuff, vs->pitch, width, height); + blit(bgbuff, vs->pitch, backbuff, vs->pitch, width, height, vs->bytesPerPixel); } else if (flags & 0x8000) { flags &= 0x7FFF; - fill(backbuff, vs->pitch, flags, width, height); - fill(bgbuff, vs->pitch, flags, width, height); + fill(backbuff, vs->pitch, flags, width, height, vs->bytesPerPixel); + fill(bgbuff, vs->pitch, flags, width, height, vs->bytesPerPixel); } else { - fill(backbuff, vs->pitch, flags, width, height); + fill(backbuff, vs->pitch, flags, width, height, vs->bytesPerPixel); } } else { - fill(backbuff, vs->pitch, color, width, height); + fill(backbuff, vs->pitch, color, width, height, vs->bytesPerPixel); } } @@ -1243,7 +1272,7 @@ void ScummEngine_v5::drawFlashlight() { _flashlight.y, _flashlight.y + _flashlight.h, USAGE_BIT_DIRTY); if (_flashlight.buffer) { - fill(_flashlight.buffer, vs->pitch, 0, _flashlight.w, _flashlight.h); + fill(_flashlight.buffer, vs->pitch, 0, _flashlight.w, _flashlight.h, vs->bytesPerPixel); } _flashlight.isDrawn = false; } @@ -1290,7 +1319,7 @@ void ScummEngine_v5::drawFlashlight() { _flashlight.buffer = vs->getPixels(_flashlight.x, _flashlight.y); bgbak = vs->getBackPixels(_flashlight.x, _flashlight.y); - blit(_flashlight.buffer, vs->pitch, bgbak, vs->pitch, _flashlight.w, _flashlight.h); + blit(_flashlight.buffer, vs->pitch, bgbak, vs->pitch, _flashlight.w, _flashlight.h, vs->bytesPerPixel); // Round the corners. To do so, we simply hard-code a set of nicely // rounded corners. @@ -1599,7 +1628,7 @@ void Gdi::drawBitmap(const byte *ptr, VirtScreen *vs, int x, const int y, const warning("Gdi::drawBitmap, strip drawn to %d below window bottom %d", y + height, vs->h); } - _vertStripNextInc = height * vs->pitch - 1; + _vertStripNextInc = height * vs->pitch - 1 * vs->bytesPerPixel; _objectMode = (flag & dbObjectMode) == dbObjectMode; prepareDrawBitmap(ptr, vs, x, y, width, height, stripnr, numstrip); @@ -1632,9 +1661,9 @@ void Gdi::drawBitmap(const byte *ptr, VirtScreen *vs, int x, const int y, const // In the case of a double buffered virtual screen, we draw to // the backbuffer, otherwise to the primary surface memory. if (vs->hasTwoBuffers) - dstPtr = vs->backBuf + y * vs->pitch + x * 8; + dstPtr = vs->backBuf + y * vs->pitch + (x * 8 * vs->bytesPerPixel); else - dstPtr = (byte *)vs->pixels + y * vs->pitch + x * 8; + dstPtr = (byte *)vs->pixels + y * vs->pitch + (x * 8 * vs->bytesPerPixel); transpStrip = drawStrip(dstPtr, vs, x, y, width, height, stripnr, smap_ptr); @@ -1643,11 +1672,11 @@ void Gdi::drawBitmap(const byte *ptr, VirtScreen *vs, int x, const int y, const transpStrip = true; if (vs->hasTwoBuffers) { - byte *frontBuf = (byte *)vs->pixels + y * vs->pitch + x * 8; + byte *frontBuf = (byte *)vs->pixels + y * vs->pitch + (x * 8 * vs->bytesPerPixel); if (lightsOn) - copy8Col(frontBuf, vs->pitch, dstPtr, height); + copy8Col(frontBuf, vs->pitch, dstPtr, height, vs->bytesPerPixel); else - clear8Col(frontBuf, vs->pitch, height); + clear8Col(frontBuf, vs->pitch, height, vs->bytesPerPixel); } decodeMask(x, y, width, height, stripnr, numzbuf, zplane_list, transpStrip, flag, tmsk_ptr); @@ -1875,7 +1904,7 @@ void Gdi::drawBMAPBg(const byte *ptr, VirtScreen *vs) { drawStripHE(dst, vs->pitch, bmap_ptr, vs->w, vs->h, true); break; case 150: - fill(dst, vs->pitch, *bmap_ptr, vs->w, vs->h); + fill(dst, vs->pitch, *bmap_ptr, vs->w, vs->h, vs->bytesPerPixel); break; default: // Alternative russian freddi3 uses badly formatted bitmaps @@ -1927,6 +1956,8 @@ void Gdi::drawBMAPBg(const byte *ptr, VirtScreen *vs) { } void Gdi::drawBMAPObject(const byte *ptr, VirtScreen *vs, int obj, int x, int y, int w, int h) { + assert(_vm->_bitDepth == 1); + const byte *bmap_ptr = _vm->findResourceData(MKID_BE('BMAP'), ptr); assert(bmap_ptr); @@ -1936,7 +1967,7 @@ void Gdi::drawBMAPObject(const byte *ptr, VirtScreen *vs, int obj, int x, int y, if (code == 8 || code == 9) { Common::Rect rScreen(0, 0, vs->w, vs->h); byte *dst = (byte *)_vm->_virtscr[kMainVirtScreen].backBuf + scrX; - Wiz::copyWizImage(dst, bmap_ptr, vs->w, vs->h, x - scrX, y, w, h, &rScreen); + Wiz::copyWizImage(dst, bmap_ptr, vs->pitch, kDstScreen, vs->w, vs->h, x - scrX, y, w, h, &rScreen, 0, 0, 0, _vm->_bitDepth); } Common::Rect rect1(x, y, x + w, y + h); @@ -1986,7 +2017,7 @@ void ScummEngine_v70he::restoreBackgroundHE(Common::Rect rect, int dirtybit) { assert(rw <= _screenWidth && rw > 0); assert(rh <= _screenHeight && rh > 0); - blit(dst, _virtscr[kMainVirtScreen].pitch, src, _virtscr[kMainVirtScreen].pitch, rw, rh); + blit(dst, _virtscr[kMainVirtScreen].pitch, src, _virtscr[kMainVirtScreen].pitch, rw, rh, vs->bytesPerPixel); markRectAsDirty(kMainVirtScreen, rect, dirtybit); } #endif @@ -2016,15 +2047,15 @@ void Gdi::resetBackground(int top, int bottom, int strip) { if (bottom > vs->bdirty[strip]) vs->bdirty[strip] = bottom; - bgbak_ptr = (byte *)vs->backBuf + top * vs->pitch + (strip + vs->xstart/8) * 8; - backbuff_ptr = (byte *)vs->pixels + top * vs->pitch + (strip + vs->xstart/8) * 8; + bgbak_ptr = (byte *)vs->backBuf + top * vs->pitch + (strip + vs->xstart/8) * 8 * vs->bytesPerPixel; + backbuff_ptr = (byte *)vs->pixels + top * vs->pitch + (strip + vs->xstart/8) * 8 * vs->bytesPerPixel; numLinesToProcess = bottom - top; if (numLinesToProcess) { if (_vm->isLightOn()) { - copy8Col(backbuff_ptr, vs->pitch, bgbak_ptr, numLinesToProcess); + copy8Col(backbuff_ptr, vs->pitch, bgbak_ptr, numLinesToProcess, vs->bytesPerPixel); } else { - clear8Col(backbuff_ptr, vs->pitch, numLinesToProcess); + clear8Col(backbuff_ptr, vs->pitch, numLinesToProcess, vs->bytesPerPixel); } } } @@ -2774,13 +2805,17 @@ void Gdi::drawStripHE(byte *dst, int dstPitch, const byte *src, int width, int h int x = width; while (1) { - if (!transpCheck || color != _transparentColor) - *dst = _roomPalette[color]; - dst++; + if (!transpCheck || color != _transparentColor) { + if (_vm->_game.features & GF_16BIT_COLOR) + WRITE_UINT16(dst, READ_LE_UINT16(_vm->_hePalettes + 2048 + color * 2)); + else + *dst = _roomPalette[color]; + } + dst += _vm->_bitDepth; --x; if (x == 0) { x = width; - dst += dstPitch - width; + dst += dstPitch - width * _vm->_bitDepth; --height; if (height == 0) return; @@ -2863,9 +2898,13 @@ void Gdi::drawStripComplex(byte *dst, int dstPitch, const byte *src, int height, int x = 8; do { FILL_BITS; - if (!transpCheck || color != _transparentColor) - *dst = _roomPalette[color] + _paletteMod; - dst++; + if (!transpCheck || color != _transparentColor) { + if (_vm->_game.features & GF_16BIT_COLOR) + WRITE_UINT16(dst, READ_LE_UINT16(_vm->_hePalettes + 2048 + color * 2)); + else + *dst = _roomPalette[color] + _paletteMod; + } + dst += _vm->_bitDepth; againPos: if (!READ_BIT) { @@ -2886,13 +2925,17 @@ void Gdi::drawStripComplex(byte *dst, int dstPitch, const byte *src, int height, do { if (!--x) { x = 8; - dst += dstPitch - 8; + dst += dstPitch - 8 * _vm->_bitDepth; if (!--height) return; } - if (!transpCheck || color != _transparentColor) - *dst = _roomPalette[color] + _paletteMod; - dst++; + if (!transpCheck || color != _transparentColor) { + if (_vm->_game.features & GF_16BIT_COLOR) + WRITE_UINT16(dst, READ_LE_UINT16(_vm->_hePalettes + 2048 + color * 2)); + else + *dst = _roomPalette[color] + _paletteMod; + } + dst += _vm->_bitDepth; } while (--reps); bits >>= 8; bits |= (*src++) << (cl - 8); @@ -2900,7 +2943,7 @@ void Gdi::drawStripComplex(byte *dst, int dstPitch, const byte *src, int height, } } } while (--x); - dst += dstPitch - 8; + dst += dstPitch - 8 * _vm->_bitDepth; } while (--height); } @@ -2915,9 +2958,13 @@ void Gdi::drawStripBasicH(byte *dst, int dstPitch, const byte *src, int height, int x = 8; do { FILL_BITS; - if (!transpCheck || color != _transparentColor) - *dst = _roomPalette[color] + _paletteMod; - dst++; + if (!transpCheck || color != _transparentColor) { + if (_vm->_game.features & GF_16BIT_COLOR) + WRITE_UINT16(dst, READ_LE_UINT16(_vm->_hePalettes + 2048 + color * 2)); + else + *dst = _roomPalette[color] + _paletteMod; + } + dst += _vm->_bitDepth; if (!READ_BIT) { } else if (!READ_BIT) { FILL_BITS; @@ -2932,7 +2979,7 @@ void Gdi::drawStripBasicH(byte *dst, int dstPitch, const byte *src, int height, color += inc; } } while (--x); - dst += dstPitch - 8; + dst += dstPitch - 8 * _vm->_bitDepth; } while (--height); } @@ -2948,8 +2995,12 @@ void Gdi::drawStripBasicV(byte *dst, int dstPitch, const byte *src, int height, int h = height; do { FILL_BITS; - if (!transpCheck || color != _transparentColor) - *dst = _roomPalette[color] + _paletteMod; + if (!transpCheck || color != _transparentColor) { + if (_vm->_game.features & GF_16BIT_COLOR) + WRITE_UINT16(dst, READ_LE_UINT16(_vm->_hePalettes + 2048 + color * 2)); + else + *dst = _roomPalette[color] + _paletteMod; + } dst += dstPitch; if (!READ_BIT) { } else if (!READ_BIT) { @@ -3016,8 +3067,12 @@ void Gdi::drawStripRaw(byte *dst, int dstPitch, const byte *src, int height, con do { for (x = 0; x < 8; x ++) { byte color = *src++; - if (!transpCheck || color != _transparentColor) - dst[x] = _roomPalette[color] + _paletteMod; + if (!transpCheck || color != _transparentColor) { + if (_vm->_game.features & GF_16BIT_COLOR) + WRITE_UINT16(dst + x * 2, READ_LE_UINT16(_vm->_hePalettes + 2048 + color * 2)); + else + dst[x] = _roomPalette[color] + _paletteMod; + } } dst += dstPitch; } while (--height); diff --git a/engines/scumm/gfx.h b/engines/scumm/gfx.h index e4c1054450..88852c8388 100644 --- a/engines/scumm/gfx.h +++ b/engines/scumm/gfx.h @@ -155,11 +155,11 @@ struct VirtScreen : Graphics::Surface { } byte *getPixels(int x, int y) const { - return (byte *)pixels + xstart + y * pitch + x; + return (byte *)pixels + y * pitch + (xstart * 2 + x) * bytesPerPixel; } byte *getBackPixels(int x, int y) const { - return (byte *)backBuf + xstart + y * pitch + x; + return (byte *)backBuf + y * pitch + (xstart * 2 + x) * bytesPerPixel; } }; diff --git a/engines/scumm/he/animation_he.cpp b/engines/scumm/he/animation_he.cpp index 0cc4419778..5983df2308 100644 --- a/engines/scumm/he/animation_he.cpp +++ b/engines/scumm/he/animation_he.cpp @@ -66,6 +66,31 @@ int MoviePlayer::load(const char *filename, int flags, int image) { return 0; } +void MoviePlayer::copyFrameToBuffer(byte *dst, uint x, uint y, uint pitch) { + uint h = getHeight(); + uint w = getWidth(); + + byte *src = _videoFrameBuffer; + + if (_vm->_game.features & GF_16BIT_COLOR) { + dst += y * pitch + x * 2; + do { + for (uint i = 0; i < w; i++) + WRITE_UINT16(dst + i * 2, src[i]); + + dst += pitch; + src += w; + } while (--h); + } else { + dst += y * pitch + x; + do { + memcpy(dst, src, w); + dst += pitch; + src += w; + } while (--h); + } +} + void MoviePlayer::handleNextFrame() { if (!isVideoLoaded()) { return; @@ -80,14 +105,14 @@ void MoviePlayer::handleNextFrame() { assert(dstPtr); uint8 *dst = _vm->findWrappedBlock(MKID_BE('WIZD'), dstPtr, 0, 0); assert(dst); - copyFrameToBuffer(dst, 0, 0, _vm->_screenWidth); + copyFrameToBuffer(dst, 0, 0, _vm->_screenWidth * _vm->_bitDepth); } else if (_flags & 1) { - copyFrameToBuffer(pvs->getBackPixels(0, 0), 0, 0, _vm->_screenWidth); + copyFrameToBuffer(pvs->getBackPixels(0, 0), 0, 0, pvs->pitch); Common::Rect imageRect(getWidth(), getHeight()); _vm->restoreBackgroundHE(imageRect); } else { - copyFrameToBuffer(pvs->getPixels(0, 0), 0, 0, _vm->_screenWidth); + copyFrameToBuffer(pvs->getPixels(0, 0), 0, 0, pvs->pitch); Common::Rect imageRect(getWidth(), getHeight()); _vm->markRectAsDirty(kMainVirtScreen, imageRect); diff --git a/engines/scumm/he/animation_he.h b/engines/scumm/he/animation_he.h index 39f03960c4..e2fc1d04b7 100644 --- a/engines/scumm/he/animation_he.h +++ b/engines/scumm/he/animation_he.h @@ -54,6 +54,7 @@ public: int getImageNum(); int load(const char *filename, int flags, int image = 0); + void copyFrameToBuffer(byte *dst, uint x, uint y, uint pitch); void handleNextFrame(); protected: diff --git a/engines/scumm/he/intern_he.h b/engines/scumm/he/intern_he.h index c2079fa5fe..949113aeeb 100644 --- a/engines/scumm/he/intern_he.h +++ b/engines/scumm/he/intern_he.h @@ -455,6 +455,7 @@ protected: uint8 *getHEPaletteIndex(int palSlot); int getHEPaletteColor(int palSlot, int color); int getHEPaletteSimilarColor(int palSlot, int red, int green, int start, int end); + int getHEPalette16BitColorComponent(int component, int type); int getHEPaletteColorComponent(int palSlot, int color, int component); void setHEPaletteColor(int palSlot, uint8 color, uint8 r, uint8 g, uint8 b); void setHEPaletteFromPtr(int palSlot, const uint8 *palData); @@ -463,7 +464,7 @@ protected: void setHEPaletteFromRoom(int palSlot, int resId, int state); void restoreHEPalette(int palSlot); void copyHEPalette(int dstPalSlot, int srcPalSlot); - void copyHEPaletteColor(int palSlot, uint8 dstColor, uint8 srcColor); + void copyHEPaletteColor(int palSlot, uint8 dstColor, uint16 srcColor); protected: /* HE version 90 script opcodes */ diff --git a/engines/scumm/he/palette_he.cpp b/engines/scumm/he/palette_he.cpp index d055b77ee2..812c39d173 100644 --- a/engines/scumm/he/palette_he.cpp +++ b/engines/scumm/he/palette_he.cpp @@ -31,6 +31,27 @@ namespace Scumm { +uint8 *ScummEngine::getHEPaletteSlot(uint16 palSlot) { + assertRange(0, palSlot, _numPalettes, "palette"); + + if (_game.heversion >= 99) { + if (palSlot) + return _hePalettes + palSlot * _hePaletteSlot + 768; + else + return _hePalettes + _hePaletteSlot + 768; + } + + return NULL; +} + +uint16 ScummEngine::get16BitColor(uint8 r, uint8 g, uint8 b) { + uint16 ar = (r >> 3) << 10; + uint16 ag = (g >> 3) << 5; + uint16 ab = (b >> 3) << 0; + uint16 col = ar | ag | ab; + return col; +} + void ScummEngine_v71he::remapHEPalette(const uint8 *src, uint8 *dst) { int r, g, b, sum, bestitem, bestsum; int ar, ag, ab; @@ -38,7 +59,7 @@ void ScummEngine_v71he::remapHEPalette(const uint8 *src, uint8 *dst) { src += 30; if (_game.heversion >= 99) { - palPtr = _hePalettes + 1024 + 30; + palPtr = _hePalettes + _hePaletteSlot + 30; } else { palPtr = _currentPalette + 30; } @@ -73,9 +94,9 @@ void ScummEngine_v71he::remapHEPalette(const uint8 *src, uint8 *dst) { uint8 *ScummEngine_v90he::getHEPaletteIndex(int palSlot) { if (palSlot) { assert(palSlot >= 1 && palSlot <= _numPalettes); - return _hePalettes + palSlot * 1024; + return _hePalettes + palSlot * _hePaletteSlot; } else { - return _hePalettes + 1024; + return _hePalettes + _hePaletteSlot; } } @@ -84,7 +105,7 @@ int ScummEngine_v90he::getHEPaletteSimilarColor(int palSlot, int red, int green, assertRange(0, start, 255, "start palette slot"); assertRange(0, end, 255, "pend alette slot"); - uint8 *pal = _hePalettes + palSlot * 1024 + start * 3; + uint8 *pal = _hePalettes + palSlot * _hePaletteSlot + start * 3; int bestsum = 0x7FFFFFFF; int bestitem = start; @@ -105,39 +126,83 @@ int ScummEngine_v90he::getHEPaletteSimilarColor(int palSlot, int red, int green, return bestitem; } +int ScummEngine_v90he::getHEPalette16BitColorComponent(int component, int type) { + uint16 col; + if (type == 2) { + col = (((component & 0xFFFF) >> 0) & 0x1F) << 3;; + } else if (type == 1) { + col = (((component & 0xFFFF) >> 5) & 0x1F) << 3; + } else { + col = (((component & 0xFFFF) >> 10) & 0x1F) << 3; + } + return col; +} + int ScummEngine_v90he::getHEPaletteColorComponent(int palSlot, int color, int component) { assertRange(1, palSlot, _numPalettes, "palette"); assertRange(0, color, 255, "palette slot"); - return _hePalettes[palSlot * 1024 + color * 3 + component % 3]; + return _hePalettes[palSlot * _hePaletteSlot + color * 3 + component % 3]; } int ScummEngine_v90he::getHEPaletteColor(int palSlot, int color) { assertRange(1, palSlot, _numPalettes, "palette"); assertRange(0, color, 255, "palette slot"); - return _hePalettes[palSlot * 1024 + 768 + color]; + if (_game.features & GF_16BIT_COLOR) + return READ_LE_UINT16(_hePalettes + palSlot * _hePaletteSlot + 768 + color * 2); + else + return _hePalettes[palSlot * _hePaletteSlot + 768 + color]; } void ScummEngine_v90he::setHEPaletteColor(int palSlot, uint8 color, uint8 r, uint8 g, uint8 b) { debug(7, "setHEPaletteColor(%d, %d, %d, %d, %d)", palSlot, color, r, g, b); assertRange(1, palSlot, _numPalettes, "palette"); - uint8 *p = _hePalettes + palSlot * 1024 + color * 3; + + uint8 *p = _hePalettes + palSlot * _hePaletteSlot + color * 3; *(p + 0) = r; *(p + 1) = g; *(p + 2) = b; - _hePalettes[palSlot * 1024 + 768 + color] = color; + if (_game.features & GF_16BIT_COLOR) { + WRITE_LE_UINT16(_hePalettes + palSlot * _hePaletteSlot + 768 + color * 2, get16BitColor(r, g, b)); + } else { + _hePalettes[palSlot * _hePaletteSlot + 768 + color] = color; + } } void ScummEngine_v90he::setHEPaletteFromPtr(int palSlot, const uint8 *palData) { assertRange(1, palSlot, _numPalettes, "palette"); - uint8 *pc = _hePalettes + palSlot * 1024; + + uint8 *pc = _hePalettes + palSlot * _hePaletteSlot; uint8 *pi = pc + 768; - for (int i = 0; i < 256; ++i) { - *pc++ = *palData++; - *pc++ = *palData++; - *pc++ = *palData++; - *pi++ = i; + if (_game.features & GF_16BIT_COLOR) { + for (int i = 0; i < 256; ++i) { + uint8 r = *pc++ = *palData++; + uint8 g = *pc++ = *palData++; + uint8 b = *pc++ = *palData++; + WRITE_LE_UINT16(pi, get16BitColor(r, g, b)); pi += 2; + } + } else { + for (int i = 0; i < 256; ++i) { + *pc++ = *palData++; + *pc++ = *palData++; + *pc++ = *palData++; + *pi++ = i; + } + } + + int i; + uint8 *palPtr = _hePalettes + palSlot * _hePaletteSlot + 768; + if (_game.features & GF_16BIT_COLOR) { + for (i = 0; i < 10; ++i) + WRITE_LE_UINT16(palPtr + i * 2, i); + for (i = 246; i < 256; ++i) + WRITE_LE_UINT16(palPtr + i * 2, i); + } else { + for (i = 0; i < 10; ++i) + *(palPtr + i) = i; + for (i = 246; i < 256; ++i) + *(palPtr + i) = i; } } @@ -176,8 +241,9 @@ void ScummEngine_v90he::setHEPaletteFromRoom(int palSlot, int resId, int state) void ScummEngine_v90he::restoreHEPalette(int palSlot) { debug(7, "restoreHEPalette(%d)", palSlot); assertRange(1, palSlot, _numPalettes, "palette"); + if (palSlot != 1) { - memcpy(_hePalettes + palSlot * 1024, _hePalettes + 1024, 1024); + memcpy(_hePalettes + palSlot * _hePaletteSlot, _hePalettes + _hePaletteSlot, _hePaletteSlot); } } @@ -185,18 +251,27 @@ void ScummEngine_v90he::copyHEPalette(int dstPalSlot, int srcPalSlot) { debug(7, "copyHEPalette(%d, %d)", dstPalSlot, srcPalSlot); assert(dstPalSlot >= 1 && dstPalSlot <= _numPalettes); assert(srcPalSlot >= 1 && srcPalSlot <= _numPalettes); + if (dstPalSlot != srcPalSlot) { - memcpy(_hePalettes + dstPalSlot * 1024, _hePalettes + srcPalSlot * 1024, 1024); + memcpy(_hePalettes + dstPalSlot * _hePaletteSlot, _hePalettes + srcPalSlot * _hePaletteSlot, _hePaletteSlot); } } -void ScummEngine_v90he::copyHEPaletteColor(int palSlot, uint8 dstColor, uint8 srcColor) { +void ScummEngine_v90he::copyHEPaletteColor(int palSlot, uint8 dstColor, uint16 srcColor) { debug(7, "copyHEPaletteColor(%d, %d, %d)", palSlot, dstColor, srcColor); assertRange(1, palSlot, _numPalettes, "palette"); - uint8 *dstPal = _hePalettes + palSlot * 1024 + dstColor * 3; - uint8 *srcPal = _hePalettes + 1024 + srcColor * 3; - memcpy(dstPal, srcPal, 3); - _hePalettes[palSlot * 1024 + 768 + dstColor] = srcColor; + + uint8 *dstPal = _hePalettes + palSlot * _hePaletteSlot + dstColor * 3; + uint8 *srcPal = _hePalettes + _hePaletteSlot + srcColor * 3; + if (_game.features & GF_16BIT_COLOR) { + dstPal[0] = (srcColor >> 10) << 3; + dstPal[1] = (srcColor >> 5) << 3; + dstPal[2] = (srcColor >> 0) << 3; + WRITE_LE_UINT16(_hePalettes + palSlot * _hePaletteSlot + 768 + dstColor * 2, srcColor); + } else { + memcpy(dstPal, srcPal, 3); + _hePalettes[palSlot * _hePaletteSlot + 768 + dstColor] = srcColor; + } } void ScummEngine_v99he::setPaletteFromPtr(const byte *ptr, int numcolor) { @@ -209,7 +284,7 @@ void ScummEngine_v99he::setPaletteFromPtr(const byte *ptr, int numcolor) { assertRange(0, numcolor, 256, "setPaletteFromPtr: numcolor"); - dest = _hePalettes + 1024; + dest = _hePalettes + _hePaletteSlot; for (i = 0; i < numcolor; i++) { r = *ptr++; @@ -220,48 +295,63 @@ void ScummEngine_v99he::setPaletteFromPtr(const byte *ptr, int numcolor) { *dest++ = r; *dest++ = g; *dest++ = b; - _hePalettes[1792 + i] = i; + + if (_game.features & GF_16BIT_COLOR) { + WRITE_LE_UINT16(_hePalettes + 2048 + i * 2, get16BitColor(r, g, b)); + } else { + _hePalettes[1792 + i] = i; + } } else { dest += 3; } } - memcpy(_hePalettes, _hePalettes + 1024, 768); - - for (i = 0; i < 10; ++i) - _hePalettes[1792 + i] = i; - for (i = 246; i < 256; ++i) - _hePalettes[1792 + i] = i; + memcpy(_hePalettes, _hePalettes + _hePaletteSlot, 768); + if (_game.features & GF_16BIT_COLOR) { + for (i = 0; i < 10; ++i) + WRITE_LE_UINT16(_hePalettes + 2048 + i * 2, i); + for (i = 246; i < 256; ++i) + WRITE_LE_UINT16(_hePalettes + 2048 + i * 2, i); + } else { + for (i = 0; i < 10; ++i) + _hePalettes[1792 + i] = i; + for (i = 246; i < 256; ++i) + _hePalettes[1792 + i] = i; + } setDirtyColors(0, numcolor - 1); } void ScummEngine_v99he::darkenPalette(int redScale, int greenScale, int blueScale, int startColor, int endColor) { uint8 *src, *dst; - int color, j; + int j, r, g, b; src = _hePalettes + startColor * 3; - dst = _hePalettes + 1024 + startColor * 3; + dst = _hePalettes + _hePaletteSlot + startColor * 3; for (j = startColor; j <= endColor; j++) { - color = *src++; - color = color * redScale / 0xFF; - if (color > 255) - color = 255; - *dst++ = color; - - color = *src++; - color = color * greenScale / 0xFF; - if (color > 255) - color = 255; - *dst++ = color; - - color = *src++; - color = color * blueScale / 0xFF; - if (color > 255) - color = 255; - *dst++ = color; - - _hePalettes[1792 + j] = j; + r = *src++; + r = r * redScale / 0xFF; + if (r > 255) + r = 255; + *dst++ = r; + + g = *src++; + g = g * greenScale / 0xFF; + if (g > 255) + g = 255; + *dst++ = g; + + b = *src++; + b = b * blueScale / 0xFF; + if (b > 255) + b = 255; + *dst++ = b; + + if (_game.features & GF_16BIT_COLOR) { + WRITE_LE_UINT16(_hePalettes + 2048 + j * 2, get16BitColor(r, g, b)); + } else { + _hePalettes[1792 + j] = j; + } setDirtyColors(j, endColor); } } @@ -272,26 +362,39 @@ void ScummEngine_v99he::copyPalColor(int dst, int src) { if ((uint) dst >= 256 || (uint) src >= 256) error("copyPalColor: invalid values, %d, %d", dst, src); - dp = &_hePalettes[1024 + dst * 3]; - sp = &_hePalettes[1024 + src * 3]; + dp = &_hePalettes[_hePaletteSlot + dst * 3]; + sp = &_hePalettes[_hePaletteSlot + src * 3]; dp[0] = sp[0]; dp[1] = sp[1]; dp[2] = sp[2]; - _hePalettes[1792 + dst] = dst; + + if (_game.features & GF_16BIT_COLOR) { + WRITE_LE_UINT16(_hePalettes + 2048 + dst * 2, get16BitColor(sp[0], sp[1], sp[2])); + } else { + _hePalettes[1792 + dst] = dst; + } setDirtyColors(dst, dst); } void ScummEngine_v99he::setPalColor(int idx, int r, int g, int b) { - _hePalettes[1024 + idx * 3 + 0] = r; - _hePalettes[1024 + idx * 3 + 1] = g; - _hePalettes[1024 + idx * 3 + 2] = b; - _hePalettes[1792 + idx] = idx; + _hePalettes[_hePaletteSlot + idx * 3 + 0] = r; + _hePalettes[_hePaletteSlot + idx * 3 + 1] = g; + _hePalettes[_hePaletteSlot + idx * 3 + 2] = b; + + if (_game.features & GF_16BIT_COLOR) { + WRITE_LE_UINT16(_hePalettes + 2048 + idx * 2, get16BitColor(r, g, b)); + } else { + _hePalettes[1792 + idx] = idx; + } setDirtyColors(idx, idx); } void ScummEngine_v99he::updatePalette() { + if (_game.features & GF_16BIT_COLOR) + return; + if (_palDirtyMax == -1) return; diff --git a/engines/scumm/he/script_v100he.cpp b/engines/scumm/he/script_v100he.cpp index 5912e3d528..d588c26a77 100644 --- a/engines/scumm/he/script_v100he.cpp +++ b/engines/scumm/he/script_v100he.cpp @@ -2152,8 +2152,9 @@ void ScummEngine_v100he::o100_systemOps() { } void ScummEngine_v100he::o100_cursorCommand() { - int a, i; + int a, b, i; int args[16]; + byte subOp = fetchScriptByte(); switch (subOp) { @@ -2168,12 +2169,12 @@ void ScummEngine_v100he::o100_cursorCommand() { case 0x80: case 0x81: a = pop(); - _wiz->loadWizCursor(a); + _wiz->loadWizCursor(a, 0); break; case 0x82: - pop(); + b = pop(); a = pop(); - _wiz->loadWizCursor(a); + _wiz->loadWizCursor(a, b); break; case 0x86: // SO_CURSOR_ON Turn cursor on _cursor.state = 1; @@ -2576,7 +2577,8 @@ void ScummEngine_v100he::o100_getWizData() { } void ScummEngine_v100he::o100_getPaletteData() { - int b, c, d, e; + int c, d, e; + int r, g, b; int palSlot, color; byte subOp = fetchScriptByte(); @@ -2585,7 +2587,10 @@ void ScummEngine_v100he::o100_getPaletteData() { case 13: c = pop(); b = pop(); - push(getHEPaletteColorComponent(1, b, c)); + if (_game.features & GF_16BIT_COLOR) + push(getHEPalette16BitColorComponent(b, c)); + else + push(getHEPaletteColorComponent(1, b, c)); break; case 20: color = pop(); @@ -2596,20 +2601,30 @@ void ScummEngine_v100he::o100_getPaletteData() { e = pop(); d = pop(); palSlot = pop(); - pop(); - c = pop(); b = pop(); - push(getHEPaletteSimilarColor(palSlot, b, c, d, e)); + g = pop(); + r = pop(); + push(getHEPaletteSimilarColor(palSlot, r, g, d, e)); break; case 53: - pop(); - c = pop(); - c = MAX(0, c); - c = MIN(c, 255); b = pop(); b = MAX(0, b); b = MIN(b, 255); - push(getHEPaletteSimilarColor(1, b, c, 10, 245)); + g = pop(); + g = MAX(0, g); + g = MIN(g, 255); + r = pop(); + r = MAX(0, r); + r = MIN(r, 255); + if (_game.features & GF_16BIT_COLOR) { + uint32 ar = ((r >> 3) << 10) & 0xFFFF; + uint32 ag = ((g >> 3) << 5) & 0xFFFF; + uint32 ab = ((b >> 3) << 0) & 0xFFFF; + uint32 col = ar | ag | ab; + push(col); + } else { + push(getHEPaletteSimilarColor(1, r, g, 10, 245)); + } break; case 73: c = pop(); diff --git a/engines/scumm/he/script_v60he.cpp b/engines/scumm/he/script_v60he.cpp index 5ad447b1c7..b416a0e75d 100644 --- a/engines/scumm/he/script_v60he.cpp +++ b/engines/scumm/he/script_v60he.cpp @@ -115,6 +115,8 @@ int ScummEngine_v60he::convertFilePath(byte *dst) { int r = 0; if (dst[0] == '.' && dst[1] == '/') { // Game Data Path r = 2; + } else if (dst[2] == 'b' && dst[5] == 'k') { // Backyard Basketball INI + r = 13; } else if (dst[0] == '*' && dst[1] == '/') { // Save Game Path (HE72 - HE100) r = 2; } else if (dst[0] == 'c' && dst[1] == ':') { // Save Game Path (HE60 - HE71) diff --git a/engines/scumm/he/script_v80he.cpp b/engines/scumm/he/script_v80he.cpp index b71a0f9e10..4b759dec53 100644 --- a/engines/scumm/he/script_v80he.cpp +++ b/engines/scumm/he/script_v80he.cpp @@ -241,7 +241,7 @@ void ScummEngine_v80he::o80_writeConfigFile() { } void ScummEngine_v80he::o80_cursorCommand() { - int a, i; + int a, b, i; int args[16]; byte subOp = fetchScriptByte(); @@ -250,12 +250,12 @@ void ScummEngine_v80he::o80_cursorCommand() { case 0x13: case 0x14: a = pop(); - _wiz->loadWizCursor(a); + _wiz->loadWizCursor(a, 0); break; case 0x3C: - pop(); + b = pop(); a = pop(); - _wiz->loadWizCursor(a); + _wiz->loadWizCursor(a, b); break; case 0x90: // SO_CURSOR_ON Turn cursor on _cursor.state = 1; diff --git a/engines/scumm/he/script_v90he.cpp b/engines/scumm/he/script_v90he.cpp index cdfef1a5e5..212ba69bdc 100644 --- a/engines/scumm/he/script_v90he.cpp +++ b/engines/scumm/he/script_v90he.cpp @@ -1253,7 +1253,7 @@ void ScummEngine_v90he::o90_setSpriteGroupInfo() { void ScummEngine_v90he::o90_getWizData() { byte filename[4096]; - int state, resId; + int resId, state, type; int32 w, h; int32 x, y; @@ -1317,9 +1317,10 @@ void ScummEngine_v90he::o90_getWizData() { push(computeWizHistogram(resId, state, x, y, w, h)); break; case 139: - pop(); - pop(); - push(0); + type = pop(); + state = pop(); + resId = pop(); + push(_wiz->getWizImageData(resId, state, type)); break; case 141: pop(); @@ -2099,7 +2100,8 @@ void ScummEngine_v90he::o90_getObjectData() { } void ScummEngine_v90he::o90_getPaletteData() { - int b, c, d, e; + int c, d, e; + int r, g, b; int palSlot, color; byte subOp = fetchScriptByte(); @@ -2109,10 +2111,10 @@ void ScummEngine_v90he::o90_getPaletteData() { e = pop(); d = pop(); palSlot = pop(); - pop(); - c = pop(); b = pop(); - push(getHEPaletteSimilarColor(palSlot, b, c, d, e)); + g = pop(); + r = pop(); + push(getHEPaletteSimilarColor(palSlot, r, g, d, e)); break; case 52: c = pop(); @@ -2128,17 +2130,31 @@ void ScummEngine_v90he::o90_getPaletteData() { case 132: c = pop(); b = pop(); - push(getHEPaletteColorComponent(1, b, c)); + if (_game.features & GF_16BIT_COLOR) + push(getHEPalette16BitColorComponent(b, c)); + else + push(getHEPaletteColorComponent(1, b, c)); break; case 217: - pop(); - c = pop(); - c = MAX(0, c); - c = MIN(c, 255); b = pop(); b = MAX(0, b); b = MIN(b, 255); - push(getHEPaletteSimilarColor(1, b, c, 10, 245)); + g = pop(); + g = MAX(0, g); + g = MIN(g, 255); + r = pop(); + r = MAX(0, r); + r = MIN(r, 255); + + if (_game.features & GF_16BIT_COLOR) { + uint32 ar = ((r >> 3) << 10) & 0xFFFF; + uint32 ag = ((g >> 3) << 5) & 0xFFFF; + uint32 ab = ((b >> 3) << 0) & 0xFFFF; + uint32 col = ar | ag | ab; + push(col); + } else { + push(getHEPaletteSimilarColor(1, r, g, 10, 245)); + } break; default: error("o90_getPaletteData: Unknown case %d", subOp); diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp index 6038433847..1c3867b980 100644 --- a/engines/scumm/he/wiz_he.cpp +++ b/engines/scumm/he/wiz_he.cpp @@ -254,7 +254,9 @@ bool Wiz::polygonContains(const WizPolygon &pol, int x, int y) { return r; } -void Wiz::copyAuxImage(uint8 *dst1, uint8 *dst2, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch) { +void Wiz::copyAuxImage(uint8 *dst1, uint8 *dst2, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, uint8 bitDepth) { + assert(bitDepth == 1); + Common::Rect dstRect(srcx, srcy, srcx + srcw, srcy + srch); dstRect.clip(dstw, dsth); @@ -263,8 +265,8 @@ void Wiz::copyAuxImage(uint8 *dst1, uint8 *dst2, const uint8 *src, int dstw, int if (rh <= 0 || rw <= 0) return; - uint8 *dst1Ptr = dst1 + dstRect.left + dstRect.top * dstw; - uint8 *dst2Ptr = dst2 + dstRect.left + dstRect.top * dstw; + uint8 *dst1Ptr = dst1 + dstRect.top * dstw + dstRect.left; + uint8 *dst2Ptr = dst2 + dstRect.top * dstw + dstRect.left; const uint8 *dataPtr = src; while (rh--) { @@ -353,12 +355,24 @@ static bool calcClipRects(int dst_w, int dst_h, int src_x, int src_y, int src_w, return srcRect.isValidRect() && dstRect.isValidRect(); } -void Wiz::copy16BitWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *palPtr, const uint8 *xmapPtr) { - // TODO: Compressed 16 bits in 555 format +void Wiz::writeColor(uint8 *dstPtr, int dstType, uint16 color) { + switch (dstType) { + case kDstScreen: + WRITE_UINT16(dstPtr, color); + break; + case kDstMemory: + case kDstResource: + WRITE_LE_UINT16(dstPtr, color); + break; + default: + error("writeColor: Unknown dstType %d", dstType); + } +} +void Wiz::copy16BitWizImage(uint8 *dst, const uint8 *src, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *palPtr, const uint8 *xmapPtr) { Common::Rect r1, r2; if (calcClipRects(dstw, dsth, srcx, srcy, srcw, srch, rect, r1, r2)) { - dst += r2.top * dstw + r2.left; + dst += r2.top * dstPitch + r2.left * 2; if (flags & kWIFFlipY) { const int dy = (srcy < 0) ? srcy : (srch - r1.height()); r1.translate(0, dy); @@ -368,17 +382,17 @@ void Wiz::copy16BitWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, in r1.translate(dx, 0); } if (xmapPtr) { - decompress16BitWizImage(dst, dstw, src, r1, flags, palPtr, xmapPtr); + decompress16BitWizImage(dst, dstPitch, dstType, src, r1, flags, palPtr, xmapPtr); } else { - decompress16BitWizImage(dst, dstw, src, r1, flags); + decompress16BitWizImage(dst, dstPitch, dstType, src, r1, flags); } } } -void Wiz::copyWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *palPtr, const uint8 *xmapPtr) { +void Wiz::copyWizImage(uint8 *dst, const uint8 *src, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *palPtr, const uint8 *xmapPtr, uint8 bitDepth) { Common::Rect r1, r2; if (calcClipRects(dstw, dsth, srcx, srcy, srcw, srch, rect, r1, r2)) { - dst += r2.left + r2.top * dstw; + dst += r2.top * dstPitch + r2.left * bitDepth; if (flags & kWIFFlipY) { const int dy = (srcy < 0) ? srcy : (srch - r1.height()); r1.translate(0, dy); @@ -388,11 +402,11 @@ void Wiz::copyWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int src r1.translate(dx, 0); } if (xmapPtr) { - decompressWizImage(dst, dstw, src, r1, flags, palPtr, xmapPtr); + decompressWizImage(dst, dstPitch, dstType, src, r1, flags, palPtr, xmapPtr, bitDepth); } else if (palPtr) { - decompressWizImage(dst, dstw, src, r1, flags, palPtr); + decompressWizImage(dst, dstPitch, dstType, src, r1, flags, palPtr, NULL, bitDepth); } else { - decompressWizImage(dst, dstw, src, r1, flags); + decompressWizImage(dst, dstPitch, dstType, src, r1, flags, NULL, NULL, bitDepth); } } } @@ -431,13 +445,13 @@ static void decodeWizMask(uint8 *&dst, uint8 &mask, int w, int maskType) { } } -void Wiz::copyWizImageWithMask(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int maskT, int maskP) { +void Wiz::copyWizImageWithMask(uint8 *dst, const uint8 *src, int dstPitch, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int maskT, int maskP) { Common::Rect srcRect, dstRect; if (!calcClipRects(dstw, dsth, srcx, srcy, srcw, srch, rect, srcRect, dstRect)) { return; } dstw = dstw / 8; - dst += dstRect.top * dstw + dstRect.left / 8; + dst += dstRect.top * dstPitch + dstRect.left / 8; const uint8 *dataPtr, *dataPtrNext; uint8 code, mask, *dstPtr, *dstPtrNext; @@ -462,7 +476,7 @@ void Wiz::copyWizImageWithMask(uint8 *dst, const uint8 *src, int dstw, int dsth, w = srcRect.width(); mask = revBitMask(dstRect.left & 7); off = READ_LE_UINT16(dataPtr); dataPtr += 2; - dstPtrNext = dstPtr + dstw; + dstPtrNext = dstPtr + dstPitch; dataPtrNext = dataPtr + off; if (off != 0) { while (w > 0) { @@ -520,7 +534,7 @@ void Wiz::copyWizImageWithMask(uint8 *dst, const uint8 *src, int dstw, int dsth, } } -void Wiz::copyRawWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *palPtr, int transColor) { +void Wiz::copyRawWizImage(uint8 *dst, const uint8 *src, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *palPtr, int transColor, uint8 bitDepth) { Common::Rect r1, r2; if (calcClipRects(dstw, dsth, srcx, srcy, srcw, srch, rect, r1, r2)) { if (flags & kWIFFlipX) { @@ -537,19 +551,17 @@ void Wiz::copyRawWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int } int h = r1.height(); int w = r1.width(); - src += r1.left + r1.top * srcw; - dst += r2.left + r2.top * dstw; + src += r1.top * srcw + r1.left; + dst += r2.top * dstPitch + r2.left * bitDepth; if (palPtr) { - decompressRawWizImage(dst, dstw, src, srcw, w, h, transColor, palPtr); + decompressRawWizImage(dst, dstPitch, dstType, src, srcw, w, h, transColor, palPtr, bitDepth); } else { - decompressRawWizImage(dst, dstw, src, srcw, w, h, transColor); + decompressRawWizImage(dst, dstPitch, dstType, src, srcw, w, h, transColor, NULL, bitDepth); } } } -void Wiz::copyRaw16BitWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *palPtr, int transColor) { - // TODO: RAW 16 bits in 555 format - +void Wiz::copyRaw16BitWizImage(uint8 *dst, const uint8 *src, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, int transColor) { Common::Rect r1, r2; if (calcClipRects(dstw, dsth, srcx, srcy, srcw, srch, rect, r1, r2)) { if (flags & kWIFFlipX) { @@ -567,29 +579,39 @@ void Wiz::copyRaw16BitWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int h = r1.height(); int w = r1.width(); src += (r1.top * srcw + r1.left) * 2; - dst += r2.top * dstw + r2.left; + dst += r2.top * dstPitch + r2.left * 2; while (h--) { - for (int i = 0; i < w; ++i) { + for (int i = 0; i < w; ++ i) { uint16 col = READ_LE_UINT16(src + 2 * i); - uint8 r = ((col >> 10) & 0x1F) << 3; - uint8 g = ((col >> 5) & 0x1F) << 3; - uint8 b = ((col >> 0) & 0x1F) << 3; - uint8 color = _vm->convert16BitColor(col, r, g, b); - if (transColor == -1 || transColor != col) { - dst[i] = color; + writeColor(dst + i * 2, dstType, col); } } src += srcw * 2; - dst += dstw; + dst += dstPitch; } } } template -void Wiz::decompress16BitWizImage(uint8 *dst, int dstPitch, const uint8 *src, const Common::Rect &srcRect, int flags, const uint8 *palPtr, const uint8 *xmapPtr) { +void Wiz::write16BitColor(uint8 *dstPtr, const uint8 *dataPtr, int dstType, const uint8 *xmapPtr) { + uint16 col = READ_LE_UINT16(dataPtr); + if (type == kWizXMap) { + uint16 srcColor = (col >> 1) & 0x7DEF; + uint16 dstColor = (READ_UINT16(dstPtr) >> 1) & 0x7DEF; + uint16 newColor = srcColor + dstColor; + writeColor(dstPtr, dstType, newColor); + } + if (type == kWizCopy) { + writeColor(dstPtr, dstType, col); + } +} + +template +void Wiz::decompress16BitWizImage(uint8 *dst, int dstPitch, int dstType, const uint8 *src, const Common::Rect &srcRect, int flags, const uint8 *palPtr, const uint8 *xmapPtr) { const uint8 *dataPtr, *dataPtrNext; - uint8 code, *dstPtr, *dstPtrNext; + uint8 code; + uint8 *dstPtr, *dstPtrNext; int h, w, xoff, dstInc; if (type == kWizXMap) { @@ -616,10 +638,10 @@ void Wiz::decompress16BitWizImage(uint8 *dst, int dstPitch, const uint8 *src, co dstPtr += (h - 1) * dstPitch; dstPitch = -dstPitch; } - dstInc = 1; + dstInc = 2; if (flags & kWIFFlipX) { - dstPtr += w - 1; - dstInc = -1; + dstPtr += (w - 1) * 2; + dstInc = -2; } while (h--) { @@ -640,7 +662,7 @@ void Wiz::decompress16BitWizImage(uint8 *dst, int dstPitch, const uint8 *src, co code = -xoff; } - dstPtr += dstInc * code; + dstPtr += dstInc; w -= code; } else if (code & 2) { code = (code >> 2) + 1; @@ -658,18 +680,7 @@ void Wiz::decompress16BitWizImage(uint8 *dst, int dstPitch, const uint8 *src, co code += w; } while (code--) { - uint16 col = READ_LE_UINT16(dataPtr); - uint8 r = ((col >> 10) & 0x1F) << 3; - uint8 g = ((col >> 5) & 0x1F) << 3; - uint8 b = ((col >> 0) & 0x1F) << 3; - col = _vm->convert16BitColor(col, r, g, b); - - if (type == kWizXMap) { - *dstPtr = xmapPtr[col * 256 + *dstPtr]; - } - if (type == kWizCopy) { - *dstPtr = col; - } + write16BitColor(dstPtr, dataPtr, dstType, xmapPtr); dstPtr += dstInc; } dataPtr+= 2; @@ -689,18 +700,7 @@ void Wiz::decompress16BitWizImage(uint8 *dst, int dstPitch, const uint8 *src, co code += w; } while (code--) { - uint16 col = READ_LE_UINT16(dataPtr); - uint8 r = ((col >> 10) & 0x1F) << 3; - uint8 g = ((col >> 5) & 0x1F) << 3; - uint8 b = ((col >> 0) & 0x1F) << 3; - col = _vm->convert16BitColor(col, r, g, b); - - if (type == kWizXMap) { - *dstPtr = xmapPtr[col * 256 + *dstPtr]; - } - if (type == kWizCopy) { - *dstPtr = col; - } + write16BitColor(dstPtr, dataPtr, dstType, xmapPtr); dataPtr += 2; dstPtr += dstInc; } @@ -713,7 +713,36 @@ void Wiz::decompress16BitWizImage(uint8 *dst, int dstPitch, const uint8 *src, co } template -void Wiz::decompressWizImage(uint8 *dst, int dstPitch, const uint8 *src, const Common::Rect &srcRect, int flags, const uint8 *palPtr, const uint8 *xmapPtr) { +void Wiz::write8BitColor(uint8 *dstPtr, const uint8 *dataPtr, int dstType, const uint8 *palPtr, const uint8 *xmapPtr, uint8 bitDepth) { + if (bitDepth == 2) { + if (type == kWizXMap) { + uint16 color = READ_LE_UINT16(palPtr + *dataPtr * 2); + uint16 srcColor = (color >> 1) & 0x7DEF; + uint16 dstColor = (READ_UINT16(dstPtr) >> 1) & 0x7DEF; + uint16 newColor = srcColor + dstColor; + writeColor(dstPtr, dstType, newColor); + } + if (type == kWizRMap) { + writeColor(dstPtr, dstType, READ_LE_UINT16(palPtr + *dataPtr * 2)); + } + if (type == kWizCopy) { + writeColor(dstPtr, dstType, *dataPtr); + } + } else { + if (type == kWizXMap) { + *dstPtr = xmapPtr[*dataPtr * 256 + *dstPtr]; + } + if (type == kWizRMap) { + *dstPtr = palPtr[*dataPtr]; + } + if (type == kWizCopy) { + *dstPtr = *dataPtr; + } + } +} + +template +void Wiz::decompressWizImage(uint8 *dst, int dstPitch, int dstType, const uint8 *src, const Common::Rect &srcRect, int flags, const uint8 *palPtr, const uint8 *xmapPtr, uint8 bitDepth) { const uint8 *dataPtr, *dataPtrNext; uint8 code, *dstPtr, *dstPtrNext; int h, w, xoff, dstInc; @@ -742,9 +771,9 @@ void Wiz::decompressWizImage(uint8 *dst, int dstPitch, const uint8 *src, const C dstPtr += (h - 1) * dstPitch; dstPitch = -dstPitch; } - dstInc = 1; + dstInc = bitDepth; if (flags & kWIFFlipX) { - dstPtr += w - 1; + dstPtr += (w - 1) * bitDepth; dstInc = -1; } @@ -784,15 +813,7 @@ void Wiz::decompressWizImage(uint8 *dst, int dstPitch, const uint8 *src, const C code += w; } while (code--) { - if (type == kWizXMap) { - *dstPtr = xmapPtr[*dataPtr * 256 + *dstPtr]; - } - if (type == kWizRMap) { - *dstPtr = palPtr[*dataPtr]; - } - if (type == kWizCopy) { - *dstPtr = *dataPtr; - } + write8BitColor(dstPtr, dataPtr, dstType, palPtr, xmapPtr, bitDepth); dstPtr += dstInc; } dataPtr++; @@ -812,15 +833,8 @@ void Wiz::decompressWizImage(uint8 *dst, int dstPitch, const uint8 *src, const C code += w; } while (code--) { - if (type == kWizXMap) { - *dstPtr = xmapPtr[*dataPtr++ * 256 + *dstPtr]; - } - if (type == kWizRMap) { - *dstPtr = palPtr[*dataPtr++]; - } - if (type == kWizCopy) { - *dstPtr = *dataPtr++; - } + write8BitColor(dstPtr, dataPtr, dstType, palPtr, xmapPtr, bitDepth); + dataPtr++; dstPtr += dstInc; } } @@ -832,7 +846,7 @@ void Wiz::decompressWizImage(uint8 *dst, int dstPitch, const uint8 *src, const C } template -void Wiz::decompressRawWizImage(uint8 *dst, int dstPitch, const uint8 *src, int srcPitch, int w, int h, int transColor, const uint8 *palPtr) { +void Wiz::decompressRawWizImage(uint8 *dst, int dstPitch, int dstType, const uint8 *src, int srcPitch, int w, int h, int transColor, const uint8 *palPtr, uint8 bitDepth) { if (type == kWizRMap) { assert(palPtr != 0); } @@ -845,10 +859,18 @@ void Wiz::decompressRawWizImage(uint8 *dst, int dstPitch, const uint8 *src, int uint8 col = src[i]; if (transColor == -1 || transColor != col) { if (type == kWizRMap) { - dst[i] = palPtr[col]; + if (bitDepth == 2) { + writeColor(dst + i * 2, dstType, READ_LE_UINT16(palPtr + col * 2)); + } else { + dst[i] = palPtr[col]; + } } if (type == kWizCopy) { - dst[i] = col; + if (bitDepth == 2) { + writeColor(dst + i * 2, dstType, col); + } else { + dst[i] = col; + } } } } @@ -938,7 +960,7 @@ uint16 Wiz::getWizPixelColor(const uint8 *data, int x, int y, int w, int h, uint } if (bitDepth == 2) - return (READ_LE_UINT16(data) & 1) ? color : READ_LE_UINT16(data + 1); + return (READ_LE_UINT16(data) & 1) ? color : READ_LE_UINT16(data + 2); else return (data[0] & 1) ? color : data[1]; @@ -949,7 +971,7 @@ uint16 Wiz::getRawWizPixelColor(const uint8 *data, int x, int y, int w, int h, u return color; } if (bitDepth == 2) - return READ_LE_UINT16(data + y * w + x * 2); + return READ_LE_UINT16(data + (y * w + x) * 2); else return data[y * w + x]; } @@ -1038,6 +1060,22 @@ void Wiz::computeRawWizHistogram(uint32 *histogram, const uint8 *data, int srcPi } } +static int wizPackType2(uint8 *dst, const uint8 *src, int srcPitch, const Common::Rect& rCapt) { + debug(9, "wizPackType2([%d,%d,%d,%d])", rCapt.left, rCapt.top, rCapt.right, rCapt.bottom); + int w = rCapt.width(); + int h = rCapt.height(); + int size = w * h * 2; + if (dst) { + src += rCapt.top * srcPitch + rCapt.left * 2; + while (h--) { + memcpy(dst, src, w * 2); + dst += w * 2; + src += srcPitch; + } + } + return size; +} + static int wizPackType1(uint8 *dst, const uint8 *src, int srcPitch, const Common::Rect& rCapt, uint8 transColor) { debug(9, "wizPackType1(%d, [%d,%d,%d,%d])", transColor, rCapt.left, rCapt.top, rCapt.right, rCapt.bottom); src += rCapt.top * srcPitch + rCapt.left; @@ -1174,7 +1212,7 @@ static int wizPackType0(uint8 *dst, const uint8 *src, int srcPitch, const Common } void Wiz::captureWizImage(int resNum, const Common::Rect& r, bool backBuffer, int compType) { - debug(5, "ScummEngine_v72he::captureWizImage(%d, %d, [%d,%d,%d,%d])", resNum, compType, r.left, r.top, r.right, r.bottom); + debug(0, "captureWizImage(%d, %d, [%d,%d,%d,%d])", resNum, compType, r.left, r.top, r.right, r.bottom); uint8 *src = NULL; VirtScreen *pvs = &_vm->_virtscr[kMainVirtScreen]; if (backBuffer) { @@ -1187,7 +1225,7 @@ void Wiz::captureWizImage(int resNum, const Common::Rect& r, bool backBuffer, in rCapt.clip(r); const uint8 *palPtr; if (_vm->_game.heversion >= 99) { - palPtr = _vm->_hePalettes + 1024; + palPtr = _vm->_hePalettes + _vm->_hePaletteSlot; } else { palPtr = _vm->_currentPalette; } @@ -1196,6 +1234,9 @@ void Wiz::captureWizImage(int resNum, const Common::Rect& r, bool backBuffer, in int h = rCapt.height(); int transColor = (_vm->VAR_WIZ_TCOLOR != 0xFF) ? _vm->VAR(_vm->VAR_WIZ_TCOLOR) : 5; + if (_vm->_game.features & GF_16BIT_COLOR) + compType = 2; + // compute compressed size int dataSize = 0; int headerSize = palPtr ? 1080 : 36; @@ -1206,6 +1247,9 @@ void Wiz::captureWizImage(int resNum, const Common::Rect& r, bool backBuffer, in case 1: dataSize = wizPackType1(0, src, pvs->pitch, rCapt, transColor); break; + case 2: + dataSize = wizPackType2(0, src, pvs->pitch, rCapt); + break; default: error("unhandled compression type %d", compType); break; @@ -1249,6 +1293,9 @@ void Wiz::captureWizImage(int resNum, const Common::Rect& r, bool backBuffer, in case 1: wizPackType1(wizImg + headerSize, src, pvs->pitch, rCapt, transColor); break; + case 2: + wizPackType2(wizImg + headerSize, src, pvs->pitch, rCapt); + break; default: break; } @@ -1274,24 +1321,15 @@ void Wiz::displayWizImage(WizImage *pwi) { drawWizPolygon(pwi->resNum, pwi->state, pwi->x1, pwi->flags, 0, 0, 0); } else { const Common::Rect *r = NULL; - drawWizImage(pwi->resNum, pwi->state, pwi->x1, pwi->y1, 0, 0, 0, r, pwi->flags, 0, 0); + drawWizImage(pwi->resNum, pwi->state, pwi->x1, pwi->y1, 0, 0, 0, r, pwi->flags, 0, _vm->getHEPaletteSlot(0)); } } -uint8 *Wiz::drawWizImage(int resNum, int state, int x1, int y1, int zorder, int shadow, int field_390, const Common::Rect *clipBox, int flags, int dstResNum, int palette) { - debug(3, "drawWizImage(resNum %d, x1 %d y1 %d flags 0x%X zorder %d shadow %d field_390 %d dstResNum %d palette %d)", resNum, x1, y1, flags, zorder, shadow, field_390, dstResNum, palette); +uint8 *Wiz::drawWizImage(int resNum, int state, int x1, int y1, int zorder, int shadow, int field_390, const Common::Rect *clipBox, int flags, int dstResNum, const uint8 *palPtr) { + debug(3, "drawWizImage(resNum %d, x1 %d y1 %d flags 0x%X zorder %d shadow %d field_390 %d dstResNum %d)", resNum, x1, y1, flags, zorder, shadow, field_390, dstResNum); uint8 *dataPtr; uint8 *dst = NULL; - const uint8 *palPtr = NULL; - if (_vm->_game.heversion >= 99) { - if (palette) { - palPtr = _vm->_hePalettes + palette * 1024 + 768; - } else { - palPtr = _vm->_hePalettes + 1792; - } - } - const uint8 *xmapPtr = NULL; if (shadow) { dataPtr = _vm->getResourceAddress(rtImage, shadow); @@ -1334,13 +1372,25 @@ uint8 *Wiz::drawWizImage(int resNum, int state, int x1, int y1, int zorder, int error("WizImage printing is unimplemented"); } - int32 cw, ch; + int32 dstPitch, dstType, cw, ch; if (flags & kWIFBlitToMemBuffer) { - dst = (uint8 *)malloc(width * height); + dst = (uint8 *)malloc(width * height * _vm->_bitDepth); int transColor = (_vm->VAR_WIZ_TCOLOR != 0xFF) ? (_vm->VAR(_vm->VAR_WIZ_TCOLOR)) : 5; - memset(dst, transColor, width * height); + + if (_vm->_bitDepth == 2) { + uint8 *tmpPtr = dst; + for (uint i = 0; i < height; i++) { + for (uint j = 0; j < width; j++) + WRITE_LE_UINT16(tmpPtr + j * 2, transColor); + tmpPtr += width * 2; + } + } else { + memset(dst, transColor, width * height); + } cw = width; ch = height; + dstPitch = cw * _vm->_bitDepth; + dstType = kDstMemory; } else { if (dstResNum) { uint8 *dstPtr = _vm->getResourceAddress(rtImage, dstResNum); @@ -1348,6 +1398,8 @@ uint8 *Wiz::drawWizImage(int resNum, int state, int x1, int y1, int zorder, int dst = _vm->findWrappedBlock(MKID_BE('WIZD'), dstPtr, 0, 0); assert(dst); getWizImageDim(dstResNum, 0, cw, ch); + dstPitch = cw * _vm->_bitDepth; + dstType = kDstResource; } else { VirtScreen *pvs = &_vm->_virtscr[kMainVirtScreen]; if (flags & kWIFMarkBufferDirty) { @@ -1357,6 +1409,8 @@ uint8 *Wiz::drawWizImage(int resNum, int state, int x1, int y1, int zorder, int } cw = pvs->w; ch = pvs->h; + dstPitch = pvs->pitch; + dstType = kDstScreen; } } @@ -1376,7 +1430,7 @@ uint8 *Wiz::drawWizImage(int resNum, int state, int x1, int y1, int zorder, int } } - if (flags & kWIFRemapPalette) { + if (flags & kWIFRemapPalette && _vm->_bitDepth == 1) { palPtr = rmap + 4; } @@ -1388,28 +1442,27 @@ uint8 *Wiz::drawWizImage(int resNum, int state, int x1, int y1, int zorder, int switch (comp) { case 0: - copyRawWizImage(dst, wizd, cw, ch, x1, y1, width, height, &rScreen, flags, palPtr, transColor); + copyRawWizImage(dst, wizd, dstPitch, dstType, cw, ch, x1, y1, width, height, &rScreen, flags, palPtr, transColor, _vm->_bitDepth); break; case 1: if (flags & 0x80) { dst = _vm->getMaskBuffer(0, 0, 1); - copyWizImageWithMask(dst, wizd, cw, ch, x1, y1, width, height, &rScreen, 0, 2); + copyWizImageWithMask(dst, wizd, dstPitch, cw, ch, x1, y1, width, height, &rScreen, 0, 2); } else if (flags & 0x100) { dst = _vm->getMaskBuffer(0, 0, 1); - copyWizImageWithMask(dst, wizd, cw, ch, x1, y1, width, height, &rScreen, 0, 1); + copyWizImageWithMask(dst, wizd, dstPitch, cw, ch, x1, y1, width, height, &rScreen, 0, 1); } else { - copyWizImage(dst, wizd, cw, ch, x1, y1, width, height, &rScreen, flags, palPtr, xmapPtr); + copyWizImage(dst, wizd, dstPitch, dstType, cw, ch, x1, y1, width, height, &rScreen, flags, palPtr, xmapPtr, _vm->_bitDepth); } break; case 2: - copyRaw16BitWizImage(dst, wizd, cw, ch, x1, y1, width, height, &rScreen, flags, palPtr, transColor); + copyRaw16BitWizImage(dst, wizd, dstPitch, dstType, cw, ch, x1, y1, width, height, &rScreen, flags, transColor); break; case 4: // TODO: Unknown image type break; case 5: - // TODO: 16bit color compressed image - copy16BitWizImage(dst, wizd, cw, ch, x1, y1, width, height, &rScreen, flags, palPtr, xmapPtr); + copy16BitWizImage(dst, wizd, dstPitch, dstType, cw, ch, x1, y1, width, height, &rScreen, flags, palPtr, xmapPtr); break; default: error("drawWizImage: Unhandled wiz compression type %d", comp); @@ -1539,7 +1592,7 @@ void Wiz::drawWizPolygon(int resNum, int state, int id, int flags, int shadow, i } void Wiz::drawWizPolygonTransform(int resNum, int state, Common::Point *wp, int flags, int shadow, int dstResNum, int palette) { - debug(3, "drawWizPolygonTransform(resNum %d, flags 0x%X, shadow %d dstResNum %d palette %d)", resNum, flags, shadow, dstResNum, palette); + debug(0, "drawWizPolygonTransform(resNum %d, flags 0x%X, shadow %d dstResNum %d palette %d)", resNum, flags, shadow, dstResNum, palette); const Common::Rect *r = NULL; uint8 *srcWizBuf = NULL; bool freeBuffer = true; @@ -1552,8 +1605,10 @@ void Wiz::drawWizPolygonTransform(int resNum, int state, Common::Point *wp, int if (flags & 0x800000) { debug(0, "drawWizPolygonTransform() unhandled flag 0x800000"); } - srcWizBuf = drawWizImage(resNum, state, 0, 0, 0, shadow, 0, r, flags, 0, palette); + + srcWizBuf = drawWizImage(resNum, state, 0, 0, 0, shadow, 0, r, flags, 0, _vm->getHEPaletteSlot(palette)); } else { + assert(_vm->_bitDepth == 1); uint8 *dataPtr = _vm->getResourceAddress(rtImage, resNum); assert(dataPtr); srcWizBuf = _vm->findWrappedBlock(MKID_BE('WIZD'), dataPtr, state, 0); @@ -1562,7 +1617,7 @@ void Wiz::drawWizPolygonTransform(int resNum, int state, Common::Point *wp, int } } else { if (getWizImageData(resNum, state, 0) != 0) { - srcWizBuf = drawWizImage(resNum, state, 0, 0, 0, shadow, 0, r, kWIFBlitToMemBuffer, 0, palette); + srcWizBuf = drawWizImage(resNum, state, 0, 0, 0, shadow, 0, r, kWIFBlitToMemBuffer, 0, _vm->getHEPaletteSlot(palette)); } else { uint8 *dataPtr = _vm->getResourceAddress(rtImage, resNum); assert(dataPtr); @@ -1584,7 +1639,7 @@ void Wiz::drawWizPolygonTransform(int resNum, int state, Common::Point *wp, int dst = _vm->findWrappedBlock(MKID_BE('WIZD'), dstPtr, 0, 0); assert(dst); getWizImageDim(dstResNum, 0, dstw, dsth); - dstpitch = dstw; + dstpitch = dstw * _vm->_bitDepth; } else { if (flags & kWIFMarkBufferDirty) { dst = pvs->getPixels(0, 0); @@ -1666,7 +1721,7 @@ void Wiz::drawWizPolygonTransform(int resNum, int state, Common::Point *wp, int int16 width = ppa->xmax - ppa->xmin + 1; pra->x_step = ((ppa->x2 - ppa->x1) << 16) / width; pra->y_step = ((ppa->y2 - ppa->y1) << 16) / width; - pra->dst_offs = yoff + x1; + pra->dst_offs = yoff + x1 * _vm->_bitDepth; pra->w = w; pra->x_s = ppa->x1 << 16; pra->y_s = ppa->y1 << 16; @@ -1695,10 +1750,14 @@ void Wiz::drawWizPolygonTransform(int resNum, int state, Common::Point *wp, int assert(src_offs < wizW * wizH); x_acc += pra->x_step; y_acc += pra->y_step; - if (transColor == -1 || transColor != srcWizBuf[src_offs]) { - *dstPtr = srcWizBuf[src_offs]; + if (_vm->_bitDepth == 2) { + if (transColor == -1 || transColor != READ_LE_UINT16(srcWizBuf + src_offs * 2)) + WRITE_LE_UINT16(dstPtr, READ_LE_UINT16(srcWizBuf + src_offs * 2)); + } else { + if (transColor == -1 || transColor != srcWizBuf[src_offs]) + *dstPtr = srcWizBuf[src_offs]; } - dstPtr++; + dstPtr += _vm->_bitDepth; } } @@ -1721,13 +1780,13 @@ void Wiz::flushWizBuffer() { drawWizPolygon(pwi->resNum, pwi->state, pwi->x1, pwi->flags, pwi->shadow, 0, pwi->palette); } else { const Common::Rect *r = NULL; - drawWizImage(pwi->resNum, pwi->state, pwi->x1, pwi->y1, pwi->zorder, pwi->shadow, pwi->field_390, r, pwi->flags, 0, pwi->palette); + drawWizImage(pwi->resNum, pwi->state, pwi->x1, pwi->y1, pwi->zorder, pwi->shadow, pwi->field_390, r, pwi->flags, 0, _vm->getHEPaletteSlot(pwi->palette)); } } _imagesNum = 0; } -void Wiz::loadWizCursor(int resId) { +void Wiz::loadWizCursor(int resId, int palette) { int32 x, y; getWizImageSpot(resId, 0, x, y); if (x < 0) { @@ -1742,7 +1801,10 @@ void Wiz::loadWizCursor(int resId) { } const Common::Rect *r = NULL; - uint8 *cursor = drawWizImage(resId, 0, 0, 0, 0, 0, 0, r, kWIFBlitToMemBuffer, 0, 0); + _vm->_bitDepth = 1; + uint8 *cursor = drawWizImage(resId, 0, 0, 0, 0, 0, 0, r, kWIFBlitToMemBuffer, 0, _vm->getHEPaletteSlot(palette)); + _vm->_bitDepth = (_vm->_game.features & GF_16BIT_COLOR) ? 2 : 1; + int32 cw, ch; getWizImageDim(resId, 0, cw, ch); _vm->setCursorHotspot(x, y); @@ -1758,7 +1820,8 @@ void Wiz::displayWizComplexImage(const WizParameters *params) { int sourceImage = 0; if (params->processFlags & kWPFMaskImg) { sourceImage = params->sourceImage; - debug(0, "displayWizComplexImage() unhandled flag kWPFMaskImg"); + debug(3, "displayWizComplexImage() unhandled flag kWPFMaskImg"); + return; } int palette = 0; if (params->processFlags & kWPFPaletteNum) { @@ -1827,14 +1890,14 @@ void Wiz::displayWizComplexImage(const WizParameters *params) { } else { if (sourceImage != 0) { // TODO: Add support for kWPFMaskImg - drawWizImage(params->sourceImage, state, po_x, po_y, params->img.zorder, shadow, field_390, r, flags, dstResNum, palette); + drawWizImage(params->sourceImage, state, po_x, po_y, params->img.zorder, shadow, field_390, r, flags, dstResNum, _vm->getHEPaletteSlot(palette)); } else if (params->processFlags & (kWPFScaled | kWPFRotate)) { drawWizComplexPolygon(params->img.resNum, state, po_x, po_y, shadow, rotationAngle, scale, r, flags, dstResNum, palette); } else { if (flags & kWIFIsPolygon) { drawWizPolygon(params->img.resNum, state, po_x, flags, shadow, dstResNum, palette); } else { - drawWizImage(params->img.resNum, state, po_x, po_y, params->img.zorder, shadow, field_390, r, flags, dstResNum, palette); + drawWizImage(params->img.resNum, state, po_x, po_y, params->img.zorder, shadow, field_390, r, flags, dstResNum, _vm->getHEPaletteSlot(palette)); } } } @@ -1842,6 +1905,8 @@ void Wiz::displayWizComplexImage(const WizParameters *params) { void Wiz::createWizEmptyImage(int resNum, int img_x, int img_y, int img_w, int img_h) { const uint16 flags = 0xB; + const uint8 compType = (_vm->_game.features & GF_16BIT_COLOR) ? 2 : 0; + const uint8 bitDepth = (_vm->_game.features & GF_16BIT_COLOR) ? 2 : 1; int res_size = 0x1C; if (flags & 1) { res_size += 0x308; @@ -1852,11 +1917,11 @@ void Wiz::createWizEmptyImage(int resNum, int img_x, int img_y, int img_w, int i if (flags & 8) { res_size += 0x10C; } - res_size += 8 + img_w * img_h; + res_size += 8 + img_w * img_h * bitDepth; const uint8 *palPtr; if (_vm->_game.heversion >= 99) { - palPtr = _vm->_hePalettes + 1024; + palPtr = _vm->_hePalettes + _vm->_hePaletteSlot; } else { palPtr = _vm->_currentPalette; } @@ -1869,7 +1934,7 @@ void Wiz::createWizEmptyImage(int resNum, int img_x, int img_y, int img_w, int i WRITE_BE_UINT32(res_data, res_size); res_data += 4; WRITE_BE_UINT32(res_data, 'WIZH'); res_data += 4; WRITE_BE_UINT32(res_data, 0x14); res_data += 4; - WRITE_LE_UINT32(res_data, 0); res_data += 4; + WRITE_LE_UINT32(res_data, compType); res_data += 4; WRITE_LE_UINT32(res_data, img_w); res_data += 4; WRITE_LE_UINT32(res_data, img_h); res_data += 4; if (flags & 1) { @@ -1892,7 +1957,7 @@ void Wiz::createWizEmptyImage(int resNum, int img_x, int img_y, int img_w, int i } } WRITE_BE_UINT32(res_data, 'WIZD'); res_data += 4; - WRITE_BE_UINT32(res_data, 8 + img_w * img_h); res_data += 4; + WRITE_BE_UINT32(res_data, 8 + img_w * img_h * bitDepth); res_data += 4; } _vm->_res->setModified(rtImage, resNum); } @@ -1909,7 +1974,8 @@ void Wiz::fillWizRect(const WizParameters *params) { int c = READ_LE_UINT32(wizh + 0x0); int w = READ_LE_UINT32(wizh + 0x4); int h = READ_LE_UINT32(wizh + 0x8); - assert(c == 0); + assert(c == 0 || c == 2); + uint8 bitDepth = (c == 2) ? 2 : 1; Common::Rect areaRect, imageRect(w, h); if (params->processFlags & kWPFClipBox) { if (!imageRect.intersects(params->box)) { @@ -1932,10 +1998,15 @@ void Wiz::fillWizRect(const WizParameters *params) { assert(wizd); int dx = areaRect.width(); int dy = areaRect.height(); - wizd += areaRect.top * w + areaRect.left; + wizd += (areaRect.top * w + areaRect.left) * bitDepth; while (dy--) { - memset(wizd, color, dx); - wizd += w; + if (bitDepth == 2) { + for (int i = 0; i < dx; i++) + WRITE_LE_UINT16(wizd + i * 2, color); + } else { + memset(wizd, color, dx); + } + wizd += w * bitDepth; } } } @@ -1945,14 +2016,19 @@ void Wiz::fillWizRect(const WizParameters *params) { struct drawProcP { Common::Rect *imageRect; uint8 *wizd; - int width; + int pitch; + int depth; }; static void drawProc(int x, int y, int c, void *data) { drawProcP *param = (drawProcP *)data; if (param->imageRect->contains(x, y)) { - *(param->wizd + y * param->width + x) = c; + uint32 offs = y * param->pitch + x * param->depth; + if (param->depth == 2) + WRITE_LE_UINT16(param->wizd + offs, c); + else + *(param->wizd + offs) = c; } } @@ -1969,7 +2045,8 @@ void Wiz::fillWizLine(const WizParameters *params) { int c = READ_LE_UINT32(wizh + 0x0); int w = READ_LE_UINT32(wizh + 0x4); int h = READ_LE_UINT32(wizh + 0x8); - assert(c == 0); + assert(c == 0 || c == 2); + uint8 bitDepth = (c == 2) ? 2 : 1; Common::Rect imageRect(w, h); if (params->processFlags & kWPFClipBox) { if (!imageRect.intersects(params->box)) { @@ -1992,13 +2069,13 @@ void Wiz::fillWizLine(const WizParameters *params) { lineP.imageRect = &imageRect; lineP.wizd = wizd; - lineP.width = w; + lineP.pitch = w * bitDepth; + lineP.depth = bitDepth; if (params->processFlags & kWPFParams) { assert (params->params2 == 1); // Catch untested usage Graphics::drawThickLine(x1, y1, x2, y2, params->params1, color, drawProc, &lineP); } else { - Graphics::drawLine(x1, y1, x2, y2, color, drawProc, &lineP); } } @@ -2167,6 +2244,9 @@ void Wiz::processWizImage(const WizParameters *params) { img_x = params->img.x1; img_y = params->img.y1; } + if (params->processFlags & kWPFParams) { + debug(0, "Compression %d Color Depth %d", params->params1, params->params2); + } createWizEmptyImage(params->img.resNum, img_x, img_y, img_w, img_h); } break; @@ -2304,7 +2384,7 @@ int Wiz::isWizPixelNonTransparent(int resNum, int state, int x, int y, int flags ret = isWizPixelNonTransparent(wizd, x, y, w, h, 1); break; case 2: - ret = getRawWizPixelColor(wizd, x, y, w, h, 2, _vm->VAR(_vm->VAR_WIZ_TCOLOR)) != _vm->VAR(_vm->VAR_WIZ_TCOLOR) ? 1 : 0; + ret = getRawWizPixelColor(wizd, x, y, w, h, 2, _vm->VAR(_vm->VAR_WIZ_TCOLOR)) != _vm->VAR(_vm->VAR_WIZ_TCOLOR) ? 1 : 0; break; case 4: // TODO: Unknown image type diff --git a/engines/scumm/he/wiz_he.h b/engines/scumm/he/wiz_he.h index e6ea0fe57e..edc42e8788 100644 --- a/engines/scumm/he/wiz_he.h +++ b/engines/scumm/he/wiz_he.h @@ -142,6 +142,12 @@ enum { kWizCopy }; +enum DstSurface { + kDstScreen = 0, + kDstMemory = 1, + kDstResource = 2 +}; + class ScummEngine_v71he; class Wiz { @@ -188,27 +194,32 @@ public: void flushWizBuffer(); void getWizImageSpot(int resId, int state, int32 &x, int32 &y); - void loadWizCursor(int resId); + void loadWizCursor(int resId, int palette); void captureWizImage(int resNum, const Common::Rect& r, bool frontBuffer, int compType); void displayWizComplexImage(const WizParameters *params); void displayWizImage(WizImage *pwi); void processWizImage(const WizParameters *params); - uint8 *drawWizImage(int resNum, int state, int x1, int y1, int zorder, int shadow, int field_390, const Common::Rect *clipBox, int flags, int dstResNum, int palette); + uint8 *drawWizImage(int resNum, int state, int x1, int y1, int zorder, int shadow, int field_390, const Common::Rect *clipBox, int flags, int dstResNum, const uint8 *palPtr); void drawWizPolygon(int resNum, int state, int id, int flags, int shadow, int dstResNum, int palette); void drawWizComplexPolygon(int resNum, int state, int po_x, int po_y, int shadow, int angle, int zoom, const Common::Rect *r, int flags, int dstResNum, int palette); void drawWizPolygonTransform(int resNum, int state, Common::Point *wp, int flags, int shadow, int dstResNum, int palette); - static void copyAuxImage(uint8 *dst1, uint8 *dst2, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch); - static void copyWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags = 0, const uint8 *palPtr = NULL, const uint8 *xmapPtr = NULL); - static void copyWizImageWithMask(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int maskT, int maskP); - void copy16BitWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags = 0, const uint8 *palPtr = NULL, const uint8 *xmapPtr = NULL); - static void copyRawWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *palPtr, int transColor); - void copyRaw16BitWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *palPtr, int transColor); - template static void decompressWizImage(uint8 *dst, int dstPitch, const uint8 *src, const Common::Rect &srcRect, int flags, const uint8 *palPtr = NULL, const uint8 *xmapPtr = NULL); - template void decompress16BitWizImage(uint8 *dst, int dstPitch, const uint8 *src, const Common::Rect &srcRect, int flags, const uint8 *palPtr = NULL, const uint8 *xmapPtr = NULL); - template static void decompressRawWizImage(uint8 *dst, int dstPitch, const uint8 *src, int srcPitch, int w, int h, int transColor, const uint8 *palPtr = NULL); + static void copyAuxImage(uint8 *dst1, uint8 *dst2, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, uint8 bitdepth); + static void copyWizImageWithMask(uint8 *dst, const uint8 *src, int dstPitch, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int maskT, int maskP); + static void copyWizImage(uint8 *dst, const uint8 *src, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *palPtr, const uint8 *xmapPtr, uint8 bitdepth); + static void copyRawWizImage(uint8 *dst, const uint8 *src, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *palPtr, int transColor, uint8 bitdepth); + static void copy16BitWizImage(uint8 *dst, const uint8 *src, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *palPtr, const uint8 *xmapPtr); + static void copyRaw16BitWizImage(uint8 *dst, const uint8 *src, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, int transColor); + template static void decompress16BitWizImage(uint8 *dst, int dstPitch, int dstType, const uint8 *src, const Common::Rect &srcRect, int flags, const uint8 *palPtr = NULL, const uint8 *xmapPtr = NULL); + template static void decompressWizImage(uint8 *dst, int dstPitch, int dstType, const uint8 *src, const Common::Rect &srcRect, int flags, const uint8 *palPtr, const uint8 *xmapPtr, uint8 bitdepth); + template static void decompressRawWizImage(uint8 *dst, int dstPitch, int dstType, const uint8 *src, int srcPitch, int w, int h, int transColor, const uint8 *palPtr, uint8 bitdepth); + + template static void write16BitColor(uint8 *dst, const uint8 *src, int dstType, const uint8 *xmapPtr); + template static void write8BitColor(uint8 *dst, const uint8 *src, int dstType, const uint8 *palPtr, const uint8 *xmapPtr, uint8 bitDepth); + static void writeColor(uint8 *dstPtr, int dstType, uint16 color); + int isWizPixelNonTransparent(const uint8 *data, int x, int y, int w, int h, uint8 bitdepth); uint16 getWizPixelColor(const uint8 *data, int x, int y, int w, int h, uint8 bitDepth, uint16 color); uint16 getRawWizPixelColor(const uint8 *data, int x, int y, int w, int h, uint8 bitDepth, uint16 color); diff --git a/engines/scumm/palette.cpp b/engines/scumm/palette.cpp index a2cd4a0d4d..c6ec85cd88 100644 --- a/engines/scumm/palette.cpp +++ b/engines/scumm/palette.cpp @@ -310,9 +310,6 @@ void ScummEngine::setDirtyColors(int min, int max) { _palDirtyMin = min; if (_palDirtyMax < max) _palDirtyMax = max; - - if (_hePaletteCache) - memset(_hePaletteCache, -1, 65536); } void ScummEngine::initCycl(const byte *ptr) { @@ -813,16 +810,6 @@ void ScummEngine_v8::desaturatePalette(int hueScale, int satScale, int lightScal #endif -int ScummEngine::convert16BitColor(uint16 color, uint8 r, uint8 g, uint8 b) { - // HACK: Find the closest matching color, and store in - // cache for faster access. - if (_hePaletteCache[color] == -1) { - _hePaletteCache[color] = remapPaletteColor(r, g, b, -1); - } - - return _hePaletteCache[color]; -} - int ScummEngine::remapPaletteColor(int r, int g, int b, int threshold) { byte *pal; int ar, ag, ab, i; diff --git a/engines/scumm/saveload.cpp b/engines/scumm/saveload.cpp index cef13341b5..051873e147 100644 --- a/engines/scumm/saveload.cpp +++ b/engines/scumm/saveload.cpp @@ -1505,7 +1505,7 @@ void ScummEngine_v90he::saveOrLoad(Serializer *s) { void ScummEngine_v99he::saveOrLoad(Serializer *s) { ScummEngine_v90he::saveOrLoad(s); - s->saveLoadArrayOf(_hePalettes, (_numPalettes + 1) * 1024, sizeof(_hePalettes[0]), sleUint8); + s->saveLoadArrayOf(_hePalettes, (_numPalettes + 1) * _hePaletteSlot, sizeof(_hePalettes[0]), sleUint8); } void ScummEngine_v100he::saveOrLoad(Serializer *s) { diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index cbfa720e79..17ffc6e5b0 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -248,6 +248,7 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr) _switchRoomEffect2 = 0; _switchRoomEffect = 0; + _bitDepth = 0; _doEffect = false; _snapScroll = false; _currentLights = 0; @@ -264,8 +265,8 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr) _palManipPalette = NULL; _palManipIntermediatePal = NULL; memset(gfxUsageBits, 0, sizeof(gfxUsageBits)); - _hePaletteCache = NULL; _hePalettes = NULL; + _hePaletteSlot = 0; _shadowPalette = NULL; _shadowPaletteSize = 0; memset(_currentPalette, 0, sizeof(_currentPalette)); @@ -521,9 +522,11 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr) _screenHeight = 200; } + _bitDepth = (_game.features & GF_16BIT_COLOR) ? 2 : 1; + // Allocate gfx compositing buffer (not needed for V7/V8 games). if (_game.version < 7) - _compositeBuf = (byte *)malloc(_screenWidth * _screenHeight); + _compositeBuf = (byte *)malloc(_screenWidth * _screenHeight * _bitDepth); else _compositeBuf = 0; @@ -814,7 +817,6 @@ ScummEngine_v90he::~ScummEngine_v90he() { delete _logicHE; } if (_game.heversion >= 99) { - free(_hePaletteCache); free(_hePalettes); } } @@ -1182,7 +1184,7 @@ void ScummEngine::setupScumm() { int maxHeapThreshold = -1; if (_game.features & GF_16BIT_COLOR) { - // 16Bit color games require double the memory, due to increased resource sizes. + // 16bit color games require double the memory, due to increased resource sizes. maxHeapThreshold = 12 * 1024 * 1024; } else if (_game.features & GF_NEW_COSTUMES) { // Since the new costumes are very big, we increase the heap limit, to avoid having @@ -1204,7 +1206,7 @@ void ScummEngine::setupScumm() { } free(_compositeBuf); - _compositeBuf = (byte *)malloc(_screenWidth * _textSurfaceMultiplier * _screenHeight * _textSurfaceMultiplier); + _compositeBuf = (byte *)malloc(_screenWidth * _textSurfaceMultiplier * _screenHeight * _textSurfaceMultiplier * _bitDepth); } #ifdef ENABLE_SCUMM_7_8 @@ -1542,11 +1544,9 @@ void ScummEngine_v99he::resetScumm() { ScummEngine_v90he::resetScumm(); - _hePaletteCache = (int16 *)malloc(65536); - memset(_hePaletteCache, -1, 65536); - - _hePalettes = (uint8 *)malloc((_numPalettes + 1) * 1024); - memset(_hePalettes, 0, (_numPalettes + 1) * 1024); + _hePaletteSlot = (_game.features & GF_16BIT_COLOR) ? 1280 : 1024; + _hePalettes = (uint8 *)malloc((_numPalettes + 1) * _hePaletteSlot); + memset(_hePalettes, 0, (_numPalettes + 1) * _hePaletteSlot); // Array 129 is set to base name len = strlen(_filenamePattern.pattern); diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h index ff3852ee83..c4b2ab9e56 100644 --- a/engines/scumm/scumm.h +++ b/engines/scumm/scumm.h @@ -954,6 +954,7 @@ public: int _screenTop; Common::RenderMode _renderMode; + uint8 _bitDepth; protected: ColorCycle _colorCycle[16]; // Palette cycles @@ -1039,7 +1040,8 @@ protected: virtual void palManipulateInit(int resID, int start, int end, int time); void palManipulate(); public: - int convert16BitColor(uint16 color, uint8 r, uint8 g, uint8 b); + uint8 *getHEPaletteSlot(uint16 palSlot); + uint16 get16BitColor(uint8 r, uint8 g, uint8 b); int remapPaletteColor(int r, int g, int b, int threshold); // Used by Actor::remapActorPalette protected: void moveMemInPalRes(int start, int end, byte direction); @@ -1115,7 +1117,7 @@ public: // HE specific byte _HEV7ActorPalette[256]; uint8 *_hePalettes; - int16 *_hePaletteCache; + uint16 _hePaletteSlot; protected: int _shadowPaletteSize; -- cgit v1.2.3 From bf212d7b2f4f3b8851a6cd44c4c922cf0f46f94b Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Thu, 4 Jun 2009 09:30:12 +0000 Subject: Fix regression in copyWizImageWithMask, which caused corruption in readtime. svn-id: r41157 --- engines/scumm/he/wiz_he.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'engines/scumm') diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp index 1c3867b980..ff58623479 100644 --- a/engines/scumm/he/wiz_he.cpp +++ b/engines/scumm/he/wiz_he.cpp @@ -450,7 +450,7 @@ void Wiz::copyWizImageWithMask(uint8 *dst, const uint8 *src, int dstPitch, int d if (!calcClipRects(dstw, dsth, srcx, srcy, srcw, srch, rect, srcRect, dstRect)) { return; } - dstw = dstw / 8; + dstPitch /= 8; dst += dstRect.top * dstPitch + dstRect.left / 8; const uint8 *dataPtr, *dataPtrNext; @@ -1447,9 +1447,11 @@ uint8 *Wiz::drawWizImage(int resNum, int state, int x1, int y1, int zorder, int case 1: if (flags & 0x80) { dst = _vm->getMaskBuffer(0, 0, 1); + dstPitch = _vm->_bitDepth; copyWizImageWithMask(dst, wizd, dstPitch, cw, ch, x1, y1, width, height, &rScreen, 0, 2); } else if (flags & 0x100) { dst = _vm->getMaskBuffer(0, 0, 1); + dstPitch /= _vm->_bitDepth; copyWizImageWithMask(dst, wizd, dstPitch, cw, ch, x1, y1, width, height, &rScreen, 0, 1); } else { copyWizImage(dst, wizd, dstPitch, dstType, cw, ch, x1, y1, width, height, &rScreen, flags, palPtr, xmapPtr, _vm->_bitDepth); -- cgit v1.2.3 From d1210392ef1c755fc0c513d81e4981141e6963ee Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Thu, 4 Jun 2009 09:32:36 +0000 Subject: Ooops, correct typo in last commit. svn-id: r41158 --- engines/scumm/he/wiz_he.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/scumm') diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp index ff58623479..f9e76e682e 100644 --- a/engines/scumm/he/wiz_he.cpp +++ b/engines/scumm/he/wiz_he.cpp @@ -1447,7 +1447,7 @@ uint8 *Wiz::drawWizImage(int resNum, int state, int x1, int y1, int zorder, int case 1: if (flags & 0x80) { dst = _vm->getMaskBuffer(0, 0, 1); - dstPitch = _vm->_bitDepth; + dstPitch /= _vm->_bitDepth; copyWizImageWithMask(dst, wizd, dstPitch, cw, ch, x1, y1, width, height, &rScreen, 0, 2); } else if (flags & 0x100) { dst = _vm->getMaskBuffer(0, 0, 1); -- cgit v1.2.3 From d08c592bfd4c1b74e91227847c04afe2b7ca7ff4 Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Thu, 4 Jun 2009 09:36:13 +0000 Subject: Update drawBMAPObject for 16bit color. svn-id: r41159 --- engines/scumm/gfx.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/gfx.cpp b/engines/scumm/gfx.cpp index a141d51735..0427e32326 100644 --- a/engines/scumm/gfx.cpp +++ b/engines/scumm/gfx.cpp @@ -1956,13 +1956,11 @@ void Gdi::drawBMAPBg(const byte *ptr, VirtScreen *vs) { } void Gdi::drawBMAPObject(const byte *ptr, VirtScreen *vs, int obj, int x, int y, int w, int h) { - assert(_vm->_bitDepth == 1); - const byte *bmap_ptr = _vm->findResourceData(MKID_BE('BMAP'), ptr); assert(bmap_ptr); byte code = *bmap_ptr++; - int scrX = _vm->_screenStartStrip * 8; + int scrX = _vm->_screenStartStrip * 8 * _vm->_bitDepth; if (code == 8 || code == 9) { Common::Rect rScreen(0, 0, vs->w, vs->h); -- cgit v1.2.3 From a45b902716aa3a86e56efaefeee1d6ae3113fbd1 Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Thu, 4 Jun 2009 09:49:06 +0000 Subject: Ooops, re-enable codec32 code. svn-id: r41161 --- engines/scumm/akos.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/akos.cpp b/engines/scumm/akos.cpp index edfbe5730d..347b5a03fc 100644 --- a/engines/scumm/akos.cpp +++ b/engines/scumm/akos.cpp @@ -1301,8 +1301,6 @@ byte AkosRenderer::codec16(int xmoveCur, int ymoveCur) { } byte AkosRenderer::codec32(int xmoveCur, int ymoveCur) { - return 0; - #ifdef ENABLE_HE Common::Rect src, dst; -- cgit v1.2.3 From fdbc49ab5f4b9320e4cdac8edd427304910d8235 Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Thu, 4 Jun 2009 11:03:45 +0000 Subject: Fix the color of Poodles Galore's finger nails in Spy Fox 3. svn-id: r41162 --- engines/scumm/actor.cpp | 5 +++-- engines/scumm/actor.h | 2 +- engines/scumm/akos.cpp | 2 +- engines/scumm/akos.h | 2 +- engines/scumm/base-costume.h | 2 +- engines/scumm/costume.cpp | 13 ++++++++----- engines/scumm/costume.h | 6 +++--- engines/scumm/he/script_v100he.cpp | 6 +----- engines/scumm/he/script_v90he.cpp | 6 +----- engines/scumm/saveload.h | 2 +- 10 files changed, 21 insertions(+), 25 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/actor.cpp b/engines/scumm/actor.cpp index eea1ec070b..f3c8e2ff6b 100644 --- a/engines/scumm/actor.cpp +++ b/engines/scumm/actor.cpp @@ -2484,9 +2484,10 @@ void Actor::saveLoadWithSerializer(Serializer *ser) { MKLINE(Actor, _flip, sleByte, VER(32)), MKLINE(Actor, _heSkipLimbs, sleByte, VER(32)), - // Actor palette grew from 64 to 256 bytes + // Actor palette grew from 64 to 256 bytes and switched to uint16 in HE games MKARRAY_OLD(Actor, _palette[0], sleByte, 64, VER(8), VER(9)), - MKARRAY(Actor, _palette[0], sleByte, 256, VER(10)), + MKARRAY_OLD(Actor, _palette[0], sleByte, 256, VER(10), VER(77)), + MKARRAY(Actor, _palette[0], sleUint16, 256, VER(78)), MK_OBSOLETE(Actor, _mask, sleByte, VER(8), VER(9)), MKLINE(Actor, _shadowMode, sleByte, VER(8)), diff --git a/engines/scumm/actor.h b/engines/scumm/actor.h index 3e8fe6626b..d32f268b11 100644 --- a/engines/scumm/actor.h +++ b/engines/scumm/actor.h @@ -157,7 +157,7 @@ protected: }; - byte _palette[256]; + uint16 _palette[256]; int _elevation; uint16 _facing; uint16 _targetFacing; diff --git a/engines/scumm/akos.cpp b/engines/scumm/akos.cpp index 347b5a03fc..b7e36b7cea 100644 --- a/engines/scumm/akos.cpp +++ b/engines/scumm/akos.cpp @@ -289,7 +289,7 @@ void AkosCostumeLoader::costumeDecodeData(Actor *a, int frame, uint usemask) { } while ((uint16)mask); } -void AkosRenderer::setPalette(byte *new_palette) { +void AkosRenderer::setPalette(uint16 *new_palette) { uint size, i; size = _vm->getResourceDataSize(akpl); diff --git a/engines/scumm/akos.h b/engines/scumm/akos.h index 17576e5869..9f4f09d4dc 100644 --- a/engines/scumm/akos.h +++ b/engines/scumm/akos.h @@ -107,7 +107,7 @@ public: int16 _actorHitX, _actorHitY; bool _actorHitResult; - void setPalette(byte *_palette); + void setPalette(uint16 *_palette); void setFacing(const Actor *a); void setCostume(int costume, int shadow); diff --git a/engines/scumm/base-costume.h b/engines/scumm/base-costume.h index 59ca3ded1f..d41d795e34 100644 --- a/engines/scumm/base-costume.h +++ b/engines/scumm/base-costume.h @@ -145,7 +145,7 @@ public: } virtual ~BaseCostumeRenderer() {} - virtual void setPalette(byte *palette) = 0; + virtual void setPalette(uint16 *palette) = 0; virtual void setFacing(const Actor *a) = 0; virtual void setCostume(int costume, int shadow) = 0; diff --git a/engines/scumm/costume.cpp b/engines/scumm/costume.cpp index 82497de87a..4358e03a2a 100644 --- a/engines/scumm/costume.cpp +++ b/engines/scumm/costume.cpp @@ -791,7 +791,7 @@ byte ClassicCostumeRenderer::drawLimb(const Actor *a, int limb) { } -void NESCostumeRenderer::setPalette(byte *palette) { +void NESCostumeRenderer::setPalette(uint16 *palette) { // TODO } @@ -874,17 +874,20 @@ void ClassicCostumeLoader::costumeDecodeData(Actor *a, int frame, uint usemask) } while (mask&0xFFFF); } -void ClassicCostumeRenderer::setPalette(byte *palette) { +void ClassicCostumeRenderer::setPalette(uint16 *palette) { int i; byte color; if (_loaded._format == 0x57) { - memcpy(_palette, palette, 13); + for (i = 0; i < 13; i++) + _palette[i] = color; } else if (_vm->_game.features & GF_OLD_BUNDLE) { if (_vm->getCurrentLights() & LIGHTMODE_actor_use_colors) { - memcpy(_palette, palette, 16); + for (i = 0; i < 16; i++) + _palette[i] = color; } else { - memset(_palette, 8, 16); + for (i = 0; i < 16; i++) + _palette[i] = 8; _palette[12] = 0; } _palette[_loaded._palette[0]] = _palette[0]; diff --git a/engines/scumm/costume.h b/engines/scumm/costume.h index 003bd6ce2b..ecb12986cf 100644 --- a/engines/scumm/costume.h +++ b/engines/scumm/costume.h @@ -94,7 +94,7 @@ protected: public: ClassicCostumeRenderer(ScummEngine *vm) : BaseCostumeRenderer(vm), _loaded(vm) {} - void setPalette(byte *palette); + void setPalette(uint16 *palette); void setFacing(const Actor *a); void setCostume(int costume, int shadow); @@ -116,7 +116,7 @@ protected: public: NESCostumeRenderer(ScummEngine *vm) : BaseCostumeRenderer(vm), _loaded(vm) {} - void setPalette(byte *palette); + void setPalette(uint16 *palette); void setFacing(const Actor *a); void setCostume(int costume, int shadow); @@ -131,7 +131,7 @@ protected: public: C64CostumeRenderer(ScummEngine *vm) : BaseCostumeRenderer(vm), _loaded(vm) {} - void setPalette(byte *palette) {} + void setPalette(uint16 *palette) {} void setFacing(const Actor *a) {} void setCostume(int costume, int shadow); diff --git a/engines/scumm/he/script_v100he.cpp b/engines/scumm/he/script_v100he.cpp index d588c26a77..90f2764b3d 100644 --- a/engines/scumm/he/script_v100he.cpp +++ b/engines/scumm/he/script_v100he.cpp @@ -2617,11 +2617,7 @@ void ScummEngine_v100he::o100_getPaletteData() { r = MAX(0, r); r = MIN(r, 255); if (_game.features & GF_16BIT_COLOR) { - uint32 ar = ((r >> 3) << 10) & 0xFFFF; - uint32 ag = ((g >> 3) << 5) & 0xFFFF; - uint32 ab = ((b >> 3) << 0) & 0xFFFF; - uint32 col = ar | ag | ab; - push(col); + push(get16BitColor(r, g, b)); } else { push(getHEPaletteSimilarColor(1, r, g, 10, 245)); } diff --git a/engines/scumm/he/script_v90he.cpp b/engines/scumm/he/script_v90he.cpp index 212ba69bdc..c6b919f554 100644 --- a/engines/scumm/he/script_v90he.cpp +++ b/engines/scumm/he/script_v90he.cpp @@ -2147,11 +2147,7 @@ void ScummEngine_v90he::o90_getPaletteData() { r = MIN(r, 255); if (_game.features & GF_16BIT_COLOR) { - uint32 ar = ((r >> 3) << 10) & 0xFFFF; - uint32 ag = ((g >> 3) << 5) & 0xFFFF; - uint32 ab = ((b >> 3) << 0) & 0xFFFF; - uint32 col = ar | ag | ab; - push(col); + push(get16BitColor(r, g, b)); } else { push(getHEPaletteSimilarColor(1, r, g, 10, 245)); } diff --git a/engines/scumm/saveload.h b/engines/scumm/saveload.h index 29184ad023..49bfe39b21 100644 --- a/engines/scumm/saveload.h +++ b/engines/scumm/saveload.h @@ -50,7 +50,7 @@ namespace Scumm { * only saves/loads those which are valid for the version of the savegame * which is being loaded/saved currently. */ -#define CURRENT_VER 77 +#define CURRENT_VER 78 /** * An auxillary macro, used to specify savegame versions. We use this instead -- cgit v1.2.3 From be36b352fca2c3e6ec0ae3b0c33d0028927d5343 Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Fri, 5 Jun 2009 00:21:10 +0000 Subject: Sound resource 1 is used for queued speech in HE60+ games, and should never be nuked, when expiring resources. svn-id: r41182 --- engines/scumm/resource.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'engines/scumm') diff --git a/engines/scumm/resource.cpp b/engines/scumm/resource.cpp index 874b787615..a3b1a5be77 100644 --- a/engines/scumm/resource.cpp +++ b/engines/scumm/resource.cpp @@ -922,7 +922,11 @@ bool ScummEngine::isResourceInUse(int type, int i) const { case rtCostume: return isCostumeInUse(i); case rtSound: - return _sound->isSoundInUse(i); + // Sound resource 1 is used for queued speech + if (_game.heversion >= 60 && i == 1) + return true; + else + return _sound->isSoundInUse(i); case rtCharset: return _charset->getCurID() == i; case rtImage: -- cgit v1.2.3 From 9911c1bf59048d9661b720f3de6f33176b5ef1e2 Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Fri, 5 Jun 2009 00:33:25 +0000 Subject: Fix endian issue, the palette must be in little endian. svn-id: r41184 --- engines/scumm/akos.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/scumm') diff --git a/engines/scumm/akos.cpp b/engines/scumm/akos.cpp index b7e36b7cea..f4bb8a2c8b 100644 --- a/engines/scumm/akos.cpp +++ b/engines/scumm/akos.cpp @@ -1357,7 +1357,7 @@ byte AkosRenderer::codec32(int xmoveCur, int ymoveCur) { palPtr = _vm->_hePalettes + _paletteNum * _vm->_hePaletteSlot + 768; } else if (rgbs) { for (uint i = 0; i < 256; i++) - _palette[i] = _vm->get16BitColor(rgbs[i * 3 + 0], rgbs[i * 3 + 1], rgbs[i * 3 + 2]); + WRITE_LE_UINT16(_palette + i, _vm->get16BitColor(rgbs[i * 3 + 0], rgbs[i * 3 + 1], rgbs[i * 3 + 2])); palPtr = (uint8 *)_palette; } } else if (_vm->_game.heversion >= 99) { -- cgit v1.2.3 From e90364c890dcea2ca824941495365ed915146d41 Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Fri, 5 Jun 2009 01:20:39 +0000 Subject: Update o72_getPixel() for 16bit color, and cleanup. svn-id: r41187 --- engines/scumm/he/script_v72he.cpp | 12 +++++++++--- engines/scumm/he/wiz_he.cpp | 13 +++++-------- engines/scumm/he/wiz_he.h | 4 ++-- 3 files changed, 16 insertions(+), 13 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/he/script_v72he.cpp b/engines/scumm/he/script_v72he.cpp index bb209e78d1..049fb13cd2 100644 --- a/engines/scumm/he/script_v72he.cpp +++ b/engines/scumm/he/script_v72he.cpp @@ -1572,7 +1572,7 @@ void ScummEngine_v72he::o72_rename() { } void ScummEngine_v72he::o72_getPixel() { - byte area; + uint16 area; int y = pop(); int x = pop(); @@ -1587,11 +1587,17 @@ void ScummEngine_v72he::o72_getPixel() { switch (subOp) { case 9: // HE 100 case 218: - area = *vs->getBackPixels(x, y - vs->topline); + if (_game.features & GF_16BIT_COLOR) + area = READ_UINT16(vs->getBackPixels(x, y - vs->topline)); + else + area = *vs->getBackPixels(x, y - vs->topline); break; case 8: // HE 100 case 219: - area = *vs->getPixels(x, y - vs->topline); + if (_game.features & GF_16BIT_COLOR) + area = READ_UINT16(vs->getPixels(x, y - vs->topline)); + else + area = *vs->getPixels(x, y - vs->topline); break; default: error("o72_getPixel: default case %d", subOp); diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp index f9e76e682e..20ff7fa309 100644 --- a/engines/scumm/he/wiz_he.cpp +++ b/engines/scumm/he/wiz_he.cpp @@ -369,7 +369,7 @@ void Wiz::writeColor(uint8 *dstPtr, int dstType, uint16 color) { } } -void Wiz::copy16BitWizImage(uint8 *dst, const uint8 *src, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *palPtr, const uint8 *xmapPtr) { +void Wiz::copy16BitWizImage(uint8 *dst, const uint8 *src, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *xmapPtr) { Common::Rect r1, r2; if (calcClipRects(dstw, dsth, srcx, srcy, srcw, srch, rect, r1, r2)) { dst += r2.top * dstPitch + r2.left * 2; @@ -382,7 +382,7 @@ void Wiz::copy16BitWizImage(uint8 *dst, const uint8 *src, int dstPitch, int dstT r1.translate(dx, 0); } if (xmapPtr) { - decompress16BitWizImage(dst, dstPitch, dstType, src, r1, flags, palPtr, xmapPtr); + decompress16BitWizImage(dst, dstPitch, dstType, src, r1, flags, xmapPtr); } else { decompress16BitWizImage(dst, dstPitch, dstType, src, r1, flags); } @@ -608,7 +608,7 @@ void Wiz::write16BitColor(uint8 *dstPtr, const uint8 *dataPtr, int dstType, cons } template -void Wiz::decompress16BitWizImage(uint8 *dst, int dstPitch, int dstType, const uint8 *src, const Common::Rect &srcRect, int flags, const uint8 *palPtr, const uint8 *xmapPtr) { +void Wiz::decompress16BitWizImage(uint8 *dst, int dstPitch, int dstType, const uint8 *src, const Common::Rect &srcRect, int flags, const uint8 *xmapPtr) { const uint8 *dataPtr, *dataPtrNext; uint8 code; uint8 *dstPtr, *dstPtrNext; @@ -617,9 +617,6 @@ void Wiz::decompress16BitWizImage(uint8 *dst, int dstPitch, int dstType, const u if (type == kWizXMap) { assert(xmapPtr != 0); } - if (type == kWizRMap) { - assert(palPtr != 0); - } dstPtr = dst; dataPtr = src; @@ -683,7 +680,7 @@ void Wiz::decompress16BitWizImage(uint8 *dst, int dstPitch, int dstType, const u write16BitColor(dstPtr, dataPtr, dstType, xmapPtr); dstPtr += dstInc; } - dataPtr+= 2; + dataPtr += 2; } else { code = (code >> 2) + 1; if (xoff > 0) { @@ -1464,7 +1461,7 @@ uint8 *Wiz::drawWizImage(int resNum, int state, int x1, int y1, int zorder, int // TODO: Unknown image type break; case 5: - copy16BitWizImage(dst, wizd, dstPitch, dstType, cw, ch, x1, y1, width, height, &rScreen, flags, palPtr, xmapPtr); + copy16BitWizImage(dst, wizd, dstPitch, dstType, cw, ch, x1, y1, width, height, &rScreen, flags, xmapPtr); break; default: error("drawWizImage: Unhandled wiz compression type %d", comp); diff --git a/engines/scumm/he/wiz_he.h b/engines/scumm/he/wiz_he.h index edc42e8788..0a320e2426 100644 --- a/engines/scumm/he/wiz_he.h +++ b/engines/scumm/he/wiz_he.h @@ -210,9 +210,9 @@ public: static void copyWizImageWithMask(uint8 *dst, const uint8 *src, int dstPitch, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int maskT, int maskP); static void copyWizImage(uint8 *dst, const uint8 *src, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *palPtr, const uint8 *xmapPtr, uint8 bitdepth); static void copyRawWizImage(uint8 *dst, const uint8 *src, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *palPtr, int transColor, uint8 bitdepth); - static void copy16BitWizImage(uint8 *dst, const uint8 *src, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *palPtr, const uint8 *xmapPtr); + static void copy16BitWizImage(uint8 *dst, const uint8 *src, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *xmapPtr); static void copyRaw16BitWizImage(uint8 *dst, const uint8 *src, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, int transColor); - template static void decompress16BitWizImage(uint8 *dst, int dstPitch, int dstType, const uint8 *src, const Common::Rect &srcRect, int flags, const uint8 *palPtr = NULL, const uint8 *xmapPtr = NULL); + template static void decompress16BitWizImage(uint8 *dst, int dstPitch, int dstType, const uint8 *src, const Common::Rect &srcRect, int flags, const uint8 *xmapPtr = NULL); template static void decompressWizImage(uint8 *dst, int dstPitch, int dstType, const uint8 *src, const Common::Rect &srcRect, int flags, const uint8 *palPtr, const uint8 *xmapPtr, uint8 bitdepth); template static void decompressRawWizImage(uint8 *dst, int dstPitch, int dstType, const uint8 *src, int srcPitch, int w, int h, int transColor, const uint8 *palPtr, uint8 bitdepth); -- cgit v1.2.3 From 1f43d9b860b9c1a6d5e62cc261ff5da94b42d50e Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Fri, 5 Jun 2009 04:28:07 +0000 Subject: Correct error in decompress16BitWizImage(). svn-id: r41190 --- engines/scumm/he/wiz_he.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/scumm') diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp index 20ff7fa309..8fe2639fbb 100644 --- a/engines/scumm/he/wiz_he.cpp +++ b/engines/scumm/he/wiz_he.cpp @@ -659,7 +659,7 @@ void Wiz::decompress16BitWizImage(uint8 *dst, int dstPitch, int dstType, const u code = -xoff; } - dstPtr += dstInc; + dstPtr += dstInc * code; w -= code; } else if (code & 2) { code = (code >> 2) + 1; -- cgit v1.2.3 From f8361b5c53b96faddb56024bb932ce46b7005dbf Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Fri, 5 Jun 2009 06:41:04 +0000 Subject: Converted cursor code to use 16-bit. svn-id: r41191 --- engines/scumm/costume.cpp | 2 +- engines/scumm/cursor.cpp | 14 ++++++++++---- engines/scumm/he/wiz_he.cpp | 4 +--- engines/scumm/scumm.h | 5 ++++- 4 files changed, 16 insertions(+), 9 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/costume.cpp b/engines/scumm/costume.cpp index 4358e03a2a..089e7a2fbe 100644 --- a/engines/scumm/costume.cpp +++ b/engines/scumm/costume.cpp @@ -876,7 +876,7 @@ void ClassicCostumeLoader::costumeDecodeData(Actor *a, int frame, uint usemask) void ClassicCostumeRenderer::setPalette(uint16 *palette) { int i; - byte color; + byte color = 0; if (_loaded._format == 0x57) { for (i = 0; i < 13; i++) diff --git a/engines/scumm/cursor.cpp b/engines/scumm/cursor.cpp index 64829114ca..66dd3807db 100644 --- a/engines/scumm/cursor.cpp +++ b/engines/scumm/cursor.cpp @@ -111,7 +111,13 @@ void ScummEngine_v6::setCursorTransparency(int a) { } void ScummEngine::updateCursor() { - const int transColor = (_game.heversion >= 80) ? 5 : 255; + //HACK Put the 16-bit mapped color, and + //hope no other palette entry shares it + int transColor = (_game.heversion >= 80) ? 5 : 255; + if (_game.features & GF_16BIT_COLOR && _hePalettes) + transColor = READ_LE_UINT16(_hePalettes + 2048 + transColor * 2); + else + transColor = 0; CursorMan.replaceCursor(_grabbedCursor, _cursor.width, _cursor.height, _cursor.hotspotX, _cursor.hotspotY, (_game.platform == Common::kPlatformNES ? _grabbedCursor[63] : transColor), @@ -138,7 +144,7 @@ void ScummEngine::setCursorFromBuffer(const byte *ptr, int width, int height, in uint size; byte *dst; - size = width * height; + size = width * height * _bitDepth; if (size > sizeof(_grabbedCursor)) error("grabCursor: grabbed cursor too big"); @@ -148,8 +154,8 @@ void ScummEngine::setCursorFromBuffer(const byte *ptr, int width, int height, in dst = _grabbedCursor; for (; height; height--) { - memcpy(dst, ptr, width); - dst += width; + memcpy(dst, ptr, width * _bitDepth); + dst += width * _bitDepth; ptr += pitch; } diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp index 8fe2639fbb..e91eb48cd4 100644 --- a/engines/scumm/he/wiz_he.cpp +++ b/engines/scumm/he/wiz_he.cpp @@ -1800,14 +1800,12 @@ void Wiz::loadWizCursor(int resId, int palette) { } const Common::Rect *r = NULL; - _vm->_bitDepth = 1; uint8 *cursor = drawWizImage(resId, 0, 0, 0, 0, 0, 0, r, kWIFBlitToMemBuffer, 0, _vm->getHEPaletteSlot(palette)); - _vm->_bitDepth = (_vm->_game.features & GF_16BIT_COLOR) ? 2 : 1; int32 cw, ch; getWizImageDim(resId, 0, cw, ch); _vm->setCursorHotspot(x, y); - _vm->setCursorFromBuffer(cursor, cw, ch, cw); + _vm->setCursorFromBuffer(cursor, cw, ch, cw * _vm->_bitDepth); // Since we set up cursor palette for default cursor, disable it now CursorMan.disableCursorPalette(true); diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h index c4b2ab9e56..5580c4c73d 100644 --- a/engines/scumm/scumm.h +++ b/engines/scumm/scumm.h @@ -974,7 +974,10 @@ protected: byte animate, animateIndex; int8 state; } _cursor; - byte _grabbedCursor[8192]; + + // HACK Double the array size to handle 16-bit images. + // this should be dynamically allocated based on game depth instead. + byte _grabbedCursor[16384]; byte _currentCursor; byte _newEffect, _switchRoomEffect2, _switchRoomEffect; -- cgit v1.2.3 From 7edfab28d82f4c15bf95ad63d0ce480676f85c62 Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Fri, 5 Jun 2009 06:47:49 +0000 Subject: Ooops, correct mistakes in commit 41162. svn-id: r41192 --- engines/scumm/costume.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/costume.cpp b/engines/scumm/costume.cpp index 089e7a2fbe..39c2f73e88 100644 --- a/engines/scumm/costume.cpp +++ b/engines/scumm/costume.cpp @@ -876,15 +876,15 @@ void ClassicCostumeLoader::costumeDecodeData(Actor *a, int frame, uint usemask) void ClassicCostumeRenderer::setPalette(uint16 *palette) { int i; - byte color = 0; + byte color; if (_loaded._format == 0x57) { for (i = 0; i < 13; i++) - _palette[i] = color; + _palette[i] = palette[i]; } else if (_vm->_game.features & GF_OLD_BUNDLE) { if (_vm->getCurrentLights() & LIGHTMODE_actor_use_colors) { for (i = 0; i < 16; i++) - _palette[i] = color; + _palette[i] = palette[i]; } else { for (i = 0; i < 16; i++) _palette[i] = 8; -- cgit v1.2.3 From 662a305752214564a9db0ac2d61594367067efa1 Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Fri, 5 Jun 2009 07:07:56 +0000 Subject: HACK not required at this point, since transparency color of 5 is still used for 16bit color HE games. svn-id: r41193 --- engines/scumm/cursor.cpp | 6 ------ 1 file changed, 6 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/cursor.cpp b/engines/scumm/cursor.cpp index 66dd3807db..957370b8fe 100644 --- a/engines/scumm/cursor.cpp +++ b/engines/scumm/cursor.cpp @@ -111,13 +111,7 @@ void ScummEngine_v6::setCursorTransparency(int a) { } void ScummEngine::updateCursor() { - //HACK Put the 16-bit mapped color, and - //hope no other palette entry shares it int transColor = (_game.heversion >= 80) ? 5 : 255; - if (_game.features & GF_16BIT_COLOR && _hePalettes) - transColor = READ_LE_UINT16(_hePalettes + 2048 + transColor * 2); - else - transColor = 0; CursorMan.replaceCursor(_grabbedCursor, _cursor.width, _cursor.height, _cursor.hotspotX, _cursor.hotspotY, (_game.platform == Common::kPlatformNES ? _grabbedCursor[63] : transColor), -- cgit v1.2.3 From 9789ba7f28d2c0a093adda01435306f28e91fede Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Fri, 5 Jun 2009 08:09:37 +0000 Subject: Corrected backend to be able to accept a 16-bit mouseKeyColor without overflow svn-id: r41194 --- engines/scumm/cursor.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/cursor.cpp b/engines/scumm/cursor.cpp index 957370b8fe..3710956b74 100644 --- a/engines/scumm/cursor.cpp +++ b/engines/scumm/cursor.cpp @@ -112,10 +112,20 @@ void ScummEngine_v6::setCursorTransparency(int a) { void ScummEngine::updateCursor() { int transColor = (_game.heversion >= 80) ? 5 : 255; - CursorMan.replaceCursor(_grabbedCursor, _cursor.width, _cursor.height, - _cursor.hotspotX, _cursor.hotspotY, - (_game.platform == Common::kPlatformNES ? _grabbedCursor[63] : transColor), - (_game.heversion == 70 ? 2 : 1)); + if (_game.features & GF_16BIT_COLOR && _hePalettes) { + //HACK Had to make a second method to avoid many, many linker errors from other engines + //this requires ENABLE_16BIT to be defined in the Scumm project, again, because I #ifdef'ed + //the method's definition and declaration in cursorman.h + CursorMan.replaceCursor16(_grabbedCursor, _cursor.width, _cursor.height, + _cursor.hotspotX, _cursor.hotspotY, + (_game.platform == Common::kPlatformNES ? _grabbedCursor[63] : transColor), + (_game.heversion == 70 ? 2 : 1)); + } else { + CursorMan.replaceCursor(_grabbedCursor, _cursor.width, _cursor.height, + _cursor.hotspotX, _cursor.hotspotY, + (_game.platform == Common::kPlatformNES ? _grabbedCursor[63] : transColor), + (_game.heversion == 70 ? 2 : 1)); + } } void ScummEngine_v6::grabCursor(int x, int y, int w, int h) { -- cgit v1.2.3 From ccee18a489ece14c499c4e0c43aeb7fc216451fb Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Fri, 5 Jun 2009 10:13:19 +0000 Subject: Cleanup. svn-id: r41195 --- engines/scumm/gfx.cpp | 59 +++++++++++++++++++------------------------------ engines/scumm/gfx.h | 8 +++++++ engines/scumm/scumm.cpp | 4 +++- 3 files changed, 34 insertions(+), 37 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/gfx.cpp b/engines/scumm/gfx.cpp index 0427e32326..d47301c974 100644 --- a/engines/scumm/gfx.cpp +++ b/engines/scumm/gfx.cpp @@ -231,6 +231,9 @@ GdiV2::~GdiV2() { free(_roomStrips); } +Gdi16Bit::Gdi16Bit(ScummEngine *vm) : Gdi(vm) { +} + void Gdi::init() { _numStrips = _vm->_screenWidth / 8; @@ -2803,12 +2806,8 @@ void Gdi::drawStripHE(byte *dst, int dstPitch, const byte *src, int width, int h int x = width; while (1) { - if (!transpCheck || color != _transparentColor) { - if (_vm->_game.features & GF_16BIT_COLOR) - WRITE_UINT16(dst, READ_LE_UINT16(_vm->_hePalettes + 2048 + color * 2)); - else - *dst = _roomPalette[color]; - } + if (!transpCheck || color != _transparentColor) + writeRoomColor(dst, color); dst += _vm->_bitDepth; --x; if (x == 0) { @@ -2896,12 +2895,8 @@ void Gdi::drawStripComplex(byte *dst, int dstPitch, const byte *src, int height, int x = 8; do { FILL_BITS; - if (!transpCheck || color != _transparentColor) { - if (_vm->_game.features & GF_16BIT_COLOR) - WRITE_UINT16(dst, READ_LE_UINT16(_vm->_hePalettes + 2048 + color * 2)); - else - *dst = _roomPalette[color] + _paletteMod; - } + if (!transpCheck || color != _transparentColor) + writeRoomColor(dst, color); dst += _vm->_bitDepth; againPos: @@ -2927,12 +2922,8 @@ void Gdi::drawStripComplex(byte *dst, int dstPitch, const byte *src, int height, if (!--height) return; } - if (!transpCheck || color != _transparentColor) { - if (_vm->_game.features & GF_16BIT_COLOR) - WRITE_UINT16(dst, READ_LE_UINT16(_vm->_hePalettes + 2048 + color * 2)); - else - *dst = _roomPalette[color] + _paletteMod; - } + if (!transpCheck || color != _transparentColor) + writeRoomColor(dst, color); dst += _vm->_bitDepth; } while (--reps); bits >>= 8; @@ -2956,12 +2947,8 @@ void Gdi::drawStripBasicH(byte *dst, int dstPitch, const byte *src, int height, int x = 8; do { FILL_BITS; - if (!transpCheck || color != _transparentColor) { - if (_vm->_game.features & GF_16BIT_COLOR) - WRITE_UINT16(dst, READ_LE_UINT16(_vm->_hePalettes + 2048 + color * 2)); - else - *dst = _roomPalette[color] + _paletteMod; - } + if (!transpCheck || color != _transparentColor) + writeRoomColor(dst, color); dst += _vm->_bitDepth; if (!READ_BIT) { } else if (!READ_BIT) { @@ -2993,12 +2980,8 @@ void Gdi::drawStripBasicV(byte *dst, int dstPitch, const byte *src, int height, int h = height; do { FILL_BITS; - if (!transpCheck || color != _transparentColor) { - if (_vm->_game.features & GF_16BIT_COLOR) - WRITE_UINT16(dst, READ_LE_UINT16(_vm->_hePalettes + 2048 + color * 2)); - else - *dst = _roomPalette[color] + _paletteMod; - } + if (!transpCheck || color != _transparentColor) + writeRoomColor(dst, color); dst += dstPitch; if (!READ_BIT) { } else if (!READ_BIT) { @@ -3065,12 +3048,8 @@ void Gdi::drawStripRaw(byte *dst, int dstPitch, const byte *src, int height, con do { for (x = 0; x < 8; x ++) { byte color = *src++; - if (!transpCheck || color != _transparentColor) { - if (_vm->_game.features & GF_16BIT_COLOR) - WRITE_UINT16(dst + x * 2, READ_LE_UINT16(_vm->_hePalettes + 2048 + color * 2)); - else - dst[x] = _roomPalette[color] + _paletteMod; - } + if (!transpCheck || color != _transparentColor) + writeRoomColor(dst + x * _vm->_bitDepth, color); } dst += dstPitch; } while (--height); @@ -3193,6 +3172,14 @@ void Gdi::unkDecode11(byte *dst, int dstPitch, const byte *src, int height) cons #undef NEXT_ROW #undef READ_BIT_256 +void Gdi16Bit::writeRoomColor(byte *dst, byte color) const { + WRITE_UINT16(dst, READ_LE_UINT16(_vm->_hePalettes + 2048 + color * 2)); +} + +void Gdi::writeRoomColor(byte *dst, byte color) const { + *dst = _roomPalette[color] + _paletteMod; +} + #pragma mark - #pragma mark --- Transition effects --- diff --git a/engines/scumm/gfx.h b/engines/scumm/gfx.h index 88852c8388..c0f2c2c083 100644 --- a/engines/scumm/gfx.h +++ b/engines/scumm/gfx.h @@ -215,6 +215,7 @@ protected: void drawStrip3DO(byte *dst, int dstPitch, const byte *src, int height, const bool transpCheck) const; void drawStripHE(byte *dst, int dstPitch, const byte *src, int width, int height, const bool transpCheck) const; + virtual void writeRoomColor(byte *dst, byte color) const; /* Mask decompressors */ void decompressTMSK(byte *dst, const byte *tmsk, const byte *src, int height) const; @@ -361,6 +362,13 @@ public: virtual void roomChanged(byte *roomptr); }; +class Gdi16Bit : public Gdi { +protected: + virtual void writeRoomColor(byte *dst, byte color) const; +public: + Gdi16Bit(ScummEngine *vm); +}; + } // End of namespace Scumm #endif diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index 17ffc6e5b0..022eba1e5b 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -109,7 +109,9 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr) _currentScript(0xFF), // Let debug() work on init stage _messageDialog(0), _pauseDialog(0), _scummMenuDialog(0), _versionDialog(0) { - if (_game.platform == Common::kPlatformNES) { + if (_game.features & GF_16BIT_COLOR) { + _gdi = new Gdi16Bit(this); + } else if (_game.platform == Common::kPlatformNES) { _gdi = new GdiNES(this); } else if (_game.version <= 1) { _gdi = new GdiV1(this); -- cgit v1.2.3 From d65bbe1d7a5efbcf04831dbb68a45ca833db1ae1 Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Fri, 5 Jun 2009 23:59:40 +0000 Subject: Fixes ScummEngine_v70he::setDefaultCursor to work in 16-bit, using a temporary hack. svn-id: r41204 --- engines/scumm/cursor.cpp | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/cursor.cpp b/engines/scumm/cursor.cpp index 3710956b74..5ec9e63e32 100644 --- a/engines/scumm/cursor.cpp +++ b/engines/scumm/cursor.cpp @@ -112,7 +112,7 @@ void ScummEngine_v6::setCursorTransparency(int a) { void ScummEngine::updateCursor() { int transColor = (_game.heversion >= 80) ? 5 : 255; - if (_game.features & GF_16BIT_COLOR && _hePalettes) { + if (_game.features & GF_16BIT_COLOR) { //HACK Had to make a second method to avoid many, many linker errors from other engines //this requires ENABLE_16BIT to be defined in the Scumm project, again, because I #ifdef'ed //the method's definition and declaration in cursorman.h @@ -176,8 +176,13 @@ void ScummEngine_v70he::setDefaultCursor() { static const byte palette[] = {0, 0, 0, 0, 0xff, 0xff, 0xff, 0, 0, 0, 0, 0}; - - memset(_grabbedCursor, 5, sizeof(_grabbedCursor)); + + if (_bitDepth == 2) { + for (i = 0; i < 1024; i++) + WRITE_UINT16(_grabbedCursor + i * 2, 5); + } else { + memset(_grabbedCursor, 5, sizeof(_grabbedCursor)); + } _cursor.hotspotX = _cursor.hotspotY = 2; src = default_he_cursor; @@ -190,10 +195,16 @@ void ScummEngine_v70he::setDefaultCursor() { for (j = 0; j < 32; j++) { switch ((p & (0x3 << 14)) >> 14) { case 1: - _grabbedCursor[32 * i + j] = 0xfe; + if (_bitDepth == 2) + WRITE_UINT16(_grabbedCursor + 64 * i + j * 2, get16BitColor(palette[4], palette[5], palette[6])); + else + _grabbedCursor[32 * i + j] = 0xfe; break; case 2: - _grabbedCursor[32 * i + j] = 0xfd; + if (_bitDepth == 2) + WRITE_UINT16(_grabbedCursor + 64 * i + j * 2, get16BitColor(palette[0], palette[1], palette[2])); + else + _grabbedCursor[32 * i + j] = 0xfd; break; default: break; @@ -205,9 +216,11 @@ void ScummEngine_v70he::setDefaultCursor() { } } - // Since white color position is not guaranteed - // we setup our own palette if supported by backend - CursorMan.replaceCursorPalette(palette, 0xfd, 3); + if (_bitDepth == 1) { + // Since white color position is not guaranteed + // we setup our own palette if supported by backend + CursorMan.replaceCursorPalette(palette, 0xfd, 3); + } updateCursor(); } -- cgit v1.2.3 From 56e5920bba753820c457c078237a8c06241302ed Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Sat, 6 Jun 2009 01:16:04 +0000 Subject: Corrected cursor display errors introduced by revision 41204, reimplemented 16-bit cursor support in a less hacky, but still temporary way. svn-id: r41209 --- engines/scumm/cursor.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/cursor.cpp b/engines/scumm/cursor.cpp index 5ec9e63e32..bc4a2e0d33 100644 --- a/engines/scumm/cursor.cpp +++ b/engines/scumm/cursor.cpp @@ -116,10 +116,11 @@ void ScummEngine::updateCursor() { //HACK Had to make a second method to avoid many, many linker errors from other engines //this requires ENABLE_16BIT to be defined in the Scumm project, again, because I #ifdef'ed //the method's definition and declaration in cursorman.h - CursorMan.replaceCursor16(_grabbedCursor, _cursor.width, _cursor.height, + CursorMan.replaceCursorReal(_grabbedCursor, _cursor.width, _cursor.height, _cursor.hotspotX, _cursor.hotspotY, (_game.platform == Common::kPlatformNES ? _grabbedCursor[63] : transColor), - (_game.heversion == 70 ? 2 : 1)); + (_game.heversion == 70 ? 2 : 1), + 16); } else { CursorMan.replaceCursor(_grabbedCursor, _cursor.width, _cursor.height, _cursor.hotspotX, _cursor.hotspotY, -- cgit v1.2.3 From f379d7fe1a2b261dbdfbd4c152fb2ff8d7f18277 Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Sat, 6 Jun 2009 07:22:19 +0000 Subject: Add initial support for copyMaskWizImage, to fix videos in later Blue's Clues games. svn-id: r41211 --- engines/scumm/he/animation_he.cpp | 7 +- engines/scumm/he/wiz_he.cpp | 130 ++++++++++++++++++++++++++++++++++---- engines/scumm/he/wiz_he.h | 4 +- 3 files changed, 124 insertions(+), 17 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/he/animation_he.cpp b/engines/scumm/he/animation_he.cpp index 5983df2308..92b72bd9be 100644 --- a/engines/scumm/he/animation_he.cpp +++ b/engines/scumm/he/animation_he.cpp @@ -75,9 +75,10 @@ void MoviePlayer::copyFrameToBuffer(byte *dst, uint x, uint y, uint pitch) { if (_vm->_game.features & GF_16BIT_COLOR) { dst += y * pitch + x * 2; do { - for (uint i = 0; i < w; i++) - WRITE_UINT16(dst + i * 2, src[i]); - + for (uint i = 0; i < w; i++) { + uint16 col = READ_LE_UINT16(_vm->_hePalettes + _vm->_hePaletteSlot + 768 + src[i] * 2); + WRITE_UINT16(dst + i * 2, col); + } dst += pitch; src += w; } while (--h); diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp index 8bc196ee08..9aa2bf741a 100644 --- a/engines/scumm/he/wiz_he.cpp +++ b/engines/scumm/he/wiz_he.cpp @@ -445,6 +445,93 @@ static void decodeWizMask(uint8 *&dst, uint8 &mask, int w, int maskType) { } } +void Wiz::copyMaskWizImage(uint8 *dst, const uint8 *src, const uint8 *mask, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *palPtr) { + Common::Rect srcRect, dstRect; + if (!calcClipRects(dstw, dsth, srcx, srcy, srcw, srch, rect, srcRect, dstRect)) { + return; + } + dst += dstRect.top * dstPitch + dstRect.left * 2; + if (flags & kWIFFlipY) { + const int dy = (srcy < 0) ? srcy : (srch - srcRect.height()); + srcRect.translate(0, dy); + } + if (flags & kWIFFlipX) { + const int dx = (srcx < 0) ? srcx : (srcw - srcRect.width()); + srcRect.translate(dx, 0); + } + + const uint8 *dataPtr, *dataPtrNext; + const uint8 *maskPtr, *maskPtrNext; + uint8 code, *dstPtr, *dstPtrNext; + int h, w, dstInc; + + dataPtr = src; + dstPtr = dst; + maskPtr = mask; + + // Skip over the first 'srcRect->top' lines in the data + dataPtr += dstRect.top * dstPitch + dstRect.left * 2; + + h = dstRect.height(); + w = dstRect.width(); + if (h <= 0 || w <= 0) + return; + + dstInc = 2; + if (flags & kWIFFlipX) { + dstPtr += (w - 1) * 2; + dstInc = -2; + } + + while (h--) { + w = dstRect.width(); + uint16 lineSize = READ_LE_UINT16(maskPtr); maskPtr += 2; + dataPtrNext = dataPtr + dstPitch; + dstPtrNext = dstPtr + dstPitch; + maskPtrNext = maskPtr + lineSize; + if (lineSize != 0) { + while (w > 0) { + code = *maskPtr++; + if (code & 1) { + code >>= 1; + dataPtr += dstInc * code; + dstPtr += dstInc * code; + w -= code; + } else if (code & 2) { + code = (code >> 2) + 1; + w -= code; + if (w < 0) { + code += w; + } + while (code--) { + if (*maskPtr != 5) + write16BitColor(dstPtr, dataPtr, dstType, palPtr); + dataPtr += 2; + dstPtr += dstInc; + } + maskPtr++; + } else { + code = (code >> 2) + 1; + w -= code; + if (w < 0) { + code += w; + } + while (code--) { + if (*maskPtr != 5) + write16BitColor(dstPtr, dataPtr, dstType, palPtr); + dataPtr += 2; + dstPtr += dstInc; + maskPtr++; + } + } + } + } + dataPtr = dataPtrNext; + dstPtr = dstPtrNext; + maskPtr = maskPtrNext; + } +} + void Wiz::copyWizImageWithMask(uint8 *dst, const uint8 *src, int dstPitch, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int maskT, int maskP) { Common::Rect srcRect, dstRect; if (!calcClipRects(dstw, dsth, srcx, srcy, srcw, srch, rect, srcRect, dstRect)) { @@ -1318,12 +1405,12 @@ void Wiz::displayWizImage(WizImage *pwi) { drawWizPolygon(pwi->resNum, pwi->state, pwi->x1, pwi->flags, 0, 0, 0); } else { const Common::Rect *r = NULL; - drawWizImage(pwi->resNum, pwi->state, pwi->x1, pwi->y1, 0, 0, 0, r, pwi->flags, 0, _vm->getHEPaletteSlot(0)); + drawWizImage(pwi->resNum, pwi->state, 0, 0, pwi->x1, pwi->y1, 0, 0, 0, r, pwi->flags, 0, _vm->getHEPaletteSlot(0)); } } -uint8 *Wiz::drawWizImage(int resNum, int state, int x1, int y1, int zorder, int shadow, int field_390, const Common::Rect *clipBox, int flags, int dstResNum, const uint8 *palPtr) { - debug(3, "drawWizImage(resNum %d, x1 %d y1 %d flags 0x%X zorder %d shadow %d field_390 %d dstResNum %d)", resNum, x1, y1, flags, zorder, shadow, field_390, dstResNum); +uint8 *Wiz::drawWizImage(int resNum, int state, int maskNum, int maskState, int x1, int y1, int zorder, int shadow, int field_390, const Common::Rect *clipBox, int flags, int dstResNum, const uint8 *palPtr) { + debug(3, "drawWizImage(resNum %d, state %d maskNum %d maskState %d x1 %d y1 %d flags 0x%X zorder %d shadow %d field_390 %d dstResNum %d)", resNum, state, maskNum, maskState, x1, y1, flags, zorder, shadow, field_390, dstResNum); uint8 *dataPtr; uint8 *dst = NULL; @@ -1348,6 +1435,21 @@ uint8 *Wiz::drawWizImage(int resNum, int state, int x1, int y1, int zorder, int uint8 *wizd = _vm->findWrappedBlock(MKID_BE('WIZD'), dataPtr, state, 0); assert(wizd); + uint8 *mask = NULL; + if (maskNum) { + uint8 *maskPtr = _vm->getResourceAddress(rtImage, maskNum); + assert(maskPtr); + + wizh = _vm->findWrappedBlock(MKID_BE('WIZH'), maskPtr, maskState, 0); + assert(wizh); + assert(comp == 2 && READ_LE_UINT32(wizh + 0x0) == 1); + width = READ_LE_UINT32(wizh + 0x4); + height = READ_LE_UINT32(wizh + 0x8); + + mask = _vm->findWrappedBlock(MKID_BE('WIZD'), maskPtr, maskState, 0); + assert(mask); + } + if (flags & kWIFHasPalette) { uint8 *pal = _vm->findWrappedBlock(MKID_BE('RGBS'), dataPtr, state, 0); assert(pal); @@ -1455,7 +1557,11 @@ uint8 *Wiz::drawWizImage(int resNum, int state, int x1, int y1, int zorder, int } break; case 2: - copyRaw16BitWizImage(dst, wizd, dstPitch, dstType, cw, ch, x1, y1, width, height, &rScreen, flags, transColor); + if (maskNum) { + copyMaskWizImage(dst, wizd, mask, dstPitch, dstType, cw, ch, x1, y1, width, height, &rScreen, flags, palPtr); + } else { + copyRaw16BitWizImage(dst, wizd, dstPitch, dstType, cw, ch, x1, y1, width, height, &rScreen, flags, transColor); + } break; case 4: // TODO: Unknown image type @@ -1605,7 +1711,7 @@ void Wiz::drawWizPolygonTransform(int resNum, int state, Common::Point *wp, int debug(0, "drawWizPolygonTransform() unhandled flag 0x800000"); } - srcWizBuf = drawWizImage(resNum, state, 0, 0, 0, shadow, 0, r, flags, 0, _vm->getHEPaletteSlot(palette)); + srcWizBuf = drawWizImage(resNum, state, 0, 0, 0, 0, 0, shadow, 0, r, flags, 0, _vm->getHEPaletteSlot(palette)); } else { assert(_vm->_bitDepth == 1); uint8 *dataPtr = _vm->getResourceAddress(rtImage, resNum); @@ -1616,7 +1722,7 @@ void Wiz::drawWizPolygonTransform(int resNum, int state, Common::Point *wp, int } } else { if (getWizImageData(resNum, state, 0) != 0) { - srcWizBuf = drawWizImage(resNum, state, 0, 0, 0, shadow, 0, r, kWIFBlitToMemBuffer, 0, _vm->getHEPaletteSlot(palette)); + srcWizBuf = drawWizImage(resNum, state, 0, 0, 0, 0, 0, shadow, 0, r, kWIFBlitToMemBuffer, 0, _vm->getHEPaletteSlot(palette)); } else { uint8 *dataPtr = _vm->getResourceAddress(rtImage, resNum); assert(dataPtr); @@ -1779,7 +1885,7 @@ void Wiz::flushWizBuffer() { drawWizPolygon(pwi->resNum, pwi->state, pwi->x1, pwi->flags, pwi->shadow, 0, pwi->palette); } else { const Common::Rect *r = NULL; - drawWizImage(pwi->resNum, pwi->state, pwi->x1, pwi->y1, pwi->zorder, pwi->shadow, pwi->field_390, r, pwi->flags, 0, _vm->getHEPaletteSlot(pwi->palette)); + drawWizImage(pwi->resNum, pwi->state, 0, 0, pwi->x1, pwi->y1, pwi->zorder, pwi->shadow, pwi->field_390, r, pwi->flags, 0, _vm->getHEPaletteSlot(pwi->palette)); } } _imagesNum = 0; @@ -1800,7 +1906,7 @@ void Wiz::loadWizCursor(int resId, int palette) { } const Common::Rect *r = NULL; - uint8 *cursor = drawWizImage(resId, 0, 0, 0, 0, 0, 0, r, kWIFBlitToMemBuffer, 0, _vm->getHEPaletteSlot(palette)); + uint8 *cursor = drawWizImage(resId, 0, 0, 0, 0, 0, 0, 0, 0, r, kWIFBlitToMemBuffer, 0, _vm->getHEPaletteSlot(palette)); int32 cw, ch; getWizImageDim(resId, 0, cw, ch); @@ -1817,8 +1923,7 @@ void Wiz::displayWizComplexImage(const WizParameters *params) { int sourceImage = 0; if (params->processFlags & kWPFMaskImg) { sourceImage = params->sourceImage; - debug(3, "displayWizComplexImage() unhandled flag kWPFMaskImg"); - return; + debug(0, "displayWizComplexImage() flag kWPFMaskImg"); } int palette = 0; if (params->processFlags & kWPFPaletteNum) { @@ -1886,15 +1991,14 @@ void Wiz::displayWizComplexImage(const WizParameters *params) { ++_imagesNum; } else { if (sourceImage != 0) { - // TODO: Add support for kWPFMaskImg - drawWizImage(params->sourceImage, state, po_x, po_y, params->img.zorder, shadow, field_390, r, flags, dstResNum, _vm->getHEPaletteSlot(palette)); + drawWizImage(params->sourceImage, 0, params->img.resNum, state, po_x, po_y, params->img.zorder, shadow, field_390, r, flags, dstResNum, _vm->getHEPaletteSlot(palette)); } else if (params->processFlags & (kWPFScaled | kWPFRotate)) { drawWizComplexPolygon(params->img.resNum, state, po_x, po_y, shadow, rotationAngle, scale, r, flags, dstResNum, palette); } else { if (flags & kWIFIsPolygon) { drawWizPolygon(params->img.resNum, state, po_x, flags, shadow, dstResNum, palette); } else { - drawWizImage(params->img.resNum, state, po_x, po_y, params->img.zorder, shadow, field_390, r, flags, dstResNum, _vm->getHEPaletteSlot(palette)); + drawWizImage(params->img.resNum, state, 0, 0, po_x, po_y, params->img.zorder, shadow, field_390, r, flags, dstResNum, _vm->getHEPaletteSlot(palette)); } } } diff --git a/engines/scumm/he/wiz_he.h b/engines/scumm/he/wiz_he.h index 4a5dd74e38..5c5daa5974 100644 --- a/engines/scumm/he/wiz_he.h +++ b/engines/scumm/he/wiz_he.h @@ -201,11 +201,13 @@ public: void displayWizImage(WizImage *pwi); void processWizImage(const WizParameters *params); - uint8 *drawWizImage(int resNum, int state, int x1, int y1, int zorder, int shadow, int field_390, const Common::Rect *clipBox, int flags, int dstResNum, const uint8 *palPtr); + uint8 *drawWizImage(int resNum, int state, int maskNum, int maskState, int x1, int y1, int zorder, int shadow, int field_390, const Common::Rect *clipBox, int flags, int dstResNum, const uint8 *palPtr); void drawWizPolygon(int resNum, int state, int id, int flags, int shadow, int dstResNum, int palette); void drawWizComplexPolygon(int resNum, int state, int po_x, int po_y, int shadow, int angle, int zoom, const Common::Rect *r, int flags, int dstResNum, int palette); void drawWizPolygonTransform(int resNum, int state, Common::Point *wp, int flags, int shadow, int dstResNum, int palette); + static void copyMaskWizImage(uint8 *dst, const uint8 *src, const uint8 *mask, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *palPtr); + static void copyAuxImage(uint8 *dst1, uint8 *dst2, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, uint8 bitdepth); static void copyWizImageWithMask(uint8 *dst, const uint8 *src, int dstPitch, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int maskT, int maskP); static void copyWizImage(uint8 *dst, const uint8 *src, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *palPtr, const uint8 *xmapPtr, uint8 bitdepth); -- cgit v1.2.3 From 58a348fd18727aab57c0f4f8ab4cc5ad893ee795 Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Wed, 10 Jun 2009 05:35:54 +0000 Subject: Scumm engine now dynamically requests 16-bit color based on game features, (using ad-hoc request format) svn-id: r41417 --- engines/scumm/scumm.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'engines/scumm') diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index 0599139778..3d0a2d0bc2 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -1083,6 +1083,12 @@ Common::Error ScummEngine::init() { // CJK FT and DIG use usual NUT fonts, not FM-TOWNS ROM, so // there is no text surface for them. This takes that into account (_screenWidth * _textSurfaceMultiplier > 320)); + } else if (_game.features & GF_16BIT_COLOR) { + int format = Graphics::kFormatRGB555 | Graphics::kFormatRGB; + Common::List formatList; + formatList.push_back((Graphics::ColorFormat) format); + formatList.push_back(Graphics::kFormat8Bit); + initGraphics(_screenWidth, _screenHeight, _screenWidth > 320, formatList); } else { initGraphics(_screenWidth, _screenHeight, _screenWidth > 320); } -- cgit v1.2.3 From 8a8366aab5ee33857a0574aac6675f27912388c3 Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Wed, 10 Jun 2009 06:05:11 +0000 Subject: Correct horizontal flipping in decompressWizImage(), when using 16bit color. svn-id: r41418 --- engines/scumm/he/wiz_he.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/scumm') diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp index 9aa2bf741a..4661bb649c 100644 --- a/engines/scumm/he/wiz_he.cpp +++ b/engines/scumm/he/wiz_he.cpp @@ -858,7 +858,7 @@ void Wiz::decompressWizImage(uint8 *dst, int dstPitch, int dstType, const uint8 dstInc = bitDepth; if (flags & kWIFFlipX) { dstPtr += (w - 1) * bitDepth; - dstInc = -1; + dstInc = -bitDepth; } while (h--) { -- cgit v1.2.3 From 6adbd0c41e79b5a21f0430e060347d4978e9ce78 Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Thu, 11 Jun 2009 05:56:00 +0000 Subject: Renamed Graphics::ColorFormat to Graphics::ColorMode, streamlined enum by removing order section and temporarily removing kFormatARGB1555 Converted cursor code to make use of _screenFormat, instead of a parameter passed directly to it by the engine. Adjusted scumm engine to account for these changes. This should probably have been two separate commits, but the changes concern the same files... svn-id: r41443 --- engines/scumm/cursor.cpp | 19 ++++--------------- engines/scumm/scumm.cpp | 10 ++++++---- 2 files changed, 10 insertions(+), 19 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/cursor.cpp b/engines/scumm/cursor.cpp index bc4a2e0d33..fcde07cbdf 100644 --- a/engines/scumm/cursor.cpp +++ b/engines/scumm/cursor.cpp @@ -112,21 +112,10 @@ void ScummEngine_v6::setCursorTransparency(int a) { void ScummEngine::updateCursor() { int transColor = (_game.heversion >= 80) ? 5 : 255; - if (_game.features & GF_16BIT_COLOR) { - //HACK Had to make a second method to avoid many, many linker errors from other engines - //this requires ENABLE_16BIT to be defined in the Scumm project, again, because I #ifdef'ed - //the method's definition and declaration in cursorman.h - CursorMan.replaceCursorReal(_grabbedCursor, _cursor.width, _cursor.height, - _cursor.hotspotX, _cursor.hotspotY, - (_game.platform == Common::kPlatformNES ? _grabbedCursor[63] : transColor), - (_game.heversion == 70 ? 2 : 1), - 16); - } else { - CursorMan.replaceCursor(_grabbedCursor, _cursor.width, _cursor.height, - _cursor.hotspotX, _cursor.hotspotY, - (_game.platform == Common::kPlatformNES ? _grabbedCursor[63] : transColor), - (_game.heversion == 70 ? 2 : 1)); - } + CursorMan.replaceCursor(_grabbedCursor, _cursor.width, _cursor.height, + _cursor.hotspotX, _cursor.hotspotY, + (_game.platform == Common::kPlatformNES ? _grabbedCursor[63] : transColor), + (_game.heversion == 70 ? 2 : 1)); } void ScummEngine_v6::grabCursor(int x, int y, int w, int h) { diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index 3d0a2d0bc2..0ebf832a37 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -1083,12 +1083,14 @@ Common::Error ScummEngine::init() { // CJK FT and DIG use usual NUT fonts, not FM-TOWNS ROM, so // there is no text surface for them. This takes that into account (_screenWidth * _textSurfaceMultiplier > 320)); +#ifdef ENABLE_16BIT } else if (_game.features & GF_16BIT_COLOR) { - int format = Graphics::kFormatRGB555 | Graphics::kFormatRGB; - Common::List formatList; - formatList.push_back((Graphics::ColorFormat) format); - formatList.push_back(Graphics::kFormat8Bit); + int format = Graphics::kFormatRGB555; + Common::List formatList; + formatList.push_back((Graphics::ColorMode) format); + formatList.push_back(Graphics::kFormatCLUT8); initGraphics(_screenWidth, _screenHeight, _screenWidth > 320, formatList); +#endif } else { initGraphics(_screenWidth, _screenHeight, _screenWidth > 320); } -- cgit v1.2.3 From 350dc4290fd5dd8f28af9e63713b48ef2c131f09 Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Sat, 13 Jun 2009 10:24:52 +0000 Subject: Fixed cursor code to keep track of cursor formats so that ThemeEngine and/or GuiManager cursors will render properly over the game (on spacebar hit, for instance) svn-id: r41491 --- engines/scumm/cursor.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'engines/scumm') diff --git a/engines/scumm/cursor.cpp b/engines/scumm/cursor.cpp index fcde07cbdf..30483a638c 100644 --- a/engines/scumm/cursor.cpp +++ b/engines/scumm/cursor.cpp @@ -112,6 +112,9 @@ void ScummEngine_v6::setCursorTransparency(int a) { void ScummEngine::updateCursor() { int transColor = (_game.heversion >= 80) ? 5 : 255; +#ifdef ENABLE_16BIT + CursorMan.replaceCursorFormat(_system->getScreenFormat()); +#endif CursorMan.replaceCursor(_grabbedCursor, _cursor.width, _cursor.height, _cursor.hotspotX, _cursor.hotspotY, (_game.platform == Common::kPlatformNES ? _grabbedCursor[63] : transColor), -- cgit v1.2.3 From e6f874ee9508a6631635504808680e50a4f55c7f Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Sat, 13 Jun 2009 13:59:41 +0000 Subject: Fix possible endian issues. svn-id: r41494 --- engines/scumm/he/wiz_he.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp index 4661bb649c..deaf7aaf72 100644 --- a/engines/scumm/he/wiz_he.cpp +++ b/engines/scumm/he/wiz_he.cpp @@ -1152,7 +1152,10 @@ static int wizPackType2(uint8 *dst, const uint8 *src, int srcPitch, const Common if (dst) { src += rCapt.top * srcPitch + rCapt.left * 2; while (h--) { - memcpy(dst, src, w * 2); + for (int i = 0; i < w; i++) { + uint16 col = READ_UINT16(src + w * 2); + WRITE_LE_UINT16(dst + w * 2, col); + } dst += w * 2; src += srcPitch; } @@ -1734,7 +1737,7 @@ void Wiz::drawWizPolygonTransform(int resNum, int state, Common::Point *wp, int if (srcWizBuf) { uint8 *dst; - int32 dstw, dsth, dstpitch, wizW, wizH; + int32 dstw, dsth, dstpitch, dstType, wizW, wizH; VirtScreen *pvs = &_vm->_virtscr[kMainVirtScreen]; int transColor = (_vm->VAR_WIZ_TCOLOR != 0xFF) ? _vm->VAR(_vm->VAR_WIZ_TCOLOR) : 5; @@ -1745,6 +1748,7 @@ void Wiz::drawWizPolygonTransform(int resNum, int state, Common::Point *wp, int assert(dst); getWizImageDim(dstResNum, 0, dstw, dsth); dstpitch = dstw * _vm->_bitDepth; + dstType = kDstResource; } else { if (flags & kWIFMarkBufferDirty) { dst = pvs->getPixels(0, 0); @@ -1754,6 +1758,7 @@ void Wiz::drawWizPolygonTransform(int resNum, int state, Common::Point *wp, int dstw = pvs->w; dsth = pvs->h; dstpitch = pvs->pitch; + dstType = kDstScreen; } getWizImageDim(resNum, state, wizW, wizH); @@ -1857,7 +1862,7 @@ void Wiz::drawWizPolygonTransform(int resNum, int state, Common::Point *wp, int y_acc += pra->y_step; if (_vm->_bitDepth == 2) { if (transColor == -1 || transColor != READ_LE_UINT16(srcWizBuf + src_offs * 2)) - WRITE_LE_UINT16(dstPtr, READ_LE_UINT16(srcWizBuf + src_offs * 2)); + writeColor(dstPtr, dstType, READ_LE_UINT16(srcWizBuf + src_offs * 2)); } else { if (transColor == -1 || transColor != srcWizBuf[src_offs]) *dstPtr = srcWizBuf[src_offs]; -- cgit v1.2.3 From 8d306ebccfa7e88b2e4f4635bff3987e550f98d3 Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Mon, 15 Jun 2009 09:45:19 +0000 Subject: Added kUnsupportedColorMode error code brought Scumm engine and SDL backend into compliance with API outlined in http://scummvmupthorn09.wordpress.com/2009/06/14/how-this-is-going-to-work/ Provided convenient Graphics::PixelFormat constructors for ColorMode enums, and bitformat integers. Removed last vestiges (I think) of initial cursor hack. svn-id: r41539 --- engines/scumm/scumm.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index 0ebf832a37..5fec6ec835 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -1085,11 +1085,10 @@ Common::Error ScummEngine::init() { (_screenWidth * _textSurfaceMultiplier > 320)); #ifdef ENABLE_16BIT } else if (_game.features & GF_16BIT_COLOR) { - int format = Graphics::kFormatRGB555; - Common::List formatList; - formatList.push_back((Graphics::ColorMode) format); - formatList.push_back(Graphics::kFormatCLUT8); - initGraphics(_screenWidth, _screenHeight, _screenWidth > 320, formatList); + Graphics::PixelFormat format = Graphics::kFormatRGB555; + initGraphics(_screenWidth, _screenHeight, _screenWidth > 320, format); + if (format != _system->getScreenFormat()) + return Common::kUnsupportedColorMode; #endif } else { initGraphics(_screenWidth, _screenHeight, _screenWidth > 320); -- cgit v1.2.3 From c97bfd16f94873a437cb92a30ebd11879f114e0c Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Mon, 15 Jun 2009 10:10:22 +0000 Subject: made Graphics::PixelFormat(ColorMode) constructor explicit, removed Graphics::PixelFormat(int bitFormat) constructor that was never really implemented anyway svn-id: r41540 --- engines/scumm/scumm.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/scumm') diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index 5fec6ec835..9469a15e54 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -1085,7 +1085,7 @@ Common::Error ScummEngine::init() { (_screenWidth * _textSurfaceMultiplier > 320)); #ifdef ENABLE_16BIT } else if (_game.features & GF_16BIT_COLOR) { - Graphics::PixelFormat format = Graphics::kFormatRGB555; + Graphics::PixelFormat format(Graphics::kFormatRGB555); initGraphics(_screenWidth, _screenHeight, _screenWidth > 320, format); if (format != _system->getScreenFormat()) return Common::kUnsupportedColorMode; -- cgit v1.2.3 From e74ba9af6b95c70cdcdbcf700e0964bf0be0fca1 Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Mon, 15 Jun 2009 13:23:26 +0000 Subject: Add error if user attempt to play HE games using 16bit color, when 16bit support is disabled. svn-id: r41544 --- engines/scumm/scumm.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'engines/scumm') diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index 9469a15e54..98da55d428 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -1083,12 +1083,14 @@ Common::Error ScummEngine::init() { // CJK FT and DIG use usual NUT fonts, not FM-TOWNS ROM, so // there is no text surface for them. This takes that into account (_screenWidth * _textSurfaceMultiplier > 320)); -#ifdef ENABLE_16BIT } else if (_game.features & GF_16BIT_COLOR) { +#ifdef ENABLE_16BIT Graphics::PixelFormat format(Graphics::kFormatRGB555); initGraphics(_screenWidth, _screenHeight, _screenWidth > 320, format); if (format != _system->getScreenFormat()) return Common::kUnsupportedColorMode; +#else + error("16bit color support is required for this game"); #endif } else { initGraphics(_screenWidth, _screenHeight, _screenWidth > 320); -- cgit v1.2.3 From 68cb22d4a95060bcba9b5a44508bc4ab57cb47ed Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Thu, 18 Jun 2009 01:13:42 +0000 Subject: Fix regression, caused by typo in my last commit. svn-id: r41621 --- engines/scumm/he/wiz_he.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp index deaf7aaf72..b2e367719e 100644 --- a/engines/scumm/he/wiz_he.cpp +++ b/engines/scumm/he/wiz_he.cpp @@ -1152,10 +1152,8 @@ static int wizPackType2(uint8 *dst, const uint8 *src, int srcPitch, const Common if (dst) { src += rCapt.top * srcPitch + rCapt.left * 2; while (h--) { - for (int i = 0; i < w; i++) { - uint16 col = READ_UINT16(src + w * 2); - WRITE_LE_UINT16(dst + w * 2, col); - } + for (int i = 0; i < w; i++) + WRITE_LE_UINT16(dst + i * 2, READ_UINT16(src + i * 2)); dst += w * 2; src += srcPitch; } -- cgit v1.2.3 From b8a9823f4e868a98ae85862eb457b6d4e7cffe1c Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Thu, 18 Jun 2009 06:10:13 +0000 Subject: Fix regression in scrolling rooms. svn-id: r41624 --- engines/scumm/gfx.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/gfx.h b/engines/scumm/gfx.h index c0f2c2c083..0910d9bc59 100644 --- a/engines/scumm/gfx.h +++ b/engines/scumm/gfx.h @@ -155,11 +155,11 @@ struct VirtScreen : Graphics::Surface { } byte *getPixels(int x, int y) const { - return (byte *)pixels + y * pitch + (xstart * 2 + x) * bytesPerPixel; + return (byte *)pixels + y * pitch + (xstart + x) * bytesPerPixel; } byte *getBackPixels(int x, int y) const { - return (byte *)backBuf + y * pitch + (xstart * 2 + x) * bytesPerPixel; + return (byte *)backBuf + y * pitch + (xstart + x) * bytesPerPixel; } }; -- cgit v1.2.3 From 7123fbdd7095257c9c23102f7d86d2c8cf21cfd0 Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Thu, 18 Jun 2009 07:12:53 +0000 Subject: Merged revisions 41625 via svnmerge from https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk ........ r41625 | Kirben | 2009-06-18 16:18:31 +1000 (Thu, 18 Jun 2009) | 1 line Correct actor layering method in HE90+ games. ........ svn-id: r41626 --- engines/scumm/actor.cpp | 16 ++++++++++++++++ engines/scumm/he/script_v100he.cpp | 3 +-- engines/scumm/he/script_v72he.cpp | 3 +-- 3 files changed, 18 insertions(+), 4 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/actor.cpp b/engines/scumm/actor.cpp index f3c8e2ff6b..52866279b8 100644 --- a/engines/scumm/actor.cpp +++ b/engines/scumm/actor.cpp @@ -1348,6 +1348,22 @@ void ScummEngine::processActors() { } } } + } else if (_game.heversion >= 90) { + for (int j = 0; j < numactors; ++j) { + for (int i = 0; i < numactors; ++i) { + int sc_actor1 = _sortedActors[j]->_layer; + int sc_actor2 = _sortedActors[i]->_layer; + if (sc_actor1 < sc_actor2) { + SWAP(_sortedActors[i], _sortedActors[j]); + } else if (sc_actor1 == sc_actor2) { + sc_actor1 = _sortedActors[j]->getPos().y; + sc_actor2 = _sortedActors[i]->getPos().y; + if (sc_actor1 < sc_actor2) { + SWAP(_sortedActors[i], _sortedActors[j]); + } + } + } + } } else { for (int j = 0; j < numactors; ++j) { for (int i = 0; i < numactors; ++i) { diff --git a/engines/scumm/he/script_v100he.cpp b/engines/scumm/he/script_v100he.cpp index fc27c338b2..60db9adefb 100644 --- a/engines/scumm/he/script_v100he.cpp +++ b/engines/scumm/he/script_v100he.cpp @@ -420,8 +420,7 @@ void ScummEngine_v100he::o100_actorOps() { a->_needRedraw = true; break; case 59: - // HE games use reverse order of layering, so we adjust - a->_layer = -pop(); + a->_layer = pop(); a->_needRedraw = true; break; case 63: diff --git a/engines/scumm/he/script_v72he.cpp b/engines/scumm/he/script_v72he.cpp index 049fb13cd2..3c55818ece 100644 --- a/engines/scumm/he/script_v72he.cpp +++ b/engines/scumm/he/script_v72he.cpp @@ -770,8 +770,7 @@ void ScummEngine_v72he::o72_actorOps() { a->setTalkCondition(k); break; case 43: // HE 90+ - // HE games use reverse order of layering, so we adjust - a->_layer = -pop(); + a->_layer = pop(); a->_needRedraw = true; break; case 64: -- cgit v1.2.3 From 704386d3b09b68f96b6d4160a1a261e3e754f461 Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Fri, 19 Jun 2009 09:28:55 +0000 Subject: Removed replaced Graphics::ColorMode enum type with factory methods for Graphics::PixelFormat. svn-id: r41662 --- engines/scumm/scumm.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/scumm') diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index 98da55d428..75a03aae0f 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -1085,7 +1085,7 @@ Common::Error ScummEngine::init() { (_screenWidth * _textSurfaceMultiplier > 320)); } else if (_game.features & GF_16BIT_COLOR) { #ifdef ENABLE_16BIT - Graphics::PixelFormat format(Graphics::kFormatRGB555); + Graphics::PixelFormat format = Graphics::PixelFormat::createFormatRGB555(); initGraphics(_screenWidth, _screenHeight, _screenWidth > 320, format); if (format != _system->getScreenFormat()) return Common::kUnsupportedColorMode; -- cgit v1.2.3 From f7dd1c15ed38418a0371032966144eb6c2e004cb Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Sat, 20 Jun 2009 05:23:09 +0000 Subject: renamed ENABLE_16BIT define to more accurate ENABLE_RGB_COLOR svn-id: r41696 --- engines/scumm/cursor.cpp | 2 +- engines/scumm/scumm.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/cursor.cpp b/engines/scumm/cursor.cpp index 30483a638c..5c695e58a5 100644 --- a/engines/scumm/cursor.cpp +++ b/engines/scumm/cursor.cpp @@ -112,7 +112,7 @@ void ScummEngine_v6::setCursorTransparency(int a) { void ScummEngine::updateCursor() { int transColor = (_game.heversion >= 80) ? 5 : 255; -#ifdef ENABLE_16BIT +#ifdef ENABLE_RGB_COLOR CursorMan.replaceCursorFormat(_system->getScreenFormat()); #endif CursorMan.replaceCursor(_grabbedCursor, _cursor.width, _cursor.height, diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index 75a03aae0f..cab8db2d45 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -1084,7 +1084,7 @@ Common::Error ScummEngine::init() { // there is no text surface for them. This takes that into account (_screenWidth * _textSurfaceMultiplier > 320)); } else if (_game.features & GF_16BIT_COLOR) { -#ifdef ENABLE_16BIT +#ifdef ENABLE_RGB_COLOR Graphics::PixelFormat format = Graphics::PixelFormat::createFormatRGB555(); initGraphics(_screenWidth, _screenHeight, _screenWidth > 320, format); if (format != _system->getScreenFormat()) -- cgit v1.2.3 From f1b05956310621c43c386fc1097f0651b985cfc8 Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Sun, 21 Jun 2009 14:43:06 +0000 Subject: Add initial support for captureWizPolygon. svn-id: r41728 --- engines/scumm/he/wiz_he.cpp | 380 +++++++++++++++++++++++++++----------------- engines/scumm/he/wiz_he.h | 3 + 2 files changed, 236 insertions(+), 147 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp index b2e367719e..5fbc12626e 100644 --- a/engines/scumm/he/wiz_he.cpp +++ b/engines/scumm/he/wiz_he.cpp @@ -1305,7 +1305,11 @@ void Wiz::captureWizImage(int resNum, const Common::Rect& r, bool backBuffer, in } else { src = pvs->getPixels(0, 0); } - Common::Rect rCapt(pvs->w, pvs->h); + captureImage(src, pvs->pitch, pvs->w, pvs->h, resNum, r, compType); +} + +void Wiz::captureImage(uint8 *src, int srcPitch, int srcw, int srch, int resNum, const Common::Rect& r, int compType) { + Common::Rect rCapt(srcw, srch); if (rCapt.intersects(r)) { rCapt.clip(r); const uint8 *palPtr; @@ -1327,13 +1331,13 @@ void Wiz::captureWizImage(int resNum, const Common::Rect& r, bool backBuffer, in int headerSize = palPtr ? 1080 : 36; switch (compType) { case 0: - dataSize = wizPackType0(0, src, pvs->pitch, rCapt); + dataSize = wizPackType0(0, src, srcPitch, rCapt); break; case 1: - dataSize = wizPackType1(0, src, pvs->pitch, rCapt, transColor); + dataSize = wizPackType1(0, src, srcPitch, rCapt, transColor); break; case 2: - dataSize = wizPackType2(0, src, pvs->pitch, rCapt); + dataSize = wizPackType2(0, src, srcPitch, rCapt); break; default: error("unhandled compression type %d", compType); @@ -1373,13 +1377,13 @@ void Wiz::captureWizImage(int resNum, const Common::Rect& r, bool backBuffer, in // write compressed data switch (compType) { case 0: - wizPackType0(wizImg + headerSize, src, pvs->pitch, rCapt); + wizPackType0(wizImg + headerSize, src, srcPitch, rCapt); break; case 1: - wizPackType1(wizImg + headerSize, src, pvs->pitch, rCapt, transColor); + wizPackType1(wizImg + headerSize, src, srcPitch, rCapt, transColor); break; case 2: - wizPackType2(wizImg + headerSize, src, pvs->pitch, rCapt); + wizPackType2(wizImg + headerSize, src, srcPitch, rCapt); break; default: break; @@ -1671,6 +1675,80 @@ struct PolygonDrawData { } }; +void Wiz::captureWizPolygon(int resNum, int maskNum, int maskState, int id1, int id2) { + debug(0, "captureWizPolygon: resNum %d, maskNum %d maskState %d, id1 %d id2 %d\n", resNum, maskNum, maskState, id1, id2); + + int i, j; + VirtScreen *pvs = &_vm->_virtscr[kMainVirtScreen]; + WizPolygon *wp1, *wp2; + const uint16 transColor = (_vm->VAR_WIZ_TCOLOR != 0xFF) ? _vm->VAR(_vm->VAR_WIZ_TCOLOR) : 5; + + wp1 = NULL; + for (i = 0; i < ARRAYSIZE(_polygons); ++i) { + if (_polygons[i].id == id1) { + wp1 = &_polygons[i]; + break; + } + } + if (!wp1) { + error("Polygon %d is not defined", id1); + } + if (wp1->numVerts != 5) { + error("Invalid point count %d for Polygon %d", wp1->numVerts, id1); + } + + wp2 = NULL; + for (i = 0; i < ARRAYSIZE(_polygons); ++i) { + if (_polygons[i].id == id2) { + wp2 = &_polygons[i]; + break; + } + } + if (!wp2) { + error("Polygon %d is not defined", id2); + } + if (wp2->numVerts != 5) { + error("Invalid point count %d for Polygon %d", wp2->numVerts, id2); + } + + int32 dstw, dsth, dstpitch; + int32 srcw, srch; + uint8 *imageBuffer; + const uint8 *src = pvs->getPixels(0, 0); + + if (maskNum) { + const Common::Rect *r = NULL; + src = drawWizImage(maskNum, maskState, 0, 0, 0, 0, 0, 0, 0, r, kWIFBlitToMemBuffer, 0, 0); + getWizImageDim(maskNum, maskState, srcw, srch); + } else { + srcw = pvs->w; + srch = pvs->h; + } + + dstw = wp2->bound.width(); + dsth = wp2->bound.height(); + dstpitch = wp2->bound.width() * _vm->_bitDepth; + imageBuffer = (uint8 *)malloc(wp2->bound.width() * wp2->bound.height() * _vm->_bitDepth); + assert(imageBuffer); + + if (_vm->_bitDepth == 2) { + uint8 *tmpPtr = imageBuffer; + for (i = 0; i < dsth; i++) { + for (j = 0; j < dstw; j++) + WRITE_LE_UINT16(tmpPtr + j * 2, transColor); + tmpPtr += dstpitch; + } + } else { + memset(imageBuffer, transColor, dstw * dsth); + } + + Common::Rect bound; + drawWizPolygonImage(imageBuffer, src, NULL, dstpitch, kDstMemory, dstw, dsth, srcw, srch, bound, wp2->vert, _vm->_bitDepth); + + captureImage(imageBuffer, dstpitch, dstw, dsth, resNum, wp2->bound, (_vm->_bitDepth == 2) ? 2 : 0); + free(imageBuffer); +} + void Wiz::drawWizComplexPolygon(int resNum, int state, int po_x, int po_y, int shadow, int angle, int scale, const Common::Rect *r, int flags, int dstResNum, int palette) { Common::Point pts[4]; @@ -1702,7 +1780,6 @@ void Wiz::drawWizPolygonTransform(int resNum, int state, Common::Point *wp, int const Common::Rect *r = NULL; uint8 *srcWizBuf = NULL; bool freeBuffer = true; - int i; if (_vm->_game.heversion >= 99) { if (getWizImageData(resNum, state, 0) != 0 || (flags & (kWIFRemapPalette | kWIFFlipX | kWIFFlipY)) || palette != 0) { @@ -1733,152 +1810,163 @@ void Wiz::drawWizPolygonTransform(int resNum, int state, Common::Point *wp, int } } - if (srcWizBuf) { - uint8 *dst; - int32 dstw, dsth, dstpitch, dstType, wizW, wizH; - VirtScreen *pvs = &_vm->_virtscr[kMainVirtScreen]; - int transColor = (_vm->VAR_WIZ_TCOLOR != 0xFF) ? _vm->VAR(_vm->VAR_WIZ_TCOLOR) : 5; + assert(srcWizBuf); - if (dstResNum) { - uint8 *dstPtr = _vm->getResourceAddress(rtImage, dstResNum); - assert(dstPtr); - dst = _vm->findWrappedBlock(MKID_BE('WIZD'), dstPtr, 0, 0); - assert(dst); - getWizImageDim(dstResNum, 0, dstw, dsth); - dstpitch = dstw * _vm->_bitDepth; - dstType = kDstResource; + uint8 *dst; + int32 dstw, dsth, dstpitch, dstType, wizW, wizH; + VirtScreen *pvs = &_vm->_virtscr[kMainVirtScreen]; + + if (dstResNum) { + uint8 *dstPtr = _vm->getResourceAddress(rtImage, dstResNum); + assert(dstPtr); + dst = _vm->findWrappedBlock(MKID_BE('WIZD'), dstPtr, 0, 0); + assert(dst); + getWizImageDim(dstResNum, 0, dstw, dsth); + dstpitch = dstw * _vm->_bitDepth; + dstType = kDstResource; + } else { + if (flags & kWIFMarkBufferDirty) { + dst = pvs->getPixels(0, 0); } else { - if (flags & kWIFMarkBufferDirty) { - dst = pvs->getPixels(0, 0); - } else { - dst = pvs->getBackPixels(0, 0); - } - dstw = pvs->w; - dsth = pvs->h; - dstpitch = pvs->pitch; - dstType = kDstScreen; + dst = pvs->getBackPixels(0, 0); } + dstw = pvs->w; + dsth = pvs->h; + dstpitch = pvs->pitch; + dstType = kDstScreen; + } - getWizImageDim(resNum, state, wizW, wizH); - - Common::Point bbox[4]; - bbox[0].x = 0; - bbox[0].y = 0; - bbox[1].x = wizW - 1; - bbox[1].y = 0; - bbox[2].x = wizW - 1; - bbox[2].y = wizH - 1; - bbox[3].x = 0; - bbox[3].y = wizH - 1; - - int16 xmin_p, xmax_p, ymin_p, ymax_p; - xmin_p = ymin_p = (int16)0x7FFF; - xmax_p = ymax_p = (int16)0x8000; - - for (i = 0; i < 4; ++i) { - xmin_p = MIN(wp[i].x, xmin_p); - xmax_p = MAX(wp[i].x, xmax_p); - ymin_p = MIN(wp[i].y, ymin_p); - ymax_p = MAX(wp[i].y, ymax_p); - } - - int16 xmin_b, xmax_b, ymin_b, ymax_b; - xmin_b = ymin_b = (int16)0x7FFF; - xmax_b = ymax_b = (int16)0x8000; - - for (i = 0; i < 4; ++i) { - xmin_b = MIN(bbox[i].x, xmin_b); - xmax_b = MAX(bbox[i].x, xmax_b); - ymin_b = MIN(bbox[i].y, ymin_b); - ymax_b = MAX(bbox[i].y, ymax_b); - } - - PolygonDrawData pdd(ymax_p - ymin_p + 1); - pdd.mat[0].x = xmin_p; - pdd.mat[0].y = ymin_p; - pdd.mat[1].x = xmax_p; - pdd.mat[1].y = ymax_p; - pdd.mat[2].x = xmin_b; - pdd.mat[2].y = ymin_b; - pdd.mat[3].x = xmax_b; - pdd.mat[3].y = ymax_b; - - // precompute the transformation which remaps 'bbox' pixels to 'wp' - for (i = 0; i < 3; ++i) { - pdd.transform(&wp[i], &wp[i + 1], &bbox[i], &bbox[i + 1]); - } - pdd.transform(&wp[3], &wp[0], &bbox[3], &bbox[0]); - - pdd.rAreasNum = 0; - PolygonDrawData::ResultArea *pra = &pdd.ra[0]; - int32 yoff = pdd.mat[0].y * dstpitch; - int16 y_start = pdd.mat[0].y; - for (i = 0; i < pdd.pAreasNum; ++i) { - PolygonDrawData::PolygonArea *ppa = &pdd.pa[i]; - if (y_start >= 0 && y_start < dsth) { - int16 x1 = ppa->xmin; - if (x1 < 0) { - x1 = 0; - } - int16 x2 = ppa->xmax; - if (x2 >= dstw) { - x2 = dstw - 1; - } - int16 w = x2 - x1 + 1; - if (w > 0) { - int16 width = ppa->xmax - ppa->xmin + 1; - pra->x_step = ((ppa->x2 - ppa->x1) << 16) / width; - pra->y_step = ((ppa->y2 - ppa->y1) << 16) / width; - pra->dst_offs = yoff + x1 * _vm->_bitDepth; - pra->w = w; - pra->x_s = ppa->x1 << 16; - pra->y_s = ppa->y1 << 16; - int16 tmp = x1 - ppa->xmin; - if (tmp != 0) { - pra->x_s += pra->x_step * tmp; - pra->y_s += pra->y_step * tmp; - } - ++pra; - ++pdd.rAreasNum; - } + Common::Rect bound; + getWizImageDim(resNum, state, wizW, wizH); + drawWizPolygonImage(dst, srcWizBuf, 0, dstpitch, dstType, dstw, dsth, wizW, wizH, bound, wp, _vm->_bitDepth); + + if (flags & kWIFMarkBufferDirty) { + _vm->markRectAsDirty(kMainVirtScreen, bound); + } else { + _vm->restoreBackgroundHE(bound); + } + + if (freeBuffer) + free(srcWizBuf); +} + +void Wiz::drawWizPolygonImage(uint8 *dst, const uint8 *src, const uint8 *mask, int dstpitch, int dstType, int dstw, int dsth, int wizW, int wizH, Common::Rect &bound, Common::Point *wp, uint8 bitDepth) { + int i, transColor = (_vm->VAR_WIZ_TCOLOR != 0xFF) ? _vm->VAR(_vm->VAR_WIZ_TCOLOR) : 5; + + Common::Point bbox[4]; + bbox[0].x = 0; + bbox[0].y = 0; + bbox[1].x = wizW - 1; + bbox[1].y = 0; + bbox[2].x = wizW - 1; + bbox[2].y = wizH - 1; + bbox[3].x = 0; + bbox[3].y = wizH - 1; + + int16 xmin_p, xmax_p, ymin_p, ymax_p; + xmin_p = ymin_p = (int16)0x7FFF; + xmax_p = ymax_p = (int16)0x8000; + + for (i = 0; i < 4; ++i) { + xmin_p = MIN(wp[i].x, xmin_p); + xmax_p = MAX(wp[i].x, xmax_p); + ymin_p = MIN(wp[i].y, ymin_p); + ymax_p = MAX(wp[i].y, ymax_p); + } + + int16 xmin_b, xmax_b, ymin_b, ymax_b; + xmin_b = ymin_b = (int16)0x7FFF; + xmax_b = ymax_b = (int16)0x8000; + + for (i = 0; i < 4; ++i) { + xmin_b = MIN(bbox[i].x, xmin_b); + xmax_b = MAX(bbox[i].x, xmax_b); + ymin_b = MIN(bbox[i].y, ymin_b); + ymax_b = MAX(bbox[i].y, ymax_b); + } + + PolygonDrawData pdd(ymax_p - ymin_p + 1); + pdd.mat[0].x = xmin_p; + pdd.mat[0].y = ymin_p; + pdd.mat[1].x = xmax_p; + pdd.mat[1].y = ymax_p; + pdd.mat[2].x = xmin_b; + pdd.mat[2].y = ymin_b; + pdd.mat[3].x = xmax_b; + pdd.mat[3].y = ymax_b; + + // precompute the transformation which remaps 'bbox' pixels to 'wp' + for (i = 0; i < 3; ++i) { + pdd.transform(&wp[i], &wp[i + 1], &bbox[i], &bbox[i + 1]); + } + pdd.transform(&wp[3], &wp[0], &bbox[3], &bbox[0]); + + pdd.rAreasNum = 0; + PolygonDrawData::ResultArea *pra = &pdd.ra[0]; + int32 yoff = pdd.mat[0].y * dstpitch; + int16 y_start = pdd.mat[0].y; + for (i = 0; i < pdd.pAreasNum; ++i) { + PolygonDrawData::PolygonArea *ppa = &pdd.pa[i]; + if (y_start >= 0 && y_start < dsth) { + int16 x1 = ppa->xmin; + if (x1 < 0) { + x1 = 0; } - ++ppa; - yoff += dstpitch; - ++y_start; - } - - pra = &pdd.ra[0]; - for (i = 0; i < pdd.rAreasNum; ++i, ++pra) { - uint8 *dstPtr = dst + pra->dst_offs; - int32 w = pra->w; - int32 x_acc = pra->x_s; - int32 y_acc = pra->y_s; - while (--w) { - int32 src_offs = (y_acc >> 16) * wizW + (x_acc >> 16); - assert(src_offs < wizW * wizH); - x_acc += pra->x_step; - y_acc += pra->y_step; - if (_vm->_bitDepth == 2) { - if (transColor == -1 || transColor != READ_LE_UINT16(srcWizBuf + src_offs * 2)) - writeColor(dstPtr, dstType, READ_LE_UINT16(srcWizBuf + src_offs * 2)); - } else { - if (transColor == -1 || transColor != srcWizBuf[src_offs]) - *dstPtr = srcWizBuf[src_offs]; + int16 x2 = ppa->xmax; + if (x2 >= dstw) { + x2 = dstw - 1; + } + int16 w = x2 - x1 + 1; + if (w > 0) { + int16 width = ppa->xmax - ppa->xmin + 1; + pra->x_step = ((ppa->x2 - ppa->x1) << 16) / width; + pra->y_step = ((ppa->y2 - ppa->y1) << 16) / width; + pra->dst_offs = yoff + x1 * _vm->_bitDepth; + pra->w = w; + pra->x_s = ppa->x1 << 16; + pra->y_s = ppa->y1 << 16; + int16 tmp = x1 - ppa->xmin; + if (tmp != 0) { + pra->x_s += pra->x_step * tmp; + pra->y_s += pra->y_step * tmp; } - dstPtr += _vm->_bitDepth; + ++pra; + ++pdd.rAreasNum; } } - - Common::Rect bound(xmin_p, ymin_p, xmax_p + 1, ymax_p + 1); - if (flags & kWIFMarkBufferDirty) { - _vm->markRectAsDirty(kMainVirtScreen, bound); - } else { - _vm->restoreBackgroundHE(bound); + ++ppa; + yoff += dstpitch; + ++y_start; + } + + pra = &pdd.ra[0]; + for (i = 0; i < pdd.rAreasNum; ++i, ++pra) { + uint8 *dstPtr = dst + pra->dst_offs; + int32 w = pra->w; + int32 x_acc = pra->x_s; + int32 y_acc = pra->y_s; + while (--w) { + int32 src_offs = (y_acc >> 16) * wizW + (x_acc >> 16); + assert(src_offs < wizW * wizH); + x_acc += pra->x_step; + y_acc += pra->y_step; + if (bitDepth == 2) { + if (transColor == -1 || transColor != READ_LE_UINT16(src + src_offs * 2)) { + //if (transColor == -1 || READ_LE_UINT16(dstPtr) != transColor) + writeColor(dstPtr, dstType, READ_LE_UINT16(src + src_offs * 2)); + } + } else { + if (transColor == -1 || transColor != src[src_offs]) + *dstPtr = src[src_offs]; + } + dstPtr += bitDepth; } - - if (freeBuffer) - free(srcWizBuf); } + + bound.left = xmin_p; + bound.top = ymin_p; + bound.right = xmax_p + 1; + bound.bottom = ymax_p + 1; } void Wiz::flushWizBuffer() { @@ -2329,9 +2417,7 @@ void Wiz::processWizImage(const WizParameters *params) { break; // HE 99+ case 7: - // Used in PuttsFunShop/SamsFunShop/soccer2004 - // TODO: Capture polygon - _vm->_res->setModified(rtImage, params->img.resNum); + captureWizPolygon(params->img.resNum, params->sourceImage, params->img.state, params->polygonId1, params->polygonId2); break; case 8: { int img_w = 640; diff --git a/engines/scumm/he/wiz_he.h b/engines/scumm/he/wiz_he.h index 5c5daa5974..6955355ed4 100644 --- a/engines/scumm/he/wiz_he.h +++ b/engines/scumm/he/wiz_he.h @@ -197,6 +197,8 @@ public: void loadWizCursor(int resId, int palette); void captureWizImage(int resNum, const Common::Rect& r, bool frontBuffer, int compType); + void captureImage(uint8 *src, int srcPitch, int srcw, int srch, int resNum, const Common::Rect& r, int compType); + void captureWizPolygon(int resNum, int maskNum, int maskState, int id1, int id2); void displayWizComplexImage(const WizParameters *params); void displayWizImage(WizImage *pwi); void processWizImage(const WizParameters *params); @@ -205,6 +207,7 @@ public: void drawWizPolygon(int resNum, int state, int id, int flags, int shadow, int dstResNum, int palette); void drawWizComplexPolygon(int resNum, int state, int po_x, int po_y, int shadow, int angle, int zoom, const Common::Rect *r, int flags, int dstResNum, int palette); void drawWizPolygonTransform(int resNum, int state, Common::Point *wp, int flags, int shadow, int dstResNum, int palette); + void drawWizPolygonImage(uint8 *dst, const uint8 *src, const uint8 *mask, int dstpitch, int dstType, int dstw, int dsth, int wizW, int wizH, Common::Rect &bound, Common::Point *wp, uint8 bitDepth); static void copyMaskWizImage(uint8 *dst, const uint8 *src, const uint8 *mask, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *palPtr); -- cgit v1.2.3 From 2a1a1576f225e5d20d3b9049160d209ffb1828be Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Mon, 22 Jun 2009 00:35:08 +0000 Subject: Cleanup. svn-id: r41737 --- engines/scumm/he/wiz_he.cpp | 62 ++++++++++++++++++++------------------------- engines/scumm/he/wiz_he.h | 2 +- 2 files changed, 29 insertions(+), 35 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp index 5fbc12626e..b6bce15496 100644 --- a/engines/scumm/he/wiz_he.cpp +++ b/engines/scumm/he/wiz_he.cpp @@ -1297,7 +1297,6 @@ static int wizPackType0(uint8 *dst, const uint8 *src, int srcPitch, const Common } void Wiz::captureWizImage(int resNum, const Common::Rect& r, bool backBuffer, int compType) { - debug(0, "captureWizImage(%d, %d, [%d,%d,%d,%d])", resNum, compType, r.left, r.top, r.right, r.bottom); uint8 *src = NULL; VirtScreen *pvs = &_vm->_virtscr[kMainVirtScreen]; if (backBuffer) { @@ -1309,6 +1308,7 @@ void Wiz::captureWizImage(int resNum, const Common::Rect& r, bool backBuffer, in } void Wiz::captureImage(uint8 *src, int srcPitch, int srcw, int srch, int resNum, const Common::Rect& r, int compType) { + debug(0, "captureImage(%d, %d, [%d,%d,%d,%d])", resNum, compType, r.left, r.top, r.right, r.bottom); Common::Rect rCapt(srcw, srch); if (rCapt.intersects(r)) { rCapt.clip(r); @@ -1675,62 +1675,56 @@ struct PolygonDrawData { } }; -void Wiz::captureWizPolygon(int resNum, int maskNum, int maskState, int id1, int id2) { - debug(0, "captureWizPolygon: resNum %d, maskNum %d maskState %d, id1 %d id2 %d\n", resNum, maskNum, maskState, id1, id2); +void Wiz::captureWizPolygon(int resNum, int maskNum, int maskState, int id1, int id2, int compType) { + debug(0, "captureWizPolygon: resNum %d, maskNum %d maskState %d, id1 %d id2 %d compType %d", resNum, maskNum, maskState, id1, id2, compType); int i, j; - VirtScreen *pvs = &_vm->_virtscr[kMainVirtScreen]; - WizPolygon *wp1, *wp2; - const uint16 transColor = (_vm->VAR_WIZ_TCOLOR != 0xFF) ? _vm->VAR(_vm->VAR_WIZ_TCOLOR) : 5; + WizPolygon *wp; - wp1 = NULL; + wp = NULL; for (i = 0; i < ARRAYSIZE(_polygons); ++i) { if (_polygons[i].id == id1) { - wp1 = &_polygons[i]; + wp = &_polygons[i]; break; } } - if (!wp1) { - error("Polygon %d is not defined", id1); + if (!wp) { + error("Polygon1 %d is not defined", id1); } - if (wp1->numVerts != 5) { - error("Invalid point count %d for Polygon %d", wp1->numVerts, id1); + if (wp->numVerts != 5) { + error("Invalid point count %d for Polygon1 %d", wp->numVerts, id1); } - wp2 = NULL; + wp = NULL; for (i = 0; i < ARRAYSIZE(_polygons); ++i) { if (_polygons[i].id == id2) { - wp2 = &_polygons[i]; + wp = &_polygons[i]; break; } } - if (!wp2) { - error("Polygon %d is not defined", id2); + if (!wp) { + error("Polygon2 %d is not defined", id2); } - if (wp2->numVerts != 5) { - error("Invalid point count %d for Polygon %d", wp2->numVerts, id2); + if (wp->numVerts != 5) { + error("Invalid point count %d for Polygon2 %d", wp->numVerts, id2); } int32 dstw, dsth, dstpitch; int32 srcw, srch; uint8 *imageBuffer; - const uint8 *src = pvs->getPixels(0, 0); - if (maskNum) { - const Common::Rect *r = NULL; - src = drawWizImage(maskNum, maskState, 0, 0, 0, 0, 0, 0, 0, r, kWIFBlitToMemBuffer, 0, 0); - getWizImageDim(maskNum, maskState, srcw, srch); - } else { - srcw = pvs->w; - srch = pvs->h; - } + assert(maskNum); + const Common::Rect *r = NULL; + const uint8 *src = drawWizImage(maskNum, maskState, 0, 0, 0, 0, 0, 0, 0, r, kWIFBlitToMemBuffer, 0, 0); + getWizImageDim(maskNum, maskState, srcw, srch); - dstw = wp2->bound.width(); - dsth = wp2->bound.height(); - dstpitch = wp2->bound.width() * _vm->_bitDepth; - imageBuffer = (uint8 *)malloc(wp2->bound.width() * wp2->bound.height() * _vm->_bitDepth); + dstw = wp->bound.width(); + dsth = wp->bound.height(); + dstpitch = dstw * _vm->_bitDepth; + imageBuffer = (uint8 *)malloc(dstw * dsth * _vm->_bitDepth); assert(imageBuffer); + const uint16 transColor = (_vm->VAR_WIZ_TCOLOR != 0xFF) ? _vm->VAR(_vm->VAR_WIZ_TCOLOR) : 5; if (_vm->_bitDepth == 2) { uint8 *tmpPtr = imageBuffer; for (i = 0; i < dsth; i++) { @@ -1743,9 +1737,9 @@ void Wiz::captureWizPolygon(int resNum, int maskNum, int maskState, int id1, int } Common::Rect bound; - drawWizPolygonImage(imageBuffer, src, NULL, dstpitch, kDstMemory, dstw, dsth, srcw, srch, bound, wp2->vert, _vm->_bitDepth); + drawWizPolygonImage(imageBuffer, src, NULL, dstpitch, kDstMemory, dstw, dsth, srcw, srch, bound, wp->vert, _vm->_bitDepth); - captureImage(imageBuffer, dstpitch, dstw, dsth, resNum, wp2->bound, (_vm->_bitDepth == 2) ? 2 : 0); + captureImage(imageBuffer, dstpitch, dstw, dsth, resNum, wp->bound, compType); free(imageBuffer); } @@ -2417,7 +2411,7 @@ void Wiz::processWizImage(const WizParameters *params) { break; // HE 99+ case 7: - captureWizPolygon(params->img.resNum, params->sourceImage, params->img.state, params->polygonId1, params->polygonId2); + captureWizPolygon(params->img.resNum, params->sourceImage, params->img.state, params->polygonId1, params->polygonId2, params->compType); break; case 8: { int img_w = 640; diff --git a/engines/scumm/he/wiz_he.h b/engines/scumm/he/wiz_he.h index 6955355ed4..d8f984f710 100644 --- a/engines/scumm/he/wiz_he.h +++ b/engines/scumm/he/wiz_he.h @@ -198,7 +198,7 @@ public: void captureWizImage(int resNum, const Common::Rect& r, bool frontBuffer, int compType); void captureImage(uint8 *src, int srcPitch, int srcw, int srch, int resNum, const Common::Rect& r, int compType); - void captureWizPolygon(int resNum, int maskNum, int maskState, int id1, int id2); + void captureWizPolygon(int resNum, int maskNum, int maskState, int id1, int id2, int compType); void displayWizComplexImage(const WizParameters *params); void displayWizImage(WizImage *pwi); void processWizImage(const WizParameters *params); -- cgit v1.2.3 From a937dfde96b35738b916e4299cc4e917fc6d2d9e Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Mon, 22 Jun 2009 11:00:53 +0000 Subject: Fix loading/saving in funshop titles. svn-id: r41764 --- engines/scumm/he/script_v72he.cpp | 5 ++-- engines/scumm/he/wiz_he.cpp | 48 +++++++++++++++++++++++---------------- 2 files changed, 31 insertions(+), 22 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/he/script_v72he.cpp b/engines/scumm/he/script_v72he.cpp index 3c55818ece..9d5bd0b23d 100644 --- a/engines/scumm/he/script_v72he.cpp +++ b/engines/scumm/he/script_v72he.cpp @@ -1482,6 +1482,7 @@ void ScummEngine_v72he::o72_readFile() { fetchScriptByte(); size = pop(); slot = pop(); + assert(_hInFileTable[slot]); val = readFileToArray(slot, size); push(val); break; @@ -1809,9 +1810,7 @@ void ScummEngine_v72he::o72_readINI() { switch (subOp) { case 43: // HE 100 case 6: // number - if (!strcmp((char *)option, "NoFontsInstalled")) { - push(1); - } else if (!strcmp((char *)option, "NoPrinting")) { + if (!strcmp((char *)option, "NoPrinting")) { push(1); } else if (!strcmp((char *)option, "TextOn")) { push(ConfMan.getBool("subtitles")); diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp index b6bce15496..2e414f2a1e 100644 --- a/engines/scumm/he/wiz_he.cpp +++ b/engines/scumm/he/wiz_he.cpp @@ -2323,7 +2323,7 @@ void Wiz::remapWizImagePal(const WizParameters *params) { } void Wiz::processWizImage(const WizParameters *params) { - byte filename[260]; + byte buffer[260]; debug(3, "processWizImage: processMode %d", params->processMode); switch (params->processMode) { @@ -2338,18 +2338,28 @@ void Wiz::processWizImage(const WizParameters *params) { break; case 3: if (params->processFlags & kWPFUseFile) { - Common::File f; + Common::SeekableReadStream *f = NULL; + memcpy(buffer, params->filename, 260); + const char *filename = (char *)buffer + _vm->convertFilePath(buffer); - memcpy(filename, params->filename, 260); - _vm->convertFilePath(filename); + if (!_vm->_saveFileMan->listSavefiles(filename).empty()) { + f = _vm->_saveFileMan->openForLoading(filename); + } else { + Common::File *nf = new Common::File(); + nf->open(filename); + if (!nf->isOpen()) + delete nf; + else + f = nf; + } - if (f.open((const char *)filename)) { - uint32 id = f.readUint32BE(); + if (f) { + uint32 id = f->readUint32BE(); if (id == MKID_BE('AWIZ') || id == MKID_BE('MULT')) { - uint32 size = f.readUint32BE(); - f.seek(0, SEEK_SET); + uint32 size = f->readUint32BE(); + f->seek(0, SEEK_SET); byte *p = _vm->_res->createResource(rtImage, params->img.resNum, size); - if (f.read(p, size) != size) { + if (f->read(p, size) != size) { _vm->_res->nukeResource(rtImage, params->img.resNum); error("i/o error when reading '%s'", filename); _vm->VAR(_vm->VAR_GAME_LOADED) = -2; @@ -2363,7 +2373,7 @@ void Wiz::processWizImage(const WizParameters *params) { _vm->VAR(_vm->VAR_GAME_LOADED) = -1; _vm->VAR(119) = -1; } - f.close(); + delete f; } else { _vm->VAR(_vm->VAR_GAME_LOADED) = -3; _vm->VAR(119) = -3; @@ -2373,7 +2383,9 @@ void Wiz::processWizImage(const WizParameters *params) { break; case 4: if (params->processFlags & kWPFUseFile) { - Common::DumpFile f; + Common::OutSaveFile *f; + memcpy(buffer, params->filename, 260); + const char *filename = (char *)buffer + _vm->convertFilePath(buffer); switch (params->fileWriteMode) { case 2: @@ -2383,22 +2395,20 @@ void Wiz::processWizImage(const WizParameters *params) { // TODO Write image to file break; case 0: - memcpy(filename, params->filename, 260); - _vm->convertFilePath(filename); - - if (!f.open((const char *)filename)) { + if (!(f = _vm->_saveFileMan->openForSaving(filename))) { debug(0, "Unable to open for write '%s'", filename); _vm->VAR(119) = -3; } else { byte *p = _vm->getResourceAddress(rtImage, params->img.resNum); uint32 size = READ_BE_UINT32(p + 4); - if (f.write(p, size) != size) { - error("i/o error when writing '%s'", params->filename); + if (f->write(p, size) != size) { + error("i/o error when writing '%s'", filename); _vm->VAR(119) = -2; } else { _vm->VAR(119) = 0; } - f.close(); + f->finalize(); + delete f; } break; default: @@ -2411,7 +2421,7 @@ void Wiz::processWizImage(const WizParameters *params) { break; // HE 99+ case 7: - captureWizPolygon(params->img.resNum, params->sourceImage, params->img.state, params->polygonId1, params->polygonId2, params->compType); + captureWizPolygon(params->img.resNum, params->sourceImage, (params->processFlags & kWPFNewState) ? params->img.state : 0, params->polygonId1, params->polygonId2, params->compType); break; case 8: { int img_w = 640; -- cgit v1.2.3 From a44859e01bead5a30d8446a5bc75857d000199d9 Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Tue, 23 Jun 2009 14:06:57 +0000 Subject: Fix error in Backyard Soccer 2004, when using Season Play. svn-id: r41808 --- engines/scumm/he/script_v100he.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'engines/scumm') diff --git a/engines/scumm/he/script_v100he.cpp b/engines/scumm/he/script_v100he.cpp index 60db9adefb..58a858ede4 100644 --- a/engines/scumm/he/script_v100he.cpp +++ b/engines/scumm/he/script_v100he.cpp @@ -1574,7 +1574,10 @@ void ScummEngine_v100he::o100_roomOps() { case 130: a = pop(); b = pop(); - copyPalColor(a, b); + if (_game.features & GF_16BIT_COLOR) + copyHEPaletteColor(1, a, b); + else + copyPalColor(a, b); break; case 131: // SO_ROOM_FADE -- cgit v1.2.3 From 865129a5630017f05d08e778ba1ef430c23cd55a Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Wed, 24 Jun 2009 06:44:30 +0000 Subject: made the cursor's pixel format a member of the cursor object, merged ____CursorFormat functions into equivalent ____Cursor functions. svn-id: r41825 --- engines/scumm/cursor.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/cursor.cpp b/engines/scumm/cursor.cpp index 5c695e58a5..190c337c63 100644 --- a/engines/scumm/cursor.cpp +++ b/engines/scumm/cursor.cpp @@ -113,12 +113,17 @@ void ScummEngine_v6::setCursorTransparency(int a) { void ScummEngine::updateCursor() { int transColor = (_game.heversion >= 80) ? 5 : 255; #ifdef ENABLE_RGB_COLOR - CursorMan.replaceCursorFormat(_system->getScreenFormat()); -#endif + CursorMan.replaceCursor(_grabbedCursor, _cursor.width, _cursor.height, + _cursor.hotspotX, _cursor.hotspotY, + (_game.platform == Common::kPlatformNES ? _grabbedCursor[63] : transColor), + (_game.heversion == 70 ? 2 : 1), + _system->getScreenFormat()); +#else CursorMan.replaceCursor(_grabbedCursor, _cursor.width, _cursor.height, _cursor.hotspotX, _cursor.hotspotY, (_game.platform == Common::kPlatformNES ? _grabbedCursor[63] : transColor), (_game.heversion == 70 ? 2 : 1)); +#endif } void ScummEngine_v6::grabCursor(int x, int y, int w, int h) { -- cgit v1.2.3 From 2859c9130462e66df705d534f9a70d1430628be7 Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Fri, 26 Jun 2009 08:50:11 +0000 Subject: Changed cursor manager functions to take *Graphics::PixelFormat with default parameter of NULL (and initialize NULL pointers with CLUT8), rather than taking a Graphics::PixelFormat with default parameter of Graphics::PixelFormat::createFormatCLUT8() svn-id: r41900 --- engines/scumm/cursor.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines/scumm') diff --git a/engines/scumm/cursor.cpp b/engines/scumm/cursor.cpp index 190c337c63..66ac68bd95 100644 --- a/engines/scumm/cursor.cpp +++ b/engines/scumm/cursor.cpp @@ -113,11 +113,12 @@ void ScummEngine_v6::setCursorTransparency(int a) { void ScummEngine::updateCursor() { int transColor = (_game.heversion >= 80) ? 5 : 255; #ifdef ENABLE_RGB_COLOR + Graphics::PixelFormat format = _system->getScreenFormat(); CursorMan.replaceCursor(_grabbedCursor, _cursor.width, _cursor.height, _cursor.hotspotX, _cursor.hotspotY, (_game.platform == Common::kPlatformNES ? _grabbedCursor[63] : transColor), (_game.heversion == 70 ? 2 : 1), - _system->getScreenFormat()); + &format); #else CursorMan.replaceCursor(_grabbedCursor, _cursor.width, _cursor.height, _cursor.hotspotX, _cursor.hotspotY, -- cgit v1.2.3 From 853aec05ba4485f0bfc90e7515322dfd56a8d4af Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Sat, 27 Jun 2009 05:58:44 +0000 Subject: changed initGraphics, and OSystem::initSize to take Graphics::PixelFormat * parameters instead of Graphics::PixelFormat parameters, to save unnecessary pixelformat initialization if ENABLE_RGB_COLOR is not set. svn-id: r41909 --- engines/scumm/scumm.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/scumm') diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index cab8db2d45..fe38bbf82f 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -1086,7 +1086,7 @@ Common::Error ScummEngine::init() { } else if (_game.features & GF_16BIT_COLOR) { #ifdef ENABLE_RGB_COLOR Graphics::PixelFormat format = Graphics::PixelFormat::createFormatRGB555(); - initGraphics(_screenWidth, _screenHeight, _screenWidth > 320, format); + initGraphics(_screenWidth, _screenHeight, _screenWidth > 320, &format); if (format != _system->getScreenFormat()) return Common::kUnsupportedColorMode; #else -- cgit v1.2.3 From 2c5d11b67b35f93b2292c1ca56d0c9fc89608921 Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Tue, 7 Jul 2009 07:50:40 +0000 Subject: Removed PixelFormat convenience constructors at behest of Max and Eugene. svn-id: r42207 --- engines/scumm/scumm.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines/scumm') diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index c6ed7b71cc..347abee190 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -1085,7 +1085,8 @@ Common::Error ScummEngine::init() { (_screenWidth * _textSurfaceMultiplier > 320)); } else if (_game.features & GF_16BIT_COLOR) { #ifdef ENABLE_RGB_COLOR - Graphics::PixelFormat format = Graphics::PixelFormat::createFormatRGB555(); + Graphics::PixelFormat format = Graphics::PixelFormat(2, 3, 3, 3, 8, 10, 5, 0, 0) +; initGraphics(_screenWidth, _screenHeight, _screenWidth > 320, &format); if (format != _system->getScreenFormat()) return Common::kUnsupportedColorMode; -- cgit v1.2.3 From cdad3763dfbacf45599034358a32fc68032e1a30 Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Thu, 9 Jul 2009 09:09:05 +0000 Subject: Corrected lingering formatting errors that were introduced by the find-and-replace assisted removal of Graphics::PixelFormat::createFormat functions. svn-id: r42281 --- engines/scumm/scumm.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index 347abee190..57283c1fbe 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -1085,8 +1085,7 @@ Common::Error ScummEngine::init() { (_screenWidth * _textSurfaceMultiplier > 320)); } else if (_game.features & GF_16BIT_COLOR) { #ifdef ENABLE_RGB_COLOR - Graphics::PixelFormat format = Graphics::PixelFormat(2, 3, 3, 3, 8, 10, 5, 0, 0) -; + Graphics::PixelFormat format = Graphics::PixelFormat(2, 3, 3, 3, 8, 10, 5, 0, 0); initGraphics(_screenWidth, _screenHeight, _screenWidth > 320, &format); if (format != _system->getScreenFormat()) return Common::kUnsupportedColorMode; -- cgit v1.2.3 From cdf751accda346f5d96e3fdfa2fd4a1b92ed4d19 Mon Sep 17 00:00:00 2001 From: Jody Northup Date: Tue, 14 Jul 2009 08:27:36 +0000 Subject: changed generic Graphics::PixelFormat constructor to take xBits instead of xLoss. Modified OSystem_SDL::getSupportedFormats and ScummEngine::init to account for this change. svn-id: r42467 --- engines/scumm/scumm.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/scumm') diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index 8d078f12d4..a00ace1f49 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -1085,7 +1085,7 @@ Common::Error ScummEngine::init() { (_screenWidth * _textSurfaceMultiplier > 320)); } else if (_game.features & GF_16BIT_COLOR) { #ifdef ENABLE_RGB_COLOR - Graphics::PixelFormat format = Graphics::PixelFormat(2, 3, 3, 3, 8, 10, 5, 0, 0); + Graphics::PixelFormat format = Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); initGraphics(_screenWidth, _screenHeight, _screenWidth > 320, &format); if (format != _system->getScreenFormat()) return Common::kUnsupportedColorMode; -- cgit v1.2.3 From 8e417b0884e676ff5fe297d1642c9d8499ad9b90 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Sat, 15 Aug 2009 14:50:21 +0000 Subject: Fix compile when compiling with --disable-he svn-id: r43410 --- engines/scumm/akos.cpp | 4 ++++ engines/scumm/cursor.cpp | 4 ++++ 2 files changed, 8 insertions(+) (limited to 'engines/scumm') diff --git a/engines/scumm/akos.cpp b/engines/scumm/akos.cpp index f4bb8a2c8b..c7f53b9763 100644 --- a/engines/scumm/akos.cpp +++ b/engines/scumm/akos.cpp @@ -299,6 +299,7 @@ void AkosRenderer::setPalette(uint16 *new_palette) { if (size > 256) error("akos_setPalette: %d is too many colors", size); +#ifdef ENABLE_HE if (_vm->_game.features & GF_16BIT_COLOR) { if (_paletteNum) { for (i = 0; i < size; i++) @@ -317,10 +318,13 @@ void AkosRenderer::setPalette(uint16 *new_palette) { for (i = 0; i < size; i++) _palette[i] = (byte)_vm->_hePalettes[_paletteNum * _vm->_hePaletteSlot + 768 + akpl[i]]; } else { +#endif for (i = 0; i < size; i++) { _palette[i] = new_palette[i] != 0xFF ? new_palette[i] : akpl[i]; } +#ifdef ENABLE_HE } +#endif if (_vm->_game.heversion == 70) { for (i = 0; i < size; i++) diff --git a/engines/scumm/cursor.cpp b/engines/scumm/cursor.cpp index 66ac68bd95..5af25e95ef 100644 --- a/engines/scumm/cursor.cpp +++ b/engines/scumm/cursor.cpp @@ -194,15 +194,19 @@ void ScummEngine_v70he::setDefaultCursor() { for (j = 0; j < 32; j++) { switch ((p & (0x3 << 14)) >> 14) { case 1: +#ifdef ENABLE_HE if (_bitDepth == 2) WRITE_UINT16(_grabbedCursor + 64 * i + j * 2, get16BitColor(palette[4], palette[5], palette[6])); else +#endif _grabbedCursor[32 * i + j] = 0xfe; break; case 2: +#ifdef ENABLE_HE if (_bitDepth == 2) WRITE_UINT16(_grabbedCursor + 64 * i + j * 2, get16BitColor(palette[0], palette[1], palette[2])); else +#endif _grabbedCursor[32 * i + j] = 0xfd; break; default: -- cgit v1.2.3 From 09845556e0383fb187f548c7cfc1a68b22329f7e Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Sun, 16 Aug 2009 00:20:23 +0000 Subject: Revert revision 43410, and add alternative fix. svn-id: r43416 --- engines/scumm/akos.cpp | 4 ---- engines/scumm/cursor.cpp | 4 ---- engines/scumm/he/palette_he.cpp | 21 --------------------- engines/scumm/palette.cpp | 21 +++++++++++++++++++++ 4 files changed, 21 insertions(+), 29 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/akos.cpp b/engines/scumm/akos.cpp index c7f53b9763..f4bb8a2c8b 100644 --- a/engines/scumm/akos.cpp +++ b/engines/scumm/akos.cpp @@ -299,7 +299,6 @@ void AkosRenderer::setPalette(uint16 *new_palette) { if (size > 256) error("akos_setPalette: %d is too many colors", size); -#ifdef ENABLE_HE if (_vm->_game.features & GF_16BIT_COLOR) { if (_paletteNum) { for (i = 0; i < size; i++) @@ -318,13 +317,10 @@ void AkosRenderer::setPalette(uint16 *new_palette) { for (i = 0; i < size; i++) _palette[i] = (byte)_vm->_hePalettes[_paletteNum * _vm->_hePaletteSlot + 768 + akpl[i]]; } else { -#endif for (i = 0; i < size; i++) { _palette[i] = new_palette[i] != 0xFF ? new_palette[i] : akpl[i]; } -#ifdef ENABLE_HE } -#endif if (_vm->_game.heversion == 70) { for (i = 0; i < size; i++) diff --git a/engines/scumm/cursor.cpp b/engines/scumm/cursor.cpp index 5af25e95ef..66ac68bd95 100644 --- a/engines/scumm/cursor.cpp +++ b/engines/scumm/cursor.cpp @@ -194,19 +194,15 @@ void ScummEngine_v70he::setDefaultCursor() { for (j = 0; j < 32; j++) { switch ((p & (0x3 << 14)) >> 14) { case 1: -#ifdef ENABLE_HE if (_bitDepth == 2) WRITE_UINT16(_grabbedCursor + 64 * i + j * 2, get16BitColor(palette[4], palette[5], palette[6])); else -#endif _grabbedCursor[32 * i + j] = 0xfe; break; case 2: -#ifdef ENABLE_HE if (_bitDepth == 2) WRITE_UINT16(_grabbedCursor + 64 * i + j * 2, get16BitColor(palette[0], palette[1], palette[2])); else -#endif _grabbedCursor[32 * i + j] = 0xfd; break; default: diff --git a/engines/scumm/he/palette_he.cpp b/engines/scumm/he/palette_he.cpp index 02f3f3fc5c..ff29f9ecd0 100644 --- a/engines/scumm/he/palette_he.cpp +++ b/engines/scumm/he/palette_he.cpp @@ -33,27 +33,6 @@ namespace Scumm { -uint8 *ScummEngine::getHEPaletteSlot(uint16 palSlot) { - assertRange(0, palSlot, _numPalettes, "palette"); - - if (_game.heversion >= 99) { - if (palSlot) - return _hePalettes + palSlot * _hePaletteSlot + 768; - else - return _hePalettes + _hePaletteSlot + 768; - } - - return NULL; -} - -uint16 ScummEngine::get16BitColor(uint8 r, uint8 g, uint8 b) { - uint16 ar = (r >> 3) << 10; - uint16 ag = (g >> 3) << 5; - uint16 ab = (b >> 3) << 0; - uint16 col = ar | ag | ab; - return col; -} - void ScummEngine_v71he::remapHEPalette(const uint8 *src, uint8 *dst) { int r, g, b, sum, bestitem, bestsum; int ar, ag, ab; diff --git a/engines/scumm/palette.cpp b/engines/scumm/palette.cpp index f59b59b40f..a596cc5b1a 100644 --- a/engines/scumm/palette.cpp +++ b/engines/scumm/palette.cpp @@ -33,6 +33,27 @@ namespace Scumm { +uint8 *ScummEngine::getHEPaletteSlot(uint16 palSlot) { + assertRange(0, palSlot, _numPalettes, "palette"); + + if (_game.heversion >= 99) { + if (palSlot) + return _hePalettes + palSlot * _hePaletteSlot + 768; + else + return _hePalettes + _hePaletteSlot + 768; + } + + return NULL; +} + +uint16 ScummEngine::get16BitColor(uint8 r, uint8 g, uint8 b) { + uint16 ar = (r >> 3) << 10; + uint16 ag = (g >> 3) << 5; + uint16 ab = (b >> 3) << 0; + uint16 col = ar | ag | ab; + return col; +} + void ScummEngine::resetPalette() { if (_game.version <= 1) { if (_game.platform == Common::kPlatformApple2GS) { -- cgit v1.2.3 From 43d57fd333afa54f4e85f30e2ef8231444988066 Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Sun, 16 Aug 2009 01:46:47 +0000 Subject: Update branch specific save game changes, to prevent conflicts. svn-id: r43421 --- engines/scumm/actor.cpp | 4 ++-- engines/scumm/saveload.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/actor.cpp b/engines/scumm/actor.cpp index 227ae1d316..9dab776b67 100644 --- a/engines/scumm/actor.cpp +++ b/engines/scumm/actor.cpp @@ -2553,8 +2553,8 @@ void Actor::saveLoadWithSerializer(Serializer *ser) { // Actor palette grew from 64 to 256 bytes and switched to uint16 in HE games MKARRAY_OLD(Actor, _palette[0], sleByte, 64, VER(8), VER(9)), - MKARRAY_OLD(Actor, _palette[0], sleByte, 256, VER(10), VER(77)), - MKARRAY(Actor, _palette[0], sleUint16, 256, VER(78)), + MKARRAY_OLD(Actor, _palette[0], sleByte, 256, VER(10), VER(79)), + MKARRAY(Actor, _palette[0], sleUint16, 256, VER(80)), MK_OBSOLETE(Actor, _mask, sleByte, VER(8), VER(9)), MKLINE(Actor, _shadowMode, sleByte, VER(8)), diff --git a/engines/scumm/saveload.h b/engines/scumm/saveload.h index 4f6adc5570..fafb6b383f 100644 --- a/engines/scumm/saveload.h +++ b/engines/scumm/saveload.h @@ -50,7 +50,7 @@ namespace Scumm { * only saves/loads those which are valid for the version of the savegame * which is being loaded/saved currently. */ -#define CURRENT_VER 79 +#define CURRENT_VER 80 /** * An auxillary macro, used to specify savegame versions. We use this instead -- cgit v1.2.3 From b33b90ecd0468c58b93e13ff80bf6939e97ed7a6 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 18 Aug 2009 15:31:26 +0000 Subject: Made AGOS, DRASCULA, GOB, GROOVIE, MADE, SCUMM and TINSEL properly stop CD audio playback on engine quit. (This only problem affected playback from CD, not from ripped audio files) svn-id: r43512 --- engines/scumm/sound.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/scumm') diff --git a/engines/scumm/sound.cpp b/engines/scumm/sound.cpp index 528cceb0cc..524dbf70ea 100644 --- a/engines/scumm/sound.cpp +++ b/engines/scumm/sound.cpp @@ -86,7 +86,7 @@ Sound::Sound(ScummEngine *parent, Audio::Mixer *mixer) Sound::~Sound() { stopCDTimer(); - AudioCD.destroy(); + AudioCD.stop(); delete _sfxFile; } -- cgit v1.2.3 From b5ce08b2c680b6b9411a40efbeda95d7f8af6143 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 20 Aug 2009 09:21:09 +0000 Subject: Switch SCUMM engine to use the SaveLoadChooser from gui/ instead of implementing its own, which resulted in code duplication. svn-id: r43552 --- engines/scumm/dialogs.cpp | 237 ++++------------------------------------------ engines/scumm/dialogs.h | 34 +------ 2 files changed, 21 insertions(+), 250 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/dialogs.cpp b/engines/scumm/dialogs.cpp index 63ac952265..53097b6815 100644 --- a/engines/scumm/dialogs.cpp +++ b/engines/scumm/dialogs.cpp @@ -213,8 +213,6 @@ ScummDialog::ScummDialog(String name) : GUI::Dialog(name) { #pragma mark - -Common::StringList generateSavegameList(ScummEngine *scumm, bool saveMode); - enum { kSaveCmd = 'SAVE', kLoadCmd = 'LOAD', @@ -226,213 +224,6 @@ enum { kChooseCmd = 'CHOS' }; -SaveLoadChooser::SaveLoadChooser(const String &title, const String &buttonLabel, bool saveMode, ScummEngine *engine) - : Dialog("ScummSaveLoad"), _saveMode(saveMode), _list(0), _chooseButton(0), _gfxWidget(0), _vm(engine) { - - _backgroundType = GUI::ThemeEngine::kDialogBackgroundSpecial; - - new StaticTextWidget(this, "ScummSaveLoad.Title", title); - - // Add choice list - _list = new GUI::ListWidget(this, "ScummSaveLoad.List"); - _list->setEditable(saveMode); - _list->setNumberingMode(saveMode ? GUI::kListNumberingOne : GUI::kListNumberingZero); - -// Tanoku: SVNMerge removed this. Unconvinient. /////////////// -// _container = new GUI::ContainerWidget(this, 0, 0, 10, 10); -/////////////////////////////////////////////////////////////// - - _gfxWidget = new GUI::GraphicsWidget(this, 0, 0, 10, 10); - - _date = new StaticTextWidget(this, 0, 0, 10, 10, "No date saved", kTextAlignCenter); - _time = new StaticTextWidget(this, 0, 0, 10, 10, "No time saved", kTextAlignCenter); - _playtime = new StaticTextWidget(this, 0, 0, 10, 10, "No playtime saved", kTextAlignCenter); - - // Buttons - new GUI::ButtonWidget(this, "ScummSaveLoad.Cancel", "Cancel", kCloseCmd, 0); - _chooseButton = new GUI::ButtonWidget(this, "ScummSaveLoad.Choose", buttonLabel, kChooseCmd, 0); - _chooseButton->setEnabled(false); - - _container = new GUI::ContainerWidget(this, 0, 0, 10, 10); -// _container->setHints(GUI::THEME_HINT_USE_SHADOW); -} - -SaveLoadChooser::~SaveLoadChooser() { -} - -const Common::String &SaveLoadChooser::getResultString() const { - return _list->getSelectedString(); -} - -void SaveLoadChooser::setList(const StringList& list) { - _list->setList(list); -} - -int SaveLoadChooser::runModal() { - if (_gfxWidget) - _gfxWidget->setGfx(0); - int ret = Dialog::runModal(); - return ret; -} - -void SaveLoadChooser::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { - int selItem = _list->getSelected(); - switch (cmd) { - case GUI::kListItemActivatedCmd: - case GUI::kListItemDoubleClickedCmd: - if (selItem >= 0) { - if (_saveMode || !getResultString().empty()) { - _list->endEditMode(); - setResult(selItem); - close(); - } - } - break; - case kChooseCmd: - _list->endEditMode(); - setResult(selItem); - close(); - break; - case GUI::kListSelectionChangedCmd: { - if (_gfxWidget) { - updateInfos(true); - } - - if (_saveMode) { - _list->startEditMode(); - } - // Disable button if nothing is selected, or (in load mode) if an empty - // list item is selected. We allow choosing an empty item in save mode - // because we then just assign a default name. - _chooseButton->setEnabled(selItem >= 0 && (_saveMode || !getResultString().empty())); - _chooseButton->draw(); - } break; - case kCloseCmd: - setResult(-1); - default: - Dialog::handleCommand(sender, cmd, data); - } -} - -void SaveLoadChooser::reflowLayout() { - if (g_gui.xmlEval()->getVar("Globals.ScummSaveLoad.ExtInfo.Visible") == 1) { - int16 x, y; - uint16 w, h; - - if (!g_gui.xmlEval()->getWidgetData("ScummSaveLoad.Thumbnail", x, y, w, h)) - error("Error when loading position data for Save/Load Thumbnails."); - - int thumbW = kThumbnailWidth; - int thumbH = ((g_system->getHeight() % 200 && g_system->getHeight() != 350) ? kThumbnailHeight2 : kThumbnailHeight1); - int thumbX = x + (w >> 1) - (thumbW >> 1); - int thumbY = y + kLineHeight; - - _container->resize(x, y, w, h); - _gfxWidget->resize(thumbX, thumbY, thumbW, thumbH); - - int height = thumbY + thumbH + kLineHeight; - - _date->resize(thumbX, height, kThumbnailWidth, kLineHeight); - - height += kLineHeight; - - _time->resize(thumbX, height, kThumbnailWidth, kLineHeight); - - height += kLineHeight; - - _playtime->resize(thumbX, height, kThumbnailWidth, kLineHeight); - - _container->setVisible(true); - _gfxWidget->setVisible(true); - _date->setVisible(true); - _time->setVisible(true); - _playtime->setVisible(true); - - _fillR = 0; //g_gui.evaluator()->getVar("scummsaveload_thumbnail.fillR"); - _fillG = 0; //g_gui.evaluator()->getVar("scummsaveload_thumbnail.fillG"); - _fillB = 0; //g_gui.evaluator()->getVar("scummsaveload_thumbnail.fillB"); - } else { - _container->setVisible(false); - _gfxWidget->setVisible(false); - _date->setVisible(false); - _time->setVisible(false); - _playtime->setVisible(false); - } - - Dialog::reflowLayout(); - - if (_container->isVisible()) - updateInfos(false); -} - -void SaveLoadChooser::updateInfos(bool redraw) { - int selItem = _list->getSelected(); - Graphics::Surface *thumb = 0; - if (selItem >= 0 && !_list->getSelectedString().empty()) - thumb = _vm->loadThumbnailFromSlot(_saveMode ? selItem + 1 : selItem); - - if (thumb) { - _gfxWidget->setGfx(thumb); - _gfxWidget->useAlpha(256); - thumb->free(); - delete thumb; - } else { - _gfxWidget->setGfx(-1, -1, _fillR, _fillG, _fillB); - } - - InfoStuff infos; - memset(&infos, 0, sizeof(InfoStuff)); - if (selItem >= 0 && !_list->getSelectedString().empty() - && _vm->loadInfosFromSlot(_saveMode ? selItem + 1 : selItem, &infos)) { - char buffer[32]; - snprintf(buffer, 32, "Date: %.2d.%.2d.%.4d", - (infos.date >> 24) & 0xFF, (infos.date >> 16) & 0xFF, - infos.date & 0xFFFF); - _date->setLabel(buffer); - - snprintf(buffer, 32, "Time: %.2d:%.2d", - (infos.time >> 8) & 0xFF, infos.time & 0xFF); - _time->setLabel(buffer); - - int minutes = infos.playtime / 60; - int hours = minutes / 60; - minutes %= 60; - - snprintf(buffer, 32, "Playtime: %.2d:%.2d", hours, minutes); - _playtime->setLabel(buffer); - } else { - _date->setLabel("No date saved"); - _time->setLabel("No time saved"); - _playtime->setLabel("No playtime saved"); - } - - if (redraw) { - _gfxWidget->draw(); - _date->draw(); - _time->draw(); - _playtime->draw(); - } -} - -#pragma mark - - -Common::StringList generateSavegameList(ScummEngine *scumm, bool saveMode) { - // Get savegame descriptions - Common::StringList descriptions; - uint i = saveMode ? 1 : 0; //the autosave is on slot #0 - bool avail_saves[81]; - - scumm->listSavegames(avail_saves, ARRAYSIZE(avail_saves)); - for (; i < ARRAYSIZE(avail_saves); i++) { - Common::String name; - if (avail_saves[i]) - scumm->getSavegameName(i, name); - descriptions.push_back(name); - } - - return descriptions; -} - ScummMenuDialog::ScummMenuDialog(ScummEngine *scumm) : ScummDialog("ScummMain"), _vm(scumm) { @@ -457,8 +248,10 @@ ScummMenuDialog::ScummMenuDialog(ScummEngine *scumm) #ifndef DISABLE_HELP _helpDialog = new HelpDialog(scumm->_game); #endif - _saveDialog = new SaveLoadChooser("Save game:", "Save", true, scumm); - _loadDialog = new SaveLoadChooser("Load game:", "Load", false, scumm); + _saveDialog = new GUI::SaveLoadChooser("Save game:", "Save"); + _saveDialog->setSaveMode(true); + _loadDialog = new GUI::SaveLoadChooser("Load game:", "Load"); + _loadDialog->setSaveMode(false); } ScummMenuDialog::~ScummMenuDialog() { @@ -513,28 +306,34 @@ void ScummMenuDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 da } void ScummMenuDialog::save() { - int idx; - _saveDialog->setList(generateSavegameList(_vm, true)); - idx = _saveDialog->runModal(); + Common::String gameId = ConfMan.get("gameid"); + + const EnginePlugin *plugin = 0; + EngineMan.findGame(gameId, &plugin); + + int idx = _saveDialog->runModal(plugin, ConfMan.getActiveDomainName()); if (idx >= 0) { String result(_saveDialog->getResultString()); char buffer[20]; const char *str; if (result.empty()) { // If the user was lazy and entered no save name, come up with a default name. - sprintf(buffer, "Save %d", idx + 1); + sprintf(buffer, "Save %d", idx); str = buffer; } else str = result.c_str(); - _vm->requestSave(idx + 1, str); + _vm->requestSave(idx, str); close(); } } void ScummMenuDialog::load() { - int idx; - _loadDialog->setList(generateSavegameList(_vm, false)); - idx = _loadDialog->runModal(); + Common::String gameId = ConfMan.get("gameid"); + + const EnginePlugin *plugin = 0; + EngineMan.findGame(gameId, &plugin); + + int idx = _loadDialog->runModal(plugin, ConfMan.getActiveDomainName()); if (idx >= 0) { _vm->requestLoad(idx); close(); diff --git a/engines/scumm/dialogs.h b/engines/scumm/dialogs.h index 85b562ed67..644c028c5e 100644 --- a/engines/scumm/dialogs.h +++ b/engines/scumm/dialogs.h @@ -29,6 +29,7 @@ #include "gui/dialog.h" #include "gui/options.h" #include "gui/widget.h" +#include "gui/saveload.h" #include "scumm/detection.h" #ifndef DISABLE_HELP @@ -53,35 +54,6 @@ protected: typedef Common::String String; }; -class SaveLoadChooser : public GUI::Dialog { - typedef Common::String String; - typedef Common::StringList StringList; -protected: - bool _saveMode; - GUI::ListWidget *_list; - GUI::ButtonWidget *_chooseButton; - GUI::GraphicsWidget *_gfxWidget; - GUI::StaticTextWidget *_date; - GUI::StaticTextWidget *_time; - GUI::StaticTextWidget *_playtime; - GUI::ContainerWidget *_container; - ScummEngine *_vm; - - uint8 _fillR, _fillG, _fillB; - - void updateInfos(bool redraw); -public: - SaveLoadChooser(const String &title, const String &buttonLabel, bool saveMode, ScummEngine *engine); - ~SaveLoadChooser(); - - virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data); - const String &getResultString() const; - void setList(const StringList& list); - int runModal(); - - virtual void reflowLayout(); -}; - class ScummMenuDialog : public ScummDialog { public: ScummMenuDialog(ScummEngine *scumm); @@ -99,8 +71,8 @@ protected: #ifndef DISABLE_HELP GUI::Dialog *_helpDialog; #endif - SaveLoadChooser *_saveDialog; - SaveLoadChooser *_loadDialog; + GUI::SaveLoadChooser *_saveDialog; + GUI::SaveLoadChooser *_loadDialog; GUI::ButtonWidget *_saveButton; -- cgit v1.2.3 From 8b0a10ad75e585ca7b5cae79467c6faf0bcc1917 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 20 Aug 2009 09:24:22 +0000 Subject: Cleanup. svn-id: r43554 --- engines/scumm/scumm.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h index bfb188f1c7..f2eb331a14 100644 --- a/engines/scumm/scumm.h +++ b/engines/scumm/scumm.h @@ -667,9 +667,6 @@ public: } static Graphics::Surface *loadThumbnailFromSlot(const char *target, int slot); - bool loadInfosFromSlot(int slot, InfoStuff *stuff) { - return loadInfosFromSlot(_targetName.c_str(), slot, stuff); - } static bool loadInfosFromSlot(const char *target, int slot, InfoStuff *stuff); protected: -- cgit v1.2.3 From ba7a574ca1026f65721463199e7afb41bb998197 Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Fri, 21 Aug 2009 10:34:13 +0000 Subject: Only enable 16bit color HE games, if 16bit color support is enabled. svn-id: r43584 --- engines/scumm/detection_tables.h | 126 ++++++++++++++++++++------------------- 1 file changed, 65 insertions(+), 61 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/detection_tables.h b/engines/scumm/detection_tables.h index 99a28153c4..01bd0446ff 100644 --- a/engines/scumm/detection_tables.h +++ b/engines/scumm/detection_tables.h @@ -80,13 +80,21 @@ static const PlainGameDescriptor gameDescriptions[] = { { "puttputt", "Putt-Putt Joins the Parade" }, #ifdef ENABLE_HE - { "airport", "Let's Explore the Airport with Buzzy" }, +#ifdef ENABLE_RGB_COLOR { "arttime", "Blue's Art Time Activities" }, - { "balloon", "Putt-Putt and Pep's Balloon-O-Rama" }, - { "baseball", "Backyard Baseball" }, { "baseball2001", "Backyard Baseball 2001" }, { "Baseball2003", "Backyard Baseball 2003" }, { "basketball", "Backyard Basketball" }, + { "football2002", "Backyard Football 2002" }, + { "freddicove", "Freddi Fish 5: The Case of the Creature of Coral Cave" }, + { "moonbase", "Moonbase Commander" }, + { "pjgames", "Pajama Sam: Games to Play On Any Day" }, + { "readtime", "Blue's Reading Time Activities" }, + { "Soccer2004", "Backyard Soccer 2004" }, +#endif + { "airport", "Let's Explore the Airport with Buzzy" }, + { "balloon", "Putt-Putt and Pep's Balloon-O-Rama" }, + { "baseball", "Backyard Baseball" }, { "Blues123Time", "Blue's 123 Time Activities" }, { "BluesABCTime", "Blue's ABC Time Activities" }, { "BluesBirthday", "Blue's Birthday Adventure" }, @@ -96,31 +104,25 @@ static const PlainGameDescriptor gameDescriptions[] = { { "dog", "Putt-Putt and Pep's Dog on a Stick" }, { "farm", "Let's Explore the Farm with Buzzy" }, { "football", "Backyard Football" }, - { "football2002", "Backyard Football 2002" }, { "freddi", "Freddi Fish 1: The Case of the Missing Kelp Seeds" }, { "freddi2", "Freddi Fish 2: The Case of the Haunted Schoolhouse" }, { "freddi3", "Freddi Fish 3: The Case of the Stolen Conch Shell" }, { "freddi4", "Freddi Fish 4: The Case of the Hogfish Rustlers of Briny Gulch" }, - { "freddicove", "Freddi Fish 5: The Case of the Creature of Coral Cave" }, { "FreddisFunShop", "Freddi Fish's One-Stop Fun Shop" }, { "jungle", "Let's Explore the Jungle with Buzzy" }, { "lost", "Pajama Sam's Lost & Found" }, { "maze", "Freddi Fish and Luther's Maze Madness" }, - { "moonbase", "Moonbase Commander" }, { "mustard", "SPY Fox in Hold the Mustard" }, { "pajama", "Pajama Sam 1: No Need to Hide When It's Dark Outside" }, { "pajama2", "Pajama Sam 2: Thunder and Lightning Aren't so Frightening" }, { "pajama3", "Pajama Sam 3: You Are What You Eat From Your Head to Your Feet" }, - { "pjgames", "Pajama Sam: Games to Play On Any Day" }, { "puttcircus", "Putt-Putt Joins the Circus" }, { "puttrace", "Putt-Putt Enters the Race" }, { "PuttsFunShop", "Putt-Putt's One-Stop Fun Shop" }, { "putttime", "Putt-Putt Travels Through Time" }, { "puttzoo", "Putt-Putt Saves the Zoo" }, - { "readtime", "Blue's Reading Time Activities" }, { "SamsFunShop", "Pajama Sam's One-Stop Fun Shop" }, { "soccer", "Backyard Soccer" }, - { "Soccer2004", "Backyard Soccer 2004" }, { "SoccerMLS", "Backyard Soccer MLS Edition" }, { "socks", "Pajama Sam's Sock Works" }, { "spyfox", "SPY Fox 1: Dry Cereal" }, @@ -500,23 +502,12 @@ static const GameFilenamePattern gameFilenamesTable[] = { { "puttputt", "Putt-Putt", kGenHEMacNoParens, UNK_LANG, Common::kPlatformMacintosh, 0 }, #ifdef ENABLE_HE - { "airport", "airport", kGenHEPC, UNK_LANG, UNK, 0 }, - { "airport", "airdemo", kGenHEPC, UNK_LANG, UNK, 0 }, - { "airport", "Airport Demo", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, - { "airport", "The AirPort", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, - +#ifdef ENABLE_RGB_COLOR { "arttime", "arttime", kGenHEPC, UNK_LANG, UNK, 0 }, { "arttime", "Blues-ArtTime", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, { "arttime", "artdemo", kGenHEPC, UNK_LANG, UNK, 0 }, { "arttime", "Blues-ArtTime Demo", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, - { "balloon", "balloon", kGenHEPC, UNK_LANG, UNK, 0 }, - { "balloon", "Balloon-O-Rama", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, - - { "baseball", "baseball", kGenHEPC, UNK_LANG, UNK, 0 }, - { "baseball", "BaseBall", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, - { "baseball", "basedemo.cup", kGenUnchanged, UNK_LANG, UNK, 0 }, - { "baseball2001", "baseball2001", kGenHEPC, UNK_LANG, UNK, 0 }, { "baseball2001", "bb2demo", kGenHEPC, UNK_LANG, UNK, 0 }, { "baseball2001", "Baseball 2001 Demo", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, @@ -529,6 +520,59 @@ static const GameFilenamePattern gameFilenamesTable[] = { { "basketball", "basketball", kGenHEPC, UNK_LANG, UNK, 0 }, { "basketball", "Basketball", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, + { "football2002", "FootBall2002", kGenHEPC, UNK_LANG, UNK, 0 }, + { "football2002", "Football 2002", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, + + { "freddicove", "freddicove", kGenHEPC, UNK_LANG, UNK, 0 }, + { "freddicove", "FreddiCCC", kGenHEPC, UNK_LANG, UNK, 0 }, + { "freddicove", "FreddiCove", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, + { "freddicove", "FreddiDZZ", kGenHEPC, Common::NL_NLD, UNK, 0 }, + { "freddicove", "FreddiDZZ", kGenHEMac, Common::NL_NLD, Common::kPlatformMacintosh, 0 }, + { "freddicove", "FreddiMML", kGenHEPC, Common::FR_FRA, UNK, 0 }, + { "freddicove", "FreddiMML", kGenHEMac, Common::FR_FRA, Common::kPlatformMacintosh, 0 }, + { "freddicove", "FFCoveDemo", kGenHEPC, UNK_LANG, UNK, 0 }, + { "freddicove", "FreddiCoveDemo", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, + { "freddicove", "ff5demo", kGenHEPC, UNK_LANG, UNK, 0 }, + { "freddicove", "FF5Demo", kGenHEMac, Common::NL_NLD, Common::kPlatformMacintosh, 0 }, + + { "moonbase", "moonbase", kGenHEPC, UNK_LANG, UNK, 0 }, + { "moonbase", "moondemo", kGenHEPC, UNK_LANG, UNK, 0 }, + + { "pjgames", "pjgames", kGenHEPC, UNK_LANG, UNK, 0 }, + { "pjgames", "PJGames", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, + + { "readtime", "Blue's Reading Time", kGenHEPC, UNK_LANG, UNK, 0 }, + { "readtime", "Blues-ReadingTime", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, + { "readtime", "readDemo", kGenHEPC, UNK_LANG, UNK, 0 }, + { "readtime", "Blues-ReadingTime Demo", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, + + { "Soccer2004", "Soccer2004", kGenHEPC, UNK_LANG, UNK, 0 }, + { "Soccer2004", "Soccer 2004", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, + + { "spyozon", "spyozon", kGenHEPC, UNK_LANG, UNK, 0 }, + { "spyozon", "sf3-demo", kGenHEPC, UNK_LANG, UNK, 0 }, + { "spyozon", "SF3Demo", kGenHEPC, Common::FR_FRA, UNK, 0 }, + { "spyozon", "Spy Ozone Demo", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, + { "spyozon", "SPYFoxAIW", kGenHEPC, Common::DE_DEU, UNK, 0 }, + { "spyozon", "SPYFoxOZU", kGenHEPC, UNK_LANG, UNK, 0 }, + { "spyozon", "SPYFoxSOS", kGenHEPC, Common::FR_FRA, UNK, 0 }, + { "spyozon", "SPYFoxSOS", kGenHEMac, Common::FR_FRA, Common::kPlatformMacintosh, 0 }, + { "spyozon", "SpyOzon", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, + { "spyozon", "ozonepre.cup", kGenUnchanged, UNK_LANG, UNK, "HE CUP" }, +#endif + + { "airport", "airport", kGenHEPC, UNK_LANG, UNK, 0 }, + { "airport", "airdemo", kGenHEPC, UNK_LANG, UNK, 0 }, + { "airport", "Airport Demo", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, + { "airport", "The AirPort", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, + + { "balloon", "balloon", kGenHEPC, UNK_LANG, UNK, 0 }, + { "balloon", "Balloon-O-Rama", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, + + { "baseball", "baseball", kGenHEPC, UNK_LANG, UNK, 0 }, + { "baseball", "BaseBall", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, + { "baseball", "basedemo.cup", kGenUnchanged, UNK_LANG, UNK, 0 }, + { "blues123time", "Blues123time", kGenHEPC, UNK_LANG, UNK, 0 }, { "blues123time", "Blue's 123 Time", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, @@ -571,9 +615,6 @@ static const GameFilenamePattern gameFilenamesTable[] = { { "football", "FootBall Demo", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, { "football", "footdemo", kGenHEPC, UNK_LANG, UNK, 0 }, - { "football2002", "FootBall2002", kGenHEPC, UNK_LANG, UNK, 0 }, - { "football2002", "Football 2002", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, - { "freddi", "freddi", kGenHEPC, UNK_LANG, UNK, 0 }, { "freddi", "Freddi", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, { "freddi", "Freddi1", kGenHEPC, UNK_LANG, UNK, 0 }, @@ -632,18 +673,6 @@ static const GameFilenamePattern gameFilenamesTable[] = { { "freddi4", "MaliceMRC", kGenHEPC, Common::FR_FRA, UNK, 0 }, { "freddi4", "Mm4demo", kGenHEPC, Common::FR_FRA, UNK, 0 }, - { "freddicove", "freddicove", kGenHEPC, UNK_LANG, UNK, 0 }, - { "freddicove", "FreddiCCC", kGenHEPC, UNK_LANG, UNK, 0 }, - { "freddicove", "FreddiCove", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, - { "freddicove", "FreddiDZZ", kGenHEPC, Common::NL_NLD, UNK, 0 }, - { "freddicove", "FreddiDZZ", kGenHEMac, Common::NL_NLD, Common::kPlatformMacintosh, 0 }, - { "freddicove", "FreddiMML", kGenHEPC, Common::FR_FRA, UNK, 0 }, - { "freddicove", "FreddiMML", kGenHEMac, Common::FR_FRA, Common::kPlatformMacintosh, 0 }, - { "freddicove", "FFCoveDemo", kGenHEPC, UNK_LANG, UNK, 0 }, - { "freddicove", "FreddiCoveDemo", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, - { "freddicove", "ff5demo", kGenHEPC, UNK_LANG, UNK, 0 }, - { "freddicove", "FF5Demo", kGenHEMac, Common::NL_NLD, Common::kPlatformMacintosh, 0 }, - { "FreddisFunShop", "FreddisFunShop", kGenHEPC, UNK_LANG, UNK, 0 }, { "FreddisFunShop", "Freddi's FunShop", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, @@ -661,9 +690,6 @@ static const GameFilenamePattern gameFilenamesTable[] = { { "maze", "Doolhof", kGenHEMac, Common::NL_NLD, Common::kPlatformMacintosh, 0 }, { "maze", "Maze Madness", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, - { "moonbase", "moonbase", kGenHEPC, UNK_LANG, UNK, 0 }, - { "moonbase", "moondemo", kGenHEPC, UNK_LANG, UNK, 0 }, - { "mustard", "mustard", kGenHEPC, UNK_LANG, UNK, 0 }, { "mustard", "Mustard", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, @@ -716,9 +742,6 @@ static const GameFilenamePattern gameFilenamesTable[] = { { "pajama3", "PyjamaSKS", kGenHEMac, Common::DE_DEU, Common::kPlatformMacintosh, 0 }, { "pajama3", "UKPajamaEAT", kGenHEPC, Common::RU_RUS, UNK, 0 }, - { "pjgames", "pjgames", kGenHEPC, UNK_LANG, UNK, 0 }, - { "pjgames", "PJGames", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, - { "puttcircus", "puttcircus", kGenHEPC, UNK_LANG, UNK, 0 }, { "puttcircus", "circdemo", kGenHEPC, UNK_LANG, UNK, 0 }, { "puttcircus", "CircusDemo", kGenHEPC, Common::FR_FRA, UNK, 0 }, @@ -788,11 +811,6 @@ static const GameFilenamePattern gameFilenamesTable[] = { { "puttzoo", "Zoo Demo", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, { "puttzoo", "Putt-Putt Saves the Zoo", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, - { "readtime", "Blue's Reading Time", kGenHEPC, UNK_LANG, UNK, 0 }, - { "readtime", "Blues-ReadingTime", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, - { "readtime", "readDemo", kGenHEPC, UNK_LANG, UNK, 0 }, - { "readtime", "Blues-ReadingTime Demo", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, - { "SamsFunShop", "SamsFunShop", kGenHEPC, UNK_LANG, UNK, 0 }, { "SamsFunShop", "Sam's FunShop", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, @@ -802,9 +820,6 @@ static const GameFilenamePattern gameFilenamesTable[] = { { "SoccerMLS", "SoccerMLS", kGenHEPC, UNK_LANG, UNK, 0 }, { "SoccerMLS", "Backyard Soccer MLS", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, - { "Soccer2004", "Soccer2004", kGenHEPC, UNK_LANG, UNK, 0 }, - { "Soccer2004", "Soccer 2004", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, - { "socks", "socks", kGenHEPC, UNK_LANG, UNK, 0 }, { "socks", "SockWorks", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, { "socks", "SokkenSoep", kGenHEPC, Common::NL_NLD, UNK, 0 }, @@ -846,17 +861,6 @@ static const GameFilenamePattern gameFilenamesTable[] = { { "spyfox2", "SPYMini", kGenHEPC, UNK_LANG, UNK, 0 }, { "spyfox2", "spy2preview.cup", kGenUnchanged, UNK_LANG, UNK, 0 }, - { "spyozon", "spyozon", kGenHEPC, UNK_LANG, UNK, 0 }, - { "spyozon", "sf3-demo", kGenHEPC, UNK_LANG, UNK, 0 }, - { "spyozon", "SF3Demo", kGenHEPC, Common::FR_FRA, UNK, 0 }, - { "spyozon", "Spy Ozone Demo", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, - { "spyozon", "SPYFoxAIW", kGenHEPC, Common::DE_DEU, UNK, 0 }, - { "spyozon", "SPYFoxOZU", kGenHEPC, UNK_LANG, UNK, 0 }, - { "spyozon", "SPYFoxSOS", kGenHEPC, Common::FR_FRA, UNK, 0 }, - { "spyozon", "SPYFoxSOS", kGenHEMac, Common::FR_FRA, Common::kPlatformMacintosh, 0 }, - { "spyozon", "SpyOzon", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, - { "spyozon", "ozonepre.cup", kGenUnchanged, UNK_LANG, UNK, "HE CUP" }, - { "thinker1", "1grademo", kGenHEPC, UNK_LANG, UNK, 0 }, { "thinker1", "thinker1", kGenHEPC, UNK_LANG, UNK, 0 }, { "thinker1", "Thinker1", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, -- cgit v1.2.3 From 007f68366fd55a519753bf533c7c3a80db3754f0 Mon Sep 17 00:00:00 2001 From: Andre Heider Date: Fri, 21 Aug 2009 18:16:37 +0000 Subject: Renamed ENABLE_RGB_COLOR to USE_RGB_COLOR, and added it to config.h to guarantee a consistent build. svn-id: r43604 --- engines/scumm/cursor.cpp | 2 +- engines/scumm/detection_tables.h | 4 ++-- engines/scumm/scumm.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/cursor.cpp b/engines/scumm/cursor.cpp index 66ac68bd95..7818d6a98e 100644 --- a/engines/scumm/cursor.cpp +++ b/engines/scumm/cursor.cpp @@ -112,7 +112,7 @@ void ScummEngine_v6::setCursorTransparency(int a) { void ScummEngine::updateCursor() { int transColor = (_game.heversion >= 80) ? 5 : 255; -#ifdef ENABLE_RGB_COLOR +#ifdef USE_RGB_COLOR Graphics::PixelFormat format = _system->getScreenFormat(); CursorMan.replaceCursor(_grabbedCursor, _cursor.width, _cursor.height, _cursor.hotspotX, _cursor.hotspotY, diff --git a/engines/scumm/detection_tables.h b/engines/scumm/detection_tables.h index 01bd0446ff..c9af022af5 100644 --- a/engines/scumm/detection_tables.h +++ b/engines/scumm/detection_tables.h @@ -80,7 +80,7 @@ static const PlainGameDescriptor gameDescriptions[] = { { "puttputt", "Putt-Putt Joins the Parade" }, #ifdef ENABLE_HE -#ifdef ENABLE_RGB_COLOR +#ifdef USE_RGB_COLOR { "arttime", "Blue's Art Time Activities" }, { "baseball2001", "Backyard Baseball 2001" }, { "Baseball2003", "Backyard Baseball 2003" }, @@ -502,7 +502,7 @@ static const GameFilenamePattern gameFilenamesTable[] = { { "puttputt", "Putt-Putt", kGenHEMacNoParens, UNK_LANG, Common::kPlatformMacintosh, 0 }, #ifdef ENABLE_HE -#ifdef ENABLE_RGB_COLOR +#ifdef USE_RGB_COLOR { "arttime", "arttime", kGenHEPC, UNK_LANG, UNK, 0 }, { "arttime", "Blues-ArtTime", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, { "arttime", "artdemo", kGenHEPC, UNK_LANG, UNK, 0 }, diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index 1beda85456..9f3ebb8053 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -1100,7 +1100,7 @@ Common::Error ScummEngine::init() { // there is no text surface for them. This takes that into account (_screenWidth * _textSurfaceMultiplier > 320)); } else if (_game.features & GF_16BIT_COLOR) { -#ifdef ENABLE_RGB_COLOR +#ifdef USE_RGB_COLOR Graphics::PixelFormat format = Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); initGraphics(_screenWidth, _screenHeight, _screenWidth > 320, &format); if (format != _system->getScreenFormat()) -- cgit v1.2.3 From 894635e91d7bdaa4517618a957441db016b2798b Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Fri, 21 Aug 2009 22:29:28 +0000 Subject: Attempt to fix builds that use the ARM screen column clear code; add new bitdepth argument that was missing in ARM builds previously. Also fix a few warnings. Also fix the WinCE build which fails in the SDL init call with a missing bitdepth field. Untested at this point (build certainly gets further than before). Committing this seems reasonable, as it can't make it any worse :) svn-id: r43614 --- engines/scumm/gfx.cpp | 8 ++++---- engines/scumm/gfxARM.s | 39 ++++++++++++++++++++++++++++++++++++--- engines/scumm/he/sound_he.cpp | 2 +- 3 files changed, 41 insertions(+), 8 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/gfx.cpp b/engines/scumm/gfx.cpp index 1802d0d39c..c6e2cd3312 100644 --- a/engines/scumm/gfx.cpp +++ b/engines/scumm/gfx.cpp @@ -38,7 +38,7 @@ #ifdef USE_ARM_GFX_ASM extern "C" void asmDrawStripToScreen(int height, int width, void const* text, void const* src, byte* dst, int vsPitch, int vmScreenWidth, int textSurfacePitch); -extern "C" void asmCopy8Col(byte* dst, int dstPitch, const byte* src, int height); +extern "C" void asmCopy8Col(byte* dst, int dstPitch, const byte* src, int height, uint8_t bitDepth); #endif /* USE_ARM_GFX_ASM */ namespace Scumm { @@ -784,8 +784,8 @@ void ditherHerc(byte *src, byte *hercbuf, int srcPitch, int *x, int *y, int *wid } void scale2x(byte *dst, int dstPitch, const byte *src, int srcPitch, int w, int h) { - uint16 *dstL1 = (uint16 *)dst; - uint16 *dstL2 = (uint16 *)(dst + dstPitch); + uint16 *dstL1 = (uint16 *)(void *)dst; + uint16 *dstL2 = (uint16 *)(void *)(dst + dstPitch); const int dstAdd = dstPitch - w; const int srcAdd = srcPitch - w; @@ -1114,7 +1114,7 @@ static void fill(byte *dst, int dstPitch, uint16 color, int w, int h, uint8 bitD #ifdef USE_ARM_GFX_ASM -#define copy8Col(A,B,C,D) asmCopy8Col(A,B,C,D) +#define copy8Col(A,B,C,D,E) asmCopy8Col(A,B,C,D,E) #else diff --git a/engines/scumm/gfxARM.s b/engines/scumm/gfxARM.s index f3a1f20303..adcd4bfac5 100644 --- a/engines/scumm/gfxARM.s +++ b/engines/scumm/gfxARM.s @@ -126,9 +126,13 @@ asmCopy8Col: @ r1 = dstPitch @ r2 = src @ r3 = height - STMFD r13!,{r14} - SUB r1,r1,#4 + @ <> = bitdepth + LDR r12,[r13] + STR r14,[r13,#-4]! + CMP r12,#8 + BNE copy8Col16 + SUB r1,r1,#4 TST r3,#1 ADDNE r3,r3,#1 BNE roll2 @@ -145,4 +149,33 @@ roll2: STR r14,[r0],r1 BNE yLoop2 - LDMFD r13!,{PC} + LDR PC,[r13],#4 + +copy8Col16: + STMFD r13!,{r4-r5} + SUB r1,r1,#12 + TST r3,#1 + ADDNE r3,r3,#1 + BNE roll3 +yLoop3: + LDR r4, [r2],#4 + LDR r5, [r2],#4 + LDR r12,[r2],#4 + LDR r14,[r2],r1 + STR r4, [r0],#4 + STR r5, [r0],#4 + STR r12,[r0],#4 + STR r14,[r0],r1 +roll3: + LDR r4, [r2],#4 + LDR r5, [r2],#4 + LDR r12,[r2],#4 + LDR r14,[r2],r1 + SUBS r3,r3,#2 + STR r4, [r0],#4 + STR r5, [r0],#4 + STR r12,[r0],#4 + STR r14,[r0],r1 + BNE yLoop3 + + LDMFD r13!,{r4,r5,PC} diff --git a/engines/scumm/he/sound_he.cpp b/engines/scumm/he/sound_he.cpp index 01f29d5db9..feaf273b4e 100644 --- a/engines/scumm/he/sound_he.cpp +++ b/engines/scumm/he/sound_he.cpp @@ -645,7 +645,7 @@ void SoundHE::playHESound(int soundID, int heOffset, int heChannel, int heFlags) Audio::AudioStream *voxStream = Audio::makeADPCMStream(&stream, false, size, Audio::kADPCMMSIma, rate, (flags & Audio::Mixer::FLAG_STEREO) ? 2 : 1, blockAlign); sound = (char *)malloc(size * 4); - size = voxStream->readBuffer((int16*)sound, size * 2); + size = voxStream->readBuffer((int16*)(void *)sound, size * 2); size *= 2; // 16bits. delete voxStream; -- cgit v1.2.3 From 71b9b5f497342000b5094f32905a8bb9b5c52bfd Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Fri, 21 Aug 2009 22:31:50 +0000 Subject: Oops. Bitdepth is 1 or 2, not 8 or 16. Could be better named perhaps? (bytedepth maybe?) svn-id: r43616 --- engines/scumm/gfxARM.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/scumm') diff --git a/engines/scumm/gfxARM.s b/engines/scumm/gfxARM.s index adcd4bfac5..caefa7175a 100644 --- a/engines/scumm/gfxARM.s +++ b/engines/scumm/gfxARM.s @@ -129,7 +129,7 @@ asmCopy8Col: @ <> = bitdepth LDR r12,[r13] STR r14,[r13,#-4]! - CMP r12,#8 + CMP r12,#1 BNE copy8Col16 SUB r1,r1,#4 -- cgit v1.2.3 From 6166c85b062f5eb365b35780c38fe6bcc91020ff Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Fri, 21 Aug 2009 22:42:51 +0000 Subject: Improved comments. svn-id: r43617 --- engines/scumm/gfxARM.s | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/gfxARM.s b/engines/scumm/gfxARM.s index caefa7175a..24f627647a 100644 --- a/engines/scumm/gfxARM.s +++ b/engines/scumm/gfxARM.s @@ -116,7 +116,8 @@ end: @ extern "C" void asmCopy8Col(byte *dst, @ int dstPitch, @ const byte *src, - @ int height); + @ int height, + @ int bitdepth); @ @ In addition, we assume that src and dst are both word (4 byte) @ aligned. This is the same assumption that the old 'inline' version @@ -126,7 +127,7 @@ asmCopy8Col: @ r1 = dstPitch @ r2 = src @ r3 = height - @ <> = bitdepth + @ <> = bitdepth (badly named, should be bytedepth, 1 or 2) LDR r12,[r13] STR r14,[r13,#-4]! CMP r12,#1 -- cgit v1.2.3 From f9fe1cbbcc58b74ce34bf487648acb71b8fd34ab Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Fri, 21 Aug 2009 22:48:54 +0000 Subject: Improved comments. svn-id: r43619 --- engines/scumm/he/sound_he.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'engines/scumm') diff --git a/engines/scumm/he/sound_he.cpp b/engines/scumm/he/sound_he.cpp index feaf273b4e..477f3cf0ad 100644 --- a/engines/scumm/he/sound_he.cpp +++ b/engines/scumm/he/sound_he.cpp @@ -645,6 +645,10 @@ void SoundHE::playHESound(int soundID, int heOffset, int heChannel, int heFlags) Audio::AudioStream *voxStream = Audio::makeADPCMStream(&stream, false, size, Audio::kADPCMMSIma, rate, (flags & Audio::Mixer::FLAG_STEREO) ? 2 : 1, blockAlign); sound = (char *)malloc(size * 4); + /* On systems where it matters, malloc will return + * even addresses, so the use of (void *) in the + * following cast shuts the compiler from warning + * unnecessarily. */ size = voxStream->readBuffer((int16*)(void *)sound, size * 2); size *= 2; // 16bits. delete voxStream; -- cgit v1.2.3 From a790e4953cb4f6e2a4ec95311eb292e7aaec62b4 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Fri, 21 Aug 2009 22:55:19 +0000 Subject: Updated comments. svn-id: r43620 --- engines/scumm/gfx.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'engines/scumm') diff --git a/engines/scumm/gfx.cpp b/engines/scumm/gfx.cpp index c6e2cd3312..ba49131ac5 100644 --- a/engines/scumm/gfx.cpp +++ b/engines/scumm/gfx.cpp @@ -784,6 +784,8 @@ void ditherHerc(byte *src, byte *hercbuf, int srcPitch, int *x, int *y, int *wid } void scale2x(byte *dst, int dstPitch, const byte *src, int srcPitch, int w, int h) { + /* dst and dstPitch should both be even. So the use of (void *) in + * the following casts to avoid the unnecessary warning is valid. */ uint16 *dstL1 = (uint16 *)(void *)dst; uint16 *dstL2 = (uint16 *)(void *)(dst + dstPitch); -- cgit v1.2.3 From 68fed4c62aae3becba7e723a28850004d8704094 Mon Sep 17 00:00:00 2001 From: Andre Heider Date: Fri, 21 Aug 2009 22:56:09 +0000 Subject: type fix svn-id: r43621 --- engines/scumm/gfx.cpp | 2 +- engines/scumm/gfxARM.s | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/gfx.cpp b/engines/scumm/gfx.cpp index ba49131ac5..fd298c2980 100644 --- a/engines/scumm/gfx.cpp +++ b/engines/scumm/gfx.cpp @@ -38,7 +38,7 @@ #ifdef USE_ARM_GFX_ASM extern "C" void asmDrawStripToScreen(int height, int width, void const* text, void const* src, byte* dst, int vsPitch, int vmScreenWidth, int textSurfacePitch); -extern "C" void asmCopy8Col(byte* dst, int dstPitch, const byte* src, int height, uint8_t bitDepth); +extern "C" void asmCopy8Col(byte* dst, int dstPitch, const byte* src, int height, uint8 bitDepth); #endif /* USE_ARM_GFX_ASM */ namespace Scumm { diff --git a/engines/scumm/gfxARM.s b/engines/scumm/gfxARM.s index 24f627647a..e78487d777 100644 --- a/engines/scumm/gfxARM.s +++ b/engines/scumm/gfxARM.s @@ -117,7 +117,7 @@ end: @ int dstPitch, @ const byte *src, @ int height, - @ int bitdepth); + @ uint8 bitdepth); @ @ In addition, we assume that src and dst are both word (4 byte) @ aligned. This is the same assumption that the old 'inline' version -- cgit v1.2.3 From 7cb03ffa3e8cbf47631afe42e01a1a577afc22ef Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Sat, 22 Aug 2009 00:27:01 +0000 Subject: Exclude 16bit specific code, when 16bit support is disabled. svn-id: r43625 --- engines/scumm/he/wiz_he.cpp | 58 ++++++++++++++++++++++++++++++--------------- engines/scumm/he/wiz_he.h | 6 +++++ 2 files changed, 45 insertions(+), 19 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp index b00294cb96..91ce9182cd 100644 --- a/engines/scumm/he/wiz_he.cpp +++ b/engines/scumm/he/wiz_he.cpp @@ -369,6 +369,7 @@ void Wiz::writeColor(uint8 *dstPtr, int dstType, uint16 color) { } } +#ifdef USE_RGB_COLOR void Wiz::copy16BitWizImage(uint8 *dst, const uint8 *src, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *xmapPtr) { Common::Rect r1, r2; if (calcClipRects(dstw, dsth, srcx, srcy, srcw, srch, rect, r1, r2)) { @@ -388,6 +389,7 @@ void Wiz::copy16BitWizImage(uint8 *dst, const uint8 *src, int dstPitch, int dstT } } } +#endif void Wiz::copyWizImage(uint8 *dst, const uint8 *src, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *palPtr, const uint8 *xmapPtr, uint8 bitDepth) { Common::Rect r1, r2; @@ -445,6 +447,7 @@ static void decodeWizMask(uint8 *&dst, uint8 &mask, int w, int maskType) { } } +#ifdef USE_RGB_COLOR void Wiz::copyMaskWizImage(uint8 *dst, const uint8 *src, const uint8 *mask, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *palPtr) { Common::Rect srcRect, dstRect; if (!calcClipRects(dstw, dsth, srcx, srcy, srcw, srch, rect, srcRect, dstRect)) { @@ -531,6 +534,7 @@ void Wiz::copyMaskWizImage(uint8 *dst, const uint8 *src, const uint8 *mask, int maskPtr = maskPtrNext; } } +#endif void Wiz::copyWizImageWithMask(uint8 *dst, const uint8 *src, int dstPitch, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int maskT, int maskP) { Common::Rect srcRect, dstRect; @@ -621,7 +625,8 @@ void Wiz::copyWizImageWithMask(uint8 *dst, const uint8 *src, int dstPitch, int d } } -void Wiz::copyRawWizImage(uint8 *dst, const uint8 *src, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *palPtr, int transColor, uint8 bitDepth) { +#ifdef USE_RGB_COLOR +void Wiz::copyRaw16BitWizImage(uint8 *dst, const uint8 *src, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, int transColor) { Common::Rect r1, r2; if (calcClipRects(dstw, dsth, srcx, srcy, srcw, srch, rect, r1, r2)) { if (flags & kWIFFlipX) { @@ -638,17 +643,23 @@ void Wiz::copyRawWizImage(uint8 *dst, const uint8 *src, int dstPitch, int dstTyp } int h = r1.height(); int w = r1.width(); - src += r1.top * srcw + r1.left; - dst += r2.top * dstPitch + r2.left * bitDepth; - if (palPtr) { - decompressRawWizImage(dst, dstPitch, dstType, src, srcw, w, h, transColor, palPtr, bitDepth); - } else { - decompressRawWizImage(dst, dstPitch, dstType, src, srcw, w, h, transColor, NULL, bitDepth); + src += (r1.top * srcw + r1.left) * 2; + dst += r2.top * dstPitch + r2.left * 2; + while (h--) { + for (int i = 0; i < w; ++ i) { + uint16 col = READ_LE_UINT16(src + 2 * i); + if (transColor == -1 || transColor != col) { + writeColor(dst + i * 2, dstType, col); + } + } + src += srcw * 2; + dst += dstPitch; } } } +#endif -void Wiz::copyRaw16BitWizImage(uint8 *dst, const uint8 *src, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, int transColor) { +void Wiz::copyRawWizImage(uint8 *dst, const uint8 *src, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *palPtr, int transColor, uint8 bitDepth) { Common::Rect r1, r2; if (calcClipRects(dstw, dsth, srcx, srcy, srcw, srch, rect, r1, r2)) { if (flags & kWIFFlipX) { @@ -665,21 +676,17 @@ void Wiz::copyRaw16BitWizImage(uint8 *dst, const uint8 *src, int dstPitch, int d } int h = r1.height(); int w = r1.width(); - src += (r1.top * srcw + r1.left) * 2; - dst += r2.top * dstPitch + r2.left * 2; - while (h--) { - for (int i = 0; i < w; ++ i) { - uint16 col = READ_LE_UINT16(src + 2 * i); - if (transColor == -1 || transColor != col) { - writeColor(dst + i * 2, dstType, col); - } - } - src += srcw * 2; - dst += dstPitch; + src += r1.top * srcw + r1.left; + dst += r2.top * dstPitch + r2.left * bitDepth; + if (palPtr) { + decompressRawWizImage(dst, dstPitch, dstType, src, srcw, w, h, transColor, palPtr, bitDepth); + } else { + decompressRawWizImage(dst, dstPitch, dstType, src, srcw, w, h, transColor, NULL, bitDepth); } } } +#ifdef USE_RGB_COLOR template void Wiz::write16BitColor(uint8 *dstPtr, const uint8 *dataPtr, int dstType, const uint8 *xmapPtr) { uint16 col = READ_LE_UINT16(dataPtr); @@ -795,6 +802,7 @@ void Wiz::decompress16BitWizImage(uint8 *dst, int dstPitch, int dstType, const u dstPtr = dstPtrNext; } } +#endif template void Wiz::write8BitColor(uint8 *dstPtr, const uint8 *dataPtr, int dstType, const uint8 *palPtr, const uint8 *xmapPtr, uint8 bitDepth) { @@ -1149,6 +1157,7 @@ void Wiz::computeRawWizHistogram(uint32 *histogram, const uint8 *data, int srcPi } } +#ifdef USE_RGB_COLOR static int wizPackType2(uint8 *dst, const uint8 *src, int srcPitch, const Common::Rect& rCapt) { debug(9, "wizPackType2([%d,%d,%d,%d])", rCapt.left, rCapt.top, rCapt.right, rCapt.bottom); int w = rCapt.width(); @@ -1165,6 +1174,7 @@ static int wizPackType2(uint8 *dst, const uint8 *src, int srcPitch, const Common } return size; } +#endif static int wizPackType1(uint8 *dst, const uint8 *src, int srcPitch, const Common::Rect& rCapt, uint8 transColor) { debug(9, "wizPackType1(%d, [%d,%d,%d,%d])", transColor, rCapt.left, rCapt.top, rCapt.right, rCapt.bottom); @@ -1341,9 +1351,11 @@ void Wiz::captureImage(uint8 *src, int srcPitch, int srcw, int srch, int resNum, case 1: dataSize = wizPackType1(0, src, srcPitch, rCapt, transColor); break; +#ifdef USE_RGB_COLOR case 2: dataSize = wizPackType2(0, src, srcPitch, rCapt); break; +#endif default: error("unhandled compression type %d", compType); break; @@ -1387,9 +1399,11 @@ void Wiz::captureImage(uint8 *src, int srcPitch, int srcw, int srch, int resNum, case 1: wizPackType1(wizImg + headerSize, src, srcPitch, rCapt, transColor); break; +#ifdef USE_RGB_COLOR case 2: wizPackType2(wizImg + headerSize, src, srcPitch, rCapt); break; +#endif default: break; } @@ -1566,6 +1580,7 @@ uint8 *Wiz::drawWizImage(int resNum, int state, int maskNum, int maskState, int copyWizImage(dst, wizd, dstPitch, dstType, cw, ch, x1, y1, width, height, &rScreen, flags, palPtr, xmapPtr, _vm->_bitDepth); } break; +#ifdef USE_RGB_COLOR case 2: if (maskNum) { copyMaskWizImage(dst, wizd, mask, dstPitch, dstType, cw, ch, x1, y1, width, height, &rScreen, flags, palPtr); @@ -1579,6 +1594,7 @@ uint8 *Wiz::drawWizImage(int resNum, int state, int maskNum, int maskState, int case 5: copy16BitWizImage(dst, wizd, dstPitch, dstType, cw, ch, x1, y1, width, height, &rScreen, flags, xmapPtr); break; +#endif default: error("drawWizImage: Unhandled wiz compression type %d", comp); } @@ -2582,6 +2598,7 @@ int Wiz::isWizPixelNonTransparent(int resNum, int state, int x, int y, int flags case 1: ret = isWizPixelNonTransparent(wizd, x, y, w, h, 1); break; +#ifdef USE_RGB_COLOR case 2: ret = getRawWizPixelColor(wizd, x, y, w, h, 2, _vm->VAR(_vm->VAR_WIZ_TCOLOR)) != _vm->VAR(_vm->VAR_WIZ_TCOLOR) ? 1 : 0; break; @@ -2593,6 +2610,7 @@ int Wiz::isWizPixelNonTransparent(int resNum, int state, int x, int y, int flags case 5: ret = isWizPixelNonTransparent(wizd, x, y, w, h, 2); break; +#endif default: error("isWizPixelNonTransparent: Unhandled wiz compression type %d", c); break; @@ -2623,6 +2641,7 @@ uint16 Wiz::getWizPixelColor(int resNum, int state, int x, int y) { case 1: color = getWizPixelColor(wizd, x, y, w, h, 1, _vm->VAR(_vm->VAR_WIZ_TCOLOR)); break; +#ifdef USE_RGB_COLOR case 2: color = getRawWizPixelColor(wizd, x, y, w, h, 2, _vm->VAR(_vm->VAR_WIZ_TCOLOR)); break; @@ -2633,6 +2652,7 @@ uint16 Wiz::getWizPixelColor(int resNum, int state, int x, int y) { case 5: color = getWizPixelColor(wizd, x, y, w, h, 2, _vm->VAR(_vm->VAR_WIZ_TCOLOR)); break; +#endif default: error("getWizPixelColor: Unhandled wiz compression type %d", c); break; diff --git a/engines/scumm/he/wiz_he.h b/engines/scumm/he/wiz_he.h index d8f984f710..a212ac4d29 100644 --- a/engines/scumm/he/wiz_he.h +++ b/engines/scumm/he/wiz_he.h @@ -209,19 +209,25 @@ public: void drawWizPolygonTransform(int resNum, int state, Common::Point *wp, int flags, int shadow, int dstResNum, int palette); void drawWizPolygonImage(uint8 *dst, const uint8 *src, const uint8 *mask, int dstpitch, int dstType, int dstw, int dsth, int wizW, int wizH, Common::Rect &bound, Common::Point *wp, uint8 bitDepth); +#ifdef USE_RGB_COLOR static void copyMaskWizImage(uint8 *dst, const uint8 *src, const uint8 *mask, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *palPtr); +#endif static void copyAuxImage(uint8 *dst1, uint8 *dst2, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, uint8 bitdepth); static void copyWizImageWithMask(uint8 *dst, const uint8 *src, int dstPitch, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int maskT, int maskP); static void copyWizImage(uint8 *dst, const uint8 *src, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *palPtr, const uint8 *xmapPtr, uint8 bitdepth); static void copyRawWizImage(uint8 *dst, const uint8 *src, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *palPtr, int transColor, uint8 bitdepth); +#ifdef USE_RGB_COLOR static void copy16BitWizImage(uint8 *dst, const uint8 *src, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *xmapPtr); static void copyRaw16BitWizImage(uint8 *dst, const uint8 *src, int dstPitch, int dstType, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, int transColor); template static void decompress16BitWizImage(uint8 *dst, int dstPitch, int dstType, const uint8 *src, const Common::Rect &srcRect, int flags, const uint8 *xmapPtr = NULL); +#endif template static void decompressWizImage(uint8 *dst, int dstPitch, int dstType, const uint8 *src, const Common::Rect &srcRect, int flags, const uint8 *palPtr, const uint8 *xmapPtr, uint8 bitdepth); template static void decompressRawWizImage(uint8 *dst, int dstPitch, int dstType, const uint8 *src, int srcPitch, int w, int h, int transColor, const uint8 *palPtr, uint8 bitdepth); +#ifdef USE_RGB_COLOR template static void write16BitColor(uint8 *dst, const uint8 *src, int dstType, const uint8 *xmapPtr); +#endif template static void write8BitColor(uint8 *dst, const uint8 *src, int dstType, const uint8 *palPtr, const uint8 *xmapPtr, uint8 bitDepth); static void writeColor(uint8 *dstPtr, int dstType, uint16 color); -- cgit v1.2.3 From 66d8adef9f875be8fc82e2fd305cbadc22ed02a6 Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Sat, 22 Aug 2009 07:18:15 +0000 Subject: Backyard Soccer MLS requires 16bit color support too. svn-id: r43630 --- engines/scumm/detection_tables.h | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/detection_tables.h b/engines/scumm/detection_tables.h index c9af022af5..e81779bdd3 100644 --- a/engines/scumm/detection_tables.h +++ b/engines/scumm/detection_tables.h @@ -91,6 +91,7 @@ static const PlainGameDescriptor gameDescriptions[] = { { "pjgames", "Pajama Sam: Games to Play On Any Day" }, { "readtime", "Blue's Reading Time Activities" }, { "Soccer2004", "Backyard Soccer 2004" }, + { "SoccerMLS", "Backyard Soccer MLS Edition" }, #endif { "airport", "Let's Explore the Airport with Buzzy" }, { "balloon", "Putt-Putt and Pep's Balloon-O-Rama" }, @@ -123,7 +124,6 @@ static const PlainGameDescriptor gameDescriptions[] = { { "puttzoo", "Putt-Putt Saves the Zoo" }, { "SamsFunShop", "Pajama Sam's One-Stop Fun Shop" }, { "soccer", "Backyard Soccer" }, - { "SoccerMLS", "Backyard Soccer MLS Edition" }, { "socks", "Pajama Sam's Sock Works" }, { "spyfox", "SPY Fox 1: Dry Cereal" }, { "spyfox2", "SPY Fox 2: Some Assembly Required" }, @@ -345,8 +345,14 @@ static const GameSettings gameVariantsTable[] = { {"SamsFunShop", 0, 0, GID_FUNSHOP, 6, 99, MDT_NONE, GF_USE_KEY | GF_HE_LOCALIZED, UNK, GUIO_NOMIDI}, {"PuttsFunShop", 0, 0, GID_FUNSHOP, 6, 99, MDT_NONE, GF_USE_KEY | GF_HE_LOCALIZED, UNK, GUIO_NOMIDI}, + // Added the use of smacker videos + {"BluesTreasureHunt", 0, 0, GID_TREASUREHUNT, 6, 99, MDT_NONE, GF_HE_LOCALIZED | GF_USE_KEY, UNK, GUIO_NOMIDI}, + +#ifdef USE_RGB_COLOR // Added 16bit color + {"arttime", 0, 0, GID_HEGAME, 6, 99, MDT_NONE, GF_USE_KEY | GF_HE_LOCALIZED | GF_16BIT_COLOR, UNK, GUIO_NOMIDI}, {"baseball2001", 0, 0, GID_HEGAME, 6, 99, MDT_NONE, GF_USE_KEY | GF_16BIT_COLOR, UNK, GUIO_NOMIDI}, + {"readtime", 0, 0, GID_HEGAME, 6, 99, MDT_NONE, GF_USE_KEY | GF_HE_LOCALIZED | GF_16BIT_COLOR, UNK, GUIO_NOMIDI}, {"SoccerMLS", 0, 0, GID_SOCCER, 6, 99, MDT_NONE, GF_USE_KEY | GF_HE_LOCALIZED | GF_16BIT_COLOR, UNK, GUIO_NOMIDI}, {"spyozon", 0, 0, GID_HEGAME, 6, 99, MDT_NONE, GF_USE_KEY | GF_HE_LOCALIZED | GF_16BIT_COLOR, UNK, GUIO_NOMIDI}, @@ -357,12 +363,7 @@ static const GameSettings gameVariantsTable[] = { // Restructured the Scumm engine {"pjgames", 0, 0, GID_HEGAME, 6, 100, MDT_NONE, GF_USE_KEY | GF_HE_LOCALIZED | GF_16BIT_COLOR, UNK, GUIO_NOMIDI}, - // Uses smacker in external files, for testing only - {"arttime", 0, 0, GID_HEGAME, 6, 99, MDT_NONE, GF_USE_KEY | GF_HE_LOCALIZED | GF_16BIT_COLOR, UNK, GUIO_NOMIDI}, - {"readtime", 0, 0, GID_HEGAME, 6, 99, MDT_NONE, GF_USE_KEY | GF_HE_LOCALIZED | GF_16BIT_COLOR, UNK, GUIO_NOMIDI}, - {"BluesTreasureHunt", 0, 0, GID_TREASUREHUNT, 6, 99, MDT_NONE, GF_HE_LOCALIZED | GF_USE_KEY, UNK, GUIO_NOMIDI}, - - // Uses bink in external files for logos + // Added the use of bink videos {"Baseball2003", 0, 0, GID_HEGAME, 6, 100, MDT_NONE, GF_USE_KEY | GF_16BIT_COLOR, UNK, GUIO_NOMIDI}, {"basketball", 0, 0, GID_BASKETBALL, 6, 100, MDT_NONE, GF_USE_KEY| GF_16BIT_COLOR, UNK, GUIO_NOMIDI}, {"football2002", 0, 0, GID_FOOTBALL, 6, 100, MDT_NONE, GF_USE_KEY | GF_16BIT_COLOR, UNK, GUIO_NOMIDI}, @@ -371,6 +372,7 @@ static const GameSettings gameVariantsTable[] = { // U32 code required, for testing only {"moonbase", 0, 0, GID_MOONBASE, 6, 100, MDT_NONE, GF_USE_KEY | GF_16BIT_COLOR, UNK, GUIO_NOMIDI}, {"moonbase", "Demo", 0, GID_MOONBASE, 6, 100, MDT_NONE, GF_USE_KEY | GF_16BIT_COLOR | GF_DEMO, UNK, GUIO_NOMIDI}, +#endif // The following are meant to be generic HE game variants and as such do // not specify a game ID. Make sure that these are last in the table, else @@ -549,6 +551,9 @@ static const GameFilenamePattern gameFilenamesTable[] = { { "Soccer2004", "Soccer2004", kGenHEPC, UNK_LANG, UNK, 0 }, { "Soccer2004", "Soccer 2004", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, + { "SoccerMLS", "SoccerMLS", kGenHEPC, UNK_LANG, UNK, 0 }, + { "SoccerMLS", "Backyard Soccer MLS", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, + { "spyozon", "spyozon", kGenHEPC, UNK_LANG, UNK, 0 }, { "spyozon", "sf3-demo", kGenHEPC, UNK_LANG, UNK, 0 }, { "spyozon", "SF3Demo", kGenHEPC, Common::FR_FRA, UNK, 0 }, @@ -817,9 +822,6 @@ static const GameFilenamePattern gameFilenamesTable[] = { { "soccer", "soccer", kGenHEPC, UNK_LANG, UNK, 0 }, { "soccer", "Soccer", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, - { "SoccerMLS", "SoccerMLS", kGenHEPC, UNK_LANG, UNK, 0 }, - { "SoccerMLS", "Backyard Soccer MLS", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, - { "socks", "socks", kGenHEPC, UNK_LANG, UNK, 0 }, { "socks", "SockWorks", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, { "socks", "SokkenSoep", kGenHEPC, Common::NL_NLD, UNK, 0 }, -- cgit v1.2.3 From 6c6ae69f3dab59fc8be948463367c615f9acd7e2 Mon Sep 17 00:00:00 2001 From: Andre Heider Date: Sat, 22 Aug 2009 09:22:23 +0000 Subject: Fixed cursor transparency for 16bit HE games on big endian architectures svn-id: r43632 --- engines/scumm/he/wiz_he.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp index 91ce9182cd..5280dc097f 100644 --- a/engines/scumm/he/wiz_he.cpp +++ b/engines/scumm/he/wiz_he.cpp @@ -1504,7 +1504,7 @@ uint8 *Wiz::drawWizImage(int resNum, int state, int maskNum, int maskState, int uint8 *tmpPtr = dst; for (uint i = 0; i < height; i++) { for (uint j = 0; j < width; j++) - WRITE_LE_UINT16(tmpPtr + j * 2, transColor); + WRITE_UINT16(tmpPtr + j * 2, transColor); tmpPtr += width * 2; } } else { @@ -1750,7 +1750,7 @@ void Wiz::captureWizPolygon(int resNum, int maskNum, int maskState, int id1, int uint8 *tmpPtr = imageBuffer; for (i = 0; i < dsth; i++) { for (j = 0; j < dstw; j++) - WRITE_LE_UINT16(tmpPtr + j * 2, transColor); + WRITE_UINT16(tmpPtr + j * 2, transColor); tmpPtr += dstpitch; } } else { @@ -1967,7 +1967,7 @@ void Wiz::drawWizPolygonImage(uint8 *dst, const uint8 *src, const uint8 *mask, i y_acc += pra->y_step; if (bitDepth == 2) { if (transColor == -1 || transColor != READ_LE_UINT16(src + src_offs * 2)) { - //if (transColor == -1 || READ_LE_UINT16(dstPtr) != transColor) + //if (transColor == -1 || READ_UINT16(dstPtr) != transColor) writeColor(dstPtr, dstType, READ_LE_UINT16(src + src_offs * 2)); } } else { -- cgit v1.2.3 From bed502a7c70c122a097d8f9ad7ca2330e69bdccb Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Sat, 22 Aug 2009 09:39:55 +0000 Subject: Fix endian issue in copyFrameToBuffer(). svn-id: r43633 --- engines/scumm/he/animation_he.cpp | 21 +++++++++++++++------ engines/scumm/he/animation_he.h | 2 +- 2 files changed, 16 insertions(+), 7 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/he/animation_he.cpp b/engines/scumm/he/animation_he.cpp index 47b25c57d1..cf071fc4aa 100644 --- a/engines/scumm/he/animation_he.cpp +++ b/engines/scumm/he/animation_he.cpp @@ -66,7 +66,7 @@ int MoviePlayer::load(const char *filename, int flags, int image) { return 0; } -void MoviePlayer::copyFrameToBuffer(byte *dst, uint x, uint y, uint pitch) { +void MoviePlayer::copyFrameToBuffer(byte *dst, int dstType, uint x, uint y, uint pitch) { uint h = getHeight(); uint w = getWidth(); @@ -76,8 +76,17 @@ void MoviePlayer::copyFrameToBuffer(byte *dst, uint x, uint y, uint pitch) { dst += y * pitch + x * 2; do { for (uint i = 0; i < w; i++) { - uint16 col = READ_LE_UINT16(_vm->_hePalettes + _vm->_hePaletteSlot + 768 + src[i] * 2); - WRITE_UINT16(dst + i * 2, col); + uint16 color = READ_LE_UINT16(_vm->_hePalettes + _vm->_hePaletteSlot + 768 + src[i] * 2); + switch (dstType) { + case kDstScreen: + WRITE_UINT16(dst + i * 2, color); + break; + case kDstResource: + WRITE_LE_UINT16(dst + i * 2, color); + break; + default: + error("copyFrameToBuffer: Unknown dstType %d", dstType); + } } dst += pitch; src += w; @@ -106,14 +115,14 @@ void MoviePlayer::handleNextFrame() { assert(dstPtr); uint8 *dst = _vm->findWrappedBlock(MKID_BE('WIZD'), dstPtr, 0, 0); assert(dst); - copyFrameToBuffer(dst, 0, 0, _vm->_screenWidth * _vm->_bitDepth); + copyFrameToBuffer(dst, kDstResource, 0, 0, _vm->_screenWidth * _vm->_bitDepth); } else if (_flags & 1) { - copyFrameToBuffer(pvs->getBackPixels(0, 0), 0, 0, pvs->pitch); + copyFrameToBuffer(pvs->getBackPixels(0, 0), kDstScreen, 0, 0, pvs->pitch); Common::Rect imageRect(getWidth(), getHeight()); _vm->restoreBackgroundHE(imageRect); } else { - copyFrameToBuffer(pvs->getPixels(0, 0), 0, 0, pvs->pitch); + copyFrameToBuffer(pvs->getPixels(0, 0), kDstScreen, 0, 0, pvs->pitch); Common::Rect imageRect(getWidth(), getHeight()); _vm->markRectAsDirty(kMainVirtScreen, imageRect); diff --git a/engines/scumm/he/animation_he.h b/engines/scumm/he/animation_he.h index 0adba35d53..86ded31940 100644 --- a/engines/scumm/he/animation_he.h +++ b/engines/scumm/he/animation_he.h @@ -54,7 +54,7 @@ public: int getImageNum(); int load(const char *filename, int flags, int image = 0); - void copyFrameToBuffer(byte *dst, uint x, uint y, uint pitch); + void copyFrameToBuffer(byte *dst, int dstType, uint x, uint y, uint pitch); void handleNextFrame(); protected: -- cgit v1.2.3 From 811cea60e76f39434e00c07d5b02ed920c16c191 Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Sat, 22 Aug 2009 13:14:46 +0000 Subject: Correct game title. svn-id: r43645 --- engines/scumm/detection_tables.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/scumm') diff --git a/engines/scumm/detection_tables.h b/engines/scumm/detection_tables.h index e81779bdd3..57fe251e05 100644 --- a/engines/scumm/detection_tables.h +++ b/engines/scumm/detection_tables.h @@ -88,7 +88,7 @@ static const PlainGameDescriptor gameDescriptions[] = { { "football2002", "Backyard Football 2002" }, { "freddicove", "Freddi Fish 5: The Case of the Creature of Coral Cave" }, { "moonbase", "Moonbase Commander" }, - { "pjgames", "Pajama Sam: Games to Play On Any Day" }, + { "pjgames", "Pajama Sam: Games to Play on Any Day" }, { "readtime", "Blue's Reading Time Activities" }, { "Soccer2004", "Backyard Soccer 2004" }, { "SoccerMLS", "Backyard Soccer MLS Edition" }, -- cgit v1.2.3 From ee0e1bfceac7eb626737f321e851ef0cdcea08d3 Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Sat, 22 Aug 2009 13:32:56 +0000 Subject: Fix endian regression, when clearing the buffer of non-cursor images. svn-id: r43649 --- engines/scumm/he/wiz_he.cpp | 15 +++++++++++---- engines/scumm/he/wiz_he.h | 1 + 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp index 5280dc097f..9ddc1ea22f 100644 --- a/engines/scumm/he/wiz_he.cpp +++ b/engines/scumm/he/wiz_he.cpp @@ -40,6 +40,7 @@ Wiz::Wiz(ScummEngine_v71he *vm) : _vm(vm) { _imagesNum = 0; memset(&_images, 0, sizeof(_images)); memset(&_polygons, 0, sizeof(_polygons)); + _cursorImage = false; _rectOverrideEnabled = false; } @@ -1503,8 +1504,13 @@ uint8 *Wiz::drawWizImage(int resNum, int state, int maskNum, int maskState, int if (_vm->_bitDepth == 2) { uint8 *tmpPtr = dst; for (uint i = 0; i < height; i++) { - for (uint j = 0; j < width; j++) - WRITE_UINT16(tmpPtr + j * 2, transColor); + for (uint j = 0; j < width; j++) { + if (_cursorImage) { + WRITE_UINT16(tmpPtr + j * 2, transColor); + } else { + WRITE_LE_UINT16(tmpPtr + j * 2, transColor); + } + } tmpPtr += width * 2; } } else { @@ -1967,8 +1973,7 @@ void Wiz::drawWizPolygonImage(uint8 *dst, const uint8 *src, const uint8 *mask, i y_acc += pra->y_step; if (bitDepth == 2) { if (transColor == -1 || transColor != READ_LE_UINT16(src + src_offs * 2)) { - //if (transColor == -1 || READ_UINT16(dstPtr) != transColor) - writeColor(dstPtr, dstType, READ_LE_UINT16(src + src_offs * 2)); + writeColor(dstPtr, dstType, READ_LE_UINT16(src + src_offs * 2)); } } else { if (transColor == -1 || transColor != src[src_offs]) @@ -2012,7 +2017,9 @@ void Wiz::loadWizCursor(int resId, int palette) { } const Common::Rect *r = NULL; + _cursorImage = true; uint8 *cursor = drawWizImage(resId, 0, 0, 0, 0, 0, 0, 0, 0, r, kWIFBlitToMemBuffer, 0, _vm->getHEPaletteSlot(palette)); + _cursorImage = false; int32 cw, ch; getWizImageDim(resId, 0, cw, ch); diff --git a/engines/scumm/he/wiz_he.h b/engines/scumm/he/wiz_he.h index a212ac4d29..1fa9564486 100644 --- a/engines/scumm/he/wiz_he.h +++ b/engines/scumm/he/wiz_he.h @@ -165,6 +165,7 @@ public: void clearWizBuffer(); Common::Rect _rectOverride; + bool _cursorImage; bool _rectOverrideEnabled; void polygonClear(); -- cgit v1.2.3 From 4ff0c2619b87658c762eac19afe85ac01530c5c1 Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Sun, 23 Aug 2009 14:51:04 +0000 Subject: Fix Moonbase Commander startup. svn-id: r43670 --- engines/scumm/he/script_v100he.cpp | 1 + engines/scumm/he/script_v72he.cpp | 12 ++++++------ engines/scumm/vars.cpp | 1 + 3 files changed, 8 insertions(+), 6 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/he/script_v100he.cpp b/engines/scumm/he/script_v100he.cpp index 49e490a8ec..29f611a58f 100644 --- a/engines/scumm/he/script_v100he.cpp +++ b/engines/scumm/he/script_v100he.cpp @@ -629,6 +629,7 @@ void ScummEngine_v100he::o100_arrayOps() { } break; case 132: + debug(0, "o100_arrayOps: case 132"); // TODO: Used by Moonbase Commander fetchScriptWord(); fetchScriptWord(); diff --git a/engines/scumm/he/script_v72he.cpp b/engines/scumm/he/script_v72he.cpp index 0c2c01d419..3dd70a09c9 100644 --- a/engines/scumm/he/script_v72he.cpp +++ b/engines/scumm/he/script_v72he.cpp @@ -1398,11 +1398,6 @@ void ScummEngine_v72he::o72_openFile() { copyScriptString(buffer, sizeof(buffer)); debug(1, "Original filename %s", buffer); - // HACK: INI filename seems to get reset, corruption elsewhere? - if (_game.id == GID_MOONBASE && buffer[0] == 0) { - strcpy((char *)buffer, "moonbase.ini"); - } - const char *filename = (char *)buffer + convertFilePath(buffer, sizeof(buffer)); debug(1, "Final filename to %s", filename); @@ -1823,7 +1818,12 @@ void ScummEngine_v72he::o72_readINI() { case 77: // HE 100 case 7: // string writeVar(0, 0); - if (!strcmp((char *)option, "SaveGamePath")) { + if (!strcmp((char *)option, "HE3File")) { + Common::String fileName = generateFilename(-3); + int len = resStrLen((const byte *)fileName.c_str()); + data = defineArray(0, kStringArray, 0, 0, 0, len); + memcpy(data, fileName.c_str(), len); + } else if (!strcmp((char *)option, "SaveGamePath")) { // We set SaveGamePath in order to detect where it used // in convertFilePath and to avoid warning about invalid // path in Macintosh verisons. diff --git a/engines/scumm/vars.cpp b/engines/scumm/vars.cpp index 98e088365e..69da7f3e09 100644 --- a/engines/scumm/vars.cpp +++ b/engines/scumm/vars.cpp @@ -312,6 +312,7 @@ void ScummEngine_v80he::setupScummVars() { void ScummEngine_v90he::setupScummVars() { ScummEngine_v80he::setupScummVars(); + VAR_TIMER = 97; VAR_SCRIPT_CYCLE = 103; VAR_NUM_SCRIPT_CYCLES = 104; -- cgit v1.2.3 From cba88415bbd3fbb6d66e54b36379a38a7c4f3eea Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Mon, 24 Aug 2009 10:06:38 +0000 Subject: Fix bug #2843387 - PUTTPUTT/FATTYBEAR: Macintosh versions assert on startup. svn-id: r43687 --- engines/scumm/he/script_v60he.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'engines/scumm') diff --git a/engines/scumm/he/script_v60he.cpp b/engines/scumm/he/script_v60he.cpp index 92848ce981..4c01d3b15c 100644 --- a/engines/scumm/he/script_v60he.cpp +++ b/engines/scumm/he/script_v60he.cpp @@ -98,6 +98,13 @@ int ScummEngine_v60he::convertFilePath(byte *dst, int dstSize) { int len = resStrLen(dst); if (_game.platform == Common::kPlatformMacintosh) { + // Remove : prefix in HE71 games + if (dst[0] == ':') { + len -= 1; + memmove(dst, dst + 1, len); + dst[len] = 0; + } + // Switch all : to / for portablity for (int i = 0; i < len; i++) { if (dst[i] == ':') -- cgit v1.2.3 From 184aae3c8c863541771fbeb09ce5f1a72ecabb95 Mon Sep 17 00:00:00 2001 From: Norbert Lange Date: Mon, 24 Aug 2009 12:39:03 +0000 Subject: Enable alternative palettse for Amiga Monkey Island - Patch ID: 2819787 use tables for palette colors instead of code with constants svn-id: r43696 --- engines/scumm/palette.cpp | 320 ++++++++++++++++++---------------------------- engines/scumm/scumm.cpp | 4 +- engines/scumm/scumm.h | 9 +- 3 files changed, 130 insertions(+), 203 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/palette.cpp b/engines/scumm/palette.cpp index a596cc5b1a..2fe3f34530 100644 --- a/engines/scumm/palette.cpp +++ b/engines/scumm/palette.cpp @@ -55,230 +55,155 @@ uint16 ScummEngine::get16BitColor(uint8 r, uint8 g, uint8 b) { } void ScummEngine::resetPalette() { + static const byte tableC64Palette[] = { + 0x00, 0x00, 0x00, 0xFD, 0xFE, 0xFC, 0xBE, 0x1A, 0x24, 0x30, 0xE6, 0xC6, + 0xB4, 0x1A, 0xE2, 0x1F, 0xD2, 0x1E, 0x21, 0x1B, 0xAE, 0xDF, 0xF6, 0x0A, + 0xB8, 0x41, 0x04, 0x6A, 0x33, 0x04, 0xFE, 0x4A, 0x57, 0x42, 0x45, 0x40, + 0x70, 0x74, 0x6F, 0x59, 0xFE, 0x59, 0x5F, 0x53, 0xFE, 0xA4, 0xA7, 0xA2, + + // Use 17 color table for v1 games to allow correct color for inventory and + // sentence line. Original games used some kind of dynamic color table + // remapping between rooms. + 0xFF, 0x55, 0xFF + }; + + static const byte tableNESPalette[] = { + /* 0x1D */ + 0x00, 0x00, 0x00, 0x00, 0x24, 0x92, 0x00, 0x00, 0xDB, 0x6D, 0x49, 0xDB, + 0x92, 0x00, 0x6D, 0xB6, 0x00, 0x6D, 0xB6, 0x24, 0x00, 0x92, 0x49, 0x00, + 0x6D, 0x49, 0x00, 0x24, 0x49, 0x00, 0x00, 0x6D, 0x24, 0x00, 0x92, 0x00, + 0x00, 0x49, 0x49, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + + 0xB6, 0xB6, 0xB6, 0x00, 0x6D, 0xDB, 0x00, 0x49, 0xFF, 0x92, 0x00, 0xFF, + 0xB6, 0x00, 0xFF, 0xFF, 0x00, 0x92, 0xFF, 0x00, 0x00, 0xDB, 0x6D, 0x00, + 0x92, 0x6D, 0x00, 0x24, 0x92, 0x00, 0x00, 0x92, 0x00, 0x00, 0xB6, 0x6D, + /* 0x00 */ + 0x00, 0x92, 0x92, 0x6D, 0x6D, 0x6D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + + 0xFF, 0xFF, 0xFF, 0x6D, 0xB6, 0xFF, 0x92, 0x92, 0xFF, 0xDB, 0x6D, 0xFF, + 0xFF, 0x00, 0xFF, 0xFF, 0x6D, 0xFF, 0xFF, 0x92, 0x00, 0xFF, 0xB6, 0x00, + 0xDB, 0xDB, 0x00, 0x6D, 0xDB, 0x00, 0x00, 0xFF, 0x00, 0x49, 0xFF, 0xDB, + 0x00, 0xFF, 0xFF, 0x49, 0x49, 0x49, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + + 0xFF, 0xFF, 0xFF, 0xB6, 0xDB, 0xFF, 0xDB, 0xB6, 0xFF, 0xFF, 0xB6, 0xFF, + 0xFF, 0x92, 0xFF, 0xFF, 0xB6, 0xB6, 0xFF, 0xDB, 0x92, 0xFF, 0xFF, 0x49, + 0xFF, 0xFF, 0x6D, 0xB6, 0xFF, 0x49, 0x92, 0xFF, 0x6D, 0x49, 0xFF, 0xDB, + 0x92, 0xDB, 0xFF, 0x92, 0x92, 0x92, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + + static const byte tableAmigaPalette[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0xBB, 0x00, 0xBB, 0x00, 0x00, 0xBB, 0xBB, + 0xBB, 0x00, 0x00, 0xBB, 0x00, 0xBB, 0xBB, 0x77, 0x00, 0xBB, 0xBB, 0xBB, + 0x77, 0x77, 0x77, 0x77, 0x77, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0xFF, + 0xFF, 0x88, 0x88, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF + }; + + static const byte tableAmigaMIPalette[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0xAA, 0x00, 0x88, 0x22, 0x00, 0x66, 0x77, + 0xBB, 0x66, 0x66, 0xAA, 0x22, 0xAA, 0x88, 0x55, 0x22, 0x77, 0x77, 0x77, + 0x33, 0x33, 0x33, 0x22, 0x55, 0xDD, 0x22, 0xDD, 0x44, 0x00, 0xCC, 0xFF, + 0xFF, 0x99, 0x99, 0xFF, 0x55, 0xFF, 0xFF, 0xFF, 0x77, 0xFF, 0xFF, 0xFF + }; + + static const byte tableEGAPalette[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0xAA, 0x00, 0xAA, 0x00, 0x00, 0xAA, 0xAA, + 0xAA, 0x00, 0x00, 0xAA, 0x00, 0xAA, 0xAA, 0x55, 0x00, 0xAA, 0xAA, 0xAA, + 0x55, 0x55, 0x55, 0x55, 0x55, 0xFF, 0x55, 0xFF, 0x55, 0x55, 0xFF, 0xFF, + 0xFF, 0x55, 0x55, 0xFF, 0x55, 0xFF, 0xFF, 0xFF, 0x55, 0xFF, 0xFF, 0xFF + }; + + static const byte tableV1Palette[] = { + 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xAA, 0x00, 0x00, 0x00, 0xAA, 0xAA, + 0xAA, 0x00, 0xAA, 0x00, 0xAA, 0x00, 0x00, 0x00, 0xAA, 0xFF, 0xFF, 0x55, + 0xFF, 0x55, 0x55, 0xAA, 0x55, 0x00, 0xFF, 0x55, 0x55, 0x55, 0x55, 0x55, + 0xAA, 0xAA, 0xAA, 0x55, 0xFF, 0x55, 0x55, 0x55, 0xFF, 0x55, 0x55, 0x55, + + 0xFF, 0x55, 0xFF + }; + + static const byte tableCGAPalette[] = { + 0x00, 0x00, 0x00, 0x00, 0xA8, 0xA8, 0xA8, 0x00, 0xA8, 0xA8, 0xA8, 0xA8 + }; + + static const byte tableHercAPalette[] = { + 0x00, 0x00, 0x00, 0xAE, 0x69, 0x38 + }; + + static const byte tableHercGPalette[] = { + 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00 + }; + if (_game.version <= 1) { if (_game.platform == Common::kPlatformApple2GS) { // TODO: unique palette? - setC64Palette(); + setPaletteFromTable(tableC64Palette, sizeof(tableC64Palette) / 3); } else if (_game.platform == Common::kPlatformC64) { - setC64Palette(); + setPaletteFromTable(tableC64Palette, sizeof(tableC64Palette) / 3); } else if (_game.platform == Common::kPlatformNES) { - setNESPalette(); + setPaletteFromTable(tableNESPalette, sizeof(tableNESPalette) / 3); } else { - setV1Palette(); + setPaletteFromTable(tableV1Palette, sizeof(tableV1Palette) / 3); + if (_game.id == GID_ZAK) + setPalColor(15, 170, 170, 170); } } else if (_game.features & GF_16COLOR) { + bool setupCursor = false; + switch (_renderMode) { case Common::kRenderEGA: - setEGAPalette(); + setPaletteFromTable(tableEGAPalette, sizeof(tableEGAPalette) / 3); break; case Common::kRenderAmiga: - setAmigaPalette(); + setPaletteFromTable(tableAmigaPalette, sizeof(tableAmigaPalette) / 3); break; case Common::kRenderCGA: - setCGAPalette(); + setPaletteFromTable(tableCGAPalette, sizeof(tableCGAPalette) / 3); + setupCursor = true; break; case Common::kRenderHercA: + setPaletteFromTable(tableHercAPalette, sizeof(tableHercAPalette) / 3); + setupCursor = true; + break; + case Common::kRenderHercG: - setHercPalette(); + setPaletteFromTable(tableHercGPalette, sizeof(tableHercGPalette) / 3); + setupCursor = true; break; default: if ((_game.platform == Common::kPlatformAmiga) || (_game.platform == Common::kPlatformAtariST)) - setAmigaPalette(); + setPaletteFromTable(tableAmigaPalette, sizeof(tableAmigaPalette) / 3); else - setEGAPalette(); + setPaletteFromTable(tableEGAPalette, sizeof(tableEGAPalette) / 3); + } + if (setupCursor) { + // Setup cursor palette + setPalColor( 7, 170, 170, 170); + setPalColor( 8, 85, 85, 85); + setPalColor(15, 255, 255, 255); } - } else - setDirtyColors(0, 255); -} - -void ScummEngine::setC64Palette() { - setPalColor( 0, 0x00, 0x00, 0x00); - setPalColor( 1, 0xFD, 0xFE, 0xFC); - setPalColor( 2, 0xBE, 0x1A, 0x24); - setPalColor( 3, 0x30, 0xE6, 0xC6); - setPalColor( 4, 0xB4, 0x1A, 0xE2); - setPalColor( 5, 0x1F, 0xD2, 0x1E); - setPalColor( 6, 0x21, 0x1B, 0xAE); - setPalColor( 7, 0xDF, 0xF6, 0x0A); - setPalColor( 8, 0xB8, 0x41, 0x04); - setPalColor( 9, 0x6A, 0x33, 0x04); - setPalColor(10, 0xFE, 0x4A, 0x57); - setPalColor(11, 0x42, 0x45, 0x40); - setPalColor(12, 0x70, 0x74, 0x6F); - setPalColor(13, 0x59, 0xFE, 0x59); - setPalColor(14, 0x5F, 0x53, 0xFE); - setPalColor(15, 0xA4, 0xA7, 0xA2); - - // Use 17 color table for v1 games to allow correct color for inventory and - // sentence line. Original games used some kind of dynamic color table - // remapping between rooms. - setPalColor(16, 255, 85, 255); -} - -void ScummEngine::setNESPalette() { - setPalColor(0x00,0x00,0x00,0x00); // 0x1D - setPalColor(0x01,0x00,0x24,0x92); - setPalColor(0x02,0x00,0x00,0xDB); - setPalColor(0x03,0x6D,0x49,0xDB); - setPalColor(0x04,0x92,0x00,0x6D); - setPalColor(0x05,0xB6,0x00,0x6D); - setPalColor(0x06,0xB6,0x24,0x00); - setPalColor(0x07,0x92,0x49,0x00); - setPalColor(0x08,0x6D,0x49,0x00); - setPalColor(0x09,0x24,0x49,0x00); - setPalColor(0x0A,0x00,0x6D,0x24); - setPalColor(0x0B,0x00,0x92,0x00); - setPalColor(0x0C,0x00,0x49,0x49); - setPalColor(0x0D,0x00,0x00,0x00); - setPalColor(0x0E,0x00,0x00,0x00); - setPalColor(0x0F,0x00,0x00,0x00); - - setPalColor(0x10,0xB6,0xB6,0xB6); - setPalColor(0x11,0x00,0x6D,0xDB); - setPalColor(0x12,0x00,0x49,0xFF); - setPalColor(0x13,0x92,0x00,0xFF); - setPalColor(0x14,0xB6,0x00,0xFF); - setPalColor(0x15,0xFF,0x00,0x92); - setPalColor(0x16,0xFF,0x00,0x00); - setPalColor(0x17,0xDB,0x6D,0x00); - setPalColor(0x18,0x92,0x6D,0x00); - setPalColor(0x19,0x24,0x92,0x00); - setPalColor(0x1A,0x00,0x92,0x00); - setPalColor(0x1B,0x00,0xB6,0x6D); - setPalColor(0x1C,0x00,0x92,0x92); - setPalColor(0x1D,0x6D,0x6D,0x6D); // 0x00 - setPalColor(0x1E,0x00,0x00,0x00); - setPalColor(0x1F,0x00,0x00,0x00); - - setPalColor(0x20,0xFF,0xFF,0xFF); - setPalColor(0x21,0x6D,0xB6,0xFF); - setPalColor(0x22,0x92,0x92,0xFF); - setPalColor(0x23,0xDB,0x6D,0xFF); - setPalColor(0x24,0xFF,0x00,0xFF); - setPalColor(0x25,0xFF,0x6D,0xFF); - setPalColor(0x26,0xFF,0x92,0x00); - setPalColor(0x27,0xFF,0xB6,0x00); - setPalColor(0x28,0xDB,0xDB,0x00); - setPalColor(0x29,0x6D,0xDB,0x00); - setPalColor(0x2A,0x00,0xFF,0x00); - setPalColor(0x2B,0x49,0xFF,0xDB); - setPalColor(0x2C,0x00,0xFF,0xFF); - setPalColor(0x2D,0x49,0x49,0x49); - setPalColor(0x2E,0x00,0x00,0x00); - setPalColor(0x2F,0x00,0x00,0x00); - - setPalColor(0x30,0xFF,0xFF,0xFF); - setPalColor(0x31,0xB6,0xDB,0xFF); - setPalColor(0x32,0xDB,0xB6,0xFF); - setPalColor(0x33,0xFF,0xB6,0xFF); - setPalColor(0x34,0xFF,0x92,0xFF); - setPalColor(0x35,0xFF,0xB6,0xB6); - setPalColor(0x36,0xFF,0xDB,0x92); - setPalColor(0x37,0xFF,0xFF,0x49); - setPalColor(0x38,0xFF,0xFF,0x6D); - setPalColor(0x39,0xB6,0xFF,0x49); - setPalColor(0x3A,0x92,0xFF,0x6D); - setPalColor(0x3B,0x49,0xFF,0xDB); - setPalColor(0x3C,0x92,0xDB,0xFF); - setPalColor(0x3D,0x92,0x92,0x92); - setPalColor(0x3E,0x00,0x00,0x00); - setPalColor(0x3F,0x00,0x00,0x00); -} - -void ScummEngine::setAmigaPalette() { - setPalColor( 0, 0, 0, 0); - setPalColor( 1, 0, 0, 187); - setPalColor( 2, 0, 187, 0); - setPalColor( 3, 0, 187, 187); - setPalColor( 4, 187, 0, 0); - setPalColor( 5, 187, 0, 187); - setPalColor( 6, 187, 119, 0); - setPalColor( 7, 187, 187, 187); - setPalColor( 8, 119, 119, 119); - setPalColor( 9, 119, 119, 255); - setPalColor(10, 0, 255, 0); - setPalColor(11, 0, 255, 255); - setPalColor(12, 255, 136, 136); - setPalColor(13, 255, 0, 255); - setPalColor(14, 255, 255, 0); - setPalColor(15, 255, 255, 255); -} - -void ScummEngine::setHercPalette() { - setPalColor( 0, 0, 0, 0); - - if (_renderMode == Common::kRenderHercA) - setPalColor( 1, 0xAE, 0x69, 0x38); - else - setPalColor( 1, 0x00, 0xFF, 0x00); - - // Setup cursor palette - setPalColor( 7, 170, 170, 170); - setPalColor( 8, 85, 85, 85); - setPalColor(15, 255, 255, 255); -} - -void ScummEngine::setCGAPalette() { - setPalColor( 0, 0, 0, 0); - setPalColor( 1, 0, 168, 168); - setPalColor( 2, 168, 0, 168); - setPalColor( 3, 168, 168, 168); - - // Setup cursor palette - setPalColor( 7, 170, 170, 170); - setPalColor( 8, 85, 85, 85); - setPalColor(15, 255, 255, 255); -} -void ScummEngine::setEGAPalette() { - setPalColor( 0, 0, 0, 0); - setPalColor( 1, 0, 0, 170); - setPalColor( 2, 0, 170, 0); - setPalColor( 3, 0, 170, 170); - setPalColor( 4, 170, 0, 0); - setPalColor( 5, 170, 0, 170); - setPalColor( 6, 170, 85, 0); - setPalColor( 7, 170, 170, 170); - setPalColor( 8, 85, 85, 85); - setPalColor( 9, 85, 85, 255); - setPalColor(10, 85, 255, 85); - setPalColor(11, 85, 255, 255); - setPalColor(12, 255, 85, 85); - setPalColor(13, 255, 85, 255); - setPalColor(14, 255, 255, 85); - setPalColor(15, 255, 255, 255); + } else { + if ((_game.platform == Common::kPlatformAmiga) && _game.version == 4) { + // if rendermode is set to EGA we use the full palette from the resources + // else we initialise and then lock down the first 16 colors. + if (_renderMode != Common::kRenderEGA) + setPaletteFromTable(tableAmigaMIPalette, sizeof(tableAmigaMIPalette) / 3); + } + setDirtyColors(0, 255); + } } -void ScummEngine::setV1Palette() { - setPalColor( 0, 0, 0, 0); - setPalColor( 1, 255, 255, 255); - setPalColor( 2, 170, 0, 0); - setPalColor( 3, 0, 170, 170); - setPalColor( 4, 170, 0, 170); - setPalColor( 5, 0, 170, 0); - setPalColor( 6, 0, 0, 170); - setPalColor( 7, 255, 255, 85); - setPalColor( 8, 255, 85, 85); - setPalColor( 9, 170, 85, 0); - setPalColor(10, 255, 85, 85); - setPalColor(11, 85, 85, 85); - setPalColor(12, 170, 170, 170); - setPalColor(13, 85, 255, 85); - setPalColor(14, 85, 85, 255); - - if (_game.id == GID_ZAK) - setPalColor(15, 170, 170, 170); - else - setPalColor(15, 85, 85, 85); - - setPalColor(16, 255, 85, 255); +void ScummEngine::setPaletteFromTable(const byte *ptr, int numcolor, int index) { + for ( ; numcolor > 0; --numcolor, ++index, ptr += 3) + setPalColor( index, ptr[0], ptr[1], ptr[2]); } void ScummEngine::setPaletteFromPtr(const byte *ptr, int numcolor) { + int firstIndex = 0; int i; byte *dest, r, g, b; @@ -298,7 +223,14 @@ void ScummEngine::setPaletteFromPtr(const byte *ptr, int numcolor) { dest = _currentPalette; - for (i = 0; i < numcolor; i++) { + // Test for Amiga Monkey Island and EGA Mode unset, if true then skip the first 16 colors. + if ((_game.platform == Common::kPlatformAmiga) && _game.version == 4 && _renderMode != Common::kRenderEGA) { + firstIndex = 16; + dest += 3 * 16; + ptr += 3 * 16; + } + + for (i = firstIndex; i < numcolor; i++) { r = *ptr++; g = *ptr++; b = *ptr++; @@ -323,7 +255,7 @@ void ScummEngine::setPaletteFromPtr(const byte *ptr, int numcolor) { memcpy(_darkenPalette, _currentPalette, 768); } - setDirtyColors(0, numcolor - 1); + setDirtyColors(firstIndex, numcolor - 1); } void ScummEngine::setDirtyColors(int min, int max) { diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index 9f3ebb8053..af6b9278c6 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -499,7 +499,9 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr) case Common::kRenderCGA: case Common::kRenderEGA: case Common::kRenderAmiga: - if ((_game.version >= 4 && !(_game.features & GF_16COLOR)) || (_game.features & GF_OLD256)) + if ((_game.version >= 4 && !(_game.features & GF_16COLOR) + && !(_game.platform == Common::kPlatformAmiga && _renderMode == Common::kRenderEGA)) + || (_game.features & GF_OLD256)) _renderMode = Common::kRenderDefault; break; diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h index 7d2bf3336a..6866b17668 100644 --- a/engines/scumm/scumm.h +++ b/engines/scumm/scumm.h @@ -1029,14 +1029,7 @@ protected: const byte *getPalettePtr(int palindex, int room); - void setC64Palette(); - void setNESPalette(); - void setAmigaPalette(); - void setHercPalette(); - void setCGAPalette(); - void setEGAPalette(); - void setV1Palette(); - + void setPaletteFromTable(const byte *ptr, int numcolor, int firstIndex = 0); void resetPalette(); void setCurrentPalette(int pal); -- cgit v1.2.3