aboutsummaryrefslogtreecommitdiff
path: root/sky
diff options
context:
space:
mode:
Diffstat (limited to 'sky')
-rw-r--r--sky/adlibchannel.cpp7
-rw-r--r--sky/adlibchannel.h4
-rw-r--r--sky/adlibmusic.cpp16
-rw-r--r--sky/adlibmusic.h2
4 files changed, 13 insertions, 16 deletions
diff --git a/sky/adlibchannel.cpp b/sky/adlibchannel.cpp
index 60a43ed4f4..c277a66de5 100644
--- a/sky/adlibchannel.cpp
+++ b/sky/adlibchannel.cpp
@@ -20,11 +20,11 @@
*/
#include "adlibchannel.h"
+#include "sound/fmopl.h"
-SkyAdlibChannel::SkyAdlibChannel(uint8 *pMusicData, uint16 startOfData, FM_OPL *pOpl)
+SkyAdlibChannel::SkyAdlibChannel(uint8 *pMusicData, uint16 startOfData)
{
_musicData = pMusicData;
- _opl = pOpl;
_channelData.startOfData = startOfData;
_channelData.eventDataPtr = startOfData;
_channelData.channelActive = 1;
@@ -62,7 +62,8 @@ void SkyAdlibChannel::updateVolume(uint16 pVolume) {
void SkyAdlibChannel::setRegister(uint8 regNum, uint8 value) {
if (_adlibRegMirror[regNum] != value) {
- OPLWriteReg(_opl,regNum,value);
+ YM3812Write(0, 0, regNum);
+ YM3812Write(0, 1, value);
_adlibRegMirror[regNum] = value;
}
}
diff --git a/sky/adlibchannel.h b/sky/adlibchannel.h
index 485a99940a..de41ac53df 100644
--- a/sky/adlibchannel.h
+++ b/sky/adlibchannel.h
@@ -23,7 +23,6 @@
#define ADLIBCHANNEL_H
#include "stdafx.h"
-#include "sound/fmopl.h"
#include "common/engine.h"
#include "sky/musicbase.h"
@@ -60,14 +59,13 @@ typedef struct {
class SkyAdlibChannel : public SkyChannelBase {
public:
- SkyAdlibChannel(uint8 *pMusicData, uint16 startOfData, FM_OPL *pOpl);
+ SkyAdlibChannel(uint8 *pMusicData, uint16 startOfData);
virtual void stopNote(void);
virtual uint8 process(uint16 aktTime);
virtual void updateVolume(uint16 pVolume);
private:
uint8 *_musicData;
uint16 _musicVolume;
- FM_OPL *_opl;
AdlibChannelType _channelData;
//-
InstrumentStruct *_instruments;
diff --git a/sky/adlibmusic.cpp b/sky/adlibmusic.cpp
index 2e62b9db03..295f7e97bd 100644
--- a/sky/adlibmusic.cpp
+++ b/sky/adlibmusic.cpp
@@ -20,6 +20,7 @@
*/
#include "sky/adlibmusic.h"
+#include "sound/fmopl.h"
void SkyAdlibMusic::passMixerFunc(void *param, int16 *buf, uint len) {
@@ -32,17 +33,15 @@ SkyAdlibMusic::SkyAdlibMusic(SoundMixer *pMixer, SkyDisk *pSkyDisk)
_driverFileBase = 60202;
_mixer = pMixer;
_sampleRate = g_system->property(OSystem::PROP_GET_SAMPLE_RATE, 0);
- 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, _sampleRate);
+ if (0 != YM3812Init(1, 3579545, _sampleRate))
+ error("Error initialising YM3812 sound chip emulation");
_mixer->setupPremix(this, passMixerFunc);
}
SkyAdlibMusic::~SkyAdlibMusic(void) {
_mixer->setupPremix(NULL, NULL);
- OPLDestroy(_opl);
+ YM3812Shutdown();
}
void SkyAdlibMusic::premixerCall(int16 *buf, uint len) {
@@ -64,7 +63,7 @@ void SkyAdlibMusic::premixerCall(int16 *buf, uint len) {
render = (len > _nextMusicPoll) ? (_nextMusicPoll) : (len);
len -= render;
_nextMusicPoll -= render;
- YM3812UpdateOne(_opl, buf, render);
+ YM3812UpdateOne(0, buf, render);
buf += render;
if (_nextMusicPoll == 0) {
pollMusic();
@@ -86,7 +85,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, _opl);
+ _channels[cnt] = new SkyAdlibChannel(_musicData, chDataStart);
}
}
@@ -94,7 +93,8 @@ void SkyAdlibMusic::startDriver(void) {
uint16 cnt = 0;
while (_initSequence[cnt] || _initSequence[cnt+1]) {
- OPLWriteReg(_opl, _initSequence[cnt], _initSequence[cnt+1]);
+ YM3812Write(0, 0, _initSequence[cnt]);
+ YM3812Write(0, 1, _initSequence[cnt+1]);
cnt += 2;
}
_allowedCommands = 0xD;
diff --git a/sky/adlibmusic.h b/sky/adlibmusic.h
index 45cc94219b..31332b63b7 100644
--- a/sky/adlibmusic.h
+++ b/sky/adlibmusic.h
@@ -23,7 +23,6 @@
#define ADLIBMUSIC_H
#include "stdafx.h"
-#include "sound/fmopl.h"
#include "sound/mixer.h"
#include "common/engine.h"
#include "adlibchannel.h"
@@ -35,7 +34,6 @@ public:
~SkyAdlibMusic(void);
private:
SoundMixer *_mixer;
- FM_OPL *_opl;
uint8 *_initSequence;
uint32 _sampleRate, _nextMusicPoll;
virtual void setupPointers(void);