From: DeaDDooMER Date: Tue, 21 Apr 2020 06:02:43 +0000 (+0400) Subject: game: switch textures in more abstract way X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=21e27adcd50196e94141390f96c8d4a089ccde08;p=flatwaifu.git game: switch textures in more abstract way --- diff --git a/src/gl/render.c b/src/gl/render.c index f68327a..28c5b86 100644 --- a/src/gl/render.c +++ b/src/gl/render.c @@ -162,6 +162,7 @@ static int max_wall_width; static int max_wall_height; static int max_textures; static image walp[256]; +static byte walswp[256]; static byte walani[256]; static image anip[ANIT][5]; static byte anic[ANIT]; @@ -2107,3 +2108,14 @@ void R_loadsky (int sky) { R_gl_free_image(&horiz); horiz = R_gl_loadimage(s); } + +void R_switch_texture (int x, int y) { + assert(x >= 0 && x < FLDW); + assert(y >= 0 && y < FLDH); + fldb[y][x] = walswp[fldb[y][x]]; +} + +int R_get_swp (int n) { + assert(n >= 0 && n < 256); + return walswp[n]; +} diff --git a/src/render.h b/src/render.h index 0b6319c..f9a4cfb 100644 --- a/src/render.h +++ b/src/render.h @@ -14,8 +14,11 @@ void R_done (void); void R_set_videomode (int w, int h, int fullscreen); +void R_switch_texture (int x, int y); + void R_get_name (int n, char s[8]); int R_get_special_id (int n); +int R_get_swp (int n); void R_begin_load (void); void R_load (char s[8], int f); void R_end_load (void); diff --git a/src/soft/render.c b/src/soft/render.c index 38c3ba7..e2cb9bf 100644 --- a/src/soft/render.c +++ b/src/soft/render.c @@ -72,6 +72,7 @@ static int w_o, w_x, w_y; static vgaimg *walp[256]; static int walh[256]; static byte walani[256]; +static byte walswp[256]; static int anih[ANIT][5]; static byte anic[ANIT]; static int max_textures; @@ -1628,3 +1629,14 @@ void R_done (void) { pitch = 0; Y_unset_videomode(); } + +void R_switch_texture (int x, int y) { + assert(x >= 0 && x < FLDW); + assert(y >= 0 && y < FLDH); + fldb[y][x] = walswp[fldb[y][x]]; +} + +int R_get_swp (int n) { + assert(n >= 0 && n < 256); + return walswp[n]; +} diff --git a/src/switch.c b/src/switch.c index 5eebc2d..79f15c0 100644 --- a/src/switch.c +++ b/src/switch.c @@ -335,8 +335,10 @@ int SW_press (int x, int y, int r, int h, byte t, int o) { else ++pl2.secrets; sw[i].tm=1;sw[i].t=0;break; } - if(sw[i].tm) - {fldb[sw[i].y][sw[i].x]=walswp[fldb[sw[i].y][sw[i].x]];p=1;} + if (sw[i].tm != 0) { + R_switch_texture(sw[i].x, sw[i].y); + p = 1; + } if(sw[i].tm==1) sw[i].tm=0; } } diff --git a/src/view.c b/src/view.c index 08fde9f..043ac78 100644 --- a/src/view.c +++ b/src/view.c @@ -43,7 +43,6 @@ int sky_type=1; dword walf[256]; -byte walswp[256]; byte fldb[FLDH][FLDW]; byte fldf[FLDH][FLDW]; byte fld[FLDH][FLDW]; @@ -60,7 +59,7 @@ void W_savegame (FILE* h) { myfwrite32(walf[i], h); } for (i = 0; i < 256; i++) { - myfwrite8(walswp[i], h); + myfwrite8(R_get_swp(i), h); } myfwrite(fldb, FLDW*FLDH, 1, h); myfwrite(fld, FLDW*FLDH, 1, h); diff --git a/src/view.h b/src/view.h index 200bf02..d64512c 100644 --- a/src/view.h +++ b/src/view.h @@ -61,7 +61,6 @@ typedef struct { extern int sky_type; extern dword walf[256]; -extern byte walswp[256]; extern byte fldb[FLDH][FLDW]; extern byte fldf[FLDH][FLDW]; extern byte fld[FLDH][FLDW];