diff options
author | Oliver Kiehl | 2003-05-09 22:06:37 +0000 |
---|---|---|
committer | Oliver Kiehl | 2003-05-09 22:06:37 +0000 |
commit | 18e1c5a80ad4f653fb597f948235ea8bfd77bb4f (patch) | |
tree | b5508ede4de79ff5821fb3b5e454c2e16bf98291 /sky | |
parent | 3a9d8cd8f48b7392614ff91d3e90932f86f1e2b4 (diff) | |
download | scummvm-rg350-18e1c5a80ad4f653fb597f948235ea8bfd77bb4f.tar.gz scummvm-rg350-18e1c5a80ad4f653fb597f948235ea8bfd77bb4f.tar.bz2 scummvm-rg350-18e1c5a80ad4f653fb597f948235ea8bfd77bb4f.zip |
no need for inheritance anymore
svn-id: r7407
Diffstat (limited to 'sky')
-rw-r--r-- | sky/sky.cpp | 29 | ||||
-rw-r--r-- | sky/text.cpp | 56 | ||||
-rw-r--r-- | sky/text.h | 41 |
3 files changed, 36 insertions, 90 deletions
diff --git a/sky/sky.cpp b/sky/sky.cpp index b5c4ed48cc..7dcf83861a 100644 --- a/sky/sky.cpp +++ b/sky/sky.cpp @@ -128,7 +128,7 @@ void SkyState::initialise(void) { } _gameVersion = _skyDisk->determineGameVersion(); - _skyText = getSkyText(); + _skyText = new SkyText(_skyDisk, _gameVersion, _language); _skyMouse = new SkyMouse(_skyDisk); initialiseScreen(); @@ -258,33 +258,6 @@ void SkyState::delay(uint amount) { //copied and mutilated from Simon.cpp } while (cur < start + amount); } -SkyText *SkyState::getSkyText() { - - switch (_gameVersion) { - case 267: - //floppy demo - return new SkyText_v00267(_skyDisk, _gameVersion, _language); - case 288: - //floppy version - return new SkyText_v00288(_skyDisk, _gameVersion, _language); - case 303: - //floppy version - return new SkyText_v00303(_skyDisk, _gameVersion, _language); - case 331: - //floppy version - return new SkyText_v00331(_skyDisk, _gameVersion, _language); - case 365: - //cd demo, uses a slightly modified version of v00372 - case 368: - //cd version, uses a slightly modified version of v00372 - case 372: - //cd version - return new SkyText_v00372(_skyDisk, _gameVersion, _language); - default: - error("Unknown game version"); - } -} - bool SkyState::isDemo(uint32 version) { switch (version) { case 267: diff --git a/sky/text.cpp b/sky/text.cpp index 0af38c92d6..6e5b147dd4 100644 --- a/sky/text.cpp +++ b/sky/text.cpp @@ -39,6 +39,8 @@ SkyText::SkyText(SkyDisk *skyDisk, uint32 gameVersion, uint16 language) { _language = language; _gameVersion = gameVersion; + initHuffTree(); + _mainCharacterSet.addr = _skyDisk->loadFile(CHAR_SET_FILE, NULL); _mainCharacterSet.charHeight = MAIN_CHAR_HEIGHT; _mainCharacterSet.charSpacing = 0; @@ -1428,36 +1430,40 @@ static const HuffTree huffTree_00372[] = { { 0, 0, '!' }, }; -char SkyText::traverseTree(const HuffTree *huffTree) { +void SkyText::initHuffTree() { + switch (_gameVersion) { + case 267: + _huffTree = huffTree_00267; + break; + case 288: + _huffTree = huffTree_00288; + break; + case 303: + _huffTree = huffTree_00303; + break; + case 331: + _huffTree = huffTree_00331; + break; + case 365: + case 368: + case 372: + _huffTree = huffTree_00372; + break; + default: + error("Unknown game version"); + } +} + +char SkyText::getTextChar() { int pos = 0; for (;;) { if (getTBit() == 0) - pos = huffTree[pos].lChild; + pos = _huffTree[pos].lChild; else - pos = huffTree[pos].rChild; - if (huffTree[pos].lChild == 0 && huffTree[pos].rChild == 0) { - return huffTree[pos].value; + pos = _huffTree[pos].rChild; + if (_huffTree[pos].lChild == 0 && _huffTree[pos].rChild == 0) { + return _huffTree[pos].value; } } } -char SkyText_v00267::getTextChar() { - return traverseTree(huffTree_00267); -} - -char SkyText_v00288::getTextChar() { - return traverseTree(huffTree_00288); -} - -char SkyText_v00303::getTextChar() { - return traverseTree(huffTree_00303); -} - -char SkyText_v00331::getTextChar() { - return traverseTree(huffTree_00331); -} - -char SkyText_v00372::getTextChar() { - return traverseTree(huffTree_00372); -} - diff --git a/sky/text.h b/sky/text.h index 0d24c70599..7814581c46 100644 --- a/sky/text.h +++ b/sky/text.h @@ -42,8 +42,8 @@ public: protected: bool getTBit(); void fnSetFont(uint32 fontNr); - char traverseTree(const HuffTree *huffTree); - virtual char getTextChar() = 0; + void initHuffTree(); + char getTextChar(); SkyDisk *_skyDisk; uint16 _language; @@ -52,6 +52,8 @@ protected: uint8 _shiftBits; uint8 *_textItemPtr; + const HuffTree *_huffTree; + struct charSet { uint8 *addr; uint32 charHeight; @@ -81,39 +83,4 @@ protected: uint32 _lowTextWidth; }; -class SkyText_v00267 : public SkyText { -public: - SkyText_v00267(SkyDisk *skyDisk, uint32 gameVersion, uint16 language) : SkyText(skyDisk, gameVersion, language) {}; -protected: - char getTextChar(); -}; - -class SkyText_v00288 : public SkyText { -public: - SkyText_v00288(SkyDisk *skyDisk, uint32 gameVersion, uint16 language) : SkyText(skyDisk, gameVersion, language) {}; -protected: - char getTextChar(); -}; - -class SkyText_v00303 : public SkyText { -public: - SkyText_v00303(SkyDisk *skyDisk, uint32 gameVersion, uint16 language) : SkyText(skyDisk, gameVersion, language) {}; -protected: - char getTextChar(); -}; - -class SkyText_v00331 : public SkyText { -public: - SkyText_v00331(SkyDisk *skyDisk, uint32 gameVersion, uint16 language) : SkyText(skyDisk, gameVersion, language) {}; -protected: - char getTextChar(); -}; - -class SkyText_v00372 : public SkyText { -public: - SkyText_v00372(SkyDisk *skyDisk, uint32 gameVersion, uint16 language) : SkyText(skyDisk, gameVersion, language) {}; -protected: - char getTextChar(); -}; - #endif |