mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-19 00:15:30 +00:00
BAGEL: Hook up MIDI playback
This commit is contained in:
parent
c106330550
commit
4a39e793ce
@ -26,6 +26,7 @@
|
||||
#include "graphics/palette.h"
|
||||
#include "bagel/bagel.h"
|
||||
#include "bagel/detection.h"
|
||||
#include "bagel/music.h"
|
||||
|
||||
#include "bagel/baglib/bagel.h"
|
||||
#include "bagel/baglib/character_object.h"
|
||||
@ -93,6 +94,7 @@ BagelEngine::BagelEngine(OSystem *syst, const ADGameDescription *gameDesc) : Eng
|
||||
}
|
||||
|
||||
BagelEngine::~BagelEngine() {
|
||||
delete _midi;
|
||||
delete _screen;
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "graphics/screen.h"
|
||||
|
||||
#include "bagel/detection.h"
|
||||
#include "bagel/music.h"
|
||||
#include "bagel/baglib/master_win.h"
|
||||
#include "bagel/boflib/stdinc.h"
|
||||
#include "bagel/boflib/bit_buf.h"
|
||||
@ -55,6 +56,7 @@ protected:
|
||||
|
||||
public:
|
||||
Graphics::Screen *_screen = nullptr;
|
||||
MusicPlayer *_midi = nullptr;
|
||||
bool _useOriginalSaveLoad = false;
|
||||
ZIPGLOBAL _zg;
|
||||
|
||||
|
@ -119,6 +119,12 @@ CBofSound::CBofSound(CBofWindow *pWnd, const CHAR *pszPathName, WORD wFlags, con
|
||||
m_wFlags |= SOUND_ASYNCH;
|
||||
}
|
||||
|
||||
if (m_wFlags & SOUND_MIDI) {
|
||||
m_chType = SOUND_TYPE_XM;
|
||||
} else {
|
||||
m_chType = SOUND_TYPE_WAV;
|
||||
}
|
||||
|
||||
if (pszPathName != nullptr) {
|
||||
|
||||
if ((m_szDrivePath[0] != '\0') && (*pszPathName == '.'))
|
||||
@ -210,6 +216,8 @@ VOID CBofSound::SetVolume(INT nVolume) {
|
||||
m_nVol = nLocalVolume;
|
||||
|
||||
g_system->getMixer()->setChannelVolume(m_handle, VOLUME_SVM(m_nVol));
|
||||
|
||||
// TODO: MIDI volume
|
||||
}
|
||||
|
||||
|
||||
@ -299,29 +307,13 @@ BOOL CBofSound::Play(DWORD dwBeginHere, DWORD TimeFormatFlag) {
|
||||
}
|
||||
|
||||
if (m_wFlags & SOUND_MIDI) {
|
||||
#if 0
|
||||
HMDIDRIVER hMidiDriver;
|
||||
|
||||
if ((hMidiDriver = CBofApp::GetApp()->GetMidiDriver()) != nullptr) {
|
||||
|
||||
if ((m_hSequence = AIL_allocate_sequence_handle(hMidiDriver)) != nullptr) {
|
||||
INT nError;
|
||||
|
||||
nError = AIL_init_sequence(m_hSequence, m_pFileBuf, 0);
|
||||
AIL_set_sequence_volume(m_hSequence, m_nVol * 10, 0);
|
||||
AIL_set_sequence_loop_count(m_hSequence, m_wLoops);
|
||||
AIL_start_sequence(m_hSequence);
|
||||
m_bPlaying = TRUE;
|
||||
|
||||
} else {
|
||||
ReportError(ERR_UNKNOWN, "Could not allocate an HSEQUENCE. (%s)", AIL_last_error());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
g_engine->_midi->play(this);
|
||||
m_bPlaying = TRUE;
|
||||
|
||||
} else if (m_wFlags & SOUND_WAVE) {
|
||||
|
||||
PlayMSS();
|
||||
PlayWAV();
|
||||
|
||||
if (m_bPlaying) {
|
||||
|
||||
@ -339,7 +331,7 @@ BOOL CBofSound::Play(DWORD dwBeginHere, DWORD TimeFormatFlag) {
|
||||
|
||||
if (!(m_wFlags & SOUND_QUEUE)) {
|
||||
|
||||
PlayMSS();
|
||||
PlayWAV();
|
||||
|
||||
} else {
|
||||
Assert(m_iQSlot >= 0 && m_iQSlot < NUM_QUEUES);
|
||||
@ -406,9 +398,12 @@ BOOL CBofSound::Pause() {
|
||||
// must be playing to be paused and not already paused
|
||||
//
|
||||
if (Playing() && (m_bPaused == FALSE)) {
|
||||
|
||||
g_system->getMixer()->pauseHandle(m_handle, true);
|
||||
|
||||
bSuccess = TRUE;
|
||||
if (m_wFlags & SOUND_MIDI) {
|
||||
g_engine->_midi->pause();
|
||||
} else {
|
||||
g_system->getMixer()->pauseHandle(m_handle, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (bSuccess)
|
||||
@ -445,9 +440,12 @@ BOOL CBofSound::Resume() {
|
||||
BOOL bSuccess = FALSE;
|
||||
|
||||
if (m_bPaused) { // must be paused to resume
|
||||
|
||||
g_system->getMixer()->pauseHandle(m_handle, false);
|
||||
|
||||
bSuccess = TRUE;
|
||||
if (m_wFlags & SOUND_MIDI) {
|
||||
g_engine->_midi->resume();
|
||||
} else {
|
||||
g_system->getMixer()->pauseHandle(m_handle, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -535,8 +533,12 @@ BOOL CBofSound::Stop() {
|
||||
// if this sound is currently playing
|
||||
//
|
||||
|
||||
g_system->getMixer()->stopHandle(m_handle);
|
||||
m_handle = {};
|
||||
if (m_wFlags & SOUND_MIDI) {
|
||||
g_engine->_midi->stop();
|
||||
} else {
|
||||
g_system->getMixer()->stopHandle(m_handle);
|
||||
m_handle = {};
|
||||
}
|
||||
|
||||
if (m_bInQueue) {
|
||||
Assert(m_iQSlot >= 0 && m_iQSlot < NUM_QUEUES);
|
||||
@ -994,24 +996,24 @@ VOID CBofSound::AudioTask() {
|
||||
//
|
||||
if ((CBofSound *)m_cQueue[pSound->m_iQSlot].GetQItem() == pSound) {
|
||||
|
||||
pSound->PlayMSS();
|
||||
pSound->PlayWAV();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else if (pSound->m_wFlags & SOUND_MIDI) {
|
||||
#if 0
|
||||
if (pSound->m_hSequence != nullptr) {
|
||||
|
||||
if (pSound->m_bPlaying) {
|
||||
|
||||
// And, Is it done?
|
||||
//
|
||||
if (AIL_sequence_status(pSound->m_hSequence) != SEQ_PLAYING) {
|
||||
if (!g_engine->_midi->isPlaying()) {
|
||||
|
||||
// Kill it
|
||||
pSound->Stop();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1021,7 +1023,7 @@ VOID CBofSound::AudioTask() {
|
||||
bAlready = FALSE;
|
||||
}
|
||||
|
||||
ERROR_CODE CBofSound::PlayMSS() {
|
||||
ERROR_CODE CBofSound::PlayWAV() {
|
||||
Assert(IsValidObject(this));
|
||||
|
||||
if (!ErrorOccurred()) {
|
||||
|
@ -73,6 +73,8 @@ namespace Bagel {
|
||||
|
||||
class CBofSound : public CBofError, public CBofObject, public CLList {
|
||||
public:
|
||||
friend class MusicPlayer;
|
||||
|
||||
CBofSound(CBofWindow *pWnd, const CHAR *pszPathName, WORD wFlags, const INT nLoops = 1);
|
||||
virtual ~CBofSound();
|
||||
|
||||
@ -153,7 +155,7 @@ public:
|
||||
|
||||
static VOID SetQVol(INT nSlot, INT nVol);
|
||||
|
||||
ERROR_CODE PlayMSS();
|
||||
ERROR_CODE PlayWAV();
|
||||
|
||||
static ERROR_CODE FlushQueue(INT nSlot);
|
||||
|
||||
|
@ -40,7 +40,7 @@ const DebugChannelDef BagelMetaEngineDetection::debugFlagList[] = {
|
||||
|
||||
BagelMetaEngineDetection::BagelMetaEngineDetection() : AdvancedMetaEngineDetection(Bagel::gameDescriptions,
|
||||
sizeof(ADGameDescription), Bagel::bagelGames) {
|
||||
_guiOptions = GUIO1(GAMEOPTION_ORIGINAL_SAVELOAD);
|
||||
_guiOptions = GUIO2(GUIO_NOSPEECH, GAMEOPTION_ORIGINAL_SAVELOAD);
|
||||
}
|
||||
|
||||
REGISTER_PLUGIN_STATIC(BAGEL_DETECTION, PLUGIN_TYPE_ENGINE_DETECTION, BagelMetaEngineDetection);
|
||||
|
@ -4,6 +4,7 @@ MODULE_OBJS = \
|
||||
bagel.o \
|
||||
console.o \
|
||||
metaengine.o \
|
||||
music.o \
|
||||
baglib/bagel.o \
|
||||
baglib/base_pda.o \
|
||||
baglib/bmp_object.o \
|
||||
|
89
engines/bagel/music.cpp
Normal file
89
engines/bagel/music.cpp
Normal file
@ -0,0 +1,89 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "audio/mididrv.h"
|
||||
#include "audio/midiparser.h"
|
||||
|
||||
#include "bagel/music.h"
|
||||
#include "bagel/boflib/sound.h"
|
||||
|
||||
namespace Bagel {
|
||||
|
||||
MusicPlayer::MusicPlayer() {
|
||||
|
||||
MidiPlayer::createDriver();
|
||||
|
||||
int ret = _driver->open();
|
||||
if (ret == 0) {
|
||||
if (_nativeMT32)
|
||||
_driver->sendMT32Reset();
|
||||
else
|
||||
_driver->sendGMReset();
|
||||
|
||||
_driver->setTimerCallback(this, &timerCallback);
|
||||
}
|
||||
}
|
||||
|
||||
void MusicPlayer::play(CBofSound *sound) {
|
||||
Common::StackLock lock(_mutex);
|
||||
|
||||
if (_isPlaying && sound == _sound) {
|
||||
// Already playing
|
||||
return;
|
||||
}
|
||||
|
||||
MidiParser *parser = nullptr;
|
||||
if (sound->m_chType == SOUND_TYPE_XM) {
|
||||
parser = MidiParser::createParser_XMIDI();
|
||||
} else if (sound->m_chType == SOUND_TYPE_QT) {
|
||||
parser = MidiParser::createParser_QT();
|
||||
} else {
|
||||
warning("Invalid sound %s passed to MusicPlayer", sound->m_szFileName);
|
||||
return;
|
||||
}
|
||||
|
||||
if (parser->loadMusic(sound->m_pFileBuf, sound->m_iFileSize)) {
|
||||
stop();
|
||||
parser->setTrack(0);
|
||||
parser->setMidiDriver(this);
|
||||
parser->setTimerRate(_driver->getBaseTempo());
|
||||
parser->property(MidiParser::mpCenterPitchWheelOnUnload, 1);
|
||||
|
||||
_parser = parser;
|
||||
|
||||
// TODO: Set channel volume
|
||||
syncVolume();
|
||||
|
||||
_isLooping = (sound->m_wLoops == 0);
|
||||
_isPlaying = true;
|
||||
_sound = sound;
|
||||
} else {
|
||||
warning("Failed to play %s", sound->m_szFileName);
|
||||
delete parser;
|
||||
}
|
||||
}
|
||||
|
||||
void MusicPlayer::stop() {
|
||||
Audio::MidiPlayer::stop();
|
||||
_sound = nullptr;
|
||||
}
|
||||
|
||||
} // End of namespace Bagel
|
43
engines/bagel/music.h
Normal file
43
engines/bagel/music.h
Normal file
@ -0,0 +1,43 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef BAGEL_MUSIC_H
|
||||
#define BAGEL_MUSIC_H
|
||||
|
||||
#include "audio/midiplayer.h"
|
||||
#include "bagel/boflib/sound.h"
|
||||
|
||||
namespace Bagel {
|
||||
|
||||
class MusicPlayer : public Audio::MidiPlayer {
|
||||
private:
|
||||
CBofSound *_sound = nullptr;
|
||||
|
||||
public:
|
||||
MusicPlayer();
|
||||
|
||||
void play(CBofSound *sound);
|
||||
void stop() override;
|
||||
};
|
||||
|
||||
} // End of namespace Bagel
|
||||
|
||||
#endif
|
@ -23,6 +23,7 @@
|
||||
#include "common/config-manager.h"
|
||||
#include "engines/util.h"
|
||||
#include "bagel/console.h"
|
||||
#include "bagel/music.h"
|
||||
#include "bagel/spacebar/spacebar.h"
|
||||
#include "bagel/spacebar/master_win.h"
|
||||
#include "bagel/spacebar/bib_odds_wnd.h"
|
||||
@ -223,7 +224,10 @@ Common::Error SpaceBarEngine::run() {
|
||||
Graphics::PixelFormat format(2, 5, 6, 5, 0, 11, 5, 0, 0);
|
||||
initGraphics(640, 480, &format);
|
||||
|
||||
// Initialize systems
|
||||
_screen = new Graphics::Screen();
|
||||
_midi = new MusicPlayer();
|
||||
syncSoundSettings();
|
||||
|
||||
// Set the engine's debugger console
|
||||
setDebugger(new Console());
|
||||
|
Loading…
x
Reference in New Issue
Block a user