diff --git a/polymer/eduke32/build/include/build.h b/polymer/eduke32/build/include/build.h index 7df7071a4..5b0c75b7c 100644 --- a/polymer/eduke32/build/include/build.h +++ b/polymer/eduke32/build/include/build.h @@ -277,6 +277,22 @@ static inline void sprite_tracker_hook(uintptr_t address); #endif // __cplusplus +typedef struct { + int32_t x, y; +} vec2_t; + +typedef struct { + int32_t x, y, z; +} vec3_t; + +typedef struct { + float x, y; +} fvec2_t; + +typedef struct { + float x, y, z; +} fvec3_t; + // Links to various ABIs specifying (or documenting non-normatively) the // alignment requirements of aggregates: // @@ -829,7 +845,8 @@ EXTERN int16_t headspritesect[MAXSECTORS+1], headspritestat[MAXSTATUS+1]; EXTERN int16_t prevspritesect[MAXSPRITES], prevspritestat[MAXSPRITES]; EXTERN int16_t nextspritesect[MAXSPRITES], nextspritestat[MAXSPRITES]; -EXTERN int16_t tilesizx[MAXTILES], tilesizy[MAXTILES]; +EXTERN vec2_t tilesiz[MAXTILES]; + EXTERN char picsiz[MAXTILES]; EXTERN char walock[MAXTILES]; #ifdef __cplusplus @@ -1046,14 +1063,6 @@ OTHER VARIABLES: you call the loadboard function. ***************************************************************************/ -typedef struct { - int32_t x, y; -} vec2_t; - -typedef struct { - int32_t x, y, z; -} vec3_t; - typedef struct { vec3_t pos; int16_t sprite, wall, sect; diff --git a/polymer/eduke32/build/include/polymost.h b/polymer/eduke32/build/include/polymost.h index b9b847415..c64df5bb2 100644 --- a/polymer/eduke32/build/include/polymost.h +++ b/polymer/eduke32/build/include/polymost.h @@ -176,60 +176,11 @@ extern float gyxscale, gxyaspect, ghalfx, grhalfxdown10; extern char ptempbuf[MAXWALLSB<<1]; -static inline void polymost_setupdetailtexture(int32_t *texunits, int32_t tex) -{ - bglActiveTextureARB(++*texunits); - - bglEnable(GL_TEXTURE_2D); - bglBindTexture(GL_TEXTURE_2D, tex); - - bglTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); - bglTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE); - - bglTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB); - bglTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR); - - bglTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_TEXTURE); - bglTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR); - - bglTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE); - bglTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_PREVIOUS_ARB); - bglTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA); - - bglTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2.0f); - - bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT); - bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT); -} - -static inline void polymost_setupglowtexture(int32_t *texunits, int32_t tex) -{ - bglActiveTextureARB(++*texunits); - - bglEnable(GL_TEXTURE_2D); - bglBindTexture(GL_TEXTURE_2D, tex); - - bglTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); - bglTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_INTERPOLATE_ARB); - - bglTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB); - bglTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR); - - bglTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_TEXTURE); - bglTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR); - - bglTexEnvf(GL_TEXTURE_ENV, GL_SOURCE2_RGB_ARB, GL_TEXTURE); - bglTexEnvf(GL_TEXTURE_ENV, GL_OPERAND2_RGB_ARB, GL_ONE_MINUS_SRC_ALPHA); - - bglTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE); - bglTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_PREVIOUS_ARB); - bglTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA); - - bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT); - bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT); -} #include "texcache.h" +extern void polymost_setupglowtexture(int32_t texunits, int32_t tex); +extern void polymost_setupdetailtexture(int32_t texunits, int32_t tex); + #endif #endif diff --git a/polymer/eduke32/build/src/build.c b/polymer/eduke32/build/src/build.c index 893070f61..43d0e50d2 100644 --- a/polymer/eduke32/build/src/build.c +++ b/polymer/eduke32/build/src/build.c @@ -631,7 +631,7 @@ int32_t app_main(int32_t argc, const char **argv) // must be after loadpics(), which inits BUILD's cache i = MAXTILES-1; - if (tilesizx[i]==0 && tilesizy[i]==0) + if (tilesiz[i].x==0 && tilesiz[i].x==0) { static char R[8*16] = { // 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, @@ -648,7 +648,7 @@ int32_t app_main(int32_t argc, const char **argv) walock[i] = 255; // permanent tile picsiz[i] = 5 + (5<<4); - tilesizx[i] = sx; tilesizy[i] = sy; + tilesiz[i].x = sx; tilesiz[i].y = sy; allocache(&waloff[i], sx*sy, &walock[i]); newtile = (char *)waloff[i]; @@ -968,11 +968,11 @@ static void handle_sprite_in_clipboard(int32_t i) int32_t j, k; sprite[i].picnum = temppicnum; - if (tilesizx[temppicnum] <= 0 || tilesizy[temppicnum] <= 0) + if (tilesiz[temppicnum].x <= 0 || tilesiz[temppicnum].y <= 0) { j = 0; for (k=0; k 0 && tilesizy[k] > 0) + if (tilesiz[k].x > 0 && tilesiz[k].y > 0) { j = k; break; @@ -1313,7 +1313,7 @@ void editinput(void) correct_ornamented_sprite(i, hit.wall); } else - sprite[i].cstat |= (tilesizy[sprite[i].picnum]>=32); + sprite[i].cstat |= (tilesiz[sprite[i].picnum].y>=32); correct_sprite_yoffset(i); @@ -2175,7 +2175,7 @@ static int32_t insert_sprite_common(int32_t sectnum, int32_t dax, int32_t day) void correct_sprite_yoffset(int32_t i) { int32_t tileyofs = picanm[sprite[i].picnum].yofs; - int32_t tileysiz = tilesizy[sprite[i].picnum]; + int32_t tileysiz = tilesiz[sprite[i].picnum].y; if (klabs(tileyofs) >= tileysiz) { @@ -6567,7 +6567,7 @@ end_join_sectors: } else handle_sprite_in_clipboard(i); - if (tilesizy[sprite[i].picnum] >= 32) + if (tilesiz[sprite[i].picnum].y >= 32) sprite[i].cstat |= 1; correct_sprite_yoffset(i); @@ -10512,14 +10512,14 @@ static void AlignWalls_(int32_t tilenum, int32_t z0, int32_t z1, int32_t doxpann { int32_t n; - if (tilesizx[tilenum]==0 || tilesizy[tilenum]==0) + if (tilesiz[tilenum].x==0 || tilesiz[tilenum].y==0) return; //do the x alignment if (doxpanning) - wall[w1_pan].xpanning = (uint8_t)((wall[w0_pan].xpanning + (wall[w0_rep].xrepeat<<3))%tilesizx[tilenum]); + wall[w1_pan].xpanning = (uint8_t)((wall[w0_pan].xpanning + (wall[w0_rep].xrepeat<<3))%tilesiz[tilenum].x); - for (n=picsiz[tilenum]>>4; (1<>4; (1<>(n+3))); diff --git a/polymer/eduke32/build/src/defs.c b/polymer/eduke32/build/src/defs.c index f9716985e..cbf8cb4f4 100644 --- a/polymer/eduke32/build/src/defs.c +++ b/polymer/eduke32/build/src/defs.c @@ -171,7 +171,7 @@ static int32_t check_tile(const char *defcmd, int32_t tile, const scriptfile *sc static void tile_from_truecolpic(int32_t tile, const palette_t *picptr, int32_t alphacut) { - const int32_t xsiz = tilesizx[tile], ysiz = tilesizy[tile]; + const int32_t xsiz = tilesiz[tile].x, ysiz = tilesiz[tile].y; int32_t i, j; char *ftd = (char *)Xmalloc(xsiz*ysiz); diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index fc96b5a61..352e128d3 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -205,8 +205,7 @@ static int32_t lastageclock; // necessary (have per-map ART files). static uint8_t *g_bakTileFileNum; static int32_t *g_bakTileFileOffs; -static int16_t *g_bakTileSizX; -static int16_t *g_bakTileSizY; +static vec2_t *g_bakTileSiz; static picanm_t *g_bakPicAnm; // NOTE: picsiz[] is not backed up, but recalculated when necessary. @@ -2280,7 +2279,7 @@ int32_t xb1[MAXWALLSB]; // Polymost uses this as a temp array static int32_t yb1[MAXWALLSB], xb2[MAXWALLSB], yb2[MAXWALLSB]; int32_t rx1[MAXWALLSB], ry1[MAXWALLSB]; static int32_t rx2[MAXWALLSB], ry2[MAXWALLSB]; -int16_t p2[MAXWALLSB], thesector[MAXWALLSB]; +int16_t bunchp2[MAXWALLSB], thesector[MAXWALLSB]; int16_t bunchfirst[MAXWALLSB], bunchlast[MAXWALLSB]; @@ -2570,8 +2569,9 @@ int32_t engine_addtsprite(int16_t z, int16_t sectnum) // static void scansector(int16_t startsectnum) { - int32_t xp1, yp1, xp2=0, yp2=0, tempint; + int32_t tempint; int32_t sectorbordercnt; + vec2_t p1, p2 ={ 0, 0 }; if (startsectnum < 0) return; @@ -2635,73 +2635,71 @@ static void scansector(int16_t startsectnum) if ((z == startwall) || (wall[z-1].point2 != z)) { - xp1 = dmulscale6(y1,cosglobalang,-x1,singlobalang); - yp1 = dmulscale6(x1,cosviewingrangeglobalang,y1,sinviewingrangeglobalang); + p1.x = dmulscale6(y1,cosglobalang,-x1,singlobalang); + p1.y = dmulscale6(x1,cosviewingrangeglobalang,y1,sinviewingrangeglobalang); } else - { - xp1 = xp2; - yp1 = yp2; - } - xp2 = dmulscale6(y2,cosglobalang,-x2,singlobalang); - yp2 = dmulscale6(x2,cosviewingrangeglobalang,y2,sinviewingrangeglobalang); - if ((yp1 < 256) && (yp2 < 256)) goto skipitaddwall; + p1 = p2; + + p2.x = dmulscale6(y2,cosglobalang,-x2,singlobalang); + p2.y = dmulscale6(x2,cosviewingrangeglobalang,y2,sinviewingrangeglobalang); + if ((p1.y < 256) && (p2.y < 256)) goto skipitaddwall; //If wall's NOT facing you - if (dmulscale32(xp1,yp2,-xp2,yp1) >= 0) goto skipitaddwall; + if (dmulscale32(p1.x, p2.y,-p2.x, p1.y) >= 0) goto skipitaddwall; - if (xp1 >= -yp1) + if (p1.x >= -p1.y) { - if ((xp1 > yp1) || (yp1 == 0)) goto skipitaddwall; - xb1[numscans] = halfxdimen + scale(xp1,halfxdimen,yp1); - if (xp1 >= 0) xb1[numscans]++; //Fix for SIGNED divide + if ((p1.x > p1.y) || (p1.y == 0)) goto skipitaddwall; + xb1[numscans] = halfxdimen + scale(p1.x,halfxdimen,p1.y); + if (p1.x >= 0) xb1[numscans]++; //Fix for SIGNED divide if (xb1[numscans] >= xdimen) xb1[numscans] = xdimen-1; - yb1[numscans] = yp1; + yb1[numscans] = p1.y; } else { - if (xp2 < -yp2) goto skipitaddwall; + if (p2.x < -p2.y) goto skipitaddwall; xb1[numscans] = 0; - tempint = yp1-yp2+xp1-xp2; + tempint = (p1.x + p1.y) - (p2.x + p2.y); if (tempint == 0) goto skipitaddwall; - yb1[numscans] = yp1 + scale(yp2-yp1,xp1+yp1,tempint); + yb1[numscans] = p1.y + scale(p2.y-p1.y,p1.x+p1.y,tempint); } if (yb1[numscans] < 256) goto skipitaddwall; - if (xp2 <= yp2) + if (p2.x <= p2.y) { - if ((xp2 < -yp2) || (yp2 == 0)) goto skipitaddwall; - xb2[numscans] = halfxdimen + scale(xp2,halfxdimen,yp2) - 1; - if (xp2 >= 0) xb2[numscans]++; //Fix for SIGNED divide + if ((p2.x < -p2.y) || (p2.y == 0)) goto skipitaddwall; + xb2[numscans] = halfxdimen + scale(p2.x,halfxdimen,p2.y) - 1; + if (p2.x >= 0) xb2[numscans]++; //Fix for SIGNED divide if (xb2[numscans] >= xdimen) xb2[numscans] = xdimen-1; - yb2[numscans] = yp2; + yb2[numscans] = p2.y; } else { - if (xp1 > yp1) goto skipitaddwall; + if (p1.x > p1.y) goto skipitaddwall; xb2[numscans] = xdimen-1; - tempint = xp2-xp1+yp1-yp2; + tempint = (p1.y - p1.x) + (p2.x - p2.y); if (tempint == 0) goto skipitaddwall; - yb2[numscans] = yp1 + scale(yp2-yp1,yp1-xp1,tempint); + yb2[numscans] = p1.y + scale(p2.y-p1.y,p1.y-p1.x,tempint); } if ((yb2[numscans] < 256) || (xb1[numscans] > xb2[numscans])) goto skipitaddwall; //Made it all the way! thesector[numscans] = sectnum; thewall[numscans] = z; - rx1[numscans] = xp1; ry1[numscans] = yp1; - rx2[numscans] = xp2; ry2[numscans] = yp2; - p2[numscans] = numscans+1; + rx1[numscans] = p1.x; ry1[numscans] = p1.y; + rx2[numscans] = p2.x; ry2[numscans] = p2.y; + bunchp2[numscans] = numscans+1; numscans++; skipitaddwall: if ((wall[z].point2 < z) && (scanfirst < numscans)) - p2[numscans-1] = scanfirst, scanfirst = numscans; + bunchp2[numscans-1] = scanfirst, scanfirst = numscans; } for (z=numscansbefore; z= xb1[p2[z]])) + if ((wall[thewall[z]].point2 != thewall[bunchp2[z]]) || (xb2[z] >= xb1[bunchp2[z]])) { - bunchfirst[numbunches++] = p2[z], p2[z] = -1; + bunchfirst[numbunches++] = bunchp2[z], bunchp2[z] = -1; #ifdef YAX_ENABLE if (scansector_retfast) return; @@ -2711,7 +2709,7 @@ skipitaddwall: for (z=bunchfrst; z=0; zz=p2[zz]); + for (zz=bunchfirst[z]; bunchp2[zz]>=0; zz=bunchp2[zz]); bunchlast[z] = zz; } } @@ -2723,38 +2721,38 @@ skipitaddwall: #define WSHELPER_DECL inline //ATTRIBUTE((always_inline)) -static WSHELPER_DECL void tweak_tsizes(int32_t *tsizx, int32_t *tsizy) +static WSHELPER_DECL void tweak_tsizes(vec2_t *tsiz) { - if (pow2long[picsiz[globalpicnum]&15] == *tsizx) - *tsizx = *tsizx-1; + if (pow2long[picsiz[globalpicnum]&15] == tsiz->x) + tsiz->x--; else - *tsizx = -*tsizx; + tsiz->x = -tsiz->x; - if (pow2long[picsiz[globalpicnum]>>4] == *tsizy) - *tsizy = (picsiz[globalpicnum]>>4); + if (pow2long[picsiz[globalpicnum]>>4] == tsiz->y) + tsiz->y = (picsiz[globalpicnum]>>4); else - *tsizy = -*tsizy; + tsiz->y = -tsiz->y; } -static WSHELPER_DECL void calc_bufplc(intptr_t *bufplc, int32_t lw, int32_t tsizx, int32_t tsizy) +static WSHELPER_DECL void calc_bufplc(intptr_t *bufplc, int32_t lw, vec2_t tsiz) { // CAUTION: lw can be negative! int32_t i = lw + globalxpanning; // if (i >= tsizx) { - if (tsizx < 0) - i = (uint32_t)i % -tsizx; + if (tsiz.x < 0) + i = (uint32_t)i % -tsiz.x; else - i &= tsizx; + i &= tsiz.x; } - if (tsizy < 0) - i *= -tsizy; + if (tsiz.y < 0) + i *= -tsiz.y; else - i <<= tsizy; + i <<= tsiz.y; -// Bassert(i >= 0 && i < tilesizx[globalpicnum]*tilesizy[globalpicnum]); +// Bassert(i >= 0 && i < tilesiz[globalpicnum].x*tilesiz[globalpicnum].y); // Address is at the first row of tile storage (which is column-major). *bufplc = waloff[globalpicnum] + i; @@ -2807,24 +2805,25 @@ static void maskwallscan(int32_t x1, int32_t x2, int32_t saturatevplc) { int32_t x; intptr_t p, fpalookup; - int32_t y1ve[4], y2ve[4], tsizx, tsizy; + int32_t y1ve[4], y2ve[4]; #ifdef MULTI_COLUMN_VLINE char bad; int32_t u4, d4, dax, z; #endif + vec2_t tsiz; setgotpic(globalpicnum); if (globalshiftval < 0) return; - tsizx = tilesizx[globalpicnum]; - tsizy = tilesizy[globalpicnum]; - if ((tsizx <= 0) || (tsizy <= 0)) return; + tsiz = tilesiz[globalpicnum]; + + if ((tsiz.x <= 0) || (tsiz.y <= 0)) return; if ((uwall[x1] > ydimen) && (uwall[x2] > ydimen)) return; if ((dwall[x1] < 0) && (dwall[x2] < 0)) return; if (waloff[globalpicnum] == 0) loadtile(globalpicnum); - tweak_tsizes(&tsizx, &tsizy); + tweak_tsizes(&tsiz); if (palookup[globalpal] == NULL) globalpal = 0; @@ -2854,7 +2853,7 @@ static void maskwallscan(int32_t x1, int32_t x2, int32_t saturatevplc) palookupoffse[0] = fpalookup + getpalookupsh(mulscale16(swall[x],globvis)); - calc_bufplc(&bufplce[0], lwall[x], tsizx, tsizy); + calc_bufplc(&bufplce[0], lwall[x], tsiz); calc_vplcinc(&vplce[0], &vince[0], swall, x, y1ve[0]); mvlineasm1(vince[0],palookupoffse[0],y2ve[0]-y1ve[0]-1,vplce[0],bufplce[0],p+ylookup[y1ve[0]]); @@ -2870,7 +2869,7 @@ static void maskwallscan(int32_t x1, int32_t x2, int32_t saturatevplc) y2ve[z] = min(dwall[dax],startdmost[dax+windowx1]-windowy1)-1; if (y2ve[z] < y1ve[z]) { bad += pow2char[z]; continue; } - calc_bufplc(&bufplce[z], lwall[dax], tsizx, tsizy); + calc_bufplc(&bufplce[z], lwall[dax], tsiz); calc_vplcinc(&vplce[z], &vince[z], swall, dax, y1ve[z]); } if (bad == 15) continue; @@ -2927,7 +2926,7 @@ do_mvlineasm1: palookupoffse[0] = fpalookup + getpalookupsh(mulscale16(swall[x],globvis)); - calc_bufplc(&bufplce[0], lwall[x], tsizx, tsizy); + calc_bufplc(&bufplce[0], lwall[x], tsiz); calc_vplcinc(&vplce[0], &vince[0], swall, x, y1ve[0]); #ifdef NONPOW2_YSIZE_ASM @@ -3058,10 +3057,10 @@ static inline int32_t bunchfront(int32_t b1, int32_t b2) if (x1b1 >= x1b2) { - for (i=b2f; xb2[i]= MAXTILES) globalpicnum = 0; setgotpic(globalpicnum); - if ((tilesizx[globalpicnum] <= 0) || (tilesizy[globalpicnum] <= 0)) return 1; + if ((tilesiz[globalpicnum].x <= 0) || (tilesiz[globalpicnum].y <= 0)) return 1; DO_TILE_ANIM(globalpicnum, 0); if (waloff[globalpicnum] == 0) loadtile(globalpicnum); @@ -3813,7 +3812,8 @@ static void wallscan(int32_t x1, int32_t x2, { int32_t x; intptr_t fpalookup; - int32_t y1ve[4], y2ve[4], tsizx, tsizy; + int32_t y1ve[4], y2ve[4]; + vec2_t tsiz; #ifdef MULTI_COLUMN_VLINE char bad; int32_t u4, d4, z; @@ -3830,15 +3830,15 @@ static void wallscan(int32_t x1, int32_t x2, if (x2 >= xdim) x2 = xdim-1; - tsizx = tilesizx[globalpicnum]; - tsizy = tilesizy[globalpicnum]; - if ((tsizx <= 0) || (tsizy <= 0)) return; + tsiz = tilesiz[globalpicnum]; + + if ((tsiz.x <= 0) || (tsiz.y <= 0)) return; if ((uwal[x1] > ydimen) && (uwal[x2] > ydimen)) return; if ((dwal[x1] < 0) && (dwal[x2] < 0)) return; if (waloff[globalpicnum] == 0) loadtile(globalpicnum); - tweak_tsizes(&tsizx, &tsizy); + tweak_tsizes(&tsiz); fpalookup = FP_OFF(palookup[globalpal]); @@ -3862,7 +3862,7 @@ static void wallscan(int32_t x1, int32_t x2, palookupoffse[0] = fpalookup + getpalookupsh(mulscale16(swal[x],globvis)); - calc_bufplc(&bufplce[0], lwal[x], tsizx, tsizy); + calc_bufplc(&bufplce[0], lwal[x], tsiz); calc_vplcinc(&vplce[0], &vince[0], swal, x, y1ve[0]); vlineasm1(vince[0],palookupoffse[0],y2ve[0]-y1ve[0]-1,vplce[0],bufplce[0],x+frameoffset+ylookup[y1ve[0]]); @@ -3876,7 +3876,7 @@ static void wallscan(int32_t x1, int32_t x2, y2ve[z] = min(dwal[x+z],dmost[x+z])-1; if (y2ve[z] < y1ve[z]) { bad += pow2char[z]; continue; } - calc_bufplc(&bufplce[z], lwal[x+z], tsizx, tsizy); + calc_bufplc(&bufplce[z], lwal[x+z], tsiz); calc_vplcinc(&vplce[z], &vince[z], swal, x+z, y1ve[z]); } if (bad == 15) continue; @@ -3933,7 +3933,7 @@ do_vlineasm1: palookupoffse[0] = fpalookup + getpalookupsh(mulscale16(swal[x],globvis)); - calc_bufplc(&bufplce[0], lwal[x], tsizx, tsizy); + calc_bufplc(&bufplce[0], lwal[x], tsiz); calc_vplcinc(&vplce[0], &vince[0], swal, x, y1ve[0]); #ifdef NONPOW2_YSIZE_ASM @@ -3958,6 +3958,8 @@ static void transmaskvline(int32_t x) intptr_t bufplc,p; int32_t y1v, y2v; + vec2_t ntsiz; + if ((x < 0) || (x >= xdimen)) return; y1v = max(uwall[x],startumost[x+windowx1]-windowy1); @@ -3967,7 +3969,9 @@ static void transmaskvline(int32_t x) palookupoffs = FP_OFF(palookup[globalpal]) + getpalookupsh(mulscale16(swall[x],globvis)); - calc_bufplc(&bufplc, lwall[x], -tilesizx[globalpicnum], -tilesizy[globalpicnum]); + ntsiz.x = -tilesiz[globalpicnum].x; + ntsiz.y = -tilesiz[globalpicnum].y; + calc_bufplc(&bufplc, lwall[x], ntsiz); calc_vplcinc(&vplc, &vinc, swall, x, y1v); p = ylookup[y1v]+x+frameoffset; @@ -3992,6 +3996,8 @@ static void transmaskvline2(int32_t x) uintptr_t p; + vec2_t ntsiz; + if ((x < 0) || (x >= xdimen)) return; if (x == xdimen-1) { transmaskvline(x); return; } @@ -4009,8 +4015,11 @@ static void transmaskvline2(int32_t x) setuptvlineasm2(globalshiftval,palookupoffse[0],palookupoffse[1]); - calc_bufplc(&bufplce[0], lwall[x], -tilesizx[globalpicnum], -tilesizy[globalpicnum]); - calc_bufplc(&bufplce[1], lwall[x2], -tilesizx[globalpicnum], -tilesizy[globalpicnum]); + ntsiz.x = -tilesiz[globalpicnum].x; + ntsiz.y = -tilesiz[globalpicnum].y; + + calc_bufplc(&bufplce[0], lwall[x], ntsiz); + calc_bufplc(&bufplce[1], lwall[x2], ntsiz); calc_vplcinc(&vplce[0], &vince[0], swall, x, y1ve[0]); calc_vplcinc(&vplce[1], &vince[1], swall, x2, y1ve[1]); @@ -4057,9 +4066,9 @@ static void transmaskwallscan(int32_t x1, int32_t x2, int32_t saturatevplc) setgotpic(globalpicnum); - Bassert(globalshiftval>=0 || ((tilesizx[globalpicnum] <= 0) || (tilesizy[globalpicnum] <= 0))); + Bassert(globalshiftval>=0 || ((tilesiz[globalpicnum].x <= 0) || (tilesiz[globalpicnum].y <= 0))); // globalshiftval<0 implies following condition - if ((tilesizx[globalpicnum] <= 0) || (tilesizy[globalpicnum] <= 0)) + if ((tilesiz[globalpicnum].x <= 0) || (tilesiz[globalpicnum].y <= 0)) return; if (waloff[globalpicnum] == 0) loadtile(globalpicnum); @@ -4335,7 +4344,7 @@ static void grouscan(int32_t dax1, int32_t dax2, int32_t sectnum, char dastat) DO_TILE_ANIM(globalpicnum, sectnum); setgotpic(globalpicnum); - if ((tilesizx[globalpicnum] <= 0) || (tilesizy[globalpicnum] <= 0)) return; + if ((tilesiz[globalpicnum].x <= 0) || (tilesiz[globalpicnum].y <= 0)) return; if (waloff[globalpicnum] == 0) loadtile(globalpicnum); wal = &wall[sec->wallptr]; @@ -4520,7 +4529,7 @@ static void parascan(int32_t dax1, int32_t dax2, int32_t sectnum, char dastat, i DO_TILE_ANIM(globalpicnum, sectnum); logtilesizy = (picsiz[globalpicnum]>>4); - tsizy = tilesizy[globalpicnum]; + tsizy = tilesiz[globalpicnum].y; if (tsizy==0) return; @@ -4566,7 +4575,7 @@ static void parascan(int32_t dax1, int32_t dax2, int32_t sectnum, char dastat, i x = -1; - for (z=bunchfirst[bunch]; z>=0; z=p2[z]) + for (z=bunchfirst[bunch]; z>=0; z=bunchp2[z]) { wallnum = thewall[z]; nextsectnum = wall[wallnum].nextsector; @@ -4681,7 +4690,7 @@ static void setup_globals_wall1(const walltype *wal, int32_t dapicnum) static void setup_globals_wall2(const walltype *wal, uint8_t secvisibility, int32_t topzref, int32_t botzref) { const int32_t logtilesizy = (picsiz[globalpicnum]>>4); - const int32_t tsizy = tilesizy[globalpicnum]; + const int32_t tsizy = tilesiz[globalpicnum].y; if (tsizy==0) { @@ -4787,7 +4796,7 @@ static void drawalls(int32_t bunch) sectnum = thesector[z]; sec = §or[sectnum]; andwstat1 = 0xff; andwstat2 = 0xff; - for (; z>=0; z=p2[z]) //uplc/dplc calculation + for (; z>=0; z=bunchp2[z]) //uplc/dplc calculation { andwstat1 &= wallmost(uplc,z,sectnum,(uint8_t)0); andwstat2 &= wallmost(dplc,z,sectnum,(uint8_t)1); @@ -4890,7 +4899,7 @@ static void drawalls(int32_t bunch) //DRAW WALLS SECTION! - for (z=bunchfirst[bunch]; z>=0; z=p2[z]) + for (z=bunchfirst[bunch]; z>=0; z=bunchp2[z]) { x1 = xb1[z]; x2 = xb2[z]; if (umost[x2] >= dmost[x2]) @@ -5538,14 +5547,14 @@ static void setup_globals_sprite1(const spritetype *tspr, const sectortype *sec, globalpicnum = tilenum; if ((unsigned)globalpicnum >= MAXTILES) globalpicnum = 0; // sprite panning - globalxpanning = (((256-spriteext[tspr->owner].xpanning)&255) * tilesizx[globalpicnum])>>8; + globalxpanning = (((256-spriteext[tspr->owner].xpanning)&255) * tilesiz[globalpicnum].x)>>8; globalypanning = 0; globvis = globalvisibility; if (sec->visibility != 0) globvis = mulscale4(globvis, (uint8_t)(sec->visibility+16)); logtilesizy = (picsiz[globalpicnum]>>4); - tsizy = tilesizy[globalpicnum]; + tsizy = tilesiz[globalpicnum].y; globalshiftval = logtilesizy; #if !defined CLASSIC_NONPOW2_YSIZE_SPRITES @@ -5674,7 +5683,7 @@ static void drawsprite_classic(int32_t snum) if ((cstat&48) != 48) { - if (spritenum < 0 || tilesizx[tilenum] <= 0 || tilesizy[tilenum] <= 0) + if (spritenum < 0 || tilesiz[tilenum].x <= 0 || tilesiz[tilenum].y <= 0) return; } @@ -5704,12 +5713,12 @@ draw_as_face_sprite: xv = mulscale16(((int32_t)tspr->xrepeat)<<16,xyaspect); - xspan = tilesizx[tilenum]; - yspan = tilesizy[tilenum]; + xspan = tilesiz[tilenum].x; + yspan = tilesiz[tilenum].y; xsiz = mulscale30(siz,xv*xspan); ysiz = mulscale14(siz,tspr->yrepeat*yspan); - if ((tilesizx[tilenum]>>11) >= xsiz || yspan >= (ysiz>>1)) + if ((tilesiz[tilenum].x>>11) >= xsiz || yspan >= (ysiz>>1)) return; //Watch out for divscale overflow x1 = xb-(xsiz>>1); @@ -5858,7 +5867,7 @@ draw_as_face_sprite: if ((cstat&4) > 0) xoff = -xoff; if ((cstat&8) > 0) yoff = -yoff; - xspan = tilesizx[tilenum]; yspan = tilesizy[tilenum]; + xspan = tilesiz[tilenum].x; yspan = tilesiz[tilenum].y; xv = tspr->xrepeat*sintable[(tspr->ang+2560+1536)&2047]; yv = tspr->xrepeat*sintable[(tspr->ang+2048+1536)&2047]; i = (xspan>>1)+xoff; @@ -6124,8 +6133,8 @@ draw_as_face_sprite: if ((cstat&4) > 0) xoff = -xoff; if ((cstat&8) > 0) yoff = -yoff; - xspan = tilesizx[tilenum]; - yspan = tilesizy[tilenum]; + xspan = tilesiz[tilenum].x; + yspan = tilesiz[tilenum].y; //Rotate center point dax = tspr->x-globalposx; @@ -6930,7 +6939,7 @@ static int32_t clippoly(int32_t npoints, int32_t clipstat) { rx2[npoints2] = addscaleclamp(rx1[z], rx1[zz]-rx1[z], s1, s2); ry2[npoints2] = addscaleclamp(ry1[z], ry1[zz]-ry1[z], s1, s2); - if (s1 < 0) p2[splitcnt++] = npoints2; + if (s1 < 0) bunchp2[splitcnt++] = npoints2; xb2[npoints2] = npoints2+1; npoints2++; } @@ -6952,13 +6961,13 @@ static int32_t clippoly(int32_t npoints, int32_t clipstat) for (z=1; z xres-1) cx2 = xres-1; if (cy2 > yres-1) cy2 = yres-1; - xsiz = tilesizx[picnum]; - ysiz = tilesizy[picnum]; + xsiz = tilesiz[picnum].x; + ysiz = tilesiz[picnum].y; if (dastat & RS_TOPLEFT) { @@ -9469,7 +9478,7 @@ killsprite: if ((s->cstat&48) != 32) { int32_t yoff = picanm[s->picnum].yofs + s->yoffset; - int32_t yspan = (tilesizy[s->picnum]*s->yrepeat<<2); + int32_t yspan = (tilesiz[s->picnum].y*s->yrepeat<<2); spritesz[k] -= (yoff*s->yrepeat)<<2; @@ -9527,7 +9536,7 @@ killsprite: _point2d pos; #ifdef USE_OPENGL - curpolygonoffset = 0; + curpolygonoffset = 0.f; #endif pos.x = (float)globalposx; pos.y = (float)globalposy; @@ -9805,7 +9814,7 @@ void drawmapview(int32_t dax, int32_t day, int32_t zoome, int16_t ang) globalpicnum = sec->floorpicnum; if ((unsigned)globalpicnum >= (unsigned)MAXTILES) globalpicnum = 0; setgotpic(globalpicnum); - if ((tilesizx[globalpicnum] <= 0) || (tilesizy[globalpicnum] <= 0)) continue; + if ((tilesiz[globalpicnum].x <= 0) || (tilesiz[globalpicnum].y <= 0)) continue; DO_TILE_ANIM(globalpicnum, s); if (waloff[globalpicnum] == 0) loadtile(globalpicnum); globalbufplc = waloff[globalpicnum]; @@ -9884,7 +9893,7 @@ void drawmapview(int32_t dax, int32_t day, int32_t zoome, int16_t ang) y1 = spr->y; get_floorspr_points(spr, 0, 0, &x1, &x2, &x3, &x4, &y1, &y2, &y3, &y4); - xspan = tilesizx[spr->picnum]; + xspan = tilesiz[spr->picnum].x; xb1[0] = 1; xb1[1] = 2; xb1[2] = 3; xb1[3] = 0; npoints = 4; @@ -9926,7 +9935,7 @@ void drawmapview(int32_t dax, int32_t day, int32_t zoome, int16_t ang) globalpal = spr->pal; // GL needs this, software doesn't if ((unsigned)globalpicnum >= (unsigned)MAXTILES) globalpicnum = 0; setgotpic(globalpicnum); - if ((tilesizx[globalpicnum] <= 0) || (tilesizy[globalpicnum] <= 0)) continue; + if ((tilesiz[globalpicnum].x <= 0) || (tilesiz[globalpicnum].y <= 0)) continue; DO_TILE_ANIM(globalpicnum, s); if (waloff[globalpicnum] == 0) loadtile(globalpicnum); globalbufplc = waloff[globalpicnum]; @@ -10065,8 +10074,7 @@ void E_MapArt_Clear(void) // Restore original per-tile arrays RESTORE_MAPART_ARRAY(tilefilenum, g_bakTileFileNum); RESTORE_MAPART_ARRAY(tilefileoffs, g_bakTileFileOffs); - RESTORE_MAPART_ARRAY(tilesizx, g_bakTileSizX); - RESTORE_MAPART_ARRAY(tilesizy, g_bakTileSizY); + RESTORE_MAPART_ARRAY(tilesiz, g_bakTileSiz); RESTORE_MAPART_ARRAY(picanm, g_bakPicAnm); E_RecalcPicSiz(); @@ -10108,8 +10116,7 @@ void E_MapArt_Setup(const char *filename) // Allocate backup arrays. ALLOC_MAPART_ARRAY(tilefilenum, g_bakTileFileNum); ALLOC_MAPART_ARRAY(tilefileoffs, g_bakTileFileOffs); - ALLOC_MAPART_ARRAY(tilesizx, g_bakTileSizX); - ALLOC_MAPART_ARRAY(tilesizy, g_bakTileSizY); + ALLOC_MAPART_ARRAY(tilesiz, g_bakTileSiz); ALLOC_MAPART_ARRAY(picanm, g_bakPicAnm); for (i=MAXARTFILES_BASE; i 1) && (pow2long[j] > tilesizx[picnum])) + while ((j > 1) && (pow2long[j] > tilesiz[picnum].x)) j--; picsiz[picnum] = j; j = 15; - while ((j > 1) && (pow2long[j] > tilesizy[picnum])) + while ((j > 1) && (pow2long[j] > tilesiz[picnum].y)) j--; picsiz[picnum] |= j<<4; } void set_tilesiz(int32_t picnum, int16_t dasizx, int16_t dasizy) { - tilesizx[picnum] = dasizx; - tilesizy[picnum] = dasizy; + tilesiz[picnum].x = dasizx; + tilesiz[picnum].y = dasizy; set_picsiz(picnum); } @@ -11423,7 +11430,7 @@ int32_t tile_exists(int32_t picnum) if (waloff[picnum] == 0) loadtile(picnum); - return (waloff[picnum] != 0 && tilesizx[picnum] > 0 && tilesizy[picnum] > 0); + return (waloff[picnum] != 0 && tilesiz[picnum].x > 0 && tilesiz[picnum].y > 0); } static const char *E_GetArtFileName(int32_t tilefilei) @@ -11459,6 +11466,7 @@ static int32_t E_ReadArtFile(int32_t tilefilei) const char *fn = E_GetArtFileName(tilefilei); const int32_t permap = (tilefilei >= MAXARTFILES_BASE); // is it a per-map ART file? + int16_t *tilesizx, *tilesizy; if ((fil = kopen4load(fn,0)) != -1) { @@ -11521,8 +11529,10 @@ static int32_t E_ReadArtFile(int32_t tilefilei) Bmemset(&walock[localtilestart], 1, localnumtiles*sizeof(walock[0])); } - kread(fil, &tilesizx[localtilestart], localnumtiles*sizeof(int16_t)); - kread(fil, &tilesizy[localtilestart], localnumtiles*sizeof(int16_t)); + tilesizx = (int16_t *)Xmalloc(localnumtiles * sizeof(int16_t)); + tilesizy = (int16_t *)Xmalloc(localnumtiles * sizeof(int16_t)); + kread(fil, tilesizx, localnumtiles*sizeof(int16_t)); + kread(fil, tilesizy, localnumtiles*sizeof(int16_t)); kread(fil, &picanm[localtilestart], localnumtiles*sizeof(picanm_t)); for (i=localtilestart; i<=localtileend; i++) @@ -11530,8 +11540,8 @@ static int32_t E_ReadArtFile(int32_t tilefilei) EDUKE32_STATIC_ASSERT(sizeof(picanm_t) == 4); EDUKE32_STATIC_ASSERT(PICANM_ANIMTYPE_MASK == 192); - tilesizx[i] = B_LITTLE16(tilesizx[i]); - tilesizy[i] = B_LITTLE16(tilesizy[i]); + tilesiz[i].x = B_LITTLE16(tilesizx[i-localtilestart]); + tilesiz[i].y = B_LITTLE16(tilesizy[i-localtilestart]); // Old on-disk format: anim type is in the 2 highest bits of the lowest byte. picanm[i].sf &= ~192; @@ -11542,10 +11552,13 @@ static int32_t E_ReadArtFile(int32_t tilefilei) picanm[i].sf &= ~PICANM_MISC_MASK; } + DO_FREE_AND_NULL(tilesizx); + DO_FREE_AND_NULL(tilesizy); + offscount = 4+4+4+4+(localnumtiles<<3); for (i=localtilestart; i<=localtileend; i++) { - int32_t dasiz = tilesizx[i]*tilesizy[i]; + int32_t dasiz = tilesiz[i].x * tilesiz[i].y; tilefilenum[i] = tilefilei; tilefileoffs[i] = offscount; @@ -11583,8 +11596,7 @@ int32_t loadpics(const char *filename, int32_t askedsize) Bstrncpyz(artfilename, filename, sizeof(artfilename)); - Bmemset(tilesizx, 0, sizeof(tilesizx)); - Bmemset(tilesizy, 0, sizeof(tilesizy)); + Bmemset(&tilesiz[0], 0, sizeof(vec2_t) * MAXTILES); Bmemset(picanm, 0, sizeof(picanm)); // artsize = 0; @@ -11627,7 +11639,7 @@ void loadtile(int16_t tilenume) int32_t i, dasiz; if ((unsigned)tilenume >= (unsigned)MAXTILES) return; - if ((dasiz = tilesizx[tilenume]*tilesizy[tilenume]) <= 0) return; + if ((dasiz = tilesiz[tilenume].x*tilesiz[tilenume].y) <= 0) return; i = tilefilenum[tilenume]; @@ -11764,8 +11776,8 @@ void copytilepiece(int32_t tilenume1, int32_t sx1, int32_t sy1, int32_t xsiz, in char *ptr1, *ptr2, dat; int32_t xsiz1, ysiz1, xsiz2, ysiz2, i, j, x1, y1, x2, y2; - xsiz1 = tilesizx[tilenume1]; ysiz1 = tilesizy[tilenume1]; - xsiz2 = tilesizx[tilenume2]; ysiz2 = tilesizy[tilenume2]; + xsiz1 = tilesiz[tilenume1].x; ysiz1 = tilesiz[tilenume1].y; + xsiz2 = tilesiz[tilenume2].x; ysiz2 = tilesiz[tilenume2].y; if ((xsiz1 > 0) && (ysiz1 > 0) && (xsiz2 > 0) && (ysiz2 > 0)) { if (waloff[tilenume1] == 0) loadtile(tilenume1); @@ -12003,7 +12015,7 @@ int32_t spriteheightofsptr(const spritetype *spr, int32_t *height, int32_t alsot int32_t hei, zofs=0; const int32_t picnum=spr->picnum, yrepeat=spr->yrepeat; - hei = (tilesizy[picnum]*yrepeat)<<2; + hei = (tilesiz[picnum].y*yrepeat)<<2; *height = hei; if (spr->cstat&128) @@ -12393,7 +12405,7 @@ static void get_wallspr_points(const spritetype *spr, int32_t *x1, int32_t *x2, dax = sintable[ang&2047]*xrepeat; day = sintable[(ang+1536)&2047]*xrepeat; - l = tilesizx[tilenum]; + l = tilesiz[tilenum].x; k = (l>>1)+xoff; *x1 -= mulscale16(dax,k); @@ -12416,8 +12428,8 @@ static void get_floorspr_points(const spritetype *spr, int32_t px, int32_t py, const int32_t cosang = sintable[(spr->ang+512)&2047]; const int32_t sinang = sintable[spr->ang&2047]; - const int32_t xspan=tilesizx[tilenum], xrepeat=spr->xrepeat; - const int32_t yspan=tilesizy[tilenum], yrepeat=spr->yrepeat; + const int32_t xspan=tilesiz[tilenum].x, xrepeat=spr->xrepeat; + const int32_t yspan=tilesiz[tilenum].y, yrepeat=spr->yrepeat; int32_t xoff = picanm[tilenum].xofs + spr->xoffset; int32_t yoff = picanm[tilenum].yofs + spr->yoffset; @@ -12498,7 +12510,7 @@ static int32_t try_facespr_intersect(const spritetype *spr, const vec3_t *refpos const int32_t offy = scale(vy,topu,bot); const int32_t dist = offx*offx + offy*offy; - i = tilesizx[spr->picnum]*spr->xrepeat; + i = tilesiz[spr->picnum].x*spr->xrepeat; if (dist <= mulscale7(i,i)) { const int32_t intx = xs + scale(vx,topt,bot); @@ -12742,11 +12754,11 @@ restart_grand: if (waloff[tilenum]) { // daz-intz > 0 && daz-intz < k - int32_t xtex = mulscale16(ucoefup16, tilesizx[tilenum]); + int32_t xtex = mulscale16(ucoefup16, tilesiz[tilenum].x); int32_t vcoefup16 = 65536-divscale16(daz-intz, k); - int32_t ytex = mulscale16(vcoefup16, tilesizy[tilenum]); + int32_t ytex = mulscale16(vcoefup16, tilesiz[tilenum].y); - const char *texel = (char *)(waloff[tilenum] + tilesizy[tilenum]*xtex + ytex); + const char *texel = (char *)(waloff[tilenum] + tilesiz[tilenum].y*xtex + ytex); if (*texel == 255) continue; } @@ -13215,7 +13227,7 @@ static int32_t clipsprite_initindex(int32_t curidx, spritetype *curspr, int32_t } if ((curspr->cstat&128) != (sector[j].CM_CSTAT&128)) - daz += (((curspr->cstat&128)>>6)-1)*((tilesizy[curspr->picnum]*curspr->yrepeat)<<1); + daz += (((curspr->cstat&128)>>6)-1)*((tilesiz[curspr->picnum].y*curspr->yrepeat)<<1); *clipsectcnt = clipsectnum = 0; // init sectors for this index @@ -14720,7 +14732,7 @@ void rotatesprite_(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum, if ((cx1 > cx2) || (cy1 > cy2)) return; if (z <= 16) return; DO_TILE_ANIM(picnum, 0xc000); - if ((tilesizx[picnum] <= 0) || (tilesizy[picnum] <= 0)) return; + if ((tilesiz[picnum].x <= 0) || (tilesiz[picnum].y <= 0)) return; // Experimental / development bits. ONLY FOR INTERNAL USE! // bit RS_CENTERORIGIN: see dorotspr_handle_bit2 @@ -14766,8 +14778,8 @@ void rotatesprite_(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum, if (per2->sy != per->sy) continue; if (per2->z != per->z) continue; if (per2->a != per->a) continue; - if (tilesizx[per2->picnum] > tilesizx[per->picnum]) continue; - if (tilesizy[per2->picnum] > tilesizy[per->picnum]) continue; + if (tilesiz[per2->picnum].x > tilesiz[per->picnum].x) continue; + if (tilesiz[per2->picnum].y > tilesiz[per->picnum].y) continue; if (per2->cx1 < per->cx1) continue; if (per2->cy1 < per->cy1) continue; if (per2->cx2 > per->cx2) continue; @@ -14790,8 +14802,8 @@ void rotatesprite_(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum, if (per2->cy2 > per->cy2) continue; if ((per2->sx>>16) < (per->sx>>16)) continue; if ((per2->sy>>16) < (per->sy>>16)) continue; - if ((per2->sx>>16)+tilesizx[per2->picnum] > (per->sx>>16)+tilesizx[per->picnum]) continue; - if ((per2->sy>>16)+tilesizy[per2->picnum] > (per->sy>>16)+tilesizy[per->picnum]) continue; + if ((per2->sx>>16)+tilesiz[per2->picnum].x > (per->sx>>16)+tilesiz[per->picnum].x) continue; + if ((per2->sy>>16)+tilesiz[per2->picnum].y > (per->sy>>16)+tilesiz[per->picnum].y) continue; per2->pagesleft = 0; } @@ -15254,7 +15266,7 @@ char getpixel(int32_t x, int32_t y) void setviewtotile(int16_t tilenume, int32_t xsiz, int32_t ysiz) { //DRAWROOMS TO TILE BACKUP&SET CODE - tilesizx[tilenume] = xsiz; tilesizy[tilenume] = ysiz; + tilesiz[tilenume].x = xsiz; tilesiz[tilenume].y = ysiz; bakxsiz[setviewcnt] = xsiz; bakysiz[setviewcnt] = ysiz; bakframeplace[setviewcnt] = frameplace; frameplace = waloff[tilenume]; bakwindowx1[setviewcnt] = windowx1; bakwindowy1[setviewcnt] = windowy1; @@ -15328,7 +15340,7 @@ void squarerotatetile(int16_t tilenume) int32_t siz; //supports square tiles only for rotation part - if ((siz = tilesizx[tilenume]) == tilesizy[tilenume]) + if ((siz = tilesiz[tilenume].x) == tilesiz[tilenume].y) { int32_t i = siz-1; @@ -16617,8 +16629,8 @@ static void drawscreen_drawsprite(int32_t j, int32_t posxe, int32_t posye, int32 if (flooraligned) { - int32_t fx = mulscale10(mulscale6(tilesizx[sprite[j].picnum], sprite[j].xrepeat),zoome) >> 1; - int32_t fy = mulscale10(mulscale6(tilesizy[sprite[j].picnum], sprite[j].yrepeat),zoome) >> 1; + int32_t fx = mulscale10(mulscale6(tilesiz[sprite[j].picnum].x, sprite[j].xrepeat),zoome) >> 1; + int32_t fy = mulscale10(mulscale6(tilesiz[sprite[j].picnum].y, sprite[j].yrepeat),zoome) >> 1; int32_t co[4][2], ii, in; int32_t sinang = sintable[(sprite[j].ang+angofs+1536)&2047]; int32_t cosang = sintable[(sprite[j].ang+angofs+1024)&2047]; @@ -16655,7 +16667,7 @@ static void drawscreen_drawsprite(int32_t j, int32_t posxe, int32_t posye, int32 } else if (wallaligned) { - int32_t fx = mulscale6(tilesizx[sprite[j].picnum], sprite[j].xrepeat); + int32_t fx = mulscale6(tilesiz[sprite[j].picnum].x, sprite[j].xrepeat); int32_t one=(((sprite[j].ang+angofs+256)&512) == 0), no=!one; x2 = mulscale11(sintable[(sprite[j].ang+angofs+2560)&2047],zoome) / 6144; diff --git a/polymer/eduke32/build/src/engine_priv.h b/polymer/eduke32/build/src/engine_priv.h index 8e583d5e4..5073dce44 100644 --- a/polymer/eduke32/build/src/engine_priv.h +++ b/polymer/eduke32/build/src/engine_priv.h @@ -66,7 +66,7 @@ extern int32_t hitallsprites; extern int32_t xb1[MAXWALLSB]; extern int32_t rx1[MAXWALLSB], ry1[MAXWALLSB]; -extern int16_t p2[MAXWALLSB]; +extern int16_t bunchp2[MAXWALLSB]; extern int16_t numscans, numbunches; #ifdef USE_OPENGL diff --git a/polymer/eduke32/build/src/hightile.c b/polymer/eduke32/build/src/hightile.c index a79a040da..d1562da06 100644 --- a/polymer/eduke32/build/src/hightile.c +++ b/polymer/eduke32/build/src/hightile.c @@ -175,7 +175,7 @@ int32_t hicsetsubsttex(int32_t picnum, int32_t palnum, const char *filen, float hicreplc[picnum] = hrn; } - if (tilesizx[picnum]<=0 || tilesizy[picnum]<=0) + if (tilesiz[picnum].x<=0 || tilesiz[picnum].y<=0) { static int32_t first=1; if (first) diff --git a/polymer/eduke32/build/src/mdsprite.c b/polymer/eduke32/build/src/mdsprite.c index b4aaab023..a30254160 100644 --- a/polymer/eduke32/build/src/mdsprite.c +++ b/polymer/eduke32/build/src/mdsprite.c @@ -2027,7 +2027,7 @@ static int32_t md3draw(md3model_t *m, const spritetype *tspr) // dereferenced unconditionally below anyway. const spriteext_t *const sext = ((unsigned)owner < MAXSPRITES+MAXUNIQHUDID) ? &spriteext[owner] : NULL; const uint8_t lpal = ((unsigned)owner < MAXSPRITES) ? sprite[tspr->owner].pal : tspr->pal; - const int32_t sizyrep = tilesizy[tspr->picnum]*tspr->yrepeat; + const int32_t sizyrep = tilesiz[tspr->picnum].y*tspr->yrepeat; if (r_vbos && (m->vbos == NULL)) mdloadvbos(m); @@ -2295,7 +2295,7 @@ static int32_t md3draw(md3model_t *m, const spritetype *tspr) { mdskinmap_t *sk; - polymost_setupdetailtexture(&texunits, i); + polymost_setupdetailtexture(++texunits, i); for (sk = m->skinmap; sk; sk = sk->next) if ((int32_t)sk->palette == DETAILPAL && sk->skinnum == tile2model[Ptile2tile(tspr->picnum,lpal)].skinnum && sk->surfnum == surfi) @@ -2308,12 +2308,11 @@ static int32_t md3draw(md3model_t *m, const spritetype *tspr) } if (r_glowmapping && !(tspr->cstat&CSTAT_SPRITE_MDHACK)) - i = mdloadskin((md2model_t *)m,tile2model[Ptile2tile(tspr->picnum,lpal)].skinnum,GLOWPAL,surfi); - else - i = 0; - - if (i) - polymost_setupglowtexture(&texunits, i); + { + i = mdloadskin((md2model_t *) m, tile2model[Ptile2tile(tspr->picnum, lpal)].skinnum, GLOWPAL, surfi); + if (i) + polymost_setupglowtexture(++texunits, i); + } if (r_vertexarrays && r_vbos) { @@ -3218,7 +3217,7 @@ int32_t voxdraw(voxmodel_t *m, const spritetype *tspr) m0.z *= f; a0.z *= f; k0 = (float)tspr->z; - if (globalorientation&128) k0 += (float)((tilesizy[tspr->picnum]*tspr->yrepeat)<<1); + if (globalorientation&128) k0 += (float)((tilesiz[tspr->picnum].y*tspr->yrepeat)<<1); f = (65536.0*512.0)/((float)xdimen*viewingrange); g = 32.0/((float)xdimen*gxyaspect); diff --git a/polymer/eduke32/build/src/polymer.c b/polymer/eduke32/build/src/polymer.c index 8edb409e0..8576b4c17 100644 --- a/polymer/eduke32/build/src/polymer.c +++ b/polymer/eduke32/build/src/polymer.c @@ -2478,7 +2478,7 @@ static int32_t polymer_updatesector(int16_t sectnum) if (curxpanning) { xpancoef = (float)(pow2long[picsiz[curpicnum] & 15]); - xpancoef *= (float)(curxpanning) / (256.0f * (float)(tilesizx[curpicnum])); + xpancoef *= (float)(curxpanning) / (256.0f * (float)(tilesiz[curpicnum].x)); } else xpancoef = 0; @@ -2486,13 +2486,13 @@ static int32_t polymer_updatesector(int16_t sectnum) if (curypanning) { ypancoef = (float)(pow2long[picsiz[curpicnum] >> 4]); - ypancoef *= (float)(curypanning) / (256.0f * (float)(tilesizy[curpicnum])); + ypancoef *= (float)(curypanning) / (256.0f * (float)(tilesiz[curpicnum].y)); } else ypancoef = 0; - curbuffer[(i*5)+3] = ((float)(tex) / (scalecoef * tilesizx[curpicnum])) + xpancoef; - curbuffer[(i*5)+4] = ((float)(tey) / (scalecoef * tilesizy[curpicnum])) + ypancoef; + curbuffer[(i*5)+3] = ((float)(tex) / (scalecoef * tilesiz[curpicnum].x)) + xpancoef; + curbuffer[(i*5)+4] = ((float)(tey) / (scalecoef * tilesiz[curpicnum].y)) + ypancoef; j--; } @@ -2817,19 +2817,19 @@ static float calc_ypancoef(char curypanning, int16_t curpicnum, int32_t dopancor { float ypancoef = (float)(pow2long[picsiz[curpicnum] >> 4]); - if (ypancoef < tilesizy[curpicnum]) + if (ypancoef < tilesiz[curpicnum].y) ypancoef *= 2; if (dopancor) { int32_t yoffs; - ftol((ypancoef - tilesizy[curpicnum]) * (255.0f / ypancoef), &yoffs); + ftol((ypancoef - tilesiz[curpicnum].y) * (255.0f / ypancoef), &yoffs); if (curypanning > 256 - yoffs) curypanning -= yoffs; } - ypancoef *= (float)curypanning / (256.0f * (float)tilesizy[curpicnum]); + ypancoef *= (float)curypanning / (256.0f * (float)tilesiz[curpicnum].y); return ypancoef; } @@ -2979,8 +2979,8 @@ static void polymer_updatewall(int16_t wallnum) else dist = (float)(xref == 0); - w->wall.buffer[(i * 5) + 3] = ((dist * 8.0f * wal->xrepeat) + wal->xpanning) / (float)(tilesizx[curpicnum]); - w->wall.buffer[(i * 5) + 4] = (-(float)(yref + (w->wall.buffer[(i * 5) + 1] * 16)) / ((tilesizy[curpicnum] * 2048.0f) / (float)(wal->yrepeat))) + ypancoef; + w->wall.buffer[(i * 5) + 3] = ((dist * 8.0f * wal->xrepeat) + wal->xpanning) / (float)(tilesiz[curpicnum].x); + w->wall.buffer[(i * 5) + 4] = (-(float)(yref + (w->wall.buffer[(i * 5) + 1] * 16)) / ((tilesiz[curpicnum].y * 2048.0f) / (float)(wal->yrepeat))) + ypancoef; if (wal->cstat & 256) w->wall.buffer[(i * 5) + 4] = -w->wall.buffer[(i * 5) + 4]; @@ -3041,8 +3041,8 @@ static void polymer_updatewall(int16_t wallnum) else dist = (float)(xref == 0); - w->wall.buffer[(i * 5) + 3] = ((dist * 8.0f * wal->xrepeat) + curxpanning) / (float)(tilesizx[curpicnum]); - w->wall.buffer[(i * 5) + 4] = (-(float)(yref + (w->wall.buffer[(i * 5) + 1] * 16)) / ((tilesizy[curpicnum] * 2048.0f) / (float)(wal->yrepeat))) + ypancoef; + w->wall.buffer[(i * 5) + 3] = ((dist * 8.0f * wal->xrepeat) + curxpanning) / (float)(tilesiz[curpicnum].x); + w->wall.buffer[(i * 5) + 4] = (-(float)(yref + (w->wall.buffer[(i * 5) + 1] * 16)) / ((tilesiz[curpicnum].y * 2048.0f) / (float)(wal->yrepeat))) + ypancoef; if ((!(wal->cstat & 2) && (wal->cstat & 256)) || ((wal->cstat & 2) && (wall[nwallnum].cstat & 256))) @@ -3122,8 +3122,8 @@ static void polymer_updatewall(int16_t wallnum) else dist = (float)(xref == 0); - w->over.buffer[(i * 5) + 3] = ((dist * 8.0f * wal->xrepeat) + wal->xpanning) / (float)(tilesizx[curpicnum]); - w->over.buffer[(i * 5) + 4] = (-(float)(yref + (w->over.buffer[(i * 5) + 1] * 16)) / ((tilesizy[curpicnum] * 2048.0f) / (float)(wal->yrepeat))) + ypancoef; + w->over.buffer[(i * 5) + 3] = ((dist * 8.0f * wal->xrepeat) + wal->xpanning) / (float)(tilesiz[curpicnum].x); + w->over.buffer[(i * 5) + 4] = (-(float)(yref + (w->over.buffer[(i * 5) + 1] * 16)) / ((tilesiz[curpicnum].y * 2048.0f) / (float)(wal->yrepeat))) + ypancoef; if (wal->cstat & 256) w->over.buffer[(i * 5) + 4] = -w->over.buffer[(i * 5) + 4]; @@ -3168,8 +3168,8 @@ static void polymer_updatewall(int16_t wallnum) else dist = (float)(xref == 0); - w->mask.buffer[(i * 5) + 3] = ((dist * 8.0f * wal->xrepeat) + wal->xpanning) / (float)(tilesizx[curpicnum]); - w->mask.buffer[(i * 5) + 4] = (-(float)(yref + (w->mask.buffer[(i * 5) + 1] * 16)) / ((tilesizy[curpicnum] * 2048.0f) / (float)(wal->yrepeat))) + ypancoef; + w->mask.buffer[(i * 5) + 3] = ((dist * 8.0f * wal->xrepeat) + wal->xpanning) / (float)(tilesiz[curpicnum].x); + w->mask.buffer[(i * 5) + 4] = (-(float)(yref + (w->mask.buffer[(i * 5) + 1] * 16)) / ((tilesiz[curpicnum].y * 2048.0f) / (float)(wal->yrepeat))) + ypancoef; if (wal->cstat & 256) w->mask.buffer[(i * 5) + 4] = -w->mask.buffer[(i * 5) + 4]; @@ -3598,8 +3598,8 @@ void polymer_updatesprite(int32_t snum) yratio = (float)(tspr->yrepeat) * 0.25f; - xsize = tilesizx[curpicnum]; - ysize = tilesizy[curpicnum]; + xsize = tilesiz[curpicnum].x; + ysize = tilesiz[curpicnum].y; if (usehightile && h_xsize[curpicnum]) { @@ -4073,21 +4073,21 @@ static void polymer_drawmdsprite(spritetype *tspr) } if (((tspr->cstat>>4) & 3) == 2) { - bglTranslatef(0.0f, 0.0, -(float)(tilesizy[tspr->picnum] * tspr->yrepeat) / 8.0f); + bglTranslatef(0.0f, 0.0, -(float)(tilesiz[tspr->picnum].y * tspr->yrepeat) / 8.0f); bglRotatef(90.0f, 0.0f, 0.0f, 1.0f); } else bglRotatef(-90.0f, 1.0f, 0.0f, 0.0f); if ((tspr->cstat & 128) && (((tspr->cstat>>4) & 3) != 2)) - bglTranslatef(0.0f, 0.0, -(float)(tilesizy[tspr->picnum] * tspr->yrepeat) / 8.0f); + bglTranslatef(0.0f, 0.0, -(float)(tilesiz[tspr->picnum].y * tspr->yrepeat) / 8.0f); // yoffset differs from zadd in that it does not follow cstat&8 y-flipping bglTranslatef(0.0f, 0.0, m->yoffset * 64 * scale * tspr->yrepeat); if (tspr->cstat & 8) { - bglTranslatef(0.0f, 0.0, (float)(tilesizy[tspr->picnum] * tspr->yrepeat) / 4.0f); + bglTranslatef(0.0f, 0.0, (float)(tilesiz[tspr->picnum].y * tspr->yrepeat) / 4.0f); bglScalef(1.0f, 1.0f, -1.0f); } @@ -4533,14 +4533,14 @@ static void polymer_getbuildmaterial(_prmaterial* material, int16_t tile if (pr_artmapping && polymer_eligible_for_artmap(tilenum, pth)) { if (!prartmaps[tilenum]) { char *tilebuffer = (char *)waloff[tilenum]; - char *tempbuffer = (char *)Xmalloc(tilesizx[tilenum] * tilesizy[tilenum]); + char *tempbuffer = (char *)Xmalloc(tilesiz[tilenum].x * tilesiz[tilenum].y); int i, j, k; i = k = 0; - while (i < tilesizy[tilenum]) { + while (i < tilesiz[tilenum].y) { j = 0; - while (j < tilesizx[tilenum]) { - tempbuffer[k] = tilebuffer[(j * tilesizy[tilenum]) + i]; + while (j < tilesiz[tilenum].x) { + tempbuffer[k] = tilebuffer[(j * tilesiz[tilenum].y) + i]; k++; j++; } @@ -4552,8 +4552,8 @@ static void polymer_getbuildmaterial(_prmaterial* material, int16_t tile bglTexImage2D(GL_TEXTURE_2D, 0, GL_R8, - tilesizx[tilenum], - tilesizy[tilenum], + tilesiz[tilenum].x, + tilesiz[tilenum].y, 0, GL_RED, GL_UNSIGNED_BYTE, diff --git a/polymer/eduke32/build/src/polymost.c b/polymer/eduke32/build/src/polymost.c index 1eeac53ec..92870851c 100644 --- a/polymer/eduke32/build/src/polymost.c +++ b/polymer/eduke32/build/src/polymost.c @@ -144,7 +144,7 @@ float gtang = 0.f; static double guo, gux, guy; //Screen-based texture mapping parameters static double gvo, gvx, gvy; static double gdo, gdx, gdy; - +static float fcosglobalang, fsinglobalang, fglobalposx, fglobalposy; static int32_t preview_mouseaim=0; // when 1, displays a CROSSHAIR tsprite at the _real_ aimed position #ifdef USE_OPENGL @@ -184,33 +184,22 @@ static int32_t fullbrightdrawingpass = 0; float curpolygonoffset; // internal polygon offset stack for drawing flat sprites to avoid depth fighting -// Detail mapping cvar int32_t r_detailmapping = 1; - -// Glow mapping cvar int32_t r_glowmapping = 1; - -// Vertex Array model drawing cvar int32_t r_vertexarrays = 1; - -// Vertex Buffer Objects model drawing cvars int32_t r_vbos = 1; int32_t r_vbocount = 64; - -// model animation smoothing cvar int32_t r_animsmoothing = 1; - -// fullbright cvar int32_t r_fullbrights = 1; - -// texture downsizing int32_t r_downsize = 0; int32_t r_downsizevar = -1; // used for fogcalc -float fogresult, fogresult2, fogcol[4], fogtable[4*MAXPALOOKUPS]; +static float fogresult, fogresult2, fogcol[4], fogtable[4*MAXPALOOKUPS]; #endif +static const float float_trans[4] = { 1.0f, 1.0f, 0.66f, 0.33f }; + char ptempbuf[MAXWALLSB<<1]; // polymost ART sky control @@ -236,7 +225,7 @@ void drawline2d(float x0, float y0, float x1, float y1, char col) if (y1 >= fyres) { x1 += (fyres-y1)*dx/dy; y1 = fyres; } else if (y1 < 0) { x1 += (0-y1)*dx/dy; y1 = 0; } - if (fabs(dx) > fabs(dy)) + if (fabsf(dx) > fabsf(dy)) { if (x0 > x1) { f = x0; x0 = x1; x1 = f; f = y0; y0 = y1; y1 = f; } y = (int32_t)(y0*65536.f)+32768; @@ -643,7 +632,7 @@ static float get_projhack_ratio(void) if (glprojectionhacks == 2) { - float abs_shang = fabs(gshang); + float abs_shang = fabsf(gshang); if (abs_shang > 0.7f) return 1.05f + 4.f*(abs_shang-0.7f); } @@ -654,8 +643,6 @@ static float get_projhack_ratio(void) static void resizeglcheck(void) { - float m[4][4]; - #ifdef REDBLUEMODE if (glredbluemode < lastglredbluemode) { @@ -696,6 +683,7 @@ static void resizeglcheck(void) const int32_t ourxdimen = (windowx2-windowx1+1); const float ratio = get_projhack_ratio(); const int32_t fovcorrect = (ratio==0) ? 0 : (int32_t)(ourxdimen*ratio - ourxdimen); + float m[4][4]; glox1 = (float)windowx1; gloy1 = (float)windowy1; glox2 = (float)windowx2; gloy2 = (float)windowy2; @@ -723,8 +711,8 @@ static void resizeglcheck(void) } // NOTE: must not use DAPICNUM for indexing into tile arrays. -static void fixtransparency(int32_t dapicnum, coltype *dapic, int32_t daxsiz, int32_t daysiz, - int32_t daxsiz2, int32_t daysiz2, int32_t dameth) +static void fixtransparency(const int32_t dapicnum, coltype *dapic, int32_t daxsiz, int32_t daysiz, + const int32_t daxsiz2, const int32_t daysiz2, const int32_t dameth) { int32_t y, naxsiz2; int32_t dox = daxsiz2-1, doy = daysiz2-1; @@ -741,7 +729,7 @@ static void fixtransparency(int32_t dapicnum, coltype *dapic, int32_t daxsiz, in for (y=doy; y>=0; y--) { int32_t x; - coltype *wpptr = &dapic[y*daxsiz2+dox]; + coltype * wpptr = &dapic[y*daxsiz2+dox]; for (x=dox; x>=0; x--,wpptr--) { @@ -885,30 +873,34 @@ static int32_t tile_is_sky(int32_t tilenum) # define tile_is_sky(x) (0) #endif -static void texture_setup(int32_t dameth) +static void texture_setup(const int32_t dameth) { + const GLuint clamp_mode = glinfo.clamptoedge ? GL_CLAMP_TO_EDGE : GL_CLAMP; + gltexfiltermode = clamp(gltexfiltermode, 0, NUMGLFILTERMODES-1); bglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, glfiltermodes[gltexfiltermode].mag); bglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, glfiltermodes[gltexfiltermode].min); if (glinfo.maxanisotropy > 1.f) { - if (glanisotropy <= 0 || glanisotropy > glinfo.maxanisotropy) - glanisotropy = (int32_t)glinfo.maxanisotropy; + uint32_t i = (unsigned) Blrintf(glinfo.maxanisotropy); + + if ((unsigned)glanisotropy > i) + glanisotropy = i; + bglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, glanisotropy); } if (!(dameth & DAMETH_CLAMPED)) { - bglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, !tile_is_sky(dapic) ? GL_REPEAT: - (glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP)); + bglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, !tile_is_sky(dapic) ? GL_REPEAT : clamp_mode); bglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); } else { //For sprite textures, clamping looks better than wrapping - bglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP); - bglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP); + bglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, clamp_mode); + bglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, clamp_mode); } } @@ -920,8 +912,8 @@ void gloadtile_art(int32_t dapic, int32_t dapal, int32_t dashade, int32_t dameth static int32_t fullbrightloadingpass = 0; - int32_t tsizx = tilesizx[dapic]; - int32_t tsizy = tilesizy[dapic]; + int32_t tsizx = tilesiz[dapic].x; + int32_t tsizy = tilesiz[dapic].y; if (!glinfo.texnpot) { @@ -1259,7 +1251,7 @@ int32_t gloadtile_hi(int32_t dapic,int32_t dapalnum, int32_t facen, hicreplctyp Bfree(picfil); picfil = 0; - if (tsizx>>r_downsize <= tilesizx[dapic] || tsizy>>r_downsize <= tilesizy[dapic]) + if (tsizx>>r_downsize <= tilesiz[dapic].x || tsizy>>r_downsize <= tilesiz[dapic].y) hicr->flags |= (HICR_NOCOMPRESS + HICR_NOSAVE); if (glinfo.texcompr && glusetexcompr && !(hicr->flags & HICR_NOSAVE)) @@ -1283,15 +1275,15 @@ int32_t gloadtile_hi(int32_t dapic,int32_t dapalnum, int32_t facen, hicreplctyp } else { - pth->scalex = ((float)tsizx) / ((float)tilesizx[dapic]); - pth->scaley = ((float)tsizy) / ((float)tilesizy[dapic]); + pth->scalex = ((float)tsizx) / ((float)tilesiz[dapic].x); + pth->scaley = ((float)tsizy) / ((float)tilesiz[dapic].y); } texture_setup(dameth); - Bfree(pic); pic=NULL; + DO_FREE_AND_NULL(pic); - if (tsizx>>r_downsize <= tilesizx[dapic] || tsizy>>r_downsize <= tilesizy[dapic]) + if (tsizx>>r_downsize <= tilesiz[dapic].x || tsizy>>r_downsize <= tilesiz[dapic].y) hicr->flags |= (HICR_NOCOMPRESS + HICR_NOSAVE); pth->picnum = dapic; @@ -1344,6 +1336,58 @@ int32_t gloadtile_hi(int32_t dapic,int32_t dapalnum, int32_t facen, hicreplctyp return 0; } +void polymost_setupdetailtexture(const int32_t texunits, const int32_t tex) +{ + bglActiveTextureARB(texunits); + + bglEnable(GL_TEXTURE_2D); + bglBindTexture(GL_TEXTURE_2D, tex); + + bglTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); + bglTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE); + + bglTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB); + bglTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR); + + bglTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_TEXTURE); + bglTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR); + + bglTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE); + bglTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_PREVIOUS_ARB); + bglTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA); + + bglTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2.0f); + + bglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + bglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); +} + +void polymost_setupglowtexture(const int32_t texunits, const int32_t tex) +{ + bglActiveTextureARB(texunits); + + bglEnable(GL_TEXTURE_2D); + bglBindTexture(GL_TEXTURE_2D, tex); + + bglTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); + bglTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_INTERPOLATE_ARB); + + bglTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB); + bglTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR); + + bglTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_TEXTURE); + bglTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR); + + bglTexEnvf(GL_TEXTURE_ENV, GL_SOURCE2_RGB_ARB, GL_TEXTURE); + bglTexEnvf(GL_TEXTURE_ENV, GL_OPERAND2_RGB_ARB, GL_ONE_MINUS_SRC_ALPHA); + + bglTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE); + bglTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_PREVIOUS_ARB); + bglTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA); + + bglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + bglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); +} #endif //(dpx,dpy) specifies an n-sided polygon. The polygon must be a convex clockwise loop. @@ -1363,14 +1407,10 @@ static pthtyp *our_texcache_fetch(int32_t dameth) static void drawpoly(float *dpx, float *dpy, int32_t n, int32_t method) { - float ngdx = 0.f, ngdy = 0.f, ngdo = 0.f, ngux = 0.f, nguy = 0.f, nguo = 0.f; - float ngvx = 0.f, ngvy = 0.f, ngvo = 0.f, dp, up, vp, du0 = 0.f, du1 = 0.f, dui, duj; - float f, r, ox, oy, oz, ox2, oy2, oz2, dd[16], uu[16], vv[16], px[16], py[16], uoffs; - int32_t i, j, k, nn, ix0, ix1, tsizx, tsizy; - int32_t dorot; - - // backup of the n for possible redrawing of fullbright - const int32_t n_ = n, method_ = method; + const int32_t method_ = method; + int32_t i, j, k; + vec2_t tsiz; + float f, r, ox, oy, oz, ox2, oy2, oz2, dd[16], uu[16], vv[16], px[16], py[16]; #ifdef YAX_ENABLE if (g_nodraw) return; @@ -1391,8 +1431,8 @@ static void drawpoly(float *dpx, float *dpy, int32_t n, int32_t method) //Load texture (globalpicnum) setgotpic(globalpicnum); - tsizx = tilesizx[globalpicnum]; - tsizy = tilesizy[globalpicnum]; + tsiz = tilesiz[globalpicnum]; + if (palookup[globalpal] == NULL) globalpal = 0; if (!waloff[globalpicnum]) @@ -1401,54 +1441,42 @@ static void drawpoly(float *dpx, float *dpy, int32_t n, int32_t method) if (!waloff[globalpicnum]) { if (getrendermode() < REND_POLYMOST) return; - tsizx = tsizy = 1; method = 1; //Hack to update Z-buffer for invalid mirror textures + tsiz.x = tsiz.y = 1; + method = 1; //Hack to update Z-buffer for invalid mirror textures } } j = 0; - dorot = ((gchang != 1.f) || (gctang != 1.f)); - if (dorot) + for (i=0; i= 3) && (px[j-1] == px[0]) && (py[j-1] == py[0])) j--; if (j < 3) return; - n = j; #ifdef USE_OPENGL if (getrendermode() >= REND_POLYMOST) @@ -1457,6 +1485,9 @@ static void drawpoly(float *dpx, float *dpy, int32_t n, int32_t method) pthtyp *pth, *detailpth, *glowpth; int32_t texunits = GL_TEXTURE0_ARB; int32_t xx, yy; + int32_t k; + + int32_t jj = j; if (skyclamphack) method |= DAMETH_CLAMPED; pth = our_texcache_fetch(method&(~3)); @@ -1471,14 +1502,13 @@ static void drawpoly(float *dpx, float *dpy, int32_t n, int32_t method) return; } - if (r_fullbrights && pth->flags & PTH_HASFULLBRIGHT) - if (indrawroomsandmasks) - { - if (!fullbrightdrawingpass) - fullbrightdrawingpass = 1; - else if (fullbrightdrawingpass == 2) - pth = pth->ofb; - } + if (pth->flags & PTH_HASFULLBRIGHT && r_fullbrights && indrawroomsandmasks) + { + if (!fullbrightdrawingpass) + fullbrightdrawingpass = 1; + else if (fullbrightdrawingpass == 2) + pth = pth->ofb; + } // If we aren't rendmode 3, we're in Polymer, which means this code is // used for rotatesprite only. Polymer handles all the material stuff, @@ -1509,7 +1539,7 @@ static void drawpoly(float *dpx, float *dpy, int32_t n, int32_t method) if (detailpth && detailpth->hicr && (detailpth->hicr->palnum == DETAILPAL)) { - polymost_setupdetailtexture(&texunits, detailpth ? detailpth->glpic : 0); + polymost_setupdetailtexture(++texunits, detailpth ? detailpth->glpic : 0); f = detailpth ? detailpth->hicr->xscale : 1.f; @@ -1531,26 +1561,26 @@ static void drawpoly(float *dpx, float *dpy, int32_t n, int32_t method) glowpth = texcache_fetch(globalpicnum, GLOWPAL, 0, method&(~3)); if (glowpth && glowpth->hicr && (glowpth->hicr->palnum == GLOWPAL)) - polymost_setupglowtexture(&texunits, glowpth ? glowpth->glpic : 0); + polymost_setupglowtexture(++texunits, glowpth ? glowpth->glpic : 0); if (pth && (pth->flags & PTH_HIGHTILE)) { hackscx = pth->scalex; hackscy = pth->scaley; - tsizx = pth->sizx; - tsizy = pth->sizy; + tsiz.x = pth->sizx; + tsiz.y = pth->sizy; } - xx = tsizx; - yy = tsizy; + xx = tsiz.x; + yy = tsiz.y; if (!glinfo.texnpot) { - for (xx=1; xx=0; i--) - { - dd[i] = px[i]*gdx + py[i]*gdy + gdo; - uu[i] = px[i]*gux + py[i]*guy + guo; - vv[i] = px[i]*gvx + py[i]*gvy + gvo; - } - } - { float pc[4]; @@ -1596,24 +1616,8 @@ static void drawpoly(float *dpx, float *dpy, int32_t n, int32_t method) #endif pc[0] = pc[1] = pc[2] = getshadefactor(globalshade); - switch (method&3) - { - default: - pc[3] = 1.0f; - break; - case 0: - case 1: - case 2: - case 3: - { - const float f[4] = { 1.0f, 1.0f, 0.66f, 0.33f }; - pc[3] = f[method&3]; - break; - } - } - // spriteext full alpha control - pc[3] *= 1.0f - alpha; + pc[3] = float_trans[method&3] * (1.f - alpha); // tinting happens only to hightile textures, and only if the texture we're // rendering isn't for the same palette as what we asked for @@ -1636,40 +1640,36 @@ static void drawpoly(float *dpx, float *dpy, int32_t n, int32_t method) } //Hack for walls&masked walls which use textures that are not a power of 2 - if ((pow2xsplit) && (tsizx != xx)) + if ((pow2xsplit) && (tsiz.x != xx)) { - if (!dorot) - { - ngdx = gdx; ngdy = gdy; ngdo = gdo+(ngdx+ngdy)*0.5f; - ngux = gux; nguy = guy; nguo = guo+(ngux+nguy)*0.5f; - ngvx = gvx; ngvy = gvy; ngvo = gvo+(ngvx+ngvy)*0.5f; - } - else - { - ox = py[1]-py[2]; oy = py[2]-py[0]; oz = py[0]-py[1]; - r = 1.f / (ox*px[0] + oy*px[1] + oz*px[2]); - ngdx = (ox*dd[0] + oy*dd[1] + oz*dd[2])*r; - ngux = (ox*uu[0] + oy*uu[1] + oz*uu[2])*r; - ngvx = (ox*vv[0] + oy*vv[1] + oz*vv[2])*r; - ox = px[2]-px[1]; oy = px[0]-px[2]; oz = px[1]-px[0]; - ngdy = (ox*dd[0] + oy*dd[1] + oz*dd[2])*r; - nguy = (ox*uu[0] + oy*uu[1] + oz*uu[2])*r; - ngvy = (ox*vv[0] + oy*vv[1] + oz*vv[2])*r; - ox = px[0]-0.5f; oy = py[0]-0.5f; //.5 centers texture nicely - ngdo = dd[0] - ox*ngdx - oy*ngdy; - nguo = uu[0] - ox*ngux - oy*nguy; - ngvo = vv[0] - ox*ngvx - oy*ngvy; - } + int32_t nn, ix0, ix1; + + float ngdx = 0.f, ngdy = 0.f, ngdo = 0.f, ngux = 0.f, nguy = 0.f, nguo = 0.f, uoffs; + float ngvx = 0.f, ngvy = 0.f, ngvo = 0.f, dp, up, vp, du0 = 0.f, du1 = 0.f, dui, duj; + + ox = py[1]-py[2]; oy = py[2]-py[0]; oz = py[0]-py[1]; + r = 1.f / (ox*px[0] + oy*px[1] + oz*px[2]); + ngdx = (ox*dd[0] + oy*dd[1] + oz*dd[2])*r; + ngux = (ox*uu[0] + oy*uu[1] + oz*uu[2])*r; + ngvx = (ox*vv[0] + oy*vv[1] + oz*vv[2])*r; + ox = px[2]-px[1]; oy = px[0]-px[2]; oz = px[1]-px[0]; + ngdy = (ox*dd[0] + oy*dd[1] + oz*dd[2])*r; + nguy = (ox*uu[0] + oy*uu[1] + oz*uu[2])*r; + ngvy = (ox*vv[0] + oy*vv[1] + oz*vv[2])*r; + ox = px[0]-0.5f; oy = py[0]-0.5f; //.5 centers texture nicely + ngdo = dd[0] - ox*ngdx - oy*ngdy; + nguo = uu[0] - ox*ngux - oy*nguy; + ngvo = vv[0] - ox*ngvx - oy*ngvy; ngux *= hackscx; nguy *= hackscx; nguo *= hackscx; ngvx *= hackscy; ngvy *= hackscy; ngvo *= hackscy; - uoffs = ((float)(xx-tsizx)*0.5f); + uoffs = ((float)(xx-tsiz.x)*0.5f); ngux -= ngdx*uoffs; nguy -= ngdy*uoffs; nguo -= ngdo*uoffs; //Find min&max u coordinates (du0...du1) - for (i=0; i du1) du1 = f; } - f = 1.0f/tsizx; + f = 1.0f/tsiz.x; ix0 = Blrintf(floorf(du0*f)); ix1 = Blrintf(floorf(du1*f)); for (; ix0<=ix1; ix0++) { - du0 = (float)(ix0*tsizx); // + uoffs; - du1 = (float)((ix0+1)*tsizx); // + uoffs; + du0 = (float)(ix0*tsiz.x); // + uoffs; + du1 = (float)((ix0+1)*tsiz.x); // + uoffs; i = 0; nn = 0; duj = (px[i]*ngux + py[i]*nguy + nguo) / (px[i]*ngdx + py[i]*ngdy + ngdo); do { - j = i+1; if (j == n) j = 0; + j = i+1; if (j == jj) j = 0; dui = duj; duj = (px[j]*ngux + py[j]*nguy + nguo) / (px[j]*ngdx + py[j]*ngdy + ngdo); @@ -1761,7 +1761,7 @@ static void drawpoly(float *dpx, float *dpy, int32_t n, int32_t method) { ox2 *= hackscx; oy2 *= hackscy; bglBegin(GL_TRIANGLE_FAN); - for (i=0; i GL_TEXTURE0_ARB) @@ -1805,7 +1805,7 @@ static void drawpoly(float *dpx, float *dpy, int32_t n, int32_t method) fullbrightdrawingpass = 2; globalshade = -128; // fullbright bglDisable(GL_FOG); - drawpoly(dpx, dpy, n_, method_); // draw them afterwards, then. :) + drawpoly(dpx, dpy, n, method_); // draw them afterwards, then. :) bglEnable(GL_FOG); globalshade = shadeforfullbrightpass; fullbrightdrawingpass = 0; @@ -1834,88 +1834,11 @@ static void vsp_finalize_init(vsptyp *vsp, int32_t vcnt) vsp[VSPMAX-1].n = vcnt; vsp[vcnt].p = VSPMAX-1; } -/*Init viewport boundary (must be 4 point convex loop): -// (px[0],py[0]).----.(px[1],py[1]) -// / \ -// / \ -// (px[3],py[3]).--------------.(px[2],py[2]) -*/ - -void initmosts(float *px, float *py, int32_t n) -{ - int32_t i, j, k, imin, vcnt; - - vcnt = 1; //0 is dummy solid node - - if (n < 3) return; - imin = (px[1] < px[0]); - for (i=n-1; i>=2; i--) if (px[i] < px[imin]) imin = i; - - - vsp[vcnt].x = px[imin]; - vsp[vcnt].cy[0] = vsp[vcnt].fy[0] = py[imin]; - vcnt++; - i = imin+1; if (i >= n) i = 0; - j = imin-1; if (j < 0) j = n-1; - do - { - if (px[i] < px[j]) - { - if ((vcnt > 1) && (px[i] <= vsp[vcnt-1].x)) vcnt--; - vsp[vcnt].x = px[i]; - vsp[vcnt].cy[0] = py[i]; - k = j+1; if (k >= n) k = 0; - //(px[k],py[k]) - //(px[i],?) - //(px[j],py[j]) - vsp[vcnt].fy[0] = (px[i]-px[k])*(py[j]-py[k])/(px[j]-px[k]) + py[k]; - vcnt++; - i++; if (i >= n) i = 0; - } - else if (px[j] < px[i]) - { - if ((vcnt > 1) && (px[j] <= vsp[vcnt-1].x)) vcnt--; - vsp[vcnt].x = px[j]; - vsp[vcnt].fy[0] = py[j]; - k = i-1; if (k < 0) k = n-1; - //(px[k],py[k]) - //(px[j],?) - //(px[i],py[i]) - vsp[vcnt].cy[0] = (px[j]-px[k])*(py[i]-py[k])/(px[i]-px[k]) + py[k]; - vcnt++; - j--; if (j < 0) j = n-1; - } - else - { - if ((vcnt > 1) && (px[i] <= vsp[vcnt-1].x)) vcnt--; - vsp[vcnt].x = px[i]; - vsp[vcnt].cy[0] = py[i]; - vsp[vcnt].fy[0] = py[j]; - vcnt++; - i++; if (i >= n) i = 0; if (i == j) break; - j--; if (j < 0) j = n-1; - } - } - while (i != j); - if (px[i] > vsp[vcnt-1].x) - { - vsp[vcnt].x = px[i]; - vsp[vcnt].cy[0] = vsp[vcnt].fy[0] = py[i]; - vcnt++; - } - - vsp_finalize_init(vsp, vcnt); - gtag = vcnt; -} - static inline void vsdel(vsptyp *vsp, int32_t i) { - int32_t pi, ni; //Delete i - pi = vsp[i].p; - ni = vsp[i].n; - vsp[ni].p = pi; - vsp[pi].n = ni; + vsp[vsp[i].n].p = vsp[i].p; + vsp[vsp[i].p].n = vsp[i].n; //Add i to empty list vsp[i].n = vsp[VSPMAX-1].n; @@ -1926,9 +1849,8 @@ static inline void vsdel(vsptyp *vsp, int32_t i) static inline int32_t vsinsaft(vsptyp *vsp, int32_t i) { - int32_t r; //i = next element from empty list - r = vsp[VSPMAX-1].n; + int32_t r = vsp[VSPMAX-1].n; vsp[vsp[r].n].p = VSPMAX-1; vsp[VSPMAX-1].n = vsp[r].n; @@ -1941,40 +1863,29 @@ static inline int32_t vsinsaft(vsptyp *vsp, int32_t i) return(r); } -static inline int32_t testvisiblemost(float x0, float x1) -{ - int32_t i, newi; - - for (i=vsp[0].n; i; i=newi) - { - newi = vsp[i].n; - if ((x0 < vsp[newi].x) && (vsp[i].x < x1) && (vsp[i].ctag >= 0)) return(1); - } - return(0); -} - static int32_t domostpolymethod = 0; void domost(float x0, float y0, float x1, float y1) { float dpx[4], dpy[4]; - float d, f, n, t, slop, dx, dx0, dx1, nx, nx0, ny0, nx1, ny1; + float d, n, t, slop, dx, dx0, dx1, nx, nx0, ny0, nx1, ny1; float spx[4], /*spy[4],*/ cy[2], cv[2]; - int32_t i, j, k, z, ni, vcnt = 0, scnt, newi, dir, spt[4]; + int32_t i, j, k, z, ni, vcnt = 0, scnt, newi, dir = 0, spt[4]; alpha = 0.f; if (x0 < x1) { dir = 1; //clip dmost (floor) - y0 -= .01f; y1 -= .01f; + y0 -= .01f; + y1 -= .01f; } else { if (x0 == x1) return; swapfloat(&x0, &x1); swapfloat(&y0, &y1); - dir = 0; //clip umost (ceiling) + //dir = 0; //clip umost (ceiling) //y0 += .01; y1 += .01; //necessary? } @@ -1993,7 +1904,7 @@ void domost(float x0, float y0, float x1, float y1) if ((x0 > nx0) && (x0 < nx1)) { t = (x0-nx0)*cv[dir] - (y0-cy[dir])*dx; - if (((!dir) && (t < 0)) || ((dir) && (t > 0))) + if (((!dir) && (t < 0.f)) || ((dir) && (t > 0.f))) { spx[scnt] = x0; /*spy[scnt] = y0;*/ spt[scnt] = -1; scnt++; } } @@ -2002,7 +1913,8 @@ void domost(float x0, float y0, float x1, float y1) { d = (y0-y1)*dx - (x0-x1)*cv[j]; n = (y0-cy[j])*dx - (x0-nx0)*cv[j]; - if ((fabs(n) <= fabs(d)) && (d *n >= 0) && (d != 0)) + + if ((fabsf(d) > fabsf(n)) && (d * n >= 0.f)) { t = n/d; nx = (x1-x0)*t + x0; if ((nx > nx0) && (nx < nx1)) @@ -2083,27 +1995,31 @@ void domost(float x0, float y0, float x1, float y1) case 2: dpx[2] = dx0; dpy[2] = ny0; + vsp[i].cy[0] = ny0; vsp[i].ctag = gtag; drawpoly(dpx,dpy,3,domostpolymethod); - vsp[i].cy[0] = ny0; vsp[i].ctag = gtag; continue; + break; case 3: case 6: dpx[2] = dx1; dpy[2] = ny1; - drawpoly(dpx,dpy,3,domostpolymethod); - vsp[i].cy[1] = ny1; vsp[i].ctag = gtag; continue; + vsp[i].cy[1] = ny1; vsp[i].ctag = gtag; + drawpoly(dpx, dpy, 3, domostpolymethod); + break; case 4: case 5: case 7: dpx[2] = dx1; dpx[3] = dx0; dpy[2] = ny1; dpy[3] = ny0; - drawpoly(dpx,dpy,4,domostpolymethod); - vsp[i].cy[0] = ny0; vsp[i].cy[1] = ny1; vsp[i].ctag = gtag; continue; + vsp[i].cy[0] = ny0; vsp[i].cy[1] = ny1; vsp[i].ctag = gtag; + drawpoly(dpx, dpy, 4, domostpolymethod); + break; case 8: dpx[2] = dx1; dpy[2] = vsp[i].fy[1]; - dpx[3] = dx0; dpy[3] = vsp[i].fy[0]; drawpoly(dpx,dpy,4,domostpolymethod); - vsp[i].ctag = vsp[i].ftag = -1; continue; + dpx[3] = dx0; dpy[3] = vsp[i].fy[0]; + vsp[i].ctag = vsp[i].ftag = -1; + drawpoly(dpx,dpy,4,domostpolymethod); default: - continue; + break; } } else @@ -2114,28 +2030,31 @@ void domost(float x0, float y0, float x1, float y1) case 6: dpx[2] = dx0; dpy[0] = ny0; dpy[1] = vsp[i].fy[1]; dpy[2] = vsp[i].fy[0]; + vsp[i].fy[0] = ny0; vsp[i].ftag = gtag; drawpoly(dpx,dpy,3,domostpolymethod); - vsp[i].fy[0] = ny0; vsp[i].ftag = gtag; continue; + break; case 5: case 2: dpx[2] = dx1; dpy[0] = vsp[i].fy[0]; dpy[1] = ny1; dpy[2] = vsp[i].fy[1]; + vsp[i].fy[1] = ny1; vsp[i].ftag = gtag; drawpoly(dpx,dpy,3,domostpolymethod); - vsp[i].fy[1] = ny1; vsp[i].ftag = gtag; continue; + break; case 4: case 3: case 1: dpx[2] = dx1; dpx[3] = dx0; dpy[0] = ny0; dpy[1] = ny1; dpy[2] = vsp[i].fy[1]; dpy[3] = vsp[i].fy[0]; + vsp[i].fy[0] = ny0; vsp[i].fy[1] = ny1; vsp[i].ftag = gtag; drawpoly(dpx,dpy,4,domostpolymethod); - vsp[i].fy[0] = ny0; vsp[i].fy[1] = ny1; vsp[i].ftag = gtag; continue; + break; case 0: dpx[2] = dx1; dpx[3] = dx0; dpy[0] = vsp[i].cy[0]; dpy[1] = vsp[i].cy[1]; dpy[2] = vsp[i].fy[1]; dpy[3] = vsp[i].fy[0]; + vsp[i].ctag = vsp[i].ftag = -1; drawpoly(dpx,dpy,4,domostpolymethod); - vsp[i].ctag = vsp[i].ftag = -1; continue; default: - continue; + break; } } } @@ -2146,6 +2065,7 @@ void domost(float x0, float y0, float x1, float y1) //Combine neighboring vertical strips with matching collinear top&bottom edges //This prevents x-splits from propagating through the entire scan i = vsp[0].n; + while (i) { ni = vsp[i].n; @@ -2186,7 +2106,7 @@ static void polymost_internal_nonparallaxed(float nx0, float ny0, float nx1, flo //(cosglobalang/ 16384*(sx-ghalfx) + 0*(sy-ghoriz) + (sinviewingrangeglobalang/16384)*ghalfx)*d + globalposy = v*16 //( 0*(sx-ghalfx) + 1*(sy-ghoriz) + ( 0)*ghalfx)*d + globalposz/16 = (sec->floorz/16) if (!(globalorientation&64)) - { ft[0] = (float)globalposx; ft[1] = (float)globalposy; ft[2] = (float)cosglobalang; ft[3] = (float)singlobalang; } + { ft[0] = fglobalposx; ft[1] = fglobalposy; ft[2] = fcosglobalang; ft[3] = fsinglobalang; } else { float r; @@ -2194,8 +2114,8 @@ static void polymost_internal_nonparallaxed(float nx0, float ny0, float nx1, flo fx = (float)(wall[wall[sec->wallptr].point2].x-wall[sec->wallptr].x); fy = (float)(wall[wall[sec->wallptr].point2].y-wall[sec->wallptr].y); r = 1.f/Bsqrtf(fx*fx+fy*fy); fx *= r; fy *= r; - ft[2] = cosglobalang*fx + singlobalang*fy; - ft[3] = singlobalang*fx - cosglobalang*fy; + ft[2] = fcosglobalang*fx + fsinglobalang*fy; + ft[3] = fsinglobalang*fx - fcosglobalang*fy; ft[0] = ((float)(globalposx-wall[sec->wallptr].x))*fx + ((float)(globalposy-wall[sec->wallptr].y))*fy; ft[1] = ((float)(globalposy-wall[sec->wallptr].y))*fx - ((float)(globalposx-wall[sec->wallptr].x))*fy; if (!(globalorientation&4)) globalorientation ^= 32; else globalorientation ^= 16; @@ -2250,8 +2170,8 @@ static void polymost_internal_nonparallaxed(float nx0, float ny0, float nx1, flo //Pick some point guaranteed to be not collinear to the 1st two points ox = nx0 + (ny1-ny0); oy = ny0 + (nx0-nx1); - ox2 = (oy-(float)globalposy)*gcosang - (ox-(float)globalposx)*gsinang ; - oy2 = (ox-(float)globalposx)*gcosang2 + (oy-(float)globalposy)*gsinang2; + ox2 = (oy-fglobalposy)*gcosang - (ox-fglobalposx)*gsinang ; + oy2 = (ox-fglobalposx)*gcosang2 + (oy-fglobalposy)*gsinang2; oy2 = 1.f/oy2; px[2] = ghalfx*ox2*oy2 + ghalfx; oy2 *= gyxscale; py[2] = oy2 + (double)ghoriz; @@ -2265,7 +2185,7 @@ static void polymost_internal_nonparallaxed(float nx0, float ny0, float nx1, flo py[0] = cf_y0; py[1] = cf_y1; - py[2] = (double)(global_getzofslope_func(sectnum,(int32_t)ox,(int32_t)oy)-globalposz)*oy2 + ghoriz; + py[2] = (double)((float)(global_getzofslope_func(sectnum,Blrintf(ox),Blrintf(oy))-globalposz)*oy2 + ghoriz); ox = py[1]-py[2]; oy = py[2]-py[0]; oz = py[0]-py[1]; r = 1.0 / (ox*px[0] + oy*px[1] + oz*px[2]); @@ -2325,17 +2245,17 @@ static void calc_ypanning(int32_t refposz, float ryp0, float ryp1, t0 = ((float)(refposz-globalposz))*ryp0 + ghoriz; t1 = ((float)(refposz-globalposz))*ryp1 + ghoriz; t = ((gdx*x0 + gdo) * (float)yrepeat) / ((x1-x0) * ryp0 * 2048.f); - i = (1<<(picsiz[globalpicnum]>>4)); if (i < tilesizy[globalpicnum]) i <<= 1; + i = (1<<(picsiz[globalpicnum]>>4)); if (i < tilesiz[globalpicnum].y) i <<= 1; #ifdef NEW_MAP_FORMAT if (g_loadedMapVersion >= 10) - i = tilesizy[globalpicnum]; + i = tilesiz[globalpicnum].y; else #endif if (polymost_is_npotmode()) { - t *= (float)tilesizy[globalpicnum] / i; - i = tilesizy[globalpicnum]; + t *= (float)tilesiz[globalpicnum].y / i; + i = tilesiz[globalpicnum].y; } else if (dopancor) { @@ -2343,19 +2263,29 @@ static void calc_ypanning(int32_t refposz, float ryp0, float ryp1, // cases, but failing in the general case. int32_t yoffs; - ftol((i-tilesizy[globalpicnum])*(255.f/i), &yoffs); + ftol((i-tilesiz[globalpicnum].y)*(255.f/i), &yoffs); if (ypan > 256-yoffs) ypan -= yoffs; } - fy = (float) (ypan * i) / 256.f; -// fy = (float)ypan * ((float)i) / 256.0; + fy = (float) (ypan * i) * (1.f/256.f); gvx = (t0-t1)*t; gvy = (x1-x0)*t; gvo = -gvx*x0 - gvy*t0 + fy*gdo; gvx += fy*gdx; gvy += fy*gdy; } +static inline int32_t testvisiblemost(float x0, float x1) +{ + int32_t i, newi; + + for (i=vsp[0].n; i; i=newi) + { + newi = vsp[i].n; + if ((x0 < vsp[newi].x) && (vsp[i].x < x1) && (vsp[i].ctag >= 0)) return(1); + } + return(0); +} static void polymost_drawalls(int32_t bunch) { @@ -2375,7 +2305,7 @@ static void polymost_drawalls(int32_t bunch) sectnum = thesector[bunchfirst[bunch]]; sec = §or[sectnum]; //DRAW WALLS SECTION! - for (z=bunchfirst[bunch]; z>=0; z=p2[z]) + for (z=bunchfirst[bunch]; z>=0; z=bunchp2[z]) { wallnum = thewall[z]; wal = &wall[wallnum]; wal2 = &wall[wal->point2]; nextsectnum = wal->nextsector; @@ -2471,14 +2401,14 @@ static void polymost_drawalls(int32_t bunch) dd[0] = (float)xdimen*.0000001f; //Adjust sky depth based on screen size! t = (float)((1<<(picsiz[globalpicnum]&15))<>1)/*+g_psky.yoffs*/)) - vv[1]*ghoriz; - i = (1<<(picsiz[globalpicnum]>>4)); if (i != tilesizy[globalpicnum]) i += i; + vv[0] = dd[0]*((float)((tilesiz[globalpicnum].y>>1)/*+g_psky.yoffs*/)) - vv[1]*ghoriz; + i = (1<<(picsiz[globalpicnum]>>4)); if (i != tilesiz[globalpicnum].y) i += i; //Hack to draw black rectangle below sky when looking down... - gdx = 0; gdy = gxyaspect / 262144.f; gdo = -ghoriz*gdy; + gdx = 0; gdy = gxyaspect * (1.f/262144.f); gdo = -ghoriz*gdy; gux = 0; guy = 0; guo = 0; - gvx = 0; gvy = (float)(tilesizy[globalpicnum]-1)*gdy; gvo = (float)(tilesizy[globalpicnum-1])*gdo; - oy = ((float)tilesizy[globalpicnum]*dd[0]-vv[0])/vv[1]; + gvx = 0; gvy = (float)(tilesiz[globalpicnum].y-1)*gdy; gvo = (float)(tilesiz[globalpicnum].y-1)*gdo; + oy = ((float)tilesiz[globalpicnum].y*dd[0]-vv[0])/vv[1]; if ((oy > fy0) && (oy > fy1)) domost(x0,oy,x1,oy); else if ((oy > fy0) != (oy > fy1)) { @@ -2503,7 +2433,7 @@ static void polymost_drawalls(int32_t bunch) gvx = 0; gvy = vv[1]; gvo = vv[0]; i = globalpicnum; r = (fy1-fy0)/(x1-x0); //slope of line - oy = ((float)viewingrange)/(ghalfx*256.0); oz = 1/oy; + oy = ((float)viewingrange)/(ghalfx*256.f); oz = 1.f/oy; y = ((((int32_t)((x0-ghalfx)*oy))+globalang)>>(11-dapskybits)); fx = x0; @@ -2605,8 +2535,8 @@ static void polymost_drawalls(int32_t bunch) //ceiling of skybox ft[0] = 512/16; ft[1] = 512/-16; - ft[2] = ((float)cosglobalang)*(1.f/2147483648.f); - ft[3] = ((float)singlobalang)*(1.f/2147483648.f); + ft[2] = fcosglobalang*(1.f/2147483648.f); + ft[3] = fsinglobalang*(1.f/2147483648.f); gdx = 0; gdy = gxyaspect*(1.f/4194304.f); gdo = -ghoriz*gdy; @@ -2674,8 +2604,8 @@ static void polymost_drawalls(int32_t bunch) drawingskybox = 5; //floor/6th texture/index 5 of skybox #endif ft[0] = 512/16; ft[1] = -512/-16; - ft[2] = ((float)cosglobalang)*(1.f/2147483648.f); - ft[3] = ((float)singlobalang)*(1.f/2147483648.f); + ft[2] = fcosglobalang*(1.f/2147483648.f); + ft[3] = fsinglobalang*(1.f/2147483648.f); gdx = 0; gdy = gxyaspect*(-1.f/4194304.f); gdo = -ghoriz*gdy; @@ -2745,8 +2675,8 @@ static void polymost_drawalls(int32_t bunch) dd[0] = (float)xdimen*.0000001f; //Adjust sky depth based on screen size! t = (float)((1<<(picsiz[globalpicnum]&15))<>1)/*+g_psky.yoffs*/)) - vv[1]*ghoriz; - i = (1<<(picsiz[globalpicnum]>>4)); if (i != tilesizy[globalpicnum]) i += i; + vv[0] = dd[0]*((float)((tilesiz[globalpicnum].y>>1)/*+g_psky.yoffs*/)) - vv[1]*ghoriz; + i = (1<<(picsiz[globalpicnum]>>4)); if (i != tilesiz[globalpicnum].y) i += i; //Hack to draw black rectangle below sky when looking down... gdx = 0; gdy = gxyaspect / -262144.f; gdo = -ghoriz*gdy; @@ -2779,7 +2709,7 @@ static void polymost_drawalls(int32_t bunch) gvx = 0; gvy = vv[1]; gvo = vv[0]; i = globalpicnum; r = (cy1-cy0)/(x1-x0); //slope of line - oy = ((float)viewingrange)/(ghalfx*256.f); oz = 1/oy; + oy = ((float)viewingrange)/(ghalfx*256.f); oz = 1.f/oy; y = ((((int32_t)((x0-ghalfx)*oy))+globalang)>>(11-dapskybits)); fx = x0; @@ -2883,17 +2813,17 @@ static void polymost_drawalls(int32_t bunch) drawingskybox = 5; //ceiling/5th texture/index 4 of skybox #endif ft[0] = 512/16; ft[1] = -512/-16; - ft[2] = ((float)cosglobalang)*(1.f/2147483648.f); - ft[3] = ((float)singlobalang)*(1.f/2147483648.f); + ft[2] = fcosglobalang*(1.f/2147483648.f); + ft[3] = fsinglobalang*(1.f/2147483648.f); gdx = 0; gdy = gxyaspect*(-1.f/4194304.f); gdo = -ghoriz*gdy; - gux = (float)ft[3]*((float)viewingrange)*(-1.0/65536.0); - gvx = (float)ft[2]*((float)viewingrange)*(-1.0/65536.0); - guy = (float)ft[0]*gdy; gvy = (float)ft[1]*gdy; - guo = (float)ft[0]*gdo; gvo = (float)ft[1]*gdo; - guo += (float)(ft[2]-gux)*ghalfx; - gvo -= (float)(ft[3]+gvx)*ghalfx; + gux = ft[3]*((float)viewingrange)*(-1.0/65536.0); + gvx = ft[2]*((float)viewingrange)*(-1.0/65536.0); + guy = ft[0]*gdy; gvy = ft[1]*gdy; + guo = ft[0]*gdo; gvo = ft[1]*gdo; + guo += (ft[2]-gux)*ghalfx; + gvo -= (ft[3]+gvx)*ghalfx; if ((_cy0 < ncy0) && (_cy1 < ncy1)) domost(_x1,_cy1,_x0,_cy0); else if ((_cy0 < ncy0) != (_cy1 < ncy1)) { @@ -2948,17 +2878,17 @@ static void polymost_drawalls(int32_t bunch) drawingskybox = 6; //floor/6th texture/index 5 of skybox #endif ft[0] = 512/16; ft[1] = 512/-16; - ft[2] = ((float)cosglobalang)*(1.f/2147483648.f); - ft[3] = ((float)singlobalang)*(1.f/2147483648.f); + ft[2] = fcosglobalang*(1.f/2147483648.f); + ft[3] = fsinglobalang*(1.f/2147483648.f); gdx = 0; gdy = gxyaspect*(1.f/4194304.f); gdo = -ghoriz*gdy; - gux = (float)ft[3]*((float)viewingrange)*(-1.0/65536.0); - gvx = (float)ft[2]*((float)viewingrange)*(-1.0/65536.0); - guy = (float)ft[0]*gdy; gvy = (float)ft[1]*gdy; - guo = (float)ft[0]*gdo; gvo = (float)ft[1]*gdo; - guo += (float)(ft[2]-gux)*ghalfx; - gvo -= (float)(ft[3]+gvx)*ghalfx; + gux = ft[3]*((float)viewingrange)*(-1.0/65536.0); + gvx = ft[2]*((float)viewingrange)*(-1.0/65536.0); + guy = ft[0]*gdy; gvy = ft[1]*gdy; + guo = ft[0]*gdo; gvo = ft[1]*gdo; + guo += (ft[2]-gux)*ghalfx; + gvo -= (ft[3]+gvx)*ghalfx; gvx = -gvx; gvy = -gvy; gvo = -gvo; //y-flip skybox floor domost(x1,cy1,x0,cy0); @@ -3138,29 +3068,26 @@ static int32_t polymost_bunchfront(const int32_t b1, const int32_t b2) { float x1b1, x1b2, x2b1, x2b2; int32_t b1f, b2f, i; - static int32_t count1, count2; b1f = bunchfirst[b1]; x1b1 = dxb1[b1f]; x2b2 = dxb2[bunchlast[b2]]; if (x1b1 >= x2b2) return(-1); b2f = bunchfirst[b2]; x1b2 = dxb1[b2f]; x2b1 = dxb2[bunchlast[b1]]; if (x1b2 >= x2b1) return(-1); if (x1b1 >= x1b2) { - for (i=b2f; dxb2[i]<=x1b1; i=p2[i]); + for (i=b2f; dxb2[i]<=x1b1; i=bunchp2[i]); return(wallfront(b1f,i)); } - for (i=b1f; dxb2[i]<=x1b2; i=p2[i]); + for (i=b1f; dxb2[i]<=x1b2; i=bunchp2[i]); return(wallfront(i,b2f)); } void polymost_scansector(int32_t sectnum) { - float d, xp1, yp1, xp2, yp2; walltype *wal, *wal2; spritetype *spr; - int32_t z, zz, startwall, endwall, numscansbefore, scanfirst, bunchfrst, nextsectnum; - int32_t xs, ys, x1, y1, x2, y2; - - int32_t sectorbordercnt; + int32_t z, zz, startwall, endwall, numscansbefore, scanfirst, bunchfrst, nextsectnum, sectorbordercnt; + fvec2_t p1, p2, fp1, fp2; + float d; if (sectnum < 0) return; @@ -3175,10 +3102,11 @@ void polymost_scansector(int32_t sectnum) if ((((spr->cstat&0x8000) == 0) || (showinvisibility)) && (spr->xrepeat > 0) && (spr->yrepeat > 0)) { - xs = spr->x-globalposx; ys = spr->y-globalposy; - if ((spr->cstat&48) || (xs*gcosang+ys*gsinang > 0) || (usemodels && tile2model[spr->picnum].modelid>=0)) + vec2_t s = { spr->x-globalposx, spr->y-globalposy }; + + if ((spr->cstat&48) || (usemodels && tile2model[spr->picnum].modelid>=0) || ((s.x * gcosang) + (s.y * gsinang) > 0)) { - if ((spr->cstat&(64+48))!=(64+16) || dmulscale6(sintable[(spr->ang+512)&2047],-xs, sintable[spr->ang&2047],-ys) > 0) + if ((spr->cstat&(64+48))!=(64+16) || dmulscale6(sintable[(spr->ang+512)&2047],-s.x, sintable[spr->ang&2047],-s.y) > 0) if (engine_addtsprite(z, sectnum)) break; } @@ -3192,12 +3120,13 @@ void polymost_scansector(int32_t sectnum) startwall = sector[sectnum].wallptr; endwall = sector[sectnum].wallnum+startwall; scanfirst = numscans; - xp2 = 0; yp2 = 0; + p2.x = p2.y = 0; + for (z=startwall,wal=&wall[z]; zpoint2]; - x1 = wal->x-globalposx; y1 = wal->y-globalposy; - x2 = wal2->x-globalposx; y2 = wal2->y-globalposy; + fp1.x = (float)(wal->x-globalposx); fp1.y = (float)(wal->y-globalposy); + fp2.x = (float)(wal2->x-globalposx); fp2.y = (float)(wal2->y-globalposy); nextsectnum = wal->nextsector; //Scan close sectors #ifdef YAX_ENABLE @@ -3205,49 +3134,47 @@ void polymost_scansector(int32_t sectnum) #endif if ((nextsectnum >= 0) && (!(wal->cstat&32)) && (!(gotsector[nextsectnum>>3]&pow2char[nextsectnum&7]))) { - d = (float)x1*(float)y2 - (float)x2*(float)y1; xp1 = (float)(x2-x1); yp1 = (float)(y2-y1); - if (d*d <= (xp1*xp1 + yp1*yp1)*(SCISDIST*SCISDIST*260.f)) + d = fp1.x*fp2.y - fp2.x*fp1.y; + p1.x = fp2.x-fp1.x; + p1.y = fp2.y-fp1.y; + + if (d*d <= (p1.x*p1.x + p1.y*p1.y) * (SCISDIST*SCISDIST*260.f)) sectorborder[sectorbordercnt++] = nextsectnum; } if ((z == startwall) || (wall[z-1].point2 != z)) { - xp1 = (float) (((int64_t)y1 * cosglobalang) - ((int64_t)x1 * singlobalang)) * (1.0f/64.f); - yp1 = (float) (((int64_t)x1 * cosviewingrangeglobalang) + ((int64_t)y1 * sinviewingrangeglobalang)) * (1.0f/64.f); -// xp1 = ((float)y1*(float)cosglobalang - (float)x1*(float)singlobalang)/64.0; -// yp1 = ((float)x1*(float)cosviewingrangeglobalang + (float)y1*(float)sinviewingrangeglobalang)/64.0; + p1.x = ((fp1.y * fcosglobalang) - (fp1.x * fsinglobalang)) * (1.0f/64.f); + p1.y = ((fp1.x * (float)cosviewingrangeglobalang) + (fp1.y * (float)sinviewingrangeglobalang)) * (1.0f/64.f); } - else { xp1 = xp2; yp1 = yp2; } + else { p1 = p2; } - xp2 = (float) (((int64_t) y2 * cosglobalang) - ((int64_t) x2 * singlobalang)) * (1.0f/64.f); - yp2 = (float) (((int64_t) x2 * cosviewingrangeglobalang) + ((int64_t) y2 * sinviewingrangeglobalang)) * (1.0f/64.f); + p2.x = ((fp2.y * fcosglobalang) - (fp2.x * fsinglobalang)) * (1.0f/64.f); + p2.y = ((fp2.x * (float) cosviewingrangeglobalang) + (fp2.y * (float) sinviewingrangeglobalang)) * (1.0f/64.f); -// xp2 = ((float)y2*(float)cosglobalang - (float)x2*(float)singlobalang)/64.0; -// yp2 = ((float)x2*(float)cosviewingrangeglobalang + (float)y2*(float)sinviewingrangeglobalang)/64.0; - - if ((yp1 >= SCISDIST) || (yp2 >= SCISDIST)) - if (xp1*yp2 < xp2*yp1) //if wall is facing you... + if ((p1.y >= SCISDIST) || (p2.y >= SCISDIST)) + if (p1.x*p2.y < p2.x*p1.y) //if wall is facing you... { - if (yp1 >= SCISDIST) - dxb1[numscans] = xp1*ghalfx/yp1 + ghalfx; + if (p1.y >= SCISDIST) + dxb1[numscans] = p1.x*ghalfx/p1.y + ghalfx; else dxb1[numscans] = -1e32f; - if (yp2 >= SCISDIST) - dxb2[numscans] = xp2*ghalfx/yp2 + ghalfx; + if (p2.y >= SCISDIST) + dxb2[numscans] = p2.x*ghalfx/p2.y + ghalfx; else dxb2[numscans] = 1e32f; if (dxb1[numscans] < dxb2[numscans]) - { thesector[numscans] = sectnum; thewall[numscans] = z; p2[numscans] = numscans+1; numscans++; } + { thesector[numscans] = sectnum; thewall[numscans] = z; bunchp2[numscans] = numscans+1; numscans++; } } if ((wall[z].point2 < z) && (scanfirst < numscans)) - { p2[numscans-1] = scanfirst; scanfirst = numscans; } + { bunchp2[numscans-1] = scanfirst; scanfirst = numscans; } } for (z=numscansbefore; z dxb1[p2[z]])) + if ((wall[thewall[z]].point2 != thewall[bunchp2[z]]) || (dxb2[z] > dxb1[bunchp2[z]])) { - bunchfirst[numbunches++] = p2[z]; p2[z] = -1; + bunchfirst[numbunches++] = bunchp2[z]; bunchp2[z] = -1; #ifdef YAX_ENABLE if (scansector_retfast) return; @@ -3256,13 +3183,87 @@ void polymost_scansector(int32_t sectnum) for (z=bunchfrst; z=0; zz=p2[zz]); + for (zz=bunchfirst[z]; bunchp2[zz]>=0; zz=bunchp2[zz]); bunchlast[z] = zz; } } while (sectorbordercnt > 0); } +/*Init viewport boundary (must be 4 point convex loop): +// (px[0],py[0]).----.(px[1],py[1]) +// / \ +// / \ +// (px[3],py[3]).--------------.(px[2],py[2]) +*/ + +void initmosts(const float * px, const float * py, int32_t n) +{ + int32_t i, j, k, imin, vcnt; + + vcnt = 1; //0 is dummy solid node + + if (n < 3) return; + imin = (px[1] < px[0]); + for (i=n-1; i>=2; i--) if (px[i] < px[imin]) imin = i; + + + vsp[vcnt].x = px[imin]; + vsp[vcnt].cy[0] = vsp[vcnt].fy[0] = py[imin]; + vcnt++; + i = imin+1; if (i >= n) i = 0; + j = imin-1; if (j < 0) j = n-1; + do + { + if (px[i] < px[j]) + { + if ((vcnt > 1) && (px[i] <= vsp[vcnt-1].x)) vcnt--; + vsp[vcnt].x = px[i]; + vsp[vcnt].cy[0] = py[i]; + k = j+1; if (k >= n) k = 0; + //(px[k],py[k]) + //(px[i],?) + //(px[j],py[j]) + vsp[vcnt].fy[0] = (px[i]-px[k])*(py[j]-py[k])/(px[j]-px[k]) + py[k]; + vcnt++; + i++; if (i >= n) i = 0; + } + else if (px[j] < px[i]) + { + if ((vcnt > 1) && (px[j] <= vsp[vcnt-1].x)) vcnt--; + vsp[vcnt].x = px[j]; + vsp[vcnt].fy[0] = py[j]; + k = i-1; if (k < 0) k = n-1; + //(px[k],py[k]) + //(px[j],?) + //(px[i],py[i]) + vsp[vcnt].cy[0] = (px[j]-px[k])*(py[i]-py[k])/(px[i]-px[k]) + py[k]; + vcnt++; + j--; if (j < 0) j = n-1; + } + else + { + if ((vcnt > 1) && (px[i] <= vsp[vcnt-1].x)) vcnt--; + vsp[vcnt].x = px[i]; + vsp[vcnt].cy[0] = py[i]; + vsp[vcnt].fy[0] = py[j]; + vcnt++; + i++; if (i >= n) i = 0; if (i == j) break; + j--; if (j < 0) j = n-1; + } + } while (i != j); + + if (px[i] > vsp[vcnt-1].x) + { + vsp[vcnt].x = px[i]; + vsp[vcnt].cy[0] = vsp[vcnt].fy[0] = py[i]; + vcnt++; + } + + vsp_finalize_init(vsp, vcnt); + gtag = vcnt; +} + void polymost_drawrooms() { int32_t i, j, n, n2, closest; @@ -3291,8 +3292,8 @@ void polymost_drawrooms() bglEnable(GL_DEPTH_TEST); bglDepthFunc(GL_ALWAYS); //NEVER,LESS,(,L)EQUAL,GREATER,(NOT,G)EQUAL,ALWAYS - //bglPolygonOffset(1,1); //Supposed to make sprites pasted on walls or floors not disappear - bglDepthRange(0.00001,1.0); //<- this is more widely supported than glPolygonOffset + bglPolygonOffset(-1.f, 0.f); //Supposed to make sprites pasted on walls or floors not disappear +// bglDepthRange(0.00001,1.0); //<- this is more widely supported than glPolygonOffset //Enable this for OpenGL red-blue glasses mode :) #ifdef REDBLUEMODE @@ -3321,11 +3322,15 @@ void polymost_drawrooms() //Polymost supports true look up/down :) Here, we convert horizon to angle. //gchang&gshang are cos&sin of this angle (respectively) + fglobalposx = (float) globalposx; + fglobalposy = (float) globalposy; gyxscale = ((float)xdimenscale)*(1.0f/131072.f); gxyaspect = ((float)xyaspect*(float)viewingrange)*(5.f/(65536.f*262144.f)); gviewxrange = ((float)viewingrange)*((float)xdimen)/(32768.f*1024.f); - gcosang = ((float)cosglobalang)*(1.0f/262144.f); - gsinang = ((float)singlobalang)*(1.0f/262144.f); + fcosglobalang = (float) cosglobalang; + gcosang = fcosglobalang*(1.0f/262144.f); + fsinglobalang = (float) singlobalang; + gsinang = fsinglobalang*(1.0f/262144.f); gcosang2 = gcosang*((float)viewingrange)*(1.0f/65536.f); gsinang2 = gsinang*((float)viewingrange)*(1.0f/65536.f); ghalfx = (float)halfxdimen; @@ -3343,8 +3348,8 @@ void polymost_drawrooms() //global cos/sin tilt angle gctang = cos(gtang); gstang = sin(gtang); - if (fabs(gstang) < .001f) //This hack avoids nasty precision bugs in domost() - { gstang = 0; if (gctang > 0) gctang = 1.f; else gctang = -1.f; } + if (fabsf(gstang) < .001f) //This hack avoids nasty precision bugs in domost() + { gstang = 0.f; if (gctang > 0.f) gctang = 1.f; else gctang = -1.f; } if (inpreparemirror) gstang = -gstang; @@ -3417,8 +3422,8 @@ void polymost_drawrooms() oz2 = oy*gchang + oz*gshang; //Standard Left/right rotation - vx = (int32_t)(ox2*((float)cosglobalang) - oy2*((float)singlobalang)); - vy = (int32_t)(ox2*((float)singlobalang) + oy2*((float)cosglobalang)); + vx = (int32_t)(ox2*fcosglobalang - oy2*fsinglobalang); + vy = (int32_t)(ox2*fsinglobalang + oy2*fcosglobalang); vz = (int32_t)(oz2*16384.f); vect.x = globalposx; @@ -3592,8 +3597,8 @@ void polymost_drawrooms() { bglDepthFunc(GL_LEQUAL); //NEVER,LESS,(,L)EQUAL,GREATER,(NOT,G)EQUAL,ALWAYS - //bglPolygonOffset(0,0); - bglDepthRange(0.0,0.99999); //<- this is more widely supported than glPolygonOffset + bglPolygonOffset(-1.f, 0.f); +// bglDepthRange(0.0,0.99999); //<- this is more widely supported than glPolygonOffset } #endif @@ -3837,11 +3842,11 @@ void polymost_drawsprite(int32_t snum) break; } - if (((tspr->cstat&(2|16)) || (gltexmayhavealpha(tspr->picnum,tspr->pal)))) + if (tspr->cstat & (2|16) || gltexmayhavealpha(tspr->picnum,tspr->pal)) { - curpolygonoffset -= 0.1f; + curpolygonoffset += .25f; bglEnable(GL_POLYGON_OFFSET_FILL); - bglPolygonOffset(-1.0f, curpolygonoffset); + bglPolygonOffset(-1.f-curpolygonoffset, -1.f); } #endif @@ -3858,8 +3863,8 @@ void polymost_drawsprite(int32_t snum) posy-=(sintable[(tspr->ang)&2047]>>13); } - oldsizx=tsizx=tilesizx[globalpicnum]; - oldsizy=tsizy=tilesizy[globalpicnum]; + oldsizx=tsizx=tilesiz[globalpicnum].x; + oldsizy=tsizy=tilesiz[globalpicnum].y; if (usehightile && h_xsize[globalpicnum]) { tsizx = h_xsize[globalpicnum]; @@ -3930,8 +3935,8 @@ void polymost_drawsprite(int32_t snum) if (spriteext[spritenum].ypanning) trepeat = 1; #endif - tilesizx[globalpicnum] = tsizx; - tilesizy[globalpicnum] = tsizy; + tilesiz[globalpicnum].x = tsizx; + tilesiz[globalpicnum].y = tsizy; pow2xsplit = 0; drawpoly(px,py,4,method); #ifdef USE_OPENGL @@ -4074,8 +4079,8 @@ void polymost_drawsprite(int32_t snum) trepeat = 1; #endif - tilesizx[globalpicnum] = tsizx; - tilesizy[globalpicnum] = tsizy; + tilesiz[globalpicnum].x = tsizx; + tilesiz[globalpicnum].y = tsizy; pow2xsplit = 0; drawpoly(px,py,4,method); #ifdef USE_OPENGL @@ -4187,8 +4192,8 @@ void polymost_drawsprite(int32_t snum) trepeat = 1; #endif - tilesizx[globalpicnum] = tsizx; - tilesizy[globalpicnum] = tsizy; + tilesiz[globalpicnum].x = tsizx; + tilesiz[globalpicnum].y = tsizy; pow2xsplit = 0; drawpoly(px,py,npoints,method); #ifdef USE_OPENGL @@ -4203,8 +4208,8 @@ void polymost_drawsprite(int32_t snum) case 3: //Voxel sprite break; } - tilesizx[globalpicnum]=oldsizx; - tilesizy[globalpicnum]=oldsizy; + tilesiz[globalpicnum].x=oldsizx; + tilesiz[globalpicnum].y=oldsizy; } EDUKE32_STATIC_ASSERT((int)RS_YFLIP == (int)HUDFLAG_FLIPPED); @@ -4221,30 +4226,19 @@ EDUKE32_STATIC_ASSERT((int)RS_YFLIP == (int)HUDFLAG_FLIPPED); //dastat&64 1:non-masked, 0:masked //dastat&128 1:draw all pages (permanent) //cx1,... clip window (actual screen coords) -void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum, - int8_t dashade, char dapalnum, int32_t dastat, uint8_t daalpha, - int32_t cx1, int32_t cy1, int32_t cx2, int32_t cy2, int32_t uniqid) -{ - static int32_t onumframes = 0; - - int32_t n, nn, xoff, yoff, xsiz, ysiz, method; - int32_t ogpicnum, ogshade, ogpal, ofoffset; - float ogchang, ogshang, ogctang, ogstang, oghalfx, oghoriz; - float ogrhalfxdown10, ogrhalfxdown10x; - float d, cosang, sinang, cosang2, sinang2, px[8], py[8], px2[8], py2[8]; - float m[4][4]; - - int32_t ourxyaspect; - -#if defined(USE_OPENGL) && defined(POLYMER) - const int32_t olddetailmapping = r_detailmapping, oldglowmapping = r_glowmapping; - const int32_t oldnormalmapping = pr_normalmapping; -#endif #ifdef USE_OPENGL - if (getrendermode() >= REND_POLYMOST && usemodels && hudmem[(dastat&4)>>2][picnum].angadd) - { - const int32_t tilenum = Ptile2tile(picnum,dapalnum); +void polymost_dorotatespritemodel(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum, + int8_t dashade, char dapalnum, int32_t dastat, uint8_t daalpha, int32_t uniqid) +{ + int32_t xoff, yoff, xsiz, ysiz; + int32_t ogshade, ogpal; + + float ogchang, ogshang, ogctang, ogstang; + float d, cosang, sinang, cosang2, sinang2; + float m[4][4]; + + const int32_t tilenum = Ptile2tile(picnum, dapalnum); if (tile2model[tilenum].modelid >= 0 && tile2model[tilenum].framenum >= 0) @@ -4254,17 +4248,17 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16 float x1, y1, z1; spritetype tspr; - memset(&tspr,0,sizeof(spritetype)); + memset(&tspr, 0, sizeof(spritetype)); if (hudmem[(dastat&4)>>2][picnum].flags & HUDFLAG_HIDE) return; ogchang = gchang; gchang = 1.f; - ogshang = gshang; gshang = 0.f; d = (float)z*(1.0f/(65536.f*16384.f)); - ogctang = gctang; gctang = (float)sintable[(a+512)&2047]*d; - ogstang = gstang; gstang = (float)sintable[a&2047]*d; + ogshang = gshang; gshang = 0.f; d = (float) z*(1.0f/(65536.f*16384.f)); + ogctang = gctang; gctang = (float) sintable[(a+512)&2047]*d; + ogstang = gstang; gstang = (float) sintable[a&2047]*d; ogshade = globalshade; globalshade = dashade; - ogpal = globalpal; globalpal = (int32_t)((uint8_t)dapalnum); + ogpal = globalpal; globalpal = (int32_t) ((uint8_t) dapalnum); ogxyaspect = gxyaspect; gxyaspect = 1.f; oldviewingrange = viewingrange; viewingrange = 65536; @@ -4281,28 +4275,30 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16 #endif if (!(hudmem[(dastat&4)>>2][picnum].flags & HUDFLAG_NOBOB)) { - float fx = ((float)sx)*(1.f/65536.f); - float fy = ((float)sy)*(1.f/65536.f); + float fx = ((float) sx)*(1.f/65536.f); + float fy = ((float) sy)*(1.f/65536.f); if (dastat & RS_TOPLEFT) { - xsiz = tilesizx[picnum]; ysiz = tilesizy[picnum]; + xsiz = tilesiz[picnum].x; ysiz = tilesiz[picnum].y; xoff = picanm[picnum].xofs + (xsiz>>1); yoff = picanm[picnum].yofs + (ysiz>>1); - d = (float)z*(1.0f/(65536.f*16384.f)); - cosang2 = cosang = (float)sintable[(a+512)&2047]*d; - sinang2 = sinang = (float)sintable[a&2047]*d; + d = (float) z*(1.0f/(65536.f*16384.f)); + cosang2 = cosang = (float) sintable[(a+512)&2047]*d; + sinang2 = sinang = (float) sintable[a&2047]*d; if ((dastat&RS_AUTO) || (!(dastat&RS_NOCLIP))) //Don't aspect unscaled perms - { d = (float)xyaspect*(1.0f/65536.f); cosang2 *= d; sinang2 *= d; } - fx += -(float)xoff*cosang2+ (float)yoff*sinang2; - fy += -(float)xoff*sinang - (float)yoff*cosang; + { + d = (float) xyaspect*(1.0f/65536.f); cosang2 *= d; sinang2 *= d; + } + fx += -(float) xoff*cosang2+ (float) yoff*sinang2; + fy += -(float) xoff*sinang - (float) yoff*cosang; } if (!(dastat & RS_AUTO)) { - x1 += fx/((float)(xdim<<15))-1.f; //-1: left of screen, +1: right of screen - y1 += fy/((float)(ydim<<15))-1.f; //-1: top of screen, +1: bottom of screen + x1 += fx/((float) (xdim<<15))-1.f; //-1: left of screen, +1: right of screen + y1 += fy/((float) (ydim<<15))-1.f; //-1: top of screen, +1: bottom of screen } else { @@ -4325,9 +4321,9 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16 { tspr.xrepeat = tspr.yrepeat = 32; - tspr.x = (int32_t)(((float)gcosang*z1 - (float)gsinang*x1)*16384.f + globalposx); - tspr.y = (int32_t)(((float)gsinang*z1 + (float)gcosang*x1)*16384.f + globalposy); - tspr.z = (int32_t)(globalposz + y1*16384.f*0.8f); + tspr.x = (int32_t) (((float) gcosang*z1 - (float) gsinang*x1)*16384.f + globalposx); + tspr.y = (int32_t) (((float) gsinang*z1 + (float) gcosang*x1)*16384.f + globalposy); + tspr.z = (int32_t) (globalposz + y1*16384.f*0.8f); } else { @@ -4335,9 +4331,9 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16 tspr.xrepeat = tspr.yrepeat = 5; - x = (float)(((float)gcosang*z1 - (float)gsinang*x1)*2560.f + globalposx); - y = (float)(((float)gsinang*z1 + (float)gcosang*x1)*2560.f + globalposy); - z = (float)(globalposz + y1*2560.f*0.8f); + x = (float) (((float) gcosang*z1 - (float) gsinang*x1)*2560.f + globalposx); + y = (float) (((float) gsinang*z1 + (float) gcosang*x1)*2560.f + globalposy); + z = (float) (globalposz + y1*2560.f*0.8f); memcpy(&tspr.x, &x, sizeof(float)); memcpy(&tspr.y, &y, sizeof(float)); @@ -4354,17 +4350,17 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16 tspr.cstat = globalorientation; if ((dastat&(RS_AUTO|RS_NOCLIP)) == RS_AUTO) - bglViewport(windowx1,yres-(windowy2+1),windowx2-windowx1+1,windowy2-windowy1+1); + bglViewport(windowx1, yres-(windowy2+1), windowx2-windowx1+1, windowy2-windowy1+1); else { - bglViewport(0,0,xdim,ydim); + bglViewport(0, 0, xdim, ydim); glox1 = -1; //Force fullscreen (glox1=-1 forces it to restore) } if (getrendermode() < REND_POLYMER) { bglMatrixMode(GL_PROJECTION); - memset(m,0,sizeof(m)); + memset(m, 0, sizeof(m)); if ((dastat&(RS_AUTO|RS_NOCLIP)) == RS_AUTO) { const float ratioratio = 1.f; //(float)xdim/ydim; @@ -4382,15 +4378,15 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16 f = 1.f / tanf((PI * fov)*(1.0f/2048.f)); } - m[0][0] = f*(float)ydimen*(ratioratio >= 1.6?1.2:1); m[0][2] = 1.f; - m[1][1] = f*(float)xdimen; m[1][2] = 1.f; - m[2][2] = 1.f; m[2][3] = (float)ydimen*(ratioratio >= 1.6?1.2:1); + m[0][0] = f*(float) ydimen*(ratioratio >= 1.6 ? 1.2 : 1); m[0][2] = 1.f; + m[1][1] = f*(float) xdimen; m[1][2] = 1.f; + m[2][2] = 1.f; m[2][3] = (float) ydimen*(ratioratio >= 1.6 ? 1.2 : 1); m[3][2] =-1.f; } else { m[0][0] = m[2][3] = 1.f; - m[1][1] = ((float)xdim)/((float)ydim); + m[1][1] = ((float) xdim)/((float) ydim); m[2][2] = 1.0001f; m[3][2] = 1-m[2][2]; } @@ -4405,7 +4401,10 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16 bglDisable(GL_DEPTH_TEST); else { + static int32_t onumframes = 0; + bglEnable(GL_DEPTH_TEST); + if (onumframes != numframes) { onumframes = numframes; @@ -4471,6 +4470,32 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16 return; } +} +#endif + +void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum, + int8_t dashade, char dapalnum, int32_t dastat, uint8_t daalpha, + int32_t cx1, int32_t cy1, int32_t cx2, int32_t cy2, int32_t uniqid) +{ + int32_t n, nn, xoff, yoff, xsiz, ysiz, method; + int32_t ogpicnum, ogshade, ogpal, ofoffset; + float ogchang, ogshang, ogctang, ogstang, oghalfx, oghoriz; + float ogrhalfxdown10, ogrhalfxdown10x; + float d, cosang, sinang, cosang2, sinang2, px[8], py[8], px2[8], py2[8]; + float m[4][4]; + + int32_t ourxyaspect; + +#if defined(USE_OPENGL) && defined(POLYMER) + const int32_t olddetailmapping = r_detailmapping, oldglowmapping = r_glowmapping; + const int32_t oldnormalmapping = pr_normalmapping; +#endif + +#ifdef USE_OPENGL + if (getrendermode() >= REND_POLYMOST && usemodels && hudmem[(dastat&4)>>2][picnum].angadd) + { + polymost_dorotatespritemodel(sx, sy, z, a, picnum, dashade, dapalnum, dastat, daalpha, uniqid); + return; } #endif @@ -4479,7 +4504,7 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16 ogshade = globalshade; globalshade = dashade; ogpal = globalpal; globalpal = (int32_t)((uint8_t)dapalnum); oghalfx = ghalfx; ghalfx = (float)(xdim>>1); - ogrhalfxdown10 = grhalfxdown10; grhalfxdown10 = 1.f/(((float)ghalfx)*1024); + ogrhalfxdown10 = grhalfxdown10; grhalfxdown10 = 1.f/(ghalfx*1024.f); ogrhalfxdown10x = grhalfxdown10x; grhalfxdown10x = grhalfxdown10; oghoriz = ghoriz; ghoriz = (float)(ydim>>1); ofoffset = frameoffset; frameoffset = frameplace; @@ -4527,8 +4552,8 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16 alpha = daalpha * (1.0f / 255.0f); - xsiz = tilesizx[globalpicnum]; - ysiz = tilesizy[globalpicnum]; + xsiz = tilesiz[globalpicnum].x; + ysiz = tilesiz[globalpicnum].y; if (dastat & RS_TOPLEFT) { @@ -4841,9 +4866,8 @@ void polymost_fillpolygon(int32_t npoints) gvx = ((float)asm2)*(1.f/4294967296.f); guy = ((float)globalx1)*(1.f/4294967296.f); gvy = ((float)globaly2)*(-1.f/4294967296.f); - guo = (((float)xdim)*gux + ((float)ydim)*guy)*-0.5f + ((float)globalposx)*(1.f/4294967296.f); - gvo = (((float)xdim)*gvx + ((float)ydim)*gvy)*-0.5f - ((float)globalposy)*(1.f/4294967296.f); - + guo = (((float) xdim)*gux + ((float) ydim)*guy)*-0.5f + (fglobalposx)*(1.f/4294967296.f); + gvo = (((float) xdim)*gvx + ((float) ydim)*gvy)*-0.5f - (fglobalposy)*(1.f/4294967296.f); //Convert int32_t to float (in-place) for (i=npoints-1; i>=0; i--) { @@ -4858,17 +4882,18 @@ void polymost_fillpolygon(int32_t npoints) bglBindTexture(GL_TEXTURE_2D, pth ? pth->glpic : 0); f = getshadefactor(globalshade); - switch ((globalorientation>>7)&3) + + if ((globalorientation>>7)&3 > 1) { - case 0: - case 1: - a = 1.0f; bglDisable(GL_BLEND); break; - case 2: - a = 0.66f; bglEnable(GL_BLEND); break; - case 3: - a = 0.33f; bglEnable(GL_BLEND); break; + bglEnable(GL_BLEND); + a = float_trans[(globalorientation>>7)&3]; + bglColor4f(f, f, f, a); + } + else + { + bglDisable(GL_BLEND); + bglColor3f(f, f, f); } - bglColor4f(f,f,f,a); tessectrap((float *)rx1,(float *)ry1,xb1,npoints); } @@ -4886,16 +4911,16 @@ int32_t polymost_drawtilescreen(int32_t tilex, int32_t tiley, int32_t wallnum, i if (!glinfo.texnpot) { - i = (1<<(picsiz[wallnum]&15)); if (i < tilesizx[wallnum]) i += i; xdimepad = (float)i; - i = (1<<(picsiz[wallnum]>>4)); if (i < tilesizy[wallnum]) i += i; ydimepad = (float)i; + i = (1<<(picsiz[wallnum]&15)); if (i < tilesiz[wallnum].x) i += i; xdimepad = (float)i; + i = (1<<(picsiz[wallnum]>>4)); if (i < tilesiz[wallnum].y) i += i; ydimepad = (float)i; } else { - xdimepad = (float)tilesizx[wallnum]; - ydimepad = (float)tilesizy[wallnum]; + xdimepad = (float)tilesiz[wallnum].x; + ydimepad = (float)tilesiz[wallnum].y; } - xdime = (float)tilesizx[wallnum]; xdimepad = xdime/xdimepad; - ydime = (float)tilesizy[wallnum]; ydimepad = ydime/ydimepad; + xdime = (float)tilesiz[wallnum].x; xdimepad = xdime/xdimepad; + ydime = (float)tilesiz[wallnum].y; ydimepad = ydime/ydimepad; if ((xdime <= dimen) && (ydime <= dimen)) { @@ -4936,15 +4961,13 @@ int32_t polymost_drawtilescreen(int32_t tilex, int32_t tiley, int32_t wallnum, i bglDisable(GL_TEXTURE_2D); bglBegin(GL_TRIANGLE_FAN); if (gammabrightness) - bglColor4f((float)curpalette[255].r*(1.0f/255.f), + bglColor3f((float)curpalette[255].r*(1.0f/255.f), (float)curpalette[255].g*(1.0f/255.f), - (float)curpalette[255].b*(1.0f/255.f), - 1); + (float)curpalette[255].b*(1.0f/255.f)); else - bglColor4f((float)britable[curbrightness][ curpalette[255].r ] * (1.0f/255.f), + bglColor3f((float)britable[curbrightness][ curpalette[255].r ] * (1.0f/255.f), (float)britable[curbrightness][ curpalette[255].g ] * (1.0f/255.f), - (float)britable[curbrightness][ curpalette[255].b ] * (1.0f/255.f), - 1); + (float)britable[curbrightness][ curpalette[255].b ] * (1.0f/255.f)); bglVertex2f((float)tilex ,(float)tiley); bglVertex2f((float)tilex+(scx*ratio),(float)tiley); bglVertex2f((float)tilex+(scx*ratio),(float)tiley+(scy*ratio)); @@ -4952,7 +4975,7 @@ int32_t polymost_drawtilescreen(int32_t tilex, int32_t tiley, int32_t wallnum, i bglEnd(); } - bglColor4f(1,1,1,1); + bglColor3f(1,1,1); bglEnable(GL_TEXTURE_2D); bglEnable(GL_BLEND); bglBegin(GL_TRIANGLE_FAN); @@ -5301,7 +5324,6 @@ void polymost_initosdfuncs(void) { "r_pr_verbosity", "verbosity level of the polymer renderer", (void *) &pr_verbosity, CVAR_INT, 0, 3 }, { "r_pr_wireframe", "toggles wireframe mode", (void *) &pr_wireframe, CVAR_INT | CVAR_NOSAVE, 0, 1 }, { "r_pr_vbos", "contols Vertex Buffer Object usage. 0: no VBOs. 1: VBOs for map data. 2: VBOs for model data.", (void *) &pr_vbos, CVAR_INT | CVAR_RESTARTVID, 0, 2 }, - { "r_pr_vboupdatemethod", "contols Vertex Buffer Object updates. 0: glBufferSubData. 1: glMapBuffer", (void *) &pr_vboupdatemethod, CVAR_BOOL, 0, 1 }, { "r_pr_gpusmoothing", "toggles model animation interpolation", (void *) &pr_gpusmoothing, CVAR_INT, 0, 1 }, { "r_pr_overrideparallax", "overrides parallax mapping scale and bias values with values from the pr_parallaxscale and pr_parallaxbias cvars; use it to fine-tune DEF tokens", (void *) &pr_overrideparallax, CVAR_BOOL | CVAR_NOSAVE, 0, 1 }, { "r_pr_parallaxscale", "overriden parallax mapping offset scale", (void *) &pr_parallaxscale, CVAR_FLOAT | CVAR_NOSAVE, -10, 10 }, diff --git a/polymer/eduke32/build/src/texcache.c b/polymer/eduke32/build/src/texcache.c index 53e500269..1f447cc38 100644 --- a/polymer/eduke32/build/src/texcache.c +++ b/polymer/eduke32/build/src/texcache.c @@ -37,7 +37,7 @@ static pthtyp *texcache_tryart(int32_t dapicnum, int32_t dapalnum, int32_t dasha for (pth=texcache.list[j]; pth; pth=pth->next) if (pth->picnum == dapicnum && pth->palnum == dapalnum && pth->shade == dashade && (pth->flags & (PTH_CLAMPED+PTH_HIGHTILE)) == TO_PTH_CLAMPED(dameth) && - polymost_want_npotytex(dameth, tilesizy[dapicnum]) == !!(pth->flags&PTH_NPOTWALL) + polymost_want_npotytex(dameth, tilesiz[dapicnum].y) == !!(pth->flags&PTH_NPOTWALL) ) { if (pth->flags & PTH_INVALIDATED) diff --git a/polymer/eduke32/source/actors.c b/polymer/eduke32/source/actors.c index 9d6a28b76..c1b22e000 100644 --- a/polymer/eduke32/source/actors.c +++ b/polymer/eduke32/source/actors.c @@ -431,7 +431,7 @@ int32_t A_MoveSpriteClipdist(int32_t spritenum, const vec3_t *change, uint32_t c } dasectnum = spr->sectnum; - daz = spr->z - 2*tilesizy[spr->picnum]*spr->yrepeat; + daz = spr->z - 2*tilesiz[spr->picnum].y*spr->yrepeat; { const int32_t oldz=spr->z; @@ -804,8 +804,8 @@ static void A_MoveSector(int32_t i) // this is the same crap as in game.c's tspr manipulation. puke. // XXX: may access tilesizy out-of-bounds by bad user code. -#define LIGHTRAD (s->yrepeat * tilesizy[s->picnum + LIGHTRAD_PICOFS]) -#define LIGHTRAD2 (((s->yrepeat) + (rand()%(s->yrepeat>>2))) * tilesizy[s->picnum + LIGHTRAD_PICOFS]) +#define LIGHTRAD (s->yrepeat * tilesiz[s->picnum + LIGHTRAD_PICOFS].y) +#define LIGHTRAD2 (((s->yrepeat) + (rand()%(s->yrepeat>>2))) * tilesiz[s->picnum + LIGHTRAD_PICOFS].y) void G_AddGameLight(int32_t radius, int32_t srcsprite, int32_t zoffset, int32_t range, int32_t color, int32_t priority) { @@ -2722,7 +2722,7 @@ ACTOR_STATIC void Proj_MoveCustom(int32_t i) Bmemcpy(&davect, s, sizeof(vec3_t)); if (proj->flashcolor) - G_AddGameLight(0, i, ((s->yrepeat*tilesizy[s->picnum])<<1), 2048, proj->flashcolor, PR_LIGHT_PRIO_LOW_GAME); + G_AddGameLight(0, i, ((s->yrepeat*tilesiz[s->picnum].y)<<1), 2048, proj->flashcolor, PR_LIGHT_PRIO_LOW_GAME); if (proj->workslike & PROJECTILE_BOUNCESOFFWALLS && s->yvel < 1) { @@ -8020,7 +8020,7 @@ static void A_DoLight(int32_t i) s->x += dx>>7; s->y += dy>>7; - G_AddGameLight(0, i, ((s->yrepeat*tilesizy[s->picnum])<<1), 1024-ii*256, + G_AddGameLight(0, i, ((s->yrepeat*tilesiz[s->picnum].y)<<1), 1024-ii*256, ii==0 ? (48+(255<<8)+(48<<16)) : 255+(48<<8)+(48<<16), PR_LIGHT_PRIO_LOW); s->x -= dx>>7; @@ -8033,7 +8033,7 @@ static void A_DoLight(int32_t i) switch (DYNAMICTILEMAP(sprite[i].picnum)) { case ATOMICHEALTH__STATIC: - G_AddGameLight(0, i, ((s->yrepeat*tilesizy[s->picnum])<<1), LIGHTRAD2 * 3, 128+(128<<8)+(255<<16),PR_LIGHT_PRIO_HIGH_GAME); + G_AddGameLight(0, i, ((s->yrepeat*tilesiz[s->picnum].y)<<1), LIGHTRAD2 * 3, 128+(128<<8)+(255<<16),PR_LIGHT_PRIO_HIGH_GAME); break; case FIRE__STATIC: @@ -8067,7 +8067,7 @@ static void A_DoLight(int32_t i) if (jj==-1 && numsavedfires<32) { jj = numsavedfires; - G_AddGameLight(0, i, ((s->yrepeat*tilesizy[s->picnum])<<1), LIGHTRAD2, color, PR_LIGHT_PRIO_HIGH_GAME); + G_AddGameLight(0, i, ((s->yrepeat*tilesiz[s->picnum].y)<<1), LIGHTRAD2, color, PR_LIGHT_PRIO_HIGH_GAME); savedfires[jj][0] = s->sectnum; savedfires[jj][1] = s->x>>3; savedfires[jj][2] = s->y>>3; @@ -8079,12 +8079,12 @@ static void A_DoLight(int32_t i) case OOZFILTER__STATIC: if (s->xrepeat > 4) - G_AddGameLight(0, i, ((s->yrepeat*tilesizy[s->picnum])<<1), 4096, 128+(255<<8)+(128<<16),PR_LIGHT_PRIO_HIGH_GAME); + G_AddGameLight(0, i, ((s->yrepeat*tilesiz[s->picnum].y)<<1), 4096, 128+(255<<8)+(128<<16),PR_LIGHT_PRIO_HIGH_GAME); break; case FLOORFLAME__STATIC: case FIREBARREL__STATIC: case FIREVASE__STATIC: - G_AddGameLight(0, i, ((s->yrepeat*tilesizy[s->picnum])<<1), LIGHTRAD, 255+(95<<8),PR_LIGHT_PRIO_HIGH_GAME); + G_AddGameLight(0, i, ((s->yrepeat*tilesiz[s->picnum].y)<<1), LIGHTRAD, 255+(95<<8),PR_LIGHT_PRIO_HIGH_GAME); break; case EXPLOSION2__STATIC: @@ -8097,7 +8097,7 @@ static void A_DoLight(int32_t i) s->x -= x; s->y -= y; - G_AddGameLight(0, i, ((s->yrepeat*tilesizy[s->picnum])<<1), LIGHTRAD, 255+(95<<8), + G_AddGameLight(0, i, ((s->yrepeat*tilesiz[s->picnum].y)<<1), LIGHTRAD, 255+(95<<8), s->yrepeat > 32 ? PR_LIGHT_PRIO_HIGH_GAME : PR_LIGHT_PRIO_LOW_GAME); s->x += x; @@ -8106,7 +8106,7 @@ static void A_DoLight(int32_t i) break; case FORCERIPPLE__STATIC: case TRANSPORTERBEAM__STATIC: - G_AddGameLight(0, i, ((s->yrepeat*tilesizy[s->picnum])<<1), LIGHTRAD, 80+(80<<8)+(255<<16),PR_LIGHT_PRIO_LOW_GAME); + G_AddGameLight(0, i, ((s->yrepeat*tilesiz[s->picnum].y)<<1), LIGHTRAD, 80+(80<<8)+(255<<16),PR_LIGHT_PRIO_LOW_GAME); break; case GROWSPARK__STATIC: { @@ -8116,7 +8116,7 @@ static void A_DoLight(int32_t i) s->x -= x; s->y -= y; - G_AddGameLight(0, i, ((s->yrepeat*tilesizy[s->picnum])<<1), 2048, 255+(95<<8),PR_LIGHT_PRIO_HIGH_GAME); + G_AddGameLight(0, i, ((s->yrepeat*tilesiz[s->picnum].y)<<1), 2048, 255+(95<<8),PR_LIGHT_PRIO_HIGH_GAME); s->x += x; s->y += y; @@ -8130,26 +8130,26 @@ static void A_DoLight(int32_t i) s->x -= x; s->y -= y; - G_AddGameLight(0, i, ((s->yrepeat*tilesizy[s->picnum])<<1), 2048, 128+(255<<8)+(128<<16),PR_LIGHT_PRIO_HIGH_GAME); + G_AddGameLight(0, i, ((s->yrepeat*tilesiz[s->picnum].y)<<1), 2048, 128+(255<<8)+(128<<16),PR_LIGHT_PRIO_HIGH_GAME); s->x += x; s->y += y; } break; case FREEZEBLAST__STATIC: - G_AddGameLight(0, i, ((s->yrepeat*tilesizy[s->picnum])<<1), LIGHTRAD<<2, 128+(128<<8)+(255<<16),PR_LIGHT_PRIO_HIGH_GAME); + G_AddGameLight(0, i, ((s->yrepeat*tilesiz[s->picnum].y)<<1), LIGHTRAD<<2, 128+(128<<8)+(255<<16),PR_LIGHT_PRIO_HIGH_GAME); break; case COOLEXPLOSION1__STATIC: - G_AddGameLight(0, i, ((s->yrepeat*tilesizy[s->picnum])<<1), LIGHTRAD<<2, 128+(0<<8)+(255<<16),PR_LIGHT_PRIO_HIGH_GAME); + G_AddGameLight(0, i, ((s->yrepeat*tilesiz[s->picnum].y)<<1), LIGHTRAD<<2, 128+(0<<8)+(255<<16),PR_LIGHT_PRIO_HIGH_GAME); break; case SHRINKSPARK__STATIC: - G_AddGameLight(0, i, ((s->yrepeat*tilesizy[s->picnum])<<1), LIGHTRAD, 128+(255<<8)+(128<<16),PR_LIGHT_PRIO_HIGH_GAME); + G_AddGameLight(0, i, ((s->yrepeat*tilesiz[s->picnum].y)<<1), LIGHTRAD, 128+(255<<8)+(128<<16),PR_LIGHT_PRIO_HIGH_GAME); break; case FIRELASER__STATIC: - G_AddGameLight(0, i, ((s->yrepeat*tilesizy[s->picnum])<<1), 64 * s->yrepeat, 255+(95<<8),PR_LIGHT_PRIO_LOW_GAME); + G_AddGameLight(0, i, ((s->yrepeat*tilesiz[s->picnum].y)<<1), 64 * s->yrepeat, 255+(95<<8),PR_LIGHT_PRIO_LOW_GAME); break; case RPG__STATIC: - G_AddGameLight(0, i, ((s->yrepeat*tilesizy[s->picnum])<<1), 128 * s->yrepeat, 255+(95<<8),PR_LIGHT_PRIO_LOW_GAME); + G_AddGameLight(0, i, ((s->yrepeat*tilesiz[s->picnum].y)<<1), 128 * s->yrepeat, 255+(95<<8),PR_LIGHT_PRIO_LOW_GAME); break; case SHOTSPARK1__STATIC: if (actor[i].t_data[2] == 0) // check for first frame of action @@ -8160,7 +8160,7 @@ static void A_DoLight(int32_t i) s->x -= x; s->y -= y; - G_AddGameLight(0, i, ((s->yrepeat*tilesizy[s->picnum])<<1), 16 * s->yrepeat, 255+(95<<8),PR_LIGHT_PRIO_LOW_GAME); + G_AddGameLight(0, i, ((s->yrepeat*tilesiz[s->picnum].y)<<1), 16 * s->yrepeat, 255+(95<<8),PR_LIGHT_PRIO_LOW_GAME); actor[i].lightcount = 1; s->x += x; diff --git a/polymer/eduke32/source/anim.c b/polymer/eduke32/source/anim.c index ebec10b3a..0ebd62542 100644 --- a/polymer/eduke32/source/anim.c +++ b/polymer/eduke32/source/anim.c @@ -375,8 +375,8 @@ int32_t G_PlayAnim(const char *fn, char t) if (!animbuf[t-1]) allocache((intptr_t *)&animbuf[t-1], length+1, &animlock[t-1]); - tilesizx[TILE_ANIM] = 200; - tilesizy[TILE_ANIM] = 320; + tilesiz[TILE_ANIM].x = 200; + tilesiz[TILE_ANIM].y = 320; kread(handle, animbuf[t-1], length); kclose(handle); diff --git a/polymer/eduke32/source/astub.c b/polymer/eduke32/source/astub.c index cfe80752b..5471cce61 100644 --- a/polymer/eduke32/source/astub.c +++ b/polymer/eduke32/source/astub.c @@ -2115,15 +2115,15 @@ static void ExtSE40Draw(int32_t spnum,int32_t x,int32_t y,int32_t z,int16_t a,in // return; // gotpic[FOF>>3] &= ~(1<<(FOF&7)); - if (tilesizx[562]) + if (tilesiz[562].x) { - fofsizex = tilesizx[562]; - tilesizx[562] = 0; + fofsizex = tilesiz[562].x; + tilesiz[562].x = 0; } - if (tilesizy[562]) + if (tilesiz[562].y) { - fofsizey = tilesizy[562]; - tilesizy[562] = 0; + fofsizey = tilesiz[562].y; + tilesiz[562].y = 0; } floor1=spnum; @@ -2467,7 +2467,7 @@ int32_t AskIfSure(const char *text) static int32_t IsValidTile(int32_t idTile) { - return (idTile>=0 && idTile=0 && idTile>2,ydim-10,whitecol,-1,szT,0); // EditArt offset flags. @@ -3650,7 +3650,7 @@ static void drawtileinfo(const char *title,int32_t x,int32_t y,int32_t picnum,in int32_t small = (xdimgame<=640); int32_t oviewingrange=viewingrange, oyxaspect=yxaspect; - if (tilesizx[picnum]>0 && tilesizy[picnum]>0) + if (tilesiz[picnum].x>0 && tilesiz[picnum].y>0) { double scalediv; int32_t scale=65536; @@ -3660,7 +3660,7 @@ static void drawtileinfo(const char *title,int32_t x,int32_t y,int32_t picnum,in x1 /= 2; x1 = (int32_t)(x1 * 320.0/xdimgame); - scalediv = max(tilesizx[picnum],tilesizy[picnum])/24.0; + scalediv = max(tilesiz[picnum].x,tilesiz[picnum].y)/24.0; scale = (int32_t)((double)scale/scalediv); setaspect(65536L, (int32_t)divscale16(ydim*320L,xdim*200L)); @@ -3868,7 +3868,7 @@ static void TextEntryMode(int16_t startspr) alphidx = i; basetile = t; if (spcgap[i] == 0) - spcgap[i] = 3*tilesizx[t]/2; + spcgap[i] = 3*tilesiz[t].x/2; goto ENDFOR1; } } @@ -3894,8 +3894,8 @@ ENDFOR1: Bmemcpy(sp, &sprite[startspr], sizeof(spritetype)); sp->yoffset = 0; sp->picnum = SMALLFNTCURSOR; - sp->xrepeat = clamp(sp->xrepeat/tilesizx[sp->picnum], 2, 255); - sp->yrepeat = clamp((sp->yrepeat*tilesizy[sprite[startspr].picnum])/tilesizy[sp->picnum], 4, 255); + sp->xrepeat = clamp(sp->xrepeat/tilesiz[sp->picnum].x, 2, 255); + sp->yrepeat = clamp((sp->yrepeat*tilesiz[sprite[startspr].picnum].y)/tilesiz[sp->picnum].y, 4, 255); sp->pal = 0; sp->cstat = 18; @@ -3966,7 +3966,7 @@ ENDFOR1: daang = sp->ang; } - j = sp->xrepeat*(hgap+tilesizx[sp->picnum]+2); + j = sp->xrepeat*(hgap+tilesiz[sp->picnum].x+2); { vec3_t vect; vect.x = dax + ((j*sintable[daang])>>17); @@ -3981,7 +3981,7 @@ ENDFOR1: // mapping char->tilenum t = alphabets[alphidx].pic[ch-33]; - j = sp->xrepeat*(hgap+tilesizx[sp->picnum]+tilesizx[t]); + j = sp->xrepeat*(hgap+tilesiz[sp->picnum].x+tilesiz[t].x); dax += (j*sintable[daang])>>17; day -= (j*sintable[(daang+512)&2047])>>17; @@ -4070,13 +4070,13 @@ ENDFOR1: } else { - sprite[linebegspr].z -= ((sprite[linebegspr].yrepeat*(vgap+tilesizy[basetile]))<<2); + sprite[linebegspr].z -= ((sprite[linebegspr].yrepeat*(vgap+tilesiz[basetile].y))<<2); asksave = 1; } } else if (ch == 13) // enter { - sprite[linebegspr].z += ((sprite[linebegspr].yrepeat*(vgap+tilesizy[basetile]))<<2); + sprite[linebegspr].z += ((sprite[linebegspr].yrepeat*(vgap+tilesiz[basetile].y))<<2); curspr = linebegspr; doingspace = 0; asksave = 1; @@ -5082,7 +5082,7 @@ static void Keys3d(void) pic += dir + MAXTILES; pic %= MAXTILES; } - while (tilesizx[pic]<=0 || tilesizy[pic]<=0); + while (tilesiz[pic].x<=0 || tilesiz[pic].y<=0); AIMED_SELOVR_PICNUM = pic; if (AIMING_AT_SPRITE) @@ -6152,7 +6152,7 @@ static void Keys3d(void) updownunits = klabs(mousey); if (!AIMING_AT_SPRITE) - updownunits = klabs((int32_t)(mousey*128./tilesizy[wall[searchwall].picnum])); + updownunits = klabs((int32_t)(mousey*128./tilesiz[wall[searchwall].picnum].y)); } } else if (eitherCTRL && !eitherALT) @@ -6375,7 +6375,7 @@ static void Keys3d(void) { // world-aligned texture - if (tilesizx[tile]<=0 || tilesizy[tile]<=0) + if (tilesiz[tile].x<=0 || tilesiz[tile].y<=0) { message("Can't align sector %d's %s, reference sector %d's has void tile", searchsector, typestr[searchstat], tempsectornum); @@ -6708,11 +6708,11 @@ paste_ceiling_or_floor: { sprite[searchwall].picnum = temppicnum; - if (tilesizx[temppicnum] <= 0 || tilesizy[temppicnum] <= 0) + if (tilesiz[temppicnum].x <= 0 || tilesiz[temppicnum].y <= 0) { j = 0; for (k=0; k 0 && tilesizy[k] > 0) + if (tilesiz[k].x > 0 && tilesiz[k].y > 0) { j = k; break; @@ -10181,7 +10181,7 @@ void ExtPreCheckKeys(void) // just before drawrooms if (frames==5) picnum+=(((totalclock>>5)%5))*5; } - if (tilesizx[picnum] == 0) + if (tilesiz[picnum].x == 0) picnum -= 5; //Hack, for actors } break; @@ -10196,7 +10196,7 @@ void ExtPreCheckKeys(void) // just before drawrooms shade = 6; } - ovhscrcoords(sprite[i].x, sprite[i].y-(tilesizy[picnum]<<2), &xp1, &yp1); + ovhscrcoords(sprite[i].x, sprite[i].y-(tilesiz[picnum].y<<2), &xp1, &yp1); ydim16 = ydim-STATUS2DSIZ2; // XXX? @@ -10400,7 +10400,7 @@ void ExtAnalyzeSprites(int32_t ourx, int32_t oury, int32_t oura, int32_t smoothr if (frames==4) tspr->picnum += (((4-(totalclock>>5)))&3)*5; if (frames==5) tspr->picnum += ((totalclock>>5)%5)*5; - if (tilesizx[tspr->picnum] == 0) + if (tilesiz[tspr->picnum].x == 0) tspr->picnum -= 5; //Hack, for actors } break; diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index 87b20ee47..b1d1b9f93 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -279,8 +279,8 @@ int32_t textsc(int32_t sc) static void G_PatchStatusBar(int32_t x1, int32_t y1, int32_t x2, int32_t y2) { int32_t scl = sbarsc(65536); - int32_t tx = sbarx16((160<<16) - (tilesizx[BOTTOMSTATUSBAR]<<15)); // centered - int32_t ty = sbary(200-tilesizy[BOTTOMSTATUSBAR]); + int32_t tx = sbarx16((160<<16) - (tilesiz[BOTTOMSTATUSBAR].x<<15)); // centered + int32_t ty = sbary(200-tilesiz[BOTTOMSTATUSBAR].y); int32_t clx1 = sbarsc(scale(x1,xdim,320)), cly1 = sbarsc(scale(y1,ydim,200)); int32_t clx2 = sbarsc(scale(x2,xdim,320)), cly2 = sbarsc(scale(y2,ydim,200)); @@ -524,7 +524,7 @@ vec2_t G_ScreenTextSize(const int32_t font, space = '\x7F'; // tile after '~' tile = G_GetStringTile(font, &space, f); - extent.x += (tilesizx[tile] * z); + extent.x += (tilesiz[tile].x * z); } // prepare the height // near-CODEDUP the other two near-CODEDUPs for this section @@ -538,7 +538,7 @@ vec2_t G_ScreenTextSize(const int32_t font, line = '\x7F'; // tile after '~' tile = G_GetStringTile(font, &line, f); - tempyextent += tilesizy[tile] * z; + tempyextent += tilesiz[tile].y * z; } SetIfGreater(&extent.y, tempyextent); @@ -569,7 +569,7 @@ vec2_t G_ScreenTextSize(const int32_t font, line = '\x7F'; // tile after '~' tile = G_GetStringTile(font, &line, f); - tempyextent += tilesizy[tile] * z; + tempyextent += tilesiz[tile].y * z; } SetIfGreater(&extent.y, tempyextent); @@ -590,17 +590,17 @@ vec2_t G_ScreenTextSize(const int32_t font, default: // width - extent.x = tilesizx[tile] * z; + extent.x = tilesiz[tile].x * z; // obnoxious hardcoded functionality from gametext if (NUMHACKACTIVE) { char numeral = '0'; // this is subject to change as an implementation detail - extent.x = (tilesizx[G_GetStringTile(font, &numeral, f)]-1) * z; + extent.x = (tilesiz[G_GetStringTile(font, &numeral, f)].x-1) * z; } // height - SetIfGreater(&extent.y, (tilesizy[tile] * z)); + SetIfGreater(&extent.y, (tilesiz[tile].y * z)); break; } @@ -659,7 +659,7 @@ vec2_t G_ScreenTextSize(const int32_t font, line = '\x7F'; // tile after '~' tile = G_GetStringTile(font, &line, f); - tempyextent += tilesizy[tile] * z; + tempyextent += tilesiz[tile].y * z; } SetIfGreater(&extent.y, tempyextent); @@ -932,7 +932,7 @@ vec2_t G_ScreenText(const int32_t font, space = '\x7F'; // tile after '~' tile = G_GetStringTile(font, &space, f); - extent.x += (tilesizx[tile] * z); + extent.x += (tilesiz[tile].x * z); } // prepare the height // near-CODEDUP the other two near-CODEDUPs for this section @@ -946,7 +946,7 @@ vec2_t G_ScreenText(const int32_t font, line = '\x7F'; // tile after '~' tile = G_GetStringTile(font, &line, f); - tempyextent += tilesizy[tile] * z; + tempyextent += tilesiz[tile].y * z; } SetIfGreater(&extent.y, tempyextent); @@ -972,7 +972,7 @@ vec2_t G_ScreenText(const int32_t font, line = '\x7F'; // tile after '~' tile = G_GetStringTile(font, &line, f); - tempyextent += tilesizy[tile] * z; + tempyextent += tilesiz[tile].y * z; } SetIfGreater(&extent.y, tempyextent); @@ -1016,17 +1016,17 @@ vec2_t G_ScreenText(const int32_t font, default: // width - extent.x = tilesizx[tile] * z; + extent.x = tilesiz[tile].x * z; // obnoxious hardcoded functionality from gametext if (NUMHACKACTIVE) { char numeral = '0'; // this is subject to change as an implementation detail - extent.x = (tilesizx[G_GetStringTile(font, &numeral, f)]-1) * z; + extent.x = (tilesiz[G_GetStringTile(font, &numeral, f)].x-1) * z; } // height - SetIfGreater(&extent.y, (tilesizy[tile] * z)); + SetIfGreater(&extent.y, (tilesiz[tile].y * z)); break; } @@ -1082,7 +1082,7 @@ vec2_t G_ScreenText(const int32_t font, line = '\x7F'; // tile after '~' tile = G_GetStringTile(font, &line, f); - tempyextent += tilesizy[tile] * z; + tempyextent += tilesiz[tile].y * z; } SetIfGreater(&extent.y, tempyextent); @@ -1764,7 +1764,7 @@ static void G_DrawAltDigiNum(int32_t x, int32_t y, int32_t n, char s, int32_t cs for (k=i-1; k>=0; k--) { p = althud_numbertile + b[k]-'0'; - j += tilesizx[p]+1; + j += tilesiz[p].x+1; } c = x-(j>>1); @@ -1776,7 +1776,7 @@ static void G_DrawAltDigiNum(int32_t x, int32_t y, int32_t n, char s, int32_t cs if (shd && getrendermode() >= REND_POLYMOST && althud_shadows) rotatesprite_fs(sbarxr(c+j-1),sbary(y+1),sbscale,0,p,127,4,cs|POLYMOSTTRANS2); rotatesprite_fs(sbarxr(c+j),sbary(y),sbscale,0,p,s,althud_numberpal,cs); - j -= tilesizx[p]+1; + j -= tilesiz[p].x+1; } return; } @@ -1788,7 +1788,7 @@ static void G_DrawAltDigiNum(int32_t x, int32_t y, int32_t n, char s, int32_t cs if (shd && getrendermode() >= REND_POLYMOST && althud_shadows) rotatesprite_fs(sbarx(c+j+1),sbary(y+1),sbscale,0,p,127,4,cs|POLYMOSTTRANS2); rotatesprite_fs(sbarx(c+j),sbary(y),sbscale,0,p,s,althud_numberpal,cs); - j += tilesizx[p]+1; + j += tilesiz[p].x+1; } } @@ -1825,14 +1825,14 @@ static void G_DrawInventory(const DukePlayer_t *p) y = 172<<16; if (ud.screen_size == 4 && ud.althud == 1) // modern mini-HUD - y -= invensc(tilesizy[BIGALPHANUM]+10); // slide on the y-axis + y -= invensc(tilesiz[BIGALPHANUM].y+10); // slide on the y-axis } else // full HUD { - y = (200<<16) - (sbarsc(tilesizy[BOTTOMSTATUSBAR]<<16) + (12<<16) + (tilesizy[BOTTOMSTATUSBAR]<<(16-1))); + y = (200<<16) - (sbarsc(tilesiz[BOTTOMSTATUSBAR].y<<16) + (12<<16) + (tilesiz[BOTTOMSTATUSBAR].y<<(16-1))); if (!ud.statusbarmode) // original non-overlay mode - y += sbarsc(tilesizy[BOTTOMSTATUSBAR]<<16)>>1; // account for the viewport y-size as the HUD scales + y += sbarsc(tilesiz[BOTTOMSTATUSBAR].y<<16)>>1; // account for the viewport y-size as the HUD scales } if (ud.screen_size == 4 && !ud.althud) // classic mini-HUD @@ -1975,7 +1975,7 @@ static void G_DrawStatusBar(int32_t snum) const int32_t althud = ud.althud; #endif - const int32_t SBY = (200-tilesizy[BOTTOMSTATUSBAR]); + const int32_t SBY = (200-tilesiz[BOTTOMSTATUSBAR].y); const int32_t sb15 = sbarsc(32768), sb15h = sbarsc(49152); const int32_t sb16 = sbarsc(65536); @@ -3127,7 +3127,7 @@ static void G_DrawOverheadMap(int32_t cposx, int32_t cposy, int32_t czoom, int16 l = spr->xrepeat; dax = sintable[k&2047]*l; day = sintable[(k+1536)&2047]*l; - l = tilesizx[tilenum]; + l = tilesiz[tilenum].x; k = (l>>1)+xoff; x1 -= mulscale16(dax,k); x2 = x1+mulscale16(dax,l); @@ -3160,9 +3160,9 @@ static void G_DrawOverheadMap(int32_t cposx, int32_t cposy, int32_t czoom, int16 k = spr->ang; cosang = sintable[(k+512)&2047]; sinang = sintable[k&2047]; - xspan = tilesizx[tilenum]; + xspan = tilesiz[tilenum].x; xrepeat = spr->xrepeat; - yspan = tilesizy[tilenum]; + yspan = tilesiz[tilenum].y; yrepeat = spr->yrepeat; dax = ((xspan>>1)+xoff)*xrepeat; @@ -3232,8 +3232,8 @@ static void G_DrawOverheadMap(int32_t cposx, int32_t cposy, int32_t czoom, int16 { if (wal->nextwall >= 0) continue; - if (tilesizx[wal->picnum] == 0) continue; - if (tilesizy[wal->picnum] == 0) continue; + if (tilesiz[wal->picnum].x == 0) continue; + if (tilesiz[wal->picnum].y == 0) continue; if (j == k) { @@ -3320,7 +3320,7 @@ void G_GetCrosshairColor(void) ptr = (char *)waloff[CROSSHAIR]; } - ii = tilesizx[CROSSHAIR]*tilesizy[CROSSHAIR]; + ii = tilesiz[CROSSHAIR].x * tilesiz[CROSSHAIR].y; if (ii <= 0) return; @@ -3358,7 +3358,7 @@ void G_SetCrosshairColor(int32_t r, int32_t g, int32_t b) ptr = (char *)waloff[CROSSHAIR]; } - ii = tilesizx[CROSSHAIR]*tilesizy[CROSSHAIR]; + ii = tilesiz[CROSSHAIR].x * tilesiz[CROSSHAIR].y; if (ii <= 0) return; if (getrendermode() == REND_CLASSIC) @@ -3845,10 +3845,10 @@ void G_DisplayRest(int32_t smoothratio) { if (ud.althud == 2) i = 2; - else i = sbarsc(ud.althud?tilesizy[BIGALPHANUM]+10:tilesizy[INVENTORYBOX]+2); + else i = sbarsc(ud.althud ? tilesiz[BIGALPHANUM].y+10 : tilesiz[INVENTORYBOX].y+2); } else if (ud.screen_size > 2) - i = sbarsc(tilesizy[BOTTOMSTATUSBAR]+1); + i = sbarsc(tilesiz[BOTTOMSTATUSBAR].y+1); else i = 2; @@ -4016,7 +4016,7 @@ void G_DrawBackground(void) flushperms(); - if (tilesizx[dapicnum] == 0 || tilesizy[dapicnum] == 0) + if (tilesiz[dapicnum].x == 0 || tilesiz[dapicnum].y == 0) { pus = pub = NUMPAGES; return; @@ -4035,7 +4035,7 @@ void G_DrawBackground(void) else { const int32_t MENUTILE = MENUSCREEN;//(getrendermode() == REND_CLASSIC ? MENUSCREEN : LOADSCREEN); - const int32_t fstilep = tilesizx[MENUTILE]>=320 && tilesizy[MENUTILE]==200; + const int32_t fstilep = tilesiz[MENUTILE].x>=320 && tilesiz[MENUTILE].y==200; int32_t bgtile = (fstilep ? MENUTILE : BIGHOLE); clearallviews(0); @@ -4052,35 +4052,35 @@ void G_DrawBackground(void) #endif { if ((unsigned)bgtile < MAXTILES) - for (y=y1; y 8) { // across top - for (y=0; y> 1; - for (y=y2-y2%tilesizy[dapicnum]; y>1; x+=tilesizx[dapicnum]) + for (y=y2-y2%tilesiz[dapicnum].y; y>1; x+=tilesiz[dapicnum].x) { rotatesprite(x<<16,y<<16,65536L,0,dapicnum,8,0,8+16+64,0,y2,x2,ydim-1); rotatesprite((xdim-x)<<16,y<<16,65536L,0,dapicnum,8,0,8+16+64,xdim-x2-1,y2,xdim-1,ydim-1); @@ -4110,7 +4110,7 @@ void G_DrawBackground(void) x1 = max(windowx1-4,0); y1 = max(windowy1-4,y); x2 = min(windowx2+4,xdim-1); - y2 = min(windowy2+4,scale(ydim,200-sbarsc(tilesizy[BOTTOMSTATUSBAR]),200)-1); + y2 = min(windowy2+4,scale(ydim,200-sbarsc(tilesiz[BOTTOMSTATUSBAR].y),200)-1); for (y=y1+4; y> 8; newz = - ((pix_diff / 128) + 1) * (128<<8); @@ -4231,7 +4231,7 @@ static void G_SE40(int32_t smoothratio) renderz = sprite[sprite2].z; picnum = sector[sprite[sprite2].sectnum].floorpicnum; sector[sprite[sprite2].sectnum].floorpicnum = 562; - tilesizx[562] = tilesizy[562] = 0; + tilesiz[562].x = tilesiz[562].y = 0; pix_diff = klabs(z) >> 8; newz = ((pix_diff / 128) + 1) * (128<<8); @@ -5861,7 +5861,7 @@ int32_t A_Spawn(int32_t j, int32_t pn) case EXPLOSION2__STATIC: if (sp->yrepeat > 32) { - G_AddGameLight(0, i, ((sp->yrepeat*tilesizy[sp->picnum])<<1), 32768, 255+(95<<8),PR_LIGHT_PRIO_MAX_GAME); + G_AddGameLight(0, i, ((sp->yrepeat*tilesiz[sp->picnum].y)<<1), 32768, 255+(95<<8),PR_LIGHT_PRIO_MAX_GAME); actor[i].lightcount = 2; } case EXPLOSION2BOT__STATIC: @@ -7812,7 +7812,7 @@ PALONLY: // XXX: t->picnum can be out-of-bounds by bad user code. if (l > 0) - while (tilesizx[t->picnum] == 0 && t->picnum > 0) + while (tilesiz[t->picnum].x == 0 && t->picnum > 0) t->picnum -= l; //Hack, for actors if (actor[i].dispicnum >= 0) @@ -11043,7 +11043,7 @@ static void G_Startup(void) ReadSaveGameHeaders(); - tilesizx[MIRROR] = tilesizy[MIRROR] = 0; + tilesiz[MIRROR].x = tilesiz[MIRROR].y = 0; screenpeek = myconnectindex; diff --git a/polymer/eduke32/source/gameexec.c b/polymer/eduke32/source/gameexec.c index 449348bb7..36dcd4bf3 100644 --- a/polymer/eduke32/source/gameexec.c +++ b/polymer/eduke32/source/gameexec.c @@ -1483,7 +1483,7 @@ skip_check: vm.g_sp->xrepeat += ksgn(j); if ((vm.g_sp->picnum == APLAYER && vm.g_sp->yrepeat < 36) || *insptr < vm.g_sp->yrepeat || - ((vm.g_sp->yrepeat*(tilesizy[vm.g_sp->picnum]+8))<<2) < (actor[vm.g_i].floorz - actor[vm.g_i].ceilingz)) + ((vm.g_sp->yrepeat*(tilesiz[vm.g_sp->picnum].y+8))<<2) < (actor[vm.g_i].floorz - actor[vm.g_i].ceilingz)) { j = ((*insptr)-vm.g_sp->yrepeat)<<1; if (klabs(j)) vm.g_sp->yrepeat += ksgn(j); diff --git a/polymer/eduke32/source/gamestructures.c b/polymer/eduke32/source/gamestructures.c index 350787aff..4e8daf037 100644 --- a/polymer/eduke32/source/gamestructures.c +++ b/polymer/eduke32/source/gamestructures.c @@ -2668,7 +2668,7 @@ static void __fastcall VM_SetSprite(int32_t lVar1, int32_t lLabelID, int32_t lVa return; case ACTOR_ALPHA: - spriteext[iActor].alpha=(float)(lVar1/255.0f); + spriteext[iActor].alpha=(float)lVar1 * (1.f/255.0f); return; default: diff --git a/polymer/eduke32/source/gamevars.c b/polymer/eduke32/source/gamevars.c index 7e4bfdb9b..b8b693c25 100644 --- a/polymer/eduke32/source/gamevars.c +++ b/polymer/eduke32/source/gamevars.c @@ -1451,8 +1451,8 @@ static void Gv_AddSystemVars(void) # endif // SYSTEM_GAMEARRAY - Gv_NewArray("tilesizx", (void *)tilesizx, MAXTILES, GAMEARRAY_READONLY|GAMEARRAY_OFSHORT); - Gv_NewArray("tilesizy", (void *)tilesizy, MAXTILES, GAMEARRAY_READONLY|GAMEARRAY_OFSHORT); + Gv_NewArray("tilesizx", NULL/*(void *)tilesizx*/, MAXTILES, GAMEARRAY_READONLY|GAMEARRAY_OFSHORT); + Gv_NewArray("tilesizy", NULL/*(void *)tilesizy*/, MAXTILES, GAMEARRAY_READONLY|GAMEARRAY_OFSHORT); #endif } diff --git a/polymer/eduke32/source/m32common.c b/polymer/eduke32/source/m32common.c index bd0d55543..61b23cc88 100644 --- a/polymer/eduke32/source/m32common.c +++ b/polymer/eduke32/source/m32common.c @@ -1679,7 +1679,7 @@ static int32_t correct_picnum(int16_t *picnumptr) { int32_t picnum = *picnumptr; - if ((unsigned)picnum >= MAXTILES || tilesizx[picnum] <= 0) + if ((unsigned)picnum >= MAXTILES || tilesiz[picnum].x <= 0) { *picnumptr = 0; return 1; diff --git a/polymer/eduke32/source/m32vars.c b/polymer/eduke32/source/m32vars.c index cb6215657..b55b9ca9d 100644 --- a/polymer/eduke32/source/m32vars.c +++ b/polymer/eduke32/source/m32vars.c @@ -674,8 +674,8 @@ static void Gv_AddSystemVars(void) Gv_NewArray("headsectbunchf", (void *)headsectbunch[1], YAX_MAXBUNCHES, GAMEARRAY_READONLY|GAMEARRAY_OFSHORT); Gv_NewArray("nextsectbunchf", (void *)nextsectbunch[1], MAXSECTORS, GAMEARRAY_READONLY|GAMEARRAY_OFSHORT); #endif - Gv_NewArray("tilesizx", (void *)tilesizx, MAXTILES, GAMEARRAY_READONLY|GAMEARRAY_OFSHORT); - Gv_NewArray("tilesizy", (void *)tilesizy, MAXTILES, GAMEARRAY_READONLY|GAMEARRAY_OFSHORT); +// Gv_NewArray("tilesizx", (void *)tilesizx, MAXTILES, GAMEARRAY_READONLY|GAMEARRAY_OFSHORT); +// Gv_NewArray("tilesizy", (void *)tilesizy, MAXTILES, GAMEARRAY_READONLY|GAMEARRAY_OFSHORT); // Gv_NewArray("picsiz", (void *)picsiz, MAXTILES, GAMEARRAY_READONLY|GAMEARRAY_OFCHAR); Gv_NewArray("picanm", (void *)picanm, MAXTILES, GAMEARRAY_READONLY|GAMEARRAY_OFINT); diff --git a/polymer/eduke32/source/menus.c b/polymer/eduke32/source/menus.c index de883d2b5..c9ea9e55c 100644 --- a/polymer/eduke32/source/menus.c +++ b/polymer/eduke32/source/menus.c @@ -1765,7 +1765,7 @@ static void M_PreMenuDraw(MenuID_t cm, MenuGroup_t *group, MenuEntry_t *entry) break; case MENU_PLAYER: - rotatesprite_fs((260)<<16,(24+(tilesizy[APLAYER]>>1))<<16,49152L,0,1441-((((4-(totalclock>>4)))&3)*5),0,entry == &ME_PLAYER_TEAM ? G_GetTeamPalette(ud.team) : ud.color,10); + rotatesprite_fs((260)<<16,(24+(tilesiz[APLAYER].y>>1))<<16,49152L,0,1441-((((4-(totalclock>>4)))&3)*5),0,entry == &ME_PLAYER_TEAM ? G_GetTeamPalette(ud.team) : ud.color,10); break; case MENU_MACROS: @@ -3548,17 +3548,17 @@ static int32_t M_RunMenu_MenuMenu(MenuMenu_t *menu, MenuEntry_t *currentry, int3 MenuRangeInt32_t *object = (MenuRangeInt32_t*)entry->entry; int32_t s, p; - const int32_t z = scale(65536, height, tilesizy[SLIDEBAR]<<16); + const int32_t z = scale(65536, height, tilesiz[SLIDEBAR].y<<16); M_ShadePal(object->font, status, &s, &p); if (status & (1<<3)) - x -= scale(tilesizx[SLIDEBAR]<<16, height, tilesizy[SLIDEBAR]<<16); + x -= scale(tilesiz[SLIDEBAR].x<<16, height, tilesiz[SLIDEBAR].y<<16); rotatesprite_fs(x, y - menu->scrollPos, z, 0, SLIDEBAR, s, entry->disabled ? 1 : 0, 2|8|16|ROTATESPRITE_FULL16); rotatesprite_fs( - x + (1<<16) + scale(scale((tilesizx[SLIDEBAR]-2-tilesizx[SLIDEBAR+1])<<16, height, tilesizy[SLIDEBAR]<<16), *object->variable - object->min, object->max - object->min), - y + scale((tilesizy[SLIDEBAR]-tilesizy[SLIDEBAR+1])<<15, height, tilesizy[SLIDEBAR]<<16) - menu->scrollPos, + x + (1<<16) + scale(scale((tilesiz[SLIDEBAR].x-2-tilesiz[SLIDEBAR+1].x)<<16, height, tilesiz[SLIDEBAR].y<<16), *object->variable - object->min, object->max - object->min), + y + scale((tilesiz[SLIDEBAR].y-tilesiz[SLIDEBAR+1].y)<<15, height, tilesiz[SLIDEBAR].y<<16) - menu->scrollPos, z, 0, SLIDEBAR+1, s, entry->disabled ? 1 : 0, 2|8|16|ROTATESPRITE_FULL16); if (object->displaytype > 0) @@ -3594,17 +3594,17 @@ static int32_t M_RunMenu_MenuMenu(MenuMenu_t *menu, MenuEntry_t *currentry, int3 MenuRangeFloat_t *object = (MenuRangeFloat_t*)entry->entry; int32_t s, p; - const int32_t z = scale(65536, height, tilesizy[SLIDEBAR]<<16); + const int32_t z = scale(65536, height, tilesiz[SLIDEBAR].y<<16); M_ShadePal(object->font, status, &s, &p); if (status & (1<<3)) - x -= scale(tilesizx[SLIDEBAR]<<16, height, tilesizy[SLIDEBAR]<<16); + x -= scale(tilesiz[SLIDEBAR].x<<16, height, tilesiz[SLIDEBAR].y<<16); rotatesprite_fs(x, y - menu->scrollPos, z, 0, SLIDEBAR, s, p, 2|8|16|ROTATESPRITE_FULL16); rotatesprite_fs( - x + (1<<16) + ((float) scale((tilesizx[SLIDEBAR]-2-tilesizx[SLIDEBAR+1])<<16, height, tilesizy[SLIDEBAR]<<16) * (*object->variable - object->min) / (object->max - object->min)), - y + scale((tilesizy[SLIDEBAR]-tilesizy[SLIDEBAR+1])<<15, height, tilesizy[SLIDEBAR]<<16) - menu->scrollPos, + x + (1<<16) + ((float) scale((tilesiz[SLIDEBAR].x-2-tilesiz[SLIDEBAR+1].x)<<16, height, tilesiz[SLIDEBAR].y<<16) * (*object->variable - object->min) / (object->max - object->min)), + y + scale((tilesiz[SLIDEBAR].y-tilesiz[SLIDEBAR+1].y)<<15, height, tilesiz[SLIDEBAR].y<<16) - menu->scrollPos, z, 0, SLIDEBAR+1, s, p, 2|8|16|ROTATESPRITE_FULL16); if (object->displaytype > 0) @@ -3640,17 +3640,17 @@ static int32_t M_RunMenu_MenuMenu(MenuMenu_t *menu, MenuEntry_t *currentry, int3 MenuRangeDouble_t *object = (MenuRangeDouble_t*)entry->entry; int32_t s, p; - const int32_t z = scale(65536, height, tilesizy[SLIDEBAR]<<16); + const int32_t z = scale(65536, height, tilesiz[SLIDEBAR].y<<16); M_ShadePal(object->font, status, &s, &p); if (status & (1<<3)) - x -= scale(tilesizx[SLIDEBAR]<<16, height, tilesizy[SLIDEBAR]<<16); + x -= scale(tilesiz[SLIDEBAR].x<<16, height, tilesiz[SLIDEBAR].y<<16); rotatesprite_fs(x, y - menu->scrollPos, z, 0, SLIDEBAR, s, p, 2|8|16|ROTATESPRITE_FULL16); rotatesprite_fs( - x + (1<<16) + ((double) scale((tilesizx[SLIDEBAR]-2-tilesizx[SLIDEBAR+1])<<16, height, tilesizy[SLIDEBAR]<<16) * (*object->variable - object->min) / (object->max - object->min)), - y + scale((tilesizy[SLIDEBAR]-tilesizy[SLIDEBAR+1])<<15, height, tilesizy[SLIDEBAR]<<16) - menu->scrollPos, + x + (1<<16) + ((double) scale((tilesiz[SLIDEBAR].x-2-tilesiz[SLIDEBAR+1].x)<<16, height, tilesiz[SLIDEBAR].y<<16) * (*object->variable - object->min) / (object->max - object->min)), + y + scale((tilesiz[SLIDEBAR].y-tilesiz[SLIDEBAR+1].y)<<15, height, tilesiz[SLIDEBAR].y<<16) - menu->scrollPos, z, 0, SLIDEBAR+1, s, p, 2|8|16|ROTATESPRITE_FULL16); if (object->displaytype > 0) @@ -3690,7 +3690,7 @@ static int32_t M_RunMenu_MenuMenu(MenuMenu_t *menu, MenuEntry_t *currentry, int3 const vec2_t dim = M_MenuText(x, y + (height>>1), object->font, object->editfield, status | (1<<5)); const int32_t h = max(dim.y, entry->font->yline); - rotatesprite_fs(x + dim.x + (1<<16) + scale(tilesizx[SPINNINGNUKEICON]<<15, h, tilesizy[SPINNINGNUKEICON]<<16), y + (height>>1) - menu->scrollPos, scale(65536, h, tilesizy[SPINNINGNUKEICON]<<16), 0, SPINNINGNUKEICON+(((totalclock>>3))%7), cursorShade, 0, 10); + rotatesprite_fs(x + dim.x + (1<<16) + scale(tilesiz[SPINNINGNUKEICON].x<<15, h, tilesiz[SPINNINGNUKEICON].y<<16), y + (height>>1) - menu->scrollPos, scale(65536, h, tilesiz[SPINNINGNUKEICON].y<<16), 0, SPINNINGNUKEICON+(((totalclock>>3))%7), cursorShade, 0, 10); } else M_MenuText(x, y + (height>>1) - menu->scrollPos, object->font, object->variable, status); @@ -3715,8 +3715,8 @@ static int32_t M_RunMenu_MenuMenu(MenuMenu_t *menu, MenuEntry_t *currentry, int3 // draw indicators if applicable if (totalextent > menu->bottomcutoff) { - rotatesprite((320 - tilesizx[SELECTDIR])<<16, menu->ytop, 65536, 0, SELECTDIR, menu->scrollPos > 0 ? 0 : 20, 0, 26, 0, 0, xdim-1, scale(ydim, menu->ytop + (tilesizy[SELECTDIR]<<15), 200<<16) - 1); - rotatesprite((320 - tilesizx[SELECTDIR])<<16, menu->bottomcutoff - (tilesizy[SELECTDIR]<<16), 65536, 0, SELECTDIR, menu->ytop + menu->totalHeight - menu->scrollPos > menu->bottomcutoff ? 0 : 20, 0, 26, 0, scale(ydim, menu->bottomcutoff - (tilesizy[SELECTDIR]<<15), 200<<16), xdim-1, ydim-1); + rotatesprite((320 - tilesiz[SELECTDIR].x)<<16, menu->ytop, 65536, 0, SELECTDIR, menu->scrollPos > 0 ? 0 : 20, 0, 26, 0, 0, xdim-1, scale(ydim, menu->ytop + (tilesiz[SELECTDIR].y<<15), 200<<16) - 1); + rotatesprite((320 - tilesiz[SELECTDIR].x)<<16, menu->bottomcutoff - (tilesiz[SELECTDIR].y<<16), 65536, 0, SELECTDIR, menu->ytop + menu->totalHeight - menu->scrollPos > menu->bottomcutoff ? 0 : 20, 0, 26, 0, scale(ydim, menu->bottomcutoff - (tilesiz[SELECTDIR].y<<15), 200<<16), xdim-1, ydim-1); } return menu->totalHeight; @@ -3775,8 +3775,8 @@ static void M_RunMenu_MenuOptionList(MenuOption_t *object) // draw indicators if applicable if (y > object->options->list->bottomcutoff) { - rotatesprite((320 - tilesizx[SELECTDIR])<<16, object->options->list->pos.y, 65536, 0, SELECTDIR, object->options->scrollPos > 0 ? 0 : 20, 0, 26, 0, 0, xdim-1, scale(ydim, object->options->list->pos.y + (tilesizy[SELECTDIR]<<15), 200<<16) - 1); - rotatesprite((320 - tilesizx[SELECTDIR])<<16, object->options->list->bottomcutoff - (tilesizy[SELECTDIR]<<16), 65536, 0, SELECTDIR, y - object->options->scrollPos > object->options->list->bottomcutoff ? 0 : 20, 0, 26, 0, scale(ydim, object->options->list->bottomcutoff - (tilesizy[SELECTDIR]<<15), 200<<16), xdim-1, ydim-1); + rotatesprite((320 - tilesiz[SELECTDIR].x)<<16, object->options->list->pos.y, 65536, 0, SELECTDIR, object->options->scrollPos > 0 ? 0 : 20, 0, 26, 0, 0, xdim-1, scale(ydim, object->options->list->pos.y + (tilesiz[SELECTDIR].y<<15), 200<<16) - 1); + rotatesprite((320 - tilesiz[SELECTDIR].x)<<16, object->options->list->bottomcutoff - (tilesiz[SELECTDIR].y<<16), 65536, 0, SELECTDIR, y - object->options->scrollPos > object->options->list->bottomcutoff ? 0 : 20, 0, 26, 0, scale(ydim, object->options->list->bottomcutoff - (tilesiz[SELECTDIR].y<<15), 200<<16), xdim-1, ydim-1); } } diff --git a/polymer/eduke32/source/net.c b/polymer/eduke32/source/net.c index 763aac26d..ebab91469 100644 --- a/polymer/eduke32/source/net.c +++ b/polymer/eduke32/source/net.c @@ -1844,7 +1844,7 @@ void Net_SendMessage(void) { const vec2_t dim = G_ScreenTextSize(STARTALPHANUM, i, 0, textsc(65536), 0, typebuf, 8|16|ROTATESPRITE_FULL16, 5<<16, 7<<16, 0, 0, TEXT_LITERALESCAPE, 0, 0, xdim-1, ydim-1); - l = i + dim.x + scale(textsc((tilesizx[SPINNINGNUKEICON]+2)<<13), ydim, 200); + l = i + dim.x + scale(textsc((tilesiz[SPINNINGNUKEICON].x+2)<<13), ydim, 200); } if (l >= (xdim<<16)) @@ -1853,7 +1853,7 @@ void Net_SendMessage(void) { const vec2_t dim = G_ScreenText(STARTALPHANUM, i, j, textsc(65536), 0, 0, typebuf, 1, 0, 8|16|ROTATESPRITE_FULL16, 0, 5<<16, 7<<16, 0, 0, TEXT_YCENTER|TEXT_LITERALESCAPE, 0, 0, xdim-1, ydim-1); - i += dim.x + scale(textsc((tilesizx[SPINNINGNUKEICON]+1)<<12), ydim, 200); + i += dim.x + scale(textsc((tilesiz[SPINNINGNUKEICON].x+1)<<12), ydim, 200); } rotatesprite_fs(i, j, textsc(32768), 0, SPINNINGNUKEICON+((totalclock>>3)%7), 4-(sintable[(totalclock<<4)&2047]>>11), 0, 0); diff --git a/polymer/eduke32/source/player.c b/polymer/eduke32/source/player.c index dd9373cbf..feb1601c7 100644 --- a/polymer/eduke32/source/player.c +++ b/polymer/eduke32/source/player.c @@ -366,7 +366,7 @@ static int32_t GetAutoAimAngle(int32_t i, int32_t p, int32_t atwith, if (j >= 0) { const spritetype *const spr = &sprite[j]; - int32_t cen = 2*(spr->yrepeat*tilesizy[spr->picnum]) + cen_add; + int32_t cen = 2*(spr->yrepeat*tilesiz[spr->picnum].y) + cen_add; int32_t dst; if (flags) @@ -1049,12 +1049,12 @@ static int32_t A_ShootCustom(const int32_t i, const int32_t atwith, int16_t sa, proj->range = 1024; if (Proj_CheckBlood(srcvect, &hit, proj->range, - mulscale3(proj->yrepeat, tilesizy[proj->decal]) << 8)) + mulscale3(proj->yrepeat, tilesiz[proj->decal].y) << 8)) { const walltype *const hitwal = &wall[hit.wall]; if (FindDistance2D(hitwal->x - wall[hitwal->point2].x, hitwal->y - wall[hitwal->point2].y) > - (mulscale3(proj->xrepeat + 8, tilesizx[proj->decal]))) + (mulscale3(proj->xrepeat + 8, tilesiz[proj->decal].x))) { if (SectorContainsSE13(hitwal->nextsector)) return -1; @@ -1136,7 +1136,7 @@ int32_t A_ShootWithZvel(int32_t i, int32_t atwith, int32_t override_zvel) { sa = s->ang; Bmemcpy(&srcvect,s,sizeof(vec3_t)); - srcvect.z -= (((s->yrepeat*tilesizy[s->picnum])<<1)-(4<<8)); + srcvect.z -= (((s->yrepeat*tilesiz[s->picnum].y)<<1)-(4<<8)); if (s->picnum != ROTATEGUN) { @@ -2003,10 +2003,10 @@ void P_DisplayScuba(int32_t snum) g_snum = snum; #ifdef USE_OPENGL if (getrendermode() >= REND_POLYMOST) - G_DrawTileScaled(44, (200-tilesizy[SCUBAMASK]), SCUBAMASK, 0, 2+16+DRAWEAP_CENTER, p); + G_DrawTileScaled(44, (200-tilesiz[SCUBAMASK].y), SCUBAMASK, 0, 2+16+DRAWEAP_CENTER, p); #endif - G_DrawTileScaled(43, (200-tilesizy[SCUBAMASK]), SCUBAMASK, 0, 2+16+DRAWEAP_CENTER, p); - G_DrawTileScaled(320-43, (200-tilesizy[SCUBAMASK]), SCUBAMASK, 0, 2+4+16+DRAWEAP_CENTER, p); + G_DrawTileScaled(43, (200-tilesiz[SCUBAMASK].y), SCUBAMASK, 0, 2+16+DRAWEAP_CENTER, p); + G_DrawTileScaled(320-43, (200-tilesiz[SCUBAMASK].y), SCUBAMASK, 0, 2+4+16+DRAWEAP_CENTER, p); } } diff --git a/polymer/eduke32/source/premap.c b/polymer/eduke32/source/premap.c index f658b93a4..13df5b482 100644 --- a/polymer/eduke32/source/premap.c +++ b/polymer/eduke32/source/premap.c @@ -553,7 +553,7 @@ void G_CacheMapData(void) void G_SetupCamTile(int32_t i,int32_t wn) { //if (waloff[wn] == 0) loadtile(wn); - setviewtotile(wn,tilesizy[wn],tilesizx[wn]); + setviewtotile(wn,tilesiz[wn].y, tilesiz[wn].x); yax_preparedrawrooms(); drawrooms(SX,SY,SZ,SA,100+sprite[i].shade,SECT); @@ -601,7 +601,7 @@ void G_UpdateScreenArea(void) } if (ud.screen_size >= 8 && ud.statusbarmode==0) - y2 -= (ss+scale(tilesizy[BOTTOMSTATUSBAR],ud.statusbarscale,100)); + y2 -= (ss+scale(tilesiz[BOTTOMSTATUSBAR].y,ud.statusbarscale,100)); y1 = scale(y1,ydim,200); y2 = scale(y2,ydim,200)+(getrendermode() != REND_CLASSIC); diff --git a/polymer/eduke32/source/savegame.c b/polymer/eduke32/source/savegame.c index dbab83b84..a109329f3 100644 --- a/polymer/eduke32/source/savegame.c +++ b/polymer/eduke32/source/savegame.c @@ -195,8 +195,8 @@ int32_t G_LoadSaveHeaderNew(int32_t spot, savehead_t *saveh) walock[TILE_LOADSHOT] = 255; if (waloff[TILE_LOADSHOT] == 0) allocache(&waloff[TILE_LOADSHOT], 320*200, &walock[TILE_LOADSHOT]); - tilesizx[TILE_LOADSHOT] = 200; - tilesizy[TILE_LOADSHOT] = 320; + tilesiz[TILE_LOADSHOT].x = 200; + tilesiz[TILE_LOADSHOT].y = 320; if (screenshotofs) { if (kdfread((char *)waloff[TILE_LOADSHOT], 320, 200, fil) != 200) diff --git a/polymer/eduke32/source/sector.c b/polymer/eduke32/source/sector.c index cd1a5c10a..c6360948c 100644 --- a/polymer/eduke32/source/sector.c +++ b/polymer/eduke32/source/sector.c @@ -382,7 +382,7 @@ void G_AnimateCamSprite(void) else if (OW >= 0 && dist(&sprite[ps->i], &sprite[i]) < 8192) { if (waloff[TILE_VIEWSCR] == 0) - allocatepermanenttile(TILE_VIEWSCR,tilesizx[PN],tilesizy[PN]); + allocatepermanenttile(TILE_VIEWSCR,tilesiz[PN].x,tilesiz[PN].y); else walock[TILE_VIEWSCR] = 255;