aboutsummaryrefslogtreecommitdiff
path: root/engines/mortevielle
diff options
context:
space:
mode:
authorPaul Gilbert2012-01-17 22:30:00 +1100
committerStrangerke2012-04-06 08:19:48 +0200
commit8c423fd790cfb200852d5de4a707817f07489195 (patch)
tree79a6bc9add4c3f2d55142d128853b5d0c73efecb /engines/mortevielle
parent6ac925fb1f05636c4d10aee5fdb17e1aef3f5020 (diff)
downloadscummvm-rg350-8c423fd790cfb200852d5de4a707817f07489195.tar.gz
scummvm-rg350-8c423fd790cfb200852d5de4a707817f07489195.tar.bz2
scummvm-rg350-8c423fd790cfb200852d5de4a707817f07489195.zip
MORTEVIELLE: Create a basic palette manager class
Diffstat (limited to 'engines/mortevielle')
-rw-r--r--engines/mortevielle/graphics.cpp50
-rw-r--r--engines/mortevielle/graphics.h6
-rw-r--r--engines/mortevielle/mortevielle.cpp7
-rw-r--r--engines/mortevielle/mortevielle.h1
4 files changed, 59 insertions, 5 deletions
diff --git a/engines/mortevielle/graphics.cpp b/engines/mortevielle/graphics.cpp
index d7ed056ef7..8e4ad338df 100644
--- a/engines/mortevielle/graphics.cpp
+++ b/engines/mortevielle/graphics.cpp
@@ -22,6 +22,7 @@
#include "common/endian.h"
#include "common/system.h"
+#include "graphics/palette.h"
#include "mortevielle/graphics.h"
#include "mortevielle/mortevielle.h"
#include "mortevielle/mouse.h"
@@ -30,6 +31,52 @@
namespace Mortevielle {
/*-------------------------------------------------------------------------*
+ * Palette Manager
+ *
+ *-------------------------------------------------------------------------*/
+
+/**
+ * Set palette entries from the 64 colour available EGA palette
+ */
+void PaletteManager::setPalette(const int *palette, uint idx, uint size) {
+ assert((idx + size) <= 16);
+
+ // Build up the EGA palette
+ byte egaPalette[64 * 3];
+
+ byte *p = &egaPalette[0];
+ for (int i = 0; i < 64; i++) {
+ *p++ = (i >> 2 & 1) * 42 + (i >> 5 & 1) * 21;
+ *p++ = (i >> 1 & 1) * 42 + (i >> 4 & 1) * 21;
+ *p++ = (i & 1) * 42 + (i >> 3 & 1) * 21;
+ }
+
+ // Loop through setting palette colours based on the passed indexes
+ for (; size > 0; --size, ++idx) {
+ int palIndex = palette[idx];
+ assert(palIndex < 64);
+
+ const byte *pRgb = (const byte *)&egaPalette[palIndex];
+ g_system->getPaletteManager()->setPalette(pRgb, idx, 1);
+ }
+}
+
+/**
+ * Set the default EGA palette
+ */
+void PaletteManager::setDefaultPalette() {
+/*
+ int defaultPalette[16] = { 0, 1, 2, 3, 4, 5, 7, 20, 56, 57, 58, 59, 60, 61, 62, 63 };
+ setPalette(defaultPalette, 0, 16);
+*/
+ // TODO: Replace with proper palette
+ for (int idx = 0; idx < 16; ++idx) {
+ uint32 c = 0x111111 * idx;
+ g_system->getPaletteManager()->setPalette((const byte *)&c, idx, 1);
+ }
+}
+
+/*-------------------------------------------------------------------------*
* Image decoding
*
* The code in this section is responsible for decoding image resources.
@@ -939,6 +986,9 @@ void ScreenSurface::drawBox(int x, int y, int dx, int dy, int col) {
destSurface.vLine(1, 2, destSurface.h - 3, col);
destSurface.vLine(dx - 1, 2, destSurface.h - 3, col);
destSurface.vLine(dx - 2, 2, destSurface.h - 3, col);
+
+ // TODO: Remove this once we have a proper game loop
+ updateScreen();
}
diff --git a/engines/mortevielle/graphics.h b/engines/mortevielle/graphics.h
index 78c1637e58..f5c2207a12 100644
--- a/engines/mortevielle/graphics.h
+++ b/engines/mortevielle/graphics.h
@@ -30,6 +30,12 @@
namespace Mortevielle {
+class PaletteManager {
+public:
+ void setPalette(const int *palette, uint idx, uint size);
+ void setDefaultPalette();
+};
+
#define FONT_WIDTH 8
#define FONT_HEIGHT 6
#define FONT_NUM_CHARS 121
diff --git a/engines/mortevielle/mortevielle.cpp b/engines/mortevielle/mortevielle.cpp
index c302bfed78..8346c3f9e7 100644
--- a/engines/mortevielle/mortevielle.cpp
+++ b/engines/mortevielle/mortevielle.cpp
@@ -121,11 +121,8 @@ Common::Error MortevielleEngine::run() {
if (err != Common::kNoError)
return err;
- // TODO: Remove once palette loading is correctly done
- for (int idx = 0; idx < 16; ++idx) {
- uint32 c = 0x111111 * idx;
- g_system->getPaletteManager()->setPalette((const byte *)&c, idx, 1);
- }
+ // Set default palette
+ _paletteManager.setDefaultPalette();
// Dispatch to the game's main routine
const char *argv[] = { "" };
diff --git a/engines/mortevielle/mortevielle.h b/engines/mortevielle/mortevielle.h
index bcd6f666d0..816a4360cc 100644
--- a/engines/mortevielle/mortevielle.h
+++ b/engines/mortevielle/mortevielle.h
@@ -52,6 +52,7 @@ private:
void loadFont(Common::File &f);
public:
ScreenSurface _screenSurface;
+ PaletteManager _paletteManager;
public:
MortevielleEngine(OSystem *system, const ADGameDescription *gameDesc);
~MortevielleEngine();