1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef SKY_TEXT_H
24 #define SKY_TEXT_H
25 
26 
27 #include "common/scummsys.h"
28 
29 namespace Sky {
30 
31 struct Compact;
32 class Disk;
33 class SkyCompact;
34 
35 struct HuffTree {
36 	unsigned char lChild;
37 	unsigned char rChild;
38 	unsigned char value;
39 };
40 
41 #define NUM_PATCH_MSG 9
42 
43 struct PatchMessage {
44 	uint32 textNr;
45 	char text[100];
46 };
47 
48 class Text {
49 public:
50 	Text(Disk *skyDisk, SkyCompact *skyCompact);
51 	~Text();
52 	struct DisplayedText displayText(uint32 textNum, uint8 *dest, bool center, uint16 pixelWidth, uint8 color);
53 	struct DisplayedText displayText(char *textPtr, uint8 *dest, bool center, uint16 pixelWidth, uint8 color);
54 	struct DisplayedText lowTextManager(uint32 textNum, uint16 width, uint16 logicNum, uint8 color, bool center);
55 	void fnSetFont(uint32 fontNr);
56 	void fnTextModule(uint32 textInfoId, uint32 textNo);
57 	void fnPointerText(uint32 pointedId, uint16 mouseX, uint16 mouseY);
58 	void logicCursor(Compact *textCompact, uint16 mouseX, uint16 mouseY);
59 	void changeTextSpriteColor(uint8 *sprData, uint8 newCol);
60 	uint32 giveCurrentCharSet();
61 
62 	uint32 _numLetters;	//no of chars in message
63 
64 private:
65 	void initHuffTree();
66 	void getText(uint32 textNr);
67 	char getTextChar(uint8 **data, uint32 *bitPos);
68 	bool getTextBit(uint8 **data, uint32 *bitPos);
69 	void makeGameCharacter(uint8 textChar, uint8 *charSetPtr, uint8 *&data, uint8 color, uint16 bufPitch);
70 
71 	bool patchMessage(uint32 textNum);
72 
73 	Disk *_skyDisk;
74 	SkyCompact *_skyCompact;
75 
76 	const HuffTree *_huffTree;
77 
78 	struct charSet {
79 		uint8 *addr;
80 		uint32 charHeight;
81 		uint32 charSpacing;
82 	} _mainCharacterSet, _linkCharacterSet, _controlCharacterSet;
83 
84 	uint32	_curCharSet;
85 	uint8	*_characterSet;
86 	uint8	_charHeight;
87 
88 	char _textBuffer[1024];
89 
90 	uint32	_dtCharSpacing;	//character separation adjustment
91 	uint32	_mouseOfsX, _mouseOfsY;
92 	static const PatchMessage _patchedMessages[NUM_PATCH_MSG];
93 	static const uint16 _patchLangIdx[8];
94 	static const uint16 _patchLangNum[8];
95 
96 	static const HuffTree _huffTree_00109[]; // trees moved to hufftext.cpp
97 	static const HuffTree _huffTree_00267[];
98 	static const HuffTree _huffTree_00288[];
99 	static const HuffTree _huffTree_00303[];
100 	static const HuffTree _huffTree_00331[];
101 	static const HuffTree _huffTree_00348[];
102 	static const HuffTree _huffTree_00365[];
103 	static const HuffTree _huffTree_00368[];
104 	static const HuffTree _huffTree_00372[];
105 };
106 
107 } // End of namespace Sky
108 
109 #endif
110