From c3f26422df1cd7fc7e3a1d69abd0bd105a7bc2ad Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 25 Sep 2019 21:47:33 +0200 Subject: [PATCH] - changed MIDI sources so that they do not have to include i_musicinterns.h anymore. They were already clean of unwanted external references, but including this file made it hard to keep it that way. This also moves a few useful definitions around to less 'dirty' headers. --- src/doomdef.h | 8 ----- src/doomtype.h | 5 --- .../swrenderer/textures/warptexture.cpp | 8 ++--- src/sound/midisources/midisource.cpp | 2 +- src/sound/midisources/midisource.h | 4 +++ src/sound/midisources/midisource_hmi.cpp | 3 +- src/sound/midisources/midisource_mus.cpp | 2 +- src/sound/midisources/midisource_smf.cpp | 2 +- src/sound/midisources/midisource_xmi.cpp | 5 +-- src/sound/music/i_musicinterns.h | 28 ----------------- src/sound/music/mididefs.h | 31 +++++++++++++++++++ src/utility/basictypes.h | 13 ++++++++ src/win32/i_crash.cpp | 6 ---- 13 files changed, 60 insertions(+), 57 deletions(-) create mode 100644 src/sound/music/mididefs.h diff --git a/src/doomdef.h b/src/doomdef.h index 08d2b59361..30e24add19 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -372,12 +372,4 @@ enum #define BLINKTHRESHOLD (4*32) -#ifndef MAKE_ID -#ifndef __BIG_ENDIAN__ -#define MAKE_ID(a,b,c,d) ((uint32_t)((a)|((b)<<8)|((c)<<16)|((d)<<24))) -#else -#define MAKE_ID(a,b,c,d) ((uint32_t)((d)|((c)<<8)|((b)<<16)|((a)<<24))) -#endif -#endif - #endif // __DOOMDEF_H__ diff --git a/src/doomtype.h b/src/doomtype.h index bc5e25da5b..ce644f7374 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -232,11 +232,6 @@ inline float RAD2DEG(float deg) } -template -char ( &_ArraySizeHelper( T (&array)[N] ))[N]; - -#define countof( array ) (sizeof( _ArraySizeHelper( array ) )) - // Auto-registration sections for GCC. // Apparently, you cannot do string concatenation inside section attributes. #ifdef __MACH__ diff --git a/src/rendering/swrenderer/textures/warptexture.cpp b/src/rendering/swrenderer/textures/warptexture.cpp index 3e38c9b9f5..afc48bc4ad 100644 --- a/src/rendering/swrenderer/textures/warptexture.cpp +++ b/src/rendering/swrenderer/textures/warptexture.cpp @@ -67,8 +67,8 @@ const uint32_t *FWarpTexture::GetPixelsBgra() resizeMult = 1; auto otherpix = FSoftwareTexture::GetPixelsBgra(); - WarpedPixelsRgba.Resize(GetWidth() * GetHeight() * resizeMult * resizeMult * 4 / 3 + 1); - WarpBuffer(WarpedPixelsRgba.Data(), otherpix, GetWidth() * resizeMult, GetHeight() * resizeMult, WidthOffsetMultiplier, HeightOffsetMultiplier, time, mTexture->shaderspeed, bWarped); + WarpedPixelsRgba.Resize(unsigned(GetWidth() * GetHeight() * resizeMult * resizeMult * 4 / 3 + 1)); + WarpBuffer(WarpedPixelsRgba.Data(), otherpix, int(GetWidth() * resizeMult), int(GetHeight() * resizeMult), WidthOffsetMultiplier, HeightOffsetMultiplier, time, mTexture->shaderspeed, bWarped); GenerateBgraMipmapsFast(); FreeAllSpans(); GenTime[2] = time; @@ -88,8 +88,8 @@ const uint8_t *FWarpTexture::GetPixels(int index) resizeMult = 1; const uint8_t *otherpix = FSoftwareTexture::GetPixels(index); - WarpedPixels[index].Resize(GetWidth() * GetHeight() * resizeMult * resizeMult); - WarpBuffer(WarpedPixels[index].Data(), otherpix, GetWidth() * resizeMult, GetHeight() * resizeMult, WidthOffsetMultiplier, HeightOffsetMultiplier, time, mTexture->shaderspeed, bWarped); + WarpedPixels[index].Resize(unsigned(GetWidth() * GetHeight() * resizeMult * resizeMult)); + WarpBuffer(WarpedPixels[index].Data(), otherpix, int(GetWidth() * resizeMult), int(GetHeight() * resizeMult), WidthOffsetMultiplier, HeightOffsetMultiplier, time, mTexture->shaderspeed, bWarped); FreeAllSpans(); GenTime[index] = time; } diff --git a/src/sound/midisources/midisource.cpp b/src/sound/midisources/midisource.cpp index a8e9921414..1609541e09 100644 --- a/src/sound/midisources/midisource.cpp +++ b/src/sound/midisources/midisource.cpp @@ -34,7 +34,7 @@ */ -#include "i_musicinterns.h" +#include "midisource.h" char MIDI_EventLengths[7] = { 2, 2, 2, 2, 1, 1, 2 }; diff --git a/src/sound/midisources/midisource.h b/src/sound/midisources/midisource.h index 01c0c28085..13eb6ade94 100644 --- a/src/sound/midisources/midisource.h +++ b/src/sound/midisources/midisource.h @@ -10,10 +10,14 @@ #include #include +#include "files.h" +#include "mus2midi.h" +#include "mididefs.h" extern char MIDI_EventLengths[7]; extern char MIDI_CommonLengths[15]; + // base class for the different MIDI sources -------------------------------------- class MIDISource diff --git a/src/sound/midisources/midisource_hmi.cpp b/src/sound/midisources/midisource_hmi.cpp index f0c4a3fb81..7543f04bf3 100644 --- a/src/sound/midisources/midisource_hmi.cpp +++ b/src/sound/midisources/midisource_hmi.cpp @@ -34,7 +34,8 @@ // HEADER FILES ------------------------------------------------------------ -#include "i_musicinterns.h" +#include "midisource.h" +#include "basictypes.h" #include "templates.h" // MACROS ------------------------------------------------------------------ diff --git a/src/sound/midisources/midisource_mus.cpp b/src/sound/midisources/midisource_mus.cpp index b41b9a23f2..c016d1ec76 100644 --- a/src/sound/midisources/midisource_mus.cpp +++ b/src/sound/midisources/midisource_mus.cpp @@ -33,7 +33,7 @@ // HEADER FILES ------------------------------------------------------------ -#include "i_musicinterns.h" +#include "midisource.h" #include "templates.h" // MACROS ------------------------------------------------------------------ diff --git a/src/sound/midisources/midisource_smf.cpp b/src/sound/midisources/midisource_smf.cpp index 0b189e27d4..a3d846cad8 100644 --- a/src/sound/midisources/midisource_smf.cpp +++ b/src/sound/midisources/midisource_smf.cpp @@ -37,7 +37,7 @@ // HEADER FILES ------------------------------------------------------------ -#include "i_musicinterns.h" +#include "midisource.h" // MACROS ------------------------------------------------------------------ diff --git a/src/sound/midisources/midisource_xmi.cpp b/src/sound/midisources/midisource_xmi.cpp index 4f32f85ed9..a5ebfd221b 100644 --- a/src/sound/midisources/midisource_xmi.cpp +++ b/src/sound/midisources/midisource_xmi.cpp @@ -34,7 +34,8 @@ // HEADER FILES ------------------------------------------------------------ -#include "i_musicinterns.h" +#include "midisource.h" +#include "basictypes.h" // MACROS ------------------------------------------------------------------ @@ -128,7 +129,7 @@ XMISong::XMISong (FileReader &reader) memset(Songs, 0, sizeof(*Songs) * NumSongs); FindXMIDforms(&MusHeader[0], MusHeader.Size(), Songs); CurrSong = Songs; - DPrintf(DMSG_SPAMMY, "XMI song count: %d\n", NumSongs); + //DPrintf(DMSG_SPAMMY, "XMI song count: %d\n", NumSongs); } //========================================================================== diff --git a/src/sound/music/i_musicinterns.h b/src/sound/music/i_musicinterns.h index f6d72208dc..2c750379d3 100644 --- a/src/sound/music/i_musicinterns.h +++ b/src/sound/music/i_musicinterns.h @@ -26,29 +26,6 @@ struct MidiHeader MidiHeader *lpNext; }; -// These constants must match the corresponding values of the Windows headers -// to avoid readjustment in the native Windows device's playback functions -// and should not be changed. -enum -{ - MIDIDEV_MIDIPORT = 1, - MIDIDEV_SYNTH, - MIDIDEV_SQSYNTH, - MIDIDEV_FMSYNTH, - MIDIDEV_MAPPER, - MIDIDEV_WAVETABLE, - MIDIDEV_SWSYNTH -}; - -enum : uint8_t -{ - MEVENT_TEMPO = 1, - MEVENT_NOP = 2, - MEVENT_LONGMSG = 128, -}; - -#define MEVENT_EVENTTYPE(x) ((uint8_t)((x) >> 24)) -#define MEVENT_EVENTPARM(x) ((x) & 0xffffff) class MIDIStreamer; @@ -205,11 +182,6 @@ protected: // Base class for streaming MUS and MIDI files ------------------------------ -enum -{ - MAX_MIDI_EVENTS = 128 -}; - class MIDIStreamer : public MusInfo { public: diff --git a/src/sound/music/mididefs.h b/src/sound/music/mididefs.h new file mode 100644 index 0000000000..f55ce794e4 --- /dev/null +++ b/src/sound/music/mididefs.h @@ -0,0 +1,31 @@ +#pragma once + +enum +{ + MAX_MIDI_EVENTS = 128 +}; + +inline constexpr uint8_t MEVENT_EVENTTYPE(uint32_t x) { return ((uint8_t)((x) >> 24)); } +inline constexpr uint32_t MEVENT_EVENTPARM(uint32_t x) { return ((x) & 0xffffff); } + +// These constants must match the corresponding values of the Windows headers +// to avoid readjustment in the native Windows device's playback functions +// and should not be changed. +enum +{ + MIDIDEV_MIDIPORT = 1, + MIDIDEV_SYNTH, + MIDIDEV_SQSYNTH, + MIDIDEV_FMSYNTH, + MIDIDEV_MAPPER, + MIDIDEV_WAVETABLE, + MIDIDEV_SWSYNTH +}; + +enum : uint8_t +{ + MEVENT_TEMPO = 1, + MEVENT_NOP = 2, + MEVENT_LONGMSG = 128, +}; + diff --git a/src/utility/basictypes.h b/src/utility/basictypes.h index f279bf58cb..5243d86892 100644 --- a/src/utility/basictypes.h +++ b/src/utility/basictypes.h @@ -36,5 +36,18 @@ typedef uint32_t angle_t; #define GCCNOWARN #endif +template +char(&_ArraySizeHelper(T(&array)[N]))[N]; + +#define countof( array ) (sizeof( _ArraySizeHelper( array ) )) + + +#ifndef MAKE_ID +#ifndef __BIG_ENDIAN__ +#define MAKE_ID(a,b,c,d) ((uint32_t)((a)|((b)<<8)|((c)<<16)|((d)<<24))) +#else +#define MAKE_ID(a,b,c,d) ((uint32_t)((d)|((c)<<8)|((b)<<16)|((a)<<24))) +#endif +#endif #endif diff --git a/src/win32/i_crash.cpp b/src/win32/i_crash.cpp index 1a2df352a0..aea0279909 100644 --- a/src/win32/i_crash.cpp +++ b/src/win32/i_crash.cpp @@ -68,12 +68,6 @@ // Maximum number of files that might appear in a crash report. #define MAX_FILES 5 -#ifndef __BIG_ENDIAN__ -#define MAKE_ID(a,b,c,d) ((a)|((b)<<8)|((c)<<16)|((d)<<24)) -#else -#define MAKE_ID(a,b,c,d) ((d)|((c)<<8)|((b)<<16)|((a)<<24)) -#endif - #define ZIP_LOCALFILE MAKE_ID('P','K',3,4) #define ZIP_CENTRALFILE MAKE_ID('P','K',1,2) #define ZIP_ENDOFDIR MAKE_ID('P','K',5,6)