aboutsummaryrefslogtreecommitdiff
path: root/engines/kyra
diff options
context:
space:
mode:
authorFlorian Kagerer2008-06-30 21:55:08 +0000
committerFlorian Kagerer2008-06-30 21:55:08 +0000
commitb07ff576233dec6e2138f19a5cf053e2ccf146df (patch)
tree7ce331305dba3458936f42542a9221f22aaf3c30 /engines/kyra
parentf530c36ad44d9605f65547d6b65127c97f8ea5b8 (diff)
downloadscummvm-rg350-b07ff576233dec6e2138f19a5cf053e2ccf146df.tar.gz
scummvm-rg350-b07ff576233dec6e2138f19a5cf053e2ccf146df.tar.bz2
scummvm-rg350-b07ff576233dec6e2138f19a5cf053e2ccf146df.zip
- this fixes Hof PC98 music initialization
- music sounds exactly like FM-Towns for now svn-id: r32854
Diffstat (limited to 'engines/kyra')
-rw-r--r--engines/kyra/kyra_hof.cpp2
-rw-r--r--engines/kyra/sound_towns.cpp51
2 files changed, 42 insertions, 11 deletions
diff --git a/engines/kyra/kyra_hof.cpp b/engines/kyra/kyra_hof.cpp
index a8b8c0dced..61a1570893 100644
--- a/engines/kyra/kyra_hof.cpp
+++ b/engines/kyra/kyra_hof.cpp
@@ -1564,7 +1564,7 @@ void KyraEngine_HoF::snd_playSoundEffect(int track, int volume) {
int16 vocIndex = (int16)READ_LE_UINT16(&_ingameSoundIndex[track * 2]);
if (vocIndex != -1)
_sound->voicePlay(_ingameSoundList[vocIndex], true);
- else if (_flags.platform == Common::kPlatformPC)
+ else if (_flags.platform != Common::kPlatformFMTowns)
// TODO ?? Maybe there is a way to let users select whether they want
// voc, midi or adl sfx (even though it makes no sense to choose anything but voc).
KyraEngine_v1::snd_playSoundEffect(track);
diff --git a/engines/kyra/sound_towns.cpp b/engines/kyra/sound_towns.cpp
index a4142603e9..6be2cae7a4 100644
--- a/engines/kyra/sound_towns.cpp
+++ b/engines/kyra/sound_towns.cpp
@@ -1348,7 +1348,7 @@ public:
CHS_EOT = 0x80
} ChannelState;
- void loadData(uint8 *data);
+ virtual void loadData(uint8 *data);
virtual void processEvents();
virtual void processFrequency();
bool processControlEvent(uint8 cmd);
@@ -1404,7 +1404,6 @@ protected:
uint8 _keyOffTime;
bool _protect;
uint8 *_dataPtr;
- uint8 _unk15, _unk16;
uint8 _ptchWhlInitDelayLo;
uint8 _ptchWhlInitDelayHi;
int16 _ptchWhlModInitVal;
@@ -1413,9 +1412,11 @@ protected:
int16 _ptchWhlModCurVal;
uint8 _ptchWhlDurLeft;
uint16 frequency;
- uint8 _unk28, _unk29;
uint8 _regOffset;
uint8 _flags;
+ uint8 _ssg1;
+ uint8 _ssg2;
+
const uint8 _chanNum;
const uint8 _keyNum;
const uint8 _part;
@@ -1439,8 +1440,13 @@ public:
void keyOn();
void keyOff();
+ void loadData(uint8 *data);
+
+private:
+ void opn_SSG_UNK(uint8 a);
};
+
class TownsPC98_OpnDriver : public Audio::AudioStream {
friend class TownsPC98_OpnChannel;
friend class TownsPC98_OpnChannelSSG;
@@ -1514,7 +1520,8 @@ protected:
uint8 _looping;
uint32 _tickCounter;
- bool __updateEnvelopes;
+ bool _updateEnvelopes;
+ int _ssgFlag;
int32 _samplesTillCallback;
int32 _samplesTillCallbackRemainder;
@@ -1536,8 +1543,8 @@ TownsPC98_OpnChannel::TownsPC98_OpnChannel(TownsPC98_OpnDriver *driver, uint8 re
uint8 key, uint8 prt, uint8 id) : _drv(driver), _regOffset(regOffs), _flags(flgs), _chanNum(num), _keyNum(key),
_part(prt), _idFlag(id) {
- _ticksLeft = _algorithm = _instrID = _totalLevel = _frqBlockMSB = _keyOffTime = _unk15 = _unk16 = 0;
- _ptchWhlInitDelayLo = _ptchWhlInitDelayHi = _ptchWhlDuration = _ptchWhlCurDelay = _ptchWhlDurLeft = _unk28 = _unk29 = 0;
+ _ticksLeft = _algorithm = _instrID = _totalLevel = _frqBlockMSB = _keyOffTime = _ssg1 = _ssg2 = 0;
+ _ptchWhlInitDelayLo = _ptchWhlInitDelayHi = _ptchWhlDuration = _ptchWhlCurDelay = _ptchWhlDurLeft = 0;
_frqLSB = 0;
_protect = _updateEnvelopes = false;
_enableLeft = _enableRight = true;
@@ -1602,7 +1609,6 @@ void TownsPC98_OpnChannel::keyOn() {
writeReg(regAdress, value);
}
-
void TownsPC98_OpnChannel::loadData(uint8 *data) {
_flags = (_flags & ~CHS_EOT) | CHS_ALL_BUT_EOT;
_ticksLeft = 1;
@@ -2242,7 +2248,7 @@ void TownsPC98_OpnChannelSSG::processEvents() {
if (_flags & CHS_EOT)
return;
- //int _ssgUnk = (_flags & CHS_SSG) ? -1 : 0;
+ _drv->_ssgFlag = (_flags & CHS_SSG) ? -1 : 0;
if (_protect == false && _ticksLeft == _keyOffTime)
keyOff();
@@ -2336,6 +2342,22 @@ void TownsPC98_OpnChannelSSG::keyOn() {
writeReg(regAdress, value);
}
+void TownsPC98_OpnChannelSSG::loadData(uint8 *data) {
+ _drv->_ssgFlag = (_flags & CHS_SSG) ? -1 : 0;
+ opn_SSG_UNK(0);
+ TownsPC98_OpnChannel::loadData(data);
+ _algorithm = 0x80;
+}
+
+void TownsPC98_OpnChannelSSG::opn_SSG_UNK(uint8 a) {
+ _ssg1 = a;
+ uint16 h = (_totalLevel + 1) * a;
+ if ((h >> 8) == _ssg2)
+ return;
+ _ssg2 = (h >> 8);
+ writeReg(8 + _regOffset, _ssg2);
+}
+
TownsPC98_OpnDriver::TownsPC98_OpnDriver(Audio::Mixer *mixer, OpnType type) :
_mixer(mixer), _trackData(0), _playing(false), _fading(false), _channels(0), _ssgChannels(0),
_looping(0), _opnCarrier(_drvTables + 76), _opnFreqTable(_drvTables + 84),
@@ -2469,7 +2491,7 @@ void TownsPC98_OpnDriver::loadData(uint8 *data, bool loadPaused) {
uint8 *src_a = data;
- for (uint8 i = 0; i < _numChan; i++) {
+ for (uint8 i = 0; i < 3; i++) {
_channels[i]->loadData(data + READ_LE_UINT16(src_a));
src_a += 2;
}
@@ -2479,11 +2501,18 @@ void TownsPC98_OpnDriver::loadData(uint8 *data, bool loadPaused) {
src_a += 2;
}
+ for (uint8 i = 3; i < _numChan; i++) {
+ _channels[i]->loadData(data + READ_LE_UINT16(src_a));
+ src_a += 2;
+ }
+
if (_hasADPCM) {
- // TODO
+ //_adpcmChannel->loadData(data + READ_LE_UINT16(src_a));
src_a += 2;
}
+ _ssgFlag = 0;
+
_patches = src_a + 4;
_cbCounter = 4;
_finishedChannelsFlag = 0;
@@ -2555,6 +2584,8 @@ void TownsPC98_OpnDriver::callback() {
_ssgChannels[i]->processFrequency();
}
}
+
+ _ssgFlag = 0;
unlock();