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 #include "common/platform.h"
24 #include "common/str.h"
25 
26 namespace Common {
27 
28 const PlatformDescription g_platforms[] = {
29 	{ "2gs", "2gs", "2gs", "Apple IIgs", kPlatformApple2GS },
30 	{ "apple2", "apple2", "apple2", "Apple II", kPlatformApple2 },
31 	{ "3do", "3do", "3do", "3DO", kPlatform3DO },
32 	{ "acorn", "acorn", "acorn", "Acorn", kPlatformAcorn },
33 	{ "amiga", "ami", "amiga", "Amiga", kPlatformAmiga },
34 	{ "atari8", "atari8", "atari8", "Atari 8-bit", kPlatformAtari8Bit },
35 	{ "atari", "atari-st", "st", "Atari ST", kPlatformAtariST },
36 	{ "c64", "c64", "c64", "Commodore 64", kPlatformC64 },
37 	{ "pc", "dos", "ibm", "DOS", kPlatformDOS },
38 	{ "pc98", "pc98", "pc98", "PC-98", kPlatformPC98 },
39 	{ "wii", "wii", "wii", "Nintendo Wii", kPlatformWii },
40 	{ "coco3", "coco3", "coco3", "CoCo3", kPlatformCoCo3 },
41 
42 	// The 'official' spelling seems to be "FM-TOWNS" (e.g. in the Indy4 demo).
43 	// However, on the net many variations can be seen, like "FMTOWNS",
44 	// "FM TOWNS", "FmTowns", etc.
45 	{ "fmtowns", "towns", "fm", "FM-TOWNS", kPlatformFMTowns },
46 
47 	{ "linux", "linux", "linux", "Linux", kPlatformLinux },
48 	{ "macintosh", "mac", "mac", "Macintosh", kPlatformMacintosh },
49 	{ "pce", "pce", "pce", "PC-Engine", kPlatformPCEngine },
50 	{ "nes", "nes", "nes", "NES", kPlatformNES },
51 	{ "segacd", "segacd", "sega", "SegaCD", kPlatformSegaCD },
52 	{ "windows", "win", "win", "Windows", kPlatformWindows },
53 	{ "playstation", "psx", "psx", "Sony PlayStation", kPlatformPSX },
54 	{ "playstation2", "ps2", "ps2", "Sony PlayStation 2", kPlatformPS2 },
55 	{ "xbox", "xbox", "xbox", "Microsoft Xbox", kPlatformXbox },
56 	{ "cdi", "cdi", "cdi", "Philips CD-i", kPlatformCDi },
57 	{ "ios", "ios", "ios", "Apple iOS", kPlatformIOS },
58 	{ "os2", "os2", "os2", "OS/2", kPlatformOS2 },
59 	{ "beos", "beos", "beos", "BeOS", kPlatformBeOS },
60 	{ "ppc", "ppc", "ppc", "PocketPC", kPlatformPocketPC },
61 	{ "megadrive", "genesis", "md", "Mega Drive/Genesis", kPlatformMegaDrive },
62 	{ "saturn", "saturn", "saturn", "Sega Saturn", kPlatformSaturn },
63 	{ "pippin", "pippin", "pippin", "Pippin", kPlatformPippin },
64 	{ "macintosh2", "macintosh2", "mac2", "Macintosh II", kPlatformMacintoshII },
65 	{ "shockwave", "shockwave", "shock", "Shockwave", kPlatformShockwave },
66 
67 	{ nullptr, nullptr, nullptr, "Default", kPlatformUnknown }
68 };
69 
parsePlatform(const String & str)70 Platform parsePlatform(const String &str) {
71 	if (str.empty())
72 		return kPlatformUnknown;
73 
74 	// Handle some special case separately, for compatibility with old config
75 	// files.
76 	if (str == "1")
77 		return kPlatformAmiga;
78 	else if (str == "2")
79 		return kPlatformAtariST;
80 	else if (str == "3")
81 		return kPlatformMacintosh;
82 
83 	const PlatformDescription *l = g_platforms;
84 	for (; l->code; ++l) {
85 		if (str.equalsIgnoreCase(l->code) || str.equalsIgnoreCase(l->code2) || str.equalsIgnoreCase(l->abbrev))
86 			return l->id;
87 	}
88 
89 	return kPlatformUnknown;
90 }
91 
92 
getPlatformCode(Platform id)93 const char *getPlatformCode(Platform id) {
94 	const PlatformDescription *l = g_platforms;
95 	for (; l->code; ++l) {
96 		if (l->id == id)
97 			return l->code;
98 	}
99 	return nullptr;
100 }
101 
getPlatformAbbrev(Platform id)102 const char *getPlatformAbbrev(Platform id) {
103 	const PlatformDescription *l = g_platforms;
104 	for (; l->code; ++l) {
105 		if (l->id == id)
106 			return l->abbrev;
107 	}
108 	return nullptr;
109 }
110 
getPlatformDescription(Platform id)111 const char *getPlatformDescription(Platform id) {
112 	const PlatformDescription *l = g_platforms;
113 	for (; l->code; ++l) {
114 		if (l->id == id)
115 			return l->description;
116 	}
117 	return l->description;
118 }
119 
120 } // End of namespace Common
121