OSDN Git Service

Merge branch 'master' of github.com:Artanejp/common_source_project-fm7
[csp-qt/common_source_project-fm7.git] / source / src / config.cpp
1 /*
2         Skelton for retropc emulator
3
4         Author : Takeda.Toshiya
5         Date   : 2006.08.18 -
6
7         [ config ]
8 */
9 #if defined(_USE_QT)
10 #include <string>
11 #include <vector>
12 #include "fileio.h"
13 #include "csp_logger.h"
14 #include "qt_main.h"
15 # if defined(Q_OS_WIN)
16 # include <windows.h>
17 # endif
18
19 extern CSP_Logger *csp_logger;
20 #endif
21
22 #include <stdlib.h>
23 #include <stdio.h>
24 #include "common.h"
25 #include "config.h"
26 #include "fileio.h"
27 #if defined(_USE_AGAR)
28 #include "agar_main.h"
29 #endif
30
31 config_t config;
32
33 #ifndef CONFIG_NAME
34 #define CONFIG_NAME "conf"
35 #endif
36
37 BOOL MyWritePrivateProfileInt(LPCTSTR lpAppName, LPCTSTR lpKeyName, int Value, LPCTSTR lpFileName)
38 {
39         return MyWritePrivateProfileString(lpAppName, lpKeyName, create_string(_T("%d"), Value), lpFileName);
40 }
41  
42 BOOL MyWritePrivateProfileBool(LPCTSTR lpAppName, LPCTSTR lpKeyName, bool Value, LPCTSTR lpFileName)
43 {
44         return MyWritePrivateProfileString(lpAppName, lpKeyName, create_string(_T("%d"), Value ? 1 : 0), lpFileName);
45 }
46  
47 bool MyGetPrivateProfileBool(LPCTSTR lpAppName, LPCTSTR lpKeyName, bool bDefault, LPCTSTR lpFileName)
48 {
49         return (MyGetPrivateProfileInt(lpAppName, lpKeyName, bDefault ? 1 : 0, lpFileName) != 0);
50 }
51
52 void initialize_config()
53 {
54         // initial settings
55         memset(&config, 0, sizeof(config_t));
56         config.window_mode = 1; 
57         // control
58 #if defined(USE_BOOT_MODE) && defined(BOOT_MODE_DEFAULT)
59         config.boot_mode = BOOT_MODE_DEFAULT;
60 #endif
61 #if defined(USE_CPU_TYPE) && defined(CPU_TYPE_DEFAULT)
62         config.cpu_type = CPU_TYPE_DEFAULT;
63 #endif
64 #if defined(USE_DIPSWITCH) && defined(DIPSWITCH_DEFAULT)
65         config.dipswitch = DIPSWITCH_DEFAULT;
66 #endif
67 #if defined(USE_DEVICE_TYPE) && defined(DEVICE_TYPE_DEFAULT)
68         config.device_type = DEVICE_TYPE_DEFAULT;
69 #endif
70 #if defined(USE_DRIVE_TYPE) && defined(DRIVE_TYPE_DEFAULT)
71         config.drive_type = DRIVE_TYPE_DEFAULT;
72 #endif
73 #if defined(USE_FD1)
74         for(int drv = 0; drv < MAX_FD; drv++) {
75 #if defined(CORRECT_DISK_TIMING_DEFAULT)
76                 config.correct_disk_timing[drv] = CORRECT_DISK_TIMING_DEFAULT;
77 #else
78                 config.correct_disk_timing[drv] = true;
79 #endif
80 #if defined(IGNORE_DISK_CRC_DEFAULT)
81                 config.ignore_disk_crc[drv] = IGNORE_DISK_CRC_DEFAULT;
82 #endif
83         }
84 #elif defined(USE_FD1)
85         for(int drv = 0; drv < MAX_FD; drv++) {
86                 config.ignore_disk_crc[drv] = false;
87         }
88 #endif  
89 #if defined(USE_TAPE)
90         config.wave_shaper = true;
91         config.direct_load_mzt = true;
92         config.baud_high = true;
93 #endif
94
95         // sound
96 #if defined(SOUND_RATE_DEFAULT)
97         config.sound_frequency = SOUND_RATE_DEFAULT;
98 #else
99         config.sound_frequency = 6;     // 48KHz
100 #endif
101         config.sound_latency = 1;       // 100msec
102         config.general_sound_level = 0;
103 #if defined(USE_SOUND_DEVICE_TYPE) && defined(SOUND_DEVICE_TYPE_DEFAULT)
104         config.sound_device_type = SOUND_DEVICE_TYPE_DEFAULT;
105 #elif defined(USE_SOUND_DEVICE_TYPE)
106         config.sound_device_type = 0;
107 #endif
108         config.sound_strict_rendering = false;
109         
110         // input
111 #ifdef _WIN32
112         config.use_direct_input = true;
113         config.disable_dwm = false;
114 #endif
115         config.keyboard_type = 0;
116 #ifdef USE_JOYSTICK
117         for(int i = 0; i < 4; i++) {
118                 for(int j = 0; j < 16; j++) {
119                         config.joy_buttons[i][j] = (i << 4) | j;
120                 }
121         }
122 #endif  
123         // printer
124 #if defined(USE_PRINTER) && defined(PRINTER_DEVICE_TYPE_DEFAULT)
125         config.printer_device_type = PRINTER_DEVICE_TYPE_DEFAULT;
126 #elif defined(USE_PRINTER)
127         config.printer_device_type = 0;
128 #endif
129 #if defined(USE_QT)
130         config.video_width = 640;
131         config.video_height = 480;
132         config.video_codec_type = 0; // MPEG4
133         
134         config.video_h264_bitrate = 512;
135         config.video_h264_bframes = 4;
136         config.video_h264_b_adapt = 2;
137         config.video_h264_minq = 14;
138         config.video_h264_maxq = 25;
139         config.video_h264_subme = 8;
140         
141         config.video_mpeg4_bitrate = 512;
142         config.video_mpeg4_bframes = 4;
143         config.video_mpeg4_minq = 1;
144         config.video_mpeg4_maxq = 20;
145         
146         config.audio_codec_type = 0;
147         config.video_threads = 0;
148         config.audio_bitrate = 160;
149         config.video_frame_rate = 30;
150 #endif
151         // screen
152 #ifndef ONE_BOARD_MICRO_COMPUTER
153 #ifdef _WIN32
154         config.use_d3d9 = true;
155 #endif
156         config.fullscreen_stretch_type = 1;     // Stretch (Aspect)
157 #endif
158         
159 #if defined(_USE_QT)
160         config.use_opengl_scanline = false;
161         config.opengl_scanline_vert = false;
162         config.opengl_scanline_horiz = false;
163         config.use_opengl_filters = false;
164         config.opengl_filter_num = 0;
165         config.render_platform = CONFIG_RENDER_PLATFORM_OPENGL_MAIN;
166         config.render_major_version = 2; // For crash with some devices.
167         config.render_minor_version = 1;
168         config.log_to_syslog = false;
169         config.log_to_console = true;
170         for(int ii = 0; ii < (CSP_LOG_TYPE_VM_DEVICE_END - CSP_LOG_TYPE_VM_DEVICE_0 + 1) ; ii++) {
171                 for(int jj = 0; jj < 8; jj++) {
172                         config.dev_log_to_syslog[ii][jj] = true;
173                         config.dev_log_to_console[ii][jj] = true;
174                         config.dev_log_recording[ii][jj] = true;
175                 }
176         }
177         config.sound_fdd = 1;
178         config.sound_relay = 0;
179         config.sound_buttons = 0;
180
181         config.roma_kana_conversion = false;
182         config.rendering_type = CONFIG_RENDER_TYPE_STD;
183 #endif  
184 }
185
186 void load_config(const _TCHAR *config_path)
187 {
188         int drv, i;
189         // initial settings
190         initialize_config();
191
192         // control
193 #ifdef USE_BOOT_MODE
194         config.boot_mode = MyGetPrivateProfileInt(_T("Control"), _T("BootMode"), config.boot_mode, config_path);
195 #endif
196 #ifdef USE_CPU_TYPE
197         config.cpu_type = MyGetPrivateProfileInt(_T("Control"), _T("CPUType"), config.cpu_type, config_path);
198 #endif
199 #ifdef USE_DIPSWITCH
200         config.dipswitch = MyGetPrivateProfileInt(_T("Control"), _T("DipSwitch"), config.dipswitch, config_path);
201 #endif
202 #ifdef USE_DEVICE_TYPE
203         config.device_type = MyGetPrivateProfileInt(_T("Control"), _T("DeviceType"), config.device_type, config_path);
204 #endif
205 #ifdef USE_DRIVE_TYPE
206         config.drive_type = MyGetPrivateProfileInt(_T("Control"), _T("DriveType"), config.drive_type, config_path);
207 #endif
208 #ifdef USE_FD1
209         {
210                 for(drv = 0; drv < MAX_FD; drv++) {
211                 config.correct_disk_timing[drv] = MyGetPrivateProfileBool(_T("Control"), create_string(_T("CorrectDiskTiming%d"), drv + 1), config.correct_disk_timing[drv], config_path);
212                 config.ignore_disk_crc[drv] = MyGetPrivateProfileBool(_T("Control"), create_string(_T("IgnoreDiskCRC%d"), drv + 1), config.ignore_disk_crc[drv], config_path);
213                 }
214         }
215 #endif
216
217 #ifdef USE_TAPE
218         config.tape_sound = MyGetPrivateProfileBool(_T("Control"), _T("TapeSound"), config.tape_sound, config_path);
219         config.wave_shaper = MyGetPrivateProfileBool(_T("Control"), _T("WaveShaper"), config.wave_shaper, config_path);
220         config.direct_load_mzt = MyGetPrivateProfileBool(_T("Control"), _T("DirectLoadMZT"), config.direct_load_mzt, config_path);
221         config.baud_high = MyGetPrivateProfileBool(_T("Control"), _T("BaudHigh"), config.baud_high, config_path);
222 #endif
223         
224         // recent files
225 #ifdef USE_CART1
226         MyGetPrivateProfileString(_T("RecentFiles"), _T("InitialCartDir"), _T(""), config.initial_cart_dir, _MAX_PATH, config_path);
227         for(drv = 0; drv < MAX_CART; drv++) {
228                 for(i = 0; i < MAX_HISTORY; i++) {
229                         MyGetPrivateProfileString(_T("RecentFiles"), create_string(_T("RecentCartPath%d_%d"), drv + 1, i + 1), _T(""), config.recent_cart_path[drv][i], _MAX_PATH, config_path);
230                 }
231         }
232 #endif
233 #ifdef USE_FD1
234         MyGetPrivateProfileString(_T("RecentFiles"), _T("InitialDiskDir"), _T(""), config.initial_floppy_disk_dir, _MAX_PATH, config_path);
235     //    get_parent_dir(config.initial_disk_dir);
236         for(drv = 0; drv < MAX_FD; drv++) {
237                 for(i = 0; i < MAX_HISTORY; i++) {
238                         MyGetPrivateProfileString(_T("RecentFiles"), create_string(_T("RecentDiskPath%d_%d"), drv + 1, i + 1), _T(""), config.recent_floppy_disk_path[drv][i], _MAX_PATH, config_path);
239                 }
240         }
241 #endif
242 #ifdef USE_QD1
243         MyGetPrivateProfileString(_T("RecentFiles"), _T("InitialQuickDiskDir"), _T(""), config.initial_quick_disk_dir, _MAX_PATH, config_path);
244         for(drv = 0; drv < MAX_QD; drv++) {
245                 for(i = 0; i < MAX_HISTORY; i++) {
246                         MyGetPrivateProfileString(_T("RecentFiles"), create_string(_T("RecentQuickDiskPath%d_%d"), drv + 1, i + 1), _T(""), config.recent_quick_disk_path[drv][i], _MAX_PATH, config_path);
247                 }
248         }
249 #endif
250
251 #ifdef USE_TAPE
252         MyGetPrivateProfileString(_T("RecentFiles"), _T("InitialTapeDir"), _T(""),
253                                                         config.initial_tape_dir, _MAX_PATH, config_path);
254         for(i = 0; i < MAX_HISTORY; i++) {
255                 MyGetPrivateProfileString(_T("RecentFiles"), create_string(_T("RecentTapePath1_%d"), i + 1), _T(""), config.recent_tape_path[i], _MAX_PATH, config_path);
256         }
257 #endif
258
259 #ifdef USE_LASER_DISC
260         MyGetPrivateProfileString(_T("RecentFiles"), _T("InitialLaserDiscDir"), _T(""),
261                                                         config.initial_laser_disc_dir, _MAX_PATH, config_path);
262         for(int i = 0; i < MAX_HISTORY; i++) {
263                 MyGetPrivateProfileString(_T("RecentFiles"), create_string(_T("RecentLaserDiscPath1_%d"), i + 1), _T(""), config.recent_laser_disc_path[i], _MAX_PATH, config_path);
264         }
265 #endif
266 #ifdef USE_BINARY_FILE1
267         MyGetPrivateProfileString(_T("RecentFiles"), _T("InitialBinaryDir"), _T(""),
268                                                         config.initial_binary_dir, _MAX_PATH, config_path);
269         for(drv = 0; drv < MAX_BINARY; drv++) {
270                 for(i = 0; i < MAX_HISTORY; i++) {
271                         _TCHAR name[64];
272                         my_stprintf_s(name, 64, _T("RecentBinaryPath%d_%d"), drv + 1, i + 1);
273                         MyGetPrivateProfileString(_T("RecentFiles"), (const _TCHAR *)name, _T(""),
274                                                                         config.recent_binary_path[drv][i], _MAX_PATH, config_path);
275                 }
276         }
277 #endif
278 #if defined(USE_BUBBLE1)
279         MyGetPrivateProfileString(_T("RecentFiles"), _T("InitialBubbleDir"), _T(""),
280                                                         config.initial_bubble_casette_dir, _MAX_PATH, config_path);
281         for(drv = 0; drv < MAX_BUBBLE; drv++) {
282                 for(i = 0; i < MAX_HISTORY; i++) {
283                         _TCHAR name[64];
284                         my_stprintf_s(name, 64, _T("RecentBubblePath%d_%d"), drv + 1, i + 1);
285                         MyGetPrivateProfileString(_T("RecentFiles"), (const _TCHAR *)name, _T(""),
286                                                                         config.recent_bubble_casette_path[drv][i], _MAX_PATH, config_path);
287                 }
288         }
289 #endif
290 #ifdef USE_BUBBLE1
291         MyGetPrivateProfileString(_T("RecentFiles"), _T("InitialBubbleDir"), _T(""), config.initial_bubble_casette_dir, _MAX_PATH, config_path);
292         for(int drv = 0; drv < MAX_BUBBLE; drv++) {
293                 for(int i = 0; i < MAX_HISTORY; i++) {
294                         MyGetPrivateProfileString(_T("RecentFiles"), create_string(_T("RecentBubblePath%d_%d"), drv + 1, i + 1), _T(""), config.recent_bubble_casette_path[drv][i], _MAX_PATH, config_path);
295                 }
296         }
297 #endif
298         
299         // screen
300 #ifndef ONE_BOARD_MICRO_COMPUTER
301         config.window_mode = MyGetPrivateProfileInt(_T("Screen"), _T("WindowMode"), config.window_mode, config_path);
302 #ifdef _WIN32
303         config.use_d3d9 = MyGetPrivateProfileBool(_T("Screen"), _T("UseD3D9"), config.use_d3d9, config_path);
304         config.wait_vsync = MyGetPrivateProfileBool(_T("Screen"), _T("WaitVSync"), config.wait_vsync, config_path);
305 #endif
306 //-     config.stretch_type = MyGetPrivateProfileInt(_T("Screen"), _T("StretchType"), config.stretch_type, config_path);
307         config.window_stretch_type = MyGetPrivateProfileInt(_T("Screen"), _T("WindowStretchType"), config.window_stretch_type, config_path);
308         config.fullscreen_stretch_type = MyGetPrivateProfileInt(_T("Screen"), _T("FullScreenStretchType"), config.fullscreen_stretch_type, config_path);
309
310 #else
311         config.window_mode = MyGetPrivateProfileInt(_T("Screen"), _T("WindowMode"), config.window_mode, config_path);
312 #endif
313 #ifdef USE_MONITOR_TYPE
314         config.monitor_type = MyGetPrivateProfileInt(_T("Screen"), _T("MonitorType"), config.monitor_type, config_path);
315 #endif
316 #ifdef USE_CRT_FILTER
317         config.crt_filter = MyGetPrivateProfileBool(_T("Screen"), _T("CRTFilter"), config.crt_filter, config_path);
318 #endif
319 #ifdef USE_SCANLINE
320         config.scan_line = MyGetPrivateProfileBool(_T("Screen"), _T("ScanLine"), config.scan_line, config_path);
321 #endif
322
323 #ifdef USE_SCREEN_ROTATE
324         config.rotate_type = MyGetPrivateProfileInt(_T("Screen"), _T("RotateType"), config.rotate_type, config_path);
325 #endif
326 #if defined(_USE_QT)
327         config.use_opengl_scanline = MyGetPrivateProfileBool(_T("Screen"), _T("UseOpenGLScanLine"),
328                                                                                                            config.use_opengl_scanline, config_path);
329         config.opengl_scanline_vert = MyGetPrivateProfileBool(_T("Screen"), _T("OpenGLScanLineVert"),
330                                                                                                            config.opengl_scanline_vert, config_path);;
331         config.opengl_scanline_horiz = MyGetPrivateProfileBool(_T("Screen"), _T("OpenGLScanLineHoriz"),
332                                                                                                            config.opengl_scanline_horiz, config_path);;
333         config.use_opengl_filters = MyGetPrivateProfileBool(_T("Screen"), _T("UseOpenGLFilters"),
334                                                                                                            config.use_opengl_filters, config_path);
335         config.opengl_filter_num =      MyGetPrivateProfileInt(_T("Screen"), _T("OpenGLFilterNum"),
336                                                                                                          config.opengl_filter_num, config_path);
337         config.render_platform = MyGetPrivateProfileInt(_T("Screen"), _T("RenderPlatform"),
338                                                                                                    config.render_platform, config_path);
339         config.render_major_version = MyGetPrivateProfileInt(_T("Screen"), _T("RenderMajorVersion"),
340                                                                                                    config.render_major_version, config_path);
341         config.render_minor_version = MyGetPrivateProfileInt(_T("Screen"), _T("RenderMinorVersion"),
342                                                                                                    config.render_minor_version, config_path);
343         config.rendering_type = MyGetPrivateProfileInt(_T("Screen"), _T("RenderType"),
344                                                                                                          config.rendering_type, config_path);
345         if(config.rendering_type < 0) config.rendering_type = 0;
346         if(config.rendering_type >= CONFIG_RENDER_TYPE_END) config.rendering_type = CONFIG_RENDER_TYPE_END - 1;
347 #endif  
348         // sound
349         config.sound_frequency = MyGetPrivateProfileInt(_T("Sound"), _T("Frequency"), config.sound_frequency, config_path);
350         config.sound_latency = MyGetPrivateProfileInt(_T("Sound"), _T("Latency"), config.sound_latency, config_path);
351         config.sound_strict_rendering = MyGetPrivateProfileBool(_T("Sound"), _T("StrictRendering"), config.sound_strict_rendering, config_path);
352 #ifdef USE_SOUND_DEVICE_TYPE
353         config.sound_device_type = MyGetPrivateProfileInt(_T("Sound"), _T("DeviceType"), config.sound_device_type, config_path);
354 #endif
355 #ifdef USE_SOUND_VOLUME
356         for(int i = 0; i < USE_SOUND_VOLUME; i++) {
357                 int tmp_l = MyGetPrivateProfileInt(_T("Sound"), create_string(_T("VolumeLeft%d"), i + 1), config.sound_volume_l[i], config_path);
358                 int tmp_r = MyGetPrivateProfileInt(_T("Sound"), create_string(_T("VolumeRight%d"), i + 1), config.sound_volume_r[i], config_path);
359 #ifdef _USE_QT
360                 // Note: when using balance , levels are -40±20db to 0±20db.
361                 config.sound_volume_l[i] = max(-60, min(20, tmp_l));
362                 config.sound_volume_r[i] = max(-60, min(20, tmp_r));
363 #else
364                 config.sound_volume_l[i] = max(-40, min(0, tmp_l));
365                 config.sound_volume_r[i] = max(-40, min(0, tmp_r));
366 #endif
367         }
368 #endif
369         MyGetPrivateProfileString(_T("Sound"), _T("FMGenDll"), _T("mamefm.dll"), config.fmgen_dll_path, _MAX_PATH, config_path);
370         config.general_sound_level = MyGetPrivateProfileInt(_T("Sound"), _T("GeneralSoundLevel"), config.general_sound_level, config_path);
371         config.sound_strict_rendering = MyGetPrivateProfileBool(_T("Sound"), _T("StrictRendering"), config.sound_strict_rendering, config_path);
372
373         // input
374 #ifdef _WIN32
375         config.use_direct_input = MyGetPrivateProfileBool(_T("Input"), _T("UseDirectInput"), config.use_direct_input, config_path);
376         config.disable_dwm = MyGetPrivateProfileBool(_T("Input"), _T("DisableDwm"), config.disable_dwm, config_path);
377 #endif
378         config.keyboard_type = MyGetPrivateProfileInt(_T("Input"), _T("KeyboardType"), config.keyboard_type, config_path);
379 #ifdef USE_JOYSTICK
380         for(int i = 0; i < 4; i++) {
381                 for(int j = 0; j < 16; j++) {
382                         config.joy_buttons[i][j] = MyGetPrivateProfileInt(_T("Input"), create_string(_T("JoyButtons%d_%d"), i + 1, j + 1), config.joy_buttons[i][j], config_path);
383                 }
384         }
385 #endif   
386 #if defined(_USE_QT)
387         for(i = 0; i < 16; i++) {
388                 _TCHAR name[256];
389                 my_stprintf_s(name, 256, _T("AssignedJoystick"), i + 1);
390                 MyGetPrivateProfileString(_T("Input"), (const _TCHAR *)name, _T(""),
391                                                                   config.assigned_joystick_name[i], 256, config_path);
392         }
393 #endif  
394         // printer
395 #ifdef USE_PRINTER
396         config.printer_device_type = MyGetPrivateProfileInt(_T("Printer"), _T("DeviceType"), config.printer_device_type, config_path);
397         MyGetPrivateProfileString(_T("Printer"), _T("PrinterDll"), _T("printer.dll"), config.printer_dll_path, _MAX_PATH, config_path);
398 #endif
399 #if defined(_USE_QT)
400         config.video_width   = MyGetPrivateProfileInt(_T("Video"), _T("VideoWidth"), config.video_width, config_path);
401         if(config.video_width < 128) config.video_width = 128;
402         config.video_height  = MyGetPrivateProfileInt(_T("Video"), _T("VideoHeight"), config.video_height, config_path);
403         if(config.video_height < 80) config.video_height = 80;
404         
405         config.video_codec_type = MyGetPrivateProfileInt(_T("Video"), _T("VideoCodecType"), config.video_codec_type, config_path);
406         if(config.video_codec_type > 1) config.video_codec_type = 1;
407         if(config.video_codec_type < 0) config.video_codec_type = 0;
408         
409         config.audio_codec_type = MyGetPrivateProfileInt(_T("Video"), _T("AudioCodecType"), config.audio_codec_type, config_path);
410         if(config.video_codec_type > 2) config.audio_codec_type = 2;
411         if(config.video_codec_type < 0) config.audio_codec_type = 0;
412         
413         config.video_h264_bitrate = MyGetPrivateProfileInt(_T("Video"), _T("H264Bitrate"), config.video_h264_bitrate, config_path);
414         if(config.video_h264_bitrate < 64) config.video_h264_bitrate = 64;
415
416         config.video_h264_bframes = MyGetPrivateProfileInt(_T("Video"), _T("H264BFrames"), config.video_h264_bframes, config_path);
417         if(config.video_h264_bframes < 0) config.video_h264_bframes = 0;
418         if(config.video_h264_bframes > 10) config.video_h264_bframes = 10;
419
420         config.video_h264_b_adapt = MyGetPrivateProfileInt(_T("Video"), _T("H264BAdapt"), config.video_h264_b_adapt, config_path);
421         if(config.video_h264_b_adapt < 0) config.video_h264_b_adapt = 0;
422         if(config.video_h264_b_adapt > 2) config.video_h264_b_adapt = 2;
423         
424         config.video_h264_subme   = MyGetPrivateProfileInt(_T("Video"), _T("H264Subme"), config.video_h264_subme, config_path);
425         if(config.video_h264_subme < 0) config.video_h264_subme = 0;
426         if(config.video_h264_subme > 11) config.video_h264_subme = 11;
427
428         config.video_h264_minq   = MyGetPrivateProfileInt(_T("Video"), _T("H264MinQ"), config.video_h264_minq, config_path);
429         if(config.video_h264_minq < 0) config.video_h264_minq = 0;
430         if(config.video_h264_minq > 63) config.video_h264_minq = 63;
431
432         config.video_h264_maxq   = MyGetPrivateProfileInt(_T("Video"), _T("H264MaxQ"), config.video_h264_maxq, config_path);
433         if(config.video_h264_maxq < 0) config.video_h264_maxq = 0;
434         if(config.video_h264_maxq > 63) config.video_h264_maxq = 63;
435         
436         config.video_mpeg4_bitrate = MyGetPrivateProfileInt(_T("Video"), _T("MPEG4Bitrate"), config.video_mpeg4_bitrate, config_path);
437         if(config.video_mpeg4_bitrate < 64) config.video_mpeg4_bitrate = 64;
438
439         config.video_mpeg4_bframes = MyGetPrivateProfileInt(_T("Video"), _T("MPEG4BFrames"), config.video_mpeg4_bframes, config_path);
440         if(config.video_mpeg4_bframes < 0) config.video_mpeg4_bframes = 0;
441         if(config.video_mpeg4_bframes > 10) config.video_mpeg4_bframes = 10;
442
443         config.video_mpeg4_minq   = MyGetPrivateProfileInt(_T("Video"), _T("MPEG4MinQ"), config.video_mpeg4_minq, config_path);
444         if(config.video_mpeg4_minq < 1) config.video_mpeg4_minq = 1;
445         if(config.video_mpeg4_minq > 31) config.video_mpeg4_minq = 31;
446
447         config.video_mpeg4_maxq   = MyGetPrivateProfileInt(_T("Video"), _T("MPEG4MaxQ"), config.video_mpeg4_maxq, config_path);
448         if(config.video_mpeg4_maxq < 1) config.video_mpeg4_maxq = 1;
449         if(config.video_mpeg4_maxq > 31) config.video_mpeg4_maxq = 31;
450         if(config.video_mpeg4_maxq < config.video_mpeg4_minq) {
451                 int n;
452                 n = config.video_mpeg4_maxq;
453                 config.video_mpeg4_maxq  = config.video_mpeg4_minq;
454                 config.video_mpeg4_minq = n;
455         }
456
457         config.video_threads = MyGetPrivateProfileInt(_T("Video"), _T("VideoThreads"), config.video_threads, config_path);
458         if(config.video_threads < 0) config.video_threads = 0;
459         if(config.video_threads > 16) config.video_threads = 16;
460         
461         config.audio_bitrate = MyGetPrivateProfileInt(_T("Video"), _T("AudioBitrate"), config.audio_bitrate, config_path);
462         if(config.audio_bitrate < 16) config.audio_bitrate = 16;
463         if(config.audio_bitrate > 448) config.audio_bitrate = 448;
464         
465         config.video_frame_rate = MyGetPrivateProfileInt(_T("Video"), _T("VideoFramerate"), config.video_frame_rate, config_path);
466         if(config.video_frame_rate < 15) config.video_frame_rate = 15;
467         if(config.video_frame_rate > 75) config.video_frame_rate = 75;
468
469 #endif  
470 #if defined(_USE_QT)
471         config.sound_fdd = MyGetPrivateProfileInt(_T("Emulator"), _T("SoundFDD"), config.sound_fdd, config_path);
472         config.sound_relay = MyGetPrivateProfileInt(_T("Emulator"), _T("SoundRelay"), config.sound_relay, config_path);
473         config.sound_buttons = MyGetPrivateProfileInt(_T("Emulator"), _T("SoundButtons"), config.sound_buttons, config_path);
474         
475         config.log_to_syslog = MyGetPrivateProfileBool(_T("Emulator"), _T("WriteToSyslog"), config.log_to_syslog, config_path);
476         config.log_to_console = MyGetPrivateProfileBool(_T("Emulator"), _T("WriteToConsole"), config.log_to_console, config_path);
477         config.roma_kana_conversion = MyGetPrivateProfileInt(_T("Emulator"), _T("RomaKana"), config.roma_kana_conversion, config_path);
478
479         for(int ii = 0; ii < (CSP_LOG_TYPE_VM_DEVICE_END - CSP_LOG_TYPE_VM_DEVICE_0 + 1) ; ii++) {
480                 uint32_t flags = 0;
481                 flags = MyGetPrivateProfileInt(_T("Emulator"), create_string(_T("SyslogEnabled%d"), ii), 0xffff, config_path);
482                 for(int jj = 0; jj < 8; jj++) {
483                         config.dev_log_to_syslog[ii][jj] = ((flags & 0x0001) != 0) ? true : false;
484                         flags >>= 1;
485                 }
486                 flags = 0;
487                 flags = MyGetPrivateProfileInt(_T("Emulator"), create_string(_T("ConsoleLogEnabled%d"), ii), 0xffff, config_path);
488                 for(int jj = 0; jj < 8; jj++) {
489                         config.dev_log_to_console[ii][jj] = ((flags & 0x0001) != 0) ? true : false;
490                         flags >>= 1;
491                 }
492                 flags = MyGetPrivateProfileInt(_T("Emulator"), create_string(_T("RecordLogEnabled%d"), ii), 0xffff, config_path);
493                 for(int jj = 0; jj < 8; jj++) {
494                         config.dev_log_recording[ii][jj] = ((flags & 0x0001) != 0) ? true : false;
495                         flags >>= 1;
496                 }
497         }
498 #endif
499 #if defined(_USE_QT)
500         //csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "Read config done.");
501 #endif
502 }
503
504 void save_config(const _TCHAR *config_path)
505 {
506         int drv, i;
507 #if !defined(_MSC_VER)
508         {
509                 FILEIO *pt = new FILEIO;
510                 if(pt->Fopen(config_path, FILEIO_WRITE_ASCII) != true) {
511                         delete pt;
512                         return;
513                 }
514                 pt->Fclose();
515                 delete pt;
516         }
517         
518 #endif  
519         // control
520 # ifdef USE_BOOT_MODE
521         MyWritePrivateProfileInt(_T("Control"), _T("BootMode"), config.boot_mode, config_path);
522 #endif
523 #ifdef USE_CPU_TYPE
524         MyWritePrivateProfileInt(_T("Control"), _T("CPUType"), config.cpu_type, config_path);
525 #endif
526 #ifdef USE_DIPSWITCH
527         MyWritePrivateProfileInt(_T("Control"), _T("DipSwitch"), config.dipswitch, config_path);
528 #endif
529 #ifdef USE_DEVICE_TYPE
530         MyWritePrivateProfileInt(_T("Control"), _T("DeviceType"), config.device_type, config_path);
531 #endif
532 #ifdef USE_DRIVE_TYPE
533         MyWritePrivateProfileInt(_T("Control"), _T("DriveType"), config.drive_type, config_path);
534 #endif
535 #ifdef USE_FD1
536         {
537                 for(drv = 0; drv < MAX_FD; drv++) {
538                 MyWritePrivateProfileBool(_T("Control"), create_string(_T("CorrectDiskTiming%d"), drv + 1), config.correct_disk_timing[drv], config_path);
539                 MyWritePrivateProfileBool(_T("Control"), create_string(_T("IgnoreDiskCRC%d"), drv + 1), config.ignore_disk_crc[drv], config_path);
540                 }
541         }
542
543 #endif
544 #ifdef USE_TAPE
545         MyWritePrivateProfileBool(_T("Control"), _T("TapeSound"), config.tape_sound, config_path);
546         MyWritePrivateProfileBool(_T("Control"), _T("WaveShaper"), config.wave_shaper, config_path);
547         MyWritePrivateProfileBool(_T("Control"), _T("DirectLoadMZT"), config.direct_load_mzt, config_path);
548         MyWritePrivateProfileBool(_T("Control"), _T("BaudHigh"), config.baud_high, config_path);
549 #endif
550 #ifdef USE_BUBBLE1
551         MyWritePrivateProfileString(_T("RecentFiles"), _T("InitialBubbleDir"), config.initial_bubble_casette_dir, config_path);
552         for(int drv = 0; drv < MAX_BUBBLE; drv++) {
553                 for(int i = 0; i < MAX_HISTORY; i++) {
554                         MyWritePrivateProfileString(_T("RecentFiles"), create_string(_T("RecentBubblePath%d_%d"), drv + 1, i + 1), config.recent_bubble_casette_path[drv][i], config_path);
555                 }
556         }
557 #endif
558         
559         // recent files
560 #ifdef USE_CART1
561         MyWritePrivateProfileString(_T("RecentFiles"), _T("InitialCartDir"), config.initial_cart_dir, config_path);
562         for(drv = 0; drv < MAX_CART; drv++) {
563                 for(i = 0; i < MAX_HISTORY; i++) {
564                         MyWritePrivateProfileString(_T("RecentFiles"), create_string(_T("RecentCartPath%d_%d"), drv + 1, i + 1), config.recent_cart_path[drv][i], config_path);
565                 }
566         }
567 #endif
568 #ifdef USE_FD1
569         MyWritePrivateProfileString(_T("RecentFiles"), _T("InitialDiskDir"), config.initial_floppy_disk_dir, config_path);
570         for(drv = 0; drv < MAX_FD; drv++) {
571                 for(i = 0; i < MAX_HISTORY; i++) {
572                         MyWritePrivateProfileString(_T("RecentFiles"), create_string(_T("RecentDiskPath%d_%d"), drv + 1, i + 1), config.recent_floppy_disk_path[drv][i], config_path);
573                 }
574         }
575 #endif
576 #ifdef USE_QD1
577         MyWritePrivateProfileString(_T("RecentFiles"), _T("InitialQuickDiskDir"), config.initial_quick_disk_dir, config_path);
578         for(drv = 0; drv < MAX_QD; drv++) {
579                 for(i = 0; i < MAX_HISTORY; i++) {
580                         MyWritePrivateProfileString(_T("RecentFiles"), create_string(_T("RecentQuickDiskPath%d_%d"), drv + 1, i + 1), config.recent_quick_disk_path[drv][i], config_path);
581                 }
582         }
583 #endif
584 #ifdef USE_TAPE
585         MyWritePrivateProfileString(_T("RecentFiles"), _T("InitialTapeDir"), config.initial_tape_dir, config_path);
586         for(i = 0; i < MAX_HISTORY; i++) {
587                 MyWritePrivateProfileString(_T("RecentFiles"), create_string(_T("RecentTapePath1_%d"), i + 1), config.recent_tape_path[i], config_path);
588         }
589 #endif
590 #ifdef USE_COMPACT_DISC
591         MyWritePrivateProfileString(_T("RecentFiles"), _T("InitialCompactDiscDir"), config.initial_compact_disc_dir, config_path);
592         for(int i = 0; i < MAX_HISTORY; i++) {
593                 MyWritePrivateProfileString(_T("RecentFiles"), create_string(_T("RecentCompactDiscPath1_%d"), i + 1), config.recent_compact_disc_path[i], config_path);
594         }
595 #endif
596 #ifdef USE_LASER_DISC
597         MyWritePrivateProfileString(_T("RecentFiles"), _T("InitialLaserDiscDir"), config.initial_laser_disc_dir, config_path);
598         for(int i = 0; i < MAX_HISTORY; i++) {
599                 MyWritePrivateProfileString(_T("RecentFiles"), create_string(_T("RecentLaserDiscPath1_%d"), i + 1), config.recent_laser_disc_path[i], config_path);
600         }
601 #endif
602 #ifdef USE_BINARY_FILE1
603         MyWritePrivateProfileString(_T("RecentFiles"), _T("InitialBinaryDir"), config.initial_binary_dir, config_path);
604         for(drv = 0; drv < MAX_BINARY; drv++) {
605                 for(i = 0; i < MAX_HISTORY; i++) {
606                         MyWritePrivateProfileString(_T("RecentFiles"), create_string(_T("RecentBinaryPath%d_%d"), drv + 1, i + 1), config.recent_binary_path[drv][i], config_path);
607                 }
608         }
609 #endif
610 #if defined(USE_BUBBLE1)
611         MyWritePrivateProfileString(_T("RecentFiles"), _T("InitialBubbleDir"), config.initial_bubble_casette_dir, config_path);
612         for(drv = 0; drv < MAX_BUBBLE; drv++) {
613                 for(i = 0; i < MAX_HISTORY; i++) {
614                         MyWritePrivateProfileString(_T("RecentFiles"), create_string(_T("RecentBubblePath%d_%d"), drv + 1, i + 1), config.recent_bubble_casette_path[drv][i], config_path);                     
615                 }
616         }
617 #endif
618 #if defined(_USE_QT)
619         MyWritePrivateProfileBool(_T("Screen"), _T("UseOpenGLScanLine"), config.use_opengl_scanline, config_path);
620         MyWritePrivateProfileBool(_T("Screen"), _T("OpenGLScanLineVert"), config.opengl_scanline_vert, config_path);;
621         MyWritePrivateProfileBool(_T("Screen"), _T("OpenGLScanLineHoriz"), config.opengl_scanline_horiz, config_path);;
622         MyWritePrivateProfileBool(_T("Screen"), _T("UseOpenGLFilters"), config.use_opengl_filters, config_path);
623         MyWritePrivateProfileInt(_T("Screen"), _T("OpenGLFilterNum"), config.opengl_filter_num, config_path);
624         MyWritePrivateProfileInt(_T("Screen"), _T("RenderType"), config.rendering_type, config_path);
625         MyWritePrivateProfileInt(_T("Screen"), _T("RenderPlatform"), config.render_platform, config_path);
626         MyWritePrivateProfileInt(_T("Screen"), _T("RenderMajorVersion"), config.render_major_version, config_path);
627         MyWritePrivateProfileInt(_T("Screen"), _T("RenderMinorVersion"), config.render_minor_version, config_path);
628 #endif
629         
630         // screen
631 #ifndef ONE_BOARD_MICRO_COMPUTER
632         MyWritePrivateProfileInt(_T("Screen"), _T("WindowMode"), config.window_mode, config_path);
633 #ifdef _WIN32
634         MyWritePrivateProfileBool(_T("Screen"), _T("UseD3D9"), config.use_d3d9, config_path);
635         MyWritePrivateProfileBool(_T("Screen"), _T("WaitVSync"), config.wait_vsync, config_path);
636 #endif
637         //MyWritePrivateProfileInt(_T("Screen"), _T("StretchType"), config.stretch_type, config_path);
638         MyWritePrivateProfileInt(_T("Screen"), _T("WindowStretchType"), config.window_stretch_type, config_path);
639         MyWritePrivateProfileInt(_T("Screen"), _T("FullScreenStretchType"), config.fullscreen_stretch_type, config_path);
640
641 #else
642         MyWritePrivateProfileInt(_T("Screen"), _T("WindowMode"), config.window_mode, config_path);
643 #endif
644 #ifdef USE_MONITOR_TYPE
645         MyWritePrivateProfileInt(_T("Screen"), _T("MonitorType"), config.monitor_type, config_path);
646 #endif
647 #ifdef USE_CRT_FILTER
648         MyWritePrivateProfileBool(_T("Screen"), _T("CRTFilter"), config.crt_filter, config_path);
649 #endif
650 #ifdef USE_SCANLINE
651         MyWritePrivateProfileBool(_T("Screen"), _T("ScanLine"), config.scan_line, config_path);
652 #endif
653 #ifdef USE_SCREEN_ROTATE
654         MyWritePrivateProfileInt(_T("Screen"), _T("RotateType"), config.rotate_type, config_path);
655 #endif
656         
657         // sound
658         MyWritePrivateProfileInt(_T("Sound"), _T("Frequency"), config.sound_frequency, config_path);
659         MyWritePrivateProfileInt(_T("Sound"), _T("Latency"), config.sound_latency, config_path);
660         MyWritePrivateProfileBool(_T("Sound"), _T("StrictRendering"), config.sound_strict_rendering, config_path);
661 #ifdef USE_SOUND_DEVICE_TYPE
662         MyWritePrivateProfileInt(_T("Sound"), _T("DeviceType"), config.sound_device_type, config_path);
663 #endif
664 #ifdef USE_SOUND_VOLUME
665         for(int i = 0; i < USE_SOUND_VOLUME; i++) {
666                 MyWritePrivateProfileInt(_T("Sound"), create_string(_T("VolumeLeft%d"), i + 1), config.sound_volume_l[i], config_path);
667                 MyWritePrivateProfileInt(_T("Sound"), create_string(_T("VolumeRight%d"), i + 1), config.sound_volume_r[i], config_path);
668         }
669 #endif
670
671         MyWritePrivateProfileString(_T("Sound"), _T("FMGenDll"), config.fmgen_dll_path, config_path);
672         MyWritePrivateProfileInt(_T("Sound"), _T("GeneralSoundLevel"), config.general_sound_level, config_path);
673         MyWritePrivateProfileBool(_T("Sound"), _T("StrictRendering"), config.sound_strict_rendering, config_path);;
674         // input
675 #ifdef _WIN32
676         MyWritePrivateProfileBool(_T("Input"), _T("UseDirectInput"), config.use_direct_input, config_path);
677         MyWritePrivateProfileBool(_T("Input"), _T("DisableDwm"), config.disable_dwm, config_path);
678 #endif
679         MyWritePrivateProfileInt(_T("Input"), _T("KeyboardType"), config.keyboard_type, config_path);
680 #ifdef USE_JOYSTICK   
681         for(int i = 0; i < 4; i++) {
682                 for(int j = 0; j < 16; j++) {
683                         MyWritePrivateProfileInt(_T("Input"), create_string(_T("JoyButtons%d_%d"), i + 1, j + 1), config.joy_buttons[i][j], config_path);
684                 }
685         }
686 #endif   
687 #if defined(_USE_QT)
688         for(i = 0; i < 16; i++) {
689                 _TCHAR name[256];
690                 my_stprintf_s(name, 256, _T("AssignedJoystick%d"), i + 1);
691                 MyWritePrivateProfileString(_T("Input"), (const _TCHAR *)name, 
692                                                                         config.assigned_joystick_name[i], config_path);
693         }
694 #endif  
695         
696         // printer
697 #ifdef USE_PRINTER
698         MyWritePrivateProfileInt(_T("Printer"), _T("DeviceType"), config.printer_device_type, config_path);
699 #endif
700 #if defined(_USE_QT)
701         MyWritePrivateProfileInt(_T("Video"), _T("VideoWidth"), config.video_width, config_path);
702         MyWritePrivateProfileInt(_T("Video"), _T("VideoHeight"), config.video_height, config_path);
703         MyWritePrivateProfileInt(_T("Video"), _T("VideoCodecType"), config.video_codec_type, config_path);
704         MyWritePrivateProfileInt(_T("Video"), _T("AudioCodecType"), config.audio_codec_type, config_path);
705         
706         MyWritePrivateProfileInt(_T("Video"), _T("H264Bitrate"), config.video_h264_bitrate, config_path);
707         MyWritePrivateProfileInt(_T("Video"), _T("H264BFrames"), config.video_h264_bframes, config_path);
708         MyWritePrivateProfileInt(_T("Video"), _T("H264BAdapt"), config.video_h264_b_adapt, config_path);
709         MyWritePrivateProfileInt(_T("Video"), _T("H264MinQ"), config.video_h264_minq, config_path);
710         MyWritePrivateProfileInt(_T("Video"), _T("H264MaxQ"), config.video_h264_maxq, config_path);
711         MyWritePrivateProfileInt(_T("Video"), _T("H264Subme"), config.video_h264_subme, config_path);
712         
713         MyWritePrivateProfileInt(_T("Video"), _T("MPEG4Bitrate"), config.video_mpeg4_bitrate, config_path);
714         MyWritePrivateProfileInt(_T("Video"), _T("MPEG4BFrames"), config.video_mpeg4_bframes, config_path);
715         MyWritePrivateProfileInt(_T("Video"), _T("MPEG4MinQ"), config.video_mpeg4_minq, config_path);
716         MyWritePrivateProfileInt(_T("Video"), _T("MPEG4MaxQ"), config.video_mpeg4_maxq, config_path);
717         
718         MyWritePrivateProfileInt(_T("Video"), _T("VideoThreads"), config.video_threads, config_path);
719         MyWritePrivateProfileInt(_T("Video"), _T("AudioBitrate"), config.audio_bitrate, config_path);
720         MyWritePrivateProfileInt(_T("Video"), _T("VideoFramerate"), config.video_frame_rate, config_path);
721 #endif  
722 #if defined(_USE_QT)
723         MyWritePrivateProfileInt(_T("Emulator"), _T("SoundFDD"), config.sound_fdd, config_path);
724         MyWritePrivateProfileInt(_T("Emulator"), _T("SoundRelay"), config.sound_relay, config_path);
725         MyWritePrivateProfileInt(_T("Emulator"), _T("SoundButtons"), config.sound_buttons, config_path);
726         
727         MyWritePrivateProfileBool(_T("Emulator"), _T("WriteToSyslog"), config.log_to_syslog, config_path);
728         MyWritePrivateProfileBool(_T("Emulator"), _T("WriteToConsole"), config.log_to_console, config_path);
729         MyWritePrivateProfileInt(_T("Emulator"), _T("RomaKana"), config.roma_kana_conversion, config_path);
730         
731         for(int ii = 0; ii < (CSP_LOG_TYPE_VM_DEVICE_END - CSP_LOG_TYPE_VM_DEVICE_0 + 1) ; ii++) {
732                 uint32_t flags = 0;
733                 flags = 0;
734                 for(int jj = 0; jj < 8; jj++) {
735                         flags <<= 1;
736                         if(config.dev_log_to_syslog[ii][jj]) flags |= 0x0001;
737                 }
738                 MyWritePrivateProfileInt(_T("Emulator"), create_string(_T("SyslogEnabled%d"), ii), flags, config_path);
739
740                 flags = 0;
741                 for(int jj = 0; jj < 8; jj++) {
742                         flags <<= 1;
743                         if(config.dev_log_to_console[ii][jj]) flags |= 0x0001;
744                 }
745                 MyWritePrivateProfileInt(_T("Emulator"), create_string(_T("ConsoleLogEnabled%d"), ii), flags, config_path);
746
747                 flags = 0;
748                 for(int jj = 0; jj < 8; jj++) {
749                         flags <<= 1;
750                         if(config.dev_log_recording[ii][jj]) flags |= 0x0001;
751                 }
752                 MyWritePrivateProfileInt(_T("Emulator"), create_string(_T("RecordLogEnabled%d"), ii), flags, config_path);
753         }
754 #endif
755 #if defined(_USE_QT) && !defined(Q_OS_WIN)
756         //csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "Write config done.");
757 #endif
758 }
759
760 #define STATE_VERSION   5
761
762 void save_config_state(void *f)
763 {
764         FILEIO *state_fio = (FILEIO *)f;
765         
766         state_fio->FputUint32(STATE_VERSION);
767 #ifdef USE_BOOT_MODE
768         state_fio->FputInt32(config.boot_mode);
769 #endif
770 #ifdef USE_CPU_TYPE
771         state_fio->FputInt32(config.cpu_type);
772 #endif
773 #ifdef USE_DIPSWITCH
774         state_fio->FputUint32(config.dipswitch);
775 #endif
776 #ifdef USE_DEVICE_TYPE
777         state_fio->FputInt32(config.device_type);
778 #endif
779 #ifdef USE_DRIVE_TYPE
780         state_fio->FputInt32(config.drive_type);
781 #endif
782 #ifdef USE_FD1
783         for(int drv = 0; drv < MAX_FD; drv++) {
784                 state_fio->FputBool(config.correct_disk_timing[drv]);
785                 state_fio->FputBool(config.ignore_disk_crc[drv]);
786         }
787 //      for(int drv = 0; drv < MAX_FD; drv++) {
788 //              state_fio->FputBool(config.fdd_hack_fast_transfer[drv]);
789 //      }
790 #endif
791 #ifdef USE_MONITOR_TYPE
792         state_fio->FputInt32(config.monitor_type);
793 #endif
794 #ifdef USE_SOUND_DEVICE_TYPE
795         state_fio->FputInt32(config.sound_device_type);
796 #endif
797 #ifdef USE_PRINTER
798         state_fio->FputInt32(config.printer_device_type);
799 #endif
800         state_fio->FputInt32(config.keyboard_type);
801 }
802
803 bool load_config_state(void *f)
804 {
805         FILEIO *state_fio = (FILEIO *)f;
806         
807         if(state_fio->FgetUint32() != STATE_VERSION) {
808                 return false;
809         }
810 #ifdef USE_BOOT_MODE
811         config.boot_mode = state_fio->FgetInt32();
812 #endif
813 #ifdef USE_CPU_TYPE
814         config.cpu_type = state_fio->FgetInt32();
815 #endif
816 #ifdef USE_DIPSWITCH
817         config.dipswitch = state_fio->FgetUint32();
818 #endif
819 #ifdef USE_DEVICE_TYPE
820         config.device_type = state_fio->FgetInt32();
821 #endif
822 #ifdef USE_DRIVE_TYPE
823         config.drive_type = state_fio->FgetInt32();
824 #endif
825 #ifdef USE_FD1
826         for(int drv = 0; drv < MAX_FD; drv++) {
827                 config.correct_disk_timing[drv] = state_fio->FgetBool();
828                 config.ignore_disk_crc[drv] = state_fio->FgetBool();
829         }
830 //      for(int drv = 0; drv < MAX_FD; drv++) {
831 //              config.fdd_hack_fast_transfer[drv] = state_fio->FgetBool();
832 //      }
833 #endif
834 #ifdef USE_MONITOR_TYPE
835         config.monitor_type = state_fio->FgetInt32();
836 #endif
837 #ifdef USE_SOUND_DEVICE_TYPE
838         config.sound_device_type = state_fio->FgetInt32();
839 #endif
840 #ifdef USE_PRINTER
841         config.printer_device_type = state_fio->FgetInt32();
842 #endif
843         config.keyboard_type = state_fio->FgetInt32();
844         return true;
845 }
846