|
From: <sag...@us...> - 2011-11-18 22:21:53
|
Revision: 1136
http://modplug.svn.sourceforge.net/modplug/?rev=1136&view=rev
Author: saga-games
Date: 2011-11-18 22:21:47 +0000 (Fri, 18 Nov 2011)
Log Message:
-----------
[Fix] PSM16 Loader: Finetuning in Silverball tunes should work better now. Also fixed note transposition, it seemed to be off by one.
[Fix] PTM Loader: Fixed sample names (off-by-two error in sample struct)
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Load_psm.cpp
trunk/OpenMPT/soundlib/Load_ptm.cpp
Modified: trunk/OpenMPT/soundlib/Load_psm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_psm.cpp 2011-11-13 00:59:17 UTC (rev 1135)
+++ trunk/OpenMPT/soundlib/Load_psm.cpp 2011-11-18 22:21:47 UTC (rev 1136)
@@ -453,7 +453,7 @@
Samples[smp].nC5Speed = LittleEndianW(pSample->C5Freq);
Samples[smp].nLength = LittleEndian(pSample->sampleLength);
Samples[smp].nLoopStart = LittleEndian(pSample->loopStart);
- Samples[smp].nLoopEnd = LittleEndian(pSample->loopEnd);
+ Samples[smp].nLoopEnd = LittleEndian(pSample->loopEnd); // Hmm... apparently we should add +1 for Extreme Pinball tunes here? See sample 8 in the medieval table music.
Samples[smp].nPan = 128;
Samples[smp].nVolume = (pSample->defaultVolume + 1) << 1;
Samples[smp].uFlags = (pSample->flags & 0x80) ? CHN_LOOP : 0;
@@ -852,7 +852,7 @@
uint32 length; // in bytes
uint32 loopStart; // in samples?
uint32 loopEnd; // in samples?
- int8 finetune; // 0 ... 15 (useless? also, why is this almost always 70?)
+ int8 finetune; // 0 ... 15 (high nibble is 7 in most cases, but why? is it maybe some transpose value?)
uint8 volume; // default volume
uint16 c2freq;
};
@@ -943,6 +943,16 @@
Samples[iSmp].nLoopStart = LittleEndian(smphdr->loopStart);
Samples[iSmp].nLoopEnd = LittleEndian(smphdr->loopEnd);
Samples[iSmp].nC5Speed = LittleEndianW(smphdr->c2freq);
+ if(smphdr->finetune & 0x0F)
+ {
+ int finetune = smphdr->finetune & 0x0F;
+ if(finetune >= 8)
+ {
+ finetune -= 16;
+ }
+ // Copied over from DUMB
+ Samples[iSmp].nC5Speed = double(Samples[iSmp].nC5Speed) * pow(1.000225659305069791926712241547647863626, finetune * 32);
+ }
Samples[iSmp].nVolume = smphdr->volume << 2;
Samples[iSmp].nGlobalVol = 256;
@@ -1016,13 +1026,13 @@
continue;
}
- row_data = Patterns[nPat] + iRow * m_nChannels + min(bChnFlag & 0x1F, m_nChannels - 1);
+ row_data = Patterns[nPat].GetpModCommand(iRow, min(bChnFlag & 0x1F, m_nChannels - 1));
if(bChnFlag & 0x80)
{
// note + instr present
ASSERT_CAN_READ(2);
- row_data->note = lpStream[dwMemPos++] + 37;
+ row_data->note = lpStream[dwMemPos++] + 36;
row_data->instr = lpStream[dwMemPos++];
}
if(bChnFlag & 0x40)
Modified: trunk/OpenMPT/soundlib/Load_ptm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_ptm.cpp 2011-11-13 00:59:17 UTC (rev 1135)
+++ trunk/OpenMPT/soundlib/Load_ptm.cpp 2011-11-18 22:21:47 UTC (rev 1136)
@@ -38,9 +38,7 @@
WORD patseg[128]; // pattern offsets (*16)
} PTMFILEHEADER, *LPPTMFILEHEADER;
-#define SIZEOF_PTMFILEHEADER 608
-
typedef struct PTMSAMPLE
{
BYTE sampletype; // sample type (bit array)
@@ -52,13 +50,11 @@
WORD length[2]; // sample size (in bytes)
WORD loopbeg[2]; // start of loop
WORD loopend[2]; // end of loop
- WORD gusdata[8];
- char samplename[28]; // name of sample, asciiz
+ WORD gusdata[7];
+ char samplename[28]; // name of sample, asciiz
DWORD ptms_id; // sample identification, 'PTMS' or 0x534d5450
} PTMSAMPLE;
-#define SIZEOF_PTMSAMPLE 80
-
#pragma pack()
@@ -79,7 +75,7 @@
pfh.fileflags = LittleEndianW(pfh.fileflags);
pfh.reserved2 = LittleEndianW(pfh.reserved2);
pfh.ptmf_id = LittleEndian(pfh.ptmf_id);
- for (UINT j = 0; j < 128; j++)
+ for (size_t j = 0; j < CountOf(pfh.patseg); j++)
{
pfh.patseg[j] = LittleEndianW(pfh.patseg[j]);
}
@@ -89,14 +85,14 @@
|| (pfh.norders > 256) || (!pfh.norders)
|| (!pfh.nsamples) || (pfh.nsamples > 255)
|| (!pfh.npatterns) || (pfh.npatterns > 128)
- || (SIZEOF_PTMFILEHEADER+pfh.nsamples*SIZEOF_PTMSAMPLE >= (int)dwMemLength)) return false;
+ || (sizeof(PTMFILEHEADER) + pfh.nsamples * sizeof(PTMSAMPLE) >= dwMemLength)) return false;
memcpy(m_szNames[0], pfh.songname, 28);
StringFixer::SpaceToNullStringFixed<28>(m_szNames[0]);
m_nType = MOD_TYPE_PTM;
m_nChannels = pfh.nchannels;
- m_nSamples = (pfh.nsamples < MAX_SAMPLES) ? pfh.nsamples : MAX_SAMPLES-1;
- dwMemPos = SIZEOF_PTMFILEHEADER;
+ m_nSamples = min(pfh.nsamples, MAX_SAMPLES - 1);
+ dwMemPos = sizeof(PTMFILEHEADER);
nOrders = (pfh.norders < MAX_ORDERS) ? pfh.norders : MAX_ORDERS-1;
Order.ReadAsByte(pfh.orders, nOrders, nOrders);
@@ -105,7 +101,7 @@
ChnSettings[ipan].nVolume = 64;
ChnSettings[ipan].nPan = ((pfh.chnpan[ipan] & 0x0F) << 4) + 4;
}
- for (SAMPLEINDEX ismp = 0; ismp < m_nSamples; ismp++, dwMemPos += SIZEOF_PTMSAMPLE)
+ for (SAMPLEINDEX ismp = 0; ismp < m_nSamples; ismp++, dwMemPos += sizeof(PTMSAMPLE))
{
MODSAMPLE *pSmp = &Samples[ismp+1];
PTMSAMPLE *psmp = (PTMSAMPLE *)(lpStream+dwMemPos);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|