Added music parser for special format of

old-style MT-32 'RO' resources.

svn-id: r9683
This commit is contained in:
Jamieson Christian 2003-08-14 08:24:13 +00:00
parent 8781f5e6f6
commit a0c71ef5e9
3 changed files with 125 additions and 0 deletions

View File

@ -343,6 +343,10 @@ SOURCE=.\scumm\intern.h
# End Source File
# Begin Source File
SOURCE=.\scumm\midiparser_ro.cpp
# End Source File
# Begin Source File
SOURCE=.\scumm\nut_renderer.cpp
# End Source File
# Begin Source File

120
scumm/midiparser_ro.cpp Normal file
View File

@ -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; }

View File

@ -18,6 +18,7 @@ SCUMM_OBJS = \
scumm/imuse_player.o \
scumm/instrument.o \
scumm/help.o \
scumm/midiparser_ro.o \
scumm/nut_renderer.o \
scumm/object.o \
scumm/player_v1.o\