From 2186ad138b1c6842c1ae2bf25cc55d75002cdb72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20G=C3=B6ffringmann?= Date: Wed, 28 May 2003 23:31:43 +0000 Subject: [PATCH] moved music drivers into seperated directory, added music support for diskdemo's adlib driver version. (maybe other sky versions also have this older adlib driver?) svn-id: r8069 --- sky/logic.h | 2 +- sky/module.mk | 8 ++++---- sky/{ => music}/adlibchannel.cpp | 24 ++++++++++++++++++------ sky/{ => music}/adlibchannel.h | 5 +++-- sky/{ => music}/adlibmusic.cpp | 19 +++++++++++++------ sky/{ => music}/adlibmusic.h | 2 +- sky/{ => music}/gmchannel.cpp | 0 sky/{ => music}/gmchannel.h | 2 +- sky/{ => music}/gmmusic.cpp | 4 ++-- sky/{ => music}/gmmusic.h | 2 +- sky/{ => music}/mt32music.cpp | 4 ++-- sky/{ => music}/mt32music.h | 2 +- sky/{ => music}/musicbase.cpp | 3 ++- sky/{ => music}/musicbase.h | 6 ++++-- sky/sky.cpp | 7 ++++--- sky/sky.h | 8 ++++---- 16 files changed, 61 insertions(+), 37 deletions(-) rename sky/{ => music}/adlibchannel.cpp (94%) rename sky/{ => music}/adlibchannel.h (95%) rename sky/{ => music}/adlibmusic.cpp (83%) rename sky/{ => music}/adlibmusic.h (95%) rename sky/{ => music}/gmchannel.cpp (100%) rename sky/{ => music}/gmchannel.h (98%) rename sky/{ => music}/gmmusic.cpp (98%) rename sky/{ => music}/gmmusic.h (95%) rename sky/{ => music}/mt32music.cpp (98%) rename sky/{ => music}/mt32music.h (95%) rename sky/{ => music}/musicbase.cpp (97%) rename sky/{ => music}/musicbase.h (96%) diff --git a/sky/logic.h b/sky/logic.h index e3fc3a65594..c0de38874aa 100644 --- a/sky/logic.h +++ b/sky/logic.h @@ -26,7 +26,7 @@ #include "sky/disk.h" #include "sky/grid.h" #include "sky/autoroute.h" -#include "sky/musicbase.h" +#include "sky/music/musicbase.h" #include "sky/mouse.h" #include "sky/screen.h" diff --git a/sky/module.mk b/sky/module.mk index 9a915cc72be..50a05e1e0bf 100644 --- a/sky/module.mk +++ b/sky/module.mk @@ -1,15 +1,11 @@ MODULE := sky MODULE_OBJS = \ - sky/adlibchannel.o \ - sky/adlibmusic.o \ sky/autoroute.o \ sky/cd_intro.o \ sky/compact.o \ sky/debug.o \ sky/disk.o \ - sky/gmchannel.o \ - sky/gmmusic.o \ sky/grid.o \ sky/intro.o \ sky/logic.o \ @@ -20,6 +16,10 @@ MODULE_OBJS = \ sky/sky.o \ sky/sound.o \ sky/text.o \ + sky/music/adlibchannel.o \ + sky/music/adlibmusic.o \ + sky/music/gmchannel.o \ + sky/music/gmmusic.o \ # Include common rules include common.rules diff --git a/sky/adlibchannel.cpp b/sky/music/adlibchannel.cpp similarity index 94% rename from sky/adlibchannel.cpp rename to sky/music/adlibchannel.cpp index c277a66de55..26ad9708149 100644 --- a/sky/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(uint8 *pMusicData, uint16 startOfData, uint32 version) { + _gameVersion = version; _musicData = pMusicData; _channelData.startOfData = startOfData; _channelData.eventDataPtr = startOfData; @@ -39,14 +40,25 @@ SkyAdlibChannel::SkyAdlibChannel(uint8 *pMusicData, uint16 startOfData) _channelData.frequency = 0; _channelData.instrumentData = NULL; - uint16 instrumentDataLoc = (_musicData[0x1206] << 8) | _musicData[0x1205]; + uint16 instrumentDataLoc; + + if (_gameVersion == 267) { + instrumentDataLoc = (_musicData[0x11FC] << 8) | _musicData[0x11FB]; + _frequenceTable = (uint16*)(_musicData+0x7F4); + _registerTable = _musicData+0xDF4; + _opOutputTable = _musicData+0xE06; + _adlibRegMirror = _musicData+0xF55; + } else { + instrumentDataLoc = (_musicData[0x1206] << 8) | _musicData[0x1205]; + _frequenceTable = (uint16*)(_musicData+0x7FE); + _registerTable = _musicData+0xDFE; + _opOutputTable = _musicData+0xE10; + _adlibRegMirror = _musicData+0xF5F; + } + _instrumentMap = _musicData+instrumentDataLoc; _instruments = (InstrumentStruct*)(_instrumentMap+0x80); - _frequenceTable = (uint16*)(_musicData+0x7FE); - _registerTable = _musicData+0xDFE; - _opOutputTable = _musicData+0xE10; - _adlibRegMirror = _musicData+0xF5F; _musicVolume = 0x100; } diff --git a/sky/adlibchannel.h b/sky/music/adlibchannel.h similarity index 95% rename from sky/adlibchannel.h rename to sky/music/adlibchannel.h index de41ac53df6..a9b43c3f9b2 100644 --- a/sky/adlibchannel.h +++ b/sky/music/adlibchannel.h @@ -24,7 +24,7 @@ #include "stdafx.h" #include "common/engine.h" -#include "sky/musicbase.h" +#include "sky/music/musicbase.h" typedef struct { uint8 ad_Op1, ad_Op2; @@ -59,11 +59,12 @@ typedef struct { class SkyAdlibChannel : public SkyChannelBase { public: - SkyAdlibChannel(uint8 *pMusicData, uint16 startOfData); + SkyAdlibChannel(uint8 *pMusicData, uint16 startOfData, uint32 version); virtual void stopNote(void); virtual uint8 process(uint16 aktTime); virtual void updateVolume(uint16 pVolume); private: + uint32 _gameVersion; uint8 *_musicData; uint16 _musicVolume; AdlibChannelType _channelData; diff --git a/sky/adlibmusic.cpp b/sky/music/adlibmusic.cpp similarity index 83% rename from sky/adlibmusic.cpp rename to sky/music/adlibmusic.cpp index 295f7e97bdb..b23afd879c9 100644 --- a/sky/adlibmusic.cpp +++ b/sky/music/adlibmusic.cpp @@ -19,7 +19,7 @@ * */ -#include "sky/adlibmusic.h" +#include "sky/music/adlibmusic.h" #include "sound/fmopl.h" void SkyAdlibMusic::passMixerFunc(void *param, int16 *buf, uint len) { @@ -27,8 +27,8 @@ void SkyAdlibMusic::passMixerFunc(void *param, int16 *buf, uint len) { ((SkyAdlibMusic*)param)->premixerCall(buf, len); } -SkyAdlibMusic::SkyAdlibMusic(SoundMixer *pMixer, SkyDisk *pSkyDisk) - : SkyMusicBase(pSkyDisk) { +SkyAdlibMusic::SkyAdlibMusic(SoundMixer *pMixer, SkyDisk *pSkyDisk, uint32 version) + : SkyMusicBase(pSkyDisk, version) { _driverFileBase = 60202; _mixer = pMixer; @@ -74,8 +74,15 @@ void SkyAdlibMusic::premixerCall(int16 *buf, uint len) { void SkyAdlibMusic::setupPointers(void) { - _musicDataLoc = (_musicData[0x1202]<<8)|_musicData[0x1201]; - _initSequence = _musicData+0xE91; + printf("game version: %d\n",_gameVersion); + if (_gameVersion == 267) { + // disk demo uses a different adlib driver version, some offsets have changed + _musicDataLoc = (_musicData[0x11F8] << 8) | _musicData[0x11F7]; + _initSequence = _musicData + 0xE87; + } else { + _musicDataLoc = (_musicData[0x1202] << 8) | _musicData[0x1201]; + _initSequence = _musicData + 0xE91; + } _nextMusicPoll = 0; } @@ -85,7 +92,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(_musicData, chDataStart, _gameVersion); } } diff --git a/sky/adlibmusic.h b/sky/music/adlibmusic.h similarity index 95% rename from sky/adlibmusic.h rename to sky/music/adlibmusic.h index 31332b63b71..dcde24150cc 100644 --- a/sky/adlibmusic.h +++ b/sky/music/adlibmusic.h @@ -30,7 +30,7 @@ class SkyAdlibMusic : public SkyMusicBase { public: - SkyAdlibMusic(SoundMixer *pMixer, SkyDisk *pSkyDisk); + SkyAdlibMusic(SoundMixer *pMixer, SkyDisk *pSkyDisk, uint32 version); ~SkyAdlibMusic(void); private: SoundMixer *_mixer; diff --git a/sky/gmchannel.cpp b/sky/music/gmchannel.cpp similarity index 100% rename from sky/gmchannel.cpp rename to sky/music/gmchannel.cpp diff --git a/sky/gmchannel.h b/sky/music/gmchannel.h similarity index 98% rename from sky/gmchannel.h rename to sky/music/gmchannel.h index eb5cb471b94..693eabf3d0b 100644 --- a/sky/gmchannel.h +++ b/sky/music/gmchannel.h @@ -25,7 +25,7 @@ #include "stdafx.h" #include "sound/mididrv.h" #include "common/engine.h" -#include "sky/musicbase.h" +#include "sky/music/musicbase.h" typedef struct { uint16 eventDataPtr; diff --git a/sky/gmmusic.cpp b/sky/music/gmmusic.cpp similarity index 98% rename from sky/gmmusic.cpp rename to sky/music/gmmusic.cpp index 98e79ca88dd..3d2ddf947d3 100644 --- a/sky/gmmusic.cpp +++ b/sky/music/gmmusic.cpp @@ -26,8 +26,8 @@ void SkyGmMusic::passTimerFunc(void *param) { ((SkyGmMusic*)param)->timerCall(); } -SkyGmMusic::SkyGmMusic(MidiDriver *pMidiDrv, SkyDisk *pSkyDisk) - : SkyMusicBase(pSkyDisk) { +SkyGmMusic::SkyGmMusic(MidiDriver *pMidiDrv, SkyDisk *pSkyDisk, uint32 version) + : SkyMusicBase(pSkyDisk, version) { _driverFileBase = 60200; _midiDrv = pMidiDrv; diff --git a/sky/gmmusic.h b/sky/music/gmmusic.h similarity index 95% rename from sky/gmmusic.h rename to sky/music/gmmusic.h index b3dca05b390..be26bf26fd8 100644 --- a/sky/gmmusic.h +++ b/sky/music/gmmusic.h @@ -30,7 +30,7 @@ class SkyGmMusic : public SkyMusicBase { public: - SkyGmMusic(MidiDriver *pMidiDrv, SkyDisk *pSkyDisk); + SkyGmMusic(MidiDriver *pMidiDrv, SkyDisk *pSkyDisk, uint32 version); ~SkyGmMusic(void); private: static void passTimerFunc(void *param); diff --git a/sky/mt32music.cpp b/sky/music/mt32music.cpp similarity index 98% rename from sky/mt32music.cpp rename to sky/music/mt32music.cpp index cb99c59f42b..53765f9941b 100644 --- a/sky/mt32music.cpp +++ b/sky/music/mt32music.cpp @@ -26,8 +26,8 @@ void SkyMT32Music::passTimerFunc(void *param) { ((SkyMT32Music*)param)->timerCall(); } -SkyMT32Music::SkyMT32Music(MidiDriver *pMidiDrv, SkyDisk *pSkyDisk) - : SkyMusicBase(pSkyDisk) { +SkyMT32Music::SkyMT32Music(MidiDriver *pMidiDrv, SkyDisk *pSkyDisk, uint32 version) + : SkyMusicBase(pSkyDisk, version) { _driverFileBase = 60200; _midiDrv = pMidiDrv; diff --git a/sky/mt32music.h b/sky/music/mt32music.h similarity index 95% rename from sky/mt32music.h rename to sky/music/mt32music.h index 76b2a18fc51..9b396b649dc 100644 --- a/sky/mt32music.h +++ b/sky/music/mt32music.h @@ -30,7 +30,7 @@ class SkyMT32Music : public SkyMusicBase { public: - SkyMT32Music(MidiDriver *pMidiDrv, SkyDisk *pSkyDisk); + SkyMT32Music(MidiDriver *pMidiDrv, SkyDisk *pSkyDisk, uint32 version); ~SkyMT32Music(void); private: static void passTimerFunc(void *param); diff --git a/sky/musicbase.cpp b/sky/music/musicbase.cpp similarity index 97% rename from sky/musicbase.cpp rename to sky/music/musicbase.cpp index cc1670f9963..7d930dae18f 100644 --- a/sky/musicbase.cpp +++ b/sky/music/musicbase.cpp @@ -21,8 +21,9 @@ #include "musicbase.h" -SkyMusicBase::SkyMusicBase(SkyDisk *pSkyDisk) { +SkyMusicBase::SkyMusicBase(SkyDisk *pSkyDisk, uint32 version) { + _gameVersion = version; _musicData = NULL; _allowedCommands = 0; _skyDisk = pSkyDisk; diff --git a/sky/musicbase.h b/sky/music/musicbase.h similarity index 96% rename from sky/musicbase.h rename to sky/music/musicbase.h index 587d9d8a8d6..306cfaa0db7 100644 --- a/sky/musicbase.h +++ b/sky/music/musicbase.h @@ -24,7 +24,7 @@ #include "stdafx.h" #include "common/engine.h" -#include "disk.h" +#include "sky/disk.h" #define FILES_PER_SECTION 4 @@ -43,13 +43,15 @@ private: class SkyMusicBase { public: - SkyMusicBase(SkyDisk *pSkyDisk); + SkyMusicBase(SkyDisk *pSkyDisk, uint32 version); virtual ~SkyMusicBase(void); void loadSection(uint8 pSection); void musicCommand(uint16 command); void startMusic(uint16 param) { _onNextPoll.musicToProcess = param & 0xF; }; // 4 protected: + uint32 _gameVersion; + SkyDisk *_skyDisk; uint8 *_musicData; uint8 _allowedCommands; diff --git a/sky/sky.cpp b/sky/sky.cpp index 3478a5e0d43..dee0b10303e 100644 --- a/sky/sky.cpp +++ b/sky/sky.cpp @@ -158,13 +158,14 @@ void SkyState::initialise(void) { _skyDisk = new SkyDisk(_gameDataPath); _skySound = new SkySound(_mixer, _skyDisk); + _gameVersion = _skyDisk->determineGameVersion(); + if (_detector->getMidiDriverType() == MD_ADLIB) { - _skyMusic = new SkyAdlibMusic(_mixer, _skyDisk); + _skyMusic = new SkyAdlibMusic(_mixer, _skyDisk, _gameVersion); } else { - _skyMusic = new SkyGmMusic(_detector->createMidi(), _skyDisk); + _skyMusic = new SkyGmMusic(_detector->createMidi(), _skyDisk, _gameVersion); } - _gameVersion = _skyDisk->determineGameVersion(); _skyText = new SkyText(_skyDisk, _gameVersion, _language); _skyMouse = new SkyMouse(_skyDisk); _skyScreen = new SkyScreen(_system, _skyDisk); diff --git a/sky/sky.h b/sky/sky.h index c5b0c05d8dd..de56ca29b72 100644 --- a/sky/sky.h +++ b/sky/sky.h @@ -33,10 +33,10 @@ #include "sky/struc.h" #include "sky/grid.h" #include "sky/screen.h" -#include "sky/musicbase.h" -#include "sky/adlibmusic.h" -#include "sky/gmmusic.h" -#include "sky/mt32music.h" +#include "sky/music/musicbase.h" +#include "sky/music/adlibmusic.h" +#include "sky/music/gmmusic.h" +#include "sky/music/mt32music.h" #include "sky/mouse.h" class SkyLogic;