aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStrangerke2012-04-09 17:34:30 +0200
committerEugene Sandulenko2018-03-28 17:36:57 +0200
commit4ed7a101558cdd73e6b51132f19708bcd9251dd6 (patch)
tree14c27a02a27ec37adfb348dbb311685d4f54bd11
parent2acfb7e2b30a84ceb46dd6c86ec5cfccbd4db333 (diff)
downloadscummvm-rg350-4ed7a101558cdd73e6b51132f19708bcd9251dd6.tar.gz
scummvm-rg350-4ed7a101558cdd73e6b51132f19708bcd9251dd6.tar.bz2
scummvm-rg350-4ed7a101558cdd73e6b51132f19708bcd9251dd6.zip
LILLIPUT: Add default palette, and palette fixup (thanks to SylvainTV for the help)
-rw-r--r--engines/lilliput/lilliput.cpp97
-rw-r--r--engines/lilliput/lilliput.h13
2 files changed, 105 insertions, 5 deletions
diff --git a/engines/lilliput/lilliput.cpp b/engines/lilliput/lilliput.cpp
index a35f252fa8..a1d9ccec7f 100644
--- a/engines/lilliput/lilliput.cpp
+++ b/engines/lilliput/lilliput.cpp
@@ -36,6 +36,72 @@
namespace Lilliput {
LilliputEngine *LilliputEngine::s_Engine = 0;
+static const byte _basisPalette[768] = {
+ 0, 0, 0, 0, 0, 42, 0, 42, 0, 0, 42, 42,
+ 42, 0, 0, 42, 0, 42, 42, 21, 0, 42, 42, 42,
+ 21, 21, 21, 21, 21, 63, 21, 63, 21, 21, 63, 63,
+ 63, 21, 21, 63, 21, 63, 63, 63, 21, 63, 63, 63,
+ 63, 63, 63, 59, 59, 59, 54, 54, 54, 50, 50, 50,
+ 46, 46, 46, 42, 42, 42, 38, 38, 38, 33, 33, 33,
+ 29, 29, 29, 25, 25, 25, 21, 21, 21, 17, 17, 17,
+ 13, 13, 13, 8, 8, 8, 4, 4, 4, 0, 0, 0,
+ 63, 54, 54, 63, 46, 46, 63, 39, 39, 63, 31, 31,
+ 63, 23, 23, 63, 16, 16, 63, 8, 8, 63, 0, 0,
+ 57, 0, 0, 51, 0, 0, 45, 0, 0, 39, 0, 0,
+ 33, 0, 0, 28, 0, 0, 22, 0, 0, 16, 0, 0,
+ 63, 58, 54, 63, 54, 46, 63, 50, 39, 63, 46, 31,
+ 63, 42, 23, 63, 38, 16, 63, 34, 8, 63, 30, 0,
+ 57, 27, 0, 51, 24, 0, 45, 21, 0, 39, 19, 0,
+ 33, 16, 0, 28, 14, 0, 22, 11, 0, 16, 8, 0,
+ 63, 63, 54, 63, 63, 46, 63, 63, 39, 63, 63, 31,
+ 63, 62, 23, 63, 61, 16, 63, 61, 8, 63, 61, 0,
+ 57, 54, 0, 51, 49, 0, 45, 43, 0, 39, 39, 0,
+ 33, 33, 0, 28, 27, 0, 22, 21, 0, 16, 16, 0,
+ 62, 63, 54, 59, 61, 47, 56, 59, 42, 53, 58, 36,
+ 50, 56, 32, 47, 54, 26, 44, 52, 22, 41, 50, 17,
+ 36, 46, 14, 32, 42, 11, 28, 37, 8, 24, 33, 6,
+ 20, 29, 4, 16, 25, 2, 13, 20, 1, 10, 16, 0,
+ 54, 63, 54, 48, 61, 48, 43, 59, 43, 38, 58, 38,
+ 33, 56, 33, 29, 54, 29, 25, 52, 24, 21, 50, 20,
+ 16, 46, 16, 14, 42, 13, 10, 37, 9, 8, 33, 7,
+ 6, 29, 4, 4, 25, 2, 2, 20, 1, 1, 16, 0,
+ 59, 63, 63, 53, 63, 63, 47, 62, 63, 41, 61, 62,
+ 35, 60, 62, 30, 59, 62, 24, 57, 62, 18, 55, 62,
+ 20, 52, 56, 15, 47, 50, 11, 42, 45, 8, 37, 39,
+ 5, 32, 33, 3, 27, 27, 1, 22, 22, 0, 16, 16,
+ 54, 59, 63, 46, 56, 63, 39, 53, 63, 31, 50, 63,
+ 23, 47, 63, 16, 44, 63, 8, 42, 63, 0, 39, 63,
+ 0, 35, 57, 0, 31, 51, 0, 27, 45, 0, 23, 39,
+ 0, 19, 33, 0, 16, 28, 0, 12, 22, 0, 9, 16,
+ 54, 54, 63, 46, 47, 63, 39, 39, 63, 31, 32, 63,
+ 23, 24, 63, 16, 16, 63, 8, 9, 63, 0, 1, 63,
+ 0, 1, 57, 0, 1, 51, 0, 0, 45, 0, 0, 39,
+ 0, 0, 33, 0, 0, 28, 0, 0, 22, 0, 0, 16,
+ 54, 63, 54, 47, 63, 46, 39, 63, 39, 32, 63, 31,
+ 24, 63, 23, 16, 63, 16, 8, 63, 8, 0, 63, 0,
+ 0, 56, 0, 0, 49, 0, 0, 43, 0, 0, 36, 0,
+ 0, 30, 0, 0, 23, 0, 0, 16, 0, 0, 10, 0,
+ 63, 54, 63, 63, 46, 63, 63, 39, 63, 63, 31, 63,
+ 63, 23, 63, 63, 16, 63, 63, 8, 63, 63, 0, 63,
+ 56, 0, 57, 50, 0, 51, 45, 0, 45, 39, 0, 39,
+ 33, 0, 33, 27, 0, 28, 22, 0, 22, 16, 0, 16,
+ 63, 58, 55, 63, 56, 52, 63, 54, 49, 63, 53, 47,
+ 63, 51, 44, 63, 49, 41, 63, 47, 39, 63, 46, 36,
+ 63, 44, 32, 63, 41, 28, 63, 39, 24, 60, 37, 23,
+ 58, 35, 22, 55, 34, 21, 52, 32, 20, 50, 31, 19,
+ 47, 30, 18, 45, 28, 17, 42, 26, 16, 40, 25, 15,
+ 39, 24, 14, 36, 23, 13, 34, 22, 12, 32, 20, 11,
+ 29, 19, 10, 27, 18, 9, 23, 16, 8, 21, 15, 7,
+ 18, 14, 6, 16, 12, 6, 14, 11, 5, 10, 8, 3,
+ 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
+ 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
+ 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
+ 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
+ 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
+ 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
+ 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
+ 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63
+};
LilliputEngine::LilliputEngine(OSystem *syst, const LilliputGameDescription *gd) : Engine(syst), _gameDescription(gd)
{
@@ -96,8 +162,11 @@ byte *LilliputEngine::loadVGA(Common::String filename, bool loadPal) {
int remainingSize = f.size();
if (loadPal) {
for (int i = 0; i < 768; ++i)
- _palette[i] = f.readByte();
+ _curPalette[i] = f.readByte();
+
remainingSize -= 768;
+ fixPaletteEntries(_curPalette, 256);
+ _system->getPaletteManager()->setPalette(_curPalette, 0, 256);
}
uint8 curByte;
@@ -309,14 +378,37 @@ void LilliputEngine::loadRules() {
// Skipped: Load Savegame
}
+void LilliputEngine::fixPaletteEntries(uint8 *palette, int num) {
+ // Color values are coded on 6bits ( for old 6bits DAC )
+ for (int32 i = 0; i < num * 3; i++) {
+ int32 a = palette[i];
+ assert(a < 64);
+
+ a = (a << 2) | (a >> 4);
+ if (a > 255)
+ a = 255;
+ palette[i] = a;
+ }
+}
+
+void LilliputEngine::initPalette() {
+ for (int i = 0; i < 768; i++)
+ _curPalette[i] = _basisPalette[i];
+
+ fixPaletteEntries(_curPalette, 256);
+ _system->getPaletteManager()->setPalette(_curPalette, 0, 256);
+}
+
Common::Error LilliputEngine::run() {
s_Engine = this;
initGraphics(320, 200);
+ _mainSurface = new Graphics::Surface();
+ _mainSurface->create(320, 200, Graphics::PixelFormat::createFormatCLUT8());
// Setup mixer
syncSoundSettings();
- // TODO: Init Palette
+ initPalette();
// Load files. In the original, the size was hardcoded
_bufferIdeogram = loadVGA("IDEOGRAM.VGA", false);
@@ -333,6 +425,7 @@ Common::Error LilliputEngine::run() {
_scriptHandler->runScript(Common::MemoryReadStream(_rulesScript, _rulesScript_size));
//TODO: Main loop
+
return Common::kNoError;
}
diff --git a/engines/lilliput/lilliput.h b/engines/lilliput/lilliput.h
index e6cbe331b4..b73b5394fe 100644
--- a/engines/lilliput/lilliput.h
+++ b/engines/lilliput/lilliput.h
@@ -23,11 +23,14 @@
#ifndef LILLIPUT_LILLIPUT_H
#define LILLIPUT_LILLIPUT_H
-#include "engines/engine.h"
-#include "common/file.h"
#include "lilliput/console.h"
#include "lilliput/script.h"
+#include "common/file.h"
+#include "engines/engine.h"
+#include "graphics/palette.h"
+#include "graphics/surface.h"
+
namespace Common {
class RandomSource;
}
@@ -76,6 +79,7 @@ public:
Common::RandomSource *_rnd;
LilliputScript *_scriptHandler;
+ Graphics::Surface *_mainSurface;
struct18560 _arr18560[4];
byte _byte1714E;
@@ -95,7 +99,7 @@ public:
byte *_bufferIsoChars;
byte *_bufferIdeogram;
byte _buffer10[4032];
- byte _palette[768];
+ byte _curPalette[768];
bool _saveFlag;
@@ -159,6 +163,9 @@ public:
byte *loadRaw(Common::String filename);
void loadRules();
+ void initPalette();
+ void fixPaletteEntries(uint8 *palette, int num);
+
GameType getGameType() const;
Common::Platform getPlatform() const;