diff options
author | Paul Gilbert | 2016-09-12 21:37:52 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-09-12 21:37:52 -0400 |
commit | 575daf32e28de21db3ac2ed5a80463a8adacd47f (patch) | |
tree | 6bec5c7451526d65c50d65ee030b56b1ed72cbf2 /engines | |
parent | dd06b6fd7a98748d6a4c0f9f63519847dc6dd3f7 (diff) | |
download | scummvm-rg350-575daf32e28de21db3ac2ed5a80463a8adacd47f.tar.gz scummvm-rg350-575daf32e28de21db3ac2ed5a80463a8adacd47f.tar.bz2 scummvm-rg350-575daf32e28de21db3ac2ed5a80463a8adacd47f.zip |
XEEN: Extra Adlib initialization during Music creation
Diffstat (limited to 'engines')
-rw-r--r-- | engines/xeen/music.cpp | 22 | ||||
-rw-r--r-- | engines/xeen/music.h | 11 |
2 files changed, 31 insertions, 2 deletions
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<void, Music>(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<uint16> _effectsOffsets; const byte *_musicPtr1, *_musicPtr2; bool _fieldF; + uint _fieldFB[7]; int _field109; int _field10B; byte _field10D[7]; @@ -74,6 +75,11 @@ private: bool _lowMusicIgnored; private: /** + * Initializes the state of the Adlib OPL driver + */ + void initialize(); + + /** * Loads effects data that was embedded in the music driver */ void loadEffectsData(); @@ -105,6 +111,11 @@ private: void reset(); /** + * Resets all the output frequencies + */ + void resetFrequencies(); + + /** * Sets the frequency for an operator */ void setFrequency(byte operatorNum, uint frequency); |