diff options
author | Willem Jan Palenstijn | 2015-07-22 22:37:40 +0200 |
---|---|---|
committer | Willem Jan Palenstijn | 2015-07-22 22:43:42 +0200 |
commit | 6ec9c81b575f13b2c4b30aeac592ebf2557b5890 (patch) | |
tree | 503d50902bad2d800165593039d08d5ccf0c98ab /engines/agos/midiparser_s1d.cpp | |
parent | 5ec05f6b647c5ea41418be7ed19ad381f97cabd8 (diff) | |
parent | 4e5c8d35f7e133e2e72a846fdbd54900c91eeb73 (diff) | |
download | scummvm-rg350-6ec9c81b575f13b2c4b30aeac592ebf2557b5890.tar.gz scummvm-rg350-6ec9c81b575f13b2c4b30aeac592ebf2557b5890.tar.bz2 scummvm-rg350-6ec9c81b575f13b2c4b30aeac592ebf2557b5890.zip |
Merge branch 'master' into mm
Conflicts:
engines/access/access.cpp
engines/access/asurface.h
engines/access/bubble_box.cpp
engines/access/bubble_box.h
engines/access/martian/martian_game.cpp
engines/access/player.cpp
engines/access/player.h
engines/access/resources.cpp
engines/access/screen.cpp
engines/access/screen.h
engines/access/sound.cpp
engines/access/sound.h
Diffstat (limited to 'engines/agos/midiparser_s1d.cpp')
-rw-r--r-- | engines/agos/midiparser_s1d.cpp | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/engines/agos/midiparser_s1d.cpp b/engines/agos/midiparser_s1d.cpp index c2c08bf451..7b9a058efc 100644 --- a/engines/agos/midiparser_s1d.cpp +++ b/engines/agos/midiparser_s1d.cpp @@ -179,12 +179,43 @@ void MidiParser_S1D::parseNextEvent(EventInfo &info) { bool MidiParser_S1D::loadMusic(byte *data, uint32 size) { unloadMusic(); + if (!size) + return false; + // The original actually just ignores the first two bytes. byte *pos = data; - if (*(pos++) != 0xFC) - debug(1, "Expected 0xFC header but found 0x%02X instead", (int) *pos); - - pos += 1; + if (*pos == 0xFC) { + // SysEx found right at the start + // this seems to happen since Elvira 2, we ignore it + // 3rd byte after the SysEx seems to be saved into a global + + // We expect at least 4 bytes in total + if (size < 4) + return false; + + byte skipOffset = pos[2]; // get second byte after the SysEx + // pos[1] seems to have been ignored + // pos[3] is saved into a global inside the original interpreters + + // Waxworks + Simon 1 demo typical header is: + // 0xFC 0x29 0x07 0x01 [0x00/0x01] + // Elvira 2 typical header is: + // 0xFC 0x04 0x06 0x06 + + if (skipOffset >= 6) { + // should be at least 6, so that we skip over the 2 size bytes and the + // smallest SysEx possible + skipOffset -= 2; // 2 size bytes were already read by previous code outside of this method + + if (size <= skipOffset) // Skip to the end of file? -> something is not correct + return false; + + // Do skip over the bytes + pos += skipOffset; + } else { + warning("MidiParser_S1D: unexpected skip offset in music file"); + } + } // And now we're at the actual data. Only one track. _numTracks = 1; |