Add TXTP command #sN for subsong N (#N still works)

This commit is contained in:
bnnm 2018-09-04 23:53:25 +02:00
parent 59b303d753
commit 131340882b

View File

@ -205,12 +205,7 @@ static int add_filename(txtp_header * txtp, char *filename) {
//;VGM_LOG("TXTP: filename=%s\n", filename);
/* parse config:
* - file.ext#2 = play subsong 2
* - file.ext#2~10 = play subsongs in 2 to 10 range
* - file.ext#c1,2 = play channels 1,2
* - file.ext#m1-2,3-4 = swaps channels 1<>2 and 3<>4
*/
/* parse config: file.ext#(command) */
{
char *config;
@ -230,10 +225,10 @@ static int add_filename(txtp_header * txtp, char *filename) {
config[0] = '\0';
config++;
//todo: alt long words, s or number=subsong
if (config[0] == 'c') {
/* mask channels */
/* channel mask */
/* - file.ext#c1,2 = play channels 1,2 */
int n, ch;
config++;
@ -251,6 +246,7 @@ static int add_filename(txtp_header * txtp, char *filename) {
}
else if (config[0] == 'm') {
/* channel mappings */
/* - file.ext#m1-2,3-4 = swaps channels 1<>2 and 3<>4 */
int n, ch_from = 0, ch_to = 0;
config++;
@ -278,10 +274,17 @@ static int add_filename(txtp_header * txtp, char *filename) {
}
}
}
else {
/* subsong range */
else if (config[0] == 's' || (config[0] >= '0' && config[0] <= '9')) {
/* subsongs */
/* - file.ext#2 = play subsong 2 */
/* - file.ext#s3 = play subsong 3 */
/* - file.ext#2~10 = play subsong range */
int subsong_start = 0, subsong_end = 0;
if (config[0]== 's')
config++;
if (sscanf(config, "%d~%d", &subsong_start, &subsong_end) == 2) {
if (subsong_start > 0 && subsong_end > 0) {
range_start = subsong_start-1;
@ -298,6 +301,10 @@ static int add_filename(txtp_header * txtp, char *filename) {
config = NULL; /* wrong config, ignore */
}
}
else {
VGM_LOG("TXTP: unknown command\n");
goto fail;
}
} while (config != NULL);