ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SIDPlayer/src/prefs.cpp
(Generate patch)

Comparing SIDPlayer/src/prefs.cpp (file contents):
Revision 1.1 by cebix, 2000-07-28T12:42:30Z vs.
Revision 1.2 by cebix, 2001-01-04T19:54:13Z

# Line 28 | Line 28
28   #include "prefs.h"
29  
30  
31 < // List of preferences items
32 < prefs_desc prefs_items[] = {
33 <        {"victype", TYPE_STRING, false},                // Type number of VIC-II to emulate ("6569", "6567" or "6567R5")
34 <        {"sidtype", TYPE_STRING, false},                // Type number of SID to emulate ("6581" or "8580")
35 <        {"samplerate", TYPE_INT32, false},              // Audio sample rate in Hz
36 <        {"audio16bit", TYPE_BOOLEAN, false},    // 16-bit audio output?
37 <        {"stereo", TYPE_BOOLEAN, false},                // Stereo audio output?
38 <        {"filters", TYPE_BOOLEAN, false},               // Emulate SID filters?
39 <        {"dualsid", TYPE_BOOLEAN, false},               // Emulate 2 SID chips?
40 <        {"audioeffect", TYPE_INT32, false},             // Audio effect type (0 = none, 1 = reverb, 2 = spatial)
41 <        {"revdelay", TYPE_INT32, false},                // Reverb delay in ms
42 <        {"revfeedback", TYPE_INT32, false},             // Reverb feedback (0..0x100 = 0..100%)
43 <        {"volume", TYPE_INT32, false},                  // Master volume (0..0x100 = 0..100%)
44 <        {"v1volume", TYPE_INT32, false},                // Volume voice 1 (0..0x100 = 0..100%)
45 <        {"v2volume", TYPE_INT32, false},                // Volume voice 2 (0..0x100 = 0..100%)
46 <        {"v3volume", TYPE_INT32, false},                // Volume voice 3 (0..0x100 = 0..100%)
47 <        {"v4volume", TYPE_INT32, false},                // Volume sampled voice (0..0x100 = 0..100%)
48 <        {"v1pan", TYPE_INT32, false},                   // Panning voice 1 (-0x100..0x100 = left..right)
49 <        {"v2pan", TYPE_INT32, false},                   // Panning voice 2 (-0x100..0x100 = left..right)
50 <        {"v3pan", TYPE_INT32, false},                   // Panning voice 3 (-0x100..0x100 = left..right)
51 <        {"v4pan", TYPE_INT32, false},                   // Panning sampled voice (-0x100..0x100 = left..right)
52 <        {"dualsep", TYPE_INT32, false},                 // Dual-SID stereo separation (0..0x100 = 0..100%)
53 <        {"replayfreq", TYPE_INT32, false},              // Frequency at which 6510 replay routine is called in Hz
54 <        {NULL, TYPE_END, false} // End of list
55 < };
56 <
57 <
58 < // Prefs item are stored in a linked list of these nodes
31 > // Prefs items are stored in a linked list of these nodes
32   struct prefs_node {
33          prefs_node *next;
34          const char *name;
# Line 65 | Line 38 | struct prefs_node {
38   };
39  
40   // List of prefs nodes
41 < static prefs_node *the_prefs;
41 > static prefs_node *the_prefs = NULL;
42 >
43 > // Prototypes
44 > static prefs_desc *find_prefs_desc(const char *name);
45  
46  
47   /*
# Line 74 | Line 50 | static prefs_node *the_prefs;
50  
51   void PrefsInit(int argc, char **argv)
52   {
77        // Start with empty list
78        the_prefs = NULL;
79
53          // Set defaults
54 <        PrefsAddString("victype", "6569");
55 <        PrefsAddString("sidtype", "6581");
56 <        PrefsAddInt32("samplerate", 44100);
57 <        PrefsAddBool("audio16bit", true);
58 <        PrefsAddBool("stereo", true);
59 <        PrefsAddBool("filters", true);
60 <        PrefsAddBool("dualsid", false);
61 <        PrefsAddInt32("audioeffect", 2);
62 <        PrefsAddInt32("revdelay", 125);
63 <        PrefsAddInt32("revfeedback", 0x50);
64 <        PrefsAddInt32("volume", 0x100);
65 <        PrefsAddInt32("v1volume", 0x100);
66 <        PrefsAddInt32("v1pan", -0x40);
67 <        PrefsAddInt32("v2volume", 0x100);
68 <        PrefsAddInt32("v2pan", 0);
69 <        PrefsAddInt32("v3volume", 0x100);
70 <        PrefsAddInt32("v3pan", 0x40);
71 <        PrefsAddInt32("v4volume", 0x100);
72 <        PrefsAddInt32("v4pan", 0);
73 <        PrefsAddInt32("dualsep", 0x80);
74 <        PrefsAddInt32("replayfreq", 50);
54 >        AddPrefsDefaults();
55 >
56 >        // Override prefs with command line arguments
57 >        argc--; argv++;
58 >        for (; argc>0; argc--, argv++) {
59 >
60 >                // Arguments are of the form '--keyword'
61 >                if (strlen(*argv) < 3 || argv[0][0] != '-' || argv[0][1] != '-')
62 >                        continue;
63 >                const char *keyword = *argv + 2;
64 >                const prefs_desc *d = find_prefs_desc(keyword);
65 >                if (d == NULL) {
66 >                        printf("WARNING: Unrecognized argument '%s'\n", *argv);
67 >                        continue;
68 >                }
69 >
70 >                // Add/replace prefs item
71 >                switch (d->type) {
72 >                        case TYPE_STRING:
73 >                                if (argc < 2) {
74 >                                        printf("WARNING: Argument '%s' must be followed by value\n", *argv);
75 >                                        break;
76 >                                }
77 >                                argc--; argv++;
78 >                                if (d->multiple)
79 >                                        PrefsAddString(keyword, *argv);
80 >                                else
81 >                                        PrefsReplaceString(keyword, *argv);
82 >                                break;
83 >
84 >                        case TYPE_BOOLEAN:
85 >                                if (argc > 1 && argv[1][0] != '-') {
86 >                                        argc--; argv++;
87 >                                        PrefsReplaceBool(keyword, !strcmp(*argv, "true") || !strcmp(*argv, "on"));
88 >                                } else
89 >                                        PrefsReplaceBool(keyword, true);
90 >                                break;
91 >
92 >                        case TYPE_INT32:
93 >                                if (argc < 2) {
94 >                                        printf("WARNING: Argument '%s' must be followed by value\n", *argv);
95 >                                        break;
96 >                                }
97 >                                argc--; argv++;
98 >                                PrefsReplaceInt32(keyword, atoi(*argv));
99 >                                break;
100 >
101 >                        default:
102 >                                break;
103 >                }
104 >        }
105   }
106  
107  
# Line 134 | Line 137 | static prefs_desc *find_prefs_desc(const
137          return NULL;
138   }
139  
140 + static prefs_desc *find_prefs_desc(const char *name)
141 + {
142 +        return find_prefs_desc(name, common_prefs_items);
143 + }
144 +
145  
146   /*
147   *  Set prefs items
# Line 150 | Line 158 | static void add_data(const char *name, p
158          p->name = strdup(name);
159          p->type = type;
160          p->data = d;
161 <        p->desc = find_prefs_desc(p->name, prefs_items);
161 >        p->desc = find_prefs_desc(p->name);
162          if (the_prefs) {
163                  prefs_node *prev = the_prefs;
164                  while (prev->next)
# Line 297 | Line 305 | void PrefsRemoveItem(const char *name, i
305  
306   static void set_callback(const char *name, prefs_func f)
307   {
308 <        prefs_desc *d = find_prefs_desc(name, prefs_items);
308 >        prefs_desc *d = find_prefs_desc(name);
309          if (d == NULL)
310                  return;
311          d->func = f;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines