From: DeaDDooMER Date: Fri, 13 Mar 2020 08:06:29 +0000 (+0300) Subject: mostly remove game dependency on low level part of render X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=584adc9c1911a6941ef07443a6fc6ff922d7c8ea;p=flatwaifu.git mostly remove game dependency on low level part of render --- diff --git a/src/a8.c b/src/a8.c index 889e550..2203b52 100644 --- a/src/a8.c +++ b/src/a8.c @@ -19,18 +19,19 @@ 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +/* #include "glob.h" #include //#include #include #include #include -#include "vga.h" +//#include "vga.h" #include "keyb.h" #include "error.h" #include "files.h" #include "sound.h" - +*/ /* #define WAIT_SZ 400000 diff --git a/src/config.c b/src/config.c index 2bf7f73..9ad78cb 100644 --- a/src/config.c +++ b/src/config.c @@ -25,7 +25,7 @@ #include #include #include "config.h" -#include "vga.h" +//#include "vga.h" #include "error.h" #include "sound.h" #include "files.h" @@ -60,11 +60,11 @@ static cfg_t cfg[]={ {"vga","screenshot",&shot_vga,SW_ON,0}, {"sndvol","sound_volume",&snd_vol,WORD,0}, {"musvol","music_volume",&mus_vol,WORD,0}, - {"fullscr","fullscreen",&fullscreen,SW_ON,0}, - {"window",NULL,&fullscreen,SW_OFF,0}, +// {"fullscr","fullscreen",&fullscreen,SW_ON,0}, +// {"window",NULL,&fullscreen,SW_OFF,0}, {NULL,"sky",&w_horiz,SW_ON,0}, {"mon",NULL,&nomon,SW_OFF,0}, - {"gamma","gamma",&gammaa,DWORD,0}, +// {"gamma","gamma",&gammaa,DWORD,0}, {"warp",NULL,&_warp,BYTE,0}, {"width","screen_width",&SCRW,DWORD,0}, {"height","screen_height",&SCRH,DWORD,0}, diff --git a/src/dots.c b/src/dots.c index 8b4bb8e..af54e3a 100644 --- a/src/dots.c +++ b/src/dots.c @@ -22,7 +22,6 @@ #include "glob.h" #include -#include "vga.h" #include "view.h" #include "dots.h" #include "misc.h" diff --git a/src/error.c b/src/error.c index 0e3e2af..ef9c388 100644 --- a/src/error.c +++ b/src/error.c @@ -27,25 +27,24 @@ #include #include "keyb.h" #include "sound.h" -#include "vga.h" +#include "render.h" #include "memory.h" #include "error.h" #include "config.h" -void close_all(void) { +static void close_all (void) { S_done(); S_donemusic(); K_done(); - V_done(); + R_done(); M_shutdown(); } -void ERR_failinit(char *s,...) { +void ERR_failinit (char *s, ...) { va_list ap; - close_all(); - va_start(ap,s); - vprintf(s,ap); + va_start(ap, s); + vprintf(s, ap); va_end(ap); puts(""); exit(1); @@ -53,17 +52,16 @@ void ERR_failinit(char *s,...) { void ERR_fatal(char *s,...) { va_list ap; - close_all(); puts("\nКРИТИЧЕСКАЯ ОШИБКА:"); - va_start(ap,s); - vprintf(s,ap); + va_start(ap, s); + vprintf(s, ap); va_end(ap); puts(""); exit(2); } -void ERR_quit(void) { +void ERR_quit (void) { void *p; //V_done(); //if(!(p=malloc(4000))) diff --git a/src/fx.c b/src/fx.c index 2af6180..35777ac 100644 --- a/src/fx.c +++ b/src/fx.c @@ -23,7 +23,6 @@ #include #include #include -#include "vga.h" #include "view.h" #include "fx.h" #include "misc.h" @@ -61,7 +60,7 @@ static void setamp(int a) { } void FX_trans1(int t) { - +/* int x,y,u,v; static unsigned char k; unsigned p; @@ -78,7 +77,7 @@ void FX_trans1(int t) { else scra[p]=fx_scr1[v*320+u]; }else scra[p]=fx_scr2[p]; } - +*/ } static void init_fx1sin(void) { diff --git a/src/game.c b/src/game.c index a8edfc2..8027592 100644 --- a/src/game.c +++ b/src/game.c @@ -26,7 +26,6 @@ #include #include "files.h" #include "memory.h" -#include "vga.h" #include "keyb.h" #include "sound.h" #include "view.h" @@ -68,15 +67,12 @@ extern short lastkey; extern int hit_xv,hit_yv; -extern vgapal std_pal; -void setgamma(int); +//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; @@ -171,11 +167,6 @@ void load_game(int n) { 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(); @@ -193,11 +184,6 @@ void G_start(void) { 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; diff --git a/src/glob.h b/src/glob.h index 771bb41..b68f4b6 100644 --- a/src/glob.h +++ b/src/glob.h @@ -41,7 +41,6 @@ typedef unsigned int dword; void logo(const char *,...); void logo_gas(int,int); -extern int gammaa; extern int snd_card; extern int _cpu; diff --git a/src/keyb.c b/src/keyb.c index b0b245c..4123c07 100644 --- a/src/keyb.c +++ b/src/keyb.c @@ -21,7 +21,6 @@ */ #include "keyb.h" -#include "vga.h" #include "error.h" #include @@ -53,10 +52,12 @@ void updatee_keys() { SDL_Event event; while (SDL_PollEvent (&event)) { + /* if (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_RETURN && event.key.keysym.mod & KMOD_LALT) { V_toggle(); } - else if (event.type == SDL_KEYDOWN || event.type == SDL_KEYUP) { + else */ + if (event.type == SDL_KEYDOWN || event.type == SDL_KEYUP) { if (event.type == SDL_KEYDOWN && key_proc!=NULL) key_proc(event.key.keysym.sym, event.type == SDL_KEYDOWN); } diff --git a/src/main.c b/src/main.c index ceba887..7bd73d4 100644 --- a/src/main.c +++ b/src/main.c @@ -30,7 +30,6 @@ #include "memory.h" #include "keyb.h" #include "sound.h" -#include "vga.h" #include "files.h" #include "view.h" #include "menu.h" @@ -39,12 +38,6 @@ #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; @@ -58,28 +51,8 @@ void logo(const char *s,...) { 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,23 +95,15 @@ 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(); - R_alloc(); 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(;;) { @@ -149,7 +114,7 @@ int main(int argc, char *argv[]) { G_act(); - G_draw(); + R_draw(); Uint32 t; while ((t = SDL_GetTicks())-ticks < DELAY) { diff --git a/src/menu.c b/src/menu.c index 415b68d..a934da7 100644 --- a/src/menu.c +++ b/src/menu.c @@ -26,7 +26,6 @@ #include #include "files.h" #include "memory.h" -#include "vga.h" #include "error.h" #include "keyb.h" #include "sound.h" @@ -155,6 +154,8 @@ static byte cbuf[32]; static snd_t *voc=NULL; static int voc_ch=0; +extern byte shot_vga; // config.c + void GMV_stop(void) { if(voc) { if(voc_ch) {S_stop(voc_ch);voc_ch=0;} @@ -237,8 +238,7 @@ void GM_command(int c) { case CANCEL: GM_set(NULL);break; case INTERP: - fullscreen=!fullscreen; - V_toggle(); + R_toggle_fullscreen(); GM_set(mnu); break; case MUSIC: @@ -329,8 +329,12 @@ void GM_command(int c) { S_volumemusic(mus_vol-8);break; case MVOLP: S_volumemusic(mus_vol+8);break; - case GAMMAM: setgamma(gammaa-1);break; - case GAMMAP: setgamma(gammaa+1);break; + case GAMMAM: + R_setgamma(R_getgamma() - 1); + break; + case GAMMAP: + R_setgamma(R_getgamma() + 1); + break; } } @@ -412,9 +416,6 @@ byte get_keychar(int keysym) return 0; } -extern vgapal main_pal,std_pal; -extern byte shot_vga; - static void shot(void) { static int num=1; char fn[100];//... diff --git a/src/miscc.c b/src/miscc.c index a174237..7c69aea 100644 --- a/src/miscc.c +++ b/src/miscc.c @@ -27,7 +27,6 @@ #include #include "files.h" #include "memory.h" -#include "vga.h" #include "sound.h" #include "view.h" #include "bmap.h" diff --git a/src/monster.c b/src/monster.c index 935b5c6..1357446 100644 --- a/src/monster.c +++ b/src/monster.c @@ -23,7 +23,6 @@ #include "glob.h" #include #include -#include "vga.h" #include "files.h" #include "view.h" #include "bmap.h" diff --git a/src/player.c b/src/player.c index fe4fe42..7a693ac 100644 --- a/src/player.c +++ b/src/player.c @@ -23,7 +23,6 @@ #include "glob.h" #include #include -#include "vga.h" #include "keyb.h" #include "view.h" #include "dots.h" diff --git a/src/render.c b/src/render.c index 67cfef4..c5494a4 100644 --- a/src/render.c +++ b/src/render.c @@ -48,8 +48,17 @@ static vgaimg *sth[22], *bfh[160 - '!'], *sfh[160 - '!'], *stone, *stone2, *keys static int prx = 0, pry = 0; // menu static vgaimg *msklh[2], *mbarl, *mbarm, *mbarr, *mbaro, *mslotl, *mslotm, *mslotr; +// low level +static int gammaa = 0; +static char main_pal[256][3]; +static char std_pal[256][3]; +static byte gamcor[5][64]={ + #include "gamma.dat" +}; -extern byte clrmap[256*12]; // main.c +extern byte bright[256]; // vga.c +extern byte mixmap[256][256]; // vga.c +extern byte clrmap[256*12]; // vga.c extern int g_trans; // game.c extern byte transdraw; // game.c @@ -819,7 +828,7 @@ static void pl_info (player_t *p, int y) { Z_gotoxy(255, y + 15); Z_printbf("%u.%u", t / 10, t % 10); } -void G_draw (void) { +void R_draw (void) { int h; word hr, mn, sc; if (g_trans && !transdraw) { @@ -959,6 +968,7 @@ void G_draw (void) { void R_alloc (void) { int i, j, n; char s[10]; + logo("R_alloc: загрузка графики\n"); // game scrnh[0] = V_loadvgaimg("TITLEPIC"); scrnh[1] = V_loadvgaimg("INTERPIC"); @@ -1159,3 +1169,47 @@ void R_alloc (void) { mslotm = V_loadvgaimg("M_LSCNTR"); mslotr = V_loadvgaimg("M_LSRGHT"); } + +void R_setgamma(int g) { + int t; + g = g < 0 ? 0 : (g > 4 ? 4 : g); + 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); +} + +int R_getgamma (void) { + return gammaa; +} + +void R_toggle_fullscreen (void) { + fullscreen = !fullscreen; + V_toggle(); +} + +void R_init () { + int i; + 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); + logo("V_init: настройка видео\n"); + if (V_init() != 0) { + ERR_failinit("Не могу установить видеорежим VGA"); + } + //R_setgamma(gammaa); + V_setrect(0, SCRW, 0, SCRH); + V_setscr(scrbuf); + V_clr(0, SCRW, 0, SCRH, 0); + R_alloc(); +} + +void R_done (void) { + V_done(); +} diff --git a/src/render.h b/src/render.h index 4f16eb3..8026af7 100644 --- a/src/render.h +++ b/src/render.h @@ -1,2 +1,8 @@ -void G_draw (void); +void R_draw (void); void R_alloc (void); +void R_init (void); +void R_done (void); + +void R_setgamma (int g); +int R_getgamma (void); +void R_toggle_fullscreen (void); diff --git a/src/smoke.c b/src/smoke.c index 1596159..6ccb15a 100644 --- a/src/smoke.c +++ b/src/smoke.c @@ -22,7 +22,6 @@ #include "glob.h" #include -#include "vga.h" #include "view.h" #include "smoke.h" #include "fx.h" @@ -39,10 +38,6 @@ static int lsm; static void *burnsnd; static int burntm=0; -byte flametab[16]={ -0xBC,0xBA,0xB8,0xB6,0xB4,0xB2,0xB0,0xD5,0xD6,0xD7,0xA1,0xA0,0xE3,0xE2,0xE1,0xE0 -}; - void SMK_savegame (FILE *h) { int i, n; for (i = n = 0; i < MAXSMOK; ++i) { diff --git a/src/vga.c b/src/vga.c index 3b4e065..21e8b4c 100644 --- a/src/vga.c +++ b/src/vga.c @@ -47,6 +47,16 @@ int cx1,cx2,cy1,cy2; char fullscreen = OFF; +byte bright[256]; +byte mixmap[256][256]; +byte clrmap[256*12]; + +static byte flametab[16] = { + 0xBC,0xBA,0xB8,0xB6,0xB4,0xB2,0xB0,0xD5,0xD6,0xD7,0xA1,0xA0,0xE3,0xE2,0xE1,0xE0 +}; + +extern void *walp[256]; + #define HQ 2 vgaimg *V_getvgaimg (int id) { @@ -211,11 +221,6 @@ void V_dot(short x,short y, unsigned char c) putpixel(x,y,c); } - -extern byte bright[256]; -extern byte flametab[16]; -extern byte mixmap[256][256]; - void smoke_sprf(int x, int y, byte c) { byte t = getpixel(x,y); @@ -318,9 +323,6 @@ void V_remap_rect(int x,int y,int w,int h,byte *cmap) mappixel(cx,cy,cmap); } -extern void *walp[256]; -extern byte clrmap[256*12]; - void Z_drawfld (byte *fld, int bg) { byte *p = fld; diff --git a/src/view.c b/src/view.c index b6b52c8..0c274fc 100644 --- a/src/view.c +++ b/src/view.c @@ -56,7 +56,6 @@ int HT; // extern map_block_t blk; -extern byte clrmap[256*12]; void V_remap_rect(int,int,int,int,byte *); byte w_horiz=ON;