aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorArnaud Boutonné2010-09-12 22:59:32 +0000
committerArnaud Boutonné2010-09-12 22:59:32 +0000
commit597eed026611eeaab6d992308677fa59b4f18908 (patch)
tree6a983b369c9577b10694ad32f9a79349828f356e /engines
parentf656ed2974175a45a1557300d8db91c1fddbba18 (diff)
downloadscummvm-rg350-597eed026611eeaab6d992308677fa59b4f18908.tar.gz
scummvm-rg350-597eed026611eeaab6d992308677fa59b4f18908.tar.bz2
scummvm-rg350-597eed026611eeaab6d992308677fa59b4f18908.zip
HUGO: Use fonts in HUGO.DAT for the DOS version
This is only a temporary solution, to be replaced by a proper .FON handling. Hugo 2 and 3 (dos) now start. svn-id: r52697
Diffstat (limited to 'engines')
-rw-r--r--engines/hugo/display.cpp45
-rw-r--r--engines/hugo/display.h14
-rw-r--r--engines/hugo/hugo.cpp47
-rw-r--r--engines/hugo/hugo.h4
-rw-r--r--engines/hugo/mouse.cpp3
-rw-r--r--engines/hugo/parser.cpp3
6 files changed, 108 insertions, 8 deletions
diff --git a/engines/hugo/display.cpp b/engines/hugo/display.cpp
index ddd193c2a6..7a42dd5cd0 100644
--- a/engines/hugo/display.cpp
+++ b/engines/hugo/display.cpp
@@ -453,4 +453,49 @@ void Screen::userHelp() {
"ESC - Return to game");
}
+Screen_v2::Screen_v2(HugoEngine &vm) : Screen(vm) {
+}
+
+Screen_v2::~Screen_v2() {
+}
+
+// Load font file, construct font ptrs and reverse data bytes
+// TODO: This uses hardcoded fonts in hugo.dat, it should be replaced
+// by a proper implementation of .FON files
+void Screen_v2::loadFont(int16 fontId) {
+ byte height, width;
+ static bool fontLoadedFl[NUM_FONTS] = {false, false, false};
+
+ debugC(2, kDebugDisplay, "loadFont(%d)", fontId);
+
+ _fnt = fontId - FIRST_FONT; // Set current font number
+
+ if (fontLoadedFl[_fnt]) // If already loaded, return
+ return;
+
+ fontLoadedFl[_fnt] = true;
+
+ memcpy(_fontdata[_fnt], _vm._arrayFont[_fnt], _vm._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)
+
+ // Setup the font array (127 characters)
+ for (int i = 1; i < 128; i++) {
+ if (i == 127)
+ i = i;
+
+ _font[_fnt][i] = _fontdata[_fnt] + offset;
+ height = *(_fontdata[_fnt] + offset);
+ width = *(_fontdata[_fnt] + offset + 1);
+
+ int16 size = height * ((width + 7) >> 3);
+ for (int j = 0; j < size; j++)
+ Utils::reverseByte(&_fontdata[_fnt][offset + 2 + j]);
+
+ offset += 2 + size;
+ }
+}
+
} // End of namespace Hugo
+
diff --git a/engines/hugo/display.h b/engines/hugo/display.h
index 5062664c18..14c5b0ebc5 100644
--- a/engines/hugo/display.h
+++ b/engines/hugo/display.h
@@ -49,7 +49,7 @@ public:
void displayList(dupdate_t update, ...);
void displayRect(int16 x, int16 y, int16 dx, int16 dy);
void initDisplay();
- void loadFont(int16 fontId);
+ virtual void loadFont(int16 fontId);
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);
@@ -76,7 +76,7 @@ public:
return _GUIBuffer;
}
-private:
+protected:
HugoEngine &_vm;
// Fonts used in dib (non-GDI)
@@ -84,6 +84,7 @@ private:
byte _fontdata[NUM_FONTS][FONTSIZE]; // Font data
byte *_font[NUM_FONTS][FONT_LEN]; // Ptrs to each char
+private:
viewdib_t _frontBuffer;
viewdib_t _backBuffer;
viewdib_t _GUIBuffer; // User interface images
@@ -98,6 +99,15 @@ private:
int16 center(char *s);
};
+class Screen_v2 : public Screen {
+public:
+ Screen_v2(HugoEngine &vm);
+ ~Screen_v2();
+
+ virtual void loadFont(int16 fontId);
+};
+
+
} // End of namespace Hugo
#endif //HUGO_DISPLAY_H
diff --git a/engines/hugo/hugo.cpp b/engines/hugo/hugo.cpp
index 316c16f018..6254488fbe 100644
--- a/engines/hugo/hugo.cpp
+++ b/engines/hugo/hugo.cpp
@@ -122,6 +122,15 @@ HugoEngine::~HugoEngine() {
free(_defltTunes);
free(_screenStates);
+
+ if (_arrayFont[0])
+ free(_arrayFont[0]);
+
+ if (_arrayFont[1])
+ free(_arrayFont[1]);
+
+ if (_arrayFont[2])
+ free(_arrayFont[2]);
}
GameType HugoEngine::getGameType() const {
@@ -140,7 +149,6 @@ Common::Error HugoEngine::run() {
s_Engine = this;
initGraphics(320, 200, false);
- _screen = new Screen(*this);
_mouseHandler = new MouseHandler(*this);
_inventoryHandler = new InventoryHandler(*this);
_parser = new Parser(*this);
@@ -152,31 +160,37 @@ Common::Error HugoEngine::run() {
_fileManager = new FileManager_v3(*this);
_scheduler = new Scheduler_v2(*this);
_introHandler = new intro_1w(*this);
+ _screen = new Screen(*this);
break;
case 1:
_fileManager = new FileManager_v2(*this);
_scheduler = new Scheduler_v2(*this);
_introHandler = new intro_2w(*this);
+ _screen = new Screen(*this);
break;
case 2:
_fileManager = new FileManager_v2(*this);
_scheduler = new Scheduler_v2(*this);
_introHandler = new intro_3w(*this);
+ _screen = new Screen(*this);
break;
case 3: // H1 DOS
_fileManager = new FileManager_v1(*this);
_scheduler = new Scheduler_v1(*this);
_introHandler = new intro_1d(*this);
+ _screen = new Screen_v2(*this);
break;
case 4:
_fileManager = new FileManager_v2(*this);
_scheduler = new Scheduler_v1(*this);
_introHandler = new intro_2d(*this);
+ _screen = new Screen_v2(*this);
break;
case 5:
_fileManager = new FileManager_v4(*this);
_scheduler = new Scheduler_v2(*this);
_introHandler = new intro_3d(*this);
+ _screen = new Screen_v2(*this);
break;
}
@@ -1332,6 +1346,37 @@ bool HugoEngine::loadHugoDat() {
_alNewscrIndex = numElem;
}
+ for (int j = 0; j < NUM_FONTS; j++)
+ _arrayFont[j] = 0;
+
+ 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 0ef001244b..5128d4e093 100644
--- a/engines/hugo/hugo.h
+++ b/engines/hugo/hugo.h
@@ -33,7 +33,7 @@
#include "hugo/game.h"
#define HUGO_DAT_VER_MAJ 0 // 1 byte
-#define HUGO_DAT_VER_MIN 21 // 1 byte
+#define HUGO_DAT_VER_MIN 22 // 1 byte
#define DATAALIGNMENT 4
namespace Common {
@@ -97,6 +97,8 @@ public:
byte *_introX;
byte *_introY;
byte *_screenStates;
+ byte *_arrayFont[3];
+ int16 _arrayFontSize[3];
char **_textData;
char **_stringtData;
char **_screenNames;
diff --git a/engines/hugo/mouse.cpp b/engines/hugo/mouse.cpp
index a3f695b92a..01df8f8ac9 100644
--- a/engines/hugo/mouse.cpp
+++ b/engines/hugo/mouse.cpp
@@ -67,8 +67,7 @@ void MouseHandler::cursorText(char *buffer, int16 cx, int16 cy, uif_t fontId, in
debugC(1, kDebugMouse, "cursorText(%s, %d, %d, %d, %d)", buffer, cx, cy, fontId, color);
- if (_vm.getPlatform() == Common::kPlatformWindows)
- _vm.screen().loadFont(fontId);
+ _vm.screen().loadFont(fontId);
// Find bounding rect for string
int16 sdx = _vm.screen().stringLength(buffer);
diff --git a/engines/hugo/parser.cpp b/engines/hugo/parser.cpp
index 33fd0ddfef..061e8e597d 100644
--- a/engines/hugo/parser.cpp
+++ b/engines/hugo/parser.cpp
@@ -197,8 +197,7 @@ void Parser::charHandler() {
void Parser::drawStatusText() {
debugC(4, kDebugParser, "drawStatusText");
- if (_vm.getPlatform() == Common::kPlatformWindows)
- _vm.screen().loadFont(U_FONT8);
+ _vm.screen().loadFont(U_FONT8);
uint16 sdx = _vm.screen().stringLength(_statusLine);
uint16 sdy = _vm.screen().fontHeight() + 1; // + 1 for shadow
uint16 posX = 0;