diff --git a/doc/TXTH.md b/doc/TXTH.md index d83aa6f9..679c0761 100644 --- a/doc/TXTH.md +++ b/doc/TXTH.md @@ -9,6 +9,10 @@ When an unsupported file is loaded (for instance "bgm01.snd"), vgmstream tries t If found and parsed correctly (the TXTH may be rejected if incorrect commands are found) vgmstream will try to play the file as described. Extension must be accepted/added to vgmstream (plugins like foobar2000 only load extensions from a whitelist in formats.c), or one could rename to any supported extension (like .vgmstream), or leave the file extensionless. +You can also use ".(sub).(ext).txth" (if the file is "filename.sub.ext"), to allow mixing slightly different files in the same folder. The "sub" part doesn't need to be an extension, for example: +- 001.1ch.str, 001.1ch.str may use .1ch.txth +- 003.2ch.str, 003.2ch.str may use .2ch.txth +- etc ## Example of a TXTH file For an unsupported bgm01.vag this would be a simple TXTH for it: diff --git a/src/meta/txth.c b/src/meta/txth.c index 0a5d8819..86798b69 100644 --- a/src/meta/txth.c +++ b/src/meta/txth.c @@ -477,8 +477,10 @@ fail: static STREAMFILE * open_txth(STREAMFILE * streamFile) { + char basename[PATH_LIMIT]; char filename[PATH_LIMIT]; char fileext[PATH_LIMIT]; + const char *subext; STREAMFILE * streamText; /* try "(path/)(name.ext).txth" */ @@ -487,6 +489,22 @@ static STREAMFILE * open_txth(STREAMFILE * streamFile) { streamText = open_streamfile(streamFile,filename); if (streamText) return streamText; + /* try "(path/)(.sub.ext).txth" */ + get_streamfile_basename(streamFile,basename,PATH_LIMIT); + subext = filename_extension(basename); + if (subext != NULL) { + get_streamfile_path(streamFile,filename,PATH_LIMIT); + get_streamfile_ext(streamFile,fileext,PATH_LIMIT); + strcat(filename,"."); + strcat(filename, subext); + strcat(filename,"."); + strcat(filename, fileext); + strcat(filename, ".txth"); + + streamText = open_streamfile(streamFile,filename); + if (streamText) return streamText; + } + /* try "(path/)(.ext).txth" */ get_streamfile_path(streamFile,filename,PATH_LIMIT); get_streamfile_ext(streamFile,fileext,PATH_LIMIT);