From c83ad9df6cd44bad3755be17a3c8626782119ac1 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 24 Mar 2016 11:30:11 +0100 Subject: [PATCH] - removed special treatment for not using stdint.h with MSVC. Current compiler versions have this file. - removed use of finesine for creating the player backdrop for the menu display. This mostly uses the code from the old 2.0 floating point version but fixes some of the constants in there which were not correct. --- src/basictypes.h | 11 ---- src/info.h | 2 +- src/menu/menu.cpp | 9 +-- src/menu/playerdisplay.cpp | 113 ++++++++++++++++++++++--------------- src/menu/readthis.cpp | 8 +-- src/tarray.h | 2 +- src/zstrformat.cpp | 6 +- 7 files changed, 79 insertions(+), 72 deletions(-) diff --git a/src/basictypes.h b/src/basictypes.h index 6c71fce9b..13be07b9f 100644 --- a/src/basictypes.h +++ b/src/basictypes.h @@ -1,16 +1,6 @@ #ifndef __BASICTYPES_H #define __BASICTYPES_H -#ifdef _MSC_VER -typedef __int8 SBYTE; -typedef unsigned __int8 BYTE; -typedef __int16 SWORD; -typedef unsigned __int16 WORD; -typedef __int32 SDWORD; -typedef unsigned __int32 uint32; -typedef __int64 SQWORD; -typedef unsigned __int64 QWORD; -#else #include typedef int8_t SBYTE; @@ -21,7 +11,6 @@ typedef int32_t SDWORD; typedef uint32_t uint32; typedef int64_t SQWORD; typedef uint64_t QWORD; -#endif typedef SDWORD int32; typedef float real32; diff --git a/src/info.h b/src/info.h index d6b3f5cf1..f0a08048c 100644 --- a/src/info.h +++ b/src/info.h @@ -37,7 +37,7 @@ #include #if !defined(_WIN32) #include // for intptr_t -#elif !defined(_MSC_VER) +#else #include // for mingw #endif diff --git a/src/menu/menu.cpp b/src/menu/menu.cpp index 081a6e446..fb0ea80d7 100644 --- a/src/menu/menu.cpp +++ b/src/menu/menu.cpp @@ -78,7 +78,7 @@ FButtonStatus MenuButtons[NUM_MKEYS]; int MenuButtonTickers[NUM_MKEYS]; bool MenuButtonOrigin[NUM_MKEYS]; int BackbuttonTime; -fixed_t BackbuttonAlpha; +float BackbuttonAlpha; static bool MenuEnabled = true; @@ -274,7 +274,7 @@ void DMenu::Drawer () } else { - screen->DrawTexture(tex, x, y, DTA_CleanNoMove, true, DTA_Alpha, BackbuttonAlpha, TAG_DONE); + screen->DrawTexture(tex, x, y, DTA_CleanNoMove, true, DTA_AlphaF, BackbuttonAlpha, TAG_DONE); } } } @@ -680,12 +680,13 @@ void M_Ticker (void) } if (BackbuttonTime > 0) { - if (BackbuttonAlpha < OPAQUE) BackbuttonAlpha += OPAQUE/10; + if (BackbuttonAlpha < 1.f) BackbuttonAlpha += .1f; + if (BackbuttonAlpha > 1.f) BackbuttonAlpha = 1.f; BackbuttonTime--; } else { - if (BackbuttonAlpha > 0) BackbuttonAlpha -= OPAQUE/10; + if (BackbuttonAlpha > 0) BackbuttonAlpha -= .1f; if (BackbuttonAlpha < 0) BackbuttonAlpha = 0; } } diff --git a/src/menu/playerdisplay.cpp b/src/menu/playerdisplay.cpp index 5caf3ce42..c3d11a43a 100644 --- a/src/menu/playerdisplay.cpp +++ b/src/menu/playerdisplay.cpp @@ -35,8 +35,6 @@ #include "doomtype.h" #include "doomstat.h" #include "d_player.h" -#include "tables.h" -#include "m_fixed.h" #include "templates.h" #include "menu/menu.h" #include "colormatcher.h" @@ -59,6 +57,22 @@ struct FBackdropTexture : public FTexture { + enum + { + COS_SIZE = 256, + ANGLESHIFT = 24 + }; + + static constexpr uint32_t DEGREES(double v) + { + return uint32_t((v)*(0x40000000 / 90.0)); + } + + static double TORAD(uint32_t x) + { + return x*(M_PI / 0x80000000); + } + public: FBackdropTexture(); @@ -68,12 +82,13 @@ public: bool CheckModified(); protected: + uint32_t costab[COS_SIZE]; BYTE Pixels[144*160]; static const Span DummySpan[2]; int LastRenderTic; - angle_t time1, time2, time3, time4; - angle_t t1ang, t2ang, z1ang, z2ang; + uint32_t time1, time2, time3, time4; + uint32_t t1ang, t2ang, z1ang, z2ang; void Render(); }; @@ -171,14 +186,19 @@ FBackdropTexture::FBackdropTexture() WidthMask = 255; LastRenderTic = 0; - time1 = ANGLE_1*180; - time2 = ANGLE_1*56; - time3 = ANGLE_1*99; - time4 = ANGLE_1*1; - t1ang = ANGLE_90; + for (int i = 0; i < COS_SIZE; ++i) + { + costab[i] = uint32_t(cos(i * (M_PI / (COS_SIZE / 2))) * 65536); + } + + time1 = DEGREES(180); + time2 = DEGREES(56); + time3 = DEGREES(99); + time4 = DEGREES(1); + t1ang = DEGREES(90); t2ang = 0; z1ang = 0; - z2ang = ANGLE_90/2; + z2ang = DEGREES(45); } //============================================================================= @@ -248,22 +268,23 @@ void FBackdropTexture::Render() int x, y; - const angle_t a1add = ANGLE_1/2; - const angle_t a2add = ANGLE_MAX-ANGLE_1; - const angle_t a3add = ANGLE_1*5/7; - const angle_t a4add = ANGLE_MAX-ANGLE_1*4/3; + const DWORD a1add = DEGREES(0.5); + const DWORD a2add = DEGREES(359); + const DWORD a3add = DEGREES(5 / 7.f); + const DWORD a4add = DEGREES(358.66666); - const angle_t t1add = ANGLE_MAX-ANGLE_1*2; - const angle_t t2add = ANGLE_MAX-ANGLE_1*3+ANGLE_1/6; - const angle_t t3add = ANGLE_1*16/7; - const angle_t t4add = ANGLE_MAX-ANGLE_1*2/3; - const angle_t x1add = 5<>ANGLETOFINESHIFT]>>2)+FRACUNIT/2; - fixed_t z2 = (finecosine[z1ang>>ANGLETOFINESHIFT]>>2)+FRACUNIT*3/4; + double z1 = (cos(TORAD(z2ang)) / 4 + 0.5) * (0x8000000); + double z2 = (cos(TORAD(z1ang)) / 4 + 0.75) * (0x8000000); - tc = MulScale5 (finecosine[t1ang>>ANGLETOFINESHIFT], z1); - ts = MulScale5 (finesine[t1ang>>ANGLETOFINESHIFT], z1); - uc = MulScale5 (finecosine[t2ang>>ANGLETOFINESHIFT], z2); - us = MulScale5 (finesine[t2ang>>ANGLETOFINESHIFT], z2); - - ltx = -width/2*tc; - lty = -width/2*ts; - lux = -width/2*uc; - luy = -width/2*us; + tc = SDWORD(cos(TORAD(t1ang)) * z1); + ts = SDWORD(sin(TORAD(t1ang)) * z1); + uc = SDWORD(cos(TORAD(t2ang)) * z2); + us = SDWORD(sin(TORAD(t2ang)) * z2); + + ltx = -width / 2 * tc; + lty = -width / 2 * ts; + lux = -width / 2 * uc; + luy = -width / 2 * us; for (y = 0; y < height; ++y) { a1 = time1; a2 = time2; - c3 = finecosine[a3>>ANGLETOFINESHIFT]; - c4 = finecosine[a4>>ANGLETOFINESHIFT]; - tx = ltx - (y-height/2)*ts; - ty = lty + (y-height/2)*tc; - ux = lux - (y-height/2)*us; - uy = luy + (y-height/2)*uc; + c3 = SDWORD(cos(TORAD(a3)) * 65536.0); + c4 = SDWORD(cos(TORAD(a4)) * 65536.0); + tx = ltx - (y - height / 2)*ts; + ty = lty + (y - height / 2)*tc; + ux = lux - (y - height / 2)*us; + uy = luy + (y - height / 2)*uc; for (x = 0; x < width; ++x) { - c1 = finecosine[a1>>ANGLETOFINESHIFT]; - c2 = finecosine[a2>>ANGLETOFINESHIFT]; - from[x] = ((c1 + c2 + c3 + c4) >> (FRACBITS+3-7)) + 128 // plasma - + pattern1[(tx>>27)+((ty>>22)&992)] // rotozoomer 1 - + pattern2[(ux>>27)+((uy>>22)&992)]; // rotozoomer 2 + c1 = costab[a1 >> ANGLESHIFT]; + c2 = costab[a2 >> ANGLESHIFT]; + from[x] = ((c1 + c2 + c3 + c4) >> (16 + 3 - 7)) + 128 // plasma + + pattern1[(tx >> 27) + ((ty >> 22) & 992)] // rotozoomer 1 + + pattern2[(ux >> 27) + ((uy >> 22) & 992)]; // rotozoomer 2 tx += tc; ty += ts; ux += uc; diff --git a/src/menu/readthis.cpp b/src/menu/readthis.cpp index 82b20bf00..0aa3c2fcd 100644 --- a/src/menu/readthis.cpp +++ b/src/menu/readthis.cpp @@ -79,7 +79,7 @@ DReadThisMenu::DReadThisMenu(DMenu *parent) void DReadThisMenu::Drawer() { FTexture *tex = NULL, *prevpic = NULL; - fixed_t alpha; + double alpha; // Did the mapper choose a custom help page via MAPINFO? if ((level.info != NULL) && level.info->F1Pic.Len() != 0) @@ -99,12 +99,12 @@ void DReadThisMenu::Drawer() } screen->Dim(0, 1.0, 0,0, SCREENWIDTH, SCREENHEIGHT); - alpha = MIN (Scale (gametic - mInfoTic, OPAQUE, TICRATE/3), OPAQUE); - if (alpha < OPAQUE && prevpic != NULL) + alpha = MIN((gametic - mInfoTic) * (3. / TICRATE), 1.); + if (alpha < 1. && prevpic != NULL) { screen->DrawTexture (prevpic, 0, 0, DTA_Fullscreen, true, TAG_DONE); } - screen->DrawTexture (tex, 0, 0, DTA_Fullscreen, true, DTA_Alpha, alpha, TAG_DONE); + screen->DrawTexture (tex, 0, 0, DTA_Fullscreen, true, DTA_AlphaF, alpha, TAG_DONE); } diff --git a/src/tarray.h b/src/tarray.h index 7b9d5970b..8f370fcb9 100644 --- a/src/tarray.h +++ b/src/tarray.h @@ -42,7 +42,7 @@ #if !defined(_WIN32) #include // for intptr_t -#elif !defined(_MSC_VER) +#else #include // for mingw #endif diff --git a/src/zstrformat.cpp b/src/zstrformat.cpp index 63c179ca6..65ed889ae 100644 --- a/src/zstrformat.cpp +++ b/src/zstrformat.cpp @@ -92,12 +92,8 @@ #include "zstring.h" #include "gdtoa.h" -#ifndef _MSC_VER #include -#else -typedef unsigned __int64 uint64_t; -typedef signed __int64 int64_t; -#endif + /* * MAXEXPDIG is the maximum number of decimal digits needed to store a