aboutsummaryrefslogtreecommitdiff
path: root/engines/hugo
diff options
context:
space:
mode:
authorArnaud Boutonné2010-11-07 00:02:48 +0000
committerArnaud Boutonné2010-11-07 00:02:48 +0000
commita4cd83061eae135f17eefe15ee023817ec734250 (patch)
tree1d9b743baabf171c48e7b0fec46c1064c60f20bd /engines/hugo
parentf5d2695800473fa44500dc3fdaa92f9fcff844b9 (diff)
downloadscummvm-rg350-a4cd83061eae135f17eefe15ee023817ec734250.tar.gz
scummvm-rg350-a4cd83061eae135f17eefe15ee023817ec734250.tar.bz2
scummvm-rg350-a4cd83061eae135f17eefe15ee023817ec734250.zip
HUGO: Move fonts to display.cpp
Some cleanup svn-id: r54103
Diffstat (limited to 'engines/hugo')
-rw-r--r--engines/hugo/display.cpp14
-rw-r--r--engines/hugo/display.h10
-rw-r--r--engines/hugo/display_v1d.cpp23
-rw-r--r--engines/hugo/display_v1w.cpp13
-rw-r--r--engines/hugo/hugo.cpp40
-rw-r--r--engines/hugo/hugo.h2
6 files changed, 54 insertions, 48 deletions
diff --git a/engines/hugo/display.cpp b/engines/hugo/display.cpp
index e31edde166..db83f8debe 100644
--- a/engines/hugo/display.cpp
+++ b/engines/hugo/display.cpp
@@ -49,7 +49,10 @@ namespace Hugo {
#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), _palette(0) {
-
+ for (int j = 0; j < NUM_FONTS; j++) {
+ _arrayFont[j] = 0;
+ fontLoadedFl[j] = false;
+ }
}
Screen::~Screen() {
@@ -507,5 +510,14 @@ void Screen::freePalette() {
free(_palette);
}
+/**
+* Free fonts
+*/
+void Screen::freeFonts() {
+ for (int i = 0; i < NUM_FONTS; i++) {
+ if (_arrayFont[i])
+ free(_arrayFont[i]);
+ }
+}
} // End of namespace Hugo
diff --git a/engines/hugo/display.h b/engines/hugo/display.h
index 333f9a25df..ec9f29f016 100644
--- a/engines/hugo/display.h
+++ b/engines/hugo/display.h
@@ -50,6 +50,7 @@ public:
virtual ~Screen();
virtual void loadFont(int16 fontId) = 0;
+ virtual void loadFontArr(Common::File &in) = 0;
int16 fontHeight();
int16 stringLength(const char *s);
@@ -61,6 +62,7 @@ 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 freeFonts();
void freePalette();
void initDisplay();
void initNewScreenDisplay();
@@ -98,14 +100,18 @@ public:
protected:
HugoEngine *_vm;
+ bool fontLoadedFl[NUM_FONTS];
+
// Fonts used in dib (non-GDI)
+ byte *_arrayFont[NUM_FONTS];
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;
+ int16 _arrayFontSize[NUM_FONTS];
+
private:
viewdib_t _frontBuffer;
viewdib_t _backBuffer;
@@ -126,6 +132,7 @@ public:
~Screen_v1d();
void loadFont(int16 fontId);
+ void loadFontArr(Common::File &in);
};
class Screen_v1w : public Screen {
@@ -134,6 +141,7 @@ public:
~Screen_v1w();
void loadFont(int16 fontId);
+ void loadFontArr(Common::File &in);
};
} // End of namespace Hugo
diff --git a/engines/hugo/display_v1d.cpp b/engines/hugo/display_v1d.cpp
index df5ea636c6..28c8e4407a 100644
--- a/engines/hugo/display_v1d.cpp
+++ b/engines/hugo/display_v1d.cpp
@@ -54,19 +54,19 @@ Screen_v1d::~Screen_v1d() {
void Screen_v1d::loadFont(int16 fontId) {
debugC(2, kDebugDisplay, "loadFont(%d)", fontId);
- static bool fontLoadedFl[NUM_FONTS] = {false, false, false};
+ assert(fontId < NUM_FONTS);
_fnt = fontId - FIRST_FONT; // Set current font number
- if (fontLoadedFl[_fnt]) // If already loaded, return
+ if (fontLoadedFl[_fnt]) // If already loaded, return
return;
fontLoadedFl[_fnt] = true;
- memcpy(_fontdata[_fnt], _vm->_arrayFont[_fnt], _vm->_arrayFontSize[_fnt]);
+ memcpy(_fontdata[_fnt], _arrayFont[_fnt], _arrayFontSize[_fnt]);
_font[_fnt][0] = _fontdata[_fnt]; // Store height,width of fonts
- int16 offset = 2; // Start at fontdata[2] ([0],[1] used for height,width)
+ int16 offset = 2; // Start at fontdata[2] ([0],[1] used for height,width)
// Setup the font array (127 characters)
for (int i = 1; i < 128; i++) {
@@ -81,5 +81,20 @@ void Screen_v1d::loadFont(int16 fontId) {
offset += 2 + size;
}
}
+
+/**
+* Load fonts from Hugo.dat
+* These fonts are a workaround to avoid handling TTF fonts used by DOS versions
+* TODO: Properly handle the vector based font files (win31)
+*/
+void Screen_v1d::loadFontArr(Common::File &in) {
+ for (int i = 0; i < NUM_FONTS; i++) {
+ _arrayFontSize[i] = in.readUint16BE();
+ _arrayFont[i] = (byte *)malloc(sizeof(byte) * _arrayFontSize[i]);
+ for (int j = 0; j < _arrayFontSize[i]; j++) {
+ _arrayFont[i][j] = in.readByte();
+ }
+ }
+}
} // End of namespace Hugo
diff --git a/engines/hugo/display_v1w.cpp b/engines/hugo/display_v1w.cpp
index 773d592731..7cc94cc85a 100644
--- a/engines/hugo/display_v1w.cpp
+++ b/engines/hugo/display_v1w.cpp
@@ -53,8 +53,6 @@ Screen_v1w::~Screen_v1w() {
void Screen_v1w::loadFont(int16 fontId) {
debugC(2, kDebugDisplay, "loadFont(%d)", fontId);
- static bool fontLoadedFl[NUM_FONTS] = {false, false, false};
-
_fnt = fontId - FIRST_FONT; // Set current font number
if (fontLoadedFl[_fnt]) // If already loaded, return
@@ -81,5 +79,16 @@ void Screen_v1w::loadFont(int16 fontId) {
offset += 2 + size;
}
}
+
+/**
+* Skips the fonts used by the DOS versions
+*/
+void Screen_v1w::loadFontArr(Common::File &in) {
+ for (int i = 0; i < NUM_FONTS; i++) {
+ uint16 numElem = in.readUint16BE();
+ for (int j = 0; j < numElem; j++)
+ in.readByte();
+ }
+}
} // End of namespace Hugo
diff --git a/engines/hugo/hugo.cpp b/engines/hugo/hugo.cpp
index 5a8f8dcc98..0893fe0447 100644
--- a/engines/hugo/hugo.cpp
+++ b/engines/hugo/hugo.cpp
@@ -79,8 +79,6 @@ HugoEngine::HugoEngine(OSystem *syst, const HugoGameDescription *gd) : Engine(sy
DebugMan.addDebugChannel(kDebugInventory, "Inventory", "Inventory debug level");
DebugMan.addDebugChannel(kDebugObject, "Object", "Object debug level");
- for (int j = 0; j < NUM_FONTS; j++)
- _arrayFont[j] = 0;
}
HugoEngine::~HugoEngine() {
@@ -135,14 +133,7 @@ HugoEngine::~HugoEngine() {
free(_defltTunes);
free(_screenStates);
- if (_arrayFont[0])
- free(_arrayFont[0]);
-
- if (_arrayFont[1])
- free(_arrayFont[1]);
-
- if (_arrayFont[2])
- free(_arrayFont[2]);
+ _screen->freeFonts();
delete _object;
delete _sound;
@@ -729,35 +720,8 @@ bool HugoEngine::loadHugoDat() {
}
_scheduler->loadAlNewscrIndex(in);
+ _screen->loadFontArr(in);
- if (_gameVariant > 2) {
- _arrayFontSize[0] = in.readUint16BE();
- _arrayFont[0] = (byte *)malloc(sizeof(byte) * _arrayFontSize[0]);
- for (int j = 0; j < _arrayFontSize[0]; j++)
- _arrayFont[0][j] = in.readByte();
-
- _arrayFontSize[1] = in.readUint16BE();
- _arrayFont[1] = (byte *)malloc(sizeof(byte) * _arrayFontSize[1]);
- for (int j = 0; j < _arrayFontSize[1]; j++)
- _arrayFont[1][j] = in.readByte();
-
- _arrayFontSize[2] = in.readUint16BE();
- _arrayFont[2] = (byte *)malloc(sizeof(byte) * _arrayFontSize[2]);
- for (int j = 0; j < _arrayFontSize[2]; j++)
- _arrayFont[2][j] = in.readByte();
- } else {
- numElem = in.readUint16BE();
- for (int j = 0; j < numElem; j++)
- in.readByte();
-
- numElem = in.readUint16BE();
- for (int j = 0; j < numElem; j++)
- in.readByte();
-
- numElem = in.readUint16BE();
- for (int j = 0; j < numElem; j++)
- in.readByte();
- }
return true;
}
diff --git a/engines/hugo/hugo.h b/engines/hugo/hugo.h
index 19f86ac061..257ccd5833 100644
--- a/engines/hugo/hugo.h
+++ b/engines/hugo/hugo.h
@@ -126,8 +126,6 @@ public:
byte *_introX;
byte *_introY;
byte *_screenStates;
- byte *_arrayFont[3];
- int16 _arrayFontSize[3];
char **_textData;
char **_stringtData;
char **_screenNames;