DEADSOFTWARE

Скриншоты теперь сохраняются в $HOME/.doom2d-rembo
[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 #include <sys/stat.h>
41 extern SDL_Surface *screen;
43 #define QSND_NUM 14
45 enum{HIT100,ARMOR,JUMP,WPNS,IMMORTAL,SPEED,OPEN,EXIT};
47 extern int PL_JUMP,PL_RUN;
48 extern byte _warp,cheat,p_fly;
50 extern byte g_music[8];
52 extern byte savname[7][24],savok[7];
53 void load_game(int);
55 static byte panim[]=
56 "BBDDAACCDDAABBDDAACCDDAABBDDAACCDDAAEEEEEFEFEFEFEFEFEFEFEFEFEEEEE";
57 static byte *panimp=panim;
59 #define PCOLORN 10
60 byte pcolortab[PCOLORN]={
61 0x18,0x20,0x40,0x58,0x60,0x70,0x80,0xB0,0xC0,0xD0
62 };
63 int p1color=5,p2color=4;
65 static byte ibuf[24],input=0;
66 static int icur;
68 enum{MENU,MSG};
69 enum{CANCEL,NEWGAME,LOADGAME,SAVEGAME,OPTIONS,QUITGAME,QUIT,ENDGAME,ENDGM,
70 PLR1,PLR2,COOP,DM,VOLUME,GAMMA,LOAD,SAVE,PLCOLOR,PLCEND,MUSIC,INTERP,
71 SVOLM,SVOLP,MVOLM,MVOLP,GAMMAM,GAMMAP,PL1CM,PL1CP,PL2CM,PL2CP};
73 #ifndef DEMO
74 static int qsnd[QSND_NUM];
75 #endif
77 static char *main_txt[]={
78 "NEW GAME","LOAD GAME","SAVE GAME","OPTIONS","EXIT"
79 },*opt_txt[]={
80 "RESTART","VOLUME","BRIGHTNESS","MUSIC","FULLSCREEN:"
81 },*ngplr_txt[]={
82 "ONE PLAYER","TWO PLAYERS"
83 },*ngdm_txt[]={
84 "COOPERATIVE","DEATHMATCH"
85 },*vol_txt[]={
86 "SOUND","MUSIC"
87 },*plcolor_txt[]={
88 "FIRST","SECOND"
89 },*gamma_txt[]={
90 ""
91 };
93 static byte main_typ[]={
94 NEWGAME,LOADGAME,SAVEGAME,OPTIONS,QUITGAME
95 },ngplr_typ[]={
96 PLR1,PLR2
97 },ngdm_typ[]={
98 COOP,DM
99 },opt_typ[]={
100 ENDGAME,VOLUME,GAMMA,MUSIC,INTERP
101 },quit_typ[]={
102 QUIT,CANCEL
103 },endgm_typ[]={
104 ENDGM,CANCEL
105 },vol_typ[]={
106 SVOLM,MVOLM
107 },plcolor_typ[]={
108 PL1CM,PL2CM
109 },gamma_typ[]={
110 GAMMAM
111 },load_typ[]={
112 LOAD,LOAD,LOAD,LOAD,LOAD,LOAD,LOAD
113 },save_typ[]={
114 SAVE,SAVE,SAVE,SAVE,SAVE,SAVE,SAVE
115 };
117 static menu_t main_mnu={
118 MENU,5,0,80,"MENU",main_txt,main_typ
119 },opt_mnu={
120 MENU,5,0,75,"OPTIONS",opt_txt,opt_typ
121 },ngplr_mnu={
122 MENU,2,0,90,"NEW GAME",ngplr_txt,ngplr_typ
123 },ngdm_mnu={
124 MENU,2,0,90,"GAME TYPE",ngdm_txt,ngdm_typ
125 },vol_mnu={
126 MENU,2,0,40,"VOLUME",vol_txt,vol_typ
127 },plcolor_mnu={
128 MENU,2,0,90,"COLOR",plcolor_txt,plcolor_typ
129 },gamma_mnu={
130 MENU,1,0,85,"BRIGHTNESS",gamma_txt,gamma_typ
131 },load_mnu={
132 MENU,7,0,85,"LOAD GAME",NULL,load_typ
133 },save_mnu={
134 MENU,7,0,85,"SAVE GAME",NULL,save_typ
135 },quit1_msg={
136 MSG,0,0,0,"ARE YOU SURE?",NULL,quit_typ
137 },quit2_msg={
138 MSG,0,0,0,"ARE YOU SURE?",NULL,quit_typ
139 },quit3_msg={
140 MSG,0,0,0,"ARE YOU SURE?",NULL,quit_typ
141 },endgm_msg={
142 MSG,0,0,0,"RESTART LEVEL?",NULL,endgm_typ
143 };
145 static menu_t *qmsg[3]={&quit1_msg,&quit2_msg,&quit3_msg};
147 static menu_t *mnu=NULL;
149 static byte gm_redraw=0;
150 static int gm_tm=0;
151 short lastkey=0;
152 static void *csnd1,*csnd2,*msnd1,*msnd2,*msnd3,*msnd4,*msnd5,*msnd6;
153 static int movsndt=0;
154 static vgaimg *msklh[2],*mbarl,*mbarm,*mbarr,*mbaro,*mslotl,*mslotm,*mslotr;
155 static byte cbuf[32];
157 static snd_t *voc=NULL;
158 static int voc_ch=0;
160 void GMV_stop(void) {
161 if(voc) {
162 if(voc_ch) {S_stop(voc_ch);voc_ch=0;}
163 free(voc);voc=NULL;
167 void GMV_say(char *nm) {
168 int r,len;
169 snd_t *p;
170 byte *d;
172 if((r=F_findres(nm))==-1) return;
173 if(!(p=malloc((len=F_getreslen(r))+16))) return;
174 p->len=len;p->rate=11000;
175 p->lstart=p->llen=0;
176 GMV_stop();
177 F_loadres(r,p+1,0,len);
178 for(d=(byte*)(p+1);len;--len,++d) *d^=128;
179 voc=p;
180 voc_ch=S_play(voc,-1,1024,255);
183 void G_code(void) {
184 void *s;
185 s=csnd2;
186 if(memcmp(cbuf+32-5,"IDDQD",5)==0) {
187 PL_hit(&pl1,400,0,HIT_SOME);
188 if(_2pl) PL_hit(&pl2,400,0,HIT_SOME);
189 s=csnd1;
190 }else if(memcmp(cbuf+32-4,"TANK",4)==0) {
191 pl1.life=pl1.armor=200;pl1.drawst|=PL_DRAWARMOR|PL_DRAWLIFE;
192 if(_2pl) {pl2.life=pl2.armor=200;pl2.drawst|=PL_DRAWARMOR|PL_DRAWLIFE;}
193 }else if(memcmp(cbuf+32-8,"BULLFROG",8)==0) {
194 PL_JUMP=(PL_JUMP==10)?20:10;
195 }else if(memcmp(cbuf+32-8,"FORMULA1",8)==0) {
196 PL_RUN=(PL_RUN==8)?24:8;
197 }else if(memcmp(cbuf+32-5,"RAMBO",5)==0) {
198 pl1.ammo=pl1.shel=pl1.rock=pl1.cell=pl1.fuel=30000;
199 pl1.wpns=0x7FF;pl1.drawst|=PL_DRAWWPN|PL_DRAWKEYS;
200 pl1.keys=0x70;
201 if(_2pl) {
202 pl2.ammo=pl2.shel=pl2.rock=pl2.cell=pl1.fuel=30000;
203 pl2.wpns=0x7FF;pl2.drawst|=PL_DRAWWPN|PL_DRAWKEYS;
204 pl2.keys=0x70;
206 }else if(memcmp(cbuf+32-5,"UJHTW",5)==0) {
207 p_immortal=!p_immortal;
208 }else if(memcmp(cbuf+32-9,",TKSQJHTK",9)==0) {
209 p_fly=!p_fly;
210 }else if(memcmp(cbuf+32-6,"CBVCBV",6)==0) {
211 SW_cheat_open();
212 }else if(memcmp(cbuf+32-7,"GOODBYE",7)==0) {
213 g_exit=1;
214 }else if(memcmp(cbuf+32-9,"GJITKYF",7)==0) {
215 if(cbuf[30]>='0' && cbuf[30]<='9' && cbuf[31]>='0' && cbuf[31]<='9') {
216 g_map=(cbuf[30]=='0')?0:(cbuf[30]-'0')*10;
217 g_map+=(cbuf[31]=='0')?0:(cbuf[31]-'0');
218 G_start();
220 }else return;
221 memset(cbuf,0,32);
222 Z_sound(s,128);
225 void GM_set(menu_t *m) {
226 mnu=m;gm_redraw=1;
227 if(g_st==GS_GAME) {
228 //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);
229 //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();}
230 //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();}
231 //pl1.drawst=pl2.drawst=0xFF;V_setrect(0,SCRW,0,SCRH);//V_setrect(0,320,0,200);
235 void setgamma(int);
237 void GM_command(int c) {
238 switch(c) {
239 case CANCEL:
240 GM_set(NULL);break;
241 case INTERP:
242 fullscreen=!fullscreen;
243 V_toggle();
244 GM_set(mnu);
245 break;
246 case MUSIC:
247 F_freemus();
248 F_nextmus(g_music);
249 F_loadmus(g_music);
250 S_startmusic(music_time*2);
251 GM_set(mnu);
252 break;
253 case NEWGAME:
254 GMV_say("_NEWGAME");
255 GM_set(&ngplr_mnu);break;
256 case PLR2:
257 GMV_say("_2PLAYER");
258 GM_set(&ngdm_mnu);break;
259 case PLR1:
260 GMV_say("_1PLAYER");
261 ngdm_mnu.cur=0;
262 case COOP: case DM:
263 if(c==COOP) GMV_say("_COOP");
264 else if(c==DM) GMV_say("_DM");
265 if(c!=PLR1) {GM_set(&plcolor_mnu);break;}
266 case PLCEND:
267 _2pl=ngplr_mnu.cur;
268 g_dm=ngdm_mnu.cur;
269 g_map=(_warp)?_warp:1;
270 PL_reset();
271 if(_2pl) {
272 pl1.color=pcolortab[p1color];
273 pl2.color=pcolortab[p2color];
274 }else pl1.color=0x70;
275 G_start();
276 GM_set(NULL);break;
277 case OPTIONS:
278 GMV_say("_RAZNOE");
279 GM_set(&opt_mnu);break;
280 case LOADGAME:
281 GMV_say("_OLDGAME");
282 F_getsavnames();GM_set(&load_mnu);break;
283 case SAVEGAME:
284 if(g_st!=GS_GAME) break;
285 GMV_say("_SAVEGAM");
286 F_getsavnames();GM_set(&save_mnu);break;
287 case SAVE:
288 input=1;memcpy(ibuf,savname[save_mnu.cur],24);icur=strlen(ibuf);
289 GM_set(mnu);break;
290 case LOAD:
291 if(!savok[load_mnu.cur]) break;
292 load_game(load_mnu.cur);
293 GM_set(NULL);break;
294 case VOLUME:
295 GMV_say("_VOLUME");
296 GM_set(&vol_mnu);break;
297 case GAMMA:
298 GMV_say("_GAMMA");
299 GM_set(&gamma_mnu);break;
300 case QUITGAME:
301 GMV_say((rand()&1)?"_EXIT1":"_EXIT2");
302 GM_set(qmsg[myrand(3)]);break;
303 case ENDGAME:
304 if(g_st!=GS_GAME) break;
305 GMV_say("_RESTART");
306 GM_set(&endgm_msg);break;
307 case QUIT:
308 F_freemus();
309 GMV_stop();
310 #ifndef DEMO
311 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;);
312 S_wait();
313 #endif
314 ERR_quit();break;
315 case ENDGM:
316 PL_reset();G_start();
317 GM_set(NULL);break;
318 case PL1CM:
319 if(--p1color<0) p1color=PCOLORN-1; break;
320 case PL1CP:
321 if(++p1color>=PCOLORN) p1color=0; break;
322 case PL2CM:
323 if(--p2color<0) p2color=PCOLORN-1; break;
324 case PL2CP:
325 if(++p2color>=PCOLORN) p2color=0; break;
326 case SVOLM:
327 S_volume(snd_vol-8);break;
328 case SVOLP:
329 S_volume(snd_vol+8);break;
330 case MVOLM:
331 S_volumemusic(mus_vol-8);break;
332 case MVOLP:
333 S_volumemusic(mus_vol+8);break;
334 case GAMMAM: setgamma(gammaa-1);break;
335 case GAMMAP: setgamma(gammaa+1);break;
339 /*
340 byte keychar[2][128]={{
341 0,0,'1','2','3','4','5','6','7','8','9','0','-','=',0,0,
342 'Q','W','E','R','T','Y','U','I','O','P','[',']','\r',0,'A','S',
343 'D','F','G','H','J','K','L',';','\'',0,0,'\\','Z','X','C','V',
344 'B','N','M',',','.','/',0,'*',0,' ',0,0,0,0,0,0,
345 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 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
349 },{
350 0,0,'!','\"','#','$','%',':','&','*','(',')','_','+',0,0,
351 'x','x','x','x','x','x','x','x','x','x','x','x','\r',0,'x','x',
352 'x','x','x','x','x','x','x','x','x',0,0,0,'x','x','x','x',
353 'x','x','x','x','x','?',0,'*',0,' ',0,0,0,0,0,0,
354 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 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
358 }};
359 */
361 struct {
362 int keysym;
363 byte ch;
364 } keychar[] = {
365 {SDLK_SPACE, ' '},
366 {SDLK_0, '0'},
367 {SDLK_1, '1'},
368 {SDLK_2, '2'},
369 {SDLK_3, '3'},
370 {SDLK_4, '4'},
371 {SDLK_5, '5'},
372 {SDLK_6, '6'},
373 {SDLK_7, '7'},
374 {SDLK_8, '8'},
375 {SDLK_9, '9'},
376 {SDLK_UNDERSCORE, '_'},
377 {SDLK_a, 'A'},
378 {SDLK_b, 'B'},
379 {SDLK_c, 'C'},
380 {SDLK_d, 'D'},
381 {SDLK_e, 'E'},
382 {SDLK_f, 'F'},
383 {SDLK_g, 'G'},
384 {SDLK_h, 'H'},
385 {SDLK_i, 'I'},
386 {SDLK_j, 'J'},
387 {SDLK_k, 'K'},
388 {SDLK_l, 'L'},
389 {SDLK_m, 'M'},
390 {SDLK_n, 'N'},
391 {SDLK_o, 'O'},
392 {SDLK_p, 'P'},
393 {SDLK_q, 'Q'},
394 {SDLK_r, 'R'},
395 {SDLK_s, 'S'},
396 {SDLK_t, 'T'},
397 {SDLK_u, 'U'},
398 {SDLK_v, 'V'},
399 {SDLK_w, 'W'},
400 {SDLK_x, 'X'},
401 {SDLK_y, 'Y'},
402 {SDLK_z, 'Z'},
403 {SDLK_COMMA,','},
404 {0}
405 };
407 byte get_keychar(int keysym)
409 int i = 0;
410 while (keychar[i].keysym) {
411 if (keychar[i].keysym == keysym) return keychar[i].ch;
412 i++;
414 return 0;
417 extern vgapal main_pal,std_pal;
418 extern byte shot_vga;
420 static void shot(void) {
421 static int num=1;
422 char fn[100];//...
423 #ifndef WIN32
424 char *e = getenv("HOME");
425 strncpy(fn, e, 60);
426 sprintf(&fn[strlen(fn)],"/.doom2d-rembo",num);
427 mkdir(fn, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
428 sprintf(&fn[strlen(fn)],"/shot%04d.bmp",num);
429 #else
430 sprintf(fn,"shot%04d.bmp",num);
431 #endif
432 SDL_SaveBMP(screen, fn);
433 ++num;
436 int GM_act(void) {
437 byte c;
439 if(mnu==&plcolor_mnu) {
440 if(*(++panimp)==0) panimp=panim;
441 GM_set(mnu);
443 if(movsndt>0) --movsndt; else movsndt=0;
444 if(g_st==GS_TITLE) if(!mnu) if(lastkey) {
445 GM_set(&main_mnu);Z_sound(msnd3,128);
446 lastkey=0;
447 return 1;
449 if(input) switch(lastkey) {
450 case SDLK_RETURN: case SDLK_KP_ENTER://case 0x1C: case 0x9C:
451 F_savegame(save_mnu.cur,ibuf);
452 input=0;GM_set(NULL);break;
453 case 1: input=0;GM_set(mnu);break;
454 case SDLK_BACKSPACE://case 0x0E:
455 if(icur) {ibuf[--icur]=0;GM_set(mnu);} break;
456 default:
457 if(icur>=23) break;
458 c=get_keychar(lastkey);//c=keychar[(keys[0x2A] || keys[0x36])?1:0][lastkey];
459 if(!c) break;
460 ibuf[icur]=c;ibuf[++icur]=0;GM_set(mnu);
461 }else {
462 switch(lastkey) {
463 case SDLK_ESCAPE://case 1:
464 if(!mnu) {GM_set(&main_mnu);Z_sound(msnd3,128);}
465 else {GM_set(NULL);Z_sound(msnd4,128);}
466 break;
467 case SDLK_F5:
468 if(mnu) break;
469 Z_sound(msnd3,128);
470 GMV_say("_GAMMA");
471 GM_set(&gamma_mnu);break;
472 case SDLK_F4://case 0x3E:
473 if(mnu) break;
474 Z_sound(msnd3,128);
475 GMV_say("_VOLUME");
476 GM_set(&vol_mnu);break;
477 case SDLK_F2://case 0x3C:
478 if(mnu) break;
479 if(g_st!=GS_GAME) break;
480 Z_sound(msnd3,128);
481 F_getsavnames();GM_set(&save_mnu);break;
482 case SDLK_F3://case 0x3D:
483 if(mnu) break;
484 Z_sound(msnd3,128);
485 F_getsavnames();GM_set(&load_mnu);break;
486 case SDLK_F10://case 0x44:
487 if(mnu) break;
488 Z_sound(msnd3,128);
489 GM_command(QUITGAME);break;
490 case SDLK_UP: case SDLK_KP8://case 0x48: case 0xC8:
491 if(!mnu) break;
492 if(mnu->type!=MENU) break;
493 if(--mnu->cur<0) mnu->cur=mnu->n-1;
494 GM_set(mnu);
495 Z_sound(msnd1,128);break;
496 case SDLK_DOWN: case SDLK_KP5: case SDLK_KP2://case 0x50: case 0xD0: case 0x4C:
497 if(!mnu) break;
498 if(mnu->type!=MENU) break;
499 if(++mnu->cur>=mnu->n) mnu->cur=0;
500 GM_set(mnu);
501 Z_sound(msnd1,128);break;
502 case SDLK_LEFT: case SDLK_RIGHT: case SDLK_KP4: case SDLK_KP6://case 0x4B: case 0x4D: case 0xCB: case 0xCD:
503 if(!mnu) break;
504 if(mnu->type!=MENU) break;
505 if(mnu->t[mnu->cur]<SVOLM) break;
506 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));
507 GM_set(mnu);
508 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);
509 break;
510 case SDLK_RETURN: case SDLK_SPACE: case SDLK_KP_ENTER://case 0x1C: case 0x39: case 0x9C:
511 if(!mnu) break;
512 if(mnu->type!=MENU) break;
513 if(mnu->t[mnu->cur]>=PL1CM) {
514 Z_sound(msnd2,128);
515 GM_command(PLCEND);
516 break;
518 if(mnu->t[mnu->cur]>=SVOLM) break;
519 Z_sound(msnd2,128);
520 GM_command(mnu->t[mnu->cur]);
521 break;
522 case SDLK_y://case 0x15:
523 if(!mnu) break;
524 if(mnu->type!=MSG) break;
525 Z_sound(msnd3,128);
526 GM_command(mnu->t[0]);
527 break;
528 case SDLK_n://case 0x31:
529 if(!mnu) break;
530 if(mnu->type!=MSG) break;
531 Z_sound(msnd4,128);
532 GM_command(mnu->t[1]);
533 break;
534 case SDLK_F1://case 0x3B:
535 if(shot_vga) {shot();Z_sound(msnd4,128);}
536 break;
539 lastkey=0;
540 return((mnu)?1:0);
543 void G_keyf(int k, int press) {
544 int i;
546 lastkey=k;
547 if(!_2pl || cheat) {
548 for(i=0;i<31;++i) cbuf[i]=cbuf[i+1];
549 cbuf[31]=get_keychar(k);
553 void GM_init(void) {
554 #ifndef DEMO
555 int i;
556 static char nm[QSND_NUM][6]={
557 "CYBSIT","KNTDTH","MNPAIN","PEPAIN","SLOP","MANSIT","BOSPN","VILACT",
558 "PLFALL","BGACT","BGDTH2","POPAIN","SGTATK","VILDTH"
559 };
560 char s[8];
562 s[0]='D';s[1]='S';
563 for(i=0;i<QSND_NUM;++i) {
564 memcpy(s+2,nm[i],6);
565 qsnd[i]=F_getresid(s);
567 #endif
568 csnd1=Z_getsnd("HAHA1");
569 csnd2=Z_getsnd("RADIO");
570 msnd1=Z_getsnd("PSTOP");
571 msnd2=Z_getsnd("PISTOL");
572 msnd3=Z_getsnd("SWTCHN");
573 msnd4=Z_getsnd("SWTCHX");
574 msnd5=Z_getsnd("SUDI");
575 msnd6=Z_getsnd("TUDI");
576 msklh[0]=M_lock(F_getresid("M_SKULL1"));
577 // msklh[0]=load_vga("vga\\spr.vga","M_SKULL1");
578 msklh[1]=M_lock(F_getresid("M_SKULL2"));
579 mbarl=M_lock(F_getresid("M_THERML"));
580 mbarm=M_lock(F_getresid("M_THERMM"));
581 mbarr=M_lock(F_getresid("M_THERMR"));
582 mbaro=M_lock(F_getresid("M_THERMO"));
583 mslotl=M_lock(F_getresid("M_LSLEFT"));
584 mslotm=M_lock(F_getresid("M_LSCNTR"));
585 mslotr=M_lock(F_getresid("M_LSRGHT"));
586 K_setkeyproc(G_keyf);
589 int GM_draw(void) {
590 int i,j,k,y;
592 ++gm_tm;
593 V_setrect(0,SCRW,0,SCRH);//V_setrect(0,320,0,200);
594 if(!mnu && !gm_redraw) return 0;
595 gm_redraw=0;
596 if(!mnu) return 1;
597 if(mnu->type==MENU) {
598 y=(200-mnu->n*16-20)/2;
599 Z_gotoxy(mnu->x,y-10);Z_printbf(mnu->ttl);
600 for(i=0;i<mnu->n;++i) {
601 if(mnu->t[i]==LOAD || mnu->t[i]==SAVE) {
602 V_spr(mnu->x,j=y+i*16+29,mslotl);
603 for(k=8;k<184;k+=8)
604 V_spr(mnu->x+k,j,mslotm);
605 V_spr(mnu->x+184,j,mslotr);
606 Z_gotoxy(mnu->x+4,j-8);
607 if(input && i==save_mnu.cur) Z_printsf("%s_",ibuf);
608 else Z_printsf("%s",savname[i]);
609 }else{
610 Z_gotoxy(mnu->x+((mnu->t[i]>=SVOLM)?((mnu->t[i]>=PL1CM)?50:152):0),y+i*16+20);
611 Z_printbf(mnu->m[i]);
613 if(mnu->t[i]==MUSIC) {
614 Z_printbf(" '%.8s'",g_music);
615 }else if(mnu->t[i]==INTERP) {
616 Z_printbf("%s",fullscreen?"ON":"OFF");
617 }else if(mnu->t[i]>=PL1CM) {
618 V_manspr(mnu->x+((mnu->t[i]==PL1CM)?15:35),y+i*16+20+14,
619 PL_getspr(*panimp,0),
620 pcolortab[(mnu->t[i]==PL1CM)?p1color:p2color]
621 );
622 }else if(mnu->t[i]>=SVOLM) {
623 V_spr(mnu->x,j=y+i*16+20,mbarl);
624 for(k=8;k<144;k+=8)
625 V_spr(mnu->x+k,j,mbarm);
626 V_spr(mnu->x+144,j,mbarr);
627 switch(mnu->t[i]) {
628 case SVOLM: k=snd_vol;break;
629 case MVOLM: k=mus_vol;break;
630 case GAMMAM: k=gammaa<<5;break;
632 V_spr(mnu->x+8+k,j,mbaro);
635 V_spr(mnu->x-25,y+mnu->cur*16+20-8,msklh[(gm_tm/6)&1]);
636 }else{
637 Z_gotoxy((320-strlen(mnu->ttl)*7)/2,90);Z_printsf(mnu->ttl);
638 Z_gotoxy(136,100);Z_printsf("(Y/N)");
640 return 1;