aboutsummaryrefslogtreecommitdiff
path: root/engines/scumm
diff options
context:
space:
mode:
authorNorbert Lange2009-08-24 17:51:47 +0000
committerNorbert Lange2009-08-24 17:51:47 +0000
commit917d4b78b36d6c5a5c25a03e7ee6a1c1b6a85fd5 (patch)
treee652563203a00f8acecfaafbf93c64dbfbd13f25 /engines/scumm
parent5f87d5090cfcb34cda3c1f5d430e0865344d7366 (diff)
parentdd7868acc2512c9761d892e67a4837f4dc38bdc0 (diff)
downloadscummvm-rg350-917d4b78b36d6c5a5c25a03e7ee6a1c1b6a85fd5.tar.gz
scummvm-rg350-917d4b78b36d6c5a5c25a03e7ee6a1c1b6a85fd5.tar.bz2
scummvm-rg350-917d4b78b36d6c5a5c25a03e7ee6a1c1b6a85fd5.zip
Merge with trunk
svn-id: r43701
Diffstat (limited to 'engines/scumm')
-rw-r--r--engines/scumm/actor.cpp7
-rw-r--r--engines/scumm/actor.h2
-rw-r--r--engines/scumm/akos.cpp81
-rw-r--r--engines/scumm/akos.h4
-rw-r--r--engines/scumm/base-costume.cpp2
-rw-r--r--engines/scumm/base-costume.h2
-rw-r--r--engines/scumm/charset.cpp4
-rw-r--r--engines/scumm/costume.cpp13
-rw-r--r--engines/scumm/costume.h6
-rw-r--r--engines/scumm/cursor.cpp44
-rw-r--r--engines/scumm/detection_tables.h148
-rw-r--r--engines/scumm/dialogs.cpp237
-rw-r--r--engines/scumm/dialogs.h34
-rw-r--r--engines/scumm/gfx.cpp230
-rw-r--r--engines/scumm/gfx.h12
-rw-r--r--engines/scumm/gfxARM.s42
-rw-r--r--engines/scumm/he/animation_he.cpp41
-rw-r--r--engines/scumm/he/animation_he.h1
-rw-r--r--engines/scumm/he/intern_he.h3
-rw-r--r--engines/scumm/he/palette_he.cpp196
-rw-r--r--engines/scumm/he/script_v100he.cpp45
-rw-r--r--engines/scumm/he/script_v60he.cpp9
-rw-r--r--engines/scumm/he/script_v72he.cpp29
-rw-r--r--engines/scumm/he/script_v80he.cpp8
-rw-r--r--engines/scumm/he/script_v90he.cpp40
-rw-r--r--engines/scumm/he/sound_he.cpp6
-rw-r--r--engines/scumm/he/wiz_he.cpp929
-rw-r--r--engines/scumm/he/wiz_he.h45
-rw-r--r--engines/scumm/palette.cpp36
-rw-r--r--engines/scumm/resource.cpp6
-rw-r--r--engines/scumm/saveload.cpp2
-rw-r--r--engines/scumm/saveload.h2
-rw-r--r--engines/scumm/scumm.cpp33
-rw-r--r--engines/scumm/scumm.h14
-rw-r--r--engines/scumm/sound.cpp2
-rw-r--r--engines/scumm/vars.cpp1
36 files changed, 1372 insertions, 944 deletions
diff --git a/engines/scumm/actor.cpp b/engines/scumm/actor.cpp
index 3033904357..9dab776b67 100644
--- a/engines/scumm/actor.cpp
+++ b/engines/scumm/actor.cpp
@@ -2451,7 +2451,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);
@@ -2551,9 +2551,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(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/actor.h b/engines/scumm/actor.h
index 3f67d42a50..c3edd24a39 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 ab7db2c4a7..f4bb8a2c8b 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);
@@ -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,7 +1294,7 @@ 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;
@@ -1335,18 +1351,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++)
+ 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) {
+ 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<kWizXMap>(dstPtr, _out.pitch, _srcptr, src, 0, palPtr, xmap);
+ Wiz::decompressWizImage<kWizXMap>(dstPtr, _out.pitch, kDstScreen, _srcptr, src, 0, palPtr, xmap, _vm->_bitDepth);
} else {
if (palPtr != NULL) {
- Wiz::decompressWizImage<kWizRMap>(dstPtr, _out.pitch, _srcptr, src, 0, palPtr);
+ Wiz::decompressWizImage<kWizRMap>(dstPtr, _out.pitch, kDstScreen, _srcptr, src, 0, palPtr, NULL, _vm->_bitDepth);
} else {
- Wiz::decompressWizImage<kWizCopy>(dstPtr, _out.pitch, _srcptr, src, 0);
+ Wiz::decompressWizImage<kWizCopy>(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..9f4f09d4dc 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
@@ -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.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/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/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/costume.cpp b/engines/scumm/costume.cpp
index 57b793d579..6923c27b38 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] = palette[i];
} 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] = palette[i];
} 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 8e1910abcf..929eb8c451 100644
--- a/engines/scumm/costume.h
+++ b/engines/scumm/costume.h
@@ -98,7 +98,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);
@@ -120,7 +120,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);
@@ -135,7 +135,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/cursor.cpp b/engines/scumm/cursor.cpp
index 64829114ca..7818d6a98e 100644
--- a/engines/scumm/cursor.cpp
+++ b/engines/scumm/cursor.cpp
@@ -111,11 +111,20 @@ void ScummEngine_v6::setCursorTransparency(int a) {
}
void ScummEngine::updateCursor() {
- const int transColor = (_game.heversion >= 80) ? 5 : 255;
+ int transColor = (_game.heversion >= 80) ? 5 : 255;
+#ifdef USE_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),
+ &format);
+#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) {
@@ -138,7 +147,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 +157,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;
}
@@ -166,8 +175,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;
@@ -180,10 +194,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;
@@ -195,9 +215,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();
}
diff --git a/engines/scumm/detection_tables.h b/engines/scumm/detection_tables.h
index 99a28153c4..57fe251e05 100644
--- a/engines/scumm/detection_tables.h
+++ b/engines/scumm/detection_tables.h
@@ -80,13 +80,22 @@ static const PlainGameDescriptor gameDescriptions[] = {
{ "puttputt", "Putt-Putt Joins the Parade" },
#ifdef ENABLE_HE
- { "airport", "Let's Explore the Airport with Buzzy" },
+#ifdef USE_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" },
+ { "SoccerMLS", "Backyard Soccer MLS Edition" },
+#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,32 +105,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" },
{ "spyfox2", "SPY Fox 2: Some Assembly Required" },
@@ -343,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},
@@ -355,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},
@@ -369,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
@@ -500,23 +504,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 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 },
{ "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 +522,62 @@ 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 },
+
+ { "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 },
+ { "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 +620,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 +678,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 +695,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 +747,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,23 +816,12 @@ 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 },
{ "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 },
-
- { "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 +863,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 },
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;
diff --git a/engines/scumm/gfx.cpp b/engines/scumm/gfx.cpp
index fa5d2011b0..fd298c2980 100644
--- a/engines/scumm/gfx.cpp
+++ b/engines/scumm/gfx.cpp
@@ -38,17 +38,17 @@
#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 bitDepth);
#endif /* USE_ARM_GFX_ASM */
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);
@@ -231,6 +231,9 @@ GdiV2::~GdiV2() {
free(_roomStrips);
}
+Gdi16Bit::Gdi16Bit(ScummEngine *vm) : Gdi(vm) {
+}
+
void Gdi::init() {
_numStrips = _vm->_screenWidth / 8;
@@ -341,8 +344,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 +589,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 +615,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);
@@ -768,8 +784,10 @@ 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);
+ /* 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);
const int dstAdd = dstPitch - w;
const int srcAdd = srcPitch - w;
@@ -986,13 +1004,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);
}
}
@@ -1021,7 +1039,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
@@ -1057,51 +1075,63 @@ 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);
+ }
}
}
#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
-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;
@@ -1110,13 +1140,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);
@@ -1181,41 +1215,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);
}
}
@@ -1253,7 +1287,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;
}
@@ -1300,7 +1334,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.
@@ -1609,7 +1643,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);
@@ -1642,9 +1676,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);
@@ -1653,11 +1687,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);
@@ -1885,7 +1919,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
@@ -1941,12 +1975,12 @@ void Gdi::drawBMAPObject(const byte *ptr, VirtScreen *vs, int obj, int x, int y,
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);
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);
@@ -1996,7 +2030,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
@@ -2026,15 +2060,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);
}
}
}
@@ -2785,12 +2819,12 @@ 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++;
+ writeRoomColor(dst, color);
+ dst += _vm->_bitDepth;
--x;
if (x == 0) {
x = width;
- dst += dstPitch - width;
+ dst += dstPitch - width * _vm->_bitDepth;
--height;
if (height == 0)
return;
@@ -2874,8 +2908,8 @@ void Gdi::drawStripComplex(byte *dst, int dstPitch, const byte *src, int height,
do {
FILL_BITS;
if (!transpCheck || color != _transparentColor)
- *dst = _roomPalette[color] + _paletteMod;
- dst++;
+ writeRoomColor(dst, color);
+ dst += _vm->_bitDepth;
againPos:
if (!READ_BIT) {
@@ -2896,13 +2930,13 @@ 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++;
+ writeRoomColor(dst, color);
+ dst += _vm->_bitDepth;
} while (--reps);
bits >>= 8;
bits |= (*src++) << (cl - 8);
@@ -2910,7 +2944,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);
}
@@ -2926,8 +2960,8 @@ void Gdi::drawStripBasicH(byte *dst, int dstPitch, const byte *src, int height,
do {
FILL_BITS;
if (!transpCheck || color != _transparentColor)
- *dst = _roomPalette[color] + _paletteMod;
- dst++;
+ writeRoomColor(dst, color);
+ dst += _vm->_bitDepth;
if (!READ_BIT) {
} else if (!READ_BIT) {
FILL_BITS;
@@ -2942,7 +2976,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);
}
@@ -2959,7 +2993,7 @@ void Gdi::drawStripBasicV(byte *dst, int dstPitch, const byte *src, int height,
do {
FILL_BITS;
if (!transpCheck || color != _transparentColor)
- *dst = _roomPalette[color] + _paletteMod;
+ writeRoomColor(dst, color);
dst += dstPitch;
if (!READ_BIT) {
} else if (!READ_BIT) {
@@ -3027,7 +3061,7 @@ void Gdi::drawStripRaw(byte *dst, int dstPitch, const byte *src, int height, con
for (x = 0; x < 8; x ++) {
byte color = *src++;
if (!transpCheck || color != _transparentColor)
- dst[x] = _roomPalette[color] + _paletteMod;
+ writeRoomColor(dst + x * _vm->_bitDepth, color);
}
dst += dstPitch;
} while (--height);
@@ -3150,6 +3184,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 e4c1054450..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 + xstart + y * pitch + x;
+ return (byte *)pixels + y * pitch + (xstart + x) * bytesPerPixel;
}
byte *getBackPixels(int x, int y) const {
- return (byte *)backBuf + xstart + y * pitch + x;
+ return (byte *)backBuf + y * pitch + (xstart + x) * bytesPerPixel;
}
};
@@ -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/gfxARM.s b/engines/scumm/gfxARM.s
index f3a1f20303..e78487d777 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,
+ @ 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
@@ -126,9 +127,13 @@ asmCopy8Col:
@ r1 = dstPitch
@ r2 = src
@ r3 = height
- STMFD r13!,{r14}
- SUB r1,r1,#4
+ @ <> = bitdepth (badly named, should be bytedepth, 1 or 2)
+ LDR r12,[r13]
+ STR r14,[r13,#-4]!
+ CMP r12,#1
+ BNE copy8Col16
+ SUB r1,r1,#4
TST r3,#1
ADDNE r3,r3,#1
BNE roll2
@@ -145,4 +150,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/animation_he.cpp b/engines/scumm/he/animation_he.cpp
index 2ca17161db..cf071fc4aa 100644
--- a/engines/scumm/he/animation_he.cpp
+++ b/engines/scumm/he/animation_he.cpp
@@ -66,6 +66,41 @@ int MoviePlayer::load(const char *filename, int flags, int image) {
return 0;
}
+void MoviePlayer::copyFrameToBuffer(byte *dst, int dstType, 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++) {
+ 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;
+ } 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 +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);
+ copyFrameToBuffer(dst, kDstResource, 0, 0, _vm->_screenWidth * _vm->_bitDepth);
} else if (_flags & 1) {
- copyFrameToBuffer(pvs->getBackPixels(0, 0), 0, 0, _vm->_screenWidth);
+ 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, _vm->_screenWidth);
+ 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 cf5d054ead..86ded31940 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, int dstType, 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 9e905b0e79..2f7f539ee3 100644
--- a/engines/scumm/he/intern_he.h
+++ b/engines/scumm/he/intern_he.h
@@ -458,6 +458,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);
@@ -466,7 +467,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 7fe04f223e..ff29f9ecd0 100644
--- a/engines/scumm/he/palette_he.cpp
+++ b/engines/scumm/he/palette_he.cpp
@@ -40,7 +40,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;
}
@@ -75,9 +75,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;
}
}
@@ -86,7 +86,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;
@@ -107,39 +107,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;
}
}
@@ -178,8 +222,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);
}
}
@@ -187,18 +232,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) {
@@ -211,7 +265,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++;
@@ -222,48 +276,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);
}
}
@@ -274,26 +343,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 44a38401ce..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();
@@ -1576,7 +1577,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
@@ -2153,8 +2157,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) {
@@ -2169,12 +2174,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;
@@ -2577,7 +2582,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();
@@ -2586,7 +2592,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();
@@ -2597,20 +2606,26 @@ 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) {
+ push(get16BitColor(r, g, b));
+ } 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 7c109b1dcd..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] == ':')
@@ -122,6 +129,8 @@ int ScummEngine_v60he::convertFilePath(byte *dst, int dstSize) {
} else if (dst[0] == '.' && dst[1] == '/') { // Game Data Path
// The default game data path is set to './' by ScummVM
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)
// The default save game path is set to '*/' by ScummVM
r = 2;
diff --git a/engines/scumm/he/script_v72he.cpp b/engines/scumm/he/script_v72he.cpp
index 1d73f0da76..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);
@@ -1484,6 +1479,7 @@ void ScummEngine_v72he::o72_readFile() {
fetchScriptByte();
size = pop();
slot = pop();
+ assert(_hInFileTable[slot]);
val = readFileToArray(slot, size);
push(val);
break;
@@ -1573,7 +1569,7 @@ void ScummEngine_v72he::o72_rename() {
}
void ScummEngine_v72he::o72_getPixel() {
- byte area;
+ uint16 area;
int y = pop();
int x = pop();
@@ -1588,11 +1584,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);
@@ -1805,9 +1807,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"));
@@ -1818,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/he/script_v80he.cpp b/engines/scumm/he/script_v80he.cpp
index 5b10944899..dd44180fa0 100644
--- a/engines/scumm/he/script_v80he.cpp
+++ b/engines/scumm/he/script_v80he.cpp
@@ -243,7 +243,7 @@ void ScummEngine_v80he::o80_writeConfigFile() {
}
void ScummEngine_v80he::o80_cursorCommand() {
- int a, i;
+ int a, b, i;
int args[16];
byte subOp = fetchScriptByte();
@@ -252,12 +252,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 be20a229f0..e302af1144 100644
--- a/engines/scumm/he/script_v90he.cpp
+++ b/engines/scumm/he/script_v90he.cpp
@@ -1255,7 +1255,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;
@@ -1319,9 +1319,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();
@@ -2101,7 +2102,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();
@@ -2111,10 +2113,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();
@@ -2130,17 +2132,27 @@ 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) {
+ push(get16BitColor(r, g, b));
+ } else {
+ push(getHEPaletteSimilarColor(1, r, g, 10, 245));
+ }
break;
default:
error("o90_getPaletteData: Unknown case %d", subOp);
diff --git a/engines/scumm/he/sound_he.cpp b/engines/scumm/he/sound_he.cpp
index 01f29d5db9..477f3cf0ad 100644
--- a/engines/scumm/he/sound_he.cpp
+++ b/engines/scumm/he/sound_he.cpp
@@ -645,7 +645,11 @@ 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);
+ /* 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;
diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp
index 549877090c..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;
}
@@ -254,7 +255,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 +266,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 +356,25 @@ 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);
+ }
+}
+#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)) {
- 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 +384,18 @@ void Wiz::copy16BitWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, in
r1.translate(dx, 0);
}
if (xmapPtr) {
- decompress16BitWizImage<kWizXMap>(dst, dstw, src, r1, flags, palPtr, xmapPtr);
+ decompress16BitWizImage<kWizXMap>(dst, dstPitch, dstType, src, r1, flags, xmapPtr);
} else {
- decompress16BitWizImage<kWizCopy>(dst, dstw, src, r1, flags);
+ decompress16BitWizImage<kWizCopy>(dst, dstPitch, dstType, src, r1, flags);
}
}
}
+#endif
-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 +405,11 @@ void Wiz::copyWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int src
r1.translate(dx, 0);
}
if (xmapPtr) {
- decompressWizImage<kWizXMap>(dst, dstw, src, r1, flags, palPtr, xmapPtr);
+ decompressWizImage<kWizXMap>(dst, dstPitch, dstType, src, r1, flags, palPtr, xmapPtr, bitDepth);
} else if (palPtr) {
- decompressWizImage<kWizRMap>(dst, dstw, src, r1, flags, palPtr);
+ decompressWizImage<kWizRMap>(dst, dstPitch, dstType, src, r1, flags, palPtr, NULL, bitDepth);
} else {
- decompressWizImage<kWizCopy>(dst, dstw, src, r1, flags);
+ decompressWizImage<kWizCopy>(dst, dstPitch, dstType, src, r1, flags, NULL, NULL, bitDepth);
}
}
}
@@ -431,13 +448,102 @@ 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) {
+#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)) {
+ 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<kWizCopy>(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<kWizCopy>(dstPtr, dataPtr, dstType, palPtr);
+ dataPtr += 2;
+ dstPtr += dstInc;
+ maskPtr++;
+ }
+ }
+ }
+ }
+ dataPtr = dataPtrNext;
+ dstPtr = dstPtrNext;
+ 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;
if (!calcClipRects(dstw, dsth, srcx, srcy, srcw, srch, rect, srcRect, dstRect)) {
return;
}
- dstw = dstw / 8;
- dst += dstRect.top * dstw + dstRect.left / 8;
+ dstPitch /= 8;
+ dst += dstRect.top * dstPitch + dstRect.left / 8;
const uint8 *dataPtr, *dataPtrNext;
uint8 code, mask, *dstPtr, *dstPtrNext;
@@ -462,7 +568,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 +626,8 @@ 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) {
+#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) {
@@ -537,19 +644,23 @@ 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;
- if (palPtr) {
- decompressRawWizImage<kWizRMap>(dst, dstw, src, srcw, w, h, transColor, palPtr);
- } else {
- decompressRawWizImage<kWizCopy>(dst, dstw, src, srcw, w, h, transColor);
+ 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 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::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) {
@@ -566,38 +677,41 @@ 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;
- while (h--) {
- 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;
- }
- }
- src += srcw * 2;
- dst += dstw;
+ src += r1.top * srcw + r1.left;
+ dst += r2.top * dstPitch + r2.left * bitDepth;
+ if (palPtr) {
+ decompressRawWizImage<kWizRMap>(dst, dstPitch, dstType, src, srcw, w, h, transColor, palPtr, bitDepth);
+ } else {
+ decompressRawWizImage<kWizCopy>(dst, dstPitch, dstType, src, srcw, w, h, transColor, NULL, bitDepth);
}
}
}
+#ifdef USE_RGB_COLOR
template <int type>
-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 <int type>
+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, *dstPtr, *dstPtrNext;
+ uint8 code;
+ uint8 *dstPtr, *dstPtrNext;
int h, w, xoff, dstInc;
if (type == kWizXMap) {
assert(xmapPtr != 0);
}
- if (type == kWizRMap) {
- assert(palPtr != 0);
- }
dstPtr = dst;
dataPtr = src;
@@ -616,10 +730,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--) {
@@ -658,21 +772,10 @@ 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<type>(dstPtr, dataPtr, dstType, xmapPtr);
dstPtr += dstInc;
}
- dataPtr+= 2;
+ dataPtr += 2;
} else {
code = (code >> 2) + 1;
if (xoff > 0) {
@@ -689,18 +792,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<type>(dstPtr, dataPtr, dstType, xmapPtr);
dataPtr += 2;
dstPtr += dstInc;
}
@@ -711,9 +803,39 @@ void Wiz::decompress16BitWizImage(uint8 *dst, int dstPitch, const uint8 *src, co
dstPtr = dstPtrNext;
}
}
+#endif
template <int type>
-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 <int type>
+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,10 +864,10 @@ 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;
- dstInc = -1;
+ dstPtr += (w - 1) * bitDepth;
+ dstInc = -bitDepth;
}
while (h--) {
@@ -784,15 +906,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<type>(dstPtr, dataPtr, dstType, palPtr, xmapPtr, bitDepth);
dstPtr += dstInc;
}
dataPtr++;
@@ -812,15 +926,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<type>(dstPtr, dataPtr, dstType, palPtr, xmapPtr, bitDepth);
+ dataPtr++;
dstPtr += dstInc;
}
}
@@ -832,12 +939,12 @@ void Wiz::decompressWizImage(uint8 *dst, int dstPitch, const uint8 *src, const C
}
// NOTE: These templates are used outside this file. We don't want the compiler to optimize them away, so we need to explicitely instantiate them.
-template void Wiz::decompressWizImage<kWizXMap>(uint8 *dst, int dstPitch, const uint8 *src, const Common::Rect &srcRect, int flags, const uint8 *palPtr, const uint8 *xmapPtr);
-template void Wiz::decompressWizImage<kWizRMap>(uint8 *dst, int dstPitch, const uint8 *src, const Common::Rect &srcRect, int flags, const uint8 *palPtr, const uint8 *xmapPtr);
-template void Wiz::decompressWizImage<kWizCopy>(uint8 *dst, int dstPitch, const uint8 *src, const Common::Rect &srcRect, int flags, const uint8 *palPtr, const uint8 *xmapPtr);
+template void Wiz::decompressWizImage<kWizXMap>(uint8 *dst, int dstPitch, int dstType, const uint8 *src, const Common::Rect &srcRect, int flags, const uint8 *palPtr, const uint8 *xmapPtr, uint8 bitDepth);
+template void Wiz::decompressWizImage<kWizRMap>(uint8 *dst, int dstPitch, int dstType, const uint8 *src, const Common::Rect &srcRect, int flags, const uint8 *palPtr, const uint8 *xmapPtr, uint8 bitDepth);
+template void Wiz::decompressWizImage<kWizCopy>(uint8 *dst, int dstPitch, int dstType, const uint8 *src, const Common::Rect &srcRect, int flags, const uint8 *palPtr, const uint8 *xmapPtr, uint8 bitDepth);
template <int type>
-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);
}
@@ -850,10 +957,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;
+ }
}
}
}
@@ -943,7 +1058,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];
@@ -954,7 +1069,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];
}
@@ -1043,6 +1158,25 @@ 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();
+ int h = rCapt.height();
+ int size = w * h * 2;
+ if (dst) {
+ src += rCapt.top * srcPitch + rCapt.left * 2;
+ while (h--) {
+ for (int i = 0; i < w; i++)
+ WRITE_LE_UINT16(dst + i * 2, READ_UINT16(src + i * 2));
+ dst += w * 2;
+ src += srcPitch;
+ }
+ }
+ 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);
src += rCapt.top * srcPitch + rCapt.left;
@@ -1179,7 +1313,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(5, "ScummEngine_v72he::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,12 +1320,17 @@ 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) {
+ 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);
const uint8 *palPtr;
if (_vm->_game.heversion >= 99) {
- palPtr = _vm->_hePalettes + 1024;
+ palPtr = _vm->_hePalettes + _vm->_hePaletteSlot;
} else {
palPtr = _vm->_currentPalette;
}
@@ -1201,16 +1339,24 @@ 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;
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;
+#ifdef USE_RGB_COLOR
+ case 2:
+ dataSize = wizPackType2(0, src, srcPitch, rCapt);
break;
+#endif
default:
error("unhandled compression type %d", compType);
break;
@@ -1249,11 +1395,16 @@ 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;
+#ifdef USE_RGB_COLOR
+ case 2:
+ wizPackType2(wizImg + headerSize, src, srcPitch, rCapt);
break;
+#endif
default:
break;
}
@@ -1279,24 +1430,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, 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, 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 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;
- 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);
@@ -1318,6 +1460,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);
@@ -1339,13 +1496,30 @@ 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++) {
+ if (_cursorImage) {
+ WRITE_UINT16(tmpPtr + j * 2, transColor);
+ } else {
+ 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);
@@ -1353,6 +1527,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) {
@@ -1362,6 +1538,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;
}
}
@@ -1381,7 +1559,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;
}
@@ -1393,29 +1571,36 @@ 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);
+ 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);
- copyWizImageWithMask(dst, wizd, cw, ch, x1, y1, width, height, &rScreen, 0, 1);
+ dstPitch /= _vm->_bitDepth;
+ 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;
+#ifdef USE_RGB_COLOR
case 2:
- copyRaw16BitWizImage(dst, wizd, cw, ch, x1, y1, width, height, &rScreen, flags, palPtr, 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
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, xmapPtr);
break;
+#endif
default:
error("drawWizImage: Unhandled wiz compression type %d", comp);
}
@@ -1517,6 +1702,74 @@ struct PolygonDrawData {
}
};
+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;
+ WizPolygon *wp;
+
+ wp = NULL;
+ for (i = 0; i < ARRAYSIZE(_polygons); ++i) {
+ if (_polygons[i].id == id1) {
+ wp = &_polygons[i];
+ break;
+ }
+ }
+ if (!wp) {
+ error("Polygon1 %d is not defined", id1);
+ }
+ if (wp->numVerts != 5) {
+ error("Invalid point count %d for Polygon1 %d", wp->numVerts, id1);
+ }
+
+ wp = NULL;
+ for (i = 0; i < ARRAYSIZE(_polygons); ++i) {
+ if (_polygons[i].id == id2) {
+ wp = &_polygons[i];
+ break;
+ }
+ }
+ if (!wp) {
+ error("Polygon2 %d is not defined", 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;
+
+ 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 = 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++) {
+ for (j = 0; j < dstw; j++)
+ WRITE_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, wp->vert, _vm->_bitDepth);
+
+ captureImage(imageBuffer, dstpitch, dstw, dsth, resNum, wp->bound, compType);
+ 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];
@@ -1544,11 +1797,10 @@ 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;
- int i;
if (_vm->_game.heversion >= 99) {
if (getWizImageData(resNum, state, 0) != 0 || (flags & (kWIFRemapPalette | kWIFFlipX | kWIFFlipY)) || palette != 0) {
@@ -1557,8 +1809,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, 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);
@@ -1567,7 +1821,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, 0, 0, shadow, 0, r, kWIFBlitToMemBuffer, 0, _vm->getHEPaletteSlot(palette));
} else {
uint8 *dataPtr = _vm->getResourceAddress(rtImage, resNum);
assert(dataPtr);
@@ -1577,146 +1831,162 @@ void Wiz::drawWizPolygonTransform(int resNum, int state, Common::Point *wp, int
}
}
- if (srcWizBuf) {
- uint8 *dst;
- int32 dstw, dsth, dstpitch, 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;
+ 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);
+ dst = pvs->getBackPixels(0, 0);
+ }
+ dstw = pvs->w;
+ dsth = pvs->h;
+ dstpitch = pvs->pitch;
+ dstType = kDstScreen;
+ }
+
+ 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;
}
- dstw = pvs->w;
- dsth = pvs->h;
- dstpitch = pvs->pitch;
- }
-
- 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;
- 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;
- }
+ int16 x2 = ppa->xmax;
+ if (x2 >= dstw) {
+ x2 = dstw - 1;
}
- ++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 (transColor == -1 || transColor != srcWizBuf[src_offs]) {
- *dstPtr = srcWizBuf[src_offs];
+ 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++;
+ ++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)) {
+ 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() {
@@ -1726,13 +1996,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, 0, 0, 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) {
@@ -1747,11 +2017,14 @@ void Wiz::loadWizCursor(int resId) {
}
const Common::Rect *r = NULL;
- uint8 *cursor = drawWizImage(resId, 0, 0, 0, 0, 0, 0, r, kWIFBlitToMemBuffer, 0, 0);
+ _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);
_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);
@@ -1763,7 +2036,7 @@ void Wiz::displayWizComplexImage(const WizParameters *params) {
int sourceImage = 0;
if (params->processFlags & kWPFMaskImg) {
sourceImage = params->sourceImage;
- debug(0, "displayWizComplexImage() unhandled flag kWPFMaskImg");
+ debug(0, "displayWizComplexImage() flag kWPFMaskImg");
}
int palette = 0;
if (params->processFlags & kWPFPaletteNum) {
@@ -1831,15 +2104,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, 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, palette);
+ drawWizImage(params->img.resNum, state, 0, 0, po_x, po_y, params->img.zorder, shadow, field_390, r, flags, dstResNum, _vm->getHEPaletteSlot(palette));
}
}
}
@@ -1847,6 +2119,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;
@@ -1857,11 +2131,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;
}
@@ -1874,7 +2148,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) {
@@ -1897,7 +2171,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);
}
@@ -1914,7 +2188,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)) {
@@ -1937,10 +2212,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;
}
}
}
@@ -1950,14 +2230,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;
}
}
@@ -1974,7 +2259,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)) {
@@ -1997,13 +2283,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);
}
}
@@ -2065,7 +2351,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) {
@@ -2080,18 +2366,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, sizeof(buffer));
- memcpy(filename, params->filename, 260);
- _vm->convertFilePath(filename, sizeof(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;
@@ -2105,7 +2401,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;
@@ -2115,7 +2411,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, sizeof(buffer));
switch (params->fileWriteMode) {
case 2:
@@ -2125,22 +2423,20 @@ void Wiz::processWizImage(const WizParameters *params) {
// TODO Write image to file
break;
case 0:
- memcpy(filename, params->filename, 260);
- _vm->convertFilePath(filename, sizeof(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:
@@ -2153,9 +2449,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->processFlags & kWPFNewState) ? params->img.state : 0, params->polygonId1, params->polygonId2, params->compType);
break;
case 8: {
int img_w = 640;
@@ -2172,6 +2466,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;
@@ -2308,8 +2605,9 @@ 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;
+ 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
@@ -2319,6 +2617,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;
@@ -2349,6 +2648,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;
@@ -2359,6 +2659,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 fe63457ead..1fa9564486 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 {
@@ -159,6 +165,7 @@ public:
void clearWizBuffer();
Common::Rect _rectOverride;
+ bool _cursorImage;
bool _rectOverrideEnabled;
void polygonClear();
@@ -188,27 +195,43 @@ 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 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, 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 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);
+ 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<int type> static void decompress16BitWizImage(uint8 *dst, int dstPitch, int dstType, const uint8 *src, const Common::Rect &srcRect, int flags, const uint8 *xmapPtr = NULL);
+#endif
+ template<int type> 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<int type> 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<int type> static void write16BitColor(uint8 *dst, const uint8 *src, int dstType, const uint8 *xmapPtr);
+#endif
+ template<int type> 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);
- 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<int type> 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<int type> void decompress16BitWizImage(uint8 *dst, int dstPitch, const uint8 *src, const Common::Rect &srcRect, int flags, const uint8 *palPtr = NULL, const uint8 *xmapPtr = NULL);
- template<int type> static void decompressRawWizImage(uint8 *dst, int dstPitch, const uint8 *src, int srcPitch, int w, int h, int transColor, const uint8 *palPtr = NULL);
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 1b531f6bab..2fe3f34530 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() {
static const byte tableC64Palette[] = {
0x00, 0x00, 0x00, 0xFD, 0xFE, 0xFC, 0xBE, 0x1A, 0x24, 0x30, 0xE6, 0xC6,
@@ -201,6 +222,8 @@ void ScummEngine::setPaletteFromPtr(const byte *ptr, int numcolor) {
assertRange(0, numcolor, 256, "setPaletteFromPtr: numcolor");
dest = _currentPalette;
+
+ // 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;
@@ -240,9 +263,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) {
@@ -729,16 +749,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/resource.cpp b/engines/scumm/resource.cpp
index 67baff97b3..d3faa15c10 100644
--- a/engines/scumm/resource.cpp
+++ b/engines/scumm/resource.cpp
@@ -919,7 +919,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:
diff --git a/engines/scumm/saveload.cpp b/engines/scumm/saveload.cpp
index aa4dce470e..7bf61a8762 100644
--- a/engines/scumm/saveload.cpp
+++ b/engines/scumm/saveload.cpp
@@ -1553,7 +1553,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/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
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index 9d6673d308..587e2a8abe 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -111,7 +111,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);
@@ -252,6 +254,7 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr)
_switchRoomEffect2 = 0;
_switchRoomEffect = 0;
+ _bitDepth = 0;
_doEffect = false;
_snapScroll = false;
_currentLights = 0;
@@ -268,8 +271,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));
@@ -525,9 +528,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;
@@ -829,7 +834,6 @@ ScummEngine_v90he::~ScummEngine_v90he() {
delete _logicHE;
}
if (_game.heversion >= 99) {
- free(_hePaletteCache);
free(_hePalettes);
}
}
@@ -1094,6 +1098,15 @@ 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) {
+#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())
+ return Common::kUnsupportedColorMode;
+#else
+ error("16bit color support is required for this game");
+#endif
} else {
initGraphics(_screenWidth, _screenHeight, _screenWidth > 320);
}
@@ -1197,7 +1210,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
@@ -1219,7 +1232,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
@@ -1560,11 +1573,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 f0f2521225..940ea512d5 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:
@@ -966,6 +963,7 @@ public:
int _screenTop;
Common::RenderMode _renderMode;
+ uint8 _bitDepth;
protected:
ColorCycle _colorCycle[16]; // Palette cycles
@@ -985,7 +983,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;
@@ -1044,7 +1045,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);
@@ -1120,7 +1122,7 @@ public:
// HE specific
byte _HEV7ActorPalette[256];
uint8 *_hePalettes;
- int16 *_hePaletteCache;
+ uint16 _hePaletteSlot;
protected:
int _shadowPaletteSize;
diff --git a/engines/scumm/sound.cpp b/engines/scumm/sound.cpp
index 07e2ce8bca..82ed2a62e6 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;
}
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;