vgmstream/src/layout/blocked_vgs.c
bnnm d46996a642 Improve Guitar Hero II multi-streams with block layout
Fixes partially by ignoring last stream, as it can be half sample rate
2017-08-28 20:05:03 +02:00

33 lines
1.0 KiB
C

#include "layout.h"
#include "../coding/coding.h"
#include "../layout/layout.h"
#include "../vgmstream.h"
/* VGS multistream frames */
void block_update_vgs(off_t block_offset, VGMSTREAM * vgmstream) {
STREAMFILE* streamFile = vgmstream->ch[0].streamfile;
size_t file_size = get_streamfile_size(vgmstream->ch[0].streamfile);
int i;
size_t channel_size = 0x10;
/* set offsets */
for (i = 0; i < vgmstream->channels; i++) {
vgmstream->ch[i].offset = block_offset + channel_size*i;
}
vgmstream->current_block_size = channel_size;
vgmstream->current_block_offset = block_offset;
vgmstream->next_block_offset = block_offset + channel_size*vgmstream->channels;
/* skip unhandled tracks: flag can be 0x0n per track, of 0x8x for last frame */
while (vgmstream->next_block_offset < file_size) {
if ((read_8bit(vgmstream->next_block_offset + 0x01, streamFile) & 0x0F) == 0x00)
break;
vgmstream->next_block_offset += channel_size;
}
}