Skip to content

Commit

Permalink
minor clean-ups to libmodplug.
Browse files Browse the repository at this point in the history
  • Loading branch information
sezero committed Feb 2, 2021
1 parent cebbbdf commit 4d574e2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 22 deletions.
18 changes: 9 additions & 9 deletions src/libmodplug/load_abc.c
Expand Up @@ -2092,7 +2092,7 @@ static void abc_substitute(ABCHANDLE *h, char *target, char *s)
int n = SDL_strlen(s);
if (l <= 0 ||n <= 0 || SDL_strstr(s, target) || abs(n-l) > 10e3)
return;
while( (p=SDL_strstr(h->line, target)) ) {
while ((p=SDL_strstr(h->line, target)) != NULL) {
if( (i=SDL_strlen(h->line)) + n - l >= (int)h->len ) {
int reqsize = h->len<<1;
while (i + n - l >= reqsize) reqsize = reqsize<<1;
Expand Down Expand Up @@ -3570,7 +3570,7 @@ BOOL CSoundFile_ReadABC(CSoundFile *_this, const uint8_t *lpStream, DWORD dwMemL
abcstate = INSKIPFORX;
abcxcount = 0;
mmfseek(mmfile,0,SEEK_SET);
while( (line=abc_gets(h, mmfile)) ) {
while ((line=abc_gets(h, mmfile)) != NULL) {
for( p=line; SDL_isspace(*p); p++ ) ;
if( !SDL_strncmp(p,"X:",2) ) abcxcount++;
}
Expand All @@ -3583,7 +3583,7 @@ BOOL CSoundFile_ReadABC(CSoundFile *_this, const uint8_t *lpStream, DWORD dwMemL
}
while( mmsp > 0 ) {
mmsp--;
while((line=abc_gets(h, mmstack[mmsp]))) {
while ((line=abc_gets(h, mmstack[mmsp])) != NULL) {
char blankline[3] = "%%";
for( p=line; SDL_isspace(*p); p++ ) ;
switch(abcstate) {
Expand Down Expand Up @@ -3938,7 +3938,7 @@ BOOL CSoundFile_ReadABC(CSoundFile *_this, const uint8_t *lpStream, DWORD dwMemL
// plough thru the songline gathering mos....
ch0 = ' ';
pp = 0;
while( (ch = *p++) ) {
while ((ch = *p++) != '\0') {
if( !pp && IsAlpha(ch) && *p != ':' ) { // maybe a macro
for( mp=h->umacro; mp; mp=mp->next ) {
if( ch == mp->name[0] ) {
Expand Down Expand Up @@ -4042,7 +4042,7 @@ BOOL CSoundFile_ReadABC(CSoundFile *_this, const uint8_t *lpStream, DWORD dwMemL
h->tp = abc_check_track(h, h->tp);
abc_track_clear_tiedvpos(h);
abcbeatvol = abc_beat_vol(h, abcvol, (h->tracktime - bartime)/barticks);
while( (ch=*p++) && (ch != ']') ) {
while ((ch=*p++) != '\0' && (ch != ']')) {
h->tp = abc_locate_track(h, h->tp->v, abcchord? abcchord+DRONEPOS2: 0);
p += abc_add_noteon(h, ch, p, h->tracktime, barsig, abcbeatvol, abceffect, abceffoper);
p += abc_notelen(p, &notelen, &notediv);
Expand Down Expand Up @@ -4210,7 +4210,7 @@ BOOL CSoundFile_ReadABC(CSoundFile *_this, const uint8_t *lpStream, DWORD dwMemL
int barticks = notelen_notediv_to_ticks(h->speed,1,mnotediv);
if (barticks == 0) barticks = 1;
abcbeatvol = abc_beat_vol(h, abcvol, (h->tracktime - bartime)/barticks);
while( (ch=*p++) && (ch != '}') ) {
while ((ch=*p++) != '\0' && (ch != '}')) {
p += abc_add_noteon(h, ch, p, h->tracktime+abcgrace, barsig, abcbeatvol, none, 0);
p += abc_notelen(p, &notelen, &notediv);
if( *p=='-' ) {
Expand Down Expand Up @@ -4296,7 +4296,7 @@ BOOL CSoundFile_ReadABC(CSoundFile *_this, const uint8_t *lpStream, DWORD dwMemL
if( h->tp == h->tpc ) abc_add_chord(p, h, h->tpc, h->tracktime); // only do chords for one voice
}
abcto = 0;
while( (ch=*p++) && (ch != '"') ) {
while ((ch=*p++) != '\0' && (ch != '"')) {
if( !SDL_strncasecmp(p,"fade",4) && h->track && h->track->slidevol > -2 )
abc_globalslide(h, h->tracktime, -2); // set volumeslide to fade away...
if( !SDL_strncasecmp(p,"to coda",7) ) {
Expand Down Expand Up @@ -4505,7 +4505,7 @@ BOOL CSoundFile_ReadABC(CSoundFile *_this, const uint8_t *lpStream, DWORD dwMemL
else {
h->tp = abc_check_track(h, h->tp);
abcvol = abc_parse_decorations(h, h->tp, p);
while( (ch=*p++) && (ch != '+') )
while ((ch=*p++) != '\0' && (ch != '+'))
;
}
break;
Expand Down Expand Up @@ -4683,7 +4683,7 @@ BOOL CSoundFile_ReadABC(CSoundFile *_this, const uint8_t *lpStream, DWORD dwMemL
ord = calculated
*/
#if 0
if( (p=SDL_getenv(ABC_ENV_DUMPTRACKS)) ) {
if ((p=SDL_getenv(ABC_ENV_DUMPTRACKS)) != NULL) {
printf("P:%s\n",abcparts);
for( t=0; t<26; t++ )
if( partpat[t][1] >= partpat[t][0] )
Expand Down
1 change: 0 additions & 1 deletion src/libmodplug/load_mod.c
Expand Up @@ -6,7 +6,6 @@
*/

#include "libmodplug.h"
#include "tables.h"

//////////////////////////////////////////////////////////
// ProTracker / NoiseTracker MOD/NST file support
Expand Down
3 changes: 1 addition & 2 deletions src/libmodplug/load_s3m.c
Expand Up @@ -6,9 +6,8 @@
*/

#include "libmodplug.h"
#include "tables.h"

//////////////////////////////////////////////////////
////////////////////////////////////////////////////////
// ScreamTracker S3M file support

#pragma pack(1)
Expand Down
12 changes: 2 additions & 10 deletions src/libmodplug/tables.h
Expand Up @@ -23,7 +23,6 @@ static const WORD ProTrackerPeriodTable[6*12] =
53,50,47,45,42,40,37,35,33,31,30,28
};


static const WORD ProTrackerTunedPeriods[16*12] =
{
1712,1616,1524,1440,1356,1280,1208,1140,1076,1016,960,907,
Expand All @@ -44,7 +43,6 @@ static const WORD ProTrackerTunedPeriods[16*12] =
1724,1628,1536,1450,1368,1292,1220,1150,1086,1026,968,914
};


// S3M C-4 periods
static const WORD FreqS3MTable[16] =
{
Expand All @@ -53,7 +51,6 @@ static const WORD FreqS3MTable[16] =
0,0,0,0
};


// S3M FineTune frequencies
static const WORD S3MFineTuneTable[16] =
{
Expand Down Expand Up @@ -119,7 +116,6 @@ static const WORD XMPeriodTable[104] =
453,450,447,443,440,437,434,431
};


static const uint32_t XMLinearTable[768] =
{
535232,534749,534266,533784,533303,532822,532341,531861,
Expand Down Expand Up @@ -221,7 +217,6 @@ static const uint32_t XMLinearTable[768] =
269555,269312,269069,268826,268583,268341,268099,267857
};


static const int8_t ft2VibratoTable[256] =
{
0,-2,-3,-5,-6,-8,-9,-11,-12,-14,-16,-17,-19,-20,-22,-23,
Expand All @@ -243,21 +238,18 @@ static const int8_t ft2VibratoTable[256] =
};



static const DWORD FineLinearSlideUpTable[16] =
{
65536, 65595, 65654, 65714, 65773, 65832, 65892, 65951,
66011, 66071, 66130, 66190, 66250, 66309, 66369, 66429
};


static const DWORD FineLinearSlideDownTable[16] =
{
65535, 65477, 65418, 65359, 65300, 65241, 65182, 65123,
65065, 65006, 64947, 64888, 64830, 64772, 64713, 64645
};


static const DWORD LinearSlideUpTable[256] =
{
65536, 65773, 66010, 66249, 66489, 66729, 66971, 67213,
Expand Down Expand Up @@ -294,7 +286,6 @@ static const DWORD LinearSlideUpTable[256] =
160439, 161019, 161601, 162186, 162772, 163361, 163952, 164545,
};


static const DWORD LinearSlideDownTable[256] =
{
65536, 65299, 65064, 64830, 64596, 64363, 64131, 63900,
Expand Down Expand Up @@ -332,7 +323,7 @@ static const DWORD LinearSlideDownTable[256] =
26770, 26673, 26577, 26481, 26386, 26291, 26196, 26102,
};


#if 0
static const int SpectrumSinusTable[256*2] =
{
0, 1, 1, 2, 3, 3, 4, 5, 6, 7, 7, 8, 9, 10, 10, 11,
Expand Down Expand Up @@ -368,4 +359,5 @@ static const int SpectrumSinusTable[256*2] =
-24, -23, -22, -22, -21, -20, -20, -19, -18, -17, -17, -16, -15, -14, -14, -13,
-12, -11, -10, -10, -9, -8, -7, -7, -6, -5, -4, -3, -3, -2, -1, 0,
};
#endif

0 comments on commit 4d574e2

Please sign in to comment.