From: <sag...@us...> - 2012-11-20 20:16:36
|
Revision: 1434 http://modplug.svn.sourceforge.net/modplug/?rev=1434&view=rev Author: saga-games Date: 2012-11-20 20:16:27 +0000 (Tue, 20 Nov 2012) Log Message: ----------- [Ref] Various small changes. Modified Paths: -------------- trunk/OpenMPT/mptrack/EffectInfo.cpp trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/SoundFilePlayConfig.cpp trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/Vstplug.h trunk/OpenMPT/mptrack/test/test.cpp trunk/OpenMPT/soundlib/Endianness.h trunk/OpenMPT/soundlib/Load_it.cpp trunk/OpenMPT/soundlib/Load_itp.cpp trunk/OpenMPT/soundlib/Load_ult.cpp trunk/OpenMPT/soundlib/Snd_defs.h trunk/OpenMPT/soundlib/plugins/PlugInterface.h trunk/OpenMPT/ungzip/ungzip.h Modified: trunk/OpenMPT/mptrack/EffectInfo.cpp =================================================================== --- trunk/OpenMPT/mptrack/EffectInfo.cpp 2012-11-19 21:42:41 UTC (rev 1433) +++ trunk/OpenMPT/mptrack/EffectInfo.cpp 2012-11-20 20:16:27 UTC (rev 1434) @@ -297,7 +297,7 @@ if (s) GetEffectName(s, gFXInfo[ndx].effect, gFXInfo[ndx].paramValue, bXX); if ((prangeMin) && (prangeMax)) { - UINT nmin = 0, nmax = 0xFF, nType = sndFile.GetType(); + UINT nmin = 0, nmax = 0xFF; if (gFXInfo[ndx].paramMask == 0xF0) { nmin = gFXInfo[ndx].paramValue; @@ -306,7 +306,7 @@ switch(gFXInfo[ndx].effect) { case CMD_ARPEGGIO: - if (nType & (MOD_TYPE_MOD | MOD_TYPE_XM)) nmin = 1; + if (sndFile.GetType() & (MOD_TYPE_MOD | MOD_TYPE_XM)) nmin = 1; break; case CMD_VOLUME: case CMD_CHANNELVOLUME: @@ -315,16 +315,16 @@ case CMD_SPEED: nmin = 1; nmax = 0xFF; - if (nType & MOD_TYPE_MOD) nmax = 0x20; else - if (nType & MOD_TYPE_XM) nmax = 0x1F; + if (sndFile.GetType() & MOD_TYPE_MOD) nmax = 0x20; else + if (sndFile.GetType() & MOD_TYPE_XM) nmax = 0x1F; break; case CMD_TEMPO: nmin = 0x20; - if (nType & MOD_TYPE_MOD) nmin = 0x21; else + if (sndFile.GetType() & MOD_TYPE_MOD) nmin = 0x21; else // -> CODE#0010 // -> DESC="add extended parameter mechanism to pattern effects" // if (nType & MOD_TYPE_S3MIT) nmin = 1; - if (nType & MOD_TYPE_S3MITMPT) nmin = 0; + if (sndFile.GetType() & MOD_TYPE_S3MITMPT) nmin = 0; // -! NEW_FEATURE#0010 break; case CMD_VOLUMESLIDE: @@ -333,14 +333,14 @@ case CMD_GLOBALVOLSLIDE: case CMD_CHANNELVOLSLIDE: case CMD_PANNINGSLIDE: - nmax = (nType & MOD_TYPE_S3MITMPT) ? 58 : 30; + nmax = (sndFile.GetType() & MOD_TYPE_S3MITMPT) ? 58 : 30; break; case CMD_PANNING8: - if (nType & (MOD_TYPE_S3M)) nmax = 0x81; + if (sndFile.GetType() & (MOD_TYPE_S3M)) nmax = 0x81; else nmax = 0xFF; break; case CMD_GLOBALVOLUME: - nmax = (nType & (MOD_TYPE_IT | MOD_TYPE_MPT)) ? 128 : 64; + nmax = (sndFile.GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT)) ? 128 : 64; break; case CMD_MODCMDEX: @@ -353,7 +353,7 @@ break; case CMD_PATTERNBREAK: // no big patterns in MOD/S3M files - if(nType & (MOD_TYPE_MOD | MOD_TYPE_S3M)) + if(sndFile.GetType() & (MOD_TYPE_MOD | MOD_TYPE_S3M)) nmax = 63; break; } Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2012-11-19 21:42:41 UTC (rev 1433) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2012-11-20 20:16:27 UTC (rev 1434) @@ -590,18 +590,20 @@ bool handledByTextBox = false; HWND hWnd = ::GetFocus(); - if (hWnd != NULL) { + if(hWnd != NULL) + { TCHAR activeWindowClassName[512]; GetClassName(hWnd, activeWindowClassName, 6); textboxHasFocus = _tcsicmp(activeWindowClassName, _T("Edit")) == 0; - if (textboxHasFocus) { + if(textboxHasFocus) + { handledByTextBox = m_InputHandler->isKeyPressHandledByTextBox(wParam); } } - if (!handledByTextBox && m_InputHandler->GeneralKeyEvent(kCtxAllContexts, code, wParam, lParam) != kcNull) + if(!handledByTextBox && m_InputHandler->GeneralKeyEvent(kCtxAllContexts, code, wParam, lParam) != kcNull) { - if (wParam != VK_ESCAPE) + if(wParam != VK_ESCAPE) return -1; // We've handled the keypress. No need to take it further. // Unless it was esc, in which case we need it to close Windows // (there might be other special cases, we'll see.. ) @@ -609,13 +611,13 @@ } return CallNextHookEx(ghKbdHook, code, wParam, lParam); -} +} BOOL CMainFrame::PreTranslateMessage(MSG* pMsg) //--------------------------------------------- { - if ((pMsg->message == WM_RBUTTONDOWN) || (pMsg->message == WM_NCRBUTTONDOWN)) + if((pMsg->message == WM_RBUTTONDOWN) || (pMsg->message == WM_NCRBUTTONDOWN)) { CWnd* pWnd = CWnd::FromHandlePermanent(pMsg->hwnd); CControlBar* pBar = NULL; Modified: trunk/OpenMPT/mptrack/SoundFilePlayConfig.cpp =================================================================== --- trunk/OpenMPT/mptrack/SoundFilePlayConfig.cpp 2012-11-19 21:42:41 UTC (rev 1433) +++ trunk/OpenMPT/mptrack/SoundFilePlayConfig.cpp 2012-11-20 20:16:27 UTC (rev 1434) @@ -11,7 +11,7 @@ #include "stdafx.h" #include "Sndfile.h" -#include ".\soundfileplayconfig.h" +#include "SoundFilePlayConfig.h" CSoundFilePlayConfig::CSoundFilePlayConfig() //------------------------------------------ Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2012-11-19 21:42:41 UTC (rev 1433) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2012-11-20 20:16:27 UTC (rev 1434) @@ -1931,12 +1931,6 @@ } -void CVstPlugin::Init(unsigned long /*nFreq*/, int /*bReset*/) -//------------------------------------------------------------ -{ - -} - void CVstPlugin::Resume() //----------------------- { Modified: trunk/OpenMPT/mptrack/Vstplug.h =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.h 2012-11-19 21:42:41 UTC (rev 1433) +++ trunk/OpenMPT/mptrack/Vstplug.h 2012-11-20 20:16:27 UTC (rev 1434) @@ -59,11 +59,11 @@ }; VSTPluginLib *pPrev, *pNext; + CVstPlugin *pPluginsList; VstInt32 dwPluginId1; VstInt32 dwPluginId2; - bool isInstrument; PluginCategory category; - CVstPlugin *pPluginsList; + bool isInstrument; CHAR szLibraryName[_MAX_FNAME]; CHAR szDllPath[_MAX_PATH]; @@ -233,7 +233,6 @@ void RestoreAllParameters(long nProg=-1); //rewbs.plugDefaultProgram - added param void RecalculateGain(); void Process(float *pOutL, float *pOutR, size_t nSamples); - void Init(unsigned long nFreq, int bReset); bool MidiSend(DWORD dwMidiCode); void MidiCC(uint8 nMidiCh, MIDIEvents::MidiCC nController, uint8 nParam, CHANNELINDEX trackChannel); void MidiPitchBend(uint8 nMidiCh, int32 increment, int8 pwd); Modified: trunk/OpenMPT/mptrack/test/test.cpp =================================================================== --- trunk/OpenMPT/mptrack/test/test.cpp 2012-11-19 21:42:41 UTC (rev 1433) +++ trunk/OpenMPT/mptrack/test/test.cpp 2012-11-20 20:16:27 UTC (rev 1434) @@ -199,12 +199,6 @@ VERIFY_EQUAL(int64_min, (std::numeric_limits<int64>::min)()); VERIFY_EQUAL(int64_max, (std::numeric_limits<int64>::max)()); VERIFY_EQUAL(uint64_max, (std::numeric_limits<uint64>::max)()); - - VERIFY_EQUAL(ROWINDEX_MAX, (std::numeric_limits<ROWINDEX>::max)()); - VERIFY_EQUAL(ORDERINDEX_MAX, (std::numeric_limits<ORDERINDEX>::max)()); - VERIFY_EQUAL(PATTERNINDEX_MAX, (std::numeric_limits<PATTERNINDEX>::max)()); - VERIFY_EQUAL(SAMPLEINDEX_MAX, (std::numeric_limits<SAMPLEINDEX>::max)()); - VERIFY_EQUAL(INSTRUMENTINDEX_MAX, (std::numeric_limits<INSTRUMENTINDEX>::max)()); } Modified: trunk/OpenMPT/soundlib/Endianness.h =================================================================== --- trunk/OpenMPT/soundlib/Endianness.h 2012-11-19 21:42:41 UTC (rev 1433) +++ trunk/OpenMPT/soundlib/Endianness.h 2012-11-20 20:16:27 UTC (rev 1434) @@ -22,17 +22,18 @@ // Deprecated. Use "SwapBytesXX" versions below. #ifdef PLATFORM_BIG_ENDIAN // PPC -inline DWORD LittleEndian(DWORD x) { return ((x & 0xFF) << 24) | ((x & 0xFF00) << 8) | ((x & 0xFF0000) >> 8) | ((x & 0xFF000000) >> 24); } -inline WORD LittleEndianW(WORD x) { return (WORD)(((x >> 8) & 0xFF) | ((x << 8) & 0xFF00)); } -#define BigEndian(x) (x) -#define BigEndianW(x) (x) +inline uint32 LittleEndian(uint32 x) { return ((x & 0xFF) << 24) | ((x & 0xFF00) << 8) | ((x & 0xFF0000) >> 8) | ((x & 0xFF000000) >> 24); } +inline uint16 LittleEndianW(uint16 x) { return (uint16)(((x >> 8) & 0xFF) | ((x << 8) & 0xFF00)); } +#define BigEndian(x) (x) +#define BigEndianW(x) (x) #else // x86 -inline DWORD BigEndian(DWORD x) { return ((x & 0xFF) << 24) | ((x & 0xFF00) << 8) | ((x & 0xFF0000) >> 8) | ((x & 0xFF000000) >> 24); } -inline WORD BigEndianW(WORD x) { return (WORD)(((x >> 8) & 0xFF) | ((x << 8) & 0xFF00)); } -#define LittleEndian(x) (x) -#define LittleEndianW(x) (x) +inline uint32 BigEndian(uint32 x) { return ((x & 0xFF) << 24) | ((x & 0xFF00) << 8) | ((x & 0xFF0000) >> 8) | ((x & 0xFF000000) >> 24); } +inline uint16 BigEndianW(uint16 x) { return (uint16)(((x >> 8) & 0xFF) | ((x << 8) & 0xFF00)); } +#define LittleEndian(x) (x) +#define LittleEndianW(x) (x) #endif +//#pragma deprecated(BigEndian, BigEndianW, LittleEndian, LittleEndianW) #ifdef PLATFORM_BIG_ENDIAN // PPC Modified: trunk/OpenMPT/soundlib/Load_it.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_it.cpp 2012-11-19 21:42:41 UTC (rev 1433) +++ trunk/OpenMPT/soundlib/Load_it.cpp 2012-11-20 20:16:27 UTC (rev 1434) @@ -1900,7 +1900,7 @@ if(plug < MAX_MIXPLUGINS) { // MPT's standard plugin data. Size not specified in file.. grrr.. - chunk.Read(m_MixPlugins[plug].Info); + chunk.ReadConvertEndianness(m_MixPlugins[plug].Info); StringFixer::SetNullTerminator(m_MixPlugins[plug].Info.szName); StringFixer::SetNullTerminator(m_MixPlugins[plug].Info.szLibraryName); Modified: trunk/OpenMPT/soundlib/Load_itp.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_itp.cpp 2012-11-19 21:42:41 UTC (rev 1433) +++ trunk/OpenMPT/soundlib/Load_itp.cpp 2012-11-20 20:16:27 UTC (rev 1434) @@ -83,8 +83,10 @@ } // Song mix plugins - size = file.ReadUint32LE(); - LoadMixPlugins(file.GetChunk(size)); + { + FileReader plugChunk = file.GetChunk(file.ReadUint32LE()); + LoadMixPlugins(plugChunk); + } // MIDI Macro config file.ReadStructPartial(m_MidiCfg, file.ReadUint32LE()); Modified: trunk/OpenMPT/soundlib/Load_ult.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_ult.cpp 2012-11-19 21:42:41 UTC (rev 1433) +++ trunk/OpenMPT/soundlib/Load_ult.cpp 2012-11-20 20:16:27 UTC (rev 1434) @@ -451,7 +451,6 @@ { ModCommand evnote; ModCommand *note; - int repeat; evnote.Clear(); for(PATTERNINDEX pat = 0; pat < numPats; pat++) @@ -460,11 +459,11 @@ ROWINDEX row = 0; while(row < 64) { - repeat = ReadULTEvent(evnote, file); + int repeat = ReadULTEvent(evnote, file); if(repeat + row > 64) repeat = 64 - row; if(repeat == 0) break; - while (repeat--) + while(repeat--) { *note = evnote; note += GetNumChannels(); Modified: trunk/OpenMPT/soundlib/Snd_defs.h =================================================================== --- trunk/OpenMPT/soundlib/Snd_defs.h 2012-11-19 21:42:41 UTC (rev 1433) +++ trunk/OpenMPT/soundlib/Snd_defs.h 2012-11-20 20:16:27 UTC (rev 1434) @@ -19,29 +19,22 @@ #endif typedef uint32 ROWINDEX; - const ROWINDEX ROWINDEX_MAX = uint32_max; - const ROWINDEX ROWINDEX_INVALID = ROWINDEX_MAX; + const ROWINDEX ROWINDEX_INVALID = uint32_max; typedef uint16 CHANNELINDEX; - const CHANNELINDEX CHANNELINDEX_MAX = uint16_max; - const CHANNELINDEX CHANNELINDEX_INVALID = CHANNELINDEX_MAX; + const CHANNELINDEX CHANNELINDEX_INVALID = uint16_max; typedef uint16 ORDERINDEX; - const ORDERINDEX ORDERINDEX_MAX = uint16_max; - const ORDERINDEX ORDERINDEX_INVALID = ORDERINDEX_MAX; + const ORDERINDEX ORDERINDEX_INVALID = uint16_max; typedef uint16 PATTERNINDEX; - const PATTERNINDEX PATTERNINDEX_MAX = uint16_max; - const PATTERNINDEX PATTERNINDEX_INVALID = PATTERNINDEX_MAX; + const PATTERNINDEX PATTERNINDEX_INVALID = uint16_max; typedef uint8 PLUGINDEX; const PLUGINDEX PLUGINDEX_INVALID = uint8_max; typedef uint16 TEMPO; typedef uint16 SAMPLEINDEX; - const SAMPLEINDEX SAMPLEINDEX_MAX = uint16_max; - const SAMPLEINDEX SAMPLEINDEX_INVALID = SAMPLEINDEX_MAX; + const SAMPLEINDEX SAMPLEINDEX_INVALID = uint16_max; typedef uint16 INSTRUMENTINDEX; - const INSTRUMENTINDEX INSTRUMENTINDEX_MAX = uint16_max; - const INSTRUMENTINDEX INSTRUMENTINDEX_INVALID = INSTRUMENTINDEX_MAX; + const INSTRUMENTINDEX INSTRUMENTINDEX_INVALID = uint16_max; typedef uint8 SEQUENCEINDEX; - const SEQUENCEINDEX SEQUENCEINDEX_MAX = uint8_max; - const SEQUENCEINDEX SEQUENCEINDEX_INVALID = SEQUENCEINDEX_MAX; + const SEQUENCEINDEX SEQUENCEINDEX_INVALID = uint8_max; typedef uintptr_t SmpLength; @@ -52,7 +45,7 @@ // Note: Sample size in bytes can be more than this (= 256 MB). #define MAX_SAMPLE_RATE 192000 // Max playback / render rate in Hz -const ROWINDEX MAX_PATTERN_ROWS = 1024; // -> CODE#0008 -> DESC="#define to set pattern size" -! BEHAVIOUR_CHANGE#0008 +const ROWINDEX MAX_PATTERN_ROWS = 1024; const ORDERINDEX MAX_ORDERS = 256; const PATTERNINDEX MAX_PATTERNS = 240; const SAMPLEINDEX MAX_SAMPLES = 4000; @@ -272,8 +265,8 @@ SONG_ITPEMBEDIH = 0x40000, // Embed instrument headers in project file // -! NEW_FEATURE#0023 SONG_BREAKTOROW = 0x80000, // Break to row command encountered (internal flag, do not touch) - SONG_POSJUMP = 0x100000, // Position jump encountered (internal flag, do not touch) - SONG_PT1XMODE = 0x200000, // ProTracker 1.x playback mode + SONG_POSJUMP = 0x100000, // Position jump encountered (internal flag, do not touch) + SONG_PT1XMODE = 0x200000, // ProTracker 1.x playback mode }; #define SONG_FILE_FLAGS (SONG_EMBEDMIDICFG|SONG_FASTVOLSLIDES|SONG_ITOLDEFFECTS|SONG_ITCOMPATGXX|SONG_LINEARSLIDES|SONG_EXFILTERRANGE|SONG_AMIGALIMITS|SONG_ITPROJECT|SONG_ITPEMBEDIH|SONG_PT1XMODE) Modified: trunk/OpenMPT/soundlib/plugins/PlugInterface.h =================================================================== --- trunk/OpenMPT/soundlib/plugins/PlugInterface.h 2012-11-19 21:42:41 UTC (rev 1433) +++ trunk/OpenMPT/soundlib/plugins/PlugInterface.h 2012-11-20 20:16:27 UTC (rev 1434) @@ -22,6 +22,7 @@ #include "Snd_defs.h" #include "../common/misc_util.h" #include "../soundlib/MIDIEvents.h" +#include "../soundlib/Endianness.h" //////////////////////////////////////////////////////////////////// // Mix Plugins @@ -39,7 +40,6 @@ virtual void SaveAllParameters() = 0; virtual void RestoreAllParameters(long nProg=-1) = 0; //rewbs.plugDefaultProgram: added param virtual void Process(float *pOutL, float *pOutR, size_t nSamples) = 0; - virtual void Init(unsigned long nFreq, int bReset) = 0; virtual bool MidiSend(DWORD dwMidiCode) = 0; virtual void MidiCC(uint8 nMidiCh, MIDIEvents::MidiCC nController, uint8 nParam, CHANNELINDEX trackChannel) = 0; virtual void MidiPitchBend(uint8 nMidiCh, int32 increment, int8 pwd) = 0; @@ -118,6 +118,19 @@ // Should only be called from SNDMIXPLUGIN::SetBypass() and IMixPlugin::Bypass() void SetBypass(bool bypass = true) { if(bypass) dwInputRouting |= irBypass; else dwInputRouting &= ~irBypass; }; + // Convert all multi-byte numeric values to current platform's endianness or vice versa. + void ConvertEndianness() + { + SwapBytesLE(dwPluginId1); + SwapBytesLE(dwPluginId2); + SwapBytesLE(dwInputRouting); + SwapBytesLE(dwOutputRouting); + SwapBytesLE(dwReserved[0]); + SwapBytesLE(dwReserved[1]); + SwapBytesLE(dwReserved[2]); + SwapBytesLE(dwReserved[3]); + } + }; STATIC_ASSERT(sizeof(SNDMIXPLUGININFO) == 128); // this is directly written to files, so the size must be correct! Modified: trunk/OpenMPT/ungzip/ungzip.h =================================================================== --- trunk/OpenMPT/ungzip/ungzip.h 2012-11-19 21:42:41 UTC (rev 1433) +++ trunk/OpenMPT/ungzip/ungzip.h 2012-11-20 20:16:27 UTC (rev 1434) @@ -15,27 +15,7 @@ #include "../zlib/zlib.h" #include "../common/typedefs.h" -#pragma pack(push, 1) -struct GZheader -{ - uint8 magic1; // 0x1F - uint8 magic2; // 0x8B - uint8 method; // 0-7 = reserved, 8 = deflate - uint8 flags; // See GZ_F* constants - uint32 mtime; // UNIX time - uint8 xflags; // Available for use by specific compression methods. We ignore this. - uint8 os; // Which OS was used to compress the file? We also ignore this. -}; - -struct GZtrailer -{ - uint32 crc32; // CRC32 of decompressed data - uint32 isize; // Size of decompressed data -}; - -#pragma pack(pop) - // magic bytes #define GZ_HMAGIC1 0x1F #define GZ_HMAGIC2 0x8B @@ -53,6 +33,35 @@ class CGzipArchive //================ { +protected: + // in + LPBYTE m_lpStream; + DWORD m_dwStreamLen; + // out + Bytef *m_pOutputFile; + DWORD m_dwOutputLen; + +#pragma pack(push, 1) + + struct GZheader + { + uint8 magic1; // 0x1F + uint8 magic2; // 0x8B + uint8 method; // 0-7 = reserved, 8 = deflate + uint8 flags; // See GZ_F* constants + uint32 mtime; // UNIX time + uint8 xflags; // Available for use by specific compression methods. We ignore this. + uint8 os; // Which OS was used to compress the file? We also ignore this. + }; + + struct GZtrailer + { + uint32 crc32; // CRC32 of decompressed data + uint32 isize; // Size of decompressed data + }; + +#pragma pack(pop) + public: LPBYTE GetOutputFile() const { return m_pOutputFile; } @@ -62,12 +71,4 @@ CGzipArchive(LPBYTE lpStream, DWORD dwMemLength); ~CGzipArchive(); - -protected: - // in - LPBYTE m_lpStream; - DWORD m_dwStreamLen; - // out - Bytef *m_pOutputFile; - DWORD m_dwOutputLen; }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |