X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fmain.c;h=edf7156aedddd98fffb899796f534cdcb4e2dd01;hb=82b3e1cc221312a5bd549d1f2d14bb682a311751;hp=2fc47cebd02be20d242e6d82622bb2f822497f85;hpb=82abbc606cc5e3d9c26e2ab6d36e093ed86ae1bf;p=flatwaifu.git diff --git a/src/main.c b/src/main.c index 2fc47ce..edf7156 100644 --- a/src/main.c +++ b/src/main.c @@ -30,56 +30,17 @@ #include "memory.h" #include "keyb.h" #include "sound.h" -#include "vga.h" #include "files.h" #include "view.h" #include "menu.h" #include "player.h" #include "my.h" +#include "render.h" +#include "game.h" +#include "music.h" #include -int gammaa=0; - -char main_pal[256][3],std_pal[256][3]; -byte mixmap[256][256]; -byte clrmap[256*12]; - -void logo(const char *s,...) { - va_list ap; - int x,y; - - va_start(ap,s); - vprintf(s,ap); - va_end(ap); - fflush(stdout); -} - -void logo_gas(int cur,int all) { -} - -byte gamcor[5][64]={ - #include "gamma.dat" -}; - -void setgamma(int g) { - int t; - - if(g>4) g=4; - if(g<0) g=0; - gammaa=g; - for(t=0;t<256;++t) { - std_pal[t][0]=gamcor[gammaa][main_pal[t][0]]; - std_pal[t][1]=gamcor[gammaa][main_pal[t][1]]; - std_pal[t][2]=gamcor[gammaa][main_pal[t][2]]; - } - VP_setall(std_pal); -} - -void myrandomize(void); - -byte bright[256]; - int main(int argc, char *argv[]) { if (SDL_Init(SDL_INIT_VIDEO)<0) ERR_failinit("Unable to init SDL: %s\n", SDL_GetError()); SDL_WM_SetCaption("Doom 2D v1.351", "Doom 2D"); @@ -122,39 +83,26 @@ int main(int argc, char *argv[]) { F_initwads(); M_startup(); F_allocres(); - F_loadres(F_getresid("PLAYPAL"),main_pal,0,768); - for(i=0;i<256;++i) - bright[i]=((int)main_pal[i][0]+main_pal[i][1]+main_pal[i][2])*8/(63*3); - F_loadres(F_getresid("MIXMAP"),mixmap,0,0x10000); - F_loadres(F_getresid("COLORMAP"),clrmap,0,256*12); G_init(); K_init(); logo("S_init: настройка звука\n"); S_init(); S_initmusic(); - logo("V_init: настройка видео\n"); - if(V_init()!=0) ERR_failinit("Не могу установить видеорежим VGA"); - setgamma(gammaa); - V_setscr(scrbuf); + R_init(); GM_init(); - F_loadmus("MENU");S_startmusic(0); + F_loadmus("MENU"); + S_startmusic(0); - Uint32 ticks = 0; - for(;;) { - + Uint32 ticks = SDL_GetTicks(); + for (;;) { updatee_keys(); - S_updatemusic(); - - G_act(); - - G_draw(); - - Uint32 t; - while ((t = SDL_GetTicks())-ticks < DELAY) { - SDL_Delay(1); + Uint32 t = SDL_GetTicks(); + if (t - ticks > DELAY) { + ticks = t; + G_act(); } - ticks = t - t % DELAY; - + R_draw(); + //SDL_Delay(1); } }