diff --git a/source/audiolib/include/multivoc.h b/source/audiolib/include/multivoc.h index c07ec70a2..142d17114 100644 --- a/source/audiolib/include/multivoc.h +++ b/source/audiolib/include/multivoc.h @@ -67,8 +67,8 @@ enum MV_Errors MV_InvalidFile, }; -void DisableInterrupts(void); -void RestoreInterrupts(void); +void MV_Lock(void); +void MV_Unlock(void); extern void (*MV_Printf)(const char *fmt, ...); const char *MV_ErrorString(int32_t ErrorNumber); diff --git a/source/audiolib/src/multivoc.cpp b/source/audiolib/src/multivoc.cpp index dc1dba62e..a45cacd09 100644 --- a/source/audiolib/src/multivoc.cpp +++ b/source/audiolib/src/multivoc.cpp @@ -90,13 +90,13 @@ float MV_VolumeSmooth = 1.f; static int lockdepth = 0; -static inline void MV_Lock(void) +void MV_Lock(void) { if (!lockdepth++) SoundDriver_Lock(); } -static inline void MV_Unlock(void) +void MV_Unlock(void) { if (!--lockdepth) SoundDriver_Unlock(); diff --git a/source/blood/src/mirrors.cpp b/source/blood/src/mirrors.cpp index 8d178a8ec..1504644e1 100644 --- a/source/blood/src/mirrors.cpp +++ b/source/blood/src/mirrors.cpp @@ -382,14 +382,13 @@ void DrawMirrors(int x, int y, int z, fix16_t a, fix16_t horiz) } else { - //renderPrepareMirror(x,y, fix16_from_int(a),nWall,&cx,&cy,&ca); - renderPrepareMirrorOld(x,y,z,a,horiz,nWall,mirrorsector,&cx,&cy,&ca); + renderPrepareMirror(x,y,z,a,horiz,nWall,&cx,&cy,&ca); } renderDrawRoomsQ16(cx, cy, z, ca,horiz,mirrorsector|MAXSECTORS); viewProcessSprites(cx,cy,z); renderDrawMasks(); if (pWall->lotag != 501) - renderCompleteMirrorOld(); + renderCompleteMirror(); if (wall[nWall].pal != 0 || wall[nWall].shade != 0) TranslateMirrorColors(wall[nWall].shade, wall[nWall].pal); pWall->nextwall = nNextWall; diff --git a/source/build/include/build.h b/source/build/include/build.h index 5bb0c6617..2f16d32c1 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -1112,10 +1112,7 @@ void renderSetTarget(int16_t tilenume, int32_t xsiz, int32_t ysiz); void renderRestoreTarget(void); void renderPrepareMirror(int32_t dax, int32_t day, int32_t daz, fix16_t daang, fix16_t dahoriz, int16_t dawall, int32_t *tposx, int32_t *tposy, fix16_t *tang); -void renderPrepareMirrorOld(int32_t dax, int32_t day, int32_t daz, fix16_t daang, fix16_t dahoriz, - int16_t dawall, int16_t dasector, int32_t *tposx, int32_t *tposy, fix16_t *tang); void renderCompleteMirror(void); -void renderCompleteMirrorOld(void); int32_t renderDrawRoomsQ16(int32_t daposx, int32_t daposy, int32_t daposz, fix16_t daang, fix16_t dahoriz, int16_t dacursectnum); diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index 190634398..d129f5271 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -205,7 +205,6 @@ static fix16_t global100horiz; // (-100..300)-scale horiz (the one passed to dr int32_t(*getpalookup_replace)(int32_t davis, int32_t dashade) = NULL; -int32_t automapping = 0; int32_t bloodhack = 0; // adapted from build.c @@ -12142,47 +12141,6 @@ void renderPrepareMirror(int32_t dax, int32_t day, int32_t daz, fix16_t daang, f #endif } -static int32_t mirthoriz, mirbakdaz; -static int16_t mirbakdasector; - -void renderPrepareMirrorOld(int32_t dax, int32_t day, int32_t daz, fix16_t daang, fix16_t dahoriz, - int16_t dawall, int16_t dasector, int32_t *tposx, int32_t *tposy, fix16_t *tang) -{ - //mirrorrender = 1; - const int32_t x = wall[dawall].x, dx = wall[wall[dawall].point2].x-x; - const int32_t y = wall[dawall].y, dy = wall[wall[dawall].point2].y-y; - - const int32_t j = dx*dx + dy*dy; - if (j == 0) - return; - - int i = ((dax-x)*dx + (day-y)*dy)<<1; - - *tposx = (x<<1) + scale(dx,i,j) - dax; - *tposy = (y<<1) + scale(dy,i,j) - day; - *tang = (fix16_from_int(getangle(dx, dy) << 1) - daang) & 0x7FFFFFF; - - if (videoGetRenderMode() != REND_CLASSIC) - { - inpreparemirror = 1; - return; - } - - videoBeginDrawing(); - mirbakdaz = daz; mirbakdasector = dasector; - if ((daz > sector[dasector].ceilingz) && (daz < sector[dasector].floorz)) - { - //Draw pink pixels on horizon to get mirror l&r bounds. - mirthoriz = scale(dahoriz - fix16_from_int(100), windowxy2.x - windowxy1.x, fix16_from_int(320)) + ((windowxy1.y + windowxy2.y) >> 1); - if ((daz << 1) > sector[dasector].ceilingz + sector[dasector].floorz) - mirthoriz--; else mirthoriz++; - mirthoriz = min(max(mirthoriz, windowxy1.y), windowxy2.y); - clearbufbyte((char*)frameplace + ylookup[mirthoriz] + windowxy1.x, windowxy2.x - windowxy1.x + 1, 0xffffffff); - } - videoEndDrawing(); -} - - // // completemirror // @@ -12245,47 +12203,6 @@ void renderCompleteMirror(void) videoEndDrawing(); } -void renderCompleteMirrorOld(void) -{ - //mirrorrender = 0; -#ifdef USE_OPENGL - if (videoGetRenderMode() != REND_CLASSIC) - return; -#endif - - videoBeginDrawing(); - int32_t x1, y1, x2, y2, dy; - char *ptr; - - //Get pink pixels on horizon to get mirror l&r bounds. - x1 = 0; x2 = windowxy2.x - windowxy1.x; - if ((mirbakdaz > sector[mirbakdasector].ceilingz) && (mirbakdaz < sector[mirbakdasector].floorz)) - { - ptr = (char *)frameplace + ylookup[mirthoriz] + windowxy1.x; - while ((ptr[x1] == 255) && (x2 >= x1)) x1++; - while ((ptr[x2] == 255) && (x2 >= x1)) x2--; - if (x1 > 0) x1--; - if (x2 < windowxy2.x - windowxy1.x) x2++; - x2 |= 3; - if (x2 > windowxy2.x - windowxy1.x) x2 = windowxy2.x - windowxy1.x; - } - - if (x2 >= x1) //Flip window x-wise - { - ptr = (char *)frameplace + ylookup[windowxy1.y] + windowxy1.x; - y1 = windowxy2.x - windowxy1.x - x2; x2 -= x1; y2 = x2 + 1; - for (dy = windowxy2.y - windowxy1.y; dy >= 0; dy--) - { - copybufbyte(&ptr[x1 + 1], &tempbuf[0], y2); - tempbuf[x2] = tempbuf[x2 - 1]; - copybufreverse(&tempbuf[x2], &ptr[y1], y2); - ptr += ylookup[1]; - faketimerhandler(); - } - } - videoEndDrawing(); -} - // // sectorofwall diff --git a/source/rr/src/game.cpp b/source/rr/src/game.cpp index 59b868775..f47b046e8 100644 --- a/source/rr/src/game.cpp +++ b/source/rr/src/game.cpp @@ -849,7 +849,7 @@ void G_HandleMirror(int32_t x, int32_t y, int32_t z, fix16_t a, fix16_t q16horiz int32_t tposx, tposy; fix16_t tang; - renderPrepareMirror(x, y, a, g_mirrorWall[i], &tposx, &tposy, &tang); + renderPrepareMirror(x, y, z, a, q16horiz, g_mirrorWall[i], &tposx, &tposy, &tang); int32_t j = g_visibility; g_visibility = (j>>1) + (j>>2); @@ -7692,30 +7692,26 @@ void G_MaybeAllocPlayer(int32_t pnum) int G_FPSLimit(void) { - static double nextPageDelay = g_frameDelay; - static uint64_t lastFrameTicks = timerGetTicksU64() - (uint64_t)g_frameDelay; - int frameWaiting = 0; + if (!r_maxfps) + return 1; - uint64_t const frameTicks = timerGetTicksU64(); - uint64_t elapsedTime = frameTicks - lastFrameTicks; + static double nextPageDelay; + static double lastFrameTicks; - if (!r_maxfps || elapsedTime >= (uint64_t)nextPageDelay) + double const frameTicks = timerGetTicksU64(); + double const elapsedTime = frameTicks - lastFrameTicks; + + if (elapsedTime >= nextPageDelay) { - if (elapsedTime >= (uint64_t)(nextPageDelay + g_frameDelay)) - { - //If we missed a frame, reset any cumulated remainder from rendering frames early - nextPageDelay = g_frameDelay; - } - else - { + if (elapsedTime <= nextPageDelay + g_frameDelay) nextPageDelay += g_frameDelay - elapsedTime; - } lastFrameTicks = frameTicks; - ++frameWaiting; + + return 1; } - return frameWaiting; + return 0; }