Ticket #8289: patch

File patch, 9.3 KB (added by sev-, 18 years ago)

Patch to support Russian Full Throttle

Line 
1diff --rec --show-c scummvm.old/base/gameDetector.cpp scummvm/base/gameDetector.cpp
2*** scummvm.old/base/gameDetector.cpp Mon Oct 6 20:24:37 2003
3--- scummvm/base/gameDetector.cpp Mon Oct 13 00:09:48 2003
4*************** static const char USAGE_STRING[] =
5*** 62,68 ****
6 " -g<mode> - Graphics mode (normal,2x,3x,2xsai,super2xsai,supereagle,\n"
7 " advmame2x,advmame3x,hq2x,hq3x,tv2x,dotmatrix)\n"
8 " -e<mode> - Set music engine (see README for details)\n"
9! " -q<lang> - Specify language (en,de,fr,it,pt,es,jp,zh,kr,se,gb,hb)\n"
10 "\n"
11 " -c<num> - Use cdrom <num> for cd audio\n"
12 " -j[num] - Enable input with joystick (default: 0 - first joystick)\n"
13--- 62,68 ----
14 " -g<mode> - Graphics mode (normal,2x,3x,2xsai,super2xsai,supereagle,\n"
15 " advmame2x,advmame3x,hq2x,hq3x,tv2x,dotmatrix)\n"
16 " -e<mode> - Set music engine (see README for details)\n"
17! " -q<lang> - Specify language (en,de,fr,it,pt,es,jp,zh,kr,se,gb,hb,ru)\n"
18 "\n"
19 " -c<num> - Use cdrom <num> for cd audio\n"
20 " -j[num] - Enable input with joystick (default: 0 - first joystick)\n"
21*************** static const struct Language languages[]
22*** 162,167 ****
23--- 162,168 ----
24 {"gb", "English", EN_GRB},
25 {"se", "Swedish", SE_SWE},
26 {"hb", "Hebrew", HB_HEB},
27+ {"ru", "Russian", RU_RUS},
28 {0, 0, 0}
29 };
30
31diff --rec --show-c scummvm.old/base/gameDetector.h scummvm/base/gameDetector.h
32*** scummvm.old/base/gameDetector.h Mon Oct 6 20:24:37 2003
33--- scummvm/base/gameDetector.h Mon Oct 13 00:10:30 2003
34*************** enum {
35*** 63,69 ****
36 KO_KOR = 8,
37 SE_SWE = 9,
38 EN_GRB = 10,
39! HB_HEB = 20
40 };
41
42 enum MidiDriverType {
43--- 63,70 ----
44 KO_KOR = 8,
45 SE_SWE = 9,
46 EN_GRB = 10,
47! HB_HEB = 20,
48! RU_RUS = 21
49 };
50
51 enum MidiDriverType {
52diff --rec --show-c scummvm.old/scumm/nut_renderer.cpp scummvm/scumm/nut_renderer.cpp
53*** scummvm.old/scumm/nut_renderer.cpp Sat Oct 4 06:52:17 2003
54--- scummvm/scumm/nut_renderer.cpp Mon Oct 13 23:51:23 2003
55***************
56*** 22,27 ****
57--- 22,29 ----
58 #include "scumm/scumm.h"
59 #include "scumm/nut_renderer.h"
60 #include "scumm/bomp.h"
61+ // FIXME: This is used to work around wrong font file format in Russian version of FT
62+ #include "base/gameDetector.h"
63
64
65 namespace Scumm {
66*************** NutRenderer::~NutRenderer() {
67*** 43,51 ****
68 }
69 }
70
71! void NutRenderer::decodeCodec44(byte *dst, const byte *src, uint32 length) {
72 byte val;
73 uint16 size_line, num;
74
75 do {
76 size_line = READ_LE_UINT16(src);
77--- 45,54 ----
78 }
79 }
80
81! int32 NutRenderer::decodeCodec44(byte *dst, const byte *src, uint32 length) {
82 byte val;
83 uint16 size_line, num;
84+ int16 decoded_length = 0;
85
86 do {
87 size_line = READ_LE_UINT16(src);
88*************** void NutRenderer::decodeCodec44(byte *ds
89*** 57,62 ****
90--- 60,66 ----
91 val = *src++;
92 memset(dst, val, num);
93 dst += num;
94+ decoded_length += num;
95 length -= 2;
96 size_line -= 2;
97 if (size_line != 0) {
98*************** void NutRenderer::decodeCodec44(byte *ds
99*** 64,82 ****
100 src += 2;
101 memcpy(dst, src, num);
102 dst += num;
103 src += num;
104 length -= num + 2;
105 size_line -= num + 2;
106 }
107 }
108 dst--;
109
110 } while (length > 1);
111 }
112
113! static void codec1(byte *dst, byte *src, int height) {
114 byte val, code;
115! int32 length;
116 int h = height, size_line;
117
118 for (h = 0; h < height; h++) {
119--- 68,89 ----
120 src += 2;
121 memcpy(dst, src, num);
122 dst += num;
123+ decoded_length += num;
124 src += num;
125 length -= num + 2;
126 size_line -= num + 2;
127 }
128 }
129 dst--;
130+ decoded_length--;
131
132 } while (length > 1);
133+ return decoded_length;
134 }
135
136! static int32 codec1(byte *dst, byte *src, int height) {
137 byte val, code;
138! int32 length, decoded_length = 0;
139 int h = height, size_line;
140
141 for (h = 0; h < height; h++) {
142*************** static void codec1(byte *dst, byte *src,
143*** 92,97 ****
144--- 99,105 ----
145 if (val)
146 memset(dst, val, length);
147 dst += length;
148+ decoded_length += length;
149 } else {
150 size_line -= length;
151 while (length--) {
152*************** static void codec1(byte *dst, byte *src,
153*** 99,112 ****
154 if (val)
155 *dst = val;
156 dst++;
157 }
158 }
159 }
160 }
161 }
162
163 bool NutRenderer::loadFont(const char *filename, const char *directory) {
164! debug(8, "NutRenderer::loadFont() called");
165 if (_loaded) {
166 warning("NutRenderer::loadFont() Font already loaded, ok, loading...");
167 }
168--- 107,122 ----
169 if (val)
170 *dst = val;
171 dst++;
172+ decoded_length++;
173 }
174 }
175 }
176 }
177+ return decoded_length;
178 }
179
180 bool NutRenderer::loadFont(const char *filename, const char *directory) {
181! debug(8, "NutRenderer::loadFont(\"%s\", \"%s\") called", filename, directory);
182 if (_loaded) {
183 warning("NutRenderer::loadFont() Font already loaded, ok, loading...");
184 }
185*************** bool NutRenderer::loadFont(const char *f
186*** 137,142 ****
187--- 147,153 ----
188
189 _nbChars = READ_LE_UINT16(dataSrc + 10);
190 uint32 offset = READ_BE_UINT32(dataSrc + 4) + 8;
191+ int32 decoded_length;
192 for (int l = 0; l < _nbChars; l++) {
193 if ((READ_BE_UINT32(dataSrc + offset) == 'FRME') || (READ_BE_UINT32(dataSrc + offset + 1) == 'FRME')) {
194 if (READ_BE_UINT32(dataSrc + offset) == 'FRME')
195*************** bool NutRenderer::loadFont(const char *f
196*** 149,161 ****
197 _chars[l].yoffs = READ_LE_UINT16(dataSrc + offset + 12);
198 _chars[l].width = READ_LE_UINT16(dataSrc + offset + 14);
199 _chars[l].height = READ_LE_UINT16(dataSrc + offset + 16);
200! _chars[l].src = new byte[_chars[l].width * _chars[l].height + 1000];
201! if ((codec == 44) || (codec == 21))
202! decodeCodec44(_chars[l].src, dataSrc + offset + 22, READ_BE_UINT32(dataSrc + offset + 4) - 14);
203 else if (codec == 1) {
204! codec1(_chars[l].src, dataSrc + offset + 22, _chars[l].height);
205 } else
206 error("NutRenderer::loadFont: unknown codec: %d", codec);
207 offset += READ_BE_UINT32(dataSrc + offset + 4) + 8;
208 } else {
209 warning("NutRenderer::loadFont(%s, %s) there is no FOBJ chunk in FRME chunk %d (offset %x)", filename, directory, l, offset);
210--- 160,185 ----
211 _chars[l].yoffs = READ_LE_UINT16(dataSrc + offset + 12);
212 _chars[l].width = READ_LE_UINT16(dataSrc + offset + 14);
213 _chars[l].height = READ_LE_UINT16(dataSrc + offset + 16);
214! _chars[l].src = new byte[(_chars[l].width + 2) * _chars[l].height + 1000];
215! if ((codec == 44) || (codec == 21))
216! decoded_length = decodeCodec44(_chars[l].src, dataSrc + offset + 22, READ_BE_UINT32(dataSrc + offset + 4) - 14);
217 else if (codec == 1) {
218! decoded_length = codec1(_chars[l].src, dataSrc + offset + 22, _chars[l].height);
219 } else
220 error("NutRenderer::loadFont: unknown codec: %d", codec);
221+
222+ // FIXME: This is used to work around wrong font file format in Russian
223+ // version of FT. Font files there contain wrong information about
224+ // glyphs width. [Sev]
225+ if (_vm->_language == RU_RUS) {
226+ // try to rely on length of returned data
227+ if (l > 127)
228+ _chars[l].width = decoded_length / _chars[l].height;
229+ // but even this not always works
230+ if (l == 134 && filename == "titlfnt.nut")
231+ _chars[l].width--;
232+ }
233+
234 offset += READ_BE_UINT32(dataSrc + offset + 4) + 8;
235 } else {
236 warning("NutRenderer::loadFont(%s, %s) there is no FOBJ chunk in FRME chunk %d (offset %x)", filename, directory, l, offset);
237diff --rec --show-c scummvm.old/scumm/nut_renderer.h scummvm/scumm/nut_renderer.h
238*** scummvm.old/scumm/nut_renderer.h Sat Oct 4 06:52:17 2003
239--- scummvm/scumm/nut_renderer.h Mon Oct 13 21:20:51 2003
240*************** protected:
241*** 41,47 ****
242 byte *src;
243 } _chars[256];
244
245! void decodeCodec44(byte *dst, const byte *src, uint32 length);
246
247 void drawChar(byte *dst, byte *mask, byte c, int x, int y, byte color);
248 void draw2byte(byte *dst, byte *mask, int c, int x, int y, byte color);
249--- 41,47 ----
250 byte *src;
251 } _chars[256];
252
253! int32 decodeCodec44(byte *dst, const byte *src, uint32 length);
254
255 void drawChar(byte *dst, byte *mask, byte c, int x, int y, byte color);
256 void draw2byte(byte *dst, byte *mask, int c, int x, int y, byte color);
257diff --rec --show-c scummvm.old/scumm/smush/smush_player.cpp scummvm/scumm/smush/smush_player.cpp
258*** scummvm.old/scumm/smush/smush_player.cpp Sat Oct 4 06:52:24 2003
259--- scummvm/scumm/smush/smush_player.cpp Mon Oct 13 23:55:31 2003
260*************** public:
261*** 102,108 ****
262 char *data_end = data_start;
263
264 while (1) {
265! if (data_end[-2] == '\r' && data_end[1] == '\n' && data_end[-1] == '\n' && data_end[0] == '\r') {
266 break;
267 }
268 data_end++;
269--- 102,113 ----
270 char *data_end = data_start;
271
272 while (1) {
273! if (data_end[-2] == '\r' && data_end[-1] == '\n' && data_end[0] == '\r' && data_end[1] == '\r') {
274! break;
275! }
276! // In Russian Full Throttle strings are finished with
277! // just one pair of CR-LF
278! if (data_end[-2] == '\r' && data_end[-1] == '\n' && data_end[0] == '#') {
279 break;
280 }
281 data_end++;
282*************** public:
283*** 144,149 ****
284--- 149,155 ----
285 if (id == _lastId) {
286 return _lastString;
287 }
288+ debug(9, "StringResource::get(%d)", id);
289 for (int i = 0; i < _nbStrings; i++) {
290 if (_strings[i].id == id) {
291 _lastId = id;