1 /***************************************************************************
2     XML Configuration File Handling.
3 
4     Load Settings.
5     Load & Save Hi-Scores.
6 
7     Copyright Chris White.
8     See license.txt for more details.
9 ***************************************************************************/
10 
11 #pragma once
12 
13 #include <set>
14 #include <string>
15 #include <vector>
16 #include "stdint.hpp"
17 
18 struct data_settings_t
19 {
20     std::string rom_path;
21     std::string res_path;
22     std::string save_path;
23     std::string cfg_file;
24     int crc32;
25 
26     std::string file_scores;            // Arcade Hi-Scores (World & Japanese)
27     std::string file_scores_jap;
28     std::string file_ttrial;            // Time Trial Hi-Scores
29     std::string file_ttrial_jap;
30     std::string file_cont;              // Continous Mode Hi-Scores
31     std::string file_cont_jap;
32 };
33 
34 struct music_t
35 {
36     // Audio Format
37     const static int IS_YM_INT = 0; // Intenal YM Track (from OutRun ROMs)
38     const static int IS_YM_EXT = 1; // External YM Track (from Binary)
39     const static int IS_WAV = 2;    // External WAV Track
40     int type;
41 
42     int cmd;                        // Z80 Command
43     std::string title;
44     std::string filename;
45 };
46 
47 struct ttrial_settings_t
48 {
49     int laps;
50     int traffic;
51     uint16_t best_times[15];
52 };
53 
54 struct menu_settings_t
55 {
56     int enabled;
57     int road_scroll_speed;
58 };
59 
60 struct video_settings_t
61 {
62     const static int MODE_WINDOW  = 0;
63     const static int MODE_FULL    = 1;
64     const static int MODE_STRETCH = 2;
65 
66     int mode;
67     int scale;
68     int scanlines;
69     int widescreen;
70     int fps;
71     int fps_count;
72     int hires;
73     int filtering;
74     int vsync;
75     int shadow;
76 };
77 
78 struct sound_settings_t
79 {
80     int enabled;
81     int rate;
82     int advertise;
83     int preview;
84     int fix_samples;
85     int music_timer;
86     std::vector <music_t> music;
87 };
88 
89 struct controls_settings_t
90 {
91     const static int GEAR_BUTTON   = 0;
92     const static int GEAR_PRESS    = 1; // For cabinets
93     const static int GEAR_SEPARATE = 2; // Separate button presses
94     const static int GEAR_AUTO     = 3;
95 
96     int gear;
97     int steer_speed;   // Steering Digital Speed
98     int pedal_speed;   // Pedal Digital Speed
99     int padconfig[12];  // Joypad Button Config
100     int keyconfig[12]; // Keyboard Button Config
101     int pad_id;        // Use the N'th joystick on the system.
102     int analog;        // Use analog controls
103     int axis[3];       // Analog Axis
104     int asettings[2];  // Analog Settings
105     bool invert[3];    // Invert Analog Axis
106 
107     float rumble;      // Simple Controller Rumble Support
108     int haptic;        // Force Feedback Enabled
109     int max_force;
110     int min_force;
111     int force_duration;
112 };
113 
114 struct smartypi_settings_t
115 {
116     int enabled;      // CannonBall used in conjunction with SMARTYPI in arcade cabinet
117     int ouputs;       // Write Digital Outputs to console
118     int cabinet;      // Cabinet Type
119 };
120 
121 struct engine_settings_t
122 {
123     int dip_time;
124     int dip_traffic;
125     bool freeplay;
126     bool freeze_timer;
127     bool disable_traffic;
128     int jap;
129     int prototype;
130     int randomgen;
131     int level_objects;
132     bool fix_bugs;
133     bool fix_bugs_backup;
134     bool fix_timer;
135     bool layout_debug;
136     bool hiscore_delete;  // Allow deletion of last entry in score table
137     int hiscore_timer;    // Override default timer on high-score entry screen
138     int new_attract;      // New Attract Mode
139     bool grippy_tyres;    // Handling: Stick to track
140     bool offroad;         // Handling: Drive off-road
141     bool bumper;          // Handling: Smash into other cars without spinning
142     bool turbo;           // Handling: Faster Car
143     int car_pal;          // Car Palette
144 };
145 
146 class Config
147 {
148 public:
149     data_settings_t        data;
150     menu_settings_t        menu;
151     video_settings_t       video;
152     sound_settings_t       sound;
153     controls_settings_t    controls;
154     engine_settings_t      engine;
155     ttrial_settings_t      ttrial;
156     smartypi_settings_t    smartypi;
157 
158 	const static int CABINET_MOVING  = 0;
159 	const static int CABINET_UPRIGHT = 1;
160 	const static int CABINET_MINI    = 2;
161 
162     // Internal screen width and height
163     uint16_t s16_width, s16_height;
164 
165     // Internal screen x offset
166     uint16_t s16_x_off;
167 
168     // 30 or 60 fps
169     int fps;
170 
171     // Original game ticks sprites at 30fps but background scroll at 60fps
172     int tick_fps;
173 
174     // Continuous Mode: Traffic Setting
175     int cont_traffic;
176 
177     Config(void);
178     ~Config(void);
179 
180     void set_config_file(const std::string& filename);
181     void load();
182     bool save();
183     void load_scores(bool original_mode);
184     void save_scores(bool original_mode);
185     void load_tiletrial_scores();
186     void save_tiletrial_scores();
187     bool clear_scores();
188     void set_fps(int fps);
189     void inc_time();
190     void inc_traffic();
191 
192 private:
193 };
194 
195 extern Config config;
196