diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index f01ee223b..09c16a7a6 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -664,7 +664,6 @@ set (PCH_SOURCES build/src/compat.cpp build/src/defs.cpp build/src/engine.cpp - build/src/glsurface.cpp build/src/hash.cpp build/src/hightile.cpp build/src/mdsprite.cpp diff --git a/source/build/include/build.h b/source/build/include/build.h index 4b3e7f6dd..82b5c7e82 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -560,7 +560,6 @@ EXTERN int32_t g_visibility, parallaxvisibility; EXTERN uint8_t numalphatabs; EXTERN vec2_t windowxy1, windowxy2; -EXTERN TArray startumost, startdmost; // The maximum tile offset ever used in any tiled parallaxed multi-sky. #define PSKYOFF_MAX 16 @@ -616,7 +615,6 @@ EXTERN int16_t headspritesect[MAXSECTORS+1], headspritestat[MAXSTATUS+1]; EXTERN int16_t prevspritesect[MAXSPRITES], prevspritestat[MAXSPRITES]; EXTERN int16_t nextspritesect[MAXSPRITES], nextspritestat[MAXSPRITES]; -extern const char pow2char_[]; static CONSTEXPR const int32_t pow2long[32] = { 1, 2, 4, 8, diff --git a/source/build/include/glsurface.h b/source/build/include/glsurface.h deleted file mode 100644 index dea8bf564..000000000 --- a/source/build/include/glsurface.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * glsurface.h - * A 32-bit rendering surface that can quickly blit 8-bit paletted buffers implemented in OpenGL. - * - * Copyright © 2018, Alex Dawson. All rights reserved. - */ - -#ifndef GLSURFACE_H_ -#define GLSURFACE_H_ - -#include "compat.h" - -// Initialize the glsurface with the Software renderer's buffer resolution. -// If the Software renderer's resolution and the actual resolution don't match, -// glsurface will still render at the full size of the screen. -// If a surface already exists, glsurface_destroy() will be automatically called before re-initializing. -// Returns whether or not the glsurface could be successfully initialized. -bool glsurface_initialize(vec2_t bufferResolution); - -// Destroy an existing surface. -void glsurface_destroy(); - -// Sets the palette to contain the RGBA byte buffer pointed to by pPalette. -// If the surface is not initialized, the function returns immediately. -void glsurface_setPalette(void* pPalette); - -// Returns a pointer to the start of the surface's pixel buffer -// Returns NULL if the surface is not initialized. -void* glsurface_getBuffer(); - -// Returns the resolution of the surface's buffer -vec2_t glsurface_getBufferResolution(); - -// Blit the surface's pixel buffer to the screen using the palette set with glsurface_setPalette(). -// Renders as soon as the data has been uploaded. -// If the surface is not initialized, the function returns immediately. -void glsurface_blitBuffer(); - -#endif /* GLSURFACE_H_ */ diff --git a/source/build/include/palette.h b/source/build/include/palette.h index 1ed4ab448..c858f05e7 100644 --- a/source/build/include/palette.h +++ b/source/build/include/palette.h @@ -49,7 +49,7 @@ struct palette_t typedef struct { uint8_t r, g, b; } rgb24_t; -extern palette_t curpalette[256], curpalettefaded[256], palfadergb; +extern palette_t curpalette[256], palfadergb; extern unsigned char palfadedelta; void paletteMakeLookupTable(int32_t palnum, const char *remapbuf, uint8_t r, uint8_t g, uint8_t b, char noFloorPal); diff --git a/source/build/include/pragmas.h b/source/build/include/pragmas.h index 1c143c99e..0efe3ee27 100644 --- a/source/build/include/pragmas.h +++ b/source/build/include/pragmas.h @@ -20,7 +20,7 @@ EDUKE32_SCALER_PRAGMA(25) EDUKE32_SCALER_PRAGMA(26) EDUKE32_SCALER_PRAGMA(27) EDUKE32_SCALER_PRAGMA(28) \ EDUKE32_SCALER_PRAGMA(29) EDUKE32_SCALER_PRAGMA(30) EDUKE32_SCALER_PRAGMA(31) -extern int32_t reciptable[2048], fpuasm; +extern int32_t reciptable[2048]; // break the C version of divscale out from the others // because asm version overflows in drawmapview() @@ -154,20 +154,9 @@ static FORCE_INLINE void swapchar2(void *a, void *b, int32_t s) } #endif -static FORCE_INLINE CONSTEXPR char readpixel(void *s) { return *(char *)s; } - - #ifndef pragmas_have_klabs -#if 0 -static FORCE_INLINE int32_t klabs(int32_t const a) -{ - uint32_t const m = a >> (sizeof(uint32_t) * CHAR_BIT - 1); - return (a ^ m) - m; -} -#else #define klabs(x) abs(x) #endif -#endif #ifndef pragmas_have_ksgn static FORCE_INLINE CONSTEXPR int ksgn(int32_t a) { return (a > 0) - (a < 0); } #endif @@ -185,25 +174,12 @@ void qinterpolatedown16(intptr_t bufptr, int32_t num, int32_t val, int32_t add); void qinterpolatedown16short(intptr_t bufptr, int32_t num, int32_t val, int32_t add); #endif -#ifndef pragmas_have_clearbuf -void clearbuf(void *d, int32_t c, int32_t a); -#endif -#ifndef pragmas_have_copybuf -void copybuf(const void *s, void *d, int32_t c); -#endif -#ifndef pragmas_have_swaps -void swapbuf4(void *a, void *b, int32_t c); -#endif - #ifndef pragmas_have_clearbufbyte void clearbufbyte(void *D, int32_t c, int32_t a); #endif #ifndef pragmas_have_copybufbyte void copybufbyte(const void *S, void *D, int32_t c); #endif -#ifndef pragmas_have_copybufreverse -void copybufreverse(const void *S, void *D, int32_t c); -#endif #ifndef pragmas_have_krecipasm static inline int32_t krecipasm(int32_t i) @@ -221,23 +197,4 @@ static inline int32_t krecipasm(int32_t i) #undef wo #undef by -static inline void swapbufreverse(void *s, void *d, int32_t c) -{ - uint8_t *src = (uint8_t *)s, *dst = (uint8_t *)d; - Bassert(c >= 4); - - do - { - swapchar(dst, src); - swapchar(dst + 1, src - 1); - swapchar(dst + 2, src - 2); - swapchar(dst + 3, src - 3); - dst += 4, src -= 4; - } while ((c -= 4) > 4); - - while (c--) - swapchar(dst++, src--); -} - - #endif // pragmas_h_ diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index 59ce87913..e7a628796 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -30,7 +30,6 @@ #include "version.h" #ifdef USE_OPENGL -# include "glsurface.h" # include "hightile.h" # include "mdsprite.h" # include "polymost.h" @@ -103,27 +102,9 @@ int32_t novoxmips = 1; #define MAXXSIZ 256 #define MAXYSIZ 256 #define MAXZSIZ 255 -#ifdef EDUKE32_TOUCH_DEVICES -# define DISTRECIPSIZ (65536+256) -#else -# define DISTRECIPSIZ 131072 -#endif int32_t voxscale[MAXVOXELS]; -static int32_t ggxinc[MAXXSIZ+1], ggyinc[MAXXSIZ+1]; -static int32_t lowrecip[1024], nytooclose; -static const int32_t nytoofar = DISTRECIPSIZ*16384ull - 1048576; -static uint32_t *distrecip; -#define DISTRECIPCACHESIZE 3 -static struct { - uint32_t *distrecip; - int32_t xdimen; - int32_t age; -} distrecipcache[DISTRECIPCACHESIZE]; -static int32_t distrecipagecnt = 0; - -static TArray lookups; static int32_t beforedrawrooms = 1; static int32_t oxdimen = -1, oviewingrange = -1, oxyaspect = -1; @@ -135,30 +116,16 @@ int32_t newaspect_enable=0; int32_t r_fpgrouscan = 1; int32_t globalflags; -//Textured Map variables -static char globalpolytype; -static TArraydotp1, dotp2; - static int8_t tempbuf[MAXWALLS]; // referenced from asm -int32_t ebpbak, espbak; -int32_t reciptable[2048], fpuasm; -intptr_t asm1, asm2, asm3, asm4, palookupoffse[4]; -uint32_t vplce[4]; -int32_t vince[4]; -intptr_t bufplce[4]; -int32_t globaltilesizy; +int32_t reciptable[2048]; +intptr_t asm1, asm2, asm3; int32_t globalx1, globaly2, globalx3, globaly3; -#define SLOPALOOKUPSIZ 16384 -static intptr_t slopalookup[SLOPALOOKUPSIZ]; // was 2048 - static int32_t no_radarang2 = 0; static int16_t radarang[1280]; static int32_t qradarang[10240]; -static TArray radarang2; -const char ATTRIBUTE((used)) pow2char_[8] = {1,2,4,8,16,32,64,128}; uint16_t ATTRIBUTE((used)) sqrtable[4096], ATTRIBUTE((used)) shlookup[4096+256], ATTRIBUTE((used)) sqrtable_old[2048]; @@ -205,15 +172,6 @@ static void getclosestpointonwall_internal(vec2_t const p, int32_t const dawall, *closest = { (int32_t)(w.x + ((d.x * i) >> 30)), (int32_t)(w.y + ((d.y * i) >> 30)) }; } -////////// YAX ////////// - -#ifdef YAX_DEBUG -// XXX: This could be replaced with the use of gethiticks(). -double u64tickspersec; -#endif -#ifdef ENGINE_SCREENSHOT_DEBUG -int32_t engine_screenshot = 0; -#endif void faketimerhandler() { @@ -271,16 +229,6 @@ int16_t yax_getbunch(int16_t i, int16_t cf) return (*(§or[i].ceilingstat + cf) & YAX_BIT) ? YAX_BUNCHNUM(i, cf) : -1; } -# else -# define YAX_PTRBUNCHNUM(Ptr, Sect, Cf) (*((Cf) ? &(Ptr)[Sect].floorbunch : &(Ptr)[Sect].ceilingbunch)) -# define YAX_BUNCHNUM(Sect, Cf) YAX_PTRBUNCHNUM(sector, Sect, Cf) - -# if !defined NEW_MAP_FORMAT -static FORCE_INLINE int32_t yax_islockededge(int32_t line, int32_t cf) -{ - return (yax_getnextwall(line, cf) >= 0); -} -# endif # endif // bunchnum: -1: also clear yax-nextwalls (forward and reverse) @@ -290,11 +238,7 @@ void yax_setbunch(int16_t i, int16_t cf, int16_t bunchnum) { if (editstatus==0) { -#ifdef NEW_MAP_FORMAT - YAX_BUNCHNUM(i, cf) = bunchnum; -#else yax_bunchnum[i][cf] = bunchnum; -#endif return; } @@ -721,8 +665,8 @@ void yax_preparedrawrooms(void) return; g_nodraw = 1; - Bmemset(yax_spritesortcnt, 0, sizeof(yax_spritesortcnt)); - Bmemset(haveymost, 0, (numyaxbunches+7)>>3); + memset(yax_spritesortcnt, 0, sizeof(yax_spritesortcnt)); + memset(haveymost, 0, (numyaxbunches+7)>>3); } @@ -1142,8 +1086,6 @@ int16_t bunchp2[MAXWALLSB], thesector[MAXWALLSB]; int16_t bunchfirst[MAXWALLSB], bunchlast[MAXWALLSB]; -TArray mirrorBuffer; - static vec3_t spritesxyz[MAXSPRITESONSCREEN+1]; int32_t xdimen = -1, xdimenrecip, halfxdimen, xdimenscale, xdimscale; @@ -1154,8 +1096,7 @@ static int32_t nrx1[8], nry1[8], nrx2[8], nry2[8]; // JBF 20031206: Thanks Ken int32_t rxi[8], ryi[8]; static int32_t rzi[8], rxi2[8], ryi2[8], rzi2[8]; -static int32_t xsi[8], ysi[8], horizycent; -static int32_t *horizlookup=0, *horizlookup2=0; +static int32_t xsi[8], ysi[8]; int32_t globalposx, globalposy, globalposz, globalhoriz; fix16_t qglobalhoriz; @@ -1194,7 +1135,6 @@ static int32_t globaly1, globalx2; int16_t sectorborder[256]; int32_t ydim16, qsetmode = 0; int16_t pointhighlight=-1, linehighlight=-1, highlightcnt=0; -static TArray lastx; int32_t halfxdim16, midydim16; @@ -1664,20 +1604,6 @@ static void dosetaspect(void) { oxyaspect = xyaspect; j = xyaspect*320; - horizycent = (ydim*4)>>1; - horizlookup2[horizycent-1] = divscale32(131072,j); - - for (i=0; i < horizycent-1; i++) - { - horizlookup[i] = divscale28(1, i-(horizycent-1)); - horizlookup2[i] = divscale20(klabs(horizlookup[i]), j); - } - - for (i=horizycent; i < ydim*4-1; i++) - { - horizlookup[i] = divscale28(1, i-(horizycent-1)); - horizlookup2[i] = divscale20(klabs(horizlookup[i]), j); - } } if (xdimen != oxdimen || viewingrange != oviewingrange) @@ -1697,55 +1623,11 @@ static void dosetaspect(void) if (k < 0 || k >= (int32_t)ARRAY_SIZE(qradarang)-1) { no_radarang2 = 1; -#ifdef DEBUGGINGAIDS - if (editstatus) - initprintf("no rad2\n"); -#endif break; } if (j != 0) j = mulscale16(qradarang[k+1]-qradarang[k], j); - radarang2[i] = ((qradarang[k]+j)>>6); - } - - if (xdimen != oxdimen && (voxoff[0][0] || playing_blood)) - { - distrecip = NULL; - for (i = 0; i < DISTRECIPCACHESIZE; i++) - { - if (distrecipcache[i].xdimen == xdimen) - distrecip = distrecipcache[i].distrecip; - } - if (distrecip == NULL) - { - int32_t minAge = 0; - for (i = 1; i < DISTRECIPCACHESIZE; i++) - { - if (distrecipcache[i].age < distrecipcache[minAge].age) - minAge = i; - } - if (distrecipcache[minAge].distrecip == NULL) - distrecipcache[minAge].distrecip = (uint32_t *)Xaligned_alloc(16, DISTRECIPSIZ * sizeof(uint32_t)); - - distrecipcache[minAge].age = ++distrecipagecnt; - distrecipcache[minAge].xdimen = xdimen; - - distrecip = distrecipcache[minAge].distrecip; - - if (xdimen < 1 << 11) - { - for (i = 1; i < DISTRECIPSIZ; i++) - distrecip[i] = tabledivide32(xdimen << 20, i); - } - else - { - for (i = 1; i < DISTRECIPSIZ; i++) - distrecip[i] = tabledivide64((uint64_t)xdimen << 20, i); - } - } - - nytooclose = xdimen*2100; } oxdimen = xdimen; @@ -2083,13 +1965,6 @@ int32_t lintersect(const int32_t originX, const int32_t originY, const int32_t o int64_t t = tabledivide64(((int64_t) originDiffCrossLineVec) << 24L, rayCrossLineVec); // For sake of completeness/readability, alternative to the above approach for an early out & avoidance of an extra division: -#if 0 - int64_t u = tabledivide64(((int64_t) originDiffCrossRay) << 24L, rayCrossLineVec); - if (u < 0 || u > 1 << 24 || t < 0 || t > 1 << 24) - { - return 0; - } -#endif *intersectionX = originX + mulscale24(ray.x, t); *intersectionY = originY + mulscale24(ray.y, t); @@ -2257,12 +2132,6 @@ int32_t engineInit(void) if (i) return i; } -#ifdef YAX_DEBUG - u64tickspersec = (double)timerGetFreqU64(); - if (u64tickspersec==0.0) - u64tickspersec = 1.0; -#endif - if (engineLoadTables()) return 1; @@ -2273,15 +2142,12 @@ int32_t engineInit(void) showinvisibility = 0; - for (i=1; i<1024; i++) - lowrecip[i] = ((1<<24)-1)/i; - voxelmemory.Reset(); for (i=0; i>2, 65536); - clearbufbyte(voxrotate, sizeof(voxrotate), 0); + for (auto& v : voxscale) v = 65536; + memset(voxrotate, 0, sizeof(voxrotate)); paletteloaded = 0; @@ -2335,10 +2201,6 @@ void engineUnInit(void) TileFiles.CloseAll(); - for (bssize_t i=0; i(sec->floorshade, numshades - 1), 0); globvis = globalhisibility; if (sec->visibility != 0) globvis = mulscale4(globvis, (uint8_t)(sec->visibility+16)); - globalpolytype = 0; if ((globalorientation&64) == 0) { set_globalpos(dax, day, globalposz); @@ -3320,7 +3178,6 @@ void renderDrawMapView(int32_t dax, int32_t day, int32_t zoome, int16_t ang) asm3 = FP_OFF(palookup[spr->pal]+(globalshade<<8)); globvis = globalhisibility; if (sec->visibility != 0) globvis = mulscale4(globvis, (uint8_t)(sec->visibility+16)); - globalpolytype = ((spr->cstat&2)>>1)+1; //relative alignment stuff ox = v2.x-v1.x; oy = v2.y-v1.y; @@ -3910,26 +3767,6 @@ int32_t engineLoadBoardV5V6(const char *filename, char fromwhere, vec3_t *dapos, #define YSAVES ((xdim*MAXSPRITES)>>7) -static void videoAllocateBuffers(void) -{ - // Needed for the game's TILT_SETVIEWTOTILE_320. - const int32_t clamped_ydim = max(ydim, 320); - - startumost.Resize(xdim); - startdmost.Resize(xdim); - radarang2.Resize(xdim); - dotp1.Resize(clamped_ydim); - dotp2.Resize(clamped_ydim); - lastx.Resize(clamped_ydim); - mirrorBuffer.Resize(xdim * ydim); - - if (videoGetRenderMode() == REND_CLASSIC) - { - glsurface_initialize({ xdim, ydim }); - } -} - - // // setgamemode // @@ -3967,14 +3804,7 @@ int32_t videoSetGameMode(char davidoption, int32_t daupscaledxdim, int32_t daups fydim = (float) ydim; #endif - videoAllocateBuffers(); - j = ydim*4; //Leave room for horizlookup&horizlookup2 - lookups.Resize(2 * j); - - horizlookup = lookups.Data(); - horizlookup2 = lookups.Data() + j; - horizycent = ((ydim*4)>>1); //Force drawrooms to call dosetaspect & recalculate stuff oxyaspect = oxdimen = oviewingrange = -1; @@ -4015,8 +3845,6 @@ void videoNextPage(void) videoShowFrame(0); } - faketimerhandler(); - #ifdef USE_OPENGL omdtims = mdtims; mdtims = timerGetTicks(); @@ -5211,12 +5039,6 @@ void videoSetViewableArea(int32_t x1, int32_t y1, int32_t x2, int32_t y2) fydimen = (float) ydimen; #endif videoSetCorrectedAspect(); - - for (bssize_t i=0; i mirrorBuffer; extern int32_t xdimen, xdimenrecip, halfxdimen, xdimenscale, xdimscale, ydimen; extern float fxdimen; extern int32_t globalposx, globalposy, globalposz, globalhoriz; diff --git a/source/build/src/glsurface.cpp b/source/build/src/glsurface.cpp deleted file mode 100644 index d0fe897a1..000000000 --- a/source/build/src/glsurface.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/* - * glsurface.cpp - * A 32-bit rendering surface that can quickly blit 8-bit paletted buffers implemented in OpenGL. - * - * Copyright © 2018, Alex Dawson. All rights reserved. - */ - -#include "glsurface.h" - -#include "baselayer.h" -#include "build.h" -#include "tarray.h" -#include "flatvertices.h" -#include "../../glbackend/glbackend.h" - -static TArray buffer; -static FHardwareTexture* bufferTexture; -static vec2_t bufferRes; - -static FHardwareTexture* paletteTexture; - -bool glsurface_initialize(vec2_t bufferResolution) -{ - if (buffer.Size()) - glsurface_destroy(); - - bufferRes = bufferResolution; - buffer.Resize(bufferRes.x * bufferRes.y); - - bufferTexture = GLInterface.NewTexture(); - bufferTexture->CreateTexture(bufferRes.x, bufferRes.y, FHardwareTexture::Indexed, false); - - glsurface_setPalette(curpalettefaded); - GLInterface.SetSurfaceShader(); - return true; -} - -void glsurface_destroy() -{ - if (bufferTexture) delete bufferTexture; - bufferTexture = nullptr; - if (paletteTexture) delete paletteTexture; - paletteTexture = nullptr; -} - -void glsurface_setPalette(void* pPalette) -{ - if (!buffer.Size()) - return; - if (!pPalette) - return; - - if (!paletteTexture) - { - paletteTexture = GLInterface.NewTexture(); - paletteTexture->CreateTexture(256, 1, FHardwareTexture::TrueColor, false); - } - paletteTexture->LoadTexture(palette); - GLInterface.BindTexture(1, paletteTexture, SamplerNoFilterClampXY); -} - -void* glsurface_getBuffer() -{ - return buffer.Data(); -} - -vec2_t glsurface_getBufferResolution() -{ - return bufferRes; -} - -void glsurface_blitBuffer() -{ - if (!buffer.Size()) - return; - - bufferTexture->LoadTexture(buffer.Data()); - GLInterface.BindTexture(0, bufferTexture, SamplerNoFilterClampXY); - GLInterface.Draw(DT_TRIANGLE_STRIP, FFlatVertexBuffer::PRESENT_INDEX, 4); -} diff --git a/source/build/src/palette.cpp b/source/build/src/palette.cpp index a0961fb0e..7d6630e56 100644 --- a/source/build/src/palette.cpp +++ b/source/build/src/palette.cpp @@ -24,7 +24,6 @@ int32_t globalblend; uint32_t g_lastpalettesum = 0; palette_t curpalette[256]; // the current palette, unadjusted for brightness or tint -palette_t curpalettefaded[256]; // the current palette, adjusted for brightness and tint (ie. what gets sent to the card) palette_t palfadergb = { 0, 0, 0, 0 }; unsigned char palfadedelta = 0; ESetPalFlags curpaletteflags; @@ -43,7 +42,6 @@ int8_t g_noFloorPal[MAXPALOOKUPS]; int32_t curbrightness = 0; -static void paletteSetFade(uint8_t offset); void setBlendFactor(int index, int alpha); @@ -723,18 +721,8 @@ void videoSetPalette(int dabrightness, int dapalid, ESetPalFlags flags) curpalette[i].g = dapal[i * 3 + 1]; curpalette[i].b = dapal[i * 3 + 2]; curpalette[i].f = 0; - - // brightness adjust the palette - curpalettefaded[i].b = britable[j][curpalette[i].b]; - curpalettefaded[i].g = britable[j][curpalette[i].g]; - curpalettefaded[i].r = britable[j][curpalette[i].r]; - curpalettefaded[i].f = 0; } - if ((flags & Pal_DontResetFade) && palfadedelta) // keep the fade - paletteSetFade(palfadedelta >> 2); - - if ((flags & Pal_DontResetFade) == 0) { palfadergb.r = palfadergb.g = palfadergb.b = 0; @@ -749,19 +737,6 @@ palette_t paletteGetColor(int32_t col) return curpalette[col]; } -static void paletteSetFade(uint8_t offset) -{ - for (native_t i=0; i<256; i++) - { - palette_t const p = paletteGetColor(i); - - curpalettefaded[i].b = p.b + (((palfadergb.b - p.b) * offset) >> 8); - curpalettefaded[i].g = p.g + (((palfadergb.g - p.g) * offset) >> 8); - curpalettefaded[i].r = p.r + (((palfadergb.r - p.r) * offset) >> 8); - curpalettefaded[i].f = 0; - } -} - // // setpalettefade // @@ -770,11 +745,5 @@ void videoFadePalette(uint8_t r, uint8_t g, uint8_t b, uint8_t offset) palfadergb.r = r; palfadergb.g = g; palfadergb.b = b; -#ifdef DEBUG_PALETTEFADE - if (offset) - offset = max(offset, 128); -#endif palfadedelta = offset; - - paletteSetFade(offset); } diff --git a/source/build/src/pragmas.cpp b/source/build/src/pragmas.cpp index 219849540..344f8cde4 100644 --- a/source/build/src/pragmas.cpp +++ b/source/build/src/pragmas.cpp @@ -53,50 +53,6 @@ void qinterpolatedown16short(intptr_t bufptr, int32_t num, int32_t val, int32_t } #endif -#ifndef pragmas_have_clearbuf -void clearbuf(void *d, int32_t c, int32_t a) -{ - auto p = (int32_t *)d; - -#if 0 - if (a == 0) - { - clearbufbyte(d, c<<2, 0); - return; - } -#endif - - while (c--) - *p++ = a; -} -#endif - -#ifndef pragmas_have_copybuf -void copybuf(const void *s, void *d, int32_t c) -{ - auto p = (const int32_t *) s; - auto q = (int32_t *) d; - - while (c--) - *q++ = *p++; -} -#endif - -#ifndef pragmas_have_swaps -void swapbuf4(void *a, void *b, int32_t c) -{ - auto p = (int32_t *) a; - auto q = (int32_t *) b; - - while ((c--) > 0) - { - int x = *q, y = *p; - *(q++) = y; - *(p++) = x; - } -} -#endif - #ifndef pragmas_have_clearbufbyte void clearbufbyte(void *D, int32_t c, int32_t a) { @@ -125,17 +81,3 @@ void copybufbyte(const void *s, void *d, int32_t c) #endif -// copybufreverse() is a special case: use the assembly version for GCC on x86 -// *and* x86_64, and the C version otherwise. -// XXX: we don't honor NOASM in the x86_64 case. - -#if !defined pragmas_have_copybufreverse -void copybufreverse(const void *s, void *d, int32_t c) -{ - auto src = (const char *)s; - auto dst = (char *)d; - - while (c--) - *dst++ = *src--; -} -#endif diff --git a/source/exhumed/src/light.cpp b/source/exhumed/src/light.cpp index a491ab6cc..43a94d385 100644 --- a/source/exhumed/src/light.cpp +++ b/source/exhumed/src/light.cpp @@ -240,89 +240,16 @@ void WaitTicks(int nTicks) // unused void DoFadeToRed() { -#ifdef USE_OPENGL - if (videoGetRenderMode() >= REND_POLYMOST) - { - videoTintBlood(-255, -255, -255); - videoNextPage(); - return; - } -#endif - for (int i = 0; i < 256; i++) - { - if (curpalettefaded[i].g > 0) - { - curpalettefaded[i].g -= 4; - if (curpalettefaded[i].g < 0) - curpalettefaded[i].g = 0; - } - - if (curpalettefaded[i].b > 0) - { - curpalettefaded[i].b -= 4; - if (curpalettefaded[i].b < 0) - curpalettefaded[i].b = 0; - } - } - - //videoUpdatePalette(0, 256); - g_lastpalettesum = -1; + // fixme + videoTintBlood(-255, -255, -255); + videoNextPage(); } void FadeToWhite() { - int ebx = 0; - -#ifdef USE_OPENGL - if (videoGetRenderMode() >= REND_POLYMOST) - { - videoTintBlood(255, 255, 255); - videoNextPage(); - return; - } -#endif - - for (int i = 0; i < 64; i++) - { - palette_t *pPal = curpalettefaded; - - for (int j = 0; j < 256; j++) - { - if (pPal->r < 255) - { - pPal->r += 4; - if (pPal->r > 255) - pPal->r = 255; - ebx++; - } - if (pPal->g < 255) - { - pPal->g += 4; - if (pPal->g > 255) - pPal->g = 255; - ebx++; - } - if (pPal->b < 255) - { - pPal->b += 4; - if (pPal->b > 255) - pPal->b = 255; - ebx++; - } - pPal++; - } - - //videoUpdatePalette(0, 256); - g_lastpalettesum = -1; - WaitTicks(2); - - // need to page flip in each iteration of the loop for non DOS version - videoNextPage(); - - if (!ebx) { - return; - } - } + // fixme + videoTintBlood(255, 255, 255); + videoNextPage(); } void FadeOut(int bFadeMusic) @@ -332,60 +259,8 @@ void FadeOut(int bFadeMusic) } -#ifdef USE_OPENGL - if (videoGetRenderMode() >= REND_POLYMOST) - { - videoTintBlood(-255, -255, -255); - videoNextPage(); - } - else -#endif - for (int i = 64; i > 0; i--) - { - int v4 = 0; - palette_t *pPal = curpalettefaded; - - for (int j = 0; j < 256; j++) - { - if (pPal->r > 0) - { - pPal->r -= 4; - if (pPal->r < 0) - pPal->r = 0; - v4++; - } - if (pPal->g > 0) - { - pPal->g -= 4; - if (pPal->g < 0) - pPal->g = 0; - v4++; - } - if (pPal->b > 0) - { - pPal->b -= 4; - if (pPal->b < 0) - pPal->b = 0; - v4++; - } - pPal++; - } - - //videoUpdatePalette(0, 256); - g_lastpalettesum = -1; - WaitTicks(2); - - // need to page flip in each iteration of the loop for non DOS version - videoNextPage(); - - if (v4 == 0) { - break; - } - - if (bFadeMusic) { - StepFadeCDaudio(); - } - } + videoTintBlood(-255, -255, -255); + videoNextPage(); if (bFadeMusic) { while (StepFadeCDaudio() != 0) {} @@ -402,76 +277,17 @@ void StartFadeIn() int DoFadeIn() { -#ifdef USE_OPENGL - if (videoGetRenderMode() >= REND_POLYMOST) - { - paletteSetColorTable(curbasepal, basepaltable[BASEPAL]); - videoSetPalette(0, curbasepal, 0); - videoNextPage(); - return 0; - } -#endif - int v2 = 0; - - for (int i = 0; i < 256; i++) - { - if (curpalettefaded[i].r != curpalette[i].r) - { - v2++; - int diff = curpalette[i].r - curpalettefaded[i].r; - if (klabs(diff) < 4) - curpalettefaded[i].r = curpalette[i].r; - else - curpalettefaded[i].r += 4 * ksgn(diff); - } - if (curpalettefaded[i].g != curpalette[i].g) - { - v2++; - int diff = curpalette[i].g - curpalettefaded[i].g; - if (klabs(diff) < 4) - curpalettefaded[i].g = curpalette[i].g; - else - curpalettefaded[i].g += 4 * ksgn(diff); - } - if (curpalettefaded[i].b != curpalette[i].b) - { - v2++; - int diff = curpalette[i].b - curpalettefaded[i].b; - if (klabs(diff) < 4) - curpalettefaded[i].b = curpalette[i].b; - else - curpalettefaded[i].b += 4 * ksgn(diff); - } - } - - //videoUpdatePalette(0, 256); - g_lastpalettesum = -1; - - return v2; + paletteSetColorTable(curbasepal, basepaltable[BASEPAL]); + videoSetPalette(0, curbasepal, 0); + videoNextPage(); + return 0; } void FadeIn() { -#ifdef USE_OPENGL - if (videoGetRenderMode() >= REND_POLYMOST) - { - videoSetPalette(0, BASEPAL, 0); - videoNextPage(); - return; - } -#endif - StartFadeIn(); + videoSetPalette(0, BASEPAL, 0); + videoNextPage(); - int val; - - do - { - val = DoFadeIn(); - WaitTicks(2); - - // need to page flip in each iteration of the loop for non DOS version - videoNextPage(); - } while (val); } void FixPalette() @@ -522,8 +338,6 @@ void FixPalette() void TintPalette(int r, int g, int b) { - palette_t *pPal = curpalettefaded; - if (bCamera) { return; } @@ -596,48 +410,13 @@ void TintPalette(int r, int g, int b) nPalDiff += nVal; -#ifdef USE_OPENGL - if (videoGetRenderMode() >= REND_POLYMOST) videoTintBlood(rtint, gtint, btint); - else -#endif - for (int i = 0; i < 256; i++) - { - nVal = pPal->r + r; - if (nVal > 255) { - nVal = 255; - } - pPal->r = nVal; - - nVal = pPal->g + g; - if (nVal > 255) { - nVal = 255; - } - pPal->g = nVal; - - nVal = pPal->b + b; - if (nVal > 255) { - nVal = 255; - } - pPal->b = nVal; - - pPal++; - } + videoTintBlood(rtint, gtint, btint); nPalDelay = 0; } void DoOverscanSet(short someval) { -#ifdef __WATCOMC__ - union REGS regs; - - regs.h.al = 1; - regs.h.ah = 0x10; - regs.h.ch = someval; - - int386(0x10, ®s, ®s); - -#endif } // unused @@ -648,30 +427,5 @@ void SetWhiteOverscan() void SetOverscan(int id) { - if (basepaltable[id] == NULL) - return; - uint8_t *palette = basepaltable[id]; - int edi = 1000; - overscanindex = 0; - - for (int i = 0; i < 256; i++) - { - int ebx = 0; - - for (int j = 0; j < 3; j++) - { - uint8_t cl = *palette; - palette++; - ebx += cl; - } - - if (ebx < edi) - { - edi = ebx; - overscanindex = i; - } - } - - DoOverscanSet(overscanindex); } END_PS_NS diff --git a/source/exhumed/src/view.cpp b/source/exhumed/src/view.cpp index 6b279d68c..30cc6c0cc 100644 --- a/source/exhumed/src/view.cpp +++ b/source/exhumed/src/view.cpp @@ -244,7 +244,6 @@ void ResetView() //videoSetGameMode(gSetup.fullscreen, gSetup.xdim, gSetup.ydim, gSetup.bpp, 0); DoOverscanSet(overscanindex); EraseScreen(overscanindex); - memcpy(curpalettefaded, curpalette, sizeof(curpalette)); //videoUpdatePalette(0, 256); #ifdef USE_OPENGL videoTintBlood(0, 0, 0); diff --git a/source/glbackend/glbackend.cpp b/source/glbackend/glbackend.cpp index 3d24eafae..4c122c2e1 100644 --- a/source/glbackend/glbackend.cpp +++ b/source/glbackend/glbackend.cpp @@ -92,7 +92,6 @@ void GLInstance::Init(int ydim) glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &glinfo.maxanisotropy); new(&renderState) PolymostRenderState; // reset to defaults. - LoadSurfaceShader(); LoadPolymostShader(); } @@ -110,20 +109,6 @@ void GLInstance::LoadPolymostShader() SetPolymostShader(); } -void GLInstance::LoadSurfaceShader() -{ - auto fr1 = GetResource("engine/shaders/glsl/glsurface.vp"); - TArray Vert = fr1.Read(); - fr1 = GetResource("engine/shaders/glsl/glsurface.fp"); - TArray Frag = fr1.Read(); - // Zero-terminate both strings. - Vert.Push(0); - Frag.Push(0); - surfaceShader = new SurfaceShader(); - surfaceShader->Load("SurfaceShader", (const char*)Vert.Data(), (const char*)Frag.Data()); -} - - void GLInstance::InitGLState(int fogmode, int multisample) { glShadeModel(GL_SMOOTH); // GL_FLAT diff --git a/source/glbackend/glbackend.h b/source/glbackend/glbackend.h index e51b3e12f..cd62fb181 100644 --- a/source/glbackend/glbackend.h +++ b/source/glbackend/glbackend.h @@ -178,7 +178,6 @@ public: void Init(int y); void InitGLState(int fogmode, int multisample); void LoadPolymostShader(); - void LoadSurfaceShader(); void Draw2D(F2DDrawer* drawer); void DrawImGui(ImDrawData*); void ResetFrame(); diff --git a/source/sw/src/border.cpp b/source/sw/src/border.cpp index f6b458a8f..6925f3dfb 100644 --- a/source/sw/src/border.cpp +++ b/source/sw/src/border.cpp @@ -162,24 +162,6 @@ SetConsoleDmost(void) if (ydim == 480 && gs.BorderNum == 2) adj = 1; - - //for (i = FIXED(0, 0); i < f_320; i += x_pix_size) - for (i = 0; i < xdim; i++) - // define picture - // boundaries - { - startdmost[i] = MSW(ystart) + adj; - } -} - -void ClearStartMost(void) -{ - int i; - - for (i = 0; i < xdim; i++) - startdmost[i] = ydim; - - memset(startumost.Data(), 0, xdim * sizeof(int16_t)); } void @@ -207,9 +189,6 @@ SetFragBar(PLAYERp pp) { y = (tilesiz[FRAG_BAR].y * num_frag_bars) - (2 * (num_frag_bars-1)); y = y * (ydim/200.0); - - if (windowxy1.y < y) - startumost[i] = y; } for (i = 0, y = 0; i < num_frag_bars; i++) diff --git a/source/sw/src/game.cpp b/source/sw/src/game.cpp index a49f9b71b..63d3544b7 100644 --- a/source/sw/src/game.cpp +++ b/source/sw/src/game.cpp @@ -1482,7 +1482,6 @@ void CreditsLevel(void) // get rid of all PERM sprites! renderFlushPerms(); save = gs.BorderNum; - ClearStartMost(); gs.BorderNum = save; twod->ClearScreen(); videoNextPage(); diff --git a/source/sw/src/game.h b/source/sw/src/game.h index 2bd1e6a64..8927f4095 100644 --- a/source/sw/src/game.h +++ b/source/sw/src/game.h @@ -2347,7 +2347,6 @@ void ManualPlayerInsert(PLAYERp pp); // game.c void SetRedrawScreen(PLAYERp pp); // border.c void SetupAspectRatio(void); // border.c -void ClearStartMost(void); // border.c void SetCrosshair(void); // border.c void initsynccrc(void); // sync.c diff --git a/source/sw/src/sector.cpp b/source/sw/src/sector.cpp index dfbdbfde7..145b3a20b 100644 --- a/source/sw/src/sector.cpp +++ b/source/sw/src/sector.cpp @@ -3161,7 +3161,7 @@ void movelava(char *dapic) offs2 = (LAVASIZ + 2) + 1 + ((intptr_t) lavabakpic); for (x = 0; x < LAVASIZ; x++) { - copybuf(offs, offs2, LAVASIZ >> 2); + memcpy(offs2, offs, LAVASIZ); offs += LAVASIZ; offs2 += LAVASIZ + 2; }