enabled RTL
fixed bad glyphs display for non french version got rid of Graphics::drawChar2 svn-id: r35006
This commit is contained in:
parent
edd61a4f40
commit
b7c9958e82
6 changed files with 84 additions and 64 deletions
|
@ -223,36 +223,23 @@ void Graphics::copyTo640(uint8 *dst, const uint8 *src, int w, int srcPitch, int
|
|||
}
|
||||
|
||||
void Graphics::drawStringChar(uint8 *dst, uint8 chr, int pitch, uint8 chrColor, const uint8 *src) {
|
||||
if (chr < 32 || chr - 32 >= kCharSet1CharsCount) {
|
||||
if (chr < 32 || chr - 32 >= _charset->xCount * _charset->yCount) {
|
||||
return;
|
||||
}
|
||||
int offset = (chr - 32) * kCharSet1CharSize;
|
||||
for (int y = 0; y < kCharSet1CharH; ++y) {
|
||||
for (int x = 0; x < kCharSet1CharW; ++x) {
|
||||
int offset = (chr - 32) * _charset->charH * _charset->charW;
|
||||
for (int y = 0; y < _charset->charH; ++y) {
|
||||
for (int x = 0; x < _charset->charW; ++x) {
|
||||
const int color = src[offset++];
|
||||
if (color != 0) {
|
||||
dst[x] = (color == 128) ? color : chrColor;
|
||||
if (_charset == &_creditsCharset) {
|
||||
dst[x] = color;
|
||||
} else {
|
||||
dst[x] = (color == 128) ? color : chrColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
dst += pitch;
|
||||
}
|
||||
}
|
||||
|
||||
void Graphics::drawStringChar2(uint8 *dst, uint8 chr, int pitch, uint8 chrColor, const uint8 *src) {
|
||||
if (chr < 32 || chr - 32 >= kCharSet2CharsCount) {
|
||||
return;
|
||||
}
|
||||
int offset = (chr - 32) * kCharSet2CharSize;
|
||||
for (int y = 0; y < kCharSet2CharH; ++y) {
|
||||
for (int x = 0; x < kCharSet2CharW; ++x) {
|
||||
const int color = src[offset++];
|
||||
if (color != 0) {
|
||||
dst[x] = color;
|
||||
}
|
||||
}
|
||||
dst += pitch;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace Tucker
|
||||
|
|
|
@ -30,20 +30,16 @@
|
|||
|
||||
namespace Tucker {
|
||||
|
||||
enum {
|
||||
kCharSet1CharW = 10,
|
||||
kCharSet1CharH = 10,
|
||||
kCharSet1CharSize = kCharSet1CharW * kCharSet1CharH,
|
||||
kCharSet1CharsCount = 32 * 7,
|
||||
kCharSet2CharW = 19,
|
||||
kCharSet2CharH = 10,
|
||||
kCharSet2CharSize = kCharSet2CharW * kCharSet2CharH,
|
||||
kCharSet2CharsCount = 16 * 6
|
||||
};
|
||||
|
||||
class Graphics {
|
||||
public:
|
||||
|
||||
struct Charset {
|
||||
int charW;
|
||||
int charH;
|
||||
int xCount;
|
||||
int yCount;
|
||||
};
|
||||
|
||||
static int encodeRLE(const uint8 *src, uint8 *dst, int w, int h);
|
||||
static int encodeRAW(const uint8 *src, uint8 *dst, int w, int h);
|
||||
|
||||
|
@ -57,6 +53,12 @@ public:
|
|||
|
||||
static void drawStringChar(uint8 *dst, uint8 chr, int pitch, uint8 chrColor, const uint8 *src);
|
||||
static void drawStringChar2(uint8 *dst, uint8 chr, int pitch, uint8 chrColor, const uint8 *src);
|
||||
|
||||
static const Charset _enCharset;
|
||||
static const Charset _frCharset;
|
||||
static const Charset _creditsCharset;
|
||||
|
||||
static const Charset *_charset;
|
||||
};
|
||||
|
||||
} // namespace Tucker
|
||||
|
|
|
@ -203,6 +203,10 @@ void TuckerEngine::openCompressedSoundFile() {
|
|||
}
|
||||
}
|
||||
|
||||
void TuckerEngine::closeCompressedSoundFile() {
|
||||
_fCompressedSound.close();
|
||||
}
|
||||
|
||||
void TuckerEngine::loadImage(uint8 *dst, int type) {
|
||||
int count = 0;
|
||||
Common::File f;
|
||||
|
@ -254,7 +258,8 @@ void TuckerEngine::loadCursor() {
|
|||
void TuckerEngine::loadCharset() {
|
||||
strcpy(_fileToLoad, "charset.pcx");
|
||||
loadImage(_loadTempBuf, 0);
|
||||
loadCharsetHelper(kCharSet1CharW, kCharSet1CharH, 32, 7);
|
||||
Graphics::_charset = (_lang == Common::FR_FRA) ? &Graphics::_frCharset : &Graphics::_enCharset;
|
||||
loadCharsetHelper();
|
||||
}
|
||||
|
||||
void TuckerEngine::loadCharset2() {
|
||||
|
@ -263,10 +268,15 @@ void TuckerEngine::loadCharset2() {
|
|||
memcpy(_charWidthTable + 65, _charWidthCharset2, 58);
|
||||
strcpy(_fileToLoad, "char2.pcx");
|
||||
loadImage(_loadTempBuf, 0);
|
||||
loadCharsetHelper(kCharSet2CharW, kCharSet2CharH, 16, 6);
|
||||
Graphics::_charset = &Graphics::_creditsCharset;
|
||||
loadCharsetHelper();
|
||||
}
|
||||
|
||||
void TuckerEngine::loadCharsetHelper(int charW, int charH, int xSize, int ySize) {
|
||||
void TuckerEngine::loadCharsetHelper() {
|
||||
const int charW = Graphics::_charset->charW;
|
||||
const int charH = Graphics::_charset->charH;
|
||||
const int xSize = Graphics::_charset->xCount;
|
||||
const int ySize = Graphics::_charset->yCount;
|
||||
int offset = 0;
|
||||
for (int y = 0; y < ySize; ++y) {
|
||||
for (int x = 0; x < xSize; ++x) {
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
*/
|
||||
|
||||
#include "tucker/tucker.h"
|
||||
#include "tucker/graphics.h"
|
||||
|
||||
namespace Tucker {
|
||||
|
||||
|
@ -233,4 +234,12 @@ const uint8 TuckerEngine::_charWidthCharset2[58] = {
|
|||
0x13, 0x12, 0x10, 0x11, 0x13, 0x14, 0x14, 0x10, 0x13, 0x10,
|
||||
};
|
||||
|
||||
const Graphics::Charset Graphics::_enCharset = { 10, 8, 32, 3 };
|
||||
|
||||
const Graphics::Charset Graphics::_frCharset = { 10, 10, 32, 7 };
|
||||
|
||||
const Graphics::Charset Graphics::_creditsCharset = { 19, 10, 16, 7 };
|
||||
|
||||
const Graphics::Charset *Graphics::_charset = 0;
|
||||
|
||||
} // namespace Tucker
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
namespace Tucker {
|
||||
|
||||
TuckerEngine::TuckerEngine(OSystem *system, Common::Language language)
|
||||
: Engine(system) {
|
||||
: Engine(system), _lang(language) {
|
||||
}
|
||||
|
||||
TuckerEngine::~TuckerEngine() {
|
||||
|
@ -53,6 +53,10 @@ Common::Error TuckerEngine::init() {
|
|||
return Common::kNoError;
|
||||
}
|
||||
|
||||
bool TuckerEngine::hasFeature(EngineFeature f) const {
|
||||
return (f == kSupportsRTL);
|
||||
}
|
||||
|
||||
Common::Error TuckerEngine::go() {
|
||||
mainLoop();
|
||||
return Common::kNoError;
|
||||
|
@ -469,30 +473,7 @@ void TuckerEngine::mainLoop() {
|
|||
if (_backgroundSpriteCurrentAnimation > -1 && _backgroundSpriteCurrentFrame > 0) {
|
||||
drawBackgroundSprites(0);
|
||||
} else {
|
||||
int offset;
|
||||
SpriteFrame *chr = &_spriteFramesTable[_currentSpriteAnimationFrame];
|
||||
if (_mirroredDrawing == 0) {
|
||||
offset = (_yPosCurrent + _mainSpritesBaseOffset - 54 + chr->yOffset) * 640 + _xPosCurrent;
|
||||
offset += chr->xOffset - 14;
|
||||
} else {
|
||||
offset = (_yPosCurrent + _mainSpritesBaseOffset - 54 + chr->yOffset) * 640 + _xPosCurrent;
|
||||
offset -= chr->xSize + chr->xOffset - 14;
|
||||
}
|
||||
Graphics::decodeRLE_248(_locationBackgroundGfxBuf + offset, _spritesGfxBuf + chr->sourceOffset, chr->xSize, chr->ySize,
|
||||
chr->yOffset, _locationHeightTable[_locationNum], _mirroredDrawing != 0);
|
||||
if (_currentSpriteAnimationLength > 1) {
|
||||
SpriteFrame *chr2 = &_spriteFramesTable[_currentSpriteAnimationFrame2];
|
||||
if (_mirroredDrawing == 0) {
|
||||
offset = (_yPosCurrent + _mainSpritesBaseOffset - 54 + chr2->yOffset) * 640 + _xPosCurrent;
|
||||
offset += chr2->xOffset - 14;
|
||||
} else {
|
||||
offset = (_yPosCurrent + _mainSpritesBaseOffset - 54 + chr2->yOffset) * 640 + _xPosCurrent;
|
||||
offset -= chr2->xSize + chr2->xOffset - 14;
|
||||
}
|
||||
Graphics::decodeRLE_248(_locationBackgroundGfxBuf + offset, _spritesGfxBuf + chr2->sourceOffset, chr2->xSize, chr2->ySize,
|
||||
_spriteFramesTable[_currentSpriteAnimationFrame].yOffset, // _currentCharacter instead ?
|
||||
_locationHeightTable[_locationNum], _mirroredDrawing != 0);
|
||||
}
|
||||
drawCurrentSprite();
|
||||
}
|
||||
}
|
||||
if (_locationHeight == 140) {
|
||||
|
@ -571,6 +552,7 @@ void TuckerEngine::mainLoop() {
|
|||
if (_flagsTable[100] != 1) {
|
||||
handleCongratulationsSequence();
|
||||
}
|
||||
closeCompressedSoundFile();
|
||||
freeBuffers();
|
||||
}
|
||||
|
||||
|
@ -1700,6 +1682,33 @@ void TuckerEngine::drawBackgroundSprites(int flipX) {
|
|||
}
|
||||
}
|
||||
|
||||
void TuckerEngine::drawCurrentSprite() {
|
||||
int offset;
|
||||
SpriteFrame *chr = &_spriteFramesTable[_currentSpriteAnimationFrame];
|
||||
if (_mirroredDrawing == 0) {
|
||||
offset = (_yPosCurrent + _mainSpritesBaseOffset - 54 + chr->yOffset) * 640 + _xPosCurrent;
|
||||
offset += chr->xOffset - 14;
|
||||
} else {
|
||||
offset = (_yPosCurrent + _mainSpritesBaseOffset - 54 + chr->yOffset) * 640 + _xPosCurrent;
|
||||
offset -= chr->xSize + chr->xOffset - 14;
|
||||
}
|
||||
Graphics::decodeRLE_248(_locationBackgroundGfxBuf + offset, _spritesGfxBuf + chr->sourceOffset, chr->xSize, chr->ySize,
|
||||
chr->yOffset, _locationHeightTable[_locationNum], _mirroredDrawing != 0);
|
||||
if (_currentSpriteAnimationLength > 1) {
|
||||
SpriteFrame *chr2 = &_spriteFramesTable[_currentSpriteAnimationFrame2];
|
||||
if (_mirroredDrawing == 0) {
|
||||
offset = (_yPosCurrent + _mainSpritesBaseOffset - 54 + chr2->yOffset) * 640 + _xPosCurrent;
|
||||
offset += chr2->xOffset - 14;
|
||||
} else {
|
||||
offset = (_yPosCurrent + _mainSpritesBaseOffset - 54 + chr2->yOffset) * 640 + _xPosCurrent;
|
||||
offset -= chr2->xSize + chr2->xOffset - 14;
|
||||
}
|
||||
Graphics::decodeRLE_248(_locationBackgroundGfxBuf + offset, _spritesGfxBuf + chr2->sourceOffset, chr2->xSize, chr2->ySize,
|
||||
_spriteFramesTable[_currentSpriteAnimationFrame].yOffset, // _currentCharacter instead ?
|
||||
_locationHeightTable[_locationNum], _mirroredDrawing != 0);
|
||||
}
|
||||
}
|
||||
|
||||
void TuckerEngine::setVolumeSound(int index, int volume) {
|
||||
if (volume < 0) {
|
||||
volume = 0;
|
||||
|
@ -2808,7 +2817,7 @@ void TuckerEngine::drawString2(int x, int y, int num) {
|
|||
int pos = getPositionForLine(num, _ptTextBuf);
|
||||
while (_ptTextBuf[pos] != '\n') {
|
||||
const uint8 chr = _ptTextBuf[pos];
|
||||
Graphics::drawStringChar2(dst, chr, 640, 1, _charsetGfxBuf);
|
||||
Graphics::drawStringChar(dst, chr, 640, 1, _charsetGfxBuf);
|
||||
dst += _charWidthTable[chr];
|
||||
++pos;
|
||||
}
|
||||
|
|
|
@ -210,7 +210,7 @@ public:
|
|||
|
||||
virtual Common::Error init();
|
||||
virtual Common::Error go();
|
||||
virtual bool hasFeature(EngineFeature f) const { return false; }
|
||||
virtual bool hasFeature(EngineFeature f) const;
|
||||
virtual void syncSoundSettings();
|
||||
|
||||
protected:
|
||||
|
@ -261,6 +261,7 @@ protected:
|
|||
void drawData3();
|
||||
void execData3PreUpdate();
|
||||
void drawBackgroundSprites(int flipX);
|
||||
void drawCurrentSprite();
|
||||
void setVolumeSound(int index, int volume);
|
||||
void setVolumeMusic(int index, int volume);
|
||||
void startSound(int offset, int index, int volume);
|
||||
|
@ -510,12 +511,13 @@ protected:
|
|||
int handleSpecialObjectSelectionSequence();
|
||||
|
||||
void openCompressedSoundFile();
|
||||
void closeCompressedSoundFile();
|
||||
uint8 *loadFile(uint8 *p = 0);
|
||||
void loadImage(uint8 *dst, int a);
|
||||
void loadCursor();
|
||||
void loadCharset();
|
||||
void loadCharset2();
|
||||
void loadCharsetHelper(int charW, int charH, int xSize, int ySize);
|
||||
void loadCharsetHelper();
|
||||
void loadCharSizeDta();
|
||||
void loadPanel();
|
||||
void loadBudSpr(int startOffset);
|
||||
|
@ -538,6 +540,7 @@ protected:
|
|||
|
||||
|
||||
Common::RandomSource _rnd;
|
||||
Common::Language _lang;
|
||||
|
||||
int _quitGame;
|
||||
bool _fastMode;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue