From b95e4b971e051837f02a60b4e86d90df4b76ab97 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Fri, 8 Feb 2013 01:04:38 +0000 Subject: [PATCH] Update DUMB to revision 5b53815e1f271746627bde0bfce7140109b88f14 - Made the new MOD pattern counting system optional SVN r4106 (trunk) --- dumb/include/dumb.h | 2 ++ dumb/src/it/readmod.c | 25 ++++++++++++++++++------- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/dumb/include/dumb.h b/dumb/include/dumb.h index f0799c7fa..bcd202298 100644 --- a/dumb/include/dumb.h +++ b/dumb/include/dumb.h @@ -395,6 +395,8 @@ void DUMBEXPORT dumb_it_set_global_volume_zero_callback(DUMB_IT_SIGRENDERER *sig int DUMBCALLBACK dumb_it_callback_terminate(void *data); int DUMBCALLBACK dumb_it_callback_midi_block(void *data, int channel, unsigned char midi_byte); +/* dumb_*_mod*: restrict |= 1-Don't read 15 sample files / 2-Use old pattern counting method */ + DUH *DUMBEXPORT dumb_load_it(const char *filename); DUH *DUMBEXPORT dumb_load_xm(const char *filename); DUH *DUMBEXPORT dumb_load_s3m(const char *filename); diff --git a/dumb/src/it/readmod.c b/dumb/src/it/readmod.c index 03ff0ff62..fcfa18824 100644 --- a/dumb/src/it/readmod.c +++ b/dumb/src/it/readmod.c @@ -567,7 +567,7 @@ static DUMB_IT_SIGDATA *it_mod_load_sigdata(DUMBFILE *f, int rstrict) } // moo - if ( rstrict && sigdata->n_samples == 15 ) + if ( ( rstrict & 1 ) && sigdata->n_samples == 15 ) { free(sigdata); dumbfile_close(f); @@ -648,6 +648,7 @@ static DUMB_IT_SIGDATA *it_mod_load_sigdata(DUMBFILE *f, int rstrict) sigdata->n_patterns = -1; + if ( !( rstrict & 2 ) ) { long total_sample_size; long remain; @@ -671,11 +672,21 @@ static DUMB_IT_SIGDATA *it_mod_load_sigdata(DUMBFILE *f, int rstrict) } } } + else + { + sigdata->n_patterns = 0; + for (i = 0; i < sigdata->n_orders; i++) + { + if (sigdata->order[i] > sigdata->n_patterns) + sigdata->n_patterns = sigdata->order[i]; + } + sigdata->n_patterns++; + } if ( sigdata->n_patterns <= 0 ) { _dumb_it_unload_sigdata(sigdata); dumbfile_close(f); - dumbfile_close(rem); + if (rem) dumbfile_close(rem); return NULL; } @@ -689,7 +700,7 @@ static DUMB_IT_SIGDATA *it_mod_load_sigdata(DUMBFILE *f, int rstrict) if (!sigdata->pattern) { _dumb_it_unload_sigdata(sigdata); dumbfile_close(f); - dumbfile_close(rem); + if (rem) dumbfile_close(rem); return NULL; } for (i = 0; i < sigdata->n_patterns; i++) @@ -701,7 +712,7 @@ static DUMB_IT_SIGDATA *it_mod_load_sigdata(DUMBFILE *f, int rstrict) if (!buffer) { _dumb_it_unload_sigdata(sigdata); dumbfile_close(f); - dumbfile_close(rem); + if (rem) dumbfile_close(rem); return NULL; } for (i = 0; i < sigdata->n_patterns; i++) { @@ -709,7 +720,7 @@ static DUMB_IT_SIGDATA *it_mod_load_sigdata(DUMBFILE *f, int rstrict) free(buffer); _dumb_it_unload_sigdata(sigdata); dumbfile_close(f); - dumbfile_close(rem); + if (rem) dumbfile_close(rem); return NULL; } } @@ -721,7 +732,7 @@ static DUMB_IT_SIGDATA *it_mod_load_sigdata(DUMBFILE *f, int rstrict) if (it_mod_read_sample_data(&sigdata->sample[i], f, fft)) { _dumb_it_unload_sigdata(sigdata); dumbfile_close(f); - dumbfile_close(rem); + if (rem) dumbfile_close(rem); return NULL; } } @@ -745,7 +756,7 @@ static DUMB_IT_SIGDATA *it_mod_load_sigdata(DUMBFILE *f, int rstrict) }*/ dumbfile_close(f); /* Destroy the BUFFERED_MOD DUMBFILE we were using. */ - dumbfile_close(rem); /* And the BUFFERED_MOD DUMBFILE used to pre-read the signature. */ + if (rem) dumbfile_close(rem); /* And the BUFFERED_MOD DUMBFILE used to pre-read the signature. */ /* The DUMBFILE originally passed to our function is intact. */ /* Now let's initialise the remaining variables, and we're done! */