Skip to content

Commit

Permalink
GROOVIE: Remove engine-specific "all" debugflag. Minor naming cleanup.
Browse files Browse the repository at this point in the history
This is now uneeded as the GUI debugger superclass implements the same
functionality and this removes a bunch of complexity from the Groovie
engine debug calls. Also, removed groovie prefix from the debug flag
naming as unecessary as these are within the Groovie namespace.
  • Loading branch information
digitall committed Jun 5, 2014
1 parent 1e6fe10 commit d875151
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 101 deletions.
18 changes: 9 additions & 9 deletions engines/groovie/cursor.cpp
Expand Up @@ -107,8 +107,8 @@ Cursor_t7g::Cursor_t7g(uint8 *img, uint8 *pal) :

_img = img + 5;

debugC(1, kGroovieDebugCursor | kGroovieDebugAll, "Groovie::Cursor: width: %d, height: %d, frames:%d", _width, _height, _numFrames);
debugC(1, kGroovieDebugCursor | kGroovieDebugUnknown | kGroovieDebugAll, "Groovie::Cursor: elinor: 0x%02X (%d), 0x%02X (%d)", elinor1, elinor1, elinor2, elinor2);
debugC(1, kDebugCursor, "Groovie::Cursor: width: %d, height: %d, frames:%d", _width, _height, _numFrames);
debugC(1, kDebugCursor | kDebugUnknown, "Groovie::Cursor: elinor: 0x%02X (%d), 0x%02X (%d)", elinor1, elinor1, elinor2, elinor2);
}

void Cursor_t7g::enable() {
Expand Down Expand Up @@ -262,26 +262,26 @@ Cursor_v2::Cursor_v2(Common::File &file) {

_img = new byte[_width * _height * _numFrames * 4];

debugC(1, kGroovieDebugCursor | kGroovieDebugAll, "Groovie::Cursor: width: %d, height: %d, frames:%d", _width, _height, _numFrames);
debugC(1, kDebugCursor, "Groovie::Cursor: width: %d, height: %d, frames:%d", _width, _height, _numFrames);

uint16 tmp16 = file.readUint16LE();
debugC(5, kGroovieDebugCursor | kGroovieDebugAll, "hotspot x?: %d\n", tmp16);
debugC(5, kDebugCursor, "hotspot x?: %d\n", tmp16);
tmp16 = file.readUint16LE();
debugC(5, kGroovieDebugCursor | kGroovieDebugAll, "hotspot y?: %d\n", tmp16);
debugC(5, kDebugCursor, "hotspot y?: %d\n", tmp16);
int loop2count = file.readUint16LE();
debugC(5, kGroovieDebugCursor | kGroovieDebugAll, "loop2count?: %d\n", loop2count);
debugC(5, kDebugCursor, "loop2count?: %d\n", loop2count);
for (int l = 0; l < loop2count; l++) {
tmp16 = file.readUint16LE();
debugC(5, kGroovieDebugCursor | kGroovieDebugAll, "loop2a: %d\n", tmp16); // Index frame can merge to/from?
debugC(5, kDebugCursor, "loop2a: %d\n", tmp16); // Index frame can merge to/from?
tmp16 = file.readUint16LE();
debugC(5, kGroovieDebugCursor | kGroovieDebugAll, "loop2b: %d\n", tmp16); // Number of frames?
debugC(5, kDebugCursor, "loop2b: %d\n", tmp16); // Number of frames?
}

file.read(pal, 0x20 * 3);

for (int f = 0; f < _numFrames; f++) {
uint32 tmp32 = file.readUint32LE();
debugC(5, kGroovieDebugCursor | kGroovieDebugAll, "loop3: %d\n", tmp32);
debugC(5, kDebugCursor, "loop3: %d\n", tmp32);

byte *data = new byte[tmp32];
file.read(data, tmp32);
Expand Down
21 changes: 10 additions & 11 deletions engines/groovie/groovie.cpp
Expand Up @@ -68,17 +68,16 @@ GroovieEngine::GroovieEngine(OSystem *syst, const GroovieGameDescription *gd) :
_modeSpeed = kGroovieSpeedFast;

// Initialize the custom debug levels
DebugMan.addDebugChannel(kGroovieDebugAll, "All", "Debug everything");
DebugMan.addDebugChannel(kGroovieDebugVideo, "Video", "Debug video and audio playback");
DebugMan.addDebugChannel(kGroovieDebugResource, "Resource", "Debug resouce management");
DebugMan.addDebugChannel(kGroovieDebugScript, "Script", "Debug the scripts");
DebugMan.addDebugChannel(kGroovieDebugUnknown, "Unknown", "Report values of unknown data in files");
DebugMan.addDebugChannel(kGroovieDebugHotspots, "Hotspots", "Show the hotspots");
DebugMan.addDebugChannel(kGroovieDebugCursor, "Cursor", "Debug cursor decompression / switching");
DebugMan.addDebugChannel(kGroovieDebugMIDI, "MIDI", "Debug MIDI / XMIDI files");
DebugMan.addDebugChannel(kGroovieDebugScriptvars, "Scriptvars", "Print out any change to script variables");
DebugMan.addDebugChannel(kGroovieDebugCell, "Cell", "Debug the cell game (in the microscope)");
DebugMan.addDebugChannel(kGroovieDebugFast, "Fast", "Play videos quickly, with no sound (unstable)");
DebugMan.addDebugChannel(kDebugVideo, "Video", "Debug video and audio playback");
DebugMan.addDebugChannel(kDebugResource, "Resource", "Debug resouce management");
DebugMan.addDebugChannel(kDebugScript, "Script", "Debug the scripts");
DebugMan.addDebugChannel(kDebugUnknown, "Unknown", "Report values of unknown data in files");
DebugMan.addDebugChannel(kDebugHotspots, "Hotspots", "Show the hotspots");
DebugMan.addDebugChannel(kDebugCursor, "Cursor", "Debug cursor decompression / switching");
DebugMan.addDebugChannel(kDebugMIDI, "MIDI", "Debug MIDI / XMIDI files");
DebugMan.addDebugChannel(kDebugScriptvars, "Scriptvars", "Print out any change to script variables");
DebugMan.addDebugChannel(kDebugCell, "Cell", "Debug the cell game (in the microscope)");
DebugMan.addDebugChannel(kDebugFast, "Fast", "Play videos quickly, with no sound (unstable)");
}

GroovieEngine::~GroovieEngine() {
Expand Down
24 changes: 12 additions & 12 deletions engines/groovie/groovie.h
Expand Up @@ -58,18 +58,18 @@ class Script;
class VideoPlayer;

enum DebugLevels {
kGroovieDebugAll = 1 << 0,
kGroovieDebugVideo = 1 << 1,
kGroovieDebugResource = 1 << 2,
kGroovieDebugScript = 1 << 3,
kGroovieDebugUnknown = 1 << 4,
kGroovieDebugHotspots = 1 << 5,
kGroovieDebugCursor = 1 << 6,
kGroovieDebugMIDI = 1 << 7,
kGroovieDebugScriptvars = 1 << 8,
kGroovieDebugCell = 1 << 9,
kGroovieDebugFast = 1 << 10
// the current limitation is 32 debug levels (1 << 31 is the last one)
kDebugVideo = 1 << 0,
kDebugResource = 1 << 1,
kDebugScript = 1 << 2,
kDebugUnknown = 1 << 3,
kDebugHotspots = 1 << 4,
kDebugCursor = 1 << 5,
kDebugMIDI = 1 << 6,
kDebugScriptvars = 1 << 7,
kDebugCell = 1 << 8,
kDebugFast = 1 << 9
// the current limitation is 32 debug levels (1 << 31 is the last one)
// but some are used by system, so avoid high values.
};

/**
Expand Down
38 changes: 19 additions & 19 deletions engines/groovie/music.cpp
Expand Up @@ -64,7 +64,7 @@ void MusicPlayer::playSong(uint32 fileref) {
void MusicPlayer::setBackgroundSong(uint32 fileref) {
Common::StackLock lock(_mutex);

debugC(1, kGroovieDebugMIDI | kGroovieDebugAll, "Groovie::Music: Changing the background song: %04X", fileref);
debugC(1, kDebugMIDI, "Groovie::Music: Changing the background song: %04X", fileref);
_backgroundFileRef = fileref;
}

Expand All @@ -86,7 +86,7 @@ void MusicPlayer::playCD(uint8 track) {
// Stop the MIDI playback
unload();

debugC(1, kGroovieDebugMIDI | kGroovieDebugAll, "Groovie::Music: Playing CD track %d", track);
debugC(1, kDebugMIDI, "Groovie::Music: Playing CD track %d", track);

if (track == 3) {
// This is the credits song, start at 23:20
Expand Down Expand Up @@ -136,9 +136,9 @@ void MusicPlayer::playCD(uint8 track) {
}

void MusicPlayer::startBackground() {
debugC(3, kGroovieDebugMIDI | kGroovieDebugAll, "Groovie::Music: startBackground()");
debugC(3, kDebugMIDI, "Groovie::Music: startBackground()");
if (!_isPlaying && _backgroundFileRef) {
debugC(3, kGroovieDebugMIDI | kGroovieDebugAll, "Groovie::Music: Starting the background song (0x%4X)", _backgroundFileRef);
debugC(3, kDebugMIDI, "Groovie::Music: Starting the background song (0x%4X)", _backgroundFileRef);
play(_backgroundFileRef, true);
}
}
Expand All @@ -158,7 +158,7 @@ void MusicPlayer::setUserVolume(uint16 volume) {
void MusicPlayer::setGameVolume(uint16 volume, uint16 time) {
Common::StackLock lock(_mutex);

debugC(1, kGroovieDebugMIDI | kGroovieDebugAll, "Groovie::Music: Setting game volume from %d to %d in %dms", _gameVolume, volume, time);
debugC(1, kDebugMIDI, "Groovie::Music: Setting game volume from %d to %d in %dms", _gameVolume, volume, time);

// Save the start parameters of the fade
_fadingStartTime = _vm->_system->getMillis();
Expand All @@ -183,12 +183,12 @@ bool MusicPlayer::play(uint32 fileref, bool loop) {
}

void MusicPlayer::applyFading() {
debugC(6, kGroovieDebugMIDI | kGroovieDebugAll, "Groovie::Music: applyFading() _fadingStartTime = %d, _fadingDuration = %d, _fadingStartVolume = %d, _fadingEndVolume = %d", _fadingStartTime, _fadingDuration, _fadingStartVolume, _fadingEndVolume);
debugC(6, kDebugMIDI, "Groovie::Music: applyFading() _fadingStartTime = %d, _fadingDuration = %d, _fadingStartVolume = %d, _fadingEndVolume = %d", _fadingStartTime, _fadingDuration, _fadingStartVolume, _fadingEndVolume);
Common::StackLock lock(_mutex);

// Calculate the passed time
uint32 time = _vm->_system->getMillis() - _fadingStartTime;
debugC(6, kGroovieDebugMIDI | kGroovieDebugAll, "Groovie::Music: time = %d, _gameVolume = %d", time, _gameVolume);
debugC(6, kDebugMIDI, "Groovie::Music: time = %d, _gameVolume = %d", time, _gameVolume);
if (time >= _fadingDuration) {
// Set the end volume
_gameVolume = _fadingEndVolume;
Expand All @@ -200,7 +200,7 @@ void MusicPlayer::applyFading() {
if (_gameVolume == _fadingEndVolume) {
// If we were fading to 0, stop the playback and restore the volume
if (_fadingEndVolume == 0) {
debugC(1, kGroovieDebugMIDI | kGroovieDebugAll, "Groovie::Music: Faded to zero: end of song. _fadingEndVolume set to 100");
debugC(1, kDebugMIDI, "Groovie::Music: Faded to zero: end of song. _fadingEndVolume set to 100");
unload();
}
}
Expand All @@ -210,7 +210,7 @@ void MusicPlayer::applyFading() {
}

void MusicPlayer::onTimer(void *refCon) {
debugC(9, kGroovieDebugMIDI | kGroovieDebugAll, "Groovie::Music: onTimer()");
debugC(9, kDebugMIDI, "Groovie::Music: onTimer()");
MusicPlayer *music = (MusicPlayer *)refCon;
Common::StackLock lock(music->_mutex);

Expand All @@ -225,7 +225,7 @@ void MusicPlayer::onTimer(void *refCon) {
}

void MusicPlayer::unload() {
debugC(1, kGroovieDebugMIDI | kGroovieDebugAll, "Groovie::Music: Stopping the playback");
debugC(1, kDebugMIDI, "Groovie::Music: Stopping the playback");

// Set the new state
_isPlaying = false;
Expand Down Expand Up @@ -319,7 +319,7 @@ void MusicPlayerMidi::updateChanVolume(byte channel) {
}

void MusicPlayerMidi::endTrack() {
debugC(3, kGroovieDebugMIDI | kGroovieDebugAll, "Groovie::Music: endTrack()");
debugC(3, kDebugMIDI, "Groovie::Music: endTrack()");
unload();
}

Expand Down Expand Up @@ -439,7 +439,7 @@ void MusicPlayerXMI::send(uint32 b) {
byte chan = b & 0xF;
byte bank = (b >> 16) & 0xFF;

debugC(5, kGroovieDebugMIDI | kGroovieDebugAll, "Groovie::Music: Selecting bank %X for channel %X", bank, chan);
debugC(5, kDebugMIDI, "Groovie::Music: Selecting bank %X for channel %X", bank, chan);
_chanBanks[chan] = bank;
return;
} else if ((b & 0xF0) == 0xC0) { // Program change
Expand All @@ -450,7 +450,7 @@ void MusicPlayerXMI::send(uint32 b) {
byte chan = b & 0xF;
byte patch = (b >> 8) & 0xFF;

debugC(5, kGroovieDebugMIDI | kGroovieDebugAll, "Groovie::Music: Setting custom patch %X from bank %X to channel %X", patch, _chanBanks[chan], chan);
debugC(5, kDebugMIDI, "Groovie::Music: Setting custom patch %X from bank %X to channel %X", patch, _chanBanks[chan], chan);

// Try to find the requested patch from the previously
// specified bank
Expand All @@ -475,7 +475,7 @@ void MusicPlayerXMI::send(uint32 b) {
}

bool MusicPlayerXMI::load(uint32 fileref, bool loop) {
debugC(1, kGroovieDebugMIDI | kGroovieDebugAll, "Groovie::Music: Starting the playback of song: %04X", fileref);
debugC(1, kDebugMIDI, "Groovie::Music: Starting the playback of song: %04X", fileref);

// Open the song resource
Common::SeekableReadStream *file = _vm->_resMan->open(fileref);
Expand All @@ -489,7 +489,7 @@ bool MusicPlayerXMI::load(uint32 fileref, bool loop) {

void MusicPlayerXMI::loadTimbres(const Common::String &filename) {
// Load the Global Timbre Library format as documented in AIL2
debugC(1, kGroovieDebugMIDI | kGroovieDebugAll, "Groovie::Music: Loading the GTL file %s", filename.c_str());
debugC(1, kDebugMIDI, "Groovie::Music: Loading the GTL file %s", filename.c_str());

// Does it exist?
if (!Common::File::exists(filename)) {
Expand Down Expand Up @@ -537,7 +537,7 @@ void MusicPlayerXMI::loadTimbres(const Common::String &filename) {

// Read the timbre data
gtl->read(_timbres[i].data, _timbres[i].size);
debugC(5, kGroovieDebugMIDI | kGroovieDebugAll, "Groovie::Music: Loaded patch %x in bank %x with size %d",
debugC(5, kDebugMIDI, "Groovie::Music: Loaded patch %x in bank %x with size %d",
_timbres[i].patch, _timbres[i].bank, _timbres[i].size);
}

Expand Down Expand Up @@ -636,7 +636,7 @@ void setRolandInstrument(MidiDriver *drv, byte channel, byte *instrument) {

// Show the timbre name as extra debug information
Common::String name((char *)instrument, 10);
debugC(5, kGroovieDebugMIDI | kGroovieDebugAll, "Groovie::Music: Setting MT32 timbre '%s' to channel %d", name.c_str(), channel);
debugC(5, kDebugMIDI, "Groovie::Music: Setting MT32 timbre '%s' to channel %d", name.c_str(), channel);

sysex.roland_id = 0x41;
sysex.device_id = channel; // Unit#
Expand Down Expand Up @@ -702,7 +702,7 @@ MusicPlayerMac_t7g::MusicPlayerMac_t7g(GroovieEngine *vm) : MusicPlayerMidi(vm)
}

bool MusicPlayerMac_t7g::load(uint32 fileref, bool loop) {
debugC(1, kGroovieDebugMIDI | kGroovieDebugAll, "Groovie::Music: Starting the playback of song: %04X", fileref);
debugC(1, kDebugMIDI, "Groovie::Music: Starting the playback of song: %04X", fileref);

// First try for compressed MIDI
Common::SeekableReadStream *file = _vm->_macResFork->getResource(MKTAG('c','m','i','d'), fileref & 0x3FF);
Expand Down Expand Up @@ -789,7 +789,7 @@ MusicPlayerMac_v2::MusicPlayerMac_v2(GroovieEngine *vm) : MusicPlayerMidi(vm) {
}

bool MusicPlayerMac_v2::load(uint32 fileref, bool loop) {
debugC(1, kGroovieDebugMIDI | kGroovieDebugAll, "Groovie::Music: Starting the playback of song: %04X", fileref);
debugC(1, kDebugMIDI, "Groovie::Music: Starting the playback of song: %04X", fileref);

// Find correct filename
ResInfo info;
Expand Down
6 changes: 3 additions & 3 deletions engines/groovie/player.cpp
Expand Up @@ -94,13 +94,13 @@ void VideoPlayer::waitFrame() {
} else {
uint32 millisDiff = currTime - _lastFrameTime;
if (millisDiff < _millisBetweenFrames) {
debugC(7, kGroovieDebugVideo | kGroovieDebugAll, "Groovie::Player: Delaying %d (currTime=%d, _lastFrameTime=%d, millisDiff=%d, _millisBetweenFrame=%d)",
debugC(7, kDebugVideo, "Groovie::Player: Delaying %d (currTime=%d, _lastFrameTime=%d, millisDiff=%d, _millisBetweenFrame=%d)",
_millisBetweenFrames - millisDiff, currTime, _lastFrameTime, millisDiff, _millisBetweenFrames);
_syst->delayMillis(_millisBetweenFrames - millisDiff);
currTime = _syst->getMillis();
debugC(7, kGroovieDebugVideo | kGroovieDebugAll, "Groovie::Player: Finished delay at %d", currTime);
debugC(7, kDebugVideo, "Groovie::Player: Finished delay at %d", currTime);
}
debugC(6, kGroovieDebugVideo | kGroovieDebugAll, "Groovie::Player: Frame displayed at %d (%f FPS)", currTime, 1000.0 / (currTime - _lastFrameTime));
debugC(6, kDebugVideo, "Groovie::Player: Frame displayed at %d (%f FPS)", currTime, 1000.0 / (currTime - _lastFrameTime));
_lastFrameTime = currTime;
}
}
Expand Down
10 changes: 5 additions & 5 deletions engines/groovie/resource.cpp
Expand Up @@ -47,7 +47,7 @@ Common::SeekableReadStream *ResMan::open(uint32 fileRef) {
return NULL;
}

debugC(1, kGroovieDebugResource | kGroovieDebugAll, "Groovie::Resource: Opening resource 0x%04X (%s, %d, %d)", fileRef, _gjds[resInfo.gjd].c_str(), resInfo.offset, resInfo.size);
debugC(1, kDebugResource, "Groovie::Resource: Opening resource 0x%04X (%s, %d, %d)", fileRef, _gjds[resInfo.gjd].c_str(), resInfo.offset, resInfo.size);

// Does it exist?
if (!Common::File::exists(_gjds[resInfo.gjd])) {
Expand Down Expand Up @@ -120,7 +120,7 @@ uint32 ResMan_t7g::getRef(Common::String name, Common::String scriptname) {
// Test whether it's the resource we're searching
Common::String resname(readname, 12);
if (resname.hasPrefix(name.c_str())) {
debugC(2, kGroovieDebugResource | kGroovieDebugAll, "Groovie::Resource: Resource %12s matches %s", readname, name.c_str());
debugC(2, kDebugResource, "Groovie::Resource: Resource %12s matches %s", readname, name.c_str());
found = true;
}

Expand Down Expand Up @@ -173,7 +173,7 @@ bool ResMan_t7g::getResInfo(uint32 fileRef, ResInfo &resInfo) {
char resname[13];
rlFile->read(resname, 12);
resname[12] = 0;
debugC(2, kGroovieDebugResource | kGroovieDebugAll, "Groovie::Resource: Resource name: %12s", resname);
debugC(2, kDebugResource, "Groovie::Resource: Resource name: %12s", resname);
resInfo.filename = resname;

// Read the resource information
Expand Down Expand Up @@ -240,7 +240,7 @@ uint32 ResMan_v2::getRef(Common::String name, Common::String scriptname) {
// Test whether it's the resource we're searching
Common::String resname(readname, 18);
if (resname.hasPrefix(name.c_str())) {
debugC(2, kGroovieDebugResource | kGroovieDebugAll, "Groovie::Resource: Resource %18s matches %s", readname, name.c_str());
debugC(2, kDebugResource, "Groovie::Resource: Resource %18s matches %s", readname, name.c_str());
found = true;
break;
}
Expand Down Expand Up @@ -284,7 +284,7 @@ bool ResMan_v2::getResInfo(uint32 fileRef, ResInfo &resInfo) {
char resname[19];
resname[18] = 0;
rlFile.read(resname, 18);
debugC(2, kGroovieDebugResource | kGroovieDebugAll, "Groovie::Resource: Resource name: %18s", resname);
debugC(2, kDebugResource, "Groovie::Resource: Resource name: %18s", resname);
resInfo.filename = resname;

// 6 padding bytes? (it looks like they're always 0)
Expand Down

0 comments on commit d875151

Please sign in to comment.