aboutsummaryrefslogtreecommitdiff
path: root/sky/music
diff options
context:
space:
mode:
authorJamieson Christian2003-07-11 07:14:21 +0000
committerJamieson Christian2003-07-11 07:14:21 +0000
commit8b8b964aadcf0f37cfb853c83857da7271af5ebc (patch)
tree0084198c30998e89b2331a8b678cc42a21dbfa72 /sky/music
parent39b37df37a7fed6f5dd62d11fb10e4b8276f05c1 (diff)
downloadscummvm-rg350-8b8b964aadcf0f37cfb853c83857da7271af5ebc.tar.gz
scummvm-rg350-8b8b964aadcf0f37cfb853c83857da7271af5ebc.tar.bz2
scummvm-rg350-8b8b964aadcf0f37cfb853c83857da7271af5ebc.zip
Reverted to "old" YM3812 (FMOPL) emulator code.
Until specific information regarding the benefits of migrating to the new emulator can be made available, the "old" code will remain in effect for the benefit of slower hardware platforms such as some WinCE-based devices. svn-id: r8903
Diffstat (limited to 'sky/music')
-rw-r--r--sky/music/adlibchannel.cpp8
-rw-r--r--sky/music/adlibchannel.h4
-rw-r--r--sky/music/adlibmusic.cpp20
-rw-r--r--sky/music/adlibmusic.h2
4 files changed, 23 insertions, 11 deletions
diff --git a/sky/music/adlibchannel.cpp b/sky/music/adlibchannel.cpp
index 6a320969d5..7418b05568 100644
--- a/sky/music/adlibchannel.cpp
+++ b/sky/music/adlibchannel.cpp
@@ -22,8 +22,9 @@
#include "adlibchannel.h"
#include "sound/fmopl.h"
-SkyAdlibChannel::SkyAdlibChannel(uint8 *pMusicData, uint16 startOfData)
+SkyAdlibChannel::SkyAdlibChannel(FM_OPL *opl, uint8 *pMusicData, uint16 startOfData)
{
+ _opl = opl;
_musicData = pMusicData;
_channelData.startOfData = startOfData;
_channelData.eventDataPtr = startOfData;
@@ -78,8 +79,9 @@ void SkyAdlibChannel::updateVolume(uint16 pVolume) {
void SkyAdlibChannel::setRegister(uint8 regNum, uint8 value) {
if (_adlibRegMirror[regNum] != value) {
- YM3812Write(0, 0, regNum);
- YM3812Write(0, 1, value);
+// YM3812Write(0, 0, regNum);
+// YM3812Write(0, 1, value);
+ OPLWriteReg (_opl, regNum, value);
_adlibRegMirror[regNum] = value;
}
}
diff --git a/sky/music/adlibchannel.h b/sky/music/adlibchannel.h
index 8ca72e8a58..3b27c2305b 100644
--- a/sky/music/adlibchannel.h
+++ b/sky/music/adlibchannel.h
@@ -26,6 +26,7 @@
#include "common/engine.h"
#include "sky/sky.h"
#include "sky/music/musicbase.h"
+#include "sound/fmopl.h"
typedef struct {
uint8 ad_Op1, ad_Op2;
@@ -60,12 +61,13 @@ typedef struct {
class SkyAdlibChannel : public SkyChannelBase {
public:
- SkyAdlibChannel(uint8 *pMusicData, uint16 startOfData);
+ SkyAdlibChannel (FM_OPL *opl, uint8 *pMusicData, uint16 startOfData);
virtual void stopNote(void);
virtual uint8 process(uint16 aktTime);
virtual void updateVolume(uint16 pVolume);
virtual bool isActive(void);
private:
+ FM_OPL *_opl;
uint8 *_musicData;
uint16 _musicVolume;
AdlibChannelType _channelData;
diff --git a/sky/music/adlibmusic.cpp b/sky/music/adlibmusic.cpp
index 6922295ef3..444e4cd3e0 100644
--- a/sky/music/adlibmusic.cpp
+++ b/sky/music/adlibmusic.cpp
@@ -33,15 +33,20 @@ SkyAdlibMusic::SkyAdlibMusic(SoundMixer *pMixer, SkyDisk *pSkyDisk, OSystem *sys
_driverFileBase = 60202;
_mixer = pMixer;
_sampleRate = g_system->property(OSystem::PROP_GET_SAMPLE_RATE, 0);
- if (0 != YM3812Init(1, 3579545, _sampleRate))
- error("Error initialising YM3812 sound chip emulation");
+// if (0 != YM3812Init(1, 3579545, _sampleRate))
+// error("Error initialising YM3812 sound chip emulation");
+ int env_bits = g_system->property(OSystem::PROP_GET_FMOPL_ENV_BITS, NULL);
+ int eg_ent = g_system->property(OSystem::PROP_GET_FMOPL_EG_ENT, NULL);
+ OPLBuildTables((env_bits ? env_bits : FMOPL_ENV_BITS_HQ), (eg_ent ? eg_ent : FMOPL_EG_ENT_HQ));
+ _opl = OPLCreate(OPL_TYPE_YM3812, 3579545, g_system->property(OSystem::PROP_GET_SAMPLE_RATE, 0));
+
_mixer->setupPremix(this, passMixerFunc);
}
SkyAdlibMusic::~SkyAdlibMusic(void) {
_mixer->setupPremix(NULL, NULL);
- YM3812Shutdown();
+// YM3812Shutdown();
}
void SkyAdlibMusic::setVolume(uint8 volume) {
@@ -70,7 +75,7 @@ void SkyAdlibMusic::premixerCall(int16 *buf, uint len) {
render = (len > _nextMusicPoll) ? (_nextMusicPoll) : (len);
len -= render;
_nextMusicPoll -= render;
- YM3812UpdateOne(0, buf, render);
+ YM3812UpdateOne (_opl, buf, render);
buf += render;
if (_nextMusicPoll == 0) {
pollMusic();
@@ -98,7 +103,7 @@ void SkyAdlibMusic::setupChannels(uint8 *channelData) {
channelData++;
for (uint8 cnt = 0; cnt < _numberOfChannels; cnt++) {
uint16 chDataStart = ((channelData[(cnt << 1) | 1] << 8) | channelData[cnt << 1]) + _musicDataLoc;
- _channels[cnt] = new SkyAdlibChannel(_musicData, chDataStart);
+ _channels[cnt] = new SkyAdlibChannel(_opl, _musicData, chDataStart);
_channels[cnt]->updateVolume(_musicVolume | 128);
}
}
@@ -107,8 +112,9 @@ void SkyAdlibMusic::startDriver(void) {
uint16 cnt = 0;
while (_initSequence[cnt] || _initSequence[cnt+1]) {
- YM3812Write(0, 0, _initSequence[cnt]);
- YM3812Write(0, 1, _initSequence[cnt+1]);
+// YM3812Write(0, 0, _initSequence[cnt]);
+// YM3812Write(0, 1, _initSequence[cnt+1]);
+ OPLWriteReg (_opl, _initSequence[cnt], _initSequence[cnt+1]);
cnt += 2;
}
_allowedCommands = 0xD;
diff --git a/sky/music/adlibmusic.h b/sky/music/adlibmusic.h
index dd7085b0cd..481977b385 100644
--- a/sky/music/adlibmusic.h
+++ b/sky/music/adlibmusic.h
@@ -28,6 +28,7 @@
#include "common/engine.h"
#include "adlibchannel.h"
#include "musicbase.h"
+#include "sound/fmopl.h"
class SkyAdlibMusic : public SkyMusicBase {
public:
@@ -35,6 +36,7 @@ public:
~SkyAdlibMusic(void);
virtual void setVolume(uint8 volume);
private:
+ FM_OPL *_opl;
SoundMixer *_mixer;
uint8 *_initSequence;
uint32 _sampleRate, _nextMusicPoll;