aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/hugo/display.cpp31
-rw-r--r--engines/hugo/display.h9
-rw-r--r--engines/hugo/hugo.cpp10
-rw-r--r--engines/hugo/hugo.h14
4 files changed, 41 insertions, 23 deletions
diff --git a/engines/hugo/display.cpp b/engines/hugo/display.cpp
index 6b182eafa6..e31edde166 100644
--- a/engines/hugo/display.cpp
+++ b/engines/hugo/display.cpp
@@ -48,7 +48,7 @@ namespace Hugo {
#define INY(Y, B) (Y >= B->y && Y <= B->y + B->dy)
#define OVERLAP(A, B) ((INX(A->x, B) || INX(A->x + A->dx, B) || INX(B->x, A) || INX(B->x + B->dx, A)) && (INY(A->y, B) || INY(A->y + A->dy, B) || INY(B->y, A) || INY(B->y + B->dy, A)))
-Screen::Screen(HugoEngine *vm) : _vm(vm) {
+Screen::Screen(HugoEngine *vm) : _vm(vm), _palette(0) {
}
@@ -58,7 +58,7 @@ Screen::~Screen() {
void Screen::createPal() {
debugC(1, kDebugDisplay, "createPal");
- g_system->setPalette(_vm->_palette, 0, NUM_COLORS);
+ g_system->setPalette(_palette, 0, NUM_COLORS);
}
/**
@@ -112,10 +112,10 @@ void Screen::remapPal(uint16 oldIndex, uint16 newIndex) {
byte pal[4];
- pal[0] = _vm->_palette[newIndex * 4 + 0];
- pal[1] = _vm->_palette[newIndex * 4 + 1];
- pal[2] = _vm->_palette[newIndex * 4 + 2];
- pal[3] = _vm->_palette[newIndex * 4 + 3];
+ pal[0] = _palette[newIndex * 4 + 0];
+ pal[1] = _palette[newIndex * 4 + 1];
+ pal[2] = _palette[newIndex * 4 + 2];
+ pal[3] = _palette[newIndex * 4 + 3];
g_system->setPalette(pal, oldIndex, 1);
}
@@ -488,5 +488,24 @@ void Screen::initNewScreenDisplay() {
// Stop premature object display in Display_list(D_DISPLAY)
_vm->getGameStatus().newScreenFl = true;
}
+
+/**
+* Load palette from Hugo.dat
+*/
+void Screen::loadPalette(Common::File &in) {
+ // Read palette
+ _paletteSize = in.readUint16BE();
+ _palette = (byte *)malloc(sizeof(byte) * _paletteSize);
+ for (int i = 0; i < _paletteSize; i++)
+ _palette[i] = in.readByte();
+}
+
+/**
+* Free palette
+*/
+void Screen::freePalette() {
+ free(_palette);
+}
+
} // End of namespace Hugo
diff --git a/engines/hugo/display.h b/engines/hugo/display.h
index d56f3e55aa..333f9a25df 100644
--- a/engines/hugo/display.h
+++ b/engines/hugo/display.h
@@ -61,8 +61,10 @@ public:
void drawRectangle(bool filledFl, uint16 x1, uint16 y1, uint16 x2, uint16 y2, int color);
void drawShape(int x, int y, int color1, int color2);
void drawStatusText();
+ void freePalette();
void initDisplay();
void initNewScreenDisplay();
+ void loadPalette(Common::File &in);
void moveImage(image_pt srcImage, uint16 x1, uint16 y1, uint16 dx, uint16 dy, uint16 width1, image_pt dstImage, uint16 x2, uint16 y2, uint16 width2);
void remapPal(uint16 oldIndex, uint16 newIndex);
void restorePal(Common::SeekableReadStream *f);
@@ -97,9 +99,12 @@ protected:
HugoEngine *_vm;
// Fonts used in dib (non-GDI)
- byte _fnt; // Current font number
- byte _fontdata[NUM_FONTS][FONTSIZE]; // Font data
+ byte _fnt; // Current font number
+ byte _fontdata[NUM_FONTS][FONTSIZE]; // Font data
byte *_font[NUM_FONTS][FONT_LEN]; // Ptrs to each char
+ byte *_palette;
+
+ byte _paletteSize;
private:
viewdib_t _frontBuffer;
diff --git a/engines/hugo/hugo.cpp b/engines/hugo/hugo.cpp
index ecdfc947d9..5a8f8dcc98 100644
--- a/engines/hugo/hugo.cpp
+++ b/engines/hugo/hugo.cpp
@@ -64,7 +64,7 @@ command_t _line; // Line of user text input
HugoEngine::HugoEngine(OSystem *syst, const HugoGameDescription *gd) : Engine(syst), _gameDescription(gd), _mouseX(0), _mouseY(0),
_textData(0), _stringtData(0), _screenNames(0), _textEngine(0), _textIntro(0), _textMouse(0), _textParser(0), _textSchedule(0),
_textUtil(0), _arrayNouns(0), _arrayVerbs(0), _arrayReqs(0), _hotspots(0), _invent(0), _uses(0), _catchallList(0),
- _backgroundObjects(0), _points(0), _cmdList(0), _screenActs(0), _heroImage(0), _defltTunes(0), _palette(0), _introX(0),
+ _backgroundObjects(0), _points(0), _cmdList(0), _screenActs(0), _heroImage(0), _defltTunes(0), _introX(0),
_introY(0), _maxInvent(0), _numBonuses(0), _numScreens(0), _tunesNbr(0), _soundSilence(0), _soundTest(0), _screenStates(0),
_numObj(0), _score(0), _maxscore(0), _backgroundObjectsSize(0), _screenActsSize(0), _usesSize(0)
@@ -96,7 +96,7 @@ HugoEngine::~HugoEngine() {
free(_arrayVerbs);
free(_screenNames);
- free(_palette);
+ _screen->freePalette();
free(_textEngine);
free(_textIntro);
free(_introX);
@@ -410,11 +410,7 @@ bool HugoEngine::loadHugoDat() {
// Read screenNames
_screenNames = loadTextsVariante(in, &_numScreens);
- // Read palette
- _paletteSize = in.readUint16BE();
- _palette = (byte *)malloc(sizeof(byte) * _paletteSize);
- for (int i = 0; i < _paletteSize; i++)
- _palette[i] = in.readByte();
+ _screen->loadPalette(in);
// Read textEngine
_textEngine = loadTexts(in);
diff --git a/engines/hugo/hugo.h b/engines/hugo/hugo.h
index 815ef2b75e..19f86ac061 100644
--- a/engines/hugo/hugo.h
+++ b/engines/hugo/hugo.h
@@ -123,7 +123,6 @@ public:
byte *_screen_p;
byte _heroImage;
- byte *_palette;
byte *_introX;
byte *_introY;
byte *_screenStates;
@@ -262,7 +261,6 @@ protected:
private:
int _mouseX;
int _mouseY;
- byte _paletteSize;
byte _introXSize;
status_t _status; // Game status structure
@@ -275,17 +273,17 @@ private:
// Vinterstum: These shouldn't be static, but we get weird pathfinding issues (and Valgrind warnings) without.
// Needs more investigation. Alignment issues?
- static overlay_t _boundary; // Boundary overlay file
- static overlay_t _overlay; // First overlay file
- static overlay_t _ovlBase; // First overlay base file
- static overlay_t _objBound; // Boundary file marks object baselines
+ static overlay_t _boundary; // Boundary overlay file
+ static overlay_t _overlay; // First overlay file
+ static overlay_t _ovlBase; // First overlay base file
+ static overlay_t _objBound; // Boundary file marks object baselines
GameType _gameType;
Common::Platform _platform;
bool _packedFl;
- int _score; // Holds current score
- int _maxscore; // Holds maximum score
+ int _score; // Holds current score
+ int _maxscore; // Holds maximum score
char **loadTextsVariante(Common::File &in, uint16 *arraySize);
char ***loadTextsArray(Common::File &in);