-
Notifications
You must be signed in to change notification settings - Fork 526
Expand file tree
/
Copy pathwconfig.cpp
More file actions
1183 lines (1034 loc) · 50.1 KB
/
wconfig.cpp
File metadata and controls
1183 lines (1034 loc) · 50.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/***********************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com),
Jerremy Koot (jkoot@snes9x.com)
(c) Copyright 2002 - 2004 Matthew Kendora
(c) Copyright 2002 - 2005 Peter Bortas (peter@bortas.org)
(c) Copyright 2004 - 2005 Joel Yliluoma (http://iki.fi/bisqwit/)
(c) Copyright 2001 - 2006 John Weidman (jweidman@slip.net)
(c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com)
(c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net),
Nach (n-a-c-h@users.sourceforge.net),
(c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com)
(c) Copyright 2006 - 2007 nitsuja
(c) Copyright 2009 - 2018 BearOso,
OV2
(c) Copyright 2017 qwertymodo
(c) Copyright 2011 - 2017 Hans-Kristian Arntzen,
Daniel De Matteis
(Under no circumstances will commercial rights be given)
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
zones
C4 x86 assembler and some C emulation code
(c) Copyright 2000 - 2003 _Demo_ (_demo_@zsnes.com),
Nach,
zsKnight (zsknight@zsnes.com)
C4 C++ code
(c) Copyright 2003 - 2006 Brad Jorsch,
Nach
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com),
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
Kris Bleakley,
Matthew Kendora,
Nach,
neviksti (neviksti@hotmail.com)
DSP-2 emulator code
(c) Copyright 2003 John Weidman,
Kris Bleakley,
Lord Nightmare (lord_nightmare@users.sourceforge.net),
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
Lancer,
z80 gaiden
DSP-4 emulator code
(c) Copyright 2004 - 2006 Dreamer Nom,
John Weidman,
Kris Bleakley,
Nach,
z80 gaiden
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code used in 1.39-1.51
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
SPC7110 and RTC C++ emulator code used in 1.52+
(c) Copyright 2009 byuu,
neviksti
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001 - 2006 byuu,
John Weidman
ST010 C++ emulator code
(c) Copyright 2003 Feather,
John Weidman,
Kris Bleakley,
Matthew Kendora
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound emulator code used in 1.5-1.51
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
Sound emulator code used in 1.52+
(c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com)
S-SMP emulator code used in 1.54+
(c) Copyright 2016 byuu
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
2xSaI filter
(c) Copyright 1999 - 2001 Derek Liauw Kie Fa
HQ2x, HQ3x, HQ4x filters
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
NTSC filter
(c) Copyright 2006 - 2007 Shay Green
GTK+ GUI code
(c) Copyright 2004 - 2018 BearOso
Win32 GUI code
(c) Copyright 2003 - 2006 blip,
funkyass,
Matthew Kendora,
Nach,
nitsuja
(c) Copyright 2009 - 2018 OV2
Mac OS GUI code
(c) Copyright 1998 - 2001 John Stiles
(c) Copyright 2001 - 2011 zones
Libretro port
(c) Copyright 2011 - 2017 Hans-Kristian Arntzen,
Daniel De Matteis
(Under no circumstances will commercial rights be given)
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com/
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
fee, providing that this license information and copyright notice appear
with all copies and any derived work.
This software is provided 'as-is', without any express or implied
warranty. In no event shall the authors be held liable for any damages
arising from the use of this software or it's derivatives.
Snes9x is freeware for PERSONAL USE only. Commercial users should
seek permission of the copyright holders first. Commercial use includes,
but is not limited to, charging money for Snes9x or software derived from
Snes9x, including Snes9x or derivatives in commercial game bundles, and/or
using Snes9x as a promotion for your commercial product.
The copyright holders request that bug fixes and improvements to the code
should be forwarded to them so everyone can benefit from the modifications
in future versions.
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
***********************************************************************************/
// all windows-specific command line and config file parsing/saving/loading
// this stuff was moved out of wsnes.cpp, to keep things a little tidier
// note:
// if you want to force all users of a new version to have a
// particular setting reset to its given default,
// change the name string of that setting (in WinRegisterConfigItems)
// to something a little different...
// but if it's not in a windows-specific category, make sure you change its name elsewhere too
#include "../port.h"
#include "../snes9x.h"
#include "wsnes9x.h"
#include "wlanguage.h"
#include "../display.h"
#include "../conffile.h"
#include "../spc7110.h"
#include "../gfx.h"
#include "../snapshot.h"
#ifdef NETPLAY_SUPPORT
#include "../netplay.h"
extern SNPServer NPServer;
#endif
#include <assert.h>
static void WinDeleteRegistryEntries ();
void WinSetDefaultValues ();
void WinDeleteRecentGamesList ();
HANDLE configMutex = NULL;
extern TCHAR multiRomA[MAX_PATH]; // lazy, should put in sGUI and add init to {0} somewhere
extern TCHAR multiRomB[MAX_PATH];
void S9xParseArg (char **argv, int &i, int argc)
{
if (strcasecmp (argv [i], "-restore") == 0)
{
WinDeleteRegistryEntries ();
WinSetDefaultValues ();
}
else if (strcasecmp (argv[i], "-hidemenu") == 0)
{
GUI.HideMenu = true;
}
else if (strcasecmp (argv[i], "-fullscreen") == 0)
{
GUI.FullScreen = true;
}
else if (!strcasecmp(argv[i], "-cartb"))
{
Settings.Multi = TRUE; // only used to signal winmain
if (i + 1 < argc)
{
lstrcpyn(multiRomB, _tFromChar(argv[++i]), MAX_PATH);
}
}
}
void WinSetDefaultValues ()
{
// TODO: delete the parts that are already covered by the default values in WinRegisterConfigItems
char temp[4];
strcpy(temp,"C:\\");
GUI.ControllerOption = SNES_JOYPAD;
GUI.ValidControllerOptions = 0xFFFF;
GUI.IgnoreNextMouseMove = false;
GUI.DoubleBuffered = false;
GUI.FullScreen = false;
GUI.Stretch = false;
GUI.FlipCounter = 0;
GUI.NumFlipFrames = 1;
Settings.BilinearFilter = false;
GUI.LockDirectories = false;
GUI.window_maximized = false;
GUI.EmulatedFullscreen = false;
WinDeleteRecentGamesList ();
GUI.SoundChannelEnable=255;
// Tracing options
Settings.TraceDMA = false;
Settings.TraceHDMA = false;
Settings.TraceVRAM = false;
Settings.TraceUnknownRegisters = false;
Settings.TraceDSP = false;
// ROM timing options (see also H_Max above)
Settings.PAL = false;
Settings.FrameTimePAL = 20000;
Settings.FrameTimeNTSC = 16667;
Settings.FrameTime = 16667;
// CPU options
Settings.Paused = false;
#ifdef NETPLAY_SUPPORT
Settings.Port = 1996;
NetPlay.MaxFrameSkip = 10;
NetPlay.MaxBehindFrameCount = 10;
NPServer.SyncByReset = true;
NPServer.SendROMImageOnConnect = false;
#endif
Settings.TakeScreenshot=false;
GUI.Language=0;
}
static bool try_save(const char *fname, ConfigFile &conf){
STREAM fp;
if((fp=OPEN_STREAM(fname, "w"))!=NULL){
fprintf(stdout, "Saving config file %s\n", fname);
CLOSE_STREAM(fp);
conf.SaveTo(fname);
return true;
}
return false;
}
static bool S9xSaveConfigFile(ConfigFile &conf){
configMutex = CreateMutex(NULL, FALSE, TEXT("Snes9xConfigMutex"));
int times = 0;
DWORD waitVal = WAIT_TIMEOUT;
while(waitVal == WAIT_TIMEOUT && ++times <= 150) // wait at most 15 seconds
waitVal = WaitForSingleObject(configMutex, 100);
// save over the .conf file if it already exists, otherwise save over the .cfg file
std::string fname;
fname=S9xGetDirectory(DEFAULT_DIR);
fname+=SLASH_STR S9X_CONF_FILE_NAME;
// ensure previous config file is not lost if we crash while writing the new one
std::string ftemp;
{
CopyFileA(fname.c_str(), (fname + ".autobak").c_str(), FALSE);
ftemp=S9xGetDirectory(DEFAULT_DIR);
ftemp+=SLASH_STR "config_error";
FILE* tempfile = fopen(ftemp.c_str(), "wb");
if(tempfile) fclose(tempfile);
}
bool ret = try_save(fname.c_str(), conf);
remove(ftemp.c_str());
remove((fname + ".autobak").c_str());
ReleaseMutex(configMutex);
CloseHandle(configMutex);
return ret;
}
static void WinDeleteRegistryEntries ()
{
// WinDeleteRegKey (HKEY_CURRENT_USER, S9X_REG_KEY_BASE);
}
static inline char *SkipSpaces (char *p)
{
while (*p && isspace (*p))
p++;
return (p);
}
const TCHAR* WinParseCommandLineAndLoadConfigFile (TCHAR *line)
{
// Break the command line up into an array of string pointers, each pointer
// points at a separate word or character sequence enclosed in quotes.
int count = 0;
static TCHAR return_filename[MAX_PATH];
#ifdef UNICODE
// split params into argv
TCHAR **params = CommandLineToArgvW(line, &count);
// convert all parameters to utf8
char **parameters = new char*[count];
for(int i = 0; i < count; i++) {
int requiredChars = WideCharToMultiByte(CP_UTF8, 0, params[i], -1, NULL, 0, NULL, NULL);
parameters[i] = new char[requiredChars];
WideCharToMultiByte(CP_UTF8, 0, params[i], -1, parameters[i], requiredChars, NULL, NULL);
}
LocalFree(params);
#else
#define MAX_PARAMETERS 100
char *p = line;
char *parameters[MAX_PARAMETERS];
while (count < MAX_PARAMETERS && *p)
{
p = SkipSpaces (p);
if (*p == '"')
{
p++;
parameters [count++] = p;
while (*p && *p != '"')
p++;
*p++ = 0;
}
else
if (*p == '\'')
{
p++;
parameters [count++] = p;
while (*p && *p != '\'')
p++;
*p++ = 0;
}
else
{
parameters [count++] = p;
while (*p && !isspace (*p))
p++;
if (!*p)
break;
*p++ = 0;
}
}
#endif
configMutex = CreateMutex(NULL, FALSE, TEXT("Snes9xConfigMutex"));
int times = 0;
DWORD waitVal = WAIT_TIMEOUT;
while(waitVal == WAIT_TIMEOUT && ++times <= 150) // wait at most 15 seconds
waitVal = WaitForSingleObject(configMutex, 100);
// ensure previous config file is not lost if we crashed while writing a new one
{
std::string ftemp;
ftemp=S9xGetDirectory(DEFAULT_DIR);
ftemp+=SLASH_STR "config_error";
FILE* tempfile = fopen(ftemp.c_str(), "rb");
if(tempfile)
{
fclose(tempfile);
std::string fname;
for(int i=0; i<2; i++)
{
fname=S9xGetDirectory(DEFAULT_DIR);
if(i == 0) fname+=SLASH_STR "snes9x.conf";
else if(i == 1) fname+=SLASH_STR "snes9x.cfg";
tempfile = fopen((fname + ".autobak").c_str(), "rb");
if(tempfile)
{
fclose(tempfile);
MoveFileExA((fname + ".autobak").c_str(), fname.c_str(), MOVEFILE_REPLACE_EXISTING|MOVEFILE_WRITE_THROUGH);
}
}
remove(ftemp.c_str());
}
}
S9xLoadConfigFiles(parameters, count);
ReleaseMutex(configMutex);
CloseHandle(configMutex);
const char* rf = S9xParseArgs (parameters, count);
if(rf) // save rom_filename as TCHAR if available
lstrcpy(return_filename, _tFromChar(rf));
#ifdef UNICODE
// free parameters
for(int i = 0; i < count; i++) {
delete [] parameters[i];
}
delete [] parameters;
#endif
return rf ? return_filename : NULL;
}
#define S(x) GAMEDEVICE_VK_##x
#define SO(x) GAMEDEVICE_VK_OEM_##x
static const char* keyToString [256] =
{
"Unassigned","LMB","RMB","Break","MMB","XMB1","XMB2","0x07",
S(BACK),S(TAB),"0x0A","0x0B",S(CLEAR),S(RETURN),"0x0E","0x0F",
S(SHIFT),S(CONTROL),S(MENU),S(PAUSE),S(CAPITAL),"Kana","0x16","Junja",
"Final","Kanji","0x1A",S(ESCAPE),"Convert","NonConvert","Accept","ModeChange",
S(SPACE),S(PRIOR),S(NEXT),S(END),S(HOME),S(LEFT),S(UP),S(RIGHT),
S(DOWN),S(SELECT),S(PRINT),S(EXECUTE),S(SNAPSHOT),S(INSERT),S(DELETE),S(HELP),
"0","1","2","3","4","5","6","7",
"8","9","0x3A","0x3B","0x3C","0x3D","0x3E","0x3F",
"0x40","A","B","C","D","E","F","G",
"H","I","J","K","L","M","N","O",
"P","Q","R","S","T","U","V","W",
"X","Y","Z",S(LWIN),S(RWIN),S(APPS),"0x5E","Sleep",
"Pad0","Pad1","Pad2","Pad3","Pad4","Pad5","Pad6","Pad7",
"Pad8","Pad9",S(MULTIPLY),S(ADD),S(SEPARATOR),S(SUBTRACT),S(DECIMAL),S(DIVIDE),
S(F1),S(F2),S(F3),S(F4),S(F5),S(F6),S(F7),S(F8),
S(F9),S(F10),S(F11),S(F12),"F13","F14","F15","F16",
"F17","F18","F19","F20","F21","F22","F23","F24",
"0x88","0x89","0x8A","0x8B","0x8C","0x8D","0x8E","0x8F",
S(NUMLOCK),S(SCROLL),"PadEqual","Masshou","Touroku","Loya","Roya","0x97",
"0x98","0x99","0x9A","0x9B","0x9C","0x9D","0x9E","0x9F",
S(LSHIFT),S(RSHIFT),S(LCONTROL),S(RCONTROL),S(LMENU),S(RMENU),"BrowserBack","BrowserForward",
"BrowserRefresh","BrowserStop","BrowserSearch","BrowserFavorites","BrowserHome","VolumeMute","VolumeDown","VolumeUp",
"MediaNextTrack","MediaPrevTrack","MediaStop","MediaPlayPause","LaunchMail","MediaSelect","LaunchApp1","LaunchApp2",
"0xB8","0xB9",";","+",",",SO(MINUS),".",SO(2),
SO(3),"0xC1","0xC2","0xC3","0xC4","0xC5","0xC6","0xC7",
"0xC8","0xC9","0xCA","0xCB","0xCC","0xCD","0xCE","0xCF",
"0xD0","0xD1","0xD2","0xD3","0xD4","0xD5","0xD6","0xD7",
"0xD8","0xD9","0xDA",SO(4),"Backslash",SO(6),"'","OEM8",
"0xE0","AX","<>","ICOHelp","ICO00","Process","ICOClear","Packet",
"0xE8","Reset","Jump","PA1_2","PA2","PA3","WSCTRL","CUSEL",
"Attention2","Finish","Copy","Auto","ENLW","Backtab","Attention","CRSEL",
"EXSEL","EREOF","Play","Zoom","NoName","PA1","Clear2","0xFF"
};
static const char* keyToAlternateString [256] =
{
"none","LeftClick","RightClick","Cancel","MiddleClick","","","","Back","","","","","Return","","",
"","","Menu","","","","","","","","","Escape","","","","",
"","PageUp","PageDown","","","","","","","","PrintScreen","","","Ins","Del","",
"","","","","","","","","","","","","","","","",
"","","","","","","","","","","","","","","","",
"","","","","","","","","","","","","","","","",
"","","","","","","","","","","","","","","","",
"","","","","","","","","","","","","","","","",
"","","","","","","","","","","","","","","","",
"NumLock","ScrollLock","","","","","","","","","","","","","","",
"","","","","","","","","","","","","","","","",
"","","","","","","","","","",SO(1),SO(PLUS),SO(COMMA),"Minus",SO(PERIOD),"?",
"","","","","","","","","","","","","","","","",
"","","","oem_pa1","","","","","","","","LBracket","|","RBracket",SO(7),"",
"ATTN2","","","","","","","","","","","","","","ATTN","",
"","","","","","","","","","","","","","","",""
};
#undef S
#undef SO
// We will maintain our own list of items to put in the config file,
// so that each config item has only one point of change across both saving and loading
// and to allow us to manage custom types of config items, such as virtual key codes represented as strings
enum ConfigItemType {
CIT_BOOL, CIT_INT, CIT_UINT, CIT_STRING, CIT_INVBOOL, CIT_BOOLONOFF, CIT_INVBOOLONOFF, CIT_VKEY, CIT_VKEYMOD
};
struct ConfigItem
{
const char* name;
void* addr;
int size;
void* def;
const char* comment;
ConfigItemType type;
ConfigItem(const char* nname, void* naddr, int nsize, void* ndef, const char* ncomment, ConfigItemType ntype) {
addr = naddr; name = nname; size = nsize; def = ndef; comment = ncomment; type = ntype;
}
void Get(ConfigFile& conf) {
switch(type)
{
case CIT_BOOL:
case CIT_BOOLONOFF:
if(size == 1) *(uint8 *)addr = (uint8) conf.GetBool(name, def!=0);
if(size == 2) *(uint16*)addr = (uint16)conf.GetBool(name, def!=0);
if(size == 4) *(uint32*)addr = (uint32)conf.GetBool(name, def!=0);
if(size == 8) *(uint64*)addr = (uint64)conf.GetBool(name, def!=0);
break;
case CIT_INT:
if(size == 1) *(uint8 *)addr = (uint8) conf.GetInt(name, reinterpret_cast<int32>(def));
if(size == 2) *(uint16*)addr = (uint16)conf.GetInt(name, reinterpret_cast<int32>(def));
if(size == 4) *(uint32*)addr = (uint32)conf.GetInt(name, reinterpret_cast<int32>(def));
if(size == 8) *(uint64*)addr = (uint64)conf.GetInt(name, reinterpret_cast<int32>(def));
break;
case CIT_UINT:
if(size == 1) *(uint8 *)addr = (uint8) conf.GetUInt(name, reinterpret_cast<uint32>(def));
if(size == 2) *(uint16*)addr = (uint16)conf.GetUInt(name, reinterpret_cast<uint32>(def));
if(size == 4) *(uint32*)addr = (uint32)conf.GetUInt(name, reinterpret_cast<uint32>(def));
if(size == 8) *(uint64*)addr = (uint64)conf.GetUInt(name, reinterpret_cast<uint32>(def));
break;
case CIT_STRING:
lstrcpyn((TCHAR*)addr, _tFromChar(conf.GetString(name, reinterpret_cast<const char*>(def))), size-1);
((TCHAR*)addr)[size-1] = TEXT('\0');
break;
case CIT_INVBOOL:
case CIT_INVBOOLONOFF:
if(size == 1) *(uint8 *)addr = (uint8) !conf.GetBool(name, def!=0);
if(size == 2) *(uint16*)addr = (uint16)!conf.GetBool(name, def!=0);
if(size == 4) *(uint32*)addr = (uint32)!conf.GetBool(name, def!=0);
if(size == 8) *(uint64*)addr = (uint64)!conf.GetBool(name, def!=0);
break;
case CIT_VKEY:
{
uint16 keyNum = (uint16)conf.GetUInt(name, reinterpret_cast<uint32>(def));
const char* keyStr = conf.GetString(name);
if(keyStr)
{
for(int i=0;i<512;i++)
{
if(i<256) // keys
{
if(!strcasecmp(keyStr,keyToString[i]) ||
(*keyToAlternateString[i] && !strcasecmp(keyStr,keyToAlternateString[i])))
{
keyNum = i;
break;
}
}
else // joystick:
{
char temp [128];
extern void TranslateKey(WORD keyz,char *out);
TranslateKey(0x8000|(i-256),temp);
if(strlen(keyStr)>3 && !strcasecmp(keyStr+3,temp+3))
{
for(int j = 0 ; j < 16 ; j++)
{
if(keyStr[2]-'0' == j || keyStr[2]-'a' == j-10)
{
keyNum = 0x8000|(i-256)|(j<<8);
i = 512;
break;
}
}
}
}
}
}
if(size == 1) *(uint8 *)addr = (uint8) keyNum;
if(size == 2) *(uint16*)addr = (uint16)keyNum;
if(size == 4) *(uint32*)addr = (uint32)keyNum;
if(size == 8) *(uint64*)addr = (uint64)keyNum;
}
break;
case CIT_VKEYMOD:
{
uint16 modNum = 0;
const char* modStr = conf.GetString(name);
if(modStr) {
if(strstr(modStr, "ft") || strstr(modStr, "FT")) modNum |= CUSTKEY_SHIFT_MASK;
if(strstr(modStr, "tr") || strstr(modStr, "TR")) modNum |= CUSTKEY_CTRL_MASK;
if(strstr(modStr, "lt") || strstr(modStr, "LT")) modNum |= CUSTKEY_ALT_MASK;
}
if(!modNum && (!modStr || strcasecmp(modStr, "none")))
modNum = conf.GetUInt(name, reinterpret_cast<uint32>(def));
if(size == 1) *(uint8 *)addr = (uint8) modNum;
if(size == 2) *(uint16*)addr = (uint16)modNum;
if(size == 4) *(uint32*)addr = (uint32)modNum;
if(size == 8) *(uint64*)addr = (uint64)modNum;
}
break;
}
// if it had a comment, override our own with it
const char* newComment = conf.GetComment(name);
if(newComment && *newComment)
comment = newComment;
}
void Set(ConfigFile& conf) {
switch(type)
{
case CIT_BOOL:
if(size == 1) conf.SetBool(name, 0!=(*(uint8 *)addr), "TRUE","FALSE", comment);
if(size == 2) conf.SetBool(name, 0!=(*(uint16*)addr), "TRUE","FALSE", comment);
if(size == 4) conf.SetBool(name, 0!=(*(uint32*)addr), "TRUE","FALSE", comment);
if(size == 8) conf.SetBool(name, 0!=(*(uint64*)addr), "TRUE","FALSE", comment);
break;
case CIT_BOOLONOFF:
if(size == 1) conf.SetBool(name, 0!=(*(uint8 *)addr), "ON","OFF", comment);
if(size == 2) conf.SetBool(name, 0!=(*(uint16*)addr), "ON","OFF", comment);
if(size == 4) conf.SetBool(name, 0!=(*(uint32*)addr), "ON","OFF", comment);
if(size == 8) conf.SetBool(name, 0!=(*(uint64*)addr), "ON","OFF", comment);
break;
case CIT_INT:
if(size == 1) conf.SetInt(name, (int32)(*(uint8 *)addr), comment);
if(size == 2) conf.SetInt(name, (int32)(*(uint16*)addr), comment);
if(size == 4) conf.SetInt(name, (int32)(*(uint32*)addr), comment);
if(size == 8) conf.SetInt(name, (int32)(*(uint64*)addr), comment);
break;
case CIT_UINT:
if(size == 1) conf.SetUInt(name, (uint32)(*(uint8 *)addr), 10, comment);
if(size == 2) conf.SetUInt(name, (uint32)(*(uint16*)addr), 10, comment);
if(size == 4) conf.SetUInt(name, (uint32)(*(uint32*)addr), 10, comment);
if(size == 8) conf.SetUInt(name, (uint32)(*(uint64*)addr), 10, comment);
break;
case CIT_STRING:
if((TCHAR*)addr)
conf.SetString(name, std::string(_tToChar((TCHAR*)addr)), comment);
break;
case CIT_INVBOOL:
if(size == 1) conf.SetBool(name, 0==(*(uint8 *)addr), "TRUE","FALSE", comment);
if(size == 2) conf.SetBool(name, 0==(*(uint16*)addr), "TRUE","FALSE", comment);
if(size == 4) conf.SetBool(name, 0==(*(uint32*)addr), "TRUE","FALSE", comment);
if(size == 8) conf.SetBool(name, 0==(*(uint64*)addr), "TRUE","FALSE", comment);
break;
case CIT_INVBOOLONOFF:
if(size == 1) conf.SetBool(name, 0==(*(uint8 *)addr), "ON","OFF", comment);
if(size == 2) conf.SetBool(name, 0==(*(uint16*)addr), "ON","OFF", comment);
if(size == 4) conf.SetBool(name, 0==(*(uint32*)addr), "ON","OFF", comment);
if(size == 8) conf.SetBool(name, 0==(*(uint64*)addr), "ON","OFF", comment);
break;
case CIT_VKEY:
{
uint16 keyNum = 0;
if(size == 1) keyNum = (uint8)(*(uint8 *)addr);
if(size == 2) keyNum = (uint16)(*(uint16*)addr);
if(size == 4) keyNum = (uint16)(*(uint32*)addr);
if(size == 8) keyNum = (uint16)(*(uint64*)addr);
if(keyNum < 256) conf.SetString(name, keyToString[keyNum], comment);
else if(keyNum & 0x8000) {
char temp [128];
extern void TranslateKey(WORD keyz,char *out);
TranslateKey(keyNum,temp);
conf.SetString(name, temp, comment);
}
else conf.SetUInt(name, keyNum, 16, comment);
}
break;
case CIT_VKEYMOD:
{
uint16 modNum = 0;
if(size == 1) modNum = (uint8)(*(uint8 *)addr);
if(size == 2) modNum = (uint16)(*(uint16*)addr);
if(size == 4) modNum = (uint16)(*(uint32*)addr);
if(size == 8) modNum = (uint16)(*(uint64*)addr);
std::string modStr;
if(modNum & CUSTKEY_CTRL_MASK) modStr += "Ctrl ";
if(modNum & CUSTKEY_ALT_MASK) modStr += "Alt ";
if(modNum & CUSTKEY_SHIFT_MASK) modStr += "Shift ";
if(!(modNum & (CUSTKEY_CTRL_MASK|CUSTKEY_ALT_MASK|CUSTKEY_SHIFT_MASK))) modStr = "none";
else modStr.erase(modStr.length()-1);
conf.SetString(name, modStr, comment);
}
break;
}
}
};
std::vector<ConfigItem> configItems;
// var must be a persistent variable. In the case of strings, it must point to a writeable character array.
#define AddItemC(name, var, def, comment, type) configItems.push_back(ConfigItem((const char*)(CATEGORY "::" name), (void*)(&var), sizeof(var), (void*)(pint)def, (const char*)comment, (ConfigItemType)type))
#define AddItem(name, var, def, type) AddItemC(name,var,def,"",type)
#define AddUInt(name, var, def) AddItem(name,var,def,CIT_UINT)
#define AddInt(name, var, def) AddItem(name,var,def,CIT_INT)
#define AddBool(name, var, def) AddItem(name,var,def,CIT_BOOL)
#define AddBool2(name, var, def) AddItem(name,var,def,CIT_BOOLONOFF)
#define AddInvBool(name, var, def) AddItem(name,var,def,CIT_INVBOOL)
#define AddInvBool2(name, var, def) AddItem(name,var,def,CIT_INVBOOLONOFF)
#define AddVKey(name, var, def) AddItem(name,var,def,CIT_VKEY)
#define AddVKMod(name, var, def) AddItem(name,var,def,CIT_VKEYMOD)
#define AddUIntC(name, var, def, comment) AddItemC(name,var,def,comment,CIT_UINT)
#define AddIntC(name, var, def, comment) AddItemC(name,var,def,comment,CIT_INT)
#define AddBoolC(name, var, def, comment) AddItemC(name,var,def,comment,CIT_BOOL)
#define AddBool2C(name, var, def, comment) AddItemC(name,var,def,comment,CIT_BOOLONOFF)
#define AddInvBoolC(name, var, def, comment) AddItemC(name,var,def,comment,CIT_INVBOOL)
#define AddInvBool2C(name, var, def, comment) AddItemC(name,var,def,comment,CIT_INVBOOLONOFF)
#define AddStringC(name, var, buflen, def, comment) configItems.push_back(ConfigItem((const char*)(CATEGORY "::" name), (void*)var, buflen, (void*)(pint)def, (const char*)comment, CIT_STRING))
#define AddString(name, var, buflen, def) AddStringC(name, var, buflen, def, "")
static char filterString [1024], filterString2 [1024], snapVerString [256];
static bool niceAlignment, showComments, readOnlyConfig;
static int configSort;
void WinPreSave(ConfigFile& conf)
{
strcpy(filterString, "output filter: ");
for(int i=0;i<NUM_FILTERS;i++)
{
static char temp [256];
sprintf(temp, "%d=%s%c ", i, GetFilterName((RenderFilter)i), i!=NUM_FILTERS-1?',':' ');
strcat(filterString, temp);
}
strcpy(filterString2, "hi-res output filter: ");
for(int i=0;i<NUM_FILTERS;i++)
{
if(GetFilterHiResSupport((RenderFilter)i))
{
static char temp [256];
sprintf(temp, "%d=%s%c ", i, GetFilterName((RenderFilter)i), i!=NUM_FILTERS-1?',':' ');
strcat(filterString2, temp);
}
}
sprintf(snapVerString, "Snapshot save version. Must be between 1 and %d (inclusive)", SNAPSHOT_VERSION);
// GetWindowRect (GUI.hWnd, &GUI.window_size);
GUI.window_size.right -= GUI.window_size.left;
GUI.window_size.bottom -= GUI.window_size.top;
int extra_width = 2*(GetSystemMetrics(SM_CXBORDER) +
GetSystemMetrics(SM_CXDLGFRAME));
GUI.window_size.right -= extra_width;
int extra_height = 2*(GetSystemMetrics(SM_CYBORDER) +
GetSystemMetrics(SM_CYDLGFRAME)) +
GetSystemMetrics(SM_CYCAPTION) +
GetSystemMetrics(SM_CYMENU) +
(GUI.HideMenu ? 0 : (
(GUI.window_size.right <= 392 ? GetSystemMetrics(SM_CYMENU) : 0) + // HACK: accounts for menu wrapping (when width is small)
(GUI.window_size.right <= 208 ? GetSystemMetrics(SM_CYMENU) : 0) +
(GUI.window_size.right <= 148 ? GetSystemMetrics(SM_CYMENU) : 0)));
GUI.window_size.bottom -= extra_height;
if(GUI.window_size.bottom < 10) GUI.window_size.bottom = 10;
if(GUI.window_size.right < 10) GUI.window_size.right = 10;
GUI.customRomDlgSettings.window_size.right -= GUI.customRomDlgSettings.window_size.left;
GUI.customRomDlgSettings.window_size.bottom -= GUI.customRomDlgSettings.window_size.top;
conf.DeleteKey("Sound::Mono");
if(configSort == 2)
conf.ClearLines();
}
void WinPostSave(ConfigFile& conf)
{
int extra_width = 2*(GetSystemMetrics(SM_CXBORDER) +
GetSystemMetrics(SM_CXDLGFRAME));
int extra_height = 2*(GetSystemMetrics(SM_CYBORDER) +
GetSystemMetrics(SM_CYDLGFRAME)) +
GetSystemMetrics(SM_CYCAPTION) +
(GUI.HideMenu ? 0 : (GetSystemMetrics(SM_CYMENU) +
(GUI.window_size.right <= 392 ? GetSystemMetrics(SM_CYMENU) : 0) + // HACK: accounts for menu wrapping (when width is small)
(GUI.window_size.right <= 208 ? GetSystemMetrics(SM_CYMENU) : 0) +
(GUI.window_size.right <= 148 ? GetSystemMetrics(SM_CYMENU) : 0)));
GUI.window_size.right += GUI.window_size.left;
GUI.window_size.bottom += GUI.window_size.top;
GUI.window_size.right += extra_width;
GUI.window_size.bottom += extra_height;
GUI.customRomDlgSettings.window_size.right += GUI.customRomDlgSettings.window_size.left;
GUI.customRomDlgSettings.window_size.bottom += GUI.customRomDlgSettings.window_size.top;
}
void WinPostLoad(ConfigFile& conf)
{
int i;
if(Settings.DisplayPressedKeys) Settings.DisplayPressedKeys = 2;
for(i=0;i<8;i++) Joypad[i+8].Enabled = Joypad[i].Enabled;
if(GUI.MaxRecentGames < 1) GUI.MaxRecentGames = 1;
if(GUI.MaxRecentGames > MAX_RECENT_GAMES_LIST_SIZE) GUI.MaxRecentGames = MAX_RECENT_GAMES_LIST_SIZE;
if(GUI.rewindGranularity==0) GUI.rewindGranularity = 1;
bool gap = false;
for(i=0;i<MAX_RECENT_GAMES_LIST_SIZE;i++) // remove gaps in recent games list
{
if(!*GUI.RecentGames[i])
gap = true;
else if(gap)
{
memmove(GUI.RecentGames[i-1], GUI.RecentGames[i], MAX_PATH * sizeof(TCHAR));
*GUI.RecentGames[i] = TEXT('\0');
gap = false;
i = -1;
}
}
if(conf.Exists("Sound::Mono")) Settings.Stereo = !conf.GetBool("Sound::Mono"); // special case
ConfigFile::SetNiceAlignment(niceAlignment);
ConfigFile::SetShowComments(showComments);
ConfigFile::SetAlphaSort(configSort==2);
ConfigFile::SetTimeSort(configSort==1);
WinPostSave(conf);
}
void WinPreLoad(ConfigFile& conf)
{
if(conf.Exists("Config::Sort"))
{
if(conf.GetUInt("Config::Sort") == 1)
{
configSort = 1;
ConfigFile::SetAlphaSort(configSort==2);
ConfigFile::SetTimeSort(configSort==1);
conf.ClearLines();
}
}
else
{
conf.DeleteKey("Config::Sort");
}
}
// and now for the important part,
// which determines what goes into and comes out of the config file:
// add all of the things we want to save and load to a list
// (but don't actually save or load anything yet)
void WinRegisterConfigItems()
{
#define CATEGORY "Config"
AddBool2C("NiceAlignment", niceAlignment, true, "on to line up the =, :, and # in each section of this config file");
AddBool2C("Comments", showComments, true, "on to keep comments such as this in this config file. To update/refresh all comments, set this to false and run Snes9x, then set it to true and run Snes9x again.");
AddUIntC("Sort", configSort, 1, "ordering within sections: 0=allow reordering, 1=force default order, 2=sort alphabetically");
AddBoolC("Lock", readOnlyConfig, false, "if true, prevents Snes9x from editing this configuration file (or making it read-only while it is running)");
#undef CATEGORY
#define CATEGORY "Display"
AddBool2C("HiRes", Settings.SupportHiRes, true, "on to support the hi-res mode that a few games use, off to render them in low-res");
AddBool2("Transparency", Settings.Transparency, true);
AddBoolC("MessagesInImage", Settings.AutoDisplayMessages, false, "true to draw text inside the SNES image (will get into AVIs, screenshots, and filters)");
AddBool2C("FrameRate", Settings.DisplayFrameRate, false, "on to display the framerate (will be inaccurate if AutoMaxSkipFrames is too small)");
AddBoolC("DisplayInput", Settings.DisplayPressedKeys, false, "true to show which buttons are pressed");
AddBoolC("DisplayFrameCount", Settings.DisplayMovieFrame, true, "true to show the frame count when a movie is playing");
#undef CATEGORY
#define CATEGORY "Display\\Win"
AddUIntC("OutputMethod", GUI.outputMethod, 1, "0=DirectDraw, 1=Direct3D, 2=OpenGL");
AddUIntC("FilterType", GUI.Scale, 0, filterString);
AddUIntC("FilterHiRes", GUI.ScaleHiRes, 0, filterString2);
AddBoolC("BlendHiRes", GUI.BlendHiRes, true, "true to horizontally blend Hi-Res images (better transparency effect on filters that do not account for this)");
AddBoolC("NTSCScanlines", GUI.NTSCScanlines, true, "true to use scanlines with Blargg's NTSC filters");
AddBoolC("ShaderEnabled", GUI.shaderEnabled, false, "true to use pixel shader (if supported by output method)");
AddStringC("Direct3D:D3DShader", GUI.D3DshaderFileName, MAX_PATH, "", "shader filename for Direct3D mode (HLSL effect file or CG shader");
AddStringC("OpenGL:OGLShader", GUI.OGLshaderFileName, MAX_PATH, "", "shader filename for OpenGL mode (bsnes-style XML shader or CG shader)");
AddBoolC("OpenGL:DisablePBOs", GUI.OGLdisablePBOs, false, "do not use PBOs in OpenGL mode, even if the video card supports them");
AddBoolC("ExtendHeight", GUI.HeightExtend, false, "true to display an extra 15 pixels at the bottom, which few games use. Also increases AVI output size from 256x224 to 256x240.");
AddBoolC("AlwaysCenterImage", GUI.AlwaysCenterImage,false, "true to center the image even if larger than window");
AddIntC("Window:Width", GUI.window_size.right, 512, "256=1x, 512=2x, 768=3x, 1024=4x, etc. (usually)");
AddIntC("Window:Height", GUI.window_size.bottom, 448, "224=1x, 448=2x, 672=3x, 896=4x, etc. (usually)");
AddIntC("Window:Left", GUI.window_size.left, 0, "in pixels from left edge of screen");
AddIntC("Window:Top", GUI.window_size.top, 0, "in pixels from top edge of screen");
AddBool("Window:Maximized", GUI.window_maximized, false);
AddIntC("CustomRomDialog:Width", GUI.customRomDlgSettings.window_size.right, 660, "");
AddIntC("CustomRomDialog:Height", GUI.customRomDlgSettings.window_size.bottom, 400, "");
AddIntC("CustomRomDialog:Left", GUI.customRomDlgSettings.window_size.left, 50, "in pixels from left edge of screen");
AddIntC("CustomRomDialog:Top", GUI.customRomDlgSettings.window_size.top, 50, "in pixels from top edge of screen");
AddBool("CustomRomDialog:Maximized", GUI.customRomDlgSettings.window_maximized, false);
AddIntC("CustomRomDialog:FolderPaneWidth", GUI.customRomDlgSettings.folderPaneWidth, 230, "");
AddIntC("CustomRomDialog:DescColumnWidth", GUI.customRomDlgSettings.columnDescription, 112, "");
AddIntC("CustomRomDialog:FilenameColumnWidth", GUI.customRomDlgSettings.columnFilename, 196, "");
AddIntC("CustomRomDialog:SizeColumnWidth", GUI.customRomDlgSettings.columnSize, 67, "");
AddBoolC("Stretch:Enabled", GUI.Stretch, true, "true to stretch the game image to fill the window or screen");
AddBoolC("Stretch:MaintainAspectRatio", GUI.AspectRatio, true, "prevents stretching from changing the aspect ratio");
AddBoolC("Stretch:IntegerScaling", GUI.IntegerScaling, false, "scales image height to exact integer multiples");
AddUIntC("Stretch:AspectRatioBaseWidth", GUI.AspectWidth, 256, "base width for aspect ratio calculation (AR=AspectRatioBaseWidth/224), default is 256 - set to 299 for 4:3 aspect ratio");
AddBoolC("Stretch:BilinearFilter", Settings.BilinearFilter, true, "allows bilinear filtering of stretching. Depending on your video card and the window size, this may result in a lower framerate.");
AddBoolC("Stretch:LocalVidMem", GUI.LocalVidMem, true, "determines the location of video memory in DirectDraw mode. May increase or decrease rendering performance, depending on your setup and which filter and stretching options are active.");
AddBool("Fullscreen:Enabled", GUI.FullScreen, false);
AddUInt("Fullscreen:Width", GUI.FullscreenMode.width, 640);
AddUInt("Fullscreen:Height", GUI.FullscreenMode.height, 480);
AddUInt("Fullscreen:Depth", GUI.FullscreenMode.depth, 16);
AddUInt("Fullscreen:RefreshRate", GUI.FullscreenMode.rate, 60);
AddBool("Fullscreen:DoubleBuffered", GUI.DoubleBuffered, false);
AddBoolC("Fullscreen:EmulateFullscreen", GUI.EmulateFullscreen, true,"true makes snes9x create a window that spans the entire screen when going fullscreen");
AddBoolC("HideMenu", GUI.HideMenu, false, "true to auto-hide the menu bar on startup.");
AddBoolC("Vsync", GUI.Vsync, false, "true to enable Vsync");
AddBoolC("ReduceInputLag", GUI.ReduceInputLag, false, "true to reduce input lag by hard synchronization");
AddBoolC("FilterMessageFont", GUI.filterMessagFont, true, "true to filter message font with EPX on 2x/3x scales if MessagesInImage is false)");
#undef CATEGORY
#define CATEGORY "Settings"
AddUIntC("FrameSkip", Settings.SkipFrames, AUTO_FRAMERATE, "200=automatic (limits at 50/60 fps), 0=none, 1=skip every other, ...");
AddUIntC("AutoMaxSkipFramesAtOnce", Settings.AutoMaxSkipFrames, 0, "most frames to skip at once to maintain speed in automatic mode, don't set to more than 1 or 2 frames because the skipping algorithm isn't very smart");
AddUIntC("TurboFrameSkip", Settings.TurboSkipFrames, 15, "how many frames to skip when in fast-forward mode");
AddUInt("AutoSaveDelay", Settings.AutoSaveDelay, 30);
AddBool("BlockInvalidVRAMAccess", Settings.BlockInvalidVRAMAccessMaster, true);
AddBool2C("SnapshotScreenshots", Settings.SnapshotScreenshots, true, "on to save the screenshot in each snapshot, for loading-when-paused display");
AddBoolC("MovieTruncateAtEnd", Settings.MovieTruncate, true, "true to truncate any leftover data in the movie file after the current frame when recording stops");
AddBoolC("MovieNotifyIgnored", Settings.MovieNotifyIgnored, false, "true to display \"(ignored)\" in the frame counter when recording when the last frame of input was not used by the SNES (such as lag or loading frames)");
AddBool("DisplayWatchedAddresses", Settings.DisplayWatchedAddresses, true);
AddBool2C("WrongMovieStateProtection", Settings.WrongMovieStateProtection, true, "off to allow states to be loaded for recording from a different movie than they were made in");
AddUIntC("MessageDisplayTime", Settings.InitialInfoStringTimeout, 120, "display length of messages, in frames. set to 0 to disable all message text");
#undef CATEGORY
#define CATEGORY "Settings\\Win"
AddUIntC("RewindBufferSize", GUI.rewindBufferSize, 0, "rewind buffer size in MB - 0 disables rewind support");
AddUIntC("RewindGranularity", GUI.rewindGranularity, 1, "rewind granularity - rewind takes a snapshot each x frames");
AddBoolC("PauseWhenInactive", GUI.InactivePause, TRUE, "true to pause Snes9x when it is not the active window");
AddBoolC("CustomRomOpenDialog", GUI.CustomRomOpen, false, "false to use standard Windows open dialog for the ROM open dialog");
AddBoolC("AVIHiRes", GUI.AVIHiRes, false, "true to record AVI in Hi-Res scale");
// AddUIntC("Language", GUI.Language, 0, "0=English, 1=Nederlands"); // NYI
AddBoolC("FrameAdvanceSkipsNonInput", GUI.FASkipsNonInput, false, "causes frame advance to fast-forward past frames where the game is definitely not checking input, such as during lag or loading time. EXPERIMENTAL");
AddBool("MovieDefaultClearSRAM", GUI.MovieClearSRAM, false);
AddBool("MovieDefaultStartFromReset", GUI.MovieStartFromReset, false);
AddBool("MovieDefaultReadOnly", GUI.MovieReadOnly, true);
AddUInt("CurrentSaveSlot", GUI.CurrentSaveSlot, 0);
AddUIntC("MaxRecentGames", GUI.MaxRecentGames, 14, "max recent games to show in the recent games menu (must be <= 32)");
#undef CATEGORY
#define CATEGORY "Settings\\Win\\Files"
AddStringC("Dir:Roms", GUI.RomDir, _MAX_PATH, ".\\Roms", "directory where the Open ROM dialog will start");
AddStringC("Dir:Screenshots", GUI.ScreensDir, _MAX_PATH, ".\\Screenshots", "directory where screenshots will be saved");
AddStringC("Dir:Movies", GUI.MovieDir, _MAX_PATH, ".\\Movies", "the default directory for recorded movie (.smv) files");
AddStringC("Dir:SPCs", GUI.SPCDir, _MAX_PATH, ".\\SPCs", "directory where SPCs will be saved");
AddStringC("Dir:Savestates", GUI.FreezeFileDir, _MAX_PATH, ".\\Saves", "directory where savestates will be created and loaded from");
AddStringC("Dir:SRAM", GUI.SRAMFileDir, _MAX_PATH, ".\\Saves", "directory where battery saves will be created and loaded from");
AddStringC("Dir:Cheats", GUI.CheatDir, _MAX_PATH, ".\\Cheats", "directory in which cheats (.cht files) will be looked for");
AddStringC("Dir:Patches", GUI.PatchDir, _MAX_PATH, ".\\Patches", "directory in which ROM patches (.ips/.bps/.ups files) will be looked for");
AddStringC("Dir:Bios", GUI.BiosDir, _MAX_PATH, ".\\BIOS", "directory where BIOS files (such as \"BS-X.bios\") will be located");
AddStringC("Dir:SatData", GUI.SatDir, _MAX_PATH, ".\\SatData", "directory where Satellaview Signal Data files will be located");
AddBoolC("Dir:Lock", GUI.LockDirectories, false, "true to prevent Snes9x from changing configured directories when you browse to a new location");
#define ADD(n) AddString("Rom:RecentGame" #n, GUI.RecentGames[n-1], MAX_PATH, "")
ADD(1); ADD(2); ADD(3); ADD(4); ADD(5); ADD(6); ADD(7); ADD(8);
ADD(9); ADD(10); ADD(11); ADD(12); ADD(13); ADD(14); ADD(15); ADD(16);
ADD(17); ADD(18); ADD(19); ADD(20); ADD(21); ADD(22); ADD(23); ADD(24);
ADD(25); ADD(26); ADD(27); ADD(28); ADD(29); ADD(30); ADD(31); ADD(32);
assert(MAX_RECENT_GAMES_LIST_SIZE == 32);
#undef ADD
AddString("Rom:MultiCartA", multiRomA, _MAX_PATH, "");
AddString("Rom:MultiCartB", multiRomB, _MAX_PATH, "");
#undef CATEGORY
#define CATEGORY "Sound"
AddIntC("Sync", Settings.SoundSync, 1, "1 to sync emulation to sound output, 0 to disable.");
AddBool2("Stereo", Settings.Stereo, true);