[Scummvm-cvs-logs] CVS: scummvm/simon items.cpp,1.68,1.69 midi.cpp,1.34,1.35 midi.h,1.12,1.13 vga.cpp,1.47,1.48
Jamieson Christian
jamieson630 at users.sourceforge.net
Tue May 20 21:37:04 CEST 2003
Update of /cvsroot/scummvm/scummvm/simon
In directory sc8-pr-cvs1:/tmp/cvs-serv1892
Modified Files:
items.cpp midi.cpp midi.h vga.cpp
Log Message:
More Simon music fixes
Index: items.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/items.cpp,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -d -r1.68 -r1.69
--- items.cpp 21 May 2003 00:45:31 -0000 1.68
+++ items.cpp 21 May 2003 04:36:09 -0000 1.69
@@ -1444,10 +1444,12 @@
// effectively preloaded so there's no latency when
// starting playback).
if (_game & GF_SIMON2) {
- int play = getVarOrByte();
+ int loop = getVarOrByte();
if (_debugMode)
- debug (0, "o_unk_127 (%d, %d, %d);", music, track, play);
+ debug (0, "o_unk_127 (%d, %d, %d): Load/play music resource", music, track, loop);
+
+ midi.setLoop (loop != 0);
if (_last_music_played != music) {
playMusic (music);
@@ -1460,19 +1462,11 @@
return;
_vc72_var1 = track;
+ _vc70_var1 = -1;
_vc70_var2 = -1;
+ _vc72_var2 = -1;
_vc72_var3 = -1;
midi_play (track);
-
- // FIXME: This doesn't seem to actually be a pause
- // indicator. If it's interpreted as such, it spoils
- // the music when Simon is exiting Calypso's shop
- // during the opening cutscene. Let's see if it
- // ever goes to anything besides 0 or 1.
-// if (play == 0)
-// midi.pause (true);
- if (play != 0 && play != 1)
- warning ("o_unk_127: play mode %d encountered!", play);
} else {
if (music != _last_music_played) {
_last_music_played = music;
Index: midi.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/midi.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- midi.cpp 21 May 2003 00:40:08 -0000 1.34
+++ midi.cpp 21 May 2003 04:36:09 -0000 1.35
@@ -37,10 +37,14 @@
_parser = 0;
_data = 0;
- memset(_volumeTable, 0, sizeof(_volumeTable));
+ memset(_volumeTable, 127, sizeof(_volumeTable));
_masterVolume = 255;
_paused = false;
_currentTrack = 255;
+ _loopTrack = 0;
+
+ _queuedTrack = 255;
+ _loopQueuedTrack = 0;
_num_songs = 0;
memset(_songs, 0, sizeof(_songs));
@@ -99,7 +103,26 @@
if (type != 0x2F)
return;
- _parser->jumpToTick (0);
+ if (_loopTrack) {
+ _parser->jumpToTick (0);
+ } else if (_queuedTrack != 255) {
+ _currentTrack = 255;
+ byte destination = _queuedTrack;
+ _queuedTrack = 255;
+ _loopTrack = _loopQueuedTrack;
+ _loopQueuedTrack = false;
+
+ // Remember, we're still inside the locked mutex.
+ // Have to unlock it before calling jump()
+ // (which locks it itself), and then relock it
+ // upon returning.
+ debug (0, " Switching to queued track");
+ _system->unlock_mutex (_mutex);
+ jump (destination, 0);
+ _system->lock_mutex (_mutex);
+ } else {
+ stop();
+ }
}
void MidiPlayer::onTimer (void *data) {
@@ -149,9 +172,8 @@
}
void MidiPlayer::stop() {
+ pause (true);
_system->lock_mutex (_mutex);
- if (_parser)
- _parser->unloadMusic();
_currentTrack = 255;
_system->unlock_mutex (_mutex);
}
@@ -193,6 +215,25 @@
if (_driver)
return;
_driver = md;
+}
+
+void MidiPlayer::setLoop (bool loop) {
+ _system->lock_mutex (_mutex);
+ _loopTrack = loop;
+ _system->unlock_mutex (_mutex);
+}
+
+void MidiPlayer::queueTrack (byte track, bool loop) {
+ _system->lock_mutex (_mutex);
+ if (_currentTrack == 255) {
+ _system->unlock_mutex (_mutex);
+ setLoop (loop);
+ jump (track, 0);
+ } else {
+ _queuedTrack = track;
+ _loopQueuedTrack = loop;
+ _system->unlock_mutex (_mutex);
+ }
}
void MidiPlayer::clearConstructs() {
Index: midi.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/midi.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- midi.h 19 May 2003 04:59:53 -0000 1.12
+++ midi.h 21 May 2003 04:36:09 -0000 1.13
@@ -40,6 +40,9 @@
byte _masterVolume; // 0-255
bool _paused;
byte _currentTrack;
+ bool _loopTrack;
+ byte _queuedTrack;
+ bool _loopQueuedTrack;
byte _num_songs;
byte *_songs[16];
@@ -57,6 +60,11 @@
void playSMF (File *in, int song);
void playMultipleSMF (File *in);
void playXMIDI (File *in);
+
+ void setLoop (bool loop);
+ void queueTrack (byte track, bool loop);
+ bool isPlaying (bool check_queued = false) { return (_currentTrack != 255 && (_queuedTrack != 255 || !check_queued)); }
+
void jump (uint16 track, uint16 tick);
void stop();
void pause (bool b);
Index: vga.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/vga.cpp,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- vga.cpp 21 May 2003 00:44:36 -0000 1.47
+++ vga.cpp 21 May 2003 04:36:09 -0000 1.48
@@ -1805,13 +1805,13 @@
void SimonState::vc_69() {
// Simon2
int16 track = vc_read_next_word();
- int16 paused = vc_read_next_word();
+ int16 loop = vc_read_next_word();
if (_debugMode)
- warning("vc_69(%d,%d): music stuff", track, paused);
+ debug (0, "vc_69(%d,%d): Play track", track, loop);
// Jamieson630:
- // This is a "play or queue track". The original
+ // This is a "play track". The original
// design stored the track to play if one was
// already in progress, so that the next time a
// "fill MIDI stream" event occured, the MIDI
@@ -1826,48 +1826,70 @@
// as a means of stopping what music is currently
// playing.
if (_vc72_var1 != track) {
+ midi.setLoop (loop != 0);
midi_play (track);
- if (paused)
- midi.pause (true);
_vc72_var1 = track;
- _vc72_var2 = -1; // (a & 0xFF) << 8 | (a >> 8);
+ _vc72_var2 = -1;
_vc72_var3 = -1;
+ _vc70_var1 = -1;
+ _vc70_var2 = loop;
}
/*
// ORIGINAL TRANSLATION FROM DISASSEMBLY
if (_vc72_var1 == 999 || _vc72_var1 == -1) {
- _vc70_var2 = paused;
+ _vc70_var2 = loop;
midi_play (track);
_vc72_var1 = track;
} else if (_vc72_var1 != track) {
_vc72_var3 = track;
- _vc72_var2 = paused; // (a & 0xFF) << 8 | (a >> 8);
+ _vc72_var2 = loop; // (a & 0xFF) << 8 | (a >> 8);
}
*/
}
void SimonState::vc_70() {
// Simon2
- uint16 a = vc_read_next_word();
- uint16 b = vc_read_next_word();
+ uint16 track = vc_read_next_word();
+ uint16 loop = vc_read_next_word();
- _vc70_var1 = a;
- _vc70_var2 = b;
+ // Jamieson630:
+ // This sets the "on end of track" action.
+ // It specifies whether to loop the current
+ // track and, if not, whether to switch to
+ // a different track upon completion.
+ _vc70_var1 = track;
+ _vc70_var2 = loop;
+
+ midi.setLoop (loop != 0);
+ if (_vc70_var1 != -1 && _vc70_var1 != 999)
+ midi.queueTrack ((byte) track, 0);
if (_debugMode)
- warning("vc_70(%d,%d): music stuff?", a, b);
+ debug (0, "vc_70 (%d,%d): Set end of track conditions", track, loop);
}
void SimonState::vc_71() {
// Simon2
+ // Jamieson630:
+ // This command skips the next instruction
+ // unless (1) there is a track playing, AND
+ // (2) there is a track queued to play after it.
+ if (_debugMode)
+ debug (0, "vc_71(): Is music playing? %s", midi.isPlaying(true) ? "YES" : "NO");
+
+ if (!midi.isPlaying (true))
+ vc_skip_next_instruction();
+/*
+ // ORIGINAL TRANSLATION FROM DISASSEMBLY
if (_vc72_var3 == -1 && _vc70_var1 == -1)
vc_skip_next_instruction();
+*/
}
void SimonState::vc_72() {
// Simon2
// Jamieson630:
- // This is a "queue or stop track". The original
+ // This is a "play or stop track". The original
// design stored the track to play if one was
// already in progress, so that the next time a
// "fill MIDI stream" event occured, the MIDI
@@ -1876,26 +1898,33 @@
// allows for an immediate response here, but
// we'll simulate the variable changes so other
// scripts don't get thrown off.
+
// NOTE: This opcode looks very similar in function
// to vc_72(), except that this opcode may allow
// for specifying a track of 999 or -1 in order to
// stop the music. We'll code it that way for now.
+
+ // NOTE: It's possible that when "stopping" a track,
+ // we're supposed to just go on to the next queued
+ // track, if any. Must find out if there is ANY
+ // case where this is used to stop a track in the
+ // first place.
+
int16 track = vc_read_next_word();
- int16 paused = !vc_read_next_word();
+ int16 loop = vc_read_next_word();
if (_debugMode)
- warning ("vc_72 (%d, %d): music stuff?", track, paused);
+ debug (0, "vc_72 (%d, %d): Play or stop track", track, loop);
if (track != _vc72_var1) {
if (track == -1 || track == 999) {
midi.stop();
_vc72_var1 = -1;
} else {
+ midi.setLoop (loop != 0);
midi_play (track);
- if (paused)
- midi.pause (true);
_vc72_var1 = track;
- _vc72_var2 = paused;
+ _vc70_var2 = loop;
}
_vc72_var3 = -1;
}
More information about the Scummvm-git-logs
mailing list