aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/graphics
diff options
context:
space:
mode:
authorMatthew Hoops2010-05-24 17:21:11 +0000
committerMatthew Hoops2010-05-24 17:21:11 +0000
commitd49fb8f42db7b9776f1dc426ebe2c6d806ad4720 (patch)
treee0760e8b76b8786f506a59dc62ef824b2304f1cd /engines/sci/graphics
parentad0eb0b06ef6c715280c21a1c036be5c56a3183a (diff)
downloadscummvm-rg350-d49fb8f42db7b9776f1dc426ebe2c6d806ad4720.tar.gz
scummvm-rg350-d49fb8f42db7b9776f1dc426ebe2c6d806ad4720.tar.bz2
scummvm-rg350-d49fb8f42db7b9776f1dc426ebe2c6d806ad4720.zip
Add support for showing the icon bar in SCI1.1 Mac.
svn-id: r49196
Diffstat (limited to 'engines/sci/graphics')
-rw-r--r--engines/sci/graphics/maciconbar.cpp91
-rw-r--r--engines/sci/graphics/maciconbar.h55
-rw-r--r--engines/sci/graphics/palette.cpp7
-rw-r--r--engines/sci/graphics/screen.cpp13
4 files changed, 164 insertions, 2 deletions
diff --git a/engines/sci/graphics/maciconbar.cpp b/engines/sci/graphics/maciconbar.cpp
new file mode 100644
index 0000000000..b2a0b0677d
--- /dev/null
+++ b/engines/sci/graphics/maciconbar.cpp
@@ -0,0 +1,91 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "sci/sci.h"
+#include "sci/engine/selector.h"
+#include "sci/engine/state.h"
+#include "sci/graphics/maciconbar.h"
+#include "sci/graphics/palette.h"
+
+#include "common/stream.h"
+#include "common/system.h"
+#include "graphics/pict.h"
+#include "graphics/surface.h"
+
+namespace Sci {
+
+void MacIconBar::addIcon(reg_t obj) {
+ _iconBarObjects.push_back(obj);
+}
+
+void MacIconBar::drawIcons() {
+ // Draw the icons to the bottom of the screen
+
+ byte *pal = new byte[256 * 4];
+ Graphics::PictDecoder *pict = new Graphics::PictDecoder(Graphics::PixelFormat::createFormatCLUT8());
+ uint32 lastX = 0;
+
+ for (uint32 i = 0; i < _iconBarObjects.size(); i++) {
+ uint32 iconIndex = GET_SEL32V(g_sci->getEngineState()->_segMan, _iconBarObjects[i], SELECTOR(iconIndex));
+ Resource *res = g_sci->getResMan()->findResource(ResourceId(kResourceTypeMacIconBarPictN, iconIndex + 1), false);
+ if (!res)
+ continue;
+
+ Common::MemoryReadStream *stream = new Common::MemoryReadStream(res->data, res->size);
+ Graphics::Surface *surf = pict->decodeImage(stream, pal);
+ remapColors(surf, pal);
+
+ g_system->copyRectToScreen((byte *)surf->pixels, surf->pitch, lastX, 200, MIN<uint32>(surf->w, 320 - lastX), surf->h);
+
+ lastX += surf->w;
+ surf->free();
+ delete surf;
+ delete stream;
+ }
+
+ delete pict;
+ delete[] pal;
+}
+
+void MacIconBar::remapColors(Graphics::Surface *surf, byte *palette) {
+ byte *pixels = (byte *)surf->pixels;
+
+ // Remap to the screen palette
+ for (uint16 i = 0; i < surf->w * surf->h; i++) {
+ byte color = *pixels;
+
+ byte r = palette[color * 4];
+ byte g = palette[color * 4 + 1];
+ byte b = palette[color * 4 + 2];
+
+ // For black, make sure the index is 0
+ if (r == 0 && g == 0 && b == 0)
+ *pixels++ = 0;
+ else
+ *pixels++ = g_sci->_gfxPalette->kernelFindColor(r, g, b);
+ }
+}
+
+} // End of namespace Sci
diff --git a/engines/sci/graphics/maciconbar.h b/engines/sci/graphics/maciconbar.h
new file mode 100644
index 0000000000..668e033f6c
--- /dev/null
+++ b/engines/sci/graphics/maciconbar.h
@@ -0,0 +1,55 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef SCI_GRAPHICS_MACICONBAR_H
+#define SCI_GRAPHICS_MACICONBAR_H
+
+#include "common/array.h"
+
+#include "sci/engine/vm.h"
+
+namespace Graphics {
+ class Surface;
+}
+
+namespace Sci {
+
+class MacIconBar {
+public:
+ MacIconBar() {}
+ ~MacIconBar() {}
+
+ void addIcon(reg_t obj);
+ void drawIcons();
+
+private:
+ Common::Array<reg_t> _iconBarObjects;
+
+ void remapColors(Graphics::Surface *surf, byte *palette);
+};
+
+} // End of namespace Sci
+
+#endif
diff --git a/engines/sci/graphics/palette.cpp b/engines/sci/graphics/palette.cpp
index 96bdb42007..841202abce 100644
--- a/engines/sci/graphics/palette.cpp
+++ b/engines/sci/graphics/palette.cpp
@@ -30,8 +30,9 @@
#include "sci/sci.h"
#include "sci/engine/state.h"
-#include "sci/graphics/screen.h"
+#include "sci/graphics/maciconbar.h"
#include "sci/graphics/palette.h"
+#include "sci/graphics/screen.h"
namespace Sci {
@@ -311,6 +312,10 @@ void GfxPalette::setOnScreen() {
if (_resMan->isAmiga32color())
return;
_screen->setPalette(&_sysPalette);
+
+ // Redraw the Mac SCI1.1 Icon bar every palette change
+ if (g_sci->_macIconBar)
+ g_sci->_macIconBar->drawIcons();
}
bool GfxPalette::kernelSetFromResource(GuiResourceId resourceId, bool force) {
diff --git a/engines/sci/graphics/screen.cpp b/engines/sci/graphics/screen.cpp
index 7ca9e33509..0e054d5a76 100644
--- a/engines/sci/graphics/screen.cpp
+++ b/engines/sci/graphics/screen.cpp
@@ -93,7 +93,18 @@ GfxScreen::GfxScreen(ResourceManager *resMan, int16 width, int16 height, int ups
}
// Initialize the actual screen
- initGraphics(_displayWidth, _displayHeight, _displayWidth > 320);
+
+ if (_resMan->isSci11Mac() && getSciVersion() == SCI_VERSION_1_1) {
+ // For SCI1.1 Mac, we need to expand the screen to accommodate for
+ // the icon bar. Of course, both KQ6 and QFG1 VGA differ in size.
+ if (!scumm_stricmp(g_sci->getGameID(), "kq6"))
+ initGraphics(_displayWidth, _displayHeight + 26, _displayWidth > 320);
+ else if (!scumm_stricmp(g_sci->getGameID(), "qfg1"))
+ initGraphics(_displayWidth, _displayHeight + 20, _displayWidth > 320);
+ else
+ error("Unknown SCI1.1 Mac game");
+ } else
+ initGraphics(_displayWidth, _displayHeight, _displayWidth > 320);
}
GfxScreen::~GfxScreen() {