DEADSOFTWARE

Editing source tree for configuring with CMake
[flatwaifu.git] / src / menu.c
1 /*
2 Copyright (C) Prikol Software 1996-1997
3 Copyright (C) Aleksey Volynskov 1996-1997
4 Copyright (C) <ARembo@gmail.com> 2011
6 This file is part of the Doom2D:Rembo project.
8 Doom2D:Rembo is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License version 2 as
10 published by the Free Software Foundation.
12 Doom2D:Rembo is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, see <http://www.gnu.org/licenses/> or
19 write to the Free Software Foundation, Inc.,
20 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 */
23 #include "glob.h"
24 #include <stdio.h>
25 #include <string.h>
26 #include <stdlib.h>
27 #include "files.h"
28 #include "memory.h"
29 #include "vga.h"
30 #include "error.h"
31 #include "keyb.h"
32 #include "sound.h"
33 #include "view.h"
34 #include "player.h"
35 #include "switch.h"
36 #include "menu.h"
37 #include "misc.h"
39 #include "SDL.h"
40 extern SDL_Surface *screen;
42 #define QSND_NUM 14
44 enum{HIT100,ARMOR,JUMP,WPNS,IMMORTAL,SPEED,OPEN,EXIT};
46 extern int PL_JUMP,PL_RUN;
47 extern byte _warp,cheat,p_fly;
49 extern byte g_music[8];
51 extern byte savname[7][24],savok[7];
52 void load_game(int);
54 static byte panim[]=
55 "BBDDAACCDDAABBDDAACCDDAABBDDAACCDDAAEEEEEFEFEFEFEFEFEFEFEFEFEEEEE";
56 static byte *panimp=panim;
58 #define PCOLORN 10
59 byte pcolortab[PCOLORN]={
60 0x18,0x20,0x40,0x58,0x60,0x70,0x80,0xB0,0xC0,0xD0
61 };
62 int p1color=5,p2color=4;
64 static byte ibuf[24],input=0;
65 static int icur;
67 enum{MENU,MSG};
68 enum{CANCEL,NEWGAME,LOADGAME,SAVEGAME,OPTIONS,QUITGAME,QUIT,ENDGAME,ENDGM,
69 PLR1,PLR2,COOP,DM,VOLUME,GAMMA,LOAD,SAVE,PLCOLOR,PLCEND,MUSIC,INTERP,
70 SVOLM,SVOLP,MVOLM,MVOLP,GAMMAM,GAMMAP,PL1CM,PL1CP,PL2CM,PL2CP};
72 #ifndef DEMO
73 static int qsnd[QSND_NUM];
74 #endif
76 static char *main_txt[]={
77 "NEW GAME","LOAD GAME","SAVE GAME","OPTIONS","EXIT"
78 },*opt_txt[]={
79 "RESTART","VOLUME","BRIGHTNESS","MUSIC","FULLSCREEN:"
80 },*ngplr_txt[]={
81 "ONE PLAYER","TWO PLAYERS"
82 },*ngdm_txt[]={
83 "COOPERATIVE","DEATHMATCH"
84 },*vol_txt[]={
85 "SOUND","MUSIC"
86 },*plcolor_txt[]={
87 "FIRST","SECOND"
88 },*gamma_txt[]={
89 ""
90 };
92 static byte main_typ[]={
93 NEWGAME,LOADGAME,SAVEGAME,OPTIONS,QUITGAME
94 },ngplr_typ[]={
95 PLR1,PLR2
96 },ngdm_typ[]={
97 COOP,DM
98 },opt_typ[]={
99 ENDGAME,VOLUME,GAMMA,MUSIC,INTERP
100 },quit_typ[]={
101 QUIT,CANCEL
102 },endgm_typ[]={
103 ENDGM,CANCEL
104 },vol_typ[]={
105 SVOLM,MVOLM
106 },plcolor_typ[]={
107 PL1CM,PL2CM
108 },gamma_typ[]={
109 GAMMAM
110 },load_typ[]={
111 LOAD,LOAD,LOAD,LOAD,LOAD,LOAD,LOAD
112 },save_typ[]={
113 SAVE,SAVE,SAVE,SAVE,SAVE,SAVE,SAVE
114 };
116 static menu_t main_mnu={
117 MENU,5,0,80,"MENU",main_txt,main_typ
118 },opt_mnu={
119 MENU,5,0,75,"OPTIONS",opt_txt,opt_typ
120 },ngplr_mnu={
121 MENU,2,0,90,"NEW GAME",ngplr_txt,ngplr_typ
122 },ngdm_mnu={
123 MENU,2,0,90,"GAME TYPE",ngdm_txt,ngdm_typ
124 },vol_mnu={
125 MENU,2,0,40,"VOLUME",vol_txt,vol_typ
126 },plcolor_mnu={
127 MENU,2,0,90,"COLOR",plcolor_txt,plcolor_typ
128 },gamma_mnu={
129 MENU,1,0,85,"BRIGHTNESS",gamma_txt,gamma_typ
130 },load_mnu={
131 MENU,7,0,85,"LOAD GAME",NULL,load_typ
132 },save_mnu={
133 MENU,7,0,85,"SAVE GAME",NULL,save_typ
134 },quit1_msg={
135 MSG,0,0,0,"ARE YOU SURE?",NULL,quit_typ
136 },quit2_msg={
137 MSG,0,0,0,"ARE YOU SURE?",NULL,quit_typ
138 },quit3_msg={
139 MSG,0,0,0,"ARE YOU SURE?",NULL,quit_typ
140 },endgm_msg={
141 MSG,0,0,0,"RESTART LEVEL?",NULL,endgm_typ
142 };
144 static menu_t *qmsg[3]={&quit1_msg,&quit2_msg,&quit3_msg};
146 static menu_t *mnu=NULL;
148 static byte gm_redraw=0;
149 static int gm_tm=0;
150 short lastkey=0;
151 static void *csnd1,*csnd2,*msnd1,*msnd2,*msnd3,*msnd4,*msnd5,*msnd6;
152 static int movsndt=0;
153 static vgaimg *msklh[2],*mbarl,*mbarm,*mbarr,*mbaro,*mslotl,*mslotm,*mslotr;
154 static byte cbuf[32];
156 static snd_t *voc=NULL;
157 static int voc_ch=0;
159 void GMV_stop(void) {
160 if(voc) {
161 if(voc_ch) {S_stop(voc_ch);voc_ch=0;}
162 free(voc);voc=NULL;
166 void GMV_say(char *nm) {
167 int r,len;
168 snd_t *p;
169 byte *d;
171 if((r=F_findres(nm))==-1) return;
172 if(!(p=malloc((len=F_getreslen(r))+16))) return;
173 p->len=len;p->rate=11000;
174 p->lstart=p->llen=0;
175 GMV_stop();
176 F_loadres(r,p+1,0,len);
177 for(d=(byte*)(p+1);len;--len,++d) *d^=128;
178 voc=p;
179 voc_ch=S_play(voc,-1,1024,255);
182 void G_code(void) {
183 void *s;
184 s=csnd2;
185 if(memcmp(cbuf+32-5,"IDDQD",5)==0) {
186 PL_hit(&pl1,400,0,HIT_SOME);
187 if(_2pl) PL_hit(&pl2,400,0,HIT_SOME);
188 s=csnd1;
189 }else if(memcmp(cbuf+32-4,"TANK",4)==0) {
190 pl1.life=pl1.armor=200;pl1.drawst|=PL_DRAWARMOR|PL_DRAWLIFE;
191 if(_2pl) {pl2.life=pl2.armor=200;pl2.drawst|=PL_DRAWARMOR|PL_DRAWLIFE;}
192 }else if(memcmp(cbuf+32-8,"BULLFROG",8)==0) {
193 PL_JUMP=(PL_JUMP==10)?20:10;
194 }else if(memcmp(cbuf+32-8,"FORMULA1",8)==0) {
195 PL_RUN=(PL_RUN==8)?24:8;
196 }else if(memcmp(cbuf+32-5,"RAMBO",5)==0) {
197 pl1.ammo=pl1.shel=pl1.rock=pl1.cell=pl1.fuel=30000;
198 pl1.wpns=0x7FF;pl1.drawst|=PL_DRAWWPN|PL_DRAWKEYS;
199 pl1.keys=0x70;
200 if(_2pl) {
201 pl2.ammo=pl2.shel=pl2.rock=pl2.cell=pl1.fuel=30000;
202 pl2.wpns=0x7FF;pl2.drawst|=PL_DRAWWPN|PL_DRAWKEYS;
203 pl2.keys=0x70;
205 }else if(memcmp(cbuf+32-5,"UJHTW",5)==0) {
206 p_immortal=!p_immortal;
207 }else if(memcmp(cbuf+32-9,",TKSQJHTK",9)==0) {
208 p_fly=!p_fly;
209 }else if(memcmp(cbuf+32-6,"CBVCBV",6)==0) {
210 SW_cheat_open();
211 }else if(memcmp(cbuf+32-7,"GOODBYE",7)==0) {
212 g_exit=1;
213 }else if(memcmp(cbuf+32-9,"GJITKYF",7)==0) {
214 if(cbuf[30]>='0' && cbuf[30]<='9' && cbuf[31]>='0' && cbuf[31]<='9') {
215 g_map=(cbuf[30]=='0')?0:(cbuf[30]-'0')*10;
216 g_map+=(cbuf[31]=='0')?0:(cbuf[31]-'0');
217 G_start();
219 }else return;
220 memset(cbuf,0,32);
221 Z_sound(s,128);
224 void GM_set(menu_t *m) {
225 mnu=m;gm_redraw=1;
226 if(g_st==GS_GAME) {
227 //V_setrect(0,SCRW,0,SCRH);V_clr(0,SCRW,0,SCRH,0);//V_setrect(0,320,0,200);V_clr(0,320,0,200,0);
228 //if(_2pl) {V_setrect(SCRW-120,120,0,SCRH);w_o=0;Z_clrst();w_o=SCRH/2;Z_clrst();}//if(_2pl) {V_setrect(200,120,0,200);w_o=0;Z_clrst();w_o=100;Z_clrst();}
229 //else {V_setrect(SCRW-120,120,0,SCRH);w_o=0;Z_clrst();}//else {V_setrect(200,120,50,100);w_o=50;Z_clrst();}
230 //pl1.drawst=pl2.drawst=0xFF;V_setrect(0,SCRW,0,SCRH);//V_setrect(0,320,0,200);
234 void setgamma(int);
236 void GM_command(int c) {
237 switch(c) {
238 case CANCEL:
239 GM_set(NULL);break;
240 case INTERP:
241 fullscreen=!fullscreen;
242 V_toggle();
243 GM_set(mnu);
244 break;
245 case MUSIC:
246 F_freemus();
247 F_nextmus(g_music);
248 F_loadmus(g_music);
249 S_startmusic(music_time*2);
250 GM_set(mnu);
251 break;
252 case NEWGAME:
253 GMV_say("_NEWGAME");
254 GM_set(&ngplr_mnu);break;
255 case PLR2:
256 GMV_say("_2PLAYER");
257 GM_set(&ngdm_mnu);break;
258 case PLR1:
259 GMV_say("_1PLAYER");
260 ngdm_mnu.cur=0;
261 case COOP: case DM:
262 if(c==COOP) GMV_say("_COOP");
263 else if(c==DM) GMV_say("_DM");
264 if(c!=PLR1) {GM_set(&plcolor_mnu);break;}
265 case PLCEND:
266 _2pl=ngplr_mnu.cur;
267 g_dm=ngdm_mnu.cur;
268 g_map=(_warp)?_warp:1;
269 PL_reset();
270 if(_2pl) {
271 pl1.color=pcolortab[p1color];
272 pl2.color=pcolortab[p2color];
273 }else pl1.color=0x70;
274 G_start();
275 GM_set(NULL);break;
276 case OPTIONS:
277 GMV_say("_RAZNOE");
278 GM_set(&opt_mnu);break;
279 case LOADGAME:
280 GMV_say("_OLDGAME");
281 F_getsavnames();GM_set(&load_mnu);break;
282 case SAVEGAME:
283 if(g_st!=GS_GAME) break;
284 GMV_say("_SAVEGAM");
285 F_getsavnames();GM_set(&save_mnu);break;
286 case SAVE:
287 input=1;memcpy(ibuf,savname[save_mnu.cur],24);icur=strlen(ibuf);
288 GM_set(mnu);break;
289 case LOAD:
290 if(!savok[load_mnu.cur]) break;
291 load_game(load_mnu.cur);
292 GM_set(NULL);break;
293 case VOLUME:
294 GMV_say("_VOLUME");
295 GM_set(&vol_mnu);break;
296 case GAMMA:
297 GMV_say("_GAMMA");
298 GM_set(&gamma_mnu);break;
299 case QUITGAME:
300 GMV_say((rand()&1)?"_EXIT1":"_EXIT2");
301 GM_set(qmsg[myrand(3)]);break;
302 case ENDGAME:
303 if(g_st!=GS_GAME) break;
304 GMV_say("_RESTART");
305 GM_set(&endgm_msg);break;
306 case QUIT:
307 F_freemus();
308 GMV_stop();
309 #ifndef DEMO
310 c=Z_sound(M_lock(qsnd[myrand(QSND_NUM)]),256);//for(c=(Z_sound(M_lock(qsnd[random2(QSND_NUM)]),256)+9)<<16,timer=0;timer<c;);
311 S_wait();
312 #endif
313 ERR_quit();break;
314 case ENDGM:
315 PL_reset();G_start();
316 GM_set(NULL);break;
317 case PL1CM:
318 if(--p1color<0) p1color=PCOLORN-1; break;
319 case PL1CP:
320 if(++p1color>=PCOLORN) p1color=0; break;
321 case PL2CM:
322 if(--p2color<0) p2color=PCOLORN-1; break;
323 case PL2CP:
324 if(++p2color>=PCOLORN) p2color=0; break;
325 case SVOLM:
326 S_volume(snd_vol-8);break;
327 case SVOLP:
328 S_volume(snd_vol+8);break;
329 case MVOLM:
330 S_volumemusic(mus_vol-8);break;
331 case MVOLP:
332 S_volumemusic(mus_vol+8);break;
333 case GAMMAM: setgamma(gammaa-1);break;
334 case GAMMAP: setgamma(gammaa+1);break;
338 /*
339 byte keychar[2][128]={{
340 0,0,'1','2','3','4','5','6','7','8','9','0','-','=',0,0,
341 'Q','W','E','R','T','Y','U','I','O','P','[',']','\r',0,'A','S',
342 'D','F','G','H','J','K','L',';','\'',0,0,'\\','Z','X','C','V',
343 'B','N','M',',','.','/',0,'*',0,' ',0,0,0,0,0,0,
344 0,0,0,0,0,0,0,0,0,0,'-',0,0,0,'+',0,
345 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
346 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
347 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
348 },{
349 0,0,'!','\"','#','$','%',':','&','*','(',')','_','+',0,0,
350 'x','x','x','x','x','x','x','x','x','x','x','x','\r',0,'x','x',
351 'x','x','x','x','x','x','x','x','x',0,0,0,'x','x','x','x',
352 'x','x','x','x','x','?',0,'*',0,' ',0,0,0,0,0,0,
353 0,0,0,0,0,0,0,0,0,0,'-',0,0,0,'+',0,
354 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
355 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
356 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
357 }};
358 */
360 struct {
361 int keysym;
362 byte ch;
363 } keychar[] = {
364 {SDLK_SPACE, ' '},
365 {SDLK_0, '0'},
366 {SDLK_1, '1'},
367 {SDLK_2, '2'},
368 {SDLK_3, '3'},
369 {SDLK_4, '4'},
370 {SDLK_5, '5'},
371 {SDLK_6, '6'},
372 {SDLK_7, '7'},
373 {SDLK_8, '8'},
374 {SDLK_9, '9'},
375 {SDLK_UNDERSCORE, '_'},
376 {SDLK_a, 'A'},
377 {SDLK_b, 'B'},
378 {SDLK_c, 'C'},
379 {SDLK_d, 'D'},
380 {SDLK_e, 'E'},
381 {SDLK_f, 'F'},
382 {SDLK_g, 'G'},
383 {SDLK_h, 'H'},
384 {SDLK_i, 'I'},
385 {SDLK_j, 'J'},
386 {SDLK_k, 'K'},
387 {SDLK_l, 'L'},
388 {SDLK_m, 'M'},
389 {SDLK_n, 'N'},
390 {SDLK_o, 'O'},
391 {SDLK_p, 'P'},
392 {SDLK_q, 'Q'},
393 {SDLK_r, 'R'},
394 {SDLK_s, 'S'},
395 {SDLK_t, 'T'},
396 {SDLK_u, 'U'},
397 {SDLK_v, 'V'},
398 {SDLK_w, 'W'},
399 {SDLK_x, 'X'},
400 {SDLK_y, 'Y'},
401 {SDLK_z, 'Z'},
402 {SDLK_COMMA,','},
403 {0}
404 };
406 byte get_keychar(int keysym)
408 int i = 0;
409 while (keychar[i].keysym) {
410 if (keychar[i].keysym == keysym) return keychar[i].ch;
411 i++;
413 return 0;
416 extern vgapal main_pal,std_pal;
417 extern byte shot_vga;
419 static void shot(void) {
420 static int num=1;
421 char fn[13];
422 sprintf(fn,"shot%04d.bmp",num);
423 SDL_SaveBMP(screen, fn);
424 ++num;
427 int GM_act(void) {
428 byte c;
430 if(mnu==&plcolor_mnu) {
431 if(*(++panimp)==0) panimp=panim;
432 GM_set(mnu);
434 if(movsndt>0) --movsndt; else movsndt=0;
435 if(g_st==GS_TITLE) if(!mnu) if(lastkey) {
436 GM_set(&main_mnu);Z_sound(msnd3,128);
437 lastkey=0;
438 return 1;
440 if(input) switch(lastkey) {
441 case SDLK_RETURN: case SDLK_KP_ENTER://case 0x1C: case 0x9C:
442 F_savegame(save_mnu.cur,ibuf);
443 input=0;GM_set(NULL);break;
444 case 1: input=0;GM_set(mnu);break;
445 case SDLK_BACKSPACE://case 0x0E:
446 if(icur) {ibuf[--icur]=0;GM_set(mnu);} break;
447 default:
448 if(icur>=23) break;
449 c=get_keychar(lastkey);//c=keychar[(keys[0x2A] || keys[0x36])?1:0][lastkey];
450 if(!c) break;
451 ibuf[icur]=c;ibuf[++icur]=0;GM_set(mnu);
452 }else {
453 switch(lastkey) {
454 case SDLK_ESCAPE://case 1:
455 if(!mnu) {GM_set(&main_mnu);Z_sound(msnd3,128);}
456 else {GM_set(NULL);Z_sound(msnd4,128);}
457 break;
458 case SDLK_F5:
459 if(mnu) break;
460 Z_sound(msnd3,128);
461 GMV_say("_GAMMA");
462 GM_set(&gamma_mnu);break;
463 case SDLK_F4://case 0x3E:
464 if(mnu) break;
465 Z_sound(msnd3,128);
466 GMV_say("_VOLUME");
467 GM_set(&vol_mnu);break;
468 case SDLK_F2://case 0x3C:
469 if(mnu) break;
470 if(g_st!=GS_GAME) break;
471 Z_sound(msnd3,128);
472 F_getsavnames();GM_set(&save_mnu);break;
473 case SDLK_F3://case 0x3D:
474 if(mnu) break;
475 Z_sound(msnd3,128);
476 F_getsavnames();GM_set(&load_mnu);break;
477 case SDLK_F10://case 0x44:
478 if(mnu) break;
479 Z_sound(msnd3,128);
480 GM_command(QUITGAME);break;
481 case SDLK_UP: case SDLK_KP8://case 0x48: case 0xC8:
482 if(!mnu) break;
483 if(mnu->type!=MENU) break;
484 if(--mnu->cur<0) mnu->cur=mnu->n-1;
485 GM_set(mnu);
486 Z_sound(msnd1,128);break;
487 case SDLK_DOWN: case SDLK_KP5: case SDLK_KP2://case 0x50: case 0xD0: case 0x4C:
488 if(!mnu) break;
489 if(mnu->type!=MENU) break;
490 if(++mnu->cur>=mnu->n) mnu->cur=0;
491 GM_set(mnu);
492 Z_sound(msnd1,128);break;
493 case SDLK_LEFT: case SDLK_RIGHT: case SDLK_KP4: case SDLK_KP6://case 0x4B: case 0x4D: case 0xCB: case 0xCD:
494 if(!mnu) break;
495 if(mnu->type!=MENU) break;
496 if(mnu->t[mnu->cur]<SVOLM) break;
497 GM_command(mnu->t[mnu->cur]+((lastkey==SDLK_LEFT || lastkey==SDLK_KP4)?0:1));//GM_command(mnu->t[mnu->cur]+((lastkey==0x4B || lastkey==0xCB)?0:1));
498 GM_set(mnu);
499 if(!movsndt) movsndt=Z_sound((lastkey==SDLK_LEFT || lastkey==SDLK_KP4)?msnd5:msnd6,255);//if(!movsndt) movsndt=Z_sound((lastkey==0x4B || lastkey==0xCB)?msnd5:msnd6,255);
500 break;
501 case SDLK_RETURN: case SDLK_SPACE: case SDLK_KP_ENTER://case 0x1C: case 0x39: case 0x9C:
502 if(!mnu) break;
503 if(mnu->type!=MENU) break;
504 if(mnu->t[mnu->cur]>=PL1CM) {
505 Z_sound(msnd2,128);
506 GM_command(PLCEND);
507 break;
509 if(mnu->t[mnu->cur]>=SVOLM) break;
510 Z_sound(msnd2,128);
511 GM_command(mnu->t[mnu->cur]);
512 break;
513 case SDLK_y://case 0x15:
514 if(!mnu) break;
515 if(mnu->type!=MSG) break;
516 Z_sound(msnd3,128);
517 GM_command(mnu->t[0]);
518 break;
519 case SDLK_n://case 0x31:
520 if(!mnu) break;
521 if(mnu->type!=MSG) break;
522 Z_sound(msnd4,128);
523 GM_command(mnu->t[1]);
524 break;
525 case SDLK_F1://case 0x3B:
526 if(shot_vga) {shot();Z_sound(msnd4,128);}
527 break;
530 lastkey=0;
531 return((mnu)?1:0);
534 void G_keyf(int k, int press) {
535 int i;
537 lastkey=k;
538 if(!_2pl || cheat) {
539 for(i=0;i<31;++i) cbuf[i]=cbuf[i+1];
540 cbuf[31]=get_keychar(k);
544 void GM_init(void) {
545 #ifndef DEMO
546 int i;
547 static char nm[QSND_NUM][6]={
548 "CYBSIT","KNTDTH","MNPAIN","PEPAIN","SLOP","MANSIT","BOSPN","VILACT",
549 "PLFALL","BGACT","BGDTH2","POPAIN","SGTATK","VILDTH"
550 };
551 char s[8];
553 s[0]='D';s[1]='S';
554 for(i=0;i<QSND_NUM;++i) {
555 memcpy(s+2,nm[i],6);
556 qsnd[i]=F_getresid(s);
558 #endif
559 csnd1=Z_getsnd("HAHA1");
560 csnd2=Z_getsnd("RADIO");
561 msnd1=Z_getsnd("PSTOP");
562 msnd2=Z_getsnd("PISTOL");
563 msnd3=Z_getsnd("SWTCHN");
564 msnd4=Z_getsnd("SWTCHX");
565 msnd5=Z_getsnd("SUDI");
566 msnd6=Z_getsnd("TUDI");
567 msklh[0]=M_lock(F_getresid("M_SKULL1"));
568 // msklh[0]=load_vga("vga\\spr.vga","M_SKULL1");
569 msklh[1]=M_lock(F_getresid("M_SKULL2"));
570 mbarl=M_lock(F_getresid("M_THERML"));
571 mbarm=M_lock(F_getresid("M_THERMM"));
572 mbarr=M_lock(F_getresid("M_THERMR"));
573 mbaro=M_lock(F_getresid("M_THERMO"));
574 mslotl=M_lock(F_getresid("M_LSLEFT"));
575 mslotm=M_lock(F_getresid("M_LSCNTR"));
576 mslotr=M_lock(F_getresid("M_LSRGHT"));
577 K_setkeyproc(G_keyf);
580 int GM_draw(void) {
581 int i,j,k,y;
583 ++gm_tm;
584 V_setrect(0,SCRW,0,SCRH);//V_setrect(0,320,0,200);
585 if(!mnu && !gm_redraw) return 0;
586 gm_redraw=0;
587 if(!mnu) return 1;
588 if(mnu->type==MENU) {
589 y=(200-mnu->n*16-20)/2;
590 Z_gotoxy(mnu->x,y-10);Z_printbf(mnu->ttl);
591 for(i=0;i<mnu->n;++i) {
592 if(mnu->t[i]==LOAD || mnu->t[i]==SAVE) {
593 V_spr(mnu->x,j=y+i*16+29,mslotl);
594 for(k=8;k<184;k+=8)
595 V_spr(mnu->x+k,j,mslotm);
596 V_spr(mnu->x+184,j,mslotr);
597 Z_gotoxy(mnu->x+4,j-8);
598 if(input && i==save_mnu.cur) Z_printsf("%s_",ibuf);
599 else Z_printsf("%s",savname[i]);
600 }else{
601 Z_gotoxy(mnu->x+((mnu->t[i]>=SVOLM)?((mnu->t[i]>=PL1CM)?50:152):0),y+i*16+20);
602 Z_printbf(mnu->m[i]);
604 if(mnu->t[i]==MUSIC) {
605 Z_printbf(" '%.8s'",g_music);
606 }else if(mnu->t[i]==INTERP) {
607 Z_printbf("%s",fullscreen?"ON":"OFF");
608 }else if(mnu->t[i]>=PL1CM) {
609 V_manspr(mnu->x+((mnu->t[i]==PL1CM)?15:35),y+i*16+20+14,
610 PL_getspr(*panimp,0),
611 pcolortab[(mnu->t[i]==PL1CM)?p1color:p2color]
612 );
613 }else if(mnu->t[i]>=SVOLM) {
614 V_spr(mnu->x,j=y+i*16+20,mbarl);
615 for(k=8;k<144;k+=8)
616 V_spr(mnu->x+k,j,mbarm);
617 V_spr(mnu->x+144,j,mbarr);
618 switch(mnu->t[i]) {
619 case SVOLM: k=snd_vol;break;
620 case MVOLM: k=mus_vol;break;
621 case GAMMAM: k=gammaa<<5;break;
623 V_spr(mnu->x+8+k,j,mbaro);
626 V_spr(mnu->x-25,y+mnu->cur*16+20-8,msklh[(gm_tm/6)&1]);
627 }else{
628 Z_gotoxy((320-strlen(mnu->ttl)*7)/2,90);Z_printsf(mnu->ttl);
629 Z_gotoxy(136,100);Z_printsf("(Y/N)");
631 return 1;