mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-01-17 23:36:41 +01:00
hlwav support for Half Life 2 (XBOX)
git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@710 51a99a44-fe44-0410-b1ba-c3e57ba2b86b
This commit is contained in:
parent
d1c2b01b98
commit
81285adbdd
@ -213,7 +213,8 @@ META_OBJS=meta/adx_header.o \
|
||||
meta/wii_bns.o \
|
||||
meta/wii_was.o \
|
||||
meta/pona.o \
|
||||
meta/fsb_test.o
|
||||
meta/fsb_test.o \
|
||||
meta/xbox_hlwav.o
|
||||
|
||||
OBJECTS=vgmstream.o streamfile.o util.o $(CODING_OBJS) $(LAYOUT_OBJS) $(META_OBJS)
|
||||
|
||||
|
@ -838,6 +838,10 @@
|
||||
RelativePath=".\meta\wvs.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\meta\xbox_hlwav.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\meta\xbox_ims.c"
|
||||
>
|
||||
|
@ -171,5 +171,6 @@ libmeta_la_SOURCES += wii_bns.c
|
||||
libmeta_la_SOURCES += wii_was.c
|
||||
libmeta_la_SOURCES += pona.c
|
||||
libmeta_la_SOURCES += fsb_test.c
|
||||
libmeta_la_SOURCES += xbox_hlwav.c
|
||||
|
||||
EXTRA_DIST = meta.h
|
||||
|
@ -421,4 +421,6 @@ VGMSTREAM * init_vgmstream_wii_was(STREAMFILE* streamFile);
|
||||
|
||||
VGMSTREAM * init_vgmstream_pona(STREAMFILE* streamFile);
|
||||
|
||||
VGMSTREAM * init_vgmstream_xbox_hlwav(STREAMFILE* streamFile);
|
||||
|
||||
#endif
|
||||
|
64
src/meta/xbox_hlwav.c
Normal file
64
src/meta/xbox_hlwav.c
Normal file
@ -0,0 +1,64 @@
|
||||
#include "meta.h"
|
||||
#include "../util.h"
|
||||
|
||||
/* HLWAV (from Half Life 2 [XBOX]) */
|
||||
VGMSTREAM * init_vgmstream_xbox_hlwav(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
char filename[260];
|
||||
off_t start_offset;
|
||||
int loop_flag;
|
||||
int channel_count;
|
||||
|
||||
/* check extension, case insensitive */
|
||||
streamFile->get_name(streamFile,filename,sizeof(filename));
|
||||
if (strcasecmp("hlwav",filename_extension(filename))) goto fail;
|
||||
|
||||
/* check header and size */
|
||||
if ((read_32bitBE(0x00,streamFile) != 0x14000000)) goto fail;
|
||||
if (((read_32bitLE(0x4,streamFile) + (read_32bitLE(0x8,streamFile))) != get_streamfile_size(streamFile))) goto fail;
|
||||
|
||||
loop_flag = (read_32bitLE(0xC,streamFile)!= 0xFFFFFFFF);
|
||||
channel_count = 2;
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
/* fill in the vital statistics */
|
||||
start_offset = read_32bitLE(0x8,streamFile);
|
||||
vgmstream->channels = channel_count;
|
||||
vgmstream->sample_rate = 22050;
|
||||
vgmstream->coding_type = coding_PCM16LE;
|
||||
vgmstream->num_samples = read_32bitLE(0x4,streamFile)/2/channel_count;
|
||||
if (loop_flag) {
|
||||
vgmstream->loop_start_sample = read_32bitLE(0x4,streamFile)/2/channel_count;
|
||||
vgmstream->loop_end_sample = read_32bitLE(0xC,streamFile)/2/channel_count;
|
||||
}
|
||||
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = 0x2;
|
||||
vgmstream->meta_type = meta_XBOX_HLWAV;
|
||||
|
||||
/* 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;
|
||||
}
|
@ -231,6 +231,7 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = {
|
||||
init_vgmstream_wii_bns,
|
||||
init_vgmstream_wii_was,
|
||||
init_vgmstream_pona,
|
||||
init_vgmstream_xbox_hlwav,
|
||||
};
|
||||
|
||||
#define INIT_VGMSTREAM_FCNS (sizeof(init_vgmstream_fcns)/sizeof(init_vgmstream_fcns[0]))
|
||||
@ -2336,6 +2337,9 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) {
|
||||
case meta_WII_WAS:
|
||||
snprintf(temp,TEMPSIZE,"DiRT2 WAS header");
|
||||
break;
|
||||
case meta_XBOX_HLWAV:
|
||||
snprintf(temp,TEMPSIZE,"Half Life 2 bgm header");
|
||||
break;
|
||||
default:
|
||||
snprintf(temp,TEMPSIZE,"THEY SHOULD HAVE SENT A POET");
|
||||
}
|
||||
|
@ -418,6 +418,7 @@ typedef enum {
|
||||
meta_EXAKT_SC, /* Activision EXAKT .SC (PS2) */
|
||||
meta_WII_WAS, /* DiRT 2 (WII) */
|
||||
meta_PONA, /* Policenauts (3DO + PSX) */
|
||||
meta_XBOX_HLWAV, /* Half Life 2 (XBOX) */
|
||||
} meta_t;
|
||||
|
||||
typedef struct {
|
||||
|
@ -141,6 +141,7 @@ char * extension_list[] = {
|
||||
"gsb\0GSB Audio File (*.GSB)\0",
|
||||
|
||||
"hgc1\0HGC1 Audio File (*.HGC1)\0",
|
||||
"hlwav\0HLWAV Audio File (*.HLWAV)\0",
|
||||
"hps\0HALPST Audio File (*.HPS)\0",
|
||||
"hwas\0HWAS Audio File (*.HWAS)\0",
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user