aboutsummaryrefslogtreecommitdiff
path: root/scumm/midiparser_ro.cpp
diff options
context:
space:
mode:
authorJamieson Christian2003-08-14 08:24:13 +0000
committerJamieson Christian2003-08-14 08:24:13 +0000
commita0c71ef5e9047dcb2d7b67dabc35b9fc9479b33b (patch)
tree2944c1a807d656b9dc81d8dd4d121072f268d461 /scumm/midiparser_ro.cpp
parent8781f5e6f6671fe07a6898dac34eb18370be2072 (diff)
downloadscummvm-rg350-a0c71ef5e9047dcb2d7b67dabc35b9fc9479b33b.tar.gz
scummvm-rg350-a0c71ef5e9047dcb2d7b67dabc35b9fc9479b33b.tar.bz2
scummvm-rg350-a0c71ef5e9047dcb2d7b67dabc35b9fc9479b33b.zip
Added music parser for special format of
old-style MT-32 'RO' resources. svn-id: r9683
Diffstat (limited to 'scumm/midiparser_ro.cpp')
-rw-r--r--scumm/midiparser_ro.cpp120
1 files changed, 120 insertions, 0 deletions
diff --git a/scumm/midiparser_ro.cpp b/scumm/midiparser_ro.cpp
new file mode 100644
index 0000000000..67d61a82f3
--- /dev/null
+++ b/scumm/midiparser_ro.cpp
@@ -0,0 +1,120 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2001-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$
+ *
+ */
+
+#include "stdafx.h"
+#include "sound/midiparser.h"
+#include "sound/mididrv.h"
+#include "common/util.h"
+
+
+//////////////////////////////////////////////////
+//
+// The Standard MIDI File version of MidiParser
+//
+//////////////////////////////////////////////////
+
+class MidiParser_RO : public MidiParser {
+protected:
+ void compressToType0();
+ void parseNextEvent (EventInfo &info);
+
+public:
+ bool loadMusic (byte *data, uint32 size);
+};
+
+
+
+//////////////////////////////////////////////////
+//
+// MidiParser_RO implementation
+//
+//////////////////////////////////////////////////
+
+void MidiParser_RO::parseNextEvent (EventInfo &info) {
+ info.delta = 0;
+ do {
+ info.start = _position._play_pos;
+ info.event = *(_position._play_pos++);
+ if (info.command() == 0xA) continue;
+
+ if (info.event == 0xF0) {
+ byte delay = *(_position._play_pos++);
+ info.delta += delay;
+ continue;
+ }
+ break;
+ } while (true);
+
+ // Seems to indicate EOT
+ if (info.event == 0)
+ info.event = 0xF0;
+ else if (info.event < 0x80)
+ return;
+
+ _position._running_status = info.event;
+ switch (info.command()) {
+ case 0xC:
+ info.basic.param1 = *(_position._play_pos++);
+ info.basic.param2 = 0;
+ break;
+
+ case 0x8: case 0x9: case 0xB:
+ info.basic.param1 = *(_position._play_pos++);
+ info.basic.param2 = *(_position._play_pos++);
+ if (info.command() == 0x9 && info.basic.param2 == 0)
+ info.event = info.channel() | 0x80;
+ info.length = 0;
+ break;
+
+ case 0xF: // End of Track messages
+ if (info.event == 0xFF)
+ _autoLoop = true;
+ info.event = 0xFF;
+ info.ext.type = 0x2F;
+ info.length = 0;
+ info.ext.data = 0;
+ break;
+ }
+}
+
+bool MidiParser_RO::loadMusic (byte *data, uint32 size) {
+ unloadMusic();
+ byte *pos = data;
+
+ if (memcmp (pos, "RO", 2)) {
+ printf ("Warning: 'RO' header expected but found '%c%c' instead.\n", pos[0], pos[1]);
+ return false;
+ }
+
+ _num_tracks = 1;
+ _ppqn = 120;
+ _tracks[0] = pos + 2;
+
+ // Note that we assume the original data passed in
+ // will persist beyond this call, i.e. we do NOT
+ // copy the data to our own buffer. Take warning....
+ resetTracking();
+ setTempo (500000);
+ setTrack (0);
+ return true;
+}
+
+MidiParser *MidiParser_createRO() { return new MidiParser_RO; }