aboutsummaryrefslogtreecommitdiff
path: root/simon
diff options
context:
space:
mode:
authorJamieson Christian2003-05-21 00:44:37 +0000
committerJamieson Christian2003-05-21 00:44:37 +0000
commit8860625e4661f9ff5fce469f80144c61a1a26427 (patch)
tree90219673d8054a7296ac971728a0494e2d6f4e70 /simon
parent9780fc9c3e5b5866ed131f70ce4146207e910433 (diff)
downloadscummvm-rg350-8860625e4661f9ff5fce469f80144c61a1a26427.tar.gz
scummvm-rg350-8860625e4661f9ff5fce469f80144c61a1a26427.tar.bz2
scummvm-rg350-8860625e4661f9ff5fce469f80144c61a1a26427.zip
Various cleanup of Simon music code
svn-id: r7758
Diffstat (limited to 'simon')
-rw-r--r--simon/items.cpp92
-rw-r--r--simon/simon.cpp7
-rw-r--r--simon/vga.cpp85
3 files changed, 111 insertions, 73 deletions
diff --git a/simon/items.cpp b/simon/items.cpp
index f9ae8f5a82..8bf557a277 100644
--- a/simon/items.cpp
+++ b/simon/items.cpp
@@ -1432,68 +1432,52 @@ void SimonState::o_unk_132_helper_2(FillOrCopyStruct *fcs, int x) {
}
void SimonState::o_unk_127() {
- int a = getVarOrWord();
- int b = getVarOrWord();
-
+ int music = getVarOrWord();
+ int track = getVarOrWord();
+
+ // Jamieson630:
+ // This appears to be a "load or play music" command.
+ // The music resource is specified, and optionally
+ // a track as well. Normally we see two calls being
+ // made, one to load the resource and another to
+ // actually start a track (so the resource is
+ // effectively preloaded so there's no latency when
+ // starting playback).
if (_game & GF_SIMON2) {
- uint c = getVarOrByte();
+ int play = getVarOrByte();
- if (_debugMode)
- warning("o_unk_127(%d,%d,%d) not implemented properly", a, b, c);
+ if (_debugMod)
+ debug (0, "o_unk_127 (%d, %d, %d);", music, track, play);
- if (_last_music_played != a) {
- if (b == 999) {
-// _next_music_to_play = a;
- playMusic (a);
- _last_music_played = a;
- // midi_play (0);
- }
+ if (_last_music_played != music) {
+ playMusic (music);
+ _last_music_played = music;
+ _next_music_to_play = -1;
+ _vc72_var1 = _vc72_var2 = _vc72_var3 = -1;
}
- if (b == _vc72_var1 || b == 999)
+ if (track == _vc72_var1 || track == 999)
return;
- if (_vc72_var1 == -1 || _vc72_var1 == 999) {
- _vc70_var2 = c;
- _vc70_var1 = -1;
- _vc72_var3 = -1;
- midi_play (b);
- _vc72_var1 = b;
- } else {
- midi_play (b);
-// _vc72_var3 = b;
-// _vc72_var2 = c;
- }
-/*
- if (_last_music_played == a) {
- if (b == _vc72_var1 || b == 999)
- return;
-
- //FIXME Changed if to allow midi jumping to work for now.
- if (b != 1) {
- _vc70_var2 = c;
- _vc70_var1 = -1;
- _vc72_var3 = -1;
- _next_music_to_play = -1;
- midi_play(b);
- _vc72_var1 = b;
- } else {
- //FIXME This is another midi jump, not sure if variable order is correct.
- _vc72_var3 = b;
- _vc72_var2 = c;
- midi.jump (b, c);
- }
- } else if (b == 999) {
- // _next_music_to_play = a;
- playMusic (a);
- midi_play (b);
- }
-*/
+ _vc72_var1 = track;
+ _vc70_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 (a != _last_music_played) {
- _last_music_played = a;
- playMusic(a);
- midi_play (b);
+ if (music != _last_music_played) {
+ _last_music_played = music;
+ playMusic (music);
+ midi_play (track);
}
}
}
diff --git a/simon/simon.cpp b/simon/simon.cpp
index a8d5b95422..77dfe7cc84 100644
--- a/simon/simon.cpp
+++ b/simon/simon.cpp
@@ -5280,12 +5280,7 @@ bool SimonState::load_game(uint slot) {
void SimonState::midi_play (uint track) {
if (track == 999)
return;
-
- if (_vc72_var1 == 999) {
-// _midi_var11 = 0;
- midi.jump (track, 0);
-// _midi_var12 = 1;
- }
+ midi.jump (track, 0);
}
diff --git a/simon/vga.cpp b/simon/vga.cpp
index 4f95dae157..8b1b40f326 100644
--- a/simon/vga.cpp
+++ b/simon/vga.cpp
@@ -1804,21 +1804,46 @@ void SimonState::vc_68_skip_if_le() {
void SimonState::vc_69() {
// Simon2
- uint16 a = vc_read_next_word();
- uint16 b = vc_read_next_word();
+ int16 track = vc_read_next_word();
+ int16 paused = vc_read_next_word();
if (_debugMode)
- warning("vc_69(%d,%d): music stuff?", a, b);
-
+ warning("vc_69(%d,%d): music stuff", track, paused);
+
+ // Jamieson630:
+ // This is a "play or queue 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
+ // player would find the change and switch
+ // tracks. We use a different architecture that
+ // 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 vc_72() may allow for
+ // specifying a non-valid track number (999 or -1)
+ // as a means of stopping what music is currently
+ // playing.
+ if (_vc72_var1 != track) {
+ midi_play (track);
+ if (paused)
+ midi.pause (true);
+ _vc72_var1 = track;
+ _vc72_var2 = -1; // (a & 0xFF) << 8 | (a >> 8);
+ _vc72_var3 = -1;
+ }
+/*
+ // ORIGINAL TRANSLATION FROM DISASSEMBLY
if (_vc72_var1 == 999 || _vc72_var1 == -1) {
- _vc70_var2 = b;
- midi_play (a);
- _vc72_var1 = a;
- } else if (_vc72_var1 != a) {
- _vc72_var3 = a;
- _vc72_var2 = (a & 0xFF) << 8 | (a >> 8);
+ _vc70_var2 = paused;
+ midi_play (track);
+ _vc72_var1 = track;
+ } else if (_vc72_var1 != track) {
+ _vc72_var3 = track;
+ _vc72_var2 = paused; // (a & 0xFF) << 8 | (a >> 8);
}
-
+*/
}
void SimonState::vc_70() {
@@ -1841,14 +1866,48 @@ void SimonState::vc_71() {
void SimonState::vc_72() {
// Simon2
+ // Jamieson630:
+ // This is a "queue 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
+ // player would find the change and switch
+ // tracks. We use a different architecture that
+ // 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.
+ int16 track = vc_read_next_word();
+ int16 paused = !vc_read_next_word();
+
+ if (_debugMode)
+ warning ("vc_72 (%d, %d): music stuff?", track, paused);
+
+ if (track != _vc72_var1) {
+ if (track == -1 || track == 999) {
+ midi.stop();
+ _vc72_var1 = -1;
+ } else {
+ midi_play (track);
+ if (paused)
+ midi.pause (true);
+ _vc72_var1 = track;
+ _vc72_var2 = paused;
+ }
+ _vc72_var3 = -1;
+ }
+/*
+ // ORIGINAL TRANSLATION FROM DISASSEMBLY
uint16 a = vc_read_next_word();
uint16 b = vc_read_next_word();
if (a != _vc72_var1) {
_vc72_var2 = b;
_vc72_var3 = a;
}
-
- midi.jump (a, b);
+*/
}
void SimonState::vc_73_set_op189_flag() {