DUMB: Fixed DSMI AMF panning and sample loops

CQTexperiment
Chris Moeller 2013-12-02 23:11:50 -08:00
parent b3d19ba78c
commit a87312b2da
1 changed files with 55 additions and 22 deletions

View File

@ -72,9 +72,15 @@ static void it_amf_process_track( IT_ENTRY *entry_table, unsigned char *track, i
else effectvalue = ( effectvalue & 0x0F ) << 4; else effectvalue = ( effectvalue & 0x0F ) << 4;
break; break;
case 0x04: if ( effectvalue & 0x80 ) { effect = IT_PORTAMENTO_UP; effectvalue = ( -( signed char ) effectvalue ) & 0x7F; } case 0x04:
else { effect = IT_PORTAMENTO_DOWN; } if ( effectvalue & 0x80 ) {
break; effect = IT_PORTAMENTO_UP;
effectvalue = ( -( signed char ) effectvalue ) & 0x7F;
}
else {
effect = IT_PORTAMENTO_DOWN;
}
break;
case 0x06: effect = IT_TONE_PORTAMENTO; break; case 0x06: effect = IT_TONE_PORTAMENTO; break;
@ -92,30 +98,57 @@ static void it_amf_process_track( IT_ENTRY *entry_table, unsigned char *track, i
case 0x10: effect = IT_SET_SAMPLE_OFFSET; break; case 0x10: effect = IT_SET_SAMPLE_OFFSET; break;
case 0x11: if ( effectvalue ) { effect = IT_VOLUME_SLIDE; case 0x11:
if ( effectvalue & 0x80 ) effectvalue = 0xF0 | ( ( -( signed char ) effectvalue ) & 0x0F ); if ( effectvalue ) {
else effectvalue = 0x0F | ( ( effectvalue & 0x0F ) << 4 ); effect = IT_VOLUME_SLIDE;
} else effect = 0; if ( effectvalue & 0x80 )
break; effectvalue = 0xF0 | ( ( -( signed char ) effectvalue ) & 0x0F );
else
effectvalue = 0x0F | ( ( effectvalue & 0x0F ) << 4 );
}
else
effect = 0;
break;
case 0x12: case 0x12:
case 0x16: if ( effectvalue ) { int mask = ( effect == 0x16 ) ? 0xE0 : 0xF0; case 0x16:
effect = ( effectvalue & 0x80 ) ? IT_PORTAMENTO_UP : IT_PORTAMENTO_DOWN; if ( effectvalue ) {
if ( effectvalue & 0x80 ) effectvalue = mask | ( ( -( signed char ) effectvalue ) & 0x0F ); int mask = ( effect == 0x16 ) ? 0xE0 : 0xF0;
else effectvalue = mask | ( effectvalue & 0x0F ); effect = ( effectvalue & 0x80 ) ? IT_PORTAMENTO_UP : IT_PORTAMENTO_DOWN;
} else effect = 0; if ( effectvalue & 0x80 )
break; effectvalue = mask | ( ( -( signed char ) effectvalue ) & 0x0F );
else
effectvalue = mask | ( effectvalue & 0x0F );
}
else
effect = 0;
break;
case 0x13: effect = IT_S; effectvalue = EFFECT_VALUE( IT_S_NOTE_DELAY, effectvalue & 0x0F ); break; case 0x13:
effect = IT_S;
effectvalue = EFFECT_VALUE( IT_S_NOTE_DELAY, effectvalue & 0x0F );
break;
case 0x14: effect = IT_S; effectvalue = EFFECT_VALUE( IT_S_DELAYED_NOTE_CUT, effectvalue & 0x0F ); break; case 0x14:
effect = IT_S;
effectvalue = EFFECT_VALUE( IT_S_DELAYED_NOTE_CUT, effectvalue & 0x0F );
break;
case 0x15: effect = IT_SET_SONG_TEMPO; break; case 0x15: effect = IT_SET_SONG_TEMPO; break;
case 0x17: effectvalue = ( effectvalue + 64 ) & 0x7F; case 0x17:
if ( entry->mask & IT_ENTRY_EFFECT ) { if ( !( entry->mask & IT_ENTRY_VOLPAN ) ) { entry->volpan = ( effectvalue / 2 ) + 128; } effect = 0; } effectvalue = ( effectvalue + 64 ) & 0x7F;
else { effect = IT_SET_PANNING; } if ( entry->mask & IT_ENTRY_EFFECT ) {
break; if ( !( entry->mask & IT_ENTRY_VOLPAN ) ) {
entry->mask |= IT_ENTRY_VOLPAN;
entry->volpan = ( effectvalue / 2 ) + 128;
}
effect = 0;
}
else {
effect = IT_SET_PANNING;
}
break;
default: effect = effectvalue = 0; default: effect = effectvalue = 0;
} }
@ -202,7 +235,7 @@ static int it_amf_read_sample_header( IT_SAMPLE *sample, DUMBFILE *f, int * offs
sample->default_pan = 0; sample->default_pan = 0;
sample->finetune = 0; sample->finetune = 0;
if ( sample->loop_start != 0 ) if ( sample->loop_end > sample->loop_start + 2 && sample->loop_end <= sample->length )
sample->flags |= IT_SAMPLE_LOOP; sample->flags |= IT_SAMPLE_LOOP;
sample->vibrato_speed = 0; sample->vibrato_speed = 0;
@ -457,7 +490,7 @@ static DUMB_IT_SIGDATA *it_amf_load_sigdata(DUMBFILE *f, int * version)
} }
/* Now let's initialise the remaining variables, and we're done! */ /* Now let's initialise the remaining variables, and we're done! */
sigdata->flags = IT_OLD_EFFECTS | IT_COMPATIBLE_GXX | IT_STEREO; sigdata->flags = IT_OLD_EFFECTS | IT_COMPATIBLE_GXX | IT_STEREO | IT_WAS_AN_S3M;
sigdata->global_volume = 128; sigdata->global_volume = 128;
sigdata->mixing_volume = 48; sigdata->mixing_volume = 48;