mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-01-31 04:13:47 +01:00
Forgot to close header file for PS2 WMUS.
git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@922 51a99a44-fe44-0410-b1ba-c3e57ba2b86b
This commit is contained in:
parent
ef1aa13b3d
commit
8489991ec9
@ -1,101 +1,102 @@
|
||||
#include "meta.h"
|
||||
#include "../util.h"
|
||||
|
||||
#include "meta.h"
|
||||
#include "../util.h"
|
||||
|
||||
//#include <windows.h>
|
||||
//#include <tchar.h>
|
||||
|
||||
/* WMUS - Arbitrary extension chosen for The Warriors (PS2) */
|
||||
|
||||
VGMSTREAM * init_vgmstream_ps2_wmus(STREAMFILE *streamFile)
|
||||
{
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
char filename[260];
|
||||
|
||||
int loop_flag = 1;
|
||||
int channel_count;
|
||||
off_t start_offset;
|
||||
int i;
|
||||
|
||||
int blockCount;
|
||||
int shortBlockSize;
|
||||
int lastBlockLocation;
|
||||
|
||||
char filenameWHED[260];
|
||||
STREAMFILE * streamFileWHED = NULL;
|
||||
|
||||
//_TCHAR szBuffer[100];
|
||||
|
||||
/* check extension, case insensitive */
|
||||
streamFile->get_name(streamFile,filename,sizeof(filename));
|
||||
|
||||
if (strcasecmp("wmus",filename_extension(filename)))
|
||||
{
|
||||
goto fail;
|
||||
}
|
||||
//#include <tchar.h>
|
||||
|
||||
/* WMUS - Arbitrary extension chosen for The Warriors (PS2) */
|
||||
|
||||
VGMSTREAM * init_vgmstream_ps2_wmus(STREAMFILE *streamFile)
|
||||
{
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
char filename[260];
|
||||
|
||||
int loop_flag = 1;
|
||||
int channel_count;
|
||||
off_t start_offset;
|
||||
int i;
|
||||
|
||||
int blockCount;
|
||||
int shortBlockSize;
|
||||
int lastBlockLocation;
|
||||
|
||||
char filenameWHED[260];
|
||||
STREAMFILE * streamFileWHED = NULL;
|
||||
|
||||
//_TCHAR szBuffer[100];
|
||||
|
||||
/* check extension, case insensitive */
|
||||
streamFile->get_name(streamFile,filename,sizeof(filename));
|
||||
|
||||
if (strcasecmp("wmus",filename_extension(filename)))
|
||||
{
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* check for .WHED file */
|
||||
strcpy(filenameWHED, filename);
|
||||
strcpy(filenameWHED + strlen(filenameWHED) - 4, "WHED");
|
||||
|
||||
strcpy(filenameWHED + strlen(filenameWHED) - 4, "WHED");
|
||||
|
||||
streamFileWHED = streamFile->open(streamFile, filenameWHED, STREAMFILE_DEFAULT_BUFFER_SIZE);
|
||||
if (!streamFileWHED)
|
||||
{
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* check loopand channel */
|
||||
loop_flag = 1;
|
||||
channel_count = read_32bitLE(0x14, streamFileWHED);
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count, loop_flag);
|
||||
if (!vgmstream)
|
||||
{
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* fill in the vital statistics */
|
||||
vgmstream->channels = channel_count;
|
||||
vgmstream->sample_rate = read_32bitLE(0x04, streamFileWHED);
|
||||
|
||||
vgmstream->coding_type = coding_PSX;
|
||||
|
||||
vgmstream->interleave_block_size = read_32bitLE(0x18, streamFileWHED);
|
||||
blockCount = read_32bitLE(0x1C, streamFileWHED) * channel_count;
|
||||
shortBlockSize = read_32bitLE(0x20, streamFileWHED);
|
||||
|
||||
vgmstream->num_samples = (vgmstream->interleave_block_size * blockCount) / 16 / channel_count * 28;
|
||||
vgmstream->loop_start_sample = 0;
|
||||
|
||||
lastBlockLocation = (vgmstream->interleave_block_size * blockCount) - (vgmstream->interleave_block_size - shortBlockSize);
|
||||
vgmstream->loop_end_sample = lastBlockLocation / 16 / channel_count * 28;
|
||||
|
||||
if (!streamFileWHED)
|
||||
{
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* check loopand channel */
|
||||
loop_flag = 1;
|
||||
channel_count = read_32bitLE(0x14, streamFileWHED);
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count, loop_flag);
|
||||
if (!vgmstream)
|
||||
{
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* fill in the vital statistics */
|
||||
vgmstream->channels = channel_count;
|
||||
vgmstream->sample_rate = read_32bitLE(0x04, streamFileWHED);
|
||||
|
||||
vgmstream->coding_type = coding_PSX;
|
||||
|
||||
vgmstream->interleave_block_size = read_32bitLE(0x18, streamFileWHED);
|
||||
blockCount = read_32bitLE(0x1C, streamFileWHED) * channel_count;
|
||||
shortBlockSize = read_32bitLE(0x20, streamFileWHED);
|
||||
|
||||
vgmstream->num_samples = (vgmstream->interleave_block_size * blockCount) / 16 / channel_count * 28;
|
||||
vgmstream->loop_start_sample = 0;
|
||||
|
||||
lastBlockLocation = (vgmstream->interleave_block_size * blockCount) - (vgmstream->interleave_block_size - shortBlockSize);
|
||||
vgmstream->loop_end_sample = lastBlockLocation / 16 / channel_count * 28;
|
||||
|
||||
//_stprintf(szBuffer, _T("%x"), lastBlockLocation);
|
||||
//MessageBox(NULL, szBuffer, _T("Foo"), MB_OK);
|
||||
|
||||
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->meta_type = meta_PS2_WMUS;
|
||||
|
||||
start_offset = 0;
|
||||
|
||||
/* open the file for reading by each channel */
|
||||
{
|
||||
for (i=0;i<channel_count;i++) {
|
||||
vgmstream->ch[i].streamfile = streamFile->open(streamFile,filename,vgmstream->interleave_block_size);
|
||||
|
||||
if (!vgmstream->ch[i].streamfile) goto fail;
|
||||
|
||||
vgmstream->ch[i].channel_start_offset=
|
||||
vgmstream->ch[i].offset=
|
||||
(off_t)(start_offset+vgmstream->interleave_block_size*i);
|
||||
}
|
||||
}
|
||||
|
||||
return vgmstream;
|
||||
|
||||
/* clean up anything we may have opened */
|
||||
fail:
|
||||
if (vgmstream) close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->meta_type = meta_PS2_WMUS;
|
||||
|
||||
start_offset = 0;
|
||||
|
||||
/* open the file for reading by each channel */
|
||||
{
|
||||
for (i=0;i<channel_count;i++) {
|
||||
vgmstream->ch[i].streamfile = streamFile->open(streamFile,filename,vgmstream->interleave_block_size);
|
||||
|
||||
if (!vgmstream->ch[i].streamfile) goto fail;
|
||||
|
||||
vgmstream->ch[i].channel_start_offset=
|
||||
vgmstream->ch[i].offset=
|
||||
(off_t)(start_offset+vgmstream->interleave_block_size*i);
|
||||
}
|
||||
}
|
||||
|
||||
return vgmstream;
|
||||
|
||||
/* clean up anything we may have opened */
|
||||
fail:
|
||||
if (streamFileWHED) close_streamfile(streamFileWHED);
|
||||
if (vgmstream) close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user