2 Skelton for retropc emulator
4 Author : Takeda.Toshiya
13 #include "csp_logger.h"
15 # if defined(Q_OS_WIN)
19 extern CSP_Logger *csp_logger;
27 #if defined(_USE_AGAR)
28 #include "agar_main.h"
34 #define CONFIG_NAME "conf"
37 BOOL MyWritePrivateProfileInt(LPCTSTR lpAppName, LPCTSTR lpKeyName, int Value, LPCTSTR lpFileName)
39 return MyWritePrivateProfileString(lpAppName, lpKeyName, create_string(_T("%d"), Value), lpFileName);
42 BOOL MyWritePrivateProfileBool(LPCTSTR lpAppName, LPCTSTR lpKeyName, bool Value, LPCTSTR lpFileName)
44 return MyWritePrivateProfileString(lpAppName, lpKeyName, create_string(_T("%d"), Value ? 1 : 0), lpFileName);
47 bool MyGetPrivateProfileBool(LPCTSTR lpAppName, LPCTSTR lpKeyName, bool bDefault, LPCTSTR lpFileName)
49 return (MyGetPrivateProfileInt(lpAppName, lpKeyName, bDefault ? 1 : 0, lpFileName) != 0);
52 void initialize_config()
55 memset(&config, 0, sizeof(config_t));
56 config.window_mode = 1;
57 // memo: set only non zero value
58 config.full_speed = false;
61 #if defined(USE_BOOT_MODE) && defined(BOOT_MODE_DEFAULT)
62 config.boot_mode = BOOT_MODE_DEFAULT;
64 #if defined(USE_CPU_TYPE) && defined(CPU_TYPE_DEFAULT)
65 config.cpu_type = CPU_TYPE_DEFAULT;
67 #if defined(USE_DIPSWITCH) && defined(DIPSWITCH_DEFAULT)
68 config.dipswitch = DIPSWITCH_DEFAULT;
70 #if defined(USE_DEVICE_TYPE) && defined(DEVICE_TYPE_DEFAULT)
71 config.device_type = DEVICE_TYPE_DEFAULT;
73 #if defined(USE_DRIVE_TYPE) && defined(DRIVE_TYPE_DEFAULT)
74 config.drive_type = DRIVE_TYPE_DEFAULT;
76 #if defined(USE_KEYBOARD_TYPE) && defined(KEYBOARD_TYPE_DEFAULT)
77 config.keyboard_type = KEYBOARD_TYPE_DEFAULT;
79 #if defined(USE_MOUSE_TYPE) && defined(MOUSE_TYPE_DEFAULT)
80 config.mouse_type = MOUSE_TYPE_DEFAULT;
82 #if defined(USE_JOYSTICK_TYPE) && defined(JOYSTICK_TYPE_DEFAULT)
83 config.joystick_type = JOYSTICK_TYPE_DEFAULT;
85 #if defined(USE_SOUND_TYPE) && defined(SOUND_TYPE_DEFAULT)
86 config.sound_type = SOUND_TYPE_DEFAULT;
88 #if defined(USE_MONITOR_TYPE) && defined(MONITOR_TYPE_DEFAULT)
89 config.monitor_type = MONITOR_TYPE_DEFAULT;
91 #if defined(USE_PRINTER_TYPE) && defined(PRINTER_TYPE_DEFAULT)
92 config.printer_type = PRINTER_TYPE_DEFAULT;
94 #if defined(USE_FLOPPY_DISK)
95 for(int drv = 0; drv < USE_FLOPPY_DISK; drv++) {
96 #if defined(CORRECT_DISK_TIMING_DEFAULT)
97 config.correct_disk_timing[drv] = CORRECT_DISK_TIMING_DEFAULT;
99 config.correct_disk_timing[drv] = false;
101 #if defined(IGNORE_DISK_CRC_DEFAULT)
102 config.ignore_disk_crc[drv] = IGNORE_DISK_CRC_DEFAULT;
104 config.ignore_disk_crc[drv] = false;
108 #if defined(USE_TAPE)
109 for(int drv = 0; drv < USE_TAPE; drv++) {
110 config.wave_shaper[drv] = true;
111 config.direct_load_mzt[drv] = true;
112 config.baud_high[drv] = true;
115 config.compress_state = true;
118 #ifndef ONE_BOARD_MICRO_COMPUTER
119 config.fullscreen_stretch_type = 1; // Stretch (Aspect)
123 #ifdef SOUND_RATE_DEFAULT
124 config.sound_frequency = SOUND_RATE_DEFAULT;
126 config.sound_frequency = 6; // 48KHz
128 config.sound_latency = 1; // 100msec
129 config.sound_strict_rendering = true;
130 #ifdef USE_FLOPPY_DISK
131 config.sound_noise_fdd = true;
134 config.sound_noise_cmt = true;
135 config.sound_play_tape = true;
139 for(int i = 0; i < 4; i++) {
140 for(int j = 0; j < 16; j++) {
141 config.joy_buttons[i][j] = (i << 4) | j;
146 config.special_debug_fdc = false;
147 config.print_statistics = false;
150 #if defined(_WIN32) && !defined(_USE_QT)
151 #ifndef ONE_BOARD_MICRO_COMPUTER
152 config.use_d3d9 = true;
154 config.use_dinput = true;
155 config.show_status_bar = true;
160 config.use_separate_thread_draw = true;
161 config.use_osd_virtual_media = true;
162 config.render_platform = CONFIG_RENDER_PLATFORM_OPENGL_ES;
163 config.render_major_version = 2; // For crash with some devices.
164 config.render_minor_version = 0;
165 config.rendering_type = CONFIG_RENDER_TYPE_STD;
167 config.use_opengl_scanline = false;
168 config.opengl_scanline_vert = false;
169 config.opengl_scanline_horiz = false;
170 config.use_opengl_filters = false;
171 config.opengl_filter_num = 0;
172 config.focus_with_click = false;
174 config.video_width = 640;
175 config.video_height = 480;
176 config.video_codec_type = 0; // MPEG4
178 config.video_h264_bitrate = 512;
179 config.video_h264_bframes = 4;
180 config.video_h264_b_adapt = 2;
181 config.video_h264_minq = 14;
182 config.video_h264_maxq = 25;
183 config.video_h264_subme = 8;
185 config.video_mpeg4_bitrate = 512;
186 config.video_mpeg4_bframes = 4;
187 config.video_mpeg4_minq = 1;
188 config.video_mpeg4_maxq = 20;
190 config.audio_codec_type = 0;
191 config.video_threads = 0;
192 config.audio_bitrate = 160;
193 config.video_frame_rate = 30;
194 config.log_to_syslog = false;
195 config.log_to_console = true;
196 for(int ii = 0; ii < (CSP_LOG_TYPE_VM_DEVICE_END - CSP_LOG_TYPE_VM_DEVICE_0 + 1) ; ii++) {
197 for(int jj = 0; jj < 8; jj++) {
198 config.dev_log_to_syslog[ii][jj] = true;
199 config.dev_log_to_console[ii][jj] = true;
200 config.dev_log_recording[ii][jj] = true;
203 config.state_log_to_console = false;
204 config.state_log_to_syslog = false;
205 config.state_log_to_recording = false;
207 config.rendering_type = CONFIG_RENDER_TYPE_STD;
208 config.virtual_media_position = 2; // Down.
209 for(int drv = 0; drv < 16; drv++) {
210 config.disk_count_immediate[drv] = false;
213 config.cursor_as_ten_key = CONFIG_CURSOR_AS_CURSOR;
214 #if defined(_FM7) || defined(_FMNEW7) || defined(_FM8) \
215 || defined(_FM77_VARIANTS) || defined(_FM77AV_VARIANTS)
216 config.numpad_enter_as_fullkey = false;
218 config.numpad_enter_as_fullkey = true;
220 config.host_keyboard_type = CONFIG_HOST_KEYBOARD_AT_109JP;
224 void load_config(const _TCHAR *config_path)
232 config.boot_mode = MyGetPrivateProfileInt(_T("Control"), _T("BootMode"), config.boot_mode, config_path);
235 config.cpu_type = MyGetPrivateProfileInt(_T("Control"), _T("CPUType"), config.cpu_type, config_path);
238 config.dipswitch = MyGetPrivateProfileInt(_T("Control"), _T("DipSwitch"), config.dipswitch, config_path);
240 #ifdef USE_DEVICE_TYPE
241 config.device_type = MyGetPrivateProfileInt(_T("Control"), _T("DeviceType"), config.device_type, config_path);
243 #ifdef USE_DRIVE_TYPE
244 config.drive_type = MyGetPrivateProfileInt(_T("Control"), _T("DriveType"), config.drive_type, config_path);
246 #ifdef USE_KEYBOARD_TYPE
247 config.keyboard_type = MyGetPrivateProfileInt(_T("Control"), _T("KeyboardType"), config.keyboard_type, config_path);
249 #ifdef USE_MOUSE_TYPE
250 config.mouse_type = MyGetPrivateProfileInt(_T("Control"), _T("MouseType"), config.mouse_type, config_path);
252 #ifdef USE_JOYSTICK_TYPE
253 config.joystick_type = MyGetPrivateProfileInt(_T("Control"), _T("JoystickType"), config.joystick_type, config_path);
255 #ifdef USE_SOUND_TYPE
256 config.sound_type = MyGetPrivateProfileInt(_T("Control"), _T("SoundType"), config.sound_type, config_path);
258 #ifdef USE_MONITOR_TYPE
259 config.monitor_type = MyGetPrivateProfileInt(_T("Control"), _T("MonitorType"), config.monitor_type, config_path);
262 config.scan_line = MyGetPrivateProfileBool(_T("Control"), _T("ScanLine"), config.scan_line, config_path);
265 config.printer_type = MyGetPrivateProfileInt(_T("Control"), _T("PrinterType"), config.printer_type, config_path);
267 #ifdef USE_FLOPPY_DISK
268 for(int drv = 0; drv < USE_FLOPPY_DISK; drv++) {
269 config.correct_disk_timing[drv] = MyGetPrivateProfileBool(_T("Control"), create_string(_T("CorrectDiskTiming%d"), drv + 1), config.correct_disk_timing[drv], config_path);
270 config.ignore_disk_crc[drv] = MyGetPrivateProfileBool(_T("Control"), create_string(_T("IgnoreDiskCRC%d"), drv + 1), config.ignore_disk_crc[drv], config_path);
272 config.disk_count_immediate[drv] = MyGetPrivateProfileBool(_T("Control"), create_string(_T("DiskIncrementImmediate%d"), drv + 1), config.disk_count_immediate[drv], config_path);
277 for(int drv = 0; drv < USE_TAPE; drv++) {
278 config.wave_shaper[drv] = MyGetPrivateProfileBool(_T("Control"), create_string(_T("WaveShaper%d"), drv + 1), config.wave_shaper[drv], config_path);
279 config.direct_load_mzt[drv] = MyGetPrivateProfileBool(_T("Control"), create_string(_T("DirectLoadMZT%d"), drv + 1), config.direct_load_mzt[drv], config_path);
280 config.baud_high[drv] = MyGetPrivateProfileBool(_T("Control"), create_string(_T("BaudHigh%d"), drv + 1), config.baud_high[drv], config_path);
283 config.compress_state = MyGetPrivateProfileBool(_T("Control"), _T("CompressState"), config.compress_state, config_path);
286 MyGetPrivateProfileString(_T("RecentFiles"), _T("InitialCartDir"), _T(""), config.initial_cart_dir, _MAX_PATH, config_path);
287 for(int drv = 0; drv < USE_CART; drv++) {
288 for(int i = 0; i < MAX_HISTORY; i++) {
289 MyGetPrivateProfileString(_T("RecentFiles"), create_string(_T("RecentCartPath%d_%d"), drv + 1, i + 1), _T(""), config.recent_cart_path[drv][i], _MAX_PATH, config_path);
293 #ifdef USE_FLOPPY_DISK
294 MyGetPrivateProfileString(_T("RecentFiles"), _T("InitialDiskDir"), _T(""), config.initial_floppy_disk_dir, _MAX_PATH, config_path);
295 for(int drv = 0; drv < USE_FLOPPY_DISK; drv++) {
296 for(int i = 0; i < MAX_HISTORY; i++) {
297 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);
301 #ifdef USE_QUICK_DISK
302 MyGetPrivateProfileString(_T("RecentFiles"), _T("InitialQuickDiskDir"), _T(""), config.initial_quick_disk_dir, _MAX_PATH, config_path);
303 for(int drv = 0; drv < USE_QUICK_DISK; drv++) {
304 for(int i = 0; i < MAX_HISTORY; i++) {
305 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);
310 MyGetPrivateProfileString(_T("RecentFiles"), _T("InitialHardDiskDir"), _T(""), config.initial_hard_disk_dir, _MAX_PATH, config_path);
311 for(int drv = 0; drv < USE_HARD_DISK; drv++) {
312 for(int i = 0; i < MAX_HISTORY; i++) {
313 MyGetPrivateProfileString(_T("RecentFiles"), create_string(_T("RecentHardDiskPath%d_%d"), drv + 1, i + 1), _T(""), config.recent_hard_disk_path[drv][i], _MAX_PATH, config_path);
315 MyGetPrivateProfileString(_T("RecentFiles"), create_string(_T("LastHardDiskPath%d"), drv + 1), _T(""), config.last_hard_disk_path[drv], _MAX_PATH, config_path);
319 MyGetPrivateProfileString(_T("RecentFiles"), _T("InitialTapeDir"), _T(""), config.initial_tape_dir, _MAX_PATH, config_path);
320 for(int drv = 0; drv < USE_TAPE; drv++) {
321 for(int i = 0; i < MAX_HISTORY; i++) {
322 MyGetPrivateProfileString(_T("RecentFiles"), create_string(_T("RecentTapePath%d_%d"), drv + 1, i + 1), _T(""), config.recent_tape_path[drv][i], _MAX_PATH, config_path);
326 #ifdef USE_COMPACT_DISC
327 MyGetPrivateProfileString(_T("RecentFiles"), _T("InitialCompactDiscDir"), _T(""), config.initial_compact_disc_dir, _MAX_PATH, config_path);
328 for(int drv = 0; drv < USE_COMPACT_DISC; drv++) {
329 for(int i = 0; i < MAX_HISTORY; i++) {
330 MyGetPrivateProfileString(_T("RecentFiles"), create_string(_T("RecentCompactDiscPath%d_%d"), drv + 1, i + 1), _T(""), config.recent_compact_disc_path[drv][i], _MAX_PATH, config_path);
334 #ifdef USE_LASER_DISC
335 MyGetPrivateProfileString(_T("RecentFiles"), _T("InitialLaserDiscDir"), _T(""), config.initial_laser_disc_dir, _MAX_PATH, config_path);
336 for(int drv = 0; drv < USE_LASER_DISC; drv++) {
337 for(int i = 0; i < MAX_HISTORY; i++) {
338 MyGetPrivateProfileString(_T("RecentFiles"), create_string(_T("RecentLaserDiscPath%d_%d"), drv + 1, i + 1), _T(""), config.recent_laser_disc_path[drv][i], _MAX_PATH, config_path);
342 #ifdef USE_BINARY_FILE
343 MyGetPrivateProfileString(_T("RecentFiles"), _T("InitialBinaryDir"), _T(""), config.initial_binary_dir, _MAX_PATH, config_path);
344 for(int drv = 0; drv < USE_BINARY_FILE; drv++) {
345 for(int i = 0; i < MAX_HISTORY; i++) {
346 MyGetPrivateProfileString(_T("RecentFiles"), create_string(_T("RecentBinaryPath%d_%d"), drv + 1, i + 1), _T(""), config.recent_binary_path[drv][i], _MAX_PATH, config_path);
351 MyGetPrivateProfileString(_T("RecentFiles"), _T("InitialBubbleDir"), _T(""), config.initial_bubble_casette_dir, _MAX_PATH, config_path);
352 for(int drv = 0; drv < USE_BUBBLE; drv++) {
353 for(int i = 0; i < MAX_HISTORY; i++) {
354 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);
360 #ifndef ONE_BOARD_MICRO_COMPUTER
361 config.window_mode = MyGetPrivateProfileInt(_T("Screen"), _T("WindowMode"), config.window_mode, config_path);
362 config.window_stretch_type = MyGetPrivateProfileInt(_T("Screen"), _T("WindowStretchType"), config.window_stretch_type, config_path);
363 config.fullscreen_stretch_type = MyGetPrivateProfileInt(_T("Screen"), _T("FullScreenStretchType"), config.fullscreen_stretch_type, config_path);
364 // #ifdef USE_SCREEN_ROTATE
365 config.rotate_type = MyGetPrivateProfileInt(_T("Screen"), _T("RotateType"), config.rotate_type, config_path);
371 #ifdef USE_SCREEN_FILTER
372 config.filter_type = MyGetPrivateProfileInt(_T("Screen"), _T("FilterType"), config.filter_type, config_path);
376 config.sound_frequency = MyGetPrivateProfileInt(_T("Sound"), _T("Frequency"), config.sound_frequency, config_path);
377 config.sound_latency = MyGetPrivateProfileInt(_T("Sound"), _T("Latency"), config.sound_latency, config_path);
378 config.sound_strict_rendering = MyGetPrivateProfileBool(_T("Sound"), _T("StrictRendering"), config.sound_strict_rendering, config_path);
379 #ifdef USE_FLOPPY_DISK
380 config.sound_noise_fdd = MyGetPrivateProfileBool(_T("Sound"), _T("NoiseFDD"), config.sound_noise_fdd, config_path);;
383 config.sound_noise_cmt = MyGetPrivateProfileBool(_T("Sound"), _T("NoiseCMT"), config.sound_noise_cmt, config_path);;
384 config.sound_play_tape = MyGetPrivateProfileBool(_T("Sound"), _T("PlayTape"), config.sound_play_tape, config_path);
386 #ifdef USE_SOUND_VOLUME
387 for(int i = 0; i < USE_SOUND_VOLUME; i++) {
388 int tmp_l = MyGetPrivateProfileInt(_T("Sound"), create_string(_T("VolumeLeft%d"), i + 1), config.sound_volume_l[i], config_path);
389 int tmp_r = MyGetPrivateProfileInt(_T("Sound"), create_string(_T("VolumeRight%d"), i + 1), config.sound_volume_r[i], config_path);
391 // Note: when using balance , levels are -40±20db to 0±20db.
392 config.sound_volume_l[i] = max(-60, min(20, tmp_l));
393 config.sound_volume_r[i] = max(-60, min(20, tmp_r));
395 config.sound_volume_l[i] = max(-40, min(0, tmp_l));
396 config.sound_volume_r[i] = max(-40, min(0, tmp_r));
400 #if defined(_WIN32) && !defined(_USE_QT)
401 MyGetPrivateProfileString(_T("Sound"), _T("FMGenDll"), _T("mamefm.dll"), config.fmgen_dll_path, _MAX_PATH, config_path);
406 for(int i = 0; i < 4; i++) {
407 for(int j = 0; j < 16; j++) {
408 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);
413 #ifdef USE_FLOPPY_DISK
414 config.special_debug_fdc = MyGetPrivateProfileInt(_T("Debug"), _T("SpecialDebugFDC"), config.special_debug_fdc, config_path);
416 config.print_statistics = MyGetPrivateProfileBool(_T("Debug"), _T("PrintCPUStatistics"), config.print_statistics, config_path);
419 MyGetPrivateProfileString(_T("Printer"), _T("PrinterDll"), _T("printer.dll"), config.printer_dll_path, _MAX_PATH, config_path);
423 #if defined(_WIN32) && !defined(_USE_QT)
424 #ifndef ONE_BOARD_MICRO_COMPUTER
425 config.use_d3d9 = MyGetPrivateProfileBool(_T("Win32"), _T("UseDirect3D9"), config.use_d3d9, config_path);
426 config.wait_vsync = MyGetPrivateProfileBool(_T("Win32"), _T("WaitVSync"), config.wait_vsync, config_path);
428 config.use_dinput = MyGetPrivateProfileBool(_T("Win32"), _T("UseDirectInput"), config.use_dinput, config_path);
429 config.disable_dwm = MyGetPrivateProfileBool(_T("Win32"), _T("DisableDwm"), config.disable_dwm, config_path);
430 config.show_status_bar = MyGetPrivateProfileBool(_T("Win32"), _T("ShowStatusBar"), config.show_status_bar, config_path);
435 config.use_separate_thread_draw = MyGetPrivateProfileBool(_T("Qt"), _T("UseSeparateThreadDraw"), config.use_separate_thread_draw, config_path);
436 config.use_osd_virtual_media = MyGetPrivateProfileBool(_T("Qt"), _T("UseOSDVirtualMedia"), config.use_osd_virtual_media, config_path);
437 config.use_opengl_scanline = MyGetPrivateProfileBool(_T("Qt"), _T("UseOpenGLScanLine"), config.use_opengl_scanline, config_path);
438 config.opengl_scanline_vert = MyGetPrivateProfileBool(_T("Qt"), _T("OpenGLScanLineVert"), config.opengl_scanline_vert, config_path);;
439 config.opengl_scanline_horiz = MyGetPrivateProfileBool(_T("Qt"), _T("OpenGLScanLineHoriz"), config.opengl_scanline_horiz, config_path);;
440 config.use_opengl_filters = MyGetPrivateProfileBool(_T("Qt"), _T("UseOpenGLFilters"), config.use_opengl_filters, config_path);
441 config.opengl_filter_num = MyGetPrivateProfileInt(_T("Qt"), _T("OpenGLFilterNum"), config.opengl_filter_num, config_path);
442 config.render_platform = MyGetPrivateProfileInt(_T("Qt"), _T("RenderPlatform"), config.render_platform, config_path);
443 config.render_major_version = MyGetPrivateProfileInt(_T("Qt"), _T("RenderMajorVersion"), config.render_major_version, config_path);
444 config.render_minor_version = MyGetPrivateProfileInt(_T("Qt"), _T("RenderMinorVersion"), config.render_minor_version, config_path);
445 config.rendering_type = MyGetPrivateProfileInt(_T("Qt"), _T("RenderType"), config.rendering_type, config_path);
447 config.general_sound_level = MyGetPrivateProfileInt(_T("Qt"), _T("GeneralSoundLevel"), config.general_sound_level, config_path);
448 config.focus_with_click = MyGetPrivateProfileBool(_T("Qt"), _T("FocusWithClick"), config.focus_with_click, config_path);
450 if(config.rendering_type < 0) config.rendering_type = 0;
451 if(config.rendering_type >= CONFIG_RENDER_TYPE_END) config.rendering_type = CONFIG_RENDER_TYPE_END - 1;
452 // Assigning joysticks.
453 for(i = 0; i < 16; i++) {
455 my_stprintf_s(name, 256, _T("AssignedJoystick"), i + 1);
456 MyGetPrivateProfileString(_T("Qt"), (const _TCHAR *)name, _T(""),
457 config.assigned_joystick_name[i], 256, config_path);
461 config.swap_kanji_pause = MyGetPrivateProfileBool(_T("Qt"), _T("SwapKanjiPause"), config.swap_kanji_pause, config_path);
462 config.cursor_as_ten_key = MyGetPrivateProfileInt(_T("Qt"), _T("CursorAsTenKey"), config.cursor_as_ten_key, config_path);
463 config.numpad_enter_as_fullkey = MyGetPrivateProfileBool(_T("Qt"), _T("NumpadEnterAsFullKey"), config.numpad_enter_as_fullkey, config_path);
464 config.host_keyboard_type = MyGetPrivateProfileInt(_T("Qt"), _T("HostKeyboardType"), config.host_keyboard_type, config_path);
468 config.video_width = MyGetPrivateProfileInt(_T("Qt"), _T("VideoWidth"), config.video_width, config_path);
469 if(config.video_width < 128) config.video_width = 128;
470 config.video_height = MyGetPrivateProfileInt(_T("Qt"), _T("VideoHeight"), config.video_height, config_path);
471 if(config.video_height < 80) config.video_height = 80;
473 config.video_codec_type = MyGetPrivateProfileInt(_T("Qt"), _T("VideoCodecType"), config.video_codec_type, config_path);
474 if(config.video_codec_type > 1) config.video_codec_type = 1;
475 if(config.video_codec_type < 0) config.video_codec_type = 0;
477 config.audio_codec_type = MyGetPrivateProfileInt(_T("Qt"), _T("AudioCodecType"), config.audio_codec_type, config_path);
478 if(config.video_codec_type > 2) config.audio_codec_type = 2;
479 if(config.video_codec_type < 0) config.audio_codec_type = 0;
481 config.video_h264_bitrate = MyGetPrivateProfileInt(_T("Qt"), _T("H264Bitrate"), config.video_h264_bitrate, config_path);
482 if(config.video_h264_bitrate < 64) config.video_h264_bitrate = 64;
484 config.video_h264_bframes = MyGetPrivateProfileInt(_T("Qt"), _T("H264BFrames"), config.video_h264_bframes, config_path);
485 if(config.video_h264_bframes < 0) config.video_h264_bframes = 0;
486 if(config.video_h264_bframes > 10) config.video_h264_bframes = 10;
488 config.video_h264_b_adapt = MyGetPrivateProfileInt(_T("Qt"), _T("H264BAdapt"), config.video_h264_b_adapt, config_path);
489 if(config.video_h264_b_adapt < 0) config.video_h264_b_adapt = 0;
490 if(config.video_h264_b_adapt > 2) config.video_h264_b_adapt = 2;
492 config.video_h264_subme = MyGetPrivateProfileInt(_T("Qt"), _T("H264Subme"), config.video_h264_subme, config_path);
493 if(config.video_h264_subme < 0) config.video_h264_subme = 0;
494 if(config.video_h264_subme > 11) config.video_h264_subme = 11;
496 config.video_h264_minq = MyGetPrivateProfileInt(_T("Qt"), _T("H264MinQ"), config.video_h264_minq, config_path);
497 if(config.video_h264_minq < 0) config.video_h264_minq = 0;
498 if(config.video_h264_minq > 63) config.video_h264_minq = 63;
500 config.video_h264_maxq = MyGetPrivateProfileInt(_T("Qt"), _T("H264MaxQ"), config.video_h264_maxq, config_path);
501 if(config.video_h264_maxq < 0) config.video_h264_maxq = 0;
502 if(config.video_h264_maxq > 63) config.video_h264_maxq = 63;
504 config.video_mpeg4_bitrate = MyGetPrivateProfileInt(_T("Qt"), _T("MPEG4Bitrate"), config.video_mpeg4_bitrate, config_path);
505 if(config.video_mpeg4_bitrate < 64) config.video_mpeg4_bitrate = 64;
507 config.video_mpeg4_bframes = MyGetPrivateProfileInt(_T("Qt"), _T("MPEG4BFrames"), config.video_mpeg4_bframes, config_path);
508 if(config.video_mpeg4_bframes < 0) config.video_mpeg4_bframes = 0;
509 if(config.video_mpeg4_bframes > 10) config.video_mpeg4_bframes = 10;
511 config.video_mpeg4_minq = MyGetPrivateProfileInt(_T("Qt"), _T("MPEG4MinQ"), config.video_mpeg4_minq, config_path);
512 if(config.video_mpeg4_minq < 1) config.video_mpeg4_minq = 1;
513 if(config.video_mpeg4_minq > 31) config.video_mpeg4_minq = 31;
515 config.video_mpeg4_maxq = MyGetPrivateProfileInt(_T("Qt"), _T("MPEG4MaxQ"), config.video_mpeg4_maxq, config_path);
516 if(config.video_mpeg4_maxq < 1) config.video_mpeg4_maxq = 1;
517 if(config.video_mpeg4_maxq > 31) config.video_mpeg4_maxq = 31;
518 if(config.video_mpeg4_maxq < config.video_mpeg4_minq) {
520 n = config.video_mpeg4_maxq;
521 config.video_mpeg4_maxq = config.video_mpeg4_minq;
522 config.video_mpeg4_minq = n;
525 config.video_threads = MyGetPrivateProfileInt(_T("Qt"), _T("VideoThreads"), config.video_threads, config_path);
526 if(config.video_threads < 0) config.video_threads = 0;
527 if(config.video_threads > 16) config.video_threads = 16;
529 config.audio_bitrate = MyGetPrivateProfileInt(_T("Qt"), _T("AudioBitrate"), config.audio_bitrate, config_path);
530 if(config.audio_bitrate < 16) config.audio_bitrate = 16;
531 if(config.audio_bitrate > 448) config.audio_bitrate = 448;
533 config.video_frame_rate = MyGetPrivateProfileInt(_T("Qt"), _T("VideoFramerate"), config.video_frame_rate, config_path);
534 if(config.video_frame_rate < 15) config.video_frame_rate = 15;
535 if(config.video_frame_rate > 75) config.video_frame_rate = 75;
537 config.log_to_syslog = MyGetPrivateProfileBool(_T("Qt"), _T("WriteToSyslog"), config.log_to_syslog, config_path);
538 config.log_to_console = MyGetPrivateProfileBool(_T("Qt"), _T("WriteToConsole"), config.log_to_console, config_path);
540 for(int ii = 0; ii < (CSP_LOG_TYPE_VM_DEVICE_END - CSP_LOG_TYPE_VM_DEVICE_0 + 1) ; ii++) {
542 flags = MyGetPrivateProfileInt(_T("Qt"), create_string(_T("SyslogEnabled%d"), ii), 0xffff, config_path);
543 for(int jj = 0; jj < 8; jj++) {
544 config.dev_log_to_syslog[ii][jj] = ((flags & 0x0001) != 0) ? true : false;
548 flags = MyGetPrivateProfileInt(_T("Qt"), create_string(_T("ConsoleLogEnabled%d"), ii), 0xffff, config_path);
549 for(int jj = 0; jj < 8; jj++) {
550 config.dev_log_to_console[ii][jj] = ((flags & 0x0001) != 0) ? true : false;
553 flags = MyGetPrivateProfileInt(_T("Qt"), create_string(_T("RecordLogEnabled%d"), ii), 0xffff, config_path);
554 for(int jj = 0; jj < 8; jj++) {
555 config.dev_log_recording[ii][jj] = ((flags & 0x0001) != 0) ? true : false;
559 config.state_log_to_console = MyGetPrivateProfileBool(_T("Qt"), _T("StateLogToConsole"), config.state_log_to_console, config_path);;
560 config.state_log_to_syslog = MyGetPrivateProfileBool(_T("Qt"), _T("StateLogToSyslog"), config.state_log_to_syslog, config_path);;
561 config.state_log_to_recording = MyGetPrivateProfileBool(_T("Qt"), _T("StateLogToRecording"), config.state_log_to_recording, config_path);;
563 config.virtual_media_position = MyGetPrivateProfileInt(_T("Qt"), _T("UiVirtualMediaPosition"), config.virtual_media_position, config_path);
564 //csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "Read config done.");
568 void save_config(const _TCHAR *config_path)
571 #if !defined(_MSC_VER)
573 FILEIO *pt = new FILEIO;
574 if(pt->Fopen(config_path, FILEIO_WRITE_ASCII) != true) {
585 MyWritePrivateProfileInt(_T("Control"), _T("BootMode"), config.boot_mode, config_path);
588 MyWritePrivateProfileInt(_T("Control"), _T("CPUType"), config.cpu_type, config_path);
591 MyWritePrivateProfileInt(_T("Control"), _T("DipSwitch"), config.dipswitch, config_path);
593 #ifdef USE_DEVICE_TYPE
594 MyWritePrivateProfileInt(_T("Control"), _T("DeviceType"), config.device_type, config_path);
596 #ifdef USE_DRIVE_TYPE
597 MyWritePrivateProfileInt(_T("Control"), _T("DriveType"), config.drive_type, config_path);
599 #ifdef USE_KEYBOARD_TYPE
600 MyWritePrivateProfileInt(_T("Control"), _T("KeyboardType"), config.keyboard_type, config_path);
602 #ifdef USE_MOUSE_TYPE
603 MyWritePrivateProfileInt(_T("Control"), _T("MouseType"), config.mouse_type, config_path);
605 #ifdef USE_JOYSTICK_TYPE
606 MyWritePrivateProfileInt(_T("Control"), _T("JoystickType"), config.joystick_type, config_path);
608 #ifdef USE_SOUND_TYPE
609 MyWritePrivateProfileInt(_T("Control"), _T("SoundType"), config.sound_type, config_path);
611 #ifdef USE_MONITOR_TYPE
612 MyWritePrivateProfileInt(_T("Control"), _T("MonitorType"), config.monitor_type, config_path);
615 MyWritePrivateProfileBool(_T("Control"), _T("ScanLine"), config.scan_line, config_path);
618 MyWritePrivateProfileInt(_T("Control"), _T("PrinterType"), config.printer_type, config_path);
620 #ifdef USE_FLOPPY_DISK
621 for(int drv = 0; drv < USE_FLOPPY_DISK; drv++) {
622 MyWritePrivateProfileBool(_T("Control"), create_string(_T("CorrectDiskTiming%d"), drv + 1), config.correct_disk_timing[drv], config_path);
623 MyWritePrivateProfileBool(_T("Control"), create_string(_T("IgnoreDiskCRC%d"), drv + 1), config.ignore_disk_crc[drv], config_path);
625 MyWritePrivateProfileBool(_T("Control"), create_string(_T("DiskIncrementImmediate%d"), drv + 1), config.disk_count_immediate[drv], config_path);
630 for(int drv = 0; drv < USE_TAPE; drv++) {
631 MyWritePrivateProfileBool(_T("Control"), create_string(_T("WaveShaper%d"), drv + 1), config.wave_shaper[drv], config_path);
632 MyWritePrivateProfileBool(_T("Control"), create_string(_T("DirectLoadMZT%d"), drv + 1), config.direct_load_mzt[drv], config_path);
633 MyWritePrivateProfileBool(_T("Control"), create_string(_T("BaudHigh%d"), drv + 1), config.baud_high[drv], config_path);
636 MyWritePrivateProfileBool(_T("Control"), _T("CompressState"), config.compress_state, config_path);
642 MyWritePrivateProfileString(_T("RecentFiles"), _T("InitialCartDir"), config.initial_cart_dir, config_path);
643 for(int drv = 0; drv < USE_CART; drv++) {
644 for(int i = 0; i < MAX_HISTORY; i++) {
645 MyWritePrivateProfileString(_T("RecentFiles"), create_string(_T("RecentCartPath%d_%d"), drv + 1, i + 1), config.recent_cart_path[drv][i], config_path);
649 #ifdef USE_FLOPPY_DISK
650 MyWritePrivateProfileString(_T("RecentFiles"), _T("InitialDiskDir"), config.initial_floppy_disk_dir, config_path);
651 for(int drv = 0; drv < USE_FLOPPY_DISK; drv++) {
652 for(int i = 0; i < MAX_HISTORY; i++) {
653 MyWritePrivateProfileString(_T("RecentFiles"), create_string(_T("RecentDiskPath%d_%d"), drv + 1, i + 1), config.recent_floppy_disk_path[drv][i], config_path);
657 #ifdef USE_QUICK_DISK
658 MyWritePrivateProfileString(_T("RecentFiles"), _T("InitialQuickDiskDir"), config.initial_quick_disk_dir, config_path);
659 for(int drv = 0; drv < USE_QUICK_DISK; drv++) {
660 for(int i = 0; i < MAX_HISTORY; i++) {
661 MyWritePrivateProfileString(_T("RecentFiles"), create_string(_T("RecentQuickDiskPath%d_%d"), drv + 1, i + 1), config.recent_quick_disk_path[drv][i], config_path);
666 MyWritePrivateProfileString(_T("RecentFiles"), _T("InitialHardDiskDir"), config.initial_hard_disk_dir, config_path);
667 for(int drv = 0; drv < USE_HARD_DISK; drv++) {
668 for(int i = 0; i < MAX_HISTORY; i++) {
669 MyWritePrivateProfileString(_T("RecentFiles"), create_string(_T("RecentHardDiskPath%d_%d"), drv + 1, i + 1), config.recent_hard_disk_path[drv][i], config_path);
671 MyWritePrivateProfileString(_T("RecentFiles"), create_string(_T("LastHardDiskPath%d"), drv + 1), config.last_hard_disk_path[drv], config_path);
675 MyWritePrivateProfileString(_T("RecentFiles"), _T("InitialTapeDir"), config.initial_tape_dir, config_path);
676 for(int drv = 0; drv < USE_TAPE; drv++) {
677 for(int i = 0; i < MAX_HISTORY; i++) {
678 MyWritePrivateProfileString(_T("RecentFiles"), create_string(_T("RecentTapePath%d_%d"), drv + 1, i + 1), config.recent_tape_path[drv][i], config_path);
682 #ifdef USE_COMPACT_DISC
683 MyWritePrivateProfileString(_T("RecentFiles"), _T("InitialCompactDiscDir"), config.initial_compact_disc_dir, config_path);
684 for(int drv = 0; drv < USE_COMPACT_DISC; drv++) {
685 for(int i = 0; i < MAX_HISTORY; i++) {
686 MyWritePrivateProfileString(_T("RecentFiles"), create_string(_T("RecentCompactDiscPath%d_%d"), drv + 1, i + 1), config.recent_compact_disc_path[drv][i], config_path);
690 #ifdef USE_LASER_DISC
691 MyWritePrivateProfileString(_T("RecentFiles"), _T("InitialLaserDiscDir"), config.initial_laser_disc_dir, config_path);
692 for(int drv = 0; drv < USE_LASER_DISC; drv++) {
693 for(int i = 0; i < MAX_HISTORY; i++) {
694 MyWritePrivateProfileString(_T("RecentFiles"), create_string(_T("RecentLaserDiscPath%d_%d"), drv + 1, i + 1), config.recent_laser_disc_path[drv][i], config_path);
698 #ifdef USE_BINARY_FILE
699 MyWritePrivateProfileString(_T("RecentFiles"), _T("InitialBinaryDir"), config.initial_binary_dir, config_path);
700 for(int drv = 0; drv < USE_BINARY_FILE; drv++) {
701 for(int i = 0; i < MAX_HISTORY; i++) {
702 MyWritePrivateProfileString(_T("RecentFiles"), create_string(_T("RecentBinaryPath%d_%d"), drv + 1, i + 1), config.recent_binary_path[drv][i], config_path);
707 MyWritePrivateProfileString(_T("RecentFiles"), _T("InitialBubbleDir"), config.initial_bubble_casette_dir, config_path);
708 for(int drv = 0; drv < USE_BUBBLE; drv++) {
709 for(int i = 0; i < MAX_HISTORY; i++) {
710 MyWritePrivateProfileString(_T("RecentFiles"), create_string(_T("RecentBubblePath%d_%d"), drv + 1, i + 1), config.recent_bubble_casette_path[drv][i], config_path);
716 #ifndef ONE_BOARD_MICRO_COMPUTER
717 MyWritePrivateProfileInt(_T("Screen"), _T("WindowMode"), config.window_mode, config_path);
718 MyWritePrivateProfileInt(_T("Screen"), _T("WindowStretchType"), config.window_stretch_type, config_path);
719 MyWritePrivateProfileInt(_T("Screen"), _T("FullScreenStretchType"), config.fullscreen_stretch_type, config_path);
720 // #ifdef USE_SCREEN_ROTATE
721 MyWritePrivateProfileInt(_T("Screen"), _T("RotateType"), config.rotate_type, config_path);
726 #ifdef USE_SCREEN_FILTER
727 MyWritePrivateProfileInt(_T("Screen"), _T("FilterType"), config.filter_type, config_path);
731 MyWritePrivateProfileInt(_T("Sound"), _T("Frequency"), config.sound_frequency, config_path);
732 MyWritePrivateProfileInt(_T("Sound"), _T("Latency"), config.sound_latency, config_path);
733 MyWritePrivateProfileBool(_T("Sound"), _T("StrictRendering"), config.sound_strict_rendering, config_path);
734 #ifdef USE_FLOPPY_DISK
735 MyWritePrivateProfileBool(_T("Sound"), _T("NoiseFDD"), config.sound_noise_fdd, config_path);
738 MyWritePrivateProfileBool(_T("Sound"), _T("NoiseCMT"), config.sound_noise_cmt, config_path);
739 MyWritePrivateProfileBool(_T("Sound"), _T("PlayTape"), config.sound_play_tape, config_path);
741 #ifdef USE_SOUND_VOLUME
742 for(int i = 0; i < USE_SOUND_VOLUME; i++) {
743 MyWritePrivateProfileInt(_T("Sound"), create_string(_T("VolumeLeft%d"), i + 1), config.sound_volume_l[i], config_path);
744 MyWritePrivateProfileInt(_T("Sound"), create_string(_T("VolumeRight%d"), i + 1), config.sound_volume_r[i], config_path);
747 #if defined(_WIN32) && !defined(_USE_QT)
748 MyWritePrivateProfileString(_T("Sound"), _T("FMGenDll"), config.fmgen_dll_path, config_path);
753 for(int i = 0; i < 4; i++) {
754 for(int j = 0; j < 16; j++) {
755 MyWritePrivateProfileInt(_T("Input"), create_string(_T("JoyButtons%d_%d"), i + 1, j + 1), config.joy_buttons[i][j], config_path);
761 #ifdef USE_FLOPPY_DISK
762 MyWritePrivateProfileInt(_T("Debug"), _T("SpecialDebugFDC"), config.special_debug_fdc, config_path);
764 MyWritePrivateProfileBool(_T("Debug"), _T("PrintCPUStatistics"), config.print_statistics, config_path);
767 MyWritePrivateProfileString(_T("Printer"), _T("PrinterDll"), config.printer_dll_path, config_path);
772 #if defined(_WIN32) && !defined(_USE_QT)
773 #ifndef ONE_BOARD_MICRO_COMPUTER
774 MyWritePrivateProfileBool(_T("Win32"), _T("UseDirect3D9"), config.use_d3d9, config_path);
775 MyWritePrivateProfileBool(_T("Win32"), _T("WaitVSync"), config.wait_vsync, config_path);
777 MyWritePrivateProfileBool(_T("Win32"), _T("UseDirectInput"), config.use_dinput, config_path);
778 MyWritePrivateProfileBool(_T("Win32"), _T("DisableDwm"), config.disable_dwm, config_path);
779 MyWritePrivateProfileBool(_T("Win32"), _T("ShowStatusBar"), config.show_status_bar, config_path);
782 MyWritePrivateProfileBool(_T("Qt"), _T("UseSeparateThreadDraw"), config.use_separate_thread_draw, config_path);
783 MyWritePrivateProfileBool(_T("Qt"), _T("UseOSDVirtualMedia"), config.use_osd_virtual_media, config_path);
784 MyWritePrivateProfileBool(_T("Qt"), _T("UseOpenGLScanLine"), config.use_opengl_scanline, config_path);
785 MyWritePrivateProfileBool(_T("Qt"), _T("OpenGLScanLineVert"), config.opengl_scanline_vert, config_path);;
786 MyWritePrivateProfileBool(_T("Qt"), _T("OpenGLScanLineHoriz"), config.opengl_scanline_horiz, config_path);;
787 MyWritePrivateProfileBool(_T("Qt"), _T("UseOpenGLFilters"), config.use_opengl_filters, config_path);
788 MyWritePrivateProfileInt(_T("Qt"), _T("OpenGLFilterNum"), config.opengl_filter_num, config_path);
789 MyWritePrivateProfileInt(_T("Qt"), _T("RenderType"), config.rendering_type, config_path);
790 MyWritePrivateProfileInt(_T("Qt"), _T("RenderPlatform"), config.render_platform, config_path);
791 MyWritePrivateProfileInt(_T("Qt"), _T("RenderMajorVersion"), config.render_major_version, config_path);
792 MyWritePrivateProfileInt(_T("Qt"), _T("RenderMinorVersion"), config.render_minor_version, config_path);
794 MyWritePrivateProfileInt(_T("Qt"), _T("GeneralSoundLevel"), config.general_sound_level, config_path);
795 MyWritePrivateProfileBool(_T("Qt"), _T("FocusWithClick"), config.focus_with_click, config_path);
798 MyWritePrivateProfileBool(_T("Qt"), _T("SwapKanjiPause"), config.swap_kanji_pause, config_path);
799 MyWritePrivateProfileInt(_T("Qt"), _T("CursorAsTenKey"), config.cursor_as_ten_key, config_path);
800 MyWritePrivateProfileBool(_T("Qt"), _T("NumpadEnterAsFullKey"), config.numpad_enter_as_fullkey, config_path);
801 MyWritePrivateProfileInt(_T("Qt"), _T("HostKeyboardType"), config.host_keyboard_type, config_path);
803 for(i = 0; i < 16; i++) {
805 my_stprintf_s(name, 256, _T("AssignedJoystick%d"), i + 1);
806 MyWritePrivateProfileString(_T("Qt"), (const _TCHAR *)name,
807 config.assigned_joystick_name[i], config_path);
809 MyWritePrivateProfileInt(_T("Qt"), _T("VideoWidth"), config.video_width, config_path);
810 MyWritePrivateProfileInt(_T("Qt"), _T("VideoHeight"), config.video_height, config_path);
811 MyWritePrivateProfileInt(_T("Qt"), _T("VideoCodecType"), config.video_codec_type, config_path);
812 MyWritePrivateProfileInt(_T("Qt"), _T("AudioCodecType"), config.audio_codec_type, config_path);
814 MyWritePrivateProfileInt(_T("Qt"), _T("H264Bitrate"), config.video_h264_bitrate, config_path);
815 MyWritePrivateProfileInt(_T("Qt"), _T("H264BFrames"), config.video_h264_bframes, config_path);
816 MyWritePrivateProfileInt(_T("Qt"), _T("H264BAdapt"), config.video_h264_b_adapt, config_path);
817 MyWritePrivateProfileInt(_T("Qt"), _T("H264MinQ"), config.video_h264_minq, config_path);
818 MyWritePrivateProfileInt(_T("Qt"), _T("H264MaxQ"), config.video_h264_maxq, config_path);
819 MyWritePrivateProfileInt(_T("Qt"), _T("H264Subme"), config.video_h264_subme, config_path);
821 MyWritePrivateProfileInt(_T("Qt"), _T("MPEG4Bitrate"), config.video_mpeg4_bitrate, config_path);
822 MyWritePrivateProfileInt(_T("Qt"), _T("MPEG4BFrames"), config.video_mpeg4_bframes, config_path);
823 MyWritePrivateProfileInt(_T("Qt"), _T("MPEG4MinQ"), config.video_mpeg4_minq, config_path);
824 MyWritePrivateProfileInt(_T("Qt"), _T("MPEG4MaxQ"), config.video_mpeg4_maxq, config_path);
826 MyWritePrivateProfileInt(_T("Qt"), _T("VideoThreads"), config.video_threads, config_path);
827 MyWritePrivateProfileInt(_T("Qt"), _T("AudioBitrate"), config.audio_bitrate, config_path);
828 MyWritePrivateProfileInt(_T("Qt"), _T("VideoFramerate"), config.video_frame_rate, config_path);
830 MyWritePrivateProfileBool(_T("Qt"), _T("WriteToSyslog"), config.log_to_syslog, config_path);
831 MyWritePrivateProfileBool(_T("Qt"), _T("WriteToConsole"), config.log_to_console, config_path);
833 for(int ii = 0; ii < (CSP_LOG_TYPE_VM_DEVICE_END - CSP_LOG_TYPE_VM_DEVICE_0 + 1) ; ii++) {
836 for(int jj = 0; jj < 8; jj++) {
838 if(config.dev_log_to_syslog[ii][jj]) flags |= 0x0001;
840 MyWritePrivateProfileInt(_T("Qt"), create_string(_T("SyslogEnabled%d"), ii), flags, config_path);
843 for(int jj = 0; jj < 8; jj++) {
845 if(config.dev_log_to_console[ii][jj]) flags |= 0x0001;
847 MyWritePrivateProfileInt(_T("Qt"), create_string(_T("ConsoleLogEnabled%d"), ii), flags, config_path);
850 for(int jj = 0; jj < 8; jj++) {
852 if(config.dev_log_recording[ii][jj]) flags |= 0x0001;
854 MyWritePrivateProfileInt(_T("Qt"), create_string(_T("RecordLogEnabled%d"), ii), flags, config_path);
856 MyWritePrivateProfileBool(_T("Qt"), _T("StateLogToConsole"), config.state_log_to_console, config_path);
857 MyWritePrivateProfileBool(_T("Qt"), _T("StateLogToSyslog"), config.state_log_to_syslog, config_path);
858 MyWritePrivateProfileBool(_T("Qt"), _T("StateLogToRecording"), config.state_log_to_recording, config_path);
860 MyWritePrivateProfileInt(_T("Qt"), _T("UiVirtualMediaPosition"), config.virtual_media_position, config_path);
861 //csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "Write config done.");
865 #define STATE_VERSION 6
867 void save_config_state(void *f)
869 FILEIO *state_fio = (FILEIO *)f;
871 state_fio->FputUint32(STATE_VERSION);
874 state_fio->FputInt32(config.boot_mode);
877 state_fio->FputInt32(config.cpu_type);
880 state_fio->FputUint32(config.dipswitch);
882 #ifdef USE_DEVICE_TYPE
883 state_fio->FputInt32(config.device_type);
885 #ifdef USE_DRIVE_TYPE
886 state_fio->FputInt32(config.drive_type);
888 #ifdef USE_KEYBOARD_TYPE
889 state_fio->FputInt32(config.keyboard_type);
891 #ifdef USE_MOUSE_TYPE
892 state_fio->FputInt32(config.mouse_type);
894 #ifdef USE_JOYSTICK_TYPE
895 state_fio->FputInt32(config.joystick_type);
897 #ifdef USE_SOUND_TYPE
898 state_fio->FputInt32(config.sound_type);
900 #ifdef USE_MONITOR_TYPE
901 state_fio->FputInt32(config.monitor_type);
903 #ifdef USE_PRINTER_TYPE
904 state_fio->FputInt32(config.printer_type);
906 #ifdef USE_FLOPPY_DISK
907 for(int drv = 0; drv < USE_FLOPPY_DISK; drv++) {
908 state_fio->FputBool(config.correct_disk_timing[drv]);
909 state_fio->FputBool(config.ignore_disk_crc[drv]);
912 state_fio->FputInt32(config.sound_frequency);
913 state_fio->FputInt32(config.sound_latency);
916 bool load_config_state(void *f)
918 FILEIO *state_fio = (FILEIO *)f;
920 if(state_fio->FgetUint32() != STATE_VERSION) {
924 config.boot_mode = state_fio->FgetInt32();
927 config.cpu_type = state_fio->FgetInt32();
930 config.dipswitch = state_fio->FgetUint32();
932 #ifdef USE_DEVICE_TYPE
933 config.device_type = state_fio->FgetInt32();
935 #ifdef USE_DRIVE_TYPE
936 config.drive_type = state_fio->FgetInt32();
938 #ifdef USE_KEYBOARD_TYPE
939 config.keyboard_type = state_fio->FgetInt32();
941 #ifdef USE_MOUSE_TYPE
942 config.mouse_type = state_fio->FgetInt32();
944 #ifdef USE_JOYSTICK_TYPE
945 config.joystick_type = state_fio->FgetInt32();
947 #ifdef USE_SOUND_TYPE
948 config.sound_type = state_fio->FgetInt32();
950 #ifdef USE_MONITOR_TYPE
951 config.monitor_type = state_fio->FgetInt32();
953 #ifdef USE_PRINTER_TYPE
954 config.printer_type = state_fio->FgetInt32();
956 #ifdef USE_FLOPPY_DISK
957 for(int drv = 0; drv < USE_FLOPPY_DISK; drv++) {
958 config.correct_disk_timing[drv] = state_fio->FgetBool();
959 config.ignore_disk_crc[drv] = state_fio->FgetBool();
962 config.sound_frequency = state_fio->FgetInt32();
963 config.sound_latency = state_fio->FgetInt32();