diff --git a/polymer/eduke32/build/include/build.h b/polymer/eduke32/build/include/build.h index 7a14e37bd..21d1e7de6 100644 --- a/polymer/eduke32/build/include/build.h +++ b/polymer/eduke32/build/include/build.h @@ -676,8 +676,8 @@ int32_t wallvisible(int32_t x, int32_t y, int16_t wallnum); #define STATUS2DSIZ 144 #define STATUS2DSIZ2 26 -void qsetmode640350(void); -void qsetmode640480(void); +//void qsetmode640350(void); +//void qsetmode640480(void); void qsetmodeany(int32_t,int32_t); void clear2dscreen(void); void draw2dgrid(int32_t posxe, int32_t posye, int32_t posze, int16_t cursectnum, int16_t ange, int32_t zoome, int16_t gride); diff --git a/polymer/eduke32/build/include/editor.h b/polymer/eduke32/build/include/editor.h index cf21b44cf..63e582ec3 100644 --- a/polymer/eduke32/build/include/editor.h +++ b/polymer/eduke32/build/include/editor.h @@ -79,7 +79,7 @@ extern int32_t pk_turnaccel,pk_turndecel,pk_uedaccel; extern int32_t revertCTRL,scrollamount; extern int32_t autosave; extern int32_t mlook; -extern int16_t prefixtiles[16]; +extern int16_t prefixtiles[10]; extern int32_t numsprites; extern int32_t showfirstwall; diff --git a/polymer/eduke32/build/src/build.c b/polymer/eduke32/build/src/build.c index 82050d566..ae0928bb8 100644 --- a/polymer/eduke32/build/src/build.c +++ b/polymer/eduke32/build/src/build.c @@ -122,10 +122,10 @@ static int32_t currentlist=0; static int32_t fillist[640]; // used for fillsector and point selection in side-view mode: -static int32_t tempxyar[MAXWALLS][2]; +static int32_t tempxyar[MAXWALLS][2] ATTRIBUTE((aligned(8))); static int32_t mousx, mousy; -int16_t prefixtiles[16] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; +int16_t prefixtiles[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; uint8_t hlsectorbitmap[MAXSECTORS>>3]; // show2dsector is already taken... static uint8_t visited[MAXWALLS>>3]; // used for AlignWalls and trace_loop @@ -2228,10 +2228,9 @@ void bfirst_search_init(int16_t *list, uint8_t *bitmap, int32_t *eltnumptr, int3 { Bmemset(bitmap, 0, (maxnum+7)>>3); - *eltnumptr = 0; - list[*eltnumptr] = firstelt; - bitmap[*eltnumptr>>3] |= (1<<(*eltnumptr&7)); - (*eltnumptr)++; + list[0] = firstelt; + bitmap[firstelt>>3] |= (1<<(firstelt&7)); + *eltnumptr = 1; } void bfirst_search_try(int16_t *list, uint8_t *bitmap, int32_t *eltnumptr, int16_t elt) @@ -2248,13 +2247,27 @@ void bfirst_search_try(int16_t *list, uint8_t *bitmap, int32_t *eltnumptr, int16 } #ifdef YAX_ENABLE -// whether all highlighted sectors are in one connected component -// wrt the nextsector relation -static int32_t highlighted_sectors_in_one_component() +static int32_t collnumsects[2]; +static int16_t collsectlist[2][MAXSECTORS]; +static uint8_t collsectbitmap[2][MAXSECTORS>>3]; + +static void collect_sectors1(int16_t *sectlist, uint8_t *sectbitmap, int32_t *numsectptr, int16_t startsec) { - int32_t j, k, startwall, endwall, sectcnt, sectnum; - static int16_t sectlist[MAXSECTORS]; - static uint8_t sectbitmap[MAXSECTORS>>3]; + int32_t j, startwall, endwall, sectcnt; + + bfirst_search_init(sectlist, sectbitmap, numsectptr, MAXSECTORS, startsec); + + for (sectcnt=0; sectcnt<*numsectptr; sectcnt++) + for (WALLS_OF_SECTOR(sectlist[sectcnt], j)) + bfirst_search_try(sectlist, sectbitmap, numsectptr, wall[j].nextsector); +} + +// whether all highlighted sectors are in one (returns 1), two (2) +// or more (>2) connected components wrt the nextsector relation +// -1 means error +static int32_t highlighted_sectors_components(void) +{ + int32_t j, k, tmp; if (highlightsectorcnt<1) return 0; @@ -2262,21 +2275,54 @@ static int32_t highlighted_sectors_in_one_component() if (highlightsectorcnt==1) return 1; - bfirst_search_init(sectlist, sectbitmap, §num, MAXSECTORS, highlightsector[0]); - - for (sectcnt=0; sectcnt>3]&(1<<(j&7)))==0) - return 0; + if ((collsectbitmap[0][j>>3]&(1<<(j&7)))==0) + { + // sector j not collected --> more than 1 conn. comp. + collect_sectors1(collsectlist[1], collsectbitmap[1], &collnumsects[1], j); + break; + } } - return 1; + if (k == highlightsectorcnt) + return 1; + + for (k=0; k>3]&(1<<(j&7)))!=0) + (((collsectbitmap[1][j>>3]&(1<<(j&7)))!=0)<<1)); + + if (tmp==3) + return -1; // components only weakly connected + + if (tmp==0) + return 3; // sector j not reached + } + + return 2; } + +#if 0 +static int cmpgeomwal1(const int16_t *w1, const int16_t *w2) +{ + const walltype *wal1 = &wall[*w1]; + const walltype *wal2 = &wall[*w2]; + + if (wal1->x == wal2->x) + return wal1->y - wal2->y; + + return wal1->x - wal2->x; +} + +static void sort_walls_geometrically(int16_t *wallist, int32_t nwalls) +{ + qsort(wallist, nwalls, sizeof(int16_t), (int(*)(const void *, const void *))&cmpgeomwal1); +} +#endif #endif void overheadeditor(void) @@ -2303,7 +2349,6 @@ void overheadeditor(void) m32_setkeyfilter(1); - //qsetmode640480(); qsetmodeany(xdim2d,ydim2d); xdim2d = xdim; ydim2d = ydim; @@ -3125,7 +3170,7 @@ void overheadeditor(void) goto end_yax; } - if (!highlighted_sectors_in_one_component()) + if (highlighted_sectors_components() != 1) { message("Sectors to extend must be in one connected component"); goto end_yax; @@ -3239,7 +3284,7 @@ void overheadeditor(void) update_highlightsector(); message("Extended %ss of highlighted sectors, creating bunch %d", - cfs[cf], numyaxbunches); + cfs[cf], numyaxbunches-1); asksave = 1; end_yax: ; } @@ -4223,6 +4268,126 @@ end_point_dragging: goto end_join_sectors; } +#if 0 +//def YAX_ENABLE + if (highlightsectorcnt > 0 && eitherCTRL) + { + // [component][ceiling(0) or floor(1)] + // compstat: &1: "has extension", &2: "differ in z", &4: "sloped" + int32_t cf, comp, compstat[2][2]={{0,0},{0,0}}, compcfz[2][2]; + + // joinstat: + // &1: ceil(comp 0) <-> flor(comp 1), &2: flor(comp 0) <-> ceil(comp 1) + // (doesn't yet say which is stationary) + int32_t joinstat, needsdisp, dx,dy,dz; + + // tempxyar: int32_t [MAXWALLS][2] + int32_t numouterwalls[2] = {0,0}, numowals; + int16_t *const outerwall[2] = { (int16_t *)tempxyar, ((int16_t *)tempxyar)+MAXWALLS }; + const walltype *wal0, *wal1; + + // join sector ceilings/floors to a new bunch + if (numyaxbunches==YAX_MAXBUNCHES) + { + message("Bunch limit of %d reached, cannot join", YAX_MAXBUNCHES); + goto end_join_sectors; + } + + // first, see whether we have exactly two connected components + // wrt wall[].nextsector + if (highlighted_sectors_components() != 2) + { + message("Sectors must be partitioned in two components to join"); + goto end_join_sectors; + } + + for (k=0; k>3]&(1<<(j&7))); + + for (cf=0; cf<2; cf++) + { + if (k==0) + compcfz[comp][cf] = SECTORFLD(j,z, cf); + + if (yax_getbunch(j, cf)>=0) + compstat[comp][cf] |= 1; + if (SECTORFLD(j,z, cf) != compcfz[comp][cf]) + compstat[comp][cf] |= 2; + if (SECTORFLD(j,stat, cf)&2) + compstat[comp][cf] |= 4; + + compcfz[comp][cf] = SECTORFLD(j,z, cf); + } + } + + // check for consistency + joinstat = 0; + if (!compstat[0][YAX_CEILING] && !compstat[1][YAX_FLOOR]) + joinstat |= 1; + if (!compstat[0][YAX_FLOOR] && !compstat[1][YAX_CEILING]) + joinstat |= 2; + + if (joinstat==0) + { + message("No consistent joining combination found"); + goto end_join_sectors; + } + if (joinstat==3) + { + if (compcfz[0][YAX_CEILING] != compstat[1][YAX_FLOOR]) + joinstat &= 1; + if (compcfz[0][YAX_CEILING] != compstat[1][YAX_FLOOR]) + joinstat &= 2; + + if (joinstat == 0) + joinstat = 3; // we couldn't disambiguate + } + + for (comp=0; comp<2; comp++) + for (k=0; kx - wal0->x; + dy = wal1->y - wal0->y; + } + + if (wal1->x - wal0->x != dx || wal1->y - wal0->y != dy || + wall[wal1->point2].x - wall[wal0->point2].x != dx || + wall[wal1->point2].y - wall[wal0->point2].y != dy) + { + message("Outer wall coordinates must coincide for both components"); + goto end_join_sectors; + } + } + } + else +#endif // defined YAX_ENABLE if (joinsector[0] < 0) { joinsector[0] = -1; @@ -6547,6 +6712,10 @@ static int32_t deletesector(int16_t sucksect) endwall = startwall + sector[sucksect].wallnum - 1; j = sector[sucksect].wallnum; +#ifdef YAX_ENABLE + yax_setbunches(sucksect, -1, -1); +#endif + for (i=sucksect; i= 0) { NEXTWALL(i).nextwall = -1; NEXTWALL(i).nextsector = -1; } + } movewalls(startwall, -j); for (i=0; i>3, (signed)sizeof(cbuf)-1); i++) + cbuf[i] = ' '; + cbuf[i] = 0; + printext256(0, 0, whitecol, 0, cbuf, 0); +} + +// sign: |16: don't draw scene int32_t _getnumber256(const char *namestart, int32_t num, int32_t maxnumber, char sign, void *(func)(int32_t)) { char buffer[80], ch; int32_t danum, oldnum; - uint8_t flags = (sign>>1)&3; + uint8_t flags = (sign>>1)&(3|8); sign &= 1; danum = num; @@ -6946,22 +7128,25 @@ int32_t _getnumber256(const char *namestart, int32_t num, int32_t maxnumber, cha if (handleevents()) quitevent = 0; - yax_preparedrawrooms(); - drawrooms(pos.x,pos.y,pos.z,ang,horiz,cursectnum); - yax_drawrooms(ExtAnalyzeSprites, horiz, cursectnum); - - ExtAnalyzeSprites(); - drawmasks(); - -#ifdef POLYMER - if (rendmode == 4 && searchit == 2) + if ((flags&8)==0) { - polymer_editorpick(); + yax_preparedrawrooms(); drawrooms(pos.x,pos.y,pos.z,ang,horiz,cursectnum); + yax_drawrooms(ExtAnalyzeSprites, horiz, cursectnum); + ExtAnalyzeSprites(); drawmasks(); - } + +#ifdef POLYMER + if (rendmode == 4 && searchit == 2) + { + polymer_editorpick(); + drawrooms(pos.x,pos.y,pos.z,ang,horiz,cursectnum); + ExtAnalyzeSprites(); + drawmasks(); + } #endif + } ch = bgetchar(); if (keystatus[0x1]) @@ -6972,7 +7157,10 @@ int32_t _getnumber256(const char *namestart, int32_t num, int32_t maxnumber, cha searchx = osearchx; searchy = osearchy; - ExtCheckKeys(); + if ((flags&8)==0) + ExtCheckKeys(); + + getnumber_clearline(); Bsprintf(buffer,"%s%d",namestart,danum); if (totalclock & 32) Bstrcat(buffer,"_ "); @@ -6986,7 +7174,7 @@ int32_t _getnumber256(const char *namestart, int32_t num, int32_t maxnumber, cha showframe(1); if (getnumber_internal1(ch, &danum, maxnumber, sign) || - getnumber_autocomplete(namestart, ch, &danum, flags)) + getnumber_autocomplete(namestart, ch, &danum, flags&(1+2))) { if (danum != oldnum) asksave = 1; @@ -7041,14 +7229,7 @@ const char *getstring_simple(const char *querystr, const char *defaultstr, int32 while (1) { if (qsetmode==200) - { - char cbuf[128]; - int32_t i; - for (i=0; i>3, (signed)sizeof(cbuf)-1); i++) - cbuf[i] = ' '; - cbuf[i] = 0; - printext256(0, 0, whitecol, 0, cbuf, 0); - } + getnumber_clearline(); if (qsetmode==200) printext256(0, 0, whitecol, 0, buf, 0); diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index 8fbde1a7a..9f90885d4 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -188,16 +188,6 @@ int16_t editstatus = 0; ////////// YAX ////////// -#ifdef YAX_DEBUG -extern char m32_debugstr[64][128]; -extern int32_t m32_numdebuglines; -# define yaxdebug(fmt, ...) do { if (m32_numdebuglines<64) Bsnprintf(m32_debugstr[m32_numdebuglines++], 128, fmt, ##__VA_ARGS__); } while (0) -# define yaxprintf(fmt, ...) do { initprintf(fmt, ##__VA_ARGS__); } while (0) -#else -# define yaxdebug(fmt, ...) -# define yaxprintf(fmt, ...) -#endif - uint8_t graysectbitmap[MAXSECTORS>>3]; uint8_t graywallbitmap[MAXWALLS>>3]; int32_t autogray = 0; @@ -263,7 +253,7 @@ void yax_updategrays(int32_t posze) // get/set functions! static int32_t g_nodraw = 0; -static int32_t scansector_retfast = 0; +int32_t scansector_retfast = 0; static int32_t scansector_collectsprites = 1; static int32_t yax_globalcf = -1; static int32_t yax_globallev = YAX_MAXDRAWS; @@ -317,11 +307,17 @@ void yax_setbunch(int16_t i, int16_t cf, int16_t bunchnum) if (bunchnum<0) { int32_t j; + int16_t ynw; + // TODO: for in-game too? for (j=sector[i].wallptr; j= 0) + { + yax_setnextwall(ynw, !cf, -1); + yax_setnextwall(j, cf, -1); + } } *(§or[i].ceilingstat + cf) &= ~YAX_BIT; @@ -608,7 +604,12 @@ static void yax_scanbunches(int32_t bbeg, int32_t numhere, const uint8_t *lastgo if (checkthisec) { numscans = numbunches = 0; - scansector(k); + if (getrendermode()==0) + scansector(k); +#ifdef USE_OPENGL + else + polymost_scansector(k); +#endif if (numbunches > 0) { bestsec = k; @@ -705,9 +706,10 @@ static void yax_copytsprite(int32_t curbunchnum, int32_t resetsortcnt) } } + void yax_preparedrawrooms(void) { - if (getrendermode()!=0 || numyaxbunches==0) + if (getrendermode()==4 || numyaxbunches==0) return; g_nodraw = 1; @@ -745,7 +747,7 @@ void yax_drawrooms(void (*ExtAnalyzeSprites)(void), int32_t horiz, int16_t sectn int32_t t; #endif - if (getrendermode()!=0 || numyaxbunches==0) + if (getrendermode()==4 || numyaxbunches==0) { #ifdef ENGINE_SCREENSHOT_DEBUG engine_screenshot = 0; @@ -872,13 +874,19 @@ void yax_drawrooms(void (*ExtAnalyzeSprites)(void), int32_t horiz, int16_t sectn scansector_collectsprites = 0; #ifdef ENGINE_CLEAR_SCREEN - if (rendmode==0) + if (getrendermode()==0) { begindrawing(); - for (i=0; i= MAXSPRITESONSCREEN) + return 1; + + copybufbyte(spr,&tsprite[spritesortcnt],sizeof(spritetype)); + spriteext[z].tspr = (spritetype *)&tsprite[spritesortcnt]; + tsprite[spritesortcnt++].owner = z; +#ifdef YAX_ENABLE + } + else + { + sortcnt = &yax_spritesortcnt[yax_globallev]; + if (*sortcnt >= MAXSPRITESONSCREEN) + return 0; + + yax_tsprite[yax_globallev][*sortcnt] = z; + (*sortcnt)++; + + // now check whether the tsprite needs duplication into another level + if ((spr->cstat&48)==32) + return 0; + + yax_getbunches(sectnum, &cb, &fb); + if (cb < 0 && fb < 0) + return 0; + + spriteheightofs(z, &spheight, &spzofs); + + // TODO: get*zofslope? + if (cb>=0 && spr->z+spzofs-spheight < sector[sectnum].ceilingz) + { + sortcnt = &yax_spritesortcnt[yax_globallev-1]; + if (*sortcnt < MAXSPRITESONSCREEN) + { + yax_tsprite[yax_globallev-1][*sortcnt] = z|MAXSPRITES; + (*sortcnt)++; + } + } + if (fb>=0 && spr->z+spzofs > sector[sectnum].floorz) + { + sortcnt = &yax_spritesortcnt[yax_globallev+1]; + if (*sortcnt < MAXSPRITESONSCREEN) + { + yax_tsprite[yax_globallev+1][*sortcnt] = z|(MAXSPRITES<<1); + (*sortcnt)++; + } + } + } +#endif + + return 0; +} + // // scansector (internal) // @@ -2088,10 +2160,6 @@ static void scansector(int16_t sectnum) int32_t xs, ys, x1, y1, x2, y2, xp1, yp1, xp2=0, yp2=0, tempint; int16_t z, zz, startwall, endwall, numscansbefore, scanfirst, bunchfrst; int16_t nextsectnum; -#ifdef YAX_ENABLE - int16_t cb, fb, *sortcnt; - int32_t spheight, spzofs; -#endif if (sectnum < 0) return; @@ -2112,60 +2180,8 @@ static void scansector(int16_t sectnum) { xs = spr->x-globalposx; ys = spr->y-globalposy; if ((spr->cstat&48) || (xs*cosglobalang+ys*singlobalang > 0)) - { -#ifdef YAX_ENABLE - if (g_nodraw==0) - { -#endif - if (spritesortcnt >= MAXSPRITESONSCREEN) - break; - - copybufbyte(spr,&tsprite[spritesortcnt],sizeof(spritetype)); - spriteext[z].tspr = (spritetype *)&tsprite[spritesortcnt]; - tsprite[spritesortcnt++].owner = z; -#ifdef YAX_ENABLE - } - else - { - sortcnt = &yax_spritesortcnt[yax_globallev]; - if (*sortcnt >= MAXSPRITESONSCREEN) - break; - - yax_tsprite[yax_globallev][*sortcnt] = z; - (*sortcnt)++; - - // now check whether the tsprite needs duplication into another level - if ((spr->cstat&48)==32) - continue; - - yax_getbunches(sectnum, &cb, &fb); - if (cb < 0 && fb < 0) - continue; - - spriteheightofs(z, &spheight, &spzofs); - - // TODO: get*zofslope? - if (cb>=0 && spr->z+spzofs-spheight < sector[sectnum].ceilingz) - { - sortcnt = &yax_spritesortcnt[yax_globallev-1]; - if (*sortcnt < MAXSPRITESONSCREEN) - { - yax_tsprite[yax_globallev-1][*sortcnt] = z|MAXSPRITES; - (*sortcnt)++; - } - } - if (fb>=0 && spr->z+spzofs > sector[sectnum].floorz) - { - sortcnt = &yax_spritesortcnt[yax_globallev+1]; - if (*sortcnt < MAXSPRITESONSCREEN) - { - yax_tsprite[yax_globallev+1][*sortcnt] = z|(MAXSPRITES<<1); - (*sortcnt)++; - } - } - } -#endif - } + if (engine_addtsprite(z, sectnum)) + break; } } @@ -6979,6 +6995,19 @@ static void loadpalette(void) kread(fil,palookup[globalpal],numpalookups<<8); kread(fil,transluc,65536); + + if (crc32once((uint8_t *)transluc, 65536)==0x94a1fac6) + { + int32_t i; + // fix up translucency table so that transluc(255,x) + // and transluc(x,255) is black instead of purple + for (i=0; i<256; i++) + { + transluc[(255<<8) + i] = transluc[i]; + transluc[255 + (i<<8)] = transluc[i<<8]; + } + } + kclose(fil); initfastcolorlookup(30L,59L,11L); @@ -7676,7 +7705,7 @@ void drawrooms(int32_t daposx, int32_t daposy, int32_t daposz, if (!g_nodraw) #endif if (numyaxbunches==0) - for (i=0; ix-globalposx; ys = tspriteptr[i]->y-globalposy; yp = dmulscale6(xs,cosviewingrangeglobalang,ys,sinviewingrangeglobalang); +#ifdef USE_OPENGL + modelp = (usemodels && tile2model[tspriteptr[i]->picnum].modelid >= 0); +#endif if (yp > (4<<8)) { xp = dmulscale6(ys,cosglobalang,-xs,singlobalang); @@ -7975,12 +8007,15 @@ void drawmasks(void) else if ((tspriteptr[i]->cstat&48) == 0) { killsprite: - spritesortcnt--; //Delete face sprite if on wrong side! - if (i == spritesortcnt) continue; - tspriteptr[i] = tspriteptr[spritesortcnt]; - spritesx[i] = spritesx[spritesortcnt]; - spritesy[i] = spritesy[spritesortcnt]; - continue; + if (!modelp) + { + spritesortcnt--; //Delete face sprite if on wrong side! + if (i == spritesortcnt) continue; + tspriteptr[i] = tspriteptr[spritesortcnt]; + spritesx[i] = spritesx[spritesortcnt]; + spritesy[i] = spritesy[spritesortcnt]; + continue; + } } spritesy[i] = yp; } @@ -13725,7 +13760,7 @@ void drawcircle16(int32_t x1, int32_t y1, int32_t r, int32_t eccen, char col) } } - +#if 0 // // qsetmode640350 // @@ -13787,7 +13822,7 @@ void qsetmode640480(void) qsetmode = 480; } - +#endif // // qsetmodeany diff --git a/polymer/eduke32/build/src/engine_priv.h b/polymer/eduke32/build/src/engine_priv.h index 4bc54b8ec..873b91ca9 100644 --- a/polymer/eduke32/build/src/engine_priv.h +++ b/polymer/eduke32/build/src/engine_priv.h @@ -70,6 +70,24 @@ extern palette_t palookupfog[MAXPALOOKUPS]; int32_t wallfront(int32_t l1, int32_t l2); int32_t animateoffs(int16_t tilenum, int16_t fakevar); +////// yax'y stuff ////// +#ifdef USE_OPENGL +extern void polymost_scansector(int32_t sectnum); +#endif +int32_t engine_addtsprite(int16_t z, int16_t sectnum); +int32_t scansector_retfast; + +#ifdef YAX_DEBUG +extern char m32_debugstr[64][128]; +extern int32_t m32_numdebuglines; +# define yaxdebug(fmt, ...) do { if (m32_numdebuglines<64) Bsnprintf(m32_debugstr[m32_numdebuglines++], 128, fmt, ##__VA_ARGS__); } while (0) +# define yaxprintf(fmt, ...) do { initprintf(fmt, ##__VA_ARGS__); } while (0) +#else +# define yaxdebug(fmt, ...) +# define yaxprintf(fmt, ...) +#endif + + extern int32_t indrawroomsandmasks; diff --git a/polymer/eduke32/build/src/polymost.c b/polymer/eduke32/build/src/polymost.c index fb63a68ea..0872ac76f 100644 --- a/polymer/eduke32/build/src/polymost.c +++ b/polymer/eduke32/build/src/polymost.c @@ -3066,7 +3066,7 @@ void domost(float x0, float y0, float x1, float y1) } } -static void polymost_scansector(int32_t sectnum); +void polymost_scansector(int32_t sectnum); // variables that are set to ceiling- or floor-members, depending // on which one is processed right now @@ -3219,6 +3219,10 @@ static void polymost_drawalls(int32_t bunch) int32_t i, x, y, z, cz, fz, wallnum, sectnum, nextsectnum; int32_t ypan,yoffs; // for panning correction + int16_t dapskybits; + static const int16_t zeropskyoff[MAXPSKYTILES]; + const int16_t *dapskyoff; + sectnum = thesector[bunchfirst[bunch]]; sec = §or[sectnum]; #if 0 // USE_OPENGL @@ -3289,17 +3293,36 @@ static void polymost_drawalls(int32_t bunch) cy1 = ((float)(cz-globalposz))*ryp1 + ghoriz; fy1 = ((float)(fz-globalposz))*ryp1 + ghoriz; - globalpicnum = sec->floorpicnum; globalshade = sec->floorshade; globalpal = (int32_t)((uint8_t)sec->floorpal); globalorientation = sec->floorstat; if (picanm[globalpicnum]&192) globalpicnum += animateoffs(globalpicnum,sectnum); + // multi-psky stuff + dapskyoff = zeropskyoff; + dapskybits = pskybits; + + for (i=0; ifloorshade, global_cf_pal = sec->floorpal; global_cf_z = sec->floorz; // REFACT global_cf_xpanning = sec->floorxpanning; global_cf_ypanning = sec->floorypanning, global_cf_heinum = sec->floorheinum; global_getzofslope_func = &getflorzofslope; if (!(globalorientation&1)) - polymost_internal_nonparallaxed(nx0, ny0, nx1, ny1, ryp0, ryp1, x0, x1, fy0, fy1, 1, sectnum); + { +#ifdef YAX_ENABLE + if (globalposz <= sec->floorz || yax_getbunch(sectnum, YAX_FLOOR) < 0 || yax_getnextwall(wallnum, YAX_FLOOR) >= 0) +#endif + polymost_internal_nonparallaxed(nx0, ny0, nx1, ny1, ryp0, ryp1, x0, x1, fy0, fy1, 1, sectnum); + } else if ((nextsectnum < 0) || (!(sector[nextsectnum].floorstat&1))) { //Parallaxing sky... hacked for Ken's mountain texture; paper-sky only :/ @@ -3321,15 +3344,15 @@ static void polymost_drawalls(int32_t bunch) } //Use clamping for tiled sky textures - for (i=(1<0; i--) - if (pskyoff[i] != pskyoff[i-1]) + for (i=(1<0; i--) + if (dapskyoff[i] != dapskyoff[i-1]) { skyclamphack = r_parallaxskyclamping; break; } } #endif if (bpp == 8 || !usehightile || !hicfindsubst(globalpicnum,globalpal,1)) { dd[0] = (float)xdimen*.0000001; //Adjust sky depth based on screen size! - t = (double)((1<<(picsiz[globalpicnum]&15))<>1)+parallaxyoffs)) - vv[1]*ghoriz; i = (1<<(picsiz[globalpicnum]>>4)); if (i != tilesizy[globalpicnum]) i += i; @@ -3364,20 +3387,19 @@ static void polymost_drawalls(int32_t bunch) i = globalpicnum; r = (fy1-fy0)/(x1-x0); //slope of line oy = ((double)viewingrange)/(ghalfx*256.0); oz = 1/oy; - y = ((((int32_t)((x0-ghalfx)*oy))+globalang)>>(11-pskybits)); + y = ((((int32_t)((x0-ghalfx)*oy))+globalang)>>(11-dapskybits)); fx = x0; do { - globalpicnum = pskyoff[y&((1<floorxpanning:0)) - gux*ghalfx; + globalpicnum = dapskyoff[y&((1<floorxpanning:0)) - gux*ghalfx; y++; - ox = fx; fx = ((double)((y<<(11-pskybits))-globalang))*oz+ghalfx; + ox = fx; fx = ((double)((y<<(11-dapskybits))-globalang))*oz+ghalfx; if (fx > x1) { fx = x1; i = -1; } pow2xsplit = 0; domost(ox,(ox-x0)*r+fy0,fx,(fx-x0)*r+fy0); //flor } while (i >= 0); - } else //NOTE: code copied from ceiling code... lots of duplicated stuff :/ { @@ -3567,12 +3589,32 @@ static void polymost_drawalls(int32_t bunch) globalorientation = sec->ceilingstat; if (picanm[globalpicnum]&192) globalpicnum += animateoffs(globalpicnum,sectnum); + // multi-psky stuff + dapskyoff = zeropskyoff; + dapskybits = pskybits; + + for (i=0; iceilingshade, global_cf_pal = sec->ceilingpal; global_cf_z = sec->ceilingz; // REFACT global_cf_xpanning = sec->ceilingxpanning; global_cf_ypanning = sec->ceilingypanning, global_cf_heinum = sec->ceilingheinum; global_getzofslope_func = &getceilzofslope; if (!(globalorientation&1)) - polymost_internal_nonparallaxed(nx0, ny0, nx1, ny1, ryp0, ryp1, x0, x1, cy0, cy1, 0, sectnum); + { +#ifdef YAX_ENABLE + if (globalposz >= sec->ceilingz || yax_getbunch(sectnum, YAX_CEILING) < 0 || yax_getnextwall(wallnum, YAX_CEILING) >= 0) +#endif + polymost_internal_nonparallaxed(nx0, ny0, nx1, ny1, ryp0, ryp1, x0, x1, cy0, cy1, 0, sectnum); + } else if ((nextsectnum < 0) || (!(sector[nextsectnum].ceilingstat&1))) { #ifdef USE_OPENGL @@ -3592,8 +3634,8 @@ static void polymost_drawalls(int32_t bunch) bglFogfv(GL_FOG_COLOR,fogcol); } //Use clamping for tiled sky textures - for (i=(1<0; i--) - if (pskyoff[i] != pskyoff[i-1]) + for (i=(1<0; i--) + if (dapskyoff[i] != dapskyoff[i-1]) { skyclamphack = r_parallaxskyclamping; break; } } #endif @@ -3602,7 +3644,7 @@ static void polymost_drawalls(int32_t bunch) { //Render for parallaxtype == 0 / paper-sky dd[0] = (float)xdimen*.0000001; //Adjust sky depth based on screen size! - t = (double)((1<<(picsiz[globalpicnum]&15))<>1)+parallaxyoffs)) - vv[1]*ghoriz; i = (1<<(picsiz[globalpicnum]>>4)); if (i != tilesizy[globalpicnum]) i += i; @@ -3636,14 +3678,14 @@ static void polymost_drawalls(int32_t bunch) i = globalpicnum; r = (cy1-cy0)/(x1-x0); //slope of line oy = ((double)viewingrange)/(ghalfx*256.0); oz = 1/oy; - y = ((((int32_t)((x0-ghalfx)*oy))+globalang)>>(11-pskybits)); + y = ((((int32_t)((x0-ghalfx)*oy))+globalang)>>(11-dapskybits)); fx = x0; do { - globalpicnum = pskyoff[y&((1<ceilingxpanning:0)) - gux*ghalfx; + globalpicnum = dapskyoff[y&((1<ceilingxpanning:0)) - gux*ghalfx; y++; - ox = fx; fx = ((double)((y<<(11-pskybits))-globalang))*oz+ghalfx; + ox = fx; fx = ((double)((y<<(11-dapskybits))-globalang))*oz+ghalfx; if (fx > x1) { fx = x1; i = -1; } pow2xsplit = 0; domost(fx,(fx-x0)*r+cy0,ox,(ox-x0)*r+cy0); //ceil } @@ -4068,7 +4110,7 @@ static int32_t polymost_bunchfront(int32_t b1, int32_t b2) return(wallfront(i,b2f)); } -static void polymost_scansector(int32_t sectnum) +void polymost_scansector(int32_t sectnum) { double d, xp1, yp1, xp2, yp2; walltype *wal, *wal2; @@ -4088,15 +4130,13 @@ static void polymost_scansector(int32_t sectnum) { spr = &sprite[z]; if ((((spr->cstat&0x8000) == 0) || (showinvisibility)) && - (spr->xrepeat > 0) && (spr->yrepeat > 0) && - (spritesortcnt < MAXSPRITESONSCREEN)) + (spr->xrepeat > 0) && (spr->yrepeat > 0)) { xs = spr->x-globalposx; ys = spr->y-globalposy; - if ((spr->cstat&48) || (xs*gcosang+ys*gsinang > 0)) + if ((spr->cstat&48) || (xs*gcosang+ys*gsinang > 0) || (usemodels && tile2model[spr->picnum].modelid>=0)) { - copybufbyte(spr,&tsprite[spritesortcnt],sizeof(spritetype)); - spriteext[z].tspr = (spritetype *)&tsprite[spritesortcnt]; - tsprite[spritesortcnt++].owner = z; + if (engine_addtsprite(z, sectnum)) + break; } } } @@ -4119,7 +4159,7 @@ static void polymost_scansector(int32_t sectnum) if ((nextsectnum >= 0) && (!(wal->cstat&32)) && (!(gotsector[nextsectnum>>3]&pow2char[nextsectnum&7]))) { d = (double)x1*(double)y2 - (double)x2*(double)y1; xp1 = (double)(x2-x1); yp1 = (double)(y2-y1); - if (d *d <= (xp1*xp1 + yp1*yp1)*(SCISDIST*SCISDIST*260.0)) + if (d*d <= (xp1*xp1 + yp1*yp1)*(SCISDIST*SCISDIST*260.0)) sectorborder[sectorbordercnt++] = nextsectnum; } @@ -4152,7 +4192,13 @@ static void polymost_scansector(int32_t sectnum) for (z=numscansbefore; z dxb1[p2[z]])) - { bunchfirst[numbunches++] = p2[z]; p2[z] = -1; } + { + bunchfirst[numbunches++] = p2[z]; p2[z] = -1; +#ifdef YAX_ENABLE + if (scansector_retfast) + return; +#endif + } for (z=bunchfrst; z= '0' && ch <= '9') - { - iTemp = (iNewTile*10) + (ch-'0'); - if (iTemp < MAXTILES) - iNewTile = iTemp; - } - else if (ch == 8) - { - iNewTile /= 10; - } - else if (ch == 13) - { - iTile = iNewTile; - break; - } - } - - clearkeys(); - - return iTile; + return getnumber256("Goto tile: ", 0, MAXTILES-1, 0+2+16); } @@ -7923,14 +7883,14 @@ static void Keys2d(void) j = 0; x = wall[sector[i].wallptr].x; y = wall[sector[i].wallptr].y; - z = sector[i].floorz; + z = getflorzofslope(i, x, y); break; case CORRUPT_WALL: i = k&(MAXWALLS-1); j = 1; x = wall[i].x; y = wall[i].y; - z = sector[sectorofwall(i)].floorz; + z = getflorzofslope(sectorofwall(i), x, y); break; case CORRUPT_SPRITE: i = k&(MAXSPRITES-1); diff --git a/polymer/eduke32/source/config.c b/polymer/eduke32/source/config.c index 7f3127b31..b545f4e95 100644 --- a/polymer/eduke32/source/config.c +++ b/polymer/eduke32/source/config.c @@ -750,7 +750,7 @@ int32_t CONFIG_ReadSetup(void) Bsprintf(buf,"WeaponChoice%d",i); dummy = -1; SCRIPT_GetNumber(ud.config.scripthandle, "Misc", buf, &dummy); - if (dummy >= 0) g_player[0].wchoice[i] = dummy; + if (dummy >= 0 && dummy<10) g_player[0].wchoice[i] = dummy; } #ifdef _WIN32 diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index 558c4e8a9..16f5bb5ce 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -2533,6 +2533,27 @@ static void G_ShowScores(void) } #undef SCORESHEETOFFSET +#ifdef YAX_DEBUG +// ugh... +char m32_debugstr[64][128]; +int32_t m32_numdebuglines=0; + +static void M32_drawdebug(void) +{ + int i, col=getclosestcol(63,63,63); + int x=4, y=8; + + if (m32_numdebuglines>0) + { + begindrawing(); + for (i=0; i640?0:1); + enddrawing(); + } + m32_numdebuglines=0; +} +#endif + void G_DisplayRest(int32_t smoothratio) { int32_t a, i, j; @@ -2800,6 +2821,10 @@ void G_DisplayRest(int32_t smoothratio) if (ud.coords) G_PrintCoords(screenpeek); +#ifdef YAX_DEBUG + M32_drawdebug(); +#endif + #ifdef USE_OPENGL { extern int32_t mdpause; @@ -3473,10 +3498,17 @@ void G_DrawRooms(int32_t snum, int32_t smoothratio) j = visibility; visibility = (j>>1) + (j>>2); - yax_preparedrawrooms(); - drawrooms(tposx,tposy,ud.camera.z,tang,ud.camerahoriz,g_mirrorSector[i]+MAXSECTORS); - g_yax_smoothratio = smoothratio; - yax_drawrooms(G_AnalyzeSprites, ud.camerahoriz, g_mirrorSector[i]+MAXSECTORS); + if (getrendermode()==0) + { + yax_preparedrawrooms(); + drawrooms(tposx,tposy,ud.camera.z,tang,ud.camerahoriz,g_mirrorSector[i]+MAXSECTORS); + g_yax_smoothratio = smoothratio; + yax_drawrooms(G_AnalyzeSprites, ud.camerahoriz, g_mirrorSector[i]+MAXSECTORS); + } +#ifdef USE_OPENGL + else + drawrooms(tposx,tposy,ud.camera.z,tang,ud.camerahoriz,g_mirrorSector[i]+MAXSECTORS); +#endif display_mirror = 1; G_DoSpriteAnimations(tposx,tposy,tang,smoothratio); diff --git a/polymer/eduke32/source/gamedef.c b/polymer/eduke32/source/gamedef.c index a5869f520..088eef788 100644 --- a/polymer/eduke32/source/gamedef.c +++ b/polymer/eduke32/source/gamedef.c @@ -1856,7 +1856,7 @@ static int32_t C_CountCaseStatements() static int32_t C_ParseCommand(int32_t loop) { - int32_t i, j=0, k=0, done, tw, otw; + int32_t i, j=0, k=0, tw, otw; char *temptextptr; intptr_t *tempscrptr = NULL; diff --git a/polymer/eduke32/source/m32def.c b/polymer/eduke32/source/m32def.c index 8794a98d3..55a858209 100644 --- a/polymer/eduke32/source/m32def.c +++ b/polymer/eduke32/source/m32def.c @@ -496,6 +496,10 @@ const memberlabel_t SpriteLabels[]= { "", -1, 0, 0, 0 } // END OF LIST }; +#ifndef POLYMER +# define PR_MAXLIGHTPRIORITY 6 +#endif + const memberlabel_t LightLabels[]= { { "x", LIGHT_X, 0, -BXY_MAX, BXY_MAX }, @@ -1103,9 +1107,7 @@ static void C_GetNextVarType(int32_t type) if (*textptr == '[') //read of array as a gamevar { int32_t lLabelID = -1, aridx; -#ifdef POLYMER int32_t lightp = 0; -#endif textptr++; flags |= M32_FLAG_ARRAY; diff --git a/polymer/eduke32/source/player.c b/polymer/eduke32/source/player.c index f7b84b307..c346e983d 100644 --- a/polymer/eduke32/source/player.c +++ b/polymer/eduke32/source/player.c @@ -5355,11 +5355,7 @@ HORIZONLY: { p->pos.x += p->vel.x>>14; p->pos.y += p->vel.y>>14; -#ifdef YAX_ENABLE - updatesectorz(p->pos.x,p->pos.y,p->pos.z,&p->cursectnum); -#else updatesector(p->pos.x,p->pos.y,&p->cursectnum); -#endif changespritesect(p->i,p->cursectnum); } else