[Scummvm-cvs-logs] CVS: scummvm/scumm midiparser_ro.cpp,NONE,1.1 module.mk,1.20,1.21

Jamieson Christian jamieson630 at users.sourceforge.net
Thu Aug 14 02:00:47 CEST 2003


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1:/tmp/cvs-serv16440/scummvm/scumm

Modified Files:
	module.mk 
Added Files:
	midiparser_ro.cpp 
Log Message:
Added music parser for special format of
old-style MT-32 'RO' resources.

--- NEW FILE: midiparser_ro.cpp ---
/* 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: /cvsroot/scummvm/scummvm/scumm/midiparser_ro.cpp,v 1.1 2003/08/14 08:24:13 jamieson630 Exp $
 *
 */

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

Index: module.mk
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/module.mk,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- module.mk	14 Aug 2003 02:28:19 -0000	1.20
+++ module.mk	14 Aug 2003 08:24:13 -0000	1.21
@@ -18,6 +18,7 @@
 	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\





More information about the Scummvm-git-logs mailing list