Fix undead VAG loops, KeyOff should stop them.

This commit is contained in:
Unknown W. Brackets 2013-05-28 23:05:34 -07:00
parent f32fa303dc
commit 42ced72b13
2 changed files with 5 additions and 1 deletions

View file

@ -63,6 +63,7 @@ void VagDecoder::DecodeBlock(u8 *&readp) {
predict_nr >>= 4; predict_nr >>= 4;
int flags = *readp++; int flags = *readp++;
if (flags == 7) { if (flags == 7) {
VERBOSE_LOG(SAS, "VAG ending block at %d", curBlock_);
end_ = true; end_ = true;
return; return;
} }
@ -102,13 +103,14 @@ void VagDecoder::GetSamples(s16 *outSamples, int numSamples) {
u8 *readp = Memory::GetPointer(read_); u8 *readp = Memory::GetPointer(read_);
if (!readp) if (!readp)
{ {
WARN_LOG(HLE, "Bad VAG samples address?"); WARN_LOG(SAS, "Bad VAG samples address?");
return; return;
} }
u8 *origp = readp; u8 *origp = readp;
for (int i = 0; i < numSamples; i++) { for (int i = 0; i < numSamples; i++) {
if (curSample == 28) { if (curSample == 28) {
if (loopAtNextBlock_) { if (loopAtNextBlock_) {
VERBOSE_LOG(SAS, "Looping VAG from block %d/%d to %d", curBlock_, numBlocks_, loopStartBlock_);
// data_ starts at curBlock = -1. // data_ starts at curBlock = -1.
read_ = data_ + 16 * loopStartBlock_ + 16; read_ = data_ + 16 * loopStartBlock_ + 16;
readp = Memory::GetPointer(read_); readp = Memory::GetPointer(read_);
@ -482,6 +484,7 @@ void SasVoice::KeyOn() {
void SasVoice::KeyOff() { void SasVoice::KeyOff() {
on = false; on = false;
envelope.KeyOff(); envelope.KeyOff();
vag.SetLoop(false);
} }
void SasVoice::ChangedParams(bool changedVag) { void SasVoice::ChangedParams(bool changedVag) {

View file

@ -82,6 +82,7 @@ public:
void DecodeBlock(u8 *&readp); void DecodeBlock(u8 *&readp);
bool End() const { return end_; } bool End() const { return end_; }
void SetLoop(bool enabled) { loopEnabled_ = enabled; }
void DoState(PointerWrap &p); void DoState(PointerWrap &p);