2008-12-11 23:17:54 +00:00
|
|
|
#include "layout.h"
|
|
|
|
#include "../vgmstream.h"
|
|
|
|
|
|
|
|
/* set up for the block at the given offset */
|
2021-06-20 10:29:49 +02:00
|
|
|
void block_update_thp(off_t block_offset, VGMSTREAM* vgmstream) {
|
2019-11-23 20:56:57 +01:00
|
|
|
int i, j;
|
2021-06-20 10:29:49 +02:00
|
|
|
STREAMFILE* sf = vgmstream->ch[0].streamfile;
|
2019-11-23 20:56:57 +01:00
|
|
|
off_t audio_offset;
|
|
|
|
size_t next_block_size, video_size;
|
|
|
|
|
2021-06-20 10:29:49 +02:00
|
|
|
next_block_size = read_u32be(block_offset + 0x00, sf);
|
2019-11-23 20:56:57 +01:00
|
|
|
/* 0x04: frame size previous */
|
2021-06-20 10:29:49 +02:00
|
|
|
video_size = read_u32be(block_offset + 0x08,sf);
|
2019-11-23 20:56:57 +01:00
|
|
|
/* 0x0c: audio size */
|
|
|
|
|
|
|
|
audio_offset = block_offset + 0x10 + video_size;
|
|
|
|
|
|
|
|
vgmstream->current_block_offset = block_offset;
|
|
|
|
vgmstream->next_block_offset = block_offset + vgmstream->full_block_size;
|
|
|
|
vgmstream->full_block_size = next_block_size;
|
|
|
|
|
|
|
|
/* block samples can be smaller than block size, normally in the last block,
|
|
|
|
* but num_samples already takes that into account, so there is no real difference */
|
2021-06-20 10:29:49 +02:00
|
|
|
vgmstream->current_block_size = read_u32be(audio_offset + 0x00, sf);
|
|
|
|
vgmstream->current_block_samples = read_u32be(audio_offset + 0x04, sf);
|
2019-11-23 20:56:57 +01:00
|
|
|
|
|
|
|
audio_offset += 0x08;
|
|
|
|
|
|
|
|
for (i = 0; i < vgmstream->channels; i++) {
|
|
|
|
off_t coef_offset = audio_offset + i*0x20;
|
|
|
|
off_t hist_offset = audio_offset + vgmstream->channels*0x20 + i*0x04;
|
2021-06-20 10:29:49 +02:00
|
|
|
off_t data_offset = audio_offset + 2*0x24 + i*vgmstream->current_block_size; /* reserved for 2 even in mono [WarioWare Inc. (GC)] */
|
2019-11-23 20:56:57 +01:00
|
|
|
|
|
|
|
for (j = 0; j < 16; j++) {
|
2021-06-20 10:29:49 +02:00
|
|
|
vgmstream->ch[i].adpcm_coef[j] = read_s16be(coef_offset + (j*0x02),sf);
|
2019-11-23 20:56:57 +01:00
|
|
|
}
|
2021-06-20 10:29:49 +02:00
|
|
|
vgmstream->ch[i].adpcm_history1_16 = read_s16be(hist_offset + 0x00,sf);
|
|
|
|
vgmstream->ch[i].adpcm_history2_16 = read_s16be(hist_offset + 0x02,sf);
|
2019-11-23 20:56:57 +01:00
|
|
|
vgmstream->ch[i].offset = data_offset;
|
|
|
|
}
|
2008-12-11 23:17:54 +00:00
|
|
|
}
|