Skip to content

Commit

Permalink
Revert "Revert making for loop variable permanent."
Browse files Browse the repository at this point in the history
This reverts commit 500711c.
  • Loading branch information
Konstanty committed Jan 30, 2022
1 parent 50fa508 commit 234b65d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/load_it.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ BOOL CSoundFile::ReadIT(const BYTE *lpStream, DWORD dwMemLength)
DWORD patpos[MAX_PATTERNS];
BYTE chnmask[64];//, channels_used[64]
MODCOMMAND lastvalue[64];
UINT j;

if ((!lpStream) || (dwMemLength < sizeof(ITFILEHEADER))) return FALSE;
ITFILEHEADER pifh = *(ITFILEHEADER *)lpStream;
Expand Down Expand Up @@ -231,7 +232,7 @@ BOOL CSoundFile::ReadIT(const BYTE *lpStream, DWORD dwMemLength)
if (inspossize > MAX_INSTRUMENTS) inspossize = MAX_INSTRUMENTS;
inspossize <<= 2;
memcpy(inspos, lpStream+dwMemPos, inspossize);
for (UINT j=0; j < (inspossize>>2); j++) {
for (j=0; j < (inspossize>>2); j++) {
inspos[j] = bswapLE32(inspos[j]);
}
dwMemPos += pifh.insnum * 4;
Expand All @@ -241,7 +242,7 @@ BOOL CSoundFile::ReadIT(const BYTE *lpStream, DWORD dwMemLength)
if (smppossize > MAX_SAMPLES) smppossize = MAX_SAMPLES;
smppossize <<= 2;
memcpy(smppos, lpStream+dwMemPos, smppossize);
for (UINT j=0; j < (smppossize>>2); j++) {
for (j=0; j < (smppossize>>2); j++) {
smppos[j] = bswapLE32(smppos[j]);
}
dwMemPos += pifh.smpnum * 4;
Expand All @@ -251,7 +252,7 @@ BOOL CSoundFile::ReadIT(const BYTE *lpStream, DWORD dwMemLength)
if (patpossize > MAX_PATTERNS) patpossize = MAX_PATTERNS;
patpossize <<= 2;
memcpy(patpos, lpStream+dwMemPos, patpossize);
for (UINT j=0; j < (patpossize>>2); j++) {
for (j=0; j < (patpossize>>2); j++) {
patpos[j] = bswapLE32(patpos[j]);
}
dwMemPos += pifh.patnum * 4;
Expand Down
5 changes: 3 additions & 2 deletions src/sndfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1392,17 +1392,18 @@ UINT CSoundFile::ReadSample(MODINSTRUMENT *pIns, UINT nFlags, LPCSTR lpMemFile,
// PTM 8bit delta to 16-bit sample
case RS_PTM8DTO16:
{
UINT j;
len = pIns->nLength * 2;
if (len > dwMemLength) break;
int8_t *pSample = (int8_t *)pIns->pSample;
int8_t delta8 = 0;
for (UINT j=0; j<len; j++)
for (j=0; j<len; j++)
{
delta8 += lpMemFile[j];
*pSample++ = delta8;
}
uint16_t *pSampleW = (uint16_t *)pIns->pSample;
for (UINT j=0; j<len; j+=2) // swaparoni!
for (j=0; j<len; j+=2) // swaparoni!
{
uint16_t rawSample = *pSampleW;
*pSampleW++ = bswapLE16(rawSample);
Expand Down

0 comments on commit 234b65d

Please sign in to comment.