diff options
Diffstat (limited to 'engines/teenagent')
-rw-r--r-- | engines/teenagent/actor.cpp | 6 | ||||
-rw-r--r-- | engines/teenagent/animation.cpp | 36 | ||||
-rw-r--r-- | engines/teenagent/callbacks.cpp | 18 | ||||
-rw-r--r-- | engines/teenagent/dialog.cpp | 12 | ||||
-rw-r--r-- | engines/teenagent/font.cpp | 12 | ||||
-rw-r--r-- | engines/teenagent/inventory.cpp | 35 | ||||
-rw-r--r-- | engines/teenagent/music.cpp | 19 | ||||
-rw-r--r-- | engines/teenagent/objects.cpp | 10 | ||||
-rw-r--r-- | engines/teenagent/objects.h | 4 | ||||
-rw-r--r-- | engines/teenagent/pack.cpp | 19 | ||||
-rw-r--r-- | engines/teenagent/scene.cpp | 118 | ||||
-rw-r--r-- | engines/teenagent/scene.h | 4 | ||||
-rw-r--r-- | engines/teenagent/surface.cpp | 10 | ||||
-rw-r--r-- | engines/teenagent/surface_list.cpp | 7 | ||||
-rw-r--r-- | engines/teenagent/surface_list.h | 1 | ||||
-rw-r--r-- | engines/teenagent/teenagent.cpp | 47 | ||||
-rw-r--r-- | engines/teenagent/teenagent.h | 25 |
17 files changed, 213 insertions, 170 deletions
diff --git a/engines/teenagent/actor.cpp b/engines/teenagent/actor.cpp index f9bf4c84ab..ef0ca32cf6 100644 --- a/engines/teenagent/actor.cpp +++ b/engines/teenagent/actor.cpp @@ -35,7 +35,7 @@ Actor::Actor(TeenAgentEngine *vm) : _vm(vm), head_index(0), idle_type(0) {} Common::Rect Actor::renderIdle(Graphics::Surface *surface, const Common::Point &position, uint8 orientation, int delta_frame, uint zoom, Common::RandomSource &rnd) { if (index == 0) { idle_type = rnd.getRandomNumber(2); - debug(0, "switched to idle animation %u", idle_type); + debugC(kDebugActor, "switched to idle animation %u", idle_type); } byte *frames_idle; @@ -44,7 +44,7 @@ Common::Rect Actor::renderIdle(Graphics::Surface *surface, const Common::Point & index += delta_frame; if (*frames_idle == 0) { idle_type = rnd.getRandomNumber(2); - debug(0, "switched to idle animation %u[loop]", idle_type); + debugC(kDebugActor, "switched to idle animation %u[loop]", idle_type); index = 3; //put 4th frame (base 1) if idle animation loops } } while (*frames_idle == 0); @@ -52,7 +52,7 @@ Common::Rect Actor::renderIdle(Graphics::Surface *surface, const Common::Point & bool mirror = orientation == kActorLeft; Surface *s = frames + *frames_idle - 1; - ///\todo remove copy-paste here and below + //TODO: remove copy-paste here and below int xp = position.x - s->w * zoom / 512 - s->x, yp = position.y - 62 * zoom / 256 - s->y; //hardcoded in original game return s->render(surface, xp, yp, mirror, Common::Rect(), zoom); } diff --git a/engines/teenagent/animation.cpp b/engines/teenagent/animation.cpp index 943458c1c2..7958df35c9 100644 --- a/engines/teenagent/animation.cpp +++ b/engines/teenagent/animation.cpp @@ -19,7 +19,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include "teenagent/teenagent.h" #include "teenagent/animation.h" + #include "common/endian.h" #include "common/textconsole.h" @@ -52,7 +54,7 @@ Surface *Animation::currentFrame(int dt) { if (data != NULL) { uint32 frame = 3 * index; - debug(0, "%u/%u", index, data_size / 3); + debugC(2, kDebugAnimation, "%u/%u", index, data_size / 3); index += dt; if (!loop && index >= data_size / 3) { @@ -73,7 +75,7 @@ Surface *Animation::currentFrame(int dt) { y = r->y = pos / 320; } } else { - debug(0, "index %u", index); + debugC(2, kDebugAnimation, "index %u", index); r = frames + index; index += dt; index %= frames_count; @@ -111,7 +113,7 @@ void Animation::load(Common::SeekableReadStream &s, Type type) { free(); if (s.size() <= 1) { - debug(1, "empty animation"); + debugC(1, kDebugAnimation, "empty animation"); return; } @@ -121,20 +123,18 @@ void Animation::load(Common::SeekableReadStream &s, Type type) { case kTypeLan: data_size = s.readUint16LE(); if (s.eos()) { - debug(1, "empty animation"); + debugC(1, kDebugAnimation, "empty animation"); return; } data_size -= 2; data = new byte[data_size]; data_size = s.read(data, data_size); - /* for (int i = 0; i < data_size; ++i) { - debug(0, "%02x ", data[i]); - } - debug(0, ", %u frames", data_size / 3); - */ + for (int i = 0; i < data_size; ++i) + debugC(2, kDebugAnimation, "%02x ", data[i]); + debugC(2, kDebugAnimation, ", %u frames", data_size / 3); frames_count = s.readByte(); - debug(1, "%u physical frames", frames_count); + debugC(1, kDebugAnimation, "%u physical frames", frames_count); if (frames_count == 0) return; @@ -142,7 +142,7 @@ void Animation::load(Common::SeekableReadStream &s, Type type) { s.skip(frames_count * 2 - 2); //sizes pos = s.readUint16LE(); - debug(0, "pos?: %04x", pos); + debugC(3, kDebugAnimation, "pos?: 0x%04x", pos); for (uint16 i = 0; i < frames_count; ++i) { frames[i].load(s, Surface::kTypeLan); @@ -158,8 +158,8 @@ void Animation::load(Common::SeekableReadStream &s, Type type) { frames_count = 0; for (byte i = 0; i < data_size / 3; ++i) { int idx = i * 3; - /* byte unk = */ - s.readByte(); + byte unk = s.readByte(); + debugC(3, kDebugAnimation, "unk?: 0x%02x", unk); data[idx] = s.readByte(); if (data[idx] == 0) data[idx] = 1; //fixme: investigate @@ -167,7 +167,7 @@ void Animation::load(Common::SeekableReadStream &s, Type type) { frames_count = data[idx]; data[idx + 1] = 0; data[idx + 2] = 0; - debug(0, "frame #%u", data[idx]); + debugC(2, kDebugAnimation, "frame #%u", data[idx]); } frames = new Surface[frames_count]; @@ -180,15 +180,15 @@ void Animation::load(Common::SeekableReadStream &s, Type type) { case kTypeVaria: frames_count = s.readByte(); - debug(1, "loading varia resource, %u physical frames", frames_count); + debugC(1, kDebugAnimation, "loading varia resource, %u physical frames", frames_count); uint16 offset[255]; for (byte i = 0; i < frames_count; ++i) { offset[i] = s.readUint16LE(); - debug(0, "%u: %04x", i, offset[i]); + debugC(0, kDebugAnimation, "%u: %04x", i, offset[i]); } frames = new Surface[frames_count]; for (uint16 i = 0; i < frames_count; ++i) { - debug(0, "%04x", offset[i]); + debugC(0, kDebugAnimation, "%04x", offset[i]); s.seek(offset[i] + off); frames[i].load(s, Surface::kTypeOns); } @@ -196,7 +196,7 @@ void Animation::load(Common::SeekableReadStream &s, Type type) { break; } - debug(0, "%u frames", data_size / 3); + debugC(2, kDebugAnimation, "%u frames", data_size / 3); } Animation::~Animation() { diff --git a/engines/teenagent/callbacks.cpp b/engines/teenagent/callbacks.cpp index da0b9848f7..bd4c6dec4c 100644 --- a/engines/teenagent/callbacks.cpp +++ b/engines/teenagent/callbacks.cpp @@ -19,8 +19,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "teenagent/scene.h" #include "teenagent/teenagent.h" +#include "teenagent/scene.h" +#include "teenagent/inventory.h" #include "teenagent/resources.h" #include "teenagent/dialog.h" @@ -36,7 +37,7 @@ namespace TeenAgent { void TeenAgentEngine::rejectMessage() { //random reject message: uint i = _rnd.getRandomNumber(3); - debug(0, "reject message: %s", (const char *)res->dseg.ptr(res->dseg.get_word(0x339e + 2 * i))); + debugC(0, kDebugCallbacks, "reject message: %s", (const char *)res->dseg.ptr(res->dseg.get_word(0x339e + 2 * i))); displayMessage(res->dseg.get_word(0x339e + 2 * i)); } @@ -45,7 +46,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) { if (addr == 0) return false; - debug(0, "processCallback(%04x)", addr); + debugC(0, kDebugCallbacks, "processCallback(%04x)", addr); byte *code = res->cseg.ptr(addr); //try trivial callbacks first @@ -53,8 +54,8 @@ bool TeenAgentEngine::processCallback(uint16 addr) { //call display_message, r uint16 msg = READ_LE_UINT16(code + 1); uint16 func = 6 + addr + READ_LE_UINT16(code + 4); - debug(0, "call %04x", func); - debug(0, "trivial callback, showing message %s", (const char *)res->dseg.ptr(addr)); + debugC(0, kDebugCallbacks, "call %04x", func); + debugC(0, kDebugCallbacks, "trivial callback, showing message %s", (const char *)res->dseg.ptr(addr)); switch (func) { case 0xa055: displayMessage(msg); @@ -64,7 +65,7 @@ bool TeenAgentEngine::processCallback(uint16 addr) { if (code[0] == 0xe8 && code[3] == 0xc3) { uint func = 3 + addr + READ_LE_UINT16(code + 1); - debug(0, "call %04x and return", func); + debugC(0, kDebugCallbacks, "call %04x and return", func); if (func == 0xa4d6) { rejectMessage(); return true; @@ -4044,12 +4045,12 @@ bool TeenAgentEngine::processCallback(uint16 addr) { case 0x9d45: { wait(50); byte attempts = ++ *(res->dseg.ptr(0xDBEA)); - debug(0, "mansion intrusion attempt #%u", attempts); + debugC(0, kDebugCallbacks, "mansion intrusion attempt #%u", attempts); if (attempts >= 7) return false; uint16 ptr = res->dseg.get_word((attempts - 2) * 2 + 0x6035); - debug(0, "mansion callback = %04x", ptr); + debugC(0, kDebugCallbacks, "mansion callback = %04x", ptr); byte id = scene->getId(); playMusic(11); @@ -4140,7 +4141,6 @@ bool TeenAgentEngine::processCallback(uint16 addr) { return true; } - //error("invalid callback %04x called", addr); warning("invalid callback %04x called", addr); return true; } diff --git a/engines/teenagent/dialog.cpp b/engines/teenagent/dialog.cpp index 69521158f8..da69d8be23 100644 --- a/engines/teenagent/dialog.cpp +++ b/engines/teenagent/dialog.cpp @@ -27,7 +27,7 @@ namespace TeenAgent { void Dialog::show(TeenAgentEngine *vm, Scene *scene, uint16 addr, uint16 animation1, uint16 animation2, byte color1, byte color2, byte slot1, byte slot2) { - debug(0, "Dialog::show(%04x, %u:%u, %u:%u)", addr, slot1, animation1, slot2, animation2); + debugC(0, kDebugDialog, "Dialog::show(%04x, %u:%u, %u:%u)", addr, slot1, animation1, slot2, animation2); int n = 0; Common::String message; byte color = color1; @@ -48,19 +48,19 @@ void Dialog::show(TeenAgentEngine *vm, Scene *scene, uint16 addr, uint16 animati while (n < 4) { byte c = vm->res->eseg.get_byte(addr++); - debug(0, "%02x: %c", c, c > 0x20? c: '.'); + debugC(1, kDebugDialog, "%02x: %c", c, c > 0x20? c: '.'); switch (c) { case 0: ++n; switch (n) { case 1: - debug(0, "new line\n"); + debugC(1, kDebugDialog, "new line\n"); if (!message.empty()) message += '\n'; break; case 2: - debug(0, "displaymessage %s", message.c_str()); + debugC(1, kDebugDialog, "displaymessage %s", message.c_str()); if (color == color2) { //pause animation in other slot SceneEvent e1(SceneEvent::kPauseAnimation); @@ -99,7 +99,7 @@ void Dialog::show(TeenAgentEngine *vm, Scene *scene, uint16 addr, uint16 animati case 3: color = (color == color1) ? color2 : color1; - debug(0, "changing color to %02x", color); + debugC(1, kDebugDialog, "changing color to %02x", color); break; } break; @@ -120,7 +120,7 @@ void Dialog::show(TeenAgentEngine *vm, Scene *scene, uint16 addr, uint16 animati } uint16 Dialog::pop(TeenAgentEngine *vm, Scene *scene, uint16 addr, uint16 animation1, uint16 animation2, byte color1, byte color2, byte slot1, byte slot2) { - debug(0, "Dialog::pop(%04x, %u:%u, %u:%u)", addr, slot1, animation1, slot2, animation2); + debugC(0, kDebugDialog, "Dialog::pop(%04x, %u:%u, %u:%u)", addr, slot1, animation1, slot2, animation2); uint16 next; do { next = vm->res->dseg.get_word(addr); diff --git a/engines/teenagent/font.cpp b/engines/teenagent/font.cpp index a56a72f021..cf3deadacb 100644 --- a/engines/teenagent/font.cpp +++ b/engines/teenagent/font.cpp @@ -20,8 +20,10 @@ */ #include "teenagent/font.h" + #include "teenagent/pack.h" -#include "common/debug.h" +#include "teenagent/teenagent.h" + #include "common/endian.h" #include "common/stream.h" #include "common/textconsole.h" @@ -43,13 +45,13 @@ void Font::load(const Pack &pack, int id) { data = new byte[s->size()]; s->read(data, s->size()); - debug(0, "font size: %d", s->size()); + debugC(0, kDebugFont, "font size: %d", s->size()); } uint Font::render(Graphics::Surface *surface, int x, int y, char c, byte color) { unsigned idx = (unsigned char)c; if (idx < 0x20 || idx >= 0x81) { - debug(0, "unhandled char 0x%02x", idx); + debugC(0, kDebugFont, "unhandled char 0x%02x", idx); return 0; } idx -= 0x20; @@ -68,7 +70,7 @@ uint Font::render(Graphics::Surface *surface, int x, int y, char c, byte color) i0 = -y; y = 0; } - debug(0, "char %c, width: %dx%d", c, w, h); + debugC(0, kDebugFont, "char %c, width: %dx%d", c, w, h); glyph += 2; glyph += i0 * w + j0; byte *dst = (byte *)surface->getBasePtr(x, y); @@ -109,7 +111,7 @@ uint Font::render(Graphics::Surface *surface, int x, int y, const Common::String do { j = find_in_str(str, '\n', i); Common::String line(str.c_str() + i, j - i); - debug(0, "line: %s", line.c_str()); + debugC(0, kDebugFont, "line: %s", line.c_str()); if (y + (int)height >= 0) { uint w = render(NULL, 0, 0, line, false); diff --git a/engines/teenagent/inventory.cpp b/engines/teenagent/inventory.cpp index dc7c6e563f..05beb419c0 100644 --- a/engines/teenagent/inventory.cpp +++ b/engines/teenagent/inventory.cpp @@ -24,6 +24,7 @@ #include "common/textconsole.h" #include "teenagent/inventory.h" + #include "teenagent/resources.h" #include "teenagent/objects.h" #include "teenagent/teenagent.h" @@ -40,13 +41,13 @@ Inventory::Inventory(TeenAgentEngine *vm) : _vm(vm) { Common::ScopedPtr<Common::SeekableReadStream> s(varia.getStream(3)); if (!s) error("no inventory background"); - debug(0, "loading inventory background..."); + debugC(0, kDebugInventory, "loading inventory background..."); _background.load(*s, Surface::kTypeOns); uint32 items_size = varia.getSize(4); if (items_size == 0) error("invalid inventory items size"); - debug(0, "loading items, size: %u", items_size); + debugC(0, kDebugInventory, "loading items, size: %u", items_size); _items = new byte[items_size]; varia.read(4, _items, items_size); @@ -93,7 +94,7 @@ bool Inventory::has(byte item) const { } void Inventory::remove(byte item) { - debug(0, "removing %u from inventory", item); + debugC(0, kDebugInventory, "removing %u from inventory", item); int i; for (i = 0; i < 24; ++i) { if (_inventory[i] == item) { @@ -109,7 +110,7 @@ void Inventory::remove(byte item) { } void Inventory::clear() { - debug(0, "clearing inventory"); + debugC(0, kDebugInventory, "clearing inventory"); for (int i = 0; i < 24; ++i) { _inventory[i] = 0; _graphics[i].free(); @@ -128,7 +129,7 @@ void Inventory::reload() { void Inventory::add(byte item) { if (has(item)) return; - debug(0, "adding %u to inventory", item); + debugC(0, kDebugInventory, "adding %u to inventory", item); for (int i = 0; i < 24; ++i) { if (_inventory[i] == 0) { _inventory[i] = item; @@ -191,7 +192,7 @@ bool Inventory::processEvent(const Common::Event &event) { if (_hoveredObj == NULL) return true; - debug(0, "lclick on %u:%s", _hoveredObj->id, _hoveredObj->name.c_str()); + debugC(0, kDebugInventory, "lclick on %u:%s", _hoveredObj->id, _hoveredObj->name.c_str()); if (_selectedObj == NULL) { if (tryObjectCallback(_hoveredObj)) @@ -207,18 +208,15 @@ bool Inventory::processEvent(const Common::Event &event) { if (id1 == id2) return true; - debug(0, "combine(%u, %u)!", id1, id2); + debugC(0, kDebugInventory, "combine(%u, %u)!", id1, id2); byte *table = _vm->res->dseg.ptr(0xC335); while (table[0] != 0 && table[1] != 0) { - if ( - (id1 == table[0] && id2 == table[1]) || - (id2 == table[0] && id1 == table[1]) - ) { + if ((id1 == table[0] && id2 == table[1]) || (id2 == table[0] && id1 == table[1])) { byte new_obj = table[2]; if (new_obj != 0) { remove(id1); remove(id2); - debug(0, "adding object %u", new_obj); + debugC(0, kDebugInventory, "adding object %u", new_obj); add(new_obj); _vm->playSoundNow(69); } @@ -241,14 +239,14 @@ bool Inventory::processEvent(const Common::Event &event) { return false; if (_hoveredObj != NULL) { - debug(0, "rclick object %u:%s", _hoveredObj->id, _hoveredObj->name.c_str()); + debugC(0, kDebugInventory, "rclick object %u:%s", _hoveredObj->id, _hoveredObj->name.c_str()); if (_hoveredObj->id != 51 && tryObjectCallback(_hoveredObj)) //do not process callback for banknote on r-click return true; } _selectedObj = _hoveredObj; if (_selectedObj) - debug(0, "selected object %s", _selectedObj->name.c_str()); + debugC(0, kDebugInventory, "selected object %s", _selectedObj->name.c_str()); return true; case Common::EVENT_KEYDOWN: @@ -271,7 +269,6 @@ bool Inventory::processEvent(const Common::Event &event) { } } - void Inventory::Item::free() { _animation.free(); _surface.free(); @@ -292,13 +289,13 @@ void Inventory::Item::load(Inventory *inventory, uint item_id) { InventoryObject *obj = &inventory->_objects[item_id]; if (obj->animated) { if (_animation.empty()) { - debug(0, "loading item %d from offset %x", obj->id, inventory->_offset[obj->id - 1]); + debugC(0, kDebugInventory, "loading item %d from offset %x", obj->id, inventory->_offset[obj->id - 1]); Common::MemoryReadStream s(inventory->_items + inventory->_offset[obj->id - 1], inventory->_offset[obj->id] - inventory->_offset[obj->id - 1]); _animation.load(s, Animation::kTypeInventory); } } else { if (_surface.empty()) { - debug(0, "loading item %d from offset %x", obj->id, inventory->_offset[obj->id - 1]); + debugC(0, kDebugInventory, "loading item %d from offset %x", obj->id, inventory->_offset[obj->id - 1]); Common::MemoryReadStream s(inventory->_items + inventory->_offset[obj->id - 1], inventory->_offset[obj->id] - inventory->_offset[obj->id - 1]); _surface.load(s, Surface::kTypeOns); } @@ -344,7 +341,7 @@ void Inventory::Item::render(Inventory *inventory, uint item_id, Graphics::Surfa void Inventory::render(Graphics::Surface *surface, int delta) { if (!_active) return; - debug(0, "Inventory::render()"); + debugC(0, kDebugInventory, "Inventory::render()"); _background.render(surface); @@ -353,7 +350,7 @@ void Inventory::render(Graphics::Surface *surface, int delta) { int idx = x + 6 * y; byte item = _inventory[idx]; if (item != 0) { - debug(0, "\t(x, y): %d,%d -> item: %u", x, y, item); + debugC(0, kDebugInventory, "\t(x, y): %d,%d -> item: %u", x, y, item); _graphics[idx].render(this, item, surface, delta); } } diff --git a/engines/teenagent/music.cpp b/engines/teenagent/music.cpp index bb314afdba..ad8d9c8515 100644 --- a/engines/teenagent/music.cpp +++ b/engines/teenagent/music.cpp @@ -43,6 +43,7 @@ MusicPlayer::~MusicPlayer() { } bool MusicPlayer::load(int id) { + debugC(0, kDebugMusic, "MusicPlayer::load(%d)", id); Common::ScopedPtr<Common::SeekableReadStream> stream(_vm->res->mmm.getStream(id)); if (!stream) return false; @@ -55,14 +56,14 @@ bool MusicPlayer::load(int id) { // Load the samples sampleCount = stream->readByte(); - debug(0, "sampleCount = %d", sampleCount); + debugC(0, kDebugMusic, "sampleCount = %d", sampleCount); for (byte currSample = 0; currSample < sampleCount; currSample++) { byte sample = stream->readByte(); // Load the sample data byte sampleResource = ((sample >> 4) & 0x0F) * 10 + (sample & 0x0F); - debug(0, "currSample = %d, sample = 0x%02x, resource: %d", currSample, sample, sampleResource); + debugC(0, kDebugMusic, "currSample = %d, sample = 0x%02x, resource: %d", currSample, sample, sampleResource); uint32 sampleSize = _vm->res->sam_mmm.getSize(sampleResource); if (sampleSize == 0) { warning("load: invalid sample %d (0x%02x)", sample, sample); @@ -89,15 +90,15 @@ bool MusicPlayer::load(int id) { _rows.push_back(row); } else if ((cmd & 0xF0) == 0x50) { byte sample = stream->readByte(); - debug(1, "%02x: set sample %02x", cmd, sample); + debugC(1, kDebugMusic, "%02x: set sample %02x", cmd, sample); row.channels[(cmd & 0x0F) - 1].sample = sample; } else if ((cmd & 0xF0) == 0x40) { byte vol = stream->readByte(); - debug(1, "%02x: set volume %02x -> %02x", cmd, row.channels[(cmd & 0x0F) - 1].volume, vol); + debugC(1, kDebugMusic, "%02x: set volume %02x -> %02x", cmd, row.channels[(cmd & 0x0F) - 1].volume, vol); //channel volume 0x40 * music volume 0x40 mixed with high bytes row.channels[(cmd & 0x0F) - 1].volume = vol * 16; } else { - debug(0, "unhandled music command %02x", cmd); + debugC(0, kDebugMusic, "unhandled music command %02x", cmd); } } _currRow = 0; @@ -124,13 +125,13 @@ void MusicPlayer::interrupt() { for (int chn = 0; chn < 3; ++chn) { setChannelVolume(chn, row->channels[chn].volume); - debug(0, "row->channels[%d].volume = %d", chn, row->channels[chn].volume); + debugC(2, kDebugMusic, "row->channels[%d].volume = %d", chn, row->channels[chn].volume); byte sample = (row->channels[chn].sample); if (row->channels[chn].note != 0 && sample != 0) { - debug(0, "row->channels[%d].note = %d", chn, row->channels[chn].note); - debug(0, "row->channels[%d].sample = %d", chn, row->channels[chn].sample); + debugC(2, kDebugMusic, "row->channels[%d].note = %d", chn, row->channels[chn].note); + debugC(2, kDebugMusic, "row->channels[%d].sample = %d", chn, row->channels[chn].sample); byte note = row->channels[chn].note; if (_samples[sample].size == 0) { @@ -143,7 +144,7 @@ void MusicPlayer::interrupt() { } } - debug(0, "------------------------------------------------"); + debugC(2, kDebugMusic, "------------------------------------------------"); ++_currRow; } diff --git a/engines/teenagent/objects.cpp b/engines/teenagent/objects.cpp index 7b0f8c7ec5..72a4ce92a9 100644 --- a/engines/teenagent/objects.cpp +++ b/engines/teenagent/objects.cpp @@ -21,8 +21,10 @@ #include "common/debug.h" #include "common/memstream.h" + #include "teenagent/objects.h" #include "teenagent/resources.h" +#include "teenagent/teenagent.h" namespace TeenAgent { @@ -84,7 +86,7 @@ void Object::setName(const Common::String &new_name) { } void Object::dump(int level) const { - debug(level, "object: %u %u [%u,%u,%u,%u], actor: [%u,%u,%u,%u], orientation: %u, name: %s", id, enabled, + debugC(level, kDebugObject, "object: %u %u [%u,%u,%u,%u], actor: [%u,%u,%u,%u], orientation: %u, name: %s", id, enabled, rect.left, rect.top, rect.right, rect.bottom, actor_rect.left, actor_rect.top, actor_rect.right, actor_rect.bottom, actor_orientation, name.c_str() @@ -101,7 +103,7 @@ Common::String Object::parse_description(const char *name) { while (*desc != 1 && *desc != 0) { Common::String line; while (*desc != 1 && *desc != 0) { - debug(0, "%02x ", *desc); + debugC(2, kDebugObject, "%02x ", *desc); line += *desc++; } @@ -138,14 +140,14 @@ void UseHotspot::load(byte *src) { } void UseHotspot::dump(int level) const { - debug(level, + debugC(level, kDebugObject, "hotspot: inv_id: %02x, obj_id: %02x, orientation?: %02x, actor position: (%d,%d), callback: %04x", inventory_id, object_id, orientation, actor_x, actor_y, callback ); } void Walkbox::dump(int level) const { - debug(level, "walkbox %02x %02x [%d, %d, %d, %d] top: %u, right: %u, bottom: %u, left: %u", + debugC(level, kDebugObject, "walkbox %02x %02x [%d, %d, %d, %d] top: %u, right: %u, bottom: %u, left: %u", type, orientation, rect.left, rect.top, rect.right, rect.bottom, side_hint[0], side_hint[1], side_hint[2], side_hint[3]); diff --git a/engines/teenagent/objects.h b/engines/teenagent/objects.h index 555287fc56..fe423a9d75 100644 --- a/engines/teenagent/objects.h +++ b/engines/teenagent/objects.h @@ -26,6 +26,8 @@ #include "common/rect.h" #include "graphics/surface.h" +#include "teenagent/teenagent.h" + namespace TeenAgent { enum {kActorUp = 1, kActorRight = 2, kActorDown = 3, kActorLeft = 4 }; @@ -52,7 +54,7 @@ struct Rect { void render(Graphics::Surface *surface, uint8 color) const; void dump(int level = 0) const { - debug(level, "rect[%u, %u, %u, %u]", left, top, right, bottom); + debugC(level, kDebugObject, "rect[%u, %u, %u, %u]", left, top, right, bottom); } inline void clear() { diff --git a/engines/teenagent/pack.cpp b/engines/teenagent/pack.cpp index 202bdf7db0..2e6c913a72 100644 --- a/engines/teenagent/pack.cpp +++ b/engines/teenagent/pack.cpp @@ -20,6 +20,8 @@ */ #include "teenagent/pack.h" +#include "teenagent/teenagent.h" + #include "common/util.h" #include "common/debug.h" #include "common/memstream.h" @@ -44,7 +46,7 @@ bool FilePack::open(const Common::String &filename) { return false; _fileCount = file.readUint32LE(); - debug(0, "opened %s, found %u entries", filename.c_str(), _fileCount); + debugC(0, kDebugPack, "opened %s, found %u entries", filename.c_str(), _fileCount); offsets = new uint32[_fileCount + 1]; for (uint32 i = 0; i <= _fileCount; ++i) { offsets[i] = file.readUint32LE(); @@ -65,18 +67,17 @@ uint32 FilePack::read(uint32 id, byte *dst, uint32 size) const { file.seek(offsets[id - 1]); uint32 rsize = offsets[id] - offsets[id - 1]; uint32 r = file.read(dst, MIN(rsize, size)); - debug(0, "read(%u, %u) = %u", id, size, r); + debugC(0, kDebugPack, "read(%u, %u) = %u", id, size, r); return r; } Common::SeekableReadStream *FilePack::getStream(uint32 id) const { if (id < 1 || id > _fileCount) return NULL; - debug(0, "stream: %04x-%04x", offsets[id - 1], offsets[id]); + debugC(0, kDebugPack, "stream: %04x-%04x", offsets[id - 1], offsets[id]); return new Common::SeekableSubReadStream(&file, offsets[id - 1], offsets[id]); } - TransientFilePack::TransientFilePack() : offsets(0) {} TransientFilePack::~TransientFilePack() { @@ -97,7 +98,7 @@ bool TransientFilePack::open(const Common::String &filename) { return false; _fileCount = file.readUint32LE(); - debug(0, "opened %s, found %u entries", filename.c_str(), _fileCount); + debugC(0, kDebugPack, "opened %s, found %u entries", filename.c_str(), _fileCount); offsets = new uint32[_fileCount + 1]; for (uint32 i = 0; i <= _fileCount; ++i) { offsets[i] = file.readUint32LE(); @@ -124,14 +125,14 @@ uint32 TransientFilePack::read(uint32 id, byte *dst, uint32 size) const { uint32 rsize = offsets[id] - offsets[id - 1]; uint32 r = file.read(dst, MIN(rsize, size)); file.close(); - debug(0, "read(%u, %u) = %u", id, size, r); + debugC(0, kDebugPack, "read(%u, %u) = %u", id, size, r); return r; } Common::SeekableReadStream *TransientFilePack::getStream(uint32 id) const { if (id < 1 || id > _fileCount) return NULL; - debug(0, "stream: %04x-%04x", offsets[id - 1], offsets[id]); + debugC(0, kDebugPack, "stream: %04x-%04x", offsets[id - 1], offsets[id]); Common::File file; if (!file.open(_filename)) return NULL; @@ -146,7 +147,6 @@ Common::SeekableReadStream *TransientFilePack::getStream(uint32 id) const { return new Common::MemoryReadStream(ptr, r, DisposeAfterUse::YES); } - void MemoryPack::close() { chunks.clear(); } @@ -157,7 +157,7 @@ bool MemoryPack::open(const Common::String &filename) { return false; uint32 count = file.readUint32LE(); - debug(0, "opened %s, found %u entries [memory]", filename.c_str(), count); + debugC(0, kDebugPack, "opened %s, found %u entries [memory]", filename.c_str(), count); for (uint32 i = 0; i < count; ++i) { uint32 offset = file.readUint32LE(); int32 pos = file.pos(); @@ -199,5 +199,4 @@ Common::SeekableReadStream *MemoryPack::getStream(uint32 id) const { return new Common::MemoryReadStream(c.data, c.size, DisposeAfterUse::NO); } - } // End of namespace TeenAgent diff --git a/engines/teenagent/scene.cpp b/engines/teenagent/scene.cpp index 8e4d1389f1..aca29cc9fb 100644 --- a/engines/teenagent/scene.cpp +++ b/engines/teenagent/scene.cpp @@ -21,6 +21,7 @@ #include "common/config-manager.h" #include "common/debug.h" +#include "common/events.h" #include "common/algorithm.h" #include "common/ptr.h" #include "common/textconsole.h" @@ -28,6 +29,7 @@ #include "graphics/palette.h" #include "teenagent/scene.h" +#include "teenagent/inventory.h" #include "teenagent/resources.h" #include "teenagent/surface.h" #include "teenagent/objects.h" @@ -91,7 +93,7 @@ bool Scene::findPath(Scene::Path &p, const Common::Point &src, const Common::Poi if (dst.x < 0 || dst.x > 319 || dst.y < 0 || dst.y > 199) return false; - debug(1, "findPath %d,%d -> %d,%d", src.x, src.y, dst.x, dst.y); + debugC(1, kDebugScene, "findPath %d,%d -> %d,%d", src.x, src.y, dst.x, dst.y); p.clear(); p.push_back(src); p.push_back(dst); @@ -110,7 +112,7 @@ bool Scene::findPath(Scene::Path &p, const Common::Point &src, const Common::Poi break; const Common::Point &p1 = *i, &p2 = *next; - debug(1, "%d,%d -> %d,%d", p1.x, p1.y, p2.x, p2.y); + debugC(1, kDebugScene, "%d,%d -> %d,%d", p1.x, p1.y, p2.x, p2.y); Common::List<uint>::iterator wi; for (wi = boxes.begin(); wi != boxes.end(); ++wi) { @@ -121,14 +123,14 @@ bool Scene::findPath(Scene::Path &p, const Common::Point &src, const Common::Poi } w.dump(1); - debug(1, "%u: intersection mask 0x%04x, searching hints", *wi, mask); + debugC(1, kDebugScene, "%u: intersection mask 0x%04x, searching hints", *wi, mask); int dx = p2.x - p1.x, dy = p2.y - p1.y; if (dx >= 0) { if ((mask & 8) != 0 && w.side_hint[3] != 0) { - debug(1, "hint left: %u", w.side_hint[3]); + debugC(1, kDebugScene, "hint left: %u", w.side_hint[3]); Common::Point w1, w2; w.rect.side(w1, w2, w.side_hint[3], p1); - debug(1, "hint: %d,%d-%d,%d", w1.x, w1.y, w2.x, w2.y); + debugC(1, kDebugScene, "hint: %d,%d-%d,%d", w1.x, w1.y, w2.x, w2.y); p.insert(next, w1); if (mask & 2) p.insert(next, w2); @@ -137,10 +139,10 @@ bool Scene::findPath(Scene::Path &p, const Common::Point &src, const Common::Poi } } else { if ((mask & 2) != 0 && w.side_hint[1] != 0) { - debug(1, "hint right: %u", w.side_hint[1]); + debugC(1, kDebugScene, "hint right: %u", w.side_hint[1]); Common::Point w1, w2; w.rect.side(w1, w2, w.side_hint[1], p1); - debug(1, "hint: %d,%d-%d,%d", w1.x, w1.y, w2.x, w2.y); + debugC(1, kDebugScene, "hint: %d,%d-%d,%d", w1.x, w1.y, w2.x, w2.y); p.insert(next, w1); if (mask & 8) p.insert(next, w2); @@ -151,10 +153,10 @@ bool Scene::findPath(Scene::Path &p, const Common::Point &src, const Common::Poi if (dy >= 0) { if ((mask & 1) != 0 && w.side_hint[0] != 0) { - debug(1, "hint top: %u", w.side_hint[0]); + debugC(1, kDebugScene, "hint top: %u", w.side_hint[0]); Common::Point w1, w2; w.rect.side(w1, w2, w.side_hint[0], p1); - debug(1, "hint: %d,%d-%d,%d", w1.x, w1.y, w2.x, w2.y); + debugC(1, kDebugScene, "hint: %d,%d-%d,%d", w1.x, w1.y, w2.x, w2.y); p.insert(next, w1); if (mask & 4) p.insert(next, w2); @@ -163,10 +165,10 @@ bool Scene::findPath(Scene::Path &p, const Common::Point &src, const Common::Poi } } else { if ((mask & 4) != 0 && w.side_hint[2] != 0) { - debug(1, "hint bottom: %u", w.side_hint[2]); + debugC(1, kDebugScene, "hint bottom: %u", w.side_hint[2]); Common::Point w1, w2; w.rect.side(w1, w2, w.side_hint[2], p1); - debug(1, "hint: %d,%d-%d,%d", w1.x, w1.y, w2.x, w2.y); + debugC(1, kDebugScene, "hint: %d,%d-%d,%d", w1.x, w1.y, w2.x, w2.y); p.insert(next, w1); if (mask & 1) p.insert(next, w2); @@ -184,13 +186,13 @@ bool Scene::findPath(Scene::Path &p, const Common::Point &src, const Common::Poi void Scene::moveTo(const Common::Point &_point, byte orient, bool validate) { Common::Point point(_point); - debug(0, "moveTo(%d, %d, %u)", point.x, point.y, orient); + debugC(0, kDebugScene, "moveTo(%d, %d, %u)", point.x, point.y, orient); const Common::Array<Walkbox> &scene_walkboxes = walkboxes[_id - 1]; for (byte i = 0; i < scene_walkboxes.size(); ++i) { const Walkbox &w = scene_walkboxes[i]; if (w.rect.in(point)) { - debug(0, "bumped into walkbox %u", i); + debugC(0, kDebugScene, "bumped into walkbox %u", i); w.dump(); byte o = w.orientation; switch (o) { @@ -252,11 +254,11 @@ void Scene::loadObjectData() { scene_objects.push_back(obj); scene_table += 2; } - debug(0, "scene[%u] has %u object(s)", i + 1, scene_objects.size()); + debugC(0, kDebugScene, "scene[%u] has %u object(s)", i + 1, scene_objects.size()); byte *walkboxes_base = _vm->res->dseg.ptr(READ_LE_UINT16(_vm->res->dseg.ptr(0x6746 + i * 2))); byte walkboxes_n = *walkboxes_base++; - debug(0, "scene[%u] has %u walkboxes", i + 1, walkboxes_n); + debugC(0, kDebugScene, "scene[%u] has %u walkboxes", i + 1, walkboxes_n); Common::Array<Walkbox> &scene_walkboxes = walkboxes[i]; for (byte j = 0; j < walkboxes_n; ++j) { @@ -280,7 +282,7 @@ void Scene::loadObjectData() { fade_table += 9; scene_fades.push_back(fade); } - debug(0, "scene[%u] has %u fadeboxes", i + 1, scene_fades.size()); + debugC(0, kDebugScene, "scene[%u] has %u fadeboxes", i + 1, scene_fades.size()); } } @@ -307,16 +309,16 @@ byte *Scene::getLans(int id) { } void Scene::loadOns() { - debug(0, "loading ons animation"); + debugC(0, kDebugScene, "loading ons animation"); uint16 addr = _vm->res->dseg.get_word(0xb4f5 + (_id - 1) * 2); - debug(0, "ons index: %04x", addr); + debugC(0, kDebugScene, "ons index: %04x", addr); ons_count = 0; byte b; byte on_id[16]; while ((b = _vm->res->dseg.get_byte(addr)) != 0xff) { - debug(0, "on: %04x = %02x", addr, b); + debugC(0, kDebugScene, "on: %04x = %02x", addr, b); ++addr; if (b == 0) continue; @@ -339,7 +341,7 @@ void Scene::loadOns() { } void Scene::loadLans() { - debug(0, "loading lans animation"); + debugC(0, kDebugScene, "loading lans animation"); //load lan000 for (byte i = 0; i < 4; ++i) { @@ -348,7 +350,7 @@ void Scene::loadLans() { uint16 bx = 0xd89e + (_id - 1) * 4 + i; byte bxv = _vm->res->dseg.get_byte(bx); uint16 res_id = 4 * (_id - 1) + i + 1; - debug(0, "lan[%u]@%04x = %02x, resource id: %u", i, bx, bxv, res_id); + debugC(0, kDebugScene, "lan[%u]@%04x = %02x, resource id: %u", i, bx, bxv, res_id); if (bxv == 0) continue; @@ -362,7 +364,7 @@ void Scene::loadLans() { } void Scene::init(int id, const Common::Point &pos) { - debug(0, "init(%d)", id); + debugC(0, kDebugScene, "init(%d)", id); _id = id; on_enabled = true; //reset on-rendering flag on loading. sounds.clear(); @@ -418,7 +420,7 @@ void Scene::init(int id, const Common::Point &pos) { } void Scene::playAnimation(byte idx, uint id, bool loop, bool paused, bool ignore) { - debug(0, "playAnimation(%u, %u, loop:%s, paused:%s, ignore:%s)", idx, id, loop ? "true" : "false", paused ? "true" : "false", ignore ? "true" : "false"); + debugC(0, kDebugScene, "playAnimation(%u, %u, loop:%s, paused:%s, ignore:%s)", idx, id, loop ? "true" : "false", paused ? "true" : "false", ignore ? "true" : "false"); assert(idx < 4); Common::ScopedPtr<Common::SeekableReadStream> s(_vm->res->loadLan(id + 1)); if (!s) @@ -431,7 +433,7 @@ void Scene::playAnimation(byte idx, uint id, bool loop, bool paused, bool ignore } void Scene::playActorAnimation(uint id, bool loop, bool ignore) { - debug(0, "playActorAnimation(%u, loop:%s, ignore:%s)", id, loop ? "true" : "false", ignore ? "true" : "false"); + debugC(0, kDebugScene, "playActorAnimation(%u, loop:%s, ignore:%s)", id, loop ? "true" : "false", ignore ? "true" : "false"); Common::ScopedPtr<Common::SeekableReadStream> s(_vm->res->loadLan(id + 1)); if (!s) error("playing animation %u failed", id); @@ -457,12 +459,12 @@ byte Scene::peekFlagEvent(uint16 addr) const { } void Scene::push(const SceneEvent &event) { - debug(0, "push"); + debugC(0, kDebugScene, "push"); //event.dump(); if (event.type == SceneEvent::kWalk && !events.empty()) { SceneEvent &prev = events.back(); if (prev.type == SceneEvent::kWalk && prev.color == event.color) { - debug(0, "fixing double-move [skipping event!]"); + debugC(0, kDebugScene, "fixing double-move [skipping event!]"); if ((event.color & 2) != 0) { //relative move prev.dst.x += event.dst.x; prev.dst.y += event.dst.y; @@ -525,7 +527,7 @@ bool Scene::processEvent(const Common::Event &event) { uint feature = event.kbd.keycode - '1'; if (feature < DebugFeatures::kMax) { debug_features.feature[feature] = !debug_features.feature[feature]; - debug(0, "switched feature %u %s", feature, debug_features.feature[feature] ? "on" : "off"); + debugC(0, kDebugScene, "switched feature %u %s", feature, debug_features.feature[feature] ? "on" : "off"); } } break; @@ -546,12 +548,12 @@ struct ZOrderCmp { }; int Scene::lookupZoom(uint y) const { + debugC(2, kDebugScene, "lookupZoom(%d)", y); for (byte *zoom_table = _vm->res->dseg.ptr(_vm->res->dseg.get_word(0x70f4 + (_id - 1) * 2)); zoom_table[0] != 0xff && zoom_table[1] != 0xff; zoom_table += 2) { - debug(0, "%d %d->%d", y, zoom_table[0], zoom_table[1]); + debugC(2, kDebugScene, "\t%d %d->%d", y, zoom_table[0], zoom_table[1]); if (y <= zoom_table[0]) { - debug(0, "%d %d->%d", y, zoom_table[0], zoom_table[1]); return 256u * (100 - zoom_table[1]) / 100; } } @@ -605,7 +607,7 @@ bool Scene::render(bool tick_game, bool tick_mark, uint32 delta) { switch (current_event.type) { case SceneEvent::kCredits: { _vm->_system->fillScreen(0); - ///\todo: optimize me + //TODO: optimize me Graphics::Surface *surface = _vm->_system->lockScreen(); _vm->res->font7.render(surface, current_event.dst.x, current_event.dst.y -= game_delta, current_event.message, current_event.color); _vm->_system->unlockScreen(); @@ -670,7 +672,7 @@ bool Scene::render(bool tick_game, bool tick_mark, uint32 delta) { } else { a = animation + i; if (!custom_animation[i].empty()) { - debug(0, "custom animation ended, restart animation in the same slot."); + debugC(0, kDebugScene, "custom animation ended, restart animation in the same slot."); custom_animation[i].free(); a->restart(); } @@ -684,7 +686,7 @@ bool Scene::render(bool tick_game, bool tick_mark, uint32 delta) { } int index = a->currentIndex(); if (index == current_event.animation) { - debug(0, "kWaitLanAnimationFrame(%d, %d) complete", current_event.slot, current_event.animation); + debugC(0, kDebugScene, "kWaitLanAnimationFrame(%d, %d) complete", current_event.slot, current_event.animation); restart |= nextEvent(); } } @@ -814,7 +816,7 @@ bool Scene::render(bool tick_game, bool tick_mark, uint32 delta) { bool visible = true; if (message_first_frame != 0 && message_animation != NULL) { int index = message_animation->currentIndex() + 1; - debug(0, "message: %s first: %u index: %u", message.c_str(), message_first_frame, index); + debugC(0, kDebugScene, "message: %s first: %u index: %u", message.c_str(), message_first_frame, index); if (index < message_first_frame) visible = false; if (index > message_last_frame) { @@ -835,7 +837,7 @@ bool Scene::render(bool tick_game, bool tick_mark, uint32 delta) { _vm->inventory->activate(false); _vm->processCallback(callback); } - debug(0, "callback timer = %u", callback_timer); + debugC(0, kDebugScene, "callback timer = %u", callback_timer); } //if (!current_event.empty()) @@ -873,7 +875,7 @@ bool Scene::render(bool tick_game, bool tick_mark, uint32 delta) { } if (!restart && current_event.type == SceneEvent::kWaitForAnimation && !got_any_animation) { - debug(0, "no animations, nextevent"); + debugC(0, kDebugScene, "no animations, nextevent"); nextEvent(); restart = true; } @@ -887,7 +889,7 @@ bool Scene::render(bool tick_game, bool tick_mark, uint32 delta) { for (Sounds::iterator i = sounds.begin(); i != sounds.end();) { Sound &sound = *i; if (sound.delay == 0) { - debug(1, "sound %u started", sound.id); + debugC(1, kDebugScene, "sound %u started", sound.id); _vm->playSoundNow(sound.id); i = sounds.erase(i); } else { @@ -901,7 +903,7 @@ bool Scene::render(bool tick_game, bool tick_mark, uint32 delta) { bool Scene::processEventQueue() { while (!events.empty() && current_event.empty()) { - debug(0, "processing next event"); + debugC(0, kDebugScene, "processing next event"); current_event = events.front(); events.pop_front(); switch (current_event.type) { @@ -911,11 +913,11 @@ bool Scene::processEventQueue() { if (on_id != 0) { --on_id; byte *ptr = getOns(current_event.scene == 0 ? _id : current_event.scene); - debug(0, "on[%u] = %02x", on_id, current_event.color); + debugC(0, kDebugScene, "on[%u] = %02x", on_id, current_event.color); ptr[on_id] = current_event.color; } else { on_enabled = current_event.color != 0; - debug(0, "%s on rendering", on_enabled ? "enabling" : "disabling"); + debugC(0, kDebugScene, "%s on rendering", on_enabled ? "enabling" : "disabling"); } loadOns(); current_event.clear(); @@ -924,7 +926,7 @@ bool Scene::processEventQueue() { case SceneEvent::kSetLan: { if (current_event.lan != 0) { - debug(0, "lan[%u] = %02x", current_event.lan - 1, current_event.color); + debugC(0, kDebugScene, "lan[%u] = %02x", current_event.lan - 1, current_event.color); byte *ptr = getLans(current_event.scene == 0 ? _id : current_event.scene); ptr[current_event.lan - 1] = current_event.color; } @@ -981,7 +983,7 @@ bool Scene::processEventQueue() { // message_animation = animation + current_event.slot; } else message_animation = &actor_animation; - debug(0, "async message %d-%d (slot %u)", message_first_frame, message_last_frame, current_event.slot); + debugC(0, kDebugScene, "async message %d-%d (slot %u)", message_first_frame, message_last_frame, current_event.slot); } else { message_timer = current_event.timer ? current_event.timer * 110 : messageDuration(message); message_first_frame = message_last_frame = 0; @@ -1018,7 +1020,7 @@ bool Scene::processEventQueue() { case SceneEvent::kPlayAnimation: { byte slot = current_event.slot & 7; //0 - mark's if (current_event.animation != 0) { - debug(0, "playing animation %u in slot %u(%02x)", current_event.animation, slot, current_event.slot); + debugC(0, kDebugScene, "playing animation %u in slot %u(%02x)", current_event.animation, slot, current_event.slot); if (slot != 0) { --slot; assert(slot < 4); @@ -1028,7 +1030,7 @@ bool Scene::processEventQueue() { } else { if (slot != 0) { --slot; - debug(0, "cancelling animation in slot %u", slot); + debugC(0, kDebugScene, "cancelling animation in slot %u", slot); assert(slot < 4); custom_animation[slot].free(); } else @@ -1042,7 +1044,7 @@ bool Scene::processEventQueue() { byte slot = current_event.slot & 7; //0 - mark's if (slot != 0) { --slot; - debug(1, "pause animation in slot %u", slot); + debugC(1, kDebugScene, "pause animation in slot %u", slot); custom_animation[slot].paused = (current_event.slot & 0x80) != 0; } else { actor_talking = false; @@ -1059,26 +1061,26 @@ bool Scene::processEventQueue() { break; case SceneEvent::kPlayActorAnimation: - debug(0, "playing actor animation %u", current_event.animation); + debugC(0, kDebugScene, "playing actor animation %u", current_event.animation); playActorAnimation(current_event.animation, (current_event.slot & 0x80) != 0, (current_event.slot & 0x20) != 0); current_event.clear(); break; case SceneEvent::kPlayMusic: - debug(0, "setting music %u", current_event.music); + debugC(0, kDebugScene, "setting music %u", current_event.music); _vm->setMusic(current_event.music); _vm->res->dseg.set_byte(0xDB90, current_event.music); current_event.clear(); break; case SceneEvent::kPlaySound: - debug(0, "playing sound %u, delay: %u", current_event.sound, current_event.color); + debugC(0, kDebugScene, "playing sound %u, delay: %u", current_event.sound, current_event.color); sounds.push_back(Sound(current_event.sound, current_event.color)); current_event.clear(); break; case SceneEvent::kEnableObject: { - debug(0, "%s object #%u", current_event.color ? "enabling" : "disabling", current_event.object - 1); + debugC(0, kDebugScene, "%s object #%u", current_event.color ? "enabling" : "disabling", current_event.object - 1); Object *obj = getObject(current_event.object - 1, current_event.scene == 0 ? _id : current_event.scene); obj->enabled = current_event.color; obj->save(); @@ -1092,17 +1094,17 @@ bool Scene::processEventQueue() { break; case SceneEvent::kWaitForAnimation: - debug(0, "waiting for the animation"); + debugC(0, kDebugScene, "waiting for the animation"); break; case SceneEvent::kWaitLanAnimationFrame: - debug(0, "waiting for the frame %d in slot %d", current_event.animation, current_event.slot); + debugC(0, kDebugScene, "waiting for the frame %d in slot %d", current_event.animation, current_event.slot); break; case SceneEvent::kTimer: callback = current_event.callback; callback_timer = current_event.timer; - debug(0, "triggering callback %04x in %u frames", callback, callback_timer); + debugC(0, kDebugScene, "triggering callback %04x in %u frames", callback, callback_timer); current_event.clear(); break; @@ -1132,20 +1134,20 @@ bool Scene::processEventQueue() { break; case SceneEvent::kWait: - debug(0, "wait %u", current_event.timer); + debugC(0, kDebugScene, "wait %u", current_event.timer); break; case SceneEvent::kCredits: - debug(0, "showing credits"); + debugC(0, kDebugScene, "showing credits"); break; case SceneEvent::kQuit: - debug(0, "quit!"); + debugC(0, kDebugScene, "quit!"); _vm->quitGame(); break; case SceneEvent::kSetFlag: - debug(0, "async set_flag(%04x, %d)", current_event.callback, current_event.color); + debugC(0, kDebugScene, "async set_flag(%04x, %d)", current_event.callback, current_event.color); _vm->res->dseg.set_byte(current_event.callback, current_event.color); current_event.clear(); break; @@ -1162,7 +1164,7 @@ bool Scene::processEventQueue() { } void Scene::setPalette(unsigned mul) { - debug(0, "setPalette(%u)", mul); + debugC(0, kDebugScene, "setPalette(%u)", mul); byte p[3 * 256]; for (int i = 0; i < 3 * 256; ++i) { @@ -1224,13 +1226,13 @@ uint Scene::messageDuration(const Common::String &str) { uint delay_delta = 1 + (255 - speed) * 99 / 255; uint delay = 60 + (total_width * delay_delta) / 8; - debug(0, "delay = %u, delta: %u", delay, delay_delta); + debugC(0, kDebugScene, "delay = %u, delta: %u", delay, delay_delta); return delay * 10; } void Scene::displayMessage(const Common::String &str, byte color, const Common::Point &pos) { //assert(!str.empty()); - debug(0, "displayMessage: %s", str.c_str()); + debugC(0, kDebugScene, "displayMessage: %s", str.c_str()); message = str; message_pos = (pos.x | pos.y) ? pos : messagePosition(str, position); message_color = color; diff --git a/engines/teenagent/scene.h b/engines/teenagent/scene.h index fed1022816..ec04041444 100644 --- a/engines/teenagent/scene.h +++ b/engines/teenagent/scene.h @@ -27,8 +27,8 @@ #include "teenagent/objects.h" #include "teenagent/surface.h" #include "teenagent/surface_list.h" +#include "teenagent/teenagent.h" -#include "common/system.h" #include "common/array.h" #include "common/list.h" @@ -117,7 +117,7 @@ struct SceneEvent { } void dump() const { - debug(0, "event[%d]: \"%s\"[%02x], slot: %d, animation: %u, timer: %u, dst: (%d, %d) [%u], scene: %u, ons: %u, lan: %u, object: %u, music: %u, sound: %u", + debugC(0, kDebugScene, "event[%d]: \"%s\"[%02x], slot: %d, animation: %u, timer: %u, dst: (%d, %d) [%u], scene: %u, ons: %u, lan: %u, object: %u, music: %u, sound: %u", (int)type, message.c_str(), color, slot, animation, timer, dst.x, dst.y, orientation, scene, ons, lan, object, music, sound ); } diff --git a/engines/teenagent/surface.cpp b/engines/teenagent/surface.cpp index 45049ab076..fa67f28096 100644 --- a/engines/teenagent/surface.cpp +++ b/engines/teenagent/surface.cpp @@ -21,6 +21,8 @@ #include "teenagent/surface.h" #include "teenagent/pack.h" +#include "teenagent/teenagent.h" + #include "common/stream.h" #include "common/debug.h" @@ -34,7 +36,7 @@ Surface::~Surface() { } void Surface::load(Common::SeekableReadStream &stream, Type type) { - debug(0, "load()"); + debugC(0, kDebugSurface, "load()"); free(); x = y = 0; @@ -48,16 +50,16 @@ void Surface::load(Common::SeekableReadStream &stream, Type type) { y = pos / 320; } - debug(0, "declared info: %ux%u (%04xx%04x) -> %u,%u", w_, h_, w_, h_, x, y); + debugC(0, kDebugSurface, "declared info: %ux%u (%04xx%04x) -> %u,%u", w_, h_, w_, h_, x, y); if (stream.eos() || w_ == 0) return; if (w_ * h_ > stream.size()) { - debug(0, "invalid surface %ux%u -> %u,%u", w_, h_, x, y); + debugC(0, kDebugSurface, "invalid surface %ux%u -> %u,%u", w_, h_, x, y); return; } - debug(0, "creating surface %ux%u -> %u,%u", w_, h_, x, y); + debugC(0, kDebugSurface, "creating surface %ux%u -> %u,%u", w_, h_, x, y); create(w_, h_, Graphics::PixelFormat::createFormatCLUT8()); stream.read(pixels, w_ * h_); diff --git a/engines/teenagent/surface_list.cpp b/engines/teenagent/surface_list.cpp index 31387ac3cb..f1e021888b 100644 --- a/engines/teenagent/surface_list.cpp +++ b/engines/teenagent/surface_list.cpp @@ -19,9 +19,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "teenagent/surface.h" #include "teenagent/surface_list.h" -#include "objects.h" +#include "teenagent/surface.h" +#include "teenagent/objects.h" +#include "teenagent/teenagent.h" namespace TeenAgent { @@ -39,7 +40,7 @@ void SurfaceList::load(Common::SeekableReadStream &stream, Type type, int sub_ha return; surfaces_n = fn - sub_hack; - debug(0, "loading %u surfaces from list (skip %d)", surfaces_n, sub_hack); + debugC(0, kDebugSurface, "loading %u surfaces from list (skip %d)", surfaces_n, sub_hack); if (surfaces_n == 0) return; diff --git a/engines/teenagent/surface_list.h b/engines/teenagent/surface_list.h index 2d7be0d52b..f1359ec346 100644 --- a/engines/teenagent/surface_list.h +++ b/engines/teenagent/surface_list.h @@ -23,6 +23,7 @@ #define TEENAGENT_SURFACE_LIST_H__ #include "common/stream.h" +#include "graphics/surface.h" namespace TeenAgent { class Surface; diff --git a/engines/teenagent/teenagent.cpp b/engines/teenagent/teenagent.cpp index db3b730d41..27ac071621 100644 --- a/engines/teenagent/teenagent.cpp +++ b/engines/teenagent/teenagent.cpp @@ -21,6 +21,7 @@ #include "common/config-manager.h" #include "common/debug.h" +#include "common/debug-channels.h" #include "common/events.h" #include "common/savefile.h" #include "common/system.h" @@ -39,20 +40,33 @@ #include "graphics/thumbnail.h" #include "teenagent/console.h" +#include "teenagent/inventory.h" #include "teenagent/music.h" #include "teenagent/objects.h" #include "teenagent/pack.h" +#include "teenagent/resources.h" #include "teenagent/scene.h" #include "teenagent/teenagent.h" namespace TeenAgent { TeenAgentEngine::TeenAgentEngine(OSystem *system, const ADGameDescription *gd) - : Engine(system), action(kActionNone), _gameDescription(gd), - _rnd("teenagent") { + : Engine(system), action(kActionNone), _gameDescription(gd), _rnd("teenagent") { + DebugMan.addDebugChannel(kDebugActor, "Actor", "Enable Actor Debug"); + DebugMan.addDebugChannel(kDebugAnimation, "Animation", "Enable Animation Debug"); + DebugMan.addDebugChannel(kDebugCallbacks, "Callbacks", "Enable Callbacks Debug"); + DebugMan.addDebugChannel(kDebugDialog, "Dialog", "Enable Dialog Debug"); + DebugMan.addDebugChannel(kDebugFont, "Font", "Enable Font Debug"); + DebugMan.addDebugChannel(kDebugInventory, "Inventory", "Enable Inventory Debug"); + DebugMan.addDebugChannel(kDebugMusic, "Music", "Enable Music Debug"); + DebugMan.addDebugChannel(kDebugObject, "Object", "Enable Object Debug"); + DebugMan.addDebugChannel(kDebugPack, "Pack", "Enable Pack Debug"); + DebugMan.addDebugChannel(kDebugScene, "Scene", "Enable Scene Debug"); + DebugMan.addDebugChannel(kDebugSurface, "Surface", "Enable Surface Debug"); + music = new MusicPlayer(this); res = new Resources(); - + console = 0; } @@ -62,6 +76,7 @@ TeenAgentEngine::~TeenAgentEngine() { delete res; delete console; + DebugMan.clearAllDebugChannels(); } bool TeenAgentEngine::trySelectedObject() { @@ -69,7 +84,7 @@ bool TeenAgentEngine::trySelectedObject() { if (inv == NULL) return false; - debug(0, "checking active object %u on %u", inv->id, dst_object->id); + debugC(0, kDebugObject, "checking active object %u on %u", inv->id, dst_object->id); //mouse time challenge hack: if ((res->dseg.get_byte(0) == 1 && inv->id == 49 && dst_object->id == 5) || @@ -83,12 +98,12 @@ bool TeenAgentEngine::trySelectedObject() { for (uint i = 0; i < hotspots.size(); ++i) { const UseHotspot &spot = hotspots[i]; if (spot.inventory_id == inv->id && dst_object->id == spot.object_id) { - debug(0, "use object on hotspot!"); + debugC(0, kDebugObject, "use object on hotspot!"); spot.dump(); if (spot.actor_x != 0xffff && spot.actor_y != 0xffff) moveTo(spot.actor_x, spot.actor_y, spot.orientation); if (!processCallback(spot.callback)) - debug(0, "fixme! display proper description"); + debugC(0, kDebugObject, "FIXME: display proper description"); inventory->resetSelectedObject(); return true; } @@ -157,14 +172,14 @@ void TeenAgentEngine::examine(const Common::Point &point, Object *object) { if (object != NULL) { Common::Point dst = object->actor_rect.center(); - debug(0, "click %d, %d, object %d, %d", point.x, point.y, dst.x, dst.y); + debugC(0, kDebugObject, "click %d, %d, object %d, %d", point.x, point.y, dst.x, dst.y); action = kActionExamine; if (object->actor_rect.valid()) scene->moveTo(dst, object->actor_orientation, true); //validate examine message. Original engine does not let you into walkboxes dst_object = object; } else if (!scene_busy) { //do not reset anything while scene is busy, but allow interrupts while walking. - debug(0, "click %d, %d", point.x, point.y); + debugC(0, kDebugObject, "click %d, %d", point.x, point.y); action = kActionNone; scene->moveTo(point, 0, true); dst_object = NULL; @@ -571,7 +586,7 @@ Common::Error TeenAgentEngine::run() { if ((!scene_busy && inventory->processEvent(event)) || scene->processEvent(event)) continue; - debug(0, "event"); + debug(5, "event"); switch (event.type) { case Common::EVENT_KEYDOWN: if ((event.kbd.hasFlags(Common::KBD_CTRL) && event.kbd.keycode == Common::KEYCODE_d) || @@ -581,7 +596,7 @@ Common::Error TeenAgentEngine::run() { openMainMenuDialog(); } if (event.kbd.hasFlags(Common::KBD_CTRL) && event.kbd.keycode == Common::KEYCODE_f) { _mark_delay = _mark_delay == 80 ? 40 : 80; - debug(0, "mark_delay = %u", _mark_delay); + debug(5, "mark_delay = %u", _mark_delay); } break; case Common::EVENT_LBUTTONDOWN: @@ -591,7 +606,7 @@ Common::Error TeenAgentEngine::run() { break; case Common::EVENT_RBUTTONDOWN: if (current_object) - debug(0, "%d, %s", current_object->id, current_object->name.c_str()); + debugC(0, kDebugObject, "%d, %s", current_object->id, current_object->name.c_str()); if (scene->getId() < 0) break; @@ -799,7 +814,7 @@ void TeenAgentEngine::displayCredits() { ++lines; event.dst.x = (320 - res->font7.render(NULL, 0, 0, event.message, 0xd1)) / 2; event.timer = 11 * lines - event.dst.y + 22; - debug(0, "credits = %s", event.message.c_str()); + debug(2, "credits = %s", event.message.c_str()); scene->push(event); } @@ -1020,7 +1035,7 @@ void TeenAgentEngine::playSoundNow(byte id) { byte *data = (byte *)malloc(size); res->sam_sam.read(id, data, size); - debug(0, "playing %u samples...", size); + debug(3, "playing %u samples...", size); Audio::AudioStream *stream = Audio::makeRawStream(data, size, 11025, 0); _mixer->playStream(Audio::Mixer::kSFXSoundType, &_soundHandle, stream); //dispose is YES by default @@ -1028,7 +1043,7 @@ void TeenAgentEngine::playSoundNow(byte id) { void TeenAgentEngine::setMusic(byte id) { - debug(0, "starting music %u", id); + debugC(0, kDebugMusic, "starting music %u", id); if (id != 1) //intro music *res->dseg.ptr(0xDB90) = id; @@ -1036,11 +1051,11 @@ void TeenAgentEngine::setMusic(byte id) { if (_gameDescription->flags & ADGF_CD) { byte track2cd[] = {7, 2, 0, 9, 3, 6, 8, 10, 4, 5, 11}; if (id == 0 || id > 11 || track2cd[id - 1] == 0) { - debug(0, "no cd music for id %u", id); + debugC(0, kDebugMusic, "no cd music for id %u", id); return; } byte track = track2cd[id - 1]; - debug(0, "playing cd track %u", track); + debugC(0, kDebugMusic, "playing cd track %u", track); _system->getAudioCDManager()->play(track, -1, 0, 0); } else if (music->load(id)) music->start(); diff --git a/engines/teenagent/teenagent.h b/engines/teenagent/teenagent.h index f34490c2ba..52f41818f1 100644 --- a/engines/teenagent/teenagent.h +++ b/engines/teenagent/teenagent.h @@ -23,12 +23,13 @@ #define TEENAGENT_ENGINE_H #include "engines/engine.h" -#include "teenagent/pack.h" -#include "teenagent/resources.h" -#include "teenagent/inventory.h" + #include "audio/audiostream.h" #include "audio/mixer.h" + #include "common/random.h" +#include "common/rect.h" +#include "common/array.h" struct ADGameDescription; @@ -43,9 +44,27 @@ struct ADGameDescription; namespace TeenAgent { struct Object; +struct UseHotspot; class Scene; class MusicPlayer; class Console; +class Resources; +class Inventory; + +// Engine Debug Flags +enum { + kDebugActor = (1 << 0), + kDebugAnimation = (1 << 1), + kDebugCallbacks = (1 << 2), + kDebugDialog = (1 << 3), + kDebugFont = (1 << 4), + kDebugInventory = (1 << 5), + kDebugMusic = (1 << 6), + kDebugObject = (1 << 7), + kDebugPack = (1 << 8), + kDebugScene = (1 << 9), + kDebugSurface = (1 << 10) +}; class TeenAgentEngine : public Engine { public: |