diff --git a/polymer/eduke32/build/include/build.h b/polymer/eduke32/build/include/build.h index 280d25163..d41c2614c 100644 --- a/polymer/eduke32/build/include/build.h +++ b/polymer/eduke32/build/include/build.h @@ -830,6 +830,8 @@ EXTERN char faketile[(MAXTILES+7)>>3]; EXTERN char *faketiledata[MAXTILES]; EXTERN char spritecol2d[MAXTILES][2]; +EXTERN uint8_t tilecols[MAXTILES]; + extern char vgapal16[4*256]; extern uint32_t drawlinepat; diff --git a/polymer/eduke32/build/include/editor.h b/polymer/eduke32/build/include/editor.h index 91d5f3880..b4546e535 100644 --- a/polymer/eduke32/build/include/editor.h +++ b/polymer/eduke32/build/include/editor.h @@ -375,6 +375,7 @@ static inline int32_t m32_is2d3dmode(void) searchy > m32_2d3d.y && searchy < (m32_2d3d.y + YSIZE_2D3D); } +extern int32_t getspritecol(int32_t spr); #define NEXTWALL(i) (wall[wall[i].nextwall]) #define POINT2(i) (wall[wall[i].point2]) diff --git a/polymer/eduke32/build/src/build.c b/polymer/eduke32/build/src/build.c index 04b2cc35f..dbfa28abb 100644 --- a/polymer/eduke32/build/src/build.c +++ b/polymer/eduke32/build/src/build.c @@ -244,7 +244,7 @@ static void getclosestpointonwall(int32_t x, int32_t y, int32_t dawall, int32_t static void initcrc(void); static int32_t menuselect(void); -static int32_t menuselect_auto(int32_t); //PK +static int32_t menuselect_auto(int, int); //PK static int32_t insert_sprite_common(int32_t sucksect, int32_t dax, int32_t day); static void correct_ornamented_sprite(int32_t i, int32_t hitw); @@ -1025,13 +1025,13 @@ static void mainloop_move(void) if (vel != 0) { - xvect += (vel*doubvel*(int32_t) sintable[(ang+2560)&2047])>>3; - yvect += (vel*doubvel*(int32_t) sintable[(ang+2048)&2047])>>3; + xvect += ((vel*doubvel)>>3)*(int32_t) sintable[(ang+2560)&2047]; + yvect += ((vel*doubvel)>>3)*(int32_t) sintable[(ang+2048)&2047]; } if (svel != 0) { - xvect += (svel*doubvel*(int32_t) sintable[(ang+2048)&2047])>>3; - yvect += (svel*doubvel*(int32_t) sintable[(ang+1536)&2047])>>3; + xvect += ((svel*doubvel)>>3)*(int32_t) sintable[(ang+2048)&2047]; + yvect += ((svel*doubvel)>>3)*(int32_t) sintable[(ang+1536)&2047]; } move_and_update(xvect, yvect, 0); @@ -3301,13 +3301,25 @@ void overheadeditor(void) { int32_t mousx, mousy; - if (zoom < ztarget) zoom += (ztarget-zoom)>>3; - if (zoom > ztarget) zoom -= (zoom-ztarget)>>3; + if (zoom < ztarget) + { + if ((ztarget - zoom) >> 3) + zoom += (ztarget - zoom) >> 3; + else zoom++; + zoom = min(zoom, ztarget); + } + else if (zoom > ztarget) + { + if ((zoom - ztarget) >> 3) + zoom -= (zoom - ztarget) >> 3; + else zoom--; + zoom = max(zoom, ztarget); + } if (!((vel|angvel|svel) //DOWN_BK(MOVEFORWARD) || DOWN_BK(MOVEBACKWARD) || DOWN_BK(TURNLEFT) || DOWN_BK(TURNRIGHT) || DOWN_BK(MOVEUP) || DOWN_BK(MOVEDOWN) || keystatus[0x10] || keystatus[0x11] || keystatus[0x48] || keystatus[0x4b] || keystatus[0x4d] || keystatus[0x50] // keypad keys - || bstatus || OSD_IsMoving())) + || bstatus || OSD_IsMoving() || ztarget != zoom)) { if (totalclock > waitdelay) { @@ -3557,16 +3569,33 @@ void overheadeditor(void) dabuffer = CallExtGetSpriteCaption(i); if (dabuffer[0] != 0) { +/* int32_t blocking = (sprite[i].cstat&1); col = 3 + 2*blocking; if (spritecol2d[sprite[i].picnum][blocking]) col = spritecol2d[sprite[i].picnum][blocking]; +*/ + + if (sprite[i].sectnum < 0) + col = editorcolors[4]; // red + else + { + if (spritecol2d[sprite[i].picnum][0]) + col = editorcolors[spritecol2d[sprite[i].picnum][0]]; + else + { + col = getspritecol(i); + + if (col == -1) + col = editorcolors[3]; + } + } if ((i == pointhighlight-16384) && (totalclock & 32)) col += (2<<2); - drawsmallabel(dabuffer, editorcolors[0], editorcolors[col], + drawsmallabel(dabuffer, editorcolors[0], col, sprite[i].x, sprite[i].y, sprite[i].z); } } @@ -3848,13 +3877,10 @@ void overheadeditor(void) } drawline16base(searchx, searchy, +0, -8, +0, -1, col); - drawline16base(searchx, searchy, +1, -8, +1, -1, col); - drawline16base(searchx, searchy, +0, +2, +0, +9, col); - drawline16base(searchx, searchy, +1, +2, +1, +9, col); - drawline16base(searchx, searchy, -8, +0, -1, +0, col); - drawline16base(searchx, searchy, -8, +1, -1, +1, col); - drawline16base(searchx, searchy, +2, +0, +9, +0, col); - drawline16base(searchx, searchy, +2, +1, +9, +1, col); + drawline16base(searchx, searchy, +0, 1, +0, 8, col); + + drawline16base(searchx, searchy, -8, 0, -1, 0, col); + drawline16base(searchx, searchy, 1, 0, 8, 0, col); ////// Draw the white pixel closest to mouse cursor on linehighlight if (linehighlight>=0) @@ -4846,7 +4872,7 @@ end_yax: ; if (highlightsectorcnt < 0) { - if (keystatus[0x36]) //Right shift (point highlighting) + if ((bstatus & 1 && highlightcnt <= 0) || (bstatus & 1 && pointhighlight == -1) || keystatus[0x36]) //Right shift (point highlighting) { if (highlightcnt == 0) { @@ -4857,9 +4883,9 @@ end_yax: ; highlighty2 = searchy; ydim16 = ydim-STATUS2DSIZ2; - plotlines2d(xx, yy, 5, editorcolors[5]); + plotlines2d(xx, yy, 5, editorcolors[14]); } - else + else if (pointhighlight == -1 || keystatus[0x36]) { highlightcnt = 0; @@ -5881,7 +5907,7 @@ end_point_dragging: if ((DOWN_BK(MOVEUP) || (bstatus&16)) && zoom < 32768) { if (DOWN_BK(MOVEUP)) - ztarget += synctics*(ztarget>>4); + ztarget += (synctics*(ztarget>>4))>>(eitherSHIFT<<1); if (bstatus&16) ztarget += 4*(ztarget>>4); @@ -5891,7 +5917,7 @@ end_point_dragging: if ((DOWN_BK(MOVEDOWN) || (bstatus&32)) && zoom > 32) { if (DOWN_BK(MOVEDOWN)) - ztarget -= synctics*(ztarget>>4); + ztarget -= (synctics*(ztarget>>4))>>(eitherSHIFT<<1); if (bstatus&32) ztarget -= 4*(ztarget>>4); @@ -7778,11 +7804,13 @@ end_insert_points: if (quickmapcycling && keystatus[0x2d]) //X { + if (eitherCTRL) //Ctrl { + int skip = 0; nextmap: // bad = 0; - i = menuselect_auto(keystatus[0x2a] ? 0:1); // LShift: prev map + i = menuselect_auto(keystatus[0x2a] ? 0:1, skip); // LShift: prev map if (i < 0) { if (i == -1) @@ -7793,7 +7821,10 @@ nextmap: else { if (LoadBoard(NULL, 4)) + { + skip = 2; goto nextmap; + } RESET_EDITOR_VARS(); oposz = pos.z; @@ -8965,15 +8996,15 @@ void clearmidstatbar16(void) static void clearministatbar16(void) { - int32_t i, col = whitecol - 21; + int32_t i, col = whitecol - 16; begindrawing(); - for (i=ydim-STATUS2DSIZ2; inext) - findfileshigh=findfileshigh->next; + if (direction) + { + if (findfileshigh->next) + findfileshigh=findfileshigh->next; + else + return -1; + } else - return -1; - } - else - { - if (findfileshigh->prev) - findfileshigh=findfileshigh->prev; - else - return -1; - } + { + if (findfileshigh->prev) + findfileshigh=findfileshigh->prev; + else + return -1; + } + } while (skip--); Bstrcat(selectedboardfilename, findfileshigh->name); @@ -10496,16 +10530,16 @@ static void keytimerstuff(void) if (DOWN_BK(STRAFE) == 0) { - if (DOWN_BK(TURNLEFT)) angvel = max(angvel-pk_turnaccel, -128); + if (DOWN_BK(TURNLEFT)) angvel = max(angvel-pk_turnaccel, -127); if (DOWN_BK(TURNRIGHT)) angvel = min(angvel+pk_turnaccel, 127); } else { if (DOWN_BK(TURNLEFT)) svel = min(svel+16, 255); // svel and vel aren't even chars... - if (DOWN_BK(TURNRIGHT)) svel = max(svel-16, -256); + if (DOWN_BK(TURNRIGHT)) svel = max(svel-16, -255); } if (DOWN_BK(MOVEFORWARD)) vel = min(vel+16, 255); - if (DOWN_BK(MOVEBACKWARD)) vel = max(vel-16, -256); + if (DOWN_BK(MOVEBACKWARD)) vel = max(vel-16, -255); /* if (DOWN_BK(STRAFELEFT)) svel = min(svel+8, 127); if (DOWN_BK(STRAFERIGHT)) svel = max(svel-8, -128); */ diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index 1ccfc413d..7a250c3ac 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -10626,6 +10626,7 @@ static int32_t finish_loadboard(const vec3_t *dapos, int16_t *dacursectnum, int1 guniqhudid = 0; + Bmemset(tilecols, 0, sizeof(tilecols)); return numremoved; } @@ -17235,27 +17236,73 @@ static void drawscreen_drawwall(int32_t i, int32_t posxe, int32_t posye, int32_t } } +int32_t getspritecol(int32_t spr) +{ + int picnum = sprite[spr].picnum; + int pal = sprite[spr].pal; + + if (palookup[pal] == NULL) pal = 0; + + if (tilecols[picnum]) return palookup[pal][tilecols[picnum]]; + + if (!waloff[picnum]) loadtile(picnum); + if (!waloff[picnum]) return -1; + + uint32_t cols[256]; + + Bmemset(cols, 0, sizeof(cols)); + + for (int i = 0; i < tilesiz[picnum].x * tilesiz[picnum].y; i++) + cols[*((char *) waloff[picnum] + i)]++; + + unsigned col = 0, cnt = 0; + + for (int i = 0; i < 240; i++) + if (cols[i] > cnt) + col = i, cnt = cols[i]; + + float sum = (float)curpalette[col].r * GRAYSCALE_COEFF_RED + (float)curpalette[col].g * GRAYSCALE_COEFF_GREEN + + (float)curpalette[col].b * GRAYSCALE_COEFF_BLUE; + + while (col < 240 && + ((float)curpalette[col + 1].r * GRAYSCALE_COEFF_RED + (float)curpalette[col + 1].g * GRAYSCALE_COEFF_GREEN + + (float)curpalette[col + 1].b * GRAYSCALE_COEFF_BLUE) > sum) + col++; + + tilecols[picnum] = col - 8; + + return palookup[pal][tilecols[picnum]]; +} + static void drawscreen_drawsprite(int32_t j, int32_t posxe, int32_t posye, int32_t posze, int32_t zoome) { int32_t x1, y1, x2, y2; - char col; + int col; int16_t hitblocking=(sprite[j].cstat&256), flooraligned=(sprite[j].cstat&32), wallaligned=(sprite[j].cstat&16); int16_t angofs = m32_sideview ? m32_sideang : 0; if (sprite[j].sectnum<0) - col = 4; // red + col = editorcolors[4]; // red else { - col = 3; if (spritecol2d[sprite[j].picnum][0]) col = spritecol2d[sprite[j].picnum][0]; + else + { + col = getspritecol(j); + + if (col == -1) col = editorcolors[3]; + } + +/* else if ((sprite[j].cstat&1) > 0) { col = 5; if (spritecol2d[sprite[j].picnum][1]) col = spritecol2d[sprite[j].picnum][1]; } +*/ } if (editstatus == 1) @@ -17282,20 +17329,23 @@ static void drawscreen_drawsprite(int32_t j, int32_t posxe, int32_t posye, int32 if ((halfxdim16+x1 >= 0) && (halfxdim16+x1 < xdim) && (midydim16+y1 >= 0) && (midydim16+y1 < ydim16)) { - drawcircle16(halfxdim16+x1, midydim16+y1, 4, 16384, editorcolors[col]); + if (zoome > 512 && sprite[j].clipdist > 32) + drawcircle16(halfxdim16+x1, midydim16+y1, mulscale14(sprite[j].clipdist<<2, zoome), 16384, col); + + drawcircle16(halfxdim16+x1, midydim16+y1, 4, 16384, col); x2 = mulscale11(sintable[(sprite[j].ang+angofs+2560)&2047],zoome) / 768; y2 = mulscale11(sintable[(sprite[j].ang+angofs+2048)&2047],zoome) / 768; y2 = scalescreeny(y2); - drawline16mid(x1,y1, x1+x2,y1+y2, editorcolors[col]); + drawline16mid(x1,y1, x1+x2,y1+y2, col); if (hitblocking) { - drawline16mid(x1,y1+1, x1+x2,y1+y2+1, editorcolors[col]); - drawline16mid(x1,y1-1, x1+x2,y1+y2-1, editorcolors[col]); - drawline16mid(x1-1,y1, x1+x2-1,y1+y2, editorcolors[col]); - drawline16mid(x1+1,y1, x1+x2+1,y1+y2, editorcolors[col]); + drawline16mid(x1,y1+1, x1+x2,y1+y2+1, col); + drawline16mid(x1,y1-1, x1+x2,y1+y2-1, col); + drawline16mid(x1-1,y1, x1+x2-1,y1+y2, col); + drawline16mid(x1+1,y1, x1+x2+1,y1+y2, col); } if (flooraligned) @@ -17324,15 +17374,15 @@ static void drawscreen_drawsprite(int32_t j, int32_t posxe, int32_t posye, int32 for (ii=3; ii>=0; ii--) { in = (ii+1)&3; - drawline16mid(x1+co[ii][0], y1-co[ii][1], x1+co[in][0], y1-co[in][1], editorcolors[col]); + drawline16mid(x1+co[ii][0], y1-co[ii][1], x1+co[in][0], y1-co[in][1], col); if (hitblocking) { - drawline16mid(x1+co[ii][0], y1-co[ii][1]+1, x1+co[in][0], y1-co[in][1]+1, editorcolors[col]); - drawline16mid(x1+co[ii][0], y1-co[ii][1]-1, x1+co[in][0], y1-co[in][1]-1, editorcolors[col]); - drawline16mid(x1+co[ii][0]+1, y1-co[ii][1], x1+co[in][0]+1, y1-co[in][1], editorcolors[col]); - drawline16mid(x1+co[ii][0]-1, y1-co[ii][1], x1+co[in][0]-1, y1-co[in][1], editorcolors[col]); + drawline16mid(x1+co[ii][0], y1-co[ii][1]+1, x1+co[in][0], y1-co[in][1]+1, col); + drawline16mid(x1+co[ii][0], y1-co[ii][1]-1, x1+co[in][0], y1-co[in][1]-1, col); + drawline16mid(x1+co[ii][0]+1, y1-co[ii][1], x1+co[in][0]+1, y1-co[in][1], col); + drawline16mid(x1+co[ii][0]-1, y1-co[ii][1], x1+co[in][0]-1, y1-co[in][1], col); } - drawline16mid(x1, y1, x1 + co[in][0], y1 - co[in][1], editorcolors[col]); + drawline16mid(x1, y1, x1 + co[in][0], y1 - co[in][1], col); } drawlinepat = 0xffffffff; } @@ -17345,21 +17395,21 @@ static void drawscreen_drawsprite(int32_t j, int32_t posxe, int32_t posye, int32 y2 = mulscale11(sintable[(sprite[j].ang+angofs+2048)&2047],zoome) / 6144; y2 = scalescreeny(y2); - drawline16mid(x1,y1, x1+x2,y1+y2, editorcolors[col]); + drawline16mid(x1,y1, x1+x2,y1+y2, col); if (!(sprite[j].cstat&64)) // not 1-sided { - drawline16mid(x1,y1, x1-x2,y1-y2, editorcolors[col]); + drawline16mid(x1,y1, x1-x2,y1-y2, col); if (hitblocking) { - drawline16mid(x1-no,y1-one, x1-x2-no,y1-y2-one, editorcolors[col]); - drawline16mid(x1+no,y1+one, x1-x2+no,y1-y2+one, editorcolors[col]); + drawline16mid(x1-no,y1-one, x1-x2-no,y1-y2-one, col); + drawline16mid(x1+no,y1+one, x1-x2+no,y1-y2+one, col); } } if (hitblocking) { - drawline16mid(x1-no,y1-one, x1+x2-no,y1+y2-one, editorcolors[col]); - drawline16mid(x1+no,y1+one, x1+x2+no,y1+y2+one, editorcolors[col]); + drawline16mid(x1-no,y1-one, x1+x2-no,y1+y2-one, col); + drawline16mid(x1+no,y1+one, x1+x2+no,y1+y2+one, col); } @@ -17367,20 +17417,20 @@ static void drawscreen_drawsprite(int32_t j, int32_t posxe, int32_t posye, int32 y2 = mulscale13(sintable[(sprite[j].ang+angofs+512)&2047],zoome) * fx / 4096; y2 = scalescreeny(y2); - drawline16mid(x1,y1, x1-x2,y1-y2, editorcolors[col]); - drawline16mid(x1,y1, x1+x2,y1+y2, editorcolors[col]); + drawline16mid(x1,y1, x1-x2,y1-y2, col); + drawline16mid(x1,y1, x1+x2,y1+y2, col); if (hitblocking) { - drawline16mid(x1+1,y1, x1+x2+1,y1+y2, editorcolors[col]); - drawline16mid(x1-1,y1, x1-x2-1,y1-y2, editorcolors[col]); - drawline16mid(x1-1,y1, x1+x2-1,y1+y2, editorcolors[col]); - drawline16mid(x1+1,y1, x1-x2+1,y1-y2, editorcolors[col]); + drawline16mid(x1+1,y1, x1+x2+1,y1+y2, col); + drawline16mid(x1-1,y1, x1-x2-1,y1-y2, col); + drawline16mid(x1-1,y1, x1+x2-1,y1+y2, col); + drawline16mid(x1+1,y1, x1-x2+1,y1-y2, col); - drawline16mid(x1,y1-1, x1+x2,y1+y2-1, editorcolors[col]); - drawline16mid(x1,y1+1, x1-x2,y1-y2+1, editorcolors[col]); - drawline16mid(x1,y1+1, x1+x2,y1+y2+1, editorcolors[col]); - drawline16mid(x1,y1-1, x1-x2,y1-y2-1, editorcolors[col]); + drawline16mid(x1,y1-1, x1+x2,y1+y2-1, col); + drawline16mid(x1,y1+1, x1-x2,y1-y2+1, col); + drawline16mid(x1,y1+1, x1+x2,y1+y2+1, col); + drawline16mid(x1,y1-1, x1-x2,y1-y2-1, col); } } } diff --git a/polymer/eduke32/source/astub.c b/polymer/eduke32/source/astub.c index 0e25dda4e..474f05d34 100644 --- a/polymer/eduke32/source/astub.c +++ b/polymer/eduke32/source/astub.c @@ -4474,7 +4474,7 @@ static void Keys3d(void) message("Visibility changed on all selected sectors"); } - if (PRESSED_KEYSC(L)) // L (grid lock) + if (!keystatus[KEYSC_QUOTE] && PRESSED_KEYSC(L)) // L (grid lock) { gridlock = !gridlock; message("Grid locking %s", gridlock ? "on" : "off");