Subversion Repositories Kolibri OS

Rev

Rev 300 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 300 Rev 550
1
// Emacs style mode select   -*- C++ -*- 
1
// Emacs style mode select   -*- C++ -*- 
2
//-----------------------------------------------------------------------------
2
//-----------------------------------------------------------------------------
3
//
3
//
4
// $Id:$
4
// $Id:$
5
//
5
//
6
// Copyright (C) 1993-1996 by id Software, Inc.
6
// Copyright (C) 1993-1996 by id Software, Inc.
7
//
7
//
8
// This source is available for distribution and/or modification
8
// This source is available for distribution and/or modification
9
// only under the terms of the DOOM Source Code License as
9
// only under the terms of the DOOM Source Code License as
10
// published by id Software. All rights reserved.
10
// published by id Software. All rights reserved.
11
//
11
//
12
// The source is distributed in the hope that it will be useful,
12
// The source is distributed in the hope that it will be useful,
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14
// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
14
// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
15
// for more details.
15
// for more details.
16
//
16
//
17
// $Log:$
17
// $Log:$
18
//
18
//
19
// DESCRIPTION:
19
// DESCRIPTION:
20
//	DOOM selection menu, options, episode etc.
20
//      DOOM selection menu, options, episode etc.
21
//	Sliders and icons. Kinda widget stuff.
21
//      Sliders and icons. Kinda widget stuff.
22
//
22
//
23
//-----------------------------------------------------------------------------
23
//-----------------------------------------------------------------------------
24
 
24
 
25
static const char
25
static const char
26
rcsid[] = "$Id: m_menu.c,v 1.7 1997/02/03 22:45:10 b1 Exp $";
26
rcsid[] = "$Id: m_menu.c,v 1.7 1997/02/03 22:45:10 b1 Exp $";
27
 
27
 
28
#include 
28
#include 
29
#include 
29
#include 
30
 
30
 
31
#include "m_swap.h"
31
#include "m_swap.h"
32
#include "doomdef.h"
32
#include "doomdef.h"
33
#include "dstrings.h"
33
#include "dstrings.h"
34
 
34
 
35
#include "d_main.h"
35
#include "d_main.h"
36
 
36
 
37
#include "i_system.h"
37
#include "i_system.h"
38
#include "i_video.h"
38
#include "i_video.h"
39
#include "z_zone.h"
39
#include "z_zone.h"
40
#include "v_video.h"
40
#include "v_video.h"
41
#include "w_wad.h"
41
#include "w_wad.h"
42
 
42
 
43
#include "r_local.h"
43
#include "r_local.h"
44
 
44
 
45
 
45
 
46
#include "hu_stuff.h"
46
#include "hu_stuff.h"
47
 
47
 
48
#include "g_game.h"
48
#include "g_game.h"
49
 
49
 
50
#include "m_argv.h"
50
#include "m_argv.h"
51
 
51
 
52
#include "s_sound.h"
52
#include "s_sound.h"
53
 
53
 
54
#include "doomstat.h"
54
#include "doomstat.h"
55
 
55
 
56
// Data.
56
// Data.
57
#include "sounds.h"
57
#include "sounds.h"
58
 
58
 
59
#include "m_menu.h"
59
#include "m_menu.h"
60
 
60
 
61
 
61
 
62
 
62
 
63
extern patch_t*		hu_font[HU_FONTSIZE];
63
extern patch_t*         hu_font[HU_FONTSIZE];
64
extern boolean		message_dontfuckwithme;
64
extern boolean          message_dontfuckwithme;
65
 
65
 
66
extern boolean		chat_on;		// in heads-up code
66
extern boolean          chat_on;                // in heads-up code
67
 
67
 
68
//
68
//
69
// defaulted values
69
// defaulted values
70
//
70
//
71
int			mouseSensitivity;       // has default
71
int                     mouseSensitivity;       // has default
72
 
72
 
73
// Show messages has default, 0 = off, 1 = on
73
// Show messages has default, 0 = off, 1 = on
74
int			showMessages;
74
int                     showMessages;
75
	
75
        
76
 
76
 
77
// Blocky mode, has default, 0 = high, 1 = normal
77
// Blocky mode, has default, 0 = high, 1 = normal
78
int			detailLevel;		
78
int                     detailLevel;            
79
int			screenblocks;		// has default
79
int                     screenblocks;           // has default
80
 
80
 
81
// temp for screenblocks (0-9)
81
// temp for screenblocks (0-9)
82
int			screenSize;		
82
int                     screenSize;             
83
 
83
 
84
// -1 = no quicksave slot picked!
84
// -1 = no quicksave slot picked!
85
int			quickSaveSlot;          
85
int                     quickSaveSlot;          
86
 
86
 
87
 // 1 = message to be printed
87
 // 1 = message to be printed
88
int			messageToPrint;
88
int                     messageToPrint;
89
// ...and here is the message string!
89
// ...and here is the message string!
90
char*			messageString;		
90
char*                   messageString;          
91
 
91
 
92
// message x & y
92
// message x & y
93
int			messx;			
93
int                     messx;                  
94
int			messy;
94
int                     messy;
95
int			messageLastMenuActive;
95
int                     messageLastMenuActive;
96
 
96
 
97
// timed message = no input from user
97
// timed message = no input from user
98
boolean			messageNeedsInput;     
98
boolean                 messageNeedsInput;     
99
 
99
 
100
void    (*messageRoutine)(int response);
100
void    (*messageRoutine)(int response);
101
 
101
 
102
#define SAVESTRINGSIZE 	24
102
#define SAVESTRINGSIZE  24
103
 
103
 
104
char gammamsg[5][26] =
104
char gammamsg[5][26] =
105
{
105
{
106
    GAMMALVL0,
106
    GAMMALVL0,
107
    GAMMALVL1,
107
    GAMMALVL1,
108
    GAMMALVL2,
108
    GAMMALVL2,
109
    GAMMALVL3,
109
    GAMMALVL3,
110
    GAMMALVL4
110
    GAMMALVL4
111
};
111
};
112
 
112
 
113
// we are going to be entering a savegame string
113
// we are going to be entering a savegame string
114
int			saveStringEnter;              
114
int                     saveStringEnter;              
115
int             	saveSlot;	// which slot to save in
115
int                     saveSlot;       // which slot to save in
116
int			saveCharIndex;	// which char we're editing
116
int                     saveCharIndex;  // which char we're editing
117
// old save description before edit
117
// old save description before edit
118
char			saveOldString[SAVESTRINGSIZE];  
118
char                    saveOldString[SAVESTRINGSIZE];  
119
 
119
 
120
boolean			inhelpscreens;
120
boolean                 inhelpscreens;
121
boolean			menuactive;
121
boolean                 menuactive;
122
 
122
 
123
#define SKULLXOFF		-32
123
#define SKULLXOFF               -32
124
#define LINEHEIGHT		16
124
#define LINEHEIGHT              16
125
 
125
 
126
extern boolean		sendpause;
126
extern boolean          sendpause;
127
char			savegamestrings[10][SAVESTRINGSIZE];
127
char                    savegamestrings[10][SAVESTRINGSIZE];
128
 
128
 
129
char	endstring[160];
129
char    endstring[160];
130
 
130
 
131
 
131
 
132
//
132
//
133
// MENU TYPEDEFS
133
// MENU TYPEDEFS
134
//
134
//
135
typedef struct
135
typedef struct
136
{
136
{
137
    // 0 = no cursor here, 1 = ok, 2 = arrows ok
137
    // 0 = no cursor here, 1 = ok, 2 = arrows ok
138
    short	status;
138
    short       status;
139
    
139
    
140
    char	name[10];
140
    char        name[10];
141
    
141
    
142
    // choice = menu item #.
142
    // choice = menu item #.
143
    // if status = 2,
143
    // if status = 2,
144
    //   choice=0:leftarrow,1:rightarrow
144
    //   choice=0:leftarrow,1:rightarrow
145
    void	(*routine)(int choice);
145
    void        (*routine)(int choice);
146
    
146
    
147
    // hotkey in menu
147
    // hotkey in menu
148
    char	alphaKey;			
148
    char        alphaKey;                       
149
} menuitem_t;
149
} menuitem_t;
150
 
150
 
151
 
151
 
152
 
152
 
153
typedef struct menu_s
153
typedef struct menu_s
154
{
154
{
155
    short		numitems;	// # of menu items
155
    short               numitems;       // # of menu items
156
    struct menu_s*	prevMenu;	// previous menu
156
    struct menu_s*      prevMenu;       // previous menu
157
    menuitem_t*		menuitems;	// menu items
157
    menuitem_t*         menuitems;      // menu items
158
    void		(*routine)();	// draw routine
158
    void                (*routine)();   // draw routine
159
    short		x;
159
    short               x;
160
    short		y;		// x,y of menu
160
    short               y;              // x,y of menu
161
    short		lastOn;		// last item user was on in menu
161
    short               lastOn;         // last item user was on in menu
162
} menu_t;
162
} menu_t;
163
 
163
 
164
short		itemOn;			// menu item skull is on
164
short           itemOn;                 // menu item skull is on
165
short		skullAnimCounter;	// skull animation counter
165
short           skullAnimCounter;       // skull animation counter
166
short		whichSkull;		// which skull to draw
166
short           whichSkull;             // which skull to draw
167
 
167
 
168
// graphic name of skulls
168
// graphic name of skulls
169
// warning: initializer-string for array of chars is too long
169
// warning: initializer-string for array of chars is too long
170
char    skullName[2][/*8*/9] = {"M_SKULL1","M_SKULL2"};
170
char    skullName[2][/*8*/9] = {"M_SKULL1","M_SKULL2"};
171
 
171
 
172
// current menudef
172
// current menudef
173
menu_t*	currentMenu;                          
173
menu_t* currentMenu;                          
174
 
174
 
175
//
175
//
176
// PROTOTYPES
176
// PROTOTYPES
177
//
177
//
178
void M_NewGame(int choice);
178
void M_NewGame(int choice);
179
void M_Episode(int choice);
179
void M_Episode(int choice);
180
void M_ChooseSkill(int choice);
180
void M_ChooseSkill(int choice);
181
void M_LoadGame(int choice);
181
void M_LoadGame(int choice);
182
void M_SaveGame(int choice);
182
void M_SaveGame(int choice);
183
void M_Options(int choice);
183
void M_Options(int choice);
184
void M_EndGame(int choice);
184
void M_EndGame(int choice);
185
void M_ReadThis(int choice);
185
void M_ReadThis(int choice);
186
void M_ReadThis2(int choice);
186
void M_ReadThis2(int choice);
187
void M_QuitDOOM(int choice);
187
void M_QuitDOOM(int choice);
188
 
188
 
189
void M_ChangeMessages(int choice);
189
void M_ChangeMessages(int choice);
190
void M_ChangeSensitivity(int choice);
190
void M_ChangeSensitivity(int choice);
191
void M_SfxVol(int choice);
191
void M_SfxVol(int choice);
192
void M_MusicVol(int choice);
192
void M_MusicVol(int choice);
193
void M_ChangeDetail(int choice);
193
void M_ChangeDetail(int choice);
194
void M_SizeDisplay(int choice);
194
void M_SizeDisplay(int choice);
195
void M_StartGame(int choice);
195
void M_StartGame(int choice);
196
void M_Sound(int choice);
196
void M_Sound(int choice);
197
 
197
 
198
void M_FinishReadThis(int choice);
198
void M_FinishReadThis(int choice);
199
void M_LoadSelect(int choice);
199
void M_LoadSelect(int choice);
200
void M_SaveSelect(int choice);
200
void M_SaveSelect(int choice);
201
void M_ReadSaveStrings(void);
201
void M_ReadSaveStrings(void);
202
void M_QuickSave(void);
202
void M_QuickSave(void);
203
void M_QuickLoad(void);
203
void M_QuickLoad(void);
204
 
204
 
205
void M_DrawMainMenu(void);
205
void M_DrawMainMenu(void);
206
void M_DrawReadThis1(void);
206
void M_DrawReadThis1(void);
207
void M_DrawReadThis2(void);
207
void M_DrawReadThis2(void);
208
void M_DrawNewGame(void);
208
void M_DrawNewGame(void);
209
void M_DrawEpisode(void);
209
void M_DrawEpisode(void);
210
void M_DrawOptions(void);
210
void M_DrawOptions(void);
211
void M_DrawSound(void);
211
void M_DrawSound(void);
212
void M_DrawLoad(void);
212
void M_DrawLoad(void);
213
void M_DrawSave(void);
213
void M_DrawSave(void);
214
 
214
 
215
void M_DrawSaveLoadBorder(int x,int y);
215
void M_DrawSaveLoadBorder(int x,int y);
216
void M_SetupNextMenu(menu_t *menudef);
216
void M_SetupNextMenu(menu_t *menudef);
217
void M_DrawThermo(int x,int y,int thermWidth,int thermDot);
217
void M_DrawThermo(int x,int y,int thermWidth,int thermDot);
218
void M_DrawEmptyCell(menu_t *menu,int item);
218
void M_DrawEmptyCell(menu_t *menu,int item);
219
void M_DrawSelCell(menu_t *menu,int item);
219
void M_DrawSelCell(menu_t *menu,int item);
220
void M_WriteText(int x, int y, char *string);
220
void M_WriteText(int x, int y, char *string);
221
int  M_StringWidth(char *string);
221
int  M_StringWidth(char *string);
222
int  M_StringHeight(char *string);
222
int  M_StringHeight(char *string);
223
void M_StartControlPanel(void);
223
void M_StartControlPanel(void);
224
void M_StartMessage(char *string,void *routine,boolean input);
224
void M_StartMessage(char *string,void *routine,boolean input);
225
void M_StopMessage(void);
225
void M_StopMessage(void);
226
void M_ClearMenus (void);
226
void M_ClearMenus (void);
227
 
227
 
228
 
228
 
229
 
229
 
230
 
230
 
231
//
231
//
232
// DOOM MENU
232
// DOOM MENU
233
//
233
//
234
enum
234
enum
235
{
235
{
236
    newgame = 0,
236
    newgame = 0,
237
    options,
237
    options,
238
    loadgame,
238
    loadgame,
239
    savegame,
239
    savegame,
240
    readthis,
240
    readthis,
241
    quitdoom,
241
    quitdoom,
242
    main_end
242
    main_end
243
} main_e;
243
} main_e;
244
 
244
 
245
menuitem_t MainMenu[]=
245
menuitem_t MainMenu[]=
246
{
246
{
247
    {1,"M_NGAME",M_NewGame,'n'},
247
    {1,"M_NGAME",M_NewGame,'n'},
248
    {1,"M_OPTION",M_Options,'o'},
248
    {1,"M_OPTION",M_Options,'o'},
249
    {1,"M_LOADG",M_LoadGame,'l'},
249
    {1,"M_LOADG",M_LoadGame,'l'},
250
    {1,"M_SAVEG",M_SaveGame,'s'},
250
    {1,"M_SAVEG",M_SaveGame,'s'},
251
    // Another hickup with Special edition.
251
    // Another hickup with Special edition.
252
    {1,"M_RDTHIS",M_ReadThis,'r'},
252
    {1,"M_RDTHIS",M_ReadThis,'r'},
253
    {1,"M_QUITG",M_QuitDOOM,'q'}
253
    {1,"M_QUITG",M_QuitDOOM,'q'}
254
};
254
};
255
 
255
 
256
menu_t  MainDef =
256
menu_t  MainDef =
257
{
257
{
258
    main_end,
258
    main_end,
259
    NULL,
259
    NULL,
260
    MainMenu,
260
    MainMenu,
261
    M_DrawMainMenu,
261
    M_DrawMainMenu,
262
    97,64,
262
    97,64,
263
    0
263
    0
264
};
264
};
265
 
265
 
266
 
266
 
267
//
267
//
268
// EPISODE SELECT
268
// EPISODE SELECT
269
//
269
//
270
enum
270
enum
271
{
271
{
272
    ep1,
272
    ep1,
273
    ep2,
273
    ep2,
274
    ep3,
274
    ep3,
275
    ep4,
275
    ep4,
276
    ep_end
276
    ep_end
277
} episodes_e;
277
} episodes_e;
278
 
278
 
279
menuitem_t EpisodeMenu[]=
279
menuitem_t EpisodeMenu[]=
280
{
280
{
281
    {1,"M_EPI1", M_Episode,'k'},
281
    {1,"M_EPI1", M_Episode,'k'},
282
    {1,"M_EPI2", M_Episode,'t'},
282
    {1,"M_EPI2", M_Episode,'t'},
283
    {1,"M_EPI3", M_Episode,'i'},
283
    {1,"M_EPI3", M_Episode,'i'},
284
    {1,"M_EPI4", M_Episode,'t'}
284
    {1,"M_EPI4", M_Episode,'t'}
285
};
285
};
286
 
286
 
287
menu_t  EpiDef =
287
menu_t  EpiDef =
288
{
288
{
289
    ep_end,		// # of menu items
289
    ep_end,             // # of menu items
290
    &MainDef,		// previous menu
290
    &MainDef,           // previous menu
291
    EpisodeMenu,	// menuitem_t ->
291
    EpisodeMenu,        // menuitem_t ->
292
    M_DrawEpisode,	// drawing routine ->
292
    M_DrawEpisode,      // drawing routine ->
293
    48,63,              // x,y
293
    48,63,              // x,y
294
    ep1			// lastOn
294
    ep1                 // lastOn
295
};
295
};
296
 
296
 
297
//
297
//
298
// NEW GAME
298
// NEW GAME
299
//
299
//
300
enum
300
enum
301
{
301
{
302
    killthings,
302
    killthings,
303
    toorough,
303
    toorough,
304
    hurtme,
304
    hurtme,
305
    violence,
305
    violence,
306
    nightmare,
306
    nightmare,
307
    newg_end
307
    newg_end
308
} newgame_e;
308
} newgame_e;
309
 
309
 
310
menuitem_t NewGameMenu[]=
310
menuitem_t NewGameMenu[]=
311
{
311
{
312
    {1,"M_JKILL",	M_ChooseSkill, 'i'},
312
    {1,"M_JKILL",       M_ChooseSkill, 'i'},
313
    {1,"M_ROUGH",	M_ChooseSkill, 'h'},
313
    {1,"M_ROUGH",       M_ChooseSkill, 'h'},
314
    {1,"M_HURT",	M_ChooseSkill, 'h'},
314
    {1,"M_HURT",        M_ChooseSkill, 'h'},
315
    {1,"M_ULTRA",	M_ChooseSkill, 'u'},
315
    {1,"M_ULTRA",       M_ChooseSkill, 'u'},
316
    {1,"M_NMARE",	M_ChooseSkill, 'n'}
316
    {1,"M_NMARE",       M_ChooseSkill, 'n'}
317
};
317
};
318
 
318
 
319
menu_t  NewDef =
319
menu_t  NewDef =
320
{
320
{
321
    newg_end,		// # of menu items
321
    newg_end,           // # of menu items
322
    &EpiDef,		// previous menu
322
    &EpiDef,            // previous menu
323
    NewGameMenu,	// menuitem_t ->
323
    NewGameMenu,        // menuitem_t ->
324
    M_DrawNewGame,	// drawing routine ->
324
    M_DrawNewGame,      // drawing routine ->
325
    48,63,              // x,y
325
    48,63,              // x,y
326
    hurtme		// lastOn
326
    hurtme              // lastOn
327
};
327
};
328
 
328
 
329
 
329
 
330
 
330
 
331
//
331
//
332
// OPTIONS MENU
332
// OPTIONS MENU
333
//
333
//
334
enum
334
enum
335
{
335
{
336
    endgame,
336
    endgame,
337
    messages,
337
    messages,
338
    detail,
338
    detail,
339
    scrnsize,
339
    scrnsize,
340
    option_empty1,
340
    option_empty1,
341
    mousesens,
341
    mousesens,
342
    option_empty2,
342
    option_empty2,
343
    soundvol,
343
    soundvol,
344
    opt_end
344
    opt_end
345
} options_e;
345
} options_e;
346
 
346
 
347
menuitem_t OptionsMenu[]=
347
menuitem_t OptionsMenu[]=
348
{
348
{
349
    {1,"M_ENDGAM",	M_EndGame,'e'},
349
    {1,"M_ENDGAM",      M_EndGame,'e'},
350
    {1,"M_MESSG",	M_ChangeMessages,'m'},
350
    {1,"M_MESSG",       M_ChangeMessages,'m'},
351
    {1,"M_DETAIL",	M_ChangeDetail,'g'},
351
    {1,"M_DETAIL",      M_ChangeDetail,'g'},
352
    {2,"M_SCRNSZ",	M_SizeDisplay,'s'},
352
    {2,"M_SCRNSZ",      M_SizeDisplay,'s'},
353
    {-1,"",0},
353
    {-1,"",0},
354
    {2,"M_MSENS",	M_ChangeSensitivity,'m'},
354
    {2,"M_MSENS",       M_ChangeSensitivity,'m'},
355
    {-1,"",0},
355
    {-1,"",0},
356
    {1,"M_SVOL",	M_Sound,'s'}
356
    {1,"M_SVOL",        M_Sound,'s'}
357
};
357
};
358
 
358
 
359
menu_t  OptionsDef =
359
menu_t  OptionsDef =
360
{
360
{
361
    opt_end,
361
    opt_end,
362
    &MainDef,
362
    &MainDef,
363
    OptionsMenu,
363
    OptionsMenu,
364
    M_DrawOptions,
364
    M_DrawOptions,
365
    60,37,
365
    60,37,
366
    0
366
    0
367
};
367
};
368
 
368
 
369
//
369
//
370
// Read This! MENU 1 & 2
370
// Read This! MENU 1 & 2
371
//
371
//
372
enum
372
enum
373
{
373
{
374
    rdthsempty1,
374
    rdthsempty1,
375
    read1_end
375
    read1_end
376
} read_e;
376
} read_e;
377
 
377
 
378
menuitem_t ReadMenu1[] =
378
menuitem_t ReadMenu1[] =
379
{
379
{
380
    {1,"",M_ReadThis2,0}
380
    {1,"",M_ReadThis2,0}
381
};
381
};
382
 
382
 
383
menu_t  ReadDef1 =
383
menu_t  ReadDef1 =
384
{
384
{
385
    read1_end,
385
    read1_end,
386
    &MainDef,
386
    &MainDef,
387
    ReadMenu1,
387
    ReadMenu1,
388
    M_DrawReadThis1,
388
    M_DrawReadThis1,
389
    280,185,
389
    280,185,
390
    0
390
    0
391
};
391
};
392
 
392
 
393
enum
393
enum
394
{
394
{
395
    rdthsempty2,
395
    rdthsempty2,
396
    read2_end
396
    read2_end
397
} read_e2;
397
} read_e2;
398
 
398
 
399
menuitem_t ReadMenu2[]=
399
menuitem_t ReadMenu2[]=
400
{
400
{
401
    {1,"",M_FinishReadThis,0}
401
    {1,"",M_FinishReadThis,0}
402
};
402
};
403
 
403
 
404
menu_t  ReadDef2 =
404
menu_t  ReadDef2 =
405
{
405
{
406
    read2_end,
406
    read2_end,
407
    &ReadDef1,
407
    &ReadDef1,
408
    ReadMenu2,
408
    ReadMenu2,
409
    M_DrawReadThis2,
409
    M_DrawReadThis2,
410
    330,175,
410
    330,175,
411
    0
411
    0
412
};
412
};
413
 
413
 
414
//
414
//
415
// SOUND VOLUME MENU
415
// SOUND VOLUME MENU
416
//
416
//
417
enum
417
enum
418
{
418
{
419
    sfx_vol,
419
    sfx_vol,
420
    sfx_empty1,
420
    sfx_empty1,
421
    music_vol,
421
    music_vol,
422
    sfx_empty2,
422
    sfx_empty2,
423
    sound_end
423
    sound_end
424
} sound_e;
424
} sound_e;
425
 
425
 
426
menuitem_t SoundMenu[]=
426
menuitem_t SoundMenu[]=
427
{
427
{
428
    {2,"M_SFXVOL",M_SfxVol,'s'},
428
    {2,"M_SFXVOL",M_SfxVol,'s'},
429
    {-1,"",0},
429
    {-1,"",0},
430
    {2,"M_MUSVOL",M_MusicVol,'m'},
430
    {2,"M_MUSVOL",M_MusicVol,'m'},
431
    {-1,"",0}
431
    {-1,"",0}
432
};
432
};
433
 
433
 
434
menu_t  SoundDef =
434
menu_t  SoundDef =
435
{
435
{
436
    sound_end,
436
    sound_end,
437
    &OptionsDef,
437
    &OptionsDef,
438
    SoundMenu,
438
    SoundMenu,
439
    M_DrawSound,
439
    M_DrawSound,
440
    80,64,
440
    80,64,
441
    0
441
    0
442
};
442
};
443
 
443
 
444
//
444
//
445
// LOAD GAME MENU
445
// LOAD GAME MENU
446
//
446
//
447
enum
447
enum
448
{
448
{
449
    load1,
449
    load1,
450
    load2,
450
    load2,
451
    load3,
451
    load3,
452
    load4,
452
    load4,
453
    load5,
453
    load5,
454
    load6,
454
    load6,
455
    load_end
455
    load_end
456
} load_e;
456
} load_e;
457
 
457
 
458
menuitem_t LoadMenu[]=
458
menuitem_t LoadMenu[]=
459
{
459
{
460
    {1,"", M_LoadSelect,'1'},
460
    {1,"", M_LoadSelect,'1'},
461
    {1,"", M_LoadSelect,'2'},
461
    {1,"", M_LoadSelect,'2'},
462
    {1,"", M_LoadSelect,'3'},
462
    {1,"", M_LoadSelect,'3'},
463
    {1,"", M_LoadSelect,'4'},
463
    {1,"", M_LoadSelect,'4'},
464
    {1,"", M_LoadSelect,'5'},
464
    {1,"", M_LoadSelect,'5'},
465
    {1,"", M_LoadSelect,'6'}
465
    {1,"", M_LoadSelect,'6'}
466
};
466
};
467
 
467
 
468
menu_t  LoadDef =
468
menu_t  LoadDef =
469
{
469
{
470
    load_end,
470
    load_end,
471
    &MainDef,
471
    &MainDef,
472
    LoadMenu,
472
    LoadMenu,
473
    M_DrawLoad,
473
    M_DrawLoad,
474
    80,54,
474
    80,54,
475
    0
475
    0
476
};
476
};
477
 
477
 
478
//
478
//
479
// SAVE GAME MENU
479
// SAVE GAME MENU
480
//
480
//
481
menuitem_t SaveMenu[]=
481
menuitem_t SaveMenu[]=
482
{
482
{
483
    {1,"", M_SaveSelect,'1'},
483
    {1,"", M_SaveSelect,'1'},
484
    {1,"", M_SaveSelect,'2'},
484
    {1,"", M_SaveSelect,'2'},
485
    {1,"", M_SaveSelect,'3'},
485
    {1,"", M_SaveSelect,'3'},
486
    {1,"", M_SaveSelect,'4'},
486
    {1,"", M_SaveSelect,'4'},
487
    {1,"", M_SaveSelect,'5'},
487
    {1,"", M_SaveSelect,'5'},
488
    {1,"", M_SaveSelect,'6'}
488
    {1,"", M_SaveSelect,'6'}
489
};
489
};
490
 
490
 
491
menu_t  SaveDef =
491
menu_t  SaveDef =
492
{
492
{
493
    load_end,
493
    load_end,
494
    &MainDef,
494
    &MainDef,
495
    SaveMenu,
495
    SaveMenu,
496
    M_DrawSave,
496
    M_DrawSave,
497
    80,54,
497
    80,54,
498
    0
498
    0
499
};
499
};
500
 
500
 
501
 
501
 
502
//
502
//
503
// M_ReadSaveStrings
503
// M_ReadSaveStrings
504
//  read the strings from the savegame files
504
//  read the strings from the savegame files
505
//
505
//
506
void M_ReadSaveStrings(void)
506
void M_ReadSaveStrings(void)
507
{
507
{
508
    FILE           *handle;
508
    FILE           *handle;
509
    int             count;
509
    int             count;
510
    int             i;
510
    int             i;
511
    char    name[256];
511
    char    name[256];
512
	
512
 
513
    for (i = 0;i < load_end;i++)
513
    for (i = 0;i < load_end;i++)
514
    {
514
    {
515
	sprintf(name,SAVEGAMENAME"%d.dsg",i);
515
        sprintf(name,"doomsav%d.dsg",i);
516
 
516
 
517
	handle = fopen (name, "r");
517
        handle = fopen (name, "r");
518
	if (handle == NULL)
518
        if (handle == NULL)
519
	{
519
        {
520
	    strcpy(&savegamestrings[i][0],EMPTYSTRING);
520
            strcpy(&savegamestrings[i][0],EMPTYSTRING);
521
	    LoadMenu[i].status = 0;
521
            LoadMenu[i].status = 0;
522
	    continue;
522
            continue;
523
	}
523
        }
524
	count = fread (&savegamestrings[i], 1, SAVESTRINGSIZE, handle);
524
        count = fread (&savegamestrings[i], 1, SAVESTRINGSIZE, handle);
525
	fclose (handle);
525
        fclose (handle);
526
	LoadMenu[i].status = 1;
526
        LoadMenu[i].status = 1;
527
    }
527
    }
528
}
528
}
529
 
529
 
530
 
530
 
531
//
531
//
532
// M_LoadGame & Cie.
532
// M_LoadGame & Cie.
533
//
533
//
534
void M_DrawLoad(void)
534
void M_DrawLoad(void)
535
{
535
{
536
    int             i;
536
    int             i;
537
	
537
        
538
    V_DrawPatchDirect (72,28,0,W_CacheLumpName("M_LOADG",PU_CACHE));
538
    V_DrawPatchDirect (72,28,0,W_CacheLumpName("M_LOADG",PU_CACHE));
539
    for (i = 0;i < load_end; i++)
539
    for (i = 0;i < load_end; i++)
540
    {
540
    {
541
	M_DrawSaveLoadBorder(LoadDef.x,LoadDef.y+LINEHEIGHT*i);
541
        M_DrawSaveLoadBorder(LoadDef.x,LoadDef.y+LINEHEIGHT*i);
542
	M_WriteText(LoadDef.x,LoadDef.y+LINEHEIGHT*i,savegamestrings[i]);
542
        M_WriteText(LoadDef.x,LoadDef.y+LINEHEIGHT*i,savegamestrings[i]);
543
    }
543
    }
544
}
544
}
545
 
545
 
546
 
546
 
547
 
547
 
548
//
548
//
549
// Draw border for the savegame description
549
// Draw border for the savegame description
550
//
550
//
551
void M_DrawSaveLoadBorder(int x,int y)
551
void M_DrawSaveLoadBorder(int x,int y)
552
{
552
{
553
    int             i;
553
    int             i;
554
	
554
        
555
    V_DrawPatchDirect (x-8,y+7,0,W_CacheLumpName("M_LSLEFT",PU_CACHE));
555
    V_DrawPatchDirect (x-8,y+7,0,W_CacheLumpName("M_LSLEFT",PU_CACHE));
556
	
556
        
557
    for (i = 0;i < 24;i++)
557
    for (i = 0;i < 24;i++)
558
    {
558
    {
559
	V_DrawPatchDirect (x,y+7,0,W_CacheLumpName("M_LSCNTR",PU_CACHE));
559
        V_DrawPatchDirect (x,y+7,0,W_CacheLumpName("M_LSCNTR",PU_CACHE));
560
	x += 8;
560
        x += 8;
561
    }
561
    }
562
 
562
 
563
    V_DrawPatchDirect (x,y+7,0,W_CacheLumpName("M_LSRGHT",PU_CACHE));
563
    V_DrawPatchDirect (x,y+7,0,W_CacheLumpName("M_LSRGHT",PU_CACHE));
564
}
564
}
565
 
565
 
566
 
566
 
567
 
567
 
568
//
568
//
569
// User wants to load this game
569
// User wants to load this game
570
//
570
//
571
void M_LoadSelect(int choice)
571
void M_LoadSelect(int choice)
572
{
572
{
573
    char    name[256];
573
    char    name[256];
574
	
574
        
575
    if (M_CheckParm("-cdrom"))
575
//    if (M_CheckParm("-cdrom"))
576
	sprintf(name,"c:\\doomdata\\"SAVEGAMENAME"%d.dsg",choice);
576
//        sprintf(name,"c:\\doomdata\\doomsav%d.dsg",choice);
577
    else
577
//    else
-
 
578
        sprintf(name,"doomsav%d.dsg",choice);
578
	sprintf(name,SAVEGAMENAME"%d.dsg",choice);
579
 
579
    G_LoadGame (name);
580
    G_LoadGame (name);
580
    M_ClearMenus ();
581
    M_ClearMenus ();
581
}
582
}
582
 
583
 
583
//
584
//
584
// Selected from DOOM menu
585
// Selected from DOOM menu
585
//
586
//
586
void M_LoadGame (int choice)
587
void M_LoadGame (int choice)
587
{
588
{
588
    if (netgame)
589
    if (netgame)
589
    {
590
    {
590
	M_StartMessage(LOADNET,NULL,false);
591
        M_StartMessage(LOADNET,NULL,false);
591
	return;
592
        return;
592
    }
593
    }
593
	
594
        
594
    M_SetupNextMenu(&LoadDef);
595
    M_SetupNextMenu(&LoadDef);
595
    M_ReadSaveStrings();
596
    M_ReadSaveStrings();
596
}
597
}
597
 
598
 
598
 
599
 
599
//
600
//
600
//  M_SaveGame & Cie.
601
//  M_SaveGame & Cie.
601
//
602
//
602
void M_DrawSave(void)
603
void M_DrawSave(void)
603
{
604
{
604
    int             i;
605
    int             i;
605
	
606
        
606
    V_DrawPatchDirect (72,28,0,W_CacheLumpName("M_SAVEG",PU_CACHE));
607
    V_DrawPatchDirect (72,28,0,W_CacheLumpName("M_SAVEG",PU_CACHE));
607
    for (i = 0;i < load_end; i++)
608
    for (i = 0;i < load_end; i++)
608
    {
609
    {
609
	M_DrawSaveLoadBorder(LoadDef.x,LoadDef.y+LINEHEIGHT*i);
610
        M_DrawSaveLoadBorder(LoadDef.x,LoadDef.y+LINEHEIGHT*i);
610
	M_WriteText(LoadDef.x,LoadDef.y+LINEHEIGHT*i,savegamestrings[i]);
611
        M_WriteText(LoadDef.x,LoadDef.y+LINEHEIGHT*i,savegamestrings[i]);
611
    }
612
    }
612
	
613
        
613
    if (saveStringEnter)
614
    if (saveStringEnter)
614
    {
615
    {
615
	i = M_StringWidth(savegamestrings[saveSlot]);
616
        i = M_StringWidth(savegamestrings[saveSlot]);
616
	M_WriteText(LoadDef.x + i,LoadDef.y+LINEHEIGHT*saveSlot,"_");
617
        M_WriteText(LoadDef.x + i,LoadDef.y+LINEHEIGHT*saveSlot,"_");
617
    }
618
    }
618
}
619
}
619
 
620
 
620
//
621
//
621
// M_Responder calls this when user is finished
622
// M_Responder calls this when user is finished
622
//
623
//
623
void M_DoSave(int slot)
624
void M_DoSave(int slot)
624
{
625
{
-
 
626
 
625
    G_SaveGame (slot,savegamestrings[slot]);
627
    G_SaveGame (slot,savegamestrings[slot]);
626
    M_ClearMenus ();
628
    M_ClearMenus ();
627
 
629
 
628
    // PICK QUICKSAVE SLOT YET?
630
    // PICK QUICKSAVE SLOT YET?
629
    if (quickSaveSlot == -2)
631
    if (quickSaveSlot == -2)
630
	quickSaveSlot = slot;
632
        quickSaveSlot = slot;
631
}
633
}
632
 
634
 
633
//
635
//
634
// User wants to save. Start string input for M_Responder
636
// User wants to save. Start string input for M_Responder
635
//
637
//
636
void M_SaveSelect(int choice)
638
void M_SaveSelect(int choice)
637
{
639
{
638
    // we are going to be intercepting all chars
640
    // we are going to be intercepting all chars
639
    saveStringEnter = 1;
641
    saveStringEnter = 1;
640
    
642
    
641
    saveSlot = choice;
643
    saveSlot = choice;
642
    strcpy(saveOldString,savegamestrings[choice]);
644
    strcpy(saveOldString,savegamestrings[choice]);
643
    if (!strcmp(savegamestrings[choice],EMPTYSTRING))
645
    if (!strcmp(savegamestrings[choice],EMPTYSTRING))
644
	savegamestrings[choice][0] = 0;
646
        savegamestrings[choice][0] = 0;
645
    saveCharIndex = strlen(savegamestrings[choice]);
647
    saveCharIndex = strlen(savegamestrings[choice]);
646
}
648
}
647
 
649
 
648
//
650
//
649
// Selected from DOOM menu
651
// Selected from DOOM menu
650
//
652
//
651
void M_SaveGame (int choice)
653
void M_SaveGame (int choice)
652
{
654
{
653
    if (!usergame)
655
    if (!usergame)
654
    {
656
    {
655
	M_StartMessage(SAVEDEAD,NULL,false);
657
        M_StartMessage(SAVEDEAD,NULL,false);
656
	return;
658
        return;
657
    }
659
    }
658
	
660
        
659
    if (gamestate != GS_LEVEL)
661
    if (gamestate != GS_LEVEL)
660
	return;
662
        return;
661
	
663
        
662
    M_SetupNextMenu(&SaveDef);
664
    M_SetupNextMenu(&SaveDef);
663
    M_ReadSaveStrings();
665
    M_ReadSaveStrings();
664
}
666
}
665
 
667
 
666
 
668
 
667
 
669
 
668
//
670
//
669
//      M_QuickSave
671
//      M_QuickSave
670
//
672
//
671
char    tempstring[80];
673
char    tempstring[80];
672
 
674
 
673
void M_QuickSaveResponse(int ch)
675
void M_QuickSaveResponse(int ch)
674
{
676
{
675
    if (ch == 'y')
677
    if (ch == 'y')
676
    {
678
    {
677
	M_DoSave(quickSaveSlot);
679
        M_DoSave(quickSaveSlot);
678
	S_StartSound(NULL,sfx_swtchx);
680
        S_StartSound(NULL,sfx_swtchx);
679
    }
681
    }
680
}
682
}
681
 
683
 
682
void M_QuickSave(void)
684
void M_QuickSave(void)
683
{
685
{
684
    if (!usergame)
686
    if (!usergame)
685
    {
687
    {
686
	S_StartSound(NULL,sfx_oof);
688
        S_StartSound(NULL,sfx_oof);
687
	return;
689
        return;
688
    }
690
    }
689
 
691
 
690
    if (gamestate != GS_LEVEL)
692
    if (gamestate != GS_LEVEL)
691
	return;
693
        return;
692
	
694
        
693
    if (quickSaveSlot < 0)
695
    if (quickSaveSlot < 0)
694
    {
696
    {
695
	M_StartControlPanel();
697
        M_StartControlPanel();
696
	M_ReadSaveStrings();
698
        M_ReadSaveStrings();
697
	M_SetupNextMenu(&SaveDef);
699
        M_SetupNextMenu(&SaveDef);
698
	quickSaveSlot = -2;	// means to pick a slot now
700
        quickSaveSlot = -2;     // means to pick a slot now
699
	return;
701
        return;
700
    }
702
    }
701
    sprintf(tempstring,QSPROMPT,savegamestrings[quickSaveSlot]);
703
    sprintf(tempstring,QSPROMPT,savegamestrings[quickSaveSlot]);
702
    M_StartMessage(tempstring,M_QuickSaveResponse,true);
704
    M_StartMessage(tempstring,M_QuickSaveResponse,true);
703
}
705
}
704
 
706
 
705
 
707
 
706
 
708
 
707
//
709
//
708
// M_QuickLoad
710
// M_QuickLoad
709
//
711
//
710
void M_QuickLoadResponse(int ch)
712
void M_QuickLoadResponse(int ch)
711
{
713
{
712
    if (ch == 'y')
714
    if (ch == 'y')
713
    {
715
    {
714
	M_LoadSelect(quickSaveSlot);
716
        M_LoadSelect(quickSaveSlot);
715
	S_StartSound(NULL,sfx_swtchx);
717
        S_StartSound(NULL,sfx_swtchx);
716
    }
718
    }
717
}
719
}
718
 
720
 
719
 
721
 
720
void M_QuickLoad(void)
722
void M_QuickLoad(void)
721
{
723
{
722
    if (netgame)
724
    if (netgame)
723
    {
725
    {
724
	M_StartMessage(QLOADNET,NULL,false);
726
        M_StartMessage(QLOADNET,NULL,false);
725
	return;
727
        return;
726
    }
728
    }
727
	
729
        
728
    if (quickSaveSlot < 0)
730
    if (quickSaveSlot < 0)
729
    {
731
    {
730
	M_StartMessage(QSAVESPOT,NULL,false);
732
        M_StartMessage(QSAVESPOT,NULL,false);
731
	return;
733
        return;
732
    }
734
    }
733
    sprintf(tempstring,QLPROMPT,savegamestrings[quickSaveSlot]);
735
    sprintf(tempstring,QLPROMPT,savegamestrings[quickSaveSlot]);
734
    M_StartMessage(tempstring,M_QuickLoadResponse,true);
736
    M_StartMessage(tempstring,M_QuickLoadResponse,true);
735
}
737
}
736
 
738
 
737
 
739
 
738
 
740
 
739
 
741
 
740
//
742
//
741
// Read This Menus
743
// Read This Menus
742
// Had a "quick hack to fix romero bug"
744
// Had a "quick hack to fix romero bug"
743
//
745
//
744
void M_DrawReadThis1(void)
746
void M_DrawReadThis1(void)
745
{
747
{
746
    inhelpscreens = true;
748
    inhelpscreens = true;
747
    switch ( gamemode )
749
    switch ( gamemode )
748
    {
750
    {
749
      case commercial:
751
      case commercial:
750
	V_DrawPatchDirect (0,0,0,W_CacheLumpName("HELP",PU_CACHE));
752
        V_DrawPatchDirect (0,0,0,W_CacheLumpName("HELP",PU_CACHE));
751
	break;
753
        break;
752
      case shareware:
754
      case shareware:
753
      case registered:
755
      case registered:
754
      case retail:
756
      case retail:
755
	V_DrawPatchDirect (0,0,0,W_CacheLumpName("HELP1",PU_CACHE));
757
        V_DrawPatchDirect (0,0,0,W_CacheLumpName("HELP1",PU_CACHE));
756
	break;
758
        break;
757
      default:
759
      default:
758
	break;
760
        break;
759
    }
761
    }
760
    return;
762
    return;
761
}
763
}
762
 
764
 
763
 
765
 
764
 
766
 
765
//
767
//
766
// Read This Menus - optional second page.
768
// Read This Menus - optional second page.
767
//
769
//
768
void M_DrawReadThis2(void)
770
void M_DrawReadThis2(void)
769
{
771
{
770
    inhelpscreens = true;
772
    inhelpscreens = true;
771
    switch ( gamemode )
773
    switch ( gamemode )
772
    {
774
    {
773
      case retail:
775
      case retail:
774
      case commercial:
776
      case commercial:
775
	// This hack keeps us from having to change menus.
777
        // This hack keeps us from having to change menus.
776
	V_DrawPatchDirect (0,0,0,W_CacheLumpName("CREDIT",PU_CACHE));
778
        V_DrawPatchDirect (0,0,0,W_CacheLumpName("CREDIT",PU_CACHE));
777
	break;
779
        break;
778
      case shareware:
780
      case shareware:
779
      case registered:
781
      case registered:
780
	V_DrawPatchDirect (0,0,0,W_CacheLumpName("HELP2",PU_CACHE));
782
        V_DrawPatchDirect (0,0,0,W_CacheLumpName("HELP2",PU_CACHE));
781
	break;
783
        break;
782
      default:
784
      default:
783
	break;
785
        break;
784
    }
786
    }
785
    return;
787
    return;
786
}
788
}
787
 
789
 
788
 
790
 
789
//
791
//
790
// Change Sfx & Music volumes
792
// Change Sfx & Music volumes
791
//
793
//
792
void M_DrawSound(void)
794
void M_DrawSound(void)
793
{
795
{
794
    V_DrawPatchDirect (60,38,0,W_CacheLumpName("M_SVOL",PU_CACHE));
796
    V_DrawPatchDirect (60,38,0,W_CacheLumpName("M_SVOL",PU_CACHE));
795
 
797
 
796
    M_DrawThermo(SoundDef.x,SoundDef.y+LINEHEIGHT*(sfx_vol+1),
798
    M_DrawThermo(SoundDef.x,SoundDef.y+LINEHEIGHT*(sfx_vol+1),
797
		 16,snd_SfxVolume);
799
                 16,snd_SfxVolume);
798
 
800
 
799
    M_DrawThermo(SoundDef.x,SoundDef.y+LINEHEIGHT*(music_vol+1),
801
    M_DrawThermo(SoundDef.x,SoundDef.y+LINEHEIGHT*(music_vol+1),
800
		 16,snd_MusicVolume);
802
                 16,snd_MusicVolume);
801
}
803
}
802
 
804
 
803
void M_Sound(int choice)
805
void M_Sound(int choice)
804
{
806
{
805
    M_SetupNextMenu(&SoundDef);
807
    M_SetupNextMenu(&SoundDef);
806
}
808
}
807
 
809
 
808
void M_SfxVol(int choice)
810
void M_SfxVol(int choice)
809
{
811
{
810
    switch(choice)
812
    switch(choice)
811
    {
813
    {
812
      case 0:
814
      case 0:
813
	if (snd_SfxVolume)
815
        if (snd_SfxVolume)
814
	    snd_SfxVolume--;
816
            snd_SfxVolume--;
815
	break;
817
        break;
816
      case 1:
818
      case 1:
817
	if (snd_SfxVolume < 15)
819
        if (snd_SfxVolume < 15)
818
	    snd_SfxVolume++;
820
            snd_SfxVolume++;
819
	break;
821
        break;
820
    }
822
    }
821
	
823
        
822
    S_SetSfxVolume(snd_SfxVolume /* *8 */);
824
    S_SetSfxVolume(snd_SfxVolume /* *8 */);
823
}
825
}
824
 
826
 
825
void M_MusicVol(int choice)
827
void M_MusicVol(int choice)
826
{
828
{
827
    switch(choice)
829
    switch(choice)
828
    {
830
    {
829
      case 0:
831
      case 0:
830
	if (snd_MusicVolume)
832
        if (snd_MusicVolume)
831
	    snd_MusicVolume--;
833
            snd_MusicVolume--;
832
	break;
834
        break;
833
      case 1:
835
      case 1:
834
	if (snd_MusicVolume < 15)
836
        if (snd_MusicVolume < 15)
835
	    snd_MusicVolume++;
837
            snd_MusicVolume++;
836
	break;
838
        break;
837
    }
839
    }
838
	
840
        
839
    S_SetMusicVolume(snd_MusicVolume /* *8 */);
841
    S_SetMusicVolume(snd_MusicVolume /* *8 */);
840
}
842
}
841
 
843
 
842
 
844
 
843
 
845
 
844
 
846
 
845
//
847
//
846
// M_DrawMainMenu
848
// M_DrawMainMenu
847
//
849
//
848
void M_DrawMainMenu(void)
850
void M_DrawMainMenu(void)
849
{
851
{
850
    V_DrawPatchDirect (94,2,0,W_CacheLumpName("M_DOOM",PU_CACHE));
852
    V_DrawPatchDirect (94,2,0,W_CacheLumpName("M_DOOM",PU_CACHE));
851
}
853
}
852
 
854
 
853
 
855
 
854
 
856
 
855
 
857
 
856
//
858
//
857
// M_NewGame
859
// M_NewGame
858
//
860
//
859
void M_DrawNewGame(void)
861
void M_DrawNewGame(void)
860
{
862
{
861
    V_DrawPatchDirect (96,14,0,W_CacheLumpName("M_NEWG",PU_CACHE));
863
    V_DrawPatchDirect (96,14,0,W_CacheLumpName("M_NEWG",PU_CACHE));
862
    V_DrawPatchDirect (54,38,0,W_CacheLumpName("M_SKILL",PU_CACHE));
864
    V_DrawPatchDirect (54,38,0,W_CacheLumpName("M_SKILL",PU_CACHE));
863
}
865
}
864
 
866
 
865
void M_NewGame(int choice)
867
void M_NewGame(int choice)
866
{
868
{
867
    if (netgame && !demoplayback)
869
    if (netgame && !demoplayback)
868
    {
870
    {
869
	M_StartMessage(NEWGAME,NULL,false);
871
        M_StartMessage(NEWGAME,NULL,false);
870
	return;
872
        return;
871
    }
873
    }
872
	
874
        
873
    if ( gamemode == commercial )
875
    if ( gamemode == commercial )
874
	M_SetupNextMenu(&NewDef);
876
        M_SetupNextMenu(&NewDef);
875
    else
877
    else
876
	M_SetupNextMenu(&EpiDef);
878
        M_SetupNextMenu(&EpiDef);
877
}
879
}
878
 
880
 
879
 
881
 
880
//
882
//
881
//      M_Episode
883
//      M_Episode
882
//
884
//
883
int     epi;
885
int     epi;
884
 
886
 
885
void M_DrawEpisode(void)
887
void M_DrawEpisode(void)
886
{
888
{
887
    V_DrawPatchDirect (54,38,0,W_CacheLumpName("M_EPISOD",PU_CACHE));
889
    V_DrawPatchDirect (54,38,0,W_CacheLumpName("M_EPISOD",PU_CACHE));
888
}
890
}
889
 
891
 
890
void M_VerifyNightmare(int ch)
892
void M_VerifyNightmare(int ch)
891
{
893
{
892
    if (ch != 'y')
894
    if (ch != 'y')
893
	return;
895
        return;
894
		
896
                
895
    G_DeferedInitNew(nightmare,epi+1,1);
897
    G_DeferedInitNew(nightmare,epi+1,1);
896
    M_ClearMenus ();
898
    M_ClearMenus ();
897
}
899
}
898
 
900
 
899
void M_ChooseSkill(int choice)
901
void M_ChooseSkill(int choice)
900
{
902
{
901
    if (choice == nightmare)
903
    if (choice == nightmare)
902
    {
904
    {
903
	M_StartMessage(NIGHTMARE,M_VerifyNightmare,true);
905
        M_StartMessage(NIGHTMARE,M_VerifyNightmare,true);
904
	return;
906
        return;
905
    }
907
    }
906
	
908
        
907
    G_DeferedInitNew(choice,epi+1,1);
909
    G_DeferedInitNew(choice,epi+1,1);
908
    M_ClearMenus ();
910
    M_ClearMenus ();
909
}
911
}
910
 
912
 
911
void M_Episode(int choice)
913
void M_Episode(int choice)
912
{
914
{
913
    if ( (gamemode == shareware)
915
    if ( (gamemode == shareware)
914
	 && choice)
916
         && choice)
915
    {
917
    {
916
	M_StartMessage(SWSTRING,NULL,false);
918
        M_StartMessage(SWSTRING,NULL,false);
917
	M_SetupNextMenu(&ReadDef1);
919
        M_SetupNextMenu(&ReadDef1);
918
	return;
920
        return;
919
    }
921
    }
920
 
922
 
921
    // Yet another hack...
923
    // Yet another hack...
922
    if ( (gamemode == registered)
924
    if ( (gamemode == registered)
923
	 && (choice > 2))
925
         && (choice > 2))
924
    {
926
    {
925
 //     __libclog_printf("M_Episode: 4th episode requires UltimateDOOM\n");
927
 //     __libclog_printf("M_Episode: 4th episode requires UltimateDOOM\n");
926
      choice = 0;
928
      choice = 0;
927
    }
929
    }
928
	 
930
         
929
    epi = choice;
931
    epi = choice;
930
    M_SetupNextMenu(&NewDef);
932
    M_SetupNextMenu(&NewDef);
931
}
933
}
932
 
934
 
933
 
935
 
934
 
936
 
935
//
937
//
936
// M_Options
938
// M_Options
937
//
939
//
938
char    detailNames[2][9]	= {"M_GDHIGH","M_GDLOW"};
940
char    detailNames[2][9]       = {"M_GDHIGH","M_GDLOW"};
939
char	msgNames[2][9]		= {"M_MSGOFF","M_MSGON"};
941
char    msgNames[2][9]          = {"M_MSGOFF","M_MSGON"};
940
 
942
 
941
 
943
 
942
void M_DrawOptions(void)
944
void M_DrawOptions(void)
943
{
945
{
944
    V_DrawPatchDirect (108,15,0,W_CacheLumpName("M_OPTTTL",PU_CACHE));
946
    V_DrawPatchDirect (108,15,0,W_CacheLumpName("M_OPTTTL",PU_CACHE));
945
	
947
        
946
    V_DrawPatchDirect (OptionsDef.x + 175,OptionsDef.y+LINEHEIGHT*detail,0,
948
    V_DrawPatchDirect (OptionsDef.x + 175,OptionsDef.y+LINEHEIGHT*detail,0,
947
		       W_CacheLumpName(detailNames[detailLevel],PU_CACHE));
949
                       W_CacheLumpName(detailNames[detailLevel],PU_CACHE));
948
 
950
 
949
    V_DrawPatchDirect (OptionsDef.x + 120,OptionsDef.y+LINEHEIGHT*messages,0,
951
    V_DrawPatchDirect (OptionsDef.x + 120,OptionsDef.y+LINEHEIGHT*messages,0,
950
		       W_CacheLumpName(msgNames[showMessages],PU_CACHE));
952
                       W_CacheLumpName(msgNames[showMessages],PU_CACHE));
951
 
953
 
952
    M_DrawThermo(OptionsDef.x,OptionsDef.y+LINEHEIGHT*(mousesens+1),
954
    M_DrawThermo(OptionsDef.x,OptionsDef.y+LINEHEIGHT*(mousesens+1),
953
		 10,mouseSensitivity);
955
                 10,mouseSensitivity);
954
	
956
        
955
    M_DrawThermo(OptionsDef.x,OptionsDef.y+LINEHEIGHT*(scrnsize+1),
957
    M_DrawThermo(OptionsDef.x,OptionsDef.y+LINEHEIGHT*(scrnsize+1),
956
		 9,screenSize);
958
                 9,screenSize);
957
}
959
}
958
 
960
 
959
void M_Options(int choice)
961
void M_Options(int choice)
960
{
962
{
961
    M_SetupNextMenu(&OptionsDef);
963
    M_SetupNextMenu(&OptionsDef);
962
}
964
}
963
 
965
 
964
 
966
 
965
 
967
 
966
//
968
//
967
//      Toggle messages on/off
969
//      Toggle messages on/off
968
//
970
//
969
void M_ChangeMessages(int choice)
971
void M_ChangeMessages(int choice)
970
{
972
{
971
    // warning: unused parameter `int choice'
973
    // warning: unused parameter `int choice'
972
    choice = 0;
974
    choice = 0;
973
    showMessages = 1 - showMessages;
975
    showMessages = 1 - showMessages;
974
	
976
        
975
    if (!showMessages)
977
    if (!showMessages)
976
	players[consoleplayer].message = MSGOFF;
978
        players[consoleplayer].message = MSGOFF;
977
    else
979
    else
978
	players[consoleplayer].message = MSGON ;
980
        players[consoleplayer].message = MSGON ;
979
 
981
 
980
    message_dontfuckwithme = true;
982
    message_dontfuckwithme = true;
981
}
983
}
982
 
984
 
983
 
985
 
984
//
986
//
985
// M_EndGame
987
// M_EndGame
986
//
988
//
987
void M_EndGameResponse(int ch)
989
void M_EndGameResponse(int ch)
988
{
990
{
989
    if (ch != 'y')
991
    if (ch != 'y')
990
	return;
992
        return;
991
		
993
                
992
    currentMenu->lastOn = itemOn;
994
    currentMenu->lastOn = itemOn;
993
    M_ClearMenus ();
995
    M_ClearMenus ();
994
    D_StartTitle ();
996
    D_StartTitle ();
995
}
997
}
996
 
998
 
997
void M_EndGame(int choice)
999
void M_EndGame(int choice)
998
{
1000
{
999
    choice = 0;
1001
    choice = 0;
1000
    if (!usergame)
1002
    if (!usergame)
1001
    {
1003
    {
1002
	S_StartSound(NULL,sfx_oof);
1004
        S_StartSound(NULL,sfx_oof);
1003
	return;
1005
        return;
1004
    }
1006
    }
1005
	
1007
        
1006
    if (netgame)
1008
    if (netgame)
1007
    {
1009
    {
1008
	M_StartMessage(NETEND,NULL,false);
1010
        M_StartMessage(NETEND,NULL,false);
1009
	return;
1011
        return;
1010
    }
1012
    }
1011
	
1013
        
1012
    M_StartMessage(ENDGAME,M_EndGameResponse,true);
1014
    M_StartMessage(ENDGAME,M_EndGameResponse,true);
1013
}
1015
}
1014
 
1016
 
1015
 
1017
 
1016
 
1018
 
1017
 
1019
 
1018
//
1020
//
1019
// M_ReadThis
1021
// M_ReadThis
1020
//
1022
//
1021
void M_ReadThis(int choice)
1023
void M_ReadThis(int choice)
1022
{
1024
{
1023
    choice = 0;
1025
    choice = 0;
1024
    M_SetupNextMenu(&ReadDef1);
1026
    M_SetupNextMenu(&ReadDef1);
1025
}
1027
}
1026
 
1028
 
1027
void M_ReadThis2(int choice)
1029
void M_ReadThis2(int choice)
1028
{
1030
{
1029
    choice = 0;
1031
    choice = 0;
1030
    M_SetupNextMenu(&ReadDef2);
1032
    M_SetupNextMenu(&ReadDef2);
1031
}
1033
}
1032
 
1034
 
1033
void M_FinishReadThis(int choice)
1035
void M_FinishReadThis(int choice)
1034
{
1036
{
1035
    choice = 0;
1037
    choice = 0;
1036
    M_SetupNextMenu(&MainDef);
1038
    M_SetupNextMenu(&MainDef);
1037
}
1039
}
1038
 
1040
 
1039
 
1041
 
1040
 
1042
 
1041
 
1043
 
1042
//
1044
//
1043
// M_QuitDOOM
1045
// M_QuitDOOM
1044
//
1046
//
1045
int     quitsounds[8] =
1047
int     quitsounds[8] =
1046
{
1048
{
1047
    sfx_pldeth,
1049
    sfx_pldeth,
1048
    sfx_dmpain,
1050
    sfx_dmpain,
1049
    sfx_popain,
1051
    sfx_popain,
1050
    sfx_slop,
1052
    sfx_slop,
1051
    sfx_telept,
1053
    sfx_telept,
1052
    sfx_posit1,
1054
    sfx_posit1,
1053
    sfx_posit3,
1055
    sfx_posit3,
1054
    sfx_sgtatk
1056
    sfx_sgtatk
1055
};
1057
};
1056
 
1058
 
1057
int     quitsounds2[8] =
1059
int     quitsounds2[8] =
1058
{
1060
{
1059
    sfx_vilact,
1061
    sfx_vilact,
1060
    sfx_getpow,
1062
    sfx_getpow,
1061
    sfx_boscub,
1063
    sfx_boscub,
1062
    sfx_slop,
1064
    sfx_slop,
1063
    sfx_skeswg,
1065
    sfx_skeswg,
1064
    sfx_kntdth,
1066
    sfx_kntdth,
1065
    sfx_bspact,
1067
    sfx_bspact,
1066
    sfx_sgtatk
1068
    sfx_sgtatk
1067
};
1069
};
1068
 
1070
 
1069
 
1071
 
1070
 
1072
 
1071
void M_QuitResponse(int ch)
1073
void M_QuitResponse(int ch)
1072
{
1074
{
1073
    if (ch != 'y')
1075
    if (ch != 'y')
1074
	return;
1076
        return;
1075
    if (!netgame)
1077
    if (!netgame)
1076
    {
1078
    {
1077
	if (gamemode == commercial)
1079
        if (gamemode == commercial)
1078
	    S_StartSound(NULL,quitsounds2[(gametic>>2)&7]);
1080
            S_StartSound(NULL,quitsounds2[(gametic>>2)&7]);
1079
	else
1081
        else
1080
	    S_StartSound(NULL,quitsounds[(gametic>>2)&7]);
1082
            S_StartSound(NULL,quitsounds[(gametic>>2)&7]);
1081
	I_WaitVBL(105);
1083
        I_WaitVBL(105);
1082
    }
1084
    }
1083
    I_Quit ();
1085
    I_Quit ();
1084
}
1086
}
1085
 
1087
 
1086
 
1088
 
1087
 
1089
 
1088
 
1090
 
1089
void M_QuitDOOM(int choice)
1091
void M_QuitDOOM(int choice)
1090
{
1092
{
1091
  // We pick index 0 which is language sensitive,
1093
  // We pick index 0 which is language sensitive,
1092
  //  or one at random, between 1 and maximum number.
1094
  //  or one at random, between 1 and maximum number.
1093
  if (language != english )
1095
  if (language != english )
1094
    sprintf(endstring,"%s\n\n"DOSY, endmsg[0] );
1096
    sprintf(endstring,"%s\n\n"DOSY, endmsg[0] );
1095
  else
1097
  else
1096
    sprintf(endstring,"%s\n\n"DOSY, endmsg[ (gametic%(NUM_QUITMESSAGES-2))+1 ]);
1098
    sprintf(endstring,"%s\n\n"DOSY, endmsg[ (gametic%(NUM_QUITMESSAGES-2))+1 ]);
1097
  
1099
  
1098
  M_StartMessage(endstring,M_QuitResponse,true);
1100
  M_StartMessage(endstring,M_QuitResponse,true);
1099
}
1101
}
1100
 
1102
 
1101
 
1103
 
1102
 
1104
 
1103
void M_ChangeSensitivity(int choice)
1105
void M_ChangeSensitivity(int choice)
1104
{
1106
{
1105
    switch(choice)
1107
    switch(choice)
1106
    {
1108
    {
1107
      case 0:
1109
      case 0:
1108
	if (mouseSensitivity)
1110
        if (mouseSensitivity)
1109
	    mouseSensitivity--;
1111
            mouseSensitivity--;
1110
	break;
1112
        break;
1111
      case 1:
1113
      case 1:
1112
	if (mouseSensitivity < 9)
1114
        if (mouseSensitivity < 9)
1113
	    mouseSensitivity++;
1115
            mouseSensitivity++;
1114
	break;
1116
        break;
1115
    }
1117
    }
1116
}
1118
}
1117
 
1119
 
1118
 
1120
 
1119
 
1121
 
1120
 
1122
 
1121
void M_ChangeDetail(int choice)
1123
void M_ChangeDetail(int choice)
1122
{
1124
{
1123
    choice = 0;
1125
    choice = 0;
1124
    detailLevel = 1 - detailLevel;
1126
    detailLevel = 1 - detailLevel;
1125
 
1127
 
1126
    // FIXME - does not work. Remove anyway?
1128
    // FIXME - does not work. Remove anyway?
1127
//    __libclog_printf("M_ChangeDetail: low detail mode n.a.\n");
1129
//    __libclog_printf("M_ChangeDetail: low detail mode n.a.\n");
1128
 
1130
 
1129
    return;
1131
    return;
1130
    
1132
    
1131
    /*R_SetViewSize (screenblocks, detailLevel);
1133
    /*R_SetViewSize (screenblocks, detailLevel);
1132
 
1134
 
1133
    if (!detailLevel)
1135
    if (!detailLevel)
1134
	players[consoleplayer].message = DETAILHI;
1136
        players[consoleplayer].message = DETAILHI;
1135
    else
1137
    else
1136
	players[consoleplayer].message = DETAILLO;*/
1138
        players[consoleplayer].message = DETAILLO;*/
1137
}
1139
}
1138
 
1140
 
1139
 
1141
 
1140
 
1142
 
1141
 
1143
 
1142
void M_SizeDisplay(int choice)
1144
void M_SizeDisplay(int choice)
1143
{
1145
{
1144
    switch(choice)
1146
    switch(choice)
1145
    {
1147
    {
1146
      case 0:
1148
      case 0:
1147
	if (screenSize > 0)
1149
        if (screenSize > 0)
1148
	{
1150
        {
1149
	    screenblocks--;
1151
            screenblocks--;
1150
	    screenSize--;
1152
            screenSize--;
1151
	}
1153
        }
1152
	break;
1154
        break;
1153
      case 1:
1155
      case 1:
1154
	if (screenSize < 8)
1156
        if (screenSize < 8)
1155
	{
1157
        {
1156
	    screenblocks++;
1158
            screenblocks++;
1157
	    screenSize++;
1159
            screenSize++;
1158
	}
1160
        }
1159
	break;
1161
        break;
1160
    }
1162
    }
1161
	
1163
        
1162
 
1164
 
1163
    R_SetViewSize (screenblocks, detailLevel);
1165
    R_SetViewSize (screenblocks, detailLevel);
1164
}
1166
}
1165
 
1167
 
1166
 
1168
 
1167
 
1169
 
1168
 
1170
 
1169
//
1171
//
1170
//      Menu Functions
1172
//      Menu Functions
1171
//
1173
//
1172
void
1174
void
1173
M_DrawThermo
1175
M_DrawThermo
1174
( int	x,
1176
( int   x,
1175
  int	y,
1177
  int   y,
1176
  int	thermWidth,
1178
  int   thermWidth,
1177
  int	thermDot )
1179
  int   thermDot )
1178
{
1180
{
1179
    int		xx;
1181
    int         xx;
1180
    int		i;
1182
    int         i;
1181
 
1183
 
1182
    xx = x;
1184
    xx = x;
1183
    V_DrawPatchDirect (xx,y,0,W_CacheLumpName("M_THERML",PU_CACHE));
1185
    V_DrawPatchDirect (xx,y,0,W_CacheLumpName("M_THERML",PU_CACHE));
1184
    xx += 8;
1186
    xx += 8;
1185
    for (i=0;i
1187
    for (i=0;i
1186
    {
1188
    {
1187
	V_DrawPatchDirect (xx,y,0,W_CacheLumpName("M_THERMM",PU_CACHE));
1189
        V_DrawPatchDirect (xx,y,0,W_CacheLumpName("M_THERMM",PU_CACHE));
1188
	xx += 8;
1190
        xx += 8;
1189
    }
1191
    }
1190
    V_DrawPatchDirect (xx,y,0,W_CacheLumpName("M_THERMR",PU_CACHE));
1192
    V_DrawPatchDirect (xx,y,0,W_CacheLumpName("M_THERMR",PU_CACHE));
1191
 
1193
 
1192
    V_DrawPatchDirect ((x+8) + thermDot*8,y,
1194
    V_DrawPatchDirect ((x+8) + thermDot*8,y,
1193
		       0,W_CacheLumpName("M_THERMO",PU_CACHE));
1195
                       0,W_CacheLumpName("M_THERMO",PU_CACHE));
1194
}
1196
}
1195
 
1197
 
1196
 
1198
 
1197
 
1199
 
1198
void
1200
void
1199
M_DrawEmptyCell
1201
M_DrawEmptyCell
1200
( menu_t*	menu,
1202
( menu_t*       menu,
1201
  int		item )
1203
  int           item )
1202
{
1204
{
1203
    V_DrawPatchDirect (menu->x - 10,        menu->y+item*LINEHEIGHT - 1, 0,
1205
    V_DrawPatchDirect (menu->x - 10,        menu->y+item*LINEHEIGHT - 1, 0,
1204
		       W_CacheLumpName("M_CELL1",PU_CACHE));
1206
                       W_CacheLumpName("M_CELL1",PU_CACHE));
1205
}
1207
}
1206
 
1208
 
1207
void
1209
void
1208
M_DrawSelCell
1210
M_DrawSelCell
1209
( menu_t*	menu,
1211
( menu_t*       menu,
1210
  int		item )
1212
  int           item )
1211
{
1213
{
1212
    V_DrawPatchDirect (menu->x - 10,        menu->y+item*LINEHEIGHT - 1, 0,
1214
    V_DrawPatchDirect (menu->x - 10,        menu->y+item*LINEHEIGHT - 1, 0,
1213
		       W_CacheLumpName("M_CELL2",PU_CACHE));
1215
                       W_CacheLumpName("M_CELL2",PU_CACHE));
1214
}
1216
}
1215
 
1217
 
1216
 
1218
 
1217
void
1219
void
1218
M_StartMessage
1220
M_StartMessage
1219
( char*		string,
1221
( char*         string,
1220
  void*		routine,
1222
  void*         routine,
1221
  boolean	input )
1223
  boolean       input )
1222
{
1224
{
1223
    messageLastMenuActive = menuactive;
1225
    messageLastMenuActive = menuactive;
1224
    messageToPrint = 1;
1226
    messageToPrint = 1;
1225
    messageString = string;
1227
    messageString = string;
1226
    messageRoutine = routine;
1228
    messageRoutine = routine;
1227
    messageNeedsInput = input;
1229
    messageNeedsInput = input;
1228
    menuactive = true;
1230
    menuactive = true;
1229
    return;
1231
    return;
1230
}
1232
}
1231
 
1233
 
1232
 
1234
 
1233
 
1235
 
1234
void M_StopMessage(void)
1236
void M_StopMessage(void)
1235
{
1237
{
1236
    menuactive = messageLastMenuActive;
1238
    menuactive = messageLastMenuActive;
1237
    messageToPrint = 0;
1239
    messageToPrint = 0;
1238
}
1240
}
1239
 
1241
 
1240
 
1242
 
1241
 
1243
 
1242
//
1244
//
1243
// Find string width from hu_font chars
1245
// Find string width from hu_font chars
1244
//
1246
//
1245
int M_StringWidth(char* string)
1247
int M_StringWidth(char* string)
1246
{
1248
{
1247
    int             i;
1249
    int             i;
1248
    int             w = 0;
1250
    int             w = 0;
1249
    int             c;
1251
    int             c;
1250
	
1252
        
1251
    for (i = 0;i < strlen(string);i++)
1253
    for (i = 0;i < strlen(string);i++)
1252
    {
1254
    {
1253
	c = toupper(string[i]) - HU_FONTSTART;
1255
        c = toupper(string[i]) - HU_FONTSTART;
1254
	if (c < 0 || c >= HU_FONTSIZE)
1256
        if (c < 0 || c >= HU_FONTSIZE)
1255
	    w += 4;
1257
            w += 4;
1256
	else
1258
        else
1257
	    w += SHORT (hu_font[c]->width);
1259
            w += SHORT (hu_font[c]->width);
1258
    }
1260
    }
1259
		
1261
                
1260
    return w;
1262
    return w;
1261
}
1263
}
1262
 
1264
 
1263
 
1265
 
1264
 
1266
 
1265
//
1267
//
1266
//      Find string height from hu_font chars
1268
//      Find string height from hu_font chars
1267
//
1269
//
1268
int M_StringHeight(char* string)
1270
int M_StringHeight(char* string)
1269
{
1271
{
1270
    int             i;
1272
    int             i;
1271
    int             h;
1273
    int             h;
1272
    int             height = SHORT(hu_font[0]->height);
1274
    int             height = SHORT(hu_font[0]->height);
1273
	
1275
        
1274
    h = height;
1276
    h = height;
1275
    for (i = 0;i < strlen(string);i++)
1277
    for (i = 0;i < strlen(string);i++)
1276
	if (string[i] == '\n')
1278
        if (string[i] == '\n')
1277
	    h += height;
1279
            h += height;
1278
		
1280
                
1279
    return h;
1281
    return h;
1280
}
1282
}
1281
 
1283
 
1282
 
1284
 
1283
//
1285
//
1284
//      Write a string using the hu_font
1286
//      Write a string using the hu_font
1285
//
1287
//
1286
void
1288
void
1287
M_WriteText
1289
M_WriteText
1288
( int		x,
1290
( int           x,
1289
  int		y,
1291
  int           y,
1290
  char*		string)
1292
  char*         string)
1291
{
1293
{
1292
    int		w;
1294
    int         w;
1293
    char*	ch;
1295
    char*       ch;
1294
    int		c;
1296
    int         c;
1295
    int		cx;
1297
    int         cx;
1296
    int		cy;
1298
    int         cy;
1297
		
1299
                
1298
 
1300
 
1299
    ch = string;
1301
    ch = string;
1300
    cx = x;
1302
    cx = x;
1301
    cy = y;
1303
    cy = y;
1302
	
1304
        
1303
    while(1)
1305
    while(1)
1304
    {
1306
    {
1305
	c = *ch++;
1307
        c = *ch++;
1306
	if (!c)
1308
        if (!c)
1307
	    break;
1309
            break;
1308
	if (c == '\n')
1310
        if (c == '\n')
1309
	{
1311
        {
1310
	    cx = x;
1312
            cx = x;
1311
	    cy += 12;
1313
            cy += 12;
1312
	    continue;
1314
            continue;
1313
	}
1315
        }
1314
		
1316
                
1315
	c = toupper(c) - HU_FONTSTART;
1317
        c = toupper(c) - HU_FONTSTART;
1316
	if (c < 0 || c>= HU_FONTSIZE)
1318
        if (c < 0 || c>= HU_FONTSIZE)
1317
	{
1319
        {
1318
	    cx += 4;
1320
            cx += 4;
1319
	    continue;
1321
            continue;
1320
	}
1322
        }
1321
		
1323
                
1322
	w = SHORT (hu_font[c]->width);
1324
        w = SHORT (hu_font[c]->width);
1323
	if (cx+w > SCREENWIDTH)
1325
        if (cx+w > SCREENWIDTH)
1324
	    break;
1326
            break;
1325
	V_DrawPatchDirect(cx, cy, 0, hu_font[c]);
1327
        V_DrawPatchDirect(cx, cy, 0, hu_font[c]);
1326
	cx+=w;
1328
        cx+=w;
1327
    }
1329
    }
1328
}
1330
}
1329
 
1331
 
1330
 
1332
 
1331
 
1333
 
1332
//
1334
//
1333
// CONTROL PANEL
1335
// CONTROL PANEL
1334
//
1336
//
1335
 
1337
 
1336
//
1338
//
1337
// M_Responder
1339
// M_Responder
1338
//
1340
//
1339
boolean M_Responder (event_t* ev)
1341
boolean M_Responder (event_t* ev)
1340
{
1342
{
1341
    int             ch;
1343
    int             ch;
1342
    int             i;
1344
    int             i;
1343
    static  int     joywait = 0;
1345
    static  int     joywait = 0;
1344
    static  int     mousewait = 0;
1346
    static  int     mousewait = 0;
1345
    static  int     mousey = 0;
1347
    static  int     mousey = 0;
1346
    static  int     lasty = 0;
1348
    static  int     lasty = 0;
1347
    static  int     mousex = 0;
1349
    static  int     mousex = 0;
1348
    static  int     lastx = 0;
1350
    static  int     lastx = 0;
1349
	
1351
        
1350
    ch = -1;
1352
    ch = -1;
1351
	
1353
        
1352
    if (ev->type == ev_joystick && joywait < I_GetTime())
1354
    if (ev->type == ev_joystick && joywait < I_GetTime())
1353
    {
1355
    {
1354
	if (ev->data3 == -1)
1356
        if (ev->data3 == -1)
1355
	{
1357
        {
1356
	    ch = KEY_UPARROW;
1358
            ch = KEY_UPARROW;
1357
	    joywait = I_GetTime() + 5;
1359
            joywait = I_GetTime() + 5;
1358
	}
1360
        }
1359
	else if (ev->data3 == 1)
1361
        else if (ev->data3 == 1)
1360
	{
1362
        {
1361
	    ch = KEY_DOWNARROW;
1363
            ch = KEY_DOWNARROW;
1362
	    joywait = I_GetTime() + 5;
1364
            joywait = I_GetTime() + 5;
1363
	}
1365
        }
1364
		
1366
                
1365
	if (ev->data2 == -1)
1367
        if (ev->data2 == -1)
1366
	{
1368
        {
1367
	    ch = KEY_LEFTARROW;
1369
            ch = KEY_LEFTARROW;
1368
	    joywait = I_GetTime() + 2;
1370
            joywait = I_GetTime() + 2;
1369
	}
1371
        }
1370
	else if (ev->data2 == 1)
1372
        else if (ev->data2 == 1)
1371
	{
1373
        {
1372
	    ch = KEY_RIGHTARROW;
1374
            ch = KEY_RIGHTARROW;
1373
	    joywait = I_GetTime() + 2;
1375
            joywait = I_GetTime() + 2;
1374
	}
1376
        }
1375
		
1377
                
1376
	if (ev->data1&1)
1378
        if (ev->data1&1)
1377
	{
1379
        {
1378
	    ch = KEY_ENTER;
1380
            ch = KEY_ENTER;
1379
	    joywait = I_GetTime() + 5;
1381
            joywait = I_GetTime() + 5;
1380
	}
1382
        }
1381
	if (ev->data1&2)
1383
        if (ev->data1&2)
1382
	{
1384
        {
1383
	    ch = KEY_BACKSPACE;
1385
            ch = KEY_BACKSPACE;
1384
	    joywait = I_GetTime() + 5;
1386
            joywait = I_GetTime() + 5;
1385
	}
1387
        }
1386
    }
1388
    }
1387
    else
1389
    else
1388
    {
1390
    {
1389
	if (ev->type == ev_mouse && mousewait < I_GetTime())
1391
        if (ev->type == ev_mouse && mousewait < I_GetTime())
1390
	{
1392
        {
1391
	    mousey += ev->data3;
1393
            mousey += ev->data3;
1392
	    if (mousey < lasty-30)
1394
            if (mousey < lasty-30)
1393
	    {
1395
            {
1394
		ch = KEY_DOWNARROW;
1396
                ch = KEY_DOWNARROW;
1395
		mousewait = I_GetTime() + 5;
1397
                mousewait = I_GetTime() + 5;
1396
		mousey = lasty -= 30;
1398
                mousey = lasty -= 30;
1397
	    }
1399
            }
1398
	    else if (mousey > lasty+30)
1400
            else if (mousey > lasty+30)
1399
	    {
1401
            {
1400
		ch = KEY_UPARROW;
1402
                ch = KEY_UPARROW;
1401
		mousewait = I_GetTime() + 5;
1403
                mousewait = I_GetTime() + 5;
1402
		mousey = lasty += 30;
1404
                mousey = lasty += 30;
1403
	    }
1405
            }
1404
		
1406
                
1405
	    mousex += ev->data2;
1407
            mousex += ev->data2;
1406
	    if (mousex < lastx-30)
1408
            if (mousex < lastx-30)
1407
	    {
1409
            {
1408
		ch = KEY_LEFTARROW;
1410
                ch = KEY_LEFTARROW;
1409
		mousewait = I_GetTime() + 5;
1411
                mousewait = I_GetTime() + 5;
1410
		mousex = lastx -= 30;
1412
                mousex = lastx -= 30;
1411
	    }
1413
            }
1412
	    else if (mousex > lastx+30)
1414
            else if (mousex > lastx+30)
1413
	    {
1415
            {
1414
		ch = KEY_RIGHTARROW;
1416
                ch = KEY_RIGHTARROW;
1415
		mousewait = I_GetTime() + 5;
1417
                mousewait = I_GetTime() + 5;
1416
		mousex = lastx += 30;
1418
                mousex = lastx += 30;
1417
	    }
1419
            }
1418
		
1420
                
1419
	    if (ev->data1&1)
1421
            if (ev->data1&1)
1420
	    {
1422
            {
1421
		ch = KEY_ENTER;
1423
                ch = KEY_ENTER;
1422
		mousewait = I_GetTime() + 15;
1424
                mousewait = I_GetTime() + 15;
1423
	    }
1425
            }
1424
			
1426
                        
1425
	    if (ev->data1&2)
1427
            if (ev->data1&2)
1426
	    {
1428
            {
1427
		ch = KEY_BACKSPACE;
1429
                ch = KEY_BACKSPACE;
1428
		mousewait = I_GetTime() + 15;
1430
                mousewait = I_GetTime() + 15;
1429
	    }
1431
            }
1430
	}
1432
        }
1431
	else
1433
        else
1432
	    if (ev->type == ev_keydown)
1434
            if (ev->type == ev_keydown)
1433
	    {
1435
            {
1434
		ch = ev->data1;
1436
                ch = ev->data1;
1435
	    }
1437
            }
1436
    }
1438
    }
1437
    
1439
    
1438
    if (ch == -1)
1440
    if (ch == -1)
1439
	return false;
1441
        return false;
1440
 
1442
 
1441
    
1443
    
1442
    // Save Game string input
1444
    // Save Game string input
1443
    if (saveStringEnter)
1445
    if (saveStringEnter)
1444
    {
1446
    {
1445
	switch(ch)
1447
        switch(ch)
1446
	{
1448
        {
1447
	  case KEY_BACKSPACE:
1449
          case KEY_BACKSPACE:
1448
	    if (saveCharIndex > 0)
1450
            if (saveCharIndex > 0)
1449
	    {
1451
            {
1450
		saveCharIndex--;
1452
                saveCharIndex--;
1451
		savegamestrings[saveSlot][saveCharIndex] = 0;
1453
                savegamestrings[saveSlot][saveCharIndex] = 0;
1452
	    }
1454
            }
1453
	    break;
1455
            break;
1454
				
1456
                                
1455
	  case KEY_ESCAPE:
1457
          case KEY_ESCAPE:
1456
	    saveStringEnter = 0;
1458
            saveStringEnter = 0;
1457
	    strcpy(&savegamestrings[saveSlot][0],saveOldString);
1459
            strcpy(&savegamestrings[saveSlot][0],saveOldString);
1458
	    break;
1460
            break;
1459
				
1461
                                
1460
	  case KEY_ENTER:
1462
          case KEY_ENTER:
1461
	    saveStringEnter = 0;
1463
            saveStringEnter = 0;
1462
	    if (savegamestrings[saveSlot][0])
1464
            if (savegamestrings[saveSlot][0])
1463
		M_DoSave(saveSlot);
1465
                M_DoSave(saveSlot);
1464
	    break;
1466
            break;
1465
				
1467
                                
1466
	  default:
1468
          default:
1467
	    ch = toupper(ch);
1469
            ch = toupper(ch);
1468
	    if (ch != 32)
1470
            if (ch != 32)
1469
		if (ch-HU_FONTSTART < 0 || ch-HU_FONTSTART >= HU_FONTSIZE)
1471
                if (ch-HU_FONTSTART < 0 || ch-HU_FONTSTART >= HU_FONTSIZE)
1470
		    break;
1472
                    break;
1471
	    if (ch >= 32 && ch <= 127 &&
1473
            if (ch >= 32 && ch <= 127 &&
1472
		saveCharIndex < SAVESTRINGSIZE-1 &&
1474
                saveCharIndex < SAVESTRINGSIZE-1 &&
1473
		M_StringWidth(savegamestrings[saveSlot]) <
1475
                M_StringWidth(savegamestrings[saveSlot]) <
1474
		(SAVESTRINGSIZE-2)*8)
1476
                (SAVESTRINGSIZE-2)*8)
1475
	    {
1477
            {
1476
		savegamestrings[saveSlot][saveCharIndex++] = ch;
1478
                savegamestrings[saveSlot][saveCharIndex++] = ch;
1477
		savegamestrings[saveSlot][saveCharIndex] = 0;
1479
                savegamestrings[saveSlot][saveCharIndex] = 0;
1478
	    }
1480
            }
1479
	    break;
1481
            break;
1480
	}
1482
        }
1481
	return true;
1483
        return true;
1482
    }
1484
    }
1483
    
1485
    
1484
    // Take care of any messages that need input
1486
    // Take care of any messages that need input
1485
    if (messageToPrint)
1487
    if (messageToPrint)
1486
    {
1488
    {
1487
	if (messageNeedsInput == true &&
1489
        if (messageNeedsInput == true &&
1488
	    !(ch == ' ' || ch == 'n' || ch == 'y' || ch == KEY_ESCAPE))
1490
            !(ch == ' ' || ch == 'n' || ch == 'y' || ch == KEY_ESCAPE))
1489
	    return false;
1491
            return false;
1490
		
1492
                
1491
	menuactive = messageLastMenuActive;
1493
        menuactive = messageLastMenuActive;
1492
	messageToPrint = 0;
1494
        messageToPrint = 0;
1493
	if (messageRoutine)
1495
        if (messageRoutine)
1494
	    messageRoutine(ch);
1496
            messageRoutine(ch);
1495
			
1497
                        
1496
	menuactive = false;
1498
        menuactive = false;
1497
	S_StartSound(NULL,sfx_swtchx);
1499
        S_StartSound(NULL,sfx_swtchx);
1498
	return true;
1500
        return true;
1499
    }
1501
    }
1500
	
1502
        
1501
    if (devparm && ch == KEY_F1)
1503
    if (devparm && ch == KEY_F1)
1502
    {
1504
    {
1503
	G_ScreenShot ();
1505
        G_ScreenShot ();
1504
	return true;
1506
        return true;
1505
    }
1507
    }
1506
		
1508
                
1507
    
1509
    
1508
    // F-Keys
1510
    // F-Keys
1509
    if (!menuactive)
1511
    if (!menuactive)
1510
	switch(ch)
1512
        switch(ch)
1511
	{
1513
        {
1512
	  case KEY_MINUS:         // Screen size down
1514
          case KEY_MINUS:         // Screen size down
1513
	    if (automapactive || chat_on)
1515
            if (automapactive || chat_on)
1514
		return false;
1516
                return false;
1515
	    M_SizeDisplay(0);
1517
            M_SizeDisplay(0);
1516
	    S_StartSound(NULL,sfx_stnmov);
1518
            S_StartSound(NULL,sfx_stnmov);
1517
	    return true;
1519
            return true;
1518
				
1520
                                
1519
	  case KEY_EQUALS:        // Screen size up
1521
          case KEY_EQUALS:        // Screen size up
1520
	    if (automapactive || chat_on)
1522
            if (automapactive || chat_on)
1521
		return false;
1523
                return false;
1522
	    M_SizeDisplay(1);
1524
            M_SizeDisplay(1);
1523
	    S_StartSound(NULL,sfx_stnmov);
1525
            S_StartSound(NULL,sfx_stnmov);
1524
	    return true;
1526
            return true;
1525
				
1527
                                
1526
	  case KEY_F1:            // Help key
1528
          case KEY_F1:            // Help key
1527
	    M_StartControlPanel ();
1529
            M_StartControlPanel ();
1528
 
1530
 
1529
	    if ( gamemode == retail )
1531
            if ( gamemode == retail )
1530
	      currentMenu = &ReadDef2;
1532
              currentMenu = &ReadDef2;
1531
	    else
1533
            else
1532
	      currentMenu = &ReadDef1;
1534
              currentMenu = &ReadDef1;
1533
	    
1535
            
1534
	    itemOn = 0;
1536
            itemOn = 0;
1535
	    S_StartSound(NULL,sfx_swtchn);
1537
            S_StartSound(NULL,sfx_swtchn);
1536
	    return true;
1538
            return true;
1537
				
1539
                                
1538
	  case KEY_F2:            // Save
1540
          case KEY_F2:            // Save
1539
	    M_StartControlPanel();
1541
            M_StartControlPanel();
1540
	    S_StartSound(NULL,sfx_swtchn);
1542
            S_StartSound(NULL,sfx_swtchn);
1541
	    M_SaveGame(0);
1543
            M_SaveGame(0);
1542
	    return true;
1544
            return true;
1543
				
1545
                                
1544
	  case KEY_F3:            // Load
1546
          case KEY_F3:            // Load
1545
	    M_StartControlPanel();
1547
            M_StartControlPanel();
1546
	    S_StartSound(NULL,sfx_swtchn);
1548
            S_StartSound(NULL,sfx_swtchn);
1547
	    M_LoadGame(0);
1549
            M_LoadGame(0);
1548
	    return true;
1550
            return true;
1549
				
1551
                                
1550
	  case KEY_F4:            // Sound Volume
1552
          case KEY_F4:            // Sound Volume
1551
	    M_StartControlPanel ();
1553
            M_StartControlPanel ();
1552
	    currentMenu = &SoundDef;
1554
            currentMenu = &SoundDef;
1553
	    itemOn = sfx_vol;
1555
            itemOn = sfx_vol;
1554
	    S_StartSound(NULL,sfx_swtchn);
1556
            S_StartSound(NULL,sfx_swtchn);
1555
	    return true;
1557
            return true;
1556
				
1558
                                
1557
	  case KEY_F5:            // Detail toggle
1559
          case KEY_F5:            // Detail toggle
1558
	    M_ChangeDetail(0);
1560
            M_ChangeDetail(0);
1559
	    S_StartSound(NULL,sfx_swtchn);
1561
            S_StartSound(NULL,sfx_swtchn);
1560
	    return true;
1562
            return true;
1561
				
1563
                                
1562
	  case KEY_F6:            // Quicksave
1564
          case KEY_F6:            // Quicksave
1563
	    S_StartSound(NULL,sfx_swtchn);
1565
            S_StartSound(NULL,sfx_swtchn);
1564
	    M_QuickSave();
1566
            M_QuickSave();
1565
	    return true;
1567
            return true;
1566
				
1568
                                
1567
	  case KEY_F7:            // End game
1569
          case KEY_F7:            // End game
1568
	    S_StartSound(NULL,sfx_swtchn);
1570
            S_StartSound(NULL,sfx_swtchn);
1569
	    M_EndGame(0);
1571
            M_EndGame(0);
1570
	    return true;
1572
            return true;
1571
				
1573
                                
1572
	  case KEY_F8:            // Toggle messages
1574
          case KEY_F8:            // Toggle messages
1573
	    M_ChangeMessages(0);
1575
            M_ChangeMessages(0);
1574
	    S_StartSound(NULL,sfx_swtchn);
1576
            S_StartSound(NULL,sfx_swtchn);
1575
	    return true;
1577
            return true;
1576
				
1578
                                
1577
	  case KEY_F9:            // Quickload
1579
          case KEY_F9:            // Quickload
1578
	    S_StartSound(NULL,sfx_swtchn);
1580
            S_StartSound(NULL,sfx_swtchn);
1579
	    M_QuickLoad();
1581
            M_QuickLoad();
1580
	    return true;
1582
            return true;
1581
				
1583
                                
1582
	  case KEY_F10:           // Quit DOOM
1584
          case KEY_F10:           // Quit DOOM
1583
	    S_StartSound(NULL,sfx_swtchn);
1585
            S_StartSound(NULL,sfx_swtchn);
1584
	    M_QuitDOOM(0);
1586
            M_QuitDOOM(0);
1585
	    return true;
1587
            return true;
1586
				
1588
                                
1587
	  case KEY_F11:           // gamma toggle
1589
          case KEY_F11:           // gamma toggle
1588
	    usegamma++;
1590
            usegamma++;
1589
	    if (usegamma > 4)
1591
            if (usegamma > 4)
1590
		usegamma = 0;
1592
                usegamma = 0;
1591
	    players[consoleplayer].message = gammamsg[usegamma];
1593
            players[consoleplayer].message = gammamsg[usegamma];
1592
	    I_SetPalette (W_CacheLumpName ("PLAYPAL",PU_CACHE));
1594
            I_SetPalette (W_CacheLumpName ("PLAYPAL",PU_CACHE));
1593
	    return true;
1595
            return true;
1594
				
1596
                                
1595
	}
1597
        }
1596
 
1598
 
1597
    
1599
    
1598
    // Pop-up menu?
1600
    // Pop-up menu?
1599
    if (!menuactive)
1601
    if (!menuactive)
1600
    {
1602
    {
1601
	if (ch == KEY_ESCAPE)
1603
        if (ch == KEY_ESCAPE)
1602
	{
1604
        {
1603
	    M_StartControlPanel ();
1605
            M_StartControlPanel ();
1604
	    S_StartSound(NULL,sfx_swtchn);
1606
            S_StartSound(NULL,sfx_swtchn);
1605
	    return true;
1607
            return true;
1606
	}
1608
        }
1607
	return false;
1609
        return false;
1608
    }
1610
    }
1609
 
1611
 
1610
    
1612
    
1611
    // Keys usable within menu
1613
    // Keys usable within menu
1612
    switch (ch)
1614
    switch (ch)
1613
    {
1615
    {
1614
      case KEY_DOWNARROW:
1616
      case KEY_DOWNARROW:
1615
	do
1617
        do
1616
	{
1618
        {
1617
	    if (itemOn+1 > currentMenu->numitems-1)
1619
            if (itemOn+1 > currentMenu->numitems-1)
1618
		itemOn = 0;
1620
                itemOn = 0;
1619
	    else itemOn++;
1621
            else itemOn++;
1620
	    S_StartSound(NULL,sfx_pstop);
1622
            S_StartSound(NULL,sfx_pstop);
1621
	} while(currentMenu->menuitems[itemOn].status==-1);
1623
        } while(currentMenu->menuitems[itemOn].status==-1);
1622
	return true;
1624
        return true;
1623
		
1625
                
1624
      case KEY_UPARROW:
1626
      case KEY_UPARROW:
1625
	do
1627
        do
1626
	{
1628
        {
1627
	    if (!itemOn)
1629
            if (!itemOn)
1628
		itemOn = currentMenu->numitems-1;
1630
                itemOn = currentMenu->numitems-1;
1629
	    else itemOn--;
1631
            else itemOn--;
1630
	    S_StartSound(NULL,sfx_pstop);
1632
            S_StartSound(NULL,sfx_pstop);
1631
	} while(currentMenu->menuitems[itemOn].status==-1);
1633
        } while(currentMenu->menuitems[itemOn].status==-1);
1632
	return true;
1634
        return true;
1633
 
1635
 
1634
      case KEY_LEFTARROW:
1636
      case KEY_LEFTARROW:
1635
	if (currentMenu->menuitems[itemOn].routine &&
1637
        if (currentMenu->menuitems[itemOn].routine &&
1636
	    currentMenu->menuitems[itemOn].status == 2)
1638
            currentMenu->menuitems[itemOn].status == 2)
1637
	{
1639
        {
1638
	    S_StartSound(NULL,sfx_stnmov);
1640
            S_StartSound(NULL,sfx_stnmov);
1639
	    currentMenu->menuitems[itemOn].routine(0);
1641
            currentMenu->menuitems[itemOn].routine(0);
1640
	}
1642
        }
1641
	return true;
1643
        return true;
1642
		
1644
                
1643
      case KEY_RIGHTARROW:
1645
      case KEY_RIGHTARROW:
1644
	if (currentMenu->menuitems[itemOn].routine &&
1646
        if (currentMenu->menuitems[itemOn].routine &&
1645
	    currentMenu->menuitems[itemOn].status == 2)
1647
            currentMenu->menuitems[itemOn].status == 2)
1646
	{
1648
        {
1647
	    S_StartSound(NULL,sfx_stnmov);
1649
            S_StartSound(NULL,sfx_stnmov);
1648
	    currentMenu->menuitems[itemOn].routine(1);
1650
            currentMenu->menuitems[itemOn].routine(1);
1649
	}
1651
        }
1650
	return true;
1652
        return true;
1651
 
1653
 
1652
      case KEY_ENTER:
1654
      case KEY_ENTER:
1653
	if (currentMenu->menuitems[itemOn].routine &&
1655
        if (currentMenu->menuitems[itemOn].routine &&
1654
	    currentMenu->menuitems[itemOn].status)
1656
            currentMenu->menuitems[itemOn].status)
1655
	{
1657
        {
1656
	    currentMenu->lastOn = itemOn;
1658
            currentMenu->lastOn = itemOn;
1657
	    if (currentMenu->menuitems[itemOn].status == 2)
1659
            if (currentMenu->menuitems[itemOn].status == 2)
1658
	    {
1660
            {
1659
		currentMenu->menuitems[itemOn].routine(1);      // right arrow
1661
                currentMenu->menuitems[itemOn].routine(1);      // right arrow
1660
		S_StartSound(NULL,sfx_stnmov);
1662
                S_StartSound(NULL,sfx_stnmov);
1661
	    }
1663
            }
1662
	    else
1664
            else
1663
	    {
1665
            {
1664
		currentMenu->menuitems[itemOn].routine(itemOn);
1666
                currentMenu->menuitems[itemOn].routine(itemOn);
1665
		S_StartSound(NULL,sfx_pistol);
1667
                S_StartSound(NULL,sfx_pistol);
1666
	    }
1668
            }
1667
	}
1669
        }
1668
	return true;
1670
        return true;
1669
		
1671
                
1670
      case KEY_ESCAPE:
1672
      case KEY_ESCAPE:
1671
	currentMenu->lastOn = itemOn;
1673
        currentMenu->lastOn = itemOn;
1672
	M_ClearMenus ();
1674
        M_ClearMenus ();
1673
	S_StartSound(NULL,sfx_swtchx);
1675
        S_StartSound(NULL,sfx_swtchx);
1674
	return true;
1676
        return true;
1675
		
1677
                
1676
      case KEY_BACKSPACE:
1678
      case KEY_BACKSPACE:
1677
	currentMenu->lastOn = itemOn;
1679
        currentMenu->lastOn = itemOn;
1678
	if (currentMenu->prevMenu)
1680
        if (currentMenu->prevMenu)
1679
	{
1681
        {
1680
	    currentMenu = currentMenu->prevMenu;
1682
            currentMenu = currentMenu->prevMenu;
1681
	    itemOn = currentMenu->lastOn;
1683
            itemOn = currentMenu->lastOn;
1682
	    S_StartSound(NULL,sfx_swtchn);
1684
            S_StartSound(NULL,sfx_swtchn);
1683
	}
1685
        }
1684
	return true;
1686
        return true;
1685
	
1687
        
1686
      default:
1688
      default:
1687
	for (i = itemOn+1;i < currentMenu->numitems;i++)
1689
        for (i = itemOn+1;i < currentMenu->numitems;i++)
1688
	    if (currentMenu->menuitems[i].alphaKey == ch)
1690
            if (currentMenu->menuitems[i].alphaKey == ch)
1689
	    {
1691
            {
1690
		itemOn = i;
1692
                itemOn = i;
1691
		S_StartSound(NULL,sfx_pstop);
1693
                S_StartSound(NULL,sfx_pstop);
1692
		return true;
1694
                return true;
1693
	    }
1695
            }
1694
	for (i = 0;i <= itemOn;i++)
1696
        for (i = 0;i <= itemOn;i++)
1695
	    if (currentMenu->menuitems[i].alphaKey == ch)
1697
            if (currentMenu->menuitems[i].alphaKey == ch)
1696
	    {
1698
            {
1697
		itemOn = i;
1699
                itemOn = i;
1698
		S_StartSound(NULL,sfx_pstop);
1700
                S_StartSound(NULL,sfx_pstop);
1699
		return true;
1701
                return true;
1700
	    }
1702
            }
1701
	break;
1703
        break;
1702
	
1704
        
1703
    }
1705
    }
1704
 
1706
 
1705
    return false;
1707
    return false;
1706
}
1708
}
1707
 
1709
 
1708
 
1710
 
1709
 
1711
 
1710
//
1712
//
1711
// M_StartControlPanel
1713
// M_StartControlPanel
1712
//
1714
//
1713
void M_StartControlPanel (void)
1715
void M_StartControlPanel (void)
1714
{
1716
{
1715
    // intro might call this repeatedly
1717
    // intro might call this repeatedly
1716
    if (menuactive)
1718
    if (menuactive)
1717
	return;
1719
        return;
1718
    
1720
    
1719
    menuactive = 1;
1721
    menuactive = 1;
1720
    currentMenu = &MainDef;         // JDC
1722
    currentMenu = &MainDef;         // JDC
1721
    itemOn = currentMenu->lastOn;   // JDC
1723
    itemOn = currentMenu->lastOn;   // JDC
1722
}
1724
}
1723
 
1725
 
1724
 
1726
 
1725
//
1727
//
1726
// M_Drawer
1728
// M_Drawer
1727
// Called after the view has been rendered,
1729
// Called after the view has been rendered,
1728
// but before it has been blitted.
1730
// but before it has been blitted.
1729
//
1731
//
1730
void M_Drawer (void)
1732
void M_Drawer (void)
1731
{
1733
{
1732
    static short	x;
1734
    static short        x;
1733
    static short	y;
1735
    static short        y;
1734
    short		i;
1736
    short               i;
1735
    short		max;
1737
    short               max;
1736
    char *p;
1738
    char *p;
1737
    int len;
1739
    int len;
1738
    char		string[40];
1740
    char                string[40];
1739
    int			start;
1741
    int                 start;
1740
 
1742
 
1741
    inhelpscreens = false;
1743
    inhelpscreens = false;
1742
 
1744
 
1743
    // Horiz. & Vertically center string and print it.
1745
    // Horiz. & Vertically center string and print it.
1744
    if (messageToPrint)
1746
    if (messageToPrint)
1745
    {
1747
    {
1746
	  y = 100 - M_StringHeight(messageString)/2;
1748
          y = 100 - M_StringHeight(messageString)/2;
1747
	  p = messageString;
1749
          p = messageString;
1748
	  len = strlen(p);
1750
          len = strlen(p);
1749
	  while(*p)
1751
          while(*p)
1750
	  {
1752
          {
1751
        for (i = 0;len;i++,len--)
1753
        for (i = 0;len;i++,len--)
1752
        {
1754
        {
1753
 	      if (*(p+i) == '\n')
1755
              if (*(p+i) == '\n')
1754
		  { memset(string,0,40);
1756
                  { memset(string,0,40);
1755
		    strncpy(string,p,i);
1757
                    strncpy(string,p,i);
1756
		    p+= i+1;
1758
                    p+= i+1;
1757
		    len-= 1;
1759
                    len-= 1;
1758
		    break;
1760
                    break;
1759
		  };
1761
                  };
1760
	    };	  
1762
            };    
1761
	
1763
        
1762
        if (len == 0)
1764
        if (len == 0)
1763
        { strncpy(string,p,i);
1765
        { strncpy(string,p,i);
1764
          p+=i;
1766
          p+=i;
1765
        };  
1767
        };  
1766
        x = 160 - M_StringWidth(string)/2;
1768
        x = 160 - M_StringWidth(string)/2;
1767
        M_WriteText(x,y,string);
1769
        M_WriteText(x,y,string);
1768
        y += SHORT(hu_font[0]->height);
1770
        y += SHORT(hu_font[0]->height);
1769
	  };
1771
          };
1770
	  return;
1772
          return;
1771
    };
1773
    };
1772
 
1774
 
1773
    if (!menuactive)
1775
    if (!menuactive)
1774
	return;
1776
        return;
1775
 
1777
 
1776
    if (currentMenu->routine)
1778
    if (currentMenu->routine)
1777
	currentMenu->routine();         // call Draw routine
1779
        currentMenu->routine();         // call Draw routine
1778
    
1780
    
1779
    // DRAW MENU
1781
    // DRAW MENU
1780
    x = currentMenu->x;
1782
    x = currentMenu->x;
1781
    y = currentMenu->y;
1783
    y = currentMenu->y;
1782
    max = currentMenu->numitems;
1784
    max = currentMenu->numitems;
1783
 
1785
 
1784
    for (i=0;i
1786
    for (i=0;i
1785
    {
1787
    {
1786
	if (currentMenu->menuitems[i].name[0])
1788
        if (currentMenu->menuitems[i].name[0])
1787
	    V_DrawPatchDirect (x,y,0,
1789
            V_DrawPatchDirect (x,y,0,
1788
			       W_CacheLumpName(currentMenu->menuitems[i].name ,PU_CACHE));
1790
                               W_CacheLumpName(currentMenu->menuitems[i].name ,PU_CACHE));
1789
	y += LINEHEIGHT;
1791
        y += LINEHEIGHT;
1790
    }
1792
    }
1791
 
1793
 
1792
    
1794
    
1793
    // DRAW SKULL
1795
    // DRAW SKULL
1794
    V_DrawPatchDirect(x + SKULLXOFF,currentMenu->y - 5 + itemOn*LINEHEIGHT, 0,
1796
    V_DrawPatchDirect(x + SKULLXOFF,currentMenu->y - 5 + itemOn*LINEHEIGHT, 0,
1795
		      W_CacheLumpName(skullName[whichSkull],PU_CACHE));
1797
                      W_CacheLumpName(skullName[whichSkull],PU_CACHE));
1796
 
1798
 
1797
}
1799
}
1798
 
1800
 
1799
 
1801
 
1800
//
1802
//
1801
// M_ClearMenus
1803
// M_ClearMenus
1802
//
1804
//
1803
void M_ClearMenus (void)
1805
void M_ClearMenus (void)
1804
{
1806
{
1805
    menuactive = 0;
1807
    menuactive = 0;
1806
    // if (!netgame && usergame && paused)
1808
    // if (!netgame && usergame && paused)
1807
    //       sendpause = true;
1809
    //       sendpause = true;
1808
}
1810
}
1809
 
1811
 
1810
 
1812
 
1811
 
1813
 
1812
 
1814
 
1813
//
1815
//
1814
// M_SetupNextMenu
1816
// M_SetupNextMenu
1815
//
1817
//
1816
void M_SetupNextMenu(menu_t *menudef)
1818
void M_SetupNextMenu(menu_t *menudef)
1817
{
1819
{
1818
    currentMenu = menudef;
1820
    currentMenu = menudef;
1819
    itemOn = currentMenu->lastOn;
1821
    itemOn = currentMenu->lastOn;
1820
}
1822
}
1821
 
1823
 
1822
 
1824
 
1823
//
1825
//
1824
// M_Ticker
1826
// M_Ticker
1825
//
1827
//
1826
void M_Ticker (void)
1828
void M_Ticker (void)
1827
{
1829
{
1828
    if (--skullAnimCounter <= 0)
1830
    if (--skullAnimCounter <= 0)
1829
    {
1831
    {
1830
	whichSkull ^= 1;
1832
        whichSkull ^= 1;
1831
	skullAnimCounter = 8;
1833
        skullAnimCounter = 8;
1832
    }
1834
    }
1833
}
1835
}
1834
 
1836
 
1835
 
1837
 
1836
//
1838
//
1837
// M_Init
1839
// M_Init
1838
//
1840
//
1839
void M_Init (void)
1841
void M_Init (void)
1840
{
1842
{
1841
    currentMenu = &MainDef;
1843
    currentMenu = &MainDef;
1842
    menuactive = 0;
1844
    menuactive = 0;
1843
    itemOn = currentMenu->lastOn;
1845
    itemOn = currentMenu->lastOn;
1844
    whichSkull = 0;
1846
    whichSkull = 0;
1845
    skullAnimCounter = 10;
1847
    skullAnimCounter = 10;
1846
    screenSize = screenblocks - 3;
1848
    screenSize = screenblocks - 3;
1847
    messageToPrint = 0;
1849
    messageToPrint = 0;
1848
    messageString = NULL;
1850
    messageString = NULL;
1849
    messageLastMenuActive = menuactive;
1851
    messageLastMenuActive = menuactive;
1850
    quickSaveSlot = -1;
1852
    quickSaveSlot = -1;
1851
 
1853
 
1852
    // Here we could catch other version dependencies,
1854
    // Here we could catch other version dependencies,
1853
    //  like HELP1/2, and four episodes.
1855
    //  like HELP1/2, and four episodes.
1854
 
1856
 
1855
  
1857
  
1856
    switch ( gamemode )
1858
    switch ( gamemode )
1857
    {
1859
    {
1858
      case commercial:
1860
      case commercial:
1859
	// This is used because DOOM 2 had only one HELP
1861
        // This is used because DOOM 2 had only one HELP
1860
        //  page. I use CREDIT as second page now, but
1862
        //  page. I use CREDIT as second page now, but
1861
	//  kept this hack for educational purposes.
1863
        //  kept this hack for educational purposes.
1862
	MainMenu[readthis] = MainMenu[quitdoom];
1864
        MainMenu[readthis] = MainMenu[quitdoom];
1863
	MainDef.numitems--;
1865
        MainDef.numitems--;
1864
	MainDef.y += 8;
1866
        MainDef.y += 8;
1865
	NewDef.prevMenu = &MainDef;
1867
        NewDef.prevMenu = &MainDef;
1866
	ReadDef1.routine = M_DrawReadThis1;
1868
        ReadDef1.routine = M_DrawReadThis1;
1867
	ReadDef1.x = 330;
1869
        ReadDef1.x = 330;
1868
	ReadDef1.y = 165;
1870
        ReadDef1.y = 165;
1869
	ReadMenu1[0].routine = M_FinishReadThis;
1871
        ReadMenu1[0].routine = M_FinishReadThis;
1870
	break;
1872
        break;
1871
      case shareware:
1873
      case shareware:
1872
	// Episode 2 and 3 are handled,
1874
        // Episode 2 and 3 are handled,
1873
	//  branching to an ad screen.
1875
        //  branching to an ad screen.
1874
      case registered:
1876
      case registered:
1875
	// We need to remove the fourth episode.
1877
        // We need to remove the fourth episode.
1876
	EpiDef.numitems--;
1878
        EpiDef.numitems--;
1877
	break;
1879
        break;
1878
      case retail:
1880
      case retail:
1879
	// We are fine.
1881
        // We are fine.
1880
      default:
1882
      default:
1881
	break;
1883
        break;
1882
    }
1884
    }
1883
    
1885
    
1884
}
1886
}
1885
>
1887
>
1886
>
1888
>
1887
>
1889
>