Add patch #2876221 - FBEAR: Fix for MIDI piano notes (DOS version), with minor change.

svn-id: r46081
This commit is contained in:
Travis Howell 2009-11-22 11:58:14 +00:00
parent bb0c765731
commit 40504d7810
5 changed files with 24 additions and 4 deletions

View File

@ -748,9 +748,12 @@ void SoundHE::playHESound(int soundID, int heOffset, int heChannel, int heFlags)
}
else if (READ_BE_UINT32(ptr) == MKID_BE('MIDI')) {
if (_vm->_imuse) {
// This is used in the DOS version of Fatty Bear's
// Birthday Surprise to change the note on the piano
// when not using a digitized instrument.
_vm->_imuse->stopSound(_currentMusic);
_currentMusic = soundID;
_vm->_imuse->startSound(soundID);
_vm->_imuse->startSoundWithNoteOffset(soundID, heOffset);
}
}
}

View File

@ -491,7 +491,10 @@ void IMuseInternal::addSysexHandler(byte mfgID, sysexfunc handler) {
_sysex = handler;
}
void IMuseInternal::startSoundWithNoteOffset(int sound, int offset) {
Common::StackLock lock(_mutex, "IMuseInternal::startSound()");
startSound_internal(sound, offset);
}
////////////////////////////////////////
//
@ -559,7 +562,7 @@ int IMuseInternal::getMusicTimer() const {
//
////////////////////////////////////////
bool IMuseInternal::startSound_internal(int sound) {
bool IMuseInternal::startSound_internal(int sound, int offset) {
// Do not start a sound if it is already set to start on an ImTrigger
// event. This fixes carnival music problems where a sound has been set
// to trigger at the right time, but then is started up immediately
@ -632,6 +635,7 @@ bool IMuseInternal::startSound_internal(int sound) {
ImClearTrigger(81, 1);
player->clear();
player->setOffsetNote(offset);
return player->startSound(sound, driver, _direct_passthrough);
}

View File

@ -74,6 +74,8 @@ public:
virtual void addSysexHandler (byte mfgID, sysexfunc handler) = 0;
public:
virtual void startSoundWithNoteOffset(int sound, int offset) = 0;
// MusicEngine base class methods.
// Not actually redefined here because none are implemented.

View File

@ -185,6 +185,7 @@ protected:
int8 _pan;
int8 _transpose;
int8 _detune;
int _note_offset;
byte _vol_eff;
uint _track_index;
@ -270,6 +271,7 @@ public:
void saveLoadWithSerializer(Serializer *ser);
int setHook(byte cls, byte value, byte chan) { return _hook.set(cls, value, chan); }
void setDetune(int detune);
void setOffsetNote(int offset);
bool setLoop(uint count, uint tobeat, uint totick, uint frombeat, uint fromtick);
void setPan(int pan);
void setPriority(int pri);
@ -507,7 +509,7 @@ protected:
protected:
// Internal mutex-free versions of the IMuse and MusicEngine methods.
bool startSound_internal(int sound);
bool startSound_internal(int sound, int offset = 0);
int stopSound_internal(int sound);
int stopAllSounds_internal();
int getSoundStatus_internal(int sound, bool ignoreFadeouts) const;
@ -525,6 +527,8 @@ public:
virtual void addSysexHandler(byte mfgID, sysexfunc handler);
public:
void startSoundWithNoteOffset(int sound, int offset);
// MusicEngine interface
void setMusicVolume(int vol);
void startSound(int sound);

View File

@ -72,6 +72,7 @@ Player::Player() :
_pan(0),
_transpose(0),
_detune(0),
_note_offset(0),
_vol_eff(0),
_track_index(0),
_loop_to_beat(0),
@ -165,6 +166,7 @@ void Player::clear() {
_active = false;
_midi = NULL;
_id = 0;
_note_offset = 0;
}
void Player::hook_clear() {
@ -252,6 +254,7 @@ void Player::send(uint32 b) {
break;
case 0x9: // Key On
param1 += _note_offset;
if (!_scanning) {
if (_isMT32 && !_se->isNativeMT32())
param2 = (((param2 * 3) >> 2) + 32) & 0x7F;
@ -666,6 +669,10 @@ void Player::setDetune(int detune) {
}
}
void Player::setOffsetNote(int offset) {
_note_offset = offset;
}
int Player::scan(uint totrack, uint tobeat, uint totick) {
if (!_active || !_parser)
return -1;