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);
318 MyGetPrivateProfileString(_T("RecentFiles"), _T("InitialTapeDir"), _T(""), config.initial_tape_dir, _MAX_PATH, config_path);
319 for(int drv = 0; drv < USE_TAPE; drv++) {
320 for(int i = 0; i < MAX_HISTORY; i++) {
321 MyGetPrivateProfileString(_T("RecentFiles"), create_string(_T("RecentTapePath%d_%d"), drv + 1, i + 1), _T(""), config.recent_tape_path[drv][i], _MAX_PATH, config_path);
325 #ifdef USE_COMPACT_DISC
326 MyGetPrivateProfileString(_T("RecentFiles"), _T("InitialCompactDiscDir"), _T(""), config.initial_compact_disc_dir, _MAX_PATH, config_path);
327 for(int drv = 0; drv < USE_COMPACT_DISC; drv++) {
328 for(int i = 0; i < MAX_HISTORY; i++) {
329 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);
333 #ifdef USE_LASER_DISC
334 MyGetPrivateProfileString(_T("RecentFiles"), _T("InitialLaserDiscDir"), _T(""), config.initial_laser_disc_dir, _MAX_PATH, config_path);
335 for(int drv = 0; drv < USE_LASER_DISC; drv++) {
336 for(int i = 0; i < MAX_HISTORY; i++) {
337 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);
341 #ifdef USE_BINARY_FILE
342 MyGetPrivateProfileString(_T("RecentFiles"), _T("InitialBinaryDir"), _T(""), config.initial_binary_dir, _MAX_PATH, config_path);
343 for(int drv = 0; drv < USE_BINARY_FILE; drv++) {
344 for(int i = 0; i < MAX_HISTORY; i++) {
345 MyGetPrivateProfileString(_T("RecentFiles"), create_string(_T("RecentBinaryPath%d_%d"), drv + 1, i + 1), _T(""), config.recent_binary_path[drv][i], _MAX_PATH, config_path);
350 MyGetPrivateProfileString(_T("RecentFiles"), _T("InitialBubbleDir"), _T(""), config.initial_bubble_casette_dir, _MAX_PATH, config_path);
351 for(int drv = 0; drv < USE_BUBBLE; drv++) {
352 for(int i = 0; i < MAX_HISTORY; i++) {
353 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);
359 #ifndef ONE_BOARD_MICRO_COMPUTER
360 config.window_mode = MyGetPrivateProfileInt(_T("Screen"), _T("WindowMode"), config.window_mode, config_path);
361 config.window_stretch_type = MyGetPrivateProfileInt(_T("Screen"), _T("WindowStretchType"), config.window_stretch_type, config_path);
362 config.fullscreen_stretch_type = MyGetPrivateProfileInt(_T("Screen"), _T("FullScreenStretchType"), config.fullscreen_stretch_type, config_path);
363 // #ifdef USE_SCREEN_ROTATE
364 config.rotate_type = MyGetPrivateProfileInt(_T("Screen"), _T("RotateType"), config.rotate_type, config_path);
370 #ifdef USE_SCREEN_FILTER
371 config.filter_type = MyGetPrivateProfileInt(_T("Screen"), _T("FilterType"), config.filter_type, config_path);
375 config.sound_frequency = MyGetPrivateProfileInt(_T("Sound"), _T("Frequency"), config.sound_frequency, config_path);
376 config.sound_latency = MyGetPrivateProfileInt(_T("Sound"), _T("Latency"), config.sound_latency, config_path);
377 config.sound_strict_rendering = MyGetPrivateProfileBool(_T("Sound"), _T("StrictRendering"), config.sound_strict_rendering, config_path);
378 #ifdef USE_FLOPPY_DISK
379 config.sound_noise_fdd = MyGetPrivateProfileBool(_T("Sound"), _T("NoiseFDD"), config.sound_noise_fdd, config_path);;
382 config.sound_noise_cmt = MyGetPrivateProfileBool(_T("Sound"), _T("NoiseCMT"), config.sound_noise_cmt, config_path);;
383 config.sound_play_tape = MyGetPrivateProfileBool(_T("Sound"), _T("PlayTape"), config.sound_play_tape, config_path);
385 #ifdef USE_SOUND_VOLUME
386 for(int i = 0; i < USE_SOUND_VOLUME; i++) {
387 int tmp_l = MyGetPrivateProfileInt(_T("Sound"), create_string(_T("VolumeLeft%d"), i + 1), config.sound_volume_l[i], config_path);
388 int tmp_r = MyGetPrivateProfileInt(_T("Sound"), create_string(_T("VolumeRight%d"), i + 1), config.sound_volume_r[i], config_path);
390 // Note: when using balance , levels are -40±20db to 0±20db.
391 config.sound_volume_l[i] = max(-60, min(20, tmp_l));
392 config.sound_volume_r[i] = max(-60, min(20, tmp_r));
394 config.sound_volume_l[i] = max(-40, min(0, tmp_l));
395 config.sound_volume_r[i] = max(-40, min(0, tmp_r));
399 #if defined(_WIN32) && !defined(_USE_QT)
400 MyGetPrivateProfileString(_T("Sound"), _T("FMGenDll"), _T("mamefm.dll"), config.fmgen_dll_path, _MAX_PATH, config_path);
405 for(int i = 0; i < 4; i++) {
406 for(int j = 0; j < 16; j++) {
407 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);
412 #ifdef USE_FLOPPY_DISK
413 config.special_debug_fdc = MyGetPrivateProfileInt(_T("Debug"), _T("SpecialDebugFDC"), config.special_debug_fdc, config_path);
415 config.print_statistics = MyGetPrivateProfileBool(_T("Debug"), _T("PrintCPUStatistics"), config.print_statistics, config_path);
418 MyGetPrivateProfileString(_T("Printer"), _T("PrinterDll"), _T("printer.dll"), config.printer_dll_path, _MAX_PATH, config_path);
422 #if defined(_WIN32) && !defined(_USE_QT)
423 #ifndef ONE_BOARD_MICRO_COMPUTER
424 config.use_d3d9 = MyGetPrivateProfileBool(_T("Win32"), _T("UseDirect3D9"), config.use_d3d9, config_path);
425 config.wait_vsync = MyGetPrivateProfileBool(_T("Win32"), _T("WaitVSync"), config.wait_vsync, config_path);
427 config.use_dinput = MyGetPrivateProfileBool(_T("Win32"), _T("UseDirectInput"), config.use_dinput, config_path);
428 config.disable_dwm = MyGetPrivateProfileBool(_T("Win32"), _T("DisableDwm"), config.disable_dwm, config_path);
429 config.show_status_bar = MyGetPrivateProfileBool(_T("Win32"), _T("ShowStatusBar"), config.show_status_bar, config_path);
434 config.use_separate_thread_draw = MyGetPrivateProfileBool(_T("Qt"), _T("UseSeparateThreadDraw"), config.use_separate_thread_draw, config_path);
435 config.use_osd_virtual_media = MyGetPrivateProfileBool(_T("Qt"), _T("UseOSDVirtualMedia"), config.use_osd_virtual_media, config_path);
436 config.use_opengl_scanline = MyGetPrivateProfileBool(_T("Qt"), _T("UseOpenGLScanLine"), config.use_opengl_scanline, config_path);
437 config.opengl_scanline_vert = MyGetPrivateProfileBool(_T("Qt"), _T("OpenGLScanLineVert"), config.opengl_scanline_vert, config_path);;
438 config.opengl_scanline_horiz = MyGetPrivateProfileBool(_T("Qt"), _T("OpenGLScanLineHoriz"), config.opengl_scanline_horiz, config_path);;
439 config.use_opengl_filters = MyGetPrivateProfileBool(_T("Qt"), _T("UseOpenGLFilters"), config.use_opengl_filters, config_path);
440 config.opengl_filter_num = MyGetPrivateProfileInt(_T("Qt"), _T("OpenGLFilterNum"), config.opengl_filter_num, config_path);
441 config.render_platform = MyGetPrivateProfileInt(_T("Qt"), _T("RenderPlatform"), config.render_platform, config_path);
442 config.render_major_version = MyGetPrivateProfileInt(_T("Qt"), _T("RenderMajorVersion"), config.render_major_version, config_path);
443 config.render_minor_version = MyGetPrivateProfileInt(_T("Qt"), _T("RenderMinorVersion"), config.render_minor_version, config_path);
444 config.rendering_type = MyGetPrivateProfileInt(_T("Qt"), _T("RenderType"), config.rendering_type, config_path);
446 config.general_sound_level = MyGetPrivateProfileInt(_T("Qt"), _T("GeneralSoundLevel"), config.general_sound_level, config_path);
447 config.focus_with_click = MyGetPrivateProfileBool(_T("Qt"), _T("FocusWithClick"), config.focus_with_click, config_path);
449 if(config.rendering_type < 0) config.rendering_type = 0;
450 if(config.rendering_type >= CONFIG_RENDER_TYPE_END) config.rendering_type = CONFIG_RENDER_TYPE_END - 1;
451 // Assigning joysticks.
452 for(i = 0; i < 16; i++) {
454 my_stprintf_s(name, 256, _T("AssignedJoystick"), i + 1);
455 MyGetPrivateProfileString(_T("Qt"), (const _TCHAR *)name, _T(""),
456 config.assigned_joystick_name[i], 256, config_path);
460 config.swap_kanji_pause = MyGetPrivateProfileBool(_T("Qt"), _T("SwapKanjiPause"), config.swap_kanji_pause, config_path);
461 config.cursor_as_ten_key = MyGetPrivateProfileInt(_T("Qt"), _T("CursorAsTenKey"), config.cursor_as_ten_key, config_path);
462 config.numpad_enter_as_fullkey = MyGetPrivateProfileBool(_T("Qt"), _T("NumpadEnterAsFullKey"), config.numpad_enter_as_fullkey, config_path);
463 config.host_keyboard_type = MyGetPrivateProfileInt(_T("Qt"), _T("HostKeyboardType"), config.host_keyboard_type, config_path);
467 config.video_width = MyGetPrivateProfileInt(_T("Qt"), _T("VideoWidth"), config.video_width, config_path);
468 if(config.video_width < 128) config.video_width = 128;
469 config.video_height = MyGetPrivateProfileInt(_T("Qt"), _T("VideoHeight"), config.video_height, config_path);
470 if(config.video_height < 80) config.video_height = 80;
472 config.video_codec_type = MyGetPrivateProfileInt(_T("Qt"), _T("VideoCodecType"), config.video_codec_type, config_path);
473 if(config.video_codec_type > 1) config.video_codec_type = 1;
474 if(config.video_codec_type < 0) config.video_codec_type = 0;
476 config.audio_codec_type = MyGetPrivateProfileInt(_T("Qt"), _T("AudioCodecType"), config.audio_codec_type, config_path);
477 if(config.video_codec_type > 2) config.audio_codec_type = 2;
478 if(config.video_codec_type < 0) config.audio_codec_type = 0;
480 config.video_h264_bitrate = MyGetPrivateProfileInt(_T("Qt"), _T("H264Bitrate"), config.video_h264_bitrate, config_path);
481 if(config.video_h264_bitrate < 64) config.video_h264_bitrate = 64;
483 config.video_h264_bframes = MyGetPrivateProfileInt(_T("Qt"), _T("H264BFrames"), config.video_h264_bframes, config_path);
484 if(config.video_h264_bframes < 0) config.video_h264_bframes = 0;
485 if(config.video_h264_bframes > 10) config.video_h264_bframes = 10;
487 config.video_h264_b_adapt = MyGetPrivateProfileInt(_T("Qt"), _T("H264BAdapt"), config.video_h264_b_adapt, config_path);
488 if(config.video_h264_b_adapt < 0) config.video_h264_b_adapt = 0;
489 if(config.video_h264_b_adapt > 2) config.video_h264_b_adapt = 2;
491 config.video_h264_subme = MyGetPrivateProfileInt(_T("Qt"), _T("H264Subme"), config.video_h264_subme, config_path);
492 if(config.video_h264_subme < 0) config.video_h264_subme = 0;
493 if(config.video_h264_subme > 11) config.video_h264_subme = 11;
495 config.video_h264_minq = MyGetPrivateProfileInt(_T("Qt"), _T("H264MinQ"), config.video_h264_minq, config_path);
496 if(config.video_h264_minq < 0) config.video_h264_minq = 0;
497 if(config.video_h264_minq > 63) config.video_h264_minq = 63;
499 config.video_h264_maxq = MyGetPrivateProfileInt(_T("Qt"), _T("H264MaxQ"), config.video_h264_maxq, config_path);
500 if(config.video_h264_maxq < 0) config.video_h264_maxq = 0;
501 if(config.video_h264_maxq > 63) config.video_h264_maxq = 63;
503 config.video_mpeg4_bitrate = MyGetPrivateProfileInt(_T("Qt"), _T("MPEG4Bitrate"), config.video_mpeg4_bitrate, config_path);
504 if(config.video_mpeg4_bitrate < 64) config.video_mpeg4_bitrate = 64;
506 config.video_mpeg4_bframes = MyGetPrivateProfileInt(_T("Qt"), _T("MPEG4BFrames"), config.video_mpeg4_bframes, config_path);
507 if(config.video_mpeg4_bframes < 0) config.video_mpeg4_bframes = 0;
508 if(config.video_mpeg4_bframes > 10) config.video_mpeg4_bframes = 10;
510 config.video_mpeg4_minq = MyGetPrivateProfileInt(_T("Qt"), _T("MPEG4MinQ"), config.video_mpeg4_minq, config_path);
511 if(config.video_mpeg4_minq < 1) config.video_mpeg4_minq = 1;
512 if(config.video_mpeg4_minq > 31) config.video_mpeg4_minq = 31;
514 config.video_mpeg4_maxq = MyGetPrivateProfileInt(_T("Qt"), _T("MPEG4MaxQ"), config.video_mpeg4_maxq, config_path);
515 if(config.video_mpeg4_maxq < 1) config.video_mpeg4_maxq = 1;
516 if(config.video_mpeg4_maxq > 31) config.video_mpeg4_maxq = 31;
517 if(config.video_mpeg4_maxq < config.video_mpeg4_minq) {
519 n = config.video_mpeg4_maxq;
520 config.video_mpeg4_maxq = config.video_mpeg4_minq;
521 config.video_mpeg4_minq = n;
524 config.video_threads = MyGetPrivateProfileInt(_T("Qt"), _T("VideoThreads"), config.video_threads, config_path);
525 if(config.video_threads < 0) config.video_threads = 0;
526 if(config.video_threads > 16) config.video_threads = 16;
528 config.audio_bitrate = MyGetPrivateProfileInt(_T("Qt"), _T("AudioBitrate"), config.audio_bitrate, config_path);
529 if(config.audio_bitrate < 16) config.audio_bitrate = 16;
530 if(config.audio_bitrate > 448) config.audio_bitrate = 448;
532 config.video_frame_rate = MyGetPrivateProfileInt(_T("Qt"), _T("VideoFramerate"), config.video_frame_rate, config_path);
533 if(config.video_frame_rate < 15) config.video_frame_rate = 15;
534 if(config.video_frame_rate > 75) config.video_frame_rate = 75;
536 config.log_to_syslog = MyGetPrivateProfileBool(_T("Qt"), _T("WriteToSyslog"), config.log_to_syslog, config_path);
537 config.log_to_console = MyGetPrivateProfileBool(_T("Qt"), _T("WriteToConsole"), config.log_to_console, config_path);
539 for(int ii = 0; ii < (CSP_LOG_TYPE_VM_DEVICE_END - CSP_LOG_TYPE_VM_DEVICE_0 + 1) ; ii++) {
541 flags = MyGetPrivateProfileInt(_T("Qt"), create_string(_T("SyslogEnabled%d"), ii), 0xffff, config_path);
542 for(int jj = 0; jj < 8; jj++) {
543 config.dev_log_to_syslog[ii][jj] = ((flags & 0x0001) != 0) ? true : false;
547 flags = MyGetPrivateProfileInt(_T("Qt"), create_string(_T("ConsoleLogEnabled%d"), ii), 0xffff, config_path);
548 for(int jj = 0; jj < 8; jj++) {
549 config.dev_log_to_console[ii][jj] = ((flags & 0x0001) != 0) ? true : false;
552 flags = MyGetPrivateProfileInt(_T("Qt"), create_string(_T("RecordLogEnabled%d"), ii), 0xffff, config_path);
553 for(int jj = 0; jj < 8; jj++) {
554 config.dev_log_recording[ii][jj] = ((flags & 0x0001) != 0) ? true : false;
558 config.state_log_to_console = MyGetPrivateProfileBool(_T("Qt"), _T("StateLogToConsole"), config.state_log_to_console, config_path);;
559 config.state_log_to_syslog = MyGetPrivateProfileBool(_T("Qt"), _T("StateLogToSyslog"), config.state_log_to_syslog, config_path);;
560 config.state_log_to_recording = MyGetPrivateProfileBool(_T("Qt"), _T("StateLogToRecording"), config.state_log_to_recording, config_path);;
562 config.virtual_media_position = MyGetPrivateProfileInt(_T("Qt"), _T("UiVirtualMediaPosition"), config.virtual_media_position, config_path);
563 //csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "Read config done.");
567 void save_config(const _TCHAR *config_path)
570 #if !defined(_MSC_VER)
572 FILEIO *pt = new FILEIO;
573 if(pt->Fopen(config_path, FILEIO_WRITE_ASCII) != true) {
584 MyWritePrivateProfileInt(_T("Control"), _T("BootMode"), config.boot_mode, config_path);
587 MyWritePrivateProfileInt(_T("Control"), _T("CPUType"), config.cpu_type, config_path);
590 MyWritePrivateProfileInt(_T("Control"), _T("DipSwitch"), config.dipswitch, config_path);
592 #ifdef USE_DEVICE_TYPE
593 MyWritePrivateProfileInt(_T("Control"), _T("DeviceType"), config.device_type, config_path);
595 #ifdef USE_DRIVE_TYPE
596 MyWritePrivateProfileInt(_T("Control"), _T("DriveType"), config.drive_type, config_path);
598 #ifdef USE_KEYBOARD_TYPE
599 MyWritePrivateProfileInt(_T("Control"), _T("KeyboardType"), config.keyboard_type, config_path);
601 #ifdef USE_MOUSE_TYPE
602 MyWritePrivateProfileInt(_T("Control"), _T("MouseType"), config.mouse_type, config_path);
604 #ifdef USE_JOYSTICK_TYPE
605 MyWritePrivateProfileInt(_T("Control"), _T("JoystickType"), config.joystick_type, config_path);
607 #ifdef USE_SOUND_TYPE
608 MyWritePrivateProfileInt(_T("Control"), _T("SoundType"), config.sound_type, config_path);
610 #ifdef USE_MONITOR_TYPE
611 MyWritePrivateProfileInt(_T("Control"), _T("MonitorType"), config.monitor_type, config_path);
614 MyWritePrivateProfileBool(_T("Control"), _T("ScanLine"), config.scan_line, config_path);
617 MyWritePrivateProfileInt(_T("Control"), _T("PrinterType"), config.printer_type, config_path);
619 #ifdef USE_FLOPPY_DISK
620 for(int drv = 0; drv < USE_FLOPPY_DISK; drv++) {
621 MyWritePrivateProfileBool(_T("Control"), create_string(_T("CorrectDiskTiming%d"), drv + 1), config.correct_disk_timing[drv], config_path);
622 MyWritePrivateProfileBool(_T("Control"), create_string(_T("IgnoreDiskCRC%d"), drv + 1), config.ignore_disk_crc[drv], config_path);
624 MyWritePrivateProfileBool(_T("Control"), create_string(_T("DiskIncrementImmediate%d"), drv + 1), config.disk_count_immediate[drv], config_path);
629 for(int drv = 0; drv < USE_TAPE; drv++) {
630 MyWritePrivateProfileBool(_T("Control"), create_string(_T("WaveShaper%d"), drv + 1), config.wave_shaper[drv], config_path);
631 MyWritePrivateProfileBool(_T("Control"), create_string(_T("DirectLoadMZT%d"), drv + 1), config.direct_load_mzt[drv], config_path);
632 MyWritePrivateProfileBool(_T("Control"), create_string(_T("BaudHigh%d"), drv + 1), config.baud_high[drv], config_path);
635 MyWritePrivateProfileBool(_T("Control"), _T("CompressState"), config.compress_state, config_path);
641 MyWritePrivateProfileString(_T("RecentFiles"), _T("InitialCartDir"), config.initial_cart_dir, config_path);
642 for(int drv = 0; drv < USE_CART; drv++) {
643 for(int i = 0; i < MAX_HISTORY; i++) {
644 MyWritePrivateProfileString(_T("RecentFiles"), create_string(_T("RecentCartPath%d_%d"), drv + 1, i + 1), config.recent_cart_path[drv][i], config_path);
648 #ifdef USE_FLOPPY_DISK
649 MyWritePrivateProfileString(_T("RecentFiles"), _T("InitialDiskDir"), config.initial_floppy_disk_dir, config_path);
650 for(int drv = 0; drv < USE_FLOPPY_DISK; drv++) {
651 for(int i = 0; i < MAX_HISTORY; i++) {
652 MyWritePrivateProfileString(_T("RecentFiles"), create_string(_T("RecentDiskPath%d_%d"), drv + 1, i + 1), config.recent_floppy_disk_path[drv][i], config_path);
656 #ifdef USE_QUICK_DISK
657 MyWritePrivateProfileString(_T("RecentFiles"), _T("InitialQuickDiskDir"), config.initial_quick_disk_dir, config_path);
658 for(int drv = 0; drv < USE_QUICK_DISK; drv++) {
659 for(int i = 0; i < MAX_HISTORY; i++) {
660 MyWritePrivateProfileString(_T("RecentFiles"), create_string(_T("RecentQuickDiskPath%d_%d"), drv + 1, i + 1), config.recent_quick_disk_path[drv][i], config_path);
665 MyWritePrivateProfileString(_T("RecentFiles"), _T("InitialHardDiskDir"), config.initial_hard_disk_dir, config_path);
666 for(int drv = 0; drv < USE_HARD_DISK; drv++) {
667 for(int i = 0; i < MAX_HISTORY; i++) {
668 MyWritePrivateProfileString(_T("RecentFiles"), create_string(_T("RecentHardDiskPath%d_%d"), drv + 1, i + 1), config.recent_hard_disk_path[drv][i], config_path);
673 MyWritePrivateProfileString(_T("RecentFiles"), _T("InitialTapeDir"), config.initial_tape_dir, config_path);
674 for(int drv = 0; drv < USE_TAPE; drv++) {
675 for(int i = 0; i < MAX_HISTORY; i++) {
676 MyWritePrivateProfileString(_T("RecentFiles"), create_string(_T("RecentTapePath%d_%d"), drv + 1, i + 1), config.recent_tape_path[drv][i], config_path);
680 #ifdef USE_COMPACT_DISC
681 MyWritePrivateProfileString(_T("RecentFiles"), _T("InitialCompactDiscDir"), config.initial_compact_disc_dir, config_path);
682 for(int drv = 0; drv < USE_COMPACT_DISC; drv++) {
683 for(int i = 0; i < MAX_HISTORY; i++) {
684 MyWritePrivateProfileString(_T("RecentFiles"), create_string(_T("RecentCompactDiscPath%d_%d"), drv + 1, i + 1), config.recent_compact_disc_path[drv][i], config_path);
688 #ifdef USE_LASER_DISC
689 MyWritePrivateProfileString(_T("RecentFiles"), _T("InitialLaserDiscDir"), config.initial_laser_disc_dir, config_path);
690 for(int drv = 0; drv < USE_LASER_DISC; drv++) {
691 for(int i = 0; i < MAX_HISTORY; i++) {
692 MyWritePrivateProfileString(_T("RecentFiles"), create_string(_T("RecentLaserDiscPath%d_%d"), drv + 1, i + 1), config.recent_laser_disc_path[drv][i], config_path);
696 #ifdef USE_BINARY_FILE
697 MyWritePrivateProfileString(_T("RecentFiles"), _T("InitialBinaryDir"), config.initial_binary_dir, config_path);
698 for(int drv = 0; drv < USE_BINARY_FILE; drv++) {
699 for(int i = 0; i < MAX_HISTORY; i++) {
700 MyWritePrivateProfileString(_T("RecentFiles"), create_string(_T("RecentBinaryPath%d_%d"), drv + 1, i + 1), config.recent_binary_path[drv][i], config_path);
705 MyWritePrivateProfileString(_T("RecentFiles"), _T("InitialBubbleDir"), config.initial_bubble_casette_dir, config_path);
706 for(int drv = 0; drv < USE_BUBBLE; drv++) {
707 for(int i = 0; i < MAX_HISTORY; i++) {
708 MyWritePrivateProfileString(_T("RecentFiles"), create_string(_T("RecentBubblePath%d_%d"), drv + 1, i + 1), config.recent_bubble_casette_path[drv][i], config_path);
714 #ifndef ONE_BOARD_MICRO_COMPUTER
715 MyWritePrivateProfileInt(_T("Screen"), _T("WindowMode"), config.window_mode, config_path);
716 MyWritePrivateProfileInt(_T("Screen"), _T("WindowStretchType"), config.window_stretch_type, config_path);
717 MyWritePrivateProfileInt(_T("Screen"), _T("FullScreenStretchType"), config.fullscreen_stretch_type, config_path);
718 // #ifdef USE_SCREEN_ROTATE
719 MyWritePrivateProfileInt(_T("Screen"), _T("RotateType"), config.rotate_type, config_path);
724 #ifdef USE_SCREEN_FILTER
725 MyWritePrivateProfileInt(_T("Screen"), _T("FilterType"), config.filter_type, config_path);
729 MyWritePrivateProfileInt(_T("Sound"), _T("Frequency"), config.sound_frequency, config_path);
730 MyWritePrivateProfileInt(_T("Sound"), _T("Latency"), config.sound_latency, config_path);
731 MyWritePrivateProfileBool(_T("Sound"), _T("StrictRendering"), config.sound_strict_rendering, config_path);
732 #ifdef USE_FLOPPY_DISK
733 MyWritePrivateProfileBool(_T("Sound"), _T("NoiseFDD"), config.sound_noise_fdd, config_path);
736 MyWritePrivateProfileBool(_T("Sound"), _T("NoiseCMT"), config.sound_noise_cmt, config_path);
737 MyWritePrivateProfileBool(_T("Sound"), _T("PlayTape"), config.sound_play_tape, config_path);
739 #ifdef USE_SOUND_VOLUME
740 for(int i = 0; i < USE_SOUND_VOLUME; i++) {
741 MyWritePrivateProfileInt(_T("Sound"), create_string(_T("VolumeLeft%d"), i + 1), config.sound_volume_l[i], config_path);
742 MyWritePrivateProfileInt(_T("Sound"), create_string(_T("VolumeRight%d"), i + 1), config.sound_volume_r[i], config_path);
745 #if defined(_WIN32) && !defined(_USE_QT)
746 MyWritePrivateProfileString(_T("Sound"), _T("FMGenDll"), config.fmgen_dll_path, config_path);
751 for(int i = 0; i < 4; i++) {
752 for(int j = 0; j < 16; j++) {
753 MyWritePrivateProfileInt(_T("Input"), create_string(_T("JoyButtons%d_%d"), i + 1, j + 1), config.joy_buttons[i][j], config_path);
759 #ifdef USE_FLOPPY_DISK
760 MyWritePrivateProfileInt(_T("Debug"), _T("SpecialDebugFDC"), config.special_debug_fdc, config_path);
762 MyWritePrivateProfileBool(_T("Debug"), _T("PrintCPUStatistics"), config.print_statistics, config_path);
765 MyWritePrivateProfileString(_T("Printer"), _T("PrinterDll"), config.printer_dll_path, config_path);
770 #if defined(_WIN32) && !defined(_USE_QT)
771 #ifndef ONE_BOARD_MICRO_COMPUTER
772 MyWritePrivateProfileBool(_T("Win32"), _T("UseDirect3D9"), config.use_d3d9, config_path);
773 MyWritePrivateProfileBool(_T("Win32"), _T("WaitVSync"), config.wait_vsync, config_path);
775 MyWritePrivateProfileBool(_T("Win32"), _T("UseDirectInput"), config.use_dinput, config_path);
776 MyWritePrivateProfileBool(_T("Win32"), _T("DisableDwm"), config.disable_dwm, config_path);
777 MyWritePrivateProfileBool(_T("Win32"), _T("ShowStatusBar"), config.show_status_bar, config_path);
780 MyWritePrivateProfileBool(_T("Qt"), _T("UseSeparateThreadDraw"), config.use_separate_thread_draw, config_path);
781 MyWritePrivateProfileBool(_T("Qt"), _T("UseOSDVirtualMedia"), config.use_osd_virtual_media, config_path);
782 MyWritePrivateProfileBool(_T("Qt"), _T("UseOpenGLScanLine"), config.use_opengl_scanline, config_path);
783 MyWritePrivateProfileBool(_T("Qt"), _T("OpenGLScanLineVert"), config.opengl_scanline_vert, config_path);;
784 MyWritePrivateProfileBool(_T("Qt"), _T("OpenGLScanLineHoriz"), config.opengl_scanline_horiz, config_path);;
785 MyWritePrivateProfileBool(_T("Qt"), _T("UseOpenGLFilters"), config.use_opengl_filters, config_path);
786 MyWritePrivateProfileInt(_T("Qt"), _T("OpenGLFilterNum"), config.opengl_filter_num, config_path);
787 MyWritePrivateProfileInt(_T("Qt"), _T("RenderType"), config.rendering_type, config_path);
788 MyWritePrivateProfileInt(_T("Qt"), _T("RenderPlatform"), config.render_platform, config_path);
789 MyWritePrivateProfileInt(_T("Qt"), _T("RenderMajorVersion"), config.render_major_version, config_path);
790 MyWritePrivateProfileInt(_T("Qt"), _T("RenderMinorVersion"), config.render_minor_version, config_path);
792 MyWritePrivateProfileInt(_T("Qt"), _T("GeneralSoundLevel"), config.general_sound_level, config_path);
793 MyWritePrivateProfileBool(_T("Qt"), _T("FocusWithClick"), config.focus_with_click, config_path);
796 MyWritePrivateProfileBool(_T("Qt"), _T("SwapKanjiPause"), config.swap_kanji_pause, config_path);
797 MyWritePrivateProfileInt(_T("Qt"), _T("CursorAsTenKey"), config.cursor_as_ten_key, config_path);
798 MyWritePrivateProfileBool(_T("Qt"), _T("NumpadEnterAsFullKey"), config.numpad_enter_as_fullkey, config_path);
799 MyWritePrivateProfileInt(_T("Qt"), _T("HostKeyboardType"), config.host_keyboard_type, config_path);
801 for(i = 0; i < 16; i++) {
803 my_stprintf_s(name, 256, _T("AssignedJoystick%d"), i + 1);
804 MyWritePrivateProfileString(_T("Qt"), (const _TCHAR *)name,
805 config.assigned_joystick_name[i], config_path);
807 MyWritePrivateProfileInt(_T("Qt"), _T("VideoWidth"), config.video_width, config_path);
808 MyWritePrivateProfileInt(_T("Qt"), _T("VideoHeight"), config.video_height, config_path);
809 MyWritePrivateProfileInt(_T("Qt"), _T("VideoCodecType"), config.video_codec_type, config_path);
810 MyWritePrivateProfileInt(_T("Qt"), _T("AudioCodecType"), config.audio_codec_type, config_path);
812 MyWritePrivateProfileInt(_T("Qt"), _T("H264Bitrate"), config.video_h264_bitrate, config_path);
813 MyWritePrivateProfileInt(_T("Qt"), _T("H264BFrames"), config.video_h264_bframes, config_path);
814 MyWritePrivateProfileInt(_T("Qt"), _T("H264BAdapt"), config.video_h264_b_adapt, config_path);
815 MyWritePrivateProfileInt(_T("Qt"), _T("H264MinQ"), config.video_h264_minq, config_path);
816 MyWritePrivateProfileInt(_T("Qt"), _T("H264MaxQ"), config.video_h264_maxq, config_path);
817 MyWritePrivateProfileInt(_T("Qt"), _T("H264Subme"), config.video_h264_subme, config_path);
819 MyWritePrivateProfileInt(_T("Qt"), _T("MPEG4Bitrate"), config.video_mpeg4_bitrate, config_path);
820 MyWritePrivateProfileInt(_T("Qt"), _T("MPEG4BFrames"), config.video_mpeg4_bframes, config_path);
821 MyWritePrivateProfileInt(_T("Qt"), _T("MPEG4MinQ"), config.video_mpeg4_minq, config_path);
822 MyWritePrivateProfileInt(_T("Qt"), _T("MPEG4MaxQ"), config.video_mpeg4_maxq, config_path);
824 MyWritePrivateProfileInt(_T("Qt"), _T("VideoThreads"), config.video_threads, config_path);
825 MyWritePrivateProfileInt(_T("Qt"), _T("AudioBitrate"), config.audio_bitrate, config_path);
826 MyWritePrivateProfileInt(_T("Qt"), _T("VideoFramerate"), config.video_frame_rate, config_path);
828 MyWritePrivateProfileBool(_T("Qt"), _T("WriteToSyslog"), config.log_to_syslog, config_path);
829 MyWritePrivateProfileBool(_T("Qt"), _T("WriteToConsole"), config.log_to_console, config_path);
831 for(int ii = 0; ii < (CSP_LOG_TYPE_VM_DEVICE_END - CSP_LOG_TYPE_VM_DEVICE_0 + 1) ; ii++) {
834 for(int jj = 0; jj < 8; jj++) {
836 if(config.dev_log_to_syslog[ii][jj]) flags |= 0x0001;
838 MyWritePrivateProfileInt(_T("Qt"), create_string(_T("SyslogEnabled%d"), ii), flags, config_path);
841 for(int jj = 0; jj < 8; jj++) {
843 if(config.dev_log_to_console[ii][jj]) flags |= 0x0001;
845 MyWritePrivateProfileInt(_T("Qt"), create_string(_T("ConsoleLogEnabled%d"), ii), flags, config_path);
848 for(int jj = 0; jj < 8; jj++) {
850 if(config.dev_log_recording[ii][jj]) flags |= 0x0001;
852 MyWritePrivateProfileInt(_T("Qt"), create_string(_T("RecordLogEnabled%d"), ii), flags, config_path);
854 MyWritePrivateProfileBool(_T("Qt"), _T("StateLogToConsole"), config.state_log_to_console, config_path);
855 MyWritePrivateProfileBool(_T("Qt"), _T("StateLogToSyslog"), config.state_log_to_syslog, config_path);
856 MyWritePrivateProfileBool(_T("Qt"), _T("StateLogToRecording"), config.state_log_to_recording, config_path);
858 MyWritePrivateProfileInt(_T("Qt"), _T("UiVirtualMediaPosition"), config.virtual_media_position, config_path);
859 //csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "Write config done.");
863 #define STATE_VERSION 6
865 void save_config_state(void *f)
867 FILEIO *state_fio = (FILEIO *)f;
869 state_fio->FputUint32(STATE_VERSION);
872 state_fio->FputInt32(config.boot_mode);
875 state_fio->FputInt32(config.cpu_type);
878 state_fio->FputUint32(config.dipswitch);
880 #ifdef USE_DEVICE_TYPE
881 state_fio->FputInt32(config.device_type);
883 #ifdef USE_DRIVE_TYPE
884 state_fio->FputInt32(config.drive_type);
886 #ifdef USE_KEYBOARD_TYPE
887 state_fio->FputInt32(config.keyboard_type);
889 #ifdef USE_MOUSE_TYPE
890 state_fio->FputInt32(config.mouse_type);
892 #ifdef USE_JOYSTICK_TYPE
893 state_fio->FputInt32(config.joystick_type);
895 #ifdef USE_SOUND_TYPE
896 state_fio->FputInt32(config.sound_type);
898 #ifdef USE_MONITOR_TYPE
899 state_fio->FputInt32(config.monitor_type);
901 #ifdef USE_PRINTER_TYPE
902 state_fio->FputInt32(config.printer_type);
904 #ifdef USE_FLOPPY_DISK
905 for(int drv = 0; drv < USE_FLOPPY_DISK; drv++) {
906 state_fio->FputBool(config.correct_disk_timing[drv]);
907 state_fio->FputBool(config.ignore_disk_crc[drv]);
910 state_fio->FputInt32(config.sound_frequency);
911 state_fio->FputInt32(config.sound_latency);
914 bool load_config_state(void *f)
916 FILEIO *state_fio = (FILEIO *)f;
918 if(state_fio->FgetUint32() != STATE_VERSION) {
922 config.boot_mode = state_fio->FgetInt32();
925 config.cpu_type = state_fio->FgetInt32();
928 config.dipswitch = state_fio->FgetUint32();
930 #ifdef USE_DEVICE_TYPE
931 config.device_type = state_fio->FgetInt32();
933 #ifdef USE_DRIVE_TYPE
934 config.drive_type = state_fio->FgetInt32();
936 #ifdef USE_KEYBOARD_TYPE
937 config.keyboard_type = state_fio->FgetInt32();
939 #ifdef USE_MOUSE_TYPE
940 config.mouse_type = state_fio->FgetInt32();
942 #ifdef USE_JOYSTICK_TYPE
943 config.joystick_type = state_fio->FgetInt32();
945 #ifdef USE_SOUND_TYPE
946 config.sound_type = state_fio->FgetInt32();
948 #ifdef USE_MONITOR_TYPE
949 config.monitor_type = state_fio->FgetInt32();
951 #ifdef USE_PRINTER_TYPE
952 config.printer_type = state_fio->FgetInt32();
954 #ifdef USE_FLOPPY_DISK
955 for(int drv = 0; drv < USE_FLOPPY_DISK; drv++) {
956 config.correct_disk_timing[drv] = state_fio->FgetBool();
957 config.ignore_disk_crc[drv] = state_fio->FgetBool();
960 config.sound_frequency = state_fio->FgetInt32();
961 config.sound_latency = state_fio->FgetInt32();