mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-01-19 00:04:04 +01:00
Clean up VGS meta to have it's own constant and proper description for use in the File Information dialog for Winamp plugin.
git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@890 51a99a44-fe44-0410-b1ba-c3e57ba2b86b
This commit is contained in:
parent
61e064dc4d
commit
56f31b8f4a
@ -1,33 +1,36 @@
|
||||
#include "meta.h"
|
||||
#include "../util.h"
|
||||
|
||||
/* VGS (Phantom of Inferno) */
|
||||
VGMSTREAM * init_vgmstream_ps2_vgs(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
char filename[260];
|
||||
|
||||
size_t fileLength;
|
||||
off_t readOffset = 0;
|
||||
off_t start_offset;
|
||||
off_t loop_start_offset;
|
||||
off_t loop_end_offset;
|
||||
|
||||
uint8_t testBuffer[0x10];
|
||||
int loop_flag = 0;
|
||||
int channel_count;
|
||||
|
||||
/* check extension, case insensitive */
|
||||
streamFile->get_name(streamFile,filename,sizeof(filename));
|
||||
if (strcasecmp("vgs",filename_extension(filename))) goto fail;
|
||||
|
||||
/* check header */
|
||||
if (read_32bitBE(0x00,streamFile) != 0x56475300)
|
||||
goto fail;
|
||||
|
||||
// get file length
|
||||
fileLength = get_streamfile_size(streamFile);
|
||||
|
||||
// Find loop start
|
||||
#include "meta.h"
|
||||
#include "../util.h"
|
||||
|
||||
/* VGS (Phantom of Inferno)
|
||||
|
||||
This format is used in _many_ Princess Soft games.
|
||||
*/
|
||||
VGMSTREAM * init_vgmstream_ps2_vgs(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
char filename[260];
|
||||
|
||||
size_t fileLength;
|
||||
off_t readOffset = 0;
|
||||
off_t start_offset;
|
||||
off_t loop_start_offset;
|
||||
off_t loop_end_offset;
|
||||
|
||||
uint8_t testBuffer[0x10];
|
||||
int loop_flag = 0;
|
||||
int channel_count;
|
||||
|
||||
/* check extension, case insensitive */
|
||||
streamFile->get_name(streamFile,filename,sizeof(filename));
|
||||
if (strcasecmp("vgs",filename_extension(filename))) goto fail;
|
||||
|
||||
/* check header */
|
||||
if (read_32bitBE(0x00,streamFile) != 0x56475300)
|
||||
goto fail;
|
||||
|
||||
// get file length
|
||||
fileLength = get_streamfile_size(streamFile);
|
||||
|
||||
// Find loop start
|
||||
do {
|
||||
readOffset += (off_t)read_streamfile(testBuffer, readOffset, 0x10, streamFile);
|
||||
|
||||
@ -38,12 +41,12 @@ VGMSTREAM * init_vgmstream_ps2_vgs(STREAMFILE *streamFile) {
|
||||
break;
|
||||
}
|
||||
|
||||
} while (streamFile->get_offset(streamFile)<((int32_t)fileLength));
|
||||
|
||||
// start at last line of file and move up
|
||||
readOffset = (int32_t)fileLength - 0x10;
|
||||
|
||||
// Find loop end
|
||||
} while (streamFile->get_offset(streamFile)<((int32_t)fileLength));
|
||||
|
||||
// start at last line of file and move up
|
||||
readOffset = (int32_t)fileLength - 0x10;
|
||||
|
||||
// Find loop end
|
||||
do {
|
||||
readOffset -= (off_t)read_streamfile(testBuffer, readOffset, 0x10, streamFile);
|
||||
|
||||
@ -53,67 +56,67 @@ VGMSTREAM * init_vgmstream_ps2_vgs(STREAMFILE *streamFile) {
|
||||
loop_end_offset = readOffset + 0x20;
|
||||
break;
|
||||
}
|
||||
} while (readOffset > 0);
|
||||
|
||||
// setup loops
|
||||
if (loop_start_offset > 0)
|
||||
{
|
||||
loop_flag = 1;
|
||||
|
||||
// if we have a start loop, use EOF if end loop is not found
|
||||
if (loop_end_offset == 0)
|
||||
{
|
||||
loop_end_offset = (int32_t)fileLength - 0x10;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
loop_flag = 0;
|
||||
}
|
||||
|
||||
channel_count = 2;
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
/* fill in the vital statistics */
|
||||
start_offset = 0x30;
|
||||
vgmstream->channels = channel_count;
|
||||
vgmstream->sample_rate = read_32bitBE(0x10,streamFile);
|
||||
vgmstream->coding_type = coding_PSX;
|
||||
vgmstream->num_samples = ((get_streamfile_size(streamFile)-0x30)/16/channel_count*28);
|
||||
|
||||
if (loop_flag)
|
||||
{
|
||||
vgmstream->loop_start_sample = loop_start_offset/16/channel_count*28;
|
||||
vgmstream->loop_end_sample = loop_end_offset/16/channel_count*28;
|
||||
}
|
||||
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = read_32bitBE(0x04,streamFile)*0x1000;
|
||||
vgmstream->meta_type = meta_PSX_FAG;
|
||||
|
||||
/* open the file for reading */
|
||||
{
|
||||
int i;
|
||||
STREAMFILE * file;
|
||||
file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
|
||||
if (!file) goto fail;
|
||||
for (i=0;i<channel_count;i++) {
|
||||
vgmstream->ch[i].streamfile = file;
|
||||
|
||||
vgmstream->ch[i].channel_start_offset=
|
||||
vgmstream->ch[i].offset=start_offset+
|
||||
vgmstream->interleave_block_size*i;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return vgmstream;
|
||||
|
||||
/* clean up anything we may have opened */
|
||||
fail:
|
||||
if (vgmstream) close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
||||
} while (readOffset > 0);
|
||||
|
||||
// setup loops
|
||||
if (loop_start_offset > 0)
|
||||
{
|
||||
loop_flag = 1;
|
||||
|
||||
// if we have a start loop, use EOF if end loop is not found
|
||||
if (loop_end_offset == 0)
|
||||
{
|
||||
loop_end_offset = (int32_t)fileLength - 0x10;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
loop_flag = 0;
|
||||
}
|
||||
|
||||
channel_count = 2;
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
/* fill in the vital statistics */
|
||||
start_offset = 0x30;
|
||||
vgmstream->channels = channel_count;
|
||||
vgmstream->sample_rate = read_32bitBE(0x10,streamFile);
|
||||
vgmstream->coding_type = coding_PSX;
|
||||
vgmstream->num_samples = ((get_streamfile_size(streamFile)-0x30)/16/channel_count*28);
|
||||
|
||||
if (loop_flag)
|
||||
{
|
||||
vgmstream->loop_start_sample = loop_start_offset/16/channel_count*28;
|
||||
vgmstream->loop_end_sample = loop_end_offset/16/channel_count*28;
|
||||
}
|
||||
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = read_32bitBE(0x04,streamFile)*0x1000;
|
||||
vgmstream->meta_type = meta_PS2_VGS;
|
||||
|
||||
/* open the file for reading */
|
||||
{
|
||||
int i;
|
||||
STREAMFILE * file;
|
||||
file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
|
||||
if (!file) goto fail;
|
||||
for (i=0;i<channel_count;i++) {
|
||||
vgmstream->ch[i].streamfile = file;
|
||||
|
||||
vgmstream->ch[i].channel_start_offset=
|
||||
vgmstream->ch[i].offset=start_offset+
|
||||
vgmstream->interleave_block_size*i;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return vgmstream;
|
||||
|
||||
/* clean up anything we may have opened */
|
||||
fail:
|
||||
if (vgmstream) close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -2735,6 +2735,9 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) {
|
||||
break;
|
||||
case meta_X360_TRA:
|
||||
snprintf(temp,TEMPSIZE,"assumed DefJam Rapstar Audio File by .tra extension");
|
||||
break;
|
||||
case meta_PS2_VGS:
|
||||
snprintf(temp,TEMPSIZE,"Princess Soft VGS header");
|
||||
break;
|
||||
default:
|
||||
snprintf(temp,TEMPSIZE,"THEY SHOULD HAVE SENT A POET");
|
||||
|
@ -501,6 +501,7 @@ typedef enum {
|
||||
meta_WII_RAS, /* Donkey Kong Country Returns (Wii) */
|
||||
meta_PS2_SPM, /* Lethal Skies Elite Pilot: Team SW */
|
||||
meta_X360_TRA, /* Def Jam Rapstar */
|
||||
meta_PS2_VGS, // Princess Soft PS2 games
|
||||
} meta_t;
|
||||
|
||||
typedef struct {
|
||||
|
Loading…
x
Reference in New Issue
Block a user