From: <sag...@us...> - 2014-10-19 19:26:49
|
Revision: 4447 http://sourceforge.net/p/modplug/code/4447 Author: saga-games Date: 2014-10-19 19:26:33 +0000 (Sun, 19 Oct 2014) Log Message: ----------- [Imp] IT Loader: Add support for reading encrypted edit time (discovered through today's IT source release, yay!). Modified Paths: -------------- trunk/OpenMPT/mptrack/dlg_misc.cpp trunk/OpenMPT/soundlib/ITTools.h trunk/OpenMPT/soundlib/Load_it.cpp Modified: trunk/OpenMPT/mptrack/dlg_misc.cpp =================================================================== --- trunk/OpenMPT/mptrack/dlg_misc.cpp 2014-10-19 15:19:34 UTC (rev 4446) +++ trunk/OpenMPT/mptrack/dlg_misc.cpp 2014-10-19 19:26:33 UTC (rev 4447) @@ -1079,7 +1079,10 @@ // Date TCHAR szDate[32]; - _tcsftime(szDate, CountOf(szDate), _T("%d %b %Y, %H:%M:%S"), &hist->loadDate); + if(hist->loadDate.tm_mday != 0) + _tcsftime(szDate, CountOf(szDate), _T("%d %b %Y, %H:%M:%S"), &hist->loadDate); + else + _tcscpy(szDate, _T("<unknown date>")); // Time + stuff uint32 duration = (uint32)((double)(hist->openTime) / HISTORY_TIMER_PRECISION); s.AppendFormat(_T("Loaded %s, open for %luh %02lum %02lus\r\n"), Modified: trunk/OpenMPT/soundlib/ITTools.h =================================================================== --- trunk/OpenMPT/soundlib/ITTools.h 2014-10-19 15:19:34 UTC (rev 4446) +++ trunk/OpenMPT/soundlib/ITTools.h 2014-10-19 19:26:33 UTC (rev 4447) @@ -65,7 +65,7 @@ uint8 pwd; // Pitch Wheel Depth uint16 msglength; // Length of Song Message uint32 msgoffset; // Offset of Song Message in File (IT crops message after first null) - char reserved[4]; // ChibiTracker writes "CHBI" here. OpenMPT writes "OMPT" here in some cases, see Load_it.cpp + char reserved[4]; // Some IT versions save an edit timer here. ChibiTracker writes "CHBI" here. OpenMPT writes "OMPT" here in some cases, see Load_it.cpp uint8 chnpan[64]; // Initial Channel Panning uint8 chnvol[64]; // Initial Channel Volume Modified: trunk/OpenMPT/soundlib/Load_it.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_it.cpp 2014-10-19 15:19:34 UTC (rev 4446) +++ trunk/OpenMPT/soundlib/Load_it.cpp 2014-10-19 19:26:33 UTC (rev 4447) @@ -960,6 +960,23 @@ { madeWithTracker = mpt::String::Print("Impulse Tracker %1.%2", (fileHeader.cwtv & 0x0F00) >> 8, mpt::fmt::hex0<2>((fileHeader.cwtv & 0xFF))); } + if(m_FileHistory.empty() && memcmp(fileHeader.reserved, "\0\0\0\0", 4)) + { + // IT encrypts the total edit time of a module in the "reserved" fild + uint32 editTime; + memcpy(&editTime, fileHeader.reserved, 4); + SwapBytesLE(editTime); + editTime ^= 0x4954524B; // 'ITRK' + editTime = (editTime >> 7) | (editTime << (32 - 7)); + editTime = -(int32)editTime; + editTime = (editTime << 4) | (editTime >> (32 - 4)); + editTime ^= 0x4A54484C; // 'JTHL' + + FileHistory hist; + MemsetZero(hist); + hist.openTime = static_cast<uint32>(editTime * (HISTORY_TIMER_PRECISION / 18.2f)); + m_FileHistory.push_back(hist); + } } break; case 1: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |