2 // SETTINGS.CPP: Virtual Jaguar configuration loading/saving support
10 #include "sdlemu_config.h"
20 // Private function prototypes
22 void CheckForTrailingSlash(char * path);
25 // Load Virtual Jaguar's settings
27 void LoadVJSettings(void)
29 if (sdlemu_init_config("./vj.cfg") == 0 // CWD
30 && sdlemu_init_config("~/vj.cfg") == 0 // Home
31 && sdlemu_init_config("~/.vj/vj.cfg") == 0 // Home under .vj directory
32 && sdlemu_init_config("vj.cfg") == 0) // Somewhere in the path
33 WriteLog("Settings: Couldn't find VJ configuration file. Using defaults...\n");
35 vjs.useJoystick = sdlemu_getval_bool("useJoystick", false);
36 vjs.joyport = sdlemu_getval_int("joyport", 0);
37 vjs.hardwareTypeNTSC = sdlemu_getval_bool("hardwareTypeNTSC", true);
38 vjs.frameSkip = sdlemu_getval_int("frameSkip", 0);
39 vjs.useJaguarBIOS = sdlemu_getval_bool("useJaguarBIOS", false);
40 vjs.DSPEnabled = sdlemu_getval_bool("DSPEnabled", false);
41 vjs.usePipelinedDSP = sdlemu_getval_bool("usePipelinedDSP", false);
42 vjs.fullscreen = sdlemu_getval_bool("fullscreen", false);
43 vjs.useOpenGL = sdlemu_getval_bool("useOpenGL", true);
44 vjs.glFilter = sdlemu_getval_int("glFilterType", 0);
46 // Keybindings in order of U, D, L, R, C, B, A, Op, Pa, 0-9, #, *
47 vjs.p1KeyBindings[0] = sdlemu_getval_int("p1k_up", SDLK_UP);
48 vjs.p1KeyBindings[1] = sdlemu_getval_int("p1k_down", SDLK_DOWN);
49 vjs.p1KeyBindings[2] = sdlemu_getval_int("p1k_left", SDLK_LEFT);
50 vjs.p1KeyBindings[3] = sdlemu_getval_int("p1k_right", SDLK_RIGHT);
51 vjs.p1KeyBindings[4] = sdlemu_getval_int("p1k_c", SDLK_z);
52 vjs.p1KeyBindings[5] = sdlemu_getval_int("p1k_b", SDLK_x);
53 vjs.p1KeyBindings[6] = sdlemu_getval_int("p1k_a", SDLK_c);
54 vjs.p1KeyBindings[7] = sdlemu_getval_int("p1k_option", SDLK_QUOTE);
55 vjs.p1KeyBindings[8] = sdlemu_getval_int("p1k_pause", SDLK_RETURN);
56 vjs.p1KeyBindings[9] = sdlemu_getval_int("p1k_0", SDLK_KP0);
57 vjs.p1KeyBindings[10] = sdlemu_getval_int("p1k_1", SDLK_KP1);
58 vjs.p1KeyBindings[11] = sdlemu_getval_int("p1k_2", SDLK_KP2);
59 vjs.p1KeyBindings[12] = sdlemu_getval_int("p1k_3", SDLK_KP3);
60 vjs.p1KeyBindings[13] = sdlemu_getval_int("p1k_4", SDLK_KP4);
61 vjs.p1KeyBindings[14] = sdlemu_getval_int("p1k_5", SDLK_KP5);
62 vjs.p1KeyBindings[15] = sdlemu_getval_int("p1k_6", SDLK_KP6);
63 vjs.p1KeyBindings[16] = sdlemu_getval_int("p1k_7", SDLK_KP7);
64 vjs.p1KeyBindings[17] = sdlemu_getval_int("p1k_8", SDLK_KP8);
65 vjs.p1KeyBindings[18] = sdlemu_getval_int("p1k_9", SDLK_KP9);
66 vjs.p1KeyBindings[19] = sdlemu_getval_int("p1k_pound", SDLK_KP_DIVIDE);
67 vjs.p1KeyBindings[20] = sdlemu_getval_int("p1k_star", SDLK_KP_MULTIPLY);
69 vjs.p2KeyBindings[0] = sdlemu_getval_int("p2k_up", SDLK_UP);
70 vjs.p2KeyBindings[1] = sdlemu_getval_int("p2k_down", SDLK_DOWN);
71 vjs.p2KeyBindings[2] = sdlemu_getval_int("p2k_left", SDLK_LEFT);
72 vjs.p2KeyBindings[3] = sdlemu_getval_int("p2k_right", SDLK_RIGHT);
73 vjs.p2KeyBindings[4] = sdlemu_getval_int("p2k_c", SDLK_z);
74 vjs.p2KeyBindings[5] = sdlemu_getval_int("p2k_b", SDLK_x);
75 vjs.p2KeyBindings[6] = sdlemu_getval_int("p2k_a", SDLK_c);
76 vjs.p2KeyBindings[7] = sdlemu_getval_int("p2k_option", SDLK_QUOTE);
77 vjs.p2KeyBindings[8] = sdlemu_getval_int("p2k_pause", SDLK_RETURN);
78 vjs.p2KeyBindings[9] = sdlemu_getval_int("p2k_0", SDLK_KP0);
79 vjs.p2KeyBindings[10] = sdlemu_getval_int("p2k_1", SDLK_KP1);
80 vjs.p2KeyBindings[11] = sdlemu_getval_int("p2k_2", SDLK_KP2);
81 vjs.p2KeyBindings[12] = sdlemu_getval_int("p2k_3", SDLK_KP3);
82 vjs.p2KeyBindings[13] = sdlemu_getval_int("p2k_4", SDLK_KP4);
83 vjs.p2KeyBindings[14] = sdlemu_getval_int("p2k_5", SDLK_KP5);
84 vjs.p2KeyBindings[15] = sdlemu_getval_int("p2k_6", SDLK_KP6);
85 vjs.p2KeyBindings[16] = sdlemu_getval_int("p2k_7", SDLK_KP7);
86 vjs.p2KeyBindings[17] = sdlemu_getval_int("p2k_8", SDLK_KP8);
87 vjs.p2KeyBindings[18] = sdlemu_getval_int("p2k_9", SDLK_KP9);
88 vjs.p2KeyBindings[19] = sdlemu_getval_int("p2k_pound", SDLK_KP_DIVIDE);
89 vjs.p2KeyBindings[20] = sdlemu_getval_int("p2k_star", SDLK_KP_MULTIPLY);
91 strcpy(vjs.jagBootPath, sdlemu_getval_string("JagBootROM", "./BIOS/jagboot.rom"));
92 strcpy(vjs.CDBootPath, sdlemu_getval_string("CDBootROM", "./BIOS/jagcd.rom"));
93 strcpy(vjs.EEPROMPath, sdlemu_getval_string("EEPROMs", "./EEPROMs"));
94 strcpy(vjs.ROMPath, sdlemu_getval_string("ROMs", "./ROMs"));
95 CheckForTrailingSlash(vjs.EEPROMPath);
96 CheckForTrailingSlash(vjs.ROMPath);
98 vjs.hardwareTypeAlpine = false; // No external setting for this yet...
102 // Save Virtual Jaguar's settings
104 void SaveVJSettings(void)
109 // Check path for a trailing slash, and append if not present
111 void CheckForTrailingSlash(char * path)
113 if (strlen(path) > 0)
114 if (path[strlen(path) - 1] != '/')
115 strcat(path, "/"); // NOTE: Possible buffer overflow