1 /* Emacs style mode select   -*- C++ -*-
2  *-----------------------------------------------------------------------------
3  *
4  *
5  *  PrBoom: a Doom port merged with LxDoom and LSDLDoom
6  *  based on BOOM, a modified and improved DOOM engine
7  *  Copyright (C) 1999 by
8  *  id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
9  *  Copyright (C) 1999-2000 by
10  *  Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
11  *  Copyright 2005, 2006 by
12  *  Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
13  *
14  *  This program is free software; you can redistribute it and/or
15  *  modify it under the terms of the GNU General Public License
16  *  as published by the Free Software Foundation; either version 2
17  *  of the License, or (at your option) any later version.
18  *
19  *  This program is distributed in the hope that it will be useful,
20  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
21  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  *  GNU General Public License for more details.
23  *
24  *  You should have received a copy of the GNU General Public License
25  *  along with this program; if not, write to the Free Software
26  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
27  *  02111-1307, USA.
28  *
29  * DESCRIPTION:
30  *  Main loop menu stuff.
31  *  Default Config File.
32  *  PCX Screenshots.
33  *
34  *-----------------------------------------------------------------------------*/
35 
36 #ifdef HAVE_CONFIG_H
37 #include "config.h"
38 #endif
39 
40 #include <stdio.h>
41 #include <errno.h>
42 #ifdef HAVE_UNISTD_H
43 #include <unistd.h>
44 #endif
45 #ifdef _MSC_VER
46 #include <io.h>
47 #endif
48 #include <fcntl.h>
49 #include <sys/stat.h>
50 
51 #include "i_smp.h"
52 
53 #include "doomstat.h"
54 #include "m_argv.h"
55 #include "g_game.h"
56 #include "m_menu.h"
57 #include "am_map.h"
58 #include "w_wad.h"
59 #include "i_system.h"
60 #include "i_sound.h"
61 #include "i_video.h"
62 #include "v_video.h"
63 #include "hu_stuff.h"
64 #include "st_stuff.h"
65 #include "dstrings.h"
66 #include "m_misc.h"
67 #include "s_sound.h"
68 #include "sounds.h"
69 #include "i_joy.h"
70 #include "lprintf.h"
71 #include "d_main.h"
72 #include "d_deh.h"
73 #include "r_draw.h"
74 #include "r_demo.h"
75 #include "r_fps.h"
76 #include "r_main.h"
77 #include "r_things.h"
78 
79 //e6y
80 #ifdef GL_DOOM
81 #include "gl_struct.h"
82 #endif
83 #include "g_overflow.h"
84 #include "r_screenmultiply.h"
85 #include "e6y.h"
86 #ifdef USE_WINDOWS_LAUNCHER
87 #include "e6y_launcher.h"
88 #endif
89 
90 // NSM
91 #include "i_capture.h"
92 
93 /* cph - disk icon not implemented */
I_BeginRead(void)94 static inline void I_BeginRead(void) {}
I_EndRead(void)95 static inline void I_EndRead(void) {}
96 
97 /*
98  * M_WriteFile
99  *
100  * killough 9/98: rewritten to use stdio and to flash disk icon
101  */
102 
M_WriteFile(char const * name,const void * source,size_t length)103 dboolean M_WriteFile(char const *name, const void *source, size_t length)
104 {
105   FILE *fp;
106 
107   errno = 0;
108 
109   if (!(fp = fopen(name, "wb")))       // Try opening file
110     return 0;                          // Could not open file for writing
111 
112   I_BeginRead();                       // Disk icon on
113   length = fwrite(source, 1, length, fp) == (size_t)length;   // Write data
114   fclose(fp);
115   I_EndRead();                         // Disk icon off
116 
117   if (!length)                         // Remove partially written file
118     remove(name);
119 
120   return length;
121 }
122 
123 /*
124  * M_ReadFile
125  *
126  * killough 9/98: rewritten to use stdio and to flash disk icon
127  */
128 
M_ReadFile(char const * name,byte ** buffer)129 int M_ReadFile(char const *name, byte **buffer)
130 {
131   FILE *fp;
132 
133   if ((fp = fopen(name, "rb")))
134     {
135       size_t length;
136 
137       I_BeginRead();
138       fseek(fp, 0, SEEK_END);
139       length = ftell(fp);
140       fseek(fp, 0, SEEK_SET);
141       *buffer = Z_Malloc(length, PU_STATIC, 0);
142       if (fread(*buffer, 1, length, fp) == length)
143         {
144           fclose(fp);
145           I_EndRead();
146           return length;
147         }
148       fclose(fp);
149     }
150 
151   /* cph 2002/08/10 - this used to return 0 on error, but that's ambiguous,
152    * because we could have a legit 0-length file. So make it -1. */
153   return -1;
154 }
155 
156 //
157 // DEFAULTS
158 //
159 
160 int usemouse;
161 dboolean    precache = true; /* if true, load all graphics at start */
162 
163 // The available anisotropic
164 typedef enum {
165   gl_anisotropic_off = 0,
166   gl_anisotropic_2x  = 1,
167   gl_anisotropic_4x  = 2,
168   gl_anisotropic_8x  = 3,
169   gl_anisotropic_16x = 4,
170 } gl_anisotropic_mode_t;
171 
172 extern int viewwidth;
173 extern int viewheight;
174 #ifdef GL_DOOM
175 extern int gl_nearclip;
176 extern int gl_colorbuffer_bits;
177 extern int gl_depthbuffer_bits;
178 extern int gl_texture_filter;
179 extern int gl_sprite_filter;
180 extern int gl_patch_filter;
181 extern int gl_texture_filter_anisotropic;
182 extern const char *gl_tex_format_string;
183 extern int gl_sky_detail;
184 extern int gl_use_paletted_texture;
185 extern int gl_use_shared_texture_palette;
186 extern int gl_seamless;
187 extern int gl_invul_bw_method;
188 
189 //e6y: all OpenGL extentions will be disabled with TRUE
190 extern int gl_compatibility;
191 
192 //cfg values
193 extern int gl_ext_texture_filter_anisotropic_default;
194 extern int gl_arb_texture_non_power_of_two_default;
195 extern int gl_arb_multitexture_default;
196 extern int gl_arb_texture_compression_default;
197 extern int gl_ext_framebuffer_object_default;
198 extern int gl_ext_packed_depth_stencil_default;
199 extern int gl_ext_blend_color_default;
200 extern int gl_use_stencil_default;
201 extern int gl_ext_arb_vertex_buffer_object_default;
202 extern int gl_arb_pixel_buffer_object_default;
203 
204 //e6y: motion bloor
205 extern int gl_motionblur;
206 extern const char *gl_motionblur_minspeed;
207 extern const char *gl_motionblur_att_a;
208 extern const char *gl_motionblur_att_b;
209 extern const char *gl_motionblur_att_c;
210 
211 //e6y: fog
212 extern int gl_fog;
213 extern int gl_fog_color;
214 
215 extern int gl_clear;
216 extern int gl_ztrick;
217 
218 #endif
219 
220 extern int realtic_clock_rate;         // killough 4/13/98: adjustable timer
221 extern int tran_filter_pct;            // killough 2/21/98
222 
223 extern int screenblocks;
224 extern int showMessages;
225 
226 #ifndef DJGPP
227 int         mus_pause_opt; // 0 = kill music, 1 = pause, 2 = continue
228 #endif
229 
230 extern const char* chat_macros[];
231 
232 extern int endoom_mode;
233 
234 extern const char* S_music_files[]; // cournia
235 
236 /* cph - Some MBF stuff parked here for now
237  * killough 10/98
238  */
239 int map_point_coordinates;
240 int map_level_stat;
241 
242 default_t defaults[] =
243 {
244   //e6y
245   {"System settings",{NULL},{0},UL,UL,def_none,ss_none},
246   {"process_affinity_mask", {&process_affinity_mask},{1},-1,UL,def_int,ss_none},
247   {"process_priority", {&process_priority},{0},0,2,def_int,ss_none},
248   {"render_smp", {&use_smp_defauls},{0},0,1,def_bool,ss_none},
249   {"try_to_reduce_cpu_cache_misses", {&try_to_reduce_cpu_cache_misses},{1},0,1,def_bool,ss_none},
250 
251   {"Misc settings",{NULL},{0},UL,UL,def_none,ss_none},
252   {"default_compatibility_level",{(int*)&default_compatibility_level},
253    {-1},-1,MAX_COMPATIBILITY_LEVEL-1,
254    def_int,ss_none}, // compatibility level" - CPhipps
255   {"realtic_clock_rate",{&realtic_clock_rate},{100},0,UL,
256    def_int,ss_none}, // percentage of normal speed (35 fps) realtic clock runs at
257   {"menu_background", {(int*)&menu_background}, {1}, 0, 1,
258    def_bool,ss_none}, // do Boom fullscreen menus have backgrounds?
259   {"max_player_corpse", {&bodyquesize}, {32},-1,UL,   // killough 2/8/98
260    def_int,ss_none}, // number of dead bodies in view supported (-1 = no limit)
261   {"flashing_hom",{&flashing_hom},{0},0,1,
262    def_bool,ss_none}, // killough 10/98 - enable flashing HOM indicator
263   {"demo_insurance",{&default_demo_insurance},{2},0,2,  // killough 3/31/98
264    def_int,ss_none}, // 1=take special steps ensuring demo sync, 2=only during recordings
265   {"endoom_mode", {&endoom_mode},{5},0,7, // CPhipps - endoom flags
266    def_hex, ss_none}, // 0, +1 for colours, +2 for non-ascii chars, +4 for skip-last-line
267   {"level_precache",{(int*)&precache},{0},0,1,
268    def_bool,ss_none}, // precache level data?
269   {"demo_smoothturns", {&demo_smoothturns},  {0},0,1,
270    def_bool,ss_stat},
271   {"demo_smoothturnsfactor", {&demo_smoothturnsfactor},  {6},1,SMOOTH_PLAYING_MAXFACTOR,
272    def_int,ss_stat},
273 
274   {"Files",{NULL},{0},UL,UL,def_none,ss_none},
275   /* cph - MBF-like wad/deh/bex autoload code */
276   {"wadfile_1",{NULL,&wad_files[0]},{0,""},UL,UL,def_str,ss_none},
277   {"wadfile_2",{NULL,&wad_files[1]},{0,""},UL,UL,def_str,ss_none},
278   {"dehfile_1",{NULL,&deh_files[0]},{0,""},UL,UL,def_str,ss_none},
279   {"dehfile_2",{NULL,&deh_files[1]},{0,""},UL,UL,def_str,ss_none},
280 
281   {"Game settings",{NULL},{0},UL,UL,def_none,ss_none},
282   {"default_skill",{&defaultskill},{3},1,5, // jff 3/24/98 allow default skill setting
283    def_int,ss_none}, // selects default skill 1=TYTD 2=NTR 3=HMP 4=UV 5=NM
284   {"weapon_recoil",{&default_weapon_recoil},{0},0,1,
285    def_bool,ss_weap, &weapon_recoil},
286   /* killough 10/98 - toggle between SG/SSG and Fist/Chainsaw */
287   {"doom_weapon_toggles",{&doom_weapon_toggles}, {1}, 0, 1,
288    def_bool, ss_weap },
289   {"player_bobbing",{&default_player_bobbing},{1},0,1,         // phares 2/25/98
290    def_bool,ss_weap, &player_bobbing},
291   {"monsters_remember",{&default_monsters_remember},{1},0,1,   // killough 3/1/98
292    def_bool,ss_enem, &monsters_remember},
293    /* MBF AI enhancement options */
294   {"monster_infighting",{&default_monster_infighting}, {1}, 0, 1,
295    def_bool, ss_enem, &monster_infighting},
296   {"monster_backing",{&default_monster_backing}, {0}, 0, 1,
297    def_bool, ss_enem, &monster_backing},
298   {"monster_avoid_hazards",{&default_monster_avoid_hazards}, {1}, 0, 1,
299    def_bool, ss_enem, &monster_avoid_hazards},
300   {"monkeys",{&default_monkeys}, {0}, 0, 1,
301    def_bool, ss_enem, &monkeys},
302   {"monster_friction",{&default_monster_friction}, {1}, 0, 1,
303    def_bool, ss_enem, &monster_friction},
304   {"help_friends",{&default_help_friends}, {0}, 0, 1,
305    def_bool, ss_enem, &help_friends},
306   {"allow_pushers",{&default_allow_pushers},{1},0,1,
307    def_bool,ss_weap, &allow_pushers},
308   {"variable_friction",{&default_variable_friction},{1},0,1,
309    def_bool,ss_weap, &variable_friction},
310 #ifdef DOGS
311   {"player_helpers",{&default_dogs}, {0}, 0, 3,
312    def_bool, ss_enem },
313   {"friend_distance",{&default_distfriend}, {128}, 0, 999,
314    def_int, ss_enem, &distfriend},
315   {"dog_jumping",{&default_dog_jumping}, {1}, 0, 1,
316    def_bool, ss_enem, &dog_jumping},
317 #endif
318    /* End of MBF AI extras */
319 
320   {"sts_always_red",{&sts_always_red},{1},0,1, // no color changes on status bar
321    def_bool,ss_stat},
322   {"sts_pct_always_gray",{&sts_pct_always_gray},{0},0,1, // 2/23/98 chg default
323    def_bool,ss_stat}, // makes percent signs on status bar always gray
324   {"sts_traditional_keys",{&sts_traditional_keys},{0},0,1,  // killough 2/28/98
325    def_bool,ss_stat}, // disables doubled card and skull key display on status bar
326   {"show_messages",{&showMessages},{1},0,1,
327    def_bool,ss_none}, // enables message display
328   {"autorun",{&autorun},{0},0,1,  // killough 3/6/98: preserve autorun across games
329    def_bool,ss_none},
330 
331   {"Dehacked settings",{NULL},{0},UL,UL,def_none,ss_none},
332   {"deh_apply_cheats",{&deh_apply_cheats},{1},0,1,
333    def_bool,ss_stat}, // if 0, dehacked cheat replacements are ignored.
334 
335   {"Compatibility settings",{NULL},{0},UL,UL,def_none,ss_none},
336   {"comp_zombie",{&default_comp[comp_zombie]},{0},0,1,def_bool,ss_comp,&comp[comp_zombie]},
337   {"comp_infcheat",{&default_comp[comp_infcheat]},{0},0,1,def_bool,ss_comp,&comp[comp_infcheat]},
338   {"comp_stairs",{&default_comp[comp_stairs]},{0},0,1,def_bool,ss_comp,&comp[comp_stairs]},
339   {"comp_telefrag",{&default_comp[comp_telefrag]},{0},0,1,def_bool,ss_comp,&comp[comp_telefrag]},
340   {"comp_dropoff",{&default_comp[comp_dropoff]},{0},0,1,def_bool,ss_comp,&comp[comp_dropoff]},
341   {"comp_falloff",{&default_comp[comp_falloff]},{0},0,1,def_bool,ss_comp,&comp[comp_falloff]},
342   {"comp_staylift",{&default_comp[comp_staylift]},{0},0,1,def_bool,ss_comp,&comp[comp_staylift]},
343   {"comp_doorstuck",{&default_comp[comp_doorstuck]},{0},0,1,def_bool,ss_comp,&comp[comp_doorstuck]},
344   {"comp_pursuit",{&default_comp[comp_pursuit]},{0},0,1,def_bool,ss_comp,&comp[comp_pursuit]},
345   {"comp_vile",{&default_comp[comp_vile]},{0},0,1,def_bool,ss_comp,&comp[comp_vile]},
346   {"comp_pain",{&default_comp[comp_pain]},{0},0,1,def_bool,ss_comp,&comp[comp_pain]},
347   {"comp_skull",{&default_comp[comp_skull]},{0},0,1,def_bool,ss_comp,&comp[comp_skull]},
348   {"comp_blazing",{&default_comp[comp_blazing]},{0},0,1,def_bool,ss_comp,&comp[comp_blazing]},
349   {"comp_doorlight",{&default_comp[comp_doorlight]},{0},0,1,def_bool,ss_comp,&comp[comp_doorlight]},
350   {"comp_god",{&default_comp[comp_god]},{0},0,1,def_bool,ss_comp,&comp[comp_god]},
351   {"comp_skymap",{&default_comp[comp_skymap]},{0},0,1,def_bool,ss_comp,&comp[comp_skymap]},
352   {"comp_floors",{&default_comp[comp_floors]},{0},0,1,def_bool,ss_comp,&comp[comp_floors]},
353   {"comp_model",{&default_comp[comp_model]},{0},0,1,def_bool,ss_comp,&comp[comp_model]},
354   {"comp_zerotags",{&default_comp[comp_zerotags]},{0},0,1,def_bool,ss_comp,&comp[comp_zerotags]},
355   {"comp_moveblock",{&default_comp[comp_moveblock]},{0},0,1,def_bool,ss_comp,&comp[comp_moveblock]},
356   {"comp_sound",{&default_comp[comp_sound]},{0},0,1,def_bool,ss_comp,&comp[comp_sound]},
357   {"comp_666",{&default_comp[comp_666]},{0},0,1,def_bool,ss_comp,&comp[comp_666]},
358   {"comp_soul",{&default_comp[comp_soul]},{0},0,1,def_bool,ss_comp,&comp[comp_soul]},
359   {"comp_maskedanim",{&default_comp[comp_maskedanim]},{0},0,1,def_bool,ss_comp,&comp[comp_maskedanim]},
360   //e6y
361   {"PrBoom-plus compatibility settings",{NULL},{0},UL,UL,def_none,ss_none},
362   {"comp_ouchface",{&default_comp[comp_ouchface]},{0},0,1,def_bool,ss_comp,&comp[comp_ouchface]},
363   {"comp_maxhealth",{&default_comp[comp_maxhealth]},{0},0,1,def_bool,ss_comp,&comp[comp_maxhealth]},
364   {"comp_translucency",{&default_comp[comp_translucency]},{0},0,1,def_bool,ss_comp,&comp[comp_translucency]},
365 
366   {"Sound settings",{NULL},{0},UL,UL,def_none,ss_none},
367 //#ifdef HAVE_LIBSDL_MIXER
368   {"snd_pcspeaker",{&snd_pcspeaker},{0}, 0, 1, def_bool,ss_none},
369 //#endif
370   {"sound_card",{&snd_card},{-1},-1,7,       // jff 1/18/98 allow Allegro drivers
371    def_int,ss_none}, // select sounds driver (DOS), -1 is autodetect, 0 is none; in Linux, non-zero enables sound
372   {"music_card",{&mus_card},{-1},-1,9,       //  to be set,  -1 = autodetect
373    def_int,ss_none}, // select music driver (DOS), -1 is autodetect, 0 is none"; in Linux, non-zero enables music
374   {"pitched_sounds",{&pitched_sounds},{0},0,1, // killough 2/21/98
375    def_bool,ss_none}, // enables variable pitch in sound effects (from id's original code)
376   {"samplerate",{&snd_samplerate},{22050},11025,48000, def_int,ss_none},
377   {"sfx_volume",{&snd_SfxVolume},{8},0,15, def_int,ss_none},
378   {"music_volume",{&snd_MusicVolume},{8},0,15, def_int,ss_none},
379   {"mus_pause_opt",{&mus_pause_opt},{1},0,2, // CPhipps - music pausing
380    def_int, ss_none}, // 0 = kill music when paused, 1 = pause music, 2 = let music continue
381   {"snd_channels",{&default_numChannels},{32},1,32,
382    def_int,ss_none}, // number of audio events simultaneously // killough
383 #ifdef _WIN32
384   {"snd_midiplayer",{NULL, &snd_midiplayer},{0,"fluidsynth"},UL,UL,def_str,ss_none},
385 #else
386   {"snd_midiplayer",{NULL, &snd_midiplayer},{0,"sdl"},UL,UL,def_str,ss_none},
387 #endif
388   {"snd_soundfont",{NULL, &snd_soundfont},{0,"TimGM6mb.sf2"},UL,UL,def_str,ss_none}, // soundfont name for synths that support it
389   {"snd_mididev",{NULL, &snd_mididev},{0,""},UL,UL,def_str,ss_none}, // midi device to use for portmidiplayer
390 
391 #ifdef _WIN32
392   {"mus_extend_volume",{&mus_extend_volume},{0},0,1,
393    def_bool,ss_none}, // e6y: apply midi volume to all midi devices
394 #endif
395 
396   {"Video settings",{NULL},{0},UL,UL,def_none,ss_none},
397 #ifdef GL_DOOM
398   #ifdef _MSC_VER
399     {"videomode",{NULL, &default_videomode},{0,"OpenGL"},UL,UL,def_str,ss_none},
400   #else
401     {"videomode",{NULL, &default_videomode},{0,"8"},UL,UL,def_str,ss_none},
402   #endif
403   {"use_gl_surface",{&use_gl_surface},{0},0,1,def_bool,ss_none},
404 #else
405   {"videomode",{NULL, &default_videomode},{0,"8"},UL,UL,def_str,ss_none},
406 #endif
407   /* 640x480 default resolution */
408   {"screen_resolution",{NULL, &screen_resolution},{0,"640x480"},UL,UL,def_str,ss_none},
409   {"use_fullscreen",{&use_fullscreen},{0},0,1, /* proff 21/05/2000 */
410    def_bool,ss_none},
411 #ifndef DISABLE_DOUBLEBUFFER
412   {"use_doublebuffer",{&use_doublebuffer},{1},0,1,             // proff 2001-7-4
413    def_bool,ss_none}, // enable doublebuffer to avoid display tearing (fullscreen)
414 #endif
415   {"translucency",{&default_translucency},{1},0,1,   // phares
416    def_bool,ss_none}, // enables translucency
417   {"tran_filter_pct",{&tran_filter_pct},{66},0,100,         // killough 2/21/98
418    def_int,ss_none}, // set percentage of foreground/background translucency mix
419   {"screenblocks",{&screenblocks},{10},3,11,  // killough 2/21/98: default to 10
420    def_int,ss_none},
421   {"usegamma",{&usegamma},{3},0,4, //jff 3/6/98 fix erroneous upper limit in range
422    def_int,ss_none}, // gamma correction level // killough 1/18/98
423   {"uncapped_framerate", {&movement_smooth_default},  {1},0,1,
424    def_bool,ss_stat},
425   {"test_interpolation_method", {&interpolation_method},  {0},0,1,
426    def_int,ss_stat},
427   {"filter_wall",{(int*)&drawvars.filterwall},{RDRAW_FILTER_POINT},
428    RDRAW_FILTER_POINT, RDRAW_FILTER_ROUNDED, def_int,ss_none},
429   {"filter_floor",{(int*)&drawvars.filterfloor},{RDRAW_FILTER_POINT},
430    RDRAW_FILTER_POINT, RDRAW_FILTER_ROUNDED, def_int,ss_none},
431   {"filter_sprite",{(int*)&drawvars.filtersprite},{RDRAW_FILTER_POINT},
432    RDRAW_FILTER_POINT, RDRAW_FILTER_ROUNDED, def_int,ss_none},
433   {"filter_z",{(int*)&drawvars.filterz},{RDRAW_FILTER_POINT},
434    RDRAW_FILTER_POINT, RDRAW_FILTER_LINEAR, def_int,ss_none},
435   {"filter_patch",{(int*)&drawvars.filterpatch},{RDRAW_FILTER_POINT},
436    RDRAW_FILTER_POINT, RDRAW_FILTER_ROUNDED, def_int,ss_none},
437   {"filter_threshold",{(int*)&drawvars.mag_threshold},{49152},
438    0, UL, def_int,ss_none},
439   {"sprite_edges",{(int*)&drawvars.sprite_edges},{RDRAW_MASKEDCOLUMNEDGE_SQUARE},
440    RDRAW_MASKEDCOLUMNEDGE_SQUARE, RDRAW_MASKEDCOLUMNEDGE_SLOPED, def_int,ss_none},
441   {"patch_edges",{(int*)&drawvars.patch_edges},{RDRAW_MASKEDCOLUMNEDGE_SQUARE},
442    RDRAW_MASKEDCOLUMNEDGE_SQUARE, RDRAW_MASKEDCOLUMNEDGE_SLOPED, def_int,ss_none},
443 
444 #ifdef GL_DOOM
445   {"OpenGL settings",{NULL},{0},UL,UL,def_none,ss_none},
446   {"gl_compatibility", {&gl_compatibility},  {0},0,1,
447    def_bool,ss_stat},
448 
449   {"gl_arb_multitexture", {&gl_arb_multitexture_default}, {1},0,1,
450    def_bool,ss_stat},
451   {"gl_arb_texture_compression", {&gl_arb_texture_compression_default}, {1},0,1,
452    def_bool,ss_stat},
453   {"gl_arb_texture_non_power_of_two", {&gl_arb_texture_non_power_of_two_default}, {1},0,1,
454    def_bool,ss_stat},
455   {"gl_ext_arb_vertex_buffer_object", {&gl_ext_arb_vertex_buffer_object_default}, {1},0,1,
456    def_bool,ss_stat},
457   {"gl_arb_pixel_buffer_object", {&gl_arb_pixel_buffer_object_default}, {1},0,1,
458    def_bool,ss_stat},
459   {"gl_ext_blend_color", {&gl_ext_blend_color_default}, {1},0,1,
460    def_bool,ss_stat},
461   {"gl_ext_framebuffer_object", {&gl_ext_framebuffer_object_default}, {1},0,1,
462    def_bool,ss_stat},
463   {"gl_ext_packed_depth_stencil", {&gl_ext_packed_depth_stencil_default}, {1},0,1,
464    def_bool,ss_stat},
465   {"gl_ext_texture_filter_anisotropic", {&gl_ext_texture_filter_anisotropic_default}, {1},0,1,
466    def_bool,ss_stat},
467   {"gl_use_stencil", {&gl_use_stencil_default}, {1},0,1,
468    def_bool,ss_stat},
469   {"gl_use_display_lists",{&gl_use_display_lists},{0},0,1,
470    def_bool,ss_none},
471 
472   {"gl_vsync",{&gl_vsync},{1},0,1,
473    def_bool,ss_none},
474   {"gl_clear",{&gl_clear},{0},0,1,
475    def_bool,ss_none},
476   {"gl_ztrick",{&gl_ztrick},{0},0,1,
477    def_bool,ss_none},
478   {"gl_nearclip",{&gl_nearclip},{5},0,UL,
479    def_int,ss_none}, /* near clipping plane pos */
480   {"gl_colorbuffer_bits",{&gl_colorbuffer_bits},{32},16,32,
481    def_int,ss_none},
482   {"gl_depthbuffer_bits",{&gl_depthbuffer_bits},{24},16,32,
483    def_int,ss_none},
484   {"gl_texture_filter",{(int*)&gl_texture_filter},
485    {filter_linear_mipmap_linear}, filter_nearest, filter_count - 1, def_int,ss_none},
486   {"gl_sprite_filter",{(int*)&gl_sprite_filter},
487    {filter_linear}, filter_nearest, filter_linear_mipmap_nearest, def_int,ss_none},
488   {"gl_patch_filter",{(int*)&gl_patch_filter},
489    {filter_linear}, filter_nearest, filter_linear, def_int,ss_none},
490   {"gl_texture_filter_anisotropic",{(int*)&gl_texture_filter_anisotropic},
491    {gl_anisotropic_8x}, gl_anisotropic_off, gl_anisotropic_16x, def_int,ss_none},
492   {"gl_tex_format_string", {NULL,&gl_tex_format_string}, {0,"GL_RGBA"},UL,UL,
493    def_str,ss_none},
494   {"gl_sprite_offset",{&gl_sprite_offset_default},{0}, 0, 5,
495    def_int,ss_none}, // amount to bring items out of floor (GL) Mead 8/13/03
496   {"gl_sprite_blend",{&gl_sprite_blend},{0},0,1,
497    def_bool,ss_none},
498   {"gl_mask_sprite_threshold",{&gl_mask_sprite_threshold},{50},0,100,
499    def_int,ss_none},
500   {"gl_skymode",{(int*)&gl_skymode},
501   {skytype_auto}, skytype_auto, skytype_count - 1, def_int,ss_none},
502   {"gl_sky_detail",{&gl_sky_detail},{16},1,32,
503    def_int,ss_none},
504   {"gl_use_paletted_texture",{&gl_use_paletted_texture},{0},0,1,
505    def_bool,ss_none},
506   {"gl_use_shared_texture_palette",{&gl_use_shared_texture_palette},{0},0,1,
507    def_bool,ss_none},
508 #endif
509 
510   {"Mouse settings",{NULL},{0},UL,UL,def_none,ss_none},
511   {"use_mouse",{&usemouse},{1},0,1,
512    def_bool,ss_none}, // enables use of mouse with DOOM
513   //jff 4/3/98 allow unlimited sensitivity
514   {"mouse_sensitivity_horiz",{&mouseSensitivity_horiz},{10},0,UL,
515    def_int,ss_none}, /* adjust horizontal (x) mouse sensitivity killough/mead */
516   //jff 4/3/98 allow unlimited sensitivity
517   {"mouse_sensitivity_vert",{&mouseSensitivity_vert},{10},0,UL,
518    def_int,ss_none}, /* adjust vertical (y) mouse sensitivity killough/mead */
519   //jff 3/8/98 allow -1 in mouse bindings to disable mouse function
520   {"mouseb_fire",{&mousebfire},{0},-1,MAX_MOUSEB,
521    def_int,ss_keys}, // mouse button number to use for fire
522   {"mouseb_strafe",{&mousebstrafe},{1},-1,MAX_MOUSEB,
523    def_int,ss_keys}, // mouse button number to use for strafing
524   {"mouseb_forward",{&mousebforward},{2},-1,MAX_MOUSEB,
525    def_int,ss_keys}, // mouse button number to use for forward motion
526   {"mouseb_backward",{&mousebbackward},{-1},-1,MAX_MOUSEB,
527    def_int,ss_keys}, // mouse button number to use for backward motion
528   {"mouseb_use", {&mousebuse},{-1},-1,MAX_MOUSEB,
529    def_int,ss_keys}, // mouse button number to use for using doors/switches
530   //jff 3/8/98 end of lower range change for -1 allowed in mouse binding
531 
532 // For key bindings, the values stored in the key_* variables       // phares
533 // are the internal Doom Codes. The values stored in the default.cfg
534 // file are the keyboard codes.
535 // CPhipps - now they're the doom codes, so default.cfg can be portable
536 
537   {"Key bindings",{NULL},{0},UL,UL,def_none,ss_none},
538   {"key_right",       {&key_right},          {KEYD_RIGHTARROW},
539    0,MAX_KEY,def_key,ss_keys}, // key to turn right
540   {"key_left",        {&key_left},           {KEYD_LEFTARROW} ,
541    0,MAX_KEY,def_key,ss_keys}, // key to turn left
542   {"key_up",          {&key_up},             {KEYD_UPARROW}   ,
543    0,MAX_KEY,def_key,ss_keys}, // key to move forward
544   {"key_down",        {&key_down},           {KEYD_DOWNARROW},
545    0,MAX_KEY,def_key,ss_keys}, // key to move backward
546   {"key_mlook",       {&key_mlook},           {'\\'},
547    0,MAX_KEY,def_key,ss_keys}, // key to move backward
548   {"key_menu_right",  {&key_menu_right},     {KEYD_RIGHTARROW},// phares 3/7/98
549    0,MAX_KEY,def_key,ss_keys}, // key to move right in a menu  //     |
550   {"key_menu_left",   {&key_menu_left},      {KEYD_LEFTARROW} ,//     V
551    0,MAX_KEY,def_key,ss_keys}, // key to move left in a menu
552   {"key_menu_up",     {&key_menu_up},        {KEYD_UPARROW}   ,
553    0,MAX_KEY,def_key,ss_keys}, // key to move up in a menu
554   {"key_menu_down",   {&key_menu_down},      {KEYD_DOWNARROW} ,
555    0,MAX_KEY,def_key,ss_keys}, // key to move down in a menu
556   {"key_menu_backspace",{&key_menu_backspace},{KEYD_BACKSPACE} ,
557    0,MAX_KEY,def_key,ss_keys}, // delete key in a menu
558   {"key_menu_escape", {&key_menu_escape},    {KEYD_ESCAPE}    ,
559    0,MAX_KEY,def_key,ss_keys}, // key to leave a menu      ,   // phares 3/7/98
560   {"key_menu_enter",  {&key_menu_enter},     {KEYD_ENTER}     ,
561    0,MAX_KEY,def_key,ss_keys}, // key to select from menu
562   {"key_setup",       {&key_setup},          {0},
563    0,MAX_KEY,def_key,ss_keys}, //e6y: key for entering setup menu
564   {"key_strafeleft",  {&key_strafeleft},     {','}           ,
565    0,MAX_KEY,def_key,ss_keys}, // key to strafe left
566   {"key_straferight", {&key_straferight},    {'.'}           ,
567    0,MAX_KEY,def_key,ss_keys}, // key to strafe right
568 
569   {"key_fire",        {&key_fire},           {KEYD_RCTRL}     ,
570    0,MAX_KEY,def_key,ss_keys}, // duh
571   {"key_use",         {&key_use},            {' '}           ,
572    0,MAX_KEY,def_key,ss_keys}, // key to open a door, use a switch
573   {"key_strafe",      {&key_strafe},         {KEYD_RALT}      ,
574    0,MAX_KEY,def_key,ss_keys}, // key to use with arrows to strafe
575   {"key_speed",       {&key_speed},          {KEYD_RSHIFT}    ,
576    0,MAX_KEY,def_key,ss_keys}, // key to run
577 
578   {"key_savegame",    {&key_savegame},       {KEYD_F2}        ,
579    0,MAX_KEY,def_key,ss_keys}, // key to save current game
580   {"key_loadgame",    {&key_loadgame},       {KEYD_F3}        ,
581    0,MAX_KEY,def_key,ss_keys}, // key to restore from saved games
582   {"key_soundvolume", {&key_soundvolume},    {KEYD_F4}        ,
583    0,MAX_KEY,def_key,ss_keys}, // key to bring up sound controls
584   {"key_hud",         {&key_hud},            {KEYD_F5}        ,
585    0,MAX_KEY,def_key,ss_keys}, // key to adjust HUD
586   {"key_quicksave",   {&key_quicksave},      {KEYD_F6}        ,
587    0,MAX_KEY,def_key,ss_keys}, // key to to quicksave
588   {"key_endgame",     {&key_endgame},        {KEYD_F7}        ,
589    0,MAX_KEY,def_key,ss_keys}, // key to end the game
590   {"key_messages",    {&key_messages},       {KEYD_F8}        ,
591    0,MAX_KEY,def_key,ss_keys}, // key to toggle message enable
592   {"key_quickload",   {&key_quickload},      {KEYD_F9}        ,
593    0,MAX_KEY,def_key,ss_keys}, // key to load from quicksave
594   {"key_quit",        {&key_quit},           {KEYD_F10}       ,
595    0,MAX_KEY,def_key,ss_keys}, // key to quit game
596   {"key_gamma",       {&key_gamma},          {KEYD_F11}       ,
597    0,MAX_KEY,def_key,ss_keys}, // key to adjust gamma correction
598   {"key_spy",         {&key_spy},            {KEYD_F12}       ,
599    0,MAX_KEY,def_key,ss_keys}, // key to view from another coop player's view
600   {"key_pause",       {&key_pause},          {KEYD_PAUSE}     ,
601    0,MAX_KEY,def_key,ss_keys}, // key to pause the game
602   {"key_autorun",     {&key_autorun},        {KEYD_CAPSLOCK}  ,
603    0,MAX_KEY,def_key,ss_keys}, // key to toggle always run mode
604   {"key_chat",        {&key_chat},           {'t'}            ,
605    0,MAX_KEY,def_key,ss_keys}, // key to enter a chat message
606   {"key_backspace",   {&key_backspace},      {KEYD_BACKSPACE} ,
607    0,MAX_KEY,def_key,ss_keys}, // backspace key
608   {"key_enter",       {&key_enter},          {KEYD_ENTER}     ,
609    0,MAX_KEY,def_key,ss_keys}, // key to select from menu or see last message
610   {"key_map",         {&key_map},            {KEYD_TAB}       ,
611    0,MAX_KEY,def_key,ss_keys}, // key to toggle automap display
612   {"key_map_right",   {&key_map_right},      {KEYD_RIGHTARROW},// phares 3/7/98
613    0,MAX_KEY,def_key,ss_keys}, // key to shift automap right   //     |
614   {"key_map_left",    {&key_map_left},       {KEYD_LEFTARROW} ,//     V
615    0,MAX_KEY,def_key,ss_keys}, // key to shift automap left
616   {"key_map_up",      {&key_map_up},         {KEYD_UPARROW}   ,
617    0,MAX_KEY,def_key,ss_keys}, // key to shift automap up
618   {"key_map_down",    {&key_map_down},       {KEYD_DOWNARROW} ,
619    0,MAX_KEY,def_key,ss_keys}, // key to shift automap down
620   {"key_map_zoomin",  {&key_map_zoomin},      {'='}           ,
621    0,MAX_KEY,def_key,ss_keys}, // key to enlarge automap
622   {"key_map_zoomout", {&key_map_zoomout},     {'-'}           ,
623    0,MAX_KEY,def_key,ss_keys}, // key to reduce automap
624   {"key_map_gobig",   {&key_map_gobig},       {'0'}           ,
625    0,MAX_KEY,def_key,ss_keys},  // key to get max zoom for automap
626   {"key_map_follow",  {&key_map_follow},      {'f'}           ,
627    0,MAX_KEY,def_key,ss_keys}, // key to toggle follow mode
628   {"key_map_mark",    {&key_map_mark},        {'m'}           ,
629    0,MAX_KEY,def_key,ss_keys}, // key to drop a marker on automap
630   {"key_map_clear",   {&key_map_clear},       {'c'}           ,
631    0,MAX_KEY,def_key,ss_keys}, // key to clear all markers on automap
632   {"key_map_grid",    {&key_map_grid},        {'g'}           ,
633    0,MAX_KEY,def_key,ss_keys}, // key to toggle grid display over automap
634   {"key_map_rotate",  {&key_map_rotate},      {'r'}           ,
635    0,MAX_KEY,def_key,ss_keys}, // key to toggle rotating the automap to match the player's orientation
636   {"key_map_overlay", {&key_map_overlay},     {'o'}           ,
637    0,MAX_KEY,def_key,ss_keys}, // key to toggle overlaying the automap on the rendered display
638 #ifdef GL_DOOM
639   {"key_map_textured", {&key_map_textured},   {0}             ,
640    0,MAX_KEY,def_key,ss_keys}, // key to toggle textured automap
641 #endif
642   {"key_reverse",     {&key_reverse},         {'/'}           ,
643    0,MAX_KEY,def_key,ss_keys}, // key to spin 180 instantly
644   {"key_zoomin",      {&key_zoomin},          {'='}           ,
645    0,MAX_KEY,def_key,ss_keys}, // key to enlarge display
646   {"key_zoomout",     {&key_zoomout},         {'-'}           ,
647    0,MAX_KEY,def_key,ss_keys}, // key to reduce display
648   {"key_chatplayer1", {&destination_keys[0]}, {'g'}            ,
649    0,MAX_KEY,def_key,ss_keys}, // key to chat with player 1
650   // killough 11/98: fix 'i'/'b' reversal
651   {"key_chatplayer2", {&destination_keys[1]}, {'i'}            ,
652    0,MAX_KEY,def_key,ss_keys}, // key to chat with player 2
653   {"key_chatplayer3", {&destination_keys[2]}, {'b'}            ,
654    0,MAX_KEY,def_key,ss_keys}, // key to chat with player 3
655   {"key_chatplayer4", {&destination_keys[3]}, {'r'}            ,
656    0,MAX_KEY,def_key,ss_keys}, // key to chat with player 4
657   {"key_weapontoggle",{&key_weapontoggle},    {'0'}            ,
658    0,MAX_KEY,def_key,ss_keys}, // key to toggle between two most preferred weapons with ammo
659   {"key_weapon1",     {&key_weapon1},         {'1'}            ,
660    0,MAX_KEY,def_key,ss_keys}, // key to switch to weapon 1 (fist/chainsaw)
661   {"key_weapon2",     {&key_weapon2},         {'2'}            ,
662    0,MAX_KEY,def_key,ss_keys}, // key to switch to weapon 2 (pistol)
663   {"key_weapon3",     {&key_weapon3},         {'3'}            ,
664    0,MAX_KEY,def_key,ss_keys}, // key to switch to weapon 3 (supershotgun/shotgun)
665   {"key_weapon4",     {&key_weapon4},         {'4'}            ,
666    0,MAX_KEY,def_key,ss_keys}, // key to switch to weapon 4 (chaingun)
667   {"key_weapon5",     {&key_weapon5},         {'5'}            ,
668    0,MAX_KEY,def_key,ss_keys}, // key to switch to weapon 5 (rocket launcher)
669   {"key_weapon6",     {&key_weapon6},         {'6'}            ,
670    0,MAX_KEY,def_key,ss_keys}, // key to switch to weapon 6 (plasma rifle)
671   {"key_weapon7",     {&key_weapon7},         {'7'}            ,
672    0,MAX_KEY,def_key,ss_keys}, // key to switch to weapon 7 (bfg9000)         //    ^
673   {"key_weapon8",     {&key_weapon8},         {'8'}            ,
674    0,MAX_KEY,def_key,ss_keys}, // key to switch to weapon 8 (chainsaw)        //    |
675   {"key_weapon9",     {&key_weapon9},         {'9'}            ,
676    0,MAX_KEY,def_key,ss_keys}, // key to switch to weapon 9 (supershotgun)    // phares
677   {"key_nextweapon",  {&key_nextweapon},      {KEYD_MWHEELUP}  ,
678    0,MAX_KEY,def_key,ss_keys}, // key to cycle to the next weapon
679   {"key_prevweapon",  {&key_prevweapon},      {KEYD_MWHEELDOWN},
680    0,MAX_KEY,def_key,ss_keys}, // key to cycle to the previous weapon
681 
682   // killough 2/22/98: screenshot key
683   {"key_screenshot",  {&key_screenshot},      {'*'}            ,
684    0,MAX_KEY,def_key,ss_keys}, // key to take a screenshot
685 
686   {"Joystick settings",{NULL},{0},UL,UL,def_none,ss_none},
687   {"use_joystick",{&usejoystick},{0},0,2,
688    def_int,ss_none}, // number of joystick to use (0 for none)
689   {"joy_left",{&joyleft},{0},  UL,UL,def_int,ss_none},
690   {"joy_right",{&joyright},{0},UL,UL,def_int,ss_none},
691   {"joy_up",  {&joyup},  {0},  UL,UL,def_int,ss_none},
692   {"joy_down",{&joydown},{0},  UL,UL,def_int,ss_none},
693   {"joyb_fire",{&joybfire},{0},0,UL,
694    def_int,ss_keys}, // joystick button number to use for fire
695   {"joyb_strafe",{&joybstrafe},{1},0,UL,
696    def_int,ss_keys}, // joystick button number to use for strafing
697   {"joyb_speed",{&joybspeed},{2},0,UL,
698    def_int,ss_keys}, // joystick button number to use for running
699   {"joyb_use",{&joybuse},{3},0,UL,
700    def_int,ss_keys}, // joystick button number to use for use/open
701 
702   {"Chat macros",{NULL},{0},UL,UL,def_none,ss_none},
703   {"chatmacro0", {0,&chat_macros[0]}, {0,HUSTR_CHATMACRO0},UL,UL,
704    def_str,ss_chat}, // chat string associated with 0 key
705   {"chatmacro1", {0,&chat_macros[1]}, {0,HUSTR_CHATMACRO1},UL,UL,
706    def_str,ss_chat}, // chat string associated with 1 key
707   {"chatmacro2", {0,&chat_macros[2]}, {0,HUSTR_CHATMACRO2},UL,UL,
708    def_str,ss_chat}, // chat string associated with 2 key
709   {"chatmacro3", {0,&chat_macros[3]}, {0,HUSTR_CHATMACRO3},UL,UL,
710    def_str,ss_chat}, // chat string associated with 3 key
711   {"chatmacro4", {0,&chat_macros[4]}, {0,HUSTR_CHATMACRO4},UL,UL,
712    def_str,ss_chat}, // chat string associated with 4 key
713   {"chatmacro5", {0,&chat_macros[5]}, {0,HUSTR_CHATMACRO5},UL,UL,
714    def_str,ss_chat}, // chat string associated with 5 key
715   {"chatmacro6", {0,&chat_macros[6]}, {0,HUSTR_CHATMACRO6},UL,UL,
716    def_str,ss_chat}, // chat string associated with 6 key
717   {"chatmacro7", {0,&chat_macros[7]}, {0,HUSTR_CHATMACRO7},UL,UL,
718    def_str,ss_chat}, // chat string associated with 7 key
719   {"chatmacro8", {0,&chat_macros[8]}, {0,HUSTR_CHATMACRO8},UL,UL,
720    def_str,ss_chat}, // chat string associated with 8 key
721   {"chatmacro9", {0,&chat_macros[9]}, {0,HUSTR_CHATMACRO9},UL,UL,
722    def_str,ss_chat}, // chat string associated with 9 key
723 
724   {"Automap settings",{NULL},{0},UL,UL,def_none,ss_none},
725   //jff 1/7/98 defaults for automap colors
726   //jff 4/3/98 remove -1 in lower range, 0 now disables new map features
727   {"mapcolor_back", {&mapcolor_back}, {247},0,255,  // black //jff 4/6/98 new black
728    def_colour,ss_auto}, // color used as background for automap
729   {"mapcolor_grid", {&mapcolor_grid}, {104},0,255,  // dk gray
730    def_colour,ss_auto}, // color used for automap grid lines
731   {"mapcolor_wall", {&mapcolor_wall}, {23},0,255,   // red-brown
732    def_colour,ss_auto}, // color used for one side walls on automap
733   {"mapcolor_fchg", {&mapcolor_fchg}, {55},0,255,   // lt brown
734    def_colour,ss_auto}, // color used for lines floor height changes across
735   {"mapcolor_cchg", {&mapcolor_cchg}, {215},0,255,  // orange
736    def_colour,ss_auto}, // color used for lines ceiling height changes across
737   {"mapcolor_clsd", {&mapcolor_clsd}, {208},0,255,  // white
738    def_colour,ss_auto}, // color used for lines denoting closed doors, objects
739   {"mapcolor_rkey", {&mapcolor_rkey}, {175},0,255,  // red
740    def_colour,ss_auto}, // color used for red key sprites
741   {"mapcolor_bkey", {&mapcolor_bkey}, {204},0,255,  // blue
742    def_colour,ss_auto}, // color used for blue key sprites
743   {"mapcolor_ykey", {&mapcolor_ykey}, {231},0,255,  // yellow
744    def_colour,ss_auto}, // color used for yellow key sprites
745   {"mapcolor_rdor", {&mapcolor_rdor}, {175},0,255,  // red
746    def_colour,ss_auto}, // color used for closed red doors
747   {"mapcolor_bdor", {&mapcolor_bdor}, {204},0,255,  // blue
748    def_colour,ss_auto}, // color used for closed blue doors
749   {"mapcolor_ydor", {&mapcolor_ydor}, {231},0,255,  // yellow
750    def_colour,ss_auto}, // color used for closed yellow doors
751   {"mapcolor_tele", {&mapcolor_tele}, {119},0,255,  // dk green
752    def_colour,ss_auto}, // color used for teleporter lines
753   {"mapcolor_secr", {&mapcolor_secr}, {252},0,255,  // purple
754    def_colour,ss_auto}, // color used for lines around secret sectors
755   {"mapcolor_exit", {&mapcolor_exit}, {0},0,255,    // none
756    def_colour,ss_auto}, // color used for exit lines
757   {"mapcolor_unsn", {&mapcolor_unsn}, {104},0,255,  // dk gray
758    def_colour,ss_auto}, // color used for lines not seen without computer map
759   {"mapcolor_flat", {&mapcolor_flat}, {88},0,255,   // lt gray
760    def_colour,ss_auto}, // color used for lines with no height changes
761   {"mapcolor_sprt", {&mapcolor_sprt}, {112},0,255,  // green
762    def_colour,ss_auto}, // color used as things
763   {"mapcolor_item", {&mapcolor_item}, {231},0,255,  // yellow
764    def_colour,ss_auto}, // color used for counted items
765   {"mapcolor_hair", {&mapcolor_hair}, {208},0,255,  // white
766    def_colour,ss_auto}, // color used for dot crosshair denoting center of map
767   {"mapcolor_sngl", {&mapcolor_sngl}, {208},0,255,  // white
768    def_colour,ss_auto}, // color used for the single player arrow
769   {"mapcolor_me",   {&mapcolor_me}, {112},0,255, // green
770    def_colour,ss_auto}, // your (player) colour
771   {"mapcolor_enemy",   {&mapcolor_enemy}, {177},0,255,
772    def_colour,ss_auto},
773   {"mapcolor_frnd",   {&mapcolor_frnd}, {112},0,255,
774    def_colour,ss_auto},
775   //jff 3/9/98 add option to not show secrets til after found
776   {"map_secret_after", {&map_secret_after}, {0},0,1, // show secret after gotten
777    def_bool,ss_auto}, // prevents showing secret sectors till after entered
778   {"map_point_coord", {&map_point_coordinates}, {0},0,1,
779    def_bool,ss_auto},
780   {"map_level_stat", {&map_level_stat}, {0},0,1,
781    def_bool,ss_auto},
782   //jff 1/7/98 end additions for automap
783   {"automapmode", {(int*)&automapmode}, {0}, 0, 31, // CPhipps - remember automap mode
784    def_hex,ss_none}, // automap mode
785   {"map_always_updates", {&map_always_updates}, {0},0,1,
786    def_bool,ss_auto},
787   {"map_grid_size", {&map_grid_size}, {128},8,256,
788    def_int,ss_auto},
789   {"map_scroll_speed", {&map_scroll_speed}, {4},1,32,
790    def_int,ss_auto},
791   {"map_wheel_zoom", {&map_wheel_zoom}, {1},0,1,
792    def_bool,ss_auto},
793 #ifdef GL_DOOM
794   {"map_use_multisamling", {&map_use_multisamling}, {1},0,1,
795    def_bool,ss_auto},
796 #else
797   {"map_use_multisamling", {&map_use_multisamling}, {0},0,1,
798    def_bool,ss_auto},
799 #endif
800 #ifdef GL_DOOM
801   {"map_textured", {&map_textured}, {1},0,1,
802    def_bool,ss_auto},
803   {"map_textured_trans", {&map_textured_trans}, {100},0,100,
804    def_int,ss_auto},
805   {"map_textured_overlay_trans", {&map_textured_overlay_trans}, {66},0,100,
806    def_int,ss_auto},
807   {"map_lines_overlay_trans", {&map_lines_overlay_trans}, {100},0,100,
808    def_int,ss_auto},
809 #endif
810   {"map_overlay_pos_x", {&map_overlay_pos_x}, {0},0,319,
811    def_int,ss_auto},
812   {"map_overlay_pos_y", {&map_overlay_pos_y}, {0},0,199,
813    def_int,ss_auto},
814   {"map_overlay_pos_width", {&map_overlay_pos_width}, {320},0,320,
815    def_int,ss_auto},
816   {"map_overlay_pos_height", {&map_overlay_pos_height}, {200},0,200,
817    def_int,ss_auto},
818 
819   {"Heads-up display settings",{NULL},{0},UL,UL,def_none,ss_none},
820   //jff 2/16/98 defaults for color ranges in hud and status
821   {"hudcolor_titl", {&hudcolor_titl}, {5},0,9,  // gold range
822    def_int,ss_auto}, // color range used for automap level title
823   {"hudcolor_xyco", {&hudcolor_xyco}, {3},0,9,  // green range
824    def_int,ss_auto}, // color range used for automap coordinates
825    {"hudcolor_mapstat_title", {&hudcolor_mapstat_title}, {6},0,9, // red range
826    def_int,ss_auto}, // color range used for automap statistics for titles
827   {"hudcolor_mapstat_value", {&hudcolor_mapstat_value}, {2},0,9,    // gray range
828    def_int,ss_auto}, // color range used for automap statistics for data
829   {"hudcolor_mapstat_time", {&hudcolor_mapstat_time}, {2},0,9,    // gray range
830    def_int,ss_auto}, // color range used for automap statistics for level time and total time
831   {"hudcolor_mesg", {&hudcolor_mesg}, {6},0,9,  // red range
832    def_int,ss_mess}, // color range used for messages during play
833   {"hudcolor_chat", {&hudcolor_chat}, {5},0,9,  // gold range
834    def_int,ss_mess}, // color range used for chat messages and entry
835   {"hudcolor_list", {&hudcolor_list}, {5},0,9,  // gold range  //jff 2/26/98
836    def_int,ss_mess}, // color range used for message review
837   {"hud_msg_lines", {&hud_msg_lines}, {1},1,16,  // 1 line scrolling window
838    def_int,ss_mess}, // number of messages in review display (1=disable)
839   {"hud_list_bgon", {&hud_list_bgon}, {0},0,1,  // solid window bg ena //jff 2/26/98
840    def_bool,ss_mess}, // enables background window behind message review
841 
842   {"health_red",    {&health_red}   , {25},0,200, // below is red
843    def_int,ss_stat}, // amount of health for red to yellow transition
844   {"health_yellow", {&health_yellow}, {50},0,200, // below is yellow
845    def_int,ss_stat}, // amount of health for yellow to green transition
846   {"health_green",  {&health_green} , {100},0,200,// below is green, above blue
847    def_int,ss_stat}, // amount of health for green to blue transition
848   {"armor_red",     {&armor_red}    , {25},0,200, // below is red
849    def_int,ss_stat}, // amount of armor for red to yellow transition
850   {"armor_yellow",  {&armor_yellow} , {50},0,200, // below is yellow
851    def_int,ss_stat}, // amount of armor for yellow to green transition
852   {"armor_green",   {&armor_green}  , {100},0,200,// below is green, above blue
853    def_int,ss_stat}, // amount of armor for green to blue transition
854   {"ammo_red",      {&ammo_red}     , {25},0,100, // below 25% is red
855    def_int,ss_stat}, // percent of ammo for red to yellow transition
856   {"ammo_yellow",   {&ammo_yellow}  , {50},0,100, // below 50% is yellow, above green
857    def_int,ss_stat}, // percent of ammo for yellow to green transition
858 
859   //jff 2/16/98 HUD and status feature controls
860   {"hud_num",    {&hud_num}, {2},0,100,
861    def_int,ss_none},
862   //jff 2/23/98
863   {"hud_displayed", {&hud_displayed},  {0},0,1, // whether hud is displayed
864    def_bool,ss_none}, // enables display of HUD
865 
866 //e6y
867   {"Prboom-plus key bindings",{NULL},{0},UL,UL,def_none,ss_none},
868   {"key_speedup", {&key_speed_up}, {KEYD_KEYPADPLUS},
869    0,MAX_KEY,def_key,ss_keys},
870   {"key_speeddown", {&key_speed_down}, {KEYD_KEYPADMINUS},
871    0,MAX_KEY,def_key,ss_keys},
872   {"key_speeddefault", {&key_speed_default}, {KEYD_KEYPADMULTIPLY},
873    0,MAX_KEY,def_key,ss_keys},
874   {"speed_step",{&speed_step},{0},0,1000,
875    def_int,ss_none},
876   {"key_demo_skip", {&key_demo_skip}, {KEYD_INSERT},
877    0,MAX_KEY,def_key,ss_keys},
878   {"key_level_restart", {&key_level_restart}, {KEYD_HOME},
879    0,MAX_KEY,def_key,ss_keys},
880   {"key_nextlevel", {&key_nextlevel}, {KEYD_PAGEDOWN},
881    0,MAX_KEY,def_key,ss_keys},
882   {"key_demo_jointogame", {&key_demo_jointogame}, {'q'},
883    0,MAX_KEY,def_key,ss_keys},
884   {"key_demo_endlevel", {&key_demo_endlevel}, {KEYD_END},
885    0,MAX_KEY,def_key,ss_keys},
886   {"key_walkcamera", {&key_walkcamera}, {KEYD_KEYPAD0},
887    0,MAX_KEY,def_key,ss_keys},
888   {"key_showalive", {&key_showalive}, {KEYD_KEYPADDIVIDE},
889    0,MAX_KEY,def_key,ss_keys},
890 
891   {"Prboom-plus heads-up display settings",{NULL},{0},UL,UL,def_none,ss_none},
892   {"hudadd_gamespeed", {&hudadd_gamespeed},  {0},0,1,
893    def_bool,ss_stat},
894   {"hudadd_leveltime", {&hudadd_leveltime},  {0},0,1,
895    def_bool,ss_stat},
896   {"hudadd_demotime", {&hudadd_demotime},  {0},0,1,
897    def_bool,ss_stat},
898   {"hudadd_secretarea", {&hudadd_secretarea},  {0},0,1,
899    def_bool,ss_stat},
900   {"hudadd_smarttotals", {&hudadd_smarttotals},  {0},0,1,
901    def_bool,ss_stat},
902   {"hudadd_demoprogressbar", {&hudadd_demoprogressbar},  {0},0,1,
903    def_bool,ss_stat},
904 
905   //e6y
906   {"Prboom-plus mouse settings",{NULL},{0},UL,UL,def_none,ss_none},
907   {"mouse_acceleration",{&mouse_acceleration},{0},0,UL,
908    def_int,ss_none},
909   {"mouse_sensitivity_mlook",{&mouseSensitivity_mlook},{10},0,UL,
910    def_int,ss_none},
911   {"mouse_doubleclick_as_use", {&mouse_doubleclick_as_use},  {1},0,1,
912    def_bool,ss_stat},
913 
914   {"Prboom-plus demos settings",{NULL},{0},UL,UL,def_none,ss_none},
915   {"demo_extendedformat", {&demo_extendedformat_default},  {0},0,1,
916    def_bool,ss_stat},
917   {"demo_demoex_filename", {NULL,&demo_demoex_filename}, {0,""},UL,UL,
918    def_str,ss_none},
919   {"getwad_cmdline", {NULL, &getwad_cmdline}, {0,""},UL,UL,
920    def_str,ss_none},
921   {"demo_overwriteexisting", {&demo_overwriteexisting},  {0},0,1,
922    def_bool,ss_stat},
923 
924   {"Prboom-plus game settings",{NULL},{0},UL,UL,def_none,ss_none},
925   {"movement_strafe50", {&movement_strafe50},  {0},0,1,
926    def_bool,ss_stat},
927   {"movement_strafe50onturns", {&movement_strafe50onturns},  {0},0,1,
928    def_bool,ss_stat},
929   {"movement_shorttics", {&movement_shorttics},  {0},0,1,
930    def_bool,ss_stat},
931   {"interpolation_maxobjects", {&interpolation_maxobjects},  {0},0,UL,
932    def_int,ss_stat},
933 
934   {"Prboom-plus misc settings",{NULL},{0},UL,UL,def_none,ss_none},
935   {"showendoom", {&showendoom},  {0},0,1,
936    def_bool,ss_stat},
937   {"screenshot_dir", {NULL,&screenshot_dir}, {0,""},UL,UL,
938    def_str,ss_none},
939 
940   // NSM
941   {"Video capture encoding settings",{NULL},{0},UL,UL,def_none,ss_none},
942   {"cap_soundcommand",{NULL, &cap_soundcommand},{0,"oggenc2 -r -R %s -q 5 - -o output.ogg"},UL,UL,def_str,ss_none},
943   {"cap_videocommand",{NULL, &cap_videocommand},{0,"x264 -o output.mp4 --crf 22 --muxer mp4 --demuxer raw --input-csp rgb --input-depth 8 --input-res %wx%h --fps 35 -"},UL,UL,def_str,ss_none},
944   {"cap_muxcommand",{NULL, &cap_muxcommand},{0,"mkvmerge -o %f output.mp4 output.ogg"},UL,UL,def_str,ss_none},
945   {"cap_tempfile1",{NULL, &cap_tempfile1},{0,"output.ogg"},UL,UL,def_str,ss_none},
946   {"cap_tempfile2",{NULL, &cap_tempfile2},{0,"output.mp4"},UL,UL,def_str,ss_none},
947   {"cap_remove_tempfiles", {&cap_remove_tempfiles},{1},0,1,def_bool,ss_none},
948 
949   {"Prboom-plus video settings",{NULL},{0},UL,UL,def_none,ss_none},
950   {"sdl_videodriver", {NULL,&sdl_videodriver}, {0,"default"},UL,UL,
951    def_str,ss_none},
952   {"sdl_video_window_pos", {NULL,&sdl_video_window_pos}, {0,"center"},UL,UL,
953    def_str,ss_none},
954   {"palette_ondamage", {&palette_ondamage},  {1},0,1,
955    def_bool,ss_stat},
956   {"palette_onbonus", {&palette_onbonus},  {1},0,1,
957    def_bool,ss_stat},
958   {"palette_onpowers", {&palette_onpowers},  {1},0,1,
959    def_bool,ss_stat},
960   {"render_wipescreen", {&render_wipescreen},  {1},0,1,
961    def_bool,ss_stat},
962   {"render_screen_multiply", {&render_screen_multiply},  {1},1,4,
963    def_int,ss_stat},
964   {"render_interlaced_scanning", {&render_interlaced_scanning},  {0},0,1,
965    def_bool,ss_stat},
966   {"render_precise",{(int*)&render_precise},{render_precise_quality},
967    render_precise_speed, render_precise_quality, def_int,ss_none},
968   {"render_aspect", {&render_aspect},  {0},0,4,
969    def_int,ss_stat},
970   {"render_doom_lightmaps", {&render_doom_lightmaps},  {0},0,1,
971    def_bool,ss_stat},
972   {"fake_contrast", {&fake_contrast},  {1},0,1,
973    def_bool,ss_stat}, /* cph - allow crappy fake contrast to be disabled */
974   {"render_stretch_hud", {&render_stretch_hud_default},{patch_stretch_4x3},0,patch_stretch_max - 1,
975   def_int,ss_stat},
976   {"render_patches_scalex", {&render_patches_scalex},{0},0,16,
977   def_int,ss_stat},
978   {"render_patches_scaley", {&render_patches_scaley},{0},0,16,
979   def_int,ss_stat},
980   {"sprites_doom_order", {&sprites_doom_order}, {DOOM_ORDER_STATIC},0,DOOM_ORDER_LAST - 1,
981    def_int,ss_stat},
982 
983 #ifdef GL_DOOM
984   {"Prboom-plus OpenGL settings",{NULL},{0},UL,UL,def_none,ss_none},
985   {"gl_allow_detail_textures", {&gl_allow_detail_textures},  {1},0,1,
986    def_bool,ss_stat},
987   {"gl_detail_maxdist", {&gl_detail_maxdist},  {0},0,65535,
988    def_int,ss_stat},
989   {"render_multisampling", {&render_multisampling},  {0},0,8,
990    def_int,ss_stat},
991   {"render_fov", {&render_fov},  {90},20,130,
992    def_int,ss_stat},
993   {"gl_spriteclip",{(int*)&gl_spriteclip},{spriteclip_smart}, spriteclip_const, spriteclip_smart, def_int,ss_none},
994    {"gl_spriteclip_threshold", {&gl_spriteclip_threshold},  {10},0,100,
995    def_int,ss_stat},
996    {"gl_sprites_frustum_culling", {&gl_sprites_frustum_culling},  {1},0,1,
997    def_bool,ss_stat},
998   {"movement_mouselook", {&movement_mouselook},  {0},0,1,
999    def_bool,ss_stat},
1000   {"movement_maxviewpitch", {&movement_maxviewpitch},  {90},0,90,
1001    def_int,ss_stat},
1002   {"movement_mouseinvert", {&movement_mouseinvert},  {0},0,1,
1003    def_bool,ss_stat},
1004   {"render_paperitems", {&render_paperitems},  {1},0,1,
1005    def_bool,ss_stat},
1006   {"gl_boom_colormaps", {&gl_boom_colormaps_default},  {1},0,1,
1007    def_bool,ss_stat},
1008   {"gl_hires_24bit_colormap", {&gl_hires_24bit_colormap},  {0},0,1,
1009    def_bool,ss_stat},
1010   {"gl_texture_internal_hires", {&gl_texture_internal_hires},  {1},0,1,
1011    def_bool,ss_stat},
1012   {"gl_texture_external_hires", {&gl_texture_external_hires},  {0},0,1,
1013    def_bool,ss_stat},
1014   {"gl_hires_override_pwads", {&gl_hires_override_pwads},  {0},0,1,
1015    def_bool,ss_stat},
1016   {"gl_texture_hires_dir", {NULL,&gl_texture_hires_dir}, {0,""},UL,UL,
1017    def_str,ss_none},
1018   {"gl_texture_hqresize", {&gl_texture_hqresize},  {0},0,1,
1019    def_bool,ss_stat},
1020   {"gl_texture_hqresize_textures", {&gl_texture_hqresize_textures},
1021    {hq_scale_2x},hq_scale_none,hq_scale_max-1, def_int,ss_stat},
1022   {"gl_texture_hqresize_sprites", {&gl_texture_hqresize_sprites},
1023    {hq_scale_none},hq_scale_none,hq_scale_max-1, def_int,ss_stat},
1024   {"gl_texture_hqresize_patches", {&gl_texture_hqresize_patches},
1025    {hq_scale_2x},hq_scale_none,hq_scale_max-1,def_int,ss_stat},
1026   {"gl_motionblur", {&gl_motionblur},  {0},0,1,
1027    def_bool,ss_stat},
1028   {"gl_motionblur_minspeed", {NULL,&gl_motionblur_minspeed}, {0,"64.1"},UL,UL,
1029    def_str,ss_none},
1030   {"gl_motionblur_att_a", {NULL,&gl_motionblur_att_a}, {0,"55.0"},UL,UL,
1031    def_str,ss_none},
1032   {"gl_motionblur_att_b", {NULL,&gl_motionblur_att_b}, {0,"1.8"},UL,UL,
1033    def_str,ss_none},
1034   {"gl_motionblur_att_c", {NULL,&gl_motionblur_att_c}, {0,"0.9"},UL,UL,
1035    def_str,ss_none},
1036   {"gl_invul_bw_method", {&gl_invul_bw_method},  {0},0,1,
1037    def_int,ss_stat},
1038   {"gl_lightmode",{(int*)&gl_lightmode},{gl_lightmode_glboom},
1039    gl_lightmode_glboom, gl_lightmode_last-1, def_int,ss_none},
1040   {"gl_light_ambient", {&gl_light_ambient},  {20},1,255,
1041    def_int,ss_stat},
1042   {"gl_fog", {&gl_fog},  {1},0,1,
1043    def_bool,ss_stat},
1044   {"gl_fog_color", {&gl_fog_color},  {0},0,0xffffff,
1045    def_hex,ss_stat},
1046   {"useglgamma",{&useglgamma},{6},0,MAX_GLGAMMA,
1047    def_int,ss_none},
1048   {"gl_color_mip_levels", {&gl_color_mip_levels},  {0},0,1,
1049    def_bool,ss_stat},
1050   {"gl_shadows", {&simple_shadows.enable},  {0},0,1,
1051    def_bool,ss_stat},
1052   {"gl_shadows_maxdist",{&gl_shadows_maxdist},{1000},0,32767,
1053    def_int,ss_none},
1054   {"gl_shadows_factor",{&gl_shadows_factor},{128},0,255,
1055    def_int,ss_none},
1056   {"gl_blend_animations",{&gl_blend_animations},{0},0,1,
1057    def_bool,ss_none},
1058 #endif
1059   {"Prboom-plus emulation settings",{NULL},{0},UL,UL,def_none,ss_none},
1060   {"overrun_spechit_warn", {&overflows[OVERFLOW_SPECHIT].warn},  {0},0,1,
1061    def_bool,ss_stat},
1062   {"overrun_spechit_emulate", {&overflows[OVERFLOW_SPECHIT].emulate},  {1},0,1,
1063    def_bool,ss_stat},
1064   {"overrun_reject_warn", {&overflows[OVERFLOW_REJECT].warn},  {0},0,1,
1065    def_bool,ss_stat},
1066   {"overrun_reject_emulate", {&overflows[OVERFLOW_REJECT].emulate},  {1},0,1,
1067    def_bool,ss_stat},
1068   {"overrun_intercept_warn", {&overflows[OVERFLOW_INTERCEPT].warn},  {0},0,1,
1069    def_bool,ss_stat},
1070   {"overrun_intercept_emulate", {&overflows[OVERFLOW_INTERCEPT].emulate},  {1},0,1,
1071    def_bool,ss_stat},
1072   {"overrun_playeringame_warn", {&overflows[OVERFLOW_PLYERINGAME].warn},  {0},0,1,
1073    def_bool,ss_stat},
1074   {"overrun_playeringame_emulate", {&overflows[OVERFLOW_PLYERINGAME].emulate},  {1},0,1,
1075    def_bool,ss_stat},
1076   {"overrun_donut_warn", {&overflows[OVERFLOW_DONUT].warn},  {0},0,1,
1077    def_bool,ss_stat},
1078   {"overrun_donut_emulate", {&overflows[OVERFLOW_DONUT].emulate},  {0},0,1,
1079    def_bool,ss_stat},
1080   {"overrun_missedbackside_warn", {&overflows[OVERFLOW_MISSEDBACKSIDE].warn},  {0},0,1,
1081    def_bool,ss_stat},
1082   {"overrun_missedbackside_emulate", {&overflows[OVERFLOW_MISSEDBACKSIDE].emulate},  {0},0,1,
1083    def_bool,ss_stat},
1084 
1085   {"Prboom-plus 'bad' compatibility settings",{NULL},{0},UL,UL,def_none,ss_none},
1086   {"comperr_zerotag", {&comperr_zerotag},  {0},0,1,
1087    def_bool,ss_stat},
1088   {"comperr_passuse", {&comperr_passuse},  {0},0,1,
1089    def_bool,ss_stat},
1090   {"comperr_hangsolid", {&comperr_hangsolid},  {0},0,1,
1091    def_bool,ss_stat},
1092 
1093 #ifdef USE_WINDOWS_LAUNCHER
1094   {"Prboom-plus launcher settings",{NULL},{0},UL,UL,def_none,ss_none},
1095   {"launcher_enable",{(int*)&launcher_enable},{launcher_enable_never},
1096    launcher_enable_never, launcher_enable_count - 1, def_int,ss_none},
1097   {"launcher_history0", {NULL,&launcher_history[0]}, {0,""},UL,UL,def_str,ss_none},
1098   {"launcher_history1", {NULL,&launcher_history[1]}, {0,""},UL,UL,def_str,ss_none},
1099   {"launcher_history2", {NULL,&launcher_history[2]}, {0,""},UL,UL,def_str,ss_none},
1100   {"launcher_history3", {NULL,&launcher_history[3]}, {0,""},UL,UL,def_str,ss_none},
1101   {"launcher_history4", {NULL,&launcher_history[4]}, {0,""},UL,UL,def_str,ss_none},
1102   {"launcher_history5", {NULL,&launcher_history[5]}, {0,""},UL,UL,def_str,ss_none},
1103   {"launcher_history6", {NULL,&launcher_history[6]}, {0,""},UL,UL,def_str,ss_none},
1104   {"launcher_history7", {NULL,&launcher_history[7]}, {0,""},UL,UL,def_str,ss_none},
1105   {"launcher_history8", {NULL,&launcher_history[8]}, {0,""},UL,UL,def_str,ss_none},
1106   {"launcher_history9", {NULL,&launcher_history[9]}, {0,""},UL,UL,def_str,ss_none},
1107 #endif
1108   {"Prboom-plus demo patterns list. Put your patterns here",{NULL},{0},UL,UL,def_none,ss_none},
1109   {"demo_patterns_mask", {NULL, &demo_patterns_mask, &demo_patterns_count, &demo_patterns_list}, {0,"demo_pattern",9, &demo_patterns_list_def[0]},UL,UL,def_arr,ss_none},
1110   {"demo_pattern0", {NULL,&demo_patterns_list_def[0]},
1111    {0,"DOOM 2: Hell on Earth/((lv)|(nm)|(pa)|(ty))\\d\\d.\\d\\d\\d\\.lmp/doom2.wad"},UL,UL,def_str,ss_none},
1112   {"demo_pattern1", {NULL,&demo_patterns_list_def[1]},
1113    {0,"DOOM 2: Plutonia Experiment/p(c|f|l|n|p|r|s|t)\\d\\d.\\d\\d\\d\\.lmp/doom2.wad|plutonia.wad"},UL,UL,def_str,ss_none},
1114   {"demo_pattern2", {NULL,&demo_patterns_list_def[2]},
1115    {0,"DOOM 2: TNT - Evilution/((e(c|f|v|p|r|s|t))|(tn))\\d\\d.\\d\\d\\d\\.lmp/doom2.wad|tnt.wad"},UL,UL,def_str,ss_none},
1116   {"demo_pattern3", {NULL,&demo_patterns_list_def[3]},
1117    {0,"The Ultimate DOOM/(((e|f|n|p|r|t|u)\\dm\\d)|(n\\ds\\d)).\\d\\d\\d\\.lmp/doom.wad"},UL,UL,def_str,ss_none},
1118   {"demo_pattern4", {NULL,&demo_patterns_list_def[4]},
1119    {0,"Alien Vendetta/a(c|f|n|p|r|s|t|v)\\d\\d.\\d\\d\\d\\.lmp/doom2.wad|av.wad|av.deh"},UL,UL,def_str,ss_none},
1120   {"demo_pattern5", {NULL,&demo_patterns_list_def[5]},
1121    {0,"Requiem/r(c|f|n|p|q|r|s|t)\\d\\d.\\d\\d\\d\\.lmp/doom2.wad|requiem.wad|req21fix.wad|reqmus.wad"},UL,UL,def_str,ss_none},
1122   {"demo_pattern6", {NULL,&demo_patterns_list_def[6]},
1123    {0,"Hell Revealed/h(c|e|f|n|p|r|s|t)\\d\\d.\\d\\d\\d\\.lmp/doom2.wad|hr.wad|hrmus.wad"},UL,UL,def_str,ss_none},
1124   {"demo_pattern7", {NULL,&demo_patterns_list_def[7]},
1125    {0,"Memento Mori/mm\\d\\d.\\d\\d\\d\\.lmp/doom2.wad|mm.wad|mmmus.wad"},UL,UL,def_str,ss_none},
1126   {"demo_pattern8", {NULL,&demo_patterns_list_def[8]},
1127    {0,"Memento Mori 2/m2\\d\\d.\\d\\d\\d\\.lmp/doom2.wad|mm2.wad|mm2mus.wad"},UL,UL,def_str,ss_none},
1128 
1129   {"Weapon preferences",{NULL},{0},UL,UL,def_none,ss_none},
1130   // killough 2/8/98: weapon preferences set by user:
1131   {"weapon_choice_1", {&weapon_preferences[0][0]}, {6}, 0,9,
1132    def_int,ss_weap}, // first choice for weapon (best)
1133   {"weapon_choice_2", {&weapon_preferences[0][1]}, {9}, 0,9,
1134    def_int,ss_weap}, // second choice for weapon
1135   {"weapon_choice_3", {&weapon_preferences[0][2]}, {4}, 0,9,
1136    def_int,ss_weap}, // third choice for weapon
1137   {"weapon_choice_4", {&weapon_preferences[0][3]}, {3}, 0,9,
1138    def_int,ss_weap}, // fourth choice for weapon
1139   {"weapon_choice_5", {&weapon_preferences[0][4]}, {2}, 0,9,
1140    def_int,ss_weap}, // fifth choice for weapon
1141   {"weapon_choice_6", {&weapon_preferences[0][5]}, {8}, 0,9,
1142    def_int,ss_weap}, // sixth choice for weapon
1143   {"weapon_choice_7", {&weapon_preferences[0][6]}, {5}, 0,9,
1144    def_int,ss_weap}, // seventh choice for weapon
1145   {"weapon_choice_8", {&weapon_preferences[0][7]}, {7}, 0,9,
1146    def_int,ss_weap}, // eighth choice for weapon
1147   {"weapon_choice_9", {&weapon_preferences[0][8]}, {1}, 0,9,
1148    def_int,ss_weap}, // ninth choice for weapon (worst)
1149 
1150   // cournia - support for arbitrary music file (defaults are mp3)
1151   {"Music", {NULL},{0},UL,UL,def_none,ss_none},
1152   {"mus_e1m1", {0,&S_music_files[mus_e1m1]}, {0,"e1m1.mp3"},UL,UL,
1153    def_str,ss_none},
1154   {"mus_e1m2", {0,&S_music_files[mus_e1m2]}, {0,"e1m2.mp3"},UL,UL,
1155    def_str,ss_none},
1156   {"mus_e1m3", {0,&S_music_files[mus_e1m3]}, {0,"e1m3.mp3"},UL,UL,
1157    def_str,ss_none},
1158   {"mus_e1m4", {0,&S_music_files[mus_e1m4]}, {0,"e1m4.mp3"},UL,UL,
1159    def_str,ss_none},
1160   {"mus_e1m5", {0,&S_music_files[mus_e1m5]}, {0,"e1m5.mp3"},UL,UL,
1161    def_str,ss_none},
1162   {"mus_e1m6", {0,&S_music_files[mus_e1m6]}, {0,"e1m6.mp3"},UL,UL,
1163    def_str,ss_none},
1164   {"mus_e1m7", {0,&S_music_files[mus_e1m7]}, {0,"e1m7.mp3"},UL,UL,
1165    def_str,ss_none},
1166   {"mus_e1m8", {0,&S_music_files[mus_e1m8]}, {0,"e1m8.mp3"},UL,UL,
1167    def_str,ss_none},
1168   {"mus_e1m9", {0,&S_music_files[mus_e1m9]}, {0,"e1m9.mp3"},UL,UL,
1169    def_str,ss_none},
1170   {"mus_e2m1", {0,&S_music_files[mus_e2m1]}, {0,"e2m1.mp3"},UL,UL,
1171    def_str,ss_none},
1172   {"mus_e2m2", {0,&S_music_files[mus_e2m2]}, {0,"e2m2.mp3"},UL,UL,
1173    def_str,ss_none},
1174   {"mus_e2m3", {0,&S_music_files[mus_e2m3]}, {0,"e2m3.mp3"},UL,UL,
1175    def_str,ss_none},
1176   {"mus_e2m4", {0,&S_music_files[mus_e2m4]}, {0,"e2m4.mp3"},UL,UL,
1177    def_str,ss_none},
1178   {"mus_e2m5", {0,&S_music_files[mus_e2m5]}, {0,"e1m7.mp3"},UL,UL,
1179    def_str,ss_none},
1180   {"mus_e2m6", {0,&S_music_files[mus_e2m6]}, {0,"e2m6.mp3"},UL,UL,
1181    def_str,ss_none},
1182   {"mus_e2m7", {0,&S_music_files[mus_e2m7]}, {0,"e2m7.mp3"},UL,UL,
1183    def_str,ss_none},
1184   {"mus_e2m8", {0,&S_music_files[mus_e2m8]}, {0,"e2m8.mp3"},UL,UL,
1185    def_str,ss_none},
1186   {"mus_e2m9", {0,&S_music_files[mus_e2m9]}, {0,"e3m1.mp3"},UL,UL,
1187    def_str,ss_none},
1188   {"mus_e3m1", {0,&S_music_files[mus_e3m1]}, {0,"e3m1.mp3"},UL,UL,
1189    def_str,ss_none},
1190   {"mus_e3m2", {0,&S_music_files[mus_e3m2]}, {0,"e3m2.mp3"},UL,UL,
1191    def_str,ss_none},
1192   {"mus_e3m3", {0,&S_music_files[mus_e3m3]}, {0,"e3m3.mp3"},UL,UL,
1193    def_str,ss_none},
1194   {"mus_e3m4", {0,&S_music_files[mus_e3m4]}, {0,"e1m8.mp3"},UL,UL,
1195    def_str,ss_none},
1196   {"mus_e3m5", {0,&S_music_files[mus_e3m5]}, {0,"e1m7.mp3"},UL,UL,
1197    def_str,ss_none},
1198   {"mus_e3m6", {0,&S_music_files[mus_e3m6]}, {0,"e1m6.mp3"},UL,UL,
1199    def_str,ss_none},
1200   {"mus_e3m7", {0,&S_music_files[mus_e3m7]}, {0,"e2m7.mp3"},UL,UL,
1201    def_str,ss_none},
1202   {"mus_e3m8", {0,&S_music_files[mus_e3m8]}, {0,"e3m8.mp3"},UL,UL,
1203    def_str,ss_none},
1204   {"mus_e3m9", {0,&S_music_files[mus_e3m9]}, {0,"e1m9.mp3"},UL,UL,
1205    def_str,ss_none},
1206   {"mus_inter", {0,&S_music_files[mus_inter]}, {0,"e2m3.mp3"},UL,UL,
1207    def_str,ss_none},
1208   {"mus_intro", {0,&S_music_files[mus_intro]}, {0,"intro.mp3"},UL,UL,
1209    def_str,ss_none},
1210   {"mus_bunny", {0,&S_music_files[mus_bunny]}, {0,"bunny.mp3"},UL,UL,
1211    def_str,ss_none},
1212   {"mus_victor", {0,&S_music_files[mus_victor]}, {0,"victor.mp3"},UL,UL,
1213    def_str,ss_none},
1214   {"mus_introa", {0,&S_music_files[mus_introa]}, {0,"intro.mp3"},UL,UL,
1215    def_str,ss_none},
1216   {"mus_runnin", {0,&S_music_files[mus_runnin]}, {0,"runnin.mp3"},UL,UL,
1217    def_str,ss_none},
1218   {"mus_stalks", {0,&S_music_files[mus_stalks]}, {0,"stalks.mp3"},UL,UL,
1219    def_str,ss_none},
1220   {"mus_countd", {0,&S_music_files[mus_countd]}, {0,"countd.mp3"},UL,UL,
1221    def_str,ss_none},
1222   {"mus_betwee", {0,&S_music_files[mus_betwee]}, {0,"betwee.mp3"},UL,UL,
1223    def_str,ss_none},
1224   {"mus_doom", {0,&S_music_files[mus_doom]}, {0,"doom.mp3"},UL,UL,
1225    def_str,ss_none},
1226   {"mus_the_da", {0,&S_music_files[mus_the_da]}, {0,"the_da.mp3"},UL,UL,
1227    def_str,ss_none},
1228   {"mus_shawn", {0,&S_music_files[mus_shawn]}, {0,"shawn.mp3"},UL,UL,
1229    def_str,ss_none},
1230   {"mus_ddtblu", {0,&S_music_files[mus_ddtblu]}, {0,"ddtblu.mp3"},UL,UL,
1231    def_str,ss_none},
1232   {"mus_in_cit", {0,&S_music_files[mus_in_cit]}, {0,"in_cit.mp3"},UL,UL,
1233    def_str,ss_none},
1234   {"mus_dead", {0,&S_music_files[mus_dead]}, {0,"dead.mp3"},UL,UL,
1235    def_str,ss_none},
1236   {"mus_stlks2", {0,&S_music_files[mus_stlks2]}, {0,"stalks.mp3"},UL,UL,
1237    def_str,ss_none},
1238   {"mus_theda2", {0,&S_music_files[mus_theda2]}, {0,"the_da.mp3"},UL,UL,
1239    def_str,ss_none},
1240   {"mus_doom2", {0,&S_music_files[mus_doom2]}, {0,"doom.mp3"},UL,UL,
1241    def_str,ss_none},
1242   {"mus_ddtbl2", {0,&S_music_files[mus_ddtbl2]}, {0,"ddtblu.mp3"},UL,UL,
1243    def_str,ss_none},
1244   {"mus_runni2", {0,&S_music_files[mus_runni2]}, {0,"runnin.mp3"},UL,UL,
1245    def_str,ss_none},
1246   {"mus_dead2", {0,&S_music_files[mus_dead2]}, {0,"dead.mp3"},UL,UL,
1247    def_str,ss_none},
1248   {"mus_stlks3", {0,&S_music_files[mus_stlks3]}, {0,"stalks.mp3"},UL,UL,
1249    def_str,ss_none},
1250   {"mus_romero", {0,&S_music_files[mus_romero]}, {0,"romero.mp3"},UL,UL,
1251    def_str,ss_none},
1252   {"mus_shawn2", {0,&S_music_files[mus_shawn2]}, {0,"shawn.mp3"},UL,UL,
1253    def_str,ss_none},
1254   {"mus_messag", {0,&S_music_files[mus_messag]}, {0,"messag.mp3"},UL,UL,
1255    def_str,ss_none},
1256   {"mus_count2", {0,&S_music_files[mus_count2]}, {0,"countd.mp3"},UL,UL,
1257    def_str,ss_none},
1258   {"mus_ddtbl3", {0,&S_music_files[mus_ddtbl3]}, {0,"ddtblu.mp3"},UL,UL,
1259    def_str,ss_none},
1260   {"mus_ampie", {0,&S_music_files[mus_ampie]}, {0,"ampie.mp3"},UL,UL,
1261    def_str,ss_none},
1262   {"mus_theda3", {0,&S_music_files[mus_theda3]}, {0,"the_da.mp3"},UL,UL,
1263    def_str,ss_none},
1264   {"mus_adrian", {0,&S_music_files[mus_adrian]}, {0,"adrian.mp3"},UL,UL,
1265    def_str,ss_none},
1266   {"mus_messg2", {0,&S_music_files[mus_messg2]}, {0,"messag.mp3"},UL,UL,
1267    def_str,ss_none},
1268   {"mus_romer2", {0,&S_music_files[mus_romer2]}, {0,"romero.mp3"},UL,UL,
1269    def_str,ss_none},
1270   {"mus_tense", {0,&S_music_files[mus_tense]}, {0,"tense.mp3"},UL,UL,
1271    def_str,ss_none},
1272   {"mus_shawn3", {0,&S_music_files[mus_shawn3]}, {0,"shawn.mp3"},UL,UL,
1273    def_str,ss_none},
1274   {"mus_openin", {0,&S_music_files[mus_openin]}, {0,"openin.mp3"},UL,UL,
1275    def_str,ss_none},
1276   {"mus_evil", {0,&S_music_files[mus_evil]}, {0,"evil.mp3"},UL,UL,
1277    def_str,ss_none},
1278   {"mus_ultima", {0,&S_music_files[mus_ultima]}, {0,"ultima.mp3"},UL,UL,
1279    def_str,ss_none},
1280   {"mus_read_m", {0,&S_music_files[mus_read_m]}, {0,"read_m.mp3"},UL,UL,
1281    def_str,ss_none},
1282   {"mus_dm2ttl", {0,&S_music_files[mus_dm2ttl]}, {0,"dm2ttl.mp3"},UL,UL,
1283    def_str,ss_none},
1284   {"mus_dm2int", {0,&S_music_files[mus_dm2int]}, {0,"dm2int.mp3"},UL,UL,
1285    def_str,ss_none},
1286 };
1287 
1288 int numdefaults;
1289 static char* defaultfile; // CPhipps - static, const
1290 
1291 //
1292 // M_SaveDefaults
1293 //
1294 
M_SaveDefaults(void)1295 void M_SaveDefaults (void)
1296 {
1297   int   i;
1298   FILE* f;
1299 
1300   f = fopen (defaultfile, "w");
1301   if (!f)
1302     return; // can't write the file, but don't complain
1303 
1304   // 3/3/98 explain format of file
1305 
1306   fprintf(f,"# Doom config file\n");
1307   fprintf(f,"# Format:\n");
1308   fprintf(f,"# variable   value\n");
1309 
1310   for (i = 0 ; i < numdefaults ; i++) {
1311     if (defaults[i].type == def_none) {
1312       // CPhipps - pure headers
1313       fprintf(f, "\n# %s\n", defaults[i].name);
1314     } else
1315       // e6y: arrays
1316       if (defaults[i].type == def_arr)
1317       {
1318         int k;
1319         fprintf (f,"%-25s \"%s\"\n",defaults[i].name,*(defaults[i].location.ppsz));
1320         for (k = 0; k < *(defaults[i].location.array_size); k++)
1321         {
1322           char ***arr = defaults[i].location.array_data;
1323           if ((*arr)[k])
1324           {
1325             char def[80];
1326             sprintf(def, "%s%d", *(defaults[i].location.ppsz), k);
1327             fprintf (f,"%-25s \"%s\"\n",def, (*arr)[k]);
1328           }
1329         }
1330         i += defaults[i].defaultvalue.array_size;
1331       }
1332       else
1333 
1334     // CPhipps - modified for new default_t form
1335     if (!IS_STRING(defaults[i])) //jff 4/10/98 kill super-hack on pointer value
1336       {
1337       // CPhipps - remove keycode hack
1338       // killough 3/6/98: use spaces instead of tabs for uniform justification
1339       if (defaults[i].type == def_hex)
1340   fprintf (f,"%-25s 0x%x\n",defaults[i].name,*(defaults[i].location.pi));
1341       else
1342   fprintf (f,"%-25s %5i\n",defaults[i].name,*(defaults[i].location.pi));
1343       }
1344     else
1345       {
1346       fprintf (f,"%-25s \"%s\"\n",defaults[i].name,*(defaults[i].location.ppsz));
1347       }
1348     }
1349 
1350   fclose (f);
1351 }
1352 
1353 /*
1354  * M_LookupDefault
1355  *
1356  * cph - mimic MBF function for now. Yes it's crap.
1357  */
1358 
M_LookupDefault(const char * name)1359 struct default_s *M_LookupDefault(const char *name)
1360 {
1361   int i;
1362   for (i = 0 ; i < numdefaults ; i++)
1363   {
1364     if ((defaults[i].type != def_none) && !strcmp(name, defaults[i].name))
1365       return &defaults[i];
1366   }
1367 
1368   I_Error("M_LookupDefault: %s not found",name);
1369   return NULL;
1370 }
1371 
1372 //
1373 // M_LoadDefaults
1374 //
1375 
1376 #define NUMCHATSTRINGS 10 // phares 4/13/98
1377 
1378 #define CFG_BUFFERMAX 32000
1379 
M_LoadDefaults(void)1380 void M_LoadDefaults (void)
1381 {
1382   int   i;
1383   int   len;
1384   FILE* f;
1385   char  def[80];
1386   char* strparm = malloc(CFG_BUFFERMAX);
1387   char* cfgline = malloc(CFG_BUFFERMAX);
1388   char* newstring = NULL;   // killough
1389   int   parm;
1390   dboolean isstring;
1391   // e6y: arrays
1392   default_t *item = NULL;
1393 
1394   // set everything to base values
1395 
1396   numdefaults = sizeof(defaults)/sizeof(defaults[0]);
1397   for (i = 0 ; i < numdefaults ; i++) {
1398     if (defaults[i].location.ppsz)
1399       *defaults[i].location.ppsz = strdup(defaults[i].defaultvalue.psz);
1400     if (defaults[i].location.pi)
1401       *defaults[i].location.pi = defaults[i].defaultvalue.i;
1402   }
1403 
1404   //e6y: arrays
1405   for (i = 0 ; i < numdefaults ; i++) {
1406     if (defaults[i].type == def_arr)
1407     {
1408       int k;
1409       default_t *item = &defaults[i];
1410       char ***arr = (char***)(item->location.array_data);
1411       // free memory
1412       for (k = 0; k < *(item->location.array_size); k++)
1413       {
1414         if ((*arr)[k])
1415         {
1416           free((*arr)[k]);
1417           (*arr)[k] = NULL;
1418         }
1419       }
1420       free(*arr);
1421       *arr = NULL;
1422       *(item->location.array_size) = 0;
1423       // load predefined data
1424       *arr = realloc(*arr, sizeof(char*) * item->defaultvalue.array_size);
1425       *(item->location.array_size) = item->defaultvalue.array_size;
1426       item->location.array_index = 0;
1427       for (k = 0; k < item->defaultvalue.array_size; k++)
1428       {
1429         if (item->defaultvalue.array_data[k])
1430           (*arr)[k] = strdup(item->defaultvalue.array_data[k]);
1431         else
1432           (*arr)[k] = strdup("");
1433       }
1434     }
1435   }
1436 
1437   // check for a custom default file
1438 
1439   i = M_CheckParm ("-config");
1440   if (i && i < myargc-1)
1441   {
1442     defaultfile = strdup(myargv[i+1]);
1443   }
1444   else
1445   {
1446     const char* exedir = I_DoomExeDir();
1447     defaultfile = malloc(PATH_MAX+1);
1448     /* get config file from same directory as executable */
1449     SNPRINTF(defaultfile, PATH_MAX,
1450             "%s%s%sboom-plus.cfg", exedir, HasTrailingSlash(exedir) ? "" : "/",
1451 #if ((defined GL_DOOM) && (defined _MSC_VER))
1452             "gl");
1453 #else
1454             "pr");
1455 #endif
1456   }
1457 
1458   lprintf (LO_CONFIRM, " default file: %s\n",defaultfile);
1459 
1460   // read the file in, overriding any set defaults
1461 
1462   f = fopen (defaultfile, "r");
1463   if (f)
1464     {
1465     while (!feof(f))
1466       {
1467       isstring = false;
1468       parm = 0;
1469       fgets(cfgline, CFG_BUFFERMAX, f);
1470       if (sscanf (cfgline, "%79s %[^\n]\n", def, strparm) == 2)
1471         {
1472 
1473         //jff 3/3/98 skip lines not starting with an alphanum
1474 
1475         if (!isalnum(def[0]))
1476           continue;
1477 
1478         if (strparm[0] == '"') {
1479           // get a string default
1480 
1481           isstring = true;
1482           len = strlen(strparm);
1483           newstring = malloc(len);
1484           strparm[len-1] = 0; // clears trailing double-quote mark
1485           strcpy(newstring, strparm+1); // clears leading double-quote mark
1486   } else if ((strparm[0] == '0') && (strparm[1] == 'x')) {
1487     // CPhipps - allow ints to be specified in hex
1488     sscanf(strparm+2, "%x", &parm);
1489   } else {
1490           sscanf(strparm, "%i", &parm);
1491     // Keycode hack removed
1492   }
1493 
1494         // e6y: arrays
1495         if (item)
1496         {
1497           int *pcount = item->location.array_size;
1498           int *index = &item->location.array_index;
1499           char ***arr = (char***)(item->location.array_data);
1500           if (!strncmp(def, *(item->location.ppsz), strlen(*(item->location.ppsz)))
1501               && ((item->maxvalue == UL) || *(item->location.array_size) < item->maxvalue) )
1502           {
1503             if ((*index) + 1 > *pcount)
1504             {
1505               *arr = realloc(*arr, sizeof(char*) * ((*index) + 1));
1506               (*pcount)++;
1507             }
1508             else
1509             {
1510               if ((*arr)[(*index)])
1511               {
1512                 free((*arr)[(*index)]);
1513                 (*arr)[(*index)] = NULL;
1514               }
1515             }
1516             (*arr)[(*index)] = newstring;
1517             (*index)++;
1518             continue;
1519           }
1520           else
1521           {
1522             item = NULL;
1523           }
1524         }
1525 
1526         for (i = 0 ; i < numdefaults ; i++)
1527           if ((defaults[i].type != def_none) && !strcmp(def, defaults[i].name))
1528             {
1529               // e6y: arrays
1530               if (defaults[i].type == def_arr)
1531               {
1532                 union { const char **c; char **s; } u; // type punning via unions
1533 
1534                 u.c = defaults[i].location.ppsz;
1535                 free(*(u.s));
1536                 *(u.s) = newstring;
1537 
1538                 item = &defaults[i];
1539                 continue;
1540               }
1541 
1542       // CPhipps - safety check
1543             if (isstring != IS_STRING(defaults[i])) {
1544         lprintf(LO_WARN, "M_LoadDefaults: Type mismatch reading %s\n", defaults[i].name);
1545         continue;
1546       }
1547             if (!isstring)
1548               {
1549 
1550               //jff 3/4/98 range check numeric parameters
1551 
1552               if ((defaults[i].minvalue==UL || defaults[i].minvalue<=parm) &&
1553                   (defaults[i].maxvalue==UL || defaults[i].maxvalue>=parm))
1554                 *(defaults[i].location.pi) = parm;
1555               }
1556             else
1557               {
1558                 union { const char **c; char **s; } u; // type punning via unions
1559 
1560                 u.c = defaults[i].location.ppsz;
1561                 free(*(u.s));
1562                 *(u.s) = newstring;
1563               }
1564             break;
1565             }
1566         }
1567       }
1568 
1569     fclose (f);
1570     }
1571 
1572   free(strparm);
1573   free(cfgline);
1574 
1575   //jff 3/4/98 redundant range checks for hud deleted here
1576   /* proff 2001/7/1 - added prboom.wad as last entry so it's always loaded and
1577      doesn't overlap with the cfg settings */
1578   //e6y: Check on existence of prboom.wad
1579 #ifndef ALL_IN_ONE
1580   if (!(wad_files[MAXLOADFILES-1] = I_FindFile("prboom-plus.wad", "")))
1581     I_Error("PrBoom-Plus.wad not found. Can't continue.");
1582 #endif
1583 }
1584 
1585 
1586 //
1587 // SCREEN SHOTS
1588 //
1589 
1590 //
1591 // M_ScreenShot
1592 //
1593 // Modified by Lee Killough so that any number of shots can be taken,
1594 // the code is faster, and no annoying "screenshot" message appears.
1595 
1596 // CPhipps - modified to use its own buffer for the image
1597 //         - checks for the case where no file can be created (doesn't occur on POSIX systems, would on DOS)
1598 //         - track errors better
1599 //         - split into 2 functions
1600 
1601 //
1602 // M_DoScreenShot
1603 // Takes a screenshot into the names file
1604 
1605 const char *screenshot_dir;
1606 
M_DoScreenShot(const char * fname)1607 void M_DoScreenShot (const char* fname)
1608 {
1609   if (I_ScreenShot(fname) != 0)
1610     doom_printf("M_ScreenShot: Error writing screenshot\n");
1611 }
1612 
1613 #ifndef SCREENSHOT_DIR
1614 #define SCREENSHOT_DIR "."
1615 #endif
1616 
1617 #ifdef HAVE_LIBPNG
1618 #define SCREENSHOT_EXT ".png"
1619 #else
1620 #define SCREENSHOT_EXT ".bmp"
1621 #endif
1622 
M_CheckWritableDir(const char * dir)1623 const char* M_CheckWritableDir(const char *dir)
1624 {
1625   static char *base = NULL;
1626   static int base_len = 0;
1627 
1628   const char *result = NULL;
1629   int len;
1630 
1631   if (!dir || !(len = strlen(dir)))
1632   {
1633     return NULL;
1634   }
1635 
1636   if (len + 1 > base_len)
1637   {
1638     base_len = len + 1;
1639     base = malloc(len + 1);
1640   }
1641 
1642   if (base)
1643   {
1644     strcpy(base, dir);
1645 
1646     if (base[len - 1] != '\\' && base[len - 1] != '/')
1647       strcat(base, "/");
1648     if (!access(base, O_RDWR))
1649     {
1650       base[strlen(base) - 1] = 0;
1651       result = base;
1652     }
1653   }
1654 
1655   return result;
1656 }
1657 
M_ScreenShot(void)1658 void M_ScreenShot(void)
1659 {
1660   static int shot;
1661   char       lbmname[PATH_MAX + 1];
1662   int        startshot;
1663   const char *shot_dir = NULL;
1664   int p;
1665 
1666   if ((p = M_CheckParm("-shotdir")) && (p < myargc - 1))
1667     shot_dir = M_CheckWritableDir(myargv[p + 1]);
1668   if (!shot_dir)
1669     shot_dir = M_CheckWritableDir(screenshot_dir);
1670   if (!shot_dir)
1671 #ifdef _WIN32
1672     shot_dir = M_CheckWritableDir(I_DoomExeDir());
1673 #else
1674     shot_dir = (!access(SCREENSHOT_DIR, 2) ? SCREENSHOT_DIR : NULL);
1675 #endif
1676 
1677   if (shot_dir)
1678   {
1679     startshot = shot; // CPhipps - prevent infinite loop
1680 
1681     do {
1682       sprintf(lbmname,"%s/doom%02d" SCREENSHOT_EXT, shot_dir, shot++);
1683     } while (!access(lbmname,0) && (shot != startshot) && (shot < 10000));
1684 
1685     if (access(lbmname,0))
1686     {
1687       S_StartSound(NULL,gamemode==commercial ? sfx_radio : sfx_tink);
1688       M_DoScreenShot(lbmname); // cph
1689       return;
1690     }
1691   }
1692 
1693   doom_printf ("M_ScreenShot: Couldn't create screenshot");
1694   return;
1695 }
1696 
M_StrToInt(const char * s,int * l)1697 int M_StrToInt(const char *s, int *l)
1698 {
1699   return (
1700     (sscanf(s, " 0x%x", l) == 1) ||
1701     (sscanf(s, " 0X%x", l) == 1) ||
1702     (sscanf(s, " 0%o", l) == 1) ||
1703     (sscanf(s, " %d", l) == 1)
1704   );
1705 }
1706 
M_StrToFloat(const char * s,float * f)1707 int M_StrToFloat(const char *s, float *f)
1708 {
1709   return (
1710     (sscanf(s, " %f", f) == 1)
1711   );
1712 }
1713 
M_DoubleToInt(double x)1714 int M_DoubleToInt(double x)
1715 {
1716 #ifdef __GNUC__
1717  double tmp = x;
1718  return (int)tmp;
1719 #else
1720  return (int)x;
1721 #endif
1722 }
1723 
M_Strlwr(char * str)1724 char* M_Strlwr(char* str)
1725 {
1726   char* p;
1727   for (p=str; *p; p++) *p = tolower(*p);
1728   return str;
1729 }
1730 
M_Strupr(char * str)1731 char* M_Strupr(char* str)
1732 {
1733   char* p;
1734   for (p=str; *p; p++) *p = toupper(*p);
1735   return str;
1736 }
1737