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 "bspf.hxx"
19
20#include "OSystem.hxx"
21#include "Version.hxx"
22#include "Logger.hxx"
23#include "AudioSettings.hxx"
24
25#ifdef DEBUGGER_SUPPORT
26 #include "DebuggerDialog.hxx"
27#endif
28
29#include "Settings.hxx"
30#include "repository/KeyValueRepositoryNoop.hxx"
31
32// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
33Settings::Settings()
34{
35 myRespository = make_shared<KeyValueRepositoryNoop>();
36
37 // Video-related options
38 setPermanent("video", "");
39 setPermanent("speed", "1.0");
40 setPermanent("vsync", "true");
41 setPermanent("center", "true");
42 setPermanent("windowedpos", Common::Point(50, 50));
43 setPermanent("display", 0);
44 setPermanent("palette", "standard");
45 setPermanent("uimessages", "true");
46
47 // TIA specific options
48 setPermanent("tia.zoom", "3");
49 setPermanent("tia.inter", "false");
50 setPermanent("tia.aspectn", "100");
51 setPermanent("tia.aspectp", "100");
52 setPermanent("fullscreen", "false");
53 setPermanent("tia.fs_stretch", "false");
54 setPermanent("tia.fs_overscan", "0");
55 setPermanent("tia.dbgcolors", "roygpb");
56
57 // TV filtering options
58 setPermanent("tv.filter", "0");
59 setPermanent("tv.phosphor", "byrom");
60 setPermanent("tv.phosblend", "50");
61 setPermanent("tv.scanlines", "25");
62 // TV options when using 'custom' mode
63 setPermanent("tv.contrast", "0.0");
64 setPermanent("tv.brightness", "0.0");
65 setPermanent("tv.hue", "0.0");
66 setPermanent("tv.saturation", "0.0");
67 setPermanent("tv.gamma", "0.0");
68 setPermanent("tv.sharpness", "0.0");
69 setPermanent("tv.resolution", "0.0");
70 setPermanent("tv.artifacts", "0.0");
71 setPermanent("tv.fringing", "0.0");
72 setPermanent("tv.bleed", "0.0");
73
74 // Sound options
75 setPermanent(AudioSettings::SETTING_ENABLED, AudioSettings::DEFAULT_ENABLED);
76 setPermanent(AudioSettings::SETTING_VOLUME, AudioSettings::DEFAULT_VOLUME);
77 setPermanent(AudioSettings::SETTING_PRESET, static_cast<int>(AudioSettings::DEFAULT_PRESET));
78 setPermanent(AudioSettings::SETTING_FRAGMENT_SIZE, AudioSettings::DEFAULT_FRAGMENT_SIZE);
79 setPermanent(AudioSettings::SETTING_SAMPLE_RATE, AudioSettings::DEFAULT_SAMPLE_RATE);
80 setPermanent(AudioSettings::SETTING_RESAMPLING_QUALITY, static_cast<int>(AudioSettings::DEFAULT_RESAMPLING_QUALITY));
81 setPermanent(AudioSettings::SETTING_HEADROOM, AudioSettings::DEFAULT_HEADROOM);
82 setPermanent(AudioSettings::SETTING_BUFFER_SIZE, AudioSettings::DEFAULT_BUFFER_SIZE);
83 setPermanent(AudioSettings::SETTING_STEREO, AudioSettings::DEFAULT_STEREO);
84 setPermanent(AudioSettings::SETTING_DPC_PITCH, AudioSettings::DEFAULT_DPC_PITCH);
85
86 // Input event options
87 setPermanent("event_ver", "1");
88 setPermanent("keymap_emu", "");
89 setPermanent("keymap_joy", "");
90 setPermanent("keymap_pad", "");
91 setPermanent("keymap_key", "");
92 setPermanent("keymap_ui", "");
93 setPermanent("joymap", "");
94 setPermanent("combomap", "");
95 setPermanent("joydeadzone", "13");
96 setPermanent("joyallow4", "false");
97 setPermanent("usemouse", "analog");
98 setPermanent("grabmouse", "true");
99 setPermanent("cursor", "2");
100 setPermanent("dejitter.base", "0");
101 setPermanent("dejitter.diff", "0");
102 setPermanent("dsense", "10");
103 setPermanent("msense", "10");
104 setPermanent("tsense", "10");
105 setPermanent("saport", "lr");
106 setPermanent("modcombo", "true");
107
108 // Snapshot options
109 setPermanent("snapsavedir", "");
110 setPermanent("snaploaddir", "");
111 setPermanent("snapname", "int");
112 setPermanent("sssingle", "false");
113 setPermanent("ss1x", "false");
114 setPermanent("ssinterval", "2");
115 setPermanent("autoslot", "false");
116 setPermanent("saveonexit", "none");
117
118 // Config files and paths
119 setPermanent("romdir", "");
120
121 // ROM browser options
122 setPermanent("exitlauncher", "false");
123 setPermanent("launcherres", Common::Size(900, 600));
124 setPermanent("launcherfont", "medium");
125 setPermanent("launcherroms", "true");
126 setPermanent("romviewer", "1");
127 setPermanent("lastrom", "");
128
129 // UI-related options
130#ifdef DEBUGGER_SUPPORT
131 setPermanent("dbg.res",
132 Common::Size(DebuggerDialog::kMediumFontMinW,
133 DebuggerDialog::kMediumFontMinH));
134#endif
135 setPermanent("uipalette", "standard");
136 setPermanent("hidpi", "false");
137 setPermanent("listdelay", "300");
138 setPermanent("mwheel", "4");
139 setPermanent("mdouble", "500");
140 setPermanent("ctrldelay", "400");
141 setPermanent("ctrlrate", "20");
142 setPermanent("basic_settings", false);
143 setPermanent("dialogpos", 0);
144
145 // Misc options
146 setPermanent("loglevel", int(Logger::Level::INFO));
147 setPermanent("logtoconsole", "0");
148 setPermanent("avoxport", "");
149 setPermanent("fastscbios", "true");
150 setPermanent("threads", "false");
151 setTemporary("romloadcount", "0");
152 setTemporary("maxres", "");
153
154#ifdef DEBUGGER_SUPPORT
155 // Debugger/disassembly options
156 setPermanent("dbg.fontsize", "medium");
157 setPermanent("dbg.fontstyle", "0");
158 setPermanent("dbg.uhex", "false");
159 setPermanent("dbg.ghostreadstrap", "true");
160 setPermanent("dis.resolve", "true");
161 setPermanent("dis.gfxformat", "2");
162 setPermanent("dis.showaddr", "true");
163 setPermanent("dis.relocate", "false");
164 setPermanent("dev.rwportbreak", "true");
165 setPermanent("dev.wrportbreak", "true");
166#endif
167
168 // Player settings
169 setPermanent("plr.stats", "false");
170 setPermanent("plr.bankrandom", "false");
171 setPermanent("plr.ramrandom", "true");
172 setPermanent("plr.cpurandom", "AXYP");
173 setPermanent("plr.colorloss", "false");
174 setPermanent("plr.tv.jitter", "true");
175 setPermanent("plr.tv.jitter_recovery", "10");
176 setPermanent("plr.debugcolors", "false");
177 setPermanent("plr.console", "2600"); // 7800
178 setPermanent("plr.timemachine", true);
179 setPermanent("plr.tm.size", 200);
180 setPermanent("plr.tm.uncompressed", 60);
181 setPermanent("plr.tm.interval", "30f"); // = 0.5 seconds
182 setPermanent("plr.tm.horizon", "10m"); // = ~10 minutes
183 setPermanent("plr.eepromaccess", "false");
184
185 // Developer settings
186 setPermanent("dev.settings", "false");
187 setPermanent("dev.stats", "true");
188 setPermanent("dev.bankrandom", "true");
189 setPermanent("dev.ramrandom", "true");
190 setPermanent("dev.cpurandom", "SAXYP");
191 setPermanent("dev.colorloss", "true");
192 setPermanent("dev.tv.jitter", "true");
193 setPermanent("dev.tv.jitter_recovery", "2");
194 setPermanent("dev.debugcolors", "false");
195 setPermanent("dev.tiadriven", "true");
196 setPermanent("dev.console", "2600"); // 7800
197 setPermanent("dev.tia.type", "standard");
198 setPermanent("dev.tia.plinvphase", "true");
199 setPermanent("dev.tia.msinvphase", "true");
200 setPermanent("dev.tia.blinvphase", "true");
201 setPermanent("dev.tia.delaypfbits", "true");
202 setPermanent("dev.tia.delaypfcolor", "true");
203 setPermanent("dev.tia.delayplswap", "true");
204 setPermanent("dev.tia.delayblswap", "true");
205 setPermanent("dev.timemachine", true);
206 setPermanent("dev.tm.size", 1000);
207 setPermanent("dev.tm.uncompressed", 600);
208 setPermanent("dev.tm.interval", "1f"); // = 1 frame
209 setPermanent("dev.tm.horizon", "30s"); // = ~30 seconds
210 // Thumb ARM emulation options
211 setPermanent("dev.thumb.trapfatal", "true");
212 setPermanent("dev.eepromaccess", "true");
213}
214
215// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
216void Settings::setRepository(shared_ptr<KeyValueRepository> repository)
217{
218 myRespository = repository;
219}
220
221// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
222void Settings::load(const Options& options)
223{
224 Options fromFile = myRespository->load();
225 for (const auto& opt: fromFile)
226 setValue(opt.first, opt.second, false);
227
228 // Apply commandline options, which override those from settings file
229 for(const auto& opt: options)
230 setValue(opt.first, opt.second, false);
231
232 // Finally, validate some settings, so the rest of the codebase
233 // can assume the values are valid
234 validate();
235}
236
237// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
238void Settings::save()
239{
240 myRespository->save(myPermanentSettings);
241}
242
243// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
244void Settings::validate()
245{
246 string s;
247 int i;
248 float f;
249
250 f = getFloat("speed");
251 if (f <= 0) setValue("speed", "1.0");
252
253 i = getInt("tia.aspectn");
254 if(i < 80 || i > 120) setValue("tia.aspectn", "90");
255 i = getInt("tia.aspectp");
256 if(i < 80 || i > 120) setValue("tia.aspectp", "100");
257
258 s = getString("tia.dbgcolors");
259 sort(s.begin(), s.end());
260 if(s != "bgopry") setValue("tia.dbgcolors", "roygpb");
261
262 s = getString("tv.phosphor");
263 if(s != "always" && s != "byrom") setValue("tv.phosphor", "byrom");
264
265 i = getInt("tv.phosblend");
266 if(i < 0 || i > 100) setValue("tv.phosblend", "50");
267
268 i = getInt("tv.filter");
269 if(i < 0 || i > 5) setValue("tv.filter", "0");
270
271 i = getInt("dev.tv.jitter_recovery");
272 if(i < 1 || i > 20) setValue("dev.tv.jitter_recovery", "2");
273
274 int size = getInt("dev.tm.size");
275 if(size < 20 || size > 1000)
276 {
277 setValue("dev.tm.size", 20);
278 size = 20;
279 }
280
281 i = getInt("dev.tm.uncompressed");
282 if(i < 0 || i > size) setValue("dev.tm.uncompressed", size);
283
284 /*i = getInt("dev.tm.interval");
285 if(i < 0 || i > 5) setValue("dev.tm.interval", 0);
286
287 i = getInt("dev.tm.horizon");
288 if(i < 0 || i > 6) setValue("dev.tm.horizon", 1);*/
289
290 i = getInt("plr.tv.jitter_recovery");
291 if(i < 1 || i > 20) setValue("plr.tv.jitter_recovery", "10");
292
293 size = getInt("plr.tm.size");
294 if(size < 20 || size > 1000)
295 {
296 setValue("plr.tm.size", 20);
297 size = 20;
298 }
299
300 i = getInt("plr.tm.uncompressed");
301 if(i < 0 || i > size) setValue("plr.tm.uncompressed", size);
302
303 /*i = getInt("plr.tm.interval");
304 if(i < 0 || i > 5) setValue("plr.tm.interval", 3);
305
306 i = getInt("plr.tm.horizon");
307 if(i < 0 || i > 6) setValue("plr.tm.horizon", 5);*/
308
309#ifdef SOUND_SUPPORT
310 AudioSettings::normalize(*this);
311#endif
312
313 i = getInt("joydeadzone");
314 if(i < 0) setValue("joydeadzone", "0");
315 else if(i > 29) setValue("joydeadzone", "29");
316
317 i = getInt("cursor");
318 if(i < 0 || i > 3)
319 setValue("cursor", "2");
320
321 i = getInt("dsense");
322 if(i < 1 || i > 20)
323 setValue("dsense", "10");
324
325 i = getInt("msense");
326 if(i < 1 || i > 20)
327 setValue("msense", "10");
328
329 i = getInt("tsense");
330 if(i < 1 || i > 20)
331 setValue("tsense", "10");
332
333 i = getInt("ssinterval");
334 if(i < 1) setValue("ssinterval", "2");
335 else if(i > 10) setValue("ssinterval", "10");
336
337 s = getString("palette");
338 if(s != "standard" && s != "z26" && s != "user")
339 setValue("palette", "standard");
340
341 s = getString("launcherfont");
342 if(s != "small" && s != "medium" && s != "large")
343 setValue("launcherfont", "medium");
344
345 s = getString("dbg.fontsize");
346 if(s != "small" && s != "medium" && s != "large")
347 setValue("dbg.fontsize", "medium");
348
349 i = getInt("romviewer");
350 if(i < 0) setValue("romviewer", "0");
351 else if(i > 2) setValue("romviewer", "2");
352
353 i = getInt("loglevel");
354 if(i < int(Logger::Level::MIN) || i > int(Logger::Level::MAX))
355 setValue("loglevel", int(Logger::Level::INFO));
356}
357
358// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
359void Settings::usage() const
360{
361 cout << endl
362 << "Stella version " << STELLA_VERSION << endl
363 << endl
364 << "Usage: stella [options ...] romfile" << endl
365 << " Run without any options or romfile to use the ROM launcher" << endl
366 << " Consult the manual for more in-depth information" << endl
367 << endl
368 << "Valid options are:" << endl
369 << endl
370 << " -video <type> Type is one of the following:\n"
371 #ifdef BSPF_WINDOWS
372 << " direct3d Direct3D acceleration\n"
373 #endif
374 << " opengl OpenGL acceleration\n"
375 << " opengles2 OpenGLES 2 acceleration\n"
376 << " opengles OpenGLES 1 acceleration\n"
377 << " software Software mode (no acceleration)\n"
378 << endl
379 << " -vsync <1|0> Enable 'synchronize to vertical blank interrupt'\n"
380 << " -fullscreen <1|0> Enable fullscreen mode\n"
381 << " -center <1|0> Centers game window in windowed modes\n"
382 << " -windowedpos <XxY> Sets the window position in windowed modes\n"
383 << " -display <number> Sets the display for Stella\n"
384 << " -palette <standard| Use the specified color palette\n"
385 << " z26|\n"
386 << " user>\n"
387 << " -speed <number> Run emulation at the given speed\n"
388 << " -uimessages <1|0> Show onscreen UI messages for different events\n"
389 << endl
390 #ifdef SOUND_SUPPORT
391 << " -audio.enabled <1|0> Enable audio\n"
392 << " -audio.volume <0-100> Volume\n"
393 << " -audio.preset <1-5> Audio preset (or 1 for custom)\n"
394 << " -audio.sample_rate <number> Output sample rate (44100|48000|96000)\n"
395 << " -audio.fragment_size <number> Fragment size (128|256|512|1024|\n"
396 << " 2048|4096)\n"
397 << " -audio.resampling_quality <1-3> Resampling quality\n"
398 << " -audio.headroom <0-20> Additional half-frames to prebuffer\n"
399 << " -audio.buffer_size <0-20> Max. number of additional half-\n"
400 << " frames to buffer\n"
401 << " -audio.stereo <1|0> Enable stereo mode for all ROMs\n"
402 << endl
403 #endif
404 << " -tia.zoom <zoom> Use the specified zoom level (windowed mode)\n"
405 << " for TIA image\n"
406 << " -tia.inter <1|0> Enable interpolated (smooth) scaling for TIA\n"
407 << " image\n"
408 << " -tia.aspectn <number> Scale TIA width by the given percentage in NTS\n"
409 << " mode\n"
410 << " -tia.aspectp <number> Scale TIA width by the given percentage in PAL\n"
411 << " mode\n"
412 << " -tia.fs_stretch <1|0> Stretch TIA image to fill fullscreen mode\n"
413 << " -tia.fs_overscan <0-10> Add overscan to TIA image in fill fullscreen mode\n"
414 << " -tia.dbgcolors <string> Debug colors to use for each object (see manual\n"
415 << " for description)\n"
416 << endl
417 << " -tv.filter <0-5> Set TV effects off (0) or to specified mode\n"
418 << " (1-5)\n"
419 << " -tv.phosphor <always|byrom> When to use phosphor mode\n"
420 << " -tv.phosblend <0-100> Set default blend level in phosphor mode\n"
421 << " -tv.scanlines <0-100> Set scanline intensity to percentage\n"
422 << " (0 disables completely)\n"
423 << " -tv.contrast <-1.0 - 1.0> Set TV effects custom contrast\n"
424 << " -tv.brightness <-1.0 - 1.0> Set TV effects custom brightness\n"
425 << " -tv.hue <-1.0 - 1.0> Set TV effects custom hue\n"
426 << " -tv.saturation <-1.0 - 1.0> Set TV effects custom saturation\n"
427 << " -tv.gamma <-1.0 - 1.0> Set TV effects custom gamma\n"
428 << " -tv.sharpness <-1.0 - 1.0> Set TV effects custom sharpness\n"
429 << " -tv.resolution <-1.0 - 1.0> Set TV effects custom resolution\n"
430 << " -tv.artifacts <-1.0 - 1.0> Set TV effects custom artifacts\n"
431 << " -tv.fringing <-1.0 - 1.0> Set TV effects custom fringing\n"
432 << " -tv.bleed <-1.0 - 1.0> Set TV effects custom bleed\n"
433 << endl
434 << " -cheat <code> Use the specified cheatcode (see manual for\n"
435 << " description)\n"
436 << " -loglevel <0|1|2> Set level of logging during application run\n"
437 << endl
438 << " -logtoconsole <1|0> Log output to console/commandline\n"
439 << " -joydeadzone <number> Sets 'deadzone' area for analog joysticks (0-29)\n"
440 << " -joyallow4 <1|0> Allow all 4 directions on a joystick to be\n"
441 << " pressed simultaneously\n"
442 << " -usemouse <always|\n"
443 << " analog|\n"
444 << " never> Use mouse as a controller as specified by ROM\n"
445 << " properties in given mode(see manual)\n"
446 << " -grabmouse <1|0> Locks the mouse cursor in the TIA window\n"
447 << " -cursor <0,1,2,3> Set cursor state in UI/emulation modes\n"
448 << " -dejitter.base <0-10> Strength of paddle value averaging\n"
449 << " -dejitter.diff <0-10> Strength of paddle reaction to fast movements\n"
450 << " -dsense <1-20> Sensitivity of digital emulated paddle movement\n"
451 << " -msense <1-20> Sensitivity of mouse emulated paddle movement\n"
452 << " -tsense <1-20> Sensitivity of mouse emulated trackball movement\n"
453 << " -saport <lr|rl> How to assign virtual ports to multiple\n"
454 << " Stelladaptor/2600-daptors\n"
455 << " -modcombo <1|0> Enable modifer key combos\n"
456 << " (Control-Q for quit may not work when disabled!)\n"
457 << " -fastscbios <1|0> Disable Supercharger BIOS progress loading bars\n"
458 << " -threads <1|0> Whether to using multi-threading during\n"
459 << " emulation\n"
460 << " -snapsavedir <path> The directory to save snapshot files to\n"
461 << " -snaploaddir <path> The directory to load snapshot files from\n"
462 << " -snapname <int|rom> Name snapshots according to internal database or\n"
463 << " ROM\n"
464 << " -sssingle <1|0> Generate single snapshot instead of many\n"
465 << " -ss1x <1|0> Generate TIA snapshot in 1x mode (ignore\n"
466 << " scaling/effects)\n"
467 << " -ssinterval <number> Number of seconds between snapshots in\n"
468 << " continuous snapshot mode\n"
469 << " -autoslot <1|0> Automatically switch to next save slot when\n"
470 << " state saving\n"
471 << " -saveonexit <none|current Automatically save state(s) when exiting emulation\n"
472 << " all>\n"
473 << endl
474 << " -rominfo <rom> Display detailed information for the given ROM\n"
475 << " -listrominfo Display contents of stella.pro, one line per ROM\n"
476 << " entry\n"
477 << " \n"
478 << " -exitlauncher <1|0> On exiting a ROM, go back to the ROM launcher\n"
479 << " -launcherres <WxH> The resolution to use in ROM launcher mode\n"
480 << " -launcherfont <small|medium| Use the specified font in the ROM launcher\n"
481 << " large>\n"
482 << " -launcherroms <1|0> Show only ROMs in the launcher (vs. all files)\n"
483 << " -romviewer <0|1|2> Show ROM info viewer at given zoom level in ROM\n"
484 << " launcher (0 for off)\n"
485 << " -lastrom <name> Last played ROM, automatically selected in launcher\n"
486 << " -romloadcount <number> Number of ROM to load next from multicard\n"
487 << " -uipalette <standard| Selects GUI theme\n"
488 << " classic|light>\n"
489 << " -hidpi <0|1> Enable HiDPI mode\n"
490 << " -dialogpos <0..4> Display all dialogs at given positions\n"
491 << " -listdelay <delay> Time to wait between keypresses in list widgets\n"
492 << " (300-1000)\n"
493 << " -mwheel <lines> Number of lines the mouse wheel will scroll in\n"
494 << " UI\n"
495 << " -mdouble <speed> Mouse double click speed in UI\n"
496 << " -ctrldelay <delay> Delay before controller input is repeated in UI\n"
497 << " -ctrlrate <rate> Rate per second of repeated controller input in UI\n"
498 << " -basic_settings <0|1> Display only a basic settings dialog\n"
499 << " -romdir <dir> Set the directory where the ROM launcher will start\n"
500 << " -avoxport <name> The name of the serial port where an AtariVox is\n"
501 << " connected\n"
502 << " -holdreset Start the emulator with the Game Reset switch\n"
503 << " held down\n"
504 << " -holdselect Start the emulator with the Game Select switch\n"
505 << " held down\n"
506 << " -holdjoy0 <U,D,L,R,F> Start the emulator with the left joystick\n"
507 << " direction/fire button held down\n"
508 << " -holdjoy1 <U,D,L,R,F> Start the emulator with the right joystick\n"
509 << " direction/fire button held down\n"
510 << " -maxres <WxH> Used by developers to force the maximum size of\n"
511 << " the application window\n"
512 << " -basedir <path> Override the base directory for all config files\n"
513 << " -baseinappdir Override the base directory for all config files\n"
514 << " by attempting to use the application directory\n"
515 << " -help Show the text you're now reading\n"
516 #ifdef DEBUGGER_SUPPORT
517 << endl
518 << " The following options are meant for developers\n"
519 << " Arguments are more fully explained in the manual\n"
520 << endl
521 << " -dis.resolve <1|0> Attempt to resolve code sections in disassembler\n"
522 << " -dis.gfxformat <2|16> Set base to use for displaying GFX sections in\n"
523 << " disassembler\n"
524 << " -dis.showaddr <1|0> Show opcode addresses in disassembler\n"
525 << " -dis.relocate <1|0> Relocate calls out of address range in\n"
526 << " disassembler\n"
527 << endl
528 << " -dbg.res <WxH> The resolution to use in debugger mode\n"
529 << " -dbg.fontsize <small|medium| Font size to use in debugger window\n"
530 << " large>\n"
531 << " -dbg.fontstyle <0-3> Font style to use in debugger window (bold vs.\n"
532 << " normal)\n"
533 << " -dbg.ghostreadstrap <1|0> Debugger traps on 'ghost' reads\n"
534 << " -dbg.uhex <0|1> lower-/uppercase HEX display\n"
535 << " -break <address> Set a breakpoint at 'address'\n"
536 << " -debug Start in debugger mode\n"
537 << endl
538 << " -bs <arg> Sets the 'Cartridge.Type' (bankswitch) property\n"
539 << " -type <arg> Same as using -bs\n"
540 << " -startbank <bank> Sets the ROM's startup bank\n"
541 << " -channels <arg> Sets the 'Cartridge.Sound' property\n"
542 << " -ld <arg> Sets the 'Console.LeftDifficulty' property\n"
543 << " -rd <arg> Sets the 'Console.RightDifficulty' property\n"
544 << " -tv <arg> Sets the 'Console.TelevisionType' property\n"
545 << " -sp <arg> Sets the 'Console.SwapPorts' property\n"
546 << " -lc <arg> Sets the 'Controller.Left' property\n"
547 << " -rc <arg> Sets the 'Controller.Right' property\n"
548 << " -bc <arg> Same as using both -lc and -rc\n"
549 << " -cp <arg> Sets the 'Controller.SwapPaddles' property\n"
550 << " -format <arg> Sets the 'Display.Format' property\n"
551 << " -ystart <arg> Sets the 'Display.YStart' property\n"
552 << " -pp <arg> Sets the 'Display.Phosphor' property\n"
553 << " -ppblend <arg> Sets the 'Display.PPBlend' property\n"
554 << endl
555 #endif
556
557 << " Various development related parameters for player settings mode\n"
558 << endl
559 << " -dev.settings <1|0> Select developer (1) or player (0) settings\n"
560 << " mode\n"
561 << endl
562 << " -plr.stats <1|0> Overlay console info during emulation\n"
563 << " -plr.console <2600|7800> Select console for B/W and Pause key\n"
564 << " handling and RAM initialization\n"
565 << " -plr.bankrandom <1|0> Randomize the startup bank on reset\n"
566 << " -plr.ramrandom <1|0> Randomize the contents of RAM on reset\n"
567 << " -plr.cpurandom <1|0> Randomize the contents of CPU registers on\n"
568 << " reset\n"
569 << " -plr.debugcolors <1|0> Enable debug colors\n"
570 << " -plr.colorloss <1|0> Enable PAL color-loss effect\n"
571 << " -plr.tv.jitter <1|0> Enable TV jitter effect\n"
572 << " -plr.tv.jitter_recovery <1-20> Set recovery time for TV jitter effect\n"
573 << " -plr.eepromaccess <1|0> Enable messages for AtariVox/SaveKey access\n"
574 << " messages\n"
575 << endl
576 << " The same parameters but for developer settings mode\n"
577 << " -dev.stats <1|0> Overlay console info during emulation\n"
578 << " -dev.console <2600|7800> Select console for B/W and Pause key\n"
579 << " handling and RAM initialization\n"
580 << " -dev.bankrandom <1|0> Randomize the startup bank on reset\n"
581 << " -dev.ramrandom <1|0> Randomize the contents of RAM on reset\n"
582 << " -dev.cpurandom <1|0> Randomize the contents of CPU registers on\n"
583 << " reset\n"
584 << " -dev.debugcolors <1|0> Enable debug colors\n"
585 << " -dev.colorloss <1|0> Enable PAL color-loss effect\n"
586 << " -dev.tv.jitter <1|0> Enable TV jitter effect\n"
587 << " -dev.tv.jitter_recovery <1-20> Set recovery time for TV jitter effect\n"
588 << " -dev.tiadriven <1|0> Drive unused TIA pins randomly on a\n"
589 << " read/peek\n"
590#ifdef DEBUGGER_SUPPORT
591 << " -dev.rwportbreak <1|0> Debugger breaks on reads from write ports\n"
592#endif
593 << " -dev.thumb.trapfatal <1|0> Determines whether errors in ARM emulation\n"
594 << " throw an exception\n"
595 << " -dev.eepromaccess <1|0> Enable messages for AtariVox/SaveKey access\n"
596 << " messages\n"
597 << " -dev.tia.type <standard|custom| Selects a TIA type\n"
598 << " koolaidman|\n"
599 << " cosmicark|pesco|\n"
600 << " quickstep|heman|>\n"
601 << " -dev.tia.plinvphase <1|0> Enable inverted HMOVE clock phase for players\n"
602 << " -dev.tia.msinvphase <1|0> Enable inverted HMOVE clock phase for\n"
603 << " missiles\n"
604 << " -dev.tia.blinvphase <1|0> Enable inverted HMOVE clock phase for ball\n"
605 << " -dev.tia.delaypfbits <1|0> Enable extra delay cycle for PF bits access\n"
606 << " -dev.tia.delaypfcolor <1|0> Enable extra delay cycle for PF color\n"
607 << " -dev.tia.delayplswap <1|0> Enable extra delay cycle for VDELP0/1 swap\n"
608 << " -dev.tia.delayblswap <1|0> Enable extra delay cycle for VDELBL swap\n"
609 << endl << std::flush;
610}
611
612// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
613const Variant& Settings::value(const string& key) const
614{
615 // Try to find the named setting and answer its value
616 auto it = myPermanentSettings.find(key);
617 if(it != myPermanentSettings.end())
618 return it->second;
619 else
620 {
621 it = myTemporarySettings.find(key);
622 if(it != myTemporarySettings.end())
623 return it->second;
624 }
625 return EmptyVariant;
626}
627
628// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
629void Settings::setValue(const string& key, const Variant& value, bool persist)
630{
631 auto it = myPermanentSettings.find(key);
632 if(it != myPermanentSettings.end()) {
633 if (persist && it->second != value) myRespository->save(key, value);
634 it->second = value;
635 }
636 else
637 myTemporarySettings[key] = value;
638}
639
640// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
641void Settings::setPermanent(const string& key, const Variant& value)
642{
643 myPermanentSettings[key] = value;
644}
645
646// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
647void Settings::setTemporary(const string& key, const Variant& value)
648{
649 myTemporarySettings[key] = value;
650}
651