diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 97a4febe2..f01ee223b 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -656,12 +656,6 @@ set (PCH_SOURCES thirdparty/src/fix16.cpp thirdparty/src/md4.cpp thirdparty/src/enet.cpp - #thirdparty/imgui/imgui.cpp - #thirdparty/imgui/imgui_demo.cpp - #thirdparty/imgui/imgui_draw.cpp - #thirdparty/imgui/imgui_impl_opengl3.cpp - #thirdparty/imgui/imgui_impl_sdl.cpp - #thirdparty/imgui/imgui_widgets.cpp # Todo: Split out the license-safe code from this. build/src/animvpx.cpp @@ -679,7 +673,6 @@ set (PCH_SOURCES build/src/polymost.cpp build/src/pragmas.cpp build/src/scriptfile.cpp - build/src/sdlayer.cpp build/src/timer.cpp build/src/voxmodel.cpp diff --git a/source/blood/src/mirrors.cpp b/source/blood/src/mirrors.cpp index e5012614d..e1394f26b 100644 --- a/source/blood/src/mirrors.cpp +++ b/source/blood/src/mirrors.cpp @@ -191,18 +191,6 @@ void InitMirrors(void) void TranslateMirrorColors(int nShade, int nPalette) { - if (videoGetRenderMode() != REND_CLASSIC) - return; - videoBeginDrawing(); - nShade = ClipRange(nShade, 0, 63); - char *pMap = palookup[nPalette] + (nShade<<8); - char *pFrame = (char*)frameplace; - unsigned int nPixels = xdim*ydim; - for (unsigned int i = 0; i < nPixels; i++, pFrame++) - { - *pFrame = pMap[*pFrame]; - } - videoEndDrawing(); } void sub_5571C(char mode) diff --git a/source/build/include/a.h b/source/build/include/a.h deleted file mode 100644 index bb854cdfc..000000000 --- a/source/build/include/a.h +++ /dev/null @@ -1,88 +0,0 @@ -// Assembly-language function wrappers for a.asm functions -// for the Build Engine -// by Jonathon Fowler (jf@jonof.id.au) - - -#ifndef a_h_ -#define a_h_ - -#include "compat.h" - -#define CLASSIC_SLICE_BY_4 -#define A_C_RESTRICT __restrict - -#define CLASSIC_NONPOW2_YSIZE_SPRITES -#ifdef LUNATIC -# define CLASSIC_NONPOW2_YSIZE_WALLS -#endif - -#define SLOPTABLESIZ 32768 -#define HALFSLOPTABLESIZ (SLOPTABLESIZ>>1) - -extern int32_t sloptable[SLOPTABLESIZ]; - -/** Definitions of high-precision integer types. **/ -// Should be used for values that represent coordinates with which calculations -// like dot product are carried out. Substituting 32-bit ints for these will -// very likely yield issues in border cases: -typedef int64_t coord_t; -// Should be used for values that may overflow if 32-bit arithmetic were used, -// but where no other adverse effect (except being undefined behavior, -// obviously) is expected to result: -typedef int64_t inthi_t; -#define inthi_rintf llrintf - - -#define ENGINE_USING_A_C - -#define prevlineasm1 vlineasm1 - -void setvlinebpl(int32_t dabpl); -void fixtransluscence(intptr_t datransoff); -void settransnormal(void); -void settransreverse(void); - -void sethlinesizes(int32_t logx, int32_t logy, intptr_t bufplc); -void setpalookupaddress(char *paladdr); -void setuphlineasm4(int32_t bxinc, int32_t byinc); -void hlineasm4(bssize_t cnt, int32_t skiploadincs, int32_t paloffs, uint32_t by, uint32_t bx, intptr_t p); - -void setupslopevlin(int32_t logylogx, intptr_t bufplc, int32_t pinc); -void slopevlin(intptr_t p, int32_t i, intptr_t slopaloffs, bssize_t cnt, int32_t bx, int32_t by); - -void setupvlineasm(int32_t neglogy); -int32_t vlineasm1(int32_t vinc, intptr_t paloffs, bssize_t cnt, uint32_t vplc, intptr_t bufplc, intptr_t p); -void vlineasm4(bssize_t cnt, char *p); - -void setupmvlineasm(int32_t neglogy, int32_t dosaturate); -int32_t mvlineasm1(int32_t vinc, intptr_t paloffs, bssize_t cnt, uint32_t vplc, intptr_t bufplc, intptr_t p); -void mvlineasm4(bssize_t cnt, char *p); - -void setuptvlineasm(int32_t neglogy, int32_t dosaturate); -int32_t tvlineasm1(int32_t vinc, intptr_t paloffs, bssize_t cnt, uint32_t vplc, intptr_t bufplc, intptr_t p); - -void setuptvlineasm2(int32_t neglogy, intptr_t paloffs1, intptr_t paloffs2); -void tvlineasm2(uint32_t vplc2, int32_t vinc1, intptr_t bufplc1, intptr_t bufplc2, uint32_t vplc1, intptr_t p); - -void msethlineshift(int32_t logx, int32_t logy); -void mhline(intptr_t bufplc, uint32_t bx, int32_t cntup16, int32_t junk, uint32_t by, intptr_t p); - -void tsethlineshift(int32_t logx, int32_t logy); -void thline(intptr_t bufplc, uint32_t bx, int32_t cntup16, int32_t junk, uint32_t by, intptr_t p); - -void setupspritevline(intptr_t paloffs, int32_t bxinc, int32_t byinc, int32_t ysiz); -void spritevline(int32_t bx, int32_t by, bssize_t cnt, intptr_t bufplc, intptr_t p); - -void msetupspritevline(intptr_t paloffs, int32_t bxinc, int32_t byinc, int32_t ysiz); -void mspritevline(int32_t bx, int32_t by, bssize_t cnt, intptr_t bufplc, intptr_t p); - -void tsetupspritevline(intptr_t paloffs, int32_t bxinc, int32_t byinc, int32_t ysiz); -void tspritevline(int32_t bx, int32_t by, bssize_t cnt, intptr_t bufplc, intptr_t p); - -void setupdrawslab (int32_t dabpl, intptr_t pal); -void drawslab (int32_t dx, int32_t v, int32_t dy, int32_t vi, intptr_t vptr, intptr_t p); -void stretchhline (intptr_t p0, int32_t u, bssize_t cnt, int32_t uinc, intptr_t rptr, intptr_t p); - -void mmxoverlay(); - -#endif // a_h_ diff --git a/source/build/include/baselayer.h b/source/build/include/baselayer.h index 3226fed25..c4690d719 100644 --- a/source/build/include/baselayer.h +++ b/source/build/include/baselayer.h @@ -16,8 +16,6 @@ #include "zstring.h" #include "vectors.h" -extern char modechange; - extern int32_t swapcomplete; EXTERN_CVAR(Bool, r_usenewaspect) @@ -26,19 +24,14 @@ EXTERN_CVAR(Bool, r_usenewaspect) extern int32_t newaspect_enable; extern int32_t r_fpgrouscan; extern int32_t setaspect_new_use_dimen; -extern int32_t xres, yres, bpp, bytesperline, refreshfreq; -extern intptr_t frameplace; -extern char offscreenrendering; +extern int32_t xres, yres, bpp, refreshfreq; int32_t videoCheckMode(int32_t *x, int32_t *y, int32_t c, int32_t fs, int32_t forced); int32_t videoSetMode(int32_t x, int32_t y, int32_t c, int32_t fs); void videoGetModes(void); -void videoEndDrawing(void); void videoShowFrame(int32_t); int32_t videoUpdatePalette(int32_t start, int32_t num); -void videoBeginDrawing(void); - extern int32_t qsetmode; #define in3dmode() (qsetmode==200) diff --git a/source/build/include/build.h b/source/build/include/build.h index ef9aed751..5d2ba7550 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -98,9 +98,6 @@ enum rendmode_t { #define SPRITES_OF_STAT_SAFE(Statnum, Iter, Next) Iter=headspritestat[Statnum]; \ Iter>=0 && (Next=nextspritestat[Iter], 1); Iter=Next -#define CLEARLINES2D(Startline, Numlines, Color) \ - clearbuf((char *)(frameplace + ((Startline)*bytesperline)), (bytesperline*(Numlines))>>2, (Color)) - ////////// True Room over Room (YAX == rot -17 of "PRO") ////////// #define YAX_ENABLE diff --git a/source/build/src/a-c.cpp b/source/build/src/a-c.cpp deleted file mode 100644 index f37ea3ec4..000000000 --- a/source/build/src/a-c.cpp +++ /dev/null @@ -1,727 +0,0 @@ -// A.ASM replacement using C -// Mainly by Ken Silverman, with things melded with my port by -// Jonathon Fowler (jf@jonof.id.au) -// -// "Build Engine & Tools" Copyright (c) 1993-1997 Ken Silverman -// Ken Silverman's official web site: "http://www.advsys.net/ken" -// See the included license file "BUILDLIC.TXT" for license info. -// -// This file has been modified from Ken Silverman's original release -// by Jonathon Fowler (jf@jonof.id.au) -// by the EDuke32 team (development@voidpoint.com) - -#include "pragmas.h" - -#ifdef ENGINE_USING_A_C - -#define BITSOFPRECISION 3 -#define BITSOFPRECISIONPOW 8 - -// Compile code to saturate vplc for sprites to prevent stray lines at the -// bottom of non-y-flipped ones? -#define USE_SATURATE_VPLC -// Also for translucent masks? -//#define USE_SATURATE_VPLC_TRANS - -extern intptr_t asm1, asm2, asm3, asm4; -extern int32_t globalx3, globaly3; - -#ifdef USE_ASM64 -# define A64_ASSIGN(var, val) var=val -#else -# define A64_ASSIGN(var, val) -#endif - -#ifdef USE_ASM64 -// variables for a64.yasm -int32_t a64_bpl, a64_transmode, a64_glogy; -intptr_t a64_paloffs; -char *a64_gtrans; -#endif - -static int32_t bpl, transmode = 0; -static char *gbuf; -static int32_t glogx, glogy; -int32_t gpinc; -static int32_t gbxinc, gbyinc; -static char *gpal, *ghlinepal, *gtrans; -static char *gpal2; - -//Global variable functions -void setvlinebpl(int32_t dabpl) { A64_ASSIGN(a64_bpl, dabpl); bpl = dabpl;} -void fixtransluscence(intptr_t datransoff) -{ - A64_ASSIGN(a64_gtrans, (char *)datransoff); - gtrans = (char *)datransoff; -} -void settransnormal(void) { A64_ASSIGN(a64_transmode, 0); transmode = 0; } -void settransreverse(void) { A64_ASSIGN(a64_transmode, 1); transmode = 1; } - - -///// Ceiling/floor horizontal line functions ///// - -void sethlinesizes(int32_t logx, int32_t logy, intptr_t bufplc) -{ glogx = logx; glogy = logy; gbuf = (char *)bufplc; } -void setpalookupaddress(char *paladdr) { ghlinepal = paladdr; } -void setuphlineasm4(int32_t bxinc, int32_t byinc) { gbxinc = bxinc; gbyinc = byinc; } -void hlineasm4(bssize_t cnt, int32_t skiploadincs, int32_t paloffs, uint32_t by, uint32_t bx, intptr_t p) -{ - Bassert(gbuf); - - if (!skiploadincs) { gbxinc = asm1; gbyinc = asm2; } - - const char *const A_C_RESTRICT palptr = &ghlinepal[paloffs]; - const char *const A_C_RESTRICT buf = gbuf; - const vec2_t inc = { gbxinc, gbyinc }; - const vec2_t log = { glogx, glogy }; - const vec2_t log32 = { 32-log.x, 32-log.y }; - char *pp = (char *)p; - -#ifdef CLASSIC_SLICE_BY_4 - for (; cnt>=4; cnt-=4, pp-=4) - { -#if 1 - *pp = palptr[buf[((bx>>log32.x)<>log32.y)]]; - *(pp-1) = palptr[buf[(((bx-inc.x)>>log32.x)<>log32.y)]]; - *(pp-2) = palptr[buf[(((bx-(inc.x<<1))>>log32.x)<>log32.y)]]; - *(pp-3) = palptr[buf[(((bx-(inc.x*3))>>log32.x)<>log32.y)]]; -#else - *(int32_t *)(pp-3) = palptr[buf[(((bx-(inc.x*3))>>log32.x)<>log32.y)]] + - (palptr[buf[(((bx-(inc.x<<1))>>log32.x)<>log32.y)]]<<8) + - (palptr[buf[(((bx-inc.x)>>log32.x)<>log32.y)]]<<16) + - (palptr[buf[((bx>>log32.x)<>log32.y)]]<<24); -#endif - bx -= inc.x<<2; - by -= inc.y<<2; - } -#endif - - for (; cnt>=0; cnt--, pp--) - { - *pp = palptr[buf[((bx>>log32.x)<>log32.y)]]; - bx -= inc.x; - by -= inc.y; - } -} - - -///// Sloped ceiling/floor vertical line functions ///// -void slopevlin(intptr_t p, int32_t i, intptr_t slopaloffs, bssize_t cnt, int32_t bx, int32_t by) -{ - intptr_t * A_C_RESTRICT slopalptr; - int32_t bz, bzinc; - uint32_t u, v; - - bz = asm3; bzinc = (asm1>>3); - slopalptr = (intptr_t *)slopaloffs; - for (; cnt>0; cnt--) - { - i = (sloptable[(bz>>6)+HALFSLOPTABLESIZ]); bz += bzinc; - u = bx+(inthi_t)globalx3*i; - v = by+(inthi_t)globaly3*i; - (*(char *)p) = *(char *)(((intptr_t)slopalptr[0])+gbuf[((u>>(32-glogx))<>(32-glogy))]); - slopalptr--; - p += gpinc; - } -} - - -///// Wall,face sprite/wall sprite vertical line functions ///// - - -extern int32_t globaltilesizy; - -static inline uint32_t ourmulscale32(uint32_t a, uint32_t b) -{ - return ((uint64_t)a*b)>>32; -} - -static inline int32_t getpix(int32_t logy, const char *buf, uint32_t vplc) -{ - return logy ? buf[vplc>>logy] : buf[ourmulscale32(vplc,globaltilesizy)]; -} - -void setupvlineasm(int32_t neglogy) { glogy = neglogy; } -// cnt+1 loop iterations! -int32_t vlineasm1(int32_t vinc, intptr_t paloffs, bssize_t cnt, uint32_t vplc, intptr_t bufplc, intptr_t p) -{ - const char *const A_C_RESTRICT buf = (char *)bufplc; - const char *const A_C_RESTRICT pal = (char *)paloffs; - const int32_t logy = glogy, ourbpl = bpl; - char *pp = (char *)p; - - cnt++; - - if (logy) - { -#ifdef CLASSIC_SLICE_BY_4 - for (; cnt>=4; cnt-=4) - { - *pp = pal[buf[vplc>>logy]]; - *(pp+ourbpl) = pal[buf[(vplc+vinc)>>logy]]; - *(pp+(ourbpl<<1)) = pal[buf[(vplc+(vinc<<1))>>logy]]; - *(pp+(ourbpl*3)) = pal[buf[(vplc+(vinc*3))>>logy ]]; - pp += ourbpl<<2; - vplc += vinc<<2; - } -#endif - while (cnt--) - { - *pp = pal[buf[vplc>>logy]]; - pp += ourbpl; - vplc += vinc; - } - } - else - { -#ifdef CLASSIC_SLICE_BY_4 - for (; cnt>=4; cnt-=4) - { - *pp = pal[buf[ourmulscale32(vplc, globaltilesizy)]]; - *(pp+ourbpl) = pal[buf[ourmulscale32((vplc+vinc),globaltilesizy)]]; - *(pp+(ourbpl<<1)) = pal[buf[ourmulscale32((vplc+(vinc<<1)), globaltilesizy)]]; - *(pp+(ourbpl*3)) = pal[buf[ourmulscale32((vplc+(vinc*3)), globaltilesizy)]]; - pp += ourbpl<<2; - vplc += vinc<<2; - } -#endif - while (cnt--) - { - *pp = pal[buf[ourmulscale32(vplc,globaltilesizy)]], pp += ourbpl; - vplc += vinc; - } - } - return vplc; -} - - -extern intptr_t palookupoffse[4]; -extern uint32_t vplce[4]; -extern int32_t vince[4]; -extern intptr_t bufplce[4]; - -#if (EDUKE32_GCC_PREREQ(4,7) || __has_extension(attribute_ext_vector_type)) && defined BITNESS64 -// XXX: The "Ubuntu clang version 3.5-1ubuntu1 (trunk) (based on LLVM 3.5)" -// does not compile us with USE_VECTOR_EXT. Maybe a newer one does? -# if !defined __clang__ -# define USE_VECTOR_EXT -# endif -#endif - -#ifdef USE_VECTOR_EXT -typedef uint32_t uint32_vec4 __attribute__ ((vector_size (16))); -#endif - -#ifdef USE_SATURATE_VPLC -# define saturate_vplc(vplc, vinc) vplc |= g_saturate & -(vplc < (uint32_t)vinc) -// NOTE: the vector types yield -1 for logical "true": -# define saturate_vplc_vec(vplc, vinc) vplc |= g_saturate & (vplc < vinc) -# ifdef USE_SATURATE_VPLC_TRANS -# define saturate_vplc_trans(vplc, vinc) saturate_vplc(vplc, vinc) -# else -# define saturate_vplc_trans(vplc, vinc) -# endif -#else -# define saturate_vplc(vplc, vinc) -# define saturate_vplc_vec(vplc, vinc) -# define saturate_vplc_trans(vplc, vinc) -#endif - -#ifdef CLASSIC_NONPOW2_YSIZE_WALLS -// cnt >= 1 -static void vlineasm4nlogy(bssize_t cnt, char *p, char *const A_C_RESTRICT * pal, char *const A_C_RESTRICT * buf, -# ifdef USE_VECTOR_EXT - uint32_vec4 vplc, const uint32_vec4 vinc) -# else - uint32_t * vplc, const int32_t *vinc) -# endif -{ - const int32_t ourbpl = bpl; - - do - { - p[0] = pal[0][buf[0][ourmulscale32(vplc[0], globaltilesizy)]]; - p[1] = pal[1][buf[1][ourmulscale32(vplc[1], globaltilesizy)]]; - p[2] = pal[2][buf[2][ourmulscale32(vplc[2], globaltilesizy)]]; - p[3] = pal[3][buf[3][ourmulscale32(vplc[3], globaltilesizy)]]; - -# if defined USE_VECTOR_EXT - vplc += vinc; -# else - vplc[0] += vinc[0]; - vplc[1] += vinc[1]; - vplc[2] += vinc[2]; - vplc[3] += vinc[3]; -# endif - p += ourbpl; - } while (--cnt); - - Bmemcpy(&vplce[0], &vplc[0], sizeof(uint32_t) * 4); -} -#endif - -// cnt >= 1 -void vlineasm4(bssize_t cnt, char *p) -{ - char * const A_C_RESTRICT pal[4] = {(char *)palookupoffse[0], (char *)palookupoffse[1], (char *)palookupoffse[2], (char *)palookupoffse[3]}; - char * const A_C_RESTRICT buf[4] = {(char *)bufplce[0], (char *)bufplce[1], (char *)bufplce[2], (char *)bufplce[3]}; -#ifdef USE_VECTOR_EXT - uint32_vec4 vinc = {(uint32_t)vince[0], (uint32_t)vince[1], (uint32_t)vince[2], (uint32_t)vince[3]}; - uint32_vec4 vplc = {vplce[0], vplce[1], vplce[2], vplce[3]}; -#else - const int32_t vinc[4] = {vince[0], vince[1], vince[2], vince[3]}; - uint32_t vplc[4] = {vplce[0], vplce[1], vplce[2], vplce[3]}; -#endif - const int32_t logy = glogy, ourbpl = bpl; - -#ifdef CLASSIC_NONPOW2_YSIZE_WALLS - if (EDUKE32_PREDICT_FALSE(!logy)) - { - // This should only happen when 'globalshiftval = 0' has been set in engine.c. - vlineasm4nlogy(cnt, p, pal, buf, vplc, vinc); - return; - } -#else - assert(logy); -#endif - - // just fucking shoot me -#ifdef CLASSIC_SLICE_BY_4 - for (; cnt>=4;cnt-=4) - { - p[0] = pal[0][buf[0][ vplc[0]>>logy ]]; - p[1] = pal[1][buf[1][ vplc[1]>>logy ]]; - p[2] = pal[2][buf[2][ vplc[2]>>logy ]]; - p[3] = pal[3][buf[3][ vplc[3]>>logy ]]; - (p+ourbpl)[0] = pal[0][buf[0][ (vplc[0]+vinc[0])>>logy ]]; - (p+ourbpl)[1] = pal[1][buf[1][ (vplc[1]+vinc[1])>>logy ]]; - (p+ourbpl)[2] = pal[2][buf[2][ (vplc[2]+vinc[2])>>logy ]]; - (p+ourbpl)[3] = pal[3][buf[3][ (vplc[3]+vinc[3])>>logy ]]; - (p+(ourbpl<<1))[0] = pal[0][buf[0][ (vplc[0]+(vinc[0]<<1))>>logy ]]; - (p+(ourbpl<<1))[1] = pal[1][buf[1][ (vplc[1]+(vinc[1]<<1))>>logy ]]; - (p+(ourbpl<<1))[2] = pal[2][buf[2][ (vplc[2]+(vinc[2]<<1))>>logy ]]; - (p+(ourbpl<<1))[3] = pal[3][buf[3][ (vplc[3]+(vinc[3]<<1))>>logy ]]; - (p+(ourbpl*3))[0] = pal[0][buf[0][ (vplc[0]+(vinc[0]*3))>>logy ]]; - (p+(ourbpl*3))[1] = pal[1][buf[1][ (vplc[1]+(vinc[1]*3))>>logy ]]; - (p+(ourbpl*3))[2] = pal[2][buf[2][ (vplc[2]+(vinc[2]*3))>>logy ]]; - (p+(ourbpl*3))[3] = pal[3][buf[3][ (vplc[3]+(vinc[3]*3))>>logy ]]; - -#if defined USE_VECTOR_EXT - vplc += vinc<<2; -#else - vplc[0] += vinc[0]<<2; - vplc[1] += vinc[1]<<2; - vplc[2] += vinc[2]<<2; - vplc[3] += vinc[3]<<2; -#endif - p += ourbpl<<2; - } -#endif - - while (cnt--) - { - p[0] = pal[0][buf[0][vplc[0]>>logy]]; - p[1] = pal[1][buf[1][vplc[1]>>logy]]; - p[2] = pal[2][buf[2][vplc[2]>>logy]]; - p[3] = pal[3][buf[3][vplc[3]>>logy]]; - -#if defined USE_VECTOR_EXT - vplc += vinc; -#else - vplc[0] += vinc[0]; - vplc[1] += vinc[1]; - vplc[2] += vinc[2]; - vplc[3] += vinc[3]; -#endif - p += ourbpl; - } - - Bmemcpy(&vplce[0], &vplc[0], sizeof(uint32_t) * 4); -} - -#ifdef USE_SATURATE_VPLC -static int32_t g_saturate; // -1 if saturating vplc is requested, 0 else -# define set_saturate(dosaturate) g_saturate = -(int)!!dosaturate -#else -# define set_saturate(dosaturate) UNREFERENCED_PARAMETER(dosaturate) -#endif - -void setupmvlineasm(int32_t neglogy, int32_t dosaturate) -{ - glogy = neglogy; - set_saturate(dosaturate); -} - -// cnt+1 loop iterations! -int32_t mvlineasm1(int32_t vinc, intptr_t paloffs, bssize_t cnt, uint32_t vplc, intptr_t bufplc, intptr_t p) -{ - char ch; - - const char *const A_C_RESTRICT buf = (char *)bufplc; - const char *const A_C_RESTRICT pal = (char *)paloffs; - const int32_t logy = glogy, ourbpl = bpl; - char *pp = (char *)p; - - cnt++; - - if (!logy) - { - do - { - ch = buf[ourmulscale32(vplc,globaltilesizy)]; - if (ch != 255) *pp = pal[ch]; - pp += ourbpl; - vplc += vinc; - saturate_vplc(vplc, vinc); - } - while (--cnt); - - return vplc; - } - - do - { - - if (buf[vplc>>logy] != 255) - *pp = pal[buf[vplc>>logy]]; - pp += ourbpl; - vplc += vinc; - saturate_vplc(vplc, vinc); - } - while (--cnt); - - return vplc; -} - -// cnt >= 1 -void mvlineasm4(bssize_t cnt, char *p) -{ - char *const A_C_RESTRICT pal[4] = {(char *)palookupoffse[0], (char *)palookupoffse[1], (char *)palookupoffse[2], (char *)palookupoffse[3]}; - char *const A_C_RESTRICT buf[4] = {(char *)bufplce[0], (char *)bufplce[1], (char *)bufplce[2], (char *)bufplce[3]}; -#ifdef USE_VECTOR_EXT - uint32_vec4 vinc = {(uint32_t)vince[0], (uint32_t)vince[1], (uint32_t)vince[2], (uint32_t)vince[3]}; - uint32_vec4 vplc = {vplce[0], vplce[1], vplce[2], vplce[3]}; -#else - const int32_t vinc[4] = {vince[0], vince[1], vince[2], vince[3]}; - uint32_t vplc[4] = {vplce[0], vplce[1], vplce[2], vplce[3]}; -#endif - const int32_t logy = glogy, ourbpl = bpl; - char ch; - - if (logy) - { - do - { - ch = buf[0][vplc[0]>>logy]; - if (ch != 255) p[0] = pal[0][ch]; - ch = buf[1][vplc[1]>>logy]; - if (ch != 255) p[1] = pal[1][ch]; - ch = buf[2][vplc[2]>>logy]; - if (ch != 255) p[2] = pal[2][ch]; - ch = buf[3][vplc[3]>>logy]; - if (ch != 255) p[3] = pal[3][ch]; - -#if !defined USE_VECTOR_EXT - vplc[0] += vinc[0]; - vplc[1] += vinc[1]; - vplc[2] += vinc[2]; - vplc[3] += vinc[3]; - saturate_vplc(vplc[0], vinc[0]); - saturate_vplc(vplc[1], vinc[1]); - saturate_vplc(vplc[2], vinc[2]); - saturate_vplc(vplc[3], vinc[3]); -#else - vplc += vinc; - saturate_vplc_vec(vplc, vinc); -#endif - p += ourbpl; - } - while (--cnt); - } - else - { - do - { - ch = buf[0][ourmulscale32(vplc[0],globaltilesizy)]; - if (ch != 255) p[0] = pal[0][ch]; - ch = buf[1][ourmulscale32(vplc[1],globaltilesizy)]; - if (ch != 255) p[1] = pal[1][ch]; - ch = buf[2][ourmulscale32(vplc[2],globaltilesizy)]; - if (ch != 255) p[2] = pal[2][ch]; - ch = buf[3][ourmulscale32(vplc[3],globaltilesizy)]; - if (ch != 255) p[3] = pal[3][ch]; - -#if !defined USE_VECTOR_EXT - vplc[0] += vinc[0]; - vplc[1] += vinc[1]; - vplc[2] += vinc[2]; - vplc[3] += vinc[3]; - saturate_vplc(vplc[0], vinc[0]); - saturate_vplc(vplc[1], vinc[1]); - saturate_vplc(vplc[2], vinc[2]); - saturate_vplc(vplc[3], vinc[3]); -#else - vplc += vinc; - saturate_vplc_vec(vplc, vinc); -#endif - p += ourbpl; - } - while (--cnt); - } - - Bmemcpy(&vplce[0], &vplc[0], sizeof(uint32_t) * 4); -} - -#ifdef USE_ASM64 -# define GLOGY a64_glogy -#else -# define GLOGY glogy -#endif - -void setuptvlineasm(int32_t neglogy, int32_t dosaturate) -{ - GLOGY = neglogy; - set_saturate(dosaturate); -} - -#if !defined USE_ASM64 -// cnt+1 loop iterations! -int32_t tvlineasm1(int32_t vinc, intptr_t paloffs, bssize_t cnt, uint32_t vplc, intptr_t bufplc, intptr_t p) -{ - char ch; - - const char *const A_C_RESTRICT buf = (char *)bufplc; - const char *const A_C_RESTRICT pal = (char *)paloffs; - const char *const A_C_RESTRICT trans = (char *)gtrans; - const int32_t logy = glogy, ourbpl = bpl, transm = transmode; - char *pp = (char *)p; - - cnt++; - - uint8_t const shift = transm<<3; - - do - { - ch = getpix(logy, buf, vplc); - if (ch != 255) *pp = trans[((*pp)<<(8-shift))|(pal[ch]<= 1 - const int32_t vinc2 = asm1; - - const char *const A_C_RESTRICT buf1 = (char *)bufplc1; - const char *const A_C_RESTRICT buf2 = (char *)bufplc2; - const int32_t logy = glogy, ourbpl = bpl, transm = transmode; - - char *pp = (char *)p; - - cnt++; - - uint8_t const shift = transm<<3; - - do - { - ch = getpix(logy, buf1, vplc1); - if (ch != 255) pp[0] = gtrans[(pp[0]<<(8-shift))|(gpal[ch]< 0); - - asm1 = vplc1; - asm2 = vplc2; -} -#endif - -//Floor sprite horizontal line functions -void msethlineshift(int32_t logx, int32_t logy) { glogx = logx; glogy = logy; } -// cntup16>>16 + 1 iterations -void mhline(intptr_t bufplc, uint32_t bx, int32_t cntup16, int32_t junk, uint32_t by, intptr_t p) -{ - char ch; - - const int32_t xinc = asm1, yinc = asm2; - - UNREFERENCED_PARAMETER(junk); - - gbuf = (char *)bufplc; - gpal = (char *)asm3; - - cntup16>>=16; - cntup16++; - do - { - ch = gbuf[((bx>>(32-glogx))<>(32-glogy))]; - if (ch != 255) *((char *)p) = gpal[ch]; - bx += xinc; - by += yinc; - p++; - } - while (--cntup16); -} - -void tsethlineshift(int32_t logx, int32_t logy) { glogx = logx; glogy = logy; } -// cntup16>>16 + 1 iterations -void thline(intptr_t bufplc, uint32_t bx, int32_t cntup16, int32_t junk, uint32_t by, intptr_t p) -{ - char ch; - - const int32_t xinc = asm1, yinc = asm2; - - UNREFERENCED_PARAMETER(junk); - - gbuf = (char *)bufplc; - gpal = (char *)asm3; - - cntup16>>=16; - cntup16++; - - uint8_t const shift = transmode<<3; - - do - { - ch = gbuf[((bx>>(32-glogx))<>(32-glogy))]; - if (ch != 255) *((char *)p) = gtrans[((*((char *)p))<<(8-shift))|(gpal[ch]<1; cnt--) - { - (*(char *)p) = gpal[gbuf[(bx>>16)*glogy+(by>>16)]]; - bx += gbxinc; - by += gbyinc; - p += bpl; - } -} - -//Rotatesprite vertical line functions -void msetupspritevline(intptr_t paloffs, int32_t bxinc, int32_t byinc, int32_t ysiz) -{ - gpal = (char *)paloffs; - gbxinc = bxinc; - gbyinc = byinc; - glogy = ysiz; -} -void mspritevline(int32_t bx, int32_t by, bssize_t cnt, intptr_t bufplc, intptr_t p) -{ - char ch; - - gbuf = (char *)bufplc; - for (; cnt>1; cnt--) - { - ch = gbuf[(bx>>16)*glogy+(by>>16)]; - if (ch != 255) (*(char *)p) = gpal[ch]; - bx += gbxinc; - by += gbyinc; - p += bpl; - } -} - -void tsetupspritevline(intptr_t paloffs, int32_t bxinc, int32_t byinc, int32_t ysiz) -{ - gpal = (char *)paloffs; - gbxinc = bxinc; - gbyinc = byinc; - glogy = ysiz; -} -void tspritevline(int32_t bx, int32_t by, bssize_t cnt, intptr_t bufplc, intptr_t p) -{ - char ch; - - gbuf = (char *)bufplc; - - uint8_t const shift = transmode<<3; - - for (; cnt>1; cnt--) - { - ch = gbuf[(bx>>16)*glogy+(by>>16)]; - if (ch != 255) *((char *)p) = gtrans[((*((char *)p))<<(8-shift))+(gpal[ch]<>16)+vptr))]; - for (int x=0; x < dx; x++) - ((char*)p)[x] = c; - p += bpl; - v += vi; - } - while (--dy); -} - -#if 0 -void stretchhline(intptr_t p0, int32_t u, bssize_t cnt, int32_t uinc, intptr_t rptr, intptr_t p) -{ - p0 = p-(cnt<<2); - do - { - p--; - *(char *)p = *(char *)((u>>16)+rptr); u -= uinc; - } - while (p > p0); -} -#endif - -#endif -/* - * vim:ts=4: - */ - diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index 1646af218..a128542af 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -1217,7 +1217,6 @@ static vec3_t spritesxyz[MAXSPRITESONSCREEN+1]; int32_t xdimen = -1, xdimenrecip, halfxdimen, xdimenscale, xdimscale; float fxdimen = -1.f; int32_t ydimen; -intptr_t frameoffset; static int32_t nrx1[8], nry1[8], nrx2[8], nry2[8]; // JBF 20031206: Thanks Ken @@ -3060,8 +3059,6 @@ killsprite: sortsprites(0, spritesortcnt); sortsprites(spritesortcnt, numSprites); - videoBeginDrawing(); //{{{ - #ifdef USE_OPENGL if (videoGetRenderMode() == REND_POLYMOST) { @@ -3281,9 +3278,6 @@ killsprite: GLInterface.SetDepthBias(0, 0); } #endif - - - videoEndDrawing(); //}}} } @@ -4174,12 +4168,6 @@ int32_t videoSetGameMode(char davidoption, int32_t daupscaledxdim, int32_t daups Bstrcpy(kensmessage,"!!!! BUILD engine&tools programmed by Ken Silverman of E.G. RI." " (c) Copyright 1995 Ken Silverman. Summary: BUILD = Ken. !!!!"); - // if (getkensmessagecrc(FP_OFF(kensmessage)) != 0x56c764d4) - // { OSD_Printf("Nice try.\n"); Bexit(EXIT_SUCCESS); } - - //if (checkvideomode(&daxdim, &daydim, dabpp, davidoption)<0) return -1; - - //bytesperline is set in this function j = bpp; @@ -5532,23 +5520,9 @@ void videoClearViewableArea(int32_t dacol) void videoClearScreen(int32_t dacol) { if (!in3dmode()) return; - //dacol += (dacol<<8); dacol += (dacol<<16); -#ifdef USE_OPENGL - if (videoGetRenderMode() >= REND_POLYMOST) - { - palette_t const p = paletteGetColor(dacol); - GLInterface.ClearScreen(PalEntry(255, p.r, p.g, p.b)); - return; - } -#endif - - videoBeginDrawing(); //{{{ - Bmemset((void *)frameplace,dacol,bytesperline*ydim); - videoEndDrawing(); //}}} - //nextpage(); - - faketimerhandler(); + palette_t const p = paletteGetColor(dacol); + GLInterface.ClearScreen(PalEntry(255, p.r, p.g, p.b)); } @@ -5579,7 +5553,6 @@ void renderSetTarget(int16_t tilenume, int32_t xsiz, int32_t ysiz) setviewcnt++; - offscreenrendering = 1; xdim = ysiz*4; ydim = xsiz*4; videoSetViewableArea(0,0,ysiz*4-1,xsiz*4-1); @@ -5595,7 +5568,6 @@ void renderRestoreTarget() if (setviewcnt <= 0) return; setviewcnt--; - offscreenrendering = (setviewcnt>0); OpenGLRenderer::GLRenderer->EndOffscreen(); xdim = bakxsiz; @@ -5603,7 +5575,6 @@ void renderRestoreTarget() videoSetViewableArea(bakwindowxy1.x,bakwindowxy1.y, bakwindowxy2.x,bakwindowxy2.y); - modechange=1; } diff --git a/source/build/src/engine_priv.h b/source/build/src/engine_priv.h index a6955688d..fb5b2aa26 100644 --- a/source/build/src/engine_priv.h +++ b/source/build/src/engine_priv.h @@ -95,7 +95,6 @@ extern tspriteptr_t tspriteptr[MAXSPRITESONSCREEN + 1]; extern TArray mirrorBuffer; extern int32_t xdimen, xdimenrecip, halfxdimen, xdimenscale, xdimscale, ydimen; extern float fxdimen; -extern intptr_t frameoffset; extern int32_t globalposx, globalposy, globalposz, globalhoriz; extern fix16_t qglobalhoriz, qglobalang; extern float fglobalposx, fglobalposy, fglobalposz; diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index 4a17ddca6..f24a43bcf 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -3164,9 +3164,6 @@ void polymost_drawrooms() polymost_outputGLDebugMessage(3, "polymost_drawrooms()"); - videoBeginDrawing(); - frameoffset = frameplace + windowxy1.y*bytesperline + windowxy1.x; - #ifdef YAX_ENABLE if (yax_polymostclearzbuffer) #endif @@ -3284,7 +3281,6 @@ void polymost_drawrooms() if (n < 3) { GLInterface.SetDepthFunc(Depth_LessEqual); - videoEndDrawing(); return; } @@ -3350,7 +3346,6 @@ void polymost_drawrooms() while (i); #endif } - //else if (!g_nodraw) { videoEndDrawing(); return; } #endif numscans = numbunches = 0; @@ -3415,8 +3410,6 @@ void polymost_drawrooms() } GLInterface.SetDepthFunc(Depth_LessEqual); - - videoEndDrawing(); } static void polymost_drawmaskwallinternal(int32_t wallIndex) diff --git a/source/build/src/sdlayer.cpp b/source/build/src/sdlayer.cpp deleted file mode 100644 index 4e0951954..000000000 --- a/source/build/src/sdlayer.cpp +++ /dev/null @@ -1,121 +0,0 @@ -// SDL interface layer for the Build Engine -// Use SDL 1.2 or 2.0 from http://www.libsdl.org - -#include "build.h" - -#include "common.h" -#include "compat.h" -#include "engine_priv.h" -#include "palette.h" -#include "baselayer.h" -#include "mmulti.h" -#include "glsurface.h" - - -double g_beforeSwapTime; -GameInterface* gi; - -int myconnectindex, numplayers; -int connecthead, connectpoint2[MAXMULTIPLAYERS]; - -void ImGui_Init_Backend() -{ - //ImGui_ImplSDL2_InitForOpenGL(sdl_window, sdl_context); -} - -void ImGui_Begin_Frame() -{ - //ImGui_ImplOpenGL3_NewFrame(); - //ImGui_ImplSDL2_NewFrame(sdl_window); - //ImGui::NewFrame(); -} - -int32_t xres=-1, yres=-1, bpp=0, bytesperline, refreshfreq=-1; -intptr_t frameplace=0; -int32_t lockcount=0; -char modechange=1; -char offscreenrendering=0; - - -// -// begindrawing() -- locks the framebuffer for drawing -// - -void videoBeginDrawing(void) -{ - if (bpp > 8) - { - if (offscreenrendering) return; - frameplace = 0; - bytesperline = 0; - modechange = 0; - return; - } - - // lock the frame - if (lockcount++ > 0) - return; - - static intptr_t backupFrameplace = 0; - - if (inpreparemirror) - { - //POGO: if we are offscreenrendering and we need to render a mirror - // or we are rendering a mirror and we start offscreenrendering, - // backup our offscreen target so we can restore it later - // (but only allow one level deep, - // i.e. no viewscreen showing a camera showing a mirror that reflects the same viewscreen and recursing) - if (offscreenrendering) - { - if (!backupFrameplace) - backupFrameplace = frameplace; - else if (frameplace != (intptr_t)mirrorBuffer.Data() && - frameplace != backupFrameplace) - return; - } - - frameplace = (intptr_t)mirrorBuffer.Data(); - - if (offscreenrendering) - return; - } - else if (offscreenrendering) - { - if (backupFrameplace) - { - frameplace = backupFrameplace; - backupFrameplace = 0; - } - return; - } - else - frameplace = (intptr_t)glsurface_getBuffer(); - - if (modechange) - { - bytesperline = xdim; - modechange=0; - } -} - - -// -// enddrawing() -- unlocks the framebuffer -// -void videoEndDrawing(void) -{ - if (bpp > 8) - { - if (!offscreenrendering) frameplace = 0; - return; - } - - if (!frameplace) return; - if (lockcount > 1) { lockcount--; return; } - if (!offscreenrendering) frameplace = 0; - if (lockcount == 0) return; - lockcount = 0; -} - -auto vsnprintfptr = vsnprintf; // This is an inline in Visual Studio but we need an address for it to satisfy the MinGW compiled libraries. - diff --git a/source/common/gamecontrol.cpp b/source/common/gamecontrol.cpp index f815869e4..99bc5ae6d 100644 --- a/source/common/gamecontrol.cpp +++ b/source/common/gamecontrol.cpp @@ -56,6 +56,16 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "resourcefile.h" #include "c_dispatch.h" #include "glbackend/glbackend.h" +#include "mmulti.h" + +// The last remains of sdlayer.cpp +double g_beforeSwapTime; +GameInterface* gi; +int myconnectindex, numplayers; +int connecthead, connectpoint2[MAXMULTIPLAYERS]; +int32_t xres = -1, yres = -1, bpp = 0, refreshfreq = -1; +auto vsnprintfptr = vsnprintf; // This is an inline in Visual Studio but we need an address for it to satisfy the MinGW compiled libraries. + MapRecord mapList[512]; // Due to how this gets used it needs to be static. EDuke defines 7 episode plus one spare episode with 64 potential levels each and relies on the static array which is freely accessible by scripts. MapRecord *currentLevel; // level that is currently played. (The real level, not what script hacks modfifying the current level index can pretend.) diff --git a/source/common/rendering/gl/renderer/gl_renderer.cpp b/source/common/rendering/gl/renderer/gl_renderer.cpp index 206b85f59..c966e333e 100644 --- a/source/common/rendering/gl/renderer/gl_renderer.cpp +++ b/source/common/rendering/gl/renderer/gl_renderer.cpp @@ -221,7 +221,6 @@ void FGLRenderer::WriteSavePic ( FileWriter *file, int width, int height) xdim = oldx; ydim = oldy; videoSetViewableArea(oldwindowxy1.x, oldwindowxy1.y, oldwindowxy2.x, oldwindowxy2.y); - modechange = 1; // The 2D drawers can contain some garbage from the dirty render setup. Get rid of that first. twodgen.Clear(); diff --git a/source/common/screenshot.cpp b/source/common/screenshot.cpp index 4705cbdea..d40fae46e 100644 --- a/source/common/screenshot.cpp +++ b/source/common/screenshot.cpp @@ -125,8 +125,6 @@ static int SaveScreenshot() auto truecolor = videoGetRenderMode() >= REND_POLYMOST; TArray imgBuf(xdim * ydim * (truecolor ? 3 : 1), true); - videoBeginDrawing(); - if (truecolor) { getScreen(imgBuf.Data()); @@ -142,8 +140,6 @@ static int SaveScreenshot() } } - videoEndDrawing(); - WritePNGfile(fil, imgBuf.Data(), Palette, truecolor ? SS_RGB : SS_PAL, xdim, ydim, truecolor? xdim*3 : xdim, png_gamma); delete fil; Printf("screenshot saved\n"); diff --git a/source/glbackend/glbackend.cpp b/source/glbackend/glbackend.cpp index 7dc23c8a2..3d24eafae 100644 --- a/source/glbackend/glbackend.cpp +++ b/source/glbackend/glbackend.cpp @@ -94,24 +94,6 @@ void GLInstance::Init(int ydim) new(&renderState) PolymostRenderState; // reset to defaults. LoadSurfaceShader(); LoadPolymostShader(); -#if 0 - IMGUI_CHECKVERSION(); - im_ctx = ImGui::CreateContext(); - ImGuiIO& io = ImGui::GetIO(); (void)io; - io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls - //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls - - // Setup Dear ImGui style - ImGui::StyleColorsDark(); - ImGui_Init_Backend(); - ImGui_ImplOpenGL3_Init(); - if (!ttf.Size()) - { - //ttf = fileSystem.LoadFile("engine/Capsmall_clean.ttf", 0); - ttf = fileSystem.LoadFile("engine/Roboto-Regular.ttf", 0); - } - if (ttf.Size()) io.Fonts->AddFontFromMemoryTTF(ttf.Data(), ttf.Size(), std::clamp(ydim / 40, 10, 30)); -#endif } void GLInstance::LoadPolymostShader() diff --git a/source/rr/src/rrdh.cpp b/source/rr/src/rrdh.cpp index 8624a9895..f1837996e 100644 --- a/source/rr/src/rrdh.cpp +++ b/source/rr/src/rrdh.cpp @@ -1864,7 +1864,6 @@ void sub_54FA4(int a1, int a2) ptr1 = (char*)waloff[7050]; if (!ptr1) return; - videoBeginDrawing(); ptr2 = (char*)frameplace; if (!ptr2) return; @@ -1879,7 +1878,6 @@ void sub_54FA4(int a1, int a2) ptr1++; } } - videoEndDrawing(); rotatesprite(a1<<16, a2<<16, 57344, 512, 7050, 0, 0, 4+2, windowxy1.x, windowxy1.y, windowxy2.x, windowxy2.y); rotatesprite(a1<<16, a2<<16, 57344, 512, 7050, -8, 0, 4+2+1, windowxy1.x, windowxy1.y, windowxy2.x, windowxy2.y); rotatesprite(a1<<16, a2<<16, 32768, 0, 7063, -24, 0, 32+2+1, windowxy1.x, windowxy1.y, windowxy2.x, windowxy2.y);