diff --git a/Source/debug.cpp b/Source/debug.cpp index 87ee91c3c..d12ec10ad 100644 --- a/Source/debug.cpp +++ b/Source/debug.cpp @@ -5,6 +5,7 @@ DEVILUTION_BEGIN_NAMESPACE #ifdef _DEBUG BOOL update_seed_check = FALSE; #endif +BOOL debugRender = FALSE; int seed_index; int level_seeds[NUMLEVELS]; diff --git a/Source/debug.h b/Source/debug.h index d8eecf07e..f47dcac1f 100644 --- a/Source/debug.h +++ b/Source/debug.h @@ -2,6 +2,7 @@ #ifndef __DEBUG_H__ #define __DEBUG_H__ +extern BOOL debugRender; extern BYTE *pSquareCel; extern char dMonsDbg[NUMLEVELS][MAXDUNX][MAXDUNY]; extern char dFlagDbg[NUMLEVELS][MAXDUNX][MAXDUNY]; diff --git a/Source/diablo.cpp b/Source/diablo.cpp index 8ee962626..af3dc80b6 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -1057,6 +1057,10 @@ void PressChar(int vkey) } switch (vkey) { + case 'R': + case 'r': + debugRender = !debugRender; + return; case 'G': case 'g': DecreaseGamma(); @@ -1268,15 +1272,6 @@ void PressChar(int vkey) case 'm': GetDebugMonster(); return; - case 'R': - case 'r': - sprintf(tempstr, "seed = %i", glSeedTbl[currlevel]); - NetSendCmdString(1 << myplr, tempstr); - sprintf(tempstr, "Mid1 = %i : Mid2 = %i : Mid3 = %i", glMid1Seed[currlevel], glMid2Seed[currlevel], glMid3Seed[currlevel]); - NetSendCmdString(1 << myplr, tempstr); - sprintf(tempstr, "End = %i", glEndSeed[currlevel]); - NetSendCmdString(1 << myplr, tempstr); - return; case 'T': case 't': if (debug_mode_key_inverted_v) { diff --git a/Source/engine.cpp b/Source/engine.cpp index f73a7358d..df8705a03 100644 --- a/Source/engine.cpp +++ b/Source/engine.cpp @@ -113,6 +113,7 @@ void CelDrawLightRed(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, char w -= width; while (width) { *dst = tbl[*pRLEBytes]; + StepRender(); pRLEBytes++; dst++; width--; @@ -150,6 +151,7 @@ void CelBlitSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) i -= width; if (dst < gpBufEnd && dst > gpBufStart) { memcpy(dst, src, width); + StepRender(); } src += width; dst += width; @@ -206,22 +208,29 @@ void CelBlitLightSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidt if (dst < gpBufEnd && dst > gpBufStart) { if (width & 1) { dst[0] = tbl[src[0]]; + StepRender(); src++; dst++; } width >>= 1; if (width & 1) { dst[0] = tbl[src[0]]; + StepRender(); dst[1] = tbl[src[1]]; + StepRender(); src += 2; dst += 2; } width >>= 1; for (; width; width--) { dst[0] = tbl[src[0]]; + StepRender(); dst[1] = tbl[src[1]]; + StepRender(); dst[2] = tbl[src[2]]; + StepRender(); dst[3] = tbl[src[3]]; + StepRender(); src += 4; dst += 4; } @@ -277,13 +286,16 @@ void CelBlitLightTransSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int width >>= 1; if (width & 1) { dst[0] = tbl[src[0]]; + StepRender(); src += 2; dst += 2; } width >>= 1; for (; width; width--) { dst[0] = tbl[src[0]]; + StepRender(); dst[2] = tbl[src[2]]; + StepRender(); src += 4; dst += 4; } @@ -293,19 +305,23 @@ void CelBlitLightTransSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int goto L_EVEN; } else { dst[0] = tbl[src[0]]; + StepRender(); src++; dst++; L_ODD: width >>= 1; if (width & 1) { dst[1] = tbl[src[1]]; + StepRender(); src += 2; dst += 2; } width >>= 1; for (; width; width--) { dst[1] = tbl[src[1]]; + StepRender(); dst[3] = tbl[src[3]]; + StepRender(); src += 4; dst += 4; } @@ -373,6 +389,7 @@ void CelDrawLightRedSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, c if (dst < gpBufEnd && dst > gpBufStart) { while (width) { *dst = tbl[*pRLEBytes]; + StepRender(); pRLEBytes++; dst++; width--; @@ -413,6 +430,7 @@ void CelBlitWidth(BYTE *pBuff, int x, int y, int wdt, BYTE *pCelBuff, int nCel, if (!(width & 0x80)) { i -= width; memcpy(dst, pRLEBytes, width); + StepRender(); dst += width; pRLEBytes += width; } else { @@ -447,8 +465,11 @@ void CelBlitOutline(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int nWid while (width) { if (*src++) { dst[-BUFFER_WIDTH] = col; + StepRender(); dst[-1] = col; + StepRender(); dst[1] = col; + StepRender(); } dst++; width--; @@ -457,9 +478,13 @@ void CelBlitOutline(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int nWid while (width) { if (*src++) { dst[-BUFFER_WIDTH] = col; + StepRender(); dst[-1] = col; + StepRender(); dst[1] = col; + StepRender(); dst[BUFFER_WIDTH] = col; + StepRender(); } dst++; width--; @@ -489,8 +514,10 @@ void ENG_set_pixel(int sx, int sy, BYTE col) dst = &gpBuffer[sx + BUFFER_WIDTH * sy]; - if (dst < gpBufEnd && dst > gpBufStart) + if (dst < gpBufEnd && dst > gpBufStart) { *dst = col; + StepRender(); + } } void engine_draw_pixel(int sx, int sy) @@ -509,8 +536,10 @@ void engine_draw_pixel(int sx, int sy) dst = &gpBuffer[sx + BUFFER_WIDTH * sy]; } - if (dst < gpBufEnd && dst > gpBufStart) + if (dst < gpBufEnd && dst > gpBufStart) { *dst = gbPixelCol; + StepRender(); + } } // Exact copy from https://github.com/erich666/GraphicsGems/blob/dad26f941e12c8bf1f96ea21c1c04cd2206ae7c9/gems/DoubleLine.c @@ -883,12 +912,14 @@ void Cl2ApplyTrans(BYTE *p, BYTE *ttbl, int nCel) nDataSize--; assert(nDataSize >= 0); *dst = ttbl[*dst]; + StepRender(); dst++; } else { nDataSize -= width; assert(nDataSize >= 0); while (width) { *dst = ttbl[*dst]; + StepRender(); dst++; width--; } @@ -940,6 +971,7 @@ void Cl2BlitSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) w -= width; while (width) { *dst = fill; + StepRender(); dst++; width--; } @@ -955,6 +987,7 @@ void Cl2BlitSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) w -= width; while (width) { *dst = *src; + StepRender(); src++; dst++; width--; @@ -1029,10 +1062,14 @@ void Cl2BlitOutlineSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWi if (*src++ && dst < gpBufEnd && dst > gpBufStart) { w -= width; dst[-1] = col; + StepRender(); dst[width] = col; + StepRender(); while (width) { dst[-BUFFER_WIDTH] = col; + StepRender(); dst[BUFFER_WIDTH] = col; + StepRender(); dst++; width--; } @@ -1049,9 +1086,13 @@ void Cl2BlitOutlineSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWi while (width) { if (*src++) { dst[-1] = col; + StepRender(); dst[1] = col; + StepRender(); dst[-BUFFER_WIDTH] = col; + StepRender(); dst[BUFFER_WIDTH] = col; + StepRender(); } dst++; width--; @@ -1135,6 +1176,7 @@ void Cl2BlitLightSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidt w -= width; while (width) { *dst = fill; + StepRender(); dst++; width--; } @@ -1150,6 +1192,7 @@ void Cl2BlitLightSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidt w -= width; while (width) { *dst = pTable[*src]; + StepRender(); src++; dst++; width--; diff --git a/Source/palette.cpp b/Source/palette.cpp index 3de01e349..dd640d598 100644 --- a/Source/palette.cpp +++ b/Source/palette.cpp @@ -185,9 +185,9 @@ void PaletteFadeIn(int fr) ApplyGamma(logical_palette, orig_palette, 256); DWORD tc = SDL_GetTicks(); - for (i = 0; i < 256; i = (SDL_GetTicks() - tc) / 2.083) { // 32 frames @ 60hz - SetFadeLevel(i); - } + //for (i = 0; i < 256; i = (SDL_GetTicks() - tc) / 2.083) { // 32 frames @ 60hz + // SetFadeLevel(i); + //} SetFadeLevel(256); memcpy(logical_palette, orig_palette, sizeof(orig_palette)); sgbFadedIn = TRUE; @@ -198,11 +198,12 @@ void PaletteFadeOut(int fr) int i; if (sgbFadedIn) { - DWORD tc = SDL_GetTicks(); - for (i = 256; i > 0; i = 256 - (SDL_GetTicks() - tc) / 2.083) { // 32 frames @ 60hz - SetFadeLevel(i); - } - SetFadeLevel(0); + //DWORD tc = SDL_GetTicks(); + //for (i = 256; i > 0; i = 256 - (SDL_GetTicks() - tc) / 2.083) { // 32 frames @ 60hz + // SetFadeLevel(i); + //} + ApplyGamma(logical_palette, orig_palette, 256); + SetFadeLevel(256); sgbFadedIn = FALSE; } } diff --git a/Source/render.cpp b/Source/render.cpp index 14b1f0fae..ee2c8ae7e 100644 --- a/Source/render.cpp +++ b/Source/render.cpp @@ -104,15 +104,18 @@ inline static void RenderLine(BYTE **dst, BYTE **src, int n, BYTE *tbl, DWORD ma if (mask == 0xFFFFFFFF) { if (light_table_index == lightmax) { memset(*dst, 0, n); + StepRender(); (*src) += n; (*dst) += n; } else if (light_table_index == 0) { memcpy(*dst, *src, n); + StepRender(); (*src) += n; (*dst) += n; } else { for (i = 0; i < n; i++, (*src)++, (*dst)++) { (*dst)[0] = tbl[(*src)[0]]; + StepRender(); } } } else { @@ -121,18 +124,21 @@ inline static void RenderLine(BYTE **dst, BYTE **src, int n, BYTE *tbl, DWORD ma for (i = 0; i < n; i++, (*dst)++, mask <<= 1) { if (mask & 0x80000000) { (*dst)[0] = 0; + StepRender(); } } } else if (light_table_index == 0) { for (i = 0; i < n; i++, (*src)++, (*dst)++, mask <<= 1) { if (mask & 0x80000000) { (*dst)[0] = (*src)[0]; + StepRender(); } } } else { for (i = 0; i < n; i++, (*src)++, (*dst)++, mask <<= 1) { if (mask & 0x80000000) { (*dst)[0] = tbl[(*src)[0]]; + StepRender(); } } } @@ -266,10 +272,12 @@ void world_draw_black_tile(int sx, int sy) for (i = 30, j = 1; i >= 0; i -= 2, j++, dst -= BUFFER_WIDTH + 2) { memset(dst, 0, 4 * j); + StepRender(); } dst += 4; for (i = 2, j = 15; i != 32; i += 2, j--, dst -= BUFFER_WIDTH - 2) { memset(dst, 0, 4 * j); + StepRender(); } } @@ -283,8 +291,11 @@ void trans_rect(int sx, int sy, int width, int height) BYTE *pix = &gpBuffer[SCREENXY(sx, sy)]; for (row = 0; row < height; row++) { for (col = 0; col < width; col++) { - if ((row & 1 && col & 1) || (!(row & 1) && !(col & 1))) + if ((row & 1 && col & 1) || (!(row & 1) && !(col & 1))) { *pix = 0; + + StepRender(); + } pix++; } pix += BUFFER_WIDTH - width; diff --git a/Source/scrollrt.cpp b/Source/scrollrt.cpp index 7df9f370a..09b7c537d 100644 --- a/Source/scrollrt.cpp +++ b/Source/scrollrt.cpp @@ -1089,6 +1089,15 @@ static void DoBlitScreen(DWORD dwX, DWORD dwY, DWORD dwWdt, DWORD dwHgt) BltFast(dwX, dwY, &SrcRect); } +void StepRender() +{ + if (!debugRender) + return; + + DoBlitScreen(0, 0, 640, 480); + RenderPresent(); +} + /** * @brief Check render pipline and blit indivudal screen parts * @param dwHgt Section of screen to update from top to bottom @@ -1184,6 +1193,8 @@ void DrawAndBlit() if (!gbRunGame) { return; } + force_redraw = 255; + memset(&gpBuffer[SCREEN_Y * BUFFER_WIDTH], 0, BUFFER_WIDTH * 480); if (SCREEN_WIDTH > PANEL_WIDTH || SCREEN_HEIGHT > VIEWPORT_HEIGHT + PANEL_HEIGHT || force_redraw == 255) { drawhpflag = TRUE; diff --git a/Source/scrollrt.h b/Source/scrollrt.h index e3fd649ce..776637977 100644 --- a/Source/scrollrt.h +++ b/Source/scrollrt.h @@ -21,6 +21,7 @@ void ClearScreenBuffer(); void ScrollView(); #endif void EnableFrameCount(); +void StepRender(); void scrollrt_draw_game_screen(BOOL draw_cursor); void DrawAndBlit(); diff --git a/SourceX/dx.cpp b/SourceX/dx.cpp index deb8e29fc..1e0847584 100644 --- a/SourceX/dx.cpp +++ b/SourceX/dx.cpp @@ -248,7 +248,7 @@ void RenderPresent() if (SDL_UpdateWindowSurface(window) <= -1) { ErrSdl(); } - LimitFrameRate(); + //LimitFrameRate(); } #else if (SDL_Flip(surface) <= -1) { diff --git a/SourceX/miniwin/misc.cpp b/SourceX/miniwin/misc.cpp index 1bc891f87..7bb8cc920 100644 --- a/SourceX/miniwin/misc.cpp +++ b/SourceX/miniwin/misc.cpp @@ -88,10 +88,11 @@ bool SpawnWindow(LPCSTR lpWindowName, int nWidth, int nHeight) InitController(); #endif - int upscale = 1; - DvlIntSetting("upscale", &upscale); - if (fullscreen) + int upscale = 0; + //DvlIntSetting("upscale", &upscale); + if (fullscreen = 0) DvlIntSetting("fullscreen", (int *)&fullscreen); + fullscreen = 0; int grabInput = 1; DvlIntSetting("grab input", &grabInput);