mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-02-06 22:54:26 +01:00
Added AGSC DSP header reading.
git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@24 51a99a44-fe44-0410-b1ba-c3e57ba2b86b
This commit is contained in:
parent
5278ba1c79
commit
99f18a80ca
81
src/meta/agsc.c
Normal file
81
src/meta/agsc.c
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
#include "agsc.h"
|
||||||
|
#include "../util.h"
|
||||||
|
|
||||||
|
/* .agsc - from Metroid Prime 2 */
|
||||||
|
|
||||||
|
VGMSTREAM * init_vgmstream_agsc(const char * const filename) {
|
||||||
|
VGMSTREAM * vgmstream = NULL;
|
||||||
|
STREAMFILE * infile = NULL;
|
||||||
|
|
||||||
|
coding_t coding_type;
|
||||||
|
|
||||||
|
off_t header_offset;
|
||||||
|
off_t start_offset;
|
||||||
|
int channel_count;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/* check extension, case insensitive */
|
||||||
|
if (strcasecmp("agsc",filename_extension(filename))) goto fail;
|
||||||
|
|
||||||
|
/* try to open the file for header reading */
|
||||||
|
infile = open_streamfile(filename);
|
||||||
|
if (!infile) goto fail;
|
||||||
|
|
||||||
|
/* check header */
|
||||||
|
if ((uint32_t)read_32bitBE(0,infile)!=0x00000001)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
/* count length of name, including terminating 0 */
|
||||||
|
for (header_offset=4;header_offset < get_streamfile_size(infile) && read_8bit(header_offset,infile)!='\0';header_offset++);
|
||||||
|
|
||||||
|
header_offset ++;
|
||||||
|
|
||||||
|
channel_count = 1;
|
||||||
|
|
||||||
|
/* build the VGMSTREAM */
|
||||||
|
|
||||||
|
vgmstream = allocate_vgmstream(1,1);
|
||||||
|
if (!vgmstream) goto fail;
|
||||||
|
|
||||||
|
/* fill in the vital statistics */
|
||||||
|
vgmstream->num_samples = read_32bitBE(header_offset+0xda,infile);
|
||||||
|
vgmstream->sample_rate = read_16bitBE(header_offset+0xd8,infile);
|
||||||
|
|
||||||
|
vgmstream->loop_start_sample = read_32bitBE(header_offset+0xde,infile);
|
||||||
|
/* this is cute, we actually have a "loop length" */
|
||||||
|
vgmstream->loop_end_sample = (vgmstream->loop_start_sample + read_32bitBE(header_offset+0xe2,infile))-1;
|
||||||
|
|
||||||
|
vgmstream->coding_type = coding_NGC_DSP;
|
||||||
|
vgmstream->layout_type = layout_none;
|
||||||
|
vgmstream->meta_type = meta_DSP_AGSC;
|
||||||
|
|
||||||
|
for (i=0;i<16;i++) {
|
||||||
|
vgmstream->ch[0].adpcm_coef[i]=read_16bitBE(header_offset+0xf6+i*2,infile);
|
||||||
|
}
|
||||||
|
|
||||||
|
start_offset = header_offset+0x116;
|
||||||
|
|
||||||
|
close_streamfile(infile); infile=NULL;
|
||||||
|
|
||||||
|
/* open the file for reading by each channel */
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i=0;i<channel_count;i++) {
|
||||||
|
vgmstream->ch[i].streamfile = open_streamfile(filename);
|
||||||
|
|
||||||
|
if (!vgmstream->ch[i].streamfile) goto fail;
|
||||||
|
|
||||||
|
vgmstream->ch[i].channel_start_offset=
|
||||||
|
vgmstream->ch[i].offset=
|
||||||
|
start_offset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return vgmstream;
|
||||||
|
|
||||||
|
/* clean up anything we may have opened */
|
||||||
|
fail:
|
||||||
|
if (infile) close_streamfile(infile);
|
||||||
|
if (vgmstream) close_vgmstream(vgmstream);
|
||||||
|
return NULL;
|
||||||
|
}
|
8
src/meta/agsc.h
Normal file
8
src/meta/agsc.h
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#include "../vgmstream.h"
|
||||||
|
|
||||||
|
#ifndef _AGSC_H
|
||||||
|
#define _AGSC_H
|
||||||
|
|
||||||
|
VGMSTREAM * init_vgmstream_agsc(const char * const filename);
|
||||||
|
|
||||||
|
#endif
|
@ -2,6 +2,7 @@
|
|||||||
#include "meta/adx_header.h"
|
#include "meta/adx_header.h"
|
||||||
#include "meta/brstm.h"
|
#include "meta/brstm.h"
|
||||||
#include "meta/nds_strm.h"
|
#include "meta/nds_strm.h"
|
||||||
|
#include "meta/agsc.h"
|
||||||
#include "layout/interleave.h"
|
#include "layout/interleave.h"
|
||||||
#include "layout/nolayout.h"
|
#include "layout/nolayout.h"
|
||||||
#include "coding/adx_decoder.h"
|
#include "coding/adx_decoder.h"
|
||||||
@ -12,11 +13,12 @@
|
|||||||
* List of functions that will recognize files. These should correspond pretty
|
* List of functions that will recognize files. These should correspond pretty
|
||||||
* directly to the metadata types
|
* directly to the metadata types
|
||||||
*/
|
*/
|
||||||
#define INIT_VGMSTREAM_FCNS 3
|
#define INIT_VGMSTREAM_FCNS 4
|
||||||
VGMSTREAM * (*init_vgmstream_fcns[INIT_VGMSTREAM_FCNS])(const char * const) = {
|
VGMSTREAM * (*init_vgmstream_fcns[INIT_VGMSTREAM_FCNS])(const char * const) = {
|
||||||
init_vgmstream_adx,
|
init_vgmstream_adx,
|
||||||
init_vgmstream_brstm,
|
init_vgmstream_brstm,
|
||||||
init_vgmstream_nds_strm,
|
init_vgmstream_nds_strm,
|
||||||
|
init_vgmstream_agsc,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* format detection and VGMSTREAM setup */
|
/* format detection and VGMSTREAM setup */
|
||||||
@ -255,6 +257,13 @@ int vgmstream_do_loop(VGMSTREAM * vgmstream) {
|
|||||||
/* if (vgmstream->loop_flag) {*/
|
/* if (vgmstream->loop_flag) {*/
|
||||||
/* is this the loop end? */
|
/* is this the loop end? */
|
||||||
if (vgmstream->current_sample==vgmstream->loop_end_sample) {
|
if (vgmstream->current_sample==vgmstream->loop_end_sample) {
|
||||||
|
int i;
|
||||||
|
/*
|
||||||
|
for (i=0;i<vgmstream->channels;i++) {
|
||||||
|
vgmstream->loop_ch[i].adpcm_history1_32 = vgmstream->ch[i].adpcm_history1_32;
|
||||||
|
vgmstream->loop_ch[i].adpcm_history2_32 = vgmstream->ch[i].adpcm_history2_32;
|
||||||
|
}
|
||||||
|
*/
|
||||||
/* restore! */
|
/* restore! */
|
||||||
memcpy(vgmstream->ch,vgmstream->loop_ch,sizeof(VGMSTREAMCHANNEL)*vgmstream->channels);
|
memcpy(vgmstream->ch,vgmstream->loop_ch,sizeof(VGMSTREAMCHANNEL)*vgmstream->channels);
|
||||||
vgmstream->current_sample=vgmstream->loop_sample;
|
vgmstream->current_sample=vgmstream->loop_sample;
|
||||||
@ -304,6 +313,9 @@ void describe_vgmstream(VGMSTREAM * vgmstream) {
|
|||||||
case meta_ADX_04:
|
case meta_ADX_04:
|
||||||
printf("ADX header type 04");
|
printf("ADX header type 04");
|
||||||
break;
|
break;
|
||||||
|
case meta_DSP_AGSC:
|
||||||
|
printf("AGSC header");
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
printf("THEY SHOULD HAVE SENT A POET");
|
printf("THEY SHOULD HAVE SENT A POET");
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,7 @@ typedef enum {
|
|||||||
meta_DSP_RS03, /* Metroid Prime 2 "RS03" */
|
meta_DSP_RS03, /* Metroid Prime 2 "RS03" */
|
||||||
meta_DSP_STM, /* Paper Mario 2 STM */
|
meta_DSP_STM, /* Paper Mario 2 STM */
|
||||||
meta_DSP_HALP, /* SSB:M "HALPST" */
|
meta_DSP_HALP, /* SSB:M "HALPST" */
|
||||||
|
meta_DSP_AGSC,
|
||||||
/* Nintendo */
|
/* Nintendo */
|
||||||
meta_AST, /* AST */
|
meta_AST, /* AST */
|
||||||
meta_STRM, /* STRM */
|
meta_STRM, /* STRM */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user