1//============================================================================
2//
3// SSSS tt lll lll
4// SS SS tt ll ll
5// SS tttttt eeee ll ll aaaa
6// SSSS tt ee ee ll ll aa
7// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
8// SS SS tt ee ll ll aa aa
9// SSSS ttt eeeee llll llll aaaaa
10//
11// Copyright (c) 1995-2019 by Bradford W. Mott, Stephen Anthony
12// and the Stella Team
13//
14// See the file "License.txt" for information on usage and redistribution of
15// this file, and for a DISCLAIMER OF ALL WARRANTIES.
16//============================================================================
17
18#include "Bankswitch.hxx"
19
20// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
21string Bankswitch::typeToName(Bankswitch::Type type)
22{
23 return BSList[int(type)].name;
24}
25
26// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
27Bankswitch::Type Bankswitch::nameToType(const string& name)
28{
29 auto it = ourNameToTypes.find(name);
30 if(it != ourNameToTypes.end())
31 return it->second;
32
33 return Bankswitch::Type::_AUTO;
34}
35
36// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
37Bankswitch::Type Bankswitch::typeFromExtension(const FilesystemNode& file)
38{
39 const string& name = file.getPath();
40 string::size_type idx = name.find_last_of('.');
41 if(idx != string::npos)
42 {
43 auto it = ourExtensions.find(name.c_str() + idx + 1);
44 if(it != ourExtensions.end())
45 return it->second;
46 }
47
48 return Bankswitch::Type::_AUTO;
49}
50
51// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
52bool Bankswitch::isValidRomName(const string& name, string& ext)
53{
54 string::size_type idx = name.find_last_of('.');
55 if(idx != string::npos)
56 {
57 const char* const e = name.c_str() + idx + 1;
58 auto it = ourExtensions.find(e);
59 if(it != ourExtensions.end())
60 {
61 ext = e;
62 return true;
63 }
64 }
65 return false;
66}
67
68// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
69bool Bankswitch::isValidRomName(const FilesystemNode& name, string& ext)
70{
71 return isValidRomName(name.getPath(), ext);
72}
73
74// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
75bool Bankswitch::isValidRomName(const FilesystemNode& name)
76{
77 string ext; // extension not used
78 return isValidRomName(name.getPath(), ext);
79}
80
81// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
82bool Bankswitch::isValidRomName(const string& name)
83{
84 string ext; // extension not used
85 return isValidRomName(name, ext);
86}
87
88// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
89Bankswitch::Description Bankswitch::BSList[int(Bankswitch::Type::NumSchemes)] = {
90 { "AUTO" , "Auto-detect" },
91 { "0840" , "0840 (8K ECONObank)" },
92 { "2IN1" , "2IN1 Multicart (4-32K)" },
93 { "4IN1" , "4IN1 Multicart (8-32K)" },
94 { "8IN1" , "8IN1 Multicart (16-64K)" },
95 { "16IN1" , "16IN1 Multicart (32-128K)" },
96 { "32IN1" , "32IN1 Multicart (64/128K)" },
97 { "64IN1" , "64IN1 Multicart (128/256K)" },
98 { "128IN1" , "128IN1 Multicart (256/512K)" },
99 { "2K" , "2K (64-2048 bytes Atari)" },
100 { "3E" , "3E (32K Tigervision)" },
101 { "3E+" , "3E+ (TJ modified DASH)" },
102 { "3F" , "3F (512K Tigervision)" },
103 { "4A50" , "4A50 (64K 4A50 + ram)" },
104 { "4K" , "4K (4K Atari)" },
105 { "4KSC" , "4KSC (CPUWIZ 4K + ram)" },
106 { "AR" , "AR (Supercharger)" },
107 { "BF" , "BF (CPUWIZ 256K)" },
108 { "BFSC" , "BFSC (CPUWIZ 256K + ram)" },
109 { "BUS" , "BUS (Experimental)" },
110 { "CDF" , "CDF (Chris, Darrell, Fred)" },
111 { "CM" , "CM (SpectraVideo CompuMate)" },
112 { "CTY" , "CTY (CDW - Chetiry)" },
113 { "CV" , "CV (Commavid extra ram)" },
114 { "CV+" , "CV+ (Extended Commavid)" },
115 { "DASH" , "DASH (Experimental)" },
116 { "DF" , "DF (CPUWIZ 128K)" },
117 { "DFSC" , "DFSC (CPUWIZ 128K + ram)" },
118 { "DPC" , "DPC (Pitfall II)" },
119 { "DPC+" , "DPC+ (Enhanced DPC)" },
120 { "E0" , "E0 (8K Parker Bros)" },
121 { "E7" , "E7 (16K M-network)" },
122 { "E78K" , "E78K (8K M-network)" },
123 { "EF" , "EF (64K H. Runner)" },
124 { "EFSC" , "EFSC (64K H. Runner + ram)" },
125 { "F0" , "F0 (Dynacom Megaboy)" },
126 { "F4" , "F4 (32K Atari)" },
127 { "F4SC" , "F4SC (32K Atari + ram)" },
128 { "F6" , "F6 (16K Atari)" },
129 { "F6SC" , "F6SC (16K Atari + ram)" },
130 { "F8" , "F8 (8K Atari)" },
131 { "F8SC" , "F8SC (8K Atari + ram)" },
132 { "FA" , "FA (CBS RAM Plus)" },
133 { "FA2" , "FA2 (CBS RAM Plus 24/28K)" },
134 { "FC" , "FC (32K Amiga)" },
135 { "FE" , "FE (8K Decathlon)" },
136 { "MDM" , "MDM (Menu Driven Megacart)" },
137 { "SB" , "SB (128-256K SUPERbank)" },
138 { "UA" , "UA (8K UA Ltd.)" },
139 { "UASW" , "UASW (8K UA swapped banks)" },
140 { "WD" , "WD (Pink Panther)" },
141 { "WDSW" , "WDSW (Pink Panther, bad)" },
142 { "X07" , "X07 (64K AtariAge)" },
143#if defined(CUSTOM_ARM)
144 { "CUSTOM" , "CUSTOM (ARM)" }
145#endif
146};
147
148// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
149Bankswitch::ExtensionMap Bankswitch::ourExtensions = {
150 // Normal file extensions that don't actually tell us anything
151 // about the bankswitch type to use
152 { "a26" , Bankswitch::Type::_AUTO },
153 { "bin" , Bankswitch::Type::_AUTO },
154 { "rom" , Bankswitch::Type::_AUTO },
155#if defined(ZIP_SUPPORT)
156 { "zip" , Bankswitch::Type::_AUTO },
157#endif
158 { "cu" , Bankswitch::Type::_AUTO },
159
160 // All bankswitch types (those that UnoCart and HarmonyCart support have the same name)
161 { "084" , Bankswitch::Type::_0840 },
162 { "0840" , Bankswitch::Type::_0840 },
163 { "2N1" , Bankswitch::Type::_2IN1 },
164 { "4N1" , Bankswitch::Type::_4IN1 },
165 { "8N1" , Bankswitch::Type::_8IN1 },
166 { "16N" , Bankswitch::Type::_16IN1 },
167 { "16N1" , Bankswitch::Type::_16IN1 },
168 { "32N" , Bankswitch::Type::_32IN1 },
169 { "32N1" , Bankswitch::Type::_32IN1 },
170 { "64N" , Bankswitch::Type::_64IN1 },
171 { "64N1" , Bankswitch::Type::_64IN1 },
172 { "128" , Bankswitch::Type::_128IN1 },
173 { "128N1" , Bankswitch::Type::_128IN1 },
174 { "2K" , Bankswitch::Type::_2K },
175 { "3E" , Bankswitch::Type::_3E },
176 { "3EP" , Bankswitch::Type::_3EP },
177 { "3E+" , Bankswitch::Type::_3EP },
178 { "3F" , Bankswitch::Type::_3F },
179 { "4A5" , Bankswitch::Type::_4A50 },
180 { "4A50" , Bankswitch::Type::_4A50 },
181 { "4K" , Bankswitch::Type::_4K },
182 { "4KS" , Bankswitch::Type::_4KSC },
183 { "4KSC" , Bankswitch::Type::_4KSC },
184 { "AR" , Bankswitch::Type::_AR },
185 { "BF" , Bankswitch::Type::_BF },
186 { "BFS" , Bankswitch::Type::_BFSC },
187 { "BFSC" , Bankswitch::Type::_BFSC },
188 { "BUS" , Bankswitch::Type::_BUS },
189 { "CDF" , Bankswitch::Type::_CDF },
190 { "CM" , Bankswitch::Type::_CM },
191 { "CTY" , Bankswitch::Type::_CTY },
192 { "CV" , Bankswitch::Type::_CV },
193 { "CVP" , Bankswitch::Type::_CVP },
194 { "DAS" , Bankswitch::Type::_DASH },
195 { "DASH" , Bankswitch::Type::_DASH },
196 { "DF" , Bankswitch::Type::_DF },
197 { "DFS" , Bankswitch::Type::_DFSC },
198 { "DFSC" , Bankswitch::Type::_DFSC },
199 { "DPC" , Bankswitch::Type::_DPC },
200 { "DPP" , Bankswitch::Type::_DPCP },
201 { "DPCP" , Bankswitch::Type::_DPCP },
202 { "E0" , Bankswitch::Type::_E0 },
203 { "E7" , Bankswitch::Type::_E7 },
204 { "E78" , Bankswitch::Type::_E78K },
205 { "E78K" , Bankswitch::Type::_E78K },
206 { "EF" , Bankswitch::Type::_EF },
207 { "EFS" , Bankswitch::Type::_EFSC },
208 { "EFSC" , Bankswitch::Type::_EFSC },
209 { "F0" , Bankswitch::Type::_F0 },
210 { "F4" , Bankswitch::Type::_F4 },
211 { "F4S" , Bankswitch::Type::_F4SC },
212 { "F4SC" , Bankswitch::Type::_F4SC },
213 { "F6" , Bankswitch::Type::_F6 },
214 { "F6S" , Bankswitch::Type::_F6SC },
215 { "F6SC" , Bankswitch::Type::_F6SC },
216 { "F8" , Bankswitch::Type::_F8 },
217 { "F8S" , Bankswitch::Type::_F8SC },
218 { "F8SC" , Bankswitch::Type::_F8SC },
219 { "FA" , Bankswitch::Type::_FA },
220 { "FA2" , Bankswitch::Type::_FA2 },
221 { "FC" , Bankswitch::Type::_FC },
222 { "FE" , Bankswitch::Type::_FE },
223 { "MDM" , Bankswitch::Type::_MDM },
224 { "SB" , Bankswitch::Type::_SB },
225 { "UA" , Bankswitch::Type::_UA },
226 { "UASW" , Bankswitch::Type::_UASW },
227 { "WD" , Bankswitch::Type::_WD },
228 { "WDSW" , Bankswitch::Type::_WDSW },
229 { "X07" , Bankswitch::Type::_X07 }
230};
231
232// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
233Bankswitch::NameToTypeMap Bankswitch::ourNameToTypes = {
234 { "AUTO" , Bankswitch::Type::_AUTO },
235 { "0840" , Bankswitch::Type::_0840 },
236 { "2IN1" , Bankswitch::Type::_2IN1 },
237 { "4IN1" , Bankswitch::Type::_4IN1 },
238 { "8IN1" , Bankswitch::Type::_8IN1 },
239 { "16IN1" , Bankswitch::Type::_16IN1 },
240 { "32IN1" , Bankswitch::Type::_32IN1 },
241 { "64IN1" , Bankswitch::Type::_64IN1 },
242 { "128IN1" , Bankswitch::Type::_128IN1 },
243 { "2K" , Bankswitch::Type::_2K },
244 { "3E" , Bankswitch::Type::_3E },
245 { "3E+" , Bankswitch::Type::_3EP },
246 { "3F" , Bankswitch::Type::_3F },
247 { "4A50" , Bankswitch::Type::_4A50 },
248 { "4K" , Bankswitch::Type::_4K },
249 { "4KSC" , Bankswitch::Type::_4KSC },
250 { "AR" , Bankswitch::Type::_AR },
251 { "BF" , Bankswitch::Type::_BF },
252 { "BFSC" , Bankswitch::Type::_BFSC },
253 { "BUS" , Bankswitch::Type::_BUS },
254 { "CDF" , Bankswitch::Type::_CDF },
255 { "CM" , Bankswitch::Type::_CM },
256 { "CTY" , Bankswitch::Type::_CTY },
257 { "CV" , Bankswitch::Type::_CV },
258 { "CV+" , Bankswitch::Type::_CVP },
259 { "DASH" , Bankswitch::Type::_DASH },
260 { "DF" , Bankswitch::Type::_DF },
261 { "DFSC" , Bankswitch::Type::_DFSC },
262 { "DPC" , Bankswitch::Type::_DPC },
263 { "DPC+" , Bankswitch::Type::_DPCP },
264 { "E0" , Bankswitch::Type::_E0 },
265 { "E7" , Bankswitch::Type::_E7 },
266 { "E78K" , Bankswitch::Type::_E78K },
267 { "EF" , Bankswitch::Type::_EF },
268 { "EFSC" , Bankswitch::Type::_EFSC },
269 { "F0" , Bankswitch::Type::_F0 },
270 { "F4" , Bankswitch::Type::_F4 },
271 { "F4SC" , Bankswitch::Type::_F4SC },
272 { "F6" , Bankswitch::Type::_F6 },
273 { "F6SC" , Bankswitch::Type::_F6SC },
274 { "F8" , Bankswitch::Type::_F8 },
275 { "F8SC" , Bankswitch::Type::_F8SC },
276 { "FA" , Bankswitch::Type::_FA },
277 { "FA2" , Bankswitch::Type::_FA2 },
278 { "FC" , Bankswitch::Type::_FC },
279 { "FE" , Bankswitch::Type::_FE },
280 { "MDM" , Bankswitch::Type::_MDM },
281 { "SB" , Bankswitch::Type::_SB },
282 { "UA" , Bankswitch::Type::_UA },
283 { "UASW" , Bankswitch::Type::_UASW },
284 { "WD" , Bankswitch::Type::_WD },
285 { "WDSW" , Bankswitch::Type::_WDSW },
286 { "X07" , Bankswitch::Type::_X07 }
287};
288