aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/sherlock/graphics.cpp84
-rw-r--r--engines/sherlock/graphics.h29
-rw-r--r--engines/sherlock/module.mk1
-rw-r--r--engines/sherlock/screen.cpp107
-rw-r--r--engines/sherlock/screen.h61
-rw-r--r--engines/sherlock/sherlock.h2
-rw-r--r--engines/sherlock/sprite.cpp2
7 files changed, 171 insertions, 115 deletions
diff --git a/engines/sherlock/graphics.cpp b/engines/sherlock/graphics.cpp
index fbfd3b7b45..23d3b443e8 100644
--- a/engines/sherlock/graphics.cpp
+++ b/engines/sherlock/graphics.cpp
@@ -77,88 +77,4 @@ void Surface::fillRect(int x1, int y1, int x2, int y2, byte color) {
Graphics::Surface::fillRect(Common::Rect(x1, y1, x2, y2), color);
}
-void Surface::drawSprite(int x, int y, SpriteFrame *spriteFrame, bool flipped, bool altFlag) {
-
-
-}
-
-/*----------------------------------------------------------------*/
-
-Screen::Screen(SherlockEngine *vm) : Surface(SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT), _vm(vm),
- _backBuffer1(SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT),
- _backBuffer2(SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT) {
- setFont(1);
-}
-
-void Screen::setFont(int fontNumber) {
- _fontNumber = fontNumber;
- Common::String fname = Common::String::format("FONT%d.VGS", fontNumber);
- Common::SeekableReadStream *stream = _vm->_res->load(fname);
-
- debug("TODO: Loading font %s, size - %d", fname.c_str(), stream->size());
-
- delete stream;
-}
-
-void Screen::update() {
- g_system->copyRectToScreen(getPixels(), this->w, 0, 0, this->w, this->h);
- g_system->updateScreen();
-}
-
-void Screen::getPalette(byte palette[PALETTE_SIZE]) {
- g_system->getPaletteManager()->grabPalette(palette, 0, PALETTE_COUNT);
-}
-
-void Screen::setPalette(const byte palette[PALETTE_SIZE]) {
- g_system->getPaletteManager()->setPalette(palette, 0, PALETTE_COUNT);
-}
-
-int Screen::equalizePalette(const byte palette[PALETTE_SIZE]) {
- int total = 0;
- byte tempPalette[PALETTE_SIZE];
- getPalette(tempPalette);
-
- // For any palette component that doesn't already match the given destination
- // palette, change by 1 towards the reference palette component
- for (int idx = 0; idx < PALETTE_SIZE; ++idx) {
- if (tempPalette[idx] > palette[idx])
- {
- --tempPalette[idx];
- ++total;
- } else if (tempPalette[idx] < palette[idx]) {
- ++tempPalette[idx];
- ++total;
- }
- }
-
- if (total > 0)
- // Palette changed, so reload it
- setPalette(tempPalette);
-
- return total;
-}
-
-void Screen::fadeToBlack() {
- const int FADE_AMOUNT = 2;
- bool repeatFlag;
- byte *srcP;
- int count;
- byte tempPalette[PALETTE_SIZE];
-
- getPalette(tempPalette);
- do {
- repeatFlag = false;
- for (srcP = &tempPalette[0], count = 0; count < PALETTE_SIZE; ++count, ++srcP) {
- int v = *srcP;
- if (v) {
- repeatFlag = true;
- *srcP = MAX(*srcP - FADE_AMOUNT, 0);
- }
- }
-
- setPalette(tempPalette);
- _vm->_events->pollEventsAndWait();
- } while (repeatFlag && !_vm->shouldQuit());
-}
-
} // End of namespace Sherlock
diff --git a/engines/sherlock/graphics.h b/engines/sherlock/graphics.h
index 79cffa839a..1765cf04ae 100644
--- a/engines/sherlock/graphics.h
+++ b/engines/sherlock/graphics.h
@@ -26,15 +26,8 @@
#include "common/rect.h"
#include "graphics/surface.h"
-#include "sherlock/sprite.h"
-
namespace Sherlock {
-#define PALETTE_SIZE 768
-#define PALETTE_COUNT 256
-
-class SherlockEngine;
-
class Surface : public Graphics::Surface {
protected:
virtual void addDirtyRect(const Common::Rect &r) {}
@@ -46,28 +39,6 @@ public:
void copyFrom(const Graphics::Surface &src, const Common::Point &pt);
void fillRect(int x1, int y1, int x2, int y2, byte color);
- void drawSprite(int x, int y, SpriteFrame *spriteFrame, bool flipped = false, bool altFlag = false);
-};
-
-class Screen : public Surface {
-private:
- SherlockEngine *_vm;
- int _fontNumber;
- Surface _backBuffer1, _backBuffer2;
-public:
- Screen(SherlockEngine *vm);
-
- void setFont(int fontNumber);
-
- void update();
-
- void getPalette(byte palette[PALETTE_SIZE]);
-
- void setPalette(const byte palette[PALETTE_SIZE]);
-
- int equalizePalette(const byte palette[PALETTE_SIZE]);
-
- void fadeToBlack();
};
} // End of namespace Sherlock
diff --git a/engines/sherlock/module.mk b/engines/sherlock/module.mk
index 7009f49d3f..06186f1504 100644
--- a/engines/sherlock/module.mk
+++ b/engines/sherlock/module.mk
@@ -12,6 +12,7 @@ MODULE_OBJS = \
journal.o \
resources.o \
room.o \
+ screen.o \
sherlock.o \
sound.o \
sprite.o \
diff --git a/engines/sherlock/screen.cpp b/engines/sherlock/screen.cpp
new file mode 100644
index 0000000000..d3fe68e367
--- /dev/null
+++ b/engines/sherlock/screen.cpp
@@ -0,0 +1,107 @@
+/* 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.
+ *
+ */
+
+#include "sherlock/screen.h"
+#include "sherlock/sherlock.h"
+#include "common/system.h"
+#include "graphics/palette.h"
+
+namespace Sherlock {
+
+Screen::Screen(SherlockEngine *vm) : Surface(SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT), _vm(vm),
+ _backBuffer1(SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT),
+ _backBuffer2(SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT) {
+ setFont(1);
+}
+
+void Screen::setFont(int fontNumber) {
+ _fontNumber = fontNumber;
+ Common::String fname = Common::String::format("FONT%d.VGS", fontNumber);
+ Common::SeekableReadStream *stream = _vm->_res->load(fname);
+
+ debug("TODO: Loading font %s, size - %d", fname.c_str(), stream->size());
+
+ delete stream;
+}
+
+void Screen::update() {
+ g_system->copyRectToScreen(getPixels(), this->w, 0, 0, this->w, this->h);
+ g_system->updateScreen();
+}
+
+void Screen::getPalette(byte palette[PALETTE_SIZE]) {
+ g_system->getPaletteManager()->grabPalette(palette, 0, PALETTE_COUNT);
+}
+
+void Screen::setPalette(const byte palette[PALETTE_SIZE]) {
+ g_system->getPaletteManager()->setPalette(palette, 0, PALETTE_COUNT);
+}
+
+int Screen::equalizePalette(const byte palette[PALETTE_SIZE]) {
+ int total = 0;
+ byte tempPalette[PALETTE_SIZE];
+ getPalette(tempPalette);
+
+ // For any palette component that doesn't already match the given destination
+ // palette, change by 1 towards the reference palette component
+ for (int idx = 0; idx < PALETTE_SIZE; ++idx) {
+ if (tempPalette[idx] > palette[idx])
+ {
+ --tempPalette[idx];
+ ++total;
+ } else if (tempPalette[idx] < palette[idx]) {
+ ++tempPalette[idx];
+ ++total;
+ }
+ }
+
+ if (total > 0)
+ // Palette changed, so reload it
+ setPalette(tempPalette);
+
+ return total;
+}
+
+void Screen::fadeToBlack() {
+ const int FADE_AMOUNT = 2;
+ bool repeatFlag;
+ byte *srcP;
+ int count;
+ byte tempPalette[PALETTE_SIZE];
+
+ getPalette(tempPalette);
+ do {
+ repeatFlag = false;
+ for (srcP = &tempPalette[0], count = 0; count < PALETTE_SIZE; ++count, ++srcP) {
+ int v = *srcP;
+ if (v) {
+ repeatFlag = true;
+ *srcP = MAX(*srcP - FADE_AMOUNT, 0);
+ }
+ }
+
+ setPalette(tempPalette);
+ _vm->_events->pollEventsAndWait();
+ } while (repeatFlag && !_vm->shouldQuit());
+}
+
+} // End of namespace Sherlock
diff --git a/engines/sherlock/screen.h b/engines/sherlock/screen.h
new file mode 100644
index 0000000000..3d1ad785e6
--- /dev/null
+++ b/engines/sherlock/screen.h
@@ -0,0 +1,61 @@
+/* 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.
+ *
+ */
+
+#ifndef SHERLOCK_SCREEN_H
+#define SHERLOCK_SCREEN_H
+
+#include "common/rect.h"
+#include "graphics/surface.h"
+
+#include "sherlock/graphics.h"
+
+namespace Sherlock {
+
+#define PALETTE_SIZE 768
+#define PALETTE_COUNT 256
+
+class SherlockEngine;
+
+class Screen : public Surface {
+private:
+ SherlockEngine *_vm;
+ int _fontNumber;
+ Surface _backBuffer1, _backBuffer2;
+public:
+ Screen(SherlockEngine *vm);
+
+ void setFont(int fontNumber);
+
+ void update();
+
+ void getPalette(byte palette[PALETTE_SIZE]);
+
+ void setPalette(const byte palette[PALETTE_SIZE]);
+
+ int equalizePalette(const byte palette[PALETTE_SIZE]);
+
+ void fadeToBlack();
+};
+
+} // End of namespace Sherlock
+
+#endif
diff --git a/engines/sherlock/sherlock.h b/engines/sherlock/sherlock.h
index b04a14e8ac..8d24a78c81 100644
--- a/engines/sherlock/sherlock.h
+++ b/engines/sherlock/sherlock.h
@@ -33,10 +33,10 @@
#include "sherlock/animation.h"
#include "sherlock/debugger.h"
#include "sherlock/events.h"
-#include "sherlock/graphics.h"
#include "sherlock/journal.h"
#include "sherlock/resources.h"
#include "sherlock/room.h"
+#include "sherlock/screen.h"
#include "sherlock/sound.h"
#include "sherlock/talk.h"
diff --git a/engines/sherlock/sprite.cpp b/engines/sherlock/sprite.cpp
index 9883d078ae..ca70932155 100644
--- a/engines/sherlock/sprite.cpp
+++ b/engines/sherlock/sprite.cpp
@@ -21,7 +21,7 @@
*/
#include "sherlock/sprite.h"
-#include "sherlock/graphics.h"
+#include "sherlock/screen.h"
#include "common/debug.h"
namespace Sherlock {