DEADSOFTWARE

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