2 Skelton for retropc emulator
4 Author : Takeda.Toshiya
11 #include <agar/core.h>
15 #include "agar_logger.h"
22 #include "agar_logger.h"
24 # if defined(Q_OS_WIN)
34 #if defined(_USE_AGAR)
35 #include "agar_main.h"
41 #define CONFIG_NAME "conf"
44 //extern _TCHAR* get_parent_dir(_TCHAR* file);
45 BOOL MyWritePrivateProfileInt(LPCTSTR lpAppName, LPCTSTR lpKeyName, int Value, LPCTSTR lpFileName)
48 my_stprintf_s(String, 32, _T("%d"), Value);
49 return MyWritePrivateProfileString(lpAppName, lpKeyName, String, lpFileName);
52 BOOL MyWritePrivateProfileBool(LPCTSTR lpAppName, LPCTSTR lpKeyName, bool Value, LPCTSTR lpFileName)
55 my_stprintf_s(String, 32, _T("%d"), Value ? 1 : 0);
56 return MyWritePrivateProfileString(lpAppName, lpKeyName, String, lpFileName);
59 bool MyGetPrivateProfileBool(LPCTSTR lpAppName, LPCTSTR lpKeyName, bool bDefault, LPCTSTR lpFileName)
61 return (MyGetPrivateProfileInt(lpAppName, lpKeyName, bDefault ? 1 : 0, lpFileName) != 0);
68 memset(&config, 0, sizeof(config_t));
69 config.window_mode = 1;
71 #if defined(USE_BOOT_MODE) && defined(BOOT_MODE_DEFAULT)
72 config.boot_mode = BOOT_MODE_DEFAULT;
74 #if defined(USE_CPU_TYPE) && defined(CPU_TYPE_DEFAULT)
75 config.cpu_type = CPU_TYPE_DEFAULT;
77 #if defined(USE_DIPSWITCH) && defined(DIPSWITCH_DEFAULT)
78 config.dipswitch = DIPSWITCH_DEFAULT;
80 #if defined(USE_DEVICE_TYPE) && defined(DEVICE_TYPE_DEFAULT)
81 config.device_type = DEVICE_TYPE_DEFAULT;
83 #if defined(USE_DRIVE_TYPE) && defined(DRIVE_TYPE_DEFAULT)
84 config.drive_type = DRIVE_TYPE_DEFAULT;
87 for(int drv = 0; drv < MAX_FD; drv++) {
88 #if defined(CORRECT_DISK_TIMING_DEFAULT)
89 config.correct_disk_timing[drv] = CORRECT_DISK_TIMING_DEFAULT;
91 config.correct_disk_timing[drv] = true;
93 #if defined(IGNORE_DISK_CRC_DEFAULT)
94 config.ignore_disk_crc[drv] = IGNORE_DISK_CRC_DEFAULT;
97 #elif defined(USE_FD1)
98 for(int drv = 0; drv < MAX_FD; drv++) {
99 config.ignore_disk_crc[drv] = false;
102 #if defined(USE_TAPE)
103 config.wave_shaper = true;
104 config.direct_load_mzt = true;
105 config.baud_high = true;
109 config.sound_frequency = 6; // 48KHz
110 config.sound_latency = 1; // 100msec
111 config.multiple_speakers = false;
112 config.general_sound_level = 0;
113 #if defined(USE_SOUND_DEVICE_TYPE) && defined(SOUND_DEVICE_TYPE_DEFAULT)
114 config.sound_device_type = SOUND_DEVICE_TYPE_DEFAULT;
115 #elif defined(USE_SOUND_DEVICE_TYPE)
116 config.sound_device_type = 0;
121 config.use_direct_input = true;
122 config.disable_dwm = false;
124 for(int i = 0; i < 4; i++) {
125 for(int j = 0; j < 16; j++) {
126 config.joy_buttons[i][j] = (i << 4) | j;
131 #if defined(USE_PRINTER) && defined(PRINTER_DEVICE_TYPE_DEFAULT)
132 config.printer_device_type = PRINTER_DEVICE_TYPE_DEFAULT;
133 #elif defined(USE_PRINTER)
134 config.printer_device_type = 0;
138 #ifndef ONE_BOARD_MICRO_COMPUTER
140 config.use_d3d9 = true;
142 config.stretch_type = 1; // Stretch (Aspect)
146 config.use_opengl_scanline = false;
147 config.opengl_scanline_vert = false;
148 config.opengl_scanline_horiz = false;
149 config.use_opengl_filters = false;
150 config.opengl_filter_num = 0;
152 #ifdef USE_MULTIPLE_SOUNDCARDS
155 for(ii = 0; ii < USE_MULTIPLE_SOUNDCARDS; ii++) {
156 config.sound_device_level[ii] = 0;
162 void load_config(const _TCHAR *config_path)
170 config.boot_mode = MyGetPrivateProfileInt(_T("Control"), _T("BootMode"), config.boot_mode, config_path);
173 config.cpu_type = MyGetPrivateProfileInt(_T("Control"), _T("CPUType"), config.cpu_type, config_path);
176 config.dipswitch = MyGetPrivateProfileInt(_T("Control"), _T("DipSwitch"), config.dipswitch, config_path);
178 #ifdef USE_DEVICE_TYPE
179 config.device_type = MyGetPrivateProfileInt(_T("Control"), _T("DeviceType"), config.device_type, config_path);
181 #ifdef USE_DRIVE_TYPE
182 config.drive_type = MyGetPrivateProfileInt(_T("Control"), _T("DriveType"), config.drive_type, config_path);
187 for(drv = 0; drv < MAX_FD; drv++) {
188 memset(name, 0x00, sizeof(name));
189 my_stprintf_s(name, 64, _T("CorrectDiskTiming%d"), drv + 1);
190 config.correct_disk_timing[drv] = MyGetPrivateProfileBool(_T("Control"), (const _TCHAR *)name,
191 config.correct_disk_timing[drv], config_path);
192 my_stprintf_s(name, 64, _T("IgnoreDiskCRC%d"), drv + 1);
193 config.ignore_disk_crc[drv] = MyGetPrivateProfileBool(_T("Control"), (const _TCHAR *)name,
194 config.ignore_disk_crc[drv], config_path);
200 config.tape_sound = MyGetPrivateProfileBool(_T("Control"), _T("TapeSound"), config.tape_sound, config_path);
201 config.wave_shaper = MyGetPrivateProfileBool(_T("Control"), _T("WaveShaper"), config.wave_shaper, config_path);
202 config.direct_load_mzt = MyGetPrivateProfileBool(_T("Control"), _T("DirectLoadMZT"), config.direct_load_mzt, config_path);
203 config.baud_high = MyGetPrivateProfileBool(_T("Control"), _T("BaudHigh"), config.baud_high, config_path);
208 MyGetPrivateProfileString(_T("RecentFiles"), _T("InitialCartDir"), _T(""), config.initial_cart_dir, _MAX_PATH, config_path);
209 for(drv = 0; drv < MAX_CART; drv++) {
210 for(i = 0; i < MAX_HISTORY; i++) {
212 my_stprintf_s(name, 64, _T("RecentCartPath%d_%d"), drv + 1, i + 1);
213 MyGetPrivateProfileString(_T("RecentFiles"), name, _T(""),
214 config.recent_cart_path[drv][i], _MAX_PATH, config_path);
219 MyGetPrivateProfileString(_T("RecentFiles"), _T("InitialDiskDir"), _T(""),
220 config.initial_disk_dir, _MAX_PATH, config_path);
221 // get_parent_dir(config.initial_disk_dir);
222 for(drv = 0; drv < MAX_FD; drv++) {
223 for(i = 0; i < MAX_HISTORY; i++) {
225 my_stprintf_s(name, 64, _T("RecentDiskPath%d_%d"), drv + 1, i + 1);
226 MyGetPrivateProfileString(_T("RecentFiles"), (const _TCHAR *)name,
227 _T(""), config.recent_disk_path[drv][i], _MAX_PATH, config_path);
232 MyGetPrivateProfileString(_T("RecentFiles"), _T("InitialQuickDiskDir"),
233 _T(""), config.initial_quickdisk_dir, _MAX_PATH, config_path);
234 for(drv = 0; drv < MAX_QD; drv++) {
235 for(i = 0; i < MAX_HISTORY; i++) {
237 my_stprintf_s(name, 64, _T("RecentQuickDiskPath%d_%d"), drv + 1, i + 1);
238 MyGetPrivateProfileString(_T("RecentFiles"), name, _T(""),
239 config.recent_quickdisk_path[drv][i], _MAX_PATH, config_path);
245 MyGetPrivateProfileString(_T("RecentFiles"), _T("InitialTapeDir"), _T(""),
246 config.initial_tape_dir, _MAX_PATH, config_path);
247 for(i = 0; i < MAX_HISTORY; i++) {
249 my_stprintf_s(name, 64, _T("RecentTapePath1_%d"), i + 1);
250 MyGetPrivateProfileString(_T("RecentFiles"), (const _TCHAR *)name, _T(""),
251 config.recent_tape_path[i], _MAX_PATH, config_path);
255 #ifdef USE_LASER_DISC
256 MyGetPrivateProfileString(_T("RecentFiles"), _T("InitialLaserDiscDir"), _T(""),
257 config.initial_laser_disc_dir, _MAX_PATH, config_path);
258 for(int i = 0; i < MAX_HISTORY; i++) {
260 my_stprintf_s(name, 64, _T("RecentLaserDiscPath1_%d"), i + 1);
261 MyGetPrivateProfileString(_T("RecentFiles"), (const _TCHAR *)name, _T(""),
262 config.recent_laser_disc_path[i], _MAX_PATH, config_path);
265 #ifdef USE_BINARY_FILE1
266 MyGetPrivateProfileString(_T("RecentFiles"), _T("InitialBinaryDir"), _T(""),
267 config.initial_binary_dir, _MAX_PATH, config_path);
268 for(drv = 0; drv < MAX_BINARY; drv++) {
269 for(i = 0; i < MAX_HISTORY; i++) {
271 my_stprintf_s(name, 64, _T("RecentBinaryPath%d_%d"), drv + 1, i + 1);
272 MyGetPrivateProfileString(_T("RecentFiles"), (const _TCHAR *)name, _T(""),
273 config.recent_binary_path[drv][i], _MAX_PATH, config_path);
279 #ifndef ONE_BOARD_MICRO_COMPUTER
280 config.window_mode = MyGetPrivateProfileInt(_T("Screen"), _T("WindowMode"), config.window_mode, config_path);
282 config.use_d3d9 = MyGetPrivateProfileBool(_T("Screen"), _T("UseD3D9"), config.use_d3d9, config_path);
283 config.wait_vsync = MyGetPrivateProfileBool(_T("Screen"), _T("WaitVSync"), config.wait_vsync, config_path);
285 config.stretch_type = MyGetPrivateProfileInt(_T("Screen"), _T("StretchType"), config.stretch_type, config_path);
287 config.window_mode = MyGetPrivateProfileInt(_T("Screen"), _T("WindowMode"), config.window_mode, config_path);
289 #ifdef USE_MONITOR_TYPE
290 config.monitor_type = MyGetPrivateProfileInt(_T("Screen"), _T("MonitorType"), config.monitor_type, config_path);
292 #ifdef USE_CRT_FILTER
293 config.crt_filter = MyGetPrivateProfileBool(_T("Screen"), _T("CRTFilter"), config.crt_filter, config_path);
296 config.scan_line = MyGetPrivateProfileBool(_T("Screen"), _T("ScanLine"), config.scan_line, config_path);
299 #ifdef USE_SCREEN_ROTATE
300 config.rotate_type = MyGetPrivateProfileInt(_T("Screen"), _T("RotateType"), config.rotate_type, config_path);
303 config.use_opengl_scanline = MyGetPrivateProfileBool(_T("Screen"), _T("UseOpenGLScanLine"),
304 config.use_opengl_scanline, config_path);
305 config.opengl_scanline_vert = MyGetPrivateProfileBool(_T("Screen"), _T("OpenGLScanLineVert"),
306 config.opengl_scanline_vert, config_path);;
307 config.opengl_scanline_horiz = MyGetPrivateProfileBool(_T("Screen"), _T("OpenGLScanLineHoriz"),
308 config.opengl_scanline_horiz, config_path);;
309 config.use_opengl_filters = MyGetPrivateProfileBool(_T("Screen"), _T("UseOpenGLFilters"),
310 config.use_opengl_filters, config_path);
311 config.opengl_filter_num = MyGetPrivateProfileInt(_T("Screen"), _T("OpenGLFilterNum"),
312 config.opengl_filter_num, config_path);
315 config.sound_frequency = MyGetPrivateProfileInt(_T("Sound"), _T("Frequency"), config.sound_frequency, config_path);
316 config.sound_latency = MyGetPrivateProfileInt(_T("Sound"), _T("Latency"), config.sound_latency, config_path);
317 #ifdef USE_SOUND_DEVICE_TYPE
318 config.sound_device_type = MyGetPrivateProfileInt(_T("Sound"), _T("DeviceType"), config.sound_device_type, config_path);
320 #ifdef USE_SOUND_VOLUME
321 for(int i = 0; i < USE_SOUND_VOLUME; i++) {
323 my_stprintf_s(name, 64, _T("VolumeLeft%d"), i + 1);
324 int tmp_l = MyGetPrivateProfileInt(_T("Sound"), name, config.sound_volume_l[i], config_path);
325 my_stprintf_s(name, 64, _T("VolumeRight%d"), i + 1);
326 int tmp_r = MyGetPrivateProfileInt(_T("Sound"), name, config.sound_volume_r[i], config_path);
327 config.sound_volume_l[i] = max(-40, min(0, tmp_l));
328 config.sound_volume_r[i] = max(-40, min(0, tmp_r));
331 #if !defined(_USE_QT)
332 MyGetPrivateProfileString(_T("Sound"), _T("FMGenDll"), _T("mamefm.dll"), config.fmgen_dll_path, _MAX_PATH, config_path);
335 config.multiple_speakers = MyGetPrivateProfileBool(_T("Sound"), _T("MultipleSpeakers"),
336 config.multiple_speakers, config_path);
337 config.general_sound_level = MyGetPrivateProfileInt(_T("Sound"), _T("GeneralSoundLevel"),
338 config.general_sound_level, config_path);
339 #ifdef USE_MULTIPLE_SOUNDCARDS
343 for(ii = 0; ii < USE_MULTIPLE_SOUNDCARDS; ii++) {
344 memset(_tag, 0x00, sizeof(_tag));
345 my_stprintf_s(_tag, 64, _T("DeviceVolumeLevel_%d"), ii + 1);
346 config.sound_device_level[ii] = MyGetPrivateProfileInt(_T("Sound"), (const _TCHAR *)_tag, config.sound_device_level[ii], config_path);
351 config.use_direct_input = MyGetPrivateProfileBool(_T("Input"), _T("UseDirectInput"), config.use_direct_input, config_path);
352 config.disable_dwm = MyGetPrivateProfileBool(_T("Input"), _T("DisableDwm"), config.disable_dwm, config_path);
354 for(int i = 0; i < 4; i++) {
355 for(int j = 0; j < 16; j++) {
357 my_stprintf_s(name, 64, _T("JoyButtons%d_%d"), i + 1, j + 1);
358 config.joy_buttons[i][j] = MyGetPrivateProfileInt(_T("Input"), name, config.joy_buttons[i][j], config_path);
362 for(i = 0; i < 16; i++) {
364 my_stprintf_s(name, 256, _T("AssignedJoystick"), i + 1);
365 MyGetPrivateProfileString(_T("Input"), (const _TCHAR *)name, _T(""),
366 config.assigned_joystick_name[i], 256, config_path);
371 config.printer_device_type = MyGetPrivateProfileInt(_T("Printer"), _T("DeviceType"), config.printer_device_type, config_path);
372 MyGetPrivateProfileString(_T("Printer"), _T("PrinterDll"), _T("printer.dll"), config.printer_dll_path, _MAX_PATH, config_path);
374 #if defined(_USE_QT) && !defined(Q_OS_WIN)
375 AGAR_DebugLog(AGAR_LOG_INFO, "Read Done.");
379 void save_config(const _TCHAR *config_path)
382 #if !defined(_MSC_VER)
384 FILEIO *pt = new FILEIO;
385 if(pt->Fopen(config_path, FILEIO_WRITE_ASCII) != true) {
395 # ifdef USE_BOOT_MODE
396 MyWritePrivateProfileInt(_T("Control"), _T("BootMode"), config.boot_mode, config_path);
399 MyWritePrivateProfileInt(_T("Control"), _T("CPUType"), config.cpu_type, config_path);
402 MyWritePrivateProfileInt(_T("Control"), _T("DipSwitch"), config.dipswitch, config_path);
404 #ifdef USE_DEVICE_TYPE
405 MyWritePrivateProfileInt(_T("Control"), _T("DeviceType"), config.device_type, config_path);
407 #ifdef USE_DRIVE_TYPE
408 MyWritePrivateProfileInt(_T("Control"), _T("DriveType"), config.drive_type, config_path);
413 for(drv = 0; drv < MAX_FD; drv++) {
414 memset(name, 0x00, sizeof(name));
415 my_stprintf_s(name, 64, _T("CorrectDiskTiming%d"), drv + 1);
416 MyWritePrivateProfileBool(_T("Control"), (const _TCHAR *)name, config.correct_disk_timing[drv], config_path);
417 my_stprintf_s(name, 64, _T("IgnoreDiskCRC%d"), drv + 1);
418 MyWritePrivateProfileBool(_T("Control"), (const _TCHAR *)name, config.ignore_disk_crc[drv], config_path);
424 MyWritePrivateProfileBool(_T("Control"), _T("TapeSound"), config.tape_sound, config_path);
425 MyWritePrivateProfileBool(_T("Control"), _T("WaveShaper"), config.wave_shaper, config_path);
426 MyWritePrivateProfileBool(_T("Control"), _T("DirectLoadMZT"), config.direct_load_mzt, config_path);
427 MyWritePrivateProfileBool(_T("Control"), _T("BaudHigh"), config.baud_high, config_path);
432 MyWritePrivateProfileString(_T("RecentFiles"), _T("InitialCartDir"), config.initial_cart_dir, config_path);
433 for(drv = 0; drv < MAX_CART; drv++) {
434 for(i = 0; i < MAX_HISTORY; i++) {
436 my_stprintf_s(name, 64, _T("RecentCartPath%d_%d"), drv + 1, i + 1);
437 MyWritePrivateProfileString(_T("RecentFiles"), (const _TCHAR *)name, config.recent_cart_path[drv][i], config_path);
442 MyWritePrivateProfileString(_T("RecentFiles"), _T("InitialDiskDir"), config.initial_disk_dir, config_path);
443 for(drv = 0; drv < MAX_FD; drv++) {
444 for(i = 0; i < MAX_HISTORY; i++) {
446 my_stprintf_s(name, 64, _T("RecentDiskPath%d_%d"), drv + 1, i + 1);
447 MyWritePrivateProfileString(_T("RecentFiles"), (const _TCHAR *)name,
448 config.recent_disk_path[drv][i], config_path);
453 MyWritePrivateProfileString(_T("RecentFiles"), _T("InitialQuickDiskDir"),
454 config.initial_quickdisk_dir, config_path);
455 for(drv = 0; drv < MAX_QD; drv++) {
456 for(i = 0; i < MAX_HISTORY; i++) {
458 my_stprintf_s(name, 64, _T("RecentQuickDiskPath%d_%d"), drv + 1, i + 1);
459 MyWritePrivateProfileString(_T("RecentFiles"), (const _TCHAR *)name,
460 config.recent_quickdisk_path[drv][i], config_path);
465 MyWritePrivateProfileString(_T("RecentFiles"), _T("InitialTapeDir"), config.initial_tape_dir, config_path);
466 for(i = 0; i < MAX_HISTORY; i++) {
468 my_stprintf_s(name, 64, _T("RecentTapePath1_%d"), i + 1);
469 MyWritePrivateProfileString(_T("RecentFiles"), (const _TCHAR *)name,
470 config.recent_tape_path[i], config_path);
473 #ifdef USE_LASER_DISC
474 MyWritePrivateProfileString(_T("RecentFiles"), _T("InitialLaserDiscDir"), config.initial_laser_disc_dir, config_path);
475 for(int i = 0; i < MAX_HISTORY; i++) {
477 my_stprintf_s(name, 64, _T("RecentLaserDiscPath1_%d"), i + 1);
478 MyWritePrivateProfileString(_T("RecentFiles"), (const _TCHAR *)name,
479 config.recent_laser_disc_path[i], config_path);
482 #ifdef USE_BINARY_FILE1
483 MyWritePrivateProfileString(_T("RecentFiles"), _T("InitialBinaryDir"), config.initial_binary_dir, config_path);
484 for(drv = 0; drv < MAX_BINARY; drv++) {
485 for(i = 0; i < MAX_HISTORY; i++) {
487 my_stprintf_s(name, 64, _T("RecentBinaryPath%d_%d"), drv + 1, i + 1);
488 MyWritePrivateProfileString(_T("RecentFiles"), (const _TCHAR *)name,
489 config.recent_binary_path[drv][i], config_path);
495 #ifndef ONE_BOARD_MICRO_COMPUTER
496 MyWritePrivateProfileInt(_T("Screen"), _T("WindowMode"), config.window_mode, config_path);
498 MyWritePrivateProfileBool(_T("Screen"), _T("UseD3D9"), config.use_d3d9, config_path);
499 MyWritePrivateProfileBool(_T("Screen"), _T("WaitVSync"), config.wait_vsync, config_path);
501 MyWritePrivateProfileInt(_T("Screen"), _T("StretchType"), config.stretch_type, config_path);
503 MyWritePrivateProfileInt(_T("Screen"), _T("WindowMode"), config.window_mode, config_path);
505 #ifdef USE_MONITOR_TYPE
506 MyWritePrivateProfileInt(_T("Screen"), _T("MonitorType"), config.monitor_type, config_path);
508 #ifdef USE_CRT_FILTER
509 MyWritePrivateProfileBool(_T("Screen"), _T("CRTFilter"), config.crt_filter, config_path);
512 MyWritePrivateProfileBool(_T("Screen"), _T("ScanLine"), config.scan_line, config_path);
514 #ifdef USE_SCREEN_ROTATE
515 MyWritePrivateProfileInt(_T("Screen"), _T("RotateType"), config.rotate_type, config_path);
518 MyWritePrivateProfileBool(_T("Screen"), _T("UseOpenGLScanLine"),
519 config.use_opengl_scanline, config_path);
520 MyWritePrivateProfileBool(_T("Screen"), _T("OpenGLScanLineVert"),
521 config.opengl_scanline_vert, config_path);;
522 MyWritePrivateProfileBool(_T("Screen"), _T("OpenGLScanLineHoriz"),
523 config.opengl_scanline_horiz, config_path);;
524 MyWritePrivateProfileBool(_T("Screen"), _T("UseOpenGLFilters"),
525 config.use_opengl_filters, config_path);
526 MyWritePrivateProfileInt(_T("Screen"), _T("OpenGLFilterNum"),
527 config.opengl_filter_num, config_path);
531 MyWritePrivateProfileInt(_T("Sound"), _T("Frequency"), config.sound_frequency, config_path);
532 MyWritePrivateProfileInt(_T("Sound"), _T("Latency"), config.sound_latency, config_path);
533 #ifdef USE_SOUND_DEVICE_TYPE
534 MyWritePrivateProfileInt(_T("Sound"), _T("DeviceType"), config.sound_device_type, config_path);
536 #ifdef USE_SOUND_VOLUME
537 for(int i = 0; i < USE_SOUND_VOLUME; i++) {
539 my_stprintf_s(name, 64, _T("VolumeLeft%d"), i + 1);
540 MyWritePrivateProfileInt(_T("Sound"), name, config.sound_volume_l[i], config_path);
541 my_stprintf_s(name, 64, _T("VolumeRight%d"), i + 1);
542 MyWritePrivateProfileInt(_T("Sound"), name, config.sound_volume_r[i], config_path);
545 #if !defined(_USE_QT)
546 MyWritePrivateProfileString(_T("Sound"), _T("FMGenDll"), config.fmgen_dll_path, config_path);
548 MyWritePrivateProfileBool(_T("Sound"), _T("MultipleSpeakers"),
549 config.multiple_speakers, config_path);
550 MyWritePrivateProfileInt(_T("Sound"), _T("GeneralSoundLevel"),
551 config.general_sound_level, config_path);
552 #ifdef USE_MULTIPLE_SOUNDCARDS
556 for(ii = 0; ii < USE_MULTIPLE_SOUNDCARDS; ii++) {
557 memset(_tag, 0x00, sizeof(_tag));
558 my_stprintf_s(_tag, 64, _T("DeviceVolumeLevel_%d"), ii + 1);
559 MyWritePrivateProfileInt(_T("Sound"), (const _TCHAR *)_tag, config.sound_device_level[ii], config_path);
565 MyWritePrivateProfileBool(_T("Input"), _T("UseDirectInput"), config.use_direct_input, config_path);
566 MyWritePrivateProfileBool(_T("Input"), _T("DisableDwm"), config.disable_dwm, config_path);
568 for(int i = 0; i < 4; i++) {
569 for(int j = 0; j < 16; j++) {
571 my_stprintf_s(name, 64, _T("JoyButtons%d_%d"), i + 1, j + 1);
572 MyWritePrivateProfileInt(_T("Input"), name, config.joy_buttons[i][j], config_path);
576 for(i = 0; i < 16; i++) {
578 my_stprintf_s(name, 256, _T("AssignedJoystick%d"), i + 1);
579 MyWritePrivateProfileString(_T("Input"), (const _TCHAR *)name,
580 config.assigned_joystick_name[i], config_path);
586 MyWritePrivateProfileInt(_T("Printer"), _T("DeviceType"), config.printer_device_type, config_path);
588 #if defined(_USE_QT) && !defined(Q_OS_WIN)
589 AGAR_DebugLog(AGAR_LOG_INFO, "Write done.");
593 #define STATE_VERSION 4
595 void save_config_state(void *f)
597 FILEIO *state_fio = (FILEIO *)f;
600 state_fio->FputUint32(STATE_VERSION);
603 state_fio->FputInt32(config.boot_mode);
606 state_fio->FputInt32(config.cpu_type);
609 state_fio->FputUint32(config.dipswitch);
611 #ifdef USE_DEVICE_TYPE
612 state_fio->FputInt32(config.device_type);
614 #ifdef USE_DRIVE_TYPE
615 state_fio->FputInt32(config.drive_type);
618 for(int drv = 0; drv < MAX_FD; drv++) {
619 state_fio->FputBool(config.correct_disk_timing[drv]);
620 state_fio->FputBool(config.ignore_disk_crc[drv]);
622 // for(int drv = 0; drv < MAX_FD; drv++) {
623 // state_fio->FputBool(config.fdd_hack_fast_transfer[drv]);
626 #ifdef USE_MONITOR_TYPE
627 state_fio->FputInt32(config.monitor_type);
629 #ifdef USE_SOUND_DEVICE_TYPE
630 state_fio->FputInt32(config.sound_device_type);
633 state_fio->FputInt32(config.printer_device_type);
638 bool load_config_state(void *f)
640 FILEIO *state_fio = (FILEIO *)f;
642 if(state_fio->FgetUint32() != STATE_VERSION) {
646 config.boot_mode = state_fio->FgetInt32();
649 config.cpu_type = state_fio->FgetInt32();
652 config.dipswitch = state_fio->FgetUint32();
654 #ifdef USE_DEVICE_TYPE
655 config.device_type = state_fio->FgetInt32();
657 #ifdef USE_DRIVE_TYPE
658 config.drive_type = state_fio->FgetInt32();
661 for(int drv = 0; drv < MAX_FD; drv++) {
662 config.correct_disk_timing[drv] = state_fio->FgetBool();
663 config.ignore_disk_crc[drv] = state_fio->FgetBool();
665 // for(int drv = 0; drv < MAX_FD; drv++) {
666 // config.fdd_hack_fast_transfer[drv] = state_fio->FgetBool();
669 #ifdef USE_MONITOR_TYPE
670 config.monitor_type = state_fio->FgetInt32();
672 #ifdef USE_SOUND_DEVICE_TYPE
673 config.sound_device_type = state_fio->FgetInt32();
676 config.printer_device_type = state_fio->FgetInt32();