DEADSOFTWARE

50387ff9569990323880d872d55ffb8298652315
[flatwaifu.git] / src / main.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 <process.h>
26 #include <stdarg.h>
27 ///#include <conio.h>
28 //#include <time.h>
29 ///#include <dos.h>
30 #include <stdlib.h>
31 #include <string.h>
32 #include "error.h"
33 #include "config.h"
34 #include "memory.h"
35 #include "keyb.h"
36 #include "sound.h"
37 #include "vga.h"
38 #include "files.h"
39 #include "view.h"
40 #include "menu.h"
41 #include "player.h"
42 #include "misc.h"
43 #include "my.h"
45 #include <SDL.h>
47 int gammaa=0;
49 char main_pal[256][3],std_pal[256][3];
50 byte mixmap[256][256];
51 byte clrmap[256*12];
53 void logo(const char *s,...) {
54 va_list ap;
55 int x,y;
57 va_start(ap,s);
58 vprintf(s,ap);
59 va_end(ap);
60 fflush(stdout);
61 }
63 void logo_gas(int cur,int all) {
64 }
66 byte gamcor[5][64]={
67 #include "gamma.dat"
68 };
70 void setgamma(int g) {
71 int t;
73 if(g>4) g=4;
74 if(g<0) g=0;
75 gammaa=g;
76 for(t=0;t<256;++t) {
77 std_pal[t][0]=gamcor[gammaa][main_pal[t][0]];
78 std_pal[t][1]=gamcor[gammaa][main_pal[t][1]];
79 std_pal[t][2]=gamcor[gammaa][main_pal[t][2]];
80 }
81 VP_setall(std_pal);
82 }
84 void myrandomize(void);
86 byte bright[256];
88 int main(int argc, char *argv[]) {
89 if (SDL_Init(SDL_INIT_VIDEO)<0) ERR_failinit("Unable to init SDL: %s\n", SDL_GetError());
90 SDL_WM_SetCaption("Doom 2D v1.351", "Doom 2D");
91 int i;
93 pl1.ku=SDLK_KP8;
94 pl1.kd=SDLK_KP5;
95 pl1.kl=SDLK_KP4;
96 pl1.kr=SDLK_KP6;
97 pl1.kf=SDLK_PAGEDOWN;
98 pl1.kj=SDLK_DELETE;
99 pl1.kwl=SDLK_HOME;
100 pl1.kwr=SDLK_END;
101 pl1.kp=SDLK_KP8;
102 pl1.id=-1;
103 pl2.ku=SDLK_e;
104 pl2.kd=SDLK_d;
105 pl2.kl=SDLK_s;
106 pl2.kr=SDLK_f;
107 pl2.kf=SDLK_a;
108 pl2.kj=SDLK_q;
109 pl2.kwl=SDLK_1;
110 pl2.kwr=SDLK_2;
111 pl2.kp=SDLK_e;
112 pl2.id=-2;
113 myrandomize();
114 F_startup();
115 char *pw;
116 #ifndef WIN32
117 pw = "/usr/share/doom2d-rembo/doom2d.wad";
118 #else
119 pw = "doom2d.wad";
120 #endif
121 if (fexists(pw))
122 F_addwad(pw);
123 else
124 F_addwad("doom2d.wad");
125 CFG_args(argc, argv);
126 CFG_load();
127 F_initwads();
128 M_startup();
129 F_allocres();
130 F_loadres(F_getresid("PLAYPAL"),main_pal,0,768);
131 for(i=0;i<256;++i)
132 bright[i]=((int)main_pal[i][0]+main_pal[i][1]+main_pal[i][2])*8/(63*3);
133 F_loadres(F_getresid("MIXMAP"),mixmap,0,0x10000);
134 F_loadres(F_getresid("COLORMAP"),clrmap,0,256*12);
135 G_init();
136 K_init();
137 logo("S_init: настройка звука\n");
138 S_init();
139 S_initmusic();
140 logo("V_init: настройка видео\n");
141 if(V_init()!=0) ERR_failinit("Не могу установить видеорежим VGA");
142 setgamma(gammaa);
143 V_setscr(scrbuf);
144 GM_init();
145 F_loadmus("MENU");S_startmusic(0);
147 Uint32 ticks = 0;
148 for(;;) {
150 updatee_keys();
152 S_updatemusic();
154 G_act();
156 G_draw();
158 Uint32 t;
159 while ((t = SDL_GetTicks())-ticks < DELAY) {
160 SDL_Delay(1);
162 ticks = t - t % DELAY;