mirror of
https://github.com/ZDoom/gzdoom-last-svn.git
synced 2025-05-30 00:41:19 +00:00
* Updated to ZDoom 4110:
- Updated DUMB revision. git-svn-id: http://mancubus.net/svn/hosted/gzdoom/trunk@1522 b0f79afe-0144-0410-b225-9a4edf0717df
This commit is contained in:
parent
726870fe1f
commit
e92ba44352
10 changed files with 128 additions and 51 deletions
|
@ -233,7 +233,6 @@ int32 DUMBEXPORT duh_get_length(DUH *duh);
|
|||
|
||||
const char *DUMBEXPORT duh_get_tag(DUH *duh, const char *key);
|
||||
|
||||
|
||||
/* Signal Rendering Functions */
|
||||
|
||||
typedef struct DUH_SIGRENDERER DUH_SIGRENDERER;
|
||||
|
@ -396,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);
|
||||
|
@ -610,6 +611,8 @@ sigdata_t *DUMBEXPORT duh_get_raw_sigdata(DUH *duh, int sig, int32 type);
|
|||
DUH_SIGRENDERER *DUMBEXPORT duh_encapsulate_raw_sigrenderer(sigrenderer_t *vsigrenderer, DUH_SIGTYPE_DESC *desc, int n_channels, int32 pos);
|
||||
sigrenderer_t *DUMBEXPORT duh_get_raw_sigrenderer(DUH_SIGRENDERER *sigrenderer, int32 type);
|
||||
|
||||
int DUMBEXPORT duh_add_signal(DUH *duh, DUH_SIGTYPE_DESC *desc, sigdata_t *sigdata);
|
||||
|
||||
|
||||
/* Standard Signal Types */
|
||||
|
||||
|
|
|
@ -130,3 +130,22 @@ DUH *make_duh(
|
|||
|
||||
return duh;
|
||||
}
|
||||
|
||||
int DUMBEXPORT duh_add_signal(DUH *duh, DUH_SIGTYPE_DESC *desc, sigdata_t *sigdata)
|
||||
{
|
||||
DUH_SIGNAL **signal;
|
||||
|
||||
if ( !duh || !desc || !sigdata ) return -1;
|
||||
|
||||
signal = ( DUH_SIGNAL ** ) realloc( duh->signal, ( duh->n_signals + 1 ) * sizeof( *duh->signal ) );
|
||||
if ( !signal ) return -1;
|
||||
duh->signal = signal;
|
||||
|
||||
memmove( signal + 1, signal, duh->n_signals * sizeof( *signal ) );
|
||||
duh->n_signals++;
|
||||
|
||||
signal[ 0 ] = make_signal( desc, sigdata );
|
||||
if ( !signal[ 0 ] ) return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -29,16 +29,30 @@
|
|||
*/
|
||||
sigdata_t *DUMBEXPORT duh_get_raw_sigdata(DUH *duh, int sig, int32 type)
|
||||
{
|
||||
int i;
|
||||
DUH_SIGNAL *signal;
|
||||
|
||||
if (!duh) return NULL;
|
||||
|
||||
if ((unsigned int)sig >= (unsigned int)duh->n_signals) return NULL;
|
||||
if ( sig >= 0 )
|
||||
{
|
||||
if ((unsigned int)sig >= (unsigned int)duh->n_signals) return NULL;
|
||||
|
||||
signal = duh->signal[sig];
|
||||
signal = duh->signal[sig];
|
||||
|
||||
if (signal && signal->desc->type == type)
|
||||
return signal->sigdata;
|
||||
if (signal && signal->desc->type == type)
|
||||
return signal->sigdata;
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( i = 0; i < duh->n_signals; i++ )
|
||||
{
|
||||
signal = duh->signal[i];
|
||||
|
||||
if (signal && signal->desc->type == type)
|
||||
return signal->sigdata;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
DUMB_IT_SIGDATA *DUMBEXPORT duh_get_it_sigdata(DUH *duh)
|
||||
{
|
||||
return duh_get_raw_sigdata(duh, 0, SIGTYPE_IT);
|
||||
return duh_get_raw_sigdata(duh, -1, SIGTYPE_IT);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1350,9 +1350,11 @@ DUH *DUMBEXPORT dumb_read_it_quick(DUMBFILE *f)
|
|||
return NULL;
|
||||
|
||||
{
|
||||
const char *tag[1][2];
|
||||
const char *tag[2][2];
|
||||
tag[0][0] = "TITLE";
|
||||
tag[0][1] = ((DUMB_IT_SIGDATA *)sigdata)->name;
|
||||
return make_duh(-1, 1, (const char *const (*)[2])tag, 1, &descptr, &sigdata);
|
||||
tag[1][0] = "FORMAT";
|
||||
tag[1][1] = "IT";
|
||||
return make_duh(-1, 2, (const char *const (*)[2])tag, 1, &descptr, &sigdata);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3722,7 +3722,7 @@ static int update_it_envelope(IT_PLAYING *playing, IT_ENVELOPE *envelope, IT_PLA
|
|||
}
|
||||
|
||||
pe->tick++;
|
||||
while (pe->tick >= envelope->node_t[pe->next_node]) {
|
||||
while (pe->tick > envelope->node_t[pe->next_node]) {
|
||||
pe->next_node++;
|
||||
if ((envelope->flags & IT_ENVELOPE_SUSTAIN_LOOP) && !(playing->flags & IT_PLAYING_SUSTAINOFF)) {
|
||||
if (pe->next_node > envelope->sus_loop_end) {
|
||||
|
|
|
@ -393,10 +393,12 @@ static DUMBFILE *dumbfile_buffer_mod(DUMBFILE *f, uint32 *fft)
|
|||
return dumbfile_open_ex(bm, &buffer_mod_dfs);
|
||||
}
|
||||
|
||||
static DUMBFILE *dumbfile_buffer_mod_2(DUMBFILE *f, int32 *remain)
|
||||
static DUMBFILE *dumbfile_buffer_mod_2(DUMBFILE *f, int n_samples, IT_SAMPLE *sample, int32 *total_sample_size, int32 *remain)
|
||||
{
|
||||
int32 read;
|
||||
int sample_number;
|
||||
BUFFERED_MOD *bm = malloc(sizeof(*bm));
|
||||
unsigned char *ptr;
|
||||
if (!bm) return NULL;
|
||||
|
||||
bm->buffered = malloc(32768);
|
||||
|
@ -430,6 +432,21 @@ static DUMBFILE *dumbfile_buffer_mod_2(DUMBFILE *f, int32 *remain)
|
|||
|
||||
if (*remain) {
|
||||
bm->ptr = 0;
|
||||
ptr = bm->buffered + *remain;
|
||||
sample_number = n_samples - 1;
|
||||
*total_sample_size = 0;
|
||||
while (ptr > bm->buffered && sample_number >= 0) {
|
||||
if (sample[sample_number].flags & IT_SAMPLE_EXISTS) {
|
||||
ptr -= (sample[sample_number].length + 1) / 2 + 5 + 16;
|
||||
if (ptr >= bm->buffered && !memcmp(ptr, "ADPCM", 5)) { /* BAH */
|
||||
*total_sample_size += (sample[sample_number].length + 1) / 2 + 5 + 16;
|
||||
} else {
|
||||
*total_sample_size += sample[sample_number].length;
|
||||
ptr -= sample[sample_number].length - ((sample[sample_number].length + 1) / 2 + 5 + 16);
|
||||
}
|
||||
}
|
||||
sample_number--;
|
||||
}
|
||||
} else {
|
||||
free(bm->buffered);
|
||||
bm->buffered = NULL;
|
||||
|
@ -447,7 +464,7 @@ static DUMB_IT_SIGDATA *it_mod_load_sigdata(DUMBFILE *f, int rstrict)
|
|||
int n_channels;
|
||||
int i;
|
||||
uint32 fft = 0;
|
||||
DUMBFILE *rem;
|
||||
DUMBFILE *rem = NULL;
|
||||
|
||||
f = dumbfile_buffer_mod(f, &fft);
|
||||
if (!f)
|
||||
|
@ -550,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);
|
||||
|
@ -629,12 +646,48 @@ static DUMB_IT_SIGDATA *it_mod_load_sigdata(DUMBFILE *f, int rstrict)
|
|||
if (sigdata->n_samples == 31)
|
||||
dumbfile_skip(f, 4);
|
||||
|
||||
/* Work out how many patterns there are. */
|
||||
sigdata->n_patterns = -1;
|
||||
for (i = 0; i < sigdata->n_orders; i++)
|
||||
if (sigdata->n_patterns < sigdata->order[i])
|
||||
sigdata->n_patterns = sigdata->order[i];
|
||||
sigdata->n_patterns++;
|
||||
|
||||
if ( !( rstrict & 2 ) )
|
||||
{
|
||||
long total_sample_size;
|
||||
long remain;
|
||||
rem = f;
|
||||
f = dumbfile_buffer_mod_2(rem, sigdata->n_samples, sigdata->sample, &total_sample_size, &remain);
|
||||
if (!f) {
|
||||
_dumb_it_unload_sigdata(sigdata);
|
||||
dumbfile_close(rem);
|
||||
return NULL;
|
||||
}
|
||||
if (remain > total_sample_size) {
|
||||
sigdata->n_patterns = ( remain - total_sample_size + 4 ) / ( 256 * sigdata->n_pchannels );
|
||||
if (fft == DUMB_ID('M',0,0,0) || fft == DUMB_ID('8',0,0,0)) {
|
||||
remain -= sigdata->n_patterns * 256 * sigdata->n_pchannels;
|
||||
if (dumbfile_skip(f, remain - total_sample_size)) {
|
||||
_dumb_it_unload_sigdata(sigdata);
|
||||
dumbfile_close(f);
|
||||
dumbfile_close(rem);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
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);
|
||||
if (rem) dumbfile_close(rem);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* May as well try to save a tiny bit of memory. */
|
||||
if (sigdata->n_orders < 128) {
|
||||
|
@ -646,6 +699,7 @@ static DUMB_IT_SIGDATA *it_mod_load_sigdata(DUMBFILE *f, int rstrict)
|
|||
if (!sigdata->pattern) {
|
||||
_dumb_it_unload_sigdata(sigdata);
|
||||
dumbfile_close(f);
|
||||
if (rem) dumbfile_close(rem);
|
||||
return NULL;
|
||||
}
|
||||
for (i = 0; i < sigdata->n_patterns; i++)
|
||||
|
@ -653,10 +707,11 @@ static DUMB_IT_SIGDATA *it_mod_load_sigdata(DUMBFILE *f, int rstrict)
|
|||
|
||||
/* Read in the patterns */
|
||||
{
|
||||
unsigned char *buffer = malloc(256 * n_channels); /* 64 rows * 4 bytes */
|
||||
unsigned char *buffer = malloc(256 * sigdata->n_pchannels); /* 64 rows * 4 bytes */
|
||||
if (!buffer) {
|
||||
_dumb_it_unload_sigdata(sigdata);
|
||||
dumbfile_close(f);
|
||||
if (rem) dumbfile_close(rem);
|
||||
return NULL;
|
||||
}
|
||||
for (i = 0; i < sigdata->n_patterns; i++) {
|
||||
|
@ -664,40 +719,13 @@ static DUMB_IT_SIGDATA *it_mod_load_sigdata(DUMBFILE *f, int rstrict)
|
|||
free(buffer);
|
||||
_dumb_it_unload_sigdata(sigdata);
|
||||
dumbfile_close(f);
|
||||
if (rem) dumbfile_close(rem);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
rem = NULL;
|
||||
|
||||
/* uggly */
|
||||
if (fft == DUMB_ID('M',0,0,0) || fft == DUMB_ID('8',0,0,0)) {
|
||||
int32 skip;
|
||||
int32 remain;
|
||||
rem = f;
|
||||
f = dumbfile_buffer_mod_2(rem, &remain);
|
||||
if (!f) {
|
||||
_dumb_it_unload_sigdata(sigdata);
|
||||
dumbfile_close(rem);
|
||||
return NULL;
|
||||
}
|
||||
for (skip = 0, i = 0; i < sigdata->n_samples; i++) {
|
||||
if (sigdata->sample[i].flags & IT_SAMPLE_EXISTS) {
|
||||
skip += sigdata->sample[i].length;
|
||||
}
|
||||
}
|
||||
if (remain - skip) {
|
||||
if (dumbfile_skip(f, remain - skip)) {
|
||||
_dumb_it_unload_sigdata(sigdata);
|
||||
dumbfile_close(f);
|
||||
dumbfile_close(rem);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* And finally, the sample data */
|
||||
for (i = 0; i < sigdata->n_samples; i++) {
|
||||
if (it_mod_read_sample_data(&sigdata->sample[i], f, fft)) {
|
||||
|
@ -727,8 +755,8 @@ static DUMB_IT_SIGDATA *it_mod_load_sigdata(DUMBFILE *f, int rstrict)
|
|||
}*/
|
||||
|
||||
dumbfile_close(f); /* Destroy the BUFFERED_MOD DUMBFILE we were using. */
|
||||
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. */
|
||||
if (rem) dumbfile_close(rem);
|
||||
|
||||
/* Now let's initialise the remaining variables, and we're done! */
|
||||
sigdata->flags = IT_WAS_AN_XM | IT_WAS_A_MOD | IT_OLD_EFFECTS | IT_COMPATIBLE_GXX | IT_STEREO;
|
||||
|
|
|
@ -319,7 +319,7 @@ unsigned get_chunk_count(IFF_CHUNKED *mod, unsigned type)
|
|||
}
|
||||
|
||||
|
||||
static DUMB_IT_SIGDATA *it_okt_load_sigdata(DUMBFILE *f, int restrict)
|
||||
static DUMB_IT_SIGDATA *it_okt_load_sigdata(DUMBFILE *f)
|
||||
{
|
||||
DUMB_IT_SIGDATA *sigdata;
|
||||
unsigned n_channels;
|
||||
|
@ -544,7 +544,7 @@ DUH *DUMBEXPORT dumb_read_okt_quick(DUMBFILE *f)
|
|||
|
||||
DUH_SIGTYPE_DESC *descptr = &_dumb_sigtype_it;
|
||||
|
||||
sigdata = it_okt_load_sigdata(f, 0);
|
||||
sigdata = it_okt_load_sigdata(f);
|
||||
|
||||
if (!sigdata)
|
||||
return NULL;
|
||||
|
|
|
@ -117,6 +117,14 @@ XM_INSTRUMENT_EXTRA;
|
|||
|
||||
|
||||
|
||||
/* Trims off trailing white space, usually added by the tracker on file creation
|
||||
*/
|
||||
static void trim_whitespace(char *ptr, size_t size)
|
||||
{
|
||||
char *p = ptr + size - 1;
|
||||
while (p >= ptr && *p <= 0x20) *p-- = '\0';
|
||||
}
|
||||
|
||||
/* Frees the original block if it can't resize it or if size is 0, and acts
|
||||
* as malloc if ptr is NULL.
|
||||
*/
|
||||
|
@ -506,6 +514,7 @@ static int it_xm_read_instrument(IT_INSTRUMENT *instrument, XM_INSTRUMENT_EXTRA
|
|||
|
||||
dumbfile_getnc(instrument->name, 22, f);
|
||||
instrument->name[22] = 0;
|
||||
trim_whitespace(instrument->name, 22);
|
||||
instrument->filename[0] = 0;
|
||||
dumbfile_skip(f, 1); /* Instrument type. Should be 0, but seems random. */
|
||||
extra->n_samples = dumbfile_igetw(f);
|
||||
|
@ -665,6 +674,7 @@ static int it_xm_read_sample_header(IT_SAMPLE *sample, DUMBFILE *f)
|
|||
|
||||
dumbfile_getnc(sample->name, 22, f);
|
||||
sample->name[22] = 0;
|
||||
trim_whitespace(sample->name, 22);
|
||||
|
||||
sample->filename[0] = 0;
|
||||
|
||||
|
@ -919,6 +929,7 @@ static DUMB_IT_SIGDATA *it_xm_load_sigdata(DUMBFILE *f, int * version)
|
|||
return NULL;
|
||||
}
|
||||
sigdata->name[20] = 0;
|
||||
trim_whitespace(sigdata->name, 20);
|
||||
|
||||
if (dumbfile_getc(f) != 0x1A) {
|
||||
TRACE("XM error: 0x1A not found\n");
|
||||
|
|
|
@ -3,5 +3,5 @@
|
|||
// This file was automatically generated by the
|
||||
// updaterevision tool. Do not edit by hand.
|
||||
|
||||
#define ZD_SVN_REVISION_STRING "4100"
|
||||
#define ZD_SVN_REVISION_NUMBER 4100
|
||||
#define ZD_SVN_REVISION_STRING "4110"
|
||||
#define ZD_SVN_REVISION_NUMBER 4110
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue