1 /* Copyright (C) 1996-1997 Aleksey Volynskov
2 * Copyright (C) 2011 Rambo
3 * Copyright (C) 2020 SovietPony
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 3 of the License ONLY.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
58 char g_music
[8] = "MENU";
66 static void *telepsnd
;
73 static void *ltnsnd
[2];
78 static void set_trans(int st
) {
80 case GS_ENDANIM
: case GS_END2ANIM
: case GS_DARKEN
:
81 case GS_BVIDEO
: case GS_EVIDEO
: case GS_END3ANIM
:
85 case GS_ENDANIM
: case GS_END2ANIM
: case GS_DARKEN
:
86 case GS_BVIDEO
: case GS_EVIDEO
: case GS_END3ANIM
:
92 void load_game (int n
) {
98 if(_2pl
) pl2
.drawst
=0xFF;
100 BM_clear(BM_PLR1
|BM_PLR2
|BM_MONSTER
);
101 BM_mark(&pl1
.o
,BM_PLR1
);
102 if(_2pl
) BM_mark(&pl2
.o
,BM_PLR2
);
104 //MUS_start(music_time);
108 void G_start (void) {
111 sprintf(s
,"MAP%02u",(word
)g_map
);
115 if(_2pl
) pl2
.drawst
=0xFF;
117 itm_rtime
=(g_dm
)?1092:0;
118 p_immortal
=0;PL_JUMP
=10;
122 if(!_2pl
) pl1
.lives
=3;
124 BM_clear(BM_PLR1
|BM_PLR2
|BM_MONSTER
);
125 BM_mark(&pl1
.o
,BM_PLR1
);
126 if(_2pl
) BM_mark(&pl2
.o
,BM_PLR2
);
128 //MUS_start(music_time);
132 #define GGAS_TOTAL (MN__LAST-MN_DEMON+16+10)
138 logo("G_init: setup game resources ");
139 logo_gas(5,GGAS_TOTAL
);
140 telepsnd
=Z_getsnd("TELEPT");
141 ltnsnd
[0]=Z_getsnd("THUND1");
142 ltnsnd
[1]=Z_getsnd("THUND2");
152 logo_gas(GGAS_TOTAL
,GGAS_TOTAL
);
160 static int G_beg_video (void) {
163 case 3: return A8_start("FALL");
164 case 4: return A8_start("KORIDOR");
165 case 5: return A8_start("SKULL");
166 case 6: return A8_start("TORCHES");
167 case 7: return A8_start("CACO");
168 case 8: return A8_start("DARTS");
169 case 9: return A8_start("FISH");
170 case 10: return A8_start("TRAP");
171 case 11: return A8_start("JAIL");
172 case 12: return A8_start("MMON1");
173 case 13: return A8_start("TOWER");
174 case 14: return A8_start("SAPOG");
175 case 15: return A8_start("SWITCH");
176 case 16: return A8_start("ACCEL");
177 case 17: return A8_start("MEAT");
178 case 18: return A8_start("LEGION");
179 case 19: return A8_start("CLOUDS");
186 static int G_end_video (void) {
189 case 1: return A8_start("TRUBA");
190 case 10: return A8_start("GOTCHA");
201 V_setscr(NULL);memcpy(fx_scr1,scra,64000);
203 transdraw=1;G_draw();transdraw=0;
206 FX_trans1(g_transt*2);
207 V_copytoscr(0,320,0,200);
217 if(g_st
==GS_BVIDEO
|| g_st
==GS_EVIDEO
) {
218 if (!A8_nextframe() || lastkey
== KEY_ESCAPE
) {
219 if (lastkey
== KEY_ESCAPE
) lastkey
= KEY_UNKNOWN
;
221 if(g_st
==GS_BVIDEO
) G_start();
224 // V_copytoscr(0,SCRW,0,SCRH);//V_copytoscr(0,320,0,200);
226 }else if(g_st
==GS_ENDANIM
|| g_st
==GS_END2ANIM
|| g_st
==GS_END3ANIM
) {
227 if(!A8_nextframe()) {
229 case GS_ENDANIM
: g_st
=GS_DARKEN
;break;
230 case GS_END2ANIM
: g_st
=GS_END3ANIM
;A8_start("KONEC");break;
231 case GS_END3ANIM
: g_st
=GS_ENDSCR
;lastkey
=0;break;
235 // V_copytoscr(0,SCRW,0,SCRH);//V_copytoscr(0,320,0,200);
237 }else if(g_st
==GS_DARKEN
) {
238 g_st
=GS_END2ANIM
;A8_start("CREDITS");
247 case GS_TITLE
: case GS_ENDSCR
:
252 if(keys
[0x39] || keys
[0x1C] || keys
[0x9C]) {
256 if (I_pressed(KEY_SPACE
) || I_pressed(KEY_RETURN
) || I_pressed(KEY_KP_ENTER
)) {
257 if (!G_beg_video()) {
270 if(lt_time
>LT_DELAY
|| lt_force
) {
271 if(!(rand()&31) || lt_force
) {
277 Z_sound(ltnsnd
[rand()&1],128);
282 pl1
.hit
=0;pl1
.hito
=-3;
283 if(_2pl
) {pl2
.hit
=0;pl2
.hito
=-3;}
289 if(pcnt
) {PL_act(&pl1
);PL_act(&pl2
);}
290 else {PL_act(&pl2
);PL_act(&pl1
);}
294 if(fld_need_remap
) BM_remapfld();
295 BM_clear(BM_PLR1
|BM_PLR2
|BM_MONSTER
);
296 BM_mark(&pl1
.o
,BM_PLR1
);
297 if(_2pl
) BM_mark(&pl2
.o
,BM_PLR2
);
304 PL_damage(&pl1
);PL_damage(&pl2
);
305 if(!(pl1
.f
&PLF_PNSND
) && pl1
.pain
) PL_cry(&pl1
);
306 if(!(pl2
.f
&PLF_PNSND
) && pl2
.pain
) PL_cry(&pl2
);
307 if((pl1
.pain
-=5) < 0) {pl1
.pain
=0;pl1
.f
&=(0xFFFF-PLF_PNSND
);}
308 if((pl2
.pain
-=5) < 0) {pl2
.pain
=0;pl2
.f
&=(0xFFFF-PLF_PNSND
);}
311 if(!(pl1
.f
&PLF_PNSND
) && pl1
.pain
) PL_cry(&pl1
);
312 if((pl1
.pain
-=5) < 0) {pl1
.pain
=0;pl1
.f
&=(0xFFFF-PLF_PNSND
);}
324 case 19: g_st
=GS_ENDANIM
;A8_start("FINAL");break;
325 case 31: case 32: g_map
=16;set_trans(GS_INTER
);break;
326 default: ++g_map
;set_trans(GS_INTER
);break;
329 if (g_st
== GS_INTER
) {
330 MUS_load("INTERMUS");
332 MUS_load("\x8a\x8e\x8d\x85\x96\x0");
336 }else if(g_exit
==2) {
338 case 31: g_map
=32;set_trans(GS_INTER
);break;
339 case 32: g_map
=16;set_trans(GS_INTER
);break;
340 default: g_map
=31;set_trans(GS_INTER
);break;
343 MUS_load("INTERMUS");
348 if(g_dm
&& g_time
>10920) {set_trans(GS_INTER
);}
352 void G_respawn_player (player_t
*p
) {
356 if(p
==&pl1
) i
=dm_pl1p
^=1;
358 p
->o
.x
=dm_pos
[i
].x
;p
->o
.y
=dm_pos
[i
].y
;p
->d
=dm_pos
[i
].d
;
359 FX_tfog(dm_pos
[i
].x
,dm_pos
[i
].y
);Z_sound(telepsnd
,128);
362 do{i
=myrand(dm_pnum
);}while(i
==dm_pl1p
|| i
==dm_pl2p
);
363 p
->o
.x
=dm_pos
[i
].x
;p
->o
.y
=dm_pos
[i
].y
;p
->d
=dm_pos
[i
].d
;
364 if(p
==&pl1
) dm_pl1p
=i
; else dm_pl2p
=i
;
365 FX_tfog(dm_pos
[i
].x
,dm_pos
[i
].y
);Z_sound(telepsnd
,128);