summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 584adc9)
raw | patch | inline | side by side (parent: 584adc9)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Sat, 14 Mar 2020 16:24:27 +0000 (19:24 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Sat, 14 Mar 2020 18:48:13 +0000 (21:48 +0300) |
12 files changed:
src/files.h | patch | blob | history | |
src/game.c | patch | blob | history | |
src/main.c | patch | blob | history | |
src/menu.c | patch | blob | history | |
src/miscc.c | patch | blob | history | |
src/redraw.c | patch | blob | history | |
src/render.c | patch | blob | history | |
src/render.h | patch | blob | history | |
src/vga.c | patch | blob | history | |
src/vga.h | patch | blob | history | |
src/view.c | patch | blob | history | |
src/view.h | patch | blob | history |
diff --git a/src/files.h b/src/files.h
index f9862caf164cbfbc6ed598c0231a73e183f86fdd..d6b60983402573ffa9f219e54594a890e33891a8 100644 (file)
--- a/src/files.h
+++ b/src/files.h
extern char wads[MAX_WADS][__MAX_PATH];
extern int wad_num;
+
+int F_getsprid(char n[4],int s,int d);
+int F_getresid(char *n);
diff --git a/src/game.c b/src/game.c
index 8027592605e60c8454e48d4dc2afe1373ac100a6..4ae9e11fdd949e4f9584b3bf6b51bc6b78d05bbb 100644 (file)
--- a/src/game.c
+++ b/src/game.c
if(g_st==GS_BVIDEO) G_start();
else goto inter;
}
- V_copytoscr(0,SCRW,0,SCRH);//V_copytoscr(0,320,0,200);
+// V_copytoscr(0,SCRW,0,SCRH);//V_copytoscr(0,320,0,200);
return;
}else if(g_st==GS_ENDANIM || g_st==GS_END2ANIM || g_st==GS_END3ANIM) {
if(!A8_nextframe()) {
case GS_END3ANIM: g_st=GS_ENDSCR;lastkey=0;break;
}g_sttm=0;return;
}
- V_copytoscr(0,SCRW,0,SCRH);//V_copytoscr(0,320,0,200);
+// V_copytoscr(0,SCRW,0,SCRH);//V_copytoscr(0,320,0,200);
return;
}else if(g_st==GS_DARKEN) {
g_st=GS_END2ANIM;A8_start("CREDITS");
if(_2pl) {pl2.hit=0;pl2.hito=-3;}
G_code();
- W_act();
IT_act();
SW_act();
if(_2pl) {
diff --git a/src/main.c b/src/main.c
index 7bd73d4fed4f91cab282c2f9fbaaef67077ee0bb..81c257ce0a40d7914b6fb719f22923c53fbbbb01 100644 (file)
--- a/src/main.c
+++ b/src/main.c
#include "menu.h"
#include "player.h"
#include "my.h"
+#include "render.h"
#include <SDL.h>
diff --git a/src/menu.c b/src/menu.c
index a934da7e6e0278ca9ce2de71a8e5b2fadef4f2d3..7d5f374ddff2e0c791c5c5327973ee9f6c997795 100644 (file)
--- a/src/menu.c
+++ b/src/menu.c
#include "switch.h"
#include "menu.h"
#include "misc.h"
+#include "render.h"
#include <SDL.h>
#include <sys/stat.h>
diff --git a/src/miscc.c b/src/miscc.c
index 7c69aeab6ac4e48e168747732a49982b4a17e05b..2ece443937950ae40de63f13a88cc8537a3e5248 100644 (file)
--- a/src/miscc.c
+++ b/src/miscc.c
#include "dots.h"
#include "monster.h"
#include "misc.h"
+#include "render.h"
//#define WD 200
//#define HT 98
return st;
}
-void Z_splash(obj_t *p,int n) {
- Z_sound(bulsnd[0],128);
- DOT_water(p->x,p->y-p->h/2,p->xv+p->vx,p->yv+p->vy,n,
- (intptr_t)walp[wfront]-1);
+void Z_splash (obj_t *p, int n) {
+ Z_sound(bulsnd[0], 128);
+ DOT_water(p->x, p->y-p->h / 2, p->xv + p->vx, p->yv + p->vy, n, R_get_special_id(wfront));
}
void Z_calc_time(dword t,word *h,word *m,word *s)
diff --git a/src/redraw.c b/src/redraw.c
index 326dafc94b5853c7851180923c1d0f41b5afe80a..032aa613e897e21c377eb20385896986825bfc16 100644 (file)
--- a/src/redraw.c
+++ b/src/redraw.c
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+/*
#include <stdlib.h>
#include <errno.h>
#include <string.h>
//#include "..\averr.h"
#include "vga.h"
#include "glob.h"
-/*
+
#define MAXRECT 500
typedef struct{short x,w,y,h;}rect;
diff --git a/src/render.c b/src/render.c
index c5494a41757ba3d9fed7ed303a65747528dc8042..5f16f7edfcc3280da0793906308719b682353a32 100644 (file)
--- a/src/render.c
+++ b/src/render.c
#include <string.h>
#include <stdarg.h>
+#include <stdlib.h> // abs()
+#include <assert.h>
#include "glob.h"
#include "render.h"
#include "view.h"
#include "smoke.h"
#include "fx.h"
#include "memory.h"
+#include "files.h"
+#include "error.h"
// game
static vgaimg *scrnh[3]; // TITLEPIC INTERPIC ENDPIC
static byte gamcor[5][64]={
#include "gamma.dat"
};
+// walls
+#define ANIT 5
+static vgaimg *walp[256];
+static int walh[256];
+static byte walani[256];
+static int anih[ANIT][5];
+static byte anic[ANIT];
+static int max_textures;
+static vgaimg *horiz;
extern byte bright[256]; // vga.c
extern byte mixmap[256][256]; // vga.c
extern int g_trans; // game.c
extern byte transdraw; // game.c
-extern void *horiz; // view.c
extern int sky_type; // view.c
extern int lt_time, lt_type, lt_side, lt_ypos, lt_force; // game.c
extern short snd_vol; // sound.c
extern short mus_vol; // music.c
-void Z_drawfld(byte *, int); // vga.c
-
/* --- misc --- */
static void *Z_getspr (char n[4], int s, int d, char *dir) {
}
}
+static void Z_drawfld (byte *fld, int bg) {
+ byte *p = fld;
+ int x, y;
+ for (y = 0; y < FLDH; y++) {
+ for (x = 0; x < FLDW; x++) {
+ int sx = x * CELW - w_x + WD / 2;
+ int sy = y * CELH - w_y + HT / 2 + 1 + w_o;
+ int id = *p;
+ if (id != 0) {
+ int spc = R_get_special_id(id);
+ if (spc <= 3) {
+ if (!bg) {
+ byte *cmap = clrmap + (spc + 7) * 256;
+ V_remap_rect(sx, sy, CELW, CELH, cmap);
+ }
+ } else {
+ V_pic(sx, sy, walp[id]);
+ }
+ }
+ p++;
+ }
+ }
+}
+
/* --- menu --- */
static int gm_tm = 0; // ???
Z_gotoxy(255, y + 15); Z_printbf("%u.%u", t / 10, t % 10);
}
+static void W_act (void) {
+ int i, a;
+ if (g_time % 3 == 0) {
+ for (i = 1; i < 256; ++i) {
+ a = walani[i];
+ if (a != 0) {
+ anic[a]++;
+ if (anih[a][anic[a]] == -1) {
+ anic[a] = 0;
+ }
+ walp[i] = V_getvgaimg(anih[a][anic[a]]);
+ }
+ }
+ }
+}
+
void R_draw (void) {
int h;
word hr, mn, sc;
+ W_act();
if (g_trans && !transdraw) {
return;
}
mslotl = V_loadvgaimg("M_LSLEFT");
mslotm = V_loadvgaimg("M_LSCNTR");
mslotr = V_loadvgaimg("M_LSRGHT");
+ // walls
+ static char *anm[ANIT - 1][5] = {
+ {"WALL22_1", "WALL23_1", "WALL23_2", NULL, NULL},
+ {"WALL58_1", "WALL58_2", "WALL58_3", NULL, NULL},
+ {"W73A_1", "W73A_2", NULL, NULL, NULL},
+ {"RP2_1", "RP2_2", "RP2_3", "RP2_4", NULL}
+ };
+ for (i = 1; i < ANIT; i++) {
+ for (j = 0; anm[i - 1][j]; j++) {
+ anih[i][j] = F_getresid(anm[i - 1][j]);
+ }
+ for(; j < 5; j++) {
+ anih[i][j] = -1;
+ }
+ }
+}
+
+void R_get_name (int n, char s[8]) {
+ if (walh[n] == -1) {
+ memset(s, 0, 8);
+ } else if (walh[n] == -2) {
+ memcpy(s, "_WATER_", 8);
+ s[7] = (char)((intptr_t)walp[n] - 1 + '0');
+ } else {
+ F_getresname(s, walh[n] & 0x7FFF);
+ }
+}
+
+static short getani (char n[8]) {
+ if (strncasecmp(n, "WALL22_1", 8) == 0) {
+ return 1;
+ } else if (strncasecmp(n, "WALL58_1", 8) == 0) {
+ return 2;
+ } else if (strncasecmp(n, "W73A_1", 8) == 0) {
+ return 3;
+ } else if (strncasecmp(n, "RP2_1", 8) == 0) {
+ return 4;
+ } else {
+ return 0;
+ }
+}
+
+int R_get_special_id (int n) {
+ assert(n >= 0 && n < 256);
+ intptr_t x = (intptr_t)walp[n] - 1;
+ return x > 0 && x <= 3 ? x : 0;
+}
+
+void R_begin_load (void) {
+ int i;
+ for (i = 0; i < max_textures; i++) {
+// if (walp[i] != NULL && walh[i] >= 0) {
+// M_unlock(walp[i]);
+// }
+ walh[i] = -1;
+ walp[i] = NULL;
+ walswp[i] = i;
+ walani[i] = 0;
+ }
+ memset(anic, 0, sizeof(anic));
+ max_textures = 0;
+}
+
+void R_load (char s[8], int f) {
+ assert(max_textures < 256);
+ if (!s[0]) {
+ walh[max_textures] = -1;
+ walp[max_textures] = NULL;
+ } else {
+ if (strncasecmp(s, "_WATER_", 7) == 0) {
+ walh[max_textures] = -2;
+ walp[max_textures] = (void*)((intptr_t)s[7] - '0' + 1);
+ } else {
+ walh[max_textures] = F_getresid(s);
+ walp[max_textures] = V_getvgaimg(walh[max_textures]);
+ if (f) {
+ walh[max_textures] |= 0x8000;
+ }
+ if (s[0] == 'S' && s[1] == 'W' && s[4] == '_') {
+ walswp[max_textures] = 0;
+ }
+ }
+ walani[max_textures] = getani(s);
+ }
+ max_textures++;
+}
+
+void R_end_load (void) {
+ int i, j, k, g;
+ char s[8];
+ j = max_textures;
+ for (i = 1; i < 256 && j < 256; i++) {
+ if (walswp[i] == 0) {
+ R_get_name(i, s);
+ s[5] ^= 1;
+ g = F_getresid(s) | (walh[i] & 0x8000);
+ k = 1;
+ while (k < 256 && walh[k] != g) {
+ k += 1;
+ }
+ if (k >= 256) {
+ k = j;
+ j += 1;
+ walh[k] = g;
+ walp[k] = V_getvgaimg(g);
+ walf[k] = g & 0x8000 ? 1 : 0;
+ }
+ walswp[i] = k;
+ walswp[k] = i;
+ }
+ }
+}
+
+void R_loadsky (int sky) {
+ char s[6];
+ strcpy(s, "RSKY1");
+ s[4] = '0' + sky;
+ M_unlock(horiz);
+ horiz = V_loadvgaimg(s);
}
void R_setgamma(int g) {
diff --git a/src/render.h b/src/render.h
index 8026af7f588f92042dd2e92a2abb820fe6bb95d5..9226e995499b5f08e7e1bb4aade8cf3028b2077e 100644 (file)
--- a/src/render.h
+++ b/src/render.h
void R_setgamma (int g);
int R_getgamma (void);
void R_toggle_fullscreen (void);
+
+void R_get_name (int n, char s[8]);
+int R_get_special_id (int n);
+void R_begin_load (void);
+void R_load (char s[8], int f);
+void R_end_load (void);
+void R_loadsky (int sky);
diff --git a/src/vga.c b/src/vga.c
index 21e8b4c363c99b63bb81b169c79fd59aa9ce8cdb..0d16859efde217bd07cc56e0da4dfda6a726744a 100644 (file)
--- a/src/vga.c
+++ b/src/vga.c
#include "view.h"
#include "memory.h"
#include "misc.h"
+#include "files.h"
#include <assert.h>
mappixel(cx,cy,cmap);
}
-void Z_drawfld (byte *fld, int bg)
-{
- byte *p = fld;
- int x, y;
- for (y = 0; y < FLDH; y++) {
- for (x = 0; x < FLDW; x++) {
- int sx = x * CELW - w_x + WD / 2;
- int sy = y * CELH - w_y + HT / 2 + 1 + w_o;
- if (*p) {
- vgaimg *pic = walp[*p];
- // special pointer value setted for _WATER_* in view.c
- if ((intptr_t)pic <= 3) {
- if (!bg) {
- byte *cmap = clrmap + ((intptr_t)pic+7)*256;
- V_remap_rect(sx, sy, CELW, CELH, cmap);
- }
- } else {
- V_pic(sx, sy, pic);
- }
- }
- p++;
- }
- }
-}
-
void V_toggle()
{
if (!SDL_WM_ToggleFullScreen(screen)) {
diff --git a/src/vga.h b/src/vga.h
index cc90ca5493d08c60b2ab73a60c6ee30f4d97daa5..48392c20ce7c3c0b1f59fd4bd7fd455c1ccfe6f2 100644 (file)
--- a/src/vga.h
+++ b/src/vga.h
// виртуальный экран
extern unsigned char scrbuf[64000];
+void V_remap_rect(int x,int y,int w,int h,byte *cmap);
void V_toggle();
void V_rotspr (int x, int y, vgaimg* i, int d);
diff --git a/src/view.c b/src/view.c
index 0c274fc81103c55d5cdfc8970f22a79177996156..73953d7dea30d469ec88408bf47f4cd230cc1ff1 100644 (file)
--- a/src/view.c
+++ b/src/view.c
#include "map.h"
#include "sound.h"
#include "my.h"
+#include "render.h"
-#define ANIT 5
-
-/*
-#define WD 200
-#define HT 98
-
-#define MAXX (FLDW*CELW-WD/2)
-#define MAXY (FLDH*CELH-HT/2)
-*/
-
-int WD; //
-int HT; //
+int WD;
+int HT;
extern map_block_t blk;
-void V_remap_rect(int,int,int,int,byte *);
-
byte w_horiz=ON;
-void *horiz=NULL;//static void *horiz=NULL;
int w_o,w_x,w_y,sky_type=1;
-void *walp[256];
dword walf[256];
-int walh[256];
byte walswp[256];
-byte walani[256];
-int anih[ANIT][5];
-byte anic[ANIT];
byte fldb[FLDH][FLDW];
byte fldf[FLDH][FLDW];
byte fld[FLDH][FLDW];
extern int lt_time,lt_type,lt_side,lt_ypos;
extern void *ltn[2][2];
-static void getname (int n, char *s) {
- if (walh[n] == -1) {
- memset(s, 0, 8);
- } else if (walh[n] == -2) {
- memcpy(s, "_WATER_", 8);
- s[7] = (char)((intptr_t)walp[n] - 1 + '0');
- } else {
- F_getresname(s, walh[n] & 0x7FFF);
- }
-}
-
-static short getani(char *n) {
- if(strncasecmp(n,"WALL22_1",8)==0) return 1;
- if(strncasecmp(n,"WALL58_1",8)==0) return 2;
- if(strncasecmp(n,"W73A_1",8)==0) return 3;
- if(strncasecmp(n,"RP2_1",8)==0) return 4;
- return 0;
-}
-
-void W_savegame(FILE* h) {
+void W_savegame (FILE* h) {
char s[8];
int i;
myfwrite32(sky_type, h);
for(i = 1; i < 256; ++i) {
- getname(i, s);
+ R_get_name(i, s);
myfwrite(s, 8, 1, h);
}
for (i = 0; i < 256; i++) {
myfwrite(fldf, FLDW*FLDH, 1, h);
}
-void W_loadgame(FILE* h) {
- char s[8];
+void W_loadgame (FILE* h) {
int i;
+ char s[256][8];
sky_type = myfread32(h);
+ R_loadsky(sky_type);
for (i = 1; i < 256; ++i) {
- walani[i]=0;
- myfread(s, 8, 1, h);
- if (!s[0]) {
- walh[i] = -1;
- walp[i] = NULL;
- } else {
- walani[i] = getani(s);
- if (strncasecmp(s, "_WATER_", 7) == 0) {
- walh[i] = -2;
- walp[i] = (void*)((intptr_t)s[7] - '0' + 1);
- } else {
- walh[i] = F_getresid(s);
- walp[i] = V_getvgaimg(walh[i]);
- }
- }
+ myfread(s[i], 8, 1, h);
}
- for (i = 0; i < 256; i++) {
+ R_begin_load();
+ R_load("", 0); // empty
+ i = myfread32(h); // ignore
+ for (i = 1; i < 256; i++) {
walf[i] = myfread32(h);
- if (i > 0 && walf[i] & 1) {
- walh[i] |= 0x8000;
- }
+ R_load(s[i], walf[i] & 1);
}
for (i = 0; i < 256; i++) {
walswp[i] = myfread8(h);
myfread(fldb, FLDW*FLDH, 1, h);
myfread(fld, FLDW*FLDH, 1, h);
myfread(fldf, FLDW*FLDH, 1, h);
- strcpy(s, "RSKY1");
- s[4] = '0' + sky_type;
- M_unlock(horiz);
- horiz = V_loadvgaimg(s);
+ R_end_load();
}
void W_init(void) {
- int i,j;
- static char *anm[ANIT-1][5]={
- {"WALL22_1","WALL23_1","WALL23_2",NULL,NULL},
- {"WALL58_1","WALL58_2","WALL58_3",NULL,NULL},
- {"W73A_1","W73A_2",NULL,NULL,NULL},
- {"RP2_1","RP2_2","RP2_3","RP2_4",NULL}
- };
-
- for(i=1;i<ANIT;++i) {
- for(j=0;anm[i-1][j];++j)
- anih[i][j]=F_getresid(anm[i-1][j]);
- for(;j<5;++j) anih[i][j]=-1;
- }
- memset(anic,0,sizeof(anic));
DOT_init();
SMK_init();
FX_init();
SW_init();
PL_init();
MN_init();
- M_unlock(horiz);
- horiz=V_loadvgaimg("RSKY1");
-
+ R_loadsky(1);
free_chunks();
}
-void W_act(void) {
- int i,a;
-
- if(g_time%3!=0) return;
- for(i=1;i<256;++i) if((a=walani[i])!=0) {
- if(anih[a][++anic[a]]==-1) anic[a]=0;
- walp[i]=V_getvgaimg(anih[a][anic[a]]);
- }
-}
-
-/*
-static void unpack(void *buf,int len,void *obuf) {
- byte *p,*o;
- int l,n;
-
- for(p=(byte*)buf,o=(byte*)obuf,l=len;l;++p,--l) if(*p==255) {
- n=*((word*)(++p));memset(o,*(p+=2),n);o+=n;l-=3;
- }else *(o++)=*p;
-}
-*/
-
static void unpack(void *buf, int len, void *obuf) {
int i = 0;
int j = 0;
}
int W_load (FILE *h) {
- int i, j, k, g;
+ char s[8];
+ int i, j, t;
void *p, *buf;
- wall_t w;
switch (blk.t) {
case MB_WALLNAMES:
- for (i = 0; i < 256; ++i) {
- walh[i] = -1;
- walswp[i] = i;
- walani[i] = 0;
- }
- for (i = 1; i < 256 && blk.sz > 0; ++i, blk.sz -= 9) {
- myfread(w.n, 8, 1, h);
- w.t = myfread8(h);
- if (strncasecmp(w.n, "_WATER_", 7) == 0) {
- walp[i] = (void*)((intptr_t)w.n[7] - '0' + 1);
- walh[i] = -2;
- } else {
- walh[i] = F_getresid(w.n);
- walp[i] = V_getvgaimg(walh[i]);
- if (w.n[0] == 'S' && w.n[1] == 'W' && w.n[4] == '_') {
- walswp[i] = 0;
- }
- walf[i] = w.t ? 1 : 0;
- if (w.t) {
- walh[i] |= 0x8000;
- }
- if (strncasecmp(w.n, "VTRAP01", 8) == 0) {
- walf[i] |= 2;
- }
- walani[i] = getani(w.n);
- }
- }
- for (j = i, i = 1; i < 256 && j < 256; ++i) {
- if (walswp[i] == 0) {
- F_getresname(w.n, walh[i] & 0x7FFF);
- w.n[5] ^= 1;
- g = F_getresid(w.n) | (walh[i] & 0x8000);
- k = 1;
- while (k < 256 && walh[k] != g) {
- k += 1;
- }
- if(k >= 256) {
- k = j;
- j += 1;
- walh[k] = g;
- walp[k] = V_getvgaimg(g);
- walf[k] = g & 0x8000 ? 1 : 0;
- }
- walswp[i] = k;
- walswp[k] = i;
+ R_begin_load();
+ R_load("", 0); // empty
+ for (i = 1; i < 256 && blk.sz > 0; i++, blk.sz -= 9) {
+ myfread(s, 8, 1, h);
+ t = myfread8(h);
+ R_load(s, t);
+ if (strncasecmp(s, "VTRAP01", 8) == 0) {
+ walf[i] |= 2;
}
}
- return 1;
- case MB_BACK:
+ R_end_load();
+ return 1;
+ case MB_BACK:
p = fldb;
goto unp;
- case MB_WTYPE:
+ case MB_WTYPE:
p = fld;
goto unp;
- case MB_FRONT:
+ case MB_FRONT:
p = fldf;
unp:
switch (blk.st) {
- case 0:
+ case 0:
myfread(p, FLDW * FLDH, 1, h);
break;
- case 1:
+ case 1:
buf = malloc(blk.sz);
- if(buf == NULL) {
- ERR_fatal("Не хватает памяти");
+ if (buf == NULL) {
+ ERR_fatal("Не хватает памяти");
}
- myfread(buf, blk.sz, 1, h);
- unpack(buf, blk.sz, p);
+ myfread(buf, blk.sz, 1, h);
+ unpack(buf, blk.sz, p);
free(buf);
break;
- default:
+ default:
return 0;
- }
+ }
return 1;
- case MB_SKY:
+ case MB_SKY:
sky_type = myfread16(h);
- strcpy(w.n, "RSKY1");
- w.n[4] = '0' + sky_type;
- M_unlock(horiz);
- horiz = V_loadvgaimg(w.n);
- return 1;
+ R_loadsky(sky_type);
+ return 1;
}
return 0;
}
diff --git a/src/view.h b/src/view.h
index bc14b4557536ac22c9eb9b50f34fe58aa2d05c42..5f1aad947d8cc55f949f76ac62a7400925a5a6c0 100644 (file)
--- a/src/view.h
+++ b/src/view.h
#pragma pack()
-void W_act(void);
+extern dword walf[256];
+extern byte walswp[256];
void W_init(void);