diff options
author | Arnaud Boutonné | 2011-01-20 22:50:50 +0000 |
---|---|---|
committer | Arnaud Boutonné | 2011-01-20 22:50:50 +0000 |
commit | a321f2a007b325943750e78635bd93465cfa96bf (patch) | |
tree | 0f0cdf18f8d6508c3b31f378dfc5a417988c5e59 /engines/hugo/display.cpp | |
parent | 6412b1d2c70bd6a611ad1bfdac8437b9adc38738 (diff) | |
download | scummvm-rg350-a321f2a007b325943750e78635bd93465cfa96bf.tar.gz scummvm-rg350-a321f2a007b325943750e78635bd93465cfa96bf.tar.bz2 scummvm-rg350-a321f2a007b325943750e78635bd93465cfa96bf.zip |
HUGO: Merge misc versions of display, intro and scheduler classes
svn-id: r55365
Diffstat (limited to 'engines/hugo/display.cpp')
-rw-r--r-- | engines/hugo/display.cpp | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/engines/hugo/display.cpp b/engines/hugo/display.cpp index 0c580c15cc..f55d2ede2a 100644 --- a/engines/hugo/display.cpp +++ b/engines/hugo/display.cpp @@ -594,5 +594,112 @@ void Screen::showCursor() { void Screen::hideCursor() { CursorMan.showMouse(false); } + +Screen_v1d::Screen_v1d(HugoEngine *vm) : Screen(vm) { +} + +Screen_v1d::~Screen_v1d() { +} + +/** +* 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_v1d::loadFont(int16 fontId) { + debugC(2, kDebugDisplay, "loadFont(%d)", fontId); + + assert(fontId < NUM_FONTS); + + _fnt = fontId - FIRST_FONT; // Set current font number + + if (fontLoadedFl[_fnt]) // If already loaded, return + return; + + fontLoadedFl[_fnt] = true; + + 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) + + // Setup the font array (127 characters) + for (int i = 1; i < 128; i++) { + _font[_fnt][i] = _fontdata[_fnt] + offset; + byte height = *(_fontdata[_fnt] + offset); + byte 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; + } +} + +/** +* 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(); + } + } +} + +Screen_v1w::Screen_v1w(HugoEngine *vm) : Screen(vm) { +} + +Screen_v1w::~Screen_v1w() { +} + +/** +* Load font file, construct font ptrs and reverse data bytes +*/ +void Screen_v1w::loadFont(int16 fontId) { + 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; + _vm->_file->readUIFItem(fontId, _fontdata[_fnt]); + + // Compile font ptrs. Note: First ptr points to height,width of font + _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++) { + _font[_fnt][i] = _fontdata[_fnt] + offset; + byte height = *(_fontdata[_fnt] + offset); + byte 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; + } +} + +/** +* 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 |