diff options
author | Johannes Schickel | 2014-06-04 01:49:29 +0200 |
---|---|---|
committer | Johannes Schickel | 2014-06-04 01:49:29 +0200 |
commit | e71c841ca06a8d4a047d7ee6096ea56c2c028781 (patch) | |
tree | fd8d1f85e12ac944f6f494680eba24b6160c06cc /engines | |
parent | 475d14ac939d7192cbc0fa763ca2dfe15a2aa71b (diff) | |
download | scummvm-rg350-e71c841ca06a8d4a047d7ee6096ea56c2c028781.tar.gz scummvm-rg350-e71c841ca06a8d4a047d7ee6096ea56c2c028781.tar.bz2 scummvm-rg350-e71c841ca06a8d4a047d7ee6096ea56c2c028781.zip |
SCUMM: Small cleanup in SFX note setup in AD code.
Diffstat (limited to 'engines')
-rw-r--r-- | engines/scumm/players/player_ad.cpp | 52 | ||||
-rw-r--r-- | engines/scumm/players/player_ad.h | 38 |
2 files changed, 44 insertions, 46 deletions
diff --git a/engines/scumm/players/player_ad.cpp b/engines/scumm/players/player_ad.cpp index 7b525116cf..0612c81786 100644 --- a/engines/scumm/players/player_ad.cpp +++ b/engines/scumm/players/player_ad.cpp @@ -662,8 +662,8 @@ void Player_AD::parseSlot(int channel) { ++curOffset; _channels[channel].state = 2; noteOffOn(channel); - parseNote(channel, 0, curOffset); - parseNote(channel, 1, curOffset); + parseNote(channel, 0, curOffset + 0); + parseNote(channel, 1, curOffset + 5); return; case 0x80: @@ -708,7 +708,7 @@ void Player_AD::updateSlot(int channel) { updateNote = true; } } else { - updateNote = processNoteEnvelope(note, _notes[note].instrumentValue); + updateNote = processNoteEnvelope(&_notes[note]); if (_notes[note].bias) { writeRegisterSpecial(note, _notes[note].bias - _notes[note].instrumentValue, *curOffset & 0x07); @@ -740,10 +740,6 @@ void Player_AD::updateSlot(int channel) { } void Player_AD::parseNote(int channel, int num, const byte *offset) { - if (num) { - offset += 5; - } - if (*offset & 0x80) { const int note = channel * 2 + num; _notes[note].state = -1; @@ -793,7 +789,7 @@ bool Player_AD::processNote(int note, const byte *offset) { } int adjustValue = ((_noteAdjustTable[timer2] * _noteAdjustScaleTable[instrumentDataOffset]) >> 16) - noteInstrumentValue; - setupNoteEnvelopeState(note, _numStepsTable[timer1], adjustValue); + setupNoteEnvelopeState(&_notes[note], _numStepsTable[timer1], adjustValue); } return false; @@ -858,39 +854,39 @@ uint8 Player_AD::readRegisterSpecial(int note, uint8 defaultValue, int offset) { return regValue; } -void Player_AD::setupNoteEnvelopeState(int note, int steps, int adjust) { - _notes[note].preIncrease = 0; +void Player_AD::setupNoteEnvelopeState(Note *note, int steps, int adjust) { + note->preIncrease = 0; if (ABS(adjust) > steps) { - _notes[note].preIncrease = 1; - _notes[note].adjust = adjust / steps; - _notes[note].envelope.stepIncrease = ABS(adjust % steps); + note->preIncrease = 1; + note->adjust = adjust / steps; + note->envelope.stepIncrease = ABS(adjust % steps); } else { - _notes[note].adjust = adjust; - _notes[note].envelope.stepIncrease = ABS(adjust); + note->adjust = adjust; + note->envelope.stepIncrease = ABS(adjust); } - _notes[note].envelope.step = steps; - _notes[note].envelope.stepCounter = 0; - _notes[note].envelope.timer = steps; + note->envelope.step = steps; + note->envelope.stepCounter = 0; + note->envelope.timer = steps; } -bool Player_AD::processNoteEnvelope(int note, int &instrumentValue) { - if (_notes[note].preIncrease) { - instrumentValue += _notes[note].adjust; +bool Player_AD::processNoteEnvelope(Note *note) { + if (note->preIncrease) { + note->instrumentValue += note->adjust; } - _notes[note].envelope.stepCounter += _notes[note].envelope.stepIncrease; - if (_notes[note].envelope.stepCounter >= _notes[note].envelope.step) { - _notes[note].envelope.stepCounter -= _notes[note].envelope.step; + note->envelope.stepCounter += note->envelope.stepIncrease; + if (note->envelope.stepCounter >= note->envelope.step) { + note->envelope.stepCounter -= note->envelope.step; - if (_notes[note].adjust < 0) { - --instrumentValue; + if (note->adjust < 0) { + --note->instrumentValue; } else { - ++instrumentValue; + ++note->instrumentValue; } } - if (--_notes[note].envelope.timer) { + if (--note->envelope.timer) { return false; } else { return true; diff --git a/engines/scumm/players/player_ad.h b/engines/scumm/players/player_ad.h index fbb65fbe24..d03d5e71cf 100644 --- a/engines/scumm/players/player_ad.h +++ b/engines/scumm/players/player_ad.h @@ -127,6 +127,23 @@ private: static const uint _rhythmChannelTable[6]; // SFX handling + struct Note { + int state; + int playTime; + int sustainTimer; + int instrumentValue; + int bias; + int preIncrease; + int adjust; + + struct Envelope { + int stepIncrease; + int step; + int stepCounter; + int timer; + } envelope; + }; + void startSfx(); void updateSfx(); void clearChannel(int channel); @@ -138,8 +155,8 @@ private: void noteOffOn(int channel); void writeRegisterSpecial(int note, uint8 value, int offset); uint8 readRegisterSpecial(int note, uint8 defaultValue, int offset); - void setupNoteEnvelopeState(int note, int steps, int adjust); - bool processNoteEnvelope(int note, int &instrumentValue); + void setupNoteEnvelopeState(Note *note, int steps, int adjust); + bool processNoteEnvelope(Note *note); int _sfxTimer; @@ -156,22 +173,7 @@ private: uint8 _rndSeed; uint8 getRnd(); - struct Note { - int state; - int playTime; - int sustainTimer; - int instrumentValue; - int bias; - int preIncrease; - int adjust; - - struct Envelope { - int stepIncrease; - int step; - int stepCounter; - int timer; - } envelope; - } _notes[22]; + Note _notes[22]; static const uint _noteBiasTable[7]; static const uint _numStepsTable[16]; |