2 Skelton for retropc emulator
4 Author : Takeda.Toshiya
13 #include "csp_logger.h"
15 # if defined(Q_OS_WIN)
25 #if defined(_USE_AGAR)
26 #include "agar_main.h"
32 #define CONFIG_NAME "conf"
35 //extern _TCHAR* get_parent_dir(_TCHAR* file);
36 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()
56 memset(&config, 0, sizeof(config_t));
57 config.window_mode = 1;
59 #if defined(USE_BOOT_MODE) && defined(BOOT_MODE_DEFAULT)
60 config.boot_mode = BOOT_MODE_DEFAULT;
62 #if defined(USE_CPU_TYPE) && defined(CPU_TYPE_DEFAULT)
63 config.cpu_type = CPU_TYPE_DEFAULT;
65 #if defined(USE_DIPSWITCH) && defined(DIPSWITCH_DEFAULT)
66 config.dipswitch = DIPSWITCH_DEFAULT;
68 #if defined(USE_DEVICE_TYPE) && defined(DEVICE_TYPE_DEFAULT)
69 config.device_type = DEVICE_TYPE_DEFAULT;
71 #if defined(USE_DRIVE_TYPE) && defined(DRIVE_TYPE_DEFAULT)
72 config.drive_type = DRIVE_TYPE_DEFAULT;
75 for(int drv = 0; drv < MAX_FD; drv++) {
76 #if defined(CORRECT_DISK_TIMING_DEFAULT)
77 config.correct_disk_timing[drv] = CORRECT_DISK_TIMING_DEFAULT;
79 config.correct_disk_timing[drv] = true;
81 #if defined(IGNORE_DISK_CRC_DEFAULT)
82 config.ignore_disk_crc[drv] = IGNORE_DISK_CRC_DEFAULT;
85 #elif defined(USE_FD1)
86 for(int drv = 0; drv < MAX_FD; drv++) {
87 config.ignore_disk_crc[drv] = false;
91 config.wave_shaper = true;
92 config.direct_load_mzt = true;
93 config.baud_high = true;
97 #if defined(SOUND_RATE_DEFAULT)
98 config.sound_frequency = SOUND_RATE_DEFAULT;
100 config.sound_frequency = 6; // 48KHz
102 config.sound_latency = 1; // 100msec
103 config.general_sound_level = 0;
104 #if defined(USE_SOUND_DEVICE_TYPE) && defined(SOUND_DEVICE_TYPE_DEFAULT)
105 config.sound_device_type = SOUND_DEVICE_TYPE_DEFAULT;
106 #elif defined(USE_SOUND_DEVICE_TYPE)
107 config.sound_device_type = 0;
112 config.use_direct_input = true;
113 config.disable_dwm = false;
115 config.keyboard_type = 0;
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;
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;
130 config.video_width = 640;
131 config.video_height = 480;
132 config.video_codec_type = 0; // MPEG4
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;
141 config.video_mpeg4_bitrate = 512;
142 config.video_mpeg4_bframes = 4;
143 config.video_mpeg4_minq = 1;
144 config.video_mpeg4_maxq = 20;
146 config.audio_codec_type = 0;
147 config.video_threads = 0;
148 config.audio_bitrate = 160;
149 config.video_frame_rate = 30;
152 #ifndef ONE_BOARD_MICRO_COMPUTER
154 config.use_d3d9 = true;
156 config.fullscreen_stretch_type = 1; // Stretch (Aspect)
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;
166 config.log_to_syslog = false;
167 config.log_to_console = true;
171 void load_config(const _TCHAR *config_path)
179 config.boot_mode = MyGetPrivateProfileInt(_T("Control"), _T("BootMode"), config.boot_mode, config_path);
182 config.cpu_type = MyGetPrivateProfileInt(_T("Control"), _T("CPUType"), config.cpu_type, config_path);
185 config.dipswitch = MyGetPrivateProfileInt(_T("Control"), _T("DipSwitch"), config.dipswitch, config_path);
187 #ifdef USE_DEVICE_TYPE
188 config.device_type = MyGetPrivateProfileInt(_T("Control"), _T("DeviceType"), config.device_type, config_path);
190 #ifdef USE_DRIVE_TYPE
191 config.drive_type = MyGetPrivateProfileInt(_T("Control"), _T("DriveType"), config.drive_type, config_path);
195 for(drv = 0; drv < MAX_FD; drv++) {
196 config.correct_disk_timing[drv] = MyGetPrivateProfileBool(_T("Control"), create_string(_T("CorrectDiskTiming%d"), drv + 1), config.correct_disk_timing[drv], config_path);
197 config.ignore_disk_crc[drv] = MyGetPrivateProfileBool(_T("Control"), create_string(_T("IgnoreDiskCRC%d"), drv + 1), config.ignore_disk_crc[drv], config_path);
203 config.tape_sound = MyGetPrivateProfileBool(_T("Control"), _T("TapeSound"), config.tape_sound, config_path);
204 config.wave_shaper = MyGetPrivateProfileBool(_T("Control"), _T("WaveShaper"), config.wave_shaper, config_path);
205 config.direct_load_mzt = MyGetPrivateProfileBool(_T("Control"), _T("DirectLoadMZT"), config.direct_load_mzt, config_path);
206 config.baud_high = MyGetPrivateProfileBool(_T("Control"), _T("BaudHigh"), config.baud_high, config_path);
211 MyGetPrivateProfileString(_T("RecentFiles"), _T("InitialCartDir"), _T(""), config.initial_cart_dir, _MAX_PATH, config_path);
212 for(drv = 0; drv < MAX_CART; drv++) {
213 for(i = 0; i < MAX_HISTORY; i++) {
214 MyGetPrivateProfileString(_T("RecentFiles"), create_string(_T("RecentCartPath%d_%d"), drv + 1, i + 1), _T(""), config.recent_cart_path[drv][i], _MAX_PATH, config_path);
219 MyGetPrivateProfileString(_T("RecentFiles"), _T("InitialDiskDir"), _T(""), config.initial_floppy_disk_dir, _MAX_PATH, config_path);
220 // get_parent_dir(config.initial_disk_dir);
221 for(drv = 0; drv < MAX_FD; drv++) {
222 for(i = 0; i < MAX_HISTORY; i++) {
223 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);
228 MyGetPrivateProfileString(_T("RecentFiles"), _T("InitialQuickDiskDir"), _T(""), config.initial_quick_disk_dir, _MAX_PATH, config_path);
229 for(drv = 0; drv < MAX_QD; drv++) {
230 for(i = 0; i < MAX_HISTORY; i++) {
231 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);
237 MyGetPrivateProfileString(_T("RecentFiles"), _T("InitialTapeDir"), _T(""),
238 config.initial_tape_dir, _MAX_PATH, config_path);
239 for(i = 0; i < MAX_HISTORY; i++) {
240 MyGetPrivateProfileString(_T("RecentFiles"), create_string(_T("RecentTapePath1_%d"), i + 1), _T(""), config.recent_tape_path[i], _MAX_PATH, config_path);
244 #ifdef USE_LASER_DISC
245 MyGetPrivateProfileString(_T("RecentFiles"), _T("InitialLaserDiscDir"), _T(""),
246 config.initial_laser_disc_dir, _MAX_PATH, config_path);
247 for(int i = 0; i < MAX_HISTORY; i++) {
248 MyGetPrivateProfileString(_T("RecentFiles"), create_string(_T("RecentLaserDiscPath1_%d"), i + 1), _T(""), config.recent_laser_disc_path[i], _MAX_PATH, config_path);
251 #ifdef USE_BINARY_FILE1
252 MyGetPrivateProfileString(_T("RecentFiles"), _T("InitialBinaryDir"), _T(""),
253 config.initial_binary_dir, _MAX_PATH, config_path);
254 for(drv = 0; drv < MAX_BINARY; drv++) {
255 for(i = 0; i < MAX_HISTORY; i++) {
257 my_stprintf_s(name, 64, _T("RecentBinaryPath%d_%d"), drv + 1, i + 1);
258 MyGetPrivateProfileString(_T("RecentFiles"), (const _TCHAR *)name, _T(""),
259 config.recent_binary_path[drv][i], _MAX_PATH, config_path);
263 #if defined(USE_BUBBLE1)
264 MyGetPrivateProfileString(_T("RecentFiles"), _T("InitialBubbleDir"), _T(""),
265 config.initial_bubble_casette_dir, _MAX_PATH, config_path);
266 for(drv = 0; drv < MAX_BUBBLE; drv++) {
267 for(i = 0; i < MAX_HISTORY; i++) {
269 my_stprintf_s(name, 64, _T("RecentBubblePath%d_%d"), drv + 1, i + 1);
270 MyGetPrivateProfileString(_T("RecentFiles"), (const _TCHAR *)name, _T(""),
271 config.recent_bubble_casette_path[drv][i], _MAX_PATH, config_path);
277 #ifndef ONE_BOARD_MICRO_COMPUTER
278 config.window_mode = MyGetPrivateProfileInt(_T("Screen"), _T("WindowMode"), config.window_mode, config_path);
280 config.use_d3d9 = MyGetPrivateProfileBool(_T("Screen"), _T("UseD3D9"), config.use_d3d9, config_path);
281 config.wait_vsync = MyGetPrivateProfileBool(_T("Screen"), _T("WaitVSync"), config.wait_vsync, config_path);
283 //- config.stretch_type = MyGetPrivateProfileInt(_T("Screen"), _T("StretchType"), config.stretch_type, config_path);
284 config.window_stretch_type = MyGetPrivateProfileInt(_T("Screen"), _T("WindowStretchType"), config.window_stretch_type, config_path);
285 config.fullscreen_stretch_type = MyGetPrivateProfileInt(_T("Screen"), _T("FullScreenStretchType"), config.fullscreen_stretch_type, config_path);
288 config.window_mode = MyGetPrivateProfileInt(_T("Screen"), _T("WindowMode"), config.window_mode, config_path);
290 #ifdef USE_MONITOR_TYPE
291 config.monitor_type = MyGetPrivateProfileInt(_T("Screen"), _T("MonitorType"), config.monitor_type, config_path);
293 #ifdef USE_CRT_FILTER
294 config.crt_filter = MyGetPrivateProfileBool(_T("Screen"), _T("CRTFilter"), config.crt_filter, config_path);
297 config.scan_line = MyGetPrivateProfileBool(_T("Screen"), _T("ScanLine"), config.scan_line, config_path);
300 #ifdef USE_SCREEN_ROTATE
301 config.rotate_type = MyGetPrivateProfileInt(_T("Screen"), _T("RotateType"), config.rotate_type, config_path);
304 config.use_opengl_scanline = MyGetPrivateProfileBool(_T("Screen"), _T("UseOpenGLScanLine"),
305 config.use_opengl_scanline, config_path);
306 config.opengl_scanline_vert = MyGetPrivateProfileBool(_T("Screen"), _T("OpenGLScanLineVert"),
307 config.opengl_scanline_vert, config_path);;
308 config.opengl_scanline_horiz = MyGetPrivateProfileBool(_T("Screen"), _T("OpenGLScanLineHoriz"),
309 config.opengl_scanline_horiz, config_path);;
310 config.use_opengl_filters = MyGetPrivateProfileBool(_T("Screen"), _T("UseOpenGLFilters"),
311 config.use_opengl_filters, config_path);
312 config.opengl_filter_num = MyGetPrivateProfileInt(_T("Screen"), _T("OpenGLFilterNum"),
313 config.opengl_filter_num, config_path);
316 config.sound_frequency = MyGetPrivateProfileInt(_T("Sound"), _T("Frequency"), config.sound_frequency, config_path);
317 config.sound_latency = MyGetPrivateProfileInt(_T("Sound"), _T("Latency"), config.sound_latency, config_path);
318 #ifdef USE_SOUND_DEVICE_TYPE
319 config.sound_device_type = MyGetPrivateProfileInt(_T("Sound"), _T("DeviceType"), config.sound_device_type, config_path);
321 #ifdef USE_SOUND_VOLUME
322 for(int i = 0; i < USE_SOUND_VOLUME; i++) {
323 int tmp_l = MyGetPrivateProfileInt(_T("Sound"), create_string(_T("VolumeLeft%d"), i + 1), config.sound_volume_l[i], config_path);
324 int tmp_r = MyGetPrivateProfileInt(_T("Sound"), create_string(_T("VolumeRight%d"), i + 1), config.sound_volume_r[i], config_path);
326 // Note: when using balance , levels are -40±20db to 0±20db.
327 config.sound_volume_l[i] = max(-60, min(20, tmp_l));
328 config.sound_volume_r[i] = max(-60, min(20, tmp_r));
330 config.sound_volume_l[i] = max(-40, min(0, tmp_l));
331 config.sound_volume_r[i] = max(-40, min(0, tmp_r));
335 MyGetPrivateProfileString(_T("Sound"), _T("FMGenDll"), _T("mamefm.dll"), config.fmgen_dll_path, _MAX_PATH, config_path);
336 config.general_sound_level = MyGetPrivateProfileInt(_T("Sound"), _T("GeneralSoundLevel"), config.general_sound_level, config_path);
339 config.use_direct_input = MyGetPrivateProfileBool(_T("Input"), _T("UseDirectInput"), config.use_direct_input, config_path);
340 config.disable_dwm = MyGetPrivateProfileBool(_T("Input"), _T("DisableDwm"), config.disable_dwm, config_path);
342 config.keyboard_type = MyGetPrivateProfileInt(_T("Input"), _T("KeyboardType"), config.keyboard_type, config_path);
344 for(int i = 0; i < 4; i++) {
345 for(int j = 0; j < 16; j++) {
346 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);
351 for(i = 0; i < 16; i++) {
353 my_stprintf_s(name, 256, _T("AssignedJoystick"), i + 1);
354 MyGetPrivateProfileString(_T("Input"), (const _TCHAR *)name, _T(""),
355 config.assigned_joystick_name[i], 256, config_path);
360 config.printer_device_type = MyGetPrivateProfileInt(_T("Printer"), _T("DeviceType"), config.printer_device_type, config_path);
361 MyGetPrivateProfileString(_T("Printer"), _T("PrinterDll"), _T("printer.dll"), config.printer_dll_path, _MAX_PATH, config_path);
364 config.video_width = MyGetPrivateProfileInt(_T("Video"), _T("VideoWidth"), config.video_width, config_path);
365 if(config.video_width < 128) config.video_width = 128;
366 config.video_height = MyGetPrivateProfileInt(_T("Video"), _T("VideoHeight"), config.video_height, config_path);
367 if(config.video_height < 80) config.video_height = 80;
369 config.video_codec_type = MyGetPrivateProfileInt(_T("Video"), _T("VideoCodecType"), config.video_codec_type, config_path);
370 if(config.video_codec_type > 1) config.video_codec_type = 1;
371 if(config.video_codec_type < 0) config.video_codec_type = 0;
373 config.audio_codec_type = MyGetPrivateProfileInt(_T("Video"), _T("AudioCodecType"), config.audio_codec_type, config_path);
374 if(config.video_codec_type > 2) config.audio_codec_type = 2;
375 if(config.video_codec_type < 0) config.audio_codec_type = 0;
377 config.video_h264_bitrate = MyGetPrivateProfileInt(_T("Video"), _T("H264Bitrate"), config.video_h264_bitrate, config_path);
378 if(config.video_h264_bitrate < 64) config.video_h264_bitrate = 64;
380 config.video_h264_bframes = MyGetPrivateProfileInt(_T("Video"), _T("H264BFrames"), config.video_h264_bframes, config_path);
381 if(config.video_h264_bframes < 0) config.video_h264_bframes = 0;
382 if(config.video_h264_bframes > 10) config.video_h264_bframes = 10;
384 config.video_h264_b_adapt = MyGetPrivateProfileInt(_T("Video"), _T("H264BAdapt"), config.video_h264_b_adapt, config_path);
385 if(config.video_h264_b_adapt < 0) config.video_h264_b_adapt = 0;
386 if(config.video_h264_b_adapt > 2) config.video_h264_b_adapt = 2;
388 config.video_h264_subme = MyGetPrivateProfileInt(_T("Video"), _T("H264Subme"), config.video_h264_subme, config_path);
389 if(config.video_h264_subme < 0) config.video_h264_subme = 0;
390 if(config.video_h264_subme > 11) config.video_h264_subme = 11;
392 config.video_h264_minq = MyGetPrivateProfileInt(_T("Video"), _T("H264MinQ"), config.video_h264_minq, config_path);
393 if(config.video_h264_minq < 0) config.video_h264_minq = 0;
394 if(config.video_h264_minq > 63) config.video_h264_minq = 63;
396 config.video_h264_maxq = MyGetPrivateProfileInt(_T("Video"), _T("H264MaxQ"), config.video_h264_maxq, config_path);
397 if(config.video_h264_maxq < 0) config.video_h264_maxq = 0;
398 if(config.video_h264_maxq > 63) config.video_h264_maxq = 63;
400 config.video_mpeg4_bitrate = MyGetPrivateProfileInt(_T("Video"), _T("MPEG4Bitrate"), config.video_mpeg4_bitrate, config_path);
401 if(config.video_mpeg4_bitrate < 64) config.video_mpeg4_bitrate = 64;
403 config.video_mpeg4_bframes = MyGetPrivateProfileInt(_T("Video"), _T("MPEG4BFrames"), config.video_mpeg4_bframes, config_path);
404 if(config.video_mpeg4_bframes < 0) config.video_mpeg4_bframes = 0;
405 if(config.video_mpeg4_bframes > 10) config.video_mpeg4_bframes = 10;
407 config.video_mpeg4_minq = MyGetPrivateProfileInt(_T("Video"), _T("MPEG4MinQ"), config.video_mpeg4_minq, config_path);
408 if(config.video_mpeg4_minq < 1) config.video_mpeg4_minq = 1;
409 if(config.video_mpeg4_minq > 31) config.video_mpeg4_minq = 31;
411 config.video_mpeg4_maxq = MyGetPrivateProfileInt(_T("Video"), _T("MPEG4MaxQ"), config.video_mpeg4_maxq, config_path);
412 if(config.video_mpeg4_maxq < 1) config.video_mpeg4_maxq = 1;
413 if(config.video_mpeg4_maxq > 31) config.video_mpeg4_maxq = 31;
414 if(config.video_mpeg4_maxq < config.video_mpeg4_minq) {
416 n = config.video_mpeg4_maxq;
417 config.video_mpeg4_maxq = config.video_mpeg4_minq;
418 config.video_mpeg4_minq = n;
421 config.video_threads = MyGetPrivateProfileInt(_T("Video"), _T("VideoThreads"), config.video_threads, config_path);
422 if(config.video_threads < 0) config.video_threads = 0;
423 if(config.video_threads > 16) config.video_threads = 16;
425 config.audio_bitrate = MyGetPrivateProfileInt(_T("Video"), _T("AudioBitrate"), config.audio_bitrate, config_path);
426 if(config.audio_bitrate < 16) config.audio_bitrate = 16;
427 if(config.audio_bitrate > 448) config.audio_bitrate = 448;
429 config.video_frame_rate = MyGetPrivateProfileInt(_T("Video"), _T("VideoFramerate"), config.video_frame_rate, config_path);
430 if(config.video_frame_rate < 15) config.video_frame_rate = 15;
431 if(config.video_frame_rate > 75) config.video_frame_rate = 75;
435 config.log_to_syslog = MyGetPrivateProfileBool(_T("Emulator"), _T("WriteToSyslog"), config.log_to_syslog, config_path);
436 config.log_to_console = MyGetPrivateProfileBool(_T("Emulator"), _T("WriteToConsole"), config.log_to_console, config_path);
437 for(int ii = 0; ii < (CSP_LOG_TYPE_VM_DEVICE_END - CSP_LOG_TYPE_VM_DEVICE_0 + 1); ii++) {
439 flags = MyGetPrivateProfileInt(_T("Emulator"), create_string(_T("SyslogEnabled%d"), ii), 0x0000, config_path);
440 for(int jj = 0; jj < 8; jj++) {
441 config.dev_log_to_syslog[ii][jj] = ((flags & 0x0001) != 0) ? true : false;
442 csp_logger->set_device_node_log(ii, 1, jj, config.dev_log_to_syslog[ii][jj]);
446 flags = MyGetPrivateProfileInt(_T("Emulator"), create_string(_T("ConsoleLogEnabled%d"), ii), 0xffff, config_path);
447 for(int jj = 0; jj < 8; jj++) {
448 config.dev_log_to_console[ii][jj] = ((flags & 0x0001) != 0) ? true : false;
449 csp_logger->set_device_node_log(ii, 2, jj, config.dev_log_to_console[ii][jj]);
452 flags = MyGetPrivateProfileInt(_T("Emulator"), create_string(_T("RecordLogEnabled%d"), ii), 0xffff, config_path);
453 for(int jj = 0; jj < 8; jj++) {
454 config.dev_log_recording[ii][jj] = ((flags & 0x0001) != 0) ? true : false;
455 csp_logger->set_device_node_log(ii, 0, jj, config.dev_log_recording[ii][jj]);
461 csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "Read config done.");
465 void save_config(const _TCHAR *config_path)
468 #if !defined(_MSC_VER)
470 FILEIO *pt = new FILEIO;
471 if(pt->Fopen(config_path, FILEIO_WRITE_ASCII) != true) {
481 # ifdef USE_BOOT_MODE
482 MyWritePrivateProfileInt(_T("Control"), _T("BootMode"), config.boot_mode, config_path);
485 MyWritePrivateProfileInt(_T("Control"), _T("CPUType"), config.cpu_type, config_path);
488 MyWritePrivateProfileInt(_T("Control"), _T("DipSwitch"), config.dipswitch, config_path);
490 #ifdef USE_DEVICE_TYPE
491 MyWritePrivateProfileInt(_T("Control"), _T("DeviceType"), config.device_type, config_path);
493 #ifdef USE_DRIVE_TYPE
494 MyWritePrivateProfileInt(_T("Control"), _T("DriveType"), config.drive_type, config_path);
498 for(drv = 0; drv < MAX_FD; drv++) {
499 MyWritePrivateProfileBool(_T("Control"), create_string(_T("CorrectDiskTiming%d"), drv + 1), config.correct_disk_timing[drv], config_path);
500 MyWritePrivateProfileBool(_T("Control"), create_string(_T("IgnoreDiskCRC%d"), drv + 1), config.ignore_disk_crc[drv], config_path);
506 MyWritePrivateProfileBool(_T("Control"), _T("TapeSound"), config.tape_sound, config_path);
507 MyWritePrivateProfileBool(_T("Control"), _T("WaveShaper"), config.wave_shaper, config_path);
508 MyWritePrivateProfileBool(_T("Control"), _T("DirectLoadMZT"), config.direct_load_mzt, config_path);
509 MyWritePrivateProfileBool(_T("Control"), _T("BaudHigh"), config.baud_high, config_path);
514 MyWritePrivateProfileString(_T("RecentFiles"), _T("InitialCartDir"), config.initial_cart_dir, config_path);
515 for(drv = 0; drv < MAX_CART; drv++) {
516 for(i = 0; i < MAX_HISTORY; i++) {
517 MyWritePrivateProfileString(_T("RecentFiles"), create_string(_T("RecentCartPath%d_%d"), drv + 1, i + 1), config.recent_cart_path[drv][i], config_path);
522 MyWritePrivateProfileString(_T("RecentFiles"), _T("InitialDiskDir"), config.initial_floppy_disk_dir, config_path);
523 for(drv = 0; drv < MAX_FD; drv++) {
524 for(i = 0; i < MAX_HISTORY; i++) {
525 MyWritePrivateProfileString(_T("RecentFiles"), create_string(_T("RecentDiskPath%d_%d"), drv + 1, i + 1), config.recent_floppy_disk_path[drv][i], config_path);
530 MyWritePrivateProfileString(_T("RecentFiles"), _T("InitialQuickDiskDir"), config.initial_quick_disk_dir, config_path);
531 for(drv = 0; drv < MAX_QD; drv++) {
532 for(i = 0; i < MAX_HISTORY; i++) {
533 MyWritePrivateProfileString(_T("RecentFiles"), create_string(_T("RecentQuickDiskPath%d_%d"), drv + 1, i + 1), config.recent_quick_disk_path[drv][i], config_path);
538 MyWritePrivateProfileString(_T("RecentFiles"), _T("InitialTapeDir"), config.initial_tape_dir, config_path);
539 for(i = 0; i < MAX_HISTORY; i++) {
540 MyWritePrivateProfileString(_T("RecentFiles"), create_string(_T("RecentTapePath1_%d"), i + 1), config.recent_tape_path[i], config_path);
543 #ifdef USE_COMPACT_DISC
544 MyWritePrivateProfileString(_T("RecentFiles"), _T("InitialCompactDiscDir"), config.initial_compact_disc_dir, config_path);
545 for(int i = 0; i < MAX_HISTORY; i++) {
546 MyWritePrivateProfileString(_T("RecentFiles"), create_string(_T("RecentCompactDiscPath1_%d"), i + 1), config.recent_compact_disc_path[i], config_path);
549 #ifdef USE_LASER_DISC
550 MyWritePrivateProfileString(_T("RecentFiles"), _T("InitialLaserDiscDir"), config.initial_laser_disc_dir, config_path);
551 for(int i = 0; i < MAX_HISTORY; i++) {
552 MyWritePrivateProfileString(_T("RecentFiles"), create_string(_T("RecentLaserDiscPath1_%d"), i + 1), config.recent_laser_disc_path[i], config_path);
555 #ifdef USE_BINARY_FILE1
556 MyWritePrivateProfileString(_T("RecentFiles"), _T("InitialBinaryDir"), config.initial_binary_dir, config_path);
557 for(drv = 0; drv < MAX_BINARY; drv++) {
558 for(i = 0; i < MAX_HISTORY; i++) {
559 MyWritePrivateProfileString(_T("RecentFiles"), create_string(_T("RecentBinaryPath%d_%d"), drv + 1, i + 1), config.recent_binary_path[drv][i], config_path);
563 #if defined(USE_BUBBLE1)
564 MyWritePrivateProfileString(_T("RecentFiles"), _T("InitialBubbleDir"), config.initial_bubble_casette_dir, config_path);
565 for(drv = 0; drv < MAX_BUBBLE; drv++) {
566 for(i = 0; i < MAX_HISTORY; i++) {
567 MyWritePrivateProfileString(_T("RecentFiles"), create_string(_T("RecentBubblePath%d_%d"), drv + 1, i + 1), config.recent_bubble_casette_path[drv][i], config_path);
572 config.use_opengl_scanline = MyGetPrivateProfileBool(_T("Screen"), _T("UseOpenGLScanLine"), config.use_opengl_scanline, config_path);
573 config.opengl_scanline_vert = MyGetPrivateProfileBool(_T("Screen"), _T("OpenGLScanLineVert"), config.opengl_scanline_vert, config_path);;
574 config.opengl_scanline_horiz = MyGetPrivateProfileBool(_T("Screen"), _T("OpenGLScanLineHoriz"), config.opengl_scanline_horiz, config_path);;
575 config.use_opengl_filters = MyGetPrivateProfileBool(_T("Screen"), _T("UseOpenGLFilters"), config.use_opengl_filters, config_path);
576 config.opengl_filter_num = MyGetPrivateProfileInt(_T("Screen"), _T("OpenGLFilterNum"), config.opengl_filter_num, config_path);
580 #ifndef ONE_BOARD_MICRO_COMPUTER
581 MyWritePrivateProfileInt(_T("Screen"), _T("WindowMode"), config.window_mode, config_path);
583 MyWritePrivateProfileBool(_T("Screen"), _T("UseD3D9"), config.use_d3d9, config_path);
584 MyWritePrivateProfileBool(_T("Screen"), _T("WaitVSync"), config.wait_vsync, config_path);
586 //MyWritePrivateProfileInt(_T("Screen"), _T("StretchType"), config.stretch_type, config_path);
587 MyWritePrivateProfileInt(_T("Screen"), _T("WindowStretchType"), config.window_stretch_type, config_path);
588 MyWritePrivateProfileInt(_T("Screen"), _T("FullScreenStretchType"), config.fullscreen_stretch_type, config_path);
591 MyWritePrivateProfileInt(_T("Screen"), _T("WindowMode"), config.window_mode, config_path);
593 #ifdef USE_MONITOR_TYPE
594 MyWritePrivateProfileInt(_T("Screen"), _T("MonitorType"), config.monitor_type, config_path);
596 #ifdef USE_CRT_FILTER
597 MyWritePrivateProfileBool(_T("Screen"), _T("CRTFilter"), config.crt_filter, config_path);
600 MyWritePrivateProfileBool(_T("Screen"), _T("ScanLine"), config.scan_line, config_path);
602 #ifdef USE_SCREEN_ROTATE
603 MyWritePrivateProfileInt(_T("Screen"), _T("RotateType"), config.rotate_type, config_path);
606 MyWritePrivateProfileBool(_T("Screen"), _T("UseOpenGLScanLine"),
607 config.use_opengl_scanline, config_path);
608 MyWritePrivateProfileBool(_T("Screen"), _T("OpenGLScanLineVert"),
609 config.opengl_scanline_vert, config_path);;
610 MyWritePrivateProfileBool(_T("Screen"), _T("OpenGLScanLineHoriz"),
611 config.opengl_scanline_horiz, config_path);;
612 MyWritePrivateProfileBool(_T("Screen"), _T("UseOpenGLFilters"),
613 config.use_opengl_filters, config_path);
614 MyWritePrivateProfileInt(_T("Screen"), _T("OpenGLFilterNum"),
615 config.opengl_filter_num, config_path);
619 MyWritePrivateProfileInt(_T("Sound"), _T("Frequency"), config.sound_frequency, config_path);
620 MyWritePrivateProfileInt(_T("Sound"), _T("Latency"), config.sound_latency, config_path);
621 #ifdef USE_SOUND_DEVICE_TYPE
622 MyWritePrivateProfileInt(_T("Sound"), _T("DeviceType"), config.sound_device_type, config_path);
624 #ifdef USE_SOUND_VOLUME
625 for(int i = 0; i < USE_SOUND_VOLUME; i++) {
626 MyWritePrivateProfileInt(_T("Sound"), create_string(_T("VolumeLeft%d"), i + 1), config.sound_volume_l[i], config_path);
627 MyWritePrivateProfileInt(_T("Sound"), create_string(_T("VolumeRight%d"), i + 1), config.sound_volume_r[i], config_path);
631 MyWritePrivateProfileString(_T("Sound"), _T("FMGenDll"), config.fmgen_dll_path, config_path);
632 MyWritePrivateProfileInt(_T("Sound"), _T("GeneralSoundLevel"), config.general_sound_level, config_path);
635 MyWritePrivateProfileBool(_T("Input"), _T("UseDirectInput"), config.use_direct_input, config_path);
636 MyWritePrivateProfileBool(_T("Input"), _T("DisableDwm"), config.disable_dwm, config_path);
638 MyWritePrivateProfileInt(_T("Input"), _T("KeyboardType"), config.keyboard_type, config_path);
640 for(int i = 0; i < 4; i++) {
641 for(int j = 0; j < 16; j++) {
642 MyWritePrivateProfileInt(_T("Input"), create_string(_T("JoyButtons%d_%d"), i + 1, j + 1), config.joy_buttons[i][j], config_path);
647 for(i = 0; i < 16; i++) {
649 my_stprintf_s(name, 256, _T("AssignedJoystick%d"), i + 1);
650 MyWritePrivateProfileString(_T("Input"), (const _TCHAR *)name,
651 config.assigned_joystick_name[i], config_path);
657 MyWritePrivateProfileInt(_T("Printer"), _T("DeviceType"), config.printer_device_type, config_path);
660 MyWritePrivateProfileInt(_T("Video"), _T("VideoWidth"), config.video_width, config_path);
661 MyWritePrivateProfileInt(_T("Video"), _T("VideoHeight"), config.video_height, config_path);
662 MyWritePrivateProfileInt(_T("Video"), _T("VideoCodecType"), config.video_codec_type, config_path);
663 MyWritePrivateProfileInt(_T("Video"), _T("AudioCodecType"), config.audio_codec_type, config_path);
665 MyWritePrivateProfileInt(_T("Video"), _T("H264Bitrate"), config.video_h264_bitrate, config_path);
666 MyWritePrivateProfileInt(_T("Video"), _T("H264BFrames"), config.video_h264_bframes, config_path);
667 MyWritePrivateProfileInt(_T("Video"), _T("H264BAdapt"), config.video_h264_b_adapt, config_path);
668 MyWritePrivateProfileInt(_T("Video"), _T("H264MinQ"), config.video_h264_minq, config_path);
669 MyWritePrivateProfileInt(_T("Video"), _T("H264MaxQ"), config.video_h264_maxq, config_path);
670 MyWritePrivateProfileInt(_T("Video"), _T("H264Subme"), config.video_h264_subme, config_path);
672 MyWritePrivateProfileInt(_T("Video"), _T("MPEG4Bitrate"), config.video_mpeg4_bitrate, config_path);
673 MyWritePrivateProfileInt(_T("Video"), _T("MPEG4BFrames"), config.video_mpeg4_bframes, config_path);
674 MyWritePrivateProfileInt(_T("Video"), _T("MPEG4MinQ"), config.video_mpeg4_minq, config_path);
675 MyWritePrivateProfileInt(_T("Video"), _T("MPEG4MaxQ"), config.video_mpeg4_maxq, config_path);
677 MyWritePrivateProfileInt(_T("Video"), _T("VideoThreads"), config.video_threads, config_path);
678 MyWritePrivateProfileInt(_T("Video"), _T("AudioBitrate"), config.audio_bitrate, config_path);
679 MyWritePrivateProfileInt(_T("Video"), _T("VideoFramerate"), config.video_frame_rate, config_path);
682 MyWritePrivateProfileBool(_T("Emulator"), _T("WriteToSyslog"), config.log_to_syslog, config_path);
683 MyWritePrivateProfileBool(_T("Emulator"), _T("WriteToConsole"), config.log_to_console, config_path);
685 for(int ii = 0; ii < (CSP_LOG_TYPE_VM_DEVICE_END - CSP_LOG_TYPE_VM_DEVICE_0 + 1); ii++) {
688 for(int jj = 0; jj < 8; jj++) {
690 if(config.dev_log_to_syslog[ii][jj]) flags |= 0x0001;
692 flags = MyWritePrivateProfileInt(_T("Emulator"), create_string(_T("SyslogEnabled%d"), ii), flags, config_path);
695 for(int jj = 0; jj < 8; jj++) {
697 if(config.dev_log_to_console[ii][jj]) flags |= 0x0001;
699 flags = MyWritePrivateProfileInt(_T("Emulator"), create_string(_T("ConsoleLogEnabled%d"), ii), flags, config_path);
702 for(int jj = 0; jj < 8; jj++) {
704 if(config.dev_log_recording[ii][jj]) flags |= 0x0001;
706 flags = MyWritePrivateProfileInt(_T("Emulator"), create_string(_T("RecordLogEnabled%d"), ii), flags, config_path);
709 #if defined(_USE_QT) && !defined(Q_OS_WIN)
710 csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "Write config done.");
716 #define STATE_VERSION 5
718 void save_config_state(void *f)
720 FILEIO *state_fio = (FILEIO *)f;
723 state_fio->FputUint32(STATE_VERSION);
726 state_fio->FputInt32(config.boot_mode);
729 state_fio->FputInt32(config.cpu_type);
732 state_fio->FputUint32(config.dipswitch);
734 #ifdef USE_DEVICE_TYPE
735 state_fio->FputInt32(config.device_type);
737 #ifdef USE_DRIVE_TYPE
738 state_fio->FputInt32(config.drive_type);
741 for(int drv = 0; drv < MAX_FD; drv++) {
742 state_fio->FputBool(config.correct_disk_timing[drv]);
743 state_fio->FputBool(config.ignore_disk_crc[drv]);
745 // for(int drv = 0; drv < MAX_FD; drv++) {
746 // state_fio->FputBool(config.fdd_hack_fast_transfer[drv]);
749 #ifdef USE_MONITOR_TYPE
750 state_fio->FputInt32(config.monitor_type);
752 #ifdef USE_SOUND_DEVICE_TYPE
753 state_fio->FputInt32(config.sound_device_type);
756 state_fio->FputInt32(config.printer_device_type);
758 state_fio->FputInt32(config.keyboard_type);
761 bool load_config_state(void *f)
763 FILEIO *state_fio = (FILEIO *)f;
765 if(state_fio->FgetUint32() != STATE_VERSION) {
769 config.boot_mode = state_fio->FgetInt32();
772 config.cpu_type = state_fio->FgetInt32();
775 config.dipswitch = state_fio->FgetUint32();
777 #ifdef USE_DEVICE_TYPE
778 config.device_type = state_fio->FgetInt32();
780 #ifdef USE_DRIVE_TYPE
781 config.drive_type = state_fio->FgetInt32();
784 for(int drv = 0; drv < MAX_FD; drv++) {
785 config.correct_disk_timing[drv] = state_fio->FgetBool();
786 config.ignore_disk_crc[drv] = state_fio->FgetBool();
788 // for(int drv = 0; drv < MAX_FD; drv++) {
789 // config.fdd_hack_fast_transfer[drv] = state_fio->FgetBool();
792 #ifdef USE_MONITOR_TYPE
793 config.monitor_type = state_fio->FgetInt32();
795 #ifdef USE_SOUND_DEVICE_TYPE
796 config.sound_device_type = state_fio->FgetInt32();
799 config.printer_device_type = state_fio->FgetInt32();
801 config.keyboard_type = state_fio->FgetInt32();