Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 347 lines (292 sloc) 8.414 kB
218e132 @fingolfin Updated legal headers in source files, based on what Pidgin (the IM c…
fingolfin authored
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.
e34571d @fingolfin Countless changes to the New GUI; some hightligths: new ScrollBarWidg…
fingolfin authored
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
b36677a @sev- Update FSF address. Eek. Actually that took place on May 1, 2005
sev- authored
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
e34571d @fingolfin Countless changes to the New GUI; some hightligths: new ScrollBarWidg…
fingolfin authored
20 *
36934b6 @fingolfin Change CVS keywords to SVN keywords
fingolfin authored
21 * $URL$
22 * $Id$
e34571d @fingolfin Countless changes to the New GUI; some hightligths: new ScrollBarWidg…
fingolfin authored
23 */
24
0df319e @fingolfin #include cleanup (explicityl specify the location for headers from co…
fingolfin authored
25 #include "common/util.h"
f0ac3d1 @fingolfin Moved error/warning/checkHeap from engines/engine.cpp to common/util.cpp
fingolfin authored
26 #include "common/system.h"
51a9bfc @lordhoto Refactor GUI options update into a function in Common: updateGameGUIO…
lordhoto authored
27 #include "common/config-manager.h"
e34571d @fingolfin Countless changes to the New GUI; some hightligths: new ScrollBarWidg…
fingolfin authored
28
d4734bd @fingolfin use namespace Common a bit more; don't zero the RNG in scumm (else th…
fingolfin authored
29 namespace Common {
e34571d @fingolfin Countless changes to the New GUI; some hightligths: new ScrollBarWidg…
fingolfin authored
30
a6c5762 @fingolfin added some comments, cleanup
fingolfin authored
31 //
c1b38d6 @fingolfin make hexdump width variable
fingolfin authored
32 // Print hexdump of the data passed in
a6c5762 @fingolfin added some comments, cleanup
fingolfin authored
33 //
36c832d @bluegr Added a startOffset parameter to hexdump() (used by SCI's own hexdump…
bluegr authored
34 void hexdump(const byte * data, int len, int bytesPerLine, int startOffset) {
d4734bd @fingolfin use namespace Common a bit more; don't zero the RNG in scumm (else th…
fingolfin authored
35 assert(1 <= bytesPerLine && bytesPerLine <= 32);
c8ceebf @fingolfin added simple hexdump() function (nice for debugging); added some debu…
fingolfin authored
36 int i;
37 byte c;
36c832d @bluegr Added a startOffset parameter to hexdump() (used by SCI's own hexdump…
bluegr authored
38 int offset = startOffset;
d4734bd @fingolfin use namespace Common a bit more; don't zero the RNG in scumm (else th…
fingolfin authored
39 while (len >= bytesPerLine) {
4ba3281 @fingolfin hexdump defaults to 16 bytes/line now, and prints an offest
fingolfin authored
40 printf("%06x: ", offset);
d4734bd @fingolfin use namespace Common a bit more; don't zero the RNG in scumm (else th…
fingolfin authored
41 for (i = 0; i < bytesPerLine; i++) {
c8ceebf @fingolfin added simple hexdump() function (nice for debugging); added some debu…
fingolfin authored
42 printf("%02x ", data[i]);
4ba3281 @fingolfin hexdump defaults to 16 bytes/line now, and prints an offest
fingolfin authored
43 if (i % 4 == 3)
44 printf(" ");
45 }
c8ceebf @fingolfin added simple hexdump() function (nice for debugging); added some debu…
fingolfin authored
46 printf(" |");
d4734bd @fingolfin use namespace Common a bit more; don't zero the RNG in scumm (else th…
fingolfin authored
47 for (i = 0; i < bytesPerLine; i++) {
c8ceebf @fingolfin added simple hexdump() function (nice for debugging); added some debu…
fingolfin authored
48 c = data[i];
caf9817 @fingolfin don't print char 0x7f
fingolfin authored
49 if (c < 32 || c >= 127)
c8ceebf @fingolfin added simple hexdump() function (nice for debugging); added some debu…
fingolfin authored
50 c = '.';
51 printf("%c", c);
52 }
53 printf("|\n");
d4734bd @fingolfin use namespace Common a bit more; don't zero the RNG in scumm (else th…
fingolfin authored
54 data += bytesPerLine;
55 len -= bytesPerLine;
56 offset += bytesPerLine;
c8ceebf @fingolfin added simple hexdump() function (nice for debugging); added some debu…
fingolfin authored
57 }
58
6b44844 @sev- Remove trailing whitespaces.
sev- authored
59 if (len <= 0)
02f90ba @fingolfin fix if len is divisible by 8
fingolfin authored
60 return;
61
4ba3281 @fingolfin hexdump defaults to 16 bytes/line now, and prints an offest
fingolfin authored
62 printf("%06x: ", offset);
5ff7c1d @fingolfin small fix for hexdump()
fingolfin authored
63 for (i = 0; i < bytesPerLine; i++) {
64 if (i < len)
65 printf("%02x ", data[i]);
66 else
67 printf(" ");
4ba3281 @fingolfin hexdump defaults to 16 bytes/line now, and prints an offest
fingolfin authored
68 if (i % 4 == 3)
69 printf(" ");
70 }
c8ceebf @fingolfin added simple hexdump() function (nice for debugging); added some debu…
fingolfin authored
71 printf(" |");
72 for (i = 0; i < len; i++) {
73 c = data[i];
caf9817 @fingolfin don't print char 0x7f
fingolfin authored
74 if (c < 32 || c >= 127)
c8ceebf @fingolfin added simple hexdump() function (nice for debugging); added some debu…
fingolfin authored
75 c = '.';
76 printf("%c", c);
77 }
d4734bd @fingolfin use namespace Common a bit more; don't zero the RNG in scumm (else th…
fingolfin authored
78 for (; i < bytesPerLine; i++)
c8ceebf @fingolfin added simple hexdump() function (nice for debugging); added some debu…
fingolfin authored
79 printf(" ");
80 printf("|\n");
81 }
9ce78dd apply patch #609508 real fix for MI2 Dialog Box crash, by CCCP at End…
Jonathan Gray authored
82
1d097d9 @fingolfin Moved debug() etc. and special debug flag handling code to common/deb…
fingolfin authored
83
a704608 @fingolfin moved platform/language constants to common/util.*
fingolfin authored
84 #pragma mark -
85
86
7c510f2 @fingolfin COMMON: Add Common::parseBool
fingolfin authored
87 bool parseBool(const Common::String &val, bool &valAsBool) {
88 if (val.equalsIgnoreCase("true") ||
89 val.equalsIgnoreCase("yes") ||
90 val.equals("1")) {
91 valAsBool = true;
92 return true;
93 }
94 if (val.equalsIgnoreCase("false") ||
95 val.equalsIgnoreCase("no") ||
96 val.equals("0")) {
97 valAsBool = false;
98 return true;
99 }
100
101 return false;
102 }
103
104
105 #pragma mark -
106
107
583ae61 @fingolfin export language list (so that it can be used by the GUI); added metho…
fingolfin authored
108 const LanguageDescription g_languages[] = {
d10fc79 @sev- Add support for Chinese translated games.
sev- authored
109 {"zh-cn", "Chinese (China)", ZH_CNA},
de9e72b @sev- Patch #1706179: "GUI: Sort languages list"
sev- authored
110 {"zh", "Chinese (Taiwan)", ZH_TWN},
111 {"cz", "Czech", CZ_CZE},
112 {"nl", "Dutch", NL_NLD},
c09fef7 @sev- Add comments explaining what does EN_ANY mean
sev- authored
113 {"en", "English", EN_ANY}, // Generic English (when only one game version exist)
2044ee1 @fingolfin Don't hardcode specific values for our language enums, as nothing sho…
fingolfin authored
114 {"gb", "English (GB)", EN_GRB},
de9e72b @sev- Patch #1706179: "GUI: Sort languages list"
sev- authored
115 {"us", "English (US)", EN_USA},
a704608 @fingolfin moved platform/language constants to common/util.*
fingolfin authored
116 {"fr", "French", FR_FRA},
de9e72b @sev- Patch #1706179: "GUI: Sort languages list"
sev- authored
117 {"de", "German", DE_DEU},
a20ad01 @bluegr Add Greek to the list of ScummVM supported languages, for FR #1723255…
bluegr authored
118 {"gr", "Greek", GR_GRE},
de9e72b @sev- Patch #1706179: "GUI: Sort languages list"
sev- authored
119 {"hb", "Hebrew", HB_ISR},
eed7635 @sev- Sort language list (and showing that Lure is really broken).
sev- authored
120 {"hu", "Hungarian", HU_HUN},
a704608 @fingolfin moved platform/language constants to common/util.*
fingolfin authored
121 {"it", "Italian", IT_ITA},
122 {"jp", "Japanese", JA_JPN},
123 {"kr", "Korean", KO_KOR},
3f22860 @fingolfin Avoid putting non-ASCII chars into source files
fingolfin authored
124 {"nb", "Norwegian Bokm\xE5l", NB_NOR},
9cde262 Add Polish version of Simon the Sorcerer 2 (Windows).
Travis Howell authored
125 {"pl", "Polish", PL_POL},
de9e72b @sev- Patch #1706179: "GUI: Sort languages list"
sev- authored
126 {"br", "Portuguese", PT_BRA},
127 {"ru", "Russian", RU_RUS},
128 {"es", "Spanish", ES_ESP},
129 {"se", "Swedish", SE_SWE},
a704608 @fingolfin moved platform/language constants to common/util.*
fingolfin authored
130 {0, 0, UNK_LANG}
131 };
132
133 Language parseLanguage(const String &str) {
9f93e5b @fingolfin Renamed various container isEmpty() methods to empty() to match STL c…
fingolfin authored
134 if (str.empty())
a704608 @fingolfin moved platform/language constants to common/util.*
fingolfin authored
135 return UNK_LANG;
136
583ae61 @fingolfin export language list (so that it can be used by the GUI); added metho…
fingolfin authored
137 const LanguageDescription *l = g_languages;
24fcd71 @fingolfin cleanup for language/platform functions
fingolfin authored
138 for (; l->code; ++l) {
e5f58ef @fingolfin Removed various uses of scumm_stricmp by the more readable String::eq…
fingolfin authored
139 if (str.equalsIgnoreCase(l->code))
a704608 @fingolfin moved platform/language constants to common/util.*
fingolfin authored
140 return l->id;
141 }
142
143 return UNK_LANG;
144 }
145
24fcd71 @fingolfin cleanup for language/platform functions
fingolfin authored
146 const char *getLanguageCode(Language id) {
147 const LanguageDescription *l = g_languages;
148 for (; l->code; ++l) {
149 if (l->id == id)
150 return l->code;
151 }
152 return 0;
153 }
a704608 @fingolfin moved platform/language constants to common/util.*
fingolfin authored
154
24fcd71 @fingolfin cleanup for language/platform functions
fingolfin authored
155 const char *getLanguageDescription(Language id) {
583ae61 @fingolfin export language list (so that it can be used by the GUI); added metho…
fingolfin authored
156 const LanguageDescription *l = g_languages;
24fcd71 @fingolfin cleanup for language/platform functions
fingolfin authored
157 for (; l->code; ++l) {
583ae61 @fingolfin export language list (so that it can be used by the GUI); added metho…
fingolfin authored
158 if (l->id == id)
24fcd71 @fingolfin cleanup for language/platform functions
fingolfin authored
159 return l->description;
583ae61 @fingolfin export language list (so that it can be used by the GUI); added metho…
fingolfin authored
160 }
161 return 0;
162 }
163
164
a704608 @fingolfin moved platform/language constants to common/util.*
fingolfin authored
165 #pragma mark -
166
167
9302e7d @fingolfin Make g_platforms global, so that the alauncher can iterate over the l…
fingolfin authored
168 const PlatformDescription g_platforms[] = {
6edf387 @clone2727 Give Gob1 CD-i its own platform.
clone2727 authored
169 {"2gs", "2gs", "2gs", "Apple IIgs", kPlatformApple2GS},
adcfd2c @sev- Now AdvancedDetector could use single ID per engine. Also it can suggest
sev- authored
170 {"3do", "3do", "3do", "3DO", kPlatform3DO},
171 {"acorn", "acorn", "acorn", "Acorn", kPlatformAcorn},
172 {"amiga", "ami", "amiga", "Amiga", kPlatformAmiga},
173 {"atari", "atari-st", "st", "Atari ST", kPlatformAtariST},
174 {"c64", "c64", "c64", "Commodore 64", kPlatformC64},
175 {"pc", "dos", "ibm", "DOS", kPlatformPC},
fd6ca3b @lordhoto - added PC-98 platform entry
lordhoto authored
176 {"pc98", "pc98", "pc98", "PC-98", kPlatformPC98},
b0a4658 Add Nintendo Wii versions of Freddi Fish 1 and Pajama Sam 1.
Travis Howell authored
177 {"wii", "wii", "wii", "Nintendo Wii", kPlatformWii},
a0fa307 @sev- Added CoCo3 version of SQ1
sev- authored
178 {"coco3", "coco3", "coco3", "CoCo3", kPlatformCoCo3},
d063162 @fingolfin Added FM-TOWNS to platforms list
fingolfin authored
179
180 // The 'official' spelling seems to be "FM-TOWNS" (e.g. in the Indy4 demo).
181 // However, on the net many variations can be seen, like "FMTOWNS",
182 // "FM TOWNS", "FmTowns", etc.
adcfd2c @sev- Now AdvancedDetector could use single ID per engine. Also it can suggest
sev- authored
183 {"fmtowns", "towns", "fm", "FM-TOWNS", kPlatformFMTowns},
d063162 @fingolfin Added FM-TOWNS to platforms list
fingolfin authored
184
adcfd2c @sev- Now AdvancedDetector could use single ID per engine. Also it can suggest
sev- authored
185 {"linux", "linux", "linux", "Linux", kPlatformLinux},
186 {"macintosh", "mac", "mac", "Macintosh", kPlatformMacintosh},
6edf387 @clone2727 Give Gob1 CD-i its own platform.
clone2727 authored
187 {"pce", "pce", "pce", "PC-Engine", kPlatformPCEngine},
adcfd2c @sev- Now AdvancedDetector could use single ID per engine. Also it can suggest
sev- authored
188 {"nes", "nes", "nes", "NES", kPlatformNES},
189 {"segacd", "segacd", "sega", "SegaCD", kPlatformSegaCD},
190 {"windows", "win", "win", "Windows", kPlatformWindows},
7e52694 @clone2727 Make the PlayStation's abbreviation to all lower-case for consistency…
clone2727 authored
191 {"playstation", "psx", "psx", "Sony PlayStation", kPlatformPSX},
6edf387 @clone2727 Give Gob1 CD-i its own platform.
clone2727 authored
192 {"cdi", "cdi", "cdi", "Phillips CD-i", kPlatformCDi},
6c46f3b Added Apple IIgs as machine type for AGI engine
Stuart George authored
193
adcfd2c @sev- Now AdvancedDetector could use single ID per engine. Also it can suggest
sev- authored
194 {0, 0, 0, "Default", kPlatformUnknown}
24fcd71 @fingolfin cleanup for language/platform functions
fingolfin authored
195 };
196
a704608 @fingolfin moved platform/language constants to common/util.*
fingolfin authored
197 Platform parsePlatform(const String &str) {
9f93e5b @fingolfin Renamed various container isEmpty() methods to empty() to match STL c…
fingolfin authored
198 if (str.empty())
a704608 @fingolfin moved platform/language constants to common/util.*
fingolfin authored
199 return kPlatformUnknown;
200
24fcd71 @fingolfin cleanup for language/platform functions
fingolfin authored
201 // Handle some special case separately, for compatibility with old config
202 // files.
e5f58ef @fingolfin Removed various uses of scumm_stricmp by the more readable String::eq…
fingolfin authored
203 if (str == "1")
a704608 @fingolfin moved platform/language constants to common/util.*
fingolfin authored
204 return kPlatformAmiga;
e5f58ef @fingolfin Removed various uses of scumm_stricmp by the more readable String::eq…
fingolfin authored
205 else if (str == "2")
a704608 @fingolfin moved platform/language constants to common/util.*
fingolfin authored
206 return kPlatformAtariST;
e5f58ef @fingolfin Removed various uses of scumm_stricmp by the more readable String::eq…
fingolfin authored
207 else if (str == "3")
a704608 @fingolfin moved platform/language constants to common/util.*
fingolfin authored
208 return kPlatformMacintosh;
24fcd71 @fingolfin cleanup for language/platform functions
fingolfin authored
209
210 const PlatformDescription *l = g_platforms;
211 for (; l->code; ++l) {
e5f58ef @fingolfin Removed various uses of scumm_stricmp by the more readable String::eq…
fingolfin authored
212 if (str.equalsIgnoreCase(l->code) || str.equalsIgnoreCase(l->code2) || str.equalsIgnoreCase(l->abbrev))
24fcd71 @fingolfin cleanup for language/platform functions
fingolfin authored
213 return l->id;
214 }
215
216 return kPlatformUnknown;
a704608 @fingolfin moved platform/language constants to common/util.*
fingolfin authored
217 }
218
219
24fcd71 @fingolfin cleanup for language/platform functions
fingolfin authored
220 const char *getPlatformCode(Platform id) {
221 const PlatformDescription *l = g_platforms;
222 for (; l->code; ++l) {
223 if (l->id == id)
224 return l->code;
583ae61 @fingolfin export language list (so that it can be used by the GUI); added metho…
fingolfin authored
225 }
24fcd71 @fingolfin cleanup for language/platform functions
fingolfin authored
226 return 0;
583ae61 @fingolfin export language list (so that it can be used by the GUI); added metho…
fingolfin authored
227 }
228
adcfd2c @sev- Now AdvancedDetector could use single ID per engine. Also it can suggest
sev- authored
229 const char *getPlatformAbbrev(Platform id) {
230 const PlatformDescription *l = g_platforms;
231 for (; l->code; ++l) {
232 if (l->id == id)
233 return l->abbrev;
234 }
235 return 0;
236 }
237
24fcd71 @fingolfin cleanup for language/platform functions
fingolfin authored
238 const char *getPlatformDescription(Platform id) {
239 const PlatformDescription *l = g_platforms;
240 for (; l->code; ++l) {
241 if (l->id == id)
242 return l->description;
243 }
29f87fb Return default description string
Chris Apers authored
244 return l->description;
24fcd71 @fingolfin cleanup for language/platform functions
fingolfin authored
245 }
246
247
27469a1 @sev- Patch #1121337 (CGA rendering in early LEC titles).
sev- authored
248 #pragma mark -
249
250
251 const RenderModeDescription g_renderModes[] = {
50f6eb7 @sev- Distinguish between green and amber hercules. Now specify it via herc…
sev- authored
252 {"hercGreen", "Hercules Green", kRenderHercG},
253 {"hercAmber", "Hercules Amber", kRenderHercA},
27469a1 @sev- Patch #1121337 (CGA rendering in early LEC titles).
sev- authored
254 {"cga", "CGA", kRenderCGA},
255 {"ega", "EGA", kRenderEGA},
07aa920 Add Amiga renderer mode for EGA games.
Travis Howell authored
256 {"amiga", "Amiga", kRenderAmiga},
27469a1 @sev- Patch #1121337 (CGA rendering in early LEC titles).
sev- authored
257 {0, 0, kRenderDefault}
258 };
259
260 RenderMode parseRenderMode(const String &str) {
9f93e5b @fingolfin Renamed various container isEmpty() methods to empty() to match STL c…
fingolfin authored
261 if (str.empty())
27469a1 @sev- Patch #1121337 (CGA rendering in early LEC titles).
sev- authored
262 return kRenderDefault;
263
264 const RenderModeDescription *l = g_renderModes;
265 for (; l->code; ++l) {
e5f58ef @fingolfin Removed various uses of scumm_stricmp by the more readable String::eq…
fingolfin authored
266 if (str.equalsIgnoreCase(l->code))
27469a1 @sev- Patch #1121337 (CGA rendering in early LEC titles).
sev- authored
267 return l->id;
268 }
269
270 return kRenderDefault;
271 }
272
273 const char *getRenderModeCode(RenderMode id) {
274 const RenderModeDescription *l = g_renderModes;
275 for (; l->code; ++l) {
276 if (l->id == id)
277 return l->code;
278 }
279 return 0;
280 }
281
282 const char *getRenderModeDescription(RenderMode id) {
283 const RenderModeDescription *l = g_renderModes;
284 for (; l->code; ++l) {
285 if (l->id == id)
286 return l->description;
287 }
288 return 0;
289 }
290
1bd6f6c @sev- Added game GUI options to advancedDetector and updated all engines
sev- authored
291 const struct GameOpt {
292 uint32 option;
293 const char *desc;
294 } g_gameOptions[] = {
295 { GUIO_NOSUBTITLES, "sndNoSubs" },
296 { GUIO_NOMUSIC, "sndNoMusic" },
297 { GUIO_NOSPEECH, "sndNoSpeech" },
298 { GUIO_NOSFX, "sndNoSFX" },
299 { GUIO_NOMIDI, "sndNoMIDI" },
300 { GUIO_NOLAUNCHLOAD, "launchNoLoad" },
301 { GUIO_NONE, 0 }
302 };
303
304 bool checkGameGUIOption(GameGUIOption option, const String &str) {
305 for (int i = 0; g_gameOptions[i].desc; i++) {
306 if (g_gameOptions[i].option & option) {
307 if (str.contains(g_gameOptions[i].desc))
308 return true;
309 else
310 return false;
311 }
312 }
313 return false;
314 }
315
316 uint32 parseGameGUIOptions(const String &str) {
317 uint32 res = 0;
318
319 for (int i = 0; g_gameOptions[i].desc; i++)
320 if (str.contains(g_gameOptions[i].desc))
321 res |= g_gameOptions[i].option;
322
323 return res;
324 }
325
326 String getGameGUIOptionsDescription(uint32 options) {
327 String res = "";
328
329 for (int i = 0; g_gameOptions[i].desc; i++)
330 if (options & g_gameOptions[i].option)
331 res += String(g_gameOptions[i].desc) + " ";
332
333 res.trim();
334
335 return res;
336 }
4e9e88a @fingolfin Added Common::getEnabledSpecialDebugLevels
fingolfin authored
337
51a9bfc @lordhoto Refactor GUI options update into a function in Common: updateGameGUIO…
lordhoto authored
338 void updateGameGUIOptions(const uint32 options) {
339 if ((options && !ConfMan.hasKey("guioptions")) ||
340 (ConfMan.hasKey("guioptions") && options != parseGameGUIOptions(ConfMan.get("guioptions")))) {
341 ConfMan.set("guioptions", getGameGUIOptionsDescription(options));
342 ConfMan.flushToDisk();
343 }
344 }
345
d4734bd @fingolfin use namespace Common a bit more; don't zero the RNG in scumm (else th…
fingolfin authored
346 } // End of namespace Common
Something went wrong with that request. Please try again.