[Scummvm-cvs-logs] CVS: scummvm/queen music.cpp,NONE,1.1 music.h,NONE,1.1 module.mk,1.17,1.18 queen.cpp,1.55,1.56 queen.h,1.19,1.20 sound.cpp,1.16,1.17
Joost Peters
joostp at users.sourceforge.net
Sun Dec 14 01:48:08 CET 2003
Update of /cvsroot/scummvm/scummvm/queen
In directory sc8-pr-cvs1:/tmp/cvs-serv3662/queen
Modified Files:
module.mk queen.cpp queen.h sound.cpp
Added Files:
music.cpp music.h
Log Message:
Initial (Roland) Music support; a lot of stuff is still missing and/or incomplete.
--- NEW FILE: music.cpp ---
/* ScummVM - Scumm Interpreter
* Copyright (C) 2003 The ScummVM project
*
* 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 2
* 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Header: /cvsroot/scummvm/scummvm/queen/music.cpp,v 1.1 2003/12/14 00:33:21 joostp Exp $
*
*/
#include "stdafx.h"
#include "queen/music.h"
#include "queen/queen.h"
#include "queen/resource.h"
#include "sound/mididrv.h"
#include "sound/midiparser.h"
namespace Queen {
Music::Music(MidiDriver *driver, QueenEngine *vm) : _loop(false), _driver(driver) {
_midi = MidiParser::createParser_SMF();
_midi->setMidiDriver(_driver);
int ret = _driver->open();
if (ret)
warning("MIDI Player init failed: \"%s\"", _driver->getErrorName(ret));
_midi->setTimerRate(_driver->getBaseTempo());
_driver->setTimerCallback((void *)_midi, _midi->timerCallback);
_musicData = vm->resource()->loadFile("AQ.RL", 0, NULL);
_musicDataSize = vm->resource()->fileSize("AQ.RL");
_numSongs = READ_LE_UINT16(_musicData);
}
Music::~Music() {
stopSong();
_midi->unloadMusic();
delete _midi;
delete[] _musicData;
}
void Music::playSong(uint16 songNum) {
if (_loop)
_midi->property(MidiParser::mpAutoLoop, 1);
else
_midi->property(MidiParser::mpAutoLoop, 0);
_midi->loadMusic(_musicData + songOffset(songNum), songLength(songNum));
_midi->setTrack(0);
_driver->setTimerCallback((void *)_midi, _midi->timerCallback);
}
void Music::stopSong() {
_driver->setTimerCallback(NULL, NULL);
}
uint32 Music::songOffset(uint16 songNum) {
uint16 offsLo = READ_LE_UINT16(_musicData + (songNum * 4) + 2);
uint16 offsHi = READ_LE_UINT16(_musicData + (songNum * 4) + 4);
return (offsHi << 4) | offsLo;
}
uint32 Music::songLength(uint16 songNum) {
if (songNum < _numSongs)
return (songOffset(songNum + 1) - songOffset(songNum));
return (_musicDataSize - songOffset(songNum));
}
} // End of namespace Queen
--- NEW FILE: music.h ---
/* ScummVM - Scumm Interpreter
* Copyright (C) 2003 The ScummVM project
*
* 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 2
* 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Header: /cvsroot/scummvm/scummvm/queen/music.h,v 1.1 2003/12/14 00:33:21 joostp Exp $
*
*/
#ifndef QUEENMUSIC_H
#define QUEENMUSIC_H
#include "common/util.h"
class MidiDriver;
class MidiParser;
namespace Queen {
class QueenEngine;
class Music {
public:
Music(MidiDriver *_driver, QueenEngine *vm);
~Music();
void playSong(uint16 songNum);
void stopSong();
void loop(bool val) { _loop = val; }
protected:
bool _loop;
byte *_musicData;
uint16 _numSongs;
uint32 _musicDataSize;
MidiDriver *_driver;
MidiParser *_midi;
QueenEngine *_vm;
uint32 songOffset(uint16 songNum);
uint32 songLength(uint16 songNum);
};
} // End of namespace Queen
#endif
Index: module.mk
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/module.mk,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- module.mk 11 Dec 2003 10:03:35 -0000 1.17
+++ module.mk 14 Dec 2003 00:33:21 -0000 1.18
@@ -9,6 +9,7 @@
queen/input.o \
queen/journal.o \
queen/logic.o \
+ queen/music.o \
queen/musicdata.o \
queen/queen.o \
queen/resource.o \
Index: queen.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/queen.cpp,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -d -r1.55 -r1.56
--- queen.cpp 13 Dec 2003 20:05:28 -0000 1.55
+++ queen.cpp 14 Dec 2003 00:33:21 -0000 1.56
@@ -37,6 +37,7 @@
#include "queen/graphics.h"
#include "queen/input.h"
#include "queen/logic.h"
+#include "queen/music.h"
#include "queen/resource.h"
#include "queen/sound.h"
#include "queen/talk.h"
@@ -107,6 +108,7 @@
delete _graphics;
delete _input;
delete _logic;
+ delete _music;
delete _sound;
delete _walk;
}
@@ -119,7 +121,7 @@
void QueenEngine::go() {
initialise();
-
+
_logic->registerDefaultSettings();
_logic->readOptionSettings();
@@ -163,6 +165,7 @@
_graphics = new Graphics(this);
_input = new Input(_resource->getLanguage(), _system);
_logic = new Logic(this);
+ _music = new Music(GameDetector::createMidi(GameDetector::detectMusicDriver(MDT_NATIVE)), this);
_sound = Sound::giveSound(_mixer, this, _resource->compression());
_walk = new Walk(this);
_timer->installTimerProc(&timerHandler, 1000000 / 50, this); //call 50 times per second
Index: queen.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/queen.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- queen.h 12 Dec 2003 15:29:58 -0000 1.19
+++ queen.h 14 Dec 2003 00:33:21 -0000 1.20
@@ -33,6 +33,7 @@
class Graphics;
class Input;
class Logic;
+class Music;
class Resource;
class Sound;
class Walk;
@@ -48,6 +49,7 @@
Graphics *graphics() const { return _graphics; }
Input *input() const { return _input; }
Logic *logic() const { return _logic; }
+ Music *music() const { return _music; }
Resource *resource() const { return _resource; }
Sound *sound() const { return _sound; }
Walk *walk() const { return _walk; }
@@ -70,6 +72,7 @@
Graphics *_graphics;
Input *_input;
Logic *_logic;
+ Music *_music;
Resource *_resource;
Sound *_sound;
Walk *_walk;
Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/sound.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- sound.cpp 11 Dec 2003 22:16:35 -0000 1.16
+++ sound.cpp 14 Dec 2003 00:33:21 -0000 1.17
@@ -23,6 +23,7 @@
#include "queen/sound.h"
#include "queen/input.h"
+#include "queen/music.h"
#include "queen/queen.h"
#include "queen/resource.h"
@@ -135,10 +136,36 @@
}
void Sound::playSong(int16 songNum) {
+ if (songNum == STOP_MUSIC) {
+ _vm->music()->stopSong();
+ return;
+ }
+
int16 newTune = _song[songNum - 1].tuneList[0];
- if (_tune[newTune - 1].sfx[0] && sfxOn())
+ if (_tune[newTune - 1].sfx[0] && sfxOn()) {
sfxPlay(_sfxName[_tune[newTune - 1].sfx[0] - 1]);
+ return;
+ }
+
+ //TODO: Record onto song stack for saving/loading
+
+ switch (_tune[newTune - 1].mode) {
+ //Random loop
+ case 0:
+ warning("Music: Random loop not yet supported (doing sequential loop instead)");
+ //Sequential loop
+ case 1:
+ _vm->music()->loop(true);
+ break;
+ //Play once
+ case 2:
+ default:
+ _vm->music()->loop(false);
+ break;
+ }
+
+ _vm->music()->playSong(_tune[newTune - 1].tuneNum[0] - 1);
}
More information about the Scummvm-git-logs
mailing list