diff options
Diffstat (limited to 'engines/groovie')
34 files changed, 437 insertions, 439 deletions
diff --git a/engines/groovie/cell.cpp b/engines/groovie/cell.cpp index 8241579156..24fac17e44 100644 --- a/engines/groovie/cell.cpp +++ b/engines/groovie/cell.cpp @@ -8,12 +8,12 @@ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/engines/groovie/cell.h b/engines/groovie/cell.h index 32c7b46547..d6f1ac97dc 100644 --- a/engines/groovie/cell.h +++ b/engines/groovie/cell.h @@ -8,12 +8,12 @@ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/engines/groovie/configure.engine b/engines/groovie/configure.engine new file mode 100644 index 0000000000..212a49bec8 --- /dev/null +++ b/engines/groovie/configure.engine @@ -0,0 +1,4 @@ +# This file is included from the main "configure" script +# add_engine [name] [desc] [build-by-default] [subengines] [base games] [deps] +add_engine groovie "Groovie" yes "groovie2" "7th Guest" +add_engine groovie2 "Groovie 2 games" no "" "" "jpeg 16bit" diff --git a/engines/groovie/cursor.cpp b/engines/groovie/cursor.cpp index cac78a95a3..442f0bfada 100644 --- a/engines/groovie/cursor.cpp +++ b/engines/groovie/cursor.cpp @@ -8,12 +8,12 @@ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -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() { @@ -260,32 +260,32 @@ Cursor_v2::Cursor_v2(Common::File &file) { _width = file.readUint16LE(); _height = file.readUint16LE(); - _img = new byte[_width * _height * _numFrames * 2]; + _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); - decodeFrame(pal, data, _img + (f * _width * _height * 2)); + decodeFrame(pal, data, _img + (f * _width * _height * 4)); delete[] data; } @@ -364,16 +364,16 @@ void Cursor_v2::decodeFrame(byte *pal, byte *data, byte *dest) { } // Convert to screen format - // NOTE: Currently locked to 16bit + // NOTE: Currently locked to 32bpp ptr = tmp; for (int y = 0; y < _height; y++) { for (int x = 0; x < _width; x++) { if (*ptr == 1) { - *(uint16 *)dest = (uint16)_format.RGBToColor(*(ptr + 1), *(ptr + 2), *(ptr + 3)); + *(uint32 *)dest = _format.RGBToColor(*(ptr + 1), *(ptr + 2), *(ptr + 3)); } else { - *(uint16 *)dest = 0; + *(uint32 *)dest = 0; } - dest += 2; + dest += 4; ptr += 4; } } @@ -385,7 +385,7 @@ void Cursor_v2::enable() { } void Cursor_v2::showFrame(uint16 frame) { - int offset = _width * _height * frame * 2; + int offset = _width * _height * frame * 4; CursorMan.replaceCursor((const byte *)(_img + offset), _width, _height, _width >> 1, _height >> 1, 0, false, &_format); } diff --git a/engines/groovie/cursor.h b/engines/groovie/cursor.h index 87d994b077..bf91112ea4 100644 --- a/engines/groovie/cursor.h +++ b/engines/groovie/cursor.h @@ -8,12 +8,12 @@ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/engines/groovie/debug.cpp b/engines/groovie/debug.cpp index 74fe22922c..16db20413f 100644 --- a/engines/groovie/debug.cpp +++ b/engines/groovie/debug.cpp @@ -8,12 +8,12 @@ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -36,16 +36,16 @@ Debugger::Debugger(GroovieEngine *vm) : _vm(vm), _script(_vm->_script) { // Register the debugger comands - DCmd_Register("step", WRAP_METHOD(Debugger, cmd_step)); - DCmd_Register("go", WRAP_METHOD(Debugger, cmd_go)); - DCmd_Register("pc", WRAP_METHOD(Debugger, cmd_pc)); - DCmd_Register("fg", WRAP_METHOD(Debugger, cmd_fg)); - DCmd_Register("bg", WRAP_METHOD(Debugger, cmd_bg)); - DCmd_Register("mem", WRAP_METHOD(Debugger, cmd_mem)); - DCmd_Register("load", WRAP_METHOD(Debugger, cmd_loadgame)); - DCmd_Register("save", WRAP_METHOD(Debugger, cmd_savegame)); - DCmd_Register("playref", WRAP_METHOD(Debugger, cmd_playref)); - DCmd_Register("dumppal", WRAP_METHOD(Debugger, cmd_dumppal)); + registerCmd("step", WRAP_METHOD(Debugger, cmd_step)); + registerCmd("go", WRAP_METHOD(Debugger, cmd_go)); + registerCmd("pc", WRAP_METHOD(Debugger, cmd_pc)); + registerCmd("fg", WRAP_METHOD(Debugger, cmd_fg)); + registerCmd("bg", WRAP_METHOD(Debugger, cmd_bg)); + registerCmd("mem", WRAP_METHOD(Debugger, cmd_mem)); + registerCmd("load", WRAP_METHOD(Debugger, cmd_loadgame)); + registerCmd("save", WRAP_METHOD(Debugger, cmd_savegame)); + registerCmd("playref", WRAP_METHOD(Debugger, cmd_playref)); + registerCmd("dumppal", WRAP_METHOD(Debugger, cmd_dumppal)); } Debugger::~Debugger() { @@ -81,7 +81,7 @@ bool Debugger::cmd_pc(int argc, const char **argv) { int val = getNumber(argv[1]); _script->_currentInstruction = val; } - DebugPrintf("pc = 0x%04X (%d)\n", _script->_currentInstruction, _script->_currentInstruction); + debugPrintf("pc = 0x%04X (%d)\n", _script->_currentInstruction, _script->_currentInstruction); return true; } @@ -97,9 +97,9 @@ bool Debugger::cmd_mem(int argc, const char **argv) { // Get val = _script->_variables[pos]; } - DebugPrintf("mem[0x%04X] = 0x%02X\n", pos, val); + debugPrintf("mem[0x%04X] = 0x%02X\n", pos, val); } else { - DebugPrintf("Syntax: mem <addr> [<val>]\n"); + debugPrintf("Syntax: mem <addr> [<val>]\n"); } return true; } @@ -109,7 +109,7 @@ bool Debugger::cmd_loadgame(int argc, const char **argv) { int slot = getNumber(argv[1]); _script->loadgame(slot); } else { - DebugPrintf("Syntax: load <slot>\n"); + debugPrintf("Syntax: load <slot>\n"); } return true; } @@ -119,7 +119,7 @@ bool Debugger::cmd_savegame(int argc, const char **argv) { int slot = getNumber(argv[1]); _script->savegame(slot); } else { - DebugPrintf("Syntax: save <slot>\n"); + debugPrintf("Syntax: save <slot>\n"); } return true; } @@ -129,7 +129,7 @@ bool Debugger::cmd_playref(int argc, const char **argv) { int ref = getNumber(argv[1]); _script->playvideofromref(ref); } else { - DebugPrintf("Syntax: playref <videorefnum>\n"); + debugPrintf("Syntax: playref <videorefnum>\n"); } return true; } @@ -140,7 +140,7 @@ bool Debugger::cmd_dumppal(int argc, const char **argv) { _vm->_system->getPaletteManager()->grabPalette(palettedump, 0, 256); for (i = 0; i < 256; i++) { - DebugPrintf("%3d: %3d,%3d,%3d\n", i, palettedump[(i * 3)], palettedump[(i * 3) + 1], palettedump[(i * 3) + 2]); + debugPrintf("%3d: %3d,%3d,%3d\n", i, palettedump[(i * 3)], palettedump[(i * 3) + 1], palettedump[(i * 3) + 2]); } return true; } diff --git a/engines/groovie/debug.h b/engines/groovie/debug.h index 76f6d16c65..b99d6c6e1b 100644 --- a/engines/groovie/debug.h +++ b/engines/groovie/debug.h @@ -8,12 +8,12 @@ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/engines/groovie/detection.cpp b/engines/groovie/detection.cpp index 7c89114e83..a249b66858 100644 --- a/engines/groovie/detection.cpp +++ b/engines/groovie/detection.cpp @@ -8,12 +8,12 @@ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/engines/groovie/detection.h b/engines/groovie/detection.h index aa900cc54d..e49474474b 100644 --- a/engines/groovie/detection.h +++ b/engines/groovie/detection.h @@ -8,12 +8,12 @@ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/engines/groovie/font.cpp b/engines/groovie/font.cpp index d29c22dd02..21a3bd07ae 100644 --- a/engines/groovie/font.cpp +++ b/engines/groovie/font.cpp @@ -8,12 +8,12 @@ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -112,7 +112,7 @@ bool T7GFont::load(Common::SeekableReadStream &stream) { return true; } -void T7GFont::drawChar(Graphics::Surface *dst, byte chr, int x, int y, uint32 color) const { +void T7GFont::drawChar(Graphics::Surface *dst, uint32 chr, int x, int y, uint32 color) const { // We ignore the color, as the font is already colored const Glyph *glyph = getGlyph(chr); const byte *src = glyph->pixels; @@ -125,7 +125,7 @@ void T7GFont::drawChar(Graphics::Surface *dst, byte chr, int x, int y, uint32 co } } -const T7GFont::Glyph *T7GFont::getGlyph(byte chr) const { +const T7GFont::Glyph *T7GFont::getGlyph(uint32 chr) const { assert (chr < 128); byte numGlyph = _mapChar2Glyph[chr]; diff --git a/engines/groovie/font.h b/engines/groovie/font.h index 20aaa4cf23..23e060faf3 100644 --- a/engines/groovie/font.h +++ b/engines/groovie/font.h @@ -8,12 +8,12 @@ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -37,8 +37,8 @@ public: int getFontHeight() const { return _maxHeight; } int getMaxCharWidth() const { return _maxWidth; } - int getCharWidth(byte chr) const { return getGlyph(chr)->width; } - void drawChar(Graphics::Surface *dst, byte chr, int x, int y, uint32 color) const; + int getCharWidth(uint32 chr) const { return getGlyph(chr)->width; } + void drawChar(Graphics::Surface *dst, uint32 chr, int x, int y, uint32 color) const; private: int _maxHeight, _maxWidth; @@ -55,7 +55,7 @@ private: byte _mapChar2Glyph[128]; Glyph *_glyphs; - const Glyph *getGlyph(byte chr) const; + const Glyph *getGlyph(uint32 chr) const; }; } // End of Groovie namespace diff --git a/engines/groovie/graphics.cpp b/engines/groovie/graphics.cpp index a4d8a4330c..b85277fac7 100644 --- a/engines/groovie/graphics.cpp +++ b/engines/groovie/graphics.cpp @@ -8,12 +8,12 @@ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/engines/groovie/graphics.h b/engines/groovie/graphics.h index c91d895c25..72ab01deb6 100644 --- a/engines/groovie/graphics.h +++ b/engines/groovie/graphics.h @@ -8,12 +8,12 @@ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/engines/groovie/groovie.cpp b/engines/groovie/groovie.cpp index 5ade442742..b42cf09245 100644 --- a/engines/groovie/groovie.cpp +++ b/engines/groovie/groovie.cpp @@ -8,12 +8,12 @@ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -29,10 +29,13 @@ #include "groovie/graphics.h" #include "groovie/music.h" #include "groovie/resource.h" -#include "groovie/roq.h" #include "groovie/stuffit.h" #include "groovie/vdx.h" +#ifdef ENABLE_GROOVIE2 +#include "groovie/roq.h" +#endif + #include "common/config-manager.h" #include "common/debug-channels.h" #include "common/events.h" @@ -50,7 +53,8 @@ namespace Groovie { GroovieEngine::GroovieEngine(OSystem *syst, const GroovieGameDescription *gd) : Engine(syst), _gameDescription(gd), _debugger(NULL), _script(NULL), _resMan(NULL), _grvCursorMan(NULL), _videoPlayer(NULL), _musicPlayer(NULL), - _graphicsMan(NULL), _macResFork(NULL), _waitingForInput(false), _font(NULL) { + _graphicsMan(NULL), _macResFork(NULL), _waitingForInput(false), _font(NULL), + _spookyMode(false) { // Adding the default directories const Common::FSNode gameDataDir(ConfMan.get("path")); @@ -64,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() { @@ -103,14 +106,18 @@ Common::Error GroovieEngine::run() { // Initialize the graphics switch (_gameDescription->version) { - case kGroovieV2: + case kGroovieV2: { // Request the mode with the highest precision available - initGraphics(640, 480, true, NULL); + Graphics::PixelFormat format(4, 8, 8, 8, 8, 24, 16, 8, 0); + initGraphics(640, 480, true, &format); - // Save the enabled mode as it can be both an RGB mode or CLUT8 - _pixelFormat = _system->getScreenFormat(); - _mode8bit = (_pixelFormat == Graphics::PixelFormat::createFormatCLUT8()); + if (_system->getScreenFormat() != format) + return Common::kUnsupportedColorMode; + + // Save the enabled mode + _pixelFormat = format; break; + } case kGroovieT7G: initGraphics(640, 480, true); _pixelFormat = Graphics::PixelFormat::createFormatCLUT8(); @@ -154,7 +161,9 @@ Common::Error GroovieEngine::run() { case kGroovieV2: _resMan = new ResMan_v2(); _grvCursorMan = new GrvCursorMan_v2(_system); +#ifdef ENABLE_GROOVIE2 _videoPlayer = new ROQPlayer(this); +#endif break; } diff --git a/engines/groovie/groovie.h b/engines/groovie/groovie.h index 79abc13b1c..d442d39cb2 100644 --- a/engines/groovie/groovie.h +++ b/engines/groovie/groovie.h @@ -8,12 +8,12 @@ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -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. }; /** @@ -110,7 +110,7 @@ public: void waitForInput(); Graphics::PixelFormat _pixelFormat; - bool _mode8bit; + bool _spookyMode; Script *_script; ResMan *_resMan; GrvCursorMan *_grvCursorMan; diff --git a/engines/groovie/lzss.cpp b/engines/groovie/lzss.cpp index a09f6e2311..2a185aeeab 100644 --- a/engines/groovie/lzss.cpp +++ b/engines/groovie/lzss.cpp @@ -8,12 +8,12 @@ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/engines/groovie/lzss.h b/engines/groovie/lzss.h index f60ea14815..06b07a946a 100644 --- a/engines/groovie/lzss.h +++ b/engines/groovie/lzss.h @@ -8,12 +8,12 @@ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/engines/groovie/module.mk b/engines/groovie/module.mk index b47eed912b..84d6222c59 100644 --- a/engines/groovie/module.mk +++ b/engines/groovie/module.mk @@ -12,12 +12,16 @@ MODULE_OBJS := \ music.o \ player.o \ resource.o \ - roq.o \ saveload.o \ script.o \ stuffit.o \ vdx.o +ifdef ENABLE_GROOVIE2 +MODULE_OBJS += \ + roq.o +endif + # This module can be built as a plugin ifeq ($(ENABLE_GROOVIE), DYNAMIC_PLUGIN) PLUGIN := 1 diff --git a/engines/groovie/music.cpp b/engines/groovie/music.cpp index 95637fc407..2c164e020c 100644 --- a/engines/groovie/music.cpp +++ b/engines/groovie/music.cpp @@ -8,12 +8,12 @@ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -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; } @@ -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 @@ -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); } } @@ -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(); @@ -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; @@ -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(); } } @@ -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); @@ -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; @@ -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(); } @@ -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 @@ -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 @@ -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); @@ -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)) { @@ -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); } @@ -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# @@ -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); @@ -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; diff --git a/engines/groovie/music.h b/engines/groovie/music.h index 92e9c8b487..4853840673 100644 --- a/engines/groovie/music.h +++ b/engines/groovie/music.h @@ -8,12 +8,12 @@ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/engines/groovie/player.cpp b/engines/groovie/player.cpp index e2a1ff3d56..c1b90fbd2c 100644 --- a/engines/groovie/player.cpp +++ b/engines/groovie/player.cpp @@ -8,12 +8,12 @@ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -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; } } diff --git a/engines/groovie/player.h b/engines/groovie/player.h index c9258ffdbd..b1aac963f2 100644 --- a/engines/groovie/player.h +++ b/engines/groovie/player.h @@ -8,12 +8,12 @@ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/engines/groovie/resource.cpp b/engines/groovie/resource.cpp index 42d76cabfa..75eba95240 100644 --- a/engines/groovie/resource.cpp +++ b/engines/groovie/resource.cpp @@ -8,12 +8,12 @@ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -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])) { @@ -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; } @@ -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 @@ -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; } @@ -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) diff --git a/engines/groovie/resource.h b/engines/groovie/resource.h index 33e15e6b98..11a861dd5c 100644 --- a/engines/groovie/resource.h +++ b/engines/groovie/resource.h @@ -8,12 +8,12 @@ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/engines/groovie/roq.cpp b/engines/groovie/roq.cpp index e1ca7fb945..379fcabc07 100644 --- a/engines/groovie/roq.cpp +++ b/engines/groovie/roq.cpp @@ -8,12 +8,12 @@ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -28,11 +28,12 @@ #include "groovie/groovie.h" #include "common/debug.h" +#include "common/rect.h" #include "common/substream.h" #include "common/textconsole.h" #include "graphics/palette.h" -#include "graphics/decoders/jpeg.h" +#include "image/jpeg.h" #ifdef USE_RGB_COLOR // Required for the YUV to RGB conversion @@ -45,24 +46,12 @@ namespace Groovie { ROQPlayer::ROQPlayer(GroovieEngine *vm) : VideoPlayer(vm), _codingTypeCount(0), - _fg(&_vm->_graphicsMan->_foreground), _bg(&_vm->_graphicsMan->_background) { + _bg(&_vm->_graphicsMan->_background), + _firstFrame(true) { // Create the work surfaces _currBuf = new Graphics::Surface(); _prevBuf = new Graphics::Surface(); - - if (_vm->_mode8bit) { - byte pal[256 * 3]; - - // Set a grayscale palette - for (int i = 0; i < 256; i++) { - pal[(i * 3) + 0] = i; - pal[(i * 3) + 1] = i; - pal[(i * 3) + 2] = i; - } - - _syst->getPaletteManager()->setPalette(pal, 0, 256); - } } ROQPlayer::~ROQPlayer() { @@ -75,7 +64,7 @@ ROQPlayer::~ROQPlayer() { uint16 ROQPlayer::loadInternal() { // Begin reading the file - debugC(1, kGroovieDebugVideo | kGroovieDebugAll, "Groovie::ROQ: Loading video"); + debugC(1, kDebugVideo, "Groovie::ROQ: Loading video"); // Read the file header ROQBlockHeader blockHeader; @@ -95,6 +84,9 @@ uint16 ROQPlayer::loadInternal() { _num2blocks = 0; _num4blocks = 0; + // Reset the first frame flag + _firstFrame = true; + if ((blockHeader.size == 0) && (blockHeader.param == 0)) { // Set the offset scaling to 2 _offScale = 2; @@ -115,35 +107,31 @@ uint16 ROQPlayer::loadInternal() { void ROQPlayer::buildShowBuf() { for (int line = 0; line < _bg->h; line++) { - byte *out = (byte *)_bg->getBasePtr(0, line); - byte *in = (byte *)_currBuf->getBasePtr(0, line / _scaleY); + uint32 *out = (uint32 *)_bg->getBasePtr(0, line); + uint32 *in = (uint32 *)_currBuf->getBasePtr(0, line / _scaleY); + for (int x = 0; x < _bg->w; x++) { - if (_vm->_mode8bit) { - // Just use the luminancy component - *out = *in; -#ifdef USE_RGB_COLOR - } else { - // Do the format conversion (YUV -> RGB -> Screen format) - byte r, g, b; - Graphics::YUV2RGB(*in, *(in + 1), *(in + 2), r, g, b); - // FIXME: this is fixed to 16bit - *(uint16 *)out = (uint16)_vm->_pixelFormat.RGBToColor(r, g, b); -#endif // USE_RGB_COLOR - } + // Copy a pixel + *out++ = *in; // Skip to the next pixel - out += _vm->_pixelFormat.bytesPerPixel; if (!(x % _scaleX)) - in += _currBuf->format.bytesPerPixel; + in++; } } + // On the first frame, copy from the current buffer to the prev buffer + if (_firstFrame) { + _prevBuf->copyFrom(*_currBuf); + _firstFrame = false; + } + // Swap buffers SWAP(_prevBuf, _currBuf); } bool ROQPlayer::playFrameInternal() { - debugC(5, kGroovieDebugVideo | kGroovieDebugAll, "Groovie::ROQ: Playing frame"); + debugC(5, kDebugVideo, "Groovie::ROQ: Playing frame"); // Process the needed blocks until the next video frame bool endframe = false; @@ -180,9 +168,9 @@ bool ROQPlayer::readBlockHeader(ROQBlockHeader &blockHeader) { blockHeader.size = _file->readUint32LE(); blockHeader.param = _file->readUint16LE(); - debugC(10, kGroovieDebugVideo | kGroovieDebugAll, "Groovie::ROQ: Block type = 0x%02X", blockHeader.type); - debugC(10, kGroovieDebugVideo | kGroovieDebugAll, "Groovie::ROQ: Block size = 0x%08X", blockHeader.size); - debugC(10, kGroovieDebugVideo | kGroovieDebugAll, "Groovie::ROQ: Block param = 0x%04X", blockHeader.param); + debugC(10, kDebugVideo, "Groovie::ROQ: Block type = 0x%02X", blockHeader.type); + debugC(10, kDebugVideo, "Groovie::ROQ: Block size = 0x%08X", blockHeader.size); + debugC(10, kDebugVideo, "Groovie::ROQ: Block param = 0x%04X", blockHeader.param); return true; } @@ -250,7 +238,7 @@ bool ROQPlayer::processBlock() { } bool ROQPlayer::processBlockInfo(ROQBlockHeader &blockHeader) { - debugC(5, kGroovieDebugVideo | kGroovieDebugAll, "Groovie::ROQ: Processing info block"); + debugC(5, kDebugVideo, "Groovie::ROQ: Processing info block"); // Verify the block header if (blockHeader.type != 0x1001 || blockHeader.size != 8 || (blockHeader.param != 0 && blockHeader.param != 1)) { @@ -258,6 +246,9 @@ bool ROQPlayer::processBlockInfo(ROQBlockHeader &blockHeader) { return false; } + // Reset the first frame flag + _firstFrame = true; + // Save the alpha channel size _alpha = blockHeader.param; @@ -282,32 +273,19 @@ bool ROQPlayer::processBlockInfo(ROQBlockHeader &blockHeader) { _prevBuf->free(); // Allocate new buffers - // These buffers use YUV data, since we can not describe it with a - // PixelFormat struct we just add some dummy PixelFormat with the - // correct bytes per pixel value. Since the surfaces are only used - // internally and no code assuming RGB data is present is used on - // them it should be just fine. - _currBuf->create(width, height, Graphics::PixelFormat(3, 0, 0, 0, 0, 0, 0, 0, 0)); - _prevBuf->create(width, height, Graphics::PixelFormat(3, 0, 0, 0, 0, 0, 0, 0, 0)); - } - - // Clear the buffers with black YUV values - byte *ptr1 = (byte *)_currBuf->getPixels(); - byte *ptr2 = (byte *)_prevBuf->getPixels(); - for (int i = 0; i < width * height; i++) { - *ptr1++ = 0; - *ptr1++ = 128; - *ptr1++ = 128; - *ptr2++ = 0; - *ptr2++ = 128; - *ptr2++ = 128; + _currBuf->create(width, height, _vm->_pixelFormat); + _prevBuf->create(width, height, _vm->_pixelFormat); } + // Clear the buffers with black + _currBuf->fillRect(Common::Rect(width, height), _vm->_pixelFormat.RGBToColor(0, 0, 0)); + _prevBuf->fillRect(Common::Rect(width, height), _vm->_pixelFormat.RGBToColor(0, 0, 0)); + return true; } bool ROQPlayer::processBlockQuadCodebook(ROQBlockHeader &blockHeader) { - debugC(5, kGroovieDebugVideo | kGroovieDebugAll, "Groovie::ROQ: Processing quad codebook block"); + debugC(5, kDebugVideo, "Groovie::ROQ: Processing quad codebook block"); // Get the number of 2x2 pixel blocks to read int newNum2blocks = blockHeader.param >> 8; @@ -324,15 +302,28 @@ bool ROQPlayer::processBlockQuadCodebook(ROQBlockHeader &blockHeader) { } // Read the 2x2 codebook + uint32 *codebook = _codebook2; + for (int i = 0; i < newNum2blocks; i++) { // Read the 4 Y components and their alpha channel + byte y[4]; + byte a[4]; + for (int j = 0; j < 4; j++) { - _codebook2[i * 10 + j * 2] = _file->readByte(); - _codebook2[i * 10 + j * 2 + 1] = _alpha ? _file->readByte() : 255; + y[j] = _file->readByte(); + a[j] = _alpha ? _file->readByte() : 255; } // Read the subsampled Cb and Cr - _file->read(&_codebook2[i * 10 + 8], 2); + byte u = _file->readByte(); + byte v = _file->readByte(); + + // Convert the codebook to RGB right here + for (int j = 0; j < 4; j++) { + byte r, g, b; + Graphics::YUV2RGB(y[j], u, v, r, g, b); + *codebook++ = _vm->_pixelFormat.ARGBToColor(a[j], r, g, b); + } } // Read the 4x4 codebook @@ -342,7 +333,7 @@ bool ROQPlayer::processBlockQuadCodebook(ROQBlockHeader &blockHeader) { } bool ROQPlayer::processBlockQuadVector(ROQBlockHeader &blockHeader) { - debugC(5, kGroovieDebugVideo | kGroovieDebugAll, "Groovie::ROQ: Processing quad vector block"); + debugC(5, kDebugVideo, "Groovie::ROQ: Processing quad vector block"); // Get the mean motion vectors int8 Mx = blockHeader.param >> 8; @@ -405,7 +396,7 @@ void ROQPlayer::processBlockQuadVectorBlock(int baseX, int baseY, int8 Mx, int8 } void ROQPlayer::processBlockQuadVectorBlockSub(int baseX, int baseY, int8 Mx, int8 My) { - debugC(6, kGroovieDebugVideo | kGroovieDebugAll, "Groovie::ROQ: Processing quad vector sub block"); + debugC(6, kDebugVideo, "Groovie::ROQ: Processing quad vector sub block"); uint16 codingType = getCodingType(); switch (codingType) { @@ -431,30 +422,25 @@ void ROQPlayer::processBlockQuadVectorBlockSub(int baseX, int baseY, int8 Mx, in } bool ROQPlayer::processBlockStill(ROQBlockHeader &blockHeader) { - debugC(5, kGroovieDebugVideo | kGroovieDebugAll, "Groovie::ROQ: Processing still (JPEG) block"); - - warning("Groovie::ROQ: JPEG frame (unfinished)"); + debugC(5, kDebugVideo, "Groovie::ROQ: Processing still (JPEG) block"); - Graphics::JPEGDecoder *jpg = new Graphics::JPEGDecoder(); - jpg->setOutputColorSpace(Graphics::JPEGDecoder::kColorSpaceYUV); + Image::JPEGDecoder jpg; uint32 startPos = _file->pos(); Common::SeekableSubReadStream subStream(_file, startPos, startPos + blockHeader.size, DisposeAfterUse::NO); - jpg->loadStream(subStream); + jpg.loadStream(subStream); - const Graphics::Surface *srcSurf = jpg->getSurface(); - const byte *src = (const byte *)srcSurf->getPixels(); - byte *ptr = (byte *)_currBuf->getPixels(); - memcpy(ptr, src, _currBuf->w * _currBuf->h * srcSurf->format.bytesPerPixel); - - delete jpg; + const Graphics::Surface *srcSurf = jpg.getSurface(); + _currBuf->free(); + delete _currBuf; + _currBuf = srcSurf->convertTo(_vm->_pixelFormat); _file->seek(startPos + blockHeader.size); return true; } bool ROQPlayer::processBlockSoundMono(ROQBlockHeader &blockHeader) { - debugC(5, kGroovieDebugVideo | kGroovieDebugAll, "Groovie::ROQ: Processing mono sound block"); + debugC(5, kDebugVideo, "Groovie::ROQ: Processing mono sound block"); // Verify the block header if (blockHeader.type != 0x1020) { @@ -497,7 +483,7 @@ bool ROQPlayer::processBlockSoundMono(ROQBlockHeader &blockHeader) { } bool ROQPlayer::processBlockSoundStereo(ROQBlockHeader &blockHeader) { - debugC(5, kGroovieDebugVideo | kGroovieDebugAll, "Groovie::ROQ: Processing stereo sound block"); + debugC(5, kDebugVideo, "Groovie::ROQ: Processing stereo sound block"); // Verify the block header if (blockHeader.type != 0x1021) { @@ -553,7 +539,7 @@ bool ROQPlayer::processBlockSoundStereo(ROQBlockHeader &blockHeader) { } bool ROQPlayer::processBlockAudioContainer(ROQBlockHeader &blockHeader) { - debugC(5, kGroovieDebugVideo | kGroovieDebugAll, "Groovie::ROQ: Processing audio container block: 0x%04X", blockHeader.param); + debugC(5, kDebugVideo, "Groovie::ROQ: Processing audio container block: 0x%04X", blockHeader.param); return true; } @@ -573,25 +559,14 @@ void ROQPlayer::paint2(byte i, int destx, int desty) { error("Groovie::ROQ: Invalid 2x2 block %d (%d available)", i, _num2blocks); } - byte *block = &_codebook2[i * 10]; - byte u = block[8]; - byte v = block[9]; + uint32 *block = _codebook2 + i * 4; + uint32 *ptr = (uint32 *)_currBuf->getBasePtr(destx, desty); + uint32 pitch = _currBuf->pitch / 4; - byte *ptr = (byte *)_currBuf->getBasePtr(destx, desty); - for (int y = 0; y < 2; y++) { - for (int x = 0; x < 2; x++) { - // Basic alpha test - // TODO: Blending - if (*(block + 1) > 128) { - *ptr = *block; - *(ptr + 1) = u; - *(ptr + 2) = v; - } - ptr += 3; - block += 2; - } - ptr += _currBuf->pitch - 6; - } + ptr[0] = block[0]; + ptr[1] = block[1]; + ptr[pitch] = block[2]; + ptr[pitch + 1] = block[3]; } void ROQPlayer::paint4(byte i, int destx, int desty) { @@ -616,25 +591,14 @@ void ROQPlayer::paint8(byte i, int destx, int desty) { byte *block4 = &_codebook4[i * 4]; for (int y4 = 0; y4 < 2; y4++) { for (int x4 = 0; x4 < 2; x4++) { - byte *block2 = &_codebook2[(*block4) * 10]; - byte u = block2[8]; - byte v = block2[9]; - block4++; + uint32 *block2 = _codebook2 + *block4++ * 4; + for (int y2 = 0; y2 < 2; y2++) { for (int x2 = 0; x2 < 2; x2++) { - for (int repy = 0; repy < 2; repy++) { - for (int repx = 0; repx < 2; repx++) { - // Basic alpha test - // TODO: Blending - if (*(block2 + 1) > 128) { - byte *ptr = (byte *)_currBuf->getBasePtr(destx + x4*4 + x2*2 + repx, desty + y4*4 + y2*2 + repy); - *ptr = *block2; - *(ptr + 1) = u; - *(ptr + 2) = v; - } - } - } - block2 += 2; + uint32 *ptr = (uint32 *)_currBuf->getBasePtr(destx + x4 * 4 + x2 * 2, desty + y4 * 4 + y2 * 2); + uint32 pitch = _currBuf->pitch / 4; + uint32 color = *block2++; + ptr[0] = ptr[1] = ptr[pitch] = ptr[pitch + 1] = color; } } } @@ -655,7 +619,7 @@ void ROQPlayer::copy(byte size, int destx, int desty, int offx, int offy) { // Move to the beginning of the next line dst += _currBuf->pitch; - src += _currBuf->pitch; + src += _prevBuf->pitch; } } diff --git a/engines/groovie/roq.h b/engines/groovie/roq.h index c5d3f255d3..7e7d38580e 100644 --- a/engines/groovie/roq.h +++ b/engines/groovie/roq.h @@ -8,12 +8,12 @@ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -71,18 +71,18 @@ private: // Codebooks uint16 _num2blocks; uint16 _num4blocks; - byte _codebook2[256 * 10]; + uint32 _codebook2[256 * 4]; byte _codebook4[256 * 4]; // Buffers - Graphics::Surface *_fg, *_bg, *_thirdBuf; + Graphics::Surface *_bg; Graphics::Surface *_currBuf, *_prevBuf; void buildShowBuf(); byte _scaleX, _scaleY; byte _offScale; bool _dirty; byte _alpha; - + bool _firstFrame; }; } // End of Groovie namespace diff --git a/engines/groovie/saveload.cpp b/engines/groovie/saveload.cpp index 1a92c02e0e..78b79cfa26 100644 --- a/engines/groovie/saveload.cpp +++ b/engines/groovie/saveload.cpp @@ -8,12 +8,12 @@ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/engines/groovie/saveload.h b/engines/groovie/saveload.h index 15ce108c7d..6f20250e0a 100644 --- a/engines/groovie/saveload.h +++ b/engines/groovie/saveload.h @@ -8,12 +8,12 @@ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/engines/groovie/script.cpp b/engines/groovie/script.cpp index 8e3bef9945..7625151082 100644 --- a/engines/groovie/script.cpp +++ b/engines/groovie/script.cpp @@ -8,12 +8,12 @@ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -47,26 +47,6 @@ namespace Groovie { -static void debugScript(int level, bool nl, const char *s, ...) GCC_PRINTF(3, 4); - -static void debugScript(int level, bool nl, const char *s, ...) { - char buf[STRINGBUFLEN]; - va_list va; - - if (!DebugMan.isDebugChannelEnabled(kGroovieDebugScript) && - !DebugMan.isDebugChannelEnabled(kGroovieDebugAll)) - return; - - va_start(va, s); - vsnprintf(buf, STRINGBUFLEN, s, va); - va_end(va); - - if (nl) - debug(level, "%s", buf); - else - debugN(level, "%s", buf); -} - Script::Script(GroovieEngine *vm, EngineVersion version) : _code(NULL), _savedCode(NULL), _stacktop(0), _debugger(NULL), _vm(vm), _videoFile(NULL), _videoRef(0), _staufsMove(NULL), _lastCursor(0xff), @@ -120,7 +100,7 @@ Script::~Script() { void Script::setVariable(uint16 variablenum, byte value) { _variables[variablenum] = value; - debugC(1, kGroovieDebugScriptvars | kGroovieDebugAll, "script variable[0x%03X] = %d (0x%04X)", variablenum, value, value); + debugC(1, kDebugScriptvars, "script variable[0x%03X] = %d (0x%04X)", variablenum, value, value); } void Script::setDebugger(Debugger *debugger) { @@ -229,7 +209,7 @@ void Script::step() { // Only output if we're not re-doing the previous instruction if (_currentInstruction != _oldInstruction) { - debugScript(1, false, "%s", _debugString.c_str()); + debugCN(1, kDebugScript, "%s", _debugString.c_str()); _oldInstruction = _currentInstruction; } @@ -354,7 +334,7 @@ uint32 Script::getVideoRefString() { // Add a trailing dot str += 0x2E; - debugScript(0, false, "%s", str.c_str()); + debugCN(0, kDebugScript, "%s", str.c_str()); // Extract the script name. Common::String scriptname(_scriptFile.c_str(), _scriptFile.size() - 4); @@ -369,8 +349,7 @@ bool Script::hotspot(Common::Rect rect, uint16 address, uint8 cursor) { bool contained = rect.contains(mousepos); // Show hotspots when debugging - if (DebugMan.isDebugChannelEnabled(kGroovieDebugHotspots) || - DebugMan.isDebugChannelEnabled(kGroovieDebugAll)) { + if (DebugMan.isDebugChannelEnabled(kDebugHotspots)) { rect.translate(0, -80); _vm->_graphicsMan->_foreground.frameRect(rect, 250); _vm->_system->copyRectToScreen(_vm->_graphicsMan->_foreground.getPixels(), _vm->_graphicsMan->_foreground.pitch, 0, 80, 640, 320); @@ -416,7 +395,7 @@ void Script::savegame(uint slot) { Common::OutSaveFile *file = SaveLoad::openForSaving(ConfMan.getActiveDomainName(), slot); if (!file) { - debugC(9, kGroovieDebugScript, "Save file pointer is null"); + debugC(9, kDebugScript, "Save file pointer is null"); GUI::MessageDialog dialog(_("Failed to save game"), _("OK")); dialog.runModal(); return; @@ -462,32 +441,32 @@ void Script::o_invalid() { } void Script::o_nop() { - debugScript(1, true, "NOP"); + debugC(1, kDebugScript, "NOP"); } void Script::o_nop8() { uint8 tmp = readScript8bits(); - debugScript(1, true, "NOP8: 0x%02X", tmp); + debugC(1, kDebugScript, "NOP8: 0x%02X", tmp); } void Script::o_nop16() { uint16 tmp = readScript16bits(); - debugScript(1, true, "NOP16: 0x%04X", tmp); + debugC(1, kDebugScript, "NOP16: 0x%04X", tmp); } void Script::o_nop32() { uint32 tmp = readScript32bits(); - debugScript(1, true, "NOP32: 0x%08X", tmp); + debugC(1, kDebugScript, "NOP32: 0x%08X", tmp); } void Script::o_nop8or16() { uint16 tmp = readScript8or16bits(); - debugScript(1, true, "NOP8OR16: 0x%04X", tmp); + debugC(1, kDebugScript, "NOP8OR16: 0x%04X", tmp); } void Script::o_playsong() { // 0x02 uint16 fileref = readScript16bits(); - debugScript(1, true, "PlaySong(0x%04X): Play xmidi file", fileref); + debugC(1, kDebugScript, "PlaySong(0x%04X): Play xmidi file", fileref); if (fileref == 0x4C17) { warning("this song is special somehow"); // don't save the reference? @@ -496,33 +475,33 @@ void Script::o_playsong() { // 0x02 } void Script::o_bf9on() { // 0x03 - debugScript(1, true, "BF9ON: bitflag 9 turned on"); + debugC(1, kDebugScript, "BF9ON: bitflag 9 turned on"); _bitflags |= 1 << 9; } void Script::o_palfadeout() { - debugScript(1, true, "PALFADEOUT"); + debugC(1, kDebugScript, "PALFADEOUT"); _vm->_graphicsMan->fadeOut(); } void Script::o_bf8on() { // 0x05 - debugScript(1, true, "BF8ON: bitflag 8 turned on"); + debugC(1, kDebugScript, "BF8ON: bitflag 8 turned on"); _bitflags |= 1 << 8; } void Script::o_bf6on() { // 0x06 - debugScript(1, true, "BF6ON: bitflag 6 turned on"); + debugC(1, kDebugScript, "BF6ON: bitflag 6 turned on"); _bitflags |= 1 << 6; } void Script::o_bf7on() { // 0x07 - debugScript(1, true, "BF7ON: bitflag 7 turned on"); + debugC(1, kDebugScript, "BF7ON: bitflag 7 turned on"); _bitflags |= 1 << 7; } void Script::o_setbackgroundsong() { // 0x08 uint16 fileref = readScript16bits(); - debugScript(1, true, "SetBackgroundSong(0x%04X)", fileref); + debugC(1, kDebugScript, "SetBackgroundSong(0x%04X)", fileref); _vm->_musicPlayer->setBackgroundSong(fileref); } @@ -531,15 +510,15 @@ void Script::o_videofromref() { // 0x09 // Show the debug information just when starting the playback if (fileref != _videoRef) { - debugScript(1, false, "VIDEOFROMREF(0x%04X) (Not fully imp): Play video file from ref", fileref); - debugC(5, kGroovieDebugVideo | kGroovieDebugAll, "Playing video 0x%04X via 0x09", fileref); + debugC(1, kDebugScript, "VIDEOFROMREF(0x%04X) (Not fully imp): Play video file from ref", fileref); + debugC(5, kDebugVideo, "Playing video 0x%04X via 0x09", fileref); } switch (fileref) { case 0x1C03: // Trilobyte logo case 0x1C04: // Virgin logo case 0x1C05: // Credits if (fileref != _videoRef) { - debugScript(1, true, "Use external file if available"); + debugC(1, kDebugScript, "Use external file if available"); } break; @@ -551,12 +530,12 @@ void Script::o_videofromref() { // 0x09 case 0x206D: // Cards on table puzzle (bedroom) case 0x2001: // Coins on table puzzle (bedroom) if (fileref != _videoRef) { - debugScript(1, false, " (This video is special somehow!)"); + debugCN(1, kDebugScript, " (This video is special somehow!)"); warning("(This video (0x%04X) is special somehow!)", fileref); } } if (fileref != _videoRef) { - debugScript(1, false, "\n"); + debugCN(1, kDebugScript, "\n"); } // Play the video if (!playvideofromref(fileref)) { @@ -570,14 +549,14 @@ bool Script::playvideofromref(uint32 fileref) { if (fileref != _videoRef) { // Debug bitflags - debugScript(1, false, "Play video 0x%04X (bitflags:", fileref); + debugCN(1, kDebugScript, "Play video 0x%04X (bitflags:", fileref); for (int i = 15; i >= 0; i--) { - debugScript(1, false, "%d", _bitflags & (1 << i)? 1 : 0); + debugCN(1, kDebugScript, "%d", _bitflags & (1 << i)? 1 : 0); if (i % 4 == 0) { - debugScript(1, false, " "); + debugCN(1, kDebugScript, " "); } } - debugScript(1, true, " <- 0)"); + debugC(1, kDebugScript, " <- 0)"); // Close the previous video file if (_videoFile) { @@ -634,7 +613,7 @@ bool Script::playvideofromref(uint32 fileref) { _eventKbdChar = 0; // Newline - debugScript(1, false, "\n"); + debugCN(1, kDebugScript, "\n"); } // Let the caller know if the video has ended @@ -646,12 +625,12 @@ bool Script::playvideofromref(uint32 fileref) { } void Script::o_bf5on() { // 0x0A - debugScript(1, true, "BF5ON: bitflag 5 turned on"); + debugC(1, kDebugScript, "BF5ON: bitflag 5 turned on"); _bitflags |= 1 << 5; } void Script::o_inputloopstart() { //0x0B - debugScript(5, true, "Input loop start"); + debugC(5, kDebugScript, "Input loop start"); // Reset the input action and the mouse cursor _inputAction = -1; @@ -675,7 +654,7 @@ void Script::o_keyboardaction() { uint8 val = readScript8bits(); uint16 address = readScript16bits(); - debugScript(5, true, "Test key == 0x%02X @0x%04X", val, address); + debugC(5, kDebugScript, "Test key == 0x%02X @0x%04X", val, address); // If there's an already planned action, do nothing if (_inputAction != -1) { @@ -700,7 +679,7 @@ void Script::o_hotspot_rect() { uint16 address = readScript16bits(); uint8 cursor = readScript8bits(); - debugScript(5, true, "HOTSPOT-RECT(%d,%d,%d,%d) @0x%04X cursor=%d", left, top, right, bottom, address, cursor); + debugC(5, kDebugScript, "HOTSPOT-RECT(%d,%d,%d,%d) @0x%04X cursor=%d", left, top, right, bottom, address, cursor); // Mark the specified rectangle Common::Rect rect(left, top, right, bottom); @@ -710,7 +689,7 @@ void Script::o_hotspot_rect() { void Script::o_hotspot_left() { uint16 address = readScript16bits(); - debugScript(5, true, "HOTSPOT-LEFT @0x%04X", address); + debugC(5, kDebugScript, "HOTSPOT-LEFT @0x%04X", address); // Mark the leftmost 100 pixels of the game area Common::Rect rect(0, 80, 100, 400); @@ -720,7 +699,7 @@ void Script::o_hotspot_left() { void Script::o_hotspot_right() { uint16 address = readScript16bits(); - debugScript(5, true, "HOTSPOT-RIGHT @0x%04X", address); + debugC(5, kDebugScript, "HOTSPOT-RIGHT @0x%04X", address); // Mark the rightmost 100 pixels of the game area Common::Rect rect(540, 80, 640, 400); @@ -730,7 +709,7 @@ void Script::o_hotspot_right() { void Script::o_hotspot_center() { uint16 address = readScript16bits(); - debugScript(5, true, "HOTSPOT-CENTER @0x%04X", address); + debugC(5, kDebugScript, "HOTSPOT-CENTER @0x%04X", address); // Mark the centermost 240 pixels of the game area Common::Rect rect(200, 80, 440, 400); @@ -740,7 +719,7 @@ void Script::o_hotspot_center() { void Script::o_hotspot_current() { uint16 address = readScript16bits(); - debugScript(5, true, "HOTSPOT-CURRENT @0x%04X", address); + debugC(5, kDebugScript, "HOTSPOT-CURRENT @0x%04X", address); // The original interpreter doesn't check the position, so accept the // whole screen @@ -749,7 +728,7 @@ void Script::o_hotspot_current() { } void Script::o_inputloopend() { - debugScript(5, true, "Input loop end"); + debugC(5, kDebugScript, "Input loop end"); // Handle the predefined hotspots if (_hotspotTopAction) { @@ -802,7 +781,7 @@ void Script::o_random() { uint16 varnum = readScript8or16bits(); uint8 maxnum = readScript8bits(); - debugScript(1, true, "RANDOM: var[0x%04X] = rand(%d)", varnum, maxnum); + debugC(1, kDebugScript, "RANDOM: var[0x%04X] = rand(%d)", varnum, maxnum); setVariable(varnum, _random.getRandomNumber(maxnum)); } @@ -810,7 +789,7 @@ void Script::o_random() { void Script::o_jmp() { uint16 address = readScript16bits(); - debugScript(1, true, "JMP @0x%04X", address); + debugC(1, kDebugScript, "JMP @0x%04X", address); // Set the current address _currentInstruction = address; @@ -819,18 +798,18 @@ void Script::o_jmp() { void Script::o_loadstring() { uint16 varnum = readScript8or16bits(); - debugScript(1, false, "LOADSTRING var[0x%04X..] =", varnum); + debugCN(1, kDebugScript, "LOADSTRING var[0x%04X..] =", varnum); do { setVariable(varnum++, readScriptChar(true, true, true)); - debugScript(1, false, " 0x%02X", _variables[varnum - 1]); + debugCN(1, kDebugScript, " 0x%02X", _variables[varnum - 1]); } while (!(getCodeByte(_currentInstruction - 1) & 0x80)); - debugScript(1, false, "\n"); + debugCN(1, kDebugScript, "\n"); } void Script::o_ret() { uint8 val = readScript8bits(); - debugScript(1, true, "RET %d", val); + debugC(1, kDebugScript, "RET %d", val); // Set the return value setVariable(0x102, val); @@ -847,7 +826,7 @@ void Script::o_ret() { void Script::o_call() { uint16 address = readScript16bits(); - debugScript(1, true, "CALL @0x%04X", address); + debugC(1, kDebugScript, "CALL @0x%04X", address); // Save return address in the call stack _stack[_stacktop] = _currentInstruction; @@ -860,7 +839,7 @@ void Script::o_call() { void Script::o_sleep() { uint16 time = readScript16bits(); - debugScript(1, true, "SLEEP 0x%04X", time); + debugC(1, kDebugScript, "SLEEP 0x%04X", time); _vm->_system->delayMillis(time * 3); } @@ -869,7 +848,7 @@ void Script::o_strcmpnejmp() { // 0x1A uint16 varnum = readScript8or16bits(); uint8 result = 1; - debugScript(1, false, "STRCMP-NEJMP: var[0x%04X..],", varnum); + debugCN(1, kDebugScript, "STRCMP-NEJMP: var[0x%04X..],", varnum); do { uint8 val = readScriptChar(true, true, true); @@ -878,33 +857,33 @@ void Script::o_strcmpnejmp() { // 0x1A result = 0; } varnum++; - debugScript(1, false, " 0x%02X", val); + debugCN(1, kDebugScript, " 0x%02X", val); } while (!(getCodeByte(_currentInstruction - 1) & 0x80)); uint16 address = readScript16bits(); if (!result) { - debugScript(1, true, " jumping to @0x%04X", address); + debugC(1, kDebugScript, " jumping to @0x%04X", address); _currentInstruction = address; } else { - debugScript(1, true, " not jumping"); + debugC(1, kDebugScript, " not jumping"); } } void Script::o_xor_obfuscate() { uint16 varnum = readScript8or16bits(); - debugScript(1, false, "XOR OBFUSCATE: var[0x%04X..] = ", varnum); + debugCN(1, kDebugScript, "XOR OBFUSCATE: var[0x%04X..] = ", varnum); do { uint8 val = readScript8bits(); _firstbit = ((val & 0x80) != 0); val &= 0x4F; setVariable(varnum, _variables[varnum] ^ val); - debugScript(1, false, "%c", _variables[varnum]); + debugCN(1, kDebugScript, "%c", _variables[varnum]); varnum++; } while (!_firstbit); - debugScript(1, false, "\n"); + debugCN(1, kDebugScript, "\n"); } void Script::o_vdxtransition() { // 0x1C @@ -912,8 +891,8 @@ void Script::o_vdxtransition() { // 0x1C // Show the debug information just when starting the playback if (fileref != _videoRef) { - debugScript(1, true, "VDX transition fileref = 0x%04X", fileref); - debugC(1, kGroovieDebugVideo | kGroovieDebugAll, "Playing video 0x%04X with transition", fileref); + debugC(1, kDebugScript, "VDX transition fileref = 0x%04X", fileref); + debugC(1, kDebugVideo, "Playing video 0x%04X with transition", fileref); } // Set bit 1 @@ -938,7 +917,7 @@ void Script::o_swap() { uint16 varnum1 = readScript8or16bits(); uint16 varnum2 = readScript16bits(); - debugScript(1, true, "SWAP var[0x%04X] <-> var[0x%04X]", varnum1, varnum2); + debugC(1, kDebugScript, "SWAP var[0x%04X] <-> var[0x%04X]", varnum1, varnum2); uint8 tmp = _variables[varnum1]; setVariable(varnum1, _variables[varnum2]); @@ -948,7 +927,7 @@ void Script::o_swap() { void Script::o_inc() { uint16 varnum = readScript8or16bits(); - debugScript(1, true, "INC var[0x%04X]", varnum); + debugC(1, kDebugScript, "INC var[0x%04X]", varnum); setVariable(varnum, _variables[varnum] + 1); } @@ -956,7 +935,7 @@ void Script::o_inc() { void Script::o_dec() { uint16 varnum = readScript8or16bits(); - debugScript(1, true, "DEC var[0x%04X]", varnum); + debugC(1, kDebugScript, "DEC var[0x%04X]", varnum); setVariable(varnum, _variables[varnum] - 1); } @@ -982,7 +961,7 @@ void Script::o_strcmpnejmp_var() { // 0x21 } void Script::o_copybgtofg() { // 0x22 - debugScript(1, true, "COPY_BG_TO_FG"); + debugC(1, kDebugScript, "COPY_BG_TO_FG"); memcpy(_vm->_graphicsMan->_foreground.getPixels(), _vm->_graphicsMan->_background.getPixels(), 640 * 320); } @@ -990,7 +969,7 @@ void Script::o_strcmpeqjmp() { // 0x23 uint16 varnum = readScript8or16bits(); uint8 result = 1; - debugScript(1, false, "STRCMP-EQJMP: var[0x%04X..],", varnum); + debugCN(1, kDebugScript, "STRCMP-EQJMP: var[0x%04X..],", varnum); do { uint8 val = readScriptChar(true, true, true); @@ -998,15 +977,15 @@ void Script::o_strcmpeqjmp() { // 0x23 result = 0; } varnum++; - debugScript(1, false, " 0x%02X", val); + debugCN(1, kDebugScript, " 0x%02X", val); } while (!(getCodeByte(_currentInstruction - 1) & 0x80)); uint16 address = readScript16bits(); if (result) { - debugScript(1, true, " jumping to @0x%04X", address); + debugC(1, kDebugScript, " jumping to @0x%04X", address); _currentInstruction = address; } else { - debugScript(1, true, " not jumping"); + debugC(1, kDebugScript, " not jumping"); } } @@ -1014,7 +993,7 @@ void Script::o_mov() { uint16 varnum1 = readScript8or16bits(); uint16 varnum2 = readScript16bits(); - debugScript(1, true, "MOV var[0x%04X] = var[0x%04X]", varnum1, varnum2); + debugC(1, kDebugScript, "MOV var[0x%04X] = var[0x%04X]", varnum1, varnum2); setVariable(varnum1, _variables[varnum2]); } @@ -1023,7 +1002,7 @@ void Script::o_add() { uint16 varnum1 = readScript8or16bits(); uint16 varnum2 = readScript16bits(); - debugScript(1, true, "ADD var[0x%04X] += var[0x%04X]", varnum1, varnum2); + debugC(1, kDebugScript, "ADD var[0x%04X] += var[0x%04X]", varnum1, varnum2); setVariable(varnum1, _variables[varnum1] + _variables[varnum2]); } @@ -1034,7 +1013,7 @@ void Script::o_videofromstring1() { // Show the debug information just when starting the playback if (fileref != _videoRef) { - debugScript(0, true, "VIDEOFROMSTRING1 0x%04X", fileref); + debugC(0, kDebugScript, "VIDEOFROMSTRING1 0x%04X", fileref); } // Play the video @@ -1050,7 +1029,7 @@ void Script::o_videofromstring2() { // Show the debug information just when starting the playback if (fileref != _videoRef) { - debugScript(0, true, "VIDEOFROMSTRING2 0x%04X", fileref); + debugC(0, kDebugScript, "VIDEOFROMSTRING2 0x%04X", fileref); } // Set bit 1 @@ -1069,11 +1048,11 @@ void Script::o_videofromstring2() { } void Script::o_stopmidi() { - debugScript(1, true, "STOPMIDI (TODO)"); + debugC(1, kDebugScript, "STOPMIDI (TODO)"); } void Script::o_endscript() { - debugScript(1, true, "END OF SCRIPT"); + debugC(1, kDebugScript, "END OF SCRIPT"); _vm->quitGame(); } @@ -1081,7 +1060,7 @@ void Script::o_sethotspottop() { uint16 address = readScript16bits(); uint8 cursor = readScript8bits(); - debugScript(5, true, "SETHOTSPOTTOP @0x%04X cursor=%d", address, cursor); + debugC(5, kDebugScript, "SETHOTSPOTTOP @0x%04X cursor=%d", address, cursor); _hotspotTopAction = address; _hotspotTopCursor = cursor; @@ -1091,7 +1070,7 @@ void Script::o_sethotspotbottom() { uint16 address = readScript16bits(); uint8 cursor = readScript8bits(); - debugScript(5, true, "SETHOTSPOTBOTTOM @0x%04X cursor=%d", address, cursor); + debugC(5, kDebugScript, "SETHOTSPOTBOTTOM @0x%04X cursor=%d", address, cursor); _hotspotBottomAction = address; _hotspotBottomCursor = cursor; @@ -1101,7 +1080,7 @@ void Script::o_loadgame() { uint16 varnum = readScript8or16bits(); uint8 slot = _variables[varnum]; - debugScript(1, true, "LOADGAME var[0x%04X] -> slot=%d (TODO)", varnum, slot); + debugC(1, kDebugScript, "LOADGAME var[0x%04X] -> slot=%d (TODO)", varnum, slot); loadgame(slot); _vm->_system->fillScreen(0); @@ -1111,7 +1090,7 @@ void Script::o_savegame() { uint16 varnum = readScript8or16bits(); uint8 slot = _variables[varnum]; - debugScript(1, true, "SAVEGAME var[0x%04X] -> slot=%d (TODO)", varnum, slot); + debugC(1, kDebugScript, "SAVEGAME var[0x%04X] -> slot=%d (TODO)", varnum, slot); savegame(slot); } @@ -1119,7 +1098,7 @@ void Script::o_savegame() { void Script::o_hotspotbottom_4() { //0x30 uint16 address = readScript16bits(); - debugScript(5, true, "HOTSPOT-BOTTOM @0x%04X", address); + debugC(5, kDebugScript, "HOTSPOT-BOTTOM @0x%04X", address); // Mark the 80 pixels under the game area Common::Rect rect(0, 400, 640, 480); @@ -1130,7 +1109,7 @@ void Script::o_midivolume() { uint16 arg1 = readScript16bits(); uint16 arg2 = readScript16bits(); - debugScript(1, true, "MIDI volume: %d %d", arg1, arg2); + debugC(1, kDebugScript, "MIDI volume: %d %d", arg1, arg2); _vm->_musicPlayer->setGameVolume(arg1, arg2); } @@ -1139,13 +1118,13 @@ void Script::o_jne() { uint16 varnum2 = readScript16bits(); uint16 address = readScript16bits(); - debugScript(1, false, "JNE: var[var[0x%04X] - 0x31] != var[0x%04X] @0x%04X", varnum1, varnum2, address); + debugCN(1, kDebugScript, "JNE: var[var[0x%04X] - 0x31] != var[0x%04X] @0x%04X", varnum1, varnum2, address); if (_variables[_variables[varnum1] - 0x31] != _variables[varnum2]) { _currentInstruction = address; - debugScript(1, true, " jumping to @0x%04X", address); + debugC(1, kDebugScript, " jumping to @0x%04X", address); } else { - debugScript(1, true, " not jumping"); + debugC(1, kDebugScript, " not jumping"); } } @@ -1153,19 +1132,19 @@ void Script::o_loadstringvar() { uint16 varnum = readScript8or16bits(); varnum = _variables[varnum] - 0x31; - debugScript(1, false, "LOADSTRINGVAR var[0x%04X..] =", varnum); + debugCN(1, kDebugScript, "LOADSTRINGVAR var[0x%04X..] =", varnum); do { setVariable(varnum++, readScriptChar(true, true, true)); - debugScript(1, false, " 0x%02X", _variables[varnum - 1]); + debugCN(1, kDebugScript, " 0x%02X", _variables[varnum - 1]); } while (!(getCodeByte(_currentInstruction - 1) & 0x80)); - debugScript(1, false, "\n"); + debugCN(1, kDebugScript, "\n"); } void Script::o_chargreatjmp() { uint16 varnum = readScript8or16bits(); uint8 result = 0; - debugScript(1, false, "CHARGREAT-JMP: var[0x%04X..],", varnum); + debugCN(1, kDebugScript, "CHARGREAT-JMP: var[0x%04X..],", varnum); do { uint8 val = readScriptChar(true, true, true); @@ -1173,20 +1152,20 @@ void Script::o_chargreatjmp() { result = 1; } varnum++; - debugScript(1, false, " 0x%02X", val); + debugCN(1, kDebugScript, " 0x%02X", val); } while (!(getCodeByte(_currentInstruction - 1) & 0x80)); uint16 address = readScript16bits(); if (result) { - debugScript(1, true, " jumping to @0x%04X", address); + debugC(1, kDebugScript, " jumping to @0x%04X", address); _currentInstruction = address; } else { - debugScript(1, true, " not jumping"); + debugC(1, kDebugScript, " not jumping"); } } void Script::o_bf7off() { - debugScript(1, true, "BF7OFF: bitflag 7 turned off"); + debugC(1, kDebugScript, "BF7OFF: bitflag 7 turned off"); _bitflags &= ~(1 << 7); } @@ -1194,7 +1173,7 @@ void Script::o_charlessjmp() { uint16 varnum = readScript8or16bits(); uint8 result = 0; - debugScript(1, false, "CHARLESS-JMP: var[0x%04X..],", varnum); + debugCN(1, kDebugScript, "CHARLESS-JMP: var[0x%04X..],", varnum); do { uint8 val = readScriptChar(true, true, true); @@ -1202,15 +1181,15 @@ void Script::o_charlessjmp() { result = 1; } varnum++; - debugScript(1, false, " 0x%02X", val); + debugCN(1, kDebugScript, " 0x%02X", val); } while (!(getCodeByte(_currentInstruction - 1) & 0x80)); uint16 address = readScript16bits(); if (result) { - debugScript(1, true, " jumping to @0x%04X", address); + debugC(1, kDebugScript, " jumping to @0x%04X", address); _currentInstruction = address; } else { - debugScript(1, true, " not jumping"); + debugC(1, kDebugScript, " not jumping"); } } @@ -1219,11 +1198,50 @@ void Script::o_copyrecttobg() { // 0x37 uint16 top = readScript16bits(); uint16 right = readScript16bits(); uint16 bottom = readScript16bits(); + + // Sanity checks to prevent bad pointer access crashes + if (left > right) { + warning("COPYRECT left:%d > right:%d", left, right); + // swap over left and right parameters + uint16 j; + j = right; + right = left; + left = j; + } + if (top > bottom) { + warning("COPYRECT top:%d > bottom:%d", top, bottom); + // swap over top and bottom parameters + uint16 j; + j = bottom; + bottom = top; + top = j; + } + if (top < 80) { + warning("COPYRECT top < 80... clamping"); + top = 80; + } + if (top >= 480) { + warning("COPYRECT top >= 480... clamping"); + top = 480 - 1; + } + if (bottom >= 480) { + warning("COPYRECT bottom >= 480... clamping"); + bottom = 480 - 1; + } + if (left >= 640) { + warning("COPYRECT left >= 640... clamping"); + left = 640 - 1; + } + if (right >= 640) { + warning("COPYRECT right >= 640... clamping"); + right = 640 - 1; + } + uint16 i, width = right - left, height = bottom - top; uint32 offset = 0; byte *fg, *bg; - debugScript(1, true, "COPYRECT((%d,%d)->(%d,%d))", left, top, right, bottom); + debugC(1, kDebugScript, "COPYRECT((%d,%d)->(%d,%d))", left, top, right, bottom); fg = (byte *)_vm->_graphicsMan->_foreground.getBasePtr(left, top - 80); bg = (byte *)_vm->_graphicsMan->_background.getBasePtr(left, top - 80); @@ -1236,13 +1254,13 @@ void Script::o_copyrecttobg() { // 0x37 } void Script::o_restorestkpnt() { - debugScript(1, true, "Restore stack pointer from saved (TODO)"); + debugC(1, kDebugScript, "Restore stack pointer from saved (TODO)"); } void Script::o_obscureswap() { uint16 var1, var2, tmp; - debugScript(1, true, "OBSCSWAP"); + debugC(1, kDebugScript, "OBSCSWAP"); // Read the first variable var1 = readScriptChar(false, true, true) * 10; @@ -1262,7 +1280,7 @@ void Script::o_printstring() { char stringstorage[15]; uint8 counter = 0; - debugScript(1, true, "PRINTSTRING"); + debugC(1, kDebugScript, "PRINTSTRING"); memset(stringstorage, 0, 15); do { @@ -1300,7 +1318,7 @@ void Script::o_hotspot_slot() { uint16 address = readScript16bits(); uint16 cursor = readScript8bits(); - debugScript(1, true, "HOTSPOT-SLOT %d (%d,%d,%d,%d) @0x%04X cursor=%d (TODO)", slot, left, top, right, bottom, address, cursor); + debugC(1, kDebugScript, "HOTSPOT-SLOT %d (%d,%d,%d,%d) @0x%04X cursor=%d (TODO)", slot, left, top, right, bottom, address, cursor); Common::Rect rect(left, top, right, bottom); if (hotspot(rect, address, cursor)) { @@ -1338,7 +1356,7 @@ void Script::o_hotspot_slot() { } void Script::o_checkvalidsaves() { - debugScript(1, true, "CHECKVALIDSAVES"); + debugC(1, kDebugScript, "CHECKVALIDSAVES"); // Reset the array of valid saves and the savegame names cache for (int i = 0; i < 10; i++) { @@ -1355,7 +1373,7 @@ void Script::o_checkvalidsaves() { while (it != list.end()) { int8 slot = it->getSaveSlot(); if (SaveLoad::isSlotValid(slot)) { - debugScript(2, true, " Found valid savegame: %s", it->getDescription().c_str()); + debugC(2, kDebugScript, " Found valid savegame: %s", it->getDescription().c_str()); // Mark this slot as used setVariable(slot, 1); @@ -1369,11 +1387,11 @@ void Script::o_checkvalidsaves() { // Save the number of valid saves setVariable(0x104, count); - debugScript(1, true, " Found %d valid savegames", count); + debugC(1, kDebugScript, " Found %d valid savegames", count); } void Script::o_resetvars() { - debugScript(1, true, "RESETVARS"); + debugC(1, kDebugScript, "RESETVARS"); for (int i = 0; i < 0x100; i++) { setVariable(i, 0); } @@ -1383,7 +1401,7 @@ void Script::o_mod() { uint16 varnum = readScript8or16bits(); uint8 val = readScript8bits(); - debugScript(1, true, "MOD var[0x%04X] %%= %d", varnum, val); + debugC(1, kDebugScript, "MOD var[0x%04X] %%= %d", varnum, val); setVariable(varnum, _variables[varnum] % val); } @@ -1395,7 +1413,7 @@ void Script::o_loadscript() { while ((c = readScript8bits())) { filename += c; } - debugScript(1, true, "LOADSCRIPT %s", filename.c_str()); + debugC(1, kDebugScript, "LOADSCRIPT %s", filename.c_str()); // Just 1 level of sub-scripts are allowed if (_savedCode) { @@ -1430,7 +1448,7 @@ void Script::o_setvideoorigin() { // Set bitflag 7 _bitflags |= 1 << 7; - debugScript(1, true, "SetVideoOrigin(0x%04X,0x%04X) (%d, %d)", origX, origY, origX, origY); + debugC(1, kDebugScript, "SetVideoOrigin(0x%04X,0x%04X) (%d, %d)", origX, origY, origX, origY); _vm->_videoPlayer->setOrigin(origX, origY); } @@ -1438,7 +1456,7 @@ void Script::o_sub() { uint16 varnum1 = readScript8or16bits(); uint16 varnum2 = readScript16bits(); - debugScript(1, true, "SUB var[0x%04X] -= var[0x%04X]", varnum1, varnum2); + debugC(1, kDebugScript, "SUB var[0x%04X] -= var[0x%04X]", varnum1, varnum2); setVariable(varnum1, _variables[varnum1] - _variables[varnum2]); } @@ -1448,7 +1466,7 @@ void Script::o_cellmove() { byte *scriptBoard = &_variables[0x19]; byte startX, startY, endX, endY; - debugScript(1, true, "CELL MOVE var[0x%02X]", depth); + debugC(1, kDebugScript, "CELL MOVE var[0x%02X]", depth); if (!_staufsMove) _staufsMove = new CellGame; @@ -1471,7 +1489,7 @@ void Script::o_cellmove() { void Script::o_returnscript() { uint8 val = readScript8bits(); - debugScript(1, true, "RETURNSCRIPT @0x%02X", val); + debugC(1, kDebugScript, "RETURNSCRIPT @0x%02X", val); // Are we returning from a sub-script? if (!_savedCode) { @@ -1504,7 +1522,7 @@ void Script::o_returnscript() { void Script::o_sethotspotright() { uint16 address = readScript16bits(); - debugScript(1, true, "SETHOTSPOTRIGHT @0x%04X", address); + debugC(1, kDebugScript, "SETHOTSPOTRIGHT @0x%04X", address); _hotspotRightAction = address; } @@ -1512,13 +1530,13 @@ void Script::o_sethotspotright() { void Script::o_sethotspotleft() { uint16 address = readScript16bits(); - debugScript(1, true, "SETHOTSPOTLEFT @0x%04X", address); + debugC(1, kDebugScript, "SETHOTSPOTLEFT @0x%04X", address); _hotspotLeftAction = address; } void Script::o_getcd() { - debugScript(1, true, "GETCD"); + debugC(1, kDebugScript, "GETCD"); // By default set it to no CD available int8 cd = -1; @@ -1545,7 +1563,7 @@ void Script::o_getcd() { void Script::o_playcd() { uint8 val = readScript8bits(); - debugScript(1, true, "PLAYCD %d", val); + debugC(1, kDebugScript, "PLAYCD %d", val); if (val == 2) { // TODO: Play the alternative logo @@ -1557,7 +1575,7 @@ void Script::o_playcd() { void Script::o_musicdelay() { uint16 delay = readScript16bits(); - debugScript(1, true, "MUSICDELAY %d", delay); + debugC(1, kDebugScript, "MUSICDELAY %d", delay); _vm->_musicPlayer->setBackgroundDelay(delay); } @@ -1569,7 +1587,7 @@ void Script::o_hotspot_outrect() { uint16 bottom = readScript16bits(); uint16 address = readScript16bits(); - debugScript(1, true, "HOTSPOT-OUTRECT(%d,%d,%d,%d) @0x%04X (TODO)", left, top, right, bottom, address); + debugC(1, kDebugScript, "HOTSPOT-OUTRECT(%d,%d,%d,%d) @0x%04X (TODO)", left, top, right, bottom, address); // Test if the current mouse position is outside the specified rectangle Common::Rect rect(left, top, right, bottom); @@ -1587,25 +1605,25 @@ void Script::o_stub56() { uint8 val2 = readScript8bits(); uint8 val3 = readScript8bits(); - debugScript(1, true, "STUB56: 0x%08X 0x%02X 0x%02X", val1, val2, val3); + debugC(1, kDebugScript, "STUB56: 0x%08X 0x%02X 0x%02X", val1, val2, val3); } void Script::o_stub59() { uint16 val1 = readScript8or16bits(); uint8 val2 = readScript8bits(); - debugScript(1, true, "STUB59: 0x%04X 0x%02X", val1, val2); + debugC(1, kDebugScript, "STUB59: 0x%04X 0x%02X", val1, val2); } void Script::o2_playsong() { uint32 fileref = readScript32bits(); - debugScript(1, true, "PlaySong(0x%08X): Play xmidi file", fileref); + debugC(1, kDebugScript, "PlaySong(0x%08X): Play xmidi file", fileref); _vm->_musicPlayer->playSong(fileref); } void Script::o2_setbackgroundsong() { uint32 fileref = readScript32bits(); - debugScript(1, true, "SetBackgroundSong(0x%08X)", fileref); + debugC(1, kDebugScript, "SetBackgroundSong(0x%08X)", fileref); _vm->_musicPlayer->setBackgroundSong(fileref); } @@ -1614,8 +1632,8 @@ void Script::o2_videofromref() { // Show the debug information just when starting the playback if (fileref != _videoRef) { - debugScript(1, true, "VIDEOFROMREF(0x%08X) (Not fully imp): Play video file from ref", fileref); - debugC(5, kGroovieDebugVideo | kGroovieDebugAll, "Playing video 0x%08X via 0x09", fileref); + debugC(1, kDebugScript, "VIDEOFROMREF(0x%08X) (Not fully imp): Play video file from ref", fileref); + debugC(5, kDebugVideo, "Playing video 0x%08X via 0x09", fileref); } // Play the video @@ -1630,8 +1648,8 @@ void Script::o2_vdxtransition() { // Show the debug information just when starting the playback if (fileref != _videoRef) { - debugScript(1, true, "VDX transition fileref = 0x%08X", fileref); - debugC(1, kGroovieDebugVideo | kGroovieDebugAll, "Playing video 0x%08X with transition", fileref); + debugC(1, kDebugScript, "VDX transition fileref = 0x%08X", fileref); + debugC(1, kDebugVideo, "Playing video 0x%08X with transition", fileref); } // Set bit 1 @@ -1652,30 +1670,30 @@ void Script::o2_vdxtransition() { void Script::o2_copyscreentobg() { uint16 val = readScript16bits(); - debugScript(1, true, "CopyScreenToBG3: 0x%04X", val); + debugC(1, kDebugScript, "CopyScreenToBG3: 0x%04X", val); error("Unimplemented Opcode 0x4F"); } void Script::o2_copybgtoscreen() { uint16 val = readScript16bits(); - debugScript(1, true, "CopyBG3ToScreen: 0x%04X", val); + debugC(1, kDebugScript, "CopyBG3ToScreen: 0x%04X", val); error("Unimplemented Opcode 0x50"); } void Script::o2_setvideoskip() { _videoSkipAddress = readScript16bits(); - debugScript(1, true, "SetVideoSkip (0x%04X)", _videoSkipAddress); + debugC(1, kDebugScript, "SetVideoSkip (0x%04X)", _videoSkipAddress); } void Script::o2_stub52() { uint8 arg = readScript8bits(); - debugScript(1, true, "STUB52 (0x%02X)", arg); + debugC(1, kDebugScript, "STUB52 (0x%02X)", arg); } void Script::o2_setscriptend() { uint16 arg = readScript16bits(); - debugScript(1, true, "SetScriptEnd (0x%04X)", arg); + debugC(1, kDebugScript, "SetScriptEnd (0x%04X)", arg); } Script::OpcodeFunc Script::_opcodesT7G[NUM_OPCODES] = { diff --git a/engines/groovie/script.h b/engines/groovie/script.h index 8cd790af5e..35e52593de 100644 --- a/engines/groovie/script.h +++ b/engines/groovie/script.h @@ -8,12 +8,12 @@ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/engines/groovie/stuffit.cpp b/engines/groovie/stuffit.cpp index 60a57a0129..bbfcd3da82 100644 --- a/engines/groovie/stuffit.cpp +++ b/engines/groovie/stuffit.cpp @@ -8,12 +8,12 @@ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/engines/groovie/stuffit.h b/engines/groovie/stuffit.h index 44f593dbea..9b2bbd3543 100644 --- a/engines/groovie/stuffit.h +++ b/engines/groovie/stuffit.h @@ -8,12 +8,12 @@ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/engines/groovie/vdx.cpp b/engines/groovie/vdx.cpp index 59d966a22f..09c2e0d3ea 100644 --- a/engines/groovie/vdx.cpp +++ b/engines/groovie/vdx.cpp @@ -8,12 +8,12 @@ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -56,8 +56,7 @@ void VDXPlayer::setOrigin(int16 x, int16 y) { } uint16 VDXPlayer::loadInternal() { - if (DebugMan.isDebugChannelEnabled(kGroovieDebugVideo) || - DebugMan.isDebugChannelEnabled(kGroovieDebugAll)) { + if (DebugMan.isDebugChannelEnabled(kDebugVideo)) { int8 i; debugN(1, "Groovie::VDX: New VDX: bitflags are "); for (i = 15; i >= 0; i--) { @@ -106,24 +105,24 @@ uint16 VDXPlayer::loadInternal() { //_flagUpdateStill = _flagNine || _flagSix; // Begin reading the file - debugC(1, kGroovieDebugVideo | kGroovieDebugAll, "Groovie::VDX: Playing video"); + debugC(1, kDebugVideo, "Groovie::VDX: Playing video"); if (_file->readUint16LE() != VDX_IDENT) { error("Groovie::VDX: This does not appear to be a 7th guest VDX file"); return 0; } else { - debugC(5, kGroovieDebugVideo | kGroovieDebugAll, "Groovie::VDX: VDX file identified correctly"); + debugC(5, kDebugVideo, "Groovie::VDX: VDX file identified correctly"); } uint16 tmp; // Skip unknown data: 6 bytes, ref Martine tmp = _file->readUint16LE(); - debugC(2, kGroovieDebugVideo | kGroovieDebugUnknown | kGroovieDebugAll, "Groovie::VDX: Martine1 = 0x%04X", tmp); + debugC(2, kDebugVideo | kDebugUnknown, "Groovie::VDX: Martine1 = 0x%04X", tmp); tmp = _file->readUint16LE(); - debugC(2, kGroovieDebugVideo | kGroovieDebugUnknown | kGroovieDebugAll, "Groovie::VDX: Martine2 = 0x%04X", tmp); + debugC(2, kDebugVideo | kDebugUnknown, "Groovie::VDX: Martine2 = 0x%04X", tmp); tmp = _file->readUint16LE(); - debugC(2, kGroovieDebugVideo | kGroovieDebugUnknown | kGroovieDebugAll, "Groovie::VDX: Martine3 (FPS?) = %d", tmp); + debugC(2, kDebugVideo | kDebugUnknown, "Groovie::VDX: Martine3 (FPS?) = %d", tmp); return tmp; } @@ -144,7 +143,7 @@ bool VDXPlayer::playFrameInternal() { if (_file->eos()) break; - debugC(5, kGroovieDebugVideo | kGroovieDebugUnknown | kGroovieDebugAll, "Groovie::VDX: Edward = 0x%04X", tmp); + debugC(5, kDebugVideo | kDebugUnknown, "Groovie::VDX: Edward = 0x%04X", tmp); // Read the chunk data and decompress if needed if (compSize) @@ -159,18 +158,18 @@ bool VDXPlayer::playFrameInternal() { // Use the current chunk switch (currRes) { case 0x00: - debugC(6, kGroovieDebugVideo | kGroovieDebugAll, "Groovie::VDX: Replay frame"); + debugC(6, kDebugVideo, "Groovie::VDX: Replay frame"); break; case 0x20: - debugC(5, kGroovieDebugVideo | kGroovieDebugAll, "Groovie::VDX: Still frame"); + debugC(5, kDebugVideo, "Groovie::VDX: Still frame"); getStill(vdxData); break; case 0x25: - debugC(5, kGroovieDebugVideo | kGroovieDebugAll, "Groovie::VDX: Animation frame"); + debugC(5, kDebugVideo, "Groovie::VDX: Animation frame"); getDelta(vdxData); break; case 0x80: - debugC(5, kGroovieDebugVideo | kGroovieDebugAll, "Groovie::VDX: Sound resource"); + debugC(5, kDebugVideo, "Groovie::VDX: Sound resource"); chunkSound(vdxData); break; default: @@ -182,7 +181,7 @@ bool VDXPlayer::playFrameInternal() { // Wait until the current frame can be shown - if (!DebugMan.isDebugChannelEnabled(kGroovieDebugFast)) { + if (!DebugMan.isDebugChannelEnabled(kDebugFast)) { waitFrame(); } // TODO: Move it to a better place @@ -344,13 +343,13 @@ void VDXPlayer::getDelta(Common::ReadStream *in) { void VDXPlayer::getStill(Common::ReadStream *in) { uint16 numXTiles = in->readUint16LE(); - debugC(5, kGroovieDebugVideo | kGroovieDebugAll, "Groovie::VDX: numXTiles=%d", numXTiles); + debugC(5, kDebugVideo, "Groovie::VDX: numXTiles=%d", numXTiles); uint16 numYTiles = in->readUint16LE(); - debugC(5, kGroovieDebugVideo | kGroovieDebugAll, "Groovie::VDX: numYTiles=%d", numYTiles); + debugC(5, kDebugVideo, "Groovie::VDX: numYTiles=%d", numYTiles); // It's skipped in the original: uint16 colorDepth = in->readUint16LE(); - debugC(5, kGroovieDebugVideo | kGroovieDebugAll, "Groovie::VDX: colorDepth=%d", colorDepth); + debugC(5, kDebugVideo, "Groovie::VDX: colorDepth=%d", colorDepth); uint16 imageWidth = TILE_SIZE * numXTiles; @@ -423,7 +422,7 @@ void VDXPlayer::getStill(Common::ReadStream *in) { */ } else { // Skip the remaining data - debugC(10, kGroovieDebugVideo | kGroovieDebugAll, "Groovie::VDX: Skipping still frame"); + debugC(10, kDebugVideo, "Groovie::VDX: Skipping still frame"); while (!in->eos()) { in->readByte(); } @@ -538,7 +537,7 @@ void VDXPlayer::chunkSound(Common::ReadStream *in) { byte *data = (byte *)malloc(60000); int chunksize = in->read(data, 60000); - if (!DebugMan.isDebugChannelEnabled(kGroovieDebugFast)) { + if (!DebugMan.isDebugChannelEnabled(kDebugFast)) { _audioStream->queueBuffer(data, chunksize, DisposeAfterUse::YES, Audio::FLAG_UNSIGNED); } } @@ -563,7 +562,7 @@ void VDXPlayer::setPalette(uint8 *palette) { if (_flagSkipPalette) return; - debugC(7, kGroovieDebugVideo | kGroovieDebugAll, "Groovie::VDX: Setting palette"); + debugC(7, kDebugVideo, "Groovie::VDX: Setting palette"); _syst->getPaletteManager()->setPalette(palette, 0, 256); } diff --git a/engines/groovie/vdx.h b/engines/groovie/vdx.h index a9bfaa1eb4..328e6e4da5 100644 --- a/engines/groovie/vdx.h +++ b/engines/groovie/vdx.h @@ -8,12 +8,12 @@ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |