From c94b4d63cba92815777d135fdc6f3e2f4c349e71 Mon Sep 17 00:00:00 2001 From: terminx Date: Tue, 2 Dec 2008 10:44:39 +0000 Subject: [PATCH] separate objects for polymost.c/mdsprite.c/hightile.c and friends git-svn-id: https://svn.eduke32.com/eduke32@1173 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/Makefile | 5 + polymer/eduke32/build/Makefile.deps | 9 +- polymer/eduke32/build/Makefile.msvc | 5 + polymer/eduke32/build/include/build.h | 1 + polymer/eduke32/build/include/hightile.h | 40 +++++++ polymer/eduke32/build/include/mdsprite.h | 18 ++++ polymer/eduke32/build/include/polymer.h | 3 +- polymer/eduke32/build/include/polymost.h | 101 ++++++++++++++--- polymer/eduke32/build/src/engine.c | 130 ++++------------------ polymer/eduke32/build/src/engine_priv.h | 132 +++++++++++++++++++++++ polymer/eduke32/build/src/hightile.c | 36 ++++--- polymer/eduke32/build/src/mdsprite.c | 34 +++--- polymer/eduke32/build/src/polymost.c | 110 ++++++++----------- polymer/eduke32/source/duke3d.h | 3 - polymer/eduke32/source/game.c | 1 + polymer/eduke32/source/gameexec.c | 7 +- 16 files changed, 410 insertions(+), 225 deletions(-) create mode 100644 polymer/eduke32/build/include/hightile.h create mode 100644 polymer/eduke32/build/src/engine_priv.h diff --git a/polymer/eduke32/build/Makefile b/polymer/eduke32/build/Makefile index fd1f3e406..9ea8dd8c9 100644 --- a/polymer/eduke32/build/Makefile +++ b/polymer/eduke32/build/Makefile @@ -113,6 +113,11 @@ ENGINEOBJS+= \ $(OBJ)/crc32.$o \ $(OBJ)/defs.$o \ $(OBJ)/engine.$o \ + $(OBJ)/polymost.$o \ + $(OBJ)/hightile.$o \ + $(OBJ)/mdsprite.$o \ + $(OBJ)/textfont.$o \ + $(OBJ)/smalltextfont.$o \ $(OBJ)/glbuild.$o \ $(OBJ)/kplib.$o \ $(OBJ)/lzf_c.$o \ diff --git a/polymer/eduke32/build/Makefile.deps b/polymer/eduke32/build/Makefile.deps index a54d98dd2..5888c8462 100644 --- a/polymer/eduke32/build/Makefile.deps +++ b/polymer/eduke32/build/Makefile.deps @@ -9,7 +9,12 @@ $(OBJ)/compat.$o: $(SRC)/compat.c $(INC)/compat.h $(OBJ)/config.$o: $(SRC)/config.c $(INC)/compat.h $(INC)/osd.h $(INC)/editor.h $(OBJ)/crc32.$o: $(SRC)/crc32.c $(INC)/crc32.h $(OBJ)/defs.$o: $(SRC)/defs.c $(INC)/build.h $(INC)/baselayer.h $(INC)/scriptfile.h $(INC)/compat.h -$(OBJ)/engine.$o: $(SRC)/engine.c $(SRC)/polymost.c $(INC)/kplib.h $(SRC)/hightile.c $(SRC)/mdsprite.c $(INC)/md4.h $(INC)/lzf.h $(INC)/lzwnew.h $(INC)/compat.h $(INC)/build.h $(INC)/pragmas.h $(INC)/cache1d.h $(INC)/a.h $(INC)/osd.h $(INC)/baselayer.h $(INC)/polymer.h $(INC)/polymost.h $(INC)/mdsprite.h +$(OBJ)/engine.$o: $(SRC)/engine.c $(INC)/compat.h $(INC)/build.h $(INC)/pragmas.h $(INC)/cache1d.h $(INC)/a.h $(INC)/osd.h $(INC)/baselayer.h $(SRC)/engine_priv.h $(INC)/polymost.h $(INC)/hightile.h $(INC)/mdsprite.h $(INC)/polymer.h +$(OBJ)/polymost.$o: $(SRC)/polymost.c $(INC)/md4.h $(INC)/lzf.h $(INC)/lzwnew.h $(SRC)/engine_priv.h $(INC)/polymost.h $(INC)/hightile.h $(INC)/mdsprite.h +$(OBJ)/hightile.$o: $(SRC)/hightile.c $(INC)/kplib.h $(INC)/hightile.h +$(OBJ)/mdsprite.$o: $(SRC)/mdsprite.c $(SRC)/engine_priv.h $(INC)/polymost.h $(INC)/hightile.h $(INC)/mdsprite.h +$(OBJ)/textfont.$o: $(SRC)/textfont.c +$(OBJ)/smalltextfont.$o: $(SRC)/smalltextfont.c $(OBJ)/glbuild.$o: $(SRC)/glbuild.c $(INC)/glbuild.h $(INC)/baselayer.h $(OBJ)/kplib.$o: $(SRC)/kplib.c $(INC)/compat.h $(OBJ)/lzf_c.$o: $(SRC)/lzf_c.c $(SRC)/lzfP.h @@ -28,7 +33,7 @@ $(OBJ)/sound.$o: $(SRC)/sound.c $(INC)/osd.h $(INC)/compat.h $(INC)/cache1d.h $(OBJ)/winlayer.$o: $(SRC)/winlayer.c $(INC)/compat.h $(INC)/winlayer.h $(INC)/baselayer.h $(INC)/pragmas.h $(INC)/build.h $(INC)/a.h $(INC)/osd.h $(INC)/dxdidf.h $(INC)/glbuild.h $(OBJ)/gtkbits.$o: $(SRC)/gtkbits.c $(INC)/baselayer.h $(INC)/build.h $(INC)/dynamicgtk.h $(OBJ)/dynamicgtk.$o: $(SRC)/dynamicgtk.c $(INC)/dynamicgtk.h -$(OBJ)/polymer.$o: $(SRC)/polymer.c $(INC)/polymer.h $(INC)/compat.h $(INC)/build.h $(INC)/glbuild.h $(INC)/osd.h $(INC)/polymost.h $(INC)/pragmas.h $(INC)/mdsprite.h +$(OBJ)/polymer.$o: $(SRC)/polymer.c $(INC)/polymer.h $(INC)/compat.h $(INC)/build.h $(INC)/glbuild.h $(INC)/osd.h $(INC)/pragmas.h $(INC)/mdsprite.h $(OBJ)/buildres.$(res): $(SRC)/misc/buildres.rc $(INC)/startwin.editor.h $(OBJ)/startwin.editor.$o: $(SRC)/startwin.editor.c $(INC)/build.h $(INC)/editor.h $(INC)/winlayer.h $(INC)/compat.h $(INC)/startwin.editor.h diff --git a/polymer/eduke32/build/Makefile.msvc b/polymer/eduke32/build/Makefile.msvc index d6dad9488..dfa66688e 100644 --- a/polymer/eduke32/build/Makefile.msvc +++ b/polymer/eduke32/build/Makefile.msvc @@ -61,6 +61,11 @@ ENGINEOBJS= \ $(OBJ)\crc32.$o \ $(OBJ)\defs.$o \ $(OBJ)\engine.$o \ + $(OBJ)\polymost.$o \ + $(OBJ)\hightile.$o \ + $(OBJ)\mdsprite.$o \ + $(OBJ)\textfont.$o \ + $(OBJ)\smalltextfont.$o \ $(OBJ)\glbuild.$o \ $(OBJ)\kplib.$o \ $(OBJ)\lzf_c.$o \ diff --git a/polymer/eduke32/build/include/build.h b/polymer/eduke32/build/include/build.h index f1695cacd..48a1cc855 100644 --- a/polymer/eduke32/build/include/build.h +++ b/polymer/eduke32/build/include/build.h @@ -542,6 +542,7 @@ extern int glredbluemode; extern int glusetexcache, glusetexcachecompression; extern int glmultisample, glnvmultisamplehint; extern int glwidescreen, glprojectionhacks; +extern int gltexmaxsize; void gltexapplyprops (void); void invalidatecache(void); diff --git a/polymer/eduke32/build/include/hightile.h b/polymer/eduke32/build/include/hightile.h new file mode 100644 index 000000000..67019ecb0 --- /dev/null +++ b/polymer/eduke32/build/include/hightile.h @@ -0,0 +1,40 @@ +#ifndef HIGHTILE_PRIV_H +#define HIGHTILE_PRIV_H + +struct hicskybox_t { + int ignore; + char *face[6]; +}; + +typedef struct hicreplc_t { + struct hicreplc_t *next; + char palnum, ignore, flags, filler; + char *filename; + float alphacut, xscale, yscale; + struct hicskybox_t *skybox; +} hicreplctyp; + +extern palette_t hictinting[MAXPALOOKUPS]; +extern hicreplctyp *hicreplc[MAXTILES]; +extern char hicfirstinit; + +typedef struct +{ + char magic[4]; // 'PMST', was 'Polymost' + int xdim, ydim; // of image, unpadded + int flags; // 1 = !2^x, 2 = has alpha, 4 = lzw compressed + int quality; // r_downsize at the time the cache was written +} texcacheheader; + +typedef struct +{ + int size; + int format; + int xdim, ydim; // of mipmap (possibly padded) + int border, depth; +} texcachepicture; + +hicreplctyp * hicfindsubst(int picnum, int palnum, int skybox); +#define HICEFFECTMASK (1|2|4|8) + +#endif diff --git a/polymer/eduke32/build/include/mdsprite.h b/polymer/eduke32/build/include/mdsprite.h index b21b25161..b43ca9248 100644 --- a/polymer/eduke32/build/include/mdsprite.h +++ b/polymer/eduke32/build/include/mdsprite.h @@ -221,5 +221,23 @@ EXTERN mdmodel **models; void updateanimation(md2model *m, spritetype *tspr); int mdloadskin(md2model *m, int number, int pal, int surf); +void mdinit(void); +void freeallmodels(void); +void clearskins(void); +int mddraw(spritetype *tspr); + +typedef struct { float xadd, yadd, zadd; short angadd, flags; } hudtyp; + +EXTERN hudtyp hudmem[2][MAXTILES]; //~320KB ... ok for now ... could replace with dynamic alloc + +EXTERN int mdinited; +EXTERN int mdpause; +EXTERN int nummodelsalloced, nextmodelid; +EXTERN voxmodel *voxmodels[MAXVOXELS]; + +void voxfree(voxmodel *m); +voxmodel *voxload(const char *filnam); +int voxdraw(voxmodel *m, spritetype *tspr); + #endif // !_mdsprite_h_ diff --git a/polymer/eduke32/build/include/polymer.h b/polymer/eduke32/build/include/polymer.h index e89e7fefd..a9e131c25 100644 --- a/polymer/eduke32/build/include/polymer.h +++ b/polymer/eduke32/build/include/polymer.h @@ -26,8 +26,9 @@ # include "build.h" # include "glbuild.h" # include "osd.h" -# include "polymost.h" +# include "hightile.h" # include "mdsprite.h" +# include "polymost.h" # include "pragmas.h" # include diff --git a/polymer/eduke32/build/include/polymost.h b/polymer/eduke32/build/include/polymost.h index e5574e35d..2cc9de79b 100644 --- a/polymer/eduke32/build/include/polymost.h +++ b/polymer/eduke32/build/include/polymost.h @@ -1,20 +1,90 @@ -#ifndef _polymost_h_ -# define _polymost_h_ +#ifndef _polymost_h_ +# define _polymost_h_ -# include "glbuild.h" +#ifdef POLYMOST -struct hicskybox_t { - int ignore; - char *face[6]; +#define CULL_OFFSET 384 +#define CULL_DELAY 2 +#define MAXCULLCHECKS 1024 + +extern int lastcullcheck; +extern char cullmodel[MAXSPRITES]; +extern int cullcheckcnt; + +#define PI 3.14159265358979323 + +typedef struct { unsigned char r, g, b, a; } coltype; + +extern int rendmode; +extern float gtang; +extern float glox1, gloy1; +extern double gxyaspect, grhalfxdown10x; +extern double gcosang, gsinang, gcosang2, gsinang2; +extern double gchang, gshang, gctang, gstang; + +struct glfiltermodes { + char *name; + int min,mag; +}; +#define numglfiltermodes 6 +extern struct glfiltermodes glfiltermodes[numglfiltermodes]; + +extern const char *TEXCACHEDIR; +void phex(unsigned char v, char *s); +void uploadtexture(int doalloc, int xsiz, int ysiz, int intexfmt, int texfmt, coltype *pic, int tsizx, int tsizy, int dameth); +void polymost_drawsprite(int snum); +void polymost_drawmaskwall(int damaskwallcnt); +void polymost_dorotatesprite(int sx, int sy, int z, short a, short picnum, + signed char dashade, char dapalnum, char dastat, int cx1, int cy1, int cx2, int cy2, int uniqid); +void polymost_fillpolygon(int npoints); +void polymost_initosdfuncs(void); +void polymost_drawrooms(void); + +void polymost_glinit(void); +void polymost_glreset(void); + +void gltexinvalidate(int dapicnum, int dapalnum, int dameth); +void gltexinvalidateall(void); +void gltexinvalidate8(void); +int polymost_printext256(int xpos, int ypos, short col, short backcol, char *name, char fontsize); + +// Depth peeling control +extern int r_curpeel; +extern float curpolygonoffset; +extern int peelcompiling; + +// Depth peeling data +extern GLuint ztexture[3]; +extern GLuint *peels; +extern GLuint *peelfbos; +extern GLuint peelprogram[2]; + +extern int cachefilehandle; +extern FILE *cacheindexptr; +extern struct HASH_table cacheH; + +struct cache_entry +{ + char name[BMAX_PATH]; + int offset; + int len; + struct cache_entry *next; }; -typedef struct hicreplc_t { - struct hicreplc_t *next; - char palnum, ignore, flags, filler; - char *filename; - float alphacut, xscale, yscale; - struct hicskybox_t *skybox; -} hicreplctyp; +typedef struct cache_entry texcacheindex; + +extern texcacheindex firstcacheindex; +extern texcacheindex *datextures; +extern texcacheindex *cacheptrs[MAXTILES<<2]; +extern int numcacheentries; + +int dxtfilter(int fil, texcachepicture *pict, char *pic, void *midbuf, char *packbuf, unsigned int miplen); +int dedxtfilter(int fil, texcachepicture *pict, char *pic, void *midbuf, char *packbuf, int ispacked); + +void writexcache(char *fn, int len, int dameth, char effect, texcacheheader *head); + +extern float shadescale; +extern float alphahackarray[MAXTILES]; typedef struct pthtyp_t { @@ -34,7 +104,6 @@ typedef struct pthtyp_t char *palmap;int size; } pthtyp; -hicreplctyp * hicfindsubst(int picnum, int palnum, int skybox); pthtyp * gltexcache (int dapicnum, int dapalnum, int dameth); extern palette_t hictinting[MAXPALOOKUPS]; @@ -47,6 +116,6 @@ extern float shadescale; extern int globalnoeffect; extern int drawingskybox; -#define HICEFFECTMASK (1|2|4|8) +#endif -#endif // !_polymost_h_ +#endif \ No newline at end of file diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index 6d93187a3..4f934df66 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -22,27 +22,24 @@ #include "scriptfile.h" #ifdef POLYMOST +# ifdef USE_OPENGL +# include "glbuild.h" +# ifdef POLYMER +# include "polymer.h" +# endif +# endif +# include "hightile.h" +# include "mdsprite.h" +# include "polymost.h" # ifdef _WIN32 # define WIN32_LEAN_AND_MEAN # include # endif -# ifdef USE_OPENGL -# include "glbuild.h" -# ifdef POLYMER -# include "polymer.h" -# endif -#endif #endif #include -#define MAXCLIPNUM 1024 -#define MAXPERMS 512 -#define MAXTILEFILES 256 -#define MAXYSAVES ((MAXXDIM*MAXSPRITES)>>7) -#define MAXNODESPERLINE 42 //Warning: This depends on MAXYSAVES & MAXYDIM! -#define MAXCLIPDIST 1024 - +#include "engine_priv.h" void *kmalloc(bsize_t size) { return(Bmalloc(size)); } #define kkmalloc kmalloc @@ -93,7 +90,7 @@ static char tempbuf[MAXWALLS]; int ebpbak, espbak; int slopalookup[16384]; // was 2048 #if defined(USE_OPENGL) -static palette_t palookupfog[MAXPALOOKUPS]; +palette_t palookupfog[MAXPALOOKUPS]; #endif static char permanentlock = 255; @@ -122,9 +119,8 @@ int pow2long[32] = int reciptable[2048], fpuasm; char britable[16][256]; // JBF 20040207: full 8bit precision -//char textfont[1024], smalltextfont[1024]; -#include "textfont.c" -#include "smalltextfont.c" + +extern char textfont[2048], smalltextfont[2048]; static char kensmessage[128]; char *engineerrstr = "No error"; @@ -191,21 +187,6 @@ int msqrtasm(unsigned int); modify exact [eax ebx ecx] int krecipasm(int); -#pragma aux setgotpic =\ - "mov ebx, eax",\ - "cmp byte ptr walock[eax], 200",\ - "jae skipit",\ - "mov byte ptr walock[eax], 199",\ - "skipit: shr eax, 3",\ - "and ebx, 7",\ - "mov dl, byte ptr gotpic[eax]",\ - "mov bl, byte ptr pow2char[ebx]",\ - "or dl, bl",\ - "mov byte ptr gotpic[eax], dl",\ - parm [eax]\ - modify exact [eax ebx ecx edx] -void setgotpic(int); - #pragma aux getclipmask =\ "sar eax, 31",\ "add ebx, ebx",\ @@ -314,27 +295,6 @@ static inline int krecipasm(int a) } } -static inline void setgotpic(int a) -{ - _asm - { - push ebx - mov eax, a - mov ebx, eax - cmp byte ptr walock[eax], 200 - jae skipit - mov byte ptr walock[eax], 199 -skipit: - shr eax, 3 - and ebx, 7 - mov dl, byte ptr gotpic[eax] - mov bl, byte ptr pow2char[ebx] - or dl, bl - mov byte ptr gotpic[eax], dl - pop ebx - } -} - static inline int getclipmask(int a, int b, int c, int d) { _asm @@ -425,24 +385,6 @@ beg: : "=a" (__r) : "c" (__c) : "edx","ebx", "cc"); \ __r; }) -#define setgotpic(a) \ - ({ int __a=(a); \ - __asm__ __volatile__ ( \ - "movl %%eax, %%ebx\n\t" \ - "cmpb $200, "ASMSYM("walock")"(%%eax)\n\t" \ - "jae 0f\n\t" \ - "movb $199, "ASMSYM("walock")"(%%eax)\n\t" \ - "0:\n\t" \ - "shrl $3, %%eax\n\t" \ - "andl $7, %%ebx\n\t" \ - "movb "ASMSYM("gotpic")"(%%eax), %%dl\n\t" \ - "movb "ASMSYM("pow2char")"(%%ebx), %%bl\n\t" \ - "orb %%bl, %%dl\n\t" \ - "movb %%dl, "ASMSYM("gotpic")"(%%eax)" \ - : "=a" (__a) : "a" (__a) \ - : "ebx", "edx", "memory", "cc"); \ - __a; }) - #define krecipasm(a) \ ({ int __a=(a); \ __asm__ __volatile__ ( \ @@ -532,12 +474,6 @@ static inline int msqrtasm(unsigned int c) return a; } -static inline void setgotpic(int tilenume) -{ - if (walock[tilenume] < 200) walock[tilenume] = 199; - gotpic[tilenume>>3] |= pow2char[tilenume&7]; -} - static inline int krecipasm(int i) { // Ken did this @@ -562,12 +498,12 @@ inline int getkensmessagecrc(int b) #endif -static int xb1[MAXWALLSB], yb1[MAXWALLSB], xb2[MAXWALLSB], yb2[MAXWALLSB]; -static int rx1[MAXWALLSB], ry1[MAXWALLSB], rx2[MAXWALLSB], ry2[MAXWALLSB]; -static short p2[MAXWALLSB], thesector[MAXWALLSB]; +int xb1[MAXWALLSB], yb1[MAXWALLSB], xb2[MAXWALLSB], yb2[MAXWALLSB]; +int rx1[MAXWALLSB], ry1[MAXWALLSB], rx2[MAXWALLSB], ry2[MAXWALLSB]; +short p2[MAXWALLSB], thesector[MAXWALLSB]; short thewall[MAXWALLSB]; -static short bunchfirst[MAXWALLSB], bunchlast[MAXWALLSB]; +short bunchfirst[MAXWALLSB], bunchlast[MAXWALLSB]; static short smost[MAXYSAVES], smostcnt; static short smoststart[MAXWALLSB]; @@ -617,13 +553,13 @@ intptr_t globalbufplc; int globalx1, globaly1, globalx2, globaly2, globalx3, globaly3, globalzx; int globalx, globaly, globalz; -static short sectorborder[256], sectorbordercnt; +short sectorborder[256], sectorbordercnt; static char tablesloaded = 0; int pageoffset, ydim16, qsetmode = 0; int startposx, startposy, startposz; short startang, startsectnum; short pointhighlight, linehighlight, highlightcnt; -static int lastx[MAXYDIM]; +int lastx[MAXYDIM]; char *transluc = NULL, paletteloaded = 0; int halfxdim16, midydim16; @@ -639,7 +575,7 @@ static int colscan[27]; static short clipnum, hitwalls[4]; int hitscangoalx = (1<<29)-1, hitscangoaly = (1<<29)-1; #ifdef POLYMOST -static int hitallsprites = 0; +int hitallsprites = 0; #endif typedef struct { int x1, y1, x2, y2; } linetype; @@ -679,7 +615,7 @@ double msens = 1.0; static char artfilename[20]; static int numtilefiles, artfil = -1, artfilnum, artfilplc; -static char inpreparemirror = 0; +char inpreparemirror = 0; static int mirrorsx1, mirrorsy1, mirrorsx2, mirrorsy2; static int setviewcnt = 0; // interface layers use this now @@ -706,26 +642,6 @@ char palfadedelta = 0; //int cacheresets = 0,cacheinvalidates = 0; -//============================================================================= //POLYMOST BEGINS -#ifdef POLYMOST -static void scansector(short sectnum); -#include "polymost.h" -#include "hightile.c" -#include "polymost.c" -#else -void hicsetpalettetint(int palnum, unsigned char r, unsigned char g, unsigned char b, unsigned char effect) -{ UNREFERENCED_PARAMETER(palnum); UNREFERENCED_PARAMETER(r); UNREFERENCED_PARAMETER(g); UNREFERENCED_PARAMETER(b); UNREFERENCED_PARAMETER(effect);} -int hicsetsubsttex(int picnum, int palnum, char *filen, float alphacut, float xscale, float yscale, char flags) -{ UNREFERENCED_PARAMETER(picnum); UNREFERENCED_PARAMETER(palnum); UNREFERENCED_PARAMETER(filen); UNREFERENCED_PARAMETER(alphacut); UNREFERENCED_PARAMETER(xscale); UNREFERENCED_PARAMETER(yscale); UNREFERENCED_PARAMETER(flags); return 0;} -int hicsetskybox(int picnum, int palnum, char *faces[6]) -{ UNREFERENCED_PARAMETER(picnum); UNREFERENCED_PARAMETER(palnum); UNREFERENCED_PARAMETER(faces); return 0;} -int hicclearsubst(int picnum, int palnum) -{ UNREFERENCED_PARAMETER(picnum); UNREFERENCED_PARAMETER(palnum);return 0;} -int polymost_drawtilescreen(int tilex, int tiley, int wallnum, int dimen, int tilezoom) -{ UNREFERENCED_PARAMETER(tilex); UNREFERENCED_PARAMETER(tiley); UNREFERENCED_PARAMETER(wallnum); UNREFERENCED_PARAMETER(dimen); UNREFERENCED_PARAMETER(tilezoom);return -1;} -#endif -//============================================================================= //POLYMOST ENDS - // // getpalookup (internal) // @@ -1042,7 +958,7 @@ static void maskwallscan(int x1, int x2, short *uwal, short *dwal, int *swal, in // // wallfront (internal) // -static int wallfront(int l1, int l2) +int wallfront(int l1, int l2) { walltype *wal; int x11, y11, x21, y21, x12, y12, x22, y22, dx, dy, t1, t2; @@ -1407,7 +1323,7 @@ static int owallmost(short *mostbuf, int w, int z) // // wallmost (internal) // -static int wallmost(short *mostbuf, int w, int sectnum, char dastat) +int wallmost(short *mostbuf, int w, int sectnum, char dastat) { int bad, i, j, t, y, z, inty, intz, xcross, yinc, fw; int x1, y1, z1, x2, y2, z2, xv, yv, dx, dy, dasqr, oz1, oz2; diff --git a/polymer/eduke32/build/src/engine_priv.h b/polymer/eduke32/build/src/engine_priv.h new file mode 100644 index 000000000..7d3587115 --- /dev/null +++ b/polymer/eduke32/build/src/engine_priv.h @@ -0,0 +1,132 @@ +#ifndef ENGINE_PRIV_H +#define ENGINE_PRIV_H + +#define MAXCLIPNUM 1024 +#define MAXPERMS 512 +#define MAXTILEFILES 256 +#define MAXYSAVES ((MAXXDIM*MAXSPRITES)>>7) +#define MAXNODESPERLINE 42 //Warning: This depends on MAXYSAVES & MAXYDIM! +#define MAXCLIPDIST 1024 + +extern char pow2char[8]; +extern int pow2int[32]; + +extern short thesector[MAXWALLSB], thewall[MAXWALLSB]; +extern short bunchfirst[MAXWALLSB], bunchlast[MAXWALLSB]; +extern short maskwall[MAXWALLSB], maskwallcnt; +extern spritetype *tspriteptr[MAXSPRITESONSCREEN]; +extern int xdimen, xdimenrecip, halfxdimen, xdimenscale, xdimscale, ydimen; +extern int frameoffset; +extern int globalposx, globalposy, globalposz, globalhoriz; +extern short globalang, globalcursectnum; +extern int globalpal, cosglobalang, singlobalang; +extern int cosviewingrangeglobalang, sinviewingrangeglobalang; +extern int globalvisibility; +extern int xyaspect; +extern int asm1, asm2, asm3, asm4; +extern int globalshade; +extern short globalpicnum; +extern int globalx1, globaly2; +extern int globalorientation; + +extern short searchit; +extern int searchx, searchy; +extern short searchsector, searchwall, searchstat; + +extern char inpreparemirror; + +extern int curbrightness, gammabrightness; +extern char britable[16][256]; +extern char picsiz[MAXTILES]; +extern int lastx[MAXYDIM]; +extern char *transluc; +extern short sectorborder[256], sectorbordercnt; +extern int qsetmode; +extern int hitallsprites; + +extern int xb1[MAXWALLSB]; +extern int rx1[MAXWALLSB], ry1[MAXWALLSB]; +extern short p2[MAXWALLSB]; +extern short numscans, numhits, numbunches; + +#ifdef USE_OPENGL +extern palette_t palookupfog[MAXPALOOKUPS]; +#endif + +int wallmost(short *mostbuf, int w, int sectnum, char dastat); +int wallfront(int l1, int l2); +int animateoffs(short tilenum, short fakevar); + +extern int indrawroomsandmasks; + + +#if defined(__WATCOMC__) && !defined(NOASM) + +#pragma aux setgotpic =\ +"mov ebx, eax",\ +"cmp byte ptr walock[eax], 200",\ +"jae skipit",\ +"mov byte ptr walock[eax], 199",\ +"skipit: shr eax, 3",\ +"and ebx, 7",\ +"mov dl, byte ptr gotpic[eax]",\ +"mov bl, byte ptr pow2char[ebx]",\ +"or dl, bl",\ +"mov byte ptr gotpic[eax], dl",\ +parm [eax]\ +modify exact [eax ebx ecx edx] +void setgotpic(int); + +#elif defined(_MSC_VER) && !defined(NOASM) // __WATCOMC__ + +static inline void setgotpic(int a) +{ + _asm { + push ebx + mov eax, a + mov ebx, eax + cmp byte ptr walock[eax], 200 + jae skipit + mov byte ptr walock[eax], 199 +skipit: + shr eax, 3 + and ebx, 7 + mov dl, byte ptr gotpic[eax] + mov bl, byte ptr pow2char[ebx] + or dl, bl + mov byte ptr gotpic[eax], dl + pop ebx + } +} + +#elif defined(__GNUC__) && defined(__i386__) && !defined(NOASM) // _MSC_VER + +#define setgotpic(a) \ +({ int __a=(a); \ + __asm__ __volatile__ ( \ + "movl %%eax, %%ebx\n\t" \ + "cmpb $200, "ASMSYM("walock")"(%%eax)\n\t" \ + "jae 0f\n\t" \ + "movb $199, "ASMSYM("walock")"(%%eax)\n\t" \ + "0:\n\t" \ + "shrl $3, %%eax\n\t" \ + "andl $7, %%ebx\n\t" \ + "movb "ASMSYM("gotpic")"(%%eax), %%dl\n\t" \ + "movb "ASMSYM("pow2char")"(%%ebx), %%bl\n\t" \ + "orb %%bl, %%dl\n\t" \ + "movb %%dl, "ASMSYM("gotpic")"(%%eax)" \ + : "=a" (__a) : "a" (__a) \ + : "ebx", "edx", "memory", "cc"); \ + __a; }) + +#else // __GNUC__ && __i386__ + +static inline void setgotpic(int tilenume) +{ + if (walock[tilenume] < 200) walock[tilenume] = 199; + gotpic[tilenume>>3] |= pow2char[tilenume&7]; +} + +#endif + +#endif /* ENGINE_PRIV_H */ diff --git a/polymer/eduke32/build/src/hightile.c b/polymer/eduke32/build/src/hightile.c index a69f6901c..82eb0072b 100644 --- a/polymer/eduke32/build/src/hightile.c +++ b/polymer/eduke32/build/src/hightile.c @@ -4,26 +4,18 @@ * See the included license file "BUILDLIC.TXT" for license info. */ -#include "kplib.h" +#ifdef POLYMOST + +#include "build.h" +#include "compat.h" +#include "kplib.h" +#include "hightile.h" + palette_t hictinting[MAXPALOOKUPS]; -//moved into polymost.h -//#define HICEFFECTMASK (1|2|4) -/*struct hicskybox_t { - int ignore; - char *face[6]; -}; - -typedef struct hicreplc_t { - struct hicreplc_t *next; - char palnum, ignore, flags, filler; - char *filename; - float alphacut; - struct hicskybox_t *skybox; -} hicreplctyp;*/ -static hicreplctyp *hicreplc[MAXTILES]; -static char hicfirstinit = 0; +hicreplctyp *hicreplc[MAXTILES]; +char hicfirstinit = 0; // // find the index into hicreplc[] which contains the replacement tile particulars @@ -290,3 +282,13 @@ int hicclearsubst(int picnum, int palnum) return 0; } + +#else /* POLYMOST */ + +void hicsetpalettetint(int palnum, unsigned char r, unsigned char g, unsigned char b, unsigned char effect) { } +int hicsetsubsttex(int picnum, int palnum, char *filen, float alphacut) { return 0; } +int hicsetskybox(int picnum, int palnum, char *faces[6]) { return 0; } +int hicclearsubst(int picnum, int palnum) { return 0; } + +#endif + diff --git a/polymer/eduke32/build/src/mdsprite.c b/polymer/eduke32/build/src/mdsprite.c index d3b6eb81d..c70a842dd 100644 --- a/polymer/eduke32/build/src/mdsprite.c +++ b/polymer/eduke32/build/src/mdsprite.c @@ -1,7 +1,19 @@ //------------------------------------- MD2/MD3 LIBRARY BEGINS ------------------------------------- +#include "compat.h" +#include "build.h" +#include "glbuild.h" +#include "pragmas.h" +#include "baselayer.h" +#include "engine_priv.h" +#include "hightile.h" +#include "polymost.h" #include "mdsprite.h" -static voxmodel *voxmodels[MAXVOXELS]; +#include "cache1d.h" +#include "kplib.h" +#include "md4.h" + +voxmodel *voxmodels[MAXVOXELS]; int curextra=MAXTILES; int addtileP(int model,int tile,int pallet) @@ -29,15 +41,11 @@ int Ptile2tile(int tile,int pallet) return t; } -//Move this to appropriate place! -typedef struct { float xadd, yadd, zadd; short angadd, flags; } hudtyp; -hudtyp hudmem[2][MAXTILES]; //~320KB ... ok for now ... could replace with dynamic alloc - -static char mdinited=0; +int mdinited=0; int mdpause=0; #define MODELALLOCGROUP 256 -static int nummodelsalloced = 0, nextmodelid = 0; +int nummodelsalloced = 0, nextmodelid = 0; static int maxmodelverts = 0, allocmodelverts = 0; static int maxmodeltris = 0, allocmodeltris = 0; @@ -54,7 +62,7 @@ int globalnoeffect=0; extern int timerticspersec; -static void freeallmodels() +void freeallmodels() { int i; @@ -87,7 +95,7 @@ static void freeallmodels() } } -static void clearskins() +void clearskins() { mdmodel *m; int i, j; @@ -134,7 +142,7 @@ static void clearskins() } } -static void mdinit() +void mdinit() { memset(hudmem,0,sizeof(hudmem)); freeallmodels(); @@ -2701,7 +2709,7 @@ static int loadvxl(const char *filnam) } #endif -static void voxfree(voxmodel *m) +void voxfree(voxmodel *m) { if (!m) return; if (m->mytex) free(m->mytex); @@ -2710,7 +2718,7 @@ static void voxfree(voxmodel *m) free(m); } -static voxmodel *voxload(const char *filnam) +voxmodel *voxload(const char *filnam) { int i, is8bit, ret; voxmodel *vm; @@ -2741,7 +2749,7 @@ static voxmodel *voxload(const char *filnam) } //Draw voxel model as perfect cubes -static int voxdraw(voxmodel *m, spritetype *tspr) +int voxdraw(voxmodel *m, spritetype *tspr) { point3d fp, m0, a0; int i, j, fi, xx, yy, zz; diff --git a/polymer/eduke32/build/src/polymost.c b/polymer/eduke32/build/src/polymost.c index 33e634e88..9268aaee3 100644 --- a/polymer/eduke32/build/src/polymost.c +++ b/polymer/eduke32/build/src/polymost.c @@ -65,7 +65,25 @@ Low priority: **************************************************************************************************/ -int animateoffs(short tilenum, short fakevar); + +#ifdef POLYMOST + +#include "compat.h" +#include "build.h" +#include "glbuild.h" +#include "pragmas.h" +#include "baselayer.h" +#include "osd.h" +#include "engine_priv.h" +#include "hightile.h" +#include "mdsprite.h" +#include "polymost.h" +#include "scriptfile.h" +#include "cache1d.h" +#include "kplib.h" + +extern char textfont[2048], smalltextfont[2048]; + int rendmode=0; int usemodels=1, usehightile=1; @@ -82,13 +100,12 @@ static double dxb1[MAXWALLSB], dxb2[MAXWALLSB]; #define LINTERPSIZ 4 //log2 of interpolation size. 4:pretty fast&acceptable quality, 0:best quality/slow! #define DEPTHDEBUG 0 //1:render distance instead of texture, for debugging only!, 0:default #define FOGSCALE 0.0000640 -#define PI 3.14159265358979323 float shadescale = 1.050; -static double gyxscale, gxyaspect, gviewxrange, ghalfx, grhalfxdown10, grhalfxdown10x, ghoriz; -static double gcosang, gsinang, gcosang2, gsinang2; -static double gchang, gshang, gctang, gstang, gvisibility; +double gyxscale, gxyaspect, gviewxrange, ghalfx, grhalfxdown10, grhalfxdown10x, ghoriz; +double gcosang, gsinang, gcosang2, gsinang2; +double gchang, gshang, gctang, gstang, gvisibility; float gtang = 0.0; double guo, gux, guy; //Screen-based texture mapping parameters double gvo, gvx, gvy; @@ -105,11 +122,7 @@ static int srepeat = 0, trepeat = 0; int glredbluemode = 0; static int lastglredbluemode = 0, redblueclearcnt = 0; -static struct glfiltermodes -{ - char *name; - int min,mag; -} glfiltermodes[] = +struct glfiltermodes glfiltermodes[numglfiltermodes] = { {"GL_NEAREST",GL_NEAREST,GL_NEAREST}, {"GL_LINEAR",GL_LINEAR,GL_LINEAR}, @@ -118,7 +131,6 @@ static struct glfiltermodes {"GL_NEAREST_MIPMAP_LINEAR",GL_NEAREST_MIPMAP_LINEAR,GL_NEAREST}, {"GL_LINEAR_MIPMAP_LINEAR",GL_LINEAR_MIPMAP_LINEAR,GL_LINEAR} }; -#define numglfiltermodes (sizeof(glfiltermodes)/sizeof(glfiltermodes[0])) int glanisotropy = 1; // 0 = maximum supported by card int glusetexcompr = 1; @@ -144,15 +156,15 @@ static int shadeforfullbrightpass; int r_depthpeeling = 0; // cvar toggling general depth peeling usage int r_peelscount = 5; // cvar controlling the number of peeling layers int r_curpeel = -1; // cvar controlling the display of independant peeling layers -static float curpolygonoffset; // internal polygon offset stack for drawing flat sprites to avoid depth fighting -static int peelcompiling = 0; // internal control var to disable blending when compiling the peeling display list -static int newpeelscount = 0; // temporary var for peels count changing during the game +float curpolygonoffset; // internal polygon offset stack for drawing flat sprites to avoid depth fighting +int peelcompiling = 0; // internal control var to disable blending when compiling the peeling display list +int newpeelscount = 0; // temporary var for peels count changing during the game // Depth peeling data -static GLuint ztexture[3]; // secondary Z-buffers identifier -static GLuint *peels; // peels identifiers -static GLuint *peelfbos; // peels FBOs identifiers -static GLuint peelprogram[2]; // ARBfp peeling fragment program +GLuint ztexture[3]; // secondary Z-buffers identifier +GLuint *peels; // peels identifiers +GLuint *peelfbos; // peels FBOs identifiers +GLuint peelprogram[2]; // ARBfp peeling fragment program // Detail mapping cvar int r_detailmapping = 1; @@ -195,6 +207,8 @@ static float fogresult, fogcol[4]; } #endif +static char tempbuf[MAXWALLSB<<1]; + // polymost ART sky control int r_parallaxskyclamping = 1; int r_parallaxskypanning = 0; @@ -310,9 +324,6 @@ void drawline2d(float x0, float y0, float x1, float y1, char col) } #ifdef USE_OPENGL -typedef struct { unsigned char r, g, b, a; } coltype; - -static void uploadtexture(int doalloc, int xsiz, int ysiz, int intexfmt, int texfmt, coltype *pic, int tsizx, int tsizy, int dameth); #include "md4.h" @@ -328,51 +339,18 @@ static void uploadtexture(int doalloc, int xsiz, int ysiz, int intexfmt, int tex int cachefilehandle = -1; // texture cache file handle FILE *cacheindexptr = NULL; -static struct HASH_table cacheH = { MAXTILES<<2, NULL }; +struct HASH_table cacheH = { MAXTILES<<2, NULL }; char TEXCACHEFILE[BMAX_PATH] = "textures"; -typedef struct -{ - char magic[4]; // 'PMST', was 'Polymost' - int xdim, ydim; // of image, unpadded - int flags; // 1 = !2^x, 2 = has alpha, 4 = lzw compressed - int quality; // r_downsize at the time the cache was written -} texcacheheader; -typedef struct -{ - int size; - int format; - int xdim, ydim; // of mipmap (possibly padded) - int border, depth; -} texcachepicture; - -int dxtfilter(int fil, texcachepicture *pict, char *pic, void *midbuf, char *packbuf, unsigned int miplen); -int dedxtfilter(int fil, texcachepicture *pict, char *pic, void *midbuf, char *packbuf, int ispacked); - -static inline void phex(unsigned char v, char *s); -void writexcache(char *fn, int len, int dameth, char effect, texcacheheader *head); - int mdtims, omdtims; float alphahackarray[MAXTILES]; -struct cache_entry -{ - char name[BMAX_PATH]; - int offset; - int len; - struct cache_entry *next; -}; - -typedef struct cache_entry texcacheindex; - texcacheindex firstcacheindex; texcacheindex *datextures = NULL; texcacheindex *cacheptrs[MAXTILES<<2]; int numcacheentries = 0; -#include "mdsprite.c" - //-------------------------------------------------------------------------------------------------- //TEXTURE MANAGEMENT: treats same texture with different .PAL as a separate texture. This makes the // max number of virtual textures very large (MAXTILES*256). Instead of allocating a handle for @@ -398,7 +376,7 @@ int numcacheentries = 0; } pthtyp;*/ #define GLTEXCACHEADSIZ 8192 -static pthtyp *gltexcachead[GLTEXCACHEADSIZ]; +pthtyp *gltexcachead[GLTEXCACHEADSIZ]; int drawingskybox = 0; @@ -654,7 +632,7 @@ void gltexapplyprops(void) //-------------------------------------------------------------------------------------------------- static int LoadCacheOffsets(void); -static float glox1, gloy1, glox2, gloy2; +float glox1, gloy1, glox2, gloy2; //Use this for both initialization and uninitialization of OpenGL. static int gltexcacnum = -1; @@ -1140,7 +1118,7 @@ void fixtransparency(coltype *dapic, int daxsiz, int daysiz, int daxsiz2, int da } } -static void uploadtexture(int doalloc, int xsiz, int ysiz, int intexfmt, int texfmt, coltype *pic, int tsizx, int tsizy, int dameth) +void uploadtexture(int doalloc, int xsiz, int ysiz, int intexfmt, int texfmt, coltype *pic, int tsizx, int tsizy, int dameth) { coltype *wpptr, *rpptr; int x2, y2, j, js=0, x3, y3, y, x, r, g, b, a, k; @@ -1423,7 +1401,7 @@ static int LoadCacheOffsets(void) return 0; } -static inline void phex(unsigned char v, char *s) +void phex(unsigned char v, char *s) { int x; x = v>>4; @@ -1513,7 +1491,7 @@ void writexcache(char *fn, int len, int dameth, char effect, texcacheheader *hea void *midbuf = NULL; unsigned int alloclen=0, level, miplen; unsigned int padx=0, pady=0; - GLuint gi; + GLint gi; int offset = 0; if (!glinfo.texcompr || !glusetexcompr || !glusetexcache || !cacheindexptr || cachefilehandle < 0) return; @@ -4198,7 +4176,6 @@ static void polymost_drawalls(int bunch) } } -static int wallfront(int, int); static int polymost_bunchfront(int b1, int b2) { double x1b1, x1b2, x2b1, x2b2; @@ -4749,10 +4726,6 @@ void polymost_drawmaskwall(int damaskwallcnt) drawpoly(dpx,dpy,n,method); } -#define CULL_OFFSET 384 -#define CULL_DELAY 2 -#define MAXCULLCHECKS 1024 - int lastcullcheck = 0; char cullmodel[MAXSPRITES]; int cullcheckcnt = 0; @@ -6729,4 +6702,11 @@ int dedxtfilter(int fil, texcachepicture *pict, char *pic, void *midbuf, char *p return 0; } #endif + +#else /* POLYMOST */ + +int polymost_drawtilescreen (int tilex, int tiley, int wallnum, int dimen) { return -1; } + +#endif + // vim:ts=4:sw=4: diff --git a/polymer/eduke32/source/duke3d.h b/polymer/eduke32/source/duke3d.h index c34d25709..0ddb02e10 100644 --- a/polymer/eduke32/source/duke3d.h +++ b/polymer/eduke32/source/duke3d.h @@ -36,9 +36,6 @@ extern "C" { #include "compat.h" #include "a.h" #include "build.h" -#if defined(POLYMOST) && defined(USE_OPENGL) -# include "polymost.h" -#endif #ifdef POLYMER # include "polymer.h" #endif diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index 949c86c2a..ac2f47153 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -44,6 +44,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "kplib.h" //#include "crc32.h" #include "util_lib.h" +#include "hightile.h" #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN diff --git a/polymer/eduke32/source/gameexec.c b/polymer/eduke32/source/gameexec.c index 2e3bf8af1..52b6ef8bc 100644 --- a/polymer/eduke32/source/gameexec.c +++ b/polymer/eduke32/source/gameexec.c @@ -910,7 +910,12 @@ static int X_DoExecute(void) insptr++; if (g_sp->picnum == APLAYER) g_sp->pal = g_player[g_sp->yvel].ps->palookup; - else g_sp->pal = ActorExtra[g_i].tempang; + else + { + if (g_sp->pal == 1 && g_sp->extra == 0) // hack for frozen + g_sp->extra++; + g_sp->pal = ActorExtra[g_i].tempang; + } ActorExtra[g_i].tempang = 0; break;