fix bug in ReadGotoBeginning (to finally seek correctly)

This commit is contained in:
2025-12-03 23:55:10 +01:00
parent 945941ef5c
commit 7ea0d11d65
2 changed files with 4 additions and 8 deletions

View File

@@ -138,6 +138,7 @@ class CTRFF_API BCSTM {
DSP_ADPCM_Param() {}
PD::u16 Coefficients[0x10];
};
struct DSP_ADPCM_Context {
DSP_ADPCM_Context()
: PredictorScale(0),

View File

@@ -147,15 +147,10 @@ CTRFF_API void BCSTM::ReadGotoBeginning(bool use_loop_beg) {
size_t off = pDataBlockRef.Ref.Offset + 0x20;
/** Shift to loop start if enabled */
if (use_loop_beg) {
off += GetNumBlocks() * GetNumChannels() * GetLoopStart();
// off += GetNumChannels() * pInfoBlock.StreamInfo.LoopStartFrame;
}
// block_size * channel_count * loop_start
try {
pFile.seekg(off, std::ios::beg);
} catch (const std::exception& e) {
throw std::runtime_error(e.what());
off += GetLoopStart() * GetBlockSize() * GetNumChannels();
}
pFile.seekg(off, std::ios::beg);
if (pFile.tellg() > pHeader.FileSize) {
throw std::runtime_error("BCSTM: Seeked Out of range!");
}