diff options
author | Max Horn | 2002-12-26 01:47:40 +0000 |
---|---|---|
committer | Max Horn | 2002-12-26 01:47:40 +0000 |
commit | a43355a1bfedcf661f4bc75b396c9e499a3bf812 (patch) | |
tree | 7b6af355d268df341fcd609d47962560a4fbdd8f /scumm | |
parent | 7e7be4f6f3911c428449c727caa06a550fec6e3a (diff) | |
download | scummvm-rg350-a43355a1bfedcf661f4bc75b396c9e499a3bf812.tar.gz scummvm-rg350-a43355a1bfedcf661f4bc75b396c9e499a3bf812.tar.bz2 scummvm-rg350-a43355a1bfedcf661f4bc75b396c9e499a3bf812.zip |
reuse the old (ugly nasty dreaded) string system for V8, too (by supplying a NUT based CharsetRenderer)
svn-id: r6162
Diffstat (limited to 'scumm')
-rw-r--r-- | scumm/charset.cpp | 76 | ||||
-rw-r--r-- | scumm/charset.h | 16 | ||||
-rw-r--r-- | scumm/intern.h | 3 | ||||
-rw-r--r-- | scumm/script_v8.cpp | 64 | ||||
-rw-r--r-- | scumm/scummvm.cpp | 14 |
5 files changed, 157 insertions, 16 deletions
diff --git a/scumm/charset.cpp b/scumm/charset.cpp index c1989832fb..57c242f71e 100644 --- a/scumm/charset.cpp +++ b/scumm/charset.cpp @@ -21,6 +21,7 @@ #include "stdafx.h" #include "charset.h" #include "scumm.h" +#include "nut_renderer.h" void CharsetRendererCommon::setCurID(byte id) { @@ -388,3 +389,78 @@ void CharsetRendererClassic::drawBits(VirtScreen *vs, byte *dst, byte *mask, int mask += _vm->gdi._numStrips; } } + +CharsetRendererNut::CharsetRendererNut(Scumm *vm) + : CharsetRenderer(vm) +{ + _current = 0; + + for (int i = 0; i < 4; i++) { + char fontname[256]; + sprintf(fontname, "resource/font%d.nut", i); + warning("Loading charset %s\n", fontname); + _fr[i] = new NutRenderer(_vm); + if (!(_fr[i]->loadFont(fontname, _vm->getGameDataPath()))) { + delete _fr[i]; + _fr[i] = NULL; + } + + _fr[i]->bindDisplay(_vm->virtscr[0].screenPtr, _vm->_realWidth, _vm->_realHeight, _vm->_realWidth); + } +} + +CharsetRendererNut::~CharsetRendererNut() +{ + for (int i = 0; i < 4; i++) + delete _fr[i]; +} + +void CharsetRendererNut::setCurID(byte id) +{ + assert(id < 4); + _curId = id; + _current = _fr[id]; +} + +int CharsetRendererNut::getCharWidth(byte chr) +{ + assert(_current); + return _current->getCharWidth(chr); +} + +int CharsetRendererNut::getFontHeight() +{ + // FIXME / TODO: how to implement this properly??? + assert(_current); + return _current->getCharHeight('|'); +} + +void CharsetRendererNut::printChar(int chr) +{ + assert(_current); + + if (chr == '@') + return; + + if (_firstChar) { + _strLeft = _left; + _strTop = _top; + _strRight = _left; + _strBottom = _top; + _firstChar = false; + } + + int width = _current->getCharWidth(chr); + int height = _current->getCharHeight(chr); + + _current->drawChar((char)chr, _left, _top, _color); + _vm->updateDirtyRect(0, _left, _left + width, _top, _top + height, 0); + + _left += width; + if (_left > _strRight) + _strRight = _left; + + if (_top + height > _strBottom) + _strBottom = _top + height; +} + diff --git a/scumm/charset.h b/scumm/charset.h index 15dc8ef4af..b5ad8cf5a5 100644 --- a/scumm/charset.h +++ b/scumm/charset.h @@ -24,6 +24,7 @@ #include "common/scummsys.h" class Scumm; +class NutRenderer; struct VirtScreen; class CharsetRenderer { @@ -46,6 +47,7 @@ public: protected: Scumm *_vm; + byte _curId; virtual int getCharWidth(byte chr) = 0; @@ -59,7 +61,7 @@ public: void addLinebreaks(int a, byte *str, int pos, int maxwidth); virtual void setCurID(byte id) = 0; - virtual int getCurID() = 0; + int getCurID() { return _curId; } virtual int getFontHeight() = 0; }; @@ -67,14 +69,12 @@ public: class CharsetRendererCommon : public CharsetRenderer { protected: - byte _curId; byte *_fontPtr; public: CharsetRendererCommon(Scumm *vm) : CharsetRenderer(vm) {} void setCurID(byte id); - int getCurID() { return _curId; } int getFontHeight() { return _fontPtr[1]; } }; @@ -104,20 +104,22 @@ public: void printChar(int chr); }; -/* -class CharsetRendererNUT : public CharsetRenderer { +class CharsetRendererNut : public CharsetRenderer { protected: int getCharWidth(byte chr); NutRenderer *_fr[4]; + NutRenderer *_current; public: - CharsetRendererNUT(Scumm *vm) : CharsetRenderer(vm) {} + CharsetRendererNut(Scumm *vm); + ~CharsetRendererNut(); void printChar(int chr); void setCurID(byte id); + + int getFontHeight(); }; -*/ #endif diff --git a/scumm/intern.h b/scumm/intern.h index d18235d2e0..9f2636eb26 100644 --- a/scumm/intern.h +++ b/scumm/intern.h @@ -407,9 +407,10 @@ protected: void decodeParseString(int m, int n); /* Version 8 Font Stuff */ +/* void loadCharset(int charset); NutRenderer *_fr[4]; - +*/ /* Version 8 script opcodes */ void o8_mod(); void o8_wait(); diff --git a/scumm/script_v8.cpp b/scumm/script_v8.cpp index c4b56256a6..984d8a031f 100644 --- a/scumm/script_v8.cpp +++ b/scumm/script_v8.cpp @@ -37,6 +37,7 @@ #define OPCODE(x) { &Scumm_v8::x, #x } +/* // FIXME: Move this somewhere better :) void Scumm_v8::loadCharset(int charset) { char fontname[256]; @@ -51,6 +52,7 @@ void Scumm_v8::loadCharset(int charset) { _fr[charset]->bindDisplay(virtscr[0].screenPtr, _realWidth, _realHeight, _realWidth); } +*/ void Scumm_v8::setupOpcodes() { @@ -528,6 +530,62 @@ void Scumm_v8::decodeParseString(int m, int n) break; case 0xD1: { +#if 1 + _messagePtr = _scriptPointer; + + if (_messagePtr[0] == '/') { + char pointer[20]; + int i, j; + + _scriptPointer += resStrLen((char*)_scriptPointer)+ 1; + translateText(_messagePtr, _transText); + for (i = 0, j = 0; (_messagePtr[i] != '/' || j == 0) && j < 19; i++) { + if (_messagePtr[i] != '/') + pointer[j++] = _messagePtr[i]; + } + pointer[j] = 0; + + // Stop any talking that's still going on + if (_sound->_talkChannel > -1) + _mixer->stop(_sound->_talkChannel); + +// _sound->_talkChannel = _sound->playBundleSound(pointer); + _messagePtr = _transText; + + switch (m) { + case 0: + actorTalk(); + break; + case 1: + drawString(1); + break; + case 2: + unkMessage1(); + break; + case 3: + unkMessage2(); + break; + } + return; + } else { + switch (m) { + case 0: + actorTalk(); + break; + case 1: + drawString(1); + break; + case 2: + unkMessage1(); + break; + case 3: + unkMessage2(); + break; + } + _scriptPointer = _messagePtr; + return; + } +#else char buffer[1024]; _messagePtr = _scriptPointer; @@ -579,6 +637,7 @@ void Scumm_v8::decodeParseString(int m, int n) x -= _fr[_string[m].charset]->getStringWidth(buffer) / 2; _fr[_string[m].charset]->drawString(buffer, x, _string[m].ypos, _string[m].color, 0); } +#endif break; } case 0xD2: // SO_PRINT_WRAP Set print wordwrap @@ -731,7 +790,7 @@ void Scumm_v8::o8_printSystem() void Scumm_v8::o8_blastText() { // FIXME - decodeParseString(2, 0); + decodeParseString(1, 0); } void Scumm_v8::o8_cursorCommand() @@ -789,7 +848,8 @@ void Scumm_v8::o8_cursorCommand() break; case 0xE7: { // SO_CHARSET_SET int charset = pop(); - loadCharset(charset); + warning("Set userface charset to %d\n", charset); +// loadCharset(charset); break; } case 0xE8: // SO_CHARSET_COLOR diff --git a/scumm/scummvm.cpp b/scumm/scummvm.cpp index 4e45dc9dc6..4eb975589e 100644 --- a/scumm/scummvm.cpp +++ b/scumm/scummvm.cpp @@ -207,8 +207,16 @@ void Scumm::scummInit() else _resourceHeaderSize = 8; + if (_features & GF_AFTER_V7) { + initScreens(0, 0, _realWidth, _realHeight); + } else { + initScreens(0, 16, _realWidth, 144); + } + if (_features & GF_OLD256) _charset = new CharsetRendererOld256(this); + else if (_features & GF_AFTER_V8) + _charset = new CharsetRendererNut(this); else _charset = new CharsetRendererClassic(this); @@ -217,12 +225,6 @@ void Scumm::scummInit() if (!(_features & GF_SMALL_NAMES) && !(_features & GF_AFTER_V8)) loadCharset(1); - if (_features & GF_AFTER_V7) { - initScreens(0, 0, _realWidth, _realHeight); - } else { - initScreens(0, 16, _realWidth, 144); - } - setShake(0); setupCursor(); |