diff --git a/polymer/eduke32/build/include/build.h b/polymer/eduke32/build/include/build.h index 4aa767ed0..ad0e01804 100644 --- a/polymer/eduke32/build/include/build.h +++ b/polymer/eduke32/build/include/build.h @@ -62,16 +62,18 @@ extern "C" { #define PR_LIGHT_PRIO_LOW_GAME 5 ////////// yax defs ////////// +#define YAX_MAXBUNCHES (MAXSECTORS>>1) #define YAX_BIT 1024 -#define YAX_CEILING 0 -#define YAX_FLOOR 1 +#define YAX_CEILING 0 // don't change! +#define YAX_FLOOR 1 // don't change! -#define YAX_SECTORFLD(Sect,Fld, Cf) (*((Cf) ? (§or[Sect].floor##Fld) : (§or[Sect].ceiling##Fld))) +#define SECTORFLD(Sect,Fld, Cf) (*((Cf) ? (§or[Sect].floor##Fld) : (§or[Sect].ceiling##Fld))) int16_t yax_getbunch(int16_t i, int16_t cf); void yax_getbunches(int16_t i, int16_t *cb, int16_t *fb); void yax_setbunch(int16_t i, int16_t cf, int16_t bunchnum); void yax_setbunches(int16_t i, int16_t cb, int16_t fb); +void yax_update(int32_t onlyreset); #define CLIPMASK0 (((1L)<<16)+1L) @@ -232,6 +234,19 @@ struct validmode_t { }; EXTERN struct validmode_t validmode[MAXVALIDMODES]; +EXTERN int32_t numyaxbunches; +#ifdef YAX_ENABLE +// Singly-linked list of sectnums grouped by bunches and ceiling (0)/floor (1) +// Usage e.g.: +// int16_t bunchnum = yax_getbunch(somesector, YAX_CEILING); +// Iteration over all sectors whose floor bunchnum equals 'bunchnum' (i.e. "all +// floors of the other side"): +// for (i=headsectbunch[1][bunchnum]; i!=-1; i=nextsectbunch[1][i]) +// + +EXTERN int16_t headsectbunch[2][YAX_MAXBUNCHES], nextsectbunch[2][MAXSECTORS]; +#endif + EXTERN int16_t numsectors, numwalls; EXTERN char display_mirror; EXTERN /*volatile*/ int32_t totalclock; @@ -279,7 +294,7 @@ EXTERN int32_t windowpos, windowx, windowy; EXTERN char show2dsector[(MAXSECTORS+7)>>3]; EXTERN char show2dwall[(MAXWALLS+7)>>3]; EXTERN char show2dsprite[(MAXSPRITES+7)>>3]; -EXTERN char automapping; +//EXTERN char automapping; EXTERN char gotpic[(MAXTILES+7)>>3]; EXTERN char gotsector[(MAXSECTORS+7)>>3]; @@ -589,7 +604,7 @@ int32_t changespritesect(int16_t spritenum, int16_t newsectnum); int32_t changespritestat(int16_t spritenum, int16_t newstatnum); int32_t setsprite(int16_t spritenum, const vec3_t *new) ATTRIBUTE((nonnull(2))); -int32_t spriteheight(int16_t i, int32_t *basez); +void spriteheightofs(int16_t i, int32_t *height, int32_t *zofs); int32_t screencapture(const char *filename, char inverseit, const char *versionstr) ATTRIBUTE((nonnull(1))); @@ -640,7 +655,8 @@ int32_t animateoffs(int16_t tilenum, int16_t fakevar); void setpolymost2dview(void); // sets up GL for 2D drawing -int32_t polymost_drawtilescreen(int32_t tilex, int32_t tiley, int32_t wallnum, int32_t dimen, int32_t tilezoom); +int32_t polymost_drawtilescreen(int32_t tilex, int32_t tiley, int32_t wallnum, int32_t dimen, int32_t tilezoom, + int32_t usehitile, uint8_t *loadedhitile); void polymost_glreset(void); void polymost_precache(int32_t dapicnum, int32_t dapalnum, int32_t datype); diff --git a/polymer/eduke32/build/include/compat.h b/polymer/eduke32/build/include/compat.h index 28441a9e9..7992a28fd 100644 --- a/polymer/eduke32/build/include/compat.h +++ b/polymer/eduke32/build/include/compat.h @@ -367,7 +367,11 @@ static inline void dtol(double d, int32_t *a) # define max(a,b) ( ((a) > (b)) ? (a) : (b) ) #endif +#if __GNUC__ >= 4 +static inline __attribute__((warn_unused_result)) int clamp(int in, int min, int max) +#else static inline int clamp(int in, int min, int max) +#endif { return in <= min ? min : in >= max ? max : in; } diff --git a/polymer/eduke32/build/include/editor.h b/polymer/eduke32/build/include/editor.h index 5cfb68c2e..7f467276a 100644 --- a/polymer/eduke32/build/include/editor.h +++ b/polymer/eduke32/build/include/editor.h @@ -140,6 +140,7 @@ int32_t writesetup(const char *fn); // from config.c void editinput(void); void clearmidstatbar16(void); +void fade_editor_screen(void); int32_t _getnumber256(const char *namestart, int32_t num, int32_t maxnumber, char sign, void *(func)(int32_t)); #define getnumber256(namestart, num, maxnumber, sign) _getnumber256(namestart, num, maxnumber, sign, NULL) @@ -160,6 +161,7 @@ extern int32_t lastpm16time; extern char lastpm16buf[156]; +void spriteoncfz(int32_t i, int32_t *czptr, int32_t *fzptr); void DoSpriteOrnament(int32_t i); void getpoint(int32_t searchxe, int32_t searchye, int32_t *x, int32_t *y); @@ -237,4 +239,10 @@ static inline int32_t atoi_safe(const char *str) return (int32_t)strtol(str, NULL, 10); } +static inline void inpclamp(int32_t *x, int32_t mi, int32_t ma) +{ + if (*x>ma) *x=ma; + if (*xma) *x=ma; - if (*x 0) { - if (searchstat == 0 || searchstat == 4) + if (AIMING_AT_WALL || AIMING_AT_MASKWALL) hitinfo.pos.z &= 0xfffffc00; else locktogrid(&dax, &day); @@ -1106,17 +1146,10 @@ void editinput(void) getzsofslope(hitinfo.hitsect, hitinfo.pos.x, hitinfo.pos.y, &cz, &fz); - j = spriteheight(i, NULL)>>1; - sprite[i].z = hitinfo.pos.z; - if ((sprite[i].cstat&48)!=32) - { - if ((sprite[i].cstat&128) == 0) - bclamp(&sprite[i].z, cz+(j<<1), fz); - else - bclamp(&sprite[i].z, cz+j, fz-j); - } + spriteoncfz(i, &cz, &fz); + sprite[i].z = clamp(hitinfo.pos.z, cz, fz); - if (searchstat == 0 || searchstat == 4) + if (AIMING_AT_WALL || AIMING_AT_MASKWALL) { sprite[i].cstat &= ~48; sprite[i].cstat |= (16+64); @@ -1142,13 +1175,13 @@ void editinput(void) { switch (searchstat) { - case 1: - case 2: + case SEARCH_CEILING: + case SEARCH_FLOOR: ExtShowSectorData(searchsector); break; - case 0: - case 4: + case SEARCH_WALL: + case SEARCH_MASKWALL: ExtShowWallData(searchwall); break; - case 3: + case SEARCH_SPRITE: ExtShowSpriteData(searchwall); break; } @@ -1158,13 +1191,13 @@ void editinput(void) { switch (searchstat) { - case 1: - case 2: + case SEARCH_CEILING: + case SEARCH_FLOOR: ExtEditSectorData(searchsector); break; - case 0: - case 4: + case SEARCH_WALL: + case SEARCH_MASKWALL: ExtEditWallData(searchwall); break; - case 3: + case SEARCH_SPRITE: ExtEditSpriteData(searchwall); break; } @@ -1449,7 +1482,7 @@ static int32_t restore_highlighted_map(mapinfofull_t *mapinfo) static int32_t newnumwalls=-1; -static void ovh_whiteoutgrab() +static void ovh_whiteoutgrab(void) { int32_t i, j, k, startwall, endwall; @@ -1480,7 +1513,7 @@ static void ovh_whiteoutgrab() } } -static void duplicate_selected_sectors() +static void duplicate_selected_sectors(void) { int32_t i, j, startwall, endwall, newnumsectors, newwalls = 0; int32_t minx=INT_MAX, maxx=INT_MIN, miny=INT_MAX, maxy=INT_MIN, dx, dy; @@ -1581,7 +1614,7 @@ static void duplicate_selected_sectors() } } -static void duplicate_selected_sprites() +static void duplicate_selected_sprites(void) { int32_t i, j, k=0; @@ -1645,7 +1678,7 @@ void DoSpriteOrnament(int32_t i) correct_ornamented_sprite(i, hitinfo.hitwall); } -void update_highlight() +void update_highlight(void) { int32_t i; @@ -1666,7 +1699,7 @@ void update_highlight() highlightcnt = -1; } -void update_highlightsector() +void update_highlightsector(void) { int32_t i; @@ -1790,7 +1823,7 @@ void correct_sprite_yoffset(int32_t i) sprite[i].yoffset = 0; } -static void fade_screen() +void fade_editor_screen(void) { char blackcol=editorcolors[0], greycol=whitecol-25, *cp; int32_t i; @@ -1861,19 +1894,15 @@ static void updatesprite1(int16_t i) if (sprite[i].sectnum>=0) { - int32_t tempint, cz, fz; - tempint = spriteheight(i, NULL); - if (sprite[i].cstat&128) - tempint >>= 1; - getzsofslope(sprite[i].sectnum, sprite[i].x, sprite[i].y, &cz, &fz); - sprite[i].z = max(sprite[i].z, cz+tempint); - sprite[i].z = min(sprite[i].z, fz); + int32_t cz, fz; + spriteoncfz(i, &cz, &fz); + inpclamp(&sprite[i].z, cz, fz); } } static int32_t ask_if_sure(const char *query, uint32_t flags); #ifdef YAX_ENABLE -static int32_t ask_above_or_below(); +static int32_t ask_above_or_below(void); #endif // returns: @@ -2136,8 +2165,8 @@ void overheadeditor(void) searchx += mousx; searchy += mousy; - bclamp(&searchx, 8, xdim-8-1); - bclamp(&searchy, 8, ydim-8-1); + inpclamp(&searchx, 8, xdim-8-1); + inpclamp(&searchy, 8, ydim-8-1); mainloop_move(); @@ -2806,7 +2835,7 @@ void overheadeditor(void) if (cf==-1) goto end_yax; - thez = YAX_SECTORFLD(highlightsector[0],z, cf); + thez = SECTORFLD(highlightsector[0],z, cf); for (i=0; i= 0) @@ -2815,15 +2844,13 @@ void overheadeditor(void) goto end_yax; } - if (i==0) - continue; - - if (YAX_SECTORFLD(highlightsector[i],z, cf) != thez) + if (SECTORFLD(highlightsector[i],z, cf) != thez) { message("All sectors must have the same %s height", cfs[cf]); goto end_yax; } - if ((YAX_SECTORFLD(highlightsector[i],stat, cf)&2)!=0) + + if (highlightsectorcnt>1 && SECTORFLD(highlightsector[i],stat, cf)&2) { message("Sector %ss must not be sloped", cfs[cf]); goto end_yax; @@ -2849,27 +2876,27 @@ void overheadeditor(void) numwalls = k; } + // create new sector based on first highlighted one i = highlightsector[0]; Bmemcpy(§or[numsectors], §or[i], sizeof(sectortype)); sector[numsectors].wallptr = m; sector[numsectors].wallnum = numwalls-m; - if (YAX_SECTORFLD(i,stat, cf)&2) - { - YAX_SECTORFLD(numsectors,stat, !cf) |= 2; - YAX_SECTORFLD(numsectors,heinum, !cf) = YAX_SECTORFLD(i,heinum, cf); - } + if (SECTORFLD(i,stat, cf)&2) + setslope(numsectors, !cf, SECTORFLD(i,heinum, cf)); + else + setslope(numsectors, !cf, 0); + setslope(numsectors, cf, 0); - YAX_SECTORFLD(numsectors,z, !cf) = YAX_SECTORFLD(i,z, cf); - YAX_SECTORFLD(numsectors,z, cf) = YAX_SECTORFLD(i,z, cf) - (1-2*cf)*16384; + SECTORFLD(numsectors,z, !cf) = SECTORFLD(i,z, cf); + SECTORFLD(numsectors,z, cf) = SECTORFLD(i,z, cf) - (1-2*cf)*DEFAULT_YAX_HEIGHT; k = -1; // nextbunchnum for (i=0; i=0 || fb0>=0 || cb1>=0 || fb0>=0) + { + printmessage16("Joining non-adjacent extended sectors not allowed!"); + joinsector[0] = joinsector[1] = -1; + goto end_join_sectors; + } +#endif + { + fade_editor_screen(); - if (!ask_if_sure("Join non-adjacent sectors? (Y/N)", 0)) - joinsector[1] = joinsector[0]; + if (!ask_if_sure("Join non-adjacent sectors? (Y/N)", 0)) + joinsector[1] = joinsector[0]; + } } - +#ifdef YAX_ENABLE + if (cb0!=cb1 || fb0!=fb1) + { + printmessage16("Joining of extended sectors with different bunches not allowed!"); + joinsector[0] = joinsector[1] = -1; + goto end_join_sectors; + } +#endif break; } } @@ -3999,9 +4050,6 @@ end_join_sectors: else { sprite[i].z = getflorzofslope(sucksect,dax,day); -// if (sprite[i].cstat&128) -// sprite[i].z -= spriteheight(i, NULL)>>1; - // PK if (prefixarg) { @@ -4058,7 +4106,14 @@ end_join_sectors: else { if (linehighlight >= 0) + { +#ifdef YAX_ENABLE + if (!yax_isinnerwall(sectorofwall(linehighlight), linehighlight)) + printmessage16("Can't make circle in wall constrained by sector extension."); + else +#endif circlewall = linehighlight; + } } keystatus[0x2e] = 0; } @@ -4109,8 +4164,8 @@ end_join_sectors: dax = centerx + mulscale14(sintable[(j+512)&2047],circlerad); day = centery + mulscale14(sintable[j],circlerad); - bclamp(&dax, -editorgridextent, editorgridextent); - bclamp(&day, -editorgridextent, editorgridextent); + inpclamp(&dax, -editorgridextent, editorgridextent); + inpclamp(&day, -editorgridextent, editorgridextent); if (bad > 0 && goodtogo) { @@ -4892,8 +4947,15 @@ end_space_handling: } else { - insertpoint(linehighlight, dax,day); - printmessage16("Point inserted."); +#ifdef YAX_ENABLE + if (!yax_isinnerwall(sectorofwall(linehighlight), linehighlight)) + printmessage16("Inserting point in constrained wall: not implemented!"); + else +#endif + { + insertpoint(linehighlight, dax,day); + printmessage16("Point inserted."); + } } } @@ -5330,7 +5392,7 @@ static int32_t ask_if_sure(const char *query, uint32_t flags) } #ifdef YAX_ENABLE -static int32_t ask_above_or_below() +static int32_t ask_above_or_below(void) { char ch; int32_t ret=-1; @@ -5459,8 +5521,8 @@ int32_t LoadBoard(const char *filename, uint32_t flags) void getpoint(int32_t searchxe, int32_t searchye, int32_t *x, int32_t *y) { - bclamp(&pos.x, -editorgridextent, editorgridextent); - bclamp(&pos.y, -editorgridextent, editorgridextent); + inpclamp(&pos.x, -editorgridextent, editorgridextent); + inpclamp(&pos.y, -editorgridextent, editorgridextent); searchxe -= halfxdim16; searchye -= midydim16; @@ -5475,8 +5537,8 @@ void getpoint(int32_t searchxe, int32_t searchye, int32_t *x, int32_t *y) *x = pos.x + divscale14(searchxe,zoom); *y = pos.y + divscale14(searchye,zoom); - bclamp(x, -editorgridextent, editorgridextent); - bclamp(y, -editorgridextent, editorgridextent); + inpclamp(x, -editorgridextent, editorgridextent); + inpclamp(y, -editorgridextent, editorgridextent); } static int32_t getlinehighlight(int32_t xplc, int32_t yplc, int32_t line) @@ -5825,7 +5887,7 @@ static int32_t deletesector(int16_t sucksect) void fixspritesectors(void) { - int32_t i, j, dax, day, daz; + int32_t i, j, dax, day, cz, fz; for (i=numsectors-1; i>=0; i--) if (sector[i].wallnum <= 0 || sector[i].wallptr >= numwalls) @@ -5842,16 +5904,19 @@ void fixspritesectors(void) if (inside(dax,day,sprite[i].sectnum) != 1) { - daz = spriteheight(i, NULL); + spriteoncfz(i, &cz, &fz); for (j=0; j= getceilzofslope(j,dax,day) - && sprite[i].z-daz <= getflorzofslope(j,dax,day)) + { + if (inside(dax,day, j) != 1) + continue; + + if (cz <= sprite[i].z && sprite[i].z <= fz) { changespritesect(i, j); break; } + } } } } @@ -6922,7 +6987,8 @@ void printcoords16(int32_t posxe, int32_t posye, int16_t ange) { char snotbuf[80]; int32_t i, m; - int32_t v8 = (numsectors > MAXSECTORSV7 || numwalls > MAXWALLSV7 || numsprites > MAXSPRITESV7); + int32_t v8 = (numsectors > MAXSECTORSV7 || numwalls > MAXWALLSV7 || + numsprites > MAXSPRITESV7 || numyaxbunches > 0); Bsprintf(snotbuf,"x:%d y:%d ang:%d r%d",posxe,posye,ange,map_revision-1); i = 0; @@ -6941,8 +7007,9 @@ void printcoords16(int32_t posxe, int32_t posye, int16_t ange) if (highlightcnt<=0 && highlightsectorcnt<=0) { - Bsprintf(snotbuf,"%d/%d sect. %d/%d walls %d/%d spri.", + Bsprintf(snotbuf,"%d/%d %s. %d/%d walls %d/%d spri.", numsectors, v8?MAXSECTORSV8:MAXSECTORSV7, + numyaxbunches>0 ? "SECT":"sect", numwalls, v8?MAXWALLSV8:MAXWALLSV7, numsprites, v8?MAXSPRITESV8:MAXSPRITESV7); } @@ -7112,23 +7179,43 @@ void showsectordata(int16_t sectnum, int16_t small) DOPRINT(32, "^10CEILING:^O"); DOPRINT(48, "Flags (hex): %x", sec->ceilingstat); - DOPRINT(56, "(X,Y)pan: %d, %d", sec->ceilingxpanning, sec->ceilingypanning); + { + int32_t xp=sec->ceilingxpanning, yp=sec->ceilingypanning; +#ifdef YAX_ENABLE + if (yax_getbunch(searchsector, YAX_CEILING) >= 0) + xp = yp = 0; +#endif + DOPRINT(56, "(X,Y)pan: %d, %d", xp, yp); + } DOPRINT(64, "Shade byte: %d", sec->ceilingshade); DOPRINT(72, "Z-coordinate: %d", sec->ceilingz); DOPRINT(80, "Tile number: %d", sec->ceilingpicnum); DOPRINT(88, "Ceiling heinum: %d", sec->ceilingheinum); DOPRINT(96, "Palookup number: %d", sec->ceilingpal); +#ifdef YAX_ENABLE + DOPRINT(104, "Bunch number: %d", yax_getbunch(sectnum, YAX_CEILING)); +#endif col++; DOPRINT(32, "^10FLOOR:^O"); DOPRINT(48, "Flags (hex): %x", sec->floorstat); - DOPRINT(56, "(X,Y)pan: %d, %d", sec->floorxpanning, sec->floorypanning); + { + int32_t xp=sec->floorxpanning, yp=sec->floorypanning; +#ifdef YAX_ENABLE + if (yax_getbunch(searchsector, YAX_FLOOR) >= 0) + xp = yp = 0; +#endif + DOPRINT(56, "(X,Y)pan: %d, %d", xp, yp); + } DOPRINT(64, "Shade byte: %d", sec->floorshade); DOPRINT(72, "Z-coordinate: %d", sec->floorz); DOPRINT(80, "Tile number: %d", sec->floorpicnum); DOPRINT(88, "Floor heinum: %d", sec->floorheinum); DOPRINT(96, "Palookup number: %d", sec->floorpal); +#ifdef YAX_ENABLE + DOPRINT(104, "Bunch number: %d", yax_getbunch(sectnum, YAX_FLOOR)); +#endif } void showwalldata(int16_t wallnum, int16_t small) diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index 04d47b921..801ce0354 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -219,7 +219,7 @@ void yax_setbunch(int16_t i, int16_t cf, int16_t bunchnum) if (bunchnum<0) { *(§or[i].ceilingstat + cf) &= ~YAX_BIT; -// YAX_BUNCHNUM(i, cf) = 0; + YAX_BUNCHNUM(i, cf) = 0; return; } @@ -233,6 +233,63 @@ void yax_setbunches(int16_t i, int16_t cb, int16_t fb) yax_setbunch(i, YAX_FLOOR, fb); } +void yax_update(int32_t onlyreset) +{ + int32_t i, oeditstatus=editstatus; + int16_t cb, fb, tmpsect; + + numyaxbunches = 0; + + for (i=0; i=0; i--) + { + yax_getbunches(i, &cb, &fb); + yax_bunchnum[i][0] = cb; + yax_bunchnum[i][1] = fb; + + if (cb >= 0) + { + if (headsectbunch[0][cb] == -1) + { + headsectbunch[0][cb] = i; + // not duplicated in floors, since every extended ceiling + // must have a corresponding floor: + numyaxbunches++; + } + else + { + tmpsect = headsectbunch[0][cb]; + headsectbunch[0][cb] = i; + nextsectbunch[0][i] = tmpsect; + } + } + + if (fb >= 0) + { + if (headsectbunch[1][fb] == -1) + headsectbunch[1][fb] = i; + else + { + tmpsect = headsectbunch[1][fb]; + headsectbunch[1][fb] = i; + nextsectbunch[1][i] = tmpsect; + } + } + } + editstatus = oeditstatus; +} #undef YAX_BUNCHNUM #endif @@ -1306,7 +1363,7 @@ static void scansector(int16_t sectnum) if (sectnum < 0) return; - if (automapping) show2dsector[sectnum>>3] |= pow2char[sectnum&7]; +// if (automapping) show2dsector[sectnum>>3] |= pow2char[sectnum&7]; sectorborder[0] = sectnum, sectorbordercnt = 1; do @@ -4687,7 +4744,7 @@ static void drawsprite(int32_t snum) #endif drawvox(tspr->x,tspr->y,tspr->z,i,(int32_t)tspr->xrepeat,(int32_t)tspr->yrepeat,vtilenum,tspr->shade,tspr->pal,lwall,swall); } - if (automapping == 1) show2dsprite[spritenum>>3] |= pow2char[spritenum&7]; +// if (automapping == 1) show2dsprite[spritenum>>3] |= pow2char[spritenum&7]; } @@ -6360,7 +6417,7 @@ int32_t initengine(void) clearbuf(&show2dsector[0],(int32_t)((MAXSECTORS+3)>>5),0L); clearbuf(&show2dsprite[0],(int32_t)((MAXSPRITES+3)>>5),0L); clearbuf(&show2dwall[0],(int32_t)((MAXWALLS+3)>>5),0L); - automapping = 0; +// automapping = 0; totalclock = 0; visibility = 512; @@ -6477,7 +6534,7 @@ void initspritelists(void) void drawrooms(int32_t daposx, int32_t daposy, int32_t daposz, int16_t daang, int32_t dahoriz, int16_t dacursectnum) { - int32_t i, j, z, cz, fz, closest; + int32_t i, j, cz, fz, closest; int16_t *shortptr1, *shortptr2; beforedrawrooms = 0; @@ -6629,11 +6686,11 @@ void drawrooms(int32_t daposx, int32_t daposy, int32_t daposz, drawalls(closest); - if (automapping) - { - for (z=bunchfirst[closest]; z>=0; z=p2[z]) - show2dwall[thewall[z]>>3] |= pow2char[thewall[z]&7]; - } +// if (automapping) +// { +// for (z=bunchfirst[closest]; z>=0; z=p2[z]) +// show2dwall[thewall[z]>>3] |= pow2char[thewall[z]&7]; +// } numbunches--; bunchfirst[closest] = bunchfirst[numbunches]; @@ -8984,25 +9041,27 @@ int32_t krecip(int32_t num) return(krecipasm(num)); } -int32_t spriteheight(int16_t i, int32_t *basez) +void spriteheightofs(int16_t i, int32_t *height, int32_t *zofs) { int32_t hei, flooraligned=((sprite[i].cstat&48)==32); + if (zofs) + *zofs = 0; + if (flooraligned) { - if (basez) - *basez = sprite[i].z; - return 0; + if (height) + *height = 0; + return; } hei = (tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<2; - if (basez) + if (zofs) { - *basez = sprite[i].z; if (sprite[i].cstat&128) - *basez -= (hei>>1); + *zofs = hei>>1; } - return hei; + *height = hei; } // @@ -10531,7 +10590,7 @@ void updatesectorexclude(int32_t x, int32_t y, int16_t *sectnum, const uint8_t * walltype *wal; int32_t i, j; - if (!(excludesectbitmap[*sectnum>>3]&(1<<(*sectnum&7))) && inside(x,y,*sectnum) == 1) + if (*sectnum>=0 && !(excludesectbitmap[*sectnum>>3]&(1<<(*sectnum&7))) && inside(x,y,*sectnum) == 1) return; if ((*sectnum >= 0) && (*sectnum < numsectors)) @@ -10745,7 +10804,7 @@ void getzrange(const vec3_t *vect, int16_t sectnum, if (0) { - beginagain: +beginagain: // replace sector and wall with clip map mapinfo_set(&origmapinfo, &clipmapinfo); clipsectcnt = clipsectnum; // should be a nop, "safety"... diff --git a/polymer/eduke32/build/src/polymost.c b/polymer/eduke32/build/src/polymost.c index b5c4857f0..3126c4175 100644 --- a/polymer/eduke32/build/src/polymost.c +++ b/polymer/eduke32/build/src/polymost.c @@ -2186,7 +2186,7 @@ void drawpoly(double *dpx, double *dpy, int32_t n, int32_t method) { float pc[4]; - int32_t shadebound = shadescale_unbounded ? numpalookups : 31; + int32_t shadebound = (shadescale_unbounded || globalshade>31) ? numpalookups : 31; f = ((float)(numpalookups-min(max((globalshade * shadescale),0),shadebound)))/((float)numpalookups); pc[0] = pc[1] = pc[2] = f; switch (method&3) @@ -4077,7 +4077,7 @@ static void polymost_scansector(int32_t sectnum) int32_t xs, ys, x1, y1, x2, y2; if (sectnum < 0) return; - if (automapping) show2dsector[sectnum>>3] |= pow2char[sectnum&7]; +// if (automapping) show2dsector[sectnum>>3] |= pow2char[sectnum&7]; sectorborder[0] = sectnum, sectorbordercnt = 1; do @@ -5788,7 +5788,7 @@ void polymost_fillpolygon(int32_t npoints) pthtyp *pth; float f,a=0.0; int32_t i; - int32_t shadebound = shadescale_unbounded ? numpalookups-1 : 31; + int32_t shadebound = (shadescale_unbounded || globalshade>31) ? numpalookups : 31; globalx1 = mulscale16(globalx1,xyaspect); globaly2 = mulscale16(globaly2,xyaspect); @@ -5829,7 +5829,8 @@ void polymost_fillpolygon(int32_t npoints) } #endif -int32_t polymost_drawtilescreen(int32_t tilex, int32_t tiley, int32_t wallnum, int32_t dimen, int32_t tilezoom) +int32_t polymost_drawtilescreen(int32_t tilex, int32_t tiley, int32_t wallnum, int32_t dimen, int32_t tilezoom, + int32_t usehitile, uint8_t *loadedhitile) { #ifdef USE_OPENGL float xdime, ydime, xdimepad, ydimepad, scx, scy, ratio = 1.0; @@ -5860,11 +5861,22 @@ int32_t polymost_drawtilescreen(int32_t tilex, int32_t tiley, int32_t wallnum, i { scx = (float)dimen; scy = (float)dimen; - if (xdime < ydime) scx *= xdime/ydime; else scy *= ydime/xdime; + if (xdime < ydime) + scx *= xdime/ydime; + else + scy *= ydime/xdime; } - pth = gltexcache(wallnum,0,4); - bglBindTexture(GL_TEXTURE_2D,pth ? pth->glpic : 0); + { + int32_t ousehightile = usehightile; + usehightile = usehitile && usehightile; + pth = gltexcache(wallnum,0,4); + if (usehightile) + loadedhitile[wallnum>>3] |= (1<<(wallnum&7)); + usehightile = ousehightile; + } + + bglBindTexture(GL_TEXTURE_2D, pth ? pth->glpic : 0); bglDisable(GL_ALPHA_TEST); @@ -5888,10 +5900,10 @@ int32_t polymost_drawtilescreen(int32_t tilex, int32_t tiley, int32_t wallnum, i (float)britable[curbrightness][ curpalette[255].g ] / 255.0, (float)britable[curbrightness][ curpalette[255].b ] / 255.0, 1); - bglVertex2f((float)tilex ,(float)tiley); + bglVertex2f((float)tilex ,(float)tiley); bglVertex2f((float)tilex+(scx*ratio),(float)tiley); bglVertex2f((float)tilex+(scx*ratio),(float)tiley+(scy*ratio)); - bglVertex2f((float)tilex ,(float)tiley+(scy*ratio)); + bglVertex2f((float)tilex ,(float)tiley+(scy*ratio)); bglEnd(); } @@ -5899,10 +5911,10 @@ int32_t polymost_drawtilescreen(int32_t tilex, int32_t tiley, int32_t wallnum, i bglEnable(GL_TEXTURE_2D); bglEnable(GL_BLEND); bglBegin(GL_TRIANGLE_FAN); - bglTexCoord2f(0, 0); bglVertex2f((float)tilex ,(float)tiley); + bglTexCoord2f(0, 0); bglVertex2f((float)tilex ,(float)tiley); bglTexCoord2f(xdimepad, 0); bglVertex2f((float)tilex+(scx*ratio),(float)tiley); bglTexCoord2f(xdimepad,ydimepad); bglVertex2f((float)tilex+(scx*ratio),(float)tiley+(scy*ratio)); - bglTexCoord2f(0,ydimepad); bglVertex2f((float)tilex ,(float)tiley+(scy*ratio)); + bglTexCoord2f(0, ydimepad); bglVertex2f((float)tilex ,(float)tiley+(scy*ratio)); bglEnd(); return(0); @@ -6621,7 +6633,11 @@ int32_t dedxtfilter(int32_t fil, texcachepicture *pict, char *pic, void *midbuf, #else /* POLYMOST */ #include "inttypes.h" -int32_t polymost_drawtilescreen(int32_t tilex, int32_t tiley, int32_t wallnum, int32_t dimen) { return -1; } +int32_t polymost_drawtilescreen(int32_t tilex, int32_t tiley, int32_t wallnum, int32_t dimen, + int32_t usehitile, uint8_t *loadedhitile) +{ + return -1; +} #endif diff --git a/polymer/eduke32/m32help.hlp b/polymer/eduke32/m32help.hlp index e5e8dd28f..c932a819d 100644 --- a/polymer/eduke32/m32help.hlp +++ b/polymer/eduke32/m32help.hlp @@ -417,13 +417,13 @@ RIGHT smooth scrolling sector Hi=X SE 3 in affected sector: Hi=X - Shades: + Shades/pals: sectors/walls: when off SE: when on ^3SE 4: RANDOM LIGHTS Hi: random blink num. ^0(research!) - Shades: + Shades/pals: sectors/walls: when off SE: when on diff --git a/polymer/eduke32/samples/a.m32 b/polymer/eduke32/samples/a.m32 index c09096e8b..84db81d7c 100644 --- a/polymer/eduke32/samples/a.m32 +++ b/polymer/eduke32/samples/a.m32 @@ -875,7 +875,7 @@ onevent EVENT_KEYS3D } // teleporter -- works on SE7 and SE17 (elevator) - ifeitherctrl ifaimingsprite + ifeitheralt ifaimingsprite ifholdkey KEY_SPACE { ife sprite[searchwall].picnum SECTOREFFECTOR diff --git a/polymer/eduke32/source/astub.c b/polymer/eduke32/source/astub.c index f46ec3dbf..dd50a0eaf 100644 --- a/polymer/eduke32/source/astub.c +++ b/polymer/eduke32/source/astub.c @@ -179,7 +179,45 @@ static char spriteshades[MAXSPRITES]; static char wallpals[MAXWALLS]; static char sectorpals[MAXSECTORS][2]; static char spritepals[MAXSPRITES]; -static char wallflag[MAXWALLS]; +static uint8_t wallflag[MAXWALLS>>3]; + +#ifdef YAX_ENABLE +static uint8_t havebunch[YAX_MAXBUNCHES]; +static int32_t *tempzar[YAX_MAXBUNCHES]; + +// check whether bunchnum has exactly one corresponding floor and ceiling +static int32_t yax_is121(int16_t bunchnum) +{ + int32_t i, ccnt=0, fcnt=0; + int16_t cb, fb; + + for (i=0; i=0 && cb==bunchnum) + ccnt++; + if (fb>=0 && fb==bunchnum) + fcnt++; + + if (ccnt>1 || fcnt>1) + return 0; + } + + if (ccnt==1 && fcnt==1) + return 1; + + return 0; +} + +static void silentmessage(const char *fmt, ...); +static int32_t yax_invalidop() +{ + silentmessage("Operation forbidden on extended sector."); + return 0; +} + +# define YAXCHK(p) ((p) || yax_invalidop()) +#endif // tile marking in tile selector for custom creation of tile groups static int16_t tilemarked[(MAXTILES+7)>>3]; @@ -188,7 +226,50 @@ static int16_t tilemarked[(MAXTILES+7)>>3]; static int16_t spritelightid[MAXSPRITES]; _prlight *spritelightptr[MAXSPRITES]; -static void DeletePolymerLights() +static int32_t check_prlight_colors(int32_t i) +{ + return (sprite[i].xvel != spritelightptr[i]->color[0]) || + (sprite[i].yvel != spritelightptr[i]->color[1]) || + (sprite[i].zvel != spritelightptr[i]->color[2]); +} + +static void copy_prlight_colors(_prlight *mylightptr, int32_t i) +{ + mylightptr->color[0] = sprite[i].xvel; + mylightptr->color[1] = sprite[i].yvel; + mylightptr->color[2] = sprite[i].zvel; +} + +static void addprlight_common1(_prlight *mylightptr, int32_t i) +{ + mylightptr->sector = SECT; + Bmemcpy(mylightptr, &sprite[i], sizeof(vec3_t)); + mylightptr->range = SHT; + copy_prlight_colors(mylightptr, i); + mylightptr->angle = SA; + mylightptr->horiz = SH; + mylightptr->minshade = sprite[i].xoffset; + mylightptr->maxshade = sprite[i].yoffset; + + // overridden for spot lights + mylightptr->radius = mylightptr->faderadius = mylightptr->tilenum = 0; + + if (CS & 2) + { + if (CS & 512) + mylightptr->priority = PR_LIGHT_PRIO_LOW; + else + mylightptr->priority = PR_LIGHT_PRIO_HIGH; + } + else + mylightptr->priority = PR_LIGHT_PRIO_MAX; + + spritelightid[i] = polymer_addlight(mylightptr); + if (spritelightid[i] >= 0) + spritelightptr[i] = &prlights[spritelightid[i]]; +} + +static void DeletePolymerLights(void) { int32_t i; for (i=0; i to exit"); - if (PRESSED_KEYSC(T)) // goto table of contents + if (keystatus[KEYSC_S]) + { + fade_editor_screen(); + } + else + { + begindrawing(); + CLEARLINES2D(0, ydim, 0); + enddrawing(); + } + + // based on 'save as' dialog in overheadeditor() + if (keystatus[KEYSC_S]) // text search + { + char ch, bad=0, pattern[IHELP_PATLEN+1]; + + for (i=0; i 0) + { + if (i > 0 && (ch == 8 || ch == 127)) + { + i--; + pattern[i] = 0; + } + else if (i < IHELP_PATLEN && ch >= 32 && ch < 128) + { + pattern[i++] = ch; + pattern[i] = 0; + } + } + } + + if (bad==1) + { + keystatus[KEYSC_ESC] = keystatus[KEYSC_Q] = keystatus[KEYSC_F1] = 0; + } + + if (bad==2) + { + keystatus[KEYSC_ENTER] = 0; + + for (i=curhp; inumlines; j++) + { + // entering an empty pattern will search with the last used pattern + if (strstr(helppage[i]->line[j], pattern[0]?pattern:oldpattern)) + { + curhp = i; + + if ((curline=j) <= helppage[i]->numlines - 32 /*-IHELP_NUMDISPLINES*/) /**/; + else if ((curline=helppage[i]->numlines- 32 /*-IHELP_NUMDISPLINES*/) >= 0) /**/; + else curline=0; + + highlighthp = i; + highlightline = j; + lasthighlighttime = totalclock; + goto ENDFOR1; + } + } + } +ENDFOR1: + if (pattern[0]) + Bmemcpy(oldpattern, pattern, IHELP_PATLEN+1); + } + } + else if (PRESSED_KEYSC(T)) // goto table of contents { curhp=0; curline=0; @@ -1628,79 +1810,6 @@ static void IntegratedHelp() curline=0; } } - - // based on 'save as' dialog in overheadeditor() - else if (keystatus[KEYSC_S]) // text search - { - char ch, bad=0, pattern[IHELP_PATLEN+1]; - - for (i=0; i 0) - { - if (i > 0 && (ch == 8 || ch == 127)) - { - i--; - pattern[i] = 0; - } - else if (i < IHELP_PATLEN && ch >= 32 && ch < 128) - { - pattern[i++] = ch; - pattern[i] = 0; - } - } - } - - if (bad==1) - { - keystatus[KEYSC_ESC] = keystatus[KEYSC_Q] = keystatus[KEYSC_F1] = 0; - } - - if (bad==2) - { - keystatus[KEYSC_ENTER] = 0; - - for (i=curhp; inumlines; j++) - { - // entering an empty pattern will search with the last used pattern - if (strstr(helppage[i]->line[j], pattern[0]?pattern:oldpattern)) - { - curhp = i; - - if ((curline=j) <= helppage[i]->numlines - 32 /*-IHELP_NUMDISPLINES*/) /**/; - else if ((curline=helppage[i]->numlines- 32 /*-IHELP_NUMDISPLINES*/) >= 0) /**/; - else curline=0; - - highlighthp = i; - highlightline = j; - lasthighlighttime = totalclock; - goto ENDFOR1; - } - } - } -ENDFOR1: - if (pattern[0]) - Bmemcpy(oldpattern, pattern, IHELP_PATLEN+1); - } - } else // '1'-'0' on the upper row { for (i=2; i<=11; i++) @@ -1890,7 +1999,7 @@ static int32_t sort_sounds(int32_t how) return 0; } -static void SoundDisplay() +static void SoundDisplay(void) { if (g_numsounds <= 0) return; @@ -2201,7 +2310,7 @@ void ExtShowSpriteData(int16_t spritenum) //F6 static int32_t fofsizex = -1; static int32_t fofsizey = -1; #if 0 -static void ResetFOFSize() +static void ResetFOFSize(void) { if (fofsizex != -1) tilesizx[FOF] = fofsizex; if (fofsizey != -1) tilesizy[FOF] = fofsizey; @@ -2462,7 +2571,7 @@ static inline void SpriteName(int16_t spritenum, char *lo2) Bstrcpy(lo2, names[sprite[spritenum].picnum]); }// end SpriteName -static void ReadPaletteTable() +static void ReadPaletteTable(void) { int32_t i,j,fp; char lookup_num; @@ -2673,12 +2782,12 @@ static int32_t DrawTiles(int32_t iTopLeft, int32_t iSelected, int32_t nXTiles, i #define TMPERRMSG_SHOW(alsoOSD) do { \ printext256(0, 0, whitecol, 0, tilesel_errmsg, 0); \ if (alsoOSD) OSD_Printf("%s\n", tilesel_errmsg); \ - showframe(1); \ } while (0) #define TMPERRMSG_PRINT(Msg, ...) do { \ Bsprintf(tilesel_errmsg, Msg, ## __VA_ARGS__); \ TMPERRMSG_SHOW(1); \ + showframe(1); \ tilesel_showerr = 1; \ } while (0) @@ -2761,7 +2870,7 @@ static int32_t m32gettile(int32_t idInitialTile) localartfreq[ wall[i].overpicnum ]++; break; - default : + default: break; } @@ -2845,22 +2954,25 @@ static int32_t m32gettile(int32_t idInitialTile) while ((keystatus[KEYSC_ENTER]|keystatus[KEYSC_ESC]|(bstatus&1)) == 0) // <- Presumably one of these is escape key ?? { + int32_t ret; zoomsz = ZoomToThumbSize[s_Zoom]; - DrawTiles(iTopLeftTile, (iTile >= localartlookupnum) ? localartlookupnum-1 : iTile, - nXTiles, nYTiles, zoomsz, moffset, - (tilesel_showerr && (iTile==iLastTile || (tilesel_showerr=0)))); + ret = DrawTiles(iTopLeftTile, (iTile >= localartlookupnum) ? localartlookupnum-1 : iTile, + nXTiles, nYTiles, zoomsz, moffset, + (tilesel_showerr && (iTile==iLastTile || (tilesel_showerr=0)))); + + if (ret==0) + { + idle_waitevent_timeout(500); + // SDL seems to miss mousewheel events when rotated slowly. + + if (handleevents()) + quitevent = 0; + } + getmousevalues(&mousedx,&mousedy,&bstatus); iLastTile = iTile; - idle_waitevent_timeout(500); - // SDL seems to miss mousewheel events when rotated slowly. - // These kludgy things seem to make it better, but I'm not sure. - - if (handleevents()) - quitevent = 0; - - getmousevalues(&mousedx,&mousedy,&bstatus); searchx += mousedx; searchy += mousedy; @@ -2891,8 +3003,8 @@ static int32_t m32gettile(int32_t idInitialTile) // Keep the pointer visible at all times. temp = min(zoomsz/2, 12); - searchx = clamp(searchx, temp, xdim-temp); - searchy = clamp(searchy, temp, ydim-temp); + inpclamp(&searchx, temp, xdim-temp); + inpclamp(&searchy, temp, ydim-temp); scrollmode = !(eitherCTRL^revertCTRL); if (bstatus&16 && scrollmode && iTopLeftTile > 0) @@ -3120,6 +3232,8 @@ static int32_t m32gettile(int32_t idInitialTile) } } } + + mousex = mousey = mouseb = 0; } // @@ -3220,7 +3334,7 @@ static int32_t m32gettile(int32_t idInitialTile) //{ //} -static int32_t OnSaveTileGroup() +static int32_t OnSaveTileGroup(void) { int32_t i, n=0; char hotkey; @@ -3521,179 +3635,247 @@ static const char *GetTilePixels(int32_t idTile) return pPixelData; } +static void classic_drawtilescreen(int32_t x, int32_t y, int32_t idTile, int32_t TileDim, + const char *pRawPixels) +{ + int32_t dispxsz = tilesizx[idTile], dispysz = tilesizy[idTile]; + int32_t divinc = 1, mulinc = 1; + + int32_t xofs, yofs; + char *pScreen; + + while ((dispxsz/divinc > TileDim) || (dispysz/divinc) > TileDim) + { + divinc++; + } + + if (divinc == 1 && s_TileZoom) + { + while ((dispxsz*(mulinc+1)) <= TileDim && (dispysz*(mulinc+1)) <= TileDim) + { + mulinc++; + } + } + + dispxsz = (dispxsz / divinc) * mulinc; + dispysz = (dispysz / divinc) * mulinc; + + for (yofs = 0; yofs < dispysz; yofs++) + { + y += yofs; + if (y>=0 && y>3]&(1<<(idTile&7))); + + // + // Draw white box around currently selected tile or marked tile + // p1=(x1, y1), p2=(x1+TileDim-1, y1+TileDim-1) + // + if (iTile == iSelected || marked) + { + int32_t x1 = ((iTile-iTopLeft) % nXTiles)*TileDim; + int32_t y1 = ((iTile - ((iTile-iTopLeft) % nXTiles) - iTopLeft)/nXTiles)*TileDim + offset; + int32_t x2 = x1+TileDim-1; + int32_t y2 = y1+TileDim-1; + + char markedcol = editorcolors[14]; + + setpolymost2dview(); + + y1=max(y1, 0); + y2=min(y2, ydim-1); + + { + // box + int32_t xx[] = {x1, x1, x2, x2, x1}; + int32_t yy[] = {y1, y2, y2, y1, y1}; + plotlines2d(xx, yy, 5, iTile==iSelected ? whitecol : markedcol); + } + + // cross + if (marked) + { + int32_t xx[] = {x1, x2}; + int32_t yy[] = {y1, y2}; + + plotlines2d(xx, yy, 2, markedcol); + swaplong(&yy[0], &yy[1]); + plotlines2d(xx, yy, 2, markedcol); + } + } +} + +static void tilescreen_drawrest(int32_t iSelected, int32_t showmsg) +{ + if (iSelected>=0 && iSelected>2,ydim-10,whitecol,-1,szT,0); + + // EditArt offset flags. + Bsprintf(szT,"%d, %d", (int8_t)((picanm[idTile]>>8)&0xFF), (int8_t)((picanm[idTile]>>16)&0xFF)); + printext256((xdim>>2)+100,ydim-10,whitecol,-1,szT,0); + + // EditArt animation flags. + if (picanm[idTile]&0xc0) + { + static const char *anmtype[] = {"", "Osc", "Fwd", "Bck"}; + + Bsprintf(szT,"%s %d", anmtype[(picanm[idTile]&0xc0)>>6], picanm[idTile]&0x3f); + printext256((xdim>>2)+100+14*8,ydim-10,whitecol,-1,szT,0); + } + } + + if (showmsg) + TMPERRMSG_SHOW(0); + + m32_showmouse(); +} + +////////// main tile drawing function ////////// static int32_t DrawTiles(int32_t iTopLeft, int32_t iSelected, int32_t nXTiles, int32_t nYTiles, int32_t TileDim, int32_t offset, int32_t showmsg) { int32_t XTile, YTile; int32_t iTile, idTile; - int32_t XPos, YPos; - int32_t XOffset, YOffset; - int32_t i, marked; + int32_t i, x, y; const char *pRawPixels; - int32_t TileSizeX, TileSizeY; - int32_t DivInc,MulInc; - char *pScreen; char szT[128]; + int32_t usehitilecnt=0, usehitile; + static uint8_t loadedhitile[(MAXTILES+7)>>3]; + begindrawing(); setpolymost2dview(); clearview(0); +restart: for (YTile = 0-(offset>0); YTile < nYTiles+(offset<0)+1; YTile++) { for (XTile = 0; XTile < nXTiles; XTile++) { iTile = iTopLeft + XTile + (YTile * nXTiles); - if (iTile>=0 && iTile < localartlookupnum) + if (iTile < 0 || iTile >= localartlookupnum) + continue; + + usehitile = usehitilecnt; + + idTile = localartlookup[ iTile ]; + if (loadedhitile[idTile>>3]&(1<<(idTile&7))) { - idTile = localartlookup[ iTile ]; + if (usehitilecnt==0) + usehitile = 1; + else + continue; + } - // Get pointer to tile's raw pixel data - pRawPixels = GetTilePixels(idTile); + // Get pointer to tile's raw pixel data + pRawPixels = GetTilePixels(idTile); - if (pRawPixels != NULL) + if (pRawPixels != NULL) + { + x = XTile * TileDim; + y = YTile * TileDim+offset; + + if (polymost_drawtilescreen(x, y, idTile, TileDim, s_TileZoom, + usehitile, loadedhitile)) + classic_drawtilescreen(x, y, idTile, TileDim, pRawPixels); + + if (localartfreq[iTile] != 0 && y >= 0 && y <= ydim-20) { - XPos = XTile * TileDim; - YPos = YTile * TileDim+offset; - - if (polymost_drawtilescreen(XPos, YPos, idTile, TileDim, s_TileZoom)) - { - TileSizeX = tilesizx[ idTile ]; - TileSizeY = tilesizy[ idTile ]; - - DivInc = 1; - MulInc = 1; - - while ((TileSizeX/DivInc > TileDim) || (TileSizeY/DivInc) > TileDim) - { - DivInc++; - } - - if (DivInc == 1 && s_TileZoom) - { - while ((TileSizeX*(MulInc+1)) <= TileDim && (TileSizeY*(MulInc+1)) <= TileDim) - { - MulInc++; - } - } - - TileSizeX = (TileSizeX / DivInc) * MulInc; - TileSizeY = (TileSizeY / DivInc) * MulInc; - - for (YOffset = 0; YOffset < TileSizeY; YOffset++) - { - int32_t y=YPos+YOffset; - if (y>=0 && y= 0 && YPos <= ydim-20) - { - Bsprintf(szT, "%d", localartfreq[iTile]); - printext256(XPos, YPos, whitecol, -1, szT, 1); - } + Bsprintf(szT, "%d", localartfreq[iTile]); + printext256(x, y, whitecol, -1, szT, 1); } + } - marked = (IsValidTile(idTile) && tilemarked[idTile>>3]&(1<<(idTile&7))); + tilescreen_drawbox(iTopLeft, iSelected, nXTiles, TileDim, offset, iTile, idTile); - // - // Draw white box around currently selected tile or marked tile - // p1=(x1, y1), p2=(x1+TileDim-1, y1+TileDim-1) - // - if (iTile == iSelected || marked) + if (usehitilecnt) + { + int32_t k; + + if (handleevents()) + quitevent=0; + + tilescreen_drawrest(iSelected, showmsg); + + enddrawing(); + showframe(1); + begindrawing(); + + k = (mousex || mousey || mouseb); + if (!k) + for (i=0; i<(signed)(sizeof(keystatus)/sizeof(keystatus[0])); i++) + if (keystatus[i]) + { + k = 1; + break; + } + if (k) { - int32_t x1 = ((iTile-iTopLeft) % nXTiles)*TileDim; - int32_t y1 = ((iTile - ((iTile-iTopLeft) % nXTiles) - iTopLeft)/nXTiles)*TileDim + offset; - int32_t x2 = x1+TileDim-1; - int32_t y2 = y1+TileDim-1; - - char markedcol = editorcolors[14]; - - setpolymost2dview(); - - y1=max(y1, 0); - y2=min(y2, ydim-1); - - { - // box - int32_t xx[] = {x1, x1, x2, x2, x1}; - int32_t yy[] = {y1, y2, y2, y1, y1}; - plotlines2d(xx, yy, 5, iTile==iSelected ? whitecol : markedcol); - } - - // cross - if (marked) - { - int32_t xx[] = {x1, x2}; - int32_t yy[] = {y1, y2}; - - plotlines2d(xx, yy, 2, markedcol); - swaplong(&yy[0], &yy[1]); - plotlines2d(xx, yy, 2, markedcol); - } + enddrawing(); + showframe(1); + return 1; } } } } - if (iSelected < 0 || iSelected >= MAXTILES) + tilescreen_drawrest(iSelected, showmsg); + + if (rendmode>=3 && qsetmode==200) { - enddrawing(); - return 1; + if (usehitilecnt==0) + { + enddrawing(); + showframe(1); + begindrawing(); + + usehitilecnt = 1; + goto restart; + } } - idTile = localartlookup[ iSelected ]; - - // Draw info bar at bottom. - - // Clear out behind the text for improved visibility. - //drawline256(0, (ydim-12)<<12, xdim<<12, (ydim-12)<<12, whitecol); - for (i=ydim-12; i>2,ydim-10,whitecol,-1,szT,0); - - // EditArt offset flags. - Bsprintf(szT,"%d, %d", (int8_t)((picanm[idTile]>>8)&0xFF), (int8_t)((picanm[idTile]>>16)&0xFF)); - printext256((xdim>>2)+100,ydim-10,whitecol,-1,szT,0); - - // EditArt animation flags. - if (picanm[idTile]&0xc0) - { - static const char *anmtype[] = {"", "Osc", "Fwd", "Bck"}; - - Bsprintf(szT,"%s %d", anmtype[(picanm[idTile]&0xc0)>>6], picanm[idTile]&0x3f); - printext256((xdim>>2)+100+14*8,ydim-10,whitecol,-1,szT,0); - } - - if (showmsg) - TMPERRMSG_SHOW(0); - - m32_showmouse(); - enddrawing(); showframe(1); - return(0); + return 0; } @@ -3701,31 +3883,27 @@ static int32_t DrawTiles(int32_t iTopLeft, int32_t iSelected, int32_t nXTiles, i #undef TMPERRMSG_PRINT #undef TMPERRMSG_RETURN - -static int32_t spriteonceilingz(int32_t searchwall) +#if 0 +static int32_t spriteonceilingz(int32_t i) { -// int32_t z=sprite[searchwall].z; + int32_t z = getceilzofslope(searchsector, sprite[i].x,sprite[i].y); + int32_t height, zofs; - int32_t z = getceilzofslope(searchsector,sprite[searchwall].x,sprite[searchwall].y); - int32_t tmphei = spriteheight(searchwall, NULL); + spriteheightofs(i, &height, &ofs); - if (sprite[searchwall].cstat&128) - z -= tmphei>>1; - if ((sprite[searchwall].cstat&48) != 32) - z += tmphei; - return z; + return z + height-ofs; } -static int32_t spriteongroundz(int32_t searchwall) +static int32_t spriteongroundz(int32_t i) { -// int32_t z=sprite[searchwall].z; + int32_t z = getflorzofslope(searchsector, sprite[i].x,sprite[i].y); + int32_t zofs; - int32_t z = getflorzofslope(searchsector,sprite[searchwall].x,sprite[searchwall].y); + spriteheightofs(i, NULL, &ofs); - if (sprite[searchwall].cstat&128) - z -= spriteheight(searchwall, NULL)>>1; - return z; + return z - ofs; } +#endif #define WIND1X 3 #define WIND1Y 150 @@ -4412,7 +4590,17 @@ static void Keys3d(void) AIMED_CEILINGFLOOR(pal), AIMED_CEILINGFLOOR(stat), sector[searchsector].lotag, sector[searchsector].hitag, sector[searchsector].extra); - Bsprintf(lines[num++],"Panning: %d, %d", AIMED_CEILINGFLOOR(xpanning), AIMED_CEILINGFLOOR(ypanning)); + { + int32_t xp=AIMED_CEILINGFLOOR(xpanning), yp=AIMED_CEILINGFLOOR(ypanning); +#ifdef YAX_ENABLE + int32_t notextended = 1; + if (yax_getbunch(searchsector, AIMING_AT_FLOOR) >= 0) + xp = yp = notextended = 0; + Bsprintf(lines[num++],"Panning: %d, %d%s", xp, yp, notextended?"":" *"); +#else + Bsprintf(lines[num++],"Panning: %d, %d", xp, yp); +#endif + } Bsprintf(lines[num++],"%sZ: %d", Typestr[searchstat], AIMED_CEILINGFLOOR(z)); Bsprintf(lines[num++],"Slope: %d", AIMED_CEILINGFLOOR(heinum)); lines[num++][0]=0; @@ -4675,8 +4863,8 @@ static void Keys3d(void) if (AIMING_AT_WALL_OR_MASK && PRESSED_KEYSC(PERIOD)) { int32_t naligned=AutoAlignWalls(searchwall, eitherCTRL, 0); - message("Auto-aligned %d wall%s %s based on wall %d", naligned, - naligned==1?"":"s", eitherCTRL?"recursively":"", searchwall); + message("Auto-aligned %d wall%s%s based on wall %d", naligned, + naligned==1?"":"s", eitherCTRL?" recursively":"", searchwall); } @@ -4695,6 +4883,9 @@ static void Keys3d(void) } if (keystatus[KEYSC_QUOTE] && PRESSED_KEYSC(L)) // ' L +#ifdef YAX_ENABLE + if (YAXCHK(!AIMING_AT_CEILING_OR_FLOOR || yax_getbunch(searchsector, AIMING_AT_FLOOR) < 0)) +#endif { i = noclip; noclip = 1; @@ -4748,7 +4939,7 @@ static void Keys3d(void) } - getzrange(&pos, cursectnum, &hiz, &hihit, &loz, &lohit, 128L, CLIPMASK0); + getzrange(&pos, cursectnum, &hiz, &hihit, &loz, &lohit, 128, CLIPMASK0); if (PRESSED_KEYSC(CAPS) || (keystatus[KEYSC_QUOTE] && PRESSED_KEYSC(Z))) // CAPS LOCK { @@ -5061,7 +5252,8 @@ static void Keys3d(void) if (AIMING_AT_CEILING_OR_FLOOR) { AIMED_CEILINGFLOOR(stat) ^= 8; - message("Sector %d %s texture expansion bit %s", searchsector, typestr[searchstat], ONOFF(sector[searchsector].ceilingstat&8)); + message("Sector %d %s texture expansion bit %s", searchsector, typestr[searchstat], + ONOFF(sector[searchsector].ceilingstat&8)); asksave = 1; } } @@ -5078,7 +5270,8 @@ static void Keys3d(void) if (AIMING_AT_CEILING_OR_FLOOR) { AIMED_CEILINGFLOOR(stat) ^= 64; - message("Sector %d %s texture relativity bit %s", searchsector, typestr[searchstat], ONOFF(AIMED_CEILINGFLOOR(stat)&64)); + message("Sector %d %s texture relativity bit %s", searchsector, typestr[searchstat], + ONOFF(AIMED_CEILINGFLOOR(stat)&64)); asksave = 1; } else if (AIMING_AT_SPRITE) @@ -5127,12 +5320,12 @@ static void Keys3d(void) else if (AIMING_AT_CEILING_OR_FLOOR) //8-way ceiling/floor flipping (bits 2,4,5) { static const int32_t next[8] = { 6, 7, 4, 5, 0, 1, 3, 2 }; // 0->6->3->5->1->7->2->4->0 - int16_t *stat = AIMING_AT_CEILING ? §or[searchsector].ceilingstat : §or[searchsector].floorstat; + int16_t *stat = &SECTORFLD(searchsector,stat, AIMING_AT_FLOOR); i = *stat; i = (i&0x4)+((i>>4)&3); i = next[i]; - message("Sector %d flip %d", searchsector, i); + message("Sector %d %s flip %d", searchsector, typestr[searchstat], i); i = (i&0x4)+((i&3)<<4); *stat &= ~0x34; *stat |= i; @@ -5193,17 +5386,14 @@ static void Keys3d(void) if (tsign) { - int16_t sect, havebtm=0, havetop=0; + int16_t sect0, sect, havebtm=0, havetop=0, moveCeilings, moveFloors; + int32_t cz, fz; k = 0; - if (highlightsectorcnt > 0) + if (highlightsectorcnt > 0 && searchsector>=0 && searchsector>3]&(1<<(searchsector&7))) + k = highlightsectorcnt; } if (k) @@ -5227,71 +5417,81 @@ static void Keys3d(void) } } - if (AIMING_AT_CEILING || havetop) - { - int32_t tmphei; + sect0 = sect; + moveCeilings = (AIMING_AT_CEILING || havetop); + moveFloors = (AIMING_AT_FLOOR || havebtm); + if (moveCeilings || moveFloors) + { + static const char *cfs[2] = { "ceiling", "floor" }; +#ifdef YAX_ENABLE + int16_t bunchnum, maxbunchnum=-1, cb, fb; + Bmemset(havebunch, 0, sizeof(havebunch)); +#endif for (j=0; j<(k?k:1); j++, sect=highlightsector[j]) { for (i=headspritesect[sect]; i!=-1; i=nextspritesect[i]) { - tmphei = spriteheight(i, NULL); - - tempint = getceilzofslope(sect, sprite[i].x, sprite[i].y); - tempint += tmphei; - - if (sprite[i].cstat&128) - tempint += tmphei>>1; - - if (sprite[i].z == tempint) + spriteoncfz(i, &cz, &fz); + if ((moveCeilings && sprite[i].z <= cz) || (moveFloors && sprite[i].z >= fz)) sprite[i].z += tsign * (updownunits << (eitherCTRL<<1)); // JBF 20031128 } - sector[sect].ceilingz += tsign * (updownunits << (eitherCTRL<<1)); // JBF 20031128 - message("Sector %d ceilingz = %d", sect, sector[sect].ceilingz); - } - } - else if (AIMING_AT_FLOOR || havebtm) - { - for (j=0; j<(k?k:1); j++, sect=highlightsector[j]) - { - for (i=headspritesect[sect]; i!=-1; i=nextspritesect[i]) + SECTORFLD(sect,z, moveFloors) += tsign * (updownunits << (eitherCTRL<<1)); // JBF 20031128 +#ifdef YAX_ENABLE + bunchnum = yax_getbunch(sect, moveFloors); + if (bunchnum >= 0 && !(havebunch[bunchnum>>3]&(1<<(bunchnum&7)))) { - tempint = getflorzofslope(sect,sprite[i].x,sprite[i].y); - - if (sprite[i].cstat&128) - tempint += spriteheight(i, NULL)>>1; - - if (sprite[i].z == tempint) - sprite[i].z += tsign * (updownunits << (eitherCTRL<<1)); // JBF 20031128 + maxbunchnum = max(maxbunchnum, bunchnum); + havebunch[bunchnum>>3] |= (1<<(bunchnum&7)); + tempzar[bunchnum] = &SECTORFLD(sect,z, moveFloors); } - - sector[sect].floorz += tsign * (updownunits << (eitherCTRL<<1)); // JBF 20031128 - message("Sector %d floorz = %d",sect,sector[sect].floorz); +#endif } - } - if (sector[searchsector].floorz < sector[searchsector].ceilingz) - { - if (tsign==-1) - sector[searchsector].floorz = sector[searchsector].ceilingz; + if (k<=1 && sector[sect0].floorz < sector[sect0].ceilingz) + { + if (moveFloors) + sector[sect0].floorz = sector[sect0].ceilingz; + else + sector[sect0].ceilingz = sector[sect0].floorz; + } + +#ifdef YAX_ENABLE + // sync z values of extended sectors' ceilings/floors + for (i=0; i= 0 && (havebunch[cb>>3]&(1<<(cb&7)))) + sector[i].ceilingz = *tempzar[cb]; + if (fb >= 0 && (havebunch[fb>>3]&(1<<(fb&7)))) + sector[i].floorz = *tempzar[fb]; + } + + if (k==0 && bunchnum>=0) + silentmessage("Bunch %d's ceilings and floors = %d", bunchnum, SECTORFLD(sect0,z, moveFloors)); else - sector[searchsector].ceilingz = sector[searchsector].floorz; +#endif + if (k==0) + silentmessage("Sector %d %sz = %d", sect0, cfs[moveFloors], SECTORFLD(sect0,z, moveFloors)); + else + silentmessage("%s %d sector %ss by %d units", tsign<0 ? "Raised" : "Lowered", + k, cfs[moveFloors], (updownunits << (eitherCTRL<<1))); } if (AIMING_AT_SPRITE) { + int32_t cz, fz; + if (eitherCTRL && !eitherALT) //CTRL - put sprite on ceiling/floor { - if (tsign==-1) - sprite[searchwall].z = spriteonceilingz(searchwall); - else - sprite[searchwall].z = spriteongroundz(searchwall); + spriteoncfz(searchwall, &cz, &fz); + sprite[searchwall].z = (tsign==1) ? fz : cz; } else { k = 0; - if (highlightcnt >= 0) + if (highlightcnt > 0) for (i=0; i= 0 && !mouseaction) { if (AIMING_AT_CEILING || (tsign < 0 && AIMING_AT_WALL_OR_MASK)) +#ifdef YAX_ENABLE + if (YAXCHK((bunchnum=yax_getbunch(searchsector, YAX_CEILING)) < 0 || yax_is121(bunchnum))) +#endif { alignceilslope(searchsector, sx, sy, getceilzofslope(ns, sx, sy)); message("Sector %d align ceiling to wall %d", searchsector, searchwall); } + if (AIMING_AT_FLOOR || (tsign > 0 && AIMING_AT_WALL_OR_MASK)) +#ifdef YAX_ENABLE + if (YAXCHK((bunchnum=yax_getbunch(searchsector, YAX_FLOOR)) < 0 || yax_is121(bunchnum))) +#endif { alignflorslope(searchsector, sx, sy, getflorzofslope(ns, sx, sy)); message("Sector %d align floor to wall %d", searchsector, searchwall); @@ -5840,13 +6050,18 @@ static void Keys3d(void) else { if (AIMING_AT_CEILING_OR_FLOOR) +#ifdef YAX_ENABLE + if (YAXCHK((bunchnum=yax_getbunch(searchsector, AIMING_AT_FLOOR)) < 0 || yax_is121(bunchnum))) +#endif { if (!(AIMED_CEILINGFLOOR(stat)&2)) AIMED_CEILINGFLOOR(heinum) = 0; - AIMED_CEILINGFLOOR(heinum) = clamp(AIMED_CEILINGFLOOR(heinum) + tsign*i, -BHEINUM_MAX, BHEINUM_MAX); + AIMED_CEILINGFLOOR(heinum) = clamp(AIMED_CEILINGFLOOR(heinum) + tsign*i, + -BHEINUM_MAX, BHEINUM_MAX); - message("Sector %d ceiling slope = %d",searchsector,AIMED_CEILINGFLOOR(heinum)); + silentmessage("Sector %d %s slope = %d", searchsector, + typestr[searchstat], AIMED_CEILINGFLOOR(heinum)); } } @@ -5870,7 +6085,7 @@ static void Keys3d(void) { int32_t fw,x1,y1,x2,y2,stat,ma,a=0; - stat = AIMING_AT_FLOOR ? sector[searchsector].floorstat : sector[searchsector].ceilingstat; + stat = SECTORFLD(searchsector,stat, AIMING_AT_FLOOR); if (stat&64) // align to first wall { fw=sector[searchsector].wallptr; @@ -5879,8 +6094,8 @@ static void Keys3d(void) a=getangle(x1-x2,y1-y2); } mouseax+=mousex; mouseay+=mousey; - ma=getangle(mouseax,mouseay); - ma+=ang-a; + ma = getangle(mouseax,mouseay); + ma += ang-a; i = stat; i = (i&0x4)+((i>>4)&3); @@ -5922,6 +6137,9 @@ static void Keys3d(void) mouseay=0; if (AIMING_AT_CEILING_OR_FLOOR) +#ifdef YAX_ENABLE + if (YAXCHK(yax_getbunch(searchsector, AIMING_AT_FLOOR) < 0)) +#endif { changedir = 1-2*(x1<0); x1 = klabs(x1); @@ -5935,10 +6153,10 @@ static void Keys3d(void) while (y1--) AIMED_CEILINGFLOOR(ypanning) = changechar(AIMED_CEILINGFLOOR(ypanning),changedir,0,0); - message("Sector %d %s panning: %d, %d", searchsector, typestr[searchstat], - AIMED_CEILINGFLOOR(xpanning), AIMED_CEILINGFLOOR(ypanning)); + silentmessage("Sector %d %s panning: %d, %d", searchsector, typestr[searchstat], + AIMED_CEILINGFLOOR(xpanning), AIMED_CEILINGFLOOR(ypanning)); + asksave=1; } - asksave=1; } } mousex=0; @@ -6003,7 +6221,7 @@ static void Keys3d(void) { while (updownunits--) wall[searchwall].xrepeat = changechar(wall[searchwall].xrepeat, changedir, smooshyalign, 1); - message("Wall %d repeat: %d, %d", searchwall, wall[searchwall].xrepeat, wall[searchwall].yrepeat); + silentmessage("Wall %d repeat: %d, %d", searchwall, wall[searchwall].xrepeat, wall[searchwall].yrepeat); } else { @@ -6023,17 +6241,22 @@ static void Keys3d(void) while (updownunits--) wall[w].xpanning = changechar(wall[w].xpanning, changedir, smooshyalign, 0); - message("Wall %d panning: %d, %d", w, wall[w].xpanning, wall[w].ypanning); + silentmessage("Wall %d panning: %d, %d", w, wall[w].xpanning, wall[w].ypanning); } asksave = 1; } else if (AIMING_AT_CEILING_OR_FLOOR) { - while (updownunits--) - AIMED_CEILINGFLOOR(xpanning) = changechar(AIMED_CEILINGFLOOR(xpanning), changedir, smooshyalign, 0); - message("Sector %d %s panning: %d, %d", searchsector, typestr[searchstat], - AIMED_CEILINGFLOOR(xpanning), AIMED_CEILINGFLOOR(ypanning)); - asksave = 1; +#ifdef YAX_ENABLE + if (YAXCHK(yax_getbunch(searchsector, AIMING_AT_FLOOR) < 0)) +#endif + { + while (updownunits--) + AIMED_CEILINGFLOOR(xpanning) = changechar(AIMED_CEILINGFLOOR(xpanning), changedir, smooshyalign, 0); + silentmessage("Sector %d %s panning: %d, %d", searchsector, typestr[searchstat], + AIMED_CEILINGFLOOR(xpanning), AIMED_CEILINGFLOOR(ypanning)); + asksave = 1; + } } else if (AIMING_AT_SPRITE) { @@ -6050,7 +6273,7 @@ static void Keys3d(void) sprite[searchwall].xrepeat = changechar(sprite[searchwall].xrepeat, changedir, smooshyalign, 1); if (sprite[searchwall].xrepeat < 4) sprite[searchwall].xrepeat = 4; - message("Sprite %d repeat: %d, %d", searchwall, sprite[searchwall].xrepeat, sprite[searchwall].yrepeat); + silentmessage("Sprite %d repeat: %d, %d", searchwall, sprite[searchwall].xrepeat, sprite[searchwall].yrepeat); } } asksave = 1; @@ -6117,7 +6340,7 @@ static void Keys3d(void) { while (updownunits--) wall[searchwall].yrepeat = changechar(wall[searchwall].yrepeat, changedir, smooshyalign, 1); - message("Wall %d repeat: %d, %d", searchwall, wall[searchwall].xrepeat, wall[searchwall].yrepeat); + silentmessage("Wall %d repeat: %d, %d", searchwall, wall[searchwall].xrepeat, wall[searchwall].yrepeat); } else { @@ -6126,16 +6349,21 @@ static void Keys3d(void) updownunits *= 8; while (updownunits--) wall[w].ypanning = changechar(wall[w].ypanning, changedir, smooshyalign, 0); - message("Wall %d panning: %d, %d", w, wall[w].xpanning, wall[w].ypanning); + silentmessage("Wall %d panning: %d, %d", w, wall[w].xpanning, wall[w].ypanning); } } else if (AIMING_AT_CEILING_OR_FLOOR) { - while (updownunits--) - AIMED_CEILINGFLOOR(ypanning) = changechar(AIMED_CEILINGFLOOR(ypanning), changedir, smooshyalign, 0); - message("Sector %d %s panning: %d, %d", searchsector, typestr[searchstat], - AIMED_CEILINGFLOOR(xpanning), AIMED_CEILINGFLOOR(ypanning)); - asksave = 1; +#ifdef YAX_ENABLE + if (YAXCHK(yax_getbunch(searchsector, AIMING_AT_FLOOR) < 0)) +#endif + { + while (updownunits--) + AIMED_CEILINGFLOOR(ypanning) = changechar(AIMED_CEILINGFLOOR(ypanning), changedir, smooshyalign, 0); + silentmessage("Sector %d %s panning: %d, %d", searchsector, typestr[searchstat], + AIMED_CEILINGFLOOR(xpanning), AIMED_CEILINGFLOOR(ypanning)); + asksave = 1; + } } else if (AIMING_AT_SPRITE) { @@ -6150,7 +6378,7 @@ static void Keys3d(void) sprite[searchwall].yrepeat = changechar(sprite[searchwall].yrepeat, changedir, smooshyalign, 1); if (sprite[searchwall].yrepeat < 4) sprite[searchwall].yrepeat = 4; - message("Sprite %d repeat: %d, %d", searchwall, sprite[searchwall].xrepeat, sprite[searchwall].yrepeat); + silentmessage("Sprite %d repeat: %d, %d", searchwall, sprite[searchwall].xrepeat, sprite[searchwall].yrepeat); } } asksave = 1; @@ -6203,6 +6431,10 @@ static void Keys3d(void) tempvis = sector[searchsector].visibility; tempxrepeat = AIMED_CEILINGFLOOR(xpanning); tempyrepeat = AIMED_CEILINGFLOOR(ypanning); +#ifdef YAX_ENABLE + if (yax_getbunch(searchsector, AIMING_AT_FLOOR) >= 0) + tempxrepeat = tempyrepeat = 0; +#endif tempcstat = AIMED_CEILINGFLOOR(stat); } else if (AIMING_AT_SPRITE) @@ -6222,24 +6454,18 @@ static void Keys3d(void) if (PRESSED_KEYSC(ENTER)) // ENTER -- paste clipboard contents { - extern char pskysearch[MAXSECTORS]; - int16_t daang; - int32_t dashade[2]; - if (eitherSHIFT) { if (AIMING_AT_WALL_OR_MASK && eitherCTRL) //Ctrl-shift Enter (auto-shade) { - dashade[0] = 127; - dashade[1] = -128; + int16_t daang; + int32_t dashade[2] = { 127, -128 }; i = searchwall; do { - if (dashade[0] > (int32_t)wall[i].shade) - dashade[0] = wall[i].shade; - if (dashade[1] < (int32_t)wall[i].shade) - dashade[1] = wall[i].shade; + dashade[0] = min(dashade[0], wall[i].shade); + dashade[1] = max(dashade[1], wall[i].shade); i = wall[i].point2; } @@ -6261,7 +6487,8 @@ static void Keys3d(void) } while (i != searchwall); - message("Wall %d auto-shaded", searchwall); + message("Auto-shaded wall %d's loop", searchwall); + asksave = 1; } else if (somethingintab < 255) { @@ -6283,6 +6510,7 @@ static void Keys3d(void) } else if (AIMING_AT_WALL_OR_MASK && eitherCTRL && somethingintab < 255) //Either ctrl key { + int32_t clipboard_has_wall = (somethingintab == SEARCH_WALL || somethingintab == SEARCH_MASKWALL); i = searchwall; do { @@ -6290,7 +6518,7 @@ static void Keys3d(void) wall[i].shade = tempshade; wall[i].pal = temppal; - if (somethingintab == SEARCH_WALL || somethingintab == SEARCH_MASKWALL) + if (clipboard_has_wall) { wall[i].xrepeat = tempxrepeat; wall[i].yrepeat = tempyrepeat; @@ -6302,11 +6530,13 @@ static void Keys3d(void) } while (i != searchwall); - message("Pasted picnum+shading+pal"); + message("Pasted picnum+shading+pal%s", clipboard_has_wall?"+pixelwidth":""); asksave = 1; } else if (AIMING_AT_CEILING_OR_FLOOR && eitherCTRL && somethingintab < 255) //Either ctrl key { + static char pskysearch[MAXSECTORS]; + Bmemset(pskysearch, 0, numsectors); i = searchsector; @@ -6320,6 +6550,9 @@ static void Keys3d(void) CEILINGFLOOR(i, pal) = temppal; if (somethingintab == SEARCH_CEILING || somethingintab == SEARCH_FLOOR) +#ifdef YAX_ENABLE + if (yax_getbunch(i, AIMING_AT_FLOOR) < 0) +#endif { CEILINGFLOOR(i, xpanning) = tempxrepeat; CEILINGFLOOR(i, ypanning) = tempyrepeat; @@ -6344,7 +6577,7 @@ static void Keys3d(void) i = j; } - message("Pasted picnum+shading+pal"); + message("Pasted picnum+shading+pal to adjoining sector %ss", typestr[searchstat]); asksave = 1; } else if (somethingintab < 255) @@ -6395,6 +6628,9 @@ static void Keys3d(void) AIMED_CEILINGFLOOR(pal) = temppal; if (somethingintab == SEARCH_CEILING || somethingintab == SEARCH_FLOOR) +#ifdef YAX_ENABLE + if (yax_getbunch(searchsector, AIMING_AT_FLOOR) < 0) +#endif { AIMED_CEILINGFLOOR(xpanning) = tempxrepeat; AIMED_CEILINGFLOOR(ypanning) = tempyrepeat; @@ -6513,10 +6749,25 @@ static void Keys3d(void) } else if (AIMING_AT_CEILING_OR_FLOOR) { - AIMED_CEILINGFLOOR(xpanning) = 0; - AIMED_CEILINGFLOOR(ypanning) = 0; +#ifdef YAX_ENABLE + j = yax_getbunch(searchsector, AIMING_AT_FLOOR); + if (j < 0) +#endif + { + AIMED_CEILINGFLOOR(xpanning) = 0; + AIMED_CEILINGFLOOR(ypanning) = 0; + } AIMED_CEILINGFLOOR(stat) &= ~2; AIMED_CEILINGFLOOR(heinum) = 0; +#ifdef YAX_ENABLE + if (j >= 0) + for (i=0; i>3]&(1<<(w&7)))) { wallshades[w] = wall[w].shade; - wall[w].shade = sprite[i].shade; wallpals[w] = wall[w].pal; + + wall[w].shade = sprite[i].shade; wall[w].pal = sprite[i].pal; - wallflag[w] = 1; + + wallflag[w>>3] |= (1<<(w&7)); } - /* if (wall[w].nextwall >= 0) - { - if (!wallflag[wall[w].nextwall]) - { - wallshades[wall[w].nextwall] = NEXTWALL(w).shade; - NEXTWALL(w).shade = sprite[i].shade; - wallpals[wall[w].nextwall] = NEXTWALL(w).pal; - NEXTWALL(w).pal = sprite[i].pal; - wallflag[wall[w].nextwall] = 1; - } - } */ + // removed: same thing with nextwalls } sectorshades[isec][0] = sector[isec].floorshade; sectorshades[isec][1] = sector[isec].ceilingshade; sector[isec].floorshade = sprite[i].shade; sector[isec].ceilingshade = sprite[i].shade; + sectorpals[isec][0] = sector[isec].floorpal; sectorpals[isec][1] = sector[isec].ceilingpal; sector[isec].floorpal = sprite[i].pal; sector[isec].ceilingpal = sprite[i].pal; - w = headspritesect[isec]; - while (w >= 0) + + for (w = headspritesect[isec]; w >= 0; w = nextspritesect[w]) { - if (w == i) { w = nextspritesect[w]; continue; } + if (w == i) + continue; + spriteshades[w] = sprite[w].shade; - sprite[w].shade = sprite[i].shade; spritepals[w] = sprite[w].pal; + + sprite[w].shade = sprite[i].shade; sprite[w].pal = sprite[i].pal; - w = nextspritesect[w]; } } else if (sprite[i].picnum == SECTOREFFECTOR && (sprite[i].lotag == 49 || sprite[i].lotag == 50)) @@ -9385,32 +9639,7 @@ void ExtPreCheckKeys(void) // just before drawrooms #pragma pack(push,1) _prlight mylight; #pragma pack(pop) - mylight.sector = SECT; - Bmemcpy(&mylight, &sprite[i], sizeof(vec3_t)); - mylight.range = SHT; - mylight.color[0] = sprite[i].xvel; - mylight.color[1] = sprite[i].yvel; - mylight.color[2] = sprite[i].zvel; - mylight.radius = 0; - mylight.angle = SA; - mylight.horiz = SH; - mylight.minshade = sprite[i].xoffset; - mylight.maxshade = sprite[i].yoffset; - mylight.tilenum = 0; - - if (CS & 2) - { - if (CS & 512) - mylight.priority = PR_LIGHT_PRIO_LOW; - else - mylight.priority = PR_LIGHT_PRIO_HIGH; - } - else - mylight.priority = PR_LIGHT_PRIO_MAX; - - spritelightid[i] = polymer_addlight(&mylight); - if (spritelightid[i] >= 0) - spritelightptr[i] = &prlights[spritelightid[i]]; + addprlight_common1(&mylight, i); } else { @@ -9425,14 +9654,8 @@ void ExtPreCheckKeys(void) // just before drawrooms spritelightptr[i]->range = SHT; spritelightptr[i]->flags.invalidate = 1; } - if ((sprite[i].xvel != spritelightptr[i]->color[0]) || - (sprite[i].yvel != spritelightptr[i]->color[1]) || - (sprite[i].zvel != spritelightptr[i]->color[2])) - { - spritelightptr[i]->color[0] = sprite[i].xvel; - spritelightptr[i]->color[1] = sprite[i].yvel; - spritelightptr[i]->color[2] = sprite[i].zvel; - } + if (check_prlight_colors(i)) + copy_prlight_colors(spritelightptr[i], i); } } } @@ -9445,34 +9668,11 @@ void ExtPreCheckKeys(void) // just before drawrooms #pragma pack(push,1) _prlight mylight; #pragma pack(pop) - - mylight.sector = SECT; - Bmemcpy(&mylight, &sprite[i], sizeof(vec3_t)); - mylight.range = SHT; - mylight.color[0] = sprite[i].xvel; - mylight.color[1] = sprite[i].yvel; - mylight.color[2] = sprite[i].zvel; mylight.radius = (256-(SS+128))<<1; mylight.faderadius = (int16_t)(mylight.radius * 0.75f); - mylight.angle = SA; - mylight.horiz = SH; - mylight.minshade = sprite[i].xoffset; - mylight.maxshade = sprite[i].yoffset; mylight.tilenum = OW; - if (CS & 2) - { - if (CS & 512) - mylight.priority = PR_LIGHT_PRIO_LOW; - else - mylight.priority = PR_LIGHT_PRIO_HIGH; - } - else - mylight.priority = PR_LIGHT_PRIO_MAX; - - spritelightid[i] = polymer_addlight(&mylight); - if (spritelightid[i] >= 0) - spritelightptr[i] = &prlights[spritelightid[i]]; + addprlight_common1(&mylight, i); } else { @@ -9487,14 +9687,8 @@ void ExtPreCheckKeys(void) // just before drawrooms spritelightptr[i]->range = SHT; spritelightptr[i]->flags.invalidate = 1; } - if ((sprite[i].xvel != spritelightptr[i]->color[0]) || - (sprite[i].yvel != spritelightptr[i]->color[1]) || - (sprite[i].zvel != spritelightptr[i]->color[2])) - { - spritelightptr[i]->color[0] = sprite[i].xvel; - spritelightptr[i]->color[1] = sprite[i].yvel; - spritelightptr[i]->color[2] = sprite[i].zvel; - } + if (check_prlight_colors(i)) + copy_prlight_colors(spritelightptr[i], i); if (((256-(SS+128))<<1) != spritelightptr[i]->radius) { spritelightptr[i]->radius = (256-(SS+128))<<1; @@ -9669,8 +9863,6 @@ void ExtPreCheckKeys(void) // just before drawrooms drawlinepat = 0xf0f0f0f0; drawcircle16(halfxdim16+xp1, midydim16+yp1, radius, scalescreeny(16384), editorcolors[(int32_t)col]); drawlinepat = 0xffffffff; - // radius = mulscale15(sprite[i].hitag,zoom); - // drawcircle16(halfxdim16+xp1, midydim16+yp1, radius, col); } } @@ -9687,7 +9879,8 @@ void ExtAnalyzeSprites(void) { frames=0; - if ((nosprites==1||nosprites==3)&&tspr->picnum<11) tspr->xrepeat=0; + if ((nosprites==1||nosprites==3) && tspr->picnum<11) + tspr->xrepeat=0; if (nosprites==1||nosprites==3) switch (tspr->picnum) @@ -9723,7 +9916,7 @@ void ExtAnalyzeSprites(void) if ((tspr->owner>=0 && (sprite[tspr->owner].cstat&2048)==0)) { - l = clamp(l, -127, 127); + inpclamp(&l, -127, 127); // tspr->shade = l; } } @@ -9822,9 +10015,9 @@ void ExtAnalyzeSprites(void) tspr->picnum -= 5; //Hack, for actors } break; + default: break; - } } @@ -9975,14 +10168,13 @@ void ExtCheckKeys(void) for (i=0; i>3]&(1<<(w&7))) { wall[w].shade = wallshades[w]; wall[w].pal = wallpals[w]; - wallflag[w] = 0; + wallflag[w>>3] &= ~(1<<(w&7)); } -#if 0 - if (wall[w].nextwall >= 0) - { - if (wallflag[wall[w].nextwall]) - { - NEXTWALL(w).shade = wallshades[wall[w].nextwall]; - NEXTWALL(w).pal = wallpals[wall[w].nextwall]; - wallflag[wall[w].nextwall] = 0; - } - } -#endif + // removed: same thing with nextwalls } sector[isec].floorshade = sectorshades[isec][0]; sector[isec].ceilingshade = sectorshades[isec][1]; @@ -10020,7 +10202,6 @@ void ExtCheckKeys(void) continue; sprite[w].shade = spriteshades[w]; sprite[w].pal = spritepals[w]; - w = nextspritesect[w]; } } @@ -10547,8 +10728,6 @@ static void EditSectorData(int16_t sectnum) med_printcurline(xpos, ypos, row, 0); col = 1; xpos = 208; - rowmax = 6; - med_dispwidth = 24; med_disptext[med_dispwidth] = 0; if (row > rowmax) row = rowmax; } @@ -10560,13 +10739,19 @@ static void EditSectorData(int16_t sectnum) med_printcurline(xpos, ypos, row, 0); col = 2; xpos = 408; - rowmax = 6; - med_dispwidth = 24; med_disptext[med_dispwidth] = 0; if (row > rowmax) row = rowmax; } } +#ifdef YAX_ENABLE + if (med_editval) + { + if ((row==0 || row==1 || row==3 || row==5) && yax_getbunch(sectnum, (col==2)) >= 0) + med_editval = 0; + } +#endif + if (col == 1) { switch (row) @@ -10581,14 +10766,14 @@ static void EditSectorData(int16_t sectnum) { Bsprintf(med_edittext,"Sector %d Ceiling X Pan: ",sectnum); printmessage16("%s", med_edittext); - sector[sectnum].ceilingxpanning = (char)getnumber16(med_edittext,(int32_t)sector[sectnum].ceilingxpanning,256L,0); + sector[sectnum].ceilingxpanning = (char)getnumber16(med_edittext,(int32_t)sector[sectnum].ceilingxpanning,255,0); Bsprintf(med_edittext,"Sector %d Ceiling Y Pan: ",sectnum); printmessage16("%s", med_edittext); - sector[sectnum].ceilingypanning = (char)getnumber16(med_edittext,(int32_t)sector[sectnum].ceilingypanning,256L,0); + sector[sectnum].ceilingypanning = (char)getnumber16(med_edittext,(int32_t)sector[sectnum].ceilingypanning,255,0); } break; case 2: - handlemed(0, "Shade byte", "Ceiling Shade", §or[sectnum].ceilingshade,sizeof(sector[sectnum].ceilingshade), 128L, 1); + handlemed(0, "Shade byte", "Ceiling Shade", §or[sectnum].ceilingshade,sizeof(sector[sectnum].ceilingshade), 128, 1); break; case 3: handlemed(0, "Z-coordinate", "Ceiling Z-coordinate", §or[sectnum].ceilingz, @@ -10623,10 +10808,10 @@ static void EditSectorData(int16_t sectnum) { Bsprintf(med_edittext,"Sector %d Floor X Pan: ",sectnum); printmessage16("%s", med_edittext); - sector[sectnum].floorxpanning = (char)getnumber16(med_edittext,(int32_t)sector[sectnum].floorxpanning,256,0); + sector[sectnum].floorxpanning = (char)getnumber16(med_edittext,(int32_t)sector[sectnum].floorxpanning,255,0); Bsprintf(med_edittext,"Sector %d Floor Y Pan: ",sectnum); printmessage16("%s", med_edittext); - sector[sectnum].floorypanning = (char)getnumber16(med_edittext,(int32_t)sector[sectnum].floorypanning,256,0); + sector[sectnum].floorypanning = (char)getnumber16(med_edittext,(int32_t)sector[sectnum].floorypanning,255,0); } break; @@ -10982,7 +11167,7 @@ static void EditSpriteData(int16_t spritenum) #define TWENTYFIVE_BLANKS " " -static void GenericSpriteSearch() +static void GenericSpriteSearch(void) { char disptext[80]; char edittext[80]; diff --git a/polymer/eduke32/source/m32vars.c b/polymer/eduke32/source/m32vars.c index d312f744b..45469fb68 100644 --- a/polymer/eduke32/source/m32vars.c +++ b/polymer/eduke32/source/m32vars.c @@ -562,6 +562,9 @@ static void Gv_AddSystemVars(void) Gv_NewVar("numsectors",(intptr_t)&numsectors, GAMEVAR_SYSTEM | GAMEVAR_SHORTPTR | GAMEVAR_READONLY); Gv_NewVar("numsprites",(intptr_t)&numsprites, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_READONLY); Gv_NewVar("numtiles",(intptr_t)&numtiles, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_READONLY); +#ifdef YAX_ENABLE + Gv_NewVar("numbunches",(intptr_t)&numyaxbunches, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_READONLY); +#endif #ifdef USE_OPENGL Gv_NewVar("rendmode",(intptr_t)&rendmode, GAMEVAR_READONLY | GAMEVAR_INTPTR | GAMEVAR_SYSTEM); @@ -665,7 +668,12 @@ static void Gv_AddSystemVars(void) Gv_NewArray("hstat", (void *)headspritestat, MAXSTATUS+1, GAMEARRAY_READONLY|GAMEARRAY_OFSHORT); Gv_NewArray("nstat", (void *)prevspritestat, MAXSPRITES, GAMEARRAY_READONLY|GAMEARRAY_OFSHORT); Gv_NewArray("pstat", (void *)nextspritestat, MAXSPRITES, GAMEARRAY_READONLY|GAMEARRAY_OFSHORT); - +#ifdef YAX_ENABLE + Gv_NewArray("headsectbunchc", (void *)headsectbunch[0], YAX_MAXBUNCHES, GAMEARRAY_READONLY|GAMEARRAY_OFSHORT); + Gv_NewArray("nextsectbunchc", (void *)nextsectbunch[0], MAXSECTORS, GAMEARRAY_READONLY|GAMEARRAY_OFSHORT); + 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("picsiz", (void *)picsiz, MAXTILES, GAMEARRAY_READONLY|GAMEARRAY_OFCHAR); diff --git a/polymer/eduke32/source/premap.c b/polymer/eduke32/source/premap.c index 59b1b28b4..43775b6d2 100644 --- a/polymer/eduke32/source/premap.c +++ b/polymer/eduke32/source/premap.c @@ -1843,7 +1843,7 @@ int32_t G_EnterLevel(int32_t g) resetpspritevars(g); //cachedebug = 0; - automapping = 0; +// automapping = 0; G_FadeLoad(0,0,0, 63, 0, -7); G_CacheMapData();