9 #include "settings.fdh"
11 const char *setfilename
= "settings.dat";
12 const uint16_t SETTINGS_VERSION
= 0x1602; // serves as both a version and magic
14 Settings normal_settings
;
15 Settings replay_settings
;
16 Settings
*settings
= &normal_settings
;
19 bool settings_load(Settings
*setfile
)
21 if (!setfile
) setfile
= &normal_settings
;
23 if (tryload(settings
))
25 stat("No saved settings; using defaults.");
27 memset(setfile
, 0, sizeof(Settings
));
28 setfile
->resolution
= 2; // 640x480 Windowed, should be safe value
29 setfile
->last_save_slot
= 0;
30 setfile
->multisave
= true;
32 setfile
->enable_debug_keys
= false;
33 setfile
->sound_enabled
= true;
34 setfile
->music_enabled
= 1; // both Boss and Regular music
36 setfile
->instant_quit
= false;
37 setfile
->emulate_bugs
= false;
38 setfile
->no_quake_in_hell
= false;
39 setfile
->inhibit_fullscreen
= false;
40 setfile
->files_extracted
= false;
42 // I found that 8bpp->32bpp blits are actually noticably faster
43 // than 32bpp->32bpp blits on several systems I tested. Not sure why
44 // but calling SDL_DisplayFormat seems to actually be slowing things
45 // down. This goes against established wisdom so if you want it back on,
46 // run "displayformat 1" in the console and restart.
47 setfile
->displayformat
= false;
54 stat("settings_load(): Hey FIXME!!!");
55 settings
->show_fps
= true;
57 input_set_mappings(settings
->input_mappings
);
65 void c------------------------------() {}
68 static bool tryload(Settings
*setfile
)
72 stat("Loading settings...");
74 fp
= fileopen(setfilename
, "rb");
77 stat("Couldn't open file %s.", setfilename
);
82 fread(setfile
, sizeof(Settings
), 1, fp
);
83 if (setfile
->version
!= SETTINGS_VERSION
)
85 stat("Wrong settings version %04x.", setfile
->version
);
94 bool settings_save(Settings
*setfile
)
99 setfile
= &normal_settings
;
101 stat("Writing settings...");
102 fp
= fileopen(setfilename
, "wb");
105 stat("Couldn't open file %s.", setfilename
);
109 for(int i
=0;i
<INPUT_COUNT
;i
++)
110 setfile
->input_mappings
[i
] = input_get_mapping(i
);
112 setfile
->version
= SETTINGS_VERSION
;
113 fwrite(setfile
, sizeof(Settings
), 1, fp
);