Skip to content

Commit

Permalink
SHERLOCK: debug levels for AdLib & Music
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Kiewitz committed May 31, 2015
1 parent f2bced6 commit 90be81b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 19 deletions.
18 changes: 9 additions & 9 deletions engines/sherlock/music.cpp
Expand Up @@ -151,16 +151,16 @@ void MidiParser_SH::parseNextEvent(EventInfo &info) {
}
} else if (info.event == 0xFC) {
// Official End-Of-Track signal
warning("System META event 0xFC");
debugC(kDebugLevelMusic, "Music: System META event 0xFC");

byte type = *(_position._playPos++);
switch (type) {
case 0x80: // end of track, triggers looping
warning("META event triggered looping");
debugC(kDebugLevelMusic, "Music: META event triggered looping");
jumpToTick(0, true, true, false);
break;
case 0x81: // end of track, stop playing
warning("META event triggered music stop");
debugC(kDebugLevelMusic, "Music: META event triggered music stop");
stopPlaying();
unloadMusic();
break;
Expand All @@ -180,7 +180,7 @@ void MidiParser_SH::parseNextEvent(EventInfo &info) {
}

bool MidiParser_SH::loadMusic(byte *data, uint32 size) {
warning("loadMusic");
debugC(kDebugLevelMusic, "Music: loadMusic()");
unloadMusic();

byte *headerPtr = data;
Expand Down Expand Up @@ -242,7 +242,7 @@ Music::Music(SherlockEngine *vm, Audio::Mixer *mixer) : _vm(vm), _mixer(mixer) {
}

bool Music::loadSong(int songNumber) {
warning("loadSong");
debugC(kDebugLevelMusic, "Music: loadSong()");

if(songNumber == 100)
songNumber = 55;
Expand Down Expand Up @@ -285,7 +285,7 @@ bool Music::playMusic(const Common::String &name) {
if (!_musicOn)
return false;

warning("Sound::playMusic %s", name.c_str());
debugC(kDebugLevelMusic, "Music: playMusic('%s')", name.c_str());
Common::SeekableReadStream *stream = _vm->_res->load(name, "MUSIC.LIB");

byte *data = new byte[stream->size()];
Expand All @@ -305,21 +305,21 @@ bool Music::playMusic(const Common::String &name) {
#endif

if (dataSize < 14) {
warning("not enough data in music file");
warning("Music: not enough data in music file");
return false;
}

byte *dataPos = data;
if (memcmp(" ", dataPos, 12)) {
warning("Expected header not found in music file");
warning("Music: expected header not found in music file");
return false;
}
dataPos += 12;
dataSize -= 12;

uint16 headerSize = READ_LE_UINT16(dataPos);
if (headerSize != 0x7F) {
warning("music header is not as expected");
warning("Music: header is not as expected");
return false;
}

Expand Down
15 changes: 7 additions & 8 deletions engines/sherlock/scalpel/drivers/adlib.cpp
Expand Up @@ -287,7 +287,7 @@ class MidiDriver_AdLib : public MidiDriver_Emulated {
int MidiDriver_AdLib::open() {
int rate = _mixer->getOutputRate();

debug(3, "ADLIB: Starting driver");
debugC(kDebugLevelAdLibDriver, "AdLib: starting driver");

_opl = OPL::Config::create(OPL::Config::kOpl2);

Expand Down Expand Up @@ -406,11 +406,11 @@ void MidiDriver_AdLib::send(uint32 b) {
// Aftertouch doesn't seem to be implemented in the Sherlock Holmes adlib driver
break;
case 0xe0:
warning("pitch bend change");
debugC(kDebugLevelAdLibDriver, "AdLib: pitch bend change");
pitchBendChange(channel, op1, op2);
break;
case 0xf0: // SysEx
warning("SysEx: %x", b);
warning("ADLIB: SysEx: %x", b);
break;
default:
warning("ADLIB: Unknown event %02x", command);
Expand Down Expand Up @@ -453,7 +453,7 @@ void MidiDriver_AdLib::noteOn(byte MIDIchannel, byte note, byte velocity) {
}
if (oldestInUseChannel >= 0) {
// channel found
warning("used In-Use channel");
debugC(kDebugLevelAdLibDriver, "AdLib: used In-Use channel");
// original driver used note 0, we use the current note
// because using note 0 could create a bad note (out of index) and we check that. Original driver didn't.
voiceOnOff(oldestInUseChannel, false, _channels[oldestInUseChannel].currentNote, 0);
Expand All @@ -464,11 +464,10 @@ void MidiDriver_AdLib::noteOn(byte MIDIchannel, byte note, byte velocity) {
voiceOnOff(oldestInUseChannel, true, note, velocity);
return;
}
warning("MIDI channel not mapped/all FM voice channels busy %d", MIDIchannel);
debugC(kDebugLevelAdLibDriver, "AdLib: MIDI channel not mapped/all FM voice channels busy %d", MIDIchannel);

} else {
// Percussion channel
warning("percussion!");
for (byte FMvoiceChannel = 0; FMvoiceChannel < SHERLOCK_ADLIB_VOICES_COUNT; FMvoiceChannel++) {
if (_voiceChannelMapping[FMvoiceChannel] == MIDIchannel) {
if (note == adlib_percussionChannelTable[FMvoiceChannel].requiredNote) {
Expand All @@ -480,7 +479,7 @@ void MidiDriver_AdLib::noteOn(byte MIDIchannel, byte note, byte velocity) {
}
}
}
warning("percussion MIDI channel not mapped/all FM voice channels busy");
debugC(kDebugLevelAdLibDriver, "AdLib: percussion MIDI channel not mapped/all FM voice channels busy");
}
}

Expand Down Expand Up @@ -519,7 +518,7 @@ void MidiDriver_AdLib::voiceOnOff(byte FMvoiceChannel, bool keyOn, byte note, by
frequencyOffset = note;
}
if (frequencyOffset >= SHERLOCK_ADLIB_NOTES_COUNT) {
warning("CRITICAL - bad note!!!");
warning("CRITICAL - AdLib driver: bad note!!!");
return;
}
frequency = adlib_FrequencyLookUpTable[frequencyOffset];
Expand Down
4 changes: 3 additions & 1 deletion engines/sherlock/sherlock.cpp
Expand Up @@ -71,7 +71,9 @@ SherlockEngine::~SherlockEngine() {
}

void SherlockEngine::initialize() {
DebugMan.addDebugChannel(kDebugScript, "scripts", "Script debug level");
DebugMan.addDebugChannel(kDebugLevelScript, "scripts", "Script debug level");
DebugMan.addDebugChannel(kDebugLevelAdLibDriver, "AdLib", "AdLib driver debugging");
DebugMan.addDebugChannel(kDebugLevelMusic, "Music", "Music debugging");

ImageFile::setVm(this);
Object::setVm(this);
Expand Down
4 changes: 3 additions & 1 deletion engines/sherlock/sherlock.h
Expand Up @@ -51,7 +51,9 @@
namespace Sherlock {

enum {
kDebugScript = 1 << 0
kDebugLevelScript = 1 << 0,
kDebugLevelAdLibDriver = 2 << 0,
kDebugLevelMusic = 3 << 0,
};

enum GameType {
Expand Down

0 comments on commit 90be81b

Please sign in to comment.