based on my findings for guifont, I changed string.cpp to read the char width table for OLD256 games! yippi! some more code cleanup, and marked two struct values as 'to be removed when savegame format changes'
svn-id: r4978
This commit is contained in:
parent
f838473c25
commit
fcfc72296c
4 changed files with 45 additions and 87 deletions
|
@ -116,7 +116,7 @@ int main(int argc, char *argv[])
|
||||||
strcat(scummhome, "\\");
|
strcat(scummhome, "\\");
|
||||||
strcat(scummhome, DEFAULT_CONFIG_FILE);
|
strcat(scummhome, DEFAULT_CONFIG_FILE);
|
||||||
#else
|
#else
|
||||||
strcpy(scummhome,DEFAULT_CONFIG_FILE);
|
strcpy(scummhome, DEFAULT_CONFIG_FILE);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ public:
|
||||||
uint speedx, speedy;
|
uint speedx, speedy;
|
||||||
byte frame;
|
byte frame;
|
||||||
byte walkbox;
|
byte walkbox;
|
||||||
byte mask; // This field is *NOT* used anymore, only kept around to make saveload.cpp happy
|
byte mask; // FIXME: This field is *NOT* used - remove next time save game format changes
|
||||||
byte animProgress, animSpeed;
|
byte animProgress, animSpeed;
|
||||||
int16 new_1, new_2;
|
int16 new_1, new_2;
|
||||||
uint16 talk_script, walk_script;
|
uint16 talk_script, walk_script;
|
||||||
|
|
|
@ -197,7 +197,7 @@ struct CharsetRenderer {
|
||||||
|
|
||||||
int _bufPos;
|
int _bufPos;
|
||||||
byte _unk12, _disableOffsX;
|
byte _unk12, _disableOffsX;
|
||||||
byte *_ptr;
|
byte *_ptr; // FIXME: This field is *NOT* used - remove next time save game format changes
|
||||||
byte _unk2, _bpp;
|
byte _unk2, _bpp;
|
||||||
byte _invNumBits;
|
byte _invNumBits;
|
||||||
uint32 _charOffs;
|
uint32 _charOffs;
|
||||||
|
@ -220,7 +220,7 @@ struct CharsetRenderer {
|
||||||
void drawBits();
|
void drawBits();
|
||||||
void printChar(int chr);
|
void printChar(int chr);
|
||||||
void printCharOld(int chr);
|
void printCharOld(int chr);
|
||||||
int getSpacing(char chr);
|
int getSpacing(char chr, byte *charset);
|
||||||
int getStringWidth(int a, byte *str, int pos);
|
int getStringWidth(int a, byte *str, int pos);
|
||||||
void addLinebreaks(int a, byte *str, int pos, int maxwidth);
|
void addLinebreaks(int a, byte *str, int pos, int maxwidth);
|
||||||
};
|
};
|
||||||
|
|
120
scumm/string.cpp
120
scumm/string.cpp
|
@ -28,7 +28,7 @@
|
||||||
int CharsetRenderer::getStringWidth(int arg, byte *text, int pos)
|
int CharsetRenderer::getStringWidth(int arg, byte *text, int pos)
|
||||||
{
|
{
|
||||||
byte *ptr;
|
byte *ptr;
|
||||||
int width, offs, w;
|
int width;
|
||||||
byte chr;
|
byte chr;
|
||||||
|
|
||||||
width = 1;
|
width = 1;
|
||||||
|
@ -69,19 +69,7 @@ int CharsetRenderer::getStringWidth(int arg, byte *text, int pos)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_vm->_features & GF_OLD256) {
|
width += getSpacing(chr, ptr);
|
||||||
width += getSpacing(chr);
|
|
||||||
} else {
|
|
||||||
offs = READ_LE_UINT32(ptr + chr * 4 + 4);
|
|
||||||
if (offs) {
|
|
||||||
if (ptr[offs + 2] >= 0x80) {
|
|
||||||
w = ptr[offs + 2] - 0x100;
|
|
||||||
} else {
|
|
||||||
w = ptr[offs + 2];
|
|
||||||
}
|
|
||||||
width += ptr[offs] + w;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
@ -90,7 +78,6 @@ void CharsetRenderer::addLinebreaks(int a, byte *str, int pos, int maxwidth)
|
||||||
{
|
{
|
||||||
int lastspace = -1;
|
int lastspace = -1;
|
||||||
int curw = 1;
|
int curw = 1;
|
||||||
int offs, w;
|
|
||||||
byte *ptr;
|
byte *ptr;
|
||||||
byte chr;
|
byte chr;
|
||||||
|
|
||||||
|
@ -138,19 +125,7 @@ void CharsetRenderer::addLinebreaks(int a, byte *str, int pos, int maxwidth)
|
||||||
|
|
||||||
if (chr == ' ')
|
if (chr == ' ')
|
||||||
lastspace = pos - 1;
|
lastspace = pos - 1;
|
||||||
if (_vm->_features & GF_OLD256) {
|
curw += getSpacing(chr, ptr);
|
||||||
curw += getSpacing(chr);
|
|
||||||
} else {
|
|
||||||
offs = READ_LE_UINT32(ptr + chr * 4 + 4);
|
|
||||||
if (offs) {
|
|
||||||
if (ptr[offs + 2] >= 0x80) {
|
|
||||||
w = ptr[offs + 2] - 0x100;
|
|
||||||
} else {
|
|
||||||
w = ptr[offs + 2];
|
|
||||||
}
|
|
||||||
curw += w + ptr[offs];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (lastspace == -1)
|
if (lastspace == -1)
|
||||||
continue;
|
continue;
|
||||||
if (curw > maxwidth) {
|
if (curw > maxwidth) {
|
||||||
|
@ -431,7 +406,11 @@ void Scumm::CHARSET_1()
|
||||||
buffer += 2;
|
buffer += 2;
|
||||||
break;
|
break;
|
||||||
case 14: {
|
case 14: {
|
||||||
int oldy = getResourceAddress(rtCharset, charset._curId)[30];
|
int oldy;
|
||||||
|
if (_features & GF_SMALL_HEADER)
|
||||||
|
oldy = getResourceAddress(rtCharset, charset._curId)[18];
|
||||||
|
else
|
||||||
|
oldy = getResourceAddress(rtCharset, charset._curId)[30];
|
||||||
|
|
||||||
charset._curId = *buffer++;
|
charset._curId = *buffer++;
|
||||||
buffer += 2;
|
buffer += 2;
|
||||||
|
@ -440,6 +419,9 @@ void Scumm::CHARSET_1()
|
||||||
charset._colorMap[i] = _charsetData[charset._curId][i - 12];
|
charset._colorMap[i] = _charsetData[charset._curId][i - 12];
|
||||||
else
|
else
|
||||||
charset._colorMap[i] = _charsetData[charset._curId][i];
|
charset._colorMap[i] = _charsetData[charset._curId][i];
|
||||||
|
if (_features & GF_SMALL_HEADER)
|
||||||
|
charset._ypos2 -= getResourceAddress(rtCharset, charset._curId)[18] - oldy;
|
||||||
|
else
|
||||||
charset._ypos2 -= getResourceAddress(rtCharset, charset._curId)[30] - oldy;
|
charset._ypos2 -= getResourceAddress(rtCharset, charset._curId)[30] - oldy;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -828,6 +810,10 @@ void CharsetRenderer::printCharOld(int chr)
|
||||||
if (chr == '@')
|
if (chr == '@')
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
byte *ptr = _vm->getResourceAddress(rtCharset, _curId) + 29;
|
||||||
|
if (_vm->_features & GF_SMALL_HEADER)
|
||||||
|
ptr -= 12;
|
||||||
|
|
||||||
if (_unk12) {
|
if (_unk12) {
|
||||||
_strLeft = _left;
|
_strLeft = _left;
|
||||||
_strTop = _top;
|
_strTop = _top;
|
||||||
|
@ -851,7 +837,8 @@ void CharsetRenderer::printCharOld(int chr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_left += getSpacing(chr);
|
// FIXME
|
||||||
|
_left += getSpacing(chr, ptr);
|
||||||
|
|
||||||
if (_left > _strRight)
|
if (_left > _strRight)
|
||||||
_strRight = _left;
|
_strRight = _left;
|
||||||
|
@ -868,29 +855,30 @@ void CharsetRenderer::printChar(int chr)
|
||||||
VirtScreen *vs;
|
VirtScreen *vs;
|
||||||
|
|
||||||
_vm->checkRange(_vm->_maxCharsets - 1, 1, _curId, "Printing with bad charset %d");
|
_vm->checkRange(_vm->_maxCharsets - 1, 1, _curId, "Printing with bad charset %d");
|
||||||
|
|
||||||
if ((vs = _vm->findVirtScreen(_top)) == NULL)
|
if ((vs = _vm->findVirtScreen(_top)) == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (chr == '@')
|
if (chr == '@')
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_ptr = _vm->getResourceAddress(rtCharset, _curId) + 29;
|
byte *ptr = _vm->getResourceAddress(rtCharset, _curId) + 29;
|
||||||
if (_vm->_features & GF_SMALL_HEADER)
|
if (_vm->_features & GF_SMALL_HEADER)
|
||||||
_ptr -= 12;
|
ptr -= 12;
|
||||||
|
|
||||||
_bpp = _unk2 = *_ptr;
|
_bpp = _unk2 = *ptr;
|
||||||
_invNumBits = 8 - _bpp;
|
_invNumBits = 8 - _bpp;
|
||||||
_bitMask = 0xFF << _invNumBits;
|
_bitMask = 0xFF << _invNumBits;
|
||||||
_colorMap[1] = _color;
|
_colorMap[1] = _color;
|
||||||
|
|
||||||
_charOffs = READ_LE_UINT32(_ptr + chr * 4 + 4);
|
_charOffs = READ_LE_UINT32(ptr + chr * 4 + 4);
|
||||||
|
|
||||||
if (!_charOffs)
|
if (!_charOffs)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
assert(_charOffs < 0x10000);
|
assert(_charOffs < 0x10000);
|
||||||
|
|
||||||
_charPtr = _ptr + _charOffs;
|
_charPtr = ptr + _charOffs;
|
||||||
|
|
||||||
_width = _charPtr[0];
|
_width = _charPtr[0];
|
||||||
_height = _charPtr[1];
|
_height = _charPtr[1];
|
||||||
|
@ -950,23 +938,14 @@ void CharsetRenderer::printChar(int chr)
|
||||||
|
|
||||||
_vm->updateDirtyRect(vs->number, _left, right, _drawTop, _bottom, 0);
|
_vm->updateDirtyRect(vs->number, _left, right, _drawTop, _bottom, 0);
|
||||||
|
|
||||||
#if defined(OLD)
|
|
||||||
if (vs->number == 0)
|
|
||||||
_hasMask = true;
|
|
||||||
#else
|
|
||||||
if (vs->number != 0)
|
if (vs->number != 0)
|
||||||
_blitAlso = false;
|
_blitAlso = false;
|
||||||
if (vs->number == 0 && _blitAlso == 0)
|
if (vs->number == 0 && _blitAlso == 0)
|
||||||
_hasMask = true;
|
_hasMask = true;
|
||||||
#endif
|
|
||||||
|
|
||||||
_dest_ptr = _backbuff_ptr = vs->screenPtr + vs->xstart + _drawTop * _vm->_realWidth + _left;
|
_dest_ptr = _backbuff_ptr = vs->screenPtr + vs->xstart + _drawTop * _vm->_realWidth + _left;
|
||||||
|
|
||||||
#if !defined(OLD)
|
|
||||||
if (_blitAlso) {
|
if (_blitAlso) {
|
||||||
#else
|
|
||||||
if (1) {
|
|
||||||
#endif
|
|
||||||
_dest_ptr = _bgbak_ptr = _vm->getResourceAddress(rtBuffer, vs->number + 5)
|
_dest_ptr = _bgbak_ptr = _vm->getResourceAddress(rtBuffer, vs->number + 5)
|
||||||
+ vs->xstart + _drawTop * _vm->_realWidth + _left;
|
+ vs->xstart + _drawTop * _vm->_realWidth + _left;
|
||||||
}
|
}
|
||||||
|
@ -979,10 +958,8 @@ void CharsetRenderer::printChar(int chr)
|
||||||
|
|
||||||
drawBits();
|
drawBits();
|
||||||
|
|
||||||
#if !defined(OLD)
|
|
||||||
if (_blitAlso)
|
if (_blitAlso)
|
||||||
_vm->blit(_backbuff_ptr, _bgbak_ptr, _width, _height);
|
_vm->blit(_backbuff_ptr, _bgbak_ptr, _width, _height);
|
||||||
#endif
|
|
||||||
|
|
||||||
_left += _width;
|
_left += _width;
|
||||||
if (_left > _strRight)
|
if (_left > _strRight)
|
||||||
|
@ -1042,44 +1019,25 @@ void CharsetRenderer::drawBits()
|
||||||
}
|
}
|
||||||
|
|
||||||
// do spacing for variable width old-style font
|
// do spacing for variable width old-style font
|
||||||
int CharsetRenderer::getSpacing(char chr)
|
int CharsetRenderer::getSpacing(char chr, byte *ptr)
|
||||||
{
|
{
|
||||||
int space;
|
int spacing;
|
||||||
|
|
||||||
if (_curId == 1) {
|
if (_vm->_features & GF_OLD256) {
|
||||||
switch (chr) {
|
spacing = *(ptr - 11 + chr);
|
||||||
case '.':
|
} else {
|
||||||
case ':':
|
int offs = READ_LE_UINT32(ptr + chr * 4 + 4);
|
||||||
case ';':
|
if (offs) {
|
||||||
case 'i':
|
spacing = ptr[offs];
|
||||||
case '\'':
|
if (ptr[offs + 2] >= 0x80) {
|
||||||
case 'I':
|
spacing += ptr[offs + 2] - 0x100;
|
||||||
case '!':
|
} else {
|
||||||
space = 2;
|
spacing += ptr[offs + 2];
|
||||||
break;
|
|
||||||
case 'l':
|
|
||||||
space = 3;
|
|
||||||
break;
|
|
||||||
case ' ':
|
|
||||||
space = 4;
|
|
||||||
break;
|
|
||||||
case '(':
|
|
||||||
case ')':
|
|
||||||
space = 5;
|
|
||||||
break;
|
|
||||||
case 'W':
|
|
||||||
case 'w':
|
|
||||||
case 'N':
|
|
||||||
case 'M':
|
|
||||||
case 'm':
|
|
||||||
space = 8;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
space = 6;
|
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
space = 7;
|
}
|
||||||
return space;
|
|
||||||
|
return spacing;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scumm::loadLanguageBundle() {
|
void Scumm::loadLanguageBundle() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue