- 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.
This commit is contained in:
Christoph Oelckers 2016-03-24 11:30:11 +01:00
parent eac0bfeaeb
commit c83ad9df6c
7 changed files with 79 additions and 72 deletions

View file

@ -1,16 +1,6 @@
#ifndef __BASICTYPES_H #ifndef __BASICTYPES_H
#define __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 <stdint.h> #include <stdint.h>
typedef int8_t SBYTE; typedef int8_t SBYTE;
@ -21,7 +11,6 @@ typedef int32_t SDWORD;
typedef uint32_t uint32; typedef uint32_t uint32;
typedef int64_t SQWORD; typedef int64_t SQWORD;
typedef uint64_t QWORD; typedef uint64_t QWORD;
#endif
typedef SDWORD int32; typedef SDWORD int32;
typedef float real32; typedef float real32;

View file

@ -37,7 +37,7 @@
#include <stddef.h> #include <stddef.h>
#if !defined(_WIN32) #if !defined(_WIN32)
#include <inttypes.h> // for intptr_t #include <inttypes.h> // for intptr_t
#elif !defined(_MSC_VER) #else
#include <stdint.h> // for mingw #include <stdint.h> // for mingw
#endif #endif

View file

@ -78,7 +78,7 @@ FButtonStatus MenuButtons[NUM_MKEYS];
int MenuButtonTickers[NUM_MKEYS]; int MenuButtonTickers[NUM_MKEYS];
bool MenuButtonOrigin[NUM_MKEYS]; bool MenuButtonOrigin[NUM_MKEYS];
int BackbuttonTime; int BackbuttonTime;
fixed_t BackbuttonAlpha; float BackbuttonAlpha;
static bool MenuEnabled = true; static bool MenuEnabled = true;
@ -274,7 +274,7 @@ void DMenu::Drawer ()
} }
else 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 (BackbuttonTime > 0)
{ {
if (BackbuttonAlpha < OPAQUE) BackbuttonAlpha += OPAQUE/10; if (BackbuttonAlpha < 1.f) BackbuttonAlpha += .1f;
if (BackbuttonAlpha > 1.f) BackbuttonAlpha = 1.f;
BackbuttonTime--; BackbuttonTime--;
} }
else else
{ {
if (BackbuttonAlpha > 0) BackbuttonAlpha -= OPAQUE/10; if (BackbuttonAlpha > 0) BackbuttonAlpha -= .1f;
if (BackbuttonAlpha < 0) BackbuttonAlpha = 0; if (BackbuttonAlpha < 0) BackbuttonAlpha = 0;
} }
} }

View file

@ -35,8 +35,6 @@
#include "doomtype.h" #include "doomtype.h"
#include "doomstat.h" #include "doomstat.h"
#include "d_player.h" #include "d_player.h"
#include "tables.h"
#include "m_fixed.h"
#include "templates.h" #include "templates.h"
#include "menu/menu.h" #include "menu/menu.h"
#include "colormatcher.h" #include "colormatcher.h"
@ -59,6 +57,22 @@
struct FBackdropTexture : public FTexture 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: public:
FBackdropTexture(); FBackdropTexture();
@ -68,12 +82,13 @@ public:
bool CheckModified(); bool CheckModified();
protected: protected:
uint32_t costab[COS_SIZE];
BYTE Pixels[144*160]; BYTE Pixels[144*160];
static const Span DummySpan[2]; static const Span DummySpan[2];
int LastRenderTic; int LastRenderTic;
angle_t time1, time2, time3, time4; uint32_t time1, time2, time3, time4;
angle_t t1ang, t2ang, z1ang, z2ang; uint32_t t1ang, t2ang, z1ang, z2ang;
void Render(); void Render();
}; };
@ -171,14 +186,19 @@ FBackdropTexture::FBackdropTexture()
WidthMask = 255; WidthMask = 255;
LastRenderTic = 0; LastRenderTic = 0;
time1 = ANGLE_1*180; for (int i = 0; i < COS_SIZE; ++i)
time2 = ANGLE_1*56; {
time3 = ANGLE_1*99; costab[i] = uint32_t(cos(i * (M_PI / (COS_SIZE / 2))) * 65536);
time4 = ANGLE_1*1; }
t1ang = ANGLE_90;
time1 = DEGREES(180);
time2 = DEGREES(56);
time3 = DEGREES(99);
time4 = DEGREES(1);
t1ang = DEGREES(90);
t2ang = 0; t2ang = 0;
z1ang = 0; z1ang = 0;
z2ang = ANGLE_90/2; z2ang = DEGREES(45);
} }
//============================================================================= //=============================================================================
@ -248,22 +268,23 @@ void FBackdropTexture::Render()
int x, y; int x, y;
const angle_t a1add = ANGLE_1/2; const DWORD a1add = DEGREES(0.5);
const angle_t a2add = ANGLE_MAX-ANGLE_1; const DWORD a2add = DEGREES(359);
const angle_t a3add = ANGLE_1*5/7; const DWORD a3add = DEGREES(5 / 7.f);
const angle_t a4add = ANGLE_MAX-ANGLE_1*4/3; const DWORD a4add = DEGREES(358.66666);
const angle_t t1add = ANGLE_MAX-ANGLE_1*2; const DWORD t1add = DEGREES(358);
const angle_t t2add = ANGLE_MAX-ANGLE_1*3+ANGLE_1/6; const DWORD t2add = DEGREES(357.16666);
const angle_t t3add = ANGLE_1*16/7; const DWORD t3add = DEGREES(2.285);
const angle_t t4add = ANGLE_MAX-ANGLE_1*2/3; const DWORD t4add = DEGREES(359.33333);
const angle_t x1add = 5<<ANGLETOFINESHIFT; const DWORD x1add = 5 * 524288;
const angle_t x2add = ANGLE_MAX-(13<<ANGLETOFINESHIFT); const DWORD x2add = 0u - 13 * 524288;
const angle_t z1add = 3<<ANGLETOFINESHIFT; const DWORD z1add = 3 * 524288;
const angle_t z2add = 4<<ANGLETOFINESHIFT; const DWORD z2add = 4 * 524288;
angle_t a1, a2, a3, a4;
fixed_t c1, c2, c3, c4; DWORD a1, a2, a3, a4;
SDWORD c1, c2, c3, c4;
DWORD tx, ty, tc, ts; DWORD tx, ty, tc, ts;
DWORD ux, uy, uc, us; DWORD ux, uy, uc, us;
DWORD ltx, lty, lux, luy; DWORD ltx, lty, lux, luy;
@ -273,36 +294,36 @@ void FBackdropTexture::Render()
a3 = time3; a3 = time3;
a4 = time4; a4 = time4;
fixed_t z1 = (finecosine[z2ang>>ANGLETOFINESHIFT]>>2)+FRACUNIT/2; double z1 = (cos(TORAD(z2ang)) / 4 + 0.5) * (0x8000000);
fixed_t z2 = (finecosine[z1ang>>ANGLETOFINESHIFT]>>2)+FRACUNIT*3/4; double z2 = (cos(TORAD(z1ang)) / 4 + 0.75) * (0x8000000);
tc = MulScale5 (finecosine[t1ang>>ANGLETOFINESHIFT], z1); tc = SDWORD(cos(TORAD(t1ang)) * z1);
ts = MulScale5 (finesine[t1ang>>ANGLETOFINESHIFT], z1); ts = SDWORD(sin(TORAD(t1ang)) * z1);
uc = MulScale5 (finecosine[t2ang>>ANGLETOFINESHIFT], z2); uc = SDWORD(cos(TORAD(t2ang)) * z2);
us = MulScale5 (finesine[t2ang>>ANGLETOFINESHIFT], z2); us = SDWORD(sin(TORAD(t2ang)) * z2);
ltx = -width/2*tc; ltx = -width / 2 * tc;
lty = -width/2*ts; lty = -width / 2 * ts;
lux = -width/2*uc; lux = -width / 2 * uc;
luy = -width/2*us; luy = -width / 2 * us;
for (y = 0; y < height; ++y) for (y = 0; y < height; ++y)
{ {
a1 = time1; a1 = time1;
a2 = time2; a2 = time2;
c3 = finecosine[a3>>ANGLETOFINESHIFT]; c3 = SDWORD(cos(TORAD(a3)) * 65536.0);
c4 = finecosine[a4>>ANGLETOFINESHIFT]; c4 = SDWORD(cos(TORAD(a4)) * 65536.0);
tx = ltx - (y-height/2)*ts; tx = ltx - (y - height / 2)*ts;
ty = lty + (y-height/2)*tc; ty = lty + (y - height / 2)*tc;
ux = lux - (y-height/2)*us; ux = lux - (y - height / 2)*us;
uy = luy + (y-height/2)*uc; uy = luy + (y - height / 2)*uc;
for (x = 0; x < width; ++x) for (x = 0; x < width; ++x)
{ {
c1 = finecosine[a1>>ANGLETOFINESHIFT]; c1 = costab[a1 >> ANGLESHIFT];
c2 = finecosine[a2>>ANGLETOFINESHIFT]; c2 = costab[a2 >> ANGLESHIFT];
from[x] = ((c1 + c2 + c3 + c4) >> (FRACBITS+3-7)) + 128 // plasma from[x] = ((c1 + c2 + c3 + c4) >> (16 + 3 - 7)) + 128 // plasma
+ pattern1[(tx>>27)+((ty>>22)&992)] // rotozoomer 1 + pattern1[(tx >> 27) + ((ty >> 22) & 992)] // rotozoomer 1
+ pattern2[(ux>>27)+((uy>>22)&992)]; // rotozoomer 2 + pattern2[(ux >> 27) + ((uy >> 22) & 992)]; // rotozoomer 2
tx += tc; tx += tc;
ty += ts; ty += ts;
ux += uc; ux += uc;

View file

@ -79,7 +79,7 @@ DReadThisMenu::DReadThisMenu(DMenu *parent)
void DReadThisMenu::Drawer() void DReadThisMenu::Drawer()
{ {
FTexture *tex = NULL, *prevpic = NULL; FTexture *tex = NULL, *prevpic = NULL;
fixed_t alpha; double alpha;
// Did the mapper choose a custom help page via MAPINFO? // Did the mapper choose a custom help page via MAPINFO?
if ((level.info != NULL) && level.info->F1Pic.Len() != 0) 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); screen->Dim(0, 1.0, 0,0, SCREENWIDTH, SCREENHEIGHT);
alpha = MIN<fixed_t> (Scale (gametic - mInfoTic, OPAQUE, TICRATE/3), OPAQUE); alpha = MIN((gametic - mInfoTic) * (3. / TICRATE), 1.);
if (alpha < OPAQUE && prevpic != NULL) if (alpha < 1. && prevpic != NULL)
{ {
screen->DrawTexture (prevpic, 0, 0, DTA_Fullscreen, true, TAG_DONE); 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);
} }

View file

@ -42,7 +42,7 @@
#if !defined(_WIN32) #if !defined(_WIN32)
#include <inttypes.h> // for intptr_t #include <inttypes.h> // for intptr_t
#elif !defined(_MSC_VER) #else
#include <stdint.h> // for mingw #include <stdint.h> // for mingw
#endif #endif

View file

@ -92,12 +92,8 @@
#include "zstring.h" #include "zstring.h"
#include "gdtoa.h" #include "gdtoa.h"
#ifndef _MSC_VER
#include <stdint.h> #include <stdint.h>
#else
typedef unsigned __int64 uint64_t;
typedef signed __int64 int64_t;
#endif
/* /*
* MAXEXPDIG is the maximum number of decimal digits needed to store a * MAXEXPDIG is the maximum number of decimal digits needed to store a