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
48 enum{HIT100
,ARMOR
,JUMP
,WPNS
,IMMORTAL
,SPEED
,OPEN
,EXIT
};
50 static byte panim
[] = "BBDDAACCDDAABBDDAACCDDAABBDDAACCDDAAEEEEEFEFEFEFEFEFEFEFEFEFEEEEE";
54 byte pcolortab
[PCOLORN
] = {
55 0x18, 0x20, 0x40, 0x58, 0x60, 0x70, 0x80, 0xB0, 0xC0, 0xD0
65 enum{CANCEL
,NEWGAME
,LOADGAME
,SAVEGAME
,OPTIONS
,QUITGAME
,QUIT
,ENDGAME
,ENDGM
,
66 PLR1
,PLR2
,COOP
,DM
,VOLUME
,GAMMA
,LOAD
,SAVE
,PLCOLOR
,PLCEND
,MUSIC
,INTERP
,
67 SVOLM
,SVOLP
,MVOLM
,MVOLP
,GAMMAM
,GAMMAP
,PL1CM
,PL1CP
,PL2CM
,PL2CP
};
70 static int qsnd
[QSND_NUM
];
73 static char *main_txt
[]={
74 "NEW GAME","LOAD GAME","SAVE GAME","OPTIONS","EXIT"
76 "RESTART","VOLUME","BRIGHTNESS","MUSIC","FULLSCREEN:"
78 "ONE PLAYER","TWO PLAYERS"
80 "COOPERATIVE","DEATHMATCH"
89 static byte main_typ
[]={
90 NEWGAME
,LOADGAME
,SAVEGAME
,OPTIONS
,QUITGAME
96 ENDGAME
,VOLUME
,GAMMA
,MUSIC
,INTERP
108 LOAD
,LOAD
,LOAD
,LOAD
,LOAD
,LOAD
,LOAD
110 SAVE
,SAVE
,SAVE
,SAVE
,SAVE
,SAVE
,SAVE
114 MENU
,5,0,80,"MENU",main_txt
,main_typ
116 MENU
,5,0,75,"OPTIONS",opt_txt
,opt_typ
118 MENU
,2,0,90,"NEW GAME",ngplr_txt
,ngplr_typ
120 MENU
,2,0,90,"GAME TYPE",ngdm_txt
,ngdm_typ
122 MENU
,2,0,40,"VOLUME",vol_txt
,vol_typ
124 MENU
,2,0,90,"COLOR",plcolor_txt
,plcolor_typ
126 MENU
,1,0,85,"BRIGHTNESS",gamma_txt
,gamma_typ
128 MENU
,7,0,85,"LOAD GAME",NULL
,load_typ
130 MENU
,7,0,85,"SAVE GAME",NULL
,save_typ
132 MSG
,0,0,0,"ARE YOU SURE?",NULL
,quit_typ
134 MSG
,0,0,0,"ARE YOU SURE?",NULL
,quit_typ
136 MSG
,0,0,0,"ARE YOU SURE?",NULL
,quit_typ
138 MSG
,0,0,0,"RESTART LEVEL?",NULL
,endgm_typ
141 static menu_t
*qmsg
[3]={&quit1_msg
,&quit2_msg
,&quit3_msg
};
147 static void *csnd1
,*csnd2
,*msnd1
,*msnd2
,*msnd3
,*msnd4
,*msnd5
,*msnd6
;
148 static int movsndt
=0;
149 static byte cbuf
[32];
154 static void GMV_stop (void) {
165 void GMV_say (const char nm
[8]) {
166 snd_t
*snd
= S_load(nm
);
170 voc_ch
= S_play(voc
, 0, 255);
174 static void GM_set (menu_t
*m
) {
177 //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);
178 //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();}
179 //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();}
180 //pl1.drawst=pl2.drawst=0xFF;V_setrect(0,SCRW,0,SCRH);//V_setrect(0,320,0,200);
187 if(memcmp(cbuf
+32-5,"IDDQD",5)==0) {
188 PL_hit(&pl1
,400,0,HIT_SOME
);
189 if(_2pl
) PL_hit(&pl2
,400,0,HIT_SOME
);
191 }else if(memcmp(cbuf
+32-4,"TANK",4)==0) {
192 pl1
.life
=pl1
.armor
=200;pl1
.drawst
|=PL_DRAWARMOR
|PL_DRAWLIFE
;
193 if(_2pl
) {pl2
.life
=pl2
.armor
=200;pl2
.drawst
|=PL_DRAWARMOR
|PL_DRAWLIFE
;}
194 }else if(memcmp(cbuf
+32-8,"BULLFROG",8)==0) {
195 PL_JUMP
=(PL_JUMP
==10)?20:10;
196 }else if(memcmp(cbuf
+32-8,"FORMULA1",8)==0) {
197 PL_RUN
=(PL_RUN
==8)?24:8;
198 }else if(memcmp(cbuf
+32-5,"RAMBO",5)==0) {
199 pl1
.ammo
=pl1
.shel
=pl1
.rock
=pl1
.cell
=pl1
.fuel
=30000;
200 pl1
.wpns
=0x7FF;pl1
.drawst
|=PL_DRAWWPN
|PL_DRAWKEYS
;
203 pl2
.ammo
=pl2
.shel
=pl2
.rock
=pl2
.cell
=pl1
.fuel
=30000;
204 pl2
.wpns
=0x7FF;pl2
.drawst
|=PL_DRAWWPN
|PL_DRAWKEYS
;
207 }else if(memcmp(cbuf
+32-5,"UJHTW",5)==0) {
208 p_immortal
=!p_immortal
;
209 }else if(memcmp(cbuf
+32-9,",TKSQJHTK",9)==0) {
211 }else if(memcmp(cbuf
+32-6,"CBVCBV",6)==0) {
213 }else if(memcmp(cbuf
+32-7,"GOODBYE",7)==0) {
215 }else if(memcmp(cbuf
+32-9,"GJITKYF",7)==0) {
216 if(cbuf
[30]>='0' && cbuf
[30]<='9' && cbuf
[31]>='0' && cbuf
[31]<='9') {
217 g_map
=(cbuf
[30]=='0')?0:(cbuf
[30]-'0')*10;
218 g_map
+=(cbuf
[31]=='0')?0:(cbuf
[31]-'0');
226 static void GM_command (int c
) {
231 R_toggle_fullscreen();
238 S_startmusic(music_time
*2);
243 GM_set(&ngplr_mnu
);break;
246 GM_set(&ngdm_mnu
);break;
251 if(c
==COOP
) GMV_say("_COOP");
252 else if(c
==DM
) GMV_say("_DM");
253 if(c
!=PLR1
) {GM_set(&plcolor_mnu
);break;}
257 g_map
=(_warp
)?_warp
:1;
260 pl1
.color
=pcolortab
[p1color
];
261 pl2
.color
=pcolortab
[p2color
];
262 }else pl1
.color
=0x70;
267 GM_set(&opt_mnu
);break;
270 F_getsavnames();GM_set(&load_mnu
);break;
272 if(g_st
!=GS_GAME
) break;
274 F_getsavnames();GM_set(&save_mnu
);break;
276 input
=1;memcpy(ibuf
,savname
[save_mnu
.cur
],24);icur
=strlen(ibuf
);
279 if(!savok
[load_mnu
.cur
]) break;
280 load_game(load_mnu
.cur
);
284 GM_set(&vol_mnu
);break;
287 GM_set(&gamma_mnu
);break;
289 GMV_say((rand()&1)?"_EXIT1":"_EXIT2");
290 GM_set(qmsg
[myrand(3)]);break;
292 if(g_st
!=GS_GAME
) break;
294 GM_set(&endgm_msg
);break;
299 c
= Z_sound(S_get(qsnd
[myrand(QSND_NUM
)]), 255);
304 PL_reset();G_start();
307 if(--p1color
<0) p1color
=PCOLORN
-1; break;
309 if(++p1color
>=PCOLORN
) p1color
=0; break;
311 if(--p2color
<0) p2color
=PCOLORN
-1; break;
313 if(++p2color
>=PCOLORN
) p2color
=0; break;
315 S_volume(snd_vol
-8);break;
317 S_volume(snd_vol
+8);break;
319 S_volumemusic(mus_vol
-8);break;
321 S_volumemusic(mus_vol
+8);break;
323 R_setgamma(R_getgamma() - 1);
326 R_setgamma(R_getgamma() + 1);
346 //{KEY_UNDERSCORE, '_'},
377 static byte
get_keychar (int keysym
) {
379 while (keychar
[i
].keysym
) {
380 if (keychar
[i
].keysym
== keysym
) return keychar
[i
].ch
;
386 static void shot (void) {
391 char *e = getenv("HOME");
393 sprintf(&fn[strlen(fn)],"/.doom2d-rembo",num);
394 mkdir(fn, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
395 sprintf(&fn[strlen(fn)],"/shot%04d.bmp",num);
397 sprintf(fn,"shot%04d.bmp",num);
399 SDL_SaveBMP(screen, fn);
407 if(mnu
==&plcolor_mnu
) {
408 if(*(++panimp
)==0) panimp
=panim
;
411 if(movsndt
>0) --movsndt
; else movsndt
=0;
412 if(g_st
==GS_TITLE
) if(!mnu
) if(lastkey
) {
413 GM_set(&main_mnu
);Z_sound(msnd3
,128);
421 F_savegame(save_mnu
.cur
, ibuf
);
438 c
= get_keychar(lastkey
);
474 if (mnu
== NULL
&& g_st
== GS_GAME
) {
490 GM_command(QUITGAME
);
495 if (mnu
!= NULL
&& mnu
->type
== MENU
) {
498 mnu
->cur
= mnu
->n
- 1;
507 if (mnu
!= NULL
&& mnu
->type
== MENU
) {
509 if (mnu
->cur
>= mnu
->n
) {
520 if (mnu
!= NULL
&& mnu
->type
== MENU
&& mnu
->t
[mnu
->cur
] >= SVOLM
) {
521 GM_command(mnu
->t
[mnu
->cur
] + (lastkey
== KEY_LEFT
|| lastkey
== KEY_KP_4
));
524 movsndt
= Z_sound(lastkey
== KEY_LEFT
|| lastkey
== KEY_KP_4
? msnd5
: msnd6
, 255);
531 if (mnu
!= NULL
&& mnu
->type
== MENU
) {
532 if (mnu
->t
[mnu
->cur
] >= PL1CM
) {
536 } else if (mnu
->t
[mnu
->cur
] < SVOLM
) {
538 GM_command(mnu
->t
[mnu
->cur
]);
543 if (mnu
!= NULL
&& mnu
->type
== MSG
) {
545 GM_command(mnu
->t
[0]);
549 if (mnu
!= NULL
&& mnu
->type
== MSG
) {
551 GM_command(mnu
->t
[1]);
562 lastkey
= KEY_UNKNOWN
;
566 void G_keyf (int key
, int down
) {
570 if (!_2pl
|| cheat
) {
571 for (i
= 0; i
< 31; ++i
) {
572 cbuf
[i
] = cbuf
[i
+ 1];
574 cbuf
[31] = get_keychar(key
);
579 void GM_init (void) {
582 static char nm
[QSND_NUM
][6]={
583 "CYBSIT","KNTDTH","MNPAIN","PEPAIN","SLOP","MANSIT","BOSPN","VILACT",
584 "PLFALL","BGACT","BGDTH2","POPAIN","SGTATK","VILDTH"
589 for(i
=0;i
<QSND_NUM
;++i
) {
591 qsnd
[i
]=F_getresid(s
);
594 csnd1
=Z_getsnd("HAHA1");
595 csnd2
=Z_getsnd("RADIO");
596 msnd1
=Z_getsnd("PSTOP");
597 msnd2
=Z_getsnd("PISTOL");
598 msnd3
=Z_getsnd("SWTCHN");
599 msnd4
=Z_getsnd("SWTCHX");
600 msnd5
=Z_getsnd("SUDI");
601 msnd6
=Z_getsnd("TUDI");