From 575daf32e28de21db3ac2ed5a80463a8adacd47f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 12 Sep 2016 21:37:52 -0400 Subject: XEEN: Extra Adlib initialization during Music creation --- engines/xeen/music.cpp | 22 ++++++++++++++++++++-- engines/xeen/music.h | 11 +++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) (limited to 'engines/xeen') diff --git a/engines/xeen/music.cpp b/engines/xeen/music.cpp index 741fe81c31..7996093d1f 100644 --- a/engines/xeen/music.cpp +++ b/engines/xeen/music.cpp @@ -27,19 +27,21 @@ namespace Xeen { -#define CALLBACKS_PER_SECOND 60 +#define CALLBACKS_PER_SECOND 72 Music::Music(Audio::Mixer *mixer) : _mixer(mixer), _effectsData(nullptr), _musicPtr1(nullptr), _musicPtr2(nullptr), _lowMusicIgnored(false), _fieldF(false), _field109(0), _field10B(0), _field114(0), _field115(0), _field117(0) { _channels.resize(ADLIB_CHANNEL_COUNT); + Common::fill(&_fieldFB[0], &_fieldFB[7], 0); Common::fill(&_field10D[0], &_field10D[7], 0); - + _mixer = mixer; _opl = OPL::Config::create(); _opl->init(); _opl->start(new Common::Functor0Mem(this, &Music::onTimer), CALLBACKS_PER_SECOND); + initialize(); loadEffectsData(); } @@ -50,6 +52,15 @@ Music::~Music() { delete[] _effectsData; } +void Music::initialize() { + write(1, 0x20); + write(8, 0); + write(0xBD, 0); + + resetFrequencies(); + reset(); +} + void Music::loadEffectsData() { File file("admus"); Common::String md5str = Common::computeStreamMD5AsString(file, 8192); @@ -121,6 +132,13 @@ void Music::reset() { setOutputLevel(8, 63); } +void Music::resetFrequencies() { + for (int opNum = 6; opNum >= 0; --opNum) { + _fieldFB[opNum] = 0; + setFrequency(opNum, 0); + } +} + void Music::setFrequency(byte operatorNum, uint frequency) { write(0xA0 + operatorNum, frequency & 0xff); write(0xB0 + operatorNum, (frequency >> 8)); diff --git a/engines/xeen/music.h b/engines/xeen/music.h index 40059be327..c2202eb2f7 100644 --- a/engines/xeen/music.h +++ b/engines/xeen/music.h @@ -65,6 +65,7 @@ private: Common::Array _effectsOffsets; const byte *_musicPtr1, *_musicPtr2; bool _fieldF; + uint _fieldFB[7]; int _field109; int _field10B; byte _field10D[7]; @@ -73,6 +74,11 @@ private: int _field117; bool _lowMusicIgnored; private: + /** + * Initializes the state of the Adlib OPL driver + */ + void initialize(); + /** * Loads effects data that was embedded in the music driver */ @@ -104,6 +110,11 @@ private: */ void reset(); + /** + * Resets all the output frequencies + */ + void resetFrequencies(); + /** * Sets the frequency for an operator */ -- cgit v1.2.3