reuse the old (ugly nasty dreaded) string system for V8, too (by supplying a NUT based CharsetRenderer)

svn-id: r6162
This commit is contained in:
Max Horn 2002-12-26 01:47:40 +00:00
parent 7e7be4f6f3
commit a43355a1bf
5 changed files with 157 additions and 16 deletions

View File

@ -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;
}

View File

@ -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

View File

@ -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();

View File

@ -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

View File

@ -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();