mirror of
https://github.com/scummvm/scummvm.git
synced 2026-06-20 05:45:29 +00:00
TWINE: use constants for music config and improved midi hqr detection
This commit is contained in:
committed by
Eugene Sandulenko
parent
cc716125f5
commit
431ac7f465
@@ -32,12 +32,6 @@
|
||||
|
||||
namespace TwinE {
|
||||
|
||||
/** Config movie types */
|
||||
#define CONF_MOVIE_NONE 0
|
||||
#define CONF_MOVIE_FLA 1
|
||||
#define CONF_MOVIE_FLAWIDE 2
|
||||
#define CONF_MOVIE_FLAPCX 3
|
||||
|
||||
/** FLA movie extension */
|
||||
#define FLA_EXT ".fla"
|
||||
|
||||
|
||||
+35
-17
@@ -35,32 +35,51 @@ namespace TwinE {
|
||||
|
||||
/** MP3 music folder */
|
||||
#define MUSIC_FOLDER "music"
|
||||
/** LBA1 default number of tracks */
|
||||
/**
|
||||
* LBA1 default number of tracks
|
||||
* <pre>
|
||||
* TRACK 01 MODE1/2352
|
||||
* INDEX 01 00:00:00
|
||||
* TRACK 02 AUDIO
|
||||
* INDEX 01 10:47:52
|
||||
* TRACK 03 AUDIO
|
||||
* INDEX 01 14:02:01
|
||||
* TRACK 04 AUDIO
|
||||
* INDEX 01 17:02:19
|
||||
* TRACK 05 AUDIO
|
||||
* INDEX 01 19:34:45
|
||||
* TRACK 06 AUDIO
|
||||
* INDEX 01 22:22:34
|
||||
* TRACK 07 AUDIO
|
||||
* INDEX 01 25:09:32
|
||||
* TRACK 08 AUDIO
|
||||
* INDEX 01 26:47:72
|
||||
* TRACK 09 AUDIO
|
||||
* INDEX 01 30:29:07
|
||||
* TRACK 10 AUDIO
|
||||
* INDEX 01 32:04:62
|
||||
* </pre>
|
||||
*/
|
||||
#define NUM_CD_TRACKS 10
|
||||
/** Number of miliseconds to fade music */
|
||||
#define FADE_MS 500
|
||||
|
||||
#if 0 // TODO
|
||||
/** SDL_Mixer track variable interface */
|
||||
Mix_Music *current_track;
|
||||
#endif
|
||||
|
||||
void Music::musicVolume(int32 volume) {
|
||||
_engine->_system->getMixer()->setVolumeForSoundType(Audio::Mixer::SoundType::kMusicSoundType, volume);
|
||||
}
|
||||
|
||||
void Music::musicFadeIn(int32 loops, int32 ms) {
|
||||
void Music::musicFadeIn() {
|
||||
int volume = _engine->_system->getMixer()->getVolumeForSoundType(Audio::Mixer::SoundType::kMusicSoundType);
|
||||
#if 0 // TODO
|
||||
Mix_FadeInMusic(current_track, loops, ms);
|
||||
Mix_FadeInMusic(current_track, 1, FADE_MS);
|
||||
#endif
|
||||
musicVolume(volume);
|
||||
}
|
||||
|
||||
void Music::musicFadeOut(int32 ms) {
|
||||
void Music::musicFadeOut() {
|
||||
int volume = _engine->_system->getMixer()->getVolumeForSoundType(Audio::Mixer::SoundType::kMusicSoundType);
|
||||
#if 0 // TODO
|
||||
while (!Mix_FadeOutMusic(ms) && Mix_PlayingMusic()) {
|
||||
while (!Mix_FadeOutMusic(FADE_MS) && Mix_PlayingMusic()) {
|
||||
SDL_Delay(100);
|
||||
}
|
||||
Mix_HaltMusic();
|
||||
@@ -104,13 +123,11 @@ void Music::stopTrackMusic() {
|
||||
return;
|
||||
}
|
||||
|
||||
musicFadeOut(FADE_MS);
|
||||
musicFadeOut();
|
||||
stopTrackMusicCd();
|
||||
}
|
||||
|
||||
void Music::playMidiMusic(int32 midiIdx, int32 loop) {
|
||||
uint8 *dos_midi_ptr;
|
||||
int32 midiSize;
|
||||
|
||||
if (!_engine->cfgfile.Sound) {
|
||||
return;
|
||||
@@ -124,19 +141,20 @@ void Music::playMidiMusic(int32 midiIdx, int32 loop) {
|
||||
currentMusic = midiIdx;
|
||||
|
||||
char filename[256];
|
||||
if (_engine->cfgfile.MidiType == 0)
|
||||
if (_engine->cfgfile.MidiType == MIDIFILE_DOS)
|
||||
snprintf(filename, sizeof(filename), "%s", Resources::HQR_MIDI_MI_DOS_FILE);
|
||||
else
|
||||
snprintf(filename, sizeof(filename), "%s", Resources::HQR_MIDI_MI_WIN_FILE);
|
||||
|
||||
if (midiPtr) {
|
||||
musicFadeOut(FADE_MS / 2);
|
||||
musicFadeOut();
|
||||
stopMidiMusic();
|
||||
}
|
||||
|
||||
midiSize = _engine->_hqrdepack->hqrGetallocEntry(&midiPtr, filename, midiIdx);
|
||||
int32 midiSize = _engine->_hqrdepack->hqrGetallocEntry(&midiPtr, filename, midiIdx);
|
||||
|
||||
if (_engine->cfgfile.Sound == 1 && _engine->cfgfile.MidiType == 0) {
|
||||
uint8 *dos_midi_ptr;
|
||||
midiSize = convert_to_midi(midiPtr, midiSize, &dos_midi_ptr);
|
||||
free(midiPtr);
|
||||
midiPtr = dos_midi_ptr;
|
||||
@@ -146,7 +164,7 @@ void Music::playMidiMusic(int32 midiIdx, int32 loop) {
|
||||
SDL_RWops *rw = SDL_RWFromMem(midiPtr, midiSize);
|
||||
current_track = Mix_LoadMUS_RW(rw, 0);
|
||||
|
||||
musicFadeIn(1, FADE_MS);
|
||||
musicFadeIn();
|
||||
|
||||
if (Mix_PlayMusic(current_track, loop) == -1)
|
||||
warning("Error while playing music: %d \n", midiIdx);
|
||||
|
||||
@@ -33,8 +33,8 @@ class Music {
|
||||
private:
|
||||
TwinEEngine *_engine;
|
||||
|
||||
void musicFadeIn(int32 loops, int32 ms);
|
||||
void musicFadeOut(int32 ms);
|
||||
void musicFadeIn();
|
||||
void musicFadeOut();
|
||||
|
||||
/** Auxiliar midi pointer to */
|
||||
uint8 *midiPtr = nullptr;
|
||||
|
||||
+12
-9
@@ -190,23 +190,26 @@ void TwinEEngine::initConfigurations() {
|
||||
cfgfile.FlagDisplayText = ConfGetOrDefault("FlagDisplayText", "ON") == "ON";
|
||||
cfgfile.FlagKeepVoice = ConfGetOrDefault("FlagKeepVoice", "OFF") == "ON";
|
||||
const Common::String midiType = ConfGetOrDefault("MidiType", "auto");
|
||||
if (midiType == "auto") {
|
||||
if (midiType == "None") {
|
||||
cfgfile.MidiType = MIDIFILE_NONE;
|
||||
} else {
|
||||
Common::File midiHqr;
|
||||
if (midiHqr.exists(Resources::HQR_MIDI_MI_WIN_FILE)) {
|
||||
cfgfile.MidiType = 1;
|
||||
cfgfile.MidiType = MIDIFILE_WIN;
|
||||
debug("Use %s for midi", Resources::HQR_MIDI_MI_WIN_FILE);
|
||||
} else if (midiHqr.exists(Resources::HQR_MIDI_MI_DOS_FILE)) {
|
||||
cfgfile.MidiType = MIDIFILE_DOS;
|
||||
debug("Use %s for midi", Resources::HQR_MIDI_MI_DOS_FILE);
|
||||
} else {
|
||||
cfgfile.MidiType = 0;
|
||||
cfgfile.MidiType = MIDIFILE_NONE;
|
||||
debug("Could not find midi hqr file");
|
||||
}
|
||||
} else if (midiType == "midi") {
|
||||
cfgfile.MidiType = 1;
|
||||
} else {
|
||||
cfgfile.MidiType = 0;
|
||||
}
|
||||
cfgfile.Version = ConfGetIntOrDefault("Version", EUROPE_VERSION);
|
||||
cfgfile.FullScreen = ConfGetIntOrDefault("FullScreen", 1) == 1;
|
||||
cfgfile.UseCD = ConfGetIntOrDefault("UseCD", 0);
|
||||
cfgfile.Sound = ConfGetIntOrDefault("Sound", 0);
|
||||
cfgfile.Movie = ConfGetIntOrDefault("Movie", 0);
|
||||
cfgfile.Sound = ConfGetIntOrDefault("Sound", 1);
|
||||
cfgfile.Movie = ConfGetIntOrDefault("Movie", CONF_MOVIE_FLA);
|
||||
cfgfile.CrossFade = ConfGetIntOrDefault("CrossFade", 0);
|
||||
cfgfile.Fps = ConfGetIntOrDefault("Fps", DEFAULT_FRAMES_PER_SECOND);
|
||||
cfgfile.Debug = ConfGetIntOrDefault("Debug", 0);
|
||||
|
||||
+16
-2
@@ -69,6 +69,20 @@ static const struct TwinELanguage {
|
||||
{"Italiano", "IT_"},
|
||||
{"Portugues", ""}};
|
||||
|
||||
enum MidiFileType {
|
||||
MIDIFILE_NONE,
|
||||
MIDIFILE_DOS,
|
||||
MIDIFILE_WIN
|
||||
};
|
||||
|
||||
/** Config movie types */
|
||||
enum MovieType {
|
||||
CONF_MOVIE_NONE = 0,
|
||||
CONF_MOVIE_FLA = 1,
|
||||
CONF_MOVIE_FLAWIDE = 2,
|
||||
CONF_MOVIE_FLAPCX = 3
|
||||
};
|
||||
|
||||
/** Configuration file structure
|
||||
|
||||
Used in the engine to load/use certain parts of code according with
|
||||
@@ -84,7 +98,7 @@ struct ConfigFile {
|
||||
/** Save voice files on hard disk */
|
||||
bool FlagKeepVoice = false;
|
||||
/** Type of music file to be used */
|
||||
int8 MidiType = 0;
|
||||
MidiFileType MidiType = MIDIFILE_NONE;
|
||||
/** *Game version */
|
||||
int32 Version = 0;
|
||||
/** To allow fullscreen or window mode. */
|
||||
@@ -94,7 +108,7 @@ struct ConfigFile {
|
||||
/** Allow various sound types */
|
||||
int32 Sound = 0;
|
||||
/** Allow various movie types */
|
||||
int32 Movie = 0;
|
||||
int32 Movie = CONF_MOVIE_FLA;
|
||||
/** Use cross fade effect while changing images, or be as the original */
|
||||
int32 CrossFade = 0;
|
||||
/** Flag used to keep the game frames per second */
|
||||
|
||||
Reference in New Issue
Block a user