seperated classic & old256 rendered (now subclasses of CharsetRenderer)

svn-id: r6152
This commit is contained in:
Max Horn 2002-12-25 21:57:01 +00:00
parent 2d46b1e4d7
commit a782a22c4d
4 changed files with 58 additions and 30 deletions

View File

@ -39,23 +39,28 @@ byte *CharsetRenderer::getFontPtr(byte id)
}
// do spacing for variable width old-style font
int CharsetRenderer::getSpacing(byte chr, byte *charset)
int CharsetRendererClassic::getSpacing(byte chr, byte *charset)
{
int spacing = 0;
int offs = READ_LE_UINT32(charset + chr * 4 + 4);
if (offs) {
spacing = charset[offs];
if (charset[offs + 2] >= 0x80) {
spacing += charset[offs + 2] - 0x100;
} else {
spacing += charset[offs + 2];
}
}
return spacing;
}
int CharsetRendererOld256::getSpacing(byte chr, byte *charset)
{
int spacing = 0;
if (_vm->_features & GF_OLD256) {
spacing = *(charset - 11 + chr);
} else {
int offs = READ_LE_UINT32(charset + chr * 4 + 4);
if (offs) {
spacing = charset[offs];
if (charset[offs + 2] >= 0x80) {
spacing += charset[offs + 2] - 0x100;
} else {
spacing += charset[offs + 2];
}
}
}
spacing = *(charset - 11 + chr);
// FIXME - this fixes the inventory icons in Zak256/Indy3
// see bug #613109.
@ -173,7 +178,7 @@ void CharsetRenderer::addLinebreaks(int a, byte *str, int pos, int maxwidth)
}
void CharsetRenderer::printCharOld(int chr)
void CharsetRendererOld256::printChar(int chr)
{ // Indy3 / Zak256
VirtScreen *vs;
byte *char_ptr, *dest_ptr;
@ -223,7 +228,7 @@ void CharsetRenderer::printCharOld(int chr)
}
void CharsetRenderer::printChar(int chr)
void CharsetRendererClassic::printChar(int chr)
{
int width, height;
int offsX, offsY;
@ -339,7 +344,7 @@ void CharsetRenderer::printChar(int chr)
_top -= offsY;
}
void CharsetRenderer::drawBits(VirtScreen *vs, byte *dst, byte *mask, int drawTop, int width, int height)
void CharsetRendererClassic::drawBits(VirtScreen *vs, byte *dst, byte *mask, int drawTop, int width, int height)
{
byte maskmask;
int y, x;

View File

@ -54,18 +54,15 @@ protected:
byte _curId;
byte *_fontPtr;
byte _bpp;
byte *_charPtr;
void drawBits(VirtScreen *vs, byte *dst, byte *mask, int drawTop, int width, int height);
byte *getFontPtr(byte id);
virtual int getSpacing(byte chr, byte *charset) = 0;
public:
CharsetRenderer(Scumm *vm) : _vm(vm) {}
void printChar(int chr);
void printCharOld(int chr);
int getSpacing(byte chr, byte *charset);
virtual void printChar(int chr) = 0;
int getStringWidth(int a, byte *str);
void addLinebreaks(int a, byte *str, int pos, int maxwidth);
@ -76,4 +73,30 @@ public:
};
class CharsetRendererClassic : public CharsetRenderer {
protected:
byte _bpp;
byte *_charPtr;
int getSpacing(byte chr, byte *charset);
void drawBits(VirtScreen *vs, byte *dst, byte *mask, int drawTop, int width, int height);
public:
CharsetRendererClassic(Scumm *vm) : CharsetRenderer(vm) {}
void printChar(int chr);
};
class CharsetRendererOld256 : public CharsetRenderer {
protected:
int getSpacing(byte chr, byte *charset);
public:
CharsetRendererOld256(Scumm *vm) : CharsetRenderer(vm) {}
void printChar(int chr);
};
#endif

View File

@ -1552,7 +1552,10 @@ void Scumm::mainRun()
void Scumm::launch()
{
_charset = new CharsetRenderer(this);
if (_features & GF_OLD256)
_charset = new CharsetRendererOld256(this);
else
_charset = new CharsetRendererClassic(this);
gdi._vm = this;

View File

@ -243,7 +243,7 @@ void Scumm::CHARSET_1()
_charset->_left = _charset->_nextLeft;
_charset->_top = _charset->_nextTop;
if (_features & GF_OLD256) {
_charset->printCharOld(c);
_charset->printChar(c);
} else if (_features & GF_AFTER_V6) {
if (!_noSubtitles || (_haveMsg != 0xFE && _haveMsg != 0xFF))
_charset->printChar(c);
@ -526,10 +526,7 @@ void Scumm::drawString(int a)
if (_string[a].no_talk_anim == 0)
_charset->_blitAlso = true;
}
if (_features & GF_OLD256)
_charset->printCharOld(chr);
else
_charset->printChar(chr);
_charset->printChar(chr);
_charset->_blitAlso = false;
}
}