diff --git a/src/game.c b/src/game.c
index a8edfc2a6dc3bd2422c1f61be37b8a81cc0d45ea..202f0f2b15f3095c3bfa4682bcaf9c68d7e3133b 100644 (file)
--- a/src/game.c
+++ b/src/game.c
-/*
- Copyright (C) Prikol Software 1996-1997
- Copyright (C) Aleksey Volynskov 1996-1997
- Copyright (C) <ARembo@gmail.com> 2011
-
- This file is part of the Doom2D:Rembo project.
-
- Doom2D:Rembo is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License version 2 as
- published by the Free Software Foundation.
-
- Doom2D:Rembo is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/> or
- write to the Free Software Foundation, Inc.,
- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+/* Copyright (C) 1996-1997 Aleksey Volynskov
+ * Copyright (C) 2011 Rambo
+ * Copyright (C) 2020 SovietPony
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3 of the License ONLY.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
#include "glob.h"
#include <stdio.h>
#include "glob.h"
#include <stdio.h>
#include <string.h>
#include "files.h"
#include "memory.h"
#include <string.h>
#include "files.h"
#include "memory.h"
-#include "vga.h"
-#include "keyb.h"
#include "sound.h"
#include "view.h"
#include "bmap.h"
#include "sound.h"
#include "view.h"
#include "bmap.h"
#include "misc.h"
#include "map.h"
#include "my.h"
#include "misc.h"
#include "map.h"
#include "my.h"
+#include "game.h"
+#include "config.h"
+#include "music.h"
+#include "a8.h"
+#include "error.h"
+#include "input.h"
-#include <SDL_keysym.h>
+#include "save.h"
#define LT_DELAY 8
#define LT_HITTIME 6
#define GETIME 1092
#define LT_DELAY 8
#define LT_HITTIME 6
#define GETIME 1092
-
-int A8_start(char*);
-int A8_nextframe(void);
-void A8_close(void);
-
-
-byte transdraw=0;
-
-
-void FX_trans1(int t);
-extern unsigned char fx_scr1[64000],fx_scr2[64000];
-
-extern short lastkey;
-
-
-extern int hit_xv,hit_yv;
-
-extern vgapal std_pal;
-void setgamma(int);
-
-extern int PL_JUMP;
-
-extern map_block_t blk;
-
-extern byte clrmap[256*12];
-
-extern byte cheat;
-
-byte _2pl=0,g_dm=0,g_st=GS_TITLE,g_exit=0,g_map=1,_warp=0;
-char g_music[8]="MENU";
-byte _net=0;
-int g_sttm=1092;
+byte transdraw;
+byte _2pl;
+byte g_dm;
+byte g_st = GS_TITLE;
+byte g_exit;
+byte g_map = 1;
+char g_music[8] = "MENU";
dword g_time;
dword g_time;
-int dm_pnum,dm_pl1p,dm_pl2p;
+int dm_pnum;
+int dm_pl1p;
+int dm_pl2p;
pos_t dm_pos[100];
pos_t dm_pos[100];
+byte cheat;
static void *telepsnd;
static void *telepsnd;
-void *scrnh[3];
-void *cd_scr;
-extern int sky_type;
-void *ltn[2][2];
-int lt_time,lt_type,lt_side,lt_ypos,lt_force;
-void *ltnsnd[2];
+int lt_time;
+int lt_type;
+int lt_side;
+int lt_ypos;
+static int lt_force;
+static void *ltnsnd[2];
-int g_trans=0,g_transt;
+int g_trans;
+static int g_transt;
static void set_trans(int st) {
switch(g_st) {
static void set_trans(int st) {
switch(g_st) {
g_trans=1;g_transt=0;
}
g_trans=1;g_transt=0;
}
-void G_savegame(FILE* h) {
- myfwrite8(_2pl, h);
- myfwrite8(g_dm, h);
- myfwrite8(g_exit, h);
- myfwrite8(g_map, h);
- myfwrite32(g_time, h);
- myfwrite32(dm_pl1p, h);
- myfwrite32(dm_pl2p, h);
- myfwrite32(dm_pnum, h);
- int i = 0;
- while (i < dm_pnum) {
- myfwrite32(dm_pos[i].x, h);
- myfwrite32(dm_pos[i].y, h);
- myfwrite8(dm_pos[i].d, h);
- i += 1;
- }
- myfwrite8(cheat, h);
- myfwrite(g_music, 8, 1, h);
-}
-
-void G_loadgame(FILE* h) {
- _2pl = myfread8(h);
- g_dm = myfread8(h);
- g_exit = myfread8(h);
- g_map = myfread8(h);
- g_time = myfread32(h);
- dm_pl1p = myfread32(h);
- dm_pl2p = myfread32(h);
- dm_pnum = myfread32(h);
- int i = 0;
- while (i < dm_pnum) {
- dm_pos[i].x = myfread32(h);
- dm_pos[i].y = myfread32(h);
- dm_pos[i].d = myfread8(h);
- i += 1;
- }
- cheat = myfread8(h);
- myfread(g_music, 8, 1, h);
- F_loadmus(g_music);
-}
-
-int G_load (FILE *h) {
- switch (blk.t) {
- case MB_MUSIC:
- myfread(g_music, 8, 1, h);
- if (music_random) {
- F_randmus(g_music);
- }
- F_loadmus(g_music);
- return 1;
- }
- return 0;
-}
-
-void load_game(int n) {
- F_freemus();
+void load_game (int n) {
+ MUS_free();
W_init();
F_loadgame(n);
set_trans(GS_GAME);
W_init();
F_loadgame(n);
set_trans(GS_GAME);
- V_setscr((g_trans)?fx_scr2:scrbuf);V_setrect(0,SCRW,0,SCRH);//V_setrect(0,320,0,200);
- V_clr(0,SCRW,0,SCRH,0);//V_clr(0,320,0,200,0);
-// if(_2pl) {w_o=0;Z_clrst();w_o=SCRH/2;Z_clrst();}//if(_2pl) {w_o=0;Z_clrst();w_o=100;Z_clrst();}
-// else {w_o=0;Z_clrst();}//else {w_o=50;Z_clrst();}
- V_setscr(scrbuf);
pl1.drawst=0xFF;
if(_2pl) pl2.drawst=0xFF;
BM_remapfld();
pl1.drawst=0xFF;
if(_2pl) pl2.drawst=0xFF;
BM_remapfld();
BM_mark(&pl1.o,BM_PLR1);
if(_2pl) BM_mark(&pl2.o,BM_PLR2);
MN_mark();
BM_mark(&pl1.o,BM_PLR1);
if(_2pl) BM_mark(&pl2.o,BM_PLR2);
MN_mark();
- S_startmusic(music_time);
+ //MUS_start(music_time);
+ MUS_start(0);
}
}
-void G_start(void) {
+void G_start (void) {
char s[8];
char s[8];
-
- F_freemus();
+ MUS_free();
sprintf(s,"MAP%02u",(word)g_map);
F_loadmap(s);
set_trans(GS_GAME);
sprintf(s,"MAP%02u",(word)g_map);
F_loadmap(s);
set_trans(GS_GAME);
- V_setscr((g_trans)?fx_scr2:scrbuf);V_setrect(0,SCRW,0,SCRH);//V_setrect(0,320,0,200);
- V_clr(0,SCRW,0,SCRH,0);//V_clr(0,320,0,200,0);
-// if(_2pl) {w_o=0;Z_clrst();w_o=SCRH/2;Z_clrst();}//if(_2pl) {w_o=0;Z_clrst();w_o=100;Z_clrst();}
-// else {w_o=0;Z_clrst();}//else {w_o=50;Z_clrst();}
- V_setscr(scrbuf);
pl1.drawst=0xFF;
if(_2pl) pl2.drawst=0xFF;
g_exit=0;
pl1.drawst=0xFF;
if(_2pl) pl2.drawst=0xFF;
g_exit=0;
BM_mark(&pl1.o,BM_PLR1);
if(_2pl) BM_mark(&pl2.o,BM_PLR2);
MN_mark();
BM_mark(&pl1.o,BM_PLR1);
if(_2pl) BM_mark(&pl2.o,BM_PLR2);
MN_mark();
- S_startmusic(music_time);
+ //MUS_start(music_time);
+ MUS_start(0);
}
#define GGAS_TOTAL (MN__LAST-MN_DEMON+16+10)
}
#define GGAS_TOTAL (MN__LAST-MN_DEMON+16+10)
-void G_init(void) {
+void G_init (void) {
int i,j;
char s[9];
int i,j;
char s[9];
- logo("G_init: настройка ресурсов игры ");
+ logo("G_init: setup game resources ");
logo_gas(5,GGAS_TOTAL);
telepsnd=Z_getsnd("TELEPT");
ltnsnd[0]=Z_getsnd("THUND1");
logo_gas(5,GGAS_TOTAL);
telepsnd=Z_getsnd("TELEPT");
ltnsnd[0]=Z_getsnd("THUND1");
g_trans=0;
}
g_trans=0;
}
-int G_beg_video(void) {
+static int G_beg_video (void) {
/*
switch(g_map) {
case 3: return A8_start("FALL");
/*
switch(g_map) {
case 3: return A8_start("FALL");
}
}
-int G_end_video(void) {
+static int G_end_video (void) {
/*
switch(g_map) {
case 1: return A8_start("TRUBA");
/*
switch(g_map) {
case 1: return A8_start("TRUBA");
return 0;
}
return 0;
}
-
-void G_act(void) {
+void G_act (void) {
static byte pcnt=0;
/*
if(g_trans) {
static byte pcnt=0;
/*
if(g_trans) {
if(g_st==GS_BVIDEO || g_st==GS_EVIDEO) {
if(g_st==GS_BVIDEO || g_st==GS_EVIDEO) {
- if(!A8_nextframe() || lastkey==SDLK_ESCAPE) {
- if(lastkey==SDLK_ESCAPE) lastkey=0;
+ if (!A8_nextframe() || lastkey == KEY_ESCAPE) {
+ if (lastkey == KEY_ESCAPE) lastkey = KEY_UNKNOWN;
A8_close();
if(g_st==GS_BVIDEO) G_start();
else goto inter;
}
A8_close();
if(g_st==GS_BVIDEO) G_start();
else goto inter;
}
- V_copytoscr(0,SCRW,0,SCRH);//V_copytoscr(0,320,0,200);
+// V_copytoscr(0,SCRW,0,SCRH);//V_copytoscr(0,320,0,200);
return;
}else if(g_st==GS_ENDANIM || g_st==GS_END2ANIM || g_st==GS_END3ANIM) {
if(!A8_nextframe()) {
return;
}else if(g_st==GS_ENDANIM || g_st==GS_END2ANIM || g_st==GS_END3ANIM) {
if(!A8_nextframe()) {
case GS_ENDANIM: g_st=GS_DARKEN;break;
case GS_END2ANIM: g_st=GS_END3ANIM;A8_start("KONEC");break;
case GS_END3ANIM: g_st=GS_ENDSCR;lastkey=0;break;
case GS_ENDANIM: g_st=GS_DARKEN;break;
case GS_END2ANIM: g_st=GS_END3ANIM;A8_start("KONEC");break;
case GS_END3ANIM: g_st=GS_ENDSCR;lastkey=0;break;
- }g_sttm=0;return;
+ }
+ return;
}
}
- V_copytoscr(0,SCRW,0,SCRH);//V_copytoscr(0,320,0,200);
+// V_copytoscr(0,SCRW,0,SCRH);//V_copytoscr(0,320,0,200);
return;
}else if(g_st==GS_DARKEN) {
g_st=GS_END2ANIM;A8_start("CREDITS");
return;
}else if(g_st==GS_DARKEN) {
g_st=GS_END2ANIM;A8_start("CREDITS");
set_trans(GS_TITLE);
}
#else
set_trans(GS_TITLE);
}
#else
- if(keys[SDLK_SPACE] || keys[SDLK_RETURN] || keys[SDLK_KP_ENTER])//if(keys[0x39] || keys[0x1C] || keys[0x9C])
- if(!G_beg_video()) G_start(); else {
- g_st=GS_BVIDEO;F_freemus();
+ if (I_pressed(KEY_SPACE) || I_pressed(KEY_RETURN) || I_pressed(KEY_KP_ENTER)) {
+ if (!G_beg_video()) {
+ G_start();
+ } else {
+ g_st = GS_BVIDEO;
+ MUS_free();
}
}
+ }
#endif
return;
}
#endif
return;
}
if(_2pl) {pl2.hit=0;pl2.hito=-3;}
G_code();
if(_2pl) {pl2.hit=0;pl2.hito=-3;}
G_code();
- W_act();
IT_act();
SW_act();
if(_2pl) {
IT_act();
SW_act();
if(_2pl) {
if(g_exit==1) {
if(G_end_video()) {
if(g_exit==1) {
if(G_end_video()) {
- F_freemus();
+ MUS_free();
g_st=GS_EVIDEO;
return;
}
g_st=GS_EVIDEO;
return;
}
case 31: case 32: g_map=16;set_trans(GS_INTER);break;
default: ++g_map;set_trans(GS_INTER);break;
}
case 31: case 32: g_map=16;set_trans(GS_INTER);break;
default: ++g_map;set_trans(GS_INTER);break;
}
- F_freemus();
- if(g_st==GS_INTER) {
- F_loadmus("INTERMUS");
- }else {F_loadmus("\x8a\x8e\x8d\x85\x96\x0");if(mus_vol>0) {S_volumemusic(128);} }
- S_startmusic(0);
+ MUS_free();
+ if (g_st == GS_INTER) {
+ MUS_load("INTERMUS");
+ } else {
+ MUS_load("\x8a\x8e\x8d\x85\x96\x0");
+ MUS_volume(128);
+ }
+ MUS_start(0);
}else if(g_exit==2) {
switch(g_map) {
case 31: g_map=32;set_trans(GS_INTER);break;
case 32: g_map=16;set_trans(GS_INTER);break;
default: g_map=31;set_trans(GS_INTER);break;
}
}else if(g_exit==2) {
switch(g_map) {
case 31: g_map=32;set_trans(GS_INTER);break;
case 32: g_map=16;set_trans(GS_INTER);break;
default: g_map=31;set_trans(GS_INTER);break;
}
- F_freemus();
- F_loadmus("INTERMUS");
- S_startmusic(0);
+ MUS_free();
+ MUS_load("INTERMUS");
+ MUS_start(0);
}
#ifdef DEMO
}
#ifdef DEMO
#endif
}
#endif
}
-void G_respawn_player(player_t *p) {
+void G_respawn_player (player_t *p) {
int i;
if(dm_pnum==2) {
int i;
if(dm_pnum==2) {