From d1b9002bb07bc671ab0e34e4c9c5b7f92d0a4843 Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Sun, 8 Jul 2007 19:56:12 +0000 Subject: Cleanup inventory code. svn-id: r27974 --- engines/parallaction/dialogue.cpp | 2 +- engines/parallaction/inventory.cpp | 59 +++++++++++++---------------------- engines/parallaction/inventory.h | 3 +- engines/parallaction/parallaction.cpp | 2 +- engines/parallaction/saveload.cpp | 2 +- 5 files changed, 26 insertions(+), 42 deletions(-) (limited to 'engines') diff --git a/engines/parallaction/dialogue.cpp b/engines/parallaction/dialogue.cpp index 7d2224164a..786ff52721 100644 --- a/engines/parallaction/dialogue.cpp +++ b/engines/parallaction/dialogue.cpp @@ -497,7 +497,7 @@ void Parallaction::runDialogue(SpeakData *data) { DialogueManager man(this, data); man.run(); - refreshInventory(_characterName); + refreshInventory(); showCursor(true); return; diff --git a/engines/parallaction/inventory.cpp b/engines/parallaction/inventory.cpp index 3581b956a6..44fdc2a1ba 100644 --- a/engines/parallaction/inventory.cpp +++ b/engines/parallaction/inventory.cpp @@ -91,31 +91,34 @@ InventoryItem _inventory[INVENTORY_MAX_ITEMS] = { void drawInventoryItem(uint16 pos, InventoryItem *item); +int16 getNumUsedSlots() { + int16 num = 0; + while (num < INVENTORY_MAX_ITEMS && _inventory[num]._id != 0) + num++; + return num; +} + // get inventory item index at position (x,y) // in screen coordinates // int16 Parallaction::getHoverInventoryItem(int16 x, int16 y) { - int16 slot = -1; - do { - slot++; - } while (_inventory[slot]._id != 0); - + int16 slot = getNumUsedSlots(); slot = (slot + 4) / INVENTORY_ITEMS_PER_LINE; - if (_invPosition.x >= x) return -1; - if ((_invPosition.x + INVENTORY_WIDTH) <= x) return -1; + Common::Rect r(INVENTORY_WIDTH, _numInvLines * INVENTORYITEM_HEIGHT); + r.moveTo(_invPosition); - if (_invPosition.y >= y) return -1; - if ((slot * INVENTORYITEM_HEIGHT + _invPosition.y) <= y) return -1; + if (!r.contains(Common::Point(x,y))) + return -1; return ((x - _invPosition.x) / INVENTORYITEM_WIDTH) + (INVENTORY_ITEMS_PER_LINE * ((y - _invPosition.y) / INVENTORYITEM_HEIGHT)); } -void refreshInventory(const char *character) { +void refreshInventory() { for (uint16 i = 0; i < INVENTORY_MAX_ITEMS; i++) { drawInventoryItem(i, &_inventory[i]); } @@ -123,24 +126,21 @@ void refreshInventory(const char *character) { } -void refreshInventoryItem(const char *character, uint16 index) { +void refreshInventoryItem(uint16 index) { drawInventoryItem(index, &_inventory[index]); return; } int Parallaction::addInventoryItem(uint16 item) { - uint16 slot = 0; - while (_inventory[slot]._id != 0) - slot++; - + int16 slot = getNumUsedSlots(); if (slot == INVENTORY_MAX_ITEMS) return -1; _inventory[slot]._id = MAKE_INVENTORY_ID(item); _inventory[slot]._index = item; - refreshInventoryItem(_characterName, slot); + refreshInventoryItem(slot); return 0; } @@ -160,7 +160,7 @@ void Parallaction::dropItem(uint16 v) { memcpy(&_inventory[slot], &_inventory[slot+1], sizeof(InventoryItem)); } - refreshInventory(_characterName); + refreshInventory(); return; } @@ -261,9 +261,8 @@ void extractInventoryGraphics(int16 pos, byte *dst) { void jobShowInventory(void *parm, Job *j) { // printf("job_showInventory()..."); - _numInvLines = 0; - while (_inventory[_numInvLines]._id != 0) _numInvLines++; - _numInvLines = (_numInvLines + 4) / INVENTORY_ITEMS_PER_LINE; + int16 slot = getNumUsedSlots(); + _numInvLines = (slot + 4) / INVENTORY_ITEMS_PER_LINE; Common::Rect r(INVENTORY_WIDTH, _numInvLines * INVENTORYITEM_HEIGHT); @@ -308,25 +307,11 @@ void jobHideInventory(void *parm, Job *j) { void openInventory() { _engineFlags |= kEngineInventory; - uint16 slot = 0; - while (_inventory[slot]._id != 0) - slot++; - + int16 slot = getNumUsedSlots(); uint16 lines = (slot + 4) / INVENTORY_ITEMS_PER_LINE; - _invPosition.x = _vm->_mousePos.x - (INVENTORY_WIDTH / 2); - if (_invPosition.x < 0) - _invPosition.x = 0; - - if ((_invPosition.x + INVENTORY_WIDTH) > SCREEN_WIDTH) - _invPosition.x = SCREEN_WIDTH - INVENTORY_WIDTH; - - _invPosition.y = _vm->_mousePos.y - 2 - (lines * INVENTORYITEM_HEIGHT); - if (_invPosition.y < 0) - _invPosition.y = 0; - - if (_invPosition.y > SCREEN_HEIGHT - lines * INVENTORYITEM_HEIGHT) - _invPosition.y = SCREEN_HEIGHT - lines * INVENTORYITEM_HEIGHT; + _invPosition.x = CLIP(_vm->_mousePos.x - (INVENTORY_WIDTH / 2), 0, SCREEN_WIDTH - INVENTORY_WIDTH); + _invPosition.y = CLIP(_vm->_mousePos.y - 2 - (lines * INVENTORYITEM_HEIGHT), 0, SCREEN_HEIGHT - lines * INVENTORYITEM_HEIGHT); return; diff --git a/engines/parallaction/inventory.h b/engines/parallaction/inventory.h index 0f798ca502..a88f835277 100644 --- a/engines/parallaction/inventory.h +++ b/engines/parallaction/inventory.h @@ -47,12 +47,11 @@ void initInventory(); void destroyInventory(); void openInventory(); void closeInventory(); -int16 isItemInInventory(int32 v); void cleanInventory(); void addInventoryItem(uint16 item); void highlightInventoryItem(int16 pos, byte color); -void refreshInventory(const char *character); +void refreshInventory(); void extractInventoryGraphics(int16 pos, byte *dst); diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp index c830b575a9..cf17d19058 100644 --- a/engines/parallaction/parallaction.cpp +++ b/engines/parallaction/parallaction.cpp @@ -774,7 +774,7 @@ void Parallaction::changeCharacter(const char *name) { _vm->_char._talk = _disk->loadTalk(baseName); _vm->_char._objs = _disk->loadObjects(baseName); _objectsNames = _disk->loadTable(baseName); - refreshInventory(baseName); + refreshInventory(); _soundMan->playCharacterMusic(name); diff --git a/engines/parallaction/saveload.cpp b/engines/parallaction/saveload.cpp index 2a9431ef94..feb37ec50d 100644 --- a/engines/parallaction/saveload.cpp +++ b/engines/parallaction/saveload.cpp @@ -238,7 +238,7 @@ void Parallaction::doSaveGame(uint16 slot, const char* name) { delete f; - refreshInventory(_characterName); + refreshInventory(); return; -- cgit v1.2.3 From a641ee4fbe8b82333131bdde1b25a9b7593440cf Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Sun, 8 Jul 2007 20:15:43 +0000 Subject: Changed inventory graphics update from synchronous to lazy. svn-id: r27975 --- engines/parallaction/dialogue.cpp | 1 - engines/parallaction/inventory.cpp | 55 +++++++++++++++-------------------- engines/parallaction/inventory.h | 1 - engines/parallaction/parallaction.cpp | 1 - engines/parallaction/saveload.cpp | 6 ---- 5 files changed, 24 insertions(+), 40 deletions(-) (limited to 'engines') diff --git a/engines/parallaction/dialogue.cpp b/engines/parallaction/dialogue.cpp index 786ff52721..d5000773de 100644 --- a/engines/parallaction/dialogue.cpp +++ b/engines/parallaction/dialogue.cpp @@ -497,7 +497,6 @@ void Parallaction::runDialogue(SpeakData *data) { DialogueManager man(this, data); man.run(); - refreshInventory(); showCursor(true); return; diff --git a/engines/parallaction/inventory.cpp b/engines/parallaction/inventory.cpp index 44fdc2a1ba..d45b831a23 100644 --- a/engines/parallaction/inventory.cpp +++ b/engines/parallaction/inventory.cpp @@ -117,17 +117,30 @@ int16 Parallaction::getHoverInventoryItem(int16 x, int16 y) { } +void drawInventoryItem(uint16 pos, InventoryItem *item) { -void refreshInventory() { - for (uint16 i = 0; i < INVENTORY_MAX_ITEMS; i++) { - drawInventoryItem(i, &_inventory[i]); + uint16 line = pos / INVENTORY_ITEMS_PER_LINE; + uint16 col = pos % INVENTORY_ITEMS_PER_LINE; + + // FIXME: this will end up in a general blit function + byte* s = _vm->_char._objs->getFramePtr(item->_index); + byte* d = _buffer + col * INVENTORYITEM_WIDTH + line * _vm->_char._objs->_height * INVENTORY_WIDTH; + for (uint32 i = 0; i < INVENTORYITEM_HEIGHT; i++) { + memcpy(d, s, INVENTORYITEM_WIDTH); + + d += INVENTORY_WIDTH; + s += INVENTORYITEM_PITCH; } + return; } -void refreshInventoryItem(uint16 index) { - drawInventoryItem(index, &_inventory[index]); + +void refreshInventory() { + for (uint16 i = 0; i < INVENTORY_MAX_ITEMS; i++) + drawInventoryItem(i, &_inventory[i]); + return; } @@ -140,8 +153,6 @@ int Parallaction::addInventoryItem(uint16 item) { _inventory[slot]._id = MAKE_INVENTORY_ID(item); _inventory[slot]._index = item; - refreshInventoryItem(slot); - return 0; } @@ -160,8 +171,6 @@ void Parallaction::dropItem(uint16 v) { memcpy(&_inventory[slot], &_inventory[slot+1], sizeof(InventoryItem)); } - refreshInventory(); - return; } @@ -177,28 +186,6 @@ int16 Parallaction::isItemInInventory(int32 v) { } - - - - -void drawInventoryItem(uint16 pos, InventoryItem *item) { - - uint16 line = pos / INVENTORY_ITEMS_PER_LINE; - uint16 col = pos % INVENTORY_ITEMS_PER_LINE; - - // FIXME: this will end up in a general blit function - byte* s = _vm->_char._objs->getFramePtr(item->_index); - byte* d = _buffer + col * INVENTORYITEM_WIDTH + line * _vm->_char._objs->_height * INVENTORY_WIDTH; - for (uint32 i = 0; i < INVENTORYITEM_HEIGHT; i++) { - memcpy(d, s, INVENTORYITEM_WIDTH); - - d += INVENTORY_WIDTH; - s += INVENTORYITEM_PITCH; - } - - return; -} - void drawBorder(const Common::Rect& r, byte *buffer, byte color) { byte *d = buffer + r.left + INVENTORY_WIDTH * r.top; @@ -242,6 +229,10 @@ void highlightInventoryItem(int16 pos, byte color) { void extractInventoryGraphics(int16 pos, byte *dst) { // printf("extractInventoryGraphics(%i)\n", pos); + // NOTE: this refresh is needed because we are reading graphics data from the + // inventory buffer instead than from the inventory icons storage. + refreshInventory(); + int16 line = pos / INVENTORY_ITEMS_PER_LINE; int16 col = pos % INVENTORY_ITEMS_PER_LINE; @@ -313,6 +304,8 @@ void openInventory() { _invPosition.x = CLIP(_vm->_mousePos.x - (INVENTORY_WIDTH / 2), 0, SCREEN_WIDTH - INVENTORY_WIDTH); _invPosition.y = CLIP(_vm->_mousePos.y - 2 - (lines * INVENTORYITEM_HEIGHT), 0, SCREEN_HEIGHT - lines * INVENTORYITEM_HEIGHT); + refreshInventory(); + return; } diff --git a/engines/parallaction/inventory.h b/engines/parallaction/inventory.h index a88f835277..7b2e93efa7 100644 --- a/engines/parallaction/inventory.h +++ b/engines/parallaction/inventory.h @@ -51,7 +51,6 @@ void cleanInventory(); void addInventoryItem(uint16 item); void highlightInventoryItem(int16 pos, byte color); -void refreshInventory(); void extractInventoryGraphics(int16 pos, byte *dst); diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp index cf17d19058..15601eaedf 100644 --- a/engines/parallaction/parallaction.cpp +++ b/engines/parallaction/parallaction.cpp @@ -774,7 +774,6 @@ void Parallaction::changeCharacter(const char *name) { _vm->_char._talk = _disk->loadTalk(baseName); _vm->_char._objs = _disk->loadObjects(baseName); _objectsNames = _disk->loadTable(baseName); - refreshInventory(); _soundMan->playCharacterMusic(name); diff --git a/engines/parallaction/saveload.cpp b/engines/parallaction/saveload.cpp index feb37ec50d..279dbda1b9 100644 --- a/engines/parallaction/saveload.cpp +++ b/engines/parallaction/saveload.cpp @@ -166,8 +166,6 @@ void Parallaction::doLoadGame(uint16 slot) { // freeTable(_objectsNames); // initTable(filename, _objectsNames); -// refreshInventory(_vm->_characterName); - // parseLocation("common"); // force reload of character to solve inventory @@ -238,11 +236,7 @@ void Parallaction::doSaveGame(uint16 slot, const char* name) { delete f; - refreshInventory(); - return; - - } enum { -- cgit v1.2.3 From 697f945e002246226631e8734fb01d96736fd770 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 8 Jul 2007 20:46:21 +0000 Subject: Reverted commit 27948. Cutaways in sfScriptGotoScene are cleared by calling clearcutaway directly again, as calling it using an event does not clear the cutaway when it should (which caused problems in the character selection screen) svn-id: r27976 --- engines/saga/sfuncs.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'engines') diff --git a/engines/saga/sfuncs.cpp b/engines/saga/sfuncs.cpp index 4954188a6e..4b30d0b406 100644 --- a/engines/saga/sfuncs.cpp +++ b/engines/saga/sfuncs.cpp @@ -565,13 +565,7 @@ void Script::sfScriptGotoScene(SCRIPTFUNC_PARAMS) { // Since it doesn't look like the IHNM scripts remove the // cutaway after the intro, this is probably the best place to // to it. - Event event; - event.type = kEvTImmediate; - event.code = kCutawayEvent; - event.op = kEventClear; - event.time = 0; - event.duration = 0; - _vm->_events->queue(&event); + _vm->_anim->clearCutaway(); } // It is possible to leave scene when converse panel is on, -- cgit v1.2.3 From dd40c72327b707915a9bdea8edf41bbb8b5d66de Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sun, 8 Jul 2007 21:25:09 +0000 Subject: cleanup svn-id: r27977 --- engines/scumm/charset.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/scumm/charset.cpp b/engines/scumm/charset.cpp index 28012e5759..40637ec4b3 100644 --- a/engines/scumm/charset.cpp +++ b/engines/scumm/charset.cpp @@ -1261,7 +1261,7 @@ void CharsetRendererV3::printChar(int chr, bool ignoreCharsetMask) { dst = vs->getPixels(_left, drawTop); drawBits1(*vs, dst, charPtr, drawTop, origWidth, origHeight); } else { - dst = (byte *)_vm->_textSurface.pixels + _top * _vm->_textSurface.pitch + _left; + dst = (byte *)_vm->_textSurface.getBasePtr(_left, _top); drawBits1(_vm->_textSurface, dst, charPtr, drawTop, origWidth, origHeight); } -- cgit v1.2.3 From 3762bcdfe1c421eee1c45995d11a5b5016a3f2fd Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sun, 8 Jul 2007 21:39:46 +0000 Subject: correct typo svn-id: r27978 --- engines/scumm/scumm.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index 2140b15544..3024f7d900 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -480,7 +480,7 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr) _renderMode = Common::kRenderDefault; } - // Do some render mode restirctions + // Check some render mode restrictions if (_game.version <= 1) _renderMode = Common::kRenderDefault; -- cgit v1.2.3 From 14244685f3674f156a202dcb87bc3c01678e12f2 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sun, 8 Jul 2007 21:42:39 +0000 Subject: SCUMM: hercules gfx code cleanup svn-id: r27979 --- engines/scumm/gfx.cpp | 65 +++++++++++++++++++++++---------------------------- engines/scumm/scumm.h | 1 - 2 files changed, 29 insertions(+), 37 deletions(-) (limited to 'engines') diff --git a/engines/scumm/gfx.cpp b/engines/scumm/gfx.cpp index 3547986ce3..31f1ea3937 100644 --- a/engines/scumm/gfx.cpp +++ b/engines/scumm/gfx.cpp @@ -47,6 +47,7 @@ static void fill(byte *dst, int dstPitch, byte color, int w, int h); static void copy8Col(byte *dst, int dstPitch, const byte *src, int height); static void clear8Col(byte *dst, int dstPitch, int height); +static void ditherHerc(byte *src, byte *hercbuf, int srcPitch, int *x, int *y, int *width, int *height); struct StripTable { int offsets[160]; @@ -535,21 +536,19 @@ void ScummEngine::updateDirtyScreen(VirtScreenNumber slot) { */ void ScummEngine::drawStripToScreen(VirtScreen *vs, int x, int width, int top, int bottom) { - if (bottom <= top) + // Short-circuit if nothing has to be drawn + if (bottom <= top || top >= vs->h) return; - if (top >= vs->h) - return; - - assert(top >= 0 && bottom <= vs->h); // Paranoia checks + // Some paranoia checks + assert(top >= 0 && bottom <= vs->h); assert(x >= 0 && width <= vs->pitch); assert(_textSurface.pixels); assert(_compositeBuf); + // Perform some clipping if (width > vs->w - x) width = vs->w - x; - - // Clip to the visible part of the scene if (top < _screenTop) top = _screenTop; if (bottom > _screenTop + _screenHeight) @@ -559,7 +558,7 @@ void ScummEngine::drawStripToScreen(VirtScreen *vs, int x, int width, int top, i int y = vs->topline + top - _screenTop; int height = bottom - top; - if (height <= 0 || width <= 0) + if (width <= 0) return; // Compute screen etc. buffer pointers @@ -591,15 +590,15 @@ void ScummEngine::drawStripToScreen(VirtScreen *vs, int x, int width, int top, i blit(dst, _screenWidth, src, vs->pitch, width, height); } - if (_renderMode == Common::kRenderCGA) - ditherCGA(_compositeBuf + x + y * _screenWidth, _screenWidth, x, y, width, height); - if (_renderMode == Common::kRenderHercA || _renderMode == Common::kRenderHercG) { ditherHerc(_compositeBuf + x + y * _screenWidth, _herculesBuf, _screenWidth, &x, &y, &width, &height); // center image on the screen - _system->copyRectToScreen(_herculesBuf + x + y * Common::kHercW, - Common::kHercW, x + (Common::kHercW - _screenWidth * 2) / 2, y, width, height); + _system->copyRectToScreen(_herculesBuf + x + y * Common::kHercW, Common::kHercW, + x + (Common::kHercW - _screenWidth * 2) / 2, y, width, height); } else { + if (_renderMode == Common::kRenderCGA) + ditherCGA(_compositeBuf + x + y * _screenWidth, _screenWidth, x, y, width, height); + // Finally blit the whole thing to the screen int x1 = x; @@ -644,10 +643,10 @@ void ScummEngine::ditherCGA(byte *dst, int dstPitch, int x, int y, int width, in for (int y1 = 0; y1 < height; y1++) { ptr = dst + y1 * dstPitch; - idx1 = (y + y1) % 2; - if (_game.version == 2) idx1 = 0; + else + idx1 = (y + y1) % 2; for (int x1 = 0; x1 < width; x1++) { idx2 = (x + x1) % 2; @@ -666,40 +665,34 @@ void ScummEngine::ditherCGA(byte *dst, int dstPitch, int x, int y, int width, in // dd cccc0 // cccc1 // dddd0 -void ScummEngine::ditherHerc(byte *src, byte *hercbuf, int srcPitch, int *x, int *y, int *width, int *height) const { +void ditherHerc(byte *src, byte *hercbuf, int srcPitch, int *x, int *y, int *width, int *height) { byte *srcptr, *dstptr; - int xo = *x, yo = *y, widtho = *width, heighto = *height; - int idx1, idx2, dsty = 0, y1; + const int xo = *x, yo = *y, widtho = *width, heighto = *height; + int dsty = yo*2 - yo/4; - // calculate dsty - for (y1 = 0; y1 < yo; y1++) { - dsty += 2; - if (y1 % 4 == 3) - dsty--; - } - *y = dsty; - *x *= 2; - *width *= 2; - *height = 0; + for (int y1 = 0; y1 < heighto;) { + assert(dsty < Common::kHercH); - for (y1 = 0; y1 < heighto;) { srcptr = src + y1 * srcPitch; dstptr = hercbuf + dsty * Common::kHercW + xo * 2; - assert(dstptr < hercbuf + Common::kHercW * Common::kHercH + widtho * 2); - - idx1 = (dsty % 7) % 2; + const int idx1 = (dsty % 7) % 2; for (int x1 = 0; x1 < widtho; x1++) { - idx2 = (xo + x1) % 2; - *dstptr++ = cgaDither[idx1][idx2][*srcptr & 0xF] >> 1; - *dstptr++ = cgaDither[idx1][idx2][*srcptr & 0xF] & 0x1; + const int idx2 = (xo + x1) % 2; + const byte tmp = cgaDither[idx1][idx2][*srcptr & 0xF]; + *dstptr++ = tmp >> 1; + *dstptr++ = tmp & 0x1; srcptr++; } if (idx1 || dsty % 7 == 6) y1++; dsty++; - (*height)++; } + + *x *= 2; + *y = yo*2 - yo/4; + *width *= 2; + *height = dsty - *y; } diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h index 4146846856..438797a018 100644 --- a/engines/scumm/scumm.h +++ b/engines/scumm/scumm.h @@ -1030,7 +1030,6 @@ protected: void updateDirtyScreen(VirtScreenNumber slot); void drawStripToScreen(VirtScreen *vs, int x, int w, int t, int b); void ditherCGA(byte *dst, int dstPitch, int x, int y, int width, int height) const; - void ditherHerc(byte *src, byte *hercbuf, int srcPitch, int *x, int *y, int *width, int *height) const; public: VirtScreen *findVirtScreen(int y); -- cgit v1.2.3 From 0a662bfb7e057b0d5302a78687387543836c8c32 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sun, 8 Jul 2007 22:13:50 +0000 Subject: cleanup in ScummEngine::drawStripToScreen; in particular, the code is now more efficient for The Dig, FT and COMI svn-id: r27980 --- engines/scumm/gfx.cpp | 78 ++++++++++++++++++++++++++++--------------------- engines/scumm/scumm.cpp | 6 +++- 2 files changed, 49 insertions(+), 35 deletions(-) (limited to 'engines') diff --git a/engines/scumm/gfx.cpp b/engines/scumm/gfx.cpp index 31f1ea3937..9306c8eac7 100644 --- a/engines/scumm/gfx.cpp +++ b/engines/scumm/gfx.cpp @@ -544,7 +544,6 @@ void ScummEngine::drawStripToScreen(VirtScreen *vs, int x, int width, int top, i assert(top >= 0 && bottom <= vs->h); assert(x >= 0 && width <= vs->pitch); assert(_textSurface.pixels); - assert(_compositeBuf); // Perform some clipping if (width > vs->w - x) @@ -561,17 +560,26 @@ void ScummEngine::drawStripToScreen(VirtScreen *vs, int x, int width, int top, i if (width <= 0) return; - // Compute screen etc. buffer pointers const byte *src = vs->getPixels(x, top); - byte *dst = _compositeBuf + x + y * _screenWidth; - if (_game.version < 7) { - // Handle the text mask in older games; newer (V7/V8) games do not use it anymore. + if (_game.version >= 7) { + // For The Dig, FT and COMI, we just blit everything to the screen at once. + _system->copyRectToScreen(src, vs->pitch, x, y, width, height); + + } else { + // For older games, things are more complicated. First off, we need to + // deal with the _textSurface, which needs to be composited over the + // screen contents. Secondly, a rendering mode might be active, which + // means a filter has to be applied. + + // Compute pointers to the composite buffer and the text surface + assert(_compositeBuf); + byte *dst = _compositeBuf + x + y * _screenWidth; const byte *text = (byte *)_textSurface.getBasePtr(x, y); - + #ifdef __DS__ DS::asmDrawStripToScreen(height, width, text, src, dst, vs->pitch, _screenWidth, _textSurface.pitch); -#else +#else // Compose the text over the game graphics for (int h = 0; h < height; ++h) { for (int w = 0; w < width; ++w) { @@ -585,36 +593,38 @@ void ScummEngine::drawStripToScreen(VirtScreen *vs, int x, int width, int top, i text += _textSurface.pitch; } #endif - } else { - // Just do a simple blit in V7/V8 games. - blit(dst, _screenWidth, src, vs->pitch, width, height); - } - if (_renderMode == Common::kRenderHercA || _renderMode == Common::kRenderHercG) { - ditherHerc(_compositeBuf + x + y * _screenWidth, _herculesBuf, _screenWidth, &x, &y, &width, &height); - // center image on the screen - _system->copyRectToScreen(_herculesBuf + x + y * Common::kHercW, Common::kHercW, - x + (Common::kHercW - _screenWidth * 2) / 2, y, width, height); - } else { - if (_renderMode == Common::kRenderCGA) - ditherCGA(_compositeBuf + x + y * _screenWidth, _screenWidth, x, y, width, height); - - // Finally blit the whole thing to the screen - int x1 = x; - - // HACK: This is dirty hack which renders narrow NES rooms centered - // NES can address negative number strips and that poses problem for - // our code. So instead of adding zillions of fixes and potentially - // breaking other games, we shift it right at the rendering stage. - if ((_game.platform == Common::kPlatformNES) && (((_NESStartStrip > 0) && (vs->number == kMainVirtScreen)) || (vs->number == kTextVirtScreen))) { - x += 16; - while (x + width >= _screenWidth) - width -= 16; - if (width < 0) - return; + src = dst = _compositeBuf + x + y * _screenWidth; + int pitch = _screenWidth; + + if (_renderMode == Common::kRenderHercA || _renderMode == Common::kRenderHercG) { + ditherHerc(dst, _herculesBuf, _screenWidth, &x, &y, &width, &height); + + src = _herculesBuf + x + y * Common::kHercW; + pitch = Common::kHercW; + + // center image on the screen + x += (Common::kHercW - _screenWidth * 2) / 2; // (720 - 320*2)/2 = 40 + } else { + if (_renderMode == Common::kRenderCGA) + ditherCGA(dst, _screenWidth, x, y, width, height); + + // HACK: This is dirty hack which renders narrow NES rooms centered + // NES can address negative number strips and that poses problem for + // our code. So instead of adding zillions of fixes and potentially + // breaking other games, we shift it right at the rendering stage. + if ((_game.platform == Common::kPlatformNES) && (((_NESStartStrip > 0) && (vs->number == kMainVirtScreen)) || (vs->number == kTextVirtScreen))) { + x += 16; + while (x + width >= _screenWidth) + width -= 16; + if (width < 0) + return; + } + } - _system->copyRectToScreen(_compositeBuf + x1 + y * _screenWidth, _screenWidth, x, y, width, height); + // Finally blit the whole thing to the screen + _system->copyRectToScreen(src, pitch, x, y, width, height); } } diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index 3024f7d900..f29f1c7970 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -521,7 +521,11 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr) _screenHeight = 200; } - _compositeBuf = (byte *)malloc(_screenWidth * _screenHeight); + // Allocate gfx compositing buffer (not needed for V7/V8 games). + if (_game.version < 7) + _compositeBuf = (byte *)malloc(_screenWidth * _screenHeight); + else + _compositeBuf = 0; _herculesBuf = 0; if (_renderMode == Common::kRenderHercA || _renderMode == Common::kRenderHercG) { -- cgit v1.2.3 From 705c1e8403dc0b96ddfc488c93e2631a146cbb85 Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Mon, 9 Jul 2007 02:27:38 +0000 Subject: Fix masking crash in Simon the Sorcerer 1 (Floppy DOS Demo), the address and pitch wasn't set for state->surf2. svn-id: r27985 --- engines/agos/gfx.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'engines') diff --git a/engines/agos/gfx.cpp b/engines/agos/gfx.cpp index 2b530fdcd6..20ab84d15d 100644 --- a/engines/agos/gfx.cpp +++ b/engines/agos/gfx.cpp @@ -666,6 +666,9 @@ void AGOSEngine_Simon1::drawImage(VC10_state *state) { } else if (getGameType() == GType_SIMON1 && (getFeatures() & GF_DEMO)) { // The DOS Floppy demo was based off Waxworks engine if (_windowNum == 4 || (_windowNum >= 10 && _windowNum <= 27)) { + state->surf2_addr = getBackGround(); + state->surf2_pitch = _screenWidth; + state->surf_addr = _window4BackScn; state->surf_pitch = _videoWindows[18] * 16; -- cgit v1.2.3 From 9782c35eaf4d34a13fae63151ba226d0ed1fd60d Mon Sep 17 00:00:00 2001 From: Max Horn Date: Mon, 9 Jul 2007 09:21:25 +0000 Subject: SCUMM: use the _compositeBuf, with 'natural' line pitch (implying linear memory access for potentially better performance) svn-id: r27988 --- engines/scumm/gfx.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'engines') diff --git a/engines/scumm/gfx.cpp b/engines/scumm/gfx.cpp index 9306c8eac7..540c347ed7 100644 --- a/engines/scumm/gfx.cpp +++ b/engines/scumm/gfx.cpp @@ -572,33 +572,32 @@ void ScummEngine::drawStripToScreen(VirtScreen *vs, int x, int width, int top, i // screen contents. Secondly, a rendering mode might be active, which // means a filter has to be applied. - // Compute pointers to the composite buffer and the text surface + // Compute pointer to the text surface assert(_compositeBuf); - byte *dst = _compositeBuf + x + y * _screenWidth; const byte *text = (byte *)_textSurface.getBasePtr(x, y); #ifdef __DS__ - DS::asmDrawStripToScreen(height, width, text, src, dst, vs->pitch, _screenWidth, _textSurface.pitch); + DS::asmDrawStripToScreen(height, width, text, src, _compositeBuf, vs->pitch, width, _textSurface.pitch); #else // Compose the text over the game graphics + byte *dst = _compositeBuf; for (int h = 0; h < height; ++h) { for (int w = 0; w < width; ++w) { if (text[w] == CHARSET_MASK_TRANSPARENCY) - dst[w] = src[w]; + *dst++ = src[w]; else - dst[w] = text[w]; + *dst++ = text[w]; } src += vs->pitch; - dst += _screenWidth; text += _textSurface.pitch; } #endif - src = dst = _compositeBuf + x + y * _screenWidth; - int pitch = _screenWidth; + src = _compositeBuf; + int pitch = width; if (_renderMode == Common::kRenderHercA || _renderMode == Common::kRenderHercG) { - ditherHerc(dst, _herculesBuf, _screenWidth, &x, &y, &width, &height); + ditherHerc(_compositeBuf, _herculesBuf, width, &x, &y, &width, &height); src = _herculesBuf + x + y * Common::kHercW; pitch = Common::kHercW; @@ -607,7 +606,7 @@ void ScummEngine::drawStripToScreen(VirtScreen *vs, int x, int width, int top, i x += (Common::kHercW - _screenWidth * 2) / 2; // (720 - 320*2)/2 = 40 } else { if (_renderMode == Common::kRenderCGA) - ditherCGA(dst, _screenWidth, x, y, width, height); + ditherCGA(_compositeBuf, width, x, y, width, height); // HACK: This is dirty hack which renders narrow NES rooms centered // NES can address negative number strips and that poses problem for -- cgit v1.2.3 From e10a6e65155deb86812aae4a89190c652b237f4f Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 9 Jul 2007 12:03:53 +0000 Subject: Fix for bug #1746661: "KQ3: Lockup when pressing ESC (Amiga version)" svn-id: r27989 --- engines/agi/agi.h | 3 ++- engines/agi/detection.cpp | 2 +- engines/agi/keyboard.cpp | 2 +- engines/agi/menu.cpp | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/agi/agi.h b/engines/agi/agi.h index 01db2acb23..825d475314 100644 --- a/engines/agi/agi.h +++ b/engines/agi/agi.h @@ -110,7 +110,8 @@ enum AgiGameFeatures { GF_AGI256_2 = (1 << 3), GF_AGIPAL = (1 << 4), GF_MACGOLDRUSH = (1 << 5), - GF_FANMADE = (1 << 6) + GF_FANMADE = (1 << 6), + GF_FORCEMENUS = (1 << 7) }; enum AgiGameID { diff --git a/engines/agi/detection.cpp b/engines/agi/detection.cpp index 29b5bb726a..fce6fa733a 100644 --- a/engines/agi/detection.cpp +++ b/engines/agi/detection.cpp @@ -635,7 +635,7 @@ static const AGIGameDescription gameDescriptions[] = { }, GID_KQ3, GType_V2, - 0, + GF_FORCEMENUS, 0x2440, }, diff --git a/engines/agi/keyboard.cpp b/engines/agi/keyboard.cpp index 3acc81ddff..9fd3700675 100644 --- a/engines/agi/keyboard.cpp +++ b/engines/agi/keyboard.cpp @@ -127,7 +127,7 @@ int AgiEngine::handleController(int key) { } if (key == BUTTON_LEFT) { - if (getflag(fMenusWork) && g_mouse.y <= CHAR_LINES) { + if ((getflag(fMenusWork) || (getFeatures() & GF_FORCEMENUS)) && g_mouse.y <= CHAR_LINES) { newInputMode(INPUT_MENU); return true; } diff --git a/engines/agi/menu.cpp b/engines/agi/menu.cpp index 5edaaf0ded..52e402bf12 100644 --- a/engines/agi/menu.cpp +++ b/engines/agi/menu.cpp @@ -267,7 +267,7 @@ bool Menu::keyhandler(int key) { static int menuActive = false; static int buttonUsed = 0; - if (!_vm->getflag(fMenusWork)) + if (!_vm->getflag(fMenusWork) && !(_vm->getFeatures() & GF_FORCEMENUS)) return false; if (!menuActive) { -- cgit v1.2.3 From 11b43f877d47965773fa9b0f7127cc22f7000db6 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 9 Jul 2007 17:39:47 +0000 Subject: Fix for bug #1742432 - AGI: Engine crashes if no game is detected svn-id: r27993 --- engines/agi/agi.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'engines') diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp index 0839b7de99..61430dcaea 100644 --- a/engines/agi/agi.cpp +++ b/engines/agi/agi.cpp @@ -676,6 +676,13 @@ void AgiEngine::initialize() { } AgiEngine::~AgiEngine() { + // If the engine hasn't been initialized yet via AgiEngine::initialize(), don't attempt to free any resources, + // as they haven't been allocated. Fixes bug #1742432 - AGI: Engine crashes if no game is detected + if (_game.state == STATE_INIT) { + delete _rnd; // delete _rnd, as it is allocated in the constructor, not in initialize() + return; + } + agiDeinit(); _sound->deinitSound(); delete _sound; -- cgit v1.2.3 From 945be6e5f220a92e92cf715c80ee72a108cfe9b6 Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Mon, 9 Jul 2007 19:19:56 +0000 Subject: Moved mouse cursor tampering from inventory.cpp to Gfx class, and some cleanup. svn-id: r27996 --- engines/parallaction/graphics.cpp | 32 ++++++++++++++++++++++++++------ engines/parallaction/graphics.h | 6 ++++++ engines/parallaction/inventory.cpp | 33 ++++++--------------------------- engines/parallaction/inventory.h | 11 +++++++---- 4 files changed, 45 insertions(+), 37 deletions(-) (limited to 'engines') diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp index 59645381b6..51ec65f792 100644 --- a/engines/parallaction/graphics.cpp +++ b/engines/parallaction/graphics.cpp @@ -438,8 +438,8 @@ void Gfx::initMouse(uint16 arg_0) { _mouseComposedArrow = _vm->_disk->loadPointer(); - byte temp[16*16]; - memcpy(temp, _mouseArrow, 16*16); + byte temp[MOUSEARROW_WIDTH*MOUSEARROW_HEIGHT]; + memcpy(temp, _mouseArrow, MOUSEARROW_WIDTH*MOUSEARROW_HEIGHT); uint16 k = 0; for (uint16 i = 0; i < 4; i++) { @@ -449,20 +449,40 @@ void Gfx::initMouse(uint16 arg_0) { return; } +// NOTE: this routine will be moved into Gfx as soon as enough clarity +// is made regarding the field _id and _index of InventoryItem. +// +void extractInventoryGraphics(int16 pos, byte *dst) { +// printf("extractInventoryGraphics(%i)\n", pos); + + + return; +} + + void Gfx::setMousePointer(int16 index) { if (index == kCursorArrow) { // standard mouse pointer - g_system->setMouseCursor(_mouseArrow, 16, 16, 0, 0, 0); + g_system->setMouseCursor(_mouseArrow, MOUSEARROW_WIDTH, MOUSEARROW_HEIGHT, 0, 0, 0); g_system->showMouse(true); } else { // inventory item pointer byte *v8 = _mouseComposedArrow->_data0; - // FIXME: target offseting is not clear - extractInventoryGraphics(index, v8 + 7 + 32 * 7); - g_system->setMouseCursor(v8, 32, 32, 0, 0, 0); + // FIXME: destination offseting is not clear + byte* s = _vm->_char._objs->getFramePtr(getInventoryItemIndex(index)); + byte* d = v8 + 7 + MOUSECOMBO_WIDTH * 7; + + for (uint32 i = 0; i < INVENTORYITEM_HEIGHT; i++) { + memcpy(d, s, INVENTORYITEM_WIDTH); + + s += INVENTORYITEM_PITCH; + d += MOUSECOMBO_WIDTH; + } + + g_system->setMouseCursor(v8, MOUSECOMBO_WIDTH, MOUSECOMBO_HEIGHT, 0, 0, 0); } return; diff --git a/engines/parallaction/graphics.h b/engines/parallaction/graphics.h index d535d3cf05..05b7dac2ec 100644 --- a/engines/parallaction/graphics.h +++ b/engines/parallaction/graphics.h @@ -57,6 +57,12 @@ namespace Parallaction { #define BASE_PALETTE_SIZE BASE_PALETTE_COLORS*3 #define PALETTE_SIZE PALETTE_COLORS*3 +#define MOUSEARROW_WIDTH 16 +#define MOUSEARROW_HEIGHT 16 + +#define MOUSECOMBO_WIDTH 32 // sizes for cursor + selected inventory item +#define MOUSECOMBO_HEIGHT 32 + #include "common/pack-start.h" // START STRUCT PACKING struct PaletteFxRange { diff --git a/engines/parallaction/inventory.cpp b/engines/parallaction/inventory.cpp index d45b831a23..b7ff835dcc 100644 --- a/engines/parallaction/inventory.cpp +++ b/engines/parallaction/inventory.cpp @@ -42,10 +42,6 @@ namespace Parallaction { #define INVENTORY_MAX_ITEMS 30 #define INVENTORY_FIRST_ITEM 4 // first four entries are used up by verbs -#define INVENTORYITEM_PITCH 32 -#define INVENTORYITEM_WIDTH 24 -#define INVENTORYITEM_HEIGHT 24 - #define INVENTORY_ITEMS_PER_LINE 5 #define INVENTORY_LINES 6 @@ -89,7 +85,6 @@ InventoryItem _inventory[INVENTORY_MAX_ITEMS] = { { 0, 0 } }; -void drawInventoryItem(uint16 pos, InventoryItem *item); int16 getNumUsedSlots() { int16 num = 0; @@ -224,30 +219,14 @@ void highlightInventoryItem(int16 pos, byte color) { } +int16 getInventoryItemIndex(int16 pos) { + // TODO: should assert against the number of items actually contained, + // not the theoretical limit. + assert(pos >= 0 && pos < INVENTORY_MAX_ITEMS); + return _inventory[pos]._index; +} -void extractInventoryGraphics(int16 pos, byte *dst) { -// printf("extractInventoryGraphics(%i)\n", pos); - - // NOTE: this refresh is needed because we are reading graphics data from the - // inventory buffer instead than from the inventory icons storage. - refreshInventory(); - - int16 line = pos / INVENTORY_ITEMS_PER_LINE; - int16 col = pos % INVENTORY_ITEMS_PER_LINE; - - // FIXME: this will end up in a general blit function - byte* d = dst; - byte* s = _buffer + col * INVENTORYITEM_WIDTH + line * _vm->_char._objs->_height * INVENTORY_WIDTH; - for (uint32 i = 0; i < INVENTORYITEM_HEIGHT; i++) { - memcpy(d, s, INVENTORYITEM_WIDTH); - - s += INVENTORY_WIDTH; - d += INVENTORYITEM_PITCH; - } - - return; -} void jobShowInventory(void *parm, Job *j) { // printf("job_showInventory()..."); diff --git a/engines/parallaction/inventory.h b/engines/parallaction/inventory.h index 7b2e93efa7..4a3e07cc97 100644 --- a/engines/parallaction/inventory.h +++ b/engines/parallaction/inventory.h @@ -34,10 +34,14 @@ namespace Parallaction { struct Cnv; struct InventoryItem { - uint32 _id; // lowest 16 bits are always zero - uint16 _index; + uint32 _id; // object name (lowest 16 bits are always zero) + uint16 _index; // index to frame in objs file }; +#define INVENTORYITEM_PITCH 32 +#define INVENTORYITEM_WIDTH 24 +#define INVENTORYITEM_HEIGHT 24 + #define MAKE_INVENTORY_ID(x) (((x) & 0xFFFF) << 16) @@ -50,10 +54,9 @@ void closeInventory(); void cleanInventory(); void addInventoryItem(uint16 item); +int16 getInventoryItemIndex(int16 pos); void highlightInventoryItem(int16 pos, byte color); -void extractInventoryGraphics(int16 pos, byte *dst); - } // namespace Parallaction -- cgit v1.2.3 From aaa987201ee15fcb48ad349911e9e41655a001dc Mon Sep 17 00:00:00 2001 From: Max Horn Date: Mon, 9 Jul 2007 21:56:35 +0000 Subject: SCUMM: more cleanup in ScummEngine::drawStripToScreen, added a big TODO comment explaining how to potentially speed up this code a lot svn-id: r27997 --- engines/scumm/gfx.cpp | 47 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 15 deletions(-) (limited to 'engines') diff --git a/engines/scumm/gfx.cpp b/engines/scumm/gfx.cpp index 540c347ed7..c70a0e9351 100644 --- a/engines/scumm/gfx.cpp +++ b/engines/scumm/gfx.cpp @@ -561,12 +561,10 @@ void ScummEngine::drawStripToScreen(VirtScreen *vs, int x, int width, int top, i return; const byte *src = vs->getPixels(x, top); + int pitch = vs->pitch; - if (_game.version >= 7) { + if (_game.version < 7) { // For The Dig, FT and COMI, we just blit everything to the screen at once. - _system->copyRectToScreen(src, vs->pitch, x, y, width, height); - - } else { // For older games, things are more complicated. First off, we need to // deal with the _textSurface, which needs to be composited over the // screen contents. Secondly, a rendering mode might be active, which @@ -576,25 +574,44 @@ void ScummEngine::drawStripToScreen(VirtScreen *vs, int x, int width, int top, i assert(_compositeBuf); const byte *text = (byte *)_textSurface.getBasePtr(x, y); + // The values x, width, etc. are all multiples of 8 at this point, + // so loop unrolloing might be a good idea... + assert(0 == ((int)text & 3)); + assert(0 == (width & 3)); + + // Compose the text over the game graphics + + // TODO: Optimize this code. There are several things that come immediately to mind: + // (1) Loop unrolling: We could read 4 or even 8 pixels at once, since everything is + // a multiple of 8 here. + // (2) More ASM versions (in particular, the ARM code for the NDS could be used on + // all ARM systems, couldn't it?) + // (3) Better encoding of the text surface data. This is the one with the biggest + // potential. + // (a) Keep an "isEmpty" marker for each pixel row in the _textSurface. The idea + // is that most rows won't contain any text data, so we can just use memcpy. + // (b) RLE encode the _textSurface row-wise. This is an improved variant of (a), + // but also more complicated to implement, and incurs a bigger overhead when + // writing to the text surface. #ifdef __DS__ DS::asmDrawStripToScreen(height, width, text, src, _compositeBuf, vs->pitch, width, _textSurface.pitch); #else - // Compose the text over the game graphics byte *dst = _compositeBuf; for (int h = 0; h < height; ++h) { for (int w = 0; w < width; ++w) { - if (text[w] == CHARSET_MASK_TRANSPARENCY) - *dst++ = src[w]; - else - *dst++ = text[w]; + byte tmp = *text++; + if (tmp == CHARSET_MASK_TRANSPARENCY) + tmp = *src; + *dst++ = tmp; + src++; } - src += vs->pitch; - text += _textSurface.pitch; + src += vs->pitch - width; + text += _textSurface.pitch - width; } #endif src = _compositeBuf; - int pitch = width; + pitch = width; if (_renderMode == Common::kRenderHercA || _renderMode == Common::kRenderHercG) { ditherHerc(_compositeBuf, _herculesBuf, width, &x, &y, &width, &height); @@ -621,10 +638,10 @@ void ScummEngine::drawStripToScreen(VirtScreen *vs, int x, int width, int top, i } } - - // Finally blit the whole thing to the screen - _system->copyRectToScreen(src, pitch, x, y, width, height); } + + // Finally blit the whole thing to the screen + _system->copyRectToScreen(src, pitch, x, y, width, height); } // CGA -- cgit v1.2.3 From 1db83059b0a33f910c1d2f78630dccde2dd167b9 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 10 Jul 2007 00:39:12 +0000 Subject: Preliminary (and buggy) Kanji support. svn-id: r27998 --- engines/scumm/charset.cpp | 32 ++++++----- engines/scumm/gfx.cpp | 135 ++++++++++++++++++++++++++++++++++++++-------- engines/scumm/input.cpp | 5 +- engines/scumm/scumm.cpp | 20 +++++-- engines/scumm/scumm.h | 3 ++ 5 files changed, 153 insertions(+), 42 deletions(-) (limited to 'engines') diff --git a/engines/scumm/charset.cpp b/engines/scumm/charset.cpp index 40637ec4b3..86b48c3690 100644 --- a/engines/scumm/charset.cpp +++ b/engines/scumm/charset.cpp @@ -48,6 +48,8 @@ better separation of the various modules. void ScummEngine::loadCJKFont() { Common::File fp; _useCJKMode = false; + _textSurfaceMultiplier = 1; + if (_language == Common::JA_JPN && _game.version <= 5) { // FM-TOWNS v3 / v5 Kanji int numChar = 256 * 32; _2byteWidth = 16; @@ -60,6 +62,7 @@ void ScummEngine::loadCJKFont() { fp.read(_2byteFontPtr, ((_2byteWidth + 7) / 8) * _2byteHeight * numChar); fp.close(); } + _textSurfaceMultiplier = 2; } else if (_language == Common::KO_KOR || _language == Common::JA_JPN || _language == Common::ZH_TWN) { int numChar = 0; const char *fontFile = NULL; @@ -85,6 +88,7 @@ void ScummEngine::loadCJKFont() { if (fontFile && fp.open(fontFile)) { debug(2, "Loading CJK Font"); _useCJKMode = true; + _textSurfaceMultiplier = 1; // No multiplication here fp.seek(2, SEEK_CUR); _2byteWidth = fp.readByte(); _2byteHeight = fp.readByte(); @@ -276,7 +280,7 @@ int CharsetRendererCommon::getFontHeight() { // do spacing for variable width old-style font int CharsetRendererClassic::getCharWidth(byte chr) { if (chr >= 0x80 && _vm->_useCJKMode) - return _vm->_2byteWidth / 2; + return _vm->_2byteWidth; int spacing = 0; int offs = READ_LE_UINT32(_fontPtr + chr * 4 + 4); @@ -1160,7 +1164,7 @@ CharsetRendererV2::CharsetRendererV2(ScummEngine *vm, Common::Language language) int CharsetRendererV3::getCharWidth(byte chr) { if (chr & 0x80 && _vm->_useCJKMode) - return _vm->_2byteWidth / 2; + return _vm->_2byteWidth; int spacing = 0; spacing = *(_widthTable + chr); @@ -1257,18 +1261,18 @@ void CharsetRendererV3::printChar(int chr, bool ignoreCharsetMask) { _hasMask = true; _textScreenID = vs->number; } - if (ignoreCharsetMask || !vs->hasTwoBuffers) { + if ((ignoreCharsetMask || !vs->hasTwoBuffers) && !(_vm->_useCJKMode && _vm->_textSurfaceMultiplier == 2)) { dst = vs->getPixels(_left, drawTop); drawBits1(*vs, dst, charPtr, drawTop, origWidth, origHeight); } else { - dst = (byte *)_vm->_textSurface.getBasePtr(_left, _top); + dst = (byte *)_vm->_textSurface.getBasePtr(_left * _vm->_textSurfaceMultiplier, _top * _vm->_textSurfaceMultiplier); drawBits1(_vm->_textSurface, dst, charPtr, drawTop, origWidth, origHeight); } if (_str.left > _left) _str.left = _left; - _left += origWidth; + _left += origWidth / _vm->_textSurfaceMultiplier; if (_str.right < _left) { _str.right = _left; @@ -1276,8 +1280,8 @@ void CharsetRendererV3::printChar(int chr, bool ignoreCharsetMask) { _str.right++; } - if (_str.bottom < _top + height) - _str.bottom = _top + height; + if (_str.bottom < _top + height / _vm->_textSurfaceMultiplier) + _str.bottom = _top + height / _vm->_textSurfaceMultiplier; } void CharsetRendererV3::drawChar(int chr, const Graphics::Surface &s, int x, int y) { @@ -1391,8 +1395,8 @@ void CharsetRendererClassic::printChar(int chr, bool ignoreCharsetMask) { _top += offsY; _left += offsX; - if (_left + origWidth > _right + 1 || _left < 0) { - _left += origWidth; + if (_left + origWidth / _vm->_textSurfaceMultiplier > _right + 1 || _left < 0) { + _left += origWidth / _vm->_textSurfaceMultiplier; _top -= offsY; return; } @@ -1424,7 +1428,7 @@ void CharsetRendererClassic::printChar(int chr, bool ignoreCharsetMask) { printCharIntern(is2byte, charPtr, origWidth, origHeight, width, height, vs, ignoreCharsetMask); - _left += origWidth; + _left += origWidth / _vm->_textSurfaceMultiplier; if (_str.right < _left) { _str.right = _left; @@ -1432,8 +1436,8 @@ void CharsetRendererClassic::printChar(int chr, bool ignoreCharsetMask) { _str.right++; } - if (_str.bottom < _top + height) - _str.bottom = _top + height; + if (_str.bottom < _top + height / _vm->_textSurfaceMultiplier) + _str.bottom = _top + height / _vm->_textSurfaceMultiplier; _top -= offsY; } @@ -1473,12 +1477,12 @@ void CharsetRendererClassic::printCharIntern(bool is2byte, const byte *charPtr, } else { Graphics::Surface dstSurface; Graphics::Surface backSurface; - if (ignoreCharsetMask || !vs->hasTwoBuffers) { + if ((ignoreCharsetMask || !vs->hasTwoBuffers) && !(_vm->_useCJKMode && _vm->_textSurfaceMultiplier == 2)) { dstSurface = *vs; dstPtr = vs->getPixels(_left, drawTop); } else { dstSurface = _vm->_textSurface; - dstPtr = (byte *)_vm->_textSurface.pixels + (_top - _vm->_screenTop) * _vm->_textSurface.pitch + _left; + dstPtr = (byte *)_vm->_textSurface.pixels + (_top - _vm->_screenTop) * _vm->_textSurface.pitch * _vm->_textSurfaceMultiplier + _left * _vm->_textSurfaceMultiplier; } if (_blitAlso && vs->hasTwoBuffers) { diff --git a/engines/scumm/gfx.cpp b/engines/scumm/gfx.cpp index c70a0e9351..3c6f57be1a 100644 --- a/engines/scumm/gfx.cpp +++ b/engines/scumm/gfx.cpp @@ -561,8 +561,25 @@ void ScummEngine::drawStripToScreen(VirtScreen *vs, int x, int width, int top, i return; const byte *src = vs->getPixels(x, top); + int m = _textSurfaceMultiplier; + byte *dst; + int vsPitch; int pitch = vs->pitch; + if (_useCJKMode && _textSurfaceMultiplier == 2) { + dst = _fmtownsBuf; + + scale2x(dst, _screenWidth * m, src, vs->pitch, width, height); + src = dst; + + vsPitch = _screenWidth * m - width * m; + + } else { + vsPitch = vs->pitch - width; + } + + dst = _compositeBuf; + if (_game.version < 7) { // For The Dig, FT and COMI, we just blit everything to the screen at once. // For older games, things are more complicated. First off, we need to @@ -572,7 +589,7 @@ void ScummEngine::drawStripToScreen(VirtScreen *vs, int x, int width, int top, i // Compute pointer to the text surface assert(_compositeBuf); - const byte *text = (byte *)_textSurface.getBasePtr(x, y); + const byte *text = (byte *)_textSurface.getBasePtr(x * m, y * m); // The values x, width, etc. are all multiples of 8 at this point, // so loop unrolloing might be a good idea... @@ -594,19 +611,18 @@ void ScummEngine::drawStripToScreen(VirtScreen *vs, int x, int width, int top, i // but also more complicated to implement, and incurs a bigger overhead when // writing to the text surface. #ifdef __DS__ - DS::asmDrawStripToScreen(height, width, text, src, _compositeBuf, vs->pitch, width, _textSurface.pitch); + DS::asmDrawStripToScreen(height, width, text, src, dst, vs->pitch, width, _textSurface.pitch); #else - byte *dst = _compositeBuf; - for (int h = 0; h < height; ++h) { - for (int w = 0; w < width; ++w) { + for (int h = 0; h < height * m; ++h) { + for (int w = 0; w < width * m; ++w) { byte tmp = *text++; if (tmp == CHARSET_MASK_TRANSPARENCY) tmp = *src; *dst++ = tmp; src++; } - src += vs->pitch - width; - text += _textSurface.pitch - width; + src += vsPitch; + text += _textSurface.pitch - width * m; } #endif @@ -621,6 +637,12 @@ void ScummEngine::drawStripToScreen(VirtScreen *vs, int x, int width, int top, i // center image on the screen x += (Common::kHercW - _screenWidth * 2) / 2; // (720 - 320*2)/2 = 40 + } else if (_useCJKMode && m == 2) { + pitch *= m; + x *= m; + y *= m; + width *= m; + height *= m; } else { if (_renderMode == Common::kRenderCGA) ditherCGA(_compositeBuf, width, x, y, width, height); @@ -721,6 +743,25 @@ void ditherHerc(byte *src, byte *hercbuf, int srcPitch, int *x, int *y, int *wid *height = dsty - *y; } +void ScummEngine::scale2x(byte *dst, int dstPitch, const byte *src, int srcPitch, int w, int h) { + byte *dstL1 = dst; + byte *dstL2 = dst + dstPitch; + + int dstAdd = dstPitch * 2 - w * 2; + int srcAdd = srcPitch - w; + + while (h--) { + for (int x = 0; x < w; ++x, dstL1 += 2, dstL2 += 2) { + uint16 col = *src++; + col |= col << 8; + *(uint16*)(dstL1) = col; + *(uint16*)(dstL2) = col; + } + dstL1 += dstAdd; dstL2 += dstAdd; + src += srcAdd; + } +} + #pragma mark - #pragma mark --- Background buffers & charset mask --- @@ -1117,8 +1158,8 @@ void ScummEngine::drawBox(int x, int y, int x2, int y2, int color) { error("can only copy bg to main window"); blit(backbuff, vs->pitch, bgbuff, vs->pitch, width, height); if (_charset->_hasMask) { - byte *mask = (byte *)_textSurface.getBasePtr(x, y - _screenTop); - fill(mask, _textSurface.pitch, CHARSET_MASK_TRANSPARENCY, width, height); + byte *mask = (byte *)_textSurface.getBasePtr(x * _textSurfaceMultiplier, (y - _screenTop) * _textSurfaceMultiplier); + fill(mask, _textSurface.pitch, CHARSET_MASK_TRANSPARENCY, width * _textSurfaceMultiplier, height * _textSurfaceMultiplier); } } else if (_game.heversion >= 71) { // Flags are used for different methods in HE games @@ -3362,7 +3403,17 @@ void ScummEngine::dissolveEffect(int width, int height) { for (i = 0; i < w * h; i++) { x = offsets[i] % vs->pitch; y = offsets[i] / vs->pitch; - _system->copyRectToScreen(vs->getPixels(x, y), vs->pitch, x, y + vs->topline, width, height); + + if (_useCJKMode && _textSurfaceMultiplier == 2) { + int m = _textSurfaceMultiplier; + byte *dst = _fmtownsBuf + x * m + y * m * _screenWidth * m; + scale2x(dst, _screenWidth * m, vs->getPixels(x, y), vs->pitch, width, height); + + _system->copyRectToScreen(dst, _screenWidth * m, x * m, (y + vs->topline) * m, width * m, height * m); + } else { + _system->copyRectToScreen(vs->getPixels(x, y), vs->pitch, x, y + vs->topline, width, height); + } + if (++blits >= blits_before_refresh) { blits = 0; @@ -3391,16 +3442,30 @@ void ScummEngine::scrollEffect(int dir) { step = (step * delay) / kScrolltime; + byte *src; + int m = _textSurfaceMultiplier; + int vsPitch = vs->pitch; + switch (dir) { case 0: //up y = 1 + step; while (y < vs->h) { moveScreen(0, -step, vs->h); - _system->copyRectToScreen(vs->getPixels(0, y - step), - vs->pitch, - 0, vs->h - step, - vs->w, step); + + src = vs->getPixels(0, y - step); + if (_useCJKMode && m == 2) { + int x1 = 0, y1 = vs->h - step; + byte *dst = _fmtownsBuf + x1 * m + y1 * m * _screenWidth * m; + scale2x(dst, _screenWidth * m, src, vs->pitch, vs->w, step); + src = dst; + vsPitch = _screenWidth * 2; + } + + _system->copyRectToScreen(src, + vsPitch, + 0 * m, (vs->h - step) * m, + vs->w * m, step * m); _system->updateScreen(); waitForTimer(delay); @@ -3412,10 +3477,18 @@ void ScummEngine::scrollEffect(int dir) { y = 1 + step; while (y < vs->h) { moveScreen(0, step, vs->h); - _system->copyRectToScreen(vs->getPixels(0, vs->h - y), - vs->pitch, + src = vs->getPixels(0, vs->h - y); + if (_useCJKMode && m == 2) { + int x1 = 0, y1 = 0; + byte *dst = _fmtownsBuf + x1 * m + y1 * m * _screenWidth * m; + scale2x(dst, _screenWidth * m, src, vs->pitch, vs->w, step); + src = dst; + vsPitch = _screenWidth * 2; + } + _system->copyRectToScreen(src, + vsPitch, 0, 0, - vs->w, step); + vs->w * m, step * m); _system->updateScreen(); waitForTimer(delay); @@ -3427,10 +3500,18 @@ void ScummEngine::scrollEffect(int dir) { x = 1 + step; while (x < vs->w) { moveScreen(-step, 0, vs->h); - _system->copyRectToScreen(vs->getPixels(x - step, 0), - vs->pitch, - vs->w - step, 0, - step, vs->h); + src = vs->getPixels(x - step, 0); + if (_useCJKMode && m == 2) { + int x1 = vs->w - step, y1 = 0; + byte *dst = _fmtownsBuf + x1 * m + y1 * m * _screenWidth * m; + scale2x(dst, _screenWidth * m, src, vs->pitch, step, vs->h); + src = dst; + vsPitch = _screenWidth * 2; + } + _system->copyRectToScreen(src, + vsPitch, + (vs->w - step) * m, 0, + step * m, vs->h * m); _system->updateScreen(); waitForTimer(delay); @@ -3442,8 +3523,16 @@ void ScummEngine::scrollEffect(int dir) { x = 1 + step; while (x < vs->w) { moveScreen(step, 0, vs->h); - _system->copyRectToScreen(vs->getPixels(vs->w - x, 0), - vs->pitch, + src = vs->getPixels(vs->w - x, 0); + if (_useCJKMode && m == 2) { + int x1 = 0, y1 = 0; + byte *dst = _fmtownsBuf + x1 * m + y1 * m * _screenWidth * m; + scale2x(dst, _screenWidth * m, src, vs->pitch, step, vs->h); + src = dst; + vsPitch = _screenWidth * 2; + } + _system->copyRectToScreen(src, + vsPitch, 0, 0, step, vs->h); _system->updateScreen(); diff --git a/engines/scumm/input.cpp b/engines/scumm/input.cpp index ffcb7d03f2..6647e9fe8d 100644 --- a/engines/scumm/input.cpp +++ b/engines/scumm/input.cpp @@ -162,8 +162,11 @@ void ScummEngine::parseEvents() { if (_renderMode == Common::kRenderHercA || _renderMode == Common::kRenderHercG) { _mouse.x -= (Common::kHercW - _screenWidth * 2) / 2; - _mouse.x /= 2; + _mouse.x >>= 1; _mouse.y = _mouse.y * 4 / 7; + } else if (_useCJKMode && _textSurfaceMultiplier == 2) { + _mouse.x >>= 1; + _mouse.y >>= 1; } break; case Common::EVENT_LBUTTONUP: diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index f29f1c7970..e54060c9e1 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -587,6 +587,7 @@ ScummEngine::~ScummEngine() { free(_compositeBuf); free(_herculesBuf); + free(_fmtownsBuf); delete _debugger; @@ -1078,12 +1079,19 @@ int ScummEngine::init() { _fileHandle = new ScummFile(); } + // Load CJK font, if present + // Load it earlier so _useCJKMode variable could be set + loadCJKFont(); + // Initialize backend _system->beginGFXTransaction(); bool defaultTo1XScaler = false; if (_renderMode == Common::kRenderHercA || _renderMode == Common::kRenderHercG) { _system->initSize(Common::kHercW, Common::kHercH); defaultTo1XScaler = true; + } else if (_useCJKMode) { + _system->initSize(_screenWidth * _textSurfaceMultiplier, _screenHeight * _textSurfaceMultiplier); + defaultTo1XScaler = true; } else { _system->initSize(_screenWidth, _screenHeight); defaultTo1XScaler = (_screenWidth > 320); @@ -1135,14 +1143,11 @@ void ScummEngine::setupScumm() { // Load localization data, if present loadLanguageBundle(); - // Load CJK font, if present - loadCJKFont(); - // Create the charset renderer setupCharsetRenderer(); // Create and clear the text surface - _textSurface.create(_screenWidth, _screenHeight, 1); + _textSurface.create(_screenWidth * _textSurfaceMultiplier, _screenHeight * _textSurfaceMultiplier, 1); clearTextSurface(); // Create the costume renderer @@ -1210,6 +1215,13 @@ void ScummEngine::setupScumm() { #if (defined(PALMOS_ARM) || defined(PALMOS_DEBUG) || defined(__GP32__)) Graphics::initfonts(); #endif + + _fmtownsBuf = 0; + if (_game.platform == Common::kPlatformFMTowns && _language == Common::JA_JPN) { + _fmtownsBuf = (byte *)malloc(_screenWidth * _textSurfaceMultiplier * _screenHeight * _textSurfaceMultiplier); + } + + _compositeBuf = (byte *)malloc(_screenWidth * _textSurfaceMultiplier * _screenHeight * _textSurfaceMultiplier); } #ifndef DISABLE_SCUMM_7_8 diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h index 438797a018..18c2275029 100644 --- a/engines/scumm/scumm.h +++ b/engines/scumm/scumm.h @@ -1026,10 +1026,12 @@ protected: // Screen rendering byte *_compositeBuf; byte *_herculesBuf; + byte *_fmtownsBuf; virtual void drawDirtyScreenParts(); void updateDirtyScreen(VirtScreenNumber slot); void drawStripToScreen(VirtScreen *vs, int x, int w, int t, int b); void ditherCGA(byte *dst, int dstPitch, int x, int y, int width, int height) const; + void scale2x(byte *dst, int dstPitch, const byte *src, int srcPitch, int w, int h); public: VirtScreen *findVirtScreen(int y); @@ -1151,6 +1153,7 @@ public: * drawStripToScreen() composits it over the game graphics. */ Graphics::Surface _textSurface; + int _textSurfaceMultiplier; protected: byte _charsetColor; -- cgit v1.2.3 From 3ac5498ec79e1081aa947dbff26f345bd9c25098 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 10 Jul 2007 01:26:12 +0000 Subject: Reberting accidental changes. svn-id: r28000 --- engines/scumm/charset.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/scumm/charset.cpp b/engines/scumm/charset.cpp index 86b48c3690..ecc6521cba 100644 --- a/engines/scumm/charset.cpp +++ b/engines/scumm/charset.cpp @@ -280,7 +280,7 @@ int CharsetRendererCommon::getFontHeight() { // do spacing for variable width old-style font int CharsetRendererClassic::getCharWidth(byte chr) { if (chr >= 0x80 && _vm->_useCJKMode) - return _vm->_2byteWidth; + return _vm->_2byteWidth / 2; int spacing = 0; int offs = READ_LE_UINT32(_fontPtr + chr * 4 + 4); @@ -1164,7 +1164,7 @@ CharsetRendererV2::CharsetRendererV2(ScummEngine *vm, Common::Language language) int CharsetRendererV3::getCharWidth(byte chr) { if (chr & 0x80 && _vm->_useCJKMode) - return _vm->_2byteWidth; + return _vm->_2byteWidth / 2; int spacing = 0; spacing = *(_widthTable + chr); -- cgit v1.2.3 From 40905f7ca230b685049029b9bff4d56ef6f0b059 Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Tue, 10 Jul 2007 09:30:56 +0000 Subject: Removed leftover empty function. svn-id: r28004 --- engines/parallaction/graphics.cpp | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'engines') diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp index 51ec65f792..67f2463038 100644 --- a/engines/parallaction/graphics.cpp +++ b/engines/parallaction/graphics.cpp @@ -449,16 +449,6 @@ void Gfx::initMouse(uint16 arg_0) { return; } -// NOTE: this routine will be moved into Gfx as soon as enough clarity -// is made regarding the field _id and _index of InventoryItem. -// -void extractInventoryGraphics(int16 pos, byte *dst) { -// printf("extractInventoryGraphics(%i)\n", pos); - - - return; -} - void Gfx::setMousePointer(int16 index) { -- cgit v1.2.3 From 728fe1ff86e26f781a0bd0656822b6845ef5707a Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 10 Jul 2007 13:25:54 +0000 Subject: Add md5sum for Italian fan translation of CD version (see fr#1727941 "KYRA: add Italian CD Version to kyra.dat"). svn-id: r28007 --- engines/kyra/detection.cpp | 2 ++ engines/kyra/staticres.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/kyra/detection.cpp b/engines/kyra/detection.cpp index 46bcc1e85f..76535ec25e 100644 --- a/engines/kyra/detection.cpp +++ b/engines/kyra/detection.cpp @@ -73,6 +73,8 @@ const KYRAGameDescription adGameDescs[] = { { { "kyra1", "CD", AD_ENTRY1("GEMCUT.PAK", "230f54e6afc007ab4117159181a1c722"), Common::DE_DEU, Common::kPlatformPC, Common::ADGF_NO_FLAGS }, KYRA1_CD_FLAGS }, { { "kyra1", "CD", AD_ENTRY1("GEMCUT.PAK", "b037c41768b652a040360ffa3556fd2a"), Common::FR_FRA, Common::kPlatformPC, Common::ADGF_NO_FLAGS }, KYRA1_CD_FLAGS }, + { { "kyra1", "CD", AD_ENTRY1("GEMCUT.PAK", "d8327fc4b7a72b23c900fa13aef4093a"), Common::IT_ITA, Common::kPlatformPC, Common::ADGF_NO_FLAGS }, KYRA1_CD_FLAGS }, // italian fan translation see fr#1727941 "KYRA: add Italian CD Version to kyra.dat" + { { "kyra1", "Demo", AD_ENTRY1("DEMO1.WSA", "fb722947d94897512b13b50cc84fd648"), Common::EN_ANY, Common::kPlatformPC, Common::ADGF_DEMO }, KYRA1_DEMO_FLAGS }, { { "kyra2", 0, AD_ENTRY1("FATE.PAK", "28cbad1c5bf06b2d3825ae57d760d032"), Common::EN_ANY, Common::kPlatformPC, Common::ADGF_NO_FLAGS }, KYRA2_CD_FLAGS }, // CD version diff --git a/engines/kyra/staticres.cpp b/engines/kyra/staticres.cpp index 16e3f98791..247cf90705 100644 --- a/engines/kyra/staticres.cpp +++ b/engines/kyra/staticres.cpp @@ -834,7 +834,7 @@ void KyraEngine::loadMainScreen(int page) { if (_flags.lang == Common::EN_ANY && !_flags.isTalkie && (_flags.platform == Common::kPlatformPC || _flags.platform == Common::kPlatformAmiga)) _screen->loadBitmap("MAIN15.CPS", page, page, _screen->getPalette(0)); - else if (_flags.lang == Common::EN_ANY || _flags.lang == Common::JA_JPN) + else if (_flags.lang == Common::EN_ANY || _flags.lang == Common::JA_JPN || (_flags.isTalkie && _flags.lang == Common::IT_ITA)) _screen->loadBitmap("MAIN_ENG.CPS", page, page, 0); else if (_flags.lang == Common::FR_FRA) _screen->loadBitmap("MAIN_FRE.CPS", page, page, 0); -- cgit v1.2.3 From 80cdd532bc8460d23b2562cafe336bedcbe6fb18 Mon Sep 17 00:00:00 2001 From: Kari Salminen Date: Tue, 10 Jul 2007 15:28:43 +0000 Subject: Add AgiButtonStyle and create correct style according to render mode (Supports PC and Amiga styles). svn-id: r28009 --- engines/agi/agi.cpp | 53 ++++++++++++++++++++++++ engines/agi/agi.h | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 166 insertions(+) (limited to 'engines') diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp index 61430dcaea..cb02df1ecc 100644 --- a/engines/agi/agi.cpp +++ b/engines/agi/agi.cpp @@ -535,6 +535,58 @@ static const GameSettings agiSettings[] = { {NULL, NULL, 0, 0, NULL} }; +AgiTextColor AgiButtonStyle::getColor(bool hasFocus, bool pressed, bool positive) const { + if (_amigaStyle) + if (positive) + if (pressed) // Positive pressed Amiga-style button + return AgiTextColor(amigaBlack, _olderAgi? amigaOrange : amigaPurple); + else // Positive unpressed Amiga-style button + return AgiTextColor(amigaWhite, amigaGreen); + else // _amigaStyle && !positive + if (pressed) // Negative pressed Amiga-style button + return AgiTextColor(amigaBlack, amigaCyan); + else // Negative unpressed Amiga-style button + return AgiTextColor(amigaWhite, amigaRed); + else // PC-style button + if (hasFocus || pressed) // A pressed or in focus PC-style button + return AgiTextColor(pcWhite, pcBlack); + else // An unpressed PC-style button without focus + return AgiTextColor(pcBlack, pcWhite); +} + +AgiTextColor AgiButtonStyle::getColor(bool hasFocus, bool pressed, bool baseFgColor, bool baseBgColor) const { + return getColor(hasFocus, pressed, AgiTextColor(baseFgColor, baseBgColor)); +} + +AgiTextColor AgiButtonStyle::getColor(bool hasFocus, bool pressed, const AgiTextColor &baseColor) const { + if (hasFocus || pressed) + return baseColor.swap(); + else + return baseColor; +} + +int AgiButtonStyle::getTextOffset(bool hasFocus, bool pressed) const { + return (pressed && !_amigaStyle) ? 1 : 0; +} + +bool AgiButtonStyle::getBorder(bool hasFocus, bool pressed) const { + return _amigaStyle && !_authenticAmiga && (hasFocus || pressed); +} + +void AgiButtonStyle::setAmigaStyle(bool amigaStyle, bool olderAgi, bool authenticAmiga) { + _amigaStyle = amigaStyle; + _olderAgi = olderAgi; + _authenticAmiga = authenticAmiga; +} + +void AgiButtonStyle::setPcStyle(bool pcStyle) { + setAmigaStyle(!pcStyle); +} + +AgiButtonStyle::AgiButtonStyle(Common::RenderMode renderMode) { + setAmigaStyle(renderMode == Common::kRenderAmiga); +} + AgiEngine::AgiEngine(OSystem *syst) : Engine(syst) { // Setup mixer @@ -635,6 +687,7 @@ void AgiEngine::initialize() { } } + _buttonStyle = AgiButtonStyle(_renderMode); _console = new Console(this); _gfx = new GfxMgr(this); _sound = new SoundMgr(this, _mixer); diff --git a/engines/agi/agi.h b/engines/agi/agi.h index 825d475314..216cb47e45 100644 --- a/engines/agi/agi.h +++ b/engines/agi/agi.h @@ -318,6 +318,118 @@ struct AgiBlock { uint8 *buffer; /* used for window background */ }; +/** AGI text color (Background and foreground color). */ +struct AgiTextColor { + /** Creates an AGI text color. Uses white text on black background by default. */ + AgiTextColor(int fgColor = 0x0F, int bgColor = 0x00) : fg(fgColor), bg(bgColor) {} + + /** Get an AGI text color with swapped foreground and background color. */ + AgiTextColor swap() const { return AgiTextColor(bg, fg); } + + int fg; ///< Foreground color (Used for text). + int bg; ///< Background color (Used for text's background). +}; + +/** + * AGI button style (Amiga or PC). + * + * Supports positive and negative button types (Used with Amiga-style only): + * Positive buttons do what the dialog was opened for. + * Negative buttons cancel what the dialog was opened for. + * Restart-dialog example: Restart-button is positive, Cancel-button negative. + * Paused-dialog example: Continue-button is positive. + */ +struct AgiButtonStyle { +// Public constants etc +public: + static const int + // Amiga colors (Indexes into the Amiga-ish palette) + amigaBlack = 0x00, ///< Accurate, is #000000 (24-bit RGB) + amigaWhite = 0x0F, ///< Practically accurate, is close to #FFFFFF (24-bit RGB) + amigaGreen = 0x02, ///< Quite accurate, should be #008A00 (24-bit RGB) + amigaOrange = 0x0C, ///< Inaccurate, too much blue, should be #FF7500 (24-bit RGB) + amigaPurple = 0x0D, ///< Inaccurate, too much green, should be #FF00FF (24-bit RGB) + amigaRed = 0x04, ///< Quite accurate, should be #BD0000 (24-bit RGB) + amigaCyan = 0x0B, ///< Inaccurate, too much red, should be #00FFDE (24-bit RGB) + // PC colors (Indexes into the EGA-palette) + pcBlack = 0x00, + pcWhite = 0x0F; + +// Public methods +public: + /** + * Get the color of the button with the given state and type using current style. + * + * @param hasFocus True if button has focus, false otherwise. + * @param pressed True if button is being pressed, false otherwise. + * @param positive True if button is positive, false if button is negative. Only matters for Amiga-style buttons. + */ + AgiTextColor getColor(bool hasFocus, bool pressed, bool positive = true) const; + + /** + * Get the color of a button with the given base color and state ignoring current style. + * Swaps foreground and background color when the button has focus or is being pressed. + * + * @param hasFocus True if button has focus, false otherwise. + * @param pressed True if button is being pressed, false otherwise. + * @param baseFgColor Foreground color of the button when it has no focus and is not being pressed. + * @param baseBgColor Background color of the button when it has no focus and is not being pressed. + */ + AgiTextColor getColor(bool hasFocus, bool pressed, bool baseFgColor, bool baseBgColor) const; + + /** + * Get the color of a button with the given base color and state ignoring current style. + * Swaps foreground and background color when the button has focus or is being pressed. + * + * @param hasFocus True if button has focus, false otherwise. + * @param pressed True if button is being pressed, false otherwise. + * @param baseColor Color of the button when it has no focus and is not being pressed. + */ + AgiTextColor getColor(bool hasFocus, bool pressed, const AgiTextColor &baseColor) const; + + /** + * How many pixels to offset the shown text diagonally down and to the right. + * Currently only used for pressed PC-style buttons. + */ + int getTextOffset(bool hasFocus, bool pressed) const; + + /** + * Show border around the button? + * Currently border is only used for in focus or pressed Amiga-style buttons + * when in inauthentic Amiga-style mode. + */ + bool getBorder(bool hasFocus, bool pressed) const; + + /** + * Set Amiga-button style. + * + * @param amigaStyle Set Amiga-button style if true, otherwise set PC-button style. + * @param olderAgi If true then use older AGI style in Amiga-mode, otherwise use newer. + * @param authenticAmiga If true then don't use a border around buttons in Amiga-mode, otherwise use. + */ + void setAmigaStyle(bool amigaStyle = true, bool olderAgi = false, bool authenticAmiga = false); + + /** + * Set PC-button style. + * @param pcStyle Set PC-button style if true, otherwise set default Amiga-button style. + */ + void setPcStyle(bool pcStyle = true); + +// Public constructors +public: + /** + * Create a button style based on the given rendering mode. + * @param renderMode If Common::kRenderAmiga then creates default Amiga-button style, otherwise PC-style. + */ + AgiButtonStyle(Common::RenderMode renderMode = Common::kRenderDefault); + +// Private member variables +private: + bool _amigaStyle; ///< Use Amiga-style buttons if true, otherwise use PC-style buttons. + bool _olderAgi; ///< Use older AGI style in Amiga-style mode. + bool _authenticAmiga; ///< Don't use border around buttons in Amiga-style mode. +}; + #define EGO_VIEW_TABLE 0 #define HORIZON 36 #define _WIDTH 160 @@ -595,6 +707,7 @@ public: int _oldMode; Menu* _menu; + AgiButtonStyle _buttonStyle; char _lastSentence[40]; -- cgit v1.2.3 From be23a6e1889f35cfa086729b7bd360d5cd5939bf Mon Sep 17 00:00:00 2001 From: Kari Salminen Date: Tue, 10 Jul 2007 15:45:30 +0000 Subject: Change AgiTextColor's default color to black text on white background. svn-id: r28010 --- engines/agi/agi.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/agi/agi.h b/engines/agi/agi.h index 216cb47e45..5fe1b1b04b 100644 --- a/engines/agi/agi.h +++ b/engines/agi/agi.h @@ -320,8 +320,8 @@ struct AgiBlock { /** AGI text color (Background and foreground color). */ struct AgiTextColor { - /** Creates an AGI text color. Uses white text on black background by default. */ - AgiTextColor(int fgColor = 0x0F, int bgColor = 0x00) : fg(fgColor), bg(bgColor) {} + /** Creates an AGI text color. Uses black text on white background by default. */ + AgiTextColor(int fgColor = 0x00, int bgColor = 0x0F) : fg(fgColor), bg(bgColor) {} /** Get an AGI text color with swapped foreground and background color. */ AgiTextColor swap() const { return AgiTextColor(bg, fg); } -- cgit v1.2.3 From b2cae8fe15e243f1403aa27a18dafbca74831c21 Mon Sep 17 00:00:00 2001 From: Kari Salminen Date: Tue, 10 Jul 2007 17:04:09 +0000 Subject: Oops. AgiButtonStyle::getColor's color parameters were bool rather than int. Fixed. svn-id: r28011 --- engines/agi/agi.cpp | 2 +- engines/agi/agi.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp index cb02df1ecc..5343999727 100644 --- a/engines/agi/agi.cpp +++ b/engines/agi/agi.cpp @@ -554,7 +554,7 @@ AgiTextColor AgiButtonStyle::getColor(bool hasFocus, bool pressed, bool positive return AgiTextColor(pcBlack, pcWhite); } -AgiTextColor AgiButtonStyle::getColor(bool hasFocus, bool pressed, bool baseFgColor, bool baseBgColor) const { +AgiTextColor AgiButtonStyle::getColor(bool hasFocus, bool pressed, int baseFgColor, int baseBgColor) const { return getColor(hasFocus, pressed, AgiTextColor(baseFgColor, baseBgColor)); } diff --git a/engines/agi/agi.h b/engines/agi/agi.h index 5fe1b1b04b..e99e8c2b57 100644 --- a/engines/agi/agi.h +++ b/engines/agi/agi.h @@ -375,7 +375,7 @@ public: * @param baseFgColor Foreground color of the button when it has no focus and is not being pressed. * @param baseBgColor Background color of the button when it has no focus and is not being pressed. */ - AgiTextColor getColor(bool hasFocus, bool pressed, bool baseFgColor, bool baseBgColor) const; + AgiTextColor getColor(bool hasFocus, bool pressed, int baseFgColor, int baseBgColor) const; /** * Get the color of a button with the given base color and state ignoring current style. -- cgit v1.2.3 From 0a5654fefc147fb67796bf5cb33f1f761041c018 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Tue, 10 Jul 2007 17:28:48 +0000 Subject: Cast the pointer to long instead of int to possibly fix the amd64 compile problem mentioned earlier on the channel. Neither seems like a particularly nice thing to do, but this is how we do it in the SDL backend, and it has apparently worked fine there... svn-id: r28012 --- engines/scumm/gfx.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/scumm/gfx.cpp b/engines/scumm/gfx.cpp index 3c6f57be1a..d21a77ea56 100644 --- a/engines/scumm/gfx.cpp +++ b/engines/scumm/gfx.cpp @@ -593,7 +593,7 @@ void ScummEngine::drawStripToScreen(VirtScreen *vs, int x, int width, int top, i // The values x, width, etc. are all multiples of 8 at this point, // so loop unrolloing might be a good idea... - assert(0 == ((int)text & 3)); + assert(0 == ((long)text & 3)); assert(0 == (width & 3)); // Compose the text over the game graphics -- cgit v1.2.3 From 83e038de191888758fdc2e2d741b12f1c28f7e2b Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Tue, 10 Jul 2007 17:41:40 +0000 Subject: For some reason, AgiTextColor(amigaBlack, _olderAgi? amigaOrange : amigaPurple) caused a linking error on my computer. Worked around that, and added curly braces for (IMO) better readability. svn-id: r28013 --- engines/agi/agi.cpp | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'engines') diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp index 5343999727..7abeaf3f05 100644 --- a/engines/agi/agi.cpp +++ b/engines/agi/agi.cpp @@ -536,22 +536,31 @@ static const GameSettings agiSettings[] = { }; AgiTextColor AgiButtonStyle::getColor(bool hasFocus, bool pressed, bool positive) const { - if (_amigaStyle) - if (positive) - if (pressed) // Positive pressed Amiga-style button - return AgiTextColor(amigaBlack, _olderAgi? amigaOrange : amigaPurple); - else // Positive unpressed Amiga-style button + if (_amigaStyle) { + if (positive) { + if (pressed) { // Positive pressed Amiga-style button + if (_olderAgi) { + return AgiTextColor(amigaBlack, amigaOrange); + } else { + return AgiTextColor(amigaBlack, amigaPurple); + } + } else { // Positive unpressed Amiga-style button return AgiTextColor(amigaWhite, amigaGreen); - else // _amigaStyle && !positive - if (pressed) // Negative pressed Amiga-style button + } + } else { // _amigaStyle && !positive + if (pressed) { // Negative pressed Amiga-style button return AgiTextColor(amigaBlack, amigaCyan); - else // Negative unpressed Amiga-style button + } else { // Negative unpressed Amiga-style button return AgiTextColor(amigaWhite, amigaRed); - else // PC-style button - if (hasFocus || pressed) // A pressed or in focus PC-style button + } + } + } else { // PC-style button + if (hasFocus || pressed) { // A pressed or in focus PC-style button return AgiTextColor(pcWhite, pcBlack); - else // An unpressed PC-style button without focus + } else { // An unpressed PC-style button without focus return AgiTextColor(pcBlack, pcWhite); + } + } } AgiTextColor AgiButtonStyle::getColor(bool hasFocus, bool pressed, int baseFgColor, int baseBgColor) const { -- cgit v1.2.3 From 969df42d016ae1fcc528c4c96ba02f1297712816 Mon Sep 17 00:00:00 2001 From: Kari Salminen Date: Tue, 10 Jul 2007 18:08:35 +0000 Subject: Make AGI's button drawing use AgiButtonStyle. Doesn't use Amiga-style yet. It's next. svn-id: r28014 --- engines/agi/agi.cpp | 1 + engines/agi/agi.h | 2 ++ engines/agi/graphics.cpp | 21 ++++++++++++++++++--- engines/agi/graphics.h | 5 ++++- engines/agi/predictive.cpp | 4 ++-- engines/agi/saveload.cpp | 2 +- engines/agi/text.cpp | 2 +- 7 files changed, 29 insertions(+), 8 deletions(-) (limited to 'engines') diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp index 7abeaf3f05..ccacb3fe01 100644 --- a/engines/agi/agi.cpp +++ b/engines/agi/agi.cpp @@ -697,6 +697,7 @@ void AgiEngine::initialize() { } _buttonStyle = AgiButtonStyle(_renderMode); + _defaultButtonStyle = AgiButtonStyle(); _console = new Console(this); _gfx = new GfxMgr(this); _sound = new SoundMgr(this, _mixer); diff --git a/engines/agi/agi.h b/engines/agi/agi.h index e99e8c2b57..c732121e11 100644 --- a/engines/agi/agi.h +++ b/engines/agi/agi.h @@ -81,6 +81,7 @@ typedef signed int Err; #define MSG_BOX_COLOUR 0x0f /* White */ #define MSG_BOX_TEXT 0x00 /* Black */ #define MSG_BOX_LINE 0x04 /* Red */ +#define BUTTON_BORDER 0x00 /* Black */ #define STATUS_FG 0x00 /* Black */ #define STATUS_BG 0x0f /* White */ @@ -708,6 +709,7 @@ public: Menu* _menu; AgiButtonStyle _buttonStyle; + AgiButtonStyle _defaultButtonStyle; char _lastSentence[40]; diff --git a/engines/agi/graphics.cpp b/engines/agi/graphics.cpp index 54f1783d83..c7b62ee11f 100644 --- a/engines/agi/graphics.cpp +++ b/engines/agi/graphics.cpp @@ -554,13 +554,24 @@ void GfxMgr::printCharacter(int x, int y, char c, int fg, int bg) { } /** - * Draw button + * Draw a default style button. + * Swaps background and foreground color if button is in focus or being pressed. * @param x x coordinate of the button * @param y y coordinate of the button * @param a set if the button has focus * @param p set if the button is pressed + * @param fgcolor foreground color of the button when it is neither in focus nor being pressed + * @param bgcolor background color of the button when it is neither in focus nor being pressed */ -void GfxMgr::drawButton(int x, int y, const char *s, int a, int p, int fgcolor, int bgcolor) { +void GfxMgr::drawDefaultStyleButton(int x, int y, const char *s, int a, int p, int fgcolor, int bgcolor) { + int textOffset = _vm->_defaultButtonStyle.getTextOffset(a > 0, p > 0); + AgiTextColor color = _vm->_defaultButtonStyle.getColor (a > 0, p > 0, fgcolor, bgcolor); + bool border = _vm->_defaultButtonStyle.getBorder (a > 0, p > 0); + + rawDrawButton(x, y, s, color.fg, color.bg, border, textOffset); +} + +void GfxMgr::rawDrawButton(int x, int y, const char *s, int fgcolor, int bgcolor, bool border, int textOffset) { int len = strlen(s); int x1, y1, x2, y2; @@ -569,8 +580,12 @@ void GfxMgr::drawButton(int x, int y, const char *s, int a, int p, int fgcolor, x2 = x + CHAR_COLS * len + 2; y2 = y + CHAR_LINES + 2; + // Draw a filled rectangle that's larger than the button. Used for drawing + // a border around the button as the button itself is drawn after this. + drawRectangle(x1, y1, x2, y2, border ? BUTTON_BORDER : MSG_BOX_COLOUR); + while (*s) { - putTextCharacter(0, x + (!!p), y + (!!p), *s++, a ? bgcolor : fgcolor, a ? fgcolor : bgcolor); + putTextCharacter(0, x + textOffset, y + textOffset, *s++, fgcolor, bgcolor); x += CHAR_COLS; } diff --git a/engines/agi/graphics.h b/engines/agi/graphics.h index b1f9c0e1d7..e9f16a63ef 100644 --- a/engines/agi/graphics.h +++ b/engines/agi/graphics.h @@ -50,6 +50,9 @@ private: uint8 _agipalPalette[16 * 3]; int _agipalFileNum; +private: + void rawDrawButton(int x, int y, const char *s, int fgcolor, int bgcolor, bool border, int textOffset); + public: GfxMgr(AgiEngine *vm); @@ -74,7 +77,7 @@ public: void clearScreen(int); void clearConsoleScreen(int); void drawBox(int, int, int, int, int, int, int); - void drawButton(int, int, const char *, int, int, int fgcolor = 0, int bgcolor = 0); + void drawDefaultStyleButton(int, int, const char *, int, int, int fgcolor = 0, int bgcolor = 0); int testButton(int, int, const char *); void drawRectangle(int, int, int, int, int); void saveBlock(int, int, int, int, uint8 *); diff --git a/engines/agi/predictive.cpp b/engines/agi/predictive.cpp index 67ebed5f05..2db4b49396 100644 --- a/engines/agi/predictive.cpp +++ b/engines/agi/predictive.cpp @@ -200,9 +200,9 @@ bool AgiEngine::predictiveDialog(void) { color2 = 7; } if (i == 14) { - _gfx->drawButton(bx[i], by[i], modes[mode], i == active, 0, color1, color2); + _gfx->drawDefaultStyleButton(bx[i], by[i], modes[mode], i == active, 0, color1, color2); } else { - _gfx->drawButton(bx[i], by[i], buttons[i], i == active, 0, color1, color2); + _gfx->drawDefaultStyleButton(bx[i], by[i], buttons[i], i == active, 0, color1, color2); } } diff --git a/engines/agi/saveload.cpp b/engines/agi/saveload.cpp index 9144dae96c..0f475ab644 100644 --- a/engines/agi/saveload.cpp +++ b/engines/agi/saveload.cpp @@ -516,7 +516,7 @@ int AgiEngine::selectSlot() { buttonY = (vm + 17) * CHAR_LINES; for (i = 0; i < 2; i++) - _gfx->drawButton(buttonX[i], buttonY, buttonText[i], 0, 0, MSG_BOX_TEXT, MSG_BOX_COLOUR); + _gfx->drawDefaultStyleButton(buttonX[i], buttonY, buttonText[i], 0, 0, MSG_BOX_TEXT, MSG_BOX_COLOUR); AllowSyntheticEvents on(this); int oldFirstSlot = _firstSlot + 1; diff --git a/engines/agi/text.cpp b/engines/agi/text.cpp index 565e94fa26..7ba7aa71fc 100644 --- a/engines/agi/text.cpp +++ b/engines/agi/text.cpp @@ -364,7 +364,7 @@ int AgiEngine::selectionBox(const char *m, const char **b) { debugC(4, kDebugLevelText, "waiting..."); for (;;) { for (i = 0; b[i]; i++) - _gfx->drawButton(bx[i], by[i], b[i], i == active, 0, MSG_BOX_TEXT, MSG_BOX_COLOUR); + _gfx->drawDefaultStyleButton(bx[i], by[i], b[i], i == active, 0, MSG_BOX_TEXT, MSG_BOX_COLOUR); _gfx->pollTimer(); /* msdos driver -> does nothing */ key = doPollKeyboard(); -- cgit v1.2.3 From 6e77abc07f20736fe7d50d3f3f3211839c630b53 Mon Sep 17 00:00:00 2001 From: Kari Salminen Date: Tue, 10 Jul 2007 18:32:24 +0000 Subject: Add Amiga-style menus (FR #657645). Used in Amiga-rendering mode. svn-id: r28015 --- engines/agi/graphics.cpp | 18 ++++++++++++++++++ engines/agi/graphics.h | 1 + engines/agi/saveload.cpp | 2 +- engines/agi/text.cpp | 2 +- 4 files changed, 21 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/agi/graphics.cpp b/engines/agi/graphics.cpp index c7b62ee11f..af57209357 100644 --- a/engines/agi/graphics.cpp +++ b/engines/agi/graphics.cpp @@ -571,6 +571,24 @@ void GfxMgr::drawDefaultStyleButton(int x, int y, const char *s, int a, int p, i rawDrawButton(x, y, s, color.fg, color.bg, border, textOffset); } +/** + * Draw a button using the currently chosen style. + * Amiga-style is used for the Amiga-rendering mode, PC-style is used otherwise. + * @param x x coordinate of the button + * @param y y coordinate of the button + * @param hasFocus set if the button has focus + * @param pressed set if the button is pressed + * @param positive set if button is positive, otherwise button is negative (Only matters with Amiga-style buttons) + * TODO: Make Amiga-style buttons a bit wider as they were in Amiga AGI games. + */ +void GfxMgr::drawCurrentStyleButton(int x, int y, const char *label, bool hasFocus, bool pressed, bool positive) { + int textOffset = _vm->_buttonStyle.getTextOffset(hasFocus, pressed); + AgiTextColor color = _vm->_buttonStyle.getColor(hasFocus, pressed, positive); + bool border = _vm->_buttonStyle.getBorder(hasFocus, pressed); + + rawDrawButton(x, y, label, color.fg, color.bg, border, textOffset); +} + void GfxMgr::rawDrawButton(int x, int y, const char *s, int fgcolor, int bgcolor, bool border, int textOffset) { int len = strlen(s); int x1, y1, x2, y2; diff --git a/engines/agi/graphics.h b/engines/agi/graphics.h index e9f16a63ef..d76a2e1397 100644 --- a/engines/agi/graphics.h +++ b/engines/agi/graphics.h @@ -78,6 +78,7 @@ public: void clearConsoleScreen(int); void drawBox(int, int, int, int, int, int, int); void drawDefaultStyleButton(int, int, const char *, int, int, int fgcolor = 0, int bgcolor = 0); + void drawCurrentStyleButton(int x, int y, const char *label, bool hasFocus, bool pressed = false, bool positive = true); int testButton(int, int, const char *); void drawRectangle(int, int, int, int, int); void saveBlock(int, int, int, int, uint8 *); diff --git a/engines/agi/saveload.cpp b/engines/agi/saveload.cpp index 0f475ab644..70096bddc2 100644 --- a/engines/agi/saveload.cpp +++ b/engines/agi/saveload.cpp @@ -516,7 +516,7 @@ int AgiEngine::selectSlot() { buttonY = (vm + 17) * CHAR_LINES; for (i = 0; i < 2; i++) - _gfx->drawDefaultStyleButton(buttonX[i], buttonY, buttonText[i], 0, 0, MSG_BOX_TEXT, MSG_BOX_COLOUR); + _gfx->drawCurrentStyleButton(buttonX[i], buttonY, buttonText[i], false, false, i == 0); AllowSyntheticEvents on(this); int oldFirstSlot = _firstSlot + 1; diff --git a/engines/agi/text.cpp b/engines/agi/text.cpp index 7ba7aa71fc..560e9b6f34 100644 --- a/engines/agi/text.cpp +++ b/engines/agi/text.cpp @@ -364,7 +364,7 @@ int AgiEngine::selectionBox(const char *m, const char **b) { debugC(4, kDebugLevelText, "waiting..."); for (;;) { for (i = 0; b[i]; i++) - _gfx->drawDefaultStyleButton(bx[i], by[i], b[i], i == active, 0, MSG_BOX_TEXT, MSG_BOX_COLOUR); + _gfx->drawCurrentStyleButton(bx[i], by[i], b[i], i == active, false, i == 0); _gfx->pollTimer(); /* msdos driver -> does nothing */ key = doPollKeyboard(); -- cgit v1.2.3 From b1feb9c65c715862d70b25cfa4e37df3a912cac5 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Tue, 10 Jul 2007 20:20:50 +0000 Subject: This commit adds a new build define USE_ARM_GFX_ASM (and sets it for the WinCE and DS builds). This causes the scumm engines graphics code to call ARM routines to do drawStripToScreen and copy8col. These routines were originally written for the DS port, and have now been made available to any other ARM device out there that wants them. I've tested this change on WinCE, but can't test it on the DS as I don't have one. We know that the routines work there though. svn-id: r28016 --- engines/scumm/gfx.cpp | 29 ++++++------ engines/scumm/gfxARM.s | 120 ++++++++++++++++++++++++++++++++++++++++++++++++ engines/scumm/module.mk | 5 ++ 3 files changed, 141 insertions(+), 13 deletions(-) create mode 100755 engines/scumm/gfxARM.s (limited to 'engines') diff --git a/engines/scumm/gfx.cpp b/engines/scumm/gfx.cpp index d21a77ea56..4e7276f2d0 100644 --- a/engines/scumm/gfx.cpp +++ b/engines/scumm/gfx.cpp @@ -35,9 +35,12 @@ #include "scumm/usage_bits.h" #include "scumm/he/wiz_he.h" #include "scumm/util.h" -#ifdef __DS__ -#include "blitters.h" -#endif + +#ifdef USE_ARM_GFX_ASM +extern "C" void DrawStripToScreenARM(int height, int width, byte const* text, byte const* src, byte* dst, + int vsPitch, int vmScreenWidth, int textSurfacePitch); +extern "C" void Copy8ColARM(byte* dst, int dstPitch, const byte* src, int height); +#endif /* USE_ARM_GFX_ASM */ namespace Scumm { @@ -610,8 +613,8 @@ void ScummEngine::drawStripToScreen(VirtScreen *vs, int x, int width, int top, i // (b) RLE encode the _textSurface row-wise. This is an improved variant of (a), // but also more complicated to implement, and incurs a bigger overhead when // writing to the text surface. -#ifdef __DS__ - DS::asmDrawStripToScreen(height, width, text, src, dst, vs->pitch, width, _textSurface.pitch); +#ifdef ARM_USE_GFX_ASM + DrawStripToScreenARM(height, width, text, src, dst, vs->pitch, width, _textSurface.pitch); #else for (int h = 0; h < height * m; ++h) { for (int w = 0; w < width * m; ++w) { @@ -625,7 +628,6 @@ void ScummEngine::drawStripToScreen(VirtScreen *vs, int x, int width, int top, i text += _textSurface.pitch - width * m; } #endif - src = _compositeBuf; pitch = width; @@ -1064,11 +1066,14 @@ static void fill(byte *dst, int dstPitch, byte color, int w, int h) { } } +#ifdef ARM_USE_GFX_ASM + +#define copy8Col(A,B,C,D) copy8ColARM(A,B,C,D) + +#else + static void copy8Col(byte *dst, int dstPitch, const byte *src, int height) { -#ifndef __DS__ - - do { #if defined(SCUMM_NEED_ALIGNMENT) memcpy(dst, src, 8); @@ -1079,12 +1084,10 @@ static void copy8Col(byte *dst, int dstPitch, const byte *src, int height) { dst += dstPitch; src += dstPitch; } while (--height); -#else - DS::asmCopy8Col(dst, dstPitch, src, height); -#endif - } +#endif /* ARM_USE_GFX_ASM */ + static void clear8Col(byte *dst, int dstPitch, int height) { do { #if defined(SCUMM_NEED_ALIGNMENT) diff --git a/engines/scumm/gfxARM.s b/engines/scumm/gfxARM.s new file mode 100755 index 0000000000..fa2457fb29 --- /dev/null +++ b/engines/scumm/gfxARM.s @@ -0,0 +1,120 @@ +@ ScummVM Scumm Interpreter +@ Copyright (C) 2007 The ScummVM project +@ +@ This program is free software@ you can redistribute it and/or +@ modify it under the terms of the GNU General Public License +@ as published by the Free Software Foundation@ either version 2 +@ of the License, or (at your option) any later version. +@ +@ This program is distributed in the hope that it will be useful, +@ but WITHOUT ANY WARRANTY; without even the implied warranty of +@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +@ GNU General Public License for more details. +@ +@ You should have received a copy of the GNU General Public License +@ along with this program@ if not, write to the Free Software +@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +@ +@ $URL: $ +@ $Id: $ +@ +@ @author Robin Watts (robin@wss.co.uk) + + .text + + .global asmDrawStripToScreen + + @ ARM implementation of asmDrawStripToScreen. + @ + @ C prototype would be: + @ + @ extern "C" void asmDrawStripToScreen(int height, + @ int width, + @ byte const *text, + @ byte const *src, + @ byte *dst, + @ int vsPitch, + @ int vsScreenWidth, + @ int textSurfacePitch); + @ + @ In addition, we assume that text, src and dst are all word (4 byte) + @ aligned. This is the same assumption that the old 'inline' version + @ made. +asmDrawStripToScreen: + @ r0 = height + @ r1 = width + @ r2 = text + @ r3 = src + MOV r12,r13 + STMFD r13!,{r4-r7,r9-r11,R14} + LDMIA r12,{r4,r5,r6,r7} + @ r4 = dst + @ r5 = vsPitch + @ r6 = vmScreenWidth + @ r7 = textSurfacePitch + + CMP r0,#0 @ If height<=0 + MOVLE r0,#1 @ height=1 + CMP r1,#4 @ If width<4 + BLT end @ return + + @ Width &= ~4 ? What's that about then? Width &= ~3 I could have + @ understood... + BIC r1,r1,#4 + + SUB r5,r5,r1 @ vsPitch -= width + SUB r6,r6,r1 @ vmScreenWidth -= width + SUB r7,r7,r1 @ textSurfacePitch -= width + MOV r10,#253 + ORR r10,r10,r10,LSL #8 + ORR r10,r10,r10,LSL #16 @ r10 = mask +yLoop: + MOV r14,r1 @ r14 = width +xLoop: + LDR r12,[r2],#4 @ r12 = [text] + LDR r11,[r3],#4 @ r11 = [src] + CMP r12,r10 + BNE singleByteCompare + SUBS r14,r14,#4 + STR r11,[r4], #4 @ r4 = [dst] + BGT xLoop + + ADD r2,r2,r7 @ text += textSurfacePitch + ADD r3,r3,r5 @ src += vsPitch + ADD r4,r4,r6 @ dst += vmScreenWidth + SUBS r0,r0,#1 + BGT yLoop + LDMFD r13!,{r4-r7,r9-r11,PC} + +singleByteCompare: + MOV r9,r12,LSR #24 @ r9 = 1st byte of [text] + CMP r9,r10,LSR #24 @ if (r9 == mask) + MOVEQ r9,r11,LSR #24 @ r9 = 1st byte of [src] + ORR r12,r9,r12,LSL #8 @ r12 = combine r9 and r12 + + MOV r9,r12,LSR #24 @ r9 = 1st byte of [text] + CMP r9,r10,LSR #24 @ if (r9 == mask) + MOVEQ r9,r11,LSR #24 @ r9 = 1st byte of [src] + ORR r12,r9,r12,LSL #8 @ r12 = combine r9 and r12 + + MOV r9,r12,LSR #24 @ r9 = 1st byte of [text] + CMP r9,r10,LSR #24 @ if (r9 == mask) + MOVEQ r9,r11,LSR #24 @ r9 = 1st byte of [src] + ORR r12,r9,r12,LSL #8 @ r12 = combine r9 and r12 + + MOV r9,r12,LSR #24 @ r9 = 1st byte of [text] + CMP r9,r10,LSR #24 @ if (r9 == mask) + MOVEQ r9,r11,LSR #24 @ r9 = 1st byte of [src] + ORR r12,r9,r12,LSL #8 @ r12 = combine r9 and r12 + + STR r12,[r4],#4 + SUBS r14,r14,#4 + BGT xLoop + + ADD r2,r2,r7 @ text += textSurfacePitch + ADD r3,r3,r5 @ src += vsPitch + ADD r4,r4,r6 @ dst += vmScreenWidth + SUBS r0,r0,#1 + BGT yLoop +end: + LDMFD r13!,{r4-r7,r9-r11,PC} diff --git a/engines/scumm/module.mk b/engines/scumm/module.mk index d8ef669410..a340f564b3 100644 --- a/engines/scumm/module.mk +++ b/engines/scumm/module.mk @@ -90,6 +90,11 @@ endif endif +ifdef USE_ARM_GFX_ASM +MODULE_OBJS += \ + gfxARM.o +endif + ifndef DISABLE_HE MODULE_OBJS += \ he/animation_he.o \ -- cgit v1.2.3 From 7a7212b9c17a195111d4e43c73bfda65437b4ec3 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Tue, 10 Jul 2007 21:24:58 +0000 Subject: Fixed bug #1751385 ("LSL: Impossible to enter "Number 9""), which was introduced when migrating to KEYCODE constants. Considering how silly the bug was, I probably introduced it myself. svn-id: r28017 --- engines/agi/agi.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp index ccacb3fe01..a5aa7854ca 100644 --- a/engines/agi/agi.cpp +++ b/engines/agi/agi.cpp @@ -178,7 +178,7 @@ void AgiEngine::processEvents() { case Common::KEYCODE_MINUS: key = '-'; break; - case Common::KEYCODE_9: + case Common::KEYCODE_TAB: key = 0x0009; break; case Common::KEYCODE_F1: -- cgit v1.2.3 From 0ed332acba26adb741e3ee7d3146eac2a9e4af60 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 10 Jul 2007 23:22:44 +0000 Subject: Fix for bug #1751344 - "ITE: p2_a.iaf not played correctly" svn-id: r28018 --- engines/saga/sndres.cpp | 10 +++++++--- engines/saga/sound.cpp | 8 +++++--- 2 files changed, 12 insertions(+), 6 deletions(-) (limited to 'engines') diff --git a/engines/saga/sndres.cpp b/engines/saga/sndres.cpp index ceb1ebf630..c0c63eb06c 100644 --- a/engines/saga/sndres.cpp +++ b/engines/saga/sndres.cpp @@ -169,7 +169,6 @@ bool SndRes::load(ResourceContext *context, uint32 resourceId, SoundBuffer &buff MemoryReadStream readS(soundResource, soundResourceLength); resourceType = soundInfo->resourceType; - buffer.isBigEndian = soundInfo->isBigEndian; if (soundResourceLength >= 8) { if (!memcmp(soundResource, "Creative", 8)) { @@ -178,7 +177,9 @@ bool SndRes::load(ResourceContext *context, uint32 resourceId, SoundBuffer &buff resourceType = kSoundWAV; } - if (_vm->getFeatures() & GF_COMPRESSED_SOUNDS) { + // If the game has patch files, then it includes a patch file for sound resource 4, used in the intro. + // Don't treat this patch file as compressed sound. This file is always included if patch files are present + if ((_vm->getFeatures() & GF_COMPRESSED_SOUNDS) && !(_vm->getPatchesCount() > 0 && resourceId == 4)) { if (soundResource[0] == char(0)) { resourceType = kSoundMP3; } else if (soundResource[0] == char(1)) { @@ -190,6 +191,9 @@ bool SndRes::load(ResourceContext *context, uint32 resourceId, SoundBuffer &buff } + buffer.isBigEndian = soundInfo->isBigEndian; + buffer.soundType = resourceType; + buffer.originalSize = 0; switch (resourceType) { case kSoundPCM: @@ -319,7 +323,7 @@ int SndRes::getVoiceLength(uint32 resourceId) { return -1; } - if (!(_vm->getFeatures() & GF_COMPRESSED_SOUNDS)) + if (!(_vm->getFeatures() & GF_COMPRESSED_SOUNDS) || buffer.originalSize == 0) msDouble = (double)buffer.size; else msDouble = (double)buffer.originalSize; diff --git a/engines/saga/sound.cpp b/engines/saga/sound.cpp index 6c2516c8a3..95b8c24a2f 100644 --- a/engines/saga/sound.cpp +++ b/engines/saga/sound.cpp @@ -83,31 +83,33 @@ void Sound::playSoundBuffer(Audio::SoundHandle *handle, SoundBuffer &buffer, int if (!(_vm->getFeatures() & GF_COMPRESSED_SOUNDS)) { _mixer->playRaw(Audio::Mixer::kSFXSoundType, handle, buffer.buffer, buffer.size, buffer.frequency, flags, -1, volume); } else { - buffer.soundFile->seek((long)buffer.fileOffset, SEEK_SET); Audio::AudioStream *stream = NULL; switch (buffer.soundType) { #ifdef USE_MAD case kSoundMP3: debug(1, "Playing MP3 compressed sound"); + buffer.soundFile->seek((long)buffer.fileOffset, SEEK_SET); stream = Audio::makeMP3Stream(buffer.soundFile, buffer.size); break; #endif #ifdef USE_VORBIS case kSoundOGG: debug(1, "Playing OGG compressed sound"); + buffer.soundFile->seek((long)buffer.fileOffset, SEEK_SET); stream = Audio::makeVorbisStream(buffer.soundFile, buffer.size); break; #endif #ifdef USE_FLAC case kSoundFLAC: debug(1, "Playing FLAC compressed sound"); + buffer.soundFile->seek((long)buffer.fileOffset, SEEK_SET); stream = Audio::makeFlacStream(buffer.soundFile, buffer.size); break; #endif default: - // Unknown compression - error("Trying to play a compressed sound, but the compression is not known"); + // No compression, play it as raw sound + _mixer->playRaw(Audio::Mixer::kSFXSoundType, handle, buffer.buffer, buffer.size, buffer.frequency, flags, -1, volume); break; } -- cgit v1.2.3 From 994a1918585f9c2c26d50c4ec4d457f3874cc7d0 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 11 Jul 2007 03:21:29 +0000 Subject: IHNM: Narrowed down the places where the actors stop being drawn when changing scenes svn-id: r28022 --- engines/saga/scene.cpp | 2 -- engines/saga/sfuncs.cpp | 12 ++++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/saga/scene.cpp b/engines/saga/scene.cpp index 362b212b14..84d1b45114 100644 --- a/engines/saga/scene.cpp +++ b/engines/saga/scene.cpp @@ -570,8 +570,6 @@ void Scene::loadScene(LoadSceneParams *loadSceneParams) { _chapterPointsChanged = false; - _vm->_actor->showActors(false); - if ((_vm->getGameType() == GType_IHNM) && (loadSceneParams->chapter != NO_CHAPTER_CHANGE)) { if (loadSceneParams->loadFlag != kLoadBySceneNumber) { error("loadScene wrong usage"); diff --git a/engines/saga/sfuncs.cpp b/engines/saga/sfuncs.cpp index 4b30d0b406..1e9460c898 100644 --- a/engines/saga/sfuncs.cpp +++ b/engines/saga/sfuncs.cpp @@ -562,9 +562,17 @@ void Script::sfScriptGotoScene(SCRIPTFUNC_PARAMS) { } if (_vm->getGameType() == GType_IHNM) { + // WORKAROUND for the briefly appearing actors at the beginning of each chapter + // This will stop the actors being drawn in those specific scenes until the scene background has been drawn + if ((_vm->_scene->currentChapterNumber() == 1 && _vm->_scene->currentSceneNumber() == 6) || + (_vm->_scene->currentChapterNumber() == 2 && _vm->_scene->currentSceneNumber() == 31) || + (_vm->_scene->currentChapterNumber() == 3 && _vm->_scene->currentSceneNumber() == 58) || + (_vm->_scene->currentChapterNumber() == 4 && _vm->_scene->currentSceneNumber() == 68) || + (_vm->_scene->currentChapterNumber() == 5 && _vm->_scene->currentSceneNumber() == 91)) + _vm->_actor->showActors(false); // Stop showing actors before the background is drawn + // Since it doesn't look like the IHNM scripts remove the - // cutaway after the intro, this is probably the best place to - // to it. + // cutaway after the intro, this is probably the best place to do it _vm->_anim->clearCutaway(); } -- cgit v1.2.3 From 3f2c527b0eb2ba4baa1e2af0d020f396c348be4d Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Wed, 11 Jul 2007 11:19:41 +0000 Subject: Provide more language.tab file sizes svn-id: r28023 --- engines/scumm/detection.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'engines') diff --git a/engines/scumm/detection.cpp b/engines/scumm/detection.cpp index ffbce945e1..8a649d9fd1 100644 --- a/engines/scumm/detection.cpp +++ b/engines/scumm/detection.cpp @@ -231,14 +231,21 @@ static Common::Language detectLanguage(const FSList &fslist, byte id) { switch (size) { case 439080: // 2daf3db71d23d99d19fc9a544fcf6431 return Common::EN_ANY; + case 322602: // caba99f4f5a0b69963e5a4d69e6f90af + return Common::ZH_TWN; case 493252: // 5d59594b24f3f1332e7d7e17455ed533 return Common::DE_DEU; case 461746: // 35bbe0e4d573b318b7b2092c331fd1fa return Common::FR_FRA; case 443439: // 4689d013f67aabd7c35f4fd7c4b4ad69 return Common::IT_ITA; + case 398613: // d1f5750d142d34c4c8f1f330a1278709 + return Common::KO_KOR; case 440586: // 5a1d0f4fa00917bdbfe035a72a6bba9d return Common::PT_BRA; + case 454457: // 0e5f450ec474a30254c0e36291fb4ebd + case 394083: // ad684ca14c2b4bf4c21a81c1dbed49bc + return Common::RU_RUS; case 449787: // 64f3fe479d45b52902cf88145c41d172 return Common::ES_ESP; } -- cgit v1.2.3 From 1dfc0614b7015f14d42cabd3fc5c2c542282966c Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 11 Jul 2007 11:46:02 +0000 Subject: Fix for bug #1751390 in LSL1. When choosing a menu option, an appropriate event is set. If that event is equal to 0x20, it was incorrectly triggered when the space bar key was pressed svn-id: r28024 --- engines/agi/menu.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'engines') diff --git a/engines/agi/menu.cpp b/engines/agi/menu.cpp index 52e402bf12..4cba788273 100644 --- a/engines/agi/menu.cpp +++ b/engines/agi/menu.cpp @@ -351,6 +351,12 @@ bool Menu::keyhandler(int key) { debugC(6, kDebugLevelMenu | kDebugLevelInput, "event %d registered", d->event); _vm->_game.evKeyp[d->event].occured = true; _vm->_game.evKeyp[d->event].data = d->event; + // In LSL1, event 0x20 is set when changing the game speed to normal via the menu + // Do not set the event data to 0x20, as this event is then incorrectly triggered + // when the spacebar is pressed, which has a keycode equal to 0x20 as well + // Fixes bug #1751390 - "LSL: after changing game speed, space key turn unfunctional" + if (d->event == 0x20) + _vm->_game.evKeyp[d->event].data = d->event + 1; goto exit_menu; } } -- cgit v1.2.3 From 61d4dda19a4ace8f41dbd1268bccbd2703cb4a4a Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 11 Jul 2007 12:28:07 +0000 Subject: Fix for SQ1 Amiga (v 1.2 1986): menus are forced in this version too, like with KQ3 Amiga svn-id: r28025 --- engines/agi/detection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/agi/detection.cpp b/engines/agi/detection.cpp index fce6fa733a..b3070f0ee3 100644 --- a/engines/agi/detection.cpp +++ b/engines/agi/detection.cpp @@ -1352,7 +1352,7 @@ static const AGIGameDescription gameDescriptions[] = { }, GID_SQ1, GType_V2, - 0, + GF_FORCEMENUS, 0x2440, }, -- cgit v1.2.3 From 24344fe6ce2ddd62d34bf09f1084758374c05218 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 11 Jul 2007 13:25:21 +0000 Subject: Should fix gui strings in Italian fan translation. svn-id: r28028 --- engines/kyra/gui.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/kyra/gui.cpp b/engines/kyra/gui.cpp index 6fc347158f..fe051dd75c 100644 --- a/engines/kyra/gui.cpp +++ b/engines/kyra/gui.cpp @@ -485,7 +485,7 @@ void KyraEngine::setGUILabels() { offset = 52; else if (_flags.lang == Common::DE_DEU) offset = 30; - else if (_flags.lang == Common::FR_FRA) + else if (_flags.lang == Common::FR_FRA || _flags.lang == Common::IT_ITA) offset = 6; offsetOn = offsetMainMenu = offsetOptions = offset; walkspeedGarbageOffset = 48; -- cgit v1.2.3 From 1b17f2d6a7b9e05031d5892a0b4a1b5871733082 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 11 Jul 2007 16:49:44 +0000 Subject: Enable menus for Space Quest 1 (PC) 1.1A svn-id: r28033 --- engines/agi/detection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/agi/detection.cpp b/engines/agi/detection.cpp index b3070f0ee3..c33ab06bed 100644 --- a/engines/agi/detection.cpp +++ b/engines/agi/detection.cpp @@ -1335,7 +1335,7 @@ static const AGIGameDescription gameDescriptions[] = { }, GID_SQ1, GType_V2, - 0, + GF_FORCEMENUS, 0x2272, }, -- cgit v1.2.3 From ec742cb4fdbf144a50b2473c2c9275e126e481d8 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 11 Jul 2007 16:52:56 +0000 Subject: Cleaned up comments svn-id: r28034 --- engines/agi/detection.cpp | 168 +++++++++++++++++++++++----------------------- 1 file changed, 84 insertions(+), 84 deletions(-) (limited to 'engines') diff --git a/engines/agi/detection.cpp b/engines/agi/detection.cpp index c33ab06bed..3f53777f2d 100644 --- a/engines/agi/detection.cpp +++ b/engines/agi/detection.cpp @@ -125,7 +125,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == AGI Demo 1 (PC) 05/87 [AGI 2.425] + // AGI Demo 1 (PC) 05/87 [AGI 2.425] { "agidemo", "Demo 1 1987-05-20", @@ -142,7 +142,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == AGI Demo 2 (IIgs) 1.0C (Censored) + // AGI Demo 2 (IIgs) 1.0C (Censored) { "agidemo", "Demo 2 1987-11-24 1.0C", @@ -159,7 +159,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == AGI Demo 2 (PC 3.5") 11/87 [AGI 2.915] + // AGI Demo 2 (PC 3.5") 11/87 [AGI 2.915] { "agidemo", "Demo 2 1987-11-24 3.5\"", @@ -176,7 +176,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == AGI Demo 2 (PC 5.25") 11/87 [v1] [AGI 2.915] + // AGI Demo 2 (PC 5.25") 11/87 [v1] [AGI 2.915] { "agidemo", "Demo 2 1987-11-24 [version 1] 5.25\"", @@ -193,7 +193,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == AGI Demo 2 (PC 5.25") 01/88 [v2] [AGI 2.917] + // AGI Demo 2 (PC 5.25") 01/88 [v2] [AGI 2.917] { "agidemo", "Demo 2 1988-01-25 [version 2] 5.25\"", @@ -210,7 +210,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == AGI Demo 3 (PC) 09/88 [AGI 3.002.102] + // AGI Demo 3 (PC) 09/88 [AGI 3.002.102] { "agidemo", "Demo 3 1988-09-13", @@ -227,7 +227,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Black Cauldron (Amiga) 2.00 6/14/87 + // Black Cauldron (Amiga) 2.00 6/14/87 { "bc", "2.00 1987-06-14", @@ -244,7 +244,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Black Cauldron (Apple IIgs) 1.0O 2/24/89 (CE) + // Black Cauldron (Apple IIgs) 1.0O 2/24/89 (CE) { "bc", "1.0O 1989-02-24 (CE)", @@ -261,7 +261,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Black Cauldron (PC) 2.00 6/14/87 [AGI 2.439] + // Black Cauldron (PC) 2.00 6/14/87 [AGI 2.439] { "bc", "2.00 1987-06-14", @@ -278,7 +278,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Black Cauldron (PC 5.25") 2.10 11/10/88 [AGI 3.002.098] + // Black Cauldron (PC 5.25") 2.10 11/10/88 [AGI 3.002.098] { "bc", "2.10 1988-11-10 5.25\"", @@ -297,7 +297,7 @@ static const AGIGameDescription gameDescriptions[] = { // These aren't supposed to work now as they require unsupported agi engine 2.01 #if 0 { - // Sarien Name == Donald Duck's Playground (Amiga) 1.0C + // Donald Duck's Playground (Amiga) 1.0C { "ddp", "1.0C 1987-04-27", @@ -314,7 +314,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Donald Duck's Playground (ST) 1.0A 8/8/86 + // Donald Duck's Playground (ST) 1.0A 8/8/86 { "ddp", "1.0A 1986-08-08", @@ -348,7 +348,7 @@ static const AGIGameDescription gameDescriptions[] = { #endif { - // Sarien Name == Gold Rush! (Amiga) 1.01 1/13/89 aka 2.05 3/9/89 # 2.316 + // Gold Rush! (Amiga) 1.01 1/13/89 aka 2.05 3/9/89 # 2.316 { "goldrush", "1.01 1989-01-13 aka 2.05 1989-03-09", @@ -365,7 +365,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Gold Rush! (Apple IIgs) 1.0M 2/28/89 (CE) aka 2.01 12/22/88 + // Gold Rush! (Apple IIgs) 1.0M 2/28/89 (CE) aka 2.01 12/22/88 { "goldrush", "1.0M 1989-02-28 (CE) aka 2.01 1988-12-22", @@ -382,7 +382,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Gold Rush! (ST) 1.01 1/13/89 aka 2.01 12/22/88 + // Gold Rush! (ST) 1.01 1/13/89 aka 2.01 12/22/88 { "goldrush", "1.01 1989-01-13 aka 2.01 1988-12-22", @@ -399,7 +399,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Gold Rush! (PC 5.25") 2.01 12/22/88 [AGI 3.002.149] + // Gold Rush! (PC 5.25") 2.01 12/22/88 [AGI 3.002.149] { "goldrush", "2.01 1988-12-22 5.25\"", @@ -416,7 +416,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Gold Rush! (PC 3.5") 2.01 12/22/88 [AGI 3.002.149] + // Gold Rush! (PC 3.5") 2.01 12/22/88 [AGI 3.002.149] { "goldrush", "2.01 1988-12-22 3.5\"", @@ -433,7 +433,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Gold Rush! (PC 5.25") 2.01 12/22/88 [AGI 3.002.149] + // Gold Rush! (PC 5.25") 2.01 12/22/88 [AGI 3.002.149] { "goldrush", "2.01 1988-12-22", @@ -454,7 +454,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == King's Quest 1 (Amiga) 1.0U # 2.082 + // King's Quest 1 (Amiga) 1.0U # 2.082 { "kq1", "1.0U 1986", @@ -471,7 +471,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == King's Quest 1 (ST) 1.0V + // King's Quest 1 (ST) 1.0V { "kq1", "1.0V 1986", @@ -488,7 +488,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == King's Quest 1 (IIgs) 1.0S-88223 + // King's Quest 1 (IIgs) 1.0S-88223 { "kq1", "1.0S 1988-02-23", @@ -505,7 +505,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == King's Quest 1 (Mac) 2.0C + // King's Quest 1 (Mac) 2.0C { "kq1", "2.0C 1987-03-26", @@ -522,7 +522,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == King's Quest 1 (PC 5.25"/3.5") 2.0F [AGI 2.917] + // King's Quest 1 (PC 5.25"/3.5") 2.0F [AGI 2.917] { "kq1", "2.0F 1987-05-05 5.25\"/3.5\"", @@ -539,7 +539,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == King's Quest 2 (IIgs) 2.0A 6/16/88 (CE) + // King's Quest 2 (IIgs) 2.0A 6/16/88 (CE) { "kq2", "2.0A 1988-06-16 (CE)", @@ -556,7 +556,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == King's Quest 2 (Amiga) 2.0J (Broken) + // King's Quest 2 (Amiga) 2.0J (Broken) { "kq2", "2.0J 1987-01-29 [OBJECT decrypted]", @@ -573,7 +573,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == King's Quest 2 (Mac) 2.0R + // King's Quest 2 (Mac) 2.0R { "kq2", "2.0R 1988-03-23", @@ -607,7 +607,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == King's Quest 2 (PC 5.25"/3.5") 2.2 [AGI 2.426] + // King's Quest 2 (PC 5.25"/3.5") 2.2 [AGI 2.426] { "kq2", "2.2 1987-05-07 5.25\"/3.5\"", @@ -624,7 +624,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == King's Quest 3 (Amiga) 1.01 11/8/86 + // King's Quest 3 (Amiga) 1.01 11/8/86 { "kq3", "1.01 1986-11-08", @@ -641,7 +641,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == King's Quest 3 (ST) 1.02 11/18/86 + // King's Quest 3 (ST) 1.02 11/18/86 { "kq3", "1.02 1986-11-18", @@ -658,7 +658,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == King's Quest 3 (Mac) 2.14 3/15/88 + // King's Quest 3 (Mac) 2.14 3/15/88 { "kq3", "2.14 1988-03-15", @@ -675,7 +675,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == King's Quest 3 (IIgs) 2.0A 8/28/88 (CE) + // King's Quest 3 (IIgs) 2.0A 8/28/88 (CE) { "kq3", "2.0A 1988-08-28 (CE)", @@ -692,7 +692,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == King's Quest 3 (Amiga) 2.15 11/15/89 # 2.333 + // King's Quest 3 (Amiga) 2.15 11/15/89 # 2.333 { "kq3", "2.15 1989-11-15", @@ -709,7 +709,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == King's Quest 3 (PC) 1.01 11/08/86 [AGI 2.272] + // King's Quest 3 (PC) 1.01 11/08/86 [AGI 2.272] { "kq3", "1.01 1986-11-08", @@ -726,7 +726,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == King's Quest 3 (PC 5.25") 2.00 5/25/87 [AGI 2.435] + // King's Quest 3 (PC 5.25") 2.00 5/25/87 [AGI 2.435] { "kq3", "2.00 1987-05-25 5.25\"", @@ -743,7 +743,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == King's Quest 3 (Mac) 2.14 3/15/88 + // King's Quest 3 (Mac) 2.14 3/15/88 { "kq3", "2.14 1988-03-15 5.25\"", @@ -760,7 +760,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == King's Quest 3 (PC 3.5") 2.14 3/15/88 [AGI 2.936] + // King's Quest 3 (PC 3.5") 2.14 3/15/88 [AGI 2.936] { "kq3", "2.14 1988-03-15 3.5\"", @@ -777,7 +777,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == King's Quest 4 (PC 5.25") 2.3 9/27/88 [AGI 3.002.086] + // King's Quest 4 (PC 5.25") 2.3 9/27/88 [AGI 3.002.086] { "kq4", "2.3 1988-09-27", @@ -794,7 +794,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == King's Quest 4 (IIgs) 1.0K 11/22/88 (CE) + // King's Quest 4 (IIgs) 1.0K 11/22/88 (CE) { "kq4", "1.0K 1988-11-22", @@ -811,7 +811,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == King's Quest 4 (PC 3.5") 2.0 7/27/88 [AGI 3.002.086] + // King's Quest 4 (PC 3.5") 2.0 7/27/88 [AGI 3.002.086] { "kq4", "2.0 1988-07-27 3.5\"", @@ -828,7 +828,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == King's Quest 4 (PC 3.5") 2.2 9/27/88 [AGI 3.002.086] + // King's Quest 4 (PC 3.5") 2.2 9/27/88 [AGI 3.002.086] { "kq4", "2.2 1988-09-27 3.5\"", @@ -845,7 +845,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == King's Quest 4 demo (PC) [AGI 3.002.102] + // King's Quest 4 demo (PC) [AGI 3.002.102] { "kq4", "Demo 1988-12-20", @@ -862,7 +862,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Leisure Suit Larry 1 (PC 5.25"/3.5") 1.00 6/1/87 [AGI 2.440] + // Leisure Suit Larry 1 (PC 5.25"/3.5") 1.00 6/1/87 [AGI 2.440] { "lsl1", "1.00 1987-06-01 5.25\"/3.5\"", @@ -879,7 +879,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Leisure Suit Larry 1 (ST) 1.04 6/18/87 + // Leisure Suit Larry 1 (ST) 1.04 6/18/87 { "lsl1", "1.04 1987-06-18", @@ -896,7 +896,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Leisure Suit Larry 1 (Amiga) 1.05 6/26/87 # x.yyy + // Leisure Suit Larry 1 (Amiga) 1.05 6/26/87 # x.yyy { "lsl1", "1.05 1987-06-26", @@ -913,7 +913,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Leisure Suit Larry 1 (IIgs) 1.0E + // Leisure Suit Larry 1 (IIgs) 1.0E { "lsl1", "1.0E 1987", @@ -930,7 +930,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Leisure Suit Larry 1 (Mac) 1.05 6/26/87 + // Leisure Suit Larry 1 (Mac) 1.05 6/26/87 { "lsl1", "1.05 1987-06-26", @@ -947,7 +947,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Manhunter NY (ST) 1.03 10/20/88 + // Manhunter NY (ST) 1.03 10/20/88 { "mh1", "1.03 1988-10-20", @@ -964,7 +964,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Manhunter NY (IIgs) 2.0E 10/05/88 (CE) + // Manhunter NY (IIgs) 2.0E 10/05/88 (CE) { "mh1", "2.0E 1988-10-05 (CE)", @@ -981,7 +981,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Manhunter NY (Amiga) 1.06 3/18/89 + // Manhunter NY (Amiga) 1.06 3/18/89 { "mh1", "1.06 1989-03-18", @@ -999,7 +999,7 @@ static const AGIGameDescription gameDescriptions[] = { { // reported by Filippos (thebluegr) in bugreport #1654500 - // Sarien Name == Manhunter NY (PC 5.25") 1.22 8/31/88 [AGI 3.002.107] + // Manhunter NY (PC 5.25") 1.22 8/31/88 [AGI 3.002.107] { "mh1", "1.22 1988-08-31", @@ -1016,7 +1016,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Manhunter NY (PC 3.5") 1.22 8/31/88 [AGI 3.002.102] + // Manhunter NY (PC 3.5") 1.22 8/31/88 [AGI 3.002.102] { "mh1", "1.22 1988-08-31", @@ -1033,7 +1033,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Manhunter SF (ST) 1.0 7/29/89 + // Manhunter SF (ST) 1.0 7/29/89 { "mh2", "1.0 1989-07-29", @@ -1050,7 +1050,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Manhunter SF (Amiga) 3.06 8/17/89 # 2.333 + // Manhunter SF (Amiga) 3.06 8/17/89 # 2.333 { "mh2", "3.06 1989-08-17", @@ -1067,7 +1067,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Manhunter SF (PC 5.25") 3.03 8/17/89 [AGI 3.002.149] + // Manhunter SF (PC 5.25") 3.03 8/17/89 [AGI 3.002.149] { "mh2", "3.03 1989-08-17 5.25\"", @@ -1084,7 +1084,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Manhunter SF (PC 3.5") 3.02 7/26/89 [AGI 3.002.149] + // Manhunter SF (PC 3.5") 3.02 7/26/89 [AGI 3.002.149] { "mh2", "3.02 1989-07-26 3.5\"", @@ -1101,7 +1101,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Mixed-Up Mother Goose (Amiga) 1.1 + // Mixed-Up Mother Goose (Amiga) 1.1 { "mixedup", "1.1 1986-12-10", @@ -1118,7 +1118,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Mixed Up Mother Goose (IIgs) + // Mixed Up Mother Goose (IIgs) { "mixedup", "1987", @@ -1135,7 +1135,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Mixed-Up Mother Goose (PC) [AGI 2.915] + // Mixed-Up Mother Goose (PC) [AGI 2.915] { "mixedup", "1987-11-10", @@ -1153,7 +1153,7 @@ static const AGIGameDescription gameDescriptions[] = { #if 0 { - // Sarien Name == Mixed Up Mother Goose (PC) [AGI 2.915] (Broken) + // Mixed Up Mother Goose (PC) [AGI 2.915] (Broken) { "mixedup", "[corrupt/OBJECT from disk 1]", @@ -1171,7 +1171,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Police Quest 1 (PC) 2.0E 11/17/87 [AGI 2.915] + // Police Quest 1 (PC) 2.0E 11/17/87 [AGI 2.915] { "pq1", "2.0E 1987-11-17", @@ -1188,7 +1188,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Police Quest 1 (Mac) 2.0G 12/3/87 + // Police Quest 1 (Mac) 2.0G 12/3/87 { "pq1", "2.0G 1987-12-03", @@ -1205,7 +1205,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Police Quest 1 (IIgs) 2.0B-88421 + // Police Quest 1 (IIgs) 2.0B-88421 { "pq1", "2.0B 1988-04-21", @@ -1222,7 +1222,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Police Quest 1 (Amiga) 2.0B 2/22/89 # 2.310 + // Police Quest 1 (Amiga) 2.0B 2/22/89 # 2.310 { "pq1", "2.0B 1989-02-22", @@ -1239,7 +1239,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Police Quest 1 (IIgs) 2.0A-88318 + // Police Quest 1 (IIgs) 2.0A-88318 { "pq1", "2.0A 1988-03-18", @@ -1256,7 +1256,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Police Quest 1 (PC) 2.0A 10/23/87 [AGI 2.903/2.911] + // Police Quest 1 (PC) 2.0A 10/23/87 [AGI 2.903/2.911] { "pq1", "2.0A 1987-10-23", @@ -1273,7 +1273,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Police Quest 1 (Mac) 2.0G 12/3/87 + // Police Quest 1 (Mac) 2.0G 12/3/87 { "pq1", "2.0G 1987-12-03 5.25\"/ST", @@ -1307,7 +1307,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Space Quest 1 (ST) 1.1A + // Space Quest 1 (ST) 1.1A { "sq1", "1.1A 1986-02-06", @@ -1324,7 +1324,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Space Quest 1 (PC) 1.1A [AGI 2.272] + // Space Quest 1 (PC) 1.1A [AGI 2.272] { "sq1", "1.1A 1986-11-13", @@ -1341,7 +1341,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Space Quest 1 (Amiga) 1.2 # 2.082 + // Space Quest 1 (Amiga) 1.2 # 2.082 { "sq1", "1.2 1986", @@ -1358,7 +1358,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Space Quest 1 (Mac) 1.5D + // Space Quest 1 (Mac) 1.5D { "sq1", "1.5D 1987-04-02", @@ -1375,7 +1375,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Space Quest 1 (IIgs) 2.2 + // Space Quest 1 (IIgs) 2.2 { "sq1", "2.2 1987", @@ -1392,7 +1392,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Space Quest 1 (PC) 1.0X [AGI 2.089] + // Space Quest 1 (PC) 1.0X [AGI 2.089] { "sq1", "1.0X 1986-09-24", @@ -1409,7 +1409,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Space Quest 1 (PC) 1.1A [AGI 2.272] + // Space Quest 1 (PC) 1.1A [AGI 2.272] { "sq1", "1.1A 1986-11-13", @@ -1426,7 +1426,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Space Quest 1 (PC 5.25"/3.5") 2.2 [AGI 2.426/2.917] + // Space Quest 1 (PC 5.25"/3.5") 2.2 [AGI 2.426/2.917] { "sq1", "2.2 1987-05-07 5.25\"/3.5\"", @@ -1444,7 +1444,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Space Quest 2 (PC 3.5") 2.0D [AGI 2.936] + // Space Quest 2 (PC 3.5") 2.0D [AGI 2.936] { "sq2", "2.0D 1988-03-14 3.5\"", @@ -1461,7 +1461,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Space Quest 2 (IIgs) 2.0A 7/25/88 (CE) + // Space Quest 2 (IIgs) 2.0A 7/25/88 (CE) { "sq2", "2.0A 1988-07-25 (CE)", @@ -1478,7 +1478,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Space Quest 2 (Amiga) 2.0F + // Space Quest 2 (Amiga) 2.0F { "sq2", "2.0F 1986-12-09 [VOL.2->PICTURE.16 broken]", @@ -1499,7 +1499,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Space Quest 2 (Mac) 2.0D + // Space Quest 2 (Mac) 2.0D { "sq2", "2.0D 1988-04-04", @@ -1517,7 +1517,7 @@ static const AGIGameDescription gameDescriptions[] = { { // reported by Filippos (thebluegr) in bugreport #1654500 - // Sarien Name == Space Quest 2 (PC 5.25") 2.0A [AGI 2.912] + // Space Quest 2 (PC 5.25") 2.0A [AGI 2.912] { "sq2", "2.0A 1987-11-06 5.25\"", @@ -1534,7 +1534,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Space Quest 2 (PC 3.5") 2.0A [AGI 2.912] + // Space Quest 2 (PC 3.5") 2.0A [AGI 2.912] { "sq2", "2.0A 1987-11-06 3.5\"", @@ -1551,7 +1551,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Space Quest 2 (PC 5.25"/ST) 2.0C/A [AGI 2.915] + // Space Quest 2 (PC 5.25"/ST) 2.0C/A [AGI 2.915] { "sq2", "2.0C/A 5.25\"/ST", @@ -1568,7 +1568,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Space Quest 2 (PC 3.5") 2.0F [AGI 2.936] + // Space Quest 2 (PC 3.5") 2.0F [AGI 2.936] { "sq2", "2.0F 1989-01-05 3.5\"", @@ -1585,7 +1585,7 @@ static const AGIGameDescription gameDescriptions[] = { { - // Sarien Name == Xmas Card 1986 (PC) [AGI 2.272] + // Xmas Card 1986 (PC) [AGI 2.272] { "xmascard", "1986-11-13 [version 1]", @@ -1675,7 +1675,7 @@ static const AGIGameDescription gameDescriptions[] = { FANMADE("Good Man (demo v3.41)", "3facd8a8f856b7b6e0f6c3200274d88c"), { - // Sarien Name == Groza + // Groza { "agi-fanmade", "Groza (russian) [AGDS sample]", -- cgit v1.2.3 From 17a4539a65c5813862b85691cca094ba616e027c Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 12 Jul 2007 08:52:07 +0000 Subject: Renamed a variable, so that it makes more sense svn-id: r28042 --- engines/saga/music.cpp | 10 +++++----- engines/saga/music.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'engines') diff --git a/engines/saga/music.cpp b/engines/saga/music.cpp index 71b6964530..0ba5482aae 100644 --- a/engines/saga/music.cpp +++ b/engines/saga/music.cpp @@ -282,7 +282,7 @@ Music::Music(SagaEngine *vm, Audio::Mixer *mixer, MidiDriver *driver, int enable xmidiParser = MidiParser::createParser_XMIDI(); smfParser = MidiParser::createParser_SMF(); - _musicContext = _vm->_resource->getContext(GAME_MUSICFILE); + _digitalMusicContext = _vm->_resource->getContext(GAME_MUSICFILE); _songTableLen = 0; _songTable = 0; @@ -405,7 +405,7 @@ void Music::play(uint32 resourceId, MusicFlags flags) { if (_vm->getGameType() == GType_ITE) { if (resourceId >= 9 && resourceId <= 34) { - if (_musicContext != NULL) { + if (_digitalMusicContext != NULL) { //TODO: check resource size loopStart = 0; // fix ITE sunstatm score @@ -415,7 +415,7 @@ void Music::play(uint32 resourceId, MusicFlags flags) { if (!(_vm->getFeatures() & GF_COMPRESSED_SOUNDS)) { // uncompressed digital music - audioStream = new RAWInputStream(_vm, _musicContext, resourceId - 9, flags == MUSIC_LOOP, loopStart); + audioStream = new RAWInputStream(_vm, _digitalMusicContext, resourceId - 9, flags == MUSIC_LOOP, loopStart); } else { // compressed digital music ResourceData * musicResourceData; @@ -423,8 +423,8 @@ void Music::play(uint32 resourceId, MusicFlags flags) { byte compressedHeader[10]; GameSoundTypes soundType; - musicResourceData = _vm->_resource->getResourceData(_musicContext, resourceId - 9); - _file = _musicContext->getFile(musicResourceData); + musicResourceData = _vm->_resource->getResourceData(_digitalMusicContext, resourceId - 9); + _file = _digitalMusicContext->getFile(musicResourceData); if (_vm->getMusicInfo() == NULL) { error("RAWInputStream() wrong musicInfo"); diff --git a/engines/saga/music.h b/engines/saga/music.h index 96d8608bcd..b038a25a11 100644 --- a/engines/saga/music.h +++ b/engines/saga/music.h @@ -137,7 +137,7 @@ private: int _currentVolume; int _currentVolumePercent; - ResourceContext *_musicContext; + ResourceContext *_digitalMusicContext; MidiParser *xmidiParser; MidiParser *smfParser; -- cgit v1.2.3 From 3e652273cc21cc605b097743f0856306ea7e3bbc Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Fri, 13 Jul 2007 14:22:11 +0000 Subject: Some more fixes for Italian fan translation. svn-id: r28055 --- engines/kyra/script_v1.cpp | 2 +- engines/kyra/sequences_v1.cpp | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/kyra/script_v1.cpp b/engines/kyra/script_v1.cpp index 87123222fb..18b6c791b9 100644 --- a/engines/kyra/script_v1.cpp +++ b/engines/kyra/script_v1.cpp @@ -1098,7 +1098,7 @@ int KyraEngine_v1::o1_specialEventDisplayBrynnsNote(ScriptState *script) { _screen->savePageToDisk("HIDPAGE.TMP", 2); _screen->savePageToDisk("SEENPAGE.TMP", 0); if (_flags.isTalkie) { - if (_flags.lang == Common::EN_ANY) + if (_flags.lang == Common::EN_ANY || _flags.lang == Common::IT_ITA) _screen->loadBitmap("NOTEENG.CPS", 3, 3, 0); else if (_flags.lang == Common::FR_FRA) _screen->loadBitmap("NOTEFRE.CPS", 3, 3, 0); diff --git a/engines/kyra/sequences_v1.cpp b/engines/kyra/sequences_v1.cpp index 1b4c0f680a..8900e68d93 100644 --- a/engines/kyra/sequences_v1.cpp +++ b/engines/kyra/sequences_v1.cpp @@ -236,9 +236,14 @@ void KyraEngine::seq_introStory() { _screen->clearPage(3); _screen->clearPage(0); - if (_flags.isTalkie) - return; - else if (_flags.lang == Common::EN_ANY && (_flags.platform == Common::kPlatformPC || _flags.platform == Common::kPlatformAmiga)) + if (_flags.isTalkie) { + // HACK: The Italian fan translation uses an special text screen here + // so we show it even though it is a talkie version. + if (_flags.lang == Common::IT_ITA) + _screen->loadBitmap("TEXT_ENG.CPS", 3, 3, 0); + else + return; + } else if (_flags.lang == Common::EN_ANY && (_flags.platform == Common::kPlatformPC || _flags.platform == Common::kPlatformAmiga)) _screen->loadBitmap("TEXT.CPS", 3, 3, _screen->_currentPalette); else if (_flags.lang == Common::EN_ANY || _flags.lang == Common::JA_JPN) _screen->loadBitmap("TEXT_ENG.CPS", 3, 3, _screen->_currentPalette); -- cgit v1.2.3 From 52f4d0b7d93ccaa78267fd218b44ad95b3ff9505 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 13 Jul 2007 16:20:32 +0000 Subject: Add TODO: music looping does not work with compressed digital music svn-id: r28056 --- engines/saga/music.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'engines') diff --git a/engines/saga/music.cpp b/engines/saga/music.cpp index 0ba5482aae..950903f4bb 100644 --- a/engines/saga/music.cpp +++ b/engines/saga/music.cpp @@ -42,6 +42,10 @@ namespace Saga { // stream class, or if I should use a "wrapper" class, like I did for Broken // Sword 2, to make it easier to add support for compressed music... but I'll // worry about that later. +// Update by md5: Apparently, it wasn't a good idea. Compressed digital music +// is handled outside of this class, so looping does not work for compressed +// digital music yet +// TODO/FIXME: Add looping support for compressed digital music class RAWInputStream : public Audio::AudioStream { private: -- cgit v1.2.3 From eedec897f83beac6f5603bd93016c284ee73b529 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 13 Jul 2007 16:37:37 +0000 Subject: Rewrote and greatly simplified the SAGA detector, removing many duplicate and unneeded entries - Digital music will now always be enabled for all versions if the digital music file is present. The duplicate game entries with and without this file have been removed - Changed the way compressed sound files are detected. All the duplicate compressed sound entries have been removed - The Wyrmkeep Windows CD version is now properly distinguished from the DOS CD version - Unified all the different patch file entries (apart from the Mac patch file entries, which are of a different type). If a patch file is not found, it's ignored svn-id: r28058 --- engines/saga/actor.h | 2 +- engines/saga/detection.cpp | 26 +- engines/saga/detection_tables.h | 924 ++++++---------------------------------- engines/saga/rscfile.cpp | 124 +++++- engines/saga/saga.cpp | 3 +- engines/saga/saga.h | 2 + 6 files changed, 270 insertions(+), 811 deletions(-) (limited to 'engines') diff --git a/engines/saga/actor.h b/engines/saga/actor.h index b9ec62337c..213f337d1c 100644 --- a/engines/saga/actor.h +++ b/engines/saga/actor.h @@ -41,7 +41,7 @@ namespace Saga { class HitZone; -// #define ACTOR_DEBUG 1 //only for actor pathfinding debug! +#define ACTOR_DEBUG 1 //only for actor pathfinding debug! #define ACTOR_BARRIERS_MAX 16 diff --git a/engines/saga/detection.cpp b/engines/saga/detection.cpp index 2096ca9af1..2c8089529f 100644 --- a/engines/saga/detection.cpp +++ b/engines/saga/detection.cpp @@ -69,7 +69,19 @@ int SagaEngine::getFontsCount() const { return _gameDescription->fontsCount; } int SagaEngine::getGameId() const { return _gameDescription->gameId; } int SagaEngine::getGameType() const { return _gameDescription->gameType; } -uint32 SagaEngine::getFeatures() const { return _gameDescription->features; } + +uint32 SagaEngine::getFeatures() const { + uint32 result = _gameDescription->features; + + if (_gf_wyrmkeep) + result |= GF_WYRMKEEP; + + if (_gf_compressed_sounds) + result |= GF_COMPRESSED_SOUNDS; + + return result; +} + Common::Language SagaEngine::getLanguage() const { return _gameDescription->desc.language; } Common::Platform SagaEngine::getPlatform() const { return _gameDescription->desc.platform; } int SagaEngine::getGameNumber() const { return _gameNumber; } @@ -133,6 +145,18 @@ bool SagaEngine::initGame() { _displayClip.right = getDisplayInfo().logicalWidth; _displayClip.bottom = getDisplayInfo().logicalHeight; + if (Common::File::exists("graphics/credit3n.dlt")) { + _gf_wyrmkeep = true; + } + + // If a compressed sound file is found in the game's directory, set the compressed flag to true + if (Common::File::exists("music.cmp") || Common::File::exists("musicd.cmp") || + Common::File::exists("sounds.cmp") || Common::File::exists("soundsd.cmp") || + Common::File::exists("voices.cmp") || Common::File::exists("voicesd.cmp") || + Common::File::exists("inherit the earth voices.cmp")) { + _gf_compressed_sounds = true; + } + return _resource->createContexts(); } diff --git a/engines/saga/detection_tables.h b/engines/saga/detection_tables.h index 5fc3a70c92..bf571e2c13 100644 --- a/engines/saga/detection_tables.h +++ b/engines/saga/detection_tables.h @@ -201,7 +201,8 @@ static const GameSoundInfo ITECD_GameSound = { true }; -static const GamePatchDescription ITEWinPatch1_Files[] = { +// Patch files. Files not found will be ignored +static const GamePatchDescription ITEPatch_Files[] = { { "cave.mid", GAME_RESOURCEFILE, 9, NULL}, { "intro.mid", GAME_RESOURCEFILE, 10, NULL}, { "fvillage.mid", GAME_RESOURCEFILE, 11, NULL}, @@ -235,31 +236,11 @@ static const GamePatchDescription ITEWinPatch1_Files[] = { { "wyrm3.dlt", GAME_RESOURCEFILE, 1532, NULL}, { "wyrm4.dlt", GAME_RESOURCEFILE, 1533, NULL}, { "credit3n.dlt", GAME_RESOURCEFILE, 1796, NULL}, + { "credit3m.dlt", GAME_RESOURCEFILE, 1796, NULL}, // Macintosh { "credit4n.dlt", GAME_RESOURCEFILE, 1797, NULL}, - { "p2_a.voc", GAME_VOICEFILE, 4, NULL} -}; - -static const GamePatchDescription ITEWinPatch2_Files[] = { - { "cave.mid", GAME_RESOURCEFILE, 9, NULL}, - { "intro.mid", GAME_RESOURCEFILE, 10, NULL}, - { "fvillage.mid", GAME_RESOURCEFILE, 11, NULL}, - { "elkfanfare.mid", GAME_RESOURCEFILE, 19, NULL}, - { "bcexpl.mid", GAME_RESOURCEFILE, 20, NULL}, - { "boargtnt.mid", GAME_RESOURCEFILE, 21, NULL}, - { "explorea.mid", GAME_RESOURCEFILE, 23, NULL}, - { "sweet.mid", GAME_RESOURCEFILE, 32, NULL}, - - { "wyrm.pak", GAME_RESOURCEFILE, 1529, NULL}, - { "wyrm1.dlt", GAME_RESOURCEFILE, 1530, NULL}, - { "wyrm2.dlt", GAME_RESOURCEFILE, 1531, NULL}, - { "wyrm3.dlt", GAME_RESOURCEFILE, 1532, NULL}, + { "credit4m.dlt", GAME_RESOURCEFILE, 1797, NULL}, // Macintosh + { "p2_a.voc", GAME_VOICEFILE, 4, NULL}, { "p2_a.iaf", GAME_VOICEFILE, 4, &ITECD_GameSound} -/* boarhall.bbm - elkenter.bbm - ferrets.bbm - ratdoor.bbm - sanctuar.bbm - tycho.bbm*/ }; static const GamePatchDescription ITEMacPatch_Files[] = { @@ -273,16 +254,6 @@ static const GamePatchDescription ITEMacPatch_Files[] = { { "p2_a.iaf", GAME_VOICEFILE, 4, &ITEMACCD_GameSound} }; -static const GamePatchDescription ITELinPatch_Files[] = { - { "wyrm.pak", GAME_RESOURCEFILE, 1529, NULL}, - { "wyrm1.dlt", GAME_RESOURCEFILE, 1530, NULL}, - { "wyrm2.dlt", GAME_RESOURCEFILE, 1531, NULL}, - { "wyrm3.dlt", GAME_RESOURCEFILE, 1532, NULL}, - { "credit3n.dlt", GAME_RESOURCEFILE, 1796, NULL}, - { "credit4n.dlt", GAME_RESOURCEFILE, 1797, NULL}, - { "P2_A.iaf", GAME_VOICEFILE, 4, &ITECD_GameSound} -}; - // IHNM section static const GameResourceDescription IHNM_Resources = { @@ -326,6 +297,9 @@ static const GameSoundInfo IHNM_GameSound = { }; static const SAGAGameDescription gameDescriptions[] = { + // ITE Section //////////////////////////////////////////////////////////////////////////////////////////// + // ITE Demos ////////////////////////////////////////////////////////////////////////////////////////////// + // Inherit the earth - DOS Demo version // sound unchecked { @@ -357,17 +331,18 @@ static const SAGAGameDescription gameDescriptions[] = { NULL, }, - // Inherit the earth - MAC Demo version 2 + // Inherit the earth - MAC Demo version 1 and 2 + // Demo 1 has normal scenes, demo 2 has scene substitutes but the files are the same (apart from musicd.rsc) { { "ite", - "Demo 2", + "Demo 1/2", { {"ited.rsc", GAME_RESOURCEFILE, "addfc9d82bc2fa1f4cab23743c652c08", -1}, {"scriptsd.rsc", GAME_SCRIPTFILE, "fded5c59b8b7c5976229f960d21e6b0b", -1}, - {"soundsd.rsc", GAME_SOUNDFILE, "b3a831fbed337d1f1300fee1dd474f6c", -1}, - {"voicesd.rsc", GAME_VOICEFILE, "e139d86bab2ee8ba3157337f894a92d4", -1}, - {"musicd.rsc", GAME_MUSICFILE, "495bdde51fd9f4bea2b9c911091b1ab2", -1}, + //{"soundsd.rsc", GAME_SOUNDFILE, "b3a831fbed337d1f1300fee1dd474f6c", -1}, + //{"voicesd.rsc", GAME_VOICEFILE, "e139d86bab2ee8ba3157337f894a92d4", -1}, + //{"musicd.rsc", GAME_MUSICFILE, "1a91cd60169f367ecb6c6e058d899b2f", -1}, { NULL, 0, NULL, 0} }, Common::EN_ANY, @@ -375,92 +350,98 @@ static const SAGAGameDescription gameDescriptions[] = { Common::ADGF_DEMO }, GType_ITE, - GID_ITE_MACDEMO2, - GF_BIG_ENDIAN_DATA | GF_WYRMKEEP | GF_CD_FX | GF_SCENE_SUBSTITUTES, + GID_ITE_MACDEMO1, + GF_BIG_ENDIAN_DATA | GF_WYRMKEEP | GF_CD_FX, ITE_DEFAULT_SCENE, &ITE_Resources, ARRAYSIZE(ITEWINDEMO_GameFonts), ITEWINDEMO_GameFonts, &ITEMACDEMO_GameVoice, &ITEMACDEMO_GameSound, - &ITEMACDEMO_GameMusic, + &ITEMACCD_GameMusic, ARRAYSIZE(ITEMacPatch_Files), ITEMacPatch_Files, }, - // Inherit the earth - MAC Demo version 1 + // Inherit the earth - Win32 Demo version 2/3, Linux Demo version + // Win32 Version 3 and Linux Demo version have digital music, Win32 version 2 has MIDI music + // These demos have scene substitutes, and can only be distinguished from Win32 demo 1 (below) + // from soundsd.rsc and voicesd.rsc { { "ite", - "Demo 1", + "Win Demo 2/3, Linux Demo", { - {"ited.rsc", GAME_RESOURCEFILE, "addfc9d82bc2fa1f4cab23743c652c08", -1}, - {"scriptsd.rsc", GAME_SCRIPTFILE, "fded5c59b8b7c5976229f960d21e6b0b", -1}, - {"soundsd.rsc", GAME_SOUNDFILE, "b3a831fbed337d1f1300fee1dd474f6c", -1}, + {"ited.rsc", GAME_RESOURCEFILE, "3a450852cbf3c80773984d565647e6ac", -1}, + {"scriptsd.rsc", GAME_SCRIPTFILE, "3f12b67fa93e56e1a6be39d2921d80bb", -1}, + {"soundsd.rsc", GAME_SOUNDFILE, "95a6c148e22e99a8c243f2978223583c", -1}, {"voicesd.rsc", GAME_VOICEFILE, "e139d86bab2ee8ba3157337f894a92d4", -1}, - {"musicd.rsc", GAME_MUSICFILE, "1a91cd60169f367ecb6c6e058d899b2f", -1}, + //{"musicd.rsc", GAME_MUSICFILE, "d6454756517f042f01210458abe8edd4", -1}, { NULL, 0, NULL, 0} }, Common::EN_ANY, - Common::kPlatformMacintosh, + Common::kPlatformWindows, Common::ADGF_DEMO }, GType_ITE, - GID_ITE_MACDEMO1, - GF_BIG_ENDIAN_DATA | GF_WYRMKEEP | GF_CD_FX, + GID_ITE_WINDEMO3, + GF_WYRMKEEP | GF_CD_FX | GF_SCENE_SUBSTITUTES, ITE_DEFAULT_SCENE, &ITE_Resources, ARRAYSIZE(ITEWINDEMO_GameFonts), ITEWINDEMO_GameFonts, - &ITEMACDEMO_GameVoice, - &ITEMACDEMO_GameSound, - &ITEMACCD_GameMusic, - ARRAYSIZE(ITEMacPatch_Files), - ITEMacPatch_Files, + &ITEWINDEMO2_GameVoice, + &ITEWINDEMO2_GameSound, + &ITELINDEMO_GameMusic, + ARRAYSIZE(ITEPatch_Files), + ITEPatch_Files, }, - // Inherit the earth - MAC CD Guild version + // Inherit the earth - Win32 Demo version 1 + // Demo version 1 does not have scene substitutes, and can only be distinguished from demo 2/3 + // from soundsd.rsc and voicesd.rsc { { "ite", - "CD", + "Demo 1", { - {"ite resources.bin", GAME_RESOURCEFILE | GAME_MACBINARY, "0bd506aa887bfc7965f695c6bd28237d", -1}, - {"ite scripts.bin", GAME_SCRIPTFILE | GAME_MACBINARY, "af0d7a2588e09ad3ecbc5b474ea238bf", -1}, - {"ite sounds.bin", GAME_SOUNDFILE | GAME_MACBINARY, "441426c6bb2a517f65c7e49b57f7a345", -1}, - {"ite music.bin", GAME_MUSICFILE_GM | GAME_MACBINARY, "c1d20324b7cdf1650e67061b8a93251c", -1}, - {"ite voices.bin", GAME_VOICEFILE | GAME_MACBINARY, "dba92ae7d57e942250fe135609708369", -1}, + {"ited.rsc", GAME_RESOURCEFILE, "3a450852cbf3c80773984d565647e6ac", -1}, + {"scriptsd.rsc", GAME_SCRIPTFILE, "3f12b67fa93e56e1a6be39d2921d80bb", -1}, + {"soundsd.rsc", GAME_SOUNDFILE, "a741139dd7365a13f463cd896ff9969a", -1}, + {"voicesd.rsc", GAME_VOICEFILE, "0759eaf5b64ae19fd429920a70151ad3", -1}, { NULL, 0, NULL, 0} }, Common::EN_ANY, - Common::kPlatformMacintosh, - Common::ADGF_NO_FLAGS + Common::kPlatformWindows, + Common::ADGF_DEMO }, GType_ITE, - GID_ITE_MACCD_G, - GF_BIG_ENDIAN_DATA | GF_CD_FX, + GID_ITE_WINDEMO1, + GF_WYRMKEEP | GF_CD_FX, ITE_DEFAULT_SCENE, &ITE_Resources, ARRAYSIZE(ITEWINDEMO_GameFonts), ITEWINDEMO_GameFonts, - &ITEMACCD_G_GameSound, - &ITEMACCD_G_GameSound, - NULL, - 0, + &ITEWINDEMO1_GameSound, + &ITEWINDEMO1_GameSound, NULL, + ARRAYSIZE(ITEPatch_Files), + ITEPatch_Files, }, - // Inherit the earth - MAC CD Wyrmkeep version + // ITE Mac versions /////////////////////////////////////////////////////////////////////////////////////// + + // Inherit the earth - MAC CD Guild version { { "ite", - "Wyrmkeep CD", + "CD", { - {"ite.rsc", GAME_RESOURCEFILE, "4f7fa11c5175980ed593392838523060", -1}, - {"scripts.rsc", GAME_SCRIPTFILE, "adf1f46c1d0589083996a7060c798ad0", -1}, - {"sounds.rsc", GAME_SOUNDFILE, "95863b89a0916941f6c5e1789843ba14", -1}, - {"inherit the earth voices", GAME_VOICEFILE, "c14c4c995e7a0d3828e3812a494301b7", -1}, - {"music.rsc", GAME_MUSICFILE, "1a91cd60169f367ecb6c6e058d899b2f", -1}, + {"ite resources.bin", GAME_RESOURCEFILE | GAME_MACBINARY, "0bd506aa887bfc7965f695c6bd28237d", -1}, + {"ite scripts.bin", GAME_SCRIPTFILE | GAME_MACBINARY, "af0d7a2588e09ad3ecbc5b474ea238bf", -1}, + {"ite sounds.bin", GAME_SOUNDFILE | GAME_MACBINARY, "441426c6bb2a517f65c7e49b57f7a345", -1}, + {"ite music.bin", GAME_MUSICFILE_GM | GAME_MACBINARY, "c1d20324b7cdf1650e67061b8a93251c", -1}, + {"ite voices.bin", GAME_VOICEFILE | GAME_MACBINARY, "dba92ae7d57e942250fe135609708369", -1}, { NULL, 0, NULL, 0} }, Common::EN_ANY, @@ -468,20 +449,20 @@ static const SAGAGameDescription gameDescriptions[] = { Common::ADGF_NO_FLAGS }, GType_ITE, - GID_ITE_MACCD, - GF_BIG_ENDIAN_DATA | GF_WYRMKEEP | GF_CD_FX, + GID_ITE_MACCD_G, + GF_BIG_ENDIAN_DATA | GF_CD_FX, ITE_DEFAULT_SCENE, &ITE_Resources, ARRAYSIZE(ITEWINDEMO_GameFonts), ITEWINDEMO_GameFonts, - &ITEMACCD_GameSound, - &ITEMACCD_GameSound, - &ITEMACCD_GameMusic, - ARRAYSIZE(ITEMacPatch_Files), - ITEMacPatch_Files, + &ITEMACCD_G_GameSound, + &ITEMACCD_G_GameSound, + NULL, + 0, + NULL, }, - // Inherit the earth - MAC CD Wyrmkeep version (compressed sound) + // Inherit the earth - MAC CD Wyrmkeep version { { "ite", @@ -489,9 +470,9 @@ static const SAGAGameDescription gameDescriptions[] = { { {"ite.rsc", GAME_RESOURCEFILE, "4f7fa11c5175980ed593392838523060", -1}, {"scripts.rsc", GAME_SCRIPTFILE, "adf1f46c1d0589083996a7060c798ad0", -1}, - {"sounds.cmp", GAME_SOUNDFILE, NULL, -1}, - {"inherit the earth voices.cmp",GAME_VOICEFILE, NULL, -1}, - {"music.cmp", GAME_MUSICFILE, NULL, -1}, + //{"sounds.rsc", GAME_SOUNDFILE, "95863b89a0916941f6c5e1789843ba14", -1}, + //{"inherit the earth voices", GAME_VOICEFILE, "c14c4c995e7a0d3828e3812a494301b7", -1}, + //{"music.rsc", GAME_MUSICFILE, "1a91cd60169f367ecb6c6e058d899b2f", -1}, { NULL, 0, NULL, 0} }, Common::EN_ANY, @@ -500,7 +481,7 @@ static const SAGAGameDescription gameDescriptions[] = { }, GType_ITE, GID_ITE_MACCD, - GF_BIG_ENDIAN_DATA | GF_WYRMKEEP | GF_CD_FX | GF_COMPRESSED_SOUNDS, + GF_BIG_ENDIAN_DATA | GF_WYRMKEEP | GF_CD_FX, ITE_DEFAULT_SCENE, &ITE_Resources, ARRAYSIZE(ITEWINDEMO_GameFonts), @@ -512,128 +493,7 @@ static const SAGAGameDescription gameDescriptions[] = { ITEMacPatch_Files, }, - // Inherit the earth - Linux Demo version - // Note: it should be before GID_ITE_WINDEMO2 version - { - { - "ite", - "Demo", - { - {"ited.rsc", GAME_RESOURCEFILE, "3a450852cbf3c80773984d565647e6ac", -1}, - {"scriptsd.rsc", GAME_SCRIPTFILE, "3f12b67fa93e56e1a6be39d2921d80bb", -1}, - {"soundsd.rsc", GAME_SOUNDFILE, "95a6c148e22e99a8c243f2978223583c", 2026769}, - {"voicesd.rsc", GAME_VOICEFILE, "e139d86bab2ee8ba3157337f894a92d4", -1}, - {"musicd.rsc", GAME_MUSICFILE, "d6454756517f042f01210458abe8edd4", -1}, - { NULL, 0, NULL, 0} - }, - Common::EN_ANY, - Common::kPlatformLinux, - Common::ADGF_DEMO - }, - GType_ITE, - GID_ITE_LINDEMO, - GF_WYRMKEEP | GF_CD_FX | GF_SCENE_SUBSTITUTES, - ITE_DEFAULT_SCENE, - &ITE_Resources, - ARRAYSIZE(ITEWINDEMO_GameFonts), - ITEWINDEMO_GameFonts, - &ITEWINDEMO2_GameVoice, - &ITEWINDEMO2_GameSound, - &ITELINDEMO_GameMusic, - ARRAYSIZE(ITELinPatch_Files), - ITELinPatch_Files, - }, - - // Inherit the earth - Win32 Demo version 3 - { - { - "ite", - "Demo 3", - { - {"ited.rsc", GAME_RESOURCEFILE, "3a450852cbf3c80773984d565647e6ac", -1}, - {"scriptsd.rsc", GAME_SCRIPTFILE, "3f12b67fa93e56e1a6be39d2921d80bb", -1}, - {"soundsd.rsc", GAME_SOUNDFILE, "95a6c148e22e99a8c243f2978223583c", 2005074}, - {"voicesd.rsc", GAME_VOICEFILE, "e139d86bab2ee8ba3157337f894a92d4", -1}, - {"musicd.rsc", GAME_MUSICFILE, "d6454756517f042f01210458abe8edd4", -1}, - { NULL, 0, NULL, 0} - }, - Common::EN_ANY, - Common::kPlatformWindows, - Common::ADGF_DEMO - }, - GType_ITE, - GID_ITE_WINDEMO3, - GF_WYRMKEEP | GF_CD_FX | GF_SCENE_SUBSTITUTES, - ITE_DEFAULT_SCENE, - &ITE_Resources, - ARRAYSIZE(ITEWINDEMO_GameFonts), - ITEWINDEMO_GameFonts, - &ITEWINDEMO2_GameVoice, - &ITEWINDEMO2_GameSound, - &ITELINDEMO_GameMusic, - ARRAYSIZE(ITEWinPatch2_Files), - ITEWinPatch2_Files, - }, - - // Inherit the earth - Win32 Demo version 2 - { - { - "ite", - "Demo 2", - { - {"ited.rsc", GAME_RESOURCEFILE, "3a450852cbf3c80773984d565647e6ac", -1}, - {"scriptsd.rsc", GAME_SCRIPTFILE, "3f12b67fa93e56e1a6be39d2921d80bb", -1}, - {"soundsd.rsc", GAME_SOUNDFILE, "95a6c148e22e99a8c243f2978223583c", 2005074}, - {"voicesd.rsc", GAME_VOICEFILE, "e139d86bab2ee8ba3157337f894a92d4", -1}, - { NULL, 0, NULL, 0} - }, - Common::EN_ANY, - Common::kPlatformWindows, - Common::ADGF_DEMO - }, - GType_ITE, - GID_ITE_WINDEMO2, - GF_WYRMKEEP | GF_CD_FX | GF_SCENE_SUBSTITUTES, - ITE_DEFAULT_SCENE, - &ITE_Resources, - ARRAYSIZE(ITEWINDEMO_GameFonts), - ITEWINDEMO_GameFonts, - &ITEWINDEMO2_GameVoice, - &ITEWINDEMO2_GameSound, - NULL, - ARRAYSIZE(ITEWinPatch2_Files), - ITEWinPatch2_Files, - }, - - // Inherit the earth - Win32 Demo version 1 - { - { - "ite", - "Demo 1", - { - {"ited.rsc", GAME_RESOURCEFILE, "3a450852cbf3c80773984d565647e6ac", -1}, - {"scriptsd.rsc", GAME_SCRIPTFILE, "3f12b67fa93e56e1a6be39d2921d80bb", -1}, - {"soundsd.rsc", GAME_SOUNDFILE, "a741139dd7365a13f463cd896ff9969a", -1}, - {"voicesd.rsc", GAME_VOICEFILE, "0759eaf5b64ae19fd429920a70151ad3", -1}, - { NULL, 0, NULL, 0} - }, - Common::EN_ANY, - Common::kPlatformWindows, - Common::ADGF_DEMO - }, - GType_ITE, - GID_ITE_WINDEMO1, - GF_WYRMKEEP | GF_CD_FX, - ITE_DEFAULT_SCENE, - &ITE_Resources, - ARRAYSIZE(ITEWINDEMO_GameFonts), - ITEWINDEMO_GameFonts, - &ITEWINDEMO1_GameSound, - &ITEWINDEMO1_GameSound, - NULL, - ARRAYSIZE(ITEWinPatch1_Files), - ITEWinPatch1_Files, - }, + // ITE CD versions //////////////////////////////////////////////////////////////////////////////////////// // Inherit the earth - Wyrmkeep combined Windows/Mac/Linux CD @@ -648,9 +508,9 @@ static const SAGAGameDescription gameDescriptions[] = { { {"ite.rsc", GAME_RESOURCEFILE, "a6433e34b97b15e64fe8214651012db9", -1}, {"scripts.rsc", GAME_SCRIPTFILE, "a891405405edefc69c9d6c420c868b84", -1}, - {"sounds.rsc", GAME_SOUNDFILE, "e2ccb61c325d6d1ead3be0e731fe29fe", -1}, - {"inherit the earth voices", GAME_VOICEFILE | GAME_SWAPENDIAN, "c14c4c995e7a0d3828e3812a494301b7", -1}, - {"music.rsc", GAME_MUSICFILE, "d6454756517f042f01210458abe8edd4", -1}, + //{"sounds.rsc", GAME_SOUNDFILE, "e2ccb61c325d6d1ead3be0e731fe29fe", -1}, + //{"inherit the earth voices", GAME_VOICEFILE | GAME_SWAPENDIAN, "c14c4c995e7a0d3828e3812a494301b7", -1}, + //{"music.rsc", GAME_MUSICFILE, "d6454756517f042f01210458abe8edd4", -1}, { NULL, 0, NULL, 0} }, Common::EN_ANY, @@ -671,479 +531,109 @@ static const SAGAGameDescription gameDescriptions[] = { NULL, }, - // Inherit the earth - Wyrmkeep combined Windows/Mac/Linux CD (compressed sound) - - // version is different from the other Wyrmkeep re-releases in that it does - // not have any substitute files. Presumably the ite.rsc file has been - // modified to include the Wyrmkeep changes. The resource files are little- - // endian, except for the voice file which is big-endian. + // Inherit the earth - Windows/Linux/DOS CD version { { "ite", - "Multi-OS CD Version", + "Windows/Linux/DOS CD Version", { - {"ite.rsc", GAME_RESOURCEFILE, "a6433e34b97b15e64fe8214651012db9", -1}, - {"scripts.rsc", GAME_SCRIPTFILE, "a891405405edefc69c9d6c420c868b84", -1}, - {"sounds.cmp", GAME_SOUNDFILE, NULL, -1}, - {"inherit the earth voices.cmp",GAME_VOICEFILE | GAME_SWAPENDIAN, NULL, -1}, - {"music.cmp", GAME_MUSICFILE, NULL, -1}, + {"ite.rsc", GAME_RESOURCEFILE, "8f4315a9bb10ec839253108a032c8b54", -1}, + {"scripts.rsc", GAME_SCRIPTFILE, "a891405405edefc69c9d6c420c868b84", -1}, + //{"sounds.rsc", GAME_SOUNDFILE, "e2ccb61c325d6d1ead3be0e731fe29fe", -1}, + //{"voices.rsc", GAME_VOICEFILE, "41bb6b95d792dde5196bdb78740895a6", -1}, + //{"music.rsc", GAME_MUSICFILE, "d6454756517f042f01210458abe8edd4", -1}, { NULL, 0, NULL, 0} }, Common::EN_ANY, - Common::kPlatformUnknown, + Common::kPlatformPC, Common::ADGF_NO_FLAGS }, GType_ITE, - GID_ITE_MULTICD, - GF_WYRMKEEP | GF_CD_FX | GF_COMPRESSED_SOUNDS, + GID_ITE_CD, + GF_CD_FX, ITE_DEFAULT_SCENE, &ITE_Resources, ARRAYSIZE(ITECD_GameFonts), ITECD_GameFonts, - &ITEMACCD_GameSound, + &ITECD_GameSound, &ITECD_GameSound, &ITEMACCD_GameMusic, - 0, - NULL, + ARRAYSIZE(ITEPatch_Files), + ITEPatch_Files, }, - // Inherit the earth - Wyrmkeep Linux CD version + // Inherit the earth - DOS CD version { { "ite", "CD Version", { {"ite.rsc", GAME_RESOURCEFILE, "8f4315a9bb10ec839253108a032c8b54", -1}, - {"scripts.rsc", GAME_SCRIPTFILE, "a891405405edefc69c9d6c420c868b84", -1}, - {"sounds.rsc", GAME_SOUNDFILE, "e2ccb61c325d6d1ead3be0e731fe29fe", -1}, - {"voices.rsc", GAME_VOICEFILE, "41bb6b95d792dde5196bdb78740895a6", -1}, - {"music.rsc", GAME_MUSICFILE, "d6454756517f042f01210458abe8edd4", -1}, + {"scripts.rsc", GAME_SCRIPTFILE, "50a0d2d7003c926a3832d503c8534e90", -1}, + //{"sounds.rsc", GAME_SOUNDFILE, "e2ccb61c325d6d1ead3be0e731fe29fe", -1}, + //{"voices.rsc", GAME_VOICEFILE, "41bb6b95d792dde5196bdb78740895a6", -1}, { NULL, 0, NULL, 0} }, Common::EN_ANY, - Common::kPlatformLinux, + Common::kPlatformPC, Common::ADGF_NO_FLAGS }, GType_ITE, - GID_ITE_LINCD, - GF_WYRMKEEP | GF_CD_FX, + GID_ITE_CD_G, + GF_CD_FX, ITE_DEFAULT_SCENE, &ITE_Resources, ARRAYSIZE(ITECD_GameFonts), ITECD_GameFonts, &ITECD_GameSound, &ITECD_GameSound, - &ITEMACCD_GameMusic, - ARRAYSIZE(ITELinPatch_Files), - ITELinPatch_Files, + NULL, + 0, + NULL, }, - // Inherit the earth - Wyrmkeep Linux CD version (compressed sound) + // Inherit the earth - DOS CD German version + // reported by mld. Bestsellergamers cover disk { { "ite", "CD Version", { - {"ite.rsc", GAME_RESOURCEFILE, "8f4315a9bb10ec839253108a032c8b54", -1}, + {"ite.rsc", GAME_RESOURCEFILE, "869fc23c8f38f575979ec67152914fee", -1}, {"scripts.rsc", GAME_SCRIPTFILE, "a891405405edefc69c9d6c420c868b84", -1}, - {"sounds.cmp", GAME_SOUNDFILE, NULL, -1}, - {"voices.cmp", GAME_VOICEFILE, NULL, -1}, - {"music.cmp", GAME_MUSICFILE, NULL, -1}, + //{"sounds.rsc", GAME_SOUNDFILE, "e2ccb61c325d6d1ead3be0e731fe29fe", -1}, + //{"voices.rsc", GAME_VOICEFILE, "2fbad5d10b9b60a3415dc4aebbb11718", -1}, { NULL, 0, NULL, 0} }, - Common::EN_ANY, - Common::kPlatformLinux, + Common::DE_DEU, + Common::kPlatformPC, Common::ADGF_NO_FLAGS }, GType_ITE, - GID_ITE_LINCD, - GF_WYRMKEEP | GF_CD_FX | GF_COMPRESSED_SOUNDS, + GID_ITE_CD_DE, + GF_CD_FX, ITE_DEFAULT_SCENE, &ITE_Resources, ARRAYSIZE(ITECD_GameFonts), ITECD_GameFonts, &ITECD_GameSound, &ITECD_GameSound, - &ITEMACCD_GameMusic, - ARRAYSIZE(ITELinPatch_Files), - ITELinPatch_Files, + NULL, + 0, + NULL, }, - // Inherit the earth - Wyrmkeep Windows CD version + // ITE floppy versions //////////////////////////////////////////////////////////////////////////////////// + + // Inherit the earth - German Floppy version { { "ite", - "CD Version", + "Floppy", { - {"ite.rsc", GAME_RESOURCEFILE, "8f4315a9bb10ec839253108a032c8b54", -1}, - {"scripts.rsc", GAME_SCRIPTFILE, "a891405405edefc69c9d6c420c868b84", -1}, - {"sounds.rsc", GAME_SOUNDFILE, "e2ccb61c325d6d1ead3be0e731fe29fe", -1}, - {"voices.rsc", GAME_VOICEFILE, "41bb6b95d792dde5196bdb78740895a6", -1}, - { NULL, 0, NULL, 0} - }, - Common::EN_ANY, - Common::kPlatformWindows, - Common::ADGF_NO_FLAGS - }, - GType_ITE, - GID_ITE_WINCD, - GF_WYRMKEEP | GF_CD_FX, - ITE_DEFAULT_SCENE, - &ITE_Resources, - ARRAYSIZE(ITECD_GameFonts), - ITECD_GameFonts, - &ITECD_GameSound, - &ITECD_GameSound, - NULL, - ARRAYSIZE(ITEWinPatch1_Files), - ITEWinPatch1_Files, - }, - - // Inherit the earth - Wyrmkeep Windows CD version (compressed sound) - { - { - "ite", - "CD Version", - { - {"ite.rsc", GAME_RESOURCEFILE, "8f4315a9bb10ec839253108a032c8b54", -1}, - {"scripts.rsc", GAME_SCRIPTFILE, "a891405405edefc69c9d6c420c868b84", -1}, - {"sounds.cmp", GAME_SOUNDFILE, NULL, -1}, - {"voices.cmp", GAME_VOICEFILE, NULL, -1}, - { NULL, 0, NULL, 0} - }, - Common::EN_ANY, - Common::kPlatformWindows, - Common::ADGF_NO_FLAGS - }, - GType_ITE, - GID_ITE_WINCD, - GF_WYRMKEEP | GF_CD_FX | GF_COMPRESSED_SOUNDS, - ITE_DEFAULT_SCENE, - &ITE_Resources, - ARRAYSIZE(ITECD_GameFonts), - ITECD_GameFonts, - &ITECD_GameSound, - &ITECD_GameSound, - NULL, - ARRAYSIZE(ITEWinPatch1_Files), - ITEWinPatch1_Files, - }, - - // Inherit the earth - DOS CD version - { - { - "ite", - "CD Version", - { - {"ite.rsc", GAME_RESOURCEFILE, "8f4315a9bb10ec839253108a032c8b54", -1}, - {"scripts.rsc", GAME_SCRIPTFILE, "50a0d2d7003c926a3832d503c8534e90", -1}, - {"sounds.rsc", GAME_SOUNDFILE, "e2ccb61c325d6d1ead3be0e731fe29fe", -1}, - {"voices.rsc", GAME_VOICEFILE, "41bb6b95d792dde5196bdb78740895a6", -1}, - { NULL, 0, NULL, 0} - }, - Common::EN_ANY, - Common::kPlatformPC, - Common::ADGF_NO_FLAGS - }, - GType_ITE, - GID_ITE_CD_G, - GF_CD_FX, - ITE_DEFAULT_SCENE, - &ITE_Resources, - ARRAYSIZE(ITECD_GameFonts), - ITECD_GameFonts, - &ITECD_GameSound, - &ITECD_GameSound, - NULL, - 0, - NULL, - }, - - // Inherit the earth - DOS CD version (compressed sound) - { - { - "ite", - "CD Version", - { - {"ite.rsc", GAME_RESOURCEFILE, "8f4315a9bb10ec839253108a032c8b54", -1}, - {"scripts.rsc", GAME_SCRIPTFILE, "50a0d2d7003c926a3832d503c8534e90", -1}, - {"sounds.cmp", GAME_SOUNDFILE, NULL, -1}, - {"voices.cmp", GAME_VOICEFILE, NULL, -1}, - { NULL, 0, NULL, 0} - }, - Common::EN_ANY, - Common::kPlatformPC, - Common::ADGF_NO_FLAGS - }, - GType_ITE, - GID_ITE_CD_G, - GF_CD_FX | GF_COMPRESSED_SOUNDS, - ITE_DEFAULT_SCENE, - &ITE_Resources, - ARRAYSIZE(ITECD_GameFonts), - ITECD_GameFonts, - &ITECD_GameSound, - &ITECD_GameSound, - NULL, - 0, - NULL, - }, - - // Inherit the earth - DOS CD version with digital music - { - { - "ite", - "CD Version", - { - {"ite.rsc", GAME_RESOURCEFILE, "8f4315a9bb10ec839253108a032c8b54", -1}, - {"scripts.rsc", GAME_SCRIPTFILE, "50a0d2d7003c926a3832d503c8534e90", -1}, - {"sounds.rsc", GAME_SOUNDFILE, "e2ccb61c325d6d1ead3be0e731fe29fe", -1}, - {"voices.rsc", GAME_VOICEFILE, "41bb6b95d792dde5196bdb78740895a6", -1}, - {"music.rsc", GAME_MUSICFILE, "d6454756517f042f01210458abe8edd4", -1}, - { NULL, 0, NULL, 0} - }, - Common::EN_ANY, - Common::kPlatformPC, - Common::ADGF_NO_FLAGS - }, - GType_ITE, - GID_ITE_CD_G2, - GF_CD_FX, - ITE_DEFAULT_SCENE, - &ITE_Resources, - ARRAYSIZE(ITECD_GameFonts), - ITECD_GameFonts, - &ITECD_GameSound, - &ITECD_GameSound, - &ITEMACCD_GameMusic, - 0, - NULL, - }, - - // Inherit the earth - DOS CD version with digital music (compressed sound) - { - { - "ite", - "CD Version", - { - {"ite.rsc", GAME_RESOURCEFILE, "8f4315a9bb10ec839253108a032c8b54", -1}, - {"scripts.rsc", GAME_SCRIPTFILE, "50a0d2d7003c926a3832d503c8534e90", -1}, - {"sounds.cmp", GAME_SOUNDFILE, NULL, -1}, - {"voices.cmp", GAME_VOICEFILE, NULL, -1}, - {"music.cmp", GAME_MUSICFILE, NULL, -1}, - { NULL, 0, NULL, 0} - }, - Common::EN_ANY, - Common::kPlatformPC, - Common::ADGF_NO_FLAGS - }, - GType_ITE, - GID_ITE_CD_G2, - GF_CD_FX | GF_COMPRESSED_SOUNDS, - ITE_DEFAULT_SCENE, - &ITE_Resources, - ARRAYSIZE(ITECD_GameFonts), - ITECD_GameFonts, - &ITECD_GameSound, - &ITECD_GameSound, - &ITEMACCD_GameMusic, - 0, - NULL, - }, - - // Inherit the earth - DOS CD German version - // reported by mld. Bestsellergamers cover disk - { - { - "ite", - "CD Version", - { - {"ite.rsc", GAME_RESOURCEFILE, "869fc23c8f38f575979ec67152914fee", -1}, - {"scripts.rsc", GAME_SCRIPTFILE, "a891405405edefc69c9d6c420c868b84", -1}, - {"sounds.rsc", GAME_SOUNDFILE, "e2ccb61c325d6d1ead3be0e731fe29fe", -1}, - {"voices.rsc", GAME_VOICEFILE, "2fbad5d10b9b60a3415dc4aebbb11718", -1}, - { NULL, 0, NULL, 0} - }, - Common::DE_DEU, - Common::kPlatformPC, - Common::ADGF_NO_FLAGS - }, - GType_ITE, - GID_ITE_CD_DE, - GF_CD_FX, - ITE_DEFAULT_SCENE, - &ITE_Resources, - ARRAYSIZE(ITECD_GameFonts), - ITECD_GameFonts, - &ITECD_GameSound, - &ITECD_GameSound, - NULL, - 0, - NULL, - }, - - // Inherit the earth - DOS CD German version (compressed sound) - // reported by mld. Bestsellergamers cover disk - { - { - "ite", - "CD Version", - { - {"ite.rsc", GAME_RESOURCEFILE, "869fc23c8f38f575979ec67152914fee", -1}, - {"scripts.rsc", GAME_SCRIPTFILE, "a891405405edefc69c9d6c420c868b84", -1}, - {"sounds.cmp", GAME_SOUNDFILE, NULL, -1}, - {"voices.cmp", GAME_VOICEFILE, NULL, -1}, - { NULL, 0, NULL, 0} - }, - Common::DE_DEU, - Common::kPlatformPC, - Common::ADGF_NO_FLAGS - }, - GType_ITE, - GID_ITE_CD_DE, - GF_CD_FX | GF_COMPRESSED_SOUNDS, - ITE_DEFAULT_SCENE, - &ITE_Resources, - ARRAYSIZE(ITECD_GameFonts), - ITECD_GameFonts, - &ITECD_GameSound, - &ITECD_GameSound, - NULL, - 0, - NULL, - }, - - // Inherit the earth - DOS CD German version with digital music - { - { - "ite", - "CD Version", - { - {"ite.rsc", GAME_RESOURCEFILE, "869fc23c8f38f575979ec67152914fee", -1}, - {"scripts.rsc", GAME_SCRIPTFILE, "a891405405edefc69c9d6c420c868b84", -1}, - {"sounds.rsc", GAME_SOUNDFILE, "e2ccb61c325d6d1ead3be0e731fe29fe", -1}, - {"voices.rsc", GAME_VOICEFILE, "2fbad5d10b9b60a3415dc4aebbb11718", -1}, - {"music.rsc", GAME_MUSICFILE, "d6454756517f042f01210458abe8edd4", -1}, - { NULL, 0, NULL, 0} - }, - Common::DE_DEU, - Common::kPlatformPC, - Common::ADGF_NO_FLAGS - }, - GType_ITE, - GID_ITE_CD_DE2, - GF_CD_FX, - ITE_DEFAULT_SCENE, - &ITE_Resources, - ARRAYSIZE(ITECD_GameFonts), - ITECD_GameFonts, - &ITECD_GameSound, - &ITECD_GameSound, - &ITEMACCD_GameMusic, - 0, - NULL, - }, - - // Inherit the earth - DOS CD German version with digital music (compressed sound) - { - { - "ite", - "CD Version", - { - {"ite.rsc", GAME_RESOURCEFILE, "869fc23c8f38f575979ec67152914fee", -1}, - {"scripts.rsc", GAME_SCRIPTFILE, "a891405405edefc69c9d6c420c868b84", -1}, - {"sounds.cmp", GAME_SOUNDFILE, NULL, -1}, - {"voices.cmp", GAME_VOICEFILE, NULL, -1}, - {"music.cmp", GAME_MUSICFILE, NULL, -1}, - { NULL, 0, NULL, 0} - }, - Common::DE_DEU, - Common::kPlatformPC, - Common::ADGF_NO_FLAGS - }, - GType_ITE, - GID_ITE_CD_DE2, - GF_CD_FX | GF_COMPRESSED_SOUNDS, - ITE_DEFAULT_SCENE, - &ITE_Resources, - ARRAYSIZE(ITECD_GameFonts), - ITECD_GameFonts, - &ITECD_GameSound, - &ITECD_GameSound, - &ITEMACCD_GameMusic, - 0, - NULL, - }, - - // Inherit the earth - CD version - { - { - "ite", - "CD Version", - { - {"ite.rsc", GAME_RESOURCEFILE, "8f4315a9bb10ec839253108a032c8b54", -1}, - {"scripts.rsc", GAME_SCRIPTFILE, "a891405405edefc69c9d6c420c868b84", -1}, - {"sounds.rsc", GAME_SOUNDFILE, "e2ccb61c325d6d1ead3be0e731fe29fe", -1}, - {"voices.rsc", GAME_VOICEFILE, "41bb6b95d792dde5196bdb78740895a6", -1}, - { NULL, 0, NULL, 0} - }, - Common::EN_ANY, - Common::kPlatformPC, - Common::ADGF_NO_FLAGS - }, - GType_ITE, - GID_ITE_CD, - GF_CD_FX, - ITE_DEFAULT_SCENE, - &ITE_Resources, - ARRAYSIZE(ITECD_GameFonts), - ITECD_GameFonts, - &ITECD_GameSound, - &ITECD_GameSound, - NULL, - 0, - NULL, - }, - - // Inherit the earth - CD version (compressed sound) - { - { - "ite", - "CD Version", - { - {"ite.rsc", GAME_RESOURCEFILE, "8f4315a9bb10ec839253108a032c8b54", -1}, - {"scripts.rsc", GAME_SCRIPTFILE, "a891405405edefc69c9d6c420c868b84", -1}, - {"sounds.cmp", GAME_SOUNDFILE, NULL, -1}, - {"voices.cmp", GAME_VOICEFILE, NULL, -1}, - { NULL, 0, NULL, 0} - }, - Common::EN_ANY, - Common::kPlatformPC, - Common::ADGF_NO_FLAGS - }, - GType_ITE, - GID_ITE_CD, - GF_CD_FX | GF_COMPRESSED_SOUNDS, - ITE_DEFAULT_SCENE, - &ITE_Resources, - ARRAYSIZE(ITECD_GameFonts), - ITECD_GameFonts, - &ITECD_GameSound, - &ITECD_GameSound, - NULL, - 0, - NULL, - }, - - // Inherit the earth - German Floppy version - { - { - "ite", - "Floppy", - { - {"ite.rsc", GAME_RESOURCEFILE, "869fc23c8f38f575979ec67152914fee", -1}, - {"scripts.rsc", GAME_SCRIPTFILE, "516f7330f8410057b834424ea719d1ef", -1}, - {"voices.rsc", GAME_SOUNDFILE | GAME_VOICEFILE, "0c9113e630f97ef0996b8c3114badb08", -1}, + {"ite.rsc", GAME_RESOURCEFILE, "869fc23c8f38f575979ec67152914fee", -1}, + {"scripts.rsc", GAME_SCRIPTFILE, "516f7330f8410057b834424ea719d1ef", -1}, + //{"voices.rsc", GAME_SOUNDFILE | GAME_VOICEFILE, "0c9113e630f97ef0996b8c3114badb08", -1}, { NULL, 0, NULL, 0} }, Common::DE_DEU, @@ -1164,95 +654,6 @@ static const SAGAGameDescription gameDescriptions[] = { NULL, }, - // Inherit the earth - German Floppy version (compressed sound) - { - { - "ite", - "Floppy", - { - {"ite.rsc", GAME_RESOURCEFILE, "869fc23c8f38f575979ec67152914fee", -1}, - {"scripts.rsc", GAME_SCRIPTFILE, "516f7330f8410057b834424ea719d1ef", -1}, - {"voices.cmp", GAME_SOUNDFILE | GAME_VOICEFILE, NULL, -1}, - { NULL, 0, NULL, 0} - }, - Common::DE_DEU, - Common::kPlatformPC, - Common::ADGF_NO_FLAGS - }, - GType_ITE, - GID_ITE_DISK_DE, - GF_COMPRESSED_SOUNDS, - ITE_DEFAULT_SCENE, - &ITE_Resources, - ARRAYSIZE(ITEDISK_GameFonts), - ITEDISK_GameFonts, - &ITEDISK_GameSound, - &ITEDISK_GameSound, - NULL, - 0, - NULL, - }, - - // Inherit the earth - German Floppy version with digital music - { - { - "ite", - "Floppy", - { - {"ite.rsc", GAME_RESOURCEFILE, "869fc23c8f38f575979ec67152914fee", -1}, - {"scripts.rsc", GAME_SCRIPTFILE, "516f7330f8410057b834424ea719d1ef", -1}, - {"voices.rsc", GAME_SOUNDFILE | GAME_VOICEFILE, "0c9113e630f97ef0996b8c3114badb08", -1}, - {"music.rsc", GAME_MUSICFILE, "d6454756517f042f01210458abe8edd4", -1}, - { NULL, 0, NULL, 0} - }, - Common::DE_DEU, - Common::kPlatformPC, - Common::ADGF_NO_FLAGS - }, - GType_ITE, - GID_ITE_DISK_DE2, - 0, - ITE_DEFAULT_SCENE, - &ITE_Resources, - ARRAYSIZE(ITEDISK_GameFonts), - ITEDISK_GameFonts, - &ITEDISK_GameSound, - &ITEDISK_GameSound, - &ITEMACCD_GameMusic, - 0, - NULL, - }, - - // Inherit the earth - German Floppy version with digital music (compressed sound) - { - { - "ite", - "Floppy", - { - {"ite.rsc", GAME_RESOURCEFILE, "869fc23c8f38f575979ec67152914fee", -1}, - {"scripts.rsc", GAME_SCRIPTFILE, "516f7330f8410057b834424ea719d1ef", -1}, - {"voices.cmp", GAME_SOUNDFILE | GAME_VOICEFILE, NULL, -1}, - {"music.cmp", GAME_MUSICFILE, NULL, -1}, - { NULL, 0, NULL, 0} - }, - Common::DE_DEU, - Common::kPlatformPC, - Common::ADGF_NO_FLAGS - }, - GType_ITE, - GID_ITE_DISK_DE2, - GF_COMPRESSED_SOUNDS, - ITE_DEFAULT_SCENE, - &ITE_Resources, - ARRAYSIZE(ITEDISK_GameFonts), - ITEDISK_GameFonts, - &ITEDISK_GameSound, - &ITEDISK_GameSound, - &ITEMACCD_GameMusic, - 0, - NULL, - }, - // Inherit the earth - Disk version { { @@ -1261,7 +662,7 @@ static const SAGAGameDescription gameDescriptions[] = { { {"ite.rsc", GAME_RESOURCEFILE, "8f4315a9bb10ec839253108a032c8b54", -1}, {"scripts.rsc", GAME_SCRIPTFILE, "516f7330f8410057b834424ea719d1ef", -1}, - {"voices.rsc", GAME_SOUNDFILE | GAME_VOICEFILE, "c46e4392fcd2e89bc91e5567db33b62d", -1}, + //{"voices.rsc", GAME_SOUNDFILE | GAME_VOICEFILE, "c46e4392fcd2e89bc91e5567db33b62d", -1}, { NULL, 0, NULL, 0} }, Common::EN_ANY, @@ -1282,94 +683,7 @@ static const SAGAGameDescription gameDescriptions[] = { NULL, }, - // Inherit the earth - Disk version (compressed sound) - { - { - "ite", - "Floppy", - { - {"ite.rsc", GAME_RESOURCEFILE, "8f4315a9bb10ec839253108a032c8b54", -1}, - {"scripts.rsc", GAME_SCRIPTFILE, "516f7330f8410057b834424ea719d1ef", -1}, - {"voices.cmp", GAME_SOUNDFILE | GAME_VOICEFILE, NULL, -1}, - { NULL, 0, NULL, 0} - }, - Common::EN_ANY, - Common::kPlatformPC, - Common::ADGF_NO_FLAGS - }, - GType_ITE, - GID_ITE_DISK_G, - GF_COMPRESSED_SOUNDS, - ITE_DEFAULT_SCENE, - &ITE_Resources, - ARRAYSIZE(ITEDISK_GameFonts), - ITEDISK_GameFonts, - &ITEDISK_GameSound, - &ITEDISK_GameSound, - NULL, - 0, - NULL, - }, - - // Inherit the earth - Disk version with digital music - { - { - "ite", - "Floppy", - { - {"ite.rsc", GAME_RESOURCEFILE, "8f4315a9bb10ec839253108a032c8b54", -1}, - {"scripts.rsc", GAME_SCRIPTFILE, "516f7330f8410057b834424ea719d1ef", -1}, - {"voices.rsc", GAME_SOUNDFILE | GAME_VOICEFILE, "c46e4392fcd2e89bc91e5567db33b62d", -1}, - {"music.rsc", GAME_MUSICFILE, "d6454756517f042f01210458abe8edd4", -1}, - { NULL, 0, NULL, 0} - }, - Common::EN_ANY, - Common::kPlatformPC, - Common::ADGF_NO_FLAGS - }, - GType_ITE, - GID_ITE_DISK_G2, - 0, - ITE_DEFAULT_SCENE, - &ITE_Resources, - ARRAYSIZE(ITEDISK_GameFonts), - ITEDISK_GameFonts, - &ITEDISK_GameSound, - &ITEDISK_GameSound, - &ITEMACCD_GameMusic, - 0, - NULL, - }, - - // Inherit the earth - Disk version with digital music (compressed sound) - { - { - "ite", - "Floppy", - { - {"ite.rsc", GAME_RESOURCEFILE, "8f4315a9bb10ec839253108a032c8b54", -1}, - {"scripts.rsc", GAME_SCRIPTFILE, "516f7330f8410057b834424ea719d1ef", -1}, - {"voices.cmp", GAME_SOUNDFILE | GAME_VOICEFILE, NULL, -1}, - {"music.cmp", GAME_MUSICFILE, NULL, -1}, - { NULL, 0, NULL, 0} - }, - Common::EN_ANY, - Common::kPlatformPC, - Common::ADGF_NO_FLAGS - }, - GType_ITE, - GID_ITE_DISK_G2, - GF_COMPRESSED_SOUNDS, - ITE_DEFAULT_SCENE, - &ITE_Resources, - ARRAYSIZE(ITEDISK_GameFonts), - ITEDISK_GameFonts, - &ITEDISK_GameSound, - &ITEDISK_GameSound, - &ITEMACCD_GameMusic, - 0, - NULL, - }, + // IHNM Section /////////////////////////////////////////////////////////////////////////////////////////// // I Have No Mouth And I Must Scream - Demo version { diff --git a/engines/saga/rscfile.cpp b/engines/saga/rscfile.cpp index 33e8a7d603..59dc42225c 100644 --- a/engines/saga/rscfile.cpp +++ b/engines/saga/rscfile.cpp @@ -343,18 +343,136 @@ bool Resource::loadContext(ResourceContext *context) { bool Resource::createContexts() { int i; ResourceContext *context; + char musicFileName[256]; + char soundFileName[256]; + char voicesFileName[256]; + int soundFileIndex = 0; + int voicesFileIndex = 0; + bool digitalMusic = false; + bool soundFileInArray = false; + bool voicesFileInArray = false; + uint16 voiceFileType = GAME_VOICEFILE; _contextsCount = 0; - for (i = 0; _vm->getFilesDescriptions()[i].fileName; i++) + for (i = 0; _vm->getFilesDescriptions()[i].fileName; i++) { _contextsCount++; + if (_vm->getFilesDescriptions()[i].fileType == GAME_SOUNDFILE) + soundFileInArray = true; + if (_vm->getFilesDescriptions()[i].fileType == GAME_VOICEFILE) + voicesFileInArray = true; + } + + if (_vm->getGameType() == GType_ITE) { + if (!soundFileInArray) { + // If the sound file is not specified in the detector table, add it here + if (Common::File::exists("sounds.rsc") || Common::File::exists("sounds.cmp")) { + _contextsCount++; + soundFileIndex = _contextsCount - 1; + if (_vm->getFeatures() & GF_COMPRESSED_SOUNDS) + sprintf(soundFileName, "sounds.cmp"); + else + sprintf(soundFileName, "sounds.rsc"); + } else if (Common::File::exists("soundsd.rsc") || Common::File::exists("soundsd.cmp")) { + _contextsCount++; + soundFileIndex = _contextsCount - 1; + if (_vm->getFeatures() & GF_COMPRESSED_SOUNDS) + sprintf(soundFileName, "soundsd.cmp"); + else + sprintf(soundFileName, "soundsd.rsc"); + } else { + // No sound file found, don't add any file to the array + soundFileInArray = true; + // ITE floppy versions have both voices and sounds in voices.rsc + voiceFileType = GAME_SOUNDFILE | GAME_VOICEFILE; + } + } + + if (!voicesFileInArray) { + // If the voices file is not specified in the detector table, add it here + if (Common::File::exists("voices.rsc") || Common::File::exists("voices.cmp")) { + _contextsCount++; + voicesFileIndex = _contextsCount - 1; + if (_vm->getFeatures() & GF_COMPRESSED_SOUNDS) + sprintf(voicesFileName, "voices.cmp"); + else + sprintf(voicesFileName, "voices.rsc"); + } else if (Common::File::exists("voicesd.rsc") || Common::File::exists("voicesd.cmp")) { + _contextsCount++; + voicesFileIndex = _contextsCount - 1; + if (_vm->getFeatures() & GF_COMPRESSED_SOUNDS) + sprintf(voicesFileName, "voicesd.cmp"); + else + sprintf(voicesFileName, "voicesd.rsc"); + } else if (Common::File::exists("inherit the earth voices") || + Common::File::exists("inherit the earth voices.cmp")) { + _contextsCount++; + voicesFileIndex = _contextsCount - 1; + if (_vm->getFeatures() & GF_COMPRESSED_SOUNDS) + sprintf(voicesFileName, "inherit the earth voices.cmp"); + else + sprintf(voicesFileName, "inherit the earth voices"); + + // The resources in the Wyrmkeep combined Windows/Mac/Linux CD version are little endian, but + // the voice file is big endian. If we got such a version with mixed files, mark this voice file + // as big endian + if (!_vm->isBigEndian()) + voiceFileType = GAME_VOICEFILE | GAME_SWAPENDIAN; // This file is big endian + } else { + // No voice file found, don't add any file to the array + voicesFileInArray = true; + } + } + + // Check for digital music in ITE + if (Common::File::exists("music.rsc") || Common::File::exists("music.cmp")) { + _contextsCount++; + digitalMusic = true; + if (_vm->getFeatures() & GF_COMPRESSED_SOUNDS) + sprintf(musicFileName, "music.cmp"); + else + sprintf(musicFileName, "music.rsc"); + } else if (Common::File::exists("musicd.rsc") || Common::File::exists("musicd.cmp")) { + _contextsCount++; + digitalMusic = true; + if (_vm->getFeatures() & GF_COMPRESSED_SOUNDS) + sprintf(musicFileName, "musicd.cmp"); + else + sprintf(musicFileName, "musicd.rsc"); + } else { + digitalMusic = false; + } + } _contexts = (ResourceContext*)calloc(_contextsCount, sizeof(*_contexts)); for (i = 0; i < _contextsCount; i++) { context = &_contexts[i]; context->file = new Common::File(); - context->fileName = _vm->getFilesDescriptions()[i].fileName; - context->fileType = _vm->getFilesDescriptions()[i].fileType; + + // For ITE, add the digital music file and sfx file information here + if (_vm->getGameType() == GType_ITE && digitalMusic && i == _contextsCount - 1) { + if (_vm->getFeatures() & GF_COMPRESSED_SOUNDS) + context->fileName = musicFileName; + else + context->fileName = musicFileName; + context->fileType = GAME_MUSICFILE; + } else if (_vm->getGameType() == GType_ITE && !soundFileInArray && i == soundFileIndex) { + if (_vm->getFeatures() & GF_COMPRESSED_SOUNDS) + context->fileName = soundFileName; + else + context->fileName = soundFileName; + context->fileType = GAME_SOUNDFILE; + } else if (_vm->getGameType() == GType_ITE && !voicesFileInArray && i == voicesFileIndex) { + if (_vm->getFeatures() & GF_COMPRESSED_SOUNDS) + context->fileName = voicesFileName; + else + context->fileName = voicesFileName; + // can be GAME_VOICEFILE or GAME_SOUNDFILE | GAME_VOICEFILE or GAME_VOICEFILE | GAME_SWAPENDIAN + context->fileType = voiceFileType; + } else { + context->fileName = _vm->getFilesDescriptions()[i].fileName; + context->fileType = _vm->getFilesDescriptions()[i].fileType; + } context->serial = 0; // IHNM has serveral different voice files, so we need to allow diff --git a/engines/saga/saga.cpp b/engines/saga/saga.cpp index 99462c5583..23eb57d1c7 100644 --- a/engines/saga/saga.cpp +++ b/engines/saga/saga.cpp @@ -107,7 +107,6 @@ SagaEngine::SagaEngine(OSystem *syst) // Mac CD Wyrmkeep Common::File::addDefaultDirectory(_gameDataPath + "patch/"); - // Setup mixer if (!_mixer->isReady()) { warning("Sound initialization failed."); @@ -150,6 +149,8 @@ int SagaEngine::init() { _subtitlesEnabled = ConfMan.getBool("subtitles"); _readingSpeed = getTalkspeed(); _copyProtection = ConfMan.getBool("copy_protection"); + _gf_wyrmkeep = false; + _gf_compressed_sounds = false; if (_readingSpeed > 3) _readingSpeed = 0; diff --git a/engines/saga/saga.h b/engines/saga/saga.h index 844a738418..cded648168 100644 --- a/engines/saga/saga.h +++ b/engines/saga/saga.h @@ -527,6 +527,8 @@ public: int _readingSpeed; bool _copyProtection; + bool _gf_wyrmkeep; + bool _gf_compressed_sounds; SndRes *_sndRes; Sound *_sound; -- cgit v1.2.3 From 355ac5db2f380d972925baf1ac2013514a30028b Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 13 Jul 2007 16:45:11 +0000 Subject: Oops, deactivated the actor debug flag again, which was incorrectly activated in commit #28058 svn-id: r28059 --- engines/saga/actor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/saga/actor.h b/engines/saga/actor.h index 213f337d1c..1d9675b4cf 100644 --- a/engines/saga/actor.h +++ b/engines/saga/actor.h @@ -41,7 +41,7 @@ namespace Saga { class HitZone; -#define ACTOR_DEBUG 1 //only for actor pathfinding debug! +//#define ACTOR_DEBUG 1 //only for actor pathfinding debug! #define ACTOR_BARRIERS_MAX 16 -- cgit v1.2.3 From 5a851033744189a53886a8db0992b54d5fd1ef3c Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Fri, 13 Jul 2007 20:50:57 +0000 Subject: Full screen updates aren't automatic after palette changes anymore now. Traded some code pollution with SPEED! svn-id: r28061 --- engines/parallaction/callables.cpp | 9 ++++++++- engines/parallaction/graphics.cpp | 5 +---- engines/parallaction/location.cpp | 6 ++++++ engines/parallaction/menu.cpp | 1 + engines/parallaction/parallaction.h | 1 + 5 files changed, 17 insertions(+), 5 deletions(-) (limited to 'engines') diff --git a/engines/parallaction/callables.cpp b/engines/parallaction/callables.cpp index be92ca1daa..d236766432 100644 --- a/engines/parallaction/callables.cpp +++ b/engines/parallaction/callables.cpp @@ -78,7 +78,8 @@ void _c_fade(void *parm) { _vm->_gfx->fadePalette(pal); _vm->_gfx->setPalette(pal); - _vm->waitTime( 1 ); + g_system->delayMillis(20); + _vm->_gfx->updateScreen(); } return; @@ -292,6 +293,9 @@ void _c_endComment(void *param) { } _vm->_gfx->setPalette(_enginePal); + g_system->delayMillis(20); + _vm->_gfx->updateScreen(); + } waitUntilLeftClick(); @@ -316,11 +320,14 @@ void _c_frankenstein(void *parm) { for (uint16 _di = 0; _di < 30; _di++) { g_system->delayMillis(20); _vm->_gfx->setPalette(pal0, FIRST_BASE_COLOR, BASE_PALETTE_COLORS); + _vm->_gfx->updateScreen(); g_system->delayMillis(20); _vm->_gfx->setPalette(pal1, FIRST_BASE_COLOR, BASE_PALETTE_COLORS); + _vm->_gfx->updateScreen(); } _vm->_gfx->setPalette(_vm->_gfx->_palette); + _vm->_gfx->updateScreen(); return; } diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp index 67f2463038..7474316460 100644 --- a/engines/parallaction/graphics.cpp +++ b/engines/parallaction/graphics.cpp @@ -30,9 +30,6 @@ #include "parallaction/parallaction.h" - -extern OSystem *g_system; - namespace Parallaction { byte * Gfx::_buffers[]; @@ -142,7 +139,7 @@ void Gfx::setPalette(Palette pal, uint32 first, uint32 num) { if (_vm->getPlatform() == Common::kPlatformAmiga) g_system->setPalette(sysExtraPal, first+FIRST_EHB_COLOR, num); - g_system->updateScreen(); +// g_system->updateScreen(); return; } diff --git a/engines/parallaction/location.cpp b/engines/parallaction/location.cpp index 3c54460692..34d2dd6a18 100644 --- a/engines/parallaction/location.cpp +++ b/engines/parallaction/location.cpp @@ -25,6 +25,8 @@ #include "common/stdafx.h" +#include "common/system.h" + #include "parallaction/parallaction.h" #include "parallaction/sound.h" @@ -249,7 +251,9 @@ void Parallaction::switchBackground(const char* background, const char* mask) { _si += 3; } + g_system->delayMillis(20); _gfx->setPalette(pal); + _gfx->updateScreen(); } _disk->loadScenery(background, mask); @@ -371,6 +375,7 @@ void Parallaction::changeLocation(char *location) { _gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront); _gfx->copyScreen(Gfx::kBitBack, Gfx::kBit2); _gfx->setBlackPalette(); + _gfx->updateScreen(); if (_location._commands.size() > 0) { runCommands(_location._commands); @@ -450,6 +455,7 @@ void Parallaction::doLocationEnterTransition() { _gfx->quickFadePalette(pal); _gfx->setPalette(pal); waitTime( 1 ); + _gfx->updateScreen(); } debugC(1, kDebugLocation, "doLocationEnterTransition completed"); diff --git a/engines/parallaction/menu.cpp b/engines/parallaction/menu.cpp index 427f24a467..7c182a56a5 100644 --- a/engines/parallaction/menu.cpp +++ b/engines/parallaction/menu.cpp @@ -435,6 +435,7 @@ void Menu::selectCharacter() { } _vm->_gfx->setBlackPalette(); + _vm->_gfx->updateScreen(); _engineFlags |= kEngineChangeLocation; diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h index 561b15acc9..ad8db9e3f4 100644 --- a/engines/parallaction/parallaction.h +++ b/engines/parallaction/parallaction.h @@ -43,6 +43,7 @@ namespace GUI { class CommandSender; } +extern OSystem *g_system; namespace Parallaction { -- cgit v1.2.3 From 9efa640f9c8f32b5c1a0b6b40621c55ef4b2b730 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 14 Jul 2007 03:44:47 +0000 Subject: Fix graphics glitch in the rat caves in ITE. Closes bug #1735437 - "ITE: Sprite priority in rat caves" svn-id: r28064 --- engines/saga/actor.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/saga/actor.cpp b/engines/saga/actor.cpp index d7882a78fd..2df186f093 100644 --- a/engines/saga/actor.cpp +++ b/engines/saga/actor.cpp @@ -1605,7 +1605,9 @@ void Actor::handleActions(int msec, bool setup) { if (actor->_lastZone) stepZoneAction(actor, actor->_lastZone, true, false); actor->_lastZone = hitZone; - if (hitZone) + // WORKAROUND for graphics glitch in the rat caves. Don't do this step zone action in the rat caves + // (room 51) to avoid the glitch + if (hitZone && !(_vm->getGameType() == GType_ITE && _vm->_scene->currentSceneNumber() == 51)) stepZoneAction(actor, hitZone, false, false); } } -- cgit v1.2.3 From 009b100094363f1e1f167d9792a35af8a3c63793 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 14 Jul 2007 13:41:03 +0000 Subject: Cleanup of the digital music code. Now all kinds of music (uncompressed and compressed) are handled by the same class, DigitalMusicInputStream svn-id: r28069 --- engines/saga/music.cpp | 140 ++++++++++++++++++++++++------------------------- 1 file changed, 69 insertions(+), 71 deletions(-) (limited to 'engines') diff --git a/engines/saga/music.cpp b/engines/saga/music.cpp index 950903f4bb..66f5de79c1 100644 --- a/engines/saga/music.cpp +++ b/engines/saga/music.cpp @@ -38,17 +38,9 @@ namespace Saga { #define BUFFER_SIZE 4096 -// I haven't decided yet if it's a good idea to make looping part of the audio -// stream class, or if I should use a "wrapper" class, like I did for Broken -// Sword 2, to make it easier to add support for compressed music... but I'll -// worry about that later. -// Update by md5: Apparently, it wasn't a good idea. Compressed digital music -// is handled outside of this class, so looping does not work for compressed -// digital music yet -// TODO/FIXME: Add looping support for compressed digital music - -class RAWInputStream : public Audio::AudioStream { +class DigitalMusicInputStream : public Audio::AudioStream { private: + Audio::AudioStream *_stream; ResourceContext *_context; Common::File *_file; uint32 _filePos; @@ -67,7 +59,8 @@ private: } public: - RAWInputStream(SagaEngine *vm, ResourceContext *context, uint32 resourceId, bool looping, uint32 loopStart); + DigitalMusicInputStream(SagaEngine *vm, ResourceContext *context, uint32 resourceId, bool looping, uint32 loopStart); + ~DigitalMusicInputStream(); int readBuffer(int16 *buffer, const int numSamples); @@ -76,17 +69,62 @@ public: int getRate() const { return _musicInfo->frequency; } }; -RAWInputStream::RAWInputStream(SagaEngine *vm, ResourceContext *context, uint32 resourceId, bool looping, uint32 loopStart) +DigitalMusicInputStream::DigitalMusicInputStream(SagaEngine *vm, ResourceContext *context, uint32 resourceId, bool looping, uint32 loopStart) : _context(context), _finished(false), _looping(looping), _bufferEnd(_buf + BUFFER_SIZE) { ResourceData * resourceData; + byte compressedHeader[10]; + GameSoundTypes soundType; resourceData = vm->_resource->getResourceData(context, resourceId); _file = context->getFile(resourceData); _musicInfo = vm->getMusicInfo(); if (_musicInfo == NULL) { - error("RAWInputStream() wrong musicInfo"); + error("DigitalMusicInputStream() wrong musicInfo"); + } + + _stream = NULL; + + if (vm->getFeatures() & GF_COMPRESSED_SOUNDS) { + // Read compressed header to determine compression type + _file->seek((long)resourceData->offset, SEEK_SET); + _file->read(compressedHeader, 9); + + if (compressedHeader[0] == char(0)) { + soundType = kSoundMP3; + } else if (compressedHeader[0] == char(1)) { + soundType = kSoundOGG; + } else if (compressedHeader[0] == char(2)) { + soundType = kSoundFLAC; + } + + switch (soundType) { +#ifdef USE_MAD + case kSoundMP3: + debug(1, "Playing MP3 compressed digital music"); + _stream = Audio::makeMP3Stream(_file, resourceData->size); + break; +#endif +#ifdef USE_VORBIS + case kSoundOGG: + debug(1, "Playing OGG compressed digital music"); + _stream = Audio::makeVorbisStream(_file, resourceData->size); + break; +#endif +#ifdef USE_FLAC + case kSoundFLAC: + debug(1, "Playing FLAC compressed digital music"); + _stream = Audio::makeFlacStream(_file, resourceData->size); + break; +#endif + default: + // Unknown compression + error("Trying to play a compressed digital music, but the compression is not known"); + break; + } + + resourceData->offset += 9; // Skip compressed header } // Determine the end position @@ -100,10 +138,23 @@ RAWInputStream::RAWInputStream(SagaEngine *vm, ResourceContext *context, uint32 refill(); } -int RAWInputStream::readBuffer(int16 *buffer, const int numSamples) { +DigitalMusicInputStream::~DigitalMusicInputStream() { + delete _stream; +} + +int DigitalMusicInputStream::readBuffer(int16 *buffer, const int numSamples) { + // TODO/FIXME: Add looping support for compressed digital music + //if (!_looping && _stream != NULL) + if (_stream != NULL) + return _stream->readBuffer(buffer, numSamples); + int samples = 0; while (samples < numSamples && !eosIntern()) { - const int len = MIN(numSamples - samples, (int) (_bufferEnd - _pos)); + int len = 0; + if (_stream != NULL) + len = _stream->readBuffer(buffer, numSamples); + else + len = MIN(numSamples - samples, (int) (_bufferEnd - _pos)); memcpy(buffer, _pos, len * 2); buffer += len; _pos += len; @@ -115,7 +166,7 @@ int RAWInputStream::readBuffer(int16 *buffer, const int numSamples) { return samples; } -void RAWInputStream::refill() { +void DigitalMusicInputStream::refill() { if (_finished) return; @@ -417,61 +468,8 @@ void Music::play(uint32 resourceId, MusicFlags flags) { loopStart = 4 * 18727; } - if (!(_vm->getFeatures() & GF_COMPRESSED_SOUNDS)) { - // uncompressed digital music - audioStream = new RAWInputStream(_vm, _digitalMusicContext, resourceId - 9, flags == MUSIC_LOOP, loopStart); - } else { - // compressed digital music - ResourceData * musicResourceData; - Common::File *_file; - byte compressedHeader[10]; - GameSoundTypes soundType; - - musicResourceData = _vm->_resource->getResourceData(_digitalMusicContext, resourceId - 9); - _file = _digitalMusicContext->getFile(musicResourceData); - - if (_vm->getMusicInfo() == NULL) { - error("RAWInputStream() wrong musicInfo"); - } - - _file->seek((long)musicResourceData->offset, SEEK_SET); - - _file->read(compressedHeader, 9); - - if (compressedHeader[0] == char(0)) { - soundType = kSoundMP3; - } else if (compressedHeader[0] == char(1)) { - soundType = kSoundOGG; - } else if (compressedHeader[0] == char(2)) { - soundType = kSoundFLAC; - } - - switch (soundType) { -#ifdef USE_MAD - case kSoundMP3: - debug(1, "Playing MP3 compressed digital music"); - audioStream = Audio::makeMP3Stream(_file, musicResourceData->size); - break; -#endif -#ifdef USE_VORBIS - case kSoundOGG: - debug(1, "Playing OGG compressed digital music"); - audioStream = Audio::makeVorbisStream(_file, musicResourceData->size); - break; -#endif -#ifdef USE_FLAC - case kSoundFLAC: - debug(1, "Playing FLAC compressed digital music"); - audioStream = Audio::makeFlacStream(_file, musicResourceData->size); - break; -#endif - default: - // Unknown compression - error("Trying to play a compressed digital music, but the compression is not known"); - break; - } - - } + // digital music + audioStream = new DigitalMusicInputStream(_vm, _digitalMusicContext, resourceId - 9, flags == MUSIC_LOOP, loopStart); } } } -- cgit v1.2.3 From 101dc5cb20afcce72107fdb3314a1b74637eced4 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 14 Jul 2007 14:18:45 +0000 Subject: Improved check for the patched sound file used in ITE intro svn-id: r28070 --- engines/saga/sndres.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/saga/sndres.cpp b/engines/saga/sndres.cpp index c0c63eb06c..7033aaed33 100644 --- a/engines/saga/sndres.cpp +++ b/engines/saga/sndres.cpp @@ -177,9 +177,13 @@ bool SndRes::load(ResourceContext *context, uint32 resourceId, SoundBuffer &buff resourceType = kSoundWAV; } - // If the game has patch files, then it includes a patch file for sound resource 4, used in the intro. - // Don't treat this patch file as compressed sound. This file is always included if patch files are present - if ((_vm->getFeatures() & GF_COMPRESSED_SOUNDS) && !(_vm->getPatchesCount() > 0 && resourceId == 4)) { + bool patchedSound = false; + // If a patch file exists for sound resource 4 (used in ITE intro), don't treat this sound as compressed + if (_vm->getGameType() == GType_ITE && resourceId == 4 && + (Common::File::exists("sound/p2_a.iaf") || Common::File::exists("sound/p2_a.voc"))) + patchedSound = true; + + if ((_vm->getFeatures() & GF_COMPRESSED_SOUNDS) && !patchedSound) { if (soundResource[0] == char(0)) { resourceType = kSoundMP3; } else if (soundResource[0] == char(1)) { -- cgit v1.2.3 From ba3c55cd135ef50e6a025c40a330564a8f5bac9c Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 14 Jul 2007 15:06:06 +0000 Subject: Some more updates for looping of compressed digital music. It's still not working, though svn-id: r28071 --- engines/saga/music.cpp | 83 +++++++++++++++++++++++++++++--------------------- 1 file changed, 48 insertions(+), 35 deletions(-) (limited to 'engines') diff --git a/engines/saga/music.cpp b/engines/saga/music.cpp index 66f5de79c1..a9064d270e 100644 --- a/engines/saga/music.cpp +++ b/engines/saga/music.cpp @@ -42,6 +42,8 @@ class DigitalMusicInputStream : public Audio::AudioStream { private: Audio::AudioStream *_stream; ResourceContext *_context; + ResourceData * resourceData; + GameSoundTypes soundType; Common::File *_file; uint32 _filePos; uint32 _startPos; @@ -62,6 +64,8 @@ public: DigitalMusicInputStream(SagaEngine *vm, ResourceContext *context, uint32 resourceId, bool looping, uint32 loopStart); ~DigitalMusicInputStream(); + void DigitalMusicInputStream::createCompressedStream(); + int readBuffer(int16 *buffer, const int numSamples); bool endOfData() const { return eosIntern(); } @@ -72,9 +76,7 @@ public: DigitalMusicInputStream::DigitalMusicInputStream(SagaEngine *vm, ResourceContext *context, uint32 resourceId, bool looping, uint32 loopStart) : _context(context), _finished(false), _looping(looping), _bufferEnd(_buf + BUFFER_SIZE) { - ResourceData * resourceData; byte compressedHeader[10]; - GameSoundTypes soundType; resourceData = vm->_resource->getResourceData(context, resourceId); _file = context->getFile(resourceData); @@ -99,31 +101,7 @@ DigitalMusicInputStream::DigitalMusicInputStream(SagaEngine *vm, ResourceContext soundType = kSoundFLAC; } - switch (soundType) { -#ifdef USE_MAD - case kSoundMP3: - debug(1, "Playing MP3 compressed digital music"); - _stream = Audio::makeMP3Stream(_file, resourceData->size); - break; -#endif -#ifdef USE_VORBIS - case kSoundOGG: - debug(1, "Playing OGG compressed digital music"); - _stream = Audio::makeVorbisStream(_file, resourceData->size); - break; -#endif -#ifdef USE_FLAC - case kSoundFLAC: - debug(1, "Playing FLAC compressed digital music"); - _stream = Audio::makeFlacStream(_file, resourceData->size); - break; -#endif - default: - // Unknown compression - error("Trying to play a compressed digital music, but the compression is not known"); - break; - } - + createCompressedStream(); resourceData->offset += 9; // Skip compressed header } @@ -142,26 +120,61 @@ DigitalMusicInputStream::~DigitalMusicInputStream() { delete _stream; } +void DigitalMusicInputStream::createCompressedStream() { + switch (soundType) { +#ifdef USE_MAD + case kSoundMP3: + debug(1, "Playing MP3 compressed digital music"); + _stream = Audio::makeMP3Stream(_file, resourceData->size); + break; +#endif +#ifdef USE_VORBIS + case kSoundOGG: + debug(1, "Playing OGG compressed digital music"); + _stream = Audio::makeVorbisStream(_file, resourceData->size); + break; +#endif +#ifdef USE_FLAC + case kSoundFLAC: + debug(1, "Playing FLAC compressed digital music"); + _stream = Audio::makeFlacStream(_file, resourceData->size); + break; +#endif + default: + // Unknown compression + error("Trying to play a compressed digital music, but the compression is not known"); + break; + } +} + int DigitalMusicInputStream::readBuffer(int16 *buffer, const int numSamples) { - // TODO/FIXME: Add looping support for compressed digital music - //if (!_looping && _stream != NULL) - if (_stream != NULL) + // TODO/FIXME: Add looping support for compressed digital music - remove this once it's done + // Currently, an illegal read is made, leading to a crash. Therefore, it's disabled for now + if (_stream != NULL) _looping = false; + + if (!_looping && _stream != NULL) return _stream->readBuffer(buffer, numSamples); int samples = 0; while (samples < numSamples && !eosIntern()) { int len = 0; - if (_stream != NULL) + if (_stream != NULL) { len = _stream->readBuffer(buffer, numSamples); - else + if (len < numSamples) { + delete _stream; + createCompressedStream(); + //_file->seek(_startPos, SEEK_SET); + //_pos = 0; + } + } else { len = MIN(numSamples - samples, (int) (_bufferEnd - _pos)); - memcpy(buffer, _pos, len * 2); + memcpy(buffer, _pos, len * 2); + } buffer += len; _pos += len; samples += len; - if (_pos >= _bufferEnd) { + if (_pos >= _bufferEnd) refill(); - } } return samples; } -- cgit v1.2.3 From c8a8d806e27442cad680ce1d9643d28e6b4af97c Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 14 Jul 2007 15:09:30 +0000 Subject: Renamed a variable, so that it makes more sense svn-id: r28072 --- engines/saga/music.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'engines') diff --git a/engines/saga/music.cpp b/engines/saga/music.cpp index a9064d270e..58a765ca4d 100644 --- a/engines/saga/music.cpp +++ b/engines/saga/music.cpp @@ -40,7 +40,7 @@ namespace Saga { class DigitalMusicInputStream : public Audio::AudioStream { private: - Audio::AudioStream *_stream; + Audio::AudioStream *_compressedStream; ResourceContext *_context; ResourceData * resourceData; GameSoundTypes soundType; @@ -86,7 +86,7 @@ DigitalMusicInputStream::DigitalMusicInputStream(SagaEngine *vm, ResourceContext error("DigitalMusicInputStream() wrong musicInfo"); } - _stream = NULL; + _compressedStream = NULL; if (vm->getFeatures() & GF_COMPRESSED_SOUNDS) { // Read compressed header to determine compression type @@ -117,7 +117,7 @@ DigitalMusicInputStream::DigitalMusicInputStream(SagaEngine *vm, ResourceContext } DigitalMusicInputStream::~DigitalMusicInputStream() { - delete _stream; + delete _compressedStream; } void DigitalMusicInputStream::createCompressedStream() { @@ -125,19 +125,19 @@ void DigitalMusicInputStream::createCompressedStream() { #ifdef USE_MAD case kSoundMP3: debug(1, "Playing MP3 compressed digital music"); - _stream = Audio::makeMP3Stream(_file, resourceData->size); + _compressedStream = Audio::makeMP3Stream(_file, resourceData->size); break; #endif #ifdef USE_VORBIS case kSoundOGG: debug(1, "Playing OGG compressed digital music"); - _stream = Audio::makeVorbisStream(_file, resourceData->size); + _compressedStream = Audio::makeVorbisStream(_file, resourceData->size); break; #endif #ifdef USE_FLAC case kSoundFLAC: debug(1, "Playing FLAC compressed digital music"); - _stream = Audio::makeFlacStream(_file, resourceData->size); + _compressedStream = Audio::makeFlacStream(_file, resourceData->size); break; #endif default: @@ -150,18 +150,18 @@ void DigitalMusicInputStream::createCompressedStream() { int DigitalMusicInputStream::readBuffer(int16 *buffer, const int numSamples) { // TODO/FIXME: Add looping support for compressed digital music - remove this once it's done // Currently, an illegal read is made, leading to a crash. Therefore, it's disabled for now - if (_stream != NULL) _looping = false; + if (_compressedStream != NULL) _looping = false; - if (!_looping && _stream != NULL) - return _stream->readBuffer(buffer, numSamples); + if (!_looping && _compressedStream != NULL) + return _compressedStream->readBuffer(buffer, numSamples); int samples = 0; while (samples < numSamples && !eosIntern()) { int len = 0; - if (_stream != NULL) { - len = _stream->readBuffer(buffer, numSamples); + if (_compressedStream != NULL) { + len = _compressedStream->readBuffer(buffer, numSamples); if (len < numSamples) { - delete _stream; + delete _compressedStream; createCompressedStream(); //_file->seek(_startPos, SEEK_SET); //_pos = 0; -- cgit v1.2.3 From a7adb5888c5a88e8b88a707f7740bcf211c011a6 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 14 Jul 2007 17:39:47 +0000 Subject: ITE: Fixed some of the incorrectly drawn dots of the menu buttons svn-id: r28076 --- engines/saga/interface.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/saga/interface.cpp b/engines/saga/interface.cpp index 55b2b0a996..12d027d124 100644 --- a/engines/saga/interface.cpp +++ b/engines/saga/interface.cpp @@ -2016,10 +2016,10 @@ void Interface::drawButtonBox(Surface *ds, const Rect& rect, ButtonKind kind, bo ((byte *)ds->getBasePtr(x, ye))[0] = cornerColor; ((byte *)ds->getBasePtr(xe, y))[0] = cornerColor; ((byte *)ds->getBasePtr(xe, ye))[0] = cornerColor; - ds->hLine(x + 1, y, x + 1 + w - 2, frameColor); - ds->hLine(x + 1, ye, x + 1 + w - 2, frameColor); - ds->vLine(x, y + 1, y + 1 + h - 2, frameColor); - ds->vLine(xe, y + 1, y + 1 + h - 2, frameColor); + ds->hLine(x + 1, y, x + w - 2, frameColor); + ds->hLine(x + 1, ye, x + w - 2, frameColor); + ds->vLine(x, y + 1, y + h - 2, frameColor); + ds->vLine(xe, y + 1, y + h - 2, frameColor); x++; y++; -- cgit v1.2.3 From 5aba81d3e756e340f5acee051f1f036d0d50fcf6 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 14 Jul 2007 18:11:14 +0000 Subject: ITE: Fixed some more incorrect dots on dialog buttons svn-id: r28077 --- engines/saga/interface.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/saga/interface.cpp b/engines/saga/interface.cpp index 12d027d124..5d93807da1 100644 --- a/engines/saga/interface.cpp +++ b/engines/saga/interface.cpp @@ -2029,7 +2029,7 @@ void Interface::drawButtonBox(Surface *ds, const Rect& rect, ButtonKind kind, bo h -= 2; ds->vLine(x, y, y + h - 1, odl); ds->hLine(x, ye, x + w - 1, odl); - ds->vLine(xe, y, y + h - 1, our); + ds->vLine(xe, y, y + h - 2, our); ds->hLine(x + 1, y, x + 1 + w - 2, our); x++; @@ -2042,7 +2042,7 @@ void Interface::drawButtonBox(Surface *ds, const Rect& rect, ButtonKind kind, bo ((byte *)ds->getBasePtr(xe, ye))[0] = fillColor; ds->vLine(x, y + 1, y + 1 + h - 2, idl); ds->hLine(x + 1, ye, x + 1 + w - 2, idl); - ds->vLine(xe, y, y + h - 1, iur); + ds->vLine(xe, y, y + h - 2, iur); ds->hLine(x + 1, y, x + 1 + w - 2, iur); x++; y++; -- cgit v1.2.3 From af21e132a25655239071b3da53841253b6db59c9 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Sat, 14 Jul 2007 18:26:43 +0000 Subject: Fixed compilation. svn-id: r28078 --- engines/saga/music.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/saga/music.cpp b/engines/saga/music.cpp index 58a765ca4d..c8b8b1ea6b 100644 --- a/engines/saga/music.cpp +++ b/engines/saga/music.cpp @@ -64,7 +64,7 @@ public: DigitalMusicInputStream(SagaEngine *vm, ResourceContext *context, uint32 resourceId, bool looping, uint32 loopStart); ~DigitalMusicInputStream(); - void DigitalMusicInputStream::createCompressedStream(); + void createCompressedStream(); int readBuffer(int16 *buffer, const int numSamples); -- cgit v1.2.3 From 198b6ac8e64044823922420afaeb948508f41775 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 15 Jul 2007 03:13:15 +0000 Subject: ITE: Music looping works now with compressed digital music. However, there's still a small pause when a track restarts svn-id: r28082 --- engines/saga/music.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'engines') diff --git a/engines/saga/music.cpp b/engines/saga/music.cpp index c8b8b1ea6b..01e3e3f805 100644 --- a/engines/saga/music.cpp +++ b/engines/saga/music.cpp @@ -148,10 +148,6 @@ void DigitalMusicInputStream::createCompressedStream() { } int DigitalMusicInputStream::readBuffer(int16 *buffer, const int numSamples) { - // TODO/FIXME: Add looping support for compressed digital music - remove this once it's done - // Currently, an illegal read is made, leading to a crash. Therefore, it's disabled for now - if (_compressedStream != NULL) _looping = false; - if (!_looping && _compressedStream != NULL) return _compressedStream->readBuffer(buffer, numSamples); @@ -161,20 +157,27 @@ int DigitalMusicInputStream::readBuffer(int16 *buffer, const int numSamples) { if (_compressedStream != NULL) { len = _compressedStream->readBuffer(buffer, numSamples); if (len < numSamples) { + // FIXME: When a looping compressed track finishes and before it restarts, there's a slight pause. + // This might be caused by the time it takes to reset the compressed stream + + // Skip to the beginning of the track in the data file + _filePos = _startPos; + _file->seek(_filePos, SEEK_SET); + // Reset the compressed stream delete _compressedStream; createCompressedStream(); - //_file->seek(_startPos, SEEK_SET); - //_pos = 0; + len = _compressedStream->readBuffer(buffer, numSamples); } + samples += len; } else { len = MIN(numSamples - samples, (int) (_bufferEnd - _pos)); memcpy(buffer, _pos, len * 2); + buffer += len; + _pos += len; + samples += len; + if (_pos >= _bufferEnd) + refill(); } - buffer += len; - _pos += len; - samples += len; - if (_pos >= _bufferEnd) - refill(); } return samples; } -- cgit v1.2.3 From 6376321e5a486fb6fba867e0e80205282826b806 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 15 Jul 2007 06:24:39 +0000 Subject: Enabled menus in some old AGI games (released in 1986) which did not have menus them originally: KQ1 Amiga and ST and early versions of KQ3 Amiga, SQ1 ST, SQ1 DOS and SQ1 Amiga. The GF_FORCEMENUS flag has been remaned to GF_MENUS. Also, two problematic versions of KQ3, a problematic version of SQ1 and a problematic version of Mixed up Mother Goose have been disabled. Finally, a duplicate detection entry for SQ1 has been removed svn-id: r28095 --- engines/agi/agi.h | 2 +- engines/agi/detection.cpp | 67 ++++++++++++++++++++++++++--------------------- engines/agi/keyboard.cpp | 2 +- engines/agi/menu.cpp | 2 +- 4 files changed, 40 insertions(+), 33 deletions(-) (limited to 'engines') diff --git a/engines/agi/agi.h b/engines/agi/agi.h index c732121e11..6c89edf1dd 100644 --- a/engines/agi/agi.h +++ b/engines/agi/agi.h @@ -112,7 +112,7 @@ enum AgiGameFeatures { GF_AGIPAL = (1 << 4), GF_MACGOLDRUSH = (1 << 5), GF_FANMADE = (1 << 6), - GF_FORCEMENUS = (1 << 7) + GF_MENUS = (1 << 7) }; enum AgiGameID { diff --git a/engines/agi/detection.cpp b/engines/agi/detection.cpp index 3f53777f2d..381444f5ff 100644 --- a/engines/agi/detection.cpp +++ b/engines/agi/detection.cpp @@ -245,6 +245,7 @@ static const AGIGameDescription gameDescriptions[] = { { // Black Cauldron (Apple IIgs) 1.0O 2/24/89 (CE) + // Menus not tested { "bc", "1.0O 1989-02-24 (CE)", @@ -298,6 +299,7 @@ static const AGIGameDescription gameDescriptions[] = { #if 0 { // Donald Duck's Playground (Amiga) 1.0C + // Menus not tested { "ddp", "1.0C 1987-04-27", @@ -315,6 +317,7 @@ static const AGIGameDescription gameDescriptions[] = { { // Donald Duck's Playground (ST) 1.0A 8/8/86 + // Menus not tested { "ddp", "1.0A 1986-08-08", @@ -332,6 +335,7 @@ static const AGIGameDescription gameDescriptions[] = { { // reported by Filippos (thebluegr) in bugreport #1654500 + // Menus not tested { "ddp", "1.0C 1986-06-09", // verify date @@ -366,6 +370,7 @@ static const AGIGameDescription gameDescriptions[] = { { // Gold Rush! (Apple IIgs) 1.0M 2/28/89 (CE) aka 2.01 12/22/88 + // Menus not tested { "goldrush", "1.0M 1989-02-28 (CE) aka 2.01 1988-12-22", @@ -455,6 +460,7 @@ static const AGIGameDescription gameDescriptions[] = { { // King's Quest 1 (Amiga) 1.0U # 2.082 + // The original game did not have menus, they are enabled under ScummVM { "kq1", "1.0U 1986", @@ -465,13 +471,14 @@ static const AGIGameDescription gameDescriptions[] = { }, GID_KQ1, GType_V2, - 0, + GF_MENUS, 0x2440, }, { // King's Quest 1 (ST) 1.0V + // The original game did not have menus, they are enabled under ScummVM { "kq1", "1.0V 1986", @@ -482,13 +489,14 @@ static const AGIGameDescription gameDescriptions[] = { }, GID_KQ1, GType_V2, - 0, + GF_MENUS, 0x2272, }, { // King's Quest 1 (IIgs) 1.0S-88223 + // Menus not tested { "kq1", "1.0S 1988-02-23", @@ -625,6 +633,7 @@ static const AGIGameDescription gameDescriptions[] = { { // King's Quest 3 (Amiga) 1.01 11/8/86 + // The original game did not have menus, they are enabled under ScummVM { "kq3", "1.01 1986-11-08", @@ -635,13 +644,14 @@ static const AGIGameDescription gameDescriptions[] = { }, GID_KQ3, GType_V2, - GF_FORCEMENUS, + GF_MENUS, 0x2440, }, - +#if 0 { // King's Quest 3 (ST) 1.02 11/18/86 + // Problematic: does not have menus, crashes if menus are enforced { "kq3", "1.02 1986-11-18", @@ -655,7 +665,7 @@ static const AGIGameDescription gameDescriptions[] = { 0, 0x2272, }, - +#endif { // King's Quest 3 (Mac) 2.14 3/15/88 @@ -707,9 +717,10 @@ static const AGIGameDescription gameDescriptions[] = { 0x3086, }, - +#if 0 { // King's Quest 3 (PC) 1.01 11/08/86 [AGI 2.272] + // Problematic: does not have menus, crashes if menus are enforced { "kq3", "1.01 1986-11-08", @@ -723,7 +734,7 @@ static const AGIGameDescription gameDescriptions[] = { 0, 0x2272, }, - +#endif { // King's Quest 3 (PC 5.25") 2.00 5/25/87 [AGI 2.435] @@ -744,6 +755,7 @@ static const AGIGameDescription gameDescriptions[] = { { // King's Quest 3 (Mac) 2.14 3/15/88 + // Menus not tested { "kq3", "2.14 1988-03-15 5.25\"", @@ -795,6 +807,7 @@ static const AGIGameDescription gameDescriptions[] = { { // King's Quest 4 (IIgs) 1.0K 11/22/88 (CE) + // Menus not tested { "kq4", "1.0K 1988-11-22", @@ -829,6 +842,7 @@ static const AGIGameDescription gameDescriptions[] = { { // King's Quest 4 (PC 3.5") 2.2 9/27/88 [AGI 3.002.086] + // Menus not tested { "kq4", "2.2 1988-09-27 3.5\"", @@ -846,6 +860,7 @@ static const AGIGameDescription gameDescriptions[] = { { // King's Quest 4 demo (PC) [AGI 3.002.102] + // Menus not tested { "kq4", "Demo 1988-12-20", @@ -1099,9 +1114,11 @@ static const AGIGameDescription gameDescriptions[] = { 0x3149, }, - +#if 0 { // Mixed-Up Mother Goose (Amiga) 1.1 + // Problematic: crashes + // Menus not tested { "mixedup", "1.1 1986-12-10", @@ -1115,7 +1132,7 @@ static const AGIGameDescription gameDescriptions[] = { 0, 0x3086, }, - +#endif { // Mixed Up Mother Goose (IIgs) @@ -1154,6 +1171,7 @@ static const AGIGameDescription gameDescriptions[] = { #if 0 { // Mixed Up Mother Goose (PC) [AGI 2.915] (Broken) + // Menus not tested { "mixedup", "[corrupt/OBJECT from disk 1]", @@ -1308,6 +1326,7 @@ static const AGIGameDescription gameDescriptions[] = { { // Space Quest 1 (ST) 1.1A + // The original game did not have menus, they are enabled under ScummVM { "sq1", "1.1A 1986-02-06", @@ -1318,13 +1337,14 @@ static const AGIGameDescription gameDescriptions[] = { }, GID_SQ1, GType_V2, - 0, + GF_MENUS, 0x2440, }, { // Space Quest 1 (PC) 1.1A [AGI 2.272] + // The original game did not have menus, they are enabled under ScummVM { "sq1", "1.1A 1986-11-13", @@ -1335,13 +1355,14 @@ static const AGIGameDescription gameDescriptions[] = { }, GID_SQ1, GType_V2, - GF_FORCEMENUS, + GF_MENUS, 0x2272, }, { // Space Quest 1 (Amiga) 1.2 # 2.082 + // The original game did not have menus, they are enabled under ScummVM { "sq1", "1.2 1986", @@ -1352,7 +1373,7 @@ static const AGIGameDescription gameDescriptions[] = { }, GID_SQ1, GType_V2, - GF_FORCEMENUS, + GF_MENUS, 0x2440, }, @@ -1390,9 +1411,10 @@ static const AGIGameDescription gameDescriptions[] = { 0x2917, }, - +#if 0 { // Space Quest 1 (PC) 1.0X [AGI 2.089] + // Problematic: does not have menus, crashes if menus are enforced { "sq1", "1.0X 1986-09-24", @@ -1406,23 +1428,7 @@ static const AGIGameDescription gameDescriptions[] = { 0, 0x2089, }, - - - { - // Space Quest 1 (PC) 1.1A [AGI 2.272] - { - "sq1", - "1.1A 1986-11-13", - AD_ENTRY1("logdir", "8d8c20ab9f4b6e4817698637174a1cb6"), - Common::EN_ANY, - Common::kPlatformPC, - Common::ADGF_NO_FLAGS - }, - GID_SQ1, - GType_V2, - 0, - 0x2272, - }, +#endif { @@ -1552,6 +1558,7 @@ static const AGIGameDescription gameDescriptions[] = { { // Space Quest 2 (PC 5.25"/ST) 2.0C/A [AGI 2.915] + // Menus not tested { "sq2", "2.0C/A 5.25\"/ST", diff --git a/engines/agi/keyboard.cpp b/engines/agi/keyboard.cpp index 9fd3700675..d41100d5d8 100644 --- a/engines/agi/keyboard.cpp +++ b/engines/agi/keyboard.cpp @@ -127,7 +127,7 @@ int AgiEngine::handleController(int key) { } if (key == BUTTON_LEFT) { - if ((getflag(fMenusWork) || (getFeatures() & GF_FORCEMENUS)) && g_mouse.y <= CHAR_LINES) { + if ((getflag(fMenusWork) || (getFeatures() & GF_MENUS)) && g_mouse.y <= CHAR_LINES) { newInputMode(INPUT_MENU); return true; } diff --git a/engines/agi/menu.cpp b/engines/agi/menu.cpp index 4cba788273..7aa7f5e55d 100644 --- a/engines/agi/menu.cpp +++ b/engines/agi/menu.cpp @@ -267,7 +267,7 @@ bool Menu::keyhandler(int key) { static int menuActive = false; static int buttonUsed = 0; - if (!_vm->getflag(fMenusWork) && !(_vm->getFeatures() & GF_FORCEMENUS)) + if (!_vm->getflag(fMenusWork) && !(_vm->getFeatures() & GF_MENUS)) return false; if (!menuActive) { -- cgit v1.2.3 From 9b4cfc5bbe70176a4b944af8e6c4897fc3e013e0 Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Sun, 15 Jul 2007 10:10:48 +0000 Subject: Screen update is no more triggered automatically when performing full screen-size blits on Front buffer. Menu code has been changed accordingly to retain consistency. svn-id: r28097 --- engines/parallaction/graphics.cpp | 2 +- engines/parallaction/menu.cpp | 44 ++++++++++++++++----------------------- engines/parallaction/zone.cpp | 2 ++ 3 files changed, 21 insertions(+), 27 deletions(-) (limited to 'engines') diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp index 7474316460..cdbf41eb2c 100644 --- a/engines/parallaction/graphics.cpp +++ b/engines/parallaction/graphics.cpp @@ -285,7 +285,7 @@ void Gfx::clearScreen(Gfx::Buffers buffer) { void Gfx::copyScreen(Gfx::Buffers srcbuffer, Gfx::Buffers dstbuffer) { memcpy(_buffers[dstbuffer], _buffers[srcbuffer], SCREEN_WIDTH*SCREEN_HEIGHT); - if (dstbuffer == kBitFront) updateScreen(); +// if (dstbuffer == kBitFront) updateScreen(); return; } diff --git a/engines/parallaction/menu.cpp b/engines/parallaction/menu.cpp index 7c182a56a5..d0a84c979c 100644 --- a/engines/parallaction/menu.cpp +++ b/engines/parallaction/menu.cpp @@ -130,11 +130,13 @@ void Menu::splash() { _vm->_disk->loadSlide("intro"); _vm->_gfx->setPalette(_vm->_gfx->_palette); _vm->_gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront); + _vm->_gfx->updateScreen(); g_system->delayMillis(2000); _vm->_disk->loadSlide("minintro"); _vm->_gfx->setPalette(_vm->_gfx->_palette); _vm->_gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront); + _vm->_gfx->updateScreen(); g_system->delayMillis(2000); } @@ -203,14 +205,10 @@ uint16 Menu::chooseLanguage() { _vm->_gfx->displayString(60, 30, "SELECT LANGUAGE", 1); - _vm->_gfx->copyScreen(Gfx::kBitFront, Gfx::kBitBack); - _vm->_gfx->copyScreen(Gfx::kBitBack, Gfx::kBit2); - _vm->changeCursor(kCursorArrow); do { _vm->updateInput(); - _vm->_gfx->swapBuffers(); if (_mouseButtons == kMouseLeftUp) { for (uint16 _si = 0; _si < 4; _si++) { @@ -242,7 +240,8 @@ uint16 Menu::chooseLanguage() { } } - _vm->waitTime( 1 ); + g_system->delayMillis(30); + _vm->_gfx->updateScreen(); } while (true); @@ -261,41 +260,33 @@ uint16 Menu::selectGame() { _vm->_disk->loadSlide("restore"); _vm->_gfx->setPalette(_vm->_gfx->_palette); - _vm->_gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront); - - _vm->_gfx->copyScreen(Gfx::kBitBack, Gfx::kBit2); - uint16 _si = 0; uint16 _di = 3; - _vm->updateInput(); + _mouseButtons = kMouseNone; while (_mouseButtons != kMouseLeftUp) { _vm->updateInput(); - _vm->_gfx->swapBuffers(); - _vm->waitTime( 1 ); - _si = 0; - if (_vm->_mousePos.x > 160) - _si = 1; + _si = (_vm->_mousePos.x > 160) ? 1 : 0; - if (_si == _di) continue; + if (_si != _di) { + _di = _si; - _di = _si; - _vm->_gfx->copyScreen(Gfx::kBit2, Gfx::kBitFront); + _vm->_gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront); + if (_si != 0) { + // load a game + _vm->_gfx->displayString(60, 30, loadGameMsg[_language], 1); + } else { + // new game + _vm->_gfx->displayString(60, 30, newGameMsg[_language], 1); + } - if (_si != 0) { - // load a game - _vm->_gfx->displayString(60, 30, loadGameMsg[_language], 1); - } else { - // new game - _vm->_gfx->displayString(60, 30, newGameMsg[_language], 1); } + g_system->delayMillis(30); _vm->_gfx->updateScreen(); - _vm->_gfx->copyScreen(Gfx::kBitFront, Gfx::kBitBack); - } if (_si == 0) return 0; // new game @@ -421,6 +412,7 @@ void Menu::selectCharacter() { g_system->delayMillis(2000); _vm->_gfx->copyScreen(Gfx::kBit2, Gfx::kBitFront); + _vm->_gfx->updateScreen(); } diff --git a/engines/parallaction/zone.cpp b/engines/parallaction/zone.cpp index d9bd36a1f5..99ef8c60f9 100644 --- a/engines/parallaction/zone.cpp +++ b/engines/parallaction/zone.cpp @@ -310,6 +310,7 @@ void Parallaction::displayCharacterComment(ExamineData *data) { waitUntilLeftClick(); _gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront); + _gfx->updateScreen(); return; } @@ -353,6 +354,7 @@ void Parallaction::displayItemComment(ExamineData *data) { _gfx->setHalfbriteMode(false); _gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront); + _gfx->updateScreen(); return; } -- cgit v1.2.3 From 5fc39e7a305d570b9a4bb9b2548f37f063330a16 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 15 Jul 2007 15:12:24 +0000 Subject: ITE: looping of compressed digital music is now done by the respective compressed streams themselves svn-id: r28104 --- engines/saga/music.cpp | 44 ++++++++++++++++---------------------------- 1 file changed, 16 insertions(+), 28 deletions(-) (limited to 'engines') diff --git a/engines/saga/music.cpp b/engines/saga/music.cpp index 01e3e3f805..5f6e558401 100644 --- a/engines/saga/music.cpp +++ b/engines/saga/music.cpp @@ -54,6 +54,7 @@ private: const int16 *_bufferEnd; const int16 *_pos; const GameSoundInfo *_musicInfo; + Common::MemoryReadStream *_memoryStream; void refill(); bool eosIntern() const { @@ -121,23 +122,27 @@ DigitalMusicInputStream::~DigitalMusicInputStream() { } void DigitalMusicInputStream::createCompressedStream() { + // we specify 32000 loops when looping is specified, which is quite close to looping forever + uint numLoops = _looping ? 32000 : 1; + _memoryStream = _file->readStream(resourceData->size); + switch (soundType) { #ifdef USE_MAD case kSoundMP3: debug(1, "Playing MP3 compressed digital music"); - _compressedStream = Audio::makeMP3Stream(_file, resourceData->size); + _compressedStream = Audio::makeMP3Stream(_memoryStream, true, 0, 0, numLoops); break; #endif #ifdef USE_VORBIS case kSoundOGG: debug(1, "Playing OGG compressed digital music"); - _compressedStream = Audio::makeVorbisStream(_file, resourceData->size); + _compressedStream = Audio::makeVorbisStream(_memoryStream, true, 0, 0, numLoops); break; #endif #ifdef USE_FLAC case kSoundFLAC: debug(1, "Playing FLAC compressed digital music"); - _compressedStream = Audio::makeFlacStream(_file, resourceData->size); + _compressedStream = Audio::makeFlacStream(_memoryStream, true, 0, 0, numLoops); break; #endif default: @@ -148,36 +153,19 @@ void DigitalMusicInputStream::createCompressedStream() { } int DigitalMusicInputStream::readBuffer(int16 *buffer, const int numSamples) { - if (!_looping && _compressedStream != NULL) + if (_compressedStream != NULL) return _compressedStream->readBuffer(buffer, numSamples); int samples = 0; while (samples < numSamples && !eosIntern()) { int len = 0; - if (_compressedStream != NULL) { - len = _compressedStream->readBuffer(buffer, numSamples); - if (len < numSamples) { - // FIXME: When a looping compressed track finishes and before it restarts, there's a slight pause. - // This might be caused by the time it takes to reset the compressed stream - - // Skip to the beginning of the track in the data file - _filePos = _startPos; - _file->seek(_filePos, SEEK_SET); - // Reset the compressed stream - delete _compressedStream; - createCompressedStream(); - len = _compressedStream->readBuffer(buffer, numSamples); - } - samples += len; - } else { - len = MIN(numSamples - samples, (int) (_bufferEnd - _pos)); - memcpy(buffer, _pos, len * 2); - buffer += len; - _pos += len; - samples += len; - if (_pos >= _bufferEnd) - refill(); - } + len = MIN(numSamples - samples, (int) (_bufferEnd - _pos)); + memcpy(buffer, _pos, len * 2); + buffer += len; + _pos += len; + samples += len; + if (_pos >= _bufferEnd) + refill(); } return samples; } -- cgit v1.2.3 From 4594202aaf5b25608e84d1e79fcd78cf476301cc Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 15 Jul 2007 15:27:42 +0000 Subject: To loop a music track forever, the number of loops is set to 0 svn-id: r28105 --- engines/saga/music.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/saga/music.cpp b/engines/saga/music.cpp index 5f6e558401..a02f48db1b 100644 --- a/engines/saga/music.cpp +++ b/engines/saga/music.cpp @@ -122,8 +122,7 @@ DigitalMusicInputStream::~DigitalMusicInputStream() { } void DigitalMusicInputStream::createCompressedStream() { - // we specify 32000 loops when looping is specified, which is quite close to looping forever - uint numLoops = _looping ? 32000 : 1; + uint numLoops = _looping ? 0 : 1; _memoryStream = _file->readStream(resourceData->size); switch (soundType) { -- cgit v1.2.3 From 2f7f5271ac0cc4781cea5b4ea235dc6458700cc2 Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Sun, 15 Jul 2007 16:04:34 +0000 Subject: Refactored selectCharacter so that menu code doesn't need auxiliary buffer kBit2 anymore. svn-id: r28106 --- engines/parallaction/menu.cpp | 112 ++++++++++++++++++++++-------------------- engines/parallaction/menu.h | 1 + 2 files changed, 59 insertions(+), 54 deletions(-) (limited to 'engines') diff --git a/engines/parallaction/menu.cpp b/engines/parallaction/menu.cpp index d0a84c979c..12b03ab4b0 100644 --- a/engines/parallaction/menu.cpp +++ b/engines/parallaction/menu.cpp @@ -87,14 +87,15 @@ const char *loadGameMsg[] = { #define SLOT_Y 64 #define SLOT_WIDTH (BLOCK_WIDTH+2) +#define PASSWORD_LEN 6 -static uint16 _amigaDinoKey[] = { 5, 3, 6, 2, 2, 7 }; -static uint16 _amigaDonnaKey[] = { 0, 3, 6, 2, 2, 6 }; -static uint16 _amigaDoughKey[] = { 1, 3 ,7, 2, 4, 6 }; +static uint16 _amigaDinoKey[PASSWORD_LEN] = { 5, 3, 6, 2, 2, 7 }; +static uint16 _amigaDonnaKey[PASSWORD_LEN] = { 0, 3, 6, 2, 2, 6 }; +static uint16 _amigaDoughKey[PASSWORD_LEN] = { 1, 3 ,7, 2, 4, 6 }; -static uint16 _pcDinoKey[] = { 5, 3, 6, 1, 4, 7 }; -static uint16 _pcDonnaKey[] = { 0, 2, 8, 5, 5, 1 }; -static uint16 _pcDoughKey[] = { 1, 7 ,7, 2, 2, 6 }; +static uint16 _pcDinoKey[PASSWORD_LEN] = { 5, 3, 6, 1, 4, 7 }; +static uint16 _pcDonnaKey[PASSWORD_LEN] = { 0, 2, 8, 5, 5, 1 }; +static uint16 _pcDoughKey[PASSWORD_LEN] = { 1, 7 ,7, 2, 2, 6 }; Menu::Menu(Parallaction *vm) { @@ -163,15 +164,16 @@ void Menu::newGame() { _vm->_gfx->displayCenteredString(100, v14[2]); _vm->_gfx->displayCenteredString(120, v14[3]); + _vm->showCursor(false); + _vm->_gfx->updateScreen(); - _vm->_gfx->copyScreen(Gfx::kBitFront, Gfx::kBitBack); _mouseButtons = kMouseNone; - - for (; _mouseButtons != kMouseLeftUp; ) { + do { _vm->updateInput(); - if (_mouseButtons == kMouseRightUp) break; - } + } while (_mouseButtons != kMouseLeftUp && _mouseButtons != kMouseRightUp); + + _vm->showCursor(true); if (_mouseButtons != kMouseRightUp) { strcpy(_vm->_location._name, "fogne"); @@ -307,6 +309,30 @@ uint16 Menu::selectGame() { } +int Menu::getSelectedBlock(const Common::Point &p, Common::Rect &r) { + + for (uint16 _si = 0; _si < 9; _si++) { + + Common::Rect q( + _si * BLOCK_X_OFFSET + BLOCK_SELECTION_X, + BLOCK_SELECTION_Y - _si * BLOCK_Y_OFFSET, + (_si + 1) * BLOCK_X_OFFSET + BLOCK_SELECTION_X, + BLOCK_SELECTION_Y + BLOCK_HEIGHT - _si * BLOCK_Y_OFFSET + ); + + if (q.contains(p)) { + r.setWidth(BLOCK_WIDTH); + r.setHeight(BLOCK_HEIGHT); + r.moveTo(_si * BLOCK_X_OFFSET + BLOCK_X, BLOCK_Y - _si * BLOCK_Y_OFFSET); + return _si; + } + + } + + return -1; +} + + // // character selection and protection // @@ -314,11 +340,8 @@ void Menu::selectCharacter() { debugC(1, kDebugMenu, "Menu::selectCharacter()"); uint16 _di = 0; - bool askPassword = true; - uint16 _donna_points = 0; - uint16 _dino_points = 0; - uint16 _dough_points = 0; + uint16 _donna_points, _dino_points, _dough_points; StaticCnv v14; @@ -334,51 +357,34 @@ void Menu::selectCharacter() { _vm->_disk->selectArchive((_vm->getFeatures() & GF_LANG_MULT) ? "disk1" : "disk0"); _vm->_disk->loadSlide("password"); // loads background into kBitBack buffer - _vm->_gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront); // - _vm->_gfx->copyScreen(Gfx::kBitBack, Gfx::kBit2); // + _vm->_gfx->setPalette(_vm->_gfx->_palette); - while (askPassword == true) { + while (true) { - askPassword = false; _di = 0; _vm->_gfx->displayString(60, 30, introMsg1[_language], 1); // displays message - _vm->_gfx->copyScreen(Gfx::kBitFront, Gfx::kBitBack); _donna_points = 0; _dino_points = 0; _dough_points = 0; - while (_di < 6) { + while (_di < PASSWORD_LEN) { _mouseButtons = kMouseNone; do { _vm->updateInput(); - _vm->_gfx->swapBuffers(); - _vm->waitTime(1); + g_system->delayMillis(30); + _vm->_gfx->updateScreen(); } while (_mouseButtons != kMouseLeftUp); // waits for left click - for (uint16 _si = 0; _si < 9; _si++) { - - Common::Rect r( - _si * BLOCK_X_OFFSET + BLOCK_SELECTION_X, - BLOCK_SELECTION_Y - _si * BLOCK_Y_OFFSET, - (_si + 1) * BLOCK_X_OFFSET + BLOCK_SELECTION_X, - BLOCK_SELECTION_Y + BLOCK_HEIGHT - _si * BLOCK_Y_OFFSET - ); - - if (!r.contains(_vm->_mousePos)) continue; - - r.setWidth(BLOCK_WIDTH); - r.setHeight(BLOCK_HEIGHT); - r.moveTo(_si * BLOCK_X_OFFSET + BLOCK_X, BLOCK_Y - _si * BLOCK_Y_OFFSET); + Common::Rect r; + int _si = getSelectedBlock(_vm->_mousePos, r); + if (_si != -1) { _vm->_gfx->grabRect(v14._data0, r, Gfx::kBitFront, BLOCK_WIDTH); - - _vm->_gfx->flatBlitCnv(&v14, _di * SLOT_WIDTH + SLOT_X, SLOT_Y, Gfx::kBitBack); _vm->_gfx->flatBlitCnv(&v14, _di * SLOT_WIDTH + SLOT_X, SLOT_Y, Gfx::kBitFront); - // beep(); if (_vm->getPlatform() == Common::kPlatformAmiga && (_vm->getFeatures() & GF_LANG_MULT)) { @@ -399,31 +405,29 @@ void Menu::selectCharacter() { _di++; } - - askPassword = (_dino_points < 6 && _donna_points < 6 && _dough_points < 6); } - if (askPassword == false) break; + if (_dino_points == PASSWORD_LEN || _donna_points == PASSWORD_LEN || _dough_points == PASSWORD_LEN) { + break; + } - _vm->_gfx->copyScreen(Gfx::kBit2, Gfx::kBitFront); + _vm->_gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront); _vm->_gfx->displayString(60, 30, introMsg2[_language], 1); _vm->_gfx->updateScreen(); g_system->delayMillis(2000); - _vm->_gfx->copyScreen(Gfx::kBit2, Gfx::kBitFront); - _vm->_gfx->updateScreen(); + _vm->_gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront); } - - if (_dino_points > _donna_points && _dino_points > _dough_points) { + if (_dino_points == PASSWORD_LEN) { sprintf(_vm->_location._name, "test.%s", _dinoName); - } else { - if (_donna_points > _dino_points && _donna_points > _dough_points) { - sprintf(_vm->_location._name, "test.%s", _donnaName); - } else { - sprintf(_vm->_location._name, "test.%s", _doughName); - } + } else + if (_donna_points == PASSWORD_LEN) { + sprintf(_vm->_location._name, "test.%s", _donnaName); + } else + if (_dough_points == PASSWORD_LEN) { + sprintf(_vm->_location._name, "test.%s", _doughName); } _vm->_gfx->setBlackPalette(); diff --git a/engines/parallaction/menu.h b/engines/parallaction/menu.h index a0b8b95371..bb9eabdfb7 100644 --- a/engines/parallaction/menu.h +++ b/engines/parallaction/menu.h @@ -48,6 +48,7 @@ protected: void newGame(); uint16 chooseLanguage(); uint16 selectGame(); + int getSelectedBlock(const Common::Point &p, Common::Rect& r); public: -- cgit v1.2.3 From e07e5eeb1dbe83f23de230481568ac5d977b1f0a Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sun, 15 Jul 2007 18:26:21 +0000 Subject: Added new Mac SCUMM MD5, tracker #1749232 svn-id: r28108 --- engines/scumm/scumm-md5.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/scumm/scumm-md5.h b/engines/scumm/scumm-md5.h index cd48ef4d02..288ae55ea7 100644 --- a/engines/scumm/scumm-md5.h +++ b/engines/scumm/scumm-md5.h @@ -1,5 +1,5 @@ /* - This file was generated by the md5table tool on Mon Jul 2 22:44:41 2007 + This file was generated by the md5table tool on Sun Jul 15 18:25:43 2007 DO NOT EDIT MANUALLY! */ @@ -320,6 +320,7 @@ static const MD5Table md5table[] = { { "86be8ada36371d4fdc35659d0e912a26", "indy3", "EGA", "EGA", -1, Common::ES_ESP, Common::kPlatformPC }, { "86c9902b7bec1a17926d4dae85beaa45", "airport", "HE 71", "Demo", -1, Common::EN_ANY, Common::kPlatformWindows }, { "870d1e3c86bc50846d808d14a36b4e08", "monkey", "VGA", "VGA", -1, Common::ES_ESP, Common::kPlatformAmiga }, + { "8776caed014c321272af407c1502a2df", "monkey", "CD", "", 8955, Common::EN_ANY, Common::kPlatformMacintosh }, { "87f6e8037b7cc996e13474b491a7a98e", "maniac", "V2", "V2", -1, Common::IT_ITA, Common::kPlatformPC }, { "8801fb4a1200b347f7a38523339526dd", "jungle", "", "", -1, Common::EN_ANY, Common::kPlatformWindows }, { "883af4b0af4f77a92f1dcf1d0a283140", "tentacle", "", "CD", -1, Common::ES_ESP, Common::kPlatformUnknown }, -- cgit v1.2.3 From 11b2806741da02dde2e2e4c1d5fa8ebb26d64233 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sun, 15 Jul 2007 18:29:05 +0000 Subject: Removed the old (obsolete) audiostream factories for MP3/Vorbis/FLAC data which took a File pointer and a size (these were only implemented as brain-dead wrapper around the newer factory methods anyway) svn-id: r28110 --- engines/kyra/sound.cpp | 4 +++- engines/kyra/sound.h | 7 ++++++- engines/touche/resource.cpp | 11 +++++++++-- 3 files changed, 18 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/kyra/sound.cpp b/engines/kyra/sound.cpp index 8deed22091..1d2ff2e512 100644 --- a/engines/kyra/sound.cpp +++ b/engines/kyra/sound.cpp @@ -61,7 +61,9 @@ void Sound::voicePlay(const char *file) { if (!_compressHandle.isOpen()) continue; - _currentVocFile = _supportedCodes[i].streamFunc(&_compressHandle, fileSize); + Common::MemoryReadStream *tmp = _compressHandle.readStream(fileSize); + assert(tmp); + _currentVocFile = _supportedCodes[i].streamFunc(tmp, true, 0, 0, 1); found = true; break; } diff --git a/engines/kyra/sound.h b/engines/kyra/sound.h index 28a9521112..b6c06b493b 100644 --- a/engines/kyra/sound.h +++ b/engines/kyra/sound.h @@ -109,7 +109,12 @@ private: struct SpeechCodecs { const char *fileext; - Audio::AudioStream *(*streamFunc)(Common::File*, uint32); + Audio::AudioStream *(*streamFunc)( + Common::SeekableReadStream *stream, + bool disposeAfterUse, + uint32 startTime, + uint32 duration, + uint numLoops); }; static const SpeechCodecs _supportedCodes[]; diff --git a/engines/touche/resource.cpp b/engines/touche/resource.cpp index 585e70c534..f9f2938502 100644 --- a/engines/touche/resource.cpp +++ b/engines/touche/resource.cpp @@ -44,7 +44,12 @@ enum { struct CompressedSpeechFile { const char *filename; - Audio::AudioStream *(*makeStream)(Common::File *file, uint32 size); + Audio::AudioStream *(*makeStream)( + Common::SeekableReadStream *stream, + bool disposeAfterUse, + uint32 startTime, + uint32 duration, + uint numLoops); }; static const CompressedSpeechFile compressedSpeechFilesTable[] = { @@ -656,7 +661,9 @@ void ToucheEngine::res_loadSpeechSegment(int num) { return; } _fSpeech[0].seek(offs); - stream = (compressedSpeechFilesTable[_compressedSpeechData].makeStream)(&_fSpeech[0], size); + Common::MemoryReadStream *tmp = _fSpeech[0].readStream(size); + assert(tmp); + stream = (compressedSpeechFilesTable[_compressedSpeechData].makeStream)(tmp, true, 0, 0, 1); } if (stream) { _speechPlaying = true; -- cgit v1.2.3 From f4c0b853cc8453acac0c9e6f6901c0056a2288fa Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sun, 15 Jul 2007 19:24:00 +0000 Subject: Fixed sound factory messup caused by my previous commit svn-id: r28111 --- engines/agos/sound.cpp | 12 +++++++++--- engines/queen/sound.cpp | 12 +++++++++--- engines/saga/sound.cpp | 13 ++++++++++--- engines/scumm/imuse_digi/dimuse_sndmgr.cpp | 6 ++++-- engines/scumm/smush/smush_player.cpp | 4 ++-- engines/scumm/sound.cpp | 13 ++++++++++--- engines/sword1/sound.cpp | 12 +++++++++--- engines/sword2/music.cpp | 14 +++++++++++--- 8 files changed, 64 insertions(+), 22 deletions(-) (limited to 'engines') diff --git a/engines/agos/sound.cpp b/engines/agos/sound.cpp index 7165e3cbff..a735f54c29 100644 --- a/engines/agos/sound.cpp +++ b/engines/agos/sound.cpp @@ -292,7 +292,9 @@ Audio::AudioStream *MP3Sound::makeAudioStream(uint sound) { uint32 size = _offsets[sound + i] - _offsets[sound]; - return Audio::makeMP3Stream(_file, size); + Common::MemoryReadStream *tmp = _file->readStream(size); + assert(tmp); + return Audio::makeMP3Stream(tmp, true); } void MP3Sound::playSound(uint sound, uint loopSound, Audio::Mixer::SoundType type, Audio::SoundHandle *handle, byte flags, int vol) { @@ -321,7 +323,9 @@ Audio::AudioStream *VorbisSound::makeAudioStream(uint sound) { uint32 size = _offsets[sound + i] - _offsets[sound]; - return Audio::makeVorbisStream(_file, size); + Common::MemoryReadStream *tmp = _file->readStream(size); + assert(tmp); + return Audio::makeVorbisStream(tmp, true); } void VorbisSound::playSound(uint sound, uint loopSound, Audio::Mixer::SoundType type, Audio::SoundHandle *handle, byte flags, int vol) { @@ -350,7 +354,9 @@ Audio::AudioStream *FlacSound::makeAudioStream(uint sound) { uint32 size = _offsets[sound + i] - _offsets[sound]; - return Audio::makeFlacStream(_file, size); + Common::MemoryReadStream *tmp = _file->readStream(size); + assert(tmp); + return Audio::makeFlacStream(tmp, true); } void FlacSound::playSound(uint sound, uint loopSound, Audio::Mixer::SoundType type, Audio::SoundHandle *handle, byte flags, int vol) { diff --git a/engines/queen/sound.cpp b/engines/queen/sound.cpp index 6184060132..a4cac2417e 100644 --- a/engines/queen/sound.cpp +++ b/engines/queen/sound.cpp @@ -67,7 +67,9 @@ public: MP3Sound(Audio::Mixer *mixer, QueenEngine *vm) : PCSound(mixer, vm) {} protected: void playSoundData(Common::File *f, uint32 size, Audio::SoundHandle *soundHandle) { - _mixer->playInputStream(Audio::Mixer::kSFXSoundType, soundHandle, Audio::makeMP3Stream(f, size)); + Common::MemoryReadStream *tmp = f->readStream(size); + assert(tmp); + _mixer->playInputStream(Audio::Mixer::kSFXSoundType, soundHandle, Audio::makeMP3Stream(tmp, true)); } }; #endif @@ -78,7 +80,9 @@ public: OGGSound(Audio::Mixer *mixer, QueenEngine *vm) : PCSound(mixer, vm) {} protected: void playSoundData(Common::File *f, uint32 size, Audio::SoundHandle *soundHandle) { - _mixer->playInputStream(Audio::Mixer::kSFXSoundType, soundHandle, Audio::makeVorbisStream(f, size)); + Common::MemoryReadStream *tmp = f->readStream(size); + assert(tmp); + _mixer->playInputStream(Audio::Mixer::kSFXSoundType, soundHandle, Audio::makeVorbisStream(tmp, true)); } }; #endif @@ -89,7 +93,9 @@ public: FLACSound(Audio::Mixer *mixer, QueenEngine *vm) : PCSound(mixer, vm) {} protected: void playSoundData(Common::File *f, uint32 size, Audio::SoundHandle *soundHandle) { - _mixer->playInputStream(Audio::Mixer::kSFXSoundType, soundHandle, Audio::makeFlacStream(f, size)); + Common::MemoryReadStream *tmp = f->readStream(size); + assert(tmp); + _mixer->playInputStream(Audio::Mixer::kSFXSoundType, soundHandle, Audio::makeFlacStream(tmp, true)); } }; #endif // #ifdef USE_FLAC diff --git a/engines/saga/sound.cpp b/engines/saga/sound.cpp index 95b8c24a2f..621b3ed310 100644 --- a/engines/saga/sound.cpp +++ b/engines/saga/sound.cpp @@ -84,27 +84,34 @@ void Sound::playSoundBuffer(Audio::SoundHandle *handle, SoundBuffer &buffer, int _mixer->playRaw(Audio::Mixer::kSFXSoundType, handle, buffer.buffer, buffer.size, buffer.frequency, flags, -1, volume); } else { Audio::AudioStream *stream = NULL; + Common::MemoryReadStream *tmp = NULL; switch (buffer.soundType) { #ifdef USE_MAD case kSoundMP3: debug(1, "Playing MP3 compressed sound"); buffer.soundFile->seek((long)buffer.fileOffset, SEEK_SET); - stream = Audio::makeMP3Stream(buffer.soundFile, buffer.size); + tmp = buffer.soundFile->readStream(buffer.size); + assert(tmp); + stream = Audio::makeMP3Stream(tmp, true); break; #endif #ifdef USE_VORBIS case kSoundOGG: debug(1, "Playing OGG compressed sound"); buffer.soundFile->seek((long)buffer.fileOffset, SEEK_SET); - stream = Audio::makeVorbisStream(buffer.soundFile, buffer.size); + tmp = buffer.soundFile->readStream(buffer.size); + assert(tmp); + stream = Audio::makeVorbisStream(tmp, true); break; #endif #ifdef USE_FLAC case kSoundFLAC: debug(1, "Playing FLAC compressed sound"); buffer.soundFile->seek((long)buffer.fileOffset, SEEK_SET); - stream = Audio::makeFlacStream(buffer.soundFile, buffer.size); + tmp = buffer.soundFile->readStream(buffer.size); + assert(tmp); + stream = Audio::makeFlacStream(tmp, true); break; #endif default: diff --git a/engines/scumm/imuse_digi/dimuse_sndmgr.cpp b/engines/scumm/imuse_digi/dimuse_sndmgr.cpp index ce963eaeea..8340af3eb5 100644 --- a/engines/scumm/imuse_digi/dimuse_sndmgr.cpp +++ b/engines/scumm/imuse_digi/dimuse_sndmgr.cpp @@ -615,13 +615,15 @@ int32 ImuseDigiSndMgr::getDataFromRegion(soundStruct *soundHandle, int region, b oggMode = true; } if (!soundHandle->compressedStream) { + Common::MemoryReadStream *tmp = cmpFile->readStream(len); + assert(tmp); #ifdef USE_VORBIS if (oggMode) - soundHandle->compressedStream = Audio::makeVorbisStream(cmpFile, len); + soundHandle->compressedStream = Audio::makeVorbisStream(tmp, true); #endif #ifdef USE_MAD if (!oggMode) - soundHandle->compressedStream = Audio::makeMP3Stream(cmpFile, len); + soundHandle->compressedStream = Audio::makeMP3Stream(tmp, true); #endif assert(soundHandle->compressedStream); } diff --git a/engines/scumm/smush/smush_player.cpp b/engines/scumm/smush/smush_player.cpp index 2c744a16e2..e7663c61c1 100644 --- a/engines/scumm/smush/smush_player.cpp +++ b/engines/scumm/smush/smush_player.cpp @@ -1183,7 +1183,7 @@ void SmushPlayer::tryCmpFile(const char *filename) { strcpy(fname + (i - filename), ".ogg"); if (file->open(fname)) { _compressedFileMode = true; - _vm->_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_compressedFileSoundHandle, Audio::makeVorbisStream(file, true, 0, 0)); + _vm->_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_compressedFileSoundHandle, Audio::makeVorbisStream(file, true)); return; } #endif @@ -1192,7 +1192,7 @@ void SmushPlayer::tryCmpFile(const char *filename) { strcpy(fname + (i - filename), ".mp3"); if (file->open(fname)) { _compressedFileMode = true; - _vm->_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_compressedFileSoundHandle, Audio::makeMP3Stream(file, true, 0, 0)); + _vm->_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_compressedFileSoundHandle, Audio::makeMP3Stream(file, true)); return; } #endif diff --git a/engines/scumm/sound.cpp b/engines/scumm/sound.cpp index e5720a013f..c42d9adf45 100644 --- a/engines/scumm/sound.cpp +++ b/engines/scumm/sound.cpp @@ -607,24 +607,31 @@ void Sound::startTalkSound(uint32 offset, uint32 b, int mode, Audio::SoundHandle if (!_soundsPaused && _mixer->isReady()) { Audio::AudioStream *input = NULL; + Common::MemoryReadStream *tmp = NULL; switch (_soundMode) { case kMP3Mode: #ifdef USE_MAD assert(size > 0); - input = Audio::makeMP3Stream(_sfxFile, size); + tmp = _sfxFile->readStream(size); + assert(tmp); + input = Audio::makeMP3Stream(tmp, true); #endif break; case kVorbisMode: #ifdef USE_VORBIS assert(size > 0); - input = Audio::makeVorbisStream(_sfxFile, size); + tmp = _sfxFile->readStream(size); + assert(tmp); + input = Audio::makeVorbisStream(tmp, true); #endif break; case kFlacMode: #ifdef USE_FLAC assert(size > 0); - input = Audio::makeFlacStream(_sfxFile, size); + tmp = _sfxFile->readStream(size); + assert(tmp); + input = Audio::makeFlacStream(tmp, true); #endif break; default: diff --git a/engines/sword1/sound.cpp b/engines/sword1/sound.cpp index 492672fad8..2594aaf8f4 100644 --- a/engines/sword1/sound.cpp +++ b/engines/sword1/sound.cpp @@ -201,7 +201,9 @@ bool Sound::startSpeech(uint16 roomNo, uint16 localNo) { #ifdef USE_FLAC else if (_cowMode == CowFlac) { _cowFile.seek(index); - _mixer->playInputStream(Audio::Mixer::kSpeechSoundType, &_speechHandle, Audio::makeFlacStream(&_cowFile, sampleSize), SOUND_SPEECH_ID, speechVol, speechPan); + Common::MemoryReadStream *tmp = _cowFile.readStream(sampleSize); + assert(tmp); + _mixer->playInputStream(Audio::Mixer::kSpeechSoundType, &_speechHandle, Audio::makeFlacStream(tmp, true), SOUND_SPEECH_ID, speechVol, speechPan); // with compressed audio, we can't calculate the wave volume. // so default to talking. for (int cnt = 0; cnt < 480; cnt++) @@ -212,7 +214,9 @@ bool Sound::startSpeech(uint16 roomNo, uint16 localNo) { #ifdef USE_VORBIS else if (_cowMode == CowVorbis) { _cowFile.seek(index); - _mixer->playInputStream(Audio::Mixer::kSpeechSoundType, &_speechHandle, Audio::makeVorbisStream(&_cowFile, sampleSize), SOUND_SPEECH_ID, speechVol, speechPan); + Common::MemoryReadStream *tmp = _cowFile.readStream(sampleSize); + assert(tmp); + _mixer->playInputStream(Audio::Mixer::kSpeechSoundType, &_speechHandle, Audio::makeVorbisStream(tmp, true), SOUND_SPEECH_ID, speechVol, speechPan); // with compressed audio, we can't calculate the wave volume. // so default to talking. for (int cnt = 0; cnt < 480; cnt++) @@ -223,7 +227,9 @@ bool Sound::startSpeech(uint16 roomNo, uint16 localNo) { #ifdef USE_MAD else if (_cowMode == CowMp3) { _cowFile.seek(index); - _mixer->playInputStream(Audio::Mixer::kSpeechSoundType, &_speechHandle, Audio::makeMP3Stream(&_cowFile, sampleSize), SOUND_SPEECH_ID, speechVol, speechPan); + Common::MemoryReadStream *tmp = _cowFile.readStream(sampleSize); + assert(tmp); + _mixer->playInputStream(Audio::Mixer::kSpeechSoundType, &_speechHandle, Audio::makeMP3Stream(tmp, true), SOUND_SPEECH_ID, speechVol, speechPan); // with compressed audio, we can't calculate the wave volume. // so default to talking. for (int cnt = 0; cnt < 480; cnt++) diff --git a/engines/sword2/music.cpp b/engines/sword2/music.cpp index 28427e5d1b..b442b6194f 100644 --- a/engines/sword2/music.cpp +++ b/engines/sword2/music.cpp @@ -139,21 +139,29 @@ static Audio::AudioStream *getAudioStream(SoundFileHandle *fh, const char *base, } fh->file.seek(pos, SEEK_SET); + + Common::MemoryReadStream *tmp = 0; switch (fh->fileType) { case kCLUMode: return makeCLUStream(&fh->file, enc_len); #ifdef USE_MAD case kMP3Mode: - return Audio::makeMP3Stream(&fh->file, enc_len); + tmp = fh->file.readStream(enc_len); + assert(tmp); + return Audio::makeMP3Stream(tmp, true); #endif #ifdef USE_VORBIS case kVorbisMode: - return Audio::makeVorbisStream(&fh->file, enc_len); + tmp = fh->file.readStream(enc_len); + assert(tmp); + return Audio::makeVorbisStream(tmp, true); #endif #ifdef USE_FLAC case kFlacMode: - return Audio::makeFlacStream(&fh->file, enc_len); + tmp = fh->file.readStream(enc_len); + assert(tmp); + return Audio::makeFlacStream(tmp, true); #endif default: return NULL; -- cgit v1.2.3 From 86d015c0551f98aec3924d85c2507462ae0ba73a Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sun, 15 Jul 2007 19:26:00 +0000 Subject: Added FIXME comments regarding use of AudioStream::openStreamFile svn-id: r28112 --- engines/scumm/smush/smush_player.cpp | 3 +++ engines/sword1/music.cpp | 4 ++++ 2 files changed, 7 insertions(+) (limited to 'engines') diff --git a/engines/scumm/smush/smush_player.cpp b/engines/scumm/smush/smush_player.cpp index e7663c61c1..ce39302e25 100644 --- a/engines/scumm/smush/smush_player.cpp +++ b/engines/scumm/smush/smush_player.cpp @@ -1178,6 +1178,9 @@ void SmushPlayer::tryCmpFile(const char *filename) { char fname[260]; #endif Common::File *file = new Common::File(); + + // FIXME: How about using AudioStream::openStreamFile instead of the code below? + #ifdef USE_VORBIS memcpy(fname, filename, i - filename); strcpy(fname + (i - filename), ".ogg"); diff --git a/engines/sword1/music.cpp b/engines/sword1/music.cpp index ebff7f9929..e6acd8f3cd 100644 --- a/engines/sword1/music.cpp +++ b/engines/sword1/music.cpp @@ -203,6 +203,10 @@ bool MusicHandle::play(const char *fileBase, bool loop) { char fileName[30]; stop(); + // FIXME: How about using AudioStream::openStreamFile instead of the code below? + // I.e.: + //_audioSource = Audio::AudioStream::openStreamFile(fileBase, 0, 0, loop ? 0 : 1); + #ifdef USE_FLAC if (!_audioSource) { sprintf(fileName, "%s.flac", fileBase); -- cgit v1.2.3 From 16529e58e6ac81f38f9dfa686adcf5e46423800c Mon Sep 17 00:00:00 2001 From: Kari Salminen Date: Sun, 15 Jul 2007 21:33:28 +0000 Subject: Added 3 different Amiga AGI palettes (From oldest to newest). Changed initPalette so its easier to enable the usage of those palettes later. svn-id: r28114 --- engines/agi/graphics.cpp | 132 +++++++++++++++++++++++++++++++++++++---------- engines/agi/graphics.h | 4 +- 2 files changed, 106 insertions(+), 30 deletions(-) (limited to 'engines') diff --git a/engines/agi/graphics.cpp b/engines/agi/graphics.cpp index af57209357..3e39fc07ea 100644 --- a/engines/agi/graphics.cpp +++ b/engines/agi/graphics.cpp @@ -67,6 +67,93 @@ uint8 egaPalette[16 * 3] = { 0x3f, 0x3f, 0x3f }; +/** + * First generation Amiga AGI palette. + * A 16-color, 12-bit RGB palette. + * + * Used by at least the following Amiga AGI versions: + * 2.082 (King's Quest I v1.0U 1986) + * 2.082 (Space Quest I v1.2 1986) + * 2.090 (King's Quest III v1.01 1986-11-08) + * 2.107 (King's Quest II v2.0J 1987-01-29) + * x.yyy (Black Cauldron v2.00 1987-06-14) + * x.yyy (Larry I v1.05 1987-06-26) + */ +uint8 amigaAgiPaletteV1[16 * 3] = { + 0x0, 0x0, 0x0, + 0x0, 0x0, 0xF, + 0x0, 0x8, 0x0, + 0x0, 0xD, 0xB, + 0xC, 0x0, 0x0, + 0xB, 0x7, 0xD, + 0x8, 0x5, 0x0, + 0xB, 0xB, 0xB, + 0x7, 0x7, 0x7, + 0x0, 0xB, 0xF, + 0x0, 0xE, 0x0, + 0x0, 0xF, 0xD, + 0xF, 0x9, 0x8, + 0xF, 0x7, 0x0, + 0xE, 0xE, 0x0, + 0xF, 0xF, 0xF +}; + +/** + * Second generation Amiga AGI palette. + * A 16-color, 12-bit RGB palette. + * + * Used by at least the following Amiga AGI versions: + * 2.202 (Space Quest II v2.0F. Intro says 1988. ScummVM 0.10.0 detects as 1986-12-09) + */ +uint8 amigaAgiPaletteV2[16 * 3] = { + 0x0, 0x0, 0x0, + 0x0, 0x0, 0xF, + 0x0, 0x8, 0x0, + 0x0, 0xD, 0xB, + 0xC, 0x0, 0x0, + 0xB, 0x7, 0xD, + 0x8, 0x5, 0x0, + 0xB, 0xB, 0xB, + 0x7, 0x7, 0x7, + 0x0, 0xB, 0xF, + 0x0, 0xE, 0x0, + 0x0, 0xF, 0xD, + 0xF, 0x9, 0x8, + 0xD, 0x0, 0xF, + 0xE, 0xE, 0x0, + 0xF, 0xF, 0xF +}; + +/** + * Third generation Amiga AGI palette. + * A 16-color, 12-bit RGB palette. + * + * Used by at least the following Amiga AGI versions: + * 2.310 (Police Quest I v2.0B 1989-02-22) + * 2.316 (Gold Rush! v2.05 1989-03-09) + * x.yyy (Manhunter I v1.06 1989-03-18) + * 2.333 (Manhunter II v3.06 1989-08-17) + * 2.333 (King's Quest III v2.15 1989-11-15) + */ +uint8 amigaAgiPaletteV3[16 * 3] = { + 0x0, 0x0, 0x0, + 0x0, 0x0, 0xB, + 0x0, 0xB, 0x0, + 0x0, 0xB, 0xB, + 0xB, 0x0, 0x0, + 0xB, 0x0, 0xB, + 0xC, 0x7, 0x0, + 0xB, 0xB, 0xB, + 0x7, 0x7, 0x7, + 0x0, 0x0, 0xF, + 0x0, 0xF, 0x0, + 0x0, 0xF, 0xF, + 0xF, 0x0, 0x0, + 0xF, 0x0, 0xF, + 0xF, 0xF, 0x0, + 0xF, 0xF, 0xF +}; + /** * 16 color amiga-ish palette. */ @@ -656,39 +743,26 @@ int GfxMgr::keypress() { /** * Initialize the color palette - * This function initializes the color palette using the specified 16-color + * This function initializes the color palette using the specified * RGB palette. - * @param p A pointer to the 16-color RGB palette. + * @param p A pointer to the source RGB palette. + * @param colorCount Count of colors in the source palette. + * @param fromBits Bits per source color component. + * @param toBits Bits per destination color component. */ -void GfxMgr::initPalette(uint8 *p) { - int i; - - for (i = 0; i < 48; i++) { - _palette[i] = p[i]; +void GfxMgr::initPalette(uint8 *p, uint colorCount, uint fromBits, uint toBits) { + const uint srcMax = (1 << fromBits) - 1; + const uint destMax = (1 << toBits) - 1; + for (uint col = 0; col < colorCount; col++) { + for (uint comp = 0; comp < 3; comp++) { // Convert RGB components + _palette[col * 4 + comp] = (p[col * 3 + comp] * destMax) / srcMax; + } + _palette[col * 4 + 3] = 0; // Set alpha to zero } } void GfxMgr::gfxSetPalette() { - int i; - byte pal[256 * 4]; - - if (!(_vm->getFeatures() & (GF_AGI256 | GF_AGI256_2))) { - for (i = 0; i < 16; i++) { - pal[i * 4 + 0] = _palette[i * 3 + 0] << 2; - pal[i * 4 + 1] = _palette[i * 3 + 1] << 2; - pal[i * 4 + 2] = _palette[i * 3 + 2] << 2; - pal[i * 4 + 3] = 0; - } - g_system->setPalette(pal, 0, 16); - } else { - for (i = 0; i < 256; i++) { - pal[i * 4 + 0] = vgaPalette[i * 3 + 0]; - pal[i * 4 + 1] = vgaPalette[i * 3 + 1]; - pal[i * 4 + 2] = vgaPalette[i * 3 + 2]; - pal[i * 4 + 3] = 0; - } - g_system->setPalette(pal, 0, 256); - } + g_system->setPalette(_palette, 0, 256); } //Gets AGIPAL Data @@ -852,7 +926,9 @@ void GfxMgr::setCursor(bool amigaStyleCursor) { * @see deinit_video() */ int GfxMgr::initVideo() { - if (_vm->_renderMode == Common::kRenderEGA) + if (_vm->getFeatures() & (GF_AGI256 | GF_AGI256_2)) + initPalette(vgaPalette, 256, 8); + else if (_vm->_renderMode == Common::kRenderEGA) initPalette(egaPalette); else initPalette(newPalette); diff --git a/engines/agi/graphics.h b/engines/agi/graphics.h index d76a2e1397..e06af90f5d 100644 --- a/engines/agi/graphics.h +++ b/engines/agi/graphics.h @@ -41,7 +41,7 @@ class GfxMgr { private: AgiEngine *_vm; - uint8 _palette[16 * 3]; + uint8 _palette[256 * 4]; uint8 *_agiScreen; unsigned char *_screen; @@ -83,7 +83,7 @@ public: void drawRectangle(int, int, int, int, int); void saveBlock(int, int, int, int, uint8 *); void restoreBlock(int, int, int, int, uint8 *); - void initPalette(uint8 *); + void initPalette(uint8 *p, uint colorCount = 16, uint fromBits = 6, uint toBits = 8); void setAGIPal(int); int getAGIPalFileNum(); void drawFrame(int x1, int y1, int x2, int y2, int c1, int c2); -- cgit v1.2.3 From e4950ea52f98d40bb4ff40484dd4bfd754edae65 Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Mon, 16 Jul 2007 01:49:34 +0000 Subject: Add Japanese 3DO version of fbpack. svn-id: r28119 --- engines/scumm/scumm-md5.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/scumm/scumm-md5.h b/engines/scumm/scumm-md5.h index 288ae55ea7..5633e74dbe 100644 --- a/engines/scumm/scumm-md5.h +++ b/engines/scumm/scumm-md5.h @@ -1,5 +1,5 @@ /* - This file was generated by the md5table tool on Sun Jul 15 18:25:43 2007 + This file was generated by the md5table tool on Mon Jul 16 01:45:48 2007 DO NOT EDIT MANUALLY! */ @@ -445,6 +445,7 @@ static const MD5Table md5table[] = { { "c8575e0b973ff1723aba6cd92c642db2", "puttrace", "HE 99", "Demo", -1, Common::FR_FRA, Common::kPlatformWindows }, { "c8aac5e3e701874e2fa4117896f9e1b1", "freddi", "HE 73", "Demo", -1, Common::EN_ANY, Common::kPlatformMacintosh }, { "c8c5baadcbfc8d0372ed4335abace8a7", "pajama3", "", "Demo", -1, Common::FR_FRA, Common::kPlatformWindows }, + { "c9717ee6059f1e43b768b464493d2fba", "fbpack", "", "", -1, Common::JA_JPN, Common::kPlatform3DO }, { "cb1559e8405d17a5a278a6b5ad9338d1", "freddi3", "", "Demo", 22718, Common::EN_ANY, Common::kPlatformUnknown }, { "cc04a076779379524ed4d9c5ee3c6fb1", "tentacle", "", "CD", 282467632, Common::EN_ANY, Common::kPlatformMacintosh }, { "cc8ba2b0df2f9c450bcf055fe2711979", "samnmax", "", "Demo", 7485, Common::DE_DEU, Common::kPlatformPC }, -- cgit v1.2.3 From af0229d5332aa68ae4fac3c5747289b15ba36cdb Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Mon, 16 Jul 2007 14:10:36 +0000 Subject: Add Bear Stormin' svn-id: r28121 --- engines/scumm/detection_tables.h | 4 ++++ engines/scumm/scumm-md5.h | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/scumm/detection_tables.h b/engines/scumm/detection_tables.h index 0c72951fb2..7e0365ef42 100644 --- a/engines/scumm/detection_tables.h +++ b/engines/scumm/detection_tables.h @@ -79,6 +79,7 @@ static const PlainGameDescriptor gameDescriptions[] = { { "comi", "The Curse of Monkey Island" }, #endif + { "brstorm", "Bear Stormin'" }, { "fbear", "Fatty Bear's Birthday Surprise" }, { "fbpack", "Fatty Bear's Fun Pack" }, { "funpack", "Putt-Putt's Fun Pack" }, @@ -248,6 +249,7 @@ static const GameSettings gameVariantsTable[] = { {"funpack", 0, 0, GID_FUNPACK, 6, 61, MDT_ADLIB | MDT_MIDI, GF_USE_KEY, UNK}, {"fbpack", 0, 0, GID_HEGAME, 6, 61, MDT_ADLIB | MDT_MIDI, GF_USE_KEY, UNK}, + {"brstorm", 0, 0, GID_FBEAR, 6, 61, MDT_ADLIB | MDT_MIDI, GF_USE_KEY, UNK}, {"fbear", "HE 61", 0, GID_FBEAR, 6, 61, MDT_ADLIB | MDT_MIDI, GF_USE_KEY, UNK}, {"fbear", "HE 70", 0, GID_FBEAR, 6, 70, MDT_NONE, GF_USE_KEY, Common::kPlatformWindows}, @@ -461,6 +463,8 @@ static const GameFilenamePattern gameFilenamesTable[] = { { "fbpack", "fbpack", kGenHEPC, UNK_LANG, UNK, 0 }, { "funpack", "funpack", kGenHEPC, UNK_LANG, UNK, 0 }, + { "brstorm", "brstorm", kGenHEPC, UNK_LANG, UNK, 0 }, + { "fbear", "fbear", kGenHEPC, UNK_LANG, UNK, 0 }, { "fbear", "fbdemo", kGenHEPC, UNK_LANG, UNK, 0 }, { "fbear", "Fatty Bear Demo", kGenHEMacNoParens, UNK_LANG, Common::kPlatformMacintosh, 0 }, diff --git a/engines/scumm/scumm-md5.h b/engines/scumm/scumm-md5.h index 5633e74dbe..8694f21e65 100644 --- a/engines/scumm/scumm-md5.h +++ b/engines/scumm/scumm-md5.h @@ -1,5 +1,5 @@ /* - This file was generated by the md5table tool on Mon Jul 16 01:45:48 2007 + This file was generated by the md5table tool on Mon Jul 16 12:41:17 2007 DO NOT EDIT MANUALLY! */ @@ -29,6 +29,7 @@ static const MD5Table md5table[] = { { "06b187468113f9ae5a400b148a847fac", "atlantis", "", "Floppy", 12075, Common::EN_ANY, Common::kPlatformMacintosh }, { "06c3cf4f31daad8b1cd93153491db9e6", "pajama3", "", "", -1, Common::NL_NLD, Common::kPlatformMacintosh }, { "07433205acdca3bc553d0e731588b35f", "airport", "", "", -1, Common::EN_ANY, Common::kPlatformWindows }, + { "07a1eefd8ca95d77310311446c0f53d0", "brstorm", "", "Demo", 5433, Common::EN_ANY, Common::kPlatformUnknown }, { "07b810e37be7489263f7bc7627d4765d", "freddi4", "unenc", "Unencrypted", -1, Common::RU_RUS, Common::kPlatformWindows }, { "084ed0fa98a6d1e9368d67fe9cfbd417", "freddi", "HE 71", "Demo", -1, Common::EN_ANY, Common::kPlatformWindows }, { "0855496dde35356b1a9691e22ba84cdc", "freddi", "HE 73", "Demo", -1, Common::EN_ANY, Common::kPlatformWindows }, -- cgit v1.2.3 From 91426f82c6f4e3edc8217e8c5122847f583095fa Mon Sep 17 00:00:00 2001 From: Neil Millstone Date: Mon, 16 Jul 2007 22:55:44 +0000 Subject: Porting DS word completion keyboard changes from branch0-10-0. svn-id: r28125 --- engines/agi/agi.cpp | 6 ++++++ engines/agi/predictive.cpp | 13 +++++++++++++ 2 files changed, 19 insertions(+) (limited to 'engines') diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp index a5aa7854ca..1c1c53dee7 100644 --- a/engines/agi/agi.cpp +++ b/engines/agi/agi.cpp @@ -448,6 +448,12 @@ int AgiEngine::agiInit() { loadGame(saveNameBuffer, false); // Do not check game id } +#ifdef __DS__ + // Normally, the engine loads the predictive text dictionary when the predictive dialog + // is shown. On the DS version, the word completion feature needs the dictionary too. + loadDict(); +#endif + return ec; } diff --git a/engines/agi/predictive.cpp b/engines/agi/predictive.cpp index 2db4b49396..eef4360cbf 100644 --- a/engines/agi/predictive.cpp +++ b/engines/agi/predictive.cpp @@ -30,6 +30,10 @@ #include "common/func.h" #include "common/config-manager.h" +#ifdef __DS__ +#include "wordcompletion.h" +#endif + namespace Agi { #define kModePre 0 @@ -521,6 +525,10 @@ void AgiEngine::loadDict(void) { while ((ptr = strchr(ptr, '\n'))) { *ptr = 0; ptr++; +#ifdef __DS__ + // Pass the line on to the DS word list + DS::addAutoCompleteLine(_predictiveDictLine[i - 1]); +#endif _predictiveDictLine[i++] = ptr; } if (_predictiveDictLine[lines - 1][0] == 0) @@ -529,6 +537,11 @@ void AgiEngine::loadDict(void) { _predictiveDictLineCount = lines; debug("Loaded %d lines", _predictiveDictLineCount); +#ifdef __DS__ + // Sort the DS word completion list, to allow for a binary chop later (in the ds backend) + DS::sortAutoCompleteWordList(); +#endif + uint32 time3 = _system->getMillis(); printf("Time to parse pred.dic: %d, total: %d\n", time3-time2, time3-time1); } -- cgit v1.2.3 From 5b7df04da9001d79c4cf5704b5d86de130e481f0 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 17 Jul 2007 18:04:30 +0000 Subject: Possible fix for bug 1754613. It's now possible to have an uncompressed music.rsc file when the rest of the data files are compressed svn-id: r28126 --- engines/saga/rscfile.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/saga/rscfile.cpp b/engines/saga/rscfile.cpp index 59dc42225c..39224b032b 100644 --- a/engines/saga/rscfile.cpp +++ b/engines/saga/rscfile.cpp @@ -427,14 +427,14 @@ bool Resource::createContexts() { if (Common::File::exists("music.rsc") || Common::File::exists("music.cmp")) { _contextsCount++; digitalMusic = true; - if (_vm->getFeatures() & GF_COMPRESSED_SOUNDS) + if (Common::File::exists("music.cmp")) sprintf(musicFileName, "music.cmp"); else sprintf(musicFileName, "music.rsc"); } else if (Common::File::exists("musicd.rsc") || Common::File::exists("musicd.cmp")) { _contextsCount++; digitalMusic = true; - if (_vm->getFeatures() & GF_COMPRESSED_SOUNDS) + if (Common::File::exists("musicd.rsc")) sprintf(musicFileName, "musicd.cmp"); else sprintf(musicFileName, "musicd.rsc"); -- cgit v1.2.3 From 332f74486e5bab77c3577d1a5579e48414aed390 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 17 Jul 2007 18:18:50 +0000 Subject: Possible fix for bug 1754613, part 2: changed the way compressed digital music is detected svn-id: r28127 --- engines/saga/music.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/saga/music.cpp b/engines/saga/music.cpp index a02f48db1b..2e4868f412 100644 --- a/engines/saga/music.cpp +++ b/engines/saga/music.cpp @@ -89,7 +89,7 @@ DigitalMusicInputStream::DigitalMusicInputStream(SagaEngine *vm, ResourceContext _compressedStream = NULL; - if (vm->getFeatures() & GF_COMPRESSED_SOUNDS) { + if (Common::File::exists("music.cmp")) { // Read compressed header to determine compression type _file->seek((long)resourceData->offset, SEEK_SET); _file->read(compressedHeader, 9); -- cgit v1.2.3 From a5e6b75edbbff5d5bc725905a6d5114a8825e988 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 17 Jul 2007 20:17:28 +0000 Subject: Re-enabled the 3 entries that can't have menus (KQ3 ST, KQ3 DOS 1.01, SQ1 DOS 1.0X). The ESC key will pause the game in those 3 games svn-id: r28129 --- engines/agi/agi.h | 3 ++- engines/agi/detection.cpp | 24 ++++++++++++------------ engines/agi/keyboard.cpp | 6 ++++-- 3 files changed, 18 insertions(+), 15 deletions(-) (limited to 'engines') diff --git a/engines/agi/agi.h b/engines/agi/agi.h index 6c89edf1dd..942c4df72e 100644 --- a/engines/agi/agi.h +++ b/engines/agi/agi.h @@ -112,7 +112,8 @@ enum AgiGameFeatures { GF_AGIPAL = (1 << 4), GF_MACGOLDRUSH = (1 << 5), GF_FANMADE = (1 << 6), - GF_MENUS = (1 << 7) + GF_MENUS = (1 << 7), + GF_ESCPAUSE = (1 << 8) }; enum AgiGameID { diff --git a/engines/agi/detection.cpp b/engines/agi/detection.cpp index 381444f5ff..be5a3bbb36 100644 --- a/engines/agi/detection.cpp +++ b/engines/agi/detection.cpp @@ -648,10 +648,10 @@ static const AGIGameDescription gameDescriptions[] = { 0x2440, }, -#if 0 + { // King's Quest 3 (ST) 1.02 11/18/86 - // Problematic: does not have menus, crashes if menus are enforced + // Does not have menus, crashes if menus are enforced. Therefore, ESC pauses the game { "kq3", "1.02 1986-11-18", @@ -662,10 +662,10 @@ static const AGIGameDescription gameDescriptions[] = { }, GID_KQ3, GType_V2, - 0, + GF_ESCPAUSE, 0x2272, }, -#endif + { // King's Quest 3 (Mac) 2.14 3/15/88 @@ -717,10 +717,10 @@ static const AGIGameDescription gameDescriptions[] = { 0x3086, }, -#if 0 + { // King's Quest 3 (PC) 1.01 11/08/86 [AGI 2.272] - // Problematic: does not have menus, crashes if menus are enforced + // Does not have menus, crashes if menus are enforced. Therefore, ESC pauses the game { "kq3", "1.01 1986-11-08", @@ -731,10 +731,10 @@ static const AGIGameDescription gameDescriptions[] = { }, GID_KQ3, GType_V2, - 0, + GF_ESCPAUSE, 0x2272, }, -#endif + { // King's Quest 3 (PC 5.25") 2.00 5/25/87 [AGI 2.435] @@ -1411,10 +1411,10 @@ static const AGIGameDescription gameDescriptions[] = { 0x2917, }, -#if 0 + { // Space Quest 1 (PC) 1.0X [AGI 2.089] - // Problematic: does not have menus, crashes if menus are enforced + // Does not have menus, crashes if menus are enforced. Therefore, ESC pauses the game { "sq1", "1.0X 1986-09-24", @@ -1425,10 +1425,10 @@ static const AGIGameDescription gameDescriptions[] = { }, GID_SQ1, GType_V2, - 0, + GF_ESCPAUSE, 0x2089, }, -#endif + { diff --git a/engines/agi/keyboard.cpp b/engines/agi/keyboard.cpp index d41100d5d8..2b7559f754 100644 --- a/engines/agi/keyboard.cpp +++ b/engines/agi/keyboard.cpp @@ -107,8 +107,10 @@ int AgiEngine::handleController(int key) { VtEntry *v = &_game.viewTable[0]; int i; - /* AGI 3.149 games and The Black Cauldron need KEY_ESCAPE to use menus */ - if (key == 0 || (key == KEY_ESCAPE && agiGetRelease() != 0x3149 && getGameID() != GID_BC) ) + // AGI 3.149 games and The Black Cauldron need KEY_ESCAPE to use menus + // Games with the GF_ESCPAUSE flag need KEY_ESCAPE to pause the game + if (key == 0 || + (key == KEY_ESCAPE && agiGetRelease() != 0x3149 && getGameID() != GID_BC && !(getFeatures() & GF_ESCPAUSE)) ) return false; if ((getGameID() == GID_MH1 || getGameID() == GID_MH2) && (key == KEY_ENTER) && -- cgit v1.2.3 From d04b653378d92facccf597f80fb3911d7d22f5c9 Mon Sep 17 00:00:00 2001 From: Paweł Kołodziejski Date: Tue, 17 Jul 2007 21:35:01 +0000 Subject: added engine stubs code for Drascula game svn-id: r28130 --- engines/drascula/detection.cpp | 183 +++++++++++++++++++++++++++++++++++++++++ engines/drascula/drascula.cpp | 104 +++++++++++++++++++++++ engines/drascula/drascula.h | 81 ++++++++++++++++++ engines/drascula/module.mk | 14 ++++ engines/engines.mk | 6 ++ 5 files changed, 388 insertions(+) create mode 100644 engines/drascula/detection.cpp create mode 100644 engines/drascula/drascula.cpp create mode 100644 engines/drascula/drascula.h create mode 100644 engines/drascula/module.mk (limited to 'engines') diff --git a/engines/drascula/detection.cpp b/engines/drascula/detection.cpp new file mode 100644 index 0000000000..7748b71bd2 --- /dev/null +++ b/engines/drascula/detection.cpp @@ -0,0 +1,183 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include "common/stdafx.h" + +#include "base/plugins.h" + +#include "common/advancedDetector.h" +#include "common/file.h" + +#include "drascula/drascula.h" + + +namespace Drascula { + +struct DrasculaGameDescription { + Common::ADGameDescription desc; + + int gameID; + int gameType; + uint32 features; + uint16 version; +}; + +uint32 DrasculaEngine::getGameID() const { + return _gameDescription->gameID; +} + +uint32 DrasculaEngine::getFeatures() const { + return _gameDescription->features; +} + +Common::Platform DrasculaEngine::getPlatform() const { + return _gameDescription->desc.platform; +} + +uint16 DrasculaEngine::getVersion() const { + return _gameDescription->version; +} + +} + +static const PlainGameDescriptor drasculaGames[] = { + {"drascula", "Drascula game"}, + + {0, 0} +}; + + +namespace Drascula { + +static const DrasculaGameDescription gameDescriptions[] = { +/* + { + // Drascula English + { + "drascula", + "English", + AD_ENTRY1("logdir", "9c4a5b09cc3564bc48b4766e679ea332"), + Common::EN_ANY, + Common::kPlatformPC, + Common::ADGF_NO_FLAGS + }, + 0, + 0, + 0, + 0, + }, + + { + // Drascula Spanish + { + "drascula", + "Spanish", + AD_ENTRY1("logdir", "9c4a5b09cc3564bc48b4766e679ea332"), + Common::EN_ANY, + Common::kPlatformPC, + Common::ADGF_NO_FLAGS + }, + 0, + 0, + 0, + 0, + }, +*/ + { AD_TABLE_END_MARKER, 0, 0, 0, 0 } +}; + +/** + * The fallback game descriptor used by the Drascula engine's fallbackDetector. + * Contents of this struct are to be overwritten by the fallbackDetector. + */ +static DrasculaGameDescription g_fallbackDesc = { + { + "", // Not used by the fallback descriptor, it uses the EncapsulatedADGameDesc's gameid + "", // Not used by the fallback descriptor, it uses the EncapsulatedADGameDesc's extra + AD_ENTRY1(0, 0), // This should always be AD_ENTRY1(0, 0) in the fallback descriptor + Common::UNK_LANG, + Common::kPlatformPC, + Common::ADGF_NO_FLAGS + }, + 0, + 0, + 0, + 0, +}; + +Common::EncapsulatedADGameDesc fallbackDetector(const FSList *fslist) { + // Set the default values for the fallback descriptor's ADGameDescription part. + g_fallbackDesc.desc.language = Common::UNK_LANG; + g_fallbackDesc.desc.platform = Common::kPlatformPC; + g_fallbackDesc.desc.flags = Common::ADGF_NO_FLAGS; + + // Set default values for the fallback descriptor's DrasculaGameDescription part. + g_fallbackDesc.gameID = 0; + g_fallbackDesc.features = 0; + g_fallbackDesc.version = 0; + + Common::EncapsulatedADGameDesc result; + + return result; +} + +} // End of namespace Drascula + +static const Common::ADParams detectionParams = { + // Pointer to ADGameDescription or its superset structure + (const byte *)Drascula::gameDescriptions, + // Size of that superset structure + sizeof(Drascula::DrasculaGameDescription), + // Number of bytes to compute MD5 sum for + 5000, + // List of all engine targets + drasculaGames, + // Structure for autoupgrading obsolete targets + 0, + // Name of single gameid (optional) + "drascula", + // List of files for file-based fallback detection (optional) + 0, + // Fallback callback + Drascula::fallbackDetector, + // Flags + Common::kADFlagAugmentPreferredTarget +}; + +ADVANCED_DETECTOR_DEFINE_PLUGIN(DRASCULA, Drascula::DrasculaEngine, detectionParams); + +REGISTER_PLUGIN(DRASCULA, "Drascula Engine", "Drascula Engine (C) 2000 Alcachofa Soft, 1996 (C) Digital Dreams Multimedia, 1994 (C) Emilio de Paz"); + +namespace Drascula { + +bool DrasculaEngine::initGame() { + Common::EncapsulatedADGameDesc encapsulatedDesc = Common::AdvancedDetector::detectBestMatchingGame(detectionParams); + _gameDescription = (const DrasculaGameDescription *)(encapsulatedDesc.realDesc); + + return (_gameDescription != 0); +} + +} // End of namespace Drascula + diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp new file mode 100644 index 0000000000..abf5d182f4 --- /dev/null +++ b/engines/drascula/drascula.cpp @@ -0,0 +1,104 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $UR$ + * $Id$ + * + */ + +#include "common/stdafx.h" + +#include "common/events.h" +#include "common/file.h" +#include "common/savefile.h" +#include "common/config-manager.h" + +#include "base/plugins.h" +#include "base/version.h" + +#include "sound/mixer.h" + +#include "drascula/drascula.h" + +namespace Drascula { + +struct GameSettings { + const char *gameid; + const char *description; + byte id; + uint32 features; + const char *detectname; +}; + +static const GameSettings agiSettings[] = { + {"drascula", "Drascula game", 0, 0, 0}, + + {NULL, NULL, 0, 0, NULL} +}; + +DrasculaEngine::DrasculaEngine(OSystem *syst) : Engine(syst) { + + // Setup mixer + if (!_mixer->isReady()) { + warning("Sound initialization failed."); + } + + _mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume")); + _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume")); + + const GameSettings *g; + + const char *gameid = ConfMan.get("gameid").c_str(); + for (g = agiSettings; g->gameid; ++g) + if (!scumm_stricmp(g->gameid, gameid)) + _gameId = g->id; + + _rnd = new Common::RandomSource(); + +} + +DrasculaEngine::~DrasculaEngine() { + delete _rnd; +} + +int DrasculaEngine::init() { + // Detect game + if (!initGame()) { + GUIErrorMessage("No valid games were found in the specified directory."); + return -1; + } + + // Initialize backend + _system->beginGFXTransaction(); + initCommonGFX(false); + _system->initSize(320, 200); + _system->endGFXTransaction(); + + return 0; +} + +int DrasculaEngine::go() { + + //runGame(); + + return 0; +} + +} // End of namespace Drascula diff --git a/engines/drascula/drascula.h b/engines/drascula/drascula.h new file mode 100644 index 0000000000..ff3e77c798 --- /dev/null +++ b/engines/drascula/drascula.h @@ -0,0 +1,81 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#ifndef DRASCULA_H +#define DRASCULA_H + +#include "common/stdafx.h" +#include "common/scummsys.h" +#include "common/endian.h" +#include "common/util.h" +#include "common/file.h" +#include "common/savefile.h" +#include "common/system.h" +#include "common/hash-str.h" + +#include "engines/engine.h" + +namespace Drascula { + +enum DrasculaGameFeatures { +}; + +struct DrasculaGameDescription; + + +class DrasculaEngine : public ::Engine { + int _gameId; + +protected: + + int init(); + int go(); +// void shutdown(); + + bool initGame(); + +public: + DrasculaEngine(OSystem *syst); + virtual ~DrasculaEngine(); + int getGameId() { + return _gameId; + } + + Common::RandomSource *_rnd; + const DrasculaGameDescription *_gameDescription; + uint32 getGameID() const; + uint32 getFeatures() const; + uint16 getVersion() const; + Common::Platform getPlatform() const; + +private: + +public: + +}; + +} // End of namespace Drascula + +#endif /* DRASCULA_H */ diff --git a/engines/drascula/module.mk b/engines/drascula/module.mk new file mode 100644 index 0000000000..51fb965915 --- /dev/null +++ b/engines/drascula/module.mk @@ -0,0 +1,14 @@ +MODULE := engines/drascula + +MODULE_OBJS = \ + detection.o \ + drascula.o + + +# This module can be built as a plugin +ifdef BUILD_PLUGINS +PLUGIN := 1 +endif + +# Include common rules +include $(srcdir)/rules.mk diff --git a/engines/engines.mk b/engines/engines.mk index b141d66585..2d6031ff12 100644 --- a/engines/engines.mk +++ b/engines/engines.mk @@ -96,3 +96,9 @@ DEFINES += -DDISABLE_CRUISE else MODULES += engines/cruise endif + +ifdef DISABLE_DRASCULA +DEFINES += -DDISABLE_DRASCULA +else +MODULES += engines/drascula +endif -- cgit v1.2.3 From 40e7b7555b61446d66d4068c4babccb08c1c6ebf Mon Sep 17 00:00:00 2001 From: Paweł Kołodziejski Date: Tue, 17 Jul 2007 22:29:09 +0000 Subject: added english and spanish version of drascula detection svn-id: r28132 --- engines/drascula/detection.cpp | 14 +++++++------- engines/drascula/drascula.cpp | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'engines') diff --git a/engines/drascula/detection.cpp b/engines/drascula/detection.cpp index 7748b71bd2..d875a52d71 100644 --- a/engines/drascula/detection.cpp +++ b/engines/drascula/detection.cpp @@ -72,13 +72,13 @@ static const PlainGameDescriptor drasculaGames[] = { namespace Drascula { static const DrasculaGameDescription gameDescriptions[] = { -/* + { - // Drascula English + // Drascula English version { "drascula", "English", - AD_ENTRY1("logdir", "9c4a5b09cc3564bc48b4766e679ea332"), + AD_ENTRY1("14.ald", "09b2735953edcd43af115c65ae00b10e"), Common::EN_ANY, Common::kPlatformPC, Common::ADGF_NO_FLAGS @@ -90,12 +90,12 @@ static const DrasculaGameDescription gameDescriptions[] = { }, { - // Drascula Spanish + // Drascula Spanish version { "drascula", "Spanish", - AD_ENTRY1("logdir", "9c4a5b09cc3564bc48b4766e679ea332"), - Common::EN_ANY, + AD_ENTRY1("14.ald", "0746ed1a5cc8d9728f790c29813f4b43"), + Common::ES_ESP, Common::kPlatformPC, Common::ADGF_NO_FLAGS }, @@ -104,7 +104,7 @@ static const DrasculaGameDescription gameDescriptions[] = { 0, 0, }, -*/ + { AD_TABLE_END_MARKER, 0, 0, 0, 0 } }; diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp index abf5d182f4..cd84a89ea1 100644 --- a/engines/drascula/drascula.cpp +++ b/engines/drascula/drascula.cpp @@ -47,7 +47,7 @@ struct GameSettings { const char *detectname; }; -static const GameSettings agiSettings[] = { +static const GameSettings drasculaSettings[] = { {"drascula", "Drascula game", 0, 0, 0}, {NULL, NULL, 0, 0, NULL} @@ -66,7 +66,7 @@ DrasculaEngine::DrasculaEngine(OSystem *syst) : Engine(syst) { const GameSettings *g; const char *gameid = ConfMan.get("gameid").c_str(); - for (g = agiSettings; g->gameid; ++g) + for (g = drasculaSettings; g->gameid; ++g) if (!scumm_stricmp(g->gameid, gameid)) _gameId = g->id; -- cgit v1.2.3 From 32c87556de72593a6d6aff021dc599cf7ff9b13d Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 18 Jul 2007 16:14:40 +0000 Subject: The SFX resource for the IHNM demo is different svn-id: r28138 --- engines/saga/sagaresnames.h | 1 + engines/saga/sndres.cpp | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/saga/sagaresnames.h b/engines/saga/sagaresnames.h index 94f97635c1..8a4ac5f568 100644 --- a/engines/saga/sagaresnames.h +++ b/engines/saga/sagaresnames.h @@ -45,6 +45,7 @@ namespace Saga { #define RID_IHNMDEMO_SCENE_LUT 286 #define RID_IHNMDEMO_SCRIPT_LUT 18 +#define RID_IHNMDEMO_SFX_LUT 222 //obj names #define ITE_OBJ_MAP 14 diff --git a/engines/saga/sndres.cpp b/engines/saga/sndres.cpp index 7033aaed33..9f783bd50d 100644 --- a/engines/saga/sndres.cpp +++ b/engines/saga/sndres.cpp @@ -68,8 +68,13 @@ SndRes::SndRes(SagaEngine *vm) : _vm(vm) { byte *resourcePointer; size_t resourceLength; - _vm->_resource->loadResource(resourceContext, RID_IHNM_SFX_LUT, - resourcePointer, resourceLength); + if (_vm->getGameId() == GID_IHNM_DEMO) { + _vm->_resource->loadResource(resourceContext, RID_IHNMDEMO_SFX_LUT, + resourcePointer, resourceLength); + } else { + _vm->_resource->loadResource(resourceContext, RID_IHNM_SFX_LUT, + resourcePointer, resourceLength); + } if (resourceLength == 0) { error("Sndres::SndRes can't read SfxIDs table"); -- cgit v1.2.3 From d9932d110a544452ad624764c0082c65857ef5da Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 19 Jul 2007 00:40:11 +0000 Subject: Fix for bug #1754613 - ITE: crashes using compressed audio. The digital music information was missing from the ITE versions that did not originally include digital music svn-id: r28141 --- engines/saga/detection_tables.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'engines') diff --git a/engines/saga/detection_tables.h b/engines/saga/detection_tables.h index bf571e2c13..b33931bd78 100644 --- a/engines/saga/detection_tables.h +++ b/engines/saga/detection_tables.h @@ -123,6 +123,8 @@ static const GameSoundInfo ITEMACDEMO_GameSound = { true }; +/* +// Not used static const GameSoundInfo ITEMACDEMO_GameMusic = { kSoundPCM, 11025, @@ -131,6 +133,7 @@ static const GameSoundInfo ITEMACDEMO_GameMusic = { false, true }; +*/ // Inherit the Earth - Wyrmkeep Linux Demo version static const GameSoundInfo ITELINDEMO_GameMusic = { @@ -326,7 +329,7 @@ static const SAGAGameDescription gameDescriptions[] = { ITEDEMO_GameFonts, &ITEDEMO_GameSound, &ITEDEMO_GameSound, - NULL, + &ITEMACCD_GameMusic, // note: this version did not originally have digital music 0, NULL, }, @@ -424,7 +427,7 @@ static const SAGAGameDescription gameDescriptions[] = { ITEWINDEMO_GameFonts, &ITEWINDEMO1_GameSound, &ITEWINDEMO1_GameSound, - NULL, + &ITEMACCD_GameMusic, // note: this version did not originally have digital music ARRAYSIZE(ITEPatch_Files), ITEPatch_Files, }, @@ -457,7 +460,7 @@ static const SAGAGameDescription gameDescriptions[] = { ITEWINDEMO_GameFonts, &ITEMACCD_G_GameSound, &ITEMACCD_G_GameSound, - NULL, + &ITEMACCD_GameMusic, // note: this version did not originally have digital music 0, NULL, }, @@ -587,7 +590,7 @@ static const SAGAGameDescription gameDescriptions[] = { ITECD_GameFonts, &ITECD_GameSound, &ITECD_GameSound, - NULL, + &ITEMACCD_GameMusic, // note: this version did not originally have digital music 0, NULL, }, @@ -618,7 +621,7 @@ static const SAGAGameDescription gameDescriptions[] = { ITECD_GameFonts, &ITECD_GameSound, &ITECD_GameSound, - NULL, + &ITEMACCD_GameMusic, // note: this version did not originally have digital music 0, NULL, }, @@ -649,7 +652,7 @@ static const SAGAGameDescription gameDescriptions[] = { ITEDISK_GameFonts, &ITEDISK_GameSound, &ITEDISK_GameSound, - NULL, + &ITEMACCD_GameMusic, // note: this version did not originally have digital music 0, NULL, }, @@ -678,7 +681,7 @@ static const SAGAGameDescription gameDescriptions[] = { ITEDISK_GameFonts, &ITEDISK_GameSound, &ITEDISK_GameSound, - NULL, + &ITEMACCD_GameMusic, // note: this version did not originally have digital music 0, NULL, }, -- cgit v1.2.3 From 470dac5f8b2c0d57879fbc636aacc2087a916777 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 19 Jul 2007 01:28:41 +0000 Subject: IHNM: Correct mapping of the arrow and save reminder sprites for the IHNM demo svn-id: r28143 --- engines/saga/sagaresnames.h | 3 +++ engines/saga/sprite.cpp | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/saga/sagaresnames.h b/engines/saga/sagaresnames.h index 8a4ac5f568..ce61be7864 100644 --- a/engines/saga/sagaresnames.h +++ b/engines/saga/sagaresnames.h @@ -111,6 +111,9 @@ namespace Saga { #define RID_IHNM_PROFILE_BG 20 #define RID_IHNM_MAIN_STRINGS 21 +#define RID_IHNMDEMO_ARROW_SPRITES 8 +#define RID_IHNMDEMO_SAVEREMINDER_SPRITES 9 + // Puzzle portraits #define RID_ITE_SAKKA_APPRAISING 6 #define RID_ITE_SAKKA_DENIAL 7 diff --git a/engines/saga/sprite.cpp b/engines/saga/sprite.cpp index 607e7d0a0b..bbe73a48a0 100644 --- a/engines/saga/sprite.cpp +++ b/engines/saga/sprite.cpp @@ -57,8 +57,13 @@ Sprite::Sprite(SagaEngine *vm) : _vm(vm) { loadList(_vm->getResourceDescription()->mainSpritesResourceId, _mainSprites); _arrowSprites = _saveReminderSprites = _inventorySprites = _mainSprites; } else { - loadList(RID_IHNM_ARROW_SPRITES, _arrowSprites); - loadList(RID_IHNM_SAVEREMINDER_SPRITES, _saveReminderSprites); + if (_vm->getGameId() == GID_IHNM_DEMO) { + loadList(RID_IHNMDEMO_ARROW_SPRITES, _arrowSprites); + loadList(RID_IHNMDEMO_SAVEREMINDER_SPRITES, _saveReminderSprites); + } else { + loadList(RID_IHNM_ARROW_SPRITES, _arrowSprites); + loadList(RID_IHNM_SAVEREMINDER_SPRITES, _saveReminderSprites); + } } } -- cgit v1.2.3 From 3ffd5dea2aec39d40a662e8585fe9e730fbe9785 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 19 Jul 2007 02:51:36 +0000 Subject: Some more resource mappings for the IHNM demo svn-id: r28144 --- engines/saga/detection_tables.h | 17 ++++++++++++++++- engines/saga/sagaresnames.h | 17 ++++++++++++++--- 2 files changed, 30 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/saga/detection_tables.h b/engines/saga/detection_tables.h index b33931bd78..75d45e4bb6 100644 --- a/engines/saga/detection_tables.h +++ b/engines/saga/detection_tables.h @@ -274,6 +274,21 @@ static const GameResourceDescription IHNM_Resources = { 0 // Actors strings (ITE only) }; +static const GameResourceDescription IHNMDEMO_Resources = { + RID_IHNMDEMO_SCENE_LUT, // Scene lookup table RN + RID_IHNMDEMO_SCRIPT_LUT, // Script lookup table RN + RID_IHNMDEMO_MAIN_PANEL, + RID_IHNMDEMO_CONVERSE_PANEL, + RID_IHNMDEMO_OPTION_PANEL, + RID_IHNMDEMO_WARNING_PANEL, + RID_IHNMDEMO_MAIN_SPRITES, + RID_IHNMDEMO_MAIN_PANEL_SPRITES, + RID_IHNMDEMO_OPTION_PANEL_SPRITES, + 0, // Default portraits (ITE only) + RID_IHNMDEMO_MAIN_STRINGS, + 0 // Actors strings (ITE only) +}; + static const GameFontDescription IHNMDEMO_GameFonts[] = { {2}, {3}, @@ -708,7 +723,7 @@ static const SAGAGameDescription gameDescriptions[] = { GID_IHNM_DEMO, 0, 0, - &IHNM_Resources, + &IHNMDEMO_Resources, ARRAYSIZE(IHNMDEMO_GameFonts), IHNMDEMO_GameFonts, &IHNM_GameSound, diff --git a/engines/saga/sagaresnames.h b/engines/saga/sagaresnames.h index ce61be7864..935544bb7b 100644 --- a/engines/saga/sagaresnames.h +++ b/engines/saga/sagaresnames.h @@ -43,8 +43,8 @@ namespace Saga { #define RID_IHNM_SCRIPT_LUT 29 #define RID_IHNM_SFX_LUT 265 -#define RID_IHNMDEMO_SCENE_LUT 286 -#define RID_IHNMDEMO_SCRIPT_LUT 18 +#define RID_IHNMDEMO_SCENE_LUT 286 // TODO: is this correct? +#define RID_IHNMDEMO_SCRIPT_LUT 18 // TODO: is this correct? #define RID_IHNMDEMO_SFX_LUT 222 //obj names @@ -100,7 +100,7 @@ namespace Saga { #define RID_IHNM_MAIN_PANEL 9 #define RID_IHNM_CONVERSE_PANEL 10 #define RID_IHNM_HOURGLASS_CURSOR 11 -#define RID_IHNM_MAIN_SPRITES 12 // TODO: verify this +#define RID_IHNM_MAIN_SPRITES 12 #define RID_IHNM_MAIN_PANEL_SPRITES 12 #define RID_IHNM_ARROW_SPRITES 13 #define RID_IHNM_SAVEREMINDER_SPRITES 14 @@ -111,8 +111,19 @@ namespace Saga { #define RID_IHNM_PROFILE_BG 20 #define RID_IHNM_MAIN_STRINGS 21 +#define RID_IHNMDEMO_MAIN_PANEL 4 // TODO: Verify this +#define RID_IHNMDEMO_CONVERSE_PANEL 5 // TODO: Verify this +#define RID_IHNMDEMO_HOURGLASS_CURSOR 6 // TODO: Verify this +#define RID_IHNMDEMO_MAIN_SPRITES 7 +#define RID_IHNMDEMO_MAIN_PANEL_SPRITES 7 #define RID_IHNMDEMO_ARROW_SPRITES 8 #define RID_IHNMDEMO_SAVEREMINDER_SPRITES 9 +#define RID_IHNMDEMO_OPTION_PANEL 10 // TODO: Verify this +#define RID_IHNMDEMO_OPTION_PANEL_SPRITES 11 // TODO: Verify this +#define RID_IHNMDEMO_WARNING_PANEL 12 // TODO: Verify this +#define RID_IHNMDEMO_BOSS_SCREEN 13 // TODO: Verify this +#define RID_IHNMDEMO_PROFILE_BG 14 // TODO: Verify this +#define RID_IHNMDEMO_MAIN_STRINGS 15 // TODO: Verify this // Puzzle portraits #define RID_ITE_SAKKA_APPRAISING 6 -- cgit v1.2.3 From a50b03a9fc280cbd09b63776d6102bd780cc41dd Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 19 Jul 2007 10:24:34 +0000 Subject: Some small updates on the IHNM demo svn-id: r28146 --- engines/saga/sagaresnames.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/saga/sagaresnames.h b/engines/saga/sagaresnames.h index 935544bb7b..3fd0332eb2 100644 --- a/engines/saga/sagaresnames.h +++ b/engines/saga/sagaresnames.h @@ -43,8 +43,8 @@ namespace Saga { #define RID_IHNM_SCRIPT_LUT 29 #define RID_IHNM_SFX_LUT 265 -#define RID_IHNMDEMO_SCENE_LUT 286 // TODO: is this correct? -#define RID_IHNMDEMO_SCRIPT_LUT 18 // TODO: is this correct? +#define RID_IHNMDEMO_SCENE_LUT 286 +#define RID_IHNMDEMO_SCRIPT_LUT 18 #define RID_IHNMDEMO_SFX_LUT 222 //obj names @@ -113,7 +113,7 @@ namespace Saga { #define RID_IHNMDEMO_MAIN_PANEL 4 // TODO: Verify this #define RID_IHNMDEMO_CONVERSE_PANEL 5 // TODO: Verify this -#define RID_IHNMDEMO_HOURGLASS_CURSOR 6 // TODO: Verify this +#define RID_IHNMDEMO_HOURGLASS_CURSOR 6 // Does not exist in the demo #define RID_IHNMDEMO_MAIN_SPRITES 7 #define RID_IHNMDEMO_MAIN_PANEL_SPRITES 7 #define RID_IHNMDEMO_ARROW_SPRITES 8 @@ -121,7 +121,7 @@ namespace Saga { #define RID_IHNMDEMO_OPTION_PANEL 10 // TODO: Verify this #define RID_IHNMDEMO_OPTION_PANEL_SPRITES 11 // TODO: Verify this #define RID_IHNMDEMO_WARNING_PANEL 12 // TODO: Verify this -#define RID_IHNMDEMO_BOSS_SCREEN 13 // TODO: Verify this +#define RID_IHNMDEMO_BOSS_SCREEN 13 // Does not exist in the demo #define RID_IHNMDEMO_PROFILE_BG 14 // TODO: Verify this #define RID_IHNMDEMO_MAIN_STRINGS 15 // TODO: Verify this -- cgit v1.2.3 From a88189b73d77030eab2f8877b817f753cab4fae9 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Fri, 20 Jul 2007 21:35:56 +0000 Subject: Add Japanese MI1 for SEGA CD svn-id: r28151 --- engines/scumm/scumm-md5.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/scumm/scumm-md5.h b/engines/scumm/scumm-md5.h index 8694f21e65..4f6b2477c6 100644 --- a/engines/scumm/scumm-md5.h +++ b/engines/scumm/scumm-md5.h @@ -1,5 +1,5 @@ /* - This file was generated by the md5table tool on Mon Jul 16 12:41:17 2007 + This file was generated by the md5table tool on Fri Jul 20 21:25:14 2007 DO NOT EDIT MANUALLY! */ @@ -25,6 +25,7 @@ static const MD5Table md5table[] = { { "04687cdf7f975a89d2474929f7b80946", "indy3", "FM-TOWNS", "", 7552, Common::EN_ANY, Common::kPlatformFMTowns }, { "0557df19f046a84c2fdc63507c6616cb", "farm", "HE 72", "Demo", -1, Common::NL_NLD, Common::kPlatformWindows }, { "055ffe4f47753e47594ac67823220c54", "puttrace", "HE 99", "", -1, Common::DE_DEU, Common::kPlatformUnknown }, + { "057c9b456dedcc4d71b991a3072a20b3", "monkey", "SEGA", "", 9465, Common::JA_JPN, Common::kPlatformSegaCD }, { "0650e8ab1432564607cd651c0fa3f344", "loom", "PC-Engine", "", -1, Common::EN_ANY, Common::kPlatformPCEngine }, { "06b187468113f9ae5a400b148a847fac", "atlantis", "", "Floppy", 12075, Common::EN_ANY, Common::kPlatformMacintosh }, { "06c3cf4f31daad8b1cd93153491db9e6", "pajama3", "", "", -1, Common::NL_NLD, Common::kPlatformMacintosh }, -- cgit v1.2.3 From b01f07a548fa883ffde48ac00599de69fab93f5c Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Fri, 20 Jul 2007 21:45:28 +0000 Subject: Prevent crash in MI1 SegaCD Jap. svn-id: r28152 --- engines/scumm/charset.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'engines') diff --git a/engines/scumm/charset.cpp b/engines/scumm/charset.cpp index ecc6521cba..ad4ee582ca 100644 --- a/engines/scumm/charset.cpp +++ b/engines/scumm/charset.cpp @@ -50,6 +50,9 @@ void ScummEngine::loadCJKFont() { _useCJKMode = false; _textSurfaceMultiplier = 1; + if (_game.platform == Common::kPlatformSegaCD) + return; + if (_language == Common::JA_JPN && _game.version <= 5) { // FM-TOWNS v3 / v5 Kanji int numChar = 256 * 32; _2byteWidth = 16; -- cgit v1.2.3 From b16d398eb1ad11d3c976ae81427d02609584a571 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Sat, 21 Jul 2007 14:39:12 +0000 Subject: The mixer no longer allows unpausing channels that aren't paused. So don't. svn-id: r28155 --- engines/sword2/music.cpp | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'engines') diff --git a/engines/sword2/music.cpp b/engines/sword2/music.cpp index b442b6194f..c2374dad9f 100644 --- a/engines/sword2/music.cpp +++ b/engines/sword2/music.cpp @@ -667,8 +667,10 @@ void Sound::muteSpeech(bool mute) { */ void Sound::pauseSpeech() { - _speechPaused = true; - _vm->_mixer->pauseHandle(_soundHandleSpeech, true); + if (!_speechPaused) { + _speechPaused = true; + _vm->_mixer->pauseHandle(_soundHandleSpeech, true); + } } /** @@ -676,8 +678,10 @@ void Sound::pauseSpeech() { */ void Sound::unpauseSpeech() { - _speechPaused = false; - _vm->_mixer->pauseHandle(_soundHandleSpeech, false); + if (_speechPaused) { + _speechPaused = false; + _vm->_mixer->pauseHandle(_soundHandleSpeech, false); + } } /** @@ -801,26 +805,22 @@ int32 Sound::setFxIdVolumePan(int32 id, int vol, int pan) { } void Sound::pauseFx() { - if (_fxPaused) - return; - - for (int i = 0; i < FXQ_LENGTH; i++) { - if (_fxQueue[i].resource) - _vm->_mixer->pauseHandle(_fxQueue[i].handle, true); + if (!_fxPaused) { + for (int i = 0; i < FXQ_LENGTH; i++) { + if (_fxQueue[i].resource) + _vm->_mixer->pauseHandle(_fxQueue[i].handle, true); + } + _fxPaused = true; } - - _fxPaused = true; } void Sound::unpauseFx() { - if (!_fxPaused) - return; - - for (int i = 0; i < FXQ_LENGTH; i++) - if (_fxQueue[i].resource) - _vm->_mixer->pauseHandle(_fxQueue[i].handle, false); - - _fxPaused = false; + if (_fxPaused) { + for (int i = 0; i < FXQ_LENGTH; i++) + if (_fxQueue[i].resource) + _vm->_mixer->pauseHandle(_fxQueue[i].handle, false); + _fxPaused = false; + } } } // End of namespace Sword2 -- cgit v1.2.3 From 7a6f0b7460ecb5be663e53d12ce226d9ae9a2d12 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sat, 21 Jul 2007 19:53:18 +0000 Subject: SCUMM/iMuse Digital: Pause sounds after loading them svn-id: r28158 --- engines/scumm/imuse_digi/dimuse.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines') diff --git a/engines/scumm/imuse_digi/dimuse.cpp b/engines/scumm/imuse_digi/dimuse.cpp index 0221657966..38e918c21a 100644 --- a/engines/scumm/imuse_digi/dimuse.cpp +++ b/engines/scumm/imuse_digi/dimuse.cpp @@ -221,6 +221,7 @@ void IMuseDigital::saveOrLoad(Serializer *ser) { type = Audio::Mixer::kMusicSoundType; _mixer->playInputStream(type, &track->mixChanHandle, track->stream, -1, vol, pan, false); + _mixer->pauseHandle(track->mixChanHandle, true); } } } -- cgit v1.2.3 From 4fa5583af415251bef28ff0cd308aa3befc90872 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sat, 21 Jul 2007 22:40:02 +0000 Subject: More support for Chinese COMI. Still some character conversions are missing. Most notable in difficulty selection screen where 'q' characters slip in. svn-id: r28159 --- engines/scumm/charset.cpp | 67 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 62 insertions(+), 5 deletions(-) (limited to 'engines') diff --git a/engines/scumm/charset.cpp b/engines/scumm/charset.cpp index ad4ee582ca..df609eec75 100644 --- a/engines/scumm/charset.cpp +++ b/engines/scumm/charset.cpp @@ -82,7 +82,7 @@ void ScummEngine::loadCJKFont() { case Common::ZH_TWN: if (_game.id == GID_CMI) { fontFile = "chinese.fnt"; - numChar = 1; //FIXME + numChar = 12779; } break; default: @@ -92,9 +92,25 @@ void ScummEngine::loadCJKFont() { debug(2, "Loading CJK Font"); _useCJKMode = true; _textSurfaceMultiplier = 1; // No multiplication here - fp.seek(2, SEEK_CUR); - _2byteWidth = fp.readByte(); - _2byteHeight = fp.readByte(); + + switch (_language) { + case Common::KO_KOR: + fp.seek(2, SEEK_CUR); + _2byteWidth = fp.readByte(); + _2byteHeight = fp.readByte(); + break; + case Common::JA_JPN: + _2byteWidth = 16; + _2byteHeight = 16; + break; + case Common::ZH_TWN: + _2byteWidth = 16; + _2byteHeight = 16; + // 0xFE -> 0x21. also compared with 0x0d. perhaps a newline + break; + default: + break; + } _2byteFontPtr = new byte[((_2byteWidth + 7) / 8) * _2byteHeight * numChar]; fp.read(_2byteFontPtr, ((_2byteWidth + 7) / 8) * _2byteHeight * numChar); @@ -190,7 +206,7 @@ static int SJIStoFMTChunk(int f, int s) { //converts sjis code to fmt font offse } byte *ScummEngine::get2byteCharPtr(int idx) { - switch (_language) { + switch (_language) { case Common::KO_KOR: idx = ((idx % 256) - 0xb0) * 94 + (idx / 256) - 0xa1; break; @@ -198,6 +214,43 @@ byte *ScummEngine::get2byteCharPtr(int idx) { idx = SJIStoFMTChunk((idx % 256), (idx / 256)); break; case Common::ZH_TWN: + { + int base = 0; + byte low = idx % 256; + int high = 0; + + if (low >= 0x20 && low <= 0x7e) { + base = (low + low * 2 + 81012) * 5; + } else { + if (low >= 0xa1 && low <= 0xa3) { + base = 392820; + low += 0x5f; + } else if (low >= 0xa4 && low <= 0xc6) { + base = 0; + low += 0x5c; + } else if (low >= 0xc9 && low <= 0xf9) { + base = 162030; + low += 0x37; + } else { + base = 392820; + low = 0xff; + } + + if (low != 0xff) { + high = idx / 256; + if (high >= 0x40 && high <= 0x7e) { + high -= 0x40; + } else { + high -= 0x62; + } + + base += (low * 157 + high) * 30; + } + } + + return _2byteFontPtr + base - 2; + break; + } default: idx = 0; } @@ -1724,6 +1777,10 @@ void CharsetRendererNut::printChar(int chr, bool ignoreCharsetMask) { if (_str.left > _left) _str.left = _left; + // Original keeps glyph width and character dimensions separately + if (_vm->_language == Common::ZH_TWN) + width = 17; + _left += width; if (_str.right < shadow.right) -- cgit v1.2.3 From cfb4b08efcb0c608eca19fccda15f8e24a1cb2f0 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sat, 21 Jul 2007 22:57:21 +0000 Subject: Proper height for Chinese characters, also remove obsolete hack for computing character base. svn-id: r28160 --- engines/scumm/charset.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/scumm/charset.cpp b/engines/scumm/charset.cpp index df609eec75..7d115d4c4b 100644 --- a/engines/scumm/charset.cpp +++ b/engines/scumm/charset.cpp @@ -82,7 +82,7 @@ void ScummEngine::loadCJKFont() { case Common::ZH_TWN: if (_game.id == GID_CMI) { fontFile = "chinese.fnt"; - numChar = 12779; + numChar = 13630; } break; default: @@ -105,7 +105,7 @@ void ScummEngine::loadCJKFont() { break; case Common::ZH_TWN: _2byteWidth = 16; - _2byteHeight = 16; + _2byteHeight = 15; // 0xFE -> 0x21. also compared with 0x0d. perhaps a newline break; default: @@ -244,11 +244,11 @@ byte *ScummEngine::get2byteCharPtr(int idx) { high -= 0x62; } - base += (low * 157 + high) * 30; + base += (low * 0x9d + high) * 30; } } - return _2byteFontPtr + base - 2; + return _2byteFontPtr + base; break; } default: -- cgit v1.2.3 From 425e6e278b323f95af5b223d06bec74f0db8d047 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sun, 22 Jul 2007 09:17:23 +0000 Subject: cleanup (in particular, don't call something 'soundHandle' which is not a Mixer::SoundHandle) svn-id: r28162 --- engines/scumm/imuse_digi/dimuse.cpp | 46 +++--- engines/scumm/imuse_digi/dimuse.h | 2 +- engines/scumm/imuse_digi/dimuse_script.cpp | 10 +- engines/scumm/imuse_digi/dimuse_sndmgr.cpp | 244 +++++++++++++++-------------- engines/scumm/imuse_digi/dimuse_sndmgr.h | 70 +++++---- engines/scumm/imuse_digi/dimuse_track.cpp | 31 ++-- 6 files changed, 204 insertions(+), 199 deletions(-) (limited to 'engines') diff --git a/engines/scumm/imuse_digi/dimuse.cpp b/engines/scumm/imuse_digi/dimuse.cpp index 38e918c21a..6d2e7dd217 100644 --- a/engines/scumm/imuse_digi/dimuse.cpp +++ b/engines/scumm/imuse_digi/dimuse.cpp @@ -166,10 +166,10 @@ void IMuseDigital::saveOrLoad(Serializer *ser) { continue; } - track->soundHandle = _sound->openSound(track->soundId, + track->soundDesc = _sound->openSound(track->soundId, track->soundName, track->soundType, track->volGroupId, -1); - if (!track->soundHandle) { + if (!track->soundDesc) { warning("IMuseDigital::saveOrLoad: Can't open sound so will not be resumed, propably on diffrent CD"); track->streamSou = NULL; track->stream = NULL; @@ -180,14 +180,14 @@ void IMuseDigital::saveOrLoad(Serializer *ser) { if (track->sndDataExtComp) { track->regionOffset = 0; } - track->sndDataExtComp = _sound->isSndDataExtComp(track->soundHandle); + track->sndDataExtComp = _sound->isSndDataExtComp(track->soundDesc); if (track->sndDataExtComp) { track->regionOffset = 0; } - track->dataOffset = _sound->getRegionOffset(track->soundHandle, track->curRegion); - int bits = _sound->getBits(track->soundHandle); - int channels = _sound->getChannels(track->soundHandle); - int freq = _sound->getFreq(track->soundHandle); + track->dataOffset = _sound->getRegionOffset(track->soundDesc, track->curRegion); + int bits = _sound->getBits(track->soundDesc); + int channels = _sound->getChannels(track->soundDesc); + int freq = _sound->getFreq(track->soundDesc); track->feedSize = freq * channels; track->mixerFlags = 0; if (channels == 2) @@ -285,8 +285,8 @@ void IMuseDigital::callback() { continue; } - int bits = _sound->getBits(track->soundHandle); - int channels = _sound->getChannels(track->soundHandle); + int bits = _sound->getBits(track->soundDesc); + int channels = _sound->getChannels(track->soundDesc); int32 feedSize = track->feedSize / _callbackFps; @@ -317,12 +317,12 @@ void IMuseDigital::callback() { track->dataMod12Bit = feedSize - tmpLength12Bits; int32 tmpOffset = (track->regionOffset * 3) / 4; - int tmpFeedSize = _sound->getDataFromRegion(track->soundHandle, track->curRegion, &tmpPtr, tmpOffset, tmpFeedSize12Bits); + int tmpFeedSize = _sound->getDataFromRegion(track->soundDesc, track->curRegion, &tmpPtr, tmpOffset, tmpFeedSize12Bits); curFeedSize = BundleCodecs::decode12BitsSample(tmpPtr, &tmpSndBufferPtr, tmpFeedSize); free(tmpPtr); } else if (bits == 16) { - curFeedSize = _sound->getDataFromRegion(track->soundHandle, track->curRegion, &tmpSndBufferPtr, track->regionOffset, feedSize); + curFeedSize = _sound->getDataFromRegion(track->soundDesc, track->curRegion, &tmpSndBufferPtr, track->regionOffset, feedSize); if (channels == 1) { curFeedSize &= ~1; } @@ -330,7 +330,7 @@ void IMuseDigital::callback() { curFeedSize &= ~3; } } else if (bits == 8) { - curFeedSize = _sound->getDataFromRegion(track->soundHandle, track->curRegion, &tmpSndBufferPtr, track->regionOffset, feedSize); + curFeedSize = _sound->getDataFromRegion(track->soundDesc, track->curRegion, &tmpSndBufferPtr, track->regionOffset, feedSize); if (channels == 2) { curFeedSize &= ~1; } @@ -347,7 +347,7 @@ void IMuseDigital::callback() { } else delete[] tmpSndBufferPtr; - if (_sound->isEndOfRegion(track->soundHandle, track->curRegion)) { + if (_sound->isEndOfRegion(track->soundDesc, track->curRegion)) { switchToNextRegion(track); if (track->toBeRemoved) break; @@ -380,7 +380,7 @@ void IMuseDigital::switchToNextRegion(Track *track) { return; } - int num_regions = _sound->getNumRegions(track->soundHandle); + int num_regions = _sound->getNumRegions(track->soundDesc); if (++track->curRegion == num_regions) { track->toBeRemoved = true; @@ -388,22 +388,22 @@ void IMuseDigital::switchToNextRegion(Track *track) { return; } - ImuseDigiSndMgr::soundStruct *soundHandle = track->soundHandle; - int jumpId = _sound->getJumpIdByRegionAndHookId(soundHandle, track->curRegion, track->curHookId); + ImuseDigiSndMgr::SoundDesc *soundDesc = track->soundDesc; + int jumpId = _sound->getJumpIdByRegionAndHookId(soundDesc, track->curRegion, track->curHookId); if (jumpId == -1) - jumpId = _sound->getJumpIdByRegionAndHookId(soundHandle, track->curRegion, 0); + jumpId = _sound->getJumpIdByRegionAndHookId(soundDesc, track->curRegion, 0); if (jumpId != -1) { - int region = _sound->getRegionIdByJumpId(soundHandle, jumpId); + int region = _sound->getRegionIdByJumpId(soundDesc, jumpId); assert(region != -1); - int sampleHookId = _sound->getJumpHookId(soundHandle, jumpId); + int sampleHookId = _sound->getJumpHookId(soundDesc, jumpId); assert(sampleHookId != -1); - int fadeDelay = (60 * _sound->getJumpFade(soundHandle, jumpId)) / 1000; + int fadeDelay = (60 * _sound->getJumpFade(soundDesc, jumpId)) / 1000; if (sampleHookId != 0) { if (track->curHookId == sampleHookId) { if (fadeDelay != 0) { Track *fadeTrack = cloneToFadeOutTrack(track, fadeDelay); if (fadeTrack) { - fadeTrack->dataOffset = _sound->getRegionOffset(fadeTrack->soundHandle, fadeTrack->curRegion); + fadeTrack->dataOffset = _sound->getRegionOffset(fadeTrack->soundDesc, fadeTrack->curRegion); fadeTrack->regionOffset = 0; debug(5, "switchToNextRegion-sound(%d) select region %d, curHookId: %d", fadeTrack->soundId, fadeTrack->curRegion, fadeTrack->curHookId); fadeTrack->curHookId = 0; @@ -417,7 +417,7 @@ void IMuseDigital::switchToNextRegion(Track *track) { if (fadeDelay != 0) { Track *fadeTrack = cloneToFadeOutTrack(track, fadeDelay); if (fadeTrack) { - fadeTrack->dataOffset = _sound->getRegionOffset(fadeTrack->soundHandle, fadeTrack->curRegion); + fadeTrack->dataOffset = _sound->getRegionOffset(fadeTrack->soundDesc, fadeTrack->curRegion); fadeTrack->regionOffset = 0; debug(5, "switchToNextRegion-sound(%d) select region %d, curHookId: %d", fadeTrack->soundId, fadeTrack->curRegion, fadeTrack->curHookId); } @@ -428,7 +428,7 @@ void IMuseDigital::switchToNextRegion(Track *track) { } debug(5, "switchToNextRegion-sound(%d) select region %d, curHookId: %d", track->soundId, track->curRegion, track->curHookId); - track->dataOffset = _sound->getRegionOffset(soundHandle, track->curRegion); + track->dataOffset = _sound->getRegionOffset(soundDesc, track->curRegion); track->regionOffset = 0; } diff --git a/engines/scumm/imuse_digi/dimuse.h b/engines/scumm/imuse_digi/dimuse.h index 1b088298df..dca9baac60 100644 --- a/engines/scumm/imuse_digi/dimuse.h +++ b/engines/scumm/imuse_digi/dimuse.h @@ -98,7 +98,7 @@ private: int32 dataMod12Bit; // value used between all callback to align 12 bit source of data int32 mixerFlags; // flags for sound mixer's channel (kFlagStereo, kFlag16Bits, kFlagReverseStereo, kFlagUnsigned, kFlagLittleEndian) - ImuseDigiSndMgr::soundStruct *soundHandle; // sound handle used by iMuse sound manager + ImuseDigiSndMgr::SoundDesc *soundDesc; // sound handle used by iMuse sound manager Audio::SoundHandle mixChanHandle; // sound mixer's channel handle Audio::AppendableAudioStream *stream; // sound mixer's audio stream handle for *.la1 and *.bun Audio::AudioStream *streamSou; // sound mixer's audio stream handle for *.sou diff --git a/engines/scumm/imuse_digi/dimuse_script.cpp b/engines/scumm/imuse_digi/dimuse_script.cpp index 186d04483e..ddc0cd5107 100644 --- a/engines/scumm/imuse_digi/dimuse_script.cpp +++ b/engines/scumm/imuse_digi/dimuse_script.cpp @@ -179,8 +179,8 @@ void IMuseDigital::flushTracks() { _mixer->stopHandle(track->mixChanHandle); delete track->stream; track->stream = NULL; - _sound->closeSound(track->soundHandle); - track->soundHandle = NULL; + _sound->closeSound(track->soundDesc); + track->soundDesc = NULL; track->used = false; } } else if (track->streamSou) { @@ -245,7 +245,7 @@ void IMuseDigital::getLipSync(int soundId, int syncId, int32 msPos, int32 &width for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) { Track *track = _track[l]; if ((track->soundId == soundId) && track->used && !track->toBeRemoved) { - _sound->getSyncSizeAndPtrById(track->soundHandle, syncId, sync_size, &sync_ptr); + _sound->getSyncSizeAndPtrById(track->soundDesc, syncId, sync_size, &sync_ptr); if ((sync_size != 0) && (sync_ptr != NULL)) { sync_size /= 4; while (sync_size--) { @@ -396,8 +396,8 @@ void IMuseDigital::stopAllSounds() { _mixer->stopHandle(track->mixChanHandle); delete track->stream; track->stream = NULL; - _sound->closeSound(track->soundHandle); - track->soundHandle = NULL; + _sound->closeSound(track->soundDesc); + track->soundDesc = NULL; } else if (track->streamSou) { _mixer->stopHandle(track->mixChanHandle); delete track->streamSou; diff --git a/engines/scumm/imuse_digi/dimuse_sndmgr.cpp b/engines/scumm/imuse_digi/dimuse_sndmgr.cpp index 8340af3eb5..3f44873e46 100644 --- a/engines/scumm/imuse_digi/dimuse_sndmgr.cpp +++ b/engines/scumm/imuse_digi/dimuse_sndmgr.cpp @@ -40,7 +40,7 @@ namespace Scumm { ImuseDigiSndMgr::ImuseDigiSndMgr(ScummEngine *scumm) { for (int l = 0; l < MAX_IMUSE_SOUNDS; l++) { - memset(&_sounds[l], 0, sizeof(soundStruct)); + memset(&_sounds[l], 0, sizeof(SoundDesc)); } _vm = scumm; _disk = 0; @@ -88,7 +88,7 @@ void ImuseDigiSndMgr::countElements(byte *ptr, int &numRegions, int &numJumps, i } while (tag != MKID_BE('DATA')); } -void ImuseDigiSndMgr::prepareSoundFromRMAP(Common::File *file, soundStruct *sound, int32 offset, int32 size) { +void ImuseDigiSndMgr::prepareSoundFromRMAP(Common::File *file, SoundDesc *sound, int32 offset, int32 size) { int l; file->seek(offset, SEEK_SET); @@ -104,11 +104,11 @@ void ImuseDigiSndMgr::prepareSoundFromRMAP(Common::File *file, soundStruct *soun sound->numRegions = file->readUint32BE(); sound->numJumps = file->readUint32BE(); sound->numSyncs = file->readUint32BE(); - sound->region = (_region *)malloc(sizeof(_region) * sound->numRegions); + sound->region = new Region[sound->numRegions]; assert(sound->region); - sound->jump = (_jump *)malloc(sizeof(_jump) * sound->numJumps); + sound->jump = new Jump[sound->numJumps]; assert(sound->jump); - sound->sync = (_sync *)malloc(sizeof(_sync) * sound->numSyncs); + sound->sync = new Sync[sound->numSyncs]; assert(sound->sync); for (l = 0; l < sound->numRegions; l++) { sound->region[l].offset = file->readUint32BE(); @@ -127,7 +127,7 @@ void ImuseDigiSndMgr::prepareSoundFromRMAP(Common::File *file, soundStruct *soun } } -void ImuseDigiSndMgr::prepareSound(byte *ptr, soundStruct *sound) { +void ImuseDigiSndMgr::prepareSound(byte *ptr, SoundDesc *sound) { if (READ_BE_UINT32(ptr) == MKID_BE('Crea')) { bool quit = false; int len; @@ -135,10 +135,16 @@ void ImuseDigiSndMgr::prepareSound(byte *ptr, soundStruct *sound) { int32 offset = READ_LE_UINT16(ptr + 20); int16 code = READ_LE_UINT16(ptr + 24); - sound->region = (_region *)malloc(sizeof(_region) * 70); + sound->numRegions = 70; + sound->region = new Region[70]; assert(sound->region); - sound->jump = (_jump *)malloc(sizeof(_jump)); + + sound->numJumps = 1; + sound->jump = new Jump[1]; assert(sound->jump); + + sound->numSyncs = 0; + sound->resPtr = ptr; sound->bits = 8; sound->channels = 1; @@ -205,11 +211,11 @@ void ImuseDigiSndMgr::prepareSound(byte *ptr, soundStruct *sound) { sound->numJumps = 0; sound->numSyncs = 0; countElements(ptr, sound->numRegions, sound->numJumps, sound->numSyncs); - sound->region = (_region *)malloc(sizeof(_region) * sound->numRegions); + sound->region = new Region[sound->numRegions]; assert(sound->region); - sound->jump = (_jump *)malloc(sizeof(_jump) * sound->numJumps); + sound->jump = new Jump[sound->numJumps]; assert(sound->jump); - sound->sync = (_sync *)malloc(sizeof(_sync) * sound->numSyncs); + sound->sync = new Sync[sound->numSyncs]; assert(sound->sync); do { @@ -260,7 +266,7 @@ void ImuseDigiSndMgr::prepareSound(byte *ptr, soundStruct *sound) { } } -ImuseDigiSndMgr::soundStruct *ImuseDigiSndMgr::allocSlot() { +ImuseDigiSndMgr::SoundDesc *ImuseDigiSndMgr::allocSlot() { for (int l = 0; l < MAX_IMUSE_SOUNDS; l++) { if (!_sounds[l].inUse) { _sounds[l].inUse = true; @@ -271,7 +277,7 @@ ImuseDigiSndMgr::soundStruct *ImuseDigiSndMgr::allocSlot() { return NULL; } -bool ImuseDigiSndMgr::openMusicBundle(soundStruct *sound, int disk) { +bool ImuseDigiSndMgr::openMusicBundle(SoundDesc *sound, int disk) { bool result = false; sound->bundle = new BundleMgr(_cacheBundleDir); @@ -306,7 +312,7 @@ bool ImuseDigiSndMgr::openMusicBundle(soundStruct *sound, int disk) { return result; } -bool ImuseDigiSndMgr::openVoiceBundle(soundStruct *sound, int disk) { +bool ImuseDigiSndMgr::openVoiceBundle(SoundDesc *sound, int disk) { bool result = false; sound->bundle = new BundleMgr(_cacheBundleDir); @@ -341,11 +347,11 @@ bool ImuseDigiSndMgr::openVoiceBundle(soundStruct *sound, int disk) { return result; } -ImuseDigiSndMgr::soundStruct *ImuseDigiSndMgr::openSound(int32 soundId, const char *soundName, int soundType, int volGroupId, int disk) { +ImuseDigiSndMgr::SoundDesc *ImuseDigiSndMgr::openSound(int32 soundId, const char *soundName, int soundType, int volGroupId, int disk) { assert(soundId >= 0); assert(soundType); - soundStruct *sound = allocSlot(); + SoundDesc *sound = allocSlot(); if (!sound) { error("ImuseDigiSndMgr::openSound() can't alloc free sound slot"); } @@ -423,99 +429,97 @@ ImuseDigiSndMgr::soundStruct *ImuseDigiSndMgr::openSound(int32 soundId, const ch return sound; } -void ImuseDigiSndMgr::closeSound(soundStruct *soundHandle) { - assert(checkForProperHandle(soundHandle)); +void ImuseDigiSndMgr::closeSound(SoundDesc *soundDesc) { + assert(checkForProperHandle(soundDesc)); - if (soundHandle->resPtr) { + if (soundDesc->resPtr) { bool found = false; for (int l = 0; l < MAX_IMUSE_SOUNDS; l++) { - if ((_sounds[l].soundId == soundHandle->soundId) && (&_sounds[l] != soundHandle)) + if ((_sounds[l].soundId == soundDesc->soundId) && (&_sounds[l] != soundDesc)) found = true; } if (!found) - _vm->_res->unlock(rtSound, soundHandle->soundId); + _vm->_res->unlock(rtSound, soundDesc->soundId); } - if (soundHandle->compressedStream) - delete soundHandle->compressedStream; - - delete soundHandle->bundle; + delete soundDesc->compressedStream; + delete soundDesc->bundle; - for (int r = 0; r < soundHandle->numSyncs; r++) - free(soundHandle->sync[r].ptr); - free(soundHandle->region); - free(soundHandle->jump); - free(soundHandle->sync); - memset(soundHandle, 0, sizeof(soundStruct)); + for (int r = 0; r < soundDesc->numSyncs; r++) + free(soundDesc->sync[r].ptr); + delete[] soundDesc->region; + delete[] soundDesc->jump; + delete[] soundDesc->sync; + memset(soundDesc, 0, sizeof(SoundDesc)); } -ImuseDigiSndMgr::soundStruct *ImuseDigiSndMgr::cloneSound(soundStruct *soundHandle) { - assert(checkForProperHandle(soundHandle)); +ImuseDigiSndMgr::SoundDesc *ImuseDigiSndMgr::cloneSound(SoundDesc *soundDesc) { + assert(checkForProperHandle(soundDesc)); - return openSound(soundHandle->soundId, soundHandle->name, soundHandle->type, soundHandle->volGroupId, soundHandle->disk); + return openSound(soundDesc->soundId, soundDesc->name, soundDesc->type, soundDesc->volGroupId, soundDesc->disk); } -bool ImuseDigiSndMgr::checkForProperHandle(soundStruct *soundHandle) { - if (!soundHandle) +bool ImuseDigiSndMgr::checkForProperHandle(SoundDesc *soundDesc) { + if (!soundDesc) return false; for (int l = 0; l < MAX_IMUSE_SOUNDS; l++) { - if (soundHandle == &_sounds[l]) + if (soundDesc == &_sounds[l]) return true; } return false; } -bool ImuseDigiSndMgr::isSndDataExtComp(soundStruct *soundHandle) { - assert(checkForProperHandle(soundHandle)); - return soundHandle->compressed; +bool ImuseDigiSndMgr::isSndDataExtComp(SoundDesc *soundDesc) { + assert(checkForProperHandle(soundDesc)); + return soundDesc->compressed; } -int ImuseDigiSndMgr::getFreq(soundStruct *soundHandle) { - assert(checkForProperHandle(soundHandle)); - return soundHandle->freq; +int ImuseDigiSndMgr::getFreq(SoundDesc *soundDesc) { + assert(checkForProperHandle(soundDesc)); + return soundDesc->freq; } -int ImuseDigiSndMgr::getBits(soundStruct *soundHandle) { - assert(checkForProperHandle(soundHandle)); - return soundHandle->bits; +int ImuseDigiSndMgr::getBits(SoundDesc *soundDesc) { + assert(checkForProperHandle(soundDesc)); + return soundDesc->bits; } -int ImuseDigiSndMgr::getChannels(soundStruct *soundHandle) { - assert(checkForProperHandle(soundHandle)); - return soundHandle->channels; +int ImuseDigiSndMgr::getChannels(SoundDesc *soundDesc) { + assert(checkForProperHandle(soundDesc)); + return soundDesc->channels; } -bool ImuseDigiSndMgr::isEndOfRegion(soundStruct *soundHandle, int region) { - assert(checkForProperHandle(soundHandle)); - assert(region >= 0 && region < soundHandle->numRegions); - return soundHandle->endFlag; +bool ImuseDigiSndMgr::isEndOfRegion(SoundDesc *soundDesc, int region) { + assert(checkForProperHandle(soundDesc)); + assert(region >= 0 && region < soundDesc->numRegions); + return soundDesc->endFlag; } -int ImuseDigiSndMgr::getNumRegions(soundStruct *soundHandle) { - assert(checkForProperHandle(soundHandle)); - return soundHandle->numRegions; +int ImuseDigiSndMgr::getNumRegions(SoundDesc *soundDesc) { + assert(checkForProperHandle(soundDesc)); + return soundDesc->numRegions; } -int ImuseDigiSndMgr::getNumJumps(soundStruct *soundHandle) { - assert(checkForProperHandle(soundHandle)); - return soundHandle->numJumps; +int ImuseDigiSndMgr::getNumJumps(SoundDesc *soundDesc) { + assert(checkForProperHandle(soundDesc)); + return soundDesc->numJumps; } -int ImuseDigiSndMgr::getRegionOffset(soundStruct *soundHandle, int region) { +int ImuseDigiSndMgr::getRegionOffset(SoundDesc *soundDesc, int region) { debug(5, "getRegionOffset() region:%d", region); - assert(checkForProperHandle(soundHandle)); - assert(region >= 0 && region < soundHandle->numRegions); - return soundHandle->region[region].offset; + assert(checkForProperHandle(soundDesc)); + assert(region >= 0 && region < soundDesc->numRegions); + return soundDesc->region[region].offset; } -int ImuseDigiSndMgr::getJumpIdByRegionAndHookId(soundStruct *soundHandle, int region, int hookId) { +int ImuseDigiSndMgr::getJumpIdByRegionAndHookId(SoundDesc *soundDesc, int region, int hookId) { debug(5, "getJumpIdByRegionAndHookId() region:%d, hookId:%d", region, hookId); - assert(checkForProperHandle(soundHandle)); - assert(region >= 0 && region < soundHandle->numRegions); - int32 offset = soundHandle->region[region].offset; - for (int l = 0; l < soundHandle->numJumps; l++) { - if (offset == soundHandle->jump[l].offset) { - if (soundHandle->jump[l].hookId == hookId) + assert(checkForProperHandle(soundDesc)); + assert(region >= 0 && region < soundDesc->numRegions); + int32 offset = soundDesc->region[region].offset; + for (int l = 0; l < soundDesc->numJumps; l++) { + if (offset == soundDesc->jump[l].offset) { + if (soundDesc->jump[l].hookId == hookId) return l; } } @@ -523,25 +527,25 @@ int ImuseDigiSndMgr::getJumpIdByRegionAndHookId(soundStruct *soundHandle, int re return -1; } -void ImuseDigiSndMgr::getSyncSizeAndPtrById(soundStruct *soundHandle, int number, int32 &sync_size, byte **sync_ptr) { - assert(checkForProperHandle(soundHandle)); +void ImuseDigiSndMgr::getSyncSizeAndPtrById(SoundDesc *soundDesc, int number, int32 &sync_size, byte **sync_ptr) { + assert(checkForProperHandle(soundDesc)); assert(number >= 0); - if (number < soundHandle->numSyncs) { - sync_size = soundHandle->sync[number].size; - *sync_ptr = soundHandle->sync[number].ptr; + if (number < soundDesc->numSyncs) { + sync_size = soundDesc->sync[number].size; + *sync_ptr = soundDesc->sync[number].ptr; } else { sync_size = 0; *sync_ptr = NULL; } } -int ImuseDigiSndMgr::getRegionIdByJumpId(soundStruct *soundHandle, int jumpId) { +int ImuseDigiSndMgr::getRegionIdByJumpId(SoundDesc *soundDesc, int jumpId) { debug(5, "getRegionIdByJumpId() jumpId:%d", jumpId); - assert(checkForProperHandle(soundHandle)); - assert(jumpId >= 0 && jumpId < soundHandle->numJumps); - int32 dest = soundHandle->jump[jumpId].dest; - for (int l = 0; l < soundHandle->numRegions; l++) { - if (dest == soundHandle->region[l].offset) { + assert(checkForProperHandle(soundDesc)); + assert(jumpId >= 0 && jumpId < soundDesc->numJumps); + int32 dest = soundDesc->jump[jumpId].dest; + for (int l = 0; l < soundDesc->numRegions; l++) { + if (dest == soundDesc->region[l].offset) { return l; } } @@ -549,64 +553,64 @@ int ImuseDigiSndMgr::getRegionIdByJumpId(soundStruct *soundHandle, int jumpId) { return -1; } -int ImuseDigiSndMgr::getJumpHookId(soundStruct *soundHandle, int number) { +int ImuseDigiSndMgr::getJumpHookId(SoundDesc *soundDesc, int number) { debug(5, "getJumpHookId() number:%d", number); - assert(checkForProperHandle(soundHandle)); - assert(number >= 0 && number < soundHandle->numJumps); - return soundHandle->jump[number].hookId; + assert(checkForProperHandle(soundDesc)); + assert(number >= 0 && number < soundDesc->numJumps); + return soundDesc->jump[number].hookId; } -int ImuseDigiSndMgr::getJumpFade(soundStruct *soundHandle, int number) { +int ImuseDigiSndMgr::getJumpFade(SoundDesc *soundDesc, int number) { debug(5, "getJumpFade() number:%d", number); - assert(checkForProperHandle(soundHandle)); - assert(number >= 0 && number < soundHandle->numJumps); - return soundHandle->jump[number].fadeDelay; + assert(checkForProperHandle(soundDesc)); + assert(number >= 0 && number < soundDesc->numJumps); + return soundDesc->jump[number].fadeDelay; } -int32 ImuseDigiSndMgr::getDataFromRegion(soundStruct *soundHandle, int region, byte **buf, int32 offset, int32 size) { - debug(5, "getDataFromRegion() region:%d, offset:%d, size:%d, numRegions:%d", region, offset, size, soundHandle->numRegions); - assert(checkForProperHandle(soundHandle)); +int32 ImuseDigiSndMgr::getDataFromRegion(SoundDesc *soundDesc, int region, byte **buf, int32 offset, int32 size) { + debug(5, "getDataFromRegion() region:%d, offset:%d, size:%d, numRegions:%d", region, offset, size, soundDesc->numRegions); + assert(checkForProperHandle(soundDesc)); assert(buf && offset >= 0 && size >= 0); - assert(region >= 0 && region < soundHandle->numRegions); + assert(region >= 0 && region < soundDesc->numRegions); - int32 region_offset = soundHandle->region[region].offset; - int32 region_length = soundHandle->region[region].length; - int32 offset_data = soundHandle->offsetData; + int32 region_offset = soundDesc->region[region].offset; + int32 region_length = soundDesc->region[region].length; + int32 offset_data = soundDesc->offsetData; int32 start = region_offset - offset_data; if (offset + size + offset_data > region_length) { size = region_length - offset; - soundHandle->endFlag = true; + soundDesc->endFlag = true; } else { - soundHandle->endFlag = false; + soundDesc->endFlag = false; } - int header_size = soundHandle->offsetData; + int header_size = soundDesc->offsetData; bool header_outside = ((_vm->_game.id == GID_CMI) && !(_vm->_game.features & GF_DEMO)); - if ((soundHandle->bundle) && (!soundHandle->compressed)) { - size = soundHandle->bundle->decompressSampleByCurIndex(start + offset, size, buf, header_size, header_outside); - } else if (soundHandle->resPtr) { + if ((soundDesc->bundle) && (!soundDesc->compressed)) { + size = soundDesc->bundle->decompressSampleByCurIndex(start + offset, size, buf, header_size, header_outside); + } else if (soundDesc->resPtr) { *buf = new byte[size]; assert(*buf); - memcpy(*buf, soundHandle->resPtr + start + offset + header_size, size); - } else if ((soundHandle->bundle) && (soundHandle->compressed)) { + memcpy(*buf, soundDesc->resPtr + start + offset + header_size, size); + } else if ((soundDesc->bundle) && (soundDesc->compressed)) { *buf = new byte[size]; assert(*buf); char fileName[24]; - sprintf(fileName, "%s_reg%03d", soundHandle->name, region); - if (scumm_stricmp(fileName, soundHandle->lastFileName) != 0) { + sprintf(fileName, "%s_reg%03d", soundDesc->name, region); + if (scumm_stricmp(fileName, soundDesc->lastFileName) != 0) { int32 offs = 0, len = 0; Common::File *cmpFile; bool oggMode = false; - sprintf(fileName, "%s_reg%03d.mp3", soundHandle->name, region); - cmpFile = soundHandle->bundle->getFile(fileName, offs, len); + sprintf(fileName, "%s_reg%03d.mp3", soundDesc->name, region); + cmpFile = soundDesc->bundle->getFile(fileName, offs, len); #ifndef USE_MAD if (len) error("Mad library compiled support needed!"); #endif if (!len) { - sprintf(fileName, "%s_reg%03d.ogg", soundHandle->name, region); - cmpFile = soundHandle->bundle->getFile(fileName, offs, len); + sprintf(fileName, "%s_reg%03d.ogg", soundDesc->name, region); + cmpFile = soundDesc->bundle->getFile(fileName, offs, len); #ifndef USE_VORBIS if (len) error("Vorbis library compiled support needed!"); @@ -614,26 +618,26 @@ int32 ImuseDigiSndMgr::getDataFromRegion(soundStruct *soundHandle, int region, b assert(len); oggMode = true; } - if (!soundHandle->compressedStream) { + if (!soundDesc->compressedStream) { Common::MemoryReadStream *tmp = cmpFile->readStream(len); assert(tmp); #ifdef USE_VORBIS if (oggMode) - soundHandle->compressedStream = Audio::makeVorbisStream(tmp, true); + soundDesc->compressedStream = Audio::makeVorbisStream(tmp, true); #endif #ifdef USE_MAD if (!oggMode) - soundHandle->compressedStream = Audio::makeMP3Stream(tmp, true); + soundDesc->compressedStream = Audio::makeMP3Stream(tmp, true); #endif - assert(soundHandle->compressedStream); + assert(soundDesc->compressedStream); } - strcpy(soundHandle->lastFileName, fileName); + strcpy(soundDesc->lastFileName, fileName); } - size = soundHandle->compressedStream->readBuffer((int16 *)*buf, size / 2) * 2; - if (soundHandle->compressedStream->endOfData()) { - delete soundHandle->compressedStream; - soundHandle->compressedStream = NULL; - soundHandle->lastFileName[0] = 0; + size = soundDesc->compressedStream->readBuffer((int16 *)*buf, size / 2) * 2; + if (soundDesc->compressedStream->endOfData()) { + delete soundDesc->compressedStream; + soundDesc->compressedStream = NULL; + soundDesc->lastFileName[0] = 0; } } diff --git a/engines/scumm/imuse_digi/dimuse_sndmgr.h b/engines/scumm/imuse_digi/dimuse_sndmgr.h index 5d2f8c88ba..e4e2e795a2 100644 --- a/engines/scumm/imuse_digi/dimuse_sndmgr.h +++ b/engines/scumm/imuse_digi/dimuse_sndmgr.h @@ -48,35 +48,39 @@ public: #define IMUSE_VOLGRP_MUSIC 3 private: - struct _region { + struct Region { int32 offset; // offset of region int32 length; // lenght of region }; - struct _jump { + struct Jump { int32 offset; // jump offset position int32 dest; // jump to dest position byte hookId; // id of hook int16 fadeDelay; // fade delay in ms }; - struct _sync { + struct Sync { int32 size; // size of sync byte *ptr; // pointer to sync }; public: - struct soundStruct { + struct SoundDesc { uint16 freq; // frequency byte channels; // stereo or mono byte bits; // 8, 12, 16 + int numJumps; // number of Jumps + Region *region; + int numRegions; // number of Regions + Jump *jump; + int numSyncs; // number of Syncs - _region *region; - _jump *jump; - _sync *sync; + Sync *sync; + bool endFlag; bool inUse; byte *allData; @@ -95,19 +99,19 @@ public: private: - soundStruct _sounds[MAX_IMUSE_SOUNDS]; + SoundDesc _sounds[MAX_IMUSE_SOUNDS]; - bool checkForProperHandle(soundStruct *soundHandle); - soundStruct *allocSlot(); - void prepareSound(byte *ptr, soundStruct *sound); - void prepareSoundFromRMAP(Common::File *file, soundStruct *sound, int32 offset, int32 size); + bool checkForProperHandle(SoundDesc *soundDesc); + SoundDesc *allocSlot(); + void prepareSound(byte *ptr, SoundDesc *sound); + void prepareSoundFromRMAP(Common::File *file, SoundDesc *sound, int32 offset, int32 size); ScummEngine *_vm; byte _disk; BundleDirCache *_cacheBundleDir; - bool openMusicBundle(soundStruct *sound, int disk); - bool openVoiceBundle(soundStruct *sound, int disk); + bool openMusicBundle(SoundDesc *sound, int disk); + bool openVoiceBundle(SoundDesc *sound, int disk); void countElements(byte *ptr, int &numRegions, int &numJumps, int &numSyncs); @@ -116,25 +120,25 @@ public: ImuseDigiSndMgr(ScummEngine *scumm); ~ImuseDigiSndMgr(); - soundStruct *openSound(int32 soundId, const char *soundName, int soundType, int volGroupId, int disk); - void closeSound(soundStruct *soundHandle); - soundStruct *cloneSound(soundStruct *soundHandle); - - bool isSndDataExtComp(soundStruct *soundHandle); - int getFreq(soundStruct *soundHandle); - int getBits(soundStruct *soundHandle); - int getChannels(soundStruct *soundHandle); - bool isEndOfRegion(soundStruct *soundHandle, int region); - int getNumRegions(soundStruct *soundHandle); - int getNumJumps(soundStruct *soundHandle); - int getRegionOffset(soundStruct *soundHandle, int region); - int getJumpIdByRegionAndHookId(soundStruct *soundHandle, int region, int hookId); - int getRegionIdByJumpId(soundStruct *soundHandle, int jumpId); - int getJumpHookId(soundStruct *soundHandle, int number); - int getJumpFade(soundStruct *soundHandle, int number); - void getSyncSizeAndPtrById(soundStruct *soundHandle, int number, int32 &sync_size, byte **sync_ptr); - - int32 getDataFromRegion(soundStruct *soundHandle, int region, byte **buf, int32 offset, int32 size); + SoundDesc *openSound(int32 soundId, const char *soundName, int soundType, int volGroupId, int disk); + void closeSound(SoundDesc *soundDesc); + SoundDesc *cloneSound(SoundDesc *soundDesc); + + bool isSndDataExtComp(SoundDesc *soundDesc); + int getFreq(SoundDesc *soundDesc); + int getBits(SoundDesc *soundDesc); + int getChannels(SoundDesc *soundDesc); + bool isEndOfRegion(SoundDesc *soundDesc, int region); + int getNumRegions(SoundDesc *soundDesc); + int getNumJumps(SoundDesc *soundDesc); + int getRegionOffset(SoundDesc *soundDesc, int region); + int getJumpIdByRegionAndHookId(SoundDesc *soundDesc, int region, int hookId); + int getRegionIdByJumpId(SoundDesc *soundDesc, int jumpId); + int getJumpHookId(SoundDesc *soundDesc, int number); + int getJumpFade(SoundDesc *soundDesc, int number); + void getSyncSizeAndPtrById(SoundDesc *soundDesc, int number, int32 &sync_size, byte **sync_ptr); + + int32 getDataFromRegion(SoundDesc *soundDesc, int region, byte **buf, int32 offset, int32 size); }; } // End of namespace Scumm diff --git a/engines/scumm/imuse_digi/dimuse_track.cpp b/engines/scumm/imuse_digi/dimuse_track.cpp index 75dde5e60f..987e1bc3c9 100644 --- a/engines/scumm/imuse_digi/dimuse_track.cpp +++ b/engines/scumm/imuse_digi/dimuse_track.cpp @@ -117,20 +117,20 @@ void IMuseDigital::startSound(int soundId, const char *soundName, int soundType, track->feedSize = 0; track->souStreamUsed = true; track->soundName[0] = 0; - track->soundHandle = NULL; + track->soundDesc = NULL; } else { track->souStreamUsed = false; strcpy(track->soundName, soundName); - track->soundHandle = _sound->openSound(soundId, soundName, soundType, volGroupId, -1); + track->soundDesc = _sound->openSound(soundId, soundName, soundType, volGroupId, -1); - if (track->soundHandle == NULL) + if (track->soundDesc == NULL) return; - track->sndDataExtComp = _sound->isSndDataExtComp(track->soundHandle); + track->sndDataExtComp = _sound->isSndDataExtComp(track->soundDesc); - bits = _sound->getBits(track->soundHandle); - channels = _sound->getChannels(track->soundHandle); - freq = _sound->getFreq(track->soundHandle); + bits = _sound->getBits(track->soundDesc); + channels = _sound->getChannels(track->soundDesc); + freq = _sound->getFreq(track->soundDesc); if ((soundId == kTalkSoundID) && (soundType == IMUSE_BUNDLE)) { if (_vm->_actorToPrintStrFor != 0xFF && _vm->_actorToPrintStrFor != 0) { @@ -325,15 +325,12 @@ IMuseDigital::Track *IMuseDigital::cloneToFadeOutTrack(const Track *track, int f // Clone the settings of the given track memcpy(fadeTrack, track, sizeof(Track)); - // Clone the soundhandle - // FIXME: Shouldn't we check here whether track->soundHandle is NULL, resp. whether stream2 - // is being used (as in, we are using compressed data)... - // - // -- aquadran -- nope :) this is called only for bundle files and sound data in *.la1 - // from switchToNextRegion and fadeOutMusic func. - // stream2 is used only for sou VOICE type sound data (FT) -- - fadeTrack->soundHandle = _sound->cloneSound(track->soundHandle); - assert(fadeTrack->soundHandle); + // Clone the sound. + // According to aquadran, this is only called for bundle files and sound + // data in *.la1 from switchToNextRegion and fadeOutMusic func. Henc we + // know that track->soundDesc != NULL. + fadeTrack->soundDesc = _sound->cloneSound(track->soundDesc); + assert(fadeTrack->soundDesc); // Set the volume fading parameters to indicate a fade out fadeTrack->volFadeDelay = fadeDelay; @@ -357,7 +354,7 @@ IMuseDigital::Track *IMuseDigital::cloneToFadeOutTrack(const Track *track, int f type = Audio::Mixer::kPlainSoundType; break; } - fadeTrack->stream = Audio::makeAppendableAudioStream(_sound->getFreq(fadeTrack->soundHandle), makeMixerFlags(fadeTrack->mixerFlags)); + fadeTrack->stream = Audio::makeAppendableAudioStream(_sound->getFreq(fadeTrack->soundDesc), makeMixerFlags(fadeTrack->mixerFlags)); _mixer->playInputStream(type, &fadeTrack->mixChanHandle, fadeTrack->stream, -1, fadeTrack->vol / 1000, fadeTrack->pan, false); fadeTrack->mixerStreamRunning = true; -- cgit v1.2.3 From 8c21abc990c3130b2e76bb33b8642a74ce145574 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 22 Jul 2007 21:01:31 +0000 Subject: Fix Chinese character widths. svn-id: r28166 --- engines/scumm/charset.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/scumm/charset.cpp b/engines/scumm/charset.cpp index 7d115d4c4b..3c910bd239 100644 --- a/engines/scumm/charset.cpp +++ b/engines/scumm/charset.cpp @@ -1778,7 +1778,7 @@ void CharsetRendererNut::printChar(int chr, bool ignoreCharsetMask) { _str.left = _left; // Original keeps glyph width and character dimensions separately - if (_vm->_language == Common::ZH_TWN) + if (_vm->_language == Common::ZH_TWN && width == 16) width = 17; _left += width; -- cgit v1.2.3 From b6eedda8858eca9926619fec03dd3075ed4fa7ac Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 22 Jul 2007 22:59:08 +0000 Subject: - Fix wrong languages in Chinese COMI - Fix credits rendering in Chinese COMI svn-id: r28167 --- engines/scumm/charset.cpp | 11 ++++++++++- engines/scumm/string.cpp | 16 +++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/scumm/charset.cpp b/engines/scumm/charset.cpp index 3c910bd239..2271bf53a1 100644 --- a/engines/scumm/charset.cpp +++ b/engines/scumm/charset.cpp @@ -371,7 +371,7 @@ int CharsetRenderer::getStringWidth(int arg, const byte *text) { break; } } else { - if (chr == '@') + if (chr == '@' && _vm->_language != Common::ZH_TWN) continue; if (chr == 255 || (_vm->_game.version <= 6 && chr == 254)) { chr = text[pos++]; @@ -397,6 +397,15 @@ int CharsetRenderer::getStringWidth(int arg, const byte *text) { continue; } } + + // Some localizations may override colors + // See credits in Chinese COMI + if (chr == '^' && pos == 1) { + if (text[pos] == 'c') { + pos += 4; + chr = text[pos++]; + } + } } if ((chr & 0x80) && _vm->_useCJKMode) { pos++; diff --git a/engines/scumm/string.cpp b/engines/scumm/string.cpp index 44e727b5d3..32fdf0e04e 100644 --- a/engines/scumm/string.cpp +++ b/engines/scumm/string.cpp @@ -172,6 +172,20 @@ void ScummEngine_v6::drawBlastTexts() { if (c == 0x0B) continue; + // Some localizations may override colors + // See credits in Chinese COMI + if (c == '^' && (buf == _blastTextQueue[i].text + 1)) { + int color; + switch (*buf) { + case 'c': + color = buf[3] - '0' + 10 *(buf[2] - '0'); + _charset->setColor(color); + + buf += 4; + c = *buf++; + } + } + if (c != 0 && c != 0xFF && c != '\n') { if (c & 0x80 && _useCJKMode) { if (_language == Common::JA_JPN && !checkSJISCode(c)) { @@ -1060,7 +1074,7 @@ int ScummEngine::convertMessageToString(const byte *msg, byte *dst, int dstSize) num += (_game.version == 8) ? 4 : 2; } } else { - if (!(chr == '@' && _game.heversion <= 71)) { + if (!(chr == '@' && _game.heversion <= 71) || _language == Common::ZH_TWN) { *dst++ = chr; } } -- cgit v1.2.3 From e243dc8e365cf3066699679ab2c84cae19091c3f Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Mon, 23 Jul 2007 02:34:21 +0000 Subject: Add support for FLAC compression of sound bundles in The Dig and COMI. svn-id: r28173 --- engines/scumm/imuse_digi/dimuse_sndmgr.cpp | 35 +++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 8 deletions(-) (limited to 'engines') diff --git a/engines/scumm/imuse_digi/dimuse_sndmgr.cpp b/engines/scumm/imuse_digi/dimuse_sndmgr.cpp index 3f44873e46..c66209b42e 100644 --- a/engines/scumm/imuse_digi/dimuse_sndmgr.cpp +++ b/engines/scumm/imuse_digi/dimuse_sndmgr.cpp @@ -26,6 +26,7 @@ #include "common/scummsys.h" #include "common/util.h" +#include "sound/flac.h" #include "sound/voc.h" #include "sound/vorbis.h" #include "sound/mp3.h" @@ -601,13 +602,16 @@ int32 ImuseDigiSndMgr::getDataFromRegion(SoundDesc *soundDesc, int region, byte if (scumm_stricmp(fileName, soundDesc->lastFileName) != 0) { int32 offs = 0, len = 0; Common::File *cmpFile; - bool oggMode = false; - sprintf(fileName, "%s_reg%03d.mp3", soundDesc->name, region); + uint8 soundMode = 0; + + sprintf(fileName, "%s_reg%03d.fla", soundDesc->name, region); cmpFile = soundDesc->bundle->getFile(fileName, offs, len); -#ifndef USE_MAD - if (len) - error("Mad library compiled support needed!"); + if (len) { +#ifndef USE_FLAC + error("FLAC library compiled support needed!"); #endif + soundMode = 3; + } if (!len) { sprintf(fileName, "%s_reg%03d.ogg", soundDesc->name, region); cmpFile = soundDesc->bundle->getFile(fileName, offs, len); @@ -616,17 +620,32 @@ int32 ImuseDigiSndMgr::getDataFromRegion(SoundDesc *soundDesc, int region, byte error("Vorbis library compiled support needed!"); #endif assert(len); - oggMode = true; + soundMode = 2; } + if (!len) { + sprintf(fileName, "%s_reg%03d.mp3", soundDesc->name, region); + cmpFile = soundDesc->bundle->getFile(fileName, offs, len); +#ifndef USE_VORBIS + if (len) + error("Mad library compiled support needed!"); +#endif + assert(len); + soundMode = 1; + } + if (!soundDesc->compressedStream) { Common::MemoryReadStream *tmp = cmpFile->readStream(len); assert(tmp); +#ifdef USE_FLAC + if (soundMode == 3) + soundDesc->compressedStream = Audio::makeFlacStream(tmp, true); +#endif #ifdef USE_VORBIS - if (oggMode) + if (soundMode == 2) soundDesc->compressedStream = Audio::makeVorbisStream(tmp, true); #endif #ifdef USE_MAD - if (!oggMode) + if (soundMode == 1) soundDesc->compressedStream = Audio::makeMP3Stream(tmp, true); #endif assert(soundDesc->compressedStream); -- cgit v1.2.3 From f4fb06845c01c4ad88af4b9293422560fbcbd929 Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Mon, 23 Jul 2007 12:32:08 +0000 Subject: Fix regression, the incorrect key was been used for highlighting items in Simon the Sorcerer 1/2. svn-id: r28179 --- engines/agos/input.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/agos/input.cpp b/engines/agos/input.cpp index 0f1c234b79..a86cad9b94 100644 --- a/engines/agos/input.cpp +++ b/engines/agos/input.cpp @@ -196,7 +196,7 @@ void AGOSEngine::waitForInput() { for (;;) { if ((getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2) && - _keyPressed.keycode == Common::KEYCODE_HASH) + _keyPressed.keycode == Common::KEYCODE_F10) displayBoxStars(); if (processSpecialKeys()) { if ((getGameType() == GType_PP && getGameId() != GID_DIMP) || -- cgit v1.2.3 From d95056ce785907ffc01d4523eb8d858ca21f52e6 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Tue, 24 Jul 2007 06:11:38 +0000 Subject: Fixing bug #1749688 ("GOB3: Objects Disappear") svn-id: r28181 --- engines/gob/inter.h | 1 + engines/gob/inter_v2.cpp | 13 ++++++++++++- engines/gob/inter_v3.cpp | 2 +- engines/gob/mult.h | 20 +++++++++++++------- engines/gob/mult_v1.cpp | 12 ++++++++++-- engines/gob/mult_v2.cpp | 44 ++++++++++++++++++++++++++++++++------------ 6 files changed, 69 insertions(+), 23 deletions(-) (limited to 'engines') diff --git a/engines/gob/inter.h b/engines/gob/inter.h index fe84741eed..aedc442a49 100644 --- a/engines/gob/inter.h +++ b/engines/gob/inter.h @@ -342,6 +342,7 @@ protected: virtual void checkSwitchTable(byte **ppExec); void o2_playMult(); + void o2_freeMultKeys(); void o2_setRenderFlags(); void o2_multSub(); void o2_initMult(); diff --git a/engines/gob/inter_v2.cpp b/engines/gob/inter_v2.cpp index d69b6fda97..bf103e68ef 100644 --- a/engines/gob/inter_v2.cpp +++ b/engines/gob/inter_v2.cpp @@ -134,7 +134,7 @@ void Inter_v2::setupOpcodes() { /* 00 */ OPCODE(o1_loadMult), OPCODE(o2_playMult), - OPCODE(o1_freeMultKeys), + OPCODE(o2_freeMultKeys), {NULL, ""}, /* 04 */ {NULL, ""}, @@ -826,6 +826,17 @@ void Inter_v2::o2_playMult() { _vm->_mult->playMult(VAR(57), -1, checkEscape & 0x1, 0); } +void Inter_v2::o2_freeMultKeys() { + uint16 index = load16(); + + if (!_vm->_mult->hasMultData(index)) + return; + + _vm->_mult->setMultData(index); + _vm->_mult->freeMultKeys(); + _vm->_mult->zeroMultData(index); +} + void Inter_v2::o2_setRenderFlags() { int16 expr; diff --git a/engines/gob/inter_v3.cpp b/engines/gob/inter_v3.cpp index d3389f2671..ef0a7d6477 100644 --- a/engines/gob/inter_v3.cpp +++ b/engines/gob/inter_v3.cpp @@ -122,7 +122,7 @@ void Inter_v3::setupOpcodes() { /* 00 */ OPCODE(o1_loadMult), OPCODE(o2_playMult), - OPCODE(o1_freeMultKeys), + OPCODE(o2_freeMultKeys), {NULL, ""}, /* 04 */ {NULL, ""}, diff --git a/engines/gob/mult.h b/engines/gob/mult.h index edfbb682ea..16d9961f89 100644 --- a/engines/gob/mult.h +++ b/engines/gob/mult.h @@ -112,7 +112,7 @@ public: } PACKED_STRUCT; struct Mult_AnimKey { - int16 frame; + uint16 frame; int16 layer; int16 posX; int16 posY; @@ -246,8 +246,10 @@ public: virtual void loadMult(int16 resId) = 0; virtual void freeMultKeys() = 0; - virtual void setMultData(uint16 multindex) = 0; - virtual void multSub(uint16 multindex) = 0; + virtual bool hasMultData(uint16 multIndex) = 0; + virtual void setMultData(uint16 multIndex) = 0; + virtual void zeroMultData(uint16 multIndex) = 0; + virtual void multSub(uint16 multIndex) = 0; virtual void animate() = 0; Mult(GobEngine *vm); @@ -299,8 +301,10 @@ public: virtual void loadMult(int16 resId); virtual void freeMultKeys(); - virtual void setMultData(uint16 multindex); - virtual void multSub(uint16 multindex); + virtual bool hasMultData(uint16 multIndex); + virtual void setMultData(uint16 multIndex); + virtual void zeroMultData(uint16 multIndex); + virtual void multSub(uint16 multIndex); virtual void animate(); protected: @@ -317,8 +321,10 @@ public: virtual void loadMult(int16 resId); virtual void freeMultKeys(); - virtual void setMultData(uint16 multindex); - virtual void multSub(uint16 multindex); + virtual bool hasMultData(uint16 multIndex); + virtual void setMultData(uint16 multIndex); + virtual void zeroMultData(uint16 multIndex); + virtual void multSub(uint16 multIndex); virtual void animate(); protected: diff --git a/engines/gob/mult_v1.cpp b/engines/gob/mult_v1.cpp index 45ce9aa8a0..0c367870ac 100644 --- a/engines/gob/mult_v1.cpp +++ b/engines/gob/mult_v1.cpp @@ -237,11 +237,19 @@ void Mult_v1::freeMultKeys() { _multData = 0; } -void Mult_v1::setMultData(uint16 multindex) { +bool Mult_v1::hasMultData(uint16 multIndex) { error("Switching mults not supported for Gob1"); } -void Mult_v1::multSub(uint16 multindex) { +void Mult_v1::setMultData(uint16 multIndex) { + error("Switching mults not supported for Gob1"); +} + +void Mult_v1::zeroMultData(uint16 multIndex) { + error("Switching mults not supported for Gob1"); +} + +void Mult_v1::multSub(uint16 multIndex) { error("Switching mults not supported for Gob1"); } diff --git a/engines/gob/mult_v2.cpp b/engines/gob/mult_v2.cpp index f57d5ecb0c..86a2a260de 100644 --- a/engines/gob/mult_v2.cpp +++ b/engines/gob/mult_v2.cpp @@ -346,28 +346,42 @@ void Mult_v2::freeMultKeys() { _multData = 0; } -void Mult_v2::setMultData(uint16 multindex) { - if (multindex > 7) +bool Mult_v2::hasMultData(uint16 multIndex) { + if (multIndex > 7) error("Multindex out of range"); - debugC(4, kDebugGameFlow, "Switching to mult %d", multindex); - _multData = _multDatas[multindex]; + return _multDatas[multIndex] != 0; } -void Mult_v2::multSub(uint16 multindex) { +void Mult_v2::setMultData(uint16 multIndex) { + if (multIndex > 7) + error("Multindex out of range"); + + debugC(4, kDebugGameFlow, "Switching to mult %d", multIndex); + _multData = _multDatas[multIndex]; +} + +void Mult_v2::zeroMultData(uint16 multIndex) { + if (multIndex > 7) + error("Multindex out of range"); + + _multDatas[multIndex] = 0; +} + +void Mult_v2::multSub(uint16 multIndex) { uint16 flags; int16 expr; int16 index; int16 startFrame, stopFrame, firstFrame; - flags = multindex; - multindex = (multindex >> 12) & 0xF; + flags = multIndex; + multIndex = (multIndex >> 12) & 0xF; - if (multindex > 7) + if (multIndex > 7) error("Multindex out of range"); - debugC(4, kDebugGameFlow, "Sub mult %d", multindex); - _multData = _multDatas[multindex]; + debugC(4, kDebugGameFlow, "Sub mult %d", multIndex); + _multData = _multDatas[multIndex]; if (!_multData) { _vm->_parse->parseValExpr(); @@ -1074,13 +1088,19 @@ void Mult_v2::advanceObjects(int16 index) { return; for (int i = 0; i < 4; i++) { + int obj = _multData->animObjs[index][i]; + if (_multData->animObjs[index][i] != -1) { int keyIndex = _multData->animKeysIndices[index][i]; int count = _multData->animKeysCount[i]; for (int j = keyIndex; j < count; j++) { + + if ((obj == -1) || (obj == 1024)) + continue; + Mult_AnimKey &key = _multData->animKeys[i][j]; - Mult_Object &animObj = _objects[_multData->animObjs[index][i]]; + Mult_Object &animObj = _objects[obj]; Mult_AnimData &animData = *(animObj.pAnimData); if (key.frame > frame) @@ -1122,7 +1142,7 @@ void Mult_v2::advanceObjects(int16 index) { } } - if (_multData->animObjs[index][i] != -1) { + if (obj != -1) { int keyIndex = _multData->imdKeysIndices[index][i]; int count = _multData->imdKeysCount[i]; -- cgit v1.2.3 From 9bb903ee6b73d2c04a5585fffbb75dfc076ab4f9 Mon Sep 17 00:00:00 2001 From: Gregory Montoir Date: Tue, 24 Jul 2007 09:50:24 +0000 Subject: fixed some issues in pathfinding code svn-id: r28183 --- engines/touche/touche.cpp | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'engines') diff --git a/engines/touche/touche.cpp b/engines/touche/touche.cpp index 18d2ac5359..fad3e64475 100644 --- a/engines/touche/touche.cpp +++ b/engines/touche/touche.cpp @@ -2704,6 +2704,7 @@ bool ToucheEngine::sortPointsData(int num1, int num2) { const int md1 = _programWalkTable[i].point1; const int md2 = _programWalkTable[i].point2; if ((md1 & 0x4000) == 0) { + assert((md2 & 0x4000) == 0); if (_programPointsTable[md1].priority == priority - 1 && _programPointsTable[md2].priority > priority) { _programPointsTable[md2].priority = priority; quit = false; @@ -2949,6 +2950,7 @@ void ToucheEngine::markWalkPoints(int keyChar) { int16 md1 = _programWalkTable[i].point1; int16 md2 = _programWalkTable[i].point2; if ((md1 & 0x4000) == 0) { + assert((md2 & 0x4000) == 0); if (_programPointsTable[md1].priority != 0 && _programPointsTable[md2].priority == 0) { _programPointsTable[md2].priority = 1; quit = false; @@ -2974,8 +2976,8 @@ void ToucheEngine::buildWalkPath(int dstPosX, int dstPosY, int keyChar) { int minPointsDataNum = -1; for (uint i = 1; i < _programPointsTable.size(); ++i) { if (_programPointsTable[i].priority != 0) { - int dx = ABS(_programPointsTable[i].x - dstPosX); - int dy = ABS(_programPointsTable[i].y - dstPosY); + int dx = _programPointsTable[i].x - dstPosX; + int dy = _programPointsTable[i].y - dstPosY; int distance = dx * dx + dy * dy; if (distance < minDistance) { minDistance = distance; @@ -2997,23 +2999,23 @@ void ToucheEngine::buildWalkPath(int dstPosX, int dstPosY, int keyChar) { int dy = pts2->y - pts1->y; if (dx == 0) { if (dstPosY > MIN(pts2->y, pts1->y) && dstPosY < MAX(pts2->y, pts1->y)) { - distance = ABS(dstPosX - pts1->x); - if (distance <= 100) { - distance *= distance; + int d = ABS(dstPosX - pts1->x); + if (d <= 100) { + distance = d * d; } } } else if (dy == 0) { if (dstPosX > MIN(pts2->x, pts1->x) && dstPosX < MAX(pts2->x, pts1->x)) { - distance = ABS(dstPosY - pts1->y); - if (distance <= 100) { - distance *= distance; + int d = ABS(dstPosY - pts1->y); + if (d <= 100) { + distance = d * d; } } } else { if (dstPosY > MIN(pts2->y, pts1->y) && dstPosY < MAX(pts2->y, pts1->y) && dstPosX > MIN(pts2->x, pts1->x) && dstPosX < MAX(pts2->x, pts1->x) ) { - distance = (dstPosY - pts1->y) * dx - (dstPosX - pts1->x) * dy; - distance = (dx * dx + dy * dy) / distance; + distance = (dstPosX - pts1->x) * dy - (dstPosY - pts1->y) * dx; + distance /= (dx * dx + dy * dy); } } if (distance < minDistance) { @@ -3047,13 +3049,13 @@ void ToucheEngine::buildWalkPath(int dstPosX, int dstPosY, int keyChar) { dstPosZ = pts2->z - (pts2->x - dstPosX) * dz / dx; dstPosY = pts2->y - (pts2->x - dstPosX) * dy / dx; } - if (key->walkDataNum == key->prevWalkDataNum && key->walkPointsList[1] == -1) { - if (key->walkPointsList[0] == _programWalkTable[minWalkDataNum].point1 || key->walkPointsList[0] == _programWalkTable[minWalkDataNum].point2) { - ++key->walkPointsListCount; - } - } } key->prevWalkDataNum = minWalkDataNum; + if (key->walkDataNum == key->prevWalkDataNum && key->walkPointsList[1] == -1) { + if (key->walkPointsList[0] == _programWalkTable[minWalkDataNum].point1 || key->walkPointsList[0] == _programWalkTable[minWalkDataNum].point2) { + ++key->walkPointsListCount; + } + } key->xPosPrev = dstPosX; key->yPosPrev = dstPosY; key->zPosPrev = dstPosZ; -- cgit v1.2.3 From 38b282b31312b827dce14f64cbbd88b74783741c Mon Sep 17 00:00:00 2001 From: Gregory Montoir Date: Tue, 24 Jul 2007 09:53:28 +0000 Subject: renamed some fields for clarification svn-id: r28184 --- engines/touche/resource.cpp | 2 +- engines/touche/saveload.cpp | 4 +-- engines/touche/touche.cpp | 70 ++++++++++++++++++++++----------------------- engines/touche/touche.h | 4 +-- 4 files changed, 40 insertions(+), 40 deletions(-) (limited to 'engines') diff --git a/engines/touche/resource.cpp b/engines/touche/resource.cpp index f9f2938502..81a11569dc 100644 --- a/engines/touche/resource.cpp +++ b/engines/touche/resource.cpp @@ -273,7 +273,7 @@ void ToucheEngine::res_decodeProgramData() { ppd.x = READ_LE_UINT16(p); p += 2; ppd.y = READ_LE_UINT16(p); p += 2; ppd.z = READ_LE_UINT16(p); p += 2; - ppd.priority = READ_LE_UINT16(p); p += 2; + ppd.order = READ_LE_UINT16(p); p += 2; _programPointsTable.push_back(ppd); if (ppd.x == -1) { break; diff --git a/engines/touche/saveload.cpp b/engines/touche/saveload.cpp index b219001c49..653c2d26a3 100644 --- a/engines/touche/saveload.cpp +++ b/engines/touche/saveload.cpp @@ -131,7 +131,7 @@ static void saveOrLoad(S &s, KeyChar &key) { saveOrLoad(s, key.followingKeyCharPos); saveOrLoad(s, key.sequenceDataIndex); saveOrLoad(s, key.sequenceDataOffset); - saveOrLoad(s, key.walkPointsListCount); + saveOrLoad(s, key.walkPointsListIndex); for (uint i = 0; i < 40; ++i) { saveOrLoad(s, key.walkPointsList[i]); } @@ -209,7 +209,7 @@ static void saveOrLoad(S &s, ProgramPointData &data) { saveOrLoad(s, data.x); saveOrLoad(s, data.y); saveOrLoad(s, data.z); - saveOrLoad(s, data.priority); + saveOrLoad(s, data.order); } template diff --git a/engines/touche/touche.cpp b/engines/touche/touche.cpp index fad3e64475..fce2c8ed1b 100644 --- a/engines/touche/touche.cpp +++ b/engines/touche/touche.cpp @@ -642,7 +642,7 @@ void ToucheEngine::initKeyChars(int keyChar) { key->sequenceDataOffset = 0; key->walkDataNum = 0; key->walkPointsList[0] = -1; - key->walkPointsListCount = 0; + key->walkPointsListIndex = 0; key->delay = 0; key->waitingKeyChar = -1; key->flags = 0; @@ -2516,7 +2516,7 @@ void ToucheEngine::buildWalkPointsList(int keyChar) { uint16 curPos, pos1, pos2; if (key->pointsDataNum & 0x8000) { const ProgramWalkData *pwd = &_programWalkTable[(key->pointsDataNum & 0x7FFF)]; - if (_programPointsTable[pwd->point1].priority < _programPointsTable[pwd->point2].priority) { + if (_programPointsTable[pwd->point1].order < _programPointsTable[pwd->point2].order) { curPos = pwd->point1; } else { curPos = pwd->point2; @@ -2525,7 +2525,7 @@ void ToucheEngine::buildWalkPointsList(int keyChar) { curPos = key->pointsDataNum; } - int16 posNum = _programPointsTable[curPos].priority; + int16 posNum = _programPointsTable[curPos].order; if (posNum == 32000) { return; } @@ -2536,25 +2536,25 @@ void ToucheEngine::buildWalkPointsList(int keyChar) { if ((_programWalkTable[i].point1 & 0x4000) == 0) { pos1 = _programWalkTable[i].point1; pos2 = _programWalkTable[i].point2; - if (pos1 == curPos && posNum > _programPointsTable[pos2].priority) { + if (pos1 == curPos && posNum > _programPointsTable[pos2].order) { curPos = pos2; assert(walkPointsCount < 40); key->walkPointsList[walkPointsCount] = curPos; ++walkPointsCount; - posNum = _programPointsTable[pos2].priority; + posNum = _programPointsTable[pos2].order; break; } - if (pos2 == curPos && posNum > _programPointsTable[pos1].priority) { + if (pos2 == curPos && posNum > _programPointsTable[pos1].order) { curPos = pos1; assert(walkPointsCount < 40); key->walkPointsList[walkPointsCount] = curPos; ++walkPointsCount; - posNum = _programPointsTable[pos1].priority; + posNum = _programPointsTable[pos1].order; break; } } } - } while (_programPointsTable[curPos].priority != 0); + } while (_programPointsTable[curPos].order != 0); assert(walkPointsCount < 40); key->walkPointsList[walkPointsCount] = -1; @@ -2562,7 +2562,7 @@ void ToucheEngine::buildWalkPointsList(int keyChar) { key->yPosPrev = _programPointsTable[curPos].y; key->zPosPrev = _programPointsTable[curPos].z; key->prevWalkDataNum = findWalkDataNum(curPos, -1); - key->walkPointsListCount = 0; + key->walkPointsListIndex = 0; if (key->walkDataNum == -1) { return; } @@ -2571,13 +2571,13 @@ void ToucheEngine::buildWalkPointsList(int keyChar) { pos2 = _programWalkTable[key->walkDataNum].point2; if (key->pointsDataNum == pos1) { if (key->walkPointsList[1] == pos2) { - ++key->walkPointsListCount; + ++key->walkPointsListIndex; } return; } if (key->pointsDataNum == pos2) { if (key->walkPointsList[1] == pos1) { - ++key->walkPointsListCount; + ++key->walkPointsListIndex; } return; } @@ -2678,7 +2678,7 @@ void ToucheEngine::unlockWalkPath(int num1, int num2) { void ToucheEngine::resetPointsData(int num) { debugC(9, kDebugEngine, "ToucheEngine::resetPointsData(%d)", num); for (uint i = 1; i < _programPointsTable.size(); ++i) { - _programPointsTable[i].priority = num; + _programPointsTable[i].order = num; } } @@ -2689,15 +2689,15 @@ bool ToucheEngine::sortPointsData(int num1, int num2) { if (num2 == -1) { return false; } - _programPointsTable[num2].priority = 0; + _programPointsTable[num2].order = 0; } else { const int md1 = _programWalkTable[num1].point1; - _programPointsTable[md1].priority = 0; + _programPointsTable[md1].order = 0; const int md2 = _programWalkTable[num1].point2; - _programPointsTable[md2].priority = 0; + _programPointsTable[md2].order = 0; } bool quit = false; - int priority = 1; + int order = 1; while (!quit) { quit = true; for (uint i = 0; i < _programWalkTable.size(); ++i) { @@ -2705,17 +2705,17 @@ bool ToucheEngine::sortPointsData(int num1, int num2) { const int md2 = _programWalkTable[i].point2; if ((md1 & 0x4000) == 0) { assert((md2 & 0x4000) == 0); - if (_programPointsTable[md1].priority == priority - 1 && _programPointsTable[md2].priority > priority) { - _programPointsTable[md2].priority = priority; + if (_programPointsTable[md1].order == order - 1 && _programPointsTable[md2].order > order) { + _programPointsTable[md2].order = order; quit = false; } - if (_programPointsTable[md2].priority == priority - 1 && _programPointsTable[md1].priority > priority) { - _programPointsTable[md1].priority = priority; + if (_programPointsTable[md2].order == order - 1 && _programPointsTable[md1].order > order) { + _programPointsTable[md1].order = order; quit = false; } } } - ++priority; + ++order; } return true; } @@ -2764,8 +2764,8 @@ void ToucheEngine::updateKeyCharWalkPath(KeyChar *key, int16 dx, int16 dy, int16 int16 xpos, ypos, zpos, walkPoint1, walkPoint2, newDirection, incDx, incDy, incDz; while (1) { - walkPoint1 = key->walkPointsList[key->walkPointsListCount]; - walkPoint2 = key->walkPointsList[key->walkPointsListCount + 1]; + walkPoint1 = key->walkPointsList[key->walkPointsListIndex]; + walkPoint2 = key->walkPointsList[key->walkPointsListIndex + 1]; key->currentWalkBox = walkPoint1; if (walkPoint1 == -1) { xpos = key->xPosPrev; @@ -2805,9 +2805,9 @@ void ToucheEngine::updateKeyCharWalkPath(KeyChar *key, int16 dx, int16 dy, int16 key->pointsDataNum = walkPoint1; if (walkPoint2 == -1) { key->walkPointsList[0] = -1; - key->walkPointsListCount = 0; + key->walkPointsListIndex = 0; } else { - ++key->walkPointsListCount; + ++key->walkPointsListIndex; int16 walkDataNum = findWalkDataNum(walkPoint1, walkPoint2); if (walkDataNum != -1) { key->walkDataNum = walkDataNum; @@ -2859,7 +2859,7 @@ void ToucheEngine::updateKeyCharWalkPath(KeyChar *key, int16 dx, int16 dy, int16 } key->prevPointsDataNum = key->pointsDataNum; key->pointsDataNum = walkPoint1; - ++key->walkPointsListCount; + ++key->walkPointsListIndex; if (newDirection != curDirection) { key->facingDirection = newDirection; key->currentAnimCounter = 0; @@ -2903,7 +2903,7 @@ void ToucheEngine::updateKeyCharWalkPath(KeyChar *key, int16 dx, int16 dy, int16 } key->prevPointsDataNum = key->pointsDataNum; key->pointsDataNum = walkPoint1; - ++key->walkPointsListCount; + ++key->walkPointsListIndex; if (newDirection != curDirection) { key->facingDirection = newDirection; key->currentAnimCounter = 0; @@ -2942,7 +2942,7 @@ void ToucheEngine::markWalkPoints(int keyChar) { int16 pointsDataNum = key->pointsDataNum; resetPointsData(0); if (pointsDataNum != -1) { - _programPointsTable[pointsDataNum].priority = 1; + _programPointsTable[pointsDataNum].order = 1; bool quit = false; while (!quit) { quit = true; @@ -2951,12 +2951,12 @@ void ToucheEngine::markWalkPoints(int keyChar) { int16 md2 = _programWalkTable[i].point2; if ((md1 & 0x4000) == 0) { assert((md2 & 0x4000) == 0); - if (_programPointsTable[md1].priority != 0 && _programPointsTable[md2].priority == 0) { - _programPointsTable[md2].priority = 1; + if (_programPointsTable[md1].order != 0 && _programPointsTable[md2].order == 0) { + _programPointsTable[md2].order = 1; quit = false; } - if (_programPointsTable[md2].priority != 0 && _programPointsTable[md1].priority == 0) { - _programPointsTable[md1].priority = 1; + if (_programPointsTable[md2].order != 0 && _programPointsTable[md1].order == 0) { + _programPointsTable[md1].order = 1; quit = false; } } @@ -2975,7 +2975,7 @@ void ToucheEngine::buildWalkPath(int dstPosX, int dstPosY, int keyChar) { int minDistance = 0x7D000000; int minPointsDataNum = -1; for (uint i = 1; i < _programPointsTable.size(); ++i) { - if (_programPointsTable[i].priority != 0) { + if (_programPointsTable[i].order != 0) { int dx = _programPointsTable[i].x - dstPosX; int dy = _programPointsTable[i].y - dstPosY; int distance = dx * dx + dy * dy; @@ -2994,7 +2994,7 @@ void ToucheEngine::buildWalkPath(int dstPosX, int dstPosY, int keyChar) { int distance = 32000; ProgramPointData *pts1 = &_programPointsTable[pwd->point1]; ProgramPointData *pts2 = &_programPointsTable[pwd->point2]; - if (pts1->priority != 0) { + if (pts1->order != 0) { int dx = pts2->x - pts1->x; int dy = pts2->y - pts1->y; if (dx == 0) { @@ -3053,7 +3053,7 @@ void ToucheEngine::buildWalkPath(int dstPosX, int dstPosY, int keyChar) { key->prevWalkDataNum = minWalkDataNum; if (key->walkDataNum == key->prevWalkDataNum && key->walkPointsList[1] == -1) { if (key->walkPointsList[0] == _programWalkTable[minWalkDataNum].point1 || key->walkPointsList[0] == _programWalkTable[minWalkDataNum].point2) { - ++key->walkPointsListCount; + ++key->walkPointsListIndex; } } key->xPosPrev = dstPosX; diff --git a/engines/touche/touche.h b/engines/touche/touche.h index ce4f84b9a8..ed346cd3b9 100644 --- a/engines/touche/touche.h +++ b/engines/touche/touche.h @@ -114,7 +114,7 @@ struct KeyChar { int16 followingKeyCharPos; uint16 sequenceDataIndex; uint16 sequenceDataOffset; - int16 walkPointsListCount; + int16 walkPointsListIndex; int16 walkPointsList[40]; uint16 scriptDataStartOffset; uint16 scriptDataOffset; @@ -209,7 +209,7 @@ struct InventoryState { struct ProgramPointData { int16 x, y, z; - int16 priority; + int16 order; }; struct ProgramWalkData { -- cgit v1.2.3 From 09c2ea82de295fab011bcddcc7c2bf0ba6dd72d7 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Tue, 24 Jul 2007 23:24:40 +0000 Subject: - Separated game type and features - Added feature constants for a 640x480 resolution and adlib - Added support for game with a 640x480 resolution. Woodruff now inits the screen before it segfaults svn-id: r28185 --- engines/gob/detection.cpp | 267 ++++++++++++++++++++++++++++++---------------- engines/gob/game.cpp | 15 +-- engines/gob/global.cpp | 2 +- engines/gob/gob.cpp | 257 ++++++++++++++++++++++++++++---------------- engines/gob/gob.h | 39 +++++-- engines/gob/inter.cpp | 2 +- engines/gob/inter_v1.cpp | 9 +- engines/gob/inter_v2.cpp | 13 +-- engines/gob/map.cpp | 2 +- engines/gob/video.cpp | 4 +- 10 files changed, 401 insertions(+), 209 deletions(-) (limited to 'engines') diff --git a/engines/gob/detection.cpp b/engines/gob/detection.cpp index 1c275185ca..a82041ce0e 100644 --- a/engines/gob/detection.cpp +++ b/engines/gob/detection.cpp @@ -34,7 +34,8 @@ namespace Gob { struct GOBGameDescription { Common::ADGameDescription desc; - uint32 features; + GameType gameType; + int32 features; const char *startTotBase; }; @@ -74,7 +75,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB1 | GF_EGA, + kGameTypeGob1, + kFeaturesEGA, "intro" }, { @@ -86,7 +88,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB1 | GF_EGA, + kGameTypeGob1, + kFeaturesEGA, "intro" }, { // Supplied by Theruler76 in bug report #1201233 @@ -98,7 +101,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB1, + kGameTypeGob1, + kFeaturesNone, "intro" }, { // CD 1.000 version. @@ -110,7 +114,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB1 | GF_CD, + kGameTypeGob1, + kFeaturesCD, "intro" }, { // CD 1.000 version. @@ -122,7 +127,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB1 | GF_CD, + kGameTypeGob1, + kFeaturesCD, "intro" }, { // CD 1.000 version. @@ -134,7 +140,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB1 | GF_CD, + kGameTypeGob1, + kFeaturesCD, "intro" }, { // CD 1.000 version. @@ -146,7 +153,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB1 | GF_CD, + kGameTypeGob1, + kFeaturesCD, "intro" }, { // CD 1.000 version. @@ -158,7 +166,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB1 | GF_CD, + kGameTypeGob1, + kFeaturesCD, "intro" }, { // CD 1.02 version. Multilingual @@ -170,7 +179,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB1 | GF_CD, + kGameTypeGob1, + kFeaturesCD, "intro" }, { // CD 1.02 version. Multilingual @@ -182,7 +192,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB1 | GF_CD, + kGameTypeGob1, + kFeaturesCD, "intro" }, { // CD 1.02 version. Multilingual @@ -194,7 +205,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB1 | GF_CD, + kGameTypeGob1, + kFeaturesCD, "intro" }, { // CD 1.02 version. Multilingual @@ -206,7 +218,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB1 | GF_CD, + kGameTypeGob1, + kFeaturesCD, "intro" }, { // CD 1.02 version. Multilingual @@ -218,7 +231,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB1 | GF_CD, + kGameTypeGob1, + kFeaturesCD, "intro" }, { @@ -230,7 +244,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformAmiga, Common::ADGF_DEMO }, - GF_GOB1, + kGameTypeGob1, + kFeaturesNone, "intro" }, { @@ -242,7 +257,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_DEMO }, - GF_GOB1, + kGameTypeGob1, + kFeaturesNone, "intro" }, { // Supplied by paul66 in bug report #1652352 @@ -254,7 +270,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformMacintosh, Common::ADGF_NO_FLAGS }, - GF_GOB1, + kGameTypeGob1, + kFeaturesAdlib, "intro" }, { // Supplied by paul66 in bug report #1652352 @@ -266,7 +283,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformMacintosh, Common::ADGF_NO_FLAGS }, - GF_GOB1, + kGameTypeGob1, + kFeaturesAdlib, "intro" }, { // Supplied by paul66 in bug report #1652352 @@ -278,7 +296,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformMacintosh, Common::ADGF_NO_FLAGS }, - GF_GOB1, + kGameTypeGob1, + kFeaturesAdlib, "intro" }, { // Supplied by paul66 in bug report #1652352 @@ -290,7 +309,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformMacintosh, Common::ADGF_NO_FLAGS }, - GF_GOB1, + kGameTypeGob1, + kFeaturesAdlib, "intro" }, { // Supplied by paul66 in bug report #1652352 @@ -302,7 +322,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformMacintosh, Common::ADGF_NO_FLAGS }, - GF_GOB1, + kGameTypeGob1, + kFeaturesAdlib, "intro" }, { @@ -314,7 +335,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB2, + kGameTypeGob2, + kFeaturesAdlib, "intro" }, { // Supplied by arcepi in bug report #1659884 @@ -326,7 +348,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB2, + kGameTypeGob2, + kFeaturesAdlib, "intro" }, { @@ -338,7 +361,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB2, + kGameTypeGob2, + kFeaturesAdlib, "intro" }, { // Supplied by fac76 in bug report #1673397 @@ -354,7 +378,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformMacintosh, Common::ADGF_NO_FLAGS }, - GF_GOB2, + kGameTypeGob2, + kFeaturesAdlib, "intro" }, { @@ -366,7 +391,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB2, + kGameTypeGob2, + kFeaturesAdlib, "intro" }, { @@ -378,7 +404,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB2, + kGameTypeGob2, + kFeaturesAdlib, "intro" }, { @@ -390,7 +417,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB2, + kGameTypeGob2, + kFeaturesAdlib, "intro" }, { @@ -402,7 +430,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformAmiga, Common::ADGF_NO_FLAGS }, - GF_GOB2, + kGameTypeGob2, + kFeaturesNone, "intro" }, { // Supplied by blackwhiteeagle in bug report #1605235 @@ -414,7 +443,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB2, + kGameTypeGob2, + kFeaturesAdlib, "intro" }, { // Supplied by bgk in bug report #1706861 @@ -426,7 +456,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformAtariST, Common::ADGF_NO_FLAGS }, - GF_GOB2, + kGameTypeGob2, + kFeaturesNone, "intro" }, { @@ -438,7 +469,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB2 | GF_CD, + kGameTypeGob2, + kFeaturesCD, "intro" }, { @@ -450,7 +482,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB2 | GF_CD, + kGameTypeGob2, + kFeaturesCD, "intro" }, { @@ -462,7 +495,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB2 | GF_CD, + kGameTypeGob2, + kFeaturesCD, "intro" }, { @@ -474,7 +508,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB2 | GF_CD, + kGameTypeGob2, + kFeaturesCD, "intro" }, { @@ -486,7 +521,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB2 | GF_CD, + kGameTypeGob2, + kFeaturesCD, "intro" }, { @@ -498,7 +534,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB2 | GF_CD, + kGameTypeGob2, + kFeaturesCD, "intro" }, { @@ -510,7 +547,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_DEMO }, - GF_GOB2, + kGameTypeGob2, + kFeaturesAdlib, "usa" }, { @@ -522,7 +560,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_DEMO }, - GF_GOB2, + kGameTypeGob2, + kFeaturesAdlib, "intro" }, { @@ -534,7 +573,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_DEMO }, - GF_GOB2, + kGameTypeGob2, + kFeaturesAdlib, "intro" }, { @@ -546,7 +586,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB2, + kGameTypeWeen, + kFeaturesAdlib, "intro" }, { @@ -558,7 +599,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB2, + kGameTypeWeen, + kFeaturesAdlib, "intro" }, { // Supplied by cybot_tmin in bug report #1667743 @@ -570,7 +612,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB2, + kGameTypeWeen, + kFeaturesAdlib, "intro" }, { // Supplied by vampir_raziel in bug report #1658373 @@ -582,7 +625,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformAmiga, Common::ADGF_NO_FLAGS }, - GF_GOB2, + kGameTypeWeen, + kFeaturesNone, "intro" }, { // Supplied by vampir_raziel in bug report #1658373 @@ -594,7 +638,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformAmiga, Common::ADGF_NO_FLAGS }, - GF_GOB2, + kGameTypeWeen, + kFeaturesNone, "intro" }, { // Supplied by vampir_raziel in bug report #1658373 @@ -606,7 +651,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformAmiga, Common::ADGF_NO_FLAGS }, - GF_GOB2, + kGameTypeWeen, + kFeaturesNone, "intro" }, { // Supplied by vampir_raziel in bug report #1658373 @@ -618,7 +664,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformAmiga, Common::ADGF_NO_FLAGS }, - GF_GOB2, + kGameTypeWeen, + kFeaturesNone, "intro" }, { @@ -630,7 +677,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformAtariST, Common::ADGF_NO_FLAGS }, - GF_GOB2, + kGameTypeWeen, + kFeaturesNone, "intro" }, { @@ -642,7 +690,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB2, + kGameTypeWeen, + kFeaturesAdlib, "intro" }, { // Supplied by cartman_ on #scummvm @@ -654,7 +703,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB2, + kGameTypeWeen, + kFeaturesAdlib, "intro" }, { // Supplied by glorfindel in bugreport #1722142 @@ -666,7 +716,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB2, + kGameTypeWeen, + kFeaturesAdlib, "intro" }, { @@ -678,7 +729,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_DEMO }, - GF_GOB2, + kGameTypeWeen, + kFeaturesAdlib, "show" }, { @@ -690,7 +742,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_DEMO }, - GF_GOB2, + kGameTypeWeen, + kFeaturesAdlib, "show" }, { @@ -702,7 +755,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_BARGON, + kGameTypeBargon, + kFeaturesNone, "intro" }, { // Supplied by Trekky in the forums @@ -714,7 +768,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformAtariST, Common::ADGF_NO_FLAGS }, - GF_BARGON, + kGameTypeBargon, + kFeaturesNone, "intro" }, { // Supplied by cesardark in bug #1681649 @@ -726,7 +781,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_BARGON, + kGameTypeBargon, + kFeaturesNone, "intro" }, { // Supplied by paul66 in bug #1692667 @@ -738,7 +794,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_BARGON, + kGameTypeBargon, + kFeaturesNone, "intro" }, { // Supplied by glorfindel in bugreport #1722142 @@ -750,7 +807,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_BARGON, + kGameTypeBargon, + kFeaturesNone, "intro" }, { @@ -762,7 +820,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB3, + kGameTypeGob3, + kFeaturesAdlib, "intro" }, { // Supplied by fac76 in bug report #1742716 @@ -778,7 +837,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformMacintosh, Common::ADGF_NO_FLAGS }, - GF_GOB3, + kGameTypeGob3, + kFeaturesAdlib, "intro" }, { @@ -790,7 +850,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB3, + kGameTypeGob3, + kFeaturesAdlib, "intro" }, { // Supplied by paul66 in bug report #1652352 @@ -802,7 +863,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB3, + kGameTypeGob3, + kFeaturesAdlib, "intro" }, { @@ -814,7 +876,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB3, + kGameTypeGob3, + kFeaturesAdlib, "intro" }, { // Supplied by Paranoimia on #scummvm @@ -826,7 +889,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB3, + kGameTypeGob3, + kFeaturesAdlib, "intro" }, { @@ -838,7 +902,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB3, + kGameTypeGob3, + kFeaturesAdlib, "intro" }, { @@ -850,7 +915,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB3, + kGameTypeGob3, + kFeaturesAdlib, "intro" }, { @@ -862,7 +928,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformAmiga, Common::ADGF_NO_FLAGS }, - GF_GOB3, + kGameTypeGob3, + kFeaturesNone, "menu" }, { @@ -874,7 +941,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformAmiga, Common::ADGF_NO_FLAGS }, - GF_GOB3, + kGameTypeGob3, + kFeaturesNone, "menu" }, { @@ -886,7 +954,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB3 | GF_CD, + kGameTypeGob3, + kFeaturesCD, "intro" }, { // Supplied by paul66 and noizert in bug reports #1652352 and #1691230 @@ -898,7 +967,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB3 | GF_CD, + kGameTypeGob3, + kFeaturesCD, "intro" }, { // Supplied by paul66 and noizert in bug reports #1652352 and #1691230 @@ -910,7 +980,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB3 | GF_CD, + kGameTypeGob3, + kFeaturesCD, "intro" }, { // Supplied by paul66 and noizert in bug reports #1652352 and #1691230 @@ -922,7 +993,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB3 | GF_CD, + kGameTypeGob3, + kFeaturesCD, "intro" }, { // Supplied by paul66 and noizert in bug reports #1652352 and #1691230 @@ -934,7 +1006,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB3 | GF_CD, + kGameTypeGob3, + kFeaturesCD, "intro" }, { // Supplied by paul66 and noizert in bug reports #1652352 and #1691230 @@ -946,7 +1019,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB3 | GF_CD, + kGameTypeGob3, + kFeaturesCD, "intro" }, { @@ -958,7 +1032,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_DEMO }, - GF_GOB3, + kGameTypeGob3, + kFeaturesAdlib, "intro" }, { @@ -970,7 +1045,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_DEMO }, - GF_GOB3, + kGameTypeGob3, + kFeaturesAdlib, "intro" }, { @@ -982,7 +1058,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_DEMO }, - GF_GOB3, + kGameTypeGob3, + kFeaturesAdlib, "intro" }, { @@ -994,7 +1071,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_DEMO }, - GF_GOB3, + kGameTypeGob3, + kFeaturesAdlib, "intro" }, { @@ -1006,7 +1084,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_WOODRUFF, + kGameTypeNone, + kFeatures640 | kFeaturesAdlib, "intro" }, { @@ -1018,7 +1097,8 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_WOODRUFF, + kGameTypeNone, + kFeatures640 | kFeaturesAdlib, "intro" }, { @@ -1030,10 +1110,11 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_WOODRUFF, + kGameTypeNone, + kFeatures640 | kFeaturesAdlib, "intro" }, - { AD_TABLE_END_MARKER, 0, NULL } + { AD_TABLE_END_MARKER, kGameTypeNone, kFeaturesNone, NULL } }; static const GOBGameDescription fallbackDescs[] = { @@ -1046,7 +1127,8 @@ static const GOBGameDescription fallbackDescs[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB1, + kGameTypeGob1, + kFeaturesNone, "intro" }, { @@ -1058,7 +1140,8 @@ static const GOBGameDescription fallbackDescs[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB1 | GF_CD, + kGameTypeGob1, + kFeaturesCD, "intro" }, { @@ -1070,7 +1153,8 @@ static const GOBGameDescription fallbackDescs[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB2, + kGameTypeGob2, + kFeaturesAdlib, "intro" }, { @@ -1082,7 +1166,8 @@ static const GOBGameDescription fallbackDescs[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB2 | GF_CD, + kGameTypeGob2, + kFeaturesCD, "intro" }, { @@ -1094,7 +1179,8 @@ static const GOBGameDescription fallbackDescs[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_BARGON, + kGameTypeBargon, + kFeaturesNone, "intro" }, { @@ -1106,7 +1192,8 @@ static const GOBGameDescription fallbackDescs[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB3, + kGameTypeGob3, + kFeaturesAdlib, "intro" }, { @@ -1118,7 +1205,8 @@ static const GOBGameDescription fallbackDescs[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - GF_GOB3 | GF_CD, + kGameTypeGob3, + kFeaturesCD, "intro" }, }; @@ -1186,6 +1274,7 @@ bool GobEngine::detectGame() { strcat(_startTot0, "0.tot"); } + _gameType = gd->gameType; _features = gd->features; _language = gd->desc.language; _platform = gd->desc.platform; diff --git a/engines/gob/game.cpp b/engines/gob/game.cpp index 795484ef0e..83c74626cd 100644 --- a/engines/gob/game.cpp +++ b/engines/gob/game.cpp @@ -315,11 +315,12 @@ void Game::evaluateScroll(int16 x, int16 y) { } int16 cursorRight = x + _vm->_draw->_cursorWidth; - int16 screenRight = _vm->_draw->_scrollOffsetX + 320; + int16 screenRight = _vm->_draw->_scrollOffsetX + _vm->_width; int16 cursorBottom = y + _vm->_draw->_cursorHeight; - int16 screenBottom = _vm->_draw->_scrollOffsetY + 200; + int16 screenBottom = _vm->_draw->_scrollOffsetY + _vm->_height; - if ((cursorRight >= 320) && (screenRight < _vm->_video->_surfWidth)) { + if ((cursorRight >= _vm->_width) && + (screenRight < _vm->_video->_surfWidth)) { uint16 off; off = MIN(_vm->_draw->_cursorWidth, @@ -328,8 +329,8 @@ void Game::evaluateScroll(int16 x, int16 y) { _vm->_draw->_scrollOffsetX += off; - _vm->_util->setMousePos(320 - _vm->_draw->_cursorWidth, y); - } else if ((cursorBottom >= (200 - _vm->_video->_splitHeight2)) && + _vm->_util->setMousePos(_vm->_width - _vm->_draw->_cursorWidth, y); + } else if ((cursorBottom >= (_vm->_height - _vm->_video->_splitHeight2)) && (screenBottom < _vm->_video->_surfHeight)) { uint16 off; @@ -339,7 +340,7 @@ void Game::evaluateScroll(int16 x, int16 y) { _vm->_draw->_scrollOffsetY += off; - _vm->_util->setMousePos(x, 200 - _vm->_video->_splitHeight2 - + _vm->_util->setMousePos(x, _vm->_height - _vm->_video->_splitHeight2 - _vm->_draw->_cursorHeight); } @@ -544,7 +545,7 @@ void Game::switchTotSub(int16 index, int16 skipPlay) { int16 newPos = _curBackupPos - index - ((index >= 0) ? 1 : 0); // WORKAROUND: Some versions don't make the MOVEMENT menu item unselectable // in the dreamland screen, resulting in a crash when it's clicked. - if ((_vm->_features & GF_GOB2) && (index == -1) && (skipPlay == 7) && + if ((_vm->getGameType() == kGameTypeGob2) && (index == -1) && (skipPlay == 7) && !scumm_stricmp(_curTotFileArray[newPos], "gob06.tot")) return; diff --git a/engines/gob/global.cpp b/engines/gob/global.cpp index ec2fa6b043..f3bc0611fd 100644 --- a/engines/gob/global.cpp +++ b/engines/gob/global.cpp @@ -112,7 +112,7 @@ Global::Global(GobEngine *vm) : _vm(vm) { _setAllPalette = false; _dontSetPalette = false; - _primarySurfDesc = new SurfaceDesc(0x13, 320, 200); + _primarySurfDesc = 0; _debugFlag = 0; _inVM = 0; diff --git a/engines/gob/gob.cpp b/engines/gob/gob.cpp index 32caca31d8..faec700145 100644 --- a/engines/gob/gob.cpp +++ b/engines/gob/gob.cpp @@ -68,6 +68,16 @@ const Common::Language GobEngine::_gobToScummVMLang[] = { }; GobEngine::GobEngine(OSystem *syst) : Engine(syst) { + _vm = this; + + _snd = 0; _adlib = 0; _mult = 0; + _game = 0; _global = 0; _cdrom = 0; + _dataIO = 0; _goblin = 0; _imdPlayer = 0; + _init = 0; _inter = 0; _map = 0; + _palAnim = 0; _parse = 0; _scenery = 0; + _draw = 0; _util = 0; _video = 0; + _saveLoad = 0; + // Setup mixer if (!_mixer->isReady()) { warning("Sound initialization failed."); @@ -94,25 +104,7 @@ GobEngine::~GobEngine() { // Stop all mixer streams (except for the permanent ones). _vm->_mixer->stopAll(); - delete _snd; - delete _adlib; - delete _mult; - delete _game; - delete _global; - delete _cdrom; - delete _dataIO; - delete _goblin; - delete _imdPlayer; - delete _init; - delete _inter; - delete _map; - delete _palAnim; - delete _parse; - delete _scenery; - delete _draw; - delete _util; - delete _video; - delete _saveLoad; + deinitGameParts(); delete[] _startTot; delete[] _startTot0; } @@ -137,7 +129,7 @@ void GobEngine::validateLanguage() { } void GobEngine::validateVideoMode(int16 videoMode) { - if ((videoMode != 0x13) && (videoMode != 0x14)) + if ((videoMode != 0x13) && (videoMode != 0x14) && (videoMode != 0x18)) error("Video mode 0x%X is not supported!", videoMode); } @@ -148,82 +140,18 @@ int GobEngine::init() { return -1; } - _adlib = 0; - _saveLoad = 0; - _global = new Global(this); - _util = new Util(this); - _dataIO = new DataIO(this); - _palAnim = new PalAnim(this); - _imdPlayer = new ImdPlayer(this); - _cdrom = new CDROM(this); - _snd = new Snd(this); - if (_features & Gob::GF_GOB1) { - _init = new Init_v1(this); - _video = new Video_v1(this); - _inter = new Inter_v1(this); - _parse = new Parse_v1(this); - _mult = new Mult_v1(this); - _draw = new Draw_v1(this); - _game = new Game_v1(this); - _map = new Map_v1(this); - _goblin = new Goblin_v1(this); - _scenery = new Scenery_v1(this); - } else if (_features & Gob::GF_GOB2) { - _init = new Init_v2(this); - _video = new Video_v2(this); - _inter = new Inter_v2(this); - _parse = new Parse_v2(this); - _mult = new Mult_v2(this); - _draw = new Draw_v2(this); - _game = new Game_v2(this); - _map = new Map_v2(this); - _goblin = new Goblin_v2(this); - _scenery = new Scenery_v2(this); - _saveLoad = new SaveLoad_v2(this, _targetName.c_str()); - } else if (_features & Gob::GF_BARGON) { - _init = new Init_v2(this); - _video = new Video_v2(this); - _inter = new Inter_Bargon(this); - _parse = new Parse_v2(this); - _mult = new Mult_v2(this); - _draw = new Draw_Bargon(this); - _game = new Game_v2(this); - _map = new Map_v2(this); - _goblin = new Goblin_v2(this); - _scenery = new Scenery_v2(this); - _saveLoad = new SaveLoad_v2(this, _targetName.c_str()); - } else if (_features & Gob::GF_GOB3) { - _init = new Init_v3(this); - _video = new Video_v2(this); - _inter = new Inter_v3(this); - _parse = new Parse_v2(this); - _mult = new Mult_v2(this); - _draw = new Draw_v2(this); - _game = new Game_v2(this); - _map = new Map_v2(this); - _goblin = new Goblin_v3(this); - _scenery = new Scenery_v2(this); - _saveLoad = new SaveLoad_v3(this, _targetName.c_str()); - } else - error("GobEngine::init(): Unknown version of game engine"); - - _noMusic = MidiDriver::parseMusicDriver(ConfMan.get("music_driver")) == MD_NULL; - if (!_noMusic && !(_platform == Common::kPlatformAmiga) && - !(_platform == Common::kPlatformAtariST) && - (((_platform == Common::kPlatformMacintosh) && (_features & Gob::GF_GOB1)) || - (_features & Gob::GF_GOB2) || (_features & Gob::GF_GOB3))) - _adlib = new Adlib(this); - _vm = this; - - _map->init(); + if (!initGameParts()) { + GUIErrorMessage("GobEngine::init(): Unknown version of game engine"); + return -1; + } _system->beginGFXTransaction(); initCommonGFX(false); - _system->initSize(320, 200); + _system->initSize(_width, _height); _system->endGFXTransaction(); // On some systems it's not safe to run CD audio games from the CD. - if (_features & GF_CD) + if (isCD()) checkCD(); int cd_num = ConfMan.getInt("cdrom"); @@ -293,4 +221,153 @@ int GobEngine::init() { return 0; } +bool GobEngine::initGameParts() { + _adlib = 0; + _saveLoad = 0; + + _global = new Global(this); + _util = new Util(this); + _dataIO = new DataIO(this); + _palAnim = new PalAnim(this); + _imdPlayer = new ImdPlayer(this); + _cdrom = new CDROM(this); + _snd = new Snd(this); + + switch (_gameType) { + case kGameTypeGob1: + _init = new Init_v1(this); + _video = new Video_v1(this); + _inter = new Inter_v1(this); + _parse = new Parse_v1(this); + _mult = new Mult_v1(this); + _draw = new Draw_v1(this); + _game = new Game_v1(this); + _map = new Map_v1(this); + _goblin = new Goblin_v1(this); + _scenery = new Scenery_v1(this); + break; + + case kGameTypeGob2: + _init = new Init_v2(this); + _video = new Video_v2(this); + _inter = new Inter_v2(this); + _parse = new Parse_v2(this); + _mult = new Mult_v2(this); + _draw = new Draw_v2(this); + _game = new Game_v2(this); + _map = new Map_v2(this); + _goblin = new Goblin_v2(this); + _scenery = new Scenery_v2(this); + _saveLoad = new SaveLoad_v2(this, _targetName.c_str()); + break; + + case kGameTypeGob3: + _init = new Init_v3(this); + _video = new Video_v2(this); + _inter = new Inter_v3(this); + _parse = new Parse_v2(this); + _mult = new Mult_v2(this); + _draw = new Draw_v2(this); + _game = new Game_v2(this); + _map = new Map_v2(this); + _goblin = new Goblin_v3(this); + _scenery = new Scenery_v2(this); + _saveLoad = new SaveLoad_v3(this, _targetName.c_str()); + break; + + case kGameTypeWoodruff: + _init = new Init_v3(this); + _video = new Video_v2(this); + _inter = new Inter_v3(this); + _parse = new Parse_v2(this); + _mult = new Mult_v2(this); + _draw = new Draw_v2(this); + _game = new Game_v2(this); + _map = new Map_v2(this); + _goblin = new Goblin_v3(this); + _scenery = new Scenery_v2(this); + _saveLoad = new SaveLoad_v3(this, _targetName.c_str()); + break; + + case kGameTypeBargon: + _init = new Init_v2(this); + _video = new Video_v2(this); + _inter = new Inter_Bargon(this); + _parse = new Parse_v2(this); + _mult = new Mult_v2(this); + _draw = new Draw_Bargon(this); + _game = new Game_v2(this); + _map = new Map_v2(this); + _goblin = new Goblin_v2(this); + _scenery = new Scenery_v2(this); + _saveLoad = new SaveLoad_v2(this, _targetName.c_str()); + break; + + case kGameTypeWeen: + _init = new Init_v2(this); + _video = new Video_v2(this); + _inter = new Inter_v2(this); + _parse = new Parse_v2(this); + _mult = new Mult_v2(this); + _draw = new Draw_v2(this); + _game = new Game_v2(this); + _map = new Map_v2(this); + _goblin = new Goblin_v2(this); + _scenery = new Scenery_v2(this); + _saveLoad = new SaveLoad_v2(this, _targetName.c_str()); + break; + + default: + deinitGameParts(); + return false; + break; + } + + _noMusic = MidiDriver::parseMusicDriver(ConfMan.get("music_driver")) == MD_NULL; + if (!_noMusic && hasAdlib()) + _adlib = new Adlib(this); + + _map->init(); + + if (is640()) { + _video->_surfWidth = _width = 640; + _video->_surfHeight = _video->_splitHeight1 = _height = 480; + _global->_mouseMaxCol = 640; + _global->_mouseMaxRow = 480; + _mode = 0x18; + _global->_primarySurfDesc = new SurfaceDesc(0x18, 640, 480); + } else { + _video->_surfWidth = _width = 320; + _video->_surfHeight = _video->_splitHeight1 = _height = 200; + _global->_mouseMaxCol = 320; + _global->_mouseMaxRow = 200; + _mode = 0x14; + _global->_primarySurfDesc = new SurfaceDesc(0x14, 320, 200); + } + + return true; +} + +void GobEngine::deinitGameParts() { + delete _snd; _snd = 0; + delete _adlib; _adlib = 0; + delete _mult; _mult = 0; + delete _game; _game = 0; + delete _global; _global = 0; + delete _cdrom; _cdrom = 0; + delete _dataIO; _dataIO = 0; + delete _goblin; _goblin = 0; + delete _imdPlayer; _imdPlayer = 0; + delete _init; _init = 0; + delete _inter; _inter = 0; + delete _map; _map = 0; + delete _palAnim; _palAnim = 0; + delete _parse; _parse = 0; + delete _scenery; _scenery = 0; + delete _draw; _draw = 0; + delete _util; _util = 0; + delete _video; _video = 0; + delete _saveLoad; _saveLoad = 0; +} + } // End of namespace Gob diff --git a/engines/gob/gob.h b/engines/gob/gob.h index 97ee312bff..8c9583c95d 100644 --- a/engines/gob/gob.h +++ b/engines/gob/gob.h @@ -78,14 +78,22 @@ class Adlib; #define VAR(var) READ_VAR_UINT32(var) #define VAR_ADDRESS(var) ((uint32 *) VARP((var) << 2)) -enum { - GF_GOB1 = 1 << 0, - GF_GOB2 = 1 << 1, - GF_GOB3 = 1 << 2, - GF_WOODRUFF = 1 << 3, - GF_BARGON = 1 << 4, - GF_CD = 1 << 5, - GF_EGA = 1 << 6 +enum GameType { + kGameTypeNone = 0, + kGameTypeGob1, + kGameTypeGob2, + kGameTypeGob3, + kGameTypeWoodruff, + kGameTypeBargon, + kGameTypeWeen +}; + +enum Features { + kFeaturesNone = 0, + kFeaturesCD = 1 << 0, + kFeaturesEGA = 1 << 1, + kFeaturesAdlib = 1 << 2, + kFeatures640 = 1 << 3 }; enum { @@ -165,6 +173,9 @@ protected: int go(); int init(); + bool initGameParts(); + void deinitGameParts(); + bool detectGame(); public: @@ -172,9 +183,15 @@ public: Common::RandomSource _rnd; + GameType _gameType; int32 _features; Common::Language _language; Common::Platform _platform; + + uint16 _width; + uint16 _height; + uint8 _mode; + char *_startTot; char *_startTot0; bool _copyProtection; @@ -211,6 +228,12 @@ public: void validateLanguage(); void validateVideoMode(int16 videoMode); + GameType getGameType() { return _gameType; } + bool isCD() { return (_features & kFeaturesCD) != 0; } + bool isEGA() { return (_features & kFeaturesEGA) != 0; } + bool is640() { return (_features & kFeatures640) != 0; } + bool hasAdlib() { return (_features & kFeaturesAdlib) != 0; } + GobEngine(OSystem *syst); virtual ~GobEngine(); }; diff --git a/engines/gob/inter.cpp b/engines/gob/inter.cpp index 1f529b7634..4da3746681 100644 --- a/engines/gob/inter.cpp +++ b/engines/gob/inter.cpp @@ -209,7 +209,7 @@ void Inter::funcBlock(int16 retFlag) { // WORKAROUND: // The EGA version of gob1 doesn't add a delay after showing // images between levels. We manually add it here. - if ((_vm->_features & GF_GOB1) && (_vm->_features & GF_EGA)) { + if ((_vm->getGameType() == kGameTypeGob1) && _vm->isEGA()) { int addr = _vm->_global->_inter_execPtr-_vm->_game->_totFileData; if ((startaddr == 0x18B4 && addr == 0x1A7F && // Zombie !strncmp(_vm->_game->_curTotFile, "avt005.tot", 10)) || diff --git a/engines/gob/inter_v1.cpp b/engines/gob/inter_v1.cpp index a3277047e7..0339cb7f44 100644 --- a/engines/gob/inter_v1.cpp +++ b/engines/gob/inter_v1.cpp @@ -1136,13 +1136,13 @@ bool Inter_v1::o1_callSub(OpFuncParams ¶ms) { } // Skipping the copy protection screen in Gobliiins - if (!_vm->_copyProtection && (_vm->_features & GF_GOB1) && (offset == 3905) + if (!_vm->_copyProtection && (_vm->getGameType() == kGameTypeGob1) && (offset == 3905) && !scumm_stricmp(_vm->_game->_curTotFile, _vm->_startTot)) { debugC(2, kDebugGameFlow, "Skipping copy protection screen"); return false; } // Skipping the copy protection screen in Gobliins 2 - if (!_vm->_copyProtection && (_vm->_features & GF_GOB2) && (offset == 1746) + if (!_vm->_copyProtection && (_vm->getGameType() == kGameTypeGob2) && (offset == 1746) && !scumm_stricmp(_vm->_game->_curTotFile, _vm->_startTot0)) { debugC(2, kDebugGameFlow, "Skipping copy protection screen"); return false; @@ -1650,8 +1650,9 @@ bool Inter_v1::o1_keyFunc(OpFuncParams ¶ms) { // WORKAROUND for bug #1726130: Ween busy-waits in the intro for a counter // to become 5000. We deliberately slow down busy-waiting, so we shorten // the counting, too. - if (((_vm->_global->_inter_execPtr - _vm->_game->_totFileData) == 729) && - (VAR(59) < 4000) && !scumm_stricmp(_vm->_game->_curTotFile, "intro5.tot")) + if ((_vm->getGameType() == kGameTypeWeen) && (VAR(59) < 4000) && + ((_vm->_global->_inter_execPtr - _vm->_game->_totFileData) == 729) && + !scumm_stricmp(_vm->_game->_curTotFile, "intro5.tot")) WRITE_VAR(59, 4000); switch (cmd) { diff --git a/engines/gob/inter_v2.cpp b/engines/gob/inter_v2.cpp index bf103e68ef..9fe5904ff7 100644 --- a/engines/gob/inter_v2.cpp +++ b/engines/gob/inter_v2.cpp @@ -1379,7 +1379,7 @@ void Inter_v2::o2_initScreen() { // Some versions require this if (videoMode == 0xD) - videoMode = 0x14; + videoMode = _vm->_mode; if ((videoMode == _vm->_global->_videoMode) && (width == -1)) return; @@ -1389,7 +1389,8 @@ void Inter_v2::o2_initScreen() { if (height > 0) _vm->_video->_surfHeight = height; - _vm->_video->_splitHeight1 = MIN(200, _vm->_video->_surfHeight - offY); + _vm->_video->_splitHeight1 = + MIN(_vm->_height, _vm->_video->_surfHeight - offY); _vm->_video->_splitHeight2 = offY; _vm->_video->_splitStart = _vm->_video->_surfHeight - offY; @@ -1425,13 +1426,13 @@ void Inter_v2::o2_scroll() { int16 curY; startX = CLIP((int) _vm->_parse->parseValExpr(), 0, - _vm->_video->_surfWidth - 320); + _vm->_video->_surfWidth - _vm->_width); startY = CLIP((int) _vm->_parse->parseValExpr(), 0, - _vm->_video->_surfHeight - 200); + _vm->_video->_surfHeight - _vm->_height); endX = CLIP((int) _vm->_parse->parseValExpr(), 0, - _vm->_video->_surfWidth - 320); + _vm->_video->_surfWidth - _vm->_width); endY = CLIP((int) _vm->_parse->parseValExpr(), 0, - _vm->_video->_surfHeight - 200); + _vm->_video->_surfHeight - _vm->_height); stepX = _vm->_parse->parseValExpr(); stepY = _vm->_parse->parseValExpr(); diff --git a/engines/gob/map.cpp b/engines/gob/map.cpp index 3c1895d099..5485d66987 100644 --- a/engines/gob/map.cpp +++ b/engines/gob/map.cpp @@ -261,7 +261,7 @@ void Map::findNearestWalkable(int16 &gobDestX, int16 &gobDestY, int i; mapWidth = _screenWidth / _tilesWidth; - mapHeight = 200 / _tilesHeight; + mapHeight = _vm->_width / _tilesHeight; direction = 0; for (i = 1; i <= gobDestX; i++) diff --git a/engines/gob/video.cpp b/engines/gob/video.cpp index 6f88a5a993..83cd436b8a 100644 --- a/engines/gob/video.cpp +++ b/engines/gob/video.cpp @@ -166,11 +166,11 @@ void Video::retrace(bool mouse) { if (_vm->_global->_primarySurfDesc) { g_system->copyRectToScreen(_vm->_global->_primarySurfDesc->getVidMem() + _scrollOffsetY * _surfWidth + _scrollOffsetX, _surfWidth, - 0, 0, 320, _splitHeight1); + 0, 0, _vm->_width, _splitHeight1); if (_splitHeight2 > 0) g_system->copyRectToScreen(_vm->_global->_primarySurfDesc->getVidMem() + _splitStart * _surfWidth, _surfWidth, 0, - 200 - _splitHeight2, 320, _splitHeight2); + _vm->_height - _splitHeight2, _vm->_width, _splitHeight2); g_system->updateScreen(); } } -- cgit v1.2.3 From e0ead7947deb937bcb6e1562e43e9125e78e971b Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Tue, 24 Jul 2007 23:42:07 +0000 Subject: Oops, forgot I've modified the entries for testing svn-id: r28186 --- engines/gob/detection.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/gob/detection.cpp b/engines/gob/detection.cpp index a82041ce0e..d399262a95 100644 --- a/engines/gob/detection.cpp +++ b/engines/gob/detection.cpp @@ -1084,7 +1084,7 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - kGameTypeNone, + kGameTypeWoodruff, kFeatures640 | kFeaturesAdlib, "intro" }, @@ -1097,7 +1097,7 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - kGameTypeNone, + kGameTypeWoodruff, kFeatures640 | kFeaturesAdlib, "intro" }, @@ -1110,7 +1110,7 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - kGameTypeNone, + kGameTypeWoodruff, kFeatures640 | kFeaturesAdlib, "intro" }, -- cgit v1.2.3 From 7490b935c5ca769f52c13e92d07f05f8c430836f Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Wed, 25 Jul 2007 00:01:31 +0000 Subject: - Removed Adlib from Woodruff's freatures - Added a fallback for Woodruff svn-id: r28187 --- engines/gob/detection.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/gob/detection.cpp b/engines/gob/detection.cpp index d399262a95..93a2b82773 100644 --- a/engines/gob/detection.cpp +++ b/engines/gob/detection.cpp @@ -1085,7 +1085,7 @@ static const GOBGameDescription gameDescriptions[] = { Common::ADGF_NO_FLAGS }, kGameTypeWoodruff, - kFeatures640 | kFeaturesAdlib, + kFeatures640, "intro" }, { @@ -1098,7 +1098,7 @@ static const GOBGameDescription gameDescriptions[] = { Common::ADGF_NO_FLAGS }, kGameTypeWoodruff, - kFeatures640 | kFeaturesAdlib, + kFeatures640, "intro" }, { @@ -1111,7 +1111,7 @@ static const GOBGameDescription gameDescriptions[] = { Common::ADGF_NO_FLAGS }, kGameTypeWoodruff, - kFeatures640 | kFeaturesAdlib, + kFeatures640, "intro" }, { AD_TABLE_END_MARKER, kGameTypeNone, kFeaturesNone, NULL } @@ -1209,6 +1209,19 @@ static const GOBGameDescription fallbackDescs[] = { kFeaturesCD, "intro" }, + { + { + "woodruff", + "unknown", + AD_ENTRY1(0, 0), + UNK_LANG, + kPlatformPC, + Common::ADGF_NO_FLAGS + }, + kGameTypeWoodruff, + kFeatures640, + "intro" + }, }; static const ADFileBasedFallback fileBased[] = { @@ -1220,6 +1233,7 @@ static const ADFileBasedFallback fileBased[] = { { &fallbackDescs[4], { "intro.stk", "scaa.imd", "scba.imd", "scbf.imd", 0 } }, { &fallbackDescs[5], { "intro.stk", "imd.itk", 0 } }, { &fallbackDescs[6], { "intro.stk", "mus_gob3.lic", 0 } }, + { &fallbackDescs[7], { "intro.stk", "woodruff.itk", 0 } }, { 0, { 0 } } }; -- cgit v1.2.3 From 5c588e1f5e4b80fb345f14a3a2cafcf8c6fdc352 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Wed, 25 Jul 2007 04:52:12 +0000 Subject: Updated loadExtData() for Woodruff. Now the Sierra logo is shown (then it crashes / freezes) svn-id: r28188 --- engines/gob/game.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/gob/game.cpp b/engines/gob/game.cpp index 83c74626cd..561330deac 100644 --- a/engines/gob/game.cpp +++ b/engines/gob/game.cpp @@ -140,8 +140,18 @@ byte *Game::loadExtData(int16 itemId, int16 *pResWidth, size = item->size; isPacked = (item->width & 0x8000) != 0; - if (pResWidth != 0) { + if ((pResWidth != 0) && (pResHeight != 0)) { *pResWidth = item->width & 0x7FFF; + + if (*pResWidth & 0x4000) + size += 1 << 16; + if (*pResWidth & 0x2000) + size += 2 << 16; + if (*pResWidth & 0x1000) + size += 4 << 16; + + *pResWidth &= 0xFFF; + *pResHeight = item->height; debugC(7, kDebugFileIO, "loadExtData(%d, %d, %d)", itemId, *pResWidth, *pResHeight); -- cgit v1.2.3 From cf3719d613a0947ce46b5541e378532b4cbcf394 Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Wed, 25 Jul 2007 11:29:47 +0000 Subject: Add eriktorbjorn's patch for bug #1498158 - AOGS: Itemheap overflow on 64bit systems. svn-id: r28189 --- engines/agos/agos.cpp | 16 ++++++++++------ engines/agos/agos.h | 5 ++--- engines/agos/items.cpp | 19 +++++-------------- 3 files changed, 17 insertions(+), 23 deletions(-) (limited to 'engines') diff --git a/engines/agos/agos.cpp b/engines/agos/agos.cpp index ae7f692c3f..ba429b510c 100644 --- a/engines/agos/agos.cpp +++ b/engines/agos/agos.cpp @@ -148,10 +148,6 @@ AGOSEngine::AGOSEngine(OSystem *syst) _itemArraySize = 0; _itemArrayInited = 0; - _itemHeapPtr = 0; - _itemHeapCurPos = 0; - _itemHeapSize = 0; - _iconFilePtr = 0; _codePtr = 0; @@ -920,7 +916,11 @@ AGOSEngine::~AGOSEngine() { _midi.close(); - free(_itemHeapPtr - _itemHeapCurPos); + for (uint i = 0; i < _itemHeap.size(); i++) { + delete [] _itemHeap[i]; + } + _itemHeap.clear(); + free(_tablesHeapPtr - _tablesHeapCurPos); free(_gameOffsetsPtr); @@ -1054,7 +1054,11 @@ void AGOSEngine::shutdown() { _midi.close(); - free(_itemHeapPtr - _itemHeapCurPos); + for (uint i = 0; i < _itemHeap.size(); i++) { + delete [] _itemHeap[i]; + } + _itemHeap.clear(); + free(_tablesHeapPtr - _tablesHeapCurPos); free(_gameOffsetsPtr); diff --git a/engines/agos/agos.h b/engines/agos/agos.h index d233d0bfeb..bf64a3bf84 100644 --- a/engines/agos/agos.h +++ b/engines/agos/agos.h @@ -28,6 +28,7 @@ #include "engines/engine.h" +#include "common/array.h" #include "common/keyboard.h" #include "common/rect.h" #include "common/util.h" @@ -231,9 +232,7 @@ protected: uint _itemArraySize; uint _itemArrayInited; - byte *_itemHeapPtr; - uint _itemHeapCurPos; - uint _itemHeapSize; + Common::Array _itemHeap; byte *_iconFilePtr; diff --git a/engines/agos/items.cpp b/engines/agos/items.cpp index 9a46b6e8ac..13034b74c9 100644 --- a/engines/agos/items.cpp +++ b/engines/agos/items.cpp @@ -42,24 +42,15 @@ Child *AGOSEngine::allocateChildBlock(Item *i, uint type, uint size) { } byte *AGOSEngine::allocateItem(uint size) { - byte *org = _itemHeapPtr; - size = (size + sizeof(void*) - 1) & ~(sizeof(void*) - 1); + byte *item = new byte[size]; - _itemHeapPtr += size; - _itemHeapCurPos += size; - - if (_itemHeapCurPos > _itemHeapSize) - error("allocateItem: Itemheap overflow"); - - return org; + memset(item, 0, size); + _itemHeap.push_back(item); + return item; } void AGOSEngine::allocItemHeap() { - _itemHeapSize = _itemMemSize; - _itemHeapCurPos = 0; - _itemHeapPtr = (byte *)calloc(_itemMemSize, 1); - if (!_itemHeapPtr) - error("Out Of Memory - Items"); + _itemHeap.clear(); } bool AGOSEngine::hasIcon(Item *item) { -- cgit v1.2.3 From 3b9286784808f5fbbc2cb1858bbb306c3c5c635c Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Wed, 25 Jul 2007 15:46:13 +0000 Subject: Added one (commented out) "The Last Dynasty" MD5 svn-id: r28190 --- engines/gob/detection.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'engines') diff --git a/engines/gob/detection.cpp b/engines/gob/detection.cpp index 93a2b82773..345c212895 100644 --- a/engines/gob/detection.cpp +++ b/engines/gob/detection.cpp @@ -54,6 +54,7 @@ static const PlainGameDescriptor gobGames[] = { {"bargon", "Bargon Attack"}, {"ween", "Ween: The Prophecy"}, {"woodruff", "The Bizarre Adventures of Woodruff and the Schnibble"}, +// {"dynasty", "The Last Dynasty"}, {0, 0} }; @@ -1114,6 +1115,19 @@ static const GOBGameDescription gameDescriptions[] = { kFeatures640, "intro" }, + /*{ + { + "dynasty", + "", + AD_ENTRY1s("intro.stk", "6190e32404b672f4bbbc39cf76f41fda", 2511470), + EN_USA, + kPlatformPC, + Common::ADGF_NO_FLAGS + }, + kGameTypeWoodruff, + kFeatures640, + "intro" + },*/ { AD_TABLE_END_MARKER, kGameTypeNone, kFeaturesNone, NULL } }; -- cgit v1.2.3 From 3bafb8cd61b7cde3f0b470f28c27675f420e8671 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Wed, 25 Jul 2007 16:00:23 +0000 Subject: Add A.J's World of Discovery. Compatibility is perfect. svn-id: r28191 --- engines/gob/detection.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'engines') diff --git a/engines/gob/detection.cpp b/engines/gob/detection.cpp index 345c212895..f793dbaca5 100644 --- a/engines/gob/detection.cpp +++ b/engines/gob/detection.cpp @@ -51,6 +51,7 @@ static const PlainGameDescriptor gobGames[] = { {"gob2cd", "Gobliins 2 CD"}, {"gob3", "Goblins Quest 3"}, {"gob3cd", "Goblins Quest 3 CD"}, + {"ajworld", "A.J's World of Discovery"}, {"bargon", "Bargon Attack"}, {"ween", "Ween: The Prophecy"}, {"woodruff", "The Bizarre Adventures of Woodruff and the Schnibble"}, @@ -812,6 +813,19 @@ static const GOBGameDescription gameDescriptions[] = { kFeaturesNone, "intro" }, + { + { + "ajworld", + "", + AD_ENTRY1s("intro.stk", "e453bea7b28a67c930764d945f64d898", 3913628), + EN_ANY, + kPlatformPC, + Common::ADGF_NO_FLAGS + }, + kGameTypeGob2, + kFeaturesNone, + "intro" + }, { { "gob3", -- cgit v1.2.3 From 4f403f4dd356693b1ca3ef02d3b17ef8fef118e7 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Wed, 25 Jul 2007 16:12:19 +0000 Subject: Use default to 1x scaler for 640x480 games to avoid superbig resolutions. svn-id: r28197 --- engines/gob/gob.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/gob/gob.cpp b/engines/gob/gob.cpp index faec700145..18cbb9f551 100644 --- a/engines/gob/gob.cpp +++ b/engines/gob/gob.cpp @@ -146,8 +146,8 @@ int GobEngine::init() { } _system->beginGFXTransaction(); - initCommonGFX(false); _system->initSize(_width, _height); + initCommonGFX(is640()); _system->endGFXTransaction(); // On some systems it's not safe to run CD audio games from the CD. -- cgit v1.2.3 From 0998a2440afa101f9db1ee141f3674f8fbd85c4e Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Wed, 25 Jul 2007 19:56:43 +0000 Subject: The drawStripToScreen() does nothing if width <= 0. In bug #1759925 ("COMI: 100% crash in SVN (not in 0.X.0)"), height was a fairly large negative number, so I've added a test for that condition as well. This seems to fix the bug. svn-id: r28199 --- engines/scumm/gfx.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/scumm/gfx.cpp b/engines/scumm/gfx.cpp index 4e7276f2d0..c1e06609b9 100644 --- a/engines/scumm/gfx.cpp +++ b/engines/scumm/gfx.cpp @@ -560,7 +560,7 @@ void ScummEngine::drawStripToScreen(VirtScreen *vs, int x, int width, int top, i int y = vs->topline + top - _screenTop; int height = bottom - top; - if (width <= 0) + if (width <= 0 || height <= 0) return; const byte *src = vs->getPixels(x, top); -- cgit v1.2.3 From 12bec1c4948760aabaa1c8f83f731f9bfc88903d Mon Sep 17 00:00:00 2001 From: Gregory Montoir Date: Wed, 25 Jul 2007 20:03:31 +0000 Subject: workaround for bug #1751149 (original game issue). svn-id: r28200 --- engines/touche/opcodes.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/touche/opcodes.cpp b/engines/touche/opcodes.cpp index f0ef748fbd..2680ab0fae 100644 --- a/engines/touche/opcodes.cpp +++ b/engines/touche/opcodes.cpp @@ -828,10 +828,16 @@ void ToucheEngine::op_setHitBoxText() { void ToucheEngine::op_fadePalette() { debugC(9, kDebugOpcodes, "ToucheEngine::op_fadePalette()"); int16 fadeOut = _script.readNextWord(); + int colorsCount = 240; + // Workaround for bug #1751149. Script triggers a palette fading, but some + // of the room graphics use palette colors >= 240. + if (_currentEpisodeNum == 104 && _currentRoomNum == 68) { + colorsCount = 256; + } if (fadeOut) { - fadePalette(0, 240, 255, -2, 128); + fadePalette(0, colorsCount, 255, -2, 128); } else { - fadePalette(0, 240, 0, 2, 128); + fadePalette(0, colorsCount, 0, 2, 128); } } -- cgit v1.2.3 From d88354a8533c36c4187ba856807a488e3b53981f Mon Sep 17 00:00:00 2001 From: Gregory Montoir Date: Wed, 25 Jul 2007 20:05:35 +0000 Subject: renamed wrongly named parameter svn-id: r28201 --- engines/touche/touche.cpp | 4 ++-- engines/touche/touche.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/touche/touche.cpp b/engines/touche/touche.cpp index fce2c8ed1b..086671d371 100644 --- a/engines/touche/touche.cpp +++ b/engines/touche/touche.cpp @@ -869,11 +869,11 @@ void ToucheEngine::redrawRoom() { } } -void ToucheEngine::fadePalette(int firstColor, int lastColor, int scale, int scaleInc, int fadingStepsCount) { +void ToucheEngine::fadePalette(int firstColor, int colorCount, int scale, int scaleInc, int fadingStepsCount) { for (int i = 0; i < fadingStepsCount; ++i) { scale += scaleInc; scale = CLIP(scale, 0, 255); - setPalette(firstColor, lastColor, scale, scale, scale); + setPalette(firstColor, colorCount, scale, scale, scale); _system->updateScreen(); _system->delayMillis(10); } diff --git a/engines/touche/touche.h b/engines/touche/touche.h index ed346cd3b9..5aef0ef613 100644 --- a/engines/touche/touche.h +++ b/engines/touche/touche.h @@ -390,7 +390,7 @@ protected: void centerScreenToKeyChar(int keyChar); void waitForKeyCharsSet(); void redrawRoom(); - void fadePalette(int firstColor, int lastColor, int scale, int scaleInc, int fadingStepsCount); + void fadePalette(int firstColor, int colorCount, int scale, int scaleInc, int fadingStepsCount); void fadePaletteFromFlags(); void moveKeyChar(uint8 *dst, int dstPitch, KeyChar *key); void changeKeyCharFrame(KeyChar *key, int keyChar); -- cgit v1.2.3 From 99a707d89e62ef4a59a58e0e946ae3db9fe804fa Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Wed, 25 Jul 2007 20:36:14 +0000 Subject: Added a few safety checks. Now Woodruff shows the loading image (closely followed by a crash). svn-id: r28203 --- engines/gob/dataio.h | 2 +- engines/gob/game.cpp | 6 +++++- engines/gob/game.h | 2 +- engines/gob/game_v2.cpp | 8 ++++++-- engines/gob/inter_v1.cpp | 8 ++++++++ 5 files changed, 21 insertions(+), 5 deletions(-) (limited to 'engines') diff --git a/engines/gob/dataio.h b/engines/gob/dataio.h index 3ea29c0efe..08498a4f7e 100644 --- a/engines/gob/dataio.h +++ b/engines/gob/dataio.h @@ -35,7 +35,7 @@ namespace Gob { #define MAX_FILES 30 #define MAX_DATA_FILES 8 -#define MAX_SLOT_COUNT 4 +#define MAX_SLOT_COUNT 8 class DataIO { public: diff --git a/engines/gob/game.cpp b/engines/gob/game.cpp index 561330deac..a5993fd1de 100644 --- a/engines/gob/game.cpp +++ b/engines/gob/game.cpp @@ -663,7 +663,7 @@ int16 Game::openLocTextFile(char *locTextFile, int language) { return _vm->_dataIO->openData(locTextFile); } -byte *Game::loadLocTexts(void) { +byte *Game::loadLocTexts(int32 *dataSize) { char locTextFile[20]; int16 handle; int i; @@ -689,6 +689,10 @@ byte *Game::loadLocTexts(void) { if (handle >= 0) { _vm->_dataIO->closeData(handle); + + if (dataSize) + *dataSize = _vm->_dataIO->getDataSize(locTextFile); + return _vm->_dataIO->getData(locTextFile); } return 0; diff --git a/engines/gob/game.h b/engines/gob/game.h index 2181d219f2..0cef993b40 100644 --- a/engines/gob/game.h +++ b/engines/gob/game.h @@ -215,7 +215,7 @@ protected: int16 adjustKey(int16 key); - byte *loadLocTexts(void); + byte *loadLocTexts(int32 *dataSize = 0); int32 loadTotFile(const char *path); void loadExtTable(void); void loadImFile(void); diff --git a/engines/gob/game_v2.cpp b/engines/gob/game_v2.cpp index 245c1f4544..d5c237c974 100644 --- a/engines/gob/game_v2.cpp +++ b/engines/gob/game_v2.cpp @@ -134,12 +134,16 @@ void Game_v2::playTot(int16 skipPlay) { totTextLoc = false; if (READ_LE_UINT32(filePtr) != (uint32) -1) { _totTextData = new TotTextTable; + + int32 size; + if (READ_LE_UINT32(filePtr) == 0) { - _totTextData->dataPtr = loadLocTexts(); + _totTextData->dataPtr = loadLocTexts(&size); totTextLoc = true; } else { _totTextData->dataPtr = (_totFileData + READ_LE_UINT32(_totFileData + 0x30)); + size = totSize; _vm->_global->_language = _vm->_global->_languageWanted; } @@ -147,7 +151,7 @@ void Game_v2::playTot(int16 skipPlay) { if (_totTextData->dataPtr != 0) { Common::MemoryReadStream totTextData(_totTextData->dataPtr, 4294967295U); - _totTextData->itemsCount = totTextData.readSint16LE(); + _totTextData->itemsCount = MIN(totTextData.readSint16LE(), (size - 2) / 4); _totTextData->items = new TotTextItem[_totTextData->itemsCount]; for (int i = 0; i < _totTextData->itemsCount; ++i) { diff --git a/engines/gob/inter_v1.cpp b/engines/gob/inter_v1.cpp index 0339cb7f44..bc7eb2ea11 100644 --- a/engines/gob/inter_v1.cpp +++ b/engines/gob/inter_v1.cpp @@ -1174,6 +1174,10 @@ bool Inter_v1::o1_loadCursor(OpFuncParams ¶ms) { id = load16(); index = (int8) *_vm->_global->_inter_execPtr++; + + if ((index * _vm->_draw->_cursorWidth) >= _vm->_draw->_cursorSprites->getWidth()) + return false; + itemPtr = &_vm->_game->_totResourceTable->items[id]; offset = itemPtr->offset; @@ -1896,6 +1900,10 @@ bool Inter_v1::o1_fillRect(OpFuncParams ¶ms) { _vm->_draw->_spriteBottom = _vm->_parse->parseValExpr(); _vm->_draw->_backColor = _vm->_parse->parseValExpr(); + + if (!_vm->_draw->_spritesArray[_vm->_draw->_destSurface]) + return false; + _vm->_draw->spriteOperation(DRAW_FILLRECT); return false; } -- cgit v1.2.3 From e151167dd89a3be0524103c83e49593242a6e66d Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Wed, 25 Jul 2007 21:02:30 +0000 Subject: Some more safety checks and the first room's background can be seen svn-id: r28204 --- engines/gob/goblin.cpp | 3 +++ engines/gob/goblin_v3.cpp | 3 +++ engines/gob/inter_v1.cpp | 4 ++++ engines/gob/scenery.cpp | 2 +- 4 files changed, 11 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/gob/goblin.cpp b/engines/gob/goblin.cpp index 418b31e2ee..1db741bd44 100644 --- a/engines/gob/goblin.cpp +++ b/engines/gob/goblin.cpp @@ -1698,6 +1698,9 @@ void Goblin::playSounds(Mult::Mult_Object *obj) { int16 sndSlot; int16 frame; + if (!obj->goblinStates) + return; + animData = obj->pAnimData; for (int i = 1; i <= obj->goblinStates[animData->state][0].dataCount; i++) { diff --git a/engines/gob/goblin_v3.cpp b/engines/gob/goblin_v3.cpp index 002ef7b749..f4aa872fa1 100644 --- a/engines/gob/goblin_v3.cpp +++ b/engines/gob/goblin_v3.cpp @@ -115,6 +115,9 @@ void Goblin_v3::placeObject(Gob_Object *objDesc, char animated, Mult::Mult_Object &obj = _vm->_mult->_objects[index]; Mult::Mult_AnimData &objAnim = *(obj.pAnimData); + if (!obj.goblinStates) + return; + if ((state != -1) && (obj.goblinStates[state] != 0)) { if (state == 8) objAnim.curLookDir = 0; diff --git a/engines/gob/inter_v1.cpp b/engines/gob/inter_v1.cpp index bc7eb2ea11..572f133e33 100644 --- a/engines/gob/inter_v1.cpp +++ b/engines/gob/inter_v1.cpp @@ -1705,6 +1705,10 @@ bool Inter_v1::o1_capturePush(OpFuncParams ¶ms) { top = _vm->_parse->parseValExpr(); width = _vm->_parse->parseValExpr(); height = _vm->_parse->parseValExpr(); + + if ((width < 0) || (height < 0)) + return false; + _vm->_game->capturePush(left, top, width, height); (*_vm->_scenery->_pCaptureCounter)++; return false; diff --git a/engines/gob/scenery.cpp b/engines/gob/scenery.cpp index ae04c220d3..95cf90bddc 100644 --- a/engines/gob/scenery.cpp +++ b/engines/gob/scenery.cpp @@ -320,7 +320,7 @@ void Scenery::updateStatic(int16 orderFrom, byte index, byte layer) { int16 top; int16 bottom; - if (layer >= _statics[index].layersCount) + if ((index >= 10) || layer >= _statics[index].layersCount) return; layerPtr = &_statics[index].layers[layer]; -- cgit v1.2.3 From 3d2c1c5ab860ca62adba669d56433de62a883a72 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Wed, 25 Jul 2007 21:48:47 +0000 Subject: - Added Inter_Woodruff, alongside with the first Stub (OpcodeFunc 0x18) - Yet another safety check - Removed another hard-coded screen height svn-id: r28205 --- engines/gob/gob.cpp | 44 +-- engines/gob/goblin_v2.cpp | 3 + engines/gob/inter.h | 37 +++ engines/gob/inter_woodruff.cpp | 730 +++++++++++++++++++++++++++++++++++++++++ engines/gob/module.mk | 1 + engines/gob/util.cpp | 4 +- 6 files changed, 795 insertions(+), 24 deletions(-) create mode 100644 engines/gob/inter_woodruff.cpp (limited to 'engines') diff --git a/engines/gob/gob.cpp b/engines/gob/gob.cpp index 18cbb9f551..8c3bb76413 100644 --- a/engines/gob/gob.cpp +++ b/engines/gob/gob.cpp @@ -261,60 +261,60 @@ bool GobEngine::initGameParts() { _saveLoad = new SaveLoad_v2(this, _targetName.c_str()); break; - case kGameTypeGob3: - _init = new Init_v3(this); + case kGameTypeBargon: + _init = new Init_v2(this); _video = new Video_v2(this); - _inter = new Inter_v3(this); + _inter = new Inter_Bargon(this); _parse = new Parse_v2(this); _mult = new Mult_v2(this); - _draw = new Draw_v2(this); + _draw = new Draw_Bargon(this); _game = new Game_v2(this); _map = new Map_v2(this); - _goblin = new Goblin_v3(this); + _goblin = new Goblin_v2(this); _scenery = new Scenery_v2(this); - _saveLoad = new SaveLoad_v3(this, _targetName.c_str()); + _saveLoad = new SaveLoad_v2(this, _targetName.c_str()); break; - case kGameTypeWoodruff: - _init = new Init_v3(this); + case kGameTypeWeen: + _init = new Init_v2(this); _video = new Video_v2(this); - _inter = new Inter_v3(this); + _inter = new Inter_v2(this); _parse = new Parse_v2(this); _mult = new Mult_v2(this); _draw = new Draw_v2(this); _game = new Game_v2(this); _map = new Map_v2(this); - _goblin = new Goblin_v3(this); + _goblin = new Goblin_v2(this); _scenery = new Scenery_v2(this); - _saveLoad = new SaveLoad_v3(this, _targetName.c_str()); + _saveLoad = new SaveLoad_v2(this, _targetName.c_str()); break; - case kGameTypeBargon: - _init = new Init_v2(this); + case kGameTypeGob3: + _init = new Init_v3(this); _video = new Video_v2(this); - _inter = new Inter_Bargon(this); + _inter = new Inter_v3(this); _parse = new Parse_v2(this); _mult = new Mult_v2(this); - _draw = new Draw_Bargon(this); + _draw = new Draw_v2(this); _game = new Game_v2(this); _map = new Map_v2(this); - _goblin = new Goblin_v2(this); + _goblin = new Goblin_v3(this); _scenery = new Scenery_v2(this); - _saveLoad = new SaveLoad_v2(this, _targetName.c_str()); + _saveLoad = new SaveLoad_v3(this, _targetName.c_str()); break; - case kGameTypeWeen: - _init = new Init_v2(this); + case kGameTypeWoodruff: + _init = new Init_v3(this); _video = new Video_v2(this); - _inter = new Inter_v2(this); + _inter = new Inter_Woodruff(this); _parse = new Parse_v2(this); _mult = new Mult_v2(this); _draw = new Draw_v2(this); _game = new Game_v2(this); _map = new Map_v2(this); - _goblin = new Goblin_v2(this); + _goblin = new Goblin_v3(this); _scenery = new Scenery_v2(this); - _saveLoad = new SaveLoad_v2(this, _targetName.c_str()); + _saveLoad = new SaveLoad_v3(this, _targetName.c_str()); break; default: diff --git a/engines/gob/goblin_v2.cpp b/engines/gob/goblin_v2.cpp index 67e9f65444..608b0f0790 100644 --- a/engines/gob/goblin_v2.cpp +++ b/engines/gob/goblin_v2.cpp @@ -314,6 +314,9 @@ void Goblin_v2::moveAdvance(Mult::Mult_Object *obj, Gob_Object *gobDesc, int16 state; int16 layer; + if (!obj->goblinStates) + return; + movePathFind(obj, 0, 0); playSounds(obj); diff --git a/engines/gob/inter.h b/engines/gob/inter.h index aedc442a49..70e0af2d4d 100644 --- a/engines/gob/inter.h +++ b/engines/gob/inter.h @@ -481,6 +481,43 @@ protected: bool o3_writeData(OpFuncParams ¶ms); }; +class Inter_Woodruff : public Inter_v3 { +public: + Inter_Woodruff(GobEngine *vm); + virtual ~Inter_Woodruff() {} + +protected: + typedef void (Inter_Woodruff::*OpcodeDrawProcWoodruff)(); + typedef bool (Inter_Woodruff::*OpcodeFuncProcWoodruff)(OpFuncParams &); + typedef void (Inter_Woodruff::*OpcodeGoblinProcWoodruff)(OpGobParams &); + struct OpcodeDrawEntryWoodruff { + OpcodeDrawProcWoodruff proc; + const char *desc; + }; + struct OpcodeFuncEntryWoodruff { + OpcodeFuncProcWoodruff proc; + const char *desc; + }; + struct OpcodeGoblinEntryWoodruff { + OpcodeGoblinProcWoodruff proc; + const char *desc; + }; + const OpcodeDrawEntryWoodruff *_opcodesDrawWoodruff; + const OpcodeFuncEntryWoodruff *_opcodesFuncWoodruff; + const OpcodeGoblinEntryWoodruff *_opcodesGoblinWoodruff; + static const int _goblinFuncLookUp[][2]; + + virtual void setupOpcodes(); + virtual void executeDrawOpcode(byte i); + virtual bool executeFuncOpcode(byte i, byte j, OpFuncParams ¶ms); + virtual void executeGoblinOpcode(int i, OpGobParams ¶ms); + virtual const char *getOpcodeDrawDesc(byte i); + virtual const char *getOpcodeFuncDesc(byte i, byte j); + virtual const char *getOpcodeGoblinDesc(int i); + + bool oWoodruff_stub0x18(OpFuncParams ¶ms); +}; + } // End of namespace Gob #endif // GOB_INTER_H diff --git a/engines/gob/inter_woodruff.cpp b/engines/gob/inter_woodruff.cpp new file mode 100644 index 0000000000..d1989c41d7 --- /dev/null +++ b/engines/gob/inter_woodruff.cpp @@ -0,0 +1,730 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include "common/stdafx.h" +#include "common/endian.h" +#include "common/file.h" + +#include "gob/gob.h" +#include "gob/inter.h" +#include "gob/global.h" +#include "gob/dataio.h" +#include "gob/draw.h" +#include "gob/game.h" +#include "gob/parse.h" + +namespace Gob { + +#define OPCODE(x) _OPCODE(Inter_Woodruff, x) + +const int Inter_Woodruff::_goblinFuncLookUp[][2] = { + {0, 0}, + {1, 1}, + {2, 2}, + {4, 3}, + {5, 4}, + {6, 5}, + {7, 6}, + {8, 7}, + {9, 8}, + {10, 9}, + {12, 10}, + {13, 11}, + {14, 12}, + {15, 13}, + {16, 14}, + {21, 15}, + {22, 16}, + {23, 17}, + {24, 18}, + {25, 19}, + {26, 20}, + {27, 21}, + {28, 22}, + {29, 23}, + {30, 24}, + {32, 25}, + {33, 26}, + {34, 27}, + {35, 28}, + {36, 29}, + {37, 30}, + {40, 31}, + {41, 32}, + {42, 33}, + {43, 34}, + {44, 35}, + {50, 36}, + {52, 37}, + {53, 38}, + {100, 39}, + {152, 40}, + {200, 41}, + {201, 42}, + {202, 43}, + {203, 44}, + {204, 45}, + {250, 46}, + {251, 47}, + {252, 48}, + {500, 49}, + {502, 50}, + {503, 51}, + {600, 52}, + {601, 53}, + {602, 54}, + {603, 55}, + {604, 56}, + {605, 57}, + {1000, 58}, + {1001, 59}, + {1002, 60}, + {1003, 61}, + {1004, 62}, + {1005, 63}, + {1006, 64}, + {1008, 65}, + {1009, 66}, + {1010, 67}, + {1011, 68}, + {1015, 69}, + {2005, 70} +}; + +Inter_Woodruff::Inter_Woodruff(GobEngine *vm) : Inter_v3(vm) { + setupOpcodes(); +} + +void Inter_Woodruff::setupOpcodes() { + static const OpcodeDrawEntryWoodruff opcodesDraw[256] = { + /* 00 */ + OPCODE(o1_loadMult), + OPCODE(o2_playMult), + OPCODE(o2_freeMultKeys), + {NULL, ""}, + /* 04 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + OPCODE(o1_initCursor), + /* 08 */ + OPCODE(o1_initCursorAnim), + OPCODE(o1_clearCursorAnim), + OPCODE(o2_setRenderFlags), + {NULL, ""}, + /* 0C */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 10 */ + OPCODE(o1_loadAnim), + OPCODE(o1_freeAnim), + OPCODE(o1_updateAnim), + OPCODE(o2_multSub), + /* 14 */ + OPCODE(o2_initMult), + OPCODE(o1_freeMult), + OPCODE(o1_animate), + OPCODE(o2_loadMultObject), + /* 18 */ + OPCODE(o1_getAnimLayerInfo), + OPCODE(o1_getObjAnimSize), + OPCODE(o1_loadStatic), + OPCODE(o1_freeStatic), + /* 1C */ + OPCODE(o2_renderStatic), + OPCODE(o2_loadCurLayer), + {NULL, ""}, + {NULL, ""}, + /* 20 */ + OPCODE(o2_playCDTrack), + OPCODE(o2_waitCDTrackEnd), + OPCODE(o2_stopCD), + OPCODE(o2_readLIC), + /* 24 */ + OPCODE(o2_freeLIC), + OPCODE(o2_getCDTrackPos), + {NULL, ""}, + {NULL, ""}, + /* 28 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 2C */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 30 */ + OPCODE(o2_loadFontToSprite), + OPCODE(o1_freeFontToSprite), + {NULL, ""}, + {NULL, ""}, + /* 34 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 38 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 3C */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 40 */ + OPCODE(o2_totSub), + OPCODE(o2_switchTotSub), + OPCODE(o2_copyVars), + OPCODE(o2_pasteVars), + /* 44 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 48 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 4C */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 50 */ + OPCODE(o2_loadMapObjects), + OPCODE(o2_freeGoblins), + OPCODE(o2_moveGoblin), + OPCODE(o2_writeGoblinPos), + /* 54 */ + OPCODE(o2_stopGoblin), + OPCODE(o2_setGoblinState), + OPCODE(o2_placeGoblin), + {NULL, ""}, + /* 58 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 5C */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 60 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 64 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 68 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 6C */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 70 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 74 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 78 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 7C */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 80 */ + OPCODE(o2_initScreen), + OPCODE(o2_scroll), + OPCODE(o2_setScrollOffset), + OPCODE(o2_playImd), + /* 84 */ + OPCODE(o2_getImdInfo), + OPCODE(o2_openItk), + OPCODE(o2_closeItk), + OPCODE(o2_setImdFrontSurf), + /* 88 */ + OPCODE(o2_resetImdFrontSurf), + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 8C */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 90 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 94 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 98 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 9C */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* A0 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* A4 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* A8 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* AC */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* B0 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* B4 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* B8 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* BC */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* C0 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* C4 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* C8 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* CC */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* D0 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* D4 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* D8 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* DC */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* E0 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* E4 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* E8 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* EC */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* F0 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* F4 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* F8 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* FC */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""} + }; + + static const OpcodeFuncEntryWoodruff opcodesFunc[80] = { + /* 00 */ + OPCODE(o1_callSub), + OPCODE(o1_callSub), + OPCODE(o1_printTotText), + OPCODE(o1_loadCursor), + /* 04 */ + {NULL, ""}, + OPCODE(o1_switch), + OPCODE(o1_repeatUntil), + OPCODE(o1_whileDo), + /* 08 */ + OPCODE(o1_if), + OPCODE(o2_evaluateStore), + OPCODE(o1_loadSpriteToPos), + {NULL, ""}, + /* 0C */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 10 */ + {NULL, ""}, + OPCODE(o2_printText), + OPCODE(o1_loadTot), + OPCODE(o1_palLoad), + /* 14 */ + OPCODE(o1_keyFunc), + OPCODE(o1_capturePush), + OPCODE(o1_capturePop), + OPCODE(o2_animPalInit), + /* 18 */ + OPCODE(oWoodruff_stub0x18), + {NULL, ""}, + OPCODE(o3_getTotTextItemPart), + {NULL, ""}, + /* 1C */ + {NULL, ""}, + {NULL, ""}, + OPCODE(o1_drawOperations), + OPCODE(o1_setcmdCount), + /* 20 */ + OPCODE(o1_return), + OPCODE(o1_renewTimeInVars), + OPCODE(o1_speakerOn), + OPCODE(o1_speakerOff), + /* 24 */ + OPCODE(o1_putPixel), + OPCODE(o2_goblinFunc), + OPCODE(o2_createSprite), + OPCODE(o1_freeSprite), + /* 28 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 2C */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 30 */ + OPCODE(o1_returnTo), + OPCODE(o1_loadSpriteContent), + OPCODE(o3_copySprite), + OPCODE(o1_fillRect), + /* 34 */ + OPCODE(o1_drawLine), + OPCODE(o1_strToLong), + OPCODE(o1_invalidate), + OPCODE(o1_setBackDelta), + /* 38 */ + OPCODE(o1_playSound), + OPCODE(o2_stopSound), + OPCODE(o2_loadSound), + OPCODE(o1_freeSoundSlot), + /* 3C */ + OPCODE(o1_waitEndPlay), + OPCODE(o1_playComposition), + OPCODE(o2_getFreeMem), + OPCODE(o2_checkData), + /* 40 */ + {NULL, ""}, + OPCODE(o1_prepareStr), + OPCODE(o1_insertStr), + OPCODE(o1_cutStr), + /* 44 */ + OPCODE(o1_strstr), + OPCODE(o1_istrlen), + OPCODE(o1_setMousePos), + OPCODE(o1_setFrameRate), + /* 48 */ + OPCODE(o1_animatePalette), + OPCODE(o1_animateCursor), + OPCODE(o1_blitCursor), + OPCODE(o1_loadFont), + /* 4C */ + OPCODE(o1_freeFont), + OPCODE(o2_readData), + OPCODE(o2_writeData), + OPCODE(o1_manageDataFile), + }; + + static const OpcodeGoblinEntryWoodruff opcodesGoblin[71] = { + /* 00 */ + OPCODE(o2_loadInfogramesIns), + OPCODE(o2_startInfogrames), + OPCODE(o2_stopInfogrames), + {NULL, ""}, + /* 04 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 08 */ + {NULL, ""}, + OPCODE(o2_playInfogrames), + {NULL, ""}, + {NULL, ""}, + /* 0C */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 10 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 14 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 18 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 1C */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 20 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 24 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + OPCODE(o2_handleGoblins), + /* 28 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 2C */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 30 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 34 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 38 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 3C */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 40 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 44 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + }; + + _opcodesDrawWoodruff = opcodesDraw; + _opcodesFuncWoodruff = opcodesFunc; + _opcodesGoblinWoodruff = opcodesGoblin; +} + +void Inter_Woodruff::executeDrawOpcode(byte i) { + debugC(1, kDebugDrawOp, "opcodeDraw %d [0x%X] (%s)", + i, i, getOpcodeDrawDesc(i)); + + OpcodeDrawProcWoodruff op = _opcodesDrawWoodruff[i].proc; + + if (op == NULL) + warning("unimplemented opcodeDraw: %d", i); + else + (this->*op) (); +} + +bool Inter_Woodruff::executeFuncOpcode(byte i, byte j, OpFuncParams ¶ms) { + debugC(1, kDebugFuncOp, "opcodeFunc %d.%d [0x%X.0x%X] (%s)", + i, j, i, j, getOpcodeFuncDesc(i, j)); + + if ((i > 4) || (j > 15)) { + warning("unimplemented opcodeFunc: %d.%d", i, j); + return false; + } + + OpcodeFuncProcWoodruff op = _opcodesFuncWoodruff[i*16 + j].proc; + + if (op == NULL) + warning("unimplemented opcodeFunc: %d.%d", i, j); + else + return (this->*op) (params); + + return false; +} + +void Inter_Woodruff::executeGoblinOpcode(int i, OpGobParams ¶ms) { + debugC(1, kDebugGobOp, "opcodeGoblin %d [0x%X] (%s)", + i, i, getOpcodeGoblinDesc(i)); + + OpcodeGoblinProcWoodruff op = NULL; + + for (int j = 0; j < ARRAYSIZE(_goblinFuncLookUp); j++) + if (_goblinFuncLookUp[j][0] == i) { + op = _opcodesGoblinWoodruff[_goblinFuncLookUp[j][1]].proc; + break; + } + + if (op == NULL) { + int16 val; + + _vm->_global->_inter_execPtr -= 2; + val = load16(); + _vm->_global->_inter_execPtr += val << 1; + } else + (this->*op) (params); +} + +const char *Inter_Woodruff::getOpcodeDrawDesc(byte i) { + return _opcodesDrawWoodruff[i].desc; +} + +const char *Inter_Woodruff::getOpcodeFuncDesc(byte i, byte j) { + if ((i > 4) || (j > 15)) + return ""; + + return _opcodesFuncWoodruff[i*16 + j].desc; +} + +const char *Inter_Woodruff::getOpcodeGoblinDesc(int i) { + for (int j = 0; j < ARRAYSIZE(_goblinFuncLookUp); j++) + if (_goblinFuncLookUp[j][0] == i) + return _opcodesGoblinWoodruff[_goblinFuncLookUp[j][1]].desc; + return ""; +} + +bool Inter_Woodruff::oWoodruff_stub0x18(OpFuncParams ¶ms) { + int16 val1 = _vm->_parse->parseValExpr(); + int16 val2 = _vm->_parse->parseValExpr(); + int16 val3 = _vm->_parse->parseValExpr(); + int16 val4 = _vm->_parse->parseValExpr(); + int16 val5 = _vm->_parse->parseValExpr(); + int16 val6 = _vm->_parse->parseValExpr(); + int16 val7 = load16(); + + warning("Stub! Woodruff Func 0x18: %d, %d, %d, %d, %d, %d, %d", + val1, val2, val3, val4, val5, val6, val7); + + return false; +} + +} // End of namespace Gob diff --git a/engines/gob/module.mk b/engines/gob/module.mk index db0660fa5c..7d90da6260 100644 --- a/engines/gob/module.mk +++ b/engines/gob/module.mk @@ -26,6 +26,7 @@ MODULE_OBJS := \ inter.o \ inter_v1.o \ inter_v2.o \ + inter_woodruff.o \ inter_v3.o \ inter_bargon.o \ map.o \ diff --git a/engines/gob/util.cpp b/engines/gob/util.cpp index ff6333aa9e..1b20ca249e 100644 --- a/engines/gob/util.cpp +++ b/engines/gob/util.cpp @@ -126,8 +126,8 @@ void Util::processInput(bool scroll) { _vm->_global->_speedFactor = MIN(_fastMode + 1, 3); if (scroll && hasMove) { - if (y >= (200 - _vm->_video->_splitHeight2)) { - y = 200 - _vm->_video->_splitHeight2 - 1; + if (y >= (_vm->_height - _vm->_video->_splitHeight2)) { + y = _vm->_height - _vm->_video->_splitHeight2 - 1; _vm->_util->setMousePos(x, y); } _vm->_game->evaluateScroll(x, y); -- cgit v1.2.3 From 88f265d5847d178e389e6d173e4eeb008495b16b Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Wed, 25 Jul 2007 22:55:00 +0000 Subject: Renamed Inter_Woodruff to Inter_v4 svn-id: r28206 --- engines/gob/gob.cpp | 2 +- engines/gob/inter.h | 32 +- engines/gob/inter_v4.cpp | 730 +++++++++++++++++++++++++++++++++++++++++ engines/gob/inter_woodruff.cpp | 730 ----------------------------------------- engines/gob/module.mk | 4 +- 5 files changed, 749 insertions(+), 749 deletions(-) create mode 100644 engines/gob/inter_v4.cpp delete mode 100644 engines/gob/inter_woodruff.cpp (limited to 'engines') diff --git a/engines/gob/gob.cpp b/engines/gob/gob.cpp index 8c3bb76413..c996b5e8d3 100644 --- a/engines/gob/gob.cpp +++ b/engines/gob/gob.cpp @@ -306,7 +306,7 @@ bool GobEngine::initGameParts() { case kGameTypeWoodruff: _init = new Init_v3(this); _video = new Video_v2(this); - _inter = new Inter_Woodruff(this); + _inter = new Inter_v4(this); _parse = new Parse_v2(this); _mult = new Mult_v2(this); _draw = new Draw_v2(this); diff --git a/engines/gob/inter.h b/engines/gob/inter.h index 70e0af2d4d..59a1ba3ccc 100644 --- a/engines/gob/inter.h +++ b/engines/gob/inter.h @@ -481,30 +481,30 @@ protected: bool o3_writeData(OpFuncParams ¶ms); }; -class Inter_Woodruff : public Inter_v3 { +class Inter_v4 : public Inter_v3 { public: - Inter_Woodruff(GobEngine *vm); - virtual ~Inter_Woodruff() {} + Inter_v4(GobEngine *vm); + virtual ~Inter_v4() {} protected: - typedef void (Inter_Woodruff::*OpcodeDrawProcWoodruff)(); - typedef bool (Inter_Woodruff::*OpcodeFuncProcWoodruff)(OpFuncParams &); - typedef void (Inter_Woodruff::*OpcodeGoblinProcWoodruff)(OpGobParams &); - struct OpcodeDrawEntryWoodruff { - OpcodeDrawProcWoodruff proc; + typedef void (Inter_v4::*OpcodeDrawProcV4)(); + typedef bool (Inter_v4::*OpcodeFuncProcV4)(OpFuncParams &); + typedef void (Inter_v4::*OpcodeGoblinProcV4)(OpGobParams &); + struct OpcodeDrawEntryV4 { + OpcodeDrawProcV4 proc; const char *desc; }; - struct OpcodeFuncEntryWoodruff { - OpcodeFuncProcWoodruff proc; + struct OpcodeFuncEntryV4 { + OpcodeFuncProcV4 proc; const char *desc; }; - struct OpcodeGoblinEntryWoodruff { - OpcodeGoblinProcWoodruff proc; + struct OpcodeGoblinEntryV4 { + OpcodeGoblinProcV4 proc; const char *desc; }; - const OpcodeDrawEntryWoodruff *_opcodesDrawWoodruff; - const OpcodeFuncEntryWoodruff *_opcodesFuncWoodruff; - const OpcodeGoblinEntryWoodruff *_opcodesGoblinWoodruff; + const OpcodeDrawEntryV4 *_opcodesDrawV4; + const OpcodeFuncEntryV4 *_opcodesFuncV4; + const OpcodeGoblinEntryV4 *_opcodesGoblinV4; static const int _goblinFuncLookUp[][2]; virtual void setupOpcodes(); @@ -515,7 +515,7 @@ protected: virtual const char *getOpcodeFuncDesc(byte i, byte j); virtual const char *getOpcodeGoblinDesc(int i); - bool oWoodruff_stub0x18(OpFuncParams ¶ms); + bool o4_stub0x18(OpFuncParams ¶ms); }; } // End of namespace Gob diff --git a/engines/gob/inter_v4.cpp b/engines/gob/inter_v4.cpp new file mode 100644 index 0000000000..02b6927f3b --- /dev/null +++ b/engines/gob/inter_v4.cpp @@ -0,0 +1,730 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include "common/stdafx.h" +#include "common/endian.h" +#include "common/file.h" + +#include "gob/gob.h" +#include "gob/inter.h" +#include "gob/global.h" +#include "gob/dataio.h" +#include "gob/draw.h" +#include "gob/game.h" +#include "gob/parse.h" + +namespace Gob { + +#define OPCODE(x) _OPCODE(Inter_v4, x) + +const int Inter_v4::_goblinFuncLookUp[][2] = { + {0, 0}, + {1, 1}, + {2, 2}, + {4, 3}, + {5, 4}, + {6, 5}, + {7, 6}, + {8, 7}, + {9, 8}, + {10, 9}, + {12, 10}, + {13, 11}, + {14, 12}, + {15, 13}, + {16, 14}, + {21, 15}, + {22, 16}, + {23, 17}, + {24, 18}, + {25, 19}, + {26, 20}, + {27, 21}, + {28, 22}, + {29, 23}, + {30, 24}, + {32, 25}, + {33, 26}, + {34, 27}, + {35, 28}, + {36, 29}, + {37, 30}, + {40, 31}, + {41, 32}, + {42, 33}, + {43, 34}, + {44, 35}, + {50, 36}, + {52, 37}, + {53, 38}, + {100, 39}, + {152, 40}, + {200, 41}, + {201, 42}, + {202, 43}, + {203, 44}, + {204, 45}, + {250, 46}, + {251, 47}, + {252, 48}, + {500, 49}, + {502, 50}, + {503, 51}, + {600, 52}, + {601, 53}, + {602, 54}, + {603, 55}, + {604, 56}, + {605, 57}, + {1000, 58}, + {1001, 59}, + {1002, 60}, + {1003, 61}, + {1004, 62}, + {1005, 63}, + {1006, 64}, + {1008, 65}, + {1009, 66}, + {1010, 67}, + {1011, 68}, + {1015, 69}, + {2005, 70} +}; + +Inter_v4::Inter_v4(GobEngine *vm) : Inter_v3(vm) { + setupOpcodes(); +} + +void Inter_v4::setupOpcodes() { + static const OpcodeDrawEntryV4 opcodesDraw[256] = { + /* 00 */ + OPCODE(o1_loadMult), + OPCODE(o2_playMult), + OPCODE(o2_freeMultKeys), + {NULL, ""}, + /* 04 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + OPCODE(o1_initCursor), + /* 08 */ + OPCODE(o1_initCursorAnim), + OPCODE(o1_clearCursorAnim), + OPCODE(o2_setRenderFlags), + {NULL, ""}, + /* 0C */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 10 */ + OPCODE(o1_loadAnim), + OPCODE(o1_freeAnim), + OPCODE(o1_updateAnim), + OPCODE(o2_multSub), + /* 14 */ + OPCODE(o2_initMult), + OPCODE(o1_freeMult), + OPCODE(o1_animate), + OPCODE(o2_loadMultObject), + /* 18 */ + OPCODE(o1_getAnimLayerInfo), + OPCODE(o1_getObjAnimSize), + OPCODE(o1_loadStatic), + OPCODE(o1_freeStatic), + /* 1C */ + OPCODE(o2_renderStatic), + OPCODE(o2_loadCurLayer), + {NULL, ""}, + {NULL, ""}, + /* 20 */ + OPCODE(o2_playCDTrack), + OPCODE(o2_waitCDTrackEnd), + OPCODE(o2_stopCD), + OPCODE(o2_readLIC), + /* 24 */ + OPCODE(o2_freeLIC), + OPCODE(o2_getCDTrackPos), + {NULL, ""}, + {NULL, ""}, + /* 28 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 2C */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 30 */ + OPCODE(o2_loadFontToSprite), + OPCODE(o1_freeFontToSprite), + {NULL, ""}, + {NULL, ""}, + /* 34 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 38 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 3C */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 40 */ + OPCODE(o2_totSub), + OPCODE(o2_switchTotSub), + OPCODE(o2_copyVars), + OPCODE(o2_pasteVars), + /* 44 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 48 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 4C */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 50 */ + OPCODE(o2_loadMapObjects), + OPCODE(o2_freeGoblins), + OPCODE(o2_moveGoblin), + OPCODE(o2_writeGoblinPos), + /* 54 */ + OPCODE(o2_stopGoblin), + OPCODE(o2_setGoblinState), + OPCODE(o2_placeGoblin), + {NULL, ""}, + /* 58 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 5C */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 60 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 64 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 68 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 6C */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 70 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 74 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 78 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 7C */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 80 */ + OPCODE(o2_initScreen), + OPCODE(o2_scroll), + OPCODE(o2_setScrollOffset), + OPCODE(o2_playImd), + /* 84 */ + OPCODE(o2_getImdInfo), + OPCODE(o2_openItk), + OPCODE(o2_closeItk), + OPCODE(o2_setImdFrontSurf), + /* 88 */ + OPCODE(o2_resetImdFrontSurf), + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 8C */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 90 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 94 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 98 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 9C */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* A0 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* A4 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* A8 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* AC */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* B0 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* B4 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* B8 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* BC */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* C0 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* C4 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* C8 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* CC */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* D0 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* D4 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* D8 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* DC */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* E0 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* E4 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* E8 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* EC */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* F0 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* F4 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* F8 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* FC */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""} + }; + + static const OpcodeFuncEntryV4 opcodesFunc[80] = { + /* 00 */ + OPCODE(o1_callSub), + OPCODE(o1_callSub), + OPCODE(o1_printTotText), + OPCODE(o1_loadCursor), + /* 04 */ + {NULL, ""}, + OPCODE(o1_switch), + OPCODE(o1_repeatUntil), + OPCODE(o1_whileDo), + /* 08 */ + OPCODE(o1_if), + OPCODE(o2_evaluateStore), + OPCODE(o1_loadSpriteToPos), + {NULL, ""}, + /* 0C */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 10 */ + {NULL, ""}, + OPCODE(o2_printText), + OPCODE(o1_loadTot), + OPCODE(o1_palLoad), + /* 14 */ + OPCODE(o1_keyFunc), + OPCODE(o1_capturePush), + OPCODE(o1_capturePop), + OPCODE(o2_animPalInit), + /* 18 */ + OPCODE(o4_stub0x18), + {NULL, ""}, + OPCODE(o3_getTotTextItemPart), + {NULL, ""}, + /* 1C */ + {NULL, ""}, + {NULL, ""}, + OPCODE(o1_drawOperations), + OPCODE(o1_setcmdCount), + /* 20 */ + OPCODE(o1_return), + OPCODE(o1_renewTimeInVars), + OPCODE(o1_speakerOn), + OPCODE(o1_speakerOff), + /* 24 */ + OPCODE(o1_putPixel), + OPCODE(o2_goblinFunc), + OPCODE(o2_createSprite), + OPCODE(o1_freeSprite), + /* 28 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 2C */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 30 */ + OPCODE(o1_returnTo), + OPCODE(o1_loadSpriteContent), + OPCODE(o3_copySprite), + OPCODE(o1_fillRect), + /* 34 */ + OPCODE(o1_drawLine), + OPCODE(o1_strToLong), + OPCODE(o1_invalidate), + OPCODE(o1_setBackDelta), + /* 38 */ + OPCODE(o1_playSound), + OPCODE(o2_stopSound), + OPCODE(o2_loadSound), + OPCODE(o1_freeSoundSlot), + /* 3C */ + OPCODE(o1_waitEndPlay), + OPCODE(o1_playComposition), + OPCODE(o2_getFreeMem), + OPCODE(o2_checkData), + /* 40 */ + {NULL, ""}, + OPCODE(o1_prepareStr), + OPCODE(o1_insertStr), + OPCODE(o1_cutStr), + /* 44 */ + OPCODE(o1_strstr), + OPCODE(o1_istrlen), + OPCODE(o1_setMousePos), + OPCODE(o1_setFrameRate), + /* 48 */ + OPCODE(o1_animatePalette), + OPCODE(o1_animateCursor), + OPCODE(o1_blitCursor), + OPCODE(o1_loadFont), + /* 4C */ + OPCODE(o1_freeFont), + OPCODE(o2_readData), + OPCODE(o2_writeData), + OPCODE(o1_manageDataFile), + }; + + static const OpcodeGoblinEntryV4 opcodesGoblin[71] = { + /* 00 */ + OPCODE(o2_loadInfogramesIns), + OPCODE(o2_startInfogrames), + OPCODE(o2_stopInfogrames), + {NULL, ""}, + /* 04 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 08 */ + {NULL, ""}, + OPCODE(o2_playInfogrames), + {NULL, ""}, + {NULL, ""}, + /* 0C */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 10 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 14 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 18 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 1C */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 20 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 24 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + OPCODE(o2_handleGoblins), + /* 28 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 2C */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 30 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 34 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 38 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 3C */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 40 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + /* 44 */ + {NULL, ""}, + {NULL, ""}, + {NULL, ""}, + }; + + _opcodesDrawV4 = opcodesDraw; + _opcodesFuncV4 = opcodesFunc; + _opcodesGoblinV4 = opcodesGoblin; +} + +void Inter_v4::executeDrawOpcode(byte i) { + debugC(1, kDebugDrawOp, "opcodeDraw %d [0x%X] (%s)", + i, i, getOpcodeDrawDesc(i)); + + OpcodeDrawProcV4 op = _opcodesDrawV4[i].proc; + + if (op == NULL) + warning("unimplemented opcodeDraw: %d", i); + else + (this->*op) (); +} + +bool Inter_v4::executeFuncOpcode(byte i, byte j, OpFuncParams ¶ms) { + debugC(1, kDebugFuncOp, "opcodeFunc %d.%d [0x%X.0x%X] (%s)", + i, j, i, j, getOpcodeFuncDesc(i, j)); + + if ((i > 4) || (j > 15)) { + warning("unimplemented opcodeFunc: %d.%d", i, j); + return false; + } + + OpcodeFuncProcV4 op = _opcodesFuncV4[i*16 + j].proc; + + if (op == NULL) + warning("unimplemented opcodeFunc: %d.%d", i, j); + else + return (this->*op) (params); + + return false; +} + +void Inter_v4::executeGoblinOpcode(int i, OpGobParams ¶ms) { + debugC(1, kDebugGobOp, "opcodeGoblin %d [0x%X] (%s)", + i, i, getOpcodeGoblinDesc(i)); + + OpcodeGoblinProcV4 op = NULL; + + for (int j = 0; j < ARRAYSIZE(_goblinFuncLookUp); j++) + if (_goblinFuncLookUp[j][0] == i) { + op = _opcodesGoblinV4[_goblinFuncLookUp[j][1]].proc; + break; + } + + if (op == NULL) { + int16 val; + + _vm->_global->_inter_execPtr -= 2; + val = load16(); + _vm->_global->_inter_execPtr += val << 1; + } else + (this->*op) (params); +} + +const char *Inter_v4::getOpcodeDrawDesc(byte i) { + return _opcodesDrawV4[i].desc; +} + +const char *Inter_v4::getOpcodeFuncDesc(byte i, byte j) { + if ((i > 4) || (j > 15)) + return ""; + + return _opcodesFuncV4[i*16 + j].desc; +} + +const char *Inter_v4::getOpcodeGoblinDesc(int i) { + for (int j = 0; j < ARRAYSIZE(_goblinFuncLookUp); j++) + if (_goblinFuncLookUp[j][0] == i) + return _opcodesGoblinV4[_goblinFuncLookUp[j][1]].desc; + return ""; +} + +bool Inter_v4::o4_stub0x18(OpFuncParams ¶ms) { + int16 val1 = _vm->_parse->parseValExpr(); + int16 val2 = _vm->_parse->parseValExpr(); + int16 val3 = _vm->_parse->parseValExpr(); + int16 val4 = _vm->_parse->parseValExpr(); + int16 val5 = _vm->_parse->parseValExpr(); + int16 val6 = _vm->_parse->parseValExpr(); + int16 val7 = load16(); + + warning("Stub! Woodruff Func 0x18: %d, %d, %d, %d, %d, %d, %d", + val1, val2, val3, val4, val5, val6, val7); + + return false; +} + +} // End of namespace Gob diff --git a/engines/gob/inter_woodruff.cpp b/engines/gob/inter_woodruff.cpp deleted file mode 100644 index d1989c41d7..0000000000 --- a/engines/gob/inter_woodruff.cpp +++ /dev/null @@ -1,730 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -#include "common/stdafx.h" -#include "common/endian.h" -#include "common/file.h" - -#include "gob/gob.h" -#include "gob/inter.h" -#include "gob/global.h" -#include "gob/dataio.h" -#include "gob/draw.h" -#include "gob/game.h" -#include "gob/parse.h" - -namespace Gob { - -#define OPCODE(x) _OPCODE(Inter_Woodruff, x) - -const int Inter_Woodruff::_goblinFuncLookUp[][2] = { - {0, 0}, - {1, 1}, - {2, 2}, - {4, 3}, - {5, 4}, - {6, 5}, - {7, 6}, - {8, 7}, - {9, 8}, - {10, 9}, - {12, 10}, - {13, 11}, - {14, 12}, - {15, 13}, - {16, 14}, - {21, 15}, - {22, 16}, - {23, 17}, - {24, 18}, - {25, 19}, - {26, 20}, - {27, 21}, - {28, 22}, - {29, 23}, - {30, 24}, - {32, 25}, - {33, 26}, - {34, 27}, - {35, 28}, - {36, 29}, - {37, 30}, - {40, 31}, - {41, 32}, - {42, 33}, - {43, 34}, - {44, 35}, - {50, 36}, - {52, 37}, - {53, 38}, - {100, 39}, - {152, 40}, - {200, 41}, - {201, 42}, - {202, 43}, - {203, 44}, - {204, 45}, - {250, 46}, - {251, 47}, - {252, 48}, - {500, 49}, - {502, 50}, - {503, 51}, - {600, 52}, - {601, 53}, - {602, 54}, - {603, 55}, - {604, 56}, - {605, 57}, - {1000, 58}, - {1001, 59}, - {1002, 60}, - {1003, 61}, - {1004, 62}, - {1005, 63}, - {1006, 64}, - {1008, 65}, - {1009, 66}, - {1010, 67}, - {1011, 68}, - {1015, 69}, - {2005, 70} -}; - -Inter_Woodruff::Inter_Woodruff(GobEngine *vm) : Inter_v3(vm) { - setupOpcodes(); -} - -void Inter_Woodruff::setupOpcodes() { - static const OpcodeDrawEntryWoodruff opcodesDraw[256] = { - /* 00 */ - OPCODE(o1_loadMult), - OPCODE(o2_playMult), - OPCODE(o2_freeMultKeys), - {NULL, ""}, - /* 04 */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - OPCODE(o1_initCursor), - /* 08 */ - OPCODE(o1_initCursorAnim), - OPCODE(o1_clearCursorAnim), - OPCODE(o2_setRenderFlags), - {NULL, ""}, - /* 0C */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* 10 */ - OPCODE(o1_loadAnim), - OPCODE(o1_freeAnim), - OPCODE(o1_updateAnim), - OPCODE(o2_multSub), - /* 14 */ - OPCODE(o2_initMult), - OPCODE(o1_freeMult), - OPCODE(o1_animate), - OPCODE(o2_loadMultObject), - /* 18 */ - OPCODE(o1_getAnimLayerInfo), - OPCODE(o1_getObjAnimSize), - OPCODE(o1_loadStatic), - OPCODE(o1_freeStatic), - /* 1C */ - OPCODE(o2_renderStatic), - OPCODE(o2_loadCurLayer), - {NULL, ""}, - {NULL, ""}, - /* 20 */ - OPCODE(o2_playCDTrack), - OPCODE(o2_waitCDTrackEnd), - OPCODE(o2_stopCD), - OPCODE(o2_readLIC), - /* 24 */ - OPCODE(o2_freeLIC), - OPCODE(o2_getCDTrackPos), - {NULL, ""}, - {NULL, ""}, - /* 28 */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* 2C */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* 30 */ - OPCODE(o2_loadFontToSprite), - OPCODE(o1_freeFontToSprite), - {NULL, ""}, - {NULL, ""}, - /* 34 */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* 38 */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* 3C */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* 40 */ - OPCODE(o2_totSub), - OPCODE(o2_switchTotSub), - OPCODE(o2_copyVars), - OPCODE(o2_pasteVars), - /* 44 */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* 48 */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* 4C */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* 50 */ - OPCODE(o2_loadMapObjects), - OPCODE(o2_freeGoblins), - OPCODE(o2_moveGoblin), - OPCODE(o2_writeGoblinPos), - /* 54 */ - OPCODE(o2_stopGoblin), - OPCODE(o2_setGoblinState), - OPCODE(o2_placeGoblin), - {NULL, ""}, - /* 58 */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* 5C */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* 60 */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* 64 */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* 68 */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* 6C */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* 70 */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* 74 */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* 78 */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* 7C */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* 80 */ - OPCODE(o2_initScreen), - OPCODE(o2_scroll), - OPCODE(o2_setScrollOffset), - OPCODE(o2_playImd), - /* 84 */ - OPCODE(o2_getImdInfo), - OPCODE(o2_openItk), - OPCODE(o2_closeItk), - OPCODE(o2_setImdFrontSurf), - /* 88 */ - OPCODE(o2_resetImdFrontSurf), - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* 8C */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* 90 */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* 94 */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* 98 */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* 9C */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* A0 */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* A4 */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* A8 */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* AC */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* B0 */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* B4 */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* B8 */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* BC */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* C0 */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* C4 */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* C8 */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* CC */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* D0 */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* D4 */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* D8 */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* DC */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* E0 */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* E4 */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* E8 */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* EC */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* F0 */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* F4 */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* F8 */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* FC */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""} - }; - - static const OpcodeFuncEntryWoodruff opcodesFunc[80] = { - /* 00 */ - OPCODE(o1_callSub), - OPCODE(o1_callSub), - OPCODE(o1_printTotText), - OPCODE(o1_loadCursor), - /* 04 */ - {NULL, ""}, - OPCODE(o1_switch), - OPCODE(o1_repeatUntil), - OPCODE(o1_whileDo), - /* 08 */ - OPCODE(o1_if), - OPCODE(o2_evaluateStore), - OPCODE(o1_loadSpriteToPos), - {NULL, ""}, - /* 0C */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* 10 */ - {NULL, ""}, - OPCODE(o2_printText), - OPCODE(o1_loadTot), - OPCODE(o1_palLoad), - /* 14 */ - OPCODE(o1_keyFunc), - OPCODE(o1_capturePush), - OPCODE(o1_capturePop), - OPCODE(o2_animPalInit), - /* 18 */ - OPCODE(oWoodruff_stub0x18), - {NULL, ""}, - OPCODE(o3_getTotTextItemPart), - {NULL, ""}, - /* 1C */ - {NULL, ""}, - {NULL, ""}, - OPCODE(o1_drawOperations), - OPCODE(o1_setcmdCount), - /* 20 */ - OPCODE(o1_return), - OPCODE(o1_renewTimeInVars), - OPCODE(o1_speakerOn), - OPCODE(o1_speakerOff), - /* 24 */ - OPCODE(o1_putPixel), - OPCODE(o2_goblinFunc), - OPCODE(o2_createSprite), - OPCODE(o1_freeSprite), - /* 28 */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* 2C */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* 30 */ - OPCODE(o1_returnTo), - OPCODE(o1_loadSpriteContent), - OPCODE(o3_copySprite), - OPCODE(o1_fillRect), - /* 34 */ - OPCODE(o1_drawLine), - OPCODE(o1_strToLong), - OPCODE(o1_invalidate), - OPCODE(o1_setBackDelta), - /* 38 */ - OPCODE(o1_playSound), - OPCODE(o2_stopSound), - OPCODE(o2_loadSound), - OPCODE(o1_freeSoundSlot), - /* 3C */ - OPCODE(o1_waitEndPlay), - OPCODE(o1_playComposition), - OPCODE(o2_getFreeMem), - OPCODE(o2_checkData), - /* 40 */ - {NULL, ""}, - OPCODE(o1_prepareStr), - OPCODE(o1_insertStr), - OPCODE(o1_cutStr), - /* 44 */ - OPCODE(o1_strstr), - OPCODE(o1_istrlen), - OPCODE(o1_setMousePos), - OPCODE(o1_setFrameRate), - /* 48 */ - OPCODE(o1_animatePalette), - OPCODE(o1_animateCursor), - OPCODE(o1_blitCursor), - OPCODE(o1_loadFont), - /* 4C */ - OPCODE(o1_freeFont), - OPCODE(o2_readData), - OPCODE(o2_writeData), - OPCODE(o1_manageDataFile), - }; - - static const OpcodeGoblinEntryWoodruff opcodesGoblin[71] = { - /* 00 */ - OPCODE(o2_loadInfogramesIns), - OPCODE(o2_startInfogrames), - OPCODE(o2_stopInfogrames), - {NULL, ""}, - /* 04 */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* 08 */ - {NULL, ""}, - OPCODE(o2_playInfogrames), - {NULL, ""}, - {NULL, ""}, - /* 0C */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* 10 */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* 14 */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* 18 */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* 1C */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* 20 */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* 24 */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - OPCODE(o2_handleGoblins), - /* 28 */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* 2C */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* 30 */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* 34 */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* 38 */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* 3C */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* 40 */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - /* 44 */ - {NULL, ""}, - {NULL, ""}, - {NULL, ""}, - }; - - _opcodesDrawWoodruff = opcodesDraw; - _opcodesFuncWoodruff = opcodesFunc; - _opcodesGoblinWoodruff = opcodesGoblin; -} - -void Inter_Woodruff::executeDrawOpcode(byte i) { - debugC(1, kDebugDrawOp, "opcodeDraw %d [0x%X] (%s)", - i, i, getOpcodeDrawDesc(i)); - - OpcodeDrawProcWoodruff op = _opcodesDrawWoodruff[i].proc; - - if (op == NULL) - warning("unimplemented opcodeDraw: %d", i); - else - (this->*op) (); -} - -bool Inter_Woodruff::executeFuncOpcode(byte i, byte j, OpFuncParams ¶ms) { - debugC(1, kDebugFuncOp, "opcodeFunc %d.%d [0x%X.0x%X] (%s)", - i, j, i, j, getOpcodeFuncDesc(i, j)); - - if ((i > 4) || (j > 15)) { - warning("unimplemented opcodeFunc: %d.%d", i, j); - return false; - } - - OpcodeFuncProcWoodruff op = _opcodesFuncWoodruff[i*16 + j].proc; - - if (op == NULL) - warning("unimplemented opcodeFunc: %d.%d", i, j); - else - return (this->*op) (params); - - return false; -} - -void Inter_Woodruff::executeGoblinOpcode(int i, OpGobParams ¶ms) { - debugC(1, kDebugGobOp, "opcodeGoblin %d [0x%X] (%s)", - i, i, getOpcodeGoblinDesc(i)); - - OpcodeGoblinProcWoodruff op = NULL; - - for (int j = 0; j < ARRAYSIZE(_goblinFuncLookUp); j++) - if (_goblinFuncLookUp[j][0] == i) { - op = _opcodesGoblinWoodruff[_goblinFuncLookUp[j][1]].proc; - break; - } - - if (op == NULL) { - int16 val; - - _vm->_global->_inter_execPtr -= 2; - val = load16(); - _vm->_global->_inter_execPtr += val << 1; - } else - (this->*op) (params); -} - -const char *Inter_Woodruff::getOpcodeDrawDesc(byte i) { - return _opcodesDrawWoodruff[i].desc; -} - -const char *Inter_Woodruff::getOpcodeFuncDesc(byte i, byte j) { - if ((i > 4) || (j > 15)) - return ""; - - return _opcodesFuncWoodruff[i*16 + j].desc; -} - -const char *Inter_Woodruff::getOpcodeGoblinDesc(int i) { - for (int j = 0; j < ARRAYSIZE(_goblinFuncLookUp); j++) - if (_goblinFuncLookUp[j][0] == i) - return _opcodesGoblinWoodruff[_goblinFuncLookUp[j][1]].desc; - return ""; -} - -bool Inter_Woodruff::oWoodruff_stub0x18(OpFuncParams ¶ms) { - int16 val1 = _vm->_parse->parseValExpr(); - int16 val2 = _vm->_parse->parseValExpr(); - int16 val3 = _vm->_parse->parseValExpr(); - int16 val4 = _vm->_parse->parseValExpr(); - int16 val5 = _vm->_parse->parseValExpr(); - int16 val6 = _vm->_parse->parseValExpr(); - int16 val7 = load16(); - - warning("Stub! Woodruff Func 0x18: %d, %d, %d, %d, %d, %d, %d", - val1, val2, val3, val4, val5, val6, val7); - - return false; -} - -} // End of namespace Gob diff --git a/engines/gob/module.mk b/engines/gob/module.mk index 7d90da6260..6c9a8d4b3e 100644 --- a/engines/gob/module.mk +++ b/engines/gob/module.mk @@ -26,9 +26,9 @@ MODULE_OBJS := \ inter.o \ inter_v1.o \ inter_v2.o \ - inter_woodruff.o \ - inter_v3.o \ inter_bargon.o \ + inter_v3.o \ + inter_v4.o \ map.o \ map_v1.o \ map_v2.o \ -- cgit v1.2.3 From 459868da77de9cb6a4f1820fd7274b2bb38ecc52 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Thu, 26 Jul 2007 01:01:00 +0000 Subject: sub0x18 is o2_addCollision(). It already existed in Gob2 (alongside with sub0x19 - o2_freeCollision()), but wasn't used there. Hotspots and menus work now (in a way) svn-id: r28207 --- engines/gob/game.h | 3 ++- engines/gob/inter.h | 4 +-- engines/gob/inter_v2.cpp | 69 ++++++++++++++++++++++++++++++++++++++++++++++-- engines/gob/inter_v3.cpp | 4 +-- engines/gob/inter_v4.cpp | 19 ++----------- 5 files changed, 75 insertions(+), 24 deletions(-) (limited to 'engines') diff --git a/engines/gob/game.h b/engines/gob/game.h index 0cef993b40..2b684a179f 100644 --- a/engines/gob/game.h +++ b/engines/gob/game.h @@ -152,6 +152,8 @@ public: void totSub(int8 flags, const char *newTotFile); void switchTotSub(int16 index, int16 skipPlay); + void freeCollision(int16 id); + virtual void playTot(int16 skipPlay) = 0; virtual void clearCollisions(void) = 0; @@ -221,7 +223,6 @@ protected: void loadImFile(void); void setCollisions(void); - void freeCollision(int16 id); void collSub(uint16 offset); void collAreaSub(int16 index, int8 enter); int16 openLocTextFile(char *locTextFile, int language); diff --git a/engines/gob/inter.h b/engines/gob/inter.h index 59a1ba3ccc..65d810412a 100644 --- a/engines/gob/inter.h +++ b/engines/gob/inter.h @@ -379,6 +379,8 @@ protected: bool o2_evaluateStore(OpFuncParams ¶ms); bool o2_printText(OpFuncParams ¶ms); bool o2_animPalInit(OpFuncParams ¶ms); + bool o2_addCollision(OpFuncParams ¶ms); + bool o2_freeCollision(OpFuncParams ¶ms); bool o2_goblinFunc(OpFuncParams ¶ms); bool o2_createSprite(OpFuncParams ¶ms); bool o2_stopSound(OpFuncParams ¶ms); @@ -514,8 +516,6 @@ protected: virtual const char *getOpcodeDrawDesc(byte i); virtual const char *getOpcodeFuncDesc(byte i, byte j); virtual const char *getOpcodeGoblinDesc(int i); - - bool o4_stub0x18(OpFuncParams ¶ms); }; } // End of namespace Gob diff --git a/engines/gob/inter_v2.cpp b/engines/gob/inter_v2.cpp index 9fe5904ff7..c78aa9e017 100644 --- a/engines/gob/inter_v2.cpp +++ b/engines/gob/inter_v2.cpp @@ -485,8 +485,8 @@ void Inter_v2::setupOpcodes() { OPCODE(o1_capturePop), OPCODE(o2_animPalInit), /* 18 */ - {NULL, ""}, - {NULL, ""}, + OPCODE(o2_addCollision), + OPCODE(o2_freeCollision), {NULL, ""}, {NULL, ""}, /* 1C */ @@ -1733,6 +1733,71 @@ bool Inter_v2::o2_animPalInit(OpFuncParams ¶ms) { return false; } +bool Inter_v2::o2_addCollision(OpFuncParams ¶ms) { + int16 id; + int16 left, top, width, height; + int16 flags; + int16 key; + int16 funcSub; + + id = _vm->_parse->parseValExpr(); + funcSub = _vm->_global->_inter_execPtr - _vm->_game->_totFileData; + left = _vm->_parse->parseValExpr(); + top = _vm->_parse->parseValExpr(); + width = _vm->_parse->parseValExpr(); + height = _vm->_parse->parseValExpr(); + flags = _vm->_parse->parseValExpr(); + key = load16(); + + if (key == 0) + key = ABS(id) + 41960; + + _vm->_draw->adjustCoords(0, &left, &top); + _vm->_draw->adjustCoords(2, &width, &height); + + if (left < 0) { + width += left; + left = 0; + } + + if (top < 0) { + height += top; + top = 0; + } + + int16 index; + if (id < 0) + index = _vm->_game->addNewCollision(0xD000 - id, left & 0xFFFC, top & 0xFFFC, + left + width + 3, top + height + 3, flags, key, 0, 0); + else + index = _vm->_game->addNewCollision(0xE000 + id, left, top, + left + width - 1, top + height - 1, flags, key, 0, 0); + + _vm->_game->_collisionAreas[index].funcSub = funcSub; + + return false; +} + +bool Inter_v2::o2_freeCollision(OpFuncParams ¶ms) { + int16 id; + + id = _vm->_parse->parseValExpr(); + if (id == -2) { + for (int i = 0; i < 150; i++) { + if ((_vm->_game->_collisionAreas[i].id & 0xF000) == 0xD000) + _vm->_game->_collisionAreas[i].left = 0xFFFF; + } + } else if (id == -1) { + for (int i = 0; i < 150; i++) { + if ((_vm->_game->_collisionAreas[i].id & 0xF000) == 0xE000) + _vm->_game->_collisionAreas[i].left = 0xFFFF; + } + } else + _vm->_game->freeCollision(0xE000 + id); + + return false; +} + bool Inter_v2::o2_goblinFunc(OpFuncParams ¶ms) { OpGobParams gobParams; int16 cmd; diff --git a/engines/gob/inter_v3.cpp b/engines/gob/inter_v3.cpp index ef0a7d6477..18601b9ed7 100644 --- a/engines/gob/inter_v3.cpp +++ b/engines/gob/inter_v3.cpp @@ -473,8 +473,8 @@ void Inter_v3::setupOpcodes() { OPCODE(o1_capturePop), OPCODE(o2_animPalInit), /* 18 */ - {NULL, ""}, - {NULL, ""}, + OPCODE(o2_addCollision), + OPCODE(o2_freeCollision), OPCODE(o3_getTotTextItemPart), {NULL, ""}, /* 1C */ diff --git a/engines/gob/inter_v4.cpp b/engines/gob/inter_v4.cpp index 02b6927f3b..776fc1df10 100644 --- a/engines/gob/inter_v4.cpp +++ b/engines/gob/inter_v4.cpp @@ -473,8 +473,8 @@ void Inter_v4::setupOpcodes() { OPCODE(o1_capturePop), OPCODE(o2_animPalInit), /* 18 */ - OPCODE(o4_stub0x18), - {NULL, ""}, + OPCODE(o2_addCollision), + OPCODE(o2_freeCollision), OPCODE(o3_getTotTextItemPart), {NULL, ""}, /* 1C */ @@ -712,19 +712,4 @@ const char *Inter_v4::getOpcodeGoblinDesc(int i) { return ""; } -bool Inter_v4::o4_stub0x18(OpFuncParams ¶ms) { - int16 val1 = _vm->_parse->parseValExpr(); - int16 val2 = _vm->_parse->parseValExpr(); - int16 val3 = _vm->_parse->parseValExpr(); - int16 val4 = _vm->_parse->parseValExpr(); - int16 val5 = _vm->_parse->parseValExpr(); - int16 val6 = _vm->_parse->parseValExpr(); - int16 val7 = load16(); - - warning("Stub! Woodruff Func 0x18: %d, %d, %d, %d, %d, %d, %d", - val1, val2, val3, val4, val5, val6, val7); - - return false; -} - } // End of namespace Gob -- cgit v1.2.3 From b644e460aac65a7aa2770845336f5a255c1a9d72 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Thu, 26 Jul 2007 03:17:54 +0000 Subject: Corrected Woodruff's hotspot text positions. svn-id: r28208 --- engines/gob/draw.h | 16 +++++++++------- engines/gob/draw_v2.cpp | 39 ++++++++++++++++++++++++++++++++++----- engines/gob/game_v2.cpp | 2 +- engines/gob/inter_v1.cpp | 9 +++++++++ 4 files changed, 53 insertions(+), 13 deletions(-) (limited to 'engines') diff --git a/engines/gob/draw.h b/engines/gob/draw.h index e37ecda334..8108a18d12 100644 --- a/engines/gob/draw.h +++ b/engines/gob/draw.h @@ -32,13 +32,15 @@ namespace Gob { #define SPRITES_COUNT 50 -#define RENDERFLAG_NOINVALIDATE 0x001 -#define RENDERFLAG_CAPTUREPUSH 0x002 -#define RENDERFLAG_COLLISIONS 0x004 -#define RENDERFLAG_CAPTUREPOP 0x008 -#define RENDERFLAG_USEDELTAS 0x010 -#define RENDERFLAG_NOBLITINVALIDATED 0x200 -#define RENDERFLAG_SKIPOPTIONALTEXT 0x400 +#define RENDERFLAG_NOINVALIDATE 0x0001 +#define RENDERFLAG_CAPTUREPUSH 0x0002 +#define RENDERFLAG_COLLISIONS 0x0004 +#define RENDERFLAG_CAPTUREPOP 0x0008 +#define RENDERFLAG_USEDELTAS 0x0010 +#define RENDERFLAG_NOBLITINVALIDATED 0x0200 +#define RENDERFLAG_SKIPOPTIONALTEXT 0x0400 +#define RENDERFLAG_FROMSPLIT 0x0800 +#define RENDERFLAG_DOUBLECOORDS 0x1000 class Draw { public: diff --git a/engines/gob/draw_v2.cpp b/engines/gob/draw_v2.cpp index c45bd0de27..55585f5619 100644 --- a/engines/gob/draw_v2.cpp +++ b/engines/gob/draw_v2.cpp @@ -197,7 +197,12 @@ void Draw_v2::printTotText(int16 id) { int16 rectLeft, rectTop, rectRight, rectBottom; int16 size; - if (!_vm->_game->_totTextData || !_vm->_game->_totTextData->dataPtr) + id &= 0xFFF; + + if (!_vm->_game->_totTextData || !_vm->_game->_totTextData->dataPtr || + (id >= _vm->_game->_totTextData->itemsCount) || + (_vm->_game->_totTextData->items[id].offset == -1) || + (_vm->_game->_totTextData->items[id].size == 0)) return; _vm->validateLanguage(); @@ -210,10 +215,34 @@ void Draw_v2::printTotText(int16 id) { if ((_renderFlags & RENDERFLAG_SKIPOPTIONALTEXT) && (ptr[1] & 0x80)) return; - destX = READ_LE_UINT16(ptr) & 0x7FFF; - destY = READ_LE_UINT16(ptr + 2); - spriteRight = READ_LE_UINT16(ptr + 4); - spriteBottom = READ_LE_UINT16(ptr + 6); + if (_renderFlags & RENDERFLAG_DOUBLECOORDS) { + destX = (READ_LE_UINT16(ptr) & 0x7FFF) * 2; + spriteRight = READ_LE_UINT16(ptr + 4) * 2 + 1; + } else { + destX = READ_LE_UINT16(ptr) & 0x7FFF; + spriteRight = READ_LE_UINT16(ptr + 4); + } + + if (_renderFlags & RENDERFLAG_FROMSPLIT) { + destY = _vm->_video->_splitHeight1; + spriteBottom = READ_LE_UINT16(ptr + 6) - READ_LE_UINT16(ptr + 2); + if (_renderFlags & RENDERFLAG_DOUBLECOORDS) + spriteBottom *= 3; + spriteBottom += _vm->_video->_splitHeight1; + if (_renderFlags & RENDERFLAG_DOUBLECOORDS) { + spriteBottom += _backDeltaX; + destY += _backDeltaX; + } + } else { + if (_renderFlags & RENDERFLAG_DOUBLECOORDS) { + destY = READ_LE_UINT16(ptr + 2) * 2; + spriteBottom = READ_LE_UINT16(ptr + 6) * 2; + } else { + destY = READ_LE_UINT16(ptr + 2); + spriteBottom = READ_LE_UINT16(ptr + 6); + } + } + ptr += 8; if (_renderFlags & RENDERFLAG_CAPTUREPUSH) { diff --git a/engines/gob/game_v2.cpp b/engines/gob/game_v2.cpp index d5c237c974..4ccd6d718e 100644 --- a/engines/gob/game_v2.cpp +++ b/engines/gob/game_v2.cpp @@ -151,7 +151,7 @@ void Game_v2::playTot(int16 skipPlay) { if (_totTextData->dataPtr != 0) { Common::MemoryReadStream totTextData(_totTextData->dataPtr, 4294967295U); - _totTextData->itemsCount = MIN(totTextData.readSint16LE(), (size - 2) / 4); + _totTextData->itemsCount = totTextData.readSint16LE() & 0x3FFF; _totTextData->items = new TotTextItem[_totTextData->itemsCount]; for (int i = 0; i < _totTextData->itemsCount; ++i) { diff --git a/engines/gob/inter_v1.cpp b/engines/gob/inter_v1.cpp index 572f133e33..5ea307bf28 100644 --- a/engines/gob/inter_v1.cpp +++ b/engines/gob/inter_v1.cpp @@ -1908,6 +1908,15 @@ bool Inter_v1::o1_fillRect(OpFuncParams ¶ms) { if (!_vm->_draw->_spritesArray[_vm->_draw->_destSurface]) return false; + if (_vm->_draw->_spriteRight < 0) { + _vm->_draw->_destSpriteX += _vm->_draw->_spriteRight - 1; + _vm->_draw->_spriteRight = -_vm->_draw->_spriteRight + 2; + } + if (_vm->_draw->_spriteBottom < 0) { + _vm->_draw->_destSpriteY += _vm->_draw->_spriteBottom - 1; + _vm->_draw->_spriteBottom = -_vm->_draw->_spriteBottom + 2; + } + _vm->_draw->spriteOperation(DRAW_FILLRECT); return false; } -- cgit v1.2.3 From 872a1ea36970af4a5440b81ac434a4e109e9cc51 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Thu, 26 Jul 2007 03:29:45 +0000 Subject: Fixed o1_fillRect() again svn-id: r28209 --- engines/gob/inter_v1.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/gob/inter_v1.cpp b/engines/gob/inter_v1.cpp index 5ea307bf28..7f5a641c1b 100644 --- a/engines/gob/inter_v1.cpp +++ b/engines/gob/inter_v1.cpp @@ -1896,7 +1896,9 @@ bool Inter_v1::o1_copySprite(OpFuncParams ¶ms) { } bool Inter_v1::o1_fillRect(OpFuncParams ¶ms) { - _vm->_draw->_destSurface = load16(); + int16 destSurf; + + _vm->_draw->_destSurface = destSurf = load16(); _vm->_draw->_destSpriteX = _vm->_parse->parseValExpr(); _vm->_draw->_destSpriteY = _vm->_parse->parseValExpr(); @@ -1905,7 +1907,7 @@ bool Inter_v1::o1_fillRect(OpFuncParams ¶ms) { _vm->_draw->_backColor = _vm->_parse->parseValExpr(); - if (!_vm->_draw->_spritesArray[_vm->_draw->_destSurface]) + if (!_vm->_draw->_spritesArray[(destSurf > 100) ? (destSurf - 80) : destSurf]) return false; if (_vm->_draw->_spriteRight < 0) { -- cgit v1.2.3 From cfff436ca7b294557f0833044c2751c37a4853da Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 26 Jul 2007 10:11:31 +0000 Subject: Added proper room change fading effect svn-id: r28212 --- engines/lure/game.cpp | 11 +++++++++-- engines/lure/game.h | 2 +- engines/lure/luredefs.h | 2 ++ engines/lure/room.cpp | 47 ++++++++++++++++++++++++++++++++++++----------- engines/lure/screen.cpp | 37 ++++++++++++++++++++++++++++--------- engines/lure/screen.h | 3 ++- 6 files changed, 78 insertions(+), 24 deletions(-) (limited to 'engines') diff --git a/engines/lure/game.cpp b/engines/lure/game.cpp index 3ac25f83b8..5bffc6ade8 100644 --- a/engines/lure/game.cpp +++ b/engines/lure/game.cpp @@ -52,7 +52,7 @@ Game::~Game() { delete _debugger; } -void Game::tick() { +void Game::tick(bool fastSpeed) { // Call the tick method for each hotspot - this is somewaht complicated // by the fact that a tick proc can unload both itself and/or others, // so we first get a list of the Ids, and call the tick proc for each @@ -65,7 +65,11 @@ void Game::tick() { int idSize = 0; for (i = res.activeHotspots().begin(); i != res.activeHotspots().end(); ++i) { Hotspot *hotspot = *i; - idList[idSize++] = hotspot->hotspotId(); + + if (!fastSpeed || ((hotspot->layer() != 0xff) && + (hotspot->hotspotId() < FIRST_NONCHARACTER_ID))) + // Add hotspot to list to execute + idList[idSize++] = hotspot->hotspotId(); } debugC(ERROR_DETAILED, kLureDebugAnimations, "Hotspot ticks begin"); @@ -289,6 +293,7 @@ void Game::playerChangeRoom() { uint16 roomNum = fields.playerNewPos().roomNumber; fields.playerNewPos().roomNumber = 0; Point &newPos = fields.playerNewPos().position; + delayList.clear(); RoomData *roomData = res.getRoom(roomNum); @@ -302,7 +307,9 @@ void Game::playerChangeRoom() { displayChuteAnimation(); else if (animFlag != 0) displayBarrelAnimation(); + fields.setField(ROOM_EXIT_ANIMATION, 0); + roomData->exitTime = g_system->getMillis(); // Change to the new room Hotspot *player = res.getActiveHotspot(PLAYER_ID); diff --git a/engines/lure/game.h b/engines/lure/game.h index b1d1f8d21a..20e56df776 100644 --- a/engines/lure/game.h +++ b/engines/lure/game.h @@ -66,7 +66,7 @@ public: static Game &getReference(); - void tick(); + void tick(bool fastSpeed = false); void nextFrame(); void execute(); void setState(uint8 flags) { _state = flags; } diff --git a/engines/lure/luredefs.h b/engines/lure/luredefs.h index a715c4a1e7..d5991a5807 100644 --- a/engines/lure/luredefs.h +++ b/engines/lure/luredefs.h @@ -113,6 +113,8 @@ enum Action { #define SUB_PALETTE_SIZE 64 // Palette resources have 220 palette entries #define RES_PALETTE_ENTRIES 220 +// Main working palette size +#define MAIN_PALETTE_SIZE 228 // Palette colour increment amouns for palette fade in/outs #define PALETTE_FADE_INC_SIZE 4 diff --git a/engines/lure/room.cpp b/engines/lure/room.cpp index 016432dfac..b48b50197b 100644 --- a/engines/lure/room.cpp +++ b/engines/lure/room.cpp @@ -24,6 +24,7 @@ #include "lure/luredefs.h" #include "lure/res.h" #include "lure/screen.h" +#include "lure/game.h" #include "lure/events.h" #include "lure/strings.h" #include "lure/scripts.h" @@ -492,18 +493,26 @@ void Room::update() { void Room::setRoomNumber(uint16 newRoomNumber, bool showOverlay) { Resources &r = Resources::getReference(); + Game &game = Game::getReference(); + Mouse &mouse = Mouse::getReference(); + + mouse.pushCursorNum(CURSOR_DISK); + _roomData = r.getRoom(newRoomNumber); if (!_roomData) error("Tried to change to non-existant room: %d", newRoomNumber); - bool leaveFlag = (_layers[0] && (newRoomNumber != _roomNumber)); + bool leaveFlag = (_layers[0] && (newRoomNumber != _roomNumber) && (_roomNumber != 0)); _roomNumber = _roomData->roomNumber; _descId = _roomData->descId; + if (leaveFlag) { + _screen.paletteFadeOut(); + leaveRoom(); + } + _screen.empty(); - _screen.resetPalette(); - if (leaveFlag) leaveRoom(); _numLayers = _roomData->numLayers; if (showOverlay) ++_numLayers; @@ -512,13 +521,9 @@ void Room::setRoomNumber(uint16 newRoomNumber, bool showOverlay) { _layers[layerNum] = new RoomLayer(_roomData->layers[layerNum], layerNum == 0); - // Load in the palette, add in the two replacements segments, and then - // set to the system palette - Palette p(228, NULL, RGB64); - Palette tempPalette(paletteId); - p.copyFrom(&tempPalette); - r.insertPaletteSubset(p); - _screen.setPalette(&p); + // Load in the game palette and set the non-room specific colours at the top end of the palette + Palette mainPalette(GAME_PALETTE_RESOURCE_ID); + _screen.setPalette(&mainPalette, MAIN_PALETTE_SIZE, GAME_COLOURS - MAIN_PALETTE_SIZE); // Set the new room number r.fieldList().setField(ROOM_NUMBER, newRoomNumber); @@ -527,8 +532,28 @@ void Room::setRoomNumber(uint16 newRoomNumber, bool showOverlay) { Script::execute(_roomData->sequenceOffset); loadRoomHotspots(); - checkCursor(); + + if (_roomData->exitTime != 0xffff) + { + // If time has passed, animation ticks needed before room is displayed + int numSeconds = (g_system->getMillis() - _roomData->exitTime) / 1000; + if (numSeconds > 300) numSeconds = 300; + + while (numSeconds-- > 0) + game.tick(true); + } + update(); + _screen.update(); + + // Generate the palette for the room and fade it in + Palette p(MAIN_PALETTE_SIZE, NULL, RGB64); + Palette tempPalette(paletteId); + p.copyFrom(&tempPalette); + r.insertPaletteSubset(p); + _screen.paletteFadeIn(&p); + + mouse.popCursor(); } // checkCursor diff --git a/engines/lure/screen.cpp b/engines/lure/screen.cpp index 8477c0def4..0cd2dd9357 100644 --- a/engines/lure/screen.cpp +++ b/engines/lure/screen.cpp @@ -28,6 +28,7 @@ #include "lure/memory.h" #include "lure/disk.h" #include "lure/decode.h" +#include "lure/events.h" namespace Lure { @@ -71,26 +72,40 @@ void Screen::setPalette(Palette *p) { _system.updateScreen(); } +// setPalette +// Variation that allows the specification of a subset of a palette passed in to be copied + +void Screen::setPalette(Palette *p, uint16 start, uint16 num) { + _palette->palette()->copyFrom(p->palette(), start * PALETTE_FADE_INC_SIZE, + start * PALETTE_FADE_INC_SIZE, num * PALETTE_FADE_INC_SIZE); + _system.setPalette(_palette->data(), 0, GAME_COLOURS); + _system.updateScreen(); +} + // paletteFadeIn // Fades in the palette. For proper operation, the palette should have been // previously set to empty void Screen::paletteFadeIn(Palette *p) { + assert(p->numEntries() <= _palette->numEntries()); + Events &events = Events::getReference(); bool changed; - byte *const pDest = p->data(); - byte *const pTemp = _palette->data(); do { changed = false; + byte *pFinal = p->data(); + byte *pCurrent = _palette->data(); - for (int palCtr = 0; palCtr < p->numEntries() * 4; ++palCtr) + for (int palCtr = 0; palCtr < p->numEntries() * PALETTE_FADE_INC_SIZE; ++palCtr, ++pCurrent, ++pFinal) { if (palCtr % PALETTE_FADE_INC_SIZE == (PALETTE_FADE_INC_SIZE - 1)) continue; - bool isDifferent = pTemp[palCtr] < pDest[palCtr]; + bool isDifferent = *pCurrent < *pFinal; + if (isDifferent) { - if (pDest[palCtr] - pTemp[palCtr] < PALETTE_FADE_INC_SIZE) - pTemp[palCtr] = pDest[palCtr]; - else pTemp[palCtr] += PALETTE_FADE_INC_SIZE; + if ((*pFinal - *pCurrent) < PALETTE_FADE_INC_SIZE) + *pCurrent = *pFinal; + else + *pCurrent += PALETTE_FADE_INC_SIZE; changed = true; } } @@ -99,6 +114,7 @@ void Screen::paletteFadeIn(Palette *p) { _system.setPalette(_palette->data(), 0, GAME_COLOURS); _system.updateScreen(); _system.delayMillis(20); + events.pollEvent(); } } while (changed); } @@ -106,14 +122,16 @@ void Screen::paletteFadeIn(Palette *p) { // paletteFadeOut // Fades the screen to black by gradually decreasing the palette colours -void Screen::paletteFadeOut() { +void Screen::paletteFadeOut(int numEntries) { + assert((uint32)numEntries <= _palette->palette()->size()); + Events &events = Events::getReference(); bool changed; do { byte *pTemp = _palette->data(); changed = false; - for (uint32 palCtr = 0; palCtr < _palette->palette()->size(); ++palCtr, ++pTemp) { + for (uint32 palCtr = 0; palCtr < (uint32)(numEntries * PALETTE_FADE_INC_SIZE); ++palCtr, ++pTemp) { if (palCtr % PALETTE_FADE_INC_SIZE == (PALETTE_FADE_INC_SIZE - 1)) continue; bool isDifferent = *pTemp > 0; @@ -128,6 +146,7 @@ void Screen::paletteFadeOut() { _system.setPalette(_palette->data(), 0, GAME_COLOURS); _system.updateScreen(); _system.delayMillis(20); + events.pollEvent(); } } while (changed); } diff --git a/engines/lure/screen.h b/engines/lure/screen.h index 9197f64a8d..7182c4236b 100644 --- a/engines/lure/screen.h +++ b/engines/lure/screen.h @@ -49,9 +49,10 @@ public: void setPaletteEmpty(); void setPalette(Palette *p); + void setPalette(Palette *p, uint16 start, uint16 num); Palette &getPalette() { return *_palette; } void paletteFadeIn(Palette *p); - void paletteFadeOut(); + void paletteFadeOut(int numEntries = MAIN_PALETTE_SIZE); void resetPalette(); void empty(); void update(); -- cgit v1.2.3 From 4785ae9cfc770746baca65ba70e014c77a24e98f Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 26 Jul 2007 13:26:34 +0000 Subject: Removed some unnecessary file existence checks svn-id: r28214 --- engines/saga/detection.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/saga/detection.cpp b/engines/saga/detection.cpp index 2c8089529f..7f154afbda 100644 --- a/engines/saga/detection.cpp +++ b/engines/saga/detection.cpp @@ -150,8 +150,7 @@ bool SagaEngine::initGame() { } // If a compressed sound file is found in the game's directory, set the compressed flag to true - if (Common::File::exists("music.cmp") || Common::File::exists("musicd.cmp") || - Common::File::exists("sounds.cmp") || Common::File::exists("soundsd.cmp") || + if (Common::File::exists("sounds.cmp") || Common::File::exists("soundsd.cmp") || Common::File::exists("voices.cmp") || Common::File::exists("voicesd.cmp") || Common::File::exists("inherit the earth voices.cmp")) { _gf_compressed_sounds = true; -- cgit v1.2.3 From da7d87e410a363754ee5f75d8e9ab29f04149386 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 26 Jul 2007 14:39:05 +0000 Subject: The demo version of IHNM has 3 font types (like ITE), not 6 (like the full version of IHNM) svn-id: r28215 --- engines/saga/font.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/saga/font.cpp b/engines/saga/font.cpp index ece48512df..caf41ab43e 100644 --- a/engines/saga/font.cpp +++ b/engines/saga/font.cpp @@ -629,7 +629,8 @@ void Font::textDrawRect(FontId fontId, Surface *ds, const char *text, const Comm Font::FontId Font::knownFont2FontIdx(KnownFont font) { FontId fontId = kSmallFont; - if (_vm->getGameType() == GType_ITE) { + // The demo version of IHNM has 3 font types (like ITE), not 6 (like the full version of IHNM) + if (_vm->getGameType() == GType_ITE || _vm->getGameId() == GID_IHNM_DEMO) { switch (font) { case (kKnownFontSmall): @@ -652,7 +653,7 @@ Font::FontId Font::knownFont2FontIdx(KnownFont font) { fontId = _vm->_font->valid(kBigFont) ? kBigFont : kMediumFont; break; } - } else if (_vm->getGameType() == GType_IHNM) { + } else if (_vm->getGameType() == GType_IHNM && _vm->getGameId() != GID_IHNM_DEMO) { switch (font) { case (kKnownFontSmall): -- cgit v1.2.3 From 75517ae813cbecbea0c95b99790e1ded4d5e8d99 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 26 Jul 2007 17:13:29 +0000 Subject: Only queue the IHNM company and title videos in the full version of IHNM, not the demo svn-id: r28217 --- engines/saga/ihnm_introproc.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/saga/ihnm_introproc.cpp b/engines/saga/ihnm_introproc.cpp index e122082322..40de389d0f 100644 --- a/engines/saga/ihnm_introproc.cpp +++ b/engines/saga/ihnm_introproc.cpp @@ -102,8 +102,11 @@ int Scene::IHNMStartProc() { n_introscenes = ARRAYSIZE(IHNM_IntroList); - for (i = 0; i < n_introscenes; i++) { - _vm->_scene->queueScene(&IHNM_IntroList[i]); + // Queue the company and title videos for the full version of IHNM + if (_vm->getGameId() != GID_IHNM_DEMO) { + for (i = 0; i < n_introscenes; i++) { + _vm->_scene->queueScene(&IHNM_IntroList[i]); + } } firstScene.loadFlag = kLoadBySceneNumber; -- cgit v1.2.3 From d3e7e81c8abdc3c57f82c482dc7efbbd237baf7d Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Thu, 26 Jul 2007 18:23:09 +0000 Subject: Dos full version of Big Red Adventure is detected now. The engine crashes immediately afterwards. svn-id: r28218 --- engines/parallaction/detection.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'engines') diff --git a/engines/parallaction/detection.cpp b/engines/parallaction/detection.cpp index 8e069c5f08..44e9126b70 100644 --- a/engines/parallaction/detection.cpp +++ b/engines/parallaction/detection.cpp @@ -49,6 +49,7 @@ Common::Platform Parallaction::getPlatform() const { return _gameDescription->de static const PlainGameDescriptor parallactionGames[] = { {"parallaction", "Parallaction engine game"}, {"nippon", "Nippon Safes Inc."}, + {"bra", "The Big Red Adventure"}, {0, 0} }; @@ -140,6 +141,24 @@ static const PARALLACTIONGameDescription gameDescriptions[] = { GF_LANG_IT, }, + { + { + "bra", + "Multi-lingual", + { + {"tbra.bmp", 0, "3174c095a0e1a4eaf05c403445711e9b", 80972 }, + {"russia.fnt", 0, "57f85ff62aeca6334fdcaf718e313b49", 18344 }, + {NULL, 0, NULL, 0 } + }, + Common::UNK_LANG, + Common::kPlatformPC, + Common::ADGF_NO_FLAGS + }, + GType_BRA, + GF_LANG_EN | GF_LANG_FR | GF_LANG_DE | GF_LANG_MULT + }, + + { AD_TABLE_END_MARKER, 0, 0 } }; -- cgit v1.2.3 From 236634662c1aa8c8bd7784584cbf99986908e8b7 Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Thu, 26 Jul 2007 18:30:27 +0000 Subject: Made screen size parameters properties of engine instead of compile-time constants. svn-id: r28219 --- engines/parallaction/disk.cpp | 31 +++++----- engines/parallaction/graphics.cpp | 103 +++++++++++++++++----------------- engines/parallaction/graphics.h | 11 +--- engines/parallaction/inventory.cpp | 4 +- engines/parallaction/parallaction.cpp | 19 +++++++ engines/parallaction/parallaction.h | 10 ++++ engines/parallaction/walk.cpp | 16 +++--- engines/parallaction/zone.cpp | 2 +- 8 files changed, 112 insertions(+), 84 deletions(-) (limited to 'engines') diff --git a/engines/parallaction/disk.cpp b/engines/parallaction/disk.cpp index 2e6d9e4820..4070f41e1c 100644 --- a/engines/parallaction/disk.cpp +++ b/engines/parallaction/disk.cpp @@ -412,9 +412,9 @@ void DosDisk::loadBackground(const char *filename) { parseBackground(_resArchive); - byte *bg = (byte*)calloc(1, SCREEN_WIDTH*SCREEN_HEIGHT); - byte *mask = (byte*)calloc(1, SCREENMASK_WIDTH*SCREEN_HEIGHT); - byte *path = (byte*)calloc(1, SCREENPATH_WIDTH*SCREEN_HEIGHT); + byte *bg = (byte*)calloc(1, _vm->_screenSize); + byte *mask = (byte*)calloc(1, _vm->_screenMaskSize); + byte *path = (byte*)calloc(1, _vm->_screenPathSize); Graphics::PackBitsReadStream stream(_resArchive); @@ -444,13 +444,13 @@ void DosDisk::loadMaskAndPath(const char *name) { if (!_resArchive.openArchivedFile(path)) errorFileNotFound(name); - byte *maskBuf = (byte*)calloc(1, SCREENMASK_WIDTH*SCREEN_HEIGHT); - byte *pathBuf = (byte*)calloc(1, SCREENPATH_WIDTH*SCREEN_HEIGHT); + byte *maskBuf = (byte*)calloc(1, _vm->_screenMaskSize); + byte *pathBuf = (byte*)calloc(1, _vm->_screenPathSize); parseDepths(_resArchive); - _resArchive.read(pathBuf, SCREENPATH_WIDTH*SCREEN_HEIGHT); - _resArchive.read(maskBuf, SCREENMASK_WIDTH*SCREEN_HEIGHT); + _resArchive.read(pathBuf, _vm->_screenPathSize); + _resArchive.read(maskBuf, _vm->_screenMaskSize); _vm->_gfx->setMask(maskBuf); _vm->setPath(pathBuf); @@ -932,7 +932,12 @@ Common::SeekableReadStream *AmigaDisk::openArchivedFile(const char* name, bool e return NULL; } -// FIXME: mask values are not computed correctly for level 1 and 2 +/* + FIXME: mask values are not computed correctly for level 1 and 2 + + NOTE: this routine is only able to build masks for Nippon Safes, since mask widths are hardcoded + into the main loop. +*/ void buildMask(byte* buf) { byte mask1[16] = { 0, 0x80, 0x20, 0xA0, 8, 0x88, 0x28, 0xA8, 2, 0x82, 0x22, 0xA2, 0xA, 0x8A, 0x2A, 0xAA }; @@ -941,7 +946,7 @@ void buildMask(byte* buf) { byte plane0[40]; byte plane1[40]; - for (uint32 i = 0; i < 200; i++) { + for (int32 i = 0; i < _vm->_screenHeight; i++) { memcpy(plane0, buf, 40); memcpy(plane1, buf+40, 40); @@ -1051,8 +1056,8 @@ void AmigaDisk::loadMask(const char *name) { s->seek(0x126, SEEK_SET); // HACK: skipping IFF/ILBM header should be done by analysis, not magic Graphics::PackBitsReadStream stream(*s); - byte *buf = (byte*)malloc(SCREENMASK_WIDTH*SCREEN_HEIGHT); - stream.read(buf, SCREENMASK_WIDTH*SCREEN_HEIGHT); + byte *buf = (byte*)malloc(_vm->_screenMaskSize); + stream.read(buf, _vm->_screenMaskSize); buildMask(buf); _vm->_gfx->setMask(buf); free(buf); @@ -1074,8 +1079,8 @@ void AmigaDisk::loadPath(const char *name) { s->seek(0x120, SEEK_SET); // HACK: skipping IFF/ILBM header should be done by analysis, not magic Graphics::PackBitsReadStream stream(*s); - byte *buf = (byte*)malloc(SCREENPATH_WIDTH*SCREEN_HEIGHT); - stream.read(buf, SCREENPATH_WIDTH*SCREEN_HEIGHT); + byte *buf = (byte*)malloc(_vm->_screenPathSize); + stream.read(buf, _vm->_screenPathSize); _vm->setPath(buf); free(buf); delete s; diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp index cdbf41eb2c..04f2ef1040 100644 --- a/engines/parallaction/graphics.cpp +++ b/engines/parallaction/graphics.cpp @@ -80,7 +80,7 @@ void Gfx::drawBalloon(const Common::Rect& r, uint16 winding) { winding = (winding == 0 ? 1 : 0); byte *s = _resBalloon[winding]; - byte *d = _buffers[kBitFront] + (r.left + (r.width()+5)/2 - 5) + (r.bottom - 1) * SCREEN_WIDTH; + byte *d = _buffers[kBitFront] + (r.left + (r.width()+5)/2 - 5) + (r.bottom - 1) * _vm->_screenWidth; for (uint16 i = 0; i < BALLOON_HEIGHT; i++) { for (uint16 j = 0; j < BALLOON_WIDTH; j++) { @@ -89,7 +89,7 @@ void Gfx::drawBalloon(const Common::Rect& r, uint16 winding) { s++; } - d += (SCREEN_WIDTH - BALLOON_WIDTH); + d += (_vm->_screenWidth - BALLOON_WIDTH); } // printf("done\n"); @@ -255,7 +255,7 @@ void Gfx::setHalfbriteMode(bool enable) { void Gfx::updateScreen() { // printf("Gfx::updateScreen()\n"); - g_system->copyRectToScreen(_buffers[kBitFront], SCREEN_WIDTH, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); + g_system->copyRectToScreen(_buffers[kBitFront], _vm->_screenWidth, 0, 0, _vm->_screenWidth, _vm->_screenHeight); g_system->updateScreen(); return; } @@ -274,7 +274,7 @@ void Gfx::swapBuffers() { // graphic primitives // void Gfx::clearScreen(Gfx::Buffers buffer) { - memset(_buffers[buffer], 0, SCREEN_WIDTH*SCREEN_HEIGHT); + memset(_buffers[buffer], 0, _vm->_screenSize); if (buffer == kBitFront) updateScreen(); @@ -283,7 +283,7 @@ void Gfx::clearScreen(Gfx::Buffers buffer) { void Gfx::copyScreen(Gfx::Buffers srcbuffer, Gfx::Buffers dstbuffer) { - memcpy(_buffers[dstbuffer], _buffers[srcbuffer], SCREEN_WIDTH*SCREEN_HEIGHT); + memcpy(_buffers[dstbuffer], _buffers[srcbuffer], _vm->_screenSize); // if (dstbuffer == kBitFront) updateScreen(); @@ -293,25 +293,25 @@ void Gfx::copyScreen(Gfx::Buffers srcbuffer, Gfx::Buffers dstbuffer) { void Gfx::floodFill(Gfx::Buffers buffer, const Common::Rect& r, byte color) { // printf("Gfx::floodFill(%i, %i, %i, %i, %i)\n", color, left, top, right, bottom); - byte *d = _buffers[buffer] + (r.left + r.top * SCREEN_WIDTH); + byte *d = _buffers[buffer] + (r.left + r.top * _vm->_screenWidth); uint16 w = r.width() + 1; uint16 h = r.height() + 1; for (uint16 i = 0; i < h; i++) { memset(d, color, w); - d += SCREEN_WIDTH; + d += _vm->_screenWidth; } return; } -void screenClip(Common::Rect& r, Common::Point& p) { +void Gfx::screenClip(Common::Rect& r, Common::Point& p) { int32 x = r.left; int32 y = r.top; - Common::Rect screen(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); + Common::Rect screen(0, 0, _vm->_screenWidth, _vm->_screenHeight); r.clip(screen); @@ -332,7 +332,7 @@ void Gfx::flatBlit(const Common::Rect& r, byte *data, Gfx::Buffers buffer) { screenClip(q, dp); byte *s = data + q.left + q.top * r.width(); - byte *d = _buffers[buffer] + dp.x + dp.y * SCREEN_WIDTH; + byte *d = _buffers[buffer] + dp.x + dp.y * _vm->_screenWidth; for (uint16 i = q.top; i < q.bottom; i++) { for (uint16 j = q.left; j < q.right; j++) { @@ -342,7 +342,7 @@ void Gfx::flatBlit(const Common::Rect& r, byte *data, Gfx::Buffers buffer) { } s += (r.width() - q.width()); - d += (SCREEN_WIDTH - q.width()); + d += (_vm->_screenWidth - q.width()); } return; @@ -357,12 +357,12 @@ void Gfx::blit(const Common::Rect& r, uint16 z, byte *data, Gfx::Buffers buffer) screenClip(q, dp); byte *s = data + q.left + q.top * r.width(); - byte *d = _buffers[buffer] + dp.x + dp.y * SCREEN_WIDTH; + byte *d = _buffers[buffer] + dp.x + dp.y * _vm->_screenWidth; for (uint16 i = q.top; i < q.bottom; i++) { uint16 n = dp.x % 4; - byte *m = _buffers[kMask0] + dp.x/4 + (dp.y + i - q.top)*SCREENMASK_WIDTH; + byte *m = _buffers[kMask0] + dp.x/4 + (dp.y + i - q.top)*_vm->_screenMaskWidth; for (uint16 j = q.left; j < q.right; j++) { if (*s != 0) { @@ -379,7 +379,7 @@ void Gfx::blit(const Common::Rect& r, uint16 z, byte *data, Gfx::Buffers buffer) } s += (r.width() - q.right + q.left); - d += (SCREEN_WIDTH - q.right + q.left); + d += (_vm->_screenWidth - q.right + q.left); } return; @@ -417,8 +417,8 @@ void jobEraseLabel(void *parm, Job *j) { if (_si < 0) _si = 0; if (_di > 190) _di = 190; - if (label->_cnv._width + _si > SCREEN_WIDTH) - _si = SCREEN_WIDTH - label->_cnv._width; + if (label->_cnv._width + _si > _vm->_screenWidth) + _si = _vm->_screenWidth - label->_cnv._width; Common::Rect r(label->_cnv._width, label->_cnv._height); r.moveTo(_vm->_gfx->_labelPosition[1]); @@ -512,13 +512,13 @@ void Gfx::blitCnv(StaticCnv *cnv, int16 x, int16 y, uint16 z, Gfx::Buffers buffe void Gfx::backupDoorBackground(DoorData *data, int16 x, int16 y) { - byte *s = _buffers[kBit2] + x + y * SCREEN_WIDTH; + byte *s = _buffers[kBit2] + x + y * _vm->_screenWidth; byte *d = data->_background; for (uint16 i = 0; i < data->_cnv->_height ; i++) { memcpy(d, s, data->_cnv->_width); - s += SCREEN_WIDTH; + s += _vm->_screenWidth; d += data->_cnv->_width; } @@ -528,7 +528,7 @@ void Gfx::backupDoorBackground(DoorData *data, int16 x, int16 y) { void Gfx::backupGetBackground(GetData *data, int16 x, int16 y) { byte *t = data->_cnv->_data0; - byte *s = _buffers[kBitBack] + x + y * SCREEN_WIDTH; + byte *s = _buffers[kBitBack] + x + y * _vm->_screenWidth; byte *d = data->_backup; for (uint16 i = 0; i < data->_cnv->_height ; i++) { @@ -540,7 +540,7 @@ void Gfx::backupGetBackground(GetData *data, int16 x, int16 y) { s++; } - s += (SCREEN_WIDTH - data->_cnv->_width); + s += (_vm->_screenWidth - data->_cnv->_width); } return; @@ -591,17 +591,17 @@ void Gfx::makeCnvFromString(StaticCnv *cnv, char *text) { } void Gfx::displayString(uint16 x, uint16 y, const char *text, byte color) { - byte *dst = _buffers[kBitFront] + x + y*SCREEN_WIDTH; + byte *dst = _buffers[kBitFront] + x + y*_vm->_screenWidth; _font->setColor(color); - _font->drawString(dst, SCREEN_WIDTH, text); + _font->drawString(dst, _vm->_screenWidth, text); } void Gfx::displayCenteredString(uint16 y, const char *text) { - uint16 x = (SCREEN_WIDTH - getStringWidth(text)) / 2; + uint16 x = (_vm->_screenWidth - getStringWidth(text)) / 2; displayString(x, y, text, 1); } -bool Gfx::displayWrappedString(char *text, uint16 x, uint16 y, byte color, uint16 wrapwidth) { +bool Gfx::displayWrappedString(char *text, uint16 x, uint16 y, byte color, int16 wrapwidth) { // printf("Gfx::displayWrappedString(%s, %i, %i, %i, %i)...", text, x, y, color, wrapwidth); uint16 lines = 0; @@ -613,6 +613,9 @@ bool Gfx::displayWrappedString(char *text, uint16 x, uint16 y, byte color, uint1 char token[40]; + if (wrapwidth == -1) + wrapwidth = _vm->_screenWidth; + while (strlen(text) > 0) { text = parseNextToken(text, token, 40, " ", true); @@ -701,11 +704,11 @@ void Gfx::restoreBackground(const Common::Rect& r) { if (left < 0) left = 0; if (top < 0) top = 0; - if (left >= SCREEN_WIDTH) return; - if (top >= SCREEN_HEIGHT) return; + if (left >= _vm->_screenWidth) return; + if (top >= _vm->_screenHeight) return; - if (left+width >= SCREEN_WIDTH) width = SCREEN_WIDTH - left; - if (top+height >= SCREEN_HEIGHT) height = SCREEN_HEIGHT - top; + if (left+width >= _vm->_screenWidth) width = _vm->_screenWidth - left; + if (top+height >= _vm->_screenHeight) height = _vm->_screenHeight - top; Common::Rect q(width, height); q.moveTo(left, top); @@ -713,8 +716,8 @@ void Gfx::restoreBackground(const Common::Rect& r) { copyRect( kBitBack, q, - _buffers[kBit2] + q.left + q.top * SCREEN_WIDTH, - SCREEN_WIDTH + _buffers[kBit2] + q.left + q.top * _vm->_screenWidth, + _vm->_screenWidth ); return; @@ -735,26 +738,26 @@ void Gfx::freeStaticCnv(StaticCnv *cnv) { void Gfx::setBackground(byte *background) { - memcpy(_buffers[kBitBack], background, SCREEN_WIDTH*SCREEN_HEIGHT); + memcpy(_buffers[kBitBack], background, _vm->_screenSize); copyScreen(kBitBack, kBit2); } void Gfx::setMask(byte *mask) { - memcpy(_buffers[kMask0], mask, SCREENMASK_WIDTH*SCREEN_HEIGHT); + memcpy(_buffers[kMask0], mask, _vm->_screenMaskSize); } void Gfx::copyRect(Gfx::Buffers dstbuffer, const Common::Rect& r, byte *src, uint16 pitch) { - byte *d = _buffers[dstbuffer] + r.left + SCREEN_WIDTH * r.top; + byte *d = _buffers[dstbuffer] + r.left + _vm->_screenWidth * r.top; byte *s = src; for (uint16 _si = 0; _si < r.height(); _si++) { memcpy(d, s, r.width()); s += pitch; - d += SCREEN_WIDTH; + d += _vm->_screenWidth; } @@ -763,51 +766,49 @@ void Gfx::copyRect(Gfx::Buffers dstbuffer, const Common::Rect& r, byte *src, uin void Gfx::grabRect(byte *dst, const Common::Rect& r, Gfx::Buffers srcbuffer, uint16 pitch) { - byte *s = _buffers[srcbuffer] + r.left + SCREEN_WIDTH * r.top; + byte *s = _buffers[srcbuffer] + r.left + _vm->_screenWidth * r.top; for (uint16 i = 0; i < r.height(); i++) { memcpy(dst, s, r.width()); - s += SCREEN_WIDTH; + s += _vm->_screenWidth; dst += pitch; } return; } +/* + the following 3 routines are hacks for Nippon Safes coming from the original code, + so they shouldn't be modified when adding support for other games +*/ void Gfx::plotMaskPixel(uint16 x, uint16 y, byte color) { - uint16 _ax = x + y * SCREEN_WIDTH; + uint16 _ax = x + y * _vm->_screenWidth; _buffers[kMask0][_ax >> 2] &= ~(3 << ((_ax & 3) << 1)); return; } - - - void Gfx::fillMaskRect(const Common::Rect& r, byte color) { - uint16 _di = r.left/4 + r.top*80; + uint16 _di = r.left/4 + r.top * _vm->_screenMaskWidth; for (uint16 _si = r.top; _si < r.bottom; _si++) { memset(&_buffers[kMask0][_di], color, r.width()/4+1); - _di += 80; + _di += _vm->_screenMaskWidth; } return; } - -// HACK -// this routine is only invoked from the 'intgrotta scenario' -// void Gfx::intGrottaHackMask() { memset(_buffers[kMask0] + 3600, 0, 3600); _bgLayers[1] = 500; return; } + int16 Gfx::queryMask(int16 v) { for (uint16 _si = 0; _si < 3; _si++) { @@ -821,13 +822,13 @@ Gfx::Gfx(Parallaction* vm) : _vm(vm) { g_system->beginGFXTransaction(); - g_system->initSize(SCREEN_WIDTH, SCREEN_HEIGHT); + g_system->initSize(_vm->_screenWidth, _vm->_screenHeight); g_system->endGFXTransaction(); - _buffers[kBitFront] = (byte*)malloc(SCREEN_SIZE); - _buffers[kBitBack] = (byte*)malloc(SCREEN_SIZE); - _buffers[kBit2] = (byte*)malloc(SCREEN_SIZE); - _buffers[kMask0] = (byte*)malloc(SCREENMASK_WIDTH * SCREEN_HEIGHT); + _buffers[kBitFront] = (byte*)malloc(_vm->_screenSize); + _buffers[kBitBack] = (byte*)malloc(_vm->_screenSize); + _buffers[kBit2] = (byte*)malloc(_vm->_screenSize); + _buffers[kMask0] = (byte*)malloc(_vm->_screenMaskWidth * _vm->_screenHeight); setBlackPalette(); diff --git a/engines/parallaction/graphics.h b/engines/parallaction/graphics.h index 05b7dac2ec..6f0f7996d3 100644 --- a/engines/parallaction/graphics.h +++ b/engines/parallaction/graphics.h @@ -36,14 +36,6 @@ namespace Parallaction { - -#define SCREEN_WIDTH 320 -#define SCREEN_HEIGHT 200 -#define SCREEN_SIZE SCREEN_WIDTH*SCREEN_HEIGHT - -#define SCREENMASK_WIDTH SCREEN_WIDTH/4 -#define SCREENPATH_WIDTH SCREEN_WIDTH/8 - #define BASE_PALETTE_COLORS 32 #define FIRST_BASE_COLOR 0 #define LAST_BASE_COLOR (FIRST_BASE_COLOR+BASE_PALETTE_COLORS-1) @@ -168,12 +160,13 @@ public: }; public: + void screenClip(Common::Rect& r, Common::Point& p); // dialogue and text void drawBalloon(const Common::Rect& r, uint16 arg_8); void displayString(uint16 x, uint16 y, const char *text, byte color); void displayCenteredString(uint16 y, const char *text); - bool displayWrappedString(char *text, uint16 x, uint16 y, byte color, uint16 wrapwidth = SCREEN_WIDTH); + bool displayWrappedString(char *text, uint16 x, uint16 y, byte color, int16 wrapwidth = -1); uint16 getStringWidth(const char *text); void getStringExtent(char *text, uint16 maxwidth, int16* width, int16* height); diff --git a/engines/parallaction/inventory.cpp b/engines/parallaction/inventory.cpp index b7ff835dcc..c9e74b2074 100644 --- a/engines/parallaction/inventory.cpp +++ b/engines/parallaction/inventory.cpp @@ -280,8 +280,8 @@ void openInventory() { int16 slot = getNumUsedSlots(); uint16 lines = (slot + 4) / INVENTORY_ITEMS_PER_LINE; - _invPosition.x = CLIP(_vm->_mousePos.x - (INVENTORY_WIDTH / 2), 0, SCREEN_WIDTH - INVENTORY_WIDTH); - _invPosition.y = CLIP(_vm->_mousePos.y - 2 - (lines * INVENTORYITEM_HEIGHT), 0, SCREEN_HEIGHT - lines * INVENTORYITEM_HEIGHT); + _invPosition.x = CLIP(_vm->_mousePos.x - (INVENTORY_WIDTH / 2), 0, (int)(_vm->_screenWidth - INVENTORY_WIDTH)); + _invPosition.y = CLIP(_vm->_mousePos.y - 2 - (lines * INVENTORYITEM_HEIGHT), 0, (int)(_vm->_screenHeight - lines * INVENTORYITEM_HEIGHT)); refreshInventory(); diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp index 15601eaedf..ca6ed73aa4 100644 --- a/engines/parallaction/parallaction.cpp +++ b/engines/parallaction/parallaction.cpp @@ -174,6 +174,25 @@ int Parallaction::init() { _baseTime = 0; + + if (_vm->getGameType() == GType_Nippon) { + _screenWidth = 320; + _screenHeight = 200; + } else + if (_vm->getGameType() == GType_BRA) { + _screenWidth = 640; + _screenHeight = 400; + } + + _screenMaskWidth = _screenWidth / 4; + _screenPathWidth = _screenWidth / 8; + + _screenSize = _screenWidth * _screenHeight; + _screenMaskSize = _screenMaskWidth * _screenHeight; + _screenPathSize = _screenPathWidth * _screenHeight; + + + if (getPlatform() == Common::kPlatformPC) { _disk = new DosDisk(this); } else { diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h index ad8db9e3f4..3a2ecd8f0b 100644 --- a/engines/parallaction/parallaction.h +++ b/engines/parallaction/parallaction.h @@ -361,6 +361,16 @@ private: const PARALLACTIONGameDescription *_gameDescription; public: + // info + int32 _screenWidth; + int32 _screenHeight; + int32 _screenSize; + + int32 _screenMaskWidth; + int32 _screenMaskSize; + int32 _screenPathWidth; + int32 _screenPathSize; + SoundMan *_soundMan; Gfx* _gfx; diff --git a/engines/parallaction/walk.cpp b/engines/parallaction/walk.cpp index 43ded244c5..5d2d005e9f 100644 --- a/engines/parallaction/walk.cpp +++ b/engines/parallaction/walk.cpp @@ -59,11 +59,11 @@ void PathBuilder::correctPathPoint(Common::Point &to) { int16 left = to.x; do { right++; - } while ((queryPath(right, to.y) == 0) && (right < SCREEN_WIDTH)); + } while ((queryPath(right, to.y) == 0) && (right < _vm->_screenWidth)); do { left--; } while ((queryPath(left, to.y) == 0) && (left > 0)); - right = (right == SCREEN_WIDTH) ? 1000 : right - to.x; + right = (right == _vm->_screenWidth) ? 1000 : right - to.x; left = (left == 0) ? 1000 : to.x - left; @@ -74,9 +74,9 @@ void PathBuilder::correctPathPoint(Common::Point &to) { } while ((queryPath(to.x, top) == 0) && (top > 0)); do { bottom++; - } while ((queryPath(to.x, bottom) == 0) && (bottom < SCREEN_HEIGHT)); + } while ((queryPath(to.x, bottom) == 0) && (bottom < _vm->_screenHeight)); top = (top == 0) ? 1000 : to.y - top; - bottom = (bottom == SCREEN_HEIGHT) ? 1000 : bottom - to.y; + bottom = (bottom == _vm->_screenHeight) ? 1000 : bottom - to.y; int16 closeX = (right >= left) ? left : right; @@ -272,7 +272,7 @@ uint16 PathBuilder::walkFunc1(int16 x, int16 y, WalkNode *Node) { void Parallaction::clipMove(Common::Point& pos, const WalkNode* from) { - if ((pos.x < from->_x) && (pos.x < SCREEN_WIDTH) && (queryPath(_vm->_char._ani.width()/2 + pos.x + 2, _vm->_char._ani.height() + pos.y) != 0)) { + if ((pos.x < from->_x) && (pos.x < _screenWidth) && (queryPath(_vm->_char._ani.width()/2 + pos.x + 2, _vm->_char._ani.height() + pos.y) != 0)) { pos.x = (pos.x + 2 < from->_x) ? pos.x + 2 : from->_x; } @@ -280,7 +280,7 @@ void Parallaction::clipMove(Common::Point& pos, const WalkNode* from) { pos.x = (pos.x - 2 > from->_x) ? pos.x - 2 : from->_x; } - if ((pos.y < from->_y) && (pos.y < (SCREEN_HEIGHT - _vm->_char._ani.height())) && (queryPath(_vm->_char._ani.width()/2 + pos.x, _vm->_char._ani.height() + pos.y + 2) != 0)) { + if ((pos.y < from->_y) && (pos.y < (_screenHeight - _vm->_char._ani.height())) && (queryPath(_vm->_char._ani.width()/2 + pos.x, _vm->_char._ani.height() + pos.y + 2) != 0)) { pos.y = (pos.y + 2 <= from->_y) ? pos.y + 2 : from->_y; } @@ -429,11 +429,11 @@ void jobWalk(void *parm, Job *j) { void Parallaction::setPath(byte *path) { - memcpy(_buffer, path, SCREENPATH_WIDTH*SCREEN_HEIGHT); + memcpy(_buffer, path, _screenPathSize); } void Parallaction::initWalk() { - _buffer = (byte*)malloc(SCREENPATH_WIDTH * SCREEN_HEIGHT); + _buffer = (byte*)malloc(_screenPathSize); } diff --git a/engines/parallaction/zone.cpp b/engines/parallaction/zone.cpp index 99ef8c60f9..485bec1c05 100644 --- a/engines/parallaction/zone.cpp +++ b/engines/parallaction/zone.cpp @@ -333,7 +333,7 @@ void Parallaction::displayItemComment(ExamineData *data) { char v68[PATH_LEN]; strcpy(v68, data->_filename); data->_cnv = _disk->loadStatic(v68); - _gfx->flatBlitCnv(data->_cnv, 140, (SCREEN_HEIGHT - data->_cnv->_height)/2, Gfx::kBitFront); + _gfx->flatBlitCnv(data->_cnv, 140, (_screenHeight - data->_cnv->_height)/2, Gfx::kBitFront); _gfx->freeStaticCnv(data->_cnv); delete data->_cnv; -- cgit v1.2.3 From f89e907998d1dd2a1ab4e73b0fdf457d70878ee3 Mon Sep 17 00:00:00 2001 From: Paweł Kołodziejski Date: Thu, 26 Jul 2007 19:52:18 +0000 Subject: added more drascula code (it still NOT WORKING) svn-id: r28220 --- engines/drascula/drascula.cpp | 4721 ++++++++++++++++++++++++++++++++++++++++- engines/drascula/drascula.h | 547 +++++ engines/drascula/texts.h | 753 +++++++ 3 files changed, 6020 insertions(+), 1 deletion(-) create mode 100644 engines/drascula/texts.h (limited to 'engines') diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp index cd84a89ea1..e800e0ef02 100644 --- a/engines/drascula/drascula.cpp +++ b/engines/drascula/drascula.cpp @@ -36,6 +36,7 @@ #include "sound/mixer.h" #include "drascula/drascula.h" +#include "drascula/texts.h" namespace Drascula { @@ -75,9 +76,43 @@ DrasculaEngine::DrasculaEngine(OSystem *syst) : Engine(syst) { } DrasculaEngine::~DrasculaEngine() { + salir_al_dos(0); + + free(VGA); + delete _rnd; } +static int x_obj[44] = {0, X_OBJ1, X_OBJ2, X_OBJ3, X_OBJ4, X_OBJ5, X_OBJ6, X_OBJ7, X_OBJ8, X_OBJ9, X_OBJ10, + X_OBJ11, X_OBJ12, X_OBJ13, X_OBJ14, X_OBJ15, X_OBJ16, X_OBJ17, X_OBJ18, X_OBJ19, X_OBJ20, + X_OBJ21, X_OBJ22, X_OBJ23, X_OBJ24, X_OBJ25, X_OBJ26, X_OBJ27, X_OBJ28, X_OBJ29, X_OBJ30, + X_OBJ31, X_OBJ32, X_OBJ33, X_OBJ34, X_OBJ35, X_OBJ36, X_OBJ37, X_OBJ38, X_OBJ39, X_OBJ40, + X_OBJ41, X_OBJ42, X_OBJ43}; +static int y_obj[44] = {0, Y_OBJ1, Y_OBJ2, Y_OBJ3, Y_OBJ4, Y_OBJ5, Y_OBJ6, Y_OBJ7, Y_OBJ8, Y_OBJ9, Y_OBJ10, + Y_OBJ11, Y_OBJ12, Y_OBJ13, Y_OBJ14, Y_OBJ15, Y_OBJ16, Y_OBJ17, Y_OBJ18, Y_OBJ19, Y_OBJ20, + Y_OBJ21, Y_OBJ22, Y_OBJ23, Y_OBJ24, Y_OBJ25, Y_OBJ26, Y_OBJ27, Y_OBJ28, Y_OBJ29, Y_OBJ30, + Y_OBJ31, Y_OBJ32, Y_OBJ33, Y_OBJ34, Y_OBJ35, Y_OBJ36, Y_OBJ37, Y_OBJ38, Y_OBJ39, Y_OBJ40, + Y_OBJ41, Y_OBJ42, Y_OBJ43}; +static int x_pol[44] = {0, 1, 42, 83, 124, 165, 206, 247, 83, 1, 206, + 1, 42, 83, 124, 165, 206, 247, 83, 1, 206, + 247, 83, 165, 1, 206, 42, 124, 83, 1, 247, + 83, 165, 1, 206, 42, 124, 83, 1, 247, 42, + 1, 165, 206}; +static int y_pol[44] = {0, 1, 1, 1, 1, 1, 1, 1, 27, 27, 1, + 27, 27, 27, 27, 27, 27, 27, 1, 1, 27, + 1, 1, 1, 1, 1, 27, 27, 27, 27, 27, + 1, 1, 1, 1, 1, 27, 27, 27, 27, 27, + 27, 1, 1}; +static int x_barra[] = {6, 51, 96, 141, 186, 232, 276, 321}; +static int x1d_menu[] = {280, 40, 80, 120, 160, 200, 240, 0, 40, 80, 120, + 160, 200, 240, 0, 40, 80, 120, 160, 200, 240, 0, + 40, 80, 120, 160, 200, 240, 0}; +static int y1d_menu[] = {0, 0, 0, 0, 0, 0, 0, 25, 25, 25, 25, 25, 25, 25, + 50, 50, 50, 50, 50, 50, 50, 75, 75, 75, 75, 75, 75, 75, 100}; +static int frame_x[6] = {43, 87, 130, 173, 216, 259}; +static int interf_x[] ={ 1, 65, 129, 193, 1, 65, 129 }; +static int interf_y[] ={ 51, 51, 51, 51, 83, 83, 83 }; + int DrasculaEngine::init() { // Detect game if (!initGame()) { @@ -91,14 +126,4698 @@ int DrasculaEngine::init() { _system->initSize(320, 200); _system->endGFXTransaction(); + VGA = (char *)malloc(320 * 200); + memset(VGA, 0, 64000); + + lleva_objeto = 0; + menu_bar = 0; menu_scr = 0; hay_nombre = 0; + frame_y = 0; + hare_x = -1; hare_se_mueve = 0; sentido_hare = 3; num_frame = 0; hare_se_ve = 1; + comprueba_flags = 1; + rompo = 0; rompo2 = 0; + anda_a_objeto = 0; + paso_x = PASO_HARE_X; paso_y = PASO_HARE_Y; + alto_hare = ALTO_PERSONAJE; ancho_hare = ANCHO_PERSONAJE; alto_pies = PIES_HARE; + alto_habla = ALTO_HABLA_HARE; ancho_habla = ANCHO_HABLA_HARE; + hay_respuesta = 0; + conta_ciego_vez = 0; + cambio_de_color = 0; + rompo_y_salgo = 0; + vb_x = 120; sentido_vb = 1; vb_se_mueve = 0; frame_vb = 1; + frame_piano = 0; + frame_borracho = 0; + frame_velas = 0; + cont_sv = 0; + term_int = 0; + num_ejec = 1; + cual_ejec = 0; hay_que_load = 0; + corta_musica = 0; + hay_seleccion = 0; + Leng = 0; + UsingMem = 0; + GlobalSpeed = 0; + + + + asigna_memoria(); + carga_info(); + + return 0; } + int DrasculaEngine::go() { + lee_dibujos("95.alg"); + descomprime_dibujo(dir_mesa, 1); + + lee_dibujos("96.alg"); + descomprime_dibujo(dir_hare_frente, COMPLETA); + lee_dibujos("99.alg"); + descomprime_dibujo(dir_hare_fondo, 1); + lee_dibujos("97.alg"); + descomprime_dibujo(dir_hare_dch, 1); + + strcpy(nombre_icono[1], "look"); + strcpy(nombre_icono[2], "take"); + strcpy(nombre_icono[3], "open"); + strcpy(nombre_icono[4], "close"); + strcpy(nombre_icono[5], "talk"); + strcpy(nombre_icono[6], "push"); + + paleta_hare(); + escoba(); + + return 0; +} + +void DrasculaEngine::salir_al_dos(int r) { + if (hay_sb == 1) + ctvd_end(); + borra_pantalla(); + Negro(); + MusicFadeout(); + stopmusic(); + libera_memoria(); + if (r == 2) + error("Game reach next segment"); +} + +void DrasculaEngine::asigna_memoria() { + dir_zona_pantalla = (char *)malloc(64000); + assert(dir_zona_pantalla); + dir_dibujo1 = (char *)malloc(64000); + assert(dir_dibujo1); + dir_hare_fondo = (char *)malloc(64000); + assert(dir_hare_fondo); + dir_dibujo3 = (char *)malloc(64000); + assert(dir_dibujo3); + dir_dibujo2 = (char *)malloc(64000); + assert(dir_dibujo2); + dir_mesa = (char *)malloc(64000); + assert(dir_mesa); + dir_hare_dch = (char *)malloc(64000); + assert(dir_hare_dch); + dir_hare_frente = (char *)malloc(64000); + assert(dir_hare_frente); +} + +void DrasculaEngine::libera_memoria() { + free(dir_zona_pantalla); + free(dir_dibujo1); + free(dir_hare_fondo); + free(dir_dibujo2); + free(dir_mesa); + free(dir_dibujo3); + free(dir_hare_dch); + free(dir_hare_frente); +} + +void DrasculaEngine::carga_info() { + hay_sb = 1; + con_voces = 0; + hay_que_load = 0; +} + +void DrasculaEngine::lee_dibujos(char *NamePcc) { + unsigned int con, x = 0; + unsigned int fExit = 0; + unsigned char ch,rep; + Common::File file; + char *auxPun; + + file.open(NamePcc); + if (!file.isOpen()) + error("missing game data %s %c", NamePcc, 7); + + Buffer_pcx = (char *)malloc(65000); + auxPun = Buffer_pcx; + file.seek(128); + while (!fExit) { + ch = file.readByte(); + rep = 1; + if ((ch & 192) == 192) { + rep = (ch & 63); + ch = file.readByte(); + } + for (con = 0; con < rep; con++) { + *auxPun++ = ch; + x++; + if (x > 64000) + fExit = 1; + } + } + + file.read(cPal, 768); + file.close(); +} + +void DrasculaEngine::descomprime_dibujo(char *dir_escritura, int plt) { + memcpy(dir_escritura, Buffer_pcx, 64000); + free(Buffer_pcx); + asigna_rgb((unsigned char *)cPal, plt); // TODO + if (plt > 1) + funde_rgb(plt); +} + +void DrasculaEngine::paleta_hare() { + int color, componente; + + for (color = 235; color < 253; color++) + for (componente = 0; componente < 4; componente++) + palHare[color][componente] = palJuego[color][componente]; + +} + +void DrasculaEngine::asigna_rgb(unsigned char *dir_lectura, int plt) { + int x, cnt = 0; + + for (x = 0; x < plt; x++) { + palJuego[x][0] = dir_lectura[cnt++] / 4; + palJuego[x][1] = dir_lectura[cnt++] / 4; + palJuego[x][2] = dir_lectura[cnt++] / 4; + palJuego[x][3] = 0; + } + ActualizaPaleta(); +} + +void DrasculaEngine::funde_rgb(int plt) { +/* TODO: ??? + unsigned int n; + + for (n = 0; n < plt; n++) { + palJuego[n][0] = inp(0x3c9); + palJuego[n][1] = inp(0x3c9); + palJuego[n][2] = inp(0x3c9); + palJuego[n][3] = 0; + } + ActualizaPaleta(); +*/ +} + +void DrasculaEngine::Negro() { + int color, componente; + DacPalette256 palNegra; + + for (color = 0; color < 256; color++) + for (componente = 0; componente < 4; componente++) + palNegra[color][componente] = 0; + + palNegra[254][0] = 0x3F; + palNegra[254][1] = 0x3F; + palNegra[254][2] = 0x15; + palNegra[254][0] = 0; + + setvgapalette256(&palNegra); +} + +void DrasculaEngine::ActualizaPaleta() { + setvgapalette256(&palJuego); +} + +void DrasculaEngine::setvgapalette256(DacPalette256 *PalBuf) { + g_system->setPalette((byte *)PalBuf, 0, 256); +} + +void DrasculaEngine::DIBUJA_FONDO(int xorg, int yorg, int xdes, int ydes, int Ancho, + int Alto, char *Origen, char *Destino) { + int x; + Destino += xdes + ydes * 320; + Origen += xorg + yorg * 320; + for (x = 0; x < Alto; x++) { + memcpy(Destino, Origen, Ancho); + Destino += 320; + Origen += 320; + } +} + +void DrasculaEngine::DIBUJA_BLOQUE(int xorg, int yorg, int xdes, int ydes, int Ancho, + int Alto, char *Origen, char *Destino) { + int y, x; + + Destino += xdes + ydes * 320; + Origen += xorg + yorg * 320; + + for (y = 0; y < Alto; y++) + for (x = 0; x < Ancho; x++) + if (Origen[x + y * 320] != 255) + Destino[x + y * 320] = Origen[x + y * 320]; +} + +void DrasculaEngine::DIBUJA_BLOQUE_CUT(int *Array, char *Origen, char *Destino) { + int y, x; + int xorg = Array[0]; + int yorg = Array[1]; + int xdes = Array[2]; + int ydes = Array[3]; + int Ancho = Array[4]; + int Alto = Array[5]; + + if (ydes < 0) { + yorg += -ydes; + Alto += ydes; + ydes = 0; + } + if (xdes < 0) { + xorg += -xdes; + Ancho += xdes; + xdes = 0; + } + if ((xdes + Ancho) > 319) + Ancho -= (xdes + Ancho) - 320; + if ((ydes + Alto) > 199) + Alto -= (ydes + Alto) - 200; + + Destino += xdes + ydes * 320; + Origen += xorg + yorg * 320; + + for (y = 0; y < Alto; y++) + for (x = 0; x < Ancho; x++) + if (Origen[x + y * 320] != 255) + Destino[x + y * 320] = Origen[x + y * 320]; +} + +void DrasculaEngine::VUELCA_PANTALLA(int xorg, int yorg, int xdes, int ydes, int Ancho, int Alto, char *Buffer) { + int x; + + VGA += xdes + ydes * 320; + Buffer += xorg + yorg * 320; + for (x = 0; x < Alto; x++) { + memcpy(VGA, Buffer, Ancho); + VGA += 320; + Buffer += 320; + } + + g_system->copyRectToScreen((const byte *)VGA, 320, 0, 0, 320, 200); +} + +void DrasculaEngine::escoba() { + int soc, l, n; + + dir_texto = dir_mesa; + + musica_antes = -1; + + soc = 0; + for (l = 0; l < 6; l++) { + soc=soc+ANCHO_PERSONAJE; + frame_x[l]=soc; + } + + for (n = 1; n < 43; n++) + objetos_que_tengo[n] = 0; + + for (n = 0; n < NUM_BANDERAS; n++) + flags[n] = 0; + + for (n = 1; n < 7; n++) + objetos_que_tengo[n] = n; + + agarra_objeto(28); + + buffer_teclado(); + + if (hay_que_load == 0) + animacion_1(); + + sin_verbo(); + lee_dibujos("2aux62.alg"); + descomprime_dibujo(dir_dibujo2, 1); + sentido_hare = 1; + obj_saliendo = 104; + if (hay_que_load != 0) + para_cargar(nom_partida); + else { + carga_escoba("62.ald"); + hare_x = -20; + hare_y = 56; + lleva_al_hare(65, 145); + } + +bucles: + if (hare_se_mueve == 0) { + paso_x=PASO_HARE_X; + paso_y=PASO_HARE_Y; + } + if (hare_se_mueve == 0 && anda_a_objeto==1) { + sentido_hare = sentido_final; + anda_a_objeto = 0; + } + + mueve_cursor(); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + if (music_status() == 0) + playmusic(musica_room); + + MirarRaton(); + + if (menu_scr == 0 && lleva_objeto == 1) + comprueba_objetos(); + + if (boton_dch == 1 && menu_scr == 1) { + lee_dibujos("99.alg"); + descomprime_dibujo(dir_hare_fondo, 1); + setvgapalette256(&palJuego); + menu_scr = 0; + espera_soltar(); + cont_sv = 0; + } + if (boton_dch == 1 && menu_scr == 0) { + hare_se_mueve = 0; + if (sentido_hare == 2) + sentido_hare = 1; + lee_dibujos("icons.alg"); + descomprime_dibujo(dir_hare_fondo, 1); + menu_scr = 1; + espera_soltar(); + sin_verbo(); + cont_sv = 0; + } + + if (boton_izq == 1 && menu_bar == 1) { + elige_en_barra(); + cont_sv = 0; + } else if (boton_izq == 1 && lleva_objeto == 0) { + comprueba1(); + cont_sv = 0; + } else if (boton_izq == 1 && lleva_objeto == 1) { + comprueba2(); + cont_sv = 0; + } + + if (y_raton < 24 && menu_scr == 0) + menu_bar = 1; + else + menu_bar = 0; + + key = getscan(); + if (key == F1 && menu_scr == 0) { + elige_verbo(1); + cont_sv = 0; + } else if (key == F2 && menu_scr == 0) { + elige_verbo(2); + cont_sv = 0; + } else if (key == F3 && menu_scr == 0) { + elige_verbo(3); + cont_sv = 0; + } else if (key == F4 && menu_scr == 0) { + elige_verbo(4); + cont_sv = 0; + } else if (key == F5 && menu_scr == 0) { + elige_verbo(5); + cont_sv = 0; + } else if (key == F6 && menu_scr == 0) { + elige_verbo(6); + cont_sv = 0; + } else if (key == F9) { + mesa(); + cont_sv = 0; + } else if (key == F10) { + saves(); + cont_sv = 0; + } else if (key == F8) { + sin_verbo(); + cont_sv = 0; + } else if (key == 47) { + con_voces = 1; + print_abc(SYS2, 96, 86); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + delay(1410); + cont_sv = 0; + } else if (key == 20) { + con_voces = 0; + print_abc(SYS3, 94, 86); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + delay(1460); + cont_sv = 0; + } else if (key == 83) { + confirma_go(); + cont_sv = 0; + } else if (key == ESC) { + confirma_salir(); + cont_sv = 0; + } else if (cont_sv == 1500) { + salva_pantallas(); + cont_sv = 0; + } else cont_sv++; + goto bucles; +} + +void DrasculaEngine::agarra_objeto(int objeto) { + lee_dibujos("icons.alg"); + descomprime_dibujo(dir_hare_fondo, 1); + elige_objeto(objeto); + lee_dibujos("99.alg"); + descomprime_dibujo(dir_hare_fondo, 1); +} + +void DrasculaEngine::elige_objeto(int objeto) { + if (lleva_objeto == 1 && menu_scr == 0) + suma_objeto(objeto_que_lleva); + DIBUJA_FONDO(x1d_menu[objeto], y1d_menu[objeto], 0, 0, ANCHOBJ,ALTOBJ, dir_hare_fondo, dir_dibujo3); + lleva_objeto = 1; + objeto_que_lleva = objeto; +} + +int DrasculaEngine::resta_objeto(int osj) { + int h, q = 0; + + for (h = 1; h < 43; h++) { + if (objetos_que_tengo[h] == osj) { + objetos_que_tengo[h] = 0; + q = 1; + break; + } + } + + if (q == 1) + return 0; + else + return 1; +} + +void DrasculaEngine::animacion_1() { + int l, l2, p; + int pos_pixel[6]; + + while (term_int == 0) { + playmusic(29); + fliplay("logoddm.bin",9); + if ((term_int == 1) || (getscan() == ESC)) + break; + delay(600); + if ((term_int == 1) || (getscan() == ESC)) + break; + borra_pantalla(); + delay(340); + if ((term_int == 1) || (getscan() == ESC)) + break; + playmusic(26); + delay(500); + if ((term_int == 1) || (getscan() == ESC)) + break; + fliplay("logoalc.bin", 8); + if ((term_int == 1) || (getscan() == ESC)) + break; + borra_pantalla(); + lee_dibujos("cielo.alg"); + descomprime_dibujo(dir_zona_pantalla, 256); + Negro(); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + FundeDelNegro(2); + if ((term_int == 1) || (getscan() == ESC)) + break; + delay(900); + if ((term_int == 1) || (getscan() == ESC)) + break; + color_abc(ROJO); + centra_texto("Transilvanya, 1993 d.c.", 160, 100); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + if ((term_int == 1) || (getscan() == ESC)) + break; + delay(1000); + if ((term_int == 1) || (getscan() == ESC)) + break; + delay(1200); + if ((term_int == 1) || (getscan() == ESC)) + break; + + fliplay("scrollb.bin", 9); + + if ((term_int == 1) || (getscan() == ESC)) + break; + borra_pantalla(); + comienza_sound("s5.als"); + if ((term_int == 1) || (getscan() == ESC)) + break; + anima("scr2.bin", 17); + if ((term_int == 1) || (getscan() == ESC)) + break; + fin_sound_corte(); + anima("scr3.bin", 17); + if ((term_int == 1) || (getscan() == ESC)) + break; + lee_dibujos("cielo2.alg"); + descomprime_dibujo(dir_zona_pantalla, 256); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + if ((term_int == 1) || (getscan() == ESC)) + break; + FundeAlNegro(1); + if ((term_int == 1) || (getscan() == ESC)) + break; + borra_pantalla(); + + lee_dibujos("96.alg"); + descomprime_dibujo(dir_hare_frente, COMPLETA); + lee_dibujos("103.alg"); + descomprime_dibujo(dir_dibujo1, MEDIA); + lee_dibujos("104.alg"); + descomprime_dibujo(dir_dibujo3, 1); + lee_dibujos("aux104.alg"); + descomprime_dibujo(dir_dibujo2, 1); + + playmusic(4); + if ((term_int == 1) || (getscan() == ESC)) + break; + delay(400); + if ((term_int == 1) || (getscan() == ESC)) + break; + + for (l2 = 0; l2 < 3; l2++) + for (l = 0; l < 7; l++) { + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); + DIBUJA_FONDO(interf_x[l], interf_y[l], 156, 45, 63, 31, dir_dibujo2, dir_zona_pantalla); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + if (getscan() == ESC) { + term_int = 1; + break; + } + pausa(3); + } + if ((term_int == 1) || (getscan() == ESC)) + break; + + l2 = 0; p = 0; + pos_pixel[3] = 45; + pos_pixel[4] = 63; + pos_pixel[5] = 31; + + for (l = 0; l < 180; l++) { + DIBUJA_FONDO(0, 0, 320 - l, 0, l, 200, dir_dibujo3, dir_zona_pantalla); + DIBUJA_FONDO(l, 0, 0, 0, 320 - l, 200, dir_dibujo1, dir_zona_pantalla); + + pos_pixel[0] = interf_x[l2]; + pos_pixel[1] = interf_y[l2]; + pos_pixel[2] = 156 - l; + + DIBUJA_BLOQUE_CUT(pos_pixel, dir_dibujo2, dir_zona_pantalla); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + p++; + if (p == 6) { + p = 0; + l2++; + } + if (l2 == 7) + l2 = 0; + if (getscan() == ESC) { + term_int = 1; + break; + } + } + if ((term_int == 1) || (getscan() == ESC)) + break; + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_zona_pantalla, dir_dibujo1); + + habla_dr_grande(TEXTD1, "D1.als"); + if ((term_int == 1) || (getscan() == ESC)) + break; + + borra_pantalla(); + + lee_dibujos("100.alg"); + descomprime_dibujo(dir_dibujo1, MEDIA); + lee_dibujos("auxigor.alg"); + descomprime_dibujo(dir_hare_frente, 1); + lee_dibujos("auxdr.alg"); + descomprime_dibujo(dir_hare_fondo, 1); + sentido_dr = 0; + x_dr = 129; + y_dr = 95; + sentido_igor = 1; + x_igor = 66; + y_igor = 97; + + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); + pon_igor(); + pon_dr(); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + habla_igor_dch(TEXTI8, "I8.als"); + if ((term_int == 1) || (getscan() == ESC)) + break; + DIBUJA_FONDO(0, 0, 0,0, 320, 200, dir_dibujo1, dir_zona_pantalla); + pon_igor(); + pon_dr(); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + habla_dr_izq(TEXTD2, "d2.als"); + if ((term_int == 1) || (getscan() == ESC)) + break; + habla_dr_izq(TEXTD3, "d3.als"); + if ((term_int == 1) || (getscan() == ESC)) + break; + anima("lib.bin", 16); + if ((term_int == 1) || (getscan() == ESC)) + break; + anima("lib2.bin", 16); + if ((term_int == 1) || (getscan() == ESC)) + break; + borra_pantalla(); + color_solo = ROJO; + lee_dibujos("plan1.alg"); + descomprime_dibujo(dir_zona_pantalla, MEDIA); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + pausa(10); + habla_solo(TEXTD4,"d4.als"); + if ((term_int == 1) || (getscan() == ESC)) + break; + lee_dibujos("plan1.alg"); + descomprime_dibujo(dir_zona_pantalla, MEDIA); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + habla_solo(TEXTD5, "d5.als"); + if ((term_int == 1) || (getscan() == ESC)) + break; + anima("lib2.bin", 16); + if ((term_int == 1) || (getscan() == ESC)) + break; + borra_pantalla(); + lee_dibujos("plan2.alg"); + descomprime_dibujo(dir_zona_pantalla, MEDIA); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + pausa(20); + habla_solo(TEXTD6, "d6.als"); + if ((term_int ==1) || (getscan() == ESC)) + break; + anima("lib2.bin", 16); + if ((term_int == 1) || (getscan() == ESC)) + break; + borra_pantalla(); + lee_dibujos("plan3.alg"); + descomprime_dibujo(dir_zona_pantalla, MEDIA); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + pausa(20); + if ((term_int == 1) || (getscan() == ESC)) + break; + habla_solo(TEXTD7, "d7.als"); + if ((term_int == 1) || (getscan() == ESC)) + break; + lee_dibujos("plan3.alg"); + descomprime_dibujo(dir_zona_pantalla, MEDIA); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + habla_solo(TEXTD8, "d8.als"); + if ((term_int == 1) || (getscan() == ESC)) + break; + borra_pantalla(); + lee_dibujos("100.alg"); + descomprime_dibujo(dir_dibujo1, MEDIA); + MusicFadeout(); + stopmusic(); + if ((term_int == 1) || (getscan() == ESC)) + break; + habla_igor_dch(TEXTI9, "I9.als"); + if ((term_int == 1) || (getscan() == ESC)) + break; + habla_dr_izq(TEXTD9, "d9.als"); + if ((term_int == 1) || (getscan() == ESC)) + break; + habla_igor_dch(TEXTI10, "I10.als"); + if ((term_int == 1) || (getscan() == ESC)) + break; + playmusic(11); + habla_dr_izq(TEXTD10, "d10.als"); + if ((term_int == 1) || (getscan() == ESC)) + break; + anima("rayo1.bin", 16); + if ((term_int == 1) || (getscan() == ESC)) + break; + comienza_sound("s5.als"); + anima("rayo2.bin", 15); + if ((term_int == 1) || (getscan() == ESC)) + break; + anima("frel2.bin", 16); + if ((term_int == 1) || (getscan() == ESC)) + break; + anima("frel.bin", 16); + if ((term_int == 1) || (getscan() == ESC)) + break; + anima("frel.bin", 16); + if ((term_int == 1) || (getscan() == ESC)) + break; + fin_sound_corte(); + borra_pantalla(); + Negro(); + playmusic(23); + FundeDelNegro(0); + if ((term_int == 1) || (getscan() == ESC)) + break; + sentido_dr = 1; + habla_igor_dch(TEXTI1, "I1.als"); + if ((term_int == 1) || (getscan() == ESC)) + break; + habla_dr_dch(TEXTD11, "d11.als"); + if ((term_int == 1) || (getscan() == ESC)) + break; + sentido_dr = 3; + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); + pon_igor(); + pon_dr(); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + pausa(1); + sentido_dr = 0; + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); + pon_igor(); + pon_dr(); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + habla_dr_izq(TEXTD12, "d12.als"); + if ((term_int == 1) || (getscan() == ESC)) + break; + sentido_dr = 3; + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); + pon_igor(); + pon_dr(); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + pausa(1); + sentido_dr = 1; + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); + pon_igor(); + pon_dr(); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + habla_igor_dch(TEXTI2, "I2.als"); + if ((term_int == 1) || (getscan() == ESC)) + break; + pausa(13); + habla_dr_dch(TEXTD13,"d13.als"); + if ((term_int == 1) || (getscan() == ESC)) + break; + sentido_dr = 3; + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); + pon_igor(); + pon_dr(); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + pausa(1); + sentido_dr = 0; + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); + pon_igor(); + pon_dr(); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + habla_dr_izq(TEXTD14, "d14.als"); + if ((term_int == 1) || (getscan() == ESC)) + break; + habla_igor_dch(TEXTI3, "I3.als"); + if ((term_int == 1) || (getscan() == ESC)) + break; + habla_dr_izq(TEXTD15, "d15.als"); + if ((term_int == 1) || (getscan() == ESC)) + break; + habla_igor_dch(TEXTI4, "I4.als"); + if ((term_int == 1) || (getscan() == ESC)) + break; + habla_dr_izq(TEXTD16, "d16.als"); + if ((term_int == 1) || (getscan() == ESC)) + break; + habla_igor_dch(TEXTI5, "I5.als"); + if ((term_int == 1) || (getscan() == ESC)) + break; + sentido_igor = 3; + habla_dr_izq(TEXTD17, "d17.als"); + if ((term_int == 1) || (getscan() == ESC)) + break; + pausa(18); + if ((term_int == 1) || (getscan() == ESC)) + break; + habla_igor_frente(TEXTI6, "I6.als"); + if ((term_int == 1) || (getscan() == ESC)) + break; + FundeAlNegro(0); + if ((term_int == 1) || (getscan() == ESC)) + break; + borra_pantalla(); + + playmusic(2); + pausa(5); + fliplay("intro.bin", 12); + term_int=1; + } + borra_pantalla(); + lee_dibujos("96.alg"); + descomprime_dibujo(dir_hare_frente, COMPLETA); + lee_dibujos("99.alg"); + descomprime_dibujo(dir_hare_fondo, 1); +} + +void DrasculaEngine::animacion_2() { + int l; + + lleva_al_hare(231, 91); + hare_se_ve = 0; + + term_int = 0; + + for (;;) { + if ((term_int == 1) || (getscan() == ESC)) + break; + + anima("ag.bin", 14); + if ((term_int == 1) || (getscan() == ESC)) + break; + + lee_dibujos("an11y13.alg"); + descomprime_dibujo(dir_hare_dch, 1); + if ((term_int == 1) || (getscan() == ESC)) + break; - //runGame(); + habla_tabernero(TEXTT22, "T22.als"); + if ((term_int == 1) || (getscan() == ESC)) + break; + lee_dibujos("97.alg"); + descomprime_dibujo(dir_hare_dch, 1); + if ((term_int == 1) || (getscan() == ESC)) + break; + + pausa(4); + comienza_sound("s1.als"); + hipo(18); + fin_sound(); + if ((term_int == 1) || (getscan() == ESC)) + break; + + borra_pantalla(); + stopmusic(); + corta_musica = 1; + memset(dir_zona_pantalla, 0, 64000); + color_solo = BLANCO; + pausa(80); + + if ((term_int == 1) || (getscan() == ESC)) + break; + habla_solo(TEXTBJ1, "BJ1.als"); + if ((term_int == 1) || (getscan() == ESC)) + break; + borra_pantalla(); + lee_dibujos("bj.alg"); + descomprime_dibujo(dir_zona_pantalla, MEDIA); + if ((term_int == 1) || (getscan() == ESC)) + break; + Negro(); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + FundeDelNegro(1); + if ((term_int == 1) || (getscan() == ESC)) + break; + color_solo = AMARILLO; + habla_solo(TEXT214, "214.als"); + if ((term_int == 1) || (getscan() == ESC)) + break; + borra_pantalla(); + + lee_dibujos("16.alg"); + descomprime_dibujo(dir_dibujo1, MEDIA); + if ((term_int == 1) || (getscan() == ESC)) + break; + lee_dibujos("auxbj.alg"); + descomprime_dibujo(dir_dibujo3, 1); + if ((term_int == 1) || (getscan() == ESC)) + break; + + strcpy(num_room,"16.alg"); + + if ((term_int == 1) || (getscan() == ESC)) + break; + for (l = 0; l < 200; l++) + factor_red[l] = 99; + x_bj = 170; + y_bj = 90; + sentido_bj = 0; + hare_x = 91; + hare_y = 95; + sentido_hare = 1; + hare_se_ve = 1; + if ((term_int == 1) || (getscan() == ESC)) + break; + + lee_dibujos("97g.alg"); + descomprime_dibujo(dir_hare_dch, 1); + if ((term_int == 1) || (getscan() == ESC)) + break; + + anima("lev.bin", 15); + if ((term_int == 1) || (getscan() == ESC)) + break; + + lleva_al_hare(100 + ancho_hare / 2, 99 + alto_hare); + if ((term_int == 1) || (getscan() == ESC)) + break; + sentido_hare = 1; + hare_x = 100; + hare_y = 95; + + habla_bj(TEXTBJ2, "BJ2.als"); + hablar(TEXT215, "215.als"); + habla_bj(TEXTBJ3, "BJ3.als"); + hablar(TEXT216, "216.als"); + habla_bj(TEXTBJ4, "BJ4.als"); + habla_bj(TEXTBJ5, "BJ5.als"); + habla_bj(TEXTBJ6, "BJ6.als"); + hablar(TEXT217, "217.als"); + habla_bj(TEXTBJ7, "BJ7.als"); + hablar(TEXT218, "218.als"); + habla_bj(TEXTBJ8, "BJ8.als"); + hablar(TEXT219, "219.als"); + habla_bj(TEXTBJ9, "BJ9.als"); + hablar(TEXT220, "220.als"); + hablar(TEXT221, "221.als"); + habla_bj(TEXTBJ10, "BJ10.als"); + hablar(TEXT222, "222.als"); + anima("gaf.bin", 15); + anima("bjb.bin", 14); + playmusic(9); + if ((term_int == 1) || (getscan() == ESC)) + break; + lee_dibujos("97.alg"); + if ((term_int == 1) || (getscan() == ESC)) + break; + descomprime_dibujo(dir_hare_dch, 1); + if ((term_int == 1) || (getscan() == ESC)) + break; + refresca_pantalla(); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + if ((term_int == 1) || (getscan() == ESC)) + break; + pausa(120); + if ((term_int == 1) || (getscan() == ESC)) + break; + habla_solo(TEXT223, "223.als"); + if ((term_int == 1) || (getscan() == ESC)) + break; + color_solo = BLANCO; + refresca_pantalla(); + if ((term_int == 1) || (getscan() == ESC)) + break; + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + pausa(110); + habla_solo(TEXTBJ11, "BJ11.als"); + if ((term_int == 1) || (getscan() == ESC)) + break; + refresca_pantalla(); + if ((term_int == 1) || (getscan() == ESC)) + break; + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + if ((term_int == 1) || (getscan() == ESC)) + break; + pausa(118); + if ((term_int == 1) || (getscan() == ESC)) + break; + lleva_al_hare(132, 97 + alto_hare); + pausa(60); + if ((term_int == 1) || (getscan() == ESC)) + break; + hablar(TEXT224, "224.als"); + if ((term_int == 1) || (getscan() == ESC)) + break; + habla_bj(TEXTBJ12, "BJ12.als"); + lleva_al_hare(157, 98 + alto_hare); + if ((term_int == 1) || (getscan() == ESC)) + break; + anima("bes.bin", 16); + playmusic(11); + anima("rap.bin", 16); + if ((term_int == 1) || (getscan() == ESC)) + break; + sentido_hare = 3; + strcpy(num_room, "no_bj.alg"); + if ((term_int == 1) || (getscan() == ESC)) + break; + pausa(8); + refresca_pantalla(); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + hablar(TEXT225, "225.als"); + pausa(76); + if ((term_int == 1) || (getscan() == ESC)) + break; + sentido_hare = 1; + refresca_pantalla(); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + hablar(TEXT226, "226.als"); + if ((term_int == 1) || (getscan() == ESC)) + break; + refresca_pantalla(); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + pausa(30); + if ((term_int == 1) || (getscan() == ESC)) + break; + hablar(TEXT227,"227.als"); + FundeAlNegro(0); + break; + } + salir_al_dos(2); +} + +void DrasculaEngine::sin_verbo() { + int c = 171; + if (menu_scr == 1) + c = 0; + if (lleva_objeto==1) + suma_objeto(objeto_que_lleva); + DIBUJA_FONDO(0, c, 0, 0, ANCHOBJ,ALTOBJ, dir_hare_fondo, dir_dibujo3); + + lleva_objeto = 0; + hay_nombre = 0; +} + +void DrasculaEngine::para_cargar(char nom_game[]) { + musica_antes = musica_room; + menu_scr = 0; + carga_partida(nom_game); + carga_escoba(datos_actuales); + sin_verbo(); +} + +void DrasculaEngine::carga_escoba(char nom_fich[13]) { + int l, obj_salir; + float chiquez, pequegnez = 0; + char para_codificar[13]; + + hay_nombre = 0; + + strcpy(para_codificar, nom_fich); + canal_p(para_codificar); + strcpy(datos_actuales, nom_fich); + + buffer_teclado(); + + // TODO + if ((ald = fopen(nom_fich, "rb")) == NULL) { + error("missing data file"); + } + fscanf(ald, "%s", num_room); + strcat(num_room,".alg"); + fscanf(ald, "%d", &musica_room); + fscanf(ald, "%s", pantalla_disco); + fscanf(ald, "%d", &nivel_osc); + + fscanf(ald, "%d", &objs_room); + + for (l = 0; l < objs_room;l++) { + fscanf(ald, "%d", &num_obj[l]); + fscanf(ald, "%s", nombre_obj[l]); + fscanf(ald, "%d", &x1[l]); + fscanf(ald, "%d", &y1[l]); + fscanf(ald, "%d", &x2[l]); + fscanf(ald, "%d", &y2[l]); + fscanf(ald, "%d", &sitiobj_x[l]); + fscanf(ald, "%d", &sitiobj_y[l]); + fscanf(ald, "%d", &sentidobj[l]); + fscanf(ald, "%d", &visible[l]); + fscanf(ald, "%d", &espuerta[l]); + if (espuerta[l] != 0) { + fscanf(ald, "%s", alapantallakeva[l]); + fscanf(ald, "%d", &x_alakeva[l]); + fscanf(ald, "%d", &y_alakeva[l]); + fscanf(ald, "%d", &sentido_alkeva[l]); + fscanf(ald, "%d", &alapuertakeva[l]); + puertas_cerradas(l); + } + } + + fscanf(ald, "%d", &suelo_x1); + fscanf(ald, "%d", &suelo_y1); + fscanf(ald, "%d", &suelo_x2); + fscanf(ald, "%d", &suelo_y2); + + fscanf(ald, "%d", &lejos); + fscanf(ald, "%d", &cerca); + + fclose(ald); + canal_p(para_codificar); + + for (l = 0; l < objs_room; l++) { + if (num_obj[l] == obj_saliendo) + obj_salir = l; + } + + lee_dibujos(pantalla_disco); + descomprime_dibujo(dir_dibujo3, 1); + + lee_dibujos(num_room); + descomprime_dibujo(dir_dibujo1, MEDIA); + + DIBUJA_FONDO(0, 171, 0, 0, ANCHOBJ, ALTOBJ, dir_hare_fondo, dir_dibujo3); + + color_hare(); + if (nivel_osc != 0) + funde_hare(nivel_osc); + paleta_hare_claro(); + color_hare(); + funde_hare(nivel_osc + 2); + paleta_hare_oscuro(); + + hare_claro(); + cambio_de_color = -1; + + for (l = 0; l <= suelo_y1; l++) + factor_red[l] = lejos; + for (l = suelo_y1; l <= 201; l++) + factor_red[l] = cerca; + + chiquez = (float)(cerca-lejos) / (float)(suelo_y2 - suelo_y1); + for (l = suelo_y1; l <= suelo_y2; l++){ + factor_red[l] = lejos + pequegnez; + pequegnez = pequegnez + chiquez; + } + + if (hare_x == -1) { + hare_x = x_alakeva[obj_salir]; + hare_y = y_alakeva[obj_salir]; + alto_hare = (ALTO_PERSONAJE * factor_red[hare_y]) / 100; + ancho_hare = (ANCHO_PERSONAJE * factor_red[hare_y]) / 100; + hare_y = hare_y - alto_hare; + } else { + alto_hare = (ALTO_PERSONAJE * factor_red[hare_y]) / 100; + ancho_hare = (ANCHO_PERSONAJE * factor_red[hare_y]) / 100; + } + hare_se_mueve=0; + + actualiza_datos(); + + espuerta[7] = 0; + + if (musica_antes != musica_room) + playmusic(musica_room); + refresca_pantalla(); +} + +void DrasculaEngine::borra_pantalla() { + memset(VGA, 0, 64000); + g_system->copyRectToScreen((const byte *)VGA, 320, 0, 0, 320, 200); +} + +void DrasculaEngine::lleva_al_hare(int punto_x, int punto_y) { + sitio_x=punto_x; + sitio_y=punto_y; + empieza_andar(); + + for(;;) { + refresca_pantalla(); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + if (hare_se_mueve == 0) + break; + } + + if (anda_a_objeto == 1) { + anda_a_objeto = 0; + sentido_hare = sentido_final; + } + refresca_pantalla(); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); +} + +void DrasculaEngine::mueve_cursor() { + int pos_cursor[8]; + + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); + + actualiza_refresco_antes(); + pon_hare(); + actualiza_refresco(); + + if (!strcmp(texto_nombre, "hacker") && hay_nombre == 1) { + if (color != ROJO && menu_scr == 0) + color_abc(ROJO); + } else if (menu_scr == 0 && color != VERDE_CLARO) + color_abc(VERDE_CLARO); + if (hay_nombre == 1 && menu_scr == 0) + centra_texto(texto_nombre, x_raton, y_raton); + if (menu_scr == 1) + menu_sin_volcar(); + else if (menu_bar == 1) + barra_menu(); + + pos_cursor[0] = 0; + pos_cursor[1] = 0; + pos_cursor[2] = x_raton - 20; + pos_cursor[3] = y_raton - 17; + pos_cursor[4] = ANCHOBJ; + pos_cursor[5] = ALTOBJ; + DIBUJA_BLOQUE_CUT(pos_cursor, dir_dibujo3, dir_zona_pantalla); +} + +void DrasculaEngine::comprueba_objetos() { + int l, veo = 0; + + for (l = 0; l < objs_room; l++) { + if (x_raton > x1[l] && y_raton > y1[l] + && x_raton < x2[l] && y_raton < y2[l] + && visible[l] == 1 && espuerta[l] == 0) { + strcpy(texto_nombre, nombre_obj[l]); + hay_nombre=1; + veo=1; + } + } + + if (x_raton > hare_x + 2 && y_raton > hare_y + 2 + && x_raton < hare_x + ancho_hare - 2 && y_raton < hare_y + alto_hare - 2 && veo == 0) { + strcpy(texto_nombre, "hacker"); + hay_nombre=1; + veo=1; + } + + if (veo == 0) + hay_nombre = 0; +} + +void DrasculaEngine::espera_soltar() { + // TODO + //boton_izq=sal.w.bx & 1; + //boton_dch=(sal.w.bx >> 1) & 1; + //x_raton=sal.w.cx >> 1; + //y_raton=sal.w.dx; +} + +void DrasculaEngine::MirarRaton() { + // TODO + //boton_izq=sal.w.bx & 1; + //boton_dch=(sal.w.bx >> 1) & 1; + //x_raton=sal.w.cx >> 1; + //y_raton=sal.w.dx; +} + +void DrasculaEngine::elige_en_barra() { + int n, num_verbo = -1; + + for (n = 0; n < 7; n++) + if (x_raton > x_barra[n] && x_raton < x_barra[n + 1]) + num_verbo = n; + + if (num_verbo < 1) + sin_verbo(); + else + elige_verbo(num_verbo); +} + +void DrasculaEngine::comprueba1() { + int l; + + if (menu_scr == 1) + saca_objeto(); + else { + for (l = 0; l < objs_room; l++) { + if (x_raton >= x1[l] && y_raton >= y1[l] + && x_raton <= x2[l] && y_raton <= y2[l] && rompo == 0) { + sal_de_la_habitacion(l); + if (rompo == 1) + break; + } + } + + if (x_raton > hare_x && y_raton > hare_y + && x_raton < hare_x + ancho_hare && y_raton < hare_y + alto_hare) + rompo = 1; + + for (l = 0; l < objs_room; l++) { + if (x_raton > x1[l] && y_raton > y1[l] + && x_raton < x2[l] && y_raton < y2[l] && rompo == 0) { + sitio_x = sitiobj_x[l]; + sitio_y = sitiobj_y[l]; + sentido_final = sentidobj[l]; + rompo = 1; + anda_a_objeto = 1; + empieza_andar(); + } + } + + if (rompo == 0) { + sitio_x = x_raton; + sitio_y = y_raton; + + if (sitio_x < suelo_x1) + sitio_x = suelo_x1; + if (sitio_x > suelo_x2) + sitio_x = suelo_x2; + if (sitio_y < suelo_y1 + alto_pies) + sitio_y = suelo_y1 + alto_pies; + if (sitio_y > suelo_y2) + sitio_y = suelo_y2; + + empieza_andar(); + } + rompo = 0; + } +} + +void DrasculaEngine::comprueba2() { + int l; + + if (menu_scr == 1) + coge_objeto(); + else { + if (!strcmp(texto_nombre, "hacker") && hay_nombre == 1) + banderas(50); + else + for (l = 0; l < objs_room; l++) { + if (x_raton > x1[l] && y_raton > y1[l] + && x_raton < x2[l] && y_raton < y2[l] && visible[l] == 1) { + sentido_final = sentidobj[l]; + anda_a_objeto = 1; + lleva_al_hare(sitiobj_x[l], sitiobj_y[l]); + banderas(num_obj[l]); + } + } + } +} + +char DrasculaEngine::getscan() { + // TODO return 0; +} + +void DrasculaEngine::elige_verbo(int verbo) { + int c = 171; + + if (menu_scr == 1) + c = 0; + if (lleva_objeto == 1) + suma_objeto(objeto_que_lleva); + + DIBUJA_FONDO(ANCHOBJ * verbo, c, 0, 0, ANCHOBJ, ALTOBJ, dir_hare_fondo, dir_dibujo3); + + lleva_objeto = 1; + objeto_que_lleva = verbo; +} + +void DrasculaEngine::mesa() { + int nivel_master, nivel_voc, nivel_cd; + + DIBUJA_BLOQUE(1, 56, 73, 63, 177, 97, dir_mesa, dir_zona_pantalla); + VUELCA_PANTALLA(73, 63, 73, 63, 177, 97, dir_zona_pantalla); + + for (;;) { + nivel_master = 72 + 61 - (12/*Master*/ * 4); + nivel_voc = 72 + 61 - (12/*Voc*/ * 4); + nivel_cd = 72 + 61 - (10/*CD*/ * 4); + + refresca_pantalla(); + + DIBUJA_BLOQUE(1, 56, 73, 63, 177, 97, dir_mesa, dir_zona_pantalla); + + DIBUJA_FONDO(183, 56, 82, nivel_master, 39, 2 + (12/*Master*/ * 4), dir_mesa, dir_zona_pantalla); + DIBUJA_FONDO(183, 56, 138, nivel_voc, 39, 2 + (12/*Voc*/ * 4), dir_mesa, dir_zona_pantalla); + DIBUJA_FONDO(183, 56, 194, nivel_cd, 39, 2 + (10/*CD*/ * 4), dir_mesa, dir_zona_pantalla); + + cursor_mesa(); + + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + + MirarRaton(); + + if (boton_dch == 1) + break; + if (boton_izq == 1) { + if (x_raton > 80 && x_raton < 121) { +// TODO +// if (y_raton < nivel_master && Master < 15) +// Master++; +// if (y_raton > nivel_master && Master > 0) +// Master--; +// SetMasterVolume(Master); + } + + if (x_raton > 136 && x_raton < 178) { +// TODO +// if (y_raton < nivel_voc && Voc < 15) +// Voc++; +// if (y_raton > nivel_voc && Voc > 0) +// Voc--; +// SetVocVolume(Voc); + } + + if (x_raton > 192 && x_raton < 233) { +// TODO +// if (y_raton < nivel_cd && CD < 15) +// CD++; +// if (y_raton > nivel_cd && CD > 0) +// CD--; +// SetCDVolume(CD); + } + } + + } + + espera_soltar(); +} + +void DrasculaEngine::saves() { + char nombres[10][23]; + char fichero[13]; + int n, n2, num_sav, y = 27; + FILE *sav; + + borra_pantalla(); + + if ((sav = fopen("saves.epa", "r")) == NULL) { + error("Can't open saves.epa file."); + } + for (n = 0; n < NUM_SAVES; n++) + fscanf(sav, "%s", nombres[n]); + fclose(sav); + + lee_dibujos("savescr.alg"); + descomprime_dibujo(dir_dibujo1, MEDIA); + + color_abc(VERDE_CLARO); + + for (;;) { + y = 27; + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); + for (n = 0; n < NUM_SAVES; n++) { + print_abc(nombres[n], 116, y); + y = y + 9; + } + print_abc(select, 117, 15); + cursor_mesa(); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + y = 27; + + MirarRaton(); + + if (boton_izq == 1) { + for (n = 0; n < NUM_SAVES; n++) { + if (x_raton > 115 && y_raton > y + (9 * n) && x_raton < 115 + 175 && y_raton < y + 10 + (9 * n)) { + strcpy(select, nombres[n]); + + if (strcmp(select, "*")) + hay_seleccion = 1; + else { + introduce_nombre(); + strcpy(nombres[n], select); + if (hay_seleccion == 1) { + if (n == 0) + strcpy(fichero, "gsave01"); + if (n == 1) + strcpy(fichero, "gsave02"); + if (n == 2) + strcpy(fichero, "gsave03"); + if (n == 3) + strcpy(fichero, "gsave04"); + if (n == 4) + strcpy(fichero, "gsave05"); + if (n == 5) + strcpy(fichero, "gsave06"); + if (n == 6) + strcpy(fichero, "gsave07"); + if (n == 7) + strcpy(fichero, "gsave08"); + if (n == 8) + strcpy(fichero, "gsave09"); + if (n == 9) + strcpy(fichero, "gsave10"); + para_grabar(fichero); + // TODO + if ((sav = fopen("saves.epa", "w")) == NULL) { + error("no puedo abrir el archivo de partidas."); + } + for (n = 0; n < NUM_SAVES; n++) + fprintf(sav, "%s\n", nombres[n]); + fclose(sav); + } + } + + print_abc(select, 117, 15); + y = 27; + for (n2 = 0; n2 < NUM_SAVES; n2++) { + print_abc(nombres[n2], 116, y); + y = y + 9; + } + if (hay_seleccion == 1) { + if (n == 0) + strcpy(fichero, "gsave01"); + if (n == 1) + strcpy(fichero, "gsave02"); + if (n == 2) + strcpy(fichero, "gsave03"); + if (n == 3) + strcpy(fichero, "gsave04"); + if (n == 4) + strcpy(fichero, "gsave05"); + if (n == 5) + strcpy(fichero, "gsave06"); + if (n == 6) + strcpy(fichero, "gsave07"); + if (n == 7) + strcpy(fichero, "gsave08"); + if (n == 8) + strcpy(fichero, "gsave09"); + if (n == 9) + strcpy(fichero, "gsave10");} + num_sav = n; + } + } + + if (x_raton > 117 && y_raton > 15 && x_raton < 295 && y_raton < 24 && hay_seleccion == 1) { + introduce_nombre(); + strcpy(nombres[num_sav], select); + print_abc(select, 117, 15); + y = 27; + for (n2 = 0; n2 < NUM_SAVES; n2++) { + print_abc(nombres[n2], 116, y); + y = y + 9; + } + } + + if (x_raton > 125 && y_raton > 123 && x_raton < 199 && y_raton < 149 && hay_seleccion == 1) { + para_cargar(fichero); + break; + } else if (x_raton > 208 && y_raton > 123 && x_raton < 282 && y_raton < 149 && hay_seleccion == 1) { + para_grabar(fichero); + if ((sav = fopen("saves.epa", "w")) == NULL) { + error("no puedo abrir el archivo de partidas."); + } + for (n = 0; n < NUM_SAVES; n++) + fprintf(sav, "%s\n", nombres[n]); + fclose(sav); + } else if (x_raton > 168 && y_raton > 154 && x_raton < 242 && y_raton < 180) + break; + else if (hay_seleccion == 0) { + print_abc("elige una partida",117,15); + } + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + delay(400); + } + y = 26; + } + + borra_pantalla(); + lee_dibujos(num_room); + descomprime_dibujo(dir_dibujo1, MEDIA); + buffer_teclado(); + hay_seleccion = 0; +} + +void DrasculaEngine::print_abc(char dicho[], int x_pantalla, int y_pantalla) { + int pos_texto[8]; + int i, y_de_letra = 0, x_de_letra = 0, h, longitud; + longitud = strlen(dicho); + + for (i = 0; dicho[i]; i++) + dicho[i] = toupper(dicho[i]); + + for (h = 0; h < longitud; h++) { + y_de_letra = Y_ABC; + + if (dicho[h] == 'A') + x_de_letra = X_A; + else if (dicho[h] == 'B') + x_de_letra = X_B; + else if (dicho[h] == 'C') + x_de_letra = X_C; + else if (dicho[h] == 'D') + x_de_letra = X_D; + else if (dicho[h] == 'E') + x_de_letra = X_E; + else if (dicho[h] == 'F') + x_de_letra = X_F; + else if (dicho[h] == 'G') + x_de_letra = X_G; + else if (dicho[h] == 'H') + x_de_letra = X_H; + else if (dicho[h] == 'I') + x_de_letra = X_I; + else if (dicho[h] == 'J') + x_de_letra = X_J; + else if (dicho[h] == 'K') + x_de_letra = X_K; + else if (dicho[h] == 'L') + x_de_letra = X_L; + else if (dicho[h] == 'M') + x_de_letra = X_M; + else if (dicho[h] == 'N') + x_de_letra = X_N; + else if (dicho[h] == '') + x_de_letra = X_GN; + else if (dicho[h] == '') + x_de_letra = X_GN; + else if (dicho[h] == 'O') + x_de_letra = X_O; + else if (dicho[h] == 'P') + x_de_letra = X_P; + else if (dicho[h] == 'Q') + x_de_letra = X_Q; + else if (dicho[h] == 'R') + x_de_letra = X_R; + else if (dicho[h] == 'S') + x_de_letra = X_S; + else if (dicho[h] == 'T') + x_de_letra = X_T; + else if (dicho[h] == 'U') + x_de_letra = X_U; + else if (dicho[h] == 'V') + x_de_letra = X_V; + else if (dicho[h] == 'W') + x_de_letra = X_W; + else if (dicho[h] == 'X') + x_de_letra = X_X; + else if (dicho[h] == 'Y') + x_de_letra = X_Y; + else if (dicho[h] == 'Z') + x_de_letra = X_Z; + else if (dicho[h] == '' || dicho[h] == ' ') + x_de_letra = ESPACIO; + else { + y_de_letra = Y_SIGNOS; + if (dicho[h] == '.') + x_de_letra = X_PUNTO; + else if (dicho[h] == ',') + x_de_letra = X_COMA; + else if (dicho[h] == '-') + x_de_letra = X_GUION; + else if (dicho[h] == '?') + x_de_letra = X_CIERRA_INTERROGACION; + else if (dicho[h] == '') + x_de_letra = X_ABRE_INTERROGACION; + else if (dicho[h] == '"') + x_de_letra = X_COMILLAS; + else if (dicho[h] == '!') + x_de_letra = X_CIERRA_EXCLAMACION; + else if (dicho[h] == '') + x_de_letra = X_ABRE_EXCLAMACION; + else if (dicho[h] == ';') + x_de_letra = X_PUNTO_Y_COMA; + else if (dicho[h] == '>') + x_de_letra = X_MAYOR_QUE; + else if (dicho[h] == '<') + x_de_letra = X_MENOR_QUE; + else if (dicho[h] == '$') + x_de_letra = X_DOLAR; + else if (dicho[h] == '%') + x_de_letra = X_POR_CIENTO; + else if (dicho[h] == ':') + x_de_letra = X_DOS_PUNTOS; + else if (dicho[h] == '&') + x_de_letra = X_AND; + else if (dicho[h] == '/') + x_de_letra = X_BARRA; + else if (dicho[h] == '(') + x_de_letra = X_ABRE_PARENTESIS; + else if (dicho[h] == ')') + x_de_letra = X_CIERRA_PARENTESIS; + else if (dicho[h] == '*') + x_de_letra = X_ASTERISCO; + else if (dicho[h] == '+') + x_de_letra = X_MAS; + else if (dicho[h] == '1') + x_de_letra = X_N1; + else if (dicho[h] == '2') + x_de_letra = X_N2; + else if (dicho[h] == '3') + x_de_letra = X_N3; + else if (dicho[h] == '4') + x_de_letra = X_N4; + else if (dicho[h] == '5') + x_de_letra = X_N5; + else if (dicho[h] == '6') + x_de_letra = X_N6; + else if (dicho[h] == '7') + x_de_letra = X_N7; + else if (dicho[h] == '8') + x_de_letra = X_N8; + else if (dicho[h] == '9') + x_de_letra = X_N9; + else if (dicho[h] == '0') + x_de_letra = X_N0; + else + y_de_letra = Y_ACENTOS; + + if (dicho[h] == '') + x_de_letra = X_A; + else if (dicho[h] == '') + x_de_letra = X_B; + else if (dicho[h] == '') + x_de_letra = X_C; + else if (dicho[h] == '') + x_de_letra = X_D; + else if (dicho[h] == '') + x_de_letra = X_E; + else if (dicho[h] == '') + x_de_letra = X_F; + else if (dicho[h] == '') + x_de_letra = X_G; + else if (dicho[h] == '') + x_de_letra = X_H; + else if (dicho[h] == '') + x_de_letra = X_I; + else if (dicho[h] == '') + x_de_letra = X_J; + else if (dicho[h] == '') + x_de_letra = X_K; + else if (dicho[h] == '') + x_de_letra = X_L; + else if (dicho[h] == '') + x_de_letra = X_M; + else if (dicho[h] == '') + x_de_letra = X_N; + else if (dicho[h] == '') + x_de_letra = X_GN; + else if (dicho[h] == '\'') + x_de_letra = X_O; + else if (dicho[h] == '') + x_de_letra = X_P; + else if (dicho[h] == '') + x_de_letra = X_P; + else if (dicho[h] == '') + x_de_letra = X_A; + else if (dicho[h] == '') + x_de_letra = X_B; + else if (dicho[h] == '') + x_de_letra = X_C; + else if (dicho[h] == '') + x_de_letra = X_D; + else if (dicho[h] == '') + x_de_letra = X_E; + else if (dicho[h] == '') + x_de_letra = X_F; + else if (dicho[h] == '') + x_de_letra = X_G; + else if (dicho[h] == '') + x_de_letra = X_H; + else if (dicho[h] == '') + x_de_letra = X_I; + else if (dicho[h] == '') + x_de_letra = X_J; + else if (dicho[h] == '') + x_de_letra = X_K; + else if (dicho[h] == '') + x_de_letra = X_L; + else if (dicho[h] == '') + x_de_letra = X_M; + else if (dicho[h] == '') + x_de_letra = X_N; + else if (dicho[h] == '') + x_de_letra = X_GN; + } + + pos_texto[0] = x_de_letra; + pos_texto[1] = y_de_letra; + pos_texto[2] = x_pantalla; + pos_texto[3] = y_pantalla; + pos_texto[4] = ANCHO_LETRAS; + pos_texto[5] = ALTO_LETRAS; + + DIBUJA_BLOQUE_CUT(pos_texto, dir_texto, dir_zona_pantalla); + + x_pantalla = x_pantalla + ANCHO_LETRAS; + if (x_pantalla > 317) { + x_pantalla = 0; + y_pantalla = y_pantalla + ALTO_LETRAS + 2; + } + } } +void DrasculaEngine::delay(int ms) { + g_system->delayMillis(ms); +} + +void DrasculaEngine::confirma_go() { + color_abc(ROJO); + refresca_pantalla(); + centra_texto(SYS0, 160, 87); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + + for (;;) { + key = getscan(); + if (key != 0) + break; + } + + if (key == 83) { + stopmusic(); + carga_partida("gsave00"); + } +} + +void DrasculaEngine::confirma_salir() { + color_abc(ROJO); + refresca_pantalla(); + centra_texto(SYS1, 160, 87); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + + for (;;) { + key = getscan(); + if (key != 0) + break; + } + + if (key == ESC) { + stopmusic(); + salir_al_dos(0); + } +} + +void DrasculaEngine::salva_pantallas() { + int xr, yr; + + borra_pantalla(); + + lee_dibujos("sv.alg"); + descomprime_dibujo(dir_dibujo1, MEDIA); + //TODO inicio_ghost(); + //TODO carga_ghost(); + + MirarRaton(); + xr = x_raton; + yr = y_raton; + + for (;;) { + //TODO efecto(dir_dibujo1); + MirarRaton(); + if (boton_dch == 1 || boton_izq == 1) + break; + if (x_raton != xr) + break; + if (y_raton != yr) + break; + } + //TODO fin_ghost(); + lee_dibujos(num_room); + descomprime_dibujo(dir_dibujo1, MEDIA); +} + +void DrasculaEngine::fliplay(char filefli[], int vel) { + return; + // TODO + OpenSSN(filefli, vel); + while (PlayFrameSSN() && (!term_int)) { + if (chkkey() == 27) + term_int = 1; + } + EndSSN(); +} + +void DrasculaEngine::FundeDelNegro(int VelocidadDeFundido) { + char fundido; + unsigned int color, componente; + + DacPalette256 palFundido; + + for (fundido = 0; fundido < 64; fundido++) { + for (color = 0; color < 256; color++) { + for (componente = 0; componente < 3; componente++) { + palFundido[color][componente] = LimitaVGA(palJuego[color][componente] - 63 + fundido); + palFundido[color][3] = 0; + } + } + pausa(VelocidadDeFundido); + + setvgapalette256(&palFundido); + } +} + +void DrasculaEngine::color_abc(int cl) { + color = cl; + + if (cl == 0) { + palJuego[254][0] = 0; + palJuego[254][1] = 0; + palJuego[254][2] = 0; + palJuego[254][3] = 0; + } else if (cl == 1) { + palJuego[254][0] = 0x10; + palJuego[254][1] = 0x3E; + palJuego[254][2] = 0x28; + palJuego[254][3] = 0; + } else if (cl == 3) { + palJuego[254][0] = 0x16; + palJuego[254][1] = 0x3F; + palJuego[254][2] = 0x16; + palJuego[254][3] = 0; + } else if (cl == 4) { + palJuego[254][0] = 0x9; + palJuego[254][1] = 0x3F; + palJuego[254][2] = 0x12; + palJuego[254][3] = 0; + } else if (cl == 5) { + palJuego[254][0] = 0x3F; + palJuego[254][1] = 0x3F; + palJuego[254][2] = 0x15; + palJuego[254][3] = 0; + } else if (cl == 7) { + palJuego[254][0] = 0x38; + palJuego[254][1] = 0; + palJuego[254][2] = 0; + palJuego[254][3] = 0; + } else if (cl == 8) { + palJuego[254][0] = 0x3F; + palJuego[254][1] = 0x27; + palJuego[254][2] = 0x0B; + palJuego[254][3] = 0; + } else if (cl == 9) { + palJuego[254][0] = 0x2A; + palJuego[254][1] = 0; + palJuego[254][2] = 0x2A; + palJuego[254][3] = 0; + } else if (cl == 10) { + palJuego[254][0] = 0x30; + palJuego[254][1] = 0x30; + palJuego[254][2] = 0x30; + palJuego[254][3] = 0; + } else if (cl == 11) { + palJuego[254][0] = 98; + palJuego[254][1] = 91; + palJuego[254][2] = 100; + palJuego[254][3] = 0; + }; + + setvgapalette256(&palJuego); +} + +char DrasculaEngine::LimitaVGA(char valor) { + return (valor & 0x3F) * (valor > 0); +} + +void DrasculaEngine::centra_texto(char mensaje[], int x_texto, int y_texto) { + char bb[190], m2[190], m1[190] ,mb[10][40]; + char m3[190]; + int h, fil, x_texto3, x_texto2, x_texto1, conta_f = 0, ya = 0; + + strcpy(m1, " "); + strcpy(m2, " "); + strcpy(m3, " "); + strcpy(bb, " "); + + for (h = 0; h < 10; h++) + strcpy(mb[h], " "); + + if (x_texto > 160) + ya = 1; + + strcpy(m1, mensaje); + if (x_texto < 60) + x_texto=60; + if (x_texto > 255) + x_texto=255; + + x_texto1 = x_texto; + + if (ya == 1) + x_texto1 = 315 - x_texto; + + x_texto2 = (strlen(m1) / 2) * ANCHO_LETRAS; + +tut: + strcpy(bb, m1); + strrev(bb); + + if (x_texto1 < x_texto2) { + strcpy(m3, strrchr(m1, ' ')); + strcpy(m1, strstr(bb, " ")); + strrev(m1); + m1[strlen(m1) - 1] = '\0'; + strcat(m3, m2); + strcpy(m2, m3); + }; + + x_texto2 = (strlen(m1) / 2) * ANCHO_LETRAS; + if (x_texto1 < x_texto2) + goto tut; + strcpy(mb[conta_f], m1); + + if (!strcmp(m2, "")) + goto imprimir; + strrev(m2); + m2[strlen(m2) - 1] = '\0'; + strrev(m2); + strcpy(m1, m2); + strcpy(m2, ""); + conta_f++; + + goto tut; + +imprimir: + + fil = y_texto - (((conta_f + 3) * ALTO_LETRAS)); + + for (h = 0; h < conta_f + 1; h++) { + x_texto3 = strlen(mb[h]) / 2; + print_abc(mb[h], ((x_texto) - x_texto3 * ANCHO_LETRAS) - 1, fil); + fil = fil + ALTO_LETRAS + 2; + } +} + +void DrasculaEngine::comienza_sound(char fichero[]) { + if (hay_sb == 1) { + if ((sku = fopen(fichero, "rb")) == NULL) { + error("no puedo abrir archivo de voz"); + } + } + ctvd_init(2); + ctvd_speaker(1); + ctvd_output(sku); +} + +void DrasculaEngine::anima(char animacion[], int FPS) { + Common::File FileIn; + unsigned Org = 0, Des = 0, j, TotDes = 0; + int NFrames = 1, New = 1; + int cnt = 2; + + TimeMed = CLOCKS_PER_SEC / FPS; + AuxBuffLast = (char *)malloc(65000); + AuxBuffDes = (char *)malloc(65000); + + FileIn.open(animacion); + + if (!FileIn.isOpen()) { + error("No encuentro un fichero de animacion."); + } + + FileIn.read(&NFrames, sizeof(NFrames)); + FileIn.read(&Leng, sizeof(Leng)); + AuxBuffOrg = (char *)malloc(Leng); + FileIn.read(AuxBuffOrg, Leng); + FileIn.read(cPal, 768); + carga_pcx(AuxBuffOrg); + free(AuxBuffOrg); + memcpy(VGA, AuxBuffDes, 64000); + g_system->copyRectToScreen((const byte *)VGA, 320, 0, 0, 320, 200); + set_dac(cPal); + memcpy(AuxBuffLast, AuxBuffDes, 64000); + WaitForNext(TimeMed); + while (cnt < NFrames) { + FileIn.read(&Leng, sizeof(Leng)); + AuxBuffOrg = (char *)malloc(Leng); + FileIn.read(AuxBuffOrg, Leng); + FileIn.read(cPal, 768); + carga_pcx(AuxBuffOrg); + free(AuxBuffOrg); + for (j = 0;j < 64000; j++) { + VGA[j] = AuxBuffLast[j] = AuxBuffDes[j] ^ AuxBuffLast[j]; + } + g_system->copyRectToScreen((const byte *)VGA, 320, 0, 0, 320, 200); + WaitForNext(TimeMed); + cnt++; + key = getscan(); + if (key == 0x01) + term_int = 1; + if (key !=0) + break; + } + free(AuxBuffLast); + free(AuxBuffDes); + FileIn.close(); +} + +void DrasculaEngine::animafin_sound_corte() { + if (hay_sb == 1) { + ctvd_stop(); + fclose(sku); + ctvd_terminate(); + } +} + +void DrasculaEngine::FundeAlNegro(int VelocidadDeFundido) { + char fundido; + unsigned int color, componente; + + DacPalette256 palFundido; + + for (fundido = 63; fundido >= 0; fundido--) { + for (color = 0; color < 256; color++) { + for (componente = 0; componente < 3; componente++) { + palFundido[color][componente] = LimitaVGA(palJuego[color][componente] - 63 + fundido); + palFundido[color][3] = 0; + } + } + pausa(VelocidadDeFundido); + + setvgapalette256(&palFundido); + } +} + +void DrasculaEngine::pausa(int cuanto) { + int diferencia, conta_antes; + + conta_antes = vez(); + + for (;;) { + diferencia = vez() - conta_antes; + if (diferencia >= 2 * cuanto) + break; + } +} + +void DrasculaEngine::habla_dr_grande(char dicho[], char filename[]) { + int tiempou; + long tiempol; + int x_habla[4] = {47, 93, 139, 185}; + int cara; + int l = 0; + + int longitud; + longitud = strlen(dicho); + + tiempol = time(NULL); + tiempou = (unsigned int)tiempol / 2; + srand(tiempou); + + buffer_teclado(); + + color_abc(ROJO); + + if (hay_sb == 1) { + if ((sku = fopen(filename, "rb")) == NULL) { + error("no puedo abrir archivo de voz"); + } + ctvd_init(2); + ctvd_speaker(1); + ctvd_output(sku); + } + +bucless: + + cara = rand() % 4; + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); + DIBUJA_FONDO(interf_x[l] + 24, interf_y[l], 0, 45, 39, 31, dir_dibujo2, dir_zona_pantalla); + DIBUJA_FONDO(x_habla[cara], 1, 171, 68, 45, 48, dir_dibujo2, dir_zona_pantalla); + l++; + if (l == 7) + l=0; + + if (con_voces == 0) + centra_texto(dicho, 191, 69); + + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + + pausa(3); + + key = getscan(); + if (key == ESC) + term_int = 1; + + if (key != 0) + ctvd_stop(); + buffer_teclado(); + if (hay_sb == 1) { + if (LookForFree() != 0) + goto bucless; + fclose(sku); + ctvd_terminate(); + } else { + longitud = longitud - 2; + if (longitud > 0) + goto bucless; + } +} + +void DrasculaEngine::pon_igor() { + int pos_igor[6]; + + pos_igor[0] = 1; + if (sentido_igor == 3) + pos_igor[1] = 138; + else if (sentido_igor == 1) + pos_igor[1] = 76; + pos_igor[2] = x_igor; + pos_igor[3] = y_igor; + pos_igor[4] = 54; + pos_igor[5] = 61; + + DIBUJA_BLOQUE_CUT(pos_igor, dir_hare_frente, dir_zona_pantalla); +} + +void DrasculaEngine::pon_dr() { + int pos_dr[6]; + + if (sentido_dr == 1) + pos_dr[0] = 47; + else if (sentido_dr == 0) + pos_dr[0] = 1; + else if (sentido_dr == 3) + pos_dr[0] = 93; + pos_dr[1] = 122; + pos_dr[2] = x_dr; + pos_dr[3] = y_dr; + pos_dr[4] = 45; + pos_dr[5] = 77; + + DIBUJA_BLOQUE_CUT(pos_dr, dir_hare_fondo, dir_zona_pantalla); +} + +void DrasculaEngine::pon_bj() { + int pos_bj[6]; + + if (sentido_bj == 3) + pos_bj[0] = 10; + else if (sentido_bj == 0) + pos_bj[0] = 37; + pos_bj[1] = 99; + pos_bj[2] = x_bj; + pos_bj[3] = y_bj; + pos_bj[4] = 26; + pos_bj[5] = 76; + + DIBUJA_BLOQUE_CUT(pos_bj, dir_dibujo3, dir_zona_pantalla); +} + +void DrasculaEngine::habla_igor_dch(char dicho[], char filename[]) { + int tiempou; + long tiempol; + + int x_habla[8] = { 56, 82, 108, 134, 160, 186, 212, 238}; + int cara; + + int longitud; + longitud = strlen(dicho); + + tiempol = time (NULL); + tiempou = (unsigned int)tiempol / 2; + srand(tiempou); + + buffer_teclado(); + + color_abc(BLANCO); + + if (hay_sb == 1) { + // TODO + if ((sku = fopen(filename, "rb")) == NULL) { + error("no puedo abrir archivo de voz"); + } + ctvd_init(2); + ctvd_speaker(1); + ctvd_output(sku); + } + +bucless: + + cara = rand() % 8; + + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); + + actualiza_refresco_antes(); + + pon_igor(); + pon_dr(); + DIBUJA_FONDO(x_igor + 17, y_igor, x_igor + 17, y_igor, 37, 24, + dir_dibujo1, dir_zona_pantalla); + + DIBUJA_BLOQUE(x_habla[cara], 148, x_igor + 17, y_igor, 25, 24, + dir_hare_frente, dir_zona_pantalla); + + actualiza_refresco(); + + if (con_voces == 0) + centra_texto(dicho, x_igor + 26, y_igor); + + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + + pausa(3); + + key = getscan(); + if (key == ESC) + term_int = 1; + if (key != 0) + ctvd_stop(); + buffer_teclado(); + if (hay_sb == 1) { + if (LookForFree() != 0) + goto bucless; + fclose(sku); + ctvd_terminate(); + } else { + longitud = longitud - 2; + if (longitud > 0) + goto bucless; + } + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); + pon_igor(); + pon_dr(); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); +} + +void DrasculaEngine::habla_dr_izq(char dicho[], char filename[]) { + int tiempou; + long tiempol; + + int x_habla[8] = { 1, 40, 79, 118, 157, 196, 235, 274 }; + int cara; + + int longitud; + longitud = strlen(dicho); + + tiempol = time(NULL); // TODO + tiempou = (unsigned int)tiempol / 2; + srand(tiempou); + + buffer_teclado(); + + color_abc(ROJO); + + if (hay_sb == 1) { + // TODO + if ((sku = fopen(filename, "rb")) == NULL) { + error("no puedo abrir archivo de voz"); + } + ctvd_init(2); + ctvd_speaker(1); + ctvd_output(sku); + } + +bucless: + + cara=rand() % 8; + + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); + + actualiza_refresco_antes(); + + pon_igor(); + pon_dr(); + + DIBUJA_FONDO(x_dr, y_dr, x_dr, y_dr, 38, 31, dir_dibujo1, dir_zona_pantalla); + DIBUJA_BLOQUE(x_habla[cara], 90, x_dr, y_dr, 38, 31, + dir_hare_fondo, dir_zona_pantalla); + + actualiza_refresco(); + + if (con_voces == 0) + centra_texto(dicho, x_dr + 19, y_dr); + + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + + pausa(3); + + key = getscan(); + if (key == ESC) + term_int = 1; + if (key != 0) + ctvd_stop(); + buffer_teclado(); + if (hay_sb == 1) { + if (LookForFree() != 0) + goto bucless; + fclose(sku); + ctvd_terminate(); + } else { + longitud = longitud - 2; + if (longitud > 0) + goto bucless; + } + + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); + pon_igor(); + pon_dr(); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); +} + +void DrasculaEngine::habla_dr_dch(char dicho[], char filename[]) { + int tiempou; + long tiempol; + + int x_habla[8] = { 1, 40, 79, 118, 157, 196, 235, 274 }; + int cara; + + int longitud; + longitud = strlen(dicho); + + // TODO + tiempol = time(NULL); + tiempou = (unsigned int)tiempol / 2; + srand(tiempou); + + buffer_teclado(); + + color_abc(ROJO); + + if (hay_sb == 1) { + // TODO + if ((sku = fopen(filename, "rb")) == NULL) { + error("no puedo abrir archivo de voz"); + } + ctvd_init(2); + ctvd_speaker(1); + ctvd_output(sku); + } + +bucless: + + cara = rand() % 8; + + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); + actualiza_refresco_antes(); + + pon_igor(); + pon_dr(); + + DIBUJA_FONDO(x_dr, y_dr, x_dr, y_dr, 45, 31, dir_dibujo1, dir_zona_pantalla); + DIBUJA_BLOQUE(x_habla[cara], 58, x_dr + 7, y_dr, 38, 31, + dir_hare_fondo, dir_zona_pantalla); + + actualiza_refresco(); + + if (con_voces == 0) + centra_texto(dicho, x_dr + 19, y_dr); + + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + + pausa(3); + + key = getscan(); + if (key == ESC) + term_int = 1; + if (key != 0) + ctvd_stop(); + buffer_teclado(); + if (hay_sb == 1) { + if (LookForFree() != 0) + goto bucless; + fclose(sku); + ctvd_terminate(); + } else { + longitud = longitud - 2; + if (longitud > 0) + goto bucless; + } + + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); + pon_igor(); + pon_dr(); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); +} + +void DrasculaEngine::habla_solo(char dicho[], char filename[]) { + int tiempou; + long tiempol; + + int longitud; + longitud = strlen(dicho); + + tiempol = time(NULL); + tiempou = (unsigned int)tiempol / 2; + srand(tiempou); + + color_abc(color_solo); + + if (hay_sb == 1) { + // TODO + if ((sku = fopen(filename, "rb")) == NULL) { + error("no puedo abrir archivo de voz"); + } + ctvd_init(2); + ctvd_speaker(1); + ctvd_output(sku); + } + +bucless: + + if (con_voces == 0) + centra_texto(dicho, 156, 90); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + + key = getscan(); + if (key == ESC) + term_int = 1; + if (key != 0) + ctvd_stop(); + buffer_teclado(); + if (hay_sb == 1) { + if (LookForFree() != 0) + goto bucless; + fclose(sku); + ctvd_terminate(); + } else { + longitud = longitud - 2; + if (longitud > 0) + goto bucless; + } +} + +void DrasculaEngine::habla_igor_frente(char dicho[], char filename[]) { + int tiempou; + long tiempol; + + int x_habla[8] = { 56, 86, 116, 146, 176, 206, 236, 266}; + int cara; + + int longitud; + longitud = strlen(dicho); + + // TODO + tiempol = time(NULL); + tiempou = (unsigned int)tiempol / 2; + srand(tiempou); + + buffer_teclado(); + + color_abc(BLANCO); + + if (hay_sb == 1) { + if ((sku = fopen(filename, "rb")) == NULL) { + error("no puedo abrir archivo de voz"); + } + ctvd_init(2); + ctvd_speaker(1); + ctvd_output(sku); + } + +bucless: + + cara = rand() % 8; + + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); + + actualiza_refresco_antes(); + + pon_igor(); + pon_dr(); + DIBUJA_FONDO(x_igor, y_igor, x_igor, y_igor, 29, 25, + dir_dibujo1, dir_zona_pantalla); + DIBUJA_BLOQUE(x_habla[cara], 173, x_igor, y_igor, 29, 25, + dir_hare_frente, dir_zona_pantalla); + + actualiza_refresco(); + + if (con_voces == 0) + centra_texto(dicho, x_igor + 26, y_igor); + + VUELCA_PANTALLA(0,0, 0,0, 320,200, dir_zona_pantalla); + + pausa(3); + + key = getscan(); + if (key == ESC) + term_int = 1; + if (key != 0) + ctvd_stop(); + buffer_teclado(); + if (hay_sb == 1) { + if (LookForFree() != 0) + goto bucless; + fclose(sku); + ctvd_terminate(); + } else { + longitud = longitud - 2; + if (longitud > 0) + goto bucless; + } + + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); + pon_igor(); + pon_dr(); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); +} + +void DrasculaEngine::habla_tabernero(char dicho[], char filename[]) { + int tiempou; + long tiempol; + + int x_habla[9] = { 1, 23, 45, 67, 89, 111, 133, 155, 177}; + int cara; + + int longitud; + longitud = strlen(dicho); + + tiempol = time(NULL); + tiempou = (unsigned int)tiempol / 2; + srand(tiempou); + + buffer_teclado(); + + color_abc(MARRON); + + if (hay_sb == 1) { + // TODO + if ((sku = fopen(filename, "rb")) == NULL) { + error("no puedo abrir archivo de voz"); + } + ctvd_init(2); + ctvd_speaker(1); + ctvd_output(sku); + } + +bucless: + + if (music_status() == 0) + playmusic(musica_room); + + cara = rand() % 9; + + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); + + actualiza_refresco_antes(); + + DIBUJA_FONDO(x_habla[cara], 2, 121, 44, 21, 24, dir_hare_dch, dir_zona_pantalla); + pon_hare(); + actualiza_refresco(); + + if (con_voces == 0) + centra_texto(dicho, 132, 45); + + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + + pausa(3); + + key = getscan(); + if (key != 0) + ctvd_stop(); + buffer_teclado(); + if (hay_sb == 1) { + if (LookForFree() != 0) + goto bucless; + fclose(sku); + ctvd_terminate(); + } else { + longitud = longitud - 2; + if (longitud > 0) + goto bucless; + } + + refresca_pantalla(); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); +} + +void DrasculaEngine::hipo(int contador) { + int y = 0, sentido = 0; + + contador = contador; + +comienza: + contador--; + + refresca_pantalla(); + VUELCA_PANTALLA(0, 1, 0, y, 320, 198, dir_zona_pantalla); + + if (sentido == 0) + y++; + else + y--; + if (y == 2) + sentido = 1; + if (y == 0) + sentido = 0; + if (contador > 0) + goto comienza; + + refresca_pantalla(); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); +} + +void DrasculaEngine::fin_sound() { + delay(1); + + if (hay_sb == 1) { + while (LookForFree() != 0); + fclose(sku); + } +} + +void DrasculaEngine::habla_bj(char dicho[], char filename[]) { + int tiempou; + long tiempol; + + int x_habla[5] = { 64, 92, 120, 148, 176}; + int cara; + + int longitud; + longitud = strlen(dicho); + + tiempol = time(NULL); + tiempou = (unsigned int)tiempol / 2; + srand(tiempou); + + buffer_teclado(); + + color_abc(BLANCO); + + if (hay_sb == 1) { + // TODO + if ((sku = fopen(filename, "rb")) == NULL) { + error("no puedo abrir archivo de voz"); + } + ctvd_init(2); + ctvd_speaker(1); + ctvd_output(sku); + } + +bucless: + + cara = rand() % 5; + + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); + + actualiza_refresco_antes(); + + DIBUJA_FONDO(x_bj + 2, y_bj - 1, x_bj + 2, y_bj - 1, 27, 40, + dir_dibujo1, dir_zona_pantalla); + + DIBUJA_BLOQUE(x_habla[cara], 99, x_bj + 2, y_bj - 1, 27, 40, + dir_dibujo3, dir_zona_pantalla); + pon_hare(); + actualiza_refresco(); + + if (con_voces == 0) + centra_texto(dicho, x_bj + 7, y_bj); + + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + + pausa(3); + + key = getscan(); + if (key == ESC) + term_int = 1; + if (key != 0) + ctvd_stop(); + buffer_teclado(); + if (hay_sb == 1) { + if (LookForFree() != 0) + goto bucless; + fclose(sku); + ctvd_terminate(); + } else { + longitud = longitud - 2; + if (longitud > 0) + goto bucless; + } + + refresca_pantalla(); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); +} + +void DrasculaEngine::hablar(char dicho[], char filename[]) { + int tiempou; + long tiempol; + + int suma_1_pixel = 1; + + int y_mask_habla = 170; + int x_habla_dch[6] = { 1, 25, 49, 73, 97, 121 }; + int x_habla_izq[6] = { 145, 169, 193, 217, 241, 265 }; + int cara; + + int longitud; + longitud = strlen(dicho); + + tiempol = time(NULL); + tiempou = (unsigned int)tiempol / 2; + srand(tiempou); + + if (factor_red[hare_y + alto_hare] == 100) + suma_1_pixel = 0; + + color_abc(AMARILLO); + + if (hay_sb == 1) { + if ((sku = fopen(filename, "rb")) == NULL) { + error("no puedo abrir archivo de voz"); + } + ctvd_init(2); + ctvd_speaker(1); + ctvd_output(sku); + } + +bucless: + + cara = rand() % 6; + + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); + + actualiza_refresco_antes(); + DIBUJA_FONDO(hare_x, hare_y, ANCHOBJ+1, 0, + ((float)ancho_hare / 100) * factor_red[hare_y + alto_hare], + ((float)(alto_habla - 1) / 100) * factor_red[hare_y + alto_hare], + dir_zona_pantalla, dir_dibujo3); + pon_hare(); + + DIBUJA_FONDO(ANCHOBJ + 1, 0, hare_x, hare_y, + ((float)ancho_hare / 100) * factor_red[hare_y + alto_hare], + ((float)(alto_habla - 1) / 100) * factor_red[hare_y + alto_hare], + dir_dibujo3, dir_zona_pantalla); + + if (sentido_hare == 0) { + reduce_hare_chico(x_habla_izq[cara], y_mask_habla, + hare_x + ((float)8 / 100) * factor_red[hare_y + alto_hare], + hare_y, ancho_habla, alto_habla, factor_red[hare_y + alto_hare], + dir_hare_dch, dir_zona_pantalla); + + actualiza_refresco(); + } else if (sentido_hare == 1) { + reduce_hare_chico(x_habla_dch[cara], y_mask_habla, + hare_x + ((float)12 / 100) * factor_red[hare_y + alto_hare], + hare_y, ancho_habla,alto_habla, factor_red[hare_y + alto_hare], + dir_hare_dch, dir_zona_pantalla); + actualiza_refresco(); + } else if (sentido_hare == 2) { + reduce_hare_chico(x_habla_izq[cara], y_mask_habla, + suma_1_pixel + hare_x + ((float)12 / 100) * factor_red[hare_y + alto_hare], + hare_y, ancho_habla, alto_habla, factor_red[hare_y + alto_hare], + dir_hare_frente, dir_zona_pantalla); + actualiza_refresco(); + } else if (sentido_hare == 3) { + reduce_hare_chico(x_habla_dch[cara], y_mask_habla, + suma_1_pixel + hare_x + ((float)8 / 100) * factor_red[hare_y + alto_hare], + hare_y, ancho_habla,alto_habla, factor_red[hare_y + alto_hare], + dir_hare_frente, dir_zona_pantalla); + actualiza_refresco(); + } + + if (con_voces == 0) + centra_texto(dicho, hare_x, hare_y); + + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + + pausa(3); + + key = getscan(); + if (key == ESC) + term_int = 1; + if (key != 0) + ctvd_stop(); + buffer_teclado(); + if (hay_sb == 1) { + if (LookForFree() != 0) + goto bucless; + fclose(sku); + ctvd_terminate(); + } else { + longitud = longitud - 2; + if (longitud > 0) + goto bucless; + } + + refresca_pantalla(); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + + if (music_status() == 0 && flags[11] == 0 && corta_musica == 0) + playmusic(musica_room); +} + +void DrasculaEngine::playmusic(int p) { +// TODO +/* unsigned short v; + stopmusic(); + + v=GetCDVolume(); + if ((p==12 || p==21) && !reducido) { + SetCDVolume(v-2); + reducido = 1; + } + cd_track_length(p, &min, &sec, &frame); + cd_set_track (p); + get_musicpos(); + cd_play_audio(startpos, endpos); + Playing=1; +*/ +} + +void DrasculaEngine::stopmusic() { +//TODO +/* unsigned short v; + + cd_stop_audio (); + /v=GetCDVolume(); + if (reducido) + { + SetCDVolume(v+2); + reducido=0; + } + cd_done_play (); + Playing=0; +*/ +} + +int DrasculaEngine::music_status() { + // TODO + //cd_status(); + //return ((cdrom_data.error & BUSY) != 0); + return 0; +} + +void DrasculaEngine::refresca_pantalla() { + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); + actualiza_refresco_antes(); + pon_hare(); + actualiza_refresco(); +} + +void DrasculaEngine::carga_partida(char nom_game[]) { + int l, n_ejec2; + + canal_p(nom_game); + // TODO + if ((sku = fopen(nom_game, "rb")) == NULL) { + error("no puedo abrir el archivo"); + } + fscanf(sku, "%d", &n_ejec2); + if (n_ejec2 != num_ejec) { + fclose(sku); + canal_p(nom_game); + strcpy(nom_partida, nom_game); + salir_al_dos(n_ejec2); + } + fscanf(sku, "%s", datos_actuales); + fscanf(sku, "%d", &hare_x); + fscanf(sku, "%d", &hare_y); + fscanf(sku, "%d", &sentido_hare); + + for (l = 1; l < 43; l++) { + fscanf(sku, "%d", &objetos_que_tengo[l]); + } + + for (l = 0; l < NUM_BANDERAS; l++) { + fscanf(sku, "%d", &flags[l]); + } + + fscanf(sku, "%d", &lleva_objeto); + fscanf(sku, "%d", &objeto_que_lleva); + + fclose(sku); + canal_p(nom_game); +} + +void DrasculaEngine::canal_p(char fich[13]){ + Common::File ald2, ald3; + + char fich2[13]; + char car; + + strcpy(fich2, "top"); + + // TODO + ald3.open(fich); + if (!ald3.isOpen()) { + error("no puedo abrir el archivo codificado"); + } + + ald2.open(fich2, Common::File::kFileWriteMode); + if (!ald2.isOpen()) { + error("no puedo abrir el archivo destino"); + } + + car = ald3.readByte(); + while (!ald3.eos()) { + ald2.writeByte(codifica(car)); + car = ald3.readByte(); + } + + ald2.close(); + ald3.close(); + // TODO + remove(fich); + rename(fich2, fich); +} + +void DrasculaEngine::puertas_cerradas (int l) {} + +void DrasculaEngine::color_hare() { + int color, componente; + + for (color = 235; color < 253; color++) { + for (componente = 0; componente < 3; componente++) { + palJuego[color][componente] = palHare[color][componente]; + } + palJuego[color][3] = 0; + } + ActualizaPaleta(); +} + +void DrasculaEngine::funde_hare(int oscuridad) { + char fundido; + unsigned int color, componente; + + for (fundido = oscuridad; fundido >= 0; fundido--) { + for (color = 235; color < 253; color++) { + for (componente = 0; componente < 3; componente++) + palJuego[color][componente] = LimitaVGA( palJuego[color][componente] - 8 + fundido ); + palJuego[color][3] = 0; + } + } + + ActualizaPaleta(); +} + +void DrasculaEngine::paleta_hare_claro() { + int color, componente; + + for (color = 235; color < 253; color++) { + for (componente = 0; componente < 3; componente++) + palHareClaro[color][componente] = palJuego[color][componente]; + palHareClaro[color][3] = 0; + } +} + +void DrasculaEngine::paleta_hare_oscuro() { + int color, componente; + + for (color = 235; color < 253; color++) { + for (componente = 0; componente < 3; componente++) + palHareOscuro[color][componente] = palJuego[color][componente]; + palHareOscuro[color][3] = 0; + } +} + +void DrasculaEngine::hare_claro() { + int color, componente; + + for (color = 235; color < 253; color++) { + for (componente = 0; componente < 3; componente++) + palJuego[color][componente] = palHareClaro[color][componente]; + palJuego[color][3] = 0; + } + + ActualizaPaleta(); +} + +void DrasculaEngine::empieza_andar() { + hare_se_mueve = 1; + + paso_x = PASO_HARE_X; + paso_y = PASO_HARE_Y; + + if ((sitio_x < hare_x + ancho_hare / 2 ) && (sitio_y <= (hare_y + alto_hare))) + cuadrante_1(); + else if ((sitio_x < hare_x + ancho_hare / 2) && (sitio_y > (hare_y + alto_hare))) + cuadrante_3(); + else if ((sitio_x > hare_x + ancho_hare / 2) && (sitio_y <= (hare_y + alto_hare))) + cuadrante_2(); + else if ((sitio_x > hare_x + ancho_hare / 2) && (sitio_y > (hare_y + alto_hare))) + cuadrante_4(); + else + hare_se_mueve=0; + + conta_vez = vez(); +} + +void DrasculaEngine::actualiza_refresco() { + if (!strcmp(num_room, "63.alg")) + refresca_63(); + else if (!strcmp(num_room, "62.alg")) + refresca_62(); +} + +void DrasculaEngine::actualiza_refresco_antes() { + if (!strcmp(num_room, "62.alg")) + refresca_62_antes(); + else if (!strcmp(num_room, "16.alg")) + pon_bj(); +} + +void DrasculaEngine::pon_hare() { + int pos_hare[6]; + int r; + + if (hare_se_mueve == 1 && paso_x == PASO_HARE_X) { + for (r = 0; r < paso_x; r++) { + if (sentido_hare == 0 && sitio_x - r == hare_x + ancho_hare / 2) { + hare_se_mueve = 0; + paso_x = PASO_HARE_X; + paso_y = PASO_HARE_Y; + } + if (sentido_hare == 1 && sitio_x + r == hare_x + ancho_hare / 2) { + hare_se_mueve = 0; + paso_x = PASO_HARE_X; + paso_y = PASO_HARE_Y; + hare_x = sitio_x - ancho_hare / 2; + hare_y = sitio_y - alto_hare; + } + } + } + if (hare_se_mueve == 1 && paso_y == PASO_HARE_Y) { + for (r = 0; r < paso_y; r++) { + if (sentido_hare == 2 && sitio_y - r == hare_y + alto_hare) { + hare_se_mueve = 0; + paso_x = PASO_HARE_X; + paso_y = PASO_HARE_Y; + } + if (sentido_hare == 3 && sitio_y + r == hare_y + alto_hare) { + hare_se_mueve = 0; + paso_x = PASO_HARE_X; + paso_y = PASO_HARE_Y; + } + } + } + + if (hare_se_ve == 0) + goto no_vuelco; + + if (hare_se_mueve == 0) { + pos_hare[0] = 0; + pos_hare[1] = DIF_MASK_HARE; + pos_hare[2] = hare_x; + pos_hare[3] = hare_y; + pos_hare[4] = ANCHO_PERSONAJE; + pos_hare[5] = ALTO_PERSONAJE; + + if (sentido_hare == 0) { + pos_hare[1] = 0; + reduce_hare_chico(pos_hare[0], pos_hare[1], + pos_hare[2], pos_hare[3], + pos_hare[4], pos_hare[5], + factor_red[hare_y + alto_hare], + dir_hare_dch, dir_zona_pantalla); + } else if (sentido_hare == 1) + reduce_hare_chico(pos_hare[0], pos_hare[1], + pos_hare[2], pos_hare[3], + pos_hare[4], pos_hare[5], + factor_red[hare_y + alto_hare], + dir_hare_dch, dir_zona_pantalla); + else if (sentido_hare == 2) + reduce_hare_chico( pos_hare[0], pos_hare[1], + pos_hare[2], pos_hare[3], + pos_hare[4], pos_hare[5], + factor_red[hare_y + alto_hare], + dir_hare_fondo, dir_zona_pantalla); + else + reduce_hare_chico( pos_hare[0], pos_hare[1], + pos_hare[2], pos_hare[3], + pos_hare[4], pos_hare[5], + factor_red[hare_y + alto_hare], + dir_hare_frente, dir_zona_pantalla); + } else if (hare_se_mueve == 1) { + pos_hare[0] = frame_x[num_frame]; + pos_hare[1] = frame_y + DIF_MASK_HARE; + pos_hare[2] = hare_x; + pos_hare[3] = hare_y; + pos_hare[4] = ANCHO_PERSONAJE; + pos_hare[5] = ALTO_PERSONAJE; + if (sentido_hare == 0) { + pos_hare[1] = 0; + reduce_hare_chico(pos_hare[0], pos_hare[1], + pos_hare[2], pos_hare[3], + pos_hare[4], pos_hare[5], + factor_red[hare_y + alto_hare], + dir_hare_dch, dir_zona_pantalla); + } else if (sentido_hare == 1) + reduce_hare_chico(pos_hare[0], pos_hare[1], + pos_hare[2], pos_hare[3], + pos_hare[4], pos_hare[5], + factor_red[hare_y + alto_hare], + dir_hare_dch, dir_zona_pantalla); + else if (sentido_hare == 2) + reduce_hare_chico(pos_hare[0], pos_hare[1], + pos_hare[2], pos_hare[3], + pos_hare[4], pos_hare[5], + factor_red[hare_y + alto_hare], + dir_hare_fondo, dir_zona_pantalla); + else + reduce_hare_chico(pos_hare[0], pos_hare[1], + pos_hare[2], pos_hare[3], + pos_hare[4], pos_hare[5], + factor_red[hare_y + alto_hare], + dir_hare_frente, dir_zona_pantalla); + +no_vuelco: + aumenta_num_frame(); + } +} + +void DrasculaEngine::menu_sin_volcar() { + int h, n, x; + char texto_icono[13]; + + x = sobre_que_objeto(); + strcpy(texto_icono, nombre_icono[x]); + + for (n = 1; n < 43; n++) { + h = objetos_que_tengo[n]; + + if (h != 0) + DIBUJA_FONDO(x_pol[n], y_pol[n], x_obj[n], y_obj[n], + ANCHOBJ, ALTOBJ, dir_hare_frente, dir_zona_pantalla); + + DIBUJA_BLOQUE(x1d_menu[h], y1d_menu[h], x_obj[n], y_obj[n], + ANCHOBJ, ALTOBJ, dir_hare_fondo, dir_zona_pantalla); + } + + if (x < 7) + print_abc(texto_icono,x_obj[x] - 2, y_obj[x] - 7); +} + +void DrasculaEngine::barra_menu() { + int n, sobre_verbo = 1; + + for (n = 0; n < 7; n++) { + if (x_raton > x_barra[n] && x_raton < x_barra[n + 1]) + sobre_verbo = 0; + DIBUJA_BLOQUE(ANCHOBJ * n, ALTOBJ * sobre_verbo, + x_barra[n], 2, ANCHOBJ, ALTOBJ, + dir_hare_fondo, dir_zona_pantalla); + sobre_verbo = 1; + } +} + +void DrasculaEngine::saca_objeto() { + int h = 0, n; + + refresca_pantalla(); + + for (n = 1; n < 43; n++){ + if (sobre_que_objeto() == n) { + h = objetos_que_tengo[n]; + objetos_que_tengo[n] = 0; + if (h != 0) + lleva_objeto = 1; + } + } + + espera_soltar(); + + if (lleva_objeto == 1) + elige_objeto(h); +} + +void DrasculaEngine::sal_de_la_habitacion(int l) { + char salgo[13]; + + if (num_obj[l] == 105 && flags[0] == 0) + hablar(TEXT442, "442.als"); + else { + puertas_cerradas(l); + + if (espuerta[l] != 0) { + lleva_al_hare(sitiobj_x[l], sitiobj_y[l]); + sentido_hare = sentidobj[l]; + refresca_pantalla(); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + hare_se_mueve = 0; + sentido_hare = sentido_alkeva[l]; + obj_saliendo = alapuertakeva[l]; + rompo = 1; + musica_antes = musica_room; + + if (num_obj[l] == 105) + animacion_2(); + borra_pantalla(); + strcpy(salgo, alapantallakeva[l]); + strcat(salgo, ".ald"); + hare_x = -1; + carga_escoba(salgo); + } + } +} + +void DrasculaEngine::coge_objeto() { + int h, n; + h = objeto_que_lleva; + comprueba_flags = 1; + + refresca_pantalla(); + menu_sin_volcar(); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + + if (objeto_que_lleva < 7) + goto usando_verbos; + + for (n = 1; n < 43; n++) { + if (sobre_que_objeto() == n && objetos_que_tengo[n] == 0) { + objetos_que_tengo[n] = h; + lleva_objeto = 0; + comprueba_flags = 0; + } + } + +usando_verbos: + + if (comprueba_flags == 1) { + comprueba_banderas_menu(); + } + espera_soltar(); + if (lleva_objeto == 0) + sin_verbo(); +} + +void DrasculaEngine::banderas(int fl) { + hare_se_mueve = 0; + refresca_pantalla(); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + + hay_respuesta = 1; + + if (menu_scr == 1) { + + if (objeto_que_lleva == MIRAR && fl == 28) + hablar(TEXT328, "328.als"); + } else { + if (objeto_que_lleva == MIRAR && fl == 50) + hablar(TEXT308, "308.als"); + else if (objeto_que_lleva == ABRIR && fl == 50) + hablar(TEXT310, "310.als" ); + else if (objeto_que_lleva == CERRAR && fl == 50) + hablar(TEXT311, "311.als" ); + else if (objeto_que_lleva == MOVER && fl == 50) + hablar(TEXT312, "312.als" ); + else if (objeto_que_lleva == COGER && fl == 50) + hablar(TEXT313, "313.als" ); + else if (objeto_que_lleva == HABLAR && fl == 50) + hablar(TEXT314,"314.als" ); + else if (!strcmp(num_room, "62.alg")) + pantalla_62(fl); + else if (!strcmp(num_room, "63.alg")) + pantalla_63(fl); + else + hay_respuesta = 0; + } + if (hay_respuesta == 0 && hay_nombre == 1) + pantalla_0(); + else if (hay_respuesta == 0 && menu_scr == 1) + pantalla_0(); +} + +void DrasculaEngine::cursor_mesa() { + int pos_cursor[8]; + + pos_cursor[0] = 225; + pos_cursor[1] = 56; + pos_cursor[2] = x_raton - 20; + pos_cursor[3] = y_raton - 12; + pos_cursor[4] = 40; + pos_cursor[5] = 25; + + DIBUJA_BLOQUE_CUT(pos_cursor, dir_mesa, dir_zona_pantalla); +} + +void DrasculaEngine::introduce_nombre() { + char key; + int v = 0, h = 0; + char select2[23]; + strcpy(select2, " "); + for (;;) { + buffer_teclado(); + select2[v] = '-'; + DIBUJA_FONDO(115, 14, 115, 14, 176, 9, dir_dibujo1, dir_zona_pantalla); + print_abc(select2, 117, 15); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + key = getscan(); + if (key != 0) { + if (key == 16) + select2[v] = 'q'; + else if (key == 17) + select2[v] = 'w'; + else if (key == 18) + select2[v] = 'e'; + else if (key == 19) + select2[v] = 'r'; + else if (key == 20) + select2[v] = 't'; + else if (key == 21) + select2[v] = 'y'; + else if (key == 22) + select2[v] = 'u'; + else if (key == 23) + select2[v] = 'i'; + else if (key == 24) + select2[v] = 'o'; + else if (key == 25) + select2[v] = 'p'; + else if (key == 30) + select2[v] = 'a'; + else if (key == 31) + select2[v] = 's'; + else if (key == 32) + select2[v] = 'd'; + else if (key == 33) + select2[v] = 'f'; + else if (key == 34) + select2[v] = 'g'; + else if (key == 35) + select2[v] = 'h'; + else if (key == 36) + select2[v] = 'j'; + else if (key == 37) + select2[v] = 'k'; + else if (key == 38) + select2[v] = 'l'; + else if (key == 39) + select2[v] = ''; + else if (key == 44) + select2[v] = 'z'; + else if (key == 45) + select2[v] = 'x'; + else if (key == 46) + select2[v] = 'c'; + else if (key == 47) + select2[v] = 'v'; + else if (key == 48) + select2[v] = 'b'; + else if (key == 49) + select2[v] = 'n'; + else if (key == 50) + select2[v] = 'm'; + else if (key == 2) + select2[v] = '1'; + else if (key == 3) + select2[v] = '2'; + else if (key == 4) + select2[v] = '3'; + else if (key == 5) + select2[v] = '4'; + else if (key == 6) + select2[v] = '5'; + else if (key == 7) + select2[v] = '6'; + else if (key == 8) + select2[v] = '7'; + else if (key == 9) + select2[v] = '8'; + else if (key == 10) + select2[v] = '9'; + else if (key == 11) + select2[v] = '0'; + else if (key == 57) + select2[v] = ''; + else if (key == ESC) + break; + else if (key == 0x1C) { + select2[v] = '\0'; + h = 1; + break; + } else if (key == 0x0E) + select2[v] = '\0'; + else + v--; + + if (key == 0x0E) + v--; + else + v++; + } + if (v == 22) + v = 21; + else if (v == -1) + v = 0; + } + if (h == 1) { + strcpy(select, select2); + hay_seleccion = 1; + } +} + +void DrasculaEngine::para_grabar(char nom_game[]) { + graba_partida(nom_game); + comienza_sound("99.als"); + fin_sound(); +} + +int DrasculaEngine::LookForFree() { + delay(10); + // TODO GAME_Poll(gamev, 10); + //return(!SDEV_ChannelFree(gamev->EffectDev, 0)); + return 1; +} + +void DrasculaEngine::OpenSSN(char *Name, int Pause) { + MiVideoSSN = (char *)malloc(64256); + GlobalSpeed = CLOCKS_PER_SEC / Pause; + FrameSSN = 0; + UsingMem = 0; + if (MiVideoSSN == NULL) + return; + Sesion = new Common::File; + Sesion->open(Name); + mSesion = TryInMem(Sesion); + LastFrame = clock(); +} + +int DrasculaEngine::PlayFrameSSN() { + int Exit = 0; + int Lengt; + char *BufferSSN; + + if (!UsingMem) + Sesion->read(&CHUNK, 1); + else { + memcpy(&CHUNK, mSesion, 1); + mSesion += 1; + } + switch (CHUNK) { + case SET_PALET: + if (!UsingMem) + Sesion->read(dacSSN, 768); + else { + memcpy(dacSSN, mSesion, 768); + mSesion += 768; + } + set_dacSSN(dacSSN); + break; + case EMPTY_FRAME: + WaitFrameSSN(); + break; + case INIT_FRAME: + if (!UsingMem) { + Sesion->read(&CMP, 1); + Sesion->read(&Lengt, 4); + } else { + memcpy(&CMP, mSesion, 1); + mSesion += 1; + memcpy(&Lengt, mSesion, 4); + mSesion += 4; + } + if (CMP == CMP_RLE) { + if (!UsingMem) { + BufferSSN = (char *)malloc(Lengt); + Sesion->read(BufferSSN, Lengt); + } else { + BufferSSN = (char *)malloc(Lengt); + memcpy(BufferSSN, mSesion, Lengt); + mSesion += Lengt; + } + Des_RLE(BufferSSN, MiVideoSSN); + free(BufferSSN); + if (FrameSSN) { + WaitFrameSSN(); + MixVideo(VGA, MiVideoSSN); + g_system->copyRectToScreen((const byte *)VGA, 320, 0, 0, 320, 200); + } else { + WaitFrameSSN(); + memcpy(VGA, MiVideoSSN, 64000); + g_system->copyRectToScreen((const byte *)VGA, 320, 0, 0, 320, 200); + } + FrameSSN++; + } else { + if (CMP == CMP_OFF) { + if (!UsingMem) { + BufferSSN = (char *)malloc(Lengt); + Sesion->read(BufferSSN, Lengt); + } else { + BufferSSN = (char *)malloc(Lengt); + memcpy(BufferSSN, mSesion, Lengt); + mSesion += Lengt; + } + Des_OFF(BufferSSN, MiVideoSSN, Lengt); + free(BufferSSN); + if (FrameSSN) { + WaitFrameSSN(); + MixVideo(VGA, MiVideoSSN); + g_system->copyRectToScreen((const byte *)VGA, 320, 0, 0, 320, 200); + } else { + WaitFrameSSN(); + memcpy(VGA, MiVideoSSN, 64000); + g_system->copyRectToScreen((const byte *)VGA, 320, 0, 0, 320, 200); + } + FrameSSN++; + } + } + break; + case END_ANIM: + Exit = 1; + break; + default: + Exit = 1; + break; + } + return (!Exit); +} + +void DrasculaEngine::EndSSN() { + free(MiVideoSSN); + if (UsingMem) + free(pointer); + else { + Sesion->close(); + delete Sesion; + } +} + +char *DrasculaEngine::TryInMem(Common::File *Sesion) { + int Lengt; + + Sesion->seek(0, SEEK_END); + Lengt = Sesion->pos(); + Sesion->seek(0, SEEK_SET); + pointer = (char *)malloc(Lengt); + if (pointer == NULL) + return NULL; + Sesion->read(pointer, Lengt); + UsingMem = 1; + Sesion->close(); + delete Sesion; + return pointer; +} + +void DrasculaEngine::set_dacSSN(char *dacSSN) { + int n = 0; +// TODO +/* + while (inp(0x3da)&8){}; + while ((inp(0x3da)&8)==0){}; + + outp(0x3c8,0); + do { + outp(0x3c9,dacSSN[n++]); + outp(0x3c9,dacSSN[n++]); + outp(0x3c9,dacSSN[n++]); + } while (n<768); +*/ +} + +void DrasculaEngine::Des_OFF(char *BufferOFF, char *MiVideoOFF, int Lenght) { + int x = 0, Reps; + int Offset; + + memset(MiVideoSSN, 0, 64000); + while (x < Lenght) { + Offset = BufferOFF[x] + BufferOFF[x + 1] * 256; + Reps = BufferOFF[x + 2]; + memcpy(MiVideoOFF + Offset, &BufferOFF[x + 3], Reps); + x += 3 + Reps; + } +} + +void DrasculaEngine::Des_RLE(char *BufferRLE, char *MiVideoRLE) { + unsigned int con, X = 0; + unsigned int fExit = 0; + char ch, rep; + while (!fExit) { + ch = *BufferRLE++; + rep = 1; + if ((ch & 192) == 192) { + rep = (ch & 63); + ch =* BufferRLE++; + } + for (con = 0; con < rep; con++) { + *MiVideoRLE++ = ch; + X++; + if (X > 64000) + fExit = 1; + } + } +} + +void DrasculaEngine::MixVideo(char *OldScreen,char *NewScreen) { + int x; + for (x = 0; x < 64000; x++) + OldScreen[x] ^= NewScreen[x]; +} + +void DrasculaEngine::WaitFrameSSN() { + while (clock() < LastFrame + GlobalSpeed) {}; + LastFrame = LastFrame + GlobalSpeed; +} + +int DrasculaEngine::chkkey() { + //TODO +/* + union REGS registros; + + registros.h.ah=0x06; + registros.h.dl=0xff; + intdos(®istros,®istros); + return(registros.h.al); +*/ + return 0; +} + +char *DrasculaEngine::carga_pcx(char *NamePcc) { + unsigned int con, X = 0; + unsigned int fExit = 0; + char ch, rep; + char *AuxPun; + + AuxPun = AuxBuffDes; + + while (!fExit) { + ch = *NamePcc++; + rep = 1; + if ((ch & 192) == 192) { + rep = (ch & 63); + ch = *NamePcc++; + } + for (con = 0; con< rep; con++) { + *AuxPun++ = ch; + X++; + if (X > 64000) + fExit = 1; + } + } + return AuxBuffDes; +} + +void DrasculaEngine::set_dac(char *dac) { + int n = 0; + /*retrazo(); + // TODO + outp(0x3c8,0); + do { + + outp(0x3c9,dac[n++]); + outp(0x3c9,dac[n++]); + outp(0x3c9,dac[n++]); + + } while (n<768); + */ +} + +void DrasculaEngine::WaitForNext(long TimeMed) { + TimeLast = clock(); + while (clock() < (TimeLast + TimeMed)) {} + TimeLast = clock(); +} + +float DrasculaEngine::vez() { +/* TODO + float trasvase; + union REGS in, out; + + in.h.ah=0; + int386(0x1A,&in,&out); + trasvase=((out.w.cx*65536)+out.w.dx)/0.182; + return(trasvase); +*/ + return 0; +} + +void DrasculaEngine::reduce_hare_chico(int x1,int y1, int x2,int y2, int ancho,int alto, int factor, char *dir_inicio, char *dir_fin) { + float suma_x, suma_y; + int n, m; + float pixel_x, pixel_y; + int pos_pixel[6]; + + nuevo_ancho = (ancho * factor) / 100; + nuevo_alto = (alto * factor) / 100; + + suma_x = ancho / nuevo_ancho; + suma_y = alto / nuevo_alto; + + pixel_x = x1; + pixel_y = y1; + + for (n = 0;n < nuevo_alto; n++){ + for (m = 0; m < nuevo_ancho; m++){ + pos_pixel[0] = pixel_x; + pos_pixel[1] = pixel_y; + pos_pixel[2] = x2 + m; + pos_pixel[3] = y2 + n; + pos_pixel[4] = 1; + pos_pixel[5] = 1; + + DIBUJA_BLOQUE_CUT(pos_pixel, dir_inicio, dir_fin); + + pixel_x = pixel_x + suma_x; + } + pixel_x = x1; + pixel_y = pixel_y + suma_y; + } +} + +char DrasculaEngine::codifica(char car) { + return ~car; +} + +void DrasculaEngine::cuadrante_1() { + float distancia_x, distancia_y; + + distancia_x = hare_x + ancho_hare / 2 - sitio_x; + distancia_y = (hare_y + alto_hare) - sitio_y; + + if (distancia_x < distancia_y) { + direccion_hare = 0; + sentido_hare = 2; + paso_x = distancia_x / (distancia_y / PASO_HARE_Y); + } else { + direccion_hare = 7; + sentido_hare = 0; + paso_y = distancia_y / (distancia_x / PASO_HARE_X); + } +} + +void DrasculaEngine::cuadrante_2() { + float distancia_x, distancia_y; + + distancia_x = abs(hare_x + ancho_hare / 2 - sitio_x); + distancia_y = (hare_y + alto_hare) - sitio_y; + + if (distancia_x < distancia_y) { + direccion_hare = 1; + sentido_hare = 2; + paso_x = distancia_x / (distancia_y / PASO_HARE_Y); + } else { + direccion_hare = 2; + sentido_hare = 1; + paso_y = distancia_y / (distancia_x / PASO_HARE_X); + } +} + +void DrasculaEngine::cuadrante_3() { + float distancia_x, distancia_y; + + distancia_x = hare_x + ancho_hare / 2 - sitio_x; + distancia_y = sitio_y - (hare_y + alto_hare); + + if (distancia_x < distancia_y) { + direccion_hare = 5; + sentido_hare = 3; + paso_x = distancia_x / (distancia_y / PASO_HARE_Y); + } else { + direccion_hare = 6; + sentido_hare = 0; + paso_y = distancia_y / (distancia_x / PASO_HARE_X); + } +} + +void DrasculaEngine::cuadrante_4() { + float distancia_x, distancia_y; + + distancia_x = abs(hare_x + ancho_hare / 2 - sitio_x); + distancia_y = sitio_y - (hare_y + alto_hare); + + if (distancia_x 101 && hare_x < 155) + DIBUJA_FONDO(31, 138, 178, 51, 18, 16, dir_dibujo3, dir_zona_pantalla); + + if (flags[11] == 0) + DIBUJA_FONDO(pianista_x[frame_piano], 157, 245, 130, 29, 42, + dir_dibujo3, dir_zona_pantalla); + else if (flags[5] == 0) + DIBUJA_FONDO(145, 139, 228, 112, 47, 60, dir_hare_dch, dir_zona_pantalla); + else + DIBUJA_FONDO(165, 140, 229, 117, 43, 59, dir_dibujo3, dir_zona_pantalla); + + if (flags[12] == 1) + DIBUJA_FONDO(borracho_x[frame_borracho], 82, 170, 50, 40, 53, + dir_dibujo3, dir_zona_pantalla); + + diferencia = vez() - conta_ciego_vez; + if (diferencia > 6) { + if (flags[12] == 1) { + frame_borracho++; + if (frame_borracho == 8) { + frame_borracho = 0; + flags[12] = 0; + } + } else if (((rand() % 95) == 15) && (flags[13] == 0)) + flags[12] = 1; + + frame_velas++; + if (frame_velas == 3) + frame_velas = 0; + frame_piano++; + if (frame_piano == 9) + frame_piano = 0; + parpadeo = rand() % 11; + conta_ciego_vez = vez(); + } +} + +void DrasculaEngine::graba_partida(char nom_game[]) { + FILE *scu; + int l; + + // TODO + if ((scu = fopen(nom_game, "w")) == NULL) { + error("no puedo abrir el archivo"); + } + fprintf(scu, "%d\n", num_ejec); + fprintf(scu, "%s\n", datos_actuales); + fprintf(scu, "%d\n", hare_x); + fprintf(scu, "%d\n", hare_y); + fprintf(scu, "%d\n", sentido_hare); + + for (l = 1; l < 43; l++) { + fprintf(scu,"%d\n", objetos_que_tengo[l]); + } + + for (l = 0; l < NUM_BANDERAS; l++) { + fprintf(scu, "%d\n", flags[l]); + } + + fprintf(scu, "%d\n", lleva_objeto); + fprintf(scu, "%d\n", objeto_que_lleva); + + fclose(scu); + canal_p(nom_game); +} + +void DrasculaEngine::aumenta_num_frame() { + diff_vez=vez()-conta_vez; + + if (diff_vez >= 5.7) { + conta_vez = vez(); + num_frame++; + if (num_frame == 6) + num_frame = 0; + + if (direccion_hare == 0){ + hare_x = hare_x - paso_x; + hare_y = hare_y - paso_y; + } else if (direccion_hare == 7) { + hare_x = hare_x - paso_x; + hare_y = hare_y - paso_y; + } else if (direccion_hare == 1) { + hare_x = hare_x + paso_x; + hare_y = hare_y - paso_y; + } else if (direccion_hare == 2) { + hare_x = hare_x + paso_x; + hare_y = hare_y - paso_y; + } else if (direccion_hare == 3) { + hare_x = hare_x + paso_x; + hare_y = hare_y + paso_y; + } else if (direccion_hare == 4) { + hare_x = hare_x + paso_x; + hare_y = hare_y + paso_y; + } else if (direccion_hare == 5) { + hare_x = hare_x - paso_x; + hare_y = hare_y + paso_y; + } else if (direccion_hare == 6) { + hare_x = hare_x - paso_x; + hare_y = hare_y + paso_y; + } + } + + diferencia_y = alto_hare - nuevo_alto; + diferencia_x = ancho_hare - nuevo_ancho; + hare_y = hare_y + diferencia_y; + hare_x = hare_x + diferencia_x; + alto_hare = nuevo_alto; + ancho_hare = nuevo_ancho; +} + +int DrasculaEngine::sobre_que_objeto() { + int n; + + for (n = 1; n < 43; n++) { + if (x_raton > x_obj[n] && y_raton > y_obj[n] + && x_raton < x_obj[n] + ANCHOBJ && y_raton < y_obj[n] + ALTOBJ) + break; + } + + return n; +} + +void DrasculaEngine::comprueba_banderas_menu() { + int h, n; + + for (n = 0; n < 43; n++){ + if (sobre_que_objeto() == n) { + h = objetos_que_tengo[n]; + if (h != 0) + banderas(h); + } + } +} + +void DrasculaEngine::pantalla_0() { + if (objeto_que_lleva == MIRAR) + hablar(TEXT54, "54.als"); + else if (objeto_que_lleva == MOVER) + hablar(TEXT19, "19.als" ); + else if (objeto_que_lleva == COGER) + hablar(TEXT11, "11.als" ); + else if (objeto_que_lleva == ABRIR) + hablar(TEXT9, "9.als" ); + else if (objeto_que_lleva == CERRAR) + hablar(TEXT9, "9.als" ); + else if (objeto_que_lleva == HABLAR) + hablar(TEXT16, "16.als" ); + else + hablar(TEXT11, "11.als"); +} + +void DrasculaEngine::pantalla_62(int fl) { + if (objeto_que_lleva == HABLAR && fl == 53) + conversa("op_13.cal"); + else if (objeto_que_lleva == HABLAR && fl == 52 && flags[0] == 0) + animacion_3(); + else if (objeto_que_lleva == HABLAR && fl == 52 && flags[0] == 1) + hablar(TEXT109, "109.als"); + else if (objeto_que_lleva == HABLAR && fl == 54) + animacion_4(); + else if (objeto_que_lleva == MIRAR && fl == 100) + hablar(TEXT168, "168.als"); + else if (objeto_que_lleva == HABLAR && fl == 100) + hablar(TEXT169, "169.als"); + else if (objeto_que_lleva == COGER && fl == 100) + hablar(TEXT170, "170.als"); + else if (objeto_que_lleva == MIRAR && fl == 101) + hablar(TEXT171, "171.als"); + else if (objeto_que_lleva == MIRAR && fl == 102) + hablar(TEXT167, "167.als"); + else if (objeto_que_lleva == MIRAR && fl == 103) + hablar(TEXT166, "166.als"); + else hay_respuesta = 0; +} + +void DrasculaEngine::pantalla_63(int fl) { + if (objeto_que_lleva == MIRAR && fl == 110) + hablar(TEXT172, "172.als"); + else if (objeto_que_lleva == MIRAR && fl == 109) + hablar(TEXT173, "173.als"); + else if (objeto_que_lleva == MOVER && fl == 109) + hablar(TEXT174, "174.als"); + else if (objeto_que_lleva == MIRAR && fl == 108) + hablar(TEXT334, "334.als"); + else if (objeto_que_lleva == HABLAR && fl == 108) + hablar(TEXT333, "333.als"); + else + hay_respuesta = 0; +} + +void DrasculaEngine::conversa(char nom_fich[]) { + int h; + int juego1 = 1, juego2 = 1, juego3 = 1, juego4 = 1; + char frase1[78]; + char frase2[78]; + char frase3[78]; + char frase4[78]; + char para_codificar[13]; + char suena1[13]; + char suena2[13]; + char suena3[13]; + char suena4[13]; + int longitud; + int respuesta1; + int respuesta2; + int respuesta3; + int usado1 = 0; + int usado2 = 0; + int usado3 = 0; + + rompo_y_salgo = 0; + + strcpy(para_codificar, nom_fich); + canal_p(para_codificar); + + // TODO + if ((ald = fopen(nom_fich, "rb")) == NULL) { + error("no puedo abrir el archivo"); + } + fscanf(ald, "%s", frase1); + fscanf(ald, "%s", frase2); + fscanf(ald, "%s", frase3); + fscanf(ald, "%s", frase4); + fscanf(ald, "%s", suena1); + fscanf(ald, "%s", suena2); + fscanf(ald, "%s", suena3); + fscanf(ald, "%s", suena4); + fscanf(ald, "%d", &respuesta1); + fscanf(ald, "%d", &respuesta2); + fscanf(ald, "%d", &respuesta3); + fclose(ald); + canal_p(para_codificar); + + longitud = strlen(frase1); + for (h = 0; h < longitud; h++) + if (frase1[h] == '') + frase1[h] = ' '; + + longitud = strlen(frase2); + for (h= 0; h < longitud; h++) + if (frase2[h] == '') + frase2[h] = ' '; + + longitud = strlen(frase3); + for (h = 0; h < longitud; h++) + if (frase3[h] == '') + frase3[h] = ' '; + + longitud = strlen(frase4); + for (h = 0; h < longitud; h++) + if (frase4[h] == '') + frase4[h] = ' '; + + lee_dibujos("car.alg"); + descomprime_dibujo(dir_hare_fondo,1); +/* TODO + ent.w.ax = 8; + ent.w.cx = 1; + ent.w.dx = 31; + int386(0x33, &ent, &sal); +*/ + color_abc(VERDE_CLARO); + +bucle_opc: + + refresca_pantalla(); + + if (music_status() == 0 && flags[11] == 0) + playmusic(musica_room); + + MirarRaton(); + + if ( y_raton > 0 && y_raton < 9) { + if (usado1 == 1 && color != BLANCO) + color_abc(BLANCO); + else if (usado1 == 0 && color != VERDE_CLARO) + color_abc(VERDE_CLARO); + } else if (y_raton > 8 && y_raton < 17){ + if (usado2==1 && color!=BLANCO) + color_abc(BLANCO); + else if (usado2 == 0 && color != VERDE_CLARO) + color_abc(VERDE_CLARO); + } else if (y_raton > 16 && y_raton < 25) { + if (usado3 == 1 && color != BLANCO) + color_abc(BLANCO); + else if (usado3 == 0 && color != VERDE_CLARO) + color_abc(VERDE_CLARO); + } else if (color != VERDE_CLARO) + color_abc(VERDE_CLARO); + + if (y_raton > 0 && y_raton < 9) + juego1 = 2; + else if (y_raton > 8 && y_raton < 17) + juego2 = 2; + else if (y_raton > 16 && y_raton < 25) + juego3 = 2; + else if (y_raton > 24 && y_raton < 33) + juego4 = 2; + + print_abc_opc(frase1, 1, 2, juego1); + print_abc_opc(frase2, 1, 10, juego2); + print_abc_opc(frase3, 1, 18, juego3); + print_abc_opc(frase4, 1, 26, juego4); + + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + + if ((boton_izq == 1) && (juego1 == 2)) { + usado1 = 1; + hablar(frase1, suena1); + responde(respuesta1); + } else if ((boton_izq == 1) && (juego2 == 2)) { + usado2 = 1; + hablar(frase2, suena2); + responde(respuesta2); + } else if ((boton_izq == 1) && (juego3 == 2)) { + usado3 = 1; + hablar(frase3, suena3); + responde(respuesta3); + } else if ((boton_izq == 1) && (juego4 == 2)) { + hablar(frase4, suena4); + rompo_y_salgo=1; + } + + if (boton_izq == 1) + color_abc(VERDE_CLARO); + + if (usado1 == 0) + juego1 = 1; + else + juego1 = 3; + if (usado2 == 0) + juego2 = 1; + else + juego2 = 3; + if (usado3 == 0) + juego3 = 1; + else + juego3 = 3; + + juego4 = 1; + + if (rompo_y_salgo == 0) + goto bucle_opc; + + lee_dibujos("99.alg"); + descomprime_dibujo(dir_hare_fondo, 1); + sin_verbo(); +} + +void DrasculaEngine::animacion_3() { + lee_dibujos("an11y13.alg"); + descomprime_dibujo(dir_hare_dch, 1); + + hablar(TEXT192, "192.als"); + habla_tabernero(TEXTT1, "t1.als"); + hablar(TEXT193, "193.als"); + habla_tabernero(TEXTT2, "t2.als"); + hablar(TEXT194, "194.als"); + habla_tabernero(TEXTT3, "t3.als"); + hablar(TEXT195, "195.als"); + habla_tabernero(TEXTT4, "t4.als"); + hablar(TEXT196, "196.als"); + habla_tabernero(TEXTT5, "t5.als"); + habla_tabernero(TEXTT6, "t6.als"); + hablar(TEXT197, "197.als"); + habla_tabernero(TEXTT7, "t7.als"); + hablar(TEXT198, "198.als"); + habla_tabernero(TEXTT8, "t8.als"); + hablar(TEXT199, "199.als"); + habla_tabernero(TEXTT9, "t9.als"); + hablar(TEXT200, "200.als"); + hablar(TEXT201, "201.als"); + hablar(TEXT202, "202.als"); + + flags[0] = 1; + + lee_dibujos("97.alg"); + descomprime_dibujo(dir_hare_dch, 1); +} + +void DrasculaEngine::animacion_4() { + lee_dibujos("an12.alg"); + descomprime_dibujo(dir_hare_dch, 1); + + hablar(TEXT205,"205.als"); + + actualiza_refresco_antes(); + + DIBUJA_FONDO(1, 139, 228, 112, 47, 60, dir_hare_dch, dir_zona_pantalla); + VUELCA_PANTALLA(228,112, 228,112, 47,60, dir_zona_pantalla); + + pausa(3); + + actualiza_refresco_antes(); + + DIBUJA_FONDO(49, 139, 228, 112, 47, 60, dir_hare_dch, dir_zona_pantalla); + pon_hare(); + + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + + pausa(3); + stopmusic(); + flags[11] = 1; + + habla_pianista(TEXTP1, "p1.als"); + hablar(TEXT206, "206.als"); + habla_pianista(TEXTP2, "p2.als"); + hablar(TEXT207, "207.als"); + habla_pianista(TEXTP3, "p3.als"); + hablar(TEXT208, "208.als"); + habla_pianista(TEXTP4, "p4.als"); + hablar(TEXT209, "209.als"); + + flags[11] = 0; + lee_dibujos("97.alg"); + descomprime_dibujo(dir_hare_dch, 1); +} + +void DrasculaEngine::print_abc_opc(char dicho[],int x_pantalla, int y_pantalla, int juego) { + int pos_texto[6]; + int i, y_de_signos, y_de_letra, x_de_letra = 0, h, longitud; + longitud = strlen(dicho); + + for (i = 0; dicho[i]; i++) + dicho[i] = toupper(dicho[i]); + + for (h = 0; h < longitud; h++) { + if (juego == 1) { + y_de_letra = Y_ABC_OPC_1; + y_de_signos=Y_SIGNOS_OPC_1; + } else if (juego == 3) { + y_de_letra = Y_ABC_OPC_3; + y_de_signos = Y_SIGNOS_OPC_3; + } else { + y_de_letra = Y_ABC_OPC_2; + y_de_signos = Y_SIGNOS_OPC_2; + } + + if (dicho[h] == 'A') + x_de_letra = X_A_OPC; + else if (dicho[h] == '') + x_de_letra = X_A_OPC; + else if (dicho[h] == '') + x_de_letra = X_A_OPC; + else if (dicho[h] == '') + x_de_letra = X_A_OPC; + else if (dicho[h] == 'B' + )x_de_letra = X_B_OPC; + else if (dicho[h] == 'C') + x_de_letra = X_C_OPC; + else if (dicho[h] == '') + x_de_letra = X_C_OPC; + else if (dicho[h] == '') + x_de_letra = X_C_OPC; + else if (dicho[h] == 'D') + x_de_letra = X_D_OPC; + else if (dicho[h] == 'E') + x_de_letra = X_E_OPC; + else if (dicho[h] == '') + x_de_letra = X_E_OPC; + else if (dicho[h] == '') + x_de_letra = X_E_OPC; + else if (dicho[h] == '') + x_de_letra = X_E_OPC; + else if (dicho[h] == 'F') + x_de_letra = X_F_OPC; + else if (dicho[h] == 'G') + x_de_letra = X_G_OPC; + else if (dicho[h] == 'H') + x_de_letra = X_H_OPC; + else if (dicho[h] == 'I') + x_de_letra = X_I_OPC; + else if (dicho[h] == '') + x_de_letra = X_I_OPC; + else if (dicho[h] == '') + x_de_letra = X_I_OPC; + else if (dicho[h] == '') + x_de_letra = X_I_OPC; + else if (dicho[h] == 'J') + x_de_letra = X_J_OPC; + else if (dicho[h] == 'K') + x_de_letra = X_K_OPC; + else if (dicho[h] == 'L') + x_de_letra = X_L_OPC; + else if (dicho[h] == 'M') + x_de_letra = X_M_OPC; + else if (dicho[h] == 'N') + x_de_letra = X_N_OPC; + else if (dicho[h] == '\'') + x_de_letra = X_GN_OPC; + else if (dicho[h] == 'O') + x_de_letra = X_O_OPC; + else if (dicho[h] == '') + x_de_letra = X_O_OPC; + else if (dicho[h] == '') + x_de_letra = X_O_OPC; + else if (dicho[h] == '') + x_de_letra = X_O_OPC; + else if (dicho[h] == 'P') + x_de_letra = X_P_OPC; + else if (dicho[h] == 'Q') + x_de_letra = X_Q_OPC; + else if (dicho[h] == 'R') + x_de_letra = X_R_OPC; + else if (dicho[h] == 'S') + x_de_letra = X_S_OPC; + else if (dicho[h] == 'T') + x_de_letra = X_T_OPC; + else if (dicho[h] == 'U') + x_de_letra = X_U_OPC; + else if (dicho[h] == '') + x_de_letra = X_U_OPC; + else if (dicho[h] == '') + x_de_letra = X_U_OPC; + else if (dicho[h] == '') + x_de_letra = X_U_OPC; + else if (dicho[h] == 'V') + x_de_letra = X_V_OPC; + else if (dicho[h] == 'W') + x_de_letra = X_W_OPC; + else if (dicho[h] == 'X') + x_de_letra = X_X_OPC; + else if (dicho[h] == 'Y') + x_de_letra = X_Y_OPC; + else if (dicho[h] == 'Z') + x_de_letra = X_Z_OPC; + else if (dicho[h] == ' ') + x_de_letra = ESPACIO_OPC; + else + y_de_letra = y_de_signos; + + if (dicho[h] == '.') + x_de_letra = X_PUNTO_OPC; + else if (dicho[h] == ',') + x_de_letra = X_COMA_OPC; + else if (dicho[h] == '-') + x_de_letra = X_GUION_OPC; + else if (dicho[h] == '?') + x_de_letra = X_CIERRA_INTERROGACION_OPC; + else if (dicho[h] == '') + x_de_letra = X_ABRE_INTERROGACION_OPC; + else if (dicho[h] == '"') + x_de_letra = X_COMILLAS_OPC; + else if (dicho[h] == '!') + x_de_letra = X_CIERRA_EXCLAMACION_OPC; + else if (dicho[h] == '') + x_de_letra = X_ABRE_EXCLAMACION_OPC; + else if (dicho[h] == ';') + x_de_letra = X_PUNTO_Y_COMA_OPC; + else if (dicho[h] == '>') + x_de_letra = X_MAYOR_QUE_OPC; + else if (dicho[h] == '<') + x_de_letra = X_MENOR_QUE_OPC; + else if (dicho[h] == '$') + x_de_letra = X_DOLAR_OPC; + else if (dicho[h] == '%') + x_de_letra = X_POR_CIENTO_OPC; + else if (dicho[h] == ':') + x_de_letra = X_DOS_PUNTOS_OPC; + else if (dicho[h] == '&') + x_de_letra = X_AND_OPC; + else if (dicho[h] == '/') + x_de_letra = X_BARRA_OPC; + else if (dicho[h] == '(') + x_de_letra = X_ABRE_PARENTESIS_OPC; + else if (dicho[h] == ')') + x_de_letra = X_CIERRA_PARENTESIS_OPC; + else if (dicho[h] == '*') + x_de_letra = X_ASTERISCO_OPC; + else if (dicho[h] == '+') + x_de_letra = X_MAS_OPC; + else if (dicho[h] == '1') + x_de_letra = X_N1_OPC; + else if (dicho[h] == '2') + x_de_letra = X_N2_OPC; + else if (dicho[h] == '3') + x_de_letra = X_N3_OPC; + else if (dicho[h] == '4') + x_de_letra = X_N4_OPC; + else if (dicho[h] == '5') + x_de_letra = X_N5_OPC; + else if (dicho[h] == '6') + x_de_letra = X_N6_OPC; + else if (dicho[h] == '7') + x_de_letra = X_N7_OPC; + else if (dicho[h] == '8') + x_de_letra = X_N8_OPC; + else if (dicho[h] == '9') + x_de_letra = X_N9_OPC; + else if (dicho[h] == '0') + x_de_letra = X_N0_OPC; + + pos_texto[0] = x_de_letra; + pos_texto[1] = y_de_letra; + pos_texto[2] = x_pantalla; + pos_texto[3] = y_pantalla; + pos_texto[4] = ANCHO_LETRAS_OPC; + pos_texto[5] = ALTO_LETRAS_OPC; + + DIBUJA_BLOQUE_CUT(pos_texto, dir_hare_fondo, dir_zona_pantalla); + + x_pantalla = x_pantalla + ANCHO_LETRAS_OPC; + } +} + +void DrasculaEngine::responde(int funcion) { + if (funcion == 10) + habla_borracho(TEXTB1, "B1.als"); + else if (funcion == 11) + habla_borracho(TEXTB2, "B2.als"); + else if (funcion == 12) + habla_borracho(TEXTB3, "B3.als"); +} + +void DrasculaEngine::habla_pianista(char dicho[], char filename[]) { + int tiempou; + long tiempol; + int x_habla[4] = { 97, 145, 193, 241}; + int cara; + int longitud; + longitud = strlen(dicho); + + tiempol = time(NULL); + tiempou = (unsigned int)tiempol / 2; + srand(tiempou); + + buffer_teclado(); + + color_abc(BLANCO); + + if (hay_sb == 1) { + // TODO + if ((sku = fopen(filename, "rb")) == NULL) { + error("no puedo abrir archivo de voz"); + } + ctvd_init(2); + ctvd_speaker(1); + ctvd_output(sku); + } + +bucless: + + cara = rand() % 4; + + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); + + actualiza_refresco_antes(); + + DIBUJA_FONDO(x_habla[cara], 139, 228, 112, 47, 60, + dir_hare_dch, dir_zona_pantalla); + pon_hare(); + actualiza_refresco(); + + if (con_voces == 0) + centra_texto(dicho, 221, 128); + + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + + pausa(3); + + key = getscan(); + if (key != 0) + ctvd_stop(); + buffer_teclado(); + if (hay_sb == 1) { + if (LookForFree() != 0) + goto bucless; + fclose(sku); + ctvd_terminate(); + } else { + longitud = longitud - 2; + if (longitud > 0) + goto bucless; + } + + refresca_pantalla(); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); +} + +void DrasculaEngine::habla_borracho(char dicho[], char filename[]) { + int tiempou; + long tiempol; + + int x_habla[8] = { 1, 21, 41, 61, 81, 101, 121, 141 }; + int cara; + int longitud; + longitud = strlen(dicho); + + tiempol = time(NULL); + tiempou = (unsigned int)tiempol / 2; + srand(tiempou); + + lee_dibujos("an11y13.alg"); + descomprime_dibujo(dir_hare_frente, 1); + + flags[13] = 1; + +bebiendo: + + if (flags[12] == 1) { + refresca_pantalla(); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + goto bebiendo; + } + + buffer_teclado(); + + color_abc(VERDE_OSCURO); + + if (hay_sb == 1) { + // TODO + if ((sku = fopen(filename, "rb")) == NULL) { + error("no puedo abrir archivo de voz\n"); + } + ctvd_init(2); + ctvd_speaker(1); + ctvd_output(sku); + } + +bucless: + + cara = rand() % 8; + + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); + + actualiza_refresco_antes(); + + DIBUJA_FONDO(x_habla[cara], 29, 177, 50, 19, 19, dir_hare_frente, dir_zona_pantalla); + pon_hare(); + actualiza_refresco(); + + if (con_voces == 0) + centra_texto(dicho, 181, 54); + + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + + pausa(3); + + key = getscan(); + if (key != 0) + ctvd_stop(); + buffer_teclado(); + if (hay_sb == 1) { + if (LookForFree() != 0) + goto bucless; + fclose(sku); + ctvd_terminate(); + } else { + longitud = longitud - 2; + if (longitud > 0) + goto bucless; + } + + refresca_pantalla(); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + + flags[13] = 0; + lee_dibujos("96.alg"); + descomprime_dibujo(dir_hare_frente, 1); + + if (music_status() == 0 && flags[11] == 0) + playmusic(musica_room); +} + +void DrasculaEngine::suma_objeto(int osj) { + int h, puesto = 0; + + for (h = 1; h < 43; h++) { + if (objetos_que_tengo[h] == osj) + puesto = 1; + } + + if (puesto == 0) { + for (h = 1; h < 43; h++) { + if (objetos_que_tengo[h] == 0) { + objetos_que_tengo[h]=osj; + puesto = 1; + break; + } + } + } +} + +void DrasculaEngine::fin_sound_corte() { + if (hay_sb == 1) { + ctvd_stop(); + fclose(sku); + ctvd_terminate(); + } +} + +void DrasculaEngine::MusicFadeout() { + //TODO +} + +void DrasculaEngine::ctvd_end() { + //TODO +} + +void DrasculaEngine::ctvd_stop() { + //TODO +} + +void DrasculaEngine::ctvd_terminate() { + //TODO +} + +void DrasculaEngine::ctvd_speaker(int flag) {} + +void DrasculaEngine::ctvd_output(FILE *file_handle) {} + +void DrasculaEngine::ctvd_init(int b) { + //TODO +} + + } // End of namespace Drascula diff --git a/engines/drascula/drascula.h b/engines/drascula/drascula.h index ff3e77c798..889fc3ffd0 100644 --- a/engines/drascula/drascula.h +++ b/engines/drascula/drascula.h @@ -44,6 +44,282 @@ enum DrasculaGameFeatures { struct DrasculaGameDescription; +#define NUM_SAVES 10 +#define NUM_BANDERAS 50 +#define ESC 0x01 +#define F1 0x3B +#define F2 0x3C +#define F3 0x3D +#define F4 0x3E +#define F5 0x3F +#define F6 0x40 +#define F8 0x42 +#define F9 0x43 +#define F10 0x44 +#define MIRAR 1 +#define COGER 2 +#define ABRIR 3 +#define CERRAR 4 +#define HABLAR 5 +#define MOVER 6 +#define INICISOUND 6 +#define FINALSOUND 8 +#define FINDRV 9 +#define DIF_MASK 55 +#define ANCHOBJ 40 +#define ALTOBJ 25 + +#define X_OBJ1 5 +#define Y_OBJ1 10 +#define X_OBJ2 50 +#define Y_OBJ2 10 +#define X_OBJ3 95 +#define Y_OBJ3 10 +#define X_OBJ4 140 +#define Y_OBJ4 10 +#define X_OBJ5 185 +#define Y_OBJ5 10 +#define X_OBJ6 230 +#define Y_OBJ6 10 +#define X_OBJ7 275 +#define Y_OBJ7 10 +#define X_OBJ8 5 +#define Y_OBJ8 40 +#define X_OBJ9 50 +#define Y_OBJ9 40 +#define X_OBJ10 95 +#define Y_OBJ10 40 +#define X_OBJ11 140 +#define Y_OBJ11 40 +#define X_OBJ12 185 +#define Y_OBJ12 40 +#define X_OBJ13 230 +#define Y_OBJ13 40 +#define X_OBJ14 275 +#define Y_OBJ14 40 +#define X_OBJ15 5 +#define Y_OBJ15 70 +#define X_OBJ16 50 +#define Y_OBJ16 70 +#define X_OBJ17 95 +#define Y_OBJ17 70 +#define X_OBJ18 140 +#define Y_OBJ18 70 +#define X_OBJ19 185 +#define Y_OBJ19 70 +#define X_OBJ20 230 +#define Y_OBJ20 70 +#define X_OBJ21 275 +#define Y_OBJ21 70 +#define X_OBJ22 5 +#define Y_OBJ22 100 +#define X_OBJ23 50 +#define Y_OBJ23 100 +#define X_OBJ24 95 +#define Y_OBJ24 100 +#define X_OBJ25 140 +#define Y_OBJ25 100 +#define X_OBJ26 185 +#define Y_OBJ26 100 +#define X_OBJ27 230 +#define Y_OBJ27 100 +#define X_OBJ28 275 +#define Y_OBJ28 100 +#define X_OBJ29 5 +#define Y_OBJ29 130 +#define X_OBJ30 50 +#define Y_OBJ30 130 +#define X_OBJ31 95 +#define Y_OBJ31 130 +#define X_OBJ32 140 +#define Y_OBJ32 130 +#define X_OBJ33 185 +#define Y_OBJ33 130 +#define X_OBJ34 230 +#define Y_OBJ34 130 +#define X_OBJ35 275 +#define Y_OBJ35 130 +#define X_OBJ36 5 +#define Y_OBJ36 160 +#define X_OBJ37 50 +#define Y_OBJ37 160 +#define X_OBJ38 95 +#define Y_OBJ38 160 +#define X_OBJ39 140 +#define Y_OBJ39 160 +#define X_OBJ40 185 +#define Y_OBJ40 160 +#define X_OBJ41 230 +#define Y_OBJ41 160 +#define X_OBJ42 275 +#define Y_OBJ42 160 +#define X_OBJ43 275 +#define Y_OBJ43 160 + +#define DIF_MASK_HARE 72 +#define DIF_MASK_ABC 22 +#define ANCHO_LETRAS 8 +#define ALTO_LETRAS 6 + +#define Y_ABC 158 +#define Y_SIGNOS 169 +#define Y_ACENTOS 180 + +#define X_A 6 +#define X_B 15 +#define X_C 24 +#define X_D 33 +#define X_E 42 +#define X_F 51 +#define X_G 60 +#define X_H 69 +#define X_I 78 +#define X_J 87 +#define X_K 96 +#define X_L 105 +#define X_M 114 +#define X_N 123 +#define X_GN 132 +#define X_O 141 +#define X_P 150 +#define X_Q 159 +#define X_R 168 +#define X_S 177 +#define X_T 186 +#define X_U 195 +#define X_V 204 +#define X_W 213 +#define X_X 222 +#define X_Y 231 +#define X_Z 240 +#define X_PUNTO 6 +#define X_COMA 15 +#define X_GUION 24 +#define X_CIERRA_INTERROGACION 33 +#define X_ABRE_INTERROGACION 42 +#define X_COMILLAS 51 +#define X_CIERRA_EXCLAMACION 60 +#define X_ABRE_EXCLAMACION 69 +#define X_PUNTO_Y_COMA 78 +#define X_MAYOR_QUE 87 +#define X_MENOR_QUE 96 +#define X_DOLAR 105 +#define X_POR_CIENTO 114 +#define X_DOS_PUNTOS 123 +#define X_AND 132 +#define X_BARRA 141 +#define X_ABRE_PARENTESIS 150 +#define X_CIERRA_PARENTESIS 159 +#define X_ASTERISCO 168 +#define X_MAS 177 +#define X_N1 186 +#define X_N2 195 +#define X_N3 204 +#define X_N4 213 +#define X_N5 222 +#define X_N6 231 +#define X_N7 240 +#define X_N8 249 +#define X_N9 258 +#define X_N0 267 +#define ESPACIO 250 +#define ALTO_HABLA_HARE 25 +#define ANCHO_HABLA_HARE 23 +#define VON_BRAUN 1 +#define AZUL_OSCURO 2 +#define VERDE_CLARO 3 +#define VERDE_OSCURO 4 +#define AMARILLO 5 +#define NARANJA 6 +#define ROJO 7 +#define MARRON 8 +#define MORADO 9 +#define BLANCO 10 +#define ROSA 11 +#define PASO_HARE_X 8 +#define PASO_HARE_Y 3 +#define ALTO_PERSONAJE 70 +#define ANCHO_PERSONAJE 43 +#define PIES_HARE 12 + +#define ANCHO_LETRAS_OPC 6 +#define ALTO_LETRAS_OPC 5 +#define Y_ABC_OPC_1 6 +#define Y_SIGNOS_OPC_1 15 +#define Y_ABC_OPC_2 31 +#define Y_SIGNOS_OPC_2 40 +#define Y_ABC_OPC_3 56 +#define Y_SIGNOS_OPC_3 65 +#define X_A_OPC 10 +#define X_B_OPC 17 +#define X_C_OPC 24 +#define X_D_OPC 31 +#define X_E_OPC 38 +#define X_F_OPC 45 +#define X_G_OPC 52 +#define X_H_OPC 59 +#define X_I_OPC 66 +#define X_J_OPC 73 +#define X_K_OPC 80 +#define X_L_OPC 87 +#define X_M_OPC 94 +#define X_N_OPC 101 +#define X_GN_OPC 108 +#define X_O_OPC 115 +#define X_P_OPC 122 +#define X_Q_OPC 129 +#define X_R_OPC 136 +#define X_S_OPC 143 +#define X_T_OPC 150 +#define X_U_OPC 157 +#define X_V_OPC 164 +#define X_W_OPC 171 +#define X_X_OPC 178 +#define X_Y_OPC 185 +#define X_Z_OPC 192 +#define ESPACIO_OPC 199 +#define X_PUNTO_OPC 10 +#define X_COMA_OPC 17 +#define X_GUION_OPC 24 +#define X_CIERRA_INTERROGACION_OPC 31 +#define X_ABRE_INTERROGACION_OPC 38 +#define X_COMILLAS_OPC 45 +#define X_CIERRA_EXCLAMACION_OPC 52 +#define X_ABRE_EXCLAMACION_OPC 59 +#define X_PUNTO_Y_COMA_OPC 66 +#define X_MAYOR_QUE_OPC 73 +#define X_MENOR_QUE_OPC 80 +#define X_DOLAR_OPC 87 +#define X_POR_CIENTO_OPC 94 +#define X_DOS_PUNTOS_OPC 101 +#define X_AND_OPC 108 +#define X_BARRA_OPC 115 +#define X_ABRE_PARENTESIS_OPC 122 +#define X_CIERRA_PARENTESIS_OPC 129 +#define X_ASTERISCO_OPC 136 +#define X_MAS_OPC 143 +#define X_N1_OPC 150 +#define X_N2_OPC 157 +#define X_N3_OPC 164 +#define X_N4_OPC 171 +#define X_N5_OPC 178 +#define X_N6_OPC 185 +#define X_N7_OPC 192 +#define X_N8_OPC 199 +#define X_N9_OPC 206 +#define X_N0_OPC 213 +#define NO_PUERTA 99 + +#define INIT_FRAME 0 +#define CMP_RLE 1 +#define CMP_OFF 2 +#define END_ANIM 3 +#define SET_PALET 4 +#define MOUSE_KEY 5 +#define EMPTY_FRAME 6 + +#define COMPLETA 256 +#define MEDIA 128 class DrasculaEngine : public ::Engine { int _gameId; @@ -70,6 +346,277 @@ public: uint16 getVersion() const; Common::Platform getPlatform() const; + void asigna_memoria(); + void libera_memoria(); + void carga_info(); + void salir_al_dos(int r); + + void lee_dibujos(char *); + void descomprime_dibujo(char *dir_escritura, int plt); + + typedef unsigned char DacPalette256[256][4]; + + void asigna_rgb(unsigned char *dir_lectura, int plt); + void funde_rgb(int plt); + void paleta_hare(); + void ActualizaPaleta(); + void setvgapalette256(DacPalette256 *PalBuf); + void DIBUJA_FONDO(int xorg, int yorg, int xdes, int ydes, int Ancho, + int Alto, char *Origen, char *Destino); + void DIBUJA_BLOQUE(int xorg, int yorg, int xdes, int ydes, int Ancho, + int Alto, char *Origen, char *Destino); + void DIBUJA_BLOQUE_CUT(int *Array, char *Origen, char *Destino); + void VUELCA_PANTALLA(int xorg, int yorg, int xdes, int ydes, int Ancho, int Alto, char *Buffer); + + DacPalette256 palJuego; + DacPalette256 palHare; + DacPalette256 palHareClaro; + DacPalette256 palHareOscuro; + + char *VGA; + + char *dir_dibujo1; + char *dir_hare_fondo; + char *dir_dibujo3; + char *dir_dibujo2; + char *dir_mesa; + char *dir_hare_dch; + char *dir_zona_pantalla; + char *dir_hare_frente; + char *dir_texto; + char *dir_pendulo; + + char cPal[768]; + char *Buffer_pcx; + long LenFile; + FILE *handle_dibujos; + + FILE *ald, *sku; + + int hay_sb; + int nivel_osc, musica_antes, musica_room; + char num_room[20], pantalla_disco[13]; + char datos_actuales[13]; + int objs_room; + + char nombre_obj[20][13]; + char nombre_icono[7][13]; + + int num_obj[20], visible[20], espuerta[20]; + int sitiobj_x[20], sitiobj_y[20], sentidobj[20]; + int objetos_que_tengo[43]; + char alapantallakeva[20][13]; + int x_alakeva[20], y_alakeva[20], sentido_alkeva[20], alapuertakeva[20]; + int x1[20], y1[20], x2[20], y2[20]; + int lleva_objeto , objeto_que_lleva; + int con_voces; + int menu_bar, menu_scr, hay_nombre; + char texto_nombre[13]; + char key; + + int flags[NUM_BANDERAS]; + + int frame_y; + int hare_x, hare_y, hare_se_mueve, direccion_hare, sentido_hare, num_frame, hare_se_ve; + int sitio_x, sitio_y, comprueba_flags; + int rompo, rompo2; + int paso_x, paso_y; + int alto_hare, ancho_hare, alto_pies; + int alto_habla, ancho_habla; + int suelo_x1, suelo_y1, suelo_x2, suelo_y2; + int cerca, lejos; + int sentido_final, anda_a_objeto; + int obj_saliendo; + float diff_vez, conta_vez; + int hay_respuesta; + int conta_ciego_vez; + int cambio_de_color; + int rompo_y_salgo; + int vb_x, sentido_vb, vb_se_mueve, frame_vb; + float nuevo_alto, nuevo_ancho; + int diferencia_x, diferencia_y; + int factor_red[201]; + int frame_piano; + int frame_borracho; + int frame_velas; + int color_solo; + int parpadeo; + int x_igor, y_igor, sentido_igor; + int x_dr, y_dr, sentido_dr; + int x_bj, y_bj, sentido_bj; + int cont_sv; + int term_int; + int num_ejec; + int cual_ejec, hay_que_load; + char nom_partida[13]; + int color; + int corta_musica; + char select[23]; + int hay_seleccion; + + + // TODO below + int x_raton; + int y_raton; + int y_raton_ant; + int boton_izq; + int boton_dch; + + + + void escoba(); + void Negro(); + void agarra_objeto(int); + void buffer_teclado() { } + void animacion_1(); + void animacion_2(); + void sin_verbo(); + void para_cargar(char[]); + void carga_escoba(char[]); + void borra_pantalla(); + void lleva_al_hare(int, int); + void mueve_cursor(); + void comprueba_objetos(); + void espera_soltar(); + void MirarRaton(); + void elige_en_barra(); + void comprueba1(); + void comprueba2(); + char getscan(); + void elige_verbo(int); + void mesa(); + void saves(); + void print_abc(char[], int, int); + void delay(int ms); + void confirma_go(); + void confirma_salir(); + void salva_pantallas(); + void elige_objeto(int objeto); + void suma_objeto(int); + int resta_objeto(int osj); + void fliplay(char filefli[], int vel); + void FundeDelNegro(int VelocidadDeFundido); + char LimitaVGA(char valor); + void color_abc(int cl); + void centra_texto(char[],int,int); + void comienza_sound(char[]); + void anima(char animacion[], int FPS); + void fin_sound_corte(); + void FundeAlNegro(int VelocidadDeFundido); + void pausa(int); + void habla_dr_grande(char dicho[], char filename[]); + void pon_igor(); + void pon_bj(); + void pon_dr(); + void habla_igor_dch(char dicho[], char filename[]); + void habla_dr_dch(char dicho[], char filename[]); + void habla_dr_izq(char dicho[], char filename[]); + void habla_solo(char[], char[]); + void habla_igor_frente(char[], char[]); + void habla_tabernero(char dicho[], char filename[]); + void hipo(int); + void fin_sound(); + void habla_bj(char[], char[]); + void hablar(char[], char[]); + void playmusic(int p); + void stopmusic(); + int music_status(); + void refresca_pantalla(); + void carga_partida(char[]); + void canal_p(char[]); + void puertas_cerradas(int); + void animafin_sound_corte(); + void color_hare(); + void funde_hare(int oscuridad); + void paleta_hare_claro(); + void paleta_hare_oscuro(); + void hare_claro(); + void actualiza_datos() {} + void empieza_andar(); + void actualiza_refresco(); + void actualiza_refresco_antes(); + void pon_hare(); + void menu_sin_volcar(); + void barra_menu(); + void saca_objeto(); + void sal_de_la_habitacion(int); + void coge_objeto(); + void banderas(int); + void cursor_mesa(); + void introduce_nombre(); + void para_grabar(char[]); + int LookForFree(); + void OpenSSN(char *Name,int Pause); + void WaitFrameSSN(); + void MixVideo(char *OldScreen,char *NewScreen); + void Des_RLE(char *BufferRLE, char *MiVideoRLE); + void Des_OFF(char *BufferOFF, char *MiVideoOFF, int Lenght); + void set_dacSSN(char *dacSSN); + char *TryInMem(Common::File *Sesion); + void EndSSN(); + int PlayFrameSSN(); + int chkkey(); + + char *AuxBuffOrg; + char *AuxBuffLast; + char *AuxBuffDes; + //TODO duplicate char cPal[768]; + int Leng; + + char *pointer; + int UsingMem; + Common::File *Sesion; + char CHUNK; + char CMP, dacSSN[768]; + char *MiVideoSSN; + char *mSesion; + int FrameSSN; + int GlobalSpeed; + int LastFrame; + + + long TimeLast; + long TimeMed; + + char *carga_pcx(char *NamePcc); + void set_dac(char *dac); + void WaitForNext(long TimeMed); + float vez(); + void reduce_hare_chico(int,int, int,int, int,int, int, char *,char *); + char codifica(char); + void cuadrante_1(); + void cuadrante_2(); + void cuadrante_3(); + void cuadrante_4(); + void refresca_62(); + void refresca_62_antes(); + void refresca_63(); + void graba_partida(char[]); + void aumenta_num_frame(); + int sobre_que_objeto(); + void comprueba_banderas_menu(); + void pantalla_0(); + void pantalla_62(int); + void pantalla_63(int); + void conversa(char []); + void animacion_3(); + void animacion_4(); + void print_abc_opc(char[], int, int, int); + void responde(int); + void habla_borracho(char dicho[], char filename[]); + void habla_pianista(char dicho[], char filename[]); + + void MusicFadeout(); + void ctvd_end(); + void ctvd_stop(); + void ctvd_terminate(); + void ctvd_speaker(int flag); + void ctvd_output(FILE *file_handle); + void ctvd_init(int b); + + + + private: public: diff --git a/engines/drascula/texts.h b/engines/drascula/texts.h new file mode 100644 index 0000000000..20536c6573 --- /dev/null +++ b/engines/drascula/texts.h @@ -0,0 +1,753 @@ +#define TEXT1 "Its the second biggest door I've seen in my life." +#define TEXT2 "Not really." +#define TEXT3 "The church is all boarded up, it must have been abandoned several years ago." +#define TEXT4 "I haven't opened it." +#define TEXT5 "What should I do, should I pull it off?" +#define TEXT6 "Hi there door, I'm going to make you a door-frame." +#define TEXT7 "It's too much for me." +#define TEXT8 "There's a window stopping the game from working properly." +#define TEXT9 "I can't." +#define TEXT10 "Yes, that's done." +#define TEXT11 "Why?" +#define TEXT12 "Hi window, are you doing anything tonight?" +#define TEXT13 "Not without permission from the Town Hall." +#define TEXT14 "If only this window wasn't boarded up..." +#define TEXT15 "Yoo-Hoo window!" +#define TEXT16 "Hi there." +#define TEXT17 "Like Microchof's." +#define TEXT18 "I can't reach." +#define TEXT19 "It's alright where it is." +#define TEXT21 "Its a coffin in the shape of a cross." +#define TEXT22 "No thanks." +#define TEXT23 "Hi dead man. No, don't get up for my sake." +#define TEXT24 "Yes, just like in poltergeist" +#define TEXT27 "I'll be back in fifteen minutes" +#define TEXT28 "Forbidden to put up posters." +#define TEXT29 "It's uncle Evaristo's tomb." +#define TEXT30 "Its locked." +#define TEXT31 "I've got one." +#define TEXT32 "Yoo Hoo, uncle Everisto!" +#define TEXT33 "There's no reply." +#define TEXT34 "It's not well parked." +#define TEXT35 "It's a door." +#define TEXT36 "A drawer in the table." +#define TEXT37 "A suspicious wardrobe." +#define TEXT38 "Hi wardrobe, how are you?" +#define TEXT41 "It's an ancient candelabrum." +#define TEXT42 "It must have been here ever since Yule Brinner had hair on his head." +#define TEXT43 "No, its a relic." +#define TEXT44 "Its a nice altarpiece." +#define TEXT46 "ha, ha, ha." +#define TEXT48 "No." +#define TEXT50 "Ha, He, Hi, Ho, Hu, great!" +#define TEXT54 "I can't see anything in particular." +#define TEXT55 "It's Fernn, the plant." +#define TEXT56 "It's one of the fences spikes" +#define TEXT57 "Hey! There's a packet of matches under here." +#define TEXT58 "Look! a packet of Kleenex, and one's still unused." +#define TEXT59 "There isn't anything else in the bucket." +#define TEXT60 "It's a blind man who can't see." +#define TEXT65 "That's a great deal of money." +#define TEXTD56 "Hi blind man. How it's going?" +#define TEXTD57 "How do you know I'm a foreigner?" +#define TEXTD58 "You look blind. You're wearing dark glasses like Stevie Wonder." +#define TEXTD59 "Look, I'm sorry, I didn't know you could see." +#define TEXTD60 "But haven't you just told me you weren't blind." +#define TEXTD61 "But if you can't see." +#define TEXTD62 "Ooookay. Sorry. In that case, Hi there sightless person." +#define TEXTD63 "I'm John Hacker. You must be one of those characters who will help me out in exchange for an object. Aren't you? Eh? Aren't you?" +#define TEXTD64 "Uuuum, excuse me for asking blin... Sightless person! But what sort of job is that, to give sickles in exchange for money while you play the accordion?" +#define TEXTD65 "Ah yes, I suppose that's true. Goodbye sightless person ...blind man (under his breath)." +#define TEXTD66 "Here is the large amount of money you asked me for." +#define TEXTD67 "You better have had." +#define TEXTD68 "Hi there foreigner." +#define TEXTD69 "And how do you know I'm blind?" +#define TEXTD70 "And I'm not kidding you but your's are like Woody Allen's." +#define TEXTD71 "No, I can't see." +#define TEXTD72 "And I'm not." +#define TEXTD73 "Oh of course. Just cos I can't see, you accuse me of being blind." +#define TEXTD74 "Hi there foreigner! What are you doing in Transylvania?" +#define TEXTD75 "That's right, foreigner. In exchange for a large sum of money I'll give you a sickle for when you might need it." +#define TEXTD76 " !!!!!!!!!!!!!!!!!!!!!!!!" +#define TEXTD77 "Because you told me before, didn't you?" +#define TEXTD78 "Thanks foreigner. Here's the sickle in exchange. You'll find it really useful later on, honestly." +#define TEXT100 "THERE IS NOTHING SPECIAL ABOUT IT" +#define TEXT101 "IT'S NOT UNUSUAL" +#define TEXT102 "HEY, WHAT'S UP MAN?" +#define TEXT103 "HI" +#define TEXT104 "NOTHING NEW?" +#define TEXT105 "HOW IS THE FAMILY?" +#define TEXT106 "THAT IS JUST LIKE YOU!" +#define TEXT107 "BUT HOW DO I GET THAT?" +#define TEXT108 "MY RELIGION DOES NOT ALLOW ME" +#define TEXT109 "IT'D BE BETTER NOT" +#define TEXT110 "YEAH, SURE MAN!" +#define TEXT111 "NO WAY" +#define TEXT112 "IMPOSSIBLE " +#define TEXT113 "THIS WILL NOT OPEN " +#define TEXT114 "I CAN'T DO IT BY MYSELF" +#define TEXT115 "I COULD DO IT IF I WANTED TO, BUT I JUST FEEL A LITTLE LAZY " +#define TEXT116 "I DO NOT SEE THE REASON " +#define TEXT117 "IT'S A QUITE NICE BRAIN " +#define TEXT118 "AND SO BRAIN, WHAT ARE YOU UP TONIGHT? " +#define TEXT119 "NO, IT MUST BE KEPT SOMEWHERE AWAY FROM THE MUTANT ACTION OF THE ATMOSPHERE" +#define TEXT120 "HE IS VERY STIFF, JUST LIKE MY BOSS " +#define TEXT121 "A VERY SHARP STICK" +#define TEXT122 "YOU FAITHFUL SHARP-PAINTED STICK, NOBLE TRANSILVAAANIAN OAK TREE" +#define TEXT123 "DAMN, I HAVE TO CUT MY NAILS! " +#define TEXT124 "B.J. IS IN THERE... SHE IS A REALLY HOT CHICK! " +#define TEXT125 "IT IS FIRMLY LOCKED " +#define TEXT126 "\"SAVE AWAY LOCKS LTD.\"" +#define TEXT127 "IT IS THE TYPICAL SKELETON YOU FIND IN THE DUNGEONS OF ALL THE GAMES" +#define TEXT128 "IT IS COMMONLY USED TO COMMUNICATE ELECTRICITY TO THE MACHINES CONNECTED TO IT " +#define TEXT129 "IT IS ABSOLUTELY HAND MADE BECAUSE THE JAPANESE MAKE THEM POCKET SIZE " +#define TEXT130 "I HAVE ONLY SEEN IN MY LIFE ANOTHER THING AS UGLY AS THIS ONE " +#define TEXT131 "FORGET IT. I AM NOT GOING TO TELL HIM ANYTHING IN CASE HE GETS MAD " +#define TEXT132 "IT SEEMS QUITE RATIONAL " +#define TEXT133 "IT IS A PICTURE OF PLATO WRITING HIS LOST DIALOGUE " +#define TEXT134 "I AM NOT ONE OF THOSE WHO TALKS TO POSTERS " +#define TEXT135 "THAT'S A VERY CUTE DESK " +#define TEXT136 "IT IS A VAMPIRES HUNTER'S DIPLOMA OFFICIALLY APPROVED BY OXFORD UNIVERSITY " +#define TEXT137 "IT'S A DARK NIGHT WITH FULL MOON " +#define TEXT138 "IT SEEMS LIKE THESE SCREWS ARE NOT MUCH TWISTED " +#define TEXT139 "DON'T LOOK NOW, BUT I THINK THAT A HIDDEN CAMERA IS FOCUSING ON ME " +#define TEXT140 "THAT'S A VERY MODERN STICK DETECTOR " +#define TEXT141 "NO. THE LABORATORY IS ON THE SECOND FLOOR " +#define TEXT142 "A NICE BEDSIDE TABLE " +#define TEXT143 "IT'S A LOT OF MONEY THAT CAN'T BE MISSING IN ANY VALUABLE ADVENTURE " +#define TEXT144 "IF I WERE A RICH MAN, DUBIDUBIDUBIDUBIDUBIDUBIDUBIDU " +#define TEXT145 "THOSE ARE STRANGE LEAVES. THEY MUST HAVE BROUGHT THEM FROM SOUTH AMERICA OR AROUND THERE " +#define TEXT146 "I DON'T THINK THEY WOULD ANSWER ME " +#define TEXT147 "THAT'S A BEAUTIFUL WOODEN CRUCIFIX. THE ICON DOESN'T REALLY GET ALL THE BEAUTY WITHIN IT" +#define TEXT148 "I ONLY PRAY BEFORE I GO TO BED " +#define TEXT149 "HEY, THIS PIKE SEEMS A LITTLE BIT LOOSE! " +#define TEXT150 "I HOPE YOU WON'T COMPLAIN ABOUT GETTING NO CLUES FROM ME " +#define TEXT151 "IT'S A QUITE CONVENTIONAL PIKE " +#define TEXT152 "THEY ARE CUTE, THOUGH THEY ARE COVERED WITH A LITTLE BIT OF SHIT " +#define TEXT153 "NO, THEY WON'T HEAR ME. HA,HA,HA THIS IS GREAT! " +#define TEXT154 "\"SLEEPING BEAUTY\" FROM CHAIKOSKY, OR CHOIFRUSKY, OR WHATEVER IT IS" +#define TEXT155 "VERY TEMPTING " +#define TEXT156 "NO, I'M NOT ONE OF THOSE WHO PUT USED BUBBLE GUMS IN THEIR MOUTH " +#define TEXT157 "THAT'S A VERY NICE SICKLE. I WONDER WHERE THE HAMMER MAY BE " +#define TEXT158 "TOBACCO MANUFACTURERS WARN ABOUT HEALTH BEING SERIOUSLY DAMAGED BY SANITARY AUTHORITIES" +#define TEXT159 "AN ABSOLUTELY NORMAL CANDLE, INCLUDING WAX AND EVERYTHING " +#define TEXT160 "THESE TWO SHINY COINS DO REALLY GLITTER! " +#define TEXT161 "THIS SHINY COIN DOES REALLY GLITTER! " +#define TEXT162 "WITH THIS I WILL BE IMMUNE AGAINST VAMPIRE'S BITES" +#define TEXT163 "NO, IT'S IS NOT THE RIGHT MOMENT YET " +#define TEXT164 "THERE IS A ONE THOUSAND BILL AND A COUPLE COINS " +#define TEXT165 "IT SAYS \"PLEASE, DO NOT THROW FOOD TO THE PIANIST\"" +#define TEXT166 "OMELET, 200. FRIED FISH, 150, MAYONNAISE POTATOES, 225" +#define TEXT167 "BEST BURGERS ON THIS SIDE OF THE DANUBE, ONLY FOR 325!" +#define TEXT168 "THAT'S A NICE SKULL WITH A VERY PENETRATING LOOK, HA, HA, HA, HA, THAT WAS GOOD!" +#define TEXT169 "HI SKULL, YOU REMIND ME OF UNCLE HAMLET " +#define TEXT170 "I HAVE THE HABIT OF NOT TOUCHING THINGS THAT HAVE BEEN ALIVE " +#define TEXT171 "IT'S A BIN " +#define TEXT172 "IT'S A BET FOR TONIGHT'S GAME " +#define TEXT173 "I WONDER WHAT THERE IS BEHIND THAT " +#define TEXT174 "HEY, THAT CURTAIN IS NOT MOVING!" +#define TEXT175 "MAN, THIS CASTLE IS REALLY GLOOMY " +#define TEXT176 "I CAN'T, HE IS TOO FAR AWAY TO HEAR ME " +#define TEXT177 "IT'S THE TYPICAL TRANSILVANIAN FOREST, WITH TREES " +#define TEXT178 "MAN YOU REALLY SAY STUPID THINGS, AND THIS IS TOO DARK! " +#define TEXT179 "GARCIA, CANDY STORE. SWEETS AND BUBBLE GUM" +#define TEXT180 "A VERY NICE DOOR " +#define TEXT181 "IT'S CLOSED " +#define TEXT182 "A COMPLETELY LOCKED BARREL " +#define TEXT184 "AREN'T THESE BUGS REALLY CUTE? " +#define TEXT185 "BSSST, PUSSYCAT... LITTLE CAT" +#define TEXT186 "THERE IS NO ANSWER " +#define TEXT187 "THE MOON IS A SATELLITE THAT TURNS AROUND THE EARTH WITH A REVOLUTION PERIOD OF 28 DAYS" +#define TEXT188 "HI, LOONY MOON " +#define TEXT189 "IT'S TOTALLY BLOCKED UP WITH PLANKS" +#define TEXT190 "IT'S IMPOSSIBLE. NOT EVEN THAT TOUGH GUY FROM TV COULD OPEN THIS " +#define TEXT191 "HEY! THE SHADOW OF THAT CYPRESS LOOKS PROLONGED TO ME! " +#define TEXT192 "YOU, BARTENDER...!! " +#define TEXT193 "I WOULD LIKE TO HAVE A ROOM PLEASE " +#define TEXT194 "DO YOU KNOW WHERE I CAN FIND THE SO CALLED DRASCULA? " +#define TEXT195 "YES, SO WHAT? " +#define TEXT196 "SO? " +#define TEXT197 "IS...THAT RIGHT? " +#define TEXT198 "GOOD QUESTION. NOW, LET ME TELL YOU MY STORY. LOOK... " +#define TEXT199 "IT'S JUST FIVE MINUTES " +#define TEXT200 "I'M JOHN HACKER AND I REPRESENT A BRITISH PROPERTY COMPANY " +#define TEXT201 "AS FAR AS I KNOW, COUNT DRASCULA WANTS TO BUY SOME PIECES OF LAND IN GIBRALTAR AND MY COMPANY SENT ME HERE TO NEGOTIATE THE SELLING " +#define TEXT202 "I THINK I'M GOING BACK TO MY MUM'S TOMORROW FIRST THING IN THE MORNING " +#define TEXT203 "BEAUTIFUL NIGHT, HUH? " +#define TEXT204 "NO, NOTHING " +#define TEXT205 "YOU...PIANIST...!!!! " +#define TEXT206 "BEAUTIFUL NIGHT " +#define TEXT207 "AND IT'S NOT EVEN COLD OR ANYTHING " +#define TEXT208 "ALL RIGHT, I'LL JUST LET YOU GO ON PLAYING " +#define TEXT209 "WELL THEN " +#define TEXT210 "HI BOSS, HOW ARE YOU? " +#define TEXT211 "AND HOW IS THE FAMILY? " +#define TEXT212 "THIS IS QUITE GROOVY, HUH? " +#define TEXT213 "I'D BETTER NOT SAY ANYTHING " +#define TEXT214 "THERE IS NO PLACE LIKE HOME. THERE IS NO...WHAT?, BUT YOU ARE NOT AUNT EMMA. AS A MATTER OF FACT, I DON'T HAVE ANY AUNT EMMA! " +#define TEXT215 "YES, SO DOES MINE. YOU CAN CALL ME ANYTHING YOU WANT, BUT IF YOU CALL ME JHONNY, I'LL COME TO YOU LIKE A DOG " +#define TEXT216 "AREN'T I JUST A FUNNY GUY, HUH?. BY THE WAY, WHERE AM I? " +#define TEXT217 "YES " +#define TEXT218 "SHOOT...! " +#define TEXT219 "OH, SURE...OF COURSE! " +#define TEXT220 "WELL, THANKS VERY MUCH FOR YOUR HELP. I WON'T BOTHER YOU ANYMORE IF YOU PLEASE TELL ME WHERE THE DOOR IS... " +#define TEXT221 "IT'S BECAUSE THE KNOCK MUST HAVE AFFECTED MY BRAIN...I CAN'T SEE A THING... " +#define TEXT222 "WELL...THAT DOESN'T MATTER. I ALWAYS CARRY AN SPARE ONE. " +#define TEXT223 "WOW, WHAT A HOT CHICK!! I DIDN'T NOTICE!, BUT OF COURSE, I WASN'T WEARING MY GLASSES " +#define TEXT224 "HEY... " +#define TEXT225 "AND ALL THIIIISSS??? " +#define TEXT226 "DON'T WORRY B.J. HONEY, I'LL SAVE YOU FROM FALLING INTO HIS CLUTCHES... " +#define TEXT227 "YOU REALLY GOT ME MAD MAN... " +#define TEXT228 "AHHH A WEREWOLF!! DIE YOU DAMNED EVIL! " +#define TEXT229 "YES, WELL... " +#define TEXT230 "YES, WELL...I THINK I'LL JUST GO ON MY WAY. EXCUSE ME " +#define TEXT231 "WHAT? " +#define TEXT232 "TO TELL YOU THE TRUTH...ON SECOND THOUGHTS...I DON'T REALLY THINK SO. " +#define TEXT233 "AND SO TELL ME YOU ERUDITE PHILOSOPHER, IS THERE ANY RELATIONSHIP CAUSE-AND-EFFECT BETWEEN SILLY AND BILLY?" +#define TEXT234 "OK, OK, FORGET IT. I DON'T EVEN KNOW WHU I SAID ANYTHING ABOUT IT " +#define TEXT235 "WHAT ARE YOU DONIG HERE PHILOSPOZING INSTEAD OF BEING EATING SOME PEOPLE " +#define TEXT236 "HOW come? " +#define TEXT237 "HEY, COULD YOU SAY AGAIN ALL THAT ABOUT PRE-EVOLUTIONARY RELATIONSHIPS? " +#define TEXT238 "YES, MAN. ALL THAT STUFF YOU TOLD ME ABOUT NEFORE. I DIDN'D GET IT VERY WELL, YOU KNOW. " +#define TEXT239 "NO, I'D RATHER NOT SAY ANYTHING, IN CASE HE GETS ANGRY OR SOMETHING... " +#define TEXT240 "HELLO? " +#define TEXT241 "YES, WHAT'S UP? " +#define TEXT242 "WELL, NOW THAT YOU MENTION IT, I'LL TELL YOU THAT... " +#define TEXT244 "WELL, THANKS FOR CALLING. BY THE WAY, THIS IS NOT THE CASE, OF COURSE, BUT WHAT COULD HAPPEN IF A VAMPIRE GOT THE RECIPE BY ANY CHANCE? " +#define TEXT245 "WELL ANYWAY. LISTEN, DOESN'T THIS LOOK TO YOU LIKE A LOT OF CRAP TO END UP SOON WITH THE GAME?. WELL, MAYBE NOT. " +#define TEXT246 "IT'S EMPTY! " +#define TEXT247 "WHY DID YOU TAKE MY ONLY LOVE, B.J. , AWAY FROM ME?. LIFE HAS NO MEANING FOR WITHOUT HER " +#define TEXT248 "HER BRAIN!!? " +#define TEXT249 "TO TELL YOU THE TRUTH, I THINK I HAD JUST ENOUGH WITH YOUR OF YOUR LITTLE MONSTER. " +#define TEXT250 "OH PLEASE, HOLLY VIRGIN, DON'T LET ANYTHING WORSE HAPPEN TO ME!! " +#define TEXT251 "YOU ARE NOT GOING TO GET YOUR WAY. I'M SURE SUPERMAN WILL CAME AND RESCUE ME!" +#define TEXT252 "WHAT A SHIT OF GAME IS THIS IN WHICH THE PROTAGONIST DIES! " +#define TEXT253 "HEY, WAIT A SECOND!, WHAT ABOUT MY LAST WISH? " +#define TEXT254 "HA. HA, I'M NOW IMMUNIZED AGAINST YOU DAMNED EVIL!. THIS CIGARETTE IS AN ANTI-VAMPIRE BREW THAT VON BRAUN GAVE TO ME " +#define TEXT255 "YES SURE, BUT YOU'LL NEVER GET ME TO GIVE YOU THE RECIPE " +#define TEXT256 "APART FROM CREATING TORTURE, I CAN ALSO STAND IT.. " +#define TEXT257 "OH, NO PLEASE! I'LL TALK, BUT PLEASE, DON'T DO THAT TO ME! " +#define TEXT258 "ALL RIGHT THEN. I TOLD YOU WHAT YOU WANTED TO KNOW. NOW SET B.J. AND ME FREE AND LEAVE US ALONE! " +#define TEXT259 "WHAT ARE YOU DOING HERE B.J.?. WHERE IS DRASCULA? " +#define TEXT260 "WHAT A MEAN GUY!. JUST BECAUSE HE BELONGS TO THE NOBILITY HE THINKS HE IS ENTITLED TO SLEEP WITH ANYBODY HE FEELS LIKE. " +#define TEXT261 "DOWN WITH ARISTOCRATIC DESPOTISM!! " +#define TEXT262 "POOR PEOPLE OF THE WORLD FOR EVER..!! " +#define TEXT263 "AND AS I CAN SEE HE HAS CHAINED YOU UP WITH LOCKS AND ALL THAT STUFF, HUH? " +#define TEXT264 "WELL, ALL RIGHT. DO YOU HAVE A HAIRPIN OVER THERE? " +#define TEXT265 "ALL RIGHT, OK, DON'T GET MAD. I'LL THINK ABOUT SOMETHING " +#define TEXT266 "YOU...BARTENDER!! " +#define TEXT267 "HOW IS THE GAME GOING? " +#define TEXT268 "WHO? " +#define TEXT269 "CAN'T YOU SEE DRASCULA IS HERE? " +#define TEXT270 "THEN, LET'S END UP WITH HIM, RIGHT? " +#define TEXT271 "GIVE ME A SCOTCH ON THE ROCKS " +#define TEXT272 "NOTHING, I JUST FORGOT WHAT I WAS GOING TO SAY... " +#define TEXT273 "EITHER YOU GET ME A SCOTCH ON THE ROCKS OR I'LL PLAY THE PIANO UNTIL THE GAME IS OVER " +#define TEXT274 "WHEN IS THE MATCH GOING TO BE OVER? " +#define TEXT275 "GOOD EVENING" +#define TEXT276 "AND SO IGOR, HOW ARE YOU FEELING...A LITTLE HUMPED...?. HA, HA, HA, THAT WAS FUNNY! " +#define TEXT277 "WHAT ARE YOU SUPPOSED TO BE DOING? " +#define TEXT278 "WELL, NO. " +#define TEXT279 "THEN WEAR GLASSES. " +#define TEXT280 "WHAT IS ALL THAT ABOUT THE SUPERNATURAL ORGY? " +#define TEXT281 "OK, OK, STOP IT. I THINK I CAN GET THE PICTURE. " +#define TEXT282 "COULDN'T YOU TELL ME WHERE DRASCULA IS? " +#define TEXT283 "OH...PLEASE...COME ON...! " +#define TEXT284 "WHY NOT? " +#define TEXT285 "OH...BUT DIES HE SLEEP AT NIGHT? " +#define TEXT286 "WELL, I HOPE YOU GET LUCKY " +#define TEXT287 "I HAVE TO TALK TO HIM... " +#define TEXT288 "YOOUUU...SKELETOOOONN..!!! " +#define TEXT289 "GOOD HEAVENS!, IT'S A DEAD MAN TALKING! " +#define TEXT290 "TELL HOW DID YOU GET TO END UP HERE " +#define TEXT291 "AND WHY WOULD DRASCULA WANT TO CREATE A MONSTER? " +#define TEXT292 "WHAT'S YOUR NAME, MY SKELETON FRIEND? " +#define TEXT293 "HEY, DON'T YOU WANT ANYTHING TO EAT? " +#define TEXT294 "I BET YOUR STOMACH IS PRETTY EMPTY...HA, HA,HA! " +#define TEXT295 "THE THING IS THAT I DON'T FEEL LIKE TALKING RIGHT NOW " +#define TEXT296 "I HOPE SOMEONE F...(WHISTLE) YOU...,AND YOUR F...(WHISTLE) SON OF (WHISTLE TWICE) " +#define TEXT297 "I REALLY LOVED HER. I KNOW SHE WASN'T MUCH OF A WONDER, BUT NOBODY'S PERFECT, RIGHT? " +#define TEXT298 "BESIDES. SHE REALLY HAD ONE OF THOSE GREAT BODIES THAT YOU NEVER FORGET... " +#define TEXT299 "I'LL NEVER BE THE SAME AGAIN. I WILL SHUT MYSELF AWAY IN A MONASTERY, AND WILL LET MY LIFE JUST FLOW... " +#define TEXT300 "NOTHING WILL GET ME OUT OF THIS MYSTERY BECAUSE..." +#define TEXT301 "WHOSE?. WHOSE? " +#define TEXT302 "I WANT TO BECOME A PIRATE " +#define TEXT303 "I WANT TO BECOME A PROGRAMMER " +#define TEXT304 "TELL ME SOMETHING ABOUT PELAYO " +#define TEXT305 "I'LL JUST GO ON PLAYING, AND I'LL FORGET I SAW YOU. " +#define TEXT306 "WHOSE STUPID IDEA COULD THIS BE? " +#define TEXT307 "IT'S LIKE MY GRANDMOTHER'S HANDBAG " +#define TEXT308 "JESUS, AREN'T I JUST REALLY COOL MAN...! " +#define TEXT309 "THE MORE I SEE MYSELF, THE MORE I LOVE ME " +#define TEXT310 "HOW DO I LOCK MYSELF THEN? " +#define TEXT311 "I'LL HAVE TO OPEN ME FIRST, RIGHT? " +#define TEXT312 "I'M ALL RIGHT WHERE I AM " +#define TEXT313 "I GOT ME " +#define TEXT314 "HI, MYSELF! " +#define TEXT315 "I'LL WEAR THEM WHEN THE RIGHT TIME COMES " +#define TEXT316 "I CAN'T SEE ANYTHING SPECIAL ABOUT IT " +#define TEXT317 "IT'S ALL RIGHT WHERE IT IS " +#define TEXT318 "AND WHAT FOR? " +#define TEXT319 "I CAN'T " +#define TEXT320 "HI, YOU! " +#define TEXT321 "IT'S UNCLE DESIDERIO'S PANTHEON! " +#define TEXT322 "YOOUU...UNCLE DESIDERIOOOO!! " +#define TEXT323 "NO, I DON'T WANT TO CUT MYSELF AGAIN " +#define TEXT324 "AHHH,,,EXCUS.... " +#define TEXT325 "JAMM. AHH... " +#define TEXT326 "YES...WOF, WOF " +#define TEXT327 "LOOK, THERE'S A PIECE OF BUBBLE GUM STUCK HERE. " +#define TEXT328 "THIS IS THE PORTABLILINE I GOT LAST CHRISTMAS " +#define TEXT329 "IT'S VERY HIGH! " +#define TEXT330 "COME OUT TO THE BALCONY MY JULIET!! " +#define TEXT331 "YOU ARE THE LIGHT THAT ILLUMINATES MY WAY! " +#define TEXT332 "HEY, DOOR!, WHAT'S THE MATTER? " +#define TEXT333 "YOOOUU, CIGARETTE SPENDING MACHINEEE! " +#define TEXT334 "IT'S A CIGARETTE SPENDING MACHINE " +#define TEXT335 "I HAVE ANOTHER COIN INSIDE " +#define TEXT336 "NO, I JUST DECIDED TO QUIT SMOKING AND DRINKING ALCOHOL " +#define TEXT337 "I WILL DEVOTE MYSELF TO WOMEN FROM NO ON " +#define TEXT338 "THIS IS A TRICK! NOTHING CAME OUT! " +#define TEXT339 "AT LAST! " +#define TEXT340 "JUST A TRUNK " +#define TEXT341 "HELLO TRUNK, YOUR NAME IS JUST LIKE MY COUSIN FRANK... " +#define TEXT342 "I'VE FOUND B.J.'S HANDBAG! " +#define TEXT343 "OH MY GOD! DON'T GET MY IMAGE REFLECTED! I'M A VAMPIRE! " +#define TEXT344 "OH...JESUS, IT'S JUST A DRAWING! " +#define TEXT345 "LITTLE MIRROR, TELL ME, WHO IS THE MOST BEAUTIFUL IN THE WHOLE KINGDOM? " +#define TEXT346 "HE WON'T OPEN " +#define TEXT347 "ALL RIGHT. I GOT THE EAR-PLUGS ON " +#define TEXT348 "IT'S A VAMPIRE'S HUNTER DIPLOMA, officially approved by oxford university " +#define TEXT349 "NOT YET. THERE ARE STILL SOME INGREDIENTS MISSING. IT'S NOT WORTH WAKING HIM UP " +#define TEXT350 "BUT I DON'T HAVE MONEY " +#define TEXT351 "IT'S A BRITISH LAMP " +#define TEXT352 "HELP ME OUT HERE BARTENDER!! " +#define TEXT353 "A VAMPIRE CAME IN AND TOOK MY GIRLFRIEND AWAY!! " +#define TEXT354 "BUT, AREN'T YOU GOING TO HELP ME!!?? " +#define TEXT355 "DEAD?, WHAT DO YOU MEAN DEAD? " +#define TEXT356 "AAHH.... " +#define TEXT357 "A VAMPIRE HAS KIDNAPPED THE GIRL IN ROOM 501 " +#define TEXT358 "BUT YOU HAVE TO HELP ME OUT! " +#define TEXT359 "CAN'T YOU PLAY ONE FROM BLUR? " +#define TEXT360 "HOW CAN YOU STAY HERE ALL DAY PLAYING THE SAME SONG ALL THE TIME? " +#define TEXT361 "AND THEN, HOW CAN YOU HEAR ME? " +#define TEXT362 "PLEASE, LEND ME THE ERA-PLUGS. " +#define TEXT363 "COME ON, I'LL GIVE THEM BACK TO YOU RIGHT AWAY " +#define TEXT364 "COOOMEE OONNN... " +#define TEXT365 "WELL GOODBYE, I HAVE TO KILL A VAMPIRE. " +#define TEXT367 "WHAT'S YOUR LANGUAGE, TRASILVANIAN? " +#define TEXT368 "WHO IS UNCLE DESIDERIO? " +#define TEXT369 "BUT, WHAT'S THE MATTER WITH THAT DRASCULA? " +#define TEXT370 "WHO IS THAT GUY NAMED VON BRAUN? " +#define TEXT371 "AND WHY DOESN'T HE DO IT? " +#define TEXT372 "AND WHERE CAN I FIND VON BRAUN? " +#define TEXT373 "WELL, THANKS AND GOODBYE. HOPE YOU SLEEP IT OFF JUST FINE. " +#define TEXT374 "WE'D BETTER CALL FIRST " +#define TEXT375 "ARE YOU PROFESSOR BRAUN? " +#define TEXT376 "AND COULD YOU TELL ME WHERE I CA...? " +#define TEXT377 "I DON'T BELIEVE HE IS GANIMEDES THE DWARF " +#define TEXT378 "PROFESSOR!! " +#define TEXT379 "PLEASE HELP ME!. THE LIFE OF MY GIRLFRIEND DEPENDS ON YOU!! " +#define TEXT380 "WELL, ALL RIGHT. I DON'T NEED YOUR HELP " +#define TEXT381 "ALL RIGHT. I'M LEAVING " +#define TEXT382 "DON'T DE AFRAID. WE WILL BEAT DRASCULA TOGETHER. " +#define TEXT383 "THEN WHY DON'T YOU HELP ME? " +#define TEXT384 "I GOT THEM " +#define TEXT385 "YES, I GOT THEM!! " +#define TEXT386 "ALL RIGHT " +#define TEXT387 "AHH....YES " +#define TEXT388 "I HAVE COME TO GET INTO THAT CABIN AGAIN " +#define TEXT389 "I AM READY TO FACE YOUR TEST" +#define TEXT390 "ALL RIGHT OLD MAN. I CAME FOR MY MONEY " +#define TEXT391 "NO, NOTHING. I WAS JUST LEAVING " +#define TEXT392 "SORRY..." +#define TEXT393 "DO YOU LIKE THIS BOOK?. IT HAS SOME SCORES FROM TCHAIKOWSKY " +#define TEXT394 "HOW CAN I KILL A VAMPIRE?" +#define TEXT395 "HAS ANYBODY TOLD YOU THAT SLEEPING IN A BAD POSITION IS NOT GOOD FOR YOU? " +#define TEXT396 "THAT'S WHAT MY MUM ALWAYS TELL ME " +#define TEXT397 "WHY WOULDN'T DRASCULA KILL YOU? " +#define TEXT398 "AND WHAT WAS IT? " +#define TEXT399 "GREAT! YOU HAVE AN IMMUNIZING BREW" +#define TEXT400 "SO? " +#define TEXT401 "ALL RIGHT " +#define TEXT402 "CAN YOU REPEAT WHAT I NEED FOR THAT BREW " +#define TEXT403 "WELL, I'LL RUSH OUT TO GET IT " +#define TEXT404 "HEY, WHAT HAPPENED WITH THE PIANIST? " +#define TEXT405 "I HAVE ALL THE INGREDIENTS OF THAT BREW " +#define TEXT406 "JUST A QUESTION. WHAT IS ALL THAT ABOUT THE ALUCSARD ETEREUM? " +#define TEXT407 "HELLO, HELLO... " +#define TEXT408 "AND WHERE IS THAT CAVERN? " +#define TEXT409 "WHAT HAPPENS? DIDN'T YOU HAVE TO GO TO THE COURT? " +#define TEXT410 "...BUT... IF I MEET MORE VAMPIRES? " +#define TEXT411 "IT'S A VAMPIRE THAT DOESN'T LET ME COME THROUGH " +#define TEXT412 "HE LOOKS LIKE YODA, BUT A LITTLE TALLER " +#define TEXT413 "HEY YODA, IF YOU JUST LET ME GO ON MY WAY, I'LL GIVE YOU A PENNY " +#define TEXT414 "OK, OK, YOU GET MAD ABOUT NOTHING MAN " +#define TEXT415 "HAS ANYBODY TOLD YOU THAT YOU LOOK LIKE YODA?" +#define TEXT416 "HI VAMPIRE, IT'S A BEAUTIFUL NIGHT, HUH? " +#define TEXT417 "ARE YOU A VAMPIRE OR AN OIL PAINTING? " +#define TEXT418 "I'D BETTER NOT SAY ANYTHING, IN CASE YOU GET MAD " +#define TEXT419 "IT'S LOCKED " +#define TEXT420 "THE MAGPIE WOULD STICK OUT MY EYES IF I TRIED! " +#define TEXT421 "OH MY GOD. IT'S LOCKED...THAT'S SCARY, HUH?" +#define TEXT422 "THE HINGES ARE RUSTY " +#define TEXT423 "THERE IS ONLY ONE CAN OF FLOUR IN THERE " +#define TEXT424 "THAT TOOK AWAY THE RUST " +#define TEXT425 "I HAVE FOUND A PINE STICK " +#define TEXT426 "I'LL TAKE THIS THICKER ONE " +#define TEXT427 "WELL, I THINK I CAN GET RID OF THIS STUPID DISGUISE " +#define TEXT428 "\"PASSAGE TO TOWERS CLOSED FOR REPAIRS. PLEASE USE MAIN ENTRANCE. SORRY FOR THE INCONVENIENCE\"" +#define TEXT429 "...HE IS PALE, HE HAS FANGS AND WEARS A TOUPE AND HE SURE IS DRASCULA! " +#define TEXT430 "IT'S B.J.! ARE YOU ALL RIGHT B.J.? " +#define TEXT431 "YES, I KNOW SHE IS STUPID, BUT I'M SO LONELY " +#define TEXT432 "YOU DON'T HAVE A KEY AROUND THERE, DO YOU?" +#define TEXT433 "I BET YOU DON'T HAVE A PICKLOCK AROUND! " +#define TEXT434 "GIVE ME A HAIRPIN, I'M GOING TO PLAY MCGYVER HERE! " +#define TEXT435 "DON'T GO ANYWHERE. I'LL BE RIGHT BACK " +#define TEXT436 "SHOOT! IT'S BROKEN! " +#define TEXT437 "OLEEEE! I EVEN SHAVED DUDE! " +#define TEXT438 "YES, DARLING? " +#define TEXT439 "HE'S NOT ARRIVED YET " +#define TEXT440 "THE PIANIST IS NOT HERE " +#define TEXT441 "A TRANSYLVANIAN SCOTCH ON THE ROCKS " +#define TEXT442 "I DON'T HAVE A ROOM YET " +#define TEXT443 "IT LOOKS LIKE HE GOT STUCK IN THE BATH AND DECIDED TO RUN A BAR " +#define TEXT444 "HE WAS DRUNK AS A SAILOR " +#define TEXT445 "THAT HAIR...REMINDS ME OF SOMEBODY " +#define TEXT446 "IT'S A RAW-BONED SKELETON " +#define TEXT447 "LOOK! THERE'S MIGUEL BOSE! " +#define TEXT448 "HE'S ASLEEP. IT'D BE A SHAME WAKING HIM UP." +#define TEXT449 "HE'S UGLIER THAN EMILIO DE PAZ " +#define TEXT450 "A PINE-WOODEN COFFIN " +#define TEXT451 "HE IS GOING TO CUT ME IN LITTLE SLICES. JUST LIKE A SAUSAGE " +#define TEXT452 "I DON'T LIKE PENDULAE. I'D RATHER PREFER ARTICHOKES. " +#define TEXT453 "I CAN'T MAKE IT. I'M HANDCUFFED " +#define TEXT454 "IT'S OBVIOUSLY A SECRET DOOR. " +#define TEXT455 "THEY IGNORE ME " +#define TEXT456 "COME ON..! " +#define TEXT457 "WHEN I READ THE SCRIPT IT WAS SUPPOSED TO MOVE, BUT THE BUDGET GOT CRAZY AND THEY COULDN'T AFFORD TO PAY THE GYM, SO THAT I NEVER GOT TOUGH. END OF STORY. " +#define TEXT458 "IT SEEMS A LITTLE LOOSE FROM THE WALL " +#define TEXT459 "I DON'T THINK IS GOING TO HELP ME ANYWAY. IT'S TOO WET TO LIGHT IT " +#define TEXT460 "TO WEST WING? NO WAY! NOBODY KNOWS WHAT YOU CAN FIND THERE!! " +#define TEXT461 "SHE'S GOT NICE TRANSILVANIAN REASONS " +#define TEXT463 "IT'S A SHAME THERE ISN'T A ROASTED LAMB IN THERE " +#define TEXT464 "LAST TIME I OPENED AN OVEN I BLEW UP THE HOUSE " +#define TEXT465 "THAT'S THE TRANSILVANIAN FOOTBALL BADGE. " +#define TEXT466 "WHAT FOR? TO PUT IT ON MY HEAD " +#define TEXT467 "I DON'T THINK THESE TOWERS ARE THE OPENING KIND " +#define TEXT468 "I DON'T WANT TO KNOW WHAT KIND OF FOOD IS IN THERE! " +#define TEXT469 "IT LOOKS IMPRESSIONIST TO ME... " +#define TEXT470 "THE NIGHT IS FALLING OVER ALL OF US...THAT'S SCARY, ISN'T IT? " +#define TEXT471 "IT'S STUCK! " +#define TEXT472 "IT'S THE KING. YOU DIDN'T IMAGINE THAT, DID YOU! " +#define TEXT473 "NO, I ALREADY HAVE ONE AT HOME TO FEED." +#define TEXT474 "A SHELF WITH BOOKS AND SOME OTHER THINGS. " +#define TEXT475 "BUT WHO CAN I CALL AT THIS TIME? " +#define TEXT476 "\"HOW TO MAKE THE TAX RETURN FORMS\". HOW INTERESTING!" +#define TEXT477 "I ALREADY HAVE ONE AT HOME. I THINK IT'S A WORLDWIDE BEST SELLER " +#define TEXT478 "A COMPLETELY NORMAL KEY " +#define TEXT479 "I THINK SHE IS NOT FROM AROUND HERE " +#define TEXT480 "HEY, THEY'RE FANG-LIKE FRENCH FRIES! I LOVE IT! " +#define TEXT481 "I DON'T THINK THIS IS THE RIGHT TIME TO EAT THAT CRAP KNOWING THAT MY GIRLFRIEND HAS BEEN KIDNAPPED BY THE MOST EVIL PERSON EVER ON EARTH " +#define TEXT482 "I'M HAVING A GREAT TIME KILLING VAMPIRES WITH THIS THING! " +#define TEXT483 "LET'S SEE IF ANOTHER ONE COMES SOON! " +#define TEXT484 "NO, IT HAS TO BE WITH A DIRTY AND STINKY VAMPIRE, JUST LIKE THE ONE I KILLED BEFORE " +#define TEXT485 "THIS IS THE ONE AND ONLY WIG ELVIS USED WHEN HE GOT BALD" +#define TEXT486 "IT'S FLOUR, BUT DON'T ASK ME ANY COMMERCIAL NAMES. " +#define TEXT487 "MAYBE ANOTHER TIME, OK? " +#define TEXT488 "THAT'S A GREAT AXE, IT'S A SHAME THERE IS NO VAMPIRE'S HEAD AROUND HERE, HUH? " +#define TEXT489 "NO. I'M REALLY A GOOD PERSON. " +#define TEXT490 "IT'S MARGARET'S THATCHER DEODORANT...HA, HA, HA...!! " +#define TEXT491 "THAT'S A PRETTY CUTE CLOAK " +#define TEXT493 "JUST LIKE ALL BRANCHES FROM ANY TREE IN THE WORLD, THERE IS NOTHING SPECIAL. " +#define TEXT494 "HEY, THAT'S AMAZING! A ROPE WITHIN THIS TYPE OF ADVENTURE!" +#define TEXT495 "I WONDER WHAT WE COULD USE IT FOR... " +#define TEXT496 "A ROPE TIED TO A BRANCH OR THE OTHER WAY AROUND, HOWEVER YOU WANT TO PUT IT..." +#define TEXT497 " IT LOOKS LIKE THIS MAGPIE IS EVIL-MINDED" +#define TEXT498 "FORGET IT, I'M NOT SAYING ANYTHING IN CASE HE GETS MAD " +#define TEXT499 "SHE LOOKS DEAD, BUT SHE REALLY ISN'T, HUH? " +#define TEXT500 "NO ANIMAL WAS HARMED DURING THE PRODUCTION OF THIS GAME " +#define TEXTB1 "I'M HERE, DRINKING " +#define TEXTB10 "FROM TIME TO TIME HE COMES DOWN TO THE VILLAGE AND TAKES SOMEONE WITH HIM.. " +#define TEXTB11 "A LITTLE WHILE AFTER WE JUST A FEW FOUND BODY PARTS. I THINK HE IS DEALING WITH ORGANS OR SOMETHING LIKE THAT" +#define TEXTB12 "THE ONLY PERSON IN THE VILLAGE WHO KNOWS HOW TO END UP WITH DRASCULA IS A CULTIVATED PERSON " +#define TEXTB13 "HE LIVES IN A LOG-CABIN OUT OF TOWN, EVER SINCE DRASCULA BEAT HIM UP. " +#define TEXTB14 "HE IS THE ONLY ONE WHO COULD HELP US WITH DRASCULA, AND HE DOESN'T WANT TO HEAR ABOUT US. HOW DO YOU LIKE THAT? " +#define TEXTB2 "THEY ARE ALL DEAD, THANKS. BURPP... " +#define TEXTB3 "YES, SURE... " +#define TEXTB4 "SHE FEELS ATTRACTED TO UNCLE DESIDERIO. " +#define TEXTB5 "EVEN BETTER, UNCLE DESIDERIO'S DEAD BODY. " +#define TEXTB6 "MY UNCLE. HE WENT TO CASTLE AND NEVER CAME BACK " +#define TEXTB7 "WELL, HE CAME BACK JUST A LITTLE. IF ONLY VON BRAUN HADN'T SCREWED THINGS UP MY UNCLE WOULD BE DRINKING WITH US NOW. " +#define TEXTB8 "NOTHING... " +#define TEXTB9 "WELL, YES !. THAT MEAN MAN HAS TERRIFIED US ALL. " +#define TEXTBJ1 "ARE YOU ALL RIGHT?. HEY, COME ON, WAKE UP! CAN YOU HEAR ME ? ARE YOU DEAD? " +#define TEXTBJ10 "OH, NO...! IT WASN'T THE HIT, HA, HA. I JUST STEEPED ON YOUR GLASSES BY ACCIDENT " +#define TEXTBJ11 "YOU REALLY LOOK GOOD WITH THOSE GLASSES. I KNOW HE'S NOT FERNANDO LANCHA, BUT I FIND HIM ATTRACTIVE... " +#define TEXTBJ12 "YES, YES, I DO...COME ON, HOLD ME AND KISS ME TIGHT " +#define TEXTBJ13 "OH JHONNY, HONEY, THANKS GOD YOU'RE HERE...THAT DAMNED DRASCULA TIED ME UP TO THE BED AND THEN HE'S GONE DOWNSTAIRS TO SEE THE FOOTBALL GAME. " +#define TEXTBJ14 "YES, IT'S TRUE. PLEASE, SET ME FREE " +#define TEXTBJ15 "NO, I'M SORRY. I USED THEM ALL IN THE TOWER WHEN I WAS TRYING TO LIBERATE WHILE YOU LET ME DOWN. " +#define TEXTBJ16 "JOHNNY, IS THAT YOU?. OH, GOD, GREAT! I KNEW YOU'D COME! " +#define TEXTBJ17 "YOU DON'T EVEN KNOW HOW MUCH THAT EVIL DRASCULA HAS MADE ME SUFFER " +#define TEXTBJ18 "FIRSTLY HE BROUGHT ME FLYING OVER HER AND THEN PUT ME IN THIS DISGUSTING ROOM WITHOUT EVEN A MIRROR OR ANYTHING " +#define TEXTBJ19 "I'M TELLING YOU!, AND THE WORSE PART IS THAT HE DIDN'T EVEN APOLOGIZE, NOT EVEN ONCE " +#define TEXTBJ2 "NO, MY NAME IS BIlLIE JEAN, BUT YOU CAN CALL ME B. J., IT'S SHORTER " +#define TEXTBJ20 "JHONNY HONEY, WHERE ARE YOU? " +#define TEXTBJ21 "I'M READY TO LEAVE DEAR. " +#define TEXTBJ22 "WAIT, I'M GOING TO TAKE A LOOK...NO DARLING, I'M SORRY " +#define TEXTBJ23 "THERE YOU GO... " +#define TEXTBJ24 "\"DEAR JOHNNY\"" +#define TEXTBJ25 "I'LL NEVER FORGET YOU BUT I HAVE REALIZED THAT THIS JUST COULDN'T WORK OUT RIGHT. TO BE HONEST WITH YOU I'LL TELL YOU THAT THERE IS ANOTHER MAN. HE IS TALLER, STRONGER... " +#define TEXTBJ26 "AND HE HAS ALSO RESCUED ME FROM DRASCULA. HE HAS ASKED ME TO MARRY HIM, AND I HAVE ACCEPTED. " +#define TEXTBJ27 "BYE JHONNY. PLEASE DON'T TRY TO FIND SOME KIND OF EXPLANATION. YOU KNOW LOVE IS BLIND AND HAS ITS OWN WAYS " +#define TEXTBJ28 "I HOPE THERE WON'T BE HARD FEELINGS BETWEEN US. REMEMBER THAT I STILL LOVE YOU, BUT ONLY AS A FRIEND " +#define TEXTBJ3 "HA, HA...! THAT WAS A GOOD ONE! " +#define TEXTBJ4 "WELL, JHONNY. YOU SEE, I WAS HERE JUST READY TO GO TO BED WHEN I HEARD THIS STRONG NOISE DOWN THE CORRIDOR. " +#define TEXTBJ5 "I DIDN'T PAY ATTENTION AT FIRST, BUT AFTER ABOUT TWO HOURS OR SO I COULDN'T SLEEP AND WENT OUT FOR A WALK. " +#define TEXTBJ6 "AS I OPENED THE DOOR I WAS SHOCKED TO FIND YOU THERE, LYING ON THE FLOOR. I THOUGHT YOU WERE DEAD, I SWEAR...HA, HA, SILLY BILLY. " +#define TEXTBJ7 "I WAS GOING TO GIVE YOU THE KISS OF LIFE BUT IT WASN'T NECESSARY BECAUSE YOU STARTED TO TALK " +#define TEXTBJ8 "YOU SAID SOMETHING ABOUT A SCARECROW. I WAS VERY SCARED, YOU KNOW. IT'S A REAL SHOCK WHEN A DEAD PERSON STARTS TALKING RIGHT? " +#define TEXTBJ9 "ISN'T THAT RIGHT?, WELL, THEN I MANAGED TO BRING YOU TO MY ROOM THE BEST WAY I COULD. I PUT YOU IN BED...AND THAT'S ALL...HA, HA, HA... " +#define TEXTD1 "HEY IGOR, HOW ARE THINGS? " +#define TEXTD10 "THE TIME HAS COME ! TURN ON THE ALKALINE BATTERIES' SWITCH. " +#define TEXTD11 "DAMNED IT! WHAT WENT WRONG? " +#define TEXTD12 "ARE YOU SURE YOU CHECKED IT ALL AND THERE WAS NOTHING MISSING?. YOU'VE BEEN LATELY MESSING AROUND WITH THAT STUFF ABOUT TAXES AND I DON'T KNOW MAN... " +#define TEXTD13 "YOU STUPID THING! YOU FORGOT TO CONNECT THE INDIFIBULATOR. THE SCREWS HAVE PROBABLY MAGNETIZED AND HIS BRAIN BURNT " +#define TEXTD14 "YOU ARE DEAD, YOU ARE DEAD...WAIT TILL I GET YOU! " +#define TEXTD15 "SHUT UP! I'LL GET ANOTHER BRAIN TOMORROW AND THEN WE WILL REPEAT THE EXPERIMENT " +#define TEXTD16 "THIS TIME I'LL GET A WOMAN'S BRAIN. SHINY AND NOT USED YET...HA, HA, HA, GOODIE ONE! " +#define TEXTD17 "SO WHAT? I'M THE BAD GUY, RIGHT? SO I CAN BE AS FULL OF MACHISMO AS I WANT, ALL RIGHT?. AND IF YOU SAY SOMETHING AGAIN I'LL TURN YOUR HUMP BACK TO FRONT!" +#define TEXTD18 "HA, HA, HA. YOU FELL TOOO!! WHAT IS IT, ARE YOU ALL STUPID IN THIS COUNTRY?. DIDN'T YOU READ THE SIGN SAYING \"DRASCULA DOES NOT SLEEP HERE\"? IGOR, YOU ARE GOING TO PAY FOR DARING TO FIGHT AGAINST ME!" +#define TEXTD19 "AND SO, TELL ME , YOU STUPID HUMAN. HOW COME YOU WANT TO DESTROY ME? " +#define TEXTD2 "IT'S ALWAYS THE SAME STORY. EVERYTIME THERE'S A GOOD GAME ON THE SATELLITE! ANYWAY, WE'LL GO SEE IT IN THE BAR, AS USUAL " +#define TEXTD20 "THAT'S BEAUTIFUL!. IF IT WASN'T BECAUSE IT MAKES ME LAUGH, I WOULD CRY. " +#define TEXTD21 "OUR GIRLFRIEND'S BRAIN TO HELP ME CONQUERING THE WORLD " +#define TEXTD22 "YES, SURE! I'LL TAKE IT FROM HER AND GIVE IT TO MY FRUSKYNSTEIN. THE WORLD WILL BE MINE WITH IT, HA, HA. " +#define TEXTD23 "NO WHAT!?. YOU'RE DEAD, MAN! I'M GOING TO...YOU REALLY GOT ME ANGRY MAN...COME ON, PREPARE TO DIE! " +#define TEXTD24 "HA, HA, HA. NOT EVEN IN YOUR WILDEST DREAMS! " +#define TEXTD25 "YES, ISN'T IT? HA, HA, " +#define TEXTD26 "ALL RIGHT, ALL RIGHT. BUT DO IT QUICKLY, OK? " +#define TEXTD27 "PUT THAT CIGARETTE OUT NOW! I CAN'T STAND YOU ANYMORE! " +#define TEXTD28 "AND SO, DOES THAT BREW HAVE THE OPPOSITE EFFECT? " +#define TEXTD29 "WELL, WE'LL SEE THAT " +#define TEXTD3 "IGOR LISTEN CAREFULLY MAN, WE ARE GOING TO START WITH PHASE NUMBER ONE OF MY PLAN TO CONQUER THE WORLD. " +#define TEXTD30 "OK, LET'S SEE IT. IGOR, BRING ME THE CD \"SCRATCHING YOUR NAILS ALL OVER THE BLACKBOARD\"" +#define TEXTD31 "NO WAY. THE GIRL STAYS WITH ME. YOU RE STAYING THERE UNTIL THE PENDULUM CUTS YOU INTO THIN SLICES. HA, HA, HA. " +#define TEXTD32 "MAN I'M I JUST BAD... COME ON IGOR, LET'S MAKE THE BREW AND CONQUER THE WORLD." +#define TEXTD33 "WHAT HAPPENS NOW? " +#define TEXTD34 "YES, WHAT?...OH, DAMNED, THE GAME! " +#define TEXTD35 "I FORGOT ABOUT THAT. GET THE GIRL AND LET'S GO AND SEE HIM. WE CAN CONQUER THE WORLD LATER. " +#define TEXTD36 "THANKS MAN, I WAS THIRSTY " +#define TEXTD37 "OH, THE CRUCIFIX!!...THE CRUCIFIX...! " +#define TEXTD38 "I DIDN'T NOTICE ABOUT THAT BEAUTIFUL CRUCIFIX! " +#define TEXTD39 "LEAVE ME ALONE!, I'M WATCHING THE GAME " +#define TEXTD4 "FIRST WE'LL CAPTURE ONE OF THE STORM'S LIGHTNINGS AND WE'LL DEMAGNETIZE IT WITH OUR INDIFIBULATOR. THE ELECTRICITY WILL COME THROUGH TO MY MONSTER AND HE'LL GET ALIVE! " +#define TEXTD5 "IF EVERYTHING WORKS OUT ALL RIGHT, THIS WILL BE THE BEGINNING OF A GREAT ARMY THAT WILL CONQUER THE WORLD FOR ME. HA, HA,. " +#define TEXTD6 "THE MONSTERS WILL DESTROY ALL THE ARMY'S WEAPONS IN THE WORLD, MEANWHILE, WE'LL BE SAFE IN THE PIECES OF LAND I BOUGHT IN GIBRALTAR." +#define TEXTD7 "WE'LL SET UP A COUP. GOVERNMENTS ALL OVER THE WORLD WILL BE UNCOVERED AND THEIR COUNTRIES WILL SURRENDER TO ME! " +#define TEXTD8 "I'LL BECOME THE FIRST BAD GUY IN HISTORY TO MAKE IT ! HA, HA ! " +#define TEXTD9 "I'M NOT TALKING TO YOU, IDIOT! I'M JUST GIVING YOU THE PLOT. ALL RIGHT, EVERYTHING READY?" +#define TEXTE1 "YOU...HEY YOU! " +#define TEXTE10 "YEAH, IT'S YOU " +#define TEXTE11 "WHY DO ALL ADVENTURE GAMES END UP WITH A SUNRISE OR A SUNSET? " +#define TEXTE12 "DO ALL THESE NAMES BELONG TO THE CREATORS OF THE GAME?" +#define TEXTE13 "AREN'T THEY ASHAMED TO BE SEEN BY EVERYBODY? " +#define TEXTE14 "JESUS, THAT EMILIO DE PAZ IS EVERYWHERE!! " +#define TEXTE15 "REALLY? " +#define TEXTE16 "YES " +#define TEXTE17 "WELL, DON'T MAKE A FUSS ABOUT IT. " +#define TEXTE18 "HEY WEREWOLF, BY THE WAY... " +#define TEXTE19 "DIDN'T YOU FALL OFF A WINDOW AND GOT BADLY HURT " +#define TEXTE2 "DON'T GIVE ME THAT CRAP ABOUT A DEAD BODY OK? " +#define TEXTE20 "IF AT LEAST IT WASN'T ALWAYS THE SAME ONES... " +#define TEXTE21 "HE'S BEEN OUT FOUR TIMES ALREADY. " +#define TEXTE22 "I'D LIKE TO BE A MODEL " +#define TEXTE23 "ALL RIGHT, AND WHAT ARE YOU GOING TO DO? " +#define TEXTE3 "I'M ALIVE. IT'S JUST THAT I'M STARVING. " +#define TEXTE4 "WELL, YOU SEE. I WAS THE DRUNKARD OF THE VILLAGE, JUST KEEPING UP WITH THE FAMILY TRADITION, YOU KNOW?, ONE NIGHT DRASCULA KIDNAPPED ME TO TAKE MY ORGANS AWAY. " +#define TEXTE5 "SINCE ALCOHOL STILL KEEPS ME QUITE YOUNG, I'M HERE LIKE A SCRAP YARD. EVERYTIMR HE NEEDS SOMETHING FOR THE MONSTER HE IS CREATING, HE JUST COMES AND TAKES IT FROM ME." +#define TEXTE6 "IT HURT AT FIRST, BUT I DON'T CARE ANYMORE " +#define TEXTE7 "I DON'T KNOW. I GUESS IT'S HIS GRADUATE PROJECT. " +#define TEXTE8 "I'M DESIDERIO, AND I CAN HELP YOU IN ANYTHING YOU NEED. " +#define TEXTE9 "THE TRUTH IS THAT I DON'T REALLY FEEL LIKE IT, BUT THANKS VERY MUCH ANYWAY SIR. " +#define TEXTI1 "MASTER, I THINK THIS IS NOT WORKING " +#define TEXTI10 "YES, MY MASTER " +#define TEXTI11 "MASTER " +#define TEXTI12 "DO YOU KNOW WHAT TIME IS IT ? " +#define TEXTI13 "WHAT?, OH, THAT SCARED ME !. YOU ARE THE \"NIGHT-CLEANING GUY\", RIGHT?" +#define TEXTI14 "I'M IGOR, THE VALET. YOU CAN START WITH THE BALL ROOM. THERE'S BEEN A SUPER NATURAL ORGY YESTERDAY AND IT LOOKS LIKE SHIT. " +#define TEXTI15 "IF YOU NEED ANYTHING, JUST BUY IT. " +#define TEXTI16 "IT'S THE TAX RETURN APPLICATION FORM, CAN'T YOU SEE IT? " +#define TEXTI17 "NEITHER DO I. FIRST OF ALL THE NUMBERS ARE VERY SMALL AND ALSO I CAN'T SEE MUCH AT THIS DISTANCE.. " +#define TEXTI18 "NO WAY!. THEY MAKE ME LOOK UGLY. " +#define TEXTI19 "OH, WELL. IT'S JUST LIKE A CRAZY PARTY THAT THE MASTER ORGANIZES WITH HIS FRIENDS EACH TIME SOME IDIOT COMES ALONG TRYING TO KILL HIM." +#define TEXTI2 "I AM POSITIVE, MASTER " +#define TEXTI20 "THEY TAKE HIS EYES OUT. THEN, POUR SOME LEMON JUICE SO THAT IT ITCHES TO DEATH, AND THEN... " +#define TEXTI21 "NO" +#define TEXTI22 "WHAT DO YOU MEAN WHY NOT? DO YOU KNOW WHAT TIME IT IS? " +#define TEXTI23 "YES, IT'S WINTER " +#define TEXTI24 "SEE YOU LATER " +#define TEXTI25 "DON'T EVEN THINK ABOUT IT! " +#define TEXTI26 "WELL, THAT'S ENOUGH FOR TODAY. I'M GOING TO HAVE SUPPER " +#define TEXTI27 "MAN, I ALWAYS FORGET TO LOCK IT, RIGHT? " +#define TEXTI28 "THE HELL WITH IT! " +#define TEXTI29 "WHAT?. OH, YOU SCARED ME MASTER, I THOUGHT YOU WERE ASLEEP. " +#define TEXTI3 "I'M SORRY MASTER " +#define TEXTI30 "OH, BY THE WAY, I TOOK THE LIVING-ROOM KEYS SO THAT YOU CAN WATCH THE EARLY MORNING CARTOONS WITHOUT WAKING ME UP. " +#define TEXTI31 "YOU'VE GOT ANOTHER COLD MASTER? DAMN IT!. I TOLD YOU TO GET SOME HEATING IN HERE... " +#define TEXTI32 "ALL RIGHT, JUST TAKE YOUR ASPIRIN AND GO TO BED TO SWEAT FOR A WHILE. GOOD NIGHT " +#define TEXTI4 "ARE YOU GOING TO BRING HERE ANOTHER CRAZY SCIENTIST? I'LL TELL YOU THAT THE LABORATORY IS ALREADY PACKED UP, AND BESIDES, THEY'RE ALL OUT OF DATE. " +#define TEXTI5 "HUSH MASTER, THE FEMINIST COULD HEAR YOU" +#define TEXTI6 "DAMNED IT! " +#define TEXTI7 "I DIDN'T EXPECT YOU SO SOON, MASTER." +#define TEXTI8 "QUITE BAD MASTER. THERE MUST BE SOME PROBLEMS WITH THE SATELLITE AND I JUST CAN'T RECEIVE ANYTHING. BESIDES THERE ARE SOME INTERFERENCES BECAUSE OF THE STORM." +#define TEXTI9 "WHAT DO I KNOW, MASTER? " +#define TEXTL1 "WAIT A MINUTE. ARE YOU GOING TO LET OURSELVES BE GUIDED BY OUR MOST PRIMITIVE INSTINCTS JUST BECAUSE WE BELONG TO DIFFERENT RACES AND THE SOCIAL SITUATION IS TELLING US TO DO SO? " +#define TEXTL10 "PUKE! HUNTING AS A WAY TO SURVIVE IS AN INCOMPATIBLE ARCHAIC THING FOR A SUPERIOR BEING LIKE ME. BESIDES, I'VE BECOME A VEGETARIAN" +#define TEXTL11 "IT JUST HAPPENS THAT I WAS ACTUALLY EATING A GUY AND I STARTED TO BETHINK AND GET TO THE ABOVE MENTIONED THOUGHT. " +#define TEXTL12 "IT TOOK ME A LONG TIME TO QUIT OLD HABITS BUT AT LEAST MY IRASCIBLE SOUL BIT UP THE CONCUPISCIBLE ONE, AND EVER SINCE, I'VE NEVER EATEN MEAT AGAIN " +#define TEXTL13 "NOT EVEN THE PLEASURE OF SUCKING UP THE BONE, FEELING THE TASTE OF THE SKIN AND THAT SWEET TASTE OF MARROW...THAT JUST TAKES YOU TO HEAVENLY PLACES. " +#define TEXTL14 "IT DOESN'T REALLY GET TO ME AT ALL. " +#define TEXTL15 "WHAT? " +#define TEXTL16 "I DON'T KNOW WHAT YOU'RE TALKING ABOUT, YOU EPHEMERAL CREATURE " +#define TEXTL17 "I'M NOT INTERESTED " +#define TEXTL18 "I DON'T KNOW ABOUT THE OTHER GAMES, BUT WE COULD USE THIS BEAUTIFUL SCREEN." +#define TEXTL2 "AREN'T WE TIED BY SENSE WHICH IS THE MOST POWERFUL WEAPON AS WELL AS THE MOST PRECIOUS GIFT? " +#define TEXTL20 "I'D CARE... " +#define TEXTL21 "NO. IT'S JUST THE SON, THE FATHER, THE GRANDFATHER AND A FRIEND, WHO ARE CALLED LIKE THAT." +#define TEXTL22 "BUT, IT IS GOING TO LOOK LIKE THE GAME WAS MADE BY FIVE PEOPLE. " +#define TEXTL23 "THESE ARE PROMISING GUYS " +#define TEXTL24 "THAT'S A GOOD ONE! A GOOD ONE!" +#define TEXTL25 "PLEASE, CALL ME CONSTANTINO " +#define TEXTL26 "IT WASN'T ME MAN. IT WAS \"EL COYOTE\", MY TWIN" +#define TEXTL27 "JESUS, THESE ARE REALLY LONG CREDIT TITLES " +#define TEXTL28 "I STOPPED COUNTING A LONG TIME AGO " +#define TEXTL29 "WHAT WILL BECOME OF YOU NOW, DESIDERIO? " +#define TEXTL3 "OH, IF WE ALL LET OUR THOUGHTS GUIDE OUR WAY IN LIFE WITHOUT LEAVING SOME ROOM FOR FEELINGS WHICH ARE PRECISELY WHAT LET'S OUR PRE-EVOLUTIVE INSTINCTS COME OUT! " +#define TEXTL30 "BUT, YOU SHOULD LOSE SOME WEIGHT " +#define TEXTL31 "I'LL JUST RETIRE TO THE TIBET AND THINK ABOUT THE MEANING OF LIFE " +#define TEXTL4 "ANSWER ME, EPHEMERAL CREATURE. WOULDN'T WE ALL BE HAPPIER WITH THOSE EMOTIONAL BOUNDINGS? " +#define TEXTL5 "YOU ARE NOT GETTING THROUGH " +#define TEXTL6 "THIS IS A VERY CLEAR EXAMPLE, YOU SEE?: YOU WANT TO GET THROUGH AND GO AHEAD WITH YOUR ADVENTURE, AND I WON'T LET YOU DO THAT" +#define TEXTL7 "WILL THAT BE A CONTROVERSIAL POINT BETWEEN US THAT HAVE JUST MET? " +#define TEXTL8 "WELL THEN " +#define TEXTL9 "WELL, THAT DEPENDS ON WHAT WE TAKE A RELATIONSHIP FOR. SOME AUTHORS DEFEND... " +#define TEXTP1 "HI " +#define TEXTP10 "I'M A CONSERVATOIRE PIANIST AND THE BARTENDER WON'T BUY MORE SCORES FOR ME " +#define TEXTP11 "OH GOD, I REALLY LOVE CLASSIC MUSIC! " +#define TEXTP12 "IT'S BECAUSE I'M WEARING EAR-PLUGS" +#define TEXTP13 "IT'S BECAUSE I CAN LIP-READ " +#define TEXTP14 "NOOO " +#define TEXTP15 "NO! I'M NOT TAKING THIS ANY LONGER! " +#define TEXTP16 "NO WAYYYYY! " +#define TEXTP17 "WHAT?, OF COURSE I'M INTERESTED " +#define TEXTP18 "THANKS GOD! I CAN PLAY A DIFFERENT SONG NOW! " +#define TEXTP19 "I GUESS YOU CAN KEEP MY EAR-PLUGS " +#define TEXTP2 "YES SIR. IT'S BEAUTIFUL " +#define TEXTP3 "NO, NO. HE WON'T DO IT " +#define TEXTP4 "ALL RIGHT THEN " +#define TEXTP5 "REALLY? " +#define TEXTP6 "AND? " +#define TEXTP7 "I'M SORRY. THE PIANIST UNION TRADE DOESN'T ALLOW ME TO SAVE GIRLS FROM VAMPIRES' CLUTCHES " +#define TEXTP8 "IF YOU HAD BEEN KIDNAPPED BY THE WEREWOLF..." +#define TEXTP9 "I CAN ONLY PLAY THIS SONG " +#define TEXTT1 "WHAT HAPPENS, WHAT'S THE MATTER? " +#define TEXTT10 "THEY'RE WINNING " +#define TEXTT11 "LEAVE ALONE, ALL RIGHT? " +#define TEXTT12 "OF COURSE. I'M NOT BLIND " +#define TEXTT13 "THE TRADITION IN THIS VILLAGE IS TO FORGET ALL HARD FEELINGS WHENEVER THERE IS A GAME, SO AS TO CHEER UP THE LOCAL TEAM " +#define TEXTT14 "AND PLEASE, SHUT UP FOR GOD'S SAKE. I CAN'T HEAR ANYTHING! " +#define TEXTT15 "COME ON, LEAVE ME ALONE AND DON'T BOTHER ME ANYMORE " +#define TEXTT16 "IT HAS JUST STARTED! AND SHUT UP! " +#define TEXTT17 "OK, OK, I THOUGHT SOMETHING WAS GOING ON. " +#define TEXTT18 "IT DOESN'T MATTER, ANYWAY. SHE'LL PROBABLY BE DEAD BY NOW. " +#define TEXTT19 "HE JUST STARTED PLAYING CLASSIC MUSIC, AND I COULDN'T STAND IT " +#define TEXTT2 "OK. ROOM 512. UPSTAIRS. THE KEY IS ON THE DOOR " +#define TEXTT20 "SINCE I'M PAYING HIM FOR PLAYING WHATEVER I WISH, I JUST FIRED HIM. " +#define TEXTT21 "AND THEN, HE GOT FRESH WITH ME. JESUS!, HE LOOKED SO NICE AND INNOCENT...WHAT A HYPOCRITE! " +#define TEXTT22 "BY THE WAY, BE CAREFUL BECAUSE I JUST WAXED THE FLOOR. " +#define TEXTT23 "SHUT UP! WE'RE WATCHING THE GAME! " +#define TEXTT24 "OH, COME ON! TAKE IT! " +#define TEXTT3 "COUNT DRASCULA!!? " +#define TEXTT4 "NO, NOTHING. THAT GUY HAS A BAD REPUTATION OVER HERE. " +#define TEXTT5 "WELL, THERE ARE ALL KINDS OF STORIES GOING AROUND ABOUT HIM, SOME SAY HE IS A VAMPIRE WHO KIDNAPS PEOPLE TO SUCK UP THEIR BLOOD. " +#define TEXTT6 "HOWEVER, SOME OTHERS SAY THAT HE IS JUST AN ORGAN-DEALER AND THAT IS THE REASON WHY THERE ARE BODY PARTS ALL OVER THE PLACE." +#define TEXTT7 "BUT OF COURSE, THOSE ARE JUST RUMORS. HE'S PROBABLY BOTH THINGS. BY THE WAY, WHY DO YOU WANT TO MEET HIM? " +#define TEXTT8 "NO, FORGET IT. I'M REALLY BUSY... " +#define TEXTT9 "WELL, OK. BUT JUST BECAUSE I WANT TO DO IT, NOT BECAUSE YOU TELL ME TO. " +#define TEXTVB1 "WHO THE HELL IS CALLING AT THIS TIME ? " +#define TEXTVB10 "YOU DON'T HAVE THEM " +#define TEXTVB11 "I'M SURE YOU WOULDN'T BET ALL YOUR MONEY ON IT, HUH? " +#define TEXTVB12 "WELL, ALL RIGHT, COME ON IN " +#define TEXTVB13 "IF YOU REALLY MEAN TO FACE DRASCULA, YOU'VE GOT TO BE ABLE TO TAKE ALL TYPES OF CREAKING AND VAMPIRE-LIKE NOISES " +#define TEXTVB14 "IS THAT CLEAR? " +#define TEXTVB15 "OK, WAIT A MINUTE " +#define TEXTVB16 "STAND IN THE CENTER OF THE ROOM, PLEASE " +#define TEXTVB17 "WHERE DID I PUT THAT RECORD CALLED \"NAILS SCRATCHING THE BLACKBOARD\"?" +#define TEXTVB18 "ALL RIGHT. LET'S GET TO IT. " +#define TEXTVB19 "YOU ARE USELESS. YOU SEE...?, JUST LIKE THE REST!! " +#define TEXTVB2 "OH, ..OH, NO, NO....I'M...GANIMEDES THE DWARF. PROFESSOR VON BRAUN DOESN'T LIVE HERE ANYMORE. " +#define TEXTVB20 "JUST GIVE ME NOW THE MONEY YOU LOST AND GET OUT OF HERE " +#define TEXTVB21 "AND DON'T COME BACK UNTIL YOU ARE ABSOLUTELY READY " +#define TEXTVB22 "WHAT DO YOU WANT NOW? " +#define TEXTVB23 "I HAVE TO ADMIT IT. YOU REALLY GOT WHAT IT TAKES TO FIGHT AGAINST THE VAMPIRES. " +#define TEXTVB24 "HEY, TAKE YOUR MONEY. I ADMIT IT WHEN I MAKE A MISTAKE... " +#define TEXTVB25 "LEAVE ME ALONE NOW, I WANT TO GET SOME SLEEP. " +#define TEXTVB26 "WHENEVER YOU ARE READY TO FIGHT AGAINST THE VAMPIRES, JUST COME BACK AND I'LL HELP YOU OUT. " +#define TEXTVB27 "OH, THAT'S EASY. JUST USING THE LIGHT OF ONE CRUCIFIX IS ENOUGH TO DESTROY HIM. " +#define TEXTVB28 "YOU HAVE TO BE EXTRA CAREFUL WITH DRASCULA, HIS FRISISNOTICS POWERS HAVE MADE OF HIM THE MOST POWERFUL VAMPIRE " +#define TEXTVB29 "YOU'D BE LOST IF IT WASN'T FOR THE... " +#define TEXTVB3 "NO, I DON'T KNOW WHERE IT IS !! " +#define TEXTVB30 "...BREW! " +#define TEXTVB31 "YEAH, YOU'RE RIGHT! I MIGHT HAVE SOME PROBLEMS WITH MY BACK IN THE FUTURE IF I KEEP ON SLEEPING THIS WAY " +#define TEXTVB32 "WELL, OK, I UNDERSTAND HE WAS A BETTER OPPONENT THAN ME, BUT YOU HAVE TO ADMIT THAT THE DISCOVERY I MADE ABOUT ANTI-VAMPIRE TECHNIQUES WAS WHAT ACTUALLY PROTECTED ME. " +#define TEXTVB33 "I'VE FOUND THIS IMMUNIZING BREW THAT KEEPS YOU SAFE FROM ANY VAMPIRES' BITE OR AGAINST HIS FRISISNOTICS POWERS." +#define TEXTVB34 "NO, NO, EXCUSE ME. I HAD IT ONCE BUT IT'S VERY DANGEROUS TO HAVE A BREW OF THAT TYPE. CAN YOU IMAGINE WHAT COULD HAPPEN IF A VAMPIRE GOT IT? " +#define TEXTVB35 "HE'D BE IMMUNIZED AGAINST GARLIC, THE CRUCIFIX, THE SUNSHINE LIGHT...I JUST HAD TO GET RID OF WHAT WAS LEFT FROM IT. TO DO IT I USED THIS SCIENTIFIC METHOD OF THROWING IT IN THE LAVATORY" +#define TEXTVB36 "DON'T WORRY, I REMEMBER EXACTLY HOW TO MAKE THAT BREW. " +#define TEXTVB37 "I NEED GARLIC, BUT I ALREADY HAVE THEM. HOWEVER YOU'LL HAVE TO GET ME SOME WAX, BUBBLE GUM AND CIGARETTE PAPER OR PERHAPS A NAPKING OR SOMETHING ALIKE " +#define TEXTVB38 "OH...AND OF COURSE THE MOST IMPORTANT INGREDIENT. LEAVES FROM A VERY STRANGE PLANT CALLED FERNAN. " +#define TEXTVB39 "IT'S A CLIMBING PLANT WHICH LEAVES HAVE MAGIC POWERS IF THEY'RE CUT WITH A GOLDEN SICKLE. " +#define TEXTVB4 "GET OUT!! " +#define TEXTVB40 "SO THAT AS SOON AS YOU HAVE THESE FIVE THINGS, JUST COME HERE AND I'LL MAKE THE BREW. " +#define TEXTVB41 "YOU'LL BE READY THEN TO FIGHT AGAINST DRASCULA " +#define TEXTVB42 "REMEMBER: WAX, NICOTINE, A PIECE OF BUBBLE GUM, A PAPER AND SOME FERNAN'S LEAVES CUT WITH A GOLDEN SICKLE." +#define TEXTVB43 "I TOLD YOU! IT WAS JUST BECAUSE OF THE BREW! " +#define TEXTVB44 "OH, ALL RIGHT. I'M GOING TO MAKE MYSELF A...THE BREW. JUST A MOMENT, OK? " +#define TEXTVB45 "IT'S A PROTECTING SPELL AGAINST VAMPIRES. " +#define TEXTVB46 "I PUT IT THERE IN ORDER TO PRETEND THAT THE SKETCHER DIDN'T FORGET TO DRAW THE WINDOW YOU CAN SEE FROM OUTSIDE. " +#define TEXTVB47 "ALL RIGHT, THE FIRST THING YOU MUST KNOW IS THE WAY TO DRASCULA'S CASTLE. " +#define TEXTVB48 "THERE IS A CAVERN THAT GETS YOU STRAIGHT FROM THE CASTLE. IGOR, THE CRAZY ELVIS' FUN, TAKES IT TO GET TO THE VILLAGE EACH MORNING. " +#define TEXTVB49 "BE CAREFUL THOUGH, THERE IS A VAMPIRE ALWAYS WATCHING OVER IT. YOU'LL HAVE TO GET RID OF HIM. " +#define TEXTVB5 "IT'S TOO LATE NOW, YOU IDIOT!! IT ALWAYS IS " +#define TEXTVB50 "THERE IS AN OLD WELL RIGHT BY THE CEMETERY CHURCH " +#define TEXTVB51 "IT WAS USED A LONG TIME AGO FOR WITCHCRAFT TRIALS " +#define TEXTVB52 "THEY THREW THE WITCHES IN THE WELL. IF THEY DROWNED THEY WERE REAL WITCHES. IF THEY DIDN'T, THEY WEREN'T. " +#define TEXTVB53 "WE THREW ONE ONCE AND SHE DIDN'T DROWN, I GUESS SHE WASN'T A WITCH " +#define TEXTVB54 "ANYWAY. THERE IS YOUR BREW. HOWEVER, I ONLY GOT TO MAKE ENOUGH JUST FOR ONE PERSON " +#define TEXTVB55 "YOU'D BETTER SMOKE IT RIGHT BEFORE YOU FIGHT AGAINST DRASCULA " +#define TEXTVB56 "COME ON, RUN! " +#define TEXTVB57 "OH, JUST EXCUSES...! " +#define TEXTVB58 "ARE YOU JOHN HACKER? I'M DOCTOR VON BRAUN " +#define TEXTVB59 "LISTEN TO ME, THIS IS VERY IMPORTANT. IT'S ABOUT THE BREW" +#define TEXTVB6 "I COULDN'T AGREE MORE. " +#define TEXTVB60 "SHUT UP AND LET ME TALK. I JUST FOUND THIS BOOK ABOUT ANTI-VAMPIRE BREWS WARNING AGAINST MIXING THE JOINT WITH ANY ALCOHOLIC DRINK BEFORE YOU" +#define TEXTVB61 "ALCOHOL REACTS WHEN MIXED WITH BREW, SO THAT IT CANCELS OUT ITS EFFECTS JUST IN A FEW SECONDS. " +#define TEXTVB62 "I'M SORRY, BUT I HAVE TO HANG UP RIGHT NOW. THE POLICE IS LOOKING FOR ME, THEY THINK I'M A PUSHER. STUPID, ISN'T IT?. ANYWAY, BYE AND GOOD LUCK SAVING THE WORLD! " +#define TEXTVB7 "ME, SCARED? " +#define TEXTVB8 "LISTEN HERE, DUDE. YOU'RE RIGHT NOW TALKING TO THE ONLY PERSON WHO KNOWS THE SECRET TO FIGHT AGAINST THE VAMPIRE." +#define TEXTVB9 "YOU NEED TO HAVE SPECIAL SKILLS TO FIGHT AGAINST A VAMPIRE. NOT EVERYBODY CAN DO IT " +#define SYS0 "PRESS SUPR AGAIN TO restart" +#define SYS1 "press ESC again to exit" +#define SYS2 "VOiCES only" +#define SYS3 "VOices and TEXT" + +#define HIS1 "A long time ago, it seems that Drascula killed Von Braun's wife, and then, as he intended to face the count, Von Braun started to investigate all he found vampires." +#define HIS2 "When he thought he was ready, he came up to the castle and had a very violent encounter with Drascula." +#define HIS3 "Nobody knows exactly what happened there. Although Von Braun lost, Drascula could not kill him." +#define HIS4 "Von Braun felt humiliated by his defect, run away from the castle and has never dared to face Drascula ever again." + + + + -- cgit v1.2.3 From 2b219db314319484b6eaf34d3bdac09e81e6acbe Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Thu, 26 Jul 2007 20:22:51 +0000 Subject: Merged archive.cpp into disk.cpp. svn-id: r28221 --- engines/parallaction/archive.cpp | 208 --------------------------------------- engines/parallaction/disk.cpp | 175 ++++++++++++++++++++++++++++++++ engines/parallaction/module.mk | 1 - 3 files changed, 175 insertions(+), 209 deletions(-) delete mode 100644 engines/parallaction/archive.cpp (limited to 'engines') diff --git a/engines/parallaction/archive.cpp b/engines/parallaction/archive.cpp deleted file mode 100644 index 9eef3f44e9..0000000000 --- a/engines/parallaction/archive.cpp +++ /dev/null @@ -1,208 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ -#include "common/stdafx.h" - -#include "common/endian.h" -#include "common/file.h" - -#include "parallaction/disk.h" -#include "parallaction/parallaction.h" - - -namespace Parallaction { - -// HACK: Several archives ('de', 'en', 'fr' and 'disk0') in the multi-lingual -// Amiga version of Nippon Safes, and one archive ('fr') in the Amiga Demo of -// Nippon Safes used different internal offsets than all the other archives. -// -// When an archive is opened in the Amiga demo, its size is checked against -// SIZEOF_SMALL_ARCHIVE to detect when the smaller archive is used. -// -// When an archive is opened in Amiga multi-lingual version, the header is -// checked again NDOS to detect when a smaller archive is used. -// -#define SIZEOF_SMALL_ARCHIVE 12778 - -#define ARCHIVE_FILENAMES_OFS 0x16 - -#define NORMAL_ARCHIVE_FILES_NUM 384 -#define SMALL_ARCHIVE_FILES_NUM 180 - -#define NORMAL_ARCHIVE_SIZES_OFS 0x3016 -#define SMALL_ARCHIVE_SIZES_OFS 0x1696 - -#define NORMAL_ARCHIVE_DATA_OFS 0x4000 -#define SMALL_ARCHIVE_DATA_OFS 0x1966 - -Archive::Archive() { - resetArchivedFile(); -} - -void Archive::open(const char *file) { - debugC(1, kDebugDisk, "Archive::open(%s)", file); - - if (_archive.isOpen()) - close(); - - char path[PATH_LEN]; - - strcpy(path, file); - if (!_archive.open(path)) - error("archive '%s' not found", path); - - _archiveName = file; - - bool isSmallArchive = false; - if (_vm->getPlatform() == Common::kPlatformAmiga) { - if (_vm->getFeatures() & GF_DEMO) { - isSmallArchive = _archive.size() == SIZEOF_SMALL_ARCHIVE; - } else if (_vm->getFeatures() & GF_LANG_MULT) { - isSmallArchive = (_archive.readUint32BE() != MKID_BE('NDOS')); - } - } - - _numFiles = (isSmallArchive) ? SMALL_ARCHIVE_FILES_NUM : NORMAL_ARCHIVE_FILES_NUM; - - _archive.seek(ARCHIVE_FILENAMES_OFS); - _archive.read(_archiveDir, _numFiles*32); - - _archive.seek((isSmallArchive) ? SMALL_ARCHIVE_SIZES_OFS : NORMAL_ARCHIVE_SIZES_OFS); - - uint32 dataOffset = (isSmallArchive) ? SMALL_ARCHIVE_DATA_OFS : NORMAL_ARCHIVE_DATA_OFS; - for (uint16 i = 0; i < _numFiles; i++) { - _archiveOffsets[i] = dataOffset; - _archiveLenghts[i] = _archive.readUint32BE(); - dataOffset += _archiveLenghts[i]; - } - - return; -} - - -void Archive::close() { - if (!_archive.isOpen()) return; - - resetArchivedFile(); - - _archive.close(); - _archiveName.clear(); -} - -Common::String Archive::name() const { - return _archiveName; -} - -bool Archive::openArchivedFile(const char *filename) { - debugC(3, kDebugDisk, "Archive::openArchivedFile(%s)", filename); - - resetArchivedFile(); - - debugC(3, kDebugDisk, "Archive::openArchivedFile(%s)", filename); - - if (!_archive.isOpen()) - error("Archive::openArchivedFile: the archive is not open"); - - uint16 i = 0; - for ( ; i < _numFiles; i++) { - if (!scumm_stricmp(_archiveDir[i], filename)) break; - } - if (i == _numFiles) return false; - - debugC(9, kDebugDisk, "Archive::openArchivedFile: '%s' found in slot %i", filename, i); - - _file = true; - - _fileOffset = _archiveOffsets[i]; - _fileCursor = _archiveOffsets[i]; - _fileEndOffset = _archiveOffsets[i] + _archiveLenghts[i]; - - _archive.seek(_fileOffset); - - return true; -} - -void Archive::resetArchivedFile() { - _file = false; - _fileCursor = 0; - _fileOffset = 0; - _fileEndOffset = 0; -} - -void Archive::closeArchivedFile() { - resetArchivedFile(); -} - - -uint32 Archive::size() const { - return (_file == true ? _fileEndOffset - _fileOffset : 0); -} - -uint32 Archive::pos() const { - return (_file == true ? _fileCursor - _fileOffset : 0 ); -} - -bool Archive::eos() const { - return (_file == true ? _fileCursor == _fileEndOffset : true ); -} - -void Archive::seek(int32 offs, int whence) { - assert(_file == true && _fileCursor <= _fileEndOffset); - - switch (whence) { - case SEEK_CUR: - _fileCursor += offs; - break; - case SEEK_SET: - _fileCursor = _fileOffset + offs; - break; - case SEEK_END: - _fileCursor = _fileEndOffset - offs; - break; - } - assert(_fileCursor <= _fileEndOffset && _fileCursor >= _fileOffset); - - _archive.seek(_fileCursor, SEEK_SET); -} - -uint32 Archive::read(void *dataPtr, uint32 dataSize) { -// printf("read(%i, %i)\n", file->_cursor, file->_endOffset); - if (_file == false) - error("Archive::read: no archived file is currently open"); - - if (_fileCursor >= _fileEndOffset) - error("can't read beyond end of archived file"); - - if (_fileEndOffset - _fileCursor < dataSize) - dataSize = _fileEndOffset - _fileCursor; - - int32 readBytes = _archive.read(dataPtr, dataSize); - _fileCursor += readBytes; - - return readBytes; -} - - - -} // namespace Parallaction diff --git a/engines/parallaction/disk.cpp b/engines/parallaction/disk.cpp index 4070f41e1c..c972827dc6 100644 --- a/engines/parallaction/disk.cpp +++ b/engines/parallaction/disk.cpp @@ -37,6 +37,181 @@ namespace Audio { namespace Parallaction { + +// HACK: Several archives ('de', 'en', 'fr' and 'disk0') in the multi-lingual +// Amiga version of Nippon Safes, and one archive ('fr') in the Amiga Demo of +// Nippon Safes used different internal offsets than all the other archives. +// +// When an archive is opened in the Amiga demo, its size is checked against +// SIZEOF_SMALL_ARCHIVE to detect when the smaller archive is used. +// +// When an archive is opened in Amiga multi-lingual version, the header is +// checked again NDOS to detect when a smaller archive is used. +// +#define SIZEOF_SMALL_ARCHIVE 12778 + +#define ARCHIVE_FILENAMES_OFS 0x16 + +#define NORMAL_ARCHIVE_FILES_NUM 384 +#define SMALL_ARCHIVE_FILES_NUM 180 + +#define NORMAL_ARCHIVE_SIZES_OFS 0x3016 +#define SMALL_ARCHIVE_SIZES_OFS 0x1696 + +#define NORMAL_ARCHIVE_DATA_OFS 0x4000 +#define SMALL_ARCHIVE_DATA_OFS 0x1966 + +Archive::Archive() { + resetArchivedFile(); +} + +void Archive::open(const char *file) { + debugC(1, kDebugDisk, "Archive::open(%s)", file); + + if (_archive.isOpen()) + close(); + + char path[PATH_LEN]; + + strcpy(path, file); + if (!_archive.open(path)) + error("archive '%s' not found", path); + + _archiveName = file; + + bool isSmallArchive = false; + if (_vm->getPlatform() == Common::kPlatformAmiga) { + if (_vm->getFeatures() & GF_DEMO) { + isSmallArchive = _archive.size() == SIZEOF_SMALL_ARCHIVE; + } else if (_vm->getFeatures() & GF_LANG_MULT) { + isSmallArchive = (_archive.readUint32BE() != MKID_BE('NDOS')); + } + } + + _numFiles = (isSmallArchive) ? SMALL_ARCHIVE_FILES_NUM : NORMAL_ARCHIVE_FILES_NUM; + + _archive.seek(ARCHIVE_FILENAMES_OFS); + _archive.read(_archiveDir, _numFiles*32); + + _archive.seek((isSmallArchive) ? SMALL_ARCHIVE_SIZES_OFS : NORMAL_ARCHIVE_SIZES_OFS); + + uint32 dataOffset = (isSmallArchive) ? SMALL_ARCHIVE_DATA_OFS : NORMAL_ARCHIVE_DATA_OFS; + for (uint16 i = 0; i < _numFiles; i++) { + _archiveOffsets[i] = dataOffset; + _archiveLenghts[i] = _archive.readUint32BE(); + dataOffset += _archiveLenghts[i]; + } + + return; +} + + +void Archive::close() { + if (!_archive.isOpen()) return; + + resetArchivedFile(); + + _archive.close(); + _archiveName.clear(); +} + +Common::String Archive::name() const { + return _archiveName; +} + +bool Archive::openArchivedFile(const char *filename) { + debugC(3, kDebugDisk, "Archive::openArchivedFile(%s)", filename); + + resetArchivedFile(); + + debugC(3, kDebugDisk, "Archive::openArchivedFile(%s)", filename); + + if (!_archive.isOpen()) + error("Archive::openArchivedFile: the archive is not open"); + + uint16 i = 0; + for ( ; i < _numFiles; i++) { + if (!scumm_stricmp(_archiveDir[i], filename)) break; + } + if (i == _numFiles) return false; + + debugC(9, kDebugDisk, "Archive::openArchivedFile: '%s' found in slot %i", filename, i); + + _file = true; + + _fileOffset = _archiveOffsets[i]; + _fileCursor = _archiveOffsets[i]; + _fileEndOffset = _archiveOffsets[i] + _archiveLenghts[i]; + + _archive.seek(_fileOffset); + + return true; +} + +void Archive::resetArchivedFile() { + _file = false; + _fileCursor = 0; + _fileOffset = 0; + _fileEndOffset = 0; +} + +void Archive::closeArchivedFile() { + resetArchivedFile(); +} + + +uint32 Archive::size() const { + return (_file == true ? _fileEndOffset - _fileOffset : 0); +} + +uint32 Archive::pos() const { + return (_file == true ? _fileCursor - _fileOffset : 0 ); +} + +bool Archive::eos() const { + return (_file == true ? _fileCursor == _fileEndOffset : true ); +} + +void Archive::seek(int32 offs, int whence) { + assert(_file == true && _fileCursor <= _fileEndOffset); + + switch (whence) { + case SEEK_CUR: + _fileCursor += offs; + break; + case SEEK_SET: + _fileCursor = _fileOffset + offs; + break; + case SEEK_END: + _fileCursor = _fileEndOffset - offs; + break; + } + assert(_fileCursor <= _fileEndOffset && _fileCursor >= _fileOffset); + + _archive.seek(_fileCursor, SEEK_SET); +} + +uint32 Archive::read(void *dataPtr, uint32 dataSize) { +// printf("read(%i, %i)\n", file->_cursor, file->_endOffset); + if (_file == false) + error("Archive::read: no archived file is currently open"); + + if (_fileCursor >= _fileEndOffset) + error("can't read beyond end of archived file"); + + if (_fileEndOffset - _fileCursor < dataSize) + dataSize = _fileEndOffset - _fileCursor; + + int32 readBytes = _archive.read(dataPtr, dataSize); + _fileCursor += readBytes; + + return readBytes; +} + + + + + /* This stream class is just a wrapper around Archive, so deallocation is not a problem. In fact, this class doesn't diff --git a/engines/parallaction/module.mk b/engines/parallaction/module.mk index 592c0cb6a3..97741673a3 100644 --- a/engines/parallaction/module.mk +++ b/engines/parallaction/module.mk @@ -2,7 +2,6 @@ MODULE := engines/parallaction MODULE_OBJS := \ animation.o \ - archive.o \ callables.o \ commands.o \ debug.o \ -- cgit v1.2.3 From f04c56fb69b08e435b6906646bd910f589bf8c71 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 27 Jul 2007 00:11:36 +0000 Subject: The meta resource table is now properly initialized for the IHNM demo. The starting chapter is also set correctly svn-id: r28222 --- engines/saga/rscfile.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/saga/rscfile.cpp b/engines/saga/rscfile.cpp index 39224b032b..318d8b71b7 100644 --- a/engines/saga/rscfile.cpp +++ b/engines/saga/rscfile.cpp @@ -555,10 +555,15 @@ void Resource::loadResource(ResourceContext *context, uint32 resourceId, byte*&r } static int metaResourceTable[] = { 0, 326, 517, 677, 805, 968, 1165, 0, 1271 }; +static int metaResourceTableDemo[] = { 0, 0, 0, 0, 0, 0, 0, 285, 0 }; void Resource::loadGlobalResources(int chapter, int actorsEntrance) { - if (chapter < 0) - chapter = 8; + if (chapter < 0) { + if (_vm->getGameId() != GID_IHNM_DEMO) + chapter = 8; + else + chapter = 7; + } // TODO //if (module.voiceLUT) @@ -583,8 +588,13 @@ void Resource::loadGlobalResources(int chapter, int actorsEntrance) { byte *resourcePointer; size_t resourceLength; - _vm->_resource->loadResource(resourceContext, metaResourceTable[chapter], - resourcePointer, resourceLength); + if (_vm->getGameId() != GID_IHNM_DEMO) { + _vm->_resource->loadResource(resourceContext, metaResourceTable[chapter], + resourcePointer, resourceLength); + } else { + _vm->_resource->loadResource(resourceContext, metaResourceTableDemo[chapter], + resourcePointer, resourceLength); + } if (resourceLength == 0) { error("Resource::loadGlobalResources wrong metaResource"); -- cgit v1.2.3 From 6dd6ea5fc7d34e207dbcaaec1cb9463635fa8a6a Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 27 Jul 2007 00:25:06 +0000 Subject: Fixed some MSVC8 warnings svn-id: r28225 --- engines/drascula/drascula.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp index e800e0ef02..ff3b49f46d 100644 --- a/engines/drascula/drascula.cpp +++ b/engines/drascula/drascula.cpp @@ -3767,7 +3767,8 @@ void DrasculaEngine::Des_OFF(char *BufferOFF, char *MiVideoOFF, int Lenght) { } void DrasculaEngine::Des_RLE(char *BufferRLE, char *MiVideoRLE) { - unsigned int con, X = 0; + signed int con = 0; + unsigned int X = 0; unsigned int fExit = 0; char ch, rep; while (!fExit) { @@ -3811,7 +3812,8 @@ int DrasculaEngine::chkkey() { } char *DrasculaEngine::carga_pcx(char *NamePcc) { - unsigned int con, X = 0; + signed int con = 0; + unsigned int X = 0; unsigned int fExit = 0; char ch, rep; char *AuxPun; -- cgit v1.2.3 From 533ebe13d2f552bd7d06c04d10e9a20c8033a1ff Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 27 Jul 2007 00:59:12 +0000 Subject: Fix for bug #1761530 - "COMI: iMUSE-related crash on startup" svn-id: r28226 --- engines/scumm/imuse_digi/dimuse_sndmgr.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/scumm/imuse_digi/dimuse_sndmgr.cpp b/engines/scumm/imuse_digi/dimuse_sndmgr.cpp index c66209b42e..acc6593347 100644 --- a/engines/scumm/imuse_digi/dimuse_sndmgr.cpp +++ b/engines/scumm/imuse_digi/dimuse_sndmgr.cpp @@ -619,13 +619,12 @@ int32 ImuseDigiSndMgr::getDataFromRegion(SoundDesc *soundDesc, int region, byte if (len) error("Vorbis library compiled support needed!"); #endif - assert(len); soundMode = 2; } if (!len) { sprintf(fileName, "%s_reg%03d.mp3", soundDesc->name, region); cmpFile = soundDesc->bundle->getFile(fileName, offs, len); -#ifndef USE_VORBIS +#ifndef USE_MAD if (len) error("Mad library compiled support needed!"); #endif -- cgit v1.2.3 From de29c28483567c84c9b875f8b12202797985d74f Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Fri, 27 Jul 2007 01:33:05 +0000 Subject: Only set soundMode, if compressed segment exists. svn-id: r28227 --- engines/scumm/imuse_digi/dimuse_sndmgr.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'engines') diff --git a/engines/scumm/imuse_digi/dimuse_sndmgr.cpp b/engines/scumm/imuse_digi/dimuse_sndmgr.cpp index acc6593347..625a24ef81 100644 --- a/engines/scumm/imuse_digi/dimuse_sndmgr.cpp +++ b/engines/scumm/imuse_digi/dimuse_sndmgr.cpp @@ -615,22 +615,24 @@ int32 ImuseDigiSndMgr::getDataFromRegion(SoundDesc *soundDesc, int region, byte if (!len) { sprintf(fileName, "%s_reg%03d.ogg", soundDesc->name, region); cmpFile = soundDesc->bundle->getFile(fileName, offs, len); + if (len) { #ifndef USE_VORBIS - if (len) error("Vorbis library compiled support needed!"); #endif - soundMode = 2; + soundMode = 2; + } } if (!len) { sprintf(fileName, "%s_reg%03d.mp3", soundDesc->name, region); cmpFile = soundDesc->bundle->getFile(fileName, offs, len); + if (len) { #ifndef USE_MAD - if (len) error("Mad library compiled support needed!"); #endif - assert(len); - soundMode = 1; + soundMode = 1; + } } + assert(len); if (!soundDesc->compressedStream) { Common::MemoryReadStream *tmp = cmpFile->readStream(len); -- cgit v1.2.3 From d6b08fc7514ec6c857613756a7d05f31648ffbcf Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Fri, 27 Jul 2007 01:41:58 +0000 Subject: - AJWorld has Adlib - Fixing languages for one version of Woodruff svn-id: r28228 --- engines/gob/detection.cpp | 56 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/gob/detection.cpp b/engines/gob/detection.cpp index f793dbaca5..07c6b380f0 100644 --- a/engines/gob/detection.cpp +++ b/engines/gob/detection.cpp @@ -823,7 +823,7 @@ static const GOBGameDescription gameDescriptions[] = { Common::ADGF_NO_FLAGS }, kGameTypeGob2, - kFeaturesNone, + kFeaturesAdlib, "intro" }, { @@ -1095,7 +1095,59 @@ static const GOBGameDescription gameDescriptions[] = { "woodruff", "", AD_ENTRY1s("intro.stk", "dccf9d31cb720b34d75487408821b77e", 20296390), - UNK_LANG, + EN_GRB, + kPlatformPC, + Common::ADGF_NO_FLAGS + }, + kGameTypeWoodruff, + kFeatures640, + "intro" + }, + { + { + "woodruff", + "", + AD_ENTRY1s("intro.stk", "dccf9d31cb720b34d75487408821b77e", 20296390), + DE_DEU, + kPlatformPC, + Common::ADGF_NO_FLAGS + }, + kGameTypeWoodruff, + kFeatures640, + "intro" + }, + { + { + "woodruff", + "", + AD_ENTRY1s("intro.stk", "dccf9d31cb720b34d75487408821b77e", 20296390), + FR_FRA, + kPlatformPC, + Common::ADGF_NO_FLAGS + }, + kGameTypeWoodruff, + kFeatures640, + "intro" + }, + { + { + "woodruff", + "", + AD_ENTRY1s("intro.stk", "dccf9d31cb720b34d75487408821b77e", 20296390), + IT_ITA, + kPlatformPC, + Common::ADGF_NO_FLAGS + }, + kGameTypeWoodruff, + kFeatures640, + "intro" + }, + { + { + "woodruff", + "", + AD_ENTRY1s("intro.stk", "dccf9d31cb720b34d75487408821b77e", 20296390), + ES_ESP, kPlatformPC, Common::ADGF_NO_FLAGS }, -- cgit v1.2.3 From 178bf76aae147a2a78ff8165dece9afb71ddc876 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 27 Jul 2007 01:59:23 +0000 Subject: The p2_a.iaf file should now be played correctly with the English DOS CD and Floppy versions of ITE. Should fix bug #1751344 - "ITE: p2_a.iaf not played correctly" svn-id: r28229 --- engines/saga/detection_tables.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/saga/detection_tables.h b/engines/saga/detection_tables.h index 75d45e4bb6..4483cbb7ed 100644 --- a/engines/saga/detection_tables.h +++ b/engines/saga/detection_tables.h @@ -606,8 +606,8 @@ static const SAGAGameDescription gameDescriptions[] = { &ITECD_GameSound, &ITECD_GameSound, &ITEMACCD_GameMusic, // note: this version did not originally have digital music - 0, - NULL, + ARRAYSIZE(ITEPatch_Files), + ITEPatch_Files, }, // Inherit the earth - DOS CD German version @@ -697,8 +697,8 @@ static const SAGAGameDescription gameDescriptions[] = { &ITEDISK_GameSound, &ITEDISK_GameSound, &ITEMACCD_GameMusic, // note: this version did not originally have digital music - 0, - NULL, + ARRAYSIZE(ITEPatch_Files), + ITEPatch_Files, }, // IHNM Section /////////////////////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 548a1394e1c3279b7674ac8ab7d8b3206f19e787 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Fri, 27 Jul 2007 04:23:22 +0000 Subject: The strrev() function is non-standard. Replace with public domain version by Bob Stout. (It would of course have been trivial to write my own, but Bob's version does it in place, which is quite magical.) svn-id: r28230 --- engines/drascula/drascula.cpp | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'engines') diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp index ff3b49f46d..f83e52f893 100644 --- a/engines/drascula/drascula.cpp +++ b/engines/drascula/drascula.cpp @@ -2048,8 +2048,8 @@ void DrasculaEngine::color_abc(int cl) { palJuego[254][3] = 0; } else if (cl == 7) { palJuego[254][0] = 0x38; - palJuego[254][1] = 0; - palJuego[254][2] = 0; + palJuego[254][1] = 0; + palJuego[254][2] = 0; palJuego[254][3] = 0; } else if (cl == 8) { palJuego[254][0] = 0x3F; @@ -2080,6 +2080,22 @@ char DrasculaEngine::LimitaVGA(char valor) { return (valor & 0x3F) * (valor > 0); } +// Public domain strrev() function by Bob Stout. +// Should perhaps be moved to common/util.cpp or similar. + +static char *scumm_strrev(char *str) { + char *p1, *p2; + + if (!str || !*str) + return str; + for (p1 = str, p2 = str + strlen(str) - 1; p2 > p1; ++p1, --p2) { + *p1 ^= *p2; + *p2 ^= *p1; + *p1 ^= *p2; + } + return str; +} + void DrasculaEngine::centra_texto(char mensaje[], int x_texto, int y_texto) { char bb[190], m2[190], m1[190] ,mb[10][40]; char m3[190]; @@ -2111,12 +2127,12 @@ void DrasculaEngine::centra_texto(char mensaje[], int x_texto, int y_texto) { tut: strcpy(bb, m1); - strrev(bb); + scumm_strrev(bb); if (x_texto1 < x_texto2) { strcpy(m3, strrchr(m1, ' ')); strcpy(m1, strstr(bb, " ")); - strrev(m1); + scumm_strrev(m1); m1[strlen(m1) - 1] = '\0'; strcat(m3, m2); strcpy(m2, m3); @@ -2129,9 +2145,9 @@ tut: if (!strcmp(m2, "")) goto imprimir; - strrev(m2); + scumm_strrev(m2); m2[strlen(m2) - 1] = '\0'; - strrev(m2); + scumm_strrev(m2); strcpy(m1, m2); strcpy(m2, ""); conta_f++; -- cgit v1.2.3 From c2516db9ac72c835cd72bafee35bff1743bda81e Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Fri, 27 Jul 2007 05:15:24 +0000 Subject: Early in the morning, strrev() looks like a more difficult problem than it really is. It's actually quite simple. In fact, the only magical thing about Bob's version was the way it swapped variables without using any temporary variable. Rewrote the function to use our SWAP() instead, since that actually makes it readable. Moved it to util.cpp (outside the Common namespace, for consistency with scumm_stricmp()) since Kirben knew of other places where it could be used. svn-id: r28231 --- engines/drascula/drascula.cpp | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) (limited to 'engines') diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp index f83e52f893..cff57d0ab5 100644 --- a/engines/drascula/drascula.cpp +++ b/engines/drascula/drascula.cpp @@ -18,7 +18,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $UR$ + * $URL$ * $Id$ * */ @@ -29,6 +29,7 @@ #include "common/file.h" #include "common/savefile.h" #include "common/config-manager.h" +//#include "common/util.h" #include "base/plugins.h" #include "base/version.h" @@ -2080,22 +2081,6 @@ char DrasculaEngine::LimitaVGA(char valor) { return (valor & 0x3F) * (valor > 0); } -// Public domain strrev() function by Bob Stout. -// Should perhaps be moved to common/util.cpp or similar. - -static char *scumm_strrev(char *str) { - char *p1, *p2; - - if (!str || !*str) - return str; - for (p1 = str, p2 = str + strlen(str) - 1; p2 > p1; ++p1, --p2) { - *p1 ^= *p2; - *p2 ^= *p1; - *p1 ^= *p2; - } - return str; -} - void DrasculaEngine::centra_texto(char mensaje[], int x_texto, int y_texto) { char bb[190], m2[190], m1[190] ,mb[10][40]; char m3[190]; -- cgit v1.2.3 From 7dcd3c5ee43e394238f662a1b228276179906004 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Fri, 27 Jul 2007 05:23:34 +0000 Subject: Removed leftover commented-out include. (I thought I needed util.h, but I guess it's included indirectly.) svn-id: r28232 --- engines/drascula/drascula.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'engines') diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp index cff57d0ab5..69fc8cd26e 100644 --- a/engines/drascula/drascula.cpp +++ b/engines/drascula/drascula.cpp @@ -29,7 +29,6 @@ #include "common/file.h" #include "common/savefile.h" #include "common/config-manager.h" -//#include "common/util.h" #include "base/plugins.h" #include "base/version.h" -- cgit v1.2.3 From 3ca5bb8689c4765679827077b5b42d8782c716eb Mon Sep 17 00:00:00 2001 From: Paweł Kołodziejski Date: Fri, 27 Jul 2007 07:10:45 +0000 Subject: commented out some parts of code which still need to work, because it of non-english chars in it svn-id: r28233 --- engines/drascula/drascula.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'engines') diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp index 69fc8cd26e..44e27758f2 100644 --- a/engines/drascula/drascula.cpp +++ b/engines/drascula/drascula.cpp @@ -1710,7 +1710,7 @@ void DrasculaEngine::print_abc(char dicho[], int x_pantalla, int y_pantalla) { for (h = 0; h < longitud; h++) { y_de_letra = Y_ABC; - +/* if (dicho[h] == 'A') x_de_letra = X_A; else if (dicho[h] == 'B') @@ -1901,7 +1901,7 @@ void DrasculaEngine::print_abc(char dicho[], int x_pantalla, int y_pantalla) { else if (dicho[h] == '') x_de_letra = X_GN; } - +*/ pos_texto[0] = x_de_letra; pos_texto[1] = y_de_letra; pos_texto[2] = x_pantalla; @@ -3492,7 +3492,7 @@ void DrasculaEngine::introduce_nombre() { VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); key = getscan(); if (key != 0) { - if (key == 16) +/* if (key == 16) select2[v] = 'q'; else if (key == 17) select2[v] = 'w'; @@ -3578,7 +3578,7 @@ void DrasculaEngine::introduce_nombre() { select2[v] = '\0'; else v--; - +*/ if (key == 0x0E) v--; else @@ -4240,7 +4240,7 @@ void DrasculaEngine::conversa(char nom_fich[]) { canal_p(para_codificar); longitud = strlen(frase1); - for (h = 0; h < longitud; h++) +/* for (h = 0; h < longitud; h++) if (frase1[h] == '') frase1[h] = ' '; @@ -4258,7 +4258,7 @@ void DrasculaEngine::conversa(char nom_fich[]) { for (h = 0; h < longitud; h++) if (frase4[h] == '') frase4[h] = ' '; - +*/ lee_dibujos("car.alg"); descomprime_dibujo(dir_hare_fondo,1); /* TODO @@ -4443,7 +4443,7 @@ void DrasculaEngine::print_abc_opc(char dicho[],int x_pantalla, int y_pantalla, y_de_letra = Y_ABC_OPC_2; y_de_signos = Y_SIGNOS_OPC_2; } - +/* if (dicho[h] == 'A') x_de_letra = X_A_OPC; else if (dicho[h] == '') @@ -4597,7 +4597,7 @@ void DrasculaEngine::print_abc_opc(char dicho[],int x_pantalla, int y_pantalla, x_de_letra = X_N9_OPC; else if (dicho[h] == '0') x_de_letra = X_N0_OPC; - +*/ pos_texto[0] = x_de_letra; pos_texto[1] = y_de_letra; pos_texto[2] = x_pantalla; -- cgit v1.2.3 From 00cc7958ff29e8cce04b97e8dcbd6421908c980d Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Fri, 27 Jul 2007 11:54:50 +0000 Subject: Fix loading restart state file in Amiga version of Waxworks. svn-id: r28234 --- engines/agos/saveload.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/agos/saveload.cpp b/engines/agos/saveload.cpp index 32b767073a..44fc35d6ac 100644 --- a/engines/agos/saveload.cpp +++ b/engines/agos/saveload.cpp @@ -1173,7 +1173,7 @@ bool AGOSEngine_Elvira2::loadGame(const char *filename, bool restartMode) { addTimeEvent(timeout, subroutine_id); } - if (getGameType() == GType_WW) { + if (getGameType() == GType_WW && getPlatform() == Common::kPlatformPC) { // TODO Load room state data for (uint s = 0; s <= _numRoomStates; s++) { f->readUint16BE(); @@ -1185,7 +1185,8 @@ bool AGOSEngine_Elvira2::loadGame(const char *filename, bool restartMode) { for (num = _itemArrayInited - 1; num; num--) { Item *item = _itemArrayPtr[item_index++], *parent_item; - if (getGameType() == GType_ELVIRA2) { + if ((getGameType() == GType_WW && getPlatform() == Common::kPlatformAmiga) || + getGameType() == GType_ELVIRA2) { parent_item = derefItem(readItemID(f)); setItemParent(item, parent_item); } else { -- cgit v1.2.3 From e27e8875f67551ab7812d55dc989f91efc2fe4b5 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 27 Jul 2007 12:59:41 +0000 Subject: AGI game strings which are substituted in game texts may contain values as well, so use agiSprintf on them to substitute any values they may contain. Fixes bug #1760541 - "PQ1: Text output garbled" svn-id: r28235 --- engines/agi/text.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/agi/text.cpp b/engines/agi/text.cpp index 560e9b6f34..1d653a9415 100644 --- a/engines/agi/text.cpp +++ b/engines/agi/text.cpp @@ -555,7 +555,7 @@ char *AgiEngine::agiSprintf(const char *s) { break; case 's': i = strtoul(s, NULL, 10); - safeStrcat(p, _game.strings[i]); + safeStrcat(p, agiSprintf(_game.strings[i])); break; case 'm': i = strtoul(s, NULL, 10) - 1; -- cgit v1.2.3 From 806a0d9f0a900b7c9dcf80173ecc02fffe4f6e90 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Fri, 27 Jul 2007 13:02:43 +0000 Subject: Fixing languages for another Woodruff version svn-id: r28236 --- engines/gob/detection.cpp | 54 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/gob/detection.cpp b/engines/gob/detection.cpp index 07c6b380f0..48b2a62dd4 100644 --- a/engines/gob/detection.cpp +++ b/engines/gob/detection.cpp @@ -1160,7 +1160,59 @@ static const GOBGameDescription gameDescriptions[] = { "woodruff", "", AD_ENTRY1s("intro.stk", "b50fee012a5abcd0ac2963e1b4b56bec", 20298108), - EN_USA, + EN_GRB, + kPlatformPC, + Common::ADGF_NO_FLAGS + }, + kGameTypeWoodruff, + kFeatures640, + "intro" + }, + { + { + "woodruff", + "", + AD_ENTRY1s("intro.stk", "b50fee012a5abcd0ac2963e1b4b56bec", 20298108), + DE_DEU, + kPlatformPC, + Common::ADGF_NO_FLAGS + }, + kGameTypeWoodruff, + kFeatures640, + "intro" + }, + { + { + "woodruff", + "", + AD_ENTRY1s("intro.stk", "b50fee012a5abcd0ac2963e1b4b56bec", 20298108), + FR_FRA, + kPlatformPC, + Common::ADGF_NO_FLAGS + }, + kGameTypeWoodruff, + kFeatures640, + "intro" + }, + { + { + "woodruff", + "", + AD_ENTRY1s("intro.stk", "b50fee012a5abcd0ac2963e1b4b56bec", 20298108), + IT_ITA, + kPlatformPC, + Common::ADGF_NO_FLAGS + }, + kGameTypeWoodruff, + kFeatures640, + "intro" + }, + { + { + "woodruff", + "", + AD_ENTRY1s("intro.stk", "b50fee012a5abcd0ac2963e1b4b56bec", 20298108), + ES_ESP, kPlatformPC, Common::ADGF_NO_FLAGS }, -- cgit v1.2.3 From d8e4d70b674ef2fc86300d01a1827b215c6abc6c Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Fri, 27 Jul 2007 13:05:24 +0000 Subject: The language fallback now prefers the other english if USA or GRB was requested but wasn't found in the game data. svn-id: r28237 --- engines/gob/game.cpp | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) (limited to 'engines') diff --git a/engines/gob/game.cpp b/engines/gob/game.cpp index a5993fd1de..e47dc1809f 100644 --- a/engines/gob/game.cpp +++ b/engines/gob/game.cpp @@ -672,18 +672,39 @@ byte *Game::loadLocTexts(int32 *dataSize) { handle = openLocTextFile(locTextFile, _vm->_global->_languageWanted); if (handle >= 0) { + _foundTotLoc = true; _vm->_global->_language = _vm->_global->_languageWanted; - } - else if (!_foundTotLoc) { - for (i = 0; i < 10; i++) { - handle = openLocTextFile(locTextFile, i); + + } else if (!_foundTotLoc) { + bool found = false; + + if (_vm->_global->_languageWanted == 2) { + handle = openLocTextFile(locTextFile, 5); + if (handle >= 0) { + _vm->_global->_language = 5; + found = true; + } + } else if (_vm->_global->_languageWanted == 5) { + handle = openLocTextFile(locTextFile, 2); if (handle >= 0) { - _vm->_global->_language = i; - break; + _vm->_global->_language = 2; + found = true; } } + + if (!found) { + for (i = 0; i < 10; i++) { + handle = openLocTextFile(locTextFile, i); + if (handle >= 0) { + _vm->_global->_language = i; + break; + } + } + } + } + debugC(1, kDebugFileIO, "Using language %d for %s", _vm->_global->_language, _curTotFile); -- cgit v1.2.3 From e22e47c398556e60a1c9e28faf4a82e9f83ad3a8 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Fri, 27 Jul 2007 16:23:06 +0000 Subject: Clarifying the language fallback warnings svn-id: r28238 --- engines/gob/gob.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/gob/gob.cpp b/engines/gob/gob.cpp index c996b5e8d3..9a14194972 100644 --- a/engines/gob/gob.cpp +++ b/engines/gob/gob.cpp @@ -121,9 +121,16 @@ void GobEngine::shutdown() { void GobEngine::validateLanguage() { if (_vm->_global->_languageWanted != _vm->_global->_language) { - warning("Your game version doesn't support the requested language"); - warning("Using the first language available: %s", - getLangDesc(_vm->_global->_language)); + warning("Your game version doesn't support the requested language %s", + getLangDesc(_vm->_global->_languageWanted)); + + if (((_vm->_global->_languageWanted == 2) && (_vm->_global->_language == 5)) || + ((_vm->_global->_languageWanted == 5) && (_vm->_global->_language == 2))) + warning("Using %s instead", getLangDesc(_vm->_global->_language)); + else + warning("Using the first language available: %s", + getLangDesc(_vm->_global->_language)); + _vm->_global->_languageWanted = _vm->_global->_language; } } -- cgit v1.2.3 From a0d956221cc6bc7ffeccc3f2ce7ae8c0c5d31f22 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 27 Jul 2007 16:39:21 +0000 Subject: Defined the starting scene for the IHNM demo svn-id: r28239 --- engines/saga/detection_tables.h | 2 +- engines/saga/sagaresnames.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/saga/detection_tables.h b/engines/saga/detection_tables.h index 4483cbb7ed..a304fb906a 100644 --- a/engines/saga/detection_tables.h +++ b/engines/saga/detection_tables.h @@ -722,7 +722,7 @@ static const SAGAGameDescription gameDescriptions[] = { GType_IHNM, GID_IHNM_DEMO, 0, - 0, + IHNMDEMO_DEFAULT_SCENE, &IHNMDEMO_Resources, ARRAYSIZE(IHNMDEMO_GameFonts), IHNMDEMO_GameFonts, diff --git a/engines/saga/sagaresnames.h b/engines/saga/sagaresnames.h index 3fd0332eb2..4b4d546514 100644 --- a/engines/saga/sagaresnames.h +++ b/engines/saga/sagaresnames.h @@ -68,6 +68,7 @@ namespace Saga { #define IHNM_DEFAULT_SCENE 151 #define ITEDEMO_DEFAULT_SCENE 68 +#define IHNMDEMO_DEFAULT_SCENE 144 // FONTS #define RID_MEDIUM_FONT 0 -- cgit v1.2.3 From 65cb1d8d42a6108a95c9af492366102af08416b5 Mon Sep 17 00:00:00 2001 From: Paweł Kołodziejski Date: Fri, 27 Jul 2007 16:56:42 +0000 Subject: fixed warning svn-id: r28240 --- engines/drascula/drascula.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'engines') diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp index 44e27758f2..c57419270b 100644 --- a/engines/drascula/drascula.cpp +++ b/engines/drascula/drascula.cpp @@ -4197,7 +4197,6 @@ void DrasculaEngine::pantalla_63(int fl) { } void DrasculaEngine::conversa(char nom_fich[]) { - int h; int juego1 = 1, juego2 = 1, juego3 = 1, juego4 = 1; char frase1[78]; char frase2[78]; -- cgit v1.2.3 From fc3570d00083345ac376f67e0558fc548e2e2f89 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Fri, 27 Jul 2007 17:24:22 +0000 Subject: Fixed a bunch of warnings. svn-id: r28241 --- engines/drascula/drascula.cpp | 14 +++++++------- engines/drascula/drascula.h | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) (limited to 'engines') diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp index c57419270b..260745f737 100644 --- a/engines/drascula/drascula.cpp +++ b/engines/drascula/drascula.cpp @@ -239,7 +239,7 @@ void DrasculaEngine::carga_info() { hay_que_load = 0; } -void DrasculaEngine::lee_dibujos(char *NamePcc) { +void DrasculaEngine::lee_dibujos(const char *NamePcc) { unsigned int con, x = 0; unsigned int fExit = 0; unsigned char ch,rep; @@ -2080,7 +2080,7 @@ char DrasculaEngine::LimitaVGA(char valor) { return (valor & 0x3F) * (valor > 0); } -void DrasculaEngine::centra_texto(char mensaje[], int x_texto, int y_texto) { +void DrasculaEngine::centra_texto(const char *mensaje, int x_texto, int y_texto) { char bb[190], m2[190], m1[190] ,mb[10][40]; char m3[190]; int h, fil, x_texto3, x_texto2, x_texto1, conta_f = 0, ya = 0; @@ -2711,7 +2711,7 @@ bucless: VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); } -void DrasculaEngine::habla_tabernero(char dicho[], char filename[]) { +void DrasculaEngine::habla_tabernero(const char *dicho, const char *filename) { int tiempou; long tiempol; @@ -2887,7 +2887,7 @@ bucless: VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); } -void DrasculaEngine::hablar(char dicho[], char filename[]) { +void DrasculaEngine::hablar(const char *dicho, const char *filename) { int tiempou; long tiempol; @@ -4196,7 +4196,7 @@ void DrasculaEngine::pantalla_63(int fl) { hay_respuesta = 0; } -void DrasculaEngine::conversa(char nom_fich[]) { +void DrasculaEngine::conversa(const char *nom_fich) { int juego1 = 1, juego2 = 1, juego3 = 1, juego4 = 1; char frase1[78]; char frase2[78]; @@ -4619,7 +4619,7 @@ void DrasculaEngine::responde(int funcion) { habla_borracho(TEXTB3, "B3.als"); } -void DrasculaEngine::habla_pianista(char dicho[], char filename[]) { +void DrasculaEngine::habla_pianista(const char *dicho, const char *filename) { int tiempou; long tiempol; int x_habla[4] = { 97, 145, 193, 241}; @@ -4684,7 +4684,7 @@ bucless: VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); } -void DrasculaEngine::habla_borracho(char dicho[], char filename[]) { +void DrasculaEngine::habla_borracho(const char *dicho, const char *filename) { int tiempou; long tiempol; diff --git a/engines/drascula/drascula.h b/engines/drascula/drascula.h index 889fc3ffd0..cb7b51bf94 100644 --- a/engines/drascula/drascula.h +++ b/engines/drascula/drascula.h @@ -351,7 +351,7 @@ public: void carga_info(); void salir_al_dos(int r); - void lee_dibujos(char *); + void lee_dibujos(const char *); void descomprime_dibujo(char *dir_escritura, int plt); typedef unsigned char DacPalette256[256][4]; @@ -498,7 +498,7 @@ public: void FundeDelNegro(int VelocidadDeFundido); char LimitaVGA(char valor); void color_abc(int cl); - void centra_texto(char[],int,int); + void centra_texto(const char *,int,int); void comienza_sound(char[]); void anima(char animacion[], int FPS); void fin_sound_corte(); @@ -513,11 +513,11 @@ public: void habla_dr_izq(char dicho[], char filename[]); void habla_solo(char[], char[]); void habla_igor_frente(char[], char[]); - void habla_tabernero(char dicho[], char filename[]); + void habla_tabernero(const char *dicho, const char *filename); void hipo(int); void fin_sound(); void habla_bj(char[], char[]); - void hablar(char[], char[]); + void hablar(const char *, const char *); void playmusic(int p); void stopmusic(); int music_status(); @@ -598,13 +598,13 @@ public: void pantalla_0(); void pantalla_62(int); void pantalla_63(int); - void conversa(char []); + void conversa(const char *); void animacion_3(); void animacion_4(); void print_abc_opc(char[], int, int, int); void responde(int); - void habla_borracho(char dicho[], char filename[]); - void habla_pianista(char dicho[], char filename[]); + void habla_borracho(const char *dicho, const char *filename); + void habla_pianista(const char *dicho, const char *filename); void MusicFadeout(); void ctvd_end(); -- cgit v1.2.3 From 6f3d59b2fcfceb16ae30a6a388b5ace451b0248a Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Fri, 27 Jul 2007 17:50:25 +0000 Subject: Disabled another bunch of warnings. This turned up two places - print_abc_opc() and print_abc() - where we would try to modify a string constant. I have disabled this for now, and added FIXME comments. svn-id: r28242 --- engines/drascula/drascula.cpp | 38 ++++++++++++++++++++++---------------- engines/drascula/drascula.h | 32 ++++++++++++++++---------------- 2 files changed, 38 insertions(+), 32 deletions(-) (limited to 'engines') diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp index 260745f737..f6fa296a1c 100644 --- a/engines/drascula/drascula.cpp +++ b/engines/drascula/drascula.cpp @@ -1180,7 +1180,7 @@ void DrasculaEngine::para_cargar(char nom_game[]) { sin_verbo(); } -void DrasculaEngine::carga_escoba(char nom_fich[13]) { +void DrasculaEngine::carga_escoba(const char *nom_fich) { int l, obj_salir; float chiquez, pequegnez = 0; char para_codificar[13]; @@ -1700,13 +1700,16 @@ void DrasculaEngine::saves() { hay_seleccion = 0; } -void DrasculaEngine::print_abc(char dicho[], int x_pantalla, int y_pantalla) { +void DrasculaEngine::print_abc(const char *dicho, int x_pantalla, int y_pantalla) { int pos_texto[8]; int i, y_de_letra = 0, x_de_letra = 0, h, longitud; longitud = strlen(dicho); + // FIXME: We can't do this on read-only strings! +#if 0 for (i = 0; dicho[i]; i++) dicho[i] = toupper(dicho[i]); +#endif for (h = 0; h < longitud; h++) { y_de_letra = Y_ABC; @@ -1988,7 +1991,7 @@ void DrasculaEngine::salva_pantallas() { descomprime_dibujo(dir_dibujo1, MEDIA); } -void DrasculaEngine::fliplay(char filefli[], int vel) { +void DrasculaEngine::fliplay(const char *filefli, int vel) { return; // TODO OpenSSN(filefli, vel); @@ -2149,7 +2152,7 @@ imprimir: } } -void DrasculaEngine::comienza_sound(char fichero[]) { +void DrasculaEngine::comienza_sound(const char *fichero) { if (hay_sb == 1) { if ((sku = fopen(fichero, "rb")) == NULL) { error("no puedo abrir archivo de voz"); @@ -2160,7 +2163,7 @@ void DrasculaEngine::comienza_sound(char fichero[]) { ctvd_output(sku); } -void DrasculaEngine::anima(char animacion[], int FPS) { +void DrasculaEngine::anima(const char *animacion, int FPS) { Common::File FileIn; unsigned Org = 0, Des = 0, j, TotDes = 0; int NFrames = 1, New = 1; @@ -2251,7 +2254,7 @@ void DrasculaEngine::pausa(int cuanto) { } } -void DrasculaEngine::habla_dr_grande(char dicho[], char filename[]) { +void DrasculaEngine::habla_dr_grande(const char *dicho, const char *filename) { int tiempou; long tiempol; int x_habla[4] = {47, 93, 139, 185}; @@ -2364,7 +2367,7 @@ void DrasculaEngine::pon_bj() { DIBUJA_BLOQUE_CUT(pos_bj, dir_dibujo3, dir_zona_pantalla); } -void DrasculaEngine::habla_igor_dch(char dicho[], char filename[]) { +void DrasculaEngine::habla_igor_dch(const char *dicho, const char *filename) { int tiempou; long tiempol; @@ -2439,7 +2442,7 @@ bucless: VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); } -void DrasculaEngine::habla_dr_izq(char dicho[], char filename[]) { +void DrasculaEngine::habla_dr_izq(const char *dicho, const char *filename) { int tiempou; long tiempol; @@ -2514,7 +2517,7 @@ bucless: VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); } -void DrasculaEngine::habla_dr_dch(char dicho[], char filename[]) { +void DrasculaEngine::habla_dr_dch(const char *dicho, const char *filename) { int tiempou; long tiempol; @@ -2589,7 +2592,7 @@ bucless: VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); } -void DrasculaEngine::habla_solo(char dicho[], char filename[]) { +void DrasculaEngine::habla_solo(const char *dicho, const char *filename) { int tiempou; long tiempol; @@ -2636,7 +2639,7 @@ bucless: } } -void DrasculaEngine::habla_igor_frente(char dicho[], char filename[]) { +void DrasculaEngine::habla_igor_frente(const char *dicho, const char *filename) { int tiempou; long tiempol; @@ -2815,7 +2818,7 @@ void DrasculaEngine::fin_sound() { } } -void DrasculaEngine::habla_bj(char dicho[], char filename[]) { +void DrasculaEngine::habla_bj(const char *dicho, const char *filename) { int tiempou; long tiempol; @@ -3043,7 +3046,7 @@ void DrasculaEngine::refresca_pantalla() { actualiza_refresco(); } -void DrasculaEngine::carga_partida(char nom_game[]) { +void DrasculaEngine::carga_partida(const char *nom_game) { int l, n_ejec2; canal_p(nom_game); @@ -3078,7 +3081,7 @@ void DrasculaEngine::carga_partida(char nom_game[]) { canal_p(nom_game); } -void DrasculaEngine::canal_p(char fich[13]){ +void DrasculaEngine::canal_p(const char *fich){ Common::File ald2, ald3; char fich2[13]; @@ -3608,7 +3611,7 @@ int DrasculaEngine::LookForFree() { return 1; } -void DrasculaEngine::OpenSSN(char *Name, int Pause) { +void DrasculaEngine::OpenSSN(const char *Name, int Pause) { MiVideoSSN = (char *)malloc(64256); GlobalSpeed = CLOCKS_PER_SEC / Pause; FrameSSN = 0; @@ -4423,13 +4426,16 @@ void DrasculaEngine::animacion_4() { descomprime_dibujo(dir_hare_dch, 1); } -void DrasculaEngine::print_abc_opc(char dicho[],int x_pantalla, int y_pantalla, int juego) { +void DrasculaEngine::print_abc_opc(const char *dicho, int x_pantalla, int y_pantalla, int juego) { int pos_texto[6]; int i, y_de_signos, y_de_letra, x_de_letra = 0, h, longitud; longitud = strlen(dicho); + // FIXME: We can't do this on read-only strings! +#if 0 for (i = 0; dicho[i]; i++) dicho[i] = toupper(dicho[i]); +#endif for (h = 0; h < longitud; h++) { if (juego == 1) { diff --git a/engines/drascula/drascula.h b/engines/drascula/drascula.h index cb7b51bf94..e21f9a5f12 100644 --- a/engines/drascula/drascula.h +++ b/engines/drascula/drascula.h @@ -472,7 +472,7 @@ public: void animacion_2(); void sin_verbo(); void para_cargar(char[]); - void carga_escoba(char[]); + void carga_escoba(const char *); void borra_pantalla(); void lleva_al_hare(int, int); void mueve_cursor(); @@ -486,7 +486,7 @@ public: void elige_verbo(int); void mesa(); void saves(); - void print_abc(char[], int, int); + void print_abc(const char *, int, int); void delay(int ms); void confirma_go(); void confirma_salir(); @@ -494,36 +494,36 @@ public: void elige_objeto(int objeto); void suma_objeto(int); int resta_objeto(int osj); - void fliplay(char filefli[], int vel); + void fliplay(const char *filefli, int vel); void FundeDelNegro(int VelocidadDeFundido); char LimitaVGA(char valor); void color_abc(int cl); void centra_texto(const char *,int,int); - void comienza_sound(char[]); - void anima(char animacion[], int FPS); + void comienza_sound(const char *); + void anima(const char *animacion, int FPS); void fin_sound_corte(); void FundeAlNegro(int VelocidadDeFundido); void pausa(int); - void habla_dr_grande(char dicho[], char filename[]); + void habla_dr_grande(const char *dicho, const char *filename); void pon_igor(); void pon_bj(); void pon_dr(); - void habla_igor_dch(char dicho[], char filename[]); - void habla_dr_dch(char dicho[], char filename[]); - void habla_dr_izq(char dicho[], char filename[]); - void habla_solo(char[], char[]); - void habla_igor_frente(char[], char[]); + void habla_igor_dch(const char *dicho, const char *filename); + void habla_dr_dch(const char *dicho, const char *filename); + void habla_dr_izq(const char *dicho, const char *filename); + void habla_solo(const char *, const char *); + void habla_igor_frente(const char *, const char *); void habla_tabernero(const char *dicho, const char *filename); void hipo(int); void fin_sound(); - void habla_bj(char[], char[]); + void habla_bj(const char *, const char *); void hablar(const char *, const char *); void playmusic(int p); void stopmusic(); int music_status(); void refresca_pantalla(); - void carga_partida(char[]); - void canal_p(char[]); + void carga_partida(const char *); + void canal_p(const char *); void puertas_cerradas(int); void animafin_sound_corte(); void color_hare(); @@ -546,7 +546,7 @@ public: void introduce_nombre(); void para_grabar(char[]); int LookForFree(); - void OpenSSN(char *Name,int Pause); + void OpenSSN(const char *Name,int Pause); void WaitFrameSSN(); void MixVideo(char *OldScreen,char *NewScreen); void Des_RLE(char *BufferRLE, char *MiVideoRLE); @@ -601,7 +601,7 @@ public: void conversa(const char *); void animacion_3(); void animacion_4(); - void print_abc_opc(char[], int, int, int); + void print_abc_opc(const char *, int, int, int); void responde(int); void habla_borracho(const char *dicho, const char *filename); void habla_pianista(const char *dicho, const char *filename); -- cgit v1.2.3 From 9f5221d7b4be26289ff5ccf8bf95f5c7645185ba Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 27 Jul 2007 18:22:36 +0000 Subject: Fixed some warnings svn-id: r28243 --- engines/drascula/drascula.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp index f6fa296a1c..38ebd0e3a8 100644 --- a/engines/drascula/drascula.cpp +++ b/engines/drascula/drascula.cpp @@ -1702,7 +1702,7 @@ void DrasculaEngine::saves() { void DrasculaEngine::print_abc(const char *dicho, int x_pantalla, int y_pantalla) { int pos_texto[8]; - int i, y_de_letra = 0, x_de_letra = 0, h, longitud; + int i = 0, y_de_letra = 0, x_de_letra = 0, h, longitud; longitud = strlen(dicho); // FIXME: We can't do this on read-only strings! @@ -4428,7 +4428,7 @@ void DrasculaEngine::animacion_4() { void DrasculaEngine::print_abc_opc(const char *dicho, int x_pantalla, int y_pantalla, int juego) { int pos_texto[6]; - int i, y_de_signos, y_de_letra, x_de_letra = 0, h, longitud; + int i = 0, y_de_signos, y_de_letra, x_de_letra = 0, h, longitud; longitud = strlen(dicho); // FIXME: We can't do this on read-only strings! -- cgit v1.2.3 From f9b66f8816cc2157ddae17e180550171e5908d8d Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 27 Jul 2007 18:32:00 +0000 Subject: The IHNM demo only has one mouse cursor svn-id: r28244 --- engines/saga/events.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/saga/events.cpp b/engines/saga/events.cpp index b93c6017c7..73a603bf5c 100644 --- a/engines/saga/events.cpp +++ b/engines/saga/events.cpp @@ -460,12 +460,13 @@ int Events::handleOneShot(Event *event) { _vm->_gfx->showCursor(false); break; case kEventSetNormalCursor: - // in ITE there is just one cursor - if (_vm->getGameType() == GType_IHNM) + // in ITE and IHNM demo there is just one cursor + if (_vm->getGameType() == GType_IHNM && _vm->getGameId() != GID_IHNM_DEMO) _vm->_gfx->setCursor(kCursorNormal); break; case kEventSetBusyCursor: - if (_vm->getGameType() == GType_IHNM) + // in ITE and IHNM demo there is just one cursor + if (_vm->getGameType() == GType_IHNM && _vm->getGameId() != GID_IHNM_DEMO) _vm->_gfx->setCursor(kCursorBusy); break; default: -- cgit v1.2.3 From a32b81d126aee4644adc074b3b091a4c121e4f7c Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 27 Jul 2007 18:36:50 +0000 Subject: Do not try to load music if the music resource id is 0. Also, the voice LUT resource ID and the voice bank are now set correctly for the IHNM demo. The IHNM demo starts now, showing some scenes, but the main panel is not loaded correctly, the status line is shown incorrectly and the demo crashes after a cutaway is shown svn-id: r28245 --- engines/saga/rscfile.cpp | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'engines') diff --git a/engines/saga/rscfile.cpp b/engines/saga/rscfile.cpp index 318d8b71b7..3063e8a9a6 100644 --- a/engines/saga/rscfile.cpp +++ b/engines/saga/rscfile.cpp @@ -683,22 +683,24 @@ void Resource::loadGlobalResources(int chapter, int actorsEntrance) { _vm->_anim->loadCutawayList(resourcePointer, resourceLength); - _vm->_resource->loadResource(resourceContext, _metaResource.songTableID, resourcePointer, resourceLength); + if (_metaResource.songTableID > 0) { + _vm->_resource->loadResource(resourceContext, _metaResource.songTableID, resourcePointer, resourceLength); - if (resourceLength == 0) { - error("Resource::loadGlobalResources Can't load songs list for current track"); - } + if (resourceLength == 0) { + error("Resource::loadGlobalResources Can't load songs list for current track"); + } - free(_vm->_music->_songTable); - - _vm->_music->_songTableLen = resourceLength / 4; - _vm->_music->_songTable = (int32 *)malloc(sizeof(int32) * _vm->_music->_songTableLen); + free(_vm->_music->_songTable); + + _vm->_music->_songTableLen = resourceLength / 4; + _vm->_music->_songTable = (int32 *)malloc(sizeof(int32) * _vm->_music->_songTableLen); - MemoryReadStream songS(resourcePointer, resourceLength); + MemoryReadStream songS(resourcePointer, resourceLength); - for (i = 0; i < _vm->_music->_songTableLen; i++) - _vm->_music->_songTable[i] = songS.readSint32LE(); - free(resourcePointer); + for (i = 0; i < _vm->_music->_songTableLen; i++) + _vm->_music->_songTable[i] = songS.readSint32LE(); + free(resourcePointer); + } int voiceLUTResourceID = 0; @@ -730,6 +732,9 @@ void Resource::loadGlobalResources(int chapter, int actorsEntrance) { voiceLUTResourceID = 28; break; case 7: + // IHNM demo + _vm->_sndRes->setVoiceBank(0); + voiceLUTResourceID = 17; break; case 8: _vm->_sndRes->setVoiceBank(0); -- cgit v1.2.3 From 67869d2c10234479949bd74abc42931a019264e6 Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Fri, 27 Jul 2007 19:02:19 +0000 Subject: - Moved disk code for Nippon Safes in new file disk_ns.cpp, adding _ns suffix to classes and member functions. - Added function stubs into new file disk_br.cpp for Big Red Adventure [IT STILL CRASHES!]. - Modified engine to create the proper Disk manager object. svn-id: r28246 --- engines/parallaction/disk.cpp | 1441 -------------------------------- engines/parallaction/disk.h | 118 ++- engines/parallaction/disk_br.cpp | 134 +++ engines/parallaction/disk_ns.cpp | 1443 +++++++++++++++++++++++++++++++++ engines/parallaction/font.cpp | 4 +- engines/parallaction/module.mk | 3 +- engines/parallaction/parallaction.cpp | 27 +- engines/parallaction/walk.cpp | 2 +- 8 files changed, 1674 insertions(+), 1498 deletions(-) delete mode 100644 engines/parallaction/disk.cpp create mode 100644 engines/parallaction/disk_br.cpp create mode 100644 engines/parallaction/disk_ns.cpp (limited to 'engines') diff --git a/engines/parallaction/disk.cpp b/engines/parallaction/disk.cpp deleted file mode 100644 index c972827dc6..0000000000 --- a/engines/parallaction/disk.cpp +++ /dev/null @@ -1,1441 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -#include "common/stdafx.h" - -#include "graphics/iff.h" -#include "graphics/surface.h" - -#include "parallaction/parallaction.h" - - -namespace Audio { - AudioStream *make8SVXStream(Common::ReadStream &input); -} - -namespace Parallaction { - - -// HACK: Several archives ('de', 'en', 'fr' and 'disk0') in the multi-lingual -// Amiga version of Nippon Safes, and one archive ('fr') in the Amiga Demo of -// Nippon Safes used different internal offsets than all the other archives. -// -// When an archive is opened in the Amiga demo, its size is checked against -// SIZEOF_SMALL_ARCHIVE to detect when the smaller archive is used. -// -// When an archive is opened in Amiga multi-lingual version, the header is -// checked again NDOS to detect when a smaller archive is used. -// -#define SIZEOF_SMALL_ARCHIVE 12778 - -#define ARCHIVE_FILENAMES_OFS 0x16 - -#define NORMAL_ARCHIVE_FILES_NUM 384 -#define SMALL_ARCHIVE_FILES_NUM 180 - -#define NORMAL_ARCHIVE_SIZES_OFS 0x3016 -#define SMALL_ARCHIVE_SIZES_OFS 0x1696 - -#define NORMAL_ARCHIVE_DATA_OFS 0x4000 -#define SMALL_ARCHIVE_DATA_OFS 0x1966 - -Archive::Archive() { - resetArchivedFile(); -} - -void Archive::open(const char *file) { - debugC(1, kDebugDisk, "Archive::open(%s)", file); - - if (_archive.isOpen()) - close(); - - char path[PATH_LEN]; - - strcpy(path, file); - if (!_archive.open(path)) - error("archive '%s' not found", path); - - _archiveName = file; - - bool isSmallArchive = false; - if (_vm->getPlatform() == Common::kPlatformAmiga) { - if (_vm->getFeatures() & GF_DEMO) { - isSmallArchive = _archive.size() == SIZEOF_SMALL_ARCHIVE; - } else if (_vm->getFeatures() & GF_LANG_MULT) { - isSmallArchive = (_archive.readUint32BE() != MKID_BE('NDOS')); - } - } - - _numFiles = (isSmallArchive) ? SMALL_ARCHIVE_FILES_NUM : NORMAL_ARCHIVE_FILES_NUM; - - _archive.seek(ARCHIVE_FILENAMES_OFS); - _archive.read(_archiveDir, _numFiles*32); - - _archive.seek((isSmallArchive) ? SMALL_ARCHIVE_SIZES_OFS : NORMAL_ARCHIVE_SIZES_OFS); - - uint32 dataOffset = (isSmallArchive) ? SMALL_ARCHIVE_DATA_OFS : NORMAL_ARCHIVE_DATA_OFS; - for (uint16 i = 0; i < _numFiles; i++) { - _archiveOffsets[i] = dataOffset; - _archiveLenghts[i] = _archive.readUint32BE(); - dataOffset += _archiveLenghts[i]; - } - - return; -} - - -void Archive::close() { - if (!_archive.isOpen()) return; - - resetArchivedFile(); - - _archive.close(); - _archiveName.clear(); -} - -Common::String Archive::name() const { - return _archiveName; -} - -bool Archive::openArchivedFile(const char *filename) { - debugC(3, kDebugDisk, "Archive::openArchivedFile(%s)", filename); - - resetArchivedFile(); - - debugC(3, kDebugDisk, "Archive::openArchivedFile(%s)", filename); - - if (!_archive.isOpen()) - error("Archive::openArchivedFile: the archive is not open"); - - uint16 i = 0; - for ( ; i < _numFiles; i++) { - if (!scumm_stricmp(_archiveDir[i], filename)) break; - } - if (i == _numFiles) return false; - - debugC(9, kDebugDisk, "Archive::openArchivedFile: '%s' found in slot %i", filename, i); - - _file = true; - - _fileOffset = _archiveOffsets[i]; - _fileCursor = _archiveOffsets[i]; - _fileEndOffset = _archiveOffsets[i] + _archiveLenghts[i]; - - _archive.seek(_fileOffset); - - return true; -} - -void Archive::resetArchivedFile() { - _file = false; - _fileCursor = 0; - _fileOffset = 0; - _fileEndOffset = 0; -} - -void Archive::closeArchivedFile() { - resetArchivedFile(); -} - - -uint32 Archive::size() const { - return (_file == true ? _fileEndOffset - _fileOffset : 0); -} - -uint32 Archive::pos() const { - return (_file == true ? _fileCursor - _fileOffset : 0 ); -} - -bool Archive::eos() const { - return (_file == true ? _fileCursor == _fileEndOffset : true ); -} - -void Archive::seek(int32 offs, int whence) { - assert(_file == true && _fileCursor <= _fileEndOffset); - - switch (whence) { - case SEEK_CUR: - _fileCursor += offs; - break; - case SEEK_SET: - _fileCursor = _fileOffset + offs; - break; - case SEEK_END: - _fileCursor = _fileEndOffset - offs; - break; - } - assert(_fileCursor <= _fileEndOffset && _fileCursor >= _fileOffset); - - _archive.seek(_fileCursor, SEEK_SET); -} - -uint32 Archive::read(void *dataPtr, uint32 dataSize) { -// printf("read(%i, %i)\n", file->_cursor, file->_endOffset); - if (_file == false) - error("Archive::read: no archived file is currently open"); - - if (_fileCursor >= _fileEndOffset) - error("can't read beyond end of archived file"); - - if (_fileEndOffset - _fileCursor < dataSize) - dataSize = _fileEndOffset - _fileCursor; - - int32 readBytes = _archive.read(dataPtr, dataSize); - _fileCursor += readBytes; - - return readBytes; -} - - - - - -/* - This stream class is just a wrapper around Archive, so - deallocation is not a problem. In fact, this class doesn't - delete its input (Archive) stream. -*/ -class DummyArchiveStream : public Common::SeekableReadStream { - - Archive *_input; - -public: - DummyArchiveStream(Archive &input) : _input(&input) { - - } - - ~DummyArchiveStream() { - // this class exists to provide this empty destructor - } - - bool eos() const { - return _input->eos(); - } - - uint32 read(void* data, uint32 dataSize) { - return _input->read(data, dataSize); - } - - uint32 pos() const { - return _input->pos(); - } - - uint32 size() const { - return _input->size(); - } - - void seek(int32 offset, int whence) { - _input->seek(offset, whence); - } - -}; - - - -Disk::Disk(Parallaction *vm) : _vm(vm) { - -} - -Disk::~Disk() { - -} - -void Disk::errorFileNotFound(const char *s) { - error("File '%s' not found", s); -} - - -Common::String Disk::selectArchive(const Common::String& name) { - Common::String oldName = _resArchive.name(); - _resArchive.open(name.c_str()); - return oldName; -} - -void Disk::setLanguage(uint16 language) { - debugC(1, kDebugDisk, "setLanguage(%i)", language); - - switch (language) { - case 0: - strcpy(_languageDir, "it/"); - break; - - case 1: - strcpy(_languageDir, "fr/"); - break; - - case 2: - strcpy(_languageDir, "en/"); - break; - - case 3: - strcpy(_languageDir, "ge/"); - break; - - default: - error("unknown language"); - - } - - _languageDir[2] = '\0'; - _locArchive.open(_languageDir); - _languageDir[2] = '/'; - - return; -} - -#pragma mark - - - - -DosDisk::DosDisk(Parallaction* vm) : Disk(vm) { - -} - -DosDisk::~DosDisk() { -} - - -// -// loads a cnv from an external file -// -Cnv* DosDisk::loadExternalCnv(const char *filename) { -// printf("Gfx::loadExternalCnv(%s)...", filename); - - char path[PATH_LEN]; - - sprintf(path, "%s.cnv", filename); - - Common::File stream; - - if (!stream.open(path)) - errorFileNotFound(path); - - uint16 numFrames = stream.readByte(); - uint16 width = stream.readByte(); - uint16 height = stream.readByte(); - - uint32 decsize = numFrames * width * height; - byte *data = (byte*)malloc(decsize); - stream.read(data, decsize); - - return new Cnv(numFrames, width, height, data); -} - -StaticCnv *DosDisk::loadExternalStaticCnv(const char *filename) { - - char path[PATH_LEN]; - - sprintf(path, "%s.cnv", filename); - - Common::File stream; - - if (!stream.open(path)) - errorFileNotFound(path); - - StaticCnv *cnv = new StaticCnv; - - stream.skip(1); - cnv->_width = stream.readByte(); - cnv->_height = stream.readByte(); - - uint16 size = cnv->_width*cnv->_height; - - cnv->_data0 = (byte*)malloc(size); - stream.read(cnv->_data0, size); - - return cnv; -} - -Cnv* DosDisk::loadCnv(const char *filename) { -// printf("Gfx::loadCnv(%s)\n", filename); - - char path[PATH_LEN]; - - strcpy(path, filename); - if (!_resArchive.openArchivedFile(path)) { - sprintf(path, "%s.pp", filename); - if (!_resArchive.openArchivedFile(path)) - errorFileNotFound(path); - } - - uint16 numFrames = _resArchive.readByte(); - uint16 width = _resArchive.readByte(); - uint16 height = _resArchive.readByte(); - - uint32 decsize = numFrames * width * height; - byte *data = (byte*)malloc(decsize); - - Graphics::PackBitsReadStream decoder(_resArchive); - decoder.read(data, decsize); - - return new Cnv(numFrames, width, height, data); -} - -Cnv* DosDisk::loadTalk(const char *name) { - - const char *ext = strstr(name, ".talk"); - if (ext != NULL) { - // npc talk - return loadCnv(name); - - } - - // character talk - char v20[PATH_LEN]; - char *v24 = const_cast(name); - if (IS_MINI_CHARACTER(v24)) { - v24+=4; - } - - if (_engineFlags & kEngineTransformedDonna) { - sprintf(v20, "%stta", v24); - } else { - sprintf(v20, "%stal", v24); - } - - return loadExternalCnv(v20); -} - -Script* DosDisk::loadLocation(const char *name) { - - char archivefile[PATH_LEN]; - - if (IS_MINI_CHARACTER(_vm->_characterName)) { - sprintf(archivefile, "%s%s", _vm->_characterName+4, _languageDir); - } else { - if (IS_DUMMY_CHARACTER(_vm->_characterName)) { - strcpy(archivefile, _languageDir); - } else { - sprintf(archivefile, "%s%s", _vm->_characterName, _languageDir); - } - } - - strcat(archivefile, name); - strcat(archivefile, ".loc"); - - debugC(3, kDebugDisk, "DosDisk::loadLocation(%s): trying '%s'", name, archivefile); - - if (!_locArchive.openArchivedFile(archivefile)) { - sprintf(archivefile, "%s%s.loc", _languageDir, name); - debugC(3, kDebugDisk, "DosDisk::loadLocation(%s): trying '%s'", name, archivefile); - - if (!_locArchive.openArchivedFile(archivefile)) - errorFileNotFound(name); - } - - return new Script(new DummyArchiveStream(_locArchive), true); -} - -Script* DosDisk::loadScript(const char* name) { - - char vC8[PATH_LEN]; - - sprintf(vC8, "%s.script", name); - - if (!_resArchive.openArchivedFile(vC8)) - errorFileNotFound(vC8); - - return new Script(new DummyArchiveStream(_resArchive), true); -} - -StaticCnv* DosDisk::loadHead(const char* name) { - - char path[PATH_LEN]; - - if (IS_MINI_CHARACTER(name)) { - name += 4; - } - - sprintf(path, "%shead", name); - path[8] = '\0'; - - return loadExternalStaticCnv(path); -} - - -StaticCnv* DosDisk::loadPointer() { - return loadExternalStaticCnv("pointer"); -} - - -Font* DosDisk::loadFont(const char* name) { - char path[PATH_LEN]; - sprintf(path, "%scnv", name); - return createFont(name, loadExternalCnv(path)); -} - - -Cnv* DosDisk::loadObjects(const char *name) { - - if (IS_MINI_CHARACTER(name)) { - name += 4; - } - - char path[PATH_LEN]; - sprintf(path, "%sobj", name); - return loadExternalCnv(path); -} - - -StaticCnv* DosDisk::loadStatic(const char* name) { - - char path[PATH_LEN]; - - strcpy(path, name); - if (!_resArchive.openArchivedFile(path)) { - sprintf(path, "%s.pp", name); - if (!_resArchive.openArchivedFile(path)) - errorFileNotFound(path); - } - - StaticCnv* cnv = new StaticCnv; - - _resArchive.skip(1); - cnv->_width = _resArchive.readByte(); - cnv->_height = _resArchive.readByte(); - - uint16 size = cnv->_width*cnv->_height; - cnv->_data0 = (byte*)malloc(size); - - Graphics::PackBitsReadStream decoder(_resArchive); - decoder.read(cnv->_data0, size); - - return cnv; -} - -Cnv* DosDisk::loadFrames(const char* name) { - return loadCnv(name); -} - -// -// slides (background images) are stored compressed by scanline in a rle fashion -// -// the uncompressed data must then be unpacked to get: -// * color data [bits 0-5] -// * mask data [bits 6-7] (z buffer) -// * path data [bit 8] (walkable areas) -// -void DosDisk::unpackBackground(Common::ReadStream *stream, byte *screen, byte *mask, byte *path) { - - byte b; - uint32 i = 0; - - while (!stream->eos()) { - b = stream->readByte(); - - path[i/8] |= ((b & 0x80) >> 7) << (i & 7); - mask[i/4] |= ((b & 0x60) >> 5) << ((i & 3) << 1); - screen[i] = b & 0x1F; - i++; - } - - return; -} - - -void DosDisk::parseDepths(Common::SeekableReadStream &stream) { - _vm->_gfx->_bgLayers[0] = stream.readByte(); - _vm->_gfx->_bgLayers[1] = stream.readByte(); - _vm->_gfx->_bgLayers[2] = stream.readByte(); - _vm->_gfx->_bgLayers[3] = stream.readByte(); -} - - -void DosDisk::parseBackground(Common::SeekableReadStream &stream) { - - stream.read(_vm->_gfx->_palette, BASE_PALETTE_SIZE); - _vm->_gfx->setPalette(_vm->_gfx->_palette); - - parseDepths(stream); - - for (uint32 _si = 0; _si < 6; _si++) { - _vm->_gfx->_palettefx[_si]._timer = stream.readUint16BE(); - _vm->_gfx->_palettefx[_si]._step = stream.readUint16BE(); - _vm->_gfx->_palettefx[_si]._flags = stream.readUint16BE(); - _vm->_gfx->_palettefx[_si]._first = stream.readByte(); - _vm->_gfx->_palettefx[_si]._last = stream.readByte(); - } - -} - -void DosDisk::loadBackground(const char *filename) { - - if (!_resArchive.openArchivedFile(filename)) - errorFileNotFound(filename); - - parseBackground(_resArchive); - - byte *bg = (byte*)calloc(1, _vm->_screenSize); - byte *mask = (byte*)calloc(1, _vm->_screenMaskSize); - byte *path = (byte*)calloc(1, _vm->_screenPathSize); - - - Graphics::PackBitsReadStream stream(_resArchive); - unpackBackground(&stream, bg, mask, path); - - _vm->_gfx->setBackground(bg); - _vm->_gfx->setMask(mask); - _vm->setPath(path); - - free(bg); - free(mask); - free(path); - - return; -} - -// -// read background path and mask from a file -// -// mask and path are normally combined (via OR) into the background picture itself -// read the comment on the top of this file for more -// -void DosDisk::loadMaskAndPath(const char *name) { - char path[PATH_LEN]; - sprintf(path, "%s.msk", name); - - if (!_resArchive.openArchivedFile(path)) - errorFileNotFound(name); - - byte *maskBuf = (byte*)calloc(1, _vm->_screenMaskSize); - byte *pathBuf = (byte*)calloc(1, _vm->_screenPathSize); - - parseDepths(_resArchive); - - _resArchive.read(pathBuf, _vm->_screenPathSize); - _resArchive.read(maskBuf, _vm->_screenMaskSize); - - _vm->_gfx->setMask(maskBuf); - _vm->setPath(pathBuf); - - return; -} - -void DosDisk::loadSlide(const char *filename) { - char path[PATH_LEN]; - sprintf(path, "%s.slide", filename); - loadBackground(path); -} - -void DosDisk::loadScenery(const char *name, const char *mask) { - char path[PATH_LEN]; - sprintf(path, "%s.dyn", name); - loadBackground(path); - - if (mask != NULL) { - // load external masks and paths only for certain locations - loadMaskAndPath(mask); - } - -} - -Table* DosDisk::loadTable(const char* name) { - char path[PATH_LEN]; - sprintf(path, "%s.tab", name); - - Common::File stream; - if (!stream.open(path)) - errorFileNotFound(path); - - Table *t = new Table(100); - - fillBuffers(stream); - while (scumm_stricmp(_tokens[0], "ENDTABLE")) { - t->addData(_tokens[0]); - fillBuffers(stream); - } - - stream.close(); - - return t; -} - -Common::ReadStream* DosDisk::loadMusic(const char* name) { - char path[PATH_LEN]; - sprintf(path, "%s.mid", name); - - Common::File *stream = new Common::File; - if (!stream->open(path)) - errorFileNotFound(path); - - return stream; -} - - -Common::ReadStream* DosDisk::loadSound(const char* name) { - return NULL; -} - - - - - - -#pragma mark - - - -/* the decoder presented here is taken from pplib by Stuart Caie. The - * following statement comes from the original source. - * - * pplib 1.0: a simple PowerPacker decompression and decryption library - * placed in the Public Domain on 2003-09-18 by Stuart Caie. - */ - -#define PP_READ_BITS(nbits, var) do { \ - bit_cnt = (nbits); (var) = 0; \ - while (bits_left < bit_cnt) { \ - if (buf < src) return 0; \ - bit_buffer |= *--buf << bits_left; \ - bits_left += 8; \ - } \ - bits_left -= bit_cnt; \ - while (bit_cnt--) { \ - (var) = ((var) << 1) | (bit_buffer & 1); \ - bit_buffer >>= 1; \ - } \ -} while (0) - -#define PP_BYTE_OUT(byte) do { \ - if (out <= dest) return 0; \ - *--out = (byte); written++; \ -} while (0) - - -class PowerPackerStream : public Common::SeekableReadStream { - - SeekableReadStream *_stream; - bool _dispose; - -private: - int ppDecrunchBuffer(byte *src, byte *dest, uint32 src_len, uint32 dest_len) { - - byte *buf, *out, *dest_end, *off_lens, bits_left = 0, bit_cnt; - uint32 bit_buffer = 0, x, todo, offbits, offset, written = 0; - - if (src == NULL || dest == NULL) return 0; - - /* set up input and output pointers */ - off_lens = src; src = &src[4]; - buf = &src[src_len]; - - out = dest_end = &dest[dest_len]; - - /* skip the first few bits */ - PP_READ_BITS(src[src_len + 3], x); - - /* while there are input bits left */ - while (written < dest_len) { - PP_READ_BITS(1, x); - if (x == 0) { - /* bit==0: literal, then match. bit==1: just match */ - todo = 1; do { PP_READ_BITS(2, x); todo += x; } while (x == 3); - while (todo--) { PP_READ_BITS(8, x); PP_BYTE_OUT(x); } - - /* should we end decoding on a literal, break out of the main loop */ - if (written == dest_len) break; - } - - /* match: read 2 bits for initial offset bitlength / match length */ - PP_READ_BITS(2, x); - offbits = off_lens[x]; - todo = x+2; - if (x == 3) { - PP_READ_BITS(1, x); - if (x == 0) offbits = 7; - PP_READ_BITS(offbits, offset); - do { PP_READ_BITS(3, x); todo += x; } while (x == 7); - } - else { - PP_READ_BITS(offbits, offset); - } - if (&out[offset] >= dest_end) return 0; /* match_overflow */ - while (todo--) { x = out[offset]; PP_BYTE_OUT(x); } - } - - /* all output bytes written without error */ - return 1; - } - - uint16 getCrunchType(uint32 signature) { - - byte eff; - - switch (signature) { - case 0x50503230: /* PP20 */ - eff = 4; - break; - case 0x50504C53: /* PPLS */ - error("PPLS crunched files are not supported"); - eff = 8; - break; - case 0x50583230: /* PX20 */ - error("PX20 crunched files are not supported"); - eff = 6; - break; - default: - eff = 0; - - } - - return eff; - } - -public: - PowerPackerStream(Common::SeekableReadStream &stream) { - - _dispose = false; - - uint32 signature = stream.readUint32BE(); - if (getCrunchType(signature) == 0) { - stream.seek(0, SEEK_SET); - _stream = &stream; - return; - } - - stream.seek(4, SEEK_END); - uint32 decrlen = stream.readUint32BE() >> 8; - byte *dest = (byte*)malloc(decrlen); - - uint32 crlen = stream.size() - 4; - byte *src = (byte*)malloc(crlen); - stream.seek(4, SEEK_SET); - stream.read(src, crlen); - - ppDecrunchBuffer(src, dest, crlen-8, decrlen); - - free(src); - _stream = new Common::MemoryReadStream(dest, decrlen, true); - _dispose = true; - } - - ~PowerPackerStream() { - if (_dispose) delete _stream; - } - - uint32 size() const { - return _stream->size(); - } - - uint32 pos() const { - return _stream->pos(); - } - - bool eos() const { - return _stream->eos(); - } - - void seek(int32 offs, int whence = SEEK_SET) { - _stream->seek(offs, whence); - } - - uint32 read(void *dataPtr, uint32 dataSize) { - return _stream->read(dataPtr, dataSize); - } -}; - - - - - -AmigaDisk::AmigaDisk(Parallaction *vm) : Disk(vm) { - -} - - -AmigaDisk::~AmigaDisk() { - -} - -#define NUM_PLANES 5 - -/* - unpackFrame transforms images from 5-bitplanes format to - 8-bit color-index mode -*/ -void AmigaDisk::unpackFrame(byte *dst, byte *src, uint16 planeSize) { - - byte s0, s1, s2, s3, s4, mask, t0, t1, t2, t3, t4; - - for (uint32 j = 0; j < planeSize; j++) { - s0 = src[j]; - s1 = src[j+planeSize]; - s2 = src[j+planeSize*2]; - s3 = src[j+planeSize*3]; - s4 = src[j+planeSize*4]; - - for (uint32 k = 0; k < 8; k++) { - mask = 1 << (7 - k); - t0 = (s0 & mask ? 1 << 0 : 0); - t1 = (s1 & mask ? 1 << 1 : 0); - t2 = (s2 & mask ? 1 << 2 : 0); - t3 = (s3 & mask ? 1 << 3 : 0); - t4 = (s4 & mask ? 1 << 4 : 0); - *dst++ = t0 | t1 | t2 | t3 | t4; - } - - } - -} - -/* - patchFrame applies DLTA data (dlta) to specified buffer (dst) -*/ -void AmigaDisk::patchFrame(byte *dst, byte *dlta, uint16 bytesPerPlane, uint16 height) { - - uint32 *dataIndex = (uint32*)dlta; - uint32 *ofslenIndex = (uint32*)dlta + 8; - - uint16 *base = (uint16*)dlta; - uint16 wordsPerLine = bytesPerPlane >> 1; - - for (uint j = 0; j < NUM_PLANES; j++) { - uint16 *dst16 = (uint16*)(dst + j * bytesPerPlane * height); - - uint16 *data = base + READ_BE_UINT32(dataIndex); - dataIndex++; - uint16 *ofslen = base + READ_BE_UINT32(ofslenIndex); - ofslenIndex++; - - while (*ofslen != 0xFFFF) { - - uint16 ofs = READ_BE_UINT16(ofslen); - ofslen++; - uint16 size = READ_BE_UINT16(ofslen); - ofslen++; - - while (size > 0) { - dst16[ofs] ^= *data++; - ofs += wordsPerLine; - size--; - } - - } - - } - -} - -// FIXME: no mask is loaded -void AmigaDisk::unpackBitmap(byte *dst, byte *src, uint16 numFrames, uint16 bytesPerPlane, uint16 height) { - - byte *baseFrame = src; - byte *tempBuffer = 0; - - uint16 planeSize = bytesPerPlane * height; - - for (uint32 i = 0; i < numFrames; i++) { - if (READ_BE_UINT32(src) == MKID_BE('DLTA')) { - - uint size = READ_BE_UINT32(src + 4); - - if (tempBuffer == 0) - tempBuffer = (byte*)malloc(planeSize * NUM_PLANES); - - memcpy(tempBuffer, baseFrame, planeSize * NUM_PLANES); - - patchFrame(tempBuffer, src + 8, bytesPerPlane, height); - unpackFrame(dst, tempBuffer, planeSize); - - src += (size + 8); - dst += planeSize * 8; - } else { - unpackFrame(dst, src, planeSize); - src += planeSize * NUM_PLANES; - dst += planeSize * 8; - } - } - - if (tempBuffer) - free(tempBuffer); - -} - -StaticCnv* AmigaDisk::makeStaticCnv(Common::SeekableReadStream &stream) { - - stream.skip(1); - uint16 width = stream.readByte(); - uint16 height = stream.readByte(); - - assert((width & 7) == 0); - - byte bytesPerPlane = width / 8; - - uint32 rawsize = bytesPerPlane * NUM_PLANES * height; - byte *buf = (byte*)malloc(rawsize); - stream.read(buf, rawsize); - - uint32 decsize = width * height; - byte *data = (byte*)calloc(decsize, 1); - - unpackBitmap(data, buf, 1, bytesPerPlane, height); - - free(buf); - - StaticCnv *cnv = new StaticCnv(); - cnv->_width = width; - cnv->_height = height; - cnv->_data0 = data; - cnv->_data1 = NULL; - - return cnv; -} - -Cnv* AmigaDisk::makeCnv(Common::SeekableReadStream &stream) { - - uint16 numFrames = stream.readByte(); - uint16 width = stream.readByte(); - uint16 height = stream.readByte(); - - assert((width & 7) == 0); - - byte bytesPerPlane = width / 8; - - uint32 rawsize = numFrames * bytesPerPlane * NUM_PLANES * height; - byte *buf = (byte*)malloc(rawsize); - stream.read(buf, rawsize); - - uint32 decsize = numFrames * width * height; - byte *data = (byte*)calloc(decsize, 1); - - unpackBitmap(data, buf, numFrames, bytesPerPlane, height); - - free(buf); - - return new Cnv(numFrames, width, height, data); -} -#undef NUM_PLANES - -Script* AmigaDisk::loadLocation(const char *name) { - debugC(1, kDebugDisk, "AmigaDisk()::loadLocation '%s'", name); - - char path[PATH_LEN]; - if (IS_MINI_CHARACTER(_vm->_characterName)) { - sprintf(path, "%s%s%s.loc.pp", _vm->_characterName+4, _languageDir, name); - } else - sprintf(path, "%s%s%s.loc.pp", _vm->_characterName, _languageDir, name); - - if (!_locArchive.openArchivedFile(path)) { - sprintf(path, "%s%s.loc.pp", _languageDir, name); - if (!_locArchive.openArchivedFile(path)) { - errorFileNotFound(name); - } - } - - debugC(3, kDebugDisk, "location file found: %s", path); - - return new Script(new PowerPackerStream(_locArchive), true); -} - -Script* AmigaDisk::loadScript(const char* name) { - debugC(1, kDebugDisk, "AmigaDisk::loadScript '%s'", name); - - char vC8[PATH_LEN]; - - sprintf(vC8, "%s.script", name); - - if (!_resArchive.openArchivedFile(vC8)) - errorFileNotFound(vC8); - - return new Script(new DummyArchiveStream(_resArchive), true); -} - -StaticCnv* AmigaDisk::loadPointer() { - debugC(1, kDebugDisk, "AmigaDisk::loadPointer"); - - Common::File stream; - if (!stream.open("pointer")) - errorFileNotFound("pointer"); - - return makeStaticCnv(stream); -} - -StaticCnv* AmigaDisk::loadStatic(const char* name) { - debugC(1, kDebugDisk, "AmigaDisk::loadStatic '%s'", name); - - Common::SeekableReadStream *s = openArchivedFile(name, true); - StaticCnv *cnv = makeStaticCnv(*s); - - delete s; - - return cnv; -} - -Common::SeekableReadStream *AmigaDisk::openArchivedFile(const char* name, bool errorOnFileNotFound) { - debugC(3, kDebugDisk, "AmigaDisk::openArchivedFile(%s)", name); - - if (_resArchive.openArchivedFile(name)) { - return new DummyArchiveStream(_resArchive); - } - - char path[PATH_LEN]; - - sprintf(path, "%s.pp", name); - if (_resArchive.openArchivedFile(path)) { - return new PowerPackerStream(_resArchive); - } - - sprintf(path, "%s.dd", name); - if (_resArchive.openArchivedFile(path)) { - return new PowerPackerStream(_resArchive); - } - - if (errorOnFileNotFound) - errorFileNotFound(name); - - return NULL; -} - -/* - FIXME: mask values are not computed correctly for level 1 and 2 - - NOTE: this routine is only able to build masks for Nippon Safes, since mask widths are hardcoded - into the main loop. -*/ -void buildMask(byte* buf) { - - byte mask1[16] = { 0, 0x80, 0x20, 0xA0, 8, 0x88, 0x28, 0xA8, 2, 0x82, 0x22, 0xA2, 0xA, 0x8A, 0x2A, 0xAA }; - byte mask0[16] = { 0, 0x40, 0x10, 0x50, 4, 0x44, 0x14, 0x54, 1, 0x41, 0x11, 0x51, 0x5, 0x45, 0x15, 0x55 }; - - byte plane0[40]; - byte plane1[40]; - - for (int32 i = 0; i < _vm->_screenHeight; i++) { - - memcpy(plane0, buf, 40); - memcpy(plane1, buf+40, 40); - - for (uint32 j = 0; j < 40; j++) { - *buf++ = mask0[(plane0[j] & 0xF0) >> 4] | mask1[(plane1[j] & 0xF0) >> 4]; - *buf++ = mask0[plane0[j] & 0xF] | mask1[plane1[j] & 0xF]; - } - - } -} - -class BackgroundDecoder : public Graphics::ILBMDecoder { - - PaletteFxRange *_range; - uint32 _i; - -protected: - void readCRNG(Common::IFFChunk &chunk) { - _range[_i]._timer = chunk.readUint16BE(); - _range[_i]._step = chunk.readUint16BE(); - _range[_i]._flags = chunk.readUint16BE(); - _range[_i]._first = chunk.readByte(); - _range[_i]._last = chunk.readByte(); - - _i++; - } - -public: - BackgroundDecoder(Common::ReadStream &input, Graphics::Surface &surface, byte *&colors, PaletteFxRange *range) : - Graphics::ILBMDecoder(input, surface, colors), _range(range), _i(0) { - } - - void decode() { - Common::IFFChunk *chunk; - while ((chunk = nextChunk()) != 0) { - switch (chunk->id) { - case ID_BMHD: - readBMHD(*chunk); - break; - - case ID_CMAP: - readCMAP(*chunk); - break; - - case ID_BODY: - readBODY(*chunk); - break; - - case ID_CRNG: - readCRNG(*chunk); - break; - } - } - } - - uint32 getNumRanges() { - return _i; - } -}; - - -void AmigaDisk::loadBackground(const char *name) { - - Common::SeekableReadStream *s = openArchivedFile(name, true); - - Graphics::Surface surf; - byte *pal; - BackgroundDecoder decoder(*s, surf, pal, _vm->_gfx->_palettefx); - decoder.decode(); - - for (uint32 i = 0; i < BASE_PALETTE_COLORS * 3; i++) - _vm->_gfx->_palette[i] = pal[i] >> 2; - free(pal); - _vm->_gfx->setPalette(_vm->_gfx->_palette); - _vm->_gfx->setBackground(static_cast(surf.pixels)); - surf.free(); - delete s; - - return; - -} - -void AmigaDisk::loadMask(const char *name) { - - char path[PATH_LEN]; - sprintf(path, "%s.mask", name); - - Common::SeekableReadStream *s = openArchivedFile(path, false); - if (s == NULL) - return; // no errors if missing mask files: not every location has one - - s->seek(0x30, SEEK_SET); - - byte r, g, b; - for (uint i = 0; i < 4; i++) { - r = s->readByte(); - g = s->readByte(); - b = s->readByte(); - - _vm->_gfx->_bgLayers[i] = (((r << 4) & 0xF00) | (g & 0xF0) | (b >> 4)) & 0xFF; - -// printf("rgb = (%x, %x, %x) -> %x\n", r, g, b, _vm->_gfx->_bgLayers[i]); - } - - - s->seek(0x126, SEEK_SET); // HACK: skipping IFF/ILBM header should be done by analysis, not magic - Graphics::PackBitsReadStream stream(*s); - - byte *buf = (byte*)malloc(_vm->_screenMaskSize); - stream.read(buf, _vm->_screenMaskSize); - buildMask(buf); - _vm->_gfx->setMask(buf); - free(buf); - delete s; - - return; -} - -void AmigaDisk::loadPath(const char *name) { - - char path[PATH_LEN]; - sprintf(path, "%s.path", name); - - Common::SeekableReadStream *s = openArchivedFile(path, false); - if (s == NULL) - return; // no errors if missing path files: not every location has one - - - s->seek(0x120, SEEK_SET); // HACK: skipping IFF/ILBM header should be done by analysis, not magic - - Graphics::PackBitsReadStream stream(*s); - byte *buf = (byte*)malloc(_vm->_screenPathSize); - stream.read(buf, _vm->_screenPathSize); - _vm->setPath(buf); - free(buf); - delete s; - - return; -} - -void AmigaDisk::loadScenery(const char* background, const char* mask) { - debugC(1, kDebugDisk, "AmigaDisk::loadScenery '%s', '%s'", background, mask); - - char path[PATH_LEN]; - sprintf(path, "%s.bkgnd", background); - - loadBackground(path); - loadMask(background); - loadPath(background); - - return; -} - -void AmigaDisk::loadSlide(const char *name) { - debugC(1, kDebugDisk, "AmigaDisk::loadSlide '%s'", name); - - char path[PATH_LEN]; - sprintf(path, "slides/%s", name); - Common::SeekableReadStream *s = openArchivedFile(path, false); - if (s) - loadBackground(path); - else - loadBackground(name); - - return; -} - -Cnv* AmigaDisk::loadFrames(const char* name) { - debugC(1, kDebugDisk, "AmigaDisk::loadFrames '%s'", name); - - Common::SeekableReadStream *s; - - char path[PATH_LEN]; - sprintf(path, "anims/%s", name); - - s = openArchivedFile(path, false); - if (!s) - s = openArchivedFile(name, true); - - Cnv *cnv = makeCnv(*s); - delete s; - - return cnv; -} - -StaticCnv* AmigaDisk::loadHead(const char* name) { - debugC(1, kDebugDisk, "AmigaDisk::loadHead '%s'", name); - - char path[PATH_LEN]; - sprintf(path, "%s.head", name); - - Common::SeekableReadStream *s = openArchivedFile(path, true); - StaticCnv *cnv = makeStaticCnv(*s); - - delete s; - - return cnv; -} - - -Cnv* AmigaDisk::loadObjects(const char *name) { - debugC(1, kDebugDisk, "AmigaDisk::loadObjects"); - - char path[PATH_LEN]; - if (_vm->getFeatures() & GF_DEMO) - sprintf(path, "%s.objs", name); - else - sprintf(path, "objs/%s.objs", name); - - Common::SeekableReadStream *s = openArchivedFile(path, true); - - Cnv *cnv = makeCnv(*s); - delete s; - - return cnv; -} - - -Cnv* AmigaDisk::loadTalk(const char *name) { - debugC(1, kDebugDisk, "AmigaDisk::loadTalk '%s'", name); - - Common::SeekableReadStream *s; - - char path[PATH_LEN]; - if (_vm->getFeatures() & GF_DEMO) - sprintf(path, "%s.talk", name); - else - sprintf(path, "talk/%s.talk", name); - - s = openArchivedFile(path, false); - if (s == NULL) { - s = openArchivedFile(name, true); - } - - Cnv *cnv = makeCnv(*s); - delete s; - - return cnv; -} - -Table* AmigaDisk::loadTable(const char* name) { - debugC(1, kDebugDisk, "AmigaDisk::loadTable '%s'", name); - - char path[PATH_LEN]; - sprintf(path, "%s.table", name); - - bool dispose = false; - - Common::SeekableReadStream *stream; - - if (!scumm_stricmp(name, "global")) { - Common::File *s = new Common::File; - if (!s->open(path)) - errorFileNotFound(path); - - dispose = true; - stream = s; - } else { - if (!(_vm->getFeatures() & GF_DEMO)) - sprintf(path, "objs/%s.table", name); - if (!_resArchive.openArchivedFile(path)) - errorFileNotFound(path); - - stream = &_resArchive; - } - - Table *t = new Table(100); - - fillBuffers(*stream); - while (scumm_stricmp(_tokens[0], "ENDTABLE")) { - t->addData(_tokens[0]); - fillBuffers(*stream); - } - - if (dispose) - delete stream; - - return t; -} - -Font* AmigaDisk::loadFont(const char* name) { - debugC(1, kDebugDisk, "AmigaFullDisk::loadFont '%s'", name); - - char path[PATH_LEN]; - sprintf(path, "%sfont", name); - - if (_vm->getFeatures() & GF_LANG_IT) { - // Italian version has separate font files - Common::File stream; - if (!stream.open(path)) - errorFileNotFound(path); - - return createFont(name, stream); - } else { - if (!_resArchive.openArchivedFile(path)) - errorFileNotFound(path); - - return createFont(name, _resArchive); - } -} - - -Common::ReadStream* AmigaDisk::loadMusic(const char* name) { - return openArchivedFile(name); -} - -Common::ReadStream* AmigaDisk::loadSound(const char* name) { - char path[PATH_LEN]; - sprintf(path, "%s.snd", name); - - openArchivedFile(path); - - return new DummyArchiveStream(_resArchive); -} - -} // namespace Parallaction diff --git a/engines/parallaction/disk.h b/engines/parallaction/disk.h index 14ea4f0e16..d910201f27 100644 --- a/engines/parallaction/disk.h +++ b/engines/parallaction/disk.h @@ -29,19 +29,8 @@ #include "parallaction/defs.h" #include "common/file.h" -namespace Audio { - class AudioStream; -} - namespace Parallaction { -//------------------------------------------------------ -// ARCHIVE MANAGEMENT -//------------------------------------------------------ - - -#define MAX_ARCHIVE_ENTRIES 384 - class Table; class Parallaction; class Gfx; @@ -51,22 +40,49 @@ class Font; struct Cnv; struct StaticCnv; + +class Disk { + +public: + Disk() { } + virtual ~Disk() { } + + virtual Common::String selectArchive(const Common::String &name) = 0; + virtual void setLanguage(uint16 language) = 0; + + virtual Script* loadLocation(const char *name) = 0; + virtual Script* loadScript(const char* name) = 0; + virtual Cnv* loadTalk(const char *name) = 0; + virtual Cnv* loadObjects(const char *name) = 0; + virtual StaticCnv* loadPointer() = 0; + virtual StaticCnv* loadHead(const char* name) = 0; + virtual Font* loadFont(const char* name) = 0; + virtual StaticCnv* loadStatic(const char* name) = 0; + virtual Cnv* loadFrames(const char* name) = 0; + virtual void loadSlide(const char *filename) = 0; + virtual void loadScenery(const char* background, const char* mask) = 0; + virtual Table* loadTable(const char* name) = 0; + virtual Common::ReadStream* loadMusic(const char* name) = 0; + virtual Common::ReadStream* loadSound(const char* name) = 0; +}; + + + + +#define MAX_ARCHIVE_ENTRIES 384 + class Archive : public Common::SeekableReadStream { protected: - bool _file; uint32 _fileOffset; uint32 _fileCursor; uint32 _fileEndOffset; - Common::String _archiveName; char _archiveDir[MAX_ARCHIVE_ENTRIES][32]; uint32 _archiveLenghts[MAX_ARCHIVE_ENTRIES]; uint32 _archiveOffsets[MAX_ARCHIVE_ENTRIES]; - Common::File _archive; - uint32 _numFiles; protected: @@ -77,21 +93,17 @@ public: void open(const char* file); void close(); - Common::String name() const; - bool openArchivedFile(const char *name); void closeArchivedFile(); - uint32 size() const; uint32 pos() const; bool eos() const; void seek(int32 offs, int whence = SEEK_SET); - uint32 read(void *dataPtr, uint32 dataSize); }; -class Disk { +class Disk_ns : public Disk { protected: Archive _resArchive; @@ -103,29 +115,14 @@ protected: void errorFileNotFound(const char *s); public: - Disk(Parallaction *vm); - virtual ~Disk(); + Disk_ns(Parallaction *vm); + virtual ~Disk_ns(); Common::String selectArchive(const Common::String &name); void setLanguage(uint16 language); - - virtual Script* loadLocation(const char *name) = 0; - virtual Script* loadScript(const char* name) = 0; - virtual Cnv* loadTalk(const char *name) = 0; - virtual Cnv* loadObjects(const char *name) = 0; - virtual StaticCnv* loadPointer() = 0; - virtual StaticCnv* loadHead(const char* name) = 0; - virtual Font* loadFont(const char* name) = 0; - virtual StaticCnv* loadStatic(const char* name) = 0; - virtual Cnv* loadFrames(const char* name) = 0; - virtual void loadSlide(const char *filename) = 0; - virtual void loadScenery(const char* background, const char* mask) = 0; - virtual Table* loadTable(const char* name) = 0; - virtual Common::ReadStream* loadMusic(const char* name) = 0; - virtual Common::ReadStream* loadSound(const char* name) = 0; }; -class DosDisk : public Disk { +class DosDisk_ns : public Disk_ns { private: void unpackBackground(Common::ReadStream *stream, byte *screen, byte *mask, byte *path); @@ -142,8 +139,8 @@ protected: Gfx *_gfx; public: - DosDisk(Parallaction *vm); - virtual ~DosDisk(); + DosDisk_ns(Parallaction *vm); + virtual ~DosDisk_ns(); Script* loadLocation(const char *name); Script* loadScript(const char* name); @@ -161,7 +158,7 @@ public: Common::ReadStream* loadSound(const char* name); }; -class AmigaDisk : public Disk { +class AmigaDisk_ns : public Disk_ns { protected: Cnv* makeCnv(Common::SeekableReadStream &stream); @@ -176,9 +173,43 @@ protected: void loadBackground(const char *name); public: - AmigaDisk(Parallaction *vm); - virtual ~AmigaDisk(); + AmigaDisk_ns(Parallaction *vm); + virtual ~AmigaDisk_ns(); + + Script* loadLocation(const char *name); + Script* loadScript(const char* name); + Cnv* loadTalk(const char *name); + Cnv* loadObjects(const char *name); + StaticCnv* loadPointer(); + StaticCnv* loadHead(const char* name); + Font* loadFont(const char* name); + StaticCnv* loadStatic(const char* name); + Cnv* loadFrames(const char* name); + void loadSlide(const char *filename); + void loadScenery(const char* background, const char* mask); + Table* loadTable(const char* name); + Common::ReadStream* loadMusic(const char* name); + Common::ReadStream* loadSound(const char* name); +}; + + +// for the moment DosDisk_br subclasses Disk. When Amiga support will +// be taken into consideration, it might be useful to add another level +// like we did for Nippon Safes. +class DosDisk_br : public Disk { + +protected: + Parallaction *_vm; + +protected: + void errorFileNotFound(const char *s); + +public: + DosDisk_br(Parallaction *vm); + virtual ~DosDisk_br(); + Common::String selectArchive(const Common::String &name); + void setLanguage(uint16 language); Script* loadLocation(const char *name); Script* loadScript(const char* name); Cnv* loadTalk(const char *name); @@ -195,6 +226,7 @@ public: Common::ReadStream* loadSound(const char* name); }; + } // namespace Parallaction diff --git a/engines/parallaction/disk_br.cpp b/engines/parallaction/disk_br.cpp new file mode 100644 index 0000000000..07d9954f23 --- /dev/null +++ b/engines/parallaction/disk_br.cpp @@ -0,0 +1,134 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include "common/stdafx.h" +#include "parallaction/parallaction.h" + + +namespace Parallaction { + + +void DosDisk_br::errorFileNotFound(const char *s) { + error("File '%s' not found", s); +} + +Common::String DosDisk_br::selectArchive(const Common::String& name) { + debugC(5, kDebugDisk, "DosDisk_br::selectArchive"); + return ""; +} + +void DosDisk_br::setLanguage(uint16 language) { + debugC(5, kDebugDisk, "DosDisk_br::setLanguage"); + + return; +} + +DosDisk_br::DosDisk_br(Parallaction* vm) : _vm(vm) { + +} + +DosDisk_br::~DosDisk_br() { +} + +Cnv* DosDisk_br::loadTalk(const char *name) { + debugC(5, kDebugDisk, "DosDisk_br::loadTalk"); + + return 0; +} + +Script* DosDisk_br::loadLocation(const char *name) { + debugC(5, kDebugDisk, "DosDisk_br::loadLocation"); + return 0; +} + +Script* DosDisk_br::loadScript(const char* name) { + debugC(5, kDebugDisk, "DosDisk_br::loadScript"); + return 0; +} + +// there are no Head resources in Big Red Adventure +StaticCnv* DosDisk_br::loadHead(const char* name) { + debugC(5, kDebugDisk, "DosDisk_br::loadHead"); + return 0; +} + + +StaticCnv* DosDisk_br::loadPointer() { + debugC(5, kDebugDisk, "DosDisk_br::loadPointer"); + return 0; +} + + +Font* DosDisk_br::loadFont(const char* name) { + debugC(5, kDebugDisk, "DosDisk_br::loadFont"); + return 0; +} + + +Cnv* DosDisk_br::loadObjects(const char *name) { + debugC(5, kDebugDisk, "DosDisk_br::loadObjects"); + return 0; +} + + +StaticCnv* DosDisk_br::loadStatic(const char* name) { + debugC(5, kDebugDisk, "DosDisk_br::loadStatic"); + return 0; +} + +Cnv* DosDisk_br::loadFrames(const char* name) { + debugC(5, kDebugDisk, "DosDisk_br::loadFrames"); + return 0; +} + +// there are no Slide resources in Big Red Adventure +void DosDisk_br::loadSlide(const char *filename) { + debugC(5, kDebugDisk, "DosDisk_br::loadSlide"); + return; +} + +void DosDisk_br::loadScenery(const char *name, const char *mask) { + debugC(5, kDebugDisk, "DosDisk_br::loadScenery"); + return; +} + +Table* DosDisk_br::loadTable(const char* name) { + debugC(5, kDebugDisk, "DosDisk_br::loadTable"); + return 0; +} + +Common::ReadStream* DosDisk_br::loadMusic(const char* name) { + debugC(5, kDebugDisk, "DosDisk_br::loadMusic"); + return 0; +} + + +Common::ReadStream* DosDisk_br::loadSound(const char* name) { + debugC(5, kDebugDisk, "DosDisk_br::loadSound"); + return 0; +} + + +} // namespace Parallaction diff --git a/engines/parallaction/disk_ns.cpp b/engines/parallaction/disk_ns.cpp new file mode 100644 index 0000000000..bf9b0277cb --- /dev/null +++ b/engines/parallaction/disk_ns.cpp @@ -0,0 +1,1443 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include "common/stdafx.h" + +#include "graphics/iff.h" +#include "graphics/surface.h" + +#include "parallaction/parallaction.h" + + +namespace Audio { + class AudioStream; + + AudioStream *make8SVXStream(Common::ReadStream &input); +} + +namespace Parallaction { + + +// HACK: Several archives ('de', 'en', 'fr' and 'disk0') in the multi-lingual +// Amiga version of Nippon Safes, and one archive ('fr') in the Amiga Demo of +// Nippon Safes used different internal offsets than all the other archives. +// +// When an archive is opened in the Amiga demo, its size is checked against +// SIZEOF_SMALL_ARCHIVE to detect when the smaller archive is used. +// +// When an archive is opened in Amiga multi-lingual version, the header is +// checked again NDOS to detect when a smaller archive is used. +// +#define SIZEOF_SMALL_ARCHIVE 12778 + +#define ARCHIVE_FILENAMES_OFS 0x16 + +#define NORMAL_ARCHIVE_FILES_NUM 384 +#define SMALL_ARCHIVE_FILES_NUM 180 + +#define NORMAL_ARCHIVE_SIZES_OFS 0x3016 +#define SMALL_ARCHIVE_SIZES_OFS 0x1696 + +#define NORMAL_ARCHIVE_DATA_OFS 0x4000 +#define SMALL_ARCHIVE_DATA_OFS 0x1966 + +Archive::Archive() { + resetArchivedFile(); +} + +void Archive::open(const char *file) { + debugC(1, kDebugDisk, "Archive::open(%s)", file); + + if (_archive.isOpen()) + close(); + + char path[PATH_LEN]; + + strcpy(path, file); + if (!_archive.open(path)) + error("archive '%s' not found", path); + + _archiveName = file; + + bool isSmallArchive = false; + if (_vm->getPlatform() == Common::kPlatformAmiga) { + if (_vm->getFeatures() & GF_DEMO) { + isSmallArchive = _archive.size() == SIZEOF_SMALL_ARCHIVE; + } else if (_vm->getFeatures() & GF_LANG_MULT) { + isSmallArchive = (_archive.readUint32BE() != MKID_BE('NDOS')); + } + } + + _numFiles = (isSmallArchive) ? SMALL_ARCHIVE_FILES_NUM : NORMAL_ARCHIVE_FILES_NUM; + + _archive.seek(ARCHIVE_FILENAMES_OFS); + _archive.read(_archiveDir, _numFiles*32); + + _archive.seek((isSmallArchive) ? SMALL_ARCHIVE_SIZES_OFS : NORMAL_ARCHIVE_SIZES_OFS); + + uint32 dataOffset = (isSmallArchive) ? SMALL_ARCHIVE_DATA_OFS : NORMAL_ARCHIVE_DATA_OFS; + for (uint16 i = 0; i < _numFiles; i++) { + _archiveOffsets[i] = dataOffset; + _archiveLenghts[i] = _archive.readUint32BE(); + dataOffset += _archiveLenghts[i]; + } + + return; +} + + +void Archive::close() { + if (!_archive.isOpen()) return; + + resetArchivedFile(); + + _archive.close(); + _archiveName.clear(); +} + +Common::String Archive::name() const { + return _archiveName; +} + +bool Archive::openArchivedFile(const char *filename) { + debugC(3, kDebugDisk, "Archive::openArchivedFile(%s)", filename); + + resetArchivedFile(); + + debugC(3, kDebugDisk, "Archive::openArchivedFile(%s)", filename); + + if (!_archive.isOpen()) + error("Archive::openArchivedFile: the archive is not open"); + + uint16 i = 0; + for ( ; i < _numFiles; i++) { + if (!scumm_stricmp(_archiveDir[i], filename)) break; + } + if (i == _numFiles) return false; + + debugC(9, kDebugDisk, "Archive::openArchivedFile: '%s' found in slot %i", filename, i); + + _file = true; + + _fileOffset = _archiveOffsets[i]; + _fileCursor = _archiveOffsets[i]; + _fileEndOffset = _archiveOffsets[i] + _archiveLenghts[i]; + + _archive.seek(_fileOffset); + + return true; +} + +void Archive::resetArchivedFile() { + _file = false; + _fileCursor = 0; + _fileOffset = 0; + _fileEndOffset = 0; +} + +void Archive::closeArchivedFile() { + resetArchivedFile(); +} + + +uint32 Archive::size() const { + return (_file == true ? _fileEndOffset - _fileOffset : 0); +} + +uint32 Archive::pos() const { + return (_file == true ? _fileCursor - _fileOffset : 0 ); +} + +bool Archive::eos() const { + return (_file == true ? _fileCursor == _fileEndOffset : true ); +} + +void Archive::seek(int32 offs, int whence) { + assert(_file == true && _fileCursor <= _fileEndOffset); + + switch (whence) { + case SEEK_CUR: + _fileCursor += offs; + break; + case SEEK_SET: + _fileCursor = _fileOffset + offs; + break; + case SEEK_END: + _fileCursor = _fileEndOffset - offs; + break; + } + assert(_fileCursor <= _fileEndOffset && _fileCursor >= _fileOffset); + + _archive.seek(_fileCursor, SEEK_SET); +} + +uint32 Archive::read(void *dataPtr, uint32 dataSize) { +// printf("read(%i, %i)\n", file->_cursor, file->_endOffset); + if (_file == false) + error("Archive::read: no archived file is currently open"); + + if (_fileCursor >= _fileEndOffset) + error("can't read beyond end of archived file"); + + if (_fileEndOffset - _fileCursor < dataSize) + dataSize = _fileEndOffset - _fileCursor; + + int32 readBytes = _archive.read(dataPtr, dataSize); + _fileCursor += readBytes; + + return readBytes; +} + + + + + +/* + This stream class is just a wrapper around Archive, so + deallocation is not a problem. In fact, this class doesn't + delete its input (Archive) stream. +*/ +class DummyArchiveStream : public Common::SeekableReadStream { + + Archive *_input; + +public: + DummyArchiveStream(Archive &input) : _input(&input) { + + } + + ~DummyArchiveStream() { + // this class exists to provide this empty destructor + } + + bool eos() const { + return _input->eos(); + } + + uint32 read(void* data, uint32 dataSize) { + return _input->read(data, dataSize); + } + + uint32 pos() const { + return _input->pos(); + } + + uint32 size() const { + return _input->size(); + } + + void seek(int32 offset, int whence) { + _input->seek(offset, whence); + } + +}; + + + +void Disk_ns::errorFileNotFound(const char *s) { + error("File '%s' not found", s); +} + +Disk_ns::Disk_ns(Parallaction *vm) : _vm(vm) { + +} + +Disk_ns::~Disk_ns() { + +} + + +Common::String Disk_ns::selectArchive(const Common::String& name) { + Common::String oldName = _resArchive.name(); + _resArchive.open(name.c_str()); + return oldName; +} + +void Disk_ns::setLanguage(uint16 language) { + debugC(1, kDebugDisk, "setLanguage(%i)", language); + + switch (language) { + case 0: + strcpy(_languageDir, "it/"); + break; + + case 1: + strcpy(_languageDir, "fr/"); + break; + + case 2: + strcpy(_languageDir, "en/"); + break; + + case 3: + strcpy(_languageDir, "ge/"); + break; + + default: + error("unknown language"); + + } + + _languageDir[2] = '\0'; + _locArchive.open(_languageDir); + _languageDir[2] = '/'; + + return; +} + +#pragma mark - + + + +DosDisk_ns::DosDisk_ns(Parallaction* vm) : Disk_ns(vm) { + +} + +DosDisk_ns::~DosDisk_ns() { +} + + +// +// loads a cnv from an external file +// +Cnv* DosDisk_ns::loadExternalCnv(const char *filename) { +// printf("Gfx::loadExternalCnv(%s)...", filename); + + char path[PATH_LEN]; + + sprintf(path, "%s.cnv", filename); + + Common::File stream; + + if (!stream.open(path)) + errorFileNotFound(path); + + uint16 numFrames = stream.readByte(); + uint16 width = stream.readByte(); + uint16 height = stream.readByte(); + + uint32 decsize = numFrames * width * height; + byte *data = (byte*)malloc(decsize); + stream.read(data, decsize); + + return new Cnv(numFrames, width, height, data); +} + +StaticCnv *DosDisk_ns::loadExternalStaticCnv(const char *filename) { + + char path[PATH_LEN]; + + sprintf(path, "%s.cnv", filename); + + Common::File stream; + + if (!stream.open(path)) + errorFileNotFound(path); + + StaticCnv *cnv = new StaticCnv; + + stream.skip(1); + cnv->_width = stream.readByte(); + cnv->_height = stream.readByte(); + + uint16 size = cnv->_width*cnv->_height; + + cnv->_data0 = (byte*)malloc(size); + stream.read(cnv->_data0, size); + + return cnv; +} + +Cnv* DosDisk_ns::loadCnv(const char *filename) { +// printf("Gfx::loadCnv(%s)\n", filename); + + char path[PATH_LEN]; + + strcpy(path, filename); + if (!_resArchive.openArchivedFile(path)) { + sprintf(path, "%s.pp", filename); + if (!_resArchive.openArchivedFile(path)) + errorFileNotFound(path); + } + + uint16 numFrames = _resArchive.readByte(); + uint16 width = _resArchive.readByte(); + uint16 height = _resArchive.readByte(); + + uint32 decsize = numFrames * width * height; + byte *data = (byte*)malloc(decsize); + + Graphics::PackBitsReadStream decoder(_resArchive); + decoder.read(data, decsize); + + return new Cnv(numFrames, width, height, data); +} + +Cnv* DosDisk_ns::loadTalk(const char *name) { + + const char *ext = strstr(name, ".talk"); + if (ext != NULL) { + // npc talk + return loadCnv(name); + + } + + // character talk + char v20[PATH_LEN]; + char *v24 = const_cast(name); + if (IS_MINI_CHARACTER(v24)) { + v24+=4; + } + + if (_engineFlags & kEngineTransformedDonna) { + sprintf(v20, "%stta", v24); + } else { + sprintf(v20, "%stal", v24); + } + + return loadExternalCnv(v20); +} + +Script* DosDisk_ns::loadLocation(const char *name) { + + char archivefile[PATH_LEN]; + + if (IS_MINI_CHARACTER(_vm->_characterName)) { + sprintf(archivefile, "%s%s", _vm->_characterName+4, _languageDir); + } else { + if (IS_DUMMY_CHARACTER(_vm->_characterName)) { + strcpy(archivefile, _languageDir); + } else { + sprintf(archivefile, "%s%s", _vm->_characterName, _languageDir); + } + } + + strcat(archivefile, name); + strcat(archivefile, ".loc"); + + debugC(3, kDebugDisk, "DosDisk_ns::loadLocation(%s): trying '%s'", name, archivefile); + + if (!_locArchive.openArchivedFile(archivefile)) { + sprintf(archivefile, "%s%s.loc", _languageDir, name); + debugC(3, kDebugDisk, "DosDisk_ns::loadLocation(%s): trying '%s'", name, archivefile); + + if (!_locArchive.openArchivedFile(archivefile)) + errorFileNotFound(name); + } + + return new Script(new DummyArchiveStream(_locArchive), true); +} + +Script* DosDisk_ns::loadScript(const char* name) { + + char vC8[PATH_LEN]; + + sprintf(vC8, "%s.script", name); + + if (!_resArchive.openArchivedFile(vC8)) + errorFileNotFound(vC8); + + return new Script(new DummyArchiveStream(_resArchive), true); +} + +StaticCnv* DosDisk_ns::loadHead(const char* name) { + + char path[PATH_LEN]; + + if (IS_MINI_CHARACTER(name)) { + name += 4; + } + + sprintf(path, "%shead", name); + path[8] = '\0'; + + return loadExternalStaticCnv(path); +} + + +StaticCnv* DosDisk_ns::loadPointer() { + return loadExternalStaticCnv("pointer"); +} + + +Font* DosDisk_ns::loadFont(const char* name) { + char path[PATH_LEN]; + sprintf(path, "%scnv", name); + return createFont(name, loadExternalCnv(path)); +} + + +Cnv* DosDisk_ns::loadObjects(const char *name) { + + if (IS_MINI_CHARACTER(name)) { + name += 4; + } + + char path[PATH_LEN]; + sprintf(path, "%sobj", name); + return loadExternalCnv(path); +} + + +StaticCnv* DosDisk_ns::loadStatic(const char* name) { + + char path[PATH_LEN]; + + strcpy(path, name); + if (!_resArchive.openArchivedFile(path)) { + sprintf(path, "%s.pp", name); + if (!_resArchive.openArchivedFile(path)) + errorFileNotFound(path); + } + + StaticCnv* cnv = new StaticCnv; + + _resArchive.skip(1); + cnv->_width = _resArchive.readByte(); + cnv->_height = _resArchive.readByte(); + + uint16 size = cnv->_width*cnv->_height; + cnv->_data0 = (byte*)malloc(size); + + Graphics::PackBitsReadStream decoder(_resArchive); + decoder.read(cnv->_data0, size); + + return cnv; +} + +Cnv* DosDisk_ns::loadFrames(const char* name) { + return loadCnv(name); +} + +// +// slides (background images) are stored compressed by scanline in a rle fashion +// +// the uncompressed data must then be unpacked to get: +// * color data [bits 0-5] +// * mask data [bits 6-7] (z buffer) +// * path data [bit 8] (walkable areas) +// +void DosDisk_ns::unpackBackground(Common::ReadStream *stream, byte *screen, byte *mask, byte *path) { + + byte b; + uint32 i = 0; + + while (!stream->eos()) { + b = stream->readByte(); + + path[i/8] |= ((b & 0x80) >> 7) << (i & 7); + mask[i/4] |= ((b & 0x60) >> 5) << ((i & 3) << 1); + screen[i] = b & 0x1F; + i++; + } + + return; +} + + +void DosDisk_ns::parseDepths(Common::SeekableReadStream &stream) { + _vm->_gfx->_bgLayers[0] = stream.readByte(); + _vm->_gfx->_bgLayers[1] = stream.readByte(); + _vm->_gfx->_bgLayers[2] = stream.readByte(); + _vm->_gfx->_bgLayers[3] = stream.readByte(); +} + + +void DosDisk_ns::parseBackground(Common::SeekableReadStream &stream) { + + stream.read(_vm->_gfx->_palette, BASE_PALETTE_SIZE); + _vm->_gfx->setPalette(_vm->_gfx->_palette); + + parseDepths(stream); + + for (uint32 _si = 0; _si < 6; _si++) { + _vm->_gfx->_palettefx[_si]._timer = stream.readUint16BE(); + _vm->_gfx->_palettefx[_si]._step = stream.readUint16BE(); + _vm->_gfx->_palettefx[_si]._flags = stream.readUint16BE(); + _vm->_gfx->_palettefx[_si]._first = stream.readByte(); + _vm->_gfx->_palettefx[_si]._last = stream.readByte(); + } + +} + +void DosDisk_ns::loadBackground(const char *filename) { + + if (!_resArchive.openArchivedFile(filename)) + errorFileNotFound(filename); + + parseBackground(_resArchive); + + byte *bg = (byte*)calloc(1, _vm->_screenSize); + byte *mask = (byte*)calloc(1, _vm->_screenMaskSize); + byte *path = (byte*)calloc(1, _vm->_screenPathSize); + + + Graphics::PackBitsReadStream stream(_resArchive); + unpackBackground(&stream, bg, mask, path); + + _vm->_gfx->setBackground(bg); + _vm->_gfx->setMask(mask); + _vm->setPath(path); + + free(bg); + free(mask); + free(path); + + return; +} + +// +// read background path and mask from a file +// +// mask and path are normally combined (via OR) into the background picture itself +// read the comment on the top of this file for more +// +void DosDisk_ns::loadMaskAndPath(const char *name) { + char path[PATH_LEN]; + sprintf(path, "%s.msk", name); + + if (!_resArchive.openArchivedFile(path)) + errorFileNotFound(name); + + byte *maskBuf = (byte*)calloc(1, _vm->_screenMaskSize); + byte *pathBuf = (byte*)calloc(1, _vm->_screenPathSize); + + parseDepths(_resArchive); + + _resArchive.read(pathBuf, _vm->_screenPathSize); + _resArchive.read(maskBuf, _vm->_screenMaskSize); + + _vm->_gfx->setMask(maskBuf); + _vm->setPath(pathBuf); + + return; +} + +void DosDisk_ns::loadSlide(const char *filename) { + char path[PATH_LEN]; + sprintf(path, "%s.slide", filename); + loadBackground(path); +} + +void DosDisk_ns::loadScenery(const char *name, const char *mask) { + char path[PATH_LEN]; + sprintf(path, "%s.dyn", name); + loadBackground(path); + + if (mask != NULL) { + // load external masks and paths only for certain locations + loadMaskAndPath(mask); + } + +} + +Table* DosDisk_ns::loadTable(const char* name) { + char path[PATH_LEN]; + sprintf(path, "%s.tab", name); + + Common::File stream; + if (!stream.open(path)) + errorFileNotFound(path); + + Table *t = new Table(100); + + fillBuffers(stream); + while (scumm_stricmp(_tokens[0], "ENDTABLE")) { + t->addData(_tokens[0]); + fillBuffers(stream); + } + + stream.close(); + + return t; +} + +Common::ReadStream* DosDisk_ns::loadMusic(const char* name) { + char path[PATH_LEN]; + sprintf(path, "%s.mid", name); + + Common::File *stream = new Common::File; + if (!stream->open(path)) + errorFileNotFound(path); + + return stream; +} + + +Common::ReadStream* DosDisk_ns::loadSound(const char* name) { + return NULL; +} + + + + + + +#pragma mark - + + +/* the decoder presented here is taken from pplib by Stuart Caie. The + * following statement comes from the original source. + * + * pplib 1.0: a simple PowerPacker decompression and decryption library + * placed in the Public Domain on 2003-09-18 by Stuart Caie. + */ + +#define PP_READ_BITS(nbits, var) do { \ + bit_cnt = (nbits); (var) = 0; \ + while (bits_left < bit_cnt) { \ + if (buf < src) return 0; \ + bit_buffer |= *--buf << bits_left; \ + bits_left += 8; \ + } \ + bits_left -= bit_cnt; \ + while (bit_cnt--) { \ + (var) = ((var) << 1) | (bit_buffer & 1); \ + bit_buffer >>= 1; \ + } \ +} while (0) + +#define PP_BYTE_OUT(byte) do { \ + if (out <= dest) return 0; \ + *--out = (byte); written++; \ +} while (0) + + +class PowerPackerStream : public Common::SeekableReadStream { + + SeekableReadStream *_stream; + bool _dispose; + +private: + int ppDecrunchBuffer(byte *src, byte *dest, uint32 src_len, uint32 dest_len) { + + byte *buf, *out, *dest_end, *off_lens, bits_left = 0, bit_cnt; + uint32 bit_buffer = 0, x, todo, offbits, offset, written = 0; + + if (src == NULL || dest == NULL) return 0; + + /* set up input and output pointers */ + off_lens = src; src = &src[4]; + buf = &src[src_len]; + + out = dest_end = &dest[dest_len]; + + /* skip the first few bits */ + PP_READ_BITS(src[src_len + 3], x); + + /* while there are input bits left */ + while (written < dest_len) { + PP_READ_BITS(1, x); + if (x == 0) { + /* bit==0: literal, then match. bit==1: just match */ + todo = 1; do { PP_READ_BITS(2, x); todo += x; } while (x == 3); + while (todo--) { PP_READ_BITS(8, x); PP_BYTE_OUT(x); } + + /* should we end decoding on a literal, break out of the main loop */ + if (written == dest_len) break; + } + + /* match: read 2 bits for initial offset bitlength / match length */ + PP_READ_BITS(2, x); + offbits = off_lens[x]; + todo = x+2; + if (x == 3) { + PP_READ_BITS(1, x); + if (x == 0) offbits = 7; + PP_READ_BITS(offbits, offset); + do { PP_READ_BITS(3, x); todo += x; } while (x == 7); + } + else { + PP_READ_BITS(offbits, offset); + } + if (&out[offset] >= dest_end) return 0; /* match_overflow */ + while (todo--) { x = out[offset]; PP_BYTE_OUT(x); } + } + + /* all output bytes written without error */ + return 1; + } + + uint16 getCrunchType(uint32 signature) { + + byte eff; + + switch (signature) { + case 0x50503230: /* PP20 */ + eff = 4; + break; + case 0x50504C53: /* PPLS */ + error("PPLS crunched files are not supported"); + eff = 8; + break; + case 0x50583230: /* PX20 */ + error("PX20 crunched files are not supported"); + eff = 6; + break; + default: + eff = 0; + + } + + return eff; + } + +public: + PowerPackerStream(Common::SeekableReadStream &stream) { + + _dispose = false; + + uint32 signature = stream.readUint32BE(); + if (getCrunchType(signature) == 0) { + stream.seek(0, SEEK_SET); + _stream = &stream; + return; + } + + stream.seek(4, SEEK_END); + uint32 decrlen = stream.readUint32BE() >> 8; + byte *dest = (byte*)malloc(decrlen); + + uint32 crlen = stream.size() - 4; + byte *src = (byte*)malloc(crlen); + stream.seek(4, SEEK_SET); + stream.read(src, crlen); + + ppDecrunchBuffer(src, dest, crlen-8, decrlen); + + free(src); + _stream = new Common::MemoryReadStream(dest, decrlen, true); + _dispose = true; + } + + ~PowerPackerStream() { + if (_dispose) delete _stream; + } + + uint32 size() const { + return _stream->size(); + } + + uint32 pos() const { + return _stream->pos(); + } + + bool eos() const { + return _stream->eos(); + } + + void seek(int32 offs, int whence = SEEK_SET) { + _stream->seek(offs, whence); + } + + uint32 read(void *dataPtr, uint32 dataSize) { + return _stream->read(dataPtr, dataSize); + } +}; + + + + + +AmigaDisk_ns::AmigaDisk_ns(Parallaction *vm) : Disk_ns(vm) { + +} + + +AmigaDisk_ns::~AmigaDisk_ns() { + +} + +#define NUM_PLANES 5 + +/* + unpackFrame transforms images from 5-bitplanes format to + 8-bit color-index mode +*/ +void AmigaDisk_ns::unpackFrame(byte *dst, byte *src, uint16 planeSize) { + + byte s0, s1, s2, s3, s4, mask, t0, t1, t2, t3, t4; + + for (uint32 j = 0; j < planeSize; j++) { + s0 = src[j]; + s1 = src[j+planeSize]; + s2 = src[j+planeSize*2]; + s3 = src[j+planeSize*3]; + s4 = src[j+planeSize*4]; + + for (uint32 k = 0; k < 8; k++) { + mask = 1 << (7 - k); + t0 = (s0 & mask ? 1 << 0 : 0); + t1 = (s1 & mask ? 1 << 1 : 0); + t2 = (s2 & mask ? 1 << 2 : 0); + t3 = (s3 & mask ? 1 << 3 : 0); + t4 = (s4 & mask ? 1 << 4 : 0); + *dst++ = t0 | t1 | t2 | t3 | t4; + } + + } + +} + +/* + patchFrame applies DLTA data (dlta) to specified buffer (dst) +*/ +void AmigaDisk_ns::patchFrame(byte *dst, byte *dlta, uint16 bytesPerPlane, uint16 height) { + + uint32 *dataIndex = (uint32*)dlta; + uint32 *ofslenIndex = (uint32*)dlta + 8; + + uint16 *base = (uint16*)dlta; + uint16 wordsPerLine = bytesPerPlane >> 1; + + for (uint j = 0; j < NUM_PLANES; j++) { + uint16 *dst16 = (uint16*)(dst + j * bytesPerPlane * height); + + uint16 *data = base + READ_BE_UINT32(dataIndex); + dataIndex++; + uint16 *ofslen = base + READ_BE_UINT32(ofslenIndex); + ofslenIndex++; + + while (*ofslen != 0xFFFF) { + + uint16 ofs = READ_BE_UINT16(ofslen); + ofslen++; + uint16 size = READ_BE_UINT16(ofslen); + ofslen++; + + while (size > 0) { + dst16[ofs] ^= *data++; + ofs += wordsPerLine; + size--; + } + + } + + } + +} + +// FIXME: no mask is loaded +void AmigaDisk_ns::unpackBitmap(byte *dst, byte *src, uint16 numFrames, uint16 bytesPerPlane, uint16 height) { + + byte *baseFrame = src; + byte *tempBuffer = 0; + + uint16 planeSize = bytesPerPlane * height; + + for (uint32 i = 0; i < numFrames; i++) { + if (READ_BE_UINT32(src) == MKID_BE('DLTA')) { + + uint size = READ_BE_UINT32(src + 4); + + if (tempBuffer == 0) + tempBuffer = (byte*)malloc(planeSize * NUM_PLANES); + + memcpy(tempBuffer, baseFrame, planeSize * NUM_PLANES); + + patchFrame(tempBuffer, src + 8, bytesPerPlane, height); + unpackFrame(dst, tempBuffer, planeSize); + + src += (size + 8); + dst += planeSize * 8; + } else { + unpackFrame(dst, src, planeSize); + src += planeSize * NUM_PLANES; + dst += planeSize * 8; + } + } + + if (tempBuffer) + free(tempBuffer); + +} + +StaticCnv* AmigaDisk_ns::makeStaticCnv(Common::SeekableReadStream &stream) { + + stream.skip(1); + uint16 width = stream.readByte(); + uint16 height = stream.readByte(); + + assert((width & 7) == 0); + + byte bytesPerPlane = width / 8; + + uint32 rawsize = bytesPerPlane * NUM_PLANES * height; + byte *buf = (byte*)malloc(rawsize); + stream.read(buf, rawsize); + + uint32 decsize = width * height; + byte *data = (byte*)calloc(decsize, 1); + + unpackBitmap(data, buf, 1, bytesPerPlane, height); + + free(buf); + + StaticCnv *cnv = new StaticCnv(); + cnv->_width = width; + cnv->_height = height; + cnv->_data0 = data; + cnv->_data1 = NULL; + + return cnv; +} + +Cnv* AmigaDisk_ns::makeCnv(Common::SeekableReadStream &stream) { + + uint16 numFrames = stream.readByte(); + uint16 width = stream.readByte(); + uint16 height = stream.readByte(); + + assert((width & 7) == 0); + + byte bytesPerPlane = width / 8; + + uint32 rawsize = numFrames * bytesPerPlane * NUM_PLANES * height; + byte *buf = (byte*)malloc(rawsize); + stream.read(buf, rawsize); + + uint32 decsize = numFrames * width * height; + byte *data = (byte*)calloc(decsize, 1); + + unpackBitmap(data, buf, numFrames, bytesPerPlane, height); + + free(buf); + + return new Cnv(numFrames, width, height, data); +} +#undef NUM_PLANES + +Script* AmigaDisk_ns::loadLocation(const char *name) { + debugC(1, kDebugDisk, "AmigaDisk_ns()::loadLocation '%s'", name); + + char path[PATH_LEN]; + if (IS_MINI_CHARACTER(_vm->_characterName)) { + sprintf(path, "%s%s%s.loc.pp", _vm->_characterName+4, _languageDir, name); + } else + sprintf(path, "%s%s%s.loc.pp", _vm->_characterName, _languageDir, name); + + if (!_locArchive.openArchivedFile(path)) { + sprintf(path, "%s%s.loc.pp", _languageDir, name); + if (!_locArchive.openArchivedFile(path)) { + errorFileNotFound(name); + } + } + + debugC(3, kDebugDisk, "location file found: %s", path); + + return new Script(new PowerPackerStream(_locArchive), true); +} + +Script* AmigaDisk_ns::loadScript(const char* name) { + debugC(1, kDebugDisk, "AmigaDisk_ns::loadScript '%s'", name); + + char vC8[PATH_LEN]; + + sprintf(vC8, "%s.script", name); + + if (!_resArchive.openArchivedFile(vC8)) + errorFileNotFound(vC8); + + return new Script(new DummyArchiveStream(_resArchive), true); +} + +StaticCnv* AmigaDisk_ns::loadPointer() { + debugC(1, kDebugDisk, "AmigaDisk_ns::loadPointer"); + + Common::File stream; + if (!stream.open("pointer")) + errorFileNotFound("pointer"); + + return makeStaticCnv(stream); +} + +StaticCnv* AmigaDisk_ns::loadStatic(const char* name) { + debugC(1, kDebugDisk, "AmigaDisk_ns::loadStatic '%s'", name); + + Common::SeekableReadStream *s = openArchivedFile(name, true); + StaticCnv *cnv = makeStaticCnv(*s); + + delete s; + + return cnv; +} + +Common::SeekableReadStream *AmigaDisk_ns::openArchivedFile(const char* name, bool errorOnFileNotFound) { + debugC(3, kDebugDisk, "AmigaDisk_ns::openArchivedFile(%s)", name); + + if (_resArchive.openArchivedFile(name)) { + return new DummyArchiveStream(_resArchive); + } + + char path[PATH_LEN]; + + sprintf(path, "%s.pp", name); + if (_resArchive.openArchivedFile(path)) { + return new PowerPackerStream(_resArchive); + } + + sprintf(path, "%s.dd", name); + if (_resArchive.openArchivedFile(path)) { + return new PowerPackerStream(_resArchive); + } + + if (errorOnFileNotFound) + errorFileNotFound(name); + + return NULL; +} + +/* + FIXME: mask values are not computed correctly for level 1 and 2 + + NOTE: this routine is only able to build masks for Nippon Safes, since mask widths are hardcoded + into the main loop. +*/ +void buildMask(byte* buf) { + + byte mask1[16] = { 0, 0x80, 0x20, 0xA0, 8, 0x88, 0x28, 0xA8, 2, 0x82, 0x22, 0xA2, 0xA, 0x8A, 0x2A, 0xAA }; + byte mask0[16] = { 0, 0x40, 0x10, 0x50, 4, 0x44, 0x14, 0x54, 1, 0x41, 0x11, 0x51, 0x5, 0x45, 0x15, 0x55 }; + + byte plane0[40]; + byte plane1[40]; + + for (int32 i = 0; i < _vm->_screenHeight; i++) { + + memcpy(plane0, buf, 40); + memcpy(plane1, buf+40, 40); + + for (uint32 j = 0; j < 40; j++) { + *buf++ = mask0[(plane0[j] & 0xF0) >> 4] | mask1[(plane1[j] & 0xF0) >> 4]; + *buf++ = mask0[plane0[j] & 0xF] | mask1[plane1[j] & 0xF]; + } + + } +} + +class BackgroundDecoder : public Graphics::ILBMDecoder { + + PaletteFxRange *_range; + uint32 _i; + +protected: + void readCRNG(Common::IFFChunk &chunk) { + _range[_i]._timer = chunk.readUint16BE(); + _range[_i]._step = chunk.readUint16BE(); + _range[_i]._flags = chunk.readUint16BE(); + _range[_i]._first = chunk.readByte(); + _range[_i]._last = chunk.readByte(); + + _i++; + } + +public: + BackgroundDecoder(Common::ReadStream &input, Graphics::Surface &surface, byte *&colors, PaletteFxRange *range) : + Graphics::ILBMDecoder(input, surface, colors), _range(range), _i(0) { + } + + void decode() { + Common::IFFChunk *chunk; + while ((chunk = nextChunk()) != 0) { + switch (chunk->id) { + case ID_BMHD: + readBMHD(*chunk); + break; + + case ID_CMAP: + readCMAP(*chunk); + break; + + case ID_BODY: + readBODY(*chunk); + break; + + case ID_CRNG: + readCRNG(*chunk); + break; + } + } + } + + uint32 getNumRanges() { + return _i; + } +}; + + +void AmigaDisk_ns::loadBackground(const char *name) { + + Common::SeekableReadStream *s = openArchivedFile(name, true); + + Graphics::Surface surf; + byte *pal; + BackgroundDecoder decoder(*s, surf, pal, _vm->_gfx->_palettefx); + decoder.decode(); + + for (uint32 i = 0; i < BASE_PALETTE_COLORS * 3; i++) + _vm->_gfx->_palette[i] = pal[i] >> 2; + free(pal); + _vm->_gfx->setPalette(_vm->_gfx->_palette); + _vm->_gfx->setBackground(static_cast(surf.pixels)); + surf.free(); + delete s; + + return; + +} + +void AmigaDisk_ns::loadMask(const char *name) { + + char path[PATH_LEN]; + sprintf(path, "%s.mask", name); + + Common::SeekableReadStream *s = openArchivedFile(path, false); + if (s == NULL) + return; // no errors if missing mask files: not every location has one + + s->seek(0x30, SEEK_SET); + + byte r, g, b; + for (uint i = 0; i < 4; i++) { + r = s->readByte(); + g = s->readByte(); + b = s->readByte(); + + _vm->_gfx->_bgLayers[i] = (((r << 4) & 0xF00) | (g & 0xF0) | (b >> 4)) & 0xFF; + +// printf("rgb = (%x, %x, %x) -> %x\n", r, g, b, _vm->_gfx->_bgLayers[i]); + } + + + s->seek(0x126, SEEK_SET); // HACK: skipping IFF/ILBM header should be done by analysis, not magic + Graphics::PackBitsReadStream stream(*s); + + byte *buf = (byte*)malloc(_vm->_screenMaskSize); + stream.read(buf, _vm->_screenMaskSize); + buildMask(buf); + _vm->_gfx->setMask(buf); + free(buf); + delete s; + + return; +} + +void AmigaDisk_ns::loadPath(const char *name) { + + char path[PATH_LEN]; + sprintf(path, "%s.path", name); + + Common::SeekableReadStream *s = openArchivedFile(path, false); + if (s == NULL) + return; // no errors if missing path files: not every location has one + + + s->seek(0x120, SEEK_SET); // HACK: skipping IFF/ILBM header should be done by analysis, not magic + + Graphics::PackBitsReadStream stream(*s); + byte *buf = (byte*)malloc(_vm->_screenPathSize); + stream.read(buf, _vm->_screenPathSize); + _vm->setPath(buf); + free(buf); + delete s; + + return; +} + +void AmigaDisk_ns::loadScenery(const char* background, const char* mask) { + debugC(1, kDebugDisk, "AmigaDisk_ns::loadScenery '%s', '%s'", background, mask); + + char path[PATH_LEN]; + sprintf(path, "%s.bkgnd", background); + + loadBackground(path); + loadMask(background); + loadPath(background); + + return; +} + +void AmigaDisk_ns::loadSlide(const char *name) { + debugC(1, kDebugDisk, "AmigaDisk_ns::loadSlide '%s'", name); + + char path[PATH_LEN]; + sprintf(path, "slides/%s", name); + Common::SeekableReadStream *s = openArchivedFile(path, false); + if (s) + loadBackground(path); + else + loadBackground(name); + + return; +} + +Cnv* AmigaDisk_ns::loadFrames(const char* name) { + debugC(1, kDebugDisk, "AmigaDisk_ns::loadFrames '%s'", name); + + Common::SeekableReadStream *s; + + char path[PATH_LEN]; + sprintf(path, "anims/%s", name); + + s = openArchivedFile(path, false); + if (!s) + s = openArchivedFile(name, true); + + Cnv *cnv = makeCnv(*s); + delete s; + + return cnv; +} + +StaticCnv* AmigaDisk_ns::loadHead(const char* name) { + debugC(1, kDebugDisk, "AmigaDisk_ns::loadHead '%s'", name); + + char path[PATH_LEN]; + sprintf(path, "%s.head", name); + + Common::SeekableReadStream *s = openArchivedFile(path, true); + StaticCnv *cnv = makeStaticCnv(*s); + + delete s; + + return cnv; +} + + +Cnv* AmigaDisk_ns::loadObjects(const char *name) { + debugC(1, kDebugDisk, "AmigaDisk_ns::loadObjects"); + + char path[PATH_LEN]; + if (_vm->getFeatures() & GF_DEMO) + sprintf(path, "%s.objs", name); + else + sprintf(path, "objs/%s.objs", name); + + Common::SeekableReadStream *s = openArchivedFile(path, true); + + Cnv *cnv = makeCnv(*s); + delete s; + + return cnv; +} + + +Cnv* AmigaDisk_ns::loadTalk(const char *name) { + debugC(1, kDebugDisk, "AmigaDisk_ns::loadTalk '%s'", name); + + Common::SeekableReadStream *s; + + char path[PATH_LEN]; + if (_vm->getFeatures() & GF_DEMO) + sprintf(path, "%s.talk", name); + else + sprintf(path, "talk/%s.talk", name); + + s = openArchivedFile(path, false); + if (s == NULL) { + s = openArchivedFile(name, true); + } + + Cnv *cnv = makeCnv(*s); + delete s; + + return cnv; +} + +Table* AmigaDisk_ns::loadTable(const char* name) { + debugC(1, kDebugDisk, "AmigaDisk_ns::loadTable '%s'", name); + + char path[PATH_LEN]; + sprintf(path, "%s.table", name); + + bool dispose = false; + + Common::SeekableReadStream *stream; + + if (!scumm_stricmp(name, "global")) { + Common::File *s = new Common::File; + if (!s->open(path)) + errorFileNotFound(path); + + dispose = true; + stream = s; + } else { + if (!(_vm->getFeatures() & GF_DEMO)) + sprintf(path, "objs/%s.table", name); + if (!_resArchive.openArchivedFile(path)) + errorFileNotFound(path); + + stream = &_resArchive; + } + + Table *t = new Table(100); + + fillBuffers(*stream); + while (scumm_stricmp(_tokens[0], "ENDTABLE")) { + t->addData(_tokens[0]); + fillBuffers(*stream); + } + + if (dispose) + delete stream; + + return t; +} + +Font* AmigaDisk_ns::loadFont(const char* name) { + debugC(1, kDebugDisk, "AmigaFullDisk::loadFont '%s'", name); + + char path[PATH_LEN]; + sprintf(path, "%sfont", name); + + if (_vm->getFeatures() & GF_LANG_IT) { + // Italian version has separate font files + Common::File stream; + if (!stream.open(path)) + errorFileNotFound(path); + + return createFont(name, stream); + } else { + if (!_resArchive.openArchivedFile(path)) + errorFileNotFound(path); + + return createFont(name, _resArchive); + } +} + + +Common::ReadStream* AmigaDisk_ns::loadMusic(const char* name) { + return openArchivedFile(name); +} + +Common::ReadStream* AmigaDisk_ns::loadSound(const char* name) { + char path[PATH_LEN]; + sprintf(path, "%s.snd", name); + + openArchivedFile(path); + + return new DummyArchiveStream(_resArchive); +} + +} // namespace Parallaction diff --git a/engines/parallaction/font.cpp b/engines/parallaction/font.cpp index 3bc7835888..ee624b083c 100644 --- a/engines/parallaction/font.cpp +++ b/engines/parallaction/font.cpp @@ -408,7 +408,7 @@ void AmigaFont::drawString(byte *buffer, uint32 pitch, const char *s) { } -Font *DosDisk::createFont(const char *name, Cnv* cnv) { +Font *DosDisk_ns::createFont(const char *name, Cnv* cnv) { Font *f = 0; if (!scumm_stricmp(name, "comic")) @@ -425,7 +425,7 @@ Font *DosDisk::createFont(const char *name, Cnv* cnv) { return f; } -Font *AmigaDisk::createFont(const char *name, Common::SeekableReadStream &stream) { +Font *AmigaDisk_ns::createFont(const char *name, Common::SeekableReadStream &stream) { // TODO: implement AmigaLabelFont for labels return new AmigaFont(stream); } diff --git a/engines/parallaction/module.mk b/engines/parallaction/module.mk index 97741673a3..a94f197cee 100644 --- a/engines/parallaction/module.mk +++ b/engines/parallaction/module.mk @@ -7,7 +7,8 @@ MODULE_OBJS := \ debug.o \ detection.o \ dialogue.o \ - disk.o \ + disk_br.o \ + disk_ns.o \ font.o \ graphics.o \ intro.o \ diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp index ca6ed73aa4..70f1de9f4a 100644 --- a/engines/parallaction/parallaction.cpp +++ b/engines/parallaction/parallaction.cpp @@ -191,17 +191,24 @@ int Parallaction::init() { _screenMaskSize = _screenMaskWidth * _screenHeight; _screenPathSize = _screenPathWidth * _screenHeight; - - - if (getPlatform() == Common::kPlatformPC) { - _disk = new DosDisk(this); - } else { - if (getFeatures() & GF_DEMO) { - strcpy(_location._name, "fognedemo"); + if (getGameType() == GType_Nippon) { + if (getPlatform() == Common::kPlatformPC) { + _disk = new DosDisk_ns(this); + } else { + if (getFeatures() & GF_DEMO) { + strcpy(_location._name, "fognedemo"); + } + _disk = new AmigaDisk_ns(this); + _disk->selectArchive((_vm->getFeatures() & GF_DEMO) ? "disk0" : "disk1"); } - _disk = new AmigaDisk(this); - _disk->selectArchive((_vm->getFeatures() & GF_DEMO) ? "disk0" : "disk1"); - } + } else + if (getGameType() == GType_BRA) { + if (getPlatform() == Common::kPlatformPC) { + _disk = new DosDisk_br(this); + } else + error("unsupported platform for Big Red Adventure"); + } else + error("unknown game type"); _engineFlags = 0; diff --git a/engines/parallaction/walk.cpp b/engines/parallaction/walk.cpp index 5d2d005e9f..fd2fa8d186 100644 --- a/engines/parallaction/walk.cpp +++ b/engines/parallaction/walk.cpp @@ -41,7 +41,7 @@ static uint16 walkData2 = 0; // next walk frame uint16 queryPath(uint16 x, uint16 y) { // NOTE: a better solution would have us mirror each byte in the mask in the loading routine - // AmigaDisk::loadPath() instead of doing it here. + // AmigaDisk_ns::loadPath() instead of doing it here. byte _al = _buffer[y*40 + x/8]; byte _dl = (_vm->getPlatform() == Common::kPlatformPC) ? (x & 7) : (7 - (x & 7)); -- cgit v1.2.3 From 8b62b591a8423ce958723efe171a6c140fcdb5d1 Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Fri, 27 Jul 2007 23:41:43 +0000 Subject: Added detection target for Big Red Adventure, and derived new engine classes for supported games. svn-id: r28247 --- engines/parallaction/detection.cpp | 31 ++++++++++++++++++++++++++++--- engines/parallaction/parallaction.h | 16 ++++++++++++++++ 2 files changed, 44 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/parallaction/detection.cpp b/engines/parallaction/detection.cpp index 44e9126b70..512df60fa9 100644 --- a/engines/parallaction/detection.cpp +++ b/engines/parallaction/detection.cpp @@ -27,6 +27,7 @@ #include "base/plugins.h" +#include "common/config-manager.h" #include "common/advancedDetector.h" #include "parallaction/parallaction.h" @@ -47,7 +48,6 @@ Common::Platform Parallaction::getPlatform() const { return _gameDescription->de } static const PlainGameDescriptor parallactionGames[] = { - {"parallaction", "Parallaction engine game"}, {"nippon", "Nippon Safes Inc."}, {"bra", "The Big Red Adventure"}, {0, 0} @@ -176,7 +176,7 @@ static const Common::ADParams detectionParams = { // Structure for autoupgrading obsolete targets 0, // Name of single gameid (optional) - "parallaction", + 0, // List of files for file-based fallback detection (optional) 0, // Fallback callback @@ -185,7 +185,32 @@ static const Common::ADParams detectionParams = { Common::kADFlagAugmentPreferredTarget }; -ADVANCED_DETECTOR_DEFINE_PLUGIN(PARALLACTION, Parallaction::Parallaction, detectionParams); +GameList Engine_PARALLACTION_gameIDList() { + return GameList(parallactionGames); +} + +GameDescriptor Engine_PARALLACTION_findGameID(const char *gameid) { + return Common::AdvancedDetector::findGameID(gameid, parallactionGames); +} + +GameList Engine_PARALLACTION_detectGames(const FSList &fslist) { + return Common::AdvancedDetector::detectAllGames(fslist, detectionParams); +} + +PluginError Engine_PARALLACTION_create(OSystem *syst, Engine **engine) { + assert(engine); + const char *gameid = ConfMan.get("gameid").c_str(); + + if (!scumm_stricmp("nippon", gameid)) { + *engine = new Parallaction::Parallaction_ns(syst); + } else + if (!scumm_stricmp("bra", gameid)) { + *engine = new Parallaction::Parallaction_br(syst); + } else + error("Parallaction engine created with invalid gameid ('%s')", gameid); + + return kNoError; +} REGISTER_PLUGIN(PARALLACTION, "Parallaction engine", "Nippon Safes Inc. (C) Dynabyte"); diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h index 3a2ecd8f0b..33dc5563e6 100644 --- a/engines/parallaction/parallaction.h +++ b/engines/parallaction/parallaction.h @@ -480,6 +480,22 @@ protected: // members int16 getHoverInventoryItem(int16 x, int16 y); }; +class Parallaction_ns : public Parallaction { + +public: + Parallaction_ns(OSystem* syst) : Parallaction(syst) { } + ~Parallaction_ns() { } + +}; + +class Parallaction_br : public Parallaction { + +public: + Parallaction_br(OSystem* syst) : Parallaction(syst) { } + ~Parallaction_br() { } + +}; + // FIXME: remove global extern Parallaction *_vm; -- cgit v1.2.3 From d1986857d5c77ef5046efafeeb0241323ad73967 Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Fri, 27 Jul 2007 23:42:59 +0000 Subject: Added Italian language flag to Big Red Adventure detection structs. svn-id: r28248 --- engines/parallaction/detection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/parallaction/detection.cpp b/engines/parallaction/detection.cpp index 512df60fa9..84c45584a4 100644 --- a/engines/parallaction/detection.cpp +++ b/engines/parallaction/detection.cpp @@ -155,7 +155,7 @@ static const PARALLACTIONGameDescription gameDescriptions[] = { Common::ADGF_NO_FLAGS }, GType_BRA, - GF_LANG_EN | GF_LANG_FR | GF_LANG_DE | GF_LANG_MULT + GF_LANG_EN | GF_LANG_FR | GF_LANG_DE | GF_LANG_IT | GF_LANG_MULT }, -- cgit v1.2.3 From ee485afa89436ae01f5afbfadd937beb05bac8ff Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 28 Jul 2007 00:20:26 +0000 Subject: Don't allow setCursor to change the cursor to an hourglass in the IHNM demo. The IHNM demo no longer crashes now svn-id: r28250 --- engines/saga/gfx.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/saga/gfx.cpp b/engines/saga/gfx.cpp index a9c6801714..8d36ee0e12 100644 --- a/engines/saga/gfx.cpp +++ b/engines/saga/gfx.cpp @@ -431,7 +431,10 @@ void Gfx::setCursor(CursorType cursorType) { switch (cursorType) { case kCursorBusy: - resourceId = RID_IHNM_HOURGLASS_CURSOR; + if (_vm->getGameId() != GID_IHNM_DEMO) + resourceId = RID_IHNM_HOURGLASS_CURSOR; + else + resourceId = (uint32)-1; break; default: resourceId = (uint32)-1; -- cgit v1.2.3 From ac101f0d6aadee61f154512016b51c9da84eb890 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 28 Jul 2007 00:33:09 +0000 Subject: Disable the status text in the IHNM demo svn-id: r28251 --- engines/saga/interface.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'engines') diff --git a/engines/saga/interface.cpp b/engines/saga/interface.cpp index 5d93807da1..423c187450 100644 --- a/engines/saga/interface.cpp +++ b/engines/saga/interface.cpp @@ -656,6 +656,10 @@ void Interface::setStatusText(const char *text, int statusColor) { if (_vm->getGameType() == GType_IHNM && _vm->_scene->currentChapterNumber() == 8) return; + // Disable the status text in the IHNM demo + if (_vm->getGameId() == GID_IHNM_DEMO) + return; + assert(text != NULL); assert(strlen(text) < STATUS_TEXT_LEN); -- cgit v1.2.3 From cd9ade4af4f5b4b1524ced4054651f5391b64530 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 28 Jul 2007 00:40:04 +0000 Subject: The mouse cursor is no longer incorrectly shown in the IHNM demo svn-id: r28252 --- engines/saga/gfx.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/saga/gfx.cpp b/engines/saga/gfx.cpp index 8d36ee0e12..c19d71c13d 100644 --- a/engines/saga/gfx.cpp +++ b/engines/saga/gfx.cpp @@ -406,7 +406,8 @@ void Gfx::blackToPal(PalEntry *srcPal, double percent) { } void Gfx::showCursor(bool state) { - CursorMan.showMouse(state); + if (_vm->getGameId() != GID_IHNM_DEMO) // Don't show the mouse cursor in the IHNM demo + CursorMan.showMouse(state); } void Gfx::setCursor(CursorType cursorType) { -- cgit v1.2.3 From 6c108f552c2a7cca51641fffeb9ad04be666771a Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 28 Jul 2007 01:03:54 +0000 Subject: The IHNM demo uses the NULL panel svn-id: r28253 --- engines/saga/scene.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/saga/scene.cpp b/engines/saga/scene.cpp index 84d1b45114..041553431b 100644 --- a/engines/saga/scene.cpp +++ b/engines/saga/scene.cpp @@ -589,10 +589,14 @@ void Scene::loadScene(LoadSceneParams *loadSceneParams) { _vm->_interface->addToInventory(IHNM_OBJ_PROFILE); _vm->_interface->activate(); - if (loadSceneParams->chapter == 8 || loadSceneParams->chapter == -1) - _vm->_interface->setMode(kPanelChapterSelection); - else + if (loadSceneParams->chapter == 8 || loadSceneParams->chapter == -1) { + if (_vm->getGameId() != GID_IHNM_DEMO) + _vm->_interface->setMode(kPanelChapterSelection); + else + _vm->_interface->setMode(kPanelNull); + } else { _vm->_interface->setMode(kPanelMain); + } _inGame = true; -- cgit v1.2.3 From 125872c90dbbf68ac423b4e17e0ab51a95d16b91 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 28 Jul 2007 01:04:59 +0000 Subject: The demo version of IHNM has no options panel, therefore the options icon and the options panel shortcuts have been disabled for the IHNM demo svn-id: r28254 --- engines/saga/interface.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/saga/interface.cpp b/engines/saga/interface.cpp index 423c187450..74ac2155a9 100644 --- a/engines/saga/interface.cpp +++ b/engines/saga/interface.cpp @@ -337,8 +337,9 @@ int Interface::activate() { _vm->_script->_skipSpeeches = false; _vm->_actor->_protagonist->_targetObject = ID_NOTHING; unlockMode(); - if (_panelMode == kPanelMain || _panelMode == kPanelChapterSelection){ - _saveReminderState = 1; + if (_panelMode == kPanelMain || _panelMode == kPanelChapterSelection) { + if (_vm->getGameId() != GID_IHNM_DEMO) + _saveReminderState = 1; } draw(); } @@ -383,9 +384,11 @@ void Interface::setMode(int mode) { if (mode == kPanelMain) { _inMainMode = true; - _saveReminderState = 1; //TODO: blinking timeout + if (_vm->getGameId() != GID_IHNM_DEMO) + _saveReminderState = 1; //TODO: blinking timeout } else if (mode == kPanelChapterSelection) { - _saveReminderState = 1; + if (_vm->getGameId() != GID_IHNM_DEMO) + _saveReminderState = 1; } else { if (mode == kPanelConverse) { _inMainMode = false; -- cgit v1.2.3 From 3d434b12335fd70659d5a99dd1dfe83b2145323f Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 28 Jul 2007 02:25:09 +0000 Subject: Fixed one of the incorrectly loaded palettes in Benny's part in the IHNM demo svn-id: r28255 --- engines/saga/animation.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/saga/animation.cpp b/engines/saga/animation.cpp index d29fc6ebe6..e9f3494cd2 100644 --- a/engines/saga/animation.cpp +++ b/engines/saga/animation.cpp @@ -94,7 +94,10 @@ void Anim::playCutaway(int cut, bool fade) { startImmediately = true; } - _vm->_gfx->savePalette(); + // WORKAROUND: The IHNM demo deals with chained cutaways in a different manner. Don't save + // the palette of cutaway 11 (the woman looking at the marble) + if (!(_vm->getGameId() == GID_IHNM_DEMO && cut == 11)) + _vm->_gfx->savePalette(); if (fade) { _vm->_gfx->getCurrentPal(saved_pal); -- cgit v1.2.3 From bb2796c57a5bd6cfb417340e6cfda141eee9342e Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Sat, 28 Jul 2007 07:52:24 +0000 Subject: Add support for multi-tune Protracker modules used in the Amiga version of Waxworks. svn-id: r28256 --- engines/agos/agos.cpp | 2 +- engines/agos/res_snd.cpp | 55 +++++++++++++++++++++++++++++++++++++--- engines/parallaction/disk.h | 8 +++--- engines/parallaction/disk_br.cpp | 2 +- engines/parallaction/disk_ns.cpp | 4 +-- engines/parallaction/sound.cpp | 2 +- 6 files changed, 60 insertions(+), 13 deletions(-) (limited to 'engines') diff --git a/engines/agos/agos.cpp b/engines/agos/agos.cpp index ba429b510c..76e4378982 100644 --- a/engines/agos/agos.cpp +++ b/engines/agos/agos.cpp @@ -820,7 +820,7 @@ void AGOSEngine_Waxworks::setupGame() { _numTextBoxes = 10; _numVars = 255; - _numMusic = 9; + _numMusic = 26; AGOSEngine::setupGame(); } diff --git a/engines/agos/res_snd.cpp b/engines/agos/res_snd.cpp index 779ed67e58..beea0de473 100644 --- a/engines/agos/res_snd.cpp +++ b/engines/agos/res_snd.cpp @@ -139,9 +139,56 @@ void AGOSEngine::loadMusic(uint16 music) { _nextMusicToPlay = -1; } +struct ModuleOffs { + uint8 tune; + uint8 fileNum; + uint32 offs; +}; + +static const ModuleOffs amigaWaxworksOffs[20] = { + // Pyramid + {2, 2, 0, }, + {3, 2, 50980}, + {4, 2, 56160}, + {5, 2, 62364}, + {6, 2, 73688}, + + // Zombie + {8, 8, 0}, + {11, 8, 51156}, + {12, 8, 56336}, + {13, 8, 65612}, + {14, 8, 68744}, + + // Mine + {9, 9, 0}, + {15, 9, 47244}, + {16, 9, 52424}, + {17, 9, 59652}, + {18, 9, 62784}, + + // Jack + {10, 10, 0}, + {19, 10, 42054}, + {20, 10, 47234}, + {21, 10, 49342}, + {22, 10, 51450}, +}; + void AGOSEngine::playModule(uint16 music) { char filename[15]; File f; + uint32 offs = 0; + + if (getPlatform() == Common::kPlatformAmiga && getGameType() == GType_WW) { + // Multiple tunes are stored in music files for main locations + for (uint i = 0; i < 20; i++) { + if (amigaWaxworksOffs[i].tune == music) { + music = amigaWaxworksOffs[i].fileNum; + offs = amigaWaxworksOffs[i].offs; + } + } + } if (getGameType() == GType_ELVIRA1 && getFeatures() & GF_DEMO) sprintf(filename, "elvira2"); @@ -159,21 +206,21 @@ void AGOSEngine::playModule(uint16 music) { if (!(getGameType() == GType_ELVIRA1 && getFeatures() & GF_DEMO) && getFeatures() & GF_CRUNCHED) { - uint srcSize = f.size(); + uint32 srcSize = f.size(); byte *srcBuf = (byte *)malloc(srcSize); if (f.read(srcBuf, srcSize) != srcSize) error("playModule: Read failed"); - uint dstSize = READ_BE_UINT32(srcBuf + srcSize - 4); + uint32 dstSize = READ_BE_UINT32(srcBuf + srcSize - 4); byte *dstBuf = (byte *)malloc(dstSize); decrunchFile(srcBuf, dstBuf, srcSize); free(srcBuf); Common::MemoryReadStream stream(dstBuf, dstSize); - audioStream = Audio::makeProtrackerStream(&stream, _mixer->getOutputRate()); + audioStream = Audio::makeProtrackerStream(&stream, offs); free(dstBuf); } else { - audioStream = Audio::makeProtrackerStream(&f, _mixer->getOutputRate()); + audioStream = Audio::makeProtrackerStream(&f); } _mixer->playInputStream(Audio::Mixer::kMusicSoundType, &_modHandle, audioStream); diff --git a/engines/parallaction/disk.h b/engines/parallaction/disk.h index d910201f27..ae572b1122 100644 --- a/engines/parallaction/disk.h +++ b/engines/parallaction/disk.h @@ -62,7 +62,7 @@ public: virtual void loadSlide(const char *filename) = 0; virtual void loadScenery(const char* background, const char* mask) = 0; virtual Table* loadTable(const char* name) = 0; - virtual Common::ReadStream* loadMusic(const char* name) = 0; + virtual Common::SeekableReadStream* loadMusic(const char* name) = 0; virtual Common::ReadStream* loadSound(const char* name) = 0; }; @@ -154,7 +154,7 @@ public: void loadSlide(const char *filename); void loadScenery(const char* background, const char* mask); Table* loadTable(const char* name); - Common::ReadStream* loadMusic(const char* name); + Common::SeekableReadStream* loadMusic(const char* name); Common::ReadStream* loadSound(const char* name); }; @@ -188,7 +188,7 @@ public: void loadSlide(const char *filename); void loadScenery(const char* background, const char* mask); Table* loadTable(const char* name); - Common::ReadStream* loadMusic(const char* name); + Common::SeekableReadStream* loadMusic(const char* name); Common::ReadStream* loadSound(const char* name); }; @@ -222,7 +222,7 @@ public: void loadSlide(const char *filename); void loadScenery(const char* background, const char* mask); Table* loadTable(const char* name); - Common::ReadStream* loadMusic(const char* name); + Common::SeekableReadStream* loadMusic(const char* name); Common::ReadStream* loadSound(const char* name); }; diff --git a/engines/parallaction/disk_br.cpp b/engines/parallaction/disk_br.cpp index 07d9954f23..452b74be51 100644 --- a/engines/parallaction/disk_br.cpp +++ b/engines/parallaction/disk_br.cpp @@ -119,7 +119,7 @@ Table* DosDisk_br::loadTable(const char* name) { return 0; } -Common::ReadStream* DosDisk_br::loadMusic(const char* name) { +Common::SeekableReadStream* DosDisk_br::loadMusic(const char* name) { debugC(5, kDebugDisk, "DosDisk_br::loadMusic"); return 0; } diff --git a/engines/parallaction/disk_ns.cpp b/engines/parallaction/disk_ns.cpp index bf9b0277cb..e500cd519b 100644 --- a/engines/parallaction/disk_ns.cpp +++ b/engines/parallaction/disk_ns.cpp @@ -674,7 +674,7 @@ Table* DosDisk_ns::loadTable(const char* name) { return t; } -Common::ReadStream* DosDisk_ns::loadMusic(const char* name) { +Common::SeekableReadStream* DosDisk_ns::loadMusic(const char* name) { char path[PATH_LEN]; sprintf(path, "%s.mid", name); @@ -1427,7 +1427,7 @@ Font* AmigaDisk_ns::loadFont(const char* name) { } -Common::ReadStream* AmigaDisk_ns::loadMusic(const char* name) { +Common::SeekableReadStream* AmigaDisk_ns::loadMusic(const char* name) { return openArchivedFile(name); } diff --git a/engines/parallaction/sound.cpp b/engines/parallaction/sound.cpp index 9976ec13a8..1026aa5f6a 100644 --- a/engines/parallaction/sound.cpp +++ b/engines/parallaction/sound.cpp @@ -379,7 +379,7 @@ void AmigaSoundMan::playMusic() { debugC(1, kDebugAudio, "AmigaSoundMan::playMusic()"); - Common::ReadStream *stream = _vm->_disk->loadMusic(_musicFile); + Common::SeekableReadStream *stream = _vm->_disk->loadMusic(_musicFile); _musicStream = Audio::makeProtrackerStream(stream); delete stream; -- cgit v1.2.3 From fb99c11af28f5f010d741992fd0fa54d1616dcff Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Sat, 28 Jul 2007 08:05:47 +0000 Subject: Switch error back to debug message, due to strange data in restart state files. svn-id: r28258 --- engines/agos/items.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/agos/items.cpp b/engines/agos/items.cpp index 13034b74c9..b2e722d681 100644 --- a/engines/agos/items.cpp +++ b/engines/agos/items.cpp @@ -382,8 +382,13 @@ int AGOSEngine::wordMatch(Item *item, int16 a, int16 n) { } Item *AGOSEngine::derefItem(uint item) { - if (item >= _itemArraySize) - error("derefItem: invalid item %d", item); + // Occurs when loading item store from restart state in + // Elvira 2 (Amiga/AtariST) and Waxworks (Amiga). + if (item >= _itemArraySize) { + debug(0, "derefItem: invalid item %d", item); + return NULL; + } + return _itemArrayPtr[item]; } -- cgit v1.2.3 From d79de5733b9bb5040b36f9da5f09c400e79ec9bd Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Sat, 28 Jul 2007 09:01:29 +0000 Subject: Add zone override table for Amiga verison of Waxworks. svn-id: r28259 --- engines/agos/zones.cpp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/agos/zones.cpp b/engines/agos/zones.cpp index a1de03e66c..d40e1da1de 100644 --- a/engines/agos/zones.cpp +++ b/engines/agos/zones.cpp @@ -44,6 +44,25 @@ void AGOSEngine::unfreezeBottom() { _vgaFrozenBase = _vgaRealBase; } +static const uint8 zoneTable[160] = { + 0, 0, 2, 2, 2, 2, 0, 2, 2, 2, + 3, 0, 0, 0, 0, 0, 0, 0, 1, 0, + 3, 3, 3, 1, 3, 0, 0, 0, 1, 0, + 2, 0, 3, 0, 3, 3, 0, 1, 1, 0, + 1, 2, 2, 2, 0, 2, 2, 2, 0, 2, + 1, 2, 2, 2, 0, 2, 2, 2, 2, 2, + 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 0, 2, 0, 3, 2, 2, 2, 3, + 2, 3, 3, 3, 1, 3, 3, 1, 1, 0, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 0, 0, 2, 2, 0, + 0, 2, 0, 2, 2, 2, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, + 2, 0, 2, 0, 0, 2, 2, 0, 2, 2, + 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, +}; + void AGOSEngine::loadZone(uint16 zoneNum) { VgaPointersEntry *vpe; @@ -56,7 +75,13 @@ void AGOSEngine::loadZone(uint16 zoneNum) { // Loading order is important // due to resource managment - loadVGAVideoFile(zoneNum, 2); + if (getPlatform() == Common::kPlatformAmiga && getGameType() == GType_WW && + zoneTable[zoneNum] == 3) { + uint8 num = (zoneNum >= 85) ? 94 : 18; + loadVGAVideoFile(num, 2); + } else { + loadVGAVideoFile(zoneNum, 2); + } vpe->vgaFile2 = _block; vpe->vgaFile2End = _blockEnd; -- cgit v1.2.3 From d6fd87fd6a31676decec39d98b4d5d0aa579bc4f Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Sat, 28 Jul 2007 09:14:05 +0000 Subject: Add save code differences in Amiga verison of Waxworks. svn-id: r28260 --- engines/agos/saveload.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/agos/saveload.cpp b/engines/agos/saveload.cpp index 44fc35d6ac..adeaa35b9f 100644 --- a/engines/agos/saveload.cpp +++ b/engines/agos/saveload.cpp @@ -1338,7 +1338,8 @@ bool AGOSEngine_Elvira2::saveGame(uint slot, const char *caption) { for (num_item = _itemArrayInited - 1; num_item; num_item--) { Item *item = _itemArrayPtr[item_index++]; - if (getGameType() == GType_ELVIRA2) { + if ((getGameType() == GType_WW && getPlatform() == Common::kPlatformAmiga) || + getGameType() == GType_ELVIRA2) { writeItemID(f, item->parent); } else { f->writeUint16BE(item->parent); -- cgit v1.2.3 From 488d9f3b435b345ba5176f4489ad043006e9069a Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Sat, 28 Jul 2007 09:16:44 +0000 Subject: Add save code differences in Amiga verison of Waxworks. svn-id: r28261 --- engines/agos/saveload.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/agos/saveload.cpp b/engines/agos/saveload.cpp index adeaa35b9f..3715088ee7 100644 --- a/engines/agos/saveload.cpp +++ b/engines/agos/saveload.cpp @@ -1326,7 +1326,7 @@ bool AGOSEngine_Elvira2::saveGame(uint slot, const char *caption) { f->writeUint16BE(te->subroutine_id); } - if (getGameType() == GType_WW) { + if (getGameType() == GType_WW && getPlatform() == Common::kPlatformPC) { // TODO Save room state data for (uint s = 0; s <= _numRoomStates; s++) { f->writeUint16BE(0); -- cgit v1.2.3 From 603bd238d11e2b4253a9a9cf74648da24b161422 Mon Sep 17 00:00:00 2001 From: Paweł Kołodziejski Date: Sat, 28 Jul 2007 09:45:05 +0000 Subject: cleanup white spaces from 'jvprat' svn-id: r28262 --- engines/drascula/drascula.cpp | 392 +++++++++++++++++++++--------------------- engines/drascula/texts.h | 6 +- 2 files changed, 199 insertions(+), 199 deletions(-) (limited to 'engines') diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp index 38ebd0e3a8..042f5944bf 100644 --- a/engines/drascula/drascula.cpp +++ b/engines/drascula/drascula.cpp @@ -99,7 +99,7 @@ static int x_pol[44] = {0, 1, 42, 83, 124, 165, 206, 247, 83, 1, 206, 83, 165, 1, 206, 42, 124, 83, 1, 247, 42, 1, 165, 206}; static int y_pol[44] = {0, 1, 1, 1, 1, 1, 1, 1, 27, 27, 1, - 27, 27, 27, 27, 27, 27, 27, 1, 1, 27, + 27, 27, 27, 27, 27, 27, 27, 1, 1, 27, 1, 1, 1, 1, 1, 27, 27, 27, 27, 27, 1, 1, 1, 1, 1, 27, 27, 27, 27, 27, 27, 1, 1}; @@ -169,10 +169,10 @@ int DrasculaEngine::init() { int DrasculaEngine::go() { lee_dibujos("95.alg"); - descomprime_dibujo(dir_mesa, 1); + descomprime_dibujo(dir_mesa, 1); lee_dibujos("96.alg"); - descomprime_dibujo(dir_hare_frente, COMPLETA); + descomprime_dibujo(dir_hare_frente, COMPLETA); lee_dibujos("99.alg"); descomprime_dibujo(dir_hare_fondo, 1); lee_dibujos("97.alg"); @@ -186,7 +186,7 @@ int DrasculaEngine::go() { strcpy(nombre_icono[6], "push"); paleta_hare(); - escoba(); + escoba(); return 0; } @@ -376,7 +376,7 @@ void DrasculaEngine::DIBUJA_BLOQUE_CUT(int *Array, char *Origen, char *Destino) if (ydes < 0) { yorg += -ydes; Alto += ydes; - ydes = 0; + ydes = 0; } if (xdes < 0) { xorg += -xdes; @@ -411,7 +411,7 @@ void DrasculaEngine::VUELCA_PANTALLA(int xorg, int yorg, int xdes, int ydes, int g_system->copyRectToScreen((const byte *)VGA, 320, 0, 0, 320, 200); } -void DrasculaEngine::escoba() { +void DrasculaEngine::escoba() { int soc, l, n; dir_texto = dir_mesa; @@ -421,7 +421,7 @@ void DrasculaEngine::escoba() { soc = 0; for (l = 0; l < 6; l++) { soc=soc+ANCHO_PERSONAJE; - frame_x[l]=soc; + frame_x[l]=soc; } for (n = 1; n < 43; n++) @@ -429,7 +429,7 @@ void DrasculaEngine::escoba() { for (n = 0; n < NUM_BANDERAS; n++) flags[n] = 0; - + for (n = 1; n < 7; n++) objetos_que_tengo[n] = n; @@ -493,15 +493,15 @@ bucles: sin_verbo(); cont_sv = 0; } - + if (boton_izq == 1 && menu_bar == 1) { elige_en_barra(); cont_sv = 0; } else if (boton_izq == 1 && lleva_objeto == 0) { - comprueba1(); + comprueba1(); cont_sv = 0; } else if (boton_izq == 1 && lleva_objeto == 1) { - comprueba2(); + comprueba2(); cont_sv = 0; } @@ -512,7 +512,7 @@ bucles: key = getscan(); if (key == F1 && menu_scr == 0) { - elige_verbo(1); + elige_verbo(1); cont_sv = 0; } else if (key == F2 && menu_scr == 0) { elige_verbo(2); @@ -573,31 +573,31 @@ void DrasculaEngine::agarra_objeto(int objeto) { void DrasculaEngine::elige_objeto(int objeto) { if (lleva_objeto == 1 && menu_scr == 0) - suma_objeto(objeto_que_lleva); + suma_objeto(objeto_que_lleva); DIBUJA_FONDO(x1d_menu[objeto], y1d_menu[objeto], 0, 0, ANCHOBJ,ALTOBJ, dir_hare_fondo, dir_dibujo3); lleva_objeto = 1; objeto_que_lleva = objeto; } int DrasculaEngine::resta_objeto(int osj) { - int h, q = 0; + int h, q = 0; - for (h = 1; h < 43; h++) { + for (h = 1; h < 43; h++) { if (objetos_que_tengo[h] == osj) { objetos_que_tengo[h] = 0; q = 1; break; } } - - if (q == 1) + + if (q == 1) return 0; - else + else return 1; } void DrasculaEngine::animacion_1() { - int l, l2, p; + int l, l2, p; int pos_pixel[6]; while (term_int == 0) { @@ -668,7 +668,7 @@ void DrasculaEngine::animacion_1() { borra_pantalla(); lee_dibujos("96.alg"); - descomprime_dibujo(dir_hare_frente, COMPLETA); + descomprime_dibujo(dir_hare_frente, COMPLETA); lee_dibujos("103.alg"); descomprime_dibujo(dir_dibujo1, MEDIA); lee_dibujos("104.alg"); @@ -679,7 +679,7 @@ void DrasculaEngine::animacion_1() { playmusic(4); if ((term_int == 1) || (getscan() == ESC)) break; - delay(400); + delay(400); if ((term_int == 1) || (getscan() == ESC)) break; @@ -709,11 +709,11 @@ void DrasculaEngine::animacion_1() { pos_pixel[0] = interf_x[l2]; pos_pixel[1] = interf_y[l2]; pos_pixel[2] = 156 - l; - + DIBUJA_BLOQUE_CUT(pos_pixel, dir_dibujo2, dir_zona_pantalla); VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); p++; - if (p == 6) { + if (p == 6) { p = 0; l2++; } @@ -754,7 +754,7 @@ void DrasculaEngine::animacion_1() { habla_igor_dch(TEXTI8, "I8.als"); if ((term_int == 1) || (getscan() == ESC)) break; - DIBUJA_FONDO(0, 0, 0,0, 320, 200, dir_dibujo1, dir_zona_pantalla); + DIBUJA_FONDO(0, 0, 0,0, 320, 200, dir_dibujo1, dir_zona_pantalla); pon_igor(); pon_dr(); VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); @@ -886,7 +886,7 @@ void DrasculaEngine::animacion_1() { VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); pausa(1); sentido_dr = 1; - DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); pon_igor(); pon_dr(); VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); @@ -898,7 +898,7 @@ void DrasculaEngine::animacion_1() { if ((term_int == 1) || (getscan() == ESC)) break; sentido_dr = 3; - DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); pon_igor(); pon_dr(); VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); @@ -948,7 +948,7 @@ void DrasculaEngine::animacion_1() { } borra_pantalla(); lee_dibujos("96.alg"); - descomprime_dibujo(dir_hare_frente, COMPLETA); + descomprime_dibujo(dir_hare_frente, COMPLETA); lee_dibujos("99.alg"); descomprime_dibujo(dir_hare_fondo, 1); } @@ -986,7 +986,7 @@ void DrasculaEngine::animacion_2() { pausa(4); comienza_sound("s1.als"); hipo(18); - fin_sound(); + fin_sound(); if ((term_int == 1) || (getscan() == ESC)) break; @@ -1058,7 +1058,7 @@ void DrasculaEngine::animacion_2() { sentido_hare = 1; hare_x = 100; hare_y = 95; - + habla_bj(TEXTBJ2, "BJ2.als"); hablar(TEXT215, "215.als"); habla_bj(TEXTBJ3, "BJ3.als"); @@ -1181,7 +1181,7 @@ void DrasculaEngine::para_cargar(char nom_game[]) { } void DrasculaEngine::carga_escoba(const char *nom_fich) { - int l, obj_salir; + int l, obj_salir; float chiquez, pequegnez = 0; char para_codificar[13]; @@ -1194,8 +1194,8 @@ void DrasculaEngine::carga_escoba(const char *nom_fich) { buffer_teclado(); // TODO - if ((ald = fopen(nom_fich, "rb")) == NULL) { - error("missing data file"); + if ((ald = fopen(nom_fich, "rb")) == NULL) { + error("missing data file"); } fscanf(ald, "%s", num_room); strcat(num_room,".alg"); @@ -1242,9 +1242,9 @@ void DrasculaEngine::carga_escoba(const char *nom_fich) { if (num_obj[l] == obj_saliendo) obj_salir = l; } - + lee_dibujos(pantalla_disco); - descomprime_dibujo(dir_dibujo3, 1); + descomprime_dibujo(dir_dibujo3, 1); lee_dibujos(num_room); descomprime_dibujo(dir_dibujo1, MEDIA); @@ -1268,7 +1268,7 @@ void DrasculaEngine::carga_escoba(const char *nom_fich) { factor_red[l] = cerca; chiquez = (float)(cerca-lejos) / (float)(suelo_y2 - suelo_y1); - for (l = suelo_y1; l <= suelo_y2; l++){ + for (l = suelo_y1; l <= suelo_y2; l++) { factor_red[l] = lejos + pequegnez; pequegnez = pequegnez + chiquez; } @@ -1279,18 +1279,18 @@ void DrasculaEngine::carga_escoba(const char *nom_fich) { alto_hare = (ALTO_PERSONAJE * factor_red[hare_y]) / 100; ancho_hare = (ANCHO_PERSONAJE * factor_red[hare_y]) / 100; hare_y = hare_y - alto_hare; - } else { + } else { alto_hare = (ALTO_PERSONAJE * factor_red[hare_y]) / 100; ancho_hare = (ANCHO_PERSONAJE * factor_red[hare_y]) / 100; } hare_se_mueve=0; - + actualiza_datos(); espuerta[7] = 0; if (musica_antes != musica_room) - playmusic(musica_room); + playmusic(musica_room); refresca_pantalla(); } @@ -1361,13 +1361,13 @@ void DrasculaEngine::comprueba_objetos() { veo=1; } } - + if (x_raton > hare_x + 2 && y_raton > hare_y + 2 && x_raton < hare_x + ancho_hare - 2 && y_raton < hare_y + alto_hare - 2 && veo == 0) { strcpy(texto_nombre, "hacker"); hay_nombre=1; veo=1; - } + } if (veo == 0) hay_nombre = 0; @@ -1406,7 +1406,7 @@ void DrasculaEngine::comprueba1() { int l; if (menu_scr == 1) - saca_objeto(); + saca_objeto(); else { for (l = 0; l < objs_room; l++) { if (x_raton >= x1[l] && y_raton >= y1[l] @@ -1418,7 +1418,7 @@ void DrasculaEngine::comprueba1() { } if (x_raton > hare_x && y_raton > hare_y - && x_raton < hare_x + ancho_hare && y_raton < hare_y + alto_hare) + && x_raton < hare_x + ancho_hare && y_raton < hare_y + alto_hare) rompo = 1; for (l = 0; l < objs_room; l++) { @@ -1465,18 +1465,18 @@ void DrasculaEngine::comprueba2() { if (x_raton > x1[l] && y_raton > y1[l] && x_raton < x2[l] && y_raton < y2[l] && visible[l] == 1) { sentido_final = sentidobj[l]; - anda_a_objeto = 1; + anda_a_objeto = 1; lleva_al_hare(sitiobj_x[l], sitiobj_y[l]); banderas(num_obj[l]); - } + } } - } + } } char DrasculaEngine::getscan() { // TODO return 0; -} +} void DrasculaEngine::elige_verbo(int verbo) { int c = 171; @@ -1506,7 +1506,7 @@ void DrasculaEngine::mesa() { refresca_pantalla(); DIBUJA_BLOQUE(1, 56, 73, 63, 177, 97, dir_mesa, dir_zona_pantalla); - + DIBUJA_FONDO(183, 56, 82, nivel_master, 39, 2 + (12/*Master*/ * 4), dir_mesa, dir_zona_pantalla); DIBUJA_FONDO(183, 56, 138, nivel_voc, 39, 2 + (12/*Voc*/ * 4), dir_mesa, dir_zona_pantalla); DIBUJA_FONDO(183, 56, 194, nivel_cd, 39, 2 + (10/*CD*/ * 4), dir_mesa, dir_zona_pantalla); @@ -1533,7 +1533,7 @@ void DrasculaEngine::mesa() { // TODO // if (y_raton < nivel_voc && Voc < 15) // Voc++; -// if (y_raton > nivel_voc && Voc > 0) +// if (y_raton > nivel_voc && Voc > 0) // Voc--; // SetVocVolume(Voc); } @@ -1590,7 +1590,7 @@ void DrasculaEngine::saves() { if (boton_izq == 1) { for (n = 0; n < NUM_SAVES; n++) { if (x_raton > 115 && y_raton > y + (9 * n) && x_raton < 115 + 175 && y_raton < y + 10 + (9 * n)) { - strcpy(select, nombres[n]); + strcpy(select, nombres[n]); if (strcmp(select, "*")) hay_seleccion = 1; @@ -1618,7 +1618,7 @@ void DrasculaEngine::saves() { strcpy(fichero, "gsave09"); if (n == 9) strcpy(fichero, "gsave10"); - para_grabar(fichero); + para_grabar(fichero); // TODO if ((sav = fopen("saves.epa", "w")) == NULL) { error("no puedo abrir el archivo de partidas."); @@ -1656,7 +1656,7 @@ void DrasculaEngine::saves() { strcpy(fichero, "gsave09"); if (n == 9) strcpy(fichero, "gsave10");} - num_sav = n; + num_sav = n; } } @@ -1674,8 +1674,8 @@ void DrasculaEngine::saves() { if (x_raton > 125 && y_raton > 123 && x_raton < 199 && y_raton < 149 && hay_seleccion == 1) { para_cargar(fichero); break; - } else if (x_raton > 208 && y_raton > 123 && x_raton < 282 && y_raton < 149 && hay_seleccion == 1) { - para_grabar(fichero); + } else if (x_raton > 208 && y_raton > 123 && x_raton < 282 && y_raton < 149 && hay_seleccion == 1) { + para_grabar(fichero); if ((sav = fopen("saves.epa", "w")) == NULL) { error("no puedo abrir el archivo de partidas."); } @@ -1903,7 +1903,7 @@ void DrasculaEngine::print_abc(const char *dicho, int x_pantalla, int y_pantalla x_de_letra = X_N; else if (dicho[h] == '') x_de_letra = X_GN; - } + } */ pos_texto[0] = x_de_letra; pos_texto[1] = y_de_letra; @@ -1929,7 +1929,7 @@ void DrasculaEngine::delay(int ms) { void DrasculaEngine::confirma_go() { color_abc(ROJO); refresca_pantalla(); - centra_texto(SYS0, 160, 87); + centra_texto(SYS0, 160, 87); VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); for (;;) { @@ -1947,12 +1947,12 @@ void DrasculaEngine::confirma_go() { void DrasculaEngine::confirma_salir() { color_abc(ROJO); refresca_pantalla(); - centra_texto(SYS1, 160, 87); + centra_texto(SYS1, 160, 87); VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); for (;;) { key = getscan(); - if (key != 0) + if (key != 0) break; } @@ -2153,8 +2153,8 @@ imprimir: } void DrasculaEngine::comienza_sound(const char *fichero) { - if (hay_sb == 1) { - if ((sku = fopen(fichero, "rb")) == NULL) { + if (hay_sb == 1) { + if ((sku = fopen(fichero, "rb")) == NULL) { error("no puedo abrir archivo de voz"); } } @@ -2284,7 +2284,7 @@ void DrasculaEngine::habla_dr_grande(const char *dicho, const char *filename) { bucless: cara = rand() % 4; - DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); DIBUJA_FONDO(interf_x[l] + 24, interf_y[l], 0, 45, 39, 31, dir_dibujo2, dir_zona_pantalla); DIBUJA_FONDO(x_habla[cara], 1, 171, 68, 45, 48, dir_dibujo2, dir_zona_pantalla); l++; @@ -2314,7 +2314,7 @@ bucless: longitud = longitud - 2; if (longitud > 0) goto bucless; - } + } } void DrasculaEngine::pon_igor() { @@ -2355,15 +2355,15 @@ void DrasculaEngine::pon_bj() { int pos_bj[6]; if (sentido_bj == 3) - pos_bj[0] = 10; + pos_bj[0] = 10; else if (sentido_bj == 0) - pos_bj[0] = 37; + pos_bj[0] = 37; pos_bj[1] = 99; - pos_bj[2] = x_bj; - pos_bj[3] = y_bj; - pos_bj[4] = 26; - pos_bj[5] = 76; - + pos_bj[2] = x_bj; + pos_bj[3] = y_bj; + pos_bj[4] = 26; + pos_bj[5] = 76; + DIBUJA_BLOQUE_CUT(pos_bj, dir_dibujo3, dir_zona_pantalla); } @@ -2373,12 +2373,12 @@ void DrasculaEngine::habla_igor_dch(const char *dicho, const char *filename) { int x_habla[8] = { 56, 82, 108, 134, 160, 186, 212, 238}; int cara; - + int longitud; longitud = strlen(dicho); tiempol = time (NULL); - tiempou = (unsigned int)tiempol / 2; + tiempou = (unsigned int)tiempol / 2; srand(tiempou); buffer_teclado(); @@ -2419,7 +2419,7 @@ bucless: VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); pausa(3); - + key = getscan(); if (key == ESC) term_int = 1; @@ -2435,7 +2435,7 @@ bucless: longitud = longitud - 2; if (longitud > 0) goto bucless; - } + } DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); pon_igor(); pon_dr(); @@ -2448,7 +2448,7 @@ void DrasculaEngine::habla_dr_izq(const char *dicho, const char *filename) { int x_habla[8] = { 1, 40, 79, 118, 157, 196, 235, 274 }; int cara; - + int longitud; longitud = strlen(dicho); @@ -2460,7 +2460,7 @@ void DrasculaEngine::habla_dr_izq(const char *dicho, const char *filename) { color_abc(ROJO); - if (hay_sb == 1) { + if (hay_sb == 1) { // TODO if ((sku = fopen(filename, "rb")) == NULL) { error("no puedo abrir archivo de voz"); @@ -2483,7 +2483,7 @@ bucless: DIBUJA_FONDO(x_dr, y_dr, x_dr, y_dr, 38, 31, dir_dibujo1, dir_zona_pantalla); DIBUJA_BLOQUE(x_habla[cara], 90, x_dr, y_dr, 38, 31, - dir_hare_fondo, dir_zona_pantalla); + dir_hare_fondo, dir_zona_pantalla); actualiza_refresco(); @@ -2509,7 +2509,7 @@ bucless: longitud = longitud - 2; if (longitud > 0) goto bucless; - } + } DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); pon_igor(); @@ -2605,7 +2605,7 @@ void DrasculaEngine::habla_solo(const char *dicho, const char *filename) { color_abc(color_solo); - if (hay_sb == 1) { + if (hay_sb == 1) { // TODO if ((sku = fopen(filename, "rb")) == NULL) { error("no puedo abrir archivo de voz"); @@ -2672,7 +2672,7 @@ bucless: cara = rand() % 8; DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); - + actualiza_refresco_antes(); pon_igor(); @@ -2777,7 +2777,7 @@ bucless: longitud = longitud - 2; if (longitud > 0) goto bucless; - } + } refresca_pantalla(); VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); @@ -2791,7 +2791,7 @@ void DrasculaEngine::hipo(int contador) { comienza: contador--; - refresca_pantalla(); + refresca_pantalla(); VUELCA_PANTALLA(0, 1, 0, y, 320, 198, dir_zona_pantalla); if (sentido == 0) @@ -2810,7 +2810,7 @@ comienza: } void DrasculaEngine::fin_sound() { - delay(1); + delay(1); if (hay_sb == 1) { while (LookForFree() != 0); @@ -2884,7 +2884,7 @@ bucless: longitud = longitud - 2; if (longitud > 0) goto bucless; - } + } refresca_pantalla(); VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); @@ -2930,12 +2930,12 @@ bucless: actualiza_refresco_antes(); DIBUJA_FONDO(hare_x, hare_y, ANCHOBJ+1, 0, - ((float)ancho_hare / 100) * factor_red[hare_y + alto_hare], - ((float)(alto_habla - 1) / 100) * factor_red[hare_y + alto_hare], - dir_zona_pantalla, dir_dibujo3); + ((float)ancho_hare / 100) * factor_red[hare_y + alto_hare], + ((float)(alto_habla - 1) / 100) * factor_red[hare_y + alto_hare], + dir_zona_pantalla, dir_dibujo3); pon_hare(); - - DIBUJA_FONDO(ANCHOBJ + 1, 0, hare_x, hare_y, + + DIBUJA_FONDO(ANCHOBJ + 1, 0, hare_x, hare_y, ((float)ancho_hare / 100) * factor_red[hare_y + alto_hare], ((float)(alto_habla - 1) / 100) * factor_red[hare_y + alto_hare], dir_dibujo3, dir_zona_pantalla); @@ -2989,7 +2989,7 @@ bucless: longitud = longitud - 2; if (longitud > 0) goto bucless; - } + } refresca_pantalla(); VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); @@ -3016,19 +3016,19 @@ void DrasculaEngine::playmusic(int p) { */ } -void DrasculaEngine::stopmusic() { +void DrasculaEngine::stopmusic() { //TODO /* unsigned short v; cd_stop_audio (); /v=GetCDVolume(); if (reducido) - { - SetCDVolume(v+2); - reducido=0; - } - cd_done_play (); - Playing=0; + { + SetCDVolume(v+2); + reducido=0; + } + cd_done_play (); + Playing=0; */ } @@ -3181,20 +3181,20 @@ void DrasculaEngine::empieza_andar() { paso_y = PASO_HARE_Y; if ((sitio_x < hare_x + ancho_hare / 2 ) && (sitio_y <= (hare_y + alto_hare))) - cuadrante_1(); + cuadrante_1(); else if ((sitio_x < hare_x + ancho_hare / 2) && (sitio_y > (hare_y + alto_hare))) - cuadrante_3(); + cuadrante_3(); else if ((sitio_x > hare_x + ancho_hare / 2) && (sitio_y <= (hare_y + alto_hare))) - cuadrante_2(); + cuadrante_2(); else if ((sitio_x > hare_x + ancho_hare / 2) && (sitio_y > (hare_y + alto_hare))) - cuadrante_4(); + cuadrante_4(); else hare_se_mueve=0; conta_vez = vez(); } -void DrasculaEngine::actualiza_refresco() { +void DrasculaEngine::actualiza_refresco() { if (!strcmp(num_room, "63.alg")) refresca_63(); else if (!strcmp(num_room, "62.alg")) @@ -3229,7 +3229,7 @@ void DrasculaEngine::pon_hare() { } } if (hare_se_mueve == 1 && paso_y == PASO_HARE_Y) { - for (r = 0; r < paso_y; r++) { + for (r = 0; r < paso_y; r++) { if (sentido_hare == 2 && sitio_y - r == hare_y + alto_hare) { hare_se_mueve = 0; paso_x = PASO_HARE_X; @@ -3244,7 +3244,7 @@ void DrasculaEngine::pon_hare() { } if (hare_se_ve == 0) - goto no_vuelco; + goto no_vuelco; if (hare_se_mueve == 0) { pos_hare[0] = 0; @@ -3273,7 +3273,7 @@ void DrasculaEngine::pon_hare() { pos_hare[4], pos_hare[5], factor_red[hare_y + alto_hare], dir_hare_fondo, dir_zona_pantalla); - else + else reduce_hare_chico( pos_hare[0], pos_hare[1], pos_hare[2], pos_hare[3], pos_hare[4], pos_hare[5], @@ -3305,7 +3305,7 @@ void DrasculaEngine::pon_hare() { pos_hare[4], pos_hare[5], factor_red[hare_y + alto_hare], dir_hare_fondo, dir_zona_pantalla); - else + else reduce_hare_chico(pos_hare[0], pos_hare[1], pos_hare[2], pos_hare[3], pos_hare[4], pos_hare[5], @@ -3316,20 +3316,20 @@ no_vuelco: aumenta_num_frame(); } } - + void DrasculaEngine::menu_sin_volcar() { int h, n, x; char texto_icono[13]; - + x = sobre_que_objeto(); strcpy(texto_icono, nombre_icono[x]); - + for (n = 1; n < 43; n++) { h = objetos_que_tengo[n]; if (h != 0) DIBUJA_FONDO(x_pol[n], y_pol[n], x_obj[n], y_obj[n], - ANCHOBJ, ALTOBJ, dir_hare_frente, dir_zona_pantalla); + ANCHOBJ, ALTOBJ, dir_hare_frente, dir_zona_pantalla); DIBUJA_BLOQUE(x1d_menu[h], y1d_menu[h], x_obj[n], y_obj[n], ANCHOBJ, ALTOBJ, dir_hare_fondo, dir_zona_pantalla); @@ -3346,8 +3346,8 @@ void DrasculaEngine::barra_menu() { if (x_raton > x_barra[n] && x_raton < x_barra[n + 1]) sobre_verbo = 0; DIBUJA_BLOQUE(ANCHOBJ * n, ALTOBJ * sobre_verbo, - x_barra[n], 2, ANCHOBJ, ALTOBJ, - dir_hare_fondo, dir_zona_pantalla); + x_barra[n], 2, ANCHOBJ, ALTOBJ, + dir_hare_fondo, dir_zona_pantalla); sobre_verbo = 1; } } @@ -3374,17 +3374,17 @@ void DrasculaEngine::saca_objeto() { void DrasculaEngine::sal_de_la_habitacion(int l) { char salgo[13]; - + if (num_obj[l] == 105 && flags[0] == 0) hablar(TEXT442, "442.als"); else { puertas_cerradas(l); if (espuerta[l] != 0) { - lleva_al_hare(sitiobj_x[l], sitiobj_y[l]); + lleva_al_hare(sitiobj_x[l], sitiobj_y[l]); sentido_hare = sentidobj[l]; refresca_pantalla(); - VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); hare_se_mueve = 0; sentido_hare = sentido_alkeva[l]; obj_saliendo = alapuertakeva[l]; @@ -3427,7 +3427,7 @@ usando_verbos: if (comprueba_flags == 1) { comprueba_banderas_menu(); } - espera_soltar(); + espera_soltar(); if (lleva_objeto == 0) sin_verbo(); } @@ -3443,7 +3443,7 @@ void DrasculaEngine::banderas(int fl) { if (objeto_que_lleva == MIRAR && fl == 28) hablar(TEXT328, "328.als"); - } else { + } else { if (objeto_que_lleva == MIRAR && fl == 50) hablar(TEXT308, "308.als"); else if (objeto_que_lleva == ABRIR && fl == 50) @@ -3453,20 +3453,20 @@ void DrasculaEngine::banderas(int fl) { else if (objeto_que_lleva == MOVER && fl == 50) hablar(TEXT312, "312.als" ); else if (objeto_que_lleva == COGER && fl == 50) - hablar(TEXT313, "313.als" ); + hablar(TEXT313, "313.als" ); else if (objeto_que_lleva == HABLAR && fl == 50) hablar(TEXT314,"314.als" ); else if (!strcmp(num_room, "62.alg")) - pantalla_62(fl); + pantalla_62(fl); else if (!strcmp(num_room, "63.alg")) - pantalla_63(fl); + pantalla_63(fl); else hay_respuesta = 0; } if (hay_respuesta == 0 && hay_nombre == 1) pantalla_0(); else if (hay_respuesta == 0 && menu_scr == 1) - pantalla_0(); + pantalla_0(); } void DrasculaEngine::cursor_mesa() { @@ -3492,7 +3492,7 @@ void DrasculaEngine::introduce_nombre() { select2[v] = '-'; DIBUJA_FONDO(115, 14, 115, 14, 176, 9, dir_dibujo1, dir_zona_pantalla); print_abc(select2, 117, 15); - VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); key = getscan(); if (key != 0) { /* if (key == 16) @@ -3578,7 +3578,7 @@ void DrasculaEngine::introduce_nombre() { h = 1; break; } else if (key == 0x0E) - select2[v] = '\0'; + select2[v] = '\0'; else v--; */ @@ -3636,7 +3636,7 @@ int DrasculaEngine::PlayFrameSSN() { mSesion += 1; } switch (CHUNK) { - case SET_PALET: + case SET_PALET: if (!UsingMem) Sesion->read(dacSSN, 768); else { @@ -3645,19 +3645,19 @@ int DrasculaEngine::PlayFrameSSN() { } set_dacSSN(dacSSN); break; - case EMPTY_FRAME: + case EMPTY_FRAME: WaitFrameSSN(); break; - case INIT_FRAME: + case INIT_FRAME: if (!UsingMem) { Sesion->read(&CMP, 1); - Sesion->read(&Lengt, 4); + Sesion->read(&Lengt, 4); } else { memcpy(&CMP, mSesion, 1); mSesion += 1; memcpy(&Lengt, mSesion, 4); mSesion += 4; - } + } if (CMP == CMP_RLE) { if (!UsingMem) { BufferSSN = (char *)malloc(Lengt); @@ -3666,7 +3666,7 @@ int DrasculaEngine::PlayFrameSSN() { BufferSSN = (char *)malloc(Lengt); memcpy(BufferSSN, mSesion, Lengt); mSesion += Lengt; - } + } Des_RLE(BufferSSN, MiVideoSSN); free(BufferSSN); if (FrameSSN) { @@ -3680,7 +3680,7 @@ int DrasculaEngine::PlayFrameSSN() { } FrameSSN++; } else { - if (CMP == CMP_OFF) { + if (CMP == CMP_OFF) { if (!UsingMem) { BufferSSN = (char *)malloc(Lengt); Sesion->read(BufferSSN, Lengt); @@ -3689,7 +3689,7 @@ int DrasculaEngine::PlayFrameSSN() { memcpy(BufferSSN, mSesion, Lengt); mSesion += Lengt; } - Des_OFF(BufferSSN, MiVideoSSN, Lengt); + Des_OFF(BufferSSN, MiVideoSSN, Lengt); free(BufferSSN); if (FrameSSN) { WaitFrameSSN(); @@ -3728,9 +3728,9 @@ char *DrasculaEngine::TryInMem(Common::File *Sesion) { int Lengt; Sesion->seek(0, SEEK_END); - Lengt = Sesion->pos(); + Lengt = Sesion->pos(); Sesion->seek(0, SEEK_SET); - pointer = (char *)malloc(Lengt); + pointer = (char *)malloc(Lengt); if (pointer == NULL) return NULL; Sesion->read(pointer, Lengt); @@ -3747,12 +3747,12 @@ void DrasculaEngine::set_dacSSN(char *dacSSN) { while (inp(0x3da)&8){}; while ((inp(0x3da)&8)==0){}; - outp(0x3c8,0); - do { - outp(0x3c9,dacSSN[n++]); - outp(0x3c9,dacSSN[n++]); - outp(0x3c9,dacSSN[n++]); - } while (n<768); + outp(0x3c8,0); + do { + outp(0x3c9,dacSSN[n++]); + outp(0x3c9,dacSSN[n++]); + outp(0x3c9,dacSSN[n++]); + } while (n<768); */ } @@ -3792,7 +3792,7 @@ void DrasculaEngine::Des_RLE(char *BufferRLE, char *MiVideoRLE) { void DrasculaEngine::MixVideo(char *OldScreen,char *NewScreen) { int x; - for (x = 0; x < 64000; x++) + for (x = 0; x < 64000; x++) OldScreen[x] ^= NewScreen[x]; } @@ -3806,10 +3806,10 @@ int DrasculaEngine::chkkey() { /* union REGS registros; - registros.h.ah=0x06; - registros.h.dl=0xff; - intdos(®istros,®istros); - return(registros.h.al); + registros.h.ah=0x06; + registros.h.dl=0xff; + intdos(®istros,®istros); + return(registros.h.al); */ return 0; } @@ -3835,7 +3835,7 @@ char *DrasculaEngine::carga_pcx(char *NamePcc) { X++; if (X > 64000) fExit = 1; - } + } } return AuxBuffDes; } @@ -3866,9 +3866,9 @@ float DrasculaEngine::vez() { float trasvase; union REGS in, out; - in.h.ah=0; - int386(0x1A,&in,&out); - trasvase=((out.w.cx*65536)+out.w.dx)/0.182; + in.h.ah=0; + int386(0x1A,&in,&out); + trasvase=((out.w.cx*65536)+out.w.dx)/0.182; return(trasvase); */ return 0; @@ -3878,7 +3878,7 @@ void DrasculaEngine::reduce_hare_chico(int x1,int y1, int x2,int y2, int ancho,i float suma_x, suma_y; int n, m; float pixel_x, pixel_y; - int pos_pixel[6]; + int pos_pixel[6]; nuevo_ancho = (ancho * factor) / 100; nuevo_alto = (alto * factor) / 100; @@ -3891,16 +3891,16 @@ void DrasculaEngine::reduce_hare_chico(int x1,int y1, int x2,int y2, int ancho,i for (n = 0;n < nuevo_alto; n++){ for (m = 0; m < nuevo_ancho; m++){ - pos_pixel[0] = pixel_x; - pos_pixel[1] = pixel_y; - pos_pixel[2] = x2 + m; - pos_pixel[3] = y2 + n; - pos_pixel[4] = 1; - pos_pixel[5] = 1; + pos_pixel[0] = pixel_x; + pos_pixel[1] = pixel_y; + pos_pixel[2] = x2 + m; + pos_pixel[3] = y2 + n; + pos_pixel[4] = 1; + pos_pixel[5] = 1; - DIBUJA_BLOQUE_CUT(pos_pixel, dir_inicio, dir_fin); + DIBUJA_BLOQUE_CUT(pos_pixel, dir_inicio, dir_fin); - pixel_x = pixel_x + suma_x; + pixel_x = pixel_x + suma_x; } pixel_x = x1; pixel_y = pixel_y + suma_y; @@ -3947,7 +3947,7 @@ void DrasculaEngine::cuadrante_2() { void DrasculaEngine::cuadrante_3() { float distancia_x, distancia_y; - + distancia_x = hare_x + ancho_hare / 2 - sitio_x; distancia_y = sitio_y - (hare_y + alto_hare); @@ -3999,7 +3999,7 @@ void DrasculaEngine::refresca_62_antes() { int cirio_x[] = { 14, 19, 24 }; int pianista_x[] = {1, 91, 61, 31, 91, 31, 1, 61, 31 }; int borracho_x[] = {1, 42, 83, 124, 165, 206, 247, 1 }; - int diferencia; + int diferencia; DIBUJA_FONDO(123, velas_y[frame_velas], 142, 14, 39, 13, dir_dibujo3, dir_zona_pantalla); @@ -4034,14 +4034,14 @@ void DrasculaEngine::refresca_62_antes() { } } else if (((rand() % 95) == 15) && (flags[13] == 0)) flags[12] = 1; - + frame_velas++; if (frame_velas == 3) frame_velas = 0; frame_piano++; if (frame_piano == 9) frame_piano = 0; - parpadeo = rand() % 11; + parpadeo = rand() % 11; conta_ciego_vez = vez(); } } @@ -4051,7 +4051,7 @@ void DrasculaEngine::graba_partida(char nom_game[]) { int l; // TODO - if ((scu = fopen(nom_game, "w")) == NULL) { + if ((scu = fopen(nom_game, "w")) == NULL) { error("no puedo abrir el archivo"); } fprintf(scu, "%d\n", num_ejec); @@ -4084,7 +4084,7 @@ void DrasculaEngine::aumenta_num_frame() { if (num_frame == 6) num_frame = 0; - if (direccion_hare == 0){ + if (direccion_hare == 0) { hare_x = hare_x - paso_x; hare_y = hare_y - paso_y; } else if (direccion_hare == 7) { @@ -4117,7 +4117,7 @@ void DrasculaEngine::aumenta_num_frame() { hare_x = hare_x + diferencia_x; alto_hare = nuevo_alto; ancho_hare = nuevo_ancho; -} +} int DrasculaEngine::sobre_que_objeto() { int n; @@ -4149,9 +4149,9 @@ void DrasculaEngine::pantalla_0() { else if (objeto_que_lleva == MOVER) hablar(TEXT19, "19.als" ); else if (objeto_que_lleva == COGER) - hablar(TEXT11, "11.als" ); + hablar(TEXT11, "11.als" ); else if (objeto_que_lleva == ABRIR) - hablar(TEXT9, "9.als" ); + hablar(TEXT9, "9.als" ); else if (objeto_que_lleva == CERRAR) hablar(TEXT9, "9.als" ); else if (objeto_que_lleva == HABLAR) @@ -4211,17 +4211,17 @@ void DrasculaEngine::conversa(const char *nom_fich) { char suena3[13]; char suena4[13]; int longitud; - int respuesta1; - int respuesta2; - int respuesta3; + int respuesta1; + int respuesta2; + int respuesta3; int usado1 = 0; int usado2 = 0; int usado3 = 0; rompo_y_salgo = 0; - + strcpy(para_codificar, nom_fich); - canal_p(para_codificar); + canal_p(para_codificar); // TODO if ((ald = fopen(nom_fich, "rb")) == NULL) { @@ -4239,7 +4239,7 @@ void DrasculaEngine::conversa(const char *nom_fich) { fscanf(ald, "%d", &respuesta2); fscanf(ald, "%d", &respuesta3); fclose(ald); - canal_p(para_codificar); + canal_p(para_codificar); longitud = strlen(frase1); /* for (h = 0; h < longitud; h++) @@ -4247,7 +4247,7 @@ void DrasculaEngine::conversa(const char *nom_fich) { frase1[h] = ' '; longitud = strlen(frase2); - for (h= 0; h < longitud; h++) + for (h = 0; h < longitud; h++) if (frase2[h] == '') frase2[h] = ' '; @@ -4264,19 +4264,19 @@ void DrasculaEngine::conversa(const char *nom_fich) { lee_dibujos("car.alg"); descomprime_dibujo(dir_hare_fondo,1); /* TODO - ent.w.ax = 8; - ent.w.cx = 1; - ent.w.dx = 31; + ent.w.ax = 8; + ent.w.cx = 1; + ent.w.dx = 31; int386(0x33, &ent, &sal); -*/ +*/ color_abc(VERDE_CLARO); bucle_opc: refresca_pantalla(); - + if (music_status() == 0 && flags[11] == 0) - playmusic(musica_room); + playmusic(musica_room); MirarRaton(); @@ -4285,7 +4285,7 @@ bucle_opc: color_abc(BLANCO); else if (usado1 == 0 && color != VERDE_CLARO) color_abc(VERDE_CLARO); - } else if (y_raton > 8 && y_raton < 17){ + } else if (y_raton > 8 && y_raton < 17) { if (usado2==1 && color!=BLANCO) color_abc(BLANCO); else if (usado2 == 0 && color != VERDE_CLARO) @@ -4311,18 +4311,18 @@ bucle_opc: print_abc_opc(frase2, 1, 10, juego2); print_abc_opc(frase3, 1, 18, juego3); print_abc_opc(frase4, 1, 26, juego4); - + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); - if ((boton_izq == 1) && (juego1 == 2)) { + if ((boton_izq == 1) && (juego1 == 2)) { usado1 = 1; hablar(frase1, suena1); responde(respuesta1); - } else if ((boton_izq == 1) && (juego2 == 2)) { + } else if ((boton_izq == 1) && (juego2 == 2)) { usado2 = 1; hablar(frase2, suena2); responde(respuesta2); - } else if ((boton_izq == 1) && (juego3 == 2)) { + } else if ((boton_izq == 1) && (juego3 == 2)) { usado3 = 1; hablar(frase3, suena3); responde(respuesta3); @@ -4336,17 +4336,17 @@ bucle_opc: if (usado1 == 0) juego1 = 1; - else + else juego1 = 3; if (usado2 == 0) juego2 = 1; - else + else juego2 = 3; if (usado3 == 0) - juego3 = 1; + juego3 = 1; else juego3 = 3; - + juego4 = 1; if (rompo_y_salgo == 0) @@ -4383,7 +4383,7 @@ void DrasculaEngine::animacion_3() { hablar(TEXT202, "202.als"); flags[0] = 1; - + lee_dibujos("97.alg"); descomprime_dibujo(dir_hare_dch, 1); } @@ -4393,7 +4393,7 @@ void DrasculaEngine::animacion_4() { descomprime_dibujo(dir_hare_dch, 1); hablar(TEXT205,"205.als"); - + actualiza_refresco_antes(); DIBUJA_FONDO(1, 139, 228, 112, 47, 60, dir_hare_dch, dir_zona_pantalla); @@ -4618,7 +4618,7 @@ void DrasculaEngine::print_abc_opc(const char *dicho, int x_pantalla, int y_pant void DrasculaEngine::responde(int funcion) { if (funcion == 10) - habla_borracho(TEXTB1, "B1.als"); + habla_borracho(TEXTB1, "B1.als"); else if (funcion == 11) habla_borracho(TEXTB2, "B2.als"); else if (funcion == 12) @@ -4660,7 +4660,7 @@ bucless: actualiza_refresco_antes(); DIBUJA_FONDO(x_habla[cara], 139, 228, 112, 47, 60, - dir_hare_dch, dir_zona_pantalla); + dir_hare_dch, dir_zona_pantalla); pon_hare(); actualiza_refresco(); @@ -4684,7 +4684,7 @@ bucless: longitud = longitud - 2; if (longitud > 0) goto bucless; - } + } refresca_pantalla(); VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); @@ -4708,7 +4708,7 @@ void DrasculaEngine::habla_borracho(const char *dicho, const char *filename) { flags[13] = 1; -bebiendo: +bebiendo: if (flags[12] == 1) { refresca_pantalla(); @@ -4762,7 +4762,7 @@ bucless: longitud = longitud - 2; if (longitud > 0) goto bucless; - } + } refresca_pantalla(); VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); @@ -4772,7 +4772,7 @@ bucless: descomprime_dibujo(dir_hare_frente, 1); if (music_status() == 0 && flags[11] == 0) - playmusic(musica_room); + playmusic(musica_room); } void DrasculaEngine::suma_objeto(int osj) { @@ -4782,7 +4782,7 @@ void DrasculaEngine::suma_objeto(int osj) { if (objetos_que_tengo[h] == osj) puesto = 1; } - + if (puesto == 0) { for (h = 1; h < 43; h++) { if (objetos_que_tengo[h] == 0) { @@ -4795,7 +4795,7 @@ void DrasculaEngine::suma_objeto(int osj) { } void DrasculaEngine::fin_sound_corte() { - if (hay_sb == 1) { + if (hay_sb == 1) { ctvd_stop(); fclose(sku); ctvd_terminate(); diff --git a/engines/drascula/texts.h b/engines/drascula/texts.h index 20536c6573..4c457f5ac3 100644 --- a/engines/drascula/texts.h +++ b/engines/drascula/texts.h @@ -742,12 +742,12 @@ #define SYS1 "press ESC again to exit" #define SYS2 "VOiCES only" #define SYS3 "VOices and TEXT" - + #define HIS1 "A long time ago, it seems that Drascula killed Von Braun's wife, and then, as he intended to face the count, Von Braun started to investigate all he found vampires." -#define HIS2 "When he thought he was ready, he came up to the castle and had a very violent encounter with Drascula." +#define HIS2 "When he thought he was ready, he came up to the castle and had a very violent encounter with Drascula." #define HIS3 "Nobody knows exactly what happened there. Although Von Braun lost, Drascula could not kill him." #define HIS4 "Von Braun felt humiliated by his defect, run away from the castle and has never dared to face Drascula ever again." - + -- cgit v1.2.3 From 8c1fcc3c08399d39b34ee333cc3d849252f49516 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 28 Jul 2007 12:26:40 +0000 Subject: The main panel is now correctly shown in the IHNM demo. Some inventory items are still wrong, though svn-id: r28264 --- engines/saga/interface.cpp | 9 +++++++-- engines/saga/sagaresnames.h | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/saga/interface.cpp b/engines/saga/interface.cpp index 74ac2155a9..150bf55111 100644 --- a/engines/saga/interface.cpp +++ b/engines/saga/interface.cpp @@ -389,6 +389,9 @@ void Interface::setMode(int mode) { } else if (mode == kPanelChapterSelection) { if (_vm->getGameId() != GID_IHNM_DEMO) _saveReminderState = 1; + } else if (mode == kPanelNull) { + if (_vm->getGameId() == GID_IHNM_DEMO) + _inMainMode = true; } else { if (mode == kPanelConverse) { _inMainMode = false; @@ -726,7 +729,8 @@ void Interface::draw() { drawStatusBar(); - if (_panelMode == kPanelMain || _panelMode == kPanelMap) { + if (_panelMode == kPanelMain || _panelMode == kPanelMap || + (_panelMode == kPanelNull && _vm->getGameId() == GID_IHNM_DEMO)) { _mainPanel.getRect(rect); backBuffer->blit(rect, _mainPanel.image); @@ -752,7 +756,8 @@ void Interface::draw() { } if (_panelMode == kPanelMain || _panelMode == kPanelConverse || - _lockedMode == kPanelMain || _lockedMode == kPanelConverse) { + _lockedMode == kPanelMain || _lockedMode == kPanelConverse || + (_panelMode == kPanelNull && _vm->getGameId() == GID_IHNM_DEMO)) { leftPortraitPoint.x = _mainPanel.x + _vm->getDisplayInfo().leftPortraitXOffset; leftPortraitPoint.y = _mainPanel.y + _vm->getDisplayInfo().leftPortraitYOffset; _vm->_sprite->draw(backBuffer, _vm->getDisplayClip(), _defPortraits, _leftPortrait, leftPortraitPoint, 256); diff --git a/engines/saga/sagaresnames.h b/engines/saga/sagaresnames.h index 4b4d546514..bb5a209946 100644 --- a/engines/saga/sagaresnames.h +++ b/engines/saga/sagaresnames.h @@ -112,7 +112,7 @@ namespace Saga { #define RID_IHNM_PROFILE_BG 20 #define RID_IHNM_MAIN_STRINGS 21 -#define RID_IHNMDEMO_MAIN_PANEL 4 // TODO: Verify this +#define RID_IHNMDEMO_MAIN_PANEL 5 #define RID_IHNMDEMO_CONVERSE_PANEL 5 // TODO: Verify this #define RID_IHNMDEMO_HOURGLASS_CURSOR 6 // Does not exist in the demo #define RID_IHNMDEMO_MAIN_SPRITES 7 @@ -124,7 +124,7 @@ namespace Saga { #define RID_IHNMDEMO_WARNING_PANEL 12 // TODO: Verify this #define RID_IHNMDEMO_BOSS_SCREEN 13 // Does not exist in the demo #define RID_IHNMDEMO_PROFILE_BG 14 // TODO: Verify this -#define RID_IHNMDEMO_MAIN_STRINGS 15 // TODO: Verify this +#define RID_IHNMDEMO_MAIN_STRINGS 16 // Puzzle portraits #define RID_ITE_SAKKA_APPRAISING 6 -- cgit v1.2.3 From b8f55ec74286d4e78f6bb82e1b3f6c33ad59b92f Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Sat, 28 Jul 2007 13:27:48 +0000 Subject: Screen is now refreshed when waiting for left clicks. Solves bug #1762618. svn-id: r28265 --- engines/parallaction/parallaction.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp index 70f1de9f4a..6f871b86cd 100644 --- a/engines/parallaction/parallaction.cpp +++ b/engines/parallaction/parallaction.cpp @@ -372,7 +372,8 @@ void waitUntilLeftClick() { break; } - g_system->delayMillis(10); + g_system->delayMillis(30); + _vm->_gfx->updateScreen(); } -- cgit v1.2.3 From 2c40b302abfa36cc0fc04b3911186be919c01129 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 28 Jul 2007 13:28:25 +0000 Subject: The palette in Benny's part in the IHNM demo is correct now svn-id: r28266 --- engines/saga/animation.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'engines') diff --git a/engines/saga/animation.cpp b/engines/saga/animation.cpp index e9f3494cd2..bad1155806 100644 --- a/engines/saga/animation.cpp +++ b/engines/saga/animation.cpp @@ -155,6 +155,12 @@ void Anim::playCutaway(int cut, bool fade) { _vm->_gfx->setPalette(palette); + // WORKAROUND for a bug found in the original IHNM demo. The palette of cutaway 12 is incorrect (the incorrect + // palette can be seen in the original demo too, for a split second). Therefore, use the saved palette for this + // cutaway + if (_vm->getGameId() == GID_IHNM_DEMO && cut == 12) + _vm->_gfx->restorePalette(); + free(buf); free(resourceData); -- cgit v1.2.3 From 7059a69bde6c2a465c41062142524c9f521c49e8 Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Sat, 28 Jul 2007 13:56:27 +0000 Subject: Fixed bug #1762638. Mask filenames weren't chosen correctly when not explicitly specified by scripts. svn-id: r28267 --- engines/parallaction/disk_ns.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/parallaction/disk_ns.cpp b/engines/parallaction/disk_ns.cpp index e500cd519b..882488056f 100644 --- a/engines/parallaction/disk_ns.cpp +++ b/engines/parallaction/disk_ns.cpp @@ -1208,13 +1208,16 @@ void AmigaDisk_ns::loadBackground(const char *name) { } void AmigaDisk_ns::loadMask(const char *name) { + debugC(5, kDebugDisk, "AmigaDisk_ns::loadMask(%s)", name); char path[PATH_LEN]; sprintf(path, "%s.mask", name); Common::SeekableReadStream *s = openArchivedFile(path, false); - if (s == NULL) + if (s == NULL) { + debugC(5, kDebugDisk, "Mask file not found"); return; // no errors if missing mask files: not every location has one + } s->seek(0x30, SEEK_SET); @@ -1236,6 +1239,12 @@ void AmigaDisk_ns::loadMask(const char *name) { byte *buf = (byte*)malloc(_vm->_screenMaskSize); stream.read(buf, _vm->_screenMaskSize); buildMask(buf); + + FILE *f = fopen("mask.bin", "wb"); + fwrite(buf, _vm->_screenMaskSize, 1, f); + fclose(f); + printf("written\n"); + _vm->_gfx->setMask(buf); free(buf); delete s; @@ -1272,8 +1281,14 @@ void AmigaDisk_ns::loadScenery(const char* background, const char* mask) { sprintf(path, "%s.bkgnd", background); loadBackground(path); - loadMask(background); - loadPath(background); + + if (mask == NULL) { + loadMask(background); + loadPath(background); + } else { + loadMask(mask); + loadPath(mask); + } return; } -- cgit v1.2.3 From 92c90ab8d6c51a9bf3fa1807139d078a155bb603 Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Sat, 28 Jul 2007 14:10:25 +0000 Subject: Remove debug code. svn-id: r28268 --- engines/parallaction/disk_ns.cpp | 5 ----- 1 file changed, 5 deletions(-) (limited to 'engines') diff --git a/engines/parallaction/disk_ns.cpp b/engines/parallaction/disk_ns.cpp index 882488056f..c0bb2691ef 100644 --- a/engines/parallaction/disk_ns.cpp +++ b/engines/parallaction/disk_ns.cpp @@ -1240,11 +1240,6 @@ void AmigaDisk_ns::loadMask(const char *name) { stream.read(buf, _vm->_screenMaskSize); buildMask(buf); - FILE *f = fopen("mask.bin", "wb"); - fwrite(buf, _vm->_screenMaskSize, 1, f); - fclose(f); - printf("written\n"); - _vm->_gfx->setMask(buf); free(buf); delete s; -- cgit v1.2.3 From 6320e6db3c21e1b4cace2b0d8f6791b665997ca3 Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Sat, 28 Jul 2007 14:21:16 +0000 Subject: Now yielding control to system after updateScreen is invoked to get smoother mouse movements. svn-id: r28269 --- engines/parallaction/parallaction.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp index 6f871b86cd..523fbcf88b 100644 --- a/engines/parallaction/parallaction.cpp +++ b/engines/parallaction/parallaction.cpp @@ -372,8 +372,8 @@ void waitUntilLeftClick() { break; } - g_system->delayMillis(30); _vm->_gfx->updateScreen(); + g_system->delayMillis(30); } -- cgit v1.2.3 From 8d5f19d9e506a36092aa866ff79402f455a96ba7 Mon Sep 17 00:00:00 2001 From: Paweł Kołodziejski Date: Sat, 28 Jul 2007 14:45:26 +0000 Subject: fixes into engine svn-id: r28270 --- engines/drascula/drascula.cpp | 460 ++++++++++++++++++++++-------------------- engines/drascula/drascula.h | 41 ++-- 2 files changed, 267 insertions(+), 234 deletions(-) (limited to 'engines') diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp index 042f5944bf..49033516a0 100644 --- a/engines/drascula/drascula.cpp +++ b/engines/drascula/drascula.cpp @@ -72,6 +72,7 @@ DrasculaEngine::DrasculaEngine(OSystem *syst) : Engine(syst) { _gameId = g->id; _rnd = new Common::RandomSource(); + Common::EventManager *_eventMan = _system->getEventManager(); } @@ -126,7 +127,7 @@ int DrasculaEngine::init() { _system->initSize(320, 200); _system->endGFXTransaction(); - VGA = (char *)malloc(320 * 200); + VGA = (byte *)malloc(320 * 200); memset(VGA, 0, 64000); lleva_objeto = 0; @@ -242,15 +243,15 @@ void DrasculaEngine::carga_info() { void DrasculaEngine::lee_dibujos(const char *NamePcc) { unsigned int con, x = 0; unsigned int fExit = 0; - unsigned char ch,rep; + byte ch, rep; Common::File file; - char *auxPun; + byte *auxPun; file.open(NamePcc); if (!file.isOpen()) error("missing game data %s %c", NamePcc, 7); - Buffer_pcx = (char *)malloc(65000); + Buffer_pcx = (byte *)malloc(65000); auxPun = Buffer_pcx; file.seek(128); while (!fExit) { @@ -275,7 +276,7 @@ void DrasculaEngine::lee_dibujos(const char *NamePcc) { void DrasculaEngine::descomprime_dibujo(char *dir_escritura, int plt) { memcpy(dir_escritura, Buffer_pcx, 64000); free(Buffer_pcx); - asigna_rgb((unsigned char *)cPal, plt); // TODO + asigna_rgb((unsigned char *)cPal, plt); if (plt > 1) funde_rgb(plt); } @@ -284,7 +285,7 @@ void DrasculaEngine::paleta_hare() { int color, componente; for (color = 235; color < 253; color++) - for (componente = 0; componente < 4; componente++) + for (componente = 0; componente < 3; componente++) palHare[color][componente] = palJuego[color][componente]; } @@ -293,10 +294,9 @@ void DrasculaEngine::asigna_rgb(unsigned char *dir_lectura, int plt) { int x, cnt = 0; for (x = 0; x < plt; x++) { - palJuego[x][0] = dir_lectura[cnt++] / 4; - palJuego[x][1] = dir_lectura[cnt++] / 4; - palJuego[x][2] = dir_lectura[cnt++] / 4; - palJuego[x][3] = 0; + palJuego[x][0] = dir_lectura[cnt++]; + palJuego[x][1] = dir_lectura[cnt++]; + palJuego[x][2] = dir_lectura[cnt++]; } ActualizaPaleta(); } @@ -309,7 +309,6 @@ void DrasculaEngine::funde_rgb(int plt) { palJuego[n][0] = inp(0x3c9); palJuego[n][1] = inp(0x3c9); palJuego[n][2] = inp(0x3c9); - palJuego[n][3] = 0; } ActualizaPaleta(); */ @@ -320,23 +319,32 @@ void DrasculaEngine::Negro() { DacPalette256 palNegra; for (color = 0; color < 256; color++) - for (componente = 0; componente < 4; componente++) + for (componente = 0; componente < 3; componente++) palNegra[color][componente] = 0; - palNegra[254][0] = 0x3F; - palNegra[254][1] = 0x3F; - palNegra[254][2] = 0x15; - palNegra[254][0] = 0; + palNegra[254][0] = 0xff; + palNegra[254][1] = 0xff; + palNegra[254][2] = 0x57; - setvgapalette256(&palNegra); + setvgapalette256((byte *)&palNegra); } void DrasculaEngine::ActualizaPaleta() { - setvgapalette256(&palJuego); + setvgapalette256((byte *)&palJuego); } -void DrasculaEngine::setvgapalette256(DacPalette256 *PalBuf) { - g_system->setPalette((byte *)PalBuf, 0, 256); +void DrasculaEngine::setvgapalette256(byte *PalBuf) { + byte pal[256 * 4]; + int i; + + for (i = 0; i < 256; i++) { + pal[i * 4 + 0] = PalBuf[i * 3 + 0] * 4; + pal[i * 4 + 1] = PalBuf[i * 3 + 1] * 4; + pal[i * 4 + 2] = PalBuf[i * 3 + 2] * 4; + pal[i * 4 + 3] = 0; + } + _system->setPalette(pal, 0, 256); + _system->updateScreen(); } void DrasculaEngine::DIBUJA_FONDO(int xorg, int yorg, int xdes, int ydes, int Ancho, @@ -408,7 +416,8 @@ void DrasculaEngine::VUELCA_PANTALLA(int xorg, int yorg, int xdes, int ydes, int Buffer += 320; } - g_system->copyRectToScreen((const byte *)VGA, 320, 0, 0, 320, 200); + _system->copyRectToScreen((const byte *)VGA, 320, 0, 0, 320, 200); + _system->updateScreen(); } void DrasculaEngine::escoba() { @@ -420,8 +429,8 @@ void DrasculaEngine::escoba() { soc = 0; for (l = 0; l < 6; l++) { - soc=soc+ANCHO_PERSONAJE; - frame_x[l]=soc; + soc = soc + ANCHO_PERSONAJE; + frame_x[l] = soc; } for (n = 1; n < 43; n++) @@ -477,7 +486,7 @@ bucles: if (boton_dch == 1 && menu_scr == 1) { lee_dibujos("99.alg"); descomprime_dibujo(dir_hare_fondo, 1); - setvgapalette256(&palJuego); + setvgapalette256((byte *)&palJuego); menu_scr = 0; espera_soltar(); cont_sv = 0; @@ -602,7 +611,7 @@ void DrasculaEngine::animacion_1() { while (term_int == 0) { playmusic(29); - fliplay("logoddm.bin",9); + fliplay("logoddm.bin", 9); if ((term_int == 1) || (getscan() == ESC)) break; delay(600); @@ -1193,49 +1202,57 @@ void DrasculaEngine::carga_escoba(const char *nom_fich) { buffer_teclado(); - // TODO - if ((ald = fopen(nom_fich, "rb")) == NULL) { + ald = new Common::File; + ald->open(nom_fich); + if (!ald->isOpen()) { error("missing data file"); } - fscanf(ald, "%s", num_room); + int size = ald->size(); + char *buffer = new char[size]; + ald->read(buffer, size); + delete ald; + for (l = 0; l < size; l++) + buffer[l] ^= 0xff; + + sscanf(buffer, "%s", num_room); strcat(num_room,".alg"); - fscanf(ald, "%d", &musica_room); - fscanf(ald, "%s", pantalla_disco); - fscanf(ald, "%d", &nivel_osc); + sscanf(buffer, "%d", &musica_room); + sscanf(buffer, "%s", pantalla_disco); + sscanf(buffer, "%d", &nivel_osc); - fscanf(ald, "%d", &objs_room); + sscanf(buffer, "%d", &objs_room); for (l = 0; l < objs_room;l++) { - fscanf(ald, "%d", &num_obj[l]); - fscanf(ald, "%s", nombre_obj[l]); - fscanf(ald, "%d", &x1[l]); - fscanf(ald, "%d", &y1[l]); - fscanf(ald, "%d", &x2[l]); - fscanf(ald, "%d", &y2[l]); - fscanf(ald, "%d", &sitiobj_x[l]); - fscanf(ald, "%d", &sitiobj_y[l]); - fscanf(ald, "%d", &sentidobj[l]); - fscanf(ald, "%d", &visible[l]); - fscanf(ald, "%d", &espuerta[l]); + sscanf(buffer, "%d", &num_obj[l]); + sscanf(buffer, "%s", nombre_obj[l]); + sscanf(buffer, "%d", &x1[l]); + sscanf(buffer, "%d", &y1[l]); + sscanf(buffer, "%d", &x2[l]); + sscanf(buffer, "%d", &y2[l]); + sscanf(buffer, "%d", &sitiobj_x[l]); + sscanf(buffer, "%d", &sitiobj_y[l]); + sscanf(buffer, "%d", &sentidobj[l]); + sscanf(buffer, "%d", &visible[l]); + sscanf(buffer, "%d", &espuerta[l]); if (espuerta[l] != 0) { - fscanf(ald, "%s", alapantallakeva[l]); - fscanf(ald, "%d", &x_alakeva[l]); - fscanf(ald, "%d", &y_alakeva[l]); - fscanf(ald, "%d", &sentido_alkeva[l]); - fscanf(ald, "%d", &alapuertakeva[l]); + sscanf(buffer, "%s", alapantallakeva[l]); + sscanf(buffer, "%d", &x_alakeva[l]); + sscanf(buffer, "%d", &y_alakeva[l]); + sscanf(buffer, "%d", &sentido_alkeva[l]); + sscanf(buffer, "%d", &alapuertakeva[l]); puertas_cerradas(l); } } - fscanf(ald, "%d", &suelo_x1); - fscanf(ald, "%d", &suelo_y1); - fscanf(ald, "%d", &suelo_x2); - fscanf(ald, "%d", &suelo_y2); + sscanf(buffer, "%d", &suelo_x1); + sscanf(buffer, "%d", &suelo_y1); + sscanf(buffer, "%d", &suelo_x2); + sscanf(buffer, "%d", &suelo_y2); - fscanf(ald, "%d", &lejos); - fscanf(ald, "%d", &cerca); + sscanf(buffer, "%d", &lejos); + sscanf(buffer, "%d", &cerca); + delete buffer; - fclose(ald); canal_p(para_codificar); for (l = 0; l < objs_room; l++) { @@ -1296,7 +1313,8 @@ void DrasculaEngine::carga_escoba(const char *nom_fich) { void DrasculaEngine::borra_pantalla() { memset(VGA, 0, 64000); - g_system->copyRectToScreen((const byte *)VGA, 320, 0, 0, 320, 200); + _system->copyRectToScreen((const byte *)VGA, 320, 0, 0, 320, 200); + _system->updateScreen(); } void DrasculaEngine::lleva_al_hare(int punto_x, int punto_y) { @@ -1478,6 +1496,42 @@ char DrasculaEngine::getscan() { return 0; } +void DrasculaEngine::update_events() { + Common::Event event; + + while (_eventMan->pollEvent(event)) { + switch (event.type) { + case Common::EVENT_KEYDOWN: +// _keyPressed = event.kbd; + break; +/* case Common::EVENT_MOUSEMOVE: + _mouseX = event.mouse.x; + _mouseY = event.mouse.y; + break; + case Common::EVENT_LBUTTONDOWN: + _mouseDown = true; + _mouseState |= BS1L_BUTTON_DOWN; + break; + case Common::EVENT_LBUTTONUP: + _mouseDown = false; + _mouseState |= BS1L_BUTTON_UP; + break; + case Common::EVENT_WHEELUP: + _mouseDown = false; + _mouseState |= BS1_WHEEL_UP; + break; + case Common::EVENT_WHEELDOWN: + _mouseDown = false; + _mouseState |= BS1_WHEEL_DOWN; + break; + case Common::EVENT_QUIT: + break; +*/ default: + break; + } + } +} + void DrasculaEngine::elige_verbo(int verbo) { int c = 171; @@ -1923,7 +1977,7 @@ void DrasculaEngine::print_abc(const char *dicho, int x_pantalla, int y_pantalla } void DrasculaEngine::delay(int ms) { - g_system->delayMillis(ms); + _system->delayMillis(ms); } void DrasculaEngine::confirma_go() { @@ -1992,8 +2046,6 @@ void DrasculaEngine::salva_pantallas() { } void DrasculaEngine::fliplay(const char *filefli, int vel) { - return; - // TODO OpenSSN(filefli, vel); while (PlayFrameSSN() && (!term_int)) { if (chkkey() == 27) @@ -2012,12 +2064,11 @@ void DrasculaEngine::FundeDelNegro(int VelocidadDeFundido) { for (color = 0; color < 256; color++) { for (componente = 0; componente < 3; componente++) { palFundido[color][componente] = LimitaVGA(palJuego[color][componente] - 63 + fundido); - palFundido[color][3] = 0; } } pausa(VelocidadDeFundido); - setvgapalette256(&palFundido); + setvgapalette256((byte *)&palFundido); } } @@ -2028,55 +2079,45 @@ void DrasculaEngine::color_abc(int cl) { palJuego[254][0] = 0; palJuego[254][1] = 0; palJuego[254][2] = 0; - palJuego[254][3] = 0; } else if (cl == 1) { palJuego[254][0] = 0x10; palJuego[254][1] = 0x3E; palJuego[254][2] = 0x28; - palJuego[254][3] = 0; } else if (cl == 3) { palJuego[254][0] = 0x16; palJuego[254][1] = 0x3F; palJuego[254][2] = 0x16; - palJuego[254][3] = 0; } else if (cl == 4) { palJuego[254][0] = 0x9; palJuego[254][1] = 0x3F; palJuego[254][2] = 0x12; - palJuego[254][3] = 0; } else if (cl == 5) { palJuego[254][0] = 0x3F; palJuego[254][1] = 0x3F; palJuego[254][2] = 0x15; - palJuego[254][3] = 0; } else if (cl == 7) { palJuego[254][0] = 0x38; palJuego[254][1] = 0; palJuego[254][2] = 0; - palJuego[254][3] = 0; } else if (cl == 8) { palJuego[254][0] = 0x3F; palJuego[254][1] = 0x27; palJuego[254][2] = 0x0B; - palJuego[254][3] = 0; } else if (cl == 9) { palJuego[254][0] = 0x2A; palJuego[254][1] = 0; palJuego[254][2] = 0x2A; - palJuego[254][3] = 0; } else if (cl == 10) { palJuego[254][0] = 0x30; palJuego[254][1] = 0x30; palJuego[254][2] = 0x30; - palJuego[254][3] = 0; } else if (cl == 11) { palJuego[254][0] = 98; palJuego[254][1] = 91; palJuego[254][2] = 100; - palJuego[254][3] = 0; }; - setvgapalette256(&palJuego); + setvgapalette256((byte *)&palJuego); } char DrasculaEngine::LimitaVGA(char valor) { @@ -2084,7 +2125,7 @@ char DrasculaEngine::LimitaVGA(char valor) { } void DrasculaEngine::centra_texto(const char *mensaje, int x_texto, int y_texto) { - char bb[190], m2[190], m1[190] ,mb[10][40]; + char bb[190], m2[190], m1[190], mb[10][40]; char m3[190]; int h, fil, x_texto3, x_texto2, x_texto1, conta_f = 0, ya = 0; @@ -2154,7 +2195,9 @@ imprimir: void DrasculaEngine::comienza_sound(const char *fichero) { if (hay_sb == 1) { - if ((sku = fopen(fichero, "rb")) == NULL) { + sku = new Common::File; + sku->open(fichero); + if (!sku->isOpen()) { error("no puedo abrir archivo de voz"); } } @@ -2187,7 +2230,8 @@ void DrasculaEngine::anima(const char *animacion, int FPS) { carga_pcx(AuxBuffOrg); free(AuxBuffOrg); memcpy(VGA, AuxBuffDes, 64000); - g_system->copyRectToScreen((const byte *)VGA, 320, 0, 0, 320, 200); + _system->copyRectToScreen((const byte *)VGA, 320, 0, 0, 320, 200); + _system->updateScreen(); set_dac(cPal); memcpy(AuxBuffLast, AuxBuffDes, 64000); WaitForNext(TimeMed); @@ -2201,7 +2245,8 @@ void DrasculaEngine::anima(const char *animacion, int FPS) { for (j = 0;j < 64000; j++) { VGA[j] = AuxBuffLast[j] = AuxBuffDes[j] ^ AuxBuffLast[j]; } - g_system->copyRectToScreen((const byte *)VGA, 320, 0, 0, 320, 200); + _system->copyRectToScreen((const byte *)VGA, 320, 0, 0, 320, 200); + _system->updateScreen(); WaitForNext(TimeMed); cnt++; key = getscan(); @@ -2218,7 +2263,7 @@ void DrasculaEngine::anima(const char *animacion, int FPS) { void DrasculaEngine::animafin_sound_corte() { if (hay_sb == 1) { ctvd_stop(); - fclose(sku); + delete sku; ctvd_terminate(); } } @@ -2238,20 +2283,12 @@ void DrasculaEngine::FundeAlNegro(int VelocidadDeFundido) { } pausa(VelocidadDeFundido); - setvgapalette256(&palFundido); + setvgapalette256((byte *)&palFundido); } } void DrasculaEngine::pausa(int cuanto) { - int diferencia, conta_antes; - - conta_antes = vez(); - - for (;;) { - diferencia = vez() - conta_antes; - if (diferencia >= 2 * cuanto) - break; - } + _system->delayMillis(cuanto); } void DrasculaEngine::habla_dr_grande(const char *dicho, const char *filename) { @@ -2273,7 +2310,9 @@ void DrasculaEngine::habla_dr_grande(const char *dicho, const char *filename) { color_abc(ROJO); if (hay_sb == 1) { - if ((sku = fopen(filename, "rb")) == NULL) { + sku = new Common::File; + sku->open(filename); + if (!sku->isOpen()) { error("no puedo abrir archivo de voz"); } ctvd_init(2); @@ -2308,7 +2347,7 @@ bucless: if (hay_sb == 1) { if (LookForFree() != 0) goto bucless; - fclose(sku); + delete sku; ctvd_terminate(); } else { longitud = longitud - 2; @@ -2386,8 +2425,9 @@ void DrasculaEngine::habla_igor_dch(const char *dicho, const char *filename) { color_abc(BLANCO); if (hay_sb == 1) { - // TODO - if ((sku = fopen(filename, "rb")) == NULL) { + sku = new Common::File; + sku->open(filename); + if (!sku->isOpen()) { error("no puedo abrir archivo de voz"); } ctvd_init(2); @@ -2429,7 +2469,7 @@ bucless: if (hay_sb == 1) { if (LookForFree() != 0) goto bucless; - fclose(sku); + delete sku; ctvd_terminate(); } else { longitud = longitud - 2; @@ -2461,8 +2501,9 @@ void DrasculaEngine::habla_dr_izq(const char *dicho, const char *filename) { color_abc(ROJO); if (hay_sb == 1) { - // TODO - if ((sku = fopen(filename, "rb")) == NULL) { + sku = new Common::File; + sku->open(filename); + if (!sku->isOpen()) { error("no puedo abrir archivo de voz"); } ctvd_init(2); @@ -2503,7 +2544,7 @@ bucless: if (hay_sb == 1) { if (LookForFree() != 0) goto bucless; - fclose(sku); + delete sku; ctvd_terminate(); } else { longitud = longitud - 2; @@ -2537,8 +2578,9 @@ void DrasculaEngine::habla_dr_dch(const char *dicho, const char *filename) { color_abc(ROJO); if (hay_sb == 1) { - // TODO - if ((sku = fopen(filename, "rb")) == NULL) { + sku = new Common::File; + sku->open(filename); + if (!sku->isOpen()) { error("no puedo abrir archivo de voz"); } ctvd_init(2); @@ -2578,7 +2620,7 @@ bucless: if (hay_sb == 1) { if (LookForFree() != 0) goto bucless; - fclose(sku); + delete sku; ctvd_terminate(); } else { longitud = longitud - 2; @@ -2606,8 +2648,9 @@ void DrasculaEngine::habla_solo(const char *dicho, const char *filename) { color_abc(color_solo); if (hay_sb == 1) { - // TODO - if ((sku = fopen(filename, "rb")) == NULL) { + sku = new Common::File; + sku->open(filename); + if (!sku->isOpen()) { error("no puedo abrir archivo de voz"); } ctvd_init(2); @@ -2630,7 +2673,7 @@ bucless: if (hay_sb == 1) { if (LookForFree() != 0) goto bucless; - fclose(sku); + delete sku; ctvd_terminate(); } else { longitud = longitud - 2; @@ -2659,7 +2702,9 @@ void DrasculaEngine::habla_igor_frente(const char *dicho, const char *filename) color_abc(BLANCO); if (hay_sb == 1) { - if ((sku = fopen(filename, "rb")) == NULL) { + sku = new Common::File; + sku->open(filename); + if (!sku->isOpen()) { error("no puedo abrir archivo de voz"); } ctvd_init(2); @@ -2700,7 +2745,7 @@ bucless: if (hay_sb == 1) { if (LookForFree() != 0) goto bucless; - fclose(sku); + delete sku; ctvd_terminate(); } else { longitud = longitud - 2; @@ -2733,8 +2778,9 @@ void DrasculaEngine::habla_tabernero(const char *dicho, const char *filename) { color_abc(MARRON); if (hay_sb == 1) { - // TODO - if ((sku = fopen(filename, "rb")) == NULL) { + sku = new Common::File; + sku->open(filename); + if (!sku->isOpen()) { error("no puedo abrir archivo de voz"); } ctvd_init(2); @@ -2771,7 +2817,7 @@ bucless: if (hay_sb == 1) { if (LookForFree() != 0) goto bucless; - fclose(sku); + delete(sku); ctvd_terminate(); } else { longitud = longitud - 2; @@ -2814,7 +2860,7 @@ void DrasculaEngine::fin_sound() { if (hay_sb == 1) { while (LookForFree() != 0); - fclose(sku); + delete sku; } } @@ -2837,8 +2883,9 @@ void DrasculaEngine::habla_bj(const char *dicho, const char *filename) { color_abc(BLANCO); if (hay_sb == 1) { - // TODO - if ((sku = fopen(filename, "rb")) == NULL) { + sku = new Common::File; + sku->open(filename); + if (!sku->isOpen()) { error("no puedo abrir archivo de voz"); } ctvd_init(2); @@ -2878,7 +2925,7 @@ bucless: if (hay_sb == 1) { if (LookForFree() != 0) goto bucless; - fclose(sku); + delete sku; ctvd_terminate(); } else { longitud = longitud - 2; @@ -2914,7 +2961,9 @@ void DrasculaEngine::hablar(const char *dicho, const char *filename) { color_abc(AMARILLO); if (hay_sb == 1) { - if ((sku = fopen(filename, "rb")) == NULL) { + sku = new Common::File; + sku->open(filename); + if (!sku->isOpen()) { error("no puedo abrir archivo de voz"); } ctvd_init(2); @@ -2983,7 +3032,7 @@ bucless: if (hay_sb == 1) { if (LookForFree() != 0) goto bucless; - fclose(sku); + delete sku; ctvd_terminate(); } else { longitud = longitud - 2; @@ -3050,34 +3099,40 @@ void DrasculaEngine::carga_partida(const char *nom_game) { int l, n_ejec2; canal_p(nom_game); - // TODO - if ((sku = fopen(nom_game, "rb")) == NULL) { - error("no puedo abrir el archivo"); + sku = new Common::File; + sku->open(nom_game); + if (!ald->isOpen()) { + error("missing data file"); } - fscanf(sku, "%d", &n_ejec2); + int size = sku->size(); + char *buffer = new char[size]; + sku->read(buffer, size); + delete sku; + for (l = 0; l < size; l++) + buffer[l] ^= 0xff; + + sscanf(buffer, "%d", &n_ejec2); if (n_ejec2 != num_ejec) { - fclose(sku); canal_p(nom_game); strcpy(nom_partida, nom_game); salir_al_dos(n_ejec2); } - fscanf(sku, "%s", datos_actuales); - fscanf(sku, "%d", &hare_x); - fscanf(sku, "%d", &hare_y); - fscanf(sku, "%d", &sentido_hare); + sscanf(buffer, "%s", datos_actuales); + sscanf(buffer, "%d", &hare_x); + sscanf(buffer, "%d", &hare_y); + sscanf(buffer, "%d", &sentido_hare); for (l = 1; l < 43; l++) { - fscanf(sku, "%d", &objetos_que_tengo[l]); + sscanf(buffer, "%d", &objetos_que_tengo[l]); } for (l = 0; l < NUM_BANDERAS; l++) { - fscanf(sku, "%d", &flags[l]); + sscanf(buffer, "%d", &flags[l]); } - fscanf(sku, "%d", &lleva_objeto); - fscanf(sku, "%d", &objeto_que_lleva); + sscanf(buffer, "%d", &lleva_objeto); + sscanf(buffer, "%d", &objeto_que_lleva); - fclose(sku); canal_p(nom_game); } @@ -3122,7 +3177,6 @@ void DrasculaEngine::color_hare() { for (componente = 0; componente < 3; componente++) { palJuego[color][componente] = palHare[color][componente]; } - palJuego[color][3] = 0; } ActualizaPaleta(); } @@ -3135,7 +3189,6 @@ void DrasculaEngine::funde_hare(int oscuridad) { for (color = 235; color < 253; color++) { for (componente = 0; componente < 3; componente++) palJuego[color][componente] = LimitaVGA( palJuego[color][componente] - 8 + fundido ); - palJuego[color][3] = 0; } } @@ -3148,7 +3201,6 @@ void DrasculaEngine::paleta_hare_claro() { for (color = 235; color < 253; color++) { for (componente = 0; componente < 3; componente++) palHareClaro[color][componente] = palJuego[color][componente]; - palHareClaro[color][3] = 0; } } @@ -3158,7 +3210,6 @@ void DrasculaEngine::paleta_hare_oscuro() { for (color = 235; color < 253; color++) { for (componente = 0; componente < 3; componente++) palHareOscuro[color][componente] = palJuego[color][componente]; - palHareOscuro[color][3] = 0; } } @@ -3168,7 +3219,6 @@ void DrasculaEngine::hare_claro() { for (color = 235; color < 253; color++) { for (componente = 0; componente < 3; componente++) palJuego[color][componente] = palHareClaro[color][componente]; - palJuego[color][3] = 0; } ActualizaPaleta(); @@ -3612,7 +3662,7 @@ int DrasculaEngine::LookForFree() { } void DrasculaEngine::OpenSSN(const char *Name, int Pause) { - MiVideoSSN = (char *)malloc(64256); + MiVideoSSN = (byte *)malloc(64256); GlobalSpeed = CLOCKS_PER_SEC / Pause; FrameSSN = 0; UsingMem = 0; @@ -3627,7 +3677,7 @@ void DrasculaEngine::OpenSSN(const char *Name, int Pause) { int DrasculaEngine::PlayFrameSSN() { int Exit = 0; int Lengt; - char *BufferSSN; + byte *BufferSSN; if (!UsingMem) Sesion->read(&CHUNK, 1); @@ -3660,10 +3710,10 @@ int DrasculaEngine::PlayFrameSSN() { } if (CMP == CMP_RLE) { if (!UsingMem) { - BufferSSN = (char *)malloc(Lengt); + BufferSSN = (byte *)malloc(Lengt); Sesion->read(BufferSSN, Lengt); } else { - BufferSSN = (char *)malloc(Lengt); + BufferSSN = (byte *)malloc(Lengt); memcpy(BufferSSN, mSesion, Lengt); mSesion += Lengt; } @@ -3672,20 +3722,21 @@ int DrasculaEngine::PlayFrameSSN() { if (FrameSSN) { WaitFrameSSN(); MixVideo(VGA, MiVideoSSN); - g_system->copyRectToScreen((const byte *)VGA, 320, 0, 0, 320, 200); + _system->copyRectToScreen((const byte *)VGA, 320, 0, 0, 320, 200); } else { WaitFrameSSN(); memcpy(VGA, MiVideoSSN, 64000); - g_system->copyRectToScreen((const byte *)VGA, 320, 0, 0, 320, 200); + _system->copyRectToScreen((const byte *)VGA, 320, 0, 0, 320, 200); } + _system->updateScreen(); FrameSSN++; } else { if (CMP == CMP_OFF) { if (!UsingMem) { - BufferSSN = (char *)malloc(Lengt); + BufferSSN = (byte *)malloc(Lengt); Sesion->read(BufferSSN, Lengt); } else { - BufferSSN = (char *)malloc(Lengt); + BufferSSN = (byte *)malloc(Lengt); memcpy(BufferSSN, mSesion, Lengt); mSesion += Lengt; } @@ -3694,12 +3745,13 @@ int DrasculaEngine::PlayFrameSSN() { if (FrameSSN) { WaitFrameSSN(); MixVideo(VGA, MiVideoSSN); - g_system->copyRectToScreen((const byte *)VGA, 320, 0, 0, 320, 200); + _system->copyRectToScreen((const byte *)VGA, 320, 0, 0, 320, 200); } else { WaitFrameSSN(); memcpy(VGA, MiVideoSSN, 64000); - g_system->copyRectToScreen((const byte *)VGA, 320, 0, 0, 320, 200); + _system->copyRectToScreen((const byte *)VGA, 320, 0, 0, 320, 200); } + _system->updateScreen(); FrameSSN++; } } @@ -3724,13 +3776,13 @@ void DrasculaEngine::EndSSN() { } } -char *DrasculaEngine::TryInMem(Common::File *Sesion) { +byte *DrasculaEngine::TryInMem(Common::File *Sesion) { int Lengt; Sesion->seek(0, SEEK_END); Lengt = Sesion->pos(); Sesion->seek(0, SEEK_SET); - pointer = (char *)malloc(Lengt); + pointer = (byte *)malloc(Lengt); if (pointer == NULL) return NULL; Sesion->read(pointer, Lengt); @@ -3740,24 +3792,13 @@ char *DrasculaEngine::TryInMem(Common::File *Sesion) { return pointer; } -void DrasculaEngine::set_dacSSN(char *dacSSN) { - int n = 0; -// TODO -/* - while (inp(0x3da)&8){}; - while ((inp(0x3da)&8)==0){}; - - outp(0x3c8,0); - do { - outp(0x3c9,dacSSN[n++]); - outp(0x3c9,dacSSN[n++]); - outp(0x3c9,dacSSN[n++]); - } while (n<768); -*/ +void DrasculaEngine::set_dacSSN(byte *dacSSN) { + setvgapalette256((byte *)dacSSN); } -void DrasculaEngine::Des_OFF(char *BufferOFF, char *MiVideoOFF, int Lenght) { - int x = 0, Reps; +void DrasculaEngine::Des_OFF(byte *BufferOFF, byte *MiVideoOFF, int Lenght) { + int x = 0; + unsigned char Reps; int Offset; memset(MiVideoSSN, 0, 64000); @@ -3769,7 +3810,7 @@ void DrasculaEngine::Des_OFF(char *BufferOFF, char *MiVideoOFF, int Lenght) { } } -void DrasculaEngine::Des_RLE(char *BufferRLE, char *MiVideoRLE) { +void DrasculaEngine::Des_RLE(byte *BufferRLE, byte *MiVideoRLE) { signed int con = 0; unsigned int X = 0; unsigned int fExit = 0; @@ -3790,7 +3831,7 @@ void DrasculaEngine::Des_RLE(char *BufferRLE, char *MiVideoRLE) { } } -void DrasculaEngine::MixVideo(char *OldScreen,char *NewScreen) { +void DrasculaEngine::MixVideo(byte *OldScreen, byte *NewScreen) { int x; for (x = 0; x < 64000; x++) OldScreen[x] ^= NewScreen[x]; @@ -3840,19 +3881,8 @@ char *DrasculaEngine::carga_pcx(char *NamePcc) { return AuxBuffDes; } -void DrasculaEngine::set_dac(char *dac) { - int n = 0; - /*retrazo(); - // TODO - outp(0x3c8,0); - do { - - outp(0x3c9,dac[n++]); - outp(0x3c9,dac[n++]); - outp(0x3c9,dac[n++]); - - } while (n<768); - */ +void DrasculaEngine::set_dac(byte *dac) { + setvgapalette256((byte *)dac); } void DrasculaEngine::WaitForNext(long TimeMed) { @@ -3862,16 +3892,7 @@ void DrasculaEngine::WaitForNext(long TimeMed) { } float DrasculaEngine::vez() { -/* TODO - float trasvase; - union REGS in, out; - - in.h.ah=0; - int386(0x1A,&in,&out); - trasvase=((out.w.cx*65536)+out.w.dx)/0.182; - return(trasvase); -*/ - return 0; + return _system->getMillis() / 1000; } void DrasculaEngine::reduce_hare_chico(int x1,int y1, int x2,int y2, int ancho,int alto, int factor, char *dir_inicio, char *dir_fin) { @@ -4076,7 +4097,7 @@ void DrasculaEngine::graba_partida(char nom_game[]) { } void DrasculaEngine::aumenta_num_frame() { - diff_vez=vez()-conta_vez; + diff_vez = vez() - conta_vez; if (diff_vez >= 5.7) { conta_vez = vez(); @@ -4200,6 +4221,7 @@ void DrasculaEngine::pantalla_63(int fl) { } void DrasculaEngine::conversa(const char *nom_fich) { + int h; int juego1 = 1, juego2 = 1, juego3 = 1, juego4 = 1; char frase1[78]; char frase2[78]; @@ -4223,44 +4245,52 @@ void DrasculaEngine::conversa(const char *nom_fich) { strcpy(para_codificar, nom_fich); canal_p(para_codificar); - // TODO - if ((ald = fopen(nom_fich, "rb")) == NULL) { - error("no puedo abrir el archivo"); + ald = new Common::File; + ald->open(nom_fich); + if (!ald->isOpen()) { + error("missing data file"); } - fscanf(ald, "%s", frase1); - fscanf(ald, "%s", frase2); - fscanf(ald, "%s", frase3); - fscanf(ald, "%s", frase4); - fscanf(ald, "%s", suena1); - fscanf(ald, "%s", suena2); - fscanf(ald, "%s", suena3); - fscanf(ald, "%s", suena4); - fscanf(ald, "%d", &respuesta1); - fscanf(ald, "%d", &respuesta2); - fscanf(ald, "%d", &respuesta3); - fclose(ald); + int size = ald->size(); + char *buffer = new char[size]; + ald->read(buffer, size); + delete ald; + for (h = 0; h < size; h++) + buffer[h] ^= 0xff; + + sscanf(buffer, "%s", frase1); + sscanf(buffer, "%s", frase2); + sscanf(buffer, "%s", frase3); + sscanf(buffer, "%s", frase4); + sscanf(buffer, "%s", suena1); + sscanf(buffer, "%s", suena2); + sscanf(buffer, "%s", suena3); + sscanf(buffer, "%s", suena4); + sscanf(buffer, "%d", &respuesta1); + sscanf(buffer, "%d", &respuesta2); + sscanf(buffer, "%d", &respuesta3); + delete buffer; canal_p(para_codificar); longitud = strlen(frase1); -/* for (h = 0; h < longitud; h++) - if (frase1[h] == '') + for (h = 0; h < longitud; h++) + if (frase1[h] == 0xa7) frase1[h] = ' '; longitud = strlen(frase2); for (h = 0; h < longitud; h++) - if (frase2[h] == '') + if (frase2[h] == 0xa7) frase2[h] = ' '; longitud = strlen(frase3); for (h = 0; h < longitud; h++) - if (frase3[h] == '') + if (frase3[h] == 0xa7) frase3[h] = ' '; longitud = strlen(frase4); for (h = 0; h < longitud; h++) - if (frase4[h] == '') + if (frase4[h] == 0xa7) frase4[h] = ' '; -*/ + lee_dibujos("car.alg"); descomprime_dibujo(dir_hare_fondo,1); /* TODO @@ -4642,8 +4672,9 @@ void DrasculaEngine::habla_pianista(const char *dicho, const char *filename) { color_abc(BLANCO); if (hay_sb == 1) { - // TODO - if ((sku = fopen(filename, "rb")) == NULL) { + sku = new Common::File; + sku->open(filename); + if (!sku->isOpen()) { error("no puedo abrir archivo de voz"); } ctvd_init(2); @@ -4678,7 +4709,7 @@ bucless: if (hay_sb == 1) { if (LookForFree() != 0) goto bucless; - fclose(sku); + delete sku; ctvd_terminate(); } else { longitud = longitud - 2; @@ -4721,8 +4752,9 @@ bebiendo: color_abc(VERDE_OSCURO); if (hay_sb == 1) { - // TODO - if ((sku = fopen(filename, "rb")) == NULL) { + sku = new Common::File; + sku->open(filename); + if (!sku->isOpen()) { error("no puedo abrir archivo de voz\n"); } ctvd_init(2); @@ -4756,7 +4788,7 @@ bucless: if (hay_sb == 1) { if (LookForFree() != 0) goto bucless; - fclose(sku); + delete sku; ctvd_terminate(); } else { longitud = longitud - 2; @@ -4797,7 +4829,7 @@ void DrasculaEngine::suma_objeto(int osj) { void DrasculaEngine::fin_sound_corte() { if (hay_sb == 1) { ctvd_stop(); - fclose(sku); + delete sku; ctvd_terminate(); } } @@ -4820,7 +4852,7 @@ void DrasculaEngine::ctvd_terminate() { void DrasculaEngine::ctvd_speaker(int flag) {} -void DrasculaEngine::ctvd_output(FILE *file_handle) {} +void DrasculaEngine::ctvd_output(Common::File *file_handle) {} void DrasculaEngine::ctvd_init(int b) { //TODO diff --git a/engines/drascula/drascula.h b/engines/drascula/drascula.h index e21f9a5f12..00dda68433 100644 --- a/engines/drascula/drascula.h +++ b/engines/drascula/drascula.h @@ -323,6 +323,7 @@ struct DrasculaGameDescription; class DrasculaEngine : public ::Engine { int _gameId; + Common::EventManager *_eventMan; protected: @@ -345,6 +346,7 @@ public: uint32 getFeatures() const; uint16 getVersion() const; Common::Platform getPlatform() const; + void update_events(); void asigna_memoria(); void libera_memoria(); @@ -354,13 +356,13 @@ public: void lee_dibujos(const char *); void descomprime_dibujo(char *dir_escritura, int plt); - typedef unsigned char DacPalette256[256][4]; + typedef unsigned char DacPalette256[256][3]; void asigna_rgb(unsigned char *dir_lectura, int plt); void funde_rgb(int plt); void paleta_hare(); void ActualizaPaleta(); - void setvgapalette256(DacPalette256 *PalBuf); + void setvgapalette256(byte *PalBuf); void DIBUJA_FONDO(int xorg, int yorg, int xdes, int ydes, int Ancho, int Alto, char *Origen, char *Destino); void DIBUJA_BLOQUE(int xorg, int yorg, int xdes, int ydes, int Ancho, @@ -373,7 +375,7 @@ public: DacPalette256 palHareClaro; DacPalette256 palHareOscuro; - char *VGA; + byte *VGA; char *dir_dibujo1; char *dir_hare_fondo; @@ -386,12 +388,11 @@ public: char *dir_texto; char *dir_pendulo; - char cPal[768]; - char *Buffer_pcx; + byte cPal[768]; + byte *Buffer_pcx; long LenFile; - FILE *handle_dibujos; - FILE *ald, *sku; + Common::File *ald, *sku; int hay_sb; int nivel_osc, musica_antes, musica_room; @@ -548,11 +549,11 @@ public: int LookForFree(); void OpenSSN(const char *Name,int Pause); void WaitFrameSSN(); - void MixVideo(char *OldScreen,char *NewScreen); - void Des_RLE(char *BufferRLE, char *MiVideoRLE); - void Des_OFF(char *BufferOFF, char *MiVideoOFF, int Lenght); - void set_dacSSN(char *dacSSN); - char *TryInMem(Common::File *Sesion); + void MixVideo(byte *OldScreen, byte *NewScreen); + void Des_RLE(byte *BufferRLE, byte *MiVideoRLE); + void Des_OFF(byte *BufferOFF, byte *MiVideoOFF, int Lenght); + void set_dacSSN(byte *dacSSN); + byte *TryInMem(Common::File *Sesion); void EndSSN(); int PlayFrameSSN(); int chkkey(); @@ -563,13 +564,13 @@ public: //TODO duplicate char cPal[768]; int Leng; - char *pointer; + byte *pointer; int UsingMem; Common::File *Sesion; - char CHUNK; - char CMP, dacSSN[768]; - char *MiVideoSSN; - char *mSesion; + byte CHUNK; + byte CMP, dacSSN[768]; + byte *MiVideoSSN; + byte *mSesion; int FrameSSN; int GlobalSpeed; int LastFrame; @@ -579,10 +580,10 @@ public: long TimeMed; char *carga_pcx(char *NamePcc); - void set_dac(char *dac); + void set_dac(byte *dac); void WaitForNext(long TimeMed); float vez(); - void reduce_hare_chico(int,int, int,int, int,int, int, char *,char *); + void reduce_hare_chico(int, int, int, int, int, int, int, char *,char *); char codifica(char); void cuadrante_1(); void cuadrante_2(); @@ -611,7 +612,7 @@ public: void ctvd_stop(); void ctvd_terminate(); void ctvd_speaker(int flag); - void ctvd_output(FILE *file_handle); + void ctvd_output(Common::File *file_handle); void ctvd_init(int b); -- cgit v1.2.3 From 485ac1329ca51a165cabfd4a498c1039e720b556 Mon Sep 17 00:00:00 2001 From: Paweł Kołodziejski Date: Sat, 28 Jul 2007 14:51:32 +0000 Subject: ops svn-id: r28271 --- engines/drascula/drascula.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp index 49033516a0..1ca80c37ed 100644 --- a/engines/drascula/drascula.cpp +++ b/engines/drascula/drascula.cpp @@ -322,9 +322,9 @@ void DrasculaEngine::Negro() { for (componente = 0; componente < 3; componente++) palNegra[color][componente] = 0; - palNegra[254][0] = 0xff; - palNegra[254][1] = 0xff; - palNegra[254][2] = 0x57; + palNegra[254][0] = 0x3F; + palNegra[254][1] = 0x3F; + palNegra[254][2] = 0x15; setvgapalette256((byte *)&palNegra); } -- cgit v1.2.3 From 4bce4afbd21a34fb2d3dca36b5460bce168d35e6 Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Sat, 28 Jul 2007 15:15:23 +0000 Subject: Should fix bug #1762614. There is a chance some regression glitches appear in locations where animations are displayed together with character comments. svn-id: r28272 --- engines/parallaction/zone.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/parallaction/zone.cpp b/engines/parallaction/zone.cpp index 485bec1c05..3fcbd0d08c 100644 --- a/engines/parallaction/zone.cpp +++ b/engines/parallaction/zone.cpp @@ -295,6 +295,13 @@ void Parallaction::parseZoneTypeBlock(Script &script, Zone *z) { void Parallaction::displayCharacterComment(ExamineData *data) { if (data->_description == NULL) return; + // NOTE: saving visible screen before displaying comment allows + // to restore the exact situation after the comment is deleted. + // This means animations are restored in the exact position as + // they were, thus avoiding clipping effect as signalled in + // BUG item #1762614. + _gfx->copyScreen(Gfx::kBitFront, Gfx::kBitBack); + _gfx->setFont(kFontDialogue); _gfx->flatBlitCnv(_char._talk, 0, 190, 80, Gfx::kBitFront); @@ -305,8 +312,6 @@ void Parallaction::displayCharacterComment(ExamineData *data) { _gfx->drawBalloon(r, 0); _gfx->displayWrappedString(data->_description, 140, 10, 0, 130); - _gfx->updateScreen(); - waitUntilLeftClick(); _gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront); -- cgit v1.2.3 From 3463604d056a356e7f0ad9595deb919ff17ec60c Mon Sep 17 00:00:00 2001 From: Paweł Kołodziejski Date: Sat, 28 Jul 2007 15:18:21 +0000 Subject: few more fixes svn-id: r28273 --- engines/drascula/drascula.cpp | 51 +++++++++++++++++++++---------------------- engines/drascula/drascula.h | 51 +++++++++++++++++++++---------------------- 2 files changed, 50 insertions(+), 52 deletions(-) (limited to 'engines') diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp index 1ca80c37ed..932cb32b44 100644 --- a/engines/drascula/drascula.cpp +++ b/engines/drascula/drascula.cpp @@ -205,21 +205,21 @@ void DrasculaEngine::salir_al_dos(int r) { } void DrasculaEngine::asigna_memoria() { - dir_zona_pantalla = (char *)malloc(64000); + dir_zona_pantalla = (byte *)malloc(64000); assert(dir_zona_pantalla); - dir_dibujo1 = (char *)malloc(64000); + dir_dibujo1 = (byte *)malloc(64000); assert(dir_dibujo1); - dir_hare_fondo = (char *)malloc(64000); + dir_hare_fondo = (byte *)malloc(64000); assert(dir_hare_fondo); - dir_dibujo3 = (char *)malloc(64000); + dir_dibujo3 = (byte *)malloc(64000); assert(dir_dibujo3); - dir_dibujo2 = (char *)malloc(64000); + dir_dibujo2 = (byte *)malloc(64000); assert(dir_dibujo2); - dir_mesa = (char *)malloc(64000); + dir_mesa = (byte *)malloc(64000); assert(dir_mesa); - dir_hare_dch = (char *)malloc(64000); + dir_hare_dch = (byte *)malloc(64000); assert(dir_hare_dch); - dir_hare_frente = (char *)malloc(64000); + dir_hare_frente = (byte *)malloc(64000); assert(dir_hare_frente); } @@ -273,10 +273,10 @@ void DrasculaEngine::lee_dibujos(const char *NamePcc) { file.close(); } -void DrasculaEngine::descomprime_dibujo(char *dir_escritura, int plt) { +void DrasculaEngine::descomprime_dibujo(byte *dir_escritura, int plt) { memcpy(dir_escritura, Buffer_pcx, 64000); free(Buffer_pcx); - asigna_rgb((unsigned char *)cPal, plt); + asigna_rgb((byte *)cPal, plt); if (plt > 1) funde_rgb(plt); } @@ -290,7 +290,7 @@ void DrasculaEngine::paleta_hare() { } -void DrasculaEngine::asigna_rgb(unsigned char *dir_lectura, int plt) { +void DrasculaEngine::asigna_rgb(byte *dir_lectura, int plt) { int x, cnt = 0; for (x = 0; x < plt; x++) { @@ -348,7 +348,7 @@ void DrasculaEngine::setvgapalette256(byte *PalBuf) { } void DrasculaEngine::DIBUJA_FONDO(int xorg, int yorg, int xdes, int ydes, int Ancho, - int Alto, char *Origen, char *Destino) { + int Alto, byte *Origen, byte *Destino) { int x; Destino += xdes + ydes * 320; Origen += xorg + yorg * 320; @@ -360,7 +360,7 @@ void DrasculaEngine::DIBUJA_FONDO(int xorg, int yorg, int xdes, int ydes, int An } void DrasculaEngine::DIBUJA_BLOQUE(int xorg, int yorg, int xdes, int ydes, int Ancho, - int Alto, char *Origen, char *Destino) { + int Alto, byte *Origen, byte *Destino) { int y, x; Destino += xdes + ydes * 320; @@ -372,7 +372,7 @@ void DrasculaEngine::DIBUJA_BLOQUE(int xorg, int yorg, int xdes, int ydes, int A Destino[x + y * 320] = Origen[x + y * 320]; } -void DrasculaEngine::DIBUJA_BLOQUE_CUT(int *Array, char *Origen, char *Destino) { +void DrasculaEngine::DIBUJA_BLOQUE_CUT(int *Array, byte *Origen, byte *Destino) { int y, x; int xorg = Array[0]; int yorg = Array[1]; @@ -405,7 +405,7 @@ void DrasculaEngine::DIBUJA_BLOQUE_CUT(int *Array, char *Origen, char *Destino) Destino[x + y * 320] = Origen[x + y * 320]; } -void DrasculaEngine::VUELCA_PANTALLA(int xorg, int yorg, int xdes, int ydes, int Ancho, int Alto, char *Buffer) { +void DrasculaEngine::VUELCA_PANTALLA(int xorg, int yorg, int xdes, int ydes, int Ancho, int Alto, byte *Buffer) { int x; VGA += xdes + ydes * 320; @@ -465,8 +465,8 @@ void DrasculaEngine::escoba() { bucles: if (hare_se_mueve == 0) { - paso_x=PASO_HARE_X; - paso_y=PASO_HARE_Y; + paso_x = PASO_HARE_X; + paso_y = PASO_HARE_Y; } if (hare_se_mueve == 0 && anda_a_objeto==1) { sentido_hare = sentido_final; @@ -2120,7 +2120,7 @@ void DrasculaEngine::color_abc(int cl) { setvgapalette256((byte *)&palJuego); } -char DrasculaEngine::LimitaVGA(char valor) { +byte DrasculaEngine::LimitaVGA(byte valor) { return (valor & 0x3F) * (valor > 0); } @@ -2213,8 +2213,8 @@ void DrasculaEngine::anima(const char *animacion, int FPS) { int cnt = 2; TimeMed = CLOCKS_PER_SEC / FPS; - AuxBuffLast = (char *)malloc(65000); - AuxBuffDes = (char *)malloc(65000); + AuxBuffLast = (byte *)malloc(65000); + AuxBuffDes = (byte *)malloc(65000); FileIn.open(animacion); @@ -2224,7 +2224,7 @@ void DrasculaEngine::anima(const char *animacion, int FPS) { FileIn.read(&NFrames, sizeof(NFrames)); FileIn.read(&Leng, sizeof(Leng)); - AuxBuffOrg = (char *)malloc(Leng); + AuxBuffOrg = (byte *)malloc(Leng); FileIn.read(AuxBuffOrg, Leng); FileIn.read(cPal, 768); carga_pcx(AuxBuffOrg); @@ -2237,7 +2237,7 @@ void DrasculaEngine::anima(const char *animacion, int FPS) { WaitForNext(TimeMed); while (cnt < NFrames) { FileIn.read(&Leng, sizeof(Leng)); - AuxBuffOrg = (char *)malloc(Leng); + AuxBuffOrg = (byte *)malloc(Leng); FileIn.read(AuxBuffOrg, Leng); FileIn.read(cPal, 768); carga_pcx(AuxBuffOrg); @@ -2278,7 +2278,6 @@ void DrasculaEngine::FundeAlNegro(int VelocidadDeFundido) { for (color = 0; color < 256; color++) { for (componente = 0; componente < 3; componente++) { palFundido[color][componente] = LimitaVGA(palJuego[color][componente] - 63 + fundido); - palFundido[color][3] = 0; } } pausa(VelocidadDeFundido); @@ -3855,12 +3854,12 @@ int DrasculaEngine::chkkey() { return 0; } -char *DrasculaEngine::carga_pcx(char *NamePcc) { +byte *DrasculaEngine::carga_pcx(byte *NamePcc) { signed int con = 0; unsigned int X = 0; unsigned int fExit = 0; char ch, rep; - char *AuxPun; + byte *AuxPun; AuxPun = AuxBuffDes; @@ -3895,7 +3894,7 @@ float DrasculaEngine::vez() { return _system->getMillis() / 1000; } -void DrasculaEngine::reduce_hare_chico(int x1,int y1, int x2,int y2, int ancho,int alto, int factor, char *dir_inicio, char *dir_fin) { +void DrasculaEngine::reduce_hare_chico(int x1,int y1, int x2,int y2, int ancho,int alto, int factor, byte *dir_inicio, byte *dir_fin) { float suma_x, suma_y; int n, m; float pixel_x, pixel_y; diff --git a/engines/drascula/drascula.h b/engines/drascula/drascula.h index 00dda68433..213d860db1 100644 --- a/engines/drascula/drascula.h +++ b/engines/drascula/drascula.h @@ -354,21 +354,21 @@ public: void salir_al_dos(int r); void lee_dibujos(const char *); - void descomprime_dibujo(char *dir_escritura, int plt); + void descomprime_dibujo(byte *dir_escritura, int plt); - typedef unsigned char DacPalette256[256][3]; + typedef byte DacPalette256[256][3]; - void asigna_rgb(unsigned char *dir_lectura, int plt); + void asigna_rgb(byte *dir_lectura, int plt); void funde_rgb(int plt); void paleta_hare(); void ActualizaPaleta(); void setvgapalette256(byte *PalBuf); void DIBUJA_FONDO(int xorg, int yorg, int xdes, int ydes, int Ancho, - int Alto, char *Origen, char *Destino); + int Alto, byte *Origen, byte *Destino); void DIBUJA_BLOQUE(int xorg, int yorg, int xdes, int ydes, int Ancho, - int Alto, char *Origen, char *Destino); - void DIBUJA_BLOQUE_CUT(int *Array, char *Origen, char *Destino); - void VUELCA_PANTALLA(int xorg, int yorg, int xdes, int ydes, int Ancho, int Alto, char *Buffer); + int Alto, byte *Origen, byte *Destino); + void DIBUJA_BLOQUE_CUT(int *Array, byte *Origen, byte *Destino); + void VUELCA_PANTALLA(int xorg, int yorg, int xdes, int ydes, int Ancho, int Alto, byte *Buffer); DacPalette256 palJuego; DacPalette256 palHare; @@ -377,16 +377,16 @@ public: byte *VGA; - char *dir_dibujo1; - char *dir_hare_fondo; - char *dir_dibujo3; - char *dir_dibujo2; - char *dir_mesa; - char *dir_hare_dch; - char *dir_zona_pantalla; - char *dir_hare_frente; - char *dir_texto; - char *dir_pendulo; + byte *dir_dibujo1; + byte *dir_hare_fondo; + byte *dir_dibujo3; + byte *dir_dibujo2; + byte *dir_mesa; + byte *dir_hare_dch; + byte *dir_zona_pantalla; + byte *dir_hare_frente; + byte *dir_texto; + byte *dir_pendulo; byte cPal[768]; byte *Buffer_pcx; @@ -413,7 +413,7 @@ public: int con_voces; int menu_bar, menu_scr, hay_nombre; char texto_nombre[13]; - char key; + byte key; int flags[NUM_BANDERAS]; @@ -497,7 +497,7 @@ public: int resta_objeto(int osj); void fliplay(const char *filefli, int vel); void FundeDelNegro(int VelocidadDeFundido); - char LimitaVGA(char valor); + byte LimitaVGA(byte valor); void color_abc(int cl); void centra_texto(const char *,int,int); void comienza_sound(const char *); @@ -547,7 +547,7 @@ public: void introduce_nombre(); void para_grabar(char[]); int LookForFree(); - void OpenSSN(const char *Name,int Pause); + void OpenSSN(const char *Name, int Pause); void WaitFrameSSN(); void MixVideo(byte *OldScreen, byte *NewScreen); void Des_RLE(byte *BufferRLE, byte *MiVideoRLE); @@ -558,10 +558,9 @@ public: int PlayFrameSSN(); int chkkey(); - char *AuxBuffOrg; - char *AuxBuffLast; - char *AuxBuffDes; - //TODO duplicate char cPal[768]; + byte *AuxBuffOrg; + byte *AuxBuffLast; + byte *AuxBuffDes; int Leng; byte *pointer; @@ -579,11 +578,11 @@ public: long TimeLast; long TimeMed; - char *carga_pcx(char *NamePcc); + byte *carga_pcx(byte *NamePcc); void set_dac(byte *dac); void WaitForNext(long TimeMed); float vez(); - void reduce_hare_chico(int, int, int, int, int, int, int, char *,char *); + void reduce_hare_chico(int, int, int, int, int, int, int, byte *, byte *); char codifica(char); void cuadrante_1(); void cuadrante_2(); -- cgit v1.2.3 From dbf01ea3fe979c9c81fa15f633c41ef035141e54 Mon Sep 17 00:00:00 2001 From: Paweł Kołodziejski Date: Sat, 28 Jul 2007 19:43:26 +0000 Subject: more fixes svn-id: r28274 --- engines/drascula/drascula.cpp | 277 +++++++++++++++++++++++------------------- engines/drascula/drascula.h | 12 +- 2 files changed, 155 insertions(+), 134 deletions(-) (limited to 'engines') diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp index 932cb32b44..7dc00b2c57 100644 --- a/engines/drascula/drascula.cpp +++ b/engines/drascula/drascula.cpp @@ -26,6 +26,7 @@ #include "common/stdafx.h" #include "common/events.h" +#include "common/keyboard.h" #include "common/file.h" #include "common/savefile.h" #include "common/config-manager.h" @@ -72,8 +73,6 @@ DrasculaEngine::DrasculaEngine(OSystem *syst) : Engine(syst) { _gameId = g->id; _rnd = new Common::RandomSource(); - Common::EventManager *_eventMan = _system->getEventManager(); - } DrasculaEngine::~DrasculaEngine() { @@ -301,18 +300,7 @@ void DrasculaEngine::asigna_rgb(byte *dir_lectura, int plt) { ActualizaPaleta(); } -void DrasculaEngine::funde_rgb(int plt) { -/* TODO: ??? - unsigned int n; - - for (n = 0; n < plt; n++) { - palJuego[n][0] = inp(0x3c9); - palJuego[n][1] = inp(0x3c9); - palJuego[n][2] = inp(0x3c9); - } - ActualizaPaleta(); -*/ -} +void DrasculaEngine::funde_rgb(int plt) {} void DrasculaEngine::Negro() { int color, componente; @@ -407,12 +395,13 @@ void DrasculaEngine::DIBUJA_BLOQUE_CUT(int *Array, byte *Origen, byte *Destino) void DrasculaEngine::VUELCA_PANTALLA(int xorg, int yorg, int xdes, int ydes, int Ancho, int Alto, byte *Buffer) { int x; + byte *ptr = VGA; - VGA += xdes + ydes * 320; + ptr += xdes + ydes * 320; Buffer += xorg + yorg * 320; for (x = 0; x < Alto; x++) { - memcpy(VGA, Buffer, Ancho); - VGA += 320; + memcpy(ptr, Buffer, Ancho); + ptr += 320; Buffer += 320; } @@ -1189,10 +1178,36 @@ void DrasculaEngine::para_cargar(char nom_game[]) { sin_verbo(); } +static char *getLine(Common::File *fp, char *buf, int len) { + int c; + char *b; + + for (;;) { + b = buf; + while (!fp->eos()) { + c = fp->readByte() ^ 0xff; + if (c == '\r') + continue; + if (c == '\n') + break; + if (b - buf >= (len - 1)) + break; + *b++ = c; + } + *b = '\0'; + if (fp->eos() && b == buf) + return NULL; + if (b != buf) + break; + } + return buf; +} + void DrasculaEngine::carga_escoba(const char *nom_fich) { int l, obj_salir; float chiquez, pequegnez = 0; char para_codificar[13]; + char buffer[256]; hay_nombre = 0; @@ -1208,50 +1223,73 @@ void DrasculaEngine::carga_escoba(const char *nom_fich) { error("missing data file"); } int size = ald->size(); - char *buffer = new char[size]; - ald->read(buffer, size); - delete ald; - for (l = 0; l < size; l++) - buffer[l] ^= 0xff; + getLine(ald, buffer, size); sscanf(buffer, "%s", num_room); strcat(num_room,".alg"); + + getLine(ald, buffer, size); sscanf(buffer, "%d", &musica_room); + getLine(ald, buffer, size); sscanf(buffer, "%s", pantalla_disco); + getLine(ald, buffer, size); sscanf(buffer, "%d", &nivel_osc); + getLine(ald, buffer, size); sscanf(buffer, "%d", &objs_room); for (l = 0; l < objs_room;l++) { + getLine(ald, buffer, size); sscanf(buffer, "%d", &num_obj[l]); + getLine(ald, buffer, size); sscanf(buffer, "%s", nombre_obj[l]); + getLine(ald, buffer, size); sscanf(buffer, "%d", &x1[l]); + getLine(ald, buffer, size); sscanf(buffer, "%d", &y1[l]); + getLine(ald, buffer, size); sscanf(buffer, "%d", &x2[l]); + getLine(ald, buffer, size); sscanf(buffer, "%d", &y2[l]); + getLine(ald, buffer, size); sscanf(buffer, "%d", &sitiobj_x[l]); + getLine(ald, buffer, size); sscanf(buffer, "%d", &sitiobj_y[l]); + getLine(ald, buffer, size); sscanf(buffer, "%d", &sentidobj[l]); + getLine(ald, buffer, size); sscanf(buffer, "%d", &visible[l]); + getLine(ald, buffer, size); sscanf(buffer, "%d", &espuerta[l]); if (espuerta[l] != 0) { + getLine(ald, buffer, size); sscanf(buffer, "%s", alapantallakeva[l]); + getLine(ald, buffer, size); sscanf(buffer, "%d", &x_alakeva[l]); + getLine(ald, buffer, size); sscanf(buffer, "%d", &y_alakeva[l]); + getLine(ald, buffer, size); sscanf(buffer, "%d", &sentido_alkeva[l]); + getLine(ald, buffer, size); sscanf(buffer, "%d", &alapuertakeva[l]); puertas_cerradas(l); } } + getLine(ald, buffer, size); sscanf(buffer, "%d", &suelo_x1); + getLine(ald, buffer, size); sscanf(buffer, "%d", &suelo_y1); + getLine(ald, buffer, size); sscanf(buffer, "%d", &suelo_x2); + getLine(ald, buffer, size); sscanf(buffer, "%d", &suelo_y2); + getLine(ald, buffer, size); sscanf(buffer, "%d", &lejos); + getLine(ald, buffer, size); sscanf(buffer, "%d", &cerca); - delete buffer; + delete ald; canal_p(para_codificar); @@ -1375,16 +1413,16 @@ void DrasculaEngine::comprueba_objetos() { && x_raton < x2[l] && y_raton < y2[l] && visible[l] == 1 && espuerta[l] == 0) { strcpy(texto_nombre, nombre_obj[l]); - hay_nombre=1; - veo=1; + hay_nombre = 1; + veo = 1; } } if (x_raton > hare_x + 2 && y_raton > hare_y + 2 && x_raton < hare_x + ancho_hare - 2 && y_raton < hare_y + alto_hare - 2 && veo == 0) { strcpy(texto_nombre, "hacker"); - hay_nombre=1; - veo=1; + hay_nombre = 1; + veo = 1; } if (veo == 0) @@ -1392,19 +1430,11 @@ void DrasculaEngine::comprueba_objetos() { } void DrasculaEngine::espera_soltar() { - // TODO - //boton_izq=sal.w.bx & 1; - //boton_dch=(sal.w.bx >> 1) & 1; - //x_raton=sal.w.cx >> 1; - //y_raton=sal.w.dx; + update_events(); } void DrasculaEngine::MirarRaton() { - // TODO - //boton_izq=sal.w.bx & 1; - //boton_dch=(sal.w.bx >> 1) & 1; - //x_raton=sal.w.cx >> 1; - //y_raton=sal.w.dx; + update_events(); } void DrasculaEngine::elige_en_barra() { @@ -1491,39 +1521,41 @@ void DrasculaEngine::comprueba2() { } } -char DrasculaEngine::getscan() { - // TODO - return 0; +byte DrasculaEngine::getscan() { + update_events(); + + return _keyPressed.ascii; } void DrasculaEngine::update_events() { Common::Event event; + Common::EventManager *eventMan = _system->getEventManager(); - while (_eventMan->pollEvent(event)) { + while (eventMan->pollEvent(event)) { switch (event.type) { case Common::EVENT_KEYDOWN: -// _keyPressed = event.kbd; + _keyPressed = event.kbd; + break; + case Common::EVENT_KEYUP: + _keyPressed = event.kbd; break; -/* case Common::EVENT_MOUSEMOVE: - _mouseX = event.mouse.x; - _mouseY = event.mouse.y; + case Common::EVENT_MOUSEMOVE: + x_raton = event.mouse.x; + y_raton = event.mouse.y; break; case Common::EVENT_LBUTTONDOWN: - _mouseDown = true; - _mouseState |= BS1L_BUTTON_DOWN; + boton_izq = 1; break; case Common::EVENT_LBUTTONUP: - _mouseDown = false; - _mouseState |= BS1L_BUTTON_UP; + boton_izq = 0; break; - case Common::EVENT_WHEELUP: - _mouseDown = false; - _mouseState |= BS1_WHEEL_UP; + case Common::EVENT_RBUTTONDOWN: + boton_dch = 1; break; - case Common::EVENT_WHEELDOWN: - _mouseDown = false; - _mouseState |= BS1_WHEEL_DOWN; + case Common::EVENT_RBUTTONUP: + boton_dch = 0; break; +/* // TODO case Common::EVENT_QUIT: break; */ default: @@ -2048,7 +2080,7 @@ void DrasculaEngine::salva_pantallas() { void DrasculaEngine::fliplay(const char *filefli, int vel) { OpenSSN(filefli, vel); while (PlayFrameSSN() && (!term_int)) { - if (chkkey() == 27) + if (getscan() == 27) term_int = 1; } EndSSN(); @@ -2300,9 +2332,9 @@ void DrasculaEngine::habla_dr_grande(const char *dicho, const char *filename) { int longitud; longitud = strlen(dicho); - tiempol = time(NULL); + tiempol = _system->getMillis(); tiempou = (unsigned int)tiempol / 2; - srand(tiempou); + _rnd->setSeed(tiempou); buffer_teclado(); @@ -2321,7 +2353,7 @@ void DrasculaEngine::habla_dr_grande(const char *dicho, const char *filename) { bucless: - cara = rand() % 4; + cara = _rnd->getRandomNumber(3); DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); DIBUJA_FONDO(interf_x[l] + 24, interf_y[l], 0, 45, 39, 31, dir_dibujo2, dir_zona_pantalla); DIBUJA_FONDO(x_habla[cara], 1, 171, 68, 45, 48, dir_dibujo2, dir_zona_pantalla); @@ -2417,7 +2449,7 @@ void DrasculaEngine::habla_igor_dch(const char *dicho, const char *filename) { tiempol = time (NULL); tiempou = (unsigned int)tiempol / 2; - srand(tiempou); + _rnd->setSeed(tiempou); buffer_teclado(); @@ -2436,7 +2468,7 @@ void DrasculaEngine::habla_igor_dch(const char *dicho, const char *filename) { bucless: - cara = rand() % 8; + cara = _rnd->getRandomNumber(7); DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); @@ -2491,9 +2523,8 @@ void DrasculaEngine::habla_dr_izq(const char *dicho, const char *filename) { int longitud; longitud = strlen(dicho); - tiempol = time(NULL); // TODO + tiempol = _system->getMillis(); tiempou = (unsigned int)tiempol / 2; - srand(tiempou); buffer_teclado(); @@ -2512,7 +2543,7 @@ void DrasculaEngine::habla_dr_izq(const char *dicho, const char *filename) { bucless: - cara=rand() % 8; + cara = _rnd->getRandomNumber(7); DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); @@ -2567,10 +2598,9 @@ void DrasculaEngine::habla_dr_dch(const char *dicho, const char *filename) { int longitud; longitud = strlen(dicho); - // TODO - tiempol = time(NULL); + tiempol = _system->getMillis(); tiempou = (unsigned int)tiempol / 2; - srand(tiempou); + _rnd->setSeed(tiempou); buffer_teclado(); @@ -2589,7 +2619,7 @@ void DrasculaEngine::habla_dr_dch(const char *dicho, const char *filename) { bucless: - cara = rand() % 8; + cara = _rnd->getRandomNumber(7); DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); actualiza_refresco_antes(); @@ -2640,9 +2670,9 @@ void DrasculaEngine::habla_solo(const char *dicho, const char *filename) { int longitud; longitud = strlen(dicho); - tiempol = time(NULL); + tiempol = _system->getMillis(); tiempou = (unsigned int)tiempol / 2; - srand(tiempou); + _rnd->setSeed(tiempou); color_abc(color_solo); @@ -2691,10 +2721,9 @@ void DrasculaEngine::habla_igor_frente(const char *dicho, const char *filename) int longitud; longitud = strlen(dicho); - // TODO - tiempol = time(NULL); + tiempol = _system->getMillis(); tiempou = (unsigned int)tiempol / 2; - srand(tiempou); + _rnd->setSeed(tiempou); buffer_teclado(); @@ -2713,7 +2742,7 @@ void DrasculaEngine::habla_igor_frente(const char *dicho, const char *filename) bucless: - cara = rand() % 8; + cara = _rnd->getRandomNumber(7); DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); @@ -2768,9 +2797,9 @@ void DrasculaEngine::habla_tabernero(const char *dicho, const char *filename) { int longitud; longitud = strlen(dicho); - tiempol = time(NULL); + tiempol = _system->getMillis(); tiempou = (unsigned int)tiempol / 2; - srand(tiempou); + _rnd->setSeed(tiempou); buffer_teclado(); @@ -2792,7 +2821,7 @@ bucless: if (music_status() == 0) playmusic(musica_room); - cara = rand() % 9; + cara = _rnd->getRandomNumber(8); DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); @@ -2873,9 +2902,9 @@ void DrasculaEngine::habla_bj(const char *dicho, const char *filename) { int longitud; longitud = strlen(dicho); - tiempol = time(NULL); + tiempol = _system->getMillis(); tiempou = (unsigned int)tiempol / 2; - srand(tiempou); + _rnd->setSeed(tiempou); buffer_teclado(); @@ -2894,7 +2923,7 @@ void DrasculaEngine::habla_bj(const char *dicho, const char *filename) { bucless: - cara = rand() % 5; + cara = _rnd->getRandomNumber(4); DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); @@ -2950,9 +2979,9 @@ void DrasculaEngine::hablar(const char *dicho, const char *filename) { int longitud; longitud = strlen(dicho); - tiempol = time(NULL); + tiempol = _system->getMillis(); tiempou = (unsigned int)tiempol / 2; - srand(tiempou); + _rnd->setSeed(tiempou); if (factor_red[hare_y + alto_hare] == 100) suma_1_pixel = 0; @@ -2972,7 +3001,7 @@ void DrasculaEngine::hablar(const char *dicho, const char *filename) { bucless: - cara = rand() % 6; + cara = _rnd->getRandomNumber(5); DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); @@ -3096,6 +3125,7 @@ void DrasculaEngine::refresca_pantalla() { void DrasculaEngine::carga_partida(const char *nom_game) { int l, n_ejec2; + char buffer[256]; canal_p(nom_game); sku = new Common::File; @@ -3104,33 +3134,38 @@ void DrasculaEngine::carga_partida(const char *nom_game) { error("missing data file"); } int size = sku->size(); - char *buffer = new char[size]; - sku->read(buffer, size); - delete sku; - for (l = 0; l < size; l++) - buffer[l] ^= 0xff; + getLine(ald, buffer, size); sscanf(buffer, "%d", &n_ejec2); if (n_ejec2 != num_ejec) { canal_p(nom_game); strcpy(nom_partida, nom_game); salir_al_dos(n_ejec2); } + getLine(ald, buffer, size); sscanf(buffer, "%s", datos_actuales); + getLine(ald, buffer, size); sscanf(buffer, "%d", &hare_x); + getLine(ald, buffer, size); sscanf(buffer, "%d", &hare_y); + getLine(ald, buffer, size); sscanf(buffer, "%d", &sentido_hare); for (l = 1; l < 43; l++) { + getLine(ald, buffer, size); sscanf(buffer, "%d", &objetos_que_tengo[l]); } for (l = 0; l < NUM_BANDERAS; l++) { + getLine(ald, buffer, size); sscanf(buffer, "%d", &flags[l]); } + getLine(ald, buffer, size); sscanf(buffer, "%d", &lleva_objeto); + getLine(ald, buffer, size); sscanf(buffer, "%d", &objeto_que_lleva); + delete ald; canal_p(nom_game); } @@ -3143,12 +3178,12 @@ void DrasculaEngine::canal_p(const char *fich){ strcpy(fich2, "top"); - // TODO ald3.open(fich); if (!ald3.isOpen()) { error("no puedo abrir el archivo codificado"); } + // TODO ald2.open(fich2, Common::File::kFileWriteMode); if (!ald2.isOpen()) { error("no puedo abrir el archivo destino"); @@ -3532,7 +3567,7 @@ void DrasculaEngine::cursor_mesa() { } void DrasculaEngine::introduce_nombre() { - char key; + byte key; int v = 0, h = 0; char select2[23]; strcpy(select2, " "); @@ -3841,19 +3876,6 @@ void DrasculaEngine::WaitFrameSSN() { LastFrame = LastFrame + GlobalSpeed; } -int DrasculaEngine::chkkey() { - //TODO -/* - union REGS registros; - - registros.h.ah=0x06; - registros.h.dl=0xff; - intdos(®istros,®istros); - return(registros.h.al); -*/ - return 0; -} - byte *DrasculaEngine::carga_pcx(byte *NamePcc) { signed int con = 0; unsigned int X = 0; @@ -4021,10 +4043,8 @@ void DrasculaEngine::refresca_62_antes() { int borracho_x[] = {1, 42, 83, 124, 165, 206, 247, 1 }; int diferencia; - DIBUJA_FONDO(123, velas_y[frame_velas], 142, 14, 39, 13, - dir_dibujo3, dir_zona_pantalla); - DIBUJA_FONDO(cirio_x[frame_velas], 146, 311, 80, 4, 8, - dir_dibujo3, dir_zona_pantalla); + DIBUJA_FONDO(123, velas_y[frame_velas], 142, 14, 39, 13, dir_dibujo3, dir_zona_pantalla); + DIBUJA_FONDO(cirio_x[frame_velas], 146, 311, 80, 4, 8, dir_dibujo3, dir_zona_pantalla); if (parpadeo == 5) DIBUJA_FONDO(1, 149, 127, 52, 9, 5, dir_dibujo3, dir_zona_pantalla); @@ -4033,16 +4053,14 @@ void DrasculaEngine::refresca_62_antes() { DIBUJA_FONDO(31, 138, 178, 51, 18, 16, dir_dibujo3, dir_zona_pantalla); if (flags[11] == 0) - DIBUJA_FONDO(pianista_x[frame_piano], 157, 245, 130, 29, 42, - dir_dibujo3, dir_zona_pantalla); + DIBUJA_FONDO(pianista_x[frame_piano], 157, 245, 130, 29, 42, dir_dibujo3, dir_zona_pantalla); else if (flags[5] == 0) DIBUJA_FONDO(145, 139, 228, 112, 47, 60, dir_hare_dch, dir_zona_pantalla); else DIBUJA_FONDO(165, 140, 229, 117, 43, 59, dir_dibujo3, dir_zona_pantalla); if (flags[12] == 1) - DIBUJA_FONDO(borracho_x[frame_borracho], 82, 170, 50, 40, 53, - dir_dibujo3, dir_zona_pantalla); + DIBUJA_FONDO(borracho_x[frame_borracho], 82, 170, 50, 40, 53, dir_dibujo3, dir_zona_pantalla); diferencia = vez() - conta_ciego_vez; if (diferencia > 6) { @@ -4052,7 +4070,7 @@ void DrasculaEngine::refresca_62_antes() { frame_borracho = 0; flags[12] = 0; } - } else if (((rand() % 95) == 15) && (flags[13] == 0)) + } else if ((_rnd->getRandomNumber(94) == 15) && (flags[13] == 0)) flags[12] = 1; frame_velas++; @@ -4061,7 +4079,7 @@ void DrasculaEngine::refresca_62_antes() { frame_piano++; if (frame_piano == 9) frame_piano = 0; - parpadeo = rand() % 11; + parpadeo = _rnd->getRandomNumber(10); conta_ciego_vez = vez(); } } @@ -4238,6 +4256,7 @@ void DrasculaEngine::conversa(const char *nom_fich) { int usado1 = 0; int usado2 = 0; int usado3 = 0; + char buffer[256]; rompo_y_salgo = 0; @@ -4250,24 +4269,30 @@ void DrasculaEngine::conversa(const char *nom_fich) { error("missing data file"); } int size = ald->size(); - char *buffer = new char[size]; - ald->read(buffer, size); - delete ald; - for (h = 0; h < size; h++) - buffer[h] ^= 0xff; + getLine(ald, buffer, size); sscanf(buffer, "%s", frase1); + getLine(ald, buffer, size); sscanf(buffer, "%s", frase2); + getLine(ald, buffer, size); sscanf(buffer, "%s", frase3); + getLine(ald, buffer, size); sscanf(buffer, "%s", frase4); + getLine(ald, buffer, size); sscanf(buffer, "%s", suena1); + getLine(ald, buffer, size); sscanf(buffer, "%s", suena2); + getLine(ald, buffer, size); sscanf(buffer, "%s", suena3); + getLine(ald, buffer, size); sscanf(buffer, "%s", suena4); + getLine(ald, buffer, size); sscanf(buffer, "%d", &respuesta1); + getLine(ald, buffer, size); sscanf(buffer, "%d", &respuesta2); + getLine(ald, buffer, size); sscanf(buffer, "%d", &respuesta3); - delete buffer; + delete ald; canal_p(para_codificar); longitud = strlen(frase1); @@ -4357,7 +4382,7 @@ bucle_opc: responde(respuesta3); } else if ((boton_izq == 1) && (juego4 == 2)) { hablar(frase4, suena4); - rompo_y_salgo=1; + rompo_y_salgo = 1; } if (boton_izq == 1) @@ -4662,9 +4687,9 @@ void DrasculaEngine::habla_pianista(const char *dicho, const char *filename) { int longitud; longitud = strlen(dicho); - tiempol = time(NULL); + tiempol = _system->getMillis(); tiempou = (unsigned int)tiempol / 2; - srand(tiempou); + _rnd->setSeed(tiempou); buffer_teclado(); @@ -4683,7 +4708,7 @@ void DrasculaEngine::habla_pianista(const char *dicho, const char *filename) { bucless: - cara = rand() % 4; + cara = _rnd->getRandomNumber(3); DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); @@ -4729,9 +4754,9 @@ void DrasculaEngine::habla_borracho(const char *dicho, const char *filename) { int longitud; longitud = strlen(dicho); - tiempol = time(NULL); + tiempol = _system->getMillis(); tiempou = (unsigned int)tiempol / 2; - srand(tiempou); + _rnd->setSeed(tiempou); lee_dibujos("an11y13.alg"); descomprime_dibujo(dir_hare_frente, 1); @@ -4763,7 +4788,7 @@ bebiendo: bucless: - cara = rand() % 8; + cara = _rnd->getRandomNumber(7); DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); diff --git a/engines/drascula/drascula.h b/engines/drascula/drascula.h index 213d860db1..1515f9803b 100644 --- a/engines/drascula/drascula.h +++ b/engines/drascula/drascula.h @@ -34,6 +34,8 @@ #include "common/savefile.h" #include "common/system.h" #include "common/hash-str.h" +#include "common/events.h" +#include "common/keyboard.h" #include "engines/engine.h" @@ -323,7 +325,7 @@ struct DrasculaGameDescription; class DrasculaEngine : public ::Engine { int _gameId; - Common::EventManager *_eventMan; + Common::KeyState _keyPressed; protected: @@ -454,17 +456,12 @@ public: int corta_musica; char select[23]; int hay_seleccion; - - - // TODO below int x_raton; int y_raton; int y_raton_ant; int boton_izq; int boton_dch; - - void escoba(); void Negro(); void agarra_objeto(int); @@ -483,7 +480,7 @@ public: void elige_en_barra(); void comprueba1(); void comprueba2(); - char getscan(); + byte getscan(); void elige_verbo(int); void mesa(); void saves(); @@ -556,7 +553,6 @@ public: byte *TryInMem(Common::File *Sesion); void EndSSN(); int PlayFrameSSN(); - int chkkey(); byte *AuxBuffOrg; byte *AuxBuffLast; -- cgit v1.2.3 From 3f01ae069af93036be52f4914658c8e55d3fe119 Mon Sep 17 00:00:00 2001 From: Paweł Kołodziejski Date: Sat, 28 Jul 2007 21:15:35 +0000 Subject: formating and correction svn-id: r28276 --- engines/drascula/drascula.cpp | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'engines') diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp index 7dc00b2c57..426c946491 100644 --- a/engines/drascula/drascula.cpp +++ b/engines/drascula/drascula.cpp @@ -942,7 +942,7 @@ void DrasculaEngine::animacion_1() { playmusic(2); pausa(5); fliplay("intro.bin", 12); - term_int=1; + term_int = 1; } borra_pantalla(); lee_dibujos("96.alg"); @@ -1162,7 +1162,7 @@ void DrasculaEngine::sin_verbo() { int c = 171; if (menu_scr == 1) c = 0; - if (lleva_objeto==1) + if (lleva_objeto == 1) suma_objeto(objeto_que_lleva); DIBUJA_FONDO(0, c, 0, 0, ANCHOBJ,ALTOBJ, dir_hare_fondo, dir_dibujo3); @@ -1338,7 +1338,7 @@ void DrasculaEngine::carga_escoba(const char *nom_fich) { alto_hare = (ALTO_PERSONAJE * factor_red[hare_y]) / 100; ancho_hare = (ANCHO_PERSONAJE * factor_red[hare_y]) / 100; } - hare_se_mueve=0; + hare_se_mueve = 0; actualiza_datos(); @@ -1356,8 +1356,8 @@ void DrasculaEngine::borra_pantalla() { } void DrasculaEngine::lleva_al_hare(int punto_x, int punto_y) { - sitio_x=punto_x; - sitio_y=punto_y; + sitio_x = punto_x; + sitio_y = punto_y; empieza_andar(); for(;;) { @@ -2174,9 +2174,9 @@ void DrasculaEngine::centra_texto(const char *mensaje, int x_texto, int y_texto) strcpy(m1, mensaje); if (x_texto < 60) - x_texto=60; + x_texto = 60; if (x_texto > 255) - x_texto=255; + x_texto = 255; x_texto1 = x_texto; @@ -2284,7 +2284,7 @@ void DrasculaEngine::anima(const char *animacion, int FPS) { key = getscan(); if (key == 0x01) term_int = 1; - if (key !=0) + if (key != 0) break; } free(AuxBuffLast); @@ -2319,7 +2319,15 @@ void DrasculaEngine::FundeAlNegro(int VelocidadDeFundido) { } void DrasculaEngine::pausa(int cuanto) { - _system->delayMillis(cuanto); + int diferencia, conta_antes; + + conta_antes = vez(); + + for (;;) { + diferencia = vez() - conta_antes; + if (diferencia >= 2 * cuanto) + break; + } } void DrasculaEngine::habla_dr_grande(const char *dicho, const char *filename) { @@ -3913,7 +3921,7 @@ void DrasculaEngine::WaitForNext(long TimeMed) { } float DrasculaEngine::vez() { - return _system->getMillis() / 1000; + return _system->getMillis(); } void DrasculaEngine::reduce_hare_chico(int x1,int y1, int x2,int y2, int ancho,int alto, int factor, byte *dir_inicio, byte *dir_fin) { -- cgit v1.2.3 From c879386fc8b78577ed37a40d9c33fe9718dad3f1 Mon Sep 17 00:00:00 2001 From: Paweł Kołodziejski Date: Sat, 28 Jul 2007 21:36:46 +0000 Subject: correction for palette and formating svn-id: r28277 --- engines/drascula/drascula.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'engines') diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp index 426c946491..2623f1cb1f 100644 --- a/engines/drascula/drascula.cpp +++ b/engines/drascula/drascula.cpp @@ -293,9 +293,9 @@ void DrasculaEngine::asigna_rgb(byte *dir_lectura, int plt) { int x, cnt = 0; for (x = 0; x < plt; x++) { - palJuego[x][0] = dir_lectura[cnt++]; - palJuego[x][1] = dir_lectura[cnt++]; - palJuego[x][2] = dir_lectura[cnt++]; + palJuego[x][0] = dir_lectura[cnt++] / 4; + palJuego[x][1] = dir_lectura[cnt++] / 4; + palJuego[x][2] = dir_lectura[cnt++] / 4; } ActualizaPaleta(); } @@ -2367,7 +2367,7 @@ bucless: DIBUJA_FONDO(x_habla[cara], 1, 171, 68, 45, 48, dir_dibujo2, dir_zona_pantalla); l++; if (l == 7) - l=0; + l =0; if (con_voces == 0) centra_texto(dicho, 191, 69); @@ -3230,7 +3230,7 @@ void DrasculaEngine::funde_hare(int oscuridad) { for (fundido = oscuridad; fundido >= 0; fundido--) { for (color = 235; color < 253; color++) { for (componente = 0; componente < 3; componente++) - palJuego[color][componente] = LimitaVGA( palJuego[color][componente] - 8 + fundido ); + palJuego[color][componente] = LimitaVGA(palJuego[color][componente] - 8 + fundido); } } -- cgit v1.2.3 From df41a5faef8a52de8a6fbba85142834df2fa9cdc Mon Sep 17 00:00:00 2001 From: Paweł Kołodziejski Date: Sat, 28 Jul 2007 22:00:21 +0000 Subject: fix display fonts svn-id: r28278 --- engines/drascula/drascula.cpp | 206 ++++++++++++++++++++---------------------- 1 file changed, 100 insertions(+), 106 deletions(-) (limited to 'engines') diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp index 2623f1cb1f..0168e12972 100644 --- a/engines/drascula/drascula.cpp +++ b/engines/drascula/drascula.cpp @@ -1791,206 +1791,200 @@ void DrasculaEngine::print_abc(const char *dicho, int x_pantalla, int y_pantalla int i = 0, y_de_letra = 0, x_de_letra = 0, h, longitud; longitud = strlen(dicho); - // FIXME: We can't do this on read-only strings! -#if 0 - for (i = 0; dicho[i]; i++) - dicho[i] = toupper(dicho[i]); -#endif - for (h = 0; h < longitud; h++) { y_de_letra = Y_ABC; -/* - if (dicho[h] == 'A') + char c = toupper(dicho[h]); + if (c == 'A') x_de_letra = X_A; - else if (dicho[h] == 'B') + else if (c == 'B') x_de_letra = X_B; - else if (dicho[h] == 'C') + else if (c == 'C') x_de_letra = X_C; - else if (dicho[h] == 'D') + else if (c == 'D') x_de_letra = X_D; - else if (dicho[h] == 'E') + else if (c == 'E') x_de_letra = X_E; - else if (dicho[h] == 'F') + else if (c == 'F') x_de_letra = X_F; - else if (dicho[h] == 'G') + else if (c == 'G') x_de_letra = X_G; - else if (dicho[h] == 'H') + else if (c == 'H') x_de_letra = X_H; - else if (dicho[h] == 'I') + else if (c == 'I') x_de_letra = X_I; - else if (dicho[h] == 'J') + else if (c == 'J') x_de_letra = X_J; - else if (dicho[h] == 'K') + else if (c == 'K') x_de_letra = X_K; - else if (dicho[h] == 'L') + else if (c == 'L') x_de_letra = X_L; - else if (dicho[h] == 'M') + else if (c == 'M') x_de_letra = X_M; - else if (dicho[h] == 'N') + else if (c == 'N') x_de_letra = X_N; - else if (dicho[h] == '') - x_de_letra = X_GN; - else if (dicho[h] == '') - x_de_letra = X_GN; - else if (dicho[h] == 'O') +//TODO else if (c == '') +// x_de_letra = X_GN; +// else if (c == '') +// x_de_letra = X_GN; + else if (c == 'O') x_de_letra = X_O; - else if (dicho[h] == 'P') + else if (c == 'P') x_de_letra = X_P; - else if (dicho[h] == 'Q') + else if (c == 'Q') x_de_letra = X_Q; - else if (dicho[h] == 'R') + else if (c == 'R') x_de_letra = X_R; - else if (dicho[h] == 'S') + else if (c == 'S') x_de_letra = X_S; - else if (dicho[h] == 'T') + else if (c == 'T') x_de_letra = X_T; - else if (dicho[h] == 'U') + else if (c == 'U') x_de_letra = X_U; - else if (dicho[h] == 'V') + else if (c == 'V') x_de_letra = X_V; - else if (dicho[h] == 'W') + else if (c == 'W') x_de_letra = X_W; - else if (dicho[h] == 'X') + else if (c == 'X') x_de_letra = X_X; - else if (dicho[h] == 'Y') + else if (c == 'Y') x_de_letra = X_Y; - else if (dicho[h] == 'Z') + else if (c == 'Z') x_de_letra = X_Z; - else if (dicho[h] == '' || dicho[h] == ' ') + else if (/*c == 0xa7 ||*/ c == ' ') x_de_letra = ESPACIO; else { y_de_letra = Y_SIGNOS; - if (dicho[h] == '.') + if (c == '.') x_de_letra = X_PUNTO; - else if (dicho[h] == ',') + else if (c == ',') x_de_letra = X_COMA; - else if (dicho[h] == '-') + else if (c == '-') x_de_letra = X_GUION; - else if (dicho[h] == '?') + else if (c == '?') x_de_letra = X_CIERRA_INTERROGACION; - else if (dicho[h] == '') - x_de_letra = X_ABRE_INTERROGACION; - else if (dicho[h] == '"') +//TODO else if (c == '') +// x_de_letra = X_ABRE_INTERROGACION; + else if (c == '"') x_de_letra = X_COMILLAS; - else if (dicho[h] == '!') + else if (c == '!') x_de_letra = X_CIERRA_EXCLAMACION; - else if (dicho[h] == '') - x_de_letra = X_ABRE_EXCLAMACION; - else if (dicho[h] == ';') +//TODO else if (c == '') +// x_de_letra = X_ABRE_EXCLAMACION; + else if (c == ';') x_de_letra = X_PUNTO_Y_COMA; - else if (dicho[h] == '>') + else if (c == '>') x_de_letra = X_MAYOR_QUE; - else if (dicho[h] == '<') + else if (c == '<') x_de_letra = X_MENOR_QUE; - else if (dicho[h] == '$') + else if (c == '$') x_de_letra = X_DOLAR; - else if (dicho[h] == '%') + else if (c == '%') x_de_letra = X_POR_CIENTO; - else if (dicho[h] == ':') + else if (c == ':') x_de_letra = X_DOS_PUNTOS; - else if (dicho[h] == '&') + else if (c == '&') x_de_letra = X_AND; - else if (dicho[h] == '/') + else if (c == '/') x_de_letra = X_BARRA; - else if (dicho[h] == '(') + else if (c == '(') x_de_letra = X_ABRE_PARENTESIS; - else if (dicho[h] == ')') + else if (c == ')') x_de_letra = X_CIERRA_PARENTESIS; - else if (dicho[h] == '*') + else if (c == '*') x_de_letra = X_ASTERISCO; - else if (dicho[h] == '+') + else if (c == '+') x_de_letra = X_MAS; - else if (dicho[h] == '1') + else if (c == '1') x_de_letra = X_N1; - else if (dicho[h] == '2') + else if (c == '2') x_de_letra = X_N2; - else if (dicho[h] == '3') + else if (c == '3') x_de_letra = X_N3; - else if (dicho[h] == '4') + else if (c == '4') x_de_letra = X_N4; - else if (dicho[h] == '5') + else if (c == '5') x_de_letra = X_N5; - else if (dicho[h] == '6') + else if (c == '6') x_de_letra = X_N6; - else if (dicho[h] == '7') + else if (c == '7') x_de_letra = X_N7; - else if (dicho[h] == '8') + else if (c == '8') x_de_letra = X_N8; - else if (dicho[h] == '9') + else if (c == '9') x_de_letra = X_N9; - else if (dicho[h] == '0') + else if (c == '0') x_de_letra = X_N0; else y_de_letra = Y_ACENTOS; - - if (dicho[h] == '') +/* + if (c == '') x_de_letra = X_A; - else if (dicho[h] == '') + else if (c == '') x_de_letra = X_B; - else if (dicho[h] == '') + else if (c == '') x_de_letra = X_C; - else if (dicho[h] == '') + else if (c == '') x_de_letra = X_D; - else if (dicho[h] == '') + else if (c == '') x_de_letra = X_E; - else if (dicho[h] == '') + else if (c == '') x_de_letra = X_F; - else if (dicho[h] == '') + else if (c == '') x_de_letra = X_G; - else if (dicho[h] == '') + else if (c == '') x_de_letra = X_H; - else if (dicho[h] == '') + else if (c == '') x_de_letra = X_I; - else if (dicho[h] == '') + else if (c == '') x_de_letra = X_J; - else if (dicho[h] == '') + else if (c == '') x_de_letra = X_K; - else if (dicho[h] == '') + else if (c == '') x_de_letra = X_L; - else if (dicho[h] == '') + else if (c == '') x_de_letra = X_M; - else if (dicho[h] == '') + else if (c == '') x_de_letra = X_N; - else if (dicho[h] == '') + else if (c == '') x_de_letra = X_GN; - else if (dicho[h] == '\'') + else if (c == '\'') x_de_letra = X_O; - else if (dicho[h] == '') + else if (c == '') x_de_letra = X_P; - else if (dicho[h] == '') + else if (c == '') x_de_letra = X_P; - else if (dicho[h] == '') + else if (c == '') x_de_letra = X_A; - else if (dicho[h] == '') + else if (c == '') x_de_letra = X_B; - else if (dicho[h] == '') + else if (c == '') x_de_letra = X_C; - else if (dicho[h] == '') + else if (c == '') x_de_letra = X_D; - else if (dicho[h] == '') + else if (c == '') x_de_letra = X_E; - else if (dicho[h] == '') + else if (c == '') x_de_letra = X_F; - else if (dicho[h] == '') + else if (c == '') x_de_letra = X_G; - else if (dicho[h] == '') + else if (c == '') x_de_letra = X_H; - else if (dicho[h] == '') + else if (c == '') x_de_letra = X_I; - else if (dicho[h] == '') + else if (c == '') x_de_letra = X_J; - else if (dicho[h] == '') + else if (c == '') x_de_letra = X_K; - else if (dicho[h] == '') + else if (c == '') x_de_letra = X_L; - else if (dicho[h] == '') + else if (c == '') x_de_letra = X_M; - else if (dicho[h] == '') + else if (c == '') x_de_letra = X_N; - else if (dicho[h] == '') + else if (c == '') x_de_letra = X_GN; - } -*/ +*/ } + pos_texto[0] = x_de_letra; pos_texto[1] = y_de_letra; pos_texto[2] = x_pantalla; -- cgit v1.2.3 From 5e0a226b69ca527445706fcba03a42877ba71c8e Mon Sep 17 00:00:00 2001 From: Paweł Kołodziejski Date: Sat, 28 Jul 2007 22:10:30 +0000 Subject: more fixes to display fonts svn-id: r28279 --- engines/drascula/drascula.cpp | 82 +++++++++++++++++++++---------------------- 1 file changed, 41 insertions(+), 41 deletions(-) (limited to 'engines') diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp index 0168e12972..4ee3eb488e 100644 --- a/engines/drascula/drascula.cpp +++ b/engines/drascula/drascula.cpp @@ -792,7 +792,7 @@ void DrasculaEngine::animacion_1() { VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); pausa(20); habla_solo(TEXTD6, "d6.als"); - if ((term_int ==1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == ESC)) break; anima("lib2.bin", 16); if ((term_int == 1) || (getscan() == ESC)) @@ -1555,10 +1555,10 @@ void DrasculaEngine::update_events() { case Common::EVENT_RBUTTONUP: boton_dch = 0; break; -/* // TODO case Common::EVENT_QUIT: + break; -*/ default: + default: break; } } @@ -4504,33 +4504,33 @@ void DrasculaEngine::print_abc_opc(const char *dicho, int x_pantalla, int y_pant y_de_letra = Y_ABC_OPC_2; y_de_signos = Y_SIGNOS_OPC_2; } -/* + if (dicho[h] == 'A') x_de_letra = X_A_OPC; else if (dicho[h] == '') x_de_letra = X_A_OPC; else if (dicho[h] == '') x_de_letra = X_A_OPC; - else if (dicho[h] == '') - x_de_letra = X_A_OPC; +// else if (dicho[h] == '') +// x_de_letra = X_A_OPC; else if (dicho[h] == 'B' )x_de_letra = X_B_OPC; else if (dicho[h] == 'C') x_de_letra = X_C_OPC; - else if (dicho[h] == '') - x_de_letra = X_C_OPC; - else if (dicho[h] == '') - x_de_letra = X_C_OPC; +// else if (dicho[h] == '') +// x_de_letra = X_C_OPC; +// else if (dicho[h] == '') +// x_de_letra = X_C_OPC; else if (dicho[h] == 'D') x_de_letra = X_D_OPC; else if (dicho[h] == 'E') x_de_letra = X_E_OPC; - else if (dicho[h] == '') - x_de_letra = X_E_OPC; - else if (dicho[h] == '') - x_de_letra = X_E_OPC; - else if (dicho[h] == '') - x_de_letra = X_E_OPC; +// else if (dicho[h] == '') +// x_de_letra = X_E_OPC; +// else if (dicho[h] == '') +// x_de_letra = X_E_OPC; +// else if (dicho[h] == '') +// x_de_letra = X_E_OPC; else if (dicho[h] == 'F') x_de_letra = X_F_OPC; else if (dicho[h] == 'G') @@ -4539,12 +4539,12 @@ void DrasculaEngine::print_abc_opc(const char *dicho, int x_pantalla, int y_pant x_de_letra = X_H_OPC; else if (dicho[h] == 'I') x_de_letra = X_I_OPC; - else if (dicho[h] == '') - x_de_letra = X_I_OPC; - else if (dicho[h] == '') - x_de_letra = X_I_OPC; - else if (dicho[h] == '') - x_de_letra = X_I_OPC; +// else if (dicho[h] == '') +// x_de_letra = X_I_OPC; +// else if (dicho[h] == '') +// x_de_letra = X_I_OPC; +// else if (dicho[h] == '') +// x_de_letra = X_I_OPC; else if (dicho[h] == 'J') x_de_letra = X_J_OPC; else if (dicho[h] == 'K') @@ -4559,12 +4559,12 @@ void DrasculaEngine::print_abc_opc(const char *dicho, int x_pantalla, int y_pant x_de_letra = X_GN_OPC; else if (dicho[h] == 'O') x_de_letra = X_O_OPC; - else if (dicho[h] == '') - x_de_letra = X_O_OPC; - else if (dicho[h] == '') - x_de_letra = X_O_OPC; - else if (dicho[h] == '') - x_de_letra = X_O_OPC; +// else if (dicho[h] == '') +// x_de_letra = X_O_OPC; +// else if (dicho[h] == '') +// x_de_letra = X_O_OPC; +// else if (dicho[h] == '') +// x_de_letra = X_O_OPC; else if (dicho[h] == 'P') x_de_letra = X_P_OPC; else if (dicho[h] == 'Q') @@ -4577,12 +4577,12 @@ void DrasculaEngine::print_abc_opc(const char *dicho, int x_pantalla, int y_pant x_de_letra = X_T_OPC; else if (dicho[h] == 'U') x_de_letra = X_U_OPC; - else if (dicho[h] == '') - x_de_letra = X_U_OPC; - else if (dicho[h] == '') - x_de_letra = X_U_OPC; - else if (dicho[h] == '') - x_de_letra = X_U_OPC; +// else if (dicho[h] == '') +// x_de_letra = X_U_OPC; +// else if (dicho[h] == '') +// x_de_letra = X_U_OPC; +// else if (dicho[h] == '') +// x_de_letra = X_U_OPC; else if (dicho[h] == 'V') x_de_letra = X_V_OPC; else if (dicho[h] == 'W') @@ -4593,8 +4593,8 @@ void DrasculaEngine::print_abc_opc(const char *dicho, int x_pantalla, int y_pant x_de_letra = X_Y_OPC; else if (dicho[h] == 'Z') x_de_letra = X_Z_OPC; - else if (dicho[h] == ' ') - x_de_letra = ESPACIO_OPC; +// else if (dicho[h] == ' ') +// x_de_letra = ESPACIO_OPC; else y_de_letra = y_de_signos; @@ -4606,12 +4606,12 @@ void DrasculaEngine::print_abc_opc(const char *dicho, int x_pantalla, int y_pant x_de_letra = X_GUION_OPC; else if (dicho[h] == '?') x_de_letra = X_CIERRA_INTERROGACION_OPC; - else if (dicho[h] == '') - x_de_letra = X_ABRE_INTERROGACION_OPC; +// else if (dicho[h] == '') +// x_de_letra = X_ABRE_INTERROGACION_OPC; else if (dicho[h] == '"') x_de_letra = X_COMILLAS_OPC; - else if (dicho[h] == '!') - x_de_letra = X_CIERRA_EXCLAMACION_OPC; +// else if (dicho[h] == '!') +// x_de_letra = X_CIERRA_EXCLAMACION_OPC; else if (dicho[h] == '') x_de_letra = X_ABRE_EXCLAMACION_OPC; else if (dicho[h] == ';') @@ -4658,7 +4658,7 @@ void DrasculaEngine::print_abc_opc(const char *dicho, int x_pantalla, int y_pant x_de_letra = X_N9_OPC; else if (dicho[h] == '0') x_de_letra = X_N0_OPC; -*/ + pos_texto[0] = x_de_letra; pos_texto[1] = y_de_letra; pos_texto[2] = x_pantalla; -- cgit v1.2.3 From c8f4818f2d5c8bd28a2afe793fb545c08dff2510 Mon Sep 17 00:00:00 2001 From: Paweł Kołodziejski Date: Sat, 28 Jul 2007 22:14:17 +0000 Subject: more fixes to display fonts svn-id: r28280 --- engines/drascula/drascula.cpp | 167 ++++++++++++++++++++---------------------- 1 file changed, 81 insertions(+), 86 deletions(-) (limited to 'engines') diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp index 4ee3eb488e..c4cb64b40d 100644 --- a/engines/drascula/drascula.cpp +++ b/engines/drascula/drascula.cpp @@ -4342,7 +4342,7 @@ bucle_opc: else if (usado1 == 0 && color != VERDE_CLARO) color_abc(VERDE_CLARO); } else if (y_raton > 8 && y_raton < 17) { - if (usado2==1 && color!=BLANCO) + if (usado2 == 1 && color != BLANCO) color_abc(BLANCO); else if (usado2 == 0 && color != VERDE_CLARO) color_abc(VERDE_CLARO); @@ -4487,16 +4487,10 @@ void DrasculaEngine::print_abc_opc(const char *dicho, int x_pantalla, int y_pant int i = 0, y_de_signos, y_de_letra, x_de_letra = 0, h, longitud; longitud = strlen(dicho); - // FIXME: We can't do this on read-only strings! -#if 0 - for (i = 0; dicho[i]; i++) - dicho[i] = toupper(dicho[i]); -#endif - for (h = 0; h < longitud; h++) { if (juego == 1) { y_de_letra = Y_ABC_OPC_1; - y_de_signos=Y_SIGNOS_OPC_1; + y_de_signos = Y_SIGNOS_OPC_1; } else if (juego == 3) { y_de_letra = Y_ABC_OPC_3; y_de_signos = Y_SIGNOS_OPC_3; @@ -4505,158 +4499,159 @@ void DrasculaEngine::print_abc_opc(const char *dicho, int x_pantalla, int y_pant y_de_signos = Y_SIGNOS_OPC_2; } - if (dicho[h] == 'A') - x_de_letra = X_A_OPC; - else if (dicho[h] == '') - x_de_letra = X_A_OPC; - else if (dicho[h] == '') + char c = toupper(dicho[h]); + if (c == 'A') x_de_letra = X_A_OPC; -// else if (dicho[h] == '') +// else if (c == '') +// x_de_letra = X_A_OPC; +// else if (c == '') // x_de_letra = X_A_OPC; - else if (dicho[h] == 'B' +// else if (c == '') +// x_de_letra = X_A_OPC; + else if (c == 'B' )x_de_letra = X_B_OPC; - else if (dicho[h] == 'C') + else if (c == 'C') x_de_letra = X_C_OPC; -// else if (dicho[h] == '') +// else if (c == '') // x_de_letra = X_C_OPC; -// else if (dicho[h] == '') +// else if (c == '') // x_de_letra = X_C_OPC; - else if (dicho[h] == 'D') + else if (c == 'D') x_de_letra = X_D_OPC; - else if (dicho[h] == 'E') + else if (c == 'E') x_de_letra = X_E_OPC; -// else if (dicho[h] == '') +// else if (c == '') // x_de_letra = X_E_OPC; -// else if (dicho[h] == '') +// else if (c == '') // x_de_letra = X_E_OPC; -// else if (dicho[h] == '') +// else if (c == '') // x_de_letra = X_E_OPC; - else if (dicho[h] == 'F') + else if (c == 'F') x_de_letra = X_F_OPC; - else if (dicho[h] == 'G') + else if (c == 'G') x_de_letra = X_G_OPC; - else if (dicho[h] == 'H') + else if (c == 'H') x_de_letra = X_H_OPC; - else if (dicho[h] == 'I') + else if (c == 'I') x_de_letra = X_I_OPC; -// else if (dicho[h] == '') +// else if (c == '') // x_de_letra = X_I_OPC; -// else if (dicho[h] == '') +// else if (c == '') // x_de_letra = X_I_OPC; -// else if (dicho[h] == '') +// else if (c == '') // x_de_letra = X_I_OPC; - else if (dicho[h] == 'J') + else if (c == 'J') x_de_letra = X_J_OPC; - else if (dicho[h] == 'K') + else if (c == 'K') x_de_letra = X_K_OPC; - else if (dicho[h] == 'L') + else if (c == 'L') x_de_letra = X_L_OPC; - else if (dicho[h] == 'M') + else if (c == 'M') x_de_letra = X_M_OPC; - else if (dicho[h] == 'N') + else if (c == 'N') x_de_letra = X_N_OPC; - else if (dicho[h] == '\'') - x_de_letra = X_GN_OPC; - else if (dicho[h] == 'O') +// else if (c == ''') +// x_de_letra = X_GN_OPC; + else if (c == 'O') x_de_letra = X_O_OPC; -// else if (dicho[h] == '') +// else if (c == '') // x_de_letra = X_O_OPC; -// else if (dicho[h] == '') +// else if (c == '') // x_de_letra = X_O_OPC; -// else if (dicho[h] == '') +// else if (c == '') // x_de_letra = X_O_OPC; - else if (dicho[h] == 'P') + else if (c == 'P') x_de_letra = X_P_OPC; - else if (dicho[h] == 'Q') + else if (c == 'Q') x_de_letra = X_Q_OPC; - else if (dicho[h] == 'R') + else if (c == 'R') x_de_letra = X_R_OPC; - else if (dicho[h] == 'S') + else if (c == 'S') x_de_letra = X_S_OPC; - else if (dicho[h] == 'T') + else if (c == 'T') x_de_letra = X_T_OPC; - else if (dicho[h] == 'U') + else if (c == 'U') x_de_letra = X_U_OPC; -// else if (dicho[h] == '') +// else if (c == '') // x_de_letra = X_U_OPC; -// else if (dicho[h] == '') +// else if (c == '') // x_de_letra = X_U_OPC; -// else if (dicho[h] == '') +// else if (c == '') // x_de_letra = X_U_OPC; - else if (dicho[h] == 'V') + else if (c == 'V') x_de_letra = X_V_OPC; - else if (dicho[h] == 'W') + else if (c == 'W') x_de_letra = X_W_OPC; - else if (dicho[h] == 'X') + else if (c == 'X') x_de_letra = X_X_OPC; - else if (dicho[h] == 'Y') + else if (c == 'Y') x_de_letra = X_Y_OPC; - else if (dicho[h] == 'Z') + else if (c == 'Z') x_de_letra = X_Z_OPC; -// else if (dicho[h] == ' ') +// else if (c == ' ') // x_de_letra = ESPACIO_OPC; else y_de_letra = y_de_signos; - if (dicho[h] == '.') + if (c == '.') x_de_letra = X_PUNTO_OPC; - else if (dicho[h] == ',') + else if (c == ',') x_de_letra = X_COMA_OPC; - else if (dicho[h] == '-') + else if (c == '-') x_de_letra = X_GUION_OPC; - else if (dicho[h] == '?') + else if (c == '?') x_de_letra = X_CIERRA_INTERROGACION_OPC; -// else if (dicho[h] == '') +// else if (c == '') // x_de_letra = X_ABRE_INTERROGACION_OPC; - else if (dicho[h] == '"') + else if (c == '"') x_de_letra = X_COMILLAS_OPC; -// else if (dicho[h] == '!') +// else if (c == '!') // x_de_letra = X_CIERRA_EXCLAMACION_OPC; - else if (dicho[h] == '') + else if (c == '') x_de_letra = X_ABRE_EXCLAMACION_OPC; - else if (dicho[h] == ';') + else if (c == ';') x_de_letra = X_PUNTO_Y_COMA_OPC; - else if (dicho[h] == '>') + else if (c == '>') x_de_letra = X_MAYOR_QUE_OPC; - else if (dicho[h] == '<') + else if (c == '<') x_de_letra = X_MENOR_QUE_OPC; - else if (dicho[h] == '$') + else if (c == '$') x_de_letra = X_DOLAR_OPC; - else if (dicho[h] == '%') + else if (c == '%') x_de_letra = X_POR_CIENTO_OPC; - else if (dicho[h] == ':') + else if (c == ':') x_de_letra = X_DOS_PUNTOS_OPC; - else if (dicho[h] == '&') + else if (c == '&') x_de_letra = X_AND_OPC; - else if (dicho[h] == '/') + else if (c == '/') x_de_letra = X_BARRA_OPC; - else if (dicho[h] == '(') + else if (c == '(') x_de_letra = X_ABRE_PARENTESIS_OPC; - else if (dicho[h] == ')') + else if (c == ')') x_de_letra = X_CIERRA_PARENTESIS_OPC; - else if (dicho[h] == '*') + else if (c == '*') x_de_letra = X_ASTERISCO_OPC; - else if (dicho[h] == '+') + else if (c == '+') x_de_letra = X_MAS_OPC; - else if (dicho[h] == '1') + else if (c == '1') x_de_letra = X_N1_OPC; - else if (dicho[h] == '2') + else if (c == '2') x_de_letra = X_N2_OPC; - else if (dicho[h] == '3') + else if (c == '3') x_de_letra = X_N3_OPC; - else if (dicho[h] == '4') + else if (c == '4') x_de_letra = X_N4_OPC; - else if (dicho[h] == '5') + else if (c == '5') x_de_letra = X_N5_OPC; - else if (dicho[h] == '6') + else if (c == '6') x_de_letra = X_N6_OPC; - else if (dicho[h] == '7') + else if (c == '7') x_de_letra = X_N7_OPC; - else if (dicho[h] == '8') + else if (c == '8') x_de_letra = X_N8_OPC; - else if (dicho[h] == '9') + else if (c == '9') x_de_letra = X_N9_OPC; - else if (dicho[h] == '0') + else if (c == '0') x_de_letra = X_N0_OPC; pos_texto[0] = x_de_letra; -- cgit v1.2.3 From 88c1e31d681b57b720f78f37ba5eb1b639493776 Mon Sep 17 00:00:00 2001 From: Paweł Kołodziejski Date: Sat, 28 Jul 2007 22:18:43 +0000 Subject: allow exit, formating svn-id: r28281 --- engines/drascula/drascula.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp index c4cb64b40d..2631f5187e 100644 --- a/engines/drascula/drascula.cpp +++ b/engines/drascula/drascula.cpp @@ -557,7 +557,8 @@ bucles: } else if (cont_sv == 1500) { salva_pantallas(); cont_sv = 0; - } else cont_sv++; + } else + cont_sv++; goto bucles; } @@ -1556,7 +1557,9 @@ void DrasculaEngine::update_events() { boton_dch = 0; break; case Common::EVENT_QUIT: - + // TODO + salir_al_dos(0); + exit(0); break; default: break; -- cgit v1.2.3 From 35eb799b8ea564cb0981337390e75d3d417708d5 Mon Sep 17 00:00:00 2001 From: Paweł Kołodziejski Date: Sun, 29 Jul 2007 06:37:45 +0000 Subject: correction to palette svn-id: r28283 --- engines/drascula/drascula.cpp | 2 +- engines/drascula/drascula.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp index 2631f5187e..e136a542ca 100644 --- a/engines/drascula/drascula.cpp +++ b/engines/drascula/drascula.cpp @@ -2149,7 +2149,7 @@ void DrasculaEngine::color_abc(int cl) { setvgapalette256((byte *)&palJuego); } -byte DrasculaEngine::LimitaVGA(byte valor) { +char DrasculaEngine::LimitaVGA(char valor) { return (valor & 0x3F) * (valor > 0); } diff --git a/engines/drascula/drascula.h b/engines/drascula/drascula.h index 1515f9803b..50586884a4 100644 --- a/engines/drascula/drascula.h +++ b/engines/drascula/drascula.h @@ -358,7 +358,7 @@ public: void lee_dibujos(const char *); void descomprime_dibujo(byte *dir_escritura, int plt); - typedef byte DacPalette256[256][3]; + typedef char DacPalette256[256][3]; void asigna_rgb(byte *dir_lectura, int plt); void funde_rgb(int plt); @@ -494,7 +494,7 @@ public: int resta_objeto(int osj); void fliplay(const char *filefli, int vel); void FundeDelNegro(int VelocidadDeFundido); - byte LimitaVGA(byte valor); + char LimitaVGA(char valor); void color_abc(int cl); void centra_texto(const char *,int,int); void comienza_sound(const char *); -- cgit v1.2.3 From 395f244ba04b0172223071eac651c8793f57cce0 Mon Sep 17 00:00:00 2001 From: Paweł Kołodziejski Date: Sun, 29 Jul 2007 07:12:24 +0000 Subject: more corrections svn-id: r28284 --- engines/drascula/drascula.cpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'engines') diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp index e136a542ca..8d2c83ae5c 100644 --- a/engines/drascula/drascula.cpp +++ b/engines/drascula/drascula.cpp @@ -2006,7 +2006,7 @@ void DrasculaEngine::print_abc(const char *dicho, int x_pantalla, int y_pantalla } void DrasculaEngine::delay(int ms) { - _system->delayMillis(ms); + _system->delayMillis(ms * 2); // originaly was 1 } void DrasculaEngine::confirma_go() { @@ -2316,15 +2316,7 @@ void DrasculaEngine::FundeAlNegro(int VelocidadDeFundido) { } void DrasculaEngine::pausa(int cuanto) { - int diferencia, conta_antes; - - conta_antes = vez(); - - for (;;) { - diferencia = vez() - conta_antes; - if (diferencia >= 2 * cuanto) - break; - } + _system->delayMillis(cuanto * 25); // was originaly 2 } void DrasculaEngine::habla_dr_grande(const char *dicho, const char *filename) { @@ -2364,7 +2356,7 @@ bucless: DIBUJA_FONDO(x_habla[cara], 1, 171, 68, 45, 48, dir_dibujo2, dir_zona_pantalla); l++; if (l == 7) - l =0; + l = 0; if (con_voces == 0) centra_texto(dicho, 191, 69); @@ -3697,7 +3689,8 @@ int DrasculaEngine::LookForFree() { delay(10); // TODO GAME_Poll(gamev, 10); //return(!SDEV_ChannelFree(gamev->EffectDev, 0)); - return 1; + delay(1000); // workround too much fast played sound + return 0; } void DrasculaEngine::OpenSSN(const char *Name, int Pause) { -- cgit v1.2.3 From f8d28abdf93c2e0bee8f0c33c676f7cb55da049c Mon Sep 17 00:00:00 2001 From: Paweł Kołodziejski Date: Sun, 29 Jul 2007 11:21:12 +0000 Subject: added sfx/voice and few corrections svn-id: r28286 --- engines/drascula/drascula.cpp | 27 ++++++++++++++------------- engines/drascula/drascula.h | 8 +++++++- 2 files changed, 21 insertions(+), 14 deletions(-) (limited to 'engines') diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp index 8d2c83ae5c..c5ecc22d31 100644 --- a/engines/drascula/drascula.cpp +++ b/engines/drascula/drascula.cpp @@ -1227,7 +1227,7 @@ void DrasculaEngine::carga_escoba(const char *nom_fich) { getLine(ald, buffer, size); sscanf(buffer, "%s", num_room); - strcat(num_room,".alg"); + strcat(num_room, ".alg"); getLine(ald, buffer, size); sscanf(buffer, "%d", &musica_room); @@ -3685,14 +3685,6 @@ void DrasculaEngine::para_grabar(char nom_game[]) { fin_sound(); } -int DrasculaEngine::LookForFree() { - delay(10); - // TODO GAME_Poll(gamev, 10); - //return(!SDEV_ChannelFree(gamev->EffectDev, 0)); - delay(1000); // workround too much fast played sound - return 0; -} - void DrasculaEngine::OpenSSN(const char *Name, int Pause) { MiVideoSSN = (byte *)malloc(64256); GlobalSpeed = CLOCKS_PER_SEC / Pause; @@ -4856,15 +4848,15 @@ void DrasculaEngine::MusicFadeout() { } void DrasculaEngine::ctvd_end() { - //TODO + _mixer->stopHandle(_soundHandle); } void DrasculaEngine::ctvd_stop() { - //TODO + _mixer->stopHandle(_soundHandle); } void DrasculaEngine::ctvd_terminate() { - //TODO +// _mixer->stopHandle(_soundHandle); } void DrasculaEngine::ctvd_speaker(int flag) {} @@ -4872,7 +4864,16 @@ void DrasculaEngine::ctvd_speaker(int flag) {} void DrasculaEngine::ctvd_output(Common::File *file_handle) {} void DrasculaEngine::ctvd_init(int b) { - //TODO + int soundSize = sku->size(); + byte *soundData = (byte *)malloc(soundSize); + sku->seek(32); + sku->read(soundData, soundSize); + _mixer->playRaw(Audio::Mixer::kPlainSoundType, &_soundHandle, soundData, soundSize - 64, + 11025, Audio::Mixer::FLAG_AUTOFREE | Audio::Mixer::FLAG_UNSIGNED); +} + +int DrasculaEngine::LookForFree() { + return _mixer->isSoundHandleActive(_soundHandle); } diff --git a/engines/drascula/drascula.h b/engines/drascula/drascula.h index 50586884a4..75e5868143 100644 --- a/engines/drascula/drascula.h +++ b/engines/drascula/drascula.h @@ -37,6 +37,10 @@ #include "common/events.h" #include "common/keyboard.h" +#include "sound/audiostream.h" +#include "sound/mixer.h" +#include "sound/voc.h" + #include "engines/engine.h" namespace Drascula { @@ -350,6 +354,8 @@ public: Common::Platform getPlatform() const; void update_events(); + Audio::SoundHandle _soundHandle; + void asigna_memoria(); void libera_memoria(); void carga_info(); @@ -438,7 +444,7 @@ public: int vb_x, sentido_vb, vb_se_mueve, frame_vb; float nuevo_alto, nuevo_ancho; int diferencia_x, diferencia_y; - int factor_red[201]; + int factor_red[202]; int frame_piano; int frame_borracho; int frame_velas; -- cgit v1.2.3 From 47e5b0f0ff93f393ddffd9ed57e8aaf4ea3a068a Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Sun, 29 Jul 2007 14:23:26 +0000 Subject: Added dummy SoundMan to help with integration of Big Red Adventure. svn-id: r28288 --- engines/parallaction/sound.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'engines') diff --git a/engines/parallaction/sound.h b/engines/parallaction/sound.h index 920a804226..f8f1a9e6b0 100644 --- a/engines/parallaction/sound.h +++ b/engines/parallaction/sound.h @@ -108,6 +108,22 @@ public: void playLocationMusic(const char *location); }; +class DummySoundMan : public SoundMan { + +public: + DummySoundMan(Parallaction *vm) : SoundMan(vm) { } + ~DummySoundMan() { } + void playMusic() { } + void stopMusic() { } + + void playSfx(const char *filename, uint channel, bool looping, int volume, int rate) { } + void stopSfx(uint channel) { } + + void playCharacterMusic(const char *character) { } + void playLocationMusic(const char *location) { } + +}; + } // namespace Parallaction #endif -- cgit v1.2.3 From 7e7b07132e1963e138bc0e630ab66d8162ee669b Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Sun, 29 Jul 2007 14:24:31 +0000 Subject: Moved specialized initialization code into subclasses. svn-id: r28289 --- engines/parallaction/parallaction.cpp | 46 --------------------- engines/parallaction/parallaction.h | 3 ++ engines/parallaction/parallaction_br.cpp | 58 +++++++++++++++++++++++++++ engines/parallaction/parallaction_ns.cpp | 69 ++++++++++++++++++++++++++++++++ 4 files changed, 130 insertions(+), 46 deletions(-) create mode 100644 engines/parallaction/parallaction_br.cpp create mode 100644 engines/parallaction/parallaction_ns.cpp (limited to 'engines') diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp index 523fbcf88b..1dfc95716e 100644 --- a/engines/parallaction/parallaction.cpp +++ b/engines/parallaction/parallaction.cpp @@ -146,12 +146,6 @@ Parallaction::~Parallaction() { int Parallaction::init() { - // Detect game - if (!detectGame()) { - GUIErrorMessage("No valid games were found in the specified directory."); - return -1; - } - _objectsNames = NULL; _globalTable = NULL; _localFlagNames = NULL; @@ -170,20 +164,8 @@ int Parallaction::init() { // _musicData1 = 0; strcpy(_characterName1, "null"); - _soundMan = 0; - _baseTime = 0; - - if (_vm->getGameType() == GType_Nippon) { - _screenWidth = 320; - _screenHeight = 200; - } else - if (_vm->getGameType() == GType_BRA) { - _screenWidth = 640; - _screenHeight = 400; - } - _screenMaskWidth = _screenWidth / 4; _screenPathWidth = _screenWidth / 8; @@ -191,25 +173,6 @@ int Parallaction::init() { _screenMaskSize = _screenMaskWidth * _screenHeight; _screenPathSize = _screenPathWidth * _screenHeight; - if (getGameType() == GType_Nippon) { - if (getPlatform() == Common::kPlatformPC) { - _disk = new DosDisk_ns(this); - } else { - if (getFeatures() & GF_DEMO) { - strcpy(_location._name, "fognedemo"); - } - _disk = new AmigaDisk_ns(this); - _disk->selectArchive((_vm->getFeatures() & GF_DEMO) ? "disk0" : "disk1"); - } - } else - if (getGameType() == GType_BRA) { - if (getPlatform() == Common::kPlatformPC) { - _disk = new DosDisk_br(this); - } else - error("unsupported platform for Big Red Adventure"); - } else - error("unknown game type"); - _engineFlags = 0; strcpy(_characterName, "dough"); @@ -231,15 +194,6 @@ int Parallaction::init() { _animations.push_front(&_vm->_char._ani); _gfx = new Gfx(this); - if (getPlatform() == Common::kPlatformPC) { - int midiDriver = MidiDriver::detectMusicDriver(MDT_MIDI | MDT_ADLIB | MDT_PREFER_MIDI); - MidiDriver *driver = MidiDriver::createMidi(midiDriver); - _soundMan = new DosSoundMan(this, driver); - _soundMan->setMusicVolume(ConfMan.getInt("music_volume")); - } else { - _soundMan = new AmigaSoundMan(this); - } - _debugger = new Debugger(this); return 0; diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h index 33dc5563e6..0cb6e92709 100644 --- a/engines/parallaction/parallaction.h +++ b/engines/parallaction/parallaction.h @@ -486,6 +486,7 @@ public: Parallaction_ns(OSystem* syst) : Parallaction(syst) { } ~Parallaction_ns() { } + int init(); }; class Parallaction_br : public Parallaction { @@ -494,6 +495,8 @@ public: Parallaction_br(OSystem* syst) : Parallaction(syst) { } ~Parallaction_br() { } + int init(); + }; // FIXME: remove global diff --git a/engines/parallaction/parallaction_br.cpp b/engines/parallaction/parallaction_br.cpp new file mode 100644 index 0000000000..1609921d85 --- /dev/null +++ b/engines/parallaction/parallaction_br.cpp @@ -0,0 +1,58 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include "common/stdafx.h" +#include "parallaction/parallaction.h" +#include "parallaction/sound.h" + +namespace Parallaction { + +int Parallaction_br::init() { + + // Detect game + if (!detectGame()) { + GUIErrorMessage("No valid games were found in the specified directory."); + return -1; + } + + _screenWidth = 640; + _screenHeight = 400; + + if (getGameType() == GType_BRA) { + if (getPlatform() == Common::kPlatformPC) { + _disk = new DosDisk_br(this); + } else + error("unsupported platform for Big Red Adventure"); + } else + error("unknown game type"); + + _soundMan = new DummySoundMan(this); + + Parallaction::init(); + + return 0; +} + +} // namespace Parallaction diff --git a/engines/parallaction/parallaction_ns.cpp b/engines/parallaction/parallaction_ns.cpp new file mode 100644 index 0000000000..bc856772c3 --- /dev/null +++ b/engines/parallaction/parallaction_ns.cpp @@ -0,0 +1,69 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include "common/stdafx.h" +#include "common/config-manager.h" + +#include "parallaction/parallaction.h" +#include "parallaction/sound.h" + +namespace Parallaction { + +int Parallaction_ns::init() { + + // Detect game + if (!detectGame()) { + GUIErrorMessage("No valid games were found in the specified directory."); + return -1; + } + + _screenWidth = 320; + _screenHeight = 200; + + if (getPlatform() == Common::kPlatformPC) { + _disk = new DosDisk_ns(this); + } else { + if (getFeatures() & GF_DEMO) { + strcpy(_location._name, "fognedemo"); + } + _disk = new AmigaDisk_ns(this); + _disk->selectArchive((_vm->getFeatures() & GF_DEMO) ? "disk0" : "disk1"); + } + + if (getPlatform() == Common::kPlatformPC) { + int midiDriver = MidiDriver::detectMusicDriver(MDT_MIDI | MDT_ADLIB | MDT_PREFER_MIDI); + MidiDriver *driver = MidiDriver::createMidi(midiDriver); + _soundMan = new DosSoundMan(this, driver); + _soundMan->setMusicVolume(ConfMan.getInt("music_volume")); + } else { + _soundMan = new AmigaSoundMan(this); + } + + Parallaction::init(); + + return 0; +} + +} // namespace Parallaction -- cgit v1.2.3 From 04027589ab0413c09bb7d47c95bed74916bf5ca8 Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Sun, 29 Jul 2007 14:32:30 +0000 Subject: Cleanup and some new comments. svn-id: r28290 --- engines/parallaction/parallaction.cpp | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) (limited to 'engines') diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp index 1dfc95716e..a31559711b 100644 --- a/engines/parallaction/parallaction.cpp +++ b/engines/parallaction/parallaction.cpp @@ -146,50 +146,39 @@ Parallaction::~Parallaction() { int Parallaction::init() { + initResources(); // needs to be pushed into subclass + + _engineFlags = 0; _objectsNames = NULL; _globalTable = NULL; - _localFlagNames = NULL; - initResources(); - _hasLocationSound = false; - _skipMenu = false; - _transCurrentHoverItem = 0; _actionAfterWalk = false; // actived when the character needs to move before taking an action _activeItem._index = 0; _activeItem._id = 0; _procCurrentHoverItem = -1; - -// _musicData1 = 0; - strcpy(_characterName1, "null"); - _baseTime = 0; + _numLocations = 0; + _location._startPosition.x = -1000; + _location._startPosition.y = -1000; + _location._startFrame = 0; + _location._comment = NULL; + _location._endComment = NULL; _screenMaskWidth = _screenWidth / 4; _screenPathWidth = _screenWidth / 8; - _screenSize = _screenWidth * _screenHeight; _screenMaskSize = _screenMaskWidth * _screenHeight; _screenPathSize = _screenPathWidth * _screenHeight; - _engineFlags = 0; - + strcpy(_characterName1, "null"); strcpy(_characterName, "dough"); memset(_locationNames, 0, 120*32); - _numLocations = 0; - - _location._startPosition.x = -1000; - _location._startPosition.y = -1000; - _location._startFrame = 0; - - _location._comment = NULL; - _location._endComment = NULL; - - initWalk(); - initInventory(); + initWalk(); // needs to be pushed into subclass + initInventory(); // needs to be pushed into subclass _animations.push_front(&_vm->_char._ani); _gfx = new Gfx(this); -- cgit v1.2.3 From 9a766cf5c48683fb81d92e094538eb101ea21660 Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Sun, 29 Jul 2007 15:21:33 +0000 Subject: Removed direct references to callable functions (opcodes). They are now only available via a virtual member function in the engine. svn-id: r28291 --- engines/parallaction/animation.cpp | 2 +- engines/parallaction/commands.cpp | 2 +- engines/parallaction/parallaction.h | 7 +++++++ engines/parallaction/parallaction_ns.cpp | 7 +++++++ 4 files changed, 16 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/parallaction/animation.cpp b/engines/parallaction/animation.cpp index d4f538c451..281e3e8da9 100644 --- a/engines/parallaction/animation.cpp +++ b/engines/parallaction/animation.cpp @@ -566,7 +566,7 @@ void jobRunScripts(void *parm, Job *j) { case INST_CALL: // call - _callables[(*inst)->_opBase._index](0); + _vm->callFunction((*inst)->_opBase._index, 0); break; case INST_WAIT: // wait diff --git a/engines/parallaction/commands.cpp b/engines/parallaction/commands.cpp index 15acdd2d86..4df9aa4559 100644 --- a/engines/parallaction/commands.cpp +++ b/engines/parallaction/commands.cpp @@ -302,7 +302,7 @@ void Parallaction::runCommands(CommandList& list, Zone *z) { break; case CMD_CALL: // call - _callables[u->_callable](z); + callFunction(u->_callable, z); break; case CMD_QUIT: // quit diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h index 0cb6e92709..25753f60b2 100644 --- a/engines/parallaction/parallaction.h +++ b/engines/parallaction/parallaction.h @@ -478,6 +478,10 @@ protected: // members int16 pickupItem(Zone *z); int16 isItemInInventory(int32 v); int16 getHoverInventoryItem(int16 x, int16 y); + +public: + virtual void callFunction(uint index, void* parm) { } + }; class Parallaction_ns : public Parallaction { @@ -487,6 +491,9 @@ public: ~Parallaction_ns() { } int init(); + +public: + virtual void callFunction(uint index, void* parm); }; class Parallaction_br : public Parallaction { diff --git a/engines/parallaction/parallaction_ns.cpp b/engines/parallaction/parallaction_ns.cpp index bc856772c3..5f0fb0fe84 100644 --- a/engines/parallaction/parallaction_ns.cpp +++ b/engines/parallaction/parallaction_ns.cpp @@ -66,4 +66,11 @@ int Parallaction_ns::init() { return 0; } +void Parallaction_ns::callFunction(uint index, void* parm) { + assert(index >= 0 && index < 25); // magic value 25 is maximum # of callables for Nippon Safes + + _callables[index](parm); +} + + } // namespace Parallaction -- cgit v1.2.3 From 5ff9d0fe89f610cca5efa72e7fae773ffe6c78fe Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Sun, 29 Jul 2007 16:08:30 +0000 Subject: Fix build. svn-id: r28292 --- engines/parallaction/module.mk | 2 ++ 1 file changed, 2 insertions(+) (limited to 'engines') diff --git a/engines/parallaction/module.mk b/engines/parallaction/module.mk index a94f197cee..afe4bd0ac3 100644 --- a/engines/parallaction/module.mk +++ b/engines/parallaction/module.mk @@ -17,6 +17,8 @@ MODULE_OBJS := \ menu.o \ parser.o \ parallaction.o \ + parallaction_br.o \ + parallaction_ns.o \ saveload.o \ sound.o \ staticres.o \ -- cgit v1.2.3 From bf5bb9280b1dc4a02b4c0ec9506a0723ed80b55e Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 29 Jul 2007 16:28:25 +0000 Subject: - Restructure Kyrandia sourcecode (part 1, breaks compiling) svn-id: r28294 --- engines/kyra/animator.cpp | 692 ------------------ engines/kyra/animator.h | 132 ---- engines/kyra/animator_v1.cpp | 692 ++++++++++++++++++ engines/kyra/animator_v1.h | 132 ++++ engines/kyra/gui.cpp | 1640 ------------------------------------------ engines/kyra/gui_v1.cpp | 1640 ++++++++++++++++++++++++++++++++++++++++++ engines/kyra/items.cpp | 944 ------------------------ engines/kyra/items_v1.cpp | 944 ++++++++++++++++++++++++ engines/kyra/saveload.cpp | 366 ---------- engines/kyra/saveload_v1.cpp | 366 ++++++++++ engines/kyra/scene.cpp | 1624 ----------------------------------------- engines/kyra/scene_v1.cpp | 1624 +++++++++++++++++++++++++++++++++++++++++ engines/kyra/timer.cpp | 292 -------- engines/kyra/timer_v1.cpp | 292 ++++++++ 14 files changed, 5690 insertions(+), 5690 deletions(-) delete mode 100644 engines/kyra/animator.cpp delete mode 100644 engines/kyra/animator.h create mode 100644 engines/kyra/animator_v1.cpp create mode 100644 engines/kyra/animator_v1.h delete mode 100644 engines/kyra/gui.cpp create mode 100644 engines/kyra/gui_v1.cpp delete mode 100644 engines/kyra/items.cpp create mode 100644 engines/kyra/items_v1.cpp delete mode 100644 engines/kyra/saveload.cpp create mode 100644 engines/kyra/saveload_v1.cpp delete mode 100644 engines/kyra/scene.cpp create mode 100644 engines/kyra/scene_v1.cpp delete mode 100644 engines/kyra/timer.cpp create mode 100644 engines/kyra/timer_v1.cpp (limited to 'engines') diff --git a/engines/kyra/animator.cpp b/engines/kyra/animator.cpp deleted file mode 100644 index 7683bb6417..0000000000 --- a/engines/kyra/animator.cpp +++ /dev/null @@ -1,692 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -#include "common/stdafx.h" -#include "common/endian.h" - -#include "kyra/kyra.h" -#include "kyra/screen.h" -#include "kyra/animator.h" -#include "kyra/sprites.h" - -#include "common/system.h" - -namespace Kyra { -ScreenAnimator::ScreenAnimator(KyraEngine *vm, OSystem *system) { - _vm = vm; - _screen = vm->screen(); - _initOk = false; - _updateScreen = false; - _system = system; - _screenObjects = _actors = _items = _sprites = _objectQueue = 0; - _noDrawShapesFlag = 0; - - _actorBkgBackUp[0] = new uint8[_screen->getRectSize(8, 69)]; - memset(_actorBkgBackUp[0], 0, _screen->getRectSize(8, 69)); - _actorBkgBackUp[1] = new uint8[_screen->getRectSize(8, 69)]; - memset(_actorBkgBackUp[1], 0, _screen->getRectSize(8, 69)); -} - -ScreenAnimator::~ScreenAnimator() { - close(); - delete [] _actorBkgBackUp[0]; - delete [] _actorBkgBackUp[1]; -} - -void ScreenAnimator::init(int actors_, int items_, int sprites_) { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::init(%d, %d, %d)", actors_, items_, sprites_); - _screenObjects = new AnimObject[actors_ + items_ + sprites_]; - assert(_screenObjects); - memset(_screenObjects, 0, sizeof(AnimObject) * (actors_ + items_ + sprites_)); - _actors = _screenObjects; - _sprites = &_screenObjects[actors_]; - _items = &_screenObjects[actors_ + items_]; - _brandonDrawFrame = 113; - - _initOk = true; -} - -void ScreenAnimator::close() { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::close()"); - if (_initOk) { - _initOk = false; - delete [] _screenObjects; - _screenObjects = _actors = _items = _sprites = _objectQueue = 0; - } -} - -void ScreenAnimator::initAnimStateList() { - AnimObject *animStates = _screenObjects; - animStates[0].index = 0; - animStates[0].active = 1; - animStates[0].flags = 0x800; - animStates[0].background = _actorBkgBackUp[0]; - animStates[0].rectSize = _screen->getRectSize(4, 48); - animStates[0].width = 4; - animStates[0].height = 48; - animStates[0].width2 = 4; - animStates[0].height2 = 3; - - for (int i = 1; i <= 4; ++i) { - animStates[i].index = i; - animStates[i].active = 0; - animStates[i].flags = 0x800; - animStates[i].background = _actorBkgBackUp[1]; - animStates[i].rectSize = _screen->getRectSize(4, 64); - animStates[i].width = 4; - animStates[i].height = 48; - animStates[i].width2 = 4; - animStates[i].height2 = 3; - } - - for (int i = 5; i < 16; ++i) { - animStates[i].index = i; - animStates[i].active = 0; - animStates[i].flags = 0; - } - - for (int i = 16; i < 28; ++i) { - animStates[i].index = i; - animStates[i].flags = 0; - animStates[i].background = _vm->_shapes[345+i]; - animStates[i].rectSize = _screen->getRectSize(3, 24); - animStates[i].width = 3; - animStates[i].height = 16; - animStates[i].width2 = 0; - animStates[i].height2 = 0; - } -} - -void ScreenAnimator::preserveAllBackgrounds() { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::preserveAllBackgrounds()"); - uint8 curPage = _screen->_curPage; - _screen->_curPage = 2; - - AnimObject *curObject = _objectQueue; - while (curObject) { - if (curObject->active && !curObject->disable) { - preserveOrRestoreBackground(curObject, false); - curObject->bkgdChangeFlag = 0; - } - curObject = curObject->nextAnimObject; - } - _screen->_curPage = curPage; -} - -void ScreenAnimator::flagAllObjectsForBkgdChange() { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::flagAllObjectsForBkgdChange()"); - AnimObject *curObject = _objectQueue; - while (curObject) { - curObject->bkgdChangeFlag = 1; - curObject = curObject->nextAnimObject; - } -} - -void ScreenAnimator::flagAllObjectsForRefresh() { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::flagAllObjectsForRefresh()"); - AnimObject *curObject = _objectQueue; - while (curObject) { - curObject->refreshFlag = 1; - curObject = curObject->nextAnimObject; - } -} - -void ScreenAnimator::restoreAllObjectBackgrounds() { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::restoreAllObjectBackground()"); - AnimObject *curObject = _objectQueue; - _screen->_curPage = 2; - - while (curObject) { - if (curObject->active && !curObject->disable) { - preserveOrRestoreBackground(curObject, true); - curObject->x2 = curObject->x1; - curObject->y2 = curObject->y1; - } - curObject = curObject->nextAnimObject; - } - - _screen->_curPage = 0; -} - -void ScreenAnimator::preserveAnyChangedBackgrounds() { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::preserveAnyChangedBackgrounds()"); - AnimObject *curObject = _objectQueue; - _screen->_curPage = 2; - - while (curObject) { - if (curObject->active && !curObject->disable && curObject->bkgdChangeFlag) { - preserveOrRestoreBackground(curObject, false); - curObject->bkgdChangeFlag = 0; - } - curObject = curObject->nextAnimObject; - } - - _screen->_curPage = 0; -} - -void ScreenAnimator::preserveOrRestoreBackground(AnimObject *obj, bool restore) { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::preserveOrRestoreBackground(%p, %d)", (const void *)obj, restore); - int x = 0, y = 0, width = obj->width, height = obj->height; - - if (restore) { - x = obj->x2 >> 3; - y = obj->y2; - } else { - x = obj->x1 >> 3; - y = obj->y1; - } - - if (x < 0) - x = 0; - if (y < 0) - y = 0; - - int temp; - - temp = x + width; - if (temp >= 39) - x = 39 - width; - temp = y + height; - if (temp >= 136) - y = 136 - height; - - if (restore) - _screen->copyBlockToPage(_screen->_curPage, x << 3, y, width << 3, height, obj->background); - else - _screen->copyRegionToBuffer(_screen->_curPage, x << 3, y, width << 3, height, obj->background); -} - -void ScreenAnimator::prepDrawAllObjects() { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::prepDrawAllObjects()"); - AnimObject *curObject = _objectQueue; - int drawPage = 2; - int flagUnk1 = 0, flagUnk2 = 0, flagUnk3 = 0; - if (_noDrawShapesFlag) - return; - if (_vm->_brandonStatusBit & 0x20) - flagUnk1 = 0x200; - if (_vm->_brandonStatusBit & 0x40) - flagUnk2 = 0x4000; - - while (curObject) { - if (curObject->active) { - int xpos = curObject->x1; - int ypos = curObject->y1; - - int drawLayer = 0; - if (!(curObject->flags & 0x800)) - drawLayer = 7; - else if (curObject->disable) - drawLayer = 0; - else - drawLayer = _vm->_sprites->getDrawLayer(curObject->drawY); - - // talking head functionallity - if (_vm->_talkingCharNum != -1 && (_vm->_currentCharacter->currentAnimFrame != 88 || curObject->index != 0)) { - const int16 baseAnimFrameTable1[] = { 0x11, 0x35, 0x59, 0x00, 0x00, 0x00 }; - const int16 baseAnimFrameTable2[] = { 0x15, 0x39, 0x5D, 0x00, 0x00, 0x00 }; - const int8 xOffsetTable1[] = { 2, 4, 0, 5, 2, 0, 0, 0 }; - const int8 xOffsetTable2[] = { 6, 4, 8, 3, 6, 0, 0, 0 }; - const int8 yOffsetTable1[] = { 0, 8, 1, 1, 0, 0, 0, 0 }; - const int8 yOffsetTable2[] = { 0, 8, 1, 1, 0, 0, 0, 0 }; - if (curObject->index == 0 || curObject->index <= 4) { - int shapesIndex = 0; - if (curObject->index == _vm->_charSayUnk3) { - shapesIndex = _vm->_currHeadShape + baseAnimFrameTable1[curObject->index]; - } else { - shapesIndex = baseAnimFrameTable2[curObject->index]; - int temp2 = 0; - if (curObject->index == 2) { - if (_vm->_characterList[2].sceneId == 77 || _vm->_characterList[2].sceneId == 86) - temp2 = 1; - else - temp2 = 0; - } else { - temp2 = 1; - } - - if (!temp2) - shapesIndex = -1; - } - - xpos = curObject->x1; - ypos = curObject->y1; - - int tempX = 0, tempY = 0; - if (curObject->flags & 0x1) { - tempX = (xOffsetTable1[curObject->index] * _brandonScaleX) >> 8; - tempY = yOffsetTable1[curObject->index]; - } else { - tempX = (xOffsetTable2[curObject->index] * _brandonScaleX) >> 8; - tempY = yOffsetTable2[curObject->index]; - } - tempY = (tempY * _brandonScaleY) >> 8; - xpos += tempX; - ypos += tempY; - - if (_vm->_scaleMode && _brandonScaleX != 256) - ++xpos; - - if (curObject->index == 0 && shapesIndex != -1) { - if (!(_vm->_brandonStatusBit & 2)) { - flagUnk3 = 0x100; - if ((flagUnk1 & 0x200) || (flagUnk2 & 0x4000)) - flagUnk3 = 0; - - int tempFlags = 0; - if (flagUnk3 & 0x100) { - tempFlags = curObject->flags & 1; - tempFlags |= 0x800 | flagUnk1 | 0x100; - } - - if (!(flagUnk3 & 0x100) && (flagUnk2 & 0x4000)) { - tempFlags = curObject->flags & 1; - tempFlags |= 0x900 | flagUnk1 | 0x4000; - _screen->drawShape(drawPage, _vm->_shapes[shapesIndex], xpos, ypos, 2, tempFlags | 4, _vm->_brandonPoisonFlagsGFX, int(1), int(_vm->_brandonInvFlag), drawLayer, _brandonScaleX, _brandonScaleY); - } else { - if (!(flagUnk2 & 0x4000)) { - tempFlags = curObject->flags & 1; - tempFlags |= 0x900 | flagUnk1; - } - - _screen->drawShape(drawPage, _vm->_shapes[shapesIndex], xpos, ypos, 2, tempFlags | 4, _vm->_brandonPoisonFlagsGFX, int(1), drawLayer, _brandonScaleX, _brandonScaleY); - } - } - } else { - if (shapesIndex != -1) { - int tempFlags = 0; - if (curObject->flags & 1) - tempFlags = 1; - _screen->drawShape(drawPage, _vm->_shapes[shapesIndex], xpos, ypos, 2, tempFlags | 0x800, drawLayer); - } - } - } - } - - xpos = curObject->x1; - ypos = curObject->y1; - - curObject->flags |= 0x800; - if (curObject->index == 0) { - flagUnk3 = 0x100; - - if (flagUnk1 & 0x200 || flagUnk2 & 0x4000) - flagUnk3 = 0; - - if (_vm->_brandonStatusBit & 2) - curObject->flags &= 0xFFFFFFFE; - - if (!_vm->_scaleMode) { - if (flagUnk3 & 0x100) - _screen->drawShape(drawPage, curObject->sceneAnimPtr, xpos, ypos, 2, curObject->flags | flagUnk1 | 0x100, (uint8*)_vm->_brandonPoisonFlagsGFX, int(1), drawLayer); - else if (flagUnk2 & 0x4000) - _screen->drawShape(drawPage, curObject->sceneAnimPtr, xpos, ypos, 2, curObject->flags | flagUnk1 | 0x4000, int(_vm->_brandonInvFlag), drawLayer); - else - _screen->drawShape(drawPage, curObject->sceneAnimPtr, xpos, ypos, 2, curObject->flags | flagUnk1, drawLayer); - } else { - if (flagUnk3 & 0x100) - _screen->drawShape(drawPage, curObject->sceneAnimPtr, xpos, ypos, 2, curObject->flags | flagUnk1 | 0x104, (uint8*)_vm->_brandonPoisonFlagsGFX, int(1), drawLayer, _brandonScaleX, _brandonScaleY); - else if (flagUnk2 & 0x4000) - _screen->drawShape(drawPage, curObject->sceneAnimPtr, xpos, ypos, 2, curObject->flags | flagUnk1 | 0x4004, int(_vm->_brandonInvFlag), drawLayer, _brandonScaleX, _brandonScaleY); - else - _screen->drawShape(drawPage, curObject->sceneAnimPtr, xpos, ypos, 2, curObject->flags | flagUnk1 | 0x4, drawLayer, _brandonScaleX, _brandonScaleY); - } - } else { - if (curObject->index >= 16 && curObject->index <= 27) - _screen->drawShape(drawPage, curObject->sceneAnimPtr, xpos, ypos, 2, curObject->flags | 4, drawLayer, (int)_vm->_scaleTable[curObject->drawY], (int)_vm->_scaleTable[curObject->drawY]); - else - _screen->drawShape(drawPage, curObject->sceneAnimPtr, xpos, ypos, 2, curObject->flags, drawLayer); - } - } - curObject = curObject->nextAnimObject; - } -} - -void ScreenAnimator::copyChangedObjectsForward(int refreshFlag) { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::copyChangedObjectsForward(%d)", refreshFlag); - - for (AnimObject *curObject = _objectQueue; curObject; curObject = curObject->nextAnimObject) { - if (curObject->active) { - if (curObject->refreshFlag || refreshFlag) { - int xpos = 0, ypos = 0, width = 0, height = 0; - xpos = (curObject->x1>>3) - (curObject->width2>>3) - 1; - ypos = curObject->y1 - curObject->height2; - width = curObject->width + (curObject->width2>>3) + 2; - height = curObject->height + curObject->height2*2; - - if (xpos < 1) - xpos = 1; - else if (xpos > 39) - continue; - - if (xpos + width > 39) - width = 39 - xpos; - - if (ypos < 8) - ypos = 8; - else if (ypos > 136) - continue; - - if (ypos + height > 136) - height = 136 - ypos; - - _screen->copyRegion(xpos << 3, ypos, xpos << 3, ypos, width << 3, height, 2, 0, Screen::CR_CLIPPED); - curObject->refreshFlag = 0; - _updateScreen = true; - } - } - } - - if (_updateScreen) { - _screen->updateScreen(); - _updateScreen = false; - } -} - -void ScreenAnimator::updateAllObjectShapes() { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::updateAllObjectShapes()"); - restoreAllObjectBackgrounds(); - preserveAnyChangedBackgrounds(); - prepDrawAllObjects(); - copyChangedObjectsForward(0); -} - -void ScreenAnimator::animRemoveGameItem(int index) { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::animRemoveGameItem(%d)", index); - restoreAllObjectBackgrounds(); - - AnimObject *animObj = &_items[index]; - animObj->sceneAnimPtr = 0; - animObj->animFrameNumber = -1; - animObj->refreshFlag = 1; - animObj->bkgdChangeFlag = 1; - updateAllObjectShapes(); - animObj->active = 0; - - objectRemoveQueue(_objectQueue, animObj); -} - -void ScreenAnimator::animAddGameItem(int index, uint16 sceneId) { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::animRemoveGameItem(%d, %d)", index, sceneId); - restoreAllObjectBackgrounds(); - assert(sceneId < _vm->_roomTableSize); - Room *currentRoom = &_vm->_roomTable[sceneId]; - AnimObject *animObj = &_items[index]; - animObj->active = 1; - animObj->refreshFlag = 1; - animObj->bkgdChangeFlag = 1; - animObj->drawY = currentRoom->itemsYPos[index]; - animObj->sceneAnimPtr = _vm->_shapes[216+currentRoom->itemsTable[index]]; - animObj->animFrameNumber = -1; - animObj->x1 = currentRoom->itemsXPos[index]; - animObj->y1 = currentRoom->itemsYPos[index]; - animObj->x1 -= fetchAnimWidth(animObj->sceneAnimPtr, _vm->_scaleTable[animObj->drawY]) >> 1; - animObj->y1 -= fetchAnimHeight(animObj->sceneAnimPtr, _vm->_scaleTable[animObj->drawY]); - animObj->x2 = animObj->x1; - animObj->y2 = animObj->y1; - animObj->width2 = 0; - animObj->height2 = 0; - _objectQueue = objectQueue(_objectQueue, animObj); - preserveAnyChangedBackgrounds(); - animObj->refreshFlag = 1; - animObj->bkgdChangeFlag = 1; -} - -void ScreenAnimator::animAddNPC(int character) { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::animAddNPC(%d)", character); - restoreAllObjectBackgrounds(); - AnimObject *animObj = &_actors[character]; - const Character *ch = &_vm->_characterList[character]; - - animObj->active = 1; - animObj->refreshFlag = 1; - animObj->bkgdChangeFlag = 1; - animObj->drawY = ch->y1; - animObj->sceneAnimPtr = _vm->_shapes[ch->currentAnimFrame]; - animObj->x1 = animObj->x2 = ch->x1 + _vm->_defaultShapeTable[ch->currentAnimFrame-7].xOffset; - animObj->y1 = animObj->y2 = ch->y1 + _vm->_defaultShapeTable[ch->currentAnimFrame-7].yOffset; - - if (ch->facing >= 1 && ch->facing <= 3) - animObj->flags |= 1; - else if (ch->facing >= 5 && ch->facing <= 7) - animObj->flags &= 0xFFFFFFFE; - - _objectQueue = objectQueue(_objectQueue, animObj); - preserveAnyChangedBackgrounds(); - animObj->refreshFlag = 1; - animObj->bkgdChangeFlag = 1; -} - -AnimObject *ScreenAnimator::objectRemoveQueue(AnimObject *queue, AnimObject *rem) { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::objectRemoveQueue(%p, %p)", (const void *)queue, (const void *)rem); - AnimObject *cur = queue; - AnimObject *prev = queue; - - while (cur != rem && cur) { - AnimObject *temp = cur->nextAnimObject; - if (!temp) - break; - prev = cur; - cur = temp; - } - - if (cur == queue) { - if (!cur) - return 0; - return cur->nextAnimObject; - } - - if (!cur->nextAnimObject) { - if (cur == rem) { - if (!prev) - return 0; - else - prev->nextAnimObject = 0; - } - } else { - if (cur == rem) - prev->nextAnimObject = rem->nextAnimObject; - } - - return queue; -} - -AnimObject *ScreenAnimator::objectAddHead(AnimObject *queue, AnimObject *head) { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::objectAddHead(%p, %p)", (const void *)queue, (const void *)head); - head->nextAnimObject = queue; - return head; -} - -AnimObject *ScreenAnimator::objectQueue(AnimObject *queue, AnimObject *add) { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::objectQueue(%p, %p)", (const void *)queue, (const void *)add); - if (add->drawY <= queue->drawY || !queue) { - add->nextAnimObject = queue; - return add; - } - AnimObject *cur = queue; - AnimObject *prev = queue; - while (add->drawY > cur->drawY) { - AnimObject *temp = cur->nextAnimObject; - if (!temp) - break; - prev = cur; - cur = temp; - } - - if (add->drawY <= cur->drawY) { - prev->nextAnimObject = add; - add->nextAnimObject = cur; - } else { - cur->nextAnimObject = add; - add->nextAnimObject = 0; - } - return queue; -} - -void ScreenAnimator::addObjectToQueue(AnimObject *object) { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::addObjectToQueue(%p)", (const void *)object); - if (!_objectQueue) - _objectQueue = objectAddHead(0, object); - else - _objectQueue = objectQueue(_objectQueue, object); -} - -void ScreenAnimator::refreshObject(AnimObject *object) { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::refreshObject(%p)", (const void *)object); - _objectQueue = objectRemoveQueue(_objectQueue, object); - if (_objectQueue) - _objectQueue = objectQueue(_objectQueue, object); - else - _objectQueue = objectAddHead(0, object); -} - -void ScreenAnimator::makeBrandonFaceMouse() { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::makeBrandonFaceMouse()"); - Common::Point mouse = _vm->getMousePos(); - if (mouse.x >= _vm->_currentCharacter->x1) - _vm->_currentCharacter->facing = 3; - else - _vm->_currentCharacter->facing = 5; - animRefreshNPC(0); - updateAllObjectShapes(); -} - -int16 ScreenAnimator::fetchAnimWidth(const uint8 *shape, int16 mult) { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::fetchAnimWidth(%p, %d)", (const void *)shape, mult); - if (_vm->gameFlags().useAltShapeHeader) - shape += 2; - return (((int16)READ_LE_UINT16((shape+3))) * mult) >> 8; -} - -int16 ScreenAnimator::fetchAnimHeight(const uint8 *shape, int16 mult) { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::fetchAnimHeight(%p, %d)", (const void *)shape, mult); - if (_vm->gameFlags().useAltShapeHeader) - shape += 2; - return (int16)(((int8)*(shape+2)) * mult) >> 8; -} - -void ScreenAnimator::setBrandonAnimSeqSize(int width, int height) { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::setBrandonAnimSeqSize(%d, %d)", width, height); - restoreAllObjectBackgrounds(); - _brandonAnimSeqSizeWidth = _actors[0].width; - _brandonAnimSeqSizeHeight = _actors[0].height; - _actors[0].width = width + 1; - _actors[0].height = height; - preserveAllBackgrounds(); -} - -void ScreenAnimator::resetBrandonAnimSeqSize() { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::resetBrandonAnimSeqSize()"); - restoreAllObjectBackgrounds(); - _actors[0].width = _brandonAnimSeqSizeWidth; - _actors[0].height = _brandonAnimSeqSizeHeight; - preserveAllBackgrounds(); -} - -void ScreenAnimator::animRefreshNPC(int character) { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::animRefreshNPC(%d)", character); - AnimObject *animObj = &_actors[character]; - Character *ch = &_vm->characterList()[character]; - - animObj->refreshFlag = 1; - animObj->bkgdChangeFlag = 1; - int facing = ch->facing; - if (facing >= 1 && facing <= 3) - animObj->flags |= 1; - else if (facing >= 5 && facing <= 7) - animObj->flags &= 0xFFFFFFFE; - - animObj->drawY = ch->y1; - animObj->sceneAnimPtr = _vm->shapes()[ch->currentAnimFrame]; - animObj->animFrameNumber = ch->currentAnimFrame; - if (character == 0) { - if (_vm->brandonStatus() & 10) { - animObj->animFrameNumber = 88; - ch->currentAnimFrame = 88; - } - if (_vm->brandonStatus() & 2) { - animObj->animFrameNumber = _brandonDrawFrame; - ch->currentAnimFrame = _brandonDrawFrame; - animObj->sceneAnimPtr = _vm->shapes()[_brandonDrawFrame]; - if (_vm->_brandonStatusBit0x02Flag) { - ++_brandonDrawFrame; - // TODO: check this - if (_brandonDrawFrame >= 122) { - _brandonDrawFrame = 113; - _vm->_brandonStatusBit0x02Flag = 0; - } - } - } - } - - int xOffset = _vm->_defaultShapeTable[ch->currentAnimFrame-7].xOffset; - int yOffset = _vm->_defaultShapeTable[ch->currentAnimFrame-7].yOffset; - - if (_vm->_scaleMode) { - animObj->x1 = ch->x1; - animObj->y1 = ch->y1; - - int newScale = _vm->_scaleTable[ch->y1]; - _brandonScaleX = newScale; - _brandonScaleY = newScale; - - animObj->x1 += (_brandonScaleX * xOffset) >> 8; - animObj->y1 += (_brandonScaleY * yOffset) >> 8; - } else { - animObj->x1 = ch->x1 + xOffset; - animObj->y1 = ch->y1 + yOffset; - } - animObj->width2 = 4; - animObj->height2 = 3; - - refreshObject(animObj); -} - -void ScreenAnimator::setCharacterDefaultFrame(int character) { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::setCharacterDefaultFrame()"); - static uint16 initFrameTable[] = { - 7, 41, 77, 0, 0 - }; - assert(character < ARRAYSIZE(initFrameTable)); - Character *edit = &_vm->characterList()[character]; - edit->sceneId = 0xFFFF; - edit->facing = 0; - edit->currentAnimFrame = initFrameTable[character]; - // edit->unk6 = 1; -} - -void ScreenAnimator::setCharactersHeight() { - debugC(9, kDebugLevelAnimator, "ScreenAnimator::setCharactersHeight()"); - static int8 initHeightTable[] = { - 48, 40, 48, 47, 56, - 44, 42, 47, 38, 35, - 40 - }; - for (int i = 0; i < 11; ++i) - _vm->characterList()[i].height = initHeightTable[i]; -} - -} // end of namespace Kyra - diff --git a/engines/kyra/animator.h b/engines/kyra/animator.h deleted file mode 100644 index e817be86d5..0000000000 --- a/engines/kyra/animator.h +++ /dev/null @@ -1,132 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -#ifndef KYRA_ANIMATOR_H -#define KYRA_ANIMATOR_H - -namespace Kyra { -class KyraEngine; -class Screen; - -struct AnimObject { - uint8 index; - uint32 active; - uint32 refreshFlag; - uint32 bkgdChangeFlag; - bool disable; - uint32 flags; - int16 drawY; - uint8 *sceneAnimPtr; - int16 animFrameNumber; - uint8 *background; - uint16 rectSize; - int16 x1, y1; - int16 x2, y2; - uint16 width; - uint16 height; - uint16 width2; - uint16 height2; - AnimObject *nextAnimObject; -}; - -class ScreenAnimator { -public: - ScreenAnimator(KyraEngine *vm, OSystem *system); - virtual ~ScreenAnimator(); - - operator bool() const { return _initOk; } - - void init(int actors, int items, int sprites); - void close(); - - AnimObject *objects() { return _screenObjects; } - AnimObject *actors() { return _actors; } - AnimObject *items() { return _items; } - AnimObject *sprites() { return _sprites; } - - void initAnimStateList(); - void preserveAllBackgrounds(); - void flagAllObjectsForBkgdChange(); - void flagAllObjectsForRefresh(); - void restoreAllObjectBackgrounds(); - void preserveAnyChangedBackgrounds(); - virtual void prepDrawAllObjects(); - void copyChangedObjectsForward(int refreshFlag); - - void updateAllObjectShapes(); - void animRemoveGameItem(int index); - void animAddGameItem(int index, uint16 sceneId); - void animAddNPC(int character); - void animRefreshNPC(int character); - - void clearQueue() { _objectQueue = 0; } - void addObjectToQueue(AnimObject *object); - void refreshObject(AnimObject *object); - - void makeBrandonFaceMouse(); - void setBrandonAnimSeqSize(int width, int height); - void resetBrandonAnimSeqSize(); - void setCharacterDefaultFrame(int character); - void setCharactersHeight(); - - int16 fetchAnimWidth(const uint8 *shape, int16 mult); - int16 fetchAnimHeight(const uint8 *shape, int16 mult); - - int _noDrawShapesFlag; - bool _updateScreen; - uint16 _brandonDrawFrame; - int _brandonScaleX; - int _brandonScaleY; - -protected: - KyraEngine *_vm; - Screen *_screen; - OSystem *_system; - bool _initOk; - - AnimObject *_screenObjects; - - AnimObject *_actors; - AnimObject *_items; - AnimObject *_sprites; - - uint8 *_actorBkgBackUp[2]; - - AnimObject *objectRemoveQueue(AnimObject *queue, AnimObject *rem); - AnimObject *objectAddHead(AnimObject *queue, AnimObject *head); - AnimObject *objectQueue(AnimObject *queue, AnimObject *add); - - void preserveOrRestoreBackground(AnimObject *obj, bool restore); - - AnimObject *_objectQueue; - - int _brandonAnimSeqSizeWidth; - int _brandonAnimSeqSizeHeight; - -}; -} // end of namespace Kyra - -#endif - diff --git a/engines/kyra/animator_v1.cpp b/engines/kyra/animator_v1.cpp new file mode 100644 index 0000000000..7683bb6417 --- /dev/null +++ b/engines/kyra/animator_v1.cpp @@ -0,0 +1,692 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include "common/stdafx.h" +#include "common/endian.h" + +#include "kyra/kyra.h" +#include "kyra/screen.h" +#include "kyra/animator.h" +#include "kyra/sprites.h" + +#include "common/system.h" + +namespace Kyra { +ScreenAnimator::ScreenAnimator(KyraEngine *vm, OSystem *system) { + _vm = vm; + _screen = vm->screen(); + _initOk = false; + _updateScreen = false; + _system = system; + _screenObjects = _actors = _items = _sprites = _objectQueue = 0; + _noDrawShapesFlag = 0; + + _actorBkgBackUp[0] = new uint8[_screen->getRectSize(8, 69)]; + memset(_actorBkgBackUp[0], 0, _screen->getRectSize(8, 69)); + _actorBkgBackUp[1] = new uint8[_screen->getRectSize(8, 69)]; + memset(_actorBkgBackUp[1], 0, _screen->getRectSize(8, 69)); +} + +ScreenAnimator::~ScreenAnimator() { + close(); + delete [] _actorBkgBackUp[0]; + delete [] _actorBkgBackUp[1]; +} + +void ScreenAnimator::init(int actors_, int items_, int sprites_) { + debugC(9, kDebugLevelAnimator, "ScreenAnimator::init(%d, %d, %d)", actors_, items_, sprites_); + _screenObjects = new AnimObject[actors_ + items_ + sprites_]; + assert(_screenObjects); + memset(_screenObjects, 0, sizeof(AnimObject) * (actors_ + items_ + sprites_)); + _actors = _screenObjects; + _sprites = &_screenObjects[actors_]; + _items = &_screenObjects[actors_ + items_]; + _brandonDrawFrame = 113; + + _initOk = true; +} + +void ScreenAnimator::close() { + debugC(9, kDebugLevelAnimator, "ScreenAnimator::close()"); + if (_initOk) { + _initOk = false; + delete [] _screenObjects; + _screenObjects = _actors = _items = _sprites = _objectQueue = 0; + } +} + +void ScreenAnimator::initAnimStateList() { + AnimObject *animStates = _screenObjects; + animStates[0].index = 0; + animStates[0].active = 1; + animStates[0].flags = 0x800; + animStates[0].background = _actorBkgBackUp[0]; + animStates[0].rectSize = _screen->getRectSize(4, 48); + animStates[0].width = 4; + animStates[0].height = 48; + animStates[0].width2 = 4; + animStates[0].height2 = 3; + + for (int i = 1; i <= 4; ++i) { + animStates[i].index = i; + animStates[i].active = 0; + animStates[i].flags = 0x800; + animStates[i].background = _actorBkgBackUp[1]; + animStates[i].rectSize = _screen->getRectSize(4, 64); + animStates[i].width = 4; + animStates[i].height = 48; + animStates[i].width2 = 4; + animStates[i].height2 = 3; + } + + for (int i = 5; i < 16; ++i) { + animStates[i].index = i; + animStates[i].active = 0; + animStates[i].flags = 0; + } + + for (int i = 16; i < 28; ++i) { + animStates[i].index = i; + animStates[i].flags = 0; + animStates[i].background = _vm->_shapes[345+i]; + animStates[i].rectSize = _screen->getRectSize(3, 24); + animStates[i].width = 3; + animStates[i].height = 16; + animStates[i].width2 = 0; + animStates[i].height2 = 0; + } +} + +void ScreenAnimator::preserveAllBackgrounds() { + debugC(9, kDebugLevelAnimator, "ScreenAnimator::preserveAllBackgrounds()"); + uint8 curPage = _screen->_curPage; + _screen->_curPage = 2; + + AnimObject *curObject = _objectQueue; + while (curObject) { + if (curObject->active && !curObject->disable) { + preserveOrRestoreBackground(curObject, false); + curObject->bkgdChangeFlag = 0; + } + curObject = curObject->nextAnimObject; + } + _screen->_curPage = curPage; +} + +void ScreenAnimator::flagAllObjectsForBkgdChange() { + debugC(9, kDebugLevelAnimator, "ScreenAnimator::flagAllObjectsForBkgdChange()"); + AnimObject *curObject = _objectQueue; + while (curObject) { + curObject->bkgdChangeFlag = 1; + curObject = curObject->nextAnimObject; + } +} + +void ScreenAnimator::flagAllObjectsForRefresh() { + debugC(9, kDebugLevelAnimator, "ScreenAnimator::flagAllObjectsForRefresh()"); + AnimObject *curObject = _objectQueue; + while (curObject) { + curObject->refreshFlag = 1; + curObject = curObject->nextAnimObject; + } +} + +void ScreenAnimator::restoreAllObjectBackgrounds() { + debugC(9, kDebugLevelAnimator, "ScreenAnimator::restoreAllObjectBackground()"); + AnimObject *curObject = _objectQueue; + _screen->_curPage = 2; + + while (curObject) { + if (curObject->active && !curObject->disable) { + preserveOrRestoreBackground(curObject, true); + curObject->x2 = curObject->x1; + curObject->y2 = curObject->y1; + } + curObject = curObject->nextAnimObject; + } + + _screen->_curPage = 0; +} + +void ScreenAnimator::preserveAnyChangedBackgrounds() { + debugC(9, kDebugLevelAnimator, "ScreenAnimator::preserveAnyChangedBackgrounds()"); + AnimObject *curObject = _objectQueue; + _screen->_curPage = 2; + + while (curObject) { + if (curObject->active && !curObject->disable && curObject->bkgdChangeFlag) { + preserveOrRestoreBackground(curObject, false); + curObject->bkgdChangeFlag = 0; + } + curObject = curObject->nextAnimObject; + } + + _screen->_curPage = 0; +} + +void ScreenAnimator::preserveOrRestoreBackground(AnimObject *obj, bool restore) { + debugC(9, kDebugLevelAnimator, "ScreenAnimator::preserveOrRestoreBackground(%p, %d)", (const void *)obj, restore); + int x = 0, y = 0, width = obj->width, height = obj->height; + + if (restore) { + x = obj->x2 >> 3; + y = obj->y2; + } else { + x = obj->x1 >> 3; + y = obj->y1; + } + + if (x < 0) + x = 0; + if (y < 0) + y = 0; + + int temp; + + temp = x + width; + if (temp >= 39) + x = 39 - width; + temp = y + height; + if (temp >= 136) + y = 136 - height; + + if (restore) + _screen->copyBlockToPage(_screen->_curPage, x << 3, y, width << 3, height, obj->background); + else + _screen->copyRegionToBuffer(_screen->_curPage, x << 3, y, width << 3, height, obj->background); +} + +void ScreenAnimator::prepDrawAllObjects() { + debugC(9, kDebugLevelAnimator, "ScreenAnimator::prepDrawAllObjects()"); + AnimObject *curObject = _objectQueue; + int drawPage = 2; + int flagUnk1 = 0, flagUnk2 = 0, flagUnk3 = 0; + if (_noDrawShapesFlag) + return; + if (_vm->_brandonStatusBit & 0x20) + flagUnk1 = 0x200; + if (_vm->_brandonStatusBit & 0x40) + flagUnk2 = 0x4000; + + while (curObject) { + if (curObject->active) { + int xpos = curObject->x1; + int ypos = curObject->y1; + + int drawLayer = 0; + if (!(curObject->flags & 0x800)) + drawLayer = 7; + else if (curObject->disable) + drawLayer = 0; + else + drawLayer = _vm->_sprites->getDrawLayer(curObject->drawY); + + // talking head functionallity + if (_vm->_talkingCharNum != -1 && (_vm->_currentCharacter->currentAnimFrame != 88 || curObject->index != 0)) { + const int16 baseAnimFrameTable1[] = { 0x11, 0x35, 0x59, 0x00, 0x00, 0x00 }; + const int16 baseAnimFrameTable2[] = { 0x15, 0x39, 0x5D, 0x00, 0x00, 0x00 }; + const int8 xOffsetTable1[] = { 2, 4, 0, 5, 2, 0, 0, 0 }; + const int8 xOffsetTable2[] = { 6, 4, 8, 3, 6, 0, 0, 0 }; + const int8 yOffsetTable1[] = { 0, 8, 1, 1, 0, 0, 0, 0 }; + const int8 yOffsetTable2[] = { 0, 8, 1, 1, 0, 0, 0, 0 }; + if (curObject->index == 0 || curObject->index <= 4) { + int shapesIndex = 0; + if (curObject->index == _vm->_charSayUnk3) { + shapesIndex = _vm->_currHeadShape + baseAnimFrameTable1[curObject->index]; + } else { + shapesIndex = baseAnimFrameTable2[curObject->index]; + int temp2 = 0; + if (curObject->index == 2) { + if (_vm->_characterList[2].sceneId == 77 || _vm->_characterList[2].sceneId == 86) + temp2 = 1; + else + temp2 = 0; + } else { + temp2 = 1; + } + + if (!temp2) + shapesIndex = -1; + } + + xpos = curObject->x1; + ypos = curObject->y1; + + int tempX = 0, tempY = 0; + if (curObject->flags & 0x1) { + tempX = (xOffsetTable1[curObject->index] * _brandonScaleX) >> 8; + tempY = yOffsetTable1[curObject->index]; + } else { + tempX = (xOffsetTable2[curObject->index] * _brandonScaleX) >> 8; + tempY = yOffsetTable2[curObject->index]; + } + tempY = (tempY * _brandonScaleY) >> 8; + xpos += tempX; + ypos += tempY; + + if (_vm->_scaleMode && _brandonScaleX != 256) + ++xpos; + + if (curObject->index == 0 && shapesIndex != -1) { + if (!(_vm->_brandonStatusBit & 2)) { + flagUnk3 = 0x100; + if ((flagUnk1 & 0x200) || (flagUnk2 & 0x4000)) + flagUnk3 = 0; + + int tempFlags = 0; + if (flagUnk3 & 0x100) { + tempFlags = curObject->flags & 1; + tempFlags |= 0x800 | flagUnk1 | 0x100; + } + + if (!(flagUnk3 & 0x100) && (flagUnk2 & 0x4000)) { + tempFlags = curObject->flags & 1; + tempFlags |= 0x900 | flagUnk1 | 0x4000; + _screen->drawShape(drawPage, _vm->_shapes[shapesIndex], xpos, ypos, 2, tempFlags | 4, _vm->_brandonPoisonFlagsGFX, int(1), int(_vm->_brandonInvFlag), drawLayer, _brandonScaleX, _brandonScaleY); + } else { + if (!(flagUnk2 & 0x4000)) { + tempFlags = curObject->flags & 1; + tempFlags |= 0x900 | flagUnk1; + } + + _screen->drawShape(drawPage, _vm->_shapes[shapesIndex], xpos, ypos, 2, tempFlags | 4, _vm->_brandonPoisonFlagsGFX, int(1), drawLayer, _brandonScaleX, _brandonScaleY); + } + } + } else { + if (shapesIndex != -1) { + int tempFlags = 0; + if (curObject->flags & 1) + tempFlags = 1; + _screen->drawShape(drawPage, _vm->_shapes[shapesIndex], xpos, ypos, 2, tempFlags | 0x800, drawLayer); + } + } + } + } + + xpos = curObject->x1; + ypos = curObject->y1; + + curObject->flags |= 0x800; + if (curObject->index == 0) { + flagUnk3 = 0x100; + + if (flagUnk1 & 0x200 || flagUnk2 & 0x4000) + flagUnk3 = 0; + + if (_vm->_brandonStatusBit & 2) + curObject->flags &= 0xFFFFFFFE; + + if (!_vm->_scaleMode) { + if (flagUnk3 & 0x100) + _screen->drawShape(drawPage, curObject->sceneAnimPtr, xpos, ypos, 2, curObject->flags | flagUnk1 | 0x100, (uint8*)_vm->_brandonPoisonFlagsGFX, int(1), drawLayer); + else if (flagUnk2 & 0x4000) + _screen->drawShape(drawPage, curObject->sceneAnimPtr, xpos, ypos, 2, curObject->flags | flagUnk1 | 0x4000, int(_vm->_brandonInvFlag), drawLayer); + else + _screen->drawShape(drawPage, curObject->sceneAnimPtr, xpos, ypos, 2, curObject->flags | flagUnk1, drawLayer); + } else { + if (flagUnk3 & 0x100) + _screen->drawShape(drawPage, curObject->sceneAnimPtr, xpos, ypos, 2, curObject->flags | flagUnk1 | 0x104, (uint8*)_vm->_brandonPoisonFlagsGFX, int(1), drawLayer, _brandonScaleX, _brandonScaleY); + else if (flagUnk2 & 0x4000) + _screen->drawShape(drawPage, curObject->sceneAnimPtr, xpos, ypos, 2, curObject->flags | flagUnk1 | 0x4004, int(_vm->_brandonInvFlag), drawLayer, _brandonScaleX, _brandonScaleY); + else + _screen->drawShape(drawPage, curObject->sceneAnimPtr, xpos, ypos, 2, curObject->flags | flagUnk1 | 0x4, drawLayer, _brandonScaleX, _brandonScaleY); + } + } else { + if (curObject->index >= 16 && curObject->index <= 27) + _screen->drawShape(drawPage, curObject->sceneAnimPtr, xpos, ypos, 2, curObject->flags | 4, drawLayer, (int)_vm->_scaleTable[curObject->drawY], (int)_vm->_scaleTable[curObject->drawY]); + else + _screen->drawShape(drawPage, curObject->sceneAnimPtr, xpos, ypos, 2, curObject->flags, drawLayer); + } + } + curObject = curObject->nextAnimObject; + } +} + +void ScreenAnimator::copyChangedObjectsForward(int refreshFlag) { + debugC(9, kDebugLevelAnimator, "ScreenAnimator::copyChangedObjectsForward(%d)", refreshFlag); + + for (AnimObject *curObject = _objectQueue; curObject; curObject = curObject->nextAnimObject) { + if (curObject->active) { + if (curObject->refreshFlag || refreshFlag) { + int xpos = 0, ypos = 0, width = 0, height = 0; + xpos = (curObject->x1>>3) - (curObject->width2>>3) - 1; + ypos = curObject->y1 - curObject->height2; + width = curObject->width + (curObject->width2>>3) + 2; + height = curObject->height + curObject->height2*2; + + if (xpos < 1) + xpos = 1; + else if (xpos > 39) + continue; + + if (xpos + width > 39) + width = 39 - xpos; + + if (ypos < 8) + ypos = 8; + else if (ypos > 136) + continue; + + if (ypos + height > 136) + height = 136 - ypos; + + _screen->copyRegion(xpos << 3, ypos, xpos << 3, ypos, width << 3, height, 2, 0, Screen::CR_CLIPPED); + curObject->refreshFlag = 0; + _updateScreen = true; + } + } + } + + if (_updateScreen) { + _screen->updateScreen(); + _updateScreen = false; + } +} + +void ScreenAnimator::updateAllObjectShapes() { + debugC(9, kDebugLevelAnimator, "ScreenAnimator::updateAllObjectShapes()"); + restoreAllObjectBackgrounds(); + preserveAnyChangedBackgrounds(); + prepDrawAllObjects(); + copyChangedObjectsForward(0); +} + +void ScreenAnimator::animRemoveGameItem(int index) { + debugC(9, kDebugLevelAnimator, "ScreenAnimator::animRemoveGameItem(%d)", index); + restoreAllObjectBackgrounds(); + + AnimObject *animObj = &_items[index]; + animObj->sceneAnimPtr = 0; + animObj->animFrameNumber = -1; + animObj->refreshFlag = 1; + animObj->bkgdChangeFlag = 1; + updateAllObjectShapes(); + animObj->active = 0; + + objectRemoveQueue(_objectQueue, animObj); +} + +void ScreenAnimator::animAddGameItem(int index, uint16 sceneId) { + debugC(9, kDebugLevelAnimator, "ScreenAnimator::animRemoveGameItem(%d, %d)", index, sceneId); + restoreAllObjectBackgrounds(); + assert(sceneId < _vm->_roomTableSize); + Room *currentRoom = &_vm->_roomTable[sceneId]; + AnimObject *animObj = &_items[index]; + animObj->active = 1; + animObj->refreshFlag = 1; + animObj->bkgdChangeFlag = 1; + animObj->drawY = currentRoom->itemsYPos[index]; + animObj->sceneAnimPtr = _vm->_shapes[216+currentRoom->itemsTable[index]]; + animObj->animFrameNumber = -1; + animObj->x1 = currentRoom->itemsXPos[index]; + animObj->y1 = currentRoom->itemsYPos[index]; + animObj->x1 -= fetchAnimWidth(animObj->sceneAnimPtr, _vm->_scaleTable[animObj->drawY]) >> 1; + animObj->y1 -= fetchAnimHeight(animObj->sceneAnimPtr, _vm->_scaleTable[animObj->drawY]); + animObj->x2 = animObj->x1; + animObj->y2 = animObj->y1; + animObj->width2 = 0; + animObj->height2 = 0; + _objectQueue = objectQueue(_objectQueue, animObj); + preserveAnyChangedBackgrounds(); + animObj->refreshFlag = 1; + animObj->bkgdChangeFlag = 1; +} + +void ScreenAnimator::animAddNPC(int character) { + debugC(9, kDebugLevelAnimator, "ScreenAnimator::animAddNPC(%d)", character); + restoreAllObjectBackgrounds(); + AnimObject *animObj = &_actors[character]; + const Character *ch = &_vm->_characterList[character]; + + animObj->active = 1; + animObj->refreshFlag = 1; + animObj->bkgdChangeFlag = 1; + animObj->drawY = ch->y1; + animObj->sceneAnimPtr = _vm->_shapes[ch->currentAnimFrame]; + animObj->x1 = animObj->x2 = ch->x1 + _vm->_defaultShapeTable[ch->currentAnimFrame-7].xOffset; + animObj->y1 = animObj->y2 = ch->y1 + _vm->_defaultShapeTable[ch->currentAnimFrame-7].yOffset; + + if (ch->facing >= 1 && ch->facing <= 3) + animObj->flags |= 1; + else if (ch->facing >= 5 && ch->facing <= 7) + animObj->flags &= 0xFFFFFFFE; + + _objectQueue = objectQueue(_objectQueue, animObj); + preserveAnyChangedBackgrounds(); + animObj->refreshFlag = 1; + animObj->bkgdChangeFlag = 1; +} + +AnimObject *ScreenAnimator::objectRemoveQueue(AnimObject *queue, AnimObject *rem) { + debugC(9, kDebugLevelAnimator, "ScreenAnimator::objectRemoveQueue(%p, %p)", (const void *)queue, (const void *)rem); + AnimObject *cur = queue; + AnimObject *prev = queue; + + while (cur != rem && cur) { + AnimObject *temp = cur->nextAnimObject; + if (!temp) + break; + prev = cur; + cur = temp; + } + + if (cur == queue) { + if (!cur) + return 0; + return cur->nextAnimObject; + } + + if (!cur->nextAnimObject) { + if (cur == rem) { + if (!prev) + return 0; + else + prev->nextAnimObject = 0; + } + } else { + if (cur == rem) + prev->nextAnimObject = rem->nextAnimObject; + } + + return queue; +} + +AnimObject *ScreenAnimator::objectAddHead(AnimObject *queue, AnimObject *head) { + debugC(9, kDebugLevelAnimator, "ScreenAnimator::objectAddHead(%p, %p)", (const void *)queue, (const void *)head); + head->nextAnimObject = queue; + return head; +} + +AnimObject *ScreenAnimator::objectQueue(AnimObject *queue, AnimObject *add) { + debugC(9, kDebugLevelAnimator, "ScreenAnimator::objectQueue(%p, %p)", (const void *)queue, (const void *)add); + if (add->drawY <= queue->drawY || !queue) { + add->nextAnimObject = queue; + return add; + } + AnimObject *cur = queue; + AnimObject *prev = queue; + while (add->drawY > cur->drawY) { + AnimObject *temp = cur->nextAnimObject; + if (!temp) + break; + prev = cur; + cur = temp; + } + + if (add->drawY <= cur->drawY) { + prev->nextAnimObject = add; + add->nextAnimObject = cur; + } else { + cur->nextAnimObject = add; + add->nextAnimObject = 0; + } + return queue; +} + +void ScreenAnimator::addObjectToQueue(AnimObject *object) { + debugC(9, kDebugLevelAnimator, "ScreenAnimator::addObjectToQueue(%p)", (const void *)object); + if (!_objectQueue) + _objectQueue = objectAddHead(0, object); + else + _objectQueue = objectQueue(_objectQueue, object); +} + +void ScreenAnimator::refreshObject(AnimObject *object) { + debugC(9, kDebugLevelAnimator, "ScreenAnimator::refreshObject(%p)", (const void *)object); + _objectQueue = objectRemoveQueue(_objectQueue, object); + if (_objectQueue) + _objectQueue = objectQueue(_objectQueue, object); + else + _objectQueue = objectAddHead(0, object); +} + +void ScreenAnimator::makeBrandonFaceMouse() { + debugC(9, kDebugLevelAnimator, "ScreenAnimator::makeBrandonFaceMouse()"); + Common::Point mouse = _vm->getMousePos(); + if (mouse.x >= _vm->_currentCharacter->x1) + _vm->_currentCharacter->facing = 3; + else + _vm->_currentCharacter->facing = 5; + animRefreshNPC(0); + updateAllObjectShapes(); +} + +int16 ScreenAnimator::fetchAnimWidth(const uint8 *shape, int16 mult) { + debugC(9, kDebugLevelAnimator, "ScreenAnimator::fetchAnimWidth(%p, %d)", (const void *)shape, mult); + if (_vm->gameFlags().useAltShapeHeader) + shape += 2; + return (((int16)READ_LE_UINT16((shape+3))) * mult) >> 8; +} + +int16 ScreenAnimator::fetchAnimHeight(const uint8 *shape, int16 mult) { + debugC(9, kDebugLevelAnimator, "ScreenAnimator::fetchAnimHeight(%p, %d)", (const void *)shape, mult); + if (_vm->gameFlags().useAltShapeHeader) + shape += 2; + return (int16)(((int8)*(shape+2)) * mult) >> 8; +} + +void ScreenAnimator::setBrandonAnimSeqSize(int width, int height) { + debugC(9, kDebugLevelAnimator, "ScreenAnimator::setBrandonAnimSeqSize(%d, %d)", width, height); + restoreAllObjectBackgrounds(); + _brandonAnimSeqSizeWidth = _actors[0].width; + _brandonAnimSeqSizeHeight = _actors[0].height; + _actors[0].width = width + 1; + _actors[0].height = height; + preserveAllBackgrounds(); +} + +void ScreenAnimator::resetBrandonAnimSeqSize() { + debugC(9, kDebugLevelAnimator, "ScreenAnimator::resetBrandonAnimSeqSize()"); + restoreAllObjectBackgrounds(); + _actors[0].width = _brandonAnimSeqSizeWidth; + _actors[0].height = _brandonAnimSeqSizeHeight; + preserveAllBackgrounds(); +} + +void ScreenAnimator::animRefreshNPC(int character) { + debugC(9, kDebugLevelAnimator, "ScreenAnimator::animRefreshNPC(%d)", character); + AnimObject *animObj = &_actors[character]; + Character *ch = &_vm->characterList()[character]; + + animObj->refreshFlag = 1; + animObj->bkgdChangeFlag = 1; + int facing = ch->facing; + if (facing >= 1 && facing <= 3) + animObj->flags |= 1; + else if (facing >= 5 && facing <= 7) + animObj->flags &= 0xFFFFFFFE; + + animObj->drawY = ch->y1; + animObj->sceneAnimPtr = _vm->shapes()[ch->currentAnimFrame]; + animObj->animFrameNumber = ch->currentAnimFrame; + if (character == 0) { + if (_vm->brandonStatus() & 10) { + animObj->animFrameNumber = 88; + ch->currentAnimFrame = 88; + } + if (_vm->brandonStatus() & 2) { + animObj->animFrameNumber = _brandonDrawFrame; + ch->currentAnimFrame = _brandonDrawFrame; + animObj->sceneAnimPtr = _vm->shapes()[_brandonDrawFrame]; + if (_vm->_brandonStatusBit0x02Flag) { + ++_brandonDrawFrame; + // TODO: check this + if (_brandonDrawFrame >= 122) { + _brandonDrawFrame = 113; + _vm->_brandonStatusBit0x02Flag = 0; + } + } + } + } + + int xOffset = _vm->_defaultShapeTable[ch->currentAnimFrame-7].xOffset; + int yOffset = _vm->_defaultShapeTable[ch->currentAnimFrame-7].yOffset; + + if (_vm->_scaleMode) { + animObj->x1 = ch->x1; + animObj->y1 = ch->y1; + + int newScale = _vm->_scaleTable[ch->y1]; + _brandonScaleX = newScale; + _brandonScaleY = newScale; + + animObj->x1 += (_brandonScaleX * xOffset) >> 8; + animObj->y1 += (_brandonScaleY * yOffset) >> 8; + } else { + animObj->x1 = ch->x1 + xOffset; + animObj->y1 = ch->y1 + yOffset; + } + animObj->width2 = 4; + animObj->height2 = 3; + + refreshObject(animObj); +} + +void ScreenAnimator::setCharacterDefaultFrame(int character) { + debugC(9, kDebugLevelAnimator, "ScreenAnimator::setCharacterDefaultFrame()"); + static uint16 initFrameTable[] = { + 7, 41, 77, 0, 0 + }; + assert(character < ARRAYSIZE(initFrameTable)); + Character *edit = &_vm->characterList()[character]; + edit->sceneId = 0xFFFF; + edit->facing = 0; + edit->currentAnimFrame = initFrameTable[character]; + // edit->unk6 = 1; +} + +void ScreenAnimator::setCharactersHeight() { + debugC(9, kDebugLevelAnimator, "ScreenAnimator::setCharactersHeight()"); + static int8 initHeightTable[] = { + 48, 40, 48, 47, 56, + 44, 42, 47, 38, 35, + 40 + }; + for (int i = 0; i < 11; ++i) + _vm->characterList()[i].height = initHeightTable[i]; +} + +} // end of namespace Kyra + diff --git a/engines/kyra/animator_v1.h b/engines/kyra/animator_v1.h new file mode 100644 index 0000000000..e817be86d5 --- /dev/null +++ b/engines/kyra/animator_v1.h @@ -0,0 +1,132 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#ifndef KYRA_ANIMATOR_H +#define KYRA_ANIMATOR_H + +namespace Kyra { +class KyraEngine; +class Screen; + +struct AnimObject { + uint8 index; + uint32 active; + uint32 refreshFlag; + uint32 bkgdChangeFlag; + bool disable; + uint32 flags; + int16 drawY; + uint8 *sceneAnimPtr; + int16 animFrameNumber; + uint8 *background; + uint16 rectSize; + int16 x1, y1; + int16 x2, y2; + uint16 width; + uint16 height; + uint16 width2; + uint16 height2; + AnimObject *nextAnimObject; +}; + +class ScreenAnimator { +public: + ScreenAnimator(KyraEngine *vm, OSystem *system); + virtual ~ScreenAnimator(); + + operator bool() const { return _initOk; } + + void init(int actors, int items, int sprites); + void close(); + + AnimObject *objects() { return _screenObjects; } + AnimObject *actors() { return _actors; } + AnimObject *items() { return _items; } + AnimObject *sprites() { return _sprites; } + + void initAnimStateList(); + void preserveAllBackgrounds(); + void flagAllObjectsForBkgdChange(); + void flagAllObjectsForRefresh(); + void restoreAllObjectBackgrounds(); + void preserveAnyChangedBackgrounds(); + virtual void prepDrawAllObjects(); + void copyChangedObjectsForward(int refreshFlag); + + void updateAllObjectShapes(); + void animRemoveGameItem(int index); + void animAddGameItem(int index, uint16 sceneId); + void animAddNPC(int character); + void animRefreshNPC(int character); + + void clearQueue() { _objectQueue = 0; } + void addObjectToQueue(AnimObject *object); + void refreshObject(AnimObject *object); + + void makeBrandonFaceMouse(); + void setBrandonAnimSeqSize(int width, int height); + void resetBrandonAnimSeqSize(); + void setCharacterDefaultFrame(int character); + void setCharactersHeight(); + + int16 fetchAnimWidth(const uint8 *shape, int16 mult); + int16 fetchAnimHeight(const uint8 *shape, int16 mult); + + int _noDrawShapesFlag; + bool _updateScreen; + uint16 _brandonDrawFrame; + int _brandonScaleX; + int _brandonScaleY; + +protected: + KyraEngine *_vm; + Screen *_screen; + OSystem *_system; + bool _initOk; + + AnimObject *_screenObjects; + + AnimObject *_actors; + AnimObject *_items; + AnimObject *_sprites; + + uint8 *_actorBkgBackUp[2]; + + AnimObject *objectRemoveQueue(AnimObject *queue, AnimObject *rem); + AnimObject *objectAddHead(AnimObject *queue, AnimObject *head); + AnimObject *objectQueue(AnimObject *queue, AnimObject *add); + + void preserveOrRestoreBackground(AnimObject *obj, bool restore); + + AnimObject *_objectQueue; + + int _brandonAnimSeqSizeWidth; + int _brandonAnimSeqSizeHeight; + +}; +} // end of namespace Kyra + +#endif + diff --git a/engines/kyra/gui.cpp b/engines/kyra/gui.cpp deleted file mode 100644 index fe051dd75c..0000000000 --- a/engines/kyra/gui.cpp +++ /dev/null @@ -1,1640 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -#include "kyra/kyra.h" -#include "kyra/screen.h" -#include "kyra/script.h" -#include "kyra/text.h" -#include "kyra/animator.h" -#include "kyra/sound.h" - -#include "common/config-manager.h" -#include "common/savefile.h" -#include "common/events.h" -#include "common/system.h" - -namespace Kyra { - -void KyraEngine::registerDefaultSettings() { - // Most settings already have sensible defaults. This one, however, is - // specific to the Kyra engine. - ConfMan.registerDefault("walkspeed", 2); - ConfMan.registerDefault("cdaudio", _flags.platform == Common::kPlatformFMTowns); -} - -void KyraEngine::readSettings() { - int talkspeed = ConfMan.getInt("talkspeed"); - - // The default talk speed is 60. This should be mapped to "Normal". - - if (talkspeed == 0) - _configTextspeed = 3; // Clickable - if (talkspeed <= 50) - _configTextspeed = 0; // Slow - else if (talkspeed <= 150) - _configTextspeed = 1; // Normal - else - _configTextspeed = 2; // Fast - - _configWalkspeed = ConfMan.getInt("walkspeed"); - _configMusic = ConfMan.getBool("music_mute") ? 0 : ((ConfMan.getBool("cdaudio") && _flags.platform == Common::kPlatformFMTowns) ? 2 : 1); - _configSounds = ConfMan.getBool("sfx_mute") ? 0 : 1; - - _sound->enableMusic(_configMusic); - _sound->enableSFX(_configSounds); - - bool speechMute = ConfMan.getBool("speech_mute"); - bool subtitles = ConfMan.getBool("subtitles"); - - if (!speechMute && subtitles) - _configVoice = 2; // Voice & Text - else if (!speechMute && !subtitles) - _configVoice = 1; // Voice only - else - _configVoice = 0; // Text only - - setWalkspeed(_configWalkspeed); -} - -void KyraEngine::writeSettings() { - bool speechMute, subtitles; - int talkspeed; - - switch (_configTextspeed) { - case 0: // Slow - talkspeed = 1; - break; - case 1: // Normal - talkspeed = 60; - break; - case 2: // Fast - talkspeed = 255; - break; - default: // Clickable - talkspeed = 0; - break; - } - - ConfMan.setInt("talkspeed", talkspeed); - ConfMan.setInt("walkspeed", _configWalkspeed); - ConfMan.setBool("music_mute", _configMusic == 0); - ConfMan.setBool("cdaudio", _configMusic == 2); - ConfMan.setBool("sfx_mute", _configSounds == 0); - - switch (_configVoice) { - case 0: // Text only - speechMute = true; - subtitles = true; - break; - case 1: // Voice only - speechMute = false; - subtitles = false; - break; - default: // Voice & Text - speechMute = false; - subtitles = true; - break; - } - - if (!_configMusic) - _sound->beginFadeOut(); - - _sound->enableMusic(_configMusic); - _sound->enableSFX(_configSounds); - - ConfMan.setBool("speech_mute", speechMute); - ConfMan.setBool("subtitles", subtitles); - - ConfMan.flushToDisk(); -} - -void KyraEngine::initMainButtonList() { - _haveScrollButtons = false; - _buttonList = &_buttonData[0]; - for (int i = 0; _buttonDataListPtr[i]; ++i) - _buttonList = initButton(_buttonList, _buttonDataListPtr[i]); -} - -Button *KyraEngine::initButton(Button *list, Button *newButton) { - if (!newButton) - return list; - if (!list) - return newButton; - Button *cur = list; - - while (true) { - if (!cur->nextButton) - break; - cur = cur->nextButton; - } - - cur->nextButton = newButton; - return list; -} - -int KyraEngine::buttonInventoryCallback(Button *caller) { - int itemOffset = caller->specialValue - 2; - uint8 inventoryItem = _currentCharacter->inventoryItems[itemOffset]; - if (_itemInHand == -1) { - if (inventoryItem == 0xFF) { - snd_playSoundEffect(0x36); - return 0; - } else { - _screen->hideMouse(); - _screen->fillRect(_itemPosX[itemOffset], _itemPosY[itemOffset], _itemPosX[itemOffset] + 15, _itemPosY[itemOffset] + 15, 12); - snd_playSoundEffect(0x35); - setMouseItem(inventoryItem); - updateSentenceCommand(_itemList[inventoryItem], _takenList[0], 179); - _itemInHand = inventoryItem; - _screen->showMouse(); - _currentCharacter->inventoryItems[itemOffset] = 0xFF; - } - } else { - if (inventoryItem != 0xFF) { - snd_playSoundEffect(0x35); - _screen->hideMouse(); - _screen->fillRect(_itemPosX[itemOffset], _itemPosY[itemOffset], _itemPosX[itemOffset] + 15, _itemPosY[itemOffset] + 15, 12); - _screen->drawShape(0, _shapes[216+_itemInHand], _itemPosX[itemOffset], _itemPosY[itemOffset], 0, 0); - setMouseItem(inventoryItem); - updateSentenceCommand(_itemList[inventoryItem], _takenList[1], 179); - _screen->showMouse(); - _currentCharacter->inventoryItems[itemOffset] = _itemInHand; - _itemInHand = inventoryItem; - } else { - snd_playSoundEffect(0x32); - _screen->hideMouse(); - _screen->drawShape(0, _shapes[216+_itemInHand], _itemPosX[itemOffset], _itemPosY[itemOffset], 0, 0); - _screen->setMouseCursor(1, 1, _shapes[0]); - updateSentenceCommand(_itemList[_itemInHand], _placedList[0], 179); - _screen->showMouse(); - _currentCharacter->inventoryItems[itemOffset] = _itemInHand; - _itemInHand = -1; - } - } - _screen->updateScreen(); - // XXX clearKyrandiaButtonIO - return 0; -} - -int KyraEngine::buttonAmuletCallback(Button *caller) { - if (!(_deathHandler & 8)) - return 1; - int jewel = caller->specialValue - 0x14; - if (_currentCharacter->sceneId == 210) { - if (_beadStateVar == 4 || _beadStateVar == 6) - return 1; - } - if (!queryGameFlag(0x2D)) - return 1; - if (_itemInHand != -1) { - assert(_putDownFirst); - characterSays(2000, _putDownFirst[0], 0, -2); - return 1; - } - if (queryGameFlag(0xF1)) { - assert(_waitForAmulet); - characterSays(2001, _waitForAmulet[0], 0, -2); - return 1; - } - if (!queryGameFlag(0x55+jewel)) { - assert(_blackJewel); - _animator->makeBrandonFaceMouse(); - drawJewelPress(jewel, 1); - characterSays(2002, _blackJewel[0], 0, -2); - return 1; - } - drawJewelPress(jewel, 0); - drawJewelsFadeOutStart(); - drawJewelsFadeOutEnd(jewel); - - _scriptInterpreter->initScript(_scriptClick, _scriptClickData); - _scriptClick->regs[3] = 0; - _scriptClick->regs[6] = jewel; - _scriptInterpreter->startScript(_scriptClick, 4); - - while (_scriptInterpreter->validScript(_scriptClick)) - _scriptInterpreter->runScript(_scriptClick); - - if (_scriptClick->regs[3]) - return 1; - - _unkAmuletVar = 1; - switch (jewel-1) { - case 0: - if (_brandonStatusBit & 1) { - seq_brandonHealing2(); - } else if (_brandonStatusBit == 0) { - seq_brandonHealing(); - assert(_healingTip); - characterSays(2003, _healingTip[0], 0, -2); - } - break; - - case 1: - seq_makeBrandonInv(); - break; - - case 2: - if (_brandonStatusBit & 1) { - assert(_wispJewelStrings); - characterSays(2004, _wispJewelStrings[0], 0, -2); - } else { - if (_brandonStatusBit & 2) { - // XXX - seq_makeBrandonNormal2(); - // XXX - } else { - // do not check for item in hand again as in the original since some strings are missing - // in the cd version - if (_currentCharacter->sceneId >= 109 && _currentCharacter->sceneId <= 198) { - snd_playWanderScoreViaMap(1, 0); - seq_makeBrandonWisp(); - snd_playWanderScoreViaMap(17, 0); - } else { - seq_makeBrandonWisp(); - } - setGameFlag(0x9E); - } - } - break; - - case 3: - seq_dispelMagicAnimation(); - assert(_magicJewelString); - characterSays(2007, _magicJewelString[0], 0, -2); - break; - - default: - break; - } - _unkAmuletVar = 0; - // XXX clearKyrandiaButtonIO (!used before every return in this function!) - return 1; -} - -void KyraEngine::processButtonList(Button *list) { - if (_haveScrollButtons) { - if (_mouseWheel < 0) - gui_scrollUp(&_scrollUpButton); - else if (_mouseWheel > 0) - gui_scrollDown(&_scrollDownButton); - } - while (list) { - if (list->flags & 8) { - list = list->nextButton; - continue; - } - - int x = list->x; - int y = list->y; - assert(list->dimTableIndex < _screen->_screenDimTableCount); - if (x < 0) { - x += _screen->_screenDimTable[list->dimTableIndex].w << 3; - } - x += _screen->_screenDimTable[list->dimTableIndex].sx << 3; - - if (y < 0) { - y += _screen->_screenDimTable[list->dimTableIndex].h; - } - y += _screen->_screenDimTable[list->dimTableIndex].sy; - - Common::Point mouse = getMousePos(); - if (mouse.x >= x && mouse.y >= y && x + list->width >= mouse.x && y + list->height >= mouse.y) { - int processMouseClick = 0; - if (list->flags & 0x400) { - if (_mousePressFlag) { - if (!(list->flags2 & 1)) { - list->flags2 |= 1; - list->flags2 |= 4; - processButton(list); - _screen->updateScreen(); - } - } else { - if (list->flags2 & 1) { - list->flags2 &= 0xFFFE; - processButton(list); - processMouseClick = 1; - } - } - } else if (_mousePressFlag) { - processMouseClick = 1; - } - - if (processMouseClick) { - if (list->buttonCallback) { - if ((this->*(list->buttonCallback))(list)) { - break; - } - } - } - } else { - if (list->flags2 & 1) { - list->flags2 &= 0xFFFE; - processButton(list); - } - if (list->flags2 & 4) { - list->flags2 &= 0xFFFB; - processButton(list); - _screen->updateScreen(); - } - list = list->nextButton; - continue; - } - - list = list->nextButton; - } -} - -void KyraEngine::processButton(Button *button) { - if (!button) - return; - - int processType = 0; - uint8 *shape = 0; - Button::ButtonCallback callback = 0; - - int flags = (button->flags2 & 5); - if (flags == 1) { - processType = button->process2; - if (processType == 1) - shape = button->process2PtrShape; - else if (processType == 4) - callback = button->process2PtrCallback; - } else if (flags == 4 || flags == 5) { - processType = button->process1; - if (processType == 1) - shape = button->process1PtrShape; - else if (processType == 4) - callback = button->process1PtrCallback; - } else { - processType = button->process0; - if (processType == 1) - shape = button->process0PtrShape; - else if (processType == 4) - callback = button->process0PtrCallback; - } - - int x = button->x; - int y = button->y; - assert(button->dimTableIndex < _screen->_screenDimTableCount); - if (x < 0) - x += _screen->_screenDimTable[button->dimTableIndex].w << 3; - - if (y < 0) - y += _screen->_screenDimTable[button->dimTableIndex].h; - - if (processType == 1 && shape) - _screen->drawShape(_screen->_curPage, shape, x, y, button->dimTableIndex, 0x10); - else if (processType == 4 && callback) - (this->*callback)(button); -} - -void KyraEngine::processAllMenuButtons() { - if (!_menuButtonList) - return; - - Button *cur = _menuButtonList; - while (true) { - if (!cur->nextButton) - break; - processMenuButton(cur); - cur = cur->nextButton; - } - return; -} - -void KyraEngine::processMenuButton(Button *button) { - if (!_displayMenu) - return; - - if (!button || (button->flags & 8)) - return; - - if (button->flags2 & 1) - button->flags2 &= 0xf7; - else - button->flags2 |= 8; - - button->flags2 &= 0xfc; - - if (button->flags2 & 4) - button->flags2 |= 0x10; - else - button->flags2 &= 0xef; - - button->flags2 &= 0xfb; - - processButton(button); -} - -int KyraEngine::drawBoxCallback(Button *button) { - if (!_displayMenu) - return 0; - - _screen->hideMouse(); - _screen->drawBox(button->x + 1, button->y + 1, button->x + button->width - 1, button->y + button->height - 1, 0xf8); - _screen->showMouse(); - - return 0; -} - -int KyraEngine::drawShadedBoxCallback(Button *button) { - if (!_displayMenu) - return 0; - - _screen->hideMouse(); - _screen->drawShadedBox(button->x, button->y, button->x + button->width, button->y + button->height, 0xf9, 0xfa); - _screen->showMouse(); - - return 0; -} - -void KyraEngine::setGUILabels() { - int offset = 0; - int offsetOptions = 0; - int offsetMainMenu = 0; - int offsetOn = 0; - - int walkspeedGarbageOffset = 36; - int menuLabelGarbageOffset = 0; - - if (_flags.isTalkie) { - if (_flags.lang == Common::EN_ANY) - offset = 52; - else if (_flags.lang == Common::DE_DEU) - offset = 30; - else if (_flags.lang == Common::FR_FRA || _flags.lang == Common::IT_ITA) - offset = 6; - offsetOn = offsetMainMenu = offsetOptions = offset; - walkspeedGarbageOffset = 48; - } else if (_flags.lang == Common::ES_ESP) { - offsetOn = offsetMainMenu = offsetOptions = offset = -4; - menuLabelGarbageOffset = 72; - } else if (_flags.lang == Common::DE_DEU) { - offset = offsetMainMenu = offsetOn = offsetOptions = 24; - } else if (_flags.platform == Common::kPlatformFMTowns) { - offset = 1; - offsetOptions = 10; - offsetOn = 0; - walkspeedGarbageOffset = 0; - } - - assert(offset + 27 < _guiStringsSize); - - // The Legend of Kyrandia - _menu[0].menuName = _guiStrings[0]; - // Load a Game - _menu[0].item[0].itemString = _guiStrings[1]; - // Save a Game - _menu[0].item[1].itemString = _guiStrings[2]; - // Game controls - _menu[0].item[2].itemString = _guiStrings[3]; - // Quit playing - _menu[0].item[3].itemString = _guiStrings[4]; - // Resume game - _menu[0].item[4].itemString = _guiStrings[5]; - - // Cancel - _menu[2].item[5].itemString = _guiStrings[10]; - - // Enter a description of your saved game: - _menu[3].menuName = _guiStrings[11]; - // Save - _menu[3].item[0].itemString = _guiStrings[12]; - // Cancel - _menu[3].item[1].itemString = _guiStrings[10]; - - // Rest in peace, Brandon - _menu[4].menuName = _guiStrings[13]; - // Load a game - _menu[4].item[0].itemString = _guiStrings[1]; - // Quit playing - _menu[4].item[1].itemString = _guiStrings[4]; - - // Game Controls - _menu[5].menuName = _guiStrings[6]; - // Yes - _menu[1].item[0].itemString = _guiStrings[22 + offset]; - // No - _menu[1].item[1].itemString = _guiStrings[23 + offset]; - - // Music is - _menu[5].item[0].labelString = _guiStrings[26 + offsetOptions]; - // Sounds are - _menu[5].item[1].labelString = _guiStrings[27 + offsetOptions]; - // Walk speed - _menu[5].item[2].labelString = &_guiStrings[24 + offsetOptions][walkspeedGarbageOffset]; - // Text speed - _menu[5].item[4].labelString = _guiStrings[25 + offsetOptions]; - // Main Menu - _menu[5].item[5].itemString = &_guiStrings[19 + offsetMainMenu][menuLabelGarbageOffset]; - - if (_flags.isTalkie) - // Text & Voice - _voiceTextString = _guiStrings[28 + offset]; - - _textSpeedString = _guiStrings[25 + offsetOptions]; - _onString = _guiStrings[20 + offsetOn]; - _offString = _guiStrings[21 + offset]; - _onCDString = _guiStrings[21]; -} - -int KyraEngine::buttonMenuCallback(Button *caller) { - _displayMenu = true; - - assert(_guiStrings); - assert(_configStrings); - - /* - for (int i = 0; i < _guiStringsSize; i++) - debug("GUI string %i: %s", i, _guiStrings[i]); - - for (int i = 0; i < _configStringsSize; i++) - debug("Config string %i: %s", i, _configStrings[i]); - */ - - setGUILabels(); - if (_currentCharacter->sceneId == 210 && _deathHandler == 0xFF) { - snd_playSoundEffect(0x36); - return 0; - } - // XXX - _screen->setPaletteIndex(0xFE, 60, 60, 0); - for (int i = 0; i < 6; i++) { - _menuButtonData[i].process0 = _menuButtonData[i].process1 = _menuButtonData[i].process2 = 4; - _menuButtonData[i].process0PtrCallback = &KyraEngine::drawShadedBoxCallback; - _menuButtonData[i].process1PtrCallback = &KyraEngine::drawBoxCallback; - _menuButtonData[i].process2PtrCallback = &KyraEngine::drawShadedBoxCallback; - } - - _screen->savePageToDisk("SEENPAGE.TMP", 0); - gui_fadePalette(); - - for (int i = 0; i < 5; i++) - calcCoords(_menu[i]); - - _menuRestoreScreen = true; - _keyPressed.reset(); - _mousePressFlag = false; - - _toplevelMenu = 0; - if (_menuDirectlyToLoad) { - gui_loadGameMenu(0); - } else { - if (!caller) - _toplevelMenu = 4; - - initMenu(_menu[_toplevelMenu]); - processAllMenuButtons(); - } - - while (_displayMenu && !_quitFlag) { - gui_processHighlights(_menu[_toplevelMenu]); - processButtonList(_menuButtonList); - gui_getInput(); - } - - if (_menuRestoreScreen) { - gui_restorePalette(); - _screen->loadPageFromDisk("SEENPAGE.TMP", 0); - _animator->_updateScreen = true; - } else { - _screen->deletePageFromDisk(0); - } - - return 0; -} - -void KyraEngine::initMenu(Menu &menu) { - _menuButtonList = 0; - - _screen->hideMouse(); - - int textX; - int textY; - - int menu_x2 = menu.width + menu.x - 1; - int menu_y2 = menu.height + menu.y - 1; - - _screen->fillRect(menu.x + 2, menu.y + 2, menu_x2 - 2, menu_y2 - 2, menu.bgcolor); - _screen->drawShadedBox(menu.x, menu.y, menu_x2, menu_y2, menu.color1, menu.color2); - - if (menu.field_10 != -1) - textX = menu.x; - else - textX = _text->getCenterStringX(menu.menuName, menu.x, menu_x2); - - textY = menu.y + menu.field_12; - - _text->printText(menu.menuName, textX - 1, textY + 1, 12, 248, 0); - _text->printText(menu.menuName, textX, textY, menu.textColor, 0, 0); - - int x1, y1, x2, y2; - for (int i = 0; i < menu.nrOfItems; i++) { - if (!menu.item[i].enabled) - continue; - - x1 = menu.x + menu.item[i].x; - y1 = menu.y + menu.item[i].y; - - x2 = x1 + menu.item[i].width - 1; - y2 = y1 + menu.item[i].height - 1; - - if (i < 6) { - _menuButtonData[i].nextButton = 0; - _menuButtonData[i].x = x1; - _menuButtonData[i].y = y1; - _menuButtonData[i].width = menu.item[i].width - 1; - _menuButtonData[i].height = menu.item[i].height - 1; - _menuButtonData[i].buttonCallback = menu.item[i].callback; - _menuButtonData[i].specialValue = menu.item[i].field_1b; - //_menuButtonData[i].field_6 = menu.item[i].field_25; - //_menuButtonData[i].field_8 = 0; - - if (!_menuButtonList) - _menuButtonList = &_menuButtonData[i]; - else - _menuButtonList = initButton(_menuButtonList, &_menuButtonData[i]); - } - _screen->fillRect(x1, y1, x2, y2, menu.item[i].bgcolor); - _screen->drawShadedBox(x1, y1, x2, y2, menu.item[i].color1, menu.item[i].color2); - - if (menu.item[i].itemString) { - if (menu.item[i].field_12 != -1 && _flags.lang == Common::EN_ANY) - textX = x1 + menu.item[i].field_12 + 3; - else - textX = _text->getCenterStringX(menu.item[i].itemString, x1, x2); - - textY = y1 + 2; - _text->printText(menu.item[i].itemString, textX - 1, textY + 1, 12, 0, 0); - - if (i == menu.highlightedItem) - _text->printText(menu.item[i].itemString, textX, textY, menu.item[i].highlightColor, 0, 0); - else - _text->printText(menu.item[i].itemString, textX, textY, menu.item[i].textColor, 0, 0); - - if (menu.item[i].labelString) { - _text->printText(menu.item[i].labelString, menu.x + menu.item[i].labelX - 1, menu.y + menu.item[i].labelY + 1, 12, 0, 0); - _text->printText(menu.item[i].labelString, menu.x + menu.item[i].labelX, menu.y + menu.item[i].labelY, 253, 0, 0); - } - } - } - - if (menu.scrollUpBtnX != -1) { - _haveScrollButtons = true; - - _scrollUpButton.x = menu.scrollUpBtnX + menu.x; - _scrollUpButton.y = menu.scrollUpBtnY + menu.y; - _scrollUpButton.buttonCallback = &KyraEngine::gui_scrollUp; - _scrollUpButton.nextButton = 0; - _menuButtonList = initButton(_menuButtonList, &_scrollUpButton); - processMenuButton(&_scrollUpButton); - - _scrollDownButton.x = menu.scrollDownBtnX + menu.x; - _scrollDownButton.y = menu.scrollDownBtnY + menu.y; - _scrollDownButton.buttonCallback = &KyraEngine::gui_scrollDown; - _scrollDownButton.nextButton = 0; - _menuButtonList = initButton(_menuButtonList, &_scrollDownButton); - processMenuButton(&_scrollDownButton); - } else { - _haveScrollButtons = false; - } - - _screen->showMouse(); - _screen->updateScreen(); -} - -void KyraEngine::calcCoords(Menu &menu) { - assert(menu.nrOfItems < 7); - - int widthBackup = _screen->_charWidth; - _screen->_charWidth = -2; - - menu.x = (320 - menu.width)/2; - - int menu_x2 = menu.width + menu.x - 1; - int maxOffset = 0; - int x1, x2, y1, y2; - - for (int i = 0; i < menu.nrOfItems; i++) { - if (menu.item[i].x == -1) - menu.item[i].x = (menu.width - menu.item[i].width)/2; - - if (menu.item[i].labelString) { - x1 = menu.x + menu.item[i].x + 25; - y1 = (200 - menu.height)/2 + menu.item[i].y; - - x2 = x1 + menu.item[i].width; - y2 = y1 + menu.item[i].height; - - int textWidth = _screen->getTextWidth(menu.item[i].labelString) + 25; - int textX = menu.item[i].labelX + menu.x; - - if (textWidth + textX > x1) { - int offset = ((textWidth + textX) - x1); - if (maxOffset < offset) - maxOffset = offset; - } - } - - if (menu.item[i].itemString) { - int textWidth = _screen->getTextWidth(menu.item[i].itemString) + 15; - - if (menu.item[i].width < textWidth) { - menu.item[i].width = textWidth; - - if ( menu.x + menu.item[i].x + menu.item[i].width > menu_x2) - menu.item[i].x -= (menu.x + menu.item[i].x + menu.item[i].width) - menu_x2 + 10; - } - } - - } - - if (maxOffset > 0) { - maxOffset = maxOffset/2; - for (int i = 0; i < menu.nrOfItems; i++) { - menu.item[i].x += maxOffset + 10; - menu.item[i].labelX -= maxOffset; - } - menu.width += maxOffset; - } - - if (menu.menuName != 0) { - int menuNameLength = _screen->getTextWidth(menu.menuName); - if (menuNameLength > menu.width) - menu.width = menuNameLength; - } - - if (menu.width > 310) - menu.width = 310; - - menu.x = (320 - menu.width)/2; - - if (menu.y == -1) - menu.y = (200 - menu.height)/2; - - _screen->_charWidth = widthBackup; -} - -void KyraEngine::gui_getInput() { - Common::Event event; - static uint32 lastScreenUpdate = 0; - uint32 now = _system->getMillis(); - - _mouseWheel = 0; - while (_eventMan->pollEvent(event)) { - switch (event.type) { - case Common::EVENT_QUIT: - quitGame(); - break; - case Common::EVENT_LBUTTONDOWN: - _mousePressFlag = true; - break; - case Common::EVENT_LBUTTONUP: - _mousePressFlag = false; - break; - case Common::EVENT_MOUSEMOVE: - _system->updateScreen(); - lastScreenUpdate = now; - break; - case Common::EVENT_WHEELUP: - _mouseWheel = -1; - break; - case Common::EVENT_WHEELDOWN: - _mouseWheel = 1; - break; - case Common::EVENT_KEYDOWN: - _keyPressed = event.kbd; - break; - default: - break; - } - } - - if (now - lastScreenUpdate > 50) { - _system->updateScreen(); - lastScreenUpdate = now; - } - - _system->delayMillis(3); -} - -int KyraEngine::gui_resumeGame(Button *button) { - debugC(9, kDebugLevelGUI, "KyraEngine::gui_resumeGame()"); - processMenuButton(button); - _displayMenu = false; - - return 0; -} - -const char *KyraEngine::getSavegameFilename(int num) { - static char saveLoadSlot[12]; - - sprintf(saveLoadSlot, "%s.%.3d", _targetName.c_str(), num); - return saveLoadSlot; -} - -int KyraEngine::getNextSavegameSlot() { - Common::InSaveFile *in; - - for (int i = 1; i < 1000; i++) { - if ((in = _saveFileMan->openForLoading(getSavegameFilename(i)))) - delete in; - else - return i; - } - warning("Didn't save: Ran out of savegame filenames"); - return 0; -} - -void KyraEngine::setupSavegames(Menu &menu, int num) { - Common::InSaveFile *in; - static char savenames[5][31]; - uint8 startSlot; - assert(num <= 5); - - if (_savegameOffset == 0) { - menu.item[0].itemString = _specialSavegameString; - menu.item[0].enabled = 1; - menu.item[0].field_1b = 0; - startSlot = 1; - } else { - startSlot = 0; - } - - for (int i = startSlot; i < num; i++) { - if ((in = _saveFileMan->openForLoading(getSavegameFilename(i + _savegameOffset)))) { - in->skip(8); - in->read(savenames[i], 31); - menu.item[i].itemString = savenames[i]; - menu.item[i].enabled = 1; - menu.item[i].field_1b = i + _savegameOffset; - delete in; - } else { - menu.item[i].enabled = 0; - //menu.item[i].itemString = ""; - //menu.item[i].field_1b = -1; - } - } -} - -int KyraEngine::gui_saveGameMenu(Button *button) { - debugC(9, kDebugLevelGUI, "KyraEngine::gui_saveGameMenu()"); - processMenuButton(button); - _menu[2].item[5].enabled = true; - - _screen->loadPageFromDisk("SEENPAGE.TMP", 0); - _screen->savePageToDisk("SEENPAGE.TMP", 0); - - _menu[2].menuName = _guiStrings[8]; // Select a position to save to: - _specialSavegameString = _guiStrings[9]; // [ EMPTY SLOT ] - for (int i = 0; i < 5; i++) - _menu[2].item[i].callback = &KyraEngine::gui_saveGame; - - _savegameOffset = 0; - setupSavegames(_menu[2], 5); - - initMenu(_menu[2]); - processAllMenuButtons(); - - _displaySubMenu = true; - _cancelSubMenu = false; - - while (_displaySubMenu && !_quitFlag) { - gui_getInput(); - gui_processHighlights(_menu[2]); - processButtonList(_menuButtonList); - } - - _screen->loadPageFromDisk("SEENPAGE.TMP", 0); - _screen->savePageToDisk("SEENPAGE.TMP", 0); - - if (_cancelSubMenu) { - initMenu(_menu[0]); - processAllMenuButtons(); - } else { - _displayMenu = false; - } - return 0; -} - -int KyraEngine::gui_loadGameMenu(Button *button) { - debugC(9, kDebugLevelGUI, "KyraEngine::gui_loadGameMenu()"); - if (_menuDirectlyToLoad) { - _menu[2].item[5].enabled = false; - } else { - processMenuButton(button); - _menu[2].item[5].enabled = true; - } - - _screen->loadPageFromDisk("SEENPAGE.TMP", 0); - _screen->savePageToDisk("SEENPAGE.TMP", 0); - - _specialSavegameString = _newGameString[0]; //[ START A NEW GAME ] - _menu[2].menuName = _guiStrings[7]; // Which game would you like to reload? - for (int i = 0; i < 5; i++) - _menu[2].item[i].callback = &KyraEngine::gui_loadGame; - - _savegameOffset = 0; - setupSavegames(_menu[2], 5); - - initMenu(_menu[2]); - processAllMenuButtons(); - - _displaySubMenu = true; - _cancelSubMenu = false; - - while (_displaySubMenu && !_quitFlag) { - gui_getInput(); - gui_processHighlights(_menu[2]); - processButtonList(_menuButtonList); - } - - _screen->loadPageFromDisk("SEENPAGE.TMP", 0); - _screen->savePageToDisk("SEENPAGE.TMP", 0); - - if (_cancelSubMenu) { - initMenu(_menu[_toplevelMenu]); - processAllMenuButtons(); - } else { - gui_restorePalette(); - loadGame(getSavegameFilename(_gameToLoad)); - _displayMenu = false; - _menuRestoreScreen = false; - } - return 0; -} - -void KyraEngine::gui_redrawTextfield() { - _screen->fillRect(38, 91, 287, 102, 250); - _text->printText(_savegameName, 38, 92, 253, 0, 0); - - _screen->_charWidth = -2; - int width = _screen->getTextWidth(_savegameName); - _screen->fillRect(39 + width, 93, 45 + width, 100, 254); - _screen->_charWidth = 0; - - _screen->updateScreen(); -} - -void KyraEngine::gui_updateSavegameString() { - int length; - - if (_keyPressed.keycode) { - length = strlen(_savegameName); - - if (_keyPressed.ascii > 31 && _keyPressed.ascii < 127) { - if (length < 31) { - _savegameName[length] = _keyPressed.ascii; - _savegameName[length+1] = 0; - gui_redrawTextfield(); - } - } else if (_keyPressed.keycode == Common::KEYCODE_BACKSPACE || - _keyPressed.keycode == Common::KEYCODE_DELETE) { - if (length > 0) { - _savegameName[length-1] = 0; - gui_redrawTextfield(); - } - } else if (_keyPressed.keycode == Common::KEYCODE_RETURN || - _keyPressed.keycode == Common::KEYCODE_KP_ENTER) { - _displaySubMenu = false; - } - } - - _keyPressed.reset(); -} - -int KyraEngine::gui_saveGame(Button *button) { - debugC(9, kDebugLevelGUI, "KyraEngine::gui_saveGame()"); - processMenuButton(button); - _gameToLoad = button->specialValue; - - _screen->loadPageFromDisk("SEENPAGE.TMP", 0); - _screen->savePageToDisk("SEENPAGE.TMP", 0); - - initMenu(_menu[3]); - processAllMenuButtons(); - - _displaySubMenu = true; - _cancelSubMenu = false; - - if (_savegameOffset == 0 && _gameToLoad == 0) { - _savegameName[0] = 0; - } else { - for (int i = 0; i < 5; i++) { - if (_menu[2].item[i].field_1b == _gameToLoad) { - strncpy(_savegameName, _menu[2].item[i].itemString, 31); - break; - } - } - } - gui_redrawTextfield(); - - while (_displaySubMenu && !_quitFlag) { - gui_getInput(); - gui_updateSavegameString(); - gui_processHighlights(_menu[3]); - processButtonList(_menuButtonList); - } - - if (_cancelSubMenu) { - _displaySubMenu = true; - _cancelSubMenu = false; - initMenu(_menu[2]); - processAllMenuButtons(); - } else { - if (_savegameOffset == 0 && _gameToLoad == 0) - _gameToLoad = getNextSavegameSlot(); - if (_gameToLoad > 0) - saveGame(getSavegameFilename(_gameToLoad), _savegameName); - } - - return 0; -} - -int KyraEngine::gui_savegameConfirm(Button *button) { - debugC(9, kDebugLevelGUI, "KyraEngine::gui_savegameConfirm()"); - processMenuButton(button); - _displaySubMenu = false; - - return 0; -} - -int KyraEngine::gui_loadGame(Button *button) { - debugC(9, kDebugLevelGUI, "KyraEngine::gui_loadGame()"); - processMenuButton(button); - _displaySubMenu = false; - _gameToLoad = button->specialValue; - - return 0; -} - -int KyraEngine::gui_cancelSubMenu(Button *button) { - debugC(9, kDebugLevelGUI, "KyraEngine::gui_cancelLoadGameMenu()"); - processMenuButton(button); - _displaySubMenu = false; - _cancelSubMenu = true; - - return 0; -} - -int KyraEngine::gui_quitPlaying(Button *button) { - debugC(9, kDebugLevelGUI, "KyraEngine::gui_quitPlaying()"); - processMenuButton(button); - - if (gui_quitConfirm(_guiStrings[14])) { // Are you sure you want to quit playing? - quitGame(); - } else { - initMenu(_menu[_toplevelMenu]); - processAllMenuButtons(); - } - - return 0; -} - -bool KyraEngine::gui_quitConfirm(const char *str) { - debugC(9, kDebugLevelGUI, "KyraEngine::gui_quitConfirm()"); - - _screen->loadPageFromDisk("SEENPAGE.TMP", 0); - _screen->savePageToDisk("SEENPAGE.TMP", 0); - - _menu[1].menuName = str; - calcCoords(_menu[1]); - initMenu(_menu[1]); - - _displaySubMenu = true; - _cancelSubMenu = true; - - while (_displaySubMenu && !_quitFlag) { - gui_getInput(); - gui_processHighlights(_menu[1]); - processButtonList(_menuButtonList); - } - - _screen->loadPageFromDisk("SEENPAGE.TMP", 0); - _screen->savePageToDisk("SEENPAGE.TMP", 0); - - return !_cancelSubMenu; -} - -int KyraEngine::gui_quitConfirmYes(Button *button) { - debugC(9, kDebugLevelGUI, "KyraEngine::gui_quitConfirmYes()"); - processMenuButton(button); - _displaySubMenu = false; - _cancelSubMenu = false; - - return 0; -} - -int KyraEngine::gui_quitConfirmNo(Button *button) { - debugC(9, kDebugLevelGUI, "KyraEngine::gui_quitConfirmNo()"); - processMenuButton(button); - _displaySubMenu = false; - _cancelSubMenu = true; - - return 0; -} - -int KyraEngine::gui_gameControlsMenu(Button *button) { - debugC(9, kDebugLevelGUI, "KyraEngine::gui_gameControlsMenu()"); - - readSettings(); - - _screen->loadPageFromDisk("SEENPAGE.TMP", 0); - _screen->savePageToDisk("SEENPAGE.TMP", 0); - - if (_flags.isTalkie) { - //_menu[5].width = 230; - - for (int i = 0; i < 5; i++) { - //_menu[5].item[i].labelX = 24; - //_menu[5].item[i].x = 115; - //_menu[5].item[i].width = 94; - } - - _menu[5].item[3].labelString = _voiceTextString; //"Voice / Text " - _menu[5].item[3].callback = &KyraEngine::gui_controlsChangeVoice; - - } else { - //_menu[5].height = 136; - //_menu[5].item[5].y = 110; - _menu[5].item[4].enabled = 0; - _menu[5].item[3].labelString = _textSpeedString; // "Text speed " - _menu[5].item[3].callback = &KyraEngine::gui_controlsChangeText; - } - - gui_setupControls(_menu[5]); - - processAllMenuButtons(); - - _displaySubMenu = true; - _cancelSubMenu = false; - - while (_displaySubMenu && !_quitFlag) { - gui_getInput(); - gui_processHighlights(_menu[5]); - processButtonList(_menuButtonList); - } - - _screen->loadPageFromDisk("SEENPAGE.TMP", 0); - _screen->savePageToDisk("SEENPAGE.TMP", 0); - - if (_cancelSubMenu) { - initMenu(_menu[_toplevelMenu]); - processAllMenuButtons(); - } - return 0; -} - -void KyraEngine::gui_setupControls(Menu &menu) { - debugC(9, kDebugLevelGUI, "KyraEngine::gui_setupControls()"); - - switch (_configMusic) { - case 0: - menu.item[0].itemString = _offString; //"Off" - break; - case 1: - menu.item[0].itemString = _onString; //"On" - break; - case 2: - menu.item[0].itemString = _onCDString; //"On + CD" - break; - } - - if (_configSounds) - menu.item[1].itemString = _onString; //"On" - else - menu.item[1].itemString = _offString; //"Off" - - - switch (_configWalkspeed) { - case 0: - menu.item[2].itemString = _configStrings[0]; //"Slowest" - break; - case 1: - menu.item[2].itemString = _configStrings[1]; //"Slow" - break; - case 2: - menu.item[2].itemString = _configStrings[2]; //"Normal" - break; - case 3: - menu.item[2].itemString = _configStrings[3]; //"Fast" - break; - case 4: - menu.item[2].itemString = _configStrings[4]; //"Fastest" - break; - default: - menu.item[2].itemString = "ERROR"; - break; - } - - int textControl = 3; - int clickableOffset = 8; - if (_flags.isTalkie) { - textControl = 4; - clickableOffset = 11; - - if (_configVoice == 0) - _menu[5].item[4].enabled = 1; - else - _menu[5].item[4].enabled = 0; - - switch (_configVoice) { - case 0: - menu.item[3].itemString = _configStrings[5]; //"Text only" - break; - case 1: - menu.item[3].itemString = _configStrings[6]; //"Voice only" - break; - case 2: - menu.item[3].itemString = _configStrings[7]; //"Voice & Text" - break; - default: - menu.item[3].itemString = "ERROR"; - break; - } - } - - switch (_configTextspeed) { - case 0: - menu.item[textControl].itemString = _configStrings[1]; //"Slow" - break; - case 1: - menu.item[textControl].itemString = _configStrings[2]; //"Normal" - break; - case 2: - menu.item[textControl].itemString = _configStrings[3]; //"Fast" - break; - case 3: - menu.item[textControl].itemString = _configStrings[clickableOffset]; //"Clickable" - break; - default: - menu.item[textControl].itemString = "ERROR"; - break; - } - - calcCoords(menu); - initMenu(menu); -} - -int KyraEngine::gui_controlsChangeMusic(Button *button) { - debugC(9, kDebugLevelGUI, "KyraEngine::gui_controlsChangeMusic()"); - processMenuButton(button); - - _configMusic = ++_configMusic % (_flags.platform == Common::kPlatformFMTowns ? 3 : 2); - gui_setupControls(_menu[5]); - return 0; -} - -int KyraEngine::gui_controlsChangeSounds(Button *button) { - debugC(9, kDebugLevelGUI, "KyraEngine::gui_controlsChangeSounds()"); - processMenuButton(button); - - _configSounds = !_configSounds; - gui_setupControls(_menu[5]); - return 0; -} - -int KyraEngine::gui_controlsChangeWalk(Button *button) { - debugC(9, kDebugLevelGUI, "KyraEngine::gui_controlsChangeWalk()"); - processMenuButton(button); - - _configWalkspeed = ++_configWalkspeed % 5; - setWalkspeed(_configWalkspeed); - gui_setupControls(_menu[5]); - return 0; -} - -int KyraEngine::gui_controlsChangeText(Button *button) { - debugC(9, kDebugLevelGUI, "KyraEngine::gui_controlsChangeText()"); - processMenuButton(button); - - _configTextspeed = ++_configTextspeed % 4; - gui_setupControls(_menu[5]); - return 0; -} - -int KyraEngine::gui_controlsChangeVoice(Button *button) { - debugC(9, kDebugLevelGUI, "KyraEngine::gui_controlsChangeVoice()"); - processMenuButton(button); - - _configVoice = ++_configVoice % 3; - gui_setupControls(_menu[5]); - return 0; -} - -int KyraEngine::gui_controlsApply(Button *button) { - debugC(9, kDebugLevelGUI, "KyraEngine::gui_controlsApply()"); - writeSettings(); - return gui_cancelSubMenu(button); -} - -int KyraEngine::gui_scrollUp(Button *button) { - debugC(9, kDebugLevelGUI, "KyraEngine::gui_scrollUp()"); - processMenuButton(button); - - if (_savegameOffset > 0) { - _savegameOffset--; - setupSavegames(_menu[2], 5); - initMenu(_menu[2]); - } - return 0; -} - -int KyraEngine::gui_scrollDown(Button *button) { - debugC(9, kDebugLevelGUI, "KyraEngine::gui_scrollDown()"); - processMenuButton(button); - - _savegameOffset++; - setupSavegames(_menu[2], 5); - initMenu(_menu[2]); - - return 0; -} - -void KyraEngine::gui_processHighlights(Menu &menu) { - int x1, y1, x2, y2; - - Common::Point mouse = getMousePos(); - for (int i = 0; i < menu.nrOfItems; i++) { - if (!menu.item[i].enabled) - continue; - - x1 = menu.x + menu.item[i].x; - y1 = menu.y + menu.item[i].y; - - x2 = x1 + menu.item[i].width; - y2 = y1 + menu.item[i].height; - - if (mouse.x > x1 && mouse.x < x2 && - mouse.y > y1 && mouse.y < y2) { - - if (menu.highlightedItem != i) { - if (menu.item[menu.highlightedItem].enabled ) - gui_redrawText(menu); - - menu.highlightedItem = i; - gui_redrawHighlight(menu); - _screen->updateScreen(); - } - } - } -} - -void KyraEngine::gui_redrawText(Menu menu) { - int textX; - int i = menu.highlightedItem; - - int x1 = menu.x + menu.item[i].x; - int y1 = menu.y + menu.item[i].y; - - int x2 = x1 + menu.item[i].width - 1; - - if (menu.item[i].field_12 != -1 &&_flags.lang == Common::EN_ANY) - textX = x1 + menu.item[i].field_12 + 3; - else - textX = _text->getCenterStringX(menu.item[i].itemString, x1, x2); - - int textY = y1 + 2; - _text->printText(menu.item[i].itemString, textX - 1, textY + 1, 12, 0, 0); - _text->printText(menu.item[i].itemString, textX, textY, menu.item[i].textColor, 0, 0); -} - -void KyraEngine::gui_redrawHighlight(Menu menu) { - int textX; - int i = menu.highlightedItem; - - int x1 = menu.x + menu.item[i].x; - int y1 = menu.y + menu.item[i].y; - - int x2 = x1 + menu.item[i].width - 1; - - if (menu.item[i].field_12 != -1 &&_flags.lang == Common::EN_ANY) - textX = x1 + menu.item[i].field_12 + 3; - else - textX = _text->getCenterStringX(menu.item[i].itemString, x1, x2); - - int textY = y1 + 2; - _text->printText(menu.item[i].itemString, textX - 1, textY + 1, 12, 0, 0); - _text->printText(menu.item[i].itemString, textX, textY, menu.item[i].highlightColor, 0, 0); -} - -void KyraEngine::gui_fadePalette() { - if (_flags.platform == Common::kPlatformAmiga) - return; - - static int16 menuPalIndexes[] = {248, 249, 250, 251, 252, 253, 254, -1}; - int index = 0; - - memcpy(_screen->getPalette(2), _screen->_currentPalette, 768); - - for (int i = 0; i < 768; i++) - _screen->_currentPalette[i] >>= 1; - - while (menuPalIndexes[index] != -1) { - memcpy(&_screen->_currentPalette[menuPalIndexes[index]*3], &_screen->getPalette(2)[menuPalIndexes[index]*3], 3); - index++; - } - - _screen->fadePalette(_screen->_currentPalette, 2); -} - -void KyraEngine::gui_restorePalette() { - if (_flags.platform == Common::kPlatformAmiga) - return; - - memcpy(_screen->_currentPalette, _screen->getPalette(2), 768); - _screen->fadePalette(_screen->_currentPalette, 2); -} - -#pragma mark - - -// Kyra 2 and 3 main menu - -void KyraEngine::gui_updateMainMenuAnimation() { - _screen->updateScreen(); -} - -bool KyraEngine::gui_mainMenuGetInput() { - Common::Event event; - - while (_eventMan->pollEvent(event)) { - switch (event.type) { - case Common::EVENT_QUIT: - quitGame(); - break; - case Common::EVENT_LBUTTONUP: - return true; - default: - break; - } - } - return false; -} - -int KyraEngine::gui_handleMainMenu() { - debugC(9, kDebugLevelMain, "KyraEngine::gui_handleMainMenu()"); - int command = -1; - - uint8 colorMap[16]; - memset(colorMap, 0, sizeof(colorMap)); - _screen->setTextColorMap(colorMap); - - const char * const *strings = &_mainMenuStrings[_lang << 2]; - Screen::FontId oldFont = _screen->setFont(Screen::FID_8_FNT); - int charWidthBackUp = _screen->_charWidth; - - _screen->_charWidth = -2; - _screen->setScreenDim(3); - int backUpX = _screen->_curDim->sx; - int backUpY = _screen->_curDim->sy; - int backUpWidth = _screen->_curDim->w; - int backUpHeight = _screen->_curDim->h; - _screen->copyRegion(backUpX, backUpY, backUpX, backUpY, backUpWidth, backUpHeight, 0, 3); - - int x = _screen->_curDim->sx << 3; - int y = _screen->_curDim->sy; - int width = _screen->_curDim->w << 3; - int height = _screen->_curDim->h; - - gui_drawMainBox(x, y, width, height, 1); - gui_drawMainBox(x + 1, y + 1, width - 2, height - 2, 0); - - int selected = 0; - - gui_drawMainMenu(strings, selected); - - _screen->showMouse(); - - int fh = _screen->getFontHeight(); - int textPos = ((_screen->_curDim->w >> 1) + _screen->_curDim->sx) << 3; - - Common::Rect menuRect(x + 16, y + 4, x + width - 16, y + 4 + fh * 4); - - while (!_quitFlag) { - gui_updateMainMenuAnimation(); - bool mousePressed = gui_mainMenuGetInput(); - - Common::Point mouse = getMousePos(); - if (menuRect.contains(mouse)) { - int item = (mouse.y - menuRect.top) / fh; - - if (item != selected) { - gui_printString(strings[selected], textPos, menuRect.top + selected * fh, 0x80, 0, 5); - gui_printString(strings[item], textPos, menuRect.top + item * fh, 0xFF, 0, 5); - - selected = item; - } - - if (mousePressed) { - // TODO: Flash the text - command = item; - break; - } - } - _system->delayMillis(10); - } - - if (_quitFlag) - command = -1; - - _screen->copyRegion(backUpX, backUpY, backUpX, backUpY, backUpWidth, backUpHeight, 3, 0); - _screen->_charWidth = charWidthBackUp; - _screen->setFont(oldFont); - - return command; -} - -void KyraEngine::gui_drawMainMenu(const char * const *strings, int select) { - debugC(9, kDebugLevelMain, "KyraEngine::gui_drawMainMenu(%p)", (const void*)strings); - static const uint16 menuTable[] = { 0x01, 0x04, 0x0C, 0x04, 0x00, 0x80, 0xFF, 0x00, 0x01, 0x02, 0x03 }; - - int top = _screen->_curDim->sy; - top += menuTable[1]; - - for (int i = 0; i < menuTable[3]; ++i) { - int curY = top + i * _screen->getFontHeight(); - int color = (i == select) ? menuTable[6] : menuTable[5]; - gui_printString(strings[i], ((_screen->_curDim->w >> 1) + _screen->_curDim->sx) << 3, curY, color, 0, 5); - } -} - -void KyraEngine::gui_drawMainBox(int x, int y, int w, int h, int fill) { - debugC(9, kDebugLevelMain, "KyraEngine::gui_drawMainBox(%d, %d, %d, %d, %d)", x, y, w, h, fill); - static const uint8 kyra3ColorTable[] = { 0x16, 0x19, 0x1A, 0x16 }; - static const uint8 kyra2ColorTable[] = { 0x0, 0x19, 0x28, 0xc8 }; - - const uint8 *colorTable; - if (_flags.gameID == GI_KYRA3) - colorTable = kyra3ColorTable; - else - colorTable = kyra2ColorTable; - - --w; --h; - - if (fill) - _screen->fillRect(x, y, x+w, y+h, colorTable[0]); - - _screen->drawClippedLine(x, y+h, x+w, y+h, colorTable[1]); - _screen->drawClippedLine(x+w, y, x+w, y+h, colorTable[1]); - _screen->drawClippedLine(x, y, x+w, y, colorTable[2]); - _screen->drawClippedLine(x, y, x, y+h, colorTable[2]); - - _screen->setPagePixel(_screen->_curPage, x, y+h, colorTable[3]); - _screen->setPagePixel(_screen->_curPage, x+w, y, colorTable[3]); -} - -void KyraEngine::gui_printString(const char *format, int x, int y, int col1, int col2, int flags, ...) { - debugC(9, kDebugLevelMain, "KyraEngine::gui_printString('%s', %d, %d, %d, %d, %d, ...)", format, x, y, col1, col2, flags); - if (!format) - return; - - char string[512]; - va_list vaList; - va_start(vaList, flags); - vsprintf(string, format, vaList); - va_end(vaList); - - if (flags & 1) - x -= _screen->getTextWidth(string) >> 1; - - if (flags & 2) - x -= _screen->getTextWidth(string); - - if (flags & 4) { - _screen->printText(string, x - 1, y, 240, col2); - _screen->printText(string, x, y + 1, 240, col2); - } - - if (flags & 8) { - _screen->printText(string, x - 1, y, 227, col2); - _screen->printText(string, x, y + 1, 227, col2); - } - - _screen->printText(string, x, y, col1, col2); -} - -} // end of namespace Kyra - diff --git a/engines/kyra/gui_v1.cpp b/engines/kyra/gui_v1.cpp new file mode 100644 index 0000000000..fe051dd75c --- /dev/null +++ b/engines/kyra/gui_v1.cpp @@ -0,0 +1,1640 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include "kyra/kyra.h" +#include "kyra/screen.h" +#include "kyra/script.h" +#include "kyra/text.h" +#include "kyra/animator.h" +#include "kyra/sound.h" + +#include "common/config-manager.h" +#include "common/savefile.h" +#include "common/events.h" +#include "common/system.h" + +namespace Kyra { + +void KyraEngine::registerDefaultSettings() { + // Most settings already have sensible defaults. This one, however, is + // specific to the Kyra engine. + ConfMan.registerDefault("walkspeed", 2); + ConfMan.registerDefault("cdaudio", _flags.platform == Common::kPlatformFMTowns); +} + +void KyraEngine::readSettings() { + int talkspeed = ConfMan.getInt("talkspeed"); + + // The default talk speed is 60. This should be mapped to "Normal". + + if (talkspeed == 0) + _configTextspeed = 3; // Clickable + if (talkspeed <= 50) + _configTextspeed = 0; // Slow + else if (talkspeed <= 150) + _configTextspeed = 1; // Normal + else + _configTextspeed = 2; // Fast + + _configWalkspeed = ConfMan.getInt("walkspeed"); + _configMusic = ConfMan.getBool("music_mute") ? 0 : ((ConfMan.getBool("cdaudio") && _flags.platform == Common::kPlatformFMTowns) ? 2 : 1); + _configSounds = ConfMan.getBool("sfx_mute") ? 0 : 1; + + _sound->enableMusic(_configMusic); + _sound->enableSFX(_configSounds); + + bool speechMute = ConfMan.getBool("speech_mute"); + bool subtitles = ConfMan.getBool("subtitles"); + + if (!speechMute && subtitles) + _configVoice = 2; // Voice & Text + else if (!speechMute && !subtitles) + _configVoice = 1; // Voice only + else + _configVoice = 0; // Text only + + setWalkspeed(_configWalkspeed); +} + +void KyraEngine::writeSettings() { + bool speechMute, subtitles; + int talkspeed; + + switch (_configTextspeed) { + case 0: // Slow + talkspeed = 1; + break; + case 1: // Normal + talkspeed = 60; + break; + case 2: // Fast + talkspeed = 255; + break; + default: // Clickable + talkspeed = 0; + break; + } + + ConfMan.setInt("talkspeed", talkspeed); + ConfMan.setInt("walkspeed", _configWalkspeed); + ConfMan.setBool("music_mute", _configMusic == 0); + ConfMan.setBool("cdaudio", _configMusic == 2); + ConfMan.setBool("sfx_mute", _configSounds == 0); + + switch (_configVoice) { + case 0: // Text only + speechMute = true; + subtitles = true; + break; + case 1: // Voice only + speechMute = false; + subtitles = false; + break; + default: // Voice & Text + speechMute = false; + subtitles = true; + break; + } + + if (!_configMusic) + _sound->beginFadeOut(); + + _sound->enableMusic(_configMusic); + _sound->enableSFX(_configSounds); + + ConfMan.setBool("speech_mute", speechMute); + ConfMan.setBool("subtitles", subtitles); + + ConfMan.flushToDisk(); +} + +void KyraEngine::initMainButtonList() { + _haveScrollButtons = false; + _buttonList = &_buttonData[0]; + for (int i = 0; _buttonDataListPtr[i]; ++i) + _buttonList = initButton(_buttonList, _buttonDataListPtr[i]); +} + +Button *KyraEngine::initButton(Button *list, Button *newButton) { + if (!newButton) + return list; + if (!list) + return newButton; + Button *cur = list; + + while (true) { + if (!cur->nextButton) + break; + cur = cur->nextButton; + } + + cur->nextButton = newButton; + return list; +} + +int KyraEngine::buttonInventoryCallback(Button *caller) { + int itemOffset = caller->specialValue - 2; + uint8 inventoryItem = _currentCharacter->inventoryItems[itemOffset]; + if (_itemInHand == -1) { + if (inventoryItem == 0xFF) { + snd_playSoundEffect(0x36); + return 0; + } else { + _screen->hideMouse(); + _screen->fillRect(_itemPosX[itemOffset], _itemPosY[itemOffset], _itemPosX[itemOffset] + 15, _itemPosY[itemOffset] + 15, 12); + snd_playSoundEffect(0x35); + setMouseItem(inventoryItem); + updateSentenceCommand(_itemList[inventoryItem], _takenList[0], 179); + _itemInHand = inventoryItem; + _screen->showMouse(); + _currentCharacter->inventoryItems[itemOffset] = 0xFF; + } + } else { + if (inventoryItem != 0xFF) { + snd_playSoundEffect(0x35); + _screen->hideMouse(); + _screen->fillRect(_itemPosX[itemOffset], _itemPosY[itemOffset], _itemPosX[itemOffset] + 15, _itemPosY[itemOffset] + 15, 12); + _screen->drawShape(0, _shapes[216+_itemInHand], _itemPosX[itemOffset], _itemPosY[itemOffset], 0, 0); + setMouseItem(inventoryItem); + updateSentenceCommand(_itemList[inventoryItem], _takenList[1], 179); + _screen->showMouse(); + _currentCharacter->inventoryItems[itemOffset] = _itemInHand; + _itemInHand = inventoryItem; + } else { + snd_playSoundEffect(0x32); + _screen->hideMouse(); + _screen->drawShape(0, _shapes[216+_itemInHand], _itemPosX[itemOffset], _itemPosY[itemOffset], 0, 0); + _screen->setMouseCursor(1, 1, _shapes[0]); + updateSentenceCommand(_itemList[_itemInHand], _placedList[0], 179); + _screen->showMouse(); + _currentCharacter->inventoryItems[itemOffset] = _itemInHand; + _itemInHand = -1; + } + } + _screen->updateScreen(); + // XXX clearKyrandiaButtonIO + return 0; +} + +int KyraEngine::buttonAmuletCallback(Button *caller) { + if (!(_deathHandler & 8)) + return 1; + int jewel = caller->specialValue - 0x14; + if (_currentCharacter->sceneId == 210) { + if (_beadStateVar == 4 || _beadStateVar == 6) + return 1; + } + if (!queryGameFlag(0x2D)) + return 1; + if (_itemInHand != -1) { + assert(_putDownFirst); + characterSays(2000, _putDownFirst[0], 0, -2); + return 1; + } + if (queryGameFlag(0xF1)) { + assert(_waitForAmulet); + characterSays(2001, _waitForAmulet[0], 0, -2); + return 1; + } + if (!queryGameFlag(0x55+jewel)) { + assert(_blackJewel); + _animator->makeBrandonFaceMouse(); + drawJewelPress(jewel, 1); + characterSays(2002, _blackJewel[0], 0, -2); + return 1; + } + drawJewelPress(jewel, 0); + drawJewelsFadeOutStart(); + drawJewelsFadeOutEnd(jewel); + + _scriptInterpreter->initScript(_scriptClick, _scriptClickData); + _scriptClick->regs[3] = 0; + _scriptClick->regs[6] = jewel; + _scriptInterpreter->startScript(_scriptClick, 4); + + while (_scriptInterpreter->validScript(_scriptClick)) + _scriptInterpreter->runScript(_scriptClick); + + if (_scriptClick->regs[3]) + return 1; + + _unkAmuletVar = 1; + switch (jewel-1) { + case 0: + if (_brandonStatusBit & 1) { + seq_brandonHealing2(); + } else if (_brandonStatusBit == 0) { + seq_brandonHealing(); + assert(_healingTip); + characterSays(2003, _healingTip[0], 0, -2); + } + break; + + case 1: + seq_makeBrandonInv(); + break; + + case 2: + if (_brandonStatusBit & 1) { + assert(_wispJewelStrings); + characterSays(2004, _wispJewelStrings[0], 0, -2); + } else { + if (_brandonStatusBit & 2) { + // XXX + seq_makeBrandonNormal2(); + // XXX + } else { + // do not check for item in hand again as in the original since some strings are missing + // in the cd version + if (_currentCharacter->sceneId >= 109 && _currentCharacter->sceneId <= 198) { + snd_playWanderScoreViaMap(1, 0); + seq_makeBrandonWisp(); + snd_playWanderScoreViaMap(17, 0); + } else { + seq_makeBrandonWisp(); + } + setGameFlag(0x9E); + } + } + break; + + case 3: + seq_dispelMagicAnimation(); + assert(_magicJewelString); + characterSays(2007, _magicJewelString[0], 0, -2); + break; + + default: + break; + } + _unkAmuletVar = 0; + // XXX clearKyrandiaButtonIO (!used before every return in this function!) + return 1; +} + +void KyraEngine::processButtonList(Button *list) { + if (_haveScrollButtons) { + if (_mouseWheel < 0) + gui_scrollUp(&_scrollUpButton); + else if (_mouseWheel > 0) + gui_scrollDown(&_scrollDownButton); + } + while (list) { + if (list->flags & 8) { + list = list->nextButton; + continue; + } + + int x = list->x; + int y = list->y; + assert(list->dimTableIndex < _screen->_screenDimTableCount); + if (x < 0) { + x += _screen->_screenDimTable[list->dimTableIndex].w << 3; + } + x += _screen->_screenDimTable[list->dimTableIndex].sx << 3; + + if (y < 0) { + y += _screen->_screenDimTable[list->dimTableIndex].h; + } + y += _screen->_screenDimTable[list->dimTableIndex].sy; + + Common::Point mouse = getMousePos(); + if (mouse.x >= x && mouse.y >= y && x + list->width >= mouse.x && y + list->height >= mouse.y) { + int processMouseClick = 0; + if (list->flags & 0x400) { + if (_mousePressFlag) { + if (!(list->flags2 & 1)) { + list->flags2 |= 1; + list->flags2 |= 4; + processButton(list); + _screen->updateScreen(); + } + } else { + if (list->flags2 & 1) { + list->flags2 &= 0xFFFE; + processButton(list); + processMouseClick = 1; + } + } + } else if (_mousePressFlag) { + processMouseClick = 1; + } + + if (processMouseClick) { + if (list->buttonCallback) { + if ((this->*(list->buttonCallback))(list)) { + break; + } + } + } + } else { + if (list->flags2 & 1) { + list->flags2 &= 0xFFFE; + processButton(list); + } + if (list->flags2 & 4) { + list->flags2 &= 0xFFFB; + processButton(list); + _screen->updateScreen(); + } + list = list->nextButton; + continue; + } + + list = list->nextButton; + } +} + +void KyraEngine::processButton(Button *button) { + if (!button) + return; + + int processType = 0; + uint8 *shape = 0; + Button::ButtonCallback callback = 0; + + int flags = (button->flags2 & 5); + if (flags == 1) { + processType = button->process2; + if (processType == 1) + shape = button->process2PtrShape; + else if (processType == 4) + callback = button->process2PtrCallback; + } else if (flags == 4 || flags == 5) { + processType = button->process1; + if (processType == 1) + shape = button->process1PtrShape; + else if (processType == 4) + callback = button->process1PtrCallback; + } else { + processType = button->process0; + if (processType == 1) + shape = button->process0PtrShape; + else if (processType == 4) + callback = button->process0PtrCallback; + } + + int x = button->x; + int y = button->y; + assert(button->dimTableIndex < _screen->_screenDimTableCount); + if (x < 0) + x += _screen->_screenDimTable[button->dimTableIndex].w << 3; + + if (y < 0) + y += _screen->_screenDimTable[button->dimTableIndex].h; + + if (processType == 1 && shape) + _screen->drawShape(_screen->_curPage, shape, x, y, button->dimTableIndex, 0x10); + else if (processType == 4 && callback) + (this->*callback)(button); +} + +void KyraEngine::processAllMenuButtons() { + if (!_menuButtonList) + return; + + Button *cur = _menuButtonList; + while (true) { + if (!cur->nextButton) + break; + processMenuButton(cur); + cur = cur->nextButton; + } + return; +} + +void KyraEngine::processMenuButton(Button *button) { + if (!_displayMenu) + return; + + if (!button || (button->flags & 8)) + return; + + if (button->flags2 & 1) + button->flags2 &= 0xf7; + else + button->flags2 |= 8; + + button->flags2 &= 0xfc; + + if (button->flags2 & 4) + button->flags2 |= 0x10; + else + button->flags2 &= 0xef; + + button->flags2 &= 0xfb; + + processButton(button); +} + +int KyraEngine::drawBoxCallback(Button *button) { + if (!_displayMenu) + return 0; + + _screen->hideMouse(); + _screen->drawBox(button->x + 1, button->y + 1, button->x + button->width - 1, button->y + button->height - 1, 0xf8); + _screen->showMouse(); + + return 0; +} + +int KyraEngine::drawShadedBoxCallback(Button *button) { + if (!_displayMenu) + return 0; + + _screen->hideMouse(); + _screen->drawShadedBox(button->x, button->y, button->x + button->width, button->y + button->height, 0xf9, 0xfa); + _screen->showMouse(); + + return 0; +} + +void KyraEngine::setGUILabels() { + int offset = 0; + int offsetOptions = 0; + int offsetMainMenu = 0; + int offsetOn = 0; + + int walkspeedGarbageOffset = 36; + int menuLabelGarbageOffset = 0; + + if (_flags.isTalkie) { + if (_flags.lang == Common::EN_ANY) + offset = 52; + else if (_flags.lang == Common::DE_DEU) + offset = 30; + else if (_flags.lang == Common::FR_FRA || _flags.lang == Common::IT_ITA) + offset = 6; + offsetOn = offsetMainMenu = offsetOptions = offset; + walkspeedGarbageOffset = 48; + } else if (_flags.lang == Common::ES_ESP) { + offsetOn = offsetMainMenu = offsetOptions = offset = -4; + menuLabelGarbageOffset = 72; + } else if (_flags.lang == Common::DE_DEU) { + offset = offsetMainMenu = offsetOn = offsetOptions = 24; + } else if (_flags.platform == Common::kPlatformFMTowns) { + offset = 1; + offsetOptions = 10; + offsetOn = 0; + walkspeedGarbageOffset = 0; + } + + assert(offset + 27 < _guiStringsSize); + + // The Legend of Kyrandia + _menu[0].menuName = _guiStrings[0]; + // Load a Game + _menu[0].item[0].itemString = _guiStrings[1]; + // Save a Game + _menu[0].item[1].itemString = _guiStrings[2]; + // Game controls + _menu[0].item[2].itemString = _guiStrings[3]; + // Quit playing + _menu[0].item[3].itemString = _guiStrings[4]; + // Resume game + _menu[0].item[4].itemString = _guiStrings[5]; + + // Cancel + _menu[2].item[5].itemString = _guiStrings[10]; + + // Enter a description of your saved game: + _menu[3].menuName = _guiStrings[11]; + // Save + _menu[3].item[0].itemString = _guiStrings[12]; + // Cancel + _menu[3].item[1].itemString = _guiStrings[10]; + + // Rest in peace, Brandon + _menu[4].menuName = _guiStrings[13]; + // Load a game + _menu[4].item[0].itemString = _guiStrings[1]; + // Quit playing + _menu[4].item[1].itemString = _guiStrings[4]; + + // Game Controls + _menu[5].menuName = _guiStrings[6]; + // Yes + _menu[1].item[0].itemString = _guiStrings[22 + offset]; + // No + _menu[1].item[1].itemString = _guiStrings[23 + offset]; + + // Music is + _menu[5].item[0].labelString = _guiStrings[26 + offsetOptions]; + // Sounds are + _menu[5].item[1].labelString = _guiStrings[27 + offsetOptions]; + // Walk speed + _menu[5].item[2].labelString = &_guiStrings[24 + offsetOptions][walkspeedGarbageOffset]; + // Text speed + _menu[5].item[4].labelString = _guiStrings[25 + offsetOptions]; + // Main Menu + _menu[5].item[5].itemString = &_guiStrings[19 + offsetMainMenu][menuLabelGarbageOffset]; + + if (_flags.isTalkie) + // Text & Voice + _voiceTextString = _guiStrings[28 + offset]; + + _textSpeedString = _guiStrings[25 + offsetOptions]; + _onString = _guiStrings[20 + offsetOn]; + _offString = _guiStrings[21 + offset]; + _onCDString = _guiStrings[21]; +} + +int KyraEngine::buttonMenuCallback(Button *caller) { + _displayMenu = true; + + assert(_guiStrings); + assert(_configStrings); + + /* + for (int i = 0; i < _guiStringsSize; i++) + debug("GUI string %i: %s", i, _guiStrings[i]); + + for (int i = 0; i < _configStringsSize; i++) + debug("Config string %i: %s", i, _configStrings[i]); + */ + + setGUILabels(); + if (_currentCharacter->sceneId == 210 && _deathHandler == 0xFF) { + snd_playSoundEffect(0x36); + return 0; + } + // XXX + _screen->setPaletteIndex(0xFE, 60, 60, 0); + for (int i = 0; i < 6; i++) { + _menuButtonData[i].process0 = _menuButtonData[i].process1 = _menuButtonData[i].process2 = 4; + _menuButtonData[i].process0PtrCallback = &KyraEngine::drawShadedBoxCallback; + _menuButtonData[i].process1PtrCallback = &KyraEngine::drawBoxCallback; + _menuButtonData[i].process2PtrCallback = &KyraEngine::drawShadedBoxCallback; + } + + _screen->savePageToDisk("SEENPAGE.TMP", 0); + gui_fadePalette(); + + for (int i = 0; i < 5; i++) + calcCoords(_menu[i]); + + _menuRestoreScreen = true; + _keyPressed.reset(); + _mousePressFlag = false; + + _toplevelMenu = 0; + if (_menuDirectlyToLoad) { + gui_loadGameMenu(0); + } else { + if (!caller) + _toplevelMenu = 4; + + initMenu(_menu[_toplevelMenu]); + processAllMenuButtons(); + } + + while (_displayMenu && !_quitFlag) { + gui_processHighlights(_menu[_toplevelMenu]); + processButtonList(_menuButtonList); + gui_getInput(); + } + + if (_menuRestoreScreen) { + gui_restorePalette(); + _screen->loadPageFromDisk("SEENPAGE.TMP", 0); + _animator->_updateScreen = true; + } else { + _screen->deletePageFromDisk(0); + } + + return 0; +} + +void KyraEngine::initMenu(Menu &menu) { + _menuButtonList = 0; + + _screen->hideMouse(); + + int textX; + int textY; + + int menu_x2 = menu.width + menu.x - 1; + int menu_y2 = menu.height + menu.y - 1; + + _screen->fillRect(menu.x + 2, menu.y + 2, menu_x2 - 2, menu_y2 - 2, menu.bgcolor); + _screen->drawShadedBox(menu.x, menu.y, menu_x2, menu_y2, menu.color1, menu.color2); + + if (menu.field_10 != -1) + textX = menu.x; + else + textX = _text->getCenterStringX(menu.menuName, menu.x, menu_x2); + + textY = menu.y + menu.field_12; + + _text->printText(menu.menuName, textX - 1, textY + 1, 12, 248, 0); + _text->printText(menu.menuName, textX, textY, menu.textColor, 0, 0); + + int x1, y1, x2, y2; + for (int i = 0; i < menu.nrOfItems; i++) { + if (!menu.item[i].enabled) + continue; + + x1 = menu.x + menu.item[i].x; + y1 = menu.y + menu.item[i].y; + + x2 = x1 + menu.item[i].width - 1; + y2 = y1 + menu.item[i].height - 1; + + if (i < 6) { + _menuButtonData[i].nextButton = 0; + _menuButtonData[i].x = x1; + _menuButtonData[i].y = y1; + _menuButtonData[i].width = menu.item[i].width - 1; + _menuButtonData[i].height = menu.item[i].height - 1; + _menuButtonData[i].buttonCallback = menu.item[i].callback; + _menuButtonData[i].specialValue = menu.item[i].field_1b; + //_menuButtonData[i].field_6 = menu.item[i].field_25; + //_menuButtonData[i].field_8 = 0; + + if (!_menuButtonList) + _menuButtonList = &_menuButtonData[i]; + else + _menuButtonList = initButton(_menuButtonList, &_menuButtonData[i]); + } + _screen->fillRect(x1, y1, x2, y2, menu.item[i].bgcolor); + _screen->drawShadedBox(x1, y1, x2, y2, menu.item[i].color1, menu.item[i].color2); + + if (menu.item[i].itemString) { + if (menu.item[i].field_12 != -1 && _flags.lang == Common::EN_ANY) + textX = x1 + menu.item[i].field_12 + 3; + else + textX = _text->getCenterStringX(menu.item[i].itemString, x1, x2); + + textY = y1 + 2; + _text->printText(menu.item[i].itemString, textX - 1, textY + 1, 12, 0, 0); + + if (i == menu.highlightedItem) + _text->printText(menu.item[i].itemString, textX, textY, menu.item[i].highlightColor, 0, 0); + else + _text->printText(menu.item[i].itemString, textX, textY, menu.item[i].textColor, 0, 0); + + if (menu.item[i].labelString) { + _text->printText(menu.item[i].labelString, menu.x + menu.item[i].labelX - 1, menu.y + menu.item[i].labelY + 1, 12, 0, 0); + _text->printText(menu.item[i].labelString, menu.x + menu.item[i].labelX, menu.y + menu.item[i].labelY, 253, 0, 0); + } + } + } + + if (menu.scrollUpBtnX != -1) { + _haveScrollButtons = true; + + _scrollUpButton.x = menu.scrollUpBtnX + menu.x; + _scrollUpButton.y = menu.scrollUpBtnY + menu.y; + _scrollUpButton.buttonCallback = &KyraEngine::gui_scrollUp; + _scrollUpButton.nextButton = 0; + _menuButtonList = initButton(_menuButtonList, &_scrollUpButton); + processMenuButton(&_scrollUpButton); + + _scrollDownButton.x = menu.scrollDownBtnX + menu.x; + _scrollDownButton.y = menu.scrollDownBtnY + menu.y; + _scrollDownButton.buttonCallback = &KyraEngine::gui_scrollDown; + _scrollDownButton.nextButton = 0; + _menuButtonList = initButton(_menuButtonList, &_scrollDownButton); + processMenuButton(&_scrollDownButton); + } else { + _haveScrollButtons = false; + } + + _screen->showMouse(); + _screen->updateScreen(); +} + +void KyraEngine::calcCoords(Menu &menu) { + assert(menu.nrOfItems < 7); + + int widthBackup = _screen->_charWidth; + _screen->_charWidth = -2; + + menu.x = (320 - menu.width)/2; + + int menu_x2 = menu.width + menu.x - 1; + int maxOffset = 0; + int x1, x2, y1, y2; + + for (int i = 0; i < menu.nrOfItems; i++) { + if (menu.item[i].x == -1) + menu.item[i].x = (menu.width - menu.item[i].width)/2; + + if (menu.item[i].labelString) { + x1 = menu.x + menu.item[i].x + 25; + y1 = (200 - menu.height)/2 + menu.item[i].y; + + x2 = x1 + menu.item[i].width; + y2 = y1 + menu.item[i].height; + + int textWidth = _screen->getTextWidth(menu.item[i].labelString) + 25; + int textX = menu.item[i].labelX + menu.x; + + if (textWidth + textX > x1) { + int offset = ((textWidth + textX) - x1); + if (maxOffset < offset) + maxOffset = offset; + } + } + + if (menu.item[i].itemString) { + int textWidth = _screen->getTextWidth(menu.item[i].itemString) + 15; + + if (menu.item[i].width < textWidth) { + menu.item[i].width = textWidth; + + if ( menu.x + menu.item[i].x + menu.item[i].width > menu_x2) + menu.item[i].x -= (menu.x + menu.item[i].x + menu.item[i].width) - menu_x2 + 10; + } + } + + } + + if (maxOffset > 0) { + maxOffset = maxOffset/2; + for (int i = 0; i < menu.nrOfItems; i++) { + menu.item[i].x += maxOffset + 10; + menu.item[i].labelX -= maxOffset; + } + menu.width += maxOffset; + } + + if (menu.menuName != 0) { + int menuNameLength = _screen->getTextWidth(menu.menuName); + if (menuNameLength > menu.width) + menu.width = menuNameLength; + } + + if (menu.width > 310) + menu.width = 310; + + menu.x = (320 - menu.width)/2; + + if (menu.y == -1) + menu.y = (200 - menu.height)/2; + + _screen->_charWidth = widthBackup; +} + +void KyraEngine::gui_getInput() { + Common::Event event; + static uint32 lastScreenUpdate = 0; + uint32 now = _system->getMillis(); + + _mouseWheel = 0; + while (_eventMan->pollEvent(event)) { + switch (event.type) { + case Common::EVENT_QUIT: + quitGame(); + break; + case Common::EVENT_LBUTTONDOWN: + _mousePressFlag = true; + break; + case Common::EVENT_LBUTTONUP: + _mousePressFlag = false; + break; + case Common::EVENT_MOUSEMOVE: + _system->updateScreen(); + lastScreenUpdate = now; + break; + case Common::EVENT_WHEELUP: + _mouseWheel = -1; + break; + case Common::EVENT_WHEELDOWN: + _mouseWheel = 1; + break; + case Common::EVENT_KEYDOWN: + _keyPressed = event.kbd; + break; + default: + break; + } + } + + if (now - lastScreenUpdate > 50) { + _system->updateScreen(); + lastScreenUpdate = now; + } + + _system->delayMillis(3); +} + +int KyraEngine::gui_resumeGame(Button *button) { + debugC(9, kDebugLevelGUI, "KyraEngine::gui_resumeGame()"); + processMenuButton(button); + _displayMenu = false; + + return 0; +} + +const char *KyraEngine::getSavegameFilename(int num) { + static char saveLoadSlot[12]; + + sprintf(saveLoadSlot, "%s.%.3d", _targetName.c_str(), num); + return saveLoadSlot; +} + +int KyraEngine::getNextSavegameSlot() { + Common::InSaveFile *in; + + for (int i = 1; i < 1000; i++) { + if ((in = _saveFileMan->openForLoading(getSavegameFilename(i)))) + delete in; + else + return i; + } + warning("Didn't save: Ran out of savegame filenames"); + return 0; +} + +void KyraEngine::setupSavegames(Menu &menu, int num) { + Common::InSaveFile *in; + static char savenames[5][31]; + uint8 startSlot; + assert(num <= 5); + + if (_savegameOffset == 0) { + menu.item[0].itemString = _specialSavegameString; + menu.item[0].enabled = 1; + menu.item[0].field_1b = 0; + startSlot = 1; + } else { + startSlot = 0; + } + + for (int i = startSlot; i < num; i++) { + if ((in = _saveFileMan->openForLoading(getSavegameFilename(i + _savegameOffset)))) { + in->skip(8); + in->read(savenames[i], 31); + menu.item[i].itemString = savenames[i]; + menu.item[i].enabled = 1; + menu.item[i].field_1b = i + _savegameOffset; + delete in; + } else { + menu.item[i].enabled = 0; + //menu.item[i].itemString = ""; + //menu.item[i].field_1b = -1; + } + } +} + +int KyraEngine::gui_saveGameMenu(Button *button) { + debugC(9, kDebugLevelGUI, "KyraEngine::gui_saveGameMenu()"); + processMenuButton(button); + _menu[2].item[5].enabled = true; + + _screen->loadPageFromDisk("SEENPAGE.TMP", 0); + _screen->savePageToDisk("SEENPAGE.TMP", 0); + + _menu[2].menuName = _guiStrings[8]; // Select a position to save to: + _specialSavegameString = _guiStrings[9]; // [ EMPTY SLOT ] + for (int i = 0; i < 5; i++) + _menu[2].item[i].callback = &KyraEngine::gui_saveGame; + + _savegameOffset = 0; + setupSavegames(_menu[2], 5); + + initMenu(_menu[2]); + processAllMenuButtons(); + + _displaySubMenu = true; + _cancelSubMenu = false; + + while (_displaySubMenu && !_quitFlag) { + gui_getInput(); + gui_processHighlights(_menu[2]); + processButtonList(_menuButtonList); + } + + _screen->loadPageFromDisk("SEENPAGE.TMP", 0); + _screen->savePageToDisk("SEENPAGE.TMP", 0); + + if (_cancelSubMenu) { + initMenu(_menu[0]); + processAllMenuButtons(); + } else { + _displayMenu = false; + } + return 0; +} + +int KyraEngine::gui_loadGameMenu(Button *button) { + debugC(9, kDebugLevelGUI, "KyraEngine::gui_loadGameMenu()"); + if (_menuDirectlyToLoad) { + _menu[2].item[5].enabled = false; + } else { + processMenuButton(button); + _menu[2].item[5].enabled = true; + } + + _screen->loadPageFromDisk("SEENPAGE.TMP", 0); + _screen->savePageToDisk("SEENPAGE.TMP", 0); + + _specialSavegameString = _newGameString[0]; //[ START A NEW GAME ] + _menu[2].menuName = _guiStrings[7]; // Which game would you like to reload? + for (int i = 0; i < 5; i++) + _menu[2].item[i].callback = &KyraEngine::gui_loadGame; + + _savegameOffset = 0; + setupSavegames(_menu[2], 5); + + initMenu(_menu[2]); + processAllMenuButtons(); + + _displaySubMenu = true; + _cancelSubMenu = false; + + while (_displaySubMenu && !_quitFlag) { + gui_getInput(); + gui_processHighlights(_menu[2]); + processButtonList(_menuButtonList); + } + + _screen->loadPageFromDisk("SEENPAGE.TMP", 0); + _screen->savePageToDisk("SEENPAGE.TMP", 0); + + if (_cancelSubMenu) { + initMenu(_menu[_toplevelMenu]); + processAllMenuButtons(); + } else { + gui_restorePalette(); + loadGame(getSavegameFilename(_gameToLoad)); + _displayMenu = false; + _menuRestoreScreen = false; + } + return 0; +} + +void KyraEngine::gui_redrawTextfield() { + _screen->fillRect(38, 91, 287, 102, 250); + _text->printText(_savegameName, 38, 92, 253, 0, 0); + + _screen->_charWidth = -2; + int width = _screen->getTextWidth(_savegameName); + _screen->fillRect(39 + width, 93, 45 + width, 100, 254); + _screen->_charWidth = 0; + + _screen->updateScreen(); +} + +void KyraEngine::gui_updateSavegameString() { + int length; + + if (_keyPressed.keycode) { + length = strlen(_savegameName); + + if (_keyPressed.ascii > 31 && _keyPressed.ascii < 127) { + if (length < 31) { + _savegameName[length] = _keyPressed.ascii; + _savegameName[length+1] = 0; + gui_redrawTextfield(); + } + } else if (_keyPressed.keycode == Common::KEYCODE_BACKSPACE || + _keyPressed.keycode == Common::KEYCODE_DELETE) { + if (length > 0) { + _savegameName[length-1] = 0; + gui_redrawTextfield(); + } + } else if (_keyPressed.keycode == Common::KEYCODE_RETURN || + _keyPressed.keycode == Common::KEYCODE_KP_ENTER) { + _displaySubMenu = false; + } + } + + _keyPressed.reset(); +} + +int KyraEngine::gui_saveGame(Button *button) { + debugC(9, kDebugLevelGUI, "KyraEngine::gui_saveGame()"); + processMenuButton(button); + _gameToLoad = button->specialValue; + + _screen->loadPageFromDisk("SEENPAGE.TMP", 0); + _screen->savePageToDisk("SEENPAGE.TMP", 0); + + initMenu(_menu[3]); + processAllMenuButtons(); + + _displaySubMenu = true; + _cancelSubMenu = false; + + if (_savegameOffset == 0 && _gameToLoad == 0) { + _savegameName[0] = 0; + } else { + for (int i = 0; i < 5; i++) { + if (_menu[2].item[i].field_1b == _gameToLoad) { + strncpy(_savegameName, _menu[2].item[i].itemString, 31); + break; + } + } + } + gui_redrawTextfield(); + + while (_displaySubMenu && !_quitFlag) { + gui_getInput(); + gui_updateSavegameString(); + gui_processHighlights(_menu[3]); + processButtonList(_menuButtonList); + } + + if (_cancelSubMenu) { + _displaySubMenu = true; + _cancelSubMenu = false; + initMenu(_menu[2]); + processAllMenuButtons(); + } else { + if (_savegameOffset == 0 && _gameToLoad == 0) + _gameToLoad = getNextSavegameSlot(); + if (_gameToLoad > 0) + saveGame(getSavegameFilename(_gameToLoad), _savegameName); + } + + return 0; +} + +int KyraEngine::gui_savegameConfirm(Button *button) { + debugC(9, kDebugLevelGUI, "KyraEngine::gui_savegameConfirm()"); + processMenuButton(button); + _displaySubMenu = false; + + return 0; +} + +int KyraEngine::gui_loadGame(Button *button) { + debugC(9, kDebugLevelGUI, "KyraEngine::gui_loadGame()"); + processMenuButton(button); + _displaySubMenu = false; + _gameToLoad = button->specialValue; + + return 0; +} + +int KyraEngine::gui_cancelSubMenu(Button *button) { + debugC(9, kDebugLevelGUI, "KyraEngine::gui_cancelLoadGameMenu()"); + processMenuButton(button); + _displaySubMenu = false; + _cancelSubMenu = true; + + return 0; +} + +int KyraEngine::gui_quitPlaying(Button *button) { + debugC(9, kDebugLevelGUI, "KyraEngine::gui_quitPlaying()"); + processMenuButton(button); + + if (gui_quitConfirm(_guiStrings[14])) { // Are you sure you want to quit playing? + quitGame(); + } else { + initMenu(_menu[_toplevelMenu]); + processAllMenuButtons(); + } + + return 0; +} + +bool KyraEngine::gui_quitConfirm(const char *str) { + debugC(9, kDebugLevelGUI, "KyraEngine::gui_quitConfirm()"); + + _screen->loadPageFromDisk("SEENPAGE.TMP", 0); + _screen->savePageToDisk("SEENPAGE.TMP", 0); + + _menu[1].menuName = str; + calcCoords(_menu[1]); + initMenu(_menu[1]); + + _displaySubMenu = true; + _cancelSubMenu = true; + + while (_displaySubMenu && !_quitFlag) { + gui_getInput(); + gui_processHighlights(_menu[1]); + processButtonList(_menuButtonList); + } + + _screen->loadPageFromDisk("SEENPAGE.TMP", 0); + _screen->savePageToDisk("SEENPAGE.TMP", 0); + + return !_cancelSubMenu; +} + +int KyraEngine::gui_quitConfirmYes(Button *button) { + debugC(9, kDebugLevelGUI, "KyraEngine::gui_quitConfirmYes()"); + processMenuButton(button); + _displaySubMenu = false; + _cancelSubMenu = false; + + return 0; +} + +int KyraEngine::gui_quitConfirmNo(Button *button) { + debugC(9, kDebugLevelGUI, "KyraEngine::gui_quitConfirmNo()"); + processMenuButton(button); + _displaySubMenu = false; + _cancelSubMenu = true; + + return 0; +} + +int KyraEngine::gui_gameControlsMenu(Button *button) { + debugC(9, kDebugLevelGUI, "KyraEngine::gui_gameControlsMenu()"); + + readSettings(); + + _screen->loadPageFromDisk("SEENPAGE.TMP", 0); + _screen->savePageToDisk("SEENPAGE.TMP", 0); + + if (_flags.isTalkie) { + //_menu[5].width = 230; + + for (int i = 0; i < 5; i++) { + //_menu[5].item[i].labelX = 24; + //_menu[5].item[i].x = 115; + //_menu[5].item[i].width = 94; + } + + _menu[5].item[3].labelString = _voiceTextString; //"Voice / Text " + _menu[5].item[3].callback = &KyraEngine::gui_controlsChangeVoice; + + } else { + //_menu[5].height = 136; + //_menu[5].item[5].y = 110; + _menu[5].item[4].enabled = 0; + _menu[5].item[3].labelString = _textSpeedString; // "Text speed " + _menu[5].item[3].callback = &KyraEngine::gui_controlsChangeText; + } + + gui_setupControls(_menu[5]); + + processAllMenuButtons(); + + _displaySubMenu = true; + _cancelSubMenu = false; + + while (_displaySubMenu && !_quitFlag) { + gui_getInput(); + gui_processHighlights(_menu[5]); + processButtonList(_menuButtonList); + } + + _screen->loadPageFromDisk("SEENPAGE.TMP", 0); + _screen->savePageToDisk("SEENPAGE.TMP", 0); + + if (_cancelSubMenu) { + initMenu(_menu[_toplevelMenu]); + processAllMenuButtons(); + } + return 0; +} + +void KyraEngine::gui_setupControls(Menu &menu) { + debugC(9, kDebugLevelGUI, "KyraEngine::gui_setupControls()"); + + switch (_configMusic) { + case 0: + menu.item[0].itemString = _offString; //"Off" + break; + case 1: + menu.item[0].itemString = _onString; //"On" + break; + case 2: + menu.item[0].itemString = _onCDString; //"On + CD" + break; + } + + if (_configSounds) + menu.item[1].itemString = _onString; //"On" + else + menu.item[1].itemString = _offString; //"Off" + + + switch (_configWalkspeed) { + case 0: + menu.item[2].itemString = _configStrings[0]; //"Slowest" + break; + case 1: + menu.item[2].itemString = _configStrings[1]; //"Slow" + break; + case 2: + menu.item[2].itemString = _configStrings[2]; //"Normal" + break; + case 3: + menu.item[2].itemString = _configStrings[3]; //"Fast" + break; + case 4: + menu.item[2].itemString = _configStrings[4]; //"Fastest" + break; + default: + menu.item[2].itemString = "ERROR"; + break; + } + + int textControl = 3; + int clickableOffset = 8; + if (_flags.isTalkie) { + textControl = 4; + clickableOffset = 11; + + if (_configVoice == 0) + _menu[5].item[4].enabled = 1; + else + _menu[5].item[4].enabled = 0; + + switch (_configVoice) { + case 0: + menu.item[3].itemString = _configStrings[5]; //"Text only" + break; + case 1: + menu.item[3].itemString = _configStrings[6]; //"Voice only" + break; + case 2: + menu.item[3].itemString = _configStrings[7]; //"Voice & Text" + break; + default: + menu.item[3].itemString = "ERROR"; + break; + } + } + + switch (_configTextspeed) { + case 0: + menu.item[textControl].itemString = _configStrings[1]; //"Slow" + break; + case 1: + menu.item[textControl].itemString = _configStrings[2]; //"Normal" + break; + case 2: + menu.item[textControl].itemString = _configStrings[3]; //"Fast" + break; + case 3: + menu.item[textControl].itemString = _configStrings[clickableOffset]; //"Clickable" + break; + default: + menu.item[textControl].itemString = "ERROR"; + break; + } + + calcCoords(menu); + initMenu(menu); +} + +int KyraEngine::gui_controlsChangeMusic(Button *button) { + debugC(9, kDebugLevelGUI, "KyraEngine::gui_controlsChangeMusic()"); + processMenuButton(button); + + _configMusic = ++_configMusic % (_flags.platform == Common::kPlatformFMTowns ? 3 : 2); + gui_setupControls(_menu[5]); + return 0; +} + +int KyraEngine::gui_controlsChangeSounds(Button *button) { + debugC(9, kDebugLevelGUI, "KyraEngine::gui_controlsChangeSounds()"); + processMenuButton(button); + + _configSounds = !_configSounds; + gui_setupControls(_menu[5]); + return 0; +} + +int KyraEngine::gui_controlsChangeWalk(Button *button) { + debugC(9, kDebugLevelGUI, "KyraEngine::gui_controlsChangeWalk()"); + processMenuButton(button); + + _configWalkspeed = ++_configWalkspeed % 5; + setWalkspeed(_configWalkspeed); + gui_setupControls(_menu[5]); + return 0; +} + +int KyraEngine::gui_controlsChangeText(Button *button) { + debugC(9, kDebugLevelGUI, "KyraEngine::gui_controlsChangeText()"); + processMenuButton(button); + + _configTextspeed = ++_configTextspeed % 4; + gui_setupControls(_menu[5]); + return 0; +} + +int KyraEngine::gui_controlsChangeVoice(Button *button) { + debugC(9, kDebugLevelGUI, "KyraEngine::gui_controlsChangeVoice()"); + processMenuButton(button); + + _configVoice = ++_configVoice % 3; + gui_setupControls(_menu[5]); + return 0; +} + +int KyraEngine::gui_controlsApply(Button *button) { + debugC(9, kDebugLevelGUI, "KyraEngine::gui_controlsApply()"); + writeSettings(); + return gui_cancelSubMenu(button); +} + +int KyraEngine::gui_scrollUp(Button *button) { + debugC(9, kDebugLevelGUI, "KyraEngine::gui_scrollUp()"); + processMenuButton(button); + + if (_savegameOffset > 0) { + _savegameOffset--; + setupSavegames(_menu[2], 5); + initMenu(_menu[2]); + } + return 0; +} + +int KyraEngine::gui_scrollDown(Button *button) { + debugC(9, kDebugLevelGUI, "KyraEngine::gui_scrollDown()"); + processMenuButton(button); + + _savegameOffset++; + setupSavegames(_menu[2], 5); + initMenu(_menu[2]); + + return 0; +} + +void KyraEngine::gui_processHighlights(Menu &menu) { + int x1, y1, x2, y2; + + Common::Point mouse = getMousePos(); + for (int i = 0; i < menu.nrOfItems; i++) { + if (!menu.item[i].enabled) + continue; + + x1 = menu.x + menu.item[i].x; + y1 = menu.y + menu.item[i].y; + + x2 = x1 + menu.item[i].width; + y2 = y1 + menu.item[i].height; + + if (mouse.x > x1 && mouse.x < x2 && + mouse.y > y1 && mouse.y < y2) { + + if (menu.highlightedItem != i) { + if (menu.item[menu.highlightedItem].enabled ) + gui_redrawText(menu); + + menu.highlightedItem = i; + gui_redrawHighlight(menu); + _screen->updateScreen(); + } + } + } +} + +void KyraEngine::gui_redrawText(Menu menu) { + int textX; + int i = menu.highlightedItem; + + int x1 = menu.x + menu.item[i].x; + int y1 = menu.y + menu.item[i].y; + + int x2 = x1 + menu.item[i].width - 1; + + if (menu.item[i].field_12 != -1 &&_flags.lang == Common::EN_ANY) + textX = x1 + menu.item[i].field_12 + 3; + else + textX = _text->getCenterStringX(menu.item[i].itemString, x1, x2); + + int textY = y1 + 2; + _text->printText(menu.item[i].itemString, textX - 1, textY + 1, 12, 0, 0); + _text->printText(menu.item[i].itemString, textX, textY, menu.item[i].textColor, 0, 0); +} + +void KyraEngine::gui_redrawHighlight(Menu menu) { + int textX; + int i = menu.highlightedItem; + + int x1 = menu.x + menu.item[i].x; + int y1 = menu.y + menu.item[i].y; + + int x2 = x1 + menu.item[i].width - 1; + + if (menu.item[i].field_12 != -1 &&_flags.lang == Common::EN_ANY) + textX = x1 + menu.item[i].field_12 + 3; + else + textX = _text->getCenterStringX(menu.item[i].itemString, x1, x2); + + int textY = y1 + 2; + _text->printText(menu.item[i].itemString, textX - 1, textY + 1, 12, 0, 0); + _text->printText(menu.item[i].itemString, textX, textY, menu.item[i].highlightColor, 0, 0); +} + +void KyraEngine::gui_fadePalette() { + if (_flags.platform == Common::kPlatformAmiga) + return; + + static int16 menuPalIndexes[] = {248, 249, 250, 251, 252, 253, 254, -1}; + int index = 0; + + memcpy(_screen->getPalette(2), _screen->_currentPalette, 768); + + for (int i = 0; i < 768; i++) + _screen->_currentPalette[i] >>= 1; + + while (menuPalIndexes[index] != -1) { + memcpy(&_screen->_currentPalette[menuPalIndexes[index]*3], &_screen->getPalette(2)[menuPalIndexes[index]*3], 3); + index++; + } + + _screen->fadePalette(_screen->_currentPalette, 2); +} + +void KyraEngine::gui_restorePalette() { + if (_flags.platform == Common::kPlatformAmiga) + return; + + memcpy(_screen->_currentPalette, _screen->getPalette(2), 768); + _screen->fadePalette(_screen->_currentPalette, 2); +} + +#pragma mark - + +// Kyra 2 and 3 main menu + +void KyraEngine::gui_updateMainMenuAnimation() { + _screen->updateScreen(); +} + +bool KyraEngine::gui_mainMenuGetInput() { + Common::Event event; + + while (_eventMan->pollEvent(event)) { + switch (event.type) { + case Common::EVENT_QUIT: + quitGame(); + break; + case Common::EVENT_LBUTTONUP: + return true; + default: + break; + } + } + return false; +} + +int KyraEngine::gui_handleMainMenu() { + debugC(9, kDebugLevelMain, "KyraEngine::gui_handleMainMenu()"); + int command = -1; + + uint8 colorMap[16]; + memset(colorMap, 0, sizeof(colorMap)); + _screen->setTextColorMap(colorMap); + + const char * const *strings = &_mainMenuStrings[_lang << 2]; + Screen::FontId oldFont = _screen->setFont(Screen::FID_8_FNT); + int charWidthBackUp = _screen->_charWidth; + + _screen->_charWidth = -2; + _screen->setScreenDim(3); + int backUpX = _screen->_curDim->sx; + int backUpY = _screen->_curDim->sy; + int backUpWidth = _screen->_curDim->w; + int backUpHeight = _screen->_curDim->h; + _screen->copyRegion(backUpX, backUpY, backUpX, backUpY, backUpWidth, backUpHeight, 0, 3); + + int x = _screen->_curDim->sx << 3; + int y = _screen->_curDim->sy; + int width = _screen->_curDim->w << 3; + int height = _screen->_curDim->h; + + gui_drawMainBox(x, y, width, height, 1); + gui_drawMainBox(x + 1, y + 1, width - 2, height - 2, 0); + + int selected = 0; + + gui_drawMainMenu(strings, selected); + + _screen->showMouse(); + + int fh = _screen->getFontHeight(); + int textPos = ((_screen->_curDim->w >> 1) + _screen->_curDim->sx) << 3; + + Common::Rect menuRect(x + 16, y + 4, x + width - 16, y + 4 + fh * 4); + + while (!_quitFlag) { + gui_updateMainMenuAnimation(); + bool mousePressed = gui_mainMenuGetInput(); + + Common::Point mouse = getMousePos(); + if (menuRect.contains(mouse)) { + int item = (mouse.y - menuRect.top) / fh; + + if (item != selected) { + gui_printString(strings[selected], textPos, menuRect.top + selected * fh, 0x80, 0, 5); + gui_printString(strings[item], textPos, menuRect.top + item * fh, 0xFF, 0, 5); + + selected = item; + } + + if (mousePressed) { + // TODO: Flash the text + command = item; + break; + } + } + _system->delayMillis(10); + } + + if (_quitFlag) + command = -1; + + _screen->copyRegion(backUpX, backUpY, backUpX, backUpY, backUpWidth, backUpHeight, 3, 0); + _screen->_charWidth = charWidthBackUp; + _screen->setFont(oldFont); + + return command; +} + +void KyraEngine::gui_drawMainMenu(const char * const *strings, int select) { + debugC(9, kDebugLevelMain, "KyraEngine::gui_drawMainMenu(%p)", (const void*)strings); + static const uint16 menuTable[] = { 0x01, 0x04, 0x0C, 0x04, 0x00, 0x80, 0xFF, 0x00, 0x01, 0x02, 0x03 }; + + int top = _screen->_curDim->sy; + top += menuTable[1]; + + for (int i = 0; i < menuTable[3]; ++i) { + int curY = top + i * _screen->getFontHeight(); + int color = (i == select) ? menuTable[6] : menuTable[5]; + gui_printString(strings[i], ((_screen->_curDim->w >> 1) + _screen->_curDim->sx) << 3, curY, color, 0, 5); + } +} + +void KyraEngine::gui_drawMainBox(int x, int y, int w, int h, int fill) { + debugC(9, kDebugLevelMain, "KyraEngine::gui_drawMainBox(%d, %d, %d, %d, %d)", x, y, w, h, fill); + static const uint8 kyra3ColorTable[] = { 0x16, 0x19, 0x1A, 0x16 }; + static const uint8 kyra2ColorTable[] = { 0x0, 0x19, 0x28, 0xc8 }; + + const uint8 *colorTable; + if (_flags.gameID == GI_KYRA3) + colorTable = kyra3ColorTable; + else + colorTable = kyra2ColorTable; + + --w; --h; + + if (fill) + _screen->fillRect(x, y, x+w, y+h, colorTable[0]); + + _screen->drawClippedLine(x, y+h, x+w, y+h, colorTable[1]); + _screen->drawClippedLine(x+w, y, x+w, y+h, colorTable[1]); + _screen->drawClippedLine(x, y, x+w, y, colorTable[2]); + _screen->drawClippedLine(x, y, x, y+h, colorTable[2]); + + _screen->setPagePixel(_screen->_curPage, x, y+h, colorTable[3]); + _screen->setPagePixel(_screen->_curPage, x+w, y, colorTable[3]); +} + +void KyraEngine::gui_printString(const char *format, int x, int y, int col1, int col2, int flags, ...) { + debugC(9, kDebugLevelMain, "KyraEngine::gui_printString('%s', %d, %d, %d, %d, %d, ...)", format, x, y, col1, col2, flags); + if (!format) + return; + + char string[512]; + va_list vaList; + va_start(vaList, flags); + vsprintf(string, format, vaList); + va_end(vaList); + + if (flags & 1) + x -= _screen->getTextWidth(string) >> 1; + + if (flags & 2) + x -= _screen->getTextWidth(string); + + if (flags & 4) { + _screen->printText(string, x - 1, y, 240, col2); + _screen->printText(string, x, y + 1, 240, col2); + } + + if (flags & 8) { + _screen->printText(string, x - 1, y, 227, col2); + _screen->printText(string, x, y + 1, 227, col2); + } + + _screen->printText(string, x, y, col1, col2); +} + +} // end of namespace Kyra + diff --git a/engines/kyra/items.cpp b/engines/kyra/items.cpp deleted file mode 100644 index 2a1a08b7de..0000000000 --- a/engines/kyra/items.cpp +++ /dev/null @@ -1,944 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -#include "kyra/kyra.h" -#include "kyra/seqplayer.h" -#include "kyra/screen.h" -#include "kyra/resource.h" -#include "kyra/sound.h" -#include "kyra/sprites.h" -#include "kyra/wsamovie.h" -#include "kyra/animator.h" -#include "kyra/text.h" - -#include "common/system.h" -#include "common/savefile.h" - -namespace Kyra { - -int KyraEngine::findDuplicateItemShape(int shape) { - static uint8 dupTable[] = { - 0x48, 0x46, 0x49, 0x47, 0x4a, 0x46, 0x4b, 0x47, - 0x4c, 0x46, 0x4d, 0x47, 0x5b, 0x5a, 0x5c, 0x5a, - 0x5d, 0x5a, 0x5e, 0x5a, 0xFF, 0xFF - }; - - int i = 0; - - while (dupTable[i] != 0xFF) { - if (dupTable[i] == shape) - return dupTable[i+1]; - i += 2; - } - return -1; -} - -void KyraEngine::addToNoDropRects(int x, int y, int w, int h) { - debugC(9, kDebugLevelMain, "KyraEngine::addToNoDropRects(%d, %d, %d, %d)", x, y, w, h); - for (int rect = 0; rect < 11; ++rect) { - if (_noDropRects[rect].x == -1) { - _noDropRects[rect].x = x; - _noDropRects[rect].y = y; - _noDropRects[rect].x2 = x + w - 1; - _noDropRects[rect].y2 = y + h - 1; - break; - } - } -} - -void KyraEngine::clearNoDropRects() { - debugC(9, kDebugLevelMain, "KyraEngine::clearNoDropRects()"); - memset(_noDropRects, -1, sizeof(_noDropRects)); -} - -byte KyraEngine::findFreeItemInScene(int scene) { - debugC(9, kDebugLevelMain, "KyraEngine::findFreeItemInScene(%d)", scene); - assert(scene < _roomTableSize); - Room *room = &_roomTable[scene]; - for (int i = 0; i < 12; ++i) { - if (room->itemsTable[i] == 0xFF) - return i; - } - return 0xFF; -} - -byte KyraEngine::findItemAtPos(int x, int y) { - debugC(9, kDebugLevelMain, "KyraEngine::findItemAtPos(%d, %d)", x, y); - assert(_currentCharacter->sceneId < _roomTableSize); - const uint8 *itemsTable = _roomTable[_currentCharacter->sceneId].itemsTable; - const uint16 *xposOffset = _roomTable[_currentCharacter->sceneId].itemsXPos; - const uint8 *yposOffset = _roomTable[_currentCharacter->sceneId].itemsYPos; - - int highestYPos = -1; - byte returnValue = 0xFF; - - for (int i = 0; i < 12; ++i) { - if (*itemsTable != 0xFF) { - int xpos = *xposOffset - 11; - int xpos2 = *xposOffset + 10; - if (x > xpos && x < xpos2) { - assert(*itemsTable < ARRAYSIZE(_itemTable)); - int itemHeight = _itemTable[*itemsTable].height; - int ypos = *yposOffset + 3; - int ypos2 = ypos - itemHeight - 3; - - if (y > ypos2 && ypos > y) { - if (highestYPos <= ypos) { - returnValue = i; - highestYPos = ypos; - } - } - } - } - ++xposOffset; - ++yposOffset; - ++itemsTable; - } - - return returnValue; -} - -void KyraEngine::placeItemInGenericMapScene(int item, int index) { - debugC(9, kDebugLevelMain, "KyraEngine::placeItemInGenericMapScene(%d, %d)", item, index); - static const uint16 itemMapSceneMinTable[] = { - 0x0000, 0x0011, 0x006D, 0x0025, 0x00C7, 0x0000 - }; - static const uint16 itemMapSceneMaxTable[] = { - 0x0010, 0x0024, 0x00C6, 0x006C, 0x00F5, 0x0000 - }; - - int minValue = itemMapSceneMinTable[index]; - int maxValue = itemMapSceneMaxTable[index]; - - while (true) { - int room = _rnd.getRandomNumberRng(minValue, maxValue); - assert(room < _roomTableSize); - int nameIndex = _roomTable[room].nameIndex; - bool placeItem = false; - - switch (nameIndex) { - case 0: case 1: case 2: case 3: - case 4: case 5: case 6: case 11: - case 12: case 16: case 17: case 20: - case 22: case 23: case 25: case 26: - case 27: case 31: case 33: case 34: - case 36: case 37: case 58: case 59: - case 60: case 61: case 83: case 84: - case 85: case 104: case 105: case 106: - placeItem = true; - break; - - case 51: - if (room != 46) - placeItem = true; - break; - - default: - break; - } - - if (placeItem) { - Room *roomPtr = &_roomTable[room]; - if (roomPtr->northExit == 0xFFFF && roomPtr->eastExit == 0xFFFF && roomPtr->southExit == 0xFFFF && roomPtr->westExit == 0xFFFF) - placeItem = false; - else if (_currentCharacter->sceneId == room) - placeItem = false; - } - - if (placeItem) { - if (!processItemDrop(room, item, -1, -1, 2, 0)) - continue; - break; - } - } -} - -void KyraEngine::createMouseItem(int item) { - debugC(9, kDebugLevelMain, "KyraEngine::createMouseItem(%d)", item); - _screen->hideMouse(); - setMouseItem(item); - _itemInHand = item; - _screen->showMouse(); -} - -void KyraEngine::destroyMouseItem() { - debugC(9, kDebugLevelMain, "KyraEngine::destroyMouseItem()"); - _screen->hideMouse(); - _screen->setMouseCursor(1, 1, _shapes[0]); - _itemInHand = -1; - _screen->showMouse(); -} - -void KyraEngine::setMouseItem(int item) { - debugC(9, kDebugLevelMain, "KyraEngine::setMouseItem(%d)", item); - if (item == -1) - _screen->setMouseCursor(1, 1, _shapes[6]); - else - _screen->setMouseCursor(8, 15, _shapes[216+item]); -} - -void KyraEngine::wipeDownMouseItem(int xpos, int ypos) { - debugC(9, kDebugLevelMain, "KyraEngine::wipeDownMouseItem(%d, %d)", xpos, ypos); - if (_itemInHand == -1) - return; - xpos -= 8; - ypos -= 15; - _screen->hideMouse(); - backUpItemRect1(xpos, ypos); - int y = ypos; - int height = 16; - - while (height >= 0) { - restoreItemRect1(xpos, ypos); - _screen->setNewShapeHeight(_shapes[216+_itemInHand], height); - uint32 nextTime = _system->getMillis() + 1 * _tickLength; - _screen->drawShape(0, _shapes[216+_itemInHand], xpos, y, 0, 0); - _screen->updateScreen(); - y += 2; - height -= 2; - delayUntil(nextTime); - } - restoreItemRect1(xpos, ypos); - _screen->resetShapeHeight(_shapes[216+_itemInHand]); - destroyMouseItem(); - _screen->showMouse(); -} - -void KyraEngine::setupSceneItems() { - debugC(9, kDebugLevelMain, "KyraEngine::setupSceneItems()"); - uint16 sceneId = _currentCharacter->sceneId; - assert(sceneId < _roomTableSize); - Room *currentRoom = &_roomTable[sceneId]; - for (int i = 0; i < 12; ++i) { - uint8 item = currentRoom->itemsTable[i]; - if (item == 0xFF || !currentRoom->needInit[i]) - continue; - - int xpos = 0; - int ypos = 0; - - if (currentRoom->itemsXPos[i] == 0xFFFF) { - xpos = currentRoom->itemsXPos[i] = _rnd.getRandomNumberRng(24, 296); - ypos = currentRoom->itemsYPos[i] = _rnd.getRandomNumberRng(_northExitHeight & 0xFF, 130); - } else { - xpos = currentRoom->itemsXPos[i]; - ypos = currentRoom->itemsYPos[i]; - } - - _lastProcessedItem = i; - - int stop = 0; - while (!stop) { - stop = processItemDrop(sceneId, item, xpos, ypos, 3, 0); - if (!stop) { - xpos = currentRoom->itemsXPos[i] = _rnd.getRandomNumberRng(24, 296); - ypos = currentRoom->itemsYPos[i] = _rnd.getRandomNumberRng(_northExitHeight & 0xFF, 130); - if (countItemsInScene(sceneId) >= 12) - break; - } else { - currentRoom->needInit[i] = 0; - } - } - } -} - -int KyraEngine::countItemsInScene(uint16 sceneId) { - debugC(9, kDebugLevelMain, "KyraEngine::countItemsInScene(%d)", sceneId); - assert(sceneId < _roomTableSize); - Room *currentRoom = &_roomTable[sceneId]; - - int items = 0; - - for (int i = 0; i < 12; ++i) { - if (currentRoom->itemsTable[i] != 0xFF) - ++items; - } - - return items; -} - -int KyraEngine::processItemDrop(uint16 sceneId, uint8 item, int x, int y, int unk1, int unk2) { - debugC(9, kDebugLevelMain, "KyraEngine::processItemDrop(%d, %d, %d, %d, %d, %d)", sceneId, item, x, y, unk1, unk2); - int freeItem = -1; - uint8 itemIndex = findItemAtPos(x, y); - if (unk1) - itemIndex = 0xFF; - - if (itemIndex != 0xFF) { - exchangeItemWithMouseItem(sceneId, itemIndex); - return 0; - } - - assert(sceneId < _roomTableSize); - Room *currentRoom = &_roomTable[sceneId]; - - if (unk1 != 3) { - for (int i = 0; i < 12; ++i) { - if (currentRoom->itemsTable[i] == 0xFF) { - freeItem = i; - break; - } - } - } else { - freeItem = _lastProcessedItem; - } - - if (freeItem == -1) - return 0; - - if (sceneId != _currentCharacter->sceneId) { - addItemToRoom(sceneId, item, freeItem, x, y); - return 1; - } - - int itemHeight = _itemTable[item].height; - _lastProcessedItemHeight = itemHeight; - - if (x == -1 && x == -1) { - x = _rnd.getRandomNumberRng(16, 304); - y = _rnd.getRandomNumberRng(_northExitHeight & 0xFF, 135); - } - - int xpos = x; - int ypos = y; - int destY = -1; - int destX = -1; - int running = 1; - - while (running) { - if ((_northExitHeight & 0xFF) <= ypos) { - bool running2 = true; - - if (_screen->getDrawLayer(xpos, ypos) > 1) { - if (((_northExitHeight >> 8) & 0xFF) != ypos) - running2 = false; - } - - if (_screen->getDrawLayer2(xpos, ypos, itemHeight) > 1) { - if (((_northExitHeight >> 8) & 0xFF) != ypos) - running2 = false; - } - - if (!isDropable(xpos, ypos)) { - if (((_northExitHeight >> 8) & 0xFF) != ypos) - running2 = false; - } - - int xpos2 = xpos; - int xpos3 = xpos; - - while (running2) { - if (isDropable(xpos2, ypos)) { - if (_screen->getDrawLayer2(xpos2, ypos, itemHeight) < 7) { - if (findItemAtPos(xpos2, ypos) == 0xFF) { - destX = xpos2; - destY = ypos; - running = 0; - running2 = false; - } - } - } - - if (isDropable(xpos3, ypos)) { - if (_screen->getDrawLayer2(xpos3, ypos, itemHeight) < 7) { - if (findItemAtPos(xpos3, ypos) == 0xFF) { - destX = xpos3; - destY = ypos; - running = 0; - running2 = false; - } - } - } - - if (!running2) - continue; - - xpos2 -= 2; - if (xpos2 < 16) - xpos2 = 16; - - xpos3 += 2; - if (xpos3 > 304) - xpos3 = 304; - - if (xpos2 > 16) - continue; - if (xpos3 < 304) - continue; - running2 = false; - } - } - - if (((_northExitHeight >> 8) & 0xFF) == ypos) { - running = 0; - destY -= _rnd.getRandomNumberRng(0, 3); - - if ((_northExitHeight & 0xFF) < destY) - continue; - - destY = (_northExitHeight & 0xFF) + 1; - continue; - } - ypos += 2; - if (((_northExitHeight >> 8) & 0xFF) >= ypos) - continue; - ypos = (_northExitHeight >> 8) & 0xFF; - } - - if (destX == -1 || destY == -1) - return 0; - - if (unk1 == 3) { - currentRoom->itemsXPos[freeItem] = destX; - currentRoom->itemsYPos[freeItem] = destY; - return 1; - } - - if (unk1 == 2) - itemSpecialFX(x, y, item); - - if (unk1 == 0) - destroyMouseItem(); - - itemDropDown(x, y, destX, destY, freeItem, item); - - if (unk1 == 0 && unk2 != 0) { - assert(_itemList && _droppedList); - updateSentenceCommand(_itemList[item], _droppedList[0], 179); - } - - return 1; -} - -void KyraEngine::exchangeItemWithMouseItem(uint16 sceneId, int itemIndex) { - debugC(9, kDebugLevelMain, "KyraEngine::exchangeItemWithMouseItem(%d, %d)", sceneId, itemIndex); - _screen->hideMouse(); - _animator->animRemoveGameItem(itemIndex); - assert(sceneId < _roomTableSize); - Room *currentRoom = &_roomTable[sceneId]; - - int item = currentRoom->itemsTable[itemIndex]; - currentRoom->itemsTable[itemIndex] = _itemInHand; - _itemInHand = item; - _animator->animAddGameItem(itemIndex, sceneId); - snd_playSoundEffect(53); - - setMouseItem(_itemInHand); - assert(_itemList && _takenList); - updateSentenceCommand(_itemList[_itemInHand], _takenList[1], 179); - _screen->showMouse(); - clickEventHandler2(); -} - -void KyraEngine::addItemToRoom(uint16 sceneId, uint8 item, int itemIndex, int x, int y) { - debugC(9, kDebugLevelMain, "KyraEngine::addItemToRoom(%d, %d, %d, %d, %d)", sceneId, item, itemIndex, x, y); - assert(sceneId < _roomTableSize); - Room *currentRoom = &_roomTable[sceneId]; - currentRoom->itemsTable[itemIndex] = item; - currentRoom->itemsXPos[itemIndex] = x; - currentRoom->itemsYPos[itemIndex] = y; - currentRoom->needInit[itemIndex] = 1; -} - -int KyraEngine::checkNoDropRects(int x, int y) { - debugC(9, kDebugLevelMain, "KyraEngine::checkNoDropRects(%d, %d)", x, y); - if (_lastProcessedItemHeight < 1 || _lastProcessedItemHeight > 16) - _lastProcessedItemHeight = 16; - if (_noDropRects[0].x == -1) - return 0; - - for (int i = 0; i < 11; ++i) { - if (_noDropRects[i].x == -1) - break; - - int xpos = _noDropRects[i].x; - int ypos = _noDropRects[i].y; - int xpos2 = _noDropRects[i].x2; - int ypos2 = _noDropRects[i].y2; - - if (xpos > x + 16) - continue; - if (xpos2 < x) - continue; - if (y < ypos) - continue; - if (ypos2 < y - _lastProcessedItemHeight) - continue; - return 1; - } - - return 0; -} - -int KyraEngine::isDropable(int x, int y) { - debugC(9, kDebugLevelMain, "KyraEngine::isDropable(%d, %d)", x, y); - x -= 8; - y -= 1; - - if (checkNoDropRects(x, y)) - return 0; - - for (int xpos = x; xpos < x + 16; ++xpos) { - if (_screen->getShapeFlag1(xpos, y) == 0) - return 0; - } - return 1; -} - -void KyraEngine::itemDropDown(int x, int y, int destX, int destY, byte freeItem, int item) { - debugC(9, kDebugLevelMain, "KyraEngine::itemDropDown(%d, %d, %d, %d, %d, %d)", x, y, destX, destY, freeItem, item); - assert(_currentCharacter->sceneId < _roomTableSize); - Room *currentRoom = &_roomTable[_currentCharacter->sceneId]; - if (x == destX && y == destY) { - currentRoom->itemsXPos[freeItem] = destX; - currentRoom->itemsYPos[freeItem] = destY; - currentRoom->itemsTable[freeItem] = item; - snd_playSoundEffect(0x32); - _animator->animAddGameItem(freeItem, _currentCharacter->sceneId); - return; - } - _screen->hideMouse(); - if (y <= destY) { - int tempY = y; - int addY = 2; - int drawX = x - 8; - int drawY = 0; - - backUpItemRect0(drawX, y - 16); - - while (tempY < destY) { - restoreItemRect0(drawX, tempY - 16); - tempY += addY; - if (tempY > destY) - tempY = destY; - ++addY; - drawY = tempY - 16; - backUpItemRect0(drawX, drawY); - uint32 nextTime = _system->getMillis() + 1 * _tickLength; - _screen->drawShape(0, _shapes[216+item], drawX, drawY, 0, 0); - _screen->updateScreen(); - delayUntil(nextTime); - } - - bool skip = false; - if (x == destX) { - if (destY - y <= 16) - skip = true; - } - - if (!skip) { - snd_playSoundEffect(0x47); - if (addY < 6) - addY = 6; - - int xDiff = (destX - x) << 4; - xDiff /= addY; - int startAddY = addY; - addY >>= 1; - if (destY - y <= 8) - addY >>= 1; - addY = -addY; - int unkX = x << 4; - while (--startAddY) { - drawX = (unkX >> 4) - 8; - drawY = tempY - 16; - restoreItemRect0(drawX, drawY); - tempY += addY; - unkX += xDiff; - if (tempY > destY) - tempY = destY; - ++addY; - drawX = (unkX >> 4) - 8; - drawY = tempY - 16; - backUpItemRect0(drawX, drawY); - uint32 nextTime = _system->getMillis() + 1 * _tickLength; - _screen->drawShape(0, _shapes[216+item], drawX, drawY, 0, 0); - _screen->updateScreen(); - delayUntil(nextTime); - } - restoreItemRect0(drawX, drawY); - } else { - restoreItemRect0(drawX, tempY - 16); - } - } - currentRoom->itemsXPos[freeItem] = destX; - currentRoom->itemsYPos[freeItem] = destY; - currentRoom->itemsTable[freeItem] = item; - snd_playSoundEffect(0x32); - _animator->animAddGameItem(freeItem, _currentCharacter->sceneId); - _screen->showMouse(); -} - -void KyraEngine::dropItem(int unk1, int item, int x, int y, int unk2) { - debugC(9, kDebugLevelMain, "KyraEngine::dropItem(%d, %d, %d, %d, %d)", unk1, item, x, y, unk2); - if (processItemDrop(_currentCharacter->sceneId, item, x, y, unk1, unk2)) - return; - snd_playSoundEffect(54); - assert(_noDropList); - if (12 == countItemsInScene(_currentCharacter->sceneId)) - drawSentenceCommand(_noDropList[0], 6); - else - drawSentenceCommand(_noDropList[1], 6); -} - -void KyraEngine::itemSpecialFX(int x, int y, int item) { - debugC(9, kDebugLevelMain, "KyraEngine::itemSpecialFX(%d, %d, %d)", x, y, item); - if (item == 41) - itemSpecialFX1(x, y, item); - else - itemSpecialFX2(x, y, item); -} - -void KyraEngine::itemSpecialFX1(int x, int y, int item) { - debugC(9, kDebugLevelMain, "KyraEngine::itemSpecialFX1(%d, %d, %d)", x, y, item); - uint8 *shape = _shapes[216+item]; - x -= 8; - int startY = y; - y -= 15; - _screen->hideMouse(); - backUpItemRect0(x, y); - for (int i = 1; i <= 16; ++i) { - _screen->setNewShapeHeight(shape, i); - --startY; - restoreItemRect0(x, y); - uint32 nextTime = _system->getMillis() + 1 * _tickLength; - _screen->drawShape(0, shape, x, startY, 0, 0); - _screen->updateScreen(); - delayUntil(nextTime); - } - restoreItemRect0(x, y); - _screen->showMouse(); -} - -void KyraEngine::itemSpecialFX2(int x, int y, int item) { - debugC(9, kDebugLevelMain, "KyraEngine::itemSpecialFX2(%d, %d, %d)", x, y, item); - x -= 8; - y -= 15; - int yAdd = (int8)(((16 - _itemTable[item].height) >> 1) & 0xFF); - backUpItemRect0(x, y); - if (item >= 80 && item <= 89) - snd_playSoundEffect(55); - - for (int i = 201; i <= 205; ++i) { - restoreItemRect0(x, y); - uint32 nextTime = _system->getMillis() + 3 * _tickLength; - _screen->drawShape(0, _shapes[i], x, y + yAdd, 0, 0); - _screen->updateScreen(); - delayUntil(nextTime); - } - - for (int i = 204; i >= 201; --i) { - restoreItemRect0(x, y); - uint32 nextTime = _system->getMillis() + 3 * _tickLength; - _screen->drawShape(0, _shapes[216+item], x, y, 0, 0); - _screen->drawShape(0, _shapes[i], x, y + yAdd, 0, 0); - _screen->updateScreen(); - delayUntil(nextTime); - } - restoreItemRect0(x, y); -} - -void KyraEngine::magicOutMouseItem(int animIndex, int itemPos) { - debugC(9, kDebugLevelMain, "KyraEngine::magicOutMouseItem(%d, %d)", animIndex, itemPos); - int videoPageBackUp = _screen->_curPage; - _screen->_curPage = 0; - int x = 0, y = 0; - if (itemPos == -1) { - Common::Point mouse = getMousePos(); - x = mouse.x - 12; - y = mouse.y - 18; - } else { - x = _itemPosX[itemPos] - 4; - y = _itemPosY[itemPos] - 3; - } - - if (_itemInHand == -1 && itemPos == -1) - return; - - int tableIndex = 0, loopStart = 0, maxLoops = 0; - if (animIndex == 0) { - tableIndex = _rnd.getRandomNumberRng(0, 5); - loopStart = 35; - maxLoops = 9; - } else if (animIndex == 1) { - tableIndex = _rnd.getRandomNumberRng(0, 11); - loopStart = 115; - maxLoops = 8; - } else if (animIndex == 2) { - tableIndex = 0; - loopStart = 124; - maxLoops = 4; - } else { - tableIndex = -1; - } - - if (animIndex == 2) - snd_playSoundEffect(0x5E); - else - snd_playSoundEffect(0x37); - _screen->hideMouse(); - backUpItemRect1(x, y); - - for (int shape = _magicMouseItemStartFrame[animIndex]; shape <= _magicMouseItemEndFrame[animIndex]; ++shape) { - restoreItemRect1(x, y); - uint32 nextTime = _system->getMillis() + 4 * _tickLength; - _screen->drawShape(0, _shapes[216+_itemInHand], x + 4, y + 3, 0, 0); - if (tableIndex == -1) - _screen->drawShape(0, _shapes[shape], x, y, 0, 0); - else - specialMouseItemFX(shape, x, y, animIndex, tableIndex, loopStart, maxLoops); - _screen->updateScreen(); - delayUntil(nextTime); - } - - if (itemPos != -1) { - restoreItemRect1(x, y); - _screen->fillRect(_itemPosX[itemPos], _itemPosY[itemPos], _itemPosX[itemPos] + 15, _itemPosY[itemPos] + 15, 12, 0); - backUpItemRect1(x, y); - } - - for (int shape = _magicMouseItemStartFrame2[animIndex]; shape <= _magicMouseItemEndFrame2[animIndex]; ++shape) { - restoreItemRect1(x, y); - uint32 nextTime = _system->getMillis() + 4 * _tickLength; - _screen->drawShape(0, _shapes[216+_itemInHand], x + 4, y + 3, 0, 0); - if (tableIndex == -1) - _screen->drawShape(0, _shapes[shape], x, y, 0, 0); - else - specialMouseItemFX(shape, x, y, animIndex, tableIndex, loopStart, maxLoops); - _screen->updateScreen(); - delayUntil(nextTime); - } - restoreItemRect1(x, y); - if (itemPos == -1) { - _screen->setMouseCursor(1, 1, _shapes[0]); - _itemInHand = -1; - } else { - _characterList[0].inventoryItems[itemPos] = 0xFF; - _screen->hideMouse(); - _screen->fillRect(_itemPosX[itemPos], _itemPosY[itemPos], _itemPosX[itemPos] + 15, _itemPosY[itemPos] + 15, 12, 0); - _screen->showMouse(); - } - _screen->showMouse(); - _screen->_curPage = videoPageBackUp; -} - -void KyraEngine::magicInMouseItem(int animIndex, int item, int itemPos) { - debugC(9, kDebugLevelMain, "KyraEngine::magicInMouseItem(%d, %d, %d)", animIndex, item, itemPos); - int videoPageBackUp = _screen->_curPage; - _screen->_curPage = 0; - int x = 0, y = 0; - if (itemPos == -1) { - Common::Point mouse = getMousePos(); - x = mouse.x - 12; - y = mouse.y - 18; - } else { - x = _itemPosX[itemPos] - 4; - y = _itemPosX[itemPos] - 3; - } - if (item < 0) - return; - - int tableIndex = -1, loopStart = 0, maxLoops = 0; - if (animIndex == 0) { - tableIndex = _rnd.getRandomNumberRng(0, 5); - loopStart = 35; - maxLoops = 9; - } else if (animIndex == 1) { - tableIndex = _rnd.getRandomNumberRng(0, 11); - loopStart = 115; - maxLoops = 8; - } else if (animIndex == 2) { - tableIndex = 0; - loopStart = 124; - maxLoops = 4; - } - - _screen->hideMouse(); - backUpItemRect1(x, y); - if (animIndex == 2) - snd_playSoundEffect(0x5E); - else - snd_playSoundEffect(0x37); - - for (int shape = _magicMouseItemStartFrame[animIndex]; shape <= _magicMouseItemEndFrame[animIndex]; ++shape) { - restoreItemRect1(x, y); - uint32 nextTime = _system->getMillis() + 4 * _tickLength; - if (tableIndex == -1) - _screen->drawShape(0, _shapes[shape], x, y, 0, 0); - else - specialMouseItemFX(shape, x, y, animIndex, tableIndex, loopStart, maxLoops); - _screen->updateScreen(); - delayUntil(nextTime); - } - - for (int shape = _magicMouseItemStartFrame2[animIndex]; shape <= _magicMouseItemEndFrame2[animIndex]; ++shape) { - restoreItemRect1(x, y); - uint32 nextTime = _system->getMillis() + 4 * _tickLength; - if (tableIndex == -1) - _screen->drawShape(0, _shapes[shape], x, y, 0, 0); - else - specialMouseItemFX(shape, x, y, animIndex, tableIndex, loopStart, maxLoops); - _screen->updateScreen(); - delayUntil(nextTime); - } - restoreItemRect1(x, y); - if (itemPos == -1) { - _screen->setMouseCursor(8, 15, _shapes[216+item]); - _itemInHand = item; - } else { - _characterList[0].inventoryItems[itemPos] = item; - _screen->hideMouse(); - _screen->drawShape(0, _shapes[216+item], _itemPosX[itemPos], _itemPosY[itemPos], 0, 0); - _screen->showMouse(); - } - _screen->showMouse(); - _screen->_curPage = videoPageBackUp; -} - -void KyraEngine::specialMouseItemFX(int shape, int x, int y, int animIndex, int tableIndex, int loopStart, int maxLoops) { - debugC(9, kDebugLevelMain, "KyraEngine::specialMouseItemFX(%d, %d, %d, %d, %d, %d, %d)", shape, x, y, animIndex, tableIndex, loopStart, maxLoops); - static const uint8 table1[] = { - 0x23, 0x45, 0x55, 0x72, 0x84, 0xCF, 0x00, 0x00 - }; - static const uint8 table2[] = { - 0x73, 0xB5, 0x80, 0x21, 0x13, 0x39, 0x45, 0x55, 0x62, 0xB4, 0xCF, 0xD8 - }; - static const uint8 table3[] = { - 0x7C, 0xD0, 0x74, 0x84, 0x87, 0x00, 0x00, 0x00 - }; - int tableValue = 0; - if (animIndex == 0) - tableValue = table1[tableIndex]; - else if (animIndex == 1) - tableValue = table2[tableIndex]; - else if (animIndex == 2) - tableValue = table3[tableIndex]; - else - return; - processSpecialMouseItemFX(shape, x, y, tableValue, loopStart, maxLoops); -} - -void KyraEngine::processSpecialMouseItemFX(int shape, int x, int y, int tableValue, int loopStart, int maxLoops) { - debugC(9, kDebugLevelMain, "KyraEngine::processSpecialMouseItemFX(%d, %d, %d, %d, %d, %d)", shape, x, y, tableValue, loopStart, maxLoops); - uint8 shapeColorTable[16]; - uint8 *shapePtr = _shapes[shape] + 10; - if (_flags.useAltShapeHeader) - shapePtr += 2; - - for (int i = 0; i < 16; ++i) - shapeColorTable[i] = shapePtr[i]; - - for (int i = loopStart; i < loopStart + maxLoops; ++i) { - for (int i2 = 0; i2 < 16; ++i2) { - if (shapePtr[i2] == i) - shapeColorTable[i2] = (i + tableValue) - loopStart; - } - } - _screen->drawShape(0, _shapes[shape], x, y, 0, 0x8000, shapeColorTable); -} - -void KyraEngine::updatePlayerItemsForScene() { - debugC(9, kDebugLevelMain, "KyraEngine::updatePlayerItemsForScene()"); - if (_itemInHand >= 29 && _itemInHand < 33) { - ++_itemInHand; - if (_itemInHand > 33) - _itemInHand = 33; - _screen->hideMouse(); - _screen->setMouseCursor(8, 15, _shapes[216+_itemInHand]); - _screen->showMouse(); - } - - bool redraw = false; - for (int i = 0; i < 10; ++i) { - uint8 item = _currentCharacter->inventoryItems[i]; - if (item >= 29 && item < 33) { - ++item; - if (item > 33) - item = 33; - _currentCharacter->inventoryItems[i] = item; - redraw = true; - } - } - - if (redraw) { - _screen->hideMouse(); - redrawInventory(0); - _screen->showMouse(); - } - - if (_itemInHand == 33) - magicOutMouseItem(2, -1); - - _screen->hideMouse(); - for (int i = 0; i < 10; ++i) { - uint8 item = _currentCharacter->inventoryItems[i]; - if (item == 33) - magicOutMouseItem(2, i); - } - _screen->showMouse(); -} - -void KyraEngine::redrawInventory(int page) { - int videoPageBackUp = _screen->_curPage; - _screen->_curPage = page; - _screen->hideMouse(); - for (int i = 0; i < 10; ++i) { - _screen->fillRect(_itemPosX[i], _itemPosY[i], _itemPosX[i] + 15, _itemPosY[i] + 15, 12, page); - if (_currentCharacter->inventoryItems[i] != 0xFF) { - uint8 item = _currentCharacter->inventoryItems[i]; - _screen->drawShape(page, _shapes[216+item], _itemPosX[i], _itemPosY[i], 0, 0); - } - } - _screen->showMouse(); - _screen->_curPage = videoPageBackUp; - _screen->updateScreen(); -} - -void KyraEngine::backUpItemRect0(int xpos, int ypos) { - debugC(9, kDebugLevelMain, "KyraEngine::backUpItemRect0(%d, %d)", xpos, ypos); - _screen->rectClip(xpos, ypos, 3<<3, 24); - _screen->copyRegionToBuffer(_screen->_curPage, xpos, ypos, 3<<3, 24, _itemBkgBackUp[0]); -} - -void KyraEngine::restoreItemRect0(int xpos, int ypos) { - debugC(9, kDebugLevelMain, "KyraEngine::restoreItemRect0(%d, %d)", xpos, ypos); - _screen->rectClip(xpos, ypos, 3<<3, 24); - _screen->copyBlockToPage(_screen->_curPage, xpos, ypos, 3<<3, 24, _itemBkgBackUp[0]); -} - -void KyraEngine::backUpItemRect1(int xpos, int ypos) { - debugC(9, kDebugLevelMain, "KyraEngine::backUpItemRect1(%d, %d)", xpos, ypos); - _screen->rectClip(xpos, ypos, 4<<3, 32); - _screen->copyRegionToBuffer(_screen->_curPage, xpos, ypos, 4<<3, 32, _itemBkgBackUp[1]); -} - -void KyraEngine::restoreItemRect1(int xpos, int ypos) { - debugC(9, kDebugLevelMain, "KyraEngine::restoreItemRect1(%d, %d)", xpos, ypos); - _screen->rectClip(xpos, ypos, 4<<3, 32); - _screen->copyBlockToPage(_screen->_curPage, xpos, ypos, 4<<3, 32, _itemBkgBackUp[1]); -} - -} // end of namespace Kyra - diff --git a/engines/kyra/items_v1.cpp b/engines/kyra/items_v1.cpp new file mode 100644 index 0000000000..2a1a08b7de --- /dev/null +++ b/engines/kyra/items_v1.cpp @@ -0,0 +1,944 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include "kyra/kyra.h" +#include "kyra/seqplayer.h" +#include "kyra/screen.h" +#include "kyra/resource.h" +#include "kyra/sound.h" +#include "kyra/sprites.h" +#include "kyra/wsamovie.h" +#include "kyra/animator.h" +#include "kyra/text.h" + +#include "common/system.h" +#include "common/savefile.h" + +namespace Kyra { + +int KyraEngine::findDuplicateItemShape(int shape) { + static uint8 dupTable[] = { + 0x48, 0x46, 0x49, 0x47, 0x4a, 0x46, 0x4b, 0x47, + 0x4c, 0x46, 0x4d, 0x47, 0x5b, 0x5a, 0x5c, 0x5a, + 0x5d, 0x5a, 0x5e, 0x5a, 0xFF, 0xFF + }; + + int i = 0; + + while (dupTable[i] != 0xFF) { + if (dupTable[i] == shape) + return dupTable[i+1]; + i += 2; + } + return -1; +} + +void KyraEngine::addToNoDropRects(int x, int y, int w, int h) { + debugC(9, kDebugLevelMain, "KyraEngine::addToNoDropRects(%d, %d, %d, %d)", x, y, w, h); + for (int rect = 0; rect < 11; ++rect) { + if (_noDropRects[rect].x == -1) { + _noDropRects[rect].x = x; + _noDropRects[rect].y = y; + _noDropRects[rect].x2 = x + w - 1; + _noDropRects[rect].y2 = y + h - 1; + break; + } + } +} + +void KyraEngine::clearNoDropRects() { + debugC(9, kDebugLevelMain, "KyraEngine::clearNoDropRects()"); + memset(_noDropRects, -1, sizeof(_noDropRects)); +} + +byte KyraEngine::findFreeItemInScene(int scene) { + debugC(9, kDebugLevelMain, "KyraEngine::findFreeItemInScene(%d)", scene); + assert(scene < _roomTableSize); + Room *room = &_roomTable[scene]; + for (int i = 0; i < 12; ++i) { + if (room->itemsTable[i] == 0xFF) + return i; + } + return 0xFF; +} + +byte KyraEngine::findItemAtPos(int x, int y) { + debugC(9, kDebugLevelMain, "KyraEngine::findItemAtPos(%d, %d)", x, y); + assert(_currentCharacter->sceneId < _roomTableSize); + const uint8 *itemsTable = _roomTable[_currentCharacter->sceneId].itemsTable; + const uint16 *xposOffset = _roomTable[_currentCharacter->sceneId].itemsXPos; + const uint8 *yposOffset = _roomTable[_currentCharacter->sceneId].itemsYPos; + + int highestYPos = -1; + byte returnValue = 0xFF; + + for (int i = 0; i < 12; ++i) { + if (*itemsTable != 0xFF) { + int xpos = *xposOffset - 11; + int xpos2 = *xposOffset + 10; + if (x > xpos && x < xpos2) { + assert(*itemsTable < ARRAYSIZE(_itemTable)); + int itemHeight = _itemTable[*itemsTable].height; + int ypos = *yposOffset + 3; + int ypos2 = ypos - itemHeight - 3; + + if (y > ypos2 && ypos > y) { + if (highestYPos <= ypos) { + returnValue = i; + highestYPos = ypos; + } + } + } + } + ++xposOffset; + ++yposOffset; + ++itemsTable; + } + + return returnValue; +} + +void KyraEngine::placeItemInGenericMapScene(int item, int index) { + debugC(9, kDebugLevelMain, "KyraEngine::placeItemInGenericMapScene(%d, %d)", item, index); + static const uint16 itemMapSceneMinTable[] = { + 0x0000, 0x0011, 0x006D, 0x0025, 0x00C7, 0x0000 + }; + static const uint16 itemMapSceneMaxTable[] = { + 0x0010, 0x0024, 0x00C6, 0x006C, 0x00F5, 0x0000 + }; + + int minValue = itemMapSceneMinTable[index]; + int maxValue = itemMapSceneMaxTable[index]; + + while (true) { + int room = _rnd.getRandomNumberRng(minValue, maxValue); + assert(room < _roomTableSize); + int nameIndex = _roomTable[room].nameIndex; + bool placeItem = false; + + switch (nameIndex) { + case 0: case 1: case 2: case 3: + case 4: case 5: case 6: case 11: + case 12: case 16: case 17: case 20: + case 22: case 23: case 25: case 26: + case 27: case 31: case 33: case 34: + case 36: case 37: case 58: case 59: + case 60: case 61: case 83: case 84: + case 85: case 104: case 105: case 106: + placeItem = true; + break; + + case 51: + if (room != 46) + placeItem = true; + break; + + default: + break; + } + + if (placeItem) { + Room *roomPtr = &_roomTable[room]; + if (roomPtr->northExit == 0xFFFF && roomPtr->eastExit == 0xFFFF && roomPtr->southExit == 0xFFFF && roomPtr->westExit == 0xFFFF) + placeItem = false; + else if (_currentCharacter->sceneId == room) + placeItem = false; + } + + if (placeItem) { + if (!processItemDrop(room, item, -1, -1, 2, 0)) + continue; + break; + } + } +} + +void KyraEngine::createMouseItem(int item) { + debugC(9, kDebugLevelMain, "KyraEngine::createMouseItem(%d)", item); + _screen->hideMouse(); + setMouseItem(item); + _itemInHand = item; + _screen->showMouse(); +} + +void KyraEngine::destroyMouseItem() { + debugC(9, kDebugLevelMain, "KyraEngine::destroyMouseItem()"); + _screen->hideMouse(); + _screen->setMouseCursor(1, 1, _shapes[0]); + _itemInHand = -1; + _screen->showMouse(); +} + +void KyraEngine::setMouseItem(int item) { + debugC(9, kDebugLevelMain, "KyraEngine::setMouseItem(%d)", item); + if (item == -1) + _screen->setMouseCursor(1, 1, _shapes[6]); + else + _screen->setMouseCursor(8, 15, _shapes[216+item]); +} + +void KyraEngine::wipeDownMouseItem(int xpos, int ypos) { + debugC(9, kDebugLevelMain, "KyraEngine::wipeDownMouseItem(%d, %d)", xpos, ypos); + if (_itemInHand == -1) + return; + xpos -= 8; + ypos -= 15; + _screen->hideMouse(); + backUpItemRect1(xpos, ypos); + int y = ypos; + int height = 16; + + while (height >= 0) { + restoreItemRect1(xpos, ypos); + _screen->setNewShapeHeight(_shapes[216+_itemInHand], height); + uint32 nextTime = _system->getMillis() + 1 * _tickLength; + _screen->drawShape(0, _shapes[216+_itemInHand], xpos, y, 0, 0); + _screen->updateScreen(); + y += 2; + height -= 2; + delayUntil(nextTime); + } + restoreItemRect1(xpos, ypos); + _screen->resetShapeHeight(_shapes[216+_itemInHand]); + destroyMouseItem(); + _screen->showMouse(); +} + +void KyraEngine::setupSceneItems() { + debugC(9, kDebugLevelMain, "KyraEngine::setupSceneItems()"); + uint16 sceneId = _currentCharacter->sceneId; + assert(sceneId < _roomTableSize); + Room *currentRoom = &_roomTable[sceneId]; + for (int i = 0; i < 12; ++i) { + uint8 item = currentRoom->itemsTable[i]; + if (item == 0xFF || !currentRoom->needInit[i]) + continue; + + int xpos = 0; + int ypos = 0; + + if (currentRoom->itemsXPos[i] == 0xFFFF) { + xpos = currentRoom->itemsXPos[i] = _rnd.getRandomNumberRng(24, 296); + ypos = currentRoom->itemsYPos[i] = _rnd.getRandomNumberRng(_northExitHeight & 0xFF, 130); + } else { + xpos = currentRoom->itemsXPos[i]; + ypos = currentRoom->itemsYPos[i]; + } + + _lastProcessedItem = i; + + int stop = 0; + while (!stop) { + stop = processItemDrop(sceneId, item, xpos, ypos, 3, 0); + if (!stop) { + xpos = currentRoom->itemsXPos[i] = _rnd.getRandomNumberRng(24, 296); + ypos = currentRoom->itemsYPos[i] = _rnd.getRandomNumberRng(_northExitHeight & 0xFF, 130); + if (countItemsInScene(sceneId) >= 12) + break; + } else { + currentRoom->needInit[i] = 0; + } + } + } +} + +int KyraEngine::countItemsInScene(uint16 sceneId) { + debugC(9, kDebugLevelMain, "KyraEngine::countItemsInScene(%d)", sceneId); + assert(sceneId < _roomTableSize); + Room *currentRoom = &_roomTable[sceneId]; + + int items = 0; + + for (int i = 0; i < 12; ++i) { + if (currentRoom->itemsTable[i] != 0xFF) + ++items; + } + + return items; +} + +int KyraEngine::processItemDrop(uint16 sceneId, uint8 item, int x, int y, int unk1, int unk2) { + debugC(9, kDebugLevelMain, "KyraEngine::processItemDrop(%d, %d, %d, %d, %d, %d)", sceneId, item, x, y, unk1, unk2); + int freeItem = -1; + uint8 itemIndex = findItemAtPos(x, y); + if (unk1) + itemIndex = 0xFF; + + if (itemIndex != 0xFF) { + exchangeItemWithMouseItem(sceneId, itemIndex); + return 0; + } + + assert(sceneId < _roomTableSize); + Room *currentRoom = &_roomTable[sceneId]; + + if (unk1 != 3) { + for (int i = 0; i < 12; ++i) { + if (currentRoom->itemsTable[i] == 0xFF) { + freeItem = i; + break; + } + } + } else { + freeItem = _lastProcessedItem; + } + + if (freeItem == -1) + return 0; + + if (sceneId != _currentCharacter->sceneId) { + addItemToRoom(sceneId, item, freeItem, x, y); + return 1; + } + + int itemHeight = _itemTable[item].height; + _lastProcessedItemHeight = itemHeight; + + if (x == -1 && x == -1) { + x = _rnd.getRandomNumberRng(16, 304); + y = _rnd.getRandomNumberRng(_northExitHeight & 0xFF, 135); + } + + int xpos = x; + int ypos = y; + int destY = -1; + int destX = -1; + int running = 1; + + while (running) { + if ((_northExitHeight & 0xFF) <= ypos) { + bool running2 = true; + + if (_screen->getDrawLayer(xpos, ypos) > 1) { + if (((_northExitHeight >> 8) & 0xFF) != ypos) + running2 = false; + } + + if (_screen->getDrawLayer2(xpos, ypos, itemHeight) > 1) { + if (((_northExitHeight >> 8) & 0xFF) != ypos) + running2 = false; + } + + if (!isDropable(xpos, ypos)) { + if (((_northExitHeight >> 8) & 0xFF) != ypos) + running2 = false; + } + + int xpos2 = xpos; + int xpos3 = xpos; + + while (running2) { + if (isDropable(xpos2, ypos)) { + if (_screen->getDrawLayer2(xpos2, ypos, itemHeight) < 7) { + if (findItemAtPos(xpos2, ypos) == 0xFF) { + destX = xpos2; + destY = ypos; + running = 0; + running2 = false; + } + } + } + + if (isDropable(xpos3, ypos)) { + if (_screen->getDrawLayer2(xpos3, ypos, itemHeight) < 7) { + if (findItemAtPos(xpos3, ypos) == 0xFF) { + destX = xpos3; + destY = ypos; + running = 0; + running2 = false; + } + } + } + + if (!running2) + continue; + + xpos2 -= 2; + if (xpos2 < 16) + xpos2 = 16; + + xpos3 += 2; + if (xpos3 > 304) + xpos3 = 304; + + if (xpos2 > 16) + continue; + if (xpos3 < 304) + continue; + running2 = false; + } + } + + if (((_northExitHeight >> 8) & 0xFF) == ypos) { + running = 0; + destY -= _rnd.getRandomNumberRng(0, 3); + + if ((_northExitHeight & 0xFF) < destY) + continue; + + destY = (_northExitHeight & 0xFF) + 1; + continue; + } + ypos += 2; + if (((_northExitHeight >> 8) & 0xFF) >= ypos) + continue; + ypos = (_northExitHeight >> 8) & 0xFF; + } + + if (destX == -1 || destY == -1) + return 0; + + if (unk1 == 3) { + currentRoom->itemsXPos[freeItem] = destX; + currentRoom->itemsYPos[freeItem] = destY; + return 1; + } + + if (unk1 == 2) + itemSpecialFX(x, y, item); + + if (unk1 == 0) + destroyMouseItem(); + + itemDropDown(x, y, destX, destY, freeItem, item); + + if (unk1 == 0 && unk2 != 0) { + assert(_itemList && _droppedList); + updateSentenceCommand(_itemList[item], _droppedList[0], 179); + } + + return 1; +} + +void KyraEngine::exchangeItemWithMouseItem(uint16 sceneId, int itemIndex) { + debugC(9, kDebugLevelMain, "KyraEngine::exchangeItemWithMouseItem(%d, %d)", sceneId, itemIndex); + _screen->hideMouse(); + _animator->animRemoveGameItem(itemIndex); + assert(sceneId < _roomTableSize); + Room *currentRoom = &_roomTable[sceneId]; + + int item = currentRoom->itemsTable[itemIndex]; + currentRoom->itemsTable[itemIndex] = _itemInHand; + _itemInHand = item; + _animator->animAddGameItem(itemIndex, sceneId); + snd_playSoundEffect(53); + + setMouseItem(_itemInHand); + assert(_itemList && _takenList); + updateSentenceCommand(_itemList[_itemInHand], _takenList[1], 179); + _screen->showMouse(); + clickEventHandler2(); +} + +void KyraEngine::addItemToRoom(uint16 sceneId, uint8 item, int itemIndex, int x, int y) { + debugC(9, kDebugLevelMain, "KyraEngine::addItemToRoom(%d, %d, %d, %d, %d)", sceneId, item, itemIndex, x, y); + assert(sceneId < _roomTableSize); + Room *currentRoom = &_roomTable[sceneId]; + currentRoom->itemsTable[itemIndex] = item; + currentRoom->itemsXPos[itemIndex] = x; + currentRoom->itemsYPos[itemIndex] = y; + currentRoom->needInit[itemIndex] = 1; +} + +int KyraEngine::checkNoDropRects(int x, int y) { + debugC(9, kDebugLevelMain, "KyraEngine::checkNoDropRects(%d, %d)", x, y); + if (_lastProcessedItemHeight < 1 || _lastProcessedItemHeight > 16) + _lastProcessedItemHeight = 16; + if (_noDropRects[0].x == -1) + return 0; + + for (int i = 0; i < 11; ++i) { + if (_noDropRects[i].x == -1) + break; + + int xpos = _noDropRects[i].x; + int ypos = _noDropRects[i].y; + int xpos2 = _noDropRects[i].x2; + int ypos2 = _noDropRects[i].y2; + + if (xpos > x + 16) + continue; + if (xpos2 < x) + continue; + if (y < ypos) + continue; + if (ypos2 < y - _lastProcessedItemHeight) + continue; + return 1; + } + + return 0; +} + +int KyraEngine::isDropable(int x, int y) { + debugC(9, kDebugLevelMain, "KyraEngine::isDropable(%d, %d)", x, y); + x -= 8; + y -= 1; + + if (checkNoDropRects(x, y)) + return 0; + + for (int xpos = x; xpos < x + 16; ++xpos) { + if (_screen->getShapeFlag1(xpos, y) == 0) + return 0; + } + return 1; +} + +void KyraEngine::itemDropDown(int x, int y, int destX, int destY, byte freeItem, int item) { + debugC(9, kDebugLevelMain, "KyraEngine::itemDropDown(%d, %d, %d, %d, %d, %d)", x, y, destX, destY, freeItem, item); + assert(_currentCharacter->sceneId < _roomTableSize); + Room *currentRoom = &_roomTable[_currentCharacter->sceneId]; + if (x == destX && y == destY) { + currentRoom->itemsXPos[freeItem] = destX; + currentRoom->itemsYPos[freeItem] = destY; + currentRoom->itemsTable[freeItem] = item; + snd_playSoundEffect(0x32); + _animator->animAddGameItem(freeItem, _currentCharacter->sceneId); + return; + } + _screen->hideMouse(); + if (y <= destY) { + int tempY = y; + int addY = 2; + int drawX = x - 8; + int drawY = 0; + + backUpItemRect0(drawX, y - 16); + + while (tempY < destY) { + restoreItemRect0(drawX, tempY - 16); + tempY += addY; + if (tempY > destY) + tempY = destY; + ++addY; + drawY = tempY - 16; + backUpItemRect0(drawX, drawY); + uint32 nextTime = _system->getMillis() + 1 * _tickLength; + _screen->drawShape(0, _shapes[216+item], drawX, drawY, 0, 0); + _screen->updateScreen(); + delayUntil(nextTime); + } + + bool skip = false; + if (x == destX) { + if (destY - y <= 16) + skip = true; + } + + if (!skip) { + snd_playSoundEffect(0x47); + if (addY < 6) + addY = 6; + + int xDiff = (destX - x) << 4; + xDiff /= addY; + int startAddY = addY; + addY >>= 1; + if (destY - y <= 8) + addY >>= 1; + addY = -addY; + int unkX = x << 4; + while (--startAddY) { + drawX = (unkX >> 4) - 8; + drawY = tempY - 16; + restoreItemRect0(drawX, drawY); + tempY += addY; + unkX += xDiff; + if (tempY > destY) + tempY = destY; + ++addY; + drawX = (unkX >> 4) - 8; + drawY = tempY - 16; + backUpItemRect0(drawX, drawY); + uint32 nextTime = _system->getMillis() + 1 * _tickLength; + _screen->drawShape(0, _shapes[216+item], drawX, drawY, 0, 0); + _screen->updateScreen(); + delayUntil(nextTime); + } + restoreItemRect0(drawX, drawY); + } else { + restoreItemRect0(drawX, tempY - 16); + } + } + currentRoom->itemsXPos[freeItem] = destX; + currentRoom->itemsYPos[freeItem] = destY; + currentRoom->itemsTable[freeItem] = item; + snd_playSoundEffect(0x32); + _animator->animAddGameItem(freeItem, _currentCharacter->sceneId); + _screen->showMouse(); +} + +void KyraEngine::dropItem(int unk1, int item, int x, int y, int unk2) { + debugC(9, kDebugLevelMain, "KyraEngine::dropItem(%d, %d, %d, %d, %d)", unk1, item, x, y, unk2); + if (processItemDrop(_currentCharacter->sceneId, item, x, y, unk1, unk2)) + return; + snd_playSoundEffect(54); + assert(_noDropList); + if (12 == countItemsInScene(_currentCharacter->sceneId)) + drawSentenceCommand(_noDropList[0], 6); + else + drawSentenceCommand(_noDropList[1], 6); +} + +void KyraEngine::itemSpecialFX(int x, int y, int item) { + debugC(9, kDebugLevelMain, "KyraEngine::itemSpecialFX(%d, %d, %d)", x, y, item); + if (item == 41) + itemSpecialFX1(x, y, item); + else + itemSpecialFX2(x, y, item); +} + +void KyraEngine::itemSpecialFX1(int x, int y, int item) { + debugC(9, kDebugLevelMain, "KyraEngine::itemSpecialFX1(%d, %d, %d)", x, y, item); + uint8 *shape = _shapes[216+item]; + x -= 8; + int startY = y; + y -= 15; + _screen->hideMouse(); + backUpItemRect0(x, y); + for (int i = 1; i <= 16; ++i) { + _screen->setNewShapeHeight(shape, i); + --startY; + restoreItemRect0(x, y); + uint32 nextTime = _system->getMillis() + 1 * _tickLength; + _screen->drawShape(0, shape, x, startY, 0, 0); + _screen->updateScreen(); + delayUntil(nextTime); + } + restoreItemRect0(x, y); + _screen->showMouse(); +} + +void KyraEngine::itemSpecialFX2(int x, int y, int item) { + debugC(9, kDebugLevelMain, "KyraEngine::itemSpecialFX2(%d, %d, %d)", x, y, item); + x -= 8; + y -= 15; + int yAdd = (int8)(((16 - _itemTable[item].height) >> 1) & 0xFF); + backUpItemRect0(x, y); + if (item >= 80 && item <= 89) + snd_playSoundEffect(55); + + for (int i = 201; i <= 205; ++i) { + restoreItemRect0(x, y); + uint32 nextTime = _system->getMillis() + 3 * _tickLength; + _screen->drawShape(0, _shapes[i], x, y + yAdd, 0, 0); + _screen->updateScreen(); + delayUntil(nextTime); + } + + for (int i = 204; i >= 201; --i) { + restoreItemRect0(x, y); + uint32 nextTime = _system->getMillis() + 3 * _tickLength; + _screen->drawShape(0, _shapes[216+item], x, y, 0, 0); + _screen->drawShape(0, _shapes[i], x, y + yAdd, 0, 0); + _screen->updateScreen(); + delayUntil(nextTime); + } + restoreItemRect0(x, y); +} + +void KyraEngine::magicOutMouseItem(int animIndex, int itemPos) { + debugC(9, kDebugLevelMain, "KyraEngine::magicOutMouseItem(%d, %d)", animIndex, itemPos); + int videoPageBackUp = _screen->_curPage; + _screen->_curPage = 0; + int x = 0, y = 0; + if (itemPos == -1) { + Common::Point mouse = getMousePos(); + x = mouse.x - 12; + y = mouse.y - 18; + } else { + x = _itemPosX[itemPos] - 4; + y = _itemPosY[itemPos] - 3; + } + + if (_itemInHand == -1 && itemPos == -1) + return; + + int tableIndex = 0, loopStart = 0, maxLoops = 0; + if (animIndex == 0) { + tableIndex = _rnd.getRandomNumberRng(0, 5); + loopStart = 35; + maxLoops = 9; + } else if (animIndex == 1) { + tableIndex = _rnd.getRandomNumberRng(0, 11); + loopStart = 115; + maxLoops = 8; + } else if (animIndex == 2) { + tableIndex = 0; + loopStart = 124; + maxLoops = 4; + } else { + tableIndex = -1; + } + + if (animIndex == 2) + snd_playSoundEffect(0x5E); + else + snd_playSoundEffect(0x37); + _screen->hideMouse(); + backUpItemRect1(x, y); + + for (int shape = _magicMouseItemStartFrame[animIndex]; shape <= _magicMouseItemEndFrame[animIndex]; ++shape) { + restoreItemRect1(x, y); + uint32 nextTime = _system->getMillis() + 4 * _tickLength; + _screen->drawShape(0, _shapes[216+_itemInHand], x + 4, y + 3, 0, 0); + if (tableIndex == -1) + _screen->drawShape(0, _shapes[shape], x, y, 0, 0); + else + specialMouseItemFX(shape, x, y, animIndex, tableIndex, loopStart, maxLoops); + _screen->updateScreen(); + delayUntil(nextTime); + } + + if (itemPos != -1) { + restoreItemRect1(x, y); + _screen->fillRect(_itemPosX[itemPos], _itemPosY[itemPos], _itemPosX[itemPos] + 15, _itemPosY[itemPos] + 15, 12, 0); + backUpItemRect1(x, y); + } + + for (int shape = _magicMouseItemStartFrame2[animIndex]; shape <= _magicMouseItemEndFrame2[animIndex]; ++shape) { + restoreItemRect1(x, y); + uint32 nextTime = _system->getMillis() + 4 * _tickLength; + _screen->drawShape(0, _shapes[216+_itemInHand], x + 4, y + 3, 0, 0); + if (tableIndex == -1) + _screen->drawShape(0, _shapes[shape], x, y, 0, 0); + else + specialMouseItemFX(shape, x, y, animIndex, tableIndex, loopStart, maxLoops); + _screen->updateScreen(); + delayUntil(nextTime); + } + restoreItemRect1(x, y); + if (itemPos == -1) { + _screen->setMouseCursor(1, 1, _shapes[0]); + _itemInHand = -1; + } else { + _characterList[0].inventoryItems[itemPos] = 0xFF; + _screen->hideMouse(); + _screen->fillRect(_itemPosX[itemPos], _itemPosY[itemPos], _itemPosX[itemPos] + 15, _itemPosY[itemPos] + 15, 12, 0); + _screen->showMouse(); + } + _screen->showMouse(); + _screen->_curPage = videoPageBackUp; +} + +void KyraEngine::magicInMouseItem(int animIndex, int item, int itemPos) { + debugC(9, kDebugLevelMain, "KyraEngine::magicInMouseItem(%d, %d, %d)", animIndex, item, itemPos); + int videoPageBackUp = _screen->_curPage; + _screen->_curPage = 0; + int x = 0, y = 0; + if (itemPos == -1) { + Common::Point mouse = getMousePos(); + x = mouse.x - 12; + y = mouse.y - 18; + } else { + x = _itemPosX[itemPos] - 4; + y = _itemPosX[itemPos] - 3; + } + if (item < 0) + return; + + int tableIndex = -1, loopStart = 0, maxLoops = 0; + if (animIndex == 0) { + tableIndex = _rnd.getRandomNumberRng(0, 5); + loopStart = 35; + maxLoops = 9; + } else if (animIndex == 1) { + tableIndex = _rnd.getRandomNumberRng(0, 11); + loopStart = 115; + maxLoops = 8; + } else if (animIndex == 2) { + tableIndex = 0; + loopStart = 124; + maxLoops = 4; + } + + _screen->hideMouse(); + backUpItemRect1(x, y); + if (animIndex == 2) + snd_playSoundEffect(0x5E); + else + snd_playSoundEffect(0x37); + + for (int shape = _magicMouseItemStartFrame[animIndex]; shape <= _magicMouseItemEndFrame[animIndex]; ++shape) { + restoreItemRect1(x, y); + uint32 nextTime = _system->getMillis() + 4 * _tickLength; + if (tableIndex == -1) + _screen->drawShape(0, _shapes[shape], x, y, 0, 0); + else + specialMouseItemFX(shape, x, y, animIndex, tableIndex, loopStart, maxLoops); + _screen->updateScreen(); + delayUntil(nextTime); + } + + for (int shape = _magicMouseItemStartFrame2[animIndex]; shape <= _magicMouseItemEndFrame2[animIndex]; ++shape) { + restoreItemRect1(x, y); + uint32 nextTime = _system->getMillis() + 4 * _tickLength; + if (tableIndex == -1) + _screen->drawShape(0, _shapes[shape], x, y, 0, 0); + else + specialMouseItemFX(shape, x, y, animIndex, tableIndex, loopStart, maxLoops); + _screen->updateScreen(); + delayUntil(nextTime); + } + restoreItemRect1(x, y); + if (itemPos == -1) { + _screen->setMouseCursor(8, 15, _shapes[216+item]); + _itemInHand = item; + } else { + _characterList[0].inventoryItems[itemPos] = item; + _screen->hideMouse(); + _screen->drawShape(0, _shapes[216+item], _itemPosX[itemPos], _itemPosY[itemPos], 0, 0); + _screen->showMouse(); + } + _screen->showMouse(); + _screen->_curPage = videoPageBackUp; +} + +void KyraEngine::specialMouseItemFX(int shape, int x, int y, int animIndex, int tableIndex, int loopStart, int maxLoops) { + debugC(9, kDebugLevelMain, "KyraEngine::specialMouseItemFX(%d, %d, %d, %d, %d, %d, %d)", shape, x, y, animIndex, tableIndex, loopStart, maxLoops); + static const uint8 table1[] = { + 0x23, 0x45, 0x55, 0x72, 0x84, 0xCF, 0x00, 0x00 + }; + static const uint8 table2[] = { + 0x73, 0xB5, 0x80, 0x21, 0x13, 0x39, 0x45, 0x55, 0x62, 0xB4, 0xCF, 0xD8 + }; + static const uint8 table3[] = { + 0x7C, 0xD0, 0x74, 0x84, 0x87, 0x00, 0x00, 0x00 + }; + int tableValue = 0; + if (animIndex == 0) + tableValue = table1[tableIndex]; + else if (animIndex == 1) + tableValue = table2[tableIndex]; + else if (animIndex == 2) + tableValue = table3[tableIndex]; + else + return; + processSpecialMouseItemFX(shape, x, y, tableValue, loopStart, maxLoops); +} + +void KyraEngine::processSpecialMouseItemFX(int shape, int x, int y, int tableValue, int loopStart, int maxLoops) { + debugC(9, kDebugLevelMain, "KyraEngine::processSpecialMouseItemFX(%d, %d, %d, %d, %d, %d)", shape, x, y, tableValue, loopStart, maxLoops); + uint8 shapeColorTable[16]; + uint8 *shapePtr = _shapes[shape] + 10; + if (_flags.useAltShapeHeader) + shapePtr += 2; + + for (int i = 0; i < 16; ++i) + shapeColorTable[i] = shapePtr[i]; + + for (int i = loopStart; i < loopStart + maxLoops; ++i) { + for (int i2 = 0; i2 < 16; ++i2) { + if (shapePtr[i2] == i) + shapeColorTable[i2] = (i + tableValue) - loopStart; + } + } + _screen->drawShape(0, _shapes[shape], x, y, 0, 0x8000, shapeColorTable); +} + +void KyraEngine::updatePlayerItemsForScene() { + debugC(9, kDebugLevelMain, "KyraEngine::updatePlayerItemsForScene()"); + if (_itemInHand >= 29 && _itemInHand < 33) { + ++_itemInHand; + if (_itemInHand > 33) + _itemInHand = 33; + _screen->hideMouse(); + _screen->setMouseCursor(8, 15, _shapes[216+_itemInHand]); + _screen->showMouse(); + } + + bool redraw = false; + for (int i = 0; i < 10; ++i) { + uint8 item = _currentCharacter->inventoryItems[i]; + if (item >= 29 && item < 33) { + ++item; + if (item > 33) + item = 33; + _currentCharacter->inventoryItems[i] = item; + redraw = true; + } + } + + if (redraw) { + _screen->hideMouse(); + redrawInventory(0); + _screen->showMouse(); + } + + if (_itemInHand == 33) + magicOutMouseItem(2, -1); + + _screen->hideMouse(); + for (int i = 0; i < 10; ++i) { + uint8 item = _currentCharacter->inventoryItems[i]; + if (item == 33) + magicOutMouseItem(2, i); + } + _screen->showMouse(); +} + +void KyraEngine::redrawInventory(int page) { + int videoPageBackUp = _screen->_curPage; + _screen->_curPage = page; + _screen->hideMouse(); + for (int i = 0; i < 10; ++i) { + _screen->fillRect(_itemPosX[i], _itemPosY[i], _itemPosX[i] + 15, _itemPosY[i] + 15, 12, page); + if (_currentCharacter->inventoryItems[i] != 0xFF) { + uint8 item = _currentCharacter->inventoryItems[i]; + _screen->drawShape(page, _shapes[216+item], _itemPosX[i], _itemPosY[i], 0, 0); + } + } + _screen->showMouse(); + _screen->_curPage = videoPageBackUp; + _screen->updateScreen(); +} + +void KyraEngine::backUpItemRect0(int xpos, int ypos) { + debugC(9, kDebugLevelMain, "KyraEngine::backUpItemRect0(%d, %d)", xpos, ypos); + _screen->rectClip(xpos, ypos, 3<<3, 24); + _screen->copyRegionToBuffer(_screen->_curPage, xpos, ypos, 3<<3, 24, _itemBkgBackUp[0]); +} + +void KyraEngine::restoreItemRect0(int xpos, int ypos) { + debugC(9, kDebugLevelMain, "KyraEngine::restoreItemRect0(%d, %d)", xpos, ypos); + _screen->rectClip(xpos, ypos, 3<<3, 24); + _screen->copyBlockToPage(_screen->_curPage, xpos, ypos, 3<<3, 24, _itemBkgBackUp[0]); +} + +void KyraEngine::backUpItemRect1(int xpos, int ypos) { + debugC(9, kDebugLevelMain, "KyraEngine::backUpItemRect1(%d, %d)", xpos, ypos); + _screen->rectClip(xpos, ypos, 4<<3, 32); + _screen->copyRegionToBuffer(_screen->_curPage, xpos, ypos, 4<<3, 32, _itemBkgBackUp[1]); +} + +void KyraEngine::restoreItemRect1(int xpos, int ypos) { + debugC(9, kDebugLevelMain, "KyraEngine::restoreItemRect1(%d, %d)", xpos, ypos); + _screen->rectClip(xpos, ypos, 4<<3, 32); + _screen->copyBlockToPage(_screen->_curPage, xpos, ypos, 4<<3, 32, _itemBkgBackUp[1]); +} + +} // end of namespace Kyra + diff --git a/engines/kyra/saveload.cpp b/engines/kyra/saveload.cpp deleted file mode 100644 index 95693684a1..0000000000 --- a/engines/kyra/saveload.cpp +++ /dev/null @@ -1,366 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -#include "common/stdafx.h" -#include "common/endian.h" -#include "common/savefile.h" -#include "common/system.h" - -#include "kyra/kyra.h" -#include "kyra/animator.h" -#include "kyra/screen.h" -#include "kyra/resource.h" -#include "kyra/sound.h" - -#define CURRENT_VERSION 7 - -// TODO: our current savefiles still use the old -// flag system to check the version, we should -// change that some day, but for now it works -#define GF_FLOPPY (1 << 0) -#define GF_TALKIE (1 << 1) -#define GF_FMTOWNS (1 << 2) - -namespace Kyra { -void KyraEngine::loadGame(const char *fileName) { - debugC(9, kDebugLevelMain, "loadGame('%s')", fileName); - Common::InSaveFile *in; - - if (!(in = _saveFileMan->openForLoading(fileName))) { - warning("Can't open file '%s', game not loaded", fileName); - return; - } - - uint32 type = in->readUint32BE(); - - // FIXME: The kyra savegame code used to be endian unsafe. Uncomment the - // following line to graciously handle old savegames from LE machines. - // if (type != MKID_BE('KYRA') && type != MKID_BE('ARYK')) { - if (type != MKID_BE('KYRA')) { - warning("No Kyrandia 1 savefile header"); - delete in; - return; - } - uint32 version = in->readUint32BE(); - if (version > CURRENT_VERSION) { - warning("Savegame is not the right version (%d)", version); - delete in; - return; - } - - char saveName[31]; - in->read(saveName, 31); - - if (version >= 2) { - uint32 flags = in->readUint32BE(); - if ((flags & GF_FLOPPY) && _flags.isTalkie) { - warning("Can not load floppy savefile for this (non floppy) gameversion"); - delete in; - return; - } else if ((flags & GF_TALKIE) && !(_flags.isTalkie)) { - warning("Can not load cdrom savefile for this (non cdrom) gameversion"); - delete in; - return; - } else if ((flags & GF_FMTOWNS) && !(_flags.platform == Common::kPlatformFMTowns)) { - warning("can not load FM-Towns savefile for this (non FM-Towns) gameversion"); - delete in; - return; - } - } else { - warning("Make sure your savefile was from this version! (too old savefile version to detect that)"); - } - - snd_playSoundEffect(0x0A); - snd_playWanderScoreViaMap(0, 1); - - // unload the current voice file should fix some problems with voices - if (_currentRoom != 0xFFFF && _flags.isTalkie) { - char file[32]; - assert(_currentRoom < _roomTableSize); - int tableId = _roomTable[_currentRoom].nameIndex; - assert(tableId < _roomFilenameTableSize); - strcpy(file, _roomFilenameTable[tableId]); - strcat(file, ".VRM"); - _res->unloadPakFile(file); - } - - int brandonX = 0, brandonY = 0; - for (int i = 0; i < 11; i++) { - _characterList[i].sceneId = in->readUint16BE(); - _characterList[i].height = in->readByte(); - _characterList[i].facing = in->readByte(); - _characterList[i].currentAnimFrame = in->readUint16BE(); - //_characterList[i].unk6 = in->readUint32BE(); - in->read(_characterList[i].inventoryItems, 10); - _characterList[i].x1 = in->readSint16BE(); - _characterList[i].y1 = in->readSint16BE(); - _characterList[i].x2 = in->readSint16BE(); - _characterList[i].y2 = in->readSint16BE(); - if (i == 0) { - brandonX = _characterList[i].x1; - brandonY = _characterList[i].y1; - } - //_characterList[i].field_20 = in->readUint16BE(); - //_characterList[i].field_23 = in->readUint16BE(); - } - - _marbleVaseItem = in->readSint16BE(); - _itemInHand = in->readByte(); - - for (int i = 0; i < 4; ++i) - _birthstoneGemTable[i] = in->readByte(); - for (int i = 0; i < 3; ++i) - _idolGemsTable[i] = in->readByte(); - for (int i = 0; i < 3; ++i) - _foyerItemTable[i] = in->readByte(); - _cauldronState = in->readByte(); - for (int i = 0; i < 2; ++i) - _crystalState[i] = in->readByte(); - - _brandonStatusBit = in->readUint16BE(); - _brandonStatusBit0x02Flag = in->readByte(); - _brandonStatusBit0x20Flag = in->readByte(); - in->read(_brandonPoisonFlagsGFX, 256); - _brandonInvFlag = in->readSint16BE(); - _poisonDeathCounter = in->readByte(); - _animator->_brandonDrawFrame = in->readUint16BE(); - - for (int i = 0; i < 32; i++) { - _timers[i].active = in->readByte(); - _timers[i].countdown = in->readSint32BE(); - _timers[i].nextRun = in->readUint32BE(); - if (_timers[i].nextRun != 0) - _timers[i].nextRun += _system->getMillis(); - } - _timerNextRun = 0; - - memset(_flagsTable, 0, sizeof(_flagsTable)); - uint32 flagsSize = in->readUint32BE(); - assert(flagsSize <= sizeof(_flagsTable)); - in->read(_flagsTable, flagsSize); - - for (int i = 0; i < _roomTableSize; ++i) { - for (int item = 0; item < 12; ++item) { - _roomTable[i].itemsTable[item] = 0xFF; - _roomTable[i].itemsXPos[item] = 0xFFFF; - _roomTable[i].itemsYPos[item] = 0xFF; - _roomTable[i].needInit[item] = 0; - } - } - - uint16 sceneId = 0; - - while (true) { - sceneId = in->readUint16BE(); - if (sceneId == 0xFFFF) - break; - assert(sceneId < _roomTableSize); - _roomTable[sceneId].nameIndex = in->readByte(); - - for (int i = 0; i < 12; i++) { - _roomTable[sceneId].itemsTable[i] = in->readByte(); - _roomTable[sceneId].itemsXPos[i] = in->readUint16BE(); - _roomTable[sceneId].itemsYPos[i] = in->readUint16BE(); - _roomTable[sceneId].needInit[i] = in->readByte(); - } - } - if (version >= 3) { - _lastMusicCommand = in->readSint16BE(); - if (_lastMusicCommand != -1) - snd_playWanderScoreViaMap(_lastMusicCommand, 1); - } - - // Version 4 stored settings in the savegame. As of version 5, they are - // handled by the config manager. - - if (version == 4) { - in->readByte(); // Text speed - in->readByte(); // Walk speed - in->readByte(); // Music - in->readByte(); // Sound - in->readByte(); // Voice - } - - if (version >= 7) { - _curSfxFile = in->readByte(); - - // In the first version there this entry was introduced, - // it wasn't made sure that _curSfxFile was initialized - // so if it's out of bounds we just set it to 0. - if (_curSfxFile >= _soundFilesTownsCount || _curSfxFile < 0) - _curSfxFile = 0; - - if (_flags.platform == Common::kPlatformFMTowns) - _sound->loadSoundFile(_curSfxFile); - } - - _screen->_disableScreen = true; - loadMainScreen(8); - - if (queryGameFlag(0x2D)) { - _screen->loadBitmap("AMULET3.CPS", 10, 10, 0); - if (!queryGameFlag(0xF1)) { - for (int i = 0x55; i <= 0x5A; ++i) { - if (queryGameFlag(i)) - seq_createAmuletJewel(i-0x55, 10, 1, 1); - } - } - _screen->copyRegion(0, 0, 0, 0, 320, 200, 10, 8); - _screen->copyRegion(0, 0, 0, 0, 320, 200, 8, 0); - } - - createMouseItem(_itemInHand); - _animator->setBrandonAnimSeqSize(3, 48); - redrawInventory(0); - _animator->_noDrawShapesFlag = 1; - enterNewScene(_currentCharacter->sceneId, _currentCharacter->facing, 0, 0, 1); - _animator->_noDrawShapesFlag = 0; - - _currentCharacter->x1 = brandonX; - _currentCharacter->y1 = brandonY; - _animator->animRefreshNPC(0); - _animator->restoreAllObjectBackgrounds(); - _animator->preserveAnyChangedBackgrounds(); - _animator->prepDrawAllObjects(); - _animator->copyChangedObjectsForward(0); - _screen->copyRegion(8, 8, 8, 8, 304, 128, 2, 0); - _screen->_disableScreen = false; - _screen->updateScreen(); - - _abortWalkFlag = true; - _abortWalkFlag2 = false; - _mousePressFlag = false; - _system->warpMouse(brandonX, brandonY); - - if (in->ioFailed()) - error("Load failed."); - else - debugC(1, kDebugLevelMain, "Loaded savegame '%s.'", saveName); - - // We didn't explicitly set the walk speed, but it's saved as part of - // the _timers array, so we need to re-sync it with _configWalkspeed. - setWalkspeed(_configWalkspeed); - - delete in; -} - -void KyraEngine::saveGame(const char *fileName, const char *saveName) { - debugC(9, kDebugLevelMain, "saveGame('%s', '%s')", fileName, saveName); - Common::OutSaveFile *out; - if (_quitFlag) return; - - if (!(out = _saveFileMan->openForSaving(fileName))) { - warning("Can't create file '%s', game not saved", fileName); - return; - } - - // Savegame version - out->writeUint32BE(MKID_BE('KYRA')); - out->writeUint32BE(CURRENT_VERSION); - out->write(saveName, 31); - if (_flags.isTalkie) - out->writeUint32BE(GF_TALKIE); - else if (_flags.platform == Common::kPlatformFMTowns) - out->writeUint32BE(GF_FMTOWNS); - else - out->writeUint32BE(GF_FLOPPY); - - for (int i = 0; i < 11; i++) { - out->writeUint16BE(_characterList[i].sceneId); - out->writeByte(_characterList[i].height); - out->writeByte(_characterList[i].facing); - out->writeUint16BE(_characterList[i].currentAnimFrame); - //out->writeUint32BE(_characterList[i].unk6); - out->write(_characterList[i].inventoryItems, 10); - out->writeSint16BE(_characterList[i].x1); - out->writeSint16BE(_characterList[i].y1); - out->writeSint16BE(_characterList[i].x2); - out->writeSint16BE(_characterList[i].y2); - //out->writeUint16BE(_characterList[i].field_20); - //out->writeUint16BE(_characterList[i].field_23); - } - - out->writeSint16BE(_marbleVaseItem); - out->writeByte(_itemInHand); - - for (int i = 0; i < 4; ++i) - out->writeByte(_birthstoneGemTable[i]); - for (int i = 0; i < 3; ++i) - out->writeByte(_idolGemsTable[i]); - for (int i = 0; i < 3; ++i) - out->writeByte(_foyerItemTable[i]); - out->writeByte(_cauldronState); - for (int i = 0; i < 2; ++i) - out->writeByte(_crystalState[i]); - - out->writeUint16BE(_brandonStatusBit); - out->writeByte(_brandonStatusBit0x02Flag); - out->writeByte(_brandonStatusBit0x20Flag); - out->write(_brandonPoisonFlagsGFX, 256); - out->writeSint16BE(_brandonInvFlag); - out->writeByte(_poisonDeathCounter); - out->writeUint16BE(_animator->_brandonDrawFrame); - - for (int i = 0; i < 32; i++) { - out->writeByte(_timers[i].active); - out->writeSint32BE(_timers[i].countdown); - if (_system->getMillis() >= _timers[i].nextRun) - out->writeUint32BE(0); - else - out->writeUint32BE(_timers[i].nextRun - _system->getMillis()); - } - - out->writeUint32BE(sizeof(_flagsTable)); - out->write(_flagsTable, sizeof(_flagsTable)); - - for (uint16 i = 0; i < _roomTableSize; i++) { - out->writeUint16BE(i); - out->writeByte(_roomTable[i].nameIndex); - for (int a = 0; a < 12; a++) { - out->writeByte(_roomTable[i].itemsTable[a]); - out->writeUint16BE(_roomTable[i].itemsXPos[a]); - out->writeUint16BE(_roomTable[i].itemsYPos[a]); - out->writeByte(_roomTable[i].needInit[a]); - } - } - // room table terminator - out->writeUint16BE(0xFFFF); - - out->writeSint16BE(_lastMusicCommand); - - out->writeByte(_curSfxFile); - - out->finalize(); - - // check for errors - if (out->ioFailed()) - warning("Can't write file '%s'. (Disk full?)", fileName); - else - debugC(1, kDebugLevelMain, "Saved game '%s.'", saveName); - - delete out; -} -} // end of namespace Kyra - diff --git a/engines/kyra/saveload_v1.cpp b/engines/kyra/saveload_v1.cpp new file mode 100644 index 0000000000..95693684a1 --- /dev/null +++ b/engines/kyra/saveload_v1.cpp @@ -0,0 +1,366 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include "common/stdafx.h" +#include "common/endian.h" +#include "common/savefile.h" +#include "common/system.h" + +#include "kyra/kyra.h" +#include "kyra/animator.h" +#include "kyra/screen.h" +#include "kyra/resource.h" +#include "kyra/sound.h" + +#define CURRENT_VERSION 7 + +// TODO: our current savefiles still use the old +// flag system to check the version, we should +// change that some day, but for now it works +#define GF_FLOPPY (1 << 0) +#define GF_TALKIE (1 << 1) +#define GF_FMTOWNS (1 << 2) + +namespace Kyra { +void KyraEngine::loadGame(const char *fileName) { + debugC(9, kDebugLevelMain, "loadGame('%s')", fileName); + Common::InSaveFile *in; + + if (!(in = _saveFileMan->openForLoading(fileName))) { + warning("Can't open file '%s', game not loaded", fileName); + return; + } + + uint32 type = in->readUint32BE(); + + // FIXME: The kyra savegame code used to be endian unsafe. Uncomment the + // following line to graciously handle old savegames from LE machines. + // if (type != MKID_BE('KYRA') && type != MKID_BE('ARYK')) { + if (type != MKID_BE('KYRA')) { + warning("No Kyrandia 1 savefile header"); + delete in; + return; + } + uint32 version = in->readUint32BE(); + if (version > CURRENT_VERSION) { + warning("Savegame is not the right version (%d)", version); + delete in; + return; + } + + char saveName[31]; + in->read(saveName, 31); + + if (version >= 2) { + uint32 flags = in->readUint32BE(); + if ((flags & GF_FLOPPY) && _flags.isTalkie) { + warning("Can not load floppy savefile for this (non floppy) gameversion"); + delete in; + return; + } else if ((flags & GF_TALKIE) && !(_flags.isTalkie)) { + warning("Can not load cdrom savefile for this (non cdrom) gameversion"); + delete in; + return; + } else if ((flags & GF_FMTOWNS) && !(_flags.platform == Common::kPlatformFMTowns)) { + warning("can not load FM-Towns savefile for this (non FM-Towns) gameversion"); + delete in; + return; + } + } else { + warning("Make sure your savefile was from this version! (too old savefile version to detect that)"); + } + + snd_playSoundEffect(0x0A); + snd_playWanderScoreViaMap(0, 1); + + // unload the current voice file should fix some problems with voices + if (_currentRoom != 0xFFFF && _flags.isTalkie) { + char file[32]; + assert(_currentRoom < _roomTableSize); + int tableId = _roomTable[_currentRoom].nameIndex; + assert(tableId < _roomFilenameTableSize); + strcpy(file, _roomFilenameTable[tableId]); + strcat(file, ".VRM"); + _res->unloadPakFile(file); + } + + int brandonX = 0, brandonY = 0; + for (int i = 0; i < 11; i++) { + _characterList[i].sceneId = in->readUint16BE(); + _characterList[i].height = in->readByte(); + _characterList[i].facing = in->readByte(); + _characterList[i].currentAnimFrame = in->readUint16BE(); + //_characterList[i].unk6 = in->readUint32BE(); + in->read(_characterList[i].inventoryItems, 10); + _characterList[i].x1 = in->readSint16BE(); + _characterList[i].y1 = in->readSint16BE(); + _characterList[i].x2 = in->readSint16BE(); + _characterList[i].y2 = in->readSint16BE(); + if (i == 0) { + brandonX = _characterList[i].x1; + brandonY = _characterList[i].y1; + } + //_characterList[i].field_20 = in->readUint16BE(); + //_characterList[i].field_23 = in->readUint16BE(); + } + + _marbleVaseItem = in->readSint16BE(); + _itemInHand = in->readByte(); + + for (int i = 0; i < 4; ++i) + _birthstoneGemTable[i] = in->readByte(); + for (int i = 0; i < 3; ++i) + _idolGemsTable[i] = in->readByte(); + for (int i = 0; i < 3; ++i) + _foyerItemTable[i] = in->readByte(); + _cauldronState = in->readByte(); + for (int i = 0; i < 2; ++i) + _crystalState[i] = in->readByte(); + + _brandonStatusBit = in->readUint16BE(); + _brandonStatusBit0x02Flag = in->readByte(); + _brandonStatusBit0x20Flag = in->readByte(); + in->read(_brandonPoisonFlagsGFX, 256); + _brandonInvFlag = in->readSint16BE(); + _poisonDeathCounter = in->readByte(); + _animator->_brandonDrawFrame = in->readUint16BE(); + + for (int i = 0; i < 32; i++) { + _timers[i].active = in->readByte(); + _timers[i].countdown = in->readSint32BE(); + _timers[i].nextRun = in->readUint32BE(); + if (_timers[i].nextRun != 0) + _timers[i].nextRun += _system->getMillis(); + } + _timerNextRun = 0; + + memset(_flagsTable, 0, sizeof(_flagsTable)); + uint32 flagsSize = in->readUint32BE(); + assert(flagsSize <= sizeof(_flagsTable)); + in->read(_flagsTable, flagsSize); + + for (int i = 0; i < _roomTableSize; ++i) { + for (int item = 0; item < 12; ++item) { + _roomTable[i].itemsTable[item] = 0xFF; + _roomTable[i].itemsXPos[item] = 0xFFFF; + _roomTable[i].itemsYPos[item] = 0xFF; + _roomTable[i].needInit[item] = 0; + } + } + + uint16 sceneId = 0; + + while (true) { + sceneId = in->readUint16BE(); + if (sceneId == 0xFFFF) + break; + assert(sceneId < _roomTableSize); + _roomTable[sceneId].nameIndex = in->readByte(); + + for (int i = 0; i < 12; i++) { + _roomTable[sceneId].itemsTable[i] = in->readByte(); + _roomTable[sceneId].itemsXPos[i] = in->readUint16BE(); + _roomTable[sceneId].itemsYPos[i] = in->readUint16BE(); + _roomTable[sceneId].needInit[i] = in->readByte(); + } + } + if (version >= 3) { + _lastMusicCommand = in->readSint16BE(); + if (_lastMusicCommand != -1) + snd_playWanderScoreViaMap(_lastMusicCommand, 1); + } + + // Version 4 stored settings in the savegame. As of version 5, they are + // handled by the config manager. + + if (version == 4) { + in->readByte(); // Text speed + in->readByte(); // Walk speed + in->readByte(); // Music + in->readByte(); // Sound + in->readByte(); // Voice + } + + if (version >= 7) { + _curSfxFile = in->readByte(); + + // In the first version there this entry was introduced, + // it wasn't made sure that _curSfxFile was initialized + // so if it's out of bounds we just set it to 0. + if (_curSfxFile >= _soundFilesTownsCount || _curSfxFile < 0) + _curSfxFile = 0; + + if (_flags.platform == Common::kPlatformFMTowns) + _sound->loadSoundFile(_curSfxFile); + } + + _screen->_disableScreen = true; + loadMainScreen(8); + + if (queryGameFlag(0x2D)) { + _screen->loadBitmap("AMULET3.CPS", 10, 10, 0); + if (!queryGameFlag(0xF1)) { + for (int i = 0x55; i <= 0x5A; ++i) { + if (queryGameFlag(i)) + seq_createAmuletJewel(i-0x55, 10, 1, 1); + } + } + _screen->copyRegion(0, 0, 0, 0, 320, 200, 10, 8); + _screen->copyRegion(0, 0, 0, 0, 320, 200, 8, 0); + } + + createMouseItem(_itemInHand); + _animator->setBrandonAnimSeqSize(3, 48); + redrawInventory(0); + _animator->_noDrawShapesFlag = 1; + enterNewScene(_currentCharacter->sceneId, _currentCharacter->facing, 0, 0, 1); + _animator->_noDrawShapesFlag = 0; + + _currentCharacter->x1 = brandonX; + _currentCharacter->y1 = brandonY; + _animator->animRefreshNPC(0); + _animator->restoreAllObjectBackgrounds(); + _animator->preserveAnyChangedBackgrounds(); + _animator->prepDrawAllObjects(); + _animator->copyChangedObjectsForward(0); + _screen->copyRegion(8, 8, 8, 8, 304, 128, 2, 0); + _screen->_disableScreen = false; + _screen->updateScreen(); + + _abortWalkFlag = true; + _abortWalkFlag2 = false; + _mousePressFlag = false; + _system->warpMouse(brandonX, brandonY); + + if (in->ioFailed()) + error("Load failed."); + else + debugC(1, kDebugLevelMain, "Loaded savegame '%s.'", saveName); + + // We didn't explicitly set the walk speed, but it's saved as part of + // the _timers array, so we need to re-sync it with _configWalkspeed. + setWalkspeed(_configWalkspeed); + + delete in; +} + +void KyraEngine::saveGame(const char *fileName, const char *saveName) { + debugC(9, kDebugLevelMain, "saveGame('%s', '%s')", fileName, saveName); + Common::OutSaveFile *out; + if (_quitFlag) return; + + if (!(out = _saveFileMan->openForSaving(fileName))) { + warning("Can't create file '%s', game not saved", fileName); + return; + } + + // Savegame version + out->writeUint32BE(MKID_BE('KYRA')); + out->writeUint32BE(CURRENT_VERSION); + out->write(saveName, 31); + if (_flags.isTalkie) + out->writeUint32BE(GF_TALKIE); + else if (_flags.platform == Common::kPlatformFMTowns) + out->writeUint32BE(GF_FMTOWNS); + else + out->writeUint32BE(GF_FLOPPY); + + for (int i = 0; i < 11; i++) { + out->writeUint16BE(_characterList[i].sceneId); + out->writeByte(_characterList[i].height); + out->writeByte(_characterList[i].facing); + out->writeUint16BE(_characterList[i].currentAnimFrame); + //out->writeUint32BE(_characterList[i].unk6); + out->write(_characterList[i].inventoryItems, 10); + out->writeSint16BE(_characterList[i].x1); + out->writeSint16BE(_characterList[i].y1); + out->writeSint16BE(_characterList[i].x2); + out->writeSint16BE(_characterList[i].y2); + //out->writeUint16BE(_characterList[i].field_20); + //out->writeUint16BE(_characterList[i].field_23); + } + + out->writeSint16BE(_marbleVaseItem); + out->writeByte(_itemInHand); + + for (int i = 0; i < 4; ++i) + out->writeByte(_birthstoneGemTable[i]); + for (int i = 0; i < 3; ++i) + out->writeByte(_idolGemsTable[i]); + for (int i = 0; i < 3; ++i) + out->writeByte(_foyerItemTable[i]); + out->writeByte(_cauldronState); + for (int i = 0; i < 2; ++i) + out->writeByte(_crystalState[i]); + + out->writeUint16BE(_brandonStatusBit); + out->writeByte(_brandonStatusBit0x02Flag); + out->writeByte(_brandonStatusBit0x20Flag); + out->write(_brandonPoisonFlagsGFX, 256); + out->writeSint16BE(_brandonInvFlag); + out->writeByte(_poisonDeathCounter); + out->writeUint16BE(_animator->_brandonDrawFrame); + + for (int i = 0; i < 32; i++) { + out->writeByte(_timers[i].active); + out->writeSint32BE(_timers[i].countdown); + if (_system->getMillis() >= _timers[i].nextRun) + out->writeUint32BE(0); + else + out->writeUint32BE(_timers[i].nextRun - _system->getMillis()); + } + + out->writeUint32BE(sizeof(_flagsTable)); + out->write(_flagsTable, sizeof(_flagsTable)); + + for (uint16 i = 0; i < _roomTableSize; i++) { + out->writeUint16BE(i); + out->writeByte(_roomTable[i].nameIndex); + for (int a = 0; a < 12; a++) { + out->writeByte(_roomTable[i].itemsTable[a]); + out->writeUint16BE(_roomTable[i].itemsXPos[a]); + out->writeUint16BE(_roomTable[i].itemsYPos[a]); + out->writeByte(_roomTable[i].needInit[a]); + } + } + // room table terminator + out->writeUint16BE(0xFFFF); + + out->writeSint16BE(_lastMusicCommand); + + out->writeByte(_curSfxFile); + + out->finalize(); + + // check for errors + if (out->ioFailed()) + warning("Can't write file '%s'. (Disk full?)", fileName); + else + debugC(1, kDebugLevelMain, "Saved game '%s.'", saveName); + + delete out; +} +} // end of namespace Kyra + diff --git a/engines/kyra/scene.cpp b/engines/kyra/scene.cpp deleted file mode 100644 index a92fd9ce7c..0000000000 --- a/engines/kyra/scene.cpp +++ /dev/null @@ -1,1624 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -#include "kyra/kyra.h" -#include "kyra/seqplayer.h" -#include "kyra/screen.h" -#include "kyra/resource.h" -#include "kyra/sound.h" -#include "kyra/sprites.h" -#include "kyra/wsamovie.h" -#include "kyra/animator.h" -#include "kyra/text.h" -#include "kyra/script.h" - -#include "common/system.h" -#include "common/savefile.h" - -namespace Kyra { - -void KyraEngine::enterNewScene(int sceneId, int facing, int unk1, int unk2, int brandonAlive) { - debugC(9, kDebugLevelMain, "KyraEngine::enterNewScene(%d, %d, %d, %d, %d)", sceneId, facing, unk1, unk2, brandonAlive); - int unkVar1 = 1; - _screen->hideMouse(); - _handleInput = false; - _abortWalkFlag = false; - _abortWalkFlag2 = false; - - if (_flags.platform == Common::kPlatformFMTowns) { - int newSfxFile = -1; - if (_currentCharacter->sceneId == 7 && sceneId == 24) - newSfxFile = 2; - else if (_currentCharacter->sceneId == 25 && sceneId == 109) - newSfxFile = 3; - else if (_currentCharacter->sceneId == 120 && sceneId == 37) - newSfxFile = 4; - else if (_currentCharacter->sceneId == 52 && sceneId == 199) - newSfxFile = 5; - else if (_currentCharacter->sceneId == 37 && sceneId == 120) - newSfxFile = 3; - else if (_currentCharacter->sceneId == 109 && sceneId == 25) - newSfxFile = 2; - else if (_currentCharacter->sceneId == 24 && sceneId == 7) - newSfxFile = 1; - - if (newSfxFile != -1) { - _curSfxFile = newSfxFile; - _sound->loadSoundFile(_curSfxFile); - } - } - - switch (_currentCharacter->sceneId) { - case 1: - if (sceneId == 0) { - moveCharacterToPos(0, 0, _currentCharacter->x1, 84); - unkVar1 = 0; - } - break; - - case 3: - if (sceneId == 2) { - moveCharacterToPos(0, 6, 155, _currentCharacter->y1); - unkVar1 = 0; - } - break; - - case 26: - if (sceneId == 27) { - moveCharacterToPos(0, 6, 155, _currentCharacter->y1); - unkVar1 = 0; - } - break; - - case 44: - if (sceneId == 45) { - moveCharacterToPos(0, 2, 192, _currentCharacter->y1); - unkVar1 = 0; - } - break; - - default: - break; - } - - if (unkVar1 && unk1) { - int xpos = _currentCharacter->x1; - int ypos = _currentCharacter->y1; - switch (facing) { - case 0: - ypos = _currentCharacter->y1 - 6; - break; - - case 2: - xpos = 336; - break; - - case 4: - ypos = 143; - break; - - case 6: - xpos = -16; - break; - - default: - break; - } - - moveCharacterToPos(0, facing, xpos, ypos); - } - - for (int i = 0; i < ARRAYSIZE(_movieObjects); ++i) - _movieObjects[i]->close(); - - if (!brandonAlive) { - _scriptInterpreter->initScript(_scriptClick, _scriptClickData); - _scriptInterpreter->startScript(_scriptClick, 5); - while (_scriptInterpreter->validScript(_scriptClick)) - _scriptInterpreter->runScript(_scriptClick); - } - - memset(_entranceMouseCursorTracks, 0xFFFF, sizeof(uint16)*4); - _currentCharacter->sceneId = sceneId; - - assert(sceneId < _roomTableSize); - assert(_roomTable[sceneId].nameIndex < _roomFilenameTableSize); - - Room *currentRoom = &_roomTable[sceneId]; - - setupSceneResource(sceneId); - - _currentRoom = sceneId; - - int tableId = _roomTable[sceneId].nameIndex; - char fileNameBuffer[32]; - strcpy(fileNameBuffer, _roomFilenameTable[tableId]); - strcat(fileNameBuffer, ".DAT"); - _sprites->loadDat(fileNameBuffer, _sceneExits); - _sprites->setupSceneAnims(); - _scriptInterpreter->unloadScript(_scriptClickData); - loadSceneMsc(); - - _walkBlockNorth = currentRoom->northExit; - _walkBlockEast = currentRoom->eastExit; - _walkBlockSouth = currentRoom->southExit; - _walkBlockWest = currentRoom->westExit; - - if (_walkBlockNorth == 0xFFFF) - _screen->blockOutRegion(0, 0, 320, (_northExitHeight & 0xFF)+3); - if (_walkBlockEast == 0xFFFF) - _screen->blockOutRegion(312, 0, 8, 139); - if (_walkBlockSouth == 0xFFFF) - _screen->blockOutRegion(0, 135, 320, 8); - if (_walkBlockWest == 0xFFFF) - _screen->blockOutRegion(0, 0, 8, 139); - - if (!brandonAlive) - updatePlayerItemsForScene(); - - startSceneScript(brandonAlive); - setupSceneItems(); - - initSceneData(facing, unk2, brandonAlive); - - _loopFlag2 = 0; - _screen->showMouse(); - if (!brandonAlive) - seq_poisonDeathNow(0); - updateMousePointer(true); - _changedScene = true; -} - -void KyraEngine::transcendScenes(int roomIndex, int roomName) { - debugC(9, kDebugLevelMain, "KyraEngine::transcendScenes(%d, %d)", roomIndex, roomName); - assert(roomIndex < _roomTableSize); - - if (_flags.isTalkie) { - char file[32]; - assert(roomIndex < _roomTableSize); - int tableId = _roomTable[roomIndex].nameIndex; - assert(tableId < _roomFilenameTableSize); - strcpy(file, _roomFilenameTable[tableId]); - strcat(file, ".VRM"); - _res->unloadPakFile(file); - } - - _roomTable[roomIndex].nameIndex = roomName; - _unkScreenVar2 = 1; - _unkScreenVar3 = 1; - _unkScreenVar1 = 0; - _brandonPosX = _currentCharacter->x1; - _brandonPosY = _currentCharacter->y1; - enterNewScene(roomIndex, _currentCharacter->facing, 0, 0, 0); - _unkScreenVar1 = 1; - _unkScreenVar2 = 0; - _unkScreenVar3 = 0; -} - -void KyraEngine::setSceneFile(int roomIndex, int roomName) { - debugC(9, kDebugLevelMain, "KyraEngine::setSceneFile(%d, %d)", roomIndex, roomName); - assert(roomIndex < _roomTableSize); - _roomTable[roomIndex].nameIndex = roomName; -} - -void KyraEngine::moveCharacterToPos(int character, int facing, int xpos, int ypos) { - debugC(9, kDebugLevelMain, "KyraEngine::moveCharacterToPos(%d, %d, %d, %d)", character, facing, xpos, ypos); - Character *ch = &_characterList[character]; - ch->facing = facing; - _screen->hideMouse(); - xpos = (int16)(xpos & 0xFFFC); - ypos = (int16)(ypos & 0xFFFE); - disableTimer(19); - disableTimer(14); - disableTimer(18); - uint32 nextFrame = 0; - - switch (facing) { - case 0: - while (ypos < ch->y1) { - nextFrame = getTimerDelay(5 + character) * _tickLength + _system->getMillis(); - setCharacterPositionWithUpdate(character); - delayUntil(nextFrame, true); - } - break; - - case 2: - while (ch->x1 < xpos) { - nextFrame = getTimerDelay(5 + character) * _tickLength + _system->getMillis(); - setCharacterPositionWithUpdate(character); - delayUntil(nextFrame, true); - } - break; - - case 4: - while (ypos > ch->y1) { - nextFrame = getTimerDelay(5 + character) * _tickLength + _system->getMillis(); - setCharacterPositionWithUpdate(character); - delayUntil(nextFrame, true); - } - break; - - case 6: - while (ch->x1 > xpos) { - nextFrame = getTimerDelay(5 + character) * _tickLength + _system->getMillis(); - setCharacterPositionWithUpdate(character); - delayUntil(nextFrame, true); - } - break; - - default: - break; - } - - enableTimer(19); - enableTimer(14); - enableTimer(18); - _screen->showMouse(); -} - -void KyraEngine::setCharacterPositionWithUpdate(int character) { - debugC(9, kDebugLevelMain, "KyraEngine::setCharacterPositionWithUpdate(%d)", character); - setCharacterPosition(character, 0); - _sprites->updateSceneAnims(); - updateGameTimers(); - _animator->updateAllObjectShapes(); - updateTextFade(); - - if (_currentCharacter->sceneId == 210) - updateKyragemFading(); -} - -int KyraEngine::setCharacterPosition(int character, int *facingTable) { - debugC(9, kDebugLevelMain, "KyraEngine::setCharacterPosition(%d, %p)", character, (const void *)facingTable); - - if (character == 0) { - _currentCharacter->x1 += _charXPosTable[_currentCharacter->facing]; - _currentCharacter->y1 += _charYPosTable[_currentCharacter->facing]; - setCharacterPositionHelper(0, facingTable); - return 1; - } else { - _characterList[character].x1 += _charXPosTable[_characterList[character].facing]; - _characterList[character].y1 += _charYPosTable[_characterList[character].facing]; - if (_characterList[character].sceneId == _currentCharacter->sceneId) - setCharacterPositionHelper(character, 0); - } - return 0; -} - -void KyraEngine::setCharacterPositionHelper(int character, int *facingTable) { - debugC(9, kDebugLevelMain, "KyraEngine::setCharacterPositionHelper(%d, %p)", character, (const void *)facingTable); - Character *ch = &_characterList[character]; - ++ch->currentAnimFrame; - int facing = ch->facing; - if (facingTable) { - if (*facingTable != *(facingTable - 1)) { - if (*(facingTable - 1) == *(facingTable + 1)) { - facing = getOppositeFacingDirection(*(facingTable - 1)); - *facingTable = *(facingTable - 1); - } - } - } - - static uint8 facingIsZero[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; - static uint8 facingIsFour[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; - - if (facing == 0) { - ++facingIsZero[character]; - } else { - bool resetTables = false; - if (facing != 7) { - if (facing - 1 != 0) { - if (facing != 4) { - if (facing == 3 || facing == 5) { - if (facingIsFour[character] > 2) - facing = 4; - resetTables = true; - } - } else { - ++facingIsFour[character]; - } - } else { - if (facingIsZero[character] > 2) - facing = 0; - resetTables = true; - } - } else { - if (facingIsZero[character] > 2) - facing = 0; - resetTables = true; - } - - if (resetTables) { - facingIsZero[character] = 0; - facingIsFour[character] = 0; - } - } - - static const uint16 maxAnimationFrame[] = { - 0x000F, 0x0031, 0x0055, 0x0000, 0x0000, 0x0000, - 0x0008, 0x002A, 0x004E, 0x0000, 0x0000, 0x0000, - 0x0022, 0x0046, 0x006A, 0x0000, 0x0000, 0x0000, - 0x001D, 0x0041, 0x0065, 0x0000, 0x0000, 0x0000, - 0x001F, 0x0043, 0x0067, 0x0000, 0x0000, 0x0000, - 0x0028, 0x004C, 0x0070, 0x0000, 0x0000, 0x0000, - 0x0023, 0x0047, 0x006B, 0x0000, 0x0000, 0x0000 - }; - - if (facing == 0) { - if (maxAnimationFrame[36+character] > ch->currentAnimFrame) - ch->currentAnimFrame = maxAnimationFrame[36+character]; - if (maxAnimationFrame[30+character] < ch->currentAnimFrame) - ch->currentAnimFrame = maxAnimationFrame[36+character]; - } else if (facing == 4) { - if (maxAnimationFrame[18+character] > ch->currentAnimFrame) - ch->currentAnimFrame = maxAnimationFrame[18+character]; - if (maxAnimationFrame[12+character] < ch->currentAnimFrame) - ch->currentAnimFrame = maxAnimationFrame[18+character]; - } else { - if (maxAnimationFrame[18+character] < ch->currentAnimFrame) - ch->currentAnimFrame = maxAnimationFrame[30+character]; - if (maxAnimationFrame[character] == ch->currentAnimFrame) - ch->currentAnimFrame = maxAnimationFrame[6+character]; - if (maxAnimationFrame[character] < ch->currentAnimFrame) - ch->currentAnimFrame = maxAnimationFrame[6+character]+2; - } - - if (character == 0 && (_brandonStatusBit & 0x10)) - ch->currentAnimFrame = 88; - - _animator->animRefreshNPC(character); -} - -int KyraEngine::getOppositeFacingDirection(int dir) { - debugC(9, kDebugLevelMain, "KyraEngine::getOppositeFacingDirection(%d)", dir); - switch (dir) { - case 0: - return 2; - case 1: - return 1; - case 3: - return 7; - case 4: - return 6; - case 5: - return 5; - case 6: - return 4; - case 7: - return 3; - default: - break; - } - return 0; -} - -void KyraEngine::loadSceneMsc() { - assert(_currentCharacter->sceneId < _roomTableSize); - int tableId = _roomTable[_currentCharacter->sceneId].nameIndex; - assert(tableId < _roomFilenameTableSize); - char fileNameBuffer[32]; - strcpy(fileNameBuffer, _roomFilenameTable[tableId]); - strcat(fileNameBuffer, ".MSC"); - _screen->fillRect(0, 0, 319, 199, 0, 5); - _screen->loadBitmap(fileNameBuffer, 3, 5, 0); -} - -void KyraEngine::startSceneScript(int brandonAlive) { - debugC(9, kDebugLevelMain, "KyraEngine::startSceneScript(%d)", brandonAlive); - assert(_currentCharacter->sceneId < _roomTableSize); - int tableId = _roomTable[_currentCharacter->sceneId].nameIndex; - assert(tableId < _roomFilenameTableSize); - char fileNameBuffer[32]; - strcpy(fileNameBuffer, _roomFilenameTable[tableId]); - strcat(fileNameBuffer, ".CPS"); - _screen->clearPage(3); - // FIXME: check this hack for amiga version - _screen->loadBitmap(fileNameBuffer, 3, 3, (_flags.platform == Common::kPlatformAmiga ? _screen->getPalette(0) : 0)); - _sprites->loadSceneShapes(); - _exitListPtr = 0; - - _scaleMode = 1; - for (int i = 0; i < 145; ++i) - _scaleTable[i] = 256; - - clearNoDropRects(); - _scriptInterpreter->initScript(_scriptClick, _scriptClickData); - strcpy(fileNameBuffer, _roomFilenameTable[tableId]); - strcat(fileNameBuffer, ".EMC"); - _scriptInterpreter->unloadScript(_scriptClickData); - _scriptInterpreter->loadScript(fileNameBuffer, _scriptClickData, &_opcodes); - _scriptInterpreter->startScript(_scriptClick, 0); - _scriptClick->regs[0] = _currentCharacter->sceneId; - _scriptClick->regs[7] = brandonAlive; - - while (_scriptInterpreter->validScript(_scriptClick)) - _scriptInterpreter->runScript(_scriptClick); -} - -void KyraEngine::initSceneData(int facing, int unk1, int brandonAlive) { - debugC(9, kDebugLevelMain, "KyraEngine::initSceneData(%d, %d, %d)", facing, unk1, brandonAlive); - - int16 xpos2 = 0; - int setFacing = 1; - - int16 xpos = 0, ypos = 0; - - if (_brandonPosX == -1 && _brandonPosY == -1) { - switch (facing + 1) { - case 0: - xpos = ypos = -1; - break; - - case 1: case 2: case 8: - xpos = _sceneExits.southXPos; - ypos = _sceneExits.southYPos; - break; - - case 3: - xpos = _sceneExits.westXPos; - ypos = _sceneExits.westYPos; - break; - - case 4: case 5: case 6: - xpos = _sceneExits.northXPos; - ypos = _sceneExits.northYPos; - break; - - case 7: - xpos = _sceneExits.eastXPos; - ypos = _sceneExits.eastYPos; - break; - - default: - break; - } - - if ((uint8)(_northExitHeight & 0xFF) + 2 >= ypos) - ypos = (_northExitHeight & 0xFF) + 4; - if (xpos >= 308) - xpos = 304; - if ((uint8)(_northExitHeight >> 8) - 2 <= ypos) - ypos = (_northExitHeight >> 8) - 4; - if (xpos <= 12) - xpos = 16; - } - - if (_brandonPosX > -1) - xpos = _brandonPosX; - if (_brandonPosY > -1) - ypos = _brandonPosY; - - int16 ypos2 = 0; - if (_brandonPosX > -1 && _brandonPosY > -1) { - switch (_currentCharacter->sceneId) { - case 1: - _currentCharacter->x1 = xpos; - _currentCharacter->x2 = xpos; - _currentCharacter->y1 = ypos; - _currentCharacter->y2 = ypos; - facing = 4; - xpos2 = 192; - ypos2 = 104; - setFacing = 0; - unk1 = 1; - break; - - case 3: - _currentCharacter->x1 = xpos; - _currentCharacter->x2 = xpos; - _currentCharacter->y1 = ypos; - _currentCharacter->y2 = ypos; - facing = 2; - xpos2 = 204; - ypos2 = 94; - setFacing = 0; - unk1 = 1; - break; - - case 26: - _currentCharacter->x1 = xpos; - _currentCharacter->x2 = xpos; - _currentCharacter->y1 = ypos; - _currentCharacter->y2 = ypos; - facing = 2; - xpos2 = 192; - ypos2 = 128; - setFacing = 0; - unk1 = 1; - break; - - case 44: - _currentCharacter->x1 = xpos; - _currentCharacter->x2 = xpos; - _currentCharacter->y1 = ypos; - _currentCharacter->y2 = ypos; - facing = 6; - xpos2 = 156; - ypos2 = 96; - setFacing = 0; - unk1 = 1; - break; - - case 37: - _currentCharacter->x1 = xpos; - _currentCharacter->x2 = xpos; - _currentCharacter->y1 = ypos; - _currentCharacter->y2 = ypos; - facing = 2; - xpos2 = 148; - ypos2 = 114; - setFacing = 0; - unk1 = 1; - break; - - default: - break; - } - } - - _brandonPosX = _brandonPosY = -1; - - if (unk1 && setFacing) { - ypos2 = ypos; - xpos2 = xpos; - switch (facing) { - case 0: - ypos = 142; - break; - - case 2: - xpos = -16; - break; - - case 4: - ypos = (uint8)(_northExitHeight & 0xFF) - 4; - break; - - case 6: - xpos = 336; - break; - - default: - break; - } - } - - xpos2 = (int16)(xpos2 & 0xFFFC); - ypos2 = (int16)(ypos2 & 0xFFFE); - xpos = (int16)(xpos & 0xFFFC); - ypos = (int16)(ypos & 0xFFFE); - _currentCharacter->facing = facing; - _currentCharacter->x1 = xpos; - _currentCharacter->x2 = xpos; - _currentCharacter->y1 = ypos; - _currentCharacter->y2 = ypos; - - initSceneObjectList(brandonAlive); - - if (unk1 && brandonAlive == 0) - moveCharacterToPos(0, facing, xpos2, ypos2); - - _scriptClick->regs[4] = _itemInHand; - _scriptClick->regs[7] = brandonAlive; - _scriptInterpreter->startScript(_scriptClick, 3); - while (_scriptInterpreter->validScript(_scriptClick)) - _scriptInterpreter->runScript(_scriptClick); -} - -void KyraEngine::initSceneObjectList(int brandonAlive) { - debugC(9, kDebugLevelMain, "KyraEngine::initSceneObjectList(%d)", brandonAlive); - for (int i = 0; i < 28; ++i) - _animator->actors()[i].active = 0; - - int startAnimFrame = 0; - - AnimObject *curAnimState = _animator->actors(); - curAnimState->active = 1; - curAnimState->drawY = _currentCharacter->y1; - curAnimState->sceneAnimPtr = _shapes[_currentCharacter->currentAnimFrame]; - curAnimState->animFrameNumber = _currentCharacter->currentAnimFrame; - startAnimFrame = _currentCharacter->currentAnimFrame-7; - int xOffset = _defaultShapeTable[startAnimFrame].xOffset; - int yOffset = _defaultShapeTable[startAnimFrame].yOffset; - - if (_scaleMode) { - curAnimState->x1 = _currentCharacter->x1; - curAnimState->y1 = _currentCharacter->y1; - - _animator->_brandonScaleX = _scaleTable[_currentCharacter->y1]; - _animator->_brandonScaleY = _scaleTable[_currentCharacter->y1]; - - curAnimState->x1 += (_animator->_brandonScaleX * xOffset) >> 8; - curAnimState->y1 += (_animator->_brandonScaleY * yOffset) >> 8; - } else { - curAnimState->x1 = _currentCharacter->x1 + xOffset; - curAnimState->y1 = _currentCharacter->y1 + yOffset; - } - - curAnimState->x2 = curAnimState->x1; - curAnimState->y2 = curAnimState->y1; - curAnimState->refreshFlag = 1; - curAnimState->bkgdChangeFlag = 1; - _animator->clearQueue(); - _animator->addObjectToQueue(curAnimState); - - int listAdded = 0; - int addedObjects = 1; - - for (int i = 1; i < 5; ++i) { - Character *ch = &_characterList[i]; - curAnimState = &_animator->actors()[addedObjects]; - if (ch->sceneId != _currentCharacter->sceneId) { - curAnimState->active = 0; - curAnimState->refreshFlag = 0; - curAnimState->bkgdChangeFlag = 0; - ++addedObjects; - continue; - } - - curAnimState->drawY = ch->y1; - curAnimState->sceneAnimPtr = _shapes[ch->currentAnimFrame]; - curAnimState->animFrameNumber = ch->currentAnimFrame; - startAnimFrame = ch->currentAnimFrame-7; - xOffset = _defaultShapeTable[startAnimFrame].xOffset; - yOffset = _defaultShapeTable[startAnimFrame].yOffset; - if (_scaleMode) { - curAnimState->x1 = ch->x1; - curAnimState->y1 = ch->y1; - - _animator->_brandonScaleX = _scaleTable[ch->y1]; - _animator->_brandonScaleY = _scaleTable[ch->y1]; - - curAnimState->x1 += (_animator->_brandonScaleX * xOffset) >> 8; - curAnimState->y1 += (_animator->_brandonScaleY * yOffset) >> 8; - } else { - curAnimState->x1 = ch->x1 + xOffset; - curAnimState->y1 = ch->y1 + yOffset; - } - curAnimState->x2 = curAnimState->x1; - curAnimState->y2 = curAnimState->y1; - curAnimState->active = 1; - curAnimState->refreshFlag = 1; - curAnimState->bkgdChangeFlag = 1; - - if (ch->facing >= 1 && ch->facing <= 3) - curAnimState->flags |= 1; - else if (ch->facing >= 5 && ch->facing <= 7) - curAnimState->flags &= 0xFFFFFFFE; - - _animator->addObjectToQueue(curAnimState); - - ++addedObjects; - ++listAdded; - if (listAdded < 2) - i = 5; - } - - for (int i = 0; i < 11; ++i) { - curAnimState = &_animator->sprites()[i]; - - if (_sprites->_anims[i].play) { - curAnimState->active = 1; - curAnimState->refreshFlag = 1; - curAnimState->bkgdChangeFlag = 1; - } else { - curAnimState->active = 0; - curAnimState->refreshFlag = 0; - curAnimState->bkgdChangeFlag = 0; - } - curAnimState->height = _sprites->_anims[i].height; - curAnimState->height2 = _sprites->_anims[i].height2; - curAnimState->width = _sprites->_anims[i].width + 1; - curAnimState->width2 = _sprites->_anims[i].width2; - curAnimState->drawY = _sprites->_anims[i].drawY; - curAnimState->x1 = curAnimState->x2 = _sprites->_anims[i].x; - curAnimState->y1 = curAnimState->y2 = _sprites->_anims[i].y; - curAnimState->background = _sprites->_anims[i].background; - curAnimState->sceneAnimPtr = _sprites->_sceneShapes[_sprites->_anims[i].sprite]; - - curAnimState->disable = _sprites->_anims[i].disable; - - if (_sprites->_anims[i].unk2) - curAnimState->flags = 0x800; - else - curAnimState->flags = 0; - - if (_sprites->_anims[i].flipX) - curAnimState->flags |= 0x1; - - _animator->addObjectToQueue(curAnimState); - } - - for (int i = 0; i < 12; ++i) { - curAnimState = &_animator->items()[i]; - Room *curRoom = &_roomTable[_currentCharacter->sceneId]; - byte curItem = curRoom->itemsTable[i]; - if (curItem != 0xFF) { - curAnimState->drawY = curRoom->itemsYPos[i]; - curAnimState->sceneAnimPtr = _shapes[216+curItem]; - curAnimState->animFrameNumber = (int16)0xFFFF; - curAnimState->y1 = curRoom->itemsYPos[i]; - curAnimState->x1 = curRoom->itemsXPos[i]; - - curAnimState->x1 -= (_animator->fetchAnimWidth(curAnimState->sceneAnimPtr, _scaleTable[curAnimState->drawY])) >> 1; - curAnimState->y1 -= _animator->fetchAnimHeight(curAnimState->sceneAnimPtr, _scaleTable[curAnimState->drawY]); - - curAnimState->x2 = curAnimState->x1; - curAnimState->y2 = curAnimState->y1; - - curAnimState->active = 1; - curAnimState->refreshFlag = 1; - curAnimState->bkgdChangeFlag = 1; - - _animator->addObjectToQueue(curAnimState); - } else { - curAnimState->active = 0; - curAnimState->refreshFlag = 0; - curAnimState->bkgdChangeFlag = 0; - } - } - - _animator->preserveAnyChangedBackgrounds(); - curAnimState = _animator->actors(); - curAnimState->bkgdChangeFlag = 1; - curAnimState->refreshFlag = 1; - for (int i = 1; i < 28; ++i) { - curAnimState = &_animator->objects()[i]; - if (curAnimState->active) { - curAnimState->bkgdChangeFlag = 1; - curAnimState->refreshFlag = 1; - } - } - _animator->restoreAllObjectBackgrounds(); - _animator->preserveAnyChangedBackgrounds(); - _animator->prepDrawAllObjects(); - initSceneScreen(brandonAlive); - _animator->copyChangedObjectsForward(0); -} - -void KyraEngine::initSceneScreen(int brandonAlive) { - if (_flags.platform == Common::kPlatformAmiga) { - if (_unkScreenVar1 && !queryGameFlag(0xF0)) { - memset(_screen->getPalette(2), 0, 32*3); - if (_currentCharacter->sceneId != 117 || !queryGameFlag(0xB3)) - _screen->setScreenPalette(_screen->getPalette(2)); - } - - if (_unkScreenVar2 == 1) - _screen->shuffleScreen(8, 8, 304, 128, 2, 0, _unkScreenVar3, false); - else - _screen->copyRegion(8, 8, 8, 8, 304, 128, 2, 0); - - if (_unkScreenVar1 && !queryGameFlag(0xA0)) { - if (_currentCharacter->sceneId == 45 && _paletteChanged) - memcpy(_screen->getPalette(0) + 12*3, _screen->getPalette(4) + 12*3, 2); - - if (_currentCharacter->sceneId >= 229 && _currentCharacter->sceneId <= 245 && (_brandonStatusBit & 1)) - memcpy(_screen->getPalette(0), _screen->getPalette(0) + 320*3, 64); - - _screen->setScreenPalette(_screen->getPalette(0)); - } - } else { - if (_unkScreenVar1 && !queryGameFlag(0xA0)) { - for (int i = 0; i < 60; ++i) { - uint16 col = _screen->getPalette(0)[684+i]; - col += _screen->getPalette(1)[684+i] << 1; - col >>= 2; - _screen->getPalette(0)[684+i] = col; - } - _screen->setScreenPalette(_screen->getPalette(0)); - } - - if (_unkScreenVar2 == 1) - _screen->shuffleScreen(8, 8, 304, 128, 2, 0, _unkScreenVar3, false); - else - _screen->copyRegion(8, 8, 8, 8, 304, 128, 2, 0); - - if (_unkScreenVar1 && _paletteChanged) { - if (!queryGameFlag(0xA0)) { - memcpy(_screen->getPalette(0) + 684, _screen->getPalette(1) + 684, 60); - _screen->setScreenPalette(_screen->getPalette(0)); - } else { - memset(_screen->getPalette(0), 0, 768); - } - } - } - - // really call this here? - _screen->updateScreen(); - - if (!_scriptInterpreter->startScript(_scriptClick, 2)) - error("Could not start script function 2 of scene script"); - - _scriptClick->regs[7] = brandonAlive; - - while (_scriptInterpreter->validScript(_scriptClick)) - _scriptInterpreter->runScript(_scriptClick); - - setTextFadeTimerCountdown(-1); - if (_currentCharacter->sceneId == 210) { - if (_itemInHand != -1) - magicOutMouseItem(2, -1); - - _screen->hideMouse(); - for (int i = 0; i < 10; ++i) { - if (_currentCharacter->inventoryItems[i] != 0xFF) - magicOutMouseItem(2, i); - } - _screen->showMouse(); - } -} - -int KyraEngine::handleSceneChange(int xpos, int ypos, int unk1, int frameReset) { - debugC(9, kDebugLevelMain, "KyraEngine::handleSceneChange(%d, %d, %d, %d)", xpos, ypos, unk1, frameReset); - if (queryGameFlag(0xEF)) - unk1 = 0; - - int sceneId = _currentCharacter->sceneId; - _pathfinderFlag = 0; - - if (xpos < 12) { - if (_roomTable[sceneId].westExit != 0xFFFF) { - xpos = 12; - ypos = _sceneExits.westYPos; - _pathfinderFlag = 7; - } - } else if (xpos >= 308) { - if (_roomTable[sceneId].eastExit != 0xFFFF) { - xpos = 307; - ypos = _sceneExits.eastYPos; - _pathfinderFlag = 13; - } - } - - if (ypos <= (_northExitHeight&0xFF)+2) { - if (_roomTable[sceneId].northExit != 0xFFFF) { - xpos = _sceneExits.northXPos; - ypos = _northExitHeight & 0xFF; - _pathfinderFlag = 14; - } - } else if (ypos >= 136) { - if (_roomTable[sceneId].southExit != 0xFFFF) { - xpos = _sceneExits.southXPos; - ypos = 136; - _pathfinderFlag = 11; - } - } - - int temp = xpos - _currentCharacter->x1; - if (ABS(temp) < 4) { - temp = ypos - _currentCharacter->y1; - if (ABS(temp) < 2) - return 0; - } - - int x = (int16)(_currentCharacter->x1 & 0xFFFC); - int y = (int16)(_currentCharacter->y1 & 0xFFFE); - xpos = (int16)(xpos & 0xFFFC); - ypos = (int16)(ypos & 0xFFFE); - - int ret = findWay(x, y, xpos, ypos, _movFacingTable, 150); - _pathfinderFlag = 0; - - if (ret >= _lastFindWayRet) - _lastFindWayRet = ret; - - if (ret == 0x7D00 || ret == 0) - return 0; - - return processSceneChange(_movFacingTable, unk1, frameReset); -} - -int KyraEngine::processSceneChange(int *table, int unk1, int frameReset) { - debugC(9, kDebugLevelMain, "KyraEngine::processSceneChange(%p, %d, %d)", (const void *)table, unk1, frameReset); - if (queryGameFlag(0xEF)) - unk1 = 0; - - int *tableStart = table; - _sceneChangeState = 0; - _loopFlag2 = 0; - bool running = true; - int returnValue = 0; - uint32 nextFrame = 0; - _abortWalkFlag = false; - _mousePressFlag = false; - - while (running) { - if (_abortWalkFlag) { - *table = 8; - _currentCharacter->currentAnimFrame = 7; - _animator->animRefreshNPC(0); - _animator->updateAllObjectShapes(); - processInput(); - return 0; - } - bool forceContinue = false; - switch (*table) { - case 0: case 1: case 2: - case 3: case 4: case 5: - case 6: case 7: - _currentCharacter->facing = getOppositeFacingDirection(*table); - break; - - case 8: - forceContinue = true; - running = false; - break; - - default: - ++table; - forceContinue = true; - break; - } - - returnValue = changeScene(_currentCharacter->facing); - if (returnValue) { - running = false; - _abortWalkFlag = false; - } - - if (unk1) { - if (_mousePressFlag) { - running = false; - _sceneChangeState = 1; - } - } - - if (forceContinue || !running) - continue; - - int temp = 0; - if (table == tableStart || table[1] == 8) - temp = setCharacterPosition(0, 0); - else - temp = setCharacterPosition(0, table); - - if (temp) - ++table; - - nextFrame = getTimerDelay(5) * _tickLength + _system->getMillis(); - while (_system->getMillis() < nextFrame) { - updateGameTimers(); - - if (_currentCharacter->sceneId == 210) { - updateKyragemFading(); - if (seq_playEnd() || _beadStateVar == 4 || _beadStateVar == 5) { - *table = 8; - running = false; - break; - } - } - - if ((nextFrame - _system->getMillis()) >= 10) - delay(10, true); - } - } - - if (frameReset && !(_brandonStatusBit & 2)) - _currentCharacter->currentAnimFrame = 7; - - _animator->animRefreshNPC(0); - _animator->updateAllObjectShapes(); - return returnValue; -} - -int KyraEngine::changeScene(int facing) { - debugC(9, kDebugLevelMain, "KyraEngine::changeScene(%d)", facing); - if (queryGameFlag(0xEF)) { - if (_currentCharacter->sceneId == 5) - return 0; - } - - int xpos = _charXPosTable[facing] + _currentCharacter->x1; - int ypos = _charYPosTable[facing] + _currentCharacter->y1; - - if (xpos >= 12 && xpos <= 308) { - if (!lineIsPassable(xpos, ypos)) - return false; - } - - if (_exitListPtr) { - int16 *ptr = _exitListPtr; - // this loop should be only entered one time, seems to be some hack in the original - while (true) { - if (*ptr == -1) - break; - - if (*ptr > _currentCharacter->x1 || _currentCharacter->y1 < ptr[1] || _currentCharacter->x1 > ptr[2] || _currentCharacter->y1 > ptr[3]) { - ptr += 10; - break; - } - - _brandonPosX = ptr[6]; - _brandonPosY = ptr[7]; - uint16 sceneId = ptr[5]; - facing = ptr[4]; - int unk1 = ptr[8]; - int unk2 = ptr[9]; - - if (sceneId == 0xFFFF) { - switch (facing) { - case 0: - sceneId = _roomTable[_currentCharacter->sceneId].northExit; - break; - - case 2: - sceneId = _roomTable[_currentCharacter->sceneId].eastExit; - break; - - case 4: - sceneId = _roomTable[_currentCharacter->sceneId].southExit; - break; - - case 6: - sceneId = _roomTable[_currentCharacter->sceneId].westExit; - break; - - default: - break; - } - } - - _currentCharacter->facing = facing; - _animator->animRefreshNPC(0); - _animator->updateAllObjectShapes(); - enterNewScene(sceneId, facing, unk1, unk2, 0); - resetGameFlag(0xEE); - return 1; - } - } - - int returnValue = 0; - facing = 0; - - if ((_northExitHeight & 0xFF) + 2 >= ypos || (_northExitHeight & 0xFF) + 2 >= _currentCharacter->y1) { - facing = 0; - returnValue = 1; - } - - if (xpos >= 308 || (_currentCharacter->x1 + 4) >= 308) { - facing = 2; - returnValue = 1; - } - - if (((_northExitHeight >> 8) & 0xFF) - 2 < ypos || ((_northExitHeight >> 8) & 0xFF) - 2 < _currentCharacter->y1) { - facing = 4; - returnValue = 1; - } - - if (xpos <= 12 || _currentCharacter->y1 <= 12) { - facing = 6; - returnValue = 1; - } - - if (!returnValue) - return 0; - - uint16 sceneId = 0xFFFF; - switch (facing) { - case 0: - sceneId = _roomTable[_currentCharacter->sceneId].northExit; - break; - - case 2: - sceneId = _roomTable[_currentCharacter->sceneId].eastExit; - break; - - case 4: - sceneId = _roomTable[_currentCharacter->sceneId].southExit; - break; - - default: - sceneId = _roomTable[_currentCharacter->sceneId].westExit; - break; - } - - if (sceneId == 0xFFFF) - return 0; - - enterNewScene(sceneId, facing, 1, 1, 0); - return returnValue; -} - -void KyraEngine::setCharactersInDefaultScene() { - static const uint32 defaultSceneTable[][4] = { - { 0xFFFF, 0x0004, 0x0003, 0xFFFF }, - { 0xFFFF, 0x0022, 0xFFFF, 0x0000 }, - { 0xFFFF, 0x001D, 0x0021, 0xFFFF }, - { 0xFFFF, 0x0000, 0x0000, 0xFFFF } - }; - - for (int i = 1; i < 5; ++i) { - Character *cur = &_characterList[i]; - //cur->field_20 = 0; - - const uint32 *curTable = defaultSceneTable[i-1]; - cur->sceneId = curTable[0]; - - if (cur->sceneId == _currentCharacter->sceneId) - //++cur->field_20; - cur->sceneId = curTable[1/*cur->field_20*/]; - - //cur->field_23 = curTable[cur->field_20+1]; - } -} - -void KyraEngine::setCharactersPositions(int character) { - static uint16 initXPosTable[] = { - 0x3200, 0x0024, 0x2230, 0x2F00, 0x0020, 0x002B, - 0x00CA, 0x00F0, 0x0082, 0x00A2, 0x0042 - }; - static uint8 initYPosTable[] = { - 0x00, 0xA2, 0x00, 0x42, 0x00, - 0x67, 0x67, 0x60, 0x5A, 0x71, - 0x76 - }; - - assert(character < ARRAYSIZE(initXPosTable)); - Character *edit = &_characterList[character]; - edit->x1 = edit->x2 = initXPosTable[character]; - edit->y1 = edit->y2 = initYPosTable[character]; -} - -#pragma mark - -#pragma mark - Pathfinder -#pragma mark - - -int KyraEngine::findWay(int x, int y, int toX, int toY, int *moveTable, int moveTableSize) { - debugC(9, kDebugLevelMain, "KyraEngine::findWay(%d, %d, %d, %d, %p, %d)", x, y, toX, toY, (const void *)moveTable, moveTableSize); - x &= 0xFFFC; toX &= 0xFFFC; - y &= 0xFFFE; toY &= 0xFFFE; - x = (int16)x; y = (int16)y; toX = (int16)toX; toY = (int16)toY; - - if (x == toY && y == toY) { - moveTable[0] = 8; - return 0; - } - - int curX = x; - int curY = y; - int lastUsedEntry = 0; - int tempValue = 0; - int *pathTable1 = new int[0x7D0]; - int *pathTable2 = new int[0x7D0]; - assert(pathTable1 && pathTable2); - - while (true) { - int newFacing = getFacingFromPointToPoint(x, y, toX, toY); - changePosTowardsFacing(curX, curY, newFacing); - - if (curX == toX && curY == toY) { - if (!lineIsPassable(curX, curY)) - break; - moveTable[lastUsedEntry++] = newFacing; - break; - } - - if (lineIsPassable(curX, curY)) { - if (lastUsedEntry == moveTableSize) { - delete [] pathTable1; - delete [] pathTable2; - return 0x7D00; - } - // debug drawing - //if (curX >= 0 && curY >= 0 && curX < 320 && curY < 200) { - // _screen->setPagePixel(0, curX, curY, 11); - // _screen->updateScreen(); - // waitTicks(5); - //} - moveTable[lastUsedEntry++] = newFacing; - x = curX; - y = curY; - continue; - } - - int temp = 0; - while (true) { - newFacing = getFacingFromPointToPoint(curX, curY, toX, toY); - changePosTowardsFacing(curX, curY, newFacing); - // debug drawing - //if (curX >= 0 && curY >= 0 && curX < 320 && curY < 200) { - // _screen->setPagePixel(0, curX, curY, 8); - // _screen->updateScreen(); - // waitTicks(5); - //} - - if (!lineIsPassable(curX, curY)) { - if (curX != toX || curY != toY) - continue; - } - - if (curX == toX && curY == toY) { - if (!lineIsPassable(curX, curY)) { - tempValue = 0; - temp = 0; - break; - } - } - - temp = findSubPath(x, y, curX, curY, pathTable1, 1, 0x7D0); - tempValue = findSubPath(x, y, curX, curY, pathTable2, 0, 0x7D0); - if (curX == toX && curY == toY) { - if (temp == 0x7D00 && tempValue == 0x7D00) { - delete [] pathTable1; - delete [] pathTable2; - return 0x7D00; - } - } - - if (temp != 0x7D00 || tempValue != 0x7D00) - break; - } - - if (temp < tempValue) { - if (lastUsedEntry + temp > moveTableSize) { - delete [] pathTable1; - delete [] pathTable2; - return 0x7D00; - } - memcpy(&moveTable[lastUsedEntry], pathTable1, temp*sizeof(int)); - lastUsedEntry += temp; - } else { - if (lastUsedEntry + tempValue > moveTableSize) { - delete [] pathTable1; - delete [] pathTable2; - return 0x7D00; - } - memcpy(&moveTable[lastUsedEntry], pathTable2, tempValue*sizeof(int)); - lastUsedEntry += tempValue; - } - x = curX; - y = curY; - if (curX == toX && curY == toY) - break; - } - - delete [] pathTable1; - delete [] pathTable2; - moveTable[lastUsedEntry] = 8; - return getMoveTableSize(moveTable); -} - -int KyraEngine::findSubPath(int x, int y, int toX, int toY, int *moveTable, int start, int end) { - debugC(9, kDebugLevelMain, "KyraEngine::findSubPath(%d, %d, %d, %d, %p, %d, %d)", x, y, toX, toY, (const void *)moveTable, start, end); - // only used for debug specific code - //static uint16 unkTable[] = { 8, 5 }; - static const int8 facingTable1[] = { 7, 0, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 7, 0 }; - static const int8 facingTable2[] = { -1, 0, -1, 2, -1, 4, -1, 6, -1, 2, -1, 4, -1, 6, -1, 0 }; - static const int8 facingTable3[] = { 2, 4, 4, 6, 6, 0, 0, 2, 6, 6, 0, 0, 2, 2, 4, 4 }; - static const int8 addPosTableX[] = { -1, 0, -1, 4, -1, 0, -1, -4, -1, -4, -1, 0, -1, 4, -1, 0 }; - static const int8 addPosTableY[] = { -1, 2, -1, 0, -1, -2, -1, 0, -1, 0, -1, 2, -1, 0, -1, -2 }; - - // debug specific - //++unkTable[start]; - //while (_screen->getPalette(0)[unkTable[start]] != 0x0F) { - // ++unkTable[start]; - //} - - int xpos1 = x, xpos2 = x; - int ypos1 = y, ypos2 = y; - int newFacing = getFacingFromPointToPoint(x, y, toX, toY); - int position = 0; - - while (position != end) { - int newFacing2 = newFacing; - while (true) { - changePosTowardsFacing(xpos1, ypos1, facingTable1[start*8 + newFacing2]); - if (!lineIsPassable(xpos1, ypos1)) { - if (facingTable1[start*8 + newFacing2] == newFacing) - return 0x7D00; - newFacing2 = facingTable1[start*8 + newFacing2]; - xpos1 = x; - ypos1 = y; - continue; - } - newFacing = facingTable1[start*8 + newFacing2]; - break; - } - // debug drawing - //if (xpos1 >= 0 && ypos1 >= 0 && xpos1 < 320 && ypos1 < 200) { - // _screen->setPagePixel(0, xpos1, ypos1, unkTable[start]); - // _screen->updateScreen(); - // waitTicks(5); - //} - if (newFacing & 1) { - int temp = xpos1 + addPosTableX[newFacing + start * 8]; - if (toX == temp) { - temp = ypos1 + addPosTableY[newFacing + start * 8]; - if (toY == temp) { - moveTable[position++] = facingTable2[newFacing + start * 8]; - return position; - } - } - } - - moveTable[position++] = newFacing; - x = xpos1; - y = ypos1; - - if (x == toX && y == toY) - return position; - - if (xpos1 == xpos2 && ypos1 == ypos2) - break; - - newFacing = facingTable3[start*8 + newFacing]; - } - - return 0x7D00; -} - -int KyraEngine::getFacingFromPointToPoint(int x, int y, int toX, int toY) { - debugC(9, kDebugLevelMain, "KyraEngine::getFacingFromPointToPoint(%d, %d, %d, %d)", x, y, toX, toY); - static const int facingTable[] = { - 1, 0, 1, 2, 3, 4, 3, 2, 7, 0, 7, 6, 5, 4, 5, 6 - }; - - int facingEntry = 0; - int ydiff = y - toY; - if (ydiff < 0) { - ++facingEntry; - ydiff = -ydiff; - } - facingEntry <<= 1; - - int xdiff = toX - x; - if (xdiff < 0) { - ++facingEntry; - xdiff = -xdiff; - } - - if (xdiff >= ydiff) { - int temp = ydiff; - ydiff = xdiff; - xdiff = temp; - - facingEntry <<= 1; - } else { - facingEntry <<= 1; - facingEntry += 1; - } - int temp = (ydiff + 1) >> 1; - - if (xdiff < temp) { - facingEntry <<= 1; - facingEntry += 1; - } else { - facingEntry <<= 1; - } - - assert(facingEntry < ARRAYSIZE(facingTable)); - return facingTable[facingEntry]; -} - -void KyraEngine::changePosTowardsFacing(int &x, int &y, int facing) { - debugC(9, kDebugLevelMain, "KyraEngine::changePosTowardsFacing(%d, %d, %d)", x, y, facing); - x += _addXPosTable[facing]; - y += _addYPosTable[facing]; -} - -bool KyraEngine::lineIsPassable(int x, int y) { - debugC(9, kDebugLevelMain, "KyraEngine::lineIsPassable(%d, %d)", x, y); - if (queryGameFlag(0xEF)) { - if (_currentCharacter->sceneId == 5) - return true; - } - - if (_pathfinderFlag & 2) { - if (x >= 312) - return false; - } - - if (_pathfinderFlag & 4) { - if (y >= 136) - return false; - } - - if (_pathfinderFlag & 8) { - if (x < 8) - return false; - } - - if (_pathfinderFlag2) { - if (x <= 8 || x >= 312) - return true; - if (y < (_northExitHeight & 0xFF) || y > 135) - return true; - } - - if (y > 137) - return false; - - if (y < 0) - y = 0; - - int ypos = 8; - if (_scaleMode) { - ypos = (_scaleTable[y] >> 5) + 1; - if (8 < ypos) - ypos = 8; - } - - x -= (ypos >> 1); - - int xpos = x; - int xtemp = xpos + ypos - 1; - if (x < 0) - xpos = 0; - - if (xtemp > 319) - xtemp = 319; - - for (; xpos < xtemp; ++xpos) { - if (!_screen->getShapeFlag1(xpos, y)) - return false; - } - return true; -} - -int KyraEngine::getMoveTableSize(int *moveTable) { - debugC(9, kDebugLevelMain, "KyraEngine::getMoveTableSize(%p)", (const void *)moveTable); - int retValue = 0; - if (moveTable[0] == 8) - return 0; - - static const int facingTable[] = { - 4, 5, 6, 7, 0, 1, 2, 3 - }; - static const int unkTable[] = { - -1, -1, 1, 2, -1, 6, 7, -1, - -1, -1, -1, -1, 2, -1, 0, -1, - 1, -1, -1, -1, 3, 4, -1, 0, - 2, -1, -1, -1, -1, -1, 4, -1, - -1, 2, 3, -1, -1, -1, 5, 6, - 6, -1, 4, -1, -1, -1, -1, -1, - 7, 0, -1, 4, 5, -1, -1, -1, - -1, -1, 0, -1, 6, -1, -1, -1 - }; - - int *oldPosition = moveTable; - int *tempPosition = moveTable; - int *curPosition = moveTable + 1; - retValue = 1; - - while (*curPosition != 8) { - if (*oldPosition == facingTable[*curPosition]) { - retValue -= 2; - *oldPosition = 9; - *curPosition = 9; - - while (tempPosition != moveTable) { - --tempPosition; - if (*tempPosition != 9) - break; - } - - if (tempPosition == moveTable && *tempPosition == 9) { - while (*tempPosition != 8 && *tempPosition == 9) - ++tempPosition; - - if (*tempPosition == 8) - return 0; - } - - oldPosition = tempPosition; - curPosition = oldPosition+1; - - while (*curPosition != 8 && *curPosition == 9) - ++curPosition; - - continue; - } - - if (unkTable[*curPosition+((*oldPosition)*8)] != -1) { - --retValue; - *oldPosition = unkTable[*curPosition+((*oldPosition)*8)]; - *curPosition = 9; - - if (tempPosition != oldPosition) { - curPosition = oldPosition; - oldPosition = tempPosition; - while (true) { - if (tempPosition == moveTable) - break; - - --tempPosition; - if (*tempPosition != 9) - break; - - } - } else { - while (true) { - ++curPosition; - if (*curPosition != 9) - break; - } - } - continue; - } - - tempPosition = oldPosition; - oldPosition = curPosition; - ++retValue; - - while (true) { - ++curPosition; - if (*curPosition != 9) - break; - } - } - - return retValue; -} - -void KyraEngine::setupSceneResource(int sceneId) { - debugC(9, kDebugLevelMain, "KyraEngine::setupSceneResource(%d)", sceneId); - if (!_flags.isTalkie) - return; - - if (_currentRoom != 0xFFFF) { - assert(_currentRoom < _roomTableSize); - int tableId = _roomTable[_currentRoom].nameIndex; - assert(tableId < _roomFilenameTableSize); - - // unload our old room - char file[64]; - strcpy(file, _roomFilenameTable[tableId]); - strcat(file, ".VRM"); - _res->unloadPakFile(file); - - strcpy(file, _roomFilenameTable[tableId]); - strcat(file, ".PAK"); - _res->unloadPakFile(file); - - strcpy(file, _roomFilenameTable[tableId]); - strcat(file, ".APK"); - _res->unloadPakFile(file); - } - - assert(sceneId < _roomTableSize); - int tableId = _roomTable[sceneId].nameIndex; - assert(tableId < _roomFilenameTableSize); - - // load our new room - char file[64]; - strcpy(file, _roomFilenameTable[tableId]); - strcat(file, ".VRM"); - if (Common::File::exists(file)) - _res->loadPakFile(file); - - strcpy(file, _roomFilenameTable[tableId]); - strcat(file, ".PAK"); - if (Common::File::exists(file)) - _res->loadPakFile(file); - - strcpy(file, _roomFilenameTable[tableId]); - strcat(file, ".APK"); - if (Common::File::exists(file)) - _res->loadPakFile(file); -} - -} // end of namespace Kyra - diff --git a/engines/kyra/scene_v1.cpp b/engines/kyra/scene_v1.cpp new file mode 100644 index 0000000000..a92fd9ce7c --- /dev/null +++ b/engines/kyra/scene_v1.cpp @@ -0,0 +1,1624 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include "kyra/kyra.h" +#include "kyra/seqplayer.h" +#include "kyra/screen.h" +#include "kyra/resource.h" +#include "kyra/sound.h" +#include "kyra/sprites.h" +#include "kyra/wsamovie.h" +#include "kyra/animator.h" +#include "kyra/text.h" +#include "kyra/script.h" + +#include "common/system.h" +#include "common/savefile.h" + +namespace Kyra { + +void KyraEngine::enterNewScene(int sceneId, int facing, int unk1, int unk2, int brandonAlive) { + debugC(9, kDebugLevelMain, "KyraEngine::enterNewScene(%d, %d, %d, %d, %d)", sceneId, facing, unk1, unk2, brandonAlive); + int unkVar1 = 1; + _screen->hideMouse(); + _handleInput = false; + _abortWalkFlag = false; + _abortWalkFlag2 = false; + + if (_flags.platform == Common::kPlatformFMTowns) { + int newSfxFile = -1; + if (_currentCharacter->sceneId == 7 && sceneId == 24) + newSfxFile = 2; + else if (_currentCharacter->sceneId == 25 && sceneId == 109) + newSfxFile = 3; + else if (_currentCharacter->sceneId == 120 && sceneId == 37) + newSfxFile = 4; + else if (_currentCharacter->sceneId == 52 && sceneId == 199) + newSfxFile = 5; + else if (_currentCharacter->sceneId == 37 && sceneId == 120) + newSfxFile = 3; + else if (_currentCharacter->sceneId == 109 && sceneId == 25) + newSfxFile = 2; + else if (_currentCharacter->sceneId == 24 && sceneId == 7) + newSfxFile = 1; + + if (newSfxFile != -1) { + _curSfxFile = newSfxFile; + _sound->loadSoundFile(_curSfxFile); + } + } + + switch (_currentCharacter->sceneId) { + case 1: + if (sceneId == 0) { + moveCharacterToPos(0, 0, _currentCharacter->x1, 84); + unkVar1 = 0; + } + break; + + case 3: + if (sceneId == 2) { + moveCharacterToPos(0, 6, 155, _currentCharacter->y1); + unkVar1 = 0; + } + break; + + case 26: + if (sceneId == 27) { + moveCharacterToPos(0, 6, 155, _currentCharacter->y1); + unkVar1 = 0; + } + break; + + case 44: + if (sceneId == 45) { + moveCharacterToPos(0, 2, 192, _currentCharacter->y1); + unkVar1 = 0; + } + break; + + default: + break; + } + + if (unkVar1 && unk1) { + int xpos = _currentCharacter->x1; + int ypos = _currentCharacter->y1; + switch (facing) { + case 0: + ypos = _currentCharacter->y1 - 6; + break; + + case 2: + xpos = 336; + break; + + case 4: + ypos = 143; + break; + + case 6: + xpos = -16; + break; + + default: + break; + } + + moveCharacterToPos(0, facing, xpos, ypos); + } + + for (int i = 0; i < ARRAYSIZE(_movieObjects); ++i) + _movieObjects[i]->close(); + + if (!brandonAlive) { + _scriptInterpreter->initScript(_scriptClick, _scriptClickData); + _scriptInterpreter->startScript(_scriptClick, 5); + while (_scriptInterpreter->validScript(_scriptClick)) + _scriptInterpreter->runScript(_scriptClick); + } + + memset(_entranceMouseCursorTracks, 0xFFFF, sizeof(uint16)*4); + _currentCharacter->sceneId = sceneId; + + assert(sceneId < _roomTableSize); + assert(_roomTable[sceneId].nameIndex < _roomFilenameTableSize); + + Room *currentRoom = &_roomTable[sceneId]; + + setupSceneResource(sceneId); + + _currentRoom = sceneId; + + int tableId = _roomTable[sceneId].nameIndex; + char fileNameBuffer[32]; + strcpy(fileNameBuffer, _roomFilenameTable[tableId]); + strcat(fileNameBuffer, ".DAT"); + _sprites->loadDat(fileNameBuffer, _sceneExits); + _sprites->setupSceneAnims(); + _scriptInterpreter->unloadScript(_scriptClickData); + loadSceneMsc(); + + _walkBlockNorth = currentRoom->northExit; + _walkBlockEast = currentRoom->eastExit; + _walkBlockSouth = currentRoom->southExit; + _walkBlockWest = currentRoom->westExit; + + if (_walkBlockNorth == 0xFFFF) + _screen->blockOutRegion(0, 0, 320, (_northExitHeight & 0xFF)+3); + if (_walkBlockEast == 0xFFFF) + _screen->blockOutRegion(312, 0, 8, 139); + if (_walkBlockSouth == 0xFFFF) + _screen->blockOutRegion(0, 135, 320, 8); + if (_walkBlockWest == 0xFFFF) + _screen->blockOutRegion(0, 0, 8, 139); + + if (!brandonAlive) + updatePlayerItemsForScene(); + + startSceneScript(brandonAlive); + setupSceneItems(); + + initSceneData(facing, unk2, brandonAlive); + + _loopFlag2 = 0; + _screen->showMouse(); + if (!brandonAlive) + seq_poisonDeathNow(0); + updateMousePointer(true); + _changedScene = true; +} + +void KyraEngine::transcendScenes(int roomIndex, int roomName) { + debugC(9, kDebugLevelMain, "KyraEngine::transcendScenes(%d, %d)", roomIndex, roomName); + assert(roomIndex < _roomTableSize); + + if (_flags.isTalkie) { + char file[32]; + assert(roomIndex < _roomTableSize); + int tableId = _roomTable[roomIndex].nameIndex; + assert(tableId < _roomFilenameTableSize); + strcpy(file, _roomFilenameTable[tableId]); + strcat(file, ".VRM"); + _res->unloadPakFile(file); + } + + _roomTable[roomIndex].nameIndex = roomName; + _unkScreenVar2 = 1; + _unkScreenVar3 = 1; + _unkScreenVar1 = 0; + _brandonPosX = _currentCharacter->x1; + _brandonPosY = _currentCharacter->y1; + enterNewScene(roomIndex, _currentCharacter->facing, 0, 0, 0); + _unkScreenVar1 = 1; + _unkScreenVar2 = 0; + _unkScreenVar3 = 0; +} + +void KyraEngine::setSceneFile(int roomIndex, int roomName) { + debugC(9, kDebugLevelMain, "KyraEngine::setSceneFile(%d, %d)", roomIndex, roomName); + assert(roomIndex < _roomTableSize); + _roomTable[roomIndex].nameIndex = roomName; +} + +void KyraEngine::moveCharacterToPos(int character, int facing, int xpos, int ypos) { + debugC(9, kDebugLevelMain, "KyraEngine::moveCharacterToPos(%d, %d, %d, %d)", character, facing, xpos, ypos); + Character *ch = &_characterList[character]; + ch->facing = facing; + _screen->hideMouse(); + xpos = (int16)(xpos & 0xFFFC); + ypos = (int16)(ypos & 0xFFFE); + disableTimer(19); + disableTimer(14); + disableTimer(18); + uint32 nextFrame = 0; + + switch (facing) { + case 0: + while (ypos < ch->y1) { + nextFrame = getTimerDelay(5 + character) * _tickLength + _system->getMillis(); + setCharacterPositionWithUpdate(character); + delayUntil(nextFrame, true); + } + break; + + case 2: + while (ch->x1 < xpos) { + nextFrame = getTimerDelay(5 + character) * _tickLength + _system->getMillis(); + setCharacterPositionWithUpdate(character); + delayUntil(nextFrame, true); + } + break; + + case 4: + while (ypos > ch->y1) { + nextFrame = getTimerDelay(5 + character) * _tickLength + _system->getMillis(); + setCharacterPositionWithUpdate(character); + delayUntil(nextFrame, true); + } + break; + + case 6: + while (ch->x1 > xpos) { + nextFrame = getTimerDelay(5 + character) * _tickLength + _system->getMillis(); + setCharacterPositionWithUpdate(character); + delayUntil(nextFrame, true); + } + break; + + default: + break; + } + + enableTimer(19); + enableTimer(14); + enableTimer(18); + _screen->showMouse(); +} + +void KyraEngine::setCharacterPositionWithUpdate(int character) { + debugC(9, kDebugLevelMain, "KyraEngine::setCharacterPositionWithUpdate(%d)", character); + setCharacterPosition(character, 0); + _sprites->updateSceneAnims(); + updateGameTimers(); + _animator->updateAllObjectShapes(); + updateTextFade(); + + if (_currentCharacter->sceneId == 210) + updateKyragemFading(); +} + +int KyraEngine::setCharacterPosition(int character, int *facingTable) { + debugC(9, kDebugLevelMain, "KyraEngine::setCharacterPosition(%d, %p)", character, (const void *)facingTable); + + if (character == 0) { + _currentCharacter->x1 += _charXPosTable[_currentCharacter->facing]; + _currentCharacter->y1 += _charYPosTable[_currentCharacter->facing]; + setCharacterPositionHelper(0, facingTable); + return 1; + } else { + _characterList[character].x1 += _charXPosTable[_characterList[character].facing]; + _characterList[character].y1 += _charYPosTable[_characterList[character].facing]; + if (_characterList[character].sceneId == _currentCharacter->sceneId) + setCharacterPositionHelper(character, 0); + } + return 0; +} + +void KyraEngine::setCharacterPositionHelper(int character, int *facingTable) { + debugC(9, kDebugLevelMain, "KyraEngine::setCharacterPositionHelper(%d, %p)", character, (const void *)facingTable); + Character *ch = &_characterList[character]; + ++ch->currentAnimFrame; + int facing = ch->facing; + if (facingTable) { + if (*facingTable != *(facingTable - 1)) { + if (*(facingTable - 1) == *(facingTable + 1)) { + facing = getOppositeFacingDirection(*(facingTable - 1)); + *facingTable = *(facingTable - 1); + } + } + } + + static uint8 facingIsZero[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; + static uint8 facingIsFour[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; + + if (facing == 0) { + ++facingIsZero[character]; + } else { + bool resetTables = false; + if (facing != 7) { + if (facing - 1 != 0) { + if (facing != 4) { + if (facing == 3 || facing == 5) { + if (facingIsFour[character] > 2) + facing = 4; + resetTables = true; + } + } else { + ++facingIsFour[character]; + } + } else { + if (facingIsZero[character] > 2) + facing = 0; + resetTables = true; + } + } else { + if (facingIsZero[character] > 2) + facing = 0; + resetTables = true; + } + + if (resetTables) { + facingIsZero[character] = 0; + facingIsFour[character] = 0; + } + } + + static const uint16 maxAnimationFrame[] = { + 0x000F, 0x0031, 0x0055, 0x0000, 0x0000, 0x0000, + 0x0008, 0x002A, 0x004E, 0x0000, 0x0000, 0x0000, + 0x0022, 0x0046, 0x006A, 0x0000, 0x0000, 0x0000, + 0x001D, 0x0041, 0x0065, 0x0000, 0x0000, 0x0000, + 0x001F, 0x0043, 0x0067, 0x0000, 0x0000, 0x0000, + 0x0028, 0x004C, 0x0070, 0x0000, 0x0000, 0x0000, + 0x0023, 0x0047, 0x006B, 0x0000, 0x0000, 0x0000 + }; + + if (facing == 0) { + if (maxAnimationFrame[36+character] > ch->currentAnimFrame) + ch->currentAnimFrame = maxAnimationFrame[36+character]; + if (maxAnimationFrame[30+character] < ch->currentAnimFrame) + ch->currentAnimFrame = maxAnimationFrame[36+character]; + } else if (facing == 4) { + if (maxAnimationFrame[18+character] > ch->currentAnimFrame) + ch->currentAnimFrame = maxAnimationFrame[18+character]; + if (maxAnimationFrame[12+character] < ch->currentAnimFrame) + ch->currentAnimFrame = maxAnimationFrame[18+character]; + } else { + if (maxAnimationFrame[18+character] < ch->currentAnimFrame) + ch->currentAnimFrame = maxAnimationFrame[30+character]; + if (maxAnimationFrame[character] == ch->currentAnimFrame) + ch->currentAnimFrame = maxAnimationFrame[6+character]; + if (maxAnimationFrame[character] < ch->currentAnimFrame) + ch->currentAnimFrame = maxAnimationFrame[6+character]+2; + } + + if (character == 0 && (_brandonStatusBit & 0x10)) + ch->currentAnimFrame = 88; + + _animator->animRefreshNPC(character); +} + +int KyraEngine::getOppositeFacingDirection(int dir) { + debugC(9, kDebugLevelMain, "KyraEngine::getOppositeFacingDirection(%d)", dir); + switch (dir) { + case 0: + return 2; + case 1: + return 1; + case 3: + return 7; + case 4: + return 6; + case 5: + return 5; + case 6: + return 4; + case 7: + return 3; + default: + break; + } + return 0; +} + +void KyraEngine::loadSceneMsc() { + assert(_currentCharacter->sceneId < _roomTableSize); + int tableId = _roomTable[_currentCharacter->sceneId].nameIndex; + assert(tableId < _roomFilenameTableSize); + char fileNameBuffer[32]; + strcpy(fileNameBuffer, _roomFilenameTable[tableId]); + strcat(fileNameBuffer, ".MSC"); + _screen->fillRect(0, 0, 319, 199, 0, 5); + _screen->loadBitmap(fileNameBuffer, 3, 5, 0); +} + +void KyraEngine::startSceneScript(int brandonAlive) { + debugC(9, kDebugLevelMain, "KyraEngine::startSceneScript(%d)", brandonAlive); + assert(_currentCharacter->sceneId < _roomTableSize); + int tableId = _roomTable[_currentCharacter->sceneId].nameIndex; + assert(tableId < _roomFilenameTableSize); + char fileNameBuffer[32]; + strcpy(fileNameBuffer, _roomFilenameTable[tableId]); + strcat(fileNameBuffer, ".CPS"); + _screen->clearPage(3); + // FIXME: check this hack for amiga version + _screen->loadBitmap(fileNameBuffer, 3, 3, (_flags.platform == Common::kPlatformAmiga ? _screen->getPalette(0) : 0)); + _sprites->loadSceneShapes(); + _exitListPtr = 0; + + _scaleMode = 1; + for (int i = 0; i < 145; ++i) + _scaleTable[i] = 256; + + clearNoDropRects(); + _scriptInterpreter->initScript(_scriptClick, _scriptClickData); + strcpy(fileNameBuffer, _roomFilenameTable[tableId]); + strcat(fileNameBuffer, ".EMC"); + _scriptInterpreter->unloadScript(_scriptClickData); + _scriptInterpreter->loadScript(fileNameBuffer, _scriptClickData, &_opcodes); + _scriptInterpreter->startScript(_scriptClick, 0); + _scriptClick->regs[0] = _currentCharacter->sceneId; + _scriptClick->regs[7] = brandonAlive; + + while (_scriptInterpreter->validScript(_scriptClick)) + _scriptInterpreter->runScript(_scriptClick); +} + +void KyraEngine::initSceneData(int facing, int unk1, int brandonAlive) { + debugC(9, kDebugLevelMain, "KyraEngine::initSceneData(%d, %d, %d)", facing, unk1, brandonAlive); + + int16 xpos2 = 0; + int setFacing = 1; + + int16 xpos = 0, ypos = 0; + + if (_brandonPosX == -1 && _brandonPosY == -1) { + switch (facing + 1) { + case 0: + xpos = ypos = -1; + break; + + case 1: case 2: case 8: + xpos = _sceneExits.southXPos; + ypos = _sceneExits.southYPos; + break; + + case 3: + xpos = _sceneExits.westXPos; + ypos = _sceneExits.westYPos; + break; + + case 4: case 5: case 6: + xpos = _sceneExits.northXPos; + ypos = _sceneExits.northYPos; + break; + + case 7: + xpos = _sceneExits.eastXPos; + ypos = _sceneExits.eastYPos; + break; + + default: + break; + } + + if ((uint8)(_northExitHeight & 0xFF) + 2 >= ypos) + ypos = (_northExitHeight & 0xFF) + 4; + if (xpos >= 308) + xpos = 304; + if ((uint8)(_northExitHeight >> 8) - 2 <= ypos) + ypos = (_northExitHeight >> 8) - 4; + if (xpos <= 12) + xpos = 16; + } + + if (_brandonPosX > -1) + xpos = _brandonPosX; + if (_brandonPosY > -1) + ypos = _brandonPosY; + + int16 ypos2 = 0; + if (_brandonPosX > -1 && _brandonPosY > -1) { + switch (_currentCharacter->sceneId) { + case 1: + _currentCharacter->x1 = xpos; + _currentCharacter->x2 = xpos; + _currentCharacter->y1 = ypos; + _currentCharacter->y2 = ypos; + facing = 4; + xpos2 = 192; + ypos2 = 104; + setFacing = 0; + unk1 = 1; + break; + + case 3: + _currentCharacter->x1 = xpos; + _currentCharacter->x2 = xpos; + _currentCharacter->y1 = ypos; + _currentCharacter->y2 = ypos; + facing = 2; + xpos2 = 204; + ypos2 = 94; + setFacing = 0; + unk1 = 1; + break; + + case 26: + _currentCharacter->x1 = xpos; + _currentCharacter->x2 = xpos; + _currentCharacter->y1 = ypos; + _currentCharacter->y2 = ypos; + facing = 2; + xpos2 = 192; + ypos2 = 128; + setFacing = 0; + unk1 = 1; + break; + + case 44: + _currentCharacter->x1 = xpos; + _currentCharacter->x2 = xpos; + _currentCharacter->y1 = ypos; + _currentCharacter->y2 = ypos; + facing = 6; + xpos2 = 156; + ypos2 = 96; + setFacing = 0; + unk1 = 1; + break; + + case 37: + _currentCharacter->x1 = xpos; + _currentCharacter->x2 = xpos; + _currentCharacter->y1 = ypos; + _currentCharacter->y2 = ypos; + facing = 2; + xpos2 = 148; + ypos2 = 114; + setFacing = 0; + unk1 = 1; + break; + + default: + break; + } + } + + _brandonPosX = _brandonPosY = -1; + + if (unk1 && setFacing) { + ypos2 = ypos; + xpos2 = xpos; + switch (facing) { + case 0: + ypos = 142; + break; + + case 2: + xpos = -16; + break; + + case 4: + ypos = (uint8)(_northExitHeight & 0xFF) - 4; + break; + + case 6: + xpos = 336; + break; + + default: + break; + } + } + + xpos2 = (int16)(xpos2 & 0xFFFC); + ypos2 = (int16)(ypos2 & 0xFFFE); + xpos = (int16)(xpos & 0xFFFC); + ypos = (int16)(ypos & 0xFFFE); + _currentCharacter->facing = facing; + _currentCharacter->x1 = xpos; + _currentCharacter->x2 = xpos; + _currentCharacter->y1 = ypos; + _currentCharacter->y2 = ypos; + + initSceneObjectList(brandonAlive); + + if (unk1 && brandonAlive == 0) + moveCharacterToPos(0, facing, xpos2, ypos2); + + _scriptClick->regs[4] = _itemInHand; + _scriptClick->regs[7] = brandonAlive; + _scriptInterpreter->startScript(_scriptClick, 3); + while (_scriptInterpreter->validScript(_scriptClick)) + _scriptInterpreter->runScript(_scriptClick); +} + +void KyraEngine::initSceneObjectList(int brandonAlive) { + debugC(9, kDebugLevelMain, "KyraEngine::initSceneObjectList(%d)", brandonAlive); + for (int i = 0; i < 28; ++i) + _animator->actors()[i].active = 0; + + int startAnimFrame = 0; + + AnimObject *curAnimState = _animator->actors(); + curAnimState->active = 1; + curAnimState->drawY = _currentCharacter->y1; + curAnimState->sceneAnimPtr = _shapes[_currentCharacter->currentAnimFrame]; + curAnimState->animFrameNumber = _currentCharacter->currentAnimFrame; + startAnimFrame = _currentCharacter->currentAnimFrame-7; + int xOffset = _defaultShapeTable[startAnimFrame].xOffset; + int yOffset = _defaultShapeTable[startAnimFrame].yOffset; + + if (_scaleMode) { + curAnimState->x1 = _currentCharacter->x1; + curAnimState->y1 = _currentCharacter->y1; + + _animator->_brandonScaleX = _scaleTable[_currentCharacter->y1]; + _animator->_brandonScaleY = _scaleTable[_currentCharacter->y1]; + + curAnimState->x1 += (_animator->_brandonScaleX * xOffset) >> 8; + curAnimState->y1 += (_animator->_brandonScaleY * yOffset) >> 8; + } else { + curAnimState->x1 = _currentCharacter->x1 + xOffset; + curAnimState->y1 = _currentCharacter->y1 + yOffset; + } + + curAnimState->x2 = curAnimState->x1; + curAnimState->y2 = curAnimState->y1; + curAnimState->refreshFlag = 1; + curAnimState->bkgdChangeFlag = 1; + _animator->clearQueue(); + _animator->addObjectToQueue(curAnimState); + + int listAdded = 0; + int addedObjects = 1; + + for (int i = 1; i < 5; ++i) { + Character *ch = &_characterList[i]; + curAnimState = &_animator->actors()[addedObjects]; + if (ch->sceneId != _currentCharacter->sceneId) { + curAnimState->active = 0; + curAnimState->refreshFlag = 0; + curAnimState->bkgdChangeFlag = 0; + ++addedObjects; + continue; + } + + curAnimState->drawY = ch->y1; + curAnimState->sceneAnimPtr = _shapes[ch->currentAnimFrame]; + curAnimState->animFrameNumber = ch->currentAnimFrame; + startAnimFrame = ch->currentAnimFrame-7; + xOffset = _defaultShapeTable[startAnimFrame].xOffset; + yOffset = _defaultShapeTable[startAnimFrame].yOffset; + if (_scaleMode) { + curAnimState->x1 = ch->x1; + curAnimState->y1 = ch->y1; + + _animator->_brandonScaleX = _scaleTable[ch->y1]; + _animator->_brandonScaleY = _scaleTable[ch->y1]; + + curAnimState->x1 += (_animator->_brandonScaleX * xOffset) >> 8; + curAnimState->y1 += (_animator->_brandonScaleY * yOffset) >> 8; + } else { + curAnimState->x1 = ch->x1 + xOffset; + curAnimState->y1 = ch->y1 + yOffset; + } + curAnimState->x2 = curAnimState->x1; + curAnimState->y2 = curAnimState->y1; + curAnimState->active = 1; + curAnimState->refreshFlag = 1; + curAnimState->bkgdChangeFlag = 1; + + if (ch->facing >= 1 && ch->facing <= 3) + curAnimState->flags |= 1; + else if (ch->facing >= 5 && ch->facing <= 7) + curAnimState->flags &= 0xFFFFFFFE; + + _animator->addObjectToQueue(curAnimState); + + ++addedObjects; + ++listAdded; + if (listAdded < 2) + i = 5; + } + + for (int i = 0; i < 11; ++i) { + curAnimState = &_animator->sprites()[i]; + + if (_sprites->_anims[i].play) { + curAnimState->active = 1; + curAnimState->refreshFlag = 1; + curAnimState->bkgdChangeFlag = 1; + } else { + curAnimState->active = 0; + curAnimState->refreshFlag = 0; + curAnimState->bkgdChangeFlag = 0; + } + curAnimState->height = _sprites->_anims[i].height; + curAnimState->height2 = _sprites->_anims[i].height2; + curAnimState->width = _sprites->_anims[i].width + 1; + curAnimState->width2 = _sprites->_anims[i].width2; + curAnimState->drawY = _sprites->_anims[i].drawY; + curAnimState->x1 = curAnimState->x2 = _sprites->_anims[i].x; + curAnimState->y1 = curAnimState->y2 = _sprites->_anims[i].y; + curAnimState->background = _sprites->_anims[i].background; + curAnimState->sceneAnimPtr = _sprites->_sceneShapes[_sprites->_anims[i].sprite]; + + curAnimState->disable = _sprites->_anims[i].disable; + + if (_sprites->_anims[i].unk2) + curAnimState->flags = 0x800; + else + curAnimState->flags = 0; + + if (_sprites->_anims[i].flipX) + curAnimState->flags |= 0x1; + + _animator->addObjectToQueue(curAnimState); + } + + for (int i = 0; i < 12; ++i) { + curAnimState = &_animator->items()[i]; + Room *curRoom = &_roomTable[_currentCharacter->sceneId]; + byte curItem = curRoom->itemsTable[i]; + if (curItem != 0xFF) { + curAnimState->drawY = curRoom->itemsYPos[i]; + curAnimState->sceneAnimPtr = _shapes[216+curItem]; + curAnimState->animFrameNumber = (int16)0xFFFF; + curAnimState->y1 = curRoom->itemsYPos[i]; + curAnimState->x1 = curRoom->itemsXPos[i]; + + curAnimState->x1 -= (_animator->fetchAnimWidth(curAnimState->sceneAnimPtr, _scaleTable[curAnimState->drawY])) >> 1; + curAnimState->y1 -= _animator->fetchAnimHeight(curAnimState->sceneAnimPtr, _scaleTable[curAnimState->drawY]); + + curAnimState->x2 = curAnimState->x1; + curAnimState->y2 = curAnimState->y1; + + curAnimState->active = 1; + curAnimState->refreshFlag = 1; + curAnimState->bkgdChangeFlag = 1; + + _animator->addObjectToQueue(curAnimState); + } else { + curAnimState->active = 0; + curAnimState->refreshFlag = 0; + curAnimState->bkgdChangeFlag = 0; + } + } + + _animator->preserveAnyChangedBackgrounds(); + curAnimState = _animator->actors(); + curAnimState->bkgdChangeFlag = 1; + curAnimState->refreshFlag = 1; + for (int i = 1; i < 28; ++i) { + curAnimState = &_animator->objects()[i]; + if (curAnimState->active) { + curAnimState->bkgdChangeFlag = 1; + curAnimState->refreshFlag = 1; + } + } + _animator->restoreAllObjectBackgrounds(); + _animator->preserveAnyChangedBackgrounds(); + _animator->prepDrawAllObjects(); + initSceneScreen(brandonAlive); + _animator->copyChangedObjectsForward(0); +} + +void KyraEngine::initSceneScreen(int brandonAlive) { + if (_flags.platform == Common::kPlatformAmiga) { + if (_unkScreenVar1 && !queryGameFlag(0xF0)) { + memset(_screen->getPalette(2), 0, 32*3); + if (_currentCharacter->sceneId != 117 || !queryGameFlag(0xB3)) + _screen->setScreenPalette(_screen->getPalette(2)); + } + + if (_unkScreenVar2 == 1) + _screen->shuffleScreen(8, 8, 304, 128, 2, 0, _unkScreenVar3, false); + else + _screen->copyRegion(8, 8, 8, 8, 304, 128, 2, 0); + + if (_unkScreenVar1 && !queryGameFlag(0xA0)) { + if (_currentCharacter->sceneId == 45 && _paletteChanged) + memcpy(_screen->getPalette(0) + 12*3, _screen->getPalette(4) + 12*3, 2); + + if (_currentCharacter->sceneId >= 229 && _currentCharacter->sceneId <= 245 && (_brandonStatusBit & 1)) + memcpy(_screen->getPalette(0), _screen->getPalette(0) + 320*3, 64); + + _screen->setScreenPalette(_screen->getPalette(0)); + } + } else { + if (_unkScreenVar1 && !queryGameFlag(0xA0)) { + for (int i = 0; i < 60; ++i) { + uint16 col = _screen->getPalette(0)[684+i]; + col += _screen->getPalette(1)[684+i] << 1; + col >>= 2; + _screen->getPalette(0)[684+i] = col; + } + _screen->setScreenPalette(_screen->getPalette(0)); + } + + if (_unkScreenVar2 == 1) + _screen->shuffleScreen(8, 8, 304, 128, 2, 0, _unkScreenVar3, false); + else + _screen->copyRegion(8, 8, 8, 8, 304, 128, 2, 0); + + if (_unkScreenVar1 && _paletteChanged) { + if (!queryGameFlag(0xA0)) { + memcpy(_screen->getPalette(0) + 684, _screen->getPalette(1) + 684, 60); + _screen->setScreenPalette(_screen->getPalette(0)); + } else { + memset(_screen->getPalette(0), 0, 768); + } + } + } + + // really call this here? + _screen->updateScreen(); + + if (!_scriptInterpreter->startScript(_scriptClick, 2)) + error("Could not start script function 2 of scene script"); + + _scriptClick->regs[7] = brandonAlive; + + while (_scriptInterpreter->validScript(_scriptClick)) + _scriptInterpreter->runScript(_scriptClick); + + setTextFadeTimerCountdown(-1); + if (_currentCharacter->sceneId == 210) { + if (_itemInHand != -1) + magicOutMouseItem(2, -1); + + _screen->hideMouse(); + for (int i = 0; i < 10; ++i) { + if (_currentCharacter->inventoryItems[i] != 0xFF) + magicOutMouseItem(2, i); + } + _screen->showMouse(); + } +} + +int KyraEngine::handleSceneChange(int xpos, int ypos, int unk1, int frameReset) { + debugC(9, kDebugLevelMain, "KyraEngine::handleSceneChange(%d, %d, %d, %d)", xpos, ypos, unk1, frameReset); + if (queryGameFlag(0xEF)) + unk1 = 0; + + int sceneId = _currentCharacter->sceneId; + _pathfinderFlag = 0; + + if (xpos < 12) { + if (_roomTable[sceneId].westExit != 0xFFFF) { + xpos = 12; + ypos = _sceneExits.westYPos; + _pathfinderFlag = 7; + } + } else if (xpos >= 308) { + if (_roomTable[sceneId].eastExit != 0xFFFF) { + xpos = 307; + ypos = _sceneExits.eastYPos; + _pathfinderFlag = 13; + } + } + + if (ypos <= (_northExitHeight&0xFF)+2) { + if (_roomTable[sceneId].northExit != 0xFFFF) { + xpos = _sceneExits.northXPos; + ypos = _northExitHeight & 0xFF; + _pathfinderFlag = 14; + } + } else if (ypos >= 136) { + if (_roomTable[sceneId].southExit != 0xFFFF) { + xpos = _sceneExits.southXPos; + ypos = 136; + _pathfinderFlag = 11; + } + } + + int temp = xpos - _currentCharacter->x1; + if (ABS(temp) < 4) { + temp = ypos - _currentCharacter->y1; + if (ABS(temp) < 2) + return 0; + } + + int x = (int16)(_currentCharacter->x1 & 0xFFFC); + int y = (int16)(_currentCharacter->y1 & 0xFFFE); + xpos = (int16)(xpos & 0xFFFC); + ypos = (int16)(ypos & 0xFFFE); + + int ret = findWay(x, y, xpos, ypos, _movFacingTable, 150); + _pathfinderFlag = 0; + + if (ret >= _lastFindWayRet) + _lastFindWayRet = ret; + + if (ret == 0x7D00 || ret == 0) + return 0; + + return processSceneChange(_movFacingTable, unk1, frameReset); +} + +int KyraEngine::processSceneChange(int *table, int unk1, int frameReset) { + debugC(9, kDebugLevelMain, "KyraEngine::processSceneChange(%p, %d, %d)", (const void *)table, unk1, frameReset); + if (queryGameFlag(0xEF)) + unk1 = 0; + + int *tableStart = table; + _sceneChangeState = 0; + _loopFlag2 = 0; + bool running = true; + int returnValue = 0; + uint32 nextFrame = 0; + _abortWalkFlag = false; + _mousePressFlag = false; + + while (running) { + if (_abortWalkFlag) { + *table = 8; + _currentCharacter->currentAnimFrame = 7; + _animator->animRefreshNPC(0); + _animator->updateAllObjectShapes(); + processInput(); + return 0; + } + bool forceContinue = false; + switch (*table) { + case 0: case 1: case 2: + case 3: case 4: case 5: + case 6: case 7: + _currentCharacter->facing = getOppositeFacingDirection(*table); + break; + + case 8: + forceContinue = true; + running = false; + break; + + default: + ++table; + forceContinue = true; + break; + } + + returnValue = changeScene(_currentCharacter->facing); + if (returnValue) { + running = false; + _abortWalkFlag = false; + } + + if (unk1) { + if (_mousePressFlag) { + running = false; + _sceneChangeState = 1; + } + } + + if (forceContinue || !running) + continue; + + int temp = 0; + if (table == tableStart || table[1] == 8) + temp = setCharacterPosition(0, 0); + else + temp = setCharacterPosition(0, table); + + if (temp) + ++table; + + nextFrame = getTimerDelay(5) * _tickLength + _system->getMillis(); + while (_system->getMillis() < nextFrame) { + updateGameTimers(); + + if (_currentCharacter->sceneId == 210) { + updateKyragemFading(); + if (seq_playEnd() || _beadStateVar == 4 || _beadStateVar == 5) { + *table = 8; + running = false; + break; + } + } + + if ((nextFrame - _system->getMillis()) >= 10) + delay(10, true); + } + } + + if (frameReset && !(_brandonStatusBit & 2)) + _currentCharacter->currentAnimFrame = 7; + + _animator->animRefreshNPC(0); + _animator->updateAllObjectShapes(); + return returnValue; +} + +int KyraEngine::changeScene(int facing) { + debugC(9, kDebugLevelMain, "KyraEngine::changeScene(%d)", facing); + if (queryGameFlag(0xEF)) { + if (_currentCharacter->sceneId == 5) + return 0; + } + + int xpos = _charXPosTable[facing] + _currentCharacter->x1; + int ypos = _charYPosTable[facing] + _currentCharacter->y1; + + if (xpos >= 12 && xpos <= 308) { + if (!lineIsPassable(xpos, ypos)) + return false; + } + + if (_exitListPtr) { + int16 *ptr = _exitListPtr; + // this loop should be only entered one time, seems to be some hack in the original + while (true) { + if (*ptr == -1) + break; + + if (*ptr > _currentCharacter->x1 || _currentCharacter->y1 < ptr[1] || _currentCharacter->x1 > ptr[2] || _currentCharacter->y1 > ptr[3]) { + ptr += 10; + break; + } + + _brandonPosX = ptr[6]; + _brandonPosY = ptr[7]; + uint16 sceneId = ptr[5]; + facing = ptr[4]; + int unk1 = ptr[8]; + int unk2 = ptr[9]; + + if (sceneId == 0xFFFF) { + switch (facing) { + case 0: + sceneId = _roomTable[_currentCharacter->sceneId].northExit; + break; + + case 2: + sceneId = _roomTable[_currentCharacter->sceneId].eastExit; + break; + + case 4: + sceneId = _roomTable[_currentCharacter->sceneId].southExit; + break; + + case 6: + sceneId = _roomTable[_currentCharacter->sceneId].westExit; + break; + + default: + break; + } + } + + _currentCharacter->facing = facing; + _animator->animRefreshNPC(0); + _animator->updateAllObjectShapes(); + enterNewScene(sceneId, facing, unk1, unk2, 0); + resetGameFlag(0xEE); + return 1; + } + } + + int returnValue = 0; + facing = 0; + + if ((_northExitHeight & 0xFF) + 2 >= ypos || (_northExitHeight & 0xFF) + 2 >= _currentCharacter->y1) { + facing = 0; + returnValue = 1; + } + + if (xpos >= 308 || (_currentCharacter->x1 + 4) >= 308) { + facing = 2; + returnValue = 1; + } + + if (((_northExitHeight >> 8) & 0xFF) - 2 < ypos || ((_northExitHeight >> 8) & 0xFF) - 2 < _currentCharacter->y1) { + facing = 4; + returnValue = 1; + } + + if (xpos <= 12 || _currentCharacter->y1 <= 12) { + facing = 6; + returnValue = 1; + } + + if (!returnValue) + return 0; + + uint16 sceneId = 0xFFFF; + switch (facing) { + case 0: + sceneId = _roomTable[_currentCharacter->sceneId].northExit; + break; + + case 2: + sceneId = _roomTable[_currentCharacter->sceneId].eastExit; + break; + + case 4: + sceneId = _roomTable[_currentCharacter->sceneId].southExit; + break; + + default: + sceneId = _roomTable[_currentCharacter->sceneId].westExit; + break; + } + + if (sceneId == 0xFFFF) + return 0; + + enterNewScene(sceneId, facing, 1, 1, 0); + return returnValue; +} + +void KyraEngine::setCharactersInDefaultScene() { + static const uint32 defaultSceneTable[][4] = { + { 0xFFFF, 0x0004, 0x0003, 0xFFFF }, + { 0xFFFF, 0x0022, 0xFFFF, 0x0000 }, + { 0xFFFF, 0x001D, 0x0021, 0xFFFF }, + { 0xFFFF, 0x0000, 0x0000, 0xFFFF } + }; + + for (int i = 1; i < 5; ++i) { + Character *cur = &_characterList[i]; + //cur->field_20 = 0; + + const uint32 *curTable = defaultSceneTable[i-1]; + cur->sceneId = curTable[0]; + + if (cur->sceneId == _currentCharacter->sceneId) + //++cur->field_20; + cur->sceneId = curTable[1/*cur->field_20*/]; + + //cur->field_23 = curTable[cur->field_20+1]; + } +} + +void KyraEngine::setCharactersPositions(int character) { + static uint16 initXPosTable[] = { + 0x3200, 0x0024, 0x2230, 0x2F00, 0x0020, 0x002B, + 0x00CA, 0x00F0, 0x0082, 0x00A2, 0x0042 + }; + static uint8 initYPosTable[] = { + 0x00, 0xA2, 0x00, 0x42, 0x00, + 0x67, 0x67, 0x60, 0x5A, 0x71, + 0x76 + }; + + assert(character < ARRAYSIZE(initXPosTable)); + Character *edit = &_characterList[character]; + edit->x1 = edit->x2 = initXPosTable[character]; + edit->y1 = edit->y2 = initYPosTable[character]; +} + +#pragma mark - +#pragma mark - Pathfinder +#pragma mark - + +int KyraEngine::findWay(int x, int y, int toX, int toY, int *moveTable, int moveTableSize) { + debugC(9, kDebugLevelMain, "KyraEngine::findWay(%d, %d, %d, %d, %p, %d)", x, y, toX, toY, (const void *)moveTable, moveTableSize); + x &= 0xFFFC; toX &= 0xFFFC; + y &= 0xFFFE; toY &= 0xFFFE; + x = (int16)x; y = (int16)y; toX = (int16)toX; toY = (int16)toY; + + if (x == toY && y == toY) { + moveTable[0] = 8; + return 0; + } + + int curX = x; + int curY = y; + int lastUsedEntry = 0; + int tempValue = 0; + int *pathTable1 = new int[0x7D0]; + int *pathTable2 = new int[0x7D0]; + assert(pathTable1 && pathTable2); + + while (true) { + int newFacing = getFacingFromPointToPoint(x, y, toX, toY); + changePosTowardsFacing(curX, curY, newFacing); + + if (curX == toX && curY == toY) { + if (!lineIsPassable(curX, curY)) + break; + moveTable[lastUsedEntry++] = newFacing; + break; + } + + if (lineIsPassable(curX, curY)) { + if (lastUsedEntry == moveTableSize) { + delete [] pathTable1; + delete [] pathTable2; + return 0x7D00; + } + // debug drawing + //if (curX >= 0 && curY >= 0 && curX < 320 && curY < 200) { + // _screen->setPagePixel(0, curX, curY, 11); + // _screen->updateScreen(); + // waitTicks(5); + //} + moveTable[lastUsedEntry++] = newFacing; + x = curX; + y = curY; + continue; + } + + int temp = 0; + while (true) { + newFacing = getFacingFromPointToPoint(curX, curY, toX, toY); + changePosTowardsFacing(curX, curY, newFacing); + // debug drawing + //if (curX >= 0 && curY >= 0 && curX < 320 && curY < 200) { + // _screen->setPagePixel(0, curX, curY, 8); + // _screen->updateScreen(); + // waitTicks(5); + //} + + if (!lineIsPassable(curX, curY)) { + if (curX != toX || curY != toY) + continue; + } + + if (curX == toX && curY == toY) { + if (!lineIsPassable(curX, curY)) { + tempValue = 0; + temp = 0; + break; + } + } + + temp = findSubPath(x, y, curX, curY, pathTable1, 1, 0x7D0); + tempValue = findSubPath(x, y, curX, curY, pathTable2, 0, 0x7D0); + if (curX == toX && curY == toY) { + if (temp == 0x7D00 && tempValue == 0x7D00) { + delete [] pathTable1; + delete [] pathTable2; + return 0x7D00; + } + } + + if (temp != 0x7D00 || tempValue != 0x7D00) + break; + } + + if (temp < tempValue) { + if (lastUsedEntry + temp > moveTableSize) { + delete [] pathTable1; + delete [] pathTable2; + return 0x7D00; + } + memcpy(&moveTable[lastUsedEntry], pathTable1, temp*sizeof(int)); + lastUsedEntry += temp; + } else { + if (lastUsedEntry + tempValue > moveTableSize) { + delete [] pathTable1; + delete [] pathTable2; + return 0x7D00; + } + memcpy(&moveTable[lastUsedEntry], pathTable2, tempValue*sizeof(int)); + lastUsedEntry += tempValue; + } + x = curX; + y = curY; + if (curX == toX && curY == toY) + break; + } + + delete [] pathTable1; + delete [] pathTable2; + moveTable[lastUsedEntry] = 8; + return getMoveTableSize(moveTable); +} + +int KyraEngine::findSubPath(int x, int y, int toX, int toY, int *moveTable, int start, int end) { + debugC(9, kDebugLevelMain, "KyraEngine::findSubPath(%d, %d, %d, %d, %p, %d, %d)", x, y, toX, toY, (const void *)moveTable, start, end); + // only used for debug specific code + //static uint16 unkTable[] = { 8, 5 }; + static const int8 facingTable1[] = { 7, 0, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 7, 0 }; + static const int8 facingTable2[] = { -1, 0, -1, 2, -1, 4, -1, 6, -1, 2, -1, 4, -1, 6, -1, 0 }; + static const int8 facingTable3[] = { 2, 4, 4, 6, 6, 0, 0, 2, 6, 6, 0, 0, 2, 2, 4, 4 }; + static const int8 addPosTableX[] = { -1, 0, -1, 4, -1, 0, -1, -4, -1, -4, -1, 0, -1, 4, -1, 0 }; + static const int8 addPosTableY[] = { -1, 2, -1, 0, -1, -2, -1, 0, -1, 0, -1, 2, -1, 0, -1, -2 }; + + // debug specific + //++unkTable[start]; + //while (_screen->getPalette(0)[unkTable[start]] != 0x0F) { + // ++unkTable[start]; + //} + + int xpos1 = x, xpos2 = x; + int ypos1 = y, ypos2 = y; + int newFacing = getFacingFromPointToPoint(x, y, toX, toY); + int position = 0; + + while (position != end) { + int newFacing2 = newFacing; + while (true) { + changePosTowardsFacing(xpos1, ypos1, facingTable1[start*8 + newFacing2]); + if (!lineIsPassable(xpos1, ypos1)) { + if (facingTable1[start*8 + newFacing2] == newFacing) + return 0x7D00; + newFacing2 = facingTable1[start*8 + newFacing2]; + xpos1 = x; + ypos1 = y; + continue; + } + newFacing = facingTable1[start*8 + newFacing2]; + break; + } + // debug drawing + //if (xpos1 >= 0 && ypos1 >= 0 && xpos1 < 320 && ypos1 < 200) { + // _screen->setPagePixel(0, xpos1, ypos1, unkTable[start]); + // _screen->updateScreen(); + // waitTicks(5); + //} + if (newFacing & 1) { + int temp = xpos1 + addPosTableX[newFacing + start * 8]; + if (toX == temp) { + temp = ypos1 + addPosTableY[newFacing + start * 8]; + if (toY == temp) { + moveTable[position++] = facingTable2[newFacing + start * 8]; + return position; + } + } + } + + moveTable[position++] = newFacing; + x = xpos1; + y = ypos1; + + if (x == toX && y == toY) + return position; + + if (xpos1 == xpos2 && ypos1 == ypos2) + break; + + newFacing = facingTable3[start*8 + newFacing]; + } + + return 0x7D00; +} + +int KyraEngine::getFacingFromPointToPoint(int x, int y, int toX, int toY) { + debugC(9, kDebugLevelMain, "KyraEngine::getFacingFromPointToPoint(%d, %d, %d, %d)", x, y, toX, toY); + static const int facingTable[] = { + 1, 0, 1, 2, 3, 4, 3, 2, 7, 0, 7, 6, 5, 4, 5, 6 + }; + + int facingEntry = 0; + int ydiff = y - toY; + if (ydiff < 0) { + ++facingEntry; + ydiff = -ydiff; + } + facingEntry <<= 1; + + int xdiff = toX - x; + if (xdiff < 0) { + ++facingEntry; + xdiff = -xdiff; + } + + if (xdiff >= ydiff) { + int temp = ydiff; + ydiff = xdiff; + xdiff = temp; + + facingEntry <<= 1; + } else { + facingEntry <<= 1; + facingEntry += 1; + } + int temp = (ydiff + 1) >> 1; + + if (xdiff < temp) { + facingEntry <<= 1; + facingEntry += 1; + } else { + facingEntry <<= 1; + } + + assert(facingEntry < ARRAYSIZE(facingTable)); + return facingTable[facingEntry]; +} + +void KyraEngine::changePosTowardsFacing(int &x, int &y, int facing) { + debugC(9, kDebugLevelMain, "KyraEngine::changePosTowardsFacing(%d, %d, %d)", x, y, facing); + x += _addXPosTable[facing]; + y += _addYPosTable[facing]; +} + +bool KyraEngine::lineIsPassable(int x, int y) { + debugC(9, kDebugLevelMain, "KyraEngine::lineIsPassable(%d, %d)", x, y); + if (queryGameFlag(0xEF)) { + if (_currentCharacter->sceneId == 5) + return true; + } + + if (_pathfinderFlag & 2) { + if (x >= 312) + return false; + } + + if (_pathfinderFlag & 4) { + if (y >= 136) + return false; + } + + if (_pathfinderFlag & 8) { + if (x < 8) + return false; + } + + if (_pathfinderFlag2) { + if (x <= 8 || x >= 312) + return true; + if (y < (_northExitHeight & 0xFF) || y > 135) + return true; + } + + if (y > 137) + return false; + + if (y < 0) + y = 0; + + int ypos = 8; + if (_scaleMode) { + ypos = (_scaleTable[y] >> 5) + 1; + if (8 < ypos) + ypos = 8; + } + + x -= (ypos >> 1); + + int xpos = x; + int xtemp = xpos + ypos - 1; + if (x < 0) + xpos = 0; + + if (xtemp > 319) + xtemp = 319; + + for (; xpos < xtemp; ++xpos) { + if (!_screen->getShapeFlag1(xpos, y)) + return false; + } + return true; +} + +int KyraEngine::getMoveTableSize(int *moveTable) { + debugC(9, kDebugLevelMain, "KyraEngine::getMoveTableSize(%p)", (const void *)moveTable); + int retValue = 0; + if (moveTable[0] == 8) + return 0; + + static const int facingTable[] = { + 4, 5, 6, 7, 0, 1, 2, 3 + }; + static const int unkTable[] = { + -1, -1, 1, 2, -1, 6, 7, -1, + -1, -1, -1, -1, 2, -1, 0, -1, + 1, -1, -1, -1, 3, 4, -1, 0, + 2, -1, -1, -1, -1, -1, 4, -1, + -1, 2, 3, -1, -1, -1, 5, 6, + 6, -1, 4, -1, -1, -1, -1, -1, + 7, 0, -1, 4, 5, -1, -1, -1, + -1, -1, 0, -1, 6, -1, -1, -1 + }; + + int *oldPosition = moveTable; + int *tempPosition = moveTable; + int *curPosition = moveTable + 1; + retValue = 1; + + while (*curPosition != 8) { + if (*oldPosition == facingTable[*curPosition]) { + retValue -= 2; + *oldPosition = 9; + *curPosition = 9; + + while (tempPosition != moveTable) { + --tempPosition; + if (*tempPosition != 9) + break; + } + + if (tempPosition == moveTable && *tempPosition == 9) { + while (*tempPosition != 8 && *tempPosition == 9) + ++tempPosition; + + if (*tempPosition == 8) + return 0; + } + + oldPosition = tempPosition; + curPosition = oldPosition+1; + + while (*curPosition != 8 && *curPosition == 9) + ++curPosition; + + continue; + } + + if (unkTable[*curPosition+((*oldPosition)*8)] != -1) { + --retValue; + *oldPosition = unkTable[*curPosition+((*oldPosition)*8)]; + *curPosition = 9; + + if (tempPosition != oldPosition) { + curPosition = oldPosition; + oldPosition = tempPosition; + while (true) { + if (tempPosition == moveTable) + break; + + --tempPosition; + if (*tempPosition != 9) + break; + + } + } else { + while (true) { + ++curPosition; + if (*curPosition != 9) + break; + } + } + continue; + } + + tempPosition = oldPosition; + oldPosition = curPosition; + ++retValue; + + while (true) { + ++curPosition; + if (*curPosition != 9) + break; + } + } + + return retValue; +} + +void KyraEngine::setupSceneResource(int sceneId) { + debugC(9, kDebugLevelMain, "KyraEngine::setupSceneResource(%d)", sceneId); + if (!_flags.isTalkie) + return; + + if (_currentRoom != 0xFFFF) { + assert(_currentRoom < _roomTableSize); + int tableId = _roomTable[_currentRoom].nameIndex; + assert(tableId < _roomFilenameTableSize); + + // unload our old room + char file[64]; + strcpy(file, _roomFilenameTable[tableId]); + strcat(file, ".VRM"); + _res->unloadPakFile(file); + + strcpy(file, _roomFilenameTable[tableId]); + strcat(file, ".PAK"); + _res->unloadPakFile(file); + + strcpy(file, _roomFilenameTable[tableId]); + strcat(file, ".APK"); + _res->unloadPakFile(file); + } + + assert(sceneId < _roomTableSize); + int tableId = _roomTable[sceneId].nameIndex; + assert(tableId < _roomFilenameTableSize); + + // load our new room + char file[64]; + strcpy(file, _roomFilenameTable[tableId]); + strcat(file, ".VRM"); + if (Common::File::exists(file)) + _res->loadPakFile(file); + + strcpy(file, _roomFilenameTable[tableId]); + strcat(file, ".PAK"); + if (Common::File::exists(file)) + _res->loadPakFile(file); + + strcpy(file, _roomFilenameTable[tableId]); + strcat(file, ".APK"); + if (Common::File::exists(file)) + _res->loadPakFile(file); +} + +} // end of namespace Kyra + diff --git a/engines/kyra/timer.cpp b/engines/kyra/timer.cpp deleted file mode 100644 index a35b701697..0000000000 --- a/engines/kyra/timer.cpp +++ /dev/null @@ -1,292 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -#include "kyra/kyra.h" -#include "kyra/screen.h" -#include "kyra/animator.h" - -#include "common/system.h" - -namespace Kyra { -void KyraEngine::setupTimers() { - debugC(9, kDebugLevelMain, "KyraEngine::setupTimers()"); - memset(_timers, 0, sizeof(_timers)); - - for (int i = 0; i < 34; i++) - _timers[i].active = 1; - - _timers[0].func = _timers[1].func = _timers[2].func = _timers[3].func = _timers[4].func = 0; //Unused. - _timers[5].func = _timers[6].func = _timers[7].func = _timers[8].func = _timers[9].func = 0; //_nullsub51; - _timers[10].func = _timers[11].func = _timers[12].func = _timers[13].func = 0; //_nullsub50; - _timers[14].func = &KyraEngine::timerCheckAnimFlag2; //_nullsub52; - _timers[15].func = &KyraEngine::timerUpdateHeadAnims; //_nullsub48; - _timers[16].func = &KyraEngine::timerSetFlags1; //_nullsub47; - _timers[17].func = 0; //sub_15120; - _timers[18].func = &KyraEngine::timerCheckAnimFlag1; //_nullsub53; - _timers[19].func = &KyraEngine::timerRedrawAmulet; //_nullsub54; - _timers[20].func = 0; //offset _timerDummy1 - _timers[21].func = 0; //sub_1517C; - _timers[22].func = 0; //offset _timerDummy2 - _timers[23].func = 0; //offset _timerDummy3, - _timers[24].func = 0; //_nullsub45; - _timers[25].func = 0; //offset _timerDummy4 - _timers[26].func = 0; //_nullsub46; - _timers[27].func = 0; //offset _timerDummy5, - _timers[28].func = 0; //offset _timerDummy6 - _timers[29].func = 0; //offset _timerDummy7, - _timers[30].func = 0; //offset _timerDummy8, - _timers[31].func = &KyraEngine::timerFadeText; //sub_151F8; - _timers[32].func = &KyraEngine::updateAnimFlag1; //_nullsub61; - _timers[33].func = &KyraEngine::updateAnimFlag2; //_nullsub62; - - _timers[0].countdown = _timers[1].countdown = _timers[2].countdown = _timers[3].countdown = _timers[4].countdown = -1; - _timers[5].countdown = 5; - _timers[6].countdown = 7; - _timers[7].countdown = 8; - _timers[8].countdown = 9; - _timers[9].countdown = 7; - _timers[10].countdown = _timers[11].countdown = _timers[12].countdown = _timers[13].countdown = 420; - _timers[14].countdown = 600; - _timers[15].countdown = 11; - _timers[16].countdown = _timers[17].countdown = 7200; - _timers[18].countdown = _timers[19].countdown = 600; - _timers[20].countdown = 7200; - _timers[21].countdown = 18000; - _timers[22].countdown = 7200; - _timers[23].countdown = _timers[24].countdown = _timers[25].countdown = _timers[26].countdown = _timers[27].countdown = 10800; - _timers[28].countdown = 21600; - _timers[29].countdown = 7200; - _timers[30].countdown = 10800; - _timers[31].countdown = -1; - _timers[32].countdown = 9; - _timers[33].countdown = 3; -} - -void KyraEngine::updateGameTimers() { - debugC(9, kDebugLevelMain, "KyraEngine::updateGameTimers()"); - - if (_system->getMillis() < _timerNextRun) - return; - - _timerNextRun += 99999; - - for (int i = 0; i < 34; i++) { - if (_timers[i].active && _timers[i].countdown > -1) { - if (_timers[i].nextRun <=_system->getMillis()) { - if (i > 4 && _timers[i].func) - (*this.*_timers[i].func)(i); - - _timers[i].nextRun = _system->getMillis() + _timers[i].countdown * _tickLength; - } - } - if (_timers[i].nextRun < _timerNextRun) - _timerNextRun = _timers[i].nextRun; - } -} - -void KyraEngine::clearNextEventTickCount() { - debugC(9, kDebugLevelMain, "KyraEngine::clearNextEventTickCount()"); - _timerNextRun = 0; -} - -void KyraEngine::setTimerDelay(uint8 timer, int32 countdown) { - debugC(9, kDebugLevelMain, "KyraEngine::setTimerDelay(%i, %d)", timer, countdown); - _timers[timer].countdown = countdown; -} - -int16 KyraEngine::getTimerDelay(uint8 timer) { - debugC(9, kDebugLevelMain, "KyraEngine::getTimerDelay(%i)", timer); - return _timers[timer].countdown; -} - -void KyraEngine::setTimerCountdown(uint8 timer, int32 countdown) { - debugC(9, kDebugLevelMain, "KyraEngine::setTimerCountdown(%i, %i)", timer, countdown); - _timers[timer].countdown = countdown; - _timers[timer].nextRun = _system->getMillis() + countdown * _tickLength; - - uint32 nextRun = _system->getMillis() + countdown * _tickLength; - if (nextRun < _timerNextRun) - _timerNextRun = nextRun; -} - -void KyraEngine::enableTimer(uint8 timer) { - debugC(9, kDebugLevelMain, "KyraEngine::enableTimer(%i)", timer); - _timers[timer].active = 1; -} - -void KyraEngine::disableTimer(uint8 timer) { - debugC(9, kDebugLevelMain, "KyraEngine::disableTimer(%i)", timer); - _timers[timer].active = 0; -} - -void KyraEngine::timerUpdateHeadAnims(int timerNum) { - debugC(9, kDebugLevelMain, "KyraEngine::timerUpdateHeadAnims(%i)", timerNum); - static int8 currentFrame = 0; - static const int8 frameTable[] = {4, 5, 4, 5, 4, 5, 0, 1, 4, 5, - 4, 4, 6, 4, 8, 1, 9, 4, -1}; - - if (_talkingCharNum < 0) - return; - - _currHeadShape = frameTable[currentFrame]; - currentFrame++; - - if (frameTable[currentFrame] == -1) - currentFrame = 0; - - _animator->animRefreshNPC(0); - _animator->animRefreshNPC(_talkingCharNum); -} - -void KyraEngine::timerSetFlags1(int timerNum) { - debugC(9, kDebugLevelMain, "KyraEngine::timerSetFlags(%i)", timerNum); - if (_currentCharacter->sceneId == 0x1C) - return; - - int rndNr = _rnd.getRandomNumberRng(0, 3); - - for (int i = 0; i < 4; i++) { - if (!queryGameFlag(rndNr + 17)) { - setGameFlag(rndNr + 17); - break; - } else { - rndNr++; - if (rndNr > 3) - rndNr = 0; - } - } -} - -void KyraEngine::timerFadeText(int timerNum) { - debugC(9, kDebugLevelMain, "KyraEngine::timerFadeText(%i)", timerNum); - _fadeText = true; -} - -void KyraEngine::updateAnimFlag1(int timerNum) { - debugC(9, kDebugLevelMain, "KyraEngine::updateAnimFlag1(%d)", timerNum); - if (_brandonStatusBit & 2) { - _brandonStatusBit0x02Flag = 1; - } -} - -void KyraEngine::updateAnimFlag2(int timerNum) { - debugC(9, kDebugLevelMain, "KyraEngine::updateAnimFlag2(%d)", timerNum); - if (_brandonStatusBit & 0x20) { - _brandonStatusBit0x20Flag = 1; - } -} - -void KyraEngine::setTextFadeTimerCountdown(int16 countdown) { - debugC(9, kDebugLevelMain, "KyraEngine::setTextFadeTimerCountdown(%i)", countdown); - //if (countdown == -1) - //countdown = 32000; - - setTimerCountdown(31, countdown*60); -} - -void KyraEngine::timerSetFlags2(int timerNum) { - debugC(9, kDebugLevelMain, "KyraEngine::timerSetFlags2(%i)", timerNum); - if (!((uint32*)(_flagsTable+0x2D))[timerNum]) - ((uint32*)(_flagsTable+0x2D))[timerNum] = 1; -} - -void KyraEngine::timerCheckAnimFlag1(int timerNum) { - debugC(9, kDebugLevelMain, "KyraEngine::timerCheckAnimFlag1(%i)", timerNum); - if (_brandonStatusBit & 0x20) { - checkAmuletAnimFlags(); - setTimerCountdown(18, -1); - } -} - -void KyraEngine::timerCheckAnimFlag2(int timerNum) { - debugC(9, kDebugLevelMain, "KyraEngine::timerCheckAnimFlag1(%i)", timerNum); - if (_brandonStatusBit & 0x2) { - checkAmuletAnimFlags(); - setTimerCountdown(14, -1); - } -} - -void KyraEngine::checkAmuletAnimFlags() { - debugC(9, kDebugLevelMain, "KyraEngine::checkSpecialAnimFlags()"); - if (_brandonStatusBit & 2) { - seq_makeBrandonNormal2(); - setTimerCountdown(19, 300); - } - - if (_brandonStatusBit & 0x20) { - seq_makeBrandonNormal(); - setTimerCountdown(19, 300); - } -} - -void KyraEngine::timerRedrawAmulet(int timerNum) { - debugC(9, kDebugLevelMain, "KyraEngine::timerRedrawAmulet(%i)", timerNum); - if (queryGameFlag(0xF1)) { - drawAmulet(); - setTimerCountdown(19, -1); - } -} - -void KyraEngine::drawAmulet() { - debugC(9, kDebugLevelMain, "KyraEngine::drawAmulet()"); - static const int16 amuletTable1[] = {0x167, 0x162, 0x15D, 0x158, 0x153, 0x150, 0x155, 0x15A, 0x15F, 0x164, 0x145, -1}; - static const int16 amuletTable3[] = {0x167, 0x162, 0x15D, 0x158, 0x153, 0x14F, 0x154, 0x159, 0x15E, 0x163, 0x144, -1}; - static const int16 amuletTable2[] = {0x167, 0x162, 0x15D, 0x158, 0x153, 0x152, 0x157, 0x15C, 0x161, 0x166, 0x147, -1}; - static const int16 amuletTable4[] = {0x167, 0x162, 0x15D, 0x158, 0x153, 0x151, 0x156, 0x15B, 0x160, 0x165, 0x146, -1}; - - resetGameFlag(0xF1); - _screen->hideMouse(); - - int i = 0; - while (amuletTable1[i] != -1) { - if (queryGameFlag(87)) - _screen->drawShape(0, _shapes[amuletTable1[i]], _amuletX[0], _amuletY[0], 0, 0); - - if (queryGameFlag(89)) - _screen->drawShape(0, _shapes[amuletTable2[i]], _amuletX[1], _amuletY[1], 0, 0); - - if (queryGameFlag(86)) - _screen->drawShape(0, _shapes[amuletTable3[i]], _amuletX[2], _amuletY[2], 0, 0); - - if (queryGameFlag(88)) - _screen->drawShape(0, _shapes[amuletTable4[i]], _amuletX[3], _amuletY[3], 0, 0); - - _screen->updateScreen(); - delayWithTicks(3); - i++; - } - _screen->showMouse(); -} - -void KyraEngine::setWalkspeed(uint8 newSpeed) { - debugC(9, kDebugLevelMain, "KyraEngine::setWalkspeed(%i)", newSpeed); - static const uint8 speeds[] = {11, 9, 6, 5, 3}; - - assert(newSpeed < ARRAYSIZE(speeds)); - setTimerDelay(5, speeds[newSpeed]); -} - -} // end of namespace Kyra - diff --git a/engines/kyra/timer_v1.cpp b/engines/kyra/timer_v1.cpp new file mode 100644 index 0000000000..a35b701697 --- /dev/null +++ b/engines/kyra/timer_v1.cpp @@ -0,0 +1,292 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include "kyra/kyra.h" +#include "kyra/screen.h" +#include "kyra/animator.h" + +#include "common/system.h" + +namespace Kyra { +void KyraEngine::setupTimers() { + debugC(9, kDebugLevelMain, "KyraEngine::setupTimers()"); + memset(_timers, 0, sizeof(_timers)); + + for (int i = 0; i < 34; i++) + _timers[i].active = 1; + + _timers[0].func = _timers[1].func = _timers[2].func = _timers[3].func = _timers[4].func = 0; //Unused. + _timers[5].func = _timers[6].func = _timers[7].func = _timers[8].func = _timers[9].func = 0; //_nullsub51; + _timers[10].func = _timers[11].func = _timers[12].func = _timers[13].func = 0; //_nullsub50; + _timers[14].func = &KyraEngine::timerCheckAnimFlag2; //_nullsub52; + _timers[15].func = &KyraEngine::timerUpdateHeadAnims; //_nullsub48; + _timers[16].func = &KyraEngine::timerSetFlags1; //_nullsub47; + _timers[17].func = 0; //sub_15120; + _timers[18].func = &KyraEngine::timerCheckAnimFlag1; //_nullsub53; + _timers[19].func = &KyraEngine::timerRedrawAmulet; //_nullsub54; + _timers[20].func = 0; //offset _timerDummy1 + _timers[21].func = 0; //sub_1517C; + _timers[22].func = 0; //offset _timerDummy2 + _timers[23].func = 0; //offset _timerDummy3, + _timers[24].func = 0; //_nullsub45; + _timers[25].func = 0; //offset _timerDummy4 + _timers[26].func = 0; //_nullsub46; + _timers[27].func = 0; //offset _timerDummy5, + _timers[28].func = 0; //offset _timerDummy6 + _timers[29].func = 0; //offset _timerDummy7, + _timers[30].func = 0; //offset _timerDummy8, + _timers[31].func = &KyraEngine::timerFadeText; //sub_151F8; + _timers[32].func = &KyraEngine::updateAnimFlag1; //_nullsub61; + _timers[33].func = &KyraEngine::updateAnimFlag2; //_nullsub62; + + _timers[0].countdown = _timers[1].countdown = _timers[2].countdown = _timers[3].countdown = _timers[4].countdown = -1; + _timers[5].countdown = 5; + _timers[6].countdown = 7; + _timers[7].countdown = 8; + _timers[8].countdown = 9; + _timers[9].countdown = 7; + _timers[10].countdown = _timers[11].countdown = _timers[12].countdown = _timers[13].countdown = 420; + _timers[14].countdown = 600; + _timers[15].countdown = 11; + _timers[16].countdown = _timers[17].countdown = 7200; + _timers[18].countdown = _timers[19].countdown = 600; + _timers[20].countdown = 7200; + _timers[21].countdown = 18000; + _timers[22].countdown = 7200; + _timers[23].countdown = _timers[24].countdown = _timers[25].countdown = _timers[26].countdown = _timers[27].countdown = 10800; + _timers[28].countdown = 21600; + _timers[29].countdown = 7200; + _timers[30].countdown = 10800; + _timers[31].countdown = -1; + _timers[32].countdown = 9; + _timers[33].countdown = 3; +} + +void KyraEngine::updateGameTimers() { + debugC(9, kDebugLevelMain, "KyraEngine::updateGameTimers()"); + + if (_system->getMillis() < _timerNextRun) + return; + + _timerNextRun += 99999; + + for (int i = 0; i < 34; i++) { + if (_timers[i].active && _timers[i].countdown > -1) { + if (_timers[i].nextRun <=_system->getMillis()) { + if (i > 4 && _timers[i].func) + (*this.*_timers[i].func)(i); + + _timers[i].nextRun = _system->getMillis() + _timers[i].countdown * _tickLength; + } + } + if (_timers[i].nextRun < _timerNextRun) + _timerNextRun = _timers[i].nextRun; + } +} + +void KyraEngine::clearNextEventTickCount() { + debugC(9, kDebugLevelMain, "KyraEngine::clearNextEventTickCount()"); + _timerNextRun = 0; +} + +void KyraEngine::setTimerDelay(uint8 timer, int32 countdown) { + debugC(9, kDebugLevelMain, "KyraEngine::setTimerDelay(%i, %d)", timer, countdown); + _timers[timer].countdown = countdown; +} + +int16 KyraEngine::getTimerDelay(uint8 timer) { + debugC(9, kDebugLevelMain, "KyraEngine::getTimerDelay(%i)", timer); + return _timers[timer].countdown; +} + +void KyraEngine::setTimerCountdown(uint8 timer, int32 countdown) { + debugC(9, kDebugLevelMain, "KyraEngine::setTimerCountdown(%i, %i)", timer, countdown); + _timers[timer].countdown = countdown; + _timers[timer].nextRun = _system->getMillis() + countdown * _tickLength; + + uint32 nextRun = _system->getMillis() + countdown * _tickLength; + if (nextRun < _timerNextRun) + _timerNextRun = nextRun; +} + +void KyraEngine::enableTimer(uint8 timer) { + debugC(9, kDebugLevelMain, "KyraEngine::enableTimer(%i)", timer); + _timers[timer].active = 1; +} + +void KyraEngine::disableTimer(uint8 timer) { + debugC(9, kDebugLevelMain, "KyraEngine::disableTimer(%i)", timer); + _timers[timer].active = 0; +} + +void KyraEngine::timerUpdateHeadAnims(int timerNum) { + debugC(9, kDebugLevelMain, "KyraEngine::timerUpdateHeadAnims(%i)", timerNum); + static int8 currentFrame = 0; + static const int8 frameTable[] = {4, 5, 4, 5, 4, 5, 0, 1, 4, 5, + 4, 4, 6, 4, 8, 1, 9, 4, -1}; + + if (_talkingCharNum < 0) + return; + + _currHeadShape = frameTable[currentFrame]; + currentFrame++; + + if (frameTable[currentFrame] == -1) + currentFrame = 0; + + _animator->animRefreshNPC(0); + _animator->animRefreshNPC(_talkingCharNum); +} + +void KyraEngine::timerSetFlags1(int timerNum) { + debugC(9, kDebugLevelMain, "KyraEngine::timerSetFlags(%i)", timerNum); + if (_currentCharacter->sceneId == 0x1C) + return; + + int rndNr = _rnd.getRandomNumberRng(0, 3); + + for (int i = 0; i < 4; i++) { + if (!queryGameFlag(rndNr + 17)) { + setGameFlag(rndNr + 17); + break; + } else { + rndNr++; + if (rndNr > 3) + rndNr = 0; + } + } +} + +void KyraEngine::timerFadeText(int timerNum) { + debugC(9, kDebugLevelMain, "KyraEngine::timerFadeText(%i)", timerNum); + _fadeText = true; +} + +void KyraEngine::updateAnimFlag1(int timerNum) { + debugC(9, kDebugLevelMain, "KyraEngine::updateAnimFlag1(%d)", timerNum); + if (_brandonStatusBit & 2) { + _brandonStatusBit0x02Flag = 1; + } +} + +void KyraEngine::updateAnimFlag2(int timerNum) { + debugC(9, kDebugLevelMain, "KyraEngine::updateAnimFlag2(%d)", timerNum); + if (_brandonStatusBit & 0x20) { + _brandonStatusBit0x20Flag = 1; + } +} + +void KyraEngine::setTextFadeTimerCountdown(int16 countdown) { + debugC(9, kDebugLevelMain, "KyraEngine::setTextFadeTimerCountdown(%i)", countdown); + //if (countdown == -1) + //countdown = 32000; + + setTimerCountdown(31, countdown*60); +} + +void KyraEngine::timerSetFlags2(int timerNum) { + debugC(9, kDebugLevelMain, "KyraEngine::timerSetFlags2(%i)", timerNum); + if (!((uint32*)(_flagsTable+0x2D))[timerNum]) + ((uint32*)(_flagsTable+0x2D))[timerNum] = 1; +} + +void KyraEngine::timerCheckAnimFlag1(int timerNum) { + debugC(9, kDebugLevelMain, "KyraEngine::timerCheckAnimFlag1(%i)", timerNum); + if (_brandonStatusBit & 0x20) { + checkAmuletAnimFlags(); + setTimerCountdown(18, -1); + } +} + +void KyraEngine::timerCheckAnimFlag2(int timerNum) { + debugC(9, kDebugLevelMain, "KyraEngine::timerCheckAnimFlag1(%i)", timerNum); + if (_brandonStatusBit & 0x2) { + checkAmuletAnimFlags(); + setTimerCountdown(14, -1); + } +} + +void KyraEngine::checkAmuletAnimFlags() { + debugC(9, kDebugLevelMain, "KyraEngine::checkSpecialAnimFlags()"); + if (_brandonStatusBit & 2) { + seq_makeBrandonNormal2(); + setTimerCountdown(19, 300); + } + + if (_brandonStatusBit & 0x20) { + seq_makeBrandonNormal(); + setTimerCountdown(19, 300); + } +} + +void KyraEngine::timerRedrawAmulet(int timerNum) { + debugC(9, kDebugLevelMain, "KyraEngine::timerRedrawAmulet(%i)", timerNum); + if (queryGameFlag(0xF1)) { + drawAmulet(); + setTimerCountdown(19, -1); + } +} + +void KyraEngine::drawAmulet() { + debugC(9, kDebugLevelMain, "KyraEngine::drawAmulet()"); + static const int16 amuletTable1[] = {0x167, 0x162, 0x15D, 0x158, 0x153, 0x150, 0x155, 0x15A, 0x15F, 0x164, 0x145, -1}; + static const int16 amuletTable3[] = {0x167, 0x162, 0x15D, 0x158, 0x153, 0x14F, 0x154, 0x159, 0x15E, 0x163, 0x144, -1}; + static const int16 amuletTable2[] = {0x167, 0x162, 0x15D, 0x158, 0x153, 0x152, 0x157, 0x15C, 0x161, 0x166, 0x147, -1}; + static const int16 amuletTable4[] = {0x167, 0x162, 0x15D, 0x158, 0x153, 0x151, 0x156, 0x15B, 0x160, 0x165, 0x146, -1}; + + resetGameFlag(0xF1); + _screen->hideMouse(); + + int i = 0; + while (amuletTable1[i] != -1) { + if (queryGameFlag(87)) + _screen->drawShape(0, _shapes[amuletTable1[i]], _amuletX[0], _amuletY[0], 0, 0); + + if (queryGameFlag(89)) + _screen->drawShape(0, _shapes[amuletTable2[i]], _amuletX[1], _amuletY[1], 0, 0); + + if (queryGameFlag(86)) + _screen->drawShape(0, _shapes[amuletTable3[i]], _amuletX[2], _amuletY[2], 0, 0); + + if (queryGameFlag(88)) + _screen->drawShape(0, _shapes[amuletTable4[i]], _amuletX[3], _amuletY[3], 0, 0); + + _screen->updateScreen(); + delayWithTicks(3); + i++; + } + _screen->showMouse(); +} + +void KyraEngine::setWalkspeed(uint8 newSpeed) { + debugC(9, kDebugLevelMain, "KyraEngine::setWalkspeed(%i)", newSpeed); + static const uint8 speeds[] = {11, 9, 6, 5, 3}; + + assert(newSpeed < ARRAYSIZE(speeds)); + setTimerDelay(5, speeds[newSpeed]); +} + +} // end of namespace Kyra + -- cgit v1.2.3 From b01232f08ad34ac16e36a83e32ca741fc8fc2169 Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Sun, 29 Jul 2007 16:29:41 +0000 Subject: - Added parser strings for Big Red Adventure - Pushed parser strings initialization down to engine subclasses svn-id: r28295 --- engines/parallaction/animation.cpp | 2 +- engines/parallaction/parallaction.cpp | 2 - engines/parallaction/parallaction.h | 22 +++- engines/parallaction/parallaction_br.cpp | 2 + engines/parallaction/parallaction_ns.cpp | 2 + engines/parallaction/staticres.cpp | 193 +++++++++++++++++++++++++++++-- 6 files changed, 206 insertions(+), 17 deletions(-) (limited to 'engines') diff --git a/engines/parallaction/animation.cpp b/engines/parallaction/animation.cpp index 281e3e8da9..118f35e705 100644 --- a/engines/parallaction/animation.cpp +++ b/engines/parallaction/animation.cpp @@ -468,7 +468,7 @@ void jobRunScripts(void *parm, Job *j) { while (((*inst)->_index != INST_SHOW) && (a->_flags & kFlagsActing)) { - debugC(9, kDebugJobs, "Animation: %s, instruction: %s", a->_label._text, (*inst)->_index == INST_END ? "end" : _instructionNamesRes[(*inst)->_index - 1]); + debugC(9, kDebugJobs, "Animation: %s, instruction: %s", a->_label._text, (*inst)->_index == INST_END ? "end" : _vm->_instructionNamesRes[(*inst)->_index - 1]); switch ((*inst)->_index) { case INST_ENDLOOP: // endloop diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp index a31559711b..e92d9f36d4 100644 --- a/engines/parallaction/parallaction.cpp +++ b/engines/parallaction/parallaction.cpp @@ -146,8 +146,6 @@ Parallaction::~Parallaction() { int Parallaction::init() { - initResources(); // needs to be pushed into subclass - _engineFlags = 0; _objectsNames = NULL; _globalTable = NULL; diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h index 25753f60b2..eabdf33282 100644 --- a/engines/parallaction/parallaction.h +++ b/engines/parallaction/parallaction.h @@ -182,8 +182,6 @@ extern uint16 _introSarcData3; // sarcophagus stuff to be saved extern uint16 _introSarcData2; // sarcophagus stuff to be saved extern char _saveData1[]; extern uint32 _commandFlags; -extern const char *_instructionNamesRes[]; -extern const char *_commandsNamesRes[]; extern const char *_dinoName; extern const char *_donnaName; extern const char *_doughName; @@ -435,7 +433,6 @@ protected: // members void initGame(); void initGlobals(); - void initResources(); void runGame(); uint32 getElapsedTime(); void resetTimer(); @@ -482,6 +479,13 @@ protected: // members public: virtual void callFunction(uint index, void* parm) { } +public: + const char **_zoneFlagNamesRes; + const char **_zoneTypeNamesRes; + const char **_commandsNamesRes; + const char **_callableNamesRes; + const char **_instructionNamesRes; + }; class Parallaction_ns : public Parallaction { @@ -494,6 +498,10 @@ public: public: virtual void callFunction(uint index, void* parm); + +private: + void initResources(); + }; class Parallaction_br : public Parallaction { @@ -504,6 +512,14 @@ public: int init(); +public: + Table *_audioCommandsNames; + const char **_audioCommandsNamesRes; + +private: + void initResources(); + + }; // FIXME: remove global diff --git a/engines/parallaction/parallaction_br.cpp b/engines/parallaction/parallaction_br.cpp index 1609921d85..44009bdf5c 100644 --- a/engines/parallaction/parallaction_br.cpp +++ b/engines/parallaction/parallaction_br.cpp @@ -50,6 +50,8 @@ int Parallaction_br::init() { _soundMan = new DummySoundMan(this); + initResources(); + Parallaction::init(); return 0; diff --git a/engines/parallaction/parallaction_ns.cpp b/engines/parallaction/parallaction_ns.cpp index 5f0fb0fe84..e971701d6f 100644 --- a/engines/parallaction/parallaction_ns.cpp +++ b/engines/parallaction/parallaction_ns.cpp @@ -61,6 +61,8 @@ int Parallaction_ns::init() { _soundMan = new AmigaSoundMan(this); } + initResources(); + Parallaction::init(); return 0; diff --git a/engines/parallaction/staticres.cpp b/engines/parallaction/staticres.cpp index e6cbc303b0..30d2b0c95a 100644 --- a/engines/parallaction/staticres.cpp +++ b/engines/parallaction/staticres.cpp @@ -219,7 +219,7 @@ byte _amigaTopazFont[2600] = -const char *_zoneFlagNamesRes[] = { +const char *_zoneFlagNamesRes_ns[] = { "closed", "active", "remove", @@ -234,7 +234,7 @@ const char *_zoneFlagNamesRes[] = { "nowalk" }; -const char *_zoneTypeNamesRes[] = { +const char *_zoneTypeNamesRes_ns[] = { "examine", "door", "get", @@ -262,7 +262,7 @@ const char _gameNames[10][20] = { "GAME10" }; -const char *_commandsNamesRes[] = { +const char *_commandsNamesRes_ns[] = { "set", "clear", "start", @@ -281,7 +281,7 @@ const char *_commandsNamesRes[] = { "stop" }; -const char *_instructionNamesRes[] = { +const char *_instructionNamesRes_ns[] = { "on", "off", "x", @@ -302,7 +302,7 @@ const char *_instructionNamesRes[] = { "move" }; -const char *_callableNamesRes[] = { +const char *_callableNamesRes_ns[] = { "Projector", "HBOff", "StartIntro", @@ -330,6 +330,148 @@ const char *_callableNamesRes[] = { "TestResult" }; +const char *_zoneTypeNamesRes_br[] = { + "examine", + "door", + "get", + "merge", + "taste", + "hear", + "feel", + "speak", + "none", + "trap", + "you", + "command", + "path", + "box" +}; + +const char *_zoneFlagNamesRes_br[] = { + "closed", + "active", + "remove", + "acting", + "locked", + "fixed", + "noname", + "nomasked", + "looping", + "added", + "character", + "nowalk", + "yourself", + "scaled", + "selfuse" +}; + +const char *_instructionNamesRes_br[] = { + "on", + "off", + "x", + "y", + "z", + "f", + "loop", + "endloop", + "show", + "inc", + "dec", + "set", + "put", + "call", + "wait", + "start", + "process", + "move", + "color", + "sound", + "mask", + "print", + "text", + "mul", + "div", + "if", + "ifeq", + "iflt", + "ifgt", + "endif", + "stop" +}; + +const char *_commandsNamesRes_br[] = { + "set", + "clear", + "start", + "speak", + "get" + "location", + "open", + "close", + "on", + "off", + "call", + "toggle", + "drop", + "quit", + "move", + "stop", + "character", + "followme", + "onmouse", + "offmouse", + "add", + "leave", + "inc", + "dec", + "text", + "dummy", + "dummy", + "let", + "music", + "fix", + "unfix", + "zeta", + "scroll", + "swap", + "give", + "text", + "part", + "dummy", + "return", + "onsave", + "offsave" +}; + +const char *_callableNamesRes_br[] = { + "blufade", + "resetpalette", + "ferrcycle", + "lipsinc", + "albycle", + "password" +}; + +const char *_audioCommandsNamesRes_br[] = { + "play", + "stop", + "pause", + "channel_level", + "fadein", + "fadeout", + "volume", + " ", + "faderate", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "loop" +}; + typedef void (*callable)(void*); @@ -385,13 +527,19 @@ const char *_minidoughName = "minidough"; const char *_minidrkiName = "minidrki"; -void Parallaction::initResources() { +void Parallaction_ns::initResources() { - _callableNames = new Table(ARRAYSIZE(_callableNamesRes), _callableNamesRes); - _instructionNames = new Table(ARRAYSIZE(_instructionNamesRes), _instructionNamesRes); - _zoneFlagNames = new Table(ARRAYSIZE(_zoneFlagNamesRes), _zoneFlagNamesRes); - _zoneTypeNames = new Table(ARRAYSIZE(_zoneTypeNamesRes), _zoneTypeNamesRes); - _commandsNames = new Table(ARRAYSIZE(_commandsNamesRes), _commandsNamesRes); + _zoneFlagNamesRes = _zoneFlagNamesRes_ns; + _zoneTypeNamesRes = _zoneTypeNamesRes_ns; + _commandsNamesRes = _commandsNamesRes_ns; + _callableNamesRes = _callableNamesRes_ns; + _instructionNamesRes = _instructionNamesRes_ns; + + _callableNames = new Table(ARRAYSIZE(_zoneFlagNamesRes_ns), _zoneFlagNamesRes_ns); + _instructionNames = new Table(ARRAYSIZE(_instructionNamesRes_ns), _instructionNamesRes_ns); + _zoneFlagNames = new Table(ARRAYSIZE(_zoneFlagNamesRes_ns), _zoneFlagNamesRes_ns); + _zoneTypeNames = new Table(ARRAYSIZE(_zoneTypeNamesRes_ns), _zoneTypeNamesRes_ns); + _commandsNames = new Table(ARRAYSIZE(_commandsNamesRes_ns), _commandsNamesRes_ns); _localFlagNames = new Table(120); _localFlagNames->addData("visited"); @@ -452,5 +600,28 @@ void Parallaction::initResources() { } +void Parallaction_br::initResources() { + + _zoneFlagNamesRes = _zoneFlagNamesRes_br; + _zoneTypeNamesRes = _zoneTypeNamesRes_br; + _commandsNamesRes = _commandsNamesRes_br; + _callableNamesRes = _callableNamesRes_br; + _instructionNamesRes = _instructionNamesRes_br; + _audioCommandsNamesRes = _audioCommandsNamesRes_br; + + _callableNames = new Table(ARRAYSIZE(_callableNamesRes_br), _callableNamesRes_br); + _instructionNames = new Table(ARRAYSIZE(_instructionNamesRes_br), _instructionNamesRes_br); + _zoneFlagNames = new Table(ARRAYSIZE(_zoneFlagNamesRes_br), _zoneFlagNamesRes_br); + _zoneTypeNames = new Table(ARRAYSIZE(_zoneTypeNamesRes_br), _zoneTypeNamesRes_br); + _commandsNames = new Table(ARRAYSIZE(_commandsNamesRes_br), _commandsNamesRes_br); + _audioCommandsNames = new Table(ARRAYSIZE(_audioCommandsNamesRes_br), _audioCommandsNamesRes_br); + + // TODO: make sure there are 120 max locations in Big Red Adventure + _localFlagNames = new Table(120); + _localFlagNames->addData("visited"); + + // TODO: init callables for Big Red Adventure + +} } // namespace Parallaction -- cgit v1.2.3 From 076d6b1bc1c4f62732ff46a0931c6bc28ef9a08f Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 29 Jul 2007 16:31:29 +0000 Subject: Restructure Kyrandia sourcecode (part 2, compiling works again) svn-id: r28296 --- engines/kyra/animator_v1.cpp | 6 +- engines/kyra/animator_v1.h | 6 +- engines/kyra/debugger.cpp | 44 +- engines/kyra/debugger.h | 11 +- engines/kyra/gui_v1.cpp | 329 ++++---------- engines/kyra/gui_v2.cpp | 195 +++++++++ engines/kyra/items_v1.cpp | 128 +++--- engines/kyra/kyra.cpp | 979 +----------------------------------------- engines/kyra/kyra.h | 869 +++---------------------------------- engines/kyra/kyra_v1.cpp | 969 +++++++++++++++++++++++++++++++++++++++++ engines/kyra/kyra_v1.h | 792 ++++++++++++++++++++++++++++++++++ engines/kyra/kyra_v2.cpp | 10 + engines/kyra/kyra_v2.h | 27 +- engines/kyra/kyra_v3.cpp | 8 +- engines/kyra/kyra_v3.h | 11 +- engines/kyra/module.mk | 17 +- engines/kyra/saveload_v1.cpp | 8 +- engines/kyra/scene_v1.cpp | 96 ++--- engines/kyra/screen.cpp | 13 - engines/kyra/screen.h | 8 +- engines/kyra/screen_v1.cpp | 53 +++ engines/kyra/screen_v1.h | 48 +++ engines/kyra/screen_v2.cpp | 41 ++ engines/kyra/screen_v2.h | 45 ++ engines/kyra/script_v1.cpp | 2 +- engines/kyra/seqplayer.cpp | 3 +- engines/kyra/seqplayer.h | 7 +- engines/kyra/sequences_v1.cpp | 136 +++--- engines/kyra/sound.cpp | 111 ----- engines/kyra/sound_v1.cpp | 140 ++++++ engines/kyra/sprites.cpp | 6 +- engines/kyra/sprites.h | 9 +- engines/kyra/staticres.cpp | 127 +++--- engines/kyra/text.cpp | 365 ---------------- engines/kyra/text_v1.cpp | 397 +++++++++++++++++ engines/kyra/timer_v1.cpp | 104 ++--- 36 files changed, 3237 insertions(+), 2883 deletions(-) create mode 100644 engines/kyra/gui_v2.cpp create mode 100644 engines/kyra/screen_v1.cpp create mode 100644 engines/kyra/screen_v1.h create mode 100644 engines/kyra/screen_v2.cpp create mode 100644 engines/kyra/screen_v2.h create mode 100644 engines/kyra/sound_v1.cpp create mode 100644 engines/kyra/text_v1.cpp (limited to 'engines') diff --git a/engines/kyra/animator_v1.cpp b/engines/kyra/animator_v1.cpp index 7683bb6417..4169b59a36 100644 --- a/engines/kyra/animator_v1.cpp +++ b/engines/kyra/animator_v1.cpp @@ -26,15 +26,15 @@ #include "common/stdafx.h" #include "common/endian.h" -#include "kyra/kyra.h" +#include "kyra/kyra_v1.h" #include "kyra/screen.h" -#include "kyra/animator.h" +#include "kyra/animator_v1.h" #include "kyra/sprites.h" #include "common/system.h" namespace Kyra { -ScreenAnimator::ScreenAnimator(KyraEngine *vm, OSystem *system) { +ScreenAnimator::ScreenAnimator(KyraEngine_v1 *vm, OSystem *system) { _vm = vm; _screen = vm->screen(); _initOk = false; diff --git a/engines/kyra/animator_v1.h b/engines/kyra/animator_v1.h index e817be86d5..8b554adf12 100644 --- a/engines/kyra/animator_v1.h +++ b/engines/kyra/animator_v1.h @@ -27,7 +27,7 @@ #define KYRA_ANIMATOR_H namespace Kyra { -class KyraEngine; +class KyraEngine_v1; class Screen; struct AnimObject { @@ -53,7 +53,7 @@ struct AnimObject { class ScreenAnimator { public: - ScreenAnimator(KyraEngine *vm, OSystem *system); + ScreenAnimator(KyraEngine_v1 *vm, OSystem *system); virtual ~ScreenAnimator(); operator bool() const { return _initOk; } @@ -101,7 +101,7 @@ public: int _brandonScaleY; protected: - KyraEngine *_vm; + KyraEngine_v1 *_vm; Screen *_screen; OSystem *_system; bool _initOk; diff --git a/engines/kyra/debugger.cpp b/engines/kyra/debugger.cpp index d5909bd8b0..0a1974c3f4 100644 --- a/engines/kyra/debugger.cpp +++ b/engines/kyra/debugger.cpp @@ -27,35 +27,35 @@ #include "common/config-manager.h" #include "common/system.h" #include "kyra/debugger.h" -#include "kyra/kyra.h" +#include "kyra/kyra_v1.h" #include "kyra/screen.h" namespace Kyra { -Debugger::Debugger(KyraEngine *vm) - : GUI::Debugger() { +Debugger_v1::Debugger_v1(KyraEngine_v1 *vm) + : Debugger(vm) { _vm = vm; - DCmd_Register("continue", WRAP_METHOD(Debugger, Cmd_Exit)); - DCmd_Register("enter", WRAP_METHOD(Debugger, cmd_enterRoom)); - DCmd_Register("rooms", WRAP_METHOD(Debugger, cmd_listRooms)); - DCmd_Register("flags", WRAP_METHOD(Debugger, cmd_listFlags)); - DCmd_Register("toggleflag", WRAP_METHOD(Debugger, cmd_toggleFlag)); - DCmd_Register("queryflag", WRAP_METHOD(Debugger, cmd_queryFlag)); - DCmd_Register("timers", WRAP_METHOD(Debugger, cmd_listTimers)); - DCmd_Register("settimercountdown", WRAP_METHOD(Debugger, cmd_setTimerCountdown)); - DCmd_Register("give", WRAP_METHOD(Debugger, cmd_giveItem)); + DCmd_Register("continue", WRAP_METHOD(Debugger_v1, Cmd_Exit)); + DCmd_Register("enter", WRAP_METHOD(Debugger_v1, cmd_enterRoom)); + DCmd_Register("rooms", WRAP_METHOD(Debugger_v1, cmd_listRooms)); + DCmd_Register("flags", WRAP_METHOD(Debugger_v1, cmd_listFlags)); + DCmd_Register("toggleflag", WRAP_METHOD(Debugger_v1, cmd_toggleFlag)); + DCmd_Register("queryflag", WRAP_METHOD(Debugger_v1, cmd_queryFlag)); + DCmd_Register("timers", WRAP_METHOD(Debugger_v1, cmd_listTimers)); + DCmd_Register("settimercountdown", WRAP_METHOD(Debugger_v1, cmd_setTimerCountdown)); + DCmd_Register("give", WRAP_METHOD(Debugger_v1, cmd_giveItem)); } -void Debugger::preEnter() { +void Debugger_v1::preEnter() { //_vm->midi.pause(1); } -void Debugger::postEnter() { +void Debugger_v1::postEnter() { //_vm->midi.pause(0); } -bool Debugger::cmd_enterRoom(int argc, const char **argv) { +bool Debugger_v1::cmd_enterRoom(int argc, const char **argv) { uint direction = 0; if (argc > 1) { int room = atoi(argv[1]); @@ -93,7 +93,7 @@ bool Debugger::cmd_enterRoom(int argc, const char **argv) { return true; } -bool Debugger::cmd_listRooms(int argc, const char **argv) { +bool Debugger_v1::cmd_listRooms(int argc, const char **argv) { for (int i = 0; i < _vm->_roomTableSize; i++) { DebugPrintf("%-3i: %-10s", i, _vm->_roomFilenameTable[_vm->_roomTable[i].nameIndex]); if (!(i % 8)) @@ -104,7 +104,7 @@ bool Debugger::cmd_listRooms(int argc, const char **argv) { return true; } -bool Debugger::cmd_listFlags(int argc, const char **argv) { +bool Debugger_v1::cmd_listFlags(int argc, const char **argv) { for (int i = 0; i < (int)sizeof(_vm->_flagsTable)*8; i++) { DebugPrintf("(%-3i): %-5i", i, _vm->queryGameFlag(i)); if (!(i % 10)) @@ -114,7 +114,7 @@ bool Debugger::cmd_listFlags(int argc, const char **argv) { return true; } -bool Debugger::cmd_toggleFlag(int argc, const char **argv) { +bool Debugger_v1::cmd_toggleFlag(int argc, const char **argv) { if (argc > 1) { uint flag = atoi(argv[1]); if (_vm->queryGameFlag(flag)) @@ -129,7 +129,7 @@ bool Debugger::cmd_toggleFlag(int argc, const char **argv) { return true; } -bool Debugger::cmd_queryFlag(int argc, const char **argv) { +bool Debugger_v1::cmd_queryFlag(int argc, const char **argv) { if (argc > 1) { uint flag = atoi(argv[1]); DebugPrintf("Flag %i is %i\n", flag, _vm->queryGameFlag(flag)); @@ -140,14 +140,14 @@ bool Debugger::cmd_queryFlag(int argc, const char **argv) { return true; } -bool Debugger::cmd_listTimers(int argc, const char **argv) { +bool Debugger_v1::cmd_listTimers(int argc, const char **argv) { for (int i = 0; i < ARRAYSIZE(_vm->_timers); i++) DebugPrintf("Timer %-2i: Active: %-3s Countdown: %-6i\n", i, _vm->_timers[i].active ? "Yes" : "No", _vm->_timers[i].countdown); return true; } -bool Debugger::cmd_setTimerCountdown(int argc, const char **argv) { +bool Debugger_v1::cmd_setTimerCountdown(int argc, const char **argv) { if (argc > 2) { uint timer = atoi(argv[1]); uint countdown = atoi(argv[2]); @@ -160,7 +160,7 @@ bool Debugger::cmd_setTimerCountdown(int argc, const char **argv) { return true; } -bool Debugger::cmd_giveItem(int argc, const char **argv) { +bool Debugger_v1::cmd_giveItem(int argc, const char **argv) { if (argc == 2) { int item = atoi(argv[1]); diff --git a/engines/kyra/debugger.h b/engines/kyra/debugger.h index 2d0e82c220..16b1e42a58 100644 --- a/engines/kyra/debugger.h +++ b/engines/kyra/debugger.h @@ -31,14 +31,21 @@ namespace Kyra { class KyraEngine; +class KyraEngine_v1; class Debugger : public GUI::Debugger { public: - Debugger(KyraEngine *vm); + Debugger(KyraEngine *vm) {} virtual ~Debugger() {} // we need this for __SYMBIAN32__ archaic gcc/UIQ +}; + +class Debugger_v1 : public Debugger { +public: + Debugger_v1(KyraEngine_v1 *vm); + virtual ~Debugger_v1() {} // we need this for __SYMBIAN32__ archaic gcc/UIQ protected: - KyraEngine *_vm; + KyraEngine_v1 *_vm; virtual void preEnter(); virtual void postEnter(); diff --git a/engines/kyra/gui_v1.cpp b/engines/kyra/gui_v1.cpp index fe051dd75c..2452185c24 100644 --- a/engines/kyra/gui_v1.cpp +++ b/engines/kyra/gui_v1.cpp @@ -23,11 +23,11 @@ * */ -#include "kyra/kyra.h" +#include "kyra/kyra_v1.h" #include "kyra/screen.h" #include "kyra/script.h" #include "kyra/text.h" -#include "kyra/animator.h" +#include "kyra/animator_v1.h" #include "kyra/sound.h" #include "common/config-manager.h" @@ -37,14 +37,14 @@ namespace Kyra { -void KyraEngine::registerDefaultSettings() { +void KyraEngine_v1::registerDefaultSettings() { // Most settings already have sensible defaults. This one, however, is // specific to the Kyra engine. ConfMan.registerDefault("walkspeed", 2); ConfMan.registerDefault("cdaudio", _flags.platform == Common::kPlatformFMTowns); } -void KyraEngine::readSettings() { +void KyraEngine_v1::readSettings() { int talkspeed = ConfMan.getInt("talkspeed"); // The default talk speed is 60. This should be mapped to "Normal". @@ -78,7 +78,7 @@ void KyraEngine::readSettings() { setWalkspeed(_configWalkspeed); } -void KyraEngine::writeSettings() { +void KyraEngine_v1::writeSettings() { bool speechMute, subtitles; int talkspeed; @@ -130,14 +130,14 @@ void KyraEngine::writeSettings() { ConfMan.flushToDisk(); } -void KyraEngine::initMainButtonList() { +void KyraEngine_v1::initMainButtonList() { _haveScrollButtons = false; _buttonList = &_buttonData[0]; for (int i = 0; _buttonDataListPtr[i]; ++i) _buttonList = initButton(_buttonList, _buttonDataListPtr[i]); } -Button *KyraEngine::initButton(Button *list, Button *newButton) { +Button *KyraEngine_v1::initButton(Button *list, Button *newButton) { if (!newButton) return list; if (!list) @@ -154,7 +154,7 @@ Button *KyraEngine::initButton(Button *list, Button *newButton) { return list; } -int KyraEngine::buttonInventoryCallback(Button *caller) { +int KyraEngine_v1::buttonInventoryCallback(Button *caller) { int itemOffset = caller->specialValue - 2; uint8 inventoryItem = _currentCharacter->inventoryItems[itemOffset]; if (_itemInHand == -1) { @@ -198,7 +198,7 @@ int KyraEngine::buttonInventoryCallback(Button *caller) { return 0; } -int KyraEngine::buttonAmuletCallback(Button *caller) { +int KyraEngine_v1::buttonAmuletCallback(Button *caller) { if (!(_deathHandler & 8)) return 1; int jewel = caller->specialValue - 0x14; @@ -294,7 +294,7 @@ int KyraEngine::buttonAmuletCallback(Button *caller) { return 1; } -void KyraEngine::processButtonList(Button *list) { +void KyraEngine_v1::processButtonList(Button *list) { if (_haveScrollButtons) { if (_mouseWheel < 0) gui_scrollUp(&_scrollUpButton); @@ -367,7 +367,7 @@ void KyraEngine::processButtonList(Button *list) { } } -void KyraEngine::processButton(Button *button) { +void KyraEngine_v1::processButton(Button *button) { if (!button) return; @@ -411,7 +411,7 @@ void KyraEngine::processButton(Button *button) { (this->*callback)(button); } -void KyraEngine::processAllMenuButtons() { +void KyraEngine_v1::processAllMenuButtons() { if (!_menuButtonList) return; @@ -425,7 +425,7 @@ void KyraEngine::processAllMenuButtons() { return; } -void KyraEngine::processMenuButton(Button *button) { +void KyraEngine_v1::processMenuButton(Button *button) { if (!_displayMenu) return; @@ -449,7 +449,7 @@ void KyraEngine::processMenuButton(Button *button) { processButton(button); } -int KyraEngine::drawBoxCallback(Button *button) { +int KyraEngine_v1::drawBoxCallback(Button *button) { if (!_displayMenu) return 0; @@ -460,7 +460,7 @@ int KyraEngine::drawBoxCallback(Button *button) { return 0; } -int KyraEngine::drawShadedBoxCallback(Button *button) { +int KyraEngine_v1::drawShadedBoxCallback(Button *button) { if (!_displayMenu) return 0; @@ -471,7 +471,7 @@ int KyraEngine::drawShadedBoxCallback(Button *button) { return 0; } -void KyraEngine::setGUILabels() { +void KyraEngine_v1::setGUILabels() { int offset = 0; int offsetOptions = 0; int offsetMainMenu = 0; @@ -561,7 +561,7 @@ void KyraEngine::setGUILabels() { _onCDString = _guiStrings[21]; } -int KyraEngine::buttonMenuCallback(Button *caller) { +int KyraEngine_v1::buttonMenuCallback(Button *caller) { _displayMenu = true; assert(_guiStrings); @@ -584,9 +584,9 @@ int KyraEngine::buttonMenuCallback(Button *caller) { _screen->setPaletteIndex(0xFE, 60, 60, 0); for (int i = 0; i < 6; i++) { _menuButtonData[i].process0 = _menuButtonData[i].process1 = _menuButtonData[i].process2 = 4; - _menuButtonData[i].process0PtrCallback = &KyraEngine::drawShadedBoxCallback; - _menuButtonData[i].process1PtrCallback = &KyraEngine::drawBoxCallback; - _menuButtonData[i].process2PtrCallback = &KyraEngine::drawShadedBoxCallback; + _menuButtonData[i].process0PtrCallback = &KyraEngine_v1::drawShadedBoxCallback; + _menuButtonData[i].process1PtrCallback = &KyraEngine_v1::drawBoxCallback; + _menuButtonData[i].process2PtrCallback = &KyraEngine_v1::drawShadedBoxCallback; } _screen->savePageToDisk("SEENPAGE.TMP", 0); @@ -627,7 +627,7 @@ int KyraEngine::buttonMenuCallback(Button *caller) { return 0; } -void KyraEngine::initMenu(Menu &menu) { +void KyraEngine_v1::initMenu(Menu &menu) { _menuButtonList = 0; _screen->hideMouse(); @@ -707,14 +707,14 @@ void KyraEngine::initMenu(Menu &menu) { _scrollUpButton.x = menu.scrollUpBtnX + menu.x; _scrollUpButton.y = menu.scrollUpBtnY + menu.y; - _scrollUpButton.buttonCallback = &KyraEngine::gui_scrollUp; + _scrollUpButton.buttonCallback = &KyraEngine_v1::gui_scrollUp; _scrollUpButton.nextButton = 0; _menuButtonList = initButton(_menuButtonList, &_scrollUpButton); processMenuButton(&_scrollUpButton); _scrollDownButton.x = menu.scrollDownBtnX + menu.x; _scrollDownButton.y = menu.scrollDownBtnY + menu.y; - _scrollDownButton.buttonCallback = &KyraEngine::gui_scrollDown; + _scrollDownButton.buttonCallback = &KyraEngine_v1::gui_scrollDown; _scrollDownButton.nextButton = 0; _menuButtonList = initButton(_menuButtonList, &_scrollDownButton); processMenuButton(&_scrollDownButton); @@ -726,7 +726,7 @@ void KyraEngine::initMenu(Menu &menu) { _screen->updateScreen(); } -void KyraEngine::calcCoords(Menu &menu) { +void KyraEngine_v1::calcCoords(Menu &menu) { assert(menu.nrOfItems < 7); int widthBackup = _screen->_charWidth; @@ -798,7 +798,7 @@ void KyraEngine::calcCoords(Menu &menu) { _screen->_charWidth = widthBackup; } -void KyraEngine::gui_getInput() { +void KyraEngine_v1::gui_getInput() { Common::Event event; static uint32 lastScreenUpdate = 0; uint32 now = _system->getMillis(); @@ -841,22 +841,22 @@ void KyraEngine::gui_getInput() { _system->delayMillis(3); } -int KyraEngine::gui_resumeGame(Button *button) { - debugC(9, kDebugLevelGUI, "KyraEngine::gui_resumeGame()"); +int KyraEngine_v1::gui_resumeGame(Button *button) { + debugC(9, kDebugLevelGUI, "KyraEngine_v1::gui_resumeGame()"); processMenuButton(button); _displayMenu = false; return 0; } -const char *KyraEngine::getSavegameFilename(int num) { +const char *KyraEngine_v1::getSavegameFilename(int num) { static char saveLoadSlot[12]; sprintf(saveLoadSlot, "%s.%.3d", _targetName.c_str(), num); return saveLoadSlot; } -int KyraEngine::getNextSavegameSlot() { +int KyraEngine_v1::getNextSavegameSlot() { Common::InSaveFile *in; for (int i = 1; i < 1000; i++) { @@ -869,7 +869,7 @@ int KyraEngine::getNextSavegameSlot() { return 0; } -void KyraEngine::setupSavegames(Menu &menu, int num) { +void KyraEngine_v1::setupSavegames(Menu &menu, int num) { Common::InSaveFile *in; static char savenames[5][31]; uint8 startSlot; @@ -900,8 +900,8 @@ void KyraEngine::setupSavegames(Menu &menu, int num) { } } -int KyraEngine::gui_saveGameMenu(Button *button) { - debugC(9, kDebugLevelGUI, "KyraEngine::gui_saveGameMenu()"); +int KyraEngine_v1::gui_saveGameMenu(Button *button) { + debugC(9, kDebugLevelGUI, "KyraEngine_v1::gui_saveGameMenu()"); processMenuButton(button); _menu[2].item[5].enabled = true; @@ -911,7 +911,7 @@ int KyraEngine::gui_saveGameMenu(Button *button) { _menu[2].menuName = _guiStrings[8]; // Select a position to save to: _specialSavegameString = _guiStrings[9]; // [ EMPTY SLOT ] for (int i = 0; i < 5; i++) - _menu[2].item[i].callback = &KyraEngine::gui_saveGame; + _menu[2].item[i].callback = &KyraEngine_v1::gui_saveGame; _savegameOffset = 0; setupSavegames(_menu[2], 5); @@ -940,8 +940,8 @@ int KyraEngine::gui_saveGameMenu(Button *button) { return 0; } -int KyraEngine::gui_loadGameMenu(Button *button) { - debugC(9, kDebugLevelGUI, "KyraEngine::gui_loadGameMenu()"); +int KyraEngine_v1::gui_loadGameMenu(Button *button) { + debugC(9, kDebugLevelGUI, "KyraEngine_v1::gui_loadGameMenu()"); if (_menuDirectlyToLoad) { _menu[2].item[5].enabled = false; } else { @@ -955,7 +955,7 @@ int KyraEngine::gui_loadGameMenu(Button *button) { _specialSavegameString = _newGameString[0]; //[ START A NEW GAME ] _menu[2].menuName = _guiStrings[7]; // Which game would you like to reload? for (int i = 0; i < 5; i++) - _menu[2].item[i].callback = &KyraEngine::gui_loadGame; + _menu[2].item[i].callback = &KyraEngine_v1::gui_loadGame; _savegameOffset = 0; setupSavegames(_menu[2], 5); @@ -987,7 +987,7 @@ int KyraEngine::gui_loadGameMenu(Button *button) { return 0; } -void KyraEngine::gui_redrawTextfield() { +void KyraEngine_v1::gui_redrawTextfield() { _screen->fillRect(38, 91, 287, 102, 250); _text->printText(_savegameName, 38, 92, 253, 0, 0); @@ -999,7 +999,7 @@ void KyraEngine::gui_redrawTextfield() { _screen->updateScreen(); } -void KyraEngine::gui_updateSavegameString() { +void KyraEngine_v1::gui_updateSavegameString() { int length; if (_keyPressed.keycode) { @@ -1026,8 +1026,8 @@ void KyraEngine::gui_updateSavegameString() { _keyPressed.reset(); } -int KyraEngine::gui_saveGame(Button *button) { - debugC(9, kDebugLevelGUI, "KyraEngine::gui_saveGame()"); +int KyraEngine_v1::gui_saveGame(Button *button) { + debugC(9, kDebugLevelGUI, "KyraEngine_v1::gui_saveGame()"); processMenuButton(button); _gameToLoad = button->specialValue; @@ -1074,16 +1074,16 @@ int KyraEngine::gui_saveGame(Button *button) { return 0; } -int KyraEngine::gui_savegameConfirm(Button *button) { - debugC(9, kDebugLevelGUI, "KyraEngine::gui_savegameConfirm()"); +int KyraEngine_v1::gui_savegameConfirm(Button *button) { + debugC(9, kDebugLevelGUI, "KyraEngine_v1::gui_savegameConfirm()"); processMenuButton(button); _displaySubMenu = false; return 0; } -int KyraEngine::gui_loadGame(Button *button) { - debugC(9, kDebugLevelGUI, "KyraEngine::gui_loadGame()"); +int KyraEngine_v1::gui_loadGame(Button *button) { + debugC(9, kDebugLevelGUI, "KyraEngine_v1::gui_loadGame()"); processMenuButton(button); _displaySubMenu = false; _gameToLoad = button->specialValue; @@ -1091,8 +1091,8 @@ int KyraEngine::gui_loadGame(Button *button) { return 0; } -int KyraEngine::gui_cancelSubMenu(Button *button) { - debugC(9, kDebugLevelGUI, "KyraEngine::gui_cancelLoadGameMenu()"); +int KyraEngine_v1::gui_cancelSubMenu(Button *button) { + debugC(9, kDebugLevelGUI, "KyraEngine_v1::gui_cancelLoadGameMenu()"); processMenuButton(button); _displaySubMenu = false; _cancelSubMenu = true; @@ -1100,8 +1100,8 @@ int KyraEngine::gui_cancelSubMenu(Button *button) { return 0; } -int KyraEngine::gui_quitPlaying(Button *button) { - debugC(9, kDebugLevelGUI, "KyraEngine::gui_quitPlaying()"); +int KyraEngine_v1::gui_quitPlaying(Button *button) { + debugC(9, kDebugLevelGUI, "KyraEngine_v1::gui_quitPlaying()"); processMenuButton(button); if (gui_quitConfirm(_guiStrings[14])) { // Are you sure you want to quit playing? @@ -1114,8 +1114,8 @@ int KyraEngine::gui_quitPlaying(Button *button) { return 0; } -bool KyraEngine::gui_quitConfirm(const char *str) { - debugC(9, kDebugLevelGUI, "KyraEngine::gui_quitConfirm()"); +bool KyraEngine_v1::gui_quitConfirm(const char *str) { + debugC(9, kDebugLevelGUI, "KyraEngine_v1::gui_quitConfirm()"); _screen->loadPageFromDisk("SEENPAGE.TMP", 0); _screen->savePageToDisk("SEENPAGE.TMP", 0); @@ -1139,8 +1139,8 @@ bool KyraEngine::gui_quitConfirm(const char *str) { return !_cancelSubMenu; } -int KyraEngine::gui_quitConfirmYes(Button *button) { - debugC(9, kDebugLevelGUI, "KyraEngine::gui_quitConfirmYes()"); +int KyraEngine_v1::gui_quitConfirmYes(Button *button) { + debugC(9, kDebugLevelGUI, "KyraEngine_v1::gui_quitConfirmYes()"); processMenuButton(button); _displaySubMenu = false; _cancelSubMenu = false; @@ -1148,8 +1148,8 @@ int KyraEngine::gui_quitConfirmYes(Button *button) { return 0; } -int KyraEngine::gui_quitConfirmNo(Button *button) { - debugC(9, kDebugLevelGUI, "KyraEngine::gui_quitConfirmNo()"); +int KyraEngine_v1::gui_quitConfirmNo(Button *button) { + debugC(9, kDebugLevelGUI, "KyraEngine_v1::gui_quitConfirmNo()"); processMenuButton(button); _displaySubMenu = false; _cancelSubMenu = true; @@ -1157,8 +1157,8 @@ int KyraEngine::gui_quitConfirmNo(Button *button) { return 0; } -int KyraEngine::gui_gameControlsMenu(Button *button) { - debugC(9, kDebugLevelGUI, "KyraEngine::gui_gameControlsMenu()"); +int KyraEngine_v1::gui_gameControlsMenu(Button *button) { + debugC(9, kDebugLevelGUI, "KyraEngine_v1::gui_gameControlsMenu()"); readSettings(); @@ -1175,14 +1175,14 @@ int KyraEngine::gui_gameControlsMenu(Button *button) { } _menu[5].item[3].labelString = _voiceTextString; //"Voice / Text " - _menu[5].item[3].callback = &KyraEngine::gui_controlsChangeVoice; + _menu[5].item[3].callback = &KyraEngine_v1::gui_controlsChangeVoice; } else { //_menu[5].height = 136; //_menu[5].item[5].y = 110; _menu[5].item[4].enabled = 0; _menu[5].item[3].labelString = _textSpeedString; // "Text speed " - _menu[5].item[3].callback = &KyraEngine::gui_controlsChangeText; + _menu[5].item[3].callback = &KyraEngine_v1::gui_controlsChangeText; } gui_setupControls(_menu[5]); @@ -1208,8 +1208,8 @@ int KyraEngine::gui_gameControlsMenu(Button *button) { return 0; } -void KyraEngine::gui_setupControls(Menu &menu) { - debugC(9, kDebugLevelGUI, "KyraEngine::gui_setupControls()"); +void KyraEngine_v1::gui_setupControls(Menu &menu) { + debugC(9, kDebugLevelGUI, "KyraEngine_v1::gui_setupControls()"); switch (_configMusic) { case 0: @@ -1299,8 +1299,8 @@ void KyraEngine::gui_setupControls(Menu &menu) { initMenu(menu); } -int KyraEngine::gui_controlsChangeMusic(Button *button) { - debugC(9, kDebugLevelGUI, "KyraEngine::gui_controlsChangeMusic()"); +int KyraEngine_v1::gui_controlsChangeMusic(Button *button) { + debugC(9, kDebugLevelGUI, "KyraEngine_v1::gui_controlsChangeMusic()"); processMenuButton(button); _configMusic = ++_configMusic % (_flags.platform == Common::kPlatformFMTowns ? 3 : 2); @@ -1308,8 +1308,8 @@ int KyraEngine::gui_controlsChangeMusic(Button *button) { return 0; } -int KyraEngine::gui_controlsChangeSounds(Button *button) { - debugC(9, kDebugLevelGUI, "KyraEngine::gui_controlsChangeSounds()"); +int KyraEngine_v1::gui_controlsChangeSounds(Button *button) { + debugC(9, kDebugLevelGUI, "KyraEngine_v1::gui_controlsChangeSounds()"); processMenuButton(button); _configSounds = !_configSounds; @@ -1317,8 +1317,8 @@ int KyraEngine::gui_controlsChangeSounds(Button *button) { return 0; } -int KyraEngine::gui_controlsChangeWalk(Button *button) { - debugC(9, kDebugLevelGUI, "KyraEngine::gui_controlsChangeWalk()"); +int KyraEngine_v1::gui_controlsChangeWalk(Button *button) { + debugC(9, kDebugLevelGUI, "KyraEngine_v1::gui_controlsChangeWalk()"); processMenuButton(button); _configWalkspeed = ++_configWalkspeed % 5; @@ -1327,8 +1327,8 @@ int KyraEngine::gui_controlsChangeWalk(Button *button) { return 0; } -int KyraEngine::gui_controlsChangeText(Button *button) { - debugC(9, kDebugLevelGUI, "KyraEngine::gui_controlsChangeText()"); +int KyraEngine_v1::gui_controlsChangeText(Button *button) { + debugC(9, kDebugLevelGUI, "KyraEngine_v1::gui_controlsChangeText()"); processMenuButton(button); _configTextspeed = ++_configTextspeed % 4; @@ -1336,8 +1336,8 @@ int KyraEngine::gui_controlsChangeText(Button *button) { return 0; } -int KyraEngine::gui_controlsChangeVoice(Button *button) { - debugC(9, kDebugLevelGUI, "KyraEngine::gui_controlsChangeVoice()"); +int KyraEngine_v1::gui_controlsChangeVoice(Button *button) { + debugC(9, kDebugLevelGUI, "KyraEngine_v1::gui_controlsChangeVoice()"); processMenuButton(button); _configVoice = ++_configVoice % 3; @@ -1345,14 +1345,14 @@ int KyraEngine::gui_controlsChangeVoice(Button *button) { return 0; } -int KyraEngine::gui_controlsApply(Button *button) { - debugC(9, kDebugLevelGUI, "KyraEngine::gui_controlsApply()"); +int KyraEngine_v1::gui_controlsApply(Button *button) { + debugC(9, kDebugLevelGUI, "KyraEngine_v1::gui_controlsApply()"); writeSettings(); return gui_cancelSubMenu(button); } -int KyraEngine::gui_scrollUp(Button *button) { - debugC(9, kDebugLevelGUI, "KyraEngine::gui_scrollUp()"); +int KyraEngine_v1::gui_scrollUp(Button *button) { + debugC(9, kDebugLevelGUI, "KyraEngine_v1::gui_scrollUp()"); processMenuButton(button); if (_savegameOffset > 0) { @@ -1363,8 +1363,8 @@ int KyraEngine::gui_scrollUp(Button *button) { return 0; } -int KyraEngine::gui_scrollDown(Button *button) { - debugC(9, kDebugLevelGUI, "KyraEngine::gui_scrollDown()"); +int KyraEngine_v1::gui_scrollDown(Button *button) { + debugC(9, kDebugLevelGUI, "KyraEngine_v1::gui_scrollDown()"); processMenuButton(button); _savegameOffset++; @@ -1374,7 +1374,7 @@ int KyraEngine::gui_scrollDown(Button *button) { return 0; } -void KyraEngine::gui_processHighlights(Menu &menu) { +void KyraEngine_v1::gui_processHighlights(Menu &menu) { int x1, y1, x2, y2; Common::Point mouse = getMousePos(); @@ -1403,7 +1403,7 @@ void KyraEngine::gui_processHighlights(Menu &menu) { } } -void KyraEngine::gui_redrawText(Menu menu) { +void KyraEngine_v1::gui_redrawText(Menu menu) { int textX; int i = menu.highlightedItem; @@ -1422,7 +1422,7 @@ void KyraEngine::gui_redrawText(Menu menu) { _text->printText(menu.item[i].itemString, textX, textY, menu.item[i].textColor, 0, 0); } -void KyraEngine::gui_redrawHighlight(Menu menu) { +void KyraEngine_v1::gui_redrawHighlight(Menu menu) { int textX; int i = menu.highlightedItem; @@ -1441,7 +1441,7 @@ void KyraEngine::gui_redrawHighlight(Menu menu) { _text->printText(menu.item[i].itemString, textX, textY, menu.item[i].highlightColor, 0, 0); } -void KyraEngine::gui_fadePalette() { +void KyraEngine_v1::gui_fadePalette() { if (_flags.platform == Common::kPlatformAmiga) return; @@ -1461,7 +1461,7 @@ void KyraEngine::gui_fadePalette() { _screen->fadePalette(_screen->_currentPalette, 2); } -void KyraEngine::gui_restorePalette() { +void KyraEngine_v1::gui_restorePalette() { if (_flags.platform == Common::kPlatformAmiga) return; @@ -1469,172 +1469,5 @@ void KyraEngine::gui_restorePalette() { _screen->fadePalette(_screen->_currentPalette, 2); } -#pragma mark - - -// Kyra 2 and 3 main menu - -void KyraEngine::gui_updateMainMenuAnimation() { - _screen->updateScreen(); -} - -bool KyraEngine::gui_mainMenuGetInput() { - Common::Event event; - - while (_eventMan->pollEvent(event)) { - switch (event.type) { - case Common::EVENT_QUIT: - quitGame(); - break; - case Common::EVENT_LBUTTONUP: - return true; - default: - break; - } - } - return false; -} - -int KyraEngine::gui_handleMainMenu() { - debugC(9, kDebugLevelMain, "KyraEngine::gui_handleMainMenu()"); - int command = -1; - - uint8 colorMap[16]; - memset(colorMap, 0, sizeof(colorMap)); - _screen->setTextColorMap(colorMap); - - const char * const *strings = &_mainMenuStrings[_lang << 2]; - Screen::FontId oldFont = _screen->setFont(Screen::FID_8_FNT); - int charWidthBackUp = _screen->_charWidth; - - _screen->_charWidth = -2; - _screen->setScreenDim(3); - int backUpX = _screen->_curDim->sx; - int backUpY = _screen->_curDim->sy; - int backUpWidth = _screen->_curDim->w; - int backUpHeight = _screen->_curDim->h; - _screen->copyRegion(backUpX, backUpY, backUpX, backUpY, backUpWidth, backUpHeight, 0, 3); - - int x = _screen->_curDim->sx << 3; - int y = _screen->_curDim->sy; - int width = _screen->_curDim->w << 3; - int height = _screen->_curDim->h; - - gui_drawMainBox(x, y, width, height, 1); - gui_drawMainBox(x + 1, y + 1, width - 2, height - 2, 0); - - int selected = 0; - - gui_drawMainMenu(strings, selected); - - _screen->showMouse(); - - int fh = _screen->getFontHeight(); - int textPos = ((_screen->_curDim->w >> 1) + _screen->_curDim->sx) << 3; - - Common::Rect menuRect(x + 16, y + 4, x + width - 16, y + 4 + fh * 4); - - while (!_quitFlag) { - gui_updateMainMenuAnimation(); - bool mousePressed = gui_mainMenuGetInput(); - - Common::Point mouse = getMousePos(); - if (menuRect.contains(mouse)) { - int item = (mouse.y - menuRect.top) / fh; - - if (item != selected) { - gui_printString(strings[selected], textPos, menuRect.top + selected * fh, 0x80, 0, 5); - gui_printString(strings[item], textPos, menuRect.top + item * fh, 0xFF, 0, 5); - - selected = item; - } - - if (mousePressed) { - // TODO: Flash the text - command = item; - break; - } - } - _system->delayMillis(10); - } - - if (_quitFlag) - command = -1; - - _screen->copyRegion(backUpX, backUpY, backUpX, backUpY, backUpWidth, backUpHeight, 3, 0); - _screen->_charWidth = charWidthBackUp; - _screen->setFont(oldFont); - - return command; -} - -void KyraEngine::gui_drawMainMenu(const char * const *strings, int select) { - debugC(9, kDebugLevelMain, "KyraEngine::gui_drawMainMenu(%p)", (const void*)strings); - static const uint16 menuTable[] = { 0x01, 0x04, 0x0C, 0x04, 0x00, 0x80, 0xFF, 0x00, 0x01, 0x02, 0x03 }; - - int top = _screen->_curDim->sy; - top += menuTable[1]; - - for (int i = 0; i < menuTable[3]; ++i) { - int curY = top + i * _screen->getFontHeight(); - int color = (i == select) ? menuTable[6] : menuTable[5]; - gui_printString(strings[i], ((_screen->_curDim->w >> 1) + _screen->_curDim->sx) << 3, curY, color, 0, 5); - } -} - -void KyraEngine::gui_drawMainBox(int x, int y, int w, int h, int fill) { - debugC(9, kDebugLevelMain, "KyraEngine::gui_drawMainBox(%d, %d, %d, %d, %d)", x, y, w, h, fill); - static const uint8 kyra3ColorTable[] = { 0x16, 0x19, 0x1A, 0x16 }; - static const uint8 kyra2ColorTable[] = { 0x0, 0x19, 0x28, 0xc8 }; - - const uint8 *colorTable; - if (_flags.gameID == GI_KYRA3) - colorTable = kyra3ColorTable; - else - colorTable = kyra2ColorTable; - - --w; --h; - - if (fill) - _screen->fillRect(x, y, x+w, y+h, colorTable[0]); - - _screen->drawClippedLine(x, y+h, x+w, y+h, colorTable[1]); - _screen->drawClippedLine(x+w, y, x+w, y+h, colorTable[1]); - _screen->drawClippedLine(x, y, x+w, y, colorTable[2]); - _screen->drawClippedLine(x, y, x, y+h, colorTable[2]); - - _screen->setPagePixel(_screen->_curPage, x, y+h, colorTable[3]); - _screen->setPagePixel(_screen->_curPage, x+w, y, colorTable[3]); -} - -void KyraEngine::gui_printString(const char *format, int x, int y, int col1, int col2, int flags, ...) { - debugC(9, kDebugLevelMain, "KyraEngine::gui_printString('%s', %d, %d, %d, %d, %d, ...)", format, x, y, col1, col2, flags); - if (!format) - return; - - char string[512]; - va_list vaList; - va_start(vaList, flags); - vsprintf(string, format, vaList); - va_end(vaList); - - if (flags & 1) - x -= _screen->getTextWidth(string) >> 1; - - if (flags & 2) - x -= _screen->getTextWidth(string); - - if (flags & 4) { - _screen->printText(string, x - 1, y, 240, col2); - _screen->printText(string, x, y + 1, 240, col2); - } - - if (flags & 8) { - _screen->printText(string, x - 1, y, 227, col2); - _screen->printText(string, x, y + 1, 227, col2); - } - - _screen->printText(string, x, y, col1, col2); -} - } // end of namespace Kyra diff --git a/engines/kyra/gui_v2.cpp b/engines/kyra/gui_v2.cpp new file mode 100644 index 0000000000..f24bf295a8 --- /dev/null +++ b/engines/kyra/gui_v2.cpp @@ -0,0 +1,195 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include "kyra/kyra.h" +#include "kyra/kyra_v2.h" +#include "kyra/screen.h" + +namespace Kyra { + +void KyraEngine_v2::gui_updateMainMenuAnimation() { + _screen->updateScreen(); +} + +bool KyraEngine_v2::gui_mainMenuGetInput() { + Common::Event event; + + while (_eventMan->pollEvent(event)) { + switch (event.type) { + case Common::EVENT_QUIT: + quitGame(); + break; + case Common::EVENT_LBUTTONUP: + return true; + default: + break; + } + } + return false; +} + +int KyraEngine_v2::gui_handleMainMenu() { + debugC(9, kDebugLevelMain, "KyraEngine_v2::gui_handleMainMenu()"); + int command = -1; + + uint8 colorMap[16]; + memset(colorMap, 0, sizeof(colorMap)); + _screen->setTextColorMap(colorMap); + + const char * const *strings = &_mainMenuStrings[_lang << 2]; + Screen::FontId oldFont = _screen->setFont(Screen::FID_8_FNT); + int charWidthBackUp = _screen->_charWidth; + + _screen->_charWidth = -2; + _screen->setScreenDim(3); + int backUpX = _screen->_curDim->sx; + int backUpY = _screen->_curDim->sy; + int backUpWidth = _screen->_curDim->w; + int backUpHeight = _screen->_curDim->h; + _screen->copyRegion(backUpX, backUpY, backUpX, backUpY, backUpWidth, backUpHeight, 0, 3); + + int x = _screen->_curDim->sx << 3; + int y = _screen->_curDim->sy; + int width = _screen->_curDim->w << 3; + int height = _screen->_curDim->h; + + gui_drawMainBox(x, y, width, height, 1); + gui_drawMainBox(x + 1, y + 1, width - 2, height - 2, 0); + + int selected = 0; + + gui_drawMainMenu(strings, selected); + + _screen->showMouse(); + + int fh = _screen->getFontHeight(); + int textPos = ((_screen->_curDim->w >> 1) + _screen->_curDim->sx) << 3; + + Common::Rect menuRect(x + 16, y + 4, x + width - 16, y + 4 + fh * 4); + + while (!_quitFlag) { + gui_updateMainMenuAnimation(); + bool mousePressed = gui_mainMenuGetInput(); + + Common::Point mouse = getMousePos(); + if (menuRect.contains(mouse)) { + int item = (mouse.y - menuRect.top) / fh; + + if (item != selected) { + gui_printString(strings[selected], textPos, menuRect.top + selected * fh, 0x80, 0, 5); + gui_printString(strings[item], textPos, menuRect.top + item * fh, 0xFF, 0, 5); + + selected = item; + } + + if (mousePressed) { + // TODO: Flash the text + command = item; + break; + } + } + _system->delayMillis(10); + } + + if (_quitFlag) + command = -1; + + _screen->copyRegion(backUpX, backUpY, backUpX, backUpY, backUpWidth, backUpHeight, 3, 0); + _screen->_charWidth = charWidthBackUp; + _screen->setFont(oldFont); + + return command; +} + +void KyraEngine_v2::gui_drawMainMenu(const char * const *strings, int select) { + debugC(9, kDebugLevelMain, "KyraEngine_v2::gui_drawMainMenu(%p)", (const void*)strings); + static const uint16 menuTable[] = { 0x01, 0x04, 0x0C, 0x04, 0x00, 0x80, 0xFF, 0x00, 0x01, 0x02, 0x03 }; + + int top = _screen->_curDim->sy; + top += menuTable[1]; + + for (int i = 0; i < menuTable[3]; ++i) { + int curY = top + i * _screen->getFontHeight(); + int color = (i == select) ? menuTable[6] : menuTable[5]; + gui_printString(strings[i], ((_screen->_curDim->w >> 1) + _screen->_curDim->sx) << 3, curY, color, 0, 5); + } +} + +void KyraEngine_v2::gui_drawMainBox(int x, int y, int w, int h, int fill) { + debugC(9, kDebugLevelMain, "KyraEngine_v2::gui_drawMainBox(%d, %d, %d, %d, %d)", x, y, w, h, fill); + static const uint8 kyra3ColorTable[] = { 0x16, 0x19, 0x1A, 0x16 }; + static const uint8 kyra2ColorTable[] = { 0x0, 0x19, 0x28, 0xc8 }; + + const uint8 *colorTable; + if (_flags.gameID == GI_KYRA3) + colorTable = kyra3ColorTable; + else + colorTable = kyra2ColorTable; + + --w; --h; + + if (fill) + _screen->fillRect(x, y, x+w, y+h, colorTable[0]); + + _screen->drawClippedLine(x, y+h, x+w, y+h, colorTable[1]); + _screen->drawClippedLine(x+w, y, x+w, y+h, colorTable[1]); + _screen->drawClippedLine(x, y, x+w, y, colorTable[2]); + _screen->drawClippedLine(x, y, x, y+h, colorTable[2]); + + _screen->setPagePixel(_screen->_curPage, x, y+h, colorTable[3]); + _screen->setPagePixel(_screen->_curPage, x+w, y, colorTable[3]); +} + +void KyraEngine_v2::gui_printString(const char *format, int x, int y, int col1, int col2, int flags, ...) { + debugC(9, kDebugLevelMain, "KyraEngine_v2::gui_printString('%s', %d, %d, %d, %d, %d, ...)", format, x, y, col1, col2, flags); + if (!format) + return; + + char string[512]; + va_list vaList; + va_start(vaList, flags); + vsprintf(string, format, vaList); + va_end(vaList); + + if (flags & 1) + x -= _screen->getTextWidth(string) >> 1; + + if (flags & 2) + x -= _screen->getTextWidth(string); + + if (flags & 4) { + _screen->printText(string, x - 1, y, 240, col2); + _screen->printText(string, x, y + 1, 240, col2); + } + + if (flags & 8) { + _screen->printText(string, x - 1, y, 227, col2); + _screen->printText(string, x, y + 1, 227, col2); + } + + _screen->printText(string, x, y, col1, col2); +} + +} // end of namespace Kyra diff --git a/engines/kyra/items_v1.cpp b/engines/kyra/items_v1.cpp index 2a1a08b7de..84b76c59a6 100644 --- a/engines/kyra/items_v1.cpp +++ b/engines/kyra/items_v1.cpp @@ -23,14 +23,14 @@ * */ -#include "kyra/kyra.h" +#include "kyra/kyra_v1.h" #include "kyra/seqplayer.h" #include "kyra/screen.h" #include "kyra/resource.h" #include "kyra/sound.h" #include "kyra/sprites.h" #include "kyra/wsamovie.h" -#include "kyra/animator.h" +#include "kyra/animator_v1.h" #include "kyra/text.h" #include "common/system.h" @@ -38,7 +38,7 @@ namespace Kyra { -int KyraEngine::findDuplicateItemShape(int shape) { +int KyraEngine_v1::findDuplicateItemShape(int shape) { static uint8 dupTable[] = { 0x48, 0x46, 0x49, 0x47, 0x4a, 0x46, 0x4b, 0x47, 0x4c, 0x46, 0x4d, 0x47, 0x5b, 0x5a, 0x5c, 0x5a, @@ -55,8 +55,8 @@ int KyraEngine::findDuplicateItemShape(int shape) { return -1; } -void KyraEngine::addToNoDropRects(int x, int y, int w, int h) { - debugC(9, kDebugLevelMain, "KyraEngine::addToNoDropRects(%d, %d, %d, %d)", x, y, w, h); +void KyraEngine_v1::addToNoDropRects(int x, int y, int w, int h) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::addToNoDropRects(%d, %d, %d, %d)", x, y, w, h); for (int rect = 0; rect < 11; ++rect) { if (_noDropRects[rect].x == -1) { _noDropRects[rect].x = x; @@ -68,13 +68,13 @@ void KyraEngine::addToNoDropRects(int x, int y, int w, int h) { } } -void KyraEngine::clearNoDropRects() { - debugC(9, kDebugLevelMain, "KyraEngine::clearNoDropRects()"); +void KyraEngine_v1::clearNoDropRects() { + debugC(9, kDebugLevelMain, "KyraEngine_v1::clearNoDropRects()"); memset(_noDropRects, -1, sizeof(_noDropRects)); } -byte KyraEngine::findFreeItemInScene(int scene) { - debugC(9, kDebugLevelMain, "KyraEngine::findFreeItemInScene(%d)", scene); +byte KyraEngine_v1::findFreeItemInScene(int scene) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::findFreeItemInScene(%d)", scene); assert(scene < _roomTableSize); Room *room = &_roomTable[scene]; for (int i = 0; i < 12; ++i) { @@ -84,8 +84,8 @@ byte KyraEngine::findFreeItemInScene(int scene) { return 0xFF; } -byte KyraEngine::findItemAtPos(int x, int y) { - debugC(9, kDebugLevelMain, "KyraEngine::findItemAtPos(%d, %d)", x, y); +byte KyraEngine_v1::findItemAtPos(int x, int y) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::findItemAtPos(%d, %d)", x, y); assert(_currentCharacter->sceneId < _roomTableSize); const uint8 *itemsTable = _roomTable[_currentCharacter->sceneId].itemsTable; const uint16 *xposOffset = _roomTable[_currentCharacter->sceneId].itemsXPos; @@ -120,8 +120,8 @@ byte KyraEngine::findItemAtPos(int x, int y) { return returnValue; } -void KyraEngine::placeItemInGenericMapScene(int item, int index) { - debugC(9, kDebugLevelMain, "KyraEngine::placeItemInGenericMapScene(%d, %d)", item, index); +void KyraEngine_v1::placeItemInGenericMapScene(int item, int index) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::placeItemInGenericMapScene(%d, %d)", item, index); static const uint16 itemMapSceneMinTable[] = { 0x0000, 0x0011, 0x006D, 0x0025, 0x00C7, 0x0000 }; @@ -175,32 +175,32 @@ void KyraEngine::placeItemInGenericMapScene(int item, int index) { } } -void KyraEngine::createMouseItem(int item) { - debugC(9, kDebugLevelMain, "KyraEngine::createMouseItem(%d)", item); +void KyraEngine_v1::createMouseItem(int item) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::createMouseItem(%d)", item); _screen->hideMouse(); setMouseItem(item); _itemInHand = item; _screen->showMouse(); } -void KyraEngine::destroyMouseItem() { - debugC(9, kDebugLevelMain, "KyraEngine::destroyMouseItem()"); +void KyraEngine_v1::destroyMouseItem() { + debugC(9, kDebugLevelMain, "KyraEngine_v1::destroyMouseItem()"); _screen->hideMouse(); _screen->setMouseCursor(1, 1, _shapes[0]); _itemInHand = -1; _screen->showMouse(); } -void KyraEngine::setMouseItem(int item) { - debugC(9, kDebugLevelMain, "KyraEngine::setMouseItem(%d)", item); +void KyraEngine_v1::setMouseItem(int item) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::setMouseItem(%d)", item); if (item == -1) _screen->setMouseCursor(1, 1, _shapes[6]); else _screen->setMouseCursor(8, 15, _shapes[216+item]); } -void KyraEngine::wipeDownMouseItem(int xpos, int ypos) { - debugC(9, kDebugLevelMain, "KyraEngine::wipeDownMouseItem(%d, %d)", xpos, ypos); +void KyraEngine_v1::wipeDownMouseItem(int xpos, int ypos) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::wipeDownMouseItem(%d, %d)", xpos, ypos); if (_itemInHand == -1) return; xpos -= 8; @@ -226,8 +226,8 @@ void KyraEngine::wipeDownMouseItem(int xpos, int ypos) { _screen->showMouse(); } -void KyraEngine::setupSceneItems() { - debugC(9, kDebugLevelMain, "KyraEngine::setupSceneItems()"); +void KyraEngine_v1::setupSceneItems() { + debugC(9, kDebugLevelMain, "KyraEngine_v1::setupSceneItems()"); uint16 sceneId = _currentCharacter->sceneId; assert(sceneId < _roomTableSize); Room *currentRoom = &_roomTable[sceneId]; @@ -264,8 +264,8 @@ void KyraEngine::setupSceneItems() { } } -int KyraEngine::countItemsInScene(uint16 sceneId) { - debugC(9, kDebugLevelMain, "KyraEngine::countItemsInScene(%d)", sceneId); +int KyraEngine_v1::countItemsInScene(uint16 sceneId) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::countItemsInScene(%d)", sceneId); assert(sceneId < _roomTableSize); Room *currentRoom = &_roomTable[sceneId]; @@ -279,8 +279,8 @@ int KyraEngine::countItemsInScene(uint16 sceneId) { return items; } -int KyraEngine::processItemDrop(uint16 sceneId, uint8 item, int x, int y, int unk1, int unk2) { - debugC(9, kDebugLevelMain, "KyraEngine::processItemDrop(%d, %d, %d, %d, %d, %d)", sceneId, item, x, y, unk1, unk2); +int KyraEngine_v1::processItemDrop(uint16 sceneId, uint8 item, int x, int y, int unk1, int unk2) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::processItemDrop(%d, %d, %d, %d, %d, %d)", sceneId, item, x, y, unk1, unk2); int freeItem = -1; uint8 itemIndex = findItemAtPos(x, y); if (unk1) @@ -432,8 +432,8 @@ int KyraEngine::processItemDrop(uint16 sceneId, uint8 item, int x, int y, int un return 1; } -void KyraEngine::exchangeItemWithMouseItem(uint16 sceneId, int itemIndex) { - debugC(9, kDebugLevelMain, "KyraEngine::exchangeItemWithMouseItem(%d, %d)", sceneId, itemIndex); +void KyraEngine_v1::exchangeItemWithMouseItem(uint16 sceneId, int itemIndex) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::exchangeItemWithMouseItem(%d, %d)", sceneId, itemIndex); _screen->hideMouse(); _animator->animRemoveGameItem(itemIndex); assert(sceneId < _roomTableSize); @@ -452,8 +452,8 @@ void KyraEngine::exchangeItemWithMouseItem(uint16 sceneId, int itemIndex) { clickEventHandler2(); } -void KyraEngine::addItemToRoom(uint16 sceneId, uint8 item, int itemIndex, int x, int y) { - debugC(9, kDebugLevelMain, "KyraEngine::addItemToRoom(%d, %d, %d, %d, %d)", sceneId, item, itemIndex, x, y); +void KyraEngine_v1::addItemToRoom(uint16 sceneId, uint8 item, int itemIndex, int x, int y) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::addItemToRoom(%d, %d, %d, %d, %d)", sceneId, item, itemIndex, x, y); assert(sceneId < _roomTableSize); Room *currentRoom = &_roomTable[sceneId]; currentRoom->itemsTable[itemIndex] = item; @@ -462,8 +462,8 @@ void KyraEngine::addItemToRoom(uint16 sceneId, uint8 item, int itemIndex, int x, currentRoom->needInit[itemIndex] = 1; } -int KyraEngine::checkNoDropRects(int x, int y) { - debugC(9, kDebugLevelMain, "KyraEngine::checkNoDropRects(%d, %d)", x, y); +int KyraEngine_v1::checkNoDropRects(int x, int y) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::checkNoDropRects(%d, %d)", x, y); if (_lastProcessedItemHeight < 1 || _lastProcessedItemHeight > 16) _lastProcessedItemHeight = 16; if (_noDropRects[0].x == -1) @@ -492,8 +492,8 @@ int KyraEngine::checkNoDropRects(int x, int y) { return 0; } -int KyraEngine::isDropable(int x, int y) { - debugC(9, kDebugLevelMain, "KyraEngine::isDropable(%d, %d)", x, y); +int KyraEngine_v1::isDropable(int x, int y) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::isDropable(%d, %d)", x, y); x -= 8; y -= 1; @@ -507,8 +507,8 @@ int KyraEngine::isDropable(int x, int y) { return 1; } -void KyraEngine::itemDropDown(int x, int y, int destX, int destY, byte freeItem, int item) { - debugC(9, kDebugLevelMain, "KyraEngine::itemDropDown(%d, %d, %d, %d, %d, %d)", x, y, destX, destY, freeItem, item); +void KyraEngine_v1::itemDropDown(int x, int y, int destX, int destY, byte freeItem, int item) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::itemDropDown(%d, %d, %d, %d, %d, %d)", x, y, destX, destY, freeItem, item); assert(_currentCharacter->sceneId < _roomTableSize); Room *currentRoom = &_roomTable[_currentCharacter->sceneId]; if (x == destX && y == destY) { @@ -591,8 +591,8 @@ void KyraEngine::itemDropDown(int x, int y, int destX, int destY, byte freeItem, _screen->showMouse(); } -void KyraEngine::dropItem(int unk1, int item, int x, int y, int unk2) { - debugC(9, kDebugLevelMain, "KyraEngine::dropItem(%d, %d, %d, %d, %d)", unk1, item, x, y, unk2); +void KyraEngine_v1::dropItem(int unk1, int item, int x, int y, int unk2) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::dropItem(%d, %d, %d, %d, %d)", unk1, item, x, y, unk2); if (processItemDrop(_currentCharacter->sceneId, item, x, y, unk1, unk2)) return; snd_playSoundEffect(54); @@ -603,16 +603,16 @@ void KyraEngine::dropItem(int unk1, int item, int x, int y, int unk2) { drawSentenceCommand(_noDropList[1], 6); } -void KyraEngine::itemSpecialFX(int x, int y, int item) { - debugC(9, kDebugLevelMain, "KyraEngine::itemSpecialFX(%d, %d, %d)", x, y, item); +void KyraEngine_v1::itemSpecialFX(int x, int y, int item) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::itemSpecialFX(%d, %d, %d)", x, y, item); if (item == 41) itemSpecialFX1(x, y, item); else itemSpecialFX2(x, y, item); } -void KyraEngine::itemSpecialFX1(int x, int y, int item) { - debugC(9, kDebugLevelMain, "KyraEngine::itemSpecialFX1(%d, %d, %d)", x, y, item); +void KyraEngine_v1::itemSpecialFX1(int x, int y, int item) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::itemSpecialFX1(%d, %d, %d)", x, y, item); uint8 *shape = _shapes[216+item]; x -= 8; int startY = y; @@ -632,8 +632,8 @@ void KyraEngine::itemSpecialFX1(int x, int y, int item) { _screen->showMouse(); } -void KyraEngine::itemSpecialFX2(int x, int y, int item) { - debugC(9, kDebugLevelMain, "KyraEngine::itemSpecialFX2(%d, %d, %d)", x, y, item); +void KyraEngine_v1::itemSpecialFX2(int x, int y, int item) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::itemSpecialFX2(%d, %d, %d)", x, y, item); x -= 8; y -= 15; int yAdd = (int8)(((16 - _itemTable[item].height) >> 1) & 0xFF); @@ -660,8 +660,8 @@ void KyraEngine::itemSpecialFX2(int x, int y, int item) { restoreItemRect0(x, y); } -void KyraEngine::magicOutMouseItem(int animIndex, int itemPos) { - debugC(9, kDebugLevelMain, "KyraEngine::magicOutMouseItem(%d, %d)", animIndex, itemPos); +void KyraEngine_v1::magicOutMouseItem(int animIndex, int itemPos) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::magicOutMouseItem(%d, %d)", animIndex, itemPos); int videoPageBackUp = _screen->_curPage; _screen->_curPage = 0; int x = 0, y = 0; @@ -744,8 +744,8 @@ void KyraEngine::magicOutMouseItem(int animIndex, int itemPos) { _screen->_curPage = videoPageBackUp; } -void KyraEngine::magicInMouseItem(int animIndex, int item, int itemPos) { - debugC(9, kDebugLevelMain, "KyraEngine::magicInMouseItem(%d, %d, %d)", animIndex, item, itemPos); +void KyraEngine_v1::magicInMouseItem(int animIndex, int item, int itemPos) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::magicInMouseItem(%d, %d, %d)", animIndex, item, itemPos); int videoPageBackUp = _screen->_curPage; _screen->_curPage = 0; int x = 0, y = 0; @@ -817,8 +817,8 @@ void KyraEngine::magicInMouseItem(int animIndex, int item, int itemPos) { _screen->_curPage = videoPageBackUp; } -void KyraEngine::specialMouseItemFX(int shape, int x, int y, int animIndex, int tableIndex, int loopStart, int maxLoops) { - debugC(9, kDebugLevelMain, "KyraEngine::specialMouseItemFX(%d, %d, %d, %d, %d, %d, %d)", shape, x, y, animIndex, tableIndex, loopStart, maxLoops); +void KyraEngine_v1::specialMouseItemFX(int shape, int x, int y, int animIndex, int tableIndex, int loopStart, int maxLoops) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::specialMouseItemFX(%d, %d, %d, %d, %d, %d, %d)", shape, x, y, animIndex, tableIndex, loopStart, maxLoops); static const uint8 table1[] = { 0x23, 0x45, 0x55, 0x72, 0x84, 0xCF, 0x00, 0x00 }; @@ -840,8 +840,8 @@ void KyraEngine::specialMouseItemFX(int shape, int x, int y, int animIndex, int processSpecialMouseItemFX(shape, x, y, tableValue, loopStart, maxLoops); } -void KyraEngine::processSpecialMouseItemFX(int shape, int x, int y, int tableValue, int loopStart, int maxLoops) { - debugC(9, kDebugLevelMain, "KyraEngine::processSpecialMouseItemFX(%d, %d, %d, %d, %d, %d)", shape, x, y, tableValue, loopStart, maxLoops); +void KyraEngine_v1::processSpecialMouseItemFX(int shape, int x, int y, int tableValue, int loopStart, int maxLoops) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::processSpecialMouseItemFX(%d, %d, %d, %d, %d, %d)", shape, x, y, tableValue, loopStart, maxLoops); uint8 shapeColorTable[16]; uint8 *shapePtr = _shapes[shape] + 10; if (_flags.useAltShapeHeader) @@ -859,8 +859,8 @@ void KyraEngine::processSpecialMouseItemFX(int shape, int x, int y, int tableVal _screen->drawShape(0, _shapes[shape], x, y, 0, 0x8000, shapeColorTable); } -void KyraEngine::updatePlayerItemsForScene() { - debugC(9, kDebugLevelMain, "KyraEngine::updatePlayerItemsForScene()"); +void KyraEngine_v1::updatePlayerItemsForScene() { + debugC(9, kDebugLevelMain, "KyraEngine_v1::updatePlayerItemsForScene()"); if (_itemInHand >= 29 && _itemInHand < 33) { ++_itemInHand; if (_itemInHand > 33) @@ -900,7 +900,7 @@ void KyraEngine::updatePlayerItemsForScene() { _screen->showMouse(); } -void KyraEngine::redrawInventory(int page) { +void KyraEngine_v1::redrawInventory(int page) { int videoPageBackUp = _screen->_curPage; _screen->_curPage = page; _screen->hideMouse(); @@ -916,26 +916,26 @@ void KyraEngine::redrawInventory(int page) { _screen->updateScreen(); } -void KyraEngine::backUpItemRect0(int xpos, int ypos) { - debugC(9, kDebugLevelMain, "KyraEngine::backUpItemRect0(%d, %d)", xpos, ypos); +void KyraEngine_v1::backUpItemRect0(int xpos, int ypos) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::backUpItemRect0(%d, %d)", xpos, ypos); _screen->rectClip(xpos, ypos, 3<<3, 24); _screen->copyRegionToBuffer(_screen->_curPage, xpos, ypos, 3<<3, 24, _itemBkgBackUp[0]); } -void KyraEngine::restoreItemRect0(int xpos, int ypos) { - debugC(9, kDebugLevelMain, "KyraEngine::restoreItemRect0(%d, %d)", xpos, ypos); +void KyraEngine_v1::restoreItemRect0(int xpos, int ypos) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::restoreItemRect0(%d, %d)", xpos, ypos); _screen->rectClip(xpos, ypos, 3<<3, 24); _screen->copyBlockToPage(_screen->_curPage, xpos, ypos, 3<<3, 24, _itemBkgBackUp[0]); } -void KyraEngine::backUpItemRect1(int xpos, int ypos) { - debugC(9, kDebugLevelMain, "KyraEngine::backUpItemRect1(%d, %d)", xpos, ypos); +void KyraEngine_v1::backUpItemRect1(int xpos, int ypos) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::backUpItemRect1(%d, %d)", xpos, ypos); _screen->rectClip(xpos, ypos, 4<<3, 32); _screen->copyRegionToBuffer(_screen->_curPage, xpos, ypos, 4<<3, 32, _itemBkgBackUp[1]); } -void KyraEngine::restoreItemRect1(int xpos, int ypos) { - debugC(9, kDebugLevelMain, "KyraEngine::restoreItemRect1(%d, %d)", xpos, ypos); +void KyraEngine_v1::restoreItemRect1(int xpos, int ypos) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::restoreItemRect1(%d, %d)", xpos, ypos); _screen->rectClip(xpos, ypos, 4<<3, 32); _screen->copyBlockToPage(_screen->_curPage, xpos, ypos, 4<<3, 32, _itemBkgBackUp[1]); } diff --git a/engines/kyra/kyra.cpp b/engines/kyra/kyra.cpp index 1664ce144f..c7e167f600 100644 --- a/engines/kyra/kyra.cpp +++ b/engines/kyra/kyra.cpp @@ -26,91 +26,31 @@ #include "common/stdafx.h" #include "common/config-manager.h" -#include "common/file.h" -#include "common/events.h" -#include "common/system.h" -#include "common/savefile.h" -#include "sound/mixer.h" #include "sound/mididrv.h" - -#include "gui/message.h" +#include "sound/mixer.h" #include "kyra/kyra.h" +#include "kyra/sound.h" #include "kyra/resource.h" #include "kyra/screen.h" -#include "kyra/script.h" -#include "kyra/seqplayer.h" -#include "kyra/sound.h" -#include "kyra/sprites.h" -#include "kyra/wsamovie.h" -#include "kyra/animator.h" #include "kyra/text.h" -#include "kyra/debugger.h" namespace Kyra { KyraEngine::KyraEngine(OSystem *system, const GameFlags &flags) : Engine(system) { - _flags = flags; - - _seq_Forest = _seq_KallakWriting = _seq_KyrandiaLogo = _seq_KallakMalcolm = - _seq_MalcolmTree = _seq_WestwoodLogo = _seq_Demo1 = _seq_Demo2 = _seq_Demo3 = - _seq_Demo4 = 0; - - _seq_WSATable = _seq_CPSTable = _seq_COLTable = _seq_textsTable = 0; - _seq_WSATable_Size = _seq_CPSTable_Size = _seq_COLTable_Size = _seq_textsTable_Size = 0; - - _roomFilenameTable = _characterImageTable = 0; - _roomFilenameTableSize = _characterImageTableSize = 0; - _itemList = _takenList = _placedList = _droppedList = _noDropList = 0; - _itemList_Size = _takenList_Size = _placedList_Size = _droppedList_Size = _noDropList_Size = 0; - _putDownFirst = _waitForAmulet = _blackJewel = _poisonGone = _healingTip = 0; - _putDownFirst_Size = _waitForAmulet_Size = _blackJewel_Size = _poisonGone_Size = _healingTip_Size = 0; - _thePoison = _fluteString = _wispJewelStrings = _magicJewelString = _flaskFull = _fullFlask = 0; - _thePoison_Size = _fluteString_Size = _wispJewelStrings_Size = 0; - _magicJewelString_Size = _flaskFull_Size = _fullFlask_Size = 0; - - _defaultShapeTable = 0; - _healingShapeTable = _healingShape2Table = 0; - _defaultShapeTableSize = _healingShapeTableSize = _healingShape2TableSize = 0; - _posionDeathShapeTable = _fluteAnimShapeTable = 0; - _posionDeathShapeTableSize = _fluteAnimShapeTableSize = 0; - _winterScrollTable = _winterScroll1Table = _winterScroll2Table = 0; - _winterScrollTableSize = _winterScroll1TableSize = _winterScroll2TableSize = 0; - _drinkAnimationTable = _brandonToWispTable = _magicAnimationTable = _brandonStoneTable = 0; - _drinkAnimationTableSize = _brandonToWispTableSize = _magicAnimationTableSize = _brandonStoneTableSize = 0; - memset(&_specialPalettes, 0, sizeof(_specialPalettes)); - _debugger = 0; - _sprites = 0; - _animator = 0; _screen = 0; _res = 0; _sound = 0; - _seq = 0; - _scriptInterpreter = 0; _text = 0; - _npcScriptData = 0; - _scriptMain = 0; - _scriptClickData = 0; - _scriptClick = 0; - _characterList = 0; - _movFacingTable = 0; - memset(_shapes, 0, sizeof(_shapes)); - memset(_movieObjects, 0, sizeof(_movieObjects)); - _finalA = _finalB = _finalC = 0; - _endSequenceBackUpRect = 0; - memset(_panPagesTable, 0, sizeof(_panPagesTable)); - _npcScriptData = _scriptClickData = 0; - _scrollUpButton.process0PtrShape = _scrollUpButton.process1PtrShape = _scrollUpButton.process2PtrShape = 0; - _scrollDownButton.process0PtrShape = _scrollDownButton.process1PtrShape = _scrollDownButton.process2PtrShape = 0; - memset(_sceneAnimTable, 0, sizeof(_sceneAnimTable)); + _staticres = 0; + _quitFlag = false; - _currHeadShape = 0; - - _curSfxFile = _curMusicTheme = 0; - - memset(&_itemBkgBackUp, 0, sizeof(_itemBkgBackUp)); + + _skipFlag = false; + + memset(_flagsTable, 0, sizeof(_flagsTable)); // sets up all engine specific debug levels Common::addSpecialDebugLevel(kDebugLevelScriptFuncs, "ScriptFuncs", "Script function debug level"); @@ -133,18 +73,10 @@ int KyraEngine::init() { _mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume")); _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume")); _mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, ConfMan.getInt("speech_volume")); - - _screen = new Screen(this, _system); - assert(_screen); - if (!_screen->init()) - error("_screen->init() failed"); - - // for now we prefer Adlib over native MIDI + + // for now we prefer Adlib over native MIDI int midiDriver = MidiDriver::detectMusicDriver(MDT_MIDI | MDT_ADLIB/* | MDT_PREFER_MIDI*/); - // TODO: We should play the native Kyra 2 Adlib music, but until that - // is support, we'll use the automagic MIDI -> Adlib converter. - if (_flags.platform == Common::kPlatformFMTowns) { // no sfx enabled for CD audio music atm // later on here should be a usage of MixedSoundDriver @@ -183,155 +115,12 @@ int KyraEngine::init() { _res = new Resource(this); assert(_res); - _sprites = new Sprites(this, _system); - assert(_sprites); - _seq = new SeqPlayer(this, _system); - assert(_seq); - _animator = new ScreenAnimator(this, _system); - assert(_animator); - _animator->init(5, 11, 12); - assert(*_animator); _text = new TextDisplayer(this, _screen); assert(_text); - _staticres = new StaticResource(this); assert(_staticres); if (!_staticres->init()) error("_staticres->init() failed"); - - initStaticResource(); - - if (!_sound->init()) - error("Couldn't init sound"); - - if (_flags.platform == Common::kPlatformFMTowns) - _sound->setSoundFileList(_soundFilesTowns, _soundFilesTownsCount); - else - _sound->setSoundFileList(_soundFiles, _soundFilesCount); - - _sound->setVolume(255); - _sound->loadSoundFile(0); - - setupOpcodeTable(); - setupButtonData(); - setupMenu(); - - _paletteChanged = 1; - _currentCharacter = 0; - _characterList = new Character[11]; - assert(_characterList); - memset(_characterList, 0, sizeof(Character)*11); - - for (int i = 0; i < 11; ++i) - memset(_characterList[i].inventoryItems, 0xFF, sizeof(_characterList[i].inventoryItems)); - - _characterList[0].sceneId = 5; - _characterList[0].height = 48; - _characterList[0].facing = 3; - _characterList[0].currentAnimFrame = 7; - - _scriptInterpreter = new ScriptHelper(this); - assert(_scriptInterpreter); - - _npcScriptData = new ScriptData; - memset(_npcScriptData, 0, sizeof(ScriptData)); - assert(_npcScriptData); - _npcScript = new ScriptState; - assert(_npcScript); - memset(_npcScript, 0, sizeof(ScriptState)); - - _scriptMain = new ScriptState; - assert(_scriptMain); - memset(_scriptMain, 0, sizeof(ScriptState)); - - _scriptClickData = new ScriptData; - assert(_scriptClickData); - memset(_scriptClickData, 0, sizeof(ScriptData)); - _scriptClick = new ScriptState; - assert(_scriptClick); - memset(_scriptClick, 0, sizeof(ScriptState)); - - _debugger = new Debugger(this); - assert(_debugger); - memset(_shapes, 0, sizeof(_shapes)); - - for (int i = 0; i < ARRAYSIZE(_movieObjects); ++i) - _movieObjects[i] = createWSAMovie(); - - memset(_flagsTable, 0, sizeof(_flagsTable)); - - _abortWalkFlag = false; - _abortWalkFlag2 = false; - _talkingCharNum = -1; - _charSayUnk3 = -1; - memset(_currSentenceColor, 0, 3); - _startSentencePalIndex = -1; - _fadeText = false; - - _cauldronState = 0; - _crystalState[0] = _crystalState[1] = -1; - - _brandonStatusBit = 0; - _brandonStatusBit0x02Flag = _brandonStatusBit0x20Flag = 10; - _brandonPosX = _brandonPosY = -1; - _deathHandler = 0xFF; - _poisonDeathCounter = 0; - - memset(_itemTable, 0, sizeof(_itemTable)); - memset(_exitList, 0xFFFF, sizeof(_exitList)); - _exitListPtr = 0; - _pathfinderFlag = _pathfinderFlag2 = 0; - _lastFindWayRet = 0; - _sceneChangeState = _loopFlag2 = 0; - _timerNextRun = 0; - - _movFacingTable = new int[150]; - assert(_movFacingTable); - _movFacingTable[0] = 8; - - registerDefaultSettings(); - readSettings(); - - _skipFlag = false; - - _marbleVaseItem = -1; - memset(_foyerItemTable, -1, sizeof(_foyerItemTable)); - _mouseState = _itemInHand = -1; - _handleInput = false; - - _currentRoom = 0xFFFF; - _scenePhasingFlag = 0; - _lastProcessedItem = 0; - _lastProcessedItemHeight = 16; - - _unkScreenVar1 = 1; - _unkScreenVar2 = 0; - _unkScreenVar3 = 0; - _unkAmuletVar = 0; - - _endSequenceNeedLoading = 1; - _malcolmFlag = 0; - _beadStateVar = 0; - _endSequenceSkipFlag = 0; - _unkEndSeqVar2 = 0; - _endSequenceBackUpRect = 0; - _unkEndSeqVar4 = 0; - _unkEndSeqVar5 = 0; - _lastDisplayedPanPage = 0; - memset(_panPagesTable, 0, sizeof(_panPagesTable)); - _finalA = _finalB = _finalC = 0; - memset(&_kyragemFadingState, 0, sizeof(_kyragemFadingState)); - _kyragemFadingState.gOffset = 0x13; - _kyragemFadingState.bOffset = 0x13; - - _mousePressFlag = false; - - _menuDirectlyToLoad = false; - - _lastMusicCommand = 0; - - _gameSpeed = 60; - _tickLength = (uint8)(1000.0 / _gameSpeed); _lang = 0; Common::Language lang = Common::parseLanguage(ConfMan.get("language")); @@ -363,216 +152,9 @@ int KyraEngine::init() { } KyraEngine::~KyraEngine() { - for (int i = 0; i < ARRAYSIZE(_movieObjects); ++i) { - if (_movieObjects[i]) - _movieObjects[i]->close(); - delete _movieObjects[i]; - _movieObjects[i] = 0; - } - - closeFinalWsa(); - if (_scriptInterpreter) { - _scriptInterpreter->unloadScript(_npcScriptData); - _scriptInterpreter->unloadScript(_scriptClickData); - } - - Common::clearAllSpecialDebugLevels(); - - delete _debugger; - delete _sprites; - delete _animator; - delete _screen; delete _res; delete _sound; - delete _seq; - delete _scriptInterpreter; delete _text; - - delete _npcScriptData; - delete _scriptMain; - - delete _scriptClickData; - delete _scriptClick; - - delete [] _characterList; - - delete [] _movFacingTable; - - delete [] _scrollUpButton.process0PtrShape; - delete [] _scrollUpButton.process1PtrShape; - delete [] _scrollUpButton.process2PtrShape; - delete [] _scrollDownButton.process0PtrShape; - delete [] _scrollDownButton.process1PtrShape; - delete [] _scrollDownButton.process2PtrShape; - - delete [] _itemBkgBackUp[0]; - delete [] _itemBkgBackUp[1]; - - for (int i = 0; i < ARRAYSIZE(_shapes); ++i) { - if (_shapes[i] != 0) { - delete [] _shapes[i]; - for (int i2 = 0; i2 < ARRAYSIZE(_shapes); i2++) { - if (_shapes[i2] == _shapes[i] && i2 != i) { - _shapes[i2] = 0; - } - } - _shapes[i] = 0; - } - } - - for (int i = 0; i < ARRAYSIZE(_sceneAnimTable); ++i) - delete [] _sceneAnimTable[i]; -} - -int KyraEngine::go() { - if (_res->getFileSize("6.FNT")) - _screen->loadFont(Screen::FID_6_FNT, "6.FNT"); - _screen->loadFont(Screen::FID_8_FNT, "8FAT.FNT"); - _screen->setScreenDim(0); - - _abortIntroFlag = false; - - if (_flags.isDemo) { - seq_demo(); - } else { - setGameFlag(0xF3); - setGameFlag(0xFD); - setGameFlag(0xEF); - seq_intro(); - if (_quitFlag) - return 0; - if (_skipIntroFlag && _abortIntroFlag) - resetGameFlag(0xEF); - startup(); - resetGameFlag(0xEF); - mainLoop(); - } - return 0; -} - - -void KyraEngine::startup() { - debugC(9, kDebugLevelMain, "KyraEngine::startup()"); - static const uint8 colorMap[] = { 0, 0, 0, 0, 12, 12, 12, 0, 0, 0, 0, 0 }; - _screen->setTextColorMap(colorMap); -// _screen->setFont(Screen::FID_6_FNT); - _screen->setAnimBlockPtr(3750); - memset(_sceneAnimTable, 0, sizeof(_sceneAnimTable)); - loadMouseShapes(); - _currentCharacter = &_characterList[0]; - for (int i = 1; i < 5; ++i) - _animator->setCharacterDefaultFrame(i); - for (int i = 5; i <= 10; ++i) - setCharactersPositions(i); - _animator->setCharactersHeight(); - resetBrandonPoisonFlags(); - _screen->_curPage = 0; - // XXX - for (int i = 0; i < 12; ++i) { - int size = _screen->getRectSize(3, 24); - _shapes[361+i] = new byte[size]; - } - - _itemBkgBackUp[0] = new uint8[_screen->getRectSize(3, 24)]; - memset(_itemBkgBackUp[0], 0, _screen->getRectSize(3, 24)); - _itemBkgBackUp[1] = new uint8[_screen->getRectSize(4, 32)]; - memset(_itemBkgBackUp[1], 0, _screen->getRectSize(4, 32)); - - for (int i = 0; i < _roomTableSize; ++i) { - for (int item = 0; item < 12; ++item) { - _roomTable[i].itemsTable[item] = 0xFF; - _roomTable[i].itemsXPos[item] = 0xFFFF; - _roomTable[i].itemsYPos[item] = 0xFF; - _roomTable[i].needInit[item] = 0; - } - } - - loadCharacterShapes(); - loadSpecialEffectShapes(); - loadItems(); - loadButtonShapes(); - initMainButtonList(); - loadMainScreen(); - setupTimers(); - _screen->loadPalette("PALETTE.COL", _screen->_currentPalette); - - // XXX - _animator->initAnimStateList(); - setCharactersInDefaultScene(); - - if (!_scriptInterpreter->loadScript("_STARTUP.EMC", _npcScriptData, &_opcodes)) - error("Could not load \"_STARTUP.EMC\" script"); - _scriptInterpreter->initScript(_scriptMain, _npcScriptData); - - if (!_scriptInterpreter->startScript(_scriptMain, 0)) - error("Could not start script function 0 of script \"_STARTUP.EMC\""); - - while (_scriptInterpreter->validScript(_scriptMain)) - _scriptInterpreter->runScript(_scriptMain); - - _scriptInterpreter->unloadScript(_npcScriptData); - - if (!_scriptInterpreter->loadScript("_NPC.EMC", _npcScriptData, &_opcodes)) - error("Could not load \"_NPC.EMC\" script"); - - snd_playTheme(1); - enterNewScene(_currentCharacter->sceneId, _currentCharacter->facing, 0, 0, 1); - - if (_abortIntroFlag && _skipIntroFlag) { - _menuDirectlyToLoad = true; - _screen->setMouseCursor(1, 1, _shapes[0]); - _screen->showMouse(); - buttonMenuCallback(0); - _menuDirectlyToLoad = false; - } else - saveGame(getSavegameFilename(0), "New game"); -} - -void KyraEngine::mainLoop() { - debugC(9, kDebugLevelMain, "KyraEngine::mainLoop()"); - - while (!_quitFlag) { - int32 frameTime = (int32)_system->getMillis(); - _skipFlag = false; - - if (_currentCharacter->sceneId == 210) { - updateKyragemFading(); - if (seq_playEnd() && _deathHandler != 8) - break; - } - - if (_deathHandler != 0xFF) { - snd_playWanderScoreViaMap(0, 1); - snd_playSoundEffect(49); - _screen->hideMouse(); - _screen->setMouseCursor(1, 1, _shapes[0]); - destroyMouseItem(); - _screen->showMouse(); - buttonMenuCallback(0); - _deathHandler = 0xFF; - } - - if ((_brandonStatusBit & 2) && _brandonStatusBit0x02Flag) - _animator->animRefreshNPC(0); - - if ((_brandonStatusBit & 0x20) && _brandonStatusBit0x20Flag) { - _animator->animRefreshNPC(0); - _brandonStatusBit0x20Flag = 0; - } - - _screen->showMouse(); - - processButtonList(_buttonList); - updateMousePointer(); - updateGameTimers(); - updateTextFade(); - - _handleInput = true; - delay((frameTime + _gameSpeed) - _system->getMillis(), true, true); - _handleInput = false; - - _sound->process(); - } } void KyraEngine::quitGame() { @@ -581,209 +163,15 @@ void KyraEngine::quitGame() { // Nothing to do here } -void KyraEngine::delayUntil(uint32 timestamp, bool updateTimers, bool update, bool isMainLoop) { - while (_system->getMillis() < timestamp && !_quitFlag) { - if (updateTimers) - updateGameTimers(); - - if (timestamp - _system->getMillis() >= 10) - delay(10, update, isMainLoop); - } -} - -void KyraEngine::delay(uint32 amount, bool update, bool isMainLoop) { - Common::Event event; - char saveLoadSlot[20]; - char savegameName[14]; - - uint32 start = _system->getMillis(); - do { - while (_eventMan->pollEvent(event)) { - switch (event.type) { - case Common::EVENT_KEYDOWN: - if (event.kbd.keycode >= '1' && event.kbd.keycode <= '9' && - (event.kbd.flags == Common::KBD_CTRL || event.kbd.flags == Common::KBD_ALT) && isMainLoop) { - sprintf(saveLoadSlot, "%s.00%d", _targetName.c_str(), event.kbd.keycode - '0'); - if (event.kbd.flags == Common::KBD_CTRL) - loadGame(saveLoadSlot); - else { - sprintf(savegameName, "Quicksave %d", event.kbd.keycode - '0'); - saveGame(saveLoadSlot, savegameName); - } - } else if (event.kbd.flags == Common::KBD_CTRL) { - if (event.kbd.keycode == 'd') - _debugger->attach(); - else if (event.kbd.keycode == 'q') - _quitFlag = true; - } else if (event.kbd.keycode == '.') - _skipFlag = true; - else if (event.kbd.keycode == Common::KEYCODE_RETURN || event.kbd.keycode == Common::KEYCODE_SPACE || event.kbd.keycode == Common::KEYCODE_ESCAPE) { - _abortIntroFlag = true; - _skipFlag = true; - } - - break; - case Common::EVENT_MOUSEMOVE: - _animator->_updateScreen = true; - break; - case Common::EVENT_QUIT: - quitGame(); - break; - case Common::EVENT_LBUTTONDOWN: - _mousePressFlag = true; - break; - case Common::EVENT_LBUTTONUP: - _mousePressFlag = false; - - if (_abortWalkFlag2) - _abortWalkFlag = true; - - if (_handleInput) { - _handleInput = false; - processInput(); - _handleInput = true; - } else - _skipFlag = true; - - break; - default: - break; - } - } - - if (_debugger->isAttached()) - _debugger->onFrame(); - - if (update) { - _sprites->updateSceneAnims(); - _animator->updateAllObjectShapes(); - updateTextFade(); - updateMousePointer(); - } - - if (_currentCharacter && _currentCharacter->sceneId == 210 && update) - updateKyragemFading(); - - if (_skipFlag && !_abortIntroFlag && !queryGameFlag(0xFE)) - _skipFlag = false; - - if (amount > 0 && !_skipFlag && !_quitFlag) - _system->delayMillis(10); - - if (_skipFlag) - _sound->voiceStop(); - } while (!_skipFlag && _system->getMillis() < start + amount && !_quitFlag); -} - Common::Point KyraEngine::getMousePos() const { Common::Point mouse = _eventMan->getMousePos(); + if (_flags.useHiResOverlay) { mouse.x >>= 1; mouse.y >>= 1; } - return mouse; -} - -void KyraEngine::waitForEvent() { - bool finished = false; - Common::Event event; - - while (!finished && !_quitFlag) { - while (_eventMan->pollEvent(event)) { - switch (event.type) { - case Common::EVENT_KEYDOWN: - finished = true; - break; - case Common::EVENT_QUIT: - quitGame(); - break; - case Common::EVENT_LBUTTONDOWN: - finished = true; - _skipFlag = true; - break; - default: - break; - } - } - - if (_debugger->isAttached()) - _debugger->onFrame(); - - _system->delayMillis(10); - } -} - -void KyraEngine::delayWithTicks(int ticks) { - uint32 nextTime = _system->getMillis() + ticks * _tickLength; - - while (_system->getMillis() < nextTime) { - _sprites->updateSceneAnims(); - _animator->updateAllObjectShapes(); - - if (_currentCharacter->sceneId == 210) { - updateKyragemFading(); - seq_playEnd(); - } - - if (_skipFlag) - break; - - if (nextTime - _system->getMillis() >= 10) - delay(10); - } -} - -#pragma mark - -#pragma mark - Animation/shape specific code -#pragma mark - - -void KyraEngine::setupShapes123(const Shape *shapeTable, int endShape, int flags) { - debugC(9, kDebugLevelMain, "KyraEngine::setupShapes123(%p, %d, %d)", (const void *)shapeTable, endShape, flags); - for (int i = 123; i <= 172; ++i) - _shapes[i] = 0; - - uint8 curImage = 0xFF; - int curPageBackUp = _screen->_curPage; - _screen->_curPage = 8; // we are using page 8 here in the original page 2 was backuped and then used for this stuff - int shapeFlags = 2; - if (flags) - shapeFlags = 3; - for (int i = 123; i < 123+endShape; ++i) { - uint8 newImage = shapeTable[i-123].imageIndex; - if (newImage != curImage && newImage != 0xFF) { - assert(_characterImageTable); - _screen->loadBitmap(_characterImageTable[newImage], 8, 8, 0); - curImage = newImage; - } - _shapes[i] = _screen->encodeShape(shapeTable[i-123].x<<3, shapeTable[i-123].y, shapeTable[i-123].w<<3, shapeTable[i-123].h, shapeFlags); - assert(i-7 < _defaultShapeTableSize); - _defaultShapeTable[i-7].xOffset = shapeTable[i-123].xOffset; - _defaultShapeTable[i-7].yOffset = shapeTable[i-123].yOffset; - _defaultShapeTable[i-7].w = shapeTable[i-123].w; - _defaultShapeTable[i-7].h = shapeTable[i-123].h; - } - _screen->_curPage = curPageBackUp; -} - -void KyraEngine::freeShapes123() { - debugC(9, kDebugLevelMain, "KyraEngine::freeShapes123()"); - - for (int i = 123; i <= 172; ++i) { - delete [] _shapes[i]; - _shapes[i] = 0; - } -} - -#pragma mark - -#pragma mark - Misc stuff -#pragma mark - - -Movie *KyraEngine::createWSAMovie() { - if (_flags.platform == Common::kPlatformAmiga) - return new WSAMovieAmiga(this); - - return new WSAMovieV1(this); + return mouse; } int KyraEngine::setGameFlag(int flag) { @@ -791,7 +179,7 @@ int KyraEngine::setGameFlag(int flag) { return 1; } -int KyraEngine::queryGameFlag(int flag) { +int KyraEngine::queryGameFlag(int flag) const { return ((_flagsTable[flag >> 3] >> (flag & 7)) & 1); } @@ -800,344 +188,19 @@ int KyraEngine::resetGameFlag(int flag) { return 0; } -void KyraEngine::setBrandonPoisonFlags(int reset) { - debugC(9, kDebugLevelMain, "KyraEngine::setBrandonPoisonFlags(%d)", reset); - _brandonStatusBit |= 1; - - if (reset) - _poisonDeathCounter = 0; - - for (int i = 0; i < 0x100; ++i) - _brandonPoisonFlagsGFX[i] = i; - - _brandonPoisonFlagsGFX[0x99] = 0x34; - _brandonPoisonFlagsGFX[0x9A] = 0x35; - _brandonPoisonFlagsGFX[0x9B] = 0x37; - _brandonPoisonFlagsGFX[0x9C] = 0x38; - _brandonPoisonFlagsGFX[0x9D] = 0x2B; -} - -void KyraEngine::resetBrandonPoisonFlags() { - debugC(9, kDebugLevelMain, "KyraEngine::resetBrandonPoisonFlags()"); - _brandonStatusBit = 0; - - for (int i = 0; i < 0x100; ++i) - _brandonPoisonFlagsGFX[i] = i; -} - -#pragma mark - -#pragma mark - Input -#pragma mark - - -void KyraEngine::processInput() { - Common::Point mouse = getMousePos(); - int xpos = mouse.x; - int ypos = mouse.y; - - debugC(9, kDebugLevelMain, "KyraEngine::processInput(%d, %d)", xpos, ypos); - _abortWalkFlag2 = false; - - if (processInputHelper(xpos, ypos)) - return; - - uint8 item = findItemAtPos(xpos, ypos); - if (item == 0xFF) { - _changedScene = false; - int handled = clickEventHandler(xpos, ypos); - if (_changedScene || handled) - return; - } - - // XXX _deathHandler specific - if (ypos <= 158) { - uint16 exit = 0xFFFF; - if (xpos < 12) { - exit = _walkBlockWest; - } else if (xpos >= 308) { - exit = _walkBlockEast; - } else if (ypos >= 136) { - exit = _walkBlockSouth; - } else if (ypos < 12) { - exit = _walkBlockNorth; - } - - if (exit != 0xFFFF) { - _abortWalkFlag2 = true; - handleSceneChange(xpos, ypos, 1, 1); - _abortWalkFlag2 = false; - return; - } else { - int script = checkForNPCScriptRun(xpos, ypos); - if (script >= 0) { - runNpcScript(script); - return; - } - if (_itemInHand != -1) { - if (ypos < 155) { - if (hasClickedOnExit(xpos, ypos)) { - _abortWalkFlag2 = true; - handleSceneChange(xpos, ypos, 1, 1); - _abortWalkFlag2 = false; - return; - } - dropItem(0, _itemInHand, xpos, ypos, 1); - } - } else { - if (ypos <= 155) { - _abortWalkFlag2 = true; - handleSceneChange(xpos, ypos, 1, 1); - _abortWalkFlag2 = false; - } - } - } - } -} - -int KyraEngine::processInputHelper(int xpos, int ypos) { - debugC(9, kDebugLevelMain, "KyraEngine::processInputHelper(%d, %d)", xpos, ypos); - uint8 item = findItemAtPos(xpos, ypos); - if (item != 0xFF) { - if (_itemInHand == -1) { - _screen->hideMouse(); - _animator->animRemoveGameItem(item); - snd_playSoundEffect(53); - assert(_currentCharacter->sceneId < _roomTableSize); - Room *currentRoom = &_roomTable[_currentCharacter->sceneId]; - int item2 = currentRoom->itemsTable[item]; - currentRoom->itemsTable[item] = 0xFF; - setMouseItem(item2); - assert(_itemList && _takenList); - updateSentenceCommand(_itemList[item2], _takenList[0], 179); - _itemInHand = item2; - _screen->showMouse(); - clickEventHandler2(); - return 1; - } else { - exchangeItemWithMouseItem(_currentCharacter->sceneId, item); - return 1; - } - } - return 0; -} - -int KyraEngine::clickEventHandler(int xpos, int ypos) { - debugC(9, kDebugLevelMain, "KyraEngine::clickEventHandler(%d, %d)", xpos, ypos); - _scriptInterpreter->initScript(_scriptClick, _scriptClickData); - _scriptClick->regs[1] = xpos; - _scriptClick->regs[2] = ypos; - _scriptClick->regs[3] = 0; - _scriptClick->regs[4] = _itemInHand; - _scriptInterpreter->startScript(_scriptClick, 1); - - while (_scriptInterpreter->validScript(_scriptClick)) - _scriptInterpreter->runScript(_scriptClick); - - return _scriptClick->regs[3]; -} - -void KyraEngine::updateMousePointer(bool forceUpdate) { - int shape = 0; - - int newMouseState = 0; - int newX = 0; - int newY = 0; - Common::Point mouse = getMousePos(); - if (mouse.y <= 158) { - if (mouse.x >= 12) { - if (mouse.x >= 308) { - if (_walkBlockEast == 0xFFFF) { - newMouseState = -2; - } else { - newMouseState = -5; - shape = 3; - newX = 7; - newY = 5; - } - } else if (mouse.y >= 136) { - if (_walkBlockSouth == 0xFFFF) { - newMouseState = -2; - } else { - newMouseState = -4; - shape = 4; - newX = 5; - newY = 7; - } - } else if (mouse.y < 12) { - if (_walkBlockNorth == 0xFFFF) { - newMouseState = -2; - } else { - newMouseState = -6; - shape = 2; - newX = 5; - newY = 1; - } - } - } else { - if (_walkBlockWest == 0xFFFF) { - newMouseState = -2; - } else { - newMouseState = -3; - newX = 1; - newY = shape = 5; - } - } - } - - if (mouse.x >= _entranceMouseCursorTracks[0] && mouse.y >= _entranceMouseCursorTracks[1] - && mouse.x <= _entranceMouseCursorTracks[2] && mouse.y <= _entranceMouseCursorTracks[3]) { - switch (_entranceMouseCursorTracks[4]) { - case 0: - newMouseState = -6; - shape = 2; - newX = 5; - newY = 1; - break; - - case 2: - newMouseState = -5; - shape = 3; - newX = 7; - newY = 5; - break; - - case 4: - newMouseState = -4; - shape = 4; - newX = 5; - newY = 7; - break; - - case 6: - newMouseState = -3; - shape = 5; - newX = 1; - newY = 5; - break; - - default: - break; - } - } - - if (newMouseState == -2) { - shape = 6; - newX = 4; - newY = 4; - } - - if ((newMouseState && _mouseState != newMouseState) || (newMouseState && forceUpdate)) { - _mouseState = newMouseState; - _screen->hideMouse(); - _screen->setMouseCursor(newX, newY, _shapes[shape]); - _screen->showMouse(); - } - - if (!newMouseState) { - if (_mouseState != _itemInHand || forceUpdate) { - if (mouse.y > 158 || (mouse.x >= 12 && mouse.x < 308 && mouse.y < 136 && mouse.y >= 12) || forceUpdate) { - _mouseState = _itemInHand; - _screen->hideMouse(); - if (_itemInHand == -1) { - _screen->setMouseCursor(1, 1, _shapes[0]); - } else { - _screen->setMouseCursor(8, 15, _shapes[216+_itemInHand]); - } - _screen->showMouse(); - } - } +void KyraEngine::delayUntil(uint32 timestamp, bool updateTimers, bool update, bool isMainLoop) { + while (_system->getMillis() < timestamp && !_quitFlag) { + if (timestamp - _system->getMillis() >= 10) + delay(10, update, isMainLoop); } } -bool KyraEngine::hasClickedOnExit(int xpos, int ypos) { - debugC(9, kDebugLevelMain, "KyraEngine::hasClickedOnExit(%d, %d)", xpos, ypos); - if (xpos < 16 || xpos >= 304) - return true; - - if (ypos < 8) - return true; - - if (ypos < 136 || ypos > 155) - return false; - - return true; -} - -void KyraEngine::clickEventHandler2() { - debugC(9, kDebugLevelMain, "KyraEngine::clickEventHandler2()"); - - Common::Point mouse = getMousePos(); - - _scriptInterpreter->initScript(_scriptClick, _scriptClickData); - _scriptClick->regs[0] = _currentCharacter->sceneId; - _scriptClick->regs[1] = mouse.x; - _scriptClick->regs[2] = mouse.y; - _scriptClick->regs[4] = _itemInHand; - _scriptInterpreter->startScript(_scriptClick, 6); - - while (_scriptInterpreter->validScript(_scriptClick)) - _scriptInterpreter->runScript(_scriptClick); -} - -int KyraEngine::checkForNPCScriptRun(int xpos, int ypos) { - debugC(9, kDebugLevelMain, "KyraEngine::checkForNPCScriptRun(%d, %d)", xpos, ypos); - int returnValue = -1; - const Character *currentChar = _currentCharacter; - int charLeft = 0, charRight = 0, charTop = 0, charBottom = 0; - - int scaleFactor = _scaleTable[currentChar->y1]; - int addX = (((scaleFactor*8)*3)>>8)>>1; - int addY = ((scaleFactor*3)<<4)>>8; - - charLeft = currentChar->x1 - addX; - charRight = currentChar->x1 + addX; - charTop = currentChar->y1 - addY; - charBottom = currentChar->y1; - - if (xpos >= charLeft && charRight >= xpos && charTop <= ypos && charBottom >= ypos) - return 0; - - if (xpos > 304 || xpos < 16) - return -1; - - for (int i = 1; i < 5; ++i) { - currentChar = &_characterList[i]; - - if (currentChar->sceneId != _currentCharacter->sceneId) - continue; - - charLeft = currentChar->x1 - 12; - charRight = currentChar->x1 + 11; - charTop = currentChar->y1 - 48; - // if (!i) { - // charBottom = currentChar->y2 - 16; - // } else { - charBottom = currentChar->y1; - // } - - if (xpos < charLeft || xpos > charRight || ypos < charTop || charBottom < ypos) - continue; - - if (returnValue != -1) { - if (currentChar->y1 >= _characterList[returnValue].y1) - returnValue = i; - } else { - returnValue = i; - } - } - - return returnValue; +void KyraEngine::delay(uint32 amount, bool update, bool isMainLoop) { + _system->delayMillis(amount); } -void KyraEngine::runNpcScript(int func) { - debugC(9, kDebugLevelMain, "KyraEngine::runNpcScript(%d)", func); - _scriptInterpreter->initScript(_npcScript, _npcScriptData); - _scriptInterpreter->startScript(_npcScript, func); - _npcScript->regs[0] = _currentCharacter->sceneId; - _npcScript->regs[4] = _itemInHand; - _npcScript->regs[5] = func; - - while (_scriptInterpreter->validScript(_npcScript)) - _scriptInterpreter->runScript(_npcScript); +void KyraEngine::delayWithTicks(int ticks) { + delay(ticks * _tickLength); } } // End of namespace Kyra diff --git a/engines/kyra/kyra.h b/engines/kyra/kyra.h index bb41a68e6b..7d795abd7c 100644 --- a/engines/kyra/kyra.h +++ b/engines/kyra/kyra.h @@ -33,24 +33,7 @@ namespace Kyra { -class Movie; -class Sound; -class SoundDigital; -class SeqPlayer; -class Resource; -class PAKFile; -class Screen; -class Sprites; -class ScriptHelper; -class Debugger; -class ScreenAnimator; -class TextDisplayer; -class KyraEngine; -class StaticResource; - struct Opcode; -struct ScriptState; -struct ScriptData; struct GameFlags { Common::Language lang; @@ -62,6 +45,11 @@ struct GameFlags { byte gameID; }; +struct Rect { + int x, y; + int x2, y2; +}; + enum { GI_KYRA1 = 0, GI_KYRA2 = 1, @@ -83,839 +71,80 @@ enum kDebugLevels { kDebugLevelMovie = 1 << 9 // prints debug output of movie specific funtions }; -struct Character { - uint16 sceneId; - uint8 height; - uint8 facing; - uint16 currentAnimFrame; - uint8 inventoryItems[10]; - int16 x1, y1, x2, y2; -}; - -struct Shape { - uint8 imageIndex; - int8 xOffset, yOffset; - uint8 x, y, w, h; -}; - -struct Room { - uint8 nameIndex; - uint16 northExit; - uint16 eastExit; - uint16 southExit; - uint16 westExit; - uint8 itemsTable[12]; - uint16 itemsXPos[12]; - uint8 itemsYPos[12]; - uint8 needInit[12]; -}; - -struct Rect { - int x, y; - int x2, y2; -}; - -struct Item { - uint8 unk1; - uint8 height; - uint8 unk2; - uint8 unk3; -}; - -struct SeqLoop { - const uint8 *ptr; - uint16 count; -}; - -struct SceneExits { - uint16 northXPos; - uint8 northYPos; - uint16 eastXPos; - uint8 eastYPos; - uint16 southXPos; - uint8 southYPos; - uint16 westXPos; - uint8 westYPos; -}; - -struct BeadState { - int16 x; - int16 y; - int16 width; - int16 height; - int16 dstX; - int16 dstY; - int16 width2; - int16 unk8; - int16 unk9; - int16 tableIndex; -}; - -struct Timer { - uint8 active; - int32 countdown; - uint32 nextRun; - void (KyraEngine::*func)(int timerNum); -}; - -struct Button { - Button *nextButton; - uint16 specialValue; - // uint8 unk[4]; - uint8 process0; - uint8 process1; - uint8 process2; - // uint8 unk - uint16 flags; - typedef int (KyraEngine::*ButtonCallback)(Button*); - // using 6 pointers instead of 3 as in the orignal here (safer for use with classes) - uint8 *process0PtrShape; - uint8 *process1PtrShape; - uint8 *process2PtrShape; - ButtonCallback process0PtrCallback; - ButtonCallback process1PtrCallback; - ButtonCallback process2PtrCallback; - uint16 dimTableIndex; - uint16 x; - uint16 y; - uint16 width; - uint16 height; - // uint8 unk[8]; - uint32 flags2; - ButtonCallback buttonCallback; - // uint8 unk[8]; -}; - -struct MenuItem { - bool enabled; - uint16 field_1; - uint8 field_3; - const char *itemString; - int16 x; - int16 field_9; - uint16 y; - uint16 width; - uint16 height; - uint8 textColor; - uint8 highlightColor; - int16 field_12; - uint8 field_13; - uint8 bgcolor; - uint8 color1; - uint8 color2; - int (KyraEngine::*callback)(Button*); - int16 field_1b; - const char *labelString; - uint16 labelX; - uint8 labelY; - uint8 field_24; - uint32 field_25; -}; - -struct Menu { - int16 x; - int16 y; - uint16 width; - uint16 height; - uint8 bgcolor; - uint8 color1; - uint8 color2; - const char *menuName; - uint8 textColor; - int16 field_10; - uint16 field_12; - uint16 highlightedItem; - uint8 nrOfItems; - int16 scrollUpBtnX; - int16 scrollUpBtnY; - int16 scrollDownBtnX; - int16 scrollDownBtnY; - MenuItem item[6]; -}; +class Screen; +class Resource; +class Sound; +class Movie; +class TextDisplayer; +class StaticResource; class KyraEngine : public Engine { - friend class MusicPlayer; - friend class Debugger; - friend class ScreenAnimator; public: KyraEngine(OSystem *system, const GameFlags &flags); virtual ~KyraEngine(); - + + bool quit() const { return _quitFlag; } + + uint8 game() const { return _flags.gameID; } + const GameFlags &gameFlags() const { return _flags; } + + // access to Kyra specific functionallity Resource *resource() { return _res; } - Screen *screen() { return _screen; } - ScreenAnimator *animator() { return _animator; } + virtual Screen *screen() = 0; TextDisplayer *text() { return _text; } Sound *sound() { return _sound; } StaticResource *staticres() { return _staticres; } + uint32 tickLength() const { return _tickLength; } - virtual Movie *createWSAMovie(); - - uint8 game() const { return _flags.gameID; } - const GameFlags &gameFlags() const { return _flags; } - - uint8 **shapes() { return _shapes; } - Character *currentCharacter() { return _currentCharacter; } - Character *characterList() { return _characterList; } - uint16 brandonStatus() { return _brandonStatusBit; } - - // TODO: remove me with workaround in animator.cpp l209 - uint16 getScene() { return _currentRoom; } - - bool quit() const { return _quitFlag; } - - int _paletteChanged; - Common::RandomSource _rnd; - int16 _northExitHeight; - - typedef void (KyraEngine::*IntroProc)(); - - // static data access - const char * const*seqWSATable() { return _seq_WSATable; } - const char * const*seqCPSTable() { return _seq_CPSTable; } - const char * const*seqCOLTable() { return _seq_COLTable; } - const char * const*seqTextsTable() { return _seq_textsTable; } - const uint8 * const*palTable1() { return &_specialPalettes[0]; } - const uint8 * const*palTable2() { return &_specialPalettes[29]; } - - // sequences - // -> misc - bool seq_skipSequence() const; - -protected: - // -> demo - void seq_demo(); - - // -> intro - void seq_intro(); - void seq_introLogos(); - void seq_introStory(); - void seq_introMalcolmTree(); - void seq_introKallakWriting(); - void seq_introKallakMalcolm(); - - // -> ingame animations - void seq_createAmuletJewel(int jewel, int page, int noSound, int drawOnly); - void seq_brandonHealing(); - void seq_brandonHealing2(); - void seq_poisonDeathNow(int now); - void seq_poisonDeathNowAnim(); - void seq_playFluteAnimation(); - void seq_winterScroll1(); - void seq_winterScroll2(); - void seq_makeBrandonInv(); - void seq_makeBrandonNormal(); - void seq_makeBrandonNormal2(); - void seq_makeBrandonWisp(); - void seq_dispelMagicAnimation(); - void seq_fillFlaskWithWater(int item, int type); - void seq_playDrinkPotionAnim(int item, int unk2, int flags); - void seq_brandonToStone(); - - // -> end fight - int seq_playEnd(); - void seq_playEnding(); - - int handleMalcolmFlag(); - int handleBeadState(); - void initBeadState(int x, int y, int x2, int y2, int unk1, BeadState *ptr); - int processBead(int x, int y, int &x2, int &y2, BeadState *ptr); - - // -> credits - void seq_playCredits(); - -public: - // delay - void delayUntil(uint32 timestamp, bool updateGameTimers = false, bool update = false, bool isMainLoop = false); - void delay(uint32 millis, bool update = false, bool isMainLoop = false); - void delayWithTicks(int ticks); - void waitForEvent(); - - // TODO - void quitGame(); - - void registerDefaultSettings(); - void readSettings(); - void writeSettings(); - - void snd_playTheme(int file, int track = 0); - void snd_playVoiceFile(int id); - void snd_voiceWaitForFinish(bool ingame = true); - bool snd_voiceIsPlaying(); - void snd_stopVoice(); - void snd_playSoundEffect(int track); - void snd_playWanderScoreViaMap(int command, int restart); - - bool speechEnabled(); - bool textEnabled(); + virtual Movie *createWSAMovie() = 0; - void updateGameTimers(); - void clearNextEventTickCount(); - void setTimerCountdown(uint8 timer, int32 countdown); - void setTimerDelay(uint8 timer, int32 countdown); - int16 getTimerDelay(uint8 timer); - void enableTimer(uint8 timer); - void disableTimer(uint8 timer); - - void saveGame(const char *fileName, const char *saveName); - void loadGame(const char *fileName); - - Common::Point getMousePos() const; + Common::RandomSource _rnd; + + // quit handling + virtual void quitGame(); + // game flag handling int setGameFlag(int flag); - int queryGameFlag(int flag); + int queryGameFlag(int flag) const; int resetGameFlag(int flag); -protected: - virtual int go(); - virtual int init(); - - // input - void processInput(); - int processInputHelper(int xpos, int ypos); - int clickEventHandler(int xpos, int ypos); - void clickEventHandler2(); - void updateMousePointer(bool forceUpdate = false); - bool hasClickedOnExit(int xpos, int ypos); - - // scene - // -> init - void loadSceneMsc(); - void startSceneScript(int brandonAlive); - void setupSceneItems(); - void initSceneData(int facing, int unk1, int brandonAlive); - void initSceneObjectList(int brandonAlive); - void initSceneScreen(int brandonAlive); - void setupSceneResource(int sceneId); - - // -> process - void enterNewScene(int sceneId, int facing, int unk1, int unk2, int brandonAlive); - int handleSceneChange(int xpos, int ypos, int unk1, int frameReset); - int processSceneChange(int *table, int unk1, int frameReset); - int changeScene(int facing); - - // -> modification - void transcendScenes(int roomIndex, int roomName); - void setSceneFile(int roomIndex, int roomName); - - // -> pathfinder - int findWay(int x, int y, int toX, int toY, int *moveTable, int moveTableSize); - int findSubPath(int x, int y, int toX, int toY, int *moveTable, int start, int end); - int getFacingFromPointToPoint(int x, int y, int toX, int toY); - void changePosTowardsFacing(int &x, int &y, int facing); - bool lineIsPassable(int x, int y); - int getMoveTableSize(int *moveTable); - - // -> item handling - // --> misc - void addItemToRoom(uint16 sceneId, uint8 item, int itemIndex, int x, int y); - - // --> drop handling - void itemDropDown(int x, int y, int destX, int destY, byte freeItem, int item); - int processItemDrop(uint16 sceneId, uint8 item, int x, int y, int unk1, int unk2); - void dropItem(int unk1, int item, int x, int y, int unk2); - - // --> dropped item handling - int countItemsInScene(uint16 sceneId); - void exchangeItemWithMouseItem(uint16 sceneId, int itemIndex); - byte findFreeItemInScene(int scene); - byte findItemAtPos(int x, int y); - - // --> drop area handling - void addToNoDropRects(int x, int y, int w, int h); - void clearNoDropRects(); - int isDropable(int x, int y); - int checkNoDropRects(int x, int y); - - // --> player items handling - void updatePlayerItemsForScene(); - - // --> item GFX handling - void backUpItemRect0(int xpos, int ypos); - void restoreItemRect0(int xpos, int ypos); - void backUpItemRect1(int xpos, int ypos); - void restoreItemRect1(int xpos, int ypos); - - // items - // -> misc - void placeItemInGenericMapScene(int item, int index); - - // -> mouse item - void createMouseItem(int item); - void destroyMouseItem(); - void setMouseItem(int item); - - // -> graphics effects - void wipeDownMouseItem(int xpos, int ypos); - void itemSpecialFX(int x, int y, int item); - void itemSpecialFX1(int x, int y, int item); - void itemSpecialFX2(int x, int y, int item); - void magicOutMouseItem(int animIndex, int itemPos); - void magicInMouseItem(int animIndex, int item, int itemPos); - void specialMouseItemFX(int shape, int x, int y, int animIndex, int tableIndex, int loopStart, int maxLoops); - void processSpecialMouseItemFX(int shape, int x, int y, int tableValue, int loopStart, int maxLoops); - - // character - // -> movement - void moveCharacterToPos(int character, int facing, int xpos, int ypos); - void setCharacterPositionWithUpdate(int character); - int setCharacterPosition(int character, int *facingTable); - void setCharacterPositionHelper(int character, int *facingTable); - int getOppositeFacingDirection(int dir); - void setCharactersPositions(int character); - - // -> brandon - void setBrandonPoisonFlags(int reset); - void resetBrandonPoisonFlags(); - - // chat - // -> process - void characterSays(int vocFile, const char *chatStr, int8 charNum, int8 chatDuration); - void waitForChatToFinish(int vocFile, int16 chatDuration, const char *str, uint8 charNum); - - // -> initialization - int initCharacterChat(int8 charNum); - void backupChatPartnerAnimFrame(int8 charNum); - void restoreChatPartnerAnimFrame(int8 charNum); - int8 getChatPartnerNum(); - - // -> deinitialization - void endCharacterChat(int8 charNum, int16 arg_4); - - // graphics - // -> misc - int findDuplicateItemShape(int shape); - void updateKyragemFading(); - - // -> interface - void loadMainScreen(int page = 3); - void redrawInventory(int page); -public: - void drawSentenceCommand(const char *sentence, int unk1); - void updateSentenceCommand(const char *str1, const char *str2, int unk1); - void updateTextFade(); - -protected: - // -> amulet - void drawJewelPress(int jewel, int drawSpecial); - void drawJewelsFadeOutStart(); - void drawJewelsFadeOutEnd(int jewel); - - // -> shape handling - void setupShapes123(const Shape *shapeTable, int endShape, int flags); - void freeShapes123(); - - // misc (TODO) - void startup(); - void mainLoop(); - - int checkForNPCScriptRun(int xpos, int ypos); - void runNpcScript(int func); - - virtual void setupOpcodeTable() = 0; - Common::Array _opcodes; - - void loadMouseShapes(); - void loadCharacterShapes(); - void loadSpecialEffectShapes(); - void loadItems(); - void loadButtonShapes(); - void initMainButtonList(); - void setCharactersInDefaultScene(); - void setupPanPages(); - void freePanPages(); - void closeFinalWsa(); - void setTimer19(); - void setupTimers(); - void timerUpdateHeadAnims(int timerNum); - void timerSetFlags1(int timerNum); - void timerSetFlags2(int timerNum); - void timerSetFlags3(int timerNum); - void timerCheckAnimFlag1(int timerNum); - void timerCheckAnimFlag2(int timerNum); - void checkAmuletAnimFlags(); - void timerRedrawAmulet(int timerNum); - void timerFadeText(int timerNum); - void updateAnimFlag1(int timerNum); - void updateAnimFlag2(int timerNum); - void drawAmulet(); - void setTextFadeTimerCountdown(int16 countdown); - void setWalkspeed(uint8 newSpeed); + // delay functionallity + virtual void delayUntil(uint32 timestamp, bool updateGameTimers = false, bool update = false, bool isMainLoop = false); + virtual void delay(uint32 millis, bool update = false, bool isMainLoop = false); + virtual void delayWithTicks(int ticks); - int buttonInventoryCallback(Button *caller); - int buttonAmuletCallback(Button *caller); - int buttonMenuCallback(Button *caller); - int drawBoxCallback(Button *button); - int drawShadedBoxCallback(Button *button); - void calcCoords(Menu &menu); - void initMenu(Menu &menu); - void setGUILabels(); - - Button *initButton(Button *list, Button *newButton); - void processButtonList(Button *list); - void processButton(Button *button); - void processMenuButton(Button *button); - void processAllMenuButtons(); - - const char *getSavegameFilename(int num); - void setupSavegames(Menu &menu, int num); - int getNextSavegameSlot(); - - int gui_resumeGame(Button *button); - int gui_loadGameMenu(Button *button); - int gui_saveGameMenu(Button *button); - int gui_gameControlsMenu(Button *button); - int gui_quitPlaying(Button *button); - int gui_quitConfirmYes(Button *button); - int gui_quitConfirmNo(Button *button); - int gui_loadGame(Button *button); - int gui_saveGame(Button *button); - int gui_savegameConfirm(Button *button); - int gui_cancelSubMenu(Button *button); - int gui_scrollUp(Button *button); - int gui_scrollDown(Button *button); - int gui_controlsChangeMusic(Button *button); - int gui_controlsChangeSounds(Button *button); - int gui_controlsChangeWalk(Button *button); - int gui_controlsChangeText(Button *button); - int gui_controlsChangeVoice(Button *button); - int gui_controlsApply(Button *button); - - bool gui_quitConfirm(const char *str); - void gui_getInput(); - void gui_redrawText(Menu menu); - void gui_redrawHighlight(Menu menu); - void gui_processHighlights(Menu &menu); - void gui_updateSavegameString(); - void gui_redrawTextfield(); - void gui_fadePalette(); - void gui_restorePalette(); - void gui_setupControls(Menu &menu); - - // Kyra 2 and 3 main menu - - static const char *_mainMenuStrings[]; - virtual void gui_initMainMenu() {} - int gui_handleMainMenu(); - virtual void gui_updateMainMenuAnimation(); - void gui_drawMainMenu(const char * const *strings, int select); - void gui_drawMainBox(int x, int y, int w, int h, int fill); - bool gui_mainMenuGetInput(); +protected: + virtual int go() = 0; + virtual int init(); - void gui_printString(const char *string, int x, int y, int col1, int col2, int flags, ...); - - GameFlags _flags; + // quit Handling bool _quitFlag; - bool _skipFlag; - bool _skipIntroFlag; - bool _abortIntroFlag; - bool _menuDirectlyToLoad; - bool _abortWalkFlag; - bool _abortWalkFlag2; - bool _mousePressFlag; - int8 _mouseWheel; - uint8 _flagsTable[69]; - uint8 *_itemBkgBackUp[2]; - uint8 *_shapes[373]; - uint16 _gameSpeed; - uint16 _tickLength; - int _lang; - int8 _itemInHand; - int _mouseState; - bool _handleInput; - bool _changedScene; - int _unkScreenVar1, _unkScreenVar2, _unkScreenVar3; - int _beadStateVar; - int _unkAmuletVar; - - int _malcolmFlag; - int _endSequenceSkipFlag; - int _endSequenceNeedLoading; - int _unkEndSeqVar2; - uint8 *_endSequenceBackUpRect; - int _unkEndSeqVar4; - int _unkEndSeqVar5; - int _lastDisplayedPanPage; - uint8 *_panPagesTable[20]; - Movie *_finalA, *_finalB, *_finalC; - - Movie *_movieObjects[10]; - - uint16 _entranceMouseCursorTracks[8]; - uint16 _walkBlockNorth; - uint16 _walkBlockEast; - uint16 _walkBlockSouth; - uint16 _walkBlockWest; - - int32 _scaleMode; - int16 _scaleTable[145]; - - Rect _noDropRects[11]; - - int8 _birthstoneGemTable[4]; - int8 _idolGemsTable[3]; - - int8 _marbleVaseItem; - int8 _foyerItemTable[3]; - - int8 _cauldronState; - int8 _crystalState[2]; - - uint16 _brandonStatusBit; - uint8 _brandonStatusBit0x02Flag; - uint8 _brandonStatusBit0x20Flag; - uint8 _brandonPoisonFlagsGFX[256]; - uint8 _deathHandler; - int16 _brandonInvFlag; - uint8 _poisonDeathCounter; - int _brandonPosX; - int _brandonPosY; - - uint16 _currentChatPartnerBackupFrame; - uint16 _currentCharAnimFrame; - int8 *_sceneAnimTable[50]; - - Item _itemTable[145]; - int _lastProcessedItem; - int _lastProcessedItemHeight; - - int16 *_exitListPtr; - int16 _exitList[11]; - SceneExits _sceneExits; - uint16 _currentRoom; - int _scenePhasingFlag; - - int _sceneChangeState; - int _loopFlag2; - - int _pathfinderFlag; - int _pathfinderFlag2; - int _lastFindWayRet; - int *_movFacingTable; - - int8 _talkingCharNum; - int8 _charSayUnk2; - int8 _charSayUnk3; - int8 _currHeadShape; - uint8 _currSentenceColor[3]; - int8 _startSentencePalIndex; - bool _fadeText; - - uint8 _configTextspeed; - uint8 _configWalkspeed; - int _configMusic; - bool _configSounds; - uint8 _configVoice; - - int _curMusicTheme; - int _curSfxFile; - int16 _lastMusicCommand; - + // intern Resource *_res; Screen *_screen; - ScreenAnimator *_animator; Sound *_sound; - SeqPlayer *_seq; - Sprites *_sprites; TextDisplayer *_text; - ScriptHelper *_scriptInterpreter; - Debugger *_debugger; StaticResource *_staticres; - - ScriptState *_scriptMain; - - ScriptState *_npcScript; - ScriptData *_npcScriptData; - - ScriptState *_scriptClick; - ScriptData *_scriptClickData; - - Character *_characterList; - Character *_currentCharacter; - - Button *_buttonList; - Button *_menuButtonList; - bool _displayMenu; - bool _menuRestoreScreen; - bool _displaySubMenu; - bool _cancelSubMenu; - uint8 _toplevelMenu; - int _savegameOffset; - int _gameToLoad; - char _savegameName[31]; - const char *_specialSavegameString; - Common::KeyState _keyPressed; - - struct KyragemState { - uint16 nextOperation; - uint16 rOffset; - uint16 gOffset; - uint16 bOffset; - uint32 timerCount; - } _kyragemFadingState; - - // TODO: get rid of all variables having pointers to the static resources if possible - // i.e. let them directly use the _staticres functions - void initStaticResource(); - - const uint8 *_seq_Forest; - const uint8 *_seq_KallakWriting; - const uint8 *_seq_KyrandiaLogo; - const uint8 *_seq_KallakMalcolm; - const uint8 *_seq_MalcolmTree; - const uint8 *_seq_WestwoodLogo; - const uint8 *_seq_Demo1; - const uint8 *_seq_Demo2; - const uint8 *_seq_Demo3; - const uint8 *_seq_Demo4; - const uint8 *_seq_Reunion; - - const char * const*_seq_WSATable; - const char * const*_seq_CPSTable; - const char * const*_seq_COLTable; - const char * const*_seq_textsTable; - - int _seq_WSATable_Size; - int _seq_CPSTable_Size; - int _seq_COLTable_Size; - int _seq_textsTable_Size; - - const char * const*_itemList; - const char * const*_takenList; - const char * const*_placedList; - const char * const*_droppedList; - const char * const*_noDropList; - const char * const*_putDownFirst; - const char * const*_waitForAmulet; - const char * const*_blackJewel; - const char * const*_poisonGone; - const char * const*_healingTip; - const char * const*_thePoison; - const char * const*_fluteString; - const char * const*_wispJewelStrings; - const char * const*_magicJewelString; - const char * const*_flaskFull; - const char * const*_fullFlask; - const char * const*_veryClever; - const char * const*_homeString; - const char * const*_newGameString; - - const char *_voiceTextString; - const char *_textSpeedString; - const char *_onString; - const char *_offString; - const char *_onCDString; - - int _itemList_Size; - int _takenList_Size; - int _placedList_Size; - int _droppedList_Size; - int _noDropList_Size; - int _putDownFirst_Size; - int _waitForAmulet_Size; - int _blackJewel_Size; - int _poisonGone_Size; - int _healingTip_Size; - int _thePoison_Size; - int _fluteString_Size; - int _wispJewelStrings_Size; - int _magicJewelString_Size; - int _flaskFull_Size; - int _fullFlask_Size; - int _veryClever_Size; - int _homeString_Size; - int _newGameString_Size; - - const char * const*_characterImageTable; - int _characterImageTableSize; - - const char * const*_guiStrings; - int _guiStringsSize; - - const char * const*_configStrings; - int _configStringsSize; - Shape *_defaultShapeTable; - int _defaultShapeTableSize; - - const Shape *_healingShapeTable; - int _healingShapeTableSize; - const Shape *_healingShape2Table; - int _healingShape2TableSize; - - const Shape *_posionDeathShapeTable; - int _posionDeathShapeTableSize; - - const Shape *_fluteAnimShapeTable; - int _fluteAnimShapeTableSize; - - const Shape *_winterScrollTable; - int _winterScrollTableSize; - const Shape *_winterScroll1Table; - int _winterScroll1TableSize; - const Shape *_winterScroll2Table; - int _winterScroll2TableSize; - - const Shape *_drinkAnimationTable; - int _drinkAnimationTableSize; - - const Shape *_brandonToWispTable; - int _brandonToWispTableSize; - - const Shape *_magicAnimationTable; - int _magicAnimationTableSize; - - const Shape *_brandonStoneTable; - int _brandonStoneTableSize; - - Room *_roomTable; - int _roomTableSize; - const char * const*_roomFilenameTable; - int _roomFilenameTableSize; - - const uint8 *_amuleteAnim; + // game speed + bool _skipFlag; + uint16 _tickLength; - const uint8 * const*_specialPalettes; - - Timer _timers[34]; - uint32 _timerNextRun; + // detection + GameFlags _flags; + int _lang; - static const char *_soundFiles[]; - static const int _soundFilesCount; - static const char *_soundFilesTowns[]; - static const int _soundFilesTownsCount; + // opcode + virtual void setupOpcodeTable() = 0; + Common::Array _opcodes; - static const int8 _charXPosTable[]; - static const int8 _addXPosTable[]; - static const int8 _charYPosTable[]; - static const int8 _addYPosTable[]; - - // positions of the inventory - static const uint16 _itemPosX[]; - static const uint8 _itemPosY[]; + // game flags + uint8 _flagsTable[100]; // TODO: check this value - void setupButtonData(); - Button *_buttonData; - Button **_buttonDataListPtr; - static Button _menuButtonData[]; - static Button _scrollUpButton; - static Button _scrollDownButton; - - bool _haveScrollButtons; - - void setupMenu(); - Menu *_menu; - - static const uint8 _magicMouseItemStartFrame[]; - static const uint8 _magicMouseItemEndFrame[]; - static const uint8 _magicMouseItemStartFrame2[]; - static const uint8 _magicMouseItemEndFrame2[]; - - static const uint16 _amuletX[]; - static const uint16 _amuletY[]; - static const uint16 _amuletX2[]; - static const uint16 _amuletY2[]; + // input + Common::Point getMousePos() const; }; } // End of namespace Kyra diff --git a/engines/kyra/kyra_v1.cpp b/engines/kyra/kyra_v1.cpp index 3246e0f426..404e62403a 100644 --- a/engines/kyra/kyra_v1.cpp +++ b/engines/kyra/kyra_v1.cpp @@ -25,13 +25,982 @@ #include "kyra/kyra_v1.h" +#include "common/file.h" +#include "common/events.h" +#include "common/system.h" +#include "common/savefile.h" + +#include "gui/message.h" + +#include "kyra/resource.h" +#include "kyra/screen.h" +#include "kyra/script.h" +#include "kyra/seqplayer.h" +#include "kyra/sound.h" +#include "kyra/sprites.h" +#include "kyra/wsamovie.h" +#include "kyra/animator_v1.h" +#include "kyra/text.h" +#include "kyra/debugger.h" + namespace Kyra { KyraEngine_v1::KyraEngine_v1(OSystem *system, const GameFlags &flags) : KyraEngine(system, flags) { + _flags = flags; + + _seq_Forest = _seq_KallakWriting = _seq_KyrandiaLogo = _seq_KallakMalcolm = + _seq_MalcolmTree = _seq_WestwoodLogo = _seq_Demo1 = _seq_Demo2 = _seq_Demo3 = + _seq_Demo4 = 0; + + _seq_WSATable = _seq_CPSTable = _seq_COLTable = _seq_textsTable = 0; + _seq_WSATable_Size = _seq_CPSTable_Size = _seq_COLTable_Size = _seq_textsTable_Size = 0; + + _roomFilenameTable = _characterImageTable = 0; + _roomFilenameTableSize = _characterImageTableSize = 0; + _itemList = _takenList = _placedList = _droppedList = _noDropList = 0; + _itemList_Size = _takenList_Size = _placedList_Size = _droppedList_Size = _noDropList_Size = 0; + _putDownFirst = _waitForAmulet = _blackJewel = _poisonGone = _healingTip = 0; + _putDownFirst_Size = _waitForAmulet_Size = _blackJewel_Size = _poisonGone_Size = _healingTip_Size = 0; + _thePoison = _fluteString = _wispJewelStrings = _magicJewelString = _flaskFull = _fullFlask = 0; + _thePoison_Size = _fluteString_Size = _wispJewelStrings_Size = 0; + _magicJewelString_Size = _flaskFull_Size = _fullFlask_Size = 0; + + _defaultShapeTable = 0; + _healingShapeTable = _healingShape2Table = 0; + _defaultShapeTableSize = _healingShapeTableSize = _healingShape2TableSize = 0; + _posionDeathShapeTable = _fluteAnimShapeTable = 0; + _posionDeathShapeTableSize = _fluteAnimShapeTableSize = 0; + _winterScrollTable = _winterScroll1Table = _winterScroll2Table = 0; + _winterScrollTableSize = _winterScroll1TableSize = _winterScroll2TableSize = 0; + _drinkAnimationTable = _brandonToWispTable = _magicAnimationTable = _brandonStoneTable = 0; + _drinkAnimationTableSize = _brandonToWispTableSize = _magicAnimationTableSize = _brandonStoneTableSize = 0; + memset(&_specialPalettes, 0, sizeof(_specialPalettes)); + _debugger = 0; + _sprites = 0; + _animator = 0; + _seq = 0; + _scriptInterpreter = 0; + _npcScriptData = 0; + _scriptMain = 0; + _scriptClickData = 0; + _scriptClick = 0; + _characterList = 0; + _movFacingTable = 0; + memset(_shapes, 0, sizeof(_shapes)); + memset(_movieObjects, 0, sizeof(_movieObjects)); + _finalA = _finalB = _finalC = 0; + _endSequenceBackUpRect = 0; + memset(_panPagesTable, 0, sizeof(_panPagesTable)); + _npcScriptData = _scriptClickData = 0; + _scrollUpButton.process0PtrShape = _scrollUpButton.process1PtrShape = _scrollUpButton.process2PtrShape = 0; + _scrollDownButton.process0PtrShape = _scrollDownButton.process1PtrShape = _scrollDownButton.process2PtrShape = 0; + memset(_sceneAnimTable, 0, sizeof(_sceneAnimTable)); + _currHeadShape = 0; + + _curSfxFile = _curMusicTheme = 0; + + memset(&_itemBkgBackUp, 0, sizeof(_itemBkgBackUp)); } KyraEngine_v1::~KyraEngine_v1() { + for (int i = 0; i < ARRAYSIZE(_movieObjects); ++i) { + if (_movieObjects[i]) + _movieObjects[i]->close(); + delete _movieObjects[i]; + _movieObjects[i] = 0; + } + + closeFinalWsa(); + if (_scriptInterpreter) { + _scriptInterpreter->unloadScript(_npcScriptData); + _scriptInterpreter->unloadScript(_scriptClickData); + } + + Common::clearAllSpecialDebugLevels(); + + delete _screen; + delete _debugger; + delete _sprites; + delete _animator; + delete _seq; + delete _scriptInterpreter; + + delete _npcScriptData; + delete _scriptMain; + + delete _scriptClickData; + delete _scriptClick; + + delete [] _characterList; + + delete [] _movFacingTable; + + delete [] _scrollUpButton.process0PtrShape; + delete [] _scrollUpButton.process1PtrShape; + delete [] _scrollUpButton.process2PtrShape; + delete [] _scrollDownButton.process0PtrShape; + delete [] _scrollDownButton.process1PtrShape; + delete [] _scrollDownButton.process2PtrShape; + + delete [] _itemBkgBackUp[0]; + delete [] _itemBkgBackUp[1]; + + for (int i = 0; i < ARRAYSIZE(_shapes); ++i) { + if (_shapes[i] != 0) { + delete [] _shapes[i]; + for (int i2 = 0; i2 < ARRAYSIZE(_shapes); i2++) { + if (_shapes[i2] == _shapes[i] && i2 != i) { + _shapes[i2] = 0; + } + } + _shapes[i] = 0; + } + } + + for (int i = 0; i < ARRAYSIZE(_sceneAnimTable); ++i) + delete [] _sceneAnimTable[i]; +} + +int KyraEngine_v1::init() { + _screen = new Screen_v1(this, _system); + assert(_screen); + if (!_screen->init()) + error("_screen->init() failed"); + + KyraEngine::init(); + + _sprites = new Sprites(this, _system); + assert(_sprites); + _seq = new SeqPlayer(this, _system); + assert(_seq); + _animator = new ScreenAnimator(this, _system); + assert(_animator); + _animator->init(5, 11, 12); + assert(*_animator); + + initStaticResource(); + + if (!_sound->init()) + error("Couldn't init sound"); + + if (_flags.platform == Common::kPlatformFMTowns) + _sound->setSoundFileList(_soundFilesTowns, _soundFilesTownsCount); + else + _sound->setSoundFileList(_soundFiles, _soundFilesCount); + + _sound->setVolume(255); + _sound->loadSoundFile(0); + + setupOpcodeTable(); + setupButtonData(); + setupMenu(); + + _paletteChanged = 1; + _currentCharacter = 0; + _characterList = new Character[11]; + assert(_characterList); + memset(_characterList, 0, sizeof(Character)*11); + + for (int i = 0; i < 11; ++i) + memset(_characterList[i].inventoryItems, 0xFF, sizeof(_characterList[i].inventoryItems)); + + _characterList[0].sceneId = 5; + _characterList[0].height = 48; + _characterList[0].facing = 3; + _characterList[0].currentAnimFrame = 7; + + _scriptInterpreter = new ScriptHelper(this); + assert(_scriptInterpreter); + + _npcScriptData = new ScriptData; + memset(_npcScriptData, 0, sizeof(ScriptData)); + assert(_npcScriptData); + _npcScript = new ScriptState; + assert(_npcScript); + memset(_npcScript, 0, sizeof(ScriptState)); + + _scriptMain = new ScriptState; + assert(_scriptMain); + memset(_scriptMain, 0, sizeof(ScriptState)); + + _scriptClickData = new ScriptData; + assert(_scriptClickData); + memset(_scriptClickData, 0, sizeof(ScriptData)); + _scriptClick = new ScriptState; + assert(_scriptClick); + memset(_scriptClick, 0, sizeof(ScriptState)); + + _debugger = new Debugger_v1(this); + assert(_debugger); + memset(_shapes, 0, sizeof(_shapes)); + + for (int i = 0; i < ARRAYSIZE(_movieObjects); ++i) + _movieObjects[i] = createWSAMovie(); + + memset(_flagsTable, 0, sizeof(_flagsTable)); + + _abortWalkFlag = false; + _abortWalkFlag2 = false; + _talkingCharNum = -1; + _charSayUnk3 = -1; + memset(_currSentenceColor, 0, 3); + _startSentencePalIndex = -1; + _fadeText = false; + + _cauldronState = 0; + _crystalState[0] = _crystalState[1] = -1; + + _brandonStatusBit = 0; + _brandonStatusBit0x02Flag = _brandonStatusBit0x20Flag = 10; + _brandonPosX = _brandonPosY = -1; + _deathHandler = 0xFF; + _poisonDeathCounter = 0; + + memset(_itemTable, 0, sizeof(_itemTable)); + memset(_exitList, 0xFFFF, sizeof(_exitList)); + _exitListPtr = 0; + _pathfinderFlag = _pathfinderFlag2 = 0; + _lastFindWayRet = 0; + _sceneChangeState = _loopFlag2 = 0; + _timerNextRun = 0; + + _movFacingTable = new int[150]; + assert(_movFacingTable); + _movFacingTable[0] = 8; + + registerDefaultSettings(); + readSettings(); + + _skipFlag = false; + + _marbleVaseItem = -1; + memset(_foyerItemTable, -1, sizeof(_foyerItemTable)); + _mouseState = _itemInHand = -1; + _handleInput = false; + + _currentRoom = 0xFFFF; + _scenePhasingFlag = 0; + _lastProcessedItem = 0; + _lastProcessedItemHeight = 16; + + _unkScreenVar1 = 1; + _unkScreenVar2 = 0; + _unkScreenVar3 = 0; + _unkAmuletVar = 0; + + _endSequenceNeedLoading = 1; + _malcolmFlag = 0; + _beadStateVar = 0; + _endSequenceSkipFlag = 0; + _unkEndSeqVar2 = 0; + _endSequenceBackUpRect = 0; + _unkEndSeqVar4 = 0; + _unkEndSeqVar5 = 0; + _lastDisplayedPanPage = 0; + memset(_panPagesTable, 0, sizeof(_panPagesTable)); + _finalA = _finalB = _finalC = 0; + memset(&_kyragemFadingState, 0, sizeof(_kyragemFadingState)); + _kyragemFadingState.gOffset = 0x13; + _kyragemFadingState.bOffset = 0x13; + + _mousePressFlag = false; + + _menuDirectlyToLoad = false; + + _lastMusicCommand = 0; + + _gameSpeed = 60; + _tickLength = (uint8)(1000.0 / _gameSpeed); + + return 0; +} + +int KyraEngine_v1::go() { + if (_res->getFileSize("6.FNT")) + _screen->loadFont(Screen::FID_6_FNT, "6.FNT"); + _screen->loadFont(Screen::FID_8_FNT, "8FAT.FNT"); + _screen->setScreenDim(0); + + _abortIntroFlag = false; + + if (_flags.isDemo) { + seq_demo(); + } else { + setGameFlag(0xF3); + setGameFlag(0xFD); + setGameFlag(0xEF); + seq_intro(); + if (_quitFlag) + return 0; + if (_skipIntroFlag && _abortIntroFlag) + resetGameFlag(0xEF); + startup(); + resetGameFlag(0xEF); + mainLoop(); + } + return 0; +} + + +void KyraEngine_v1::startup() { + debugC(9, kDebugLevelMain, "KyraEngine_v1::startup()"); + static const uint8 colorMap[] = { 0, 0, 0, 0, 12, 12, 12, 0, 0, 0, 0, 0 }; + _screen->setTextColorMap(colorMap); +// _screen->setFont(Screen::FID_6_FNT); + _screen->setAnimBlockPtr(3750); + memset(_sceneAnimTable, 0, sizeof(_sceneAnimTable)); + loadMouseShapes(); + _currentCharacter = &_characterList[0]; + for (int i = 1; i < 5; ++i) + _animator->setCharacterDefaultFrame(i); + for (int i = 5; i <= 10; ++i) + setCharactersPositions(i); + _animator->setCharactersHeight(); + resetBrandonPoisonFlags(); + _screen->_curPage = 0; + // XXX + for (int i = 0; i < 12; ++i) { + int size = _screen->getRectSize(3, 24); + _shapes[361+i] = new byte[size]; + } + + _itemBkgBackUp[0] = new uint8[_screen->getRectSize(3, 24)]; + memset(_itemBkgBackUp[0], 0, _screen->getRectSize(3, 24)); + _itemBkgBackUp[1] = new uint8[_screen->getRectSize(4, 32)]; + memset(_itemBkgBackUp[1], 0, _screen->getRectSize(4, 32)); + + for (int i = 0; i < _roomTableSize; ++i) { + for (int item = 0; item < 12; ++item) { + _roomTable[i].itemsTable[item] = 0xFF; + _roomTable[i].itemsXPos[item] = 0xFFFF; + _roomTable[i].itemsYPos[item] = 0xFF; + _roomTable[i].needInit[item] = 0; + } + } + + loadCharacterShapes(); + loadSpecialEffectShapes(); + loadItems(); + loadButtonShapes(); + initMainButtonList(); + loadMainScreen(); + setupTimers(); + _screen->loadPalette("PALETTE.COL", _screen->_currentPalette); + + // XXX + _animator->initAnimStateList(); + setCharactersInDefaultScene(); + + if (!_scriptInterpreter->loadScript("_STARTUP.EMC", _npcScriptData, &_opcodes)) + error("Could not load \"_STARTUP.EMC\" script"); + _scriptInterpreter->initScript(_scriptMain, _npcScriptData); + + if (!_scriptInterpreter->startScript(_scriptMain, 0)) + error("Could not start script function 0 of script \"_STARTUP.EMC\""); + + while (_scriptInterpreter->validScript(_scriptMain)) + _scriptInterpreter->runScript(_scriptMain); + + _scriptInterpreter->unloadScript(_npcScriptData); + + if (!_scriptInterpreter->loadScript("_NPC.EMC", _npcScriptData, &_opcodes)) + error("Could not load \"_NPC.EMC\" script"); + + snd_playTheme(1); + enterNewScene(_currentCharacter->sceneId, _currentCharacter->facing, 0, 0, 1); + + if (_abortIntroFlag && _skipIntroFlag) { + _menuDirectlyToLoad = true; + _screen->setMouseCursor(1, 1, _shapes[0]); + _screen->showMouse(); + buttonMenuCallback(0); + _menuDirectlyToLoad = false; + } else + saveGame(getSavegameFilename(0), "New game"); +} + +void KyraEngine_v1::mainLoop() { + debugC(9, kDebugLevelMain, "KyraEngine_v1::mainLoop()"); + + while (!_quitFlag) { + int32 frameTime = (int32)_system->getMillis(); + _skipFlag = false; + + if (_currentCharacter->sceneId == 210) { + updateKyragemFading(); + if (seq_playEnd() && _deathHandler != 8) + break; + } + + if (_deathHandler != 0xFF) { + snd_playWanderScoreViaMap(0, 1); + snd_playSoundEffect(49); + _screen->hideMouse(); + _screen->setMouseCursor(1, 1, _shapes[0]); + destroyMouseItem(); + _screen->showMouse(); + buttonMenuCallback(0); + _deathHandler = 0xFF; + } + + if ((_brandonStatusBit & 2) && _brandonStatusBit0x02Flag) + _animator->animRefreshNPC(0); + + if ((_brandonStatusBit & 0x20) && _brandonStatusBit0x20Flag) { + _animator->animRefreshNPC(0); + _brandonStatusBit0x20Flag = 0; + } + + _screen->showMouse(); + + processButtonList(_buttonList); + updateMousePointer(); + updateGameTimers(); + updateTextFade(); + + _handleInput = true; + delay((frameTime + _gameSpeed) - _system->getMillis(), true, true); + _handleInput = false; + + _sound->process(); + } +} + +void KyraEngine_v1::delayUntil(uint32 timestamp, bool updateTimers, bool update, bool isMainLoop) { + while (_system->getMillis() < timestamp && !_quitFlag) { + if (updateTimers) + updateGameTimers(); + + if (timestamp - _system->getMillis() >= 10) + delay(10, update, isMainLoop); + } +} + +void KyraEngine_v1::delay(uint32 amount, bool update, bool isMainLoop) { + Common::Event event; + char saveLoadSlot[20]; + char savegameName[14]; + + uint32 start = _system->getMillis(); + do { + while (_eventMan->pollEvent(event)) { + switch (event.type) { + case Common::EVENT_KEYDOWN: + if (event.kbd.keycode >= '1' && event.kbd.keycode <= '9' && + (event.kbd.flags == Common::KBD_CTRL || event.kbd.flags == Common::KBD_ALT) && isMainLoop) { + sprintf(saveLoadSlot, "%s.00%d", _targetName.c_str(), event.kbd.keycode - '0'); + if (event.kbd.flags == Common::KBD_CTRL) + loadGame(saveLoadSlot); + else { + sprintf(savegameName, "Quicksave %d", event.kbd.keycode - '0'); + saveGame(saveLoadSlot, savegameName); + } + } else if (event.kbd.flags == Common::KBD_CTRL) { + if (event.kbd.keycode == 'd') + _debugger->attach(); + else if (event.kbd.keycode == 'q') + _quitFlag = true; + } else if (event.kbd.keycode == '.') + _skipFlag = true; + else if (event.kbd.keycode == Common::KEYCODE_RETURN || event.kbd.keycode == Common::KEYCODE_SPACE || event.kbd.keycode == Common::KEYCODE_ESCAPE) { + _abortIntroFlag = true; + _skipFlag = true; + } + + break; + case Common::EVENT_MOUSEMOVE: + _animator->_updateScreen = true; + break; + case Common::EVENT_QUIT: + quitGame(); + break; + case Common::EVENT_LBUTTONDOWN: + _mousePressFlag = true; + break; + case Common::EVENT_LBUTTONUP: + _mousePressFlag = false; + + if (_abortWalkFlag2) + _abortWalkFlag = true; + + if (_handleInput) { + _handleInput = false; + processInput(); + _handleInput = true; + } else + _skipFlag = true; + + break; + default: + break; + } + } + + if (_debugger->isAttached()) + _debugger->onFrame(); + + if (update) { + _sprites->updateSceneAnims(); + _animator->updateAllObjectShapes(); + updateTextFade(); + updateMousePointer(); + } + + if (_currentCharacter && _currentCharacter->sceneId == 210 && update) + updateKyragemFading(); + + if (_skipFlag && !_abortIntroFlag && !queryGameFlag(0xFE)) + _skipFlag = false; + + if (amount > 0 && !_skipFlag && !_quitFlag) + _system->delayMillis(10); + + if (_skipFlag) + _sound->voiceStop(); + } while (!_skipFlag && _system->getMillis() < start + amount && !_quitFlag); +} + +void KyraEngine_v1::waitForEvent() { + bool finished = false; + Common::Event event; + + while (!finished && !_quitFlag) { + while (_eventMan->pollEvent(event)) { + switch (event.type) { + case Common::EVENT_KEYDOWN: + finished = true; + break; + case Common::EVENT_QUIT: + quitGame(); + break; + case Common::EVENT_LBUTTONDOWN: + finished = true; + _skipFlag = true; + break; + default: + break; + } + } + + if (_debugger->isAttached()) + _debugger->onFrame(); + + _system->delayMillis(10); + } +} + +void KyraEngine_v1::delayWithTicks(int ticks) { + uint32 nextTime = _system->getMillis() + ticks * _tickLength; + + while (_system->getMillis() < nextTime) { + _sprites->updateSceneAnims(); + _animator->updateAllObjectShapes(); + + if (_currentCharacter->sceneId == 210) { + updateKyragemFading(); + seq_playEnd(); + } + + if (_skipFlag) + break; + + if (nextTime - _system->getMillis() >= 10) + delay(10); + } +} + +#pragma mark - +#pragma mark - Animation/shape specific code +#pragma mark - + +void KyraEngine_v1::setupShapes123(const Shape *shapeTable, int endShape, int flags) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::setupShapes123(%p, %d, %d)", (const void *)shapeTable, endShape, flags); + + for (int i = 123; i <= 172; ++i) + _shapes[i] = 0; + + uint8 curImage = 0xFF; + int curPageBackUp = _screen->_curPage; + _screen->_curPage = 8; // we are using page 8 here in the original page 2 was backuped and then used for this stuff + int shapeFlags = 2; + if (flags) + shapeFlags = 3; + for (int i = 123; i < 123+endShape; ++i) { + uint8 newImage = shapeTable[i-123].imageIndex; + if (newImage != curImage && newImage != 0xFF) { + assert(_characterImageTable); + _screen->loadBitmap(_characterImageTable[newImage], 8, 8, 0); + curImage = newImage; + } + _shapes[i] = _screen->encodeShape(shapeTable[i-123].x<<3, shapeTable[i-123].y, shapeTable[i-123].w<<3, shapeTable[i-123].h, shapeFlags); + assert(i-7 < _defaultShapeTableSize); + _defaultShapeTable[i-7].xOffset = shapeTable[i-123].xOffset; + _defaultShapeTable[i-7].yOffset = shapeTable[i-123].yOffset; + _defaultShapeTable[i-7].w = shapeTable[i-123].w; + _defaultShapeTable[i-7].h = shapeTable[i-123].h; + } + _screen->_curPage = curPageBackUp; +} + +void KyraEngine_v1::freeShapes123() { + debugC(9, kDebugLevelMain, "KyraEngine_v1::freeShapes123()"); + + for (int i = 123; i <= 172; ++i) { + delete [] _shapes[i]; + _shapes[i] = 0; + } +} + +#pragma mark - +#pragma mark - Misc stuff +#pragma mark - + +Movie *KyraEngine_v1::createWSAMovie() { + if (_flags.platform == Common::kPlatformAmiga) + return new WSAMovieAmiga(this); + + return new WSAMovieV1(this); +} + +void KyraEngine_v1::setBrandonPoisonFlags(int reset) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::setBrandonPoisonFlags(%d)", reset); + _brandonStatusBit |= 1; + + if (reset) + _poisonDeathCounter = 0; + + for (int i = 0; i < 0x100; ++i) + _brandonPoisonFlagsGFX[i] = i; + + _brandonPoisonFlagsGFX[0x99] = 0x34; + _brandonPoisonFlagsGFX[0x9A] = 0x35; + _brandonPoisonFlagsGFX[0x9B] = 0x37; + _brandonPoisonFlagsGFX[0x9C] = 0x38; + _brandonPoisonFlagsGFX[0x9D] = 0x2B; +} + +void KyraEngine_v1::resetBrandonPoisonFlags() { + debugC(9, kDebugLevelMain, "KyraEngine_v1::resetBrandonPoisonFlags()"); + _brandonStatusBit = 0; + + for (int i = 0; i < 0x100; ++i) + _brandonPoisonFlagsGFX[i] = i; +} + +#pragma mark - +#pragma mark - Input +#pragma mark - + +void KyraEngine_v1::processInput() { + Common::Point mouse = getMousePos(); + int xpos = mouse.x; + int ypos = mouse.y; + + debugC(9, kDebugLevelMain, "KyraEngine_v1::processInput(%d, %d)", xpos, ypos); + _abortWalkFlag2 = false; + + if (processInputHelper(xpos, ypos)) + return; + + uint8 item = findItemAtPos(xpos, ypos); + if (item == 0xFF) { + _changedScene = false; + int handled = clickEventHandler(xpos, ypos); + if (_changedScene || handled) + return; + } + + // XXX _deathHandler specific + if (ypos <= 158) { + uint16 exit = 0xFFFF; + if (xpos < 12) { + exit = _walkBlockWest; + } else if (xpos >= 308) { + exit = _walkBlockEast; + } else if (ypos >= 136) { + exit = _walkBlockSouth; + } else if (ypos < 12) { + exit = _walkBlockNorth; + } + + if (exit != 0xFFFF) { + _abortWalkFlag2 = true; + handleSceneChange(xpos, ypos, 1, 1); + _abortWalkFlag2 = false; + return; + } else { + int script = checkForNPCScriptRun(xpos, ypos); + if (script >= 0) { + runNpcScript(script); + return; + } + if (_itemInHand != -1) { + if (ypos < 155) { + if (hasClickedOnExit(xpos, ypos)) { + _abortWalkFlag2 = true; + handleSceneChange(xpos, ypos, 1, 1); + _abortWalkFlag2 = false; + return; + } + dropItem(0, _itemInHand, xpos, ypos, 1); + } + } else { + if (ypos <= 155) { + _abortWalkFlag2 = true; + handleSceneChange(xpos, ypos, 1, 1); + _abortWalkFlag2 = false; + } + } + } + } +} + +int KyraEngine_v1::processInputHelper(int xpos, int ypos) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::processInputHelper(%d, %d)", xpos, ypos); + uint8 item = findItemAtPos(xpos, ypos); + if (item != 0xFF) { + if (_itemInHand == -1) { + _screen->hideMouse(); + _animator->animRemoveGameItem(item); + snd_playSoundEffect(53); + assert(_currentCharacter->sceneId < _roomTableSize); + Room *currentRoom = &_roomTable[_currentCharacter->sceneId]; + int item2 = currentRoom->itemsTable[item]; + currentRoom->itemsTable[item] = 0xFF; + setMouseItem(item2); + assert(_itemList && _takenList); + updateSentenceCommand(_itemList[item2], _takenList[0], 179); + _itemInHand = item2; + _screen->showMouse(); + clickEventHandler2(); + return 1; + } else { + exchangeItemWithMouseItem(_currentCharacter->sceneId, item); + return 1; + } + } + return 0; +} + +int KyraEngine_v1::clickEventHandler(int xpos, int ypos) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::clickEventHandler(%d, %d)", xpos, ypos); + _scriptInterpreter->initScript(_scriptClick, _scriptClickData); + _scriptClick->regs[1] = xpos; + _scriptClick->regs[2] = ypos; + _scriptClick->regs[3] = 0; + _scriptClick->regs[4] = _itemInHand; + _scriptInterpreter->startScript(_scriptClick, 1); + + while (_scriptInterpreter->validScript(_scriptClick)) + _scriptInterpreter->runScript(_scriptClick); + + return _scriptClick->regs[3]; +} + +void KyraEngine_v1::updateMousePointer(bool forceUpdate) { + int shape = 0; + + int newMouseState = 0; + int newX = 0; + int newY = 0; + Common::Point mouse = getMousePos(); + if (mouse.y <= 158) { + if (mouse.x >= 12) { + if (mouse.x >= 308) { + if (_walkBlockEast == 0xFFFF) { + newMouseState = -2; + } else { + newMouseState = -5; + shape = 3; + newX = 7; + newY = 5; + } + } else if (mouse.y >= 136) { + if (_walkBlockSouth == 0xFFFF) { + newMouseState = -2; + } else { + newMouseState = -4; + shape = 4; + newX = 5; + newY = 7; + } + } else if (mouse.y < 12) { + if (_walkBlockNorth == 0xFFFF) { + newMouseState = -2; + } else { + newMouseState = -6; + shape = 2; + newX = 5; + newY = 1; + } + } + } else { + if (_walkBlockWest == 0xFFFF) { + newMouseState = -2; + } else { + newMouseState = -3; + newX = 1; + newY = shape = 5; + } + } + } + + if (mouse.x >= _entranceMouseCursorTracks[0] && mouse.y >= _entranceMouseCursorTracks[1] + && mouse.x <= _entranceMouseCursorTracks[2] && mouse.y <= _entranceMouseCursorTracks[3]) { + switch (_entranceMouseCursorTracks[4]) { + case 0: + newMouseState = -6; + shape = 2; + newX = 5; + newY = 1; + break; + + case 2: + newMouseState = -5; + shape = 3; + newX = 7; + newY = 5; + break; + + case 4: + newMouseState = -4; + shape = 4; + newX = 5; + newY = 7; + break; + + case 6: + newMouseState = -3; + shape = 5; + newX = 1; + newY = 5; + break; + + default: + break; + } + } + + if (newMouseState == -2) { + shape = 6; + newX = 4; + newY = 4; + } + + if ((newMouseState && _mouseState != newMouseState) || (newMouseState && forceUpdate)) { + _mouseState = newMouseState; + _screen->hideMouse(); + _screen->setMouseCursor(newX, newY, _shapes[shape]); + _screen->showMouse(); + } + + if (!newMouseState) { + if (_mouseState != _itemInHand || forceUpdate) { + if (mouse.y > 158 || (mouse.x >= 12 && mouse.x < 308 && mouse.y < 136 && mouse.y >= 12) || forceUpdate) { + _mouseState = _itemInHand; + _screen->hideMouse(); + if (_itemInHand == -1) { + _screen->setMouseCursor(1, 1, _shapes[0]); + } else { + _screen->setMouseCursor(8, 15, _shapes[216+_itemInHand]); + } + _screen->showMouse(); + } + } + } +} + +bool KyraEngine_v1::hasClickedOnExit(int xpos, int ypos) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::hasClickedOnExit(%d, %d)", xpos, ypos); + if (xpos < 16 || xpos >= 304) + return true; + + if (ypos < 8) + return true; + + if (ypos < 136 || ypos > 155) + return false; + + return true; +} + +void KyraEngine_v1::clickEventHandler2() { + debugC(9, kDebugLevelMain, "KyraEngine_v1::clickEventHandler2()"); + + Common::Point mouse = getMousePos(); + + _scriptInterpreter->initScript(_scriptClick, _scriptClickData); + _scriptClick->regs[0] = _currentCharacter->sceneId; + _scriptClick->regs[1] = mouse.x; + _scriptClick->regs[2] = mouse.y; + _scriptClick->regs[4] = _itemInHand; + _scriptInterpreter->startScript(_scriptClick, 6); + + while (_scriptInterpreter->validScript(_scriptClick)) + _scriptInterpreter->runScript(_scriptClick); +} + +int KyraEngine_v1::checkForNPCScriptRun(int xpos, int ypos) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::checkForNPCScriptRun(%d, %d)", xpos, ypos); + int returnValue = -1; + const Character *currentChar = _currentCharacter; + int charLeft = 0, charRight = 0, charTop = 0, charBottom = 0; + + int scaleFactor = _scaleTable[currentChar->y1]; + int addX = (((scaleFactor*8)*3)>>8)>>1; + int addY = ((scaleFactor*3)<<4)>>8; + + charLeft = currentChar->x1 - addX; + charRight = currentChar->x1 + addX; + charTop = currentChar->y1 - addY; + charBottom = currentChar->y1; + + if (xpos >= charLeft && charRight >= xpos && charTop <= ypos && charBottom >= ypos) + return 0; + + if (xpos > 304 || xpos < 16) + return -1; + + for (int i = 1; i < 5; ++i) { + currentChar = &_characterList[i]; + + if (currentChar->sceneId != _currentCharacter->sceneId) + continue; + + charLeft = currentChar->x1 - 12; + charRight = currentChar->x1 + 11; + charTop = currentChar->y1 - 48; + // if (!i) { + // charBottom = currentChar->y2 - 16; + // } else { + charBottom = currentChar->y1; + // } + + if (xpos < charLeft || xpos > charRight || ypos < charTop || charBottom < ypos) + continue; + + if (returnValue != -1) { + if (currentChar->y1 >= _characterList[returnValue].y1) + returnValue = i; + } else { + returnValue = i; + } + } + + return returnValue; +} + +void KyraEngine_v1::runNpcScript(int func) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::runNpcScript(%d)", func); + _scriptInterpreter->initScript(_npcScript, _npcScriptData); + _scriptInterpreter->startScript(_npcScript, func); + _npcScript->regs[0] = _currentCharacter->sceneId; + _npcScript->regs[4] = _itemInHand; + _npcScript->regs[5] = func; + + while (_scriptInterpreter->validScript(_npcScript)) + _scriptInterpreter->runScript(_npcScript); } #define Opcode(x) OpcodeV1(this, &KyraEngine_v1::x) diff --git a/engines/kyra/kyra_v1.h b/engines/kyra/kyra_v1.h index 5afa248981..1bd8f48971 100644 --- a/engines/kyra/kyra_v1.h +++ b/engines/kyra/kyra_v1.h @@ -28,14 +28,806 @@ #include "kyra/kyra.h" #include "kyra/script.h" +#include "kyra/screen_v1.h" namespace Kyra { +class Movie; +class SoundDigital; +class SeqPlayer; +class Sprites; +class ScriptHelper; +class Debugger; +class ScreenAnimator; +class TextDisplayer; +class KyraEngine_v1; + +struct Character { + uint16 sceneId; + uint8 height; + uint8 facing; + uint16 currentAnimFrame; + uint8 inventoryItems[10]; + int16 x1, y1, x2, y2; +}; + +struct Shape { + uint8 imageIndex; + int8 xOffset, yOffset; + uint8 x, y, w, h; +}; + +struct Room { + uint8 nameIndex; + uint16 northExit; + uint16 eastExit; + uint16 southExit; + uint16 westExit; + uint8 itemsTable[12]; + uint16 itemsXPos[12]; + uint8 itemsYPos[12]; + uint8 needInit[12]; +}; + +struct Item { + uint8 unk1; + uint8 height; + uint8 unk2; + uint8 unk3; +}; + +struct SeqLoop { + const uint8 *ptr; + uint16 count; +}; + +struct SceneExits { + uint16 northXPos; + uint8 northYPos; + uint16 eastXPos; + uint8 eastYPos; + uint16 southXPos; + uint8 southYPos; + uint16 westXPos; + uint8 westYPos; +}; + +struct BeadState { + int16 x; + int16 y; + int16 width; + int16 height; + int16 dstX; + int16 dstY; + int16 width2; + int16 unk8; + int16 unk9; + int16 tableIndex; +}; + +struct Timer { + uint8 active; + int32 countdown; + uint32 nextRun; + void (KyraEngine_v1::*func)(int timerNum); +}; + +struct Button { + Button *nextButton; + uint16 specialValue; + // uint8 unk[4]; + uint8 process0; + uint8 process1; + uint8 process2; + // uint8 unk + uint16 flags; + typedef int (KyraEngine_v1::*ButtonCallback)(Button*); + // using 6 pointers instead of 3 as in the orignal here (safer for use with classes) + uint8 *process0PtrShape; + uint8 *process1PtrShape; + uint8 *process2PtrShape; + ButtonCallback process0PtrCallback; + ButtonCallback process1PtrCallback; + ButtonCallback process2PtrCallback; + uint16 dimTableIndex; + uint16 x; + uint16 y; + uint16 width; + uint16 height; + // uint8 unk[8]; + uint32 flags2; + ButtonCallback buttonCallback; + // uint8 unk[8]; +}; + +struct MenuItem { + bool enabled; + uint16 field_1; + uint8 field_3; + const char *itemString; + int16 x; + int16 field_9; + uint16 y; + uint16 width; + uint16 height; + uint8 textColor; + uint8 highlightColor; + int16 field_12; + uint8 field_13; + uint8 bgcolor; + uint8 color1; + uint8 color2; + int (KyraEngine_v1::*callback)(Button*); + int16 field_1b; + const char *labelString; + uint16 labelX; + uint8 labelY; + uint8 field_24; + uint32 field_25; +}; + +struct Menu { + int16 x; + int16 y; + uint16 width; + uint16 height; + uint8 bgcolor; + uint8 color1; + uint8 color2; + const char *menuName; + uint8 textColor; + int16 field_10; + uint16 field_12; + uint16 highlightedItem; + uint8 nrOfItems; + int16 scrollUpBtnX; + int16 scrollUpBtnY; + int16 scrollDownBtnX; + int16 scrollDownBtnY; + MenuItem item[6]; +}; + class KyraEngine_v1 : public KyraEngine { + friend class MusicPlayer; + friend class Debugger_v1; + friend class ScreenAnimator; public: KyraEngine_v1(OSystem *system, const GameFlags &flags); ~KyraEngine_v1(); + Screen *screen() { return _screen; } + ScreenAnimator *animator() { return _animator; } + virtual Movie *createWSAMovie(); + + uint8 **shapes() { return _shapes; } + Character *currentCharacter() { return _currentCharacter; } + Character *characterList() { return _characterList; } + uint16 brandonStatus() { return _brandonStatusBit; } + + // TODO: remove me with workaround in animator.cpp l209 + uint16 getScene() { return _currentRoom; } + + int _paletteChanged; + int16 _northExitHeight; + + typedef void (KyraEngine_v1::*IntroProc)(); + + // static data access + const char * const*seqWSATable() { return _seq_WSATable; } + const char * const*seqCPSTable() { return _seq_CPSTable; } + const char * const*seqCOLTable() { return _seq_COLTable; } + const char * const*seqTextsTable() { return _seq_textsTable; } + + const uint8 * const*palTable1() { return &_specialPalettes[0]; } + const uint8 * const*palTable2() { return &_specialPalettes[29]; } + +protected: + virtual int go(); + virtual int init(); + +public: + // sequences + // -> misc + bool seq_skipSequence() const; +protected: + // -> demo + void seq_demo(); + + // -> intro + void seq_intro(); + void seq_introLogos(); + void seq_introStory(); + void seq_introMalcolmTree(); + void seq_introKallakWriting(); + void seq_introKallakMalcolm(); + + // -> ingame animations + void seq_createAmuletJewel(int jewel, int page, int noSound, int drawOnly); + void seq_brandonHealing(); + void seq_brandonHealing2(); + void seq_poisonDeathNow(int now); + void seq_poisonDeathNowAnim(); + void seq_playFluteAnimation(); + void seq_winterScroll1(); + void seq_winterScroll2(); + void seq_makeBrandonInv(); + void seq_makeBrandonNormal(); + void seq_makeBrandonNormal2(); + void seq_makeBrandonWisp(); + void seq_dispelMagicAnimation(); + void seq_fillFlaskWithWater(int item, int type); + void seq_playDrinkPotionAnim(int item, int unk2, int flags); + void seq_brandonToStone(); + + // -> end fight + int seq_playEnd(); + void seq_playEnding(); + + int handleMalcolmFlag(); + int handleBeadState(); + void initBeadState(int x, int y, int x2, int y2, int unk1, BeadState *ptr); + int processBead(int x, int y, int &x2, int &y2, BeadState *ptr); + + // -> credits + void seq_playCredits(); + +public: + // delay + void delayUntil(uint32 timestamp, bool updateGameTimers = false, bool update = false, bool isMainLoop = false); + void delay(uint32 millis, bool update = false, bool isMainLoop = false); + void delayWithTicks(int ticks); + void waitForEvent(); + + // TODO + void registerDefaultSettings(); + void readSettings(); + void writeSettings(); + + void snd_playTheme(int file, int track = 0); + void snd_playVoiceFile(int id); + void snd_voiceWaitForFinish(bool ingame = true); + bool snd_voiceIsPlaying(); + void snd_stopVoice(); + void snd_playSoundEffect(int track); + void snd_playWanderScoreViaMap(int command, int restart); + + bool speechEnabled(); + bool textEnabled(); + + void updateGameTimers(); + void clearNextEventTickCount(); + void setTimerCountdown(uint8 timer, int32 countdown); + void setTimerDelay(uint8 timer, int32 countdown); + int16 getTimerDelay(uint8 timer); + void enableTimer(uint8 timer); + void disableTimer(uint8 timer); + + void saveGame(const char *fileName, const char *saveName); + void loadGame(const char *fileName); + +protected: + // input + void processInput(); + int processInputHelper(int xpos, int ypos); + int clickEventHandler(int xpos, int ypos); + void clickEventHandler2(); + void updateMousePointer(bool forceUpdate = false); + bool hasClickedOnExit(int xpos, int ypos); + + // scene + // -> init + void loadSceneMsc(); + void startSceneScript(int brandonAlive); + void setupSceneItems(); + void initSceneData(int facing, int unk1, int brandonAlive); + void initSceneObjectList(int brandonAlive); + void initSceneScreen(int brandonAlive); + void setupSceneResource(int sceneId); + + // -> process + void enterNewScene(int sceneId, int facing, int unk1, int unk2, int brandonAlive); + int handleSceneChange(int xpos, int ypos, int unk1, int frameReset); + int processSceneChange(int *table, int unk1, int frameReset); + int changeScene(int facing); + + // -> modification + void transcendScenes(int roomIndex, int roomName); + void setSceneFile(int roomIndex, int roomName); + + // -> pathfinder + int findWay(int x, int y, int toX, int toY, int *moveTable, int moveTableSize); + int findSubPath(int x, int y, int toX, int toY, int *moveTable, int start, int end); + int getFacingFromPointToPoint(int x, int y, int toX, int toY); + void changePosTowardsFacing(int &x, int &y, int facing); + bool lineIsPassable(int x, int y); + int getMoveTableSize(int *moveTable); + + // -> item handling + // --> misc + void addItemToRoom(uint16 sceneId, uint8 item, int itemIndex, int x, int y); + + // --> drop handling + void itemDropDown(int x, int y, int destX, int destY, byte freeItem, int item); + int processItemDrop(uint16 sceneId, uint8 item, int x, int y, int unk1, int unk2); + void dropItem(int unk1, int item, int x, int y, int unk2); + + // --> dropped item handling + int countItemsInScene(uint16 sceneId); + void exchangeItemWithMouseItem(uint16 sceneId, int itemIndex); + byte findFreeItemInScene(int scene); + byte findItemAtPos(int x, int y); + + // --> drop area handling + void addToNoDropRects(int x, int y, int w, int h); + void clearNoDropRects(); + int isDropable(int x, int y); + int checkNoDropRects(int x, int y); + + // --> player items handling + void updatePlayerItemsForScene(); + + // --> item GFX handling + void backUpItemRect0(int xpos, int ypos); + void restoreItemRect0(int xpos, int ypos); + void backUpItemRect1(int xpos, int ypos); + void restoreItemRect1(int xpos, int ypos); + + // items + // -> misc + void placeItemInGenericMapScene(int item, int index); + + // -> mouse item + void createMouseItem(int item); + void destroyMouseItem(); + void setMouseItem(int item); + + // -> graphics effects + void wipeDownMouseItem(int xpos, int ypos); + void itemSpecialFX(int x, int y, int item); + void itemSpecialFX1(int x, int y, int item); + void itemSpecialFX2(int x, int y, int item); + void magicOutMouseItem(int animIndex, int itemPos); + void magicInMouseItem(int animIndex, int item, int itemPos); + void specialMouseItemFX(int shape, int x, int y, int animIndex, int tableIndex, int loopStart, int maxLoops); + void processSpecialMouseItemFX(int shape, int x, int y, int tableValue, int loopStart, int maxLoops); + + // character + // -> movement + void moveCharacterToPos(int character, int facing, int xpos, int ypos); + void setCharacterPositionWithUpdate(int character); + int setCharacterPosition(int character, int *facingTable); + void setCharacterPositionHelper(int character, int *facingTable); + int getOppositeFacingDirection(int dir); + void setCharactersPositions(int character); + + // -> brandon + void setBrandonPoisonFlags(int reset); + void resetBrandonPoisonFlags(); + + // chat + // -> process + void characterSays(int vocFile, const char *chatStr, int8 charNum, int8 chatDuration); + void waitForChatToFinish(int vocFile, int16 chatDuration, const char *str, uint8 charNum); + + // -> initialization + int initCharacterChat(int8 charNum); + void backupChatPartnerAnimFrame(int8 charNum); + void restoreChatPartnerAnimFrame(int8 charNum); + int8 getChatPartnerNum(); + + // -> deinitialization + void endCharacterChat(int8 charNum, int16 arg_4); + + // graphics + // -> misc + int findDuplicateItemShape(int shape); + void updateKyragemFading(); + + // -> interface + void loadMainScreen(int page = 3); + void redrawInventory(int page); +public: + void drawSentenceCommand(const char *sentence, int unk1); + void updateSentenceCommand(const char *str1, const char *str2, int unk1); + void updateTextFade(); + +protected: + // -> amulet + void drawJewelPress(int jewel, int drawSpecial); + void drawJewelsFadeOutStart(); + void drawJewelsFadeOutEnd(int jewel); + + // -> shape handling + void setupShapes123(const Shape *shapeTable, int endShape, int flags); + void freeShapes123(); + + // misc (TODO) + void startup(); + void mainLoop(); + + int checkForNPCScriptRun(int xpos, int ypos); + void runNpcScript(int func); + + void loadMouseShapes(); + void loadCharacterShapes(); + void loadSpecialEffectShapes(); + void loadItems(); + void loadButtonShapes(); + void initMainButtonList(); + void setCharactersInDefaultScene(); + void setupPanPages(); + void freePanPages(); + void closeFinalWsa(); + + void setTimer19(); + void setupTimers(); + void timerUpdateHeadAnims(int timerNum); + void timerSetFlags1(int timerNum); + void timerSetFlags2(int timerNum); + void timerSetFlags3(int timerNum); + void timerCheckAnimFlag1(int timerNum); + void timerCheckAnimFlag2(int timerNum); + void checkAmuletAnimFlags(); + void timerRedrawAmulet(int timerNum); + void timerFadeText(int timerNum); + void updateAnimFlag1(int timerNum); + void updateAnimFlag2(int timerNum); + void drawAmulet(); + void setTextFadeTimerCountdown(int16 countdown); + void setWalkspeed(uint8 newSpeed); + + int buttonInventoryCallback(Button *caller); + int buttonAmuletCallback(Button *caller); + int buttonMenuCallback(Button *caller); + int drawBoxCallback(Button *button); + int drawShadedBoxCallback(Button *button); + void calcCoords(Menu &menu); + void initMenu(Menu &menu); + void setGUILabels(); + + Button *initButton(Button *list, Button *newButton); + void processButtonList(Button *list); + void processButton(Button *button); + void processMenuButton(Button *button); + void processAllMenuButtons(); + + const char *getSavegameFilename(int num); + void setupSavegames(Menu &menu, int num); + int getNextSavegameSlot(); + + int gui_resumeGame(Button *button); + int gui_loadGameMenu(Button *button); + int gui_saveGameMenu(Button *button); + int gui_gameControlsMenu(Button *button); + int gui_quitPlaying(Button *button); + int gui_quitConfirmYes(Button *button); + int gui_quitConfirmNo(Button *button); + int gui_loadGame(Button *button); + int gui_saveGame(Button *button); + int gui_savegameConfirm(Button *button); + int gui_cancelSubMenu(Button *button); + int gui_scrollUp(Button *button); + int gui_scrollDown(Button *button); + int gui_controlsChangeMusic(Button *button); + int gui_controlsChangeSounds(Button *button); + int gui_controlsChangeWalk(Button *button); + int gui_controlsChangeText(Button *button); + int gui_controlsChangeVoice(Button *button); + int gui_controlsApply(Button *button); + + bool gui_quitConfirm(const char *str); + void gui_getInput(); + void gui_redrawText(Menu menu); + void gui_redrawHighlight(Menu menu); + void gui_processHighlights(Menu &menu); + void gui_updateSavegameString(); + void gui_redrawTextfield(); + void gui_fadePalette(); + void gui_restorePalette(); + void gui_setupControls(Menu &menu); + + bool _skipIntroFlag; + bool _abortIntroFlag; + bool _menuDirectlyToLoad; + bool _abortWalkFlag; + bool _abortWalkFlag2; + bool _mousePressFlag; + int8 _mouseWheel; + uint8 *_itemBkgBackUp[2]; + uint8 *_shapes[373]; + uint16 _gameSpeed; + int8 _itemInHand; + int _mouseState; + bool _handleInput; + bool _changedScene; + int _unkScreenVar1, _unkScreenVar2, _unkScreenVar3; + int _beadStateVar; + int _unkAmuletVar; + + int _malcolmFlag; + int _endSequenceSkipFlag; + int _endSequenceNeedLoading; + int _unkEndSeqVar2; + uint8 *_endSequenceBackUpRect; + int _unkEndSeqVar4; + int _unkEndSeqVar5; + int _lastDisplayedPanPage; + uint8 *_panPagesTable[20]; + Movie *_finalA, *_finalB, *_finalC; + + Movie *_movieObjects[10]; + + uint16 _entranceMouseCursorTracks[8]; + uint16 _walkBlockNorth; + uint16 _walkBlockEast; + uint16 _walkBlockSouth; + uint16 _walkBlockWest; + + int32 _scaleMode; + int16 _scaleTable[145]; + + Rect _noDropRects[11]; + + int8 _birthstoneGemTable[4]; + int8 _idolGemsTable[3]; + + int8 _marbleVaseItem; + int8 _foyerItemTable[3]; + + int8 _cauldronState; + int8 _crystalState[2]; + + uint16 _brandonStatusBit; + uint8 _brandonStatusBit0x02Flag; + uint8 _brandonStatusBit0x20Flag; + uint8 _brandonPoisonFlagsGFX[256]; + uint8 _deathHandler; + int16 _brandonInvFlag; + uint8 _poisonDeathCounter; + int _brandonPosX; + int _brandonPosY; + + uint16 _currentChatPartnerBackupFrame; + uint16 _currentCharAnimFrame; + + int8 *_sceneAnimTable[50]; + + Item _itemTable[145]; + int _lastProcessedItem; + int _lastProcessedItemHeight; + + int16 *_exitListPtr; + int16 _exitList[11]; + SceneExits _sceneExits; + uint16 _currentRoom; + int _scenePhasingFlag; + + int _sceneChangeState; + int _loopFlag2; + + int _pathfinderFlag; + int _pathfinderFlag2; + int _lastFindWayRet; + int *_movFacingTable; + + int8 _talkingCharNum; + int8 _charSayUnk2; + int8 _charSayUnk3; + int8 _currHeadShape; + uint8 _currSentenceColor[3]; + int8 _startSentencePalIndex; + bool _fadeText; + + uint8 _configTextspeed; + uint8 _configWalkspeed; + int _configMusic; + bool _configSounds; + uint8 _configVoice; + + int _curMusicTheme; + int _curSfxFile; + int16 _lastMusicCommand; + + ScreenAnimator *_animator; + SeqPlayer *_seq; + Sprites *_sprites; + Screen_v1 *_screen; + ScriptHelper *_scriptInterpreter; + Debugger *_debugger; + + ScriptState *_scriptMain; + + ScriptState *_npcScript; + ScriptData *_npcScriptData; + + ScriptState *_scriptClick; + ScriptData *_scriptClickData; + + Character *_characterList; + Character *_currentCharacter; + + Button *_buttonList; + Button *_menuButtonList; + bool _displayMenu; + bool _menuRestoreScreen; + bool _displaySubMenu; + bool _cancelSubMenu; + uint8 _toplevelMenu; + int _savegameOffset; + int _gameToLoad; + char _savegameName[31]; + const char *_specialSavegameString; + Common::KeyState _keyPressed; + + struct KyragemState { + uint16 nextOperation; + uint16 rOffset; + uint16 gOffset; + uint16 bOffset; + uint32 timerCount; + } _kyragemFadingState; + + // TODO: get rid of all variables having pointers to the static resources if possible + // i.e. let them directly use the _staticres functions + void initStaticResource(); + + const uint8 *_seq_Forest; + const uint8 *_seq_KallakWriting; + const uint8 *_seq_KyrandiaLogo; + const uint8 *_seq_KallakMalcolm; + const uint8 *_seq_MalcolmTree; + const uint8 *_seq_WestwoodLogo; + const uint8 *_seq_Demo1; + const uint8 *_seq_Demo2; + const uint8 *_seq_Demo3; + const uint8 *_seq_Demo4; + const uint8 *_seq_Reunion; + + const char * const*_seq_WSATable; + const char * const*_seq_CPSTable; + const char * const*_seq_COLTable; + const char * const*_seq_textsTable; + + int _seq_WSATable_Size; + int _seq_CPSTable_Size; + int _seq_COLTable_Size; + int _seq_textsTable_Size; + + const char * const*_itemList; + const char * const*_takenList; + const char * const*_placedList; + const char * const*_droppedList; + const char * const*_noDropList; + const char * const*_putDownFirst; + const char * const*_waitForAmulet; + const char * const*_blackJewel; + const char * const*_poisonGone; + const char * const*_healingTip; + const char * const*_thePoison; + const char * const*_fluteString; + const char * const*_wispJewelStrings; + const char * const*_magicJewelString; + const char * const*_flaskFull; + const char * const*_fullFlask; + const char * const*_veryClever; + const char * const*_homeString; + const char * const*_newGameString; + + const char *_voiceTextString; + const char *_textSpeedString; + const char *_onString; + const char *_offString; + const char *_onCDString; + + int _itemList_Size; + int _takenList_Size; + int _placedList_Size; + int _droppedList_Size; + int _noDropList_Size; + int _putDownFirst_Size; + int _waitForAmulet_Size; + int _blackJewel_Size; + int _poisonGone_Size; + int _healingTip_Size; + int _thePoison_Size; + int _fluteString_Size; + int _wispJewelStrings_Size; + int _magicJewelString_Size; + int _flaskFull_Size; + int _fullFlask_Size; + int _veryClever_Size; + int _homeString_Size; + int _newGameString_Size; + + const char * const*_characterImageTable; + int _characterImageTableSize; + + const char * const*_guiStrings; + int _guiStringsSize; + + const char * const*_configStrings; + int _configStringsSize; + + Shape *_defaultShapeTable; + int _defaultShapeTableSize; + + const Shape *_healingShapeTable; + int _healingShapeTableSize; + const Shape *_healingShape2Table; + int _healingShape2TableSize; + + const Shape *_posionDeathShapeTable; + int _posionDeathShapeTableSize; + + const Shape *_fluteAnimShapeTable; + int _fluteAnimShapeTableSize; + + const Shape *_winterScrollTable; + int _winterScrollTableSize; + const Shape *_winterScroll1Table; + int _winterScroll1TableSize; + const Shape *_winterScroll2Table; + int _winterScroll2TableSize; + + const Shape *_drinkAnimationTable; + int _drinkAnimationTableSize; + + const Shape *_brandonToWispTable; + int _brandonToWispTableSize; + + const Shape *_magicAnimationTable; + int _magicAnimationTableSize; + + const Shape *_brandonStoneTable; + int _brandonStoneTableSize; + + Room *_roomTable; + int _roomTableSize; + const char * const*_roomFilenameTable; + int _roomFilenameTableSize; + + const uint8 *_amuleteAnim; + + const uint8 * const*_specialPalettes; + + Timer _timers[34]; + uint32 _timerNextRun; + + static const char *_soundFiles[]; + static const int _soundFilesCount; + static const char *_soundFilesTowns[]; + static const int _soundFilesTownsCount; + + static const int8 _charXPosTable[]; + static const int8 _addXPosTable[]; + static const int8 _charYPosTable[]; + static const int8 _addYPosTable[]; + + // positions of the inventory + static const uint16 _itemPosX[]; + static const uint8 _itemPosY[]; + + void setupButtonData(); + Button *_buttonData; + Button **_buttonDataListPtr; + static Button _menuButtonData[]; + static Button _scrollUpButton; + static Button _scrollDownButton; + + bool _haveScrollButtons; + + void setupMenu(); + Menu *_menu; + + static const uint8 _magicMouseItemStartFrame[]; + static const uint8 _magicMouseItemEndFrame[]; + static const uint8 _magicMouseItemStartFrame2[]; + static const uint8 _magicMouseItemEndFrame2[]; + + static const uint16 _amuletX[]; + static const uint16 _amuletY[]; + static const uint16 _amuletX2[]; + static const uint16 _amuletY2[]; protected: typedef OpcodeImpl OpcodeV1; void setupOpcodeTable(); diff --git a/engines/kyra/kyra_v2.cpp b/engines/kyra/kyra_v2.cpp index 03d1f8e27e..2f52d8919d 100644 --- a/engines/kyra/kyra_v2.cpp +++ b/engines/kyra/kyra_v2.cpp @@ -41,9 +41,19 @@ KyraEngine_v2::KyraEngine_v2(OSystem *system, const GameFlags &flags) : KyraEngi KyraEngine_v2::~KyraEngine_v2() { delete [] _mouseSHPBuf; + delete _screen; +} + +Movie *KyraEngine_v2::createWSAMovie() { + return new WSAMovieV2(this); } int KyraEngine_v2::init() { + _screen = new Screen_v2(this, _system); + assert(_screen); + if (!_screen->init()) + error("_screen->init() failed"); + KyraEngine::init(); if (_res->getFileSize("6.FNT")) diff --git a/engines/kyra/kyra_v2.h b/engines/kyra/kyra_v2.h index e3dac3f0d5..df73118376 100644 --- a/engines/kyra/kyra_v2.h +++ b/engines/kyra/kyra_v2.h @@ -26,6 +26,9 @@ #ifndef KYRA_KYRA_V2_H #define KYRA_KYRA_V2_H +#include "kyra/kyra.h" +#include "kyra/screen_v2.h" + namespace Kyra { enum kSequences { @@ -82,10 +85,24 @@ class KyraEngine_v2 : public KyraEngine { public: KyraEngine_v2(OSystem *system, const GameFlags &flags); ~KyraEngine_v2(); + + virtual Screen *screen() { return _screen; } + Screen *screen_v2() { return _screen; } + + Movie *createWSAMovie(); +protected: + // Main menu code, also used for Kyra 3 + static const char *_mainMenuStrings[]; + + virtual void gui_initMainMenu() {} + int gui_handleMainMenu(); + virtual void gui_updateMainMenuAnimation(); + void gui_drawMainMenu(const char * const *strings, int select); + void gui_drawMainBox(int x, int y, int w, int h, int fill); + bool gui_mainMenuGetInput(); + + void gui_printString(const char *string, int x, int y, int col1, int col2, int flags, ...); - int go(); - -private: void setupOpcodeTable() {} void seq_playSequences(int startSeq, int endSeq = -1); @@ -111,7 +128,11 @@ private: void seq_setChatEntry(uint16 strIndex, uint16 posX, uint16 posY, int duration, uint16 unk1); void mainMenu(); + int init(); + int go(); + + Screen_v2 *_screen; ActiveWSA *_activeWSA; ActiveChat *_activeChat; diff --git a/engines/kyra/kyra_v3.cpp b/engines/kyra/kyra_v3.cpp index f035158892..b49635ab2d 100644 --- a/engines/kyra/kyra_v3.cpp +++ b/engines/kyra/kyra_v3.cpp @@ -38,7 +38,7 @@ #include "graphics/cursorman.h" namespace Kyra { -KyraEngine_v3::KyraEngine_v3(OSystem *system, const GameFlags &flags) : KyraEngine(system, flags) { +KyraEngine_v3::KyraEngine_v3(OSystem *system, const GameFlags &flags) : KyraEngine_v2(system, flags) { _soundDigital = 0; _musicSoundChannel = -1; _menuAudioFile = "TITLE1.AUD"; @@ -87,10 +87,6 @@ KyraEngine_v3::~KyraEngine_v3() { delete [] _scenesList; } -Movie *KyraEngine_v3::createWSAMovie() { - return new WSAMovieV2(this); -} - int KyraEngine_v3::init() { KyraEngine::init(); @@ -324,7 +320,7 @@ int KyraEngine_v3::musicUpdate(int forceRestart) { #pragma mark - void KyraEngine_v3::gui_initMainMenu() { - KyraEngine::gui_initMainMenu(); + KyraEngine_v2::gui_initMainMenu(); _mainMenuFrame = 29; _mainMenuFrameAdd = 1; } diff --git a/engines/kyra/kyra_v3.h b/engines/kyra/kyra_v3.h index 5616fcbf0e..79c48b0dcb 100644 --- a/engines/kyra/kyra_v3.h +++ b/engines/kyra/kyra_v3.h @@ -26,20 +26,17 @@ #ifndef KYRA_KYRA_V3_H #define KYRA_KYRA_V3_H -#include "kyra/kyra.h" +#include "kyra/kyra_v2.h" namespace Kyra { -// maybe subclass KyraEngine_v2 later -class WSAMovieV2; +class SoundDigital; -class KyraEngine_v3 : public KyraEngine { +class KyraEngine_v3 : public KyraEngine_v2 { public: KyraEngine_v3(OSystem *system, const GameFlags &flags); ~KyraEngine_v3(); - - Movie *createWSAMovie(); - + SoundDigital *soundDigital() { return _soundDigital; } int go(); diff --git a/engines/kyra/module.mk b/engines/kyra/module.mk index 8303028b27..0ddcc1bf7f 100644 --- a/engines/kyra/module.mk +++ b/engines/kyra/module.mk @@ -1,19 +1,22 @@ MODULE := engines/kyra MODULE_OBJS := \ - animator.o \ + animator_v1.o \ debugger.o \ detection.o \ - gui.o \ - items.o \ + gui_v1.o \ + gui_v2.o \ + items_v1.o \ kyra.o \ kyra_v1.o \ kyra_v2.o \ kyra_v3.o \ resource.o \ - saveload.o \ - scene.o \ + saveload_v1.o \ + scene_v1.o \ screen.o \ + screen_v1.o \ + screen_v2.o \ script_v1.o \ script.o \ seqplayer.o \ @@ -23,10 +26,12 @@ MODULE_OBJS := \ sound_digital.o \ sound_towns.o \ sound.o \ + sound_v1.o \ sprites.o \ staticres.o \ text.o \ - timer.o \ + text_v1.o \ + timer_v1.o \ vqa.o \ wsamovie.o diff --git a/engines/kyra/saveload_v1.cpp b/engines/kyra/saveload_v1.cpp index 95693684a1..d28a0b3f8b 100644 --- a/engines/kyra/saveload_v1.cpp +++ b/engines/kyra/saveload_v1.cpp @@ -28,8 +28,8 @@ #include "common/savefile.h" #include "common/system.h" -#include "kyra/kyra.h" -#include "kyra/animator.h" +#include "kyra/kyra_v1.h" +#include "kyra/animator_v1.h" #include "kyra/screen.h" #include "kyra/resource.h" #include "kyra/sound.h" @@ -44,7 +44,7 @@ #define GF_FMTOWNS (1 << 2) namespace Kyra { -void KyraEngine::loadGame(const char *fileName) { +void KyraEngine_v1::loadGame(const char *fileName) { debugC(9, kDebugLevelMain, "loadGame('%s')", fileName); Common::InSaveFile *in; @@ -266,7 +266,7 @@ void KyraEngine::loadGame(const char *fileName) { delete in; } -void KyraEngine::saveGame(const char *fileName, const char *saveName) { +void KyraEngine_v1::saveGame(const char *fileName, const char *saveName) { debugC(9, kDebugLevelMain, "saveGame('%s', '%s')", fileName, saveName); Common::OutSaveFile *out; if (_quitFlag) return; diff --git a/engines/kyra/scene_v1.cpp b/engines/kyra/scene_v1.cpp index a92fd9ce7c..e01bb98e18 100644 --- a/engines/kyra/scene_v1.cpp +++ b/engines/kyra/scene_v1.cpp @@ -23,14 +23,14 @@ * */ -#include "kyra/kyra.h" +#include "kyra/kyra_v1.h" #include "kyra/seqplayer.h" #include "kyra/screen.h" #include "kyra/resource.h" #include "kyra/sound.h" #include "kyra/sprites.h" #include "kyra/wsamovie.h" -#include "kyra/animator.h" +#include "kyra/animator_v1.h" #include "kyra/text.h" #include "kyra/script.h" @@ -39,8 +39,8 @@ namespace Kyra { -void KyraEngine::enterNewScene(int sceneId, int facing, int unk1, int unk2, int brandonAlive) { - debugC(9, kDebugLevelMain, "KyraEngine::enterNewScene(%d, %d, %d, %d, %d)", sceneId, facing, unk1, unk2, brandonAlive); +void KyraEngine_v1::enterNewScene(int sceneId, int facing, int unk1, int unk2, int brandonAlive) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::enterNewScene(%d, %d, %d, %d, %d)", sceneId, facing, unk1, unk2, brandonAlive); int unkVar1 = 1; _screen->hideMouse(); _handleInput = false; @@ -191,8 +191,8 @@ void KyraEngine::enterNewScene(int sceneId, int facing, int unk1, int unk2, int _changedScene = true; } -void KyraEngine::transcendScenes(int roomIndex, int roomName) { - debugC(9, kDebugLevelMain, "KyraEngine::transcendScenes(%d, %d)", roomIndex, roomName); +void KyraEngine_v1::transcendScenes(int roomIndex, int roomName) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::transcendScenes(%d, %d)", roomIndex, roomName); assert(roomIndex < _roomTableSize); if (_flags.isTalkie) { @@ -217,14 +217,14 @@ void KyraEngine::transcendScenes(int roomIndex, int roomName) { _unkScreenVar3 = 0; } -void KyraEngine::setSceneFile(int roomIndex, int roomName) { - debugC(9, kDebugLevelMain, "KyraEngine::setSceneFile(%d, %d)", roomIndex, roomName); +void KyraEngine_v1::setSceneFile(int roomIndex, int roomName) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::setSceneFile(%d, %d)", roomIndex, roomName); assert(roomIndex < _roomTableSize); _roomTable[roomIndex].nameIndex = roomName; } -void KyraEngine::moveCharacterToPos(int character, int facing, int xpos, int ypos) { - debugC(9, kDebugLevelMain, "KyraEngine::moveCharacterToPos(%d, %d, %d, %d)", character, facing, xpos, ypos); +void KyraEngine_v1::moveCharacterToPos(int character, int facing, int xpos, int ypos) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::moveCharacterToPos(%d, %d, %d, %d)", character, facing, xpos, ypos); Character *ch = &_characterList[character]; ch->facing = facing; _screen->hideMouse(); @@ -278,8 +278,8 @@ void KyraEngine::moveCharacterToPos(int character, int facing, int xpos, int ypo _screen->showMouse(); } -void KyraEngine::setCharacterPositionWithUpdate(int character) { - debugC(9, kDebugLevelMain, "KyraEngine::setCharacterPositionWithUpdate(%d)", character); +void KyraEngine_v1::setCharacterPositionWithUpdate(int character) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::setCharacterPositionWithUpdate(%d)", character); setCharacterPosition(character, 0); _sprites->updateSceneAnims(); updateGameTimers(); @@ -290,8 +290,8 @@ void KyraEngine::setCharacterPositionWithUpdate(int character) { updateKyragemFading(); } -int KyraEngine::setCharacterPosition(int character, int *facingTable) { - debugC(9, kDebugLevelMain, "KyraEngine::setCharacterPosition(%d, %p)", character, (const void *)facingTable); +int KyraEngine_v1::setCharacterPosition(int character, int *facingTable) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::setCharacterPosition(%d, %p)", character, (const void *)facingTable); if (character == 0) { _currentCharacter->x1 += _charXPosTable[_currentCharacter->facing]; @@ -307,8 +307,8 @@ int KyraEngine::setCharacterPosition(int character, int *facingTable) { return 0; } -void KyraEngine::setCharacterPositionHelper(int character, int *facingTable) { - debugC(9, kDebugLevelMain, "KyraEngine::setCharacterPositionHelper(%d, %p)", character, (const void *)facingTable); +void KyraEngine_v1::setCharacterPositionHelper(int character, int *facingTable) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::setCharacterPositionHelper(%d, %p)", character, (const void *)facingTable); Character *ch = &_characterList[character]; ++ch->currentAnimFrame; int facing = ch->facing; @@ -391,8 +391,8 @@ void KyraEngine::setCharacterPositionHelper(int character, int *facingTable) { _animator->animRefreshNPC(character); } -int KyraEngine::getOppositeFacingDirection(int dir) { - debugC(9, kDebugLevelMain, "KyraEngine::getOppositeFacingDirection(%d)", dir); +int KyraEngine_v1::getOppositeFacingDirection(int dir) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::getOppositeFacingDirection(%d)", dir); switch (dir) { case 0: return 2; @@ -414,7 +414,7 @@ int KyraEngine::getOppositeFacingDirection(int dir) { return 0; } -void KyraEngine::loadSceneMsc() { +void KyraEngine_v1::loadSceneMsc() { assert(_currentCharacter->sceneId < _roomTableSize); int tableId = _roomTable[_currentCharacter->sceneId].nameIndex; assert(tableId < _roomFilenameTableSize); @@ -425,8 +425,8 @@ void KyraEngine::loadSceneMsc() { _screen->loadBitmap(fileNameBuffer, 3, 5, 0); } -void KyraEngine::startSceneScript(int brandonAlive) { - debugC(9, kDebugLevelMain, "KyraEngine::startSceneScript(%d)", brandonAlive); +void KyraEngine_v1::startSceneScript(int brandonAlive) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::startSceneScript(%d)", brandonAlive); assert(_currentCharacter->sceneId < _roomTableSize); int tableId = _roomTable[_currentCharacter->sceneId].nameIndex; assert(tableId < _roomFilenameTableSize); @@ -457,8 +457,8 @@ void KyraEngine::startSceneScript(int brandonAlive) { _scriptInterpreter->runScript(_scriptClick); } -void KyraEngine::initSceneData(int facing, int unk1, int brandonAlive) { - debugC(9, kDebugLevelMain, "KyraEngine::initSceneData(%d, %d, %d)", facing, unk1, brandonAlive); +void KyraEngine_v1::initSceneData(int facing, int unk1, int brandonAlive) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::initSceneData(%d, %d, %d)", facing, unk1, brandonAlive); int16 xpos2 = 0; int setFacing = 1; @@ -627,8 +627,8 @@ void KyraEngine::initSceneData(int facing, int unk1, int brandonAlive) { _scriptInterpreter->runScript(_scriptClick); } -void KyraEngine::initSceneObjectList(int brandonAlive) { - debugC(9, kDebugLevelMain, "KyraEngine::initSceneObjectList(%d)", brandonAlive); +void KyraEngine_v1::initSceneObjectList(int brandonAlive) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::initSceneObjectList(%d)", brandonAlive); for (int i = 0; i < 28; ++i) _animator->actors()[i].active = 0; @@ -798,7 +798,7 @@ void KyraEngine::initSceneObjectList(int brandonAlive) { _animator->copyChangedObjectsForward(0); } -void KyraEngine::initSceneScreen(int brandonAlive) { +void KyraEngine_v1::initSceneScreen(int brandonAlive) { if (_flags.platform == Common::kPlatformAmiga) { if (_unkScreenVar1 && !queryGameFlag(0xF0)) { memset(_screen->getPalette(2), 0, 32*3); @@ -871,8 +871,8 @@ void KyraEngine::initSceneScreen(int brandonAlive) { } } -int KyraEngine::handleSceneChange(int xpos, int ypos, int unk1, int frameReset) { - debugC(9, kDebugLevelMain, "KyraEngine::handleSceneChange(%d, %d, %d, %d)", xpos, ypos, unk1, frameReset); +int KyraEngine_v1::handleSceneChange(int xpos, int ypos, int unk1, int frameReset) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::handleSceneChange(%d, %d, %d, %d)", xpos, ypos, unk1, frameReset); if (queryGameFlag(0xEF)) unk1 = 0; @@ -931,8 +931,8 @@ int KyraEngine::handleSceneChange(int xpos, int ypos, int unk1, int frameReset) return processSceneChange(_movFacingTable, unk1, frameReset); } -int KyraEngine::processSceneChange(int *table, int unk1, int frameReset) { - debugC(9, kDebugLevelMain, "KyraEngine::processSceneChange(%p, %d, %d)", (const void *)table, unk1, frameReset); +int KyraEngine_v1::processSceneChange(int *table, int unk1, int frameReset) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::processSceneChange(%p, %d, %d)", (const void *)table, unk1, frameReset); if (queryGameFlag(0xEF)) unk1 = 0; @@ -1024,8 +1024,8 @@ int KyraEngine::processSceneChange(int *table, int unk1, int frameReset) { return returnValue; } -int KyraEngine::changeScene(int facing) { - debugC(9, kDebugLevelMain, "KyraEngine::changeScene(%d)", facing); +int KyraEngine_v1::changeScene(int facing) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::changeScene(%d)", facing); if (queryGameFlag(0xEF)) { if (_currentCharacter->sceneId == 5) return 0; @@ -1142,7 +1142,7 @@ int KyraEngine::changeScene(int facing) { return returnValue; } -void KyraEngine::setCharactersInDefaultScene() { +void KyraEngine_v1::setCharactersInDefaultScene() { static const uint32 defaultSceneTable[][4] = { { 0xFFFF, 0x0004, 0x0003, 0xFFFF }, { 0xFFFF, 0x0022, 0xFFFF, 0x0000 }, @@ -1165,7 +1165,7 @@ void KyraEngine::setCharactersInDefaultScene() { } } -void KyraEngine::setCharactersPositions(int character) { +void KyraEngine_v1::setCharactersPositions(int character) { static uint16 initXPosTable[] = { 0x3200, 0x0024, 0x2230, 0x2F00, 0x0020, 0x002B, 0x00CA, 0x00F0, 0x0082, 0x00A2, 0x0042 @@ -1186,8 +1186,8 @@ void KyraEngine::setCharactersPositions(int character) { #pragma mark - Pathfinder #pragma mark - -int KyraEngine::findWay(int x, int y, int toX, int toY, int *moveTable, int moveTableSize) { - debugC(9, kDebugLevelMain, "KyraEngine::findWay(%d, %d, %d, %d, %p, %d)", x, y, toX, toY, (const void *)moveTable, moveTableSize); +int KyraEngine_v1::findWay(int x, int y, int toX, int toY, int *moveTable, int moveTableSize) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::findWay(%d, %d, %d, %d, %p, %d)", x, y, toX, toY, (const void *)moveTable, moveTableSize); x &= 0xFFFC; toX &= 0xFFFC; y &= 0xFFFE; toY &= 0xFFFE; x = (int16)x; y = (int16)y; toX = (int16)toX; toY = (int16)toY; @@ -1301,8 +1301,8 @@ int KyraEngine::findWay(int x, int y, int toX, int toY, int *moveTable, int move return getMoveTableSize(moveTable); } -int KyraEngine::findSubPath(int x, int y, int toX, int toY, int *moveTable, int start, int end) { - debugC(9, kDebugLevelMain, "KyraEngine::findSubPath(%d, %d, %d, %d, %p, %d, %d)", x, y, toX, toY, (const void *)moveTable, start, end); +int KyraEngine_v1::findSubPath(int x, int y, int toX, int toY, int *moveTable, int start, int end) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::findSubPath(%d, %d, %d, %d, %p, %d, %d)", x, y, toX, toY, (const void *)moveTable, start, end); // only used for debug specific code //static uint16 unkTable[] = { 8, 5 }; static const int8 facingTable1[] = { 7, 0, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 7, 0 }; @@ -1370,8 +1370,8 @@ int KyraEngine::findSubPath(int x, int y, int toX, int toY, int *moveTable, int return 0x7D00; } -int KyraEngine::getFacingFromPointToPoint(int x, int y, int toX, int toY) { - debugC(9, kDebugLevelMain, "KyraEngine::getFacingFromPointToPoint(%d, %d, %d, %d)", x, y, toX, toY); +int KyraEngine_v1::getFacingFromPointToPoint(int x, int y, int toX, int toY) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::getFacingFromPointToPoint(%d, %d, %d, %d)", x, y, toX, toY); static const int facingTable[] = { 1, 0, 1, 2, 3, 4, 3, 2, 7, 0, 7, 6, 5, 4, 5, 6 }; @@ -1413,14 +1413,14 @@ int KyraEngine::getFacingFromPointToPoint(int x, int y, int toX, int toY) { return facingTable[facingEntry]; } -void KyraEngine::changePosTowardsFacing(int &x, int &y, int facing) { - debugC(9, kDebugLevelMain, "KyraEngine::changePosTowardsFacing(%d, %d, %d)", x, y, facing); +void KyraEngine_v1::changePosTowardsFacing(int &x, int &y, int facing) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::changePosTowardsFacing(%d, %d, %d)", x, y, facing); x += _addXPosTable[facing]; y += _addYPosTable[facing]; } -bool KyraEngine::lineIsPassable(int x, int y) { - debugC(9, kDebugLevelMain, "KyraEngine::lineIsPassable(%d, %d)", x, y); +bool KyraEngine_v1::lineIsPassable(int x, int y) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::lineIsPassable(%d, %d)", x, y); if (queryGameFlag(0xEF)) { if (_currentCharacter->sceneId == 5) return true; @@ -1478,8 +1478,8 @@ bool KyraEngine::lineIsPassable(int x, int y) { return true; } -int KyraEngine::getMoveTableSize(int *moveTable) { - debugC(9, kDebugLevelMain, "KyraEngine::getMoveTableSize(%p)", (const void *)moveTable); +int KyraEngine_v1::getMoveTableSize(int *moveTable) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::getMoveTableSize(%p)", (const void *)moveTable); int retValue = 0; if (moveTable[0] == 8) return 0; @@ -1573,8 +1573,8 @@ int KyraEngine::getMoveTableSize(int *moveTable) { return retValue; } -void KyraEngine::setupSceneResource(int sceneId) { - debugC(9, kDebugLevelMain, "KyraEngine::setupSceneResource(%d)", sceneId); +void KyraEngine_v1::setupSceneResource(int sceneId) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::setupSceneResource(%d)", sceneId); if (!_flags.isTalkie) return; diff --git a/engines/kyra/screen.cpp b/engines/kyra/screen.cpp index 641a034eab..0e01801369 100644 --- a/engines/kyra/screen.cpp +++ b/engines/kyra/screen.cpp @@ -382,19 +382,6 @@ void Screen::k2IntroFadeToGrey(int delay) { setPaletteIndex(254, 254, 254, 254); } -void Screen::fadeSpecialPalette(int palIndex, int startIndex, int size, int fadeTime) { - debugC(9, kDebugLevelScreen, "fadeSpecialPalette(%d, %d, %d, %d)", palIndex, startIndex, size, fadeTime); - assert(_vm->palTable1()[palIndex]); - assert(_currentPalette); - uint8 tempPal[768]; - memcpy(tempPal, _currentPalette, 768); - memcpy(&tempPal[startIndex*3], _vm->palTable1()[palIndex], size*3); - fadePalette(tempPal, fadeTime*18); - memcpy(&_currentPalette[startIndex*3], &tempPal[startIndex*3], size*3); - setScreenPalette(_currentPalette); - _system->updateScreen(); -} - void Screen::fadePalette(const uint8 *palData, int delay) { debugC(9, kDebugLevelScreen, "Screen::fadePalette(%p, %d)", (const void *)palData, delay); updateScreen(); diff --git a/engines/kyra/screen.h b/engines/kyra/screen.h index a60cdbd637..355407a330 100644 --- a/engines/kyra/screen.h +++ b/engines/kyra/screen.h @@ -33,7 +33,6 @@ class OSystem; namespace Kyra { class KyraEngine; -class Debugger; struct Rect; struct ScreenDim { @@ -57,7 +56,7 @@ struct Font { }; class Screen { - friend class Debugger; + friend class Debugger_v1; public: enum { @@ -94,7 +93,7 @@ public: }; Screen(KyraEngine *vm, OSystem *system); - ~Screen(); + virtual ~Screen(); bool init(); @@ -136,7 +135,6 @@ public: void k2IntroFadeToGrey(int delay=0x54); - void fadeSpecialPalette(int palIndex, int startIndex, int size, int fadeTime); void fadePalette(const uint8 *palData, int delay); void setPaletteIndex(uint8 index, uint8 red, uint8 green, uint8 blue); @@ -243,7 +241,7 @@ public: uint16 getShapeSize(const uint8 *shp); -private: +protected: uint8 *getPagePtr(int pageNum); void updateDirtyRects(); void updateDirtyRectsOvl(); diff --git a/engines/kyra/screen_v1.cpp b/engines/kyra/screen_v1.cpp new file mode 100644 index 0000000000..dc0fd798fa --- /dev/null +++ b/engines/kyra/screen_v1.cpp @@ -0,0 +1,53 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include "kyra/kyra_v1.h" +#include "kyra/screen_v1.h" + +namespace Kyra { + +Screen_v1::Screen_v1(KyraEngine_v1 *vm, OSystem *system) + : Screen(vm, system) { + _vm = vm; +} + +Screen_v1::~Screen_v1() { +} + +void Screen_v1::fadeSpecialPalette(int palIndex, int startIndex, int size, int fadeTime) { + debugC(9, kDebugLevelScreen, "Screen_v1::fadeSpecialPalette(%d, %d, %d, %d)", palIndex, startIndex, size, fadeTime); + + assert(_vm->palTable1()[palIndex]); + assert(_currentPalette); + uint8 tempPal[768]; + memcpy(tempPal, _currentPalette, 768); + memcpy(&tempPal[startIndex*3], _vm->palTable1()[palIndex], size*3); + fadePalette(tempPal, fadeTime*18); + memcpy(&_currentPalette[startIndex*3], &tempPal[startIndex*3], size*3); + setScreenPalette(_currentPalette); + _system->updateScreen(); +} + +} // end of namespace Kyra diff --git a/engines/kyra/screen_v1.h b/engines/kyra/screen_v1.h new file mode 100644 index 0000000000..988e28bfbf --- /dev/null +++ b/engines/kyra/screen_v1.h @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#ifndef KYRA_SCREEN_V1_H +#define KYRA_SCREEN_V1_H + +#include "kyra/screen.h" + +namespace Kyra { + +class KyraEngine_v1; + +class Screen_v1 : public Screen { +public: + Screen_v1(KyraEngine_v1 *vm, OSystem *system); + virtual ~Screen_v1(); + + void fadeSpecialPalette(int palIndex, int startIndex, int size, int fadeTime); + +protected: + KyraEngine_v1 *_vm; +}; + +} // end of namespace Kyra + +#endif diff --git a/engines/kyra/screen_v2.cpp b/engines/kyra/screen_v2.cpp new file mode 100644 index 0000000000..3e98cdbe5b --- /dev/null +++ b/engines/kyra/screen_v2.cpp @@ -0,0 +1,41 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include "common/stdafx.h" + +#include "kyra/kyra_v2.h" +#include "kyra/screen_v2.h" + +namespace Kyra { + +Screen_v2::Screen_v2(KyraEngine_v2 *vm, OSystem *system) + : Screen(vm, system) { + _vm = vm; +} + +Screen_v2::~Screen_v2() { +} + +} // end of namespace Kyra diff --git a/engines/kyra/screen_v2.h b/engines/kyra/screen_v2.h new file mode 100644 index 0000000000..e45d44d3ff --- /dev/null +++ b/engines/kyra/screen_v2.h @@ -0,0 +1,45 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#ifndef KYRA_SCREEN_V2_H +#define KYRA_SCREEN_V2_H + +#include "kyra/screen.h" + +namespace Kyra { + +class KyraEngine_v2; + +class Screen_v2 : public Screen { +public: + Screen_v2(KyraEngine_v2 *vm, OSystem *system); + virtual ~Screen_v2(); +private: + KyraEngine_v2 *_vm; +}; + +} // End of namespace Kyra + +#endif diff --git a/engines/kyra/script_v1.cpp b/engines/kyra/script_v1.cpp index 18b6c791b9..14edf5fff8 100644 --- a/engines/kyra/script_v1.cpp +++ b/engines/kyra/script_v1.cpp @@ -30,7 +30,7 @@ #include "kyra/screen.h" #include "kyra/sprites.h" #include "kyra/wsamovie.h" -#include "kyra/animator.h" +#include "kyra/animator_v1.h" #include "kyra/text.h" #include "common/system.h" diff --git a/engines/kyra/seqplayer.cpp b/engines/kyra/seqplayer.cpp index ba221bf35a..20a98c66c1 100644 --- a/engines/kyra/seqplayer.cpp +++ b/engines/kyra/seqplayer.cpp @@ -28,7 +28,6 @@ #include "engines/engine.h" -#include "kyra/kyra.h" #include "kyra/resource.h" #include "kyra/screen.h" #include "kyra/sound.h" @@ -41,7 +40,7 @@ namespace Kyra { -SeqPlayer::SeqPlayer(KyraEngine* vm, OSystem* system) { +SeqPlayer::SeqPlayer(KyraEngine_v1 *vm, OSystem *system) { _vm = vm; _system = system; diff --git a/engines/kyra/seqplayer.h b/engines/kyra/seqplayer.h index 0fba0403e4..4636a956e9 100644 --- a/engines/kyra/seqplayer.h +++ b/engines/kyra/seqplayer.h @@ -26,11 +26,13 @@ #ifndef KYRA_SEQPLAYER_H #define KYRA_SEQPLAYER_H +#include "kyra/kyra_v1.h" + namespace Kyra { class SeqPlayer { public: - SeqPlayer(KyraEngine* vm, OSystem* system); + SeqPlayer(KyraEngine_v1 *vm, OSystem *system); ~SeqPlayer(); void setCopyViewOffs(bool offs) { @@ -43,9 +45,8 @@ public: bool playSequence(const uint8 *seqData, bool skipSeq); uint8 *setPanPages(int pageNum, int shape); - protected: - KyraEngine *_vm; + KyraEngine_v1 *_vm; OSystem *_system; Screen *_screen; Sound *_sound; diff --git a/engines/kyra/sequences_v1.cpp b/engines/kyra/sequences_v1.cpp index 8900e68d93..55c294fb1c 100644 --- a/engines/kyra/sequences_v1.cpp +++ b/engines/kyra/sequences_v1.cpp @@ -25,12 +25,12 @@ #include "kyra/kyra.h" #include "kyra/seqplayer.h" -#include "kyra/screen.h" +#include "kyra/screen_v1.h" #include "kyra/resource.h" #include "kyra/sound.h" #include "kyra/sprites.h" #include "kyra/wsamovie.h" -#include "kyra/animator.h" +#include "kyra/animator_v1.h" #include "kyra/text.h" #include "common/events.h" @@ -39,8 +39,8 @@ namespace Kyra { -void KyraEngine::seq_demo() { - debugC(9, kDebugLevelMain, "KyraEngine::seq_demo()"); +void KyraEngine_v1::seq_demo() { + debugC(9, kDebugLevelMain, "KyraEngine_v1::seq_demo()"); snd_playTheme(0, 2); @@ -89,18 +89,18 @@ void KyraEngine::seq_demo() { _sound->haltTrack(); } -void KyraEngine::seq_intro() { - debugC(9, kDebugLevelMain, "KyraEngine::seq_intro()"); +void KyraEngine_v1::seq_intro() { + debugC(9, kDebugLevelMain, "KyraEngine_v1::seq_intro()"); if (_flags.isTalkie) _res->loadPakFile("INTRO.VRM"); static const IntroProc introProcTable[] = { - &KyraEngine::seq_introLogos, - &KyraEngine::seq_introStory, - &KyraEngine::seq_introMalcolmTree, - &KyraEngine::seq_introKallakWriting, - &KyraEngine::seq_introKallakMalcolm + &KyraEngine_v1::seq_introLogos, + &KyraEngine_v1::seq_introStory, + &KyraEngine_v1::seq_introMalcolmTree, + &KyraEngine_v1::seq_introKallakWriting, + &KyraEngine_v1::seq_introKallakMalcolm }; Common::InSaveFile *in; @@ -129,8 +129,8 @@ void KyraEngine::seq_intro() { _res->unloadPakFile("INTRO.VRM"); } -void KyraEngine::seq_introLogos() { - debugC(9, kDebugLevelMain, "KyraEngine::seq_introLogos()"); +void KyraEngine_v1::seq_introLogos() { + debugC(9, kDebugLevelMain, "KyraEngine_v1::seq_introLogos()"); if (_flags.platform == Common::kPlatformFMTowns) { _screen->loadBitmap("LOGO.CPS", 3, 3, _screen->_currentPalette); @@ -231,8 +231,8 @@ void KyraEngine::seq_introLogos() { _seq->playSequence(_seq_Forest, true); } -void KyraEngine::seq_introStory() { - debugC(9, kDebugLevelMain, "KyraEngine::seq_introStory()"); +void KyraEngine_v1::seq_introStory() { + debugC(9, kDebugLevelMain, "KyraEngine_v1::seq_introStory()"); _screen->clearPage(3); _screen->clearPage(0); @@ -278,15 +278,15 @@ void KyraEngine::seq_introStory() { delay(360 * _tickLength); } -void KyraEngine::seq_introMalcolmTree() { - debugC(9, kDebugLevelMain, "KyraEngine::seq_introMalcolmTree()"); +void KyraEngine_v1::seq_introMalcolmTree() { + debugC(9, kDebugLevelMain, "KyraEngine_v1::seq_introMalcolmTree()"); _screen->_curPage = 0; _screen->clearPage(3); _seq->playSequence(_seq_MalcolmTree, true); } -void KyraEngine::seq_introKallakWriting() { - debugC(9, kDebugLevelMain, "KyraEngine::seq_introKallakWriting()"); +void KyraEngine_v1::seq_introKallakWriting() { + debugC(9, kDebugLevelMain, "KyraEngine_v1::seq_introKallakWriting()"); _seq->makeHandShapes(); _screen->setAnimBlockPtr(5060); _screen->_charWidth = -2; @@ -294,13 +294,13 @@ void KyraEngine::seq_introKallakWriting() { _seq->playSequence(_seq_KallakWriting, true); } -void KyraEngine::seq_introKallakMalcolm() { - debugC(9, kDebugLevelMain, "KyraEngine::seq_introKallakMalcolm()"); +void KyraEngine_v1::seq_introKallakMalcolm() { + debugC(9, kDebugLevelMain, "KyraEngine_v1::seq_introKallakMalcolm()"); _screen->clearPage(3); _seq->playSequence(_seq_KallakMalcolm, true); } -void KyraEngine::seq_createAmuletJewel(int jewel, int page, int noSound, int drawOnly) { +void KyraEngine_v1::seq_createAmuletJewel(int jewel, int page, int noSound, int drawOnly) { debugC(9, kDebugLevelMain, "seq_createAmuletJewel(%d, %d, %d, %d)", jewel, page, noSound, drawOnly); static const uint16 specialJewelTable[] = { 0x167, 0x162, 0x15D, 0x158, 0x153, 0xFFFF @@ -360,7 +360,7 @@ void KyraEngine::seq_createAmuletJewel(int jewel, int page, int noSound, int dra setGameFlag(0x55+jewel); } -void KyraEngine::seq_brandonHealing() { +void KyraEngine_v1::seq_brandonHealing() { debugC(9, kDebugLevelMain, "seq_brandonHealing()"); if (!(_deathHandler & 8)) return; @@ -391,7 +391,7 @@ void KyraEngine::seq_brandonHealing() { _screen->showMouse(); } -void KyraEngine::seq_brandonHealing2() { +void KyraEngine_v1::seq_brandonHealing2() { debugC(9, kDebugLevelMain, "seq_brandonHealing2()"); _screen->hideMouse(); checkAmuletAnimFlags(); @@ -415,7 +415,7 @@ void KyraEngine::seq_brandonHealing2() { characterSays(2011, _poisonGone[1], 0, -2); } -void KyraEngine::seq_poisonDeathNow(int now) { +void KyraEngine_v1::seq_poisonDeathNow(int now) { debugC(9, kDebugLevelMain, "seq_poisonDeathNow(%d)", now); if (!(_brandonStatusBit & 1)) return; @@ -436,7 +436,7 @@ void KyraEngine::seq_poisonDeathNow(int now) { } } -void KyraEngine::seq_poisonDeathNowAnim() { +void KyraEngine_v1::seq_poisonDeathNowAnim() { debugC(9, kDebugLevelMain, "seq_poisonDeathNowAnim()"); _screen->hideMouse(); checkAmuletAnimFlags(); @@ -477,7 +477,7 @@ void KyraEngine::seq_poisonDeathNowAnim() { _screen->showMouse(); } -void KyraEngine::seq_playFluteAnimation() { +void KyraEngine_v1::seq_playFluteAnimation() { debugC(9, kDebugLevelMain, "seq_playFluteAnimation()"); _screen->hideMouse(); checkAmuletAnimFlags(); @@ -531,7 +531,7 @@ void KyraEngine::seq_playFluteAnimation() { } } -void KyraEngine::seq_winterScroll1() { +void KyraEngine_v1::seq_winterScroll1() { debugC(9, kDebugLevelMain, "seq_winterScroll1()"); _screen->hideMouse(); checkAmuletAnimFlags(); @@ -612,7 +612,7 @@ void KyraEngine::seq_winterScroll1() { _screen->showMouse(); } -void KyraEngine::seq_winterScroll2() { +void KyraEngine_v1::seq_winterScroll2() { debugC(9, kDebugLevelMain, "seq_winterScroll2()"); _screen->hideMouse(); checkAmuletAnimFlags(); @@ -641,7 +641,7 @@ void KyraEngine::seq_winterScroll2() { _screen->showMouse(); } -void KyraEngine::seq_makeBrandonInv() { +void KyraEngine_v1::seq_makeBrandonInv() { debugC(9, kDebugLevelMain, "seq_makeBrandonInv()"); if (_deathHandler == 8) return; @@ -667,7 +667,7 @@ void KyraEngine::seq_makeBrandonInv() { _screen->showMouse(); } -void KyraEngine::seq_makeBrandonNormal() { +void KyraEngine_v1::seq_makeBrandonNormal() { debugC(9, kDebugLevelMain, "seq_makeBrandonNormal()"); _screen->hideMouse(); _brandonStatusBit |= 0x40; @@ -683,7 +683,7 @@ void KyraEngine::seq_makeBrandonNormal() { _screen->showMouse(); } -void KyraEngine::seq_makeBrandonNormal2() { +void KyraEngine_v1::seq_makeBrandonNormal2() { debugC(9, kDebugLevelMain, "seq_makeBrandonNormal2()"); _screen->hideMouse(); assert(_brandonToWispTable); @@ -709,7 +709,7 @@ void KyraEngine::seq_makeBrandonNormal2() { _screen->showMouse(); } -void KyraEngine::seq_makeBrandonWisp() { +void KyraEngine_v1::seq_makeBrandonWisp() { debugC(9, kDebugLevelMain, "seq_makeBrandonWisp()"); if (_deathHandler == 8) return; @@ -751,7 +751,7 @@ void KyraEngine::seq_makeBrandonWisp() { _screen->showMouse(); } -void KyraEngine::seq_dispelMagicAnimation() { +void KyraEngine_v1::seq_dispelMagicAnimation() { debugC(9, kDebugLevelMain, "seq_dispelMagicAnimation()"); if (_deathHandler == 8) return; @@ -793,7 +793,7 @@ void KyraEngine::seq_dispelMagicAnimation() { _screen->showMouse(); } -void KyraEngine::seq_fillFlaskWithWater(int item, int type) { +void KyraEngine_v1::seq_fillFlaskWithWater(int item, int type) { debugC(9, kDebugLevelMain, "seq_fillFlaskWithWater(%d, %d)", item, type); int newItem = -1; static const uint8 flaskTable1[] = { 0x46, 0x48, 0x4A, 0x4C }; @@ -826,8 +826,8 @@ void KyraEngine::seq_fillFlaskWithWater(int item, int type) { characterSays(voiceEntries[type], _fullFlask[type], 0, -2); } -void KyraEngine::seq_playDrinkPotionAnim(int item, int unk2, int flags) { - debugC(9, kDebugLevelMain, "KyraEngine::seq_playDrinkPotionAnim(%d, %d, %d)", item, unk2, flags); +void KyraEngine_v1::seq_playDrinkPotionAnim(int item, int unk2, int flags) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::seq_playDrinkPotionAnim(%d, %d, %d)", item, unk2, flags); uint8 red, green, blue; switch (item) { @@ -918,8 +918,8 @@ void KyraEngine::seq_playDrinkPotionAnim(int item, int unk2, int flags) { _screen->showMouse(); } -int KyraEngine::seq_playEnd() { - debugC(9, kDebugLevelMain, "KyraEngine::seq_playEnd()"); +int KyraEngine_v1::seq_playEnd() { + debugC(9, kDebugLevelMain, "KyraEngine_v1::seq_playEnd()"); if (_endSequenceSkipFlag) return 0; @@ -1011,8 +1011,8 @@ int KyraEngine::seq_playEnd() { return 0; } -void KyraEngine::seq_brandonToStone() { - debugC(9, kDebugLevelMain, "KyraEngine::seq_brandonToStone()"); +void KyraEngine_v1::seq_brandonToStone() { + debugC(9, kDebugLevelMain, "KyraEngine_v1::seq_brandonToStone()"); _screen->hideMouse(); assert(_brandonStoneTable); setupShapes123(_brandonStoneTable, 14, 0); @@ -1027,8 +1027,8 @@ void KyraEngine::seq_brandonToStone() { _screen->showMouse(); } -void KyraEngine::seq_playEnding() { - debugC(9, kDebugLevelMain, "KyraEngine::seq_playEnding()"); +void KyraEngine_v1::seq_playEnding() { + debugC(9, kDebugLevelMain, "KyraEngine_v1::seq_playEnding()"); if (_quitFlag) return; _screen->hideMouse(); @@ -1051,8 +1051,8 @@ void KyraEngine::seq_playEnding() { seq_playCredits(); } -void KyraEngine::seq_playCredits() { - debugC(9, kDebugLevelMain, "KyraEngine::seq_playCredits()"); +void KyraEngine_v1::seq_playCredits() { + debugC(9, kDebugLevelMain, "KyraEngine_v1::seq_playCredits()"); static const uint8 colorMap[] = { 0, 0, 0xC, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; static const char stringTerms[] = { 0x5, 0xd, 0x0}; static const int numStrings = 250; @@ -1208,13 +1208,13 @@ void KyraEngine::seq_playCredits() { _screen->showMouse(); } -bool KyraEngine::seq_skipSequence() const { - debugC(9, kDebugLevelMain, "KyraEngine::seq_skipSequence()"); +bool KyraEngine_v1::seq_skipSequence() const { + debugC(9, kDebugLevelMain, "KyraEngine_v1::seq_skipSequence()"); return _quitFlag || _abortIntroFlag; } -int KyraEngine::handleMalcolmFlag() { - debugC(9, kDebugLevelMain, "KyraEngine::handleMalcolmFlag()"); +int KyraEngine_v1::handleMalcolmFlag() { + debugC(9, kDebugLevelMain, "KyraEngine_v1::handleMalcolmFlag()"); static uint16 frame = 0; static uint32 timer1 = 0; static uint32 timer2 = 0; @@ -1382,8 +1382,8 @@ int KyraEngine::handleMalcolmFlag() { return 0; } -int KyraEngine::handleBeadState() { - debugC(9, kDebugLevelMain, "KyraEngine::handleBeadState()"); +int KyraEngine_v1::handleBeadState() { + debugC(9, kDebugLevelMain, "KyraEngine_v1::handleBeadState()"); static uint32 timer1 = 0; static uint32 timer2 = 0; static BeadState beadState1 = { -1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; @@ -1602,8 +1602,8 @@ int KyraEngine::handleBeadState() { return 0; } -void KyraEngine::initBeadState(int x, int y, int x2, int y2, int unk, BeadState *ptr) { - debugC(9, kDebugLevelMain, "KyraEngine::initBeadState(%d, %d, %d, %d, %d, %p)", x, y, x2, y2, unk, (const void *)ptr); +void KyraEngine_v1::initBeadState(int x, int y, int x2, int y2, int unk, BeadState *ptr) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::initBeadState(%d, %d, %d, %d, %d, %p)", x, y, x2, y2, unk, (const void *)ptr); ptr->unk9 = unk; int xDiff = x2 - x; int yDiff = y2 - y; @@ -1636,8 +1636,8 @@ void KyraEngine::initBeadState(int x, int y, int x2, int y2, int unk, BeadState ptr->unk8 = unk2; } -int KyraEngine::processBead(int x, int y, int &x2, int &y2, BeadState *ptr) { - debugC(9, kDebugLevelMain, "KyraEngine::processBead(%d, %d, %p, %p, %p)", x, y, (const void *)&x2, (const void *)&y2, (const void *)ptr); +int KyraEngine_v1::processBead(int x, int y, int &x2, int &y2, BeadState *ptr) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::processBead(%d, %d, %p, %p, %p)", x, y, (const void *)&x2, (const void *)&y2, (const void *)ptr); if (x == ptr->dstX && y == ptr->dstY) return 1; @@ -1673,8 +1673,8 @@ int KyraEngine::processBead(int x, int y, int &x2, int &y2, BeadState *ptr) { return 0; } -void KyraEngine::setupPanPages() { - debugC(9, kDebugLevelMain, "KyraEngine::setupPanPages()"); +void KyraEngine_v1::setupPanPages() { + debugC(9, kDebugLevelMain, "KyraEngine_v1::setupPanPages()"); _screen->loadBitmap("BEAD.CPS", 3, 3, 0); if (_flags.platform == Common::kPlatformMacintosh || _flags.platform == Common::kPlatformAmiga) { int pageBackUp = _screen->_curPage; @@ -1702,8 +1702,8 @@ void KyraEngine::setupPanPages() { } } -void KyraEngine::freePanPages() { - debugC(9, kDebugLevelMain, "KyraEngine::freePanPages()"); +void KyraEngine_v1::freePanPages() { + debugC(9, kDebugLevelMain, "KyraEngine_v1::freePanPages()"); delete _endSequenceBackUpRect; _endSequenceBackUpRect = 0; for (int i = 0; i <= 19; ++i) { @@ -1712,8 +1712,8 @@ void KyraEngine::freePanPages() { } } -void KyraEngine::closeFinalWsa() { - debugC(9, kDebugLevelMain, "KyraEngine::closeFinalWsa()"); +void KyraEngine_v1::closeFinalWsa() { + debugC(9, kDebugLevelMain, "KyraEngine_v1::closeFinalWsa()"); delete _finalA; _finalA = 0; delete _finalB; @@ -1724,7 +1724,7 @@ void KyraEngine::closeFinalWsa() { _endSequenceNeedLoading = 1; } -void KyraEngine::updateKyragemFading() { +void KyraEngine_v1::updateKyragemFading() { static const uint8 kyraGemPalette[0x28] = { 0x3F, 0x3B, 0x38, 0x34, 0x32, 0x2F, 0x2C, 0x29, 0x25, 0x22, 0x1F, 0x1C, 0x19, 0x16, 0x12, 0x0F, 0x0C, 0x0A, 0x06, 0x03, @@ -1794,8 +1794,8 @@ void KyraEngine::updateKyragemFading() { _kyragemFadingState.timerCount = _system->getMillis() + 120 * _tickLength; } -void KyraEngine::drawJewelPress(int jewel, int drawSpecial) { - debugC(9, kDebugLevelMain, "KyraEngine::drawJewelPress(%d, %d)", jewel, drawSpecial); +void KyraEngine_v1::drawJewelPress(int jewel, int drawSpecial) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::drawJewelPress(%d, %d)", jewel, drawSpecial); _screen->hideMouse(); int shape = 0; @@ -1819,8 +1819,8 @@ void KyraEngine::drawJewelPress(int jewel, int drawSpecial) { _screen->showMouse(); } -void KyraEngine::drawJewelsFadeOutStart() { - debugC(9, kDebugLevelMain, "KyraEngine::drawJewelsFadeOutStart()"); +void KyraEngine_v1::drawJewelsFadeOutStart() { + debugC(9, kDebugLevelMain, "KyraEngine_v1::drawJewelsFadeOutStart()"); static const uint16 jewelTable1[] = { 0x164, 0x15F, 0x15A, 0x155, 0x150, 0xFFFF }; static const uint16 jewelTable2[] = { 0x163, 0x15E, 0x159, 0x154, 0x14F, 0xFFFF }; static const uint16 jewelTable3[] = { 0x166, 0x160, 0x15C, 0x157, 0x152, 0xFFFF }; @@ -1839,8 +1839,8 @@ void KyraEngine::drawJewelsFadeOutStart() { } } -void KyraEngine::drawJewelsFadeOutEnd(int jewel) { - debugC(9, kDebugLevelMain, "KyraEngine::drawJewelsFadeOutEnd(%d)", jewel); +void KyraEngine_v1::drawJewelsFadeOutEnd(int jewel) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::drawJewelsFadeOutEnd(%d)", jewel); static const uint16 jewelTable[] = { 0x153, 0x158, 0x15D, 0x162, 0x148, 0xFFFF }; int newDelay = 0; diff --git a/engines/kyra/sound.cpp b/engines/kyra/sound.cpp index 1d2ff2e512..562754b9c5 100644 --- a/engines/kyra/sound.cpp +++ b/engines/kyra/sound.cpp @@ -434,117 +434,6 @@ void SoundMidiPC::beginFadeOut() { _fadeStartTime = _vm->_system->getMillis(); } -#pragma mark - - -bool KyraEngine::speechEnabled() { - return _flags.isTalkie && (_configVoice == 1 || _configVoice == 2); -} - -bool KyraEngine::textEnabled() { - return !_flags.isTalkie || (_configVoice == 0 || _configVoice == 2); -} - -void KyraEngine::snd_playTheme(int file, int track) { - debugC(9, kDebugLevelMain | kDebugLevelSound, "KyraEngine::snd_playTheme(%d)", file); - _curSfxFile = _curMusicTheme = file; - _sound->loadSoundFile(_curMusicTheme); - _sound->playTrack(track); -} - -void KyraEngine::snd_playSoundEffect(int track) { - debugC(9, kDebugLevelMain | kDebugLevelSound, "KyraEngine::snd_playSoundEffect(%d)", track); - if (_flags.platform == Common::kPlatformFMTowns && track == 49) { - snd_playWanderScoreViaMap(56, 1); - return; - } - _sound->playSoundEffect(track); -} - -void KyraEngine::snd_playWanderScoreViaMap(int command, int restart) { - debugC(9, kDebugLevelMain | kDebugLevelSound, "KyraEngine::snd_playWanderScoreViaMap(%d, %d)", command, restart); - if (restart) - _lastMusicCommand = -1; - - if (_flags.platform == Common::kPlatformFMTowns) { - if (command == 1) { - _sound->beginFadeOut(); - } else if (command >= 35 && command <= 38) { - snd_playSoundEffect(command-20); - } else if (command >= 2) { - if (_lastMusicCommand != command) { - // the original does -2 here we handle this inside _sound->playTrack() - _sound->playTrack(command); - } - } else { - _sound->haltTrack(); - } - } else { - static const int8 soundTable[] = { - -1, 0, -1, 1, 0, 3, 0, 2, - 0, 4, 1, 2, 1, 3, 1, 4, - 1, 92, 1, 6, 1, 7, 2, 2, - 2, 3, 2, 4, 2, 5, 2, 6, - 2, 7, 3, 3, 3, 4, 1, 8, - 1, 9, 4, 2, 4, 3, 4, 4, - 4, 5, 4, 6, 4, 7, 4, 8, - 1, 11, 1, 12, 1, 14, 1, 13, - 4, 9, 5, 12, 6, 2, 6, 6, - 6, 7, 6, 8, 6, 9, 6, 3, - 6, 4, 6, 5, 7, 2, 7, 3, - 7, 4, 7, 5, 7, 6, 7, 7, - 7, 8, 7, 9, 8, 2, 8, 3, - 8, 4, 8, 5, 6, 11, 5, 11 - }; - //if (!_disableSound) { - // XXX - //} - assert(command*2+1 < ARRAYSIZE(soundTable)); - if (_curMusicTheme != soundTable[command*2]+1) { - if (soundTable[command*2] != -1) - snd_playTheme(soundTable[command*2]+1); - } - - if (command != 1) { - if (_lastMusicCommand != command) { - _sound->haltTrack(); - _sound->playTrack(soundTable[command*2+1]); - } - } else { - _sound->beginFadeOut(); - } - } - - _lastMusicCommand = command; -} - -void KyraEngine::snd_playVoiceFile(int id) { - debugC(9, kDebugLevelMain | kDebugLevelSound, "KyraEngine::snd_playVoiceFile(%d)", id); - char vocFile[9]; - assert(id >= 0 && id < 9999); - sprintf(vocFile, "%03d", id); - _sound->voicePlay(vocFile); -} - -void KyraEngine::snd_voiceWaitForFinish(bool ingame) { - debugC(9, kDebugLevelMain | kDebugLevelSound, "KyraEngine::snd_voiceWaitForFinish(%d)", ingame); - while (_sound->voiceIsPlaying() && !_skipFlag) { - if (ingame) - delay(10, true); - else - _system->delayMillis(10); - } -} - -void KyraEngine::snd_stopVoice() { - debugC(9, kDebugLevelMain | kDebugLevelSound, "KyraEngine::snd_stopVoice()"); - _sound->voiceStop(); -} - -bool KyraEngine::snd_voiceIsPlaying() { - debugC(9, kDebugLevelMain | kDebugLevelSound, "KyraEngine::snd_voiceIsPlaying()"); - return _sound->voiceIsPlaying(); -} - // static res const Sound::SpeechCodecs Sound::_supportedCodes[] = { diff --git a/engines/kyra/sound_v1.cpp b/engines/kyra/sound_v1.cpp new file mode 100644 index 0000000000..3ea86189b2 --- /dev/null +++ b/engines/kyra/sound_v1.cpp @@ -0,0 +1,140 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include "kyra/sound.h" +#include "kyra/kyra_v1.h" + +namespace Kyra { + +bool KyraEngine_v1::speechEnabled() { + return _flags.isTalkie && (_configVoice == 1 || _configVoice == 2); +} + +bool KyraEngine_v1::textEnabled() { + return !_flags.isTalkie || (_configVoice == 0 || _configVoice == 2); +} + +void KyraEngine_v1::snd_playTheme(int file, int track) { + debugC(9, kDebugLevelMain | kDebugLevelSound, "KyraEngine_v1::snd_playTheme(%d)", file); + _curSfxFile = _curMusicTheme = file; + _sound->loadSoundFile(_curMusicTheme); + _sound->playTrack(track); +} + +void KyraEngine_v1::snd_playSoundEffect(int track) { + debugC(9, kDebugLevelMain | kDebugLevelSound, "KyraEngine_v1::snd_playSoundEffect(%d)", track); + if (_flags.platform == Common::kPlatformFMTowns && track == 49) { + snd_playWanderScoreViaMap(56, 1); + return; + } + _sound->playSoundEffect(track); +} + +void KyraEngine_v1::snd_playWanderScoreViaMap(int command, int restart) { + debugC(9, kDebugLevelMain | kDebugLevelSound, "KyraEngine_v1::snd_playWanderScoreViaMap(%d, %d)", command, restart); + if (restart) + _lastMusicCommand = -1; + + if (_flags.platform == Common::kPlatformFMTowns) { + if (command == 1) { + _sound->beginFadeOut(); + } else if (command >= 35 && command <= 38) { + snd_playSoundEffect(command-20); + } else if (command >= 2) { + if (_lastMusicCommand != command) { + // the original does -2 here we handle this inside _sound->playTrack() + _sound->playTrack(command); + } + } else { + _sound->haltTrack(); + } + } else { + static const int8 soundTable[] = { + -1, 0, -1, 1, 0, 3, 0, 2, + 0, 4, 1, 2, 1, 3, 1, 4, + 1, 92, 1, 6, 1, 7, 2, 2, + 2, 3, 2, 4, 2, 5, 2, 6, + 2, 7, 3, 3, 3, 4, 1, 8, + 1, 9, 4, 2, 4, 3, 4, 4, + 4, 5, 4, 6, 4, 7, 4, 8, + 1, 11, 1, 12, 1, 14, 1, 13, + 4, 9, 5, 12, 6, 2, 6, 6, + 6, 7, 6, 8, 6, 9, 6, 3, + 6, 4, 6, 5, 7, 2, 7, 3, + 7, 4, 7, 5, 7, 6, 7, 7, + 7, 8, 7, 9, 8, 2, 8, 3, + 8, 4, 8, 5, 6, 11, 5, 11 + }; + //if (!_disableSound) { + // XXX + //} + assert(command*2+1 < ARRAYSIZE(soundTable)); + if (_curMusicTheme != soundTable[command*2]+1) { + if (soundTable[command*2] != -1) + snd_playTheme(soundTable[command*2]+1); + } + + if (command != 1) { + if (_lastMusicCommand != command) { + _sound->haltTrack(); + _sound->playTrack(soundTable[command*2+1]); + } + } else { + _sound->beginFadeOut(); + } + } + + _lastMusicCommand = command; +} + +void KyraEngine_v1::snd_playVoiceFile(int id) { + debugC(9, kDebugLevelMain | kDebugLevelSound, "KyraEngine_v1::snd_playVoiceFile(%d)", id); + char vocFile[9]; + assert(id >= 0 && id < 9999); + sprintf(vocFile, "%03d", id); + _sound->voicePlay(vocFile); +} + +void KyraEngine_v1::snd_voiceWaitForFinish(bool ingame) { + debugC(9, kDebugLevelMain | kDebugLevelSound, "KyraEngine_v1::snd_voiceWaitForFinish(%d)", ingame); + while (_sound->voiceIsPlaying() && !_skipFlag) { + if (ingame) + delay(10, true); + else + _system->delayMillis(10); + } +} + +void KyraEngine_v1::snd_stopVoice() { + debugC(9, kDebugLevelMain | kDebugLevelSound, "KyraEngine_v1::snd_stopVoice()"); + _sound->voiceStop(); +} + +bool KyraEngine_v1::snd_voiceIsPlaying() { + debugC(9, kDebugLevelMain | kDebugLevelSound, "KyraEngine_v1::snd_voiceIsPlaying()"); + return _sound->voiceIsPlaying(); +} + +} // end of namespace Kyra diff --git a/engines/kyra/sprites.cpp b/engines/kyra/sprites.cpp index 0a3f243df2..1a2c7f6146 100644 --- a/engines/kyra/sprites.cpp +++ b/engines/kyra/sprites.cpp @@ -29,14 +29,14 @@ #include "common/util.h" #include "common/system.h" #include "kyra/screen.h" -#include "kyra/kyra.h" +#include "kyra/kyra_v1.h" #include "kyra/sprites.h" #include "kyra/resource.h" -#include "kyra/animator.h" +#include "kyra/animator_v1.h" namespace Kyra { -Sprites::Sprites(KyraEngine *vm, OSystem *system) { +Sprites::Sprites(KyraEngine_v1 *vm, OSystem *system) { _vm = vm; _res = vm->resource(); _screen = vm->screen(); diff --git a/engines/kyra/sprites.h b/engines/kyra/sprites.h index 179942d519..255d878635 100644 --- a/engines/kyra/sprites.h +++ b/engines/kyra/sprites.h @@ -26,6 +26,8 @@ #ifndef KYRA_SPRITES_H #define KYRA_SPRITES_H +#include "kyra/kyra_v1.h" + namespace Kyra { #define MAX_NUM_ANIMS 11 @@ -61,10 +63,11 @@ struct Anim { bool disable; }; +class KyraEngine_v1; + class Sprites { public: - - Sprites(KyraEngine *vm, OSystem *system); + Sprites(KyraEngine_v1 *vm, OSystem *system); ~Sprites(); void updateSceneAnims(); @@ -83,7 +86,7 @@ public: protected: void freeSceneShapes(); - KyraEngine *_vm; + KyraEngine_v1 *_vm; Resource *_res; OSystem *_system; Screen *_screen; diff --git a/engines/kyra/staticres.cpp b/engines/kyra/staticres.cpp index 247cf90705..68e5401481 100644 --- a/engines/kyra/staticres.cpp +++ b/engines/kyra/staticres.cpp @@ -27,6 +27,7 @@ #include "common/endian.h" #include "common/md5.h" #include "kyra/kyra.h" +#include "kyra/kyra_v1.h" #include "kyra/kyra_v2.h" #include "kyra/kyra_v3.h" #include "kyra/screen.h" @@ -617,7 +618,7 @@ uint8 *StaticResource::getFile(const char *name, int &size) { #pragma mark - -void KyraEngine::initStaticResource() { +void KyraEngine_v1::initStaticResource() { int temp = 0; _seq_Forest = _staticres->loadRawData(kForestSeq, temp); _seq_KallakWriting = _staticres->loadRawData(kKallakWritingSeq, temp); @@ -708,7 +709,7 @@ void KyraEngine::initStaticResource() { } } -void KyraEngine::loadMouseShapes() { +void KyraEngine_v1::loadMouseShapes() { _screen->loadBitmap("MOUSE.CPS", 3, 3, 0); _screen->_curPage = 2; _shapes[0] = _screen->encodeShape(0, 0, 8, 10, 0); @@ -724,7 +725,7 @@ void KyraEngine::loadMouseShapes() { _screen->setShapePages(5, 3); } -void KyraEngine::loadCharacterShapes() { +void KyraEngine_v1::loadCharacterShapes() { int curImage = 0xFF; int videoPage = _screen->_curPage; _screen->_curPage = 2; @@ -745,7 +746,7 @@ void KyraEngine::loadCharacterShapes() { _screen->_curPage = videoPage; } -void KyraEngine::loadSpecialEffectShapes() { +void KyraEngine_v1::loadSpecialEffectShapes() { _screen->loadBitmap("EFFECTS.CPS", 3, 3, 0); _screen->_curPage = 2; @@ -763,7 +764,7 @@ void KyraEngine::loadSpecialEffectShapes() { _shapes[currShape] = _screen->encodeShape((currShape-201) * 16, 106, 16, 16, 1); } -void KyraEngine::loadItems() { +void KyraEngine_v1::loadItems() { int shape; _screen->loadBitmap("JEWELS3.CPS", 3, 3, 0); @@ -817,7 +818,7 @@ void KyraEngine::loadItems() { delete[] fileData; } -void KyraEngine::loadButtonShapes() { +void KyraEngine_v1::loadButtonShapes() { _screen->loadBitmap("BUTTONS2.CPS", 3, 3, 0); _screen->_curPage = 2; _scrollUpButton.process0PtrShape = _screen->encodeShape(0, 0, 24, 14, 1); @@ -829,7 +830,7 @@ void KyraEngine::loadButtonShapes() { _screen->_curPage = 0; } -void KyraEngine::loadMainScreen(int page) { +void KyraEngine_v1::loadMainScreen(int page) { _screen->clearPage(page); if (_flags.lang == Common::EN_ANY && !_flags.isTalkie && (_flags.platform == Common::kPlatformPC || _flags.platform == Common::kPlatformAmiga)) @@ -878,7 +879,7 @@ const ScreenDim Screen::_screenDimTableK3[] = { const int Screen::_screenDimTableCountK3 = ARRAYSIZE(_screenDimTableK3); -const char *KyraEngine::_soundFiles[] = { +const char *KyraEngine_v1::_soundFiles[] = { "INTRO", "KYRA1A", "KYRA1B", @@ -891,9 +892,9 @@ const char *KyraEngine::_soundFiles[] = { "KYRAMISC" }; -const int KyraEngine::_soundFilesCount = ARRAYSIZE(KyraEngine::_soundFiles); +const int KyraEngine_v1::_soundFilesCount = ARRAYSIZE(KyraEngine_v1::_soundFiles); -const char *KyraEngine::_soundFilesTowns[] = { +const char *KyraEngine_v1::_soundFilesTowns[] = { "TW_INTRO.SFX", "TW_SCEN1.SFX", "TW_SCEN2.SFX", @@ -902,49 +903,49 @@ const char *KyraEngine::_soundFilesTowns[] = { "TW_SCEN5.SFX", }; -const int KyraEngine::_soundFilesTownsCount = ARRAYSIZE(KyraEngine::_soundFilesTowns); +const int KyraEngine_v1::_soundFilesTownsCount = ARRAYSIZE(KyraEngine_v1::_soundFilesTowns); -const int8 KyraEngine::_charXPosTable[] = { +const int8 KyraEngine_v1::_charXPosTable[] = { 0, 4, 4, 4, 0, -4, -4, -4 }; -const int8 KyraEngine::_addXPosTable[] = { +const int8 KyraEngine_v1::_addXPosTable[] = { 4, 4, 0, -4, -4, -4, 0, 4 }; -const int8 KyraEngine::_charYPosTable[] = { +const int8 KyraEngine_v1::_charYPosTable[] = { -2, -2, 0, 2, 2, 2, 0, -2 }; -const int8 KyraEngine::_addYPosTable[] = { +const int8 KyraEngine_v1::_addYPosTable[] = { 0, -2, -2, -2, 0, 2, 2, 2 }; -const uint16 KyraEngine::_itemPosX[] = { +const uint16 KyraEngine_v1::_itemPosX[] = { 95, 115, 135, 155, 175, 95, 115, 135, 155, 175 }; -const uint8 KyraEngine::_itemPosY[] = { +const uint8 KyraEngine_v1::_itemPosY[] = { 160, 160, 160, 160, 160, 181, 181, 181, 181, 181 }; -void KyraEngine::setupButtonData() { +void KyraEngine_v1::setupButtonData() { static Button buttonData[] = { - { 0, 0x02, /*XXX,*/0, 0, 0, /*XXX,*/ 0x0400, 0, 0, 0, 0, 0, 0, 0, 0x05D, 0x9E, 0x13, 0x14, /*XXX,*/ 0, &KyraEngine::buttonInventoryCallback/*, XXX*/ }, - { 0, 0x01, /*XXX,*/1, 1, 1, /*XXX,*/ 0x0487, 0, 0, 0, 0, 0, 0, 0, 0x009, 0xA4, 0x36, 0x1E, /*XXX,*/ 0, &KyraEngine::buttonMenuCallback/*, XXX*/ }, - { 0, 0x03, /*XXX,*/0, 0, 0, /*XXX,*/ 0x0400, 0, 0, 0, 0, 0, 0, 0, 0x071, 0x9E, 0x13, 0x14, /*XXX,*/ 0, &KyraEngine::buttonInventoryCallback/*, XXX*/ }, - { 0, 0x04, /*XXX,*/0, 0, 0, /*XXX,*/ 0x0400, 0, 0, 0, 0, 0, 0, 0, 0x085, 0x9E, 0x13, 0x14, /*XXX,*/ 0, &KyraEngine::buttonInventoryCallback/*, XXX*/ }, - { 0, 0x05, /*XXX,*/0, 0, 0, /*XXX,*/ 0x0400, 0, 0, 0, 0, 0, 0, 0, 0x099, 0x9E, 0x13, 0x14, /*XXX,*/ 0, &KyraEngine::buttonInventoryCallback/*, XXX*/ }, - { 0, 0x06, /*XXX,*/0, 0, 0, /*XXX,*/ 0x0400, 0, 0, 0, 0, 0, 0, 0, 0x0AD, 0x9E, 0x13, 0x14, /*XXX,*/ 0, &KyraEngine::buttonInventoryCallback/*, XXX*/ }, - { 0, 0x07, /*XXX,*/0, 0, 0, /*XXX,*/ 0x0400, 0, 0, 0, 0, 0, 0, 0, 0x05D, 0xB3, 0x13, 0x14, /*XXX,*/ 0, &KyraEngine::buttonInventoryCallback/*, XXX*/ }, - { 0, 0x08, /*XXX,*/0, 0, 0, /*XXX,*/ 0x0400, 0, 0, 0, 0, 0, 0, 0, 0x071, 0xB3, 0x13, 0x14, /*XXX,*/ 0, &KyraEngine::buttonInventoryCallback/*, XXX*/ }, - { 0, 0x09, /*XXX,*/0, 0, 0, /*XXX,*/ 0x0400, 0, 0, 0, 0, 0, 0, 0, 0x085, 0xB3, 0x13, 0x14, /*XXX,*/ 0, &KyraEngine::buttonInventoryCallback/*, XXX*/ }, - { 0, 0x0A, /*XXX,*/0, 0, 0, /*XXX,*/ 0x0400, 0, 0, 0, 0, 0, 0, 0, 0x099, 0xB3, 0x13, 0x14, /*XXX,*/ 0, &KyraEngine::buttonInventoryCallback/*, XXX*/ }, - { 0, 0x0B, /*XXX,*/0, 0, 0, /*XXX,*/ 0x0400, 0, 0, 0, 0, 0, 0, 0, 0x0AD, 0xB3, 0x13, 0x14, /*XXX,*/ 0, &KyraEngine::buttonInventoryCallback/*, XXX*/ }, - { 0, 0x15, /*XXX,*/1, 1, 1, /*XXX,*/ 0x0487, 0, 0, 0, 0, 0, 0, 0, 0x0FD, 0x9C, 0x1A, 0x12, /*XXX,*/ 0, &KyraEngine::buttonAmuletCallback/*, XXX*/ }, - { 0, 0x16, /*XXX,*/1, 1, 1, /*XXX,*/ 0x0487, 0, 0, 0, 0, 0, 0, 0, 0x0E7, 0xAA, 0x1A, 0x12, /*XXX,*/ 0, &KyraEngine::buttonAmuletCallback/*, XXX*/ }, - { 0, 0x17, /*XXX,*/1, 1, 1, /*XXX,*/ 0x0487, 0, 0, 0, 0, 0, 0, 0, 0x0FD, 0xB5, 0x1A, 0x12, /*XXX,*/ 0, &KyraEngine::buttonAmuletCallback/*, XXX*/ }, - { 0, 0x18, /*XXX,*/1, 1, 1, /*XXX,*/ 0x0487, 0, 0, 0, 0, 0, 0, 0, 0x113, 0xAA, 0x1A, 0x12, /*XXX,*/ 0, &KyraEngine::buttonAmuletCallback/*, XXX*/ } + { 0, 0x02, /*XXX,*/0, 0, 0, /*XXX,*/ 0x0400, 0, 0, 0, 0, 0, 0, 0, 0x05D, 0x9E, 0x13, 0x14, /*XXX,*/ 0, &KyraEngine_v1::buttonInventoryCallback/*, XXX*/ }, + { 0, 0x01, /*XXX,*/1, 1, 1, /*XXX,*/ 0x0487, 0, 0, 0, 0, 0, 0, 0, 0x009, 0xA4, 0x36, 0x1E, /*XXX,*/ 0, &KyraEngine_v1::buttonMenuCallback/*, XXX*/ }, + { 0, 0x03, /*XXX,*/0, 0, 0, /*XXX,*/ 0x0400, 0, 0, 0, 0, 0, 0, 0, 0x071, 0x9E, 0x13, 0x14, /*XXX,*/ 0, &KyraEngine_v1::buttonInventoryCallback/*, XXX*/ }, + { 0, 0x04, /*XXX,*/0, 0, 0, /*XXX,*/ 0x0400, 0, 0, 0, 0, 0, 0, 0, 0x085, 0x9E, 0x13, 0x14, /*XXX,*/ 0, &KyraEngine_v1::buttonInventoryCallback/*, XXX*/ }, + { 0, 0x05, /*XXX,*/0, 0, 0, /*XXX,*/ 0x0400, 0, 0, 0, 0, 0, 0, 0, 0x099, 0x9E, 0x13, 0x14, /*XXX,*/ 0, &KyraEngine_v1::buttonInventoryCallback/*, XXX*/ }, + { 0, 0x06, /*XXX,*/0, 0, 0, /*XXX,*/ 0x0400, 0, 0, 0, 0, 0, 0, 0, 0x0AD, 0x9E, 0x13, 0x14, /*XXX,*/ 0, &KyraEngine_v1::buttonInventoryCallback/*, XXX*/ }, + { 0, 0x07, /*XXX,*/0, 0, 0, /*XXX,*/ 0x0400, 0, 0, 0, 0, 0, 0, 0, 0x05D, 0xB3, 0x13, 0x14, /*XXX,*/ 0, &KyraEngine_v1::buttonInventoryCallback/*, XXX*/ }, + { 0, 0x08, /*XXX,*/0, 0, 0, /*XXX,*/ 0x0400, 0, 0, 0, 0, 0, 0, 0, 0x071, 0xB3, 0x13, 0x14, /*XXX,*/ 0, &KyraEngine_v1::buttonInventoryCallback/*, XXX*/ }, + { 0, 0x09, /*XXX,*/0, 0, 0, /*XXX,*/ 0x0400, 0, 0, 0, 0, 0, 0, 0, 0x085, 0xB3, 0x13, 0x14, /*XXX,*/ 0, &KyraEngine_v1::buttonInventoryCallback/*, XXX*/ }, + { 0, 0x0A, /*XXX,*/0, 0, 0, /*XXX,*/ 0x0400, 0, 0, 0, 0, 0, 0, 0, 0x099, 0xB3, 0x13, 0x14, /*XXX,*/ 0, &KyraEngine_v1::buttonInventoryCallback/*, XXX*/ }, + { 0, 0x0B, /*XXX,*/0, 0, 0, /*XXX,*/ 0x0400, 0, 0, 0, 0, 0, 0, 0, 0x0AD, 0xB3, 0x13, 0x14, /*XXX,*/ 0, &KyraEngine_v1::buttonInventoryCallback/*, XXX*/ }, + { 0, 0x15, /*XXX,*/1, 1, 1, /*XXX,*/ 0x0487, 0, 0, 0, 0, 0, 0, 0, 0x0FD, 0x9C, 0x1A, 0x12, /*XXX,*/ 0, &KyraEngine_v1::buttonAmuletCallback/*, XXX*/ }, + { 0, 0x16, /*XXX,*/1, 1, 1, /*XXX,*/ 0x0487, 0, 0, 0, 0, 0, 0, 0, 0x0E7, 0xAA, 0x1A, 0x12, /*XXX,*/ 0, &KyraEngine_v1::buttonAmuletCallback/*, XXX*/ }, + { 0, 0x17, /*XXX,*/1, 1, 1, /*XXX,*/ 0x0487, 0, 0, 0, 0, 0, 0, 0, 0x0FD, 0xB5, 0x1A, 0x12, /*XXX,*/ 0, &KyraEngine_v1::buttonAmuletCallback/*, XXX*/ }, + { 0, 0x18, /*XXX,*/1, 1, 1, /*XXX,*/ 0x0487, 0, 0, 0, 0, 0, 0, 0, 0x113, 0xAA, 0x1A, 0x12, /*XXX,*/ 0, &KyraEngine_v1::buttonAmuletCallback/*, XXX*/ } }; static Button *buttonDataListPtr[] = { @@ -969,10 +970,10 @@ void KyraEngine::setupButtonData() { _buttonDataListPtr = buttonDataListPtr; } -Button KyraEngine::_scrollUpButton = {0, 0x12, 1, 1, 1, 0x483, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x18, 0x0f, 0, 0}; -Button KyraEngine::_scrollDownButton = {0, 0x13, 1, 1, 1, 0x483, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x18, 0x0f, 0, 0}; +Button KyraEngine_v1::_scrollUpButton = {0, 0x12, 1, 1, 1, 0x483, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x18, 0x0f, 0, 0}; +Button KyraEngine_v1::_scrollDownButton = {0, 0x13, 1, 1, 1, 0x483, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x18, 0x0f, 0, 0}; -Button KyraEngine::_menuButtonData[] = { +Button KyraEngine_v1::_menuButtonData[] = { { 0, 0x0c, /*XXX,*/1, 1, 1, /*XXX,*/ 0x487, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*XXX,*/ 0, 0 /*, XXX*/ }, { 0, 0x0d, /*XXX,*/1, 1, 1, /*XXX,*/ 0x487, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*XXX,*/ 0, 0 /*, XXX*/ }, { 0, 0x0e, /*XXX,*/1, 1, 1, /*XXX,*/ 0x487, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*XXX,*/ 0, 0 /*, XXX*/ }, @@ -981,33 +982,33 @@ Button KyraEngine::_menuButtonData[] = { { 0, 0x11, /*XXX,*/1, 1, 1, /*XXX,*/ 0x487, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*XXX,*/ 0, 0 /*, XXX*/ } }; -void KyraEngine::setupMenu() { +void KyraEngine_v1::setupMenu() { static Menu menu[] = { { -1, -1, 208, 136, 248, 249, 250, 0, 251, -1, 8, 0, 5, -1, -1, -1, -1, { {1, 0, 0, 0, -1, -1, 30, 148, 15, 252, 253, 24, 0, - 248, 249, 250, &KyraEngine::gui_loadGameMenu, -1, 0, 0, 0, 0, 0}, + 248, 249, 250, &KyraEngine_v1::gui_loadGameMenu, -1, 0, 0, 0, 0, 0}, {1, 0, 0, 0, -1, -1, 47, 148, 15, 252, 253, 24, 0, - 248, 249, 250, &KyraEngine::gui_saveGameMenu, -1, 0, 0, 0, 0, 0}, + 248, 249, 250, &KyraEngine_v1::gui_saveGameMenu, -1, 0, 0, 0, 0, 0}, {1, 0, 0, 0, -1, -1, 64, 148, 15, 252, 253, 24, 0, - 248, 249, 250, &KyraEngine::gui_gameControlsMenu, -1, 0, 0, 0, 0, 0}, + 248, 249, 250, &KyraEngine_v1::gui_gameControlsMenu, -1, 0, 0, 0, 0, 0}, {1, 0, 0, 0, -1, -1, 81, 148, 15, 252, 253, 24, 0, - 248, 249, 250, &KyraEngine::gui_quitPlaying, -1, 0, 0, 0, 0, 0}, + 248, 249, 250, &KyraEngine_v1::gui_quitPlaying, -1, 0, 0, 0, 0, 0}, {1, 0, 0, 0, 86, 0, 110, 92, 15, 252, 253, -1, 255, - 248, 249, 250, &KyraEngine::gui_resumeGame, -1, 0, 0, 0, 0, 0} + 248, 249, 250, &KyraEngine_v1::gui_resumeGame, -1, 0, 0, 0, 0, 0} } }, { -1, -1, 288, 56, 248, 249, 250, 0, 254,-1, 8, 0, 2, -1, -1, -1, -1, { {1, 0, 0, 0, 24, 0, 30, 72, 15, 252, 253, -1, 255, - 248, 249, 250, &KyraEngine::gui_quitConfirmYes, -1, 0, 0, 0, 0, 0}, + 248, 249, 250, &KyraEngine_v1::gui_quitConfirmYes, -1, 0, 0, 0, 0, 0}, {1, 0, 0, 0, 192, 0, 30, 72, 15, 252, 253, -1, 255, - 248, 249, 250, &KyraEngine::gui_quitConfirmNo, -1, 0, 0, 0, 0, 0} + 248, 249, 250, &KyraEngine_v1::gui_quitConfirmNo, -1, 0, 0, 0, 0, 0} } }, { -1, -1, 288, 160, 248, 249, 250, 0, 251, -1, 8, 0, 6, 132, 22, 132, 124, @@ -1028,46 +1029,46 @@ void KyraEngine::setupMenu() { 248, 249, 250, 0, -1, 0, 0, 0, 0, 0}, {1, 0, 0, 0, 184, 0, 134, 88, 15, 252, 253, -1, 255, - 248, 249, 250, &KyraEngine::gui_cancelSubMenu, -1, 0, 0, 0, 0, 0}, + 248, 249, 250, &KyraEngine_v1::gui_cancelSubMenu, -1, 0, 0, 0, 0, 0}, } }, { -1, -1, 288, 67, 248, 249, 250, 0, 251, -1, 8, 0, 3, -1, -1, -1, -1, { {1, 0, 0, 0, 24, 0, 44, 72, 15, 252, 253, -1, 255, - 248, 249, 250, &KyraEngine::gui_savegameConfirm, -1, 0, 0, 0, 0, 0}, + 248, 249, 250, &KyraEngine_v1::gui_savegameConfirm, -1, 0, 0, 0, 0, 0}, {1, 0, 0, 0, 192, 0, 44, 72, 15, 252, 253, -1, 255, - 248, 249, 250, &KyraEngine::gui_cancelSubMenu, -1, 0, 0, 0, 0, 0} + 248, 249, 250, &KyraEngine_v1::gui_cancelSubMenu, -1, 0, 0, 0, 0, 0} } }, { -1, -1, 208, 76, 248, 249, 250, 0, 251, -1, 8, 0, 2, -1, -1, -1, -1, { {1, 0, 0, 0, -1, -1, 30, 148, 15, 252, 253, 24, 0, - 248, 249, 250, &KyraEngine::gui_loadGameMenu, -1, 0, 0, 0, 0, 0}, + 248, 249, 250, &KyraEngine_v1::gui_loadGameMenu, -1, 0, 0, 0, 0, 0}, {1, 0, 0, 0, -1, -1, 47, 148, 15, 252, 253, 24, 0, - 248, 249, 250, &KyraEngine::gui_quitPlaying, -1, 0, 0, 0, 0, 0} + 248, 249, 250, &KyraEngine_v1::gui_quitPlaying, -1, 0, 0, 0, 0, 0} } }, { -1, -1, 208, 153, 248, 249, 250, 0, 251, -1, 8, 0, 6, -1, -1, -1, -1, { {1, 0, 0, 0, 110, 0, 30, 64, 15, 252, 253, 5, 0, - 248, 249, 250, &KyraEngine::gui_controlsChangeMusic, -1, 0, 34, 32, 0, 0}, + 248, 249, 250, &KyraEngine_v1::gui_controlsChangeMusic, -1, 0, 34, 32, 0, 0}, {1, 0, 0, 0, 110, 0, 47, 64, 15, 252, 253, 5, 0, - 248, 249, 250, &KyraEngine::gui_controlsChangeSounds, -1, 0, 34, 49, 0, 0}, + 248, 249, 250, &KyraEngine_v1::gui_controlsChangeSounds, -1, 0, 34, 49, 0, 0}, {1, 0, 0, 0, 110, 0, 64, 64, 15, 252, 253, 5, 0, - 248, 249, 250, &KyraEngine::gui_controlsChangeWalk, -1, 0, 34, 66, 0, 0}, + 248, 249, 250, &KyraEngine_v1::gui_controlsChangeWalk, -1, 0, 34, 66, 0, 0}, {1, 0, 0, 0, 110, 0, 81, 64, 15, 252, 253, 5, 0, 248, 249, 250, 0, -1, 0, 34, 83, 0, 0 }, {1, 0, 0, 0, 110, 0, 98, 64, 15, 252, 253, 5, 0, - 248, 249, 250, &KyraEngine::gui_controlsChangeText, -1, 0, 34, 100, 0, 0 }, + 248, 249, 250, &KyraEngine_v1::gui_controlsChangeText, -1, 0, 34, 100, 0, 0 }, {1, 0, 0, 0, 64, 0, 127, 92, 15, 252, 253, -1, 255, - 248, 249, 250, &KyraEngine::gui_controlsApply, -1, -0, 0, 0, 0, 0} + 248, 249, 250, &KyraEngine_v1::gui_controlsApply, -1, -0, 0, 0, 0, 0} } } }; @@ -1075,31 +1076,31 @@ void KyraEngine::setupMenu() { _menu = menu; } -const uint8 KyraEngine::_magicMouseItemStartFrame[] = { +const uint8 KyraEngine_v1::_magicMouseItemStartFrame[] = { 0xAD, 0xB7, 0xBE, 0x00 }; -const uint8 KyraEngine::_magicMouseItemEndFrame[] = { +const uint8 KyraEngine_v1::_magicMouseItemEndFrame[] = { 0xB1, 0xB9, 0xC2, 0x00 }; -const uint8 KyraEngine::_magicMouseItemStartFrame2[] = { +const uint8 KyraEngine_v1::_magicMouseItemStartFrame2[] = { 0xB2, 0xBA, 0xC3, 0x00 }; -const uint8 KyraEngine::_magicMouseItemEndFrame2[] = { +const uint8 KyraEngine_v1::_magicMouseItemEndFrame2[] = { 0xB6, 0xBD, 0xC8, 0x00 }; -const uint16 KyraEngine::_amuletX[] = { 231, 275, 253, 253 }; -const uint16 KyraEngine::_amuletY[] = { 170, 170, 159, 181 }; +const uint16 KyraEngine_v1::_amuletX[] = { 231, 275, 253, 253 }; +const uint16 KyraEngine_v1::_amuletY[] = { 170, 170, 159, 181 }; -const uint16 KyraEngine::_amuletX2[] = { 0x000, 0x0FD, 0x0E7, 0x0FD, 0x113, 0x000 }; -const uint16 KyraEngine::_amuletY2[] = { 0x000, 0x09F, 0x0AA, 0x0B5, 0x0AA, 0x000 }; +const uint16 KyraEngine_v1::_amuletX2[] = { 0x000, 0x0FD, 0x0E7, 0x0FD, 0x113, 0x000 }; +const uint16 KyraEngine_v1::_amuletY2[] = { 0x000, 0x09F, 0x0AA, 0x0B5, 0x0AA, 0x000 }; // Kyra 2 and 3 main menu -const char *KyraEngine::_mainMenuStrings[] = { +const char *KyraEngine_v2::_mainMenuStrings[] = { "Start a new game", "Introduction", "Load a game", diff --git a/engines/kyra/text.cpp b/engines/kyra/text.cpp index 58ce3c9d1e..e62410ca19 100644 --- a/engines/kyra/text.cpp +++ b/engines/kyra/text.cpp @@ -28,8 +28,6 @@ #include "kyra/kyra.h" #include "kyra/screen.h" #include "kyra/text.h" -#include "kyra/animator.h" -#include "kyra/sprites.h" #include "common/events.h" #include "common/system.h" @@ -37,369 +35,6 @@ namespace Kyra { -void KyraEngine::waitForChatToFinish(int vocFile, int16 chatDuration, const char *chatStr, uint8 charNum) { - debugC(9, kDebugLevelMain, "KyraEngine::waitForChatToFinish(%i, %s, %i)", chatDuration, chatStr, charNum); - bool hasUpdatedNPCs = false; - bool runLoop = true; - bool drawText = textEnabled(); - uint8 currPage; - Common::Event event; - - //while (towns_isEscKeyPressed() ) - //towns_getKey(); - - uint32 timeToEnd = strlen(chatStr) * 8 * _tickLength + _system->getMillis(); - - if (_configVoice == 0 && chatDuration != -1) { - switch (_configTextspeed) { - case 0: - chatDuration *= 2; - break; - case 2: - chatDuration /= 4; - break; - case 3: - chatDuration = -1; - break; - } - } - - if (chatDuration != -1) - chatDuration *= _tickLength; - - if (vocFile != -1) { - snd_voiceWaitForFinish(); - snd_playVoiceFile(vocFile); - } - - disableTimer(14); - disableTimer(18); - disableTimer(19); - - uint32 timeAtStart = _system->getMillis(); - uint32 loopStart; - while (runLoop) { - loopStart = _system->getMillis(); - if (_currentCharacter->sceneId == 210) - if (seq_playEnd()) - break; - - if (_system->getMillis() > timeToEnd && !hasUpdatedNPCs) { - hasUpdatedNPCs = true; - disableTimer(15); - _currHeadShape = 4; - _animator->animRefreshNPC(0); - _animator->animRefreshNPC(_talkingCharNum); - - if (_charSayUnk2 != -1) { - _animator->sprites()[_charSayUnk2].active = 0; - _sprites->_anims[_charSayUnk2].play = false; - _charSayUnk2 = -1; - } - } - - updateGameTimers(); - _sprites->updateSceneAnims(); - _animator->restoreAllObjectBackgrounds(); - _animator->preserveAnyChangedBackgrounds(); - _animator->prepDrawAllObjects(); - - if (drawText) { - currPage = _screen->_curPage; - _screen->_curPage = 2; - _text->printCharacterText(chatStr, charNum, _characterList[charNum].x1); - _animator->_updateScreen = true; - _screen->_curPage = currPage; - } - - _animator->copyChangedObjectsForward(0); - updateTextFade(); - - if ((chatDuration < (int16)(_system->getMillis() - timeAtStart)) && chatDuration != -1 && (!drawText || !snd_voiceIsPlaying())) - break; - - uint32 nextTime = loopStart + _tickLength; - - while (_system->getMillis() < nextTime) { - while (_eventMan->pollEvent(event)) { - switch (event.type) { - case Common::EVENT_KEYDOWN: - if (event.kbd.keycode == '.') - _skipFlag = true; - break; - case Common::EVENT_QUIT: - quitGame(); - runLoop = false; - break; - case Common::EVENT_LBUTTONDOWN: - runLoop = false; - break; - default: - break; - } - } - - if (nextTime - _system->getMillis() >= 10) { - _system->delayMillis(10); - _system->updateScreen(); - } - } - - if (_skipFlag) - runLoop = false; - } - - snd_voiceWaitForFinish(); - snd_stopVoice(); - - enableTimer(14); - enableTimer(15); - enableTimer(18); - enableTimer(19); - //clearKyrandiaButtonIO(); -} - -void KyraEngine::endCharacterChat(int8 charNum, int16 convoInitialized) { - _charSayUnk3 = -1; - - if (charNum > 4 && charNum < 11) { - //TODO: weird _game_inventory stuff here - warning("STUB: endCharacterChat() for high charnums"); - } - - if (convoInitialized != 0) { - _talkingCharNum = -1; - if (_currentCharacter->currentAnimFrame != 88) - _currentCharacter->currentAnimFrame = 7; - _animator->animRefreshNPC(0); - _animator->updateAllObjectShapes(); - } -} - -void KyraEngine::restoreChatPartnerAnimFrame(int8 charNum) { - _talkingCharNum = -1; - - if (charNum > 0 && charNum < 5) { - _characterList[charNum].currentAnimFrame = _currentChatPartnerBackupFrame; - _animator->animRefreshNPC(charNum); - } - - if (_currentCharacter->currentAnimFrame != 88) - _currentCharacter->currentAnimFrame = 7; - - _animator->animRefreshNPC(0); - _animator->updateAllObjectShapes(); -} - -void KyraEngine::backupChatPartnerAnimFrame(int8 charNum) { - _talkingCharNum = 0; - - if (charNum < 5 && charNum > 0) - _currentChatPartnerBackupFrame = _characterList[charNum].currentAnimFrame; - - if (_currentCharacter->currentAnimFrame != 88) { - _currentCharacter->currentAnimFrame = 16; - if (_scaleMode != 0) - _currentCharacter->currentAnimFrame = 7; - } - - _animator->animRefreshNPC(0); - _animator->updateAllObjectShapes(); -} - -int8 KyraEngine::getChatPartnerNum() { - uint8 sceneTable[] = {0x2, 0x5, 0x2D, 0x7, 0x1B, 0x8, 0x22, 0x9, 0x30, 0x0A}; - int pos = 0; - int partner = -1; - - for (int i = 1; i < 6; i++) { - if (_currentCharacter->sceneId == sceneTable[pos]) { - partner = sceneTable[pos+1]; - break; - } - pos += 2; - } - - for (int i = 1; i < 5; i++) { - if (_characterList[i].sceneId == _currentCharacter->sceneId) { - partner = i; - break; - } - } - return partner; -} - -int KyraEngine::initCharacterChat(int8 charNum) { - int returnValue = 0; - - if (_talkingCharNum == -1) { - returnValue = 1; - _talkingCharNum = 0; - - if (_currentCharacter->currentAnimFrame != 88) { - _currentCharacter->currentAnimFrame = 16; - if (_scaleMode != 0) - _currentCharacter->currentAnimFrame = 7; - } - - _animator->animRefreshNPC(0); - _animator->updateAllObjectShapes(); - } - - _charSayUnk2 = -1; - _animator->flagAllObjectsForBkgdChange(); - _animator->restoreAllObjectBackgrounds(); - - if (charNum > 4 && charNum < 11) { - // TODO: Fill in weird _game_inventory stuff here - warning("STUB: initCharacterChat() for high charnums"); - } - - _animator->flagAllObjectsForRefresh(); - _animator->flagAllObjectsForBkgdChange(); - _animator->preserveAnyChangedBackgrounds(); - _charSayUnk3 = charNum; - - return returnValue; -} - -void KyraEngine::characterSays(int vocFile, const char *chatStr, int8 charNum, int8 chatDuration) { - debugC(9, kDebugLevelMain, "KyraEngine::characterSays('%s', %i, %d)", chatStr, charNum, chatDuration); - uint8 startAnimFrames[] = { 0x10, 0x32, 0x56, 0x0, 0x0, 0x0 }; - - uint16 chatTicks; - int16 convoInitialized; - int8 chatPartnerNum; - - if (_currentCharacter->sceneId == 210) - return; - - convoInitialized = initCharacterChat(charNum); - chatPartnerNum = getChatPartnerNum(); - - if (chatPartnerNum >= 0 && chatPartnerNum < 5) - backupChatPartnerAnimFrame(chatPartnerNum); - - if (charNum < 5) { - _characterList[charNum].currentAnimFrame = startAnimFrames[charNum]; - _charSayUnk3 = charNum; - _talkingCharNum = charNum; - _animator->animRefreshNPC(charNum); - } - - char *processedString = _text->preprocessString(chatStr); - int lineNum = _text->buildMessageSubstrings(processedString); - - int16 yPos = _characterList[charNum].y1; - yPos -= ((_scaleTable[yPos] * _characterList[charNum].height) >> 8); - yPos -= 8; - yPos -= lineNum * 10; - - if (yPos < 11) - yPos = 11; - - if (yPos > 100) - yPos = 100; - - _text->_talkMessageY = yPos; - _text->_talkMessageH = lineNum * 10; - - if (textEnabled()) { - _animator->restoreAllObjectBackgrounds(); - - _screen->copyRegion(12, _text->_talkMessageY, 12, 136, 308, _text->_talkMessageH, 2, 2); - _screen->hideMouse(); - - _text->printCharacterText(processedString, charNum, _characterList[charNum].x1); - _screen->showMouse(); - } - - if (chatDuration == -2) - chatTicks = strlen(processedString) * 9; - else - chatTicks = chatDuration; - - if (!speechEnabled()) - vocFile = -1; - waitForChatToFinish(vocFile, chatTicks, chatStr, charNum); - - if (textEnabled()) { - _animator->restoreAllObjectBackgrounds(); - - _screen->copyRegion(12, 136, 12, _text->_talkMessageY, 308, _text->_talkMessageH, 2, 2); - _animator->preserveAllBackgrounds(); - _animator->prepDrawAllObjects(); - _screen->hideMouse(); - - _screen->copyRegion(12, _text->_talkMessageY, 12, _text->_talkMessageY, 308, _text->_talkMessageH, 2, 0); - _screen->showMouse(); - _animator->flagAllObjectsForRefresh(); - _animator->copyChangedObjectsForward(0); - } - - if (chatPartnerNum != -1 && chatPartnerNum < 5) - restoreChatPartnerAnimFrame(chatPartnerNum); - - endCharacterChat(charNum, convoInitialized); -} - -void KyraEngine::drawSentenceCommand(const char *sentence, int color) { - debugC(9, kDebugLevelMain, "KyraEngine::drawSentenceCommand('%s', %i)", sentence, color); - _screen->hideMouse(); - _screen->fillRect(8, 143, 311, 152, 12); - - if (_startSentencePalIndex != color || _fadeText != false) { - _currSentenceColor[0] = _screen->_currentPalette[765] = _screen->_currentPalette[color*3]; - _currSentenceColor[1] = _screen->_currentPalette[766] = _screen->_currentPalette[color*3+1]; - _currSentenceColor[2] = _screen->_currentPalette[767] = _screen->_currentPalette[color*3+2]; - - _screen->setScreenPalette(_screen->_currentPalette); - _startSentencePalIndex = 0; - } - - _text->printText(sentence, 8, 143, 0xFF, 12, 0); - _screen->showMouse(); - setTextFadeTimerCountdown(15); - _fadeText = false; -} - -void KyraEngine::updateSentenceCommand(const char *str1, const char *str2, int color) { - debugC(9, kDebugLevelMain, "KyraEngine::updateSentenceCommand('%s', '%s', %i)", str1, str2, color); - char sentenceCommand[500]; - strncpy(sentenceCommand, str1, 500); - if (str2) - strncat(sentenceCommand, str2, 500 - strlen(sentenceCommand)); - - drawSentenceCommand(sentenceCommand, color); - _screen->updateScreen(); -} - -void KyraEngine::updateTextFade() { - debugC(9, kDebugLevelMain, "KyraEngine::updateTextFade()"); - if (!_fadeText) - return; - - bool finished = false; - for (int i = 0; i < 3; i++) - if (_currSentenceColor[i] > 4) - _currSentenceColor[i] -= 4; - else - if (_currSentenceColor[i]) { - _currSentenceColor[i] = 0; - finished = true; - } - - _screen->_currentPalette[765] = _currSentenceColor[0]; - _screen->_currentPalette[766] = _currSentenceColor[1]; - _screen->_currentPalette[767] = _currSentenceColor[2]; - _screen->setScreenPalette(_screen->_currentPalette); - - if (finished) { - _fadeText = false; - _startSentencePalIndex = -1; - } -} - TextDisplayer::TextDisplayer(KyraEngine *vm, Screen *screen) { _screen = screen; _vm = vm; diff --git a/engines/kyra/text_v1.cpp b/engines/kyra/text_v1.cpp new file mode 100644 index 0000000000..3ca986adf8 --- /dev/null +++ b/engines/kyra/text_v1.cpp @@ -0,0 +1,397 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include "kyra/kyra_v1.h" +#include "kyra/screen_v1.h" +#include "kyra/text.h" +#include "kyra/animator_v1.h" +#include "kyra/sprites.h" + +namespace Kyra { + +void KyraEngine_v1::waitForChatToFinish(int vocFile, int16 chatDuration, const char *chatStr, uint8 charNum) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::waitForChatToFinish(%i, %s, %i)", chatDuration, chatStr, charNum); + bool hasUpdatedNPCs = false; + bool runLoop = true; + bool drawText = textEnabled(); + uint8 currPage; + Common::Event event; + + //while (towns_isEscKeyPressed() ) + //towns_getKey(); + + uint32 timeToEnd = strlen(chatStr) * 8 * _tickLength + _system->getMillis(); + + if (_configVoice == 0 && chatDuration != -1) { + switch (_configTextspeed) { + case 0: + chatDuration *= 2; + break; + case 2: + chatDuration /= 4; + break; + case 3: + chatDuration = -1; + break; + } + } + + if (chatDuration != -1) + chatDuration *= _tickLength; + + if (vocFile != -1) { + snd_voiceWaitForFinish(); + snd_playVoiceFile(vocFile); + } + + disableTimer(14); + disableTimer(18); + disableTimer(19); + + uint32 timeAtStart = _system->getMillis(); + uint32 loopStart; + while (runLoop) { + loopStart = _system->getMillis(); + if (_currentCharacter->sceneId == 210) + if (seq_playEnd()) + break; + + if (_system->getMillis() > timeToEnd && !hasUpdatedNPCs) { + hasUpdatedNPCs = true; + disableTimer(15); + _currHeadShape = 4; + _animator->animRefreshNPC(0); + _animator->animRefreshNPC(_talkingCharNum); + + if (_charSayUnk2 != -1) { + _animator->sprites()[_charSayUnk2].active = 0; + _sprites->_anims[_charSayUnk2].play = false; + _charSayUnk2 = -1; + } + } + + updateGameTimers(); + _sprites->updateSceneAnims(); + _animator->restoreAllObjectBackgrounds(); + _animator->preserveAnyChangedBackgrounds(); + _animator->prepDrawAllObjects(); + + if (drawText) { + currPage = _screen->_curPage; + _screen->_curPage = 2; + _text->printCharacterText(chatStr, charNum, _characterList[charNum].x1); + _animator->_updateScreen = true; + _screen->_curPage = currPage; + } + + _animator->copyChangedObjectsForward(0); + updateTextFade(); + + if ((chatDuration < (int16)(_system->getMillis() - timeAtStart)) && chatDuration != -1 && (!drawText || !snd_voiceIsPlaying())) + break; + + uint32 nextTime = loopStart + _tickLength; + + while (_system->getMillis() < nextTime) { + while (_eventMan->pollEvent(event)) { + switch (event.type) { + case Common::EVENT_KEYDOWN: + if (event.kbd.keycode == '.') + _skipFlag = true; + break; + case Common::EVENT_QUIT: + quitGame(); + runLoop = false; + break; + case Common::EVENT_LBUTTONDOWN: + runLoop = false; + break; + default: + break; + } + } + + if (nextTime - _system->getMillis() >= 10) { + _system->delayMillis(10); + _system->updateScreen(); + } + } + + if (_skipFlag) + runLoop = false; + } + + snd_voiceWaitForFinish(); + snd_stopVoice(); + + enableTimer(14); + enableTimer(15); + enableTimer(18); + enableTimer(19); + //clearKyrandiaButtonIO(); +} + +void KyraEngine_v1::endCharacterChat(int8 charNum, int16 convoInitialized) { + _charSayUnk3 = -1; + + if (charNum > 4 && charNum < 11) { + //TODO: weird _game_inventory stuff here + warning("STUB: endCharacterChat() for high charnums"); + } + + if (convoInitialized != 0) { + _talkingCharNum = -1; + if (_currentCharacter->currentAnimFrame != 88) + _currentCharacter->currentAnimFrame = 7; + _animator->animRefreshNPC(0); + _animator->updateAllObjectShapes(); + } +} + +void KyraEngine_v1::restoreChatPartnerAnimFrame(int8 charNum) { + _talkingCharNum = -1; + + if (charNum > 0 && charNum < 5) { + _characterList[charNum].currentAnimFrame = _currentChatPartnerBackupFrame; + _animator->animRefreshNPC(charNum); + } + + if (_currentCharacter->currentAnimFrame != 88) + _currentCharacter->currentAnimFrame = 7; + + _animator->animRefreshNPC(0); + _animator->updateAllObjectShapes(); +} + +void KyraEngine_v1::backupChatPartnerAnimFrame(int8 charNum) { + _talkingCharNum = 0; + + if (charNum < 5 && charNum > 0) + _currentChatPartnerBackupFrame = _characterList[charNum].currentAnimFrame; + + if (_currentCharacter->currentAnimFrame != 88) { + _currentCharacter->currentAnimFrame = 16; + if (_scaleMode != 0) + _currentCharacter->currentAnimFrame = 7; + } + + _animator->animRefreshNPC(0); + _animator->updateAllObjectShapes(); +} + +int8 KyraEngine_v1::getChatPartnerNum() { + uint8 sceneTable[] = {0x2, 0x5, 0x2D, 0x7, 0x1B, 0x8, 0x22, 0x9, 0x30, 0x0A}; + int pos = 0; + int partner = -1; + + for (int i = 1; i < 6; i++) { + if (_currentCharacter->sceneId == sceneTable[pos]) { + partner = sceneTable[pos+1]; + break; + } + pos += 2; + } + + for (int i = 1; i < 5; i++) { + if (_characterList[i].sceneId == _currentCharacter->sceneId) { + partner = i; + break; + } + } + return partner; +} + +int KyraEngine_v1::initCharacterChat(int8 charNum) { + int returnValue = 0; + + if (_talkingCharNum == -1) { + returnValue = 1; + _talkingCharNum = 0; + + if (_currentCharacter->currentAnimFrame != 88) { + _currentCharacter->currentAnimFrame = 16; + if (_scaleMode != 0) + _currentCharacter->currentAnimFrame = 7; + } + + _animator->animRefreshNPC(0); + _animator->updateAllObjectShapes(); + } + + _charSayUnk2 = -1; + _animator->flagAllObjectsForBkgdChange(); + _animator->restoreAllObjectBackgrounds(); + + if (charNum > 4 && charNum < 11) { + // TODO: Fill in weird _game_inventory stuff here + warning("STUB: initCharacterChat() for high charnums"); + } + + _animator->flagAllObjectsForRefresh(); + _animator->flagAllObjectsForBkgdChange(); + _animator->preserveAnyChangedBackgrounds(); + _charSayUnk3 = charNum; + + return returnValue; +} + +void KyraEngine_v1::characterSays(int vocFile, const char *chatStr, int8 charNum, int8 chatDuration) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::characterSays('%s', %i, %d)", chatStr, charNum, chatDuration); + uint8 startAnimFrames[] = { 0x10, 0x32, 0x56, 0x0, 0x0, 0x0 }; + + uint16 chatTicks; + int16 convoInitialized; + int8 chatPartnerNum; + + if (_currentCharacter->sceneId == 210) + return; + + convoInitialized = initCharacterChat(charNum); + chatPartnerNum = getChatPartnerNum(); + + if (chatPartnerNum >= 0 && chatPartnerNum < 5) + backupChatPartnerAnimFrame(chatPartnerNum); + + if (charNum < 5) { + _characterList[charNum].currentAnimFrame = startAnimFrames[charNum]; + _charSayUnk3 = charNum; + _talkingCharNum = charNum; + _animator->animRefreshNPC(charNum); + } + + char *processedString = _text->preprocessString(chatStr); + int lineNum = _text->buildMessageSubstrings(processedString); + + int16 yPos = _characterList[charNum].y1; + yPos -= ((_scaleTable[yPos] * _characterList[charNum].height) >> 8); + yPos -= 8; + yPos -= lineNum * 10; + + if (yPos < 11) + yPos = 11; + + if (yPos > 100) + yPos = 100; + + _text->_talkMessageY = yPos; + _text->_talkMessageH = lineNum * 10; + + if (textEnabled()) { + _animator->restoreAllObjectBackgrounds(); + + _screen->copyRegion(12, _text->_talkMessageY, 12, 136, 308, _text->_talkMessageH, 2, 2); + _screen->hideMouse(); + + _text->printCharacterText(processedString, charNum, _characterList[charNum].x1); + _screen->showMouse(); + } + + if (chatDuration == -2) + chatTicks = strlen(processedString) * 9; + else + chatTicks = chatDuration; + + if (!speechEnabled()) + vocFile = -1; + waitForChatToFinish(vocFile, chatTicks, chatStr, charNum); + + if (textEnabled()) { + _animator->restoreAllObjectBackgrounds(); + + _screen->copyRegion(12, 136, 12, _text->_talkMessageY, 308, _text->_talkMessageH, 2, 2); + _animator->preserveAllBackgrounds(); + _animator->prepDrawAllObjects(); + _screen->hideMouse(); + + _screen->copyRegion(12, _text->_talkMessageY, 12, _text->_talkMessageY, 308, _text->_talkMessageH, 2, 0); + _screen->showMouse(); + _animator->flagAllObjectsForRefresh(); + _animator->copyChangedObjectsForward(0); + } + + if (chatPartnerNum != -1 && chatPartnerNum < 5) + restoreChatPartnerAnimFrame(chatPartnerNum); + + endCharacterChat(charNum, convoInitialized); +} + +void KyraEngine_v1::drawSentenceCommand(const char *sentence, int color) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::drawSentenceCommand('%s', %i)", sentence, color); + _screen->hideMouse(); + _screen->fillRect(8, 143, 311, 152, 12); + + if (_startSentencePalIndex != color || _fadeText != false) { + _currSentenceColor[0] = _screen->_currentPalette[765] = _screen->_currentPalette[color*3]; + _currSentenceColor[1] = _screen->_currentPalette[766] = _screen->_currentPalette[color*3+1]; + _currSentenceColor[2] = _screen->_currentPalette[767] = _screen->_currentPalette[color*3+2]; + + _screen->setScreenPalette(_screen->_currentPalette); + _startSentencePalIndex = 0; + } + + _text->printText(sentence, 8, 143, 0xFF, 12, 0); + _screen->showMouse(); + setTextFadeTimerCountdown(15); + _fadeText = false; +} + +void KyraEngine_v1::updateSentenceCommand(const char *str1, const char *str2, int color) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::updateSentenceCommand('%s', '%s', %i)", str1, str2, color); + char sentenceCommand[500]; + strncpy(sentenceCommand, str1, 500); + if (str2) + strncat(sentenceCommand, str2, 500 - strlen(sentenceCommand)); + + drawSentenceCommand(sentenceCommand, color); + _screen->updateScreen(); +} + +void KyraEngine_v1::updateTextFade() { + debugC(9, kDebugLevelMain, "KyraEngine_v1::updateTextFade()"); + if (!_fadeText) + return; + + bool finished = false; + for (int i = 0; i < 3; i++) + if (_currSentenceColor[i] > 4) + _currSentenceColor[i] -= 4; + else + if (_currSentenceColor[i]) { + _currSentenceColor[i] = 0; + finished = true; + } + + _screen->_currentPalette[765] = _currSentenceColor[0]; + _screen->_currentPalette[766] = _currSentenceColor[1]; + _screen->_currentPalette[767] = _currSentenceColor[2]; + _screen->setScreenPalette(_screen->_currentPalette); + + if (finished) { + _fadeText = false; + _startSentencePalIndex = -1; + } +} + +} // end of namespace Kyra diff --git a/engines/kyra/timer_v1.cpp b/engines/kyra/timer_v1.cpp index a35b701697..0b5184fe5a 100644 --- a/engines/kyra/timer_v1.cpp +++ b/engines/kyra/timer_v1.cpp @@ -23,15 +23,15 @@ * */ -#include "kyra/kyra.h" +#include "kyra/kyra_v1.h" #include "kyra/screen.h" -#include "kyra/animator.h" +#include "kyra/animator_v1.h" #include "common/system.h" namespace Kyra { -void KyraEngine::setupTimers() { - debugC(9, kDebugLevelMain, "KyraEngine::setupTimers()"); +void KyraEngine_v1::setupTimers() { + debugC(9, kDebugLevelMain, "KyraEngine_v1::setupTimers()"); memset(_timers, 0, sizeof(_timers)); for (int i = 0; i < 34; i++) @@ -40,12 +40,12 @@ void KyraEngine::setupTimers() { _timers[0].func = _timers[1].func = _timers[2].func = _timers[3].func = _timers[4].func = 0; //Unused. _timers[5].func = _timers[6].func = _timers[7].func = _timers[8].func = _timers[9].func = 0; //_nullsub51; _timers[10].func = _timers[11].func = _timers[12].func = _timers[13].func = 0; //_nullsub50; - _timers[14].func = &KyraEngine::timerCheckAnimFlag2; //_nullsub52; - _timers[15].func = &KyraEngine::timerUpdateHeadAnims; //_nullsub48; - _timers[16].func = &KyraEngine::timerSetFlags1; //_nullsub47; + _timers[14].func = &KyraEngine_v1::timerCheckAnimFlag2; //_nullsub52; + _timers[15].func = &KyraEngine_v1::timerUpdateHeadAnims; //_nullsub48; + _timers[16].func = &KyraEngine_v1::timerSetFlags1; //_nullsub47; _timers[17].func = 0; //sub_15120; - _timers[18].func = &KyraEngine::timerCheckAnimFlag1; //_nullsub53; - _timers[19].func = &KyraEngine::timerRedrawAmulet; //_nullsub54; + _timers[18].func = &KyraEngine_v1::timerCheckAnimFlag1; //_nullsub53; + _timers[19].func = &KyraEngine_v1::timerRedrawAmulet; //_nullsub54; _timers[20].func = 0; //offset _timerDummy1 _timers[21].func = 0; //sub_1517C; _timers[22].func = 0; //offset _timerDummy2 @@ -57,9 +57,9 @@ void KyraEngine::setupTimers() { _timers[28].func = 0; //offset _timerDummy6 _timers[29].func = 0; //offset _timerDummy7, _timers[30].func = 0; //offset _timerDummy8, - _timers[31].func = &KyraEngine::timerFadeText; //sub_151F8; - _timers[32].func = &KyraEngine::updateAnimFlag1; //_nullsub61; - _timers[33].func = &KyraEngine::updateAnimFlag2; //_nullsub62; + _timers[31].func = &KyraEngine_v1::timerFadeText; //sub_151F8; + _timers[32].func = &KyraEngine_v1::updateAnimFlag1; //_nullsub61; + _timers[33].func = &KyraEngine_v1::updateAnimFlag2; //_nullsub62; _timers[0].countdown = _timers[1].countdown = _timers[2].countdown = _timers[3].countdown = _timers[4].countdown = -1; _timers[5].countdown = 5; @@ -84,8 +84,8 @@ void KyraEngine::setupTimers() { _timers[33].countdown = 3; } -void KyraEngine::updateGameTimers() { - debugC(9, kDebugLevelMain, "KyraEngine::updateGameTimers()"); +void KyraEngine_v1::updateGameTimers() { + debugC(9, kDebugLevelMain, "KyraEngine_v1::updateGameTimers()"); if (_system->getMillis() < _timerNextRun) return; @@ -106,23 +106,23 @@ void KyraEngine::updateGameTimers() { } } -void KyraEngine::clearNextEventTickCount() { - debugC(9, kDebugLevelMain, "KyraEngine::clearNextEventTickCount()"); +void KyraEngine_v1::clearNextEventTickCount() { + debugC(9, kDebugLevelMain, "KyraEngine_v1::clearNextEventTickCount()"); _timerNextRun = 0; } -void KyraEngine::setTimerDelay(uint8 timer, int32 countdown) { - debugC(9, kDebugLevelMain, "KyraEngine::setTimerDelay(%i, %d)", timer, countdown); +void KyraEngine_v1::setTimerDelay(uint8 timer, int32 countdown) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::setTimerDelay(%i, %d)", timer, countdown); _timers[timer].countdown = countdown; } -int16 KyraEngine::getTimerDelay(uint8 timer) { - debugC(9, kDebugLevelMain, "KyraEngine::getTimerDelay(%i)", timer); +int16 KyraEngine_v1::getTimerDelay(uint8 timer) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::getTimerDelay(%i)", timer); return _timers[timer].countdown; } -void KyraEngine::setTimerCountdown(uint8 timer, int32 countdown) { - debugC(9, kDebugLevelMain, "KyraEngine::setTimerCountdown(%i, %i)", timer, countdown); +void KyraEngine_v1::setTimerCountdown(uint8 timer, int32 countdown) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::setTimerCountdown(%i, %i)", timer, countdown); _timers[timer].countdown = countdown; _timers[timer].nextRun = _system->getMillis() + countdown * _tickLength; @@ -131,18 +131,18 @@ void KyraEngine::setTimerCountdown(uint8 timer, int32 countdown) { _timerNextRun = nextRun; } -void KyraEngine::enableTimer(uint8 timer) { - debugC(9, kDebugLevelMain, "KyraEngine::enableTimer(%i)", timer); +void KyraEngine_v1::enableTimer(uint8 timer) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::enableTimer(%i)", timer); _timers[timer].active = 1; } -void KyraEngine::disableTimer(uint8 timer) { - debugC(9, kDebugLevelMain, "KyraEngine::disableTimer(%i)", timer); +void KyraEngine_v1::disableTimer(uint8 timer) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::disableTimer(%i)", timer); _timers[timer].active = 0; } -void KyraEngine::timerUpdateHeadAnims(int timerNum) { - debugC(9, kDebugLevelMain, "KyraEngine::timerUpdateHeadAnims(%i)", timerNum); +void KyraEngine_v1::timerUpdateHeadAnims(int timerNum) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::timerUpdateHeadAnims(%i)", timerNum); static int8 currentFrame = 0; static const int8 frameTable[] = {4, 5, 4, 5, 4, 5, 0, 1, 4, 5, 4, 4, 6, 4, 8, 1, 9, 4, -1}; @@ -160,8 +160,8 @@ void KyraEngine::timerUpdateHeadAnims(int timerNum) { _animator->animRefreshNPC(_talkingCharNum); } -void KyraEngine::timerSetFlags1(int timerNum) { - debugC(9, kDebugLevelMain, "KyraEngine::timerSetFlags(%i)", timerNum); +void KyraEngine_v1::timerSetFlags1(int timerNum) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::timerSetFlags(%i)", timerNum); if (_currentCharacter->sceneId == 0x1C) return; @@ -179,57 +179,57 @@ void KyraEngine::timerSetFlags1(int timerNum) { } } -void KyraEngine::timerFadeText(int timerNum) { - debugC(9, kDebugLevelMain, "KyraEngine::timerFadeText(%i)", timerNum); +void KyraEngine_v1::timerFadeText(int timerNum) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::timerFadeText(%i)", timerNum); _fadeText = true; } -void KyraEngine::updateAnimFlag1(int timerNum) { - debugC(9, kDebugLevelMain, "KyraEngine::updateAnimFlag1(%d)", timerNum); +void KyraEngine_v1::updateAnimFlag1(int timerNum) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::updateAnimFlag1(%d)", timerNum); if (_brandonStatusBit & 2) { _brandonStatusBit0x02Flag = 1; } } -void KyraEngine::updateAnimFlag2(int timerNum) { - debugC(9, kDebugLevelMain, "KyraEngine::updateAnimFlag2(%d)", timerNum); +void KyraEngine_v1::updateAnimFlag2(int timerNum) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::updateAnimFlag2(%d)", timerNum); if (_brandonStatusBit & 0x20) { _brandonStatusBit0x20Flag = 1; } } -void KyraEngine::setTextFadeTimerCountdown(int16 countdown) { - debugC(9, kDebugLevelMain, "KyraEngine::setTextFadeTimerCountdown(%i)", countdown); +void KyraEngine_v1::setTextFadeTimerCountdown(int16 countdown) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::setTextFadeTimerCountdown(%i)", countdown); //if (countdown == -1) //countdown = 32000; setTimerCountdown(31, countdown*60); } -void KyraEngine::timerSetFlags2(int timerNum) { - debugC(9, kDebugLevelMain, "KyraEngine::timerSetFlags2(%i)", timerNum); +void KyraEngine_v1::timerSetFlags2(int timerNum) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::timerSetFlags2(%i)", timerNum); if (!((uint32*)(_flagsTable+0x2D))[timerNum]) ((uint32*)(_flagsTable+0x2D))[timerNum] = 1; } -void KyraEngine::timerCheckAnimFlag1(int timerNum) { - debugC(9, kDebugLevelMain, "KyraEngine::timerCheckAnimFlag1(%i)", timerNum); +void KyraEngine_v1::timerCheckAnimFlag1(int timerNum) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::timerCheckAnimFlag1(%i)", timerNum); if (_brandonStatusBit & 0x20) { checkAmuletAnimFlags(); setTimerCountdown(18, -1); } } -void KyraEngine::timerCheckAnimFlag2(int timerNum) { - debugC(9, kDebugLevelMain, "KyraEngine::timerCheckAnimFlag1(%i)", timerNum); +void KyraEngine_v1::timerCheckAnimFlag2(int timerNum) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::timerCheckAnimFlag1(%i)", timerNum); if (_brandonStatusBit & 0x2) { checkAmuletAnimFlags(); setTimerCountdown(14, -1); } } -void KyraEngine::checkAmuletAnimFlags() { - debugC(9, kDebugLevelMain, "KyraEngine::checkSpecialAnimFlags()"); +void KyraEngine_v1::checkAmuletAnimFlags() { + debugC(9, kDebugLevelMain, "KyraEngine_v1::checkSpecialAnimFlags()"); if (_brandonStatusBit & 2) { seq_makeBrandonNormal2(); setTimerCountdown(19, 300); @@ -241,16 +241,16 @@ void KyraEngine::checkAmuletAnimFlags() { } } -void KyraEngine::timerRedrawAmulet(int timerNum) { - debugC(9, kDebugLevelMain, "KyraEngine::timerRedrawAmulet(%i)", timerNum); +void KyraEngine_v1::timerRedrawAmulet(int timerNum) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::timerRedrawAmulet(%i)", timerNum); if (queryGameFlag(0xF1)) { drawAmulet(); setTimerCountdown(19, -1); } } -void KyraEngine::drawAmulet() { - debugC(9, kDebugLevelMain, "KyraEngine::drawAmulet()"); +void KyraEngine_v1::drawAmulet() { + debugC(9, kDebugLevelMain, "KyraEngine_v1::drawAmulet()"); static const int16 amuletTable1[] = {0x167, 0x162, 0x15D, 0x158, 0x153, 0x150, 0x155, 0x15A, 0x15F, 0x164, 0x145, -1}; static const int16 amuletTable3[] = {0x167, 0x162, 0x15D, 0x158, 0x153, 0x14F, 0x154, 0x159, 0x15E, 0x163, 0x144, -1}; static const int16 amuletTable2[] = {0x167, 0x162, 0x15D, 0x158, 0x153, 0x152, 0x157, 0x15C, 0x161, 0x166, 0x147, -1}; @@ -280,8 +280,8 @@ void KyraEngine::drawAmulet() { _screen->showMouse(); } -void KyraEngine::setWalkspeed(uint8 newSpeed) { - debugC(9, kDebugLevelMain, "KyraEngine::setWalkspeed(%i)", newSpeed); +void KyraEngine_v1::setWalkspeed(uint8 newSpeed) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::setWalkspeed(%i)", newSpeed); static const uint8 speeds[] = {11, 9, 6, 5, 3}; assert(newSpeed < ARRAYSIZE(speeds)); -- cgit v1.2.3 From 1140fca82e79121ad2a154dc98b1637c8d56d55d Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 29 Jul 2007 16:33:11 +0000 Subject: - Kyrandia 1 works again - Added timer class for timer handling - Little bit more resturcturing - A little bit (almost nothing but a start!) Kyrandia 2 support svn-id: r28297 --- engines/kyra/animator_v2.cpp | 313 +++++++++++ engines/kyra/debugger.cpp | 9 +- engines/kyra/gui_v1.cpp | 33 ++ engines/kyra/gui_v2.cpp | 7 +- engines/kyra/items_v2.cpp | 56 ++ engines/kyra/kyra.cpp | 20 +- engines/kyra/kyra.h | 30 +- engines/kyra/kyra_v1.cpp | 40 +- engines/kyra/kyra_v1.h | 31 +- engines/kyra/kyra_v2.cpp | 1179 ++++++++++++++++++++++++++++++++++++++++- engines/kyra/kyra_v2.h | 352 +++++++++++- engines/kyra/kyra_v3.cpp | 10 +- engines/kyra/module.mk | 7 + engines/kyra/resource.cpp | 4 +- engines/kyra/resource.h | 5 +- engines/kyra/saveload_v1.cpp | 23 +- engines/kyra/scene.cpp | 383 +++++++++++++ engines/kyra/scene_v1.cpp | 374 +------------ engines/kyra/scene_v2.cpp | 865 ++++++++++++++++++++++++++++++ engines/kyra/screen.cpp | 68 +-- engines/kyra/screen.h | 18 +- engines/kyra/screen_v2.cpp | 522 +++++++++++++++++- engines/kyra/screen_v2.h | 41 +- engines/kyra/script.cpp | 209 ++++---- engines/kyra/script.h | 94 ++-- engines/kyra/script_v1.cpp | 325 ++++++------ engines/kyra/script_v2.cpp | 430 +++++++++++++++ engines/kyra/sequences_v1.cpp | 9 +- engines/kyra/sequences_v2.cpp | 1 + engines/kyra/staticres.cpp | 67 ++- engines/kyra/text_v1.cpp | 24 +- engines/kyra/timer.cpp | 251 +++++++++ engines/kyra/timer.h | 93 ++++ engines/kyra/timer_v1.cpp | 222 ++------ engines/kyra/timer_v2.cpp | 80 +++ engines/kyra/util.h | 61 +++ engines/kyra/wsamovie.cpp | 101 +++- engines/kyra/wsamovie.h | 18 +- 38 files changed, 5312 insertions(+), 1063 deletions(-) create mode 100644 engines/kyra/animator_v2.cpp create mode 100644 engines/kyra/items_v2.cpp create mode 100644 engines/kyra/scene.cpp create mode 100644 engines/kyra/scene_v2.cpp create mode 100644 engines/kyra/script_v2.cpp create mode 100644 engines/kyra/timer.cpp create mode 100644 engines/kyra/timer.h create mode 100644 engines/kyra/timer_v2.cpp create mode 100644 engines/kyra/util.h (limited to 'engines') diff --git a/engines/kyra/animator_v2.cpp b/engines/kyra/animator_v2.cpp new file mode 100644 index 0000000000..179bdd140d --- /dev/null +++ b/engines/kyra/animator_v2.cpp @@ -0,0 +1,313 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include "kyra/kyra_v2.h" +#include "kyra/wsamovie.h" + +namespace Kyra { + +void KyraEngine_v2::clearAnimObjects() { + memset(_animObjects, 0, sizeof(_animObjects)); + + _animObjects[0].index = 0; + _animObjects[0].type = 0; + _animObjects[0].enabled = 1; + _animObjects[0].flags = 0x800; + _animObjects[0].width = 32; + _animObjects[0].height = 49; + _animObjects[0].width2 = 4; + _animObjects[0].height2 = 10; + + for (int i = 1; i < 11; ++i) { + _animObjects[i].index = i; + _animObjects[i].type = 2; + } + + for (int i = 11; i <= 40; ++i) { + _animObjects[i].index = i; + _animObjects[i].type = 1; + _animObjects[i].flags = 0x800; + _animObjects[i].width = 16; + _animObjects[i].height = 16; + } +} + +KyraEngine_v2::AnimObj *KyraEngine_v2::initAnimList(AnimObj *list, AnimObj *entry) { + entry->nextObject = list; + return entry; +} + +KyraEngine_v2::AnimObj *KyraEngine_v2::addToAnimListSorted(AnimObj *list, AnimObj *add) { + if (add->yPos1 <= list->yPos1) { + add->nextObject = list; + return add; + } + + AnimObj *cur = list; + AnimObj *prev = list; + while (add->yPos1 > cur->yPos1) { + AnimObj *temp = cur->nextObject; + if (!temp) + break; + prev = cur; + cur = temp; + } + + if (add->yPos1 <= cur->yPos1) { + prev->nextObject = add; + add->nextObject = cur; + } else { + cur->nextObject = add; + add->nextObject = 0; + } + return list; +} + +KyraEngine_v2::AnimObj *KyraEngine_v2::deleteAnimListEntry(AnimObj *list, AnimObj *entry) { + if (!list) + return 0; + + AnimObj *old = 0; + AnimObj *cur = list; + + while (true) { + if (cur == entry) + break; + if (!cur->nextObject) + break; + old = cur; + cur = cur->nextObject; + } + + if (cur == list) { + if (!cur->nextObject) + return 0; + cur = cur->nextObject; + return cur; + } + + if (!cur->nextObject) { + if (!old) + return 0; + old->nextObject = 0; + return list; + } + + if (cur != entry) + return list; + + old->nextObject = entry->nextObject; + return list; +} + +void KyraEngine_v2::drawAnimObjects() { + for (AnimObj *curObject = _animList; curObject; curObject = curObject->nextObject) { + if (!curObject->enabled) + continue; + + int x = curObject->xPos2 - (_screen->getScreenDim(2)->sx << 3); + int y = curObject->yPos2 - _screen->getScreenDim(2)->sy; + int layer = 7; + + if (curObject->flags & 0x800) { + if (curObject->animFlags) + layer = 0; + else + layer = getDrawLayer(curObject->xPos1, curObject->yPos1); + } + curObject->flags |= 0x800; + + if (curObject->index) + drawSceneAnimObject(curObject, x, y, layer); + else + drawCharacterAnimObject(curObject, x, y, layer); + } +} + +void KyraEngine_v2::refreshAnimObjects(int force) { + for (AnimObj *curObject = _animList; curObject; curObject = curObject->nextObject) { + if (!curObject->enabled) + continue; + if (!curObject->needRefresh && !force) + continue; + + int x = curObject->xPos2 - curObject->width2; + if (x < 0) + x = 0; + if (x >= 320) + x = 319; + int y = curObject->yPos2 - curObject->height2; + if (y < 0) + y = 0; + if (y >= 143) + y = 142; + + int width = curObject->width + curObject->width2 + 8; + int height = curObject->height + curObject->height2*2; + if (width + x > 320) + width -= width + x - 322; + if (height + y > 143) + height -= height + y - 144; + + _screen->hideMouse(); + _screen->copyRegion(x, y, x, y, width, height, 2, 0, Screen::CR_CLIPPED); + _screen->showMouse(); + + curObject->needRefresh = false; + } +} + +void KyraEngine_v2::refreshAnimObjectsIfNeed() { + for (AnimObj *curEntry = _animList; curEntry; curEntry = curEntry->nextObject) { + if (curEntry->enabled && curEntry->needRefresh) { + restorePage3(); + drawAnimObjects(); + refreshAnimObjects(0); + _screen->updateScreen(); + return; + } + } +} + +void KyraEngine_v2::updateCharacterAnim(int) { + Character *c = &_mainCharacter; + AnimObj *animState = _animObjects; + + animState->needRefresh = 1; + animState->unk8 = 1; + + if (c->facing >= 1 && c->facing <= 3) + animState->flags |= 1; + else if (c->facing >= 5 && c->facing <= 7) + animState->flags &= ~1; + + animState->xPos2 = animState->xPos1 = c->x1; + animState->yPos2 = animState->yPos1 = c->y1; + animState->shapePtr = _defaultShapeTable[c->animFrame]; + animState->shapeIndex1 = animState->shapeIndex2 = c->animFrame; + + int xAdd = _shapeDescTable[c->animFrame-9].xAdd; + int yAdd = _shapeDescTable[c->animFrame-9].yAdd; + + _charScaleX = _charScaleY = getScale(c->x1, c->y1); + + animState->xPos2 += (xAdd * _charScaleX) >> 8; + animState->yPos2 += (yAdd * _charScaleY) >> 8; + animState->width2 = 8; + animState->height2 = 10; + + _animList = deleteAnimListEntry(_animList, animState); + if (_animList) + _animList = addToAnimListSorted(_animList, animState); + else + _animList = initAnimList(_animList, animState); + + updateCharPal(1); +} + +void KyraEngine_v2::updateSceneAnim(int anim, int newFrame) { + AnimObj *animObject = &_animObjects[1+anim]; + if (!animObject->enabled) + return; + + animObject->needRefresh = 1; + animObject->unk8 = 1; + animObject->flags = 0; + + if (_sceneAnims[anim].flags & 2) + animObject->flags |= 0x800; + else + animObject->flags &= ~0x800; + + if (_sceneAnims[anim].flags & 4) + animObject->flags |= 1; + else + animObject->flags &= ~1; + + if (_sceneAnims[anim].flags & 0x20) { + animObject->shapePtr = _sceneShapeTable[newFrame]; + animObject->shapeIndex2 = 0xFFFF; + animObject->shapeIndex3 = 0xFFFF; + animObject->animNum = 0xFFFF; + } else { + animObject->shapePtr = 0; + animObject->shapeIndex3 = newFrame; + animObject->animNum = anim; + } + + animObject->xPos1 = _sceneAnims[anim].x; + animObject->yPos1 = _sceneAnims[anim].y; + animObject->xPos2 = _sceneAnims[anim].x2; + animObject->yPos2 = _sceneAnims[anim].y2; + + if (_sceneAnims[anim].flags & 2) { + _animList = deleteAnimListEntry(_animList, animObject); + if (!_animList) + _animList = initAnimList(_animList, animObject); + else + _animList = addToAnimListSorted(_animList, animObject); + } +} + +void KyraEngine_v2::drawSceneAnimObject(AnimObj *obj, int x, int y, int layer) { + if (obj->type == 1) { + if (obj->shapeIndex1 == 0xFFFF) + return; + int scale = getScale(obj->xPos1, obj->yPos1); + _screen->drawShape(2, getShapePtr(obj->shapeIndex1), x, y, 2, obj->flags | 4, layer, scale, scale); + return; + } + + if (obj->shapePtr) { + _screen->drawShape(2, obj->shapePtr, x, y, 2, obj->flags, layer); + } else { + if (obj->shapeIndex3 == 0xFFFF || obj->animNum == 0xFFFF) + return; + + int flags = 0x4000; + if (obj->flags & 0x800) + flags |= 0x8000; + + if (_sceneAnims[obj->animNum].wsaFlag) { + x = y = 0; + } else { + x = obj->xPos2; + y = obj->yPos2; + } + + _sceneAnimMovie[obj->animNum]->setX(x); + _sceneAnimMovie[obj->animNum]->setY(y); + _sceneAnimMovie[obj->animNum]->setDrawPage(2); + _sceneAnimMovie[obj->animNum]->displayFrame(obj->shapeIndex3, int(flags | layer), 0, 0); + } +} + +void KyraEngine_v2::drawCharacterAnimObject(AnimObj *obj, int x, int y, int layer) { + if (_drawNoShapeFlag || obj->shapeIndex1 == 0xFFFF) + return; + _screen->drawShape(2, getShapePtr(obj->shapeIndex1), x, y, 2, obj->flags | 4, layer, _charScaleX, _charScaleY); +} + +} // end of namespace Kyra diff --git a/engines/kyra/debugger.cpp b/engines/kyra/debugger.cpp index 0a1974c3f4..152dc21c61 100644 --- a/engines/kyra/debugger.cpp +++ b/engines/kyra/debugger.cpp @@ -29,6 +29,7 @@ #include "kyra/debugger.h" #include "kyra/kyra_v1.h" #include "kyra/screen.h" +#include "kyra/timer.h" namespace Kyra { @@ -141,8 +142,8 @@ bool Debugger_v1::cmd_queryFlag(int argc, const char **argv) { } bool Debugger_v1::cmd_listTimers(int argc, const char **argv) { - for (int i = 0; i < ARRAYSIZE(_vm->_timers); i++) - DebugPrintf("Timer %-2i: Active: %-3s Countdown: %-6i\n", i, _vm->_timers[i].active ? "Yes" : "No", _vm->_timers[i].countdown); + for (int i = 0; i < _vm->timer()->count(); i++) + DebugPrintf("Timer %-2i: Active: %-3s Countdown: %-6i\n", i, _vm->timer()->isEnabled(i) ? "Yes" : "No", _vm->timer()->getDelay(i)); return true; } @@ -151,8 +152,8 @@ bool Debugger_v1::cmd_setTimerCountdown(int argc, const char **argv) { if (argc > 2) { uint timer = atoi(argv[1]); uint countdown = atoi(argv[2]); - _vm->setTimerCountdown(timer, countdown); - DebugPrintf("Timer %i now has countdown %i\n", timer, _vm->_timers[timer].countdown); + _vm->timer()->setCountdown(timer, countdown); + DebugPrintf("Timer %i now has countdown %i\n", timer, _vm->timer()->getDelay(timer)); } else { DebugPrintf("Syntax: settimercountdown \n"); } diff --git a/engines/kyra/gui_v1.cpp b/engines/kyra/gui_v1.cpp index 2452185c24..b7692cc97d 100644 --- a/engines/kyra/gui_v1.cpp +++ b/engines/kyra/gui_v1.cpp @@ -1469,5 +1469,38 @@ void KyraEngine_v1::gui_restorePalette() { _screen->fadePalette(_screen->_currentPalette, 2); } +#pragma mark - + +void KyraEngine_v1::drawAmulet() { + debugC(9, kDebugLevelMain, "KyraEngine_v1::drawAmulet()"); + static const int16 amuletTable1[] = {0x167, 0x162, 0x15D, 0x158, 0x153, 0x150, 0x155, 0x15A, 0x15F, 0x164, 0x145, -1}; + static const int16 amuletTable3[] = {0x167, 0x162, 0x15D, 0x158, 0x153, 0x14F, 0x154, 0x159, 0x15E, 0x163, 0x144, -1}; + static const int16 amuletTable2[] = {0x167, 0x162, 0x15D, 0x158, 0x153, 0x152, 0x157, 0x15C, 0x161, 0x166, 0x147, -1}; + static const int16 amuletTable4[] = {0x167, 0x162, 0x15D, 0x158, 0x153, 0x151, 0x156, 0x15B, 0x160, 0x165, 0x146, -1}; + + resetGameFlag(0xF1); + _screen->hideMouse(); + + int i = 0; + while (amuletTable1[i] != -1) { + if (queryGameFlag(87)) + _screen->drawShape(0, _shapes[amuletTable1[i]], _amuletX[0], _amuletY[0], 0, 0); + + if (queryGameFlag(89)) + _screen->drawShape(0, _shapes[amuletTable2[i]], _amuletX[1], _amuletY[1], 0, 0); + + if (queryGameFlag(86)) + _screen->drawShape(0, _shapes[amuletTable3[i]], _amuletX[2], _amuletY[2], 0, 0); + + if (queryGameFlag(88)) + _screen->drawShape(0, _shapes[amuletTable4[i]], _amuletX[3], _amuletY[3], 0, 0); + + _screen->updateScreen(); + delayWithTicks(3); + i++; + } + _screen->showMouse(); +} + } // end of namespace Kyra diff --git a/engines/kyra/gui_v2.cpp b/engines/kyra/gui_v2.cpp index f24bf295a8..838d347f8f 100644 --- a/engines/kyra/gui_v2.cpp +++ b/engines/kyra/gui_v2.cpp @@ -11,7 +11,7 @@ * 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 + * 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 @@ -63,7 +63,10 @@ int KyraEngine_v2::gui_handleMainMenu() { int charWidthBackUp = _screen->_charWidth; _screen->_charWidth = -2; - _screen->setScreenDim(3); + if (_flags.gameID == GI_KYRA2) + _screen->setScreenDim(11); + else + _screen->setScreenDim(3); int backUpX = _screen->_curDim->sx; int backUpY = _screen->_curDim->sy; int backUpWidth = _screen->_curDim->w; diff --git a/engines/kyra/items_v2.cpp b/engines/kyra/items_v2.cpp new file mode 100644 index 0000000000..fd4c7a5fab --- /dev/null +++ b/engines/kyra/items_v2.cpp @@ -0,0 +1,56 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include "kyra/kyra_v2.h" + +namespace Kyra { + +int KyraEngine_v2::findFreeItem() { + for (int i = 0; i < 30; ++i) { + if (_itemList[i].id == 0xFFFF) + return i; + } + return -1; +} + +int KyraEngine_v2::findItem(uint16 sceneId, int id) { + for (int i = 0; i < 30; ++i) { + if (_itemList[i].id == id && _itemList[i].sceneId == sceneId) + return i; + } + return -1; +} + +void KyraEngine_v2::resetItemList() { + for (int i = 0; i < 30; ++i) { + _itemList[i].id = 0xFFFF; + _itemList[i].sceneId = 0xFFFF; + _itemList[i].x = 0; + _itemList[i].y = 0; + _itemList[i].unk7 = 0; + } +} + +} // end of namespace Kyra diff --git a/engines/kyra/kyra.cpp b/engines/kyra/kyra.cpp index c7e167f600..1d8d7440f0 100644 --- a/engines/kyra/kyra.cpp +++ b/engines/kyra/kyra.cpp @@ -35,16 +35,23 @@ #include "kyra/resource.h" #include "kyra/screen.h" #include "kyra/text.h" +#include "kyra/timer.h" +#include "kyra/script.h" namespace Kyra { KyraEngine::KyraEngine(OSystem *system, const GameFlags &flags) : Engine(system) { - _screen = 0; _res = 0; _sound = 0; _text = 0; _staticres = 0; + _timer = 0; + _scriptInterpreter = 0; + + _flags = flags; + _gameSpeed = 60; + _tickLength = (uint8)(1000.0 / _gameSpeed); _quitFlag = false; @@ -63,6 +70,7 @@ KyraEngine::KyraEngine(OSystem *system, const GameFlags &flags) Common::addSpecialDebugLevel(kDebugLevelGUI, "GUI", "GUI debug level"); Common::addSpecialDebugLevel(kDebugLevelSequence, "Sequence", "Sequence debug level"); Common::addSpecialDebugLevel(kDebugLevelMovie, "Movie", "Movie debug level"); + Common::addSpecialDebugLevel(kDebugLevelTimer, "Timer", "Timer debug level"); } int KyraEngine::init() { @@ -115,12 +123,18 @@ int KyraEngine::init() { _res = new Resource(this); assert(_res); - _text = new TextDisplayer(this, _screen); + _text = new TextDisplayer(this, this->screen()); assert(_text); _staticres = new StaticResource(this); assert(_staticres); if (!_staticres->init()) error("_staticres->init() failed"); + _timer = new TimerManager(this, _system); + assert(_timer); + _scriptInterpreter = new ScriptHelper(this); + assert(_scriptInterpreter); + + setupOpcodeTable(); _lang = 0; Common::Language lang = Common::parseLanguage(ConfMan.get("language")); @@ -155,6 +169,8 @@ KyraEngine::~KyraEngine() { delete _res; delete _sound; delete _text; + delete _timer; + delete _scriptInterpreter; } void KyraEngine::quitGame() { diff --git a/engines/kyra/kyra.h b/engines/kyra/kyra.h index 7d795abd7c..8ed546d1ce 100644 --- a/engines/kyra/kyra.h +++ b/engines/kyra/kyra.h @@ -31,9 +31,9 @@ #include "common/array.h" #include "common/events.h" -namespace Kyra { +#include "kyra/util.h" -struct Opcode; +namespace Kyra { struct GameFlags { Common::Language lang; @@ -59,16 +59,17 @@ enum { // TODO: this is just the start of makeing the debug output of the kyra engine a bit more useable // in the future we maybe merge some flags and/or create new ones enum kDebugLevels { - kDebugLevelScriptFuncs = 1 << 0, // prints debug output of o1_* functions + kDebugLevelScriptFuncs = 1 << 0, // prints debug output of o#_* functions kDebugLevelScript = 1 << 1, // prints debug output of "ScriptHelper" functions kDebugLevelSprites = 1 << 2, // prints debug output of "Sprites" functions kDebugLevelScreen = 1 << 3, // prints debug output of "Screen" functions kDebugLevelSound = 1 << 4, // prints debug output of "Sound" functions kDebugLevelAnimator = 1 << 5, // prints debug output of "ScreenAnimator" functions - kDebugLevelMain = 1 << 6, // prints debug output of common "KyraEngine*" functions && "TextDisplayer" functions + kDebugLevelMain = 1 << 6, // prints debug output of common "KyraEngine(_v#)" functions && "TextDisplayer" functions kDebugLevelGUI = 1 << 7, // prints debug output of "KyraEngine*" gui functions kDebugLevelSequence = 1 << 8, // prints debug output of "SeqPlayer" functions - kDebugLevelMovie = 1 << 9 // prints debug output of movie specific funtions + kDebugLevelMovie = 1 << 9, // prints debug output of movie specific funtions + kDebugLevelTimer = 1 << 10 // prints debug output of "TimerManager" functions }; class Screen; @@ -77,6 +78,8 @@ class Sound; class Movie; class TextDisplayer; class StaticResource; +class TimerManager; +class ScriptHelper; class KyraEngine : public Engine { public: @@ -94,6 +97,7 @@ public: TextDisplayer *text() { return _text; } Sound *sound() { return _sound; } StaticResource *staticres() { return _staticres; } + TimerManager *timer() { return _timer; } uint32 tickLength() const { return _tickLength; } @@ -123,14 +127,16 @@ protected: // intern Resource *_res; - Screen *_screen; Sound *_sound; TextDisplayer *_text; StaticResource *_staticres; + TimerManager *_timer; + ScriptHelper *_scriptInterpreter; // game speed bool _skipFlag; uint16 _tickLength; + uint16 _gameSpeed; // detection GameFlags _flags; @@ -145,6 +151,18 @@ protected: // input Common::Point getMousePos() const; + + // pathfinder + virtual int findWay(int x, int y, int toX, int toY, int *moveTable, int moveTableSize); + int findSubPath(int x, int y, int toX, int toY, int *moveTable, int start, int end); + int getFacingFromPointToPoint(int x, int y, int toX, int toY); + int getOppositeFacingDirection(int dir); + void changePosTowardsFacing(int &x, int &y, int facing); + int getMoveTableSize(int *moveTable); + virtual bool lineIsPassable(int x, int y) = 0; + + static const int8 _addXPosTable[]; + static const int8 _addYPosTable[]; }; } // End of namespace Kyra diff --git a/engines/kyra/kyra_v1.cpp b/engines/kyra/kyra_v1.cpp index 404e62403a..45ee42b0d3 100644 --- a/engines/kyra/kyra_v1.cpp +++ b/engines/kyra/kyra_v1.cpp @@ -42,6 +42,7 @@ #include "kyra/animator_v1.h" #include "kyra/text.h" #include "kyra/debugger.h" +#include "kyra/timer.h" namespace Kyra { @@ -80,7 +81,6 @@ KyraEngine_v1::KyraEngine_v1(OSystem *system, const GameFlags &flags) _sprites = 0; _animator = 0; _seq = 0; - _scriptInterpreter = 0; _npcScriptData = 0; _scriptMain = 0; _scriptClickData = 0; @@ -124,8 +124,7 @@ KyraEngine_v1::~KyraEngine_v1() { delete _sprites; delete _animator; delete _seq; - delete _scriptInterpreter; - + delete _npcScriptData; delete _scriptMain; @@ -181,18 +180,18 @@ int KyraEngine_v1::init() { initStaticResource(); - if (!_sound->init()) - error("Couldn't init sound"); - if (_flags.platform == Common::kPlatformFMTowns) _sound->setSoundFileList(_soundFilesTowns, _soundFilesTownsCount); else _sound->setSoundFileList(_soundFiles, _soundFilesCount); + + if (!_sound->init()) + error("Couldn't init sound"); _sound->setVolume(255); _sound->loadSoundFile(0); - setupOpcodeTable(); + setupTimers(); setupButtonData(); setupMenu(); @@ -210,9 +209,6 @@ int KyraEngine_v1::init() { _characterList[0].facing = 3; _characterList[0].currentAnimFrame = 7; - _scriptInterpreter = new ScriptHelper(this); - assert(_scriptInterpreter); - _npcScriptData = new ScriptData; memset(_npcScriptData, 0, sizeof(ScriptData)); assert(_npcScriptData); @@ -263,7 +259,6 @@ int KyraEngine_v1::init() { _pathfinderFlag = _pathfinderFlag2 = 0; _lastFindWayRet = 0; _sceneChangeState = _loopFlag2 = 0; - _timerNextRun = 0; _movFacingTable = new int[150]; assert(_movFacingTable); @@ -309,9 +304,6 @@ int KyraEngine_v1::init() { _menuDirectlyToLoad = false; _lastMusicCommand = 0; - - _gameSpeed = 60; - _tickLength = (uint8)(1000.0 / _gameSpeed); return 0; } @@ -456,7 +448,7 @@ void KyraEngine_v1::mainLoop() { processButtonList(_buttonList); updateMousePointer(); - updateGameTimers(); + _timer->update(); updateTextFade(); _handleInput = true; @@ -470,7 +462,7 @@ void KyraEngine_v1::mainLoop() { void KyraEngine_v1::delayUntil(uint32 timestamp, bool updateTimers, bool update, bool isMainLoop) { while (_system->getMillis() < timestamp && !_quitFlag) { if (updateTimers) - updateGameTimers(); + _timer->update(); if (timestamp - _system->getMillis() >= 10) delay(10, update, isMainLoop); @@ -1003,6 +995,21 @@ void KyraEngine_v1::runNpcScript(int func) { _scriptInterpreter->runScript(_npcScript); } +void KyraEngine_v1::checkAmuletAnimFlags() { + debugC(9, kDebugLevelMain, "KyraEngine_v1::checkSpecialAnimFlags()"); + + if (_brandonStatusBit & 2) { + seq_makeBrandonNormal2(); + _timer->setCountdown(19, 300); + } + + if (_brandonStatusBit & 0x20) { + seq_makeBrandonNormal(); + _timer->setCountdown(19, 300); + } +} + +typedef Functor1Mem OpcodeV1; #define Opcode(x) OpcodeV1(this, &KyraEngine_v1::x) void KyraEngine_v1::setupOpcodeTable() { static const OpcodeV1 opcodeTable[] = { @@ -1201,6 +1208,7 @@ void KyraEngine_v1::setupOpcodeTable() { Opcode(o1_fillRect), Opcode(o1_vocUnload), Opcode(o1_vocLoad), + // 0x9c Opcode(o1_dummy) }; diff --git a/engines/kyra/kyra_v1.h b/engines/kyra/kyra_v1.h index 1bd8f48971..6e5ba98d3c 100644 --- a/engines/kyra/kyra_v1.h +++ b/engines/kyra/kyra_v1.h @@ -36,7 +36,6 @@ class Movie; class SoundDigital; class SeqPlayer; class Sprites; -class ScriptHelper; class Debugger; class ScreenAnimator; class TextDisplayer; @@ -105,13 +104,6 @@ struct BeadState { int16 tableIndex; }; -struct Timer { - uint8 active; - int32 countdown; - uint32 nextRun; - void (KyraEngine_v1::*func)(int timerNum); -}; - struct Button { Button *nextButton; uint16 specialValue; @@ -294,14 +286,6 @@ public: bool speechEnabled(); bool textEnabled(); - void updateGameTimers(); - void clearNextEventTickCount(); - void setTimerCountdown(uint8 timer, int32 countdown); - void setTimerDelay(uint8 timer, int32 countdown); - int16 getTimerDelay(uint8 timer); - void enableTimer(uint8 timer); - void disableTimer(uint8 timer); - void saveGame(const char *fileName, const char *saveName); void loadGame(const char *fileName); @@ -336,11 +320,7 @@ protected: // -> pathfinder int findWay(int x, int y, int toX, int toY, int *moveTable, int moveTableSize); - int findSubPath(int x, int y, int toX, int toY, int *moveTable, int start, int end); - int getFacingFromPointToPoint(int x, int y, int toX, int toY); - void changePosTowardsFacing(int &x, int &y, int facing); bool lineIsPassable(int x, int y); - int getMoveTableSize(int *moveTable); // -> item handling // --> misc @@ -397,7 +377,6 @@ protected: void setCharacterPositionWithUpdate(int character); int setCharacterPosition(int character, int *facingTable); void setCharacterPositionHelper(int character, int *facingTable); - int getOppositeFacingDirection(int dir); void setCharactersPositions(int character); // -> brandon @@ -459,7 +438,7 @@ protected: void freePanPages(); void closeFinalWsa(); - void setTimer19(); + //void setTimer19(); void setupTimers(); void timerUpdateHeadAnims(int timerNum); void timerSetFlags1(int timerNum); @@ -535,7 +514,6 @@ protected: int8 _mouseWheel; uint8 *_itemBkgBackUp[2]; uint8 *_shapes[373]; - uint16 _gameSpeed; int8 _itemInHand; int _mouseState; bool _handleInput; @@ -632,7 +610,6 @@ protected: SeqPlayer *_seq; Sprites *_sprites; Screen_v1 *_screen; - ScriptHelper *_scriptInterpreter; Debugger *_debugger; ScriptState *_scriptMain; @@ -790,18 +767,13 @@ protected: const uint8 * const*_specialPalettes; - Timer _timers[34]; - uint32 _timerNextRun; - static const char *_soundFiles[]; static const int _soundFilesCount; static const char *_soundFilesTowns[]; static const int _soundFilesTownsCount; static const int8 _charXPosTable[]; - static const int8 _addXPosTable[]; static const int8 _charYPosTable[]; - static const int8 _addYPosTable[]; // positions of the inventory static const uint16 _itemPosX[]; @@ -829,7 +801,6 @@ protected: static const uint16 _amuletX2[]; static const uint16 _amuletY2[]; protected: - typedef OpcodeImpl OpcodeV1; void setupOpcodeTable(); // Opcodes diff --git a/engines/kyra/kyra_v2.cpp b/engines/kyra/kyra_v2.cpp index 2f52d8919d..7a9d631c25 100644 --- a/engines/kyra/kyra_v2.cpp +++ b/engines/kyra/kyra_v2.cpp @@ -29,14 +29,38 @@ #include "kyra/resource.h" #include "kyra/wsamovie.h" #include "kyra/sound.h" +#include "kyra/script.h" +#include "kyra/text.h" +#include "kyra/timer.h" #include "common/system.h" namespace Kyra { KyraEngine_v2::KyraEngine_v2(OSystem *system, const GameFlags &flags) : KyraEngine(system, flags) { - memset(_gameShapes, 0, sizeof(_gameShapes)); + memset(_defaultShapeTable, 0, sizeof(_defaultShapeTable)); _mouseSHPBuf = 0; + + _gamePlayBuffer = 0; + _cCodeBuffer = _optionsBuffer = _chapterBuffer = 0; + + _overwriteSceneFacing = false; + _mainCharX = _mainCharY = -1; + _drawNoShapeFlag = false; + _charPalEntry = 0; + _itemInHand = -1; + _unkSceneScreenFlag1 = false; + _noScriptEnter = true; + _currentChapter = 0; + _newChapterFile = 1; + _handItemSet = -1; + _lastProcessedSceneScript = 0; + _specialSceneScriptRunFlag = false; + memset(_animObjects, 0, sizeof(_animObjects)); + _unkHandleSceneChangeFlag = false; + _pathfinderFlag = 0; + + memset(&_sceneScriptData, 0, sizeof(_sceneScriptData)); } KyraEngine_v2::~KyraEngine_v2() { @@ -55,13 +79,14 @@ int KyraEngine_v2::init() { error("_screen->init() failed"); KyraEngine::init(); + + setupTimers(); - if (_res->getFileSize("6.FNT")) - _screen->loadFont(Screen::FID_6_FNT, "6.FNT"); - if (_res->getFileSize("8FAT.FNT")) - _screen->loadFont(Screen::FID_8_FNT, "8FAT.FNT"); - _screen->loadFont(Screen::FID_GOLDFONT_FNT, "GOLDFONT.FNT"); - _screen->setAnimBlockPtr(3500); + _screen->loadFont(_screen->FID_6_FNT, "6.FNT"); + _screen->loadFont(_screen->FID_8_FNT, "8FAT.FNT"); + _screen->loadFont(_screen->FID_GOLDFONT_FNT, "GOLDFONT.FNT"); + _screen->loadFont(_screen->FID_BOOKFONT_FNT, "BOOKFONT.FNT"); + _screen->setAnimBlockPtr(3504); _screen->setScreenDim(0); assert(_introStringsSize == 21); @@ -76,11 +101,11 @@ int KyraEngine_v2::init() { assert(_mouseSHPBuf); for (int i = 0; i < 2; i++) { - _gameShapes[i] = _screen->getPtrToShape(_mouseSHPBuf, i); - assert(_gameShapes[i]); + _defaultShapeTable[i] = _screen->getPtrToShape(_mouseSHPBuf, i); + assert(_defaultShapeTable[i]); } - _screen->setMouseCursor(0, 0, _gameShapes[0]); + _screen->setMouseCursor(0, 0, _defaultShapeTable[0]); return 0; } @@ -105,14 +130,14 @@ int KyraEngine_v2::go() { _res->unloadPakFile("OUTFARM.PAK"); _res->unloadPakFile("FLYTRAP.PAK"); - seq_playSequences(kSequenceVirgin, kSequenceWestwood); + //seq_playSequences(kSequenceVirgin, kSequenceWestwood); mainMenu(); return 0; } void KyraEngine_v2::mainMenu() { - bool running = true; + /*bool running = true; while (running && !_quitFlag) { seq_playSequences(kSequenceTitle); @@ -120,6 +145,11 @@ void KyraEngine_v2::mainMenu() { switch (gui_handleMainMenu()) { case 0: + _screen->showMouse();*/ + startup(); + runLoop(); + cleanup(); + /*running = false; break; case 1: seq_playSequences(kSequenceOverview, kSequenceZanFaun); @@ -133,7 +163,1130 @@ void KyraEngine_v2::mainMenu() { break; } _screen->hideMouse(); - } + }*/ +} + +void KyraEngine_v2::startup() { + _screen->_curPage = 0; + delete [] _mouseSHPBuf; + _mouseSHPBuf = 0; + + memset(_defaultShapeTable, 0, sizeof(_defaultShapeTable)); + memset(_sceneShapeTable, 0, sizeof(_sceneShapeTable)); + _gamePlayBuffer = new uint8[46080]; + _unkBuf500Bytes = new uint8[500]; + + loadMouseShapes(); + loadItemShapes(); + + _screen->setMouseCursor(0, 0, getShapePtr(0)); + + _screenBuffer = new uint8[64000]; + + loadCCodeBuffer("C_CODE.XXX"); + loadOptionsBuffer("OPTIONS.XXX"); + loadChapterBuffer(_newChapterFile); + + _unkBuf200kByte = new uint8[200000]; + + showMessageFromCCode(265, 150, 0); + + // XXX + + showMessageFromCCode(0, 0, 207); + + // XXX + + _screen->setShapePages(5, 3); + + memset(&_mainCharacter, 0, sizeof(_mainCharacter)); + _mainCharacter.height = 0x30; + _mainCharacter.facing = 4; + _mainCharacter.animFrame = 0x12; + memset(_mainCharacter.inventory, -1, sizeof(_mainCharacter.inventory)); + + memset(_sceneAnims, 0, sizeof(_sceneAnims)); + for (int i = 0; i < ARRAYSIZE(_sceneAnimMovie); ++i) + _sceneAnimMovie[i] = new WSAMovieV2(this); + memset(_wsaSlots, 0, sizeof(_wsaSlots)); + for (int i = 0; i < ARRAYSIZE(_wsaSlots); ++i) + _wsaSlots[i] = new WSAMovieV2(this); + + _maskPage = 0;//_screen->getPagePtr(5); + _screen->_curPage = 0; + + _objectList = new Object[72]; + memset(_objectList, 0, sizeof(Object)*72); + _shapeDescTable = new ShapeDesc[55]; + memset(_shapeDescTable, 0, sizeof(ShapeDesc)*55); + + for (int i = 9; i <= 32; ++i) { + _shapeDescTable[i-9].unk5 = 30; + _shapeDescTable[i-9].unk7 = 55; + _shapeDescTable[i-9].xAdd = -15; + _shapeDescTable[i-9].yAdd = -50; + } + + for (int i = 19; i <= 24; ++i) { + _shapeDescTable[i-9].unk7 = 53; + _shapeDescTable[i-9].yAdd = -51; + } + + _gfxBackUpRect = new uint8[_screen->getRectSize(32, 32)]; + _itemList = new Item[30]; + resetItemList(); + //loadButtonShapes(); + _loadedZTable = 1; + loadZShapes(_loadedZTable); + loadInventoryShapes(); + + _res->loadFileToBuf("PALETTE.COL", _screen->_currentPalette, 0x300); + _screen->loadBitmap("_PLAYFLD.CPS", 3, 3, 0); + _screen->copyPage(3, 0); + _screen->showMouse(); + _screen->hideMouse(); + + clearAnimObjects(); + + // XXX + + _sceneList = new SceneDesc[86]; + runStartScript(1, 0); + loadNPCScript(); + + // XXX + + enterNewScene(_mainCharacter.sceneId, _mainCharacter.facing, 0, 0, 1); + _screen->showMouse(); + + //sub_20EE8(1); + //setNextIdleAnimTimer(); + //XXX + _timer->setDelay(0, 5); +} + +void KyraEngine_v2::runLoop() { + _screen->updateScreen(); + + _quitFlag = false; + while (!_quitFlag) { + //XXX + int inputFlag = checkInput(0/*dword_324C5*/); + update(); + if (inputFlag == 198 || inputFlag == 199) { + _unk3 = _handItemSet; + Common::Point mouse = getMousePos(); + handleInput(mouse.x, mouse.y); + } + //XXX + } +} + +void KyraEngine_v2::handleInput(int x, int y) { + //setNextIdleAnimTimer(); + if (_unk5) { + _unk5 = 0; + return; + } + + if (!_screen->isMouseVisible()) + return; + + if (_unk3 == -2) { + //snd_playSfx(13); + return; + } + + //setNextIdleAnimTimer(); + + if (x <= 6 || x >= 312 || y <= 6 || y >= 135) { + bool exitOk = false; + assert(_unk3 + 6 >= 0); + switch (_unk3 + 6) { + case 0: + if (_sceneExit1 != 0xFFFF) + exitOk = true; + break; + + case 1: + if (_sceneExit2 != 0xFFFF) + exitOk = true; + break; + + case 2: + if (_sceneExit3 != 0xFFFF) + exitOk = true; + break; + + case 3: + if (_sceneExit4 != 0xFFFF) + exitOk = true; + break; + + default: + break; + } + + if (exitOk) { + inputSceneChange(x, y, 1, 1); + return; + } + } + + if (checkCharCollision(x, y) >= 0 && _unk3 >= -1) { + runSceneScript2(); + return; + } else { + //XXX + } + + //XXX + + inputSceneChange(x, y, 1, 1); +} + +int KyraEngine_v2::update() { + refreshAnimObjectsIfNeed(); + updateMouse(); + updateSpecialSceneScripts(); + _timer->update(); + //sub_274C0(); + //updateInvWsa(); + //sub_1574C(); + //XXX + _screen->updateScreen(); + return 0; +} + +void KyraEngine_v2::updateMouse() { + int shapeIndex = 0; + int type = 0; + int xOffset = 0, yOffset = 0; + Common::Point mouse = getMousePos(); + + if (mouse.y <= 145) { + if (mouse.x <= 6) { + if (_sceneExit4 != 0xFFFF) { + type = -3; + shapeIndex = 4; + xOffset = 1; + yOffset = 5; + } else { + type = -2; + } + } else if (mouse.x >= 312) { + if (_sceneExit2 != 0xFFFF) { + type = -5; + shapeIndex = 2; + xOffset = 7; + yOffset = 5; + } else { + type = -2; + } + } else if (mouse.y >= 135) { + if (_sceneExit3 != 0xFFFF) { + type = -4; + shapeIndex = 3; + xOffset = 5; + yOffset = 10; + } else { + type = -2; + } + } else if (mouse.y <= 6) { + if (_sceneExit1 != 0xFFFF) { + type = -6; + shapeIndex = 1; + xOffset = 5; + yOffset = 1; + } else { + type = -2; + } + } + } + + for (int i = 0; i < _specialExitCount; ++i) { + if (checkSpecialSceneExit(i, mouse.x, mouse.y)) { + switch (_specialExitTable[20+i]) { + case 0: + type = -6; + shapeIndex = 1; + xOffset = 5; + yOffset = 1; + break; + + case 2: + type = -5; + shapeIndex = 2; + xOffset = 7; + yOffset = 5; + break; + + case 4: + type = -4; + shapeIndex = 3; + xOffset = 5; + yOffset = 7; + break; + + case 6: + type = -3; + shapeIndex = 4; + xOffset = 1; + yOffset = 5; + break; + + default: + break; + } + } + } + + if (type == -2) { + shapeIndex = 5; + xOffset = 5; + yOffset = 9; + } + + if (type != 0 && _handItemSet != type) { + _handItemSet = type; + _screen->hideMouse(); + _screen->setMouseCursor(xOffset, yOffset, getShapePtr(shapeIndex)); + _screen->showMouse(); + } + + if (type == 0 && _handItemSet != _itemInHand) { + if ((mouse.y > 145) || (mouse.x > 6 && mouse.x < 312 && mouse.y > 6 && mouse.y < 135)) { + _handItemSet = _itemInHand; + _screen->hideMouse(); + if (_itemInHand == -1) + _screen->setMouseCursor(0, 0, getShapePtr(0)); + else + _screen->setMouseCursor(8, 15, getShapePtr(_itemInHand+64)); + _screen->showMouse(); + } + } +} + +int KyraEngine_v2::checkInput(void *p) { + Common::Event event; + int keys = 0; + while (_eventMan->pollEvent(event)) { + switch (event.type) { + case Common::EVENT_KEYDOWN: + if (event.kbd.keycode == Common::KEYCODE_RETURN) + keys = 199; + break; + + case Common::EVENT_LBUTTONUP: + keys = 198; + break; + + case Common::EVENT_QUIT: + _quitFlag = true; + break; + + default: + break; + } + + //if ( _debugger->isAttached()) + // _debugger->onFrame(); + } + + _system->delayMillis(10); + return keys; +} + +void KyraEngine_v2::cleanup() { + delete [] _gamePlayBuffer; + delete [] _unkBuf500Bytes; + delete [] _screenBuffer; + delete [] _unkBuf200kByte; + + for (int i = 0; i < ARRAYSIZE(_defaultShapeTable); ++i) + delete [] _defaultShapeTable[i]; + freeSceneShapePtrs(); + + delete [] _cCodeBuffer; + delete [] _optionsBuffer; + delete [] _chapterBuffer; + + delete [] _objectList; + delete [] _shapeDescTable; + + delete [] _gfxBackUpRect; + + delete [] _sceneList; + + for (int i = 0; i < ARRAYSIZE(_sceneAnimMovie); ++i) + delete _sceneAnimMovie[i]; + for (int i = 0; i < ARRAYSIZE(_wsaSlots); ++i) + delete _wsaSlots[i]; +} + +#pragma mark - Localization + +void KyraEngine_v2::loadCCodeBuffer(const char *file) { + char tempString[13]; + strcpy(tempString, file); + changeFileExtension(tempString); + + delete [] _cCodeBuffer; + _cCodeBuffer = _res->fileData(tempString, 0); +} + +void KyraEngine_v2::loadOptionsBuffer(const char *file) { + char tempString[13]; + strcpy(tempString, file); + changeFileExtension(tempString); + + delete [] _optionsBuffer; + _optionsBuffer = _res->fileData(tempString, 0); +} + +void KyraEngine_v2::loadChapterBuffer(int chapter) { + char tempString[14]; + + static const char *chapterFilenames[] = { + "CH1.XXX", "CH2.XXX", "CH3.XXX", "CH4.XXX", "CH5.XXX" + }; + + assert(chapter >= 1 && chapter <= ARRAYSIZE(chapterFilenames)); + strcpy(tempString, chapterFilenames[chapter-1]); + changeFileExtension(tempString); + + delete [] _chapterBuffer; + _chapterBuffer = _res->fileData(tempString, 0); + _currentChapter = chapter; +} + +void KyraEngine_v2::changeFileExtension(char *buffer) { + while (*buffer != '.') ++buffer; + + ++buffer; + strcpy(buffer, _languageExtension[_lang]); +} + +const uint8 *KyraEngine_v2::getTableEntry(const uint8 *buffer, int id) { + return buffer + READ_LE_UINT16(buffer + (id<<1)); +} + +const char *KyraEngine_v2::getTableString(int id, const uint8 *buffer, int decode) { + const char *string = (const char*)getTableEntry(buffer, id); + + if (decode) { + decodeString1(string, _internStringBuf); + decodeString2(_internStringBuf, _internStringBuf); + string = _internStringBuf; + } + + return string; +} + +const char *KyraEngine_v2::getChapterString(int id) { + if (_currentChapter != _newChapterFile) + loadChapterBuffer(_newChapterFile); + + return getTableString(id, _chapterBuffer, 1); +} + +int KyraEngine_v2::decodeString1(const char *src, char *dst) { + static const uint8 decodeTable1[] = { + 0x20, 0x65, 0x74, 0x61, 0x69, 0x6E, 0x6F, 0x73, 0x72, 0x6C, 0x68, + 0x63, 0x64, 0x75, 0x70, 0x6D + }; + + static const uint8 decodeTable2[] = { + 0x74, 0x61, 0x73, 0x69, 0x6F, 0x20, 0x77, 0x62, 0x20, 0x72, 0x6E, + 0x73, 0x64, 0x61, 0x6C, 0x6D, 0x68, 0x20, 0x69, 0x65, 0x6F, 0x72, + 0x61, 0x73, 0x6E, 0x72, 0x74, 0x6C, 0x63, 0x20, 0x73, 0x79, 0x6E, + 0x73, 0x74, 0x63, 0x6C, 0x6F, 0x65, 0x72, 0x20, 0x64, 0x74, 0x67, + 0x65, 0x73, 0x69, 0x6F, 0x6E, 0x72, 0x20, 0x75, 0x66, 0x6D, 0x73, + 0x77, 0x20, 0x74, 0x65, 0x70, 0x2E, 0x69, 0x63, 0x61, 0x65, 0x20, + 0x6F, 0x69, 0x61, 0x64, 0x75, 0x72, 0x20, 0x6C, 0x61, 0x65, 0x69, + 0x79, 0x6F, 0x64, 0x65, 0x69, 0x61, 0x20, 0x6F, 0x74, 0x72, 0x75, + 0x65, 0x74, 0x6F, 0x61, 0x6B, 0x68, 0x6C, 0x72, 0x20, 0x65, 0x69, + 0x75, 0x2C, 0x2E, 0x6F, 0x61, 0x6E, 0x73, 0x72, 0x63, 0x74, 0x6C, + 0x61, 0x69, 0x6C, 0x65, 0x6F, 0x69, 0x72, 0x61, 0x74, 0x70, 0x65, + 0x61, 0x6F, 0x69, 0x70, 0x20, 0x62, 0x6D + }; + + int size = 0; + uint cChar = 0; + while ((cChar = *src++) != 0) { + if (cChar & 0x80) { + cChar &= 0x7F; + int index = (cChar & 0x78) >> 3; + *dst++ = decodeTable1[index]; + ++size; + assert(cChar < sizeof(decodeTable2)); + cChar = decodeTable2[cChar]; + } + + *dst++ = cChar; + ++size; + } + + *dst++ = 0; + return size; +} + +void KyraEngine_v2::decodeString2(const char *src, char *dst) { + if (!src || !dst) + return; + + char out = 0; + while ((out = *src) != 0) { + if (*src == 0x1B) { + ++src; + out = *src + 0x7F; + } + *dst++ = out; + ++src; + } + + *dst = 0; +} + +#pragma mark - + +void KyraEngine_v2::showMessageFromCCode(int id, int16 palIndex, int) { + const char *string = getTableString(id, _cCodeBuffer, 1); + showMessage(string, palIndex); +} + +void KyraEngine_v2::showMessage(const char *string, int16 palIndex) { + _shownMessage = string; + _screen->hideMouse(); + _screen->fillRect(0, 190, 319, 199, 0xCF); + + if (string) { + if (palIndex != -1 || _msgUnk1) { + palIndex *= 3; + memcpy(_messagePal, _screen->_currentPalette + palIndex, 3); + memmove(_screen->_currentPalette + 765, _screen->_currentPalette + palIndex, 3); + _screen->setScreenPalette(_screen->_currentPalette); + } + + int x = _text->getCenterStringX(string, 0, 320); + _text->printText(string, x, 190, 255, 207, 0); + + setTimer1DelaySecs(7); + } + + _msgUnk1 = 0; + _screen->showMouse(); +} + +void KyraEngine_v2::showChapterMessage(int id, int16 palIndex) { + showMessage(getChapterString(id), palIndex); +} + +void KyraEngine_v2::loadMouseShapes() { + _screen->loadBitmap("_MOUSE.CSH", 3, 3, 0); + + for (int i = 0; i <= 8; ++i) { + _defaultShapeTable[i] = _screen->makeShapeCopy(_screen->getCPagePtr(3), i); + assert(_defaultShapeTable[i]); + } +} + +void KyraEngine_v2::loadItemShapes() { + _screen->loadBitmap("_ITEMS.CSH", 3, 3, 0); + + for (int i = 64; i <= 239; ++i) { + _defaultShapeTable[i] = _screen->makeShapeCopy(_screen->getCPagePtr(3), i-64); + assert(_defaultShapeTable[i]); + } + + _res->loadFileToBuf("_ITEMHT.DAT", _itemHtDat, sizeof(_itemHtDat)); + assert(_res->getFileSize("_ITEMHT.DAT") == sizeof(_itemHtDat)); + + _screen->_curPage = 0; +} + +void KyraEngine_v2::loadZShapes(int shapes) { + char file[10]; + strcpy(file, "_ZX.SHP"); + + _loadedZTable = shapes; + file[2] = '0' + shapes; + + uint8 *data = _res->fileData(file, 0); + for (int i = 9; i <= 32; ++i) { + delete [] _defaultShapeTable[i]; + _defaultShapeTable[i] = _screen->makeShapeCopy(data, i-9); + } + delete [] data; + + _loadedZTable = shapes; +} + +void KyraEngine_v2::loadInventoryShapes() { + int curPageBackUp = _screen->_curPage; + _screen->_curPage = 2; + + _screen->loadBitmap("_PLAYALL.CPS", 3, 3, 0); + + for (int i = 0; i < 10; ++i) + _defaultShapeTable[240+i] = _screen->encodeShape(_inventoryX[i], _inventoryY[i], 16, 16, 0); + + _screen->_curPage = curPageBackUp; +} + +void KyraEngine_v2::runStartScript(int script, int unk1) { + char filename[14]; + strcpy(filename, "_START0X.EMC"); + filename[7] = script + '0'; + + ScriptData scriptData; + ScriptState scriptState; + + _scriptInterpreter->loadScript(filename, &scriptData, &_opcodes); + _scriptInterpreter->initScript(&scriptState, &scriptData); + scriptState.regs[6] = unk1; + _scriptInterpreter->startScript(&scriptState, 0); + while (_scriptInterpreter->validScript(&scriptState)) + _scriptInterpreter->runScript(&scriptState); + _scriptInterpreter->unloadScript(&scriptData); +} + +void KyraEngine_v2::loadNPCScript() { + char filename[12]; + strcpy(filename, "_NPC.EMC"); + + switch (_lang) { + case 0: + filename[5] = 'E'; + break; + + case 1: + filename[5] = 'F'; + break; + + case 2: + filename[5] = 'G'; + break; + + default: + break; + }; + + _scriptInterpreter->loadScript(filename, &_npcScriptData, &_opcodes); +} + +void KyraEngine_v2::resetScaleTable() { + for (int i = 0; i < ARRAYSIZE(_scaleTable); ++i) + _scaleTable[i] = 0x100; +} + +void KyraEngine_v2::setScaleTableItem(int item, int data) { + if (item >= 1 || item <= 15) + _scaleTable[item-1] = (data << 8) / 100; +} + +int KyraEngine_v2::getScale(int x, int y) { + return _scaleTable[_screen->getLayer(x, y) - 1]; +} + +void KyraEngine_v2::setDrawLayerTableEntry(int entry, int data) { + if (entry >= 1 || entry <= 15) + _drawLayerTable[entry-1] = data; +} + +int KyraEngine_v2::getDrawLayer(int x, int y) { + int layer = _screen->getLayer(x, y); + layer = _drawLayerTable[layer-1]; + if (layer < 0) + layer = 0; + else if (layer >= 7) + layer = 6; + return layer; +} + +void KyraEngine_v2::restorePage3() { + _screen->copyBlockToPage(2, 0, 0, 320, 144, _gamePlayBuffer); +} + +void KyraEngine_v2::updateCharPal(int unk1) { + static bool unkVar1 = false; + + if (!_useCharPal) + return; + + int layer = _screen->getLayer(_mainCharacter.x1, _mainCharacter.y1); + int palEntry = _charPalTable[layer]; + + if (palEntry != _charPalEntry && unk1) { + const uint8 *src = &_scenePal[(palEntry << 4) * 3]; + uint8 *ptr = _screen->getPalette(0) + 336; + for (int i = 0; i < 48; ++i) { + *ptr -= (*ptr - *src) >> 1; + ++ptr; + ++src; + } + _screen->setScreenPalette(_screen->getPalette(0)); + unkVar1 = true; + _charPalEntry = palEntry; + } else if (unkVar1 && !unk1) { + memcpy(_screen->getPalette(0) + 336, &_scenePal[(palEntry << 4) * 3], 48); + _screen->setScreenPalette(_screen->getPalette(0)); + unkVar1 = false; + } +} + +int KyraEngine_v2::inputSceneChange(int x, int y, int unk1, int unk2) { + bool refreshNPC = false; + uint16 curScene = _mainCharacter.sceneId; + _pathfinderFlag = 15; + + if (!_unkHandleSceneChangeFlag) { + if (_unk3 == -3) { + if (_sceneList[curScene].exit4 != 0xFFFF) { + x = 4; + y = _sceneEnterY4; + _pathfinderFlag = 7; + } + } else if (_unk3 == -5) { + if (_sceneList[curScene].exit2 != 0xFFFF) { + x = 316; + y = _sceneEnterY2; + _pathfinderFlag = 7; + } + } else if (_unk3 == -6) { + if (_sceneList[curScene].exit1 != 0xFFFF) { + x = _sceneEnterX1; + y = _sceneEnterY1 - 2; + _pathfinderFlag = 14; + } + } else if (_unk3 == -4) { + if (_sceneList[curScene].exit3 != 0xFFFF) { + x = _sceneEnterX3; + y = 147; + _pathfinderFlag = 11; + } + } + } + + if (_pathfinderFlag) { + if (findItem(curScene, 13) >= 0 && _unk3 <= -3) { + //XXX + _pathfinderFlag = 0; + return 0; + } else if (_itemInHand == 72) { + //XXX + _pathfinderFlag = 0; + return 0; + } else if (findItem(curScene, 72) >= 0 && _unk3 <= -3) { + //XXX + _pathfinderFlag = 0; + return 0; + } else if (0/*XXX*/) { + //XXX + _pathfinderFlag = 0; + return 0; + } + } + + if (ABS(_mainCharacter.x1 - x) < 4 || ABS(_mainCharacter.y1 - y) < 2) + return 0; + + int curX = _mainCharacter.x1 & ~3; + int curY = _mainCharacter.y1 & ~1; + int dstX = x & ~3; + int dstY = y & ~1; + + int wayLength = findWay(curX, curY, dstX, dstY, _movFacingTable, 600); + _pathfinderFlag = 0; + _timer->disable(5); + + if (wayLength != 0 && wayLength != 0x7D00) + refreshNPC = trySceneChange(_movFacingTable, unk1, unk2); + + //XXX + + if (refreshNPC) + enterNewSceneUnk2(0); + + _pathfinderFlag = 0; + return refreshNPC; +} + +bool KyraEngine_v2::checkSpecialSceneExit(int num, int x, int y) { + if (_specialExitTable[0+num] > x || _specialExitTable[5+num] > y || + _specialExitTable[10+num] < x || _specialExitTable[15+num] < y) + return 0; + return 1; +} + +void KyraEngine_v2::moveCharacter(int facing, int x, int y) { + _mainCharacter.facing = facing; + x &= ~3; + y &= ~1; + + _screen->hideMouse(); + switch (facing) { + case 0: + while (y < _mainCharacter.y1) + updateCharPosWithUpdate(); + break; + + case 2: + while (_mainCharacter.x1 < x) + updateCharPosWithUpdate(); + break; + + case 4: + while (y > _mainCharacter.y1) + updateCharPosWithUpdate(); + break; + + case 6: + while (_mainCharacter.x1 > x) + updateCharPosWithUpdate(); + break; + + default: + break; + } + + _screen->showMouse(); +} + +int KyraEngine_v2::updateCharPos(int *table) { + static uint32 nextUpdate = 0; + static const int updateX[] = { 0, 4, 4, 4, 0, -4, -4, -4 }; + static const int updateY[] = { -2, -2, 0, 2, 2, 2, 0, -2 }; + + if (_system->getMillis() < nextUpdate) + return 0; + + int facing = _mainCharacter.facing; + _mainCharacter.x1 += updateX[facing]; + _mainCharacter.y1 += updateY[facing]; + updateCharAnimFrame(0, table); + nextUpdate = _system->getMillis() + _timer->getDelay(0) * _tickLength; + return 1; +} + +void KyraEngine_v2::updateCharPosWithUpdate() { + updateCharPos(0); + update(); +} + +void KyraEngine_v2::updateCharAnimFrame(int charId, int *table) { + static int unkTable1[] = { 0, 0 }; + static const int unkTable2[] = { 17, 0 }; + static const int unkTable3[] = { 10, 0 }; + static const int unkTable4[] = { 24, 0 }; + static const int unkTable5[] = { 19, 0 }; + static const int unkTable6[] = { 21, 0 }; + static const int unkTable7[] = { 31, 0 }; + static const int unkTable8[] = { 26, 0 }; + + Character *character = &_mainCharacter; + ++character->animFrame; + int facing = character->facing; + + if (table) { + if (table[0] != table[-1] && table[-1] == table[1]) { + facing = getOppositeFacingDirection(table[-1]); + table[0] = table[-1]; + } + } + + if (!facing) { + ++unkTable1[charId]; + } else if (facing == 4) { + ++unkTable1[charId+1]; + } else if (facing == 7 || facing == 1 || facing == 5 || facing == 3) { + if (facing == 7 || facing == 1) { + if (unkTable1[charId] > 2) + facing = 0; + } else { + if (unkTable1[charId+1] > 2) + facing = 4; + } + + unkTable1[charId] = 0; + unkTable1[charId+1] = 0; + } + + if (facing == 0) { + if (character->animFrame < unkTable8[charId]) + character->animFrame = unkTable8[charId]; + + if (character->animFrame > unkTable7[charId]) + character->animFrame = unkTable8[charId]; + } else if (facing == 4) { + if (character->animFrame < unkTable5[charId]) + character->animFrame = unkTable5[charId]; + + if (character->animFrame > unkTable4[charId]) + character->animFrame = unkTable5[charId]; + } else { + if (character->animFrame > unkTable5[charId]) + character->animFrame = unkTable6[charId]; + + if (character->animFrame == unkTable2[charId]) + character->animFrame = unkTable3[charId]; + + if (character->animFrame > unkTable2[charId]) + character->animFrame = unkTable3[charId] + 2; + } + + updateCharacterAnim(charId); +} + +int KyraEngine_v2::checkCharCollision(int x, int y) { + int scale1 = 0, scale2 = 0, scale3 = 0; + int x1 = 0, x2 = 0, y1 = 0, y2 = 0; + scale1 = getScale(_mainCharacter.x1, _mainCharacter.y1); + scale2 = (scale1 * 24) >> 8; + scale3 = (scale1 * 48) >> 8; + + x1 = _mainCharacter.x1 - (scale2 >> 1); + x2 = _mainCharacter.x1 + (scale2 >> 1); + y1 = _mainCharacter.y1 - scale3; + y2 = _mainCharacter.y1; + + if (x >= x1 && x <= x2 && y >= y1 && y <= y2) + return 0; + + return -1; +} + +#pragma mark - + +typedef Functor1Mem OpcodeV2; +#define Opcode(x) OpcodeV2(this, &KyraEngine_v2::x) +#define OpcodeUnImpl() OpcodeV2(this, 0) +void KyraEngine_v2::setupOpcodeTable() { + static const OpcodeV2 opcodeTable[] = { + // 0x00 + Opcode(o2_setCharacterFacingRefresh), + OpcodeUnImpl(), + Opcode(o2_defineObject), + Opcode(o2_refreshCharacter), + // 0x04 + Opcode(o2_getCharacterX), + Opcode(o2_getCharacterY), + Opcode(o2_getCharacterFacing), + OpcodeUnImpl(), + // 0x08 + Opcode(o2_setSceneComment), + OpcodeUnImpl(), + OpcodeUnImpl(), + OpcodeUnImpl(), + // 0x0c + OpcodeUnImpl(), + OpcodeUnImpl(), + OpcodeUnImpl(), + OpcodeUnImpl(), + // 0x10 + OpcodeUnImpl(), + Opcode(o2_showChapterMessage), + OpcodeUnImpl(), + OpcodeUnImpl(), + // 0x14 + Opcode(o2_wsaClose), + OpcodeUnImpl(), + OpcodeUnImpl(), + Opcode(o2_displayWsaFrame), + // 0x18 + Opcode(o2_displayWsaSequentialFrames), + Opcode(o2_wsaOpen), + OpcodeUnImpl(), + OpcodeUnImpl(), + // 0x1c + OpcodeUnImpl(), + OpcodeUnImpl(), + OpcodeUnImpl(), + OpcodeUnImpl(), + // 0x20 + OpcodeUnImpl(), + OpcodeUnImpl(), + OpcodeUnImpl(), + Opcode(o2_defineItem), + // 0x24 + OpcodeUnImpl(), + OpcodeUnImpl(), + OpcodeUnImpl(), + Opcode(o2_queryGameFlag), + // 0x28 + Opcode(o2_resetGameFlag), + Opcode(o2_setGameFlag), + OpcodeUnImpl(), + OpcodeUnImpl(), + // 0x2c + OpcodeUnImpl(), + Opcode(o2_hideMouse), + Opcode(o2_addSpecialExit), + OpcodeUnImpl(), + // 0x30 + Opcode(o2_showMouse), + OpcodeUnImpl(), + OpcodeUnImpl(), + OpcodeUnImpl(), + // 0x34 + OpcodeUnImpl(), + OpcodeUnImpl(), + OpcodeUnImpl(), + OpcodeUnImpl(), + // 0x38 + Opcode(o2_dummy), + OpcodeUnImpl(), + Opcode(o2_setScaleTableItem), + Opcode(o2_setDrawLayerTableItem), + // 0x3c + OpcodeUnImpl(), + OpcodeUnImpl(), + OpcodeUnImpl(), + Opcode(o2_drawSceneShapeOnPage), + // 0x40 + OpcodeUnImpl(), + OpcodeUnImpl(), + Opcode(o2_dummy), + OpcodeUnImpl(), + // 0x44 + OpcodeUnImpl(), + Opcode(o2_restoreBackBuffer), + OpcodeUnImpl(), + OpcodeUnImpl(), + // 0x48 + OpcodeUnImpl(), + OpcodeUnImpl(), + OpcodeUnImpl(), + OpcodeUnImpl(), + // 0x4c + OpcodeUnImpl(), + OpcodeUnImpl(), + Opcode(o2_dummy), + Opcode(o2_dummy), + // 0x50 + OpcodeUnImpl(), + OpcodeUnImpl(), + OpcodeUnImpl(), + OpcodeUnImpl(), + // 0x54 + OpcodeUnImpl(), + OpcodeUnImpl(), + OpcodeUnImpl(), + OpcodeUnImpl(), + // 0x58 + OpcodeUnImpl(), + OpcodeUnImpl(), + OpcodeUnImpl(), + OpcodeUnImpl(), + // 0x5c + OpcodeUnImpl(), + OpcodeUnImpl(), + OpcodeUnImpl(), + OpcodeUnImpl(), + // 0x60 + Opcode(o2_getRand), + OpcodeUnImpl(), + OpcodeUnImpl(), + OpcodeUnImpl(), + // 0x64 + OpcodeUnImpl(), + OpcodeUnImpl(), + OpcodeUnImpl(), + OpcodeUnImpl(), + // 0x68 + OpcodeUnImpl(), + OpcodeUnImpl(), + OpcodeUnImpl(), + OpcodeUnImpl(), + // 0x6c + Opcode(o2_encodeShape), + Opcode(o2_defineRoomEntrance), + OpcodeUnImpl(), + Opcode(o2_setSpecialSceneScriptRunTime), + // 0x70 + Opcode(o2_defineSceneAnim), + Opcode(o2_updateSceneAnim), + Opcode(o2_updateSceneAnim), + OpcodeUnImpl(), + // 0x74 + OpcodeUnImpl(), + OpcodeUnImpl(), + OpcodeUnImpl(), + OpcodeUnImpl(), + // 0x78 + OpcodeUnImpl(), + Opcode(o2_defineRoom), + OpcodeUnImpl(), + OpcodeUnImpl(), + // 0x7c + OpcodeUnImpl(), + Opcode(o2_dummy), + Opcode(o2_dummy), + OpcodeUnImpl(), + // 0x80 + OpcodeUnImpl(), + OpcodeUnImpl(), + OpcodeUnImpl(), + OpcodeUnImpl(), + // 0x84 + OpcodeUnImpl(), + OpcodeUnImpl(), + OpcodeUnImpl(), + OpcodeUnImpl(), + // 0x88 + OpcodeUnImpl(), + OpcodeUnImpl(), + OpcodeUnImpl(), + OpcodeUnImpl(), + // 0x8c + OpcodeUnImpl(), + OpcodeUnImpl(), + OpcodeUnImpl(), + Opcode(o2_setSpecialSceneScriptState), + // 0x90 + Opcode(o2_clearSpecialSceneScriptState), + Opcode(o2_querySpecialSceneScriptState), + OpcodeUnImpl(), + OpcodeUnImpl(), + // 0x94 + OpcodeUnImpl(), + OpcodeUnImpl(), + Opcode(o2_wsaClose), + OpcodeUnImpl(), + // 0x98 + OpcodeUnImpl(), + OpcodeUnImpl(), + OpcodeUnImpl(), + OpcodeUnImpl(), + // 0x9c + OpcodeUnImpl(), + OpcodeUnImpl(), + OpcodeUnImpl(), + OpcodeUnImpl(), + // 0xa0 + OpcodeUnImpl(), + OpcodeUnImpl(), + OpcodeUnImpl(), + OpcodeUnImpl(), + // 0xa4 + OpcodeUnImpl(), + OpcodeUnImpl(), + OpcodeUnImpl(), + OpcodeUnImpl(), + // 0xa8 + OpcodeUnImpl(), + OpcodeUnImpl(), + OpcodeUnImpl(), + OpcodeUnImpl(), + // 0xac + OpcodeUnImpl(), + OpcodeUnImpl(), + Opcode(o2_dummy), + Opcode(o2_dummy), + }; + + for (int i = 0; i < ARRAYSIZE(opcodeTable); ++i) + _opcodes.push_back(&opcodeTable[i]); } } // end of namespace Kyra diff --git a/engines/kyra/kyra_v2.h b/engines/kyra/kyra_v2.h index df73118376..fb8fd2c454 100644 --- a/engines/kyra/kyra_v2.h +++ b/engines/kyra/kyra_v2.h @@ -27,6 +27,7 @@ #define KYRA_KYRA_V2_H #include "kyra/kyra.h" +#include "kyra/script.h" #include "kyra/screen_v2.h" namespace Kyra { @@ -87,7 +88,7 @@ public: ~KyraEngine_v2(); virtual Screen *screen() { return _screen; } - Screen *screen_v2() { return _screen; } + Screen_v2 *screen_v2() { return _screen; } Movie *createWSAMovie(); protected: @@ -103,8 +104,7 @@ protected: void gui_printString(const char *string, int x, int y, int col1, int col2, int flags, ...); - void setupOpcodeTable() {} - + // intro void seq_playSequences(int startSeq, int endSeq = -1); int seq_introWestwood(int seqNum); int seq_introTitle(int seqNum); @@ -136,7 +136,6 @@ protected: ActiveWSA *_activeWSA; ActiveChat *_activeChat; - uint8 *_gameShapes[50]; uint8 *_mouseSHPBuf; static const char *_introSoundList[]; @@ -145,6 +144,351 @@ protected: static const int _introStringsSize; int _introStringsDuration[21]; + +protected: + // game initialization + void startup(); + void runLoop(); + void cleanup(); + + void setupTimers(); + void setupOpcodeTable(); + + void loadMouseShapes(); + void loadItemShapes(); + + // run + int update(); + void updateMouse(); + + int checkInput(void *p); + void handleInput(int x, int y); + + int inputSceneChange(int x, int y, int unk1, int unk2); + + // gfx/animation specific + uint8 *_gamePlayBuffer; + void restorePage3(); + + uint8 *_screenBuffer; + uint8 *_maskPage; + uint8 *_gfxBackUpRect; + + uint8 *getShapePtr(int index) { return _defaultShapeTable[index]; } + uint8 *_defaultShapeTable[250]; + uint8 *_sceneShapeTable[50]; + + WSAMovieV2 *_wsaSlots[10]; + + void freeSceneShapePtrs(); + + struct ShapeDesc { + uint8 unk0, unk1, unk2, unk3, unk4; + uint16 unk5, unk7; + int16 xAdd, yAdd; + }; + + ShapeDesc *_shapeDescTable; + + struct SceneAnim { + uint16 flags; + int16 x, y; + int16 x2, y2; + int16 width, height; + uint16 unkE; + uint16 specialSize; + uint16 unk12; + int16 shapeIndex; + uint16 wsaFlag; + char filename[14]; + }; + + SceneAnim _sceneAnims[10]; + WSAMovieV2 *_sceneAnimMovie[10]; + bool _specialSceneScriptState[10]; + ScriptState _sceneSpecialScripts[10]; + uint32 _sceneSpecialScriptsTimer[10]; + int _lastProcessedSceneScript; + bool _specialSceneScriptRunFlag; + + void updateSpecialSceneScripts(); + void freeSceneAnims(); + + int _loadedZTable; + void loadZShapes(int shapes); + void loadInventoryShapes(); + + void resetScaleTable(); + void setScaleTableItem(int item, int data); + int getScale(int x, int y); + uint16 _scaleTable[15]; + + void setDrawLayerTableEntry(int entry, int data); + int getDrawLayer(int x, int y); + int _drawLayerTable[15]; + + // animator + struct AnimObj { + uint16 index; + uint16 type; + uint16 enabled; + uint16 needRefresh; + uint16 unk8; + uint16 animFlags; + uint16 flags; + int16 xPos1, yPos1; + uint8 *shapePtr; + uint16 shapeIndex1; + uint16 animNum; + uint16 shapeIndex3; + uint16 shapeIndex2; + uint16 unk1E; + uint8 unk20; + uint8 unk21; + uint8 unk22; + uint8 unk23; + int16 xPos2, yPos2; + int16 xPos3, yPos3; + int16 width, height; + int16 width2, height2; + AnimObj *nextObject; + }; + + AnimObj _animObjects[42]; + void clearAnimObjects(); + + AnimObj *_animList; + bool _drawNoShapeFlag; + AnimObj *initAnimList(AnimObj *list, AnimObj *entry); + AnimObj *addToAnimListSorted(AnimObj *list, AnimObj *entry); + AnimObj *deleteAnimListEntry(AnimObj *list, AnimObj *entry); + + void drawAnimObjects(); + void drawSceneAnimObject(AnimObj *obj, int x, int y, int drawLayer); + void drawCharacterAnimObject(AnimObj *obj, int x, int y, int drawLayer); + + void refreshAnimObjects(int force); + void refreshAnimObjectsIfNeed(); + + void updateCharacterAnim(int); + void updateSceneAnim(int anim, int newFrame); + + // scene + struct SceneDesc { + char filename[10]; + uint16 exit1, exit2, exit3, exit4; + uint8 flags; + uint8 sound; + }; + + SceneDesc *_sceneList; + const char *_sceneCommentString; + uint16 _sceneExit1, _sceneExit2, _sceneExit3, _sceneExit4; + int _sceneEnterX1, _sceneEnterY1, _sceneEnterX2, _sceneEnterY2, + _sceneEnterX3, _sceneEnterY3, _sceneEnterX4, _sceneEnterY4; + int _specialExitCount; + uint16 _specialExitTable[25]; + bool checkSpecialSceneExit(int num, int x, int y); + uint8 _scenePal[688]; + bool _overwriteSceneFacing; + + void enterNewScene(uint16 newScene, int facing, int unk1, int unk2, int unk3); + void enterNewSceneUnk1(int facing, int unk1, int unk2); + void enterNewSceneUnk2(int unk1); + void unloadScene(); + + void loadScenePal(); + void loadSceneMsc(); + + void startSceneScript(int unk1); + void runSceneScript2(); + void runSceneScript4(int unk1); + void runSceneScript7(); + + void initSceneAnims(int unk1); + void initSceneScreen(int unk1); + + int trySceneChange(int *moveTable, int unk1, int updateChar); + int checkSceneChange(); + + // pathfinder + int _movFacingTable[600]; + int findWay(int curX, int curY, int dstX, int dstY, int *moveTable, int moveTableSize); + bool lineIsPassable(int x, int y); + bool directLinePassable(int x, int y, int toX, int toY); + + int pathfinderUnk1(int *moveTable); + int pathfinderUnk2(int index, int v1, int v2); + int pathfinderUnk3(int tableLen, int x, int y); + int pathfinderUnk4(int index, int v); + void pathfinderUnk5(int *moveTable, int unk1, int x, int y, int moveTableSize); + + int _pathfinderUnkTable1[400]; + int _pathfinderUnkTable2[200]; + + // item + uint8 _itemHtDat[176]; + + struct Item { + uint16 id; + uint16 sceneId; + int16 x; + int8 y; + uint16 unk7; + }; + Item *_itemList; + + int findFreeItem(); + int findItem(uint16 sceneId, int id); + void resetItemList(); + + int _itemInHand; + int _handItemSet; + + // inventroy + static int _inventoryX[]; + static int _inventoryY[]; + + // localization + void loadCCodeBuffer(const char *file); + void loadOptionsBuffer(const char *file); + void loadChapterBuffer(int chapter); + uint8 *_optionsBuffer; + uint8 *_cCodeBuffer; + + uint8 *_chapterBuffer; + int _currentChapter; + int _newChapterFile; + + const uint8 *getTableEntry(const uint8 *buffer, int id); + const char *getTableString(int id, const uint8 *buffer, int decode); + const char *getChapterString(int id); + int decodeString1(const char *src, char *dst); + void decodeString2(const char *src, char *dst); + + void changeFileExtension(char *buffer); + + char _internStringBuf[200]; + static const char *_languageExtension[]; + static const char *_scriptLangExt[]; + + // character + struct Character { + uint16 sceneId; + uint16 unk2; + uint8 height; + uint8 facing; + uint16 animFrame; + uint8 unk8; + uint8 unk9; + uint8 unkA; + uint16 inventory[20]; + int16 x1, y1; + int16 x2, y2; + }; + + Character _mainCharacter; + bool _useCharPal; + int _charPalEntry; + uint8 _charPalTable[16]; + void updateCharPal(int unk1); + + void moveCharacter(int facing, int x, int y); + int updateCharPos(int *table); + void updateCharPosWithUpdate(); + void updateCharAnimFrame(int num, int *table); + + int checkCharCollision(int x, int y); + + int _mainCharX, _mainCharY; + int _charScaleX, _charScaleY; + + static int _characterFrameTable[]; + + // text + void showMessageFromCCode(int id, int16 palIndex, int); + void showMessage(const char *string, int16 palIndex); + void showChapterMessage(int id, int16 palIndex); + + const char *_shownMessage; + + byte _messagePal[3]; + int _msgUnk1; + + // timer + void timerFunc2(int); + void timerFunc3(int); + void timerFunc4(int); + void timerFunc5(int); + void timerFunc6(int); + + void setTimer1DelaySecs(int secs); + + // opcodes + int o2_setCharacterFacingRefresh(ScriptState *script); + int o2_defineObject(ScriptState *script); + int o2_refreshCharacter(ScriptState *script); + int o2_getCharacterX(ScriptState *script); + int o2_getCharacterY(ScriptState *script); + int o2_getCharacterFacing(ScriptState *script); + int o2_setSceneComment(ScriptState *script); + int o2_showChapterMessage(ScriptState *script); + int o2_wsaClose(ScriptState *script); + int o2_displayWsaFrame(ScriptState *script); + int o2_displayWsaSequentialFrames(ScriptState *script); + int o2_wsaOpen(ScriptState *script); + int o2_defineItem(ScriptState *script); + int o2_queryGameFlag(ScriptState *script); + int o2_resetGameFlag(ScriptState *script); + int o2_setGameFlag(ScriptState *script); + int o2_hideMouse(ScriptState *script); + int o2_addSpecialExit(ScriptState *script); + int o2_showMouse(ScriptState *script); + int o2_setScaleTableItem(ScriptState *script); + int o2_setDrawLayerTableItem(ScriptState *script); + int o2_drawSceneShapeOnPage(ScriptState *script); + int o2_restoreBackBuffer(ScriptState *script); + int o2_getRand(ScriptState *script); + int o2_encodeShape(ScriptState *script); + int o2_defineRoomEntrance(ScriptState *script); + int o2_setSpecialSceneScriptRunTime(ScriptState *script); + int o2_defineSceneAnim(ScriptState *script); + int o2_updateSceneAnim(ScriptState *script); + int o2_defineRoom(ScriptState *script); + int o2_setSpecialSceneScriptState(ScriptState *script); + int o2_clearSpecialSceneScriptState(ScriptState *script); + int o2_querySpecialSceneScriptState(ScriptState *script); + int o2_dummy(ScriptState *script); + + // script + void runStartScript(int script, int unk1); + void loadNPCScript(); + + bool _noScriptEnter; + + ScriptData _npcScriptData; + + ScriptData _sceneScriptData; + ScriptState _sceneScriptState; + + // pathfinder + int _pathfinderFlag; + + // unk + struct Object { + char filename[13]; + uint8 scriptId; + int16 x, y; + int8 unk12; + }; + Object *_objectList; + + uint8 *_unkBuf500Bytes; + uint8 *_unkBuf200kByte; + bool _unkFlag1; + int _unk3, _unk4, _unk5; + bool _unkSceneScreenFlag1; + bool _unkHandleSceneChangeFlag; }; } // end of namespace Kyra diff --git a/engines/kyra/kyra_v3.cpp b/engines/kyra/kyra_v3.cpp index b49635ab2d..9aa4b1f4da 100644 --- a/engines/kyra/kyra_v3.cpp +++ b/engines/kyra/kyra_v3.cpp @@ -290,14 +290,14 @@ void KyraEngine_v3::stopMusicTrack() { int KyraEngine_v3::musicUpdate(int forceRestart) { debugC(9, kDebugLevelMain, "KyraEngine::unkUpdate(%d)", forceRestart); - static uint32 timer = 0; + static uint32 mTimer = 0; static uint16 lock = 0; - if (ABS(_system->getMillis() - timer) > (int)(0x0F * _tickLength)) { - timer = _system->getMillis(); + if (ABS(_system->getMillis() - mTimer) > (int)(0x0F * _tickLength)) { + mTimer = _system->getMillis(); } - if (_system->getMillis() < timer && !forceRestart) { + if (_system->getMillis() < mTimer && !forceRestart) { return 1; } @@ -311,7 +311,7 @@ int KyraEngine_v3::musicUpdate(int forceRestart) { } } lock = 0; - timer = _system->getMillis() + 0x0F * _tickLength; + mTimer = _system->getMillis() + 0x0F * _tickLength; } return 1; diff --git a/engines/kyra/module.mk b/engines/kyra/module.mk index 0ddcc1bf7f..0517c393a1 100644 --- a/engines/kyra/module.mk +++ b/engines/kyra/module.mk @@ -2,22 +2,27 @@ MODULE := engines/kyra MODULE_OBJS := \ animator_v1.o \ + animator_v2.o \ debugger.o \ detection.o \ gui_v1.o \ gui_v2.o \ items_v1.o \ + items_v2.o \ kyra.o \ kyra_v1.o \ kyra_v2.o \ kyra_v3.o \ resource.o \ saveload_v1.o \ + scene.o \ scene_v1.o \ + scene_v2.o \ screen.o \ screen_v1.o \ screen_v2.o \ script_v1.o \ + script_v2.o \ script.o \ seqplayer.o \ sequences_v1.o \ @@ -31,7 +36,9 @@ MODULE_OBJS := \ staticres.o \ text.o \ text_v1.o \ + timer.o \ timer_v1.o \ + timer_v2.o \ vqa.o \ wsamovie.o diff --git a/engines/kyra/resource.cpp b/engines/kyra/resource.cpp index 3ff8dd984c..fa333bf8bd 100644 --- a/engines/kyra/resource.cpp +++ b/engines/kyra/resource.cpp @@ -42,11 +42,11 @@ namespace Kyra { namespace { -struct ResFilenameEqual : public Common::BinaryFunction { +struct ResFilenameEqual : public Common::UnaryFunction { uint _filename; ResFilenameEqual(uint file) : _filename(file) {} - bool operator()(ResourceFile *f) { + bool operator()(const ResourceFile *f) { return f->filename() == _filename; } }; diff --git a/engines/kyra/resource.h b/engines/kyra/resource.h index 19855ed9c9..139a7fa72c 100644 --- a/engines/kyra/resource.h +++ b/engines/kyra/resource.h @@ -122,9 +122,8 @@ public: uint32 getFileSize(const char *file) const; uint8* fileData(const char *file, uint32 *size) const; - // it gives back a file handle (used for the speech player) - // it could be that the needed file is embedded in the returned - // handle + // gives back a file handle + // it is possible that the needed file is embedded in the returned handle bool getFileHandle(const char *file, uint32 *size, Common::File &filehandle); bool loadFileToBuf(const char *file, void *buf, uint32 maxSize); diff --git a/engines/kyra/saveload_v1.cpp b/engines/kyra/saveload_v1.cpp index d28a0b3f8b..c2ceee1d3b 100644 --- a/engines/kyra/saveload_v1.cpp +++ b/engines/kyra/saveload_v1.cpp @@ -33,8 +33,9 @@ #include "kyra/screen.h" #include "kyra/resource.h" #include "kyra/sound.h" +#include "kyra/timer.h" -#define CURRENT_VERSION 7 +#define CURRENT_VERSION 8 // TODO: our current savefiles still use the old // flag system to check the version, we should @@ -147,14 +148,7 @@ void KyraEngine_v1::loadGame(const char *fileName) { _poisonDeathCounter = in->readByte(); _animator->_brandonDrawFrame = in->readUint16BE(); - for (int i = 0; i < 32; i++) { - _timers[i].active = in->readByte(); - _timers[i].countdown = in->readSint32BE(); - _timers[i].nextRun = in->readUint32BE(); - if (_timers[i].nextRun != 0) - _timers[i].nextRun += _system->getMillis(); - } - _timerNextRun = 0; + _timer->loadDataFromFile(in, version); memset(_flagsTable, 0, sizeof(_flagsTable)); uint32 flagsSize = in->readUint32BE(); @@ -206,7 +200,7 @@ void KyraEngine_v1::loadGame(const char *fileName) { if (version >= 7) { _curSfxFile = in->readByte(); - // In the first version there this entry was introduced, + // In the first version when this entry was introduced, // it wasn't made sure that _curSfxFile was initialized // so if it's out of bounds we just set it to 0. if (_curSfxFile >= _soundFilesTownsCount || _curSfxFile < 0) @@ -323,14 +317,7 @@ void KyraEngine_v1::saveGame(const char *fileName, const char *saveName) { out->writeByte(_poisonDeathCounter); out->writeUint16BE(_animator->_brandonDrawFrame); - for (int i = 0; i < 32; i++) { - out->writeByte(_timers[i].active); - out->writeSint32BE(_timers[i].countdown); - if (_system->getMillis() >= _timers[i].nextRun) - out->writeUint32BE(0); - else - out->writeUint32BE(_timers[i].nextRun - _system->getMillis()); - } + _timer->saveDataToFile(out); out->writeUint32BE(sizeof(_flagsTable)); out->write(_flagsTable, sizeof(_flagsTable)); diff --git a/engines/kyra/scene.cpp b/engines/kyra/scene.cpp new file mode 100644 index 0000000000..bf85ab1474 --- /dev/null +++ b/engines/kyra/scene.cpp @@ -0,0 +1,383 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include "kyra/kyra.h" +#include "kyra/screen.h" + +namespace Kyra { + +int KyraEngine::findWay(int x, int y, int toX, int toY, int *moveTable, int moveTableSize) { + debugC(9, kDebugLevelMain, "KyraEngine::findWay(%d, %d, %d, %d, %p, %d)", x, y, toX, toY, (const void *)moveTable, moveTableSize); + x &= 0xFFFC; toX &= 0xFFFC; + y &= 0xFFFE; toY &= 0xFFFE; + x = (int16)x; y = (int16)y; toX = (int16)toX; toY = (int16)toY; + + if (x == toY && y == toY) { + moveTable[0] = 8; + return 0; + } + + int curX = x; + int curY = y; + int tempValue = 0; + int lastUsedEntry = 0; + int *pathTable1 = new int[0x7D0]; + int *pathTable2 = new int[0x7D0]; + assert(pathTable1 && pathTable2); + + while (true) { + int newFacing = getFacingFromPointToPoint(x, y, toX, toY); + changePosTowardsFacing(curX, curY, newFacing); + + if (curX == toX && curY == toY) { + if (!lineIsPassable(curX, curY)) + break; + moveTable[lastUsedEntry++] = newFacing; + break; + } + + if (lineIsPassable(curX, curY)) { + if (lastUsedEntry == moveTableSize) { + delete [] pathTable1; + delete [] pathTable2; + return 0x7D00; + } + // debug drawing + //if (curX >= 0 && curY >= 0 && curX < 320 && curY < 200) { + // _screen->setPagePixel(0, curX, curY, 11); + // _screen->updateScreen(); + // waitTicks(5); + //} + moveTable[lastUsedEntry++] = newFacing; + x = curX; + y = curY; + continue; + } + + int temp = 0; + while (true) { + newFacing = getFacingFromPointToPoint(curX, curY, toX, toY); + changePosTowardsFacing(curX, curY, newFacing); + // debug drawing + //if (curX >= 0 && curY >= 0 && curX < 320 && curY < 200) { + // _screen->setPagePixel(0, curX, curY, 8); + // _screen->updateScreen(); + // waitTicks(5); + //} + + if (!lineIsPassable(curX, curY)) { + if (curX != toX || curY != toY) + continue; + } + + if (curX == toX && curY == toY) { + if (!lineIsPassable(curX, curY)) { + tempValue = 0; + temp = 0; + break; + } + } + + temp = findSubPath(x, y, curX, curY, pathTable1, 1, 0x7D0); + tempValue = findSubPath(x, y, curX, curY, pathTable2, 0, 0x7D0); + if (curX == toX && curY == toY) { + if (temp == 0x7D00 && tempValue == 0x7D00) { + delete [] pathTable1; + delete [] pathTable2; + return 0x7D00; + } + } + + if (temp != 0x7D00 || tempValue != 0x7D00) + break; + } + + if (temp < tempValue) { + if (lastUsedEntry + temp > moveTableSize) { + delete [] pathTable1; + delete [] pathTable2; + return 0x7D00; + } + memcpy(&moveTable[lastUsedEntry], pathTable1, temp*sizeof(int)); + lastUsedEntry += temp; + } else { + if (lastUsedEntry + tempValue > moveTableSize) { + delete [] pathTable1; + delete [] pathTable2; + return 0x7D00; + } + memcpy(&moveTable[lastUsedEntry], pathTable2, tempValue*sizeof(int)); + lastUsedEntry += tempValue; + } + x = curX; + y = curY; + if (curX == toX && curY == toY) + break; + } + + delete [] pathTable1; + delete [] pathTable2; + moveTable[lastUsedEntry] = 8; + return lastUsedEntry; +} + +int KyraEngine::findSubPath(int x, int y, int toX, int toY, int *moveTable, int start, int end) { + debugC(9, kDebugLevelMain, "KyraEngine::findSubPath(%d, %d, %d, %d, %p, %d, %d)", x, y, toX, toY, (const void *)moveTable, start, end); + // only used for debug specific code + //static uint16 unkTable[] = { 8, 5 }; + static const int8 facingTable1[] = { 7, 0, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 7, 0 }; + static const int8 facingTable2[] = { -1, 0, -1, 2, -1, 4, -1, 6, -1, 2, -1, 4, -1, 6, -1, 0 }; + static const int8 facingTable3[] = { 2, 4, 4, 6, 6, 0, 0, 2, 6, 6, 0, 0, 2, 2, 4, 4 }; + static const int8 addPosTableX[] = { -1, 0, -1, 4, -1, 0, -1, -4, -1, -4, -1, 0, -1, 4, -1, 0 }; + static const int8 addPosTableY[] = { -1, 2, -1, 0, -1, -2, -1, 0, -1, 0, -1, 2, -1, 0, -1, -2 }; + + // debug specific + /*++unkTable[start]; + while (screen()->getPalette(0)[unkTable[start]] != 0x0F) { + ++unkTable[start]; + }*/ + + int xpos1 = x, xpos2 = x; + int ypos1 = y, ypos2 = y; + int newFacing = getFacingFromPointToPoint(x, y, toX, toY); + int position = 0; + + while (position != end) { + int newFacing2 = newFacing; + while (true) { + changePosTowardsFacing(xpos1, ypos1, facingTable1[start*8 + newFacing2]); + if (!lineIsPassable(xpos1, ypos1)) { + if (facingTable1[start*8 + newFacing2] == newFacing) + return 0x7D00; + newFacing2 = facingTable1[start*8 + newFacing2]; + xpos1 = x; + ypos1 = y; + continue; + } + newFacing = facingTable1[start*8 + newFacing2]; + break; + } + // debug drawing + /*if (xpos1 >= 0 && ypos1 >= 0 && xpos1 < 320 && ypos1 < 200) { + screen()->setPagePixel(0, xpos1, ypos1, unkTable[start]); + screen()->updateScreen(); + //waitTicks(5); + }*/ + if (newFacing & 1) { + int temp = xpos1 + addPosTableX[newFacing + start * 8]; + if (toX == temp) { + temp = ypos1 + addPosTableY[newFacing + start * 8]; + if (toY == temp) { + moveTable[position++] = facingTable2[newFacing + start * 8]; + return position; + } + } + } + + moveTable[position++] = newFacing; + x = xpos1; + y = ypos1; + + if (x == toX && y == toY) + return position; + + if (xpos1 == xpos2 && ypos1 == ypos2) + break; + + newFacing = facingTable3[start*8 + newFacing]; + } + + return 0x7D00; +} + +int KyraEngine::getFacingFromPointToPoint(int x, int y, int toX, int toY) { + debugC(9, kDebugLevelMain, "KyraEngine::getFacingFromPointToPoint(%d, %d, %d, %d)", x, y, toX, toY); + static const int facingTable[] = { + 1, 0, 1, 2, 3, 4, 3, 2, 7, 0, 7, 6, 5, 4, 5, 6 + }; + + int facingEntry = 0; + int ydiff = y - toY; + if (ydiff < 0) { + ++facingEntry; + ydiff = -ydiff; + } + facingEntry <<= 1; + + int xdiff = toX - x; + if (xdiff < 0) { + ++facingEntry; + xdiff = -xdiff; + } + + if (xdiff >= ydiff) { + int temp = ydiff; + ydiff = xdiff; + xdiff = temp; + + facingEntry <<= 1; + } else { + facingEntry <<= 1; + facingEntry += 1; + } + int temp = (ydiff + 1) >> 1; + + if (xdiff < temp) { + facingEntry <<= 1; + facingEntry += 1; + } else { + facingEntry <<= 1; + } + + assert(facingEntry < ARRAYSIZE(facingTable)); + return facingTable[facingEntry]; +} + + +int KyraEngine::getOppositeFacingDirection(int dir) { + debugC(9, kDebugLevelMain, "KyraEngine::getOppositeFacingDirection(%d)", dir); + switch (dir) { + case 0: + return 2; + case 1: + return 1; + case 3: + return 7; + case 4: + return 6; + case 5: + return 5; + case 6: + return 4; + case 7: + return 3; + default: + break; + } + return 0; +} + +void KyraEngine::changePosTowardsFacing(int &x, int &y, int facing) { + debugC(9, kDebugLevelMain, "KyraEngine::changePosTowardsFacing(%d, %d, %d)", x, y, facing); + x += _addXPosTable[facing]; + y += _addYPosTable[facing]; +} + +int KyraEngine::getMoveTableSize(int *moveTable) { + debugC(9, kDebugLevelMain, "KyraEngine::getMoveTableSize(%p)", (const void *)moveTable); + int retValue = 0; + if (moveTable[0] == 8) + return 0; + + static const int facingTable[] = { + 4, 5, 6, 7, 0, 1, 2, 3 + }; + static const int unkTable[] = { + -1, -1, 1, 2, -1, 6, 7, -1, + -1, -1, -1, -1, 2, -1, 0, -1, + 1, -1, -1, -1, 3, 4, -1, 0, + 2, -1, -1, -1, -1, -1, 4, -1, + -1, 2, 3, -1, -1, -1, 5, 6, + 6, -1, 4, -1, -1, -1, -1, -1, + 7, 0, -1, 4, 5, -1, -1, -1, + -1, -1, 0, -1, 6, -1, -1, -1 + }; + + int *oldPosition = moveTable; + int *tempPosition = moveTable; + int *curPosition = moveTable + 1; + retValue = 1; + + while (*curPosition != 8) { + if (*oldPosition == facingTable[*curPosition]) { + retValue -= 2; + *oldPosition = 9; + *curPosition = 9; + + while (tempPosition != moveTable) { + --tempPosition; + if (*tempPosition != 9) + break; + } + + if (tempPosition == moveTable && *tempPosition == 9) { + while (*tempPosition != 8 && *tempPosition == 9) + ++tempPosition; + + if (*tempPosition == 8) + return 0; + } + + oldPosition = tempPosition; + curPosition = oldPosition+1; + + while (*curPosition != 8 && *curPosition == 9) + ++curPosition; + + continue; + } + + if (unkTable[*curPosition+((*oldPosition)*8)] != -1) { + --retValue; + *oldPosition = unkTable[*curPosition+((*oldPosition)*8)]; + *curPosition = 9; + + if (tempPosition != oldPosition) { + curPosition = oldPosition; + oldPosition = tempPosition; + while (true) { + if (tempPosition == moveTable) + break; + + --tempPosition; + if (*tempPosition != 9) + break; + + } + } else { + while (true) { + ++curPosition; + if (*curPosition != 9) + break; + } + } + continue; + } + + tempPosition = oldPosition; + oldPosition = curPosition; + ++retValue; + + while (true) { + ++curPosition; + if (*curPosition != 9) + break; + } + } + + return retValue; +} + +} // end of namespace Kyra diff --git a/engines/kyra/scene_v1.cpp b/engines/kyra/scene_v1.cpp index e01bb98e18..3754d5e2ab 100644 --- a/engines/kyra/scene_v1.cpp +++ b/engines/kyra/scene_v1.cpp @@ -33,6 +33,7 @@ #include "kyra/animator_v1.h" #include "kyra/text.h" #include "kyra/script.h" +#include "kyra/timer.h" #include "common/system.h" #include "common/savefile.h" @@ -230,15 +231,15 @@ void KyraEngine_v1::moveCharacterToPos(int character, int facing, int xpos, int _screen->hideMouse(); xpos = (int16)(xpos & 0xFFFC); ypos = (int16)(ypos & 0xFFFE); - disableTimer(19); - disableTimer(14); - disableTimer(18); + _timer->disable(19); + _timer->disable(14); + _timer->disable(18); uint32 nextFrame = 0; switch (facing) { case 0: while (ypos < ch->y1) { - nextFrame = getTimerDelay(5 + character) * _tickLength + _system->getMillis(); + nextFrame = _timer->getDelay(5 + character) * _tickLength + _system->getMillis(); setCharacterPositionWithUpdate(character); delayUntil(nextFrame, true); } @@ -246,7 +247,7 @@ void KyraEngine_v1::moveCharacterToPos(int character, int facing, int xpos, int case 2: while (ch->x1 < xpos) { - nextFrame = getTimerDelay(5 + character) * _tickLength + _system->getMillis(); + nextFrame = _timer->getDelay(5 + character) * _tickLength + _system->getMillis(); setCharacterPositionWithUpdate(character); delayUntil(nextFrame, true); } @@ -254,7 +255,7 @@ void KyraEngine_v1::moveCharacterToPos(int character, int facing, int xpos, int case 4: while (ypos > ch->y1) { - nextFrame = getTimerDelay(5 + character) * _tickLength + _system->getMillis(); + nextFrame = _timer->getDelay(5 + character) * _tickLength + _system->getMillis(); setCharacterPositionWithUpdate(character); delayUntil(nextFrame, true); } @@ -262,7 +263,7 @@ void KyraEngine_v1::moveCharacterToPos(int character, int facing, int xpos, int case 6: while (ch->x1 > xpos) { - nextFrame = getTimerDelay(5 + character) * _tickLength + _system->getMillis(); + nextFrame = _timer->getDelay(5 + character) * _tickLength + _system->getMillis(); setCharacterPositionWithUpdate(character); delayUntil(nextFrame, true); } @@ -272,9 +273,9 @@ void KyraEngine_v1::moveCharacterToPos(int character, int facing, int xpos, int break; } - enableTimer(19); - enableTimer(14); - enableTimer(18); + _timer->enable(19); + _timer->enable(14); + _timer->enable(18); _screen->showMouse(); } @@ -282,7 +283,7 @@ void KyraEngine_v1::setCharacterPositionWithUpdate(int character) { debugC(9, kDebugLevelMain, "KyraEngine_v1::setCharacterPositionWithUpdate(%d)", character); setCharacterPosition(character, 0); _sprites->updateSceneAnims(); - updateGameTimers(); + _timer->update(); _animator->updateAllObjectShapes(); updateTextFade(); @@ -391,29 +392,6 @@ void KyraEngine_v1::setCharacterPositionHelper(int character, int *facingTable) _animator->animRefreshNPC(character); } -int KyraEngine_v1::getOppositeFacingDirection(int dir) { - debugC(9, kDebugLevelMain, "KyraEngine_v1::getOppositeFacingDirection(%d)", dir); - switch (dir) { - case 0: - return 2; - case 1: - return 1; - case 3: - return 7; - case 4: - return 6; - case 5: - return 5; - case 6: - return 4; - case 7: - return 3; - default: - break; - } - return 0; -} - void KyraEngine_v1::loadSceneMsc() { assert(_currentCharacter->sceneId < _roomTableSize); int tableId = _roomTable[_currentCharacter->sceneId].nameIndex; @@ -998,9 +976,9 @@ int KyraEngine_v1::processSceneChange(int *table, int unk1, int frameReset) { if (temp) ++table; - nextFrame = getTimerDelay(5) * _tickLength + _system->getMillis(); + nextFrame = _timer->getDelay(5) * _tickLength + _system->getMillis(); while (_system->getMillis() < nextFrame) { - updateGameTimers(); + _timer->update(); if (_currentCharacter->sceneId == 210) { updateKyragemFading(); @@ -1188,237 +1166,10 @@ void KyraEngine_v1::setCharactersPositions(int character) { int KyraEngine_v1::findWay(int x, int y, int toX, int toY, int *moveTable, int moveTableSize) { debugC(9, kDebugLevelMain, "KyraEngine_v1::findWay(%d, %d, %d, %d, %p, %d)", x, y, toX, toY, (const void *)moveTable, moveTableSize); - x &= 0xFFFC; toX &= 0xFFFC; - y &= 0xFFFE; toY &= 0xFFFE; - x = (int16)x; y = (int16)y; toX = (int16)toX; toY = (int16)toY; - - if (x == toY && y == toY) { - moveTable[0] = 8; - return 0; - } - - int curX = x; - int curY = y; - int lastUsedEntry = 0; - int tempValue = 0; - int *pathTable1 = new int[0x7D0]; - int *pathTable2 = new int[0x7D0]; - assert(pathTable1 && pathTable2); - - while (true) { - int newFacing = getFacingFromPointToPoint(x, y, toX, toY); - changePosTowardsFacing(curX, curY, newFacing); - - if (curX == toX && curY == toY) { - if (!lineIsPassable(curX, curY)) - break; - moveTable[lastUsedEntry++] = newFacing; - break; - } - - if (lineIsPassable(curX, curY)) { - if (lastUsedEntry == moveTableSize) { - delete [] pathTable1; - delete [] pathTable2; - return 0x7D00; - } - // debug drawing - //if (curX >= 0 && curY >= 0 && curX < 320 && curY < 200) { - // _screen->setPagePixel(0, curX, curY, 11); - // _screen->updateScreen(); - // waitTicks(5); - //} - moveTable[lastUsedEntry++] = newFacing; - x = curX; - y = curY; - continue; - } - - int temp = 0; - while (true) { - newFacing = getFacingFromPointToPoint(curX, curY, toX, toY); - changePosTowardsFacing(curX, curY, newFacing); - // debug drawing - //if (curX >= 0 && curY >= 0 && curX < 320 && curY < 200) { - // _screen->setPagePixel(0, curX, curY, 8); - // _screen->updateScreen(); - // waitTicks(5); - //} - - if (!lineIsPassable(curX, curY)) { - if (curX != toX || curY != toY) - continue; - } - - if (curX == toX && curY == toY) { - if (!lineIsPassable(curX, curY)) { - tempValue = 0; - temp = 0; - break; - } - } - - temp = findSubPath(x, y, curX, curY, pathTable1, 1, 0x7D0); - tempValue = findSubPath(x, y, curX, curY, pathTable2, 0, 0x7D0); - if (curX == toX && curY == toY) { - if (temp == 0x7D00 && tempValue == 0x7D00) { - delete [] pathTable1; - delete [] pathTable2; - return 0x7D00; - } - } - - if (temp != 0x7D00 || tempValue != 0x7D00) - break; - } - - if (temp < tempValue) { - if (lastUsedEntry + temp > moveTableSize) { - delete [] pathTable1; - delete [] pathTable2; - return 0x7D00; - } - memcpy(&moveTable[lastUsedEntry], pathTable1, temp*sizeof(int)); - lastUsedEntry += temp; - } else { - if (lastUsedEntry + tempValue > moveTableSize) { - delete [] pathTable1; - delete [] pathTable2; - return 0x7D00; - } - memcpy(&moveTable[lastUsedEntry], pathTable2, tempValue*sizeof(int)); - lastUsedEntry += tempValue; - } - x = curX; - y = curY; - if (curX == toX && curY == toY) - break; - } - - delete [] pathTable1; - delete [] pathTable2; - moveTable[lastUsedEntry] = 8; + KyraEngine::findWay(x, y, toX, toY, moveTable, moveTableSize); return getMoveTableSize(moveTable); } -int KyraEngine_v1::findSubPath(int x, int y, int toX, int toY, int *moveTable, int start, int end) { - debugC(9, kDebugLevelMain, "KyraEngine_v1::findSubPath(%d, %d, %d, %d, %p, %d, %d)", x, y, toX, toY, (const void *)moveTable, start, end); - // only used for debug specific code - //static uint16 unkTable[] = { 8, 5 }; - static const int8 facingTable1[] = { 7, 0, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 7, 0 }; - static const int8 facingTable2[] = { -1, 0, -1, 2, -1, 4, -1, 6, -1, 2, -1, 4, -1, 6, -1, 0 }; - static const int8 facingTable3[] = { 2, 4, 4, 6, 6, 0, 0, 2, 6, 6, 0, 0, 2, 2, 4, 4 }; - static const int8 addPosTableX[] = { -1, 0, -1, 4, -1, 0, -1, -4, -1, -4, -1, 0, -1, 4, -1, 0 }; - static const int8 addPosTableY[] = { -1, 2, -1, 0, -1, -2, -1, 0, -1, 0, -1, 2, -1, 0, -1, -2 }; - - // debug specific - //++unkTable[start]; - //while (_screen->getPalette(0)[unkTable[start]] != 0x0F) { - // ++unkTable[start]; - //} - - int xpos1 = x, xpos2 = x; - int ypos1 = y, ypos2 = y; - int newFacing = getFacingFromPointToPoint(x, y, toX, toY); - int position = 0; - - while (position != end) { - int newFacing2 = newFacing; - while (true) { - changePosTowardsFacing(xpos1, ypos1, facingTable1[start*8 + newFacing2]); - if (!lineIsPassable(xpos1, ypos1)) { - if (facingTable1[start*8 + newFacing2] == newFacing) - return 0x7D00; - newFacing2 = facingTable1[start*8 + newFacing2]; - xpos1 = x; - ypos1 = y; - continue; - } - newFacing = facingTable1[start*8 + newFacing2]; - break; - } - // debug drawing - //if (xpos1 >= 0 && ypos1 >= 0 && xpos1 < 320 && ypos1 < 200) { - // _screen->setPagePixel(0, xpos1, ypos1, unkTable[start]); - // _screen->updateScreen(); - // waitTicks(5); - //} - if (newFacing & 1) { - int temp = xpos1 + addPosTableX[newFacing + start * 8]; - if (toX == temp) { - temp = ypos1 + addPosTableY[newFacing + start * 8]; - if (toY == temp) { - moveTable[position++] = facingTable2[newFacing + start * 8]; - return position; - } - } - } - - moveTable[position++] = newFacing; - x = xpos1; - y = ypos1; - - if (x == toX && y == toY) - return position; - - if (xpos1 == xpos2 && ypos1 == ypos2) - break; - - newFacing = facingTable3[start*8 + newFacing]; - } - - return 0x7D00; -} - -int KyraEngine_v1::getFacingFromPointToPoint(int x, int y, int toX, int toY) { - debugC(9, kDebugLevelMain, "KyraEngine_v1::getFacingFromPointToPoint(%d, %d, %d, %d)", x, y, toX, toY); - static const int facingTable[] = { - 1, 0, 1, 2, 3, 4, 3, 2, 7, 0, 7, 6, 5, 4, 5, 6 - }; - - int facingEntry = 0; - int ydiff = y - toY; - if (ydiff < 0) { - ++facingEntry; - ydiff = -ydiff; - } - facingEntry <<= 1; - - int xdiff = toX - x; - if (xdiff < 0) { - ++facingEntry; - xdiff = -xdiff; - } - - if (xdiff >= ydiff) { - int temp = ydiff; - ydiff = xdiff; - xdiff = temp; - - facingEntry <<= 1; - } else { - facingEntry <<= 1; - facingEntry += 1; - } - int temp = (ydiff + 1) >> 1; - - if (xdiff < temp) { - facingEntry <<= 1; - facingEntry += 1; - } else { - facingEntry <<= 1; - } - - assert(facingEntry < ARRAYSIZE(facingTable)); - return facingTable[facingEntry]; -} - -void KyraEngine_v1::changePosTowardsFacing(int &x, int &y, int facing) { - debugC(9, kDebugLevelMain, "KyraEngine_v1::changePosTowardsFacing(%d, %d, %d)", x, y, facing); - x += _addXPosTable[facing]; - y += _addYPosTable[facing]; -} - bool KyraEngine_v1::lineIsPassable(int x, int y) { debugC(9, kDebugLevelMain, "KyraEngine_v1::lineIsPassable(%d, %d)", x, y); if (queryGameFlag(0xEF)) { @@ -1478,100 +1229,7 @@ bool KyraEngine_v1::lineIsPassable(int x, int y) { return true; } -int KyraEngine_v1::getMoveTableSize(int *moveTable) { - debugC(9, kDebugLevelMain, "KyraEngine_v1::getMoveTableSize(%p)", (const void *)moveTable); - int retValue = 0; - if (moveTable[0] == 8) - return 0; - - static const int facingTable[] = { - 4, 5, 6, 7, 0, 1, 2, 3 - }; - static const int unkTable[] = { - -1, -1, 1, 2, -1, 6, 7, -1, - -1, -1, -1, -1, 2, -1, 0, -1, - 1, -1, -1, -1, 3, 4, -1, 0, - 2, -1, -1, -1, -1, -1, 4, -1, - -1, 2, 3, -1, -1, -1, 5, 6, - 6, -1, 4, -1, -1, -1, -1, -1, - 7, 0, -1, 4, 5, -1, -1, -1, - -1, -1, 0, -1, 6, -1, -1, -1 - }; - - int *oldPosition = moveTable; - int *tempPosition = moveTable; - int *curPosition = moveTable + 1; - retValue = 1; - - while (*curPosition != 8) { - if (*oldPosition == facingTable[*curPosition]) { - retValue -= 2; - *oldPosition = 9; - *curPosition = 9; - - while (tempPosition != moveTable) { - --tempPosition; - if (*tempPosition != 9) - break; - } - - if (tempPosition == moveTable && *tempPosition == 9) { - while (*tempPosition != 8 && *tempPosition == 9) - ++tempPosition; - - if (*tempPosition == 8) - return 0; - } - - oldPosition = tempPosition; - curPosition = oldPosition+1; - - while (*curPosition != 8 && *curPosition == 9) - ++curPosition; - - continue; - } - - if (unkTable[*curPosition+((*oldPosition)*8)] != -1) { - --retValue; - *oldPosition = unkTable[*curPosition+((*oldPosition)*8)]; - *curPosition = 9; - - if (tempPosition != oldPosition) { - curPosition = oldPosition; - oldPosition = tempPosition; - while (true) { - if (tempPosition == moveTable) - break; - - --tempPosition; - if (*tempPosition != 9) - break; - - } - } else { - while (true) { - ++curPosition; - if (*curPosition != 9) - break; - } - } - continue; - } - - tempPosition = oldPosition; - oldPosition = curPosition; - ++retValue; - - while (true) { - ++curPosition; - if (*curPosition != 9) - break; - } - } - - return retValue; -} +#pragma mark - void KyraEngine_v1::setupSceneResource(int sceneId) { debugC(9, kDebugLevelMain, "KyraEngine_v1::setupSceneResource(%d)", sceneId); diff --git a/engines/kyra/scene_v2.cpp b/engines/kyra/scene_v2.cpp new file mode 100644 index 0000000000..fbda1f8455 --- /dev/null +++ b/engines/kyra/scene_v2.cpp @@ -0,0 +1,865 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include "kyra/kyra_v2.h" +#include "kyra/screen_v2.h" +#include "kyra/wsamovie.h" + +#include "common/func.h" + +namespace Kyra { + +void KyraEngine_v2::enterNewScene(uint16 newScene, int facing, int unk1, int unk2, int unk3) { + // XXX + _screen->hideMouse(); + + if (!unk3) { + //updateSpecialItems(); + //displayInvWsaLastFrame(); + } + + if (unk1) { + int x = _mainCharacter.x1; + int y = _mainCharacter.y1; + + switch (facing) { + case 0: + y -= 6; + break; + + case 2: + x = 335; + break; + + case 4: + y = 147; + break; + + case 6: + x = -16; + break; + + default: + break; + } + + moveCharacter(facing, x, y); + } + + //XXX sound + + _unkFlag1 = false; + + if (!unk3) { + _scriptInterpreter->initScript(&_sceneScriptState, &_sceneScriptData); + _scriptInterpreter->startScript(&_sceneScriptState, 5); + while (_scriptInterpreter->validScript(&_sceneScriptState)) + _scriptInterpreter->runScript(&_sceneScriptState); + } + + Common::for_each(_wsaSlots, _wsaSlots+ARRAYSIZE(_wsaSlots), Common::mem_fun(&WSAMovieV2::close)); + _specialExitCount = 0; + memset(_specialExitTable, -1, sizeof(_specialExitTable)); + + _mainCharacter.sceneId = newScene; + _sceneList[newScene].flags &= ~1; + loadScenePal(); + unloadScene(); + loadSceneMsc(); + + SceneDesc &scene = _sceneList[newScene]; + _sceneExit1 = scene.exit1; + _sceneExit2 = scene.exit2; + _sceneExit3 = scene.exit3; + _sceneExit4 = scene.exit4; + + //XXX sound + + startSceneScript(unk3); + + if (_overwriteSceneFacing) { + facing = _mainCharacter.facing; + _overwriteSceneFacing = false; + } + + enterNewSceneUnk1(facing, unk2, unk3); + + setTimer1DelaySecs(-1); + _sceneScriptState.regs[3] = 1; + enterNewSceneUnk2(unk3); + _screen->showMouse(); + _unk5 = 0; + //setNextIdleAnimTimer(); +} + +void KyraEngine_v2::enterNewSceneUnk1(int facing, int unk1, int unk2) { + int x = 0, y = 0; + int x2 = 0, y2 = 0; + bool needProc = true; + + if (_mainCharX == -1 && _mainCharY == -1) { + switch (facing+1) { + case 1: case 2: case 8: + x2 = _sceneEnterX3; + y2 = _sceneEnterY3; + break; + + case 3: + x2 = _sceneEnterX4; + y2 = _sceneEnterY4; + break; + + case 4: case 5: case 6: + x2 = _sceneEnterX1; + y2 = _sceneEnterY1; + break; + + case 7: + x2 = _sceneEnterX2; + y2 = _sceneEnterY2; + break; + + default: + x2 = y2 = -1; + break; + } + + if (x2 >= 316) + x2 = 312; + if (y2 >= 141) + y2 = 139; + if (x2 <= 4) + x2 = 8; + } + + if (_mainCharX >= 0) { + x = x2 = _mainCharX; + needProc = false; + } + + if (_mainCharY >= 0) { + y = y2 = _mainCharY; + needProc = false; + } + + _mainCharX = _mainCharY = -1; + + if (unk1 && needProc) { + x = x2; + y = y2; + + switch (facing) { + case 0: + y2 = 147; + break; + + case 2: + x2 = -16; + break; + + case 4: + y2 = y - 4; + break; + + case 6: + x2 = 335; + break; + + default: + break; + } + } + + x2 &= ~3; + x &= ~3; + y2 &= ~1; + y &= ~1; + + _mainCharacter.facing = facing; + _mainCharacter.x1 = _mainCharacter.x2 = x2; + _mainCharacter.y1 = _mainCharacter.y2 = y2; + initSceneAnims(unk2); + + if (!unk2) { + //XXX sound + } + + if (unk1 && !unk2 && _mainCharacter.animFrame != 32) + moveCharacter(facing, x, y); +} + +void KyraEngine_v2::enterNewSceneUnk2(int unk1) { + _unk3 = -1; + + if (_mainCharX == -1 && _mainCharY == -1 && _mainCharacter.sceneId != 61 && + !queryGameFlag(0x1F1) && !queryGameFlag(0x192) && !queryGameFlag(0x193) && + _mainCharacter.sceneId != 70 && !queryGameFlag(0x159) && _mainCharacter.sceneId != 37) { + _mainCharacter.animFrame = _characterFrameTable[_mainCharacter.facing]; + updateCharacterAnim(0); + refreshAnimObjectsIfNeed(); + } + + if (!unk1) { + runSceneScript4(0); + //XXX sub_27158 + } + + _unk4 = 0; + _unk3 = -1; +} + +int KyraEngine_v2::trySceneChange(int *moveTable, int unk1, int updateChar) { + bool running = true; + bool unkFlag = false; + int8 updateType = -1; + int changedScene = 0; + const int *moveTableStart = moveTable; + _unk4 = 0; + while (running) { + if (*moveTable >= 0 && *moveTable <= 7) { + _mainCharacter.facing = getOppositeFacingDirection(*moveTable); + unkFlag = true; + } else { + if (*moveTable == 8) { + running = false; + } else { + ++moveTable; + unkFlag = false; + } + } + + if (checkSceneChange()) { + running = false; + changedScene = 1; + } + + if (unk1) { + //XXX + } + + if (!unkFlag || !running) + continue; + + int ret = 0; + if (moveTable == moveTableStart || moveTable[1] == 8) + ret = updateCharPos(0); + else + ret = updateCharPos(moveTable); + + if (ret) + ++moveTable; + + ++updateType; + if (!updateType) { + update(); + } else if (updateType == 1) { + refreshAnimObjectsIfNeed(); + updateType = -1; + } + } + + if (updateChar) + _mainCharacter.animFrame = _characterFrameTable[_mainCharacter.facing]; + + updateCharacterAnim(0); + refreshAnimObjectsIfNeed(); + + if (!changedScene && !_unk4) { + //XXX + } + return changedScene; +} + +int KyraEngine_v2::checkSceneChange() { + SceneDesc &curScene = _sceneList[_mainCharacter.sceneId]; + int charX = _mainCharacter.x1, charY = _mainCharacter.y1; + int facing = 0; + int process = 0; + + if (_screen->getLayer(charX, charY) == 1 && _unk3 == -6) { + facing = 0; + process = 1; + } else if (charX >= 316 && _unk3 == -5) { + facing = 2; + process = 1; + } else if (charY >= 142 && _unk3 == -4) { + facing = 4; + process = 1; + } else if (charX <= 4 && _unk3 == -3) { + facing = 6; + process = 1; + } + + if (!process) + return 0; + + uint16 newScene = 0xFFFF; + switch (facing) { + case 0: + newScene = curScene.exit1; + break; + + case 2: + newScene = curScene.exit2; + break; + + case 4: + newScene = curScene.exit3; + break; + + case 6: + newScene = curScene.exit4; + break; + + default: + newScene = _mainCharacter.sceneId; + break; + } + + if (newScene == 0xFFFF) + return 0; + + enterNewScene(newScene, facing, 1, 1, 0); + return 1; +} + +void KyraEngine_v2::unloadScene() { + _scriptInterpreter->unloadScript(&_sceneScriptData); + freeSceneShapePtrs(); + freeSceneAnims(); +} + +void KyraEngine_v2::loadScenePal() { + uint16 sceneId = _mainCharacter.sceneId; + memcpy(_screen->getPalette(1), _screen->getPalette(0), 768); + + char filename[14]; + strcpy(filename, _sceneList[sceneId].filename); + strcat(filename, ".COL"); + _screen->loadBitmap(filename, 3, 3, 0); + memcpy(_screen->getPalette(1), _screen->getCPagePtr(3), 384); + memset(_screen->getPalette(1), 0, 3); + memcpy(_scenePal, _screen->getCPagePtr(3)+336, 432); +} + +void KyraEngine_v2::loadSceneMsc() { + uint16 sceneId = _mainCharacter.sceneId; + char filename[14]; + strcpy(filename, _sceneList[sceneId].filename); + strcat(filename, ".MSC"); + _screen->loadBitmap(filename, 3, 5, 0); +} + +void KyraEngine_v2::startSceneScript(int unk1) { + uint16 sceneId = _mainCharacter.sceneId; + char filename[14]; + + strcpy(filename, _sceneList[sceneId].filename); + if (sceneId == 68 && (queryGameFlag(0x1BC) || queryGameFlag(0x1DC))) + strcpy(filename, "DOORX"); + strcat(filename, ".CPS"); + + _screen->loadBitmap(filename, 3, 3, 0); + resetScaleTable(); + _useCharPal = false; + memset(_charPalTable, 0, sizeof(_charPalTable)); + //XXX _unkTable33 + memset(_specialSceneScriptState, 0, sizeof(_specialSceneScriptState)); + + _sceneEnterX1 = 160; + _sceneEnterY1 = 0; + _sceneEnterX2 = 296; + _sceneEnterY2 = 72; + _sceneEnterX3 = 160; + _sceneEnterY3 = 128; + _sceneEnterX4 = 24; + _sceneEnterY4 = 72; + + _sceneCommentString = "Undefined scene comment string!"; + _scriptInterpreter->initScript(&_sceneScriptState, &_sceneScriptData); + + strcpy(filename, _sceneList[sceneId].filename); + strcat(filename, "."); + strcat(filename, _scriptLangExt[_lang]); + + assert(_res->getFileSize(filename)); + _scriptInterpreter->loadScript(filename, &_sceneScriptData, &_opcodes); + runSceneScript7(); + + _scriptInterpreter->startScript(&_sceneScriptState, 0); + _sceneScriptState.regs[0] = sceneId; + _sceneScriptState.regs[5] = unk1; + while (_scriptInterpreter->validScript(&_sceneScriptState)) + _scriptInterpreter->runScript(&_sceneScriptState); + + memcpy(_gamePlayBuffer, _screen->getCPagePtr(3), 46080); + + for (int i = 0; i < 10; ++i) { + _scriptInterpreter->initScript(&_sceneSpecialScripts[i], &_sceneScriptData); + _scriptInterpreter->startScript(&_sceneSpecialScripts[i], i+8); + _sceneSpecialScriptsTimer[i] = 0; + } + + _sceneEnterX1 &= ~3; + _sceneEnterX2 &= ~3; + _sceneEnterX3 &= ~3; + _sceneEnterX4 &= ~3; + _sceneEnterY1 &= ~1; + _sceneEnterY2 &= ~1; + _sceneEnterY3 &= ~1; + _sceneEnterY4 &= ~1; +} + +void KyraEngine_v2::runSceneScript2() { + _scriptInterpreter->initScript(&_sceneScriptState, &_sceneScriptData); + _sceneScriptState.regs[4] = _itemInHand; + _scriptInterpreter->startScript(&_sceneScriptState, 2); + + while (_scriptInterpreter->validScript(&_sceneScriptState)) + _scriptInterpreter->runScript(&_sceneScriptState); +} + +void KyraEngine_v2::runSceneScript4(int unk1) { + _sceneScriptState.regs[4] = _itemInHand; + _sceneScriptState.regs[5] = unk1; + + _scriptInterpreter->startScript(&_sceneScriptState, 4); + while (_scriptInterpreter->validScript(&_sceneScriptState)) + _scriptInterpreter->runScript(&_sceneScriptState); +} + +void KyraEngine_v2::runSceneScript7() { + int oldPage = _screen->_curPage; + _screen->_curPage = 2; + + _scriptInterpreter->startScript(&_sceneScriptState, 7); + while (_scriptInterpreter->validScript(&_sceneScriptState)) + _scriptInterpreter->runScript(&_sceneScriptState); + + _screen->_curPage = oldPage; +} + +void KyraEngine_v2::initSceneAnims(int unk1) { + for (int i = 0; i < ARRAYSIZE(_animObjects); ++i) + _animObjects[i].enabled = 0; + + bool animInit = false; + + AnimObj *animState = &_animObjects[0]; + + if (_mainCharacter.animFrame != 32) + _mainCharacter.animFrame = _characterFrameTable[_mainCharacter.facing]; + + animState->enabled = 1; + animState->xPos1 = _mainCharacter.x1; + animState->yPos1 = _mainCharacter.y1; + animState->shapePtr = _defaultShapeTable[_mainCharacter.animFrame]; + animState->shapeIndex1 = animState->shapeIndex2 = _mainCharacter.animFrame; + + int frame = _mainCharacter.animFrame - 9; + int shapeX = _shapeDescTable[frame].xAdd; + int shapeY = _shapeDescTable[frame].yAdd; + + animState->xPos2 = _mainCharacter.x1; + animState->yPos2 = _mainCharacter.y1; + + _charScaleX = _charScaleY = getScale(_mainCharacter.x1, _mainCharacter.y1); + + int shapeXScaled = (shapeX * _charScaleX) >> 8; + int shapeYScaled = (shapeY * _charScaleY) >> 8; + + animState->xPos2 += shapeXScaled; + animState->yPos2 += shapeYScaled; + animState->xPos3 = animState->xPos2; + animState->yPos3 = animState->yPos2; + animState->needRefresh = 1; + animState->unk8 = 1; + + _animList = 0; + + AnimObj *charAnimState = animState; + + for (int i = 0; i < 10; ++i) { + animState = &_animObjects[i+1]; + animState->enabled = 0; + animState->needRefresh = 0; + animState->unk8 = 0; + + if (_sceneAnims[i].flags & 1) { + animState->enabled = 1; + animState->needRefresh = 1; + animState->unk8 = 1; + } + + animState->animFlags = _sceneAnims[i].flags & 8; + + if (_sceneAnims[i].flags & 2) + animState->flags = 0x800; + else + animState->flags = 0; + + if (_sceneAnims[i].flags & 4) + animState->flags |= 1; + + animState->xPos1 = _sceneAnims[i].x; + animState->yPos1 = _sceneAnims[i].y; + + if (_sceneAnims[i].flags & 0x20) + animState->shapePtr = _sceneShapeTable[_sceneAnims[i].shapeIndex]; + else + animState->shapePtr = 0; + + if (_sceneAnims[i].flags & 0x40) { + animState->shapeIndex3 = _sceneAnims[i].shapeIndex; + animState->animNum = i; + } else { + animState->shapeIndex3 = 0xFFFF; + animState->animNum = 0xFFFF; + } + + animState->shapeIndex2 = 0xFFFF; + + animState->xPos3 = animState->xPos2 = _sceneAnims[i].x2; + animState->yPos3 = animState->yPos2 = _sceneAnims[i].y2; + animState->width = _sceneAnims[i].width; + animState->height = _sceneAnims[i].height; + animState->width2 = animState->height2 = _sceneAnims[i].specialSize; + + if (_sceneAnims[i].flags & 1) { + if (animInit) { + _animList = addToAnimListSorted(_animList, animState); + } else { + _animList = initAnimList(_animList, animState); + animInit = true; + } + } + } + + if (animInit) { + _animList = addToAnimListSorted(_animList, charAnimState); + } else { + _animList = initAnimList(_animList, charAnimState); + animInit = true; + } + + for (int i = 0; i < 30; ++i) { + animState = &_animObjects[i+11]; + + uint16 shapeIndex = _itemList[i].id; + if (shapeIndex == 0xFFFF || _itemList[i].sceneId != _mainCharacter.sceneId) { + animState->enabled = 0; + animState->needRefresh = 0; + animState->unk8 = 0; + } else { + animState->xPos1 = _itemList[i].x; + animState->yPos1 = _itemList[i].y; + animState->shapePtr = _defaultShapeTable[64+shapeIndex]; + animState->shapeIndex1 = animState->shapeIndex2 = shapeIndex+64; + + animState->xPos2 = _itemList[i].x; + animState->yPos2 = _itemList[i].y; + int objectScale = getScale(animState->xPos2, animState->yPos2); + + const uint8 *shape = getShapePtr(animState->shapeIndex1); + animState->xPos2 -= (_screen->getShapeScaledWidth(shape, objectScale) >> 1); + animState->yPos2 -= (_screen->getShapeScaledHeight(shape, objectScale) >> 1); + animState->xPos3 = animState->xPos2; + animState->yPos3 = animState->yPos2; + + animState->enabled = 1; + animState->needRefresh = 1; + animState->unk8 = 1; + + if (animInit) { + _animList = addToAnimListSorted(_animList, animState); + } else { + _animList = initAnimList(_animList, animState); + animInit = true; + } + } + } + + _animObjects[0].unk8 = 1; + _animObjects[0].needRefresh = 1; + + for (int i = 1; i < 41; ++i) { + if (_animObjects[i].enabled) { + _animObjects[i].needRefresh = 1; + _animObjects[i].unk8 = 1; + } + } + + restorePage3(); + drawAnimObjects(); + _screen->hideMouse(); + initSceneScreen(unk1); + _screen->showMouse(); + refreshAnimObjects(0); +} + +void KyraEngine_v2::initSceneScreen(int unk1) { + if (_unkSceneScreenFlag1) { + _screen->copyRegion(0, 0, 0, 0, 320, 144, 2, 0); + return; + } + + if (_noScriptEnter) { + memset(_screen->getPalette(0), 0, 384); + _screen->setScreenPalette(_screen->getPalette(0)); + } + + _screen->copyRegion(0, 0, 0, 0, 320, 144, 2, 0); + + if (_noScriptEnter) + memcpy(_screen->getPalette(0), _screen->getPalette(1), 384); + + updateCharPal(0); + + _scriptInterpreter->startScript(&_sceneScriptState, 3); + _sceneScriptState.regs[5] = unk1; + while (_scriptInterpreter->validScript(&_sceneScriptState)) + _scriptInterpreter->runScript(&_sceneScriptState); +} + +void KyraEngine_v2::updateSpecialSceneScripts() { + uint32 nextTime = _system->getMillis() + _tickLength; + const int startScript = _lastProcessedSceneScript; + + while (_system->getMillis() <= nextTime) { + if (_sceneSpecialScriptsTimer[_lastProcessedSceneScript] <= _system->getMillis() && + !_specialSceneScriptState[_lastProcessedSceneScript]) { + _specialSceneScriptRunFlag = true; + + while (_specialSceneScriptRunFlag && _sceneSpecialScriptsTimer[_lastProcessedSceneScript] <= _system->getMillis()) + _specialSceneScriptRunFlag = _scriptInterpreter->runScript(&_sceneSpecialScripts[_lastProcessedSceneScript]) != 0; + } + + if (!_scriptInterpreter->validScript(&_sceneSpecialScripts[_lastProcessedSceneScript])) { + _scriptInterpreter->startScript(&_sceneSpecialScripts[_lastProcessedSceneScript], 8+_lastProcessedSceneScript); + _specialSceneScriptRunFlag = false; + } + + ++_lastProcessedSceneScript; + if (_lastProcessedSceneScript >= 10) + _lastProcessedSceneScript = 0; + + if (_lastProcessedSceneScript == startScript) + return; + } +} + +void KyraEngine_v2::freeSceneShapePtrs() { + for (int i = 0; i < ARRAYSIZE(_sceneShapeTable); ++i) + delete [] _sceneShapeTable[i]; + memset(_sceneShapeTable, 0, sizeof(_sceneShapeTable)); +} + +void KyraEngine_v2::freeSceneAnims() { + Common::for_each(_sceneAnimMovie, _sceneAnimMovie+ARRAYSIZE(_sceneAnimMovie), Common::mem_fun(&WSAMovieV2::close)); +} + +#pragma mark - +#pragma mark - Pathfinder +#pragma mark - + +int KyraEngine_v2::findWay(int x, int y, int toX, int toY, int *moveTable, int moveTableSize) { + debugC(9, kDebugLevelMain, "KyraEngine_v2::findWay(%d, %d, %d, %d, %p, %d)", x, y, toX, toY, (const void *)moveTable, moveTableSize); + x &= ~3; toX &= ~3; + y &= ~1; toY &= ~1; + int size = KyraEngine::findWay(x, y, toX, toY, moveTable, moveTableSize); + /*if (size) { + int temp = pathfinderUnk1(moveTable); + temp = pathfinderUnk3(temp, x, y); + pathfinderUnk5(moveTable, temp, x, y, moveTableSize); + }*/ + return getMoveTableSize(moveTable); +} + +bool KyraEngine_v2::lineIsPassable(int x, int y) { + debugC(9, kDebugLevelMain, "KyraEngine_v2::lineIsPassable(%d, %d)", x, y); + static int unkTable[] = { 1, 1, 1, 1, 1, 2, 4, 6, 8 }; + + if (_pathfinderFlag & 2) { + if (x >= 320) + return false; + } + + if (_pathfinderFlag & 4) { + if (y >= 144) + return false; + } + + if (_pathfinderFlag & 8) { + if (x < 0) + return false; + } + + if (y > 143) + return false; + + int unk1 = unkTable[getScale(x, y) >> 5]; + + if (y < 0) + y = 0; + x -= unk1 >> 1; + if (x < 0) + x = 0; + int x2 = x + unk1; + if (x2 > 320) + x2 = 320; + + for (;x < x2; ++x) + if (!_screen->getShapeFlag1(x, y)) + return false; + + return true; +} + +bool KyraEngine_v2::directLinePassable(int x, int y, int toX, int toY) { + while (x != toX && y != toY) { + int facing = getFacingFromPointToPoint(x, y, toX, toY); + x += _addXPosTable[facing]; + y += _addYPosTable[facing]; + if (!_screen->getShapeFlag1(x, y)) + return false; + } + return true; +} + +int KyraEngine_v2::pathfinderUnk1(int *moveTable) { + bool breakLoop = false; + int *moveTableCur = moveTable; + int oldEntry = *moveTableCur, curEntry = *moveTableCur; + int oldX = 0, newX = 0, oldY = 0, newY = 0; + int lastEntry = 0; + lastEntry = pathfinderUnk2(lastEntry, 0, 0); + + while (*moveTableCur != 8) { + oldEntry = curEntry; + + while (true) { + curEntry = *moveTableCur; + if (curEntry >= 0 && curEntry <= 7) + break; + + if (curEntry == 8) { + breakLoop = true; + break; + } else { + ++moveTableCur; + } + } + + if (breakLoop) + break; + + oldX = newX; + oldY = newY; + + newX += _addXPosTable[curEntry]; + newY += _addYPosTable[curEntry]; + + int temp = ABS(curEntry - oldEntry); + if (temp > 4) { + temp = 8 - temp; + } + + if (temp > 1 || oldEntry != curEntry) + lastEntry = pathfinderUnk2(lastEntry, oldX, oldY); + + ++moveTableCur; + } + + lastEntry = pathfinderUnk2(lastEntry, newX, newY); + _pathfinderUnkTable1[lastEntry*2+0] = -1; + _pathfinderUnkTable1[lastEntry*2+1] = -1; + return lastEntry; +} + +int KyraEngine_v2::pathfinderUnk2(int index, int v1, int v2) { + _pathfinderUnkTable1[index<<1] = v1; + _pathfinderUnkTable1[(index<<1)+1] = v2; + ++index; + if (index >= 199) + --index; + return index; +} + +int KyraEngine_v2::pathfinderUnk3(int tableLen, int x, int y) { + int x1 = 0, y1 = 0; + int x2 = 0, y2 = 0; + int lastEntry = 0; + int index2 = tableLen-1, index1 = 0; + while (index2 > index1) { + x1 = _pathfinderUnkTable1[index1*2+0] + x; + y1 = _pathfinderUnkTable1[index1*2+1] + y; + x2 = _pathfinderUnkTable1[index2*2+0] + x; + y2 = _pathfinderUnkTable1[index2*2+0] + x; + + if (directLinePassable(x1, y1, x2, y2)) { + lastEntry = pathfinderUnk4(lastEntry, index2); + if (tableLen-1 == index2) + break; + index1 = index2; + index2 = tableLen-1; + } else if (index1+1 == index2) { + lastEntry = pathfinderUnk4(lastEntry, index2); + index1 = index2; + index2 = tableLen-1; + } else { + --index2; + } + } + return lastEntry; +} + +int KyraEngine_v2::pathfinderUnk4(int index, int v) { + _pathfinderUnkTable2[index] = v; + ++index; + if (index >= 199) + --index; + return index; +} + +void KyraEngine_v2::pathfinderUnk5(int *moveTable, int tableLen, int x, int y, int moveTableSize) { + int x1 = 0, y1 = 0; + int x2 = 0, y2 = 0; + int index1 = 0, index2 = 0; + int sizeLeft = moveTableSize; + for (int i = 0; i < tableLen; ++i) { + index2 = _pathfinderUnkTable2[i]; + x1 = _pathfinderUnkTable1[index1*2+0] + x; + y1 = _pathfinderUnkTable1[index1*2+1] + y; + x2 = _pathfinderUnkTable1[index2*2+0] + x; + y2 = _pathfinderUnkTable1[index2*2+0] + x; + + int wayLen = findWay(x1, y1, x2, y2, moveTable, sizeLeft); + moveTable += wayLen; + sizeLeft -= wayLen; // unlike the original we want to be sure that the size left is correct + index1 = index2; + } +} + +} // end of namespace Kyra diff --git a/engines/kyra/screen.cpp b/engines/kyra/screen.cpp index 0e01801369..a7e9c90824 100644 --- a/engines/kyra/screen.cpp +++ b/engines/kyra/screen.cpp @@ -355,33 +355,6 @@ void Screen::fadeToBlack(int delay) { fadePalette(blackPal, delay); } -void Screen::k2IntroFadeToGrey(int delay) { - debugC(9, kDebugLevelScreen, "Screen::k2IntroFadeToGrey()"); - - for (int i = 0; i <= 50; ++i) { - if (i <= 8 || i >= 30) { - _currentPalette[3 * i + 0] = (_currentPalette[3 * i + 0] + - _currentPalette[3 * i + 1] + - _currentPalette[3 * i + 2]) / 3; - _currentPalette[3 * i + 1] = _currentPalette[3 * i + 0]; - _currentPalette[3 * i + 2] = _currentPalette[3 * i + 0]; - } - } - - // color 71 is the same in both the overview and closeup scenes - // Converting it to greyscale makes the trees in the closeup look dull - for (int i = 71; i < 200; ++i) { - _currentPalette[3 * i + 0] = (_currentPalette[3 * i + 0] + - _currentPalette[3 * i + 1] + - _currentPalette[3 * i + 2]) / 3; - _currentPalette[3 * i + 1] = _currentPalette[3 * i + 0]; - _currentPalette[3 * i + 2] = _currentPalette[3 * i + 0]; - } - fadePalette(_currentPalette, delay); - // Make the font color white again - setPaletteIndex(254, 254, 254, 254); -} - void Screen::fadePalette(const uint8 *palData, int delay) { debugC(9, kDebugLevelScreen, "Screen::fadePalette(%p, %d)", (const void *)palData, delay); updateScreen(); @@ -1057,13 +1030,8 @@ void Screen::drawCharANSI(uint8 c, int x, int y) { void Screen::setScreenDim(int dim) { debugC(9, kDebugLevelScreen, "Screen::setScreenDim(%d)", dim); - if (_vm->game() == GI_KYRA1) { - assert(dim < _screenDimTableCount); - _curDim = &_screenDimTable[dim]; - } else { - assert(dim < _screenDimTableCountK3); - _curDim = &_screenDimTableK3[dim]; - } + assert(dim < _screenDimTableCount); + _curDim = &_screenDimTable[dim]; // XXX } @@ -2680,38 +2648,6 @@ void Screen::loadPalette(const byte *data, uint8 *palData, int bytes) { } } -// kyra3 specific - -const uint8 *Screen::getPtrToShape(const uint8 *shpFile, int shape) { - debugC(9, kDebugLevelScreen, "KyraEngine::getPtrToShape(%p, %d)", (const void *)shpFile, shape); - uint16 shapes = READ_LE_UINT16(shpFile); - - if (shapes <= shape) - return 0; - - uint32 offset = READ_LE_UINT32(shpFile + (shape << 2) + 2); - - return shpFile + offset + 2; -} - -uint8 *Screen::getPtrToShape(uint8 *shpFile, int shape) { - debugC(9, kDebugLevelScreen, "KyraEngine::getPtrToShape(%p, %d)", (void *)shpFile, shape); - uint16 shapes = READ_LE_UINT16(shpFile); - - if (shapes <= shape) - return 0; - - uint32 offset = READ_LE_UINT32(shpFile + (shape << 2) + 2); - - return shpFile + offset + 2; -} - -uint16 Screen::getShapeSize(const uint8 *shp) { - debugC(9, kDebugLevelScreen, "KyraEngine::getShapeSize(%p)", (const void *)shp); - - return READ_LE_UINT16(shp+6); -} - // dirty rect handling void Screen::addDirtyRect(int x, int y, int w, int h) { diff --git a/engines/kyra/screen.h b/engines/kyra/screen.h index 355407a330..b1a1eb7b1a 100644 --- a/engines/kyra/screen.h +++ b/engines/kyra/screen.h @@ -133,8 +133,6 @@ public: void fadeFromBlack(int delay=0x54); void fadeToBlack(int delay=0x54); - void k2IntroFadeToGrey(int delay=0x54); - void fadePalette(const uint8 *palData, int delay); void setPaletteIndex(uint8 index, uint8 red, uint8 green, uint8 blue); @@ -162,7 +160,7 @@ public: void setTextColorMap(const uint8 *cmap); void setTextColor(const uint8 *cmap, int a, int b); - void setScreenDim(int dim); + virtual void setScreenDim(int dim); // shape handling uint8 *encodeShape(int x, int y, int w, int h, int flags); @@ -170,7 +168,7 @@ public: int setNewShapeHeight(uint8 *shape, int height); int resetShapeHeight(uint8 *shape); - void drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, int sd, int flags, ...); + virtual void drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, int sd, int flags, ...); // mouse handling void hideMouse(); @@ -178,7 +176,7 @@ public: void setMouseCursor(int x, int y, byte *shape); // rect handling - int getRectSize(int w, int h); + virtual int getRectSize(int w, int h); void rectClip(int &x, int &y, int w, int h); @@ -208,6 +206,7 @@ public: void copyBackgroundBlock(int x, int page, int flag); void copyBackgroundBlock2(int x); + // kyra1 specific? int getDrawLayer(int x, int y); int getDrawLayer2(int x, int y, int height); @@ -232,15 +231,6 @@ public: static void convertAmigaGfx(uint8 *data, int w, int h, bool offscreen = true); static void convertAmigaMsc(uint8 *data); - // maybe subclass screen for kyra3 - static const ScreenDim _screenDimTableK3[]; - static const int _screenDimTableCountK3; - - uint8 *getPtrToShape(uint8 *shpFile, int shape); - const uint8 *getPtrToShape(const uint8 *shpFile, int shape); - - uint16 getShapeSize(const uint8 *shp); - protected: uint8 *getPagePtr(int pageNum); void updateDirtyRects(); diff --git a/engines/kyra/screen_v2.cpp b/engines/kyra/screen_v2.cpp index 3e98cdbe5b..3ad69818c6 100644 --- a/engines/kyra/screen_v2.cpp +++ b/engines/kyra/screen_v2.cpp @@ -11,7 +11,7 @@ * 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 + * 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 @@ -24,6 +24,7 @@ */ #include "common/stdafx.h" +#include "common/endian.h" #include "kyra/kyra_v2.h" #include "kyra/screen_v2.h" @@ -38,4 +39,523 @@ Screen_v2::Screen_v2(KyraEngine_v2 *vm, OSystem *system) Screen_v2::~Screen_v2() { } +void Screen_v2::setScreenDim(int dim) { + debugC(9, kDebugLevelScreen, "Screen_v2::setScreenDim(%d)", dim); + if (_vm->game() == GI_KYRA2) { + assert(dim < _screenDimTableCount); + _curDim = &_screenDimTable[dim]; + } else { + assert(dim < _screenDimTableCountK3); + _curDim = &_screenDimTableK3[dim]; + } +} + +const ScreenDim *Screen_v2::getScreenDim(int dim) { + debugC(9, kDebugLevelScreen, "Screen_v2::getScreenDim(%d)", dim); + if (_vm->game() == GI_KYRA2) { + assert(dim < _screenDimTableCount); + return &_screenDimTable[dim]; + } else { + assert(dim < _screenDimTableCountK3); + return &_screenDimTableK3[dim]; + } +} + +void Screen_v2::k2IntroFadeToGrey(int delay) { + debugC(9, kDebugLevelScreen, "Screen_v2::k2IntroFadeToGrey(%d)", delay); + + for (int i = 0; i <= 50; ++i) { + if (i <= 8 || i >= 30) { + _currentPalette[3 * i + 0] = (_currentPalette[3 * i + 0] + + _currentPalette[3 * i + 1] + + _currentPalette[3 * i + 2]) / 3; + _currentPalette[3 * i + 1] = _currentPalette[3 * i + 0]; + _currentPalette[3 * i + 2] = _currentPalette[3 * i + 0]; + } + } + + // color 71 is the same in both the overview and closeup scenes + // Converting it to greyscale makes the trees in the closeup look dull + for (int i = 71; i < 200; ++i) { + _currentPalette[3 * i + 0] = (_currentPalette[3 * i + 0] + + _currentPalette[3 * i + 1] + + _currentPalette[3 * i + 2]) / 3; + _currentPalette[3 * i + 1] = _currentPalette[3 * i + 0]; + _currentPalette[3 * i + 2] = _currentPalette[3 * i + 0]; + } + fadePalette(_currentPalette, delay); + // Make the font color white again + setPaletteIndex(254, 254, 254, 254); +} + +void Screen_v2::copyWsaRect(int x, int y, int w, int h, int dimState, int plotFunc, const uint8 *src, + int unk1, const uint8 *unkPtr1, const uint8 *unkPtr2) { + uint8 *dstPtr = getPagePtr(_curPage); + uint8 *origDst = dstPtr; + + const ScreenDim *dim = getScreenDim(dimState); + int dimX1 = dim->sx << 3; + int dimX2 = dim->w << 3; + dimX2 += dimX1; + + int dimY1 = dim->sy; + int dimY2 = dim->h; + dimY2 += dimY1; + + int temp = y - dimY1; + if (temp < 0) { + if ((temp += h) <= 0) + return; + else { + SWAP(temp, h); + y += temp - h; + src += (temp - h) * w; + } + } + + temp = dimY2 - y; + if (temp <= 0) + return; + + if (temp < h) + h = temp; + + int srcOffset = 0; + temp = x - dimX1; + if (temp < 0) { + temp = -temp; + srcOffset = temp; + x += temp; + w -= temp; + } + + int srcAdd = 0; + + temp = dimX2 - x; + if (temp <= 0) + return; + + if (temp < w) { + SWAP(w, temp); + temp -= w; + srcAdd = temp; + } + + dstPtr += y * SCREEN_W + x; + uint8 *dst = dstPtr; + + if (_curPage == 0 || _curPage == 1) + addDirtyRect(x, y, w, h); + + clearOverlayRect(_curPage, x, y, w, h); + + temp = h; + while (h--) { + src += srcOffset; + int cW = w; + + switch (plotFunc) { + case 0: + memcpy(dst, src, cW); + dst += cW; src += cW; + break; + + case 1: + while (cW--) { + uint8 d = *src++; + uint8 t = unkPtr1[d]; + if (t != 0xFF) + d = unkPtr2[*dst + (t << 8)]; + *dst++ = d; + } + break; + + case 4: + while (cW--) { + uint8 d = *src++; + if (d) + *dst = d; + ++dst; + } + break; + + case 5: + while (cW--) { + uint8 d = *src++; + if (d) { + uint8 t = unkPtr1[d]; + if (t != 0xFF) + d = unkPtr2[*dst + (t << 8)]; + *dst = d; + } + ++dst; + } + break; + + case 8: + case 9: + while (cW--) { + uint8 d = *src++; + uint8 t = _shapePages[0][dst - origDst] & 7; + if (unk1 < t) + d = _shapePages[1][dst - origDst]; + *dst++ = d; + } + break; + + case 12: + case 13: + while (cW--) { + uint8 d = *src++; + if (d) { + uint8 t = _shapePages[0][dst - origDst] & 7; + if (unk1 < t) + d = _shapePages[1][dst - origDst]; + *dst++ = d; + } else { + d = _shapePages[1][dst - origDst]; + *dst++ = d; + } + } + break; + + default: + break; + } + + dst = (dstPtr += SCREEN_W); + src += srcAdd; + } +} + +const uint8 *Screen_v2::getPtrToShape(const uint8 *shpFile, int shape) { + debugC(9, kDebugLevelScreen, "Screen_v2::getPtrToShape(%p, %d)", (const void *)shpFile, shape); + uint16 shapes = READ_LE_UINT16(shpFile); + + if (shapes <= shape) + return 0; + + uint32 offset = READ_LE_UINT32(shpFile + (shape << 2) + 2); + + return shpFile + offset + 2; +} + +uint8 *Screen_v2::getPtrToShape(uint8 *shpFile, int shape) { + debugC(9, kDebugLevelScreen, "Screen_v2::getPtrToShape(%p, %d)", (void *)shpFile, shape); + uint16 shapes = READ_LE_UINT16(shpFile); + + if (shapes <= shape) + return 0; + + uint32 offset = READ_LE_UINT32(shpFile + (shape << 2) + 2); + + return shpFile + offset + 2; +} + +int Screen_v2::getShapeScaledWidth(const uint8 *shpFile, int scale) { + int width = READ_LE_UINT16(shpFile+3); + return (width * scale) >> 8; +} + +int Screen_v2::getShapeScaledHeight(const uint8 *shpFile, int scale) { + int height = shpFile[2]; + return (height * scale) >> 8; +} + +uint16 Screen_v2::getShapeSize(const uint8 *shp) { + debugC(9, kDebugLevelScreen, "Screen_v2::getShapeSize(%p)", (const void *)shp); + + return READ_LE_UINT16(shp+6); +} + +uint8 *Screen_v2::makeShapeCopy(const uint8 *src, int index) { + debugC(9, kDebugLevelScreen, "Screen_v2::makeShapeCopy(%p, %d)", (const void *)src, index); + + const uint8 *shape = getPtrToShape(src, index); + int size = getShapeSize(shape); + + uint8 *copy = new uint8[size]; + assert(copy); + memcpy(copy, shape, size); + + return copy; +} + +void Screen_v2::drawShape(uint8 page, const uint8 *shape, int x, int y, int sd, int flags, ...) { + if (!shape) + return; + + if (*shape & 1) + flags |= 0x400; + + va_list args; + va_start(args, flags); + + static int drawShapeVar1 = 0; + static int drawShapeVar2[] = { + 1, 3, 2, 5, 4, 3, 2, 1 + }; + static int drawShapeVar3 = 1; + static int drawShapeVar4 = 0; + static int drawShapeVar5 = 0; + + uint8 *table = 0; + int tableLoopCount = 0; + int drawLayer = 0; + const uint8 *table2 = 0; + uint8 *table3 = 0; + uint8 *table4 = 0; + + if (flags & 0x8000) { + table2 = va_arg(args, uint8*); + } + if (flags & 0x100) { + table = va_arg(args, uint8*); + tableLoopCount = va_arg(args, int); + if (!tableLoopCount) + flags &= 0xFFFFFEFF; + } + if (flags & 0x1000) { + table3 = va_arg(args, uint8*); + table4 = va_arg(args, uint8*); + } + if (flags & 0x200) { + drawShapeVar1 += 1; + drawShapeVar1 &= 7; + drawShapeVar3 = drawShapeVar2[drawShapeVar1]; + drawShapeVar4 = 0; + drawShapeVar5 = 256; + } + if (flags & 0x4000) { + drawShapeVar5 = va_arg(args, int); + } + if (flags & 0x800) { + drawLayer = va_arg(args, int); + } + int scale_w, scale_h; + if (flags & 0x04) { + scale_w = va_arg(args, int); + scale_h = va_arg(args, int); + } else { + scale_w = 0x100; + scale_h = 0x100; + } + + int ppc = (flags >> 8) & 0x3F; + + const uint8 *src = shape; + uint16 shapeFlags = READ_LE_UINT16(src); src += 2; + + int shapeHeight = *src++; + int scaledShapeHeight = (shapeHeight * scale_h) >> 8; + if (scaledShapeHeight == 0) { + va_end(args); + return; + } + + int shapeWidth = READ_LE_UINT16(src); src += 2; + int scaledShapeWidth = (shapeWidth * scale_w) >> 8; + if (scaledShapeWidth == 0) { + va_end(args); + return; + } + + if (flags & 0x20) { + x -= scaledShapeWidth >> 1; + y -= scaledShapeHeight >> 1; + } + + src += 3; + + uint16 frameSize = READ_LE_UINT16(src); src += 2; + int colorTableColors = 0x10; + + if (shapeFlags & 4) + colorTableColors = *src++; + + if (!(flags & 0x8000) && (shapeFlags & 1)) + table2 = src; + + if ((shapeFlags & 1) || (flags & 0x400)) + src += colorTableColors; + + if (!(shapeFlags & 2)) { + decodeFrame4(src, _animBlockPtr, frameSize); + src = _animBlockPtr; + } + + int shapeSize = shapeWidth * shapeHeight; + if (_decodeShapeBufferSize < shapeSize) { + delete [] _decodeShapeBuffer; + _decodeShapeBuffer = new uint8[shapeSize]; + _decodeShapeBufferSize = shapeSize; + } + if (!_decodeShapeBuffer) { + _decodeShapeBufferSize = 0; + va_end(args); + return; + } + memset(_decodeShapeBuffer, 0, _decodeShapeBufferSize); + uint8 *decodedShapeFrame = _decodeShapeBuffer; + + for (int j = 0; j < shapeHeight; ++j) { + uint8 *dsbNextLine = decodedShapeFrame + shapeWidth; + int count = shapeWidth; + while (count > 0) { + uint8 code = *src++; + if (code != 0) { + *decodedShapeFrame++ = code; + --count; + } else { + code = *src++; + decodedShapeFrame += code; + count -= code; + } + } + decodedShapeFrame = dsbNextLine; + } + + uint16 sx1 = getScreenDim(sd)->sx << 3; + uint16 sy1 = getScreenDim(sd)->sy; + uint16 sx2 = sx1 + getScreenDim(sd)->w << 3; + uint16 sy2 = sy1 + getScreenDim(sd)->h; + if (flags & 0x10) { + x += sx1; + y += sy1; + } + + int x1, x2; + if (x >= 0) { + x1 = 0; + if (x + scaledShapeWidth < sx2) { + x2 = scaledShapeWidth; + } else { + x2 = sx2 - x; + } + } else { + x2 = scaledShapeWidth; + x1 = -x; + x = 0; + if (x2 > sx2) { + x2 = sx2; + } + } + + int y1, y2; + if (y >= 0) { + y1 = 0; + if (y + scaledShapeHeight < sy2) { + y2 = scaledShapeHeight; + } else { + y2 = sy2 - y; + } + } else { + y2 = scaledShapeHeight; + y1 = -y; + y = 0; + if (y2 > sy2) { + y2 = sy2; + } + } + + uint8 *dst = getPagePtr(page) + y * 320 + x; + uint8 *dstStart = getPagePtr(page); + + int scaleYTable[200]; + for (y = y1; y < y2; ++y) { + scaleYTable[y] = (y << 8) / scale_h; + } + int scaleXTable[320]; + for (x = x1; x < x2; ++x) { + scaleXTable[x] = (x << 8) / scale_w; + } + + const uint8 *shapeBuffer = _decodeShapeBuffer; + if (flags & 0x02) { + shapeBuffer += shapeWidth * (shapeHeight - 1); + } + if (flags & 0x01) { + shapeBuffer += shapeWidth - 1; + } + + for (y = y1; y < y2; ++y) { + uint8 *dstNextLine = dst + 320; + int j = scaleYTable[y]; + if (flags & 0x02) { + j = -j; + } + for (x = x1; x < x2; ++x) { + int xpos = scaleXTable[x]; + if (flags & 0x01) + xpos = -xpos; + uint8 color = shapeBuffer[j * shapeWidth + xpos]; + if (color != 0) { + switch (ppc) { + case 0: + *dst = color; + break; + + case 4: + *dst = table2[color]; + break; + + case 8: { + int layer = _shapePages[0][dst - dstStart] & 7; + if (drawLayer > layer) + color = _shapePages[1][dst - dstStart]; + *dst = color; + } break; + + case 12: { + int layer = _shapePages[0][dst - dstStart] & 7; + if (drawLayer < layer) + color = _shapePages[1][dst - dstStart]; + else + color = table2[color]; + *dst = color; + } break; + + default: + warning("unhandled ppc: %d", ppc); + break; + } + } + ++dst; + } + dst = dstNextLine; + } + va_end(args); +} + +int Screen_v2::getRectSize(int w, int h) { + if (w > 320 || h > 200) + return 0; + return w*h; +} + +int Screen_v2::getLayer(int x, int y) { + if (x < 0) + x = 0; + else if (x >= 320) + x = 319; + if (y < 0) + y = 0; + else if (y >= 144) + y = 143; + + uint8 pixel = *(getCPagePtr(5) + y * 320 + x); + pixel &= 0x7F; + pixel >>= 3; + + if (pixel < 1) + pixel = 1; + else if (pixel > 15) + pixel = 15; + return pixel; +} + +bool Screen_v2::isMouseVisible() const { + return _mouseLockCount == 0; +} + } // end of namespace Kyra diff --git a/engines/kyra/screen_v2.h b/engines/kyra/screen_v2.h index e45d44d3ff..7912d6b999 100644 --- a/engines/kyra/screen_v2.h +++ b/engines/kyra/screen_v2.h @@ -11,7 +11,7 @@ * 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 + * 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 @@ -36,8 +36,47 @@ class Screen_v2 : public Screen { public: Screen_v2(KyraEngine_v2 *vm, OSystem *system); virtual ~Screen_v2(); + + virtual void setScreenDim(int dim); + const ScreenDim *getScreenDim(int dim); + + // palette handling + void k2IntroFadeToGrey(int delay=0x54); + + // screen page handling + void copyWsaRect(int x, int y, int w, int h, int dimState, int plotFunc, const uint8 *src, + int unk1, const uint8 *unkPtr1, const uint8 *unkPtr2); + + // shape handling + uint8 *getPtrToShape(uint8 *shpFile, int shape); + const uint8 *getPtrToShape(const uint8 *shpFile, int shape); + + int getShapeScaledWidth(const uint8 *shpFile, int scale); + int getShapeScaledHeight(const uint8 *shpFile, int scale); + + uint16 getShapeSize(const uint8 *shp); + + uint8 *makeShapeCopy(const uint8 *src, int index); + + void drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, int sd, int flags, ...); + + // rect handling + virtual int getRectSize(int w, int h); + + // layer handling + int getLayer(int x, int y); + + // mouse handling + bool isMouseVisible() const; private: KyraEngine_v2 *_vm; + + static const ScreenDim _screenDimTable[]; + static const int _screenDimTableCount; + + // maybe subclass screen for kyra3 + static const ScreenDim _screenDimTableK3[]; + static const int _screenDimTableCountK3; }; } // End of namespace Kyra diff --git a/engines/kyra/script.cpp b/engines/kyra/script.cpp index b43cd3b471..739e92feda 100644 --- a/engines/kyra/script.cpp +++ b/engines/kyra/script.cpp @@ -40,64 +40,62 @@ namespace Kyra { ScriptHelper::ScriptHelper(KyraEngine *vm) : _vm(vm) { #define COMMAND(x) { &ScriptHelper::x, #x } - // now we create a list of all Command/Opcode procs and so static CommandEntry commandProcs[] = { // 0x00 - COMMAND(c1_jmpTo), - COMMAND(c1_setRetValue), - COMMAND(c1_pushRetOrPos), - COMMAND(c1_push), + COMMAND(cmd_jmpTo), + COMMAND(cmd_setRetValue), + COMMAND(cmd_pushRetOrPos), + COMMAND(cmd_push), // 0x04 - COMMAND(c1_push), - COMMAND(c1_pushReg), - COMMAND(c1_pushBPNeg), - COMMAND(c1_pushBPAdd), + COMMAND(cmd_push), + COMMAND(cmd_pushReg), + COMMAND(cmd_pushBPNeg), + COMMAND(cmd_pushBPAdd), // 0x08 - COMMAND(c1_popRetOrPos), - COMMAND(c1_popReg), - COMMAND(c1_popBPNeg), - COMMAND(c1_popBPAdd), + COMMAND(cmd_popRetOrPos), + COMMAND(cmd_popReg), + COMMAND(cmd_popBPNeg), + COMMAND(cmd_popBPAdd), // 0x0C - COMMAND(c1_addSP), - COMMAND(c1_subSP), - COMMAND(c1_execOpcode), - COMMAND(c1_ifNotJmp), + COMMAND(cmd_addSP), + COMMAND(cmd_subSP), + COMMAND(cmd_execOpcode), + COMMAND(cmd_ifNotJmp), // 0x10 - COMMAND(c1_negate), - COMMAND(c1_eval), - COMMAND(c1_setRetAndJmp) + COMMAND(cmd_negate), + COMMAND(cmd_eval), + COMMAND(cmd_setRetAndJmp) }; _commands = commandProcs; #undef COMMAND } bool ScriptHelper::loadScript(const char *filename, ScriptData *scriptData, const Common::Array *opcodes) { - uint32 size = 0; - uint8 *data = _vm->resource()->fileData(filename, &size); - const byte *curData = data; + ScriptFileParser file(filename, _vm->resource()); + if (!file) { + error("Couldn't open script file '%s'", filename); + return false; + } - uint32 formBlockSize = getFORMBlockSize(curData); + uint32 formBlockSize = file.getFORMBlockSize(); if (formBlockSize == (uint32)-1) { - delete [] data; error("No FORM chunk found in file: '%s'", filename); return false; } - uint32 chunkSize = getIFFBlockSize(data, curData, size, TEXT_CHUNK); + uint32 chunkSize = file.getIFFBlockSize(TEXT_CHUNK); if (chunkSize != (uint32)-1) { scriptData->text = new byte[chunkSize]; - if (!loadIFFBlock(data, curData, size, TEXT_CHUNK, scriptData->text, chunkSize)) { - delete [] data; + if (!file.loadIFFBlock(TEXT_CHUNK, scriptData->text, chunkSize)) { unloadScript(scriptData); error("Couldn't load TEXT chunk from file: '%s'", filename); return false; } } - chunkSize = getIFFBlockSize(data, curData, size, ORDR_CHUNK); + chunkSize = file.getIFFBlockSize(ORDR_CHUNK); if (chunkSize == (uint32)-1) { - delete [] data; unloadScript(scriptData); error("No ORDR chunk found in file: '%s'", filename); return false; @@ -106,8 +104,7 @@ bool ScriptHelper::loadScript(const char *filename, ScriptData *scriptData, cons scriptData->ordr = new uint16[chunkSize]; - if (!loadIFFBlock(data, curData, size, ORDR_CHUNK, scriptData->ordr, chunkSize << 1)) { - delete [] data; + if (!file.loadIFFBlock(ORDR_CHUNK, scriptData->ordr, chunkSize << 1)) { unloadScript(scriptData); error("Couldn't load ORDR chunk from file: '%s'", filename); return false; @@ -116,9 +113,8 @@ bool ScriptHelper::loadScript(const char *filename, ScriptData *scriptData, cons while (chunkSize--) scriptData->ordr[chunkSize] = READ_BE_UINT16(&scriptData->ordr[chunkSize]); - chunkSize = getIFFBlockSize(data, curData, size, DATA_CHUNK); + chunkSize = file.getIFFBlockSize(DATA_CHUNK); if (chunkSize == (uint32)-1) { - delete [] data; unloadScript(scriptData); error("No DATA chunk found in file: '%s'", filename); return false; @@ -127,8 +123,7 @@ bool ScriptHelper::loadScript(const char *filename, ScriptData *scriptData, cons scriptData->data = new uint16[chunkSize]; - if (!loadIFFBlock(data, curData, size, DATA_CHUNK, scriptData->data, chunkSize << 1)) { - delete [] data; + if (!file.loadIFFBlock(DATA_CHUNK, scriptData->data, chunkSize << 1)) { unloadScript(scriptData); error("Couldn't load DATA chunk from file: '%s'", filename); return false; @@ -139,8 +134,7 @@ bool ScriptHelper::loadScript(const char *filename, ScriptData *scriptData, cons scriptData->data[chunkSize] = READ_BE_UINT16(&scriptData->data[chunkSize]); scriptData->opcodes = opcodes; - - delete [] data; + return true; } @@ -172,10 +166,14 @@ bool ScriptHelper::startScript(ScriptState *script, int function) { if (functionOffset == 0xFFFF) return false; - if (_vm->gameFlags().platform == Common::kPlatformFMTowns) + if (_vm->game() == GI_KYRA1) { + if (_vm->gameFlags().platform == Common::kPlatformFMTowns) + script->ip = &script->dataPtr->data[functionOffset+1]; + else + script->ip = &script->dataPtr->data[functionOffset]; + } else { script->ip = &script->dataPtr->data[functionOffset+1]; - else - script->ip = &script->dataPtr->data[functionOffset]; + } return true; } @@ -217,37 +215,51 @@ bool ScriptHelper::runScript(ScriptState *script) { return _continue; } -uint32 ScriptHelper::getFORMBlockSize(const byte *&data) const { - static const uint32 chunkName = FORM_CHUNK; +#pragma mark - +#pragma mark - ScriptFileParser implementation +#pragma mark - + +void ScriptFileParser::setFile(const char *filename, Resource *res) { + destroy(); + + if (!res->getFileHandle(filename, &_endOffset, _scriptFile)) + return; + _startOffset = _scriptFile.pos(); + _endOffset += _startOffset; +} + +void ScriptFileParser::destroy() { + _scriptFile.close(); + _startOffset = _endOffset = 0; +} + +uint32 ScriptFileParser::getFORMBlockSize() { + uint32 oldOffset = _scriptFile.pos(); + + uint32 data = _scriptFile.readUint32LE(); - if (READ_LE_UINT32(data) != chunkName) + if (data != FORM_CHUNK) { + _scriptFile.seek(oldOffset); return (uint32)-1; + } - data += 4; - uint32 retValue = READ_BE_UINT32(data); data += 4; - return retValue; + data = _scriptFile.readUint32BE(); + return data; } -uint32 ScriptHelper::getIFFBlockSize(const byte *start, const byte *&data, uint32 maxSize, const uint32 chunkName) const { +uint32 ScriptFileParser::getIFFBlockSize(const uint32 chunkName) { uint32 size = (uint32)-1; - bool special = false; - if (data == (start + maxSize)) - data = start + 0x0C; + _scriptFile.seek(_startOffset + 0x0C); - while (data < (start + maxSize)) { - uint32 chunk = READ_LE_UINT32(data); data += 4; - uint32 size_temp = READ_BE_UINT32(data); data += 4; + while (_scriptFile.pos() < _endOffset) { + uint32 chunk = _scriptFile.readUint32LE(); + uint32 size_temp = _scriptFile.readUint32BE(); + if (chunk != chunkName) { - if (special) { - data += (size_temp + 1) & 0xFFFFFFFE; - } else { - data = start + 0x0C; - special = true; - } + _scriptFile.seek((size_temp + 1) & (~1), SEEK_CUR); + assert(_scriptFile.pos() <= _endOffset); } else { - // kill our data - data = start; size = size_temp; break; } @@ -256,32 +268,21 @@ uint32 ScriptHelper::getIFFBlockSize(const byte *start, const byte *&data, uint3 return size; } -bool ScriptHelper::loadIFFBlock(const byte *start, const byte *&data, uint32 maxSize, const uint32 chunkName, void *loadTo, uint32 ptrSize) const { - bool special = false; - - if (data == (start + maxSize)) - data = start + 0x0C; +bool ScriptFileParser::loadIFFBlock(const uint32 chunkName, void *loadTo, uint32 ptrSize) { + _scriptFile.seek(_startOffset + 0x0C); + + while (_scriptFile.pos() < _endOffset) { + uint32 chunk = _scriptFile.readUint32LE(); + uint32 chunkSize = _scriptFile.readUint32BE(); - while (data < (start + maxSize)) { - uint32 chunk = READ_LE_UINT32(data); data += 4; - uint32 chunkSize = READ_BE_UINT32(data); data += 4; if (chunk != chunkName) { - if (special) { - data += (chunkSize + 1) & 0xFFFFFFFE; - } else { - data = start + 0x0C; - special = true; - } + _scriptFile.seek((chunkSize + 1) & (~1), SEEK_CUR); + assert(_scriptFile.pos() <= _endOffset); } else { uint32 loadSize = 0; - if (chunkSize < ptrSize) - loadSize = chunkSize; - else - loadSize = ptrSize; - memcpy(loadTo, data, loadSize); - chunkSize = (chunkSize + 1) & 0xFFFFFFFE; - if (chunkSize > loadSize) - data += (chunkSize - loadSize); + + loadSize = MIN(ptrSize, chunkSize); + _scriptFile.read(loadTo, loadSize); return true; } } @@ -293,15 +294,15 @@ bool ScriptHelper::loadIFFBlock(const byte *start, const byte *&data, uint32 max #pragma mark - Command implementations #pragma mark - -void ScriptHelper::c1_jmpTo(ScriptState* script) { +void ScriptHelper::cmd_jmpTo(ScriptState* script) { script->ip = script->dataPtr->data + _parameter; } -void ScriptHelper::c1_setRetValue(ScriptState* script) { +void ScriptHelper::cmd_setRetValue(ScriptState* script) { script->retValue = _parameter; } -void ScriptHelper::c1_pushRetOrPos(ScriptState* script) { +void ScriptHelper::cmd_pushRetOrPos(ScriptState* script) { switch (_parameter) { case 0: script->stack[--script->sp] = script->retValue; @@ -320,23 +321,23 @@ void ScriptHelper::c1_pushRetOrPos(ScriptState* script) { } } -void ScriptHelper::c1_push(ScriptState* script) { +void ScriptHelper::cmd_push(ScriptState* script) { script->stack[--script->sp] = _parameter; } -void ScriptHelper::c1_pushReg(ScriptState* script) { +void ScriptHelper::cmd_pushReg(ScriptState* script) { script->stack[--script->sp] = script->regs[_parameter]; } -void ScriptHelper::c1_pushBPNeg(ScriptState* script) { +void ScriptHelper::cmd_pushBPNeg(ScriptState* script) { script->stack[--script->sp] = script->stack[(-(int32)(_parameter + 2)) + script->bp]; } -void ScriptHelper::c1_pushBPAdd(ScriptState* script) { +void ScriptHelper::cmd_pushBPAdd(ScriptState* script) { script->stack[--script->sp] = script->stack[(_parameter - 1) + script->bp]; } -void ScriptHelper::c1_popRetOrPos(ScriptState* script) { +void ScriptHelper::cmd_popRetOrPos(ScriptState* script) { switch (_parameter) { case 0: script->retValue = script->stack[script->sp++]; @@ -359,48 +360,48 @@ void ScriptHelper::c1_popRetOrPos(ScriptState* script) { } } -void ScriptHelper::c1_popReg(ScriptState* script) { +void ScriptHelper::cmd_popReg(ScriptState* script) { script->regs[_parameter] = script->stack[script->sp++]; } -void ScriptHelper::c1_popBPNeg(ScriptState* script) { +void ScriptHelper::cmd_popBPNeg(ScriptState* script) { script->stack[(-(int32)(_parameter + 2)) + script->bp] = script->stack[script->sp++]; } -void ScriptHelper::c1_popBPAdd(ScriptState* script) { +void ScriptHelper::cmd_popBPAdd(ScriptState* script) { script->stack[(_parameter - 1) + script->bp] = script->stack[script->sp++]; } -void ScriptHelper::c1_addSP(ScriptState* script) { +void ScriptHelper::cmd_addSP(ScriptState* script) { script->sp += _parameter; } -void ScriptHelper::c1_subSP(ScriptState* script) { +void ScriptHelper::cmd_subSP(ScriptState* script) { script->sp -= _parameter; } -void ScriptHelper::c1_execOpcode(ScriptState* script) { +void ScriptHelper::cmd_execOpcode(ScriptState* script) { uint8 opcode = _parameter; assert(script->dataPtr->opcodes); assert(opcode < script->dataPtr->opcodes->size()); - if ((*script->dataPtr->opcodes)[opcode]) { + if ((*script->dataPtr->opcodes)[opcode] && *(*script->dataPtr->opcodes)[opcode]) { script->retValue = (*(*script->dataPtr->opcodes)[opcode])(script); } else { script->retValue = 0; - warning("calling unimplemented opcode(0x%.02X)", opcode); + warning("calling unimplemented opcode(0x%.02X/%d)", opcode, opcode); } } -void ScriptHelper::c1_ifNotJmp(ScriptState* script) { +void ScriptHelper::cmd_ifNotJmp(ScriptState* script) { if (!script->stack[script->sp++]) { _parameter &= 0x7FFF; script->ip = script->dataPtr->data + _parameter; } } -void ScriptHelper::c1_negate(ScriptState* script) { +void ScriptHelper::cmd_negate(ScriptState* script) { int16 value = script->stack[script->sp]; switch (_parameter) { case 0: @@ -424,7 +425,7 @@ void ScriptHelper::c1_negate(ScriptState* script) { } } -void ScriptHelper::c1_eval(ScriptState* script) { +void ScriptHelper::cmd_eval(ScriptState* script) { int16 ret = 0; bool error = false; @@ -542,7 +543,7 @@ void ScriptHelper::c1_eval(ScriptState* script) { } } -void ScriptHelper::c1_setRetAndJmp(ScriptState* script) { +void ScriptHelper::cmd_setRetAndJmp(ScriptState* script) { if (script->sp >= 60) { _continue = false; script->ip = 0; diff --git a/engines/kyra/script.h b/engines/kyra/script.h index 5e43039110..3396712a24 100644 --- a/engines/kyra/script.h +++ b/engines/kyra/script.h @@ -27,33 +27,11 @@ #define KYRA_SCRIPT_H #include "kyra/kyra.h" +#include "kyra/util.h" -namespace Kyra { - -struct ScriptState; - -struct Opcode { - virtual ~Opcode() {} - - virtual operator bool() const = 0; - - virtual int operator()(ScriptState*) const = 0; -}; +#include "common/file.h" -template -struct OpcodeImpl : public Opcode { - T *vm; - typedef int (T::*Callback)(ScriptState*); - Callback callback; - - OpcodeImpl(T *v, Callback c) : Opcode(), vm(v), callback(c) {} - - operator bool() const { return callback != 0; } - - int operator()(ScriptState *state) const { - return (vm->*callback)(state); - } -}; +namespace Kyra { struct ScriptData { byte *text; @@ -74,6 +52,31 @@ struct ScriptState { int16 stack[61]; // VM stack }; +#define stackPos(x) script->stack[script->sp+x] +#define stackPosString(x) (const char*)&script->dataPtr->text[READ_BE_UINT16(&((uint16 *)script->dataPtr->text)[stackPos(x)])] + +class ScriptFileParser { +public: + ScriptFileParser() : _scriptFile(), _startOffset(0), _endOffset(0) {} + ScriptFileParser(const char *filename, Resource *res) : _scriptFile(), _startOffset(0), _endOffset(0) { setFile(filename, res); } + ~ScriptFileParser() { destroy(); } + + // 'script' must be allocated with new! + void setFile(const char *filename, Resource *res); + + operator bool() const { return (_startOffset != _endOffset) && _scriptFile.isOpen(); } + + uint32 getFORMBlockSize(); + uint32 getIFFBlockSize(const uint32 chunk); + bool loadIFFBlock(const uint32 chunk, void *loadTo, uint32 ptrSize); +private: + void destroy(); + + Common::File _scriptFile; + uint32 _startOffset; + uint32 _endOffset; +}; + class ScriptHelper { public: ScriptHelper(KyraEngine *vm); @@ -88,10 +91,6 @@ public: bool runScript(ScriptState *script); protected: - uint32 getFORMBlockSize(const byte *&data) const; - uint32 getIFFBlockSize(const byte *start, const byte *&data, uint32 maxSize, const uint32 chunk) const; - bool loadIFFBlock(const byte *start, const byte *&data, uint32 maxSize, const uint32 chunk, void *loadTo, uint32 ptrSize) const; - KyraEngine *_vm; int16 _parameter; bool _continue; @@ -104,25 +103,24 @@ protected: const CommandEntry *_commands; private: - void c1_jmpTo(ScriptState*); - void c1_setRetValue(ScriptState*); - void c1_pushRetOrPos(ScriptState*); - void c1_push(ScriptState*); - //void c1_push(); same as 03 - void c1_pushReg(ScriptState*); - void c1_pushBPNeg(ScriptState*); - void c1_pushBPAdd(ScriptState*); - void c1_popRetOrPos(ScriptState*); - void c1_popReg(ScriptState*); - void c1_popBPNeg(ScriptState*); - void c1_popBPAdd(ScriptState*); - void c1_addSP(ScriptState*); - void c1_subSP(ScriptState*); - void c1_execOpcode(ScriptState*); - void c1_ifNotJmp(ScriptState*); - void c1_negate(ScriptState*); - void c1_eval(ScriptState*); - void c1_setRetAndJmp(ScriptState*); + void cmd_jmpTo(ScriptState*); + void cmd_setRetValue(ScriptState*); + void cmd_pushRetOrPos(ScriptState*); + void cmd_push(ScriptState*); + void cmd_pushReg(ScriptState*); + void cmd_pushBPNeg(ScriptState*); + void cmd_pushBPAdd(ScriptState*); + void cmd_popRetOrPos(ScriptState*); + void cmd_popReg(ScriptState*); + void cmd_popBPNeg(ScriptState*); + void cmd_popBPAdd(ScriptState*); + void cmd_addSP(ScriptState*); + void cmd_subSP(ScriptState*); + void cmd_execOpcode(ScriptState*); + void cmd_ifNotJmp(ScriptState*); + void cmd_negate(ScriptState*); + void cmd_eval(ScriptState*); + void cmd_setRetAndJmp(ScriptState*); }; } // end of namespace Kyra diff --git a/engines/kyra/script_v1.cpp b/engines/kyra/script_v1.cpp index 14edf5fff8..bd776e2046 100644 --- a/engines/kyra/script_v1.cpp +++ b/engines/kyra/script_v1.cpp @@ -25,6 +25,8 @@ #include "common/stdafx.h" #include "common/endian.h" +#include "common/system.h" + #include "kyra/kyra_v1.h" #include "kyra/script.h" #include "kyra/screen.h" @@ -32,14 +34,11 @@ #include "kyra/wsamovie.h" #include "kyra/animator_v1.h" #include "kyra/text.h" -#include "common/system.h" +#include "kyra/timer.h" namespace Kyra { -#define stackPos(x) script->stack[script->sp+x] -#define stackPosString(x) (const char*)&script->dataPtr->text[READ_BE_UINT16(&((uint16 *)script->dataPtr->text)[stackPos(x)])] - int KyraEngine_v1::o1_magicInMouseItem(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_magicInMouseItem(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1magicInMouseItem(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); magicInMouseItem(stackPos(0), stackPos(1), -1); return 0; } @@ -47,10 +46,10 @@ int KyraEngine_v1::o1_magicInMouseItem(ScriptState *script) { int KyraEngine_v1::o1_characterSays(ScriptState *script) { _skipFlag = false; if (_flags.isTalkie) { - debugC(3, kDebugLevelScriptFuncs, "o1_characterSays(%p) (%d, '%s', %d, %d)", (const void *)script, stackPos(0), stackPosString(1), stackPos(2), stackPos(3)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1characterSays(%p) (%d, '%s', %d, %d)", (const void *)script, stackPos(0), stackPosString(1), stackPos(2), stackPos(3)); characterSays(stackPos(0), stackPosString(1), stackPos(2), stackPos(3)); } else { - debugC(3, kDebugLevelScriptFuncs, "o1_characterSays(%p) ('%s', %d, %d)", (const void *)script, stackPosString(0), stackPos(1), stackPos(2)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1characterSays(%p) ('%s', %d, %d)", (const void *)script, stackPosString(0), stackPos(1), stackPos(2)); const char *string = stackPosString(0); if (_flags.platform == Common::kPlatformFMTowns && _flags.lang == Common::JA_JPN) { @@ -76,7 +75,7 @@ int KyraEngine_v1::o1_characterSays(ScriptState *script) { } int KyraEngine_v1::o1_pauseTicks(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_pauseTicks(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1pauseTicks(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); if (stackPos(1)) { warning("STUB: special o1_pauseTicks"); // delete this after correct implementing @@ -88,23 +87,23 @@ int KyraEngine_v1::o1_pauseTicks(ScriptState *script) { } int KyraEngine_v1::o1_drawSceneAnimShape(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_drawSceneAnimShape(%p) (%d, %d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1drawSceneAnimShape(%p) (%d, %d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4)); _screen->drawShape(stackPos(4), _sprites->_sceneShapes[stackPos(0)], stackPos(1), stackPos(2), 0, (stackPos(3) != 0) ? 1 : 0); return 0; } int KyraEngine_v1::o1_queryGameFlag(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_queryGameFlag(%p) (0x%X)", (const void *)script, stackPos(0)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1queryGameFlag(%p) (0x%X)", (const void *)script, stackPos(0)); return queryGameFlag(stackPos(0)); } int KyraEngine_v1::o1_setGameFlag(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_setGameFlag(%p) (0x%X)", (const void *)script, stackPos(0)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1setGameFlag(%p) (0x%X)", (const void *)script, stackPos(0)); return setGameFlag(stackPos(0)); } int KyraEngine_v1::o1_resetGameFlag(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_resetGameFlag(%p) (0x%X)", (const void *)script, stackPos(0)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1resetGameFlag(%p) (0x%X)", (const void *)script, stackPos(0)); return resetGameFlag(stackPos(0)); } @@ -114,7 +113,7 @@ int KyraEngine_v1::o1_runNPCScript(ScriptState *script) { } int KyraEngine_v1::o1_setSpecialExitList(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_setSpecialExitList(%p) (%d, %d, %d, %d, %d, %d, %d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4), stackPos(5), stackPos(6), stackPos(7), stackPos(8), stackPos(9)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1setSpecialExitList(%p) (%d, %d, %d, %d, %d, %d, %d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4), stackPos(5), stackPos(6), stackPos(7), stackPos(8), stackPos(9)); for (int i = 0; i < 10; ++i) _exitList[i] = stackPos(i); @@ -124,33 +123,33 @@ int KyraEngine_v1::o1_setSpecialExitList(ScriptState *script) { } int KyraEngine_v1::o1_blockInWalkableRegion(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_blockInWalkableRegion(%p) (%d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1blockInWalkableRegion(%p) (%d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3)); _screen->blockInRegion(stackPos(0), stackPos(1), stackPos(2)-stackPos(0)+1, stackPos(3)-stackPos(1)+1); return 0; } int KyraEngine_v1::o1_blockOutWalkableRegion(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_blockOutWalkableRegion(%p) (%d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1blockOutWalkableRegion(%p) (%d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3)); _screen->blockOutRegion(stackPos(0), stackPos(1), stackPos(2)-stackPos(0)+1, stackPos(3)-stackPos(1)+1); return 0; } int KyraEngine_v1::o1_walkPlayerToPoint(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_walkPlayerToPoint(%p) (%d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1walkPlayerToPoint(%p) (%d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3)); int normalTimers = stackPos(2); if (!normalTimers) { - disableTimer(19); - disableTimer(14); - disableTimer(18); + _timer->disable(19); + _timer->disable(14); + _timer->disable(18); } int reinitScript = handleSceneChange(stackPos(0), stackPos(1), stackPos(2), stackPos(3)); if (!normalTimers) { - enableTimer(19); - enableTimer(14); - enableTimer(18); + _timer->enable(19); + _timer->enable(14); + _timer->enable(18); } if (reinitScript) @@ -164,7 +163,7 @@ int KyraEngine_v1::o1_walkPlayerToPoint(ScriptState *script) { } int KyraEngine_v1::o1_dropItemInScene(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_dropItemInScene(%p) (%d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1dropItemInScene(%p) (%d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2)); int item = stackPos(0); int xpos = stackPos(1); int ypos = stackPos(2); @@ -189,7 +188,7 @@ int KyraEngine_v1::o1_dropItemInScene(ScriptState *script) { } int KyraEngine_v1::o1_drawAnimShapeIntoScene(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_drawAnimShapeIntoScene(%p) (%d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1drawAnimShapeIntoScene(%p) (%d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3)); _screen->hideMouse(); _animator->restoreAllObjectBackgrounds(); int shape = stackPos(0); @@ -207,49 +206,49 @@ int KyraEngine_v1::o1_drawAnimShapeIntoScene(ScriptState *script) { } int KyraEngine_v1::o1_createMouseItem(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_createMouseItem(%p) (%d)", (const void *)script, stackPos(0)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1createMouseItem(%p) (%d)", (const void *)script, stackPos(0)); createMouseItem(stackPos(0)); return 0; } int KyraEngine_v1::o1_savePageToDisk(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_savePageToDisk(%p) ('%s', %d)", (const void *)script, stackPosString(0), stackPos(1)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1savePageToDisk(%p) ('%s', %d)", (const void *)script, stackPosString(0), stackPos(1)); _screen->savePageToDisk(stackPosString(0), stackPos(1)); return 0; } int KyraEngine_v1::o1_sceneAnimOn(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_sceneAnimOn(%p) (%d)", (const void *)script, stackPos(0)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1sceneAnimOn(%p) (%d)", (const void *)script, stackPos(0)); _sprites->_anims[stackPos(0)].play = true; return 0; } int KyraEngine_v1::o1_sceneAnimOff(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_sceneAnimOff(%p) (%d)", (const void *)script, stackPos(0)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1sceneAnimOff(%p) (%d)", (const void *)script, stackPos(0)); _sprites->_anims[stackPos(0)].play = false; return 0; } int KyraEngine_v1::o1_getElapsedSeconds(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_getElapsedSeconds(%p) ()", (const void *)script); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1getElapsedSeconds(%p) ()", (const void *)script); return _system->getMillis() / 1000; } int KyraEngine_v1::o1_mouseIsPointer(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_mouseIsPointer(%p) ()", (const void *)script); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1mouseIsPointer(%p) ()", (const void *)script); if (_itemInHand == -1) return 1; return 0; } int KyraEngine_v1::o1_destroyMouseItem(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_destroyMouseItem(%p) ()", (const void *)script); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1destroyMouseItem(%p) ()", (const void *)script); destroyMouseItem(); return 0; } int KyraEngine_v1::o1_runSceneAnimUntilDone(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_runSceneAnimUntilDone(%p) (%d)", (const void *)script, stackPos(0)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1runSceneAnimUntilDone(%p) (%d)", (const void *)script, stackPos(0)); _screen->hideMouse(); _animator->restoreAllObjectBackgrounds(); _sprites->_anims[stackPos(0)].play = true; @@ -268,59 +267,59 @@ int KyraEngine_v1::o1_runSceneAnimUntilDone(ScriptState *script) { int KyraEngine_v1::o1_fadeSpecialPalette(ScriptState *script) { if (_flags.platform == Common::kPlatformAmiga) { - debugC(3, kDebugLevelScriptFuncs, "o1_fadeSpecialPalette(%p) (%d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1fadeSpecialPalette(%p) (%d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2)); if (_currentCharacter->sceneId != 45) { if (stackPos(0) == 13) { memcpy(_screen->getPalette(0), _screen->getPalette(0) + 384*3, 32*3); _screen->setScreenPalette(_screen->getPalette(0)); } } else { - warning("o1_fadeSpecialPalette not implemented"); + warning("KyraEngine_v1::o1fadeSpecialPalette not implemented"); } } else { - debugC(3, kDebugLevelScriptFuncs, "o1_fadeSpecialPalette(%p) (%d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1fadeSpecialPalette(%p) (%d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3)); _screen->fadeSpecialPalette(stackPos(0), stackPos(1), stackPos(2), stackPos(3)); } return 0; } int KyraEngine_v1::o1_playAdlibSound(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_playAdlibSound(%p) (%d)", (const void *)script, stackPos(0)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1playAdlibSound(%p) (%d)", (const void *)script, stackPos(0)); snd_playSoundEffect(stackPos(0)); return 0; } int KyraEngine_v1::o1_playAdlibScore(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_playAdlibScore(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1playAdlibScore(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); snd_playWanderScoreViaMap(stackPos(0), stackPos(1)); return 0; } int KyraEngine_v1::o1_phaseInSameScene(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_phaseInSameScene(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1phaseInSameScene(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); transcendScenes(stackPos(0), stackPos(1)); return 0; } int KyraEngine_v1::o1_setScenePhasingFlag(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_setScenePhasingFlag(%p) ()", (const void *)script); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1setScenePhasingFlag(%p) ()", (const void *)script); _scenePhasingFlag = 1; return 1; } int KyraEngine_v1::o1_resetScenePhasingFlag(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_resetScenePhasingFlag(%p) ()", (const void *)script); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1resetScenePhasingFlag(%p) ()", (const void *)script); _scenePhasingFlag = 0; return 0; } int KyraEngine_v1::o1_queryScenePhasingFlag(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_queryScenePhasingFlag(%p) ()", (const void *)script); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1queryScenePhasingFlag(%p) ()", (const void *)script); return _scenePhasingFlag; } int KyraEngine_v1::o1_sceneToDirection(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_sceneToDirection(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1sceneToDirection(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); assert(stackPos(0) < _roomTableSize); Room *curRoom = &_roomTable[stackPos(0)]; uint16 returnValue = 0xFFFF; @@ -350,7 +349,7 @@ int KyraEngine_v1::o1_sceneToDirection(ScriptState *script) { } int KyraEngine_v1::o1_setBirthstoneGem(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_setBirthstoneGem(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1setBirthstoneGem(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); int index = stackPos(0); if (index < 4 && index >= 0) { _birthstoneGemTable[index] = stackPos(1); @@ -360,19 +359,19 @@ int KyraEngine_v1::o1_setBirthstoneGem(ScriptState *script) { } int KyraEngine_v1::o1_placeItemInGenericMapScene(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_placeItemInGenericMapScene(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1placeItemInGenericMapScene(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); placeItemInGenericMapScene(stackPos(0), stackPos(1)); return 0; } int KyraEngine_v1::o1_setBrandonStatusBit(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_setBrandonStatusBit(%p) (%d)", (const void *)script, stackPos(0)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1setBrandonStatusBit(%p) (%d)", (const void *)script, stackPos(0)); _brandonStatusBit |= stackPos(0); return 0; } int KyraEngine_v1::o1_pauseSeconds(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_pauseSeconds(%p) (%d)", (const void *)script, stackPos(0)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1pauseSeconds(%p) (%d)", (const void *)script, stackPos(0)); if (stackPos(0) > 0 && !_skipFlag) delay(stackPos(0)*1000, true); _skipFlag = false; @@ -380,7 +379,7 @@ int KyraEngine_v1::o1_pauseSeconds(ScriptState *script) { } int KyraEngine_v1::o1_getCharactersLocation(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_getCharactersLocation(%p) (%d)", (const void *)script, stackPos(0)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1getCharactersLocation(%p) (%d)", (const void *)script, stackPos(0)); return _characterList[stackPos(0)].sceneId; } @@ -390,31 +389,31 @@ int KyraEngine_v1::o1_runNPCSubscript(ScriptState *script) { } int KyraEngine_v1::o1_magicOutMouseItem(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_magicOutMouseItem(%p) (%d)", (const void *)script, stackPos(0)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1magicOutMouseItem(%p) (%d)", (const void *)script, stackPos(0)); magicOutMouseItem(stackPos(0), -1); return 0; } int KyraEngine_v1::o1_internalAnimOn(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_internalAnimOn(%p) (%d)", (const void *)script, stackPos(0)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1internalAnimOn(%p) (%d)", (const void *)script, stackPos(0)); _animator->sprites()[stackPos(0)].active = 1; return 0; } int KyraEngine_v1::o1_forceBrandonToNormal(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_forceBrandonToNormal(%p) ()", (const void *)script); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1forceBrandonToNormal(%p) ()", (const void *)script); checkAmuletAnimFlags(); return 0; } int KyraEngine_v1::o1_poisonDeathNow(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_poisonDeathNow(%p) ()", (const void *)script); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1poisonDeathNow(%p) ()", (const void *)script); seq_poisonDeathNow(1); return 0; } int KyraEngine_v1::o1_setScaleMode(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_setScaleMode(%p) (%d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1setScaleMode(%p) (%d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3)); int len = stackPos(0); int setValue1 = stackPos(1); int start2 = stackPos(2); @@ -432,7 +431,7 @@ int KyraEngine_v1::o1_setScaleMode(ScriptState *script) { } int KyraEngine_v1::o1_openWSAFile(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_openWSAFile(%p) ('%s', %d, %d, %d)", (const void *)script, stackPosString(0), stackPos(1), stackPos(2), stackPos(3)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1openWSAFile(%p) ('%s', %d, %d, %d)", (const void *)script, stackPosString(0), stackPos(1), stackPos(2), stackPos(3)); const char *filename = stackPosString(0); int wsaIndex = stackPos(1); @@ -444,7 +443,7 @@ int KyraEngine_v1::o1_openWSAFile(ScriptState *script) { } int KyraEngine_v1::o1_closeWSAFile(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_closeWSAFile(%p) (%d)", (const void *)script, stackPos(0)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1closeWSAFile(%p) (%d)", (const void *)script, stackPos(0)); int wsaIndex = stackPos(0); if (_movieObjects[wsaIndex]) @@ -454,7 +453,7 @@ int KyraEngine_v1::o1_closeWSAFile(ScriptState *script) { } int KyraEngine_v1::o1_runWSAFromBeginningToEnd(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_runWSAFromBeginningToEnd(%p) (%d, %d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1runWSAFromBeginningToEnd(%p) (%d, %d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4)); _screen->hideMouse(); @@ -495,7 +494,7 @@ int KyraEngine_v1::o1_runWSAFromBeginningToEnd(ScriptState *script) { } int KyraEngine_v1::o1_displayWSAFrame(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_displayWSAFrame(%p) (%d, %d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1displayWSAFrame(%p) (%d, %d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4)); int frame = stackPos(0); int xpos = stackPos(1); int ypos = stackPos(2); @@ -522,13 +521,13 @@ int KyraEngine_v1::o1_displayWSAFrame(ScriptState *script) { } int KyraEngine_v1::o1_enterNewScene(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_enterNewScene(%p) (%d, %d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1enterNewScene(%p) (%d, %d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4)); enterNewScene(stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4)); return 0; } int KyraEngine_v1::o1_setSpecialEnterXAndY(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_setSpecialEnterXAndY(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1setSpecialEnterXAndY(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); _brandonPosX = stackPos(0); _brandonPosY = stackPos(1); if (_brandonPosX + 1 == 0 && _brandonPosY + 1 == 0) @@ -537,7 +536,7 @@ int KyraEngine_v1::o1_setSpecialEnterXAndY(ScriptState *script) { } int KyraEngine_v1::o1_runWSAFrames(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_runWSAFrames(%p) (%d, %d, %d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4), stackPos(5)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1runWSAFrames(%p) (%d, %d, %d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4), stackPos(5)); int xpos = stackPos(0); int ypos = stackPos(1); int delayTime = stackPos(2); @@ -564,7 +563,7 @@ int KyraEngine_v1::o1_runWSAFrames(ScriptState *script) { } int KyraEngine_v1::o1_popBrandonIntoScene(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_popBrandonIntoScene(%p) (%d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1popBrandonIntoScene(%p) (%d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3)); int changeScaleMode = stackPos(3); int xpos = (int16)(stackPos(0) & 0xFFFC); int ypos = (int16)(stackPos(1) & 0xFFFE); @@ -613,7 +612,7 @@ int KyraEngine_v1::o1_popBrandonIntoScene(ScriptState *script) { } int KyraEngine_v1::o1_restoreAllObjectBackgrounds(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_restoreAllObjectBackgrounds(%p) (%d)", (const void *)script, stackPos(0)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1restoreAllObjectBackgrounds(%p) (%d)", (const void *)script, stackPos(0)); int disable = stackPos(0); int activeBackup = 0; if (disable) { @@ -627,13 +626,13 @@ int KyraEngine_v1::o1_restoreAllObjectBackgrounds(ScriptState *script) { } int KyraEngine_v1::o1_setCustomPaletteRange(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_setCustomPaletteRange(%p) (%d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1setCustomPaletteRange(%p) (%d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2)); memcpy(_screen->getPalette(1) + stackPos(1)*3, _specialPalettes[stackPos(0)], stackPos(2)*3); return 0; } int KyraEngine_v1::o1_loadPageFromDisk(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_loadPageFromDisk(%p) ('%s', %d)", (const void *)script, stackPosString(0), stackPos(1)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1loadPageFromDisk(%p) ('%s', %d)", (const void *)script, stackPosString(0), stackPos(1)); _screen->loadPageFromDisk(stackPosString(0), stackPos(1)); _animator->_updateScreen = true; return 0; @@ -641,7 +640,7 @@ int KyraEngine_v1::o1_loadPageFromDisk(ScriptState *script) { int KyraEngine_v1::o1_customPrintTalkString(ScriptState *script) { if (_flags.isTalkie) { - debugC(3, kDebugLevelScriptFuncs, "o1_customPrintTalkString(%p) (%d, '%s', %d, %d, %d)", (const void *)script, stackPos(0), stackPosString(1), stackPos(2), stackPos(3), stackPos(4) & 0xFF); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1customPrintTalkString(%p) (%d, '%s', %d, %d, %d)", (const void *)script, stackPos(0), stackPosString(1), stackPos(2), stackPos(3), stackPos(4) & 0xFF); if (speechEnabled()) { snd_voiceWaitForFinish(); @@ -651,7 +650,7 @@ int KyraEngine_v1::o1_customPrintTalkString(ScriptState *script) { if (textEnabled()) _text->printTalkTextMessage(stackPosString(1), stackPos(2), stackPos(3), stackPos(4) & 0xFF, 0, 2); } else { - debugC(3, kDebugLevelScriptFuncs, "o1_customPrintTalkString(%p) ('%s', %d, %d, %d)", (const void *)script, stackPosString(0), stackPos(1), stackPos(2), stackPos(3) & 0xFF); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1customPrintTalkString(%p) ('%s', %d, %d, %d)", (const void *)script, stackPosString(0), stackPos(1), stackPos(2), stackPos(3) & 0xFF); _skipFlag = false; _text->printTalkTextMessage(stackPosString(0), stackPos(1), stackPos(2), stackPos(3) & 0xFF, 0, 2); } @@ -660,7 +659,7 @@ int KyraEngine_v1::o1_customPrintTalkString(ScriptState *script) { } int KyraEngine_v1::o1_restoreCustomPrintBackground(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_restoreCustomPrintBackground(%p) ()", (const void *)script); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1restoreCustomPrintBackground(%p) ()", (const void *)script); snd_voiceWaitForFinish(); snd_stopVoice(); _text->restoreTalkTextMessageBkgd(2, 0); @@ -668,29 +667,29 @@ int KyraEngine_v1::o1_restoreCustomPrintBackground(ScriptState *script) { } int KyraEngine_v1::o1_hideMouse(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_hideMouse(%p) ()", (const void *)script); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1hideMouse(%p) ()", (const void *)script); _screen->hideMouse(); return 0; } int KyraEngine_v1::o1_showMouse(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_showMouse(%p) ()", (const void *)script); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1showMouse(%p) ()", (const void *)script); _screen->showMouse(); return 0; } int KyraEngine_v1::o1_getCharacterX(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_getCharacterX(%p) (%d)", (const void *)script, stackPos(0)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1getCharacterX(%p) (%d)", (const void *)script, stackPos(0)); return _characterList[stackPos(0)].x1; } int KyraEngine_v1::o1_getCharacterY(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_getCharacterY(%p) (%d)", (const void *)script, stackPos(0)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1getCharacterY(%p) (%d)", (const void *)script, stackPos(0)); return _characterList[stackPos(0)].y1; } int KyraEngine_v1::o1_changeCharactersFacing(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_changeCharactersFacing(%p) (%d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1changeCharactersFacing(%p) (%d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2)); int character = stackPos(0); int facing = stackPos(1); int newAnimFrame = stackPos(2); @@ -708,7 +707,7 @@ int KyraEngine_v1::o1_changeCharactersFacing(ScriptState *script) { } int KyraEngine_v1::o1_copyWSARegion(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_copyWSARegion(%p) (%d, %d, %d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4), stackPos(5)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1copyWSARegion(%p) (%d, %d, %d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4), stackPos(5)); int xpos = stackPos(0); int ypos = stackPos(1); int width = stackPos(2); @@ -721,7 +720,7 @@ int KyraEngine_v1::o1_copyWSARegion(ScriptState *script) { } int KyraEngine_v1::o1_printText(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_printText(%p) ('%s', %d, %d, 0x%X, 0x%X)", (const void *)script, stackPosString(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1printText(%p) ('%s', %d, %d, 0x%X, 0x%X)", (const void *)script, stackPosString(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4)); if (_flags.lang == Common::JA_JPN && stackPos(3) == 7) _screen->printText(stackPosString(0), stackPos(1), stackPos(2), 0, 0x80); else @@ -731,7 +730,7 @@ int KyraEngine_v1::o1_printText(ScriptState *script) { } int KyraEngine_v1::o1_random(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_random(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1random(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); assert(stackPos(0) < stackPos(1)); return _rnd.getRandomNumberRng(stackPos(0), stackPos(1)); } @@ -742,7 +741,7 @@ int KyraEngine_v1::o1_loadSoundFile(ScriptState *script) { } int KyraEngine_v1::o1_displayWSAFrameOnHidPage(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_displayWSAFrameOnHidPage(%p) (%d, %d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1displayWSAFrameOnHidPage(%p) (%d, %d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4)); int frame = stackPos(0); int xpos = stackPos(1); int ypos = stackPos(2); @@ -771,7 +770,7 @@ int KyraEngine_v1::o1_displayWSAFrameOnHidPage(ScriptState *script) { } int KyraEngine_v1::o1_displayWSASequentialFrames(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_displayWSASequentialFrames(%p) (%d, %d, %d, %d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4), stackPos(5), stackPos(6)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1displayWSASequentialFrames(%p) (%d, %d, %d, %d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4), stackPos(5), stackPos(6)); int startFrame = stackPos(0); int endFrame = stackPos(1); int xpos = stackPos(2); @@ -847,7 +846,7 @@ int KyraEngine_v1::o1_displayWSASequentialFrames(ScriptState *script) { } int KyraEngine_v1::o1_drawCharacterStanding(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_drawCharacterStanding(%p) (%d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1drawCharacterStanding(%p) (%d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3)); int character = stackPos(0); int animFrame = stackPos(1); int newFacing = stackPos(2); @@ -862,13 +861,13 @@ int KyraEngine_v1::o1_drawCharacterStanding(ScriptState *script) { } int KyraEngine_v1::o1_internalAnimOff(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_internalAnimOff(%p) (%d)", (const void *)script, stackPos(0)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1internalAnimOff(%p) (%d)", (const void *)script, stackPos(0)); _animator->sprites()[stackPos(0)].active = 0; return 0; } int KyraEngine_v1::o1_changeCharactersXAndY(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_changeCharactersXAndY(%p) (%d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1changeCharactersXAndY(%p) (%d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2)); Character *ch = &_characterList[stackPos(0)]; int16 x = stackPos(1); int16 y = stackPos(2); @@ -884,25 +883,25 @@ int KyraEngine_v1::o1_changeCharactersXAndY(ScriptState *script) { } int KyraEngine_v1::o1_clearSceneAnimatorBeacon(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_clearSceneAnimatorBeacon(%p) ()", (const void *)script); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1clearSceneAnimatorBeacon(%p) ()", (const void *)script); _sprites->_sceneAnimatorBeaconFlag = 0; return 0; } int KyraEngine_v1::o1_querySceneAnimatorBeacon(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_querySceneAnimatorBeacon(%p) ()", (const void *)script); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1querySceneAnimatorBeacon(%p) ()", (const void *)script); return _sprites->_sceneAnimatorBeaconFlag; } int KyraEngine_v1::o1_refreshSceneAnimator(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_refreshSceneAnimator(%p) ()", (const void *)script); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1refreshSceneAnimator(%p) ()", (const void *)script); _sprites->updateSceneAnims(); _animator->updateAllObjectShapes(); return 0; } int KyraEngine_v1::o1_placeItemInOffScene(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_placeItemInOffScene(%p) (%d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1placeItemInOffScene(%p) (%d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3)); int item = stackPos(0); int xpos = stackPos(1); int ypos = stackPos(2); @@ -921,7 +920,7 @@ int KyraEngine_v1::o1_placeItemInOffScene(ScriptState *script) { } int KyraEngine_v1::o1_wipeDownMouseItem(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_wipeDownMouseItem(%p) (%d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1wipeDownMouseItem(%p) (%d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2)); _screen->hideMouse(); wipeDownMouseItem(stackPos(1), stackPos(2)); destroyMouseItem(); @@ -930,7 +929,7 @@ int KyraEngine_v1::o1_wipeDownMouseItem(ScriptState *script) { } int KyraEngine_v1::o1_placeCharacterInOtherScene(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_placeCharacterInOtherScene(%p) (%d, %d, %d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4), stackPos(5)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1placeCharacterInOtherScene(%p) (%d, %d, %d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4), stackPos(5)); int id = stackPos(0); int sceneId = stackPos(1); int xpos = (int16)(stackPos(2) & 0xFFFC); @@ -947,7 +946,7 @@ int KyraEngine_v1::o1_placeCharacterInOtherScene(ScriptState *script) { } int KyraEngine_v1::o1_getKey(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_getKey(%p) ()", (const void *)script); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1getKey(%p) ()", (const void *)script); waitForEvent(); return 0; } @@ -958,7 +957,7 @@ int KyraEngine_v1::o1_specificItemInInventory(ScriptState *script) { } int KyraEngine_v1::o1_popMobileNPCIntoScene(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_popMobileNPCIntoScene(%p) (%d, %d, %d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3), (int16)(stackPos(4) & 0xFFFC), (int8)(stackPos(5) & 0xFE)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1popMobileNPCIntoScene(%p) (%d, %d, %d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3), (int16)(stackPos(4) & 0xFFFC), (int8)(stackPos(5) & 0xFE)); int character = stackPos(0); int sceneId = stackPos(1); int animFrame = stackPos(2); @@ -994,7 +993,7 @@ int KyraEngine_v1::o1_unhideMobileCharacter(ScriptState *script) { } int KyraEngine_v1::o1_setCharactersLocation(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_setCharactersLocation(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1setCharactersLocation(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); Character *ch = &_characterList[stackPos(0)]; AnimObject *animObj = &_animator->actors()[stackPos(0)]; int newScene = stackPos(1); @@ -1011,7 +1010,7 @@ int KyraEngine_v1::o1_setCharactersLocation(ScriptState *script) { } int KyraEngine_v1::o1_walkCharacterToPoint(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_walkCharacterToPoint(%p) (%d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1walkCharacterToPoint(%p) (%d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2)); int character = stackPos(0); int toX = stackPos(1); int toY = stackPos(2); @@ -1078,11 +1077,11 @@ int KyraEngine_v1::o1_walkCharacterToPoint(ScriptState *script) { setCharacterPosition(character, 0); ++curPos; - nextFrame = getTimerDelay(5 + character) * _tickLength + _system->getMillis(); + nextFrame = _timer->getDelay(5 + character) * _tickLength + _system->getMillis(); while (_system->getMillis() < nextFrame) { _sprites->updateSceneAnims(); updateMousePointer(); - updateGameTimers(); + _timer->update(); _animator->updateAllObjectShapes(); updateTextFade(); if ((nextFrame - _system->getMillis()) >= 10) @@ -1093,7 +1092,7 @@ int KyraEngine_v1::o1_walkCharacterToPoint(ScriptState *script) { } int KyraEngine_v1::o1_specialEventDisplayBrynnsNote(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_specialEventDisplayBrynnsNote(%p) ()", (const void *)script); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1specialEventDisplayBrynnsNote(%p) ()", (const void *)script); _screen->hideMouse(); _screen->savePageToDisk("HIDPAGE.TMP", 2); _screen->savePageToDisk("SEENPAGE.TMP", 0); @@ -1115,7 +1114,7 @@ int KyraEngine_v1::o1_specialEventDisplayBrynnsNote(ScriptState *script) { } int KyraEngine_v1::o1_specialEventRemoveBrynnsNote(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_specialEventRemoveBrynnsNote(%p) ()", (const void *)script); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1specialEventRemoveBrynnsNote(%p) ()", (const void *)script); _screen->hideMouse(); _screen->loadPageFromDisk("SEENPAGE.TMP", 0); _screen->loadPageFromDisk("HIDPAGE.TMP", 2); @@ -1126,13 +1125,13 @@ int KyraEngine_v1::o1_specialEventRemoveBrynnsNote(ScriptState *script) { } int KyraEngine_v1::o1_setLogicPage(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_setLogicPage(%p) (%d)", (const void *)script, stackPos(0)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1setLogicPage(%p) (%d)", (const void *)script, stackPos(0)); _screen->_curPage = stackPos(0); return stackPos(0); } int KyraEngine_v1::o1_fatPrint(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_fatPrint(%p) ('%s', %d, %d, %d, %d, %d)", (const void *)script, stackPosString(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4), stackPos(5)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1fatPrint(%p) ('%s', %d, %d, %d, %d, %d)", (const void *)script, stackPosString(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4), stackPos(5)); // Workround for bug #1582672 ("KYRA1: Text crippled and drawn wrong") // I'm not sure how the original handels this, since it seems to call @@ -1145,13 +1144,13 @@ int KyraEngine_v1::o1_fatPrint(ScriptState *script) { } int KyraEngine_v1::o1_preserveAllObjectBackgrounds(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_preserveAllObjectBackgrounds(%p) ()", (const void *)script); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1preserveAllObjectBackgrounds(%p) ()", (const void *)script); _animator->preserveAllBackgrounds(); return 0; } int KyraEngine_v1::o1_updateSceneAnimations(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_updateSceneAnimations(%p) (%d)", (const void *)script, stackPos(0)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1updateSceneAnimations(%p) (%d)", (const void *)script, stackPos(0)); int times = stackPos(0); while (times--) { _sprites->updateSceneAnims(); @@ -1161,23 +1160,23 @@ int KyraEngine_v1::o1_updateSceneAnimations(ScriptState *script) { } int KyraEngine_v1::o1_sceneAnimationActive(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_sceneAnimationActive(%p) (%d)", (const void *)script, stackPos(0)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1sceneAnimationActive(%p) (%d)", (const void *)script, stackPos(0)); return _sprites->_anims[stackPos(0)].play; } int KyraEngine_v1::o1_setCharactersMovementDelay(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_setCharactersMovementDelay(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); - setTimerDelay(stackPos(0)+5, stackPos(1)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1setCharactersMovementDelay(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); + _timer->setDelay(stackPos(0)+5, stackPos(1)); return 0; } int KyraEngine_v1::o1_getCharactersFacing(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_getCharactersFacing(%p) (%d)", (const void *)script, stackPos(0)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1getCharactersFacing(%p) (%d)", (const void *)script, stackPos(0)); return _characterList[stackPos(0)].facing; } int KyraEngine_v1::o1_bkgdScrollSceneAndMasksRight(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_bkgdScrollSceneAndMasksRight(%p) (%d)", (const void *)script, stackPos(0)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1bkgdScrollSceneAndMasksRight(%p) (%d)", (const void *)script, stackPos(0)); _screen->copyBackgroundBlock(stackPos(0), 2, 0); _screen->copyBackgroundBlock2(stackPos(0)); // update the whole screen @@ -1187,13 +1186,13 @@ int KyraEngine_v1::o1_bkgdScrollSceneAndMasksRight(ScriptState *script) { } int KyraEngine_v1::o1_dispelMagicAnimation(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_dispelMagicAnimation(%p) ()", (const void *)script); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1dispelMagicAnimation(%p) ()", (const void *)script); seq_dispelMagicAnimation(); return 0; } int KyraEngine_v1::o1_findBrightestFireberry(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_findBrightestFireberry(%p) ()", (const void *)script); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1findBrightestFireberry(%p) ()", (const void *)script); if (_currentCharacter->sceneId >= 187 && _currentCharacter->sceneId <= 198) return 29; @@ -1237,7 +1236,7 @@ int KyraEngine_v1::o1_findBrightestFireberry(ScriptState *script) { } int KyraEngine_v1::o1_setFireberryGlowPalette(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_setFireberryGlowPalette(%p) (%d)", (const void *)script, stackPos(0)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1setFireberryGlowPalette(%p) (%d)", (const void *)script, stackPos(0)); int palIndex = 0; switch (stackPos(0)) { case 0x1E: @@ -1274,19 +1273,19 @@ int KyraEngine_v1::o1_setFireberryGlowPalette(ScriptState *script) { } int KyraEngine_v1::o1_setDeathHandlerFlag(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_setDeathHandlerFlag(%p) (%d)", (const void *)script, stackPos(0)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1setDeathHandlerFlag(%p) (%d)", (const void *)script, stackPos(0)); _deathHandler = stackPos(0); return 0; } int KyraEngine_v1::o1_drinkPotionAnimation(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_drinkPotionAnimation(%p) (%d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1drinkPotionAnimation(%p) (%d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2)); seq_playDrinkPotionAnim(stackPos(0), stackPos(1), stackPos(2)); return 0; } int KyraEngine_v1::o1_makeAmuletAppear(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_makeAmuletAppear(%p) ()", (const void *)script); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1makeAmuletAppear(%p) ()", (const void *)script); WSAMovieV1 amulet(this); amulet.open("AMULET.WSA", 1, 0); amulet.setX(224); @@ -1327,7 +1326,7 @@ int KyraEngine_v1::o1_makeAmuletAppear(ScriptState *script) { } int KyraEngine_v1::o1_drawItemShapeIntoScene(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_drawItemShapeIntoScene(%p) (%d, %d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1drawItemShapeIntoScene(%p) (%d, %d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4)); int item = stackPos(0); int x = stackPos(1); int y = stackPos(2); @@ -1354,13 +1353,13 @@ int KyraEngine_v1::o1_drawItemShapeIntoScene(ScriptState *script) { } int KyraEngine_v1::o1_setCharactersCurrentFrame(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_setCharactersCurrentFrame(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1setCharactersCurrentFrame(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); _characterList[stackPos(0)].currentAnimFrame = stackPos(1); return 0; } int KyraEngine_v1::o1_waitForConfirmationMouseClick(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_waitForConfirmationMouseClick(%p) ()", (const void *)script); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1waitForConfirmationMouseClick(%p) ()", (const void *)script); // if (mouseEnabled) { while (!_mousePressFlag) { updateMousePointer(); @@ -1390,18 +1389,18 @@ int KyraEngine_v1::o1_pageFlip(ScriptState *script) { } int KyraEngine_v1::o1_setSceneFile(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_setSceneFile(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1setSceneFile(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); setSceneFile(stackPos(0), stackPos(1)); return 0; } int KyraEngine_v1::o1_getItemInMarbleVase(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_getItemInMarbleVase(%p) ()", (const void *)script); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1getItemInMarbleVase(%p) ()", (const void *)script); return _marbleVaseItem; } int KyraEngine_v1::o1_setItemInMarbleVase(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_setItemInMarbleVase(%p) (%d)", (const void *)script, stackPos(0)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1setItemInMarbleVase(%p) (%d)", (const void *)script, stackPos(0)); _marbleVaseItem = stackPos(0); return 0; } @@ -1417,7 +1416,7 @@ int KyraEngine_v1::o1_intPrint(ScriptState *script) { } int KyraEngine_v1::o1_shakeScreen(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_shakeScreen(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1shakeScreen(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); int waitTicks = stackPos(1); int times = stackPos(0); @@ -1430,57 +1429,57 @@ int KyraEngine_v1::o1_shakeScreen(ScriptState *script) { } int KyraEngine_v1::o1_createAmuletJewel(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_createAmuletJewel(%p) (%d)", (const void *)script, stackPos(0)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1createAmuletJewel(%p) (%d)", (const void *)script, stackPos(0)); seq_createAmuletJewel(stackPos(0), 0, 0, 0); return 0; } int KyraEngine_v1::o1_setSceneAnimCurrXY(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_setSceneAnimCurrXY(%p) (%d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1setSceneAnimCurrXY(%p) (%d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2)); _sprites->_anims[stackPos(0)].x = stackPos(1); _sprites->_anims[stackPos(0)].y = stackPos(2); return 0; } int KyraEngine_v1::o1_poisonBrandonAndRemaps(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_poisonBrandonAndRemaps(%p) ()", (const void *)script); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1poisonBrandonAndRemaps(%p) ()", (const void *)script); setBrandonPoisonFlags(1); return 0; } int KyraEngine_v1::o1_fillFlaskWithWater(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_fillFlaskWithWater(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1fillFlaskWithWater(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); seq_fillFlaskWithWater(stackPos(0), stackPos(1)); return 0; } int KyraEngine_v1::o1_getCharactersMovementDelay(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_getCharactersMovementDelay(%p) (%d)", (const void *)script, stackPos(0)); - return getTimerDelay(stackPos(0)+5); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1getCharactersMovementDelay(%p) (%d)", (const void *)script, stackPos(0)); + return _timer->getDelay(stackPos(0)+5); } int KyraEngine_v1::o1_getBirthstoneGem(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_getBirthstoneGem(%p) (%d)", (const void *)script, stackPos(0)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1getBirthstoneGem(%p) (%d)", (const void *)script, stackPos(0)); if (stackPos(0) < 4) return _birthstoneGemTable[stackPos(0)]; return 0; } int KyraEngine_v1::o1_queryBrandonStatusBit(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_queryBrandonStatusBit(%p) (%d)", (const void *)script, stackPos(0)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1queryBrandonStatusBit(%p) (%d)", (const void *)script, stackPos(0)); if (_brandonStatusBit & stackPos(0)) return 1; return 0; } int KyraEngine_v1::o1_playFluteAnimation(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_playFluteAnimation(%p) ()", (const void *)script); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1playFluteAnimation(%p) ()", (const void *)script); seq_playFluteAnimation(); return 0; } int KyraEngine_v1::o1_playWinterScrollSequence(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_playWinterScrollSequence(%p) (%d)", (const void *)script, stackPos(0)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1playWinterScrollSequence(%p) (%d)", (const void *)script, stackPos(0)); if (!stackPos(0)) seq_winterScroll2(); else @@ -1489,40 +1488,40 @@ int KyraEngine_v1::o1_playWinterScrollSequence(ScriptState *script) { } int KyraEngine_v1::o1_getIdolGem(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_getIdolGem(%p) (%d)", (const void *)script, stackPos(0)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1getIdolGem(%p) (%d)", (const void *)script, stackPos(0)); return _idolGemsTable[stackPos(0)]; } int KyraEngine_v1::o1_setIdolGem(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_setIdolGem(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1setIdolGem(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); _idolGemsTable[stackPos(0)] = stackPos(1); return 0; } int KyraEngine_v1::o1_totalItemsInScene(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_totalItemsInScene(%p) (%d)", (const void *)script, stackPos(0)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1totalItemsInScene(%p) (%d)", (const void *)script, stackPos(0)); return countItemsInScene(stackPos(0)); } int KyraEngine_v1::o1_restoreBrandonsMovementDelay(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_restoreBrandonsMovementDelay(%p) ()", (const void *)script); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1restoreBrandonsMovementDelay(%p) ()", (const void *)script); setWalkspeed(_configWalkspeed); return 0; } int KyraEngine_v1::o1_setMousePos(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_setMousePos(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1setMousePos(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); _system->warpMouse(stackPos(0), stackPos(1)); return 0; } int KyraEngine_v1::o1_getMouseState(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_getMouseState(%p) ()", (const void *)script); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1getMouseState(%p) ()", (const void *)script); return _mouseState; } int KyraEngine_v1::o1_setEntranceMouseCursorTrack(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_setEntranceMouseCursorTrack(%p) (%d, %d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1setEntranceMouseCursorTrack(%p) (%d, %d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4)); _entranceMouseCursorTracks[0] = stackPos(0); _entranceMouseCursorTracks[1] = stackPos(1); _entranceMouseCursorTracks[2] = stackPos(0) + stackPos(2) - 1; @@ -1532,19 +1531,19 @@ int KyraEngine_v1::o1_setEntranceMouseCursorTrack(ScriptState *script) { } int KyraEngine_v1::o1_itemAppearsOnGround(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_itemAppearsOnGround(%p) (%d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1itemAppearsOnGround(%p) (%d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2)); processItemDrop(_currentCharacter->sceneId, stackPos(0), stackPos(1), stackPos(2), 2, 0); return 0; } int KyraEngine_v1::o1_setNoDrawShapesFlag(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_setNoDrawShapesFlag(%p) (%d)", (const void *)script, stackPos(0)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1setNoDrawShapesFlag(%p) (%d)", (const void *)script, stackPos(0)); _animator->_noDrawShapesFlag = stackPos(0); return 0; } int KyraEngine_v1::o1_fadeEntirePalette(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_fadeEntirePalette(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1fadeEntirePalette(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); int cmd = stackPos(0); uint8 *fadePal = 0; @@ -1584,7 +1583,7 @@ int KyraEngine_v1::o1_fadeEntirePalette(ScriptState *script) { } int KyraEngine_v1::o1_itemOnGroundHere(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_itemOnGroundHere(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1itemOnGroundHere(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); assert(stackPos(0) < _roomTableSize); Room *curRoom = &_roomTable[stackPos(0)]; for (int i = 0; i < 12; ++i) { @@ -1595,18 +1594,18 @@ int KyraEngine_v1::o1_itemOnGroundHere(ScriptState *script) { } int KyraEngine_v1::o1_queryCauldronState(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_queryCauldronState(%p) ()", (const void *)script); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1queryCauldronState(%p) ()", (const void *)script); return _cauldronState; } int KyraEngine_v1::o1_setCauldronState(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_setCauldronState(%p) (%d)", (const void *)script, stackPos(0)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1setCauldronState(%p) (%d)", (const void *)script, stackPos(0)); _cauldronState = stackPos(0); return _cauldronState; } int KyraEngine_v1::o1_queryCrystalState(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_queryCrystalState(%p) (%d)", (const void *)script, stackPos(0)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1queryCrystalState(%p) (%d)", (const void *)script, stackPos(0)); if (!stackPos(0)) return _crystalState[0]; else if (stackPos(0) == 1) @@ -1615,7 +1614,7 @@ int KyraEngine_v1::o1_queryCrystalState(ScriptState *script) { } int KyraEngine_v1::o1_setCrystalState(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_setCrystalState(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1setCrystalState(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); if (!stackPos(0)) _crystalState[0] = stackPos(1); else if (stackPos(0) == 1) @@ -1629,7 +1628,7 @@ int KyraEngine_v1::o1_setPaletteRange(ScriptState *script) { } int KyraEngine_v1::o1_shrinkBrandonDown(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_shrinkBrandonDown(%p) (%d)", (const void *)script, stackPos(0)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1shrinkBrandonDown(%p) (%d)", (const void *)script, stackPos(0)); int delayTime = stackPos(0); checkAmuletAnimFlags(); int scaleValue = _scaleTable[_currentCharacter->y1]; @@ -1655,7 +1654,7 @@ int KyraEngine_v1::o1_shrinkBrandonDown(ScriptState *script) { } int KyraEngine_v1::o1_growBrandonUp(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_growBrandonUp(%p) ()", (const void *)script); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1growBrandonUp(%p) ()", (const void *)script); int scaleValue = _scaleTable[_currentCharacter->y1]; int scale = 0; if (_scaleMode) @@ -1676,26 +1675,26 @@ int KyraEngine_v1::o1_growBrandonUp(ScriptState *script) { } int KyraEngine_v1::o1_setBrandonScaleXAndY(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_setBrandonScaleXAndY(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1setBrandonScaleXAndY(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); _animator->_brandonScaleX = stackPos(0); _animator->_brandonScaleY = stackPos(1); return 0; } int KyraEngine_v1::o1_resetScaleMode(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_resetScaleMode(%p) ()", (const void *)script); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1resetScaleMode(%p) ()", (const void *)script); _scaleMode = 0; return 0; } int KyraEngine_v1::o1_getScaleDepthTableValue(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_getScaleDepthTableValue(%p) (%d)", (const void *)script, stackPos(0)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1getScaleDepthTableValue(%p) (%d)", (const void *)script, stackPos(0)); assert(stackPos(0) < ARRAYSIZE(_scaleTable)); return _scaleTable[stackPos(0)]; } int KyraEngine_v1::o1_setScaleDepthTableValue(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_setScaleDepthTableValue(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1setScaleDepthTableValue(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); assert(stackPos(0) < ARRAYSIZE(_scaleTable)); _scaleTable[stackPos(0)] = stackPos(1); return stackPos(1); @@ -1703,10 +1702,10 @@ int KyraEngine_v1::o1_setScaleDepthTableValue(ScriptState *script) { int KyraEngine_v1::o1_message(ScriptState *script) { if (_flags.isTalkie) { - debugC(3, kDebugLevelScriptFuncs, "o1_message(%p) (%d, '%s', %d)", (const void *)script, stackPos(0), stackPosString(1), stackPos(2)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1message(%p) (%d, '%s', %d)", (const void *)script, stackPos(0), stackPosString(1), stackPos(2)); drawSentenceCommand(stackPosString(1), stackPos(2)); } else { - debugC(3, kDebugLevelScriptFuncs, "o1_message(%p) ('%s', %d)", (const void *)script, stackPosString(0), stackPos(1)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1message(%p) ('%s', %d)", (const void *)script, stackPosString(0), stackPos(1)); drawSentenceCommand(stackPosString(0), stackPos(1)); } @@ -1714,38 +1713,38 @@ int KyraEngine_v1::o1_message(ScriptState *script) { } int KyraEngine_v1::o1_checkClickOnNPC(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_checkClickOnNPC(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1checkClickOnNPC(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); return checkForNPCScriptRun(stackPos(0), stackPos(1)); } int KyraEngine_v1::o1_getFoyerItem(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_getFoyerItem(%p) (%d)", (const void *)script, stackPos(0)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1getFoyerItem(%p) (%d)", (const void *)script, stackPos(0)); assert(stackPos(0) < ARRAYSIZE(_foyerItemTable)); return _foyerItemTable[stackPos(0)]; } int KyraEngine_v1::o1_setFoyerItem(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_setFoyerItem(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1setFoyerItem(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); assert(stackPos(0) < ARRAYSIZE(_foyerItemTable)); _foyerItemTable[stackPos(0)] = stackPos(1); return stackPos(1); } int KyraEngine_v1::o1_setNoItemDropRegion(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_setNoItemDropRegion(%p) (%d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1setNoItemDropRegion(%p) (%d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3)); addToNoDropRects(stackPos(0), stackPos(1), stackPos(2), stackPos(3)); return 0; } int KyraEngine_v1::o1_walkMalcolmOn(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_walkMalcolmOn(%p) ()", (const void *)script); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1walkMalcolmOn(%p) ()", (const void *)script); if (!_malcolmFlag) _malcolmFlag = 1; return 0; } int KyraEngine_v1::o1_passiveProtection(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_passiveProtection(%p) ()", (const void *)script); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1passiveProtection(%p) ()", (const void *)script); return 1; } @@ -1755,24 +1754,24 @@ int KyraEngine_v1::o1_setPlayingLoop(ScriptState *script) { } int KyraEngine_v1::o1_brandonToStoneSequence(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_brandonToStoneSequence(%p) ()", (const void *)script); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1brandonToStoneSequence(%p) ()", (const void *)script); seq_brandonToStone(); return 0; } int KyraEngine_v1::o1_brandonHealingSequence(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_brandonHealingSequence(%p) ()", (const void *)script); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1brandonHealingSequence(%p) ()", (const void *)script); seq_brandonHealing(); return 0; } int KyraEngine_v1::o1_protectCommandLine(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_protectCommandLine(%p) (%d)", (const void *)script, stackPos(0)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1protectCommandLine(%p) (%d)", (const void *)script, stackPos(0)); return stackPos(0); } int KyraEngine_v1::o1_pauseMusicSeconds(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_pauseMusicSeconds(%p) ()", (const void *)script); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1pauseMusicSeconds(%p) ()", (const void *)script); // if music disabled // return o1_pauseSeconds(script); @@ -1785,13 +1784,13 @@ int KyraEngine_v1::o1_resetMaskRegion(ScriptState *script) { } int KyraEngine_v1::o1_setPaletteChangeFlag(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_setPaletteChangeFlag(%p) (%d)", (const void *)script, stackPos(0)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1setPaletteChangeFlag(%p) (%d)", (const void *)script, stackPos(0)); _paletteChanged = stackPos(0); return _paletteChanged; } int KyraEngine_v1::o1_fillRect(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_fillRect(%p) (%d, %d, %d, %d, %d, 0x%X)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4), stackPos(5)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1fillRect(%p) (%d, %d, %d, %d, %d, 0x%X)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4), stackPos(5)); int videoPageBackup = _screen->_curPage; _screen->_curPage = stackPos(0); _screen->fillRect(stackPos(1), stackPos(2), stackPos(3), stackPos(4), stackPos(5)); @@ -1800,19 +1799,19 @@ int KyraEngine_v1::o1_fillRect(ScriptState *script) { } int KyraEngine_v1::o1_vocUnload(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_vocUnload(%p) ()", (const void *)script); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1vocUnload(%p) ()", (const void *)script); // this should unload all voc files (not needed) return 0; } int KyraEngine_v1::o1_vocLoad(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_vocLoad(%p) (%d)", (const void *)script, stackPos(0)); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1vocLoad(%p) (%d)", (const void *)script, stackPos(0)); // this should load the specified voc file (not needed) return 0; } int KyraEngine_v1::o1_dummy(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o1_dummy(%p) ()", (const void *)script); + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v1::o1dummy(%p) ()", (const void *)script); return 0; } diff --git a/engines/kyra/script_v2.cpp b/engines/kyra/script_v2.cpp new file mode 100644 index 0000000000..ce1cd99e03 --- /dev/null +++ b/engines/kyra/script_v2.cpp @@ -0,0 +1,430 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include "kyra/kyra_v2.h" +#include "kyra/wsamovie.h" + +#include "common/endian.h" + +namespace Kyra { + +int KyraEngine_v2::o2_setCharacterFacingRefresh(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2_setCharacterFacingRefresh(%p) (-, %d, %d)", (const void *)script, stackPos(1), stackPos(2)); + int animFrame = stackPos(2); + if (animFrame >= 0) + _mainCharacter.animFrame = animFrame; + _mainCharacter.facing = stackPos(1); + updateCharacterAnim(0); + refreshAnimObjectsIfNeed(); + return 0; +} + +int KyraEngine_v2::o2_defineObject(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2_defineObject(%p) (%d, '%s', %d, %d, %d, %d)", (const void *)script, + stackPos(0), stackPosString(1), stackPos(2), stackPos(3), stackPos(4), stackPos(5)); + Object *object = &_objectList[stackPos(0)]; + strcpy(object->filename, stackPosString(1)); + object->scriptId = stackPos(2); + object->x = stackPos(3); + object->y = stackPos(4); + object->unk12 = stackPos(5); + return 0; +} + +int KyraEngine_v2::o2_refreshCharacter(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2_refreshCharacter(%p) (-, %d, %d, %d)", (const void *)script, stackPos(1), stackPos(2), stackPos(3)); + int unk = stackPos(1); + int facing = stackPos(2); + int refresh = stackPos(3); + if (facing >= 0) + _mainCharacter.facing = facing; + if (unk >= 0 && unk != 32) + _mainCharacter.animFrame = _characterFrameTable[_mainCharacter.facing]; + updateCharacterAnim(0); + if (refresh) + refreshAnimObjectsIfNeed(); + return 0; +} + +int KyraEngine_v2::o2_getCharacterX(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2_getCharacterX(%p) ()", (const void *)script); + return _mainCharacter.x1; +} + +int KyraEngine_v2::o2_getCharacterY(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2_getCharacterY(%p) ()", (const void *)script); + return _mainCharacter.y1; +} + +int KyraEngine_v2::o2_getCharacterFacing(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2_getCharacterFacing(%p) ()", (const void *)script); + return _mainCharacter.facing; +} + +int KyraEngine_v2::o2_setSceneComment(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2_setSceneComment(%p) ('%s')", (const void *)script, stackPosString(0)); + _sceneCommentString = stackPosString(0); + return 0; +} + +int KyraEngine_v2::o2_showChapterMessage(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2_showChapterMessage(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); + showChapterMessage(stackPos(0), stackPos(1)); + return 0; +} + +int KyraEngine_v2::o2_wsaClose(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2_wsaClose(%p) (%d)", (const void *)script, stackPos(0)); + assert(stackPos(0) >= 0 && stackPos(0) < ARRAYSIZE(_wsaSlots)); + _wsaSlots[stackPos(0)]->close(); + return 0; +} + +int KyraEngine_v2::o2_displayWsaFrame(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2_displayWsaFrame(%p) (%d, %d, %d, %d, %d, %d, %d, %d, %d)", (const void *)script, + stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4), stackPos(5), stackPos(6), stackPos(7), stackPos(8)); + int frame = stackPos(0); + int x = stackPos(1); + int y = stackPos(2); + int waitTime = stackPos(3); + int slot = stackPos(4); + int copyParam = stackPos(5); + int doUpdate = stackPos(6); + int dstPage = stackPos(7); + int backUp = stackPos(8); + + _screen->hideMouse(); + uint32 endTime = _system->getMillis() + waitTime * _tickLength; + _wsaSlots[slot]->setX(x); + _wsaSlots[slot]->setY(y); + _wsaSlots[slot]->setDrawPage(dstPage); + _wsaSlots[slot]->displayFrame(frame, copyParam | 0xC000); + _screen->updateScreen(); + + if (backUp) + memcpy(_gamePlayBuffer, _screen->getCPagePtr(3), 46080); + + while (_system->getMillis() < endTime) { + if (doUpdate) + update(); + + if (endTime - _system->getMillis() >= 10) + delay(10); + } + _screen->showMouse(); + return 0; +} + +int KyraEngine_v2::o2_displayWsaSequentialFrames(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2_displayWsaSequentialFrames(%p) (%d, %d, %d, %d, %d, %d, %d, %d)", (const void *)script, + stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4), stackPos(5), stackPos(6), stackPos(7)); + int startFrame = stackPos(0); + int endFrame = stackPos(1); + int x = stackPos(2); + int y = stackPos(3); + int waitTime = stackPos(4); + int slot = stackPos(5); + int maxTimes = stackPos(6); + int copyFlags = stackPos(7); + + if (maxTimes > 1) + maxTimes = 1; + + _wsaSlots[slot]->setX(x); + _wsaSlots[slot]->setY(y); + _wsaSlots[slot]->setDrawPage(0); + + _screen->hideMouse(); + int curTime = 0; + while (curTime < maxTimes) { + if (startFrame < endFrame) { + for (int i = startFrame; i <= endFrame; ++i) { + uint32 endTime = _system->getMillis() + waitTime * _tickLength; + _wsaSlots[slot]->displayFrame(i, 0xC000 | copyFlags); + _screen->updateScreen(); + + do { + update(); + + if (endTime - _system->getMillis() >= 10) + delay(10); + } while (_system->getMillis() < endTime); + } + } else { + for (int i = startFrame; i >= endFrame; --i) { + uint32 endTime = _system->getMillis() + waitTime * _tickLength; + _wsaSlots[slot]->displayFrame(i, 0xC000 | copyFlags); + _screen->updateScreen(); + + do { + update(); + + if (endTime - _system->getMillis() >= 10) + delay(10); + } while (_system->getMillis() < endTime); + } + } + + ++curTime; + } + _screen->showMouse(); + return 0; +} + +int KyraEngine_v2::o2_wsaOpen(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2_wsaOpen(%p) ('%s', %d)", (const void *)script, stackPosString(0), stackPos(1)); + assert(stackPos(1) >= 0 && stackPos(1) < ARRAYSIZE(_wsaSlots)); + _wsaSlots[stackPos(1)]->open(stackPosString(0), 1, 0); + return 0; +} + +int KyraEngine_v2::o2_defineItem(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2_defineItem(%p) (%d, %d, %d, %d)", (const void *)script, + stackPos(0), stackPos(1), stackPos(2), stackPos(3)); + int freeItem = findFreeItem(); + + if (freeItem >= 0) { + _itemList[freeItem].id = stackPos(0); + _itemList[freeItem].x = stackPos(1); + _itemList[freeItem].y = stackPos(2); + _itemList[freeItem].sceneId = stackPos(3); + } + + return freeItem; +} + +int KyraEngine_v2::o2_queryGameFlag(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2_queryGameFlag(%p) (%d)", (const void *)script, stackPos(0)); + return queryGameFlag(stackPos(0)); +} + +int KyraEngine_v2::o2_resetGameFlag(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2_resetGameFlag(%p) (%d)", (const void *)script, stackPos(0)); + return resetGameFlag(stackPos(0)); +} + +int KyraEngine_v2::o2_setGameFlag(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2_setGameFlag(%p) (%d)", (const void *)script, stackPos(0)); + return setGameFlag(stackPos(0)); +} + +int KyraEngine_v2::o2_hideMouse(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2_hideMouse(%p) ()", (const void *)script); + _screen->hideMouse(); + return 0; +} + +int KyraEngine_v2::o2_addSpecialExit(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2_addSpecialExit(%p) (%d, %d, %d, %d, %d)", (const void *)script, + stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4)); + if (_specialExitCount < 5) { + _specialExitTable[_specialExitCount+0] = stackPos(0); + _specialExitTable[_specialExitCount+5] = stackPos(1); + _specialExitTable[_specialExitCount+10] = stackPos(2); + _specialExitTable[_specialExitCount+15] = stackPos(3); + _specialExitTable[_specialExitCount+20] = stackPos(4); + ++_specialExitCount; + } + return 0; +} + +int KyraEngine_v2::o2_showMouse(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2_showMouse(%p) ()", (const void *)script); + _screen->showMouse(); + return 0; +} + +int KyraEngine_v2::o2_setScaleTableItem(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2_setScaleTableItem(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); + setScaleTableItem(stackPos(0), stackPos(1)); + return 0; +} + +int KyraEngine_v2::o2_setDrawLayerTableItem(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2_setDrawLayerTableItem(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); + setDrawLayerTableEntry(stackPos(0), stackPos(1)); + return 0; +} + +int KyraEngine_v2::o2_drawSceneShapeOnPage(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2_drawSceneShapeOnPage(%p) (%d, %d, %d, %d, %d)", (const void *)script, + stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4)); + int shape = stackPos(0); + int x = stackPos(1); + int y = stackPos(2); + int flag = stackPos(3); + int drawPage = stackPos(4); + _screen->drawShape(drawPage, _sceneShapeTable[shape], x, y, 2, flag ? 1 : 0); + return 0; +} + +int KyraEngine_v2::o2_restoreBackBuffer(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2_restoreBackBuffer(%p) (%d, %d)", (const void *)script, stackPos(0)); + int disable = stackPos(0); + int oldState = 0; + if (disable) { + oldState = _animObjects[0].enabled; + _animObjects[0].enabled = 0; + } + restorePage3(); + if (disable) + _animObjects[0].enabled = oldState; + return 0; +} + +int KyraEngine_v2::o2_getRand(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2_getRand(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); + assert(stackPos(0) < stackPos(1)); + return _rnd.getRandomNumberRng(stackPos(0), stackPos(1)); +} + +int KyraEngine_v2::o2_encodeShape(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2_encodeShape(%p) (%d, %d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), + stackPos(2), stackPos(3), stackPos(4)); + _sceneShapeTable[stackPos(0)] = _screen->encodeShape(stackPos(1), stackPos(2), stackPos(3), stackPos(4), 2); + return 0; +} + +int KyraEngine_v2::o2_defineRoomEntrance(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2_defineRoomEntrance(%p) (%d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2)); + switch (stackPos(0)) { + case 0: + _sceneEnterX1 = stackPos(1); + _sceneEnterY1 = stackPos(2); + break; + + case 1: + _sceneEnterX2 = stackPos(1); + _sceneEnterY2 = stackPos(2); + break; + + case 2: + _sceneEnterX3 = stackPos(1); + _sceneEnterY3 = stackPos(2); + break; + + case 3: + _sceneEnterX4 = stackPos(1); + _sceneEnterY4 = stackPos(2); + break; + + default: + break; + } + return 0; +} + +int KyraEngine_v2::o2_setSpecialSceneScriptRunTime(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2_setSpecialSceneScriptRunTime(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); + assert(stackPos(0) >= 0 && stackPos(0) < 10); + _sceneSpecialScriptsTimer[stackPos(0)] = _system->getMillis() + stackPos(1) * _tickLength; + return 0; +} + +int KyraEngine_v2::o2_defineSceneAnim(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2_defineSceneAnim(%p) (%d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, '%s')", (const void *)script, + stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4), stackPos(5), stackPos(6), stackPos(7), stackPos(8), + stackPos(9), stackPos(10), stackPos(11), stackPosString(12)); + int animId = stackPos(0); + SceneAnim &anim = _sceneAnims[animId]; + anim.flags = stackPos(1); + anim.x = stackPos(2); + anim.y = stackPos(3); + anim.x2 = stackPos(4); + anim.y2 = stackPos(5); + anim.width = stackPos(6); + anim.height = stackPos(7); + anim.unkE = stackPos(8); + anim.specialSize = stackPos(9); + anim.unk12 = stackPos(10); + anim.shapeIndex = stackPos(11); + if (stackPosString(12) != 0) + strcpy(anim.filename, stackPosString(12)); + + if (anim.flags & 0x40) { + if (!_sceneAnimMovie[animId]->open(anim.filename, 1, 0)) + error("couldn't load '%s'", anim.filename); + + if (_sceneAnimMovie[animId]->xAdd() || _sceneAnimMovie[animId]->yAdd()) + anim.wsaFlag = 1; + else + anim.wsaFlag = 0; + } + + return 0; +} + +int KyraEngine_v2::o2_updateSceneAnim(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2_updateSceneAnim(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); + updateSceneAnim(stackPos(0), stackPos(1)); + _specialSceneScriptRunFlag = false; + return 0; +} + +int KyraEngine_v2::o2_defineRoom(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2_defineRoom(%p) (%d, '%s', %d, %d, %d, %d, %d, %d)", (const void *)script, + stackPos(0), stackPosString(1), stackPos(2), stackPos(3), stackPos(4), stackPos(5), stackPos(6), stackPos(7)); + SceneDesc *scene = &_sceneList[stackPos(0)]; + strcpy(scene->filename, stackPosString(1)); + scene->exit1 = stackPos(2); + scene->exit2 = stackPos(3); + scene->exit3 = stackPos(4); + scene->exit4 = stackPos(5); + scene->flags = stackPos(6); + scene->sound = stackPos(7); + + if (_mainCharacter.sceneId == stackPos(0)) { + _sceneExit1 = scene->exit1; + _sceneExit2 = scene->exit2; + _sceneExit3 = scene->exit3; + _sceneExit4 = scene->exit4; + } + + return 0; +} + +int KyraEngine_v2::o2_setSpecialSceneScriptState(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2_setSpecialSceneScriptState(%p) (%d)", (const void *)script, stackPos(0)); + _specialSceneScriptState[stackPos(0)] = 1; + return 1; +} + +int KyraEngine_v2::o2_clearSpecialSceneScriptState(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2_clearSpecialSceneScriptState(%p) (%d)", (const void *)script, stackPos(0)); + _specialSceneScriptState[stackPos(0)] = 0; + return 0; +} + +int KyraEngine_v2::o2_querySpecialSceneScriptState(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2_querySpecialSceneScriptState(%p) (%d)", (const void *)script, stackPos(0)); + return _specialSceneScriptState[stackPos(0)]; +} + +int KyraEngine_v2::o2_dummy(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "o2_dummy(%p) ()", (const void *)script); + return 0; +} + +} // end of namespace Kyra diff --git a/engines/kyra/sequences_v1.cpp b/engines/kyra/sequences_v1.cpp index 55c294fb1c..3bba3406a8 100644 --- a/engines/kyra/sequences_v1.cpp +++ b/engines/kyra/sequences_v1.cpp @@ -32,6 +32,7 @@ #include "kyra/wsamovie.h" #include "kyra/animator_v1.h" #include "kyra/text.h" +#include "kyra/timer.h" #include "common/events.h" #include "common/system.h" @@ -654,7 +655,7 @@ void KyraEngine_v1::seq_makeBrandonInv() { _screen->hideMouse(); checkAmuletAnimFlags(); _brandonStatusBit |= 0x20; - setTimerCountdown(18, 2700); + _timer->setCountdown(18, 2700); _brandonStatusBit |= 0x40; snd_playSoundEffect(0x77); _brandonInvFlag = 0; @@ -732,9 +733,9 @@ void KyraEngine_v1::seq_makeBrandonWisp() { _brandonStatusBit |= 2; if (_currentCharacter->sceneId >= 109 && _currentCharacter->sceneId <= 198) - setTimerCountdown(14, 18000); + _timer->setCountdown(14, 18000); else - setTimerCountdown(14, 7200); + _timer->setCountdown(14, 7200); _animator->_brandonDrawFrame = 113; _brandonStatusBit0x02Flag = 1; @@ -1858,7 +1859,7 @@ void KyraEngine_v1::drawJewelsFadeOutEnd(int jewel) { } setGameFlag(0xF1); - setTimerCountdown(19, newDelay); + _timer->setCountdown(19, newDelay); _screen->hideMouse(); for (int i = 0; jewelTable[i] != 0xFFFF; ++i) { uint16 shape = jewelTable[i]; diff --git a/engines/kyra/sequences_v2.cpp b/engines/kyra/sequences_v2.cpp index afda1091e6..1c098bf887 100644 --- a/engines/kyra/sequences_v2.cpp +++ b/engines/kyra/sequences_v2.cpp @@ -569,6 +569,7 @@ void KyraEngine_v2::seq_loadWSA(int wsaNum, const char *filename, int frameDelay _activeWSA[wsaNum].movie = new WSAMovieV2(this); assert(_activeWSA[wsaNum].movie); _activeWSA[wsaNum].endFrame = _activeWSA[wsaNum].movie->open(filename, 0, _screen->_currentPalette); + _activeWSA[wsaNum].movie->flagOldOff(true); assert(_activeWSA[wsaNum].movie->opened()); _activeWSA[wsaNum].currentFrame = 0; _activeWSA[wsaNum].frameDelay = frameDelay; diff --git a/engines/kyra/staticres.cpp b/engines/kyra/staticres.cpp index 68e5401481..3cf8648aa8 100644 --- a/engines/kyra/staticres.cpp +++ b/engines/kyra/staticres.cpp @@ -868,16 +868,41 @@ const ScreenDim Screen::_screenDimTable[] = { { 0x03, 0x28, 0x22, 0x46, 0x0F, 0x0D, 0x00, 0x00 } }; -const int Screen::_screenDimTableCount = ARRAYSIZE(_screenDimTable); +const int Screen::_screenDimTableCount = ARRAYSIZE(Screen::_screenDimTable); + +const ScreenDim Screen_v2::_screenDimTable[] = { + { 0x00, 0x00, 0x28, 0xC8, 0xC7, 0xCF, 0x00, 0x00 }, + { 0x08, 0x48, 0x18, 0x38, 0xC7, 0xCF, 0x00, 0x00 }, + { 0x00, 0x00, 0x28, 0x90, 0xC7, 0xCF, 0x00, 0x00 }, + { 0x00, 0xC2, 0x28, 0x06, 0xC7, 0xCF, 0x00, 0x00 }, + { 0x00, 0x90, 0x28, 0x38, 0x96, 0xCF, 0x00, 0x00 }, + { 0x01, 0x94, 0x26, 0x30, 0x96, 0x1B, 0x00, 0x00 }, + { 0x00, 0x90, 0x28, 0x38, 0xC7, 0xCC, 0x00, 0x00 }, + { 0x01, 0x96, 0x26, 0x32, 0xC7, 0xCC, 0x00, 0x00 }, + { 0x00, 0x00, 0x28, 0x88, 0xC7, 0xCF, 0x00, 0x00 }, + { 0x00, 0x08, 0x28, 0xB8, 0xC7, 0xCF, 0x00, 0x00 }, + { 0x01, 0x28, 0x26, 0x46, 0xC7, 0xCC, 0x00, 0x00 }, + { 0x0A, 0x96, 0x14, 0x30, 0x19, 0xF0, 0x00, 0x00 } // menu, just present for current menu code +}; + +const int Screen_v2::_screenDimTableCount = ARRAYSIZE(Screen_v2::_screenDimTable); -const ScreenDim Screen::_screenDimTableK3[] = { +const ScreenDim Screen_v2::_screenDimTableK3[] = { { 0x00, 0x00, 0x28, 0xC8, 0xFF, 0xF0, 0x00, 0x00 }, { 0x08, 0x48, 0x18, 0x38, 0xFF, 0xF0, 0x00, 0x00 }, { 0x00, 0x00, 0x28, 0xBC, 0xFF, 0xF0, 0x00, 0x00 }, { 0x0A, 0x96, 0x14, 0x30, 0x19, 0xF0, 0x00, 0x00 } }; -const int Screen::_screenDimTableCountK3 = ARRAYSIZE(_screenDimTableK3); +const int Screen_v2::_screenDimTableCountK3 = ARRAYSIZE(Screen_v2::_screenDimTableK3); + +const int8 KyraEngine::_addXPosTable[] = { + 4, 4, 0, -4, -4, -4, 0, 4 +}; + +const int8 KyraEngine::_addYPosTable[] = { + 0, -2, -2, -2, 0, 2, 2, 2 +}; const char *KyraEngine_v1::_soundFiles[] = { "INTRO", @@ -909,18 +934,10 @@ const int8 KyraEngine_v1::_charXPosTable[] = { 0, 4, 4, 4, 0, -4, -4, -4 }; -const int8 KyraEngine_v1::_addXPosTable[] = { - 4, 4, 0, -4, -4, -4, 0, 4 -}; - const int8 KyraEngine_v1::_charYPosTable[] = { -2, -2, 0, 2, 2, 2, 0, -2 }; -const int8 KyraEngine_v1::_addYPosTable[] = { - 0, -2, -2, -2, 0, 2, 2, 2 -}; - const uint16 KyraEngine_v1::_itemPosX[] = { 95, 115, 135, 155, 175, 95, 115, 135, 155, 175 }; @@ -1196,6 +1213,34 @@ const char *KyraEngine_v2::_introSoundList[] = { const int KyraEngine_v2::_introSoundListSize = ARRAYSIZE(KyraEngine_v2::_introSoundList); +const char *KyraEngine_v2::_languageExtension[] = { + "ENG", + "FRE", + "GER"/*, + "ITA", Italian and Spanish was never included + "SPA"*/ +}; + +const char *KyraEngine_v2::_scriptLangExt[] = { + "EMC", + "FMC", + "GMC"/*, + "IMC", Italian and Spanish was never included + "SMC"*/ +}; + +int KyraEngine_v2::_characterFrameTable[] = { + 0x19, 0x09, 0x09, 0x12, 0x12, 0x12, 0x09, 0x09 +}; + +int KyraEngine_v2::_inventoryX[] = { + 0x4F, 0x63, 0x77, 0x8B, 0x9F, 0x4F, 0x63, 0x77, 0x8B, 0x9F +}; + +int KyraEngine_v2::_inventoryY[] = { + 0x95, 0x95, 0x95, 0x95, 0x95, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA +}; + // kyra 3 static res const char *KyraEngine_v3::_soundList[] = { diff --git a/engines/kyra/text_v1.cpp b/engines/kyra/text_v1.cpp index 3ca986adf8..c04aa2105f 100644 --- a/engines/kyra/text_v1.cpp +++ b/engines/kyra/text_v1.cpp @@ -28,6 +28,7 @@ #include "kyra/text.h" #include "kyra/animator_v1.h" #include "kyra/sprites.h" +#include "kyra/timer.h" namespace Kyra { @@ -66,9 +67,9 @@ void KyraEngine_v1::waitForChatToFinish(int vocFile, int16 chatDuration, const c snd_playVoiceFile(vocFile); } - disableTimer(14); - disableTimer(18); - disableTimer(19); + _timer->disable(14); + _timer->disable(18); + _timer->disable(19); uint32 timeAtStart = _system->getMillis(); uint32 loopStart; @@ -80,7 +81,7 @@ void KyraEngine_v1::waitForChatToFinish(int vocFile, int16 chatDuration, const c if (_system->getMillis() > timeToEnd && !hasUpdatedNPCs) { hasUpdatedNPCs = true; - disableTimer(15); + _timer->disable(15); _currHeadShape = 4; _animator->animRefreshNPC(0); _animator->animRefreshNPC(_talkingCharNum); @@ -92,7 +93,7 @@ void KyraEngine_v1::waitForChatToFinish(int vocFile, int16 chatDuration, const c } } - updateGameTimers(); + _timer->update(); _sprites->updateSceneAnims(); _animator->restoreAllObjectBackgrounds(); _animator->preserveAnyChangedBackgrounds(); @@ -146,10 +147,10 @@ void KyraEngine_v1::waitForChatToFinish(int vocFile, int16 chatDuration, const c snd_voiceWaitForFinish(); snd_stopVoice(); - enableTimer(14); - enableTimer(15); - enableTimer(18); - enableTimer(19); + _timer->enable(14); + _timer->enable(15); + _timer->enable(18); + _timer->enable(19); //clearKyrandiaButtonIO(); } @@ -374,7 +375,7 @@ void KyraEngine_v1::updateTextFade() { return; bool finished = false; - for (int i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { if (_currSentenceColor[i] > 4) _currSentenceColor[i] -= 4; else @@ -382,7 +383,8 @@ void KyraEngine_v1::updateTextFade() { _currSentenceColor[i] = 0; finished = true; } - + } + _screen->_currentPalette[765] = _currSentenceColor[0]; _screen->_currentPalette[766] = _currSentenceColor[1]; _screen->_currentPalette[767] = _currSentenceColor[2]; diff --git a/engines/kyra/timer.cpp b/engines/kyra/timer.cpp new file mode 100644 index 0000000000..dff191cbe0 --- /dev/null +++ b/engines/kyra/timer.cpp @@ -0,0 +1,251 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include "kyra/kyra.h" +#include "kyra/timer.h" + +#include "common/func.h" +#include "common/savefile.h" + +namespace Kyra { + +namespace { +struct TimerResync : public Common::UnaryFunction { + uint32 _tickLength, _curTime; + TimerResync(KyraEngine *vm, uint32 curTime) : _tickLength(vm->tickLength()), _curTime(curTime) {} + + void operator()(TimerEntry &entry) const { + if (entry.lastUpdate < 0) { + if ((entry.lastUpdate + _curTime) <= 0) + entry.nextRun = 0; + else + entry.nextRun = _curTime + entry.lastUpdate + entry.countdown * _tickLength; + } else { + uint32 nextRun = entry.lastUpdate + entry.countdown * _tickLength; + if (_curTime < nextRun) + nextRun = 0; + entry.nextRun = nextRun; + } + } +}; + +struct TimerEqual : public Common::UnaryFunction { + uint8 _id; + + TimerEqual(uint8 id) : _id(id) {} + + bool operator()(const TimerEntry &entry) const { + return entry.id == _id; + } +}; +} // end of anonymous namespace + +void TimerManager::reset() { + for (Iterator pos = _timers.begin(); pos != _timers.end(); ++pos) { + delete pos->func; + } + + _timers.clear(); +} + +void TimerManager::addTimer(uint8 id, TimerFunc *func, int countdown, bool enabled) { + debugC(9, kDebugLevelTimer, "TimerManager::addTimer(%d, %p, %d, %d)", id, (const void*)func, countdown, enabled); + + TimerEntry newTimer; + + newTimer.id = id; + newTimer.countdown = countdown; + newTimer.enabled = enabled ? 1 : 0; + newTimer.lastUpdate = newTimer.nextRun = 0; + newTimer.func = func; + + _timers.push_back(newTimer); +} + +void TimerManager::update() { + debugC(9, kDebugLevelTimer, "TimerManager::update()"); + + if (_system->getMillis() < _nextRun) + return; + + _nextRun += 99999; + + for (Iterator pos = _timers.begin(); pos != _timers.end(); ++pos) { + if (pos->enabled && pos->countdown >= 0 && pos->nextRun <= _system->getMillis()) { + if (pos->func && *pos->func) + (*pos->func)(pos->id); + + uint32 curTime = _system->getMillis(); + pos->lastUpdate = curTime; + pos->nextRun = curTime + pos->countdown * _vm->tickLength(); + + _nextRun = MIN(_nextRun, pos->nextRun); + } + } +} + +void TimerManager::resync() { + debugC(9, kDebugLevelTimer, "TimerManager::resync()"); + + _nextRun = 0; // force rerun + Common::for_each(_timers.begin(), _timers.end(), TimerResync(_vm, _system->getMillis())); +} + +void TimerManager::resetNextRun() { + debugC(9, kDebugLevelTimer, "TimerManager::resetNextRun()"); + _nextRun = 0; +} + +void TimerManager::setCountdown(uint8 id, int32 countdown) { + debugC(9, kDebugLevelTimer, "TimerManager::setCountdown(%d, %d)", id, countdown); + + Iterator timer = Common::find_if(_timers.begin(), _timers.end(), TimerEqual(id)); + if (timer != _timers.end()) { + timer->countdown = countdown; + + if (countdown >= 0) { + uint32 curTime = _system->getMillis(); + timer->lastUpdate = curTime; + timer->nextRun = curTime + countdown * _vm->tickLength(); + + _nextRun = MIN(_nextRun, timer->nextRun); + } + } else { + warning("TimerManager::setCountdown: No timer %d", id); + } +} + +void TimerManager::setDelay(uint8 id, int32 countdown) { + debugC(9, kDebugLevelTimer, "TimerManager::setDelay(%d, %d)", id, countdown); + + Iterator timer = Common::find_if(_timers.begin(), _timers.end(), TimerEqual(id)); + if (timer != _timers.end()) + timer->countdown = countdown; + else + warning("TimerManager::setDelay: No timer %d", id); +} + +int32 TimerManager::getDelay(uint8 id) const { + debugC(9, kDebugLevelTimer, "TimerManager::getDelay(%d)", id); + + CIterator timer = Common::find_if(_timers.begin(), _timers.end(), TimerEqual(id)); + if (timer != _timers.end()) + return timer->countdown; + + warning("TimerManager::getDelay: No timer %d", id); + return -1; +} + +bool TimerManager::isEnabled(uint8 id) const { + debugC(9, kDebugLevelTimer, "TimerManager::isEnabled(%d)", id); + + CIterator timer = Common::find_if(_timers.begin(), _timers.end(), TimerEqual(id)); + if (timer != _timers.end()) + return (timer->enabled == 1); + + warning("TimerManager::isEnabled: No timer %d", id); + return false; +} + +void TimerManager::enable(uint8 id) { + debugC(9, kDebugLevelTimer, "TimerManager::enable(%d)", id); + + Iterator timer = Common::find_if(_timers.begin(), _timers.end(), TimerEqual(id)); + if (timer != _timers.end()) + timer->enabled = 1; + else + warning("TimerManager::enable: No timer %d", id); +} + +void TimerManager::disable(uint8 id) { + debugC(9, kDebugLevelTimer, "TimerManager::disable(%d)", id); + + Iterator timer = Common::find_if(_timers.begin(), _timers.end(), TimerEqual(id)); + if (timer != _timers.end()) + timer->enabled = 0; + else + warning("TimerManager::disable: No timer %d", id); +} + +void TimerManager::loadDataFromFile(Common::InSaveFile *file, int version) { + debugC(9, kDebugLevelTimer, "TimerManager::loadDataFromFile(%p, %d)", (const void*)file, version); + + if (version <= 7) { + _nextRun = 0; + for (int i = 0; i < 32; ++i) { + uint8 enabled = file->readByte(); + int32 countdown = file->readSint32BE(); + uint32 nextRun = file->readUint32BE(); + + Iterator timer = Common::find_if(_timers.begin(), _timers.end(), TimerEqual(i)); + if (timer != _timers.end()) { + timer->enabled = enabled; + timer->countdown = countdown; + + if (nextRun) { + timer->nextRun = nextRun + _system->getMillis(); + timer->lastUpdate = timer->nextRun - countdown * _vm->tickLength(); + } else { + uint32 curTime = _system->getMillis(); + timer->nextRun = curTime; + timer->lastUpdate = curTime - countdown * _vm->tickLength(); + } + } else { + warning("Loading timer data for non existing timer %d", i); + } + } + } else { + int entries = file->readByte(); + for (int i = 0; i < entries; ++i) { + uint8 id = file->readByte(); + + Iterator timer = Common::find_if(_timers.begin(), _timers.end(), TimerEqual(id)); + if (timer != _timers.end()) { + timer->enabled = file->readByte(); + timer->countdown = file->readSint32BE(); + timer->lastUpdate = file->readSint32BE(); + } else { + warning("Loading timer data for non existing timer %d", id); + file->seek(7, SEEK_CUR); + } + } + + resync(); + } +} + +void TimerManager::saveDataToFile(Common::OutSaveFile *file) const { + debugC(9, kDebugLevelTimer, "TimerManager::saveDataToFile(%p)", (const void*)file); + + file->writeByte(count()); + for (CIterator pos = _timers.begin(); pos != _timers.end(); ++pos) { + file->writeByte(pos->id); + file->writeByte(pos->enabled); + file->writeSint32BE(pos->countdown); + file->writeSint32BE(pos->lastUpdate - _system->getMillis()); + } +} + +} // end of namespace Kyra diff --git a/engines/kyra/timer.h b/engines/kyra/timer.h new file mode 100644 index 0000000000..1edeb92a42 --- /dev/null +++ b/engines/kyra/timer.h @@ -0,0 +1,93 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#ifndef KYRA_TIMER_H +#define KYRA_TIMER_H + +#include "kyra/kyra.h" +#include "kyra/util.h" + +#include "common/list.h" + +namespace Common { +class InSaveFile; +class OutSaveFile; +} // end of namespace Common + +namespace Kyra { + +typedef Functor1 TimerFunc; + +struct TimerEntry { + uint8 id; + int32 countdown; + int8 enabled; + + int32 lastUpdate; + uint32 nextRun; + + TimerFunc *func; +}; + +class TimerManager { +public: + TimerManager(KyraEngine *vm, OSystem *sys) : _vm(vm), _system(sys), _timers(), _nextRun(0) {} + ~TimerManager() { reset(); } + + void reset(); + + void addTimer(uint8 id, TimerFunc *func, int countdown, bool enabled); + + int count() const { return _timers.size(); } + + void update(); + + void resetNextRun(); + + void setCountdown(uint8 id, int32 countdown); + void setDelay(uint8 id, int32 countdown); + int32 getDelay(uint8 id) const; + + bool isEnabled(uint8 id) const; + void enable(uint8 id); + void disable(uint8 id); + + void resync(); + + void loadDataFromFile(Common::InSaveFile *file, int version); + void saveDataToFile(Common::OutSaveFile *file) const; +private: + KyraEngine *_vm; + OSystem *_system; + Common::List _timers; + uint32 _nextRun; + + typedef Common::List::iterator Iterator; + typedef Common::List::const_iterator CIterator; +}; + +} // end of namespace Kyra + +#endif diff --git a/engines/kyra/timer_v1.cpp b/engines/kyra/timer_v1.cpp index 0b5184fe5a..55dab4413f 100644 --- a/engines/kyra/timer_v1.cpp +++ b/engines/kyra/timer_v1.cpp @@ -11,7 +11,7 @@ * 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 + * 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 @@ -23,126 +23,58 @@ * */ +#include "kyra/kyra.h" #include "kyra/kyra_v1.h" #include "kyra/screen.h" #include "kyra/animator_v1.h" +#include "kyra/timer.h" #include "common/system.h" namespace Kyra { -void KyraEngine_v1::setupTimers() { - debugC(9, kDebugLevelMain, "KyraEngine_v1::setupTimers()"); - memset(_timers, 0, sizeof(_timers)); - - for (int i = 0; i < 34; i++) - _timers[i].active = 1; - - _timers[0].func = _timers[1].func = _timers[2].func = _timers[3].func = _timers[4].func = 0; //Unused. - _timers[5].func = _timers[6].func = _timers[7].func = _timers[8].func = _timers[9].func = 0; //_nullsub51; - _timers[10].func = _timers[11].func = _timers[12].func = _timers[13].func = 0; //_nullsub50; - _timers[14].func = &KyraEngine_v1::timerCheckAnimFlag2; //_nullsub52; - _timers[15].func = &KyraEngine_v1::timerUpdateHeadAnims; //_nullsub48; - _timers[16].func = &KyraEngine_v1::timerSetFlags1; //_nullsub47; - _timers[17].func = 0; //sub_15120; - _timers[18].func = &KyraEngine_v1::timerCheckAnimFlag1; //_nullsub53; - _timers[19].func = &KyraEngine_v1::timerRedrawAmulet; //_nullsub54; - _timers[20].func = 0; //offset _timerDummy1 - _timers[21].func = 0; //sub_1517C; - _timers[22].func = 0; //offset _timerDummy2 - _timers[23].func = 0; //offset _timerDummy3, - _timers[24].func = 0; //_nullsub45; - _timers[25].func = 0; //offset _timerDummy4 - _timers[26].func = 0; //_nullsub46; - _timers[27].func = 0; //offset _timerDummy5, - _timers[28].func = 0; //offset _timerDummy6 - _timers[29].func = 0; //offset _timerDummy7, - _timers[30].func = 0; //offset _timerDummy8, - _timers[31].func = &KyraEngine_v1::timerFadeText; //sub_151F8; - _timers[32].func = &KyraEngine_v1::updateAnimFlag1; //_nullsub61; - _timers[33].func = &KyraEngine_v1::updateAnimFlag2; //_nullsub62; - - _timers[0].countdown = _timers[1].countdown = _timers[2].countdown = _timers[3].countdown = _timers[4].countdown = -1; - _timers[5].countdown = 5; - _timers[6].countdown = 7; - _timers[7].countdown = 8; - _timers[8].countdown = 9; - _timers[9].countdown = 7; - _timers[10].countdown = _timers[11].countdown = _timers[12].countdown = _timers[13].countdown = 420; - _timers[14].countdown = 600; - _timers[15].countdown = 11; - _timers[16].countdown = _timers[17].countdown = 7200; - _timers[18].countdown = _timers[19].countdown = 600; - _timers[20].countdown = 7200; - _timers[21].countdown = 18000; - _timers[22].countdown = 7200; - _timers[23].countdown = _timers[24].countdown = _timers[25].countdown = _timers[26].countdown = _timers[27].countdown = 10800; - _timers[28].countdown = 21600; - _timers[29].countdown = 7200; - _timers[30].countdown = 10800; - _timers[31].countdown = -1; - _timers[32].countdown = 9; - _timers[33].countdown = 3; -} - -void KyraEngine_v1::updateGameTimers() { - debugC(9, kDebugLevelMain, "KyraEngine_v1::updateGameTimers()"); - - if (_system->getMillis() < _timerNextRun) - return; - - _timerNextRun += 99999; - - for (int i = 0; i < 34; i++) { - if (_timers[i].active && _timers[i].countdown > -1) { - if (_timers[i].nextRun <=_system->getMillis()) { - if (i > 4 && _timers[i].func) - (*this.*_timers[i].func)(i); - - _timers[i].nextRun = _system->getMillis() + _timers[i].countdown * _tickLength; - } - } - if (_timers[i].nextRun < _timerNextRun) - _timerNextRun = _timers[i].nextRun; - } -} - -void KyraEngine_v1::clearNextEventTickCount() { - debugC(9, kDebugLevelMain, "KyraEngine_v1::clearNextEventTickCount()"); - _timerNextRun = 0; -} - -void KyraEngine_v1::setTimerDelay(uint8 timer, int32 countdown) { - debugC(9, kDebugLevelMain, "KyraEngine_v1::setTimerDelay(%i, %d)", timer, countdown); - _timers[timer].countdown = countdown; -} -int16 KyraEngine_v1::getTimerDelay(uint8 timer) { - debugC(9, kDebugLevelMain, "KyraEngine_v1::getTimerDelay(%i)", timer); - return _timers[timer].countdown; -} +#define TimerV1(x) new Functor1Mem(this, &KyraEngine_v1::x) -void KyraEngine_v1::setTimerCountdown(uint8 timer, int32 countdown) { - debugC(9, kDebugLevelMain, "KyraEngine_v1::setTimerCountdown(%i, %i)", timer, countdown); - _timers[timer].countdown = countdown; - _timers[timer].nextRun = _system->getMillis() + countdown * _tickLength; +void KyraEngine_v1::setupTimers() { + debugC(9, kDebugLevelMain | kDebugLevelTimer, "KyraEngine_v1::setupTimers()"); - uint32 nextRun = _system->getMillis() + countdown * _tickLength; - if (nextRun < _timerNextRun) - _timerNextRun = nextRun; -} + for (int i = 0; i <= 4; ++i) + _timer->addTimer(i, 0, -1, 1); -void KyraEngine_v1::enableTimer(uint8 timer) { - debugC(9, kDebugLevelMain, "KyraEngine_v1::enableTimer(%i)", timer); - _timers[timer].active = 1; -} + _timer->addTimer(5, 0, 5, 1); + _timer->addTimer(6, 0, 7, 1); + _timer->addTimer(7, 0, 8, 1); + _timer->addTimer(8, 0, 9, 1); + _timer->addTimer(9, 0, 7, 1); + + for (int i = 10; i <= 13; ++i) + _timer->addTimer(i, 0, 420, 1); + + _timer->addTimer(14, TimerV1(timerCheckAnimFlag2), 600, 1); + _timer->addTimer(15, TimerV1(timerUpdateHeadAnims), 11, 1); + _timer->addTimer(16, TimerV1(timerSetFlags1), 7200, 1); + _timer->addTimer(17, 0 /*sub_15120*/, 7200, 1); + _timer->addTimer(18, TimerV1(timerCheckAnimFlag1), 600, 1); + _timer->addTimer(19, TimerV1(timerRedrawAmulet), 600, 1); + + _timer->addTimer(20, 0, 7200, 1); + _timer->addTimer(21, 0/*sub_1517C*/, 18000, 1); + _timer->addTimer(22, 0, 7200, 1); + + for (int i = 23; i <= 27; ++i) + _timer->addTimer(i, 0, 10800, 1); -void KyraEngine_v1::disableTimer(uint8 timer) { - debugC(9, kDebugLevelMain, "KyraEngine_v1::disableTimer(%i)", timer); - _timers[timer].active = 0; + _timer->addTimer(28, 0, 21600, 1); + _timer->addTimer(29, 0, 7200, 1); + _timer->addTimer(30, 0, 10800, 1); + + _timer->addTimer(31, TimerV1(timerFadeText), -1, 1); + _timer->addTimer(32, TimerV1(updateAnimFlag1), 9, 1); + _timer->addTimer(33, TimerV1(updateAnimFlag2), 3, 1); } void KyraEngine_v1::timerUpdateHeadAnims(int timerNum) { - debugC(9, kDebugLevelMain, "KyraEngine_v1::timerUpdateHeadAnims(%i)", timerNum); + debugC(9, kDebugLevelMain | kDebugLevelTimer, "KyraEngine_v1::timerUpdateHeadAnims(%i)", timerNum); static int8 currentFrame = 0; static const int8 frameTable[] = {4, 5, 4, 5, 4, 5, 0, 1, 4, 5, 4, 4, 6, 4, 8, 1, 9, 4, -1}; @@ -161,7 +93,7 @@ void KyraEngine_v1::timerUpdateHeadAnims(int timerNum) { } void KyraEngine_v1::timerSetFlags1(int timerNum) { - debugC(9, kDebugLevelMain, "KyraEngine_v1::timerSetFlags(%i)", timerNum); + debugC(9, kDebugLevelMain | kDebugLevelTimer, "KyraEngine_v1::timerSetFlags(%i)", timerNum); if (_currentCharacter->sceneId == 0x1C) return; @@ -180,112 +112,68 @@ void KyraEngine_v1::timerSetFlags1(int timerNum) { } void KyraEngine_v1::timerFadeText(int timerNum) { - debugC(9, kDebugLevelMain, "KyraEngine_v1::timerFadeText(%i)", timerNum); + debugC(9, kDebugLevelMain | kDebugLevelTimer, "KyraEngine_v1::timerFadeText(%i)", timerNum); _fadeText = true; } void KyraEngine_v1::updateAnimFlag1(int timerNum) { - debugC(9, kDebugLevelMain, "KyraEngine_v1::updateAnimFlag1(%d)", timerNum); + debugC(9, kDebugLevelMain | kDebugLevelTimer, "KyraEngine_v1::updateAnimFlag1(%d)", timerNum); if (_brandonStatusBit & 2) { _brandonStatusBit0x02Flag = 1; } } void KyraEngine_v1::updateAnimFlag2(int timerNum) { - debugC(9, kDebugLevelMain, "KyraEngine_v1::updateAnimFlag2(%d)", timerNum); + debugC(9, kDebugLevelMain | kDebugLevelTimer, "KyraEngine_v1::updateAnimFlag2(%d)", timerNum); if (_brandonStatusBit & 0x20) { _brandonStatusBit0x20Flag = 1; } } void KyraEngine_v1::setTextFadeTimerCountdown(int16 countdown) { - debugC(9, kDebugLevelMain, "KyraEngine_v1::setTextFadeTimerCountdown(%i)", countdown); - //if (countdown == -1) - //countdown = 32000; + debugC(9, kDebugLevelMain | kDebugLevelTimer, "KyraEngine_v1::setTextFadeTimerCountdown(%i)", countdown); + if (countdown == -1) + countdown = 32000; - setTimerCountdown(31, countdown*60); + _timer->setCountdown(31, countdown*60); } void KyraEngine_v1::timerSetFlags2(int timerNum) { - debugC(9, kDebugLevelMain, "KyraEngine_v1::timerSetFlags2(%i)", timerNum); + debugC(9, kDebugLevelMain | kDebugLevelTimer, "KyraEngine_v1::timerSetFlags2(%i)", timerNum); if (!((uint32*)(_flagsTable+0x2D))[timerNum]) ((uint32*)(_flagsTable+0x2D))[timerNum] = 1; } void KyraEngine_v1::timerCheckAnimFlag1(int timerNum) { - debugC(9, kDebugLevelMain, "KyraEngine_v1::timerCheckAnimFlag1(%i)", timerNum); + debugC(9, kDebugLevelMain | kDebugLevelTimer, "KyraEngine_v1::timerCheckAnimFlag1(%i)", timerNum); if (_brandonStatusBit & 0x20) { checkAmuletAnimFlags(); - setTimerCountdown(18, -1); + _timer->setCountdown(18, -1); } } void KyraEngine_v1::timerCheckAnimFlag2(int timerNum) { - debugC(9, kDebugLevelMain, "KyraEngine_v1::timerCheckAnimFlag1(%i)", timerNum); + debugC(9, kDebugLevelMain | kDebugLevelTimer, "KyraEngine_v1::timerCheckAnimFlag2(%i)", timerNum); if (_brandonStatusBit & 0x2) { checkAmuletAnimFlags(); - setTimerCountdown(14, -1); - } -} - -void KyraEngine_v1::checkAmuletAnimFlags() { - debugC(9, kDebugLevelMain, "KyraEngine_v1::checkSpecialAnimFlags()"); - if (_brandonStatusBit & 2) { - seq_makeBrandonNormal2(); - setTimerCountdown(19, 300); - } - - if (_brandonStatusBit & 0x20) { - seq_makeBrandonNormal(); - setTimerCountdown(19, 300); + _timer->setCountdown(14, -1); } } void KyraEngine_v1::timerRedrawAmulet(int timerNum) { - debugC(9, kDebugLevelMain, "KyraEngine_v1::timerRedrawAmulet(%i)", timerNum); + debugC(9, kDebugLevelMain | kDebugLevelTimer, "KyraEngine_v1::timerRedrawAmulet(%i)", timerNum); if (queryGameFlag(0xF1)) { drawAmulet(); - setTimerCountdown(19, -1); - } -} - -void KyraEngine_v1::drawAmulet() { - debugC(9, kDebugLevelMain, "KyraEngine_v1::drawAmulet()"); - static const int16 amuletTable1[] = {0x167, 0x162, 0x15D, 0x158, 0x153, 0x150, 0x155, 0x15A, 0x15F, 0x164, 0x145, -1}; - static const int16 amuletTable3[] = {0x167, 0x162, 0x15D, 0x158, 0x153, 0x14F, 0x154, 0x159, 0x15E, 0x163, 0x144, -1}; - static const int16 amuletTable2[] = {0x167, 0x162, 0x15D, 0x158, 0x153, 0x152, 0x157, 0x15C, 0x161, 0x166, 0x147, -1}; - static const int16 amuletTable4[] = {0x167, 0x162, 0x15D, 0x158, 0x153, 0x151, 0x156, 0x15B, 0x160, 0x165, 0x146, -1}; - - resetGameFlag(0xF1); - _screen->hideMouse(); - - int i = 0; - while (amuletTable1[i] != -1) { - if (queryGameFlag(87)) - _screen->drawShape(0, _shapes[amuletTable1[i]], _amuletX[0], _amuletY[0], 0, 0); - - if (queryGameFlag(89)) - _screen->drawShape(0, _shapes[amuletTable2[i]], _amuletX[1], _amuletY[1], 0, 0); - - if (queryGameFlag(86)) - _screen->drawShape(0, _shapes[amuletTable3[i]], _amuletX[2], _amuletY[2], 0, 0); - - if (queryGameFlag(88)) - _screen->drawShape(0, _shapes[amuletTable4[i]], _amuletX[3], _amuletY[3], 0, 0); - - _screen->updateScreen(); - delayWithTicks(3); - i++; + _timer->setCountdown(19, -1); } - _screen->showMouse(); } void KyraEngine_v1::setWalkspeed(uint8 newSpeed) { - debugC(9, kDebugLevelMain, "KyraEngine_v1::setWalkspeed(%i)", newSpeed); + debugC(9, kDebugLevelMain | kDebugLevelTimer, "KyraEngine_v1::setWalkspeed(%i)", newSpeed); static const uint8 speeds[] = {11, 9, 6, 5, 3}; assert(newSpeed < ARRAYSIZE(speeds)); - setTimerDelay(5, speeds[newSpeed]); + _timer->setDelay(5, speeds[newSpeed]); } } // end of namespace Kyra diff --git a/engines/kyra/timer_v2.cpp b/engines/kyra/timer_v2.cpp new file mode 100644 index 0000000000..2db90f6ecc --- /dev/null +++ b/engines/kyra/timer_v2.cpp @@ -0,0 +1,80 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include "kyra/kyra_v2.h" +#include "kyra/timer.h" + +namespace Kyra { + +#define TimerV2(x) new Functor1Mem(this, &KyraEngine_v2::x) + +void KyraEngine_v2::setupTimers() { + debugC(9, kDebugLevelMain | kDebugLevelTimer, "KyraEngine_v2::setupTimers()"); + + _timer->addTimer(0, 0, 5, 1); + _timer->addTimer(1, TimerV2(timerFunc2), -1, 1); + _timer->addTimer(2, TimerV2(timerFunc3), 1, 1); + _timer->addTimer(3, TimerV2(timerFunc4), 1, 0); + _timer->addTimer(4, TimerV2(timerFunc5), 1, 0); + _timer->addTimer(5, TimerV2(timerFunc6), 1, 0); +} + +void KyraEngine_v2::timerFunc2(int arg) { + debugC(9, kDebugLevelMain | kDebugLevelTimer, "KyraEngine_v2::timerFunc2(%d)", arg); + if (_shownMessage) + _msgUnk1 = 1; +} + +void KyraEngine_v2::timerFunc3(int arg) { + debugC(9, kDebugLevelMain | kDebugLevelTimer, "KyraEngine_v2::timerFunc3(%d)", arg); + // XXX +} + +void KyraEngine_v2::timerFunc4(int arg) { + debugC(9, kDebugLevelMain | kDebugLevelTimer, "KyraEngine_v2::timerFunc4(%d)", arg); + _timer->disable(3); + setGameFlag(0xD8); +} + +void KyraEngine_v2::timerFunc5(int arg) { + debugC(9, kDebugLevelMain | kDebugLevelTimer, "KyraEngine_v2::timerFunc5(%d)", arg); + // XXX +} + +void KyraEngine_v2::timerFunc6(int arg) { + debugC(9, kDebugLevelMain | kDebugLevelTimer, "KyraEngine_v2::timerFunc6(%d)", arg); + // XXX +} + +void KyraEngine_v2::setTimer1DelaySecs(int secs) { + debugC(9, kDebugLevelMain | kDebugLevelTimer, "KyraEngine_v2::setTimer1DelaySecs(%d)", secs); + + if (secs == -1) + secs = 32000; + + _timer->setCountdown(1, secs * 60); +} + +} // end of namespace Kyra diff --git a/engines/kyra/util.h b/engines/kyra/util.h new file mode 100644 index 0000000000..edb2ca454a --- /dev/null +++ b/engines/kyra/util.h @@ -0,0 +1,61 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#ifndef KYRA_UTIL_H +#define KYRA_UTIL_H + +#include "common/func.h" + +namespace Kyra { + +template +struct Functor1 : public Common::UnaryFunction { + virtual operator bool() const = 0; + virtual Res operator()(Arg) const = 0; +}; + +template +class Functor1Mem : public Functor1 { +public: + typedef Res (T::*FuncType)(Arg); + + Functor1Mem(T *t, const FuncType &func) : _t(t), _func(func) {} + + operator bool() const { return _func != 0; } + Res operator()(Arg v1) const { + return (_t->*_func)(v1); + } +private: + mutable T *_t; + Res (T::*_func)(Arg); +}; + +struct ScriptState; + +typedef Functor1 Opcode; + +} // end of namespace Kyra + +#endif diff --git a/engines/kyra/wsamovie.cpp b/engines/kyra/wsamovie.cpp index f0119101fd..7e9ec9b78b 100644 --- a/engines/kyra/wsamovie.cpp +++ b/engines/kyra/wsamovie.cpp @@ -28,10 +28,11 @@ #include "common/system.h" #include "kyra/kyra.h" +#include "kyra/kyra_v2.h" #include "kyra/screen.h" +#include "kyra/screen_v2.h" #include "kyra/wsamovie.h" - namespace Kyra { WSAMovieV1::WSAMovieV1(KyraEngine *vm) : Movie(vm) {} WSAMovieV1::~WSAMovieV1() { close(); } @@ -132,8 +133,8 @@ void WSAMovieV1::close() { } } -void WSAMovieV1::displayFrame(int frameNum) { - debugC(9, kDebugLevelMovie, "WSAMovieV1::displayFrame(%d)", frameNum); +void WSAMovieV1::displayFrame(int frameNum, ...) { + debugC(9, kDebugLevelMovie, "WSAMovieV1::displayFrame(%d, ...)", frameNum); if (frameNum >= _numFrames || !_opened) return; @@ -234,7 +235,7 @@ void WSAMovieAmiga::close() { WSAMovieV1::close(); } -void WSAMovieAmiga::displayFrame(int frameNum) { +void WSAMovieAmiga::displayFrame(int frameNum, ...) { debugC(9, kDebugLevelMovie, "WSAMovieAmiga::displayFrame(%d)", frameNum); if (frameNum >= _numFrames || !_opened) return; @@ -340,7 +341,7 @@ void WSAMovieAmiga::processFrame(int frameNum, uint8 *dst) { #pragma mark - -WSAMovieV2::WSAMovieV2(KyraEngine *vm) : WSAMovieV1(vm), _xAdd(0), _yAdd(0) {} +WSAMovieV2::WSAMovieV2(KyraEngine_v2 *vm) : WSAMovieV1(vm), _vm(vm), _xAdd(0), _yAdd(0), _oldOff(false) {} int WSAMovieV2::open(const char *filename, int unk1, uint8 *palBuf) { debugC(9, kDebugLevelMovie, "WSAMovieV2::open('%s', %d, %p)", filename, unk1, (const void *)palBuf); @@ -419,5 +420,95 @@ int WSAMovieV2::open(const char *filename, int unk1, uint8 *palBuf) { return _numFrames; } +void WSAMovieV2::displayFrame(int frameNum, ...) { + debugC(9, kDebugLevelMovie, "WSAMovieV2::displayFrame(%d, ...)", frameNum); + if (frameNum >= _numFrames || !_opened) + return; + + uint8 *dst = 0; + if (_flags & WF_OFFSCREEN_DECODE) + dst = _offscreenBuffer; + else + dst = _vm->screen()->getPageRect(_drawPage, _x, _y, _width, _height); + + if (_currentFrame == _numFrames) { + if (!(_flags & WF_NO_FIRST_FRAME)) { + if (_flags & WF_OFFSCREEN_DECODE) + Screen::decodeFrameDelta(dst, _deltaBuffer); + else + Screen::decodeFrameDeltaPage(dst, _deltaBuffer, _width, (_flags & WF_XOR) == 0); + } + _currentFrame = 0; + } + + // try to reduce the number of needed frame operations + int diffCount = ABS(_currentFrame - frameNum); + int frameStep = 1; + int frameCount; + if (_currentFrame < frameNum) { + frameCount = _numFrames - frameNum + _currentFrame; + if (diffCount > frameCount) + frameStep = -1; + else + frameCount = diffCount; + } else { + frameCount = _numFrames - _currentFrame + frameNum; + if (frameCount >= diffCount) { + frameStep = -1; + frameCount = diffCount; + } + } + + // process + if (frameStep > 0) { + uint16 cf = _currentFrame; + while (frameCount--) { + cf += frameStep; + processFrame(cf, dst); + if (cf == _numFrames) + cf = 0; + } + } else { + uint16 cf = _currentFrame; + while (frameCount--) { + if (cf == 0) + cf = _numFrames; + processFrame(cf, dst); + cf += frameStep; + } + } + + // display + _currentFrame = frameNum; + if (_flags & WF_OFFSCREEN_DECODE) { + if (_oldOff) { + // Kyrandia 1 offscreen buffer -> screen copy method of Kyrandia 1, needs to be present + // for our intro code that doesn't supply all the needed parameters for the Kyrandia 2 method + _vm->screen()->copyBlockToPage(_drawPage, _x, _y, _width, _height, _offscreenBuffer); + } else { + // This is the offscreen buffer -> screen copy method of Kyrandia 2 as it's implemented + // in the original, we use this in game + Screen_v2 *screen = _vm->screen_v2(); + int pageBackUp = screen->_curPage; + screen->_curPage = _drawPage; + + va_list args; + va_start(args, frameNum); + + int copyParam = va_arg(args, int); + int plotFunc = (copyParam & 0xFF00) >> 12; + int unk1 = copyParam & 0xFF; + + const uint8 *unkPtr1 = va_arg(args, const uint8*); + const uint8 *unkPtr2 = va_arg(args, const uint8*); + va_end(args); + + screen->copyWsaRect(_x, _y, _width, _height, 0, plotFunc, _offscreenBuffer, unk1, unkPtr1, unkPtr2); + + screen->_curPage = pageBackUp; + } + } +} + } // end of namespace Kyra diff --git a/engines/kyra/wsamovie.h b/engines/kyra/wsamovie.h index a3af9f16b7..0e93bd2a93 100644 --- a/engines/kyra/wsamovie.h +++ b/engines/kyra/wsamovie.h @@ -35,6 +35,7 @@ class SoundHandle; namespace Kyra { class KyraEngine; +class KyraEngine_v2; class Movie { public: @@ -48,7 +49,7 @@ public: virtual int frames() = 0; - virtual void displayFrame(int frameNum) = 0; + virtual void displayFrame(int frameNum, ...) = 0; virtual void setX(int x) { _x = x; } virtual void setY(int y) { _y = y; } @@ -71,7 +72,7 @@ public: virtual int frames() { return _opened ? _numFrames : -1; } - virtual void displayFrame(int frameNum); + virtual void displayFrame(int frameNum, ...); enum WSAFlags { WF_OFFSCREEN_DECODE = 0x10, @@ -101,7 +102,7 @@ public: int open(const char *filename, int offscreen, uint8 *palette); void close(); - void displayFrame(int frameNum); + void displayFrame(int frameNum, ...); private: void processFrame(int frameNum, uint8 *dst); @@ -110,9 +111,11 @@ private: class WSAMovieV2 : public WSAMovieV1 { public: - WSAMovieV2(KyraEngine *vm); + WSAMovieV2(KyraEngine_v2 *vm); int open(const char *filename, int unk1, uint8 *palette); + + virtual void displayFrame(int frameNum, ...); void setX(int x) { _x = x + _xAdd; } void setY(int y) { _y = y + _yAdd; } @@ -122,10 +125,15 @@ public: int width() const { return _width; } int height() const { return _height; } -protected: + // HACK for our intro code + void flagOldOff(bool enabled) { _oldOff = enabled; } +protected: + KyraEngine_v2 *_vm; + int16 _xAdd; int16 _yAdd; + bool _oldOff; // old offscreen copy, HACK for our intro code }; } // end of namespace Kyra -- cgit v1.2.3 From 5354f3b1d0a389e316437ca76193e7a5782465ae Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 29 Jul 2007 16:35:15 +0000 Subject: - fixes some warnings - enables Kyrandia 2 main menu again svn-id: r28298 --- engines/kyra/kyra_v2.cpp | 8 ++++---- engines/kyra/util.h | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/kyra/kyra_v2.cpp b/engines/kyra/kyra_v2.cpp index 7a9d631c25..3e08ea43c6 100644 --- a/engines/kyra/kyra_v2.cpp +++ b/engines/kyra/kyra_v2.cpp @@ -137,7 +137,7 @@ int KyraEngine_v2::go() { } void KyraEngine_v2::mainMenu() { - /*bool running = true; + bool running = true; while (running && !_quitFlag) { seq_playSequences(kSequenceTitle); @@ -145,11 +145,11 @@ void KyraEngine_v2::mainMenu() { switch (gui_handleMainMenu()) { case 0: - _screen->showMouse();*/ + _screen->showMouse(); startup(); runLoop(); cleanup(); - /*running = false; + running = false; break; case 1: seq_playSequences(kSequenceOverview, kSequenceZanFaun); @@ -163,7 +163,7 @@ void KyraEngine_v2::mainMenu() { break; } _screen->hideMouse(); - }*/ + } } void KyraEngine_v2::startup() { diff --git a/engines/kyra/util.h b/engines/kyra/util.h index edb2ca454a..98692df015 100644 --- a/engines/kyra/util.h +++ b/engines/kyra/util.h @@ -32,6 +32,8 @@ namespace Kyra { template struct Functor1 : public Common::UnaryFunction { + virtual ~Functor1() {} + virtual operator bool() const = 0; virtual Res operator()(Arg) const = 0; }; -- cgit v1.2.3 From 7e4909efad06c71447c2cb563f4ceb4db5143758 Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Sun, 29 Jul 2007 16:42:29 +0000 Subject: Moved all callable routines and related data into callables.cpp. svn-id: r28299 --- engines/parallaction/callables.cpp | 343 ++++++++++++++++++++++++++++++++++-- engines/parallaction/intro.cpp | 320 --------------------------------- engines/parallaction/module.mk | 1 - engines/parallaction/parallaction.h | 5 - engines/parallaction/staticres.cpp | 10 -- 5 files changed, 329 insertions(+), 350 deletions(-) delete mode 100644 engines/parallaction/intro.cpp (limited to 'engines') diff --git a/engines/parallaction/callables.cpp b/engines/parallaction/callables.cpp index d236766432..97c6b85453 100644 --- a/engines/parallaction/callables.cpp +++ b/engines/parallaction/callables.cpp @@ -29,6 +29,8 @@ #include "common/file.h" +#include "graphics/primitives.h" // for Graphics::drawLine + #include "parallaction/parallaction.h" #include "parallaction/menu.h" #include "parallaction/sound.h" @@ -36,12 +38,141 @@ namespace Parallaction { +/* + game callables data members +*/ +// there three guys are extern'd somewhere +Zone *_moveSarcZone0 = NULL; +int16 _introSarcData1 = 0; +Zone *_moveSarcZone1 = NULL; +// part completion messages +static const char *endMsg0[] = {"COMPLIMENTI!", "BRAVO!", "CONGRATULATIONS!", "PRIMA!"}; +static const char *endMsg1[] = {"HAI FINITO QUESTA PARTE", "TU AS COMPLETE' CETTE AVENTURE", "YOU HAVE COMPLETED THIS PART", "DU HAST EIN ABENTEUER ERFOLGREICH"}; +static const char *endMsg2[] = {"ORA COMPLETA IL RESTO ", "AVEC SUCCES.", "NOW GO ON WITH THE REST OF", "ZU ENDE GEFUHRT"}; +static const char *endMsg3[] = {"DELL' AVVENTURA", "CONTINUE AVEC LES AUTRES", "THIS ADVENTURE", "MACH' MIT DEN ANDEREN WEITER"}; +// game completion messages +static const char *endMsg4[] = {"COMPLIMENTI!", "BRAVO!", "CONGRATULATIONS!", "PRIMA!"}; +static const char *endMsg5[] = {"HAI FINITO LE TRE PARTI", "TU AS COMPLETE' LES TROIS PARTIES", "YOU HAVE COMPLETED THE THREE PARTS", "DU HAST DREI ABENTEURE ERFOLGREICH"}; +static const char *endMsg6[] = {"DELL' AVVENTURA", "DE L'AVENTURE", "OF THIS ADVENTURE", "ZU ENDE GEFUHRT"}; +static const char *endMsg7[] = {"ED ORA IL GRAN FINALE ", "ET MAINTENANT LE GRAND FINAL", "NOW THE GREAT FINAL", "UND YETZT DER GROSSE SCHLUSS!"}; +static uint16 num_foglie = 0; static Zone *_moveSarcZones[5]; static Zone *_moveSarcExaZones[5]; +/* + intro callables data members +*/ + +static Animation *_rightHandAnim; + +static uint16 _rightHandPositions[684] = { + 0x0064, 0x0046, 0x006c, 0x0046, 0x0074, 0x0046, 0x007c, 0x0046, + 0x0084, 0x0046, 0x008c, 0x0046, 0x0094, 0x0046, 0x009c, 0x0046, + 0x00a4, 0x0046, 0x00ac, 0x0046, 0x00b4, 0x0046, 0x00bc, 0x0046, + 0x00c4, 0x0046, 0x00cc, 0x0046, 0x00d4, 0x0046, 0x00dc, 0x0046, + 0x00e4, 0x0046, 0x00ec, 0x0046, 0x00f4, 0x0046, 0x00fc, 0x0046, + 0x0104, 0x0046, 0x00ff, 0x0042, 0x00ff, 0x004a, 0x00ff, 0x0052, + 0x00ff, 0x005a, 0x00ff, 0x0062, 0x00ff, 0x006a, 0x00ff, 0x0072, + 0x00ff, 0x007a, 0x00ff, 0x0082, 0x00ff, 0x008a, 0x00ff, 0x0092, + 0x00ff, 0x009a, 0x00ff, 0x00a2, 0x0104, 0x0097, 0x00fc, 0x0097, + 0x00f4, 0x0097, 0x00ec, 0x0097, 0x00e4, 0x0097, 0x00dc, 0x0097, + 0x00d4, 0x0097, 0x00cc, 0x0097, 0x00c4, 0x0097, 0x00bc, 0x0097, + 0x00b4, 0x0097, 0x00ac, 0x0097, 0x00a4, 0x0097, 0x009c, 0x0097, + 0x0094, 0x0097, 0x008c, 0x0097, 0x0084, 0x0097, 0x007c, 0x0097, + 0x0074, 0x0097, 0x006c, 0x0097, 0x0064, 0x0097, 0x0066, 0x0042, + 0x0066, 0x004a, 0x0066, 0x0052, 0x0066, 0x005a, 0x0066, 0x0062, + 0x0066, 0x006a, 0x0066, 0x0072, 0x0066, 0x007a, 0x0066, 0x0082, + 0x0066, 0x008a, 0x0066, 0x0092, 0x0066, 0x009a, 0x0066, 0x00a2, + 0x008c, 0x0091, 0x0099, 0x0042, 0x0099, 0x004a, 0x0099, 0x0052, + 0x0099, 0x005a, 0x0099, 0x0062, 0x0099, 0x006a, 0x0099, 0x0072, + 0x0099, 0x007a, 0x0099, 0x0082, 0x0099, 0x008a, 0x0099, 0x0092, + 0x0099, 0x009a, 0x0099, 0x00a2, 0x00a0, 0x004d, 0x00cc, 0x0042, + 0x00cc, 0x004a, 0x00cc, 0x0052, 0x00cc, 0x005a, 0x00cc, 0x0062, + 0x00cc, 0x006a, 0x00cc, 0x0072, 0x00cc, 0x007a, 0x00cc, 0x0082, + 0x00cc, 0x008a, 0x00cc, 0x0092, 0x00cc, 0x009a, 0x00cc, 0x00a2, + 0x00ca, 0x0050, 0x00b1, 0x0050, 0x0081, 0x0052, 0x007e, 0x0052, + 0x007c, 0x0055, 0x007c, 0x005c, 0x007e, 0x005e, 0x0080, 0x005e, + 0x0082, 0x005c, 0x0082, 0x0054, 0x0080, 0x0052, 0x0078, 0x0052, + 0x007c, 0x005e, 0x0077, 0x0061, 0x0074, 0x006e, 0x0074, 0x0078, + 0x0076, 0x007a, 0x0079, 0x0078, 0x0079, 0x0070, 0x0078, 0x0070, + 0x0078, 0x006b, 0x007b, 0x0066, 0x007a, 0x006f, 0x0084, 0x006f, + 0x0085, 0x0066, 0x0086, 0x0070, 0x0085, 0x0070, 0x0085, 0x0079, + 0x0088, 0x0079, 0x008a, 0x0078, 0x008a, 0x006c, 0x0087, 0x0061, + 0x0085, 0x005f, 0x0082, 0x005f, 0x0080, 0x0061, 0x007e, 0x0061, + 0x007b, 0x005f, 0x007c, 0x006f, 0x007c, 0x0071, 0x0079, 0x0074, + 0x0079, 0x0089, 0x0076, 0x008c, 0x0076, 0x008e, 0x007a, 0x008e, + 0x007f, 0x0089, 0x007f, 0x0083, 0x007e, 0x0083, 0x007e, 0x0077, + 0x0080, 0x0077, 0x0080, 0x0083, 0x0080, 0x008b, 0x0084, 0x0090, + 0x0088, 0x0090, 0x0088, 0x008e, 0x0085, 0x008b, 0x0085, 0x0074, + 0x0082, 0x0071, 0x00b2, 0x0052, 0x00b0, 0x0054, 0x00b0, 0x0056, + 0x00ae, 0x0058, 0x00af, 0x0059, 0x00af, 0x005e, 0x00b2, 0x0061, + 0x00b5, 0x0061, 0x00b8, 0x005e, 0x00b8, 0x005a, 0x00b9, 0x0059, + 0x00b9, 0x0058, 0x00b7, 0x0056, 0x00b7, 0x0054, 0x00b5, 0x0052, + 0x00b2, 0x0052, 0x00ae, 0x005a, 0x00ab, 0x005b, 0x00ab, 0x006d, + 0x00ae, 0x0072, 0x00b8, 0x0072, 0x00bc, 0x006d, 0x00bc, 0x005b, + 0x00b9, 0x005a, 0x00bc, 0x005c, 0x00be, 0x005c, 0x00c1, 0x005f, + 0x00c4, 0x0067, 0x00c4, 0x006d, 0x00c1, 0x0076, 0x00c0, 0x0077, + 0x00bd, 0x0077, 0x00bb, 0x0075, 0x00bd, 0x0073, 0x00bb, 0x0072, + 0x00be, 0x0070, 0x00be, 0x006a, 0x00a9, 0x006a, 0x00a9, 0x0070, + 0x00ac, 0x0072, 0x00aa, 0x0073, 0x00ac, 0x0075, 0x00aa, 0x0077, + 0x00a7, 0x0077, 0x00a3, 0x006d, 0x00a3, 0x0067, 0x00a6, 0x005f, + 0x00a9, 0x005c, 0x00ab, 0x005c, 0x00ac, 0x0077, 0x00ac, 0x007c, + 0x00ab, 0x007c, 0x00ab, 0x0084, 0x00ac, 0x0084, 0x00ac, 0x008b, + 0x00a9, 0x008e, 0x00a9, 0x0090, 0x00ae, 0x0090, 0x00ae, 0x008d, + 0x00b2, 0x008c, 0x00b2, 0x0087, 0x00b1, 0x0086, 0x00b1, 0x007b, + 0x00b2, 0x0079, 0x00b4, 0x0079, 0x00b4, 0x007d, 0x00b5, 0x007d, + 0x00b5, 0x0087, 0x00b4, 0x0087, 0x00b4, 0x008c, 0x00b6, 0x008c, + 0x00b9, 0x0091, 0x00b4, 0x0091, 0x00bd, 0x008f, 0x00ba, 0x008c, + 0x00ba, 0x0083, 0x00bb, 0x0082, 0x00bb, 0x0075, 0x00cc, 0x006e, + 0x00d4, 0x006c, 0x00db, 0x0069, 0x00d9, 0x0068, 0x00d9, 0x0064, + 0x00dc, 0x0064, 0x00dc, 0x0060, 0x00df, 0x0056, 0x00e5, 0x0052, + 0x00e7, 0x0052, 0x00ec, 0x0056, 0x00ef, 0x005d, 0x00f1, 0x0065, + 0x00f3, 0x0064, 0x00f3, 0x0069, 0x00f0, 0x0069, 0x00ec, 0x0065, + 0x00ec, 0x005e, 0x00e9, 0x005f, 0x00e9, 0x005a, 0x00e7, 0x0058, + 0x00e4, 0x0058, 0x00e3, 0x0054, 0x00e3, 0x0058, 0x00e1, 0x005c, + 0x00e4, 0x0061, 0x00e7, 0x0061, 0x00e9, 0x005f, 0x00eb, 0x005d, + 0x00e4, 0x0062, 0x00e0, 0x0064, 0x00e0, 0x0069, 0x00e2, 0x006b, + 0x00e0, 0x0072, 0x00e0, 0x0077, 0x00ec, 0x0077, 0x00ec, 0x0071, + 0x00ea, 0x006b, 0x00ec, 0x006a, 0x00ec, 0x0063, 0x00e7, 0x0063, + 0x00e7, 0x0065, 0x00e1, 0x0069, 0x00e3, 0x0068, 0x00e6, 0x0069, + 0x00ec, 0x005e, 0x00ea, 0x006b, 0x00e7, 0x006b, 0x00e7, 0x006a, + 0x00e5, 0x006a, 0x00e5, 0x006b, 0x00e2, 0x006b, 0x00df, 0x006c, + 0x00dc, 0x006f, 0x00dc, 0x0071, 0x00da, 0x0073, 0x00d8, 0x0073, + 0x00d8, 0x006f, 0x00dc, 0x006b, 0x00dc, 0x0069, 0x00dd, 0x0068, + 0x00ef, 0x0068, 0x00f0, 0x0069, 0x00f0, 0x006b, 0x00f4, 0x006f, + 0x00f4, 0x0072, 0x00f3, 0x0073, 0x00f2, 0x0073, 0x00f0, 0x0071, + 0x00f0, 0x006f, 0x00ec, 0x006b, 0x00ec, 0x007a, 0x00eb, 0x007b, + 0x00eb, 0x007f, 0x00ec, 0x0080, 0x00ec, 0x0084, 0x00eb, 0x0085, + 0x00eb, 0x008b, 0x00ec, 0x008c, 0x00ec, 0x008f, 0x00ed, 0x0091, + 0x00e9, 0x0091, 0x00e9, 0x008f, 0x00e7, 0x008d, 0x00e7, 0x0090, + 0x00e7, 0x0089, 0x00e8, 0x0088, 0x00e8, 0x0086, 0x00e7, 0x0085, + 0x00e7, 0x007d, 0x00e6, 0x007c, 0x00e6, 0x0078, 0x00e5, 0x007d, + 0x00e5, 0x0085, 0x00e4, 0x0086, 0x00e4, 0x0088, 0x00e5, 0x0089, + 0x00e5, 0x0090, 0x00e5, 0x008b, 0x00e3, 0x0091, 0x00df, 0x0091, + 0x00e0, 0x0090, 0x00e0, 0x008c, 0x00e2, 0x008b, 0x00e1, 0x0085, + 0x00e0, 0x0084, 0x00e0, 0x0080, 0x00e1, 0x007f, 0x00e1, 0x007c, + 0x00e0, 0x007b, 0x00e0, 0x0077 +}; + +struct Credit { + const char *_role; + const char *_name; +} _credits[] = { + {"Music and Sound Effects", "MARCO CAPRELLI"}, + {"PC Version", "RICCARDO BALLARINO"}, + {"Project Manager", "LOVRANO CANEPA"}, + {"Production", "BRUNO BOZ"}, + {"Special Thanks to", "LUIGI BENEDICENTI - GILDA and DANILO"}, + {"Copyright 1992 Euclidea s.r.l ITALY", "All rights reserved"} +}; + +/* + game callables +*/ + void _c_null(void *parm) { return; @@ -85,9 +216,7 @@ void _c_fade(void *parm) { return; } -Zone *_moveSarcZone0 = NULL; -int16 _introSarcData1 = 0; -Zone *_moveSarcZone1 = NULL; + void _c_moveSarc(void *parm) { @@ -164,7 +293,7 @@ void _c_moveSarc(void *parm) { } -static uint16 num_foglie = 0; + void _c_contaFoglie(void *parm) { @@ -331,16 +460,6 @@ void _c_frankenstein(void *parm) { return; } -// part completion messages -const char *endMsg0[] = {"COMPLIMENTI!", "BRAVO!", "CONGRATULATIONS!", "PRIMA!"}; -const char *endMsg1[] = {"HAI FINITO QUESTA PARTE", "TU AS COMPLETE' CETTE AVENTURE", "YOU HAVE COMPLETED THIS PART", "DU HAST EIN ABENTEUER ERFOLGREICH"}; -const char *endMsg2[] = {"ORA COMPLETA IL RESTO ", "AVEC SUCCES.", "NOW GO ON WITH THE REST OF", "ZU ENDE GEFUHRT"}; -const char *endMsg3[] = {"DELL' AVVENTURA", "CONTINUE AVEC LES AUTRES", "THIS ADVENTURE", "MACH' MIT DEN ANDEREN WEITER"}; -// game completion messages -const char *endMsg4[] = {"COMPLIMENTI!", "BRAVO!", "CONGRATULATIONS!", "PRIMA!"}; -const char *endMsg5[] = {"HAI FINITO LE TRE PARTI", "TU AS COMPLETE' LES TROIS PARTIES", "YOU HAVE COMPLETED THE THREE PARTS", "DU HAST DREI ABENTEURE ERFOLGREICH"}; -const char *endMsg6[] = {"DELL' AVVENTURA", "DE L'AVENTURE", "OF THIS ADVENTURE", "ZU ENDE GEFUHRT"}; -const char *endMsg7[] = {"ED ORA IL GRAN FINALE ", "ET MAINTENANT LE GRAND FINAL", "NOW THE GREAT FINAL", "UND YETZT DER GROSSE SCHLUSS!"}; void _c_finito(void *parm) { @@ -464,4 +583,200 @@ void _c_closeMusic(void*) { _vm->_soundMan->stopMusic(); } +/* + intro callables +*/ + +void _c_startIntro(void *parm) { + _rightHandAnim = _vm->findAnimation("righthand"); + + if (_vm->getPlatform() == Common::kPlatformPC) { + _vm->_soundMan->setMusicFile("intro"); + _vm->_soundMan->playMusic(); + } + + _engineFlags |= kEngineBlockInput; + + return; +} + +void _c_endIntro(void *parm) { + + _vm->_gfx->setFont(kFontMenu); + + debugC(1, kDebugLocation, "endIntro()"); + + for (uint16 _si = 0; _si < 6; _si++) { + _vm->_gfx->displayCenteredString(80, _credits[_si]._role); + _vm->_gfx->displayCenteredString(100, _credits[_si]._name); + + _vm->_gfx->updateScreen(); + + for (uint16 v2 = 0; v2 < 100; v2++) { + _mouseButtons = kMouseNone; + _vm->updateInput(); + if (_mouseButtons == kMouseLeftUp) + break; + + _vm->waitTime( 1 ); + } + + _vm->_gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront); + } + debugC(1, kDebugLocation, "endIntro(): done showing credits"); + + if ((_vm->getFeatures() & GF_DEMO) == 0) { + _vm->_gfx->displayCenteredString(80, "CLICK MOUSE BUTTON TO START"); + _vm->_gfx->updateScreen(); + + waitUntilLeftClick(); + + _engineFlags &= ~kEngineBlockInput; + _vm->_menu->selectCharacter(); + } else { + waitUntilLeftClick(); + } + + return; +} + +void _c_moveSheet(void *parm) { + + static uint16 x = 319; + + if (x > 66) + x -= 16; + + Common::Rect r; + + r.left = x; + r.top = 47; + r.right = (x + 32 > 319) ? 319 : (x + 32); + r.bottom = 199; + _vm->_gfx->floodFill(Gfx::kBitBack, r, 1); + _vm->_gfx->floodFill(Gfx::kBit2, r, 1); + + if (x >= 104) return; + + r.left = x+215; + r.top = 47; + r.right = (x + 247 > 319) ? 319 : (x + 247); + r.bottom = 199; + _vm->_gfx->floodFill(Gfx::kBitBack, r, 12); + _vm->_gfx->floodFill(Gfx::kBit2, r, 12); + + return; +} + +void plotPixel(int x, int y, int color, void *data) { + _vm->_gfx->plotMaskPixel(x, y, color); +} + +void _c_sketch(void *parm) { + + static uint16 index = 1; + + uint16 newy = _rightHandPositions[2*index+1]; + uint16 newx = _rightHandPositions[2*index]; + + uint16 oldy = _rightHandPositions[2*(index-1)+1]; + uint16 oldx = _rightHandPositions[2*(index-1)]; + + Graphics::drawLine(oldx, oldy, newx, newy, 0, plotPixel, NULL); + + _rightHandAnim->_left = newx; + _rightHandAnim->_top = newy - 20; + + index++; + + return; +} + + + + +void _c_shade(void *parm) { + + Common::Rect r( + _rightHandAnim->_left - 36, + _rightHandAnim->_top - 36, + _rightHandAnim->_left, + _rightHandAnim->_top + ); + + _vm->_gfx->fillMaskRect(r, 0); + + return; + +} + +void _c_projector(void*) { +#ifdef HALFBRITE + static int dword_16032 = 0; + +// Bitmap bm; +// InitBitMap(&bm); + + if (dword_16032 != 0) { +/* // keep drawing spotlight in its final place + _vm->_gfx->flatBlitCnv(&scnv, 110, 25, Gfx::kBitFront); + BltBitMap(&bm, 0, 0, &_screen._bitMap, 110, 25, a3->??, a3->??, 0x20, 0x20); +*/ return; + } + + _vm->_gfx->setHalfbriteMode(true); +/* + // move spot light around the stage + int d7, d6; + for (d7 = 0; d7 < 150; d7++) { + + if (d7 < 100) { + int d1 = d7; + if (d1 < 0) + d1++; + + d1 >>= 1; + d6 = 50 - d1; + } else { + int d1 = d7 / 100; + if (d1 < 0) + d1++; + + d1 >>= 1; + d6 = d1; + } + + BltBitMap(&bm, 0, 0, &_screen._bitMap, d7+20, d6, a3->??, a3->??, 0x20, 0x20); + sub_1590C(d6 + a3->??); + BltBitMap(&bm, 0, 0, &_screen._bitMap, d7+20, d6, a3->??, a3->??, 0xFA, 0x20); + } + + for (d7 = 50; d7 > -10; d7--) { + BltBitMap(&bm, 0, 0, &_screen._bitMap, d7+120, d6, a3->??, a3->??, 0x20, 0x20); + sub_1590C(d6 + a3->??); + BltBitMap(&bm, 0, 0, &_screen._bitMap, d7+120, d6, a3->??, a3->??, 0xFA, 0x20); + } + + BltBitMap(&bm, 0, 0, &_screen._bitMap, d7+120, d6, a3->??, a3->??, 0x20, 0x20); + _vm->_gfx->flatBlitCnv(&scnv, d7+120, d6, Gfx::kBitFront); +*/ + + dword_16032 = 1; + return; +#endif +} + +void _c_HBOff(void*) { +#ifdef HALFBRITE + _vm->_gfx->setHalfbriteMode(false); +#endif +} + +void _c_HBOn(void*) { +#ifdef HALFBRITE + _vm->_gfx->setHalfbriteMode(true); +#endif +} + + } // namespace Parallaction diff --git a/engines/parallaction/intro.cpp b/engines/parallaction/intro.cpp deleted file mode 100644 index 96a072b28d..0000000000 --- a/engines/parallaction/intro.cpp +++ /dev/null @@ -1,320 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -#include "common/stdafx.h" - -#include "parallaction/parallaction.h" -#include "parallaction/menu.h" -#include "parallaction/sound.h" - -#include "graphics/primitives.h" - -namespace Parallaction { - -static Animation *_rightHandAnim; - -static uint16 _rightHandPositions[684] = { - 0x0064, 0x0046, 0x006c, 0x0046, 0x0074, 0x0046, 0x007c, 0x0046, - 0x0084, 0x0046, 0x008c, 0x0046, 0x0094, 0x0046, 0x009c, 0x0046, - 0x00a4, 0x0046, 0x00ac, 0x0046, 0x00b4, 0x0046, 0x00bc, 0x0046, - 0x00c4, 0x0046, 0x00cc, 0x0046, 0x00d4, 0x0046, 0x00dc, 0x0046, - 0x00e4, 0x0046, 0x00ec, 0x0046, 0x00f4, 0x0046, 0x00fc, 0x0046, - 0x0104, 0x0046, 0x00ff, 0x0042, 0x00ff, 0x004a, 0x00ff, 0x0052, - 0x00ff, 0x005a, 0x00ff, 0x0062, 0x00ff, 0x006a, 0x00ff, 0x0072, - 0x00ff, 0x007a, 0x00ff, 0x0082, 0x00ff, 0x008a, 0x00ff, 0x0092, - 0x00ff, 0x009a, 0x00ff, 0x00a2, 0x0104, 0x0097, 0x00fc, 0x0097, - 0x00f4, 0x0097, 0x00ec, 0x0097, 0x00e4, 0x0097, 0x00dc, 0x0097, - 0x00d4, 0x0097, 0x00cc, 0x0097, 0x00c4, 0x0097, 0x00bc, 0x0097, - 0x00b4, 0x0097, 0x00ac, 0x0097, 0x00a4, 0x0097, 0x009c, 0x0097, - 0x0094, 0x0097, 0x008c, 0x0097, 0x0084, 0x0097, 0x007c, 0x0097, - 0x0074, 0x0097, 0x006c, 0x0097, 0x0064, 0x0097, 0x0066, 0x0042, - 0x0066, 0x004a, 0x0066, 0x0052, 0x0066, 0x005a, 0x0066, 0x0062, - 0x0066, 0x006a, 0x0066, 0x0072, 0x0066, 0x007a, 0x0066, 0x0082, - 0x0066, 0x008a, 0x0066, 0x0092, 0x0066, 0x009a, 0x0066, 0x00a2, - 0x008c, 0x0091, 0x0099, 0x0042, 0x0099, 0x004a, 0x0099, 0x0052, - 0x0099, 0x005a, 0x0099, 0x0062, 0x0099, 0x006a, 0x0099, 0x0072, - 0x0099, 0x007a, 0x0099, 0x0082, 0x0099, 0x008a, 0x0099, 0x0092, - 0x0099, 0x009a, 0x0099, 0x00a2, 0x00a0, 0x004d, 0x00cc, 0x0042, - 0x00cc, 0x004a, 0x00cc, 0x0052, 0x00cc, 0x005a, 0x00cc, 0x0062, - 0x00cc, 0x006a, 0x00cc, 0x0072, 0x00cc, 0x007a, 0x00cc, 0x0082, - 0x00cc, 0x008a, 0x00cc, 0x0092, 0x00cc, 0x009a, 0x00cc, 0x00a2, - 0x00ca, 0x0050, 0x00b1, 0x0050, 0x0081, 0x0052, 0x007e, 0x0052, - 0x007c, 0x0055, 0x007c, 0x005c, 0x007e, 0x005e, 0x0080, 0x005e, - 0x0082, 0x005c, 0x0082, 0x0054, 0x0080, 0x0052, 0x0078, 0x0052, - 0x007c, 0x005e, 0x0077, 0x0061, 0x0074, 0x006e, 0x0074, 0x0078, - 0x0076, 0x007a, 0x0079, 0x0078, 0x0079, 0x0070, 0x0078, 0x0070, - 0x0078, 0x006b, 0x007b, 0x0066, 0x007a, 0x006f, 0x0084, 0x006f, - 0x0085, 0x0066, 0x0086, 0x0070, 0x0085, 0x0070, 0x0085, 0x0079, - 0x0088, 0x0079, 0x008a, 0x0078, 0x008a, 0x006c, 0x0087, 0x0061, - 0x0085, 0x005f, 0x0082, 0x005f, 0x0080, 0x0061, 0x007e, 0x0061, - 0x007b, 0x005f, 0x007c, 0x006f, 0x007c, 0x0071, 0x0079, 0x0074, - 0x0079, 0x0089, 0x0076, 0x008c, 0x0076, 0x008e, 0x007a, 0x008e, - 0x007f, 0x0089, 0x007f, 0x0083, 0x007e, 0x0083, 0x007e, 0x0077, - 0x0080, 0x0077, 0x0080, 0x0083, 0x0080, 0x008b, 0x0084, 0x0090, - 0x0088, 0x0090, 0x0088, 0x008e, 0x0085, 0x008b, 0x0085, 0x0074, - 0x0082, 0x0071, 0x00b2, 0x0052, 0x00b0, 0x0054, 0x00b0, 0x0056, - 0x00ae, 0x0058, 0x00af, 0x0059, 0x00af, 0x005e, 0x00b2, 0x0061, - 0x00b5, 0x0061, 0x00b8, 0x005e, 0x00b8, 0x005a, 0x00b9, 0x0059, - 0x00b9, 0x0058, 0x00b7, 0x0056, 0x00b7, 0x0054, 0x00b5, 0x0052, - 0x00b2, 0x0052, 0x00ae, 0x005a, 0x00ab, 0x005b, 0x00ab, 0x006d, - 0x00ae, 0x0072, 0x00b8, 0x0072, 0x00bc, 0x006d, 0x00bc, 0x005b, - 0x00b9, 0x005a, 0x00bc, 0x005c, 0x00be, 0x005c, 0x00c1, 0x005f, - 0x00c4, 0x0067, 0x00c4, 0x006d, 0x00c1, 0x0076, 0x00c0, 0x0077, - 0x00bd, 0x0077, 0x00bb, 0x0075, 0x00bd, 0x0073, 0x00bb, 0x0072, - 0x00be, 0x0070, 0x00be, 0x006a, 0x00a9, 0x006a, 0x00a9, 0x0070, - 0x00ac, 0x0072, 0x00aa, 0x0073, 0x00ac, 0x0075, 0x00aa, 0x0077, - 0x00a7, 0x0077, 0x00a3, 0x006d, 0x00a3, 0x0067, 0x00a6, 0x005f, - 0x00a9, 0x005c, 0x00ab, 0x005c, 0x00ac, 0x0077, 0x00ac, 0x007c, - 0x00ab, 0x007c, 0x00ab, 0x0084, 0x00ac, 0x0084, 0x00ac, 0x008b, - 0x00a9, 0x008e, 0x00a9, 0x0090, 0x00ae, 0x0090, 0x00ae, 0x008d, - 0x00b2, 0x008c, 0x00b2, 0x0087, 0x00b1, 0x0086, 0x00b1, 0x007b, - 0x00b2, 0x0079, 0x00b4, 0x0079, 0x00b4, 0x007d, 0x00b5, 0x007d, - 0x00b5, 0x0087, 0x00b4, 0x0087, 0x00b4, 0x008c, 0x00b6, 0x008c, - 0x00b9, 0x0091, 0x00b4, 0x0091, 0x00bd, 0x008f, 0x00ba, 0x008c, - 0x00ba, 0x0083, 0x00bb, 0x0082, 0x00bb, 0x0075, 0x00cc, 0x006e, - 0x00d4, 0x006c, 0x00db, 0x0069, 0x00d9, 0x0068, 0x00d9, 0x0064, - 0x00dc, 0x0064, 0x00dc, 0x0060, 0x00df, 0x0056, 0x00e5, 0x0052, - 0x00e7, 0x0052, 0x00ec, 0x0056, 0x00ef, 0x005d, 0x00f1, 0x0065, - 0x00f3, 0x0064, 0x00f3, 0x0069, 0x00f0, 0x0069, 0x00ec, 0x0065, - 0x00ec, 0x005e, 0x00e9, 0x005f, 0x00e9, 0x005a, 0x00e7, 0x0058, - 0x00e4, 0x0058, 0x00e3, 0x0054, 0x00e3, 0x0058, 0x00e1, 0x005c, - 0x00e4, 0x0061, 0x00e7, 0x0061, 0x00e9, 0x005f, 0x00eb, 0x005d, - 0x00e4, 0x0062, 0x00e0, 0x0064, 0x00e0, 0x0069, 0x00e2, 0x006b, - 0x00e0, 0x0072, 0x00e0, 0x0077, 0x00ec, 0x0077, 0x00ec, 0x0071, - 0x00ea, 0x006b, 0x00ec, 0x006a, 0x00ec, 0x0063, 0x00e7, 0x0063, - 0x00e7, 0x0065, 0x00e1, 0x0069, 0x00e3, 0x0068, 0x00e6, 0x0069, - 0x00ec, 0x005e, 0x00ea, 0x006b, 0x00e7, 0x006b, 0x00e7, 0x006a, - 0x00e5, 0x006a, 0x00e5, 0x006b, 0x00e2, 0x006b, 0x00df, 0x006c, - 0x00dc, 0x006f, 0x00dc, 0x0071, 0x00da, 0x0073, 0x00d8, 0x0073, - 0x00d8, 0x006f, 0x00dc, 0x006b, 0x00dc, 0x0069, 0x00dd, 0x0068, - 0x00ef, 0x0068, 0x00f0, 0x0069, 0x00f0, 0x006b, 0x00f4, 0x006f, - 0x00f4, 0x0072, 0x00f3, 0x0073, 0x00f2, 0x0073, 0x00f0, 0x0071, - 0x00f0, 0x006f, 0x00ec, 0x006b, 0x00ec, 0x007a, 0x00eb, 0x007b, - 0x00eb, 0x007f, 0x00ec, 0x0080, 0x00ec, 0x0084, 0x00eb, 0x0085, - 0x00eb, 0x008b, 0x00ec, 0x008c, 0x00ec, 0x008f, 0x00ed, 0x0091, - 0x00e9, 0x0091, 0x00e9, 0x008f, 0x00e7, 0x008d, 0x00e7, 0x0090, - 0x00e7, 0x0089, 0x00e8, 0x0088, 0x00e8, 0x0086, 0x00e7, 0x0085, - 0x00e7, 0x007d, 0x00e6, 0x007c, 0x00e6, 0x0078, 0x00e5, 0x007d, - 0x00e5, 0x0085, 0x00e4, 0x0086, 0x00e4, 0x0088, 0x00e5, 0x0089, - 0x00e5, 0x0090, 0x00e5, 0x008b, 0x00e3, 0x0091, 0x00df, 0x0091, - 0x00e0, 0x0090, 0x00e0, 0x008c, 0x00e2, 0x008b, 0x00e1, 0x0085, - 0x00e0, 0x0084, 0x00e0, 0x0080, 0x00e1, 0x007f, 0x00e1, 0x007c, - 0x00e0, 0x007b, 0x00e0, 0x0077 -}; - -extern Credit _credits[]; - -void _c_startIntro(void *parm) { - _rightHandAnim = _vm->findAnimation("righthand"); - - if (_vm->getPlatform() == Common::kPlatformPC) { - _vm->_soundMan->setMusicFile("intro"); - _vm->_soundMan->playMusic(); - } - - _engineFlags |= kEngineBlockInput; - - return; -} - -void _c_endIntro(void *parm) { - - _vm->_gfx->setFont(kFontMenu); - - debugC(1, kDebugLocation, "endIntro()"); - - for (uint16 _si = 0; _si < 6; _si++) { - _vm->_gfx->displayCenteredString(80, _credits[_si]._role); - _vm->_gfx->displayCenteredString(100, _credits[_si]._name); - - _vm->_gfx->updateScreen(); - - for (uint16 v2 = 0; v2 < 100; v2++) { - _mouseButtons = kMouseNone; - _vm->updateInput(); - if (_mouseButtons == kMouseLeftUp) - break; - - _vm->waitTime( 1 ); - } - - _vm->_gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront); - } - debugC(1, kDebugLocation, "endIntro(): done showing credits"); - - if ((_vm->getFeatures() & GF_DEMO) == 0) { - _vm->_gfx->displayCenteredString(80, "CLICK MOUSE BUTTON TO START"); - _vm->_gfx->updateScreen(); - - waitUntilLeftClick(); - - _engineFlags &= ~kEngineBlockInput; - _vm->_menu->selectCharacter(); - } else { - waitUntilLeftClick(); - } - - return; -} - -void _c_moveSheet(void *parm) { - - static uint16 x = 319; - - if (x > 66) - x -= 16; - - Common::Rect r; - - r.left = x; - r.top = 47; - r.right = (x + 32 > 319) ? 319 : (x + 32); - r.bottom = 199; - _vm->_gfx->floodFill(Gfx::kBitBack, r, 1); - _vm->_gfx->floodFill(Gfx::kBit2, r, 1); - - if (x >= 104) return; - - r.left = x+215; - r.top = 47; - r.right = (x + 247 > 319) ? 319 : (x + 247); - r.bottom = 199; - _vm->_gfx->floodFill(Gfx::kBitBack, r, 12); - _vm->_gfx->floodFill(Gfx::kBit2, r, 12); - - return; -} - -void plotPixel(int x, int y, int color, void *data) { - _vm->_gfx->plotMaskPixel(x, y, color); -} - -void _c_sketch(void *parm) { - - static uint16 index = 1; - - uint16 newy = _rightHandPositions[2*index+1]; - uint16 newx = _rightHandPositions[2*index]; - - uint16 oldy = _rightHandPositions[2*(index-1)+1]; - uint16 oldx = _rightHandPositions[2*(index-1)]; - - Graphics::drawLine(oldx, oldy, newx, newy, 0, plotPixel, NULL); - - _rightHandAnim->_left = newx; - _rightHandAnim->_top = newy - 20; - - index++; - - return; -} - - - - -void _c_shade(void *parm) { - - Common::Rect r( - _rightHandAnim->_left - 36, - _rightHandAnim->_top - 36, - _rightHandAnim->_left, - _rightHandAnim->_top - ); - - _vm->_gfx->fillMaskRect(r, 0); - - return; - -} - -void _c_projector(void*) { -#ifdef HALFBRITE - static int dword_16032 = 0; - -// Bitmap bm; -// InitBitMap(&bm); - - if (dword_16032 != 0) { -/* // keep drawing spotlight in its final place - _vm->_gfx->flatBlitCnv(&scnv, 110, 25, Gfx::kBitFront); - BltBitMap(&bm, 0, 0, &_screen._bitMap, 110, 25, a3->??, a3->??, 0x20, 0x20); -*/ return; - } - - _vm->_gfx->setHalfbriteMode(true); -/* - // move spot light around the stage - int d7, d6; - for (d7 = 0; d7 < 150; d7++) { - - if (d7 < 100) { - int d1 = d7; - if (d1 < 0) - d1++; - - d1 >>= 1; - d6 = 50 - d1; - } else { - int d1 = d7 / 100; - if (d1 < 0) - d1++; - - d1 >>= 1; - d6 = d1; - } - - BltBitMap(&bm, 0, 0, &_screen._bitMap, d7+20, d6, a3->??, a3->??, 0x20, 0x20); - sub_1590C(d6 + a3->??); - BltBitMap(&bm, 0, 0, &_screen._bitMap, d7+20, d6, a3->??, a3->??, 0xFA, 0x20); - } - - for (d7 = 50; d7 > -10; d7--) { - BltBitMap(&bm, 0, 0, &_screen._bitMap, d7+120, d6, a3->??, a3->??, 0x20, 0x20); - sub_1590C(d6 + a3->??); - BltBitMap(&bm, 0, 0, &_screen._bitMap, d7+120, d6, a3->??, a3->??, 0xFA, 0x20); - } - - BltBitMap(&bm, 0, 0, &_screen._bitMap, d7+120, d6, a3->??, a3->??, 0x20, 0x20); - _vm->_gfx->flatBlitCnv(&scnv, d7+120, d6, Gfx::kBitFront); -*/ - - dword_16032 = 1; - return; -#endif -} - -void _c_HBOff(void*) { -#ifdef HALFBRITE - _vm->_gfx->setHalfbriteMode(false); -#endif -} - -void _c_HBOn(void*) { -#ifdef HALFBRITE - _vm->_gfx->setHalfbriteMode(true); -#endif -} - -} // namespace Parallaction diff --git a/engines/parallaction/module.mk b/engines/parallaction/module.mk index afe4bd0ac3..052ab64aff 100644 --- a/engines/parallaction/module.mk +++ b/engines/parallaction/module.mk @@ -11,7 +11,6 @@ MODULE_OBJS := \ disk_ns.o \ font.o \ graphics.o \ - intro.o \ inventory.o \ location.o \ menu.o \ diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h index eabdf33282..1bc1cc63bd 100644 --- a/engines/parallaction/parallaction.h +++ b/engines/parallaction/parallaction.h @@ -160,11 +160,6 @@ public: typedef Job* JobPointer; typedef ManagedList JobList; -struct Credit { - const char *_role; - const char *_name; -}; - typedef void (*callable)(void*); extern uint16 _mouseButtons; diff --git a/engines/parallaction/staticres.cpp b/engines/parallaction/staticres.cpp index 30d2b0c95a..534228d122 100644 --- a/engines/parallaction/staticres.cpp +++ b/engines/parallaction/staticres.cpp @@ -506,16 +506,6 @@ void _c_HBOn(void*); callable _callables[25]; - -Credit _credits[] = { - {"Music and Sound Effects", "MARCO CAPRELLI"}, - {"PC Version", "RICCARDO BALLARINO"}, - {"Project Manager", "LOVRANO CANEPA"}, - {"Production", "BRUNO BOZ"}, - {"Special Thanks to", "LUIGI BENEDICENTI - GILDA and DANILO"}, - {"Copyright 1992 Euclidea s.r.l ITALY", "All rights reserved"} -}; - const char *_dinoName = "dino"; const char *_donnaName = "donna"; const char *_doughName = "dough"; -- cgit v1.2.3 From 9df68f57b0beac1272e054f979f70deede97d22f Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Sun, 29 Jul 2007 16:56:06 +0000 Subject: Fixed mismatched table name in initialization. svn-id: r28300 --- engines/parallaction/staticres.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/parallaction/staticres.cpp b/engines/parallaction/staticres.cpp index 534228d122..567b43785a 100644 --- a/engines/parallaction/staticres.cpp +++ b/engines/parallaction/staticres.cpp @@ -525,7 +525,7 @@ void Parallaction_ns::initResources() { _callableNamesRes = _callableNamesRes_ns; _instructionNamesRes = _instructionNamesRes_ns; - _callableNames = new Table(ARRAYSIZE(_zoneFlagNamesRes_ns), _zoneFlagNamesRes_ns); + _callableNames = new Table(ARRAYSIZE(_callableNamesRes_ns), _callableNamesRes_ns); _instructionNames = new Table(ARRAYSIZE(_instructionNamesRes_ns), _instructionNamesRes_ns); _zoneFlagNames = new Table(ARRAYSIZE(_zoneFlagNamesRes_ns), _zoneFlagNamesRes_ns); _zoneTypeNames = new Table(ARRAYSIZE(_zoneTypeNamesRes_ns), _zoneTypeNamesRes_ns); -- cgit v1.2.3 From 4774696a9620cb0c325b7ceb82d85c77ea5363f1 Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Sun, 29 Jul 2007 17:02:08 +0000 Subject: Made current callable routines members of Parallaction_ns, and moved them to callables_ns.cpp. svn-id: r28302 --- engines/parallaction/callables.cpp | 782 ------------------------------- engines/parallaction/callables_ns.cpp | 782 +++++++++++++++++++++++++++++++ engines/parallaction/module.mk | 2 +- engines/parallaction/parallaction.h | 36 ++ engines/parallaction/parallaction_ns.cpp | 3 +- engines/parallaction/staticres.cpp | 135 ++---- 6 files changed, 872 insertions(+), 868 deletions(-) delete mode 100644 engines/parallaction/callables.cpp create mode 100644 engines/parallaction/callables_ns.cpp (limited to 'engines') diff --git a/engines/parallaction/callables.cpp b/engines/parallaction/callables.cpp deleted file mode 100644 index 97c6b85453..0000000000 --- a/engines/parallaction/callables.cpp +++ /dev/null @@ -1,782 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - - -#include "common/stdafx.h" -#include "common/system.h" - -#include "common/file.h" - -#include "graphics/primitives.h" // for Graphics::drawLine - -#include "parallaction/parallaction.h" -#include "parallaction/menu.h" -#include "parallaction/sound.h" - - -namespace Parallaction { - -/* - game callables data members -*/ - -// there three guys are extern'd somewhere -Zone *_moveSarcZone0 = NULL; -int16 _introSarcData1 = 0; -Zone *_moveSarcZone1 = NULL; - -// part completion messages -static const char *endMsg0[] = {"COMPLIMENTI!", "BRAVO!", "CONGRATULATIONS!", "PRIMA!"}; -static const char *endMsg1[] = {"HAI FINITO QUESTA PARTE", "TU AS COMPLETE' CETTE AVENTURE", "YOU HAVE COMPLETED THIS PART", "DU HAST EIN ABENTEUER ERFOLGREICH"}; -static const char *endMsg2[] = {"ORA COMPLETA IL RESTO ", "AVEC SUCCES.", "NOW GO ON WITH THE REST OF", "ZU ENDE GEFUHRT"}; -static const char *endMsg3[] = {"DELL' AVVENTURA", "CONTINUE AVEC LES AUTRES", "THIS ADVENTURE", "MACH' MIT DEN ANDEREN WEITER"}; -// game completion messages -static const char *endMsg4[] = {"COMPLIMENTI!", "BRAVO!", "CONGRATULATIONS!", "PRIMA!"}; -static const char *endMsg5[] = {"HAI FINITO LE TRE PARTI", "TU AS COMPLETE' LES TROIS PARTIES", "YOU HAVE COMPLETED THE THREE PARTS", "DU HAST DREI ABENTEURE ERFOLGREICH"}; -static const char *endMsg6[] = {"DELL' AVVENTURA", "DE L'AVENTURE", "OF THIS ADVENTURE", "ZU ENDE GEFUHRT"}; -static const char *endMsg7[] = {"ED ORA IL GRAN FINALE ", "ET MAINTENANT LE GRAND FINAL", "NOW THE GREAT FINAL", "UND YETZT DER GROSSE SCHLUSS!"}; - -static uint16 num_foglie = 0; -static Zone *_moveSarcZones[5]; -static Zone *_moveSarcExaZones[5]; - -/* - intro callables data members -*/ - -static Animation *_rightHandAnim; - -static uint16 _rightHandPositions[684] = { - 0x0064, 0x0046, 0x006c, 0x0046, 0x0074, 0x0046, 0x007c, 0x0046, - 0x0084, 0x0046, 0x008c, 0x0046, 0x0094, 0x0046, 0x009c, 0x0046, - 0x00a4, 0x0046, 0x00ac, 0x0046, 0x00b4, 0x0046, 0x00bc, 0x0046, - 0x00c4, 0x0046, 0x00cc, 0x0046, 0x00d4, 0x0046, 0x00dc, 0x0046, - 0x00e4, 0x0046, 0x00ec, 0x0046, 0x00f4, 0x0046, 0x00fc, 0x0046, - 0x0104, 0x0046, 0x00ff, 0x0042, 0x00ff, 0x004a, 0x00ff, 0x0052, - 0x00ff, 0x005a, 0x00ff, 0x0062, 0x00ff, 0x006a, 0x00ff, 0x0072, - 0x00ff, 0x007a, 0x00ff, 0x0082, 0x00ff, 0x008a, 0x00ff, 0x0092, - 0x00ff, 0x009a, 0x00ff, 0x00a2, 0x0104, 0x0097, 0x00fc, 0x0097, - 0x00f4, 0x0097, 0x00ec, 0x0097, 0x00e4, 0x0097, 0x00dc, 0x0097, - 0x00d4, 0x0097, 0x00cc, 0x0097, 0x00c4, 0x0097, 0x00bc, 0x0097, - 0x00b4, 0x0097, 0x00ac, 0x0097, 0x00a4, 0x0097, 0x009c, 0x0097, - 0x0094, 0x0097, 0x008c, 0x0097, 0x0084, 0x0097, 0x007c, 0x0097, - 0x0074, 0x0097, 0x006c, 0x0097, 0x0064, 0x0097, 0x0066, 0x0042, - 0x0066, 0x004a, 0x0066, 0x0052, 0x0066, 0x005a, 0x0066, 0x0062, - 0x0066, 0x006a, 0x0066, 0x0072, 0x0066, 0x007a, 0x0066, 0x0082, - 0x0066, 0x008a, 0x0066, 0x0092, 0x0066, 0x009a, 0x0066, 0x00a2, - 0x008c, 0x0091, 0x0099, 0x0042, 0x0099, 0x004a, 0x0099, 0x0052, - 0x0099, 0x005a, 0x0099, 0x0062, 0x0099, 0x006a, 0x0099, 0x0072, - 0x0099, 0x007a, 0x0099, 0x0082, 0x0099, 0x008a, 0x0099, 0x0092, - 0x0099, 0x009a, 0x0099, 0x00a2, 0x00a0, 0x004d, 0x00cc, 0x0042, - 0x00cc, 0x004a, 0x00cc, 0x0052, 0x00cc, 0x005a, 0x00cc, 0x0062, - 0x00cc, 0x006a, 0x00cc, 0x0072, 0x00cc, 0x007a, 0x00cc, 0x0082, - 0x00cc, 0x008a, 0x00cc, 0x0092, 0x00cc, 0x009a, 0x00cc, 0x00a2, - 0x00ca, 0x0050, 0x00b1, 0x0050, 0x0081, 0x0052, 0x007e, 0x0052, - 0x007c, 0x0055, 0x007c, 0x005c, 0x007e, 0x005e, 0x0080, 0x005e, - 0x0082, 0x005c, 0x0082, 0x0054, 0x0080, 0x0052, 0x0078, 0x0052, - 0x007c, 0x005e, 0x0077, 0x0061, 0x0074, 0x006e, 0x0074, 0x0078, - 0x0076, 0x007a, 0x0079, 0x0078, 0x0079, 0x0070, 0x0078, 0x0070, - 0x0078, 0x006b, 0x007b, 0x0066, 0x007a, 0x006f, 0x0084, 0x006f, - 0x0085, 0x0066, 0x0086, 0x0070, 0x0085, 0x0070, 0x0085, 0x0079, - 0x0088, 0x0079, 0x008a, 0x0078, 0x008a, 0x006c, 0x0087, 0x0061, - 0x0085, 0x005f, 0x0082, 0x005f, 0x0080, 0x0061, 0x007e, 0x0061, - 0x007b, 0x005f, 0x007c, 0x006f, 0x007c, 0x0071, 0x0079, 0x0074, - 0x0079, 0x0089, 0x0076, 0x008c, 0x0076, 0x008e, 0x007a, 0x008e, - 0x007f, 0x0089, 0x007f, 0x0083, 0x007e, 0x0083, 0x007e, 0x0077, - 0x0080, 0x0077, 0x0080, 0x0083, 0x0080, 0x008b, 0x0084, 0x0090, - 0x0088, 0x0090, 0x0088, 0x008e, 0x0085, 0x008b, 0x0085, 0x0074, - 0x0082, 0x0071, 0x00b2, 0x0052, 0x00b0, 0x0054, 0x00b0, 0x0056, - 0x00ae, 0x0058, 0x00af, 0x0059, 0x00af, 0x005e, 0x00b2, 0x0061, - 0x00b5, 0x0061, 0x00b8, 0x005e, 0x00b8, 0x005a, 0x00b9, 0x0059, - 0x00b9, 0x0058, 0x00b7, 0x0056, 0x00b7, 0x0054, 0x00b5, 0x0052, - 0x00b2, 0x0052, 0x00ae, 0x005a, 0x00ab, 0x005b, 0x00ab, 0x006d, - 0x00ae, 0x0072, 0x00b8, 0x0072, 0x00bc, 0x006d, 0x00bc, 0x005b, - 0x00b9, 0x005a, 0x00bc, 0x005c, 0x00be, 0x005c, 0x00c1, 0x005f, - 0x00c4, 0x0067, 0x00c4, 0x006d, 0x00c1, 0x0076, 0x00c0, 0x0077, - 0x00bd, 0x0077, 0x00bb, 0x0075, 0x00bd, 0x0073, 0x00bb, 0x0072, - 0x00be, 0x0070, 0x00be, 0x006a, 0x00a9, 0x006a, 0x00a9, 0x0070, - 0x00ac, 0x0072, 0x00aa, 0x0073, 0x00ac, 0x0075, 0x00aa, 0x0077, - 0x00a7, 0x0077, 0x00a3, 0x006d, 0x00a3, 0x0067, 0x00a6, 0x005f, - 0x00a9, 0x005c, 0x00ab, 0x005c, 0x00ac, 0x0077, 0x00ac, 0x007c, - 0x00ab, 0x007c, 0x00ab, 0x0084, 0x00ac, 0x0084, 0x00ac, 0x008b, - 0x00a9, 0x008e, 0x00a9, 0x0090, 0x00ae, 0x0090, 0x00ae, 0x008d, - 0x00b2, 0x008c, 0x00b2, 0x0087, 0x00b1, 0x0086, 0x00b1, 0x007b, - 0x00b2, 0x0079, 0x00b4, 0x0079, 0x00b4, 0x007d, 0x00b5, 0x007d, - 0x00b5, 0x0087, 0x00b4, 0x0087, 0x00b4, 0x008c, 0x00b6, 0x008c, - 0x00b9, 0x0091, 0x00b4, 0x0091, 0x00bd, 0x008f, 0x00ba, 0x008c, - 0x00ba, 0x0083, 0x00bb, 0x0082, 0x00bb, 0x0075, 0x00cc, 0x006e, - 0x00d4, 0x006c, 0x00db, 0x0069, 0x00d9, 0x0068, 0x00d9, 0x0064, - 0x00dc, 0x0064, 0x00dc, 0x0060, 0x00df, 0x0056, 0x00e5, 0x0052, - 0x00e7, 0x0052, 0x00ec, 0x0056, 0x00ef, 0x005d, 0x00f1, 0x0065, - 0x00f3, 0x0064, 0x00f3, 0x0069, 0x00f0, 0x0069, 0x00ec, 0x0065, - 0x00ec, 0x005e, 0x00e9, 0x005f, 0x00e9, 0x005a, 0x00e7, 0x0058, - 0x00e4, 0x0058, 0x00e3, 0x0054, 0x00e3, 0x0058, 0x00e1, 0x005c, - 0x00e4, 0x0061, 0x00e7, 0x0061, 0x00e9, 0x005f, 0x00eb, 0x005d, - 0x00e4, 0x0062, 0x00e0, 0x0064, 0x00e0, 0x0069, 0x00e2, 0x006b, - 0x00e0, 0x0072, 0x00e0, 0x0077, 0x00ec, 0x0077, 0x00ec, 0x0071, - 0x00ea, 0x006b, 0x00ec, 0x006a, 0x00ec, 0x0063, 0x00e7, 0x0063, - 0x00e7, 0x0065, 0x00e1, 0x0069, 0x00e3, 0x0068, 0x00e6, 0x0069, - 0x00ec, 0x005e, 0x00ea, 0x006b, 0x00e7, 0x006b, 0x00e7, 0x006a, - 0x00e5, 0x006a, 0x00e5, 0x006b, 0x00e2, 0x006b, 0x00df, 0x006c, - 0x00dc, 0x006f, 0x00dc, 0x0071, 0x00da, 0x0073, 0x00d8, 0x0073, - 0x00d8, 0x006f, 0x00dc, 0x006b, 0x00dc, 0x0069, 0x00dd, 0x0068, - 0x00ef, 0x0068, 0x00f0, 0x0069, 0x00f0, 0x006b, 0x00f4, 0x006f, - 0x00f4, 0x0072, 0x00f3, 0x0073, 0x00f2, 0x0073, 0x00f0, 0x0071, - 0x00f0, 0x006f, 0x00ec, 0x006b, 0x00ec, 0x007a, 0x00eb, 0x007b, - 0x00eb, 0x007f, 0x00ec, 0x0080, 0x00ec, 0x0084, 0x00eb, 0x0085, - 0x00eb, 0x008b, 0x00ec, 0x008c, 0x00ec, 0x008f, 0x00ed, 0x0091, - 0x00e9, 0x0091, 0x00e9, 0x008f, 0x00e7, 0x008d, 0x00e7, 0x0090, - 0x00e7, 0x0089, 0x00e8, 0x0088, 0x00e8, 0x0086, 0x00e7, 0x0085, - 0x00e7, 0x007d, 0x00e6, 0x007c, 0x00e6, 0x0078, 0x00e5, 0x007d, - 0x00e5, 0x0085, 0x00e4, 0x0086, 0x00e4, 0x0088, 0x00e5, 0x0089, - 0x00e5, 0x0090, 0x00e5, 0x008b, 0x00e3, 0x0091, 0x00df, 0x0091, - 0x00e0, 0x0090, 0x00e0, 0x008c, 0x00e2, 0x008b, 0x00e1, 0x0085, - 0x00e0, 0x0084, 0x00e0, 0x0080, 0x00e1, 0x007f, 0x00e1, 0x007c, - 0x00e0, 0x007b, 0x00e0, 0x0077 -}; - -struct Credit { - const char *_role; - const char *_name; -} _credits[] = { - {"Music and Sound Effects", "MARCO CAPRELLI"}, - {"PC Version", "RICCARDO BALLARINO"}, - {"Project Manager", "LOVRANO CANEPA"}, - {"Production", "BRUNO BOZ"}, - {"Special Thanks to", "LUIGI BENEDICENTI - GILDA and DANILO"}, - {"Copyright 1992 Euclidea s.r.l ITALY", "All rights reserved"} -}; - -/* - game callables -*/ - -void _c_null(void *parm) { - - return; -} - -void _c_play_boogie(void *parm) { - - static uint16 flag = 1; - - if (flag == 0) - return; - flag = 0; - - _vm->_soundMan->setMusicFile("boogie2"); - _vm->_soundMan->playMusic(); - - return; -} - - -void _c_score(void *parm) { - _score += 5; - return; -} - -void _c_fade(void *parm) { - - _vm->_gfx->setBlackPalette(); - - Gfx::Palette pal; - memset(pal, 0, sizeof(Gfx::Palette)); - - for (uint16 _di = 0; _di < 64; _di++) { - _vm->_gfx->fadePalette(pal); - _vm->_gfx->setPalette(pal); - - g_system->delayMillis(20); - _vm->_gfx->updateScreen(); - } - - return; -} - - - -void _c_moveSarc(void *parm) { - - Animation *a; - - if (_introSarcData2 != 0) { - - _introSarcData2 = 0; - if (_moveSarcZones[0] == NULL) { - - _moveSarcZones[0] = _vm->findZone("sarc1"); - _moveSarcZones[1] = _vm->findZone("sarc2"); - _moveSarcZones[2] = _vm->findZone("sarc3"); - _moveSarcZones[3] = _vm->findZone("sarc4"); - _moveSarcZones[4] = _vm->findZone("sarc5"); - - _moveSarcExaZones[0] = _vm->findZone("sarc1exa"); - _moveSarcExaZones[1] = _vm->findZone("sarc2exa"); - _moveSarcExaZones[2] = _vm->findZone("sarc3exa"); - _moveSarcExaZones[3] = _vm->findZone("sarc4exa"); - _moveSarcExaZones[4] = _vm->findZone("sarc5exa"); - - } - - a = _vm->findAnimation("sposta"); - - _moveSarcZone1 = (Zone*)parm; - - for (uint16 _si = 0; _si < 5; _si++) { - if (_moveSarcZones[_si] == _moveSarcZone1) { - _moveSarcZone0 = _moveSarcExaZones[_si]; - } - } - - _introSarcData1 = _introSarcData3 - _moveSarcZone1->_left; - a->_z = _introSarcData3; - a->_frame = _moveSarcZone1->_top - (_introSarcData1 / 20); - _introSarcData3 = _moveSarcZone1->_left; - - if (_introSarcData1 > 0) { - a->_left = _introSarcData1 / 2; - } else { - a->_left = -_introSarcData1 / 2; - } - - if (_introSarcData1 > 0) { - a->_top = 2; - } else { - a->_top = -2; - } - - return; - - } - - _introSarcData2 = 1; - _moveSarcZone1->translate(_introSarcData1, -_introSarcData1 / 20); - _moveSarcZone0->translate(_introSarcData1, -_introSarcData1 / 20); - - if (_moveSarcZones[0]->_left == 35 && - _moveSarcZones[1]->_left == 68 && - _moveSarcZones[2]->_left == 101 && - _moveSarcZones[3]->_left == 134 && - _moveSarcZones[4]->_left == 167) { - - a = _vm->findAnimation("finito"); - - a->_flags |= (kFlagsActive | kFlagsActing); - _localFlags[_vm->_currentLocationIndex] |= 0x20; // GROSS HACK: activates 'finito' flag in dinoit_museo.loc - } - - return; - -} - - - - -void _c_contaFoglie(void *parm) { - - num_foglie++; - if (num_foglie != 6) - return; - - _commandFlags |= 0x1000; - - return; -} - -void _c_zeroFoglie(void *parm) { - num_foglie = 0; - return; -} - -void _c_trasformata(void *parm) { - _engineFlags ^= kEngineTransformedDonna; - return; -} - -void _c_offMouse(void *parm) { - _vm->showCursor(false); - _engineFlags |= kEngineBlockInput; - return; -} - -void _c_onMouse(void *parm) { - _engineFlags &= ~kEngineBlockInput; - _vm->showCursor(true); - return; -} - - - -void _c_setMask(void *parm) { - - _vm->_gfx->intGrottaHackMask(); - - return; -} - -void _c_endComment(void *param) { - - byte* _enginePal = _vm->_gfx->_palette; - Gfx::Palette pal; - - uint32 si; - for (si = 0; si < 32; si++) { - - byte al = _enginePal[si*3+1]; - if (al > _enginePal[si*3+2]) { - al = _enginePal[si*3+1]; - } else { - al = _enginePal[si*3+2]; - } - - if (al < _enginePal[si*3]) { - al = _enginePal[si*3]; - } else { - al = _enginePal[si*3+1]; - } - - if (al > _enginePal[si*3+2]) { - al = _enginePal[si*3+1]; - } else { - al = _enginePal[si*3+2]; - } - - pal[si*3] = al; - pal[si*3+2] = al; - pal[si*3+1] = al; - - } - - int16 w = 0, h = 0; - _vm->_gfx->getStringExtent(_vm->_location._endComment, 130, &w, &h); - - Common::Rect r(w+5, h+5); - r.moveTo(5, 5); - _vm->_gfx->floodFill(Gfx::kBitFront, r, 0); - - r.setWidth(w+3); - r.setHeight(h+3); - r.moveTo(7, 7); - _vm->_gfx->floodFill(Gfx::kBitFront, r, 1); - - _vm->_gfx->setFont(kFontDialogue); - _vm->_gfx->displayWrappedString(_vm->_location._endComment, 3, 5, 0, 130); - _vm->_gfx->updateScreen(); - - uint32 di = 0; - for (di = 0; di < PALETTE_COLORS; di++) { - for (si = 0; si <= 93; si +=3) { - - int8 al; - - if (_enginePal[si] != pal[si]) { - al = _enginePal[si]; - if (al > pal[si]) - al = 1; - else - al = -1; - _enginePal[si] += al; - } - - if (_enginePal[si+1] != pal[si+1]) { - al = _enginePal[si+1]; - if (al > pal[si+1]) - al = 1; - else - al = -1; - _enginePal[si+1] += al; - } - - if (_enginePal[si+2] != pal[si+2]) { - al = _enginePal[si+2]; - if (al > pal[si+2]) - al = 1; - else - al = -1; - _enginePal[si+2] += al; - } - - } - - _vm->_gfx->setPalette(_enginePal); - g_system->delayMillis(20); - _vm->_gfx->updateScreen(); - - } - - waitUntilLeftClick(); - - return; -} - -void _c_frankenstein(void *parm) { - - Gfx::Palette pal0; - Gfx::Palette pal1; - - for (uint16 i = 0; i <= BASE_PALETTE_COLORS; i++) { - pal0[(i+FIRST_BASE_COLOR)] = _vm->_gfx->_palette[i]; - pal0[(i+FIRST_BASE_COLOR)*3+1] = 0; - pal0[(i+FIRST_BASE_COLOR)*3+2] = 0; - - pal1[(i+FIRST_BASE_COLOR)*3+1] = 0; - pal1[(i+FIRST_BASE_COLOR)*3+2] = 0; - } - - for (uint16 _di = 0; _di < 30; _di++) { - g_system->delayMillis(20); - _vm->_gfx->setPalette(pal0, FIRST_BASE_COLOR, BASE_PALETTE_COLORS); - _vm->_gfx->updateScreen(); - g_system->delayMillis(20); - _vm->_gfx->setPalette(pal1, FIRST_BASE_COLOR, BASE_PALETTE_COLORS); - _vm->_gfx->updateScreen(); - } - - _vm->_gfx->setPalette(_vm->_gfx->_palette); - _vm->_gfx->updateScreen(); - - return; -} - - -void _c_finito(void *parm) { - - const char **v8C = endMsg0; - const char **v7C = endMsg1; - const char **v6C = endMsg2; - const char **v5C = endMsg3; - const char **v4C = endMsg4; - const char **v3C = endMsg5; - const char **v2C = endMsg6; - const char **v1C = endMsg7; - - Common::File stream; - - stream.open(_vm->_characterName, Common::File::kFileWriteMode); - if (stream.isOpen()) - stream.close(); - - Common::File streamDino, streamDough, streamDonna; - - streamDino.open("dino"); - streamDough.open("dough"); - streamDonna.open("donna"); - - bool gameCompleted = streamDino.isOpen() && streamDough.isOpen() && streamDonna.isOpen(); - - streamDino.close(); - streamDough.close(); - streamDonna.close(); - - cleanInventory(); - - _vm->_gfx->setPalette(_vm->_gfx->_palette); - - if (gameCompleted) { - _vm->_gfx->setFont(kFontMenu); - _vm->_gfx->displayCenteredString(70, v4C[_language]); - _vm->_gfx->displayCenteredString(100, v3C[_language]); - _vm->_gfx->displayCenteredString(130, v2C[_language]); - _vm->_gfx->displayCenteredString(160, v1C[_language]); - - _vm->_gfx->updateScreen(); - waitUntilLeftClick(); - - strcpy(_vm->_location._name, "estgrotta.drki"); - - _engineFlags |= kEngineChangeLocation; - } else { - _vm->_gfx->setFont(kFontMenu); - _vm->_gfx->displayCenteredString(70, v8C[_language]); - _vm->_gfx->displayCenteredString(100, v7C[_language]); - _vm->_gfx->displayCenteredString(130, v6C[_language]); - _vm->_gfx->displayCenteredString(160, v5C[_language]); - - _vm->_gfx->updateScreen(); - waitUntilLeftClick(); - - _vm->_menu->selectCharacter(); - } - - // this code saves main character animation from being removed from the following code - _vm->_animations.remove(&_vm->_char._ani); - _vm->_locationNames[0][0] = '\0'; - _vm->_numLocations = 0; - _commandFlags = 0; - - // this flag tells freeZones to unconditionally remove *all* Zones - _engineFlags |= kEngineQuit; - - // TODO (LIST): this sequence should be just _zones.clear() - _vm->freeZones(); - - // TODO (LIST): this sequence should be just _animations.clear() - _vm->freeAnimations(); - - // this dangerous flag can now be cleared - _engineFlags &= ~kEngineQuit; - - // main character animation is restored - _vm->_animations.push_front(&_vm->_char._ani); - _score = 0; - - return; -} - -void _c_ridux(void *parm) { - _vm->changeCharacter(_minidinoName); - return; -} - -void _c_testResult(void *parm) { - _vm->_gfx->swapBuffers(); - - _vm->_disk->selectArchive("disk1"); - _vm->parseLocation("common"); - - _vm->_gfx->setFont(kFontMenu); - - _vm->_gfx->displayCenteredString(38, _slideText[0]); - _vm->_gfx->displayCenteredString(58, _slideText[1]); - - _vm->_gfx->copyScreen(Gfx::kBitFront, Gfx::kBitBack); - _vm->_gfx->copyScreen(Gfx::kBitFront, Gfx::kBit2); - - return; -} - -void _c_offSound(void*) { - _vm->_soundMan->stopSfx(0); - _vm->_soundMan->stopSfx(1); - _vm->_soundMan->stopSfx(2); - _vm->_soundMan->stopSfx(3); -} - -void _c_startMusic(void*) { - _vm->_soundMan->playMusic(); -} - -void _c_closeMusic(void*) { - _vm->_soundMan->stopMusic(); -} - -/* - intro callables -*/ - -void _c_startIntro(void *parm) { - _rightHandAnim = _vm->findAnimation("righthand"); - - if (_vm->getPlatform() == Common::kPlatformPC) { - _vm->_soundMan->setMusicFile("intro"); - _vm->_soundMan->playMusic(); - } - - _engineFlags |= kEngineBlockInput; - - return; -} - -void _c_endIntro(void *parm) { - - _vm->_gfx->setFont(kFontMenu); - - debugC(1, kDebugLocation, "endIntro()"); - - for (uint16 _si = 0; _si < 6; _si++) { - _vm->_gfx->displayCenteredString(80, _credits[_si]._role); - _vm->_gfx->displayCenteredString(100, _credits[_si]._name); - - _vm->_gfx->updateScreen(); - - for (uint16 v2 = 0; v2 < 100; v2++) { - _mouseButtons = kMouseNone; - _vm->updateInput(); - if (_mouseButtons == kMouseLeftUp) - break; - - _vm->waitTime( 1 ); - } - - _vm->_gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront); - } - debugC(1, kDebugLocation, "endIntro(): done showing credits"); - - if ((_vm->getFeatures() & GF_DEMO) == 0) { - _vm->_gfx->displayCenteredString(80, "CLICK MOUSE BUTTON TO START"); - _vm->_gfx->updateScreen(); - - waitUntilLeftClick(); - - _engineFlags &= ~kEngineBlockInput; - _vm->_menu->selectCharacter(); - } else { - waitUntilLeftClick(); - } - - return; -} - -void _c_moveSheet(void *parm) { - - static uint16 x = 319; - - if (x > 66) - x -= 16; - - Common::Rect r; - - r.left = x; - r.top = 47; - r.right = (x + 32 > 319) ? 319 : (x + 32); - r.bottom = 199; - _vm->_gfx->floodFill(Gfx::kBitBack, r, 1); - _vm->_gfx->floodFill(Gfx::kBit2, r, 1); - - if (x >= 104) return; - - r.left = x+215; - r.top = 47; - r.right = (x + 247 > 319) ? 319 : (x + 247); - r.bottom = 199; - _vm->_gfx->floodFill(Gfx::kBitBack, r, 12); - _vm->_gfx->floodFill(Gfx::kBit2, r, 12); - - return; -} - -void plotPixel(int x, int y, int color, void *data) { - _vm->_gfx->plotMaskPixel(x, y, color); -} - -void _c_sketch(void *parm) { - - static uint16 index = 1; - - uint16 newy = _rightHandPositions[2*index+1]; - uint16 newx = _rightHandPositions[2*index]; - - uint16 oldy = _rightHandPositions[2*(index-1)+1]; - uint16 oldx = _rightHandPositions[2*(index-1)]; - - Graphics::drawLine(oldx, oldy, newx, newy, 0, plotPixel, NULL); - - _rightHandAnim->_left = newx; - _rightHandAnim->_top = newy - 20; - - index++; - - return; -} - - - - -void _c_shade(void *parm) { - - Common::Rect r( - _rightHandAnim->_left - 36, - _rightHandAnim->_top - 36, - _rightHandAnim->_left, - _rightHandAnim->_top - ); - - _vm->_gfx->fillMaskRect(r, 0); - - return; - -} - -void _c_projector(void*) { -#ifdef HALFBRITE - static int dword_16032 = 0; - -// Bitmap bm; -// InitBitMap(&bm); - - if (dword_16032 != 0) { -/* // keep drawing spotlight in its final place - _vm->_gfx->flatBlitCnv(&scnv, 110, 25, Gfx::kBitFront); - BltBitMap(&bm, 0, 0, &_screen._bitMap, 110, 25, a3->??, a3->??, 0x20, 0x20); -*/ return; - } - - _vm->_gfx->setHalfbriteMode(true); -/* - // move spot light around the stage - int d7, d6; - for (d7 = 0; d7 < 150; d7++) { - - if (d7 < 100) { - int d1 = d7; - if (d1 < 0) - d1++; - - d1 >>= 1; - d6 = 50 - d1; - } else { - int d1 = d7 / 100; - if (d1 < 0) - d1++; - - d1 >>= 1; - d6 = d1; - } - - BltBitMap(&bm, 0, 0, &_screen._bitMap, d7+20, d6, a3->??, a3->??, 0x20, 0x20); - sub_1590C(d6 + a3->??); - BltBitMap(&bm, 0, 0, &_screen._bitMap, d7+20, d6, a3->??, a3->??, 0xFA, 0x20); - } - - for (d7 = 50; d7 > -10; d7--) { - BltBitMap(&bm, 0, 0, &_screen._bitMap, d7+120, d6, a3->??, a3->??, 0x20, 0x20); - sub_1590C(d6 + a3->??); - BltBitMap(&bm, 0, 0, &_screen._bitMap, d7+120, d6, a3->??, a3->??, 0xFA, 0x20); - } - - BltBitMap(&bm, 0, 0, &_screen._bitMap, d7+120, d6, a3->??, a3->??, 0x20, 0x20); - _vm->_gfx->flatBlitCnv(&scnv, d7+120, d6, Gfx::kBitFront); -*/ - - dword_16032 = 1; - return; -#endif -} - -void _c_HBOff(void*) { -#ifdef HALFBRITE - _vm->_gfx->setHalfbriteMode(false); -#endif -} - -void _c_HBOn(void*) { -#ifdef HALFBRITE - _vm->_gfx->setHalfbriteMode(true); -#endif -} - - -} // namespace Parallaction diff --git a/engines/parallaction/callables_ns.cpp b/engines/parallaction/callables_ns.cpp new file mode 100644 index 0000000000..b0312bb714 --- /dev/null +++ b/engines/parallaction/callables_ns.cpp @@ -0,0 +1,782 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + + +#include "common/stdafx.h" +#include "common/system.h" + +#include "common/file.h" + +#include "graphics/primitives.h" // for Graphics::drawLine + +#include "parallaction/parallaction.h" +#include "parallaction/menu.h" +#include "parallaction/sound.h" + + +namespace Parallaction { + +/* + game callables data members +*/ + +// there three guys are extern'd somewhere +Zone *_moveSarcZone0 = NULL; +int16 _introSarcData1 = 0; +Zone *_moveSarcZone1 = NULL; + +// part completion messages +static const char *endMsg0[] = {"COMPLIMENTI!", "BRAVO!", "CONGRATULATIONS!", "PRIMA!"}; +static const char *endMsg1[] = {"HAI FINITO QUESTA PARTE", "TU AS COMPLETE' CETTE AVENTURE", "YOU HAVE COMPLETED THIS PART", "DU HAST EIN ABENTEUER ERFOLGREICH"}; +static const char *endMsg2[] = {"ORA COMPLETA IL RESTO ", "AVEC SUCCES.", "NOW GO ON WITH THE REST OF", "ZU ENDE GEFUHRT"}; +static const char *endMsg3[] = {"DELL' AVVENTURA", "CONTINUE AVEC LES AUTRES", "THIS ADVENTURE", "MACH' MIT DEN ANDEREN WEITER"}; +// game completion messages +static const char *endMsg4[] = {"COMPLIMENTI!", "BRAVO!", "CONGRATULATIONS!", "PRIMA!"}; +static const char *endMsg5[] = {"HAI FINITO LE TRE PARTI", "TU AS COMPLETE' LES TROIS PARTIES", "YOU HAVE COMPLETED THE THREE PARTS", "DU HAST DREI ABENTEURE ERFOLGREICH"}; +static const char *endMsg6[] = {"DELL' AVVENTURA", "DE L'AVENTURE", "OF THIS ADVENTURE", "ZU ENDE GEFUHRT"}; +static const char *endMsg7[] = {"ED ORA IL GRAN FINALE ", "ET MAINTENANT LE GRAND FINAL", "NOW THE GREAT FINAL", "UND YETZT DER GROSSE SCHLUSS!"}; + +static uint16 num_foglie = 0; +static Zone *_moveSarcZones[5]; +static Zone *_moveSarcExaZones[5]; + +/* + intro callables data members +*/ + +static Animation *_rightHandAnim; + +static uint16 _rightHandPositions[684] = { + 0x0064, 0x0046, 0x006c, 0x0046, 0x0074, 0x0046, 0x007c, 0x0046, + 0x0084, 0x0046, 0x008c, 0x0046, 0x0094, 0x0046, 0x009c, 0x0046, + 0x00a4, 0x0046, 0x00ac, 0x0046, 0x00b4, 0x0046, 0x00bc, 0x0046, + 0x00c4, 0x0046, 0x00cc, 0x0046, 0x00d4, 0x0046, 0x00dc, 0x0046, + 0x00e4, 0x0046, 0x00ec, 0x0046, 0x00f4, 0x0046, 0x00fc, 0x0046, + 0x0104, 0x0046, 0x00ff, 0x0042, 0x00ff, 0x004a, 0x00ff, 0x0052, + 0x00ff, 0x005a, 0x00ff, 0x0062, 0x00ff, 0x006a, 0x00ff, 0x0072, + 0x00ff, 0x007a, 0x00ff, 0x0082, 0x00ff, 0x008a, 0x00ff, 0x0092, + 0x00ff, 0x009a, 0x00ff, 0x00a2, 0x0104, 0x0097, 0x00fc, 0x0097, + 0x00f4, 0x0097, 0x00ec, 0x0097, 0x00e4, 0x0097, 0x00dc, 0x0097, + 0x00d4, 0x0097, 0x00cc, 0x0097, 0x00c4, 0x0097, 0x00bc, 0x0097, + 0x00b4, 0x0097, 0x00ac, 0x0097, 0x00a4, 0x0097, 0x009c, 0x0097, + 0x0094, 0x0097, 0x008c, 0x0097, 0x0084, 0x0097, 0x007c, 0x0097, + 0x0074, 0x0097, 0x006c, 0x0097, 0x0064, 0x0097, 0x0066, 0x0042, + 0x0066, 0x004a, 0x0066, 0x0052, 0x0066, 0x005a, 0x0066, 0x0062, + 0x0066, 0x006a, 0x0066, 0x0072, 0x0066, 0x007a, 0x0066, 0x0082, + 0x0066, 0x008a, 0x0066, 0x0092, 0x0066, 0x009a, 0x0066, 0x00a2, + 0x008c, 0x0091, 0x0099, 0x0042, 0x0099, 0x004a, 0x0099, 0x0052, + 0x0099, 0x005a, 0x0099, 0x0062, 0x0099, 0x006a, 0x0099, 0x0072, + 0x0099, 0x007a, 0x0099, 0x0082, 0x0099, 0x008a, 0x0099, 0x0092, + 0x0099, 0x009a, 0x0099, 0x00a2, 0x00a0, 0x004d, 0x00cc, 0x0042, + 0x00cc, 0x004a, 0x00cc, 0x0052, 0x00cc, 0x005a, 0x00cc, 0x0062, + 0x00cc, 0x006a, 0x00cc, 0x0072, 0x00cc, 0x007a, 0x00cc, 0x0082, + 0x00cc, 0x008a, 0x00cc, 0x0092, 0x00cc, 0x009a, 0x00cc, 0x00a2, + 0x00ca, 0x0050, 0x00b1, 0x0050, 0x0081, 0x0052, 0x007e, 0x0052, + 0x007c, 0x0055, 0x007c, 0x005c, 0x007e, 0x005e, 0x0080, 0x005e, + 0x0082, 0x005c, 0x0082, 0x0054, 0x0080, 0x0052, 0x0078, 0x0052, + 0x007c, 0x005e, 0x0077, 0x0061, 0x0074, 0x006e, 0x0074, 0x0078, + 0x0076, 0x007a, 0x0079, 0x0078, 0x0079, 0x0070, 0x0078, 0x0070, + 0x0078, 0x006b, 0x007b, 0x0066, 0x007a, 0x006f, 0x0084, 0x006f, + 0x0085, 0x0066, 0x0086, 0x0070, 0x0085, 0x0070, 0x0085, 0x0079, + 0x0088, 0x0079, 0x008a, 0x0078, 0x008a, 0x006c, 0x0087, 0x0061, + 0x0085, 0x005f, 0x0082, 0x005f, 0x0080, 0x0061, 0x007e, 0x0061, + 0x007b, 0x005f, 0x007c, 0x006f, 0x007c, 0x0071, 0x0079, 0x0074, + 0x0079, 0x0089, 0x0076, 0x008c, 0x0076, 0x008e, 0x007a, 0x008e, + 0x007f, 0x0089, 0x007f, 0x0083, 0x007e, 0x0083, 0x007e, 0x0077, + 0x0080, 0x0077, 0x0080, 0x0083, 0x0080, 0x008b, 0x0084, 0x0090, + 0x0088, 0x0090, 0x0088, 0x008e, 0x0085, 0x008b, 0x0085, 0x0074, + 0x0082, 0x0071, 0x00b2, 0x0052, 0x00b0, 0x0054, 0x00b0, 0x0056, + 0x00ae, 0x0058, 0x00af, 0x0059, 0x00af, 0x005e, 0x00b2, 0x0061, + 0x00b5, 0x0061, 0x00b8, 0x005e, 0x00b8, 0x005a, 0x00b9, 0x0059, + 0x00b9, 0x0058, 0x00b7, 0x0056, 0x00b7, 0x0054, 0x00b5, 0x0052, + 0x00b2, 0x0052, 0x00ae, 0x005a, 0x00ab, 0x005b, 0x00ab, 0x006d, + 0x00ae, 0x0072, 0x00b8, 0x0072, 0x00bc, 0x006d, 0x00bc, 0x005b, + 0x00b9, 0x005a, 0x00bc, 0x005c, 0x00be, 0x005c, 0x00c1, 0x005f, + 0x00c4, 0x0067, 0x00c4, 0x006d, 0x00c1, 0x0076, 0x00c0, 0x0077, + 0x00bd, 0x0077, 0x00bb, 0x0075, 0x00bd, 0x0073, 0x00bb, 0x0072, + 0x00be, 0x0070, 0x00be, 0x006a, 0x00a9, 0x006a, 0x00a9, 0x0070, + 0x00ac, 0x0072, 0x00aa, 0x0073, 0x00ac, 0x0075, 0x00aa, 0x0077, + 0x00a7, 0x0077, 0x00a3, 0x006d, 0x00a3, 0x0067, 0x00a6, 0x005f, + 0x00a9, 0x005c, 0x00ab, 0x005c, 0x00ac, 0x0077, 0x00ac, 0x007c, + 0x00ab, 0x007c, 0x00ab, 0x0084, 0x00ac, 0x0084, 0x00ac, 0x008b, + 0x00a9, 0x008e, 0x00a9, 0x0090, 0x00ae, 0x0090, 0x00ae, 0x008d, + 0x00b2, 0x008c, 0x00b2, 0x0087, 0x00b1, 0x0086, 0x00b1, 0x007b, + 0x00b2, 0x0079, 0x00b4, 0x0079, 0x00b4, 0x007d, 0x00b5, 0x007d, + 0x00b5, 0x0087, 0x00b4, 0x0087, 0x00b4, 0x008c, 0x00b6, 0x008c, + 0x00b9, 0x0091, 0x00b4, 0x0091, 0x00bd, 0x008f, 0x00ba, 0x008c, + 0x00ba, 0x0083, 0x00bb, 0x0082, 0x00bb, 0x0075, 0x00cc, 0x006e, + 0x00d4, 0x006c, 0x00db, 0x0069, 0x00d9, 0x0068, 0x00d9, 0x0064, + 0x00dc, 0x0064, 0x00dc, 0x0060, 0x00df, 0x0056, 0x00e5, 0x0052, + 0x00e7, 0x0052, 0x00ec, 0x0056, 0x00ef, 0x005d, 0x00f1, 0x0065, + 0x00f3, 0x0064, 0x00f3, 0x0069, 0x00f0, 0x0069, 0x00ec, 0x0065, + 0x00ec, 0x005e, 0x00e9, 0x005f, 0x00e9, 0x005a, 0x00e7, 0x0058, + 0x00e4, 0x0058, 0x00e3, 0x0054, 0x00e3, 0x0058, 0x00e1, 0x005c, + 0x00e4, 0x0061, 0x00e7, 0x0061, 0x00e9, 0x005f, 0x00eb, 0x005d, + 0x00e4, 0x0062, 0x00e0, 0x0064, 0x00e0, 0x0069, 0x00e2, 0x006b, + 0x00e0, 0x0072, 0x00e0, 0x0077, 0x00ec, 0x0077, 0x00ec, 0x0071, + 0x00ea, 0x006b, 0x00ec, 0x006a, 0x00ec, 0x0063, 0x00e7, 0x0063, + 0x00e7, 0x0065, 0x00e1, 0x0069, 0x00e3, 0x0068, 0x00e6, 0x0069, + 0x00ec, 0x005e, 0x00ea, 0x006b, 0x00e7, 0x006b, 0x00e7, 0x006a, + 0x00e5, 0x006a, 0x00e5, 0x006b, 0x00e2, 0x006b, 0x00df, 0x006c, + 0x00dc, 0x006f, 0x00dc, 0x0071, 0x00da, 0x0073, 0x00d8, 0x0073, + 0x00d8, 0x006f, 0x00dc, 0x006b, 0x00dc, 0x0069, 0x00dd, 0x0068, + 0x00ef, 0x0068, 0x00f0, 0x0069, 0x00f0, 0x006b, 0x00f4, 0x006f, + 0x00f4, 0x0072, 0x00f3, 0x0073, 0x00f2, 0x0073, 0x00f0, 0x0071, + 0x00f0, 0x006f, 0x00ec, 0x006b, 0x00ec, 0x007a, 0x00eb, 0x007b, + 0x00eb, 0x007f, 0x00ec, 0x0080, 0x00ec, 0x0084, 0x00eb, 0x0085, + 0x00eb, 0x008b, 0x00ec, 0x008c, 0x00ec, 0x008f, 0x00ed, 0x0091, + 0x00e9, 0x0091, 0x00e9, 0x008f, 0x00e7, 0x008d, 0x00e7, 0x0090, + 0x00e7, 0x0089, 0x00e8, 0x0088, 0x00e8, 0x0086, 0x00e7, 0x0085, + 0x00e7, 0x007d, 0x00e6, 0x007c, 0x00e6, 0x0078, 0x00e5, 0x007d, + 0x00e5, 0x0085, 0x00e4, 0x0086, 0x00e4, 0x0088, 0x00e5, 0x0089, + 0x00e5, 0x0090, 0x00e5, 0x008b, 0x00e3, 0x0091, 0x00df, 0x0091, + 0x00e0, 0x0090, 0x00e0, 0x008c, 0x00e2, 0x008b, 0x00e1, 0x0085, + 0x00e0, 0x0084, 0x00e0, 0x0080, 0x00e1, 0x007f, 0x00e1, 0x007c, + 0x00e0, 0x007b, 0x00e0, 0x0077 +}; + +struct Credit { + const char *_role; + const char *_name; +} _credits[] = { + {"Music and Sound Effects", "MARCO CAPRELLI"}, + {"PC Version", "RICCARDO BALLARINO"}, + {"Project Manager", "LOVRANO CANEPA"}, + {"Production", "BRUNO BOZ"}, + {"Special Thanks to", "LUIGI BENEDICENTI - GILDA and DANILO"}, + {"Copyright 1992 Euclidea s.r.l ITALY", "All rights reserved"} +}; + +/* + game callables +*/ + +void Parallaction_ns::_c_null(void *parm) { + + return; +} + +void Parallaction_ns::_c_play_boogie(void *parm) { + + static uint16 flag = 1; + + if (flag == 0) + return; + flag = 0; + + _vm->_soundMan->setMusicFile("boogie2"); + _vm->_soundMan->playMusic(); + + return; +} + + +void Parallaction_ns::_c_score(void *parm) { + _score += 5; + return; +} + +void Parallaction_ns::_c_fade(void *parm) { + + _vm->_gfx->setBlackPalette(); + + Gfx::Palette pal; + memset(pal, 0, sizeof(Gfx::Palette)); + + for (uint16 _di = 0; _di < 64; _di++) { + _vm->_gfx->fadePalette(pal); + _vm->_gfx->setPalette(pal); + + g_system->delayMillis(20); + _vm->_gfx->updateScreen(); + } + + return; +} + + + +void Parallaction_ns::_c_moveSarc(void *parm) { + + Animation *a; + + if (_introSarcData2 != 0) { + + _introSarcData2 = 0; + if (_moveSarcZones[0] == NULL) { + + _moveSarcZones[0] = _vm->findZone("sarc1"); + _moveSarcZones[1] = _vm->findZone("sarc2"); + _moveSarcZones[2] = _vm->findZone("sarc3"); + _moveSarcZones[3] = _vm->findZone("sarc4"); + _moveSarcZones[4] = _vm->findZone("sarc5"); + + _moveSarcExaZones[0] = _vm->findZone("sarc1exa"); + _moveSarcExaZones[1] = _vm->findZone("sarc2exa"); + _moveSarcExaZones[2] = _vm->findZone("sarc3exa"); + _moveSarcExaZones[3] = _vm->findZone("sarc4exa"); + _moveSarcExaZones[4] = _vm->findZone("sarc5exa"); + + } + + a = _vm->findAnimation("sposta"); + + _moveSarcZone1 = (Zone*)parm; + + for (uint16 _si = 0; _si < 5; _si++) { + if (_moveSarcZones[_si] == _moveSarcZone1) { + _moveSarcZone0 = _moveSarcExaZones[_si]; + } + } + + _introSarcData1 = _introSarcData3 - _moveSarcZone1->_left; + a->_z = _introSarcData3; + a->_frame = _moveSarcZone1->_top - (_introSarcData1 / 20); + _introSarcData3 = _moveSarcZone1->_left; + + if (_introSarcData1 > 0) { + a->_left = _introSarcData1 / 2; + } else { + a->_left = -_introSarcData1 / 2; + } + + if (_introSarcData1 > 0) { + a->_top = 2; + } else { + a->_top = -2; + } + + return; + + } + + _introSarcData2 = 1; + _moveSarcZone1->translate(_introSarcData1, -_introSarcData1 / 20); + _moveSarcZone0->translate(_introSarcData1, -_introSarcData1 / 20); + + if (_moveSarcZones[0]->_left == 35 && + _moveSarcZones[1]->_left == 68 && + _moveSarcZones[2]->_left == 101 && + _moveSarcZones[3]->_left == 134 && + _moveSarcZones[4]->_left == 167) { + + a = _vm->findAnimation("finito"); + + a->_flags |= (kFlagsActive | kFlagsActing); + _localFlags[_vm->_currentLocationIndex] |= 0x20; // GROSS HACK: activates 'finito' flag in dinoit_museo.loc + } + + return; + +} + + + + +void Parallaction_ns::_c_contaFoglie(void *parm) { + + num_foglie++; + if (num_foglie != 6) + return; + + _commandFlags |= 0x1000; + + return; +} + +void Parallaction_ns::_c_zeroFoglie(void *parm) { + num_foglie = 0; + return; +} + +void Parallaction_ns::_c_trasformata(void *parm) { + _engineFlags ^= kEngineTransformedDonna; + return; +} + +void Parallaction_ns::_c_offMouse(void *parm) { + _vm->showCursor(false); + _engineFlags |= kEngineBlockInput; + return; +} + +void Parallaction_ns::_c_onMouse(void *parm) { + _engineFlags &= ~kEngineBlockInput; + _vm->showCursor(true); + return; +} + + + +void Parallaction_ns::_c_setMask(void *parm) { + + _vm->_gfx->intGrottaHackMask(); + + return; +} + +void Parallaction_ns::_c_endComment(void *param) { + + byte* _enginePal = _vm->_gfx->_palette; + Gfx::Palette pal; + + uint32 si; + for (si = 0; si < 32; si++) { + + byte al = _enginePal[si*3+1]; + if (al > _enginePal[si*3+2]) { + al = _enginePal[si*3+1]; + } else { + al = _enginePal[si*3+2]; + } + + if (al < _enginePal[si*3]) { + al = _enginePal[si*3]; + } else { + al = _enginePal[si*3+1]; + } + + if (al > _enginePal[si*3+2]) { + al = _enginePal[si*3+1]; + } else { + al = _enginePal[si*3+2]; + } + + pal[si*3] = al; + pal[si*3+2] = al; + pal[si*3+1] = al; + + } + + int16 w = 0, h = 0; + _vm->_gfx->getStringExtent(_vm->_location._endComment, 130, &w, &h); + + Common::Rect r(w+5, h+5); + r.moveTo(5, 5); + _vm->_gfx->floodFill(Gfx::kBitFront, r, 0); + + r.setWidth(w+3); + r.setHeight(h+3); + r.moveTo(7, 7); + _vm->_gfx->floodFill(Gfx::kBitFront, r, 1); + + _vm->_gfx->setFont(kFontDialogue); + _vm->_gfx->displayWrappedString(_vm->_location._endComment, 3, 5, 0, 130); + _vm->_gfx->updateScreen(); + + uint32 di = 0; + for (di = 0; di < PALETTE_COLORS; di++) { + for (si = 0; si <= 93; si +=3) { + + int8 al; + + if (_enginePal[si] != pal[si]) { + al = _enginePal[si]; + if (al > pal[si]) + al = 1; + else + al = -1; + _enginePal[si] += al; + } + + if (_enginePal[si+1] != pal[si+1]) { + al = _enginePal[si+1]; + if (al > pal[si+1]) + al = 1; + else + al = -1; + _enginePal[si+1] += al; + } + + if (_enginePal[si+2] != pal[si+2]) { + al = _enginePal[si+2]; + if (al > pal[si+2]) + al = 1; + else + al = -1; + _enginePal[si+2] += al; + } + + } + + _vm->_gfx->setPalette(_enginePal); + g_system->delayMillis(20); + _vm->_gfx->updateScreen(); + + } + + waitUntilLeftClick(); + + return; +} + +void Parallaction_ns::_c_frankenstein(void *parm) { + + Gfx::Palette pal0; + Gfx::Palette pal1; + + for (uint16 i = 0; i <= BASE_PALETTE_COLORS; i++) { + pal0[(i+FIRST_BASE_COLOR)] = _vm->_gfx->_palette[i]; + pal0[(i+FIRST_BASE_COLOR)*3+1] = 0; + pal0[(i+FIRST_BASE_COLOR)*3+2] = 0; + + pal1[(i+FIRST_BASE_COLOR)*3+1] = 0; + pal1[(i+FIRST_BASE_COLOR)*3+2] = 0; + } + + for (uint16 _di = 0; _di < 30; _di++) { + g_system->delayMillis(20); + _vm->_gfx->setPalette(pal0, FIRST_BASE_COLOR, BASE_PALETTE_COLORS); + _vm->_gfx->updateScreen(); + g_system->delayMillis(20); + _vm->_gfx->setPalette(pal1, FIRST_BASE_COLOR, BASE_PALETTE_COLORS); + _vm->_gfx->updateScreen(); + } + + _vm->_gfx->setPalette(_vm->_gfx->_palette); + _vm->_gfx->updateScreen(); + + return; +} + + +void Parallaction_ns::_c_finito(void *parm) { + + const char **v8C = endMsg0; + const char **v7C = endMsg1; + const char **v6C = endMsg2; + const char **v5C = endMsg3; + const char **v4C = endMsg4; + const char **v3C = endMsg5; + const char **v2C = endMsg6; + const char **v1C = endMsg7; + + Common::File stream; + + stream.open(_vm->_characterName, Common::File::kFileWriteMode); + if (stream.isOpen()) + stream.close(); + + Common::File streamDino, streamDough, streamDonna; + + streamDino.open("dino"); + streamDough.open("dough"); + streamDonna.open("donna"); + + bool gameCompleted = streamDino.isOpen() && streamDough.isOpen() && streamDonna.isOpen(); + + streamDino.close(); + streamDough.close(); + streamDonna.close(); + + cleanInventory(); + + _vm->_gfx->setPalette(_vm->_gfx->_palette); + + if (gameCompleted) { + _vm->_gfx->setFont(kFontMenu); + _vm->_gfx->displayCenteredString(70, v4C[_language]); + _vm->_gfx->displayCenteredString(100, v3C[_language]); + _vm->_gfx->displayCenteredString(130, v2C[_language]); + _vm->_gfx->displayCenteredString(160, v1C[_language]); + + _vm->_gfx->updateScreen(); + waitUntilLeftClick(); + + strcpy(_vm->_location._name, "estgrotta.drki"); + + _engineFlags |= kEngineChangeLocation; + } else { + _vm->_gfx->setFont(kFontMenu); + _vm->_gfx->displayCenteredString(70, v8C[_language]); + _vm->_gfx->displayCenteredString(100, v7C[_language]); + _vm->_gfx->displayCenteredString(130, v6C[_language]); + _vm->_gfx->displayCenteredString(160, v5C[_language]); + + _vm->_gfx->updateScreen(); + waitUntilLeftClick(); + + _vm->_menu->selectCharacter(); + } + + // this code saves main character animation from being removed from the following code + _vm->_animations.remove(&_vm->_char._ani); + _vm->_locationNames[0][0] = '\0'; + _vm->_numLocations = 0; + _commandFlags = 0; + + // this flag tells freeZones to unconditionally remove *all* Zones + _engineFlags |= kEngineQuit; + + // TODO (LIST): this sequence should be just _zones.clear() + _vm->freeZones(); + + // TODO (LIST): this sequence should be just _animations.clear() + _vm->freeAnimations(); + + // this dangerous flag can now be cleared + _engineFlags &= ~kEngineQuit; + + // main character animation is restored + _vm->_animations.push_front(&_vm->_char._ani); + _score = 0; + + return; +} + +void Parallaction_ns::_c_ridux(void *parm) { + _vm->changeCharacter(_minidinoName); + return; +} + +void Parallaction_ns::_c_testResult(void *parm) { + _vm->_gfx->swapBuffers(); + + _vm->_disk->selectArchive("disk1"); + _vm->parseLocation("common"); + + _vm->_gfx->setFont(kFontMenu); + + _vm->_gfx->displayCenteredString(38, _slideText[0]); + _vm->_gfx->displayCenteredString(58, _slideText[1]); + + _vm->_gfx->copyScreen(Gfx::kBitFront, Gfx::kBitBack); + _vm->_gfx->copyScreen(Gfx::kBitFront, Gfx::kBit2); + + return; +} + +void Parallaction_ns::_c_offSound(void*) { + _vm->_soundMan->stopSfx(0); + _vm->_soundMan->stopSfx(1); + _vm->_soundMan->stopSfx(2); + _vm->_soundMan->stopSfx(3); +} + +void Parallaction_ns::_c_startMusic(void*) { + _vm->_soundMan->playMusic(); +} + +void Parallaction_ns::_c_closeMusic(void*) { + _vm->_soundMan->stopMusic(); +} + +/* + intro callables +*/ + +void Parallaction_ns::_c_startIntro(void *parm) { + _rightHandAnim = _vm->findAnimation("righthand"); + + if (_vm->getPlatform() == Common::kPlatformPC) { + _vm->_soundMan->setMusicFile("intro"); + _vm->_soundMan->playMusic(); + } + + _engineFlags |= kEngineBlockInput; + + return; +} + +void Parallaction_ns::_c_endIntro(void *parm) { + + _vm->_gfx->setFont(kFontMenu); + + debugC(1, kDebugLocation, "endIntro()"); + + for (uint16 _si = 0; _si < 6; _si++) { + _vm->_gfx->displayCenteredString(80, _credits[_si]._role); + _vm->_gfx->displayCenteredString(100, _credits[_si]._name); + + _vm->_gfx->updateScreen(); + + for (uint16 v2 = 0; v2 < 100; v2++) { + _mouseButtons = kMouseNone; + _vm->updateInput(); + if (_mouseButtons == kMouseLeftUp) + break; + + _vm->waitTime( 1 ); + } + + _vm->_gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront); + } + debugC(1, kDebugLocation, "endIntro(): done showing credits"); + + if ((_vm->getFeatures() & GF_DEMO) == 0) { + _vm->_gfx->displayCenteredString(80, "CLICK MOUSE BUTTON TO START"); + _vm->_gfx->updateScreen(); + + waitUntilLeftClick(); + + _engineFlags &= ~kEngineBlockInput; + _vm->_menu->selectCharacter(); + } else { + waitUntilLeftClick(); + } + + return; +} + +void Parallaction_ns::_c_moveSheet(void *parm) { + + static uint16 x = 319; + + if (x > 66) + x -= 16; + + Common::Rect r; + + r.left = x; + r.top = 47; + r.right = (x + 32 > 319) ? 319 : (x + 32); + r.bottom = 199; + _vm->_gfx->floodFill(Gfx::kBitBack, r, 1); + _vm->_gfx->floodFill(Gfx::kBit2, r, 1); + + if (x >= 104) return; + + r.left = x+215; + r.top = 47; + r.right = (x + 247 > 319) ? 319 : (x + 247); + r.bottom = 199; + _vm->_gfx->floodFill(Gfx::kBitBack, r, 12); + _vm->_gfx->floodFill(Gfx::kBit2, r, 12); + + return; +} + +void plotPixel(int x, int y, int color, void *data) { + _vm->_gfx->plotMaskPixel(x, y, color); +} + +void Parallaction_ns::_c_sketch(void *parm) { + + static uint16 index = 1; + + uint16 newy = _rightHandPositions[2*index+1]; + uint16 newx = _rightHandPositions[2*index]; + + uint16 oldy = _rightHandPositions[2*(index-1)+1]; + uint16 oldx = _rightHandPositions[2*(index-1)]; + + Graphics::drawLine(oldx, oldy, newx, newy, 0, plotPixel, NULL); + + _rightHandAnim->_left = newx; + _rightHandAnim->_top = newy - 20; + + index++; + + return; +} + + + + +void Parallaction_ns::_c_shade(void *parm) { + + Common::Rect r( + _rightHandAnim->_left - 36, + _rightHandAnim->_top - 36, + _rightHandAnim->_left, + _rightHandAnim->_top + ); + + _vm->_gfx->fillMaskRect(r, 0); + + return; + +} + +void Parallaction_ns::_c_projector(void*) { +#ifdef HALFBRITE + static int dword_16032 = 0; + +// Bitmap bm; +// InitBitMap(&bm); + + if (dword_16032 != 0) { +/* // keep drawing spotlight in its final place + _vm->_gfx->flatBlitCnv(&scnv, 110, 25, Gfx::kBitFront); + BltBitMap(&bm, 0, 0, &_screen._bitMap, 110, 25, a3->??, a3->??, 0x20, 0x20); +*/ return; + } + + _vm->_gfx->setHalfbriteMode(true); +/* + // move spot light around the stage + int d7, d6; + for (d7 = 0; d7 < 150; d7++) { + + if (d7 < 100) { + int d1 = d7; + if (d1 < 0) + d1++; + + d1 >>= 1; + d6 = 50 - d1; + } else { + int d1 = d7 / 100; + if (d1 < 0) + d1++; + + d1 >>= 1; + d6 = d1; + } + + BltBitMap(&bm, 0, 0, &_screen._bitMap, d7+20, d6, a3->??, a3->??, 0x20, 0x20); + sub_1590C(d6 + a3->??); + BltBitMap(&bm, 0, 0, &_screen._bitMap, d7+20, d6, a3->??, a3->??, 0xFA, 0x20); + } + + for (d7 = 50; d7 > -10; d7--) { + BltBitMap(&bm, 0, 0, &_screen._bitMap, d7+120, d6, a3->??, a3->??, 0x20, 0x20); + sub_1590C(d6 + a3->??); + BltBitMap(&bm, 0, 0, &_screen._bitMap, d7+120, d6, a3->??, a3->??, 0xFA, 0x20); + } + + BltBitMap(&bm, 0, 0, &_screen._bitMap, d7+120, d6, a3->??, a3->??, 0x20, 0x20); + _vm->_gfx->flatBlitCnv(&scnv, d7+120, d6, Gfx::kBitFront); +*/ + + dword_16032 = 1; + return; +#endif +} + +void Parallaction_ns::_c_HBOff(void*) { +#ifdef HALFBRITE + _vm->_gfx->setHalfbriteMode(false); +#endif +} + +void Parallaction_ns::_c_HBOn(void*) { +#ifdef HALFBRITE + _vm->_gfx->setHalfbriteMode(true); +#endif +} + + +} // namespace Parallaction diff --git a/engines/parallaction/module.mk b/engines/parallaction/module.mk index 052ab64aff..5a7a3b9694 100644 --- a/engines/parallaction/module.mk +++ b/engines/parallaction/module.mk @@ -2,7 +2,7 @@ MODULE := engines/parallaction MODULE_OBJS := \ animation.o \ - callables.o \ + callables_ns.o \ commands.o \ debug.o \ detection.o \ diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h index 1bc1cc63bd..7a4e076675 100644 --- a/engines/parallaction/parallaction.h +++ b/engines/parallaction/parallaction.h @@ -497,6 +497,42 @@ public: private: void initResources(); + typedef void (Parallaction_ns::*Callable)(void*); + + // common callables + void _c_play_boogie(void*); + void _c_startIntro(void*); + void _c_endIntro(void*); + void _c_moveSheet(void*); + void _c_sketch(void*); + void _c_shade(void*); + void _c_score(void*); + void _c_fade(void*); + void _c_moveSarc(void*); + void _c_contaFoglie(void*); + void _c_zeroFoglie(void*); + void _c_trasformata(void*); + void _c_offMouse(void*); + void _c_onMouse(void*); + void _c_setMask(void*); + void _c_endComment(void*); + void _c_frankenstein(void*); + void _c_finito(void*); + void _c_ridux(void*); + void _c_testResult(void*); + + // dos specific callables + void _c_null(void*); + + // amiga specific callables + void _c_projector(void*); + void _c_HBOff(void*); + void _c_offSound(void*); + void _c_startMusic(void*); + void _c_closeMusic(void*); + void _c_HBOn(void*); + + Callable _callables[25]; }; class Parallaction_br : public Parallaction { diff --git a/engines/parallaction/parallaction_ns.cpp b/engines/parallaction/parallaction_ns.cpp index e971701d6f..742f2c860a 100644 --- a/engines/parallaction/parallaction_ns.cpp +++ b/engines/parallaction/parallaction_ns.cpp @@ -69,9 +69,10 @@ int Parallaction_ns::init() { } void Parallaction_ns::callFunction(uint index, void* parm) { + printf("index = %i\n", index); assert(index >= 0 && index < 25); // magic value 25 is maximum # of callables for Nippon Safes - _callables[index](parm); + (this->*_callables[index])(parm); } diff --git a/engines/parallaction/staticres.cpp b/engines/parallaction/staticres.cpp index 567b43785a..ec94f56916 100644 --- a/engines/parallaction/staticres.cpp +++ b/engines/parallaction/staticres.cpp @@ -472,40 +472,6 @@ const char *_audioCommandsNamesRes_br[] = { "loop" }; -typedef void (*callable)(void*); - - -void _c_play_boogie(void*); -void _c_startIntro(void*); -void _c_endIntro(void*); -void _c_moveSheet(void*); -void _c_sketch(void*); -void _c_shade(void*); -void _c_score(void*); -void _c_fade(void*); -void _c_moveSarc(void*); -void _c_contaFoglie(void*); -void _c_zeroFoglie(void*); -void _c_trasformata(void*); -void _c_offMouse(void*); -void _c_onMouse(void*); -void _c_setMask(void*); -void _c_endComment(void*); -void _c_frankenstein(void*); -void _c_finito(void*); -void _c_ridux(void*); -void _c_testResult(void*); -void _c_null(void*); - -void _c_projector(void*); -void _c_HBOff(void*); -void _c_offSound(void*); -void _c_startMusic(void*); -void _c_closeMusic(void*); -void _c_HBOn(void*); - -callable _callables[25]; - const char *_dinoName = "dino"; const char *_donnaName = "donna"; const char *_doughName = "dough"; @@ -516,6 +482,7 @@ const char *_minidonnaName = "minidonna"; const char *_minidoughName = "minidough"; const char *_minidrkiName = "minidrki"; +#define CALLABLE_NS(x) &Parallaction_ns::x void Parallaction_ns::initResources() { @@ -535,57 +502,57 @@ void Parallaction_ns::initResources() { _localFlagNames->addData("visited"); if (getPlatform() == Common::kPlatformPC) { - _callables[0] = _c_play_boogie; - _callables[1] = _c_play_boogie; - _callables[2] = _c_startIntro; - _callables[3] = _c_endIntro; - _callables[4] = _c_moveSheet; - _callables[5] = _c_sketch; - _callables[6] = _c_shade; - _callables[7] = _c_score; - _callables[8] = _c_null; - _callables[9] = _c_null; - _callables[10] = _c_null; - _callables[11] = _c_fade; - _callables[12] = _c_play_boogie; - _callables[13] = _c_moveSarc; - _callables[14] = _c_contaFoglie; - _callables[15] = _c_zeroFoglie; - _callables[16] = _c_trasformata; - _callables[17] = _c_offMouse; - _callables[18] = _c_onMouse; - _callables[19] = _c_setMask; - _callables[20] = _c_endComment; - _callables[21] = _c_frankenstein; - _callables[22] = _c_finito; - _callables[23] = _c_ridux; - _callables[24] = _c_testResult; + _callables[0] = CALLABLE_NS(_c_play_boogie); + _callables[1] = CALLABLE_NS(_c_play_boogie); + _callables[2] = CALLABLE_NS(_c_startIntro); + _callables[3] = CALLABLE_NS(_c_endIntro); + _callables[4] = CALLABLE_NS(_c_moveSheet); + _callables[5] = CALLABLE_NS(_c_sketch); + _callables[6] = CALLABLE_NS(_c_shade); + _callables[7] = CALLABLE_NS(_c_score); + _callables[8] = CALLABLE_NS(_c_null); + _callables[9] = CALLABLE_NS(_c_null); + _callables[10] = CALLABLE_NS(_c_null); + _callables[11] = CALLABLE_NS(_c_fade); + _callables[12] = CALLABLE_NS(_c_play_boogie); + _callables[13] = CALLABLE_NS(_c_moveSarc); + _callables[14] = CALLABLE_NS(_c_contaFoglie); + _callables[15] = CALLABLE_NS(_c_zeroFoglie); + _callables[16] = CALLABLE_NS(_c_trasformata); + _callables[17] = CALLABLE_NS(_c_offMouse); + _callables[18] = CALLABLE_NS(_c_onMouse); + _callables[19] = CALLABLE_NS(_c_setMask); + _callables[20] = CALLABLE_NS(_c_endComment); + _callables[21] = CALLABLE_NS(_c_frankenstein); + _callables[22] = CALLABLE_NS(_c_finito); + _callables[23] = CALLABLE_NS(_c_ridux); + _callables[24] = CALLABLE_NS(_c_testResult); } else { - _callables[0] = _c_projector; - _callables[1] = _c_HBOff; - _callables[2] = _c_startIntro; - _callables[3] = _c_endIntro; - _callables[4] = _c_moveSheet; - _callables[5] = _c_sketch; - _callables[6] = _c_shade; - _callables[7] = _c_score; - _callables[8] = _c_offSound; - _callables[9] = _c_startMusic; - _callables[10] = _c_closeMusic; - _callables[11] = _c_fade; - _callables[12] = _c_HBOn; - _callables[13] = _c_moveSarc; - _callables[14] = _c_contaFoglie; - _callables[15] = _c_zeroFoglie; - _callables[16] = _c_trasformata; - _callables[17] = _c_offMouse; - _callables[18] = _c_onMouse; - _callables[19] = _c_setMask; - _callables[20] = _c_endComment; - _callables[21] = _c_frankenstein; - _callables[22] = _c_finito; - _callables[23] = _c_ridux; - _callables[24] = _c_testResult; + _callables[0] = CALLABLE_NS(_c_projector); + _callables[1] = CALLABLE_NS(_c_HBOff); + _callables[2] = CALLABLE_NS(_c_startIntro); + _callables[3] = CALLABLE_NS(_c_endIntro); + _callables[4] = CALLABLE_NS(_c_moveSheet); + _callables[5] = CALLABLE_NS(_c_sketch); + _callables[6] = CALLABLE_NS(_c_shade); + _callables[7] = CALLABLE_NS(_c_score); + _callables[8] = CALLABLE_NS(_c_offSound); + _callables[9] = CALLABLE_NS(_c_startMusic); + _callables[10] = CALLABLE_NS(_c_closeMusic); + _callables[11] = CALLABLE_NS(_c_fade); + _callables[12] = CALLABLE_NS(_c_HBOn); + _callables[13] = CALLABLE_NS(_c_moveSarc); + _callables[14] = CALLABLE_NS(_c_contaFoglie); + _callables[15] = CALLABLE_NS(_c_zeroFoglie); + _callables[16] = CALLABLE_NS(_c_trasformata); + _callables[17] = CALLABLE_NS(_c_offMouse); + _callables[18] = CALLABLE_NS(_c_onMouse); + _callables[19] = CALLABLE_NS(_c_setMask); + _callables[20] = CALLABLE_NS(_c_endComment); + _callables[21] = CALLABLE_NS(_c_frankenstein); + _callables[22] = CALLABLE_NS(_c_finito); + _callables[23] = CALLABLE_NS(_c_ridux); + _callables[24] = CALLABLE_NS(_c_testResult); } } -- cgit v1.2.3 From ae461cebd6d7ae7b3d4272da30529dc035b196ff Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Sun, 29 Jul 2007 17:06:23 +0000 Subject: Cleanup. svn-id: r28303 --- engines/parallaction/callables_ns.cpp | 210 +++++++++++++++++----------------- 1 file changed, 103 insertions(+), 107 deletions(-) (limited to 'engines') diff --git a/engines/parallaction/callables_ns.cpp b/engines/parallaction/callables_ns.cpp index b0312bb714..de5e1e9862 100644 --- a/engines/parallaction/callables_ns.cpp +++ b/engines/parallaction/callables_ns.cpp @@ -42,10 +42,9 @@ namespace Parallaction { game callables data members */ -// there three guys are extern'd somewhere -Zone *_moveSarcZone0 = NULL; -int16 _introSarcData1 = 0; -Zone *_moveSarcZone1 = NULL; +static Zone *_moveSarcZone0 = NULL; +static int16 _introSarcData1 = 0; +static Zone *_moveSarcZone1 = NULL; // part completion messages static const char *endMsg0[] = {"COMPLIMENTI!", "BRAVO!", "CONGRATULATIONS!", "PRIMA!"}; @@ -186,8 +185,8 @@ void Parallaction_ns::_c_play_boogie(void *parm) { return; flag = 0; - _vm->_soundMan->setMusicFile("boogie2"); - _vm->_soundMan->playMusic(); + _soundMan->setMusicFile("boogie2"); + _soundMan->playMusic(); return; } @@ -200,17 +199,17 @@ void Parallaction_ns::_c_score(void *parm) { void Parallaction_ns::_c_fade(void *parm) { - _vm->_gfx->setBlackPalette(); + _gfx->setBlackPalette(); Gfx::Palette pal; memset(pal, 0, sizeof(Gfx::Palette)); for (uint16 _di = 0; _di < 64; _di++) { - _vm->_gfx->fadePalette(pal); - _vm->_gfx->setPalette(pal); + _gfx->fadePalette(pal); + _gfx->setPalette(pal); g_system->delayMillis(20); - _vm->_gfx->updateScreen(); + _gfx->updateScreen(); } return; @@ -227,21 +226,21 @@ void Parallaction_ns::_c_moveSarc(void *parm) { _introSarcData2 = 0; if (_moveSarcZones[0] == NULL) { - _moveSarcZones[0] = _vm->findZone("sarc1"); - _moveSarcZones[1] = _vm->findZone("sarc2"); - _moveSarcZones[2] = _vm->findZone("sarc3"); - _moveSarcZones[3] = _vm->findZone("sarc4"); - _moveSarcZones[4] = _vm->findZone("sarc5"); + _moveSarcZones[0] = findZone("sarc1"); + _moveSarcZones[1] = findZone("sarc2"); + _moveSarcZones[2] = findZone("sarc3"); + _moveSarcZones[3] = findZone("sarc4"); + _moveSarcZones[4] = findZone("sarc5"); - _moveSarcExaZones[0] = _vm->findZone("sarc1exa"); - _moveSarcExaZones[1] = _vm->findZone("sarc2exa"); - _moveSarcExaZones[2] = _vm->findZone("sarc3exa"); - _moveSarcExaZones[3] = _vm->findZone("sarc4exa"); - _moveSarcExaZones[4] = _vm->findZone("sarc5exa"); + _moveSarcExaZones[0] = findZone("sarc1exa"); + _moveSarcExaZones[1] = findZone("sarc2exa"); + _moveSarcExaZones[2] = findZone("sarc3exa"); + _moveSarcExaZones[3] = findZone("sarc4exa"); + _moveSarcExaZones[4] = findZone("sarc5exa"); } - a = _vm->findAnimation("sposta"); + a = findAnimation("sposta"); _moveSarcZone1 = (Zone*)parm; @@ -282,10 +281,10 @@ void Parallaction_ns::_c_moveSarc(void *parm) { _moveSarcZones[3]->_left == 134 && _moveSarcZones[4]->_left == 167) { - a = _vm->findAnimation("finito"); + a = findAnimation("finito"); a->_flags |= (kFlagsActive | kFlagsActing); - _localFlags[_vm->_currentLocationIndex] |= 0x20; // GROSS HACK: activates 'finito' flag in dinoit_museo.loc + _localFlags[_currentLocationIndex] |= 0x20; // GROSS HACK: activates 'finito' flag in dinoit_museo.loc } return; @@ -317,14 +316,14 @@ void Parallaction_ns::_c_trasformata(void *parm) { } void Parallaction_ns::_c_offMouse(void *parm) { - _vm->showCursor(false); + showCursor(false); _engineFlags |= kEngineBlockInput; return; } void Parallaction_ns::_c_onMouse(void *parm) { _engineFlags &= ~kEngineBlockInput; - _vm->showCursor(true); + showCursor(true); return; } @@ -332,14 +331,14 @@ void Parallaction_ns::_c_onMouse(void *parm) { void Parallaction_ns::_c_setMask(void *parm) { - _vm->_gfx->intGrottaHackMask(); + _gfx->intGrottaHackMask(); return; } void Parallaction_ns::_c_endComment(void *param) { - byte* _enginePal = _vm->_gfx->_palette; + byte* _enginePal = _gfx->_palette; Gfx::Palette pal; uint32 si; @@ -371,20 +370,20 @@ void Parallaction_ns::_c_endComment(void *param) { } int16 w = 0, h = 0; - _vm->_gfx->getStringExtent(_vm->_location._endComment, 130, &w, &h); + _gfx->getStringExtent(_location._endComment, 130, &w, &h); Common::Rect r(w+5, h+5); r.moveTo(5, 5); - _vm->_gfx->floodFill(Gfx::kBitFront, r, 0); + _gfx->floodFill(Gfx::kBitFront, r, 0); r.setWidth(w+3); r.setHeight(h+3); r.moveTo(7, 7); - _vm->_gfx->floodFill(Gfx::kBitFront, r, 1); + _gfx->floodFill(Gfx::kBitFront, r, 1); - _vm->_gfx->setFont(kFontDialogue); - _vm->_gfx->displayWrappedString(_vm->_location._endComment, 3, 5, 0, 130); - _vm->_gfx->updateScreen(); + _gfx->setFont(kFontDialogue); + _gfx->displayWrappedString(_location._endComment, 3, 5, 0, 130); + _gfx->updateScreen(); uint32 di = 0; for (di = 0; di < PALETTE_COLORS; di++) { @@ -421,9 +420,9 @@ void Parallaction_ns::_c_endComment(void *param) { } - _vm->_gfx->setPalette(_enginePal); + _gfx->setPalette(_enginePal); g_system->delayMillis(20); - _vm->_gfx->updateScreen(); + _gfx->updateScreen(); } @@ -438,7 +437,7 @@ void Parallaction_ns::_c_frankenstein(void *parm) { Gfx::Palette pal1; for (uint16 i = 0; i <= BASE_PALETTE_COLORS; i++) { - pal0[(i+FIRST_BASE_COLOR)] = _vm->_gfx->_palette[i]; + pal0[(i+FIRST_BASE_COLOR)] = _gfx->_palette[i]; pal0[(i+FIRST_BASE_COLOR)*3+1] = 0; pal0[(i+FIRST_BASE_COLOR)*3+2] = 0; @@ -448,15 +447,15 @@ void Parallaction_ns::_c_frankenstein(void *parm) { for (uint16 _di = 0; _di < 30; _di++) { g_system->delayMillis(20); - _vm->_gfx->setPalette(pal0, FIRST_BASE_COLOR, BASE_PALETTE_COLORS); - _vm->_gfx->updateScreen(); + _gfx->setPalette(pal0, FIRST_BASE_COLOR, BASE_PALETTE_COLORS); + _gfx->updateScreen(); g_system->delayMillis(20); - _vm->_gfx->setPalette(pal1, FIRST_BASE_COLOR, BASE_PALETTE_COLORS); - _vm->_gfx->updateScreen(); + _gfx->setPalette(pal1, FIRST_BASE_COLOR, BASE_PALETTE_COLORS); + _gfx->updateScreen(); } - _vm->_gfx->setPalette(_vm->_gfx->_palette); - _vm->_gfx->updateScreen(); + _gfx->setPalette(_gfx->_palette); + _gfx->updateScreen(); return; } @@ -475,7 +474,7 @@ void Parallaction_ns::_c_finito(void *parm) { Common::File stream; - stream.open(_vm->_characterName, Common::File::kFileWriteMode); + stream.open(_characterName, Common::File::kFileWriteMode); if (stream.isOpen()) stream.close(); @@ -493,94 +492,91 @@ void Parallaction_ns::_c_finito(void *parm) { cleanInventory(); - _vm->_gfx->setPalette(_vm->_gfx->_palette); + _gfx->setPalette(_gfx->_palette); if (gameCompleted) { - _vm->_gfx->setFont(kFontMenu); - _vm->_gfx->displayCenteredString(70, v4C[_language]); - _vm->_gfx->displayCenteredString(100, v3C[_language]); - _vm->_gfx->displayCenteredString(130, v2C[_language]); - _vm->_gfx->displayCenteredString(160, v1C[_language]); + _gfx->setFont(kFontMenu); + _gfx->displayCenteredString(70, v4C[_language]); + _gfx->displayCenteredString(100, v3C[_language]); + _gfx->displayCenteredString(130, v2C[_language]); + _gfx->displayCenteredString(160, v1C[_language]); - _vm->_gfx->updateScreen(); + _gfx->updateScreen(); waitUntilLeftClick(); - strcpy(_vm->_location._name, "estgrotta.drki"); + strcpy(_location._name, "estgrotta.drki"); _engineFlags |= kEngineChangeLocation; } else { - _vm->_gfx->setFont(kFontMenu); - _vm->_gfx->displayCenteredString(70, v8C[_language]); - _vm->_gfx->displayCenteredString(100, v7C[_language]); - _vm->_gfx->displayCenteredString(130, v6C[_language]); - _vm->_gfx->displayCenteredString(160, v5C[_language]); + _gfx->setFont(kFontMenu); + _gfx->displayCenteredString(70, v8C[_language]); + _gfx->displayCenteredString(100, v7C[_language]); + _gfx->displayCenteredString(130, v6C[_language]); + _gfx->displayCenteredString(160, v5C[_language]); - _vm->_gfx->updateScreen(); + _gfx->updateScreen(); waitUntilLeftClick(); - _vm->_menu->selectCharacter(); + _menu->selectCharacter(); } // this code saves main character animation from being removed from the following code - _vm->_animations.remove(&_vm->_char._ani); - _vm->_locationNames[0][0] = '\0'; - _vm->_numLocations = 0; + _animations.remove(&_char._ani); + _locationNames[0][0] = '\0'; + _numLocations = 0; _commandFlags = 0; // this flag tells freeZones to unconditionally remove *all* Zones _engineFlags |= kEngineQuit; - // TODO (LIST): this sequence should be just _zones.clear() - _vm->freeZones(); - - // TODO (LIST): this sequence should be just _animations.clear() - _vm->freeAnimations(); + freeZones(); + freeAnimations(); // this dangerous flag can now be cleared _engineFlags &= ~kEngineQuit; // main character animation is restored - _vm->_animations.push_front(&_vm->_char._ani); + _animations.push_front(&_char._ani); _score = 0; return; } void Parallaction_ns::_c_ridux(void *parm) { - _vm->changeCharacter(_minidinoName); + changeCharacter(_minidinoName); return; } void Parallaction_ns::_c_testResult(void *parm) { - _vm->_gfx->swapBuffers(); + _gfx->swapBuffers(); - _vm->_disk->selectArchive("disk1"); - _vm->parseLocation("common"); + _disk->selectArchive("disk1"); + parseLocation("common"); - _vm->_gfx->setFont(kFontMenu); + _gfx->setFont(kFontMenu); - _vm->_gfx->displayCenteredString(38, _slideText[0]); - _vm->_gfx->displayCenteredString(58, _slideText[1]); + _gfx->displayCenteredString(38, _slideText[0]); + _gfx->displayCenteredString(58, _slideText[1]); - _vm->_gfx->copyScreen(Gfx::kBitFront, Gfx::kBitBack); - _vm->_gfx->copyScreen(Gfx::kBitFront, Gfx::kBit2); + _gfx->copyScreen(Gfx::kBitFront, Gfx::kBitBack); + _gfx->copyScreen(Gfx::kBitFront, Gfx::kBit2); return; } void Parallaction_ns::_c_offSound(void*) { - _vm->_soundMan->stopSfx(0); - _vm->_soundMan->stopSfx(1); - _vm->_soundMan->stopSfx(2); - _vm->_soundMan->stopSfx(3); + _soundMan->stopSfx(0); + _soundMan->stopSfx(1); + _soundMan->stopSfx(2); + _soundMan->stopSfx(3); } void Parallaction_ns::_c_startMusic(void*) { - _vm->_soundMan->playMusic(); + _soundMan->playMusic(); } void Parallaction_ns::_c_closeMusic(void*) { - _vm->_soundMan->stopMusic(); + _soundMan->stopMusic(); } /* @@ -588,11 +584,11 @@ void Parallaction_ns::_c_closeMusic(void*) { */ void Parallaction_ns::_c_startIntro(void *parm) { - _rightHandAnim = _vm->findAnimation("righthand"); + _rightHandAnim = findAnimation("righthand"); - if (_vm->getPlatform() == Common::kPlatformPC) { - _vm->_soundMan->setMusicFile("intro"); - _vm->_soundMan->playMusic(); + if (getPlatform() == Common::kPlatformPC) { + _soundMan->setMusicFile("intro"); + _soundMan->playMusic(); } _engineFlags |= kEngineBlockInput; @@ -602,37 +598,37 @@ void Parallaction_ns::_c_startIntro(void *parm) { void Parallaction_ns::_c_endIntro(void *parm) { - _vm->_gfx->setFont(kFontMenu); + _gfx->setFont(kFontMenu); debugC(1, kDebugLocation, "endIntro()"); for (uint16 _si = 0; _si < 6; _si++) { - _vm->_gfx->displayCenteredString(80, _credits[_si]._role); - _vm->_gfx->displayCenteredString(100, _credits[_si]._name); + _gfx->displayCenteredString(80, _credits[_si]._role); + _gfx->displayCenteredString(100, _credits[_si]._name); - _vm->_gfx->updateScreen(); + _gfx->updateScreen(); for (uint16 v2 = 0; v2 < 100; v2++) { _mouseButtons = kMouseNone; - _vm->updateInput(); + updateInput(); if (_mouseButtons == kMouseLeftUp) break; - _vm->waitTime( 1 ); + waitTime( 1 ); } - _vm->_gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront); + _gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront); } debugC(1, kDebugLocation, "endIntro(): done showing credits"); - if ((_vm->getFeatures() & GF_DEMO) == 0) { - _vm->_gfx->displayCenteredString(80, "CLICK MOUSE BUTTON TO START"); - _vm->_gfx->updateScreen(); + if ((getFeatures() & GF_DEMO) == 0) { + _gfx->displayCenteredString(80, "CLICK MOUSE BUTTON TO START"); + _gfx->updateScreen(); waitUntilLeftClick(); _engineFlags &= ~kEngineBlockInput; - _vm->_menu->selectCharacter(); + _menu->selectCharacter(); } else { waitUntilLeftClick(); } @@ -653,8 +649,8 @@ void Parallaction_ns::_c_moveSheet(void *parm) { r.top = 47; r.right = (x + 32 > 319) ? 319 : (x + 32); r.bottom = 199; - _vm->_gfx->floodFill(Gfx::kBitBack, r, 1); - _vm->_gfx->floodFill(Gfx::kBit2, r, 1); + _gfx->floodFill(Gfx::kBitBack, r, 1); + _gfx->floodFill(Gfx::kBit2, r, 1); if (x >= 104) return; @@ -662,8 +658,8 @@ void Parallaction_ns::_c_moveSheet(void *parm) { r.top = 47; r.right = (x + 247 > 319) ? 319 : (x + 247); r.bottom = 199; - _vm->_gfx->floodFill(Gfx::kBitBack, r, 12); - _vm->_gfx->floodFill(Gfx::kBit2, r, 12); + _gfx->floodFill(Gfx::kBitBack, r, 12); + _gfx->floodFill(Gfx::kBit2, r, 12); return; } @@ -704,7 +700,7 @@ void Parallaction_ns::_c_shade(void *parm) { _rightHandAnim->_top ); - _vm->_gfx->fillMaskRect(r, 0); + _gfx->fillMaskRect(r, 0); return; @@ -719,12 +715,12 @@ void Parallaction_ns::_c_projector(void*) { if (dword_16032 != 0) { /* // keep drawing spotlight in its final place - _vm->_gfx->flatBlitCnv(&scnv, 110, 25, Gfx::kBitFront); + _gfx->flatBlitCnv(&scnv, 110, 25, Gfx::kBitFront); BltBitMap(&bm, 0, 0, &_screen._bitMap, 110, 25, a3->??, a3->??, 0x20, 0x20); */ return; } - _vm->_gfx->setHalfbriteMode(true); + _gfx->setHalfbriteMode(true); /* // move spot light around the stage int d7, d6; @@ -758,7 +754,7 @@ void Parallaction_ns::_c_projector(void*) { } BltBitMap(&bm, 0, 0, &_screen._bitMap, d7+120, d6, a3->??, a3->??, 0x20, 0x20); - _vm->_gfx->flatBlitCnv(&scnv, d7+120, d6, Gfx::kBitFront); + _gfx->flatBlitCnv(&scnv, d7+120, d6, Gfx::kBitFront); */ dword_16032 = 1; @@ -768,13 +764,13 @@ void Parallaction_ns::_c_projector(void*) { void Parallaction_ns::_c_HBOff(void*) { #ifdef HALFBRITE - _vm->_gfx->setHalfbriteMode(false); + _gfx->setHalfbriteMode(false); #endif } void Parallaction_ns::_c_HBOn(void*) { #ifdef HALFBRITE - _vm->_gfx->setHalfbriteMode(true); + _gfx->setHalfbriteMode(true); #endif } -- cgit v1.2.3 From e5808ea2f28a51bdf4317b1498aa58ef14f7df53 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 29 Jul 2007 17:10:51 +0000 Subject: Fixed some warnings svn-id: r28304 --- engines/kyra/kyra_v2.cpp | 2 +- engines/kyra/screen_v2.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/kyra/kyra_v2.cpp b/engines/kyra/kyra_v2.cpp index 3e08ea43c6..e27f31b691 100644 --- a/engines/kyra/kyra_v2.cpp +++ b/engines/kyra/kyra_v2.cpp @@ -901,7 +901,7 @@ int KyraEngine_v2::inputSceneChange(int x, int y, int unk1, int unk2) { _timer->disable(5); if (wayLength != 0 && wayLength != 0x7D00) - refreshNPC = trySceneChange(_movFacingTable, unk1, unk2); + refreshNPC = (trySceneChange(_movFacingTable, unk1, unk2) != 0); //XXX diff --git a/engines/kyra/screen_v2.cpp b/engines/kyra/screen_v2.cpp index 3ad69818c6..83c75585a8 100644 --- a/engines/kyra/screen_v2.cpp +++ b/engines/kyra/screen_v2.cpp @@ -417,7 +417,7 @@ void Screen_v2::drawShape(uint8 page, const uint8 *shape, int x, int y, int sd, uint16 sx1 = getScreenDim(sd)->sx << 3; uint16 sy1 = getScreenDim(sd)->sy; - uint16 sx2 = sx1 + getScreenDim(sd)->w << 3; + uint16 sx2 = sx1 + (getScreenDim(sd)->w << 3); uint16 sy2 = sy1 + getScreenDim(sd)->h; if (flags & 0x10) { x += sx1; -- cgit v1.2.3 From 65abeadcf60f730856f1222573189f2605507729 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 29 Jul 2007 17:21:21 +0000 Subject: Fixed bug in Resource::getFileHandle. svn-id: r28306 --- engines/kyra/resource.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/kyra/resource.cpp b/engines/kyra/resource.cpp index fa333bf8bd..b8d7eb3f64 100644 --- a/engines/kyra/resource.cpp +++ b/engines/kyra/resource.cpp @@ -220,8 +220,11 @@ uint8 *Resource::fileData(const char *file, uint32 *size) const { bool Resource::getFileHandle(const char *file, uint32 *size, Common::File &filehandle) { filehandle.close(); - if (filehandle.open(file)) + if (filehandle.open(file)) { + if (size) + *size = filehandle.size(); return true; + } uint fileHash = Common::hashit_lower(file); for (ResIterator start = _pakfiles.begin() ;start != _pakfiles.end(); ++start) { @@ -229,12 +232,14 @@ bool Resource::getFileHandle(const char *file, uint32 *size, Common::File &fileh continue; if ((*start)->getFileHandle(fileHash, filehandle)) { - - *size = (*start)->getFileSize(fileHash); + uint32 tSize = (*start)->getFileSize(fileHash); - if (!(*size)) + if (!tSize) continue; + if (size) + *size = tSize; + return true; } } -- cgit v1.2.3 From 50537d3ae0a9d41f42419d1898941bac3160b6d4 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sun, 29 Jul 2007 17:37:08 +0000 Subject: Fixed some warnings svn-id: r28308 --- engines/kyra/scene_v2.cpp | 6 ++++-- engines/kyra/script_v2.cpp | 2 +- engines/parallaction/parallaction_ns.cpp | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/kyra/scene_v2.cpp b/engines/kyra/scene_v2.cpp index fbda1f8455..7863fa6638 100644 --- a/engines/kyra/scene_v2.cpp +++ b/engines/kyra/scene_v2.cpp @@ -689,11 +689,13 @@ int KyraEngine_v2::findWay(int x, int y, int toX, int toY, int *moveTable, int m x &= ~3; toX &= ~3; y &= ~1; toY &= ~1; int size = KyraEngine::findWay(x, y, toX, toY, moveTable, moveTableSize); - /*if (size) { + if (size) { +/* int temp = pathfinderUnk1(moveTable); temp = pathfinderUnk3(temp, x, y); pathfinderUnk5(moveTable, temp, x, y, moveTableSize); - }*/ +*/ + } return getMoveTableSize(moveTable); } diff --git a/engines/kyra/script_v2.cpp b/engines/kyra/script_v2.cpp index ce1cd99e03..3e1bc4ed2f 100644 --- a/engines/kyra/script_v2.cpp +++ b/engines/kyra/script_v2.cpp @@ -281,7 +281,7 @@ int KyraEngine_v2::o2_drawSceneShapeOnPage(ScriptState *script) { } int KyraEngine_v2::o2_restoreBackBuffer(ScriptState *script) { - debugC(3, kDebugLevelScriptFuncs, "o2_restoreBackBuffer(%p) (%d, %d)", (const void *)script, stackPos(0)); + debugC(3, kDebugLevelScriptFuncs, "o2_restoreBackBuffer(%p) (%d)", (const void *)script, stackPos(0)); int disable = stackPos(0); int oldState = 0; if (disable) { diff --git a/engines/parallaction/parallaction_ns.cpp b/engines/parallaction/parallaction_ns.cpp index 742f2c860a..e9030b0abb 100644 --- a/engines/parallaction/parallaction_ns.cpp +++ b/engines/parallaction/parallaction_ns.cpp @@ -70,7 +70,7 @@ int Parallaction_ns::init() { void Parallaction_ns::callFunction(uint index, void* parm) { printf("index = %i\n", index); - assert(index >= 0 && index < 25); // magic value 25 is maximum # of callables for Nippon Safes + assert(index < 25); // magic value 25 is maximum # of callables for Nippon Safes (this->*_callables[index])(parm); } -- cgit v1.2.3 From 3e95cd9f53da15ce85a987a71512129c6b29182b Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sun, 29 Jul 2007 17:48:25 +0000 Subject: Fixing some warnings svn-id: r28309 --- engines/drascula/drascula.cpp | 104 ++++++++++++++++++++++-------------------- engines/drascula/drascula.h | 5 +- 2 files changed, 56 insertions(+), 53 deletions(-) (limited to 'engines') diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp index c5ecc22d31..2008c730f5 100644 --- a/engines/drascula/drascula.cpp +++ b/engines/drascula/drascula.cpp @@ -508,7 +508,7 @@ bucles: else menu_bar = 0; - key = getscan(); + byte key = getscan(); if (key == F1 && menu_scr == 0) { elige_verbo(1); cont_sv = 0; @@ -1325,7 +1325,7 @@ void DrasculaEngine::carga_escoba(const char *nom_fich) { chiquez = (float)(cerca-lejos) / (float)(suelo_y2 - suelo_y1); for (l = suelo_y1; l <= suelo_y2; l++) { - factor_red[l] = lejos + pequegnez; + factor_red[l] = (int)(lejos + pequegnez); pequegnez = pequegnez + chiquez; } @@ -1386,9 +1386,9 @@ void DrasculaEngine::mueve_cursor() { actualiza_refresco(); if (!strcmp(texto_nombre, "hacker") && hay_nombre == 1) { - if (color != ROJO && menu_scr == 0) + if (_color != ROJO && menu_scr == 0) color_abc(ROJO); - } else if (menu_scr == 0 && color != VERDE_CLARO) + } else if (menu_scr == 0 && _color != VERDE_CLARO) color_abc(VERDE_CLARO); if (hay_nombre == 1 && menu_scr == 0) centra_texto(texto_nombre, x_raton, y_raton); @@ -1791,7 +1791,7 @@ void DrasculaEngine::saves() { void DrasculaEngine::print_abc(const char *dicho, int x_pantalla, int y_pantalla) { int pos_texto[8]; - int i = 0, y_de_letra = 0, x_de_letra = 0, h, longitud; + int y_de_letra = 0, x_de_letra = 0, h, longitud; longitud = strlen(dicho); for (h = 0; h < longitud; h++) { @@ -2010,6 +2010,8 @@ void DrasculaEngine::delay(int ms) { } void DrasculaEngine::confirma_go() { + byte key; + color_abc(ROJO); refresca_pantalla(); centra_texto(SYS0, 160, 87); @@ -2028,6 +2030,8 @@ void DrasculaEngine::confirma_go() { } void DrasculaEngine::confirma_salir() { + byte key; + color_abc(ROJO); refresca_pantalla(); centra_texto(SYS1, 160, 87); @@ -2102,7 +2106,7 @@ void DrasculaEngine::FundeDelNegro(int VelocidadDeFundido) { } void DrasculaEngine::color_abc(int cl) { - color = cl; + _color = cl; if (cl == 0) { palJuego[254][0] = 0; @@ -2237,8 +2241,8 @@ void DrasculaEngine::comienza_sound(const char *fichero) { void DrasculaEngine::anima(const char *animacion, int FPS) { Common::File FileIn; - unsigned Org = 0, Des = 0, j, TotDes = 0; - int NFrames = 1, New = 1; + unsigned j; + int NFrames = 1; int cnt = 2; TimeMed = CLOCKS_PER_SEC / FPS; @@ -2278,7 +2282,7 @@ void DrasculaEngine::anima(const char *animacion, int FPS) { _system->updateScreen(); WaitForNext(TimeMed); cnt++; - key = getscan(); + byte key = getscan(); if (key == 0x01) term_int = 1; if (key != 0) @@ -2365,7 +2369,7 @@ bucless: pausa(3); - key = getscan(); + byte key = getscan(); if (key == ESC) term_int = 1; @@ -2488,7 +2492,7 @@ bucless: pausa(3); - key = getscan(); + byte key = getscan(); if (key == ESC) term_int = 1; if (key != 0) @@ -2562,7 +2566,7 @@ bucless: pausa(3); - key = getscan(); + byte key = getscan(); if (key == ESC) term_int = 1; if (key != 0) @@ -2637,7 +2641,7 @@ bucless: pausa(3); - key = getscan(); + byte key = getscan(); if (key == ESC) term_int = 1; if (key != 0) @@ -2690,7 +2694,7 @@ bucless: centra_texto(dicho, 156, 90); VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); - key = getscan(); + byte key = getscan(); if (key == ESC) term_int = 1; if (key != 0) @@ -2761,7 +2765,7 @@ bucless: pausa(3); - key = getscan(); + byte key = getscan(); if (key == ESC) term_int = 1; if (key != 0) @@ -2835,7 +2839,7 @@ bucless: pausa(3); - key = getscan(); + byte key = getscan(); if (key != 0) ctvd_stop(); buffer_teclado(); @@ -2941,7 +2945,7 @@ bucless: pausa(3); - key = getscan(); + byte key = getscan(); if (key == ESC) term_int = 1; if (key != 0) @@ -3004,38 +3008,38 @@ bucless: actualiza_refresco_antes(); DIBUJA_FONDO(hare_x, hare_y, ANCHOBJ+1, 0, - ((float)ancho_hare / 100) * factor_red[hare_y + alto_hare], - ((float)(alto_habla - 1) / 100) * factor_red[hare_y + alto_hare], + ancho_hare * factor_red[hare_y + alto_hare] / 100, + (alto_habla - 1) * factor_red[hare_y + alto_hare] / 100, dir_zona_pantalla, dir_dibujo3); pon_hare(); DIBUJA_FONDO(ANCHOBJ + 1, 0, hare_x, hare_y, - ((float)ancho_hare / 100) * factor_red[hare_y + alto_hare], - ((float)(alto_habla - 1) / 100) * factor_red[hare_y + alto_hare], + ancho_hare * factor_red[hare_y + alto_hare] / 100, + (alto_habla - 1) * factor_red[hare_y + alto_hare] / 100, dir_dibujo3, dir_zona_pantalla); if (sentido_hare == 0) { reduce_hare_chico(x_habla_izq[cara], y_mask_habla, - hare_x + ((float)8 / 100) * factor_red[hare_y + alto_hare], + hare_x + 8 * factor_red[hare_y + alto_hare] / 100, hare_y, ancho_habla, alto_habla, factor_red[hare_y + alto_hare], dir_hare_dch, dir_zona_pantalla); actualiza_refresco(); } else if (sentido_hare == 1) { reduce_hare_chico(x_habla_dch[cara], y_mask_habla, - hare_x + ((float)12 / 100) * factor_red[hare_y + alto_hare], + hare_x + 12 * factor_red[hare_y + alto_hare] / 100, hare_y, ancho_habla,alto_habla, factor_red[hare_y + alto_hare], dir_hare_dch, dir_zona_pantalla); actualiza_refresco(); } else if (sentido_hare == 2) { reduce_hare_chico(x_habla_izq[cara], y_mask_habla, - suma_1_pixel + hare_x + ((float)12 / 100) * factor_red[hare_y + alto_hare], + suma_1_pixel + hare_x + 12 * factor_red[hare_y + alto_hare] / 100, hare_y, ancho_habla, alto_habla, factor_red[hare_y + alto_hare], dir_hare_frente, dir_zona_pantalla); actualiza_refresco(); } else if (sentido_hare == 3) { reduce_hare_chico(x_habla_dch[cara], y_mask_habla, - suma_1_pixel + hare_x + ((float)8 / 100) * factor_red[hare_y + alto_hare], + suma_1_pixel + hare_x + 8 * factor_red[hare_y + alto_hare] / 100, hare_y, ancho_habla,alto_habla, factor_red[hare_y + alto_hare], dir_hare_frente, dir_zona_pantalla); actualiza_refresco(); @@ -3048,7 +3052,7 @@ bucless: pausa(3); - key = getscan(); + byte key = getscan(); if (key == ESC) term_int = 1; if (key != 0) @@ -3692,9 +3696,9 @@ void DrasculaEngine::OpenSSN(const char *Name, int Pause) { UsingMem = 0; if (MiVideoSSN == NULL) return; - Sesion = new Common::File; - Sesion->open(Name); - mSesion = TryInMem(Sesion); + _Sesion = new Common::File; + _Sesion->open(Name); + mSesion = TryInMem(_Sesion); LastFrame = clock(); } @@ -3704,7 +3708,7 @@ int DrasculaEngine::PlayFrameSSN() { byte *BufferSSN; if (!UsingMem) - Sesion->read(&CHUNK, 1); + _Sesion->read(&CHUNK, 1); else { memcpy(&CHUNK, mSesion, 1); mSesion += 1; @@ -3712,7 +3716,7 @@ int DrasculaEngine::PlayFrameSSN() { switch (CHUNK) { case SET_PALET: if (!UsingMem) - Sesion->read(dacSSN, 768); + _Sesion->read(dacSSN, 768); else { memcpy(dacSSN, mSesion, 768); mSesion += 768; @@ -3724,8 +3728,8 @@ int DrasculaEngine::PlayFrameSSN() { break; case INIT_FRAME: if (!UsingMem) { - Sesion->read(&CMP, 1); - Sesion->read(&Lengt, 4); + _Sesion->read(&CMP, 1); + _Sesion->read(&Lengt, 4); } else { memcpy(&CMP, mSesion, 1); mSesion += 1; @@ -3735,7 +3739,7 @@ int DrasculaEngine::PlayFrameSSN() { if (CMP == CMP_RLE) { if (!UsingMem) { BufferSSN = (byte *)malloc(Lengt); - Sesion->read(BufferSSN, Lengt); + _Sesion->read(BufferSSN, Lengt); } else { BufferSSN = (byte *)malloc(Lengt); memcpy(BufferSSN, mSesion, Lengt); @@ -3758,7 +3762,7 @@ int DrasculaEngine::PlayFrameSSN() { if (CMP == CMP_OFF) { if (!UsingMem) { BufferSSN = (byte *)malloc(Lengt); - Sesion->read(BufferSSN, Lengt); + _Sesion->read(BufferSSN, Lengt); } else { BufferSSN = (byte *)malloc(Lengt); memcpy(BufferSSN, mSesion, Lengt); @@ -3795,8 +3799,8 @@ void DrasculaEngine::EndSSN() { if (UsingMem) free(pointer); else { - Sesion->close(); - delete Sesion; + _Sesion->close(); + delete _Sesion; } } @@ -4287,22 +4291,22 @@ void DrasculaEngine::conversa(const char *nom_fich) { longitud = strlen(frase1); for (h = 0; h < longitud; h++) - if (frase1[h] == 0xa7) + if (frase1[h] == (char)0xa7) frase1[h] = ' '; longitud = strlen(frase2); for (h = 0; h < longitud; h++) - if (frase2[h] == 0xa7) + if (frase2[h] == (char)0xa7) frase2[h] = ' '; longitud = strlen(frase3); for (h = 0; h < longitud; h++) - if (frase3[h] == 0xa7) + if (frase3[h] == (char)0xa7) frase3[h] = ' '; longitud = strlen(frase4); for (h = 0; h < longitud; h++) - if (frase4[h] == 0xa7) + if (frase4[h] == (char)0xa7) frase4[h] = ' '; lee_dibujos("car.alg"); @@ -4325,21 +4329,21 @@ bucle_opc: MirarRaton(); if ( y_raton > 0 && y_raton < 9) { - if (usado1 == 1 && color != BLANCO) + if (usado1 == 1 && _color != BLANCO) color_abc(BLANCO); - else if (usado1 == 0 && color != VERDE_CLARO) + else if (usado1 == 0 && _color != VERDE_CLARO) color_abc(VERDE_CLARO); } else if (y_raton > 8 && y_raton < 17) { - if (usado2 == 1 && color != BLANCO) + if (usado2 == 1 && _color != BLANCO) color_abc(BLANCO); - else if (usado2 == 0 && color != VERDE_CLARO) + else if (usado2 == 0 && _color != VERDE_CLARO) color_abc(VERDE_CLARO); } else if (y_raton > 16 && y_raton < 25) { - if (usado3 == 1 && color != BLANCO) + if (usado3 == 1 && _color != BLANCO) color_abc(BLANCO); - else if (usado3 == 0 && color != VERDE_CLARO) + else if (usado3 == 0 && _color != VERDE_CLARO) color_abc(VERDE_CLARO); - } else if (color != VERDE_CLARO) + } else if (_color != VERDE_CLARO) color_abc(VERDE_CLARO); if (y_raton > 0 && y_raton < 9) @@ -4472,7 +4476,7 @@ void DrasculaEngine::animacion_4() { void DrasculaEngine::print_abc_opc(const char *dicho, int x_pantalla, int y_pantalla, int juego) { int pos_texto[6]; - int i = 0, y_de_signos, y_de_letra, x_de_letra = 0, h, longitud; + int y_de_signos, y_de_letra, x_de_letra = 0, h, longitud; longitud = strlen(dicho); for (h = 0; h < longitud; h++) { @@ -4790,7 +4794,7 @@ bucless: pausa(3); - key = getscan(); + byte key = getscan(); if (key != 0) ctvd_stop(); buffer_teclado(); diff --git a/engines/drascula/drascula.h b/engines/drascula/drascula.h index 75e5868143..eeb3ac52e9 100644 --- a/engines/drascula/drascula.h +++ b/engines/drascula/drascula.h @@ -421,7 +421,6 @@ public: int con_voces; int menu_bar, menu_scr, hay_nombre; char texto_nombre[13]; - byte key; int flags[NUM_BANDERAS]; @@ -458,7 +457,7 @@ public: int num_ejec; int cual_ejec, hay_que_load; char nom_partida[13]; - int color; + int _color; int corta_musica; char select[23]; int hay_seleccion; @@ -567,7 +566,7 @@ public: byte *pointer; int UsingMem; - Common::File *Sesion; + Common::File *_Sesion; byte CHUNK; byte CMP, dacSSN[768]; byte *MiVideoSSN; -- cgit v1.2.3 From 0b39041e5d7ac08f0a7879e55739ee681a7a9765 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Sun, 29 Jul 2007 18:14:44 +0000 Subject: Fix compilation svn-id: r28310 --- engines/drascula/drascula.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp index 2008c730f5..a2e2a67db3 100644 --- a/engines/drascula/drascula.cpp +++ b/engines/drascula/drascula.cpp @@ -4715,7 +4715,7 @@ bucless: pausa(3); - key = getscan(); + byte key = getscan(); if (key != 0) ctvd_stop(); buffer_teclado(); -- cgit v1.2.3 From 092de55a6a56af7629cc12e4c9ec1afd70395ce2 Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Sun, 29 Jul 2007 18:46:29 +0000 Subject: Removed debug code. svn-id: r28311 --- engines/parallaction/parallaction_ns.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'engines') diff --git a/engines/parallaction/parallaction_ns.cpp b/engines/parallaction/parallaction_ns.cpp index e9030b0abb..e75043fb68 100644 --- a/engines/parallaction/parallaction_ns.cpp +++ b/engines/parallaction/parallaction_ns.cpp @@ -69,7 +69,6 @@ int Parallaction_ns::init() { } void Parallaction_ns::callFunction(uint index, void* parm) { - printf("index = %i\n", index); assert(index < 25); // magic value 25 is maximum # of callables for Nippon Safes (this->*_callables[index])(parm); -- cgit v1.2.3 From 160a4ceaad1cf55e2aca3494616835e74e4c8a42 Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Sun, 29 Jul 2007 18:49:24 +0000 Subject: Added callables stubs for Big Red Adventure. svn-id: r28312 --- engines/parallaction/callables_br.cpp | 60 ++++++++++++++++++++++++++++++++ engines/parallaction/module.mk | 1 + engines/parallaction/parallaction.h | 12 +++++++ engines/parallaction/parallaction_br.cpp | 6 ++++ 4 files changed, 79 insertions(+) create mode 100644 engines/parallaction/callables_br.cpp (limited to 'engines') diff --git a/engines/parallaction/callables_br.cpp b/engines/parallaction/callables_br.cpp new file mode 100644 index 0000000000..829195fd7a --- /dev/null +++ b/engines/parallaction/callables_br.cpp @@ -0,0 +1,60 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include "common/stdafx.h" + +#include "parallaction/parallaction.h" + +namespace Parallaction { + + +void Parallaction_br::_c_blufade(void*) { + warning("Parallaction_br::_c_blufade() not yet implemented"); +} + +void Parallaction_br::_c_resetpalette(void*) { + warning("Parallaction_br::_c_resetpalette() not yet implemented"); +} + +void Parallaction_br::_c_ferrcycle(void*) { + warning("Parallaction_br::_c_ferrcycle() not yet implemented"); +} + +void Parallaction_br::_c_lipsinc(void*) { + warning("Parallaction_br::_c_lipsinc() not yet implemented"); +} + +void Parallaction_br::_c_albcycle(void*) { + warning("Parallaction_br::_c_albcycle() not yet implemented"); +} + +void Parallaction_br::_c_password(void*) { + warning("Parallaction_br::_c_password() not yet implemented"); +} + + + + +} // namespace Parallaction diff --git a/engines/parallaction/module.mk b/engines/parallaction/module.mk index 5a7a3b9694..b7f60eeb32 100644 --- a/engines/parallaction/module.mk +++ b/engines/parallaction/module.mk @@ -2,6 +2,7 @@ MODULE := engines/parallaction MODULE_OBJS := \ animation.o \ + callables_br.o \ callables_ns.o \ commands.o \ debug.o \ diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h index 7a4e076675..53ae64a136 100644 --- a/engines/parallaction/parallaction.h +++ b/engines/parallaction/parallaction.h @@ -543,6 +543,9 @@ public: int init(); +public: + virtual void callFunction(uint index, void* parm); + public: Table *_audioCommandsNames; const char **_audioCommandsNamesRes; @@ -550,7 +553,16 @@ public: private: void initResources(); + typedef void (Parallaction_br::*Callable)(void*); + + void _c_blufade(void*); + void _c_resetpalette(void*); + void _c_ferrcycle(void*); + void _c_lipsinc(void*); + void _c_albcycle(void*); + void _c_password(void*); + Callable _callables[6]; }; // FIXME: remove global diff --git a/engines/parallaction/parallaction_br.cpp b/engines/parallaction/parallaction_br.cpp index 44009bdf5c..7dcc94d7c6 100644 --- a/engines/parallaction/parallaction_br.cpp +++ b/engines/parallaction/parallaction_br.cpp @@ -57,4 +57,10 @@ int Parallaction_br::init() { return 0; } +void Parallaction_br::callFunction(uint index, void* parm) { + assert(index < 6); // magic value 6 is maximum # of callables for Big Red Adventure + + (this->*_callables[index])(parm); +} + } // namespace Parallaction -- cgit v1.2.3 From bb22e2205096d08a3e210ce2280fd3576776a34b Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 29 Jul 2007 19:06:17 +0000 Subject: Inventory icons in the IHNM demo are displayed correctly now svn-id: r28313 --- engines/saga/sfuncs.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/saga/sfuncs.cpp b/engines/saga/sfuncs.cpp index 1e9460c898..fed3f36a6f 100644 --- a/engines/saga/sfuncs.cpp +++ b/engines/saga/sfuncs.cpp @@ -277,7 +277,16 @@ void Script::sfTakeObject(SCRIPTFUNC_PARAMS) { obj = _vm->_actor->getObj(objectId); if (obj->_sceneNumber != ITE_SCENE_INV) { obj->_sceneNumber = ITE_SCENE_INV; - //4debug for (int j=0;j<17;j++) + + // WORKAROUND for two incorrect object sprites in the IHNM demo + // (the mirror and the icon in Ted's part). Set them correctly here + if (_vm->getGameId() == GID_IHNM_DEMO) { + if (obj->_spriteListResourceId == 4) + obj->_spriteListResourceId = 24; + if (obj->_spriteListResourceId == 3) + obj->_spriteListResourceId = 25; + } + _vm->_interface->addToInventory(objectId); } } @@ -870,10 +879,16 @@ void Script::sfDropObject(SCRIPTFUNC_PARAMS) { _vm->_scene->currentSceneNumber() == 59 && obj->_id == 16385) obj->_sceneNumber = -1; - if (_vm->getGameType() == GType_IHNM) - obj->_spriteListResourceId = spriteId; - else + if (_vm->getGameType() == GType_IHNM) { + if (_vm->getGameId() != GID_IHNM_DEMO) { + obj->_spriteListResourceId = spriteId; + } else { + // Don't update the object's _spriteListResourceId in the IHNM demo, as this function is + // called incorrectly there (with spriteId == 0, which resets the object sprites) + } + } else { obj->_spriteListResourceId = OBJ_SPRITE_BASE + spriteId; + } obj->_location.x = x; obj->_location.y = y; -- cgit v1.2.3 From 283b89daf83ef62d29f0c7d7d54a64fcc8bd69d8 Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Sun, 29 Jul 2007 19:17:53 +0000 Subject: Cleanup. svn-id: r28315 --- engines/parallaction/commands.cpp | 2 +- engines/parallaction/dialogue.cpp | 2 +- engines/parallaction/parallaction.cpp | 56 ++++++++++++++++---------------- engines/parallaction/parallaction_ns.cpp | 2 +- engines/parallaction/walk.cpp | 44 ++++++++++++------------- engines/parallaction/zone.cpp | 2 +- 6 files changed, 54 insertions(+), 54 deletions(-) (limited to 'engines') diff --git a/engines/parallaction/commands.cpp b/engines/parallaction/commands.cpp index 4df9aa4559..f7d027ea07 100644 --- a/engines/parallaction/commands.cpp +++ b/engines/parallaction/commands.cpp @@ -314,7 +314,7 @@ void Parallaction::runCommands(CommandList& list, Zone *z) { continue; } - WalkNodeList *vC = _vm->_char._builder.buildPath(u->_move._x, u->_move._y); + WalkNodeList *vC = _char._builder.buildPath(u->_move._x, u->_move._y); addJob(&jobWalk, vC, kPriority19 ); _engineFlags |= kEngineWalking; diff --git a/engines/parallaction/dialogue.cpp b/engines/parallaction/dialogue.cpp index d5000773de..101d5955bf 100644 --- a/engines/parallaction/dialogue.cpp +++ b/engines/parallaction/dialogue.cpp @@ -491,7 +491,7 @@ void Parallaction::runDialogue(SpeakData *data) { _gfx->setFont(kFontDialogue); - if (_vm->getPlatform() == Common::kPlatformPC) + if (getPlatform() == Common::kPlatformPC) showCursor(false); DialogueManager man(this, data); diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp index e92d9f36d4..c4f3fb0e4c 100644 --- a/engines/parallaction/parallaction.cpp +++ b/engines/parallaction/parallaction.cpp @@ -102,7 +102,7 @@ Parallaction::Parallaction(OSystem *syst) : Engine(syst) { // FIXME - _vm = this; +// _vm = this; _mouseHidden = false; @@ -178,7 +178,7 @@ int Parallaction::init() { initWalk(); // needs to be pushed into subclass initInventory(); // needs to be pushed into subclass - _animations.push_front(&_vm->_char._ani); + _animations.push_front(&_char._ani); _gfx = new Gfx(this); _debugger = new Debugger(this); @@ -219,9 +219,9 @@ void Parallaction::initGame() { parseLocation(_location._name); if (_location._startPosition.x != -1000) { - _vm->_char._ani._left = _location._startPosition.x; - _vm->_char._ani._top = _location._startPosition.y; - _vm->_char._ani._frame = _location._startFrame; + _char._ani._left = _location._startPosition.x; + _char._ani._top = _location._startPosition.y; + _char._ani._frame = _location._startFrame; _location._startPosition.y = -1000; _location._startPosition.x = -1000; } @@ -466,9 +466,9 @@ void Parallaction::processInput(InputData *data) { debugC(2, kDebugInput, "processInput: kEvWalk"); _hoverZone = NULL; changeCursor(kCursorArrow); - if (_vm->_char._ani._flags & kFlagsRemove) break; - if ((_vm->_char._ani._flags & kFlagsActive) == 0) break; - WalkNodeList *v4 = _vm->_char._builder.buildPath(data->_mousePos.x, data->_mousePos.y); + if (_char._ani._flags & kFlagsRemove) break; + if ((_char._ani._flags & kFlagsActive) == 0) break; + WalkNodeList *v4 = _char._builder.buildPath(data->_mousePos.x, data->_mousePos.y); addJob(&jobWalk, v4, kPriority19); _engineFlags |= kEngineWalking; // inhibits processing of input until walking is over } @@ -684,27 +684,27 @@ void Parallaction::changeCursor(int32 index) { void Parallaction::freeCharacter() { debugC(3, kDebugLocation, "freeCharacter()"); - if (!IS_DUMMY_CHARACTER(_vm->_characterName)) { + if (!IS_DUMMY_CHARACTER(_characterName)) { if (_objectsNames) delete _objectsNames; _objectsNames = NULL; - if (_vm->_char._ani._cnv) - delete _vm->_char._ani._cnv; - _vm->_char._ani._cnv = NULL; + if (_char._ani._cnv) + delete _char._ani._cnv; + _char._ani._cnv = NULL; - if (_vm->_char._talk) - delete _vm->_char._talk; - _vm->_char._talk = NULL; + if (_char._talk) + delete _char._talk; + _char._talk = NULL; - _vm->_gfx->freeStaticCnv(_vm->_char._head); - if (_vm->_char._head) - delete _vm->_char._head; - _vm->_char._head = NULL; + _gfx->freeStaticCnv(_char._head); + if (_char._head) + delete _char._head; + _char._head = NULL; - if (_vm->_char._objs) - delete _vm->_char._objs; - _vm->_char._objs = NULL; + if (_char._objs) + delete _char._objs; + _char._objs = NULL; } return; @@ -731,16 +731,16 @@ void Parallaction::changeCharacter(const char *name) { // character for sanity before memory is freed freeCharacter(); - Common::String oldArchive = _disk->selectArchive((_vm->getFeatures() & GF_LANG_MULT) ? "disk1" : "disk0"); - _vm->_char._ani._cnv = _disk->loadFrames(fullName); + Common::String oldArchive = _disk->selectArchive((getFeatures() & GF_LANG_MULT) ? "disk1" : "disk0"); + _char._ani._cnv = _disk->loadFrames(fullName); if (!IS_DUMMY_CHARACTER(name)) { - if (_vm->getPlatform() == Common::kPlatformAmiga && (_vm->getFeatures() & GF_LANG_MULT)) + if (getPlatform() == Common::kPlatformAmiga && (getFeatures() & GF_LANG_MULT)) _disk->selectArchive("disk0"); - _vm->_char._head = _disk->loadHead(baseName); - _vm->_char._talk = _disk->loadTalk(baseName); - _vm->_char._objs = _disk->loadObjects(baseName); + _char._head = _disk->loadHead(baseName); + _char._talk = _disk->loadTalk(baseName); + _char._objs = _disk->loadObjects(baseName); _objectsNames = _disk->loadTable(baseName); _soundMan->playCharacterMusic(name); diff --git a/engines/parallaction/parallaction_ns.cpp b/engines/parallaction/parallaction_ns.cpp index e75043fb68..947cb22a7f 100644 --- a/engines/parallaction/parallaction_ns.cpp +++ b/engines/parallaction/parallaction_ns.cpp @@ -49,7 +49,7 @@ int Parallaction_ns::init() { strcpy(_location._name, "fognedemo"); } _disk = new AmigaDisk_ns(this); - _disk->selectArchive((_vm->getFeatures() & GF_DEMO) ? "disk0" : "disk1"); + _disk->selectArchive((getFeatures() & GF_DEMO) ? "disk0" : "disk1"); } if (getPlatform() == Common::kPlatformPC) { diff --git a/engines/parallaction/walk.cpp b/engines/parallaction/walk.cpp index fd2fa8d186..d57e9d2532 100644 --- a/engines/parallaction/walk.cpp +++ b/engines/parallaction/walk.cpp @@ -272,19 +272,19 @@ uint16 PathBuilder::walkFunc1(int16 x, int16 y, WalkNode *Node) { void Parallaction::clipMove(Common::Point& pos, const WalkNode* from) { - if ((pos.x < from->_x) && (pos.x < _screenWidth) && (queryPath(_vm->_char._ani.width()/2 + pos.x + 2, _vm->_char._ani.height() + pos.y) != 0)) { + if ((pos.x < from->_x) && (pos.x < _screenWidth) && (queryPath(_char._ani.width()/2 + pos.x + 2, _char._ani.height() + pos.y) != 0)) { pos.x = (pos.x + 2 < from->_x) ? pos.x + 2 : from->_x; } - if ((pos.x > from->_x) && (pos.x > -20) && (queryPath(_vm->_char._ani.width()/2 + pos.x - 2, _vm->_char._ani.height() + pos.y) != 0)) { + if ((pos.x > from->_x) && (pos.x > -20) && (queryPath(_char._ani.width()/2 + pos.x - 2, _char._ani.height() + pos.y) != 0)) { pos.x = (pos.x - 2 > from->_x) ? pos.x - 2 : from->_x; } - if ((pos.y < from->_y) && (pos.y < (_screenHeight - _vm->_char._ani.height())) && (queryPath(_vm->_char._ani.width()/2 + pos.x, _vm->_char._ani.height() + pos.y + 2) != 0)) { + if ((pos.y < from->_y) && (pos.y < (_screenHeight - _char._ani.height())) && (queryPath(_char._ani.width()/2 + pos.x, _char._ani.height() + pos.y + 2) != 0)) { pos.y = (pos.y + 2 <= from->_y) ? pos.y + 2 : from->_y; } - if ((pos.y > from->_y) && (pos.y > -20) && (queryPath(_vm->_char._ani.width()/2 + pos.x, _vm->_char._ani.height() + pos.y- 2) != 0)) { + if ((pos.y > from->_y) && (pos.y > -20) && (queryPath(_char._ani.width()/2 + pos.x, _char._ani.height() + pos.y- 2) != 0)) { pos.y = (pos.y - 2 >= from->_y) ? pos.y - 2 :from->_y; } @@ -304,7 +304,7 @@ int16 Parallaction::selectWalkFrame(const Common::Point& pos, const WalkNode* fr // walk frame selection int16 v16; - if (_vm->_char._ani.getFrameNum() == 20) { + if (_char._ani.getFrameNum() == 20) { if (dist.x > dist.y) { walkData2 = (from->_x > pos.x) ? 0 : 7; @@ -336,49 +336,49 @@ int16 Parallaction::selectWalkFrame(const Common::Point& pos, const WalkNode* fr uint16 Parallaction::checkDoor() { // printf("checkDoor()..."); - if (_vm->_currentLocationIndex != _doorData1) { - _doorData1 = _vm->_currentLocationIndex; + if (_currentLocationIndex != _doorData1) { + _doorData1 = _currentLocationIndex; _zoneTrap = NULL; } _engineFlags &= ~kEngineWalking; - Zone *z = _vm->hitZone(kZoneDoor, _vm->_char._ani._left + _vm->_char._ani.width() / 2, _vm->_char._ani._top + _vm->_char._ani.height()); + Zone *z = hitZone(kZoneDoor, _char._ani._left + _char._ani.width() / 2, _char._ani._top + _char._ani.height()); if (z != NULL) { if ((z->_flags & kFlagsClosed) == 0) { - _vm->_location._startPosition.x = z->u.door->_startPos.x; - _vm->_location._startPosition.y = z->u.door->_startPos.y; - _vm->_location._startFrame = z->u.door->_startFrame; - strcpy( _vm->_location._name, z->u.door->_location ); + _location._startPosition.x = z->u.door->_startPos.x; + _location._startPosition.y = z->u.door->_startPos.y; + _location._startFrame = z->u.door->_startFrame; + strcpy(_location._name, z->u.door->_location); _engineFlags |= kEngineChangeLocation; _zoneTrap = NULL; } else { - _vm->runCommands(z->_commands, z); + runCommands(z->_commands, z); } } - z = _vm->hitZone(kZoneTrap, _vm->_char._ani._left + _vm->_char._ani.width() / 2, _vm->_char._ani._top + _vm->_char._ani.height()); + z = hitZone(kZoneTrap, _char._ani._left + _char._ani.width() / 2, _char._ani._top + _char._ani.height()); if (z != NULL) { - _localFlags[_vm->_currentLocationIndex] |= kFlagsEnter; - _vm->runCommands(z->_commands, z); - _localFlags[_vm->_currentLocationIndex] &= ~kFlagsEnter; + _localFlags[_currentLocationIndex] |= kFlagsEnter; + runCommands(z->_commands, z); + _localFlags[_currentLocationIndex] &= ~kFlagsEnter; _zoneTrap = z; } else if (_zoneTrap != NULL) { - _localFlags[_vm->_currentLocationIndex] |= kFlagsExit; - _vm->runCommands(_zoneTrap->_commands, _zoneTrap); - _localFlags[_vm->_currentLocationIndex] &= ~kFlagsExit; + _localFlags[_currentLocationIndex] |= kFlagsExit; + runCommands(_zoneTrap->_commands, _zoneTrap); + _localFlags[_currentLocationIndex] &= ~kFlagsExit; _zoneTrap = NULL; } // printf("done\n"); - _vm->_char._ani._frame = walkData2; - return _vm->_char._ani._frame; + _char._ani._frame = walkData2; + return _char._ani._frame; } diff --git a/engines/parallaction/zone.cpp b/engines/parallaction/zone.cpp index 3fcbd0d08c..73095e6f65 100644 --- a/engines/parallaction/zone.cpp +++ b/engines/parallaction/zone.cpp @@ -349,7 +349,7 @@ void Parallaction::displayItemComment(ExamineData *data) { Common::Rect r(v6C, v6A); r.moveTo(0, 90); _gfx->drawBalloon(r, 0); - _gfx->flatBlitCnv(_vm->_char._head, 100, 152, Gfx::kBitFront); + _gfx->flatBlitCnv(_char._head, 100, 152, Gfx::kBitFront); _gfx->displayWrappedString(data->_description, 0, 90, 0, 130); jobEraseAnimations((void*)1, NULL); -- cgit v1.2.3 From 65ee4ae2d42fcb029a35673be28c8bce57b3fbcd Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Sun, 29 Jul 2007 19:56:06 +0000 Subject: Now callables array is properly initialized. svn-id: r28316 --- engines/parallaction/staticres.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/parallaction/staticres.cpp b/engines/parallaction/staticres.cpp index ec94f56916..6ff3b8a948 100644 --- a/engines/parallaction/staticres.cpp +++ b/engines/parallaction/staticres.cpp @@ -483,6 +483,8 @@ const char *_minidoughName = "minidough"; const char *_minidrkiName = "minidrki"; #define CALLABLE_NS(x) &Parallaction_ns::x +#define CALLABLE_BR(x) &Parallaction_br::x + void Parallaction_ns::initResources() { @@ -577,7 +579,14 @@ void Parallaction_br::initResources() { _localFlagNames = new Table(120); _localFlagNames->addData("visited"); - // TODO: init callables for Big Red Adventure + if (getPlatform() == Common::kPlatformPC) { + _callables[0] = CALLABLE_BR(_c_blufade); + _callables[1] = CALLABLE_BR(_c_resetpalette); + _callables[2] = CALLABLE_BR(_c_ferrcycle); + _callables[3] = CALLABLE_BR(_c_lipsinc); + _callables[4] = CALLABLE_BR(_c_albcycle); + _callables[5] = CALLABLE_BR(_c_password); + } } -- cgit v1.2.3 From b89bd7462c698b32cd80e16a02d80d48804a9e89 Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Sun, 29 Jul 2007 21:08:39 +0000 Subject: Oops. Last cleanup left out one very important line. svn-id: r28317 --- engines/parallaction/parallaction.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp index c4f3fb0e4c..986bc6ebd7 100644 --- a/engines/parallaction/parallaction.cpp +++ b/engines/parallaction/parallaction.cpp @@ -102,7 +102,7 @@ Parallaction::Parallaction(OSystem *syst) : Engine(syst) { // FIXME -// _vm = this; + _vm = this; _mouseHidden = false; -- cgit v1.2.3 From d9e6db79b53b46f933178f07d1ff69650a8fcd6f Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Sun, 29 Jul 2007 21:14:17 +0000 Subject: Refactored allegedly ugly code. svn-id: r28318 --- engines/parallaction/parallaction.h | 12 ++-- engines/parallaction/staticres.cpp | 124 ++++++++++++++++++++---------------- 2 files changed, 76 insertions(+), 60 deletions(-) (limited to 'engines') diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h index 53ae64a136..31b125c92a 100644 --- a/engines/parallaction/parallaction.h +++ b/engines/parallaction/parallaction.h @@ -492,12 +492,15 @@ public: int init(); public: + typedef void (Parallaction_ns::*Callable)(void*); + virtual void callFunction(uint index, void* parm); private: void initResources(); - typedef void (Parallaction_ns::*Callable)(void*); + static const Callable _dosCallables[25]; + static const Callable _amigaCallables[25]; // common callables void _c_play_boogie(void*); @@ -532,7 +535,7 @@ private: void _c_closeMusic(void*); void _c_HBOn(void*); - Callable _callables[25]; + const Callable *_callables; }; class Parallaction_br : public Parallaction { @@ -544,6 +547,7 @@ public: int init(); public: + typedef void (Parallaction_br::*Callable)(void*); virtual void callFunction(uint index, void* parm); public: @@ -553,7 +557,7 @@ public: private: void initResources(); - typedef void (Parallaction_br::*Callable)(void*); + static const Callable _dosCallables[6]; void _c_blufade(void*); void _c_resetpalette(void*); @@ -562,7 +566,7 @@ private: void _c_albcycle(void*); void _c_password(void*); - Callable _callables[6]; + const Callable *_callables; }; // FIXME: remove global diff --git a/engines/parallaction/staticres.cpp b/engines/parallaction/staticres.cpp index 6ff3b8a948..046176a933 100644 --- a/engines/parallaction/staticres.cpp +++ b/engines/parallaction/staticres.cpp @@ -483,8 +483,73 @@ const char *_minidoughName = "minidough"; const char *_minidrkiName = "minidrki"; #define CALLABLE_NS(x) &Parallaction_ns::x + +const Parallaction_ns::Callable Parallaction_ns::_dosCallables[] = { + CALLABLE_NS(_c_play_boogie), + CALLABLE_NS(_c_play_boogie), + CALLABLE_NS(_c_startIntro), + CALLABLE_NS(_c_endIntro), + CALLABLE_NS(_c_moveSheet), + CALLABLE_NS(_c_sketch), + CALLABLE_NS(_c_shade), + CALLABLE_NS(_c_score), + CALLABLE_NS(_c_null), + CALLABLE_NS(_c_null), + CALLABLE_NS(_c_null), + CALLABLE_NS(_c_fade), + CALLABLE_NS(_c_play_boogie), + CALLABLE_NS(_c_moveSarc), + CALLABLE_NS(_c_contaFoglie), + CALLABLE_NS(_c_zeroFoglie), + CALLABLE_NS(_c_trasformata), + CALLABLE_NS(_c_offMouse), + CALLABLE_NS(_c_onMouse), + CALLABLE_NS(_c_setMask), + CALLABLE_NS(_c_endComment), + CALLABLE_NS(_c_frankenstein), + CALLABLE_NS(_c_finito), + CALLABLE_NS(_c_ridux), + CALLABLE_NS(_c_testResult) +}; + +const Parallaction_ns::Callable Parallaction_ns::_amigaCallables[] = { + CALLABLE_NS(_c_projector), + CALLABLE_NS(_c_HBOff), + CALLABLE_NS(_c_startIntro), + CALLABLE_NS(_c_endIntro), + CALLABLE_NS(_c_moveSheet), + CALLABLE_NS(_c_sketch), + CALLABLE_NS(_c_shade), + CALLABLE_NS(_c_score), + CALLABLE_NS(_c_offSound), + CALLABLE_NS(_c_startMusic), + CALLABLE_NS(_c_closeMusic), + CALLABLE_NS(_c_fade), + CALLABLE_NS(_c_play_boogie), + CALLABLE_NS(_c_moveSarc), + CALLABLE_NS(_c_contaFoglie), + CALLABLE_NS(_c_zeroFoglie), + CALLABLE_NS(_c_trasformata), + CALLABLE_NS(_c_offMouse), + CALLABLE_NS(_c_onMouse), + CALLABLE_NS(_c_setMask), + CALLABLE_NS(_c_endComment), + CALLABLE_NS(_c_frankenstein), + CALLABLE_NS(_c_finito), + CALLABLE_NS(_c_ridux), + CALLABLE_NS(_c_testResult) +}; + #define CALLABLE_BR(x) &Parallaction_br::x +const Parallaction_br::Callable Parallaction_br::_dosCallables[] = { + CALLABLE_BR(_c_blufade), + CALLABLE_BR(_c_resetpalette), + CALLABLE_BR(_c_ferrcycle), + CALLABLE_BR(_c_lipsinc), + CALLABLE_BR(_c_albcycle), + CALLABLE_BR(_c_password) +}; void Parallaction_ns::initResources() { @@ -504,57 +569,9 @@ void Parallaction_ns::initResources() { _localFlagNames->addData("visited"); if (getPlatform() == Common::kPlatformPC) { - _callables[0] = CALLABLE_NS(_c_play_boogie); - _callables[1] = CALLABLE_NS(_c_play_boogie); - _callables[2] = CALLABLE_NS(_c_startIntro); - _callables[3] = CALLABLE_NS(_c_endIntro); - _callables[4] = CALLABLE_NS(_c_moveSheet); - _callables[5] = CALLABLE_NS(_c_sketch); - _callables[6] = CALLABLE_NS(_c_shade); - _callables[7] = CALLABLE_NS(_c_score); - _callables[8] = CALLABLE_NS(_c_null); - _callables[9] = CALLABLE_NS(_c_null); - _callables[10] = CALLABLE_NS(_c_null); - _callables[11] = CALLABLE_NS(_c_fade); - _callables[12] = CALLABLE_NS(_c_play_boogie); - _callables[13] = CALLABLE_NS(_c_moveSarc); - _callables[14] = CALLABLE_NS(_c_contaFoglie); - _callables[15] = CALLABLE_NS(_c_zeroFoglie); - _callables[16] = CALLABLE_NS(_c_trasformata); - _callables[17] = CALLABLE_NS(_c_offMouse); - _callables[18] = CALLABLE_NS(_c_onMouse); - _callables[19] = CALLABLE_NS(_c_setMask); - _callables[20] = CALLABLE_NS(_c_endComment); - _callables[21] = CALLABLE_NS(_c_frankenstein); - _callables[22] = CALLABLE_NS(_c_finito); - _callables[23] = CALLABLE_NS(_c_ridux); - _callables[24] = CALLABLE_NS(_c_testResult); + _callables = _dosCallables; } else { - _callables[0] = CALLABLE_NS(_c_projector); - _callables[1] = CALLABLE_NS(_c_HBOff); - _callables[2] = CALLABLE_NS(_c_startIntro); - _callables[3] = CALLABLE_NS(_c_endIntro); - _callables[4] = CALLABLE_NS(_c_moveSheet); - _callables[5] = CALLABLE_NS(_c_sketch); - _callables[6] = CALLABLE_NS(_c_shade); - _callables[7] = CALLABLE_NS(_c_score); - _callables[8] = CALLABLE_NS(_c_offSound); - _callables[9] = CALLABLE_NS(_c_startMusic); - _callables[10] = CALLABLE_NS(_c_closeMusic); - _callables[11] = CALLABLE_NS(_c_fade); - _callables[12] = CALLABLE_NS(_c_HBOn); - _callables[13] = CALLABLE_NS(_c_moveSarc); - _callables[14] = CALLABLE_NS(_c_contaFoglie); - _callables[15] = CALLABLE_NS(_c_zeroFoglie); - _callables[16] = CALLABLE_NS(_c_trasformata); - _callables[17] = CALLABLE_NS(_c_offMouse); - _callables[18] = CALLABLE_NS(_c_onMouse); - _callables[19] = CALLABLE_NS(_c_setMask); - _callables[20] = CALLABLE_NS(_c_endComment); - _callables[21] = CALLABLE_NS(_c_frankenstein); - _callables[22] = CALLABLE_NS(_c_finito); - _callables[23] = CALLABLE_NS(_c_ridux); - _callables[24] = CALLABLE_NS(_c_testResult); + _callables = _amigaCallables; } } @@ -580,12 +597,7 @@ void Parallaction_br::initResources() { _localFlagNames->addData("visited"); if (getPlatform() == Common::kPlatformPC) { - _callables[0] = CALLABLE_BR(_c_blufade); - _callables[1] = CALLABLE_BR(_c_resetpalette); - _callables[2] = CALLABLE_BR(_c_ferrcycle); - _callables[3] = CALLABLE_BR(_c_lipsinc); - _callables[4] = CALLABLE_BR(_c_albcycle); - _callables[5] = CALLABLE_BR(_c_password); + _callables = _dosCallables; } } -- cgit v1.2.3 From 976d39e2aae0485948328009fc7a2c2a152dd778 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 29 Jul 2007 22:47:06 +0000 Subject: Changed some comments so that they follow the same commenting style svn-id: r28319 --- engines/saga/sagaresnames.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'engines') diff --git a/engines/saga/sagaresnames.h b/engines/saga/sagaresnames.h index bb5a209946..f4dcf7bf18 100644 --- a/engines/saga/sagaresnames.h +++ b/engines/saga/sagaresnames.h @@ -47,7 +47,7 @@ namespace Saga { #define RID_IHNMDEMO_SCRIPT_LUT 18 #define RID_IHNMDEMO_SFX_LUT 222 -//obj names +// Object names #define ITE_OBJ_MAP 14 #define ITE_OBJ_MAGIC_HAT 0 @@ -55,10 +55,10 @@ namespace Saga { #define RID_IHNM_DEFAULT_PALETTE 1 -//actor names +// Actor names #define ITE_ACTOR_PUZZLE 176 -// SCENES +// Scenes #define ITE_SCENE_INV -1 #define ITE_SCENE_PUZZLE 26 #define ITE_SCENE_LODGE 21 @@ -70,12 +70,12 @@ namespace Saga { #define ITEDEMO_DEFAULT_SCENE 68 #define IHNMDEMO_DEFAULT_SCENE 144 -// FONTS +// Fonts #define RID_MEDIUM_FONT 0 #define RID_BIG_FONT 1 #define RID_SMALL_FONT 2 -// INTERFACE IMAGES +// Interface images #define RID_ITE_MAIN_PANEL 3 #define RID_ITE_CONVERSE_PANEL 4 #define RID_ITE_OPTION_PANEL 5 @@ -167,7 +167,7 @@ namespace Saga { #define RID_ITE_INTRO_IMG_3 1561 #define RID_ITE_INTRO_IMG_4 1565 -// ITE_VOICES +// ITE voices #define RID_CAVE_VOICE_0 0 #define RID_CAVE_VOICE_1 1 #define RID_CAVE_VOICE_2 2 @@ -193,7 +193,7 @@ namespace Saga { #define RID_BOAR_VOICE_006 245 #define RID_BOAR_VOICE_007 246 -// MUSIC +// Music #define MUSIC_1 9 #define MUSIC_2 10 #define MUSIC_SUNSPOT 26 @@ -201,7 +201,7 @@ namespace Saga { // TODO: If the sound effects are numbered sequentially, we don't really need // these constants. But for now they might be useful for debugging. -// SOUND EFFECTS +// Sound effects #define FX_DOOR_OPEN 14 #define FX_DOOR_CLOSE 15 -- cgit v1.2.3 From b888c0858156960943f68adf23d94e669495cbd0 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 30 Jul 2007 09:14:15 +0000 Subject: The credits of the IHNM demo are displayed correctly now svn-id: r28320 --- engines/saga/animation.h | 1 + engines/saga/ihnm_introproc.cpp | 133 +++++++++++++++++++++++++++++++++------- engines/saga/scene.h | 2 - 3 files changed, 113 insertions(+), 23 deletions(-) (limited to 'engines') diff --git a/engines/saga/animation.h b/engines/saga/animation.h index 89a1e77807..2af57fb60f 100644 --- a/engines/saga/animation.h +++ b/engines/saga/animation.h @@ -154,6 +154,7 @@ public: } return (_animations[animId] != NULL); } + int cutawayResourceID(int cutaway) { return _cutawayList[cutaway].animResourceId; } private: void decodeFrame(AnimationData *anim, size_t frameOffset, byte *buf, size_t bufLength); void fillFrameOffsets(AnimationData *anim); diff --git a/engines/saga/ihnm_introproc.cpp b/engines/saga/ihnm_introproc.cpp index 40de389d0f..33cfb57ce2 100644 --- a/engines/saga/ihnm_introproc.cpp +++ b/engines/saga/ihnm_introproc.cpp @@ -31,6 +31,7 @@ #include "saga/animation.h" #include "saga/events.h" #include "saga/interface.h" +#include "saga/rscfile.h" #include "saga/sndres.h" #include "saga/music.h" @@ -39,7 +40,7 @@ namespace Saga { SceneResourceData IHNM_IntroMovie1RL[] = { - {30, 2, 0, 0, false} , + {30, 2, 0, 0, false}, {31, 14, 0, 0, false} }; @@ -50,7 +51,7 @@ SceneDescription IHNM_IntroMovie1Desc = { }; SceneResourceData IHNM_IntroMovie2RL[] = { - {32, 2, 0, 0, false} , + {32, 2, 0, 0, false}, {33, 14, 0, 0, false} }; @@ -82,31 +83,100 @@ SceneDescription IHNM_IntroMovie4Desc = { ARRAYSIZE(IHNM_IntroMovie4RL) }; +// Demo +SceneResourceData IHNMDEMO_IntroMovie1RL[] = { + {19, 2, 0, 0, false} // this scene doesn't have an animation +}; + +SceneDescription IHNMDEMO_IntroMovie1Desc = { + 0, 0, 0, 0, 0, 0, 0, 0, + IHNMDEMO_IntroMovie1RL, + ARRAYSIZE(IHNMDEMO_IntroMovie1RL) +}; + +SceneResourceData IHNMDEMO_IntroMovie2RL[] = { + {22, 2, 0, 0, false}, + {23, 14, 0, 0, false} +}; + +SceneDescription IHNMDEMO_IntroMovie2Desc = { + 0, 0, 0, 0, 0, 0, 0, 0, + IHNMDEMO_IntroMovie2RL, + ARRAYSIZE(IHNMDEMO_IntroMovie2RL) +}; + LoadSceneParams IHNM_IntroList[] = { {0, kLoadByDescription, &IHNM_IntroMovie1Desc, Scene::SC_IHNMIntroMovieProc1, false, kTransitionNoFade, 0, NO_CHAPTER_CHANGE}, {0, kLoadByDescription, &IHNM_IntroMovie2Desc, Scene::SC_IHNMIntroMovieProc2, false, kTransitionNoFade, 0, NO_CHAPTER_CHANGE}, {0, kLoadByDescription, &IHNM_IntroMovie3Desc, Scene::SC_IHNMIntroMovieProc3, false, kTransitionNoFade, 0, NO_CHAPTER_CHANGE}, }; +LoadSceneParams IHNMDEMO_IntroList[] = { + {0, kLoadByDescription, &IHNMDEMO_IntroMovie1Desc, Scene::SC_IHNMIntroMovieProc1, false, kTransitionNoFade, 0, NO_CHAPTER_CHANGE}, + {0, kLoadByDescription, &IHNMDEMO_IntroMovie2Desc, Scene::SC_IHNMIntroMovieProc3, false, kTransitionNoFade, 0, NO_CHAPTER_CHANGE}, +}; + +// IHNM cutaway intro resource IDs +#define RID_IHNM_INTRO_CUTAWAYS 39 +#define RID_IHNMDEMO_INTRO_CUTAWAYS 25 + int Scene::IHNMStartProc() { size_t n_introscenes; size_t i; LoadSceneParams firstScene; + /* + // Test code - uses loadCutawayList to load the intro cutaways, like the original + + ResourceContext *resourceContext; + //ResourceContext *soundContext; + byte *resourcePointer; + size_t resourceLength; + + resourceContext = _vm->_resource->getContext(GAME_RESOURCEFILE); + if (resourceContext == NULL) { + error("Scene::IHNMStartProc() resource context not found"); + } + + if (_vm->getGameId() != GID_IHNM_DEMO) + _vm->_resource->loadResource(resourceContext, RID_IHNM_INTRO_CUTAWAYS, resourcePointer, resourceLength); + else + _vm->_resource->loadResource(resourceContext, RID_IHNMDEMO_INTRO_CUTAWAYS, resourcePointer, resourceLength); + + if (resourceLength == 0) { + error("Scene::IHNMStartProc() Can't load cutaway list"); + } + + // Load the cutaways for the title screens + _vm->_anim->loadCutawayList(resourcePointer, resourceLength); + + // Note that the resource ID needed is the returned ID minus one + printf("%i\n", _vm->_anim->cutawayResourceID(0)); + printf("%i\n", _vm->_anim->cutawayResourceID(1)); + printf("%i\n", _vm->_anim->cutawayResourceID(2)); + */ + // The original used the "play video" mechanism for the first part of // the intro. We just use that panel mode. _vm->_anim->setCutAwayMode(kPanelVideo); _vm->_interface->setMode(kPanelVideo); - n_introscenes = ARRAYSIZE(IHNM_IntroList); + if (_vm->getGameId() != GID_IHNM_DEMO) + n_introscenes = ARRAYSIZE(IHNM_IntroList); + else + n_introscenes = ARRAYSIZE(IHNMDEMO_IntroList); - // Queue the company and title videos for the full version of IHNM + // Queue the company and title videos if (_vm->getGameId() != GID_IHNM_DEMO) { for (i = 0; i < n_introscenes; i++) { _vm->_scene->queueScene(&IHNM_IntroList[i]); } + } else { + for (i = 0; i < n_introscenes; i++) { + _vm->_scene->queueScene(&IHNMDEMO_IntroList[i]); + } } firstScene.loadFlag = kLoadBySceneNumber; @@ -143,16 +213,30 @@ int Scene::IHNMIntroMovieProc1(int param) { q_event = _vm->_events->queue(&event); - _vm->_anim->setFrameTime(0, IHNM_INTRO_FRAMETIME); - _vm->_anim->setFlag(0, ANIM_FLAG_ENDSCENE); + if (_vm->getGameId() != GID_IHNM_DEMO) { + _vm->_anim->setFrameTime(0, IHNM_INTRO_FRAMETIME); + _vm->_anim->setFlag(0, ANIM_FLAG_ENDSCENE); - event.type = kEvTOneshot; - event.code = kAnimEvent; - event.op = kEventPlay; - event.param = 0; - event.time = 0; + event.type = kEvTOneshot; + event.code = kAnimEvent; + event.op = kEventPlay; + event.param = 0; + event.time = 0; + + q_event = _vm->_events->chain(q_event, &event); + } else { + // The IHNM demo doesn't have an animation at the + // Cyberdreans logo screen + + // Queue end of scene after a while + event.type = kEvTOneshot; + event.code = kSceneEvent; + event.op = kEventEnd; + event.time = 4000; + + q_event = _vm->_events->chain(q_event, &event); + } - q_event = _vm->_events->chain(q_event, &event); break; default: break; @@ -276,14 +360,18 @@ int Scene::IHNMIntroMovieProc3(int param) { // In the GM file, this music also appears as tracks 7, 13, 19, // 25 and 31, but only track 1 sounds right with the FM music. - event.type = kEvTOneshot; - event.code = kMusicEvent; - event.param = 1; - event.param2 = MUSIC_NORMAL; - event.op = kEventPlay; - event.time = 0; - - q_event = _vm->_events->chain(q_event, &event); + // FIXME: MIDI music in the demo is problematic right now, so music is + // disabled in this part + if (_vm->getGameId() != GID_IHNM_DEMO) { + event.type = kEvTOneshot; + event.code = kMusicEvent; + event.param = 1; + event.param2 = MUSIC_NORMAL; + event.op = kEventPlay; + event.time = 0; + + q_event = _vm->_events->chain(q_event, &event); + } // Background for intro scene is the first frame of the intro // animation; display it but don't set palette @@ -320,7 +408,10 @@ int Scene::IHNMIntroMovieProc3(int param) { event.type = kEvTOneshot; event.code = kSceneEvent; event.op = kEventEnd; - event.time = _vm->_music->hasAdlib() ? IHNM_TITLE_TIME_FM : IHNM_TITLE_TIME_GM; + if (_vm->getGameId() != GID_IHNM_DEMO) + event.time = _vm->_music->hasAdlib() ? IHNM_TITLE_TIME_FM : IHNM_TITLE_TIME_GM; + else + event.time = 10000; q_event = _vm->_events->chain(q_event, &event); break; diff --git a/engines/saga/scene.h b/engines/saga/scene.h index 5fa4569949..99168e6504 100644 --- a/engines/saga/scene.h +++ b/engines/saga/scene.h @@ -392,13 +392,11 @@ class Scene { static int SC_IHNMIntroMovieProc1(int param, void *refCon); static int SC_IHNMIntroMovieProc2(int param, void *refCon); static int SC_IHNMIntroMovieProc3(int param, void *refCon); - static int SC_IHNMHateProc(int param, void *refCon); private: int IHNMIntroMovieProc1(int param); int IHNMIntroMovieProc2(int param); int IHNMIntroMovieProc3(int param); - int IHNMHateProc(int param); public: static int SC_ITEIntroAnimProc(int param, void *refCon); -- cgit v1.2.3 From 36496dd467648d6345b08b78a99447429fa0f26a Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 30 Jul 2007 10:33:17 +0000 Subject: The actors at the end of Benny's part in the IHNM demo are no longer incorrectly shown svn-id: r28322 --- engines/saga/sfuncs.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/saga/sfuncs.cpp b/engines/saga/sfuncs.cpp index fed3f36a6f..caf13e0c9e 100644 --- a/engines/saga/sfuncs.cpp +++ b/engines/saga/sfuncs.cpp @@ -577,7 +577,8 @@ void Script::sfScriptGotoScene(SCRIPTFUNC_PARAMS) { (_vm->_scene->currentChapterNumber() == 2 && _vm->_scene->currentSceneNumber() == 31) || (_vm->_scene->currentChapterNumber() == 3 && _vm->_scene->currentSceneNumber() == 58) || (_vm->_scene->currentChapterNumber() == 4 && _vm->_scene->currentSceneNumber() == 68) || - (_vm->_scene->currentChapterNumber() == 5 && _vm->_scene->currentSceneNumber() == 91)) + (_vm->_scene->currentChapterNumber() == 5 && _vm->_scene->currentSceneNumber() == 91) || + (_vm->_scene->currentChapterNumber() == 7 && _vm->_scene->currentSceneNumber() == 145)) _vm->_actor->showActors(false); // Stop showing actors before the background is drawn // Since it doesn't look like the IHNM scripts remove the -- cgit v1.2.3 From 653cf4c971e740e9ce9955447aa8d18491544b18 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 30 Jul 2007 11:55:11 +0000 Subject: Initial support of the psychic profile in IHNM (still buggy) svn-id: r28323 --- engines/saga/detection_tables.h | 4 ++ engines/saga/saga.cpp | 3 + engines/saga/saga.h | 1 + engines/saga/sfuncs.cpp | 119 +++++++++++++++++++++++++++++++++++++++- 4 files changed, 126 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/saga/detection_tables.h b/engines/saga/detection_tables.h index a304fb906a..b26a9b75d5 100644 --- a/engines/saga/detection_tables.h +++ b/engines/saga/detection_tables.h @@ -36,6 +36,7 @@ static const GameResourceDescription ITE_Resources = { RID_ITE_MAIN_PANEL_SPRITES, 0, // Option panel sprites (IHNM only) RID_ITE_DEFAULT_PORTRAITS, + 0, // Psychic profile background (IHNM only) RID_ITE_MAIN_STRINGS, RID_ITE_ACTOR_NAMES }; @@ -51,6 +52,7 @@ static const GameResourceDescription ITEDemo_Resources = { RID_ITEDEMO_MAIN_PANEL_SPRITES, 0, // Option panel sprites (IHNM only) RID_ITEDEMO_DEFAULT_PORTRAITS, + 0, // Psychic profile background (IHNM only) RID_ITEDEMO_MAIN_STRINGS, RID_ITEDEMO_ACTOR_NAMES }; @@ -270,6 +272,7 @@ static const GameResourceDescription IHNM_Resources = { RID_IHNM_MAIN_PANEL_SPRITES, RID_IHNM_OPTION_PANEL_SPRITES, 0, // Default portraits (ITE only) + RID_IHNM_PROFILE_BG, RID_IHNM_MAIN_STRINGS, 0 // Actors strings (ITE only) }; @@ -285,6 +288,7 @@ static const GameResourceDescription IHNMDEMO_Resources = { RID_IHNMDEMO_MAIN_PANEL_SPRITES, RID_IHNMDEMO_OPTION_PANEL_SPRITES, 0, // Default portraits (ITE only) + RID_IHNMDEMO_PROFILE_BG, RID_IHNMDEMO_MAIN_STRINGS, 0 // Actors strings (ITE only) }; diff --git a/engines/saga/saga.cpp b/engines/saga/saga.cpp index 23eb57d1c7..76731c201a 100644 --- a/engines/saga/saga.cpp +++ b/engines/saga/saga.cpp @@ -455,6 +455,9 @@ ColorId SagaEngine::KnownColor2ColorId(KnownColor knownColor) { colorId = kITEColorTransBlack; break; + case (kKnownColorBrightWhite): + colorId = kITEColorBrightWhite; + break; case (kKnownColorBlack): colorId = kIHNMColorBlack; break; diff --git a/engines/saga/saga.h b/engines/saga/saga.h index cded648168..220a563c14 100644 --- a/engines/saga/saga.h +++ b/engines/saga/saga.h @@ -301,6 +301,7 @@ struct GameResourceDescription { uint32 mainPanelSpritesResourceId; uint32 optionPanelSpritesResourceId; uint32 defaultPortraitsResourceId; + uint32 psychicProfileResourceId; uint32 mainStringsResourceId; uint32 actorsStringsResourceId; }; diff --git a/engines/saga/sfuncs.cpp b/engines/saga/sfuncs.cpp index caf13e0c9e..74ff8e88dc 100644 --- a/engines/saga/sfuncs.cpp +++ b/engines/saga/sfuncs.cpp @@ -40,6 +40,7 @@ #include "saga/render.h" #include "saga/sound.h" #include "saga/sndres.h" +#include "saga/rscfile.h" #include "saga/script.h" #include "saga/objectmap.h" @@ -1476,7 +1477,123 @@ void Script::sfPlacardOff(SCRIPTFUNC_PARAMS) { } void Script::sfPsychicProfile(SCRIPTFUNC_PARAMS) { - SF_stub("sfPsychicProfile", thread, nArgs); + int stringId; + Surface *backBuffer = _vm->_gfx->getBackBuffer(); + static PalEntry cur_pal[PAL_ENTRIES]; + PalEntry *pal; + Event event; + Event *q_event; + + // FIXME: This still needs work: the actors are shown while the psychic + // profile is shown and the text placement and color are incorrect + + thread->wait(kWaitTypePlacard); + + _vm->_interface->rememberMode(); + _vm->_interface->setMode(kPanelPlacard); + + stringId = thread->pop(); + + event.type = kEvTOneshot; + event.code = kCursorEvent; + event.op = kEventHide; + + q_event = _vm->_events->queue(&event); + + _vm->_gfx->getCurrentPal(cur_pal); + + event.type = kEvTImmediate; + event.code = kPalEvent; + event.op = kEventPalToBlack; + event.time = 0; + event.duration = kNormalFadeDuration; + event.data = cur_pal; + + q_event = _vm->_events->chain(q_event, &event); + + event.type = kEvTOneshot; + event.code = kInterfaceEvent; + event.op = kEventClearStatus; + + q_event = _vm->_events->chain(q_event, &event); + + event.type = kEvTOneshot; + event.code = kGraphicsEvent; + event.op = kEventSetFlag; + event.param = RF_PLACARD; + + q_event = _vm->_events->chain(q_event, &event); + + // Set the background and palette for the psychic profile + ResourceContext *context = _vm->_resource->getContext(GAME_RESOURCEFILE); + + byte *resourceData; + size_t resourceDataLength; + + _vm->_resource->loadResource(context, _vm->getResourceDescription()->psychicProfileResourceId, resourceData, resourceDataLength); + + byte *buf; + size_t buflen; + int width; + int height; + + _vm->decodeBGImage(resourceData, resourceDataLength, &buf, &buflen, &width, &height); + + const PalEntry *palette = (const PalEntry *)_vm->getImagePal(resourceData, resourceDataLength); + + Surface *bgSurface = _vm->_render->getBackGroundSurface(); + const Rect rect(width, height); + + bgSurface->blit(rect, buf); + _vm->_frameCount++; + + _vm->_gfx->setPalette(palette); + + free(buf); + free(resourceData); + + // Put the text in the center of the viewport, assuming it will fit on + // one line. If we cannot make that assumption we'll need to extend + // the text drawing function so that it can center text around a point. + // It doesn't end up in exactly the same spot as the original did it, + // but it's close enough for now at least. + + TextListEntry textEntry; + + textEntry.knownColor = kKnownColorTransparent; + textEntry.effectKnownColor = kKnownColorBrightWhite; + textEntry.point.x = _vm->getDisplayWidth() / 2; + textEntry.point.y = (_vm->_scene->getHeight() - _vm->_font->getHeight(kKnownFontMedium)) / 2; + textEntry.font = kKnownFontVerb; + textEntry.flags = (FontEffectFlags)(kFontOutline | kFontCentered); + textEntry.text = thread->_strings->getString(stringId); + + _placardTextEntry = _vm->_scene->_textList.addEntry(textEntry); + + event.type = kEvTOneshot; + event.code = kTextEvent; + event.op = kEventDisplay; + event.data = _placardTextEntry; + + q_event = _vm->_events->chain(q_event, &event); + + _vm->_scene->getBGPal(pal); + + event.type = kEvTImmediate; + event.code = kPalEvent; + event.op = kEventBlackToPal; + event.time = 0; + event.duration = kNormalFadeDuration; + event.data = pal; + + q_event = _vm->_events->chain(q_event, &event); + + event.type = kEvTOneshot; + event.code = kScriptEvent; + event.op = kEventThreadWake; + event.param = kWaitTypePlacard; + + q_event = _vm->_events->chain(q_event, &event); } void Script::sfPsychicProfileOff(SCRIPTFUNC_PARAMS) { -- cgit v1.2.3 From ba44fcbf6b5a209fd7d705ffcf678568bb049640 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 30 Jul 2007 13:19:46 +0000 Subject: Some corrections for the psychic profile screen in IHNM. The psychic profile background drawing has been turned into an event, so actors and animations will no longer be incorrectly shown. Also, the incorrect text color has been fixed. The text position is still wrong, though, and it's currently not possible to exit the psychic profile screen svn-id: r28324 --- engines/saga/events.cpp | 34 ++++++++++++++++++++++++++++++++++ engines/saga/events.h | 3 ++- engines/saga/sfuncs.cpp | 39 +++++++++------------------------------ 3 files changed, 45 insertions(+), 31 deletions(-) (limited to 'engines') diff --git a/engines/saga/events.cpp b/engines/saga/events.cpp index 73a603bf5c..5bdcf671d3 100644 --- a/engines/saga/events.cpp +++ b/engines/saga/events.cpp @@ -35,6 +35,7 @@ #include "saga/palanim.h" #include "saga/render.h" #include "saga/sndres.h" +#include "saga/rscfile.h" #include "saga/music.h" #include "saga/actor.h" @@ -344,6 +345,39 @@ int Events::handleOneShot(Event *event) { _vm->_actor->showActors(true); } break; + case kPsychicProfileBgEvent: + { + ResourceContext *context = _vm->_resource->getContext(GAME_RESOURCEFILE); + + byte *resourceData; + size_t resourceDataLength; + + _vm->_resource->loadResource(context, _vm->getResourceDescription()->psychicProfileResourceId, resourceData, resourceDataLength); + + byte *buf; + size_t buflen; + int width; + int height; + + _vm->decodeBGImage(resourceData, resourceDataLength, &buf, &buflen, &width, &height); + + const PalEntry *palette = (const PalEntry *)_vm->getImagePal(resourceData, resourceDataLength); + + Surface *bgSurface = _vm->_render->getBackGroundSurface(); + const Rect rect(width, height); + + bgSurface->blit(rect, buf); + _vm->_frameCount++; + + _vm->_gfx->setPalette(palette); + + free(buf); + free(resourceData); + + // Draw the scene. It won't be drawn by Render::drawScene(), as the RF_PLACARD is set + _vm->_scene->draw(); + } + break; case kAnimEvent: switch (event->op) { case kEventPlay: diff --git a/engines/saga/events.h b/engines/saga/events.h index d0af1fe916..2486525751 100644 --- a/engines/saga/events.h +++ b/engines/saga/events.h @@ -60,7 +60,8 @@ enum EventCodes { kScriptEvent, kCursorEvent, kGraphicsEvent, - kCutawayEvent + kCutawayEvent, + kPsychicProfileBgEvent }; enum EventOps { diff --git a/engines/saga/sfuncs.cpp b/engines/saga/sfuncs.cpp index 74ff8e88dc..5bbe5d3c5b 100644 --- a/engines/saga/sfuncs.cpp +++ b/engines/saga/sfuncs.cpp @@ -1484,8 +1484,7 @@ void Script::sfPsychicProfile(SCRIPTFUNC_PARAMS) { Event event; Event *q_event; - // FIXME: This still needs work: the actors are shown while the psychic - // profile is shown and the text placement and color are incorrect + // FIXME: This still needs work: the text placement is incorrect thread->wait(kWaitTypePlacard); @@ -1525,32 +1524,10 @@ void Script::sfPsychicProfile(SCRIPTFUNC_PARAMS) { q_event = _vm->_events->chain(q_event, &event); // Set the background and palette for the psychic profile - ResourceContext *context = _vm->_resource->getContext(GAME_RESOURCEFILE); - - byte *resourceData; - size_t resourceDataLength; - - _vm->_resource->loadResource(context, _vm->getResourceDescription()->psychicProfileResourceId, resourceData, resourceDataLength); - - byte *buf; - size_t buflen; - int width; - int height; - - _vm->decodeBGImage(resourceData, resourceDataLength, &buf, &buflen, &width, &height); - - const PalEntry *palette = (const PalEntry *)_vm->getImagePal(resourceData, resourceDataLength); - - Surface *bgSurface = _vm->_render->getBackGroundSurface(); - const Rect rect(width, height); - - bgSurface->blit(rect, buf); - _vm->_frameCount++; - - _vm->_gfx->setPalette(palette); + event.type = kEvTOneshot; + event.code = kPsychicProfileBgEvent; - free(buf); - free(resourceData); + q_event = _vm->_events->chain(q_event, &event); // Put the text in the center of the viewport, assuming it will fit on // one line. If we cannot make that assumption we'll need to extend @@ -1558,14 +1535,16 @@ void Script::sfPsychicProfile(SCRIPTFUNC_PARAMS) { // It doesn't end up in exactly the same spot as the original did it, // but it's close enough for now at least. + // FIXME: This assumption is wrong for the psychic profile, the text + // placement is incorrect + TextListEntry textEntry; - textEntry.knownColor = kKnownColorTransparent; - textEntry.effectKnownColor = kKnownColorBrightWhite; + textEntry.knownColor = kKnownColorBlack; textEntry.point.x = _vm->getDisplayWidth() / 2; textEntry.point.y = (_vm->_scene->getHeight() - _vm->_font->getHeight(kKnownFontMedium)) / 2; textEntry.font = kKnownFontVerb; - textEntry.flags = (FontEffectFlags)(kFontOutline | kFontCentered); + textEntry.flags = (FontEffectFlags)(kFontCentered); textEntry.text = thread->_strings->getString(stringId); _placardTextEntry = _vm->_scene->_textList.addEntry(textEntry); -- cgit v1.2.3 From 7498c6b43e73e7ebcafa4bc766ea06acdfe00b5f Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 30 Jul 2007 14:22:53 +0000 Subject: It's now possible to exit from the psychic profile screen in IHNM svn-id: r28325 --- engines/saga/interface.cpp | 18 ++++++++++++- engines/saga/scene.cpp | 67 ++++++++++++++++++++++++++++++++++++++++++++++ engines/saga/scene.h | 3 +++ engines/saga/script.h | 1 + engines/saga/sfuncs.cpp | 67 ++++------------------------------------------ 5 files changed, 93 insertions(+), 63 deletions(-) (limited to 'engines') diff --git a/engines/saga/interface.cpp b/engines/saga/interface.cpp index 150bf55111..bb1de8c70a 100644 --- a/engines/saga/interface.cpp +++ b/engines/saga/interface.cpp @@ -652,6 +652,12 @@ bool Interface::processAscii(uint16 ascii) { _protectHash = (_protectHash << 1) + toupper(*p); } break; + case kPanelPlacard: + if (_vm->getGameType() == GType_IHNM) { + // Any keypress here returns the user back to the game + _vm->_scene->clearPsychicProfile(); + } + break; } return false; } @@ -1548,7 +1554,10 @@ void Interface::update(const Point& mousePoint, int updateFlag) { _vm->_actor->abortSpeech(); if (_vm->_scene->isInIntro() || _fadeMode == kFadeOut || !_active) { - return; + // When opening the psychic profile, the interface is locked (_active is false) + // Don't return if the psychic profile is up, so that mouse clicks can be processed + if (!(_vm->getGameType() == GType_IHNM && _panelMode == kPanelPlacard)) + return; } if (_statusTextInput) { @@ -1694,6 +1703,13 @@ void Interface::update(const Point& mousePoint, int updateFlag) { // No mouse interaction break; + case kPanelPlacard: + if (_vm->getGameType() == GType_IHNM) { + // Any mouse click here returns the user back to the game + if (updateFlag & UPDATE_MOUSECLICK) + _vm->_scene->clearPsychicProfile(); + } + break; } _lastMousePoint = mousePoint; diff --git a/engines/saga/scene.cpp b/engines/saga/scene.cpp index 041553431b..2d85642891 100644 --- a/engines/saga/scene.cpp +++ b/engines/saga/scene.cpp @@ -1284,4 +1284,71 @@ void Scene::loadSceneEntryList(const byte* resourcePointer, size_t resourceLengt } } +void Scene::clearPlacard() { + static PalEntry cur_pal[PAL_ENTRIES]; + PalEntry *pal; + Event event; + Event *q_event; + + _vm->_interface->restoreMode(); + + _vm->_gfx->getCurrentPal(cur_pal); + + event.type = kEvTImmediate; + event.code = kPalEvent; + event.op = kEventPalToBlack; + event.time = 0; + event.duration = kNormalFadeDuration; + event.data = cur_pal; + + q_event = _vm->_events->queue(&event); + + event.type = kEvTOneshot; + event.code = kGraphicsEvent; + event.op = kEventClearFlag; + event.param = RF_PLACARD; + + q_event = _vm->_events->chain(q_event, &event); + + event.type = kEvTOneshot; + event.code = kTextEvent; + event.op = kEventRemove; + event.data = _vm->_script->getPlacardTextEntry(); + + q_event = _vm->_events->chain(q_event, &event); + + _vm->_scene->getBGPal(pal); + + event.type = kEvTImmediate; + event.code = kPalEvent; + event.op = kEventBlackToPal; + event.time = 0; + event.duration = kNormalFadeDuration; + event.data = pal; + + q_event = _vm->_events->chain(q_event, &event); + + event.type = kEvTOneshot; + event.code = kCursorEvent; + event.op = kEventShow; + + q_event = _vm->_events->chain(q_event, &event); + + event.type = kEvTOneshot; + event.code = kScriptEvent; + event.op = kEventThreadWake; + event.param = kWaitTypePlacard; + + q_event = _vm->_events->chain(q_event, &event); +} + +void Scene::clearPsychicProfile() { + _vm->_scene->clearPlacard(); + _vm->_actor->showActors(false); + _vm->_gfx->restorePalette(); + _vm->_scene->restoreScene(); + _vm->_interface->setMode(kPanelMain); + _vm->_interface->activate(); +} + } // End of namespace Saga diff --git a/engines/saga/scene.h b/engines/saga/scene.h index 99168e6504..d6414e5759 100644 --- a/engines/saga/scene.h +++ b/engines/saga/scene.h @@ -340,6 +340,9 @@ class Scene { return _vm->getDisplayInfo().sceneHeight; } + void clearPlacard(); + void clearPsychicProfile(); + private: void loadScene(LoadSceneParams *loadSceneParams); void loadSceneDescriptor(uint32 resourceId); diff --git a/engines/saga/script.h b/engines/saga/script.h index 5adfb6181a..b9864fb227 100644 --- a/engines/saga/script.h +++ b/engines/saga/script.h @@ -380,6 +380,7 @@ public: setPointerVerb(); } int getVerbType(VerbTypes verbType); + TextListEntry *getPlacardTextEntry() { return _placardTextEntry; } private: // When reading or writing data to the common buffer, we have to use a diff --git a/engines/saga/sfuncs.cpp b/engines/saga/sfuncs.cpp index 5bbe5d3c5b..f6aa21cb02 100644 --- a/engines/saga/sfuncs.cpp +++ b/engines/saga/sfuncs.cpp @@ -1315,11 +1315,6 @@ void Script::sfPlacard(SCRIPTFUNC_PARAMS) { Event event; Event *q_event; - if (_vm->getGameType() == GType_IHNM) { - warning("Psychic profile is not implemented"); - return; - } - thread->wait(kWaitTypePlacard); _vm->_interface->rememberMode(); @@ -1416,64 +1411,9 @@ void Script::sfPlacard(SCRIPTFUNC_PARAMS) { // Script function #49 (0x31) void Script::sfPlacardOff(SCRIPTFUNC_PARAMS) { - static PalEntry cur_pal[PAL_ENTRIES]; - PalEntry *pal; - Event event; - Event *q_event; - thread->wait(kWaitTypePlacard); - _vm->_interface->restoreMode(); - - _vm->_gfx->getCurrentPal(cur_pal); - - event.type = kEvTImmediate; - event.code = kPalEvent; - event.op = kEventPalToBlack; - event.time = 0; - event.duration = kNormalFadeDuration; - event.data = cur_pal; - - q_event = _vm->_events->queue(&event); - - event.type = kEvTOneshot; - event.code = kGraphicsEvent; - event.op = kEventClearFlag; - event.param = RF_PLACARD; - - q_event = _vm->_events->chain(q_event, &event); - - event.type = kEvTOneshot; - event.code = kTextEvent; - event.op = kEventRemove; - event.data = _placardTextEntry; - - q_event = _vm->_events->chain(q_event, &event); - - _vm->_scene->getBGPal(pal); - - event.type = kEvTImmediate; - event.code = kPalEvent; - event.op = kEventBlackToPal; - event.time = 0; - event.duration = kNormalFadeDuration; - event.data = pal; - - q_event = _vm->_events->chain(q_event, &event); - - event.type = kEvTOneshot; - event.code = kCursorEvent; - event.op = kEventShow; - - q_event = _vm->_events->chain(q_event, &event); - - event.type = kEvTOneshot; - event.code = kScriptEvent; - event.op = kEventThreadWake; - event.param = kWaitTypePlacard; - - q_event = _vm->_events->chain(q_event, &event); - + _vm->_scene->clearPlacard(); } void Script::sfPsychicProfile(SCRIPTFUNC_PARAMS) { @@ -1490,6 +1430,7 @@ void Script::sfPsychicProfile(SCRIPTFUNC_PARAMS) { _vm->_interface->rememberMode(); _vm->_interface->setMode(kPanelPlacard); + _vm->_gfx->savePalette(); stringId = thread->pop(); @@ -1576,7 +1517,9 @@ void Script::sfPsychicProfile(SCRIPTFUNC_PARAMS) { } void Script::sfPsychicProfileOff(SCRIPTFUNC_PARAMS) { - SF_stub("sfPsychicProfileOff", thread, nArgs); + thread->wait(kWaitTypePlacard); + + _vm->_scene->clearPsychicProfile(); } // Script function #50 (0x32) -- cgit v1.2.3 From c8aae376a92c9fbb6d37b81c35de6d030a37319a Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 30 Jul 2007 14:35:26 +0000 Subject: Process only mouse clicks in the psychic profile, not mouse movement svn-id: r28326 --- engines/saga/interface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/saga/interface.cpp b/engines/saga/interface.cpp index bb1de8c70a..ea69d75590 100644 --- a/engines/saga/interface.cpp +++ b/engines/saga/interface.cpp @@ -1556,7 +1556,7 @@ void Interface::update(const Point& mousePoint, int updateFlag) { if (_vm->_scene->isInIntro() || _fadeMode == kFadeOut || !_active) { // When opening the psychic profile, the interface is locked (_active is false) // Don't return if the psychic profile is up, so that mouse clicks can be processed - if (!(_vm->getGameType() == GType_IHNM && _panelMode == kPanelPlacard)) + if (!(_vm->getGameType() == GType_IHNM && _panelMode == kPanelPlacard && (updateFlag & UPDATE_MOUSECLICK))) return; } -- cgit v1.2.3 From f06f150c76f43f1dc97eadea5af7bf46ddba9ba4 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Mon, 30 Jul 2007 15:53:38 +0000 Subject: Restructured and cleaned-up IMD playing svn-id: r28327 --- engines/gob/coktelvideo.cpp | 935 +++++++++++++++++++++++++++++++ engines/gob/coktelvideo.h | 248 +++++++++ engines/gob/dataio.cpp | 99 +++- engines/gob/dataio.h | 34 +- engines/gob/game.cpp | 8 +- engines/gob/game.h | 3 +- engines/gob/game_v2.cpp | 52 +- engines/gob/gob.cpp | 8 +- engines/gob/gob.h | 4 +- engines/gob/imd.cpp | 1249 ------------------------------------------ engines/gob/imd.h | 143 ----- engines/gob/init.cpp | 10 +- engines/gob/inter_bargon.cpp | 42 +- engines/gob/inter_v2.cpp | 64 +-- engines/gob/module.mk | 3 +- engines/gob/mult_v2.cpp | 15 +- engines/gob/util.cpp | 10 +- engines/gob/videoplayer.cpp | 334 +++++++++++ engines/gob/videoplayer.h | 86 +++ 19 files changed, 1836 insertions(+), 1511 deletions(-) create mode 100644 engines/gob/coktelvideo.cpp create mode 100644 engines/gob/coktelvideo.h delete mode 100644 engines/gob/imd.cpp delete mode 100644 engines/gob/imd.h create mode 100644 engines/gob/videoplayer.cpp create mode 100644 engines/gob/videoplayer.h (limited to 'engines') diff --git a/engines/gob/coktelvideo.cpp b/engines/gob/coktelvideo.cpp new file mode 100644 index 0000000000..8f17810430 --- /dev/null +++ b/engines/gob/coktelvideo.cpp @@ -0,0 +1,935 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include "common/stdafx.h" +#include "common/endian.h" +#include "common/system.h" + +#include "gob/coktelvideo.h" + +namespace Gob { + +Imd::Imd() { + clear(false); +} + +Imd::~Imd() { + clear(); +} + +bool Imd::load(Common::SeekableReadStream &stream) { + unload(); + + _stream = &stream; + + // Version + uint16 handle = _stream->readUint16LE(); + _version = _stream->readByte(); + + // Version checking + if ((handle != 0) || (_version < 2)) { + warning("IMD Version incorrect (%d,%X)", handle, _version); + unload(); + return false; + } + + // Rest header + _features = _stream->readByte(); + _framesCount = _stream->readUint16LE(); + _x = _stream->readUint16LE(); + _y = _stream->readUint16LE(); + _width = _stream->readUint16LE(); + _height = _stream->readUint16LE(); + _flags = _stream->readUint16LE(); + _firstFramePos = _stream->readUint16LE(); + + // Palette + _stream->read((byte *) _palette, 768); + + // Standard coordinates + if (_version >= 3) { + _stdX = _stream->readUint16LE(); + if (_stdX > 1) { + warning("IMD: More than one standard coordinate quad found (%d)", _stdX); + unload(); + return false; + } + if (_stdX != 0) { + _stdX = _stream->readUint16LE(); + _stdY = _stream->readUint16LE(); + _stdWidth = _stream->readUint16LE(); + _stdHeight = _stream->readUint16LE(); + _features |= kFeaturesStdCoords; + } else + _stdX = -1; + } else + _stdX = -1; + + // Offset to frame positions table + uint32 framesPosPos = 0; + if (_version >= 4) { + framesPosPos = _stream->readUint32LE(); + if (framesPosPos != 0) { + _framesPos = new int32[_framesCount]; + assert(_framesPos); + _features |= kFeaturesFramesPos; + } + } + + // Offset to frame coordinates + uint32 framesCoordsPos = 0; + if (_features & kFeaturesFrameCoords) + framesCoordsPos = _stream->readUint32LE(); + + // Sound + if (_features & kFeaturesSound) { + _soundFreq = _stream->readUint16LE(); + _soundSliceSize = _stream->readUint16LE(); + _soundSlicesCount = _stream->readUint16LE(); + + if (_soundFreq < 0) + _soundFreq = -_soundFreq; + + if (_soundSlicesCount < 0) + _soundSlicesCount = -_soundSlicesCount - 1; + + if (_soundSlicesCount > 40) { + warning("IMD: More than 40 sound slices found (%d)", _soundSlicesCount); + unload(); + return false; + } + + _soundSliceLength = 1000 / (_soundFreq / _soundSliceSize); + _frameLength = _soundSliceLength; + + _soundStage = 1; + _hasSound = true; + + _audioStream = Audio::makeAppendableAudioStream(_soundFreq, 0); + } else + _frameLength = 1000 / 12; // 12 FPS for a video without sound + + // Sizes of the frame data and extra video buffer + if (_features & kFeaturesDataSize) { + _frameDataSize = _stream->readUint16LE(); + if (_frameDataSize == 0) { + _frameDataSize = _stream->readUint32LE(); + _vidBufferSize = _stream->readUint32LE(); + } else + _vidBufferSize = _stream->readUint16LE(); + } else { + _frameDataSize = _width * _height + 500; + if (!(_flags & 0x100) || (_flags & 0x1000)) + _vidBufferSize = _frameDataSize; + } + + // Frame positions table + if (_framesPos) { + _stream->seek(framesPosPos, SEEK_SET); + for (int i = 0; i < _framesCount; i++) + _framesPos[i] = _stream->readUint32LE(); + } + + // Frame coordinates table + if (_features & kFeaturesFrameCoords) { + _stream->seek(framesCoordsPos, SEEK_SET); + _frameCoords = new Coord[_framesCount]; + assert(_frameCoords); + for (int i = 0; i < _framesCount; i++) { + _frameCoords[i].left = _stream->readUint16LE(); + _frameCoords[i].top = _stream->readUint16LE(); + _frameCoords[i].right = _stream->readUint16LE(); + _frameCoords[i].bottom = _stream->readUint16LE(); + } + } + + // Seek to the first frame + _stream->seek(_firstFramePos, SEEK_SET); + + // Allocating working memory + _frameData = new byte[_frameDataSize + 500]; + assert(_frameData); + memset(_frameData, 0, _frameDataSize + 500); + _vidBuffer = new byte[_vidBufferSize + 500]; + assert(_vidBuffer); + memset(_vidBuffer, 0, _vidBufferSize + 500); + + return true; +} + +void Imd::unload() { + clear(); +} + +void Imd::setXY(int16 x, int16 y) { + // Adjusting the standard coordinates + if (_stdX != -1) { + if (x != -1) + _stdX = _stdX - _x + x; + if (y != -1) + _stdY = _stdY - _y + y; + } + + // Going through the coordinate table as well + if (_frameCoords) { + for (int i = 0; i < _framesCount; i++) { + if (_frameCoords[i].left != -1) { + if (x != -1) { + _frameCoords[i].left = _frameCoords[i].left - _x + x; + _frameCoords[i].right = _frameCoords[i].right - _x + x; + } + if (y != -1) { + _frameCoords[i].top = _frameCoords[i].top - _y + y; + _frameCoords[i].bottom = _frameCoords[i].bottom - _y + y; + } + } + } + } + + if (x != -1) + _x = x; + if (y != -1) + _y = y; +} + +void Imd::setVideoMemory(byte *vidMem, uint16 width, uint16 height) { + deleteVidMem(); + + _hasOwnVidMem = false; + _vidMem = vidMem; + _vidMemWidth = width; + _vidMemHeight = height; +} + +void Imd::setVideoMemory() { + deleteVidMem(); + + if ((_width > 0) && (_height > 0)) { + setXY(0, 0); + _hasOwnVidMem = true; + _vidMem = new byte[_width * _height]; + _vidMemWidth = _width; + _vidMemHeight = _height; + } +} + +void Imd::enableSound(Audio::Mixer &mixer) { + // Only possible on the first frame + if (_curFrame > 0) + return; + + _mixer = &mixer; + _soundEnabled = true; +} + +void Imd::disableSound() { + if (_audioStream) { + + if (_soundStage == 2) { + _audioStream->finish(); + _mixer->stopHandle(_audioHandle); + } else + delete _audioStream; + + _audioStream = 0; + } + _soundEnabled = false; + _mixer = 0; +} + +void Imd::seekFrame(int16 frame, int16 whence, bool restart) { + if (!_stream) + // Nothing to do + return; + + // Find the frame to which to seek + if (whence == SEEK_CUR) + frame += _curFrame; + else if (whence == SEEK_END) + frame = _framesCount - frame - 1; + else if (whence != SEEK_SET) + return; + + if ((frame >= _framesCount) || (frame == _curFrame)) + // Nothing to do + return; + + // Try every possible way to find a file offset to that frame + uint32 framePos = 0; + if (frame == 0) { + framePos = _firstFramePos; + } else if (frame == 1) { + framePos = _firstFramePos; + _stream->seek(framePos, SEEK_SET); + framePos += _stream->readUint16LE() + 4; + } else if (_framesPos) { + framePos = _framesPos[frame]; + } else if (restart && (_soundStage == 0)) { + for (int i = ((frame > _curFrame) ? _curFrame : 0); i <= frame; i++) + processFrame(i); + } else + error("Frame %d is not directly accessible", frame); + + // Seek + _stream->seek(framePos, SEEK_SET); + _curFrame = frame; +} + +CoktelVideo::State Imd::nextFrame() { + return processFrame(_curFrame); +} + +void Imd::waitEndFrame() { + if (_soundEnabled && _hasSound) { + if (_soundStage != 2) + return; + + if (_skipFrames == 0) { + int32 waitTime = (_curFrame * _soundSliceLength) - + (g_system->getMillis() - _soundStartTime); + + if (waitTime < 0) { + _skipFrames = -waitTime / _soundSliceLength; + warning("IMD A/V sync broken, skipping %d frame(s)", _skipFrames + 1); + } else if (waitTime > 0) + g_system->delayMillis(waitTime); + + } else + _skipFrames--; + } else + g_system->delayMillis(_frameLength); +} + +void Imd::copyCurrentFrame(byte *dest, uint16 x, uint16 y, uint16 width, int16 transp) { + if (!_vidMem) + return; + + dest += width * y; + + uint16 copyWidth = MIN(width - x, _width); + uint16 destPitch = width - x; + byte *vidMem = _vidMem; + + if (transp < 0) { + // No transparency + if ((x > 0) || (_width != width)) { + // Copy row-by-row + for (int i = 0; i < _height; i++) { + dest += x; + memcpy(dest, vidMem, copyWidth); + dest += destPitch; + vidMem += _width; + } + + } else + // Dimensions fit, copy everything at once + memcpy(dest, _vidMem, _width * _height); + + return; + } + + // Transparency, copy per pixel + for (int i = 0; i < _height; i++) { + byte *s = vidMem; + byte *d = dest; + + d += x; + for (int j = 0; j < _width; j++) { + if (*s != transp) + *d = *s; + + s++; + d++; + } + + dest += width;; + vidMem += _width; + } +} + +void Imd::deleteVidMem(bool del) { + if (del) { + if (_hasOwnVidMem) + delete[] _vidMem; + } + + _hasOwnVidMem = false; + _vidMem = 0; + _vidMemWidth = _vidMemHeight = 0; +} + +void Imd::clear(bool del) { + if (del) { + delete[] _framesPos; + delete[] _frameCoords; + delete[] _frameData; + delete[] _vidBuffer; + + disableSound(); + } + + _stream = 0; + + _version = 0; + _features = 0; + _flags = 0; + _x = _y = _width = _height = 0; + _stdX = _stdY = _stdWidth = _stdHeight = 0; + _framesCount = _curFrame = 0; + _framesPos = 0; + _firstFramePos = 0; + _frameCoords = 0; + + _frameDataSize = _vidBufferSize = 0; + _frameData = _vidBuffer = 0; + + memset(_palette, 0, 768); + + deleteVidMem(del); + + _hasSound = false; + _soundEnabled = false; + _soundStage = 0; + _soundStartTime = 0; + _skipFrames = 0; + + _soundFreq = 0; + _soundSliceSize = 0; + _soundSlicesCount = 0; + _soundSliceLength = 0; + + _audioStream = 0; + + _frameLength = 0; + _lastFrameTime = 0; +} + +CoktelVideo::State Imd::processFrame(int16 frame) { + State state; + uint32 cmd = 0; + int16 xBak, yBak, heightBak, widthBak; + bool hasNextCmd = false; + bool startSound = false; + + if (!_stream || (frame >= _framesCount)) { + state.flags = kStateBreak; + return state; + } + + if (frame != _curFrame) { + state.flags |= kStateSeeked; + seekFrame(frame, SEEK_SET); + } + + state.left = xBak = _x; + state.top = yBak = _y; + state.bottom = heightBak = _height; + state.right = widthBak = _width; + state.right += state.left - 1; + state.bottom += state.top - 1; + +/* if ((frame == 0) && (_features & 0x8)) + _vm->_video->setPalette(_palette);*/ + + do { + if (frame != 0) { + if (_stdX != -1) { + state.left = _x = _stdX; + state.top = _y = _stdY; + state.right = _width = _stdWidth; + state.bottom = _height = _stdHeight; + state.right += state.left - 1; + state.bottom += state.top - 1; + state.flags |= kStateStdCoords; + } + if (_frameCoords && + (_frameCoords[frame].left != -1)) { + state.left = _x = _frameCoords[frame].left; + state.top = _y = _frameCoords[frame].top; + state.right = _width = + _frameCoords[frame].right - _x + 1; + state.bottom = _height = + _frameCoords[frame].bottom - _y + 1; + state.right += state.left - 1; + state.bottom += state.top - 1; + state.flags |= kStateFrameCoords; + } + } + + cmd = _stream->readUint16LE(); + + if ((cmd & 0xFFF8) == 0xFFF0) { + if (cmd == 0xFFF0) { + _stream->seek(2, SEEK_CUR); + cmd = _stream->readUint16LE(); + } + + if (cmd == 0xFFF1) { + state.flags = kStateBreak; + continue; + } else if (cmd == 0xFFF2) { // Skip (16 bit) + cmd = _stream->readUint16LE(); + _stream->seek(cmd, SEEK_CUR); + state.flags = kStateBreak; + continue; + } else if (cmd == 0xFFF3) { // Skip (32 bit) + cmd = _stream->readUint32LE(); + _stream->seek(cmd, SEEK_CUR); + state.flags = kStateBreak; + continue; + } + } + + if (_soundStage != 0) { + byte *soundBuf; + +/* if (!hasNextCmd) + waitEndSoundSlice();*/ + + // Next sound slice data + if (cmd == 0xFF00) { + + if (!hasNextCmd && _soundEnabled) { + soundBuf = new byte[_soundSliceSize]; + assert(soundBuf); + + _stream->read(soundBuf, _soundSliceSize); + unsignedToSigned(soundBuf, _soundSliceSize); + _audioStream->queueBuffer(soundBuf, _soundSliceSize); + } else + _stream->seek(_soundSliceSize, SEEK_CUR); + + cmd = _stream->readUint16LE(); + + // Initial sound data (all slices) + } else if (cmd == 0xFF01) { + int dataLength = _soundSliceSize * _soundSlicesCount; + + if (!hasNextCmd && _soundEnabled) { + soundBuf = new byte[dataLength]; + assert(soundBuf); + + _stream->read(soundBuf, dataLength); + unsignedToSigned(soundBuf, dataLength); + + _soundStage = 1; + startSound = true; + _audioStream->queueBuffer(soundBuf, dataLength); + } else + _stream->seek(dataLength, SEEK_CUR); + + cmd = _stream->readUint16LE(); + + // Empty sound slice + } else if (!hasNextCmd && (_soundEnabled)) { + soundBuf = new byte[_soundSliceSize]; + assert(soundBuf); + + memset(soundBuf, 0, _soundSliceSize); + _audioStream->queueBuffer(soundBuf, _soundSliceSize); + } + } + + // Set palette + if (cmd == 0xFFF4) { + _stream->seek(2, SEEK_CUR); + state.flags |= kStatePalette; + _stream->read(_palette, 768); + cmd = _stream->readUint16LE(); + } + + hasNextCmd = false; + + // Jump to frame + if (cmd == 0xFFFD) { + + frame = _stream->readUint16LE(); + if (_framesPos) { + _curFrame = frame; + _stream->seek(_framesPos[frame], SEEK_SET); + + hasNextCmd = true; + state.flags |= kStateJump; + } + + } else if (cmd == 0xFFFC) { + + state.flags |= 1; + cmd = _stream->readUint32LE(); + _stream->read(_frameData, cmd + 2); + + int16 left = _x; + int16 top = _y; + int16 right = _width + left; + int16 bottom = _height + top; + + if (!_vidMem) + setVideoMemory(); + + if (_vidMemWidth < right) { + left = 0; + right = _width; + } + if (_vidMemWidth < right) + right = _vidMemWidth; + if (_vidMemHeight < bottom) { + top = 0; + bottom = _height; + } + if (_vidMemHeight < bottom) + bottom = _vidMemHeight; + + _x = left; + _y = top; + _height = bottom - top; + _width = right - left; + + renderFrame(); + + state.flags |= _frameData[0]; + + // Frame video data + } else if (cmd != 0) { + + _stream->read(_frameData, cmd + 2); + + renderFrame(); + + state.flags |= _frameData[0]; + + } else + state.flags |= kStateNoData; + + } while (hasNextCmd); + + if (startSound && _soundEnabled) { + _mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_audioHandle, _audioStream); + _soundStartTime = g_system->getMillis(); + _skipFrames = 0; + _soundStage = 2; + } + + _x = xBak; + _y = yBak; + _width = widthBak; + _height = heightBak; + + _curFrame++; + if ((_curFrame == _framesCount) && (_soundStage == 2)) { + _audioStream->finish(); + _mixer->stopHandle(_audioHandle); + _audioStream = 0; + _soundStage = 0; + } + + _lastFrameTime = g_system->getMillis(); + return state; +} + +CoktelVideo::State Imd::peekFrame(int16 frame) { + State state; + uint32 posBak; + uint32 tmp; + uint16 cmd; + int16 frameBak; + + if (!_stream) { + state.flags = kStateBreak; + return state; + } + + posBak = _stream->pos(); + frameBak = _curFrame; + + if (_curFrame != frame) { + state.flags |= kStateSeeked; + seekFrame(frame, SEEK_SET); + } + + do { + if (frame != 0) { + if (_stdX != -1) + state.flags |= kStateStdCoords; + if (_frameCoords && (_frameCoords[frame].left != -1)) + state.flags |= kStateFrameCoords; + } + + cmd = _stream->readUint16LE(); + + if ((cmd & 0xFFF8) == 0xFFF0) { + if (cmd == 0xFFF0) { + _stream->seek(2, SEEK_CUR); + cmd = _stream->readUint16LE(); + } + + if (cmd == 0xFFF1) { + state.flags = kStateBreak; + continue; + } else if (cmd == 0xFFF2) { // Skip (16 bit) + cmd = _stream->readUint16LE(); + _stream->seek(cmd, SEEK_CUR); + state.flags = kStateBreak; + continue; + } else if (cmd == 0xFFF3) { // Skip (32 bit) + tmp = _stream->readUint32LE(); + _stream->seek(cmd, SEEK_CUR); + state.flags = kStateBreak; + continue; + } + } + + // Jump to frame + if (cmd == 0xFFFD) { + frame = _stream->readUint16LE(); + if (_framesPos) { + _stream->seek(_framesPos[frame], SEEK_SET); + state.flags |= kStateJump; + continue; + } + break; + } + + // Next sound slice data + if (cmd == 0xFF00) { + _stream->seek(_soundSliceSize, SEEK_CUR); + cmd = _stream->readUint16LE(); + // Initial sound data (all slices) + } else if (cmd == 0xFF01) { + _stream->seek(_soundSliceSize * _soundSlicesCount, SEEK_CUR); + cmd = _stream->readUint16LE(); + } + + // Frame video data + if (cmd != 0) { + _stream->read(_frameData, 5); + state.flags |= _frameData[0]; + } else + state.flags |= kStateNoData; + + break; + + } while (true); + + _stream->seek(posBak, SEEK_SET); + _curFrame = frameBak; + return state; +} + +void Imd::renderFrame() { + if (!_frameData || (_width <= 0) || (_height <= 0)) + return; + + if (!_vidMem) + setVideoMemory(); + + byte *dataPtr = _frameData; + int16 imdX = _x; + int16 imdY = _y; + int16 imdW = _width; + int16 imdH = _height; + int16 sW = _vidMemWidth; + byte *imdVidMem = _vidMem + sW * imdY + imdX; + uint8 type = *dataPtr++; + byte *srcPtr = dataPtr; + + + if (type & 0x10) { // Palette data + type ^= 0x10; + dataPtr += 49; + } + + srcPtr = dataPtr; + if (type & 0x80) { // Frame data is compressed + srcPtr = _vidBuffer; + type &= 0x7F; + if ((type == 2) && (imdW == sW)) { + frameUncompressor(imdVidMem, dataPtr); + return; + } else + frameUncompressor(srcPtr, dataPtr); + } + + uint16 pixCount, pixWritten; + byte *imdVidMemBak; + + if (type == 2) { // Whole block + for (int i = 0; i < imdH; i++) { + memcpy(imdVidMem, srcPtr, imdW); + srcPtr += imdW; + imdVidMem += sW; + } + } else if (type == 1) { // Sparse block + imdVidMemBak = imdVidMem; + for (int i = 0; i < imdH; i++) { + pixWritten = 0; + while (pixWritten < imdW) { + pixCount = *srcPtr++; + if (pixCount & 0x80) { // data + pixCount = MIN((pixCount & 0x7F) + 1, imdW - pixWritten); + memcpy(imdVidMem, srcPtr, pixCount); + + pixWritten += pixCount; + imdVidMem += pixCount; + srcPtr += pixCount; + } else { // "hole" + pixCount = (pixCount + 1) % 256; + pixWritten += pixCount; + imdVidMem += pixCount; + } + } + imdVidMemBak += sW; + imdVidMem = imdVidMemBak; + } + } else if (type == 0x42) { // Whole quarter-wide block + for (int i = 0; i < imdH; i++) { + imdVidMemBak = imdVidMem; + + for (int j = 0; j < imdW; j += 4, imdVidMem += 4, srcPtr++) + memset(imdVidMem, *srcPtr, 4); + + imdVidMemBak += sW; + imdVidMem = imdVidMemBak; + } + } else if ((type & 0xF) == 2) { // Whole half-high block + for (; imdH > 1; imdH -= 2, imdVidMem += sW + sW, srcPtr += imdW) { + memcpy(imdVidMem, srcPtr, imdW); + memcpy(imdVidMem + sW, srcPtr, imdW); + } + if (imdH == -1) + memcpy(imdVidMem, srcPtr, imdW); + } else { // Sparse half-high block + imdVidMemBak = imdVidMem; + for (int i = 0; i < imdH; i += 2) { + pixWritten = 0; + while (pixWritten < imdW) { + pixCount = *srcPtr++; + if (pixCount & 0x80) { // data + pixCount = MIN((pixCount & 0x7F) + 1, imdW - pixWritten); + memcpy(imdVidMem, srcPtr, pixCount); + memcpy(imdVidMem + sW, srcPtr, pixCount); + + pixWritten += pixCount; + imdVidMem += pixCount; + srcPtr += pixCount; + } else { // "hole" + pixCount = (pixCount + 1) % 256; + pixWritten += pixCount; + imdVidMem += pixCount; + } + } + imdVidMemBak += sW + sW; + imdVidMem = imdVidMemBak; + } + } +} + +void Imd::frameUncompressor(byte *dest, byte *src) { + int i; + byte buf[4370]; + uint16 chunkLength; + uint16 frameLength; + uint16 bufPos1; + uint16 bufPos2; + uint16 tmp; + uint8 chunkBitField; + uint8 chunkCount; + bool mode; + + frameLength = READ_LE_UINT16(src); + src += 4; + + if ((READ_LE_UINT16(src) == 0x1234) && (READ_LE_UINT16(src + 2) == 0x5678)) { + src += 4; + bufPos1 = 273; + mode = 1; // 123Ch (cmp al, 12h) + } else { + bufPos1 = 4078; + mode = 0; // 275h (jnz +2) + } + + memset(buf, 32, bufPos1); + chunkCount = 1; + chunkBitField = 0; + + while (frameLength > 0) { + chunkCount--; + if (chunkCount == 0) { + tmp = *src++; + chunkCount = 8; + chunkBitField = tmp; + } + if (chunkBitField % 2) { + chunkBitField >>= 1; + buf[bufPos1] = *src; + *dest++ = *src++; + bufPos1 = (bufPos1 + 1) % 4096; + frameLength--; + continue; + } + chunkBitField >>= 1; + + tmp = READ_LE_UINT16(src); + src += 2; + chunkLength = ((tmp & 0xF00) >> 8) + 3; + + if ((mode && ((chunkLength & 0xFF) == 0x12)) || + (!mode && (chunkLength == 0))) + chunkLength = *src++ + 0x12; + + bufPos2 = (tmp & 0xFF) + ((tmp >> 4) & 0x0F00); + if (((tmp + chunkLength) >= 4096) || + ((chunkLength + bufPos1) >= 4096)) { + + for (i = 0; i < chunkLength; i++, dest++) { + *dest = buf[bufPos2]; + buf[bufPos1] = buf[bufPos2]; + bufPos1 = (bufPos1 + 1) % 4096; + bufPos2 = (bufPos2 + 1) % 4096; + } + + } else if (((tmp + chunkLength) < bufPos1) || + ((chunkLength + bufPos1) < bufPos2)) { + + memcpy(dest, buf + bufPos2, chunkLength); + memmove(buf + bufPos1, buf + bufPos2, chunkLength); + + dest += chunkLength; + bufPos1 += chunkLength; + bufPos2 += chunkLength; + + } else { + + for (i = 0; i < chunkLength; i++, dest++, bufPos1++, bufPos2++) { + *dest = buf[bufPos2]; + buf[bufPos1] = buf[bufPos2]; + } + + } + frameLength -= chunkLength; + + } +} + +} // End of namespace Gob diff --git a/engines/gob/coktelvideo.h b/engines/gob/coktelvideo.h new file mode 100644 index 0000000000..4e7512eb8b --- /dev/null +++ b/engines/gob/coktelvideo.h @@ -0,0 +1,248 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#ifndef GOB_COKTELVIDEO_H +#define GOB_COKTELVIDEO_H + +#include "common/stream.h" +#include "sound/mixer.h" +#include "sound/audiostream.h" + +namespace Gob { + +/** Common interface for handling Coktel Vision videos and derivated formats. */ +class CoktelVideo { +public: + enum Features { + kFeaturesNone = 0, + /** Has an own palette. */ + kFeaturesPalette = 8, + /** Suggests a data size. */ + kFeaturesDataSize = 0x20, + /** Has sound. */ + kFeaturesSound = 0x40, + /** Has specific frame coordinates. */ + kFeaturesFrameCoords = 0x80, + /** Has general standard coordinates. */ + kFeaturesStdCoords = 0x100, + /** Has a frame positions table. */ + kFeaturesFramesPos = 0x200 + }; + + enum StateFlags { + kStateNone = 0, + /** Changed the palette. */ + kStatePalette = 0x10, + /** Performed a jump to another frame. */ + kStateJump = 0x200, + /** Updated according to the specific frame coordinates. */ + kStateFrameCoords = 0x400, + /** Got no frame data. */ + kStateNoData = 0x800, + /** Updated according to the general standard coordinates. */ + kStateStdCoords = 0x1000, + /** Had to explicitely seek to the frame. */ + kStateSeeked = 0x2000, + /** Reached a break-point. */ + kStateBreak = 0x8000 + }; + + struct State { + /** Left-most value of the updated rectangle. */ + int16 left; + /** Top-most value of the updated rectangle. */ + int16 top; + /** Right-most value of the updated rectangle. */ + int16 right; + /** Bottom-most value of the updated rectangle. */ + int16 bottom; + /** Set accordingly to what was done. */ + uint32 flags; + }; + + virtual ~CoktelVideo() { } + + /** Returns the features the loaded video possesses. */ + virtual uint16 getFeatures() const = 0; + /** Returns the x coordinate of the video. */ + virtual int16 getX() const = 0; + /** Returns the y coordinate of the video. */ + virtual int16 getY() const = 0; + /** Returns the width of the video. */ + virtual int16 getWidth() const = 0; + /** Returns the height of the video. */ + virtual int16 getHeight() const = 0; + /** Returns the number of frames the loaded video has. */ + virtual int16 getFramesCount() const = 0; + /** Returns the current frame number. */ + virtual int16 getCurrentFrame() const = 0; + /** Returns the frame rate. */ + virtual int16 getFrameRate() const = 0; + /** Returns the number of frames the video lags behind the audio. */ + virtual uint32 getSyncLag() const = 0; + /** Returns the current frame's palette. */ + virtual const byte *getPalette() const = 0; + + /** Load a video out of a stream. */ + virtual bool load(Common::SeekableReadStream &stream) = 0; + /** Unload the currently loaded video. */ + virtual void unload() = 0; + + /** Set the coordinations where to draw the video. */ + virtual void setXY(int16 x, int16 y) = 0; + /** Use a specific memory block as video memory. */ + virtual void setVideoMemory(byte *vidMem, uint16 width, uint16 height) = 0; + /** Use an own memory block as video memory. */ + virtual void setVideoMemory() = 0; + + /** Play sound (if the IMD has sound). */ + virtual void enableSound(Audio::Mixer &mixer) = 0; + /** Don't play sound or stop currently playing sound. */ + virtual void disableSound() = 0; + + /** Seek to a specific frame. + * + * @param frame The frame to which to seek. + * @param whence The offset from whence the frame is given. + * @param restart Restart the video to reach an otherwise inaccessible frame? + */ + virtual void seekFrame(int16 frame, int16 whence = SEEK_SET, bool restart = false) = 0; + + /** Render the next frame. */ + virtual State nextFrame() = 0; + /** Look at what a frame would do/have, without actually rendering the frame. */ + virtual State peekFrame(int16 frame) = 0; + /** Wait for the frame to end. */ + virtual void waitEndFrame() = 0; + + /** Copy the current frame. + * + * @param dest The memory to which to copy the current frame + * @param x The x position to where to copy. + * @param y The y position to where to copy. + * @param pitch The buffer's width. + * @param transp Which color should be seen as transparent? + */ + virtual void copyCurrentFrame(byte *dest, uint16 x, uint16 y, uint16 width, int16 transp = -1) = 0; +}; + +/** Coktel Vision's IMD files. + */ +class Imd : public CoktelVideo { +public: + Imd(); + ~Imd(); + + uint16 getFeatures() const { return _features; } + int16 getX() const { return _x; } + int16 getY() const { return _y; } + int16 getWidth() const { return _width; } + int16 getHeight() const { return _height; } + int16 getFramesCount() const { return _framesCount; } + int16 getCurrentFrame() const { return _curFrame; } + int16 getFrameRate() const { if (_hasSound) return 1000 / _soundSliceLength; return 12; } + uint32 getSyncLag() const { return _skipFrames; } + const byte *getPalette() const { return _palette; } + + bool load(Common::SeekableReadStream &stream); + void unload(); + + void setXY(int16 x, int16 y); + void setVideoMemory(byte *vidMem, uint16 width, uint16 height); + void setVideoMemory(); + + void enableSound(Audio::Mixer &mixer); + void disableSound(); + + void seekFrame(int16 frame, int16 whence = SEEK_SET, bool restart = false); + + State nextFrame(); + State peekFrame(int16 frame); + void waitEndFrame(); + + void copyCurrentFrame(byte *dest, uint16 x, uint16 y, uint16 width, int16 transp = -1); + +protected: + struct Coord { + int16 left; + int16 top; + int16 right; + int16 bottom; + } PACKED_STRUCT; + + Common::SeekableReadStream *_stream; + uint8 _version; + uint16 _features; + int16 _flags; + int16 _x, _y, _width, _height; + int16 _stdX, _stdY, _stdWidth, _stdHeight; + int16 _framesCount, _curFrame; + int32 *_framesPos; + int32 _firstFramePos; + Coord *_frameCoords; + + int32 _frameDataSize, _vidBufferSize; + byte *_frameData, *_vidBuffer; + + byte _palette[768]; + + bool _hasOwnVidMem; + byte *_vidMem; + uint16 _vidMemWidth, _vidMemHeight; + + bool _hasSound; + bool _soundEnabled; + uint8 _soundStage; // (0: no sound, 1: loaded, 2: playing) + uint32 _soundStartTime; + uint32 _skipFrames; + + int16 _soundFreq; + uint16 _soundSliceSize; + int16 _soundSlicesCount; + uint16 _soundSliceLength; + + Audio::AppendableAudioStream *_audioStream; + Audio::SoundHandle _audioHandle; + + uint32 _frameLength; + uint32 _lastFrameTime; + + Audio::Mixer *_mixer; + + void unsignedToSigned(byte *buffer, int length) { + while (length-- > 0) *buffer++ ^= 0x80; + } + + void deleteVidMem(bool del = true); + void clear(bool del = true); + + State processFrame(int16 frame); + void renderFrame(); + void frameUncompressor(byte *dest, byte *src); +}; + +} // End of namespace Gob + +#endif // GOB_COKTELVIDEO_H diff --git a/engines/gob/dataio.cpp b/engines/gob/dataio.cpp index 7ded953427..73318adc14 100644 --- a/engines/gob/dataio.cpp +++ b/engines/gob/dataio.cpp @@ -33,6 +33,83 @@ namespace Gob { +DataStream::DataStream(DataIO &io, int16 handle, uint32 dSize, bool dispose) { + _io = &io; + _handle = handle; + _size = dSize; + _dispose = dispose; + + _data = 0; + _stream = 0; +} + +DataStream::DataStream(byte *buf, uint32 dSize, bool dispose) { + _data = buf; + _size = dSize; + _stream = new Common::MemoryReadStream(_data, _size); + _dispose = dispose; + + _io = 0; + _handle = -1; +} + +DataStream::~DataStream() { + delete _stream; + + if (_dispose) { + delete[] _data; + if ((_handle >= 0) && _io) + _io->closeData(_handle); + } +} + +uint32 DataStream::pos() const { + if (_stream) + return _stream->pos(); + + uint32 resPos = _io->getChunkPos(_handle); + if (resPos != 0xFFFFFFFF) + return resPos; + + return _io->file_getHandle(_handle)->pos(); +} + +uint32 DataStream::size() const { + if (_stream) + return _stream->size(); + + return _size; +} + +void DataStream::seek(int32 offset, int whence) { + if (_stream) + _stream->seek(offset, whence); + + int32 resPos = _io->seekChunk(_handle, offset, whence); + if (resPos != -1) + return; + + _io->file_getHandle(_handle)->seek(offset, whence); +} + +bool DataStream::eos() const { + if (_stream) + return _stream->eos(); + + return pos() >= size(); +} + +uint32 DataStream::read(void *dataPtr, uint32 dataSize) { + if (_stream) + return _stream->read(dataPtr, dataSize); + + int32 res = _io->readChunk(_handle, (byte *) dataPtr, dataSize); + if (res >= 0) + return res; + + return _io->file_getHandle(_handle)->read((byte *) dataPtr, dataSize); +} + DataIO::DataIO(GobEngine *vm) : _vm(vm) { for (int i = 0; i < MAX_DATA_FILES; i++) { _dataFiles[i] = 0; @@ -115,6 +192,10 @@ Common::File *DataIO::file_getHandle(int16 handle) { return &_filesHandles[handle]; } +const Common::File *DataIO::file_getHandle(int16 handle) const { + return &_filesHandles[handle]; +} + int16 DataIO::file_open(const char *path, Common::File::AccessMode mode) { int16 i; @@ -226,7 +307,7 @@ int16 DataIO::seekChunk(int16 handle, int32 pos, int16 from) { return _chunkPos[file * MAX_SLOT_COUNT + slot]; } -uint32 DataIO::getChunkPos(int16 handle) { +uint32 DataIO::getChunkPos(int16 handle) const { int16 file; int16 slot; @@ -390,6 +471,15 @@ int16 DataIO::openData(const char *path, Common::File::AccessMode mode) { return file_open(path, mode); } +DataStream *DataIO::openAsStream(int16 handle, bool dispose) { + uint32 curPos = getPos(handle); + seekData(handle, 0, SEEK_END); + uint32 size = getPos(handle); + seekData(handle, curPos, SEEK_SET); + + return new DataStream(*this, handle, size, dispose); +} + int32 DataIO::readData(int16 handle, byte *buf, uint16 size) { int32 res; @@ -492,4 +582,11 @@ byte *DataIO::getData(const char *path) { return data; } +DataStream *DataIO::getDataStream(const char *path) { + uint32 size = getDataSize(path); + byte *data = getData(path); + + return new DataStream(data, size); +} + } // End of namespace Gob diff --git a/engines/gob/dataio.h b/engines/gob/dataio.h index 08498a4f7e..3560093d9e 100644 --- a/engines/gob/dataio.h +++ b/engines/gob/dataio.h @@ -37,6 +37,32 @@ namespace Gob { #define MAX_DATA_FILES 8 #define MAX_SLOT_COUNT 8 +class DataIO; + +class DataStream : public Common::SeekableReadStream { +public: + DataStream(DataIO &io, int16 handle, uint32 dSize, bool dispose = false); + DataStream(byte *buf, uint32 dSize, bool dispose = true); + virtual ~DataStream(); + + virtual uint32 pos() const; + virtual uint32 size() const; + + virtual void seek(int32 offset, int whence = SEEK_SET); + + virtual bool eos() const; + + virtual uint32 read(void *dataPtr, uint32 dataSize); + +private: + DataIO *_io; + int16 _handle; + uint32 _size; + byte *_data; + Common::MemoryReadStream *_stream; + bool _dispose; +}; + class DataIO { public: struct ChunkDesc { @@ -55,6 +81,8 @@ public: void closeData(int16 handle); int16 openData(const char *path, Common::File::AccessMode mode = Common::File::kFileReadMode); + DataStream *openAsStream(int16 handle, bool dispose = false); + int32 readData(int16 handle, byte *buf, uint16 size); byte readByte(int16 handle); uint16 readUint16(int16 handle); @@ -64,6 +92,7 @@ public: uint32 getPos(int16 handle); int32 getDataSize(const char *name); byte *getData(const char *path); + DataStream *getDataStream(const char *path); DataIO(class GobEngine *vm); ~DataIO(); @@ -85,13 +114,16 @@ protected: int16 file_open(const char *path, Common::File::AccessMode mode = Common::File::kFileReadMode); Common::File *file_getHandle(int16 handle); + const Common::File *file_getHandle(int16 handle) const; int16 getChunk(const char *chunkName); char freeChunk(int16 handle); int32 readChunk(int16 handle, byte *buf, uint16 size); int16 seekChunk(int16 handle, int32 pos, int16 from); - uint32 getChunkPos(int16 handle); + uint32 getChunkPos(int16 handle) const; int32 getChunkSize(const char *chunkName); + +friend class DataStream; }; } // End of namespace Gob diff --git a/engines/gob/game.cpp b/engines/gob/game.cpp index e47dc1809f..b625a35258 100644 --- a/engines/gob/game.cpp +++ b/engines/gob/game.cpp @@ -379,10 +379,12 @@ int16 Game::checkKeys(int16 *pMouseX, int16 *pMouseY, _vm->_inter->_soundEndTimeKey = 0; } - _vm->_util->getMouseState(pMouseX, pMouseY, pButtons); + if (pMouseX && pMouseY && pButtons) { + _vm->_util->getMouseState(pMouseX, pMouseY, pButtons); - if (*pButtons == 3) - *pButtons = 0; + if (*pButtons == 3) + *pButtons = 0; + } return _vm->_util->checkKey(); } diff --git a/engines/gob/game.h b/engines/gob/game.h index 2b684a179f..c83497eaeb 100644 --- a/engines/gob/game.h +++ b/engines/gob/game.h @@ -147,7 +147,8 @@ public: void evaluateScroll(int16 x, int16 y); - int16 checkKeys(int16 *pMousex, int16 *pMouseY, int16 *pButtons, char handleMouse); + int16 checkKeys(int16 *pMousex = 0, int16 *pMouseY = 0, + int16 *pButtons = 0, char handleMouse = 0); void start(void); void totSub(int8 flags, const char *newTotFile); void switchTotSub(int16 index, int16 skipPlay); diff --git a/engines/gob/game_v2.cpp b/engines/gob/game_v2.cpp index 4ccd6d718e..f7f7a10b92 100644 --- a/engines/gob/game_v2.cpp +++ b/engines/gob/game_v2.cpp @@ -1,27 +1,27 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ + /* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ #include "common/stdafx.h" #include "common/endian.h" @@ -34,13 +34,13 @@ #include "gob/dataio.h" #include "gob/draw.h" #include "gob/goblin.h" -#include "gob/imd.h" #include "gob/inter.h" #include "gob/mult.h" #include "gob/parse.h" #include "gob/scenery.h" #include "gob/sound.h" #include "gob/video.h" +#include "gob/videoplayer.h" namespace Gob { @@ -271,7 +271,7 @@ void Game_v2::playTot(int16 skipPlay) { _vm->_snd->freeSample(_soundSamples[i]); } - _vm->_imdPlayer->closeImd(); + _vm->_vidPlayer->closeVideo(); if (_totToLoad[0] == 0) break; diff --git a/engines/gob/gob.cpp b/engines/gob/gob.cpp index 9a14194972..f1bec2b8d5 100644 --- a/engines/gob/gob.cpp +++ b/engines/gob/gob.cpp @@ -48,7 +48,7 @@ #include "gob/parse.h" #include "gob/scenery.h" #include "gob/music.h" -#include "gob/imd.h" +#include "gob/videoplayer.h" #include "gob/saveload.h" namespace Gob { @@ -72,7 +72,7 @@ GobEngine::GobEngine(OSystem *syst) : Engine(syst) { _snd = 0; _adlib = 0; _mult = 0; _game = 0; _global = 0; _cdrom = 0; - _dataIO = 0; _goblin = 0; _imdPlayer = 0; + _dataIO = 0; _goblin = 0; _vidPlayer = 0; _init = 0; _inter = 0; _map = 0; _palAnim = 0; _parse = 0; _scenery = 0; _draw = 0; _util = 0; _video = 0; @@ -236,7 +236,7 @@ bool GobEngine::initGameParts() { _util = new Util(this); _dataIO = new DataIO(this); _palAnim = new PalAnim(this); - _imdPlayer = new ImdPlayer(this); + _vidPlayer = new VideoPlayer(this); _cdrom = new CDROM(this); _snd = new Snd(this); @@ -364,7 +364,7 @@ void GobEngine::deinitGameParts() { delete _cdrom; _cdrom = 0; delete _dataIO; _dataIO = 0; delete _goblin; _goblin = 0; - delete _imdPlayer; _imdPlayer = 0; + delete _vidPlayer; _vidPlayer = 0; delete _init; _init = 0; delete _inter; _inter = 0; delete _map; _map = 0; diff --git a/engines/gob/gob.h b/engines/gob/gob.h index 8c9583c95d..9a88571c0e 100644 --- a/engines/gob/gob.h +++ b/engines/gob/gob.h @@ -42,7 +42,7 @@ class Draw; class CDROM; class DataIO; class Goblin; -class ImdPlayer; +class VideoPlayer; class Init; class Inter; class Map; @@ -216,7 +216,7 @@ public: Inter *_inter; SaveLoad *_saveLoad; Adlib *_adlib; - ImdPlayer *_imdPlayer; + VideoPlayer *_vidPlayer; void shutdown(); diff --git a/engines/gob/imd.cpp b/engines/gob/imd.cpp deleted file mode 100644 index 395fb01f9b..0000000000 --- a/engines/gob/imd.cpp +++ /dev/null @@ -1,1249 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -#include "common/stdafx.h" -#include "common/endian.h" - -#include "gob/gob.h" -#include "gob/imd.h" -#include "gob/global.h" -#include "gob/util.h" -#include "gob/dataio.h" -#include "gob/draw.h" -#include "gob/game.h" -#include "gob/inter.h" -#include "gob/palanim.h" -#include "gob/sound.h" -#include "gob/video.h" - -namespace Gob { - -ImdPlayer::ImdPlayer(GobEngine *vm) : _vm(vm) { - _curImd = 0; - _curFile[0] = 0; - - _curX = 0; - _curY = 0; - _left = 0; - _top = 0; - _right = 0; - _bottom = 0; - - _frameData = 0; - _vidBuffer = 0; - - _frontSurf = 21; - _backSurf = 21; - _frontMem = 0; - _frameDelay = 0; - - _noSound = true; - - _soundStartTime = 0; - _skipFrames = 0; - - _soundFreq = 0; - _soundSliceSize = 0; - _soundSlicesCount = 0; - - _soundSliceLength = 0; - _soundStage = 0; - - _audioStream = 0; -} - -ImdPlayer::~ImdPlayer() { - if (_curImd) { - delete[] _curImd->palette; - delete[] _curImd->framesPos; - delete[] _curImd->frameCoords; - delete[] _curImd->extraPalette; - } - delete[] _frameData; - delete[] _vidBuffer; - delete[] _frontMem; - delete _curImd; -} - -// flag bits: 0 = read and set palette -// 1 = read palette -ImdPlayer::Imd *ImdPlayer::loadImdFile(const char *path, SurfaceDesc *surfDesc, int8 flags) { - Imd *imdPtr; - int16 handle; - char buf[18]; - uint32 framesPosPos = 0; - uint32 framesCordsPos = 0; - - strncpy0(buf, path, 17); - if (!strchr(buf, '.')) { - buf[13] = 0; - strcat(buf, ".IMD"); - } - - handle = _vm->_dataIO->openData(buf); - - if (handle < 0) { - warning("Can't open IMD \"%s\"", buf); - return 0; - } - - imdPtr = new Imd; - assert(imdPtr); - memset(imdPtr, 0, sizeof(Imd)); - - imdPtr->handle = _vm->_dataIO->readUint16(handle); - imdPtr->verMin = _vm->_dataIO->readUint16(handle); - imdPtr->framesCount = _vm->_dataIO->readUint16(handle); - imdPtr->x = _vm->_dataIO->readUint16(handle); - imdPtr->y = _vm->_dataIO->readUint16(handle); - imdPtr->width = _vm->_dataIO->readUint16(handle); - imdPtr->height = _vm->_dataIO->readUint16(handle); - imdPtr->field_E = _vm->_dataIO->readUint16(handle); - imdPtr->curFrame = _vm->_dataIO->readUint16(handle); - - if ((imdPtr->handle != 0) || ((imdPtr->verMin & 0xFF) < 2)) { - warning("%s: Version incorrect (%d,%X)", buf, imdPtr->handle, imdPtr->verMin); - _vm->_dataIO->closeData(handle); - delete imdPtr; - return 0; - } - - imdPtr->handle = handle; - imdPtr->surfDesc = surfDesc; - imdPtr->firstFramePos = imdPtr->curFrame; - imdPtr->curFrame = 0; - - if ((imdPtr->verMin & 0x800) && ((flags & 3) != 3)) - imdPtr->extraPalette = new Video::Color[256]; - - if (flags & 3) { - imdPtr->palette = new Video::Color[256]; - assert(imdPtr->palette); - _vm->_dataIO->readData(handle, (byte *) imdPtr->palette, 768); - } else - _vm->_dataIO->seekData(handle, 768, SEEK_CUR); - - if ((flags & 3) == 1) - _vm->_video->setPalette(imdPtr->palette); - - if ((imdPtr->verMin & 0xFF) >= 3) { - imdPtr->stdX = _vm->_dataIO->readUint16(handle); - if (imdPtr->stdX > 1) { - warning("%s: More than one standard coordinate quad found (%d)", - buf, imdPtr->stdX); - finishImd(imdPtr); - return 0; - } - if (imdPtr->stdX != 0) { - imdPtr->stdX = _vm->_dataIO->readUint16(handle); - imdPtr->stdY = _vm->_dataIO->readUint16(handle); - imdPtr->stdWidth = _vm->_dataIO->readUint16(handle); - imdPtr->stdHeight = _vm->_dataIO->readUint16(handle); - } else - imdPtr->stdX = -1; - } else - imdPtr->stdX = -1; - - if ((imdPtr->verMin & 0xFF) >= 4) { - framesPosPos = _vm->_dataIO->readUint32(handle); - if (framesPosPos != 0) { - imdPtr->framesPos = new int32[imdPtr->framesCount]; - assert(imdPtr->framesPos); - } - } - - if (imdPtr->verMin & 0x8000) - framesCordsPos = _vm->_dataIO->readUint32(handle); - - _noSound = true; - _soundStage = 0; - if (imdPtr->verMin & 0x4000) { - _soundFreq = _vm->_dataIO->readUint16(handle); - _soundSliceSize = _vm->_dataIO->readUint16(handle); - _soundSlicesCount = _vm->_dataIO->readUint16(handle); - - if (_soundFreq < 0) - _soundFreq = -_soundFreq; - - if (_soundSlicesCount < 0) - _soundSlicesCount = -_soundSlicesCount - 1; - - if (_soundSlicesCount > 40) { - warning("%s: More than 40 sound slices found (%d)", - buf, _soundSlicesCount); - finishImd(imdPtr); - return 0; - } - - _soundSliceLength = 1000 / (_soundFreq / _soundSliceSize); - - _soundStage = 1; - _noSound = false; - - _audioStream = Audio::makeAppendableAudioStream(_soundFreq, 0); - } - - if (imdPtr->verMin & 0x2000) { - imdPtr->frameDataSize = _vm->_dataIO->readUint16(handle); - if (imdPtr->frameDataSize == 0) { - imdPtr->frameDataSize = _vm->_dataIO->readUint32(handle); - imdPtr->vidBufferSize = _vm->_dataIO->readUint32(handle); - } else - imdPtr->vidBufferSize = _vm->_dataIO->readUint16(handle); - } else { - imdPtr->frameDataSize = imdPtr->width * imdPtr->height + 500; - if (!(imdPtr->field_E & 0x100) || (imdPtr->field_E & 0x1000)) - imdPtr->vidBufferSize = imdPtr->frameDataSize; - } - - if (imdPtr->framesPos) { - _vm->_dataIO->seekData(handle, framesPosPos, SEEK_SET); - for (int i = 0; i < imdPtr->framesCount; i++) - imdPtr->framesPos[i] = _vm->_dataIO->readUint32(handle); - } - - if (imdPtr->verMin & 0x8000) { - _vm->_dataIO->seekData(handle, framesCordsPos, SEEK_SET); - imdPtr->frameCoords = new ImdCoord[imdPtr->framesCount]; - assert(imdPtr->frameCoords); - for (int i = 0; i < imdPtr->framesCount; i++) { - imdPtr->frameCoords[i].left = _vm->_dataIO->readUint16(handle); - imdPtr->frameCoords[i].top = _vm->_dataIO->readUint16(handle); - imdPtr->frameCoords[i].right = _vm->_dataIO->readUint16(handle); - imdPtr->frameCoords[i].bottom = _vm->_dataIO->readUint16(handle); - } - } - - _vm->_dataIO->seekData(handle, imdPtr->firstFramePos, SEEK_SET); - return imdPtr; -} - -void ImdPlayer::finishImd(ImdPlayer::Imd *&imdPtr) { - if (!imdPtr) - return; - - if (_soundStage == 2) - _vm->_snd->stopSound(0); - - _vm->_dataIO->closeData(imdPtr->handle); - - delete[] imdPtr->frameCoords; - delete[] imdPtr->palette; - delete[] imdPtr->framesPos; - delete[] imdPtr->extraPalette; - - delete imdPtr; - - if (_audioStream) { - _audioStream->finish(); - _vm->_mixer->stopHandle(_audioHandle); - _audioStream = 0; - } -} - -int8 ImdPlayer::openImd(const char *path, int16 x, int16 y, - int16 startFrame, int16 flags) { - const char *src; - byte *vidMem; - SurfaceDesc *surfDesc; - - if (!_curImd) - _curFile[0] = 0; - - src = strrchr(path, '\\'); - src = !src ? path : src + 1; - - if ((path[0] != 0) && scumm_stricmp(_curFile, src)) { - closeImd(); - - _curImd = loadImdFile(path, 0, 3); - if (!_curImd) - return 0; - - _curX = _curImd->x; - _curY = _curImd->y; - strncpy0(_curFile, src, 17); - - delete[] _frameData; - _frameData = new byte[_curImd->frameDataSize + 500]; - assert(_frameData); - memset(_frameData, 0, _curImd->frameDataSize + 500); - - delete[] _vidBuffer; - _vidBuffer = new byte[_curImd->vidBufferSize + 500]; - assert(_vidBuffer); - memset(_vidBuffer, 0, _curImd->vidBufferSize + 500); - - if (!(flags & 0x100)) { - - if (_vm->_global->_videoMode == 0x14) { - - _backSurf = (flags & 0x80) ? 20 : 21; - if (!(_curImd->field_E & 0x100) || (_curImd->field_E & 0x2000)) { - setXY(_curImd, 0, 0); - _curImd->surfDesc = - _vm->_video->initSurfDesc(0x13, - _curImd->width, _curImd->height, 0); - } else { - _curImd->surfDesc = _vm->_draw->_spritesArray[_frontSurf]; - if ((x != -1) || (y != -1)) { - _curX = x != -1 ? x : _curX; - _curY = y != -1 ? y : _curY; - setXY(_curImd, _curX, _curY); - } - } - - if (flags & 0x40) { - _curX = x != -1 ? x : _curX; - _curY = y != -1 ? y : _curY; - if (_curImd->surfDesc->_vidMode == 0x14) { - surfDesc = _vm->_video->initSurfDesc(0x13, - _curImd->width, _curImd->height, 0); - _vm->_video->drawSprite(_vm->_draw->_spritesArray[21], - surfDesc, _curX, _curY, - _curX + _curImd->width - 1, _curY + _curImd->height - 1, - 0, 0, 0); - - vidMem = _curImd->surfDesc->getVidMem(); - for (int i = 0; i < _curImd->height; i++) - for (int j = 0; j < _curImd->width; j++, vidMem++) { - *(vidMem) = *(surfDesc->getVidMem() + - (j / 4) + (surfDesc->getWidth() / 4 * i)); - } - surfDesc = 0; - } - } - - } else { - if ((x != -1) || (y != -1)) { - _curX = (x != -1) ? x : _curX; - _curY = (y != -1) ? y : _curY; - setXY(_curImd, _curX, _curY); - } - _backSurf = (flags & 0x80) ? 20 : 21; - _curImd->surfDesc = _vm->_draw->_spritesArray[_backSurf]; - } - - } - } - - if (!_curImd) - return 0; - - if (startFrame == -1) { - closeImd(); - return 0; - } - - _curX = (x != -1) ? x : _curX; - _curY = (y != -1) ? y : _curY; - - WRITE_VAR(7, _curImd->framesCount); - - return 1; -} - -void ImdPlayer::closeImd(void) { - finishImd(_curImd); - - delete[] _frameData; - delete[] _vidBuffer; - _frameData = 0; - _vidBuffer = 0; - - _curImd = 0; -} - -void ImdPlayer::setXY(ImdPlayer::Imd *imdPtr, int16 x, int16 y) { - int i; - - if (imdPtr->stdX != -1) { - imdPtr->stdX = imdPtr->stdX - imdPtr->x + x; - imdPtr->stdY = imdPtr->stdY - imdPtr->y + y; - } - - if (imdPtr->frameCoords) { - for (i = 0; i < imdPtr->framesCount; i++) { - if (imdPtr->frameCoords[i].left != -1) { - imdPtr->frameCoords[i].left = - imdPtr->frameCoords[i].left - imdPtr->x + x; - imdPtr->frameCoords[i].top = - imdPtr->frameCoords[i].top - imdPtr->y + y; - imdPtr->frameCoords[i].right = - imdPtr->frameCoords[i].right - imdPtr->x + x; - imdPtr->frameCoords[i].bottom = - imdPtr->frameCoords[i].bottom - imdPtr->y + y; - } - } - } - - imdPtr->x = x; - imdPtr->y = y; -} - -void ImdPlayer::drawFrame(Imd *imdPtr, int16 frame, int16 x, int16 y, - SurfaceDesc *dest) { - if (!dest) - dest = _vm->_draw->_frontSurface; - - if (frame == 0) - _vm->_video->drawSprite(imdPtr->surfDesc, dest, 0, 0, - imdPtr->width - 1, imdPtr->height - 1, x, y, 0); - else if (imdPtr->frameCoords && (imdPtr->frameCoords[frame].left != -1)) - _vm->_video->drawSprite(imdPtr->surfDesc, dest, - imdPtr->frameCoords[frame].left, imdPtr->frameCoords[frame].top, - imdPtr->frameCoords[frame].right, imdPtr->frameCoords[frame].bottom, - imdPtr->frameCoords[frame].left + x, - imdPtr->frameCoords[frame].top + y, 0); - else if (imdPtr->stdX != -1) - _vm->_video->drawSprite(imdPtr->surfDesc, dest, - imdPtr->stdX, imdPtr->stdY, imdPtr->stdX + imdPtr->stdWidth - 1, - imdPtr->stdY + imdPtr->stdHeight - 1, x + imdPtr->stdX, - y + imdPtr->stdY, 0); - else - _vm->_video->drawSprite(imdPtr->surfDesc, dest, 0, 0, - imdPtr->width - 1, imdPtr->height - 1, x, y, 0); -} - -void ImdPlayer::renderFrame(Imd *imdPtr) { - int16 imdX, imdY; - int16 imdW, imdH; - int16 sW; - uint16 pixCount, pixWritten; - uint8 type; - byte *imdVidMem; - byte *imdVidMemBak; - byte *dataPtr = 0; - byte *srcPtr = 0; - - dataPtr = _frameData; - imdX = imdPtr->x; - imdY = imdPtr->y; - imdW = imdPtr->width; - imdH = imdPtr->height; - sW = imdPtr->surfDesc->getWidth(); - imdVidMem = imdPtr->surfDesc->getVidMem() + sW * imdY + imdX; - - type = *dataPtr++; - srcPtr = dataPtr; - - if (type & 0x10) { // Palette data - type ^= 0x10; - dataPtr += 49; - } - - srcPtr = dataPtr; - if (type & 0x80) { // Frame data is compressed - srcPtr = _vidBuffer; - type &= 0x7F; - if ((type == 2) && (imdW == sW)) { - frameUncompressor(imdVidMem, dataPtr); - return; - } else - frameUncompressor(srcPtr, dataPtr); - } - - if (type == 2) { // Whole block - for (int i = 0; i < imdH; i++) { - memcpy(imdVidMem, srcPtr, imdW); - srcPtr += imdW; - imdVidMem += sW; - } - } else if (type == 1) { // Sparse block - imdVidMemBak = imdVidMem; - for (int i = 0; i < imdH; i++) { - pixWritten = 0; - while (pixWritten < imdW) { - pixCount = *srcPtr++; - if (pixCount & 0x80) { // data - pixCount = MIN((pixCount & 0x7F) + 1, imdW - pixWritten); - memcpy(imdVidMem, srcPtr, pixCount); - - pixWritten += pixCount; - imdVidMem += pixCount; - srcPtr += pixCount; - } else { // "hole" - pixCount = (pixCount + 1) % 256; - pixWritten += pixCount; - imdVidMem += pixCount; - } - } - imdVidMemBak += sW; - imdVidMem = imdVidMemBak; - } - } else if (type == 0x42) { // Whole quarter-wide block - for (int i = 0; i < imdH; i++) { - imdVidMemBak = imdVidMem; - - for (int j = 0; j < imdW; j += 4, imdVidMem += 4, srcPtr++) - memset(imdVidMem, *srcPtr, 4); - - imdVidMemBak += sW; - imdVidMem = imdVidMemBak; - } - } else if ((type & 0xF) == 2) { // Whole half-high block - for (; imdH > 1; imdH -= 2, imdVidMem += sW + sW, srcPtr += imdW) { - memcpy(imdVidMem, srcPtr, imdW); - memcpy(imdVidMem + sW, srcPtr, imdW); - } - if (imdH == -1) - memcpy(imdVidMem, srcPtr, imdW); - } else { // Sparse half-high block - imdVidMemBak = imdVidMem; - for (int i = 0; i < imdH; i += 2) { - pixWritten = 0; - while (pixWritten < imdW) { - pixCount = *srcPtr++; - if (pixCount & 0x80) { // data - pixCount = MIN((pixCount & 0x7F) + 1, imdW - pixWritten); - memcpy(imdVidMem, srcPtr, pixCount); - memcpy(imdVidMem + sW, srcPtr, pixCount); - - pixWritten += pixCount; - imdVidMem += pixCount; - srcPtr += pixCount; - } else { // "hole" - pixCount = (pixCount + 1) % 256; - pixWritten += pixCount; - imdVidMem += pixCount; - } - } - imdVidMemBak += sW + sW; - imdVidMem = imdVidMemBak; - } - } -} - -void ImdPlayer::frameUncompressor(byte *dest, byte *src) { - int i; - byte buf[4370]; - uint16 chunkLength; - uint16 frameLength; - uint16 bufPos1; - uint16 bufPos2; - uint16 tmp; - uint8 chunkBitField; - uint8 chunkCount; - bool mode; - - frameLength = READ_LE_UINT16(src); - src += 4; - - if ((READ_LE_UINT16(src) == 0x1234) && (READ_LE_UINT16(src + 2) == 0x5678)) { - src += 4; - bufPos1 = 273; - mode = 1; // 123Ch (cmp al, 12h) - } else { - bufPos1 = 4078; - mode = 0; // 275h (jnz +2) - } - - memset(buf, 32, bufPos1); - chunkCount = 1; - chunkBitField = 0; - - while (frameLength > 0) { - chunkCount--; - if (chunkCount == 0) { - tmp = *src++; - chunkCount = 8; - chunkBitField = tmp; - } - if (chunkBitField % 2) { - chunkBitField >>= 1; - buf[bufPos1] = *src; - *dest++ = *src++; - bufPos1 = (bufPos1 + 1) % 4096; - frameLength--; - continue; - } - chunkBitField >>= 1; - - tmp = READ_LE_UINT16(src); - src += 2; - chunkLength = ((tmp & 0xF00) >> 8) + 3; - - if ((mode && ((chunkLength & 0xFF) == 0x12)) || - (!mode && (chunkLength == 0))) - chunkLength = *src++ + 0x12; - - bufPos2 = (tmp & 0xFF) + ((tmp >> 4) & 0x0F00); - if (((tmp + chunkLength) >= 4096) || - ((chunkLength + bufPos1) >= 4096)) { - - for (i = 0; i < chunkLength; i++, dest++) { - *dest = buf[bufPos2]; - buf[bufPos1] = buf[bufPos2]; - bufPos1 = (bufPos1 + 1) % 4096; - bufPos2 = (bufPos2 + 1) % 4096; - } - - } else if (((tmp + chunkLength) < bufPos1) || - ((chunkLength + bufPos1) < bufPos2)) { - - memcpy(dest, buf + bufPos2, chunkLength); - memmove(buf + bufPos1, buf + bufPos2, chunkLength); - - dest += chunkLength; - bufPos1 += chunkLength; - bufPos2 += chunkLength; - - } else { - - for (i = 0; i < chunkLength; i++, dest++, bufPos1++, bufPos2++) { - *dest = buf[bufPos2]; - buf[bufPos1] = buf[bufPos2]; - } - - } - frameLength -= chunkLength; - - } -} - -void ImdPlayer::play(const char *path, int16 x, int16 y, bool interruptible) { - int16 mouseX; - int16 mouseY; - int16 buttons; - - _vm->_util->setFrameRate(12); - if (!openImd(path, x, y, 0, 2)) - return; - - _vm->_video->fillRect(_vm->_draw->_frontSurface, x, y, - x + _curImd->width - 1, y + _curImd->height - 1, 0); - - for (int i = 0; i < _curImd->framesCount; i++) { - play(i, 4, 0, 255, 0, _curImd->framesCount - 1); - - if (_vm->_quitRequested || (interruptible && - (_vm->_game->checkKeys(&mouseX, &mouseY, &buttons, 0) == 0x11B))) - break; - } - - closeImd(); -} - -void ImdPlayer::play(const char *path, int16 x, int16 y, int16 startFrame, - int16 frames, bool fade, bool interruptible) { - int16 mouseX; - int16 mouseY; - int16 buttons = 0; - int endFrame; - - _vm->_util->setFrameRate(12); - if (!openImd(path, x, y, 0, 0)) - return; - - _vm->_video->fillRect(_vm->_draw->_frontSurface, x, y, - x + _curImd->width - 1, y + _curImd->height - 1, 0); - - if (fade) - _vm->_palAnim->fade(0, -2, 0); - - endFrame = frames > 0 ? frames : _curImd->framesCount; - for (int i = startFrame; i < endFrame; i++) { - view(_curImd, i); - drawFrame(_curImd, i, x, y); - if (fade) { - _vm->_palAnim->fade(_vm->_global->_pPaletteDesc, -2, 0); - fade = false; - } - _vm->_video->waitRetrace(); - - if (_vm->_quitRequested || (interruptible && - (_vm->_game->checkKeys(&mouseX, &mouseY, &buttons, 0) == 0x11B))) { - _vm->_palAnim->fade(0, -2, 0); - _vm->_video->clearSurf(_vm->_draw->_frontSurface); - memset((char *) _vm->_draw->_vgaPalette, 0, 768); - - WRITE_VAR(4, buttons); - WRITE_VAR(0, 0x11B); - WRITE_VAR(57, (uint32) -1); - break; - } - - _vm->_util->waitEndFrame(); - } - - if (frames < 0) { - endFrame = _curImd->framesCount + frames; - for (int i = _curImd->framesCount - 1; i >= endFrame; i--) { - seekFrame(_curImd, i, SEEK_SET, true); - drawFrame(_curImd, i, x, y); - _vm->_video->waitRetrace(); - - if (_vm->_quitRequested || (interruptible && - (_vm->_game->checkKeys(&mouseX, &mouseY, &buttons, 0) == 0x11B))) { - _vm->_palAnim->fade(0, -2, 0); - _vm->_video->clearSurf(_vm->_draw->_frontSurface); - memset((char *) _vm->_draw->_vgaPalette, 0, 768); - - WRITE_VAR(4, buttons); - WRITE_VAR(0, 0x11B); - WRITE_VAR(57, (uint32) -1); - break; - } - - _vm->_util->waitEndFrame(); - } - } - - closeImd(); -} - -void ImdPlayer::play(int16 frame, uint16 palCmd, - int16 palStart, int16 palEnd, int16 palFrame, int16 lastFrame) { - uint32 viewRet = 0; - SurfaceDesc *surfDescBak; - bool modifiedPal = false; - - _vm->_draw->_showCursor = 0; - - if ((frame < 0) || (frame > lastFrame)) - return; - - palCmd &= 0x3F; - if ((frame == palFrame) || ((frame == lastFrame) && (palCmd == 8))) { - modifiedPal = true; - _vm->_draw->_applyPal = true; - - if (palCmd >= 4) - copyPalette(palStart, palEnd); - } - - if (modifiedPal && (palCmd == 8) && (_backSurf == 20)) - _vm->_video->setFullPalette(_vm->_global->_pPaletteDesc); - - if (_curImd->surfDesc) { - if (_curImd->surfDesc->_vidMode == 0x14) { - - if ((_frontMem == _vm->_draw->_frontSurface->getVidMem()) && - (_frontSurf == 20)) { - _vm->_draw->_frontSurface->swap(_vm->_draw->_backSurface); - viewRet = view(_curImd, frame); - _vm->_draw->_frontSurface->swap(_vm->_draw->_backSurface); - } else - viewRet = view(_curImd, frame); - - if (_frontSurf == 21) - _vm->_draw->invalidateRect(_left, _top, _right, _bottom); - - } else { - if ((_curImd->field_E & 0x100) && - (_vm->_global->_videoMode == 0x14) && - (_frontSurf == 20) && - (checkFrameType(_curImd, frame) & 0x8000) && - (_backSurf == 21)) { - - surfDescBak = _curImd->surfDesc; - if (_frontMem == _vm->_draw->_spritesArray[20]->getVidMem()) - _curImd->surfDesc = _vm->_draw->_spritesArray[21]; - else - _curImd->surfDesc = _vm->_draw->_spritesArray[20]; - setXY(_curImd, _curX, _curY); - viewRet = view(_curImd, frame); - _curImd->surfDesc = surfDescBak; - setXY(_curImd, 0, 0); - - } else { - viewRet = view(_curImd, frame); - if (!(viewRet & 0x800)) - drawFrame(frame); - } - } - } else - viewRet = view(_curImd, frame); - - if (modifiedPal && (palCmd == 16)) { - if (_backSurf == 21) - _vm->_draw->forceBlit(); - _vm->_palAnim->fade(_vm->_global->_pPaletteDesc, -2, 0); - _vm->_draw->_noInvalidated = true; - } - - if (viewRet & 0x10) { - copyPalette(palStart, palEnd); - - if (_backSurf == 20) - _vm->_video->setFullPalette(_vm->_global->_pPaletteDesc); - else - _vm->_draw->_applyPal = true; - } - - if (modifiedPal && (palCmd == 8) && (_backSurf == 21)) - _vm->_video->setFullPalette(_vm->_global->_pPaletteDesc); - - if (!(viewRet & 0x800)) { - if (_vm->_draw->_cursorIndex == -1) { - if (_frontSurf == 20) - flipFrontMem(); - else - _vm->_draw->blitInvalidated(); - } else - _vm->_draw->animateCursor(-1); - } - - if (modifiedPal && ((palCmd == 2) || (palCmd == 4))) - _vm->_palAnim->fade(_vm->_global->_pPaletteDesc, -2, 0); - - // To allow quitting, etc. during IMDs - _vm->_util->processInput(); - if (_vm->_quitRequested) - return; - - if (_soundStage != 2) { - if (viewRet & 0x800) { - if (_frameDelay == 0) - _vm->_util->delay(30); - else { - _frameDelay -= 30; - if (_frameDelay < 0) - _frameDelay = 0; - } - } else - _vm->_util->waitEndFrame(); - } - - _vm->_inter->animPalette(); -} - -inline void ImdPlayer::drawFrame(int16 frame) { - if (_backSurf == 21) { - - if (_vm->_global->_videoMode == 0x14) { - if (_frontSurf == 21) { - _vm->_draw->_frontSurface->swap(_vm->_draw->_spritesArray[21]); - drawFrame(_curImd, frame, _curX, _curY); - _vm->_draw->_frontSurface->swap(_vm->_draw->_spritesArray[21]); - _vm->_draw->invalidateRect(_curX + _left, _curY + _top, - _curX + _right, _curY + _bottom); - } else { - if (_frontMem == _vm->_draw->_spritesArray[20]->getVidMem()) { - _vm->_draw->_frontSurface->swap(_vm->_draw->_spritesArray[21]); - drawFrame(_curImd, frame, _curX, _curY); - _vm->_draw->_frontSurface->swap(_vm->_draw->_spritesArray[21]); - } else - drawFrame(_curImd, frame, _curX, _curY); - } - } else - _vm->_draw->invalidateRect(_left, _top, _right, _bottom); - - } else if (_vm->_global->_videoMode == 0x14) - drawFrame(_curImd, frame, _curX, _curY); -} - -inline void ImdPlayer::copyPalette(int16 palStart, int16 palEnd) { - if ((palStart == -1) || (palEnd == -1)) - memcpy((char *) _vm->_global->_pPaletteDesc->vgaPal, - (char *) _curImd->palette, 768); - else - memcpy(((char *) (_vm->_global->_pPaletteDesc->vgaPal)) + - palStart * 3, ((char *) (_curImd->palette)) + palStart * 3, - (palEnd - palStart + 1) * 3); -} - -inline void ImdPlayer::flipFrontMem() { - if (_frontMem == _vm->_draw->_frontSurface->getVidMem()) - _frontMem = _vm->_draw->_backSurface->getVidMem(); - else - _frontMem = _vm->_draw->_frontSurface->getVidMem(); -} - -uint16 ImdPlayer::checkFrameType(Imd *imdPtr, int16 frame) { - uint16 retVal = 0; - uint32 posBak; - uint32 tmp; - uint16 cmd; - int16 frameBak; - - if (!imdPtr) - return 0x8000; - - posBak = _vm->_dataIO->getPos(imdPtr->handle); - frameBak = imdPtr->curFrame; - - if (imdPtr->curFrame != frame) { - retVal |= 0x2000; - seekFrame(imdPtr, frame, SEEK_SET); - } - - do { - if (frame != 0) { - if (imdPtr->stdX != -1) - retVal |= 0x1000; - if (imdPtr->frameCoords && (imdPtr->frameCoords[frame].left != -1)) - retVal |= 0x400; - } - - cmd = _vm->_dataIO->readUint16(imdPtr->handle); - - if ((cmd & 0xFFF8) == 0xFFF0) { - if (cmd == 0xFFF0) { - _vm->_dataIO->seekData(imdPtr->handle, 2, SEEK_CUR); - cmd = _vm->_dataIO->readUint16(imdPtr->handle); - } - - if (cmd == 0xFFF1) { - retVal = 0x8000; - continue; - } else if (cmd == 0xFFF2) { // Skip (16 bit) - cmd = _vm->_dataIO->readUint16(imdPtr->handle); - _vm->_dataIO->seekData(imdPtr->handle, cmd, SEEK_CUR); - retVal = 0x8000; - continue; - } else if (cmd == 0xFFF3) { // Skip (32 bit) - tmp = _vm->_dataIO->readUint32(imdPtr->handle); - _vm->_dataIO->seekData(imdPtr->handle, cmd, SEEK_CUR); - retVal = 0x8000; - continue; - } - } - - // Jump to frame - if (cmd == 0xFFFD) { - frame = _vm->_dataIO->readUint16(imdPtr->handle); - if (imdPtr->framesPos) { - _vm->_dataIO->seekData(imdPtr->handle, - imdPtr->framesPos[frame], SEEK_SET); - retVal |= 0x200; - continue; - } - break; - } - - // Next sound slice data - if (cmd == 0xFF00) { - _vm->_dataIO->seekData(imdPtr->handle, - _soundSliceSize, SEEK_CUR); - cmd = _vm->_dataIO->readUint16(imdPtr->handle); - // Initial sound data (all slices) - } else if (cmd == 0xFF01) { - _vm->_dataIO->seekData(imdPtr->handle, - _soundSliceSize * _soundSlicesCount, SEEK_CUR); - cmd = _vm->_dataIO->readUint16(imdPtr->handle); - } - - // Frame video data - if (cmd != 0) { - _vm->_dataIO->readData(imdPtr->handle, _frameData, 5); - retVal |= _frameData[0]; - } else - retVal |= 0x800; - - break; - - } while (true); - - _vm->_dataIO->seekData(imdPtr->handle, posBak, SEEK_SET); - imdPtr->curFrame = frameBak; - return retVal; -} - -void ImdPlayer::seekFrame(Imd *imdPtr, int16 frame, int16 from, bool restart) { - uint32 framePos = 0; - - if (!imdPtr) - return; - - if (from == SEEK_CUR) - frame += imdPtr->curFrame; - else if (from == SEEK_END) - frame = imdPtr->framesCount - frame - 1; - - if (frame >= imdPtr->framesCount) - return; - - if (frame == 0) { - framePos = imdPtr->firstFramePos; - } else if (frame == 1) { - framePos = imdPtr->firstFramePos; - _vm->_dataIO->seekData(imdPtr->handle, framePos, SEEK_SET); - framePos += _vm->_dataIO->readUint16(imdPtr->handle) + 4; - } else if (imdPtr->framesPos) { - framePos = imdPtr->framesPos[frame]; - } else if (restart && (_soundStage == 0)) { - for (int i = 0; i <= frame; i++) - view(_curImd, i); - } else - error("%s: Frame %d is not directly accessible", _curFile, frame); - - _vm->_dataIO->seekData(imdPtr->handle, framePos, SEEK_SET); - imdPtr->curFrame = frame; -} - -uint32 ImdPlayer::view(Imd *imdPtr, int16 frame) { - uint32 retVal = 0; - uint32 cmd = 0; - int16 xBak, yBak, heightBak, widthBak; - bool hasNextCmd = false; - bool startSound = false; - - if (!imdPtr) - return 0x8000; - - if (frame != imdPtr->curFrame) { - retVal |= 0x2000; - seekFrame(imdPtr, frame, SEEK_SET); - } - - _left = xBak = imdPtr->x; - _top = yBak = imdPtr->y; - _bottom = heightBak= imdPtr->height; - _right = widthBak = imdPtr->width; - _right += _left - 1; - _bottom += _top - 1; - - if ((frame == 0) && (imdPtr->verMin & 0x800)) - _vm->_video->setPalette(imdPtr->palette); - - do { - if (frame != 0) { - if (imdPtr->stdX != -1) { - _left = imdPtr->x = imdPtr->stdX; - _top = imdPtr->y = imdPtr->stdY; - _right = imdPtr->width = imdPtr->stdWidth; - _bottom = imdPtr->height = imdPtr->stdHeight; - _right += _left - 1; - _bottom += _top - 1; - retVal |= 0x1000; - } - if (imdPtr->frameCoords && - (imdPtr->frameCoords[frame].left != -1)) { - _left = imdPtr->x = imdPtr->frameCoords[frame].left; - _top = imdPtr->y = imdPtr->frameCoords[frame].top; - _right = imdPtr->width = - imdPtr->frameCoords[frame].right - imdPtr->x + 1; - _bottom = imdPtr->height = - imdPtr->frameCoords[frame].bottom - imdPtr->y + 1; - _right += _left - 1; - _bottom += _top - 1; - retVal |= 0x400; - } - } - - cmd = _vm->_dataIO->readUint16(imdPtr->handle); - - if ((cmd & 0xFFF8) == 0xFFF0) { - if (cmd == 0xFFF0) { - _vm->_dataIO->seekData(imdPtr->handle, 2, SEEK_CUR); - cmd = _vm->_dataIO->readUint16(imdPtr->handle); - } - - if (cmd == 0xFFF1) { - retVal = 0x8000; - continue; - } else if (cmd == 0xFFF2) { // Skip (16 bit) - cmd = _vm->_dataIO->readUint16(imdPtr->handle); - _vm->_dataIO->seekData(imdPtr->handle, cmd, SEEK_CUR); - retVal = 0x8000; - continue; - } else if (cmd == 0xFFF3) { // Skip (32 bit) - cmd = _vm->_dataIO->readUint32(imdPtr->handle); - _vm->_dataIO->seekData(imdPtr->handle, cmd, SEEK_CUR); - retVal = 0x8000; - continue; - } - } - - if (_soundStage != 0) { - byte *soundBuf; - - if (!hasNextCmd) - waitEndSoundSlice(); - - // Next sound slice data - if (cmd == 0xFF00) { - - if (!hasNextCmd && !_noSound) { - soundBuf = new byte[_soundSliceSize]; - assert(soundBuf); - - _vm->_dataIO->readData(imdPtr->handle, soundBuf, - _soundSliceSize); - _vm->_snd->convToSigned(soundBuf, _soundSliceSize); - _audioStream->queueBuffer(soundBuf, _soundSliceSize); - } else - _vm->_dataIO->seekData(imdPtr->handle, - _soundSliceSize, SEEK_CUR); - - cmd = _vm->_dataIO->readUint16(imdPtr->handle); - - // Initial sound data (all slices) - } else if (cmd == 0xFF01) { - int dataLength = _soundSliceSize * _soundSlicesCount; - - if (!hasNextCmd && !_noSound) { - soundBuf = new byte[dataLength]; - assert(soundBuf); - - _vm->_dataIO->readData(imdPtr->handle, soundBuf, dataLength); - _vm->_snd->convToSigned(soundBuf, dataLength); - - _soundStage = 1; - startSound = true; - _audioStream->queueBuffer(soundBuf, dataLength); - } else - _vm->_dataIO->seekData(imdPtr->handle, dataLength, SEEK_CUR); - - cmd = _vm->_dataIO->readUint16(imdPtr->handle); - - // Empty sound slice - } else if (!hasNextCmd && (!_noSound)) { - soundBuf = new byte[_soundSliceSize]; - assert(soundBuf); - - memset(soundBuf, 0, _soundSliceSize); - _audioStream->queueBuffer(soundBuf, _soundSliceSize); - } - } - - // Set palette - if (cmd == 0xFFF4) { - _vm->_dataIO->seekData(imdPtr->handle, 2, SEEK_CUR); - retVal |= 0x10; - if (imdPtr->extraPalette) { - _vm->_dataIO->readData(imdPtr->handle, - (byte *) imdPtr->extraPalette, 768); - _vm->_video->setPalette(imdPtr->extraPalette); - } else if (imdPtr->palette) - _vm->_dataIO->readData(imdPtr->handle, - (byte *) imdPtr->palette, 768); - else - _vm->_dataIO->readData(imdPtr->handle, _frameData, 768); - - cmd = _vm->_dataIO->readUint16(imdPtr->handle); - } - - hasNextCmd = false; - - // Jump to frame - if (cmd == 0xFFFD) { - - frame = _vm->_dataIO->readUint16(imdPtr->handle); - if (imdPtr->framesPos) { - imdPtr->curFrame = frame; - _vm->_dataIO->seekData(imdPtr->handle, - imdPtr->framesPos[frame], SEEK_SET); - - hasNextCmd = true; - retVal |= 0x200; - } - - } else if (cmd == 0xFFFC) { - - retVal |= 1; - cmd = _vm->_dataIO->readUint32(imdPtr->handle); - _vm->_dataIO->readData(imdPtr->handle, _frameData, cmd + 2); - - if (imdPtr->surfDesc) { - int16 left = imdPtr->x; - int16 top = imdPtr->y; - int16 right = imdPtr->width + left; - int16 bottom = imdPtr->height + top; - - if (imdPtr->surfDesc->getWidth() < right) { - left = 0; - right = imdPtr->width; - } - if (imdPtr->surfDesc->getWidth() < right) - right = imdPtr->surfDesc->getWidth(); - if (imdPtr->surfDesc->getHeight() < bottom) { - top = 0; - bottom = imdPtr->height; - } - if (imdPtr->surfDesc->getHeight() < bottom) - bottom = imdPtr->surfDesc->getHeight(); - - imdPtr->x = left; - imdPtr->y = top; - imdPtr->height = bottom - top; - imdPtr->width = right - left; - - renderFrame(imdPtr); - } - - retVal |= _frameData[0]; - - // Frame video data - } else if (cmd != 0) { - - _vm->_dataIO->readData(imdPtr->handle, _frameData, cmd + 2); - if (imdPtr->surfDesc) - renderFrame(imdPtr); - - retVal |= _frameData[0]; - - } else - retVal |= 0x800; - - } while (hasNextCmd); - - if (startSound) { - _vm->_snd->stopSound(0); - _vm->_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_audioHandle, _audioStream); - _soundStartTime = _vm->_util->getTimeKey(); - _skipFrames = 0; - _soundStage = 2; - } - - imdPtr->x = xBak; - imdPtr->y = yBak; - imdPtr->width = widthBak; - imdPtr->height = heightBak; - - imdPtr->curFrame++; - if ((imdPtr->curFrame == imdPtr->framesCount) && (_soundStage == 2)) { - waitEndSoundSlice(); - _audioStream->finish(); - _vm->_mixer->stopHandle(_audioHandle); - _audioStream = 0; - } - - return retVal; -} - -inline void ImdPlayer::waitEndSoundSlice() { - if (_soundStage != 2) - return; - - if (_skipFrames == 0) { - - _vm->_video->retrace(); - - int32 waitTime = (_curImd->curFrame * _soundSliceLength) - - (_vm->_util->getTimeKey() - _soundStartTime); - - if (waitTime < 0) { - _skipFrames = -waitTime / _soundSliceLength; - warning("IMD A/V sync broken, skipping %d frame(s)", _skipFrames + 1); - } else if (waitTime > 0) - _vm->_util->delay(waitTime); - - } else - _skipFrames--; -} - -} // End of namespace Gob diff --git a/engines/gob/imd.h b/engines/gob/imd.h deleted file mode 100644 index 27d95cd579..0000000000 --- a/engines/gob/imd.h +++ /dev/null @@ -1,143 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -#ifndef GOB_IMD_H -#define GOB_IMD_H - -#include "gob/video.h" -#include "gob/sound.h" - -namespace Gob { - -class ImdPlayer { -public: - -#include "common/pack-start.h" // START STRUCT PACKING - - struct ImdCoord { - int16 left; - int16 top; - int16 right; - int16 bottom; - } PACKED_STRUCT; - - struct Imd { - int16 handle; - int16 verMin; - int16 framesCount; - int16 x; - int16 y; - int16 width; - int16 height; - int16 field_E; - int16 curFrame; - Video::Color *palette; - SurfaceDesc *surfDesc; - int32 *framesPos; - int32 firstFramePos; - int16 stdX; - int16 stdY; - int16 stdWidth; - int16 stdHeight; - ImdCoord *frameCoords; - int32 frameDataSize; - int32 vidBufferSize; - Video::Color *extraPalette; - } PACKED_STRUCT; - -#include "common/pack-end.h" // END STRUCT PACKING - - Imd *_curImd; - byte _frontSurf; - int8 _backSurf; - byte *_frontMem; - int32 _frameDelay; - - uint8 _soundStage; // (0: no sound, 1: loaded, 2: playing) - - ImdPlayer(GobEngine *vm); - virtual ~ImdPlayer(); - - Imd *loadImdFile(const char *path, SurfaceDesc *surfDesc, int8 flags); - void finishImd(Imd *&imdPtr); - - int8 openImd(const char *path, int16 x, int16 y, - int16 startFrame, int16 flags); - void closeImd(void); - - void play(int16 frame, uint16 palCmd, int16 palStart, int16 palEnd, - int16 palFrame, int16 lastFrame); - void play(const char *path, int16 x, int16 y, bool interruptible); - void play(const char *path, int16 x, int16 y, int16 startFrame, - int16 frames, bool fade, bool interruptible); - -protected: - char _curFile[18]; - - int16 _curX; - int16 _curY; - int16 _left; - int16 _top; - int16 _right; - int16 _bottom; - - byte *_frameData; - byte *_vidBuffer; - - bool _noSound; - - uint32 _soundStartTime; - uint32 _skipFrames; - - int16 _soundFreq; - uint16 _soundSliceSize; - int16 _soundSlicesCount; - uint16 _soundSliceLength; - - Audio::AppendableAudioStream *_audioStream; - Audio::SoundHandle _audioHandle; - - GobEngine *_vm; - - void copyPalette(int16 palStart, int16 palEnd); - void flipFrontMem(); - void drawFrame(int16 frame); - void setXY(Imd *imdPtr, int16 x, int16 y); - - void seekFrame(Imd *imdPtr, int16 frame, int16 from, bool restart = false); - uint16 checkFrameType(Imd *imdPtr, int16 frame); - void drawFrame(Imd *imdPtr, int16 frame, int16 x, int16 y, - SurfaceDesc *dest = 0); - - uint32 view(ImdPlayer::Imd *imdPtr, int16 arg_4); - void renderFrame(Imd *imdPtr); - void frameUncompressor(byte *dest, byte *src); - - void waitEndSoundSlice(); -}; - -} // End of namespace Gob - -#endif // GOB_IMD_H diff --git a/engines/gob/init.cpp b/engines/gob/init.cpp index 2f1dbe5326..85f95fb261 100644 --- a/engines/gob/init.cpp +++ b/engines/gob/init.cpp @@ -37,7 +37,7 @@ #include "gob/palanim.h" #include "gob/sound.h" #include "gob/video.h" -#include "gob/imd.h" +#include "gob/videoplayer.h" namespace Gob { @@ -167,8 +167,14 @@ void Init::initGame(const char *totName) { _vm->_dataIO->closeData(imdHandle); _vm->_draw->initScreen(); _vm->_draw->_cursorIndex = -1; + _vm->_util->longDelay(200); // Letting everything settle - _vm->_imdPlayer->play("coktel", -1, -1, true); + + if (_vm->_vidPlayer->openVideo("coktel.imd")) { + _vm->_vidPlayer->play(); + _vm->_vidPlayer->closeVideo(); + } + _vm->_draw->closeScreen(); } else if ((imdHandle = _vm->_dataIO->openData("coktel.clt")) >= 0) { _vm->_draw->initScreen(); diff --git a/engines/gob/inter_bargon.cpp b/engines/gob/inter_bargon.cpp index ffbe9e45ea..492ea198a1 100644 --- a/engines/gob/inter_bargon.cpp +++ b/engines/gob/inter_bargon.cpp @@ -33,10 +33,10 @@ #include "gob/dataio.h" #include "gob/draw.h" #include "gob/game.h" -#include "gob/imd.h" #include "gob/palanim.h" #include "gob/sound.h" #include "gob/video.h" +#include "gob/videoplayer.h" namespace Gob { @@ -717,11 +717,17 @@ const char *Inter_Bargon::getOpcodeGoblinDesc(int i) { } void Inter_Bargon::oBargon_intro0(OpGobParams ¶ms) { - _vm->_imdPlayer->play("scaa", 0, 160, 0, 92, 0, 1); + if (_vm->_vidPlayer->openVideo("scaa", 0, 160)) { + _vm->_vidPlayer->play(0, 92, 27, 0, 0, 0); + _vm->_vidPlayer->closeVideo(); + } } void Inter_Bargon::oBargon_intro1(OpGobParams ¶ms) { - _vm->_imdPlayer->play("scaa", 0, 160, 0, -23, 1, 1); + if (_vm->_vidPlayer->openVideo("scaa", 0, 160)) { + _vm->_vidPlayer->play(0, -1, 27, 0, 0, 0, 0, 0, true, 23); + _vm->_vidPlayer->closeVideo(); + } } void Inter_Bargon::oBargon_intro2(OpGobParams ¶ms) { @@ -813,27 +819,45 @@ void Inter_Bargon::oBargon_intro3(OpGobParams ¶ms) { } void Inter_Bargon::oBargon_intro4(OpGobParams ¶ms) { - _vm->_imdPlayer->play("scba", 191, 54, 0, 0, 1, 1); + if (_vm->_vidPlayer->openVideo("scba", 191, 54)) { + _vm->_vidPlayer->play(0, -1, 27, 0, 0, 0, 0, 0, true); + _vm->_vidPlayer->closeVideo(); + } } void Inter_Bargon::oBargon_intro5(OpGobParams ¶ms) { - _vm->_imdPlayer->play("scbb", 191, 54, 0, 0, 0, 1); + if (_vm->_vidPlayer->openVideo("scbb", 191, 54)) { + _vm->_vidPlayer->play(0, -1, 27, 0, 0, 0); + _vm->_vidPlayer->closeVideo(); + } } void Inter_Bargon::oBargon_intro6(OpGobParams ¶ms) { - _vm->_imdPlayer->play("scbc", 191, 54, 0, 0, 0, 1); + if (_vm->_vidPlayer->openVideo("scbc", 191, 54)) { + _vm->_vidPlayer->play(0, -1, 27, 0, 0, 0); + _vm->_vidPlayer->closeVideo(); + } } void Inter_Bargon::oBargon_intro7(OpGobParams ¶ms) { - _vm->_imdPlayer->play("scbf", 191, 54, 0, 0, 0, 1); + if (_vm->_vidPlayer->openVideo("scbf", 191, 54)) { + _vm->_vidPlayer->play(0, -1, 27, 0, 0, 0); + _vm->_vidPlayer->closeVideo(); + } } void Inter_Bargon::oBargon_intro8(OpGobParams ¶ms) { - _vm->_imdPlayer->play("scbc", 191, 54, 0, 0, 0, 1); + if (_vm->_vidPlayer->openVideo("scbc", 191, 54)) { + _vm->_vidPlayer->play(0, -1, 27, 0, 0, 0); + _vm->_vidPlayer->closeVideo(); + } } void Inter_Bargon::oBargon_intro9(OpGobParams ¶ms) { - _vm->_imdPlayer->play("scbd", 191, 54, 0, 0, 0, 1); + if (_vm->_vidPlayer->openVideo("scbd", 191, 54)) { + _vm->_vidPlayer->play(0, -1, 27, 0, 0, 0); + _vm->_vidPlayer->closeVideo(); + } } } // End of namespace Gob diff --git a/engines/gob/inter_v2.cpp b/engines/gob/inter_v2.cpp index c78aa9e017..58970d9fcd 100644 --- a/engines/gob/inter_v2.cpp +++ b/engines/gob/inter_v2.cpp @@ -38,7 +38,6 @@ #include "gob/draw.h" #include "gob/game.h" #include "gob/goblin.h" -#include "gob/imd.h" #include "gob/map.h" #include "gob/mult.h" #include "gob/parse.h" @@ -46,6 +45,7 @@ #include "gob/sound.h" #include "gob/video.h" #include "gob/saveload.h" +#include "gob/videoplayer.h" namespace Gob { @@ -1493,48 +1493,28 @@ void Inter_v2::o2_playImd() { palEnd = _vm->_parse->parseValExpr(); palCmd = 1 << (flags & 0x3F); - if (!_vm->_imdPlayer->openImd(imd, x, y, startFrame, flags)) { + if ((imd[0] != 0) && !_vm->_vidPlayer->openVideo(imd, x, y, flags)) { WRITE_VAR(11, -1); return; } close = (lastFrame == -1); - if (lastFrame < 0) - lastFrame = _vm->_imdPlayer->_curImd->framesCount - 1; if (startFrame == -2) { startFrame = lastFrame = 0; close = false; } - _vm->_game->_preventScroll = true; - for (int i = startFrame; i <= lastFrame; i++) { - _vm->_imdPlayer->play(i, palCmd, palStart, palEnd, 0, lastFrame); - WRITE_VAR(11, i); - - if (_vm->_quitRequested) - break; - - if (breakKey != 0) { - _vm->_util->getMouseState(&_vm->_global->_inter_mouseX, - &_vm->_global->_inter_mouseY, &_vm->_game->_mouseButtons); - - storeKey(_vm->_util->checkKey()); - if (VAR(0) == (unsigned) breakKey) { - if (_vm->_imdPlayer->_soundStage == 2) - _vm->_snd->stopSound(0); - _vm->_game->_preventScroll = false; - return; - } - } + if (startFrame >= 0) { + _vm->_game->_preventScroll = true; + _vm->_vidPlayer->play(startFrame, lastFrame, breakKey, palCmd, palStart, palEnd, 0); + _vm->_game->_preventScroll = false; } - _vm->_game->_preventScroll = false; if (close) - _vm->_imdPlayer->closeImd(); + _vm->_vidPlayer->closeVideo(); } void Inter_v2::o2_getImdInfo() { - ImdPlayer::Imd *imd; int16 varX, varY; int16 varFrames; int16 varWidth, varHeight; @@ -1545,21 +1525,9 @@ void Inter_v2::o2_getImdInfo() { varFrames = _vm->_parse->parseVarIndex(); varWidth = _vm->_parse->parseVarIndex(); varHeight = _vm->_parse->parseVarIndex(); - imd = _vm->_imdPlayer->loadImdFile(_vm->_global->_inter_resStr, 0, 2); - if (!imd) { - WRITE_VAR_OFFSET(varX, -1); - WRITE_VAR_OFFSET(varY, -1); - WRITE_VAR_OFFSET(varFrames, -1); - WRITE_VAR_OFFSET(varWidth, -1); - WRITE_VAR_OFFSET(varHeight, -1); - } else { - WRITE_VAR_OFFSET(varX, imd->x); - WRITE_VAR_OFFSET(varY, imd->y); - WRITE_VAR_OFFSET(varFrames, imd->framesCount); - WRITE_VAR_OFFSET(varWidth, imd->width); - WRITE_VAR_OFFSET(varHeight, imd->height); - } - _vm->_imdPlayer->finishImd(imd); + + _vm->_vidPlayer->writeVideoInfo(_vm->_global->_inter_resStr, varX, varY, + varFrames, varWidth, varHeight); } void Inter_v2::o2_openItk() { @@ -1577,21 +1545,9 @@ void Inter_v2::o2_closeItk() { } void Inter_v2::o2_setImdFrontSurf() { - _vm->_imdPlayer->_frontSurf = 21; - if (_vm->_global->_videoMode == 0x14) { - _vm->_imdPlayer->_frontMem = _vm->_draw->_frontSurface->getVidMem(); - _vm->_draw->blitInvalidated(); - _vm->_imdPlayer->_frontSurf = 20; - } } void Inter_v2::o2_resetImdFrontSurf() { - _vm->_imdPlayer->_frontSurf = 21; - if (_vm->_imdPlayer->_frontMem) { - _vm->_imdPlayer->_frontMem = _vm->_draw->_frontSurface->getVidMem(); - _vm->_draw->forceBlit(); - } else - _vm->_draw->forceBlit(true); } bool Inter_v2::o2_evaluateStore(OpFuncParams ¶ms) { diff --git a/engines/gob/module.mk b/engines/gob/module.mk index 6c9a8d4b3e..7571853f27 100644 --- a/engines/gob/module.mk +++ b/engines/gob/module.mk @@ -18,7 +18,8 @@ MODULE_OBJS := \ goblin_v1.o \ goblin_v2.o \ goblin_v3.o \ - imd.o \ + coktelvideo.o \ + videoplayer.o \ init.o \ init_v1.o \ init_v2.o \ diff --git a/engines/gob/mult_v2.cpp b/engines/gob/mult_v2.cpp index 86a2a260de..cced4aac63 100644 --- a/engines/gob/mult_v2.cpp +++ b/engines/gob/mult_v2.cpp @@ -34,11 +34,11 @@ #include "gob/draw.h" #include "gob/game.h" #include "gob/goblin.h" -#include "gob/imd.h" #include "gob/inter.h" #include "gob/parse.h" #include "gob/scenery.h" #include "gob/video.h" +#include "gob/videoplayer.h" namespace Gob { @@ -1041,7 +1041,7 @@ void Mult_v2::playImd(const char *imdFile, Mult::Mult_ImdKey &key, int16 dir, x = y = -1; if (key.imdFile == -1) { - _vm->_imdPlayer->closeImd(); + _vm->_vidPlayer->closeVideo(); _vm->_game->_preventScroll = false; return; } @@ -1059,23 +1059,24 @@ void Mult_v2::playImd(const char *imdFile, Mult::Mult_ImdKey &key, int16 dir, if ((lastFrame - palFrame) < startFrame) if (!(key.flags & 0x4000)) { _vm->_game->_preventScroll = false; - _vm->_imdPlayer->closeImd(); + _vm->_vidPlayer->closeVideo(); return; } - if (!_vm->_imdPlayer->openImd(imdFile, x, y, 0, flags)) { + if (!_vm->_vidPlayer->openVideo(imdFile, x, y, flags)) { _vm->_game->_preventScroll = false; return; } if (palFrame == -1) palFrame = 0; + if (lastFrame == -1) - lastFrame = _vm->_imdPlayer->_curImd->framesCount - 1; + lastFrame = _vm->_vidPlayer->getFramesCount() - 1; baseFrame = startFrame % (lastFrame - palFrame + 1); - _vm->_imdPlayer->play(baseFrame + palFrame, flags & 0x7F, - palStart, palEnd, palFrame, lastFrame); + _vm->_vidPlayer->play(baseFrame + palFrame, baseFrame + palFrame, 0, + flags & 0x7F, palStart, palEnd, palFrame, lastFrame); } void Mult_v2::advanceObjects(int16 index) { diff --git a/engines/gob/util.cpp b/engines/gob/util.cpp index 1b20ca249e..ec8bb59f06 100644 --- a/engines/gob/util.cpp +++ b/engines/gob/util.cpp @@ -32,7 +32,6 @@ #include "gob/dataio.h" #include "gob/draw.h" #include "gob/game.h" -#include "gob/imd.h" #include "gob/sound.h" #include "gob/video.h" @@ -301,7 +300,6 @@ void Util::setFrameRate(int16 rate) { _vm->_global->_frameWaitTime = 1000 / rate; _vm->_global->_startFrameTime = getTimeKey(); - _vm->_imdPlayer->_frameDelay = 0; } void Util::waitEndFrame() { @@ -312,17 +310,13 @@ void Util::waitEndFrame() { time = getTimeKey() - _vm->_global->_startFrameTime; if ((time > 1000) || (time < 0)) { _vm->_global->_startFrameTime = getTimeKey(); - _vm->_imdPlayer->_frameDelay = 0; return; } - if (_vm->_global->_frameWaitTime - time > 0) { - _vm->_imdPlayer->_frameDelay = 0; - delay(_vm->_global->_frameWaitTime - _vm->_imdPlayer->_frameDelay - time); - } + if ((_vm->_global->_frameWaitTime - time) > 0) + delay(_vm->_global->_frameWaitTime - time); _vm->_global->_startFrameTime = getTimeKey(); - _vm->_imdPlayer->_frameDelay = time - _vm->_global->_frameWaitTime; } void Util::setScrollOffset(int16 x, int16 y) { diff --git a/engines/gob/videoplayer.cpp b/engines/gob/videoplayer.cpp new file mode 100644 index 0000000000..dfb06e6c2d --- /dev/null +++ b/engines/gob/videoplayer.cpp @@ -0,0 +1,334 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include "gob/videoplayer.h" +#include "gob/global.h" +#include "gob/util.h" +#include "gob/dataio.h" +#include "gob/video.h" +#include "gob/draw.h" +#include "gob/game.h" +#include "gob/palanim.h" +#include "gob/inter.h" + +namespace Gob { + +const char *VideoPlayer::_extensions[] = { "IMD", "VMD" }; + +VideoPlayer::VideoPlayer(GobEngine *vm) : _vm(vm) { + _curFile[0] = 0; + _stream = 0; + _video = 0; + _backSurf = false; +} + +VideoPlayer::~VideoPlayer() { + closeVideo(); +} + +bool VideoPlayer::openVideo(const char *video, int16 x, int16 y, int16 flags, Type which) { + char fileName[256]; + + strncpy0(fileName, video, 250); + + char *extStart = strchr(fileName, '.'); + if (extStart) { + // The requested file already has an extension. Verifying. + + int i; + for (i = 0; i < ARRAYSIZE(_extensions); i++) { + if (!scumm_stricmp(extStart + 1, _extensions[i])) { + if ((which != kVideoTypeTry) && (which == ((Type) i))) { + warning("Attempted to open video \"%s\", " + "but requested a different type", fileName); + return false; + } + which = (Type) i; + break; + } + } + if (i >= ARRAYSIZE(_extensions)) + extStart = 0; + + } + + if (!extStart) { + // No or unrecognized extension. Probing. + + int len = strlen(fileName); + + int i; + for (i = 0; i < ARRAYSIZE(_extensions); i++) { + if ((which == kVideoTypeTry) || (which == ((Type) i))) { + int16 handle; + + fileName[len] = '.'; + fileName[len + 1] = 0; + strcat(fileName, _extensions[i]); + + handle = _vm->_dataIO->openData(fileName); + if (handle >= 0) { + _vm->_dataIO->closeData(handle); + which = (Type) i; + break; + } + } + } + if ((i >= ARRAYSIZE(_extensions)) || (which == kVideoTypeTry)) { + fileName[len] = 0; + warning("Couldn't open video \"%s\"", fileName); + return false; + } + + } + + if (scumm_strnicmp(_curFile, fileName, strlen(fileName))) { + closeVideo(); + + int16 handle = _vm->_dataIO->openData(fileName); + + if (handle < 0) { + warning("Couldn't open video \"%s\": No such file", fileName); + return false; + } + + _stream = _vm->_dataIO->openAsStream(handle, true); + + if (which == kVideoTypeIMD) { + _video = new Imd(); + } else if (which == kVideoTypeVMD) { + warning("STUB: VMD"); + closeVideo(); + return false; + } else { + warning("Couldn't open video \"%s\": Invalid video Type", fileName); + closeVideo(); + return false; + } + + if (!_video->load(*_stream)) { + warning("While loading video \"%s\"", fileName); + closeVideo(); + return false; + } + + _video->setXY(x, y); + + if (!(flags & kFlagNoVideo)) { + _backSurf = ((flags & kFlagFrontSurface) == 0); + SurfaceDesc::Ptr surf = _vm->_draw->_spritesArray[_backSurf ? 21 : 20]; + _video->setVideoMemory(surf->getVidMem(), surf->getWidth(), surf->getHeight()); + } else + _video->setVideoMemory(); + + _video->enableSound(*_vm->_mixer); + } + + if (!_video) + return false; + + WRITE_VAR(7, _video->getFramesCount()); + + return true; +} + +void VideoPlayer::play(int16 startFrame, int16 lastFrame, int16 breakKey, + uint16 palCmd, int16 palStart, int16 palEnd, + int16 palFrame, int16 endFrame, bool fade, int16 reverseTo) { + + if (!_video) + return; + + if (startFrame < 0) + startFrame = _video->getCurrentFrame(); + if (lastFrame < 0) + lastFrame = _video->getFramesCount() - 1; + if (palFrame < 0) + palFrame = startFrame; + if (endFrame < 0) + endFrame = lastFrame; + palCmd &= 0x3F; + + if (_video->getCurrentFrame() != startFrame) + _video->seekFrame(startFrame); + + _vm->_draw->_showCursor = 0; + _vm->_util->setFrameRate(12); + + if (fade) + _vm->_palAnim->fade(0, -2, 0); + + while (startFrame <= lastFrame) { + if (doPlay(startFrame, breakKey, palCmd, palStart, palEnd, palFrame, endFrame)) + break; + + if (fade) { + _vm->_palAnim->fade(_vm->_global->_pPaletteDesc, -2, 0); + fade = false; + } + + _video->waitEndFrame(); + startFrame++; + } + + if (reverseTo >= 0) { + int16 toFrame = _video->getFramesCount() - reverseTo; + for (int i = _video->getCurrentFrame(); i >= toFrame; i--) { + _video->seekFrame(i, SEEK_SET, true); + if (doPlay(i, breakKey, 0, 0, 0, 0, 0)) { + _vm->_palAnim->fade(0, -2, 0); + memset((char *) _vm->_draw->_vgaPalette, 0, 768); + } + _video->waitEndFrame(); + } + } +} + +int16 VideoPlayer::getFramesCount() const { + if (!_video) + return 0; + + return _video->getFramesCount(); +} + +int16 VideoPlayer::getCurrentFrame() const { + if (!_video) + return 0; + + return _video->getCurrentFrame(); +} + +bool VideoPlayer::doPlay(int16 frame, int16 breakKey, + uint16 palCmd, int16 palStart, int16 palEnd, + int16 palFrame, int16 endFrame) { + + bool modifiedPal = false; + + if ((frame == palFrame) || ((frame == endFrame) && (palCmd == 8))) { + modifiedPal = true; + _vm->_draw->_applyPal = true; + + if (palCmd >= 4) + copyPalette(palStart, palEnd); + } + + if (modifiedPal && (palCmd == 8) && !_backSurf) + _vm->_video->setFullPalette(_vm->_global->_pPaletteDesc); + + + CoktelVideo::State state = _video->nextFrame(); + WRITE_VAR(11, frame); + + + if (modifiedPal && (palCmd == 16)) { + if (_backSurf) + _vm->_draw->forceBlit(); + _vm->_palAnim->fade(_vm->_global->_pPaletteDesc, -2, 0); + _vm->_draw->_noInvalidated = true; + } + + if (state.flags & CoktelVideo::kStatePalette) { + copyPalette(palStart, palEnd); + + if (!_backSurf) + _vm->_video->setFullPalette(_vm->_global->_pPaletteDesc); + else + _vm->_draw->_applyPal = true; + } + + if (modifiedPal && (palCmd == 8) && _backSurf) + _vm->_video->setFullPalette(_vm->_global->_pPaletteDesc); + + + if (_backSurf) { + _vm->_draw->invalidateRect(state.left, state.top, state.right, state.bottom); + _vm->_draw->blitInvalidated(); + } + _vm->_video->retrace(); + + + if (modifiedPal && ((palCmd == 2) || (palCmd == 4))) + _vm->_palAnim->fade(_vm->_global->_pPaletteDesc, -2, 0); + + + _vm->_util->processInput(); + + if (_vm->_quitRequested) { + _video->disableSound(); + return true; + } + + if (breakKey != 0) { + _vm->_util->getMouseState(&_vm->_global->_inter_mouseX, + &_vm->_global->_inter_mouseY, &_vm->_game->_mouseButtons); + + _vm->_inter->storeKey(_vm->_util->checkKey()); + if (VAR(0) == (unsigned) breakKey) { + _video->disableSound(); + return true; + } + } + + return false; +} + +void VideoPlayer::copyPalette(int16 palStart, int16 palEnd) { + if ((palStart == -1) || (palEnd == -1)) + memcpy((char *) _vm->_global->_pPaletteDesc->vgaPal, + _video->getPalette(), 768); + else + memcpy(((char *) (_vm->_global->_pPaletteDesc->vgaPal)) + + palStart * 3, _video->getPalette() + palStart * 3, + (palEnd - palStart + 1) * 3); +} + +void VideoPlayer::writeVideoInfo(const char *video, int16 varX, int16 varY, + int16 varFrames, int16 varWidth, int16 varHeight) { + + if (openVideo(video)) { + WRITE_VAR_OFFSET(varX, _video->getX()); + WRITE_VAR_OFFSET(varY, _video->getY()); + WRITE_VAR_OFFSET(varFrames, _video->getFramesCount()); + WRITE_VAR_OFFSET(varWidth, _video->getWidth()); + WRITE_VAR_OFFSET(varHeight, _video->getHeight()); + closeVideo(); + } else { + WRITE_VAR_OFFSET(varX, -1); + WRITE_VAR_OFFSET(varY, -1); + WRITE_VAR_OFFSET(varFrames, -1); + WRITE_VAR_OFFSET(varWidth, -1); + WRITE_VAR_OFFSET(varHeight, -1); + } +} + +void VideoPlayer::closeVideo() { + delete _video; + delete _stream; + + _video = 0; + _stream = 0; +} + +} // End of namespace Gob diff --git a/engines/gob/videoplayer.h b/engines/gob/videoplayer.h new file mode 100644 index 0000000000..c4c608dc99 --- /dev/null +++ b/engines/gob/videoplayer.h @@ -0,0 +1,86 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#ifndef GOB_VIDEOPLAYER_H +#define GOB_VIDEOPLAYER_H + +#include "gob/coktelvideo.h" +#include "gob/dataio.h" + +namespace Gob { + +class GobEngine; + +class VideoPlayer { +public: + enum Flags { + kFlagNone = 0, + kFlagFrontSurface = 0x80, + kFlagNoVideo = 0x100 + }; + + enum Type { + kVideoTypeTry = -1, + kVideoTypeIMD = 0, + kVideoTypeVMD = 1 + }; + + VideoPlayer(GobEngine *vm); + ~VideoPlayer(); + + bool openVideo(const char *video, int16 x = -1, int16 y = -1, + int16 flags = kFlagFrontSurface, Type which = kVideoTypeTry); + + void play(int16 startFrame = -1, int16 lastFrame = -1, int16 breakKey = 27, + uint16 palCmd = 8, int16 palStart = 0, int16 palEnd = 255, + int16 palFrame = -1, int16 endFrame = -1, bool fade = false, + int16 reverseTo = -1); + + int16 getFramesCount() const; + int16 getCurrentFrame() const; + void writeVideoInfo(const char *video, int16 varX, int16 varY, + int16 varFrames, int16 varWidth, int16 varHeight); + + void closeVideo(); + +private: + static const char *_extensions[]; + + GobEngine *_vm; + + char _curFile[256]; + DataStream *_stream; + CoktelVideo *_video; + bool _backSurf; + + void copyPalette(int16 palStart = -1, int16 palEnd = -1); + bool doPlay(int16 frame, int16 breakKey, + uint16 palCmd, int16 palStart, int16 palEnd, + int16 palFrame, int16 endFrame); +}; + +} // End of namespace Gob + +#endif // GOB_VIDEOPLAYER_H -- cgit v1.2.3 From 78e8dadbe3728d8ea378075b7a0e82147feb2351 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 30 Jul 2007 16:12:40 +0000 Subject: Verified some resources of the IHNM demo svn-id: r28328 --- engines/saga/sagaresnames.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/saga/sagaresnames.h b/engines/saga/sagaresnames.h index f4dcf7bf18..ad31ac8361 100644 --- a/engines/saga/sagaresnames.h +++ b/engines/saga/sagaresnames.h @@ -119,11 +119,11 @@ namespace Saga { #define RID_IHNMDEMO_MAIN_PANEL_SPRITES 7 #define RID_IHNMDEMO_ARROW_SPRITES 8 #define RID_IHNMDEMO_SAVEREMINDER_SPRITES 9 -#define RID_IHNMDEMO_OPTION_PANEL 10 // TODO: Verify this -#define RID_IHNMDEMO_OPTION_PANEL_SPRITES 11 // TODO: Verify this -#define RID_IHNMDEMO_WARNING_PANEL 12 // TODO: Verify this +#define RID_IHNMDEMO_OPTION_PANEL 10 +#define RID_IHNMDEMO_OPTION_PANEL_SPRITES 11 +#define RID_IHNMDEMO_WARNING_PANEL 12 #define RID_IHNMDEMO_BOSS_SCREEN 13 // Does not exist in the demo -#define RID_IHNMDEMO_PROFILE_BG 14 // TODO: Verify this +#define RID_IHNMDEMO_PROFILE_BG 14 #define RID_IHNMDEMO_MAIN_STRINGS 16 // Puzzle portraits -- cgit v1.2.3 From 60b41486acd5db88c1890f891e1b814986ea195b Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 30 Jul 2007 16:16:22 +0000 Subject: The disk icon is now shown in the IHNM demo (though it's not functional yet) svn-id: r28329 --- engines/saga/interface.cpp | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'engines') diff --git a/engines/saga/interface.cpp b/engines/saga/interface.cpp index ea69d75590..70d868cd80 100644 --- a/engines/saga/interface.cpp +++ b/engines/saga/interface.cpp @@ -338,8 +338,7 @@ int Interface::activate() { _vm->_actor->_protagonist->_targetObject = ID_NOTHING; unlockMode(); if (_panelMode == kPanelMain || _panelMode == kPanelChapterSelection) { - if (_vm->getGameId() != GID_IHNM_DEMO) - _saveReminderState = 1; + _saveReminderState = 1; } draw(); } @@ -382,21 +381,33 @@ void Interface::restoreMode(bool draw_) { void Interface::setMode(int mode) { debug(1, "Interface::setMode %i", mode); + // The non-interactive part of the IHNM demo does not have an options + // screen - the psychic profile screen is displayed instead, with some + // dialog options (help, play non-interactive demo, play interactive demo, quit) + // TODO: Show the psychic profile screen in the non-interactive demo and show + // the normal options screen in the interactive demo + if (_vm->getGameId() == GID_IHNM_DEMO && mode == kPanelOption) + mode = kPanelNull; + if (mode == kPanelMain) { _inMainMode = true; - if (_vm->getGameId() != GID_IHNM_DEMO) - _saveReminderState = 1; //TODO: blinking timeout + _saveReminderState = 1; //TODO: blinking timeout } else if (mode == kPanelChapterSelection) { - if (_vm->getGameId() != GID_IHNM_DEMO) - _saveReminderState = 1; + _saveReminderState = 1; } else if (mode == kPanelNull) { - if (_vm->getGameId() == GID_IHNM_DEMO) + if (_vm->getGameId() == GID_IHNM_DEMO) { _inMainMode = true; + _saveReminderState = 1; + } } else { if (mode == kPanelConverse) { _inMainMode = false; } - _saveReminderState = 0; + + if (_vm->getGameId() != GID_IHNM_DEMO) + _saveReminderState = 0; + else + _saveReminderState = 1; } _panelMode = mode; -- cgit v1.2.3 From 012f16d5c3f6c9cc49c3182ced12e47cdd8becb0 Mon Sep 17 00:00:00 2001 From: Gregory Montoir Date: Mon, 30 Jul 2007 17:45:43 +0000 Subject: added missing MIDI gm->mt32 program change mapping (bug #1759318) svn-id: r28331 --- engines/touche/midi.cpp | 9 +++++++-- engines/touche/midi.h | 5 ++++- engines/touche/staticres.cpp | 11 +++++++++++ engines/touche/touche.cpp | 3 ++- 4 files changed, 24 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/touche/midi.cpp b/engines/touche/midi.cpp index 29e68a4562..b90d4082c5 100644 --- a/engines/touche/midi.cpp +++ b/engines/touche/midi.cpp @@ -32,8 +32,8 @@ namespace Touche { -MidiPlayer::MidiPlayer(MidiDriver *driver) - : _driver(driver), _parser(0), _midiData(0), _isLooping(false), _isPlaying(false), _masterVolume(0) { +MidiPlayer::MidiPlayer(MidiDriver *driver, bool nativeMT32) + : _driver(driver), _parser(0), _midiData(0), _isLooping(false), _isPlaying(false), _masterVolume(0), _nativeMT32(nativeMT32) { assert(_driver); memset(_channelsTable, 0, sizeof(_channelsTable)); memset(_channelsVolume, 0, sizeof(_channelsVolume)); @@ -129,6 +129,11 @@ void MidiPlayer::send(uint32 b) { return; } break; + default: + if ((b & 0xF0) == 0xC0 && _nativeMT32) { // program change + b = (b & 0xFFFF00FF) | (_gmToRol[(b >> 8) & 0x7F] << 8); + } + break; } if (!_channelsTable[ch]) { _channelsTable[ch] = (ch == 9) ? _driver->getPercussionChannel() : _driver->allocateChannel(); diff --git a/engines/touche/midi.h b/engines/touche/midi.h index 808ecfb205..3b128593db 100644 --- a/engines/touche/midi.h +++ b/engines/touche/midi.h @@ -46,7 +46,7 @@ public: NUM_CHANNELS = 16 }; - MidiPlayer(MidiDriver *driver); + MidiPlayer(MidiDriver *driver, bool nativeMT32); ~MidiPlayer(); void play(Common::ReadStream &stream, int size, bool loop = false); @@ -77,9 +77,12 @@ private: bool _isLooping; bool _isPlaying; int _masterVolume; + bool _nativeMT32; MidiChannel *_channelsTable[NUM_CHANNELS]; uint8 _channelsVolume[NUM_CHANNELS]; Common::Mutex _mutex; + + static const uint8 _gmToRol[]; }; } // namespace Touche diff --git a/engines/touche/staticres.cpp b/engines/touche/staticres.cpp index 4c3ea4855f..eb3ddc15ff 100644 --- a/engines/touche/staticres.cpp +++ b/engines/touche/staticres.cpp @@ -27,6 +27,7 @@ #include "touche/graphics.h" #include "touche/touche.h" +#include "touche/midi.h" namespace Touche { @@ -1332,5 +1333,15 @@ int Graphics::_fontSize = Graphics::_engFontSize; const uint8 *Graphics::_fontData = Graphics::_engFontData; +const uint8 MidiPlayer::_gmToRol[] = { + 0x01, 0x02, 0x03, 0x08, 0x04, 0x05, 0x11, 0x14, 0x66, 0x66, 0x66, 0x62, 0x69, 0x68, 0x67, 0x26, + 0x09, 0x0A, 0x0B, 0x0E, 0x0F, 0x10, 0x10, 0x10, 0x3C, 0x3D, 0x3D, 0x3D, 0x3D, 0x3E, 0x3F, 0x3F, + 0x47, 0x41, 0x42, 0x48, 0x45, 0x46, 0x1D, 0x1E, 0x35, 0x36, 0x37, 0x39, 0x33, 0x34, 0x3A, 0x71, + 0x31, 0x32, 0x31, 0x32, 0x23, 0x23, 0x23, 0x7B, 0x59, 0x5B, 0x5F, 0x5A, 0x5D, 0x60, 0x19, 0x1A, + 0x4F, 0x50, 0x51, 0x52, 0x55, 0x56, 0x57, 0x53, 0x4B, 0x49, 0x4D, 0x4E, 0x6F, 0x6C, 0x6D, 0x6E, + 0x30, 0x19, 0x4E, 0x2B, 0x28, 0x23, 0x19, 0x30, 0x21, 0x25, 0x1C, 0x21, 0x24, 0x22, 0x21, 0x22, + 0x2A, 0x25, 0x24, 0x26, 0x2E, 0x22, 0x29, 0x21, 0x40, 0x40, 0x6A, 0x6A, 0x68, 0x10, 0x35, 0x10, + 0x7F, 0x6B, 0x69, 0x75, 0x76, 0x72, 0x74, 0x01, 0x01, 0x70, 0x01, 0x7D, 0x7C, 0x01, 0x01, 0x01 +}; } // namespace Touche diff --git a/engines/touche/touche.cpp b/engines/touche/touche.cpp index 086671d371..c67b1e9be3 100644 --- a/engines/touche/touche.cpp +++ b/engines/touche/touche.cpp @@ -97,8 +97,9 @@ int ToucheEngine::init() { setupOpcodes(); int midiDriver = MidiDriver::detectMusicDriver(MDT_MIDI | MDT_ADLIB | MDT_PREFER_MIDI); + bool native_mt32 = ((midiDriver == MD_MT32) || ConfMan.getBool("native_mt32")); MidiDriver *driver = MidiDriver::createMidi(midiDriver); - _midiPlayer = new MidiPlayer(driver); + _midiPlayer = new MidiPlayer(driver, native_mt32); _mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume")); _mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, ConfMan.getInt("speech_volume")); -- cgit v1.2.3 From 2b2af8ab5ea768edbfa3ff3bbb56ecc6df046906 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 30 Jul 2007 18:26:56 +0000 Subject: Music works now in the IHNM demo svn-id: r28332 --- engines/saga/detection_tables.h | 1 + engines/saga/ihnm_introproc.cpp | 16 ++++++++++++---- engines/saga/music.cpp | 4 +++- engines/saga/rscfile.cpp | 5 ++++- 4 files changed, 20 insertions(+), 6 deletions(-) (limited to 'engines') diff --git a/engines/saga/detection_tables.h b/engines/saga/detection_tables.h index b26a9b75d5..22e5ccdc50 100644 --- a/engines/saga/detection_tables.h +++ b/engines/saga/detection_tables.h @@ -713,6 +713,7 @@ static const SAGAGameDescription gameDescriptions[] = { "ihnm", "Demo", { + {"music.res", GAME_MUSICFILE_FM, "0439083e3dfdc51b486071d45872ae52", -1}, {"scream.res", GAME_RESOURCEFILE, "46bbdc65d164ba7e89836a0935eec8e6", -1}, {"scripts.res", GAME_SCRIPTFILE, "9626bda8978094ff9b29198bc1ed5f9a", -1}, {"sfx.res", GAME_SOUNDFILE, "1c610d543f32ec8b525e3f652536f269", -1}, diff --git a/engines/saga/ihnm_introproc.cpp b/engines/saga/ihnm_introproc.cpp index 33cfb57ce2..631da37e82 100644 --- a/engines/saga/ihnm_introproc.cpp +++ b/engines/saga/ihnm_introproc.cpp @@ -225,6 +225,16 @@ int Scene::IHNMIntroMovieProc1(int param) { q_event = _vm->_events->chain(q_event, &event); } else { + // Start playing the intro music for the demo version + event.type = kEvTOneshot; + event.code = kMusicEvent; + event.param = 1; + event.param2 = MUSIC_NORMAL; + event.op = kEventPlay; + event.time = 0; + + q_event = _vm->_events->chain(q_event, &event); + // The IHNM demo doesn't have an animation at the // Cyberdreans logo screen @@ -232,7 +242,7 @@ int Scene::IHNMIntroMovieProc1(int param) { event.type = kEvTOneshot; event.code = kSceneEvent; event.op = kEventEnd; - event.time = 4000; + event.time = 8000; q_event = _vm->_events->chain(q_event, &event); } @@ -360,8 +370,6 @@ int Scene::IHNMIntroMovieProc3(int param) { // In the GM file, this music also appears as tracks 7, 13, 19, // 25 and 31, but only track 1 sounds right with the FM music. - // FIXME: MIDI music in the demo is problematic right now, so music is - // disabled in this part if (_vm->getGameId() != GID_IHNM_DEMO) { event.type = kEvTOneshot; event.code = kMusicEvent; @@ -411,7 +419,7 @@ int Scene::IHNMIntroMovieProc3(int param) { if (_vm->getGameId() != GID_IHNM_DEMO) event.time = _vm->_music->hasAdlib() ? IHNM_TITLE_TIME_FM : IHNM_TITLE_TIME_GM; else - event.time = 10000; + event.time = 12000; q_event = _vm->_events->chain(q_event, &event); break; diff --git a/engines/saga/music.cpp b/engines/saga/music.cpp index 2e4868f412..24234864aa 100644 --- a/engines/saga/music.cpp +++ b/engines/saga/music.cpp @@ -517,8 +517,10 @@ void Music::play(uint32 resourceId, MusicFlags flags) { // Oddly enough, the intro music (song 1) is very // different in the two files. I have no idea why. + // Note that the IHNM demo has only got one music file + // (music.rsc). It is assumed that it contains FM music - if (hasAdlib()) { + if (hasAdlib() || _vm->getGameId() == GID_IHNM_DEMO) { context = _vm->_resource->getContext(GAME_MUSICFILE_FM); } else { context = _vm->_resource->getContext(GAME_MUSICFILE_GM); diff --git a/engines/saga/rscfile.cpp b/engines/saga/rscfile.cpp index 3063e8a9a6..2db85cfc65 100644 --- a/engines/saga/rscfile.cpp +++ b/engines/saga/rscfile.cpp @@ -683,7 +683,7 @@ void Resource::loadGlobalResources(int chapter, int actorsEntrance) { _vm->_anim->loadCutawayList(resourcePointer, resourceLength); - if (_metaResource.songTableID > 0) { + if (_vm->getGameId() != GID_IHNM_DEMO) { _vm->_resource->loadResource(resourceContext, _metaResource.songTableID, resourcePointer, resourceLength); if (resourceLength == 0) { @@ -700,6 +700,9 @@ void Resource::loadGlobalResources(int chapter, int actorsEntrance) { for (i = 0; i < _vm->_music->_songTableLen; i++) _vm->_music->_songTable[i] = songS.readSint32LE(); free(resourcePointer); + } else { + // The IHNM demo has a fixed music track and doesn't load a song table + _vm->_music->play(3, MUSIC_NORMAL); } int voiceLUTResourceID = 0; -- cgit v1.2.3 From 4c2ec23de7e37c148f9d3ada3cf85507c8f1db97 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Mon, 30 Jul 2007 18:35:16 +0000 Subject: Added a few stub messages svn-id: r28333 --- engines/gob/inter.h | 2 ++ engines/gob/inter_v4.cpp | 77 +++++++++++++++++++++++++++++++++++++++++++-- engines/gob/videoplayer.cpp | 2 +- 3 files changed, 77 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/gob/inter.h b/engines/gob/inter.h index 65d810412a..db56ad4cd9 100644 --- a/engines/gob/inter.h +++ b/engines/gob/inter.h @@ -516,6 +516,8 @@ protected: virtual const char *getOpcodeDrawDesc(byte i); virtual const char *getOpcodeFuncDesc(byte i, byte j); virtual const char *getOpcodeGoblinDesc(int i); + + void o4_playVmdOrMusic(); }; } // End of namespace Gob diff --git a/engines/gob/inter_v4.cpp b/engines/gob/inter_v4.cpp index 776fc1df10..1297b03fbf 100644 --- a/engines/gob/inter_v4.cpp +++ b/engines/gob/inter_v4.cpp @@ -30,10 +30,9 @@ #include "gob/gob.h" #include "gob/inter.h" #include "gob/global.h" -#include "gob/dataio.h" -#include "gob/draw.h" #include "gob/game.h" #include "gob/parse.h" +#include "gob/videoplayer.h" namespace Gob { @@ -283,7 +282,7 @@ void Inter_v4::setupOpcodes() { OPCODE(o2_initScreen), OPCODE(o2_scroll), OPCODE(o2_setScrollOffset), - OPCODE(o2_playImd), + OPCODE(o4_playVmdOrMusic), /* 84 */ OPCODE(o2_getImdInfo), OPCODE(o2_openItk), @@ -712,4 +711,76 @@ const char *Inter_v4::getOpcodeGoblinDesc(int i) { return ""; } +void Inter_v4::o4_playVmdOrMusic() { + char fileName[128]; + int16 x, y; + int16 startFrame; + int16 lastFrame; + int16 breakKey; + int16 flags; + int16 palStart; + int16 palEnd; + uint16 palCmd; + bool close; + + evalExpr(0); + _vm->_global->_inter_resStr[8] = 0; + strncpy0(fileName, _vm->_global->_inter_resStr, 127); + + x = _vm->_parse->parseValExpr(); + y = _vm->_parse->parseValExpr(); + startFrame = _vm->_parse->parseValExpr(); + lastFrame = _vm->_parse->parseValExpr(); + breakKey = _vm->_parse->parseValExpr(); + flags = _vm->_parse->parseValExpr(); + palStart = _vm->_parse->parseValExpr(); + palEnd = _vm->_parse->parseValExpr(); + palCmd = 1 << (flags & 0x3F); + + close = false; + if (lastFrame == -1) { + close = true; + } else if (lastFrame == -3) { + warning("Woodruff Stub: Video/Music command -3: Play background video %s", fileName); + return; + } else if (lastFrame == -4) { + warning("Woodruff Stub: Video/Music command -4: Play background video %s", fileName); + return; + } else if (lastFrame == -5) { + warning("Woodruff Stub: Video/Music command -5"); + return; + } else if (lastFrame == -6) { + warning("Woodruff Stub: Video/Music command -6: Load background video %s", fileName); + return; + } else if (lastFrame == -8) { + warning("Woodruff Stub: Video/Music command -8: Play background video %s", fileName); + return; + } else if (lastFrame == -9) { + warning("Woodruff Stub: Video/Music command -9: Play background music %s (%d-%d)", fileName, palEnd, palStart); + return; + } else if (lastFrame < 0) { + warning("Unknown Video/Music command: %d, %s", lastFrame, fileName); + return; + } + + if (startFrame == -2) { + startFrame = lastFrame = 0; + close = false; + } + + if ((fileName[0] != 0) && !_vm->_vidPlayer->openVideo(fileName, x, y, flags)) { + WRITE_VAR(11, -1); + return; + } + + if (startFrame >= 0) { + _vm->_game->_preventScroll = true; + _vm->_vidPlayer->play(startFrame, lastFrame, breakKey, palCmd, palStart, palEnd, 0); + _vm->_game->_preventScroll = false; + } + + if (close) + _vm->_vidPlayer->closeVideo(); +} + } // End of namespace Gob diff --git a/engines/gob/videoplayer.cpp b/engines/gob/videoplayer.cpp index dfb06e6c2d..d048b6084d 100644 --- a/engines/gob/videoplayer.cpp +++ b/engines/gob/videoplayer.cpp @@ -119,7 +119,7 @@ bool VideoPlayer::openVideo(const char *video, int16 x, int16 y, int16 flags, Ty if (which == kVideoTypeIMD) { _video = new Imd(); } else if (which == kVideoTypeVMD) { - warning("STUB: VMD"); + warning("STUB: %s", fileName); closeVideo(); return false; } else { -- cgit v1.2.3 From ba271c04054ff0ec64032df3626ab89353089415 Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Mon, 30 Jul 2007 18:39:38 +0000 Subject: Replaced some palette code in _c_endComment with a function call. svn-id: r28334 --- engines/parallaction/callables_ns.cpp | 30 ++---------------------------- 1 file changed, 2 insertions(+), 28 deletions(-) (limited to 'engines') diff --git a/engines/parallaction/callables_ns.cpp b/engines/parallaction/callables_ns.cpp index de5e1e9862..adf74cf75c 100644 --- a/engines/parallaction/callables_ns.cpp +++ b/engines/parallaction/callables_ns.cpp @@ -341,33 +341,7 @@ void Parallaction_ns::_c_endComment(void *param) { byte* _enginePal = _gfx->_palette; Gfx::Palette pal; - uint32 si; - for (si = 0; si < 32; si++) { - - byte al = _enginePal[si*3+1]; - if (al > _enginePal[si*3+2]) { - al = _enginePal[si*3+1]; - } else { - al = _enginePal[si*3+2]; - } - - if (al < _enginePal[si*3]) { - al = _enginePal[si*3]; - } else { - al = _enginePal[si*3+1]; - } - - if (al > _enginePal[si*3+2]) { - al = _enginePal[si*3+1]; - } else { - al = _enginePal[si*3+2]; - } - - pal[si*3] = al; - pal[si*3+2] = al; - pal[si*3+1] = al; - - } + _gfx->buildBWPalette(pal); int16 w = 0, h = 0; _gfx->getStringExtent(_location._endComment, 130, &w, &h); @@ -385,7 +359,7 @@ void Parallaction_ns::_c_endComment(void *param) { _gfx->displayWrappedString(_location._endComment, 3, 5, 0, 130); _gfx->updateScreen(); - uint32 di = 0; + uint32 si, di; for (di = 0; di < PALETTE_COLORS; di++) { for (si = 0; si <= 93; si +=3) { -- cgit v1.2.3 From fa190dc2975f55b86790ab64937bff2e609633ad Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Mon, 30 Jul 2007 19:05:49 +0000 Subject: Fixed palette going psychedelic at the very end of the game. svn-id: r28335 --- engines/parallaction/callables_ns.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/parallaction/callables_ns.cpp b/engines/parallaction/callables_ns.cpp index adf74cf75c..b124ba864a 100644 --- a/engines/parallaction/callables_ns.cpp +++ b/engines/parallaction/callables_ns.cpp @@ -367,7 +367,7 @@ void Parallaction_ns::_c_endComment(void *param) { if (_enginePal[si] != pal[si]) { al = _enginePal[si]; - if (al > pal[si]) + if (al < pal[si]) al = 1; else al = -1; @@ -376,7 +376,7 @@ void Parallaction_ns::_c_endComment(void *param) { if (_enginePal[si+1] != pal[si+1]) { al = _enginePal[si+1]; - if (al > pal[si+1]) + if (al < pal[si+1]) al = 1; else al = -1; @@ -385,7 +385,7 @@ void Parallaction_ns::_c_endComment(void *param) { if (_enginePal[si+2] != pal[si+2]) { al = _enginePal[si+2]; - if (al > pal[si+2]) + if (al < pal[si+2]) al = 1; else al = -1; -- cgit v1.2.3 From 2dd1dd53000918abba04156845fce2f50182657e Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Mon, 30 Jul 2007 19:54:51 +0000 Subject: Fixing Full Throttle. If I understand the code correctly, this *should* be correct not break anything else. ;) svn-id: r28338 --- engines/scumm/imuse_digi/dimuse_sndmgr.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/scumm/imuse_digi/dimuse_sndmgr.cpp b/engines/scumm/imuse_digi/dimuse_sndmgr.cpp index 625a24ef81..be80cb73e8 100644 --- a/engines/scumm/imuse_digi/dimuse_sndmgr.cpp +++ b/engines/scumm/imuse_digi/dimuse_sndmgr.cpp @@ -136,11 +136,11 @@ void ImuseDigiSndMgr::prepareSound(byte *ptr, SoundDesc *sound) { int32 offset = READ_LE_UINT16(ptr + 20); int16 code = READ_LE_UINT16(ptr + 24); - sound->numRegions = 70; + sound->numRegions = 0; sound->region = new Region[70]; assert(sound->region); - sound->numJumps = 1; + sound->numJumps = 0; sound->jump = new Jump[1]; assert(sound->jump); -- cgit v1.2.3 From 1856a0f11b3f74064a105c2a4a8431e87c958568 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 30 Jul 2007 21:13:51 +0000 Subject: Correct the object sprites only in Ted's part of the IHNM demo svn-id: r28339 --- engines/saga/sfuncs.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/saga/sfuncs.cpp b/engines/saga/sfuncs.cpp index f6aa21cb02..bbbe7a35ac 100644 --- a/engines/saga/sfuncs.cpp +++ b/engines/saga/sfuncs.cpp @@ -282,9 +282,9 @@ void Script::sfTakeObject(SCRIPTFUNC_PARAMS) { // WORKAROUND for two incorrect object sprites in the IHNM demo // (the mirror and the icon in Ted's part). Set them correctly here if (_vm->getGameId() == GID_IHNM_DEMO) { - if (obj->_spriteListResourceId == 4) + if (obj->_spriteListResourceId == 4 && objectId == 16408) obj->_spriteListResourceId = 24; - if (obj->_spriteListResourceId == 3) + if (obj->_spriteListResourceId == 3 && objectId == 16409) obj->_spriteListResourceId = 25; } -- cgit v1.2.3 From 91c2aefc2a4c276d71e51e4e2f541513ef1f19b8 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 30 Jul 2007 21:14:57 +0000 Subject: Fixed some resources of the IHNM demo svn-id: r28340 --- engines/saga/sagaresnames.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/saga/sagaresnames.h b/engines/saga/sagaresnames.h index ad31ac8361..761ac1ab68 100644 --- a/engines/saga/sagaresnames.h +++ b/engines/saga/sagaresnames.h @@ -113,7 +113,7 @@ namespace Saga { #define RID_IHNM_MAIN_STRINGS 21 #define RID_IHNMDEMO_MAIN_PANEL 5 -#define RID_IHNMDEMO_CONVERSE_PANEL 5 // TODO: Verify this +#define RID_IHNMDEMO_CONVERSE_PANEL 6 #define RID_IHNMDEMO_HOURGLASS_CURSOR 6 // Does not exist in the demo #define RID_IHNMDEMO_MAIN_SPRITES 7 #define RID_IHNMDEMO_MAIN_PANEL_SPRITES 7 @@ -123,7 +123,7 @@ namespace Saga { #define RID_IHNMDEMO_OPTION_PANEL_SPRITES 11 #define RID_IHNMDEMO_WARNING_PANEL 12 #define RID_IHNMDEMO_BOSS_SCREEN 13 // Does not exist in the demo -#define RID_IHNMDEMO_PROFILE_BG 14 +#define RID_IHNMDEMO_PROFILE_BG 15 #define RID_IHNMDEMO_MAIN_STRINGS 16 // Puzzle portraits -- cgit v1.2.3 From 6f1baac2cda438dbcb6401382dbf64f1a1e9e8bf Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 30 Jul 2007 21:17:15 +0000 Subject: The interactive part of the IHNM demo loads music normally, like the full version, so only load music manually when songTableID is 0 svn-id: r28341 --- engines/saga/rscfile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/saga/rscfile.cpp b/engines/saga/rscfile.cpp index 2db85cfc65..31961cfb5d 100644 --- a/engines/saga/rscfile.cpp +++ b/engines/saga/rscfile.cpp @@ -683,7 +683,7 @@ void Resource::loadGlobalResources(int chapter, int actorsEntrance) { _vm->_anim->loadCutawayList(resourcePointer, resourceLength); - if (_vm->getGameId() != GID_IHNM_DEMO) { + if (_metaResource.songTableID > 0) { _vm->_resource->loadResource(resourceContext, _metaResource.songTableID, resourcePointer, resourceLength); if (resourceLength == 0) { -- cgit v1.2.3 From f77195a5cc319fead3821aba7fdcb16543b8fb98 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Mon, 30 Jul 2007 23:22:09 +0000 Subject: - Removed left-over, commented-out code - Added support for palette changing within the frame data (haven't seen any IMD that actually does that, though) svn-id: r28342 --- engines/gob/coktelvideo.cpp | 30 +++++++++++++++--------------- engines/gob/coktelvideo.h | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) (limited to 'engines') diff --git a/engines/gob/coktelvideo.cpp b/engines/gob/coktelvideo.cpp index 8f17810430..e7eebe602a 100644 --- a/engines/gob/coktelvideo.cpp +++ b/engines/gob/coktelvideo.cpp @@ -450,9 +450,6 @@ CoktelVideo::State Imd::processFrame(int16 frame) { state.right += state.left - 1; state.bottom += state.top - 1; -/* if ((frame == 0) && (_features & 0x8)) - _vm->_video->setPalette(_palette);*/ - do { if (frame != 0) { if (_stdX != -1) { @@ -505,9 +502,6 @@ CoktelVideo::State Imd::processFrame(int16 frame) { if (_soundStage != 0) { byte *soundBuf; -/* if (!hasNextCmd) - waitEndSoundSlice();*/ - // Next sound slice data if (cmd == 0xFF00) { @@ -606,8 +600,7 @@ CoktelVideo::State Imd::processFrame(int16 frame) { _height = bottom - top; _width = right - left; - renderFrame(); - + state.flags |= renderFrame(); state.flags |= _frameData[0]; // Frame video data @@ -615,8 +608,7 @@ CoktelVideo::State Imd::processFrame(int16 frame) { _stream->read(_frameData, cmd + 2); - renderFrame(); - + state.flags |= renderFrame(); state.flags |= _frameData[0]; } else @@ -737,9 +729,9 @@ CoktelVideo::State Imd::peekFrame(int16 frame) { return state; } -void Imd::renderFrame() { +uint32 Imd::renderFrame() { if (!_frameData || (_width <= 0) || (_height <= 0)) - return; + return 0; if (!_vidMem) setVideoMemory(); @@ -753,11 +745,17 @@ void Imd::renderFrame() { byte *imdVidMem = _vidMem + sW * imdY + imdX; uint8 type = *dataPtr++; byte *srcPtr = dataPtr; - + uint32 retVal = 0; if (type & 0x10) { // Palette data + // One byte index + int index = *dataPtr++; + // 16 entries with each 3 bytes (RGB) + memcpy(_palette + index * 3, dataPtr, MIN((255 - index) * 3, 48)); + + retVal = kStatePalette; + dataPtr += 48; type ^= 0x10; - dataPtr += 49; } srcPtr = dataPtr; @@ -766,7 +764,7 @@ void Imd::renderFrame() { type &= 0x7F; if ((type == 2) && (imdW == sW)) { frameUncompressor(imdVidMem, dataPtr); - return; + return retVal; } else frameUncompressor(srcPtr, dataPtr); } @@ -843,6 +841,8 @@ void Imd::renderFrame() { imdVidMem = imdVidMemBak; } } + + return retVal; } void Imd::frameUncompressor(byte *dest, byte *src) { diff --git a/engines/gob/coktelvideo.h b/engines/gob/coktelvideo.h index 4e7512eb8b..5788d024af 100644 --- a/engines/gob/coktelvideo.h +++ b/engines/gob/coktelvideo.h @@ -239,7 +239,7 @@ protected: void clear(bool del = true); State processFrame(int16 frame); - void renderFrame(); + uint32 renderFrame(); void frameUncompressor(byte *dest, byte *src); }; -- cgit v1.2.3 From a09a95c99a6a7ccb7ef66c60dace493eefb3eb86 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 30 Jul 2007 23:30:08 +0000 Subject: sf92 is not null in the demo version of IHNM svn-id: r28343 --- engines/saga/script.h | 1 + engines/saga/sfuncs.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/saga/script.h b/engines/saga/script.h index b9864fb227..04181ae7d2 100644 --- a/engines/saga/script.h +++ b/engines/saga/script.h @@ -596,6 +596,7 @@ private: void sf89(SCRIPTFUNC_PARAMS); void sfGetPoints(SCRIPTFUNC_PARAMS); void sfSetGlobalFlag(SCRIPTFUNC_PARAMS); + void sf92(SCRIPTFUNC_PARAMS); void sfClearGlobalFlag(SCRIPTFUNC_PARAMS); void sfTestGlobalFlag(SCRIPTFUNC_PARAMS); void sfSetPoints(SCRIPTFUNC_PARAMS); diff --git a/engines/saga/sfuncs.cpp b/engines/saga/sfuncs.cpp index bbbe7a35ac..b654d97fb1 100644 --- a/engines/saga/sfuncs.cpp +++ b/engines/saga/sfuncs.cpp @@ -230,7 +230,7 @@ static const ScriptFunctionDescription IHNMscriptFunctionsList[IHNM_SCRIPT_FUNCT OPCODE(sf89), OPCODE(sfVstopFX), OPCODE(sfVstopLoopedFX), - OPCODE(sfNull), + OPCODE(sf92), // only used in the demo version of IHNM OPCODE(sfDemoIsInteractive), OPCODE(sfVsetTrack), OPCODE(sfGetPoints), @@ -2109,6 +2109,11 @@ void Script::sfVstopLoopedFX(SCRIPTFUNC_PARAMS) { _vm->_sound->stopSound(); } +void Script::sf92(SCRIPTFUNC_PARAMS) { + SF_stub("sf92", thread, nArgs); + // This opcode is empty in the full version of IHNM, but it's not empty in the demo +} + void Script::sfDemoIsInteractive(SCRIPTFUNC_PARAMS) { thread->_returnValue = 0; } -- cgit v1.2.3 From 889d1a4aeee83392b2b1fcfb252ac37156587434 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 30 Jul 2007 23:37:18 +0000 Subject: The interactive part of the IHNM demo fully works now. Also, made the options screen work in the non-interactive part of the demo svn-id: r28344 --- engines/saga/animation.cpp | 12 ++++++- engines/saga/gfx.cpp | 3 +- engines/saga/interface.cpp | 83 +++++++++++++++++++++++++++++++++++----------- engines/saga/scene.cpp | 15 +++++++++ engines/saga/scene.h | 1 + 5 files changed, 92 insertions(+), 22 deletions(-) (limited to 'engines') diff --git a/engines/saga/animation.cpp b/engines/saga/animation.cpp index bad1155806..a8fa7005d8 100644 --- a/engines/saga/animation.cpp +++ b/engines/saga/animation.cpp @@ -316,7 +316,17 @@ void Anim::clearCutaway(void) { } _vm->_interface->restoreMode(); - _vm->_gfx->showCursor(true); + + if (_vm->getGameId() != GID_IHNM_DEMO) { + if (_vm->_scene->currentSceneNumber() >= 144 && _vm->_scene->currentSceneNumber() <= 149) { + // Don't show the mouse cursor in the non-interactive part of the IHNM demo + } else { + _vm->_gfx->showCursor(true); + } + } else { + // Enable the save reminder state after each cutaway for the IHNM demo + _vm->_interface->setSaveReminderState(true); + } } } diff --git a/engines/saga/gfx.cpp b/engines/saga/gfx.cpp index c19d71c13d..8d36ee0e12 100644 --- a/engines/saga/gfx.cpp +++ b/engines/saga/gfx.cpp @@ -406,8 +406,7 @@ void Gfx::blackToPal(PalEntry *srcPal, double percent) { } void Gfx::showCursor(bool state) { - if (_vm->getGameId() != GID_IHNM_DEMO) // Don't show the mouse cursor in the IHNM demo - CursorMan.showMouse(state); + CursorMan.showMouse(state); } void Gfx::setCursor(CursorType cursorType) { diff --git a/engines/saga/interface.cpp b/engines/saga/interface.cpp index 70d868cd80..19d9db7132 100644 --- a/engines/saga/interface.cpp +++ b/engines/saga/interface.cpp @@ -339,11 +339,21 @@ int Interface::activate() { unlockMode(); if (_panelMode == kPanelMain || _panelMode == kPanelChapterSelection) { _saveReminderState = 1; + } else if (_panelMode == kPanelNull && _vm->getGameId() == GID_IHNM_DEMO) { + _saveReminderState = 1; } draw(); } - _vm->_gfx->showCursor(true); + if (_vm->getGameId() != GID_IHNM_DEMO) { + _vm->_gfx->showCursor(true); + } else { + if (_vm->_scene->currentSceneNumber() >= 144 && _vm->_scene->currentSceneNumber() <= 149) { + // Don't show the mouse cursor in the non-interactive part of the IHNM demo + } else { + _vm->_gfx->showCursor(true); + } + } return SUCCESS; } @@ -381,14 +391,6 @@ void Interface::restoreMode(bool draw_) { void Interface::setMode(int mode) { debug(1, "Interface::setMode %i", mode); - // The non-interactive part of the IHNM demo does not have an options - // screen - the psychic profile screen is displayed instead, with some - // dialog options (help, play non-interactive demo, play interactive demo, quit) - // TODO: Show the psychic profile screen in the non-interactive demo and show - // the normal options screen in the interactive demo - if (_vm->getGameId() == GID_IHNM_DEMO && mode == kPanelOption) - mode = kPanelNull; - if (mode == kPanelMain) { _inMainMode = true; _saveReminderState = 1; //TODO: blinking timeout @@ -398,16 +400,20 @@ void Interface::setMode(int mode) { if (_vm->getGameId() == GID_IHNM_DEMO) { _inMainMode = true; _saveReminderState = 1; - } + if ((_vm->_scene->currentSceneNumber() >= 144 && _vm->_scene->currentSceneNumber() <= 149) || + _vm->_scene->currentSceneNumber() == 0 || _vm->_scene->currentSceneNumber() == -1) + _vm->_gfx->showCursor(false); + } + } else if (mode == kPanelOption) { + // Show the cursor in the IHNM demo + if (_vm->getGameId() == GID_IHNM_DEMO) + _vm->_gfx->showCursor(true); } else { if (mode == kPanelConverse) { _inMainMode = false; } - if (_vm->getGameId() != GID_IHNM_DEMO) - _saveReminderState = 0; - else - _saveReminderState = 1; + _saveReminderState = 0; } _panelMode = mode; @@ -493,6 +499,11 @@ bool Interface::processAscii(uint16 ascii) { } return true; } + + if (_vm->getGameId() == GID_IHNM_DEMO) { + if (_vm->_scene->currentSceneNumber() >= 144 && _vm->_scene->currentSceneNumber() <= 149) + _vm->_scene->showIHNMDemoSpecialScreen(); + } break; case kPanelCutaway: if (ascii == 27) { // Esc @@ -501,6 +512,11 @@ bool Interface::processAscii(uint16 ascii) { _vm->_scene->cutawaySkip(); return true; } + + if (_vm->getGameId() == GID_IHNM_DEMO) { + if (_vm->_scene->currentSceneNumber() >= 144 && _vm->_scene->currentSceneNumber() <= 149) + _vm->_scene->showIHNMDemoSpecialScreen(); + } break; case kPanelVideo: if (ascii == 27) { // Esc @@ -511,6 +527,12 @@ bool Interface::processAscii(uint16 ascii) { _vm->_actor->abortAllSpeeches(); } _vm->_scene->cutawaySkip(); + return true; + } + + if (_vm->getGameId() == GID_IHNM_DEMO) { + if (_vm->_scene->currentSceneNumber() >= 144 && _vm->_scene->currentSceneNumber() <= 149) + _vm->_scene->showIHNMDemoSpecialScreen(); } break; case kPanelOption: @@ -679,8 +701,8 @@ void Interface::setStatusText(const char *text, int statusColor) { if (_vm->getGameType() == GType_IHNM && _vm->_scene->currentChapterNumber() == 8) return; - // Disable the status text in the IHNM demo - if (_vm->getGameId() == GID_IHNM_DEMO) + // Disable the status text in the introduction of the IHNM demo + if (_vm->getGameId() == GID_IHNM_DEMO && _vm->_scene->currentSceneNumber() == 0) return; assert(text != NULL); @@ -1496,10 +1518,20 @@ void Interface::setOption(PanelButton *panelButton) { switch (panelButton->id) { case kTextContinuePlaying: ConfMan.flushToDisk(); - if (!(_vm->getGameType() == GType_IHNM && _vm->_scene->currentChapterNumber() == 8)) + if (_vm->getGameType() == GType_ITE) { setMode(kPanelMain); - else - setMode(kPanelChapterSelection); + } else { + if (_vm->_scene->currentChapterNumber() == 8) { + setMode(kPanelChapterSelection); + } else if (_vm->getGameId() == GID_IHNM_DEMO) { + if (_vm->_scene->currentSceneNumber() >= 144 && _vm->_scene->currentSceneNumber() <= 149) + setMode(kPanelNull); + else + setMode(kPanelMain); + } else { + setMode(kPanelMain); + } + } break; case kTextQuitGame: setMode(kPanelQuit); @@ -1515,6 +1547,12 @@ void Interface::setOption(PanelButton *panelButton) { } break; case kTextSave: + // Disallow saving in the non-interactive part of the IHNM demo + if (_vm->getGameId() == GID_IHNM_DEMO) { + if (_vm->_scene->currentSceneNumber() >= 144 && _vm->_scene->currentSceneNumber() <= 149) + return; + } + if (!_vm->isSaveListFull() && (_optionSaveFileTitleNumber == 0)) { _textInputString[0] = 0; } else { @@ -1721,6 +1759,13 @@ void Interface::update(const Point& mousePoint, int updateFlag) { _vm->_scene->clearPsychicProfile(); } break; + + case kPanelNull: + if (_vm->getGameId() == GID_IHNM_DEMO && (updateFlag & UPDATE_MOUSECLICK)) { + if (_vm->_scene->currentSceneNumber() >= 144 && _vm->_scene->currentSceneNumber() <= 149) + _vm->_scene->showIHNMDemoSpecialScreen(); + } + break; } _lastMousePoint = mousePoint; diff --git a/engines/saga/scene.cpp b/engines/saga/scene.cpp index 2d85642891..d615a2a387 100644 --- a/engines/saga/scene.cpp +++ b/engines/saga/scene.cpp @@ -642,6 +642,15 @@ void Scene::loadScene(LoadSceneParams *loadSceneParams) { debug(3, "Loading scene number %d:", _sceneNumber); + if (_vm->getGameId() == GID_IHNM_DEMO && _sceneNumber == 144) { + // WORKAROUND for the non-interactive part of the IHNM demo: When restarting the + // non-interactive demo, opcode sfMainMode is incorrectly called. Therefore, if the + // starting scene of the non-interactive demo is loaded (scene 144), set panel to null + // and lock the user interface + _vm->_interface->deactivate(); + _vm->_interface->setMode(kPanelNull); + } + // Load scene descriptor and resource list resources if (_loadDescription) { debug(3, "Loading scene resource %i", _sceneResourceId); @@ -1351,4 +1360,10 @@ void Scene::clearPsychicProfile() { _vm->_interface->activate(); } +void Scene::showIHNMDemoSpecialScreen() { + _vm->_gfx->showCursor(true); + _vm->_interface->clearInventory(); + _vm->_scene->changeScene(150, 0, kTransitionFade); +} + } // End of namespace Saga diff --git a/engines/saga/scene.h b/engines/saga/scene.h index d6414e5759..9666a6a6e8 100644 --- a/engines/saga/scene.h +++ b/engines/saga/scene.h @@ -342,6 +342,7 @@ class Scene { void clearPlacard(); void clearPsychicProfile(); + void showIHNMDemoSpecialScreen(); private: void loadScene(LoadSceneParams *loadSceneParams); -- cgit v1.2.3 From 3ee5ee2c060a4caf847ea15756cab802c9d91db7 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 31 Jul 2007 00:06:57 +0000 Subject: Loading saved games in the demo version of IHNM should work now svn-id: r28345 --- engines/saga/rscfile.cpp | 2 +- engines/saga/saveload.cpp | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/saga/rscfile.cpp b/engines/saga/rscfile.cpp index 31961cfb5d..d308fcbe7e 100644 --- a/engines/saga/rscfile.cpp +++ b/engines/saga/rscfile.cpp @@ -702,7 +702,7 @@ void Resource::loadGlobalResources(int chapter, int actorsEntrance) { free(resourcePointer); } else { // The IHNM demo has a fixed music track and doesn't load a song table - _vm->_music->play(3, MUSIC_NORMAL); + _vm->_music->play(3, MUSIC_LOOP); } int voiceLUTResourceID = 0; diff --git a/engines/saga/saveload.cpp b/engines/saga/saveload.cpp index c93ace81b3..48fcc16d4e 100644 --- a/engines/saga/saveload.cpp +++ b/engines/saga/saveload.cpp @@ -276,7 +276,10 @@ void SagaEngine::load(const char *fileName) { _scene->setCurrentMusicTrack(in->readSint32LE()); _scene->setCurrentMusicRepeat(in->readSint32LE()); _music->stop(); - _music->play(_music->_songTable[_scene->getCurrentMusicTrack()], _scene->getCurrentMusicRepeat() ? MUSIC_LOOP : MUSIC_NORMAL); + if (getGameId() != GID_IHNM_DEMO) + _music->play(_music->_songTable[_scene->getCurrentMusicTrack()], _scene->getCurrentMusicRepeat() ? MUSIC_LOOP : MUSIC_NORMAL); + else + _music->play(3, MUSIC_LOOP); } // Inset scene -- cgit v1.2.3 From 9a125828b92cae9c1b503731f29ee3712322228f Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 31 Jul 2007 00:18:45 +0000 Subject: The mouse works correctly now in the options dialog when it's opened in the non-interactive part of the IHNM demo svn-id: r28346 --- engines/saga/interface.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/saga/interface.cpp b/engines/saga/interface.cpp index 19d9db7132..c7054436d9 100644 --- a/engines/saga/interface.cpp +++ b/engines/saga/interface.cpp @@ -1603,9 +1603,11 @@ void Interface::update(const Point& mousePoint, int updateFlag) { _vm->_actor->abortSpeech(); if (_vm->_scene->isInIntro() || _fadeMode == kFadeOut || !_active) { - // When opening the psychic profile, the interface is locked (_active is false) - // Don't return if the psychic profile is up, so that mouse clicks can be processed - if (!(_vm->getGameType() == GType_IHNM && _panelMode == kPanelPlacard && (updateFlag & UPDATE_MOUSECLICK))) + // When opening the psychic profile, or the options screen in the non-interactive part of the IHNM demo, + // the interface is locked (_active is false) + // Don't return in those cases, so that mouse actions can be processed + if (!(_vm->getGameType() == GType_IHNM && _panelMode == kPanelPlacard && (updateFlag & UPDATE_MOUSECLICK)) && + !(_vm->getGameId() == GID_IHNM_DEMO && (_panelMode == kPanelOption || _panelMode == kPanelQuit))) return; } -- cgit v1.2.3 From 2707e3a7e8cc02429ca73f59b488c75dbfc82500 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 31 Jul 2007 00:52:00 +0000 Subject: Music should not be played after changing scene if it's disabled from the options svn-id: r28347 --- engines/saga/music.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'engines') diff --git a/engines/saga/music.cpp b/engines/saga/music.cpp index 24234864aa..710485fc05 100644 --- a/engines/saga/music.cpp +++ b/engines/saga/music.cpp @@ -431,6 +431,10 @@ void Music::play(uint32 resourceId, MusicFlags flags) { _player->stopMusic(); _mixer->stopHandle(_musicHandle); + if (!_vm->_musicVolume) { + return; + } + int realTrackNumber; if (_vm->getGameType() == GType_ITE) { -- cgit v1.2.3 From 32d00708687d10152ebc84df86b84aaad2059478 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 31 Jul 2007 01:21:25 +0000 Subject: Play MIDI music at the volume specified in the options screen svn-id: r28348 --- engines/saga/sfuncs.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/saga/sfuncs.cpp b/engines/saga/sfuncs.cpp index b654d97fb1..6cf1b35485 100644 --- a/engines/saga/sfuncs.cpp +++ b/engines/saga/sfuncs.cpp @@ -1752,7 +1752,7 @@ void Script::sfPlayMusic(SCRIPTFUNC_PARAMS) { int16 param = thread->pop() + 9; if (param >= 9 && param <= 34) { - _vm->_music->setVolume(-1, 1); + _vm->_music->setVolume(_vm->_musicVolume == 10 ? -1 : _vm->_musicVolume * 25, 1); _vm->_music->play(param); } else { _vm->_music->stop(); @@ -1769,7 +1769,7 @@ void Script::sfPlayMusic(SCRIPTFUNC_PARAMS) { if (param1 >= _vm->_music->_songTableLen) { warning("sfPlayMusic: Wrong song number (%d > %d)", param1, _vm->_music->_songTableLen - 1); } else { - _vm->_music->setVolume(-1, 1); + _vm->_music->setVolume(_vm->_musicVolume == 10 ? -1 : _vm->_musicVolume * 25, 1); _vm->_music->play(_vm->_music->_songTable[param1], param2 ? MUSIC_LOOP : MUSIC_NORMAL); if (!_vm->_scene->haveChapterPointsChanged()) { _vm->_scene->setCurrentMusicTrack(param1); @@ -2206,7 +2206,7 @@ void Script::sfQueueMusic(SCRIPTFUNC_PARAMS) { if (param1 >= _vm->_music->_songTableLen) { warning("sfQueueMusic: Wrong song number (%d > %d)", param1, _vm->_music->_songTableLen - 1); } else { - _vm->_music->setVolume(-1, 1); + _vm->_music->setVolume(_vm->_musicVolume == 10 ? -1 : _vm->_musicVolume * 25, 1); event.type = kEvTOneshot; event.code = kMusicEvent; event.param = _vm->_music->_songTable[param1]; -- cgit v1.2.3 From 34292a6b586a44aa8fb9361369dddf854ce999c6 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Tue, 31 Jul 2007 01:43:32 +0000 Subject: Minor DataIO-cleanup svn-id: r28349 --- engines/gob/cdrom.cpp | 17 +++++++++-------- engines/gob/dataio.cpp | 49 ++++++++++++------------------------------------ engines/gob/dataio.h | 11 ++++------- engines/gob/game.cpp | 29 +++++++++++++++++----------- engines/gob/init.cpp | 17 +++++++++++------ engines/gob/inter_v1.cpp | 15 ++++++++------- engines/gob/inter_v2.cpp | 12 +++++++----- 7 files changed, 69 insertions(+), 81 deletions(-) (limited to 'engines') diff --git a/engines/gob/cdrom.cpp b/engines/gob/cdrom.cpp index 6b32720cff..2ee8595ad3 100644 --- a/engines/gob/cdrom.cpp +++ b/engines/gob/cdrom.cpp @@ -68,29 +68,30 @@ void CDROM::readLIC(const char *fname) { _vm->_dataIO->getUnpackedData(tmp); handle = _vm->_dataIO->openData(tmp); + DataStream *stream = _vm->_dataIO->openAsStream(handle, true); - version = _vm->_dataIO->readUint16(handle); - startChunk = _vm->_dataIO->readUint16(handle); - _numTracks = _vm->_dataIO->readUint16(handle); + version = stream->readUint16LE(); + startChunk = stream->readUint16LE(); + _numTracks = stream->readUint16LE(); if (version != 3) error("%s: Unknown version %d", fname, version); - _vm->_dataIO->seekData(handle, 50, SEEK_SET); + stream->seek(50); for (int i = 0; i < startChunk; i++) { - pos = _vm->_dataIO->readUint16(handle); + pos = stream->readUint16LE(); if (!pos) break; - _vm->_dataIO->seekData(handle, pos, SEEK_CUR); + stream->skip(pos); } _LICbuffer = new byte[_numTracks * 22]; - _vm->_dataIO->readData(handle, _LICbuffer, _numTracks * 22); + stream->read(_LICbuffer, _numTracks * 22); - _vm->_dataIO->closeData(handle); + delete stream; } void CDROM::freeLICbuffer() { diff --git a/engines/gob/dataio.cpp b/engines/gob/dataio.cpp index 73318adc14..3c5dbed575 100644 --- a/engines/gob/dataio.cpp +++ b/engines/gob/dataio.cpp @@ -480,39 +480,14 @@ DataStream *DataIO::openAsStream(int16 handle, bool dispose) { return new DataStream(*this, handle, size, dispose); } -int32 DataIO::readData(int16 handle, byte *buf, uint16 size) { - int32 res; - - res = readChunk(handle, buf, size); - if (res >= 0) - return res; - - return file_getHandle(handle)->read(buf, size); -} - -byte DataIO::readByte(int16 handle) { - byte buf; - - readData(handle, &buf, 1); - return ((byte) buf); -} - -uint16 DataIO::readUint16(int16 handle) { - byte buf[2]; - - readData(handle, buf, 2); - return READ_LE_UINT16(buf); -} - -uint32 DataIO::readUint32(int16 handle) { - byte buf[4]; +uint32 DataIO::getPos(int16 handle) { + uint32 resPos; - readData(handle, buf, 4); - return READ_LE_UINT32(buf); -} + resPos = getChunkPos(handle); + if (resPos != 0xFFFFFFFF) + return resPos; -int32 DataIO::writeData(int16 handle, byte *buf, uint16 size) { - return file_getHandle(handle)->write(buf, size); + return file_getHandle(handle)->pos(); } void DataIO::seekData(int16 handle, int32 pos, int16 from) { @@ -525,14 +500,14 @@ void DataIO::seekData(int16 handle, int32 pos, int16 from) { file_getHandle(handle)->seek(pos, from); } -uint32 DataIO::getPos(int16 handle) { - uint32 resPos; +int32 DataIO::readData(int16 handle, byte *buf, uint16 size) { + int32 res; - resPos = getChunkPos(handle); - if (resPos != 0xFFFFFFFF) - return resPos; + res = readChunk(handle, buf, size); + if (res >= 0) + return res; - return file_getHandle(handle)->pos(); + return file_getHandle(handle)->read(buf, size); } int32 DataIO::getDataSize(const char *name) { diff --git a/engines/gob/dataio.h b/engines/gob/dataio.h index 3560093d9e..b30a389865 100644 --- a/engines/gob/dataio.h +++ b/engines/gob/dataio.h @@ -83,13 +83,6 @@ public: Common::File::AccessMode mode = Common::File::kFileReadMode); DataStream *openAsStream(int16 handle, bool dispose = false); - int32 readData(int16 handle, byte *buf, uint16 size); - byte readByte(int16 handle); - uint16 readUint16(int16 handle); - uint32 readUint32(int16 handle); - int32 writeData(int16 handle, byte *buf, uint16 size); - void seekData(int16 handle, int32 pos, int16 from); - uint32 getPos(int16 handle); int32 getDataSize(const char *name); byte *getData(const char *path); DataStream *getDataStream(const char *path); @@ -123,6 +116,10 @@ protected: uint32 getChunkPos(int16 handle) const; int32 getChunkSize(const char *chunkName); + uint32 getPos(int16 handle); + void seekData(int16 handle, int32 pos, int16 from); + int32 readData(int16 handle, byte *buf, uint16 size); + friend class DataStream; }; diff --git a/engines/gob/game.cpp b/engines/gob/game.cpp index b625a35258..37817c12a3 100644 --- a/engines/gob/game.cpp +++ b/engines/gob/game.cpp @@ -174,8 +174,10 @@ byte *Game::loadExtData(int16 itemId, int16 *pResWidth, } else handle = _extHandle; + DataStream *stream = _vm->_dataIO->openAsStream(handle); + debugC(7, kDebugFileIO, "off: %d size: %d", offset, tableSize); - _vm->_dataIO->seekData(handle, offset + tableSize, SEEK_SET); + stream->seek(offset + tableSize); realSize = size; if (isPacked) dataBuf = new byte[size + 2]; @@ -185,11 +187,13 @@ byte *Game::loadExtData(int16 itemId, int16 *pResWidth, dataPtr = dataBuf; while (size > 32000) { // BUG: huge->far conversion. Need normalization? - _vm->_dataIO->readData(handle, dataPtr, 32000); + stream->read(dataPtr, 32000); size -= 32000; dataPtr += 32000; } - _vm->_dataIO->readData(handle, dataPtr, size); + stream->read(dataPtr, size); + + delete stream; if (commonHandle != -1) { _vm->_dataIO->closeData(commonHandle); _extHandle = _vm->_dataIO->openData(_curExtFile); @@ -421,23 +425,26 @@ void Game::loadExtTable(void) { if (_extHandle < 0) return; - count = _vm->_dataIO->readUint16(_extHandle); + DataStream *stream = _vm->_dataIO->openAsStream(_extHandle); + count = stream->readUint16LE(); - _vm->_dataIO->seekData(_extHandle, 0, SEEK_SET); + stream->seek(0); _extTable = new ExtTable; _extTable->items = 0; if (count) _extTable->items = new ExtItem[count]; - _extTable->itemsCount = _vm->_dataIO->readUint16(_extHandle); - _extTable->unknown = _vm->_dataIO->readByte(_extHandle); + _extTable->itemsCount = stream->readUint16LE(); + _extTable->unknown = stream->readByte(); for (int i = 0; i < count; i++) { - _extTable->items[i].offset = _vm->_dataIO->readUint32(_extHandle); - _extTable->items[i].size = _vm->_dataIO->readUint16(_extHandle); - _extTable->items[i].width = _vm->_dataIO->readUint16(_extHandle); - _extTable->items[i].height = _vm->_dataIO->readUint16(_extHandle); + _extTable->items[i].offset = stream->readUint32LE(); + _extTable->items[i].size = stream->readUint16LE(); + _extTable->items[i].width = stream->readUint16LE(); + _extTable->items[i].height = stream->readUint16LE(); } + + delete stream; } void Game::loadImFile(void) { diff --git a/engines/gob/init.cpp b/engines/gob/init.cpp index 85f95fb261..4712a19a5d 100644 --- a/engines/gob/init.cpp +++ b/engines/gob/init.cpp @@ -147,10 +147,12 @@ void Init::initGame(const char *totName) { handle = _vm->_dataIO->openData(buffer); if (handle >= 0) { - // Get variables count - _vm->_dataIO->seekData(handle, 0x2C, SEEK_SET); - varsCount = _vm->_dataIO->readUint16(handle); - _vm->_dataIO->closeData(handle); + DataStream *stream = _vm->_dataIO->openAsStream(handle, true); + + stream->seek(0x2C); + varsCount = stream->readUint16LE(); + + delete stream; _vm->_global->_inter_variables = new byte[varsCount * 4]; _vm->_global->_inter_variablesSizes = new byte[varsCount * 4]; @@ -178,9 +180,12 @@ void Init::initGame(const char *totName) { _vm->_draw->closeScreen(); } else if ((imdHandle = _vm->_dataIO->openData("coktel.clt")) >= 0) { _vm->_draw->initScreen(); + + stream = _vm->_dataIO->openAsStream(imdHandle, true); _vm->_util->clearPalette(); - _vm->_dataIO->readData(imdHandle, (byte *) _vm->_draw->_vgaPalette, 768); - _vm->_dataIO->closeData(imdHandle); + stream->read((byte *) _vm->_draw->_vgaPalette, 768); + delete stream; + imdHandle = _vm->_dataIO->openData("coktel.ims"); if (imdHandle >= 0) { byte *sprBuf; diff --git a/engines/gob/inter_v1.cpp b/engines/gob/inter_v1.cpp index 7f5a641c1b..5d74138db1 100644 --- a/engines/gob/inter_v1.cpp +++ b/engines/gob/inter_v1.cpp @@ -2225,22 +2225,23 @@ bool Inter_v1::o1_readData(OpFuncParams ¶ms) { WRITE_VAR(1, 1); handle = _vm->_dataIO->openData(_vm->_global->_inter_resStr); if (handle >= 0) { + DataStream *stream = _vm->_dataIO->openAsStream(handle, true); + _vm->_draw->animateCursor(4); if (offset < 0) - _vm->_dataIO->seekData(handle, -offset - 1, SEEK_END); + stream->seek(-offset - 1, SEEK_END); else - _vm->_dataIO->seekData(handle, offset, SEEK_SET); + stream->seek(offset); if (((dataVar >> 2) == 59) && (size == 4)) - WRITE_VAR(59, _vm->_dataIO->readUint32(handle)); + WRITE_VAR(59, stream->readUint32LE()); else - retSize = _vm->_dataIO->readData(handle, - _vm->_global->_inter_variables + dataVar, size); - - _vm->_dataIO->closeData(handle); + retSize = stream->read(_vm->_global->_inter_variables + dataVar, size); if (retSize == size) WRITE_VAR(1, 0); + + delete stream; } if (_vm->_game->_extHandle >= 0) diff --git a/engines/gob/inter_v2.cpp b/engines/gob/inter_v2.cpp index 58970d9fcd..23abc38f6c 100644 --- a/engines/gob/inter_v2.cpp +++ b/engines/gob/inter_v2.cpp @@ -1903,25 +1903,27 @@ bool Inter_v2::o2_readData(OpFuncParams ¶ms) { if (handle < 0) return false; + DataStream *stream = _vm->_dataIO->openAsStream(handle, true); + _vm->_draw->animateCursor(4); if (offset < 0) - _vm->_dataIO->seekData(handle, -offset - 1, SEEK_END); + stream->seek(-offset - 1, SEEK_END); else - _vm->_dataIO->seekData(handle, offset, SEEK_SET); + stream->seek(offset); if (((dataVar >> 2) == 59) && (size == 4)) { - WRITE_VAR(59, _vm->_dataIO->readUint32(handle)); + WRITE_VAR(59, stream->readUint32LE()); // The scripts in some versions divide through 256^3 then, // effectively doing a LE->BE conversion if ((_vm->_platform != Common::kPlatformPC) && (VAR(59) < 256)) WRITE_VAR(59, SWAP_BYTES_32(VAR(59))); } else - retSize = _vm->_dataIO->readData(handle, buf, size); + retSize = stream->read(buf, size); if (retSize == size) WRITE_VAR(1, 0); - _vm->_dataIO->closeData(handle); + delete stream; return false; } -- cgit v1.2.3 From 165f7fcf73302a08cad5eddf24a00889f56cdefb Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 31 Jul 2007 04:19:23 +0000 Subject: Implement some differences to the actor walking code in IHNM svn-id: r28352 --- engines/saga/actor.cpp | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'engines') diff --git a/engines/saga/actor.cpp b/engines/saga/actor.cpp index 2df186f093..5cb91b8663 100644 --- a/engines/saga/actor.cpp +++ b/engines/saga/actor.cpp @@ -2129,7 +2129,10 @@ bool Actor::actorWalkTo(uint16 actorId, const Location &toLocation) { if ((((actor->_currentAction >= kActionWalkToPoint) && (actor->_currentAction <= kActionWalkDir)) || (actor == _protagonist)) && !_vm->_scene->canWalk(pointFrom)) { - for (i = 1; i < 8; i++) { + + int max = _vm->getGameType() == GType_ITE ? 8 : 4; + + for (i = 1; i < max; i++) { pointAdd = pointFrom; pointAdd.y += i; if (_vm->_scene->canWalk(pointAdd)) { @@ -2142,17 +2145,19 @@ bool Actor::actorWalkTo(uint16 actorId, const Location &toLocation) { pointFrom = pointAdd; break; } - pointAdd = pointFrom; - pointAdd.x += i; - if (_vm->_scene->canWalk(pointAdd)) { - pointFrom = pointAdd; - break; - } - pointAdd = pointFrom; - pointAdd.x -= i; - if (_vm->_scene->canWalk(pointAdd)) { - pointFrom = pointAdd; - break; + if (_vm->getGameType() == GType_ITE) { + pointAdd = pointFrom; + pointAdd.x += i; + if (_vm->_scene->canWalk(pointAdd)) { + pointFrom = pointAdd; + break; + } + pointAdd = pointFrom; + pointAdd.x -= i; + if (_vm->_scene->canWalk(pointAdd)) { + pointFrom = pointAdd; + break; + } } } } -- cgit v1.2.3 From 89451cfa43a81eaa1d944229571d8eb7c4cac5b8 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 31 Jul 2007 15:36:38 +0000 Subject: It's now possible to return to the chapter selection screen correctly in IHNM svn-id: r28358 --- engines/saga/scene.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/saga/scene.cpp b/engines/saga/scene.cpp index d615a2a387..6e51296bad 100644 --- a/engines/saga/scene.cpp +++ b/engines/saga/scene.cpp @@ -579,7 +579,16 @@ void Scene::loadScene(LoadSceneParams *loadSceneParams) { _vm->_interface->setLeftPortrait(0); _vm->_anim->freeCutawayList(); - _vm->_script->freeModules(); + // FIXME: Freed script modules are not reloaded correctly when changing chapters. + // This is apparent when returning back to the character selection screen, + // where the scene script module is loaded incorrectly + // Don't free them for now, but free them on game exit, like ITE. + // This has no impact on the game itself (other than increased memory usage), + // as each chapter uses a different module slot + // TODO: Find out why the script modules are not loaded correctly when + // changing chapters and uncomment this again + //_vm->_script->freeModules(); + // deleteAllScenes(); // installSomeAlarm() -- cgit v1.2.3 From c596fba864c8f2d6c72f21da4df8bc3ebcbfd8eb Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 31 Jul 2007 15:40:08 +0000 Subject: sfPsychicProfileOff is not used, therefore disable it to prevent it from trying to clear the psychic profile again svn-id: r28359 --- engines/saga/sfuncs.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/saga/sfuncs.cpp b/engines/saga/sfuncs.cpp index 6cf1b35485..61d8caaaf0 100644 --- a/engines/saga/sfuncs.cpp +++ b/engines/saga/sfuncs.cpp @@ -1519,7 +1519,8 @@ void Script::sfPsychicProfile(SCRIPTFUNC_PARAMS) { void Script::sfPsychicProfileOff(SCRIPTFUNC_PARAMS) { thread->wait(kWaitTypePlacard); - _vm->_scene->clearPsychicProfile(); + // This is not used + //_vm->_scene->clearPsychicProfile(); } // Script function #50 (0x32) -- cgit v1.2.3 From ea251afbb7dcee4de2c6f99d223480841c89ed40 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Tue, 31 Jul 2007 17:05:45 +0000 Subject: Added the spanish version of Woodruff, provided by jvprat on #scummvm svn-id: r28360 --- engines/gob/detection.cpp | 65 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) (limited to 'engines') diff --git a/engines/gob/detection.cpp b/engines/gob/detection.cpp index 48b2a62dd4..b98a6755db 100644 --- a/engines/gob/detection.cpp +++ b/engines/gob/detection.cpp @@ -1233,6 +1233,71 @@ static const GOBGameDescription gameDescriptions[] = { kFeatures640, "intro" }, + { // Supplied by jvprat on #scummvm + { + "woodruff", + "", + AD_ENTRY1s("intro.stk", "270529d9b8cce770b1575908a3800b52", 20296452), + ES_ESP, + kPlatformPC, + Common::ADGF_NO_FLAGS + }, + kGameTypeWoodruff, + kFeatures640, + "intro" + }, + { // Supplied by jvprat on #scummvm + { + "woodruff", + "", + AD_ENTRY1s("intro.stk", "270529d9b8cce770b1575908a3800b52", 20296452), + EN_GRB, + kPlatformPC, + Common::ADGF_NO_FLAGS + }, + kGameTypeWoodruff, + kFeatures640, + "intro" + }, + { // Supplied by jvprat on #scummvm + { + "woodruff", + "", + AD_ENTRY1s("intro.stk", "270529d9b8cce770b1575908a3800b52", 20296452), + DE_DEU, + kPlatformPC, + Common::ADGF_NO_FLAGS + }, + kGameTypeWoodruff, + kFeatures640, + "intro" + }, + { // Supplied by jvprat on #scummvm + { + "woodruff", + "", + AD_ENTRY1s("intro.stk", "270529d9b8cce770b1575908a3800b52", 20296452), + FR_FRA, + kPlatformPC, + Common::ADGF_NO_FLAGS + }, + kGameTypeWoodruff, + kFeatures640, + "intro" + }, + { // Supplied by jvprat on #scummvm + { + "woodruff", + "", + AD_ENTRY1s("intro.stk", "270529d9b8cce770b1575908a3800b52", 20296452), + IT_ITA, + kPlatformPC, + Common::ADGF_NO_FLAGS + }, + kGameTypeWoodruff, + kFeatures640, + "intro" + }, /*{ { "dynasty", -- cgit v1.2.3 From 03d7990a341a5c05d2b23b073620159d3fe15a0f Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 31 Jul 2007 17:41:10 +0000 Subject: Some updates to the psychic profile in IHNM. sfPsychicProfileOff has been enabled again svn-id: r28361 --- engines/saga/interface.cpp | 10 +++++----- engines/saga/scene.cpp | 13 +++++++------ engines/saga/sfuncs.cpp | 5 +++-- 3 files changed, 15 insertions(+), 13 deletions(-) (limited to 'engines') diff --git a/engines/saga/interface.cpp b/engines/saga/interface.cpp index c7054436d9..941262e10e 100644 --- a/engines/saga/interface.cpp +++ b/engines/saga/interface.cpp @@ -369,18 +369,18 @@ int Interface::deactivate() { } void Interface::rememberMode() { - assert (_savedMode == -1); + debug(1, "rememberMode(%d)", _savedMode); _savedMode = _panelMode; - - debug(1, "rememberMode(%d)", _savedMode); } void Interface::restoreMode(bool draw_) { - assert (_savedMode != -1); - debug(1, "restoreMode(%d)", _savedMode); + // If _savedMode is -1 by a race condition, set it to kPanelMain + if (_savedMode == -1) + _savedMode = kPanelMain; + _panelMode = _savedMode; _savedMode = -1; diff --git a/engines/saga/scene.cpp b/engines/saga/scene.cpp index 6e51296bad..3c98421361 100644 --- a/engines/saga/scene.cpp +++ b/engines/saga/scene.cpp @@ -1361,12 +1361,13 @@ void Scene::clearPlacard() { } void Scene::clearPsychicProfile() { - _vm->_scene->clearPlacard(); - _vm->_actor->showActors(false); - _vm->_gfx->restorePalette(); - _vm->_scene->restoreScene(); - _vm->_interface->setMode(kPanelMain); - _vm->_interface->activate(); + if (_vm->_interface->getMode() == kPanelPlacard) { + _vm->_scene->clearPlacard(); + _vm->_actor->showActors(false); + _vm->_gfx->restorePalette(); + _vm->_scene->restoreScene(); + _vm->_interface->activate(); + } } void Scene::showIHNMDemoSpecialScreen() { diff --git a/engines/saga/sfuncs.cpp b/engines/saga/sfuncs.cpp index 61d8caaaf0..ef1ecd587f 100644 --- a/engines/saga/sfuncs.cpp +++ b/engines/saga/sfuncs.cpp @@ -1519,8 +1519,9 @@ void Script::sfPsychicProfile(SCRIPTFUNC_PARAMS) { void Script::sfPsychicProfileOff(SCRIPTFUNC_PARAMS) { thread->wait(kWaitTypePlacard); - // This is not used - //_vm->_scene->clearPsychicProfile(); + // This is called a while after the psychic profile is + // opened, to close it automatically + _vm->_scene->clearPsychicProfile(); } // Script function #50 (0x32) -- cgit v1.2.3 From cd20f09a9d8085d1082313fd1d58c87deeb30333 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 31 Jul 2007 18:08:40 +0000 Subject: Cleanup: removed dead code, fixed some comments and did some layout changes svn-id: r28362 --- engines/saga/actor.h | 5 ----- engines/saga/animation.cpp | 13 ++----------- engines/saga/animation.h | 2 +- engines/saga/detection_tables.h | 2 ++ engines/saga/displayinfo.h | 2 ++ engines/saga/font.cpp | 1 + engines/saga/gfx.cpp | 5 +---- engines/saga/image.cpp | 1 + engines/saga/isomap.cpp | 2 ++ engines/saga/ite_introproc.cpp | 1 - engines/saga/list.h | 2 ++ engines/saga/music.cpp | 3 +++ engines/saga/objectmap.cpp | 1 + engines/saga/puzzle.h | 2 ++ engines/saga/render.cpp | 1 + engines/saga/rscfile.cpp | 1 + engines/saga/saga.h | 2 +- engines/saga/saveload.cpp | 8 -------- engines/saga/sndres.cpp | 2 +- engines/saga/sprite.cpp | 1 + 20 files changed, 25 insertions(+), 32 deletions(-) (limited to 'engines') diff --git a/engines/saga/actor.h b/engines/saga/actor.h index 1d9675b4cf..ef62661c6c 100644 --- a/engines/saga/actor.h +++ b/engines/saga/actor.h @@ -614,11 +614,6 @@ public: void showActors(bool flag) { _showActors = flag; } - /* - uint16 _currentFrameIndex; - void frameTest() { - _currentFrameIndex++; - }*/ protected: friend class Script; bool loadActorResources(ActorData *actor); diff --git a/engines/saga/animation.cpp b/engines/saga/animation.cpp index a8fa7005d8..7b3bdcd665 100644 --- a/engines/saga/animation.cpp +++ b/engines/saga/animation.cpp @@ -24,6 +24,7 @@ */ // Background animation management module + #include "saga/saga.h" #include "saga/gfx.h" @@ -386,16 +387,6 @@ void Anim::load(uint16 animId, const byte *animResourceData, size_t animResource fillFrameOffsets(anim); - /* char s[200]; - sprintf(s, "d:\\anim%i",animId); - long flen=anim->resourceLength; - char *buf=(char*)anim->resourceData; - FILE*f; - f=fopen(s,"wb"); - for (long i = 0; i < flen; i++) - fputc(buf[i],f); - fclose(f);*/ - // Set animation data anim->currentFrame = 0; anim->completed = 0; @@ -661,7 +652,7 @@ void Anim::decodeFrame(AnimationData *anim, size_t frameOffset, byte *buf, size_ yStart = readS.readUint16BE(); else yStart = readS.readByte(); - readS.readByte(); /* Skip pad byte */ + readS.readByte(); // Skip pad byte /*xPos = */readS.readUint16BE(); /*yPos = */readS.readUint16BE(); /*width = */readS.readUint16BE(); diff --git a/engines/saga/animation.h b/engines/saga/animation.h index 2af57fb60f..f8cf90425f 100644 --- a/engines/saga/animation.h +++ b/engines/saga/animation.h @@ -209,4 +209,4 @@ private: } // End of namespace Saga -#endif /* ANIMATION_H_ */ +#endif // ANIMATION_H_ diff --git a/engines/saga/detection_tables.h b/engines/saga/detection_tables.h index 22e5ccdc50..832d7b34d4 100644 --- a/engines/saga/detection_tables.h +++ b/engines/saga/detection_tables.h @@ -23,6 +23,8 @@ * */ +// Game detection information and MD5s + namespace Saga { static const GameResourceDescription ITE_Resources = { diff --git a/engines/saga/displayinfo.h b/engines/saga/displayinfo.h index 3e1845abba..0d7bfaf554 100644 --- a/engines/saga/displayinfo.h +++ b/engines/saga/displayinfo.h @@ -23,6 +23,8 @@ * */ +// Interface widget display information + #ifndef SAGA_DISPLAYINFO_H #define SAGA_DISPLAYINFO_H diff --git a/engines/saga/font.cpp b/engines/saga/font.cpp index caf41ab43e..c38c9e2110 100644 --- a/engines/saga/font.cpp +++ b/engines/saga/font.cpp @@ -24,6 +24,7 @@ */ // Font management and font drawing module + #include "saga/saga.h" #include "saga/gfx.h" #include "saga/rscfile.h" diff --git a/engines/saga/gfx.cpp b/engines/saga/gfx.cpp index 8d36ee0e12..56ffe04c96 100644 --- a/engines/saga/gfx.cpp +++ b/engines/saga/gfx.cpp @@ -130,10 +130,7 @@ void Surface::drawPolyLine(const Point *points, int count, int color) { } } -/** -* Dissolve one image with another. -* If flags if set to 1, do zero masking. -*/ +// Dissolve one image with another. If flags is set to 1, do zero masking. void Surface::transitionDissolve(const byte *sourceBuffer, const Common::Rect &sourceRect, int flags, double percent) { #define XOR_MASK 0xB400; int pixelcount = w * h; diff --git a/engines/saga/image.cpp b/engines/saga/image.cpp index f76258c565..9f72036634 100644 --- a/engines/saga/image.cpp +++ b/engines/saga/image.cpp @@ -24,6 +24,7 @@ */ // SAGA Image resource management routines + #include "saga/saga.h" #include "saga/stream.h" diff --git a/engines/saga/isomap.cpp b/engines/saga/isomap.cpp index 124242204b..4f635c6e3b 100644 --- a/engines/saga/isomap.cpp +++ b/engines/saga/isomap.cpp @@ -24,6 +24,7 @@ */ // Isometric level module + #include "saga/saga.h" #include "saga/gfx.h" @@ -1609,6 +1610,7 @@ void IsoMap::findTilePath(ActorData* actor, const Location &start, const Locatio /* if (i > 64) { i = 64; }*/ + actor->_walkStepsCount = i; if (i) { actor->setTileDirectionsSize(i, false); diff --git a/engines/saga/ite_introproc.cpp b/engines/saga/ite_introproc.cpp index ec4d07c069..1664969644 100644 --- a/engines/saga/ite_introproc.cpp +++ b/engines/saga/ite_introproc.cpp @@ -23,7 +23,6 @@ * */ - // Intro sequence scene procedures #include "saga/saga.h" diff --git a/engines/saga/list.h b/engines/saga/list.h index 28159475c3..1363155f43 100644 --- a/engines/saga/list.h +++ b/engines/saga/list.h @@ -23,6 +23,8 @@ * */ +// List functions + #ifndef SAGA_LIST_H #define SAGA_LIST_H diff --git a/engines/saga/music.cpp b/engines/saga/music.cpp index 710485fc05..04e79c174d 100644 --- a/engines/saga/music.cpp +++ b/engines/saga/music.cpp @@ -22,6 +22,9 @@ * $Id$ * */ + +// MIDI and digital music class + #include "saga/saga.h" #include "saga/rscfile.h" diff --git a/engines/saga/objectmap.cpp b/engines/saga/objectmap.cpp index 52f2e89be7..9e633a6709 100644 --- a/engines/saga/objectmap.cpp +++ b/engines/saga/objectmap.cpp @@ -28,6 +28,7 @@ // Polygon Hit Test code ( HitTestPoly() ) adapted from code (C) Eric Haines // appearing in Graphics Gems IV, "Point in Polygon Strategies." // p. 24-46, code: p. 34-45 + #include "saga/saga.h" #include "saga/gfx.h" diff --git a/engines/saga/puzzle.h b/engines/saga/puzzle.h index 92bf73e2a0..3713cbaab7 100644 --- a/engines/saga/puzzle.h +++ b/engines/saga/puzzle.h @@ -23,6 +23,8 @@ * */ +// ITE puzzle scene + #ifndef SAGA_PUZZLE_H #define SAGA_PUZZLE_H diff --git a/engines/saga/render.cpp b/engines/saga/render.cpp index 16536f762e..930476b4e2 100644 --- a/engines/saga/render.cpp +++ b/engines/saga/render.cpp @@ -24,6 +24,7 @@ */ // Main rendering loop + #include "saga/saga.h" #include "saga/actor.h" diff --git a/engines/saga/rscfile.cpp b/engines/saga/rscfile.cpp index d308fcbe7e..3a60ae60e6 100644 --- a/engines/saga/rscfile.cpp +++ b/engines/saga/rscfile.cpp @@ -24,6 +24,7 @@ */ // RSC Resource file management module + #include "saga/saga.h" #include "saga/actor.h" diff --git a/engines/saga/saga.h b/engines/saga/saga.h index 220a563c14..43952fe564 100644 --- a/engines/saga/saga.h +++ b/engines/saga/saga.h @@ -551,7 +551,7 @@ public: Resource *_resource; - /** Random number generator */ + // Random number generator Common::RandomSource _rnd; private: diff --git a/engines/saga/saveload.cpp b/engines/saga/saveload.cpp index 48fcc16d4e..6f27e1b19b 100644 --- a/engines/saga/saveload.cpp +++ b/engines/saga/saveload.cpp @@ -154,14 +154,6 @@ void SagaEngine::fillSaveList() { } i++; } -/* 4debug - for (i = 0; i < 14; i++) { - sprintf(_saveFiles[i].name,"test%i", i); - _saveFiles[i].slotNumber = i; - } - _saveFilesCount = 14; - _saveFilesMaxCount = 14; - */ } diff --git a/engines/saga/sndres.cpp b/engines/saga/sndres.cpp index 9f783bd50d..3f1957b9c5 100644 --- a/engines/saga/sndres.cpp +++ b/engines/saga/sndres.cpp @@ -44,7 +44,7 @@ namespace Saga { SndRes::SndRes(SagaEngine *vm) : _vm(vm) { - /* Load sound module resource file contexts */ + // Load sound module resource file contexts _sfxContext = _vm->_resource->getContext(GAME_SOUNDFILE); if (_sfxContext == NULL) { error("SndRes::SndRes resource context not found"); diff --git a/engines/saga/sprite.cpp b/engines/saga/sprite.cpp index bbe73a48a0..1a70a44bbd 100644 --- a/engines/saga/sprite.cpp +++ b/engines/saga/sprite.cpp @@ -24,6 +24,7 @@ */ // Sprite management module + #include "saga/saga.h" #include "saga/gfx.h" -- cgit v1.2.3 From 2e9ca7bf85cdaf71f009c689a0aae6cd14e8f710 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Tue, 31 Jul 2007 18:16:33 +0000 Subject: Still partly broken/stubby VMD playing svn-id: r28363 --- engines/gob/coktelvideo.cpp | 497 +++++++++++++++++++++++++++++++++----------- engines/gob/coktelvideo.h | 90 ++++++-- engines/gob/dataio.cpp | 17 +- engines/gob/inter_v4.cpp | 4 +- engines/gob/videoplayer.cpp | 5 +- 5 files changed, 463 insertions(+), 150 deletions(-) (limited to 'engines') diff --git a/engines/gob/coktelvideo.cpp b/engines/gob/coktelvideo.cpp index e7eebe602a..0d59bf4993 100644 --- a/engines/gob/coktelvideo.cpp +++ b/engines/gob/coktelvideo.cpp @@ -58,13 +58,16 @@ bool Imd::load(Common::SeekableReadStream &stream) { // Rest header _features = _stream->readByte(); _framesCount = _stream->readUint16LE(); - _x = _stream->readUint16LE(); - _y = _stream->readUint16LE(); - _width = _stream->readUint16LE(); - _height = _stream->readUint16LE(); + _x = _stream->readSint16LE(); + _y = _stream->readSint16LE(); + _width = _stream->readSint16LE(); + _height = _stream->readSint16LE(); _flags = _stream->readUint16LE(); _firstFramePos = _stream->readUint16LE(); + // IMDs always have video + _features |= kFeaturesVideo; + // Palette _stream->read((byte *) _palette, 768); @@ -77,10 +80,10 @@ bool Imd::load(Common::SeekableReadStream &stream) { return false; } if (_stdX != 0) { - _stdX = _stream->readUint16LE(); - _stdY = _stream->readUint16LE(); - _stdWidth = _stream->readUint16LE(); - _stdHeight = _stream->readUint16LE(); + _stdX = _stream->readSint16LE(); + _stdY = _stream->readSint16LE(); + _stdWidth = _stream->readSint16LE(); + _stdHeight = _stream->readSint16LE(); _features |= kFeaturesStdCoords; } else _stdX = -1; @@ -92,7 +95,7 @@ bool Imd::load(Common::SeekableReadStream &stream) { if (_version >= 4) { framesPosPos = _stream->readUint32LE(); if (framesPosPos != 0) { - _framesPos = new int32[_framesCount]; + _framesPos = new uint32[_framesCount]; assert(_framesPos); _features |= kFeaturesFramesPos; } @@ -105,9 +108,9 @@ bool Imd::load(Common::SeekableReadStream &stream) { // Sound if (_features & kFeaturesSound) { - _soundFreq = _stream->readUint16LE(); + _soundFreq = _stream->readSint16LE(); _soundSliceSize = _stream->readUint16LE(); - _soundSlicesCount = _stream->readUint16LE(); + _soundSlicesCount = _stream->readSint16LE(); if (_soundFreq < 0) _soundFreq = -_soundFreq; @@ -158,10 +161,10 @@ bool Imd::load(Common::SeekableReadStream &stream) { _frameCoords = new Coord[_framesCount]; assert(_frameCoords); for (int i = 0; i < _framesCount; i++) { - _frameCoords[i].left = _stream->readUint16LE(); - _frameCoords[i].top = _stream->readUint16LE(); - _frameCoords[i].right = _stream->readUint16LE(); - _frameCoords[i].bottom = _stream->readUint16LE(); + _frameCoords[i].left = _stream->readSint16LE(); + _frameCoords[i].top = _stream->readSint16LE(); + _frameCoords[i].right = _stream->readSint16LE(); + _frameCoords[i].bottom = _stream->readSint16LE(); } } @@ -186,9 +189,9 @@ void Imd::unload() { void Imd::setXY(int16 x, int16 y) { // Adjusting the standard coordinates if (_stdX != -1) { - if (x != -1) + if (x >= 0) _stdX = _stdX - _x + x; - if (y != -1) + if (y >= 0) _stdY = _stdY - _y + y; } @@ -196,11 +199,11 @@ void Imd::setXY(int16 x, int16 y) { if (_frameCoords) { for (int i = 0; i < _framesCount; i++) { if (_frameCoords[i].left != -1) { - if (x != -1) { + if (x >= 0) { _frameCoords[i].left = _frameCoords[i].left - _x + x; _frameCoords[i].right = _frameCoords[i].right - _x + x; } - if (y != -1) { + if (y >= 0) { _frameCoords[i].top = _frameCoords[i].top - _y + y; _frameCoords[i].bottom = _frameCoords[i].bottom - _y + y; } @@ -208,9 +211,9 @@ void Imd::setXY(int16 x, int16 y) { } } - if (x != -1) + if (x >= 0) _x = x; - if (y != -1) + if (y >= 0) _y = y; } @@ -259,7 +262,7 @@ void Imd::disableSound() { _mixer = 0; } -void Imd::seekFrame(int16 frame, int16 whence, bool restart) { +void Imd::seekFrame(int32 frame, int16 whence, bool restart) { if (!_stream) // Nothing to do return; @@ -272,7 +275,7 @@ void Imd::seekFrame(int16 frame, int16 whence, bool restart) { else if (whence != SEEK_SET) return; - if ((frame >= _framesCount) || (frame == _curFrame)) + if ((frame < 0) || (frame >= _framesCount) || (frame == _curFrame)) // Nothing to do return; @@ -293,7 +296,7 @@ void Imd::seekFrame(int16 frame, int16 whence, bool restart) { error("Frame %d is not directly accessible", frame); // Seek - _stream->seek(framePos, SEEK_SET); + _stream->seek(framePos); _curFrame = frame; } @@ -426,7 +429,7 @@ void Imd::clear(bool del) { _lastFrameTime = 0; } -CoktelVideo::State Imd::processFrame(int16 frame) { +CoktelVideo::State Imd::processFrame(uint16 frame) { State state; uint32 cmd = 0; int16 xBak, yBak, heightBak, widthBak; @@ -440,7 +443,7 @@ CoktelVideo::State Imd::processFrame(int16 frame) { if (frame != _curFrame) { state.flags |= kStateSeeked; - seekFrame(frame, SEEK_SET); + seekFrame(frame); } state.left = xBak = _x; @@ -559,7 +562,7 @@ CoktelVideo::State Imd::processFrame(int16 frame) { // Jump to frame if (cmd == 0xFFFD) { - frame = _stream->readUint16LE(); + frame = _stream->readSint16LE(); if (_framesPos) { _curFrame = frame; _stream->seek(_framesPos[frame], SEEK_SET); @@ -612,7 +615,7 @@ CoktelVideo::State Imd::processFrame(int16 frame) { state.flags |= _frameData[0]; } else - state.flags |= kStateNoData; + state.flags |= kStateNoVideoData; } while (hasNextCmd); @@ -640,95 +643,6 @@ CoktelVideo::State Imd::processFrame(int16 frame) { return state; } -CoktelVideo::State Imd::peekFrame(int16 frame) { - State state; - uint32 posBak; - uint32 tmp; - uint16 cmd; - int16 frameBak; - - if (!_stream) { - state.flags = kStateBreak; - return state; - } - - posBak = _stream->pos(); - frameBak = _curFrame; - - if (_curFrame != frame) { - state.flags |= kStateSeeked; - seekFrame(frame, SEEK_SET); - } - - do { - if (frame != 0) { - if (_stdX != -1) - state.flags |= kStateStdCoords; - if (_frameCoords && (_frameCoords[frame].left != -1)) - state.flags |= kStateFrameCoords; - } - - cmd = _stream->readUint16LE(); - - if ((cmd & 0xFFF8) == 0xFFF0) { - if (cmd == 0xFFF0) { - _stream->seek(2, SEEK_CUR); - cmd = _stream->readUint16LE(); - } - - if (cmd == 0xFFF1) { - state.flags = kStateBreak; - continue; - } else if (cmd == 0xFFF2) { // Skip (16 bit) - cmd = _stream->readUint16LE(); - _stream->seek(cmd, SEEK_CUR); - state.flags = kStateBreak; - continue; - } else if (cmd == 0xFFF3) { // Skip (32 bit) - tmp = _stream->readUint32LE(); - _stream->seek(cmd, SEEK_CUR); - state.flags = kStateBreak; - continue; - } - } - - // Jump to frame - if (cmd == 0xFFFD) { - frame = _stream->readUint16LE(); - if (_framesPos) { - _stream->seek(_framesPos[frame], SEEK_SET); - state.flags |= kStateJump; - continue; - } - break; - } - - // Next sound slice data - if (cmd == 0xFF00) { - _stream->seek(_soundSliceSize, SEEK_CUR); - cmd = _stream->readUint16LE(); - // Initial sound data (all slices) - } else if (cmd == 0xFF01) { - _stream->seek(_soundSliceSize * _soundSlicesCount, SEEK_CUR); - cmd = _stream->readUint16LE(); - } - - // Frame video data - if (cmd != 0) { - _stream->read(_frameData, 5); - state.flags |= _frameData[0]; - } else - state.flags |= kStateNoData; - - break; - - } while (true); - - _stream->seek(posBak, SEEK_SET); - _curFrame = frameBak; - return state; -} - uint32 Imd::renderFrame() { if (!_frameData || (_width <= 0) || (_height <= 0)) return 0; @@ -763,10 +677,10 @@ uint32 Imd::renderFrame() { srcPtr = _vidBuffer; type &= 0x7F; if ((type == 2) && (imdW == sW)) { - frameUncompressor(imdVidMem, dataPtr); + deLZ77(imdVidMem, dataPtr); return retVal; } else - frameUncompressor(srcPtr, dataPtr); + deLZ77(srcPtr, dataPtr); } uint16 pixCount, pixWritten; @@ -845,7 +759,7 @@ uint32 Imd::renderFrame() { return retVal; } -void Imd::frameUncompressor(byte *dest, byte *src) { +void Imd::deLZ77(byte *dest, byte *src) { int i; byte buf[4370]; uint16 chunkLength; @@ -857,7 +771,7 @@ void Imd::frameUncompressor(byte *dest, byte *src) { uint8 chunkCount; bool mode; - frameLength = READ_LE_UINT16(src); + frameLength = READ_LE_UINT32(src); src += 4; if ((READ_LE_UINT16(src) == 0x1234) && (READ_LE_UINT16(src + 2) == 0x5678)) { @@ -932,4 +846,345 @@ void Imd::frameUncompressor(byte *dest, byte *src) { } } +Vmd::Vmd() { + clear(false); +} + +Vmd::~Vmd() { + clear(); +} + +bool Vmd::load(Common::SeekableReadStream &stream) { + unload(); + + _stream = &stream; + + uint16 headerLength = _stream->readUint16LE(); + uint16 handle = _stream->readUint16LE(); + _version = _stream->readUint16LE(); + + // Version checking + if ((headerLength != 814) || (handle != 0) || (_version != 1)) { + warning("IMD Version incorrect (%d, %d, %d)", headerLength, handle, _version); + unload(); + return false; + } + + _framesCount = _stream->readUint16LE(); + + warning("# of frames: %d", _framesCount); + + _x = _stream->readSint16LE(); + _y = _stream->readSint16LE(); + _width = _stream->readSint16LE(); + _height = _stream->readSint16LE(); + if ((_width != 0) && (_height != 0)) { + _hasVideo = true; + _features |= kFeaturesVideo; + + warning("%dx%d+%d+%d", _width, _height, _x, _y); + + } else + _hasVideo = false; + + _flags = _stream->readUint16LE(); + _partsPerFrame = _stream->readUint16LE(); + _firstFramePos = _stream->readUint32LE(); + uint32 unknown1 = _stream->readUint32LE(); + + warning("flags: %d (0x%X), #parts: %d, firstFramePos: %d, U1: %d (0x%X)", + _flags, _flags, _partsPerFrame, _firstFramePos, unknown1, unknown1); + + _stream->read((byte *) _palette, 768); + + _frameDataSize = _stream->readUint32LE(); + _vidBufferSize = _stream->readUint32LE(); + + if (_hasVideo) { + if (_frameDataSize == 0) + _frameDataSize = _width * _height + 500; + if (_vidBufferSize) + _vidBufferSize = _frameDataSize; + + _frameData = new byte[_frameDataSize]; + assert(_frameData); + memset(_frameData, 0, _frameDataSize); + _vidBuffer = new byte[_vidBufferSize]; + assert(_vidBuffer); + memset(_vidBuffer, 0, _vidBufferSize); + warning("Sizes: frameData: %d, vidBuffer: %d", _frameDataSize, _vidBufferSize); + } + + _soundFreq = _stream->readSint16LE(); + _soundSliceSize = _stream->readUint16LE(); + _soundSlicesCount = _stream->readSint16LE(); + uint16 soundFlags = _stream->readUint16LE(); + _hasSound = (_soundFreq != 0); + + if (_hasSound) { + _features |= kFeaturesSound; + + _soundSliceLength = 1000 / (_soundFreq / _soundSliceSize); + _frameLength = _soundSliceLength; + + _soundStage = 1; + + _audioStream = Audio::makeAppendableAudioStream(_soundFreq, 0); + + warning("Sound: Freq: %d, # slices %d, slideSize: %d, flags: %d (0x%X), sliceLen = %d", + _soundFreq, _soundSlicesCount, _soundSliceSize, soundFlags, soundFlags, _soundSliceLength); + + } else + _frameLength = 1000 / 12; // 12 FPS for a video without sound + + uint32 frameInfoOffset = _stream->readUint32LE(); + + warning("frameInfoOffset: %d", frameInfoOffset); + + _stream->seek(frameInfoOffset); + _frames = new Frame[_framesCount]; + for (uint16 i = 0; i < _framesCount; i++) { + _frames[i].parts = new Part[_partsPerFrame]; + _stream->skip(2); + _frames[i].offset = _stream->readUint32LE(); + } + for (uint16 i = 0; i < _framesCount; i++) { + for (uint16 j = 0; j < _partsPerFrame; j++) { + _frames[i].parts[j].type = (PartType) _stream->readByte(); + uint16 Unknown3 = _stream->readByte(); + _frames[i].parts[j].size = _stream->readUint32LE(); + if (_frames[i].parts[j].type == kPartTypeAudio) { + _frames[i].parts[j].flags = _stream->readByte(); + _stream->skip(9); + warning("%d.%d (%d): Audio: %d (0x%X), %d (0x%X)", + i, j, _frames[i].parts[j].size, + Unknown3, Unknown3, _frames[i].parts[j].flags, _frames[i].parts[j].flags); + + } else if (_frames[i].parts[j].type == kPartTypeVideo) { + _frames[i].parts[j].left = _stream->readUint16LE(); + _frames[i].parts[j].top = _stream->readUint16LE(); + _frames[i].parts[j].right = _stream->readUint16LE(); + _frames[i].parts[j].bottom = _stream->readUint16LE(); + uint16 Unknown4 = _stream->readByte(); + _frames[i].parts[j].flags = _stream->readByte(); + warning("%d.%d (%d): Video: %d (0x%X), %d+%d+%d+%d, %d (0x%X), %d (0x%X)", + i, j, _frames[i].parts[j].size, + Unknown3, Unknown3, _frames[i].parts[j].left, + _frames[i].parts[j].top, _frames[i].parts[j].right, + _frames[i].parts[j].bottom, Unknown4, Unknown4, + _frames[i].parts[j].flags, _frames[i].parts[j].flags); + + } else { + warning("VMD: Unknown frame part type found (%d.%d: %d, %d)", + i, j, _frames[i].parts[j].type, _frames[i].parts[j].size); + _stream->skip(10); +// unload(); +// return false; + } + } + } + + return true; +} + +void Vmd::unload() { + clear(); +} + +void Vmd::setXY(int16 x, int16 y) { + + for (int i = 0; i < _framesCount; i++) { + for (int j = 0; j < _partsPerFrame; j++) { + + if (_frames[i].parts[j].type == kPartTypeVideo) { + if (x >= 0) { + _frames[i].parts[j].left = _frames[i].parts[j].left - _x + x; + _frames[i].parts[j].right = _frames[i].parts[j].right - _x + x; + } + if (y >= 0) { + _frames[i].parts[j].top = _frames[i].parts[j].top - _y + y; + _frames[i].parts[j].bottom = _frames[i].parts[j].bottom - _y + y; + } + } + + } + } + + if (x >= 0) + _x = x; + if (y >= 0) + _y = y; +} + +void Vmd::seekFrame(int32 frame, int16 whence, bool restart) { + if (!_stream) + // Nothing to do + return; + + // Find the frame to which to seek + if (whence == SEEK_CUR) + frame += _curFrame; + else if (whence == SEEK_END) + frame = _framesCount - frame - 1; + else if (whence != SEEK_SET) + return; + + if ((frame < 0) || (frame >= _framesCount)) + // Nothing to do + return; + + // Seek + _stream->seek(_frames[frame].offset); + _curFrame = frame; +} + +CoktelVideo::State Vmd::nextFrame() { + State state; + + state = processFrame(_curFrame); + _curFrame++; + return state; +} + +void Vmd::clear(bool del) { + Imd::clear(del); + + if (del) { + delete[] _frames; + } + + _hasVideo = true; + _partsPerFrame = 0; + _frames = 0; +} + +CoktelVideo::State Vmd::processFrame(uint16 frame) { + State state; + int16 xBak, yBak, heightBak, widthBak; + bool startSound = false; + + seekFrame(frame); + + state.flags |= kStateNoVideoData; + state.left = -1; + + for (uint16 i = 0; i < _partsPerFrame; i++) { + Part &part = _frames[frame].parts[i]; + + if (part.type == kPartTypeAudio) { + byte *soundBuf; + + // Next sound slice data + if (part.flags == 1) { + + if (_soundEnabled) { + soundBuf = new byte[part.size]; + assert(soundBuf); + + _stream->read(soundBuf, part.size); + unsignedToSigned(soundBuf, part.size); + + _audioStream->queueBuffer(soundBuf, part.size); + } else + _stream->skip(part.size); + + // Initial sound data (all slices) + } else if (part.flags == 2) { + + if (_soundEnabled) { + uint32 U = _stream->readUint32LE(); + + warning("Mask? %d (0x%X)", U, U); + + soundBuf = new byte[part.size - 4]; + assert(soundBuf); + + _stream->read(soundBuf, part.size - 4); + unsignedToSigned(soundBuf, part.size - 4); + + _audioStream->queueBuffer(soundBuf, part.size - 4); + + if (_soundStage == 1) { + startSound = true; + } + + } else + _stream->skip(part.size); + + // Empty sound slice + } else if (part.flags == 3) { + + if (_soundEnabled && (part.size > 0)) { + soundBuf = new byte[part.size]; + assert(soundBuf); + + memset(soundBuf, 0, part.size); + + _audioStream->queueBuffer(soundBuf, part.size); + } else + _stream->skip(part.size); + } + + } else if (part.type == kPartTypeVideo) { + state.flags &= ~kStateNoVideoData; + + if (state.left == -1) { + state.left = _x = part.left; + state.top = _y = part.top; + state.right = _width = part.right; + state.bottom = _height = part.bottom; + _width -= _x - 1; + _height -= _y - 1; + } else { + _x = part.left; + _y = part.top; + _width = part.right - (_x - 1); + _height = part.bottom - (_y - 1); + state.left = MIN(state.left, part.left); + state.top = MIN(state.top, part.top); + state.right = MAX(state.right, part.right); + state.bottom = MAX(state.bottom, part.bottom); + } + + if (part.flags & 2) { + uint8 index = _stream->readByte(); + uint8 count = _stream->readByte(); + + _stream->read(_palette + index * 3, count + 1); + _stream->skip((255 - count) * 3); + + state.flags |= kStatePalette; + } + + _stream->read(_frameData, part.size); + state.flags |= renderFrame(); + } else { + warning("Unknown frame part type %d, size %d (%d of %d)", part.type, part.size, i + 1, _partsPerFrame); + _stream->skip(part.size); + } + } + + if (startSound && _soundEnabled) { + _mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_audioHandle, _audioStream); + _soundStartTime = g_system->getMillis(); + _skipFrames = 0; + _soundStage = 2; + } + + _x = xBak; + _y = yBak; + _width = widthBak; + _height = heightBak; + + if ((_curFrame == (_framesCount - 1)) && (_soundStage == 2)) { + _audioStream->finish(); + _mixer->stopHandle(_audioHandle); + _audioStream = 0; + _soundStage = 0; + } + + _lastFrameTime = g_system->getMillis(); + return state; +} + } // End of namespace Gob diff --git a/engines/gob/coktelvideo.h b/engines/gob/coktelvideo.h index 5788d024af..678fde3967 100644 --- a/engines/gob/coktelvideo.h +++ b/engines/gob/coktelvideo.h @@ -48,7 +48,9 @@ public: /** Has general standard coordinates. */ kFeaturesStdCoords = 0x100, /** Has a frame positions table. */ - kFeaturesFramesPos = 0x200 + kFeaturesFramesPos = 0x200, + /** Has video. */ + kFeaturesVideo = 0x400 }; enum StateFlags { @@ -60,7 +62,7 @@ public: /** Updated according to the specific frame coordinates. */ kStateFrameCoords = 0x400, /** Got no frame data. */ - kStateNoData = 0x800, + kStateNoVideoData = 0x800, /** Updated according to the general standard coordinates. */ kStateStdCoords = 0x1000, /** Had to explicitely seek to the frame. */ @@ -80,6 +82,8 @@ public: int16 bottom; /** Set accordingly to what was done. */ uint32 flags; + + State() : left(0), top(0), right(0), bottom(0), flags(0) { } }; virtual ~CoktelVideo() { } @@ -95,9 +99,13 @@ public: /** Returns the height of the video. */ virtual int16 getHeight() const = 0; /** Returns the number of frames the loaded video has. */ - virtual int16 getFramesCount() const = 0; - /** Returns the current frame number. */ - virtual int16 getCurrentFrame() const = 0; + virtual uint16 getFramesCount() const = 0; + /** Returns the current frame number. + * + * This is the current frame after the last nextFrame()-call, + * i.e. it's 0 after loading, 1 after the first nextFrame()-call, etc.. + */ + virtual uint16 getCurrentFrame() const = 0; /** Returns the frame rate. */ virtual int16 getFrameRate() const = 0; /** Returns the number of frames the video lags behind the audio. */ @@ -128,12 +136,10 @@ public: * @param whence The offset from whence the frame is given. * @param restart Restart the video to reach an otherwise inaccessible frame? */ - virtual void seekFrame(int16 frame, int16 whence = SEEK_SET, bool restart = false) = 0; + virtual void seekFrame(int32 frame, int16 whence = SEEK_SET, bool restart = false) = 0; /** Render the next frame. */ virtual State nextFrame() = 0; - /** Look at what a frame would do/have, without actually rendering the frame. */ - virtual State peekFrame(int16 frame) = 0; /** Wait for the frame to end. */ virtual void waitEndFrame() = 0; @@ -160,8 +166,8 @@ public: int16 getY() const { return _y; } int16 getWidth() const { return _width; } int16 getHeight() const { return _height; } - int16 getFramesCount() const { return _framesCount; } - int16 getCurrentFrame() const { return _curFrame; } + uint16 getFramesCount() const { return _framesCount; } + uint16 getCurrentFrame() const { return _curFrame; } int16 getFrameRate() const { if (_hasSound) return 1000 / _soundSliceLength; return 12; } uint32 getSyncLag() const { return _skipFrames; } const byte *getPalette() const { return _palette; } @@ -176,10 +182,9 @@ public: void enableSound(Audio::Mixer &mixer); void disableSound(); - void seekFrame(int16 frame, int16 whence = SEEK_SET, bool restart = false); + void seekFrame(int32 frame, int16 whence = SEEK_SET, bool restart = false); State nextFrame(); - State peekFrame(int16 frame); void waitEndFrame(); void copyCurrentFrame(byte *dest, uint16 x, uint16 y, uint16 width, int16 transp = -1); @@ -193,17 +198,17 @@ protected: } PACKED_STRUCT; Common::SeekableReadStream *_stream; - uint8 _version; + uint16 _version; uint16 _features; - int16 _flags; + uint16 _flags; int16 _x, _y, _width, _height; int16 _stdX, _stdY, _stdWidth, _stdHeight; - int16 _framesCount, _curFrame; - int32 *_framesPos; - int32 _firstFramePos; + uint16 _framesCount, _curFrame; + uint32 *_framesPos; + uint32 _firstFramePos; Coord *_frameCoords; - int32 _frameDataSize, _vidBufferSize; + uint32 _frameDataSize, _vidBufferSize; byte *_frameData, *_vidBuffer; byte _palette[768]; @@ -238,9 +243,54 @@ protected: void deleteVidMem(bool del = true); void clear(bool del = true); - State processFrame(int16 frame); + State processFrame(uint16 frame); uint32 renderFrame(); - void frameUncompressor(byte *dest, byte *src); + void deLZ77(byte *dest, byte *src); +}; + +class Vmd : public Imd { +public: + Vmd(); + ~Vmd(); + + bool load(Common::SeekableReadStream &stream); + void unload(); + + void setXY(int16 x, int16 y); + + void seekFrame(int32 frame, int16 whence = SEEK_SET, bool restart = false); + + State nextFrame(); + +protected: + enum PartType { + kPartTypeAudio = 1, + kPartTypeVideo = 2 + }; + struct Part { + PartType type; + uint32 size; + int16 left; + int16 top; + int16 right; + int16 bottom; + byte flags; + } PACKED_STRUCT; + struct Frame { + uint32 offset; + Part *parts; + + Frame() : parts(0) { } + ~Frame() { delete[] parts; } + } PACKED_STRUCT; + + bool _hasVideo; + uint16 _partsPerFrame; + Frame *_frames; + + void clear(bool del = true); + + State processFrame(uint16 frame); }; } // End of namespace Gob diff --git a/engines/gob/dataio.cpp b/engines/gob/dataio.cpp index 3c5dbed575..361627caf4 100644 --- a/engines/gob/dataio.cpp +++ b/engines/gob/dataio.cpp @@ -103,11 +103,20 @@ uint32 DataStream::read(void *dataPtr, uint32 dataSize) { if (_stream) return _stream->read(dataPtr, dataSize); - int32 res = _io->readChunk(_handle, (byte *) dataPtr, dataSize); - if (res >= 0) - return res; + if ((_handle < 50) || (_handle >= 128)) + return _io->file_getHandle(_handle)->read((byte *) dataPtr, dataSize); + + byte *data = (byte *) dataPtr; + uint32 haveRead = 0; + while (dataSize > 0x3FFF) { + _io->readChunk(_handle, (byte *) data, 0x3FFF); + dataSize -= 0x3FFF; + data += 0x3FFF; + haveRead += 0x3FFF; + } + _io->readChunk(_handle, (byte *) data, dataSize); - return _io->file_getHandle(_handle)->read((byte *) dataPtr, dataSize); + return haveRead + dataSize; } DataIO::DataIO(GobEngine *vm) : _vm(vm) { diff --git a/engines/gob/inter_v4.cpp b/engines/gob/inter_v4.cpp index 1297b03fbf..81f53757a3 100644 --- a/engines/gob/inter_v4.cpp +++ b/engines/gob/inter_v4.cpp @@ -742,12 +742,12 @@ void Inter_v4::o4_playVmdOrMusic() { close = true; } else if (lastFrame == -3) { warning("Woodruff Stub: Video/Music command -3: Play background video %s", fileName); - return; +// return; } else if (lastFrame == -4) { warning("Woodruff Stub: Video/Music command -4: Play background video %s", fileName); return; } else if (lastFrame == -5) { - warning("Woodruff Stub: Video/Music command -5"); + warning("Woodruff Stub: Video/Music command -5: Stop background music"); return; } else if (lastFrame == -6) { warning("Woodruff Stub: Video/Music command -6: Load background video %s", fileName); diff --git a/engines/gob/videoplayer.cpp b/engines/gob/videoplayer.cpp index d048b6084d..e72354a169 100644 --- a/engines/gob/videoplayer.cpp +++ b/engines/gob/videoplayer.cpp @@ -119,9 +119,7 @@ bool VideoPlayer::openVideo(const char *video, int16 x, int16 y, int16 flags, Ty if (which == kVideoTypeIMD) { _video = new Imd(); } else if (which == kVideoTypeVMD) { - warning("STUB: %s", fileName); - closeVideo(); - return false; + _video = new Vmd(); } else { warning("Couldn't open video \"%s\": Invalid video Type", fileName); closeVideo(); @@ -161,6 +159,7 @@ void VideoPlayer::play(int16 startFrame, int16 lastFrame, int16 breakKey, if (!_video) return; + breakKey = 27; if (startFrame < 0) startFrame = _video->getCurrentFrame(); if (lastFrame < 0) -- cgit v1.2.3 From 806995ddd020548cc9cf9d144c430664008841ab Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 31 Jul 2007 18:26:14 +0000 Subject: Fixed some warnings svn-id: r28364 --- engines/gob/coktelvideo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/gob/coktelvideo.cpp b/engines/gob/coktelvideo.cpp index 0d59bf4993..bb50ddf04a 100644 --- a/engines/gob/coktelvideo.cpp +++ b/engines/gob/coktelvideo.cpp @@ -1060,7 +1060,7 @@ void Vmd::clear(bool del) { CoktelVideo::State Vmd::processFrame(uint16 frame) { State state; - int16 xBak, yBak, heightBak, widthBak; + int16 xBak = 0, yBak = 0, heightBak = 0, widthBak = 0; bool startSound = false; seekFrame(frame); -- cgit v1.2.3 From bd22db45025abe9449f9d7a05f36fd8b268fbb5c Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Tue, 31 Jul 2007 19:12:44 +0000 Subject: Renamed palette functions. svn-id: r28365 --- engines/parallaction/callables_ns.cpp | 4 ++-- engines/parallaction/graphics.cpp | 6 +++--- engines/parallaction/graphics.h | 6 +++--- engines/parallaction/location.cpp | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) (limited to 'engines') diff --git a/engines/parallaction/callables_ns.cpp b/engines/parallaction/callables_ns.cpp index b124ba864a..9b3972723f 100644 --- a/engines/parallaction/callables_ns.cpp +++ b/engines/parallaction/callables_ns.cpp @@ -205,7 +205,7 @@ void Parallaction_ns::_c_fade(void *parm) { memset(pal, 0, sizeof(Gfx::Palette)); for (uint16 _di = 0; _di < 64; _di++) { - _gfx->fadePalette(pal); + _gfx->fadeInPalette(pal); _gfx->setPalette(pal); g_system->delayMillis(20); @@ -341,7 +341,7 @@ void Parallaction_ns::_c_endComment(void *param) { byte* _enginePal = _gfx->_palette; Gfx::Palette pal; - _gfx->buildBWPalette(pal); + _gfx->makeGrayscalePalette(pal); int16 w = 0, h = 0; _gfx->getStringExtent(_location._endComment, 130, &w, &h); diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp index 04f2ef1040..948f2a7b34 100644 --- a/engines/parallaction/graphics.cpp +++ b/engines/parallaction/graphics.cpp @@ -203,14 +203,14 @@ void Gfx::animatePalette() { return; } -void Gfx::fadePalette(Palette pal) { +void Gfx::fadeInPalette(Palette pal) { for (uint16 i = 0; i < BASE_PALETTE_COLORS * 3; i++) if (pal[i] < _palette[i]) pal[i]++; return; } -void Gfx::buildBWPalette(Palette pal) { +void Gfx::makeGrayscalePalette(Palette pal) { for (uint16 i = 0; i < BASE_PALETTE_COLORS; i++) { byte max; @@ -226,7 +226,7 @@ void Gfx::buildBWPalette(Palette pal) { return; } -void Gfx::quickFadePalette(Palette pal) { +void Gfx::fadePalette(Palette pal) { for (uint16 i = 0; i < BASE_PALETTE_COLORS * 3; i++) { if (pal[i] == _palette[i]) continue; diff --git a/engines/parallaction/graphics.h b/engines/parallaction/graphics.h index 6f0f7996d3..11589b22cd 100644 --- a/engines/parallaction/graphics.h +++ b/engines/parallaction/graphics.h @@ -209,9 +209,9 @@ public: void setPalette(Palette palette, uint32 first = FIRST_BASE_COLOR, uint32 num = BASE_PALETTE_COLORS); void setBlackPalette(); void animatePalette(); - void fadePalette(Palette palette); - void buildBWPalette(Palette palette); - void quickFadePalette(Palette palette); + void fadeInPalette(Palette palette); // fades palette (from black) to system palette + void fadePalette(Palette palette); // fades palette to system palette + void makeGrayscalePalette(Palette palette); // transform palette into black and white // amiga specific void setHalfbriteMode(bool enable); diff --git a/engines/parallaction/location.cpp b/engines/parallaction/location.cpp index 34d2dd6a18..e689a8e82d 100644 --- a/engines/parallaction/location.cpp +++ b/engines/parallaction/location.cpp @@ -424,7 +424,7 @@ void Parallaction::doLocationEnterTransition() { } byte pal[PALETTE_SIZE]; - _gfx->buildBWPalette(pal); + _gfx->makeGrayscalePalette(pal); _gfx->setPalette(pal); jobRunScripts(NULL, NULL); @@ -452,7 +452,7 @@ void Parallaction::doLocationEnterTransition() { // fades maximum intensity palette towards approximation of main palette for (uint16 _si = 0; _si<6; _si++) { - _gfx->quickFadePalette(pal); + _gfx->fadePalette(pal); _gfx->setPalette(pal); waitTime( 1 ); _gfx->updateScreen(); -- cgit v1.2.3 From 873a3e24e578eb2b32627352c69ecd4f05add677 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Tue, 31 Jul 2007 19:18:41 +0000 Subject: Added an English Bargon Attack Amiga/AtariST version, as provided by pwigren in bug #1764174 svn-id: r28366 --- engines/gob/detection.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'engines') diff --git a/engines/gob/detection.cpp b/engines/gob/detection.cpp index b98a6755db..4286e10b6d 100644 --- a/engines/gob/detection.cpp +++ b/engines/gob/detection.cpp @@ -800,6 +800,19 @@ static const GOBGameDescription gameDescriptions[] = { kFeaturesNone, "intro" }, + { // Supplied by pwigren in bugreport #1764174 + { + "bargon", + "", + AD_ENTRY1s("intro.stk", "569d679fe41d49972d34c9fce5930dda", 269825), + EN_ANY, + kPlatformAmiga, + Common::ADGF_NO_FLAGS + }, + kGameTypeBargon, + kFeaturesNone, + "intro" + }, { // Supplied by glorfindel in bugreport #1722142 { "bargon", -- cgit v1.2.3 From b29935e93c9ffddf8c510c0f192e9aafd522ea2d Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Tue, 31 Jul 2007 19:25:07 +0000 Subject: Generalized fadePalette to support custom target palette. svn-id: r28367 --- engines/parallaction/graphics.cpp | 14 +++++++++++--- engines/parallaction/graphics.h | 2 +- engines/parallaction/location.cpp | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) (limited to 'engines') diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp index 948f2a7b34..27e2de939d 100644 --- a/engines/parallaction/graphics.cpp +++ b/engines/parallaction/graphics.cpp @@ -226,11 +226,19 @@ void Gfx::makeGrayscalePalette(Palette pal) { return; } -void Gfx::fadePalette(Palette pal) { +void Gfx::fadePalette(Palette pal, Palette target, uint step) { + + if (step == 0) + return; for (uint16 i = 0; i < BASE_PALETTE_COLORS * 3; i++) { - if (pal[i] == _palette[i]) continue; - pal[i] += (pal[i] < _palette[i] ? 4 : -4); + if (pal[i] == target[i]) continue; + + if (pal[i] < target[i]) + pal[i] = CLIP(pal[i] + step, (uint)0, (uint)target[i]); + else + pal[i] = CLIP(pal[i] - step, (uint)target[i], (uint)255); + } return; diff --git a/engines/parallaction/graphics.h b/engines/parallaction/graphics.h index 11589b22cd..b7013d125e 100644 --- a/engines/parallaction/graphics.h +++ b/engines/parallaction/graphics.h @@ -210,7 +210,7 @@ public: void setBlackPalette(); void animatePalette(); void fadeInPalette(Palette palette); // fades palette (from black) to system palette - void fadePalette(Palette palette); // fades palette to system palette + void fadePalette(Palette palette, Palette target, uint step); // fades palette to target palette, with specified step void makeGrayscalePalette(Palette palette); // transform palette into black and white // amiga specific diff --git a/engines/parallaction/location.cpp b/engines/parallaction/location.cpp index e689a8e82d..024938074b 100644 --- a/engines/parallaction/location.cpp +++ b/engines/parallaction/location.cpp @@ -452,7 +452,7 @@ void Parallaction::doLocationEnterTransition() { // fades maximum intensity palette towards approximation of main palette for (uint16 _si = 0; _si<6; _si++) { - _gfx->fadePalette(pal); + _gfx->fadePalette(pal, _gfx->_palette, 4); _gfx->setPalette(pal); waitTime( 1 ); _gfx->updateScreen(); -- cgit v1.2.3 From 4b008f97242e60d12899a89968cb129afc3c22a8 Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Tue, 31 Jul 2007 19:33:36 +0000 Subject: Changed code to use the new fadePalette function, thus removing fadeInPalette and some custom fade code in _c_endComment. svn-id: r28368 --- engines/parallaction/callables_ns.cpp | 50 ++++++----------------------------- engines/parallaction/graphics.cpp | 7 ----- engines/parallaction/graphics.h | 1 - 3 files changed, 8 insertions(+), 50 deletions(-) (limited to 'engines') diff --git a/engines/parallaction/callables_ns.cpp b/engines/parallaction/callables_ns.cpp index 9b3972723f..94a0747ab1 100644 --- a/engines/parallaction/callables_ns.cpp +++ b/engines/parallaction/callables_ns.cpp @@ -205,11 +205,11 @@ void Parallaction_ns::_c_fade(void *parm) { memset(pal, 0, sizeof(Gfx::Palette)); for (uint16 _di = 0; _di < 64; _di++) { - _gfx->fadeInPalette(pal); + _gfx->fadePalette(pal, _gfx->_palette, 1); _gfx->setPalette(pal); - g_system->delayMillis(20); _gfx->updateScreen(); + g_system->delayMillis(20); } return; @@ -338,11 +338,6 @@ void Parallaction_ns::_c_setMask(void *parm) { void Parallaction_ns::_c_endComment(void *param) { - byte* _enginePal = _gfx->_palette; - Gfx::Palette pal; - - _gfx->makeGrayscalePalette(pal); - int16 w = 0, h = 0; _gfx->getStringExtent(_location._endComment, 130, &w, &h); @@ -359,45 +354,16 @@ void Parallaction_ns::_c_endComment(void *param) { _gfx->displayWrappedString(_location._endComment, 3, 5, 0, 130); _gfx->updateScreen(); - uint32 si, di; - for (di = 0; di < PALETTE_COLORS; di++) { - for (si = 0; si <= 93; si +=3) { - - int8 al; - - if (_enginePal[si] != pal[si]) { - al = _enginePal[si]; - if (al < pal[si]) - al = 1; - else - al = -1; - _enginePal[si] += al; - } - - if (_enginePal[si+1] != pal[si+1]) { - al = _enginePal[si+1]; - if (al < pal[si+1]) - al = 1; - else - al = -1; - _enginePal[si+1] += al; - } - if (_enginePal[si+2] != pal[si+2]) { - al = _enginePal[si+2]; - if (al < pal[si+2]) - al = 1; - else - al = -1; - _enginePal[si+2] += al; - } + Gfx::Palette pal; + _gfx->makeGrayscalePalette(pal); - } + for (uint di = 0; di < 64; di++) { + _gfx->fadePalette(_gfx->_palette, pal, 1); + _gfx->setPalette(_gfx->_palette); - _gfx->setPalette(_enginePal); - g_system->delayMillis(20); _gfx->updateScreen(); - + g_system->delayMillis(20); } waitUntilLeftClick(); diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp index 27e2de939d..16b1059c28 100644 --- a/engines/parallaction/graphics.cpp +++ b/engines/parallaction/graphics.cpp @@ -203,13 +203,6 @@ void Gfx::animatePalette() { return; } -void Gfx::fadeInPalette(Palette pal) { - for (uint16 i = 0; i < BASE_PALETTE_COLORS * 3; i++) - if (pal[i] < _palette[i]) pal[i]++; - - return; -} - void Gfx::makeGrayscalePalette(Palette pal) { for (uint16 i = 0; i < BASE_PALETTE_COLORS; i++) { diff --git a/engines/parallaction/graphics.h b/engines/parallaction/graphics.h index b7013d125e..cb92c90547 100644 --- a/engines/parallaction/graphics.h +++ b/engines/parallaction/graphics.h @@ -209,7 +209,6 @@ public: void setPalette(Palette palette, uint32 first = FIRST_BASE_COLOR, uint32 num = BASE_PALETTE_COLORS); void setBlackPalette(); void animatePalette(); - void fadeInPalette(Palette palette); // fades palette (from black) to system palette void fadePalette(Palette palette, Palette target, uint step); // fades palette to target palette, with specified step void makeGrayscalePalette(Palette palette); // transform palette into black and white -- cgit v1.2.3 From 6b3c03317d236da2c8d13754d59a8a9bd9ae851b Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Tue, 31 Jul 2007 20:15:58 +0000 Subject: Added Ween English Atari ST and updated the Amiga version, as provided by pwigren in bug #1764174 svn-id: r28369 --- engines/gob/detection.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/gob/detection.cpp b/engines/gob/detection.cpp index 4286e10b6d..18c7e31717 100644 --- a/engines/gob/detection.cpp +++ b/engines/gob/detection.cpp @@ -622,7 +622,11 @@ static const GOBGameDescription gameDescriptions[] = { { "ween", "", - AD_ENTRY1s("intro.stk", "bfd9d02faf3d8d60a2cf744f95eb48dd", 456570), + { + {"intro.stk", 0, "bfd9d02faf3d8d60a2cf744f95eb48dd", 456570}, + {"ween.ins", 0, "d2cb24292c9ddafcad07e23382027218", 87800}, + {NULL, 0, NULL, 0} + }, EN_GRB, kPlatformAmiga, Common::ADGF_NO_FLAGS @@ -631,6 +635,23 @@ static const GOBGameDescription gameDescriptions[] = { kFeaturesNone, "intro" }, + { // Supplied by pwigren in bug report #1764174 + { + "ween", + "", + { + {"intro.stk", 0, "bfd9d02faf3d8d60a2cf744f95eb48dd", 456570}, + {"music__5.snd", 0, "7d1819b9981ecddd53d3aacbc75f1cc8", 13446}, + {NULL, 0, NULL, 0} + }, + EN_GRB, + kPlatformAtariST, + Common::ADGF_NO_FLAGS + }, + kGameTypeWeen, + kFeaturesNone, + "intro" + }, { // Supplied by vampir_raziel in bug report #1658373 { "ween", -- cgit v1.2.3 From d4999255b7e66cd263a203c140d4372568837c6f Mon Sep 17 00:00:00 2001 From: Gregory Montoir Date: Tue, 31 Jul 2007 21:17:15 +0000 Subject: fix for bug #1751226 (glitches on save/load svn-id: r28370 --- engines/touche/saveload.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/touche/saveload.cpp b/engines/touche/saveload.cpp index 653c2d26a3..fb82e68944 100644 --- a/engines/touche/saveload.cpp +++ b/engines/touche/saveload.cpp @@ -280,8 +280,8 @@ void ToucheEngine::loadGameStateData(Common::ReadStream *stream) { _newMusicNum = stream->readUint16LE(); _currentRoomNum = stream->readUint16LE(); res_loadRoom(_currentRoomNum); - int16 roomOffsX = stream->readUint16LE(); - int16 roomOffsY = stream->readUint16LE(); + int16 roomOffsX = _flagsTable[614] = stream->readUint16LE(); + int16 roomOffsY = _flagsTable[615] = stream->readUint16LE(); _disabledInputCounter = stream->readUint16LE(); res_loadProgram(_currentEpisodeNum); setupEpisode(-1); @@ -291,7 +291,7 @@ void ToucheEngine::loadGameStateData(Common::ReadStream *stream) { saveOrLoadCommonArray(*stream, _programWalkTable); saveOrLoadCommonArray(*stream, _programPointsTable); stream->read(_updatedRoomAreasTable, 200); - for (uint i = 1; i <= _updatedRoomAreasTable[0]; ++i) { + for (uint i = 1; i < _updatedRoomAreasTable[0]; ++i) { updateRoomAreas(_updatedRoomAreasTable[i], -1); } saveOrLoadStaticArray(*stream, _sequenceEntryTable, NUM_SEQUENCES); @@ -327,7 +327,9 @@ void ToucheEngine::loadGameStateData(Common::ReadStream *stream) { Graphics::copyRect(_offscreenBuffer, kScreenWidth, 0, 0, _backdropBuffer, _currentBitmapWidth, _flagsTable[614], _flagsTable[615], kScreenWidth, kRoomHeight); + updateRoomRegions(); updateEntireScreen(); + _roomNeedRedraw = false; if (_flagsTable[617] != 0) { res_loadSpeech(_flagsTable[617]); } -- cgit v1.2.3 From 9bdbb470c031273a56a519de5e13136ad846a22e Mon Sep 17 00:00:00 2001 From: Gregory Montoir Date: Tue, 31 Jul 2007 21:19:45 +0000 Subject: add missing clipping svn-id: r28371 --- engines/touche/graphics.cpp | 64 +++++++++++++++++++++++++++++++-------------- 1 file changed, 44 insertions(+), 20 deletions(-) (limited to 'engines') diff --git a/engines/touche/graphics.cpp b/engines/touche/graphics.cpp index 51fdcbd89a..2ca11a1f95 100644 --- a/engines/touche/graphics.cpp +++ b/engines/touche/graphics.cpp @@ -177,34 +177,58 @@ void Graphics::drawLine(uint8 *dst, int dstPitch, int x1, int y1, int x2, int y2 } void Graphics::copyRect(uint8 *dst, int dstPitch, int dstX, int dstY, const uint8 *src, int srcPitch, int srcX, int srcY, int w, int h, int flags) { - if (w != 0 && h != 0) { - dst += dstY * dstPitch + dstX; - src += srcY * srcPitch + srcX; - while (h--) { - for (int i = 0; i < w; ++i) { - if ((flags & kTransparent) == 0 || src[i] != 0) { - dst[i] = src[i]; - } + if (dstX < 0) { + w += dstX; + dstX = 0; + } + if (w <= 0) { + return; + } + if (dstY < 0) { + h += dstY; + dstY = 0; + } + if (h <= 0) { + return; + } + dst += dstY * dstPitch + dstX; + src += srcY * srcPitch + srcX; + while (h--) { + for (int i = 0; i < w; ++i) { + if ((flags & kTransparent) == 0 || src[i] != 0) { + dst[i] = src[i]; } - dst += dstPitch; - src += srcPitch; } + dst += dstPitch; + src += srcPitch; } } void Graphics::copyMask(uint8 *dst, int dstPitch, int dstX, int dstY, const uint8 *src, int srcPitch, int srcX, int srcY, int w, int h, uint8 fillColor) { - if (w != 0 && h != 0) { - dst += dstY * dstPitch + dstX; - src += srcY * srcPitch + srcX; - while (h--) { - for (int i = 0; i < w; ++i) { - if (src[i] != 0) { - dst[i] = fillColor; - } + if (dstX < 0) { + w += dstX; + dstX = 0; + } + if (w <= 0) { + return; + } + if (dstY < 0) { + h += dstY; + dstY = 0; + } + if (h <= 0) { + return; + } + dst += dstY * dstPitch + dstX; + src += srcY * srcPitch + srcX; + while (h--) { + for (int i = 0; i < w; ++i) { + if (src[i] != 0) { + dst[i] = fillColor; } - dst += dstPitch; - src += srcPitch; } + dst += dstPitch; + src += srcPitch; } } -- cgit v1.2.3 From 6b590bf4d14a0f0d3024d85b9a6220956e131d23 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 31 Jul 2007 21:57:32 +0000 Subject: Fixed incorrect file assignment for the ITE Windows demo svn-id: r28372 --- engines/saga/rscfile.cpp | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) (limited to 'engines') diff --git a/engines/saga/rscfile.cpp b/engines/saga/rscfile.cpp index 3a60ae60e6..126cb58344 100644 --- a/engines/saga/rscfile.cpp +++ b/engines/saga/rscfile.cpp @@ -435,7 +435,7 @@ bool Resource::createContexts() { } else if (Common::File::exists("musicd.rsc") || Common::File::exists("musicd.cmp")) { _contextsCount++; digitalMusic = true; - if (Common::File::exists("musicd.rsc")) + if (Common::File::exists("musicd.cmp")) sprintf(musicFileName, "musicd.cmp"); else sprintf(musicFileName, "musicd.rsc"); @@ -452,22 +452,13 @@ bool Resource::createContexts() { // For ITE, add the digital music file and sfx file information here if (_vm->getGameType() == GType_ITE && digitalMusic && i == _contextsCount - 1) { - if (_vm->getFeatures() & GF_COMPRESSED_SOUNDS) - context->fileName = musicFileName; - else - context->fileName = musicFileName; + context->fileName = musicFileName; context->fileType = GAME_MUSICFILE; } else if (_vm->getGameType() == GType_ITE && !soundFileInArray && i == soundFileIndex) { - if (_vm->getFeatures() & GF_COMPRESSED_SOUNDS) - context->fileName = soundFileName; - else - context->fileName = soundFileName; + context->fileName = soundFileName; context->fileType = GAME_SOUNDFILE; } else if (_vm->getGameType() == GType_ITE && !voicesFileInArray && i == voicesFileIndex) { - if (_vm->getFeatures() & GF_COMPRESSED_SOUNDS) - context->fileName = voicesFileName; - else - context->fileName = voicesFileName; + context->fileName = voicesFileName; // can be GAME_VOICEFILE or GAME_SOUNDFILE | GAME_VOICEFILE or GAME_VOICEFILE | GAME_SWAPENDIAN context->fileType = voiceFileType; } else { -- cgit v1.2.3 From 507461e94df430484b0f377c17a54472810747c2 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Tue, 31 Jul 2007 23:06:25 +0000 Subject: - VMD playing works a bit better now - Minor cleanup svn-id: r28373 --- engines/gob/coktelvideo.cpp | 305 ++++++++++++++++++++++---------------------- engines/gob/coktelvideo.h | 4 +- 2 files changed, 159 insertions(+), 150 deletions(-) (limited to 'engines') diff --git a/engines/gob/coktelvideo.cpp b/engines/gob/coktelvideo.cpp index bb50ddf04a..d8275c4ad3 100644 --- a/engines/gob/coktelvideo.cpp +++ b/engines/gob/coktelvideo.cpp @@ -315,7 +315,7 @@ void Imd::waitEndFrame() { if (waitTime < 0) { _skipFrames = -waitTime / _soundSliceLength; - warning("IMD A/V sync broken, skipping %d frame(s)", _skipFrames + 1); + warning("Video A/V sync broken, skipping %d frame(s)", _skipFrames + 1); } else if (waitTime > 0) g_system->delayMillis(waitTime); @@ -418,6 +418,7 @@ void Imd::clear(bool del) { _soundStartTime = 0; _skipFrames = 0; + _soundFlags = 0; _soundFreq = 0; _soundSliceSize = 0; _soundSlicesCount = 0; @@ -432,7 +433,6 @@ void Imd::clear(bool del) { CoktelVideo::State Imd::processFrame(uint16 frame) { State state; uint32 cmd = 0; - int16 xBak, yBak, heightBak, widthBak; bool hasNextCmd = false; bool startSound = false; @@ -446,34 +446,29 @@ CoktelVideo::State Imd::processFrame(uint16 frame) { seekFrame(frame); } - state.left = xBak = _x; - state.top = yBak = _y; - state.bottom = heightBak = _height; - state.right = widthBak = _width; - state.right += state.left - 1; - state.bottom += state.top - 1; + if (!_vidMem) + setVideoMemory(); + + state.left = _x; + state.top = _y; + state.right = _width + state.left - 1; + state.bottom = _height + state.top - 1; do { if (frame != 0) { if (_stdX != -1) { - state.left = _x = _stdX; - state.top = _y = _stdY; - state.right = _width = _stdWidth; - state.bottom = _height = _stdHeight; - state.right += state.left - 1; - state.bottom += state.top - 1; + state.left = _stdX; + state.top = _stdY; + state.right = _stdWidth + state.left - 1; + state.bottom = _stdHeight + state.top - 1; state.flags |= kStateStdCoords; } if (_frameCoords && (_frameCoords[frame].left != -1)) { - state.left = _x = _frameCoords[frame].left; - state.top = _y = _frameCoords[frame].top; - state.right = _width = - _frameCoords[frame].right - _x + 1; - state.bottom = _height = - _frameCoords[frame].bottom - _y + 1; - state.right += state.left - 1; - state.bottom += state.top - 1; + state.left = _frameCoords[frame].left; + state.top = _frameCoords[frame].top; + state.right = _frameCoords[frame].right; + state.bottom = _frameCoords[frame].bottom; state.flags |= kStateFrameCoords; } } @@ -577,33 +572,20 @@ CoktelVideo::State Imd::processFrame(uint16 frame) { cmd = _stream->readUint32LE(); _stream->read(_frameData, cmd + 2); - int16 left = _x; - int16 top = _y; - int16 right = _width + left; - int16 bottom = _height + top; - - if (!_vidMem) - setVideoMemory(); - - if (_vidMemWidth < right) { - left = 0; - right = _width; + if (_vidMemWidth <= state.right) { + state.left = 0; + state.right -= state.left; } - if (_vidMemWidth < right) - right = _vidMemWidth; - if (_vidMemHeight < bottom) { - top = 0; - bottom = _height; + if (_vidMemWidth <= state.right) + state.right = _vidMemWidth - 1; + if (_vidMemHeight <= state.bottom) { + state.top = 0; + state.bottom -= state.top; } - if (_vidMemHeight < bottom) - bottom = _vidMemHeight; - - _x = left; - _y = top; - _height = bottom - top; - _width = right - left; + if (_vidMemHeight <= state.bottom) + state.bottom = _vidMemHeight -1; - state.flags |= renderFrame(); + state.flags |= renderFrame(state.left, state.top, state.right, state.bottom); state.flags |= _frameData[0]; // Frame video data @@ -611,7 +593,7 @@ CoktelVideo::State Imd::processFrame(uint16 frame) { _stream->read(_frameData, cmd + 2); - state.flags |= renderFrame(); + state.flags |= renderFrame(state.left, state.top, state.right, state.bottom); state.flags |= _frameData[0]; } else @@ -626,11 +608,6 @@ CoktelVideo::State Imd::processFrame(uint16 frame) { _soundStage = 2; } - _x = xBak; - _y = yBak; - _width = widthBak; - _height = heightBak; - _curFrame++; if ((_curFrame == _framesCount) && (_soundStage == 2)) { _audioStream->finish(); @@ -643,23 +620,18 @@ CoktelVideo::State Imd::processFrame(uint16 frame) { return state; } -uint32 Imd::renderFrame() { - if (!_frameData || (_width <= 0) || (_height <= 0)) +uint32 Imd::renderFrame(int16 left, int16 top, int16 right, int16 bottom) { + if (!_frameData || !_vidMem || (_width <= 0) || (_height <= 0)) return 0; - if (!_vidMem) - setVideoMemory(); - - byte *dataPtr = _frameData; - int16 imdX = _x; - int16 imdY = _y; - int16 imdW = _width; - int16 imdH = _height; + uint32 retVal = 0; + int16 width = right - left + 1; + int16 height = bottom - top + 1; int16 sW = _vidMemWidth; - byte *imdVidMem = _vidMem + sW * imdY + imdX; + byte *dataPtr = _frameData; + byte *imdVidMem = _vidMem + sW * top + left; + byte *srcPtr; uint8 type = *dataPtr++; - byte *srcPtr = dataPtr; - uint32 retVal = 0; if (type & 0x10) { // Palette data // One byte index @@ -673,10 +645,11 @@ uint32 Imd::renderFrame() { } srcPtr = dataPtr; + if (type & 0x80) { // Frame data is compressed srcPtr = _vidBuffer; type &= 0x7F; - if ((type == 2) && (imdW == sW)) { + if ((type == 2) && (width == sW)) { deLZ77(imdVidMem, dataPtr); return retVal; } else @@ -687,19 +660,19 @@ uint32 Imd::renderFrame() { byte *imdVidMemBak; if (type == 2) { // Whole block - for (int i = 0; i < imdH; i++) { - memcpy(imdVidMem, srcPtr, imdW); - srcPtr += imdW; + for (int i = 0; i < height; i++) { + memcpy(imdVidMem, srcPtr, width); + srcPtr += width; imdVidMem += sW; } } else if (type == 1) { // Sparse block imdVidMemBak = imdVidMem; - for (int i = 0; i < imdH; i++) { + for (int i = 0; i < height; i++) { pixWritten = 0; - while (pixWritten < imdW) { + while (pixWritten < width) { pixCount = *srcPtr++; if (pixCount & 0x80) { // data - pixCount = MIN((pixCount & 0x7F) + 1, imdW - pixWritten); + pixCount = MIN((pixCount & 0x7F) + 1, width - pixWritten); memcpy(imdVidMem, srcPtr, pixCount); pixWritten += pixCount; @@ -715,30 +688,30 @@ uint32 Imd::renderFrame() { imdVidMem = imdVidMemBak; } } else if (type == 0x42) { // Whole quarter-wide block - for (int i = 0; i < imdH; i++) { + for (int i = 0; i < height; i++) { imdVidMemBak = imdVidMem; - for (int j = 0; j < imdW; j += 4, imdVidMem += 4, srcPtr++) + for (int j = 0; j < width; j += 4, imdVidMem += 4, srcPtr++) memset(imdVidMem, *srcPtr, 4); imdVidMemBak += sW; imdVidMem = imdVidMemBak; } } else if ((type & 0xF) == 2) { // Whole half-high block - for (; imdH > 1; imdH -= 2, imdVidMem += sW + sW, srcPtr += imdW) { - memcpy(imdVidMem, srcPtr, imdW); - memcpy(imdVidMem + sW, srcPtr, imdW); + for (; height > 1; height -= 2, imdVidMem += sW + sW, srcPtr += width) { + memcpy(imdVidMem, srcPtr, width); + memcpy(imdVidMem + sW, srcPtr, width); } - if (imdH == -1) - memcpy(imdVidMem, srcPtr, imdW); + if (height == -1) + memcpy(imdVidMem, srcPtr, width); } else { // Sparse half-high block imdVidMemBak = imdVidMem; - for (int i = 0; i < imdH; i += 2) { + for (int i = 0; i < height; i += 2) { pixWritten = 0; - while (pixWritten < imdW) { + while (pixWritten < width) { pixCount = *srcPtr++; if (pixCount & 0x80) { // data - pixCount = MIN((pixCount & 0x7F) + 1, imdW - pixWritten); + pixCount = MIN((pixCount & 0x7F) + 1, width - pixWritten); memcpy(imdVidMem, srcPtr, pixCount); memcpy(imdVidMem + sW, srcPtr, pixCount); @@ -865,15 +838,13 @@ bool Vmd::load(Common::SeekableReadStream &stream) { // Version checking if ((headerLength != 814) || (handle != 0) || (_version != 1)) { - warning("IMD Version incorrect (%d, %d, %d)", headerLength, handle, _version); + warning("VMD Version incorrect (%d, %d, %d)", headerLength, handle, _version); unload(); return false; } _framesCount = _stream->readUint16LE(); - warning("# of frames: %d", _framesCount); - _x = _stream->readSint16LE(); _y = _stream->readSint16LE(); _width = _stream->readSint16LE(); @@ -881,19 +852,13 @@ bool Vmd::load(Common::SeekableReadStream &stream) { if ((_width != 0) && (_height != 0)) { _hasVideo = true; _features |= kFeaturesVideo; - - warning("%dx%d+%d+%d", _width, _height, _x, _y); - } else _hasVideo = false; _flags = _stream->readUint16LE(); _partsPerFrame = _stream->readUint16LE(); _firstFramePos = _stream->readUint32LE(); - uint32 unknown1 = _stream->readUint32LE(); - - warning("flags: %d (0x%X), #parts: %d, firstFramePos: %d, U1: %d (0x%X)", - _flags, _flags, _partsPerFrame, _firstFramePos, unknown1, unknown1); + _stream->skip(4); // Unknown _stream->read((byte *) _palette, 768); @@ -912,13 +877,12 @@ bool Vmd::load(Common::SeekableReadStream &stream) { _vidBuffer = new byte[_vidBufferSize]; assert(_vidBuffer); memset(_vidBuffer, 0, _vidBufferSize); - warning("Sizes: frameData: %d, vidBuffer: %d", _frameDataSize, _vidBufferSize); } _soundFreq = _stream->readSint16LE(); _soundSliceSize = _stream->readUint16LE(); _soundSlicesCount = _stream->readSint16LE(); - uint16 soundFlags = _stream->readUint16LE(); + _soundFlags = _stream->readUint16LE(); _hasSound = (_soundFreq != 0); if (_hasSound) { @@ -928,59 +892,45 @@ bool Vmd::load(Common::SeekableReadStream &stream) { _frameLength = _soundSliceLength; _soundStage = 1; - _audioStream = Audio::makeAppendableAudioStream(_soundFreq, 0); - - warning("Sound: Freq: %d, # slices %d, slideSize: %d, flags: %d (0x%X), sliceLen = %d", - _soundFreq, _soundSlicesCount, _soundSliceSize, soundFlags, soundFlags, _soundSliceLength); - } else _frameLength = 1000 / 12; // 12 FPS for a video without sound uint32 frameInfoOffset = _stream->readUint32LE(); - warning("frameInfoOffset: %d", frameInfoOffset); - _stream->seek(frameInfoOffset); _frames = new Frame[_framesCount]; for (uint16 i = 0; i < _framesCount; i++) { _frames[i].parts = new Part[_partsPerFrame]; - _stream->skip(2); + _stream->skip(2); // Unknown _frames[i].offset = _stream->readUint32LE(); } for (uint16 i = 0; i < _framesCount; i++) { for (uint16 j = 0; j < _partsPerFrame; j++) { + _frames[i].parts[j].type = (PartType) _stream->readByte(); - uint16 Unknown3 = _stream->readByte(); + _stream->skip(1); // Unknown _frames[i].parts[j].size = _stream->readUint32LE(); + if (_frames[i].parts[j].type == kPartTypeAudio) { + _frames[i].parts[j].flags = _stream->readByte(); - _stream->skip(9); - warning("%d.%d (%d): Audio: %d (0x%X), %d (0x%X)", - i, j, _frames[i].parts[j].size, - Unknown3, Unknown3, _frames[i].parts[j].flags, _frames[i].parts[j].flags); + _stream->skip(9); // Unknow } else if (_frames[i].parts[j].type == kPartTypeVideo) { + _frames[i].parts[j].left = _stream->readUint16LE(); _frames[i].parts[j].top = _stream->readUint16LE(); _frames[i].parts[j].right = _stream->readUint16LE(); _frames[i].parts[j].bottom = _stream->readUint16LE(); - uint16 Unknown4 = _stream->readByte(); + _stream->skip(1); // Unknown _frames[i].parts[j].flags = _stream->readByte(); - warning("%d.%d (%d): Video: %d (0x%X), %d+%d+%d+%d, %d (0x%X), %d (0x%X)", - i, j, _frames[i].parts[j].size, - Unknown3, Unknown3, _frames[i].parts[j].left, - _frames[i].parts[j].top, _frames[i].parts[j].right, - _frames[i].parts[j].bottom, Unknown4, Unknown4, - _frames[i].parts[j].flags, _frames[i].parts[j].flags); } else { - warning("VMD: Unknown frame part type found (%d.%d: %d, %d)", - i, j, _frames[i].parts[j].type, _frames[i].parts[j].size); + // Unknow type _stream->skip(10); -// unload(); -// return false; } + } } @@ -1060,13 +1010,18 @@ void Vmd::clear(bool del) { CoktelVideo::State Vmd::processFrame(uint16 frame) { State state; - int16 xBak = 0, yBak = 0, heightBak = 0, widthBak = 0; bool startSound = false; seekFrame(frame); state.flags |= kStateNoVideoData; - state.left = -1; + state.left = 0x7FFF; + state.right = 0x7FFF; + state.top = 0; + state.bottom = 0; + + if (!_vidMem) + setVideoMemory(); for (uint16 i = 0; i < _partsPerFrame; i++) { Part &part = _frames[frame].parts[i]; @@ -1092,9 +1047,7 @@ CoktelVideo::State Vmd::processFrame(uint16 frame) { } else if (part.flags == 2) { if (_soundEnabled) { - uint32 U = _stream->readUint32LE(); - - warning("Mask? %d (0x%X)", U, U); + _stream->skip(4); // Unknown soundBuf = new byte[part.size - 4]; assert(soundBuf); @@ -1128,24 +1081,7 @@ CoktelVideo::State Vmd::processFrame(uint16 frame) { } else if (part.type == kPartTypeVideo) { state.flags &= ~kStateNoVideoData; - if (state.left == -1) { - state.left = _x = part.left; - state.top = _y = part.top; - state.right = _width = part.right; - state.bottom = _height = part.bottom; - _width -= _x - 1; - _height -= _y - 1; - } else { - _x = part.left; - _y = part.top; - _width = part.right - (_x - 1); - _height = part.bottom - (_y - 1); - state.left = MIN(state.left, part.left); - state.top = MIN(state.top, part.top); - state.right = MAX(state.right, part.right); - state.bottom = MAX(state.bottom, part.bottom); - } - + // New palette if (part.flags & 2) { uint8 index = _stream->readByte(); uint8 count = _stream->readByte(); @@ -1157,10 +1093,20 @@ CoktelVideo::State Vmd::processFrame(uint16 frame) { } _stream->read(_frameData, part.size); - state.flags |= renderFrame(); - } else { - warning("Unknown frame part type %d, size %d (%d of %d)", part.type, part.size, i + 1, _partsPerFrame); + if (renderFrame(part.left, part.top, part.right, part.bottom)) { + // Rendering succeeded, merging areas + state.left = MIN(state.left, part.left); + state.top = MIN(state.top, part.top); + state.right = MAX(state.right, part.right); + state.bottom = MAX(state.bottom, part.bottom); + } + + } else if (part.type == 4) { + // Unknown _stream->skip(part.size); + } else { + // Unknow type +// warning("Unknown frame part type %d, size %d (%d of %d)", part.type, part.size, i + 1, _partsPerFrame); } } @@ -1171,11 +1117,6 @@ CoktelVideo::State Vmd::processFrame(uint16 frame) { _soundStage = 2; } - _x = xBak; - _y = yBak; - _width = widthBak; - _height = heightBak; - if ((_curFrame == (_framesCount - 1)) && (_soundStage == 2)) { _audioStream->finish(); _mixer->stopHandle(_audioHandle); @@ -1187,4 +1128,70 @@ CoktelVideo::State Vmd::processFrame(uint16 frame) { return state; } +uint32 Vmd::renderFrame(int16 left, int16 top, int16 right, int16 bottom) { + if (!_frameData || !_vidMem || (_width <= 0) || (_height <= 0)) + return 0; + + int16 width = right - left + 1; + int16 height = bottom - top + 1; + int16 sW = _vidMemWidth; + byte *dataPtr = _frameData; + byte *imdVidMem = _vidMem + sW * top + left; + byte *srcPtr; + uint8 type = *dataPtr++; + + srcPtr = dataPtr; + + if (type & 0x80) { // Frame data is compressed + srcPtr = _vidBuffer; + type &= 0x7F; + if ((type == 2) && (width == sW)) { + deLZ77(imdVidMem, dataPtr); + return 1; + } else + deLZ77(srcPtr, dataPtr); + } + + uint16 pixCount, pixWritten; + byte *imdVidMemBak; + + if (type == 1) { // Sparse block + imdVidMemBak = imdVidMem; + for (int i = 0; i < height; i++) { + pixWritten = 0; + while (pixWritten < width) { + pixCount = *srcPtr++; + if (pixCount & 0x80) { // data + pixCount = MIN((pixCount & 0x7F) + 1, width - pixWritten); + memcpy(imdVidMem, srcPtr, pixCount); + + pixWritten += pixCount; + imdVidMem += pixCount; + srcPtr += pixCount; + } else { // "hole" + pixCount = (pixCount + 1) % 256; + pixWritten += pixCount; + imdVidMem += pixCount; + } + } + imdVidMemBak += sW; + imdVidMem = imdVidMemBak; + } + } else if (type == 2) { // Whole block + for (int i = 0; i < height; i++) { + memcpy(imdVidMem, srcPtr, width); + srcPtr += width; + imdVidMem += sW; + } + } else if (type == 3) { // RLE block + warning("Frame render method 3: RLE block"); + return 0; + } else { + warning("Unkown frame rendering method %d (0x%X)", type, type); + return 0; + } + + return 1; +} + } // End of namespace Gob diff --git a/engines/gob/coktelvideo.h b/engines/gob/coktelvideo.h index 678fde3967..39228c7bca 100644 --- a/engines/gob/coktelvideo.h +++ b/engines/gob/coktelvideo.h @@ -223,6 +223,7 @@ protected: uint32 _soundStartTime; uint32 _skipFrames; + uint16 _soundFlags; int16 _soundFreq; uint16 _soundSliceSize; int16 _soundSlicesCount; @@ -244,7 +245,7 @@ protected: void clear(bool del = true); State processFrame(uint16 frame); - uint32 renderFrame(); + uint32 renderFrame(int16 left, int16 top, int16 right, int16 bottom); void deLZ77(byte *dest, byte *src); }; @@ -291,6 +292,7 @@ protected: void clear(bool del = true); State processFrame(uint16 frame); + uint32 renderFrame(int16 left, int16 top, int16 right, int16 bottom); }; } // End of namespace Gob -- cgit v1.2.3 From 9f05751611366325f9855684b66c47515ae553dd Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Tue, 31 Jul 2007 23:34:05 +0000 Subject: Woodruff's intro.vmd now works correctly! :)) svn-id: r28374 --- engines/gob/coktelvideo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/gob/coktelvideo.cpp b/engines/gob/coktelvideo.cpp index d8275c4ad3..a8765c4a99 100644 --- a/engines/gob/coktelvideo.cpp +++ b/engines/gob/coktelvideo.cpp @@ -1086,7 +1086,7 @@ CoktelVideo::State Vmd::processFrame(uint16 frame) { uint8 index = _stream->readByte(); uint8 count = _stream->readByte(); - _stream->read(_palette + index * 3, count + 1); + _stream->read(_palette + index * 3, (count + 1) * 3); _stream->skip((255 - count) * 3); state.flags |= kStatePalette; -- cgit v1.2.3 From e416cd0d83ebe4ed336a4f0f4d8dfe0de0b2059d Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 1 Aug 2007 00:38:28 +0000 Subject: Fix for the non-loading BBM files in the ITE demos with substitute scenes. This is a very strange bug, and it seems to be directly related to an issue with the Common::File class svn-id: r28375 --- engines/saga/saga.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'engines') diff --git a/engines/saga/saga.cpp b/engines/saga/saga.cpp index 76731c201a..35cb8b2647 100644 --- a/engines/saga/saga.cpp +++ b/engines/saga/saga.cpp @@ -233,6 +233,30 @@ int SagaEngine::init() { _voicesEnabled = true; } + // WORKAROUND for a weird bug that I haven't been able to understand. + // In some ITE demos, scenes are substituted with pictures, which are + // loaded instead of the actual scene in Scene::changeScene(). The + // weird phenomenon is that NO files can be opened or found in that + // function. However, file existence works in other parts of the engine. + // The strange thing is that if we add a dummy file existence check here + // (or in any part of init() or go()) for a file that exists (it doesn't + // work if the file doesn't exist), files are opened correctly in the + // function. I don't know if this is a bug of the Common::File class or + // of the SAGA engine itself (or perhaps of a clashing definition?), but + // still, it's very strange that a file existence check fixes things. In + // both cases (with and without this dummy check here), the Common::File + // open function called from Scene::changeScene() finds the file through + // the _filesMap, but without this dummy check here, the handle returned + // is 0 + // To reproduce: run any of the ITE demos that has scene substitutes like, + // for example, the ITE demo from Wyrmkeep's site. Enter the game, and + // exit the faire (to speed things up, open the debug console and type + // "scene_change 1", close the console and visit any place other than + // the faire) + // Since the files we need are BBM files, just check for the existence + // of one file of them here + if (Common::File::exists("tycho.bbm")) {} + // FIXME: This is the ugly way of reducing redraw overhead. It works // well for 320x200 but it's unclear how well it will work for // 640x480. -- cgit v1.2.3 From c4829fe340e2338b69fe8d4dd6ccba60c6518c31 Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Wed, 1 Aug 2007 00:57:51 +0000 Subject: Fix compiler warning. svn-id: r28376 --- engines/saga/events.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'engines') diff --git a/engines/saga/events.cpp b/engines/saga/events.cpp index 5bdcf671d3..b7f65b9f83 100644 --- a/engines/saga/events.cpp +++ b/engines/saga/events.cpp @@ -364,7 +364,6 @@ int Events::handleOneShot(Event *event) { const PalEntry *palette = (const PalEntry *)_vm->getImagePal(resourceData, resourceDataLength); Surface *bgSurface = _vm->_render->getBackGroundSurface(); - const Rect rect(width, height); bgSurface->blit(rect, buf); _vm->_frameCount++; -- cgit v1.2.3 From ad2bfc18d6c8450a66db50daad7fe5b8447f3838 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Wed, 1 Aug 2007 01:20:02 +0000 Subject: Some GK2 VMDs now load and play, too. The sound is borked, though (probably 16 bit). svn-id: r28377 --- engines/gob/coktelvideo.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/gob/coktelvideo.cpp b/engines/gob/coktelvideo.cpp index a8765c4a99..864a760ea8 100644 --- a/engines/gob/coktelvideo.cpp +++ b/engines/gob/coktelvideo.cpp @@ -868,7 +868,7 @@ bool Vmd::load(Common::SeekableReadStream &stream) { if (_hasVideo) { if (_frameDataSize == 0) _frameDataSize = _width * _height + 500; - if (_vidBufferSize) + if (_vidBufferSize == 0) _vidBufferSize = _frameDataSize; _frameData = new byte[_frameDataSize]; @@ -888,7 +888,7 @@ bool Vmd::load(Common::SeekableReadStream &stream) { if (_hasSound) { _features |= kFeaturesSound; - _soundSliceLength = 1000 / (_soundFreq / _soundSliceSize); + _soundSliceLength = (uint16) (1000.0 / ((double) _soundFreq / (double) _soundSliceSize)); _frameLength = _soundSliceLength; _soundStage = 1; -- cgit v1.2.3 From d5e10d1d568e3ac57755f70828342965e2e7c46e Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Wed, 1 Aug 2007 01:21:03 +0000 Subject: Fix compiler warnings. svn-id: r28378 --- engines/drascula/drascula.cpp | 52 +++++++++++++++++++++---------------------- engines/saga/sfuncs.cpp | 2 +- 2 files changed, 27 insertions(+), 27 deletions(-) (limited to 'engines') diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp index a2e2a67db3..ef9d743bfb 100644 --- a/engines/drascula/drascula.cpp +++ b/engines/drascula/drascula.cpp @@ -3820,8 +3820,8 @@ byte *DrasculaEngine::TryInMem(Common::File *Sesion) { return pointer; } -void DrasculaEngine::set_dacSSN(byte *dacSSN) { - setvgapalette256((byte *)dacSSN); +void DrasculaEngine::set_dacSSN(byte *PalBuf) { + setvgapalette256((byte *)PalBuf); } void DrasculaEngine::Des_OFF(byte *BufferOFF, byte *MiVideoOFF, int Lenght) { @@ -3900,9 +3900,9 @@ void DrasculaEngine::set_dac(byte *dac) { setvgapalette256((byte *)dac); } -void DrasculaEngine::WaitForNext(long TimeMed) { +void DrasculaEngine::WaitForNext(long TimeLen) { TimeLast = clock(); - while (clock() < (TimeLast + TimeMed)) {} + while (clock() < (TimeLast + TimeLen)) {} TimeLast = clock(); } @@ -3910,7 +3910,7 @@ float DrasculaEngine::vez() { return _system->getMillis(); } -void DrasculaEngine::reduce_hare_chico(int x1,int y1, int x2,int y2, int ancho,int alto, int factor, byte *dir_inicio, byte *dir_fin) { +void DrasculaEngine::reduce_hare_chico(int xx1,int yy1, int xx2,int yy2, int ancho,int alto, int factor, byte *dir_inicio, byte *dir_fin) { float suma_x, suma_y; int n, m; float pixel_x, pixel_y; @@ -3922,15 +3922,15 @@ void DrasculaEngine::reduce_hare_chico(int x1,int y1, int x2,int y2, int ancho,i suma_x = ancho / nuevo_ancho; suma_y = alto / nuevo_alto; - pixel_x = x1; - pixel_y = y1; + pixel_x = xx1; + pixel_y = yy1; for (n = 0;n < nuevo_alto; n++){ for (m = 0; m < nuevo_ancho; m++){ - pos_pixel[0] = pixel_x; - pos_pixel[1] = pixel_y; - pos_pixel[2] = x2 + m; - pos_pixel[3] = y2 + n; + pos_pixel[0] = (int)pixel_x; + pos_pixel[1] = (int)pixel_y; + pos_pixel[2] = xx2 + m; + pos_pixel[3] = yy2 + n; pos_pixel[4] = 1; pos_pixel[5] = 1; @@ -3938,7 +3938,7 @@ void DrasculaEngine::reduce_hare_chico(int x1,int y1, int x2,int y2, int ancho,i pixel_x = pixel_x + suma_x; } - pixel_x = x1; + pixel_x = xx1; pixel_y = pixel_y + suma_y; } } @@ -3956,11 +3956,11 @@ void DrasculaEngine::cuadrante_1() { if (distancia_x < distancia_y) { direccion_hare = 0; sentido_hare = 2; - paso_x = distancia_x / (distancia_y / PASO_HARE_Y); + paso_x = (int)distancia_x / ((int)distancia_y / PASO_HARE_Y); } else { direccion_hare = 7; sentido_hare = 0; - paso_y = distancia_y / (distancia_x / PASO_HARE_X); + paso_y = (int)distancia_y / ((int)distancia_x / PASO_HARE_X); } } @@ -3973,11 +3973,11 @@ void DrasculaEngine::cuadrante_2() { if (distancia_x < distancia_y) { direccion_hare = 1; sentido_hare = 2; - paso_x = distancia_x / (distancia_y / PASO_HARE_Y); + paso_x = (int)distancia_x / ((int)distancia_y / PASO_HARE_Y); } else { direccion_hare = 2; sentido_hare = 1; - paso_y = distancia_y / (distancia_x / PASO_HARE_X); + paso_y = (int)distancia_y / ((int)distancia_x / PASO_HARE_X); } } @@ -3990,11 +3990,11 @@ void DrasculaEngine::cuadrante_3() { if (distancia_x < distancia_y) { direccion_hare = 5; sentido_hare = 3; - paso_x = distancia_x / (distancia_y / PASO_HARE_Y); + paso_x = (int)distancia_x / ((int)distancia_y / PASO_HARE_Y); } else { direccion_hare = 6; sentido_hare = 0; - paso_y = distancia_y / (distancia_x / PASO_HARE_X); + paso_y = (int)distancia_y / ((int)distancia_x / PASO_HARE_X); } } @@ -4007,11 +4007,11 @@ void DrasculaEngine::cuadrante_4() { if (distancia_x 6) { if (flags[12] == 1) { frame_borracho++; @@ -4074,7 +4074,7 @@ void DrasculaEngine::refresca_62_antes() { if (frame_piano == 9) frame_piano = 0; parpadeo = _rnd->getRandomNumber(10); - conta_ciego_vez = vez(); + conta_ciego_vez = (int)vez(); } } @@ -4143,12 +4143,12 @@ void DrasculaEngine::aumenta_num_frame() { } } - diferencia_y = alto_hare - nuevo_alto; - diferencia_x = ancho_hare - nuevo_ancho; + diferencia_y = alto_hare - (int)nuevo_alto; + diferencia_x = ancho_hare - (int)nuevo_ancho; hare_y = hare_y + diferencia_y; hare_x = hare_x + diferencia_x; - alto_hare = nuevo_alto; - ancho_hare = nuevo_ancho; + alto_hare = (int)nuevo_alto; + ancho_hare = (int)nuevo_ancho; } int DrasculaEngine::sobre_que_objeto() { diff --git a/engines/saga/sfuncs.cpp b/engines/saga/sfuncs.cpp index ef1ecd587f..b468d4482f 100644 --- a/engines/saga/sfuncs.cpp +++ b/engines/saga/sfuncs.cpp @@ -1418,7 +1418,7 @@ void Script::sfPlacardOff(SCRIPTFUNC_PARAMS) { void Script::sfPsychicProfile(SCRIPTFUNC_PARAMS) { int stringId; - Surface *backBuffer = _vm->_gfx->getBackBuffer(); + //Surface *backBuffer = _vm->_gfx->getBackBuffer(); static PalEntry cur_pal[PAL_ENTRIES]; PalEntry *pal; Event event; -- cgit v1.2.3 From 4abcd58c76434c3bc995fc92c9d6223d4f577a32 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 1 Aug 2007 02:19:05 +0000 Subject: Updated the ITE demo versions svn-id: r28379 --- engines/saga/detection_tables.h | 90 +++++++++++++++++++++++++++++++---------- engines/saga/sprite.cpp | 4 +- 2 files changed, 72 insertions(+), 22 deletions(-) (limited to 'engines') diff --git a/engines/saga/detection_tables.h b/engines/saga/detection_tables.h index 832d7b34d4..f051c27e9d 100644 --- a/engines/saga/detection_tables.h +++ b/engines/saga/detection_tables.h @@ -127,8 +127,6 @@ static const GameSoundInfo ITEMACDEMO_GameSound = { true }; -/* -// Not used static const GameSoundInfo ITEMACDEMO_GameMusic = { kSoundPCM, 11025, @@ -137,7 +135,6 @@ static const GameSoundInfo ITEMACDEMO_GameMusic = { false, true }; -*/ // Inherit the Earth - Wyrmkeep Linux Demo version static const GameSoundInfo ITELINDEMO_GameMusic = { @@ -322,8 +319,13 @@ static const GameSoundInfo IHNM_GameSound = { static const SAGAGameDescription gameDescriptions[] = { // ITE Section //////////////////////////////////////////////////////////////////////////////////////////// + + // ITE Demos ////////////////////////////////////////////////////////////////////////////////////////////// +#if 0 + // Based on a very early version of the engine. Not supported yet + // Inherit the earth - DOS Demo version // sound unchecked { @@ -354,16 +356,50 @@ static const SAGAGameDescription gameDescriptions[] = { 0, NULL, }, +#endif + + // Inherit the earth - MAC Demo version + { + { + "ite", + "Demo 2", + { + {"ited.rsc", GAME_RESOURCEFILE, "addfc9d82bc2fa1f4cab23743c652c08", 1865461}, + {"scriptsd.rsc", GAME_SCRIPTFILE, "fded5c59b8b7c5976229f960d21e6b0b", 70083}, + //{"soundsd.rsc", GAME_SOUNDFILE, "b3a831fbed337d1f1300fee1dd474f6c", -1}, + //{"voicesd.rsc", GAME_VOICEFILE, "e139d86bab2ee8ba3157337f894a92d4", -1}, + //{"musicd.rsc", GAME_MUSICFILE, "495bdde51fd9f4bea2b9c911091b1ab2", -1}, + { NULL, 0, NULL, 0} + }, + Common::EN_ANY, + Common::kPlatformMacintosh, + Common::ADGF_DEMO + }, + GType_ITE, + GID_ITE_MACDEMO2, + GF_BIG_ENDIAN_DATA | GF_WYRMKEEP | GF_CD_FX | GF_SCENE_SUBSTITUTES, + ITE_DEFAULT_SCENE, + &ITE_Resources, + ARRAYSIZE(ITEWINDEMO_GameFonts), + ITEWINDEMO_GameFonts, + &ITEMACDEMO_GameVoice, + &ITEMACDEMO_GameSound, + &ITEMACDEMO_GameMusic, + ARRAYSIZE(ITEMacPatch_Files), + ITEMacPatch_Files, + }, + +#if 0 + // Currently broken, exiting the faire leads to a crash - // Inherit the earth - MAC Demo version 1 and 2 - // Demo 1 has normal scenes, demo 2 has scene substitutes but the files are the same (apart from musicd.rsc) + // Inherit the earth - MAC Demo version 1 { { "ite", - "Demo 1/2", + "Demo 1", { - {"ited.rsc", GAME_RESOURCEFILE, "addfc9d82bc2fa1f4cab23743c652c08", -1}, - {"scriptsd.rsc", GAME_SCRIPTFILE, "fded5c59b8b7c5976229f960d21e6b0b", -1}, + {"ited.rsc", GAME_RESOURCEFILE, "addfc9d82bc2fa1f4cab23743c652c08", 1131098}, + {"scriptsd.rsc", GAME_SCRIPTFILE, "fded5c59b8b7c5976229f960d21e6b0b", 38613}, //{"soundsd.rsc", GAME_SOUNDFILE, "b3a831fbed337d1f1300fee1dd474f6c", -1}, //{"voicesd.rsc", GAME_VOICEFILE, "e139d86bab2ee8ba3157337f894a92d4", -1}, //{"musicd.rsc", GAME_MUSICFILE, "1a91cd60169f367ecb6c6e058d899b2f", -1}, @@ -386,20 +422,19 @@ static const SAGAGameDescription gameDescriptions[] = { ARRAYSIZE(ITEMacPatch_Files), ITEMacPatch_Files, }, +#endif // Inherit the earth - Win32 Demo version 2/3, Linux Demo version // Win32 Version 3 and Linux Demo version have digital music, Win32 version 2 has MIDI music - // These demos have scene substitutes, and can only be distinguished from Win32 demo 1 (below) - // from soundsd.rsc and voicesd.rsc { { "ite", "Win Demo 2/3, Linux Demo", { - {"ited.rsc", GAME_RESOURCEFILE, "3a450852cbf3c80773984d565647e6ac", -1}, - {"scriptsd.rsc", GAME_SCRIPTFILE, "3f12b67fa93e56e1a6be39d2921d80bb", -1}, - {"soundsd.rsc", GAME_SOUNDFILE, "95a6c148e22e99a8c243f2978223583c", -1}, - {"voicesd.rsc", GAME_VOICEFILE, "e139d86bab2ee8ba3157337f894a92d4", -1}, + {"ited.rsc", GAME_RESOURCEFILE, "3a450852cbf3c80773984d565647e6ac", 1951395}, + {"scriptsd.rsc", GAME_SCRIPTFILE, "3f12b67fa93e56e1a6be39d2921d80bb", 70051}, + //{"soundsd.rsc", GAME_SOUNDFILE, "95a6c148e22e99a8c243f2978223583c", -1}, + //{"voicesd.rsc", GAME_VOICEFILE, "e139d86bab2ee8ba3157337f894a92d4", -1}, //{"musicd.rsc", GAME_MUSICFILE, "d6454756517f042f01210458abe8edd4", -1}, { NULL, 0, NULL, 0} }, @@ -421,18 +456,19 @@ static const SAGAGameDescription gameDescriptions[] = { ITEPatch_Files, }, +#if 0 + // Currently broken, exiting the faire leads to a crash + // Inherit the earth - Win32 Demo version 1 - // Demo version 1 does not have scene substitutes, and can only be distinguished from demo 2/3 - // from soundsd.rsc and voicesd.rsc { { "ite", "Demo 1", { - {"ited.rsc", GAME_RESOURCEFILE, "3a450852cbf3c80773984d565647e6ac", -1}, - {"scriptsd.rsc", GAME_SCRIPTFILE, "3f12b67fa93e56e1a6be39d2921d80bb", -1}, - {"soundsd.rsc", GAME_SOUNDFILE, "a741139dd7365a13f463cd896ff9969a", -1}, - {"voicesd.rsc", GAME_VOICEFILE, "0759eaf5b64ae19fd429920a70151ad3", -1}, + {"ited.rsc", GAME_RESOURCEFILE, "3a450852cbf3c80773984d565647e6ac", 1327323}, + {"scriptsd.rsc", GAME_SCRIPTFILE, "3f12b67fa93e56e1a6be39d2921d80bb", 38613}, + //{"soundsd.rsc", GAME_SOUNDFILE, "a741139dd7365a13f463cd896ff9969a", -1}, + //{"voicesd.rsc", GAME_VOICEFILE, "0759eaf5b64ae19fd429920a70151ad3", -1}, { NULL, 0, NULL, 0} }, Common::EN_ANY, @@ -452,6 +488,10 @@ static const SAGAGameDescription gameDescriptions[] = { ARRAYSIZE(ITEPatch_Files), ITEPatch_Files, }, +#endif + + // TODO: Add Amiga demos here (not supported yet) + // ITE Mac versions /////////////////////////////////////////////////////////////////////////////////////// @@ -517,7 +557,8 @@ static const SAGAGameDescription gameDescriptions[] = { ITEMacPatch_Files, }, - // ITE CD versions //////////////////////////////////////////////////////////////////////////////////////// + + // ITE PC CD versions ////////////////////////////////////////////////////////////////////////////////////// // Inherit the earth - Wyrmkeep combined Windows/Mac/Linux CD @@ -647,6 +688,7 @@ static const SAGAGameDescription gameDescriptions[] = { NULL, }, + // ITE floppy versions //////////////////////////////////////////////////////////////////////////////////// // Inherit the earth - German Floppy version @@ -707,6 +749,12 @@ static const SAGAGameDescription gameDescriptions[] = { ITEPatch_Files, }, + + // ITE Amiga versions ///////////////////////////////////////////////////////////////////////////////////// + + // TODO: Add the Amiga versions here (not supported yet) + + // IHNM Section /////////////////////////////////////////////////////////////////////////////////////////// // I Have No Mouth And I Must Scream - Demo version diff --git a/engines/saga/sprite.cpp b/engines/saga/sprite.cpp index 1a70a44bbd..ac911e5a9c 100644 --- a/engines/saga/sprite.cpp +++ b/engines/saga/sprite.cpp @@ -119,7 +119,9 @@ void Sprite::loadList(int resourceId, SpriteList &spriteList) { offset = readS.readUint16(); if (offset >= spriteListLength) { - error("Sprite::loadList offset exceed"); + // ITE Mac demos throw this warning + warning("Sprite::loadList offset exceeded"); + return; } spritePointer = spriteListData; -- cgit v1.2.3 From b58d259f7ee00f6cff86afc48f713979db8a31a0 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 1 Aug 2007 02:37:29 +0000 Subject: The psychic profile background is displayed correctly again svn-id: r28380 --- engines/saga/events.cpp | 3 ++- engines/saga/sfuncs.cpp | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/saga/events.cpp b/engines/saga/events.cpp index b7f65b9f83..80e6b58595 100644 --- a/engines/saga/events.cpp +++ b/engines/saga/events.cpp @@ -364,8 +364,9 @@ int Events::handleOneShot(Event *event) { const PalEntry *palette = (const PalEntry *)_vm->getImagePal(resourceData, resourceDataLength); Surface *bgSurface = _vm->_render->getBackGroundSurface(); + const Rect profileRect(width, height); - bgSurface->blit(rect, buf); + bgSurface->blit(profileRect, buf); _vm->_frameCount++; _vm->_gfx->setPalette(palette); diff --git a/engines/saga/sfuncs.cpp b/engines/saga/sfuncs.cpp index b468d4482f..c0e105a8fd 100644 --- a/engines/saga/sfuncs.cpp +++ b/engines/saga/sfuncs.cpp @@ -1418,7 +1418,6 @@ void Script::sfPlacardOff(SCRIPTFUNC_PARAMS) { void Script::sfPsychicProfile(SCRIPTFUNC_PARAMS) { int stringId; - //Surface *backBuffer = _vm->_gfx->getBackBuffer(); static PalEntry cur_pal[PAL_ENTRIES]; PalEntry *pal; Event event; -- cgit v1.2.3 From e68624e7893f34dcf2d25df6ee536daf46d2f993 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 1 Aug 2007 09:02:28 +0000 Subject: Patch files are no longer left open the whole time, but are only opened when needed. This fixes the strange bug where BBM files didn't appear in the ITE demos that have substitute scenes when using MSVC compiled executables, as too many files were open at the same time svn-id: r28381 --- engines/saga/rscfile.cpp | 3 +++ engines/saga/rscfile.h | 2 ++ engines/saga/saga.cpp | 24 ------------------------ 3 files changed, 5 insertions(+), 24 deletions(-) (limited to 'engines') diff --git a/engines/saga/rscfile.cpp b/engines/saga/rscfile.cpp index 126cb58344..0aa7e2eafe 100644 --- a/engines/saga/rscfile.cpp +++ b/engines/saga/rscfile.cpp @@ -330,6 +330,7 @@ bool Resource::loadContext(ResourceContext *context) { if (resourceData->patchData->_patchFile->open(patchDescription->fileName)) { resourceData->offset = 0; resourceData->size = resourceData->patchData->_patchFile->size(); + resourceData->patchData->_patchFile->close(); } else { delete resourceData->patchData; resourceData->patchData = NULL; @@ -544,6 +545,8 @@ void Resource::loadResource(ResourceContext *context, uint32 resourceId, byte*&r if (file->read(resourceBuffer, resourceSize) != resourceSize) { error("Resource::loadResource() failed to read"); } + if (resourceData->patchData != NULL) + file->close(); } static int metaResourceTable[] = { 0, 326, 517, 677, 805, 968, 1165, 0, 1271 }; diff --git a/engines/saga/rscfile.h b/engines/saga/rscfile.h index f8b6ddc3be..2df3b2eb7c 100644 --- a/engines/saga/rscfile.h +++ b/engines/saga/rscfile.h @@ -83,6 +83,8 @@ struct ResourceContext { Common::File *getFile(ResourceData *resourceData) const { if (resourceData->patchData != NULL) { + if (!resourceData->patchData->_patchFile->isOpen()) + resourceData->patchData->_patchFile->open(resourceData->patchData->_patchDescription->fileName); return resourceData->patchData->_patchFile; } else { return file; diff --git a/engines/saga/saga.cpp b/engines/saga/saga.cpp index 35cb8b2647..76731c201a 100644 --- a/engines/saga/saga.cpp +++ b/engines/saga/saga.cpp @@ -233,30 +233,6 @@ int SagaEngine::init() { _voicesEnabled = true; } - // WORKAROUND for a weird bug that I haven't been able to understand. - // In some ITE demos, scenes are substituted with pictures, which are - // loaded instead of the actual scene in Scene::changeScene(). The - // weird phenomenon is that NO files can be opened or found in that - // function. However, file existence works in other parts of the engine. - // The strange thing is that if we add a dummy file existence check here - // (or in any part of init() or go()) for a file that exists (it doesn't - // work if the file doesn't exist), files are opened correctly in the - // function. I don't know if this is a bug of the Common::File class or - // of the SAGA engine itself (or perhaps of a clashing definition?), but - // still, it's very strange that a file existence check fixes things. In - // both cases (with and without this dummy check here), the Common::File - // open function called from Scene::changeScene() finds the file through - // the _filesMap, but without this dummy check here, the handle returned - // is 0 - // To reproduce: run any of the ITE demos that has scene substitutes like, - // for example, the ITE demo from Wyrmkeep's site. Enter the game, and - // exit the faire (to speed things up, open the debug console and type - // "scene_change 1", close the console and visit any place other than - // the faire) - // Since the files we need are BBM files, just check for the existence - // of one file of them here - if (Common::File::exists("tycho.bbm")) {} - // FIXME: This is the ugly way of reducing redraw overhead. It works // well for 320x200 but it's unclear how well it will work for // 640x480. -- cgit v1.2.3 From 5d7daad632f757621476e29b8de1ee47512948ba Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 1 Aug 2007 09:08:27 +0000 Subject: Re-enabled the problematic older ITE demos (with notes on their current problems) svn-id: r28382 --- engines/saga/detection_tables.h | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'engines') diff --git a/engines/saga/detection_tables.h b/engines/saga/detection_tables.h index f051c27e9d..c4bd4fd7b3 100644 --- a/engines/saga/detection_tables.h +++ b/engines/saga/detection_tables.h @@ -323,8 +323,8 @@ static const SAGAGameDescription gameDescriptions[] = { // ITE Demos ////////////////////////////////////////////////////////////////////////////////////////////// -#if 0 - // Based on a very early version of the engine. Not supported yet + // Note: This version is NOT supported yet + // Based on a very early version of the engine // Inherit the earth - DOS Demo version // sound unchecked @@ -356,7 +356,7 @@ static const SAGAGameDescription gameDescriptions[] = { 0, NULL, }, -#endif + // Inherit the earth - MAC Demo version { @@ -389,8 +389,9 @@ static const SAGAGameDescription gameDescriptions[] = { ITEMacPatch_Files, }, -#if 0 - // Currently broken, exiting the faire leads to a crash + + // Note: This version is NOT supported yet + // Exiting the faire leads to a crash // Inherit the earth - MAC Demo version 1 { @@ -422,7 +423,7 @@ static const SAGAGameDescription gameDescriptions[] = { ARRAYSIZE(ITEMacPatch_Files), ITEMacPatch_Files, }, -#endif + // Inherit the earth - Win32 Demo version 2/3, Linux Demo version // Win32 Version 3 and Linux Demo version have digital music, Win32 version 2 has MIDI music @@ -456,8 +457,9 @@ static const SAGAGameDescription gameDescriptions[] = { ITEPatch_Files, }, -#if 0 - // Currently broken, exiting the faire leads to a crash + + // Note: This version is NOT supported yet + // Exiting the faire leads to a crash // Inherit the earth - Win32 Demo version 1 { @@ -488,7 +490,7 @@ static const SAGAGameDescription gameDescriptions[] = { ARRAYSIZE(ITEPatch_Files), ITEPatch_Files, }, -#endif + // TODO: Add Amiga demos here (not supported yet) -- cgit v1.2.3 From 35052de25feca6ff2a27c4f2434280939e20dd09 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Wed, 1 Aug 2007 12:24:04 +0000 Subject: Support for (still a bit glitchy) 16bit sound svn-id: r28383 --- engines/gob/coktelvideo.cpp | 158 ++++++++++++++++++++++++++++++++++---------- engines/gob/coktelvideo.h | 15 ++++- 2 files changed, 138 insertions(+), 35 deletions(-) (limited to 'engines') diff --git a/engines/gob/coktelvideo.cpp b/engines/gob/coktelvideo.cpp index 864a760ea8..cd497293af 100644 --- a/engines/gob/coktelvideo.cpp +++ b/engines/gob/coktelvideo.cpp @@ -109,7 +109,7 @@ bool Imd::load(Common::SeekableReadStream &stream) { // Sound if (_features & kFeaturesSound) { _soundFreq = _stream->readSint16LE(); - _soundSliceSize = _stream->readUint16LE(); + _soundSliceSize = _stream->readSint16LE(); _soundSlicesCount = _stream->readSint16LE(); if (_soundFreq < 0) @@ -540,6 +540,7 @@ CoktelVideo::State Imd::processFrame(uint16 frame) { assert(soundBuf); memset(soundBuf, 0, _soundSliceSize); + _audioStream->queueBuffer(soundBuf, _soundSliceSize); } } @@ -819,6 +820,22 @@ void Imd::deLZ77(byte *dest, byte *src) { } } +const uint16 Vmd::_tableDPCM[128] = { + 0x0000, 0x0008, 0x0010, 0x0020, 0x0030, 0x0040, 0x0050, 0x0060, 0x0070, 0x0080, + 0x0090, 0x00A0, 0x00B0, 0x00C0, 0x00D0, 0x00E0, 0x00F0, 0x0100, 0x0110, 0x0120, + 0x0130, 0x0140, 0x0150, 0x0160, 0x0170, 0x0180, 0x0190, 0x01A0, 0x01B0, 0x01C0, + 0x01D0, 0x01E0, 0x01F0, 0x0200, 0x0208, 0x0210, 0x0218, 0x0220, 0x0228, 0x0230, + 0x0238, 0x0240, 0x0248, 0x0250, 0x0258, 0x0260, 0x0268, 0x0270, 0x0278, 0x0280, + 0x0288, 0x0290, 0x0298, 0x02A0, 0x02A8, 0x02B0, 0x02B8, 0x02C0, 0x02C8, 0x02D0, + 0x02D8, 0x02E0, 0x02E8, 0x02F0, 0x02F8, 0x0300, 0x0308, 0x0310, 0x0318, 0x0320, + 0x0328, 0x0330, 0x0338, 0x0340, 0x0348, 0x0350, 0x0358, 0x0360, 0x0368, 0x0370, + 0x0378, 0x0380, 0x0388, 0x0390, 0x0398, 0x03A0, 0x03A8, 0x03B0, 0x03B8, 0x03C0, + 0x03C8, 0x03D0, 0x03D8, 0x03E0, 0x03E8, 0x03F0, 0x03F8, 0x0400, 0x0440, 0x0480, + 0x04C0, 0x0500, 0x0540, 0x0580, 0x05C0, 0x0600, 0x0640, 0x0680, 0x06C0, 0x0700, + 0x0740, 0x0780, 0x07C0, 0x0800, 0x0900, 0x0A00, 0x0B00, 0x0C00, 0x0D00, 0x0E00, + 0x0F00, 0x1000, 0x1400, 0x1800, 0x1C00, 0x2000, 0x3000, 0x4000 +}; + Vmd::Vmd() { clear(false); } @@ -880,7 +897,7 @@ bool Vmd::load(Common::SeekableReadStream &stream) { } _soundFreq = _stream->readSint16LE(); - _soundSliceSize = _stream->readUint16LE(); + _soundSliceSize = _stream->readSint16LE(); _soundSlicesCount = _stream->readSint16LE(); _soundFlags = _stream->readUint16LE(); _hasSound = (_soundFreq != 0); @@ -888,11 +905,26 @@ bool Vmd::load(Common::SeekableReadStream &stream) { if (_hasSound) { _features |= kFeaturesSound; - _soundSliceLength = (uint16) (1000.0 / ((double) _soundFreq / (double) _soundSliceSize)); + _soundStereo = (_soundFlags & 0x8000) ? 1 : ((_soundFlags & 0x200) ? 2 : 0); + if (_soundStereo > 0) { + warning("TODO: VMD stereo"); + unload(); + return false; + } + + if (_soundSliceSize < 0) { + _soundBytesPerSample = 2; + _soundSliceSize = -_soundSliceSize; + } + + _soundSliceLength = (uint16) (1000.0 / + ((double) _soundFreq / (double) _soundSliceSize)); + _frameLength = _soundSliceLength; _soundStage = 1; - _audioStream = Audio::makeAppendableAudioStream(_soundFreq, 0); + _audioStream = Audio::makeAppendableAudioStream(_soundFreq, + (_soundBytesPerSample == 2) ? Audio::Mixer::FLAG_16BITS : 0); } else _frameLength = 1000 / 12; // 12 FPS for a video without sound @@ -1004,8 +1036,12 @@ void Vmd::clear(bool del) { } _hasVideo = true; + _partsPerFrame = 0; _frames = 0; + + _soundBytesPerSample = 1; + _soundStereo = 0; } CoktelVideo::State Vmd::processFrame(uint16 frame) { @@ -1027,39 +1063,23 @@ CoktelVideo::State Vmd::processFrame(uint16 frame) { Part &part = _frames[frame].parts[i]; if (part.type == kPartTypeAudio) { - byte *soundBuf; - // Next sound slice data if (part.flags == 1) { - if (_soundEnabled) { - soundBuf = new byte[part.size]; - assert(soundBuf); - - _stream->read(soundBuf, part.size); - unsignedToSigned(soundBuf, part.size); - - _audioStream->queueBuffer(soundBuf, part.size); - } else + if (_soundEnabled) + filledSoundSlice(part.size); + else _stream->skip(part.size); // Initial sound data (all slices) } else if (part.flags == 2) { if (_soundEnabled) { - _stream->skip(4); // Unknown - - soundBuf = new byte[part.size - 4]; - assert(soundBuf); - - _stream->read(soundBuf, part.size - 4); - unsignedToSigned(soundBuf, part.size - 4); + uint32 mask = _stream->readUint32LE(); + filledSoundSlices(part.size - 4, mask); - _audioStream->queueBuffer(soundBuf, part.size - 4); - - if (_soundStage == 1) { + if (_soundStage == 1) startSound = true; - } } else _stream->skip(part.size); @@ -1067,15 +1087,11 @@ CoktelVideo::State Vmd::processFrame(uint16 frame) { // Empty sound slice } else if (part.flags == 3) { - if (_soundEnabled && (part.size > 0)) { - soundBuf = new byte[part.size]; - assert(soundBuf); - - memset(soundBuf, 0, part.size); - - _audioStream->queueBuffer(soundBuf, part.size); - } else + if (_soundEnabled && (part.size > 0)) + emptySoundSlice(part.size); + else _stream->skip(part.size); + } } else if (part.type == kPartTypeVideo) { @@ -1194,4 +1210,78 @@ uint32 Vmd::renderFrame(int16 left, int16 top, int16 right, int16 bottom) { return 1; } +void Vmd::emptySoundSlice(uint32 size) { + byte *soundBuf = new byte[size]; + assert(soundBuf); + + memset(soundBuf, 0, size); + + _audioStream->queueBuffer(soundBuf, size); +} + +void Vmd::soundSlice8bit(uint32 size) { + byte *soundBuf = new byte[size]; + assert(soundBuf); + + _stream->read(soundBuf, size); + unsignedToSigned(soundBuf, size); + + _audioStream->queueBuffer(soundBuf, size); +} + +void Vmd::soundSlice16bit(uint32 size, int16 &init) { + byte *dataBuf = new byte[size]; + byte *soundBuf = new byte[size * 2]; + + _stream->read(dataBuf, size); + deDPCM(soundBuf, dataBuf, init, size); + _audioStream->queueBuffer(soundBuf, size * 2); + + delete[] dataBuf; +} + +void Vmd::filledSoundSlice(uint32 size) { + if (_soundBytesPerSample == 1) { + soundSlice8bit(size); + } else if (_soundBytesPerSample == 2) { + int16 init = _stream->readSint16LE(); + soundSlice16bit(size - 1, init); + } +} + +void Vmd::filledSoundSlices(uint32 size, uint32 mask) { + if (_soundBytesPerSample == 1) { + soundSlice8bit(size); + return; + } + + for (int i = 0; i < (_soundSlicesCount - 1); i++) { + + if (mask & 1) + emptySoundSlice(_soundSliceSize * 2); + else { + int16 init = _stream->readSint16LE(); + soundSlice16bit(_soundSliceSize, init); + } + + mask >>= 1; + } + +} + +void Vmd::deDPCM(byte *soundBuf, byte *dataBuf, int16 &init, uint32 n) { + int16 *out = (int16 *) soundBuf; + + int32 s = init; + for (uint32 i = 0; i < n; i++) { + if(dataBuf[i] & 0x80) + s -= _tableDPCM[dataBuf[i] & 0x7F]; + else + s += _tableDPCM[dataBuf[i]]; + + s = CLIP(s, -32768, 32767); + *out++ = TO_BE_16(s); + } +} + } // End of namespace Gob diff --git a/engines/gob/coktelvideo.h b/engines/gob/coktelvideo.h index 39228c7bca..a4e5452cce 100644 --- a/engines/gob/coktelvideo.h +++ b/engines/gob/coktelvideo.h @@ -225,7 +225,7 @@ protected: uint16 _soundFlags; int16 _soundFreq; - uint16 _soundSliceSize; + int16 _soundSliceSize; int16 _soundSlicesCount; uint16 _soundSliceLength; @@ -285,14 +285,27 @@ protected: ~Frame() { delete[] parts; } } PACKED_STRUCT; + static const uint16 _tableDPCM[128]; + bool _hasVideo; + uint16 _partsPerFrame; Frame *_frames; + byte _soundBytesPerSample; + byte _soundStereo; // (0: mono, 1: old-style stereo, 2: new-style stereo) + void clear(bool del = true); State processFrame(uint16 frame); uint32 renderFrame(int16 left, int16 top, int16 right, int16 bottom); + + void emptySoundSlice(uint32 size); + void soundSlice8bit(uint32 size); + void soundSlice16bit(uint32 size, int16 &init); + void filledSoundSlice(uint32 size); + void filledSoundSlices(uint32 size, uint32 mask); + void deDPCM(byte *soundBuf, byte *dataBuf, int16 &init, uint32 n); }; } // End of namespace Gob -- cgit v1.2.3 From e5bd393a8939bd8464cfd65e6ee0fe6c0fd05462 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 1 Aug 2007 14:19:55 +0000 Subject: Compressed sounds now work in IHNM svn-id: r28384 --- engines/saga/detection.cpp | 19 ++++++--- engines/saga/detection_tables.h | 95 +++++++++++++++++------------------------ engines/saga/rscfile.cpp | 87 +++++++++++++++++++++++++++++++------ engines/saga/sndres.cpp | 10 +++-- 4 files changed, 133 insertions(+), 78 deletions(-) (limited to 'engines') diff --git a/engines/saga/detection.cpp b/engines/saga/detection.cpp index 7f154afbda..d5e12a66f3 100644 --- a/engines/saga/detection.cpp +++ b/engines/saga/detection.cpp @@ -150,11 +150,20 @@ bool SagaEngine::initGame() { } // If a compressed sound file is found in the game's directory, set the compressed flag to true - if (Common::File::exists("sounds.cmp") || Common::File::exists("soundsd.cmp") || - Common::File::exists("voices.cmp") || Common::File::exists("voicesd.cmp") || - Common::File::exists("inherit the earth voices.cmp")) { - _gf_compressed_sounds = true; - } + if (_gameDescription->gameType == GType_ITE) { + if (Common::File::exists("sounds.cmp") || Common::File::exists("soundsd.cmp") || + Common::File::exists("voices.cmp") || Common::File::exists("voicesd.cmp") || + Common::File::exists("inherit the earth voices.cmp")) { + _gf_compressed_sounds = true; + } + } else { + if (Common::File::exists("voicess.cmp") || Common::File::exists("voices1.cmp") || + Common::File::exists("voices2.cmp") || Common::File::exists("voices3.cmp") || + Common::File::exists("voices4.cmp") || Common::File::exists("voices5.cmp") || + Common::File::exists("voices6.cmp") || Common::File::exists("voicesd.cmp")) { + _gf_compressed_sounds = true; + } + } return _resource->createContexts(); } diff --git a/engines/saga/detection_tables.h b/engines/saga/detection_tables.h index c4bd4fd7b3..4bcbb004a0 100644 --- a/engines/saga/detection_tables.h +++ b/engines/saga/detection_tables.h @@ -65,15 +65,6 @@ static const GameFontDescription ITEDEMO_GameFonts[] = { {1} }; -static const GameSoundInfo ITEDEMO_GameSound = { - kSoundVOC, - -1, - -1, - false, - false, - true -}; - // Inherit the Earth - Wyrmkeep Win32 Demo version static const GameFontDescription ITEWINDEMO_GameFonts[] = { @@ -136,16 +127,6 @@ static const GameSoundInfo ITEMACDEMO_GameMusic = { true }; -// Inherit the Earth - Wyrmkeep Linux Demo version -static const GameSoundInfo ITELINDEMO_GameMusic = { - kSoundPCM, - 11025, - 16, - true, - false, - true -}; - static const GameSoundInfo ITEMACCD_G_GameSound = { kSoundMacPCM, 22050, @@ -336,7 +317,7 @@ static const SAGAGameDescription gameDescriptions[] = { {"ite.rsc", GAME_RESOURCEFILE, "986c79c4d2939dbe555576529fd37932", -1}, //{"ite.dmo", GAME_DEMOFILE}, "0b9a70eb4e120b6f00579b46c8cae29e" {"scripts.rsc", GAME_SCRIPTFILE, "d5697dd3240a3ceaddaa986c47e1a2d7", -1}, - {"voices.rsc", GAME_SOUNDFILE | GAME_VOICEFILE, "c58e67c506af4ffa03fd0aac2079deb0", -1}, + //{"voices.rsc", GAME_SOUNDFILE | GAME_VOICEFILE, "c58e67c506af4ffa03fd0aac2079deb0", -1}, { NULL, 0, NULL, 0} }, Common::EN_ANY, @@ -350,8 +331,8 @@ static const SAGAGameDescription gameDescriptions[] = { &ITEDemo_Resources, ARRAYSIZE(ITEDEMO_GameFonts), ITEDEMO_GameFonts, - &ITEDEMO_GameSound, - &ITEDEMO_GameSound, + &ITEDISK_GameSound, + &ITEDISK_GameSound, &ITEMACCD_GameMusic, // note: this version did not originally have digital music 0, NULL, @@ -452,7 +433,7 @@ static const SAGAGameDescription gameDescriptions[] = { ITEWINDEMO_GameFonts, &ITEWINDEMO2_GameVoice, &ITEWINDEMO2_GameSound, - &ITELINDEMO_GameMusic, + &ITEMACCD_GameMusic, ARRAYSIZE(ITEPatch_Files), ITEPatch_Files, }, @@ -769,7 +750,7 @@ static const SAGAGameDescription gameDescriptions[] = { {"scream.res", GAME_RESOURCEFILE, "46bbdc65d164ba7e89836a0935eec8e6", -1}, {"scripts.res", GAME_SCRIPTFILE, "9626bda8978094ff9b29198bc1ed5f9a", -1}, {"sfx.res", GAME_SOUNDFILE, "1c610d543f32ec8b525e3f652536f269", -1}, - {"voicesd.res", GAME_VOICEFILE, "3bbc16a8f741dbb511da506c660a0b54", -1}, + //{"voicesd.res", GAME_VOICEFILE, "3bbc16a8f741dbb511da506c660a0b54", -1}, { NULL, 0, NULL, 0} }, Common::EN_ANY, @@ -802,13 +783,13 @@ static const SAGAGameDescription gameDescriptions[] = { {"patch.re_", GAME_PATCHFILE | GAME_RESOURCEFILE, "58b79e61594779513c7f2d35509fa89e", -1}, {"scripts.res", GAME_SCRIPTFILE, "be38bbc5a26be809dbf39f13befebd01", -1}, {"sfx.res", GAME_SOUNDFILE, "1c610d543f32ec8b525e3f652536f269", -1}, - {"voicess.res", GAME_VOICEFILE, "54b1f2013a075338ceb0e258d97808bd", -1}, //order of voice bank file is important - {"voices1.res", GAME_VOICEFILE, "fc6440b38025f4b2cc3ff55c3da5c3eb", -1}, - {"voices2.res", GAME_VOICEFILE, "b37f10fd1696ade7d58704ccaaebceeb", -1}, - {"voices3.res", GAME_VOICEFILE, "3bbc16a8f741dbb511da506c660a0b54", -1}, - {"voices4.res", GAME_VOICEFILE, "ebfa160122d2247a676ca39920e5d481", -1}, - {"voices5.res", GAME_VOICEFILE, "1f501ce4b72392bdd1d9ec38f6eec6da", -1}, - {"voices6.res", GAME_VOICEFILE, "f580ed7568c7d6ef34e934ba20adf834", -1}, + //{"voicess.res", GAME_VOICEFILE, "54b1f2013a075338ceb0e258d97808bd", -1}, //order of voice bank file is important + //{"voices1.res", GAME_VOICEFILE, "fc6440b38025f4b2cc3ff55c3da5c3eb", -1}, + //{"voices2.res", GAME_VOICEFILE, "b37f10fd1696ade7d58704ccaaebceeb", -1}, + //{"voices3.res", GAME_VOICEFILE, "3bbc16a8f741dbb511da506c660a0b54", -1}, + //{"voices4.res", GAME_VOICEFILE, "ebfa160122d2247a676ca39920e5d481", -1}, + //{"voices5.res", GAME_VOICEFILE, "1f501ce4b72392bdd1d9ec38f6eec6da", -1}, + //{"voices6.res", GAME_VOICEFILE, "f580ed7568c7d6ef34e934ba20adf834", -1}, { NULL, 0, NULL, 0} }, Common::EN_ANY, @@ -843,12 +824,12 @@ static const SAGAGameDescription gameDescriptions[] = { {"scripts.res", GAME_SCRIPTFILE, "32aa01a89937520fe0ea513950117292", -1}, {"patch.re_", GAME_PATCHFILE | GAME_RESOURCEFILE, "58b79e61594779513c7f2d35509fa89e", -1}, {"sfx.res", GAME_SOUNDFILE, "1c610d543f32ec8b525e3f652536f269", -1}, - {"voicess.res", GAME_VOICEFILE, "8b09a196a52627cacb4eab13bfe0b2c3", -1}, //order of voice bank file is important - {"voices1.res", GAME_VOICEFILE, "424971e1e2373187c3f5734fe36071a2", -1}, - {"voices2.res", GAME_VOICEFILE, "c270e0980782af43641a86e4a14e2a32", -1}, - {"voices3.res", GAME_VOICEFILE, "49e42befea883fd101ec3d0f5d0647b9", -1}, - {"voices5.res", GAME_VOICEFILE, "c477443c52a0aa56e686ebd8d051e4ab", -1}, - {"voices6.res", GAME_VOICEFILE, "2b9aea838f74b4eecfb29a8f205a2bd4", -1}, + //{"voicess.res", GAME_VOICEFILE, "8b09a196a52627cacb4eab13bfe0b2c3", -1}, //order of voice bank file is important + //{"voices1.res", GAME_VOICEFILE, "424971e1e2373187c3f5734fe36071a2", -1}, + //{"voices2.res", GAME_VOICEFILE, "c270e0980782af43641a86e4a14e2a32", -1}, + //{"voices3.res", GAME_VOICEFILE, "49e42befea883fd101ec3d0f5d0647b9", -1}, + //{"voices5.res", GAME_VOICEFILE, "c477443c52a0aa56e686ebd8d051e4ab", -1}, + //{"voices6.res", GAME_VOICEFILE, "2b9aea838f74b4eecfb29a8f205a2bd4", -1}, { NULL, 0, NULL, 0} }, Common::DE_DEU, @@ -881,13 +862,13 @@ static const SAGAGameDescription gameDescriptions[] = { {"patch.re_", GAME_PATCHFILE | GAME_RESOURCEFILE, "58b79e61594779513c7f2d35509fa89e", -1}, {"scripts.res", GAME_SCRIPTFILE, "be38bbc5a26be809dbf39f13befebd01", -1}, {"sfx.res", GAME_SOUNDFILE, "1c610d543f32ec8b525e3f652536f269", -1}, - {"voicess.res", GAME_VOICEFILE, "d869de9883c8faea7f687217a9ec7057", -1}, //order of voice bank file is important - {"voices1.res", GAME_VOICEFILE, "dc6a34e3d1668730ea46815a92c7847f", -1}, - {"voices2.res", GAME_VOICEFILE, "dc6a5fa7a4cdc2ca5a6fd924e969986c", -1}, - {"voices3.res", GAME_VOICEFILE, "dc6a5fa7a4cdc2ca5a6fd924e969986c", -1}, - {"voices4.res", GAME_VOICEFILE, "0f87400b804232a58dd22e404420cc45", -1}, - {"voices5.res", GAME_VOICEFILE, "172668cfc5d8c305cb5b1a9b4d995fc0", -1}, - {"voices6.res", GAME_VOICEFILE, "96c9bda9a5f41d6bc232ed7bf6d371d9", -1}, + //{"voicess.res", GAME_VOICEFILE, "d869de9883c8faea7f687217a9ec7057", -1}, //order of voice bank file is important + //{"voices1.res", GAME_VOICEFILE, "dc6a34e3d1668730ea46815a92c7847f", -1}, + //{"voices2.res", GAME_VOICEFILE, "dc6a5fa7a4cdc2ca5a6fd924e969986c", -1}, + //{"voices3.res", GAME_VOICEFILE, "dc6a5fa7a4cdc2ca5a6fd924e969986c", -1}, + //{"voices4.res", GAME_VOICEFILE, "0f87400b804232a58dd22e404420cc45", -1}, + //{"voices5.res", GAME_VOICEFILE, "172668cfc5d8c305cb5b1a9b4d995fc0", -1}, + //{"voices6.res", GAME_VOICEFILE, "96c9bda9a5f41d6bc232ed7bf6d371d9", -1}, { NULL, 0, NULL, 0} }, Common::ES_ESP, @@ -920,13 +901,13 @@ static const SAGAGameDescription gameDescriptions[] = { {"patch.re_", GAME_PATCHFILE | GAME_RESOURCEFILE, "58b79e61594779513c7f2d35509fa89e", -1}, {"scripts.res", GAME_SCRIPTFILE, "be38bbc5a26be809dbf39f13befebd01", -1}, {"sfx.res", GAME_SOUNDFILE, "1c610d543f32ec8b525e3f652536f269", -1}, - {"voicess.res", GAME_VOICEFILE, "9df7cd3b18ddaa16b5291b3432567036", -1}, //order of voice bank file is important - {"voices1.res", GAME_VOICEFILE, "d6100d2dc3b2b9f2e1ad247f613dce9b", -1}, - {"voices2.res", GAME_VOICEFILE, "84f6f48ecc2832841ea6417a9a379430", -1}, - {"voices3.res", GAME_VOICEFILE, "ebb9501283047f27a0f54e27b3c8ba1e", -1}, - {"voices4.res", GAME_VOICEFILE, "4c145da5fa6d1306162a7ca8ce5a4f2e", -1}, - {"voices5.res", GAME_VOICEFILE, "871a559644281917677eca4af1b05620", -1}, - {"voices6.res", GAME_VOICEFILE, "211be5c24f066d69a2f6cfa953acfba6", -1}, + //{"voicess.res", GAME_VOICEFILE, "9df7cd3b18ddaa16b5291b3432567036", -1}, //order of voice bank file is important + //{"voices1.res", GAME_VOICEFILE, "d6100d2dc3b2b9f2e1ad247f613dce9b", -1}, + //{"voices2.res", GAME_VOICEFILE, "84f6f48ecc2832841ea6417a9a379430", -1}, + //{"voices3.res", GAME_VOICEFILE, "ebb9501283047f27a0f54e27b3c8ba1e", -1}, + //{"voices4.res", GAME_VOICEFILE, "4c145da5fa6d1306162a7ca8ce5a4f2e", -1}, + //{"voices5.res", GAME_VOICEFILE, "871a559644281917677eca4af1b05620", -1}, + //{"voices6.res", GAME_VOICEFILE, "211be5c24f066d69a2f6cfa953acfba6", -1}, { NULL, 0, NULL, 0} }, Common::RU_RUS, @@ -959,12 +940,12 @@ static const SAGAGameDescription gameDescriptions[] = { {"scripts.res", GAME_SCRIPTFILE, "32aa01a89937520fe0ea513950117292", -1}, {"patch.re_", GAME_PATCHFILE | GAME_RESOURCEFILE, "58b79e61594779513c7f2d35509fa89e", -1}, {"sfx.res", GAME_SOUNDFILE, "1c610d543f32ec8b525e3f652536f269", -1}, - {"voicess.res", GAME_VOICEFILE, "b8642e943bbebf89cef2f48b31cb4305", -1}, //order of voice bank file is important - {"voices1.res", GAME_VOICEFILE, "424971e1e2373187c3f5734fe36071a2", -1}, - {"voices2.res", GAME_VOICEFILE, "c2d93a35d2c2def9c3d6d242576c794b", -1}, - {"voices3.res", GAME_VOICEFILE, "49e42befea883fd101ec3d0f5d0647b9", -1}, - {"voices5.res", GAME_VOICEFILE, "f4c415de7c03de86b73f9a12b8bd632f", -1}, - {"voices6.res", GAME_VOICEFILE, "3fc5358a5d8eee43bdfab2740276572e", -1}, + //{"voicess.res", GAME_VOICEFILE, "b8642e943bbebf89cef2f48b31cb4305", -1}, //order of voice bank file is important + //{"voices1.res", GAME_VOICEFILE, "424971e1e2373187c3f5734fe36071a2", -1}, + //{"voices2.res", GAME_VOICEFILE, "c2d93a35d2c2def9c3d6d242576c794b", -1}, + //{"voices3.res", GAME_VOICEFILE, "49e42befea883fd101ec3d0f5d0647b9", -1}, + //{"voices5.res", GAME_VOICEFILE, "f4c415de7c03de86b73f9a12b8bd632f", -1}, + //{"voices6.res", GAME_VOICEFILE, "3fc5358a5d8eee43bdfab2740276572e", -1}, { NULL, 0, NULL, 0} }, Common::FR_FRA, diff --git a/engines/saga/rscfile.cpp b/engines/saga/rscfile.cpp index 0aa7e2eafe..4d3ff1e47c 100644 --- a/engines/saga/rscfile.cpp +++ b/engines/saga/rscfile.cpp @@ -353,6 +353,8 @@ bool Resource::createContexts() { bool digitalMusic = false; bool soundFileInArray = false; bool voicesFileInArray = false; + bool multipleVoices = false; + bool censoredVersion = false; uint16 voiceFileType = GAME_VOICEFILE; _contextsCount = 0; @@ -364,8 +366,8 @@ bool Resource::createContexts() { voicesFileInArray = true; } - if (_vm->getGameType() == GType_ITE) { - if (!soundFileInArray) { + if (!soundFileInArray) { + if (_vm->getGameType() == GType_ITE) { // If the sound file is not specified in the detector table, add it here if (Common::File::exists("sounds.rsc") || Common::File::exists("sounds.cmp")) { _contextsCount++; @@ -387,9 +389,24 @@ bool Resource::createContexts() { // ITE floppy versions have both voices and sounds in voices.rsc voiceFileType = GAME_SOUNDFILE | GAME_VOICEFILE; } + } else { + // If the sound file is not specified in the detector table, add it here + if (Common::File::exists("sfx.res") || Common::File::exists("sfx.cmp")) { + _contextsCount++; + soundFileIndex = _contextsCount - 1; + if (_vm->getFeatures() & GF_COMPRESSED_SOUNDS) + sprintf(soundFileName, "sfx.cmp"); + else + sprintf(soundFileName, "sfx.res"); + } else { + // No sound file found, don't add any file to the array + soundFileInArray = true; + } } + } - if (!voicesFileInArray) { + if (!voicesFileInArray) { + if (_vm->getGameType() == GType_ITE) { // If the voices file is not specified in the detector table, add it here if (Common::File::exists("voices.rsc") || Common::File::exists("voices.cmp")) { _contextsCount++; @@ -413,18 +430,50 @@ bool Resource::createContexts() { sprintf(voicesFileName, "inherit the earth voices.cmp"); else sprintf(voicesFileName, "inherit the earth voices"); - - // The resources in the Wyrmkeep combined Windows/Mac/Linux CD version are little endian, but - // the voice file is big endian. If we got such a version with mixed files, mark this voice file - // as big endian - if (!_vm->isBigEndian()) - voiceFileType = GAME_VOICEFILE | GAME_SWAPENDIAN; // This file is big endian + // The resources in the Wyrmkeep combined Windows/Mac/Linux CD version are little endian, but + // the voice file is big endian. If we got such a version with mixed files, mark this voice file + // as big endian + if (!_vm->isBigEndian()) + voiceFileType = GAME_VOICEFILE | GAME_SWAPENDIAN; // This file is big endian + } else { + // No voice file found, don't add any file to the array + voicesFileInArray = true; + } + } else { + // If the voices file is not specified in the detector table, add it here + if (Common::File::exists("voicess.res") || Common::File::exists("voicess.cmp")) { + _contextsCount++; + voicesFileIndex = _contextsCount - 1; + // IHNM has multiple voice files + multipleVoices = true; + // Note: it is assumed that the voices are always last in the list + if (Common::File::exists("voices4.res") || Common::File::exists("voices4.cmp")) { + _contextsCount += 6; // voices1-voices6 + } else { + // The German and French versions of IHNM don't have Nimdok's chapter, therefore the voices file + // for that chapter is missing + _contextsCount += 5; // voices1-voices3, voices4-voices5 + censoredVersion = true; + } + if (_vm->getFeatures() & GF_COMPRESSED_SOUNDS) + sprintf(voicesFileName, "voicess.cmp"); + else + sprintf(voicesFileName, "voicess.res"); + } else if (Common::File::exists("voicesd.res") || Common::File::exists("voicesd.cmp")) { + _contextsCount++; + voicesFileIndex = _contextsCount - 1; + if (_vm->getFeatures() & GF_COMPRESSED_SOUNDS) + sprintf(voicesFileName, "voicesd.cmp"); + else + sprintf(voicesFileName, "voicesd.res"); } else { // No voice file found, don't add any file to the array voicesFileInArray = true; } } + } + if (_vm->getGameType() == GType_ITE) { // Check for digital music in ITE if (Common::File::exists("music.rsc") || Common::File::exists("music.cmp")) { _contextsCount++; @@ -455,16 +504,28 @@ bool Resource::createContexts() { if (_vm->getGameType() == GType_ITE && digitalMusic && i == _contextsCount - 1) { context->fileName = musicFileName; context->fileType = GAME_MUSICFILE; - } else if (_vm->getGameType() == GType_ITE && !soundFileInArray && i == soundFileIndex) { + } else if (!soundFileInArray && i == soundFileIndex) { context->fileName = soundFileName; context->fileType = GAME_SOUNDFILE; - } else if (_vm->getGameType() == GType_ITE && !voicesFileInArray && i == voicesFileIndex) { + } else if (!voicesFileInArray && i == voicesFileIndex) { context->fileName = voicesFileName; // can be GAME_VOICEFILE or GAME_SOUNDFILE | GAME_VOICEFILE or GAME_VOICEFILE | GAME_SWAPENDIAN context->fileType = voiceFileType; } else { - context->fileName = _vm->getFilesDescriptions()[i].fileName; - context->fileType = _vm->getFilesDescriptions()[i].fileType; + if (!(!voicesFileInArray && multipleVoices && (i > voicesFileIndex))) { + context->fileName = _vm->getFilesDescriptions()[i].fileName; + context->fileType = _vm->getFilesDescriptions()[i].fileType; + } else { + int token = (censoredVersion && (i - voicesFileIndex >= 4)) ? 1 : 0; // censored versions don't have voice4 + + if (_vm->getFeatures() & GF_COMPRESSED_SOUNDS) + sprintf(voicesFileName, "voices%i.cmp", i - voicesFileIndex + token); + else + sprintf(voicesFileName, "voices%i.res", i - voicesFileIndex + token); + + context->fileName = voicesFileName; + context->fileType = GAME_VOICEFILE; + } } context->serial = 0; diff --git a/engines/saga/sndres.cpp b/engines/saga/sndres.cpp index 3f1957b9c5..edbdebabab 100644 --- a/engines/saga/sndres.cpp +++ b/engines/saga/sndres.cpp @@ -182,13 +182,17 @@ bool SndRes::load(ResourceContext *context, uint32 resourceId, SoundBuffer &buff resourceType = kSoundWAV; } - bool patchedSound = false; + bool uncompressedSound = false; // If a patch file exists for sound resource 4 (used in ITE intro), don't treat this sound as compressed if (_vm->getGameType() == GType_ITE && resourceId == 4 && (Common::File::exists("sound/p2_a.iaf") || Common::File::exists("sound/p2_a.voc"))) - patchedSound = true; + uncompressedSound = true; - if ((_vm->getFeatures() & GF_COMPRESSED_SOUNDS) && !patchedSound) { + // FIXME: Currently, the SFX.RES file in IHNM cannot be compressed + if (_vm->getGameType() == GType_IHNM && (context->fileType & GAME_SOUNDFILE)) + uncompressedSound = true; + + if ((_vm->getFeatures() & GF_COMPRESSED_SOUNDS) && !uncompressedSound) { if (soundResource[0] == char(0)) { resourceType = kSoundMP3; } else if (soundResource[0] == char(1)) { -- cgit v1.2.3 From 8e5fb44fcb00a78b47734e2edb11b2ae0c561adb Mon Sep 17 00:00:00 2001 From: Kari Salminen Date: Wed, 1 Aug 2007 18:14:10 +0000 Subject: Added data for the Atari ST AGI palette and Apple IIGS AGI palettes V1 and V2. svn-id: r28387 --- engines/agi/graphics.cpp | 67 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/agi/graphics.cpp b/engines/agi/graphics.cpp index 3e39fc07ea..b9e8971e13 100644 --- a/engines/agi/graphics.cpp +++ b/engines/agi/graphics.cpp @@ -68,7 +68,69 @@ uint8 egaPalette[16 * 3] = { }; /** - * First generation Amiga AGI palette. + * Atari ST AGI palette. + * Used by all of the tested Atari ST AGI games + * from Donald Duck's Playground (1986) to Manhunter II (1989). + * 16 RGB colors. 3 bits per color component. + */ +uint8 atariStAgiPalette[16 * 3] = { + 0x0, 0x0, 0x0, + 0x0, 0x0, 0x7, + 0x0, 0x4, 0x0, + 0x0, 0x5, 0x4, + 0x5, 0x0, 0x0, + 0x5, 0x3, 0x6, + 0x4, 0x3, 0x0, + 0x5, 0x5, 0x5, + 0x3, 0x3, 0x2, + 0x0, 0x5, 0x7, + 0x0, 0x6, 0x0, + 0x0, 0x7, 0x6, + 0x7, 0x2, 0x3, + 0x7, 0x4, 0x7, + 0x7, 0x7, 0x4, + 0x7, 0x7, 0x7 +}; + +/** + * Second generation Apple IIGS AGI palette. + * A 16-color, 12-bit RGB palette. + * + * Used by at least the following Apple IIGS AGI versions: + * 1.003 (Leisure Suit Larry I v1.0E, intro says 1987) + * 1.005 (AGI Demo 2 1987-06-30?) + * 1.006 (King's Quest I v1.0S 1988-02-23) + * 1.007 (Police Quest I v2.0B 1988-04-21 8:00am) + * 1.013 (King's Quest II v2.0A 1988-06-16 (CE)) + * 1.013 (Mixed-Up Mother Goose v2.0A 1988-05-31 10:00am) + * 1.014 (King's Quest III v2.0A 1988-08-28 (CE)) + * 1.014 (Space Quest II v2.0A, LOGIC.141 says 1988) + * 2.004 (Manhunter I v2.0E 1988-10-05 (CE)) + * 2.006 (King's Quest IV v1.0K 1988-11-22 (CE)) + * 3.001 (Black Cauldron v1.0O 1989-02-24 (CE)) + * 3.003 (Gold Rush! v1.0M 1989-02-28 (CE)) + */ +uint8 appleIIgsAgiPaletteV2[16 * 3] = { + 0x0, 0x0, 0x0, + 0x0, 0x0, 0xF, + 0x0, 0x8, 0x0, + 0x0, 0xD, 0xB, + 0xC, 0x0, 0x0, + 0xB, 0x7, 0xD, + 0x8, 0x5, 0x0, + 0xB, 0xB, 0xB, + 0x7, 0x7, 0x7, + 0x0, 0xB, 0xF, + 0x0, 0xE, 0x0, + 0x0, 0xF, 0xD, + 0xF, 0x9, 0x8, + 0xD, 0x9, 0xF, // Only this differs from the 1st generation palette + 0xE, 0xE, 0x0, + 0xF, 0xF, 0xF +}; + +/** + * First generation Amiga & Apple IIGS AGI palette. * A 16-color, 12-bit RGB palette. * * Used by at least the following Amiga AGI versions: @@ -78,6 +140,9 @@ uint8 egaPalette[16 * 3] = { * 2.107 (King's Quest II v2.0J 1987-01-29) * x.yyy (Black Cauldron v2.00 1987-06-14) * x.yyy (Larry I v1.05 1987-06-26) + * + * Also used by at least the following Apple IIGS AGI versions: + * 1.002 (Space Quest I, intro says v2.2 1987) */ uint8 amigaAgiPaletteV1[16 * 3] = { 0x0, 0x0, 0x0, -- cgit v1.2.3 From abec62d46b164be60cda331958418f00d8832acf Mon Sep 17 00:00:00 2001 From: Paweł Kołodziejski Date: Wed, 1 Aug 2007 19:31:36 +0000 Subject: more changes svn-id: r28388 --- engines/drascula/drascula.cpp | 133 ++++++++++++++++++++++-------------------- engines/drascula/drascula.h | 6 +- 2 files changed, 70 insertions(+), 69 deletions(-) (limited to 'engines') diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp index ef9d743bfb..fe3d0105f2 100644 --- a/engines/drascula/drascula.cpp +++ b/engines/drascula/drascula.cpp @@ -1588,17 +1588,17 @@ void DrasculaEngine::mesa() { VUELCA_PANTALLA(73, 63, 73, 63, 177, 97, dir_zona_pantalla); for (;;) { - nivel_master = 72 + 61 - (12/*Master*/ * 4); - nivel_voc = 72 + 61 - (12/*Voc*/ * 4); - nivel_cd = 72 + 61 - (10/*CD*/ * 4); + nivel_master = 72 + 61 - ((_mixer->getVolumeForSoundType(Audio::Mixer::kPlainSoundType) / 16) * 4); + nivel_voc = 72 + 61 - ((_mixer->getVolumeForSoundType(Audio::Mixer::kSFXSoundType) / 16) * 4); + nivel_cd = 72 + 61 - ((_mixer->getVolumeForSoundType(Audio::Mixer::kMusicSoundType) / 16) * 4); refresca_pantalla(); DIBUJA_BLOQUE(1, 56, 73, 63, 177, 97, dir_mesa, dir_zona_pantalla); - DIBUJA_FONDO(183, 56, 82, nivel_master, 39, 2 + (12/*Master*/ * 4), dir_mesa, dir_zona_pantalla); - DIBUJA_FONDO(183, 56, 138, nivel_voc, 39, 2 + (12/*Voc*/ * 4), dir_mesa, dir_zona_pantalla); - DIBUJA_FONDO(183, 56, 194, nivel_cd, 39, 2 + (10/*CD*/ * 4), dir_mesa, dir_zona_pantalla); + DIBUJA_FONDO(183, 56, 82, nivel_master, 39, 2 + ((_mixer->getVolumeForSoundType(Audio::Mixer::kPlainSoundType) / 16) * 4), dir_mesa, dir_zona_pantalla); + DIBUJA_FONDO(183, 56, 138, nivel_voc, 39, 2 + ((_mixer->getVolumeForSoundType(Audio::Mixer::kSFXSoundType) / 16) * 4), dir_mesa, dir_zona_pantalla); + DIBUJA_FONDO(183, 56, 194, nivel_cd, 39, 2 + ((_mixer->getVolumeForSoundType(Audio::Mixer::kMusicSoundType) / 16) * 4), dir_mesa, dir_zona_pantalla); cursor_mesa(); @@ -1610,30 +1610,30 @@ void DrasculaEngine::mesa() { break; if (boton_izq == 1) { if (x_raton > 80 && x_raton < 121) { -// TODO -// if (y_raton < nivel_master && Master < 15) -// Master++; -// if (y_raton > nivel_master && Master > 0) -// Master--; -// SetMasterVolume(Master); + int vol = _mixer->getVolumeForSoundType(Audio::Mixer::kPlainSoundType) / 16; + if (y_raton < nivel_master && vol < 15) + vol++; + if (y_raton > nivel_master && vol > 0) + vol--; + _mixer->setVolumeForSoundType(Audio::Mixer::kPlainSoundType, vol * 16); } if (x_raton > 136 && x_raton < 178) { -// TODO -// if (y_raton < nivel_voc && Voc < 15) -// Voc++; -// if (y_raton > nivel_voc && Voc > 0) -// Voc--; -// SetVocVolume(Voc); + int vol = _mixer->getVolumeForSoundType(Audio::Mixer::kSFXSoundType) / 16; + if (y_raton < nivel_voc && vol < 15) + vol++; + if (y_raton > nivel_voc && vol > 0) + vol--; + _mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, vol * 16); } if (x_raton > 192 && x_raton < 233) { -// TODO -// if (y_raton < nivel_cd && CD < 15) -// CD++; -// if (y_raton > nivel_cd && CD > 0) -// CD--; -// SetCDVolume(CD); + int vol = _mixer->getVolumeForSoundType(Audio::Mixer::kMusicSoundType) / 16; + if (y_raton < nivel_cd && vol < 15) + vol++; + if (y_raton > nivel_cd && vol > 0) + vol--; + _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, vol * 16); } } @@ -1646,16 +1646,16 @@ void DrasculaEngine::saves() { char nombres[10][23]; char fichero[13]; int n, n2, num_sav, y = 27; - FILE *sav; + Common::InSaveFile *sav; borra_pantalla(); - if ((sav = fopen("saves.epa", "r")) == NULL) { + if (!(sav = _saveFileMan->openForLoading("saves.epa"))) { error("Can't open saves.epa file."); } for (n = 0; n < NUM_SAVES; n++) - fscanf(sav, "%s", nombres[n]); - fclose(sav); + sav->read(nombres[n], 23); + delete sav; lee_dibujos("savescr.alg"); descomprime_dibujo(dir_dibujo1, MEDIA); @@ -1708,13 +1708,14 @@ void DrasculaEngine::saves() { if (n == 9) strcpy(fichero, "gsave10"); para_grabar(fichero); - // TODO - if ((sav = fopen("saves.epa", "w")) == NULL) { - error("no puedo abrir el archivo de partidas."); + Common::OutSaveFile *tsav; + if (!(tsav = _saveFileMan->openForSaving("saves.epa"))) { + error("Can't open saves.epa file."); } for (n = 0; n < NUM_SAVES; n++) - fprintf(sav, "%s\n", nombres[n]); - fclose(sav); + tsav->write(nombres[n], 23); + tsav->finalize(); + delete tsav; } } @@ -1765,12 +1766,14 @@ void DrasculaEngine::saves() { break; } else if (x_raton > 208 && y_raton > 123 && x_raton < 282 && y_raton < 149 && hay_seleccion == 1) { para_grabar(fichero); - if ((sav = fopen("saves.epa", "w")) == NULL) { - error("no puedo abrir el archivo de partidas."); + Common::OutSaveFile *tsav; + if (!(tsav = _saveFileMan->openForSaving("saves.epa"))) { + error("Can't open saves.epa file."); } for (n = 0; n < NUM_SAVES; n++) - fprintf(sav, "%s\n", nombres[n]); - fclose(sav); + tsav->write(nombres[n], 23); + tsav->finalize(); + delete tsav; } else if (x_raton > 168 && y_raton > 154 && x_raton < 242 && y_raton < 180) break; else if (hay_seleccion == 0) { @@ -2245,7 +2248,6 @@ void DrasculaEngine::anima(const char *animacion, int FPS) { int NFrames = 1; int cnt = 2; - TimeMed = CLOCKS_PER_SEC / FPS; AuxBuffLast = (byte *)malloc(65000); AuxBuffDes = (byte *)malloc(65000); @@ -2267,7 +2269,7 @@ void DrasculaEngine::anima(const char *animacion, int FPS) { _system->updateScreen(); set_dac(cPal); memcpy(AuxBuffLast, AuxBuffDes, 64000); - WaitForNext(TimeMed); + WaitForNext(FPS); while (cnt < NFrames) { FileIn.read(&Leng, sizeof(Leng)); AuxBuffOrg = (byte *)malloc(Leng); @@ -2280,7 +2282,7 @@ void DrasculaEngine::anima(const char *animacion, int FPS) { } _system->copyRectToScreen((const byte *)VGA, 320, 0, 0, 320, 200); _system->updateScreen(); - WaitForNext(TimeMed); + WaitForNext(FPS); cnt++; byte key = getscan(); if (key == 0x01) @@ -2320,7 +2322,7 @@ void DrasculaEngine::FundeAlNegro(int VelocidadDeFundido) { } void DrasculaEngine::pausa(int cuanto) { - _system->delayMillis(cuanto * 25); // was originaly 2 + _system->delayMillis(cuanto * 30); // was originaly 2 } void DrasculaEngine::habla_dr_grande(const char *dicho, const char *filename) { @@ -2526,6 +2528,7 @@ void DrasculaEngine::habla_dr_izq(const char *dicho, const char *filename) { tiempol = _system->getMillis(); tiempou = (unsigned int)tiempol / 2; + _rnd->setSeed(tiempou); buffer_teclado(); @@ -3172,6 +3175,9 @@ void DrasculaEngine::carga_partida(const char *nom_game) { } void DrasculaEngine::canal_p(const char *fich){ + return; + // TODO + Common::File ald2, ald3; char fich2[13]; @@ -3184,7 +3190,6 @@ void DrasculaEngine::canal_p(const char *fich){ error("no puedo abrir el archivo codificado"); } - // TODO ald2.open(fich2, Common::File::kFileWriteMode); if (!ald2.isOpen()) { error("no puedo abrir el archivo destino"); @@ -3198,7 +3203,6 @@ void DrasculaEngine::canal_p(const char *fich){ ald2.close(); ald3.close(); - // TODO remove(fich); rename(fich2, fich); } @@ -3421,7 +3425,7 @@ void DrasculaEngine::menu_sin_volcar() { } if (x < 7) - print_abc(texto_icono,x_obj[x] - 2, y_obj[x] - 7); + print_abc(texto_icono, x_obj[x] - 2, y_obj[x] - 7); } void DrasculaEngine::barra_menu() { @@ -3900,17 +3904,15 @@ void DrasculaEngine::set_dac(byte *dac) { setvgapalette256((byte *)dac); } -void DrasculaEngine::WaitForNext(long TimeLen) { - TimeLast = clock(); - while (clock() < (TimeLast + TimeLen)) {} - TimeLast = clock(); +void DrasculaEngine::WaitForNext(int FPS) { + _system->delayMillis(1000 / FPS); } float DrasculaEngine::vez() { - return _system->getMillis(); + return _system->getMillis() / 20; // originaly was 1 } -void DrasculaEngine::reduce_hare_chico(int xx1,int yy1, int xx2,int yy2, int ancho,int alto, int factor, byte *dir_inicio, byte *dir_fin) { +void DrasculaEngine::reduce_hare_chico(int xx1, int yy1, int xx2, int yy2, int ancho, int alto, int factor, byte *dir_inicio, byte *dir_fin) { float suma_x, suma_y; int n, m; float pixel_x, pixel_y; @@ -4079,31 +4081,34 @@ void DrasculaEngine::refresca_62_antes() { } void DrasculaEngine::graba_partida(char nom_game[]) { - FILE *scu; + Common::OutSaveFile *out; int l; - // TODO - if ((scu = fopen(nom_game, "w")) == NULL) { + if (!(out = _saveFileMan->openForSaving(nom_game))) { error("no puedo abrir el archivo"); } - fprintf(scu, "%d\n", num_ejec); - fprintf(scu, "%s\n", datos_actuales); - fprintf(scu, "%d\n", hare_x); - fprintf(scu, "%d\n", hare_y); - fprintf(scu, "%d\n", sentido_hare); + out->writeSint32LE(num_ejec); + out->write(datos_actuales, 13); + out->writeSint32LE(hare_x); + out->writeSint32LE(hare_y); + out->writeSint32LE(sentido_hare); for (l = 1; l < 43; l++) { - fprintf(scu,"%d\n", objetos_que_tengo[l]); + out->writeSint32LE(objetos_que_tengo[l]); } for (l = 0; l < NUM_BANDERAS; l++) { - fprintf(scu, "%d\n", flags[l]); + out->writeSint32LE(flags[l]); } - fprintf(scu, "%d\n", lleva_objeto); - fprintf(scu, "%d\n", objeto_que_lleva); + out->writeSint32LE(lleva_objeto); + out->writeSint32LE(objeto_que_lleva); + + out->finalize(); + if (out->ioFailed()) + warning("Can't write file '%s'. (Disk full?)", nom_game); - fclose(scu); + delete out; canal_p(nom_game); } @@ -4872,7 +4877,7 @@ void DrasculaEngine::ctvd_init(int b) { byte *soundData = (byte *)malloc(soundSize); sku->seek(32); sku->read(soundData, soundSize); - _mixer->playRaw(Audio::Mixer::kPlainSoundType, &_soundHandle, soundData, soundSize - 64, + _mixer->playRaw(Audio::Mixer::kSFXSoundType, &_soundHandle, soundData, soundSize - 64, 11025, Audio::Mixer::FLAG_AUTOFREE | Audio::Mixer::FLAG_UNSIGNED); } diff --git a/engines/drascula/drascula.h b/engines/drascula/drascula.h index eeb3ac52e9..55f8a3b189 100644 --- a/engines/drascula/drascula.h +++ b/engines/drascula/drascula.h @@ -575,13 +575,9 @@ public: int GlobalSpeed; int LastFrame; - - long TimeLast; - long TimeMed; - byte *carga_pcx(byte *NamePcc); void set_dac(byte *dac); - void WaitForNext(long TimeMed); + void WaitForNext(int FPS); float vez(); void reduce_hare_chico(int, int, int, int, int, int, int, byte *, byte *); char codifica(char); -- cgit v1.2.3 From b2a9379470f3a64cb2b341e91427c147236aeae5 Mon Sep 17 00:00:00 2001 From: Paweł Kołodziejski Date: Wed, 1 Aug 2007 20:11:32 +0000 Subject: added cd audio playing svn-id: r28389 --- engines/drascula/drascula.cpp | 42 ++++++++++-------------------------------- engines/drascula/drascula.h | 1 + 2 files changed, 11 insertions(+), 32 deletions(-) (limited to 'engines') diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp index fe3d0105f2..556d61df58 100644 --- a/engines/drascula/drascula.cpp +++ b/engines/drascula/drascula.cpp @@ -73,6 +73,10 @@ DrasculaEngine::DrasculaEngine(OSystem *syst) : Engine(syst) { _gameId = g->id; _rnd = new Common::RandomSource(); + + int cd_num = ConfMan.getInt("cdrom"); + if (cd_num >= 0) + _system->openCD(cd_num); } DrasculaEngine::~DrasculaEngine() { @@ -1532,6 +1536,8 @@ void DrasculaEngine::update_events() { Common::Event event; Common::EventManager *eventMan = _system->getEventManager(); + AudioCD.updateCD(); + while (eventMan->pollEvent(event)) { switch (event.type) { case Common::EVENT_KEYDOWN: @@ -3080,44 +3086,16 @@ bucless: } void DrasculaEngine::playmusic(int p) { -// TODO -/* unsigned short v; - stopmusic(); - - v=GetCDVolume(); - if ((p==12 || p==21) && !reducido) { - SetCDVolume(v-2); - reducido = 1; - } - cd_track_length(p, &min, &sec, &frame); - cd_set_track (p); - get_musicpos(); - cd_play_audio(startpos, endpos); - Playing=1; -*/ + AudioCD.stop(); + AudioCD.play(p - 1, 1, 0, 0); } void DrasculaEngine::stopmusic() { -//TODO -/* unsigned short v; - - cd_stop_audio (); - /v=GetCDVolume(); - if (reducido) - { - SetCDVolume(v+2); - reducido=0; - } - cd_done_play (); - Playing=0; -*/ + AudioCD.stop(); } int DrasculaEngine::music_status() { - // TODO - //cd_status(); - //return ((cdrom_data.error & BUSY) != 0); - return 0; + return AudioCD.isPlaying() != 0; } void DrasculaEngine::refresca_pantalla() { diff --git a/engines/drascula/drascula.h b/engines/drascula/drascula.h index 55f8a3b189..4e737a8870 100644 --- a/engines/drascula/drascula.h +++ b/engines/drascula/drascula.h @@ -40,6 +40,7 @@ #include "sound/audiostream.h" #include "sound/mixer.h" #include "sound/voc.h" +#include "sound/audiocd.h" #include "engines/engine.h" -- cgit v1.2.3 From ee436b0b268c3c58e3744fb83f2f4a630b958655 Mon Sep 17 00:00:00 2001 From: Paweł Kołodziejski Date: Wed, 1 Aug 2007 20:12:45 +0000 Subject: ops svn-id: r28390 --- engines/drascula/drascula.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp index 556d61df58..68052e007f 100644 --- a/engines/drascula/drascula.cpp +++ b/engines/drascula/drascula.cpp @@ -3095,7 +3095,7 @@ void DrasculaEngine::stopmusic() { } int DrasculaEngine::music_status() { - return AudioCD.isPlaying() != 0; + return AudioCD.isPlaying(); } void DrasculaEngine::refresca_pantalla() { -- cgit v1.2.3 From 503ee127e53615528cfbcfded6cbe890c2edcddf Mon Sep 17 00:00:00 2001 From: Paweł Kołodziejski Date: Wed, 1 Aug 2007 20:13:58 +0000 Subject: formating svn-id: r28391 --- engines/drascula/drascula.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp index 68052e007f..8332e775f7 100644 --- a/engines/drascula/drascula.cpp +++ b/engines/drascula/drascula.cpp @@ -461,7 +461,7 @@ bucles: paso_x = PASO_HARE_X; paso_y = PASO_HARE_Y; } - if (hare_se_mueve == 0 && anda_a_objeto==1) { + if (hare_se_mueve == 0 && anda_a_objeto == 1) { sentido_hare = sentido_final; anda_a_objeto = 0; } -- cgit v1.2.3 From ce6c1a462d2ea1c1404cbb51eac3e919af7e01dc Mon Sep 17 00:00:00 2001 From: Paweł Kołodziejski Date: Wed, 1 Aug 2007 20:56:39 +0000 Subject: added MusicFadeout code svn-id: r28392 --- engines/drascula/drascula.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp index 8332e775f7..c19239b9a3 100644 --- a/engines/drascula/drascula.cpp +++ b/engines/drascula/drascula.cpp @@ -4831,7 +4831,22 @@ void DrasculaEngine::fin_sound_corte() { } void DrasculaEngine::MusicFadeout() { - //TODO + int org_vol = _mixer->getVolumeForSoundType(Audio::Mixer::kMusicSoundType); + for (;;) { + int vol = _mixer->getVolumeForSoundType(Audio::Mixer::kMusicSoundType); + vol -= 10; + if (vol < 0) + vol = 0; + _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, vol); + if (vol == 0) + break; + update_events(); + _system->updateScreen(); + _system->delayMillis(50); + } + AudioCD.stop(); + _system->delayMillis(100); + _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, org_vol); } void DrasculaEngine::ctvd_end() { -- cgit v1.2.3 From 79c67653b63b23143fc89004bd5106919f85d5b5 Mon Sep 17 00:00:00 2001 From: Gregory Montoir Date: Wed, 1 Aug 2007 20:59:59 +0000 Subject: workaround for original game graphic glitch #1751170 svn-id: r28393 --- engines/touche/resource.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'engines') diff --git a/engines/touche/resource.cpp b/engines/touche/resource.cpp index 81a11569dc..cd2124806d 100644 --- a/engines/touche/resource.cpp +++ b/engines/touche/resource.cpp @@ -521,19 +521,20 @@ void ToucheEngine::res_loadBackdrop() { debugC(9, kDebugResource, "ToucheEngine::res_loadBackdrop()"); _currentBitmapWidth = _fData.readUint16LE(); _currentBitmapHeight = _fData.readUint16LE(); - uint8 *dst = _backdropBuffer; for (int i = 0; i < _currentBitmapHeight; ++i) { - res_decodeScanLineImageRLE(dst + _currentBitmapWidth * i, _currentBitmapWidth); + res_decodeScanLineImageRLE(_backdropBuffer + _currentBitmapWidth * i, _currentBitmapWidth); } _roomWidth = _currentBitmapWidth; - dst = _backdropBuffer; for (int i = 0; i < _currentBitmapWidth; ++i) { - if (*dst == 255) { + if (_backdropBuffer[i] == 255) { _roomWidth = i; - *dst = 0; + _backdropBuffer[i] = 0; break; } - ++dst; + } + // Workaround for bug #1751149 (original bitmap has a white pixel in its transparent area). + if (_currentRoomNum == 8 && _currentBitmapWidth == 860) { + _backdropBuffer[120 * _currentBitmapWidth + 734] = 0; } } -- cgit v1.2.3 From 617a500ef243df46dafbe7e036e3ea220b0feb78 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 1 Aug 2007 21:47:17 +0000 Subject: IHNM and ITE: ScummVM will no longer crash when loading games from the command line svn-id: r28394 --- engines/saga/actor.cpp | 4 +++- engines/saga/script.cpp | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/saga/actor.cpp b/engines/saga/actor.cpp index 5cb91b8663..c2ecff4a1a 100644 --- a/engines/saga/actor.cpp +++ b/engines/saga/actor.cpp @@ -897,7 +897,9 @@ void Actor::updateActorsScene(int actorsEntrance) { } } - assert(_protagonist); + // _protagonist can be null while loading a game from the command line + if (_protagonist == NULL) + return; if ((actorsEntrance >= 0) && (_vm->_scene->_entryList.entryListCount > 0)) { if (_vm->_scene->_entryList.entryListCount <= actorsEntrance) { diff --git a/engines/saga/script.cpp b/engines/saga/script.cpp index 262d63c51f..82fcb352c0 100644 --- a/engines/saga/script.cpp +++ b/engines/saga/script.cpp @@ -750,6 +750,10 @@ void Script::whichObject(const Point& mousePoint) { _leftButtonVerb = _currentVerb; newRightButtonVerb = getVerbType(kVerbNone); + // _protagonist can be null while loading a game from the command line + if (_vm->_actor->_protagonist == NULL) + return; + if (_vm->_actor->_protagonist->_currentAction != kActionWalkDir) { if (_vm->_scene->getHeight() >= mousePoint.y) { newObjectId = _vm->_actor->hitTest(mousePoint, true); -- cgit v1.2.3 From 87f0a934fb6c5ba54452148c4c5c7d3b45375352 Mon Sep 17 00:00:00 2001 From: Paweł Kołodziejski Date: Wed, 1 Aug 2007 22:11:04 +0000 Subject: added some keyboard code svn-id: r28396 --- engines/drascula/drascula.cpp | 340 +++++++++++++++++++++--------------------- 1 file changed, 170 insertions(+), 170 deletions(-) (limited to 'engines') diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp index c19239b9a3..f5fb35a715 100644 --- a/engines/drascula/drascula.cpp +++ b/engines/drascula/drascula.cpp @@ -513,49 +513,49 @@ bucles: menu_bar = 0; byte key = getscan(); - if (key == F1 && menu_scr == 0) { + if (key == Common::KEYCODE_F1 && menu_scr == 0) { elige_verbo(1); cont_sv = 0; - } else if (key == F2 && menu_scr == 0) { + } else if (key == Common::KEYCODE_F2 && menu_scr == 0) { elige_verbo(2); cont_sv = 0; - } else if (key == F3 && menu_scr == 0) { + } else if (key == Common::KEYCODE_F3 && menu_scr == 0) { elige_verbo(3); cont_sv = 0; - } else if (key == F4 && menu_scr == 0) { + } else if (key == Common::KEYCODE_F4 && menu_scr == 0) { elige_verbo(4); cont_sv = 0; - } else if (key == F5 && menu_scr == 0) { + } else if (key == Common::KEYCODE_F5 && menu_scr == 0) { elige_verbo(5); cont_sv = 0; - } else if (key == F6 && menu_scr == 0) { + } else if (key == Common::KEYCODE_F6 && menu_scr == 0) { elige_verbo(6); cont_sv = 0; - } else if (key == F9) { + } else if (key == Common::KEYCODE_F9) { mesa(); cont_sv = 0; - } else if (key == F10) { + } else if (key == Common::KEYCODE_F10) { saves(); cont_sv = 0; - } else if (key == F8) { + } else if (key == Common::KEYCODE_F8) { sin_verbo(); cont_sv = 0; - } else if (key == 47) { + } else if (key == Common::KEYCODE_v) { con_voces = 1; print_abc(SYS2, 96, 86); VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); delay(1410); cont_sv = 0; - } else if (key == 20) { + } else if (key == Common::KEYCODE_t) { con_voces = 0; print_abc(SYS3, 94, 86); VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); delay(1460); cont_sv = 0; - } else if (key == 83) { + } else if (key == Common::KEYCODE_DELETE) { confirma_go(); cont_sv = 0; - } else if (key == ESC) { + } else if (key == Common::KEYCODE_ESCAPE) { confirma_salir(); cont_sv = 0; } else if (cont_sv == 1500) { @@ -606,21 +606,21 @@ void DrasculaEngine::animacion_1() { while (term_int == 0) { playmusic(29); fliplay("logoddm.bin", 9); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; delay(600); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; borra_pantalla(); delay(340); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; playmusic(26); delay(500); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; fliplay("logoalc.bin", 8); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; borra_pantalla(); lee_dibujos("cielo.alg"); @@ -628,45 +628,45 @@ void DrasculaEngine::animacion_1() { Negro(); VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); FundeDelNegro(2); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; delay(900); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; color_abc(ROJO); centra_texto("Transilvanya, 1993 d.c.", 160, 100); VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; delay(1000); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; delay(1200); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; fliplay("scrollb.bin", 9); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; borra_pantalla(); comienza_sound("s5.als"); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; anima("scr2.bin", 17); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; fin_sound_corte(); anima("scr3.bin", 17); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; lee_dibujos("cielo2.alg"); descomprime_dibujo(dir_zona_pantalla, 256); VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; FundeAlNegro(1); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; borra_pantalla(); @@ -680,10 +680,10 @@ void DrasculaEngine::animacion_1() { descomprime_dibujo(dir_dibujo2, 1); playmusic(4); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; delay(400); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; for (l2 = 0; l2 < 3; l2++) @@ -691,13 +691,13 @@ void DrasculaEngine::animacion_1() { DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); DIBUJA_FONDO(interf_x[l], interf_y[l], 156, 45, 63, 31, dir_dibujo2, dir_zona_pantalla); VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); - if (getscan() == ESC) { + if (getscan() == Common::KEYCODE_ESCAPE) { term_int = 1; break; } pausa(3); } - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; l2 = 0; p = 0; @@ -722,17 +722,17 @@ void DrasculaEngine::animacion_1() { } if (l2 == 7) l2 = 0; - if (getscan() == ESC) { + if (getscan() == Common::KEYCODE_ESCAPE) { term_int = 1; break; } } - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_zona_pantalla, dir_dibujo1); habla_dr_grande(TEXTD1, "D1.als"); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; borra_pantalla(); @@ -755,23 +755,23 @@ void DrasculaEngine::animacion_1() { pon_dr(); VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); habla_igor_dch(TEXTI8, "I8.als"); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; DIBUJA_FONDO(0, 0, 0,0, 320, 200, dir_dibujo1, dir_zona_pantalla); pon_igor(); pon_dr(); VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); habla_dr_izq(TEXTD2, "d2.als"); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; habla_dr_izq(TEXTD3, "d3.als"); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; anima("lib.bin", 16); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; anima("lib2.bin", 16); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; borra_pantalla(); color_solo = ROJO; @@ -780,16 +780,16 @@ void DrasculaEngine::animacion_1() { VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); pausa(10); habla_solo(TEXTD4,"d4.als"); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; lee_dibujos("plan1.alg"); descomprime_dibujo(dir_zona_pantalla, MEDIA); VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); habla_solo(TEXTD5, "d5.als"); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; anima("lib2.bin", 16); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; borra_pantalla(); lee_dibujos("plan2.alg"); @@ -797,76 +797,76 @@ void DrasculaEngine::animacion_1() { VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); pausa(20); habla_solo(TEXTD6, "d6.als"); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; anima("lib2.bin", 16); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; borra_pantalla(); lee_dibujos("plan3.alg"); descomprime_dibujo(dir_zona_pantalla, MEDIA); VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); pausa(20); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; habla_solo(TEXTD7, "d7.als"); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; lee_dibujos("plan3.alg"); descomprime_dibujo(dir_zona_pantalla, MEDIA); VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); habla_solo(TEXTD8, "d8.als"); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; borra_pantalla(); lee_dibujos("100.alg"); descomprime_dibujo(dir_dibujo1, MEDIA); MusicFadeout(); stopmusic(); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; habla_igor_dch(TEXTI9, "I9.als"); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; habla_dr_izq(TEXTD9, "d9.als"); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; habla_igor_dch(TEXTI10, "I10.als"); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; playmusic(11); habla_dr_izq(TEXTD10, "d10.als"); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; anima("rayo1.bin", 16); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; comienza_sound("s5.als"); anima("rayo2.bin", 15); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; anima("frel2.bin", 16); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; anima("frel.bin", 16); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; anima("frel.bin", 16); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; fin_sound_corte(); borra_pantalla(); Negro(); playmusic(23); FundeDelNegro(0); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; sentido_dr = 1; habla_igor_dch(TEXTI1, "I1.als"); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; habla_dr_dch(TEXTD11, "d11.als"); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; sentido_dr = 3; DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); @@ -880,7 +880,7 @@ void DrasculaEngine::animacion_1() { pon_dr(); VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); habla_dr_izq(TEXTD12, "d12.als"); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; sentido_dr = 3; DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); @@ -894,11 +894,11 @@ void DrasculaEngine::animacion_1() { pon_dr(); VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); habla_igor_dch(TEXTI2, "I2.als"); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; pausa(13); habla_dr_dch(TEXTD13,"d13.als"); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; sentido_dr = 3; DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); @@ -912,35 +912,35 @@ void DrasculaEngine::animacion_1() { pon_dr(); VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); habla_dr_izq(TEXTD14, "d14.als"); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; habla_igor_dch(TEXTI3, "I3.als"); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; habla_dr_izq(TEXTD15, "d15.als"); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; habla_igor_dch(TEXTI4, "I4.als"); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; habla_dr_izq(TEXTD16, "d16.als"); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; habla_igor_dch(TEXTI5, "I5.als"); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; sentido_igor = 3; habla_dr_izq(TEXTD17, "d17.als"); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; pausa(18); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; habla_igor_frente(TEXTI6, "I6.als"); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; FundeAlNegro(0); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; borra_pantalla(); @@ -965,32 +965,32 @@ void DrasculaEngine::animacion_2() { term_int = 0; for (;;) { - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; anima("ag.bin", 14); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; lee_dibujos("an11y13.alg"); descomprime_dibujo(dir_hare_dch, 1); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; habla_tabernero(TEXTT22, "T22.als"); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; lee_dibujos("97.alg"); descomprime_dibujo(dir_hare_dch, 1); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; pausa(4); comienza_sound("s1.als"); hipo(18); fin_sound(); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; borra_pantalla(); @@ -1000,39 +1000,39 @@ void DrasculaEngine::animacion_2() { color_solo = BLANCO; pausa(80); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; habla_solo(TEXTBJ1, "BJ1.als"); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; borra_pantalla(); lee_dibujos("bj.alg"); descomprime_dibujo(dir_zona_pantalla, MEDIA); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; Negro(); VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); FundeDelNegro(1); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; color_solo = AMARILLO; habla_solo(TEXT214, "214.als"); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; borra_pantalla(); lee_dibujos("16.alg"); descomprime_dibujo(dir_dibujo1, MEDIA); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; lee_dibujos("auxbj.alg"); descomprime_dibujo(dir_dibujo3, 1); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; strcpy(num_room,"16.alg"); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; for (l = 0; l < 200; l++) factor_red[l] = 99; @@ -1043,20 +1043,20 @@ void DrasculaEngine::animacion_2() { hare_y = 95; sentido_hare = 1; hare_se_ve = 1; - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; lee_dibujos("97g.alg"); descomprime_dibujo(dir_hare_dch, 1); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; anima("lev.bin", 15); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; lleva_al_hare(100 + ancho_hare / 2, 99 + alto_hare); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; sentido_hare = 1; hare_x = 100; @@ -1082,79 +1082,79 @@ void DrasculaEngine::animacion_2() { anima("gaf.bin", 15); anima("bjb.bin", 14); playmusic(9); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; lee_dibujos("97.alg"); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; descomprime_dibujo(dir_hare_dch, 1); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; refresca_pantalla(); VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; pausa(120); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; habla_solo(TEXT223, "223.als"); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; color_solo = BLANCO; refresca_pantalla(); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); pausa(110); habla_solo(TEXTBJ11, "BJ11.als"); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; refresca_pantalla(); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; pausa(118); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; lleva_al_hare(132, 97 + alto_hare); pausa(60); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; hablar(TEXT224, "224.als"); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; habla_bj(TEXTBJ12, "BJ12.als"); lleva_al_hare(157, 98 + alto_hare); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; anima("bes.bin", 16); playmusic(11); anima("rap.bin", 16); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; sentido_hare = 3; strcpy(num_room, "no_bj.alg"); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; pausa(8); refresca_pantalla(); VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); hablar(TEXT225, "225.als"); pausa(76); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; sentido_hare = 1; refresca_pantalla(); VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); hablar(TEXT226, "226.als"); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; refresca_pantalla(); VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); pausa(30); - if ((term_int == 1) || (getscan() == ESC)) + if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; hablar(TEXT227,"227.als"); FundeAlNegro(0); @@ -1529,7 +1529,7 @@ void DrasculaEngine::comprueba2() { byte DrasculaEngine::getscan() { update_events(); - return _keyPressed.ascii; + return _keyPressed.keycode; } void DrasculaEngine::update_events() { @@ -1544,7 +1544,7 @@ void DrasculaEngine::update_events() { _keyPressed = event.kbd; break; case Common::EVENT_KEYUP: - _keyPressed = event.kbd; + _keyPressed.keycode = Common::KEYCODE_INVALID; break; case Common::EVENT_MOUSEMOVE: x_raton = event.mouse.x; @@ -1836,8 +1836,8 @@ void DrasculaEngine::print_abc(const char *dicho, int x_pantalla, int y_pantalla x_de_letra = X_N; //TODO else if (c == '') // x_de_letra = X_GN; -// else if (c == '') -// x_de_letra = X_GN; + else if (c == '') + x_de_letra = X_GN; else if (c == 'O') x_de_letra = X_O; else if (c == 'P') @@ -2032,7 +2032,7 @@ void DrasculaEngine::confirma_go() { break; } - if (key == 83) { + if (key == Common::KEYCODE_DELETE) { stopmusic(); carga_partida("gsave00"); } @@ -2052,7 +2052,7 @@ void DrasculaEngine::confirma_salir() { break; } - if (key == ESC) { + if (key == Common::KEYCODE_ESCAPE) { stopmusic(); salir_al_dos(0); } @@ -2090,7 +2090,7 @@ void DrasculaEngine::salva_pantallas() { void DrasculaEngine::fliplay(const char *filefli, int vel) { OpenSSN(filefli, vel); while (PlayFrameSSN() && (!term_int)) { - if (getscan() == 27) + if (getscan() == Common::KEYCODE_ESCAPE) term_int = 1; } EndSSN(); @@ -2291,7 +2291,7 @@ void DrasculaEngine::anima(const char *animacion, int FPS) { WaitForNext(FPS); cnt++; byte key = getscan(); - if (key == 0x01) + if (key == Common::KEYCODE_ESCAPE) term_int = 1; if (key != 0) break; @@ -2378,7 +2378,7 @@ bucless: pausa(3); byte key = getscan(); - if (key == ESC) + if (key == Common::KEYCODE_ESCAPE) term_int = 1; if (key != 0) @@ -2501,7 +2501,7 @@ bucless: pausa(3); byte key = getscan(); - if (key == ESC) + if (key == Common::KEYCODE_ESCAPE) term_int = 1; if (key != 0) ctvd_stop(); @@ -2576,7 +2576,7 @@ bucless: pausa(3); byte key = getscan(); - if (key == ESC) + if (key == Common::KEYCODE_ESCAPE) term_int = 1; if (key != 0) ctvd_stop(); @@ -2651,7 +2651,7 @@ bucless: pausa(3); byte key = getscan(); - if (key == ESC) + if (key == Common::KEYCODE_ESCAPE) term_int = 1; if (key != 0) ctvd_stop(); @@ -2704,7 +2704,7 @@ bucless: VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); byte key = getscan(); - if (key == ESC) + if (key == Common::KEYCODE_ESCAPE) term_int = 1; if (key != 0) ctvd_stop(); @@ -2775,7 +2775,7 @@ bucless: pausa(3); byte key = getscan(); - if (key == ESC) + if (key == Common::KEYCODE_ESCAPE) term_int = 1; if (key != 0) ctvd_stop(); @@ -2955,7 +2955,7 @@ bucless: pausa(3); byte key = getscan(); - if (key == ESC) + if (key == Common::KEYCODE_ESCAPE) term_int = 1; if (key != 0) ctvd_stop(); @@ -3062,7 +3062,7 @@ bucless: pausa(3); byte key = getscan(); - if (key == ESC) + if (key == Common::KEYCODE_ESCAPE) term_int = 1; if (key != 0) ctvd_stop(); @@ -3562,94 +3562,94 @@ void DrasculaEngine::introduce_nombre() { VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); key = getscan(); if (key != 0) { -/* if (key == 16) + if (key == Common::KEYCODE_q) select2[v] = 'q'; - else if (key == 17) + else if (key == Common::KEYCODE_w) select2[v] = 'w'; - else if (key == 18) + else if (key == Common::KEYCODE_e) select2[v] = 'e'; - else if (key == 19) + else if (key == Common::KEYCODE_r) select2[v] = 'r'; - else if (key == 20) + else if (key == Common::KEYCODE_t) select2[v] = 't'; - else if (key == 21) + else if (key == Common::KEYCODE_y) select2[v] = 'y'; - else if (key == 22) + else if (key == Common::KEYCODE_u) select2[v] = 'u'; - else if (key == 23) + else if (key == Common::KEYCODE_i) select2[v] = 'i'; - else if (key == 24) + else if (key == Common::KEYCODE_o) select2[v] = 'o'; - else if (key == 25) + else if (key == Common::KEYCODE_p) select2[v] = 'p'; - else if (key == 30) + else if (key == Common::KEYCODE_a) select2[v] = 'a'; - else if (key == 31) + else if (key == Common::KEYCODE_s) select2[v] = 's'; - else if (key == 32) + else if (key == Common::KEYCODE_d) select2[v] = 'd'; - else if (key == 33) + else if (key == Common::KEYCODE_f) select2[v] = 'f'; - else if (key == 34) + else if (key == Common::KEYCODE_g) select2[v] = 'g'; - else if (key == 35) + else if (key == Common::KEYCODE_h) select2[v] = 'h'; - else if (key == 36) + else if (key == Common::KEYCODE_j) select2[v] = 'j'; - else if (key == 37) + else if (key == Common::KEYCODE_k) select2[v] = 'k'; - else if (key == 38) + else if (key == Common::KEYCODE_l) select2[v] = 'l'; - else if (key == 39) + else if ((key == Common::KEYCODE_LCTRL) || (key == Common::KEYCODE_RCTRL)) select2[v] = ''; - else if (key == 44) + else if (key == Common::KEYCODE_z) select2[v] = 'z'; - else if (key == 45) + else if (key == Common::KEYCODE_x) select2[v] = 'x'; - else if (key == 46) + else if (key == Common::KEYCODE_c) select2[v] = 'c'; - else if (key == 47) + else if (key == Common::KEYCODE_v) select2[v] = 'v'; - else if (key == 48) + else if (key == Common::KEYCODE_b) select2[v] = 'b'; - else if (key == 49) + else if (key == Common::KEYCODE_n) select2[v] = 'n'; - else if (key == 50) + else if (key == Common::KEYCODE_m) select2[v] = 'm'; - else if (key == 2) + else if (key == Common::KEYCODE_1) select2[v] = '1'; - else if (key == 3) + else if (key == Common::KEYCODE_2) select2[v] = '2'; - else if (key == 4) + else if (key == Common::KEYCODE_3) select2[v] = '3'; - else if (key == 5) + else if (key == Common::KEYCODE_4) select2[v] = '4'; - else if (key == 6) + else if (key == Common::KEYCODE_5) select2[v] = '5'; - else if (key == 7) + else if (key == Common::KEYCODE_6) select2[v] = '6'; - else if (key == 8) + else if (key == Common::KEYCODE_7) select2[v] = '7'; - else if (key == 9) + else if (key == Common::KEYCODE_8) select2[v] = '8'; - else if (key == 10) + else if (key == Common::KEYCODE_9) select2[v] = '9'; - else if (key == 11) + else if (key == Common::KEYCODE_0) select2[v] = '0'; - else if (key == 57) + else if (key == Common::KEYCODE_SPACE) select2[v] = ''; else if (key == ESC) break; - else if (key == 0x1C) { + else if (key == Common::KEYCODE_RETURN) { select2[v] = '\0'; h = 1; break; - } else if (key == 0x0E) + } else if (key == Common::KEYCODE_BACKSPACE) select2[v] = '\0'; else v--; -*/ - if (key == 0x0E) + + if (key == Common::KEYCODE_BACKSPACE) v--; else v++; -- cgit v1.2.3 From 6a82a3fbfcfda201655b55aea5fec13762e3cd95 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 1 Aug 2007 23:38:31 +0000 Subject: The text of the psychic profile in IHNM is shown correctly now svn-id: r28397 --- engines/saga/sfuncs.cpp | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) (limited to 'engines') diff --git a/engines/saga/sfuncs.cpp b/engines/saga/sfuncs.cpp index c0e105a8fd..a41ecfa6e8 100644 --- a/engines/saga/sfuncs.cpp +++ b/engines/saga/sfuncs.cpp @@ -1417,14 +1417,13 @@ void Script::sfPlacardOff(SCRIPTFUNC_PARAMS) { } void Script::sfPsychicProfile(SCRIPTFUNC_PARAMS) { - int stringId; + int stringId, textHeight; static PalEntry cur_pal[PAL_ENTRIES]; PalEntry *pal; + TextListEntry textEntry; Event event; Event *q_event; - // FIXME: This still needs work: the text placement is incorrect - thread->wait(kWaitTypePlacard); _vm->_interface->rememberMode(); @@ -1469,20 +1468,14 @@ void Script::sfPsychicProfile(SCRIPTFUNC_PARAMS) { q_event = _vm->_events->chain(q_event, &event); - // Put the text in the center of the viewport, assuming it will fit on - // one line. If we cannot make that assumption we'll need to extend - // the text drawing function so that it can center text around a point. - // It doesn't end up in exactly the same spot as the original did it, - // but it's close enough for now at least. - - // FIXME: This assumption is wrong for the psychic profile, the text - // placement is incorrect - - TextListEntry textEntry; + textHeight = _vm->_font->getHeight(kKnownFontVerb, thread->_strings->getString(stringId), 226, kFontCentered); textEntry.knownColor = kKnownColorBlack; - textEntry.point.x = _vm->getDisplayWidth() / 2; - textEntry.point.y = (_vm->_scene->getHeight() - _vm->_font->getHeight(kKnownFontMedium)) / 2; + textEntry.useRect = true; + textEntry.rect.left = 245; + textEntry.rect.setHeight(210 + 76); + textEntry.rect.setWidth(226); + textEntry.rect.top = 210 - textHeight; textEntry.font = kKnownFontVerb; textEntry.flags = (FontEffectFlags)(kFontCentered); textEntry.text = thread->_strings->getString(stringId); -- cgit v1.2.3 From 63f3d5b253fb38e810480d786369eeb1bed5f49e Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 2 Aug 2007 01:04:44 +0000 Subject: Partially implemented opcodes 87, 88 and 89, used in the help system of the IHNM demo. It's still buggy, though svn-id: r28398 --- engines/saga/interface.cpp | 45 +++++++++----- engines/saga/scene.cpp | 93 +++++++++++++++++++++++++++++ engines/saga/scene.h | 1 + engines/saga/script.h | 6 +- engines/saga/sfuncs.cpp | 143 +++++++++++++++------------------------------ 5 files changed, 173 insertions(+), 115 deletions(-) (limited to 'engines') diff --git a/engines/saga/interface.cpp b/engines/saga/interface.cpp index 941262e10e..6811f5ecd0 100644 --- a/engines/saga/interface.cpp +++ b/engines/saga/interface.cpp @@ -463,12 +463,18 @@ void Interface::setMode(int mode) { _vm->_render->setFlag(RF_DEMO_SUBST); break; case kPanelProtect: - _protectPanel.currentButton = NULL; - _textInputMaxWidth = _protectEdit->width - 10; - _textInput = true; - _textInputString[0] = 0; - _textInputStringLength = 0; - _textInputPos = _textInputStringLength + 1; + if (_vm->getGameType() == GType_ITE) { + // This is used as the copy protection panel in ITE + _protectPanel.currentButton = NULL; + _textInputMaxWidth = _protectEdit->width - 10; + _textInput = true; + _textInputString[0] = 0; + _textInputStringLength = 0; + _textInputPos = _textInputStringLength + 1; + } else { + // In the IHNM demo, this panel mode is set by the scripts + // to flip through the pages of the help system + } break; } @@ -671,18 +677,25 @@ bool Interface::processAscii(uint16 ascii) { keyBossExit(); break; case kPanelProtect: - if (_textInput && processTextInput(ascii)) { - return true; - } + if (_vm->getGameType() == GType_ITE) { + if (_textInput && processTextInput(ascii)) { + return true; + } - if (ascii == 27 || ascii == 13) { // Esc or Enter - _vm->_script->wakeUpThreads(kWaitTypeRequest); - _vm->_interface->setMode(kPanelMain); - - _protectHash = 0; + if (ascii == 27 || ascii == 13) { // Esc or Enter + _vm->_script->wakeUpThreads(kWaitTypeRequest); + _vm->_interface->setMode(kPanelMain); + + _protectHash = 0; - for (char *p = _textInputString; *p; p++) - _protectHash = (_protectHash << 1) + toupper(*p); + for (char *p = _textInputString; *p; p++) + _protectHash = (_protectHash << 1) + toupper(*p); + } + } else { + // In the IHNM demo, this panel mode is set by the scripts + // to flip through the pages of the help system + // Any keypress here returns the user back to the game + _vm->_scene->clearPsychicProfile(); } break; case kPanelPlacard: diff --git a/engines/saga/scene.cpp b/engines/saga/scene.cpp index 3c98421361..4510bcc24c 100644 --- a/engines/saga/scene.cpp +++ b/engines/saga/scene.cpp @@ -1360,6 +1360,99 @@ void Scene::clearPlacard() { q_event = _vm->_events->chain(q_event, &event); } +void Scene::showPsychicProfile(const char *text) { + int textHeight; + static PalEntry cur_pal[PAL_ENTRIES]; + PalEntry *pal; + TextListEntry textEntry; + Event event; + Event *q_event; + + if (_vm->_interface->getMode() == kPanelPlacard) + return; + + _vm->_interface->rememberMode(); + _vm->_interface->setMode(kPanelPlacard); + _vm->_gfx->savePalette(); + + event.type = kEvTOneshot; + event.code = kCursorEvent; + event.op = kEventHide; + + q_event = _vm->_events->queue(&event); + + _vm->_gfx->getCurrentPal(cur_pal); + + event.type = kEvTImmediate; + event.code = kPalEvent; + event.op = kEventPalToBlack; + event.time = 0; + event.duration = kNormalFadeDuration; + event.data = cur_pal; + + q_event = _vm->_events->chain(q_event, &event); + + event.type = kEvTOneshot; + event.code = kInterfaceEvent; + event.op = kEventClearStatus; + + q_event = _vm->_events->chain(q_event, &event); + + event.type = kEvTOneshot; + event.code = kGraphicsEvent; + event.op = kEventSetFlag; + event.param = RF_PLACARD; + + q_event = _vm->_events->chain(q_event, &event); + + // Set the background and palette for the psychic profile + event.type = kEvTOneshot; + event.code = kPsychicProfileBgEvent; + + q_event = _vm->_events->chain(q_event, &event); + + if (text != NULL) { + textHeight = _vm->_font->getHeight(kKnownFontVerb, text, 226, kFontCentered); + + textEntry.knownColor = kKnownColorBlack; + textEntry.useRect = true; + textEntry.rect.left = 245; + textEntry.rect.setHeight(210 + 76); + textEntry.rect.setWidth(226); + textEntry.rect.top = 210 - textHeight; + textEntry.font = kKnownFontVerb; + textEntry.flags = (FontEffectFlags)(kFontCentered); + textEntry.text = text; + + TextListEntry *_psychicProfileTextEntry = _vm->_scene->_textList.addEntry(textEntry); + + event.type = kEvTOneshot; + event.code = kTextEvent; + event.op = kEventDisplay; + event.data = _psychicProfileTextEntry; + + q_event = _vm->_events->chain(q_event, &event); + } + + _vm->_scene->getBGPal(pal); + + event.type = kEvTImmediate; + event.code = kPalEvent; + event.op = kEventBlackToPal; + event.time = 0; + event.duration = kNormalFadeDuration; + event.data = pal; + + q_event = _vm->_events->chain(q_event, &event); + + event.type = kEvTOneshot; + event.code = kScriptEvent; + event.op = kEventThreadWake; + event.param = kWaitTypePlacard; + + q_event = _vm->_events->chain(q_event, &event); +} + void Scene::clearPsychicProfile() { if (_vm->_interface->getMode() == kPanelPlacard) { _vm->_scene->clearPlacard(); diff --git a/engines/saga/scene.h b/engines/saga/scene.h index 9666a6a6e8..da97bddff5 100644 --- a/engines/saga/scene.h +++ b/engines/saga/scene.h @@ -341,6 +341,7 @@ class Scene { } void clearPlacard(); + void showPsychicProfile(const char *text); void clearPsychicProfile(); void showIHNMDemoSpecialScreen(); diff --git a/engines/saga/script.h b/engines/saga/script.h index 04181ae7d2..74f26142bd 100644 --- a/engines/saga/script.h +++ b/engines/saga/script.h @@ -591,9 +591,9 @@ private: void sfScriptStartVideo(SCRIPTFUNC_PARAMS); void sfScriptReturnFromVideo(SCRIPTFUNC_PARAMS); void sfScriptEndVideo(SCRIPTFUNC_PARAMS); - void sf87(SCRIPTFUNC_PARAMS); - void sf88(SCRIPTFUNC_PARAMS); - void sf89(SCRIPTFUNC_PARAMS); + void sfShowIHNMDemoHelp(SCRIPTFUNC_PARAMS); + void sfShowIHNMDemoHelpText(SCRIPTFUNC_PARAMS); + void sfClearIHNMDemoHelpText(SCRIPTFUNC_PARAMS); void sfGetPoints(SCRIPTFUNC_PARAMS); void sfSetGlobalFlag(SCRIPTFUNC_PARAMS); void sf92(SCRIPTFUNC_PARAMS); diff --git a/engines/saga/sfuncs.cpp b/engines/saga/sfuncs.cpp index a41ecfa6e8..8a5b52fd25 100644 --- a/engines/saga/sfuncs.cpp +++ b/engines/saga/sfuncs.cpp @@ -225,9 +225,9 @@ static const ScriptFunctionDescription IHNMscriptFunctionsList[IHNM_SCRIPT_FUNCT OPCODE(sfScriptReturnFromVideo), OPCODE(sfScriptEndVideo), OPCODE(sfSetActorZ), - OPCODE(sf87), - OPCODE(sf88), - OPCODE(sf89), + OPCODE(sfShowIHNMDemoHelp), + OPCODE(sfShowIHNMDemoHelpText), + OPCODE(sfClearIHNMDemoHelpText), OPCODE(sfVstopFX), OPCODE(sfVstopLoopedFX), OPCODE(sf92), // only used in the demo version of IHNM @@ -1417,95 +1417,10 @@ void Script::sfPlacardOff(SCRIPTFUNC_PARAMS) { } void Script::sfPsychicProfile(SCRIPTFUNC_PARAMS) { - int stringId, textHeight; - static PalEntry cur_pal[PAL_ENTRIES]; - PalEntry *pal; - TextListEntry textEntry; - Event event; - Event *q_event; - thread->wait(kWaitTypePlacard); - _vm->_interface->rememberMode(); - _vm->_interface->setMode(kPanelPlacard); - _vm->_gfx->savePalette(); - - stringId = thread->pop(); - - event.type = kEvTOneshot; - event.code = kCursorEvent; - event.op = kEventHide; - - q_event = _vm->_events->queue(&event); - - _vm->_gfx->getCurrentPal(cur_pal); - - event.type = kEvTImmediate; - event.code = kPalEvent; - event.op = kEventPalToBlack; - event.time = 0; - event.duration = kNormalFadeDuration; - event.data = cur_pal; - - q_event = _vm->_events->chain(q_event, &event); - - event.type = kEvTOneshot; - event.code = kInterfaceEvent; - event.op = kEventClearStatus; - - q_event = _vm->_events->chain(q_event, &event); - - event.type = kEvTOneshot; - event.code = kGraphicsEvent; - event.op = kEventSetFlag; - event.param = RF_PLACARD; - - q_event = _vm->_events->chain(q_event, &event); - - // Set the background and palette for the psychic profile - event.type = kEvTOneshot; - event.code = kPsychicProfileBgEvent; - - q_event = _vm->_events->chain(q_event, &event); - - textHeight = _vm->_font->getHeight(kKnownFontVerb, thread->_strings->getString(stringId), 226, kFontCentered); - - textEntry.knownColor = kKnownColorBlack; - textEntry.useRect = true; - textEntry.rect.left = 245; - textEntry.rect.setHeight(210 + 76); - textEntry.rect.setWidth(226); - textEntry.rect.top = 210 - textHeight; - textEntry.font = kKnownFontVerb; - textEntry.flags = (FontEffectFlags)(kFontCentered); - textEntry.text = thread->_strings->getString(stringId); - - _placardTextEntry = _vm->_scene->_textList.addEntry(textEntry); - - event.type = kEvTOneshot; - event.code = kTextEvent; - event.op = kEventDisplay; - event.data = _placardTextEntry; - - q_event = _vm->_events->chain(q_event, &event); - - _vm->_scene->getBGPal(pal); - - event.type = kEvTImmediate; - event.code = kPalEvent; - event.op = kEventBlackToPal; - event.time = 0; - event.duration = kNormalFadeDuration; - event.data = pal; - - q_event = _vm->_events->chain(q_event, &event); - - event.type = kEvTOneshot; - event.code = kScriptEvent; - event.op = kEventThreadWake; - event.param = kWaitTypePlacard; - - q_event = _vm->_events->chain(q_event, &event); + int stringId = thread->pop(); + _vm->_scene->showPsychicProfile(thread->_strings->getString(stringId)); } void Script::sfPsychicProfileOff(SCRIPTFUNC_PARAMS) { @@ -2083,16 +1998,52 @@ void Script::sfScriptEndVideo(SCRIPTFUNC_PARAMS) { _vm->_anim->endVideo(); } -void Script::sf87(SCRIPTFUNC_PARAMS) { - SF_stub("sf87", thread, nArgs); +void Script::sfShowIHNMDemoHelp(SCRIPTFUNC_PARAMS) { + thread->wait(kWaitTypePlacard); + + _vm->_scene->showPsychicProfile(NULL); } -void Script::sf88(SCRIPTFUNC_PARAMS) { - SF_stub("sf88", thread, nArgs); +void Script::sfShowIHNMDemoHelpText(SCRIPTFUNC_PARAMS) { + int stringId, textHeight; + TextListEntry textEntry; + Event event; + + stringId = thread->pop(); + + // FIXME: This is called multiple times in a row, one for each page of the help screens. We should wait + // somehow before showing the next page + + textHeight = _vm->_font->getHeight(kKnownFontVerb, thread->_strings->getString(stringId), 226, kFontCentered); + + textEntry.knownColor = kKnownColorBlack; + textEntry.useRect = true; + textEntry.rect.left = 245; + textEntry.rect.setHeight(210 + 76); + textEntry.rect.setWidth(226); + textEntry.rect.top = 210 - textHeight; + textEntry.font = kKnownFontVerb; + textEntry.flags = (FontEffectFlags)(kFontCentered); + textEntry.text = thread->_strings->getString(stringId); + + TextListEntry *_psychicProfileTextEntry = _vm->_scene->_textList.addEntry(textEntry); + + event.type = kEvTOneshot; + event.code = kTextEvent; + event.op = kEventDisplay; + event.data = _psychicProfileTextEntry; + + _vm->_events->queue(&event); } -void Script::sf89(SCRIPTFUNC_PARAMS) { - SF_stub("sf89", thread, nArgs); +void Script::sfClearIHNMDemoHelpText(SCRIPTFUNC_PARAMS) { + thread->wait(kWaitTypePlacard); + + // This is called a while after the psychic profile is + // opened in the IHNM demo, to flip through the help system pages + _vm->_scene->clearPsychicProfile(); + // FIXME: The demo uses mode 8 when changing pages + //_vm->_interface->setMode(8); } void Script::sfVstopFX(SCRIPTFUNC_PARAMS) { -- cgit v1.2.3 From ec4a240b502f7be2c67582382b4af4f0451aa035 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 2 Aug 2007 01:56:45 +0000 Subject: The help screens in the IHNM demo are shown a bit more correctly now, though they're still buggy svn-id: r28399 --- engines/saga/scene.cpp | 1 + engines/saga/script.h | 1 + engines/saga/sfuncs.cpp | 17 ++++++++++++----- 3 files changed, 14 insertions(+), 5 deletions(-) (limited to 'engines') diff --git a/engines/saga/scene.cpp b/engines/saga/scene.cpp index 4510bcc24c..3ae0e9c950 100644 --- a/engines/saga/scene.cpp +++ b/engines/saga/scene.cpp @@ -1424,6 +1424,7 @@ void Scene::showPsychicProfile(const char *text) { textEntry.flags = (FontEffectFlags)(kFontCentered); textEntry.text = text; + _vm->_scene->_textList.clear(); TextListEntry *_psychicProfileTextEntry = _vm->_scene->_textList.addEntry(textEntry); event.type = kEvTOneshot; diff --git a/engines/saga/script.h b/engines/saga/script.h index 74f26142bd..1c05182647 100644 --- a/engines/saga/script.h +++ b/engines/saga/script.h @@ -444,6 +444,7 @@ private: int _stickyVerb; int _leftButtonVerb; int _rightButtonVerb; + int _ihnmDemoCurrentY; public: uint16 _pendingObject[2]; diff --git a/engines/saga/sfuncs.cpp b/engines/saga/sfuncs.cpp index 8a5b52fd25..0efbef0ca2 100644 --- a/engines/saga/sfuncs.cpp +++ b/engines/saga/sfuncs.cpp @@ -2001,6 +2001,7 @@ void Script::sfScriptEndVideo(SCRIPTFUNC_PARAMS) { void Script::sfShowIHNMDemoHelp(SCRIPTFUNC_PARAMS) { thread->wait(kWaitTypePlacard); + _ihnmDemoCurrentY = 0; _vm->_scene->showPsychicProfile(NULL); } @@ -2011,9 +2012,6 @@ void Script::sfShowIHNMDemoHelpText(SCRIPTFUNC_PARAMS) { stringId = thread->pop(); - // FIXME: This is called multiple times in a row, one for each page of the help screens. We should wait - // somehow before showing the next page - textHeight = _vm->_font->getHeight(kKnownFontVerb, thread->_strings->getString(stringId), 226, kFontCentered); textEntry.knownColor = kKnownColorBlack; @@ -2021,11 +2019,14 @@ void Script::sfShowIHNMDemoHelpText(SCRIPTFUNC_PARAMS) { textEntry.rect.left = 245; textEntry.rect.setHeight(210 + 76); textEntry.rect.setWidth(226); - textEntry.rect.top = 210 - textHeight; + textEntry.rect.top = 76 + _ihnmDemoCurrentY; textEntry.font = kKnownFontVerb; textEntry.flags = (FontEffectFlags)(kFontCentered); textEntry.text = thread->_strings->getString(stringId); + if (_ihnmDemoCurrentY == 0) + _vm->_scene->_textList.clear(); + TextListEntry *_psychicProfileTextEntry = _vm->_scene->_textList.addEntry(textEntry); event.type = kEvTOneshot; @@ -2034,16 +2035,22 @@ void Script::sfShowIHNMDemoHelpText(SCRIPTFUNC_PARAMS) { event.data = _psychicProfileTextEntry; _vm->_events->queue(&event); + + _ihnmDemoCurrentY += 10; } void Script::sfClearIHNMDemoHelpText(SCRIPTFUNC_PARAMS) { thread->wait(kWaitTypePlacard); + warning("TODO: sfClearIHNMDemoHelpText"); + // This is called a while after the psychic profile is // opened in the IHNM demo, to flip through the help system pages - _vm->_scene->clearPsychicProfile(); + _vm->_scene->clearPlacard(); // FIXME: The demo uses mode 8 when changing pages //_vm->_interface->setMode(8); + _vm->_interface->setMode(7); + _ihnmDemoCurrentY = 0; } void Script::sfVstopFX(SCRIPTFUNC_PARAMS) { -- cgit v1.2.3 From 014de3cfe795d3d181e5a8cc9f9e8099d41b5d81 Mon Sep 17 00:00:00 2001 From: Paweł Kołodziejski Date: Thu, 2 Aug 2007 06:47:04 +0000 Subject: formating svn-id: r28400 --- engines/drascula/drascula.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp index f5fb35a715..a91ad730aa 100644 --- a/engines/drascula/drascula.cpp +++ b/engines/drascula/drascula.cpp @@ -757,7 +757,7 @@ void DrasculaEngine::animacion_1() { habla_igor_dch(TEXTI8, "I8.als"); if ((term_int == 1) || (getscan() == Common::KEYCODE_ESCAPE)) break; - DIBUJA_FONDO(0, 0, 0,0, 320, 200, dir_dibujo1, dir_zona_pantalla); + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); pon_igor(); pon_dr(); VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); -- cgit v1.2.3 From 46d6ffcdf67da9925b22364a4593b396e120cd4c Mon Sep 17 00:00:00 2001 From: Paweł Kołodziejski Date: Thu, 2 Aug 2007 07:09:28 +0000 Subject: allow engine shutdown and restart with diffrent mode svn-id: r28401 --- engines/drascula/drascula.cpp | 140 ++++++++++++++++++++++-------------------- engines/drascula/drascula.h | 9 +-- 2 files changed, 80 insertions(+), 69 deletions(-) (limited to 'engines') diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp index a91ad730aa..44f377d0f1 100644 --- a/engines/drascula/drascula.cpp +++ b/engines/drascula/drascula.cpp @@ -82,8 +82,6 @@ DrasculaEngine::DrasculaEngine(OSystem *syst) : Engine(syst) { DrasculaEngine::~DrasculaEngine() { salir_al_dos(0); - free(VGA); - delete _rnd; } @@ -130,68 +128,72 @@ int DrasculaEngine::init() { _system->initSize(320, 200); _system->endGFXTransaction(); - VGA = (byte *)malloc(320 * 200); - memset(VGA, 0, 64000); - - lleva_objeto = 0; - menu_bar = 0; menu_scr = 0; hay_nombre = 0; - frame_y = 0; - hare_x = -1; hare_se_mueve = 0; sentido_hare = 3; num_frame = 0; hare_se_ve = 1; - comprueba_flags = 1; - rompo = 0; rompo2 = 0; - anda_a_objeto = 0; - paso_x = PASO_HARE_X; paso_y = PASO_HARE_Y; - alto_hare = ALTO_PERSONAJE; ancho_hare = ANCHO_PERSONAJE; alto_pies = PIES_HARE; - alto_habla = ALTO_HABLA_HARE; ancho_habla = ANCHO_HABLA_HARE; - hay_respuesta = 0; - conta_ciego_vez = 0; - cambio_de_color = 0; - rompo_y_salgo = 0; - vb_x = 120; sentido_vb = 1; vb_se_mueve = 0; frame_vb = 1; - frame_piano = 0; - frame_borracho = 0; - frame_velas = 0; - cont_sv = 0; - term_int = 0; - num_ejec = 1; - cual_ejec = 0; hay_que_load = 0; - corta_musica = 0; - hay_seleccion = 0; - Leng = 0; - UsingMem = 0; - GlobalSpeed = 0; - - - - asigna_memoria(); - carga_info(); - - return 0; } int DrasculaEngine::go() { - lee_dibujos("95.alg"); - descomprime_dibujo(dir_mesa, 1); + _gameMode = 1; - lee_dibujos("96.alg"); - descomprime_dibujo(dir_hare_frente, COMPLETA); - lee_dibujos("99.alg"); - descomprime_dibujo(dir_hare_fondo, 1); - lee_dibujos("97.alg"); - descomprime_dibujo(dir_hare_dch, 1); + for (;;) { + VGA = (byte *)malloc(320 * 200); + memset(VGA, 0, 64000); + + lleva_objeto = 0; + menu_bar = 0; menu_scr = 0; hay_nombre = 0; + frame_y = 0; + hare_x = -1; hare_se_mueve = 0; sentido_hare = 3; num_frame = 0; hare_se_ve = 1; + comprueba_flags = 1; + rompo = 0; rompo2 = 0; + anda_a_objeto = 0; + paso_x = PASO_HARE_X; paso_y = PASO_HARE_Y; + alto_hare = ALTO_PERSONAJE; ancho_hare = ANCHO_PERSONAJE; alto_pies = PIES_HARE; + alto_habla = ALTO_HABLA_HARE; ancho_habla = ANCHO_HABLA_HARE; + hay_respuesta = 0; + conta_ciego_vez = 0; + cambio_de_color = 0; + rompo_y_salgo = 0; + vb_x = 120; sentido_vb = 1; vb_se_mueve = 0; frame_vb = 1; + frame_piano = 0; + frame_borracho = 0; + frame_velas = 0; + cont_sv = 0; + term_int = 0; + num_ejec = 1; + cual_ejec = 0; hay_que_load = 0; + corta_musica = 0; + hay_seleccion = 0; + Leng = 0; + UsingMem = 0; + GlobalSpeed = 0; + + asigna_memoria(); + carga_info(); - strcpy(nombre_icono[1], "look"); - strcpy(nombre_icono[2], "take"); - strcpy(nombre_icono[3], "open"); - strcpy(nombre_icono[4], "close"); - strcpy(nombre_icono[5], "talk"); - strcpy(nombre_icono[6], "push"); + lee_dibujos("95.alg"); + descomprime_dibujo(dir_mesa, 1); - paleta_hare(); - escoba(); + lee_dibujos("96.alg"); + descomprime_dibujo(dir_hare_frente, COMPLETA); + lee_dibujos("99.alg"); + descomprime_dibujo(dir_hare_fondo, 1); + lee_dibujos("97.alg"); + descomprime_dibujo(dir_hare_dch, 1); + strcpy(nombre_icono[1], "look"); + strcpy(nombre_icono[2], "take"); + strcpy(nombre_icono[3], "open"); + strcpy(nombre_icono[4], "close"); + strcpy(nombre_icono[5], "talk"); + strcpy(nombre_icono[6], "push"); + + paleta_hare(); + if (escoba()) { + salir_al_dos(0); + break; + } + salir_al_dos(0); + } return 0; } @@ -203,8 +205,7 @@ void DrasculaEngine::salir_al_dos(int r) { MusicFadeout(); stopmusic(); libera_memoria(); - if (r == 2) - error("Game reach next segment"); + free(VGA); } void DrasculaEngine::asigna_memoria() { @@ -413,7 +414,7 @@ void DrasculaEngine::VUELCA_PANTALLA(int xorg, int yorg, int xdes, int ydes, int _system->updateScreen(); } -void DrasculaEngine::escoba() { +bool DrasculaEngine::escoba() { int soc, l, n; dir_texto = dir_mesa; @@ -500,7 +501,8 @@ bucles: elige_en_barra(); cont_sv = 0; } else if (boton_izq == 1 && lleva_objeto == 0) { - comprueba1(); + if (comprueba1()) + return true; cont_sv = 0; } else if (boton_izq == 1 && lleva_objeto == 1) { comprueba2(); @@ -956,7 +958,7 @@ void DrasculaEngine::animacion_1() { descomprime_dibujo(dir_hare_fondo, 1); } -void DrasculaEngine::animacion_2() { +bool DrasculaEngine::animacion_2() { int l; lleva_al_hare(231, 91); @@ -1160,7 +1162,9 @@ void DrasculaEngine::animacion_2() { FundeAlNegro(0); break; } - salir_al_dos(2); + + _gameMode = 2; + return true; } void DrasculaEngine::sin_verbo() { @@ -1455,7 +1459,7 @@ void DrasculaEngine::elige_en_barra() { elige_verbo(num_verbo); } -void DrasculaEngine::comprueba1() { +bool DrasculaEngine::comprueba1() { int l; if (menu_scr == 1) @@ -1464,7 +1468,8 @@ void DrasculaEngine::comprueba1() { for (l = 0; l < objs_room; l++) { if (x_raton >= x1[l] && y_raton >= y1[l] && x_raton <= x2[l] && y_raton <= y2[l] && rompo == 0) { - sal_de_la_habitacion(l); + if (sal_de_la_habitacion(l)) + return true; if (rompo == 1) break; } @@ -1503,6 +1508,8 @@ void DrasculaEngine::comprueba1() { } rompo = 0; } + + return false; } void DrasculaEngine::comprueba2() { @@ -3439,7 +3446,7 @@ void DrasculaEngine::saca_objeto() { elige_objeto(h); } -void DrasculaEngine::sal_de_la_habitacion(int l) { +bool DrasculaEngine::sal_de_la_habitacion(int l) { char salgo[13]; if (num_obj[l] == 105 && flags[0] == 0) @@ -3459,7 +3466,8 @@ void DrasculaEngine::sal_de_la_habitacion(int l) { musica_antes = musica_room; if (num_obj[l] == 105) - animacion_2(); + if (animacion_2()) + return true; borra_pantalla(); strcpy(salgo, alapantallakeva[l]); strcat(salgo, ".ald"); @@ -3467,6 +3475,8 @@ void DrasculaEngine::sal_de_la_habitacion(int l) { carga_escoba(salgo); } } + + return false; } void DrasculaEngine::coge_objeto() { diff --git a/engines/drascula/drascula.h b/engines/drascula/drascula.h index 4e737a8870..91ace757c4 100644 --- a/engines/drascula/drascula.h +++ b/engines/drascula/drascula.h @@ -467,13 +467,14 @@ public: int y_raton_ant; int boton_izq; int boton_dch; + int _gameMode; - void escoba(); + bool escoba(); void Negro(); void agarra_objeto(int); void buffer_teclado() { } void animacion_1(); - void animacion_2(); + bool animacion_2(); void sin_verbo(); void para_cargar(char[]); void carga_escoba(const char *); @@ -484,7 +485,7 @@ public: void espera_soltar(); void MirarRaton(); void elige_en_barra(); - void comprueba1(); + bool comprueba1(); void comprueba2(); byte getscan(); void elige_verbo(int); @@ -543,7 +544,7 @@ public: void menu_sin_volcar(); void barra_menu(); void saca_objeto(); - void sal_de_la_habitacion(int); + bool sal_de_la_habitacion(int); void coge_objeto(); void banderas(int); void cursor_mesa(); -- cgit v1.2.3 From 482d626663cc1c83edbe6c043398a2e8c4ce3703 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Thu, 2 Aug 2007 08:07:39 +0000 Subject: Fixing compilation for Raziel_AOne ;) svn-id: r28402 --- engines/gob/coktelvideo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/gob/coktelvideo.cpp b/engines/gob/coktelvideo.cpp index cd497293af..964abc8369 100644 --- a/engines/gob/coktelvideo.cpp +++ b/engines/gob/coktelvideo.cpp @@ -1279,7 +1279,7 @@ void Vmd::deDPCM(byte *soundBuf, byte *dataBuf, int16 &init, uint32 n) { else s += _tableDPCM[dataBuf[i]]; - s = CLIP(s, -32768, 32767); + s = CLIP(s, -32768, 32767); *out++ = TO_BE_16(s); } } -- cgit v1.2.3 From d51b3b4f6295742c4b018585df1c129d76858566 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Thu, 2 Aug 2007 09:01:58 +0000 Subject: Added Italian Woodruff, as supplied by Hkz on #scummvm svn-id: r28403 --- engines/gob/detection.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'engines') diff --git a/engines/gob/detection.cpp b/engines/gob/detection.cpp index 18c7e31717..83b66a4177 100644 --- a/engines/gob/detection.cpp +++ b/engines/gob/detection.cpp @@ -1332,6 +1332,45 @@ static const GOBGameDescription gameDescriptions[] = { kFeatures640, "intro" }, + { // Supplied by Hkz on #scummvm + { + "woodruff", + "", + AD_ENTRY1s("intro.stk", "f4c344023b073782d2fddd9d8b515318", 7069736), + IT_ITA, + kPlatformPC, + Common::ADGF_NO_FLAGS + }, + kGameTypeWoodruff, + kFeatures640, + "intro" + }, + { // Supplied by Hkz on #scummvm + { + "woodruff", + "", + AD_ENTRY1s("intro.stk", "f4c344023b073782d2fddd9d8b515318", 7069736), + DE_DEU, + kPlatformPC, + Common::ADGF_NO_FLAGS + }, + kGameTypeWoodruff, + kFeatures640, + "intro" + }, + { // Supplied by Hkz on #scummvm + { + "woodruff", + "", + AD_ENTRY1s("intro.stk", "f4c344023b073782d2fddd9d8b515318", 7069736), + FR_FRA, + kPlatformPC, + Common::ADGF_NO_FLAGS + }, + kGameTypeWoodruff, + kFeatures640, + "intro" + }, /*{ { "dynasty", -- cgit v1.2.3 From 8299835cad43c4da9cc594647e805913fd95841a Mon Sep 17 00:00:00 2001 From: Kari Salminen Date: Thu, 2 Aug 2007 11:10:26 +0000 Subject: Added methods for reading Apple IIGS AGI samples and creating AudioStream-objects out of them. Commented out some code to make things compile. svn-id: r28404 --- engines/agi/sound.cpp | 100 +++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 87 insertions(+), 13 deletions(-) (limited to 'engines') diff --git a/engines/agi/sound.cpp b/engines/agi/sound.cpp index 954cca8f8f..f65839de97 100644 --- a/engines/agi/sound.cpp +++ b/engines/agi/sound.cpp @@ -72,15 +72,13 @@ struct SoundInstrument { struct SoundWavelist wbl[8]; }; -struct SoundIIgsSample { - uint8 typeLo; - uint8 typeHi; - uint8 srateLo; - uint8 srateHi; - uint16 unknown[2]; - uint8 sizeLo; - uint8 sizeHi; - uint16 unknown2[13]; +#define IIGS_SAMPLE_HEADER_SIZE 54 +struct IIgsSampleHeader { + uint16 type; + uint8 pitch; ///< Logarithmic, base is 2**(1/12), unknown multiplier (Possibly in range 1040-1080) + uint8 unknown[5]; + uint16 size; + uint8 unknown2[44]; }; #if 0 @@ -89,6 +87,82 @@ static int numInstruments; static uint8 *wave; #endif +/** + * Read an Apple IIGS AGI sample header from the given stream. + * @param header The header to which to write the data. + * @param stream The source stream from which to read the data. + * @return True if successful, false otherwise. + */ +bool readIIgsSampleHeader(IIgsSampleHeader &header, Common::SeekableReadStream &stream) { + // Check there's room in the stream for the header + if (stream.size() - stream.pos() >= IIGS_SAMPLE_HEADER_SIZE) { + header.type = stream.readUint16LE(); + header.pitch = stream.readByte(); + // Gold Rush's sample resource 60 (A looping sound of horse's hoof hitting + // pavement) is the only one that has 0x7F at header offset 3, all other + // samples have 0x00 there. + stream.read(header.unknown, 5); + header.size = stream.readUint16LE(); + stream.read(header.unknown2, 44); + return !stream.ioFailed(); + } else // No room in the stream for the header, so failure + return false; +} + +/** + * Load an Apple IIGS AGI sample resource from the given stream and + * create an AudioStream out of it. + * + * @param stream The source stream. + * @param resnum Sound resource number. Optional. Used for error messages. + * @return A non-null AudioStream pointer if successful, NULL otherwise. + * @note In case of failure (i.e. NULL is returned), stream is reset back + * to its original position and its I/O failed -status is cleared. + * TODO: Add better handling of invalid resource number when printing error messages. + * TODO: Add support for looping sounds. + * FIXME: Fix sample rate calculation, it's probably not accurate at the moment. + */ +Audio::AudioStream *makeIIgsSampleStream(Common::SeekableReadStream &stream, int resnum = -1) { + const uint32 startPos = stream.pos(); + IIgsSampleHeader header; + Audio::AudioStream *result = NULL; + bool readHeaderOk = readIIgsSampleHeader(header, stream); + + // Check that the header was read ok and that it's of the correct type + // and that there's room for the sample data in the stream. + if (readHeaderOk && header.type == AGI_SOUND_SAMPLE) { // An Apple IIGS AGI sample resource + uint32 tailLen = stream.size() - stream.pos(); + if (tailLen < header.size) { // Check if there's no room for the sample data in the stream + // Apple IIGS Manhunter I: Sound resource 16 has only 16074 bytes + // of sample data although header says it should have 16384 bytes. + warning("Apple IIGS sample (%d) too short (%d bytes. Should be %d bytes). Using the part that's left", resnum, tailLen, header.size); + header.size = (uint16) tailLen; // Use the part that's left + } + if (header.pitch > 0x7F) { // Check if the pitch is invalid + warning("Apple IIGS sample (%d) has too high pitch (0x%02x)", resnum, header.pitch); + header.pitch &= 0x7F; // Apple IIGS AGI probably did it this way too + } + // Allocate memory for the sample data and read it in + byte *sampleData = (byte *) malloc(header.size); + uint32 readBytes = stream.read(sampleData, header.size); + if (readBytes == header.size) { // Check that we got all the data we requested + // Make an audio stream from the mono, 8 bit, unsigned input data + byte flags = Audio::Mixer::FLAG_AUTOFREE | Audio::Mixer::FLAG_UNSIGNED; + int rate = (int) (1076 * pow(pow(2, 1/12.0), header.pitch)); + result = Audio::makeLinearInputStream(sampleData, header.size, rate, flags, 0, 0); + } + } + + // If couldn't make a sample out of the input stream for any reason then + // rewind back to stream's starting position and clear I/O failed -status. + if (result == NULL) { + stream.seek(startPos); + stream.clearIOFailed(); + } + + return result; +} + #endif static int playing; @@ -169,7 +243,7 @@ void SoundMgr::unloadSound(int resnum) { } void SoundMgr::decodeSound(int resnum) { -#ifdef USE_IIGS_SOUND +#if 0 int type, size; int16 *buf; uint8 *src; @@ -190,12 +264,12 @@ void SoundMgr::decodeSound(int resnum) { _vm->_game.sounds[resnum].rdata = (uint8 *) buf; free(src); } -#endif /* USE_IIGS_SOUND */ +#endif } void SoundMgr::startSound(int resnum, int flag) { int i, type; -#ifdef USE_IIGS_SOUND +#if 0 struct SoundIIgsSample *smp; #endif @@ -218,7 +292,7 @@ void SoundMgr::startSound(int resnum, int flag) { song = (uint8 *)_vm->_game.sounds[resnum].rdata; switch (type) { -#ifdef USE_IIGS_SOUND +#if 0 case AGI_SOUND_SAMPLE: debugC(3, kDebugLevelSound, "IIGS sample"); smp = (struct SoundIIgsSample *)_vm->_game.sounds[resnum].rdata; -- cgit v1.2.3 From af16be07a1dad35993d06056cf072b03ee5c63e9 Mon Sep 17 00:00:00 2001 From: Kari Salminen Date: Thu, 2 Aug 2007 11:39:45 +0000 Subject: Added reading of volume parameter from Apple IIGS AGI sample header. svn-id: r28405 --- engines/agi/sound.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/agi/sound.cpp b/engines/agi/sound.cpp index f65839de97..ad8700bbe7 100644 --- a/engines/agi/sound.cpp +++ b/engines/agi/sound.cpp @@ -76,9 +76,11 @@ struct SoundInstrument { struct IIgsSampleHeader { uint16 type; uint8 pitch; ///< Logarithmic, base is 2**(1/12), unknown multiplier (Possibly in range 1040-1080) - uint8 unknown[5]; + uint8 unknown_Ofs3_Len1; + uint8 volume; ///< Current guess: Logarithmic in 6 dB steps + uint8 unknown_Ofs5_Len3[3]; uint16 size; - uint8 unknown2[44]; + uint8 unknown_Ofs10_Len44[44]; }; #if 0 @@ -101,9 +103,11 @@ bool readIIgsSampleHeader(IIgsSampleHeader &header, Common::SeekableReadStream & // Gold Rush's sample resource 60 (A looping sound of horse's hoof hitting // pavement) is the only one that has 0x7F at header offset 3, all other // samples have 0x00 there. - stream.read(header.unknown, 5); + header.unknown_Ofs3_Len1 = stream.readByte(); + header.volume = stream.readByte(); + stream.read(header.unknown_Ofs5_Len3, 3); header.size = stream.readUint16LE(); - stream.read(header.unknown2, 44); + stream.read(header.unknown_Ofs10_Len44, 44); return !stream.ioFailed(); } else // No room in the stream for the header, so failure return false; -- cgit v1.2.3 From 3e9c4be28026a4ef3c3a790073f2a42738374819 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 2 Aug 2007 14:43:10 +0000 Subject: The help screen in the IHNM demo is shown correctly now svn-id: r28406 --- engines/saga/interface.cpp | 21 ++++++++++++++++----- engines/saga/scene.cpp | 6 ++++-- engines/saga/script.h | 6 +++--- engines/saga/sfuncs.cpp | 28 ++++++++++------------------ 4 files changed, 33 insertions(+), 28 deletions(-) (limited to 'engines') diff --git a/engines/saga/interface.cpp b/engines/saga/interface.cpp index 6811f5ecd0..8cfd993391 100644 --- a/engines/saga/interface.cpp +++ b/engines/saga/interface.cpp @@ -694,14 +694,18 @@ bool Interface::processAscii(uint16 ascii) { } else { // In the IHNM demo, this panel mode is set by the scripts // to flip through the pages of the help system - // Any keypress here returns the user back to the game - _vm->_scene->clearPsychicProfile(); } break; case kPanelPlacard: if (_vm->getGameType() == GType_IHNM) { // Any keypress here returns the user back to the game - _vm->_scene->clearPsychicProfile(); + if (_vm->getGameId() != GID_IHNM_DEMO) { + _vm->_scene->clearPsychicProfile(); + } else { + setMode(kPanelConverse); + _vm->_scene->_textList.clear(); + _vm->_script->wakeUpThreads(kWaitTypeDelay); + } } break; } @@ -1770,8 +1774,15 @@ void Interface::update(const Point& mousePoint, int updateFlag) { case kPanelPlacard: if (_vm->getGameType() == GType_IHNM) { // Any mouse click here returns the user back to the game - if (updateFlag & UPDATE_MOUSECLICK) - _vm->_scene->clearPsychicProfile(); + if (updateFlag & UPDATE_MOUSECLICK) { + if (_vm->getGameId() != GID_IHNM_DEMO) { + _vm->_scene->clearPsychicProfile(); + } else { + setMode(kPanelConverse); + _vm->_scene->_textList.clear(); + _vm->_script->wakeUpThreads(kWaitTypeDelay); + } + } } break; diff --git a/engines/saga/scene.cpp b/engines/saga/scene.cpp index 3ae0e9c950..c49fe546ee 100644 --- a/engines/saga/scene.cpp +++ b/engines/saga/scene.cpp @@ -1411,6 +1411,8 @@ void Scene::showPsychicProfile(const char *text) { q_event = _vm->_events->chain(q_event, &event); + _vm->_scene->_textList.clear(); + if (text != NULL) { textHeight = _vm->_font->getHeight(kKnownFontVerb, text, 226, kFontCentered); @@ -1424,7 +1426,6 @@ void Scene::showPsychicProfile(const char *text) { textEntry.flags = (FontEffectFlags)(kFontCentered); textEntry.text = text; - _vm->_scene->_textList.clear(); TextListEntry *_psychicProfileTextEntry = _vm->_scene->_textList.addEntry(textEntry); event.type = kEvTOneshot; @@ -1455,8 +1456,9 @@ void Scene::showPsychicProfile(const char *text) { } void Scene::clearPsychicProfile() { - if (_vm->_interface->getMode() == kPanelPlacard) { + if (_vm->_interface->getMode() == kPanelPlacard || _vm->getGameId() == GID_IHNM_DEMO) { _vm->_scene->clearPlacard(); + _vm->_scene->_textList.clear(); _vm->_actor->showActors(false); _vm->_gfx->restorePalette(); _vm->_scene->restoreScene(); diff --git a/engines/saga/script.h b/engines/saga/script.h index 1c05182647..5e5e702132 100644 --- a/engines/saga/script.h +++ b/engines/saga/script.h @@ -592,9 +592,9 @@ private: void sfScriptStartVideo(SCRIPTFUNC_PARAMS); void sfScriptReturnFromVideo(SCRIPTFUNC_PARAMS); void sfScriptEndVideo(SCRIPTFUNC_PARAMS); - void sfShowIHNMDemoHelp(SCRIPTFUNC_PARAMS); - void sfShowIHNMDemoHelpText(SCRIPTFUNC_PARAMS); - void sfClearIHNMDemoHelpText(SCRIPTFUNC_PARAMS); + void sfShowIHNMDemoHelpBg(SCRIPTFUNC_PARAMS); + void sfAddIHNMDemoHelpTextLine(SCRIPTFUNC_PARAMS); + void sfShowIHNMDemoHelpPage(SCRIPTFUNC_PARAMS); void sfGetPoints(SCRIPTFUNC_PARAMS); void sfSetGlobalFlag(SCRIPTFUNC_PARAMS); void sf92(SCRIPTFUNC_PARAMS); diff --git a/engines/saga/sfuncs.cpp b/engines/saga/sfuncs.cpp index 0efbef0ca2..16a484a056 100644 --- a/engines/saga/sfuncs.cpp +++ b/engines/saga/sfuncs.cpp @@ -225,9 +225,9 @@ static const ScriptFunctionDescription IHNMscriptFunctionsList[IHNM_SCRIPT_FUNCT OPCODE(sfScriptReturnFromVideo), OPCODE(sfScriptEndVideo), OPCODE(sfSetActorZ), - OPCODE(sfShowIHNMDemoHelp), - OPCODE(sfShowIHNMDemoHelpText), - OPCODE(sfClearIHNMDemoHelpText), + OPCODE(sfShowIHNMDemoHelpBg), + OPCODE(sfAddIHNMDemoHelpTextLine), + OPCODE(sfShowIHNMDemoHelpPage), OPCODE(sfVstopFX), OPCODE(sfVstopLoopedFX), OPCODE(sf92), // only used in the demo version of IHNM @@ -1998,14 +1998,12 @@ void Script::sfScriptEndVideo(SCRIPTFUNC_PARAMS) { _vm->_anim->endVideo(); } -void Script::sfShowIHNMDemoHelp(SCRIPTFUNC_PARAMS) { - thread->wait(kWaitTypePlacard); - +void Script::sfShowIHNMDemoHelpBg(SCRIPTFUNC_PARAMS) { _ihnmDemoCurrentY = 0; _vm->_scene->showPsychicProfile(NULL); } -void Script::sfShowIHNMDemoHelpText(SCRIPTFUNC_PARAMS) { +void Script::sfAddIHNMDemoHelpTextLine(SCRIPTFUNC_PARAMS) { int stringId, textHeight; TextListEntry textEntry; Event event; @@ -2039,17 +2037,11 @@ void Script::sfShowIHNMDemoHelpText(SCRIPTFUNC_PARAMS) { _ihnmDemoCurrentY += 10; } -void Script::sfClearIHNMDemoHelpText(SCRIPTFUNC_PARAMS) { - thread->wait(kWaitTypePlacard); - - warning("TODO: sfClearIHNMDemoHelpText"); - - // This is called a while after the psychic profile is - // opened in the IHNM demo, to flip through the help system pages - _vm->_scene->clearPlacard(); - // FIXME: The demo uses mode 8 when changing pages - //_vm->_interface->setMode(8); - _vm->_interface->setMode(7); +void Script::sfShowIHNMDemoHelpPage(SCRIPTFUNC_PARAMS) { + // Note: The IHNM demo changes panel mode to 8 (kPanelProtect in ITE) + // when changing pages + _vm->_interface->setMode(kPanelConverse); + _vm->_interface->setMode(kPanelPlacard); _ihnmDemoCurrentY = 0; } -- cgit v1.2.3 From ccc9359181a30813321911501c9721bf8556f592 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 2 Aug 2007 14:57:18 +0000 Subject: Text is cleared correctly in the IHNM demo help screen, when waiting for the game to change the page automatically svn-id: r28407 --- engines/saga/sfuncs.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/saga/sfuncs.cpp b/engines/saga/sfuncs.cpp index 16a484a056..c0e44584df 100644 --- a/engines/saga/sfuncs.cpp +++ b/engines/saga/sfuncs.cpp @@ -2000,6 +2000,8 @@ void Script::sfScriptEndVideo(SCRIPTFUNC_PARAMS) { void Script::sfShowIHNMDemoHelpBg(SCRIPTFUNC_PARAMS) { _ihnmDemoCurrentY = 0; + _vm->_scene->_textList.clear(); + _vm->_interface->setMode(kPanelConverse); _vm->_scene->showPsychicProfile(NULL); } @@ -2022,9 +2024,6 @@ void Script::sfAddIHNMDemoHelpTextLine(SCRIPTFUNC_PARAMS) { textEntry.flags = (FontEffectFlags)(kFontCentered); textEntry.text = thread->_strings->getString(stringId); - if (_ihnmDemoCurrentY == 0) - _vm->_scene->_textList.clear(); - TextListEntry *_psychicProfileTextEntry = _vm->_scene->_textList.addEntry(textEntry); event.type = kEvTOneshot; @@ -2040,7 +2039,6 @@ void Script::sfAddIHNMDemoHelpTextLine(SCRIPTFUNC_PARAMS) { void Script::sfShowIHNMDemoHelpPage(SCRIPTFUNC_PARAMS) { // Note: The IHNM demo changes panel mode to 8 (kPanelProtect in ITE) // when changing pages - _vm->_interface->setMode(kPanelConverse); _vm->_interface->setMode(kPanelPlacard); _ihnmDemoCurrentY = 0; } -- cgit v1.2.3 From 4289509e209d3c21e55aafdd99a48c65d679852a Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Thu, 2 Aug 2007 15:08:49 +0000 Subject: Fixed warnings. (A key code does not fit in a byte.) svn-id: r28408 --- engines/drascula/drascula.cpp | 6 +++--- engines/drascula/drascula.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp index 44f377d0f1..a1e184826c 100644 --- a/engines/drascula/drascula.cpp +++ b/engines/drascula/drascula.cpp @@ -514,7 +514,7 @@ bucles: else menu_bar = 0; - byte key = getscan(); + Common::KeyCode key = getscan(); if (key == Common::KEYCODE_F1 && menu_scr == 0) { elige_verbo(1); cont_sv = 0; @@ -1533,7 +1533,7 @@ void DrasculaEngine::comprueba2() { } } -byte DrasculaEngine::getscan() { +Common::KeyCode DrasculaEngine::getscan() { update_events(); return _keyPressed.keycode; @@ -3560,7 +3560,7 @@ void DrasculaEngine::cursor_mesa() { } void DrasculaEngine::introduce_nombre() { - byte key; + Common::KeyCode key; int v = 0, h = 0; char select2[23]; strcpy(select2, " "); diff --git a/engines/drascula/drascula.h b/engines/drascula/drascula.h index 91ace757c4..a5947d73e7 100644 --- a/engines/drascula/drascula.h +++ b/engines/drascula/drascula.h @@ -487,7 +487,7 @@ public: void elige_en_barra(); bool comprueba1(); void comprueba2(); - byte getscan(); + Common::KeyCode getscan(); void elige_verbo(int); void mesa(); void saves(); -- cgit v1.2.3 From 1c262740613075cbfd525877d8f3011e4431e063 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 2 Aug 2007 15:29:50 +0000 Subject: Undefined character 9 is no longer printed in the IHNM demo help screen svn-id: r28409 --- engines/saga/font.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/saga/font.cpp b/engines/saga/font.cpp index c38c9e2110..71cd6b0eef 100644 --- a/engines/saga/font.cpp +++ b/engines/saga/font.cpp @@ -332,7 +332,7 @@ void Font::outFont(const FontStyle &drawFont, Surface *ds, const char *text, siz // Check if character is defined if ((drawFont.fontCharEntry[c_code].index == 0) && (c_code != FONT_FIRSTCHAR)) { #if FONT_SHOWUNDEFINED - if (c_code == FONT_CH_SPACE) { + if (c_code == FONT_CH_SPACE || c_code == 9) { textPoint.x += drawFont.fontCharEntry[c_code].tracking; continue; } -- cgit v1.2.3 From b9092cc18d717cf62d1a09364916bbca3b671296 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Thu, 2 Aug 2007 16:19:47 +0000 Subject: Strip path from save file name svn-id: r28410 --- engines/gob/saveload_v2.cpp | 4 ++++ engines/gob/saveload_v3.cpp | 4 ++++ 2 files changed, 8 insertions(+) (limited to 'engines') diff --git a/engines/gob/saveload_v2.cpp b/engines/gob/saveload_v2.cpp index 35c3429ab6..13f23cccb6 100644 --- a/engines/gob/saveload_v2.cpp +++ b/engines/gob/saveload_v2.cpp @@ -47,6 +47,10 @@ SaveLoad_v2::SaveLoad_v2(GobEngine *vm, const char *targetName) : } SaveType SaveLoad_v2::getSaveType(const char *fileName) { + const char *backSlash; + if ((backSlash = strrchr(fileName, '\\'))) + fileName = backSlash + 1; + if (!scumm_stricmp(fileName, "cat.inf")) return kSaveGame; if (!scumm_stricmp(fileName, "cat.cat")) diff --git a/engines/gob/saveload_v3.cpp b/engines/gob/saveload_v3.cpp index b376a8a75c..2f143d683a 100644 --- a/engines/gob/saveload_v3.cpp +++ b/engines/gob/saveload_v3.cpp @@ -58,6 +58,10 @@ SaveLoad_v3::SaveLoad_v3(GobEngine *vm, const char *targetName) : } SaveType SaveLoad_v3::getSaveType(const char *fileName) { + const char *backSlash; + if ((backSlash = strrchr(fileName, '\\'))) + fileName = backSlash + 1; + if (!scumm_stricmp(fileName, "cat.inf")) return kSaveGame; if (!scumm_stricmp(fileName, "ima.inf")) -- cgit v1.2.3 From 8d09c1a3ade02211565a4c74ddaa72a15138f574 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Thu, 2 Aug 2007 16:21:49 +0000 Subject: Don't crash at getRandom(0) svn-id: r28411 --- engines/gob/util.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'engines') diff --git a/engines/gob/util.cpp b/engines/gob/util.cpp index ec8bb59f06..40acf21f9e 100644 --- a/engines/gob/util.cpp +++ b/engines/gob/util.cpp @@ -49,6 +49,9 @@ uint32 Util::getTimeKey(void) { } int16 Util::getRandom(int16 max) { + if (max == 0) + return 0; + return _vm->_rnd.getRandomNumber(max - 1); } -- cgit v1.2.3 From 0ea88e439faded4029587143e48c475d3581838c Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Thu, 2 Aug 2007 16:24:04 +0000 Subject: Don't restart the audiostream when the IMD refills all sound buffers at once svn-id: r28412 --- engines/gob/coktelvideo.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/gob/coktelvideo.cpp b/engines/gob/coktelvideo.cpp index 964abc8369..16df54d85f 100644 --- a/engines/gob/coktelvideo.cpp +++ b/engines/gob/coktelvideo.cpp @@ -257,6 +257,7 @@ void Imd::disableSound() { delete _audioStream; _audioStream = 0; + _soundStage = 0; } _soundEnabled = false; _mixer = 0; @@ -526,8 +527,9 @@ CoktelVideo::State Imd::processFrame(uint16 frame) { _stream->read(soundBuf, dataLength); unsignedToSigned(soundBuf, dataLength); - _soundStage = 1; - startSound = true; + if (_soundStage == 1) + startSound = true; + _audioStream->queueBuffer(soundBuf, dataLength); } else _stream->seek(dataLength, SEEK_CUR); -- cgit v1.2.3 From c1d7fa04331f4a2aed056845419d3c2f0421b927 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Thu, 2 Aug 2007 16:55:57 +0000 Subject: Added the MD5 of Inca II. It works a bit but hangs when a space shooter sequence should start svn-id: r28413 --- engines/gob/detection.cpp | 72 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 69 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/gob/detection.cpp b/engines/gob/detection.cpp index 83b66a4177..6e200f5f4c 100644 --- a/engines/gob/detection.cpp +++ b/engines/gob/detection.cpp @@ -49,11 +49,12 @@ static const PlainGameDescriptor gobGames[] = { {"gob1cd", "Gobliiins CD"}, {"gob2", "Gobliins 2"}, {"gob2cd", "Gobliins 2 CD"}, - {"gob3", "Goblins Quest 3"}, - {"gob3cd", "Goblins Quest 3 CD"}, - {"ajworld", "A.J's World of Discovery"}, {"bargon", "Bargon Attack"}, {"ween", "Ween: The Prophecy"}, + {"ajworld", "A.J's World of Discovery"}, + {"gob3", "Goblins Quest 3"}, + {"gob3cd", "Goblins Quest 3 CD"}, + {"inca2", "Inca II: Wiracocha"}, {"woodruff", "The Bizarre Adventures of Woodruff and the Schnibble"}, // {"dynasty", "The Last Dynasty"}, {0, 0} @@ -1124,6 +1125,71 @@ static const GOBGameDescription gameDescriptions[] = { kFeaturesAdlib, "intro" }, + { + { + "inca2", + "", + AD_ENTRY1s("intro.stk", "47c3b452767c4f49ea7b109143e77c30", 916828), + EN_USA, + kPlatformPC, + Common::ADGF_NO_FLAGS + }, + kGameTypeGob3, + kFeaturesCD, + "intro" + }, + { + { + "inca2", + "", + AD_ENTRY1s("intro.stk", "47c3b452767c4f49ea7b109143e77c30", 916828), + DE_DEU, + kPlatformPC, + Common::ADGF_NO_FLAGS + }, + kGameTypeGob3, + kFeaturesCD, + "intro" + }, + { + { + "inca2", + "", + AD_ENTRY1s("intro.stk", "47c3b452767c4f49ea7b109143e77c30", 916828), + FR_FRA, + kPlatformPC, + Common::ADGF_NO_FLAGS + }, + kGameTypeGob3, + kFeaturesCD, + "intro" + }, + { + { + "inca2", + "", + AD_ENTRY1s("intro.stk", "47c3b452767c4f49ea7b109143e77c30", 916828), + IT_ITA, + kPlatformPC, + Common::ADGF_NO_FLAGS + }, + kGameTypeGob3, + kFeaturesCD, + "intro" + }, + { + { + "inca2", + "", + AD_ENTRY1s("intro.stk", "47c3b452767c4f49ea7b109143e77c30", 916828), + ES_ESP, + kPlatformPC, + Common::ADGF_NO_FLAGS + }, + kGameTypeGob3, + kFeaturesCD, + "intro" + }, { { "woodruff", -- cgit v1.2.3 From a865457d731e0444bcabba829ff098f662d45a13 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Thu, 2 Aug 2007 19:07:47 +0000 Subject: Added Lost in Time. The title screen doesn't show and the wobble-effect isn't there, but the game is (partly?) playable. svn-id: r28414 --- engines/gob/detection.cpp | 16 +++++++++++++++- engines/gob/inter_v2.cpp | 2 +- engines/gob/inter_v3.cpp | 2 +- 3 files changed, 17 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/gob/detection.cpp b/engines/gob/detection.cpp index 6e200f5f4c..5522a900b0 100644 --- a/engines/gob/detection.cpp +++ b/engines/gob/detection.cpp @@ -49,9 +49,10 @@ static const PlainGameDescriptor gobGames[] = { {"gob1cd", "Gobliiins CD"}, {"gob2", "Gobliins 2"}, {"gob2cd", "Gobliins 2 CD"}, - {"bargon", "Bargon Attack"}, {"ween", "Ween: The Prophecy"}, + {"bargon", "Bargon Attack"}, {"ajworld", "A.J's World of Discovery"}, + {"lost", "Lost in Time"}, {"gob3", "Goblins Quest 3"}, {"gob3cd", "Goblins Quest 3 CD"}, {"inca2", "Inca II: Wiracocha"}, @@ -861,6 +862,19 @@ static const GOBGameDescription gameDescriptions[] = { kFeaturesAdlib, "intro" }, + { + { + "lost", + "", + AD_ENTRY1s("intro.stk", "7b7f48490dedc8a7cb999388e2fadbe3", 3930674), + EN_USA, + kPlatformPC, + Common::ADGF_NO_FLAGS + }, + kGameTypeGob3, + kFeaturesAdlib, + "intro" + }, { { "gob3", diff --git a/engines/gob/inter_v2.cpp b/engines/gob/inter_v2.cpp index 23abc38f6c..8cb8b706bd 100644 --- a/engines/gob/inter_v2.cpp +++ b/engines/gob/inter_v2.cpp @@ -1378,7 +1378,7 @@ void Inter_v2::o2_initScreen() { _vm->_global->_fakeVideoMode = videoMode; // Some versions require this - if (videoMode == 0xD) + if ((videoMode == 0xD) || (videoMode == 0x10)) videoMode = _vm->_mode; if ((videoMode == _vm->_global->_videoMode) && (width == -1)) diff --git a/engines/gob/inter_v3.cpp b/engines/gob/inter_v3.cpp index 18601b9ed7..701842a9d2 100644 --- a/engines/gob/inter_v3.cpp +++ b/engines/gob/inter_v3.cpp @@ -594,7 +594,7 @@ void Inter_v3::setupOpcodes() { {NULL, ""}, {NULL, ""}, {NULL, ""}, - OPCODE(o2_handleGoblins), + {NULL, ""}, /* 28 */ {NULL, ""}, {NULL, ""}, -- cgit v1.2.3 From 93f9cf5fd3c0436bf28b67b5dc05abb87146efd3 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Thu, 2 Aug 2007 19:16:32 +0000 Subject: Renamed "lost" to "lostintime". svn-id: r28415 --- engines/gob/detection.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/gob/detection.cpp b/engines/gob/detection.cpp index 5522a900b0..3a9eae8891 100644 --- a/engines/gob/detection.cpp +++ b/engines/gob/detection.cpp @@ -52,7 +52,7 @@ static const PlainGameDescriptor gobGames[] = { {"ween", "Ween: The Prophecy"}, {"bargon", "Bargon Attack"}, {"ajworld", "A.J's World of Discovery"}, - {"lost", "Lost in Time"}, + {"lostintime", "Lost in Time"}, {"gob3", "Goblins Quest 3"}, {"gob3cd", "Goblins Quest 3 CD"}, {"inca2", "Inca II: Wiracocha"}, @@ -864,7 +864,7 @@ static const GOBGameDescription gameDescriptions[] = { }, { { - "lost", + "lostintime", "", AD_ENTRY1s("intro.stk", "7b7f48490dedc8a7cb999388e2fadbe3", 3930674), EN_USA, -- cgit v1.2.3 From da8dbb271dd77d6bb38af3b2d12905a6d64e8cd1 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Thu, 2 Aug 2007 20:48:09 +0000 Subject: Added entries for the CD version of Lost in Time. (I'm told this is how we handle multi-lingual games.) svn-id: r28416 --- engines/gob/detection.cpp | 78 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) (limited to 'engines') diff --git a/engines/gob/detection.cpp b/engines/gob/detection.cpp index 3a9eae8891..b9d784c63d 100644 --- a/engines/gob/detection.cpp +++ b/engines/gob/detection.cpp @@ -875,6 +875,84 @@ static const GOBGameDescription gameDescriptions[] = { kFeaturesAdlib, "intro" }, + { + { + "lostintime", + "", + AD_ENTRY1s("intro.stk", "6263d09e996c1b4e84ef2d650b820e57", 4831170), + EN_USA, + kPlatformPC, + Common::ADGF_NO_FLAGS + }, + kGameTypeGob3, + kFeaturesCD, + "intro" + }, + { + { + "lostintime", + "", + AD_ENTRY1s("intro.stk", "6263d09e996c1b4e84ef2d650b820e57", 4831170), + FR_FRA, + kPlatformPC, + Common::ADGF_NO_FLAGS + }, + kGameTypeGob3, + kFeaturesCD, + "intro" + }, + { + { + "lostintime", + "", + AD_ENTRY1s("intro.stk", "6263d09e996c1b4e84ef2d650b820e57", 4831170), + IT_ITA, + kPlatformPC, + Common::ADGF_NO_FLAGS + }, + kGameTypeGob3, + kFeaturesCD, + "intro" + }, + { + { + "lostintime", + "", + AD_ENTRY1s("intro.stk", "6263d09e996c1b4e84ef2d650b820e57", 4831170), + DE_DEU, + kPlatformPC, + Common::ADGF_NO_FLAGS + }, + kGameTypeGob3, + kFeaturesCD, + "intro" + }, + { + { + "lostintime", + "", + AD_ENTRY1s("intro.stk", "6263d09e996c1b4e84ef2d650b820e57", 4831170), + ES_ESP, + kPlatformPC, + Common::ADGF_NO_FLAGS + }, + kGameTypeGob3, + kFeaturesCD, + "intro" + }, + { + { + "lostintime", + "", + AD_ENTRY1s("intro.stk", "6263d09e996c1b4e84ef2d650b820e57", 4831170), + EN_GRB, + kPlatformPC, + Common::ADGF_NO_FLAGS + }, + kGameTypeGob3, + kFeaturesCD, + "intro" + }, { { "gob3", -- cgit v1.2.3 From 59089f95dd2e21065a424405b486e7138cf6b1c6 Mon Sep 17 00:00:00 2001 From: Paweł Kołodziejski Date: Thu, 2 Aug 2007 20:59:03 +0000 Subject: added next part of engine svn-id: r28417 --- engines/drascula/drascula.cpp | 2284 ++++++++++++++++++++++++++++++++++++++--- engines/drascula/drascula.h | 111 +- 2 files changed, 2217 insertions(+), 178 deletions(-) (limited to 'engines') diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp index a1e184826c..3cae993bab 100644 --- a/engines/drascula/drascula.cpp +++ b/engines/drascula/drascula.cpp @@ -111,10 +111,14 @@ static int x1d_menu[] = {280, 40, 80, 120, 160, 200, 240, 0, 40, 80, 120, 40, 80, 120, 160, 200, 240, 0}; static int y1d_menu[] = {0, 0, 0, 0, 0, 0, 0, 25, 25, 25, 25, 25, 25, 25, 50, 50, 50, 50, 50, 50, 50, 75, 75, 75, 75, 75, 75, 75, 100}; -static int frame_x[6] = {43, 87, 130, 173, 216, 259}; +static int frame_x[20] = {43, 87, 130, 173, 216, 259}; static int interf_x[] ={ 1, 65, 129, 193, 1, 65, 129 }; static int interf_y[] ={ 51, 51, 51, 51, 83, 83, 83 }; - +static char mirar_t[3][88] = {TEXT100, TEXT101, TEXT54}; +static char mirar_v[3][14] = {"100.als", "101.als", "54.als"}; +static char poder_t[6][88] = {TEXT11, TEXT109, TEXT111, TEXT110, TEXT115, TEXT116}; +static char poder_v[6][14] = {"11.als", "109.als", "111.als", "110.als", "115.als", "116.als"}; + int DrasculaEngine::init() { // Detect game if (!initGame()) { @@ -133,7 +137,7 @@ int DrasculaEngine::init() { int DrasculaEngine::go() { - _gameMode = 1; + num_ejec = 1; for (;;) { VGA = (byte *)malloc(320 * 200); @@ -159,13 +163,17 @@ int DrasculaEngine::go() { frame_velas = 0; cont_sv = 0; term_int = 0; - num_ejec = 1; cual_ejec = 0; hay_que_load = 0; corta_musica = 0; hay_seleccion = 0; Leng = 0; UsingMem = 0; GlobalSpeed = 0; + frame_ciego = 0; + frame_ronquido = 0; + frame_murcielago = 0; + c_mirar = 0; + c_poder = 0; asigna_memoria(); carga_info(); @@ -175,11 +183,15 @@ int DrasculaEngine::go() { lee_dibujos("96.alg"); descomprime_dibujo(dir_hare_frente, COMPLETA); - lee_dibujos("99.alg"); - descomprime_dibujo(dir_hare_fondo, 1); - lee_dibujos("97.alg"); - descomprime_dibujo(dir_hare_dch, 1); - + if (num_ejec == 1) { + lee_dibujos("99.alg"); + descomprime_dibujo(dir_hare_fondo, 1); + lee_dibujos("97.alg"); + descomprime_dibujo(dir_hare_dch, 1); + } else if (num_ejec == 2) { + lee_dibujos("pts.alg"); + descomprime_dibujo(dir_dibujo2, 1); + } strcpy(nombre_icono[1], "look"); strcpy(nombre_icono[2], "take"); strcpy(nombre_icono[3], "open"); @@ -294,6 +306,16 @@ void DrasculaEngine::paleta_hare() { } +void DrasculaEngine::hare_oscuro() { + int color, componente; + + for (color = 235; color < 253; color++ ) + for (componente = 0; componente < 3; componente++) + palJuego[color][componente] = palHareOscuro[color][componente]; + + ActualizaPaleta(); +} + void DrasculaEngine::asigna_rgb(byte *dir_lectura, int plt) { int x, cnt = 0; @@ -433,28 +455,44 @@ bool DrasculaEngine::escoba() { for (n = 0; n < NUM_BANDERAS; n++) flags[n] = 0; + if (num_ejec == 2) { + flags[16] = 1; + flags[17] = 1; + flags[27] = 1; + } + for (n = 1; n < 7; n++) objetos_que_tengo[n] = n; - agarra_objeto(28); - - buffer_teclado(); + if (num_ejec == 1) { + agarra_objeto(28); + buffer_teclado(); - if (hay_que_load == 0) - animacion_1(); + if (hay_que_load == 0) + animacion_1_1(); - sin_verbo(); - lee_dibujos("2aux62.alg"); - descomprime_dibujo(dir_dibujo2, 1); - sentido_hare = 1; - obj_saliendo = 104; - if (hay_que_load != 0) - para_cargar(nom_partida); - else { - carga_escoba("62.ald"); - hare_x = -20; - hare_y = 56; - lleva_al_hare(65, 145); + sin_verbo(); + lee_dibujos("2aux62.alg"); + descomprime_dibujo(dir_dibujo2, 1); + sentido_hare = 1; + obj_saliendo = 104; + if (hay_que_load != 0) + para_cargar(nom_partida); + else { + carga_escoba_1("62.ald"); + hare_x = -20; + hare_y = 56; + lleva_al_hare(65, 145); + } + } else if (num_ejec == 2) { + suma_objeto(28); + buffer_teclado(); + sentido_hare = 3; + obj_saliendo = 162; + if (hay_que_load == 0) + carga_escoba_2("14.ald"); + else + para_cargar(nom_partida); } bucles: @@ -467,9 +505,18 @@ bucles: anda_a_objeto = 0; } + if (num_ejec == 2) { + if ((!strcmp(num_room, "3.alg")) && (hare_x == 279) && (hare_y + alto_hare == 101)) + animacion_1_2(); + else if ((!strcmp(num_room, "14.alg")) && (hare_x == 214) && (hare_y + alto_hare == 121)) + lleva_al_hare(190, 130); + else if ((!strcmp(num_room, "14.alg")) && (hare_x == 246) && (hare_y + alto_hare == 112)) + lleva_al_hare(190, 130); + } + mueve_cursor(); VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); - if (music_status() == 0) + if (music_status() == 0 && musica_room != 0) playmusic(musica_room); MirarRaton(); @@ -478,7 +525,10 @@ bucles: comprueba_objetos(); if (boton_dch == 1 && menu_scr == 1) { - lee_dibujos("99.alg"); + if (num_ejec == 1) + lee_dibujos("99.alg"); + else if (num_ejec == 2) + lee_dibujos(fondo_y_menu); descomprime_dibujo(dir_hare_fondo, 1); setvgapalette256((byte *)&palJuego); menu_scr = 0; @@ -601,7 +651,7 @@ int DrasculaEngine::resta_objeto(int osj) { return 1; } -void DrasculaEngine::animacion_1() { +void DrasculaEngine::animacion_1_1() { int l, l2, p; int pos_pixel[6]; @@ -958,7 +1008,7 @@ void DrasculaEngine::animacion_1() { descomprime_dibujo(dir_hare_fondo, 1); } -bool DrasculaEngine::animacion_2() { +bool DrasculaEngine::animacion_2_1() { int l; lleva_al_hare(231, 91); @@ -1163,7 +1213,7 @@ bool DrasculaEngine::animacion_2() { break; } - _gameMode = 2; + num_ejec = 2; return true; } @@ -1182,8 +1232,15 @@ void DrasculaEngine::sin_verbo() { void DrasculaEngine::para_cargar(char nom_game[]) { musica_antes = musica_room; menu_scr = 0; + if (num_ejec == 2) + borra_pantalla(); carga_partida(nom_game); - carga_escoba(datos_actuales); + if (num_ejec == 1) { + carga_escoba_1(datos_actuales); + } else if (num_ejec == 2) { + ald->close(); + carga_escoba_2(datos_actuales); + } sin_verbo(); } @@ -1212,7 +1269,7 @@ static char *getLine(Common::File *fp, char *buf, int len) { return buf; } -void DrasculaEngine::carga_escoba(const char *nom_fich) { +void DrasculaEngine::carga_escoba_1(const char *nom_fich) { int l, obj_salir; float chiquez, pequegnez = 0; char para_codificar[13]; @@ -1247,7 +1304,7 @@ void DrasculaEngine::carga_escoba(const char *nom_fich) { getLine(ald, buffer, size); sscanf(buffer, "%d", &objs_room); - for (l = 0; l < objs_room;l++) { + for (l = 0; l < objs_room; l++) { getLine(ald, buffer, size); sscanf(buffer, "%d", &num_obj[l]); getLine(ald, buffer, size); @@ -1358,6 +1415,203 @@ void DrasculaEngine::carga_escoba(const char *nom_fich) { refresca_pantalla(); } +void DrasculaEngine::carga_escoba_2(const char *nom_fich) { + int soc, l, martin, obj_salir; + char pant1[20], pant2[20], pant3[20], pant4[20]; + char para_codificar[20]; + char buffer[256]; + + hay_nombre = 0; + + strcpy(para_codificar, nom_fich); + canal_p(para_codificar); + strcpy(datos_actuales, nom_fich); + + buffer_teclado(); + + ald = new Common::File; + ald->open(nom_fich); + if (!ald->isOpen()) { + error("missing data file"); + } + int size = ald->size(); + + getLine(ald, buffer, size); + sscanf(buffer, "%s", num_room); + strcat(num_room, ".alg"); + + getLine(ald, buffer, size); + sscanf(buffer, "%d", &musica_room); + getLine(ald, buffer, size); + sscanf(buffer, "%s", pantalla_disco); + getLine(ald, buffer, size); + sscanf(buffer, "%d", &nivel_osc); + + getLine(ald, buffer, size); + sscanf(buffer, "%d", &martin); + if (martin == 0) + goto martini; + ancho_hare = martin; + getLine(ald, buffer, size); + sscanf(buffer, "%d",&alto_hare); + getLine(ald, buffer, size); + sscanf(buffer, "%d",&alto_pies); + getLine(ald, buffer, size); + sscanf(buffer, "%d",&paso_x); + getLine(ald, buffer, size); + sscanf(buffer, "%d",&paso_y); + + getLine(ald, buffer, size); + sscanf(buffer, "%s",pant1); + getLine(ald, buffer, size); + sscanf(buffer, "%s",pant2); + getLine(ald, buffer, size); + sscanf(buffer, "%s",pant3); + getLine(ald, buffer, size); + sscanf(buffer, "%s",pant4); + + lee_dibujos(pant2); + descomprime_dibujo(dir_hare_dch, 1); + lee_dibujos(pant1); + descomprime_dibujo(dir_hare_frente, 1); + lee_dibujos(pant4); + descomprime_dibujo(dir_hare_fondo, 1); + + strcpy(fondo_y_menu, pant4); + +martini: + + getLine(ald, buffer, size); + sscanf(buffer, "%d", &objs_room); + + for (l = 0; l < objs_room; l++) { + getLine(ald, buffer, size); + sscanf(buffer, "%d", &num_obj[l]); + getLine(ald, buffer, size); + sscanf(buffer, "%s", nombre_obj[l]); + getLine(ald, buffer, size); + sscanf(buffer, "%d", &x1[l]); + getLine(ald, buffer, size); + sscanf(buffer, "%d", &y1[l]); + getLine(ald, buffer, size); + sscanf(buffer, "%d", &x2[l]); + getLine(ald, buffer, size); + sscanf(buffer, "%d", &y2[l]); + getLine(ald, buffer, size); + sscanf(buffer, "%d", &sitiobj_x[l]); + getLine(ald, buffer, size); + sscanf(buffer, "%d", &sitiobj_y[l]); + getLine(ald, buffer, size); + sscanf(buffer, "%d", &sentidobj[l]); + getLine(ald, buffer, size); + sscanf(buffer, "%d", &visible[l]); + getLine(ald, buffer, size); + sscanf(buffer, "%d", &espuerta[l]); + if (espuerta[l] != 0) { + getLine(ald, buffer, size); + sscanf(buffer, "%s", alapantallakeva[l]); + getLine(ald, buffer, size); + sscanf(buffer, "%d", &x_alakeva[l]); + getLine(ald, buffer, size); + sscanf(buffer, "%d", &y_alakeva[l]); + getLine(ald, buffer, size); + sscanf(buffer, "%d", &sentido_alkeva[l]); + getLine(ald, buffer, size); + sscanf(buffer, "%d", &alapuertakeva[l]); + puertas_cerradas(l); + } + } + + getLine(ald, buffer, size); + sscanf(buffer, "%d", &suelo_x1); + getLine(ald, buffer, size); + sscanf(buffer, "%d", &suelo_y1); + getLine(ald, buffer, size); + sscanf(buffer, "%d", &suelo_x2); + getLine(ald, buffer, size); + sscanf(buffer, "%d", &suelo_y2); + + delete ald; + + canal_p(para_codificar); + + if (martin == 0) { + paso_x = PASO_HARE_X; + paso_y = PASO_HARE_Y; + alto_hare = ALTO_PERSONAJE; + ancho_hare = ANCHO_PERSONAJE; + alto_pies = PIES_HARE; + lee_dibujos("97.alg"); + descomprime_dibujo(dir_hare_dch, 1); + lee_dibujos("96.alg"); + descomprime_dibujo(dir_hare_frente, 1); + lee_dibujos("99.alg"); + descomprime_dibujo(dir_hare_fondo, 1); + + strcpy(fondo_y_menu,"99.alg"); + } + + for (l = 0; l < objs_room; l++) { + if (num_obj[l] == obj_saliendo) + obj_salir = l; + } + + if (hare_x == -1) { + hare_x = x_alakeva[obj_salir]; + hare_y = y_alakeva[obj_salir] - alto_hare; + } + hare_se_mueve = 0; + + lee_dibujos(pantalla_disco); + descomprime_dibujo(dir_dibujo3, 1); + + lee_dibujos(num_room); + descomprime_dibujo(dir_dibujo1, MEDIA); + + DIBUJA_FONDO(0, 171, 0, 0, ANCHOBJ, ALTOBJ, dir_hare_fondo, dir_dibujo3); + + color_hare(); + if (nivel_osc != 0) + funde_hare(nivel_osc); + paleta_hare_claro(); + color_hare(); + funde_hare(nivel_osc + 2); + paleta_hare_oscuro(); + + hare_claro(); + cambio_de_color = -1; + + color_abc(VERDE_CLARO); + + soc = 0; + for (l = 0; l < 6; l++) { + soc = soc + ancho_hare; + frame_x[l] = soc; + } + + actualiza_datos(); + + if (!strcmp(num_room, "14.alg") && flags[39] == 1) + musica_room = 16; + else if (!strcmp(num_room, "15.alg") && flags[39] == 1) + musica_room = 16; + if (!strcmp(num_room, "14.alg") && flags[5]==1) + musica_room = 0; + else if (!strcmp(num_room, "15.alg") && flags[5] == 1) + musica_room = 0; + + if (musica_antes != musica_room && musica_room != 0) + playmusic(musica_room); + if (musica_room == 0) + stopmusic(); + + if ((!strcmp(num_room, "9.alg")) || (strcmp(num_room, "2.alg")) + || (!strcmp(num_room, "14.alg")) || (!strcmp(num_room, "18.alg"))) + conta_ciego_vez = vez(); + + refresca_pantalla(); +} + void DrasculaEngine::borra_pantalla() { memset(VGA, 0, 64000); _system->copyRectToScreen((const byte *)VGA, 320, 0, 0, 320, 200); @@ -1427,12 +1681,20 @@ void DrasculaEngine::comprueba_objetos() { } } - if (x_raton > hare_x + 2 && y_raton > hare_y + 2 - && x_raton < hare_x + ancho_hare - 2 && y_raton < hare_y + alto_hare - 2 && veo == 0) { - strcpy(texto_nombre, "hacker"); - hay_nombre = 1; - veo = 1; - } + if (num_ejec == 1) + if (x_raton > hare_x + 2 && y_raton > hare_y + 2 + && x_raton < hare_x + ancho_hare - 2 && y_raton < hare_y + alto_hare - 2 && veo == 0) { + strcpy(texto_nombre, "hacker"); + hay_nombre = 1; + veo = 1; + } + else if (num_ejec == 2) + if (x_raton > hare_x + 2 && y_raton > hare_y + 2 + && x_raton < hare_x + ancho_hare - 2 && y_raton < hare_y + alto_hare - 2) { + strcpy(texto_nombre, "hacker"); + hay_nombre = 1; + veo = 1; + } if (veo == 0) hay_nombre = 0; @@ -3002,6 +3264,9 @@ void DrasculaEngine::hablar(const char *dicho, const char *filename) { if (factor_red[hare_y + alto_hare] == 100) suma_1_pixel = 0; + + if (num_ejec == 2) + buffer_teclado(); color_abc(AMARILLO); @@ -3023,29 +3288,47 @@ bucless: DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); actualiza_refresco_antes(); - DIBUJA_FONDO(hare_x, hare_y, ANCHOBJ+1, 0, + if (num_ejec == 1) + DIBUJA_FONDO(hare_x, hare_y, ANCHOBJ + 1, 0, ancho_hare * factor_red[hare_y + alto_hare] / 100, (alto_habla - 1) * factor_red[hare_y + alto_hare] / 100, dir_zona_pantalla, dir_dibujo3); + else if (num_ejec == 2) + DIBUJA_FONDO(hare_x, hare_y, ANCHOBJ + 1, 0, ancho_hare, alto_habla - 1, + dir_zona_pantalla, dir_dibujo3); pon_hare(); - DIBUJA_FONDO(ANCHOBJ + 1, 0, hare_x, hare_y, + if (num_ejec == 1) + DIBUJA_FONDO(ANCHOBJ + 1, 0, hare_x, hare_y, ancho_hare * factor_red[hare_y + alto_hare] / 100, (alto_habla - 1) * factor_red[hare_y + alto_hare] / 100, dir_dibujo3, dir_zona_pantalla); + else if (num_ejec == 2) + DIBUJA_FONDO(ANCHOBJ + 1, 0, hare_x, hare_y, + ancho_hare, alto_habla - 1, + dir_dibujo3, dir_zona_pantalla); if (sentido_hare == 0) { - reduce_hare_chico(x_habla_izq[cara], y_mask_habla, + if (num_ejec == 1) + reduce_hare_chico(x_habla_izq[cara], y_mask_habla, hare_x + 8 * factor_red[hare_y + alto_hare] / 100, hare_y, ancho_habla, alto_habla, factor_red[hare_y + alto_hare], dir_hare_dch, dir_zona_pantalla); - + else if (num_ejec == 2) + DIBUJA_BLOQUE(x_habla_dch[cara], y_mask_habla, + hare_x + 12, hare_y, ancho_habla, alto_habla, + dir_hare_dch, dir_zona_pantalla); actualiza_refresco(); } else if (sentido_hare == 1) { - reduce_hare_chico(x_habla_dch[cara], y_mask_habla, + if (num_ejec == 1) + reduce_hare_chico(x_habla_dch[cara], y_mask_habla, hare_x + 12 * factor_red[hare_y + alto_hare] / 100, hare_y, ancho_habla,alto_habla, factor_red[hare_y + alto_hare], dir_hare_dch, dir_zona_pantalla); + else if (num_ejec == 2) + DIBUJA_BLOQUE(x_habla_dch[cara], y_mask_habla, + hare_x + 8, hare_y, ancho_habla, alto_habla, + dir_hare_dch, dir_zona_pantalla); actualiza_refresco(); } else if (sentido_hare == 2) { reduce_hare_chico(x_habla_izq[cara], y_mask_habla, @@ -3069,8 +3352,9 @@ bucless: pausa(3); byte key = getscan(); - if (key == Common::KEYCODE_ESCAPE) - term_int = 1; + if (num_ejec == 1) + if (key == Common::KEYCODE_ESCAPE) + term_int = 1; if (key != 0) ctvd_stop(); buffer_teclado(); @@ -3088,8 +3372,9 @@ bucless: refresca_pantalla(); VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); - if (music_status() == 0 && flags[11] == 0 && corta_musica == 0) - playmusic(musica_room); + if (num_ejec == 1) + if (music_status() == 0 && flags[11] == 0 && corta_musica == 0) + playmusic(musica_room); } void DrasculaEngine::playmusic(int p) { @@ -3114,47 +3399,35 @@ void DrasculaEngine::refresca_pantalla() { void DrasculaEngine::carga_partida(const char *nom_game) { int l, n_ejec2; - char buffer[256]; + Common::InSaveFile *sav; canal_p(nom_game); - sku = new Common::File; - sku->open(nom_game); - if (!ald->isOpen()) { - error("missing data file"); + if (!(sav = _saveFileMan->openForLoading("nom_game"))) { + error("missing savegame file"); } - int size = sku->size(); - getLine(ald, buffer, size); - sscanf(buffer, "%d", &n_ejec2); + n_ejec2 = sav->readSint32LE(); if (n_ejec2 != num_ejec) { canal_p(nom_game); strcpy(nom_partida, nom_game); + error("TODO"); salir_al_dos(n_ejec2); } - getLine(ald, buffer, size); - sscanf(buffer, "%s", datos_actuales); - getLine(ald, buffer, size); - sscanf(buffer, "%d", &hare_x); - getLine(ald, buffer, size); - sscanf(buffer, "%d", &hare_y); - getLine(ald, buffer, size); - sscanf(buffer, "%d", &sentido_hare); + sav->read(datos_actuales, 20); + hare_x = sav->readSint32LE(); + hare_y = sav->readSint32LE(); + sentido_hare = sav->readSint32LE(); for (l = 1; l < 43; l++) { - getLine(ald, buffer, size); - sscanf(buffer, "%d", &objetos_que_tengo[l]); + objetos_que_tengo[l] = sav->readSint32LE(); } for (l = 0; l < NUM_BANDERAS; l++) { - getLine(ald, buffer, size); - sscanf(buffer, "%d", &flags[l]); + flags[l] = sav->readSint32LE(); } - getLine(ald, buffer, size); - sscanf(buffer, "%d", &lleva_objeto); - getLine(ald, buffer, size); - sscanf(buffer, "%d", &objeto_que_lleva); - delete ald; + lleva_objeto = sav->readSint32LE(); + objeto_que_lleva = sav->readSint32LE(); canal_p(nom_game); } @@ -3192,7 +3465,39 @@ void DrasculaEngine::canal_p(const char *fich){ rename(fich2, fich); } -void DrasculaEngine::puertas_cerradas (int l) {} +void DrasculaEngine::puertas_cerradas (int l) { + if (num_ejec == 1) + return; + + if (num_obj[l] == 138 && flags[0] == 0) + espuerta[l] = 0; + else if (num_obj[l] == 138 && flags[0] == 1) + espuerta[l] = 1; + else if (num_obj[l] == 136 && flags[8] == 0) + espuerta[l] = 0; + else if (num_obj[l] == 136 && flags[8] == 1) + espuerta[l] = 1; + else if (num_obj[l] == 156 && flags[16] == 0) + espuerta[l] = 0; + else if (num_obj[l] == 156 && flags[16] == 1) + espuerta[l] = 1; + else if (num_obj[l] == 163 && flags[17] == 0) + espuerta[l] = 0; + else if (num_obj[l] == 163 && flags[17] == 1) + espuerta[l] = 1; + else if (num_obj[l] == 177 && flags[15] == 0) + espuerta[l] = 0; + else if (num_obj[l] == 177 && flags[15] == 1) + espuerta[l] = 1; + else if (num_obj[l] == 175 && flags[40] == 0) + espuerta[l] = 0; + else if (num_obj[l] == 175 && flags[40] == 1) + espuerta[l] = 1; + else if (num_obj[l] == 173 && flags[36] == 0) + espuerta[l] = 0; + else if (num_obj[l] == 173 && flags[36] == 1) + espuerta[l] = 1; +} void DrasculaEngine::color_hare() { int color, componente; @@ -3254,17 +3559,31 @@ void DrasculaEngine::empieza_andar() { paso_x = PASO_HARE_X; paso_y = PASO_HARE_Y; - if ((sitio_x < hare_x + ancho_hare / 2 ) && (sitio_y <= (hare_y + alto_hare))) - cuadrante_1(); - else if ((sitio_x < hare_x + ancho_hare / 2) && (sitio_y > (hare_y + alto_hare))) - cuadrante_3(); - else if ((sitio_x > hare_x + ancho_hare / 2) && (sitio_y <= (hare_y + alto_hare))) - cuadrante_2(); - else if ((sitio_x > hare_x + ancho_hare / 2) && (sitio_y > (hare_y + alto_hare))) - cuadrante_4(); - else - hare_se_mueve=0; - + if (num_ejec == 1) { + if ((sitio_x < hare_x + ancho_hare / 2 ) && (sitio_y <= (hare_y + alto_hare))) + cuadrante_1(); + else if ((sitio_x < hare_x + ancho_hare / 2) && (sitio_y > (hare_y + alto_hare))) + cuadrante_3(); + else if ((sitio_x > hare_x + ancho_hare / 2) && (sitio_y <= (hare_y + alto_hare))) + cuadrante_2(); + else if ((sitio_x > hare_x + ancho_hare / 2) && (sitio_y > (hare_y + alto_hare))) + cuadrante_4(); + else + hare_se_mueve = 0; + } else if (num_ejec == 2) { + if ((sitio_x < hare_x) && (sitio_y <= (hare_y + alto_hare))) + cuadrante_1(); + else if ((sitio_x < hare_x) && (sitio_y > (hare_y + alto_hare))) + cuadrante_3(); + else if ((sitio_x > hare_x + ancho_hare) && (sitio_y <= (hare_y + alto_hare))) + cuadrante_2(); + else if ((sitio_x > hare_x + ancho_hare) && (sitio_y > (hare_y + alto_hare))) + cuadrante_4(); + else if (sitio_y < hare_y + alto_hare) + anda_parriba(); + else if (sitio_y > hare_y + alto_hare) + anda_pabajo(); + } conta_vez = vez(); } @@ -3273,13 +3592,53 @@ void DrasculaEngine::actualiza_refresco() { refresca_63(); else if (!strcmp(num_room, "62.alg")) refresca_62(); + else if (!strcmp(num_room, "3.alg")) + refresca_3(); + else if (!strcmp(num_room, "2.alg")) + refresca_2(); + else if (!strcmp(num_room, "4.alg")) + refresca_4(); + else if (!strcmp(num_room, "5.alg")) + refresca_5(); + else if (!strcmp(num_room, "15.alg")) + refresca_15(); + else if (!strcmp(num_room, "17.alg")) + refresca_17(); + else if (!strcmp(num_room, "18.alg")) + refresca_18(); + else if (!strcmp(num_room, "10.alg")) + mapa(); } void DrasculaEngine::actualiza_refresco_antes() { if (!strcmp(num_room, "62.alg")) refresca_62_antes(); + else if (!strcmp(num_room, "1.alg")) + refresca_1_antes(); + else if (!strcmp(num_room, "3.alg")) + refresca_3_antes(); + else if (!strcmp(num_room, "5.alg")) + refresca_5_antes(); + else if (!strcmp(num_room, "6.alg")) + refresca_6_antes(); + else if (!strcmp(num_room, "7.alg")) + refresca_7_antes(); + else if (!strcmp(num_room, "9.alg")) + refresca_9_antes(); + else if (!strcmp(num_room, "12.alg")) + refresca_12_antes(); + else if (!strcmp(num_room, "14.alg")) + refresca_14_antes(); else if (!strcmp(num_room, "16.alg")) - pon_bj(); + if (num_ejec == 1) + pon_bj(); + else if (num_ejec == 2) { + refresca_16_antes(); + } + else if (!strcmp(num_room,"17.alg")) + refresca_17_antes(); + else if (!strcmp(num_room,"18.alg")) + refresca_18_antes(); } void DrasculaEngine::pon_hare() { @@ -3288,17 +3647,32 @@ void DrasculaEngine::pon_hare() { if (hare_se_mueve == 1 && paso_x == PASO_HARE_X) { for (r = 0; r < paso_x; r++) { - if (sentido_hare == 0 && sitio_x - r == hare_x + ancho_hare / 2) { - hare_se_mueve = 0; - paso_x = PASO_HARE_X; - paso_y = PASO_HARE_Y; - } - if (sentido_hare == 1 && sitio_x + r == hare_x + ancho_hare / 2) { - hare_se_mueve = 0; - paso_x = PASO_HARE_X; - paso_y = PASO_HARE_Y; - hare_x = sitio_x - ancho_hare / 2; - hare_y = sitio_y - alto_hare; + if (num_ejec == 1) { + if (sentido_hare == 0 && sitio_x - r == hare_x + ancho_hare / 2) { + hare_se_mueve = 0; + paso_x = PASO_HARE_X; + paso_y = PASO_HARE_Y; + } + if (sentido_hare == 1 && sitio_x + r == hare_x + ancho_hare / 2) { + hare_se_mueve = 0; + paso_x = PASO_HARE_X; + paso_y = PASO_HARE_Y; + hare_x = sitio_x - ancho_hare / 2; + hare_y = sitio_y - alto_hare; + } + } else if (num_ejec == 2) { + if (sentido_hare == 0 && sitio_x - r == hare_x) { + hare_se_mueve = 0; + paso_x = PASO_HARE_X; + paso_y = PASO_HARE_Y; + } + if (sentido_hare == 1 && sitio_x + r == hare_x + ancho_hare) { + hare_se_mueve = 0; + paso_x = PASO_HARE_X; + paso_y = PASO_HARE_Y; + hare_x = sitio_x - ancho_hare + 4; + hare_y = sitio_y - alto_hare; + } } } } @@ -3317,74 +3691,109 @@ void DrasculaEngine::pon_hare() { } } - if (hare_se_ve == 0) - goto no_vuelco; + if (num_ejec == 1) + if (hare_se_ve == 0) + goto no_vuelco; if (hare_se_mueve == 0) { pos_hare[0] = 0; pos_hare[1] = DIF_MASK_HARE; pos_hare[2] = hare_x; pos_hare[3] = hare_y; - pos_hare[4] = ANCHO_PERSONAJE; - pos_hare[5] = ALTO_PERSONAJE; + if (num_ejec == 1) { + pos_hare[4] = ANCHO_PERSONAJE; + pos_hare[5] = ALTO_PERSONAJE; + } else if (num_ejec == 2) { + pos_hare[4] = ancho_hare; + pos_hare[5] = alto_hare; + } if (sentido_hare == 0) { pos_hare[1] = 0; - reduce_hare_chico(pos_hare[0], pos_hare[1], + if (num_ejec == 1) + reduce_hare_chico(pos_hare[0], pos_hare[1], pos_hare[2], pos_hare[3], pos_hare[4], pos_hare[5], factor_red[hare_y + alto_hare], dir_hare_dch, dir_zona_pantalla); + else if (num_ejec == 2) + DIBUJA_BLOQUE_CUT(pos_hare, dir_hare_dch, dir_zona_pantalla); } else if (sentido_hare == 1) - reduce_hare_chico(pos_hare[0], pos_hare[1], + if (num_ejec == 1) + reduce_hare_chico(pos_hare[0], pos_hare[1], pos_hare[2], pos_hare[3], pos_hare[4], pos_hare[5], factor_red[hare_y + alto_hare], dir_hare_dch, dir_zona_pantalla); + else if (num_ejec == 2) + DIBUJA_BLOQUE_CUT(pos_hare, dir_hare_dch, dir_zona_pantalla); else if (sentido_hare == 2) - reduce_hare_chico( pos_hare[0], pos_hare[1], + if (num_ejec == 1) + reduce_hare_chico( pos_hare[0], pos_hare[1], pos_hare[2], pos_hare[3], pos_hare[4], pos_hare[5], factor_red[hare_y + alto_hare], dir_hare_fondo, dir_zona_pantalla); + else if (num_ejec == 2) + DIBUJA_BLOQUE_CUT(pos_hare, dir_hare_fondo, dir_zona_pantalla); else - reduce_hare_chico( pos_hare[0], pos_hare[1], + if (num_ejec == 1) + reduce_hare_chico( pos_hare[0], pos_hare[1], pos_hare[2], pos_hare[3], pos_hare[4], pos_hare[5], factor_red[hare_y + alto_hare], dir_hare_frente, dir_zona_pantalla); + else if (num_ejec == 2) + DIBUJA_BLOQUE_CUT(pos_hare, dir_hare_frente, dir_zona_pantalla); } else if (hare_se_mueve == 1) { pos_hare[0] = frame_x[num_frame]; pos_hare[1] = frame_y + DIF_MASK_HARE; pos_hare[2] = hare_x; pos_hare[3] = hare_y; - pos_hare[4] = ANCHO_PERSONAJE; - pos_hare[5] = ALTO_PERSONAJE; + if (num_ejec == 1) { + pos_hare[4] = ANCHO_PERSONAJE; + pos_hare[5] = ALTO_PERSONAJE; + } else if (num_ejec == 2) { + pos_hare[4] = ancho_hare; + pos_hare[5] = alto_hare; + } if (sentido_hare == 0) { pos_hare[1] = 0; - reduce_hare_chico(pos_hare[0], pos_hare[1], + if (num_ejec == 1) + reduce_hare_chico(pos_hare[0], pos_hare[1], pos_hare[2], pos_hare[3], pos_hare[4], pos_hare[5], factor_red[hare_y + alto_hare], dir_hare_dch, dir_zona_pantalla); + else if (num_ejec == 2) + DIBUJA_BLOQUE_CUT(pos_hare, dir_hare_dch, dir_zona_pantalla); } else if (sentido_hare == 1) - reduce_hare_chico(pos_hare[0], pos_hare[1], + if (num_ejec == 1) + reduce_hare_chico(pos_hare[0], pos_hare[1], pos_hare[2], pos_hare[3], pos_hare[4], pos_hare[5], factor_red[hare_y + alto_hare], dir_hare_dch, dir_zona_pantalla); + else if (num_ejec == 2) + DIBUJA_BLOQUE_CUT(pos_hare, dir_hare_dch, dir_zona_pantalla); else if (sentido_hare == 2) - reduce_hare_chico(pos_hare[0], pos_hare[1], + if (num_ejec == 1) + reduce_hare_chico(pos_hare[0], pos_hare[1], pos_hare[2], pos_hare[3], pos_hare[4], pos_hare[5], factor_red[hare_y + alto_hare], dir_hare_fondo, dir_zona_pantalla); + else if (num_ejec == 2) + DIBUJA_BLOQUE_CUT(pos_hare, dir_hare_fondo, dir_zona_pantalla); else - reduce_hare_chico(pos_hare[0], pos_hare[1], + if (num_ejec == 1) + reduce_hare_chico(pos_hare[0], pos_hare[1], pos_hare[2], pos_hare[3], pos_hare[4], pos_hare[5], factor_red[hare_y + alto_hare], dir_hare_frente, dir_zona_pantalla); + else if (num_ejec == 2) + DIBUJA_BLOQUE_CUT(pos_hare, dir_hare_frente, dir_zona_pantalla); no_vuelco: aumenta_num_frame(); @@ -3449,30 +3858,63 @@ void DrasculaEngine::saca_objeto() { bool DrasculaEngine::sal_de_la_habitacion(int l) { char salgo[13]; - if (num_obj[l] == 105 && flags[0] == 0) - hablar(TEXT442, "442.als"); - else { - puertas_cerradas(l); + if (num_ejec == 1) { + if (num_obj[l] == 105 && flags[0] == 0) + hablar(TEXT442, "442.als"); + else { + puertas_cerradas(l); - if (espuerta[l] != 0) { - lleva_al_hare(sitiobj_x[l], sitiobj_y[l]); - sentido_hare = sentidobj[l]; - refresca_pantalla(); - VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); - hare_se_mueve = 0; + if (espuerta[l] != 0) { + lleva_al_hare(sitiobj_x[l], sitiobj_y[l]); + sentido_hare = sentidobj[l]; + refresca_pantalla(); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + hare_se_mueve = 0; + sentido_hare = sentido_alkeva[l]; + obj_saliendo = alapuertakeva[l]; + rompo = 1; + musica_antes = musica_room; + + if (num_obj[l] == 105) + if (animacion_2_1()) + return true; + borra_pantalla(); + strcpy(salgo, alapantallakeva[l]); + strcat(salgo, ".ald"); + hare_x = -1; + carga_escoba_1(salgo); + } + } + } else if (num_ejec == 2) { + puertas_cerradas(l); + if (espuerta[l] != 0) { + lleva_al_hare(sitiobj_x[l], sitiobj_y[l]); + hare_se_mueve = 0; sentido_hare = sentido_alkeva[l]; obj_saliendo = alapuertakeva[l]; rompo = 1; - musica_antes = musica_room; - - if (num_obj[l] == 105) - if (animacion_2()) - return true; + musica_antes = musica_room; + if (num_obj[l] == 136) + animacion_2_2(); + if (num_obj[l] == 124) + animacion_3_2(); + if (num_obj[l] == 173) + animacion_35(); + if (num_obj[l] == 146 && flags[39] == 1) { + flags[5] = 1; + flags[11] = 1; + } + if (num_obj[l] == 176 && flags[29] == 1) { + flags[29] = 0; + resta_objeto(23); + suma_objeto(11); + } borra_pantalla(); + ald->close(); strcpy(salgo, alapantallakeva[l]); strcat(salgo, ".ald"); - hare_x = -1; - carga_escoba(salgo); + hare_x =- 1; + carga_escoba_2(salgo); } } @@ -3517,9 +3959,57 @@ void DrasculaEngine::banderas(int fl) { hay_respuesta = 1; if (menu_scr == 1) { - - if (objeto_que_lleva == MIRAR && fl == 28) - hablar(TEXT328, "328.als"); + if (objeto_que_lleva == MIRAR && fl == 28) + hablar(TEXT328, "328.als"); + if ((objeto_que_lleva == MIRAR && fl == 22 && flags[23] == 0) + || (objeto_que_lleva == ABRIR && fl == 22 && flags[23] == 0)) { + hablar(TEXT164, "164.als"); + flags[23] = 1; + sin_verbo(); + suma_objeto(7); + suma_objeto(18); + } else if (objeto_que_lleva == MIRAR && fl == 22 && flags[23] == 1) + hablar(TEXT307, "307.als"); + else if (objeto_que_lleva == MIRAR && fl == 7) + hablar(TEXT143, "143.als"); + else if (objeto_que_lleva == HABLAR && fl == 7) + hablar(TEXT144, "144.als"); + else if (objeto_que_lleva == MIRAR && fl == 8) + hablar(TEXT145, "145.als"); + else if (objeto_que_lleva == HABLAR && fl == 8) + hablar(TEXT146, "146.als"); + else if (objeto_que_lleva == MIRAR && fl == 9) + hablar(TEXT147, "147.als"); + else if (objeto_que_lleva == HABLAR && fl == 9) + hablar(TEXT148, "148.als"); + else if (objeto_que_lleva == MIRAR && fl == 10) + hablar(TEXT151, "151.als"); + else if (objeto_que_lleva == MIRAR && fl == 11) + hablar(TEXT152, "152.als"); + else if (objeto_que_lleva == HABLAR && fl == 11) + hablar(TEXT153, "153.als"); + else if (objeto_que_lleva == MIRAR && fl == 12) + hablar(TEXT154, "154.als"); + else if (objeto_que_lleva == MIRAR && fl == 13) + hablar(TEXT155, "155.als"); + else if (objeto_que_lleva == MIRAR && fl == 14) + hablar(TEXT157, "157.als"); + else if (objeto_que_lleva == MIRAR && fl == 15) + hablar(TEXT58, "58.als"); + else if (objeto_que_lleva == MIRAR && fl == 16) + hablar(TEXT158, "158.als"); + else if (objeto_que_lleva == MIRAR && fl == 17) + hablar(TEXT159, "159.als"); + else if (objeto_que_lleva == MIRAR && fl == 18) + hablar(TEXT160, "160.als"); + else if (objeto_que_lleva == MIRAR && fl == 19) + hablar(TEXT161, "161.als"); + else if (objeto_que_lleva == MIRAR && fl == 20) + hablar(TEXT162, "162.als"); + else if (objeto_que_lleva == MIRAR && fl == 23) + hablar(TEXT152, "152.als"); + else + hay_respuesta = 0; } else { if (objeto_que_lleva == MIRAR && fl == 50) hablar(TEXT308, "308.als"); @@ -3938,9 +4428,13 @@ char DrasculaEngine::codifica(char car) { } void DrasculaEngine::cuadrante_1() { - float distancia_x, distancia_y; + float distancia_x = 0, distancia_y; + + if (num_ejec == 1) + distancia_x = hare_x + ancho_hare / 2 - sitio_x; + else if (num_ejec == 2) + distancia_x = hare_x + ancho_hare - sitio_x; - distancia_x = hare_x + ancho_hare / 2 - sitio_x; distancia_y = (hare_y + alto_hare) - sitio_y; if (distancia_x < distancia_y) { @@ -3955,9 +4449,13 @@ void DrasculaEngine::cuadrante_1() { } void DrasculaEngine::cuadrante_2() { - float distancia_x, distancia_y; + float distancia_x = 0, distancia_y; + + if (num_ejec == 1) + distancia_x = abs(hare_x + ancho_hare / 2 - sitio_x); + else if (num_ejec == 2) + distancia_x = abs(hare_x + ancho_hare - sitio_x); - distancia_x = abs(hare_x + ancho_hare / 2 - sitio_x); distancia_y = (hare_y + alto_hare) - sitio_y; if (distancia_x < distancia_y) { @@ -3972,9 +4470,13 @@ void DrasculaEngine::cuadrante_2() { } void DrasculaEngine::cuadrante_3() { - float distancia_x, distancia_y; + float distancia_x = 0, distancia_y; + + if (num_ejec == 1) + distancia_x = hare_x + ancho_hare / 2 - sitio_x; + else if (num_ejec == 2) + distancia_x = hare_x + ancho_hare - sitio_x; - distancia_x = hare_x + ancho_hare / 2 - sitio_x; distancia_y = sitio_y - (hare_y + alto_hare); if (distancia_x < distancia_y) { @@ -3989,9 +4491,13 @@ void DrasculaEngine::cuadrante_3() { } void DrasculaEngine::cuadrante_4() { - float distancia_x, distancia_y; + float distancia_x = 0, distancia_y; + + if (num_ejec == 1) + distancia_x = abs(hare_x + ancho_hare / 2 - sitio_x); + else if (num_ejec == 2) + distancia_x = abs(hare_x + ancho_hare - sitio_x); - distancia_x = abs(hare_x + ancho_hare / 2 - sitio_x); distancia_y = sitio_y - (hare_y + alto_hare); if (distancia_x writeSint32LE(num_ejec); - out->write(datos_actuales, 13); + out->write(datos_actuales, 20); out->writeSint32LE(hare_x); out->writeSint32LE(hare_y); out->writeSint32LE(sentido_hare); @@ -4136,12 +4642,14 @@ void DrasculaEngine::aumenta_num_frame() { } } - diferencia_y = alto_hare - (int)nuevo_alto; - diferencia_x = ancho_hare - (int)nuevo_ancho; - hare_y = hare_y + diferencia_y; - hare_x = hare_x + diferencia_x; - alto_hare = (int)nuevo_alto; - ancho_hare = (int)nuevo_ancho; + if (num_ejec == 1) { + diferencia_y = alto_hare - (int)nuevo_alto; + diferencia_x = ancho_hare - (int)nuevo_ancho; + hare_y = hare_y + diferencia_y; + hare_x = hare_x + diferencia_x; + alto_hare = (int)nuevo_alto; + ancho_hare = (int)nuevo_ancho; + } } int DrasculaEngine::sobre_que_objeto() { @@ -4169,31 +4677,53 @@ void DrasculaEngine::comprueba_banderas_menu() { } void DrasculaEngine::pantalla_0() { - if (objeto_que_lleva == MIRAR) - hablar(TEXT54, "54.als"); - else if (objeto_que_lleva == MOVER) + if (objeto_que_lleva == MIRAR) { + if (num_ejec == 1) + hablar(TEXT54, "54.als"); + else if (num_ejec == 2) { + hablar(mirar_t[c_mirar], mirar_v[c_mirar]); + c_mirar++; + if (c_mirar == 3) + c_mirar = 0; + } + } else if (objeto_que_lleva == MOVER) hablar(TEXT19, "19.als" ); else if (objeto_que_lleva == COGER) - hablar(TEXT11, "11.als" ); + if (num_ejec == 1) + hablar(TEXT11, "11.als" ); + else if (num_ejec == 2) { + hablar(poder_t[c_poder], poder_v[c_poder]); + c_poder++; + if (c_poder == 6) + c_poder = 0; + } else if (objeto_que_lleva == ABRIR) hablar(TEXT9, "9.als" ); else if (objeto_que_lleva == CERRAR) hablar(TEXT9, "9.als" ); else if (objeto_que_lleva == HABLAR) hablar(TEXT16, "16.als" ); - else - hablar(TEXT11, "11.als"); + else { + if (num_ejec == 1) + hablar(TEXT11, "11.als"); + else if (num_ejec == 1) { + hablar(poder_t[c_poder], poder_v[c_poder]); + c_poder++; + if (c_poder == 6) + c_poder = 0; + } + } } void DrasculaEngine::pantalla_62(int fl) { if (objeto_que_lleva == HABLAR && fl == 53) conversa("op_13.cal"); else if (objeto_que_lleva == HABLAR && fl == 52 && flags[0] == 0) - animacion_3(); + animacion_3_2(); else if (objeto_que_lleva == HABLAR && fl == 52 && flags[0] == 1) hablar(TEXT109, "109.als"); else if (objeto_que_lleva == HABLAR && fl == 54) - animacion_4(); + animacion_4_1(); else if (objeto_que_lleva == MIRAR && fl == 100) hablar(TEXT168, "168.als"); else if (objeto_que_lleva == HABLAR && fl == 100) @@ -4282,6 +4812,12 @@ void DrasculaEngine::conversa(const char *nom_fich) { delete ald; canal_p(para_codificar); + if (num_ejec == 2 && !strcmp(nom_fich, "op_5.cal") && flags[38] == 1 && flags[33] == 1) { + strcpy(frase3, TEXT405); + strcpy(suena3, "405.als"); + respuesta3 = 31; + } + longitud = strlen(frase1); for (h = 0; h < longitud; h++) if (frase1[h] == (char)0xa7) @@ -4316,8 +4852,12 @@ bucle_opc: refresca_pantalla(); - if (music_status() == 0 && flags[11] == 0) - playmusic(musica_room); + if (num_ejec == 1) + if (music_status() == 0 && flags[11] == 0) + playmusic(musica_room); + else if (num_ejec == 2) + if (music_status() == 0 && flags[11] == 0 && musica_room != 0) + playmusic(musica_room); MirarRaton(); @@ -4393,12 +4933,15 @@ bucle_opc: if (rompo_y_salgo == 0) goto bucle_opc; - lee_dibujos("99.alg"); + if (num_ejec == 1) + lee_dibujos("99.alg"); + else if (num_ejec == 2) + lee_dibujos(fondo_y_menu); descomprime_dibujo(dir_hare_fondo, 1); sin_verbo(); } -void DrasculaEngine::animacion_3() { +void DrasculaEngine::animacion_3_1() { lee_dibujos("an11y13.alg"); descomprime_dibujo(dir_hare_dch, 1); @@ -4429,7 +4972,7 @@ void DrasculaEngine::animacion_3() { descomprime_dibujo(dir_hare_dch, 1); } -void DrasculaEngine::animacion_4() { +void DrasculaEngine::animacion_4_1() { lee_dibujos("an12.alg"); descomprime_dibujo(dir_hare_dch, 1); @@ -4659,6 +5202,34 @@ void DrasculaEngine::responde(int funcion) { habla_borracho(TEXTB2, "B2.als"); else if (funcion == 12) habla_borracho(TEXTB3, "B3.als"); + else if (funcion == 8) + animacion_8(); + else if (funcion == 9) + animacion_9(); + else if (funcion == 10) + animacion_10(); + else if (funcion == 15) + animacion_15(); + else if (funcion == 16) + animacion_16(); + else if (funcion == 17) + animacion_17(); + else if (funcion == 19) + animacion_19(); + else if (funcion == 20) + animacion_20(); + else if (funcion == 21) + animacion_21(); + else if (funcion == 23) + animacion_23(); + else if (funcion == 28) + animacion_28(); + else if (funcion == 29) + animacion_29(); + else if (funcion == 30) + animacion_30(); + else if (funcion == 31) + animacion_31(); } void DrasculaEngine::habla_pianista(const char *dicho, const char *filename) { @@ -4888,5 +5459,1398 @@ int DrasculaEngine::LookForFree() { return _mixer->isSoundHandleActive(_soundHandle); } +void DrasculaEngine::actualiza_datos() { + if (!strcmp(num_room,"2.alg") && flags[40] == 0) + visible[3] = 0; + else if (!strcmp(num_room, "3.alg") && flags[3] == 1) + visible[8] = 0; + else if (!strcmp(num_room, "6.alg") && flags[1] == 1 && flags[10] == 0) { + visible[2] = 0; + visible[4] = 1; + } else if (!strcmp(num_room, "7.alg") && flags[35] == 1) + visible[3] = 0; + else if (!strcmp(num_room, "14.alg") && flags[5] == 1) + visible[4] = 0; + else if (!strcmp(num_room, "18.alg") && flags[28] == 1) + visible[2] = 0; +} + +void DrasculaEngine::animacion_1_2() { + lleva_al_hare(178, 121); + lleva_al_hare(169, 135); +} + +void DrasculaEngine::animacion_2_2() { + int n, x=0; + + sentido_hare = 0; + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); + pon_hare(); + actualiza_refresco(); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + lee_dibujos("an2_1.alg"); + descomprime_dibujo(dir_hare_frente, 1); + lee_dibujos("an2_2.alg"); + descomprime_dibujo(dir_hare_dch, 1); + + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); + DIBUJA_FONDO(1, 1, 201, 87, 50, 52, dir_hare_frente, dir_zona_pantalla); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + for (n = 0; n < 6; n++) { + x++; + DIBUJA_FONDO(x, 1, 201, 87, 50, 52, dir_hare_frente, dir_zona_pantalla); + VUELCA_PANTALLA(201,87, 201,87, 50,52, dir_zona_pantalla); + x = x + 50; + pausa(3); + } + + x = 0; + + for (n = 0; n < 6; n++) { + x++; + DIBUJA_FONDO(x, 55, 201, 87, 50, 52, dir_hare_frente, dir_zona_pantalla); + VUELCA_PANTALLA(201, 87, 201, 87, 50, 52, dir_zona_pantalla); + x = x + 50; + pausa(3); + } + + x = 0; + + for (n = 0; n < 6; n++){ + x++; + DIBUJA_FONDO(x, 109, 201, 87, 50, 52, dir_hare_frente, dir_zona_pantalla); + VUELCA_PANTALLA(201, 87, 201, 87, 50, 52, dir_zona_pantalla); + x = x + 50; + pausa(3); + } + + x = 0; + comienza_sound("s2.als"); + + for (n = 0; n < 6; n++) { + x++; + DIBUJA_FONDO(x, 1, 201, 87, 50, 52, dir_hare_dch, dir_zona_pantalla); + VUELCA_PANTALLA(201,87, 201,87, 50,52, dir_zona_pantalla); + x = x + 50; + pausa(3); + } + + x = 0; + + for (n = 0; n < 6; n++) { + x++; + DIBUJA_FONDO(x, 55, 201, 87, 50, 52, dir_hare_dch, dir_zona_pantalla); + VUELCA_PANTALLA(201, 87, 201, 87, 50, 52, dir_zona_pantalla); + x = x + 50; + pausa(3); + } + x = 0; + + for (n = 0; n < 2; n++) { + x++; + DIBUJA_FONDO(x, 109, 201, 87, 50, 52, dir_hare_dch, dir_zona_pantalla); + VUELCA_PANTALLA(201, 87, 201, 87, 50, 52, dir_zona_pantalla); + x = x + 50; + pausa(3); + } + + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + + fin_sound(); + + pausa (4); + + comienza_sound("s1.als"); + hipo_sin_nadie(12); + fin_sound(); + } + +void DrasculaEngine::animacion_3_2() { + lleva_al_hare(163, 106); + lleva_al_hare(287, 101); + sentido_hare = 0; +} + +void DrasculaEngine::animacion_4_2() { + stopmusic(); + flags[9] = 1; + + pausa(12); + hablar(TEXTD56, "d56.als" ); + pausa(8); + + borra_pantalla(); + lee_dibujos("ciego1.alg"); + descomprime_dibujo(dir_dibujo1, MEDIA); + lee_dibujos("ciego2.alg"); + descomprime_dibujo(dir_dibujo3, 1); + lee_dibujos("ciego3.alg"); + descomprime_dibujo(dir_hare_dch, 1); + lee_dibujos("ciego4.alg"); + descomprime_dibujo(dir_hare_fondo, 1); + lee_dibujos("ciego5.alg"); + descomprime_dibujo(dir_hare_frente, 1); + + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + + pausa(10); + + habla_ciego(TEXTD68, "d68.als", "44472225500022227555544444664447222550002222755554444466"); + pausa(5); + habla_hacker(TEXTD57, "d57.als"); + pausa(6); + habla_ciego(TEXTD69,"d69.als","444722255000222275555444446655033336666664464402256555005504450005446"); + pausa(4); + habla_hacker(TEXTD58,"d58.als"); + habla_ciego(TEXTD70,"d70.als", "4447222550002222755554444466550333226220044644550044755665500440006655556666655044744656550446470046"); + delay(14); + habla_hacker(TEXTD59,"d59.als"); + habla_ciego(TEXTD71,"d71.als", "550330227556444744446660004446655544444722255000222275555444446644444"); + habla_hacker(TEXTD60,"d60.als"); + habla_ciego(TEXTD72,"d72.als", "55033022755644455550444744400044504447222550002222755554444466000"); + habla_hacker(TEXTD61,"d61.als"); + habla_ciego(TEXTD73,"d73.als", "55033022755644444447227444466644444722255000222275555444446664404446554440055655022227500544446044444446"); + habla_hacker(TEXTD62,"d62.als"); + habla_ciego(TEXTD74,"d74.als", "55033022755644444472244472225500022227555544444662550002222755444446666055522275550005550022200222000222666"); + habla_hacker(TEXTD63,"d63.als"); + habla_ciego(TEXTD75,"d75.als", "44447774444555500222205550444444466666225266444755444722255000222275555444446633223220044022203336227555770550444660557220553302224477777550550550222635533000662220002275572227025555"); + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + _system->delayMillis(1); + habla_hacker(TEXTD64, "d64.als"); + habla_ciego(TEXTD76, "d76.als", "5555500004445550330244472225500022227555544444662755644446666005204402266222003332222774440446665555005550335544444"); + + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + + pausa(14); + + borra_pantalla(); + + playmusic(musica_room); + lee_dibujos("9.alg"); + descomprime_dibujo(dir_dibujo1, MEDIA); + lee_dibujos("aux9.alg"); + descomprime_dibujo(dir_dibujo3, 1); + lee_dibujos("96.alg"); + descomprime_dibujo(dir_hare_frente, 1); + lee_dibujos("97.alg"); + descomprime_dibujo(dir_hare_dch, 1); + lee_dibujos("99.alg"); + descomprime_dibujo(dir_hare_fondo, 1); + sin_verbo(); + + flags[9] = 0; + flags[4] = 1; +} + +void DrasculaEngine::animacion_8() { + habla_pianista(TEXTP6, "P6.als"); + hablar(TEXT358, "358.als"); + habla_pianista(TEXTP7, "P7.als"); + habla_pianista(TEXTP8, "P8.als"); +} + +void DrasculaEngine::animacion_9() { + habla_pianista(TEXTP9, "P9.als"); + habla_pianista(TEXTP10, "P10.als"); + habla_pianista(TEXTP11, "P11.als"); +} + +void DrasculaEngine::animacion_10() { + habla_pianista(TEXTP12, "P12.als"); + hablar(TEXT361, "361.als"); + pausa(40); + habla_pianista(TEXTP13, "P13.als"); + hablar(TEXT362, "362.als"); + habla_pianista(TEXTP14, "P14.als"); + hablar(TEXT363, "363.als"); + habla_pianista(TEXTP15, "P15.als"); + hablar(TEXT364, "364.als"); + habla_pianista(TEXTP16, "P16.als"); +} + +void DrasculaEngine::animacion_14() { + int n, pos_cabina[6]; + int l = 0; + + lee_dibujos("an14_2.alg"); + descomprime_dibujo(dir_hare_fondo, 1); + lee_dibujos("an14_1.alg"); + + pos_cabina[0]=150; + pos_cabina[1]=6; + pos_cabina[2]=69; + pos_cabina[3]=-160; + pos_cabina[4]=158; + pos_cabina[5]=161; + + for (n = -160; n <= 0; n = n + 5 + l) { + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); + actualiza_refresco_antes(); + pon_hare(); + pon_vb(); + pos_cabina[3] = n; + DIBUJA_BLOQUE_CUT(pos_cabina, dir_hare_fondo, dir_zona_pantalla); + actualiza_refresco(); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + l = l + 1; + } + + flags[24] = 1; + + descomprime_dibujo(dir_dibujo1, 1); + + comienza_sound("s7.als"); + hipo(15); + + fin_sound(); + + lee_dibujos("99.alg"); + descomprime_dibujo(dir_hare_fondo, 1); +} + +void DrasculaEngine::animacion_15() { + habla_borracho(TEXTB8, "B8.als"); + pausa(7); + habla_borracho(TEXTB9, "B9.als"); + habla_borracho(TEXTB10, "B10.als"); + habla_borracho(TEXTB11, "B11.als"); +} + +void DrasculaEngine::animacion_16() { + int l; + + habla_borracho(TEXTB12, "B12.als"); + hablar(TEXT371, "371.als"); + + borra_pantalla(); + + playmusic(32); + int key = getscan(); + if (key != 0) + goto asco; + + color_abc(VERDE_OSCURO); + + lee_dibujos("his1.alg"); + descomprime_dibujo(dir_dibujo1, MEDIA); + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); + centra_texto(HIS1, 180, 180); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + key = getscan(); + if (key != 0) + goto asco; + + _system->delayMillis(4); + key = getscan(); + if (key != 0) + goto asco; + + FundeAlNegro(1); + key = getscan(); + if (key != 0) + goto asco; + + borra_pantalla(); + lee_dibujos("his2.alg"); + descomprime_dibujo(dir_dibujo1, MEDIA); + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); + centra_texto(HIS2, 180, 180); + VUELCA_PANTALLA(0,0,0,0, 320,200, dir_zona_pantalla); + key = getscan(); + if (key != 0) + goto asco; + + _system->delayMillis(4); + key = getscan(); + if (key != 0) + goto asco; + + FundeAlNegro(1); + key = getscan(); + if (key != 0) + goto asco; + + borra_pantalla(); + lee_dibujos("his3.alg"); + descomprime_dibujo(dir_dibujo1, MEDIA); + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); + centra_texto(HIS3, 180, 180); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + key = getscan(); + if (key != 0) + goto asco; + + _system->delayMillis(4); + key = getscan(); + if (key != 0) + goto asco; + + FundeAlNegro(1); + + borra_pantalla(); + lee_dibujos("his4_1.alg"); + descomprime_dibujo(dir_dibujo1, MEDIA); + lee_dibujos("his4_2.alg"); + descomprime_dibujo(dir_dibujo3, 1); + + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo3, dir_zona_pantalla); + centra_texto(HIS1, 180, 180); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + key = getscan(); + if (key != 0) + goto asco; + + _system->delayMillis(4); + key = getscan(); + if (key != 0) + goto asco; + + for (l = 1; l < 200; l++){ + DIBUJA_FONDO(0, 0, 0, l, 320, 200 - l, dir_dibujo3, dir_zona_pantalla); + DIBUJA_FONDO(0, 200 - l, 0, 0, 320, l, dir_dibujo1, dir_zona_pantalla); + VUELCA_PANTALLA(0,0,0,0, 320,200, dir_zona_pantalla); + key = getscan(); + if (key != 0) + goto asco; + } + + pausa(5); + FundeAlNegro(2); + borra_pantalla(); + +asco: + lee_dibujos(pantalla_disco); + descomprime_dibujo(dir_dibujo3, 1); + lee_dibujos(num_room); + descomprime_dibujo(dir_dibujo1, MEDIA); + Negro(); + refresca_pantalla(); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + FundeDelNegro(0); + if (musica_room != 0) + playmusic(musica_room); + else + stopmusic(); +} + +void DrasculaEngine::animacion_17() { + habla_borracho(TEXTB13, "B13.als"); + habla_borracho(TEXTB14, "B14.als"); + flags[40] = 1; +} + +void DrasculaEngine::animacion_19() { + habla_vbpuerta(TEXTVB5, "VB5.als"); +} + +void DrasculaEngine::animacion_20() { + habla_vbpuerta(TEXTVB7, "VB7.als"); + habla_vbpuerta(TEXTVB8, "VB8.als"); + hablar(TEXT383, "383.als"); + habla_vbpuerta(TEXTVB9, "VB9.als"); + hablar(TEXT384, "384.als"); + habla_vbpuerta(TEXTVB10, "VB10.als"); + hablar(TEXT385, "385.als"); + habla_vbpuerta(TEXTVB11, "VB11.als"); + if (flags[23] == 0) { + hablar(TEXT350, "350.als"); + habla_vbpuerta(TEXTVB57, "VB57.als"); + } else { + hablar(TEXT386, "386.als"); + habla_vbpuerta(TEXTVB12, "VB12.als"); + flags[18] = 0; + flags[14] = 1; + abre_puerta(15, 1); + sal_de_la_habitacion(1); + animacion_23(); + sal_de_la_habitacion(0); + flags[21] = 0; + flags[24] = 0; + sentido_vb = 1; + vb_x = 120; + + rompo_y_salgo = 1; + } +} + +void DrasculaEngine::animacion_21() { + habla_vbpuerta(TEXTVB6, "VB6.als"); +} + +void DrasculaEngine::animacion_23() { + lee_dibujos("an24.alg"); + descomprime_dibujo(dir_hare_frente, 1); + + flags[21] = 1; + + if (flags[25] == 0) { + habla_vb(TEXTVB13, "VB13.als"); + habla_vb(TEXTVB14, "VB14.als"); + pausa(10); + hablar(TEXT387, "387.als"); + } + + habla_vb(TEXTVB15, "VB15.als"); + lleva_vb(42); + sentido_vb = 1; + habla_vb(TEXTVB16, "VB16.als"); + sentido_vb = 2; + lleva_al_hare(157, 147); + lleva_al_hare(131, 149); + sentido_hare = 0; + animacion_14(); + if (flags[25] == 0) + habla_vb(TEXTVB17, "VB17.als"); + pausa(8); + sentido_vb = 1; + habla_vb(TEXTVB18, "VB18.als"); + + if (flags[29] == 0) + animacion_23_anexo(); + else + animacion_23_anexo2(); + + sentido_vb = 2; + animacion_25(); + lleva_vb(99); + + if (flags[29] == 0) { + habla_vb(TEXTVB19, "VB19.als"); + if (flags[25] == 0) { + habla_vb(TEXTVB20,"VB20.als"); + if (resta_objeto(7) == 0) + flags[30] = 1; + if (resta_objeto(18) == 0) + flags[31] = 1; + if (resta_objeto(19) == 0) + flags[32] = 1; + } + habla_vb(TEXTVB21, "VB21.als"); + } else + animacion_27(); + + flags[25] = 1; + rompo_y_salgo = 1; +} + +void DrasculaEngine::animacion_23_anexo() { + int n, p_x = hare_x + 2, p_y = hare_y - 3; + int x[] = {1,38,75,112,75,112,75,112,149,112,149,112,149,186,223,260,1,38,75,112,149,112,149,112,149,112,149,186,223,260,260,260,260,223}; + int y[] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,76,76,76,76,76,76,76,76,76,76,76,76,76,76,1,1,1,1}; + + lee_dibujos("an23.alg"); + descomprime_dibujo(dir_hare_fondo, 1); + + for (n = 0; n < 34; n++) { + DIBUJA_BLOQUE(p_x, p_y, p_x, p_y, 36, 74, dir_dibujo1, dir_zona_pantalla); + DIBUJA_BLOQUE(x[n], y[n], p_x, p_y, 36, 74, dir_hare_fondo, dir_zona_pantalla); + actualiza_refresco(); + VUELCA_PANTALLA(p_x, p_y, p_x, p_y, 36, 74, dir_zona_pantalla); + pausa(5); + } + + lee_dibujos("99.alg"); + descomprime_dibujo(dir_hare_fondo, 1); +} + +void DrasculaEngine::animacion_23_anexo2() { + int n, p_x = hare_x + 4, p_y = hare_y; + int x[] = {1,35,69,103,137,171,205,239,273,1,35,69,103,137}; + int y[] = {1,1,1,1,1,1,1,1,1,73,73,73,73,73}; + + pausa(50); + + lee_dibujos("an23_2.alg"); + descomprime_dibujo(dir_hare_fondo, 1); + + for (n = 0; n < 14; n++) { + DIBUJA_BLOQUE(p_x, p_y, p_x, p_y, 33, 71, dir_dibujo1, dir_zona_pantalla); + DIBUJA_BLOQUE(x[n], y[n], p_x, p_y, 33, 71, dir_hare_fondo, dir_zona_pantalla); + actualiza_refresco(); + VUELCA_PANTALLA(p_x,p_y, p_x,p_y, 33,71, dir_zona_pantalla); + pausa(5); + } + + lee_dibujos("99.alg"); + descomprime_dibujo(dir_hare_fondo,1); +} + +void DrasculaEngine::animacion_25() { + int n, pos_cabina[6]; + + lee_dibujos("an14_2.alg"); + descomprime_dibujo(dir_hare_fondo, 1); + lee_dibujos("18.alg"); + descomprime_dibujo(dir_dibujo1, 1); + + pos_cabina[0] = 150; + pos_cabina[1] = 6; + pos_cabina[2] = 69; + pos_cabina[3] = 0; + pos_cabina[4] = 158; + pos_cabina[5] = 161; + + flags[24] = 0; + + comienza_sound("s6.als"); + + for (n = 0; n >= -160; n = n - 8) { + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); + + actualiza_refresco_antes(); + pon_hare(); + pon_vb(); + + pos_cabina[3] = n; + + DIBUJA_BLOQUE_CUT(pos_cabina, dir_hare_fondo, dir_zona_pantalla); + + actualiza_refresco(); + VUELCA_PANTALLA(0,0, 0,0, 320,200, dir_zona_pantalla); + } + + fin_sound(); + + lee_dibujos("99.alg"); + descomprime_dibujo(dir_hare_fondo, 1); +} + +void DrasculaEngine::animacion_27() { + flags[22] = 1; + + sin_verbo(); + resta_objeto(23); + suma_objeto(11); + + habla_vb(TEXTVB23, "VB23.als"); + habla_vb(TEXTVB24, "VB24.als"); + if (flags[30] == 1) + suma_objeto(7); + if (flags[31] == 1) + suma_objeto(18); + if (flags[32] == 1) + suma_objeto(19); + habla_vb(TEXTVB25,"VB25.als"); + habla_vb(TEXTVB26,"VB26.als"); +} + +void DrasculaEngine::animacion_28(){ + habla_vb(TEXTVB27, "VB27.als"); + habla_vb(TEXTVB28, "VB28.als"); + habla_vb(TEXTVB29, "VB29.als"); + habla_vb(TEXTVB30, "VB30.als"); +} + +void DrasculaEngine::animacion_29(){ + if (flags[33] == 0) { + habla_vb(TEXTVB32, "VB32.als"); + hablar(TEXT398, "398.als"); + habla_vb(TEXTVB33, "VB33.als"); + hablar(TEXT399, "399.als"); + habla_vb(TEXTVB34, "VB34.als"); + habla_vb(TEXTVB35, "VB35.als"); + hablar(TEXT400, "400.als"); + habla_vb(TEXTVB36, "VB36.als"); + habla_vb(TEXTVB37, "VB37.als"); + hablar(TEXT386, "386.als"); + habla_vb(TEXTVB38, "VB38.als"); + habla_vb(TEXTVB39, "VB39.als"); + hablar(TEXT401, "401.als"); + habla_vb(TEXTVB40, "VB40.als"); + habla_vb(TEXTVB41, "VB41.als"); + flags[33] = 1; + } else + habla_vb(TEXTVB43, "VB43.als"); + + hablar(TEXT402, "402.als"); + habla_vb(TEXTVB42, "VB42.als"); + + if (flags[38] == 0) { + hablar(TEXT403, "403.als"); + rompo_y_salgo = 1; + } else + hablar(TEXT386, "386.als"); +} + +void DrasculaEngine::animacion_30(){ + habla_vb(TEXTVB31, "VB31.als"); + hablar(TEXT396, "396.als"); +} + +void DrasculaEngine::animacion_31(){ + habla_vb(TEXTVB44, "VB44.als"); + lleva_vb(-50); + pausa(15); + lleva_al_hare(159, 140); + lee_dibujos("99.alg"); + descomprime_dibujo(dir_hare_fondo, 1); + sentido_hare = 2; + refresca_pantalla(); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + pausa(78); + sentido_hare = 0; + refresca_pantalla(); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + pausa(22); + hablar(TEXT406, "406.als"); + lleva_vb(98); + habla_vb(TEXTVB45, "VB45.als"); + habla_vb(TEXTVB46, "VB46.als"); + habla_vb(TEXTVB47, "VB47.als"); + hablar(TEXT407, "407.als"); + habla_vb(TEXTVB48, "VB48.als"); + habla_vb(TEXTVB49, "VB49.als"); + hablar(TEXT408, "408.als"); + habla_vb(TEXTVB50, "VB50.als"); + habla_vb(TEXTVB51, "VB51.als"); + hablar(TEXT409, "409.als"); + habla_vb(TEXTVB52, "VB52.als"); + habla_vb(TEXTVB53, "VB53.als"); + pausa(12); + habla_vb(TEXTVB54, "VB54.als"); + habla_vb(TEXTVB55, "VB55.als"); + hablar(TEXT410, "410.als"); + habla_vb(TEXTVB56, "VB56.als"); + + rompo_y_salgo = 1; + + flags[38] = 0; + flags[36] = 1; + sin_verbo(); + resta_objeto(8); + resta_objeto(13); + resta_objeto(15); + resta_objeto(16); + resta_objeto(17); + suma_objeto(20); +} + +void DrasculaEngine::animacion_35() { + int n, x = 0; + + lleva_al_hare(96, 165); + lleva_al_hare(79, 165); + + refresca_pantalla(); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + + lee_dibujos("an35_1.alg"); + descomprime_dibujo(dir_hare_fondo, 1); + lee_dibujos("an35_2.alg"); + descomprime_dibujo(dir_hare_frente, 1); + + for (n = 0; n < 6; n++) { + x++; + DIBUJA_FONDO(x, 1, 70, 90, 46, 80, dir_hare_fondo, dir_zona_pantalla); + VUELCA_PANTALLA(70,90, 70,90, 46,80,dir_zona_pantalla); + x = x + 46; + pausa(3); + } + x = 0; + + for (n = 0; n < 6; n++) { + x++; + DIBUJA_FONDO(x, 82, 70, 90, 46, 80, dir_hare_fondo, dir_zona_pantalla); + VUELCA_PANTALLA(70, 90, 70, 90, 46, 80, dir_zona_pantalla); + x = x + 46; + pausa(3); + } + + x = 0; + + for (n = 0; n < 6; n++) { + x++; + DIBUJA_FONDO(x, 1, 70, 90, 46, 80, dir_hare_frente, dir_zona_pantalla); + VUELCA_PANTALLA(70, 90, 70, 90, 46, 80, dir_zona_pantalla); + + x = x + 46; + + pausa(3); + } + x = 0; + + for (n = 0; n < 2; n++) { + x++; + DIBUJA_FONDO(x, 82, 70, 90, 46, 80, dir_hare_frente, dir_zona_pantalla); + VUELCA_PANTALLA(70, 90, 70,90, 46, 80,dir_zona_pantalla); + x = x + 46; + pausa(3); + } + + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); + + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + + pausa(19); + + comienza_sound("s1.als"); + hipo_sin_nadie(18); + fin_sound(); + + pausa(10); + + FundeAlNegro(2); + + // TODO + salir_al_dos(3); +} + +void DrasculaEngine::habla_vb(char dicho[], char filename[]) { + int tiempou; + long tiempol; + + int x_habla[6] = {1,27,53,79,105,131}; + int cara; + + int longitud; + longitud = strlen(dicho); + + tiempol = _system->getMillis(); + tiempou = (unsigned int)tiempol / 2; + _rnd->setSeed(tiempou); + + buffer_teclado(); + + color_abc(VON_BRAUN); + + if (hay_sb == 1) { + sku = new Common::File; + sku->open(filename); + if (!sku->isOpen()) { + error("no puedo abrir archivo de voz"); + } + ctvd_init(2); + ctvd_speaker(1); + ctvd_output(sku); + } + + DIBUJA_FONDO(vb_x + 5, 64, ANCHOBJ + 1, 0, 25, 27, dir_dibujo1, dir_dibujo3); + +bucless: + + if (sentido_vb == 1) { + cara = _rnd->getRandomNumber(5); + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); + + pon_hare(); + pon_vb(); + + DIBUJA_FONDO(ANCHOBJ + 1, 0, vb_x + 5, 64, 25, 27, dir_dibujo3, dir_zona_pantalla); + DIBUJA_BLOQUE(x_habla[cara], 34, vb_x + 5, 64, 25, 27, dir_hare_frente, dir_zona_pantalla); + actualiza_refresco(); + } + + if (con_voces == 0) + centra_texto(dicho, vb_x, 66); + + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + + pausa(3); + + int key = getscan(); + if (key != 0) + ctvd_stop(); + buffer_teclado(); + if (hay_sb == 1) { + if (LookForFree() != 0) + goto bucless; + delete sku; + ctvd_terminate(); + } else { + longitud = longitud - 2; + if (longitud > 0) + goto bucless; + } + + refresca_pantalla(); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + if (music_status() == 0 && flags[11] == 0 && musica_room != 0) + playmusic(musica_room); +} + +void DrasculaEngine::habla_vbpuerta(char dicho[], char filename[]) { + int tiempou; + long tiempol; + + int longitud; + longitud = strlen(dicho); + + tiempol = _system->getMillis(); + tiempou = (unsigned int)tiempol / 2; + _rnd->setSeed(tiempou); + + buffer_teclado(); + + color_abc(VON_BRAUN); + + if (hay_sb == 1) { + sku = new Common::File; + sku->open(filename); + if (!sku->isOpen()) { + error("no puedo abrir archivo de voz"); + } + ctvd_init(2); + ctvd_speaker(1); + ctvd_output(sku); + } + +bucless: + + refresca_pantalla(); + if (con_voces == 0) + centra_texto(dicho, 150, 80); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + + int key = getscan(); + if (key != 0) + ctvd_stop(); + buffer_teclado(); + if (hay_sb == 1) { + if (LookForFree() != 0) + goto bucless; + delete sku; + ctvd_terminate(); + } else { + longitud = longitud - 2; + if (longitud > 0) + goto bucless; + } + + refresca_pantalla(); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + if (music_status() == 0 && flags[11] == 0 && musica_room != 0) + playmusic(musica_room); +} + +void DrasculaEngine::habla_ciego(char dicho[], char filename[], char sincronia[]) { + byte *num_cara; + int p; + int pos_ciego[6]; + int cara = 0; + + int longitud; + longitud = strlen(dicho); + + buffer_teclado(); + + color_abc(VON_BRAUN); + + for (p = 0; sincronia[p]; p++) + sincronia[p] = toupper(sincronia[p]); + + p = 0; + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + + if (hay_sb == 1) { + sku = new Common::File; + sku->open(filename); + if (!sku->isOpen()) { + error("no puedo abrir archivo de voz"); + } + ctvd_init(2); + ctvd_speaker(1); + ctvd_output(sku); + } + + pos_ciego[1] = 2; + pos_ciego[2] = 73; + pos_ciego[3] = 1; + pos_ciego[4] = 126; + pos_ciego[5] = 149; + +bucless: + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); + pos_ciego[5] = 149; + if (sincronia[p] == '0') + cara = 0; + if (sincronia[p] == '1') + cara = 1; + if (sincronia[p] == '2') + cara = 2; + if (sincronia[p] == '3') + cara = 3; + if (sincronia[p] == '4') + cara = 4; + if (sincronia[p] == '5') + cara = 5; + if (sincronia[p] == '6') + cara = 6; + if (sincronia[p] == '7') + cara = 7; + + if (cara == 0 || cara == 2 || cara == 4 || cara == 6) + pos_ciego[0] = 1; + else + pos_ciego[0] = 132; + + if (cara == 0) + num_cara = dir_dibujo3; + else if (cara == 1) + num_cara = dir_dibujo3; + else if (cara == 2) + num_cara = dir_hare_dch; + else if (cara == 3) + num_cara = dir_hare_dch; + else if (cara == 4) + num_cara = dir_hare_fondo; + else if (cara == 5) + num_cara = dir_hare_fondo; + else { + num_cara = dir_hare_frente; + pos_ciego[5] = 146; + } + + DIBUJA_BLOQUE_CUT( pos_ciego, num_cara, dir_zona_pantalla); + + if (con_voces == 0) + centra_texto(dicho, 310, 71); + + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + pausa(2); + p++; + + int key = getscan(); + if (key != 0) + ctvd_stop(); + buffer_teclado(); + if (hay_sb == 1) { + if (LookForFree() != 0) + goto bucless; + delete sku; + ctvd_terminate(); + } else { + longitud = longitud - 2; + if (longitud > 0) + goto bucless; + } +} + +void DrasculaEngine::habla_hacker(char dicho[], char filename[]) { + int tiempou; + long tiempol; + + int longitud; + longitud = strlen(dicho); + + tiempol = _system->getMillis(); + tiempou = (unsigned int)tiempol / 2; + _rnd->setSeed(tiempou); + + buffer_teclado(); + + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + + color_abc(AMARILLO); + + if (hay_sb == 1) { + sku = new Common::File; + sku->open(filename); + if (!sku->isOpen()) { + error("no puedo abrir archivo de voz"); + } + ctvd_init(2); + ctvd_speaker(1); + ctvd_output(sku); + } + +bucless: + if (con_voces == 0) + centra_texto(dicho, 156, 170); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + + int key = getscan(); + if (key!=0) + ctvd_stop(); + if (hay_sb == 1) { + if (LookForFree() != 0) + goto bucless; + delete sku; + ctvd_terminate(); + } else { + longitud = longitud - 2; + if (longitud > 0) + goto bucless; + } + + key = 0; +} + +void DrasculaEngine::anda_pabajo() { + direccion_hare = 4; + sentido_hare = 3; + paso_x = 0; +} + +void DrasculaEngine::anda_parriba() { + direccion_hare = 0; + sentido_hare = 2; + paso_x = 0; +} + +void DrasculaEngine::pon_vb() { + int pos_vb[6]; + + if (vb_se_mueve == 0) { + pos_vb[0] = 256; + pos_vb[1] = 129; + pos_vb[2] = vb_x; + pos_vb[3] = 66; + pos_vb[4] = 33; + pos_vb[5] = 69; + if (sentido_vb == 0) + pos_vb[0] = 222; + else if (sentido_vb == 1) + pos_vb[0] = 188; + } else { + pos_vb[2] = vb_x; + pos_vb[3] = 66; + pos_vb[4] = 28; + pos_vb[5] = 68; + + if (sentido_vb == 0) { + pos_vb[0] = frame_vb; + pos_vb[1] = 62; + } else { + pos_vb[0] = frame_vb; + pos_vb[1] = 131; + } + + frame_vb = frame_vb + 29; + if (frame_vb > 146) + frame_vb = 1; + } + + DIBUJA_BLOQUE_CUT(pos_vb, dir_hare_frente, dir_zona_pantalla); +} + +void DrasculaEngine::lleva_vb(int punto_x) { + if (punto_x < vb_x) + sentido_vb = 0; + else + sentido_vb = 1; + + vb_se_mueve = 1; + + for (;;) { + refresca_pantalla(); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + if (sentido_vb == 0) { + vb_x = vb_x - 5; + if (vb_x <= punto_x) + break; + } else { + vb_x = vb_x + 5; + if (vb_x >= punto_x) + break; + } + pausa(5); + } + + vb_se_mueve = 0; +} + +void DrasculaEngine::hipo_sin_nadie(int contador){ + int y = 0, sentido = 0; + contador = contador; + +comienza: + contador--; + + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); + VUELCA_PANTALLA(0, 1, 0, y, 320, 198, dir_zona_pantalla); + + if (sentido == 0) + y++; + else + y--; + if (y == 2) + sentido = 1; + if (y == 0) + sentido = 0; + if (contador > 0) + goto comienza; + + DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); +} + +void DrasculaEngine::abre_puerta(int nflag, int n_puerta) { + if (flags[nflag] == 0) { + comienza_sound("s3.als"); + flags[nflag] = 1; + if (n_puerta != NO_PUERTA) + puertas_cerradas(n_puerta); + refresca_pantalla(); + VUELCA_PANTALLA(0, 0, 0, 0, 320, 200, dir_zona_pantalla); + fin_sound(); + sin_verbo(); + } +} + +void DrasculaEngine::mapa() { + int l, veo = 0; + + for (l = 0; l < objs_room; l++) { + if (x_raton > x1[l] && y_raton > y1[l] + && x_raton < x2[l] && y_raton < y2[l] + && visible[l] == 1) { + strcpy(texto_nombre, nombre_obj[l]); + hay_nombre = 1; + veo = 1; + } + } + + if (veo == 0) + hay_nombre = 0; +} + +void DrasculaEngine::refresca_1_antes() { + int cambio_col_antes = cambio_de_color; + + if (hare_x > 98 && hare_x < 153) + cambio_de_color = 1; + else + cambio_de_color = 0; + + if (cambio_col_antes != cambio_de_color && cambio_de_color == 1) + hare_oscuro(); + if (cambio_col_antes != cambio_de_color && cambio_de_color == 0) + hare_claro(); + + if (flags[8] == 0) + DIBUJA_FONDO(2, 158, 208, 67, 27, 40, dir_dibujo3, dir_zona_pantalla); +} + +void DrasculaEngine::refresca_2(){ + int pos_murci[6]; + int diferencia; + int murci_x[] = {0,38,76,114,152,190,228,266, + 0,38,76,114,152,190,228,266, + 0,38,76,114,152,190, + 0,48,96,144,192,240, + 30,88,146,204,262, + 88,146,204,262, + 88,146,204,262}; + + int murci_y[] = {179,179,179,179,179,179,179,179, + 158,158,158,158,158,158,158,158, + 137,137,137,137,137,137, + 115,115,115,115,115,115, + 78,78,78,78,78, + 41,41,41,41, + 4,4,4,4}; + + if (frame_murcielago == 41) + frame_murcielago = 0; + + pos_murci[0] = murci_x[frame_murcielago]; + pos_murci[1] = murci_y[frame_murcielago]; + + if (frame_murcielago < 22) { + pos_murci[4] = 37; + pos_murci[5] = 21; + } else if (frame_murcielago > 27) { + pos_murci[4] = 57; + pos_murci[5] = 36; + } else { + pos_murci[4] = 47; + pos_murci[5] = 22; + } + + pos_murci[2] = 239; + pos_murci[3] = 19; + + DIBUJA_BLOQUE_CUT(pos_murci, dir_dibujo3, dir_zona_pantalla); + diferencia = vez() - conta_ciego_vez; + if (diferencia >= 6) { + frame_murcielago++; + conta_ciego_vez = vez(); + } + + DIBUJA_BLOQUE(29, 37, 58, 114, 57, 39, dir_dibujo3, dir_zona_pantalla); + mapa(); +} + +void DrasculaEngine::refresca_3_antes() { + if (flags[3] == 1) + DIBUJA_FONDO(258, 110, 85, 44, 23, 53, dir_dibujo3, dir_zona_pantalla); +} + +void DrasculaEngine::refresca_3() { + if (hare_y + alto_hare < 118) + DIBUJA_BLOQUE(129, 110, 194, 36, 126, 88, dir_dibujo3, dir_zona_pantalla); + DIBUJA_BLOQUE(47, 57, 277, 143, 43, 50, dir_dibujo3, dir_zona_pantalla); +} + +void DrasculaEngine::refresca_4() { + int cambio_col_antes = cambio_de_color; + if (hare_x > 190) + cambio_de_color = 1; + else + cambio_de_color=0; + + if (cambio_col_antes != cambio_de_color && cambio_de_color == 1) + hare_oscuro(); + if (cambio_col_antes != cambio_de_color && cambio_de_color == 0) + hare_claro(); +} + +void DrasculaEngine::refresca_5() { + DIBUJA_BLOQUE(114, 130, 211, 87, 109, 69, dir_dibujo3, dir_zona_pantalla); +} + +void DrasculaEngine::refresca_15() { + DIBUJA_BLOQUE(1, 154, 83, 122, 131, 44, dir_dibujo3, dir_zona_pantalla); +} + +void DrasculaEngine::refresca_17() { + DIBUJA_BLOQUE(48, 135, 78, 139, 80, 30, dir_dibujo3, dir_zona_pantalla); +} + +void DrasculaEngine::refresca_18() { + if (flags[24] == 1) + DIBUJA_BLOQUE(177, 1, 69, 29, 142, 130, dir_dibujo3, dir_zona_pantalla); + DIBUJA_BLOQUE(105, 132, 109, 108, 196, 65, dir_dibujo3, dir_zona_pantalla); +} + +void DrasculaEngine::refresca_5_antes(){ + if (flags[8] == 0) + DIBUJA_FONDO(256, 152, 208, 67, 27, 40, dir_dibujo3, dir_zona_pantalla); +} + +void DrasculaEngine::refresca_6_antes() { + int cambio_col_antes=cambio_de_color; + + if ((hare_x > 149 && hare_y + alto_hare > 160 && hare_x < 220 && hare_y + alto_hare < 188) || + (hare_x > 75 && hare_y + alto_hare > 183 && hare_x < 145)) + cambio_de_color = 0; + else + cambio_de_color=1; + + if (cambio_col_antes != cambio_de_color && cambio_de_color == 1) + hare_oscuro(); + if (cambio_col_antes != cambio_de_color && cambio_de_color == 0) + hare_claro(); + + if (flags[1] == 0) + DIBUJA_FONDO(97, 117, 34, 148, 36, 31, dir_dibujo3, dir_zona_pantalla); + if (flags[0] == 0) + DIBUJA_FONDO(3, 103, 185, 69, 23, 76, dir_dibujo3, dir_zona_pantalla); + if (flags[2] == 0) + DIBUJA_FONDO(28, 100, 219, 72, 64, 97, dir_dibujo3, dir_zona_pantalla); +} + +void DrasculaEngine::refresca_7_antes() { + if (flags[35] == 0) + DIBUJA_FONDO(1, 72, 158, 162, 19, 12, dir_dibujo3, dir_zona_pantalla); +} + +void DrasculaEngine::refresca_9_antes() { + int ciego_x[] = {26,68,110,152,194,236,278,26,68}; + int ciego_y[] = {51,51,51,51,51,51,51,127,127}; + int diferencia; + + DIBUJA_BLOQUE(ciego_x[frame_ciego], ciego_y[frame_ciego], 122, 57, 41, 72, dir_dibujo3, dir_zona_pantalla); + if (flags[9] == 0) { + diferencia = vez() - conta_ciego_vez; + if (diferencia >= 11) { + frame_ciego++; + conta_ciego_vez = vez(); + } + if (frame_ciego == 9) + frame_ciego = 0; + } else + frame_ciego=3; +} + +void DrasculaEngine::refresca_12_antes() { + if (flags[16] == 0) + DIBUJA_FONDO(1, 131, 106, 117, 55, 68, dir_dibujo3, dir_zona_pantalla); +} + +void DrasculaEngine::refresca_14_antes() { + int velas_y[] = {158,172,186}; + int cirio_x[] = {14,19,24}; + int pianista_x[] = {1,91,61,31,91,31,1,61,31}; + int borracho_x[] = {1,42,83,124,165,206,247,1}; + int diferencia; + + DIBUJA_FONDO(123, velas_y[frame_velas], 142, 14, 39, 13, dir_dibujo3, dir_zona_pantalla); + DIBUJA_FONDO(cirio_x[frame_velas], 146, 311, 80, 4, 8, dir_dibujo3, dir_zona_pantalla); + + if (parpadeo == 5) + DIBUJA_FONDO(1, 149, 127, 52, 9, 5, dir_dibujo3, dir_zona_pantalla); + if (hare_x > 101 && hare_x < 155) + DIBUJA_FONDO(31, 138, 178, 51, 18, 16, dir_dibujo3, dir_zona_pantalla); + if (flags[11] == 0) + DIBUJA_FONDO(pianista_x[frame_piano], 157, 245, 130, 29, 42, dir_dibujo3, dir_zona_pantalla); + else if (flags[5] == 0) + DIBUJA_FONDO(145, 139, 228, 112, 47, 60, dir_hare_dch, dir_zona_pantalla); + else + DIBUJA_FONDO(165, 140, 229, 117, 43, 59, dir_dibujo3, dir_zona_pantalla); + + if (flags[12] == 1) + DIBUJA_FONDO(borracho_x[frame_borracho], 82, 170, 50, 40, 53, dir_dibujo3, dir_zona_pantalla); + diferencia = vez() - conta_ciego_vez; + if (diferencia > 6) { + if (flags[12] == 1) { + frame_borracho++; + if (frame_borracho == 8) { + frame_borracho = 0; + flags[12] = 0; + } + } else if ((_rnd->getRandomNumber(94) == 15) && (flags[13] == 0)) + flags[12] = 1; + + frame_velas++; + if (frame_velas == 3) + frame_velas = 0; + frame_piano++; + if (frame_piano == 9) + frame_piano = 0; + parpadeo = _rnd->getRandomNumber(10); + conta_ciego_vez=vez(); + } +} + +void DrasculaEngine::refresca_16_antes() { + if (flags[17] == 0) + DIBUJA_FONDO(1, 103, 24, 72, 33, 95, dir_dibujo3, dir_zona_pantalla); + if (flags[19] == 1) + DIBUJA_FONDO(37, 151, 224, 115, 56, 47, dir_dibujo3, dir_zona_pantalla); +} + +void DrasculaEngine::refresca_17_antes() { + if (flags[15] == 1) + DIBUJA_FONDO(1, 135, 108, 65, 44, 63, dir_dibujo3, dir_zona_pantalla); +} + +void DrasculaEngine::refresca_18_antes() { + int diferencia; + int ronquido_x[] = {95,136,95,136,95,95,95,95,136,95,95,95,95,95,95,95}; + int ronquido_y[] = {18,18,56,56,94,94,94,94,94,18,18,18,18,18,18,18}; + + if (flags[21] == 0) { + DIBUJA_FONDO(1, 69, 120, 58, 56, 61, dir_dibujo3, dir_zona_pantalla); + DIBUJA_FONDO(ronquido_x[frame_ronquido], ronquido_y[frame_ronquido], 124, 59, 40, 37, dir_dibujo3, dir_zona_pantalla); + } else + pon_vb(); + + diferencia = vez() - conta_ciego_vez; + if (diferencia > 9) { + frame_ronquido++; + if (frame_ronquido == 16) + frame_ronquido = 0; + conta_ciego_vez = vez(); + } +} + + } // End of namespace Drascula diff --git a/engines/drascula/drascula.h b/engines/drascula/drascula.h index a5947d73e7..2c5e5bef0a 100644 --- a/engines/drascula/drascula.h +++ b/engines/drascula/drascula.h @@ -405,23 +405,29 @@ public: int hay_sb; int nivel_osc, musica_antes, musica_room; - char num_room[20], pantalla_disco[13]; - char datos_actuales[13]; + char num_room[20], pantalla_disco[20]; + char datos_actuales[20]; int objs_room; + char fondo_y_menu[20]; - char nombre_obj[20][13]; - char nombre_icono[7][13]; + char nombre_obj[30][20]; + char nombre_icono[14][20]; - int num_obj[20], visible[20], espuerta[20]; - int sitiobj_x[20], sitiobj_y[20], sentidobj[20]; - int objetos_que_tengo[43]; - char alapantallakeva[20][13]; - int x_alakeva[20], y_alakeva[20], sentido_alkeva[20], alapuertakeva[20]; - int x1[20], y1[20], x2[20], y2[20]; + int num_obj[40], visible[40], espuerta[40]; + int sitiobj_x[40], sitiobj_y[40], sentidobj[40]; + int objetos_que_tengo[50]; + char alapantallakeva[40][20]; + int x_alakeva[40], y_alakeva[40], sentido_alkeva[40], alapuertakeva[40]; + int x1[40], y1[40], x2[40], y2[40]; int lleva_objeto , objeto_que_lleva; int con_voces; int menu_bar, menu_scr, hay_nombre; - char texto_nombre[13]; + char texto_nombre[20]; + int frame_ciego; + int frame_ronquido; + int frame_murcielago; + int c_mirar; + int c_poder; int flags[NUM_BANDERAS]; @@ -467,17 +473,88 @@ public: int y_raton_ant; int boton_izq; int boton_dch; - int _gameMode; bool escoba(); void Negro(); + void habla_vb(char[], char[]); + void habla_vbpuerta(char dicho[], char filename[]); + void habla_ciego(char[], char[], char[]); + void habla_hacker(char[], char[]); void agarra_objeto(int); + void anda_parriba(); + void anda_pabajo(); + void pon_vb(); + void lleva_vb(int punto_x); + void hipo_sin_nadie(int contador); + void abre_puerta(int nflag, int n_puerta); + void mapa(); void buffer_teclado() { } - void animacion_1(); - bool animacion_2(); + void animacion_1_1(); + bool animacion_2_1(); + void animacion_1_2(); + void animacion_2_2(); + void animacion_3_1(); + void animacion_4_1(); + void animacion_3_2(); + void animacion_4_2(); + void animacion_7(); + void animacion_8(); + void animacion_9(); + void animacion_10(); + void animacion_11(); + void animacion_12(); + void animacion_13(); + void animacion_14(); + void animacion_15(); + void animacion_16(); + void animacion_17(); + void animacion_18(); + void animacion_19(); + void animacion_20(); + void animacion_21(); + void animacion_22(); + void animacion_23(); + void animacion_23_anexo(); + void animacion_23_anexo2(); + void animacion_24(); + void animacion_25(); + void animacion_26(); + void animacion_27(); + void animacion_28(); + void animacion_29(); + void animacion_30(); + void animacion_31(); + void animacion_32(); + void animacion_33(); + void animacion_34(); + void animacion_35(); + void animacion_36(); + + void refresca_1_antes(); + void refresca_2(); + void refresca_3(); + void refresca_3_antes(); + void refresca_4(); + void refresca_5(); + void refresca_5_antes(); + void refresca_6_antes(); + void refresca_7_antes(); + void refresca_9_antes(); + void refresca_12_antes(); + void refresca_14_antes(); + void refresca_15(); + void refresca_16_antes(); + void refresca_17_antes(); + void refresca_17(); + void refresca_18_antes(); + void refresca_18(); + void hare_oscuro(); + + void sin_verbo(); void para_cargar(char[]); - void carga_escoba(const char *); + void carga_escoba_1(const char *); + void carga_escoba_2(const char *); void borra_pantalla(); void lleva_al_hare(int, int); void mueve_cursor(); @@ -536,7 +613,7 @@ public: void paleta_hare_claro(); void paleta_hare_oscuro(); void hare_claro(); - void actualiza_datos() {} + void actualiza_datos(); void empieza_andar(); void actualiza_refresco(); void actualiza_refresco_antes(); @@ -598,8 +675,6 @@ public: void pantalla_62(int); void pantalla_63(int); void conversa(const char *); - void animacion_3(); - void animacion_4(); void print_abc_opc(const char *, int, int, int); void responde(int); void habla_borracho(const char *dicho, const char *filename); -- cgit v1.2.3 From a2aec6c753b7d2881a2460e039d5309e6120de62 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Thu, 2 Aug 2007 22:12:20 +0000 Subject: Saving works now in Lost in Time svn-id: r28418 --- engines/gob/detection.cpp | 16 ++++++++-------- engines/gob/gob.cpp | 14 ++++++++++++++ engines/gob/gob.h | 3 ++- engines/gob/saveload.h | 7 ++++++- engines/gob/saveload_v3.cpp | 23 ++++++++++++++--------- 5 files changed, 44 insertions(+), 19 deletions(-) (limited to 'engines') diff --git a/engines/gob/detection.cpp b/engines/gob/detection.cpp index b9d784c63d..7faef57cc1 100644 --- a/engines/gob/detection.cpp +++ b/engines/gob/detection.cpp @@ -52,9 +52,9 @@ static const PlainGameDescriptor gobGames[] = { {"ween", "Ween: The Prophecy"}, {"bargon", "Bargon Attack"}, {"ajworld", "A.J's World of Discovery"}, - {"lostintime", "Lost in Time"}, {"gob3", "Goblins Quest 3"}, {"gob3cd", "Goblins Quest 3 CD"}, + {"lostintime", "Lost in Time"}, {"inca2", "Inca II: Wiracocha"}, {"woodruff", "The Bizarre Adventures of Woodruff and the Schnibble"}, // {"dynasty", "The Last Dynasty"}, @@ -871,7 +871,7 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - kGameTypeGob3, + kGameTypeLostInTime, kFeaturesAdlib, "intro" }, @@ -884,7 +884,7 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - kGameTypeGob3, + kGameTypeLostInTime, kFeaturesCD, "intro" }, @@ -897,7 +897,7 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - kGameTypeGob3, + kGameTypeLostInTime, kFeaturesCD, "intro" }, @@ -910,7 +910,7 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - kGameTypeGob3, + kGameTypeLostInTime, kFeaturesCD, "intro" }, @@ -923,7 +923,7 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - kGameTypeGob3, + kGameTypeLostInTime, kFeaturesCD, "intro" }, @@ -936,7 +936,7 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - kGameTypeGob3, + kGameTypeLostInTime, kFeaturesCD, "intro" }, @@ -949,7 +949,7 @@ static const GOBGameDescription gameDescriptions[] = { kPlatformPC, Common::ADGF_NO_FLAGS }, - kGameTypeGob3, + kGameTypeLostInTime, kFeaturesCD, "intro" }, diff --git a/engines/gob/gob.cpp b/engines/gob/gob.cpp index f1bec2b8d5..40a505364d 100644 --- a/engines/gob/gob.cpp +++ b/engines/gob/gob.cpp @@ -310,6 +310,20 @@ bool GobEngine::initGameParts() { _saveLoad = new SaveLoad_v3(this, _targetName.c_str()); break; + case kGameTypeLostInTime: + _init = new Init_v3(this); + _video = new Video_v2(this); + _inter = new Inter_v3(this); + _parse = new Parse_v2(this); + _mult = new Mult_v2(this); + _draw = new Draw_v2(this); + _game = new Game_v2(this); + _map = new Map_v2(this); + _goblin = new Goblin_v3(this); + _scenery = new Scenery_v2(this); + _saveLoad = new SaveLoad_v3(this, _targetName.c_str(), 4768, 0, 50); + break; + case kGameTypeWoodruff: _init = new Init_v3(this); _video = new Video_v2(this); diff --git a/engines/gob/gob.h b/engines/gob/gob.h index 9a88571c0e..d573dc3a89 100644 --- a/engines/gob/gob.h +++ b/engines/gob/gob.h @@ -85,7 +85,8 @@ enum GameType { kGameTypeGob3, kGameTypeWoodruff, kGameTypeBargon, - kGameTypeWeen + kGameTypeWeen, + kGameTypeLostInTime }; enum Features { diff --git a/engines/gob/saveload.h b/engines/gob/saveload.h index b8c9e730dd..8868bc1a12 100644 --- a/engines/gob/saveload.h +++ b/engines/gob/saveload.h @@ -136,7 +136,8 @@ class SaveLoad_v3 : public SaveLoad_v2 { public: virtual SaveType getSaveType(const char *fileName); - SaveLoad_v3(GobEngine *vm, const char *targetName); + SaveLoad_v3(GobEngine *vm, const char *targetName, uint32 screenshotSize = 19968, + uint32 indexOffset = 40, uint32 screenshotOffset = 80); virtual ~SaveLoad_v3() {} protected: @@ -144,6 +145,10 @@ protected: bool _firstSizeGame; int8 _saveSlot; + uint32 _screenshotSize; + uint32 _indexOffset; + uint32 _screenshotOffset; + virtual uint32 getSaveGameSize(); virtual int32 getSizeGame(); diff --git a/engines/gob/saveload_v3.cpp b/engines/gob/saveload_v3.cpp index 2f143d683a..249361e222 100644 --- a/engines/gob/saveload_v3.cpp +++ b/engines/gob/saveload_v3.cpp @@ -34,9 +34,14 @@ namespace Gob { -SaveLoad_v3::SaveLoad_v3(GobEngine *vm, const char *targetName) : +SaveLoad_v3::SaveLoad_v3(GobEngine *vm, const char *targetName, + uint32 screenshotSize, uint32 indexOffset, uint32 screenshotOffset) : SaveLoad_v2(vm, targetName) { + _screenshotSize = screenshotSize; + _indexOffset = indexOffset; + _screenshotOffset = screenshotOffset; + _saveSlot = -1; _stagesCount = 3; @@ -81,7 +86,7 @@ uint32 SaveLoad_v3::getSaveGameSize() { size = 1040 + (READ_LE_UINT32(_vm->_game->_totFileData + 0x2C) * 4) * 2; if (_useScreenshots) - size += 19968; + size += _screenshotSize; return size; } @@ -126,7 +131,7 @@ int32 SaveLoad_v3::getSizeScreenshot() { in = saveMan->openForLoading(setCurSlot(i)); if (in) { delete in; - size = (i + 1) * 19968 + 80; + size = (i + 1) * _screenshotSize + _screenshotOffset; break; } } @@ -218,11 +223,11 @@ bool SaveLoad_v3::loadScreenshot(int16 dataVar, int32 size, int32 offset) { Common::SaveFileManager *saveMan = g_system->getSavefileManager(); Common::InSaveFile *in; - int slot = (offset - 80) / 19968; - int slotR = (offset - 80) % 19968; + int slot = (offset - _screenshotOffset) / _screenshotSize; + int slotR = (offset - _screenshotOffset) % _screenshotSize; _useScreenshots = true; - if ((size == 40) && (offset == 40)) { + if ((size == 40) && (offset == _indexOffset)) { char buf[40]; memset(buf, 0, 40); @@ -335,12 +340,12 @@ bool SaveLoad_v3::saveNotes(int16 dataVar, int32 size, int32 offset) { } bool SaveLoad_v3::saveScreenshot(int16 dataVar, int32 size, int32 offset) { - int slot = (offset - 80) / 19968; - int slotR = (offset - 80) % 19968; + int slot = (offset - _screenshotOffset) / _screenshotSize; + int slotR = (offset - _screenshotOffset) % _screenshotSize; _useScreenshots = true; - if ((offset < 80) && (size > 0)) { + if ((offset < _screenshotOffset) && (size > 0)) { return true; -- cgit v1.2.3 From 8ecda22a8c0d438b1134f4c1c034b791adb671fe Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Thu, 2 Aug 2007 22:23:57 +0000 Subject: Fixed some of the compiler warnings, and added a FIXME comment (and #if 0:ed) to where we're trying to modify a string constant. svn-id: r28419 --- engines/drascula/drascula.cpp | 13 ++++++++----- engines/drascula/drascula.h | 8 ++++---- 2 files changed, 12 insertions(+), 9 deletions(-) (limited to 'engines') diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp index 3cae993bab..df433e12f0 100644 --- a/engines/drascula/drascula.cpp +++ b/engines/drascula/drascula.cpp @@ -6199,7 +6199,7 @@ void DrasculaEngine::animacion_35() { salir_al_dos(3); } -void DrasculaEngine::habla_vb(char dicho[], char filename[]) { +void DrasculaEngine::habla_vb(const char *dicho, const char *filename) { int tiempou; long tiempol; @@ -6272,7 +6272,7 @@ bucless: playmusic(musica_room); } -void DrasculaEngine::habla_vbpuerta(char dicho[], char filename[]) { +void DrasculaEngine::habla_vbpuerta(const char *dicho, const char *filename) { int tiempou; long tiempol; @@ -6326,7 +6326,7 @@ bucless: playmusic(musica_room); } -void DrasculaEngine::habla_ciego(char dicho[], char filename[], char sincronia[]) { +void DrasculaEngine::habla_ciego(const char *dicho, const char *filename, const char *sincronia) { byte *num_cara; int p; int pos_ciego[6]; @@ -6339,8 +6339,11 @@ void DrasculaEngine::habla_ciego(char dicho[], char filename[], char sincronia[] color_abc(VON_BRAUN); - for (p = 0; sincronia[p]; p++) + // FIXME: We can't do this to a read-only string! +#if 0 + for (p = 0; sincronia[p]; p++) sincronia[p] = toupper(sincronia[p]); +#endif p = 0; DIBUJA_FONDO(0, 0, 0, 0, 320, 200, dir_dibujo1, dir_zona_pantalla); @@ -6430,7 +6433,7 @@ bucless: } } -void DrasculaEngine::habla_hacker(char dicho[], char filename[]) { +void DrasculaEngine::habla_hacker(const char *dicho, const char *filename) { int tiempou; long tiempol; diff --git a/engines/drascula/drascula.h b/engines/drascula/drascula.h index 2c5e5bef0a..d8e49ba930 100644 --- a/engines/drascula/drascula.h +++ b/engines/drascula/drascula.h @@ -476,10 +476,10 @@ public: bool escoba(); void Negro(); - void habla_vb(char[], char[]); - void habla_vbpuerta(char dicho[], char filename[]); - void habla_ciego(char[], char[], char[]); - void habla_hacker(char[], char[]); + void habla_vb(const char *, const char *); + void habla_vbpuerta(const char *dicho, const char *filename); + void habla_ciego(const char *, const char *, const char *); + void habla_hacker(const char *, const char *); void agarra_objeto(int); void anda_parriba(); void anda_pabajo(); -- cgit v1.2.3 From ff8fda1b800839c126cafe1b07ded7329475deb1 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 2 Aug 2007 22:27:59 +0000 Subject: Fixed some warnings svn-id: r28420 --- engines/gob/saveload.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/gob/saveload.h b/engines/gob/saveload.h index 8868bc1a12..36d53b6ebc 100644 --- a/engines/gob/saveload.h +++ b/engines/gob/saveload.h @@ -146,8 +146,8 @@ protected: int8 _saveSlot; uint32 _screenshotSize; - uint32 _indexOffset; - uint32 _screenshotOffset; + int32 _indexOffset; + int32 _screenshotOffset; virtual uint32 getSaveGameSize(); -- cgit v1.2.3 From 8b99a6508f854cd4d55e5415e8e5991dc36da75c Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Thu, 2 Aug 2007 22:36:43 +0000 Subject: Made the offsets in the construct signed as well svn-id: r28421 --- engines/gob/saveload.h | 2 +- engines/gob/saveload_v3.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/gob/saveload.h b/engines/gob/saveload.h index 36d53b6ebc..28cd458442 100644 --- a/engines/gob/saveload.h +++ b/engines/gob/saveload.h @@ -137,7 +137,7 @@ public: virtual SaveType getSaveType(const char *fileName); SaveLoad_v3(GobEngine *vm, const char *targetName, uint32 screenshotSize = 19968, - uint32 indexOffset = 40, uint32 screenshotOffset = 80); + int32 indexOffset = 40, int32 screenshotOffset = 80); virtual ~SaveLoad_v3() {} protected: diff --git a/engines/gob/saveload_v3.cpp b/engines/gob/saveload_v3.cpp index 249361e222..5e540cfdc8 100644 --- a/engines/gob/saveload_v3.cpp +++ b/engines/gob/saveload_v3.cpp @@ -35,7 +35,7 @@ namespace Gob { SaveLoad_v3::SaveLoad_v3(GobEngine *vm, const char *targetName, - uint32 screenshotSize, uint32 indexOffset, uint32 screenshotOffset) : + uint32 screenshotSize, int32 indexOffset, int32 screenshotOffset) : SaveLoad_v2(vm, targetName) { _screenshotSize = screenshotSize; -- cgit v1.2.3 From 4f86d473d07fcac858bebca51eeb0a80f244c27d Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Fri, 3 Aug 2007 07:47:34 +0000 Subject: Add German Amiga version of Waxworks. svn-id: r28429 --- engines/agos/detection_tables.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'engines') diff --git a/engines/agos/detection_tables.h b/engines/agos/detection_tables.h index d2e01958b6..acb66496d8 100644 --- a/engines/agos/detection_tables.h +++ b/engines/agos/detection_tables.h @@ -542,6 +542,32 @@ static const AGOSGameDescription gameDescriptions[] = { GF_OLD_BUNDLE | GF_CRUNCHED | GF_CRUNCHED_GAMEPC | GF_PLANAR }, + // Waxworks - German Amiga Floppy + { + { + "waxworks", + "Floppy", + + { + { "gameamiga", GAME_BASEFILE, "2938a17103de603c4c6f05e6a433b365", -1}, + { "icon.pkd", GAME_ICONFILE, "4822a91c18b1b2005ac17fc617f7dcbe", -1}, + { "menus.dat", GAME_MENUFILE, "3409eeb8ca8b46fc04da99de67573f5e", -1}, + { "start", GAME_RESTFILE, "b575b336e741dde1725edd4079d5ab67", -1}, + { "stripped.txt", GAME_STRFILE, "6faaebff2786216900061eeb978f10af", -1}, + { "tbllist", GAME_TBLFILE, "95c44bfc380770a6b6dd0dfcc69e80a0", -1}, + { "xtbllist", GAME_XTBLFILE, "6c7b3db345d46349a5226f695c03e20f", -1}, + { NULL, 0, NULL, 0} + }, + Common::DE_DEU, + Common::kPlatformAmiga, + Common::ADGF_NO_FLAGS + }, + + GType_WW, + GID_WAXWORKS, + GF_OLD_BUNDLE | GF_CRUNCHED | GF_CRUNCHED_GAMEPC | GF_PLANAR + }, + // Waxworks - English DOS Floppy Demo { { -- cgit v1.2.3 From 02103a65a271af647ff32928b331ee4291607931 Mon Sep 17 00:00:00 2001 From: Kari Salminen Date: Fri, 3 Aug 2007 14:22:20 +0000 Subject: Figured out most missing parts of the Apple IIGS sample header. Added methods for reading Apple IIGS instrument headers. svn-id: r28432 --- engines/agi/sound.cpp | 114 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 74 insertions(+), 40 deletions(-) (limited to 'engines') diff --git a/engines/agi/sound.cpp b/engines/agi/sound.cpp index ad8700bbe7..b9dabd0c89 100644 --- a/engines/agi/sound.cpp +++ b/engines/agi/sound.cpp @@ -40,26 +40,27 @@ namespace Agi { #ifdef USE_IIGS_SOUND -/** - * AGI engine sound envelope structure. - */ -struct SoundEnvelope { +struct IIgsEnvelopeSegment { uint8 bp; - uint8 incHi; - uint8 inc_lo; + uint16 inc; ///< 8b.8b fixed point, big endian? +}; + +#define ENVELOPE_SEGMENT_COUNT 8 +struct IIgsEnvelope { + IIgsEnvelopeSegment seg[ENVELOPE_SEGMENT_COUNT]; }; -struct SoundWavelist { +struct IIgsWaveInfo { uint8 top; uint8 addr; uint8 size; uint8 mode; - uint8 relHi; - uint8 relLo; + uint16 relPitch; ///< 8b.8b fixed point, big endian? }; -struct SoundInstrument { - struct SoundEnvelope env[8]; +#define MAX_WAVE_COUNT 8 +struct IIgsInstrumentHeader { + IIgsEnvelope env; uint8 relseg; uint8 priority; uint8 bendrange; @@ -68,19 +69,19 @@ struct SoundInstrument { uint8 spare; uint8 wac; uint8 wbc; - struct SoundWavelist wal[8]; - struct SoundWavelist wbl[8]; + IIgsWaveInfo wal[MAX_WAVE_COUNT]; + IIgsWaveInfo wbl[MAX_WAVE_COUNT]; }; -#define IIGS_SAMPLE_HEADER_SIZE 54 struct IIgsSampleHeader { uint16 type; uint8 pitch; ///< Logarithmic, base is 2**(1/12), unknown multiplier (Possibly in range 1040-1080) - uint8 unknown_Ofs3_Len1; + uint8 unknownByte_Ofs3; // 0x7F in Gold Rush's sound resource 60, 0 in all others. uint8 volume; ///< Current guess: Logarithmic in 6 dB steps - uint8 unknown_Ofs5_Len3[3]; - uint16 size; - uint8 unknown_Ofs10_Len44[44]; + uint8 unknownByte_Ofs5; ///< 0 in all tested samples. + uint16 instrumentSize; ///< Little endian. 44 in all tested samples. A guess. + uint16 sampleSize; ///< Little endian. Accurate in all tested samples excluding Manhunter I's sound resource 16. + IIgsInstrumentHeader instrument; }; #if 0 @@ -89,6 +90,46 @@ static int numInstruments; static uint8 *wave; #endif +bool readIIgsEnvelope(IIgsEnvelope &envelope, Common::SeekableReadStream &stream) { + for (int segNum = 0; segNum < ENVELOPE_SEGMENT_COUNT; segNum++) { + envelope.seg[segNum].bp = stream.readByte(); + envelope.seg[segNum].inc = stream.readUint16BE(); + } + return !stream.ioFailed(); +} + +bool readIIgsWaveInfo(IIgsWaveInfo &waveInfo, Common::SeekableReadStream &stream) { + waveInfo.top = stream.readByte(); + waveInfo.addr = stream.readByte(); + waveInfo.size = stream.readByte(); + waveInfo.mode = stream.readByte(); + waveInfo.relPitch = stream.readUint16BE(); + return !stream.ioFailed(); +} + +/** + * Read an Apple IIGS instrument header from the given stream. + * @param header The header to which to write the data. + * @param stream The source stream from which to read the data. + * @return True if successful, false otherwise. + */ +bool readIIgsInstrumentHeader(IIgsInstrumentHeader &header, Common::SeekableReadStream &stream) { + readIIgsEnvelope(header.env, stream); + header.relseg = stream.readByte(); + header.priority = stream.readByte(); + header.bendrange = stream.readByte(); + header.vibdepth = stream.readByte(); + header.vibspeed = stream.readByte(); + header.spare = stream.readByte(); + header.wac = stream.readByte(); + header.wbc = stream.readByte(); + for (int waveA = 0; waveA < header.wac; waveA++) // Read A wave lists + readIIgsWaveInfo(header.wal[waveA], stream); + for (int waveB = 0; waveB < header.wbc; waveB++) // Read B wave lists + readIIgsWaveInfo(header.wbl[waveB], stream); + return !stream.ioFailed(); +} + /** * Read an Apple IIGS AGI sample header from the given stream. * @param header The header to which to write the data. @@ -96,21 +137,14 @@ static uint8 *wave; * @return True if successful, false otherwise. */ bool readIIgsSampleHeader(IIgsSampleHeader &header, Common::SeekableReadStream &stream) { - // Check there's room in the stream for the header - if (stream.size() - stream.pos() >= IIGS_SAMPLE_HEADER_SIZE) { - header.type = stream.readUint16LE(); - header.pitch = stream.readByte(); - // Gold Rush's sample resource 60 (A looping sound of horse's hoof hitting - // pavement) is the only one that has 0x7F at header offset 3, all other - // samples have 0x00 there. - header.unknown_Ofs3_Len1 = stream.readByte(); - header.volume = stream.readByte(); - stream.read(header.unknown_Ofs5_Len3, 3); - header.size = stream.readUint16LE(); - stream.read(header.unknown_Ofs10_Len44, 44); - return !stream.ioFailed(); - } else // No room in the stream for the header, so failure - return false; + header.type = stream.readUint16LE(); + header.pitch = stream.readByte(); + header.unknownByte_Ofs3 = stream.readByte(); + header.volume = stream.readByte(); + header.unknownByte_Ofs5 = stream.readByte(); + header.instrumentSize = stream.readUint16LE(); + header.sampleSize = stream.readUint16LE(); + return readIIgsInstrumentHeader(header.instrument, stream); } /** @@ -136,24 +170,24 @@ Audio::AudioStream *makeIIgsSampleStream(Common::SeekableReadStream &stream, int // and that there's room for the sample data in the stream. if (readHeaderOk && header.type == AGI_SOUND_SAMPLE) { // An Apple IIGS AGI sample resource uint32 tailLen = stream.size() - stream.pos(); - if (tailLen < header.size) { // Check if there's no room for the sample data in the stream + if (tailLen < header.sampleSize) { // Check if there's no room for the sample data in the stream // Apple IIGS Manhunter I: Sound resource 16 has only 16074 bytes // of sample data although header says it should have 16384 bytes. - warning("Apple IIGS sample (%d) too short (%d bytes. Should be %d bytes). Using the part that's left", resnum, tailLen, header.size); - header.size = (uint16) tailLen; // Use the part that's left + warning("Apple IIGS sample (%d) too short (%d bytes. Should be %d bytes). Using the part that's left", resnum, tailLen, header.sampleSize); + header.sampleSize = (uint16) tailLen; // Use the part that's left } if (header.pitch > 0x7F) { // Check if the pitch is invalid warning("Apple IIGS sample (%d) has too high pitch (0x%02x)", resnum, header.pitch); header.pitch &= 0x7F; // Apple IIGS AGI probably did it this way too } // Allocate memory for the sample data and read it in - byte *sampleData = (byte *) malloc(header.size); - uint32 readBytes = stream.read(sampleData, header.size); - if (readBytes == header.size) { // Check that we got all the data we requested + byte *sampleData = (byte *) malloc(header.sampleSize); + uint32 readBytes = stream.read(sampleData, header.sampleSize); + if (readBytes == header.sampleSize) { // Check that we got all the data we requested // Make an audio stream from the mono, 8 bit, unsigned input data byte flags = Audio::Mixer::FLAG_AUTOFREE | Audio::Mixer::FLAG_UNSIGNED; int rate = (int) (1076 * pow(pow(2, 1/12.0), header.pitch)); - result = Audio::makeLinearInputStream(sampleData, header.size, rate, flags, 0, 0); + result = Audio::makeLinearInputStream(sampleData, header.sampleSize, rate, flags, 0, 0); } } -- cgit v1.2.3 From e802f067cd96d63054b4233e44db02b660557787 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Fri, 3 Aug 2007 15:18:00 +0000 Subject: Lost in Time now (kind of) shows the title and the wobble-effect is drawn svn-id: r28433 --- engines/gob/draw.cpp | 85 ++++++++++++++++++++++++++++++++++++++++++++++++ engines/gob/draw.h | 3 ++ engines/gob/gob.cpp | 3 +- engines/gob/inter.h | 2 ++ engines/gob/inter_v1.cpp | 2 +- engines/gob/inter_v2.cpp | 4 ++- engines/gob/inter_v3.cpp | 6 +++- 7 files changed, 101 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/gob/draw.cpp b/engines/gob/draw.cpp index bc5b205bd1..acf4d5765b 100644 --- a/engines/gob/draw.cpp +++ b/engines/gob/draw.cpp @@ -33,6 +33,7 @@ #include "gob/game.h" #include "gob/inter.h" #include "gob/video.h" +#include "gob/palanim.h" namespace Gob { @@ -411,4 +412,88 @@ void Draw::forceBlit(bool backwards) { 0, 0, 0); } +const int16 Draw::_wobbleTable[360] = { + 0x0000, 0x011D, 0x023B, 0x0359, 0x0476, 0x0593, 0x06B0, 0x07CC, 0x08E8, + 0x0A03, 0x0B1D, 0x0C36, 0x0D4E, 0x0E65, 0x0F7B, 0x1090, 0x11A4, 0x12B6, + 0x13C6, 0x14D6, 0x15E3, 0x16EF, 0x17F9, 0x1901, 0x1A07, 0x1B0C, 0x1C0E, + 0x1D0E, 0x1E0B, 0x1F07, 0x2000, 0x20F6, 0x21EA, 0x22DB, 0x23C9, 0x24B5, + 0x259E, 0x2684, 0x2766, 0x2846, 0x2923, 0x29FC, 0x2AD3, 0x2BA5, 0x2C75, + 0x2D41, 0x2E09, 0x2ECE, 0x2F8F, 0x304D, 0x3106, 0x31BC, 0x326E, 0x331C, + 0x33C6, 0x346C, 0x350E, 0x35AC, 0x3646, 0x36DB, 0x376C, 0x37F9, 0x3882, + 0x3906, 0x3985, 0x3A00, 0x3A77, 0x3AE9, 0x3B56, 0x3BBF, 0x3C23, 0x3C83, + 0x3CDE, 0x3D34, 0x3D85, 0x3DD1, 0x3E19, 0x3E5C, 0x3E99, 0x3ED2, 0x3F07, + 0x3F36, 0x3F60, 0x3F85, 0x3FA6, 0x3FC1, 0x3FD8, 0x3FE9, 0x3FF6, 0x3FFD, + 0x4000, 0x3FFD, 0x3FF6, 0x3FE9, 0x3FD8, 0x3FC1, 0x3FA6, 0x3F85, 0x3F60, + 0x3F36, 0x3F07, 0x3ED2, 0x3E99, 0x3E5C, 0x3E19, 0x3DD1, 0x3D85, 0x3D34, + 0x3CDE, 0x3C83, 0x3C23, 0x3BBF, 0x3B56, 0x3AE9, 0x3A77, 0x3A00, 0x3985, + 0x3906, 0x3882, 0x37F9, 0x376C, 0x36DB, 0x3646, 0x35AC, 0x350E, 0x346C, + 0x33C6, 0x331C, 0x326E, 0x31BC, 0x3106, 0x304D, 0x2F8F, 0x2ECE, 0x2E09, + 0x2D41, 0x2C75, 0x2BA5, 0x2AD3, 0x29FC, 0x2923, 0x2846, 0x2766, 0x2684, + 0x259E, 0x24B5, 0x23C9, 0x22DB, 0x21EA, 0x20F6, 0x1FFF, 0x1F07, 0x1E0B, + 0x1D0E, 0x1C0E, 0x1B0C, 0x1A07, 0x1901, 0x17F9, 0x16EF, 0x15E3, 0x14D6, + 0x13C6, 0x12B6, 0x11A4, 0x1090, 0x0F7B, 0x0E65, 0x0D4E, 0x0C36, 0x0B1D, + 0x0A03, 0x08E8, 0x07CC, 0x06B0, 0x0593, 0x0476, 0x0359, 0x023B, 0x011D + -0x0000, -0x011D, -0x023B, -0x0359, -0x0476, -0x0593, -0x06B0, -0x07CC, -0x08E8, + -0x0A03, -0x0B1D, -0x0C36, -0x0D4E, -0x0E65, -0x0F7B, -0x1090, -0x11A4, -0x12B6, + -0x13C6, -0x14D6, -0x15E3, -0x16EF, -0x17F9, -0x1901, -0x1A07, -0x1B0C, -0x1C0E, + -0x1D0E, -0x1E0B, -0x1F07, -0x2000, -0x20F6, -0x21EA, -0x22DB, -0x23C9, -0x24B5, + -0x259E, -0x2684, -0x2766, -0x2846, -0x2923, -0x29FC, -0x2AD3, -0x2BA5, -0x2C75, + -0x2D41, -0x2E09, -0x2ECE, -0x2F8F, -0x304D, -0x3106, -0x31BC, -0x326E, -0x331C, + -0x33C6, -0x346C, -0x350E, -0x35AC, -0x3646, -0x36DB, -0x376C, -0x37F9, -0x3882, + -0x3906, -0x3985, -0x3A00, -0x3A77, -0x3AE9, -0x3B56, -0x3BBF, -0x3C23, -0x3C83, + -0x3CDE, -0x3D34, -0x3D85, -0x3DD1, -0x3E19, -0x3E5C, -0x3E99, -0x3ED2, -0x3F07, + -0x3F36, -0x3F60, -0x3F85, -0x3FA6, -0x3FC1, -0x3FD8, -0x3FE9, -0x3FF6, -0x3FFD, + -0x4000, -0x3FFD, -0x3FF6, -0x3FE9, -0x3FD8, -0x3FC1, -0x3FA6, -0x3F85, -0x3F60, + -0x3F36, -0x3F07, -0x3ED2, -0x3E99, -0x3E5C, -0x3E19, -0x3DD1, -0x3D85, -0x3D34, + -0x3CDE, -0x3C83, -0x3C23, -0x3BBF, -0x3B56, -0x3AE9, -0x3A77, -0x3A00, -0x3985, + -0x3906, -0x3882, -0x37F9, -0x376C, -0x36DB, -0x3646, -0x35AC, -0x350E, -0x346C, + -0x33C6, -0x331C, -0x326E, -0x31BC, -0x3106, -0x304D, -0x2F8F, -0x2ECE, -0x2E09, + -0x2D41, -0x2C75, -0x2BA5, -0x2AD3, -0x29FC, -0x2923, -0x2846, -0x2766, -0x2684, + -0x259E, -0x24B5, -0x23C9, -0x22DB, -0x21EA, -0x20F6, -0x1FFF, -0x1F07, -0x1E0B, + -0x1D0E, -0x1C0E, -0x1B0C, -0x1A07, -0x1901, -0x17F9, -0x16EF, -0x15E3, -0x14D6, + -0x13C6, -0x12B6, -0x11A4, -0x1090, -0x0F7B, -0x0E65, -0x0D4E, -0x0C36, -0x0B1D, + -0x0A03, -0x08E8, -0x07CC, -0x06B0, -0x0593, -0x0476, -0x0359, -0x023B, -0x011D +}; + +void Draw::wobble(SurfaceDesc *surfDesc) { + int16 amplitude = 32; + uint16 curFrame = 0; + uint16 frameWobble = 0; + uint16 rowWobble = 0; + int8 *offsets = new int8[_vm->_height]; + + _vm->_palAnim->fade(_vm->_global->_pPaletteDesc, 0, -1); + + while (amplitude > 0) { + rowWobble = frameWobble; + frameWobble = (frameWobble + 20) % 360; + + for (uint16 y = 0; y < _vm->_height; y++) { + offsets[y] = amplitude + + ((_wobbleTable[rowWobble] * amplitude) / 0x4000); + + rowWobble = (rowWobble + 20) % 360; + } + + if (curFrame++ & 16) + amplitude--; + + for (uint16 y = 0; y < _vm->_height; y++) + _vm->_video->drawSprite(surfDesc, _frontSurface, + 0, y, _vm->_width - 1, y, offsets[y], y, 0); + + _vm->_palAnim->fadeStep(0); + _vm->_video->waitRetrace(); + } + + _vm->_video->drawSprite(surfDesc, _frontSurface, + 0, 0, _vm->_width - 1, _vm->_height - 1, 0, 0, 0); + + _applyPal = false; + _invalidatedCount = 0; + _noInvalidated = true; + + delete[] offsets; +} + } // End of namespace Gob diff --git a/engines/gob/draw.h b/engines/gob/draw.h index 8108a18d12..4bf59856be 100644 --- a/engines/gob/draw.h +++ b/engines/gob/draw.h @@ -153,6 +153,9 @@ public: int32 getSpriteRectSize(int16 index); void forceBlit(bool backwards = false); + static const int16 _wobbleTable[360]; + void wobble(SurfaceDesc *surfDesc); + virtual void initScreen() = 0; virtual void closeScreen() = 0; virtual void blitCursor() = 0; diff --git a/engines/gob/gob.cpp b/engines/gob/gob.cpp index 40a505364d..d9385b1b0f 100644 --- a/engines/gob/gob.cpp +++ b/engines/gob/gob.cpp @@ -136,7 +136,8 @@ void GobEngine::validateLanguage() { } void GobEngine::validateVideoMode(int16 videoMode) { - if ((videoMode != 0x13) && (videoMode != 0x14) && (videoMode != 0x18)) + if ((videoMode != 0x10) && (videoMode != 0x13) && + (videoMode != 0x14) && (videoMode != 0x18)) error("Video mode 0x%X is not supported!", videoMode); } diff --git a/engines/gob/inter.h b/engines/gob/inter.h index db56ad4cd9..a7317492ad 100644 --- a/engines/gob/inter.h +++ b/engines/gob/inter.h @@ -481,6 +481,8 @@ protected: bool o3_checkData(OpFuncParams ¶ms); bool o3_readData(OpFuncParams ¶ms); bool o3_writeData(OpFuncParams ¶ms); + + void o3_wobble(OpGobParams ¶ms); }; class Inter_v4 : public Inter_v3 { diff --git a/engines/gob/inter_v1.cpp b/engines/gob/inter_v1.cpp index 5d74138db1..9f30d9dea2 100644 --- a/engines/gob/inter_v1.cpp +++ b/engines/gob/inter_v1.cpp @@ -1617,7 +1617,7 @@ bool Inter_v1::o1_palLoad(OpFuncParams ¶ms) { _vm->_global->_pPaletteDesc->unused1 = _vm->_draw->_unusedPalette1; if (_vm->_global->_videoMode < 0x13) { - _vm->_global->_pPaletteDesc->vgaPal = _vm->_draw->_vgaSmallPalette; + _vm->_global->_pPaletteDesc->vgaPal = _vm->_draw->_vgaPalette; _vm->_palAnim->fade(_vm->_global->_pPaletteDesc, 0, 0); return false; } diff --git a/engines/gob/inter_v2.cpp b/engines/gob/inter_v2.cpp index 8cb8b706bd..476ebedddd 100644 --- a/engines/gob/inter_v2.cpp +++ b/engines/gob/inter_v2.cpp @@ -1375,10 +1375,12 @@ void Inter_v2::o2_initScreen() { width = _vm->_parse->parseValExpr(); height = _vm->_parse->parseValExpr(); + _vm->_global->_colorCount = (videoMode == 0x10) ? 16 : 256; + _vm->_global->_fakeVideoMode = videoMode; // Some versions require this - if ((videoMode == 0xD) || (videoMode == 0x10)) + if ((videoMode == 0xD))// || (videoMode == 0x10)) videoMode = _vm->_mode; if ((videoMode == _vm->_global->_videoMode) && (width == -1)) diff --git a/engines/gob/inter_v3.cpp b/engines/gob/inter_v3.cpp index 701842a9d2..51413c839a 100644 --- a/engines/gob/inter_v3.cpp +++ b/engines/gob/inter_v3.cpp @@ -594,7 +594,7 @@ void Inter_v3::setupOpcodes() { {NULL, ""}, {NULL, ""}, {NULL, ""}, - {NULL, ""}, + OPCODE(o3_wobble), /* 28 */ {NULL, ""}, {NULL, ""}, @@ -894,4 +894,8 @@ bool Inter_v3::o3_copySprite(OpFuncParams ¶ms) { return false; } +void Inter_v3::o3_wobble(OpGobParams ¶ms) { + _vm->_draw->wobble(_vm->_draw->_backSurface); +} + } // End of namespace Gob -- cgit v1.2.3 From 7ec3572ee6711965bfaf2996fed22bc1d65c7fd0 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Fri, 3 Aug 2007 16:21:39 +0000 Subject: Repaired the cursor and saving in the notebook svn-id: r28434 --- engines/gob/game_v2.cpp | 1 + engines/gob/saveload.h | 2 -- engines/gob/saveload_v3.cpp | 12 +++--------- 3 files changed, 4 insertions(+), 11 deletions(-) (limited to 'engines') diff --git a/engines/gob/game_v2.cpp b/engines/gob/game_v2.cpp index f7f7a10b92..7e87b9e8f8 100644 --- a/engines/gob/game_v2.cpp +++ b/engines/gob/game_v2.cpp @@ -101,6 +101,7 @@ void Game_v2::playTot(int16 skipPlay) { _extTable = 0; _extHandle = -1; + _vm->_draw->_cursorHotspotXVar = -1; _totToLoad[0] = 0; if ((_curTotFile[0] == 0) && (_totFileData == 0)) diff --git a/engines/gob/saveload.h b/engines/gob/saveload.h index 28cd458442..d7e45246ad 100644 --- a/engines/gob/saveload.h +++ b/engines/gob/saveload.h @@ -152,10 +152,8 @@ protected: virtual uint32 getSaveGameSize(); virtual int32 getSizeGame(); - virtual int32 getSizeNotes(); virtual int32 getSizeScreenshot(); virtual bool loadGame(int16 dataVar, int32 size, int32 offset); - virtual bool loadNotes(int16 dataVar, int32 size, int32 offset); virtual bool loadScreenshot(int16 dataVar, int32 size, int32 offset); virtual bool saveGame(int16 dataVar, int32 size, int32 offset); virtual bool saveNotes(int16 dataVar, int32 size, int32 offset); diff --git a/engines/gob/saveload_v3.cpp b/engines/gob/saveload_v3.cpp index 5e540cfdc8..d0f791d8df 100644 --- a/engines/gob/saveload_v3.cpp +++ b/engines/gob/saveload_v3.cpp @@ -73,6 +73,8 @@ SaveType SaveLoad_v3::getSaveType(const char *fileName) { return kSaveScreenshot; if (!scumm_stricmp(fileName, "intro.$$$")) return kSaveTempSprite; + if (!scumm_stricmp(fileName, "bloc.inf")) + return kSaveNotes; if (!scumm_stricmp(fileName, "prot")) return kSaveIgnore; if (!scumm_stricmp(fileName, "config")) @@ -91,10 +93,6 @@ uint32 SaveLoad_v3::getSaveGameSize() { return size; } -int32 SaveLoad_v3::getSizeNotes() { - return -1; -} - int32 SaveLoad_v3::getSizeGame() { if (_firstSizeGame) { _firstSizeGame = false; @@ -215,10 +213,6 @@ bool SaveLoad_v3::loadGame(int16 dataVar, int32 size, int32 offset) { return false; } -bool SaveLoad_v3::loadNotes(int16 dataVar, int32 size, int32 offset) { - return false; -} - bool SaveLoad_v3::loadScreenshot(int16 dataVar, int32 size, int32 offset) { Common::SaveFileManager *saveMan = g_system->getSavefileManager(); Common::InSaveFile *in; @@ -336,7 +330,7 @@ bool SaveLoad_v3::saveGame(int16 dataVar, int32 size, int32 offset) { } bool SaveLoad_v3::saveNotes(int16 dataVar, int32 size, int32 offset) { - return false; + return SaveLoad_v2::saveNotes(dataVar, size - 160, offset); } bool SaveLoad_v3::saveScreenshot(int16 dataVar, int32 size, int32 offset) { -- cgit v1.2.3 From 055e6654e55f6d8d1f53527b9397865c35d2f0bd Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Fri, 3 Aug 2007 17:51:36 +0000 Subject: Lost in Time's title is shown correctly now. The size switching looks a bit whacky, but that's what the game does :) svn-id: r28435 --- engines/gob/inter_v2.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/gob/inter_v2.cpp b/engines/gob/inter_v2.cpp index 476ebedddd..64d092b919 100644 --- a/engines/gob/inter_v2.cpp +++ b/engines/gob/inter_v2.cpp @@ -1375,12 +1375,30 @@ void Inter_v2::o2_initScreen() { width = _vm->_parse->parseValExpr(); height = _vm->_parse->parseValExpr(); - _vm->_global->_colorCount = (videoMode == 0x10) ? 16 : 256; + // Lost in Time switches to 640x400x16 when showing the title screen + if (_vm->getGameType() == kGameTypeLostInTime) { + if (videoMode == 0x10) { + width = _vm->_width = 640; + height = _vm->_height = 400; + _vm->_global->_colorCount = 16; + _vm->_system->initSize(_vm->_width, _vm->_height); + } else if (_vm->_global->_videoMode == 0x10) { + if (width == -1) + width = 320; + if (height == -1) + height = 200; + + _vm->_width = 320; + _vm->_height = 200; + _vm->_global->_colorCount = 256; + _vm->_system->initSize(_vm->_width, _vm->_height); + } + } _vm->_global->_fakeVideoMode = videoMode; // Some versions require this - if ((videoMode == 0xD))// || (videoMode == 0x10)) + if (videoMode == 0xD) videoMode = _vm->_mode; if ((videoMode == _vm->_global->_videoMode) && (width == -1)) -- cgit v1.2.3 From ff8ed07958a3c75c1cd909d4cdd2849c8b76cd14 Mon Sep 17 00:00:00 2001 From: Kari Salminen Date: Fri, 3 Aug 2007 18:20:58 +0000 Subject: Added Apple IIGS arrow cursor data. svn-id: r28436 --- engines/agi/graphics.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/agi/graphics.cpp b/engines/agi/graphics.cpp index b9e8971e13..b6430e0f81 100644 --- a/engines/agi/graphics.cpp +++ b/engines/agi/graphics.cpp @@ -911,7 +911,27 @@ static const byte sciMouseCursor[] = { }; /** - * RGBA-palette for the black and white SCI-style arrow cursor. + * A black and white Apple IIGS style arrow cursor (9x11). + * 0 = Transparent. + * 1 = Black (#000000 in 24-bit RGB). + * 2 = White (#FFFFFF in 24-bit RGB). + */ +static const byte appleIIgsMouseCursor[] = { + 2,2,0,0,0,0,0,0,0, + 2,1,2,0,0,0,0,0,0, + 2,1,1,2,0,0,0,0,0, + 2,1,1,1,2,0,0,0,0, + 2,1,1,1,1,2,0,0,0, + 2,1,1,1,1,1,2,0,0, + 2,1,1,1,1,1,1,2,0, + 2,1,1,1,1,1,1,1,2, + 2,1,1,2,1,1,2,2,0, + 2,2,2,0,2,1,1,2,0, + 0,0,0,0,0,2,2,2,0 +}; + +/** + * RGBA-palette for the black and white SCI and Apple IIGS arrow cursors. */ static const byte sciMouseCursorPalette[] = { 0x00, 0x00, 0x00, 0x00, // Black -- cgit v1.2.3 From 8b5f0624f5a6c80826fb547ac6613b21ce2e1cc7 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Fri, 3 Aug 2007 21:09:41 +0000 Subject: Make resolution change in Lost in Time less wacky. svn-id: r28437 --- engines/gob/inter_v2.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/gob/inter_v2.cpp b/engines/gob/inter_v2.cpp index 64d092b919..376aef75d9 100644 --- a/engines/gob/inter_v2.cpp +++ b/engines/gob/inter_v2.cpp @@ -1381,7 +1381,10 @@ void Inter_v2::o2_initScreen() { width = _vm->_width = 640; height = _vm->_height = 400; _vm->_global->_colorCount = 16; - _vm->_system->initSize(_vm->_width, _vm->_height); + _vm->_system->beginGFXTransaction(); + _vm->_system->initSize(_vm->_width, _vm->_height); + _vm->initCommonGFX(true); + _vm->_system->endGFXTransaction(); } else if (_vm->_global->_videoMode == 0x10) { if (width == -1) width = 320; @@ -1391,7 +1394,10 @@ void Inter_v2::o2_initScreen() { _vm->_width = 320; _vm->_height = 200; _vm->_global->_colorCount = 256; - _vm->_system->initSize(_vm->_width, _vm->_height); + _vm->_system->beginGFXTransaction(); + _vm->_system->initSize(_vm->_width, _vm->_height); + _vm->initCommonGFX(false); + _vm->_system->endGFXTransaction(); } } -- cgit v1.2.3 From feb07bb1d8f2db08dc0d06a3948bb1010132c2ce Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Sat, 4 Aug 2007 05:56:38 +0000 Subject: Fix disabling speech in FOA. svn-id: r28439 --- engines/scumm/sound.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/scumm/sound.cpp b/engines/scumm/sound.cpp index c42d9adf45..62f65c22c1 100644 --- a/engines/scumm/sound.cpp +++ b/engines/scumm/sound.cpp @@ -838,7 +838,7 @@ void Sound::soundKludge(int *list, int num) { } void Sound::talkSound(uint32 a, uint32 b, int mode, int channel) { - if (_vm->_game.version >= 6 && ConfMan.getBool("speech_mute")) + if (_vm->_game.version >= 5 && ConfMan.getBool("speech_mute")) return; if (mode == 1) { -- cgit v1.2.3 From 3447c0e264c5850b9a2fb3cf4500a984501aa59a Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Sat, 4 Aug 2007 06:18:28 +0000 Subject: Tell the user if saving a game fails. (I haven't tested the saveGameSimple() function, since I don't know when it's used.) This should fix bug #1767237 ("AGI: Saving games to non existing path"). svn-id: r28441 --- engines/agi/agi.h | 1 + engines/agi/saveload.cpp | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 9 deletions(-) (limited to 'engines') diff --git a/engines/agi/agi.h b/engines/agi/agi.h index 942c4df72e..f37b61478e 100644 --- a/engines/agi/agi.h +++ b/engines/agi/agi.h @@ -156,6 +156,7 @@ enum AGIErrors { errNoLoopsInView, errViewDataError, errNoGameList, + errIOError, errUnk = 127 }; diff --git a/engines/agi/saveload.cpp b/engines/agi/saveload.cpp index 70096bddc2..05ce80b1a3 100644 --- a/engines/agi/saveload.cpp +++ b/engines/agi/saveload.cpp @@ -55,6 +55,7 @@ int AgiEngine::saveGame(const char *fileName, const char *description) { int i; struct ImageStackElement *ptr = _imageStack; Common::OutSaveFile *out; + int result = errOK; debugC(3, kDebugLevelMain | kDebugLevelSavegame, "AgiEngine::saveGame(%s, %s)", fileName, description); if (!(out = _saveFileMan->openForSaving(fileName))) { @@ -206,14 +207,15 @@ int AgiEngine::saveGame(const char *fileName, const char *description) { out->writeSint16BE(_gfx->getAGIPalFileNum()); out->finalize(); - if (out->ioFailed()) + if (out->ioFailed()) { warning("Can't write file '%s'. (Disk full?)", fileName); - else + result = errIOError; + } else debugC(1, kDebugLevelMain | kDebugLevelSavegame, "Saved game %s in file %s", description, fileName); delete out; debugC(3, kDebugLevelMain | kDebugLevelSavegame, "Closed %s", fileName); - return errOK; + return result; } int AgiEngine::loadGame(const char *fileName, bool checkId) { @@ -751,20 +753,24 @@ int AgiEngine::saveGameDialog() { sprintf(fileName, "%s", getSavegameFilename(slot)); debugC(8, kDebugLevelMain | kDebugLevelResources, "file is [%s]", fileName); - saveGame(fileName, desc); + int result = saveGame(fileName, desc); - messageBox("Game saved."); + if (result == errOK) + messageBox("Game saved."); + else + messageBox("Error saving game."); - return errOK; + return result; } int AgiEngine::saveGameSimple() { char fileName[MAX_PATH]; sprintf(fileName, "%s", getSavegameFilename(0)); - saveGame(fileName, "Default savegame"); - - return errOK; + int result = saveGame(fileName, "Default savegame"); + if (result != errOK) + messageBox("Error saving game."); + return result; } int AgiEngine::loadGameDialog() { -- cgit v1.2.3 From 1935f5a8b3ac284a3df692e22bff2a0f808286bd Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Sat, 4 Aug 2007 09:43:28 +0000 Subject: Fixed broken implementation of Close command. svn-id: r28444 --- engines/parallaction/commands.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'engines') diff --git a/engines/parallaction/commands.cpp b/engines/parallaction/commands.cpp index f7d027ea07..dc392fde2c 100644 --- a/engines/parallaction/commands.cpp +++ b/engines/parallaction/commands.cpp @@ -274,6 +274,9 @@ void Parallaction::runCommands(CommandList& list, Zone *z) { case CMD_CLOSE: // close u->_zone->_flags |= kFlagsClosed; + if (u->_zone->u.door->_cnv) { + addJob(&jobToggleDoor, (void*)u->_zone, kPriority18 ); + } break; case CMD_ON: // on -- cgit v1.2.3 From 532a662f5a5a00389fc6523aaf018c6a3112226f Mon Sep 17 00:00:00 2001 From: Kari Salminen Date: Sat, 4 Aug 2007 12:05:32 +0000 Subject: Some Apple IIGS sound chip playing mode defines etc. svn-id: r28445 --- engines/agi/sound.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'engines') diff --git a/engines/agi/sound.cpp b/engines/agi/sound.cpp index b9dabd0c89..0182a27db7 100644 --- a/engines/agi/sound.cpp +++ b/engines/agi/sound.cpp @@ -54,6 +54,19 @@ struct IIgsWaveInfo { uint8 top; uint8 addr; uint8 size; +// Oscillator channel (Bits 4-7 of mode-byte). Simplified to use only stereo here. +#define MASK_OSC_CHANNEL (1 << 4) +#define OSC_CHANNEL_LEFT (1 << 4) +#define OSC_CHANNEL_RIGHT (0 << 4) +// Oscillator halt bit (Bit 0 of mode-byte) +#define MASK_OSC_HALT (1 << 0) +#define OSC_HALT (1 << 0) +// Oscillator mode (Bits 1 and 2 of mode-byte) +#define MASK_OSC_MODE (3 << 1) +#define OSC_MODE_LOOP (0 << 1) +#define OSC_MODE_ONESHOT (1 << 1) +#define OSC_MODE_SYNC_AM (2 << 1) +#define OSC_MODE_SWAP (3 << 1) uint8 mode; uint16 relPitch; ///< 8b.8b fixed point, big endian? }; -- cgit v1.2.3 From 44ddb2419b9d09c894bd3b2c8e1be39c87b30e67 Mon Sep 17 00:00:00 2001 From: Kari Salminen Date: Sat, 4 Aug 2007 12:16:10 +0000 Subject: Fixes compilation error C2666: 'pow' : 7 overloads have similar conversions on Windows (VS2003), Xbox (VS2003) and Xbox 360 (VS2005). Thanks to Carch for reporting the compilation problems. svn-id: r28446 --- engines/agi/sound.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/agi/sound.cpp b/engines/agi/sound.cpp index 0182a27db7..b083b77440 100644 --- a/engines/agi/sound.cpp +++ b/engines/agi/sound.cpp @@ -50,6 +50,9 @@ struct IIgsEnvelope { IIgsEnvelopeSegment seg[ENVELOPE_SEGMENT_COUNT]; }; +// 2**(1/12) i.e. the 12th root of 2 +#define SEMITONE 1.059463094359295 + struct IIgsWaveInfo { uint8 top; uint8 addr; @@ -199,7 +202,7 @@ Audio::AudioStream *makeIIgsSampleStream(Common::SeekableReadStream &stream, int if (readBytes == header.sampleSize) { // Check that we got all the data we requested // Make an audio stream from the mono, 8 bit, unsigned input data byte flags = Audio::Mixer::FLAG_AUTOFREE | Audio::Mixer::FLAG_UNSIGNED; - int rate = (int) (1076 * pow(pow(2, 1/12.0), header.pitch)); + int rate = (int) (1076 * pow(SEMITONE, header.pitch)); result = Audio::makeLinearInputStream(sampleData, header.sampleSize, rate, flags, 0, 0); } } -- cgit v1.2.3 From 44279df48e3951fe58b325c36fae276eddcb1f94 Mon Sep 17 00:00:00 2001 From: Kari Salminen Date: Sat, 4 Aug 2007 12:23:28 +0000 Subject: Fixes compilation error C2677: binary '&&' : no global operator found which takes type 'const Kyra::Opcode' (or there is no acceptable conversion) on Windows (VS2003), Xbox (VS2003) and Xbox 360 (VS2005). For some reason the compilers didn't automatically use the operator bool() in the Kyra::Opcode so now doing it explicitly. Thanks to Carch for reporting the compilation problems. svn-id: r28447 --- engines/kyra/script.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/kyra/script.cpp b/engines/kyra/script.cpp index 739e92feda..5966fa2c25 100644 --- a/engines/kyra/script.cpp +++ b/engines/kyra/script.cpp @@ -386,7 +386,7 @@ void ScriptHelper::cmd_execOpcode(ScriptState* script) { assert(script->dataPtr->opcodes); assert(opcode < script->dataPtr->opcodes->size()); - if ((*script->dataPtr->opcodes)[opcode] && *(*script->dataPtr->opcodes)[opcode]) { + if ((*script->dataPtr->opcodes)[opcode] && (bool) *(*script->dataPtr->opcodes)[opcode]) { script->retValue = (*(*script->dataPtr->opcodes)[opcode])(script); } else { script->retValue = 0; -- cgit v1.2.3 From 663e78b911a7447c25d24e5b7de820a1c790a759 Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Sat, 4 Aug 2007 18:58:50 +0000 Subject: Added routine to restore door backgrounds: this means that backgrounds for door and get zones are now handled by two different sets of routines. This fixes bugs #1765191 and #1762643 (it was actually the same bug). svn-id: r28449 --- engines/parallaction/graphics.cpp | 34 +++++++++++++++++++++++++++++++++- engines/parallaction/graphics.h | 3 ++- engines/parallaction/zone.cpp | 13 ++++++++----- 3 files changed, 43 insertions(+), 7 deletions(-) (limited to 'engines') diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp index 16b1059c28..8d45c4aaa9 100644 --- a/engines/parallaction/graphics.cpp +++ b/engines/parallaction/graphics.cpp @@ -547,10 +547,42 @@ void Gfx::backupGetBackground(GetData *data, int16 x, int16 y) { return; } +// +// restores background according to specified frame +// +void Gfx::restoreDoorBackground(StaticCnv *cnv, const Common::Rect& r, byte* background) { + + byte *t = cnv->_data0; + byte *s = background; + byte *d0 = _buffers[kBitBack] + r.left + r.top * _vm->_screenWidth; + byte *d1 = _buffers[kBit2] + r.left + r.top * _vm->_screenWidth; + + for (uint16 i = 0; i < r.height() ; i++) { + for (uint16 j = 0; j < r.width() ; j++) { + if (*t) { + *d0 = *s; + *d1 = *s; + } + + d0++; + d1++; + t++; + s++; + } + + d0 += (_vm->_screenWidth - r.width()); + d1 += (_vm->_screenWidth - r.width()); + } + + + return; +} + + // // copies a rectangular bitmap on the background // -void Gfx::restoreZoneBackground(const Common::Rect& r, byte *data) { +void Gfx::restoreGetBackground(const Common::Rect& r, byte *data) { StaticCnv cnv; diff --git a/engines/parallaction/graphics.h b/engines/parallaction/graphics.h index cb92c90547..f518bd6625 100644 --- a/engines/parallaction/graphics.h +++ b/engines/parallaction/graphics.h @@ -175,7 +175,8 @@ public: void freeStaticCnv(StaticCnv *cnv); void backupDoorBackground(DoorData *data, int16 x, int16 y); void backupGetBackground(GetData *data, int16 x, int16 y); - void restoreZoneBackground(const Common::Rect& r, byte *data); + void restoreGetBackground(const Common::Rect& r, byte *data); + void restoreDoorBackground(StaticCnv *cnv, const Common::Rect& r, byte* background); // location void setBackground(byte *background); diff --git a/engines/parallaction/zone.cpp b/engines/parallaction/zone.cpp index 73095e6f65..50f63b3b75 100644 --- a/engines/parallaction/zone.cpp +++ b/engines/parallaction/zone.cpp @@ -424,14 +424,17 @@ void jobToggleDoor(void *parm, Job *j) { StaticCnv v14; if (z->u.door->_cnv) { + Common::Rect r(z->_left, z->_top, z->_left+z->u.door->_cnv->_width, z->_top+z->u.door->_cnv->_height); + + uint16 _ax = (z->_flags & kFlagsClosed ? 1 : 0); + v14._width = z->u.door->_cnv->_width; v14._height = z->u.door->_cnv->_height; + v14._data0 = z->u.door->_cnv->getFramePtr(_ax); - Common::Rect r(z->_left, z->_top, z->_left+z->u.door->_cnv->_width, z->_top+z->u.door->_cnv->_height); - - _vm->_gfx->restoreZoneBackground(r, z->u.door->_background); + _vm->_gfx->restoreDoorBackground(&v14, r, z->u.door->_background); - uint16 _ax = (z->_flags & kFlagsClosed ? 0 : 1); + _ax = (z->_flags & kFlagsClosed ? 0 : 1); _vm->_gfx->flatBlitCnv(z->u.door->_cnv, _ax, z->_left, z->_top, Gfx::kBitBack); _vm->_gfx->flatBlitCnv(z->u.door->_cnv, _ax, z->_left, z->_top, Gfx::kBit2); @@ -469,7 +472,7 @@ void jobRemovePickedItem(void *parm, Job *j) { if (z->u.get->_cnv) { Common::Rect r(z->_left, z->_top, z->_left + z->u.get->_cnv->_width, z->_top + z->u.get->_cnv->_height); - _vm->_gfx->restoreZoneBackground(r, z->u.get->_backup); + _vm->_gfx->restoreGetBackground(r, z->u.get->_backup); } count++; -- cgit v1.2.3 From ca01e07a3ce0fe50605aaf199ec8f780198990e0 Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Sat, 4 Aug 2007 22:14:45 +0000 Subject: Fixes bug #1765310. Counter needs to be reset at the beginning of each iteration. svn-id: r28451 --- engines/parallaction/dialogue.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/parallaction/dialogue.cpp b/engines/parallaction/dialogue.cpp index 101d5955bf..84ecde6e64 100644 --- a/engines/parallaction/dialogue.cpp +++ b/engines/parallaction/dialogue.cpp @@ -236,11 +236,12 @@ uint16 DialogueManager::askPassword() { debugC(1, kDebugDialogue, "checkDialoguePassword()"); char password[100]; - uint16 passwordLen = 0; + uint16 passwordLen; while (true) { clear(); + passwordLen = 0; strcpy(password, "......."); Common::Rect r(_answerBalloonW[0], _answerBalloonH[0]); -- cgit v1.2.3 From d31d50ac3dbf5c12b126b4d26ba2cd15e7057dcc Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Sun, 5 Aug 2007 01:42:38 +0000 Subject: Possible fix for bug #1767748 (Gobliiins is not fast as it can be on slow computers) svn-id: r28456 --- engines/gob/game_v1.cpp | 3 ++- engines/gob/video.cpp | 10 ++++++---- engines/gob/video.h | 1 + 3 files changed, 9 insertions(+), 5 deletions(-) (limited to 'engines') diff --git a/engines/gob/game_v1.cpp b/engines/gob/game_v1.cpp index 6ba68553c7..9c18ec1151 100644 --- a/engines/gob/game_v1.cpp +++ b/engines/gob/game_v1.cpp @@ -911,7 +911,8 @@ void Game_v1::collisionsBlock(void) { _shouldPushColls = 0; _vm->_global->_inter_execPtr = savedIP; deltaTime = timeVal - - (_vm->_util->getTimeKey() - timeKey); + ((_vm->_util->getTimeKey() - timeKey) + - _vm->_video->_lastRetraceLength); if (deltaTime < 2) deltaTime = 2; diff --git a/engines/gob/video.cpp b/engines/gob/video.cpp index 83cd436b8a..0dc15a8657 100644 --- a/engines/gob/video.cpp +++ b/engines/gob/video.cpp @@ -94,6 +94,7 @@ Video::Video(GobEngine *vm) : _vm(vm) { _splitHeight1 = 200; _splitHeight2 = 0; _splitStart = 0; + _lastRetraceLength = 0; _curSparse = 0; _lastSparse = 0xFFFFFFFF; @@ -161,6 +162,8 @@ SurfaceDesc *Video::initSurfDesc(int16 vidMode, int16 width, int16 height, } void Video::retrace(bool mouse) { + uint32 time = _vm->_util->getTimeKey(); + if (mouse) CursorMan.showMouse((_vm->_draw->_showCursor & 2) != 0); if (_vm->_global->_primarySurfDesc) { @@ -173,14 +176,13 @@ void Video::retrace(bool mouse) { _vm->_height - _splitHeight2, _vm->_width, _splitHeight2); g_system->updateScreen(); } + + _lastRetraceLength = _vm->_util->getTimeKey() - time; } void Video::waitRetrace(bool mouse) { - uint32 time; - - time = _vm->_util->getTimeKey(); retrace(mouse); - _vm->_util->delay(MAX(1, 10 - (int)(_vm->_util->getTimeKey() - time))); + _vm->_util->delay(MAX(1, 10 - (int) _lastRetraceLength)); } void Video::sparseRetrace(int max) { diff --git a/engines/gob/video.h b/engines/gob/video.h index 51d02bd219..dc23bda81e 100644 --- a/engines/gob/video.h +++ b/engines/gob/video.h @@ -104,6 +104,7 @@ public: int16 _splitHeight1; int16 _splitHeight2; int16 _splitStart; + uint32 _lastRetraceLength; void freeDriver(); void initPrimary(int16 mode); -- cgit v1.2.3 From d03e3e9c870a7d0d28c6e43ee3f0fe0af2a4847d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 5 Aug 2007 02:56:51 +0000 Subject: Added code for hotspot fields I didn't originally understand svn-id: r28457 --- engines/lure/hotspots.cpp | 87 ++++++++++++++++++++++++++++++--------------- engines/lure/hotspots.h | 7 ++++ engines/lure/res_struct.cpp | 15 ++------ engines/lure/res_struct.h | 10 +----- 4 files changed, 70 insertions(+), 49 deletions(-) (limited to 'engines') diff --git a/engines/lure/hotspots.cpp b/engines/lure/hotspots.cpp index 82b4725a70..b4ade06bd4 100644 --- a/engines/lure/hotspots.cpp +++ b/engines/lure/hotspots.cpp @@ -689,7 +689,6 @@ void Hotspot::converse(uint16 destCharacterId, uint16 messageId, bool standStill if (standStill) { setDelayCtr(_data->talkCountdown); _data->characterMode = CHARMODE_CONVERSING; - //TODO: HS[3Eh]=character_hotspot_id, HS[40h]=active_hotspot_id } } @@ -1332,7 +1331,10 @@ void Hotspot::doUse(HotspotData *hotspot) { faceHotspot(hotspot); endAction(); - // TODO: If character=3E9h, HS[-1]=28h, HS[1Fh]=50h + if (hotspotId() == RATPOUCH_ID) { + _tempDest.position.x = 40; + setFrameCtr(80); + } uint16 sequenceOffset = res.getHotspotAction(hotspot->actionsOffset, USE); @@ -1727,7 +1729,6 @@ void Hotspot::doBribe(HotspotData *hotspot) { ++tempId; // Move over entry's sequence offset } - // TODO: call to talk_setup faceHotspot(hotspot); setActionCtr(0); endAction(); @@ -1738,8 +1739,8 @@ void Hotspot::doBribe(HotspotData *hotspot) { if (sequenceOffset != 0) return; } - // TODO: talk_record_index - showMessage(sequenceOffset); + uint16 talkIndex = res.fieldList().getField(TALK_INDEX); + showMessage((talkIndex == 6) ? 0x30 : 0x29); } void Hotspot::doExamine(HotspotData *hotspot) { @@ -1811,7 +1812,7 @@ void Hotspot::npcHeySir(HotspotData *hotspot) { return; } - // TODO: Check storage of hotspot Id in data_1090/data_1091=0 + // TODO: Check storage of hotspot Id in talk_first=player/talk_second=0 // Get the npc to say "Hey Sir" to player showMessage(0x22, PLAYER_ID); @@ -2059,6 +2060,9 @@ void Hotspot::saveToStream(Common::WriteStream *stream) { stream->writeSint16LE(_destX); stream->writeSint16LE(_destY); stream->writeUint16LE(_destHotspotId); + stream->writeByte(_tempDest.counter); + stream->writeSint16LE(_tempDest.position.x); + stream->writeSint16LE(_tempDest.position.y); stream->writeUint16LE(_frameWidth); stream->writeUint16LE(_height); stream->writeUint16LE(_width); @@ -2096,6 +2100,9 @@ void Hotspot::loadFromStream(Common::ReadStream *stream) { _destX = stream->readSint16LE(); _destY = stream->readSint16LE(); _destHotspotId = stream->readUint16LE(); + _tempDest.counter = stream->readByte(); + _tempDest.position.x = stream->readSint16LE(); + _tempDest.position.y = stream->readSint16LE(); _frameWidth = stream->readUint16LE(); _height = stream->readUint16LE(); _width = stream->readUint16LE(); @@ -2227,6 +2234,7 @@ void HotspotTickHandlers::standardCharacterAnimHandler(Hotspot &h) { RoomPathsData &paths = Resources::getReference().getRoom(h.roomNumber())->paths; PathFinder &pathFinder = h.pathFinder(); CurrentActionStack &actions = h.currentActions(); + Hotspot *player = res.getActiveHotspot(PLAYER_ID); uint16 impingingList[MAX_NUM_IMPINGING]; int numImpinging; bool bumpedPlayer; @@ -2276,8 +2284,6 @@ void HotspotTickHandlers::standardCharacterAnimHandler(Hotspot &h) { if (numImpinging > 0) { // Scan to check if the character has bumped into player - Hotspot *player = res.getActiveHotspot(PLAYER_ID); - if (bumpedPlayer && (player->characterMode() == CHARMODE_IDLE)) { // Signal the player to move out of the way automatically player->setBlockedState(BS_INITIAL); @@ -2300,8 +2306,12 @@ void HotspotTickHandlers::standardCharacterAnimHandler(Hotspot &h) { h.setSkipFlag(false); } - // TODO: Handling of any set Tick Script Offset, as well as certain other - // as of yet unknown hotspot flags + if (h.resource()->scriptHotspotId != 0) { + // Character bumped against another + fields.setField(USE_HOTSPOT_ID, h.resource()->scriptHotspotId); + Script::execute(h.resource()->tickScriptOffset); + h.resource()->scriptHotspotId = 0; + } debugC(ERROR_DETAILED, kLureDebugAnimations, "Hotspot standard character point 4"); if (h.pauseCtr() != 0) { @@ -2332,13 +2342,14 @@ void HotspotTickHandlers::standardCharacterAnimHandler(Hotspot &h) { // All other character modes if (h.delayCtr() > 0) { // There is some countdown left to do - bool decrementFlag = true; + h.updateMovement(); - if (!decrementFlag) { - HotspotData *hotspot = res.getHotspot(0); // TODO: HS[50h] - decrementFlag = (hotspot->roomNumber != h.roomNumber()) ? false : + bool decrementFlag = (h.resource()->actionHotspotId != 0); + if (decrementFlag) { + HotspotData *hotspot = res.getHotspot(h.resource()->actionHotspotId); + decrementFlag = (hotspot->roomNumber != h.hotspotId()) ? false : Support::charactersIntersecting(hotspot, h.resource()); - } + } if (decrementFlag) { h.setDelayCtr(h.delayCtr() - 1); @@ -2353,12 +2364,20 @@ void HotspotTickHandlers::standardCharacterAnimHandler(Hotspot &h) { h.pathFinder().clear(); if ((currentMode == CHARMODE_WAIT_FOR_PLAYER) || (currentMode == CHARMODE_WAIT_FOR_INTERACT)) { - // TODO: HS[33h]=0 + h.resource()->talkOverride = 0; h.showMessage(1); } return; } + /* interactHotspotId never seems to be set + if ((h.resource()->interactHotspotId != 0) && !player->currentActions().isEmpty()) { + h.setActionCtr(99); + if (!actions.isEmpty()) + actions.top().setAction(DISPATCH_ACTION); + } + */ + debugC(ERROR_DETAILED, kLureDebugAnimations, "Hotspot standard character point 6"); CurrentAction action = actions.action(); PathFinderResult pfResult; @@ -2567,7 +2586,9 @@ void HotspotTickHandlers::puzzledAnimHandler(Hotspot &h) { } void HotspotTickHandlers::roomExitAnimHandler(Hotspot &h) { - RoomExitJoinData *rec = Resources::getReference().getExitJoin(h.hotspotId()); + Resources &res = Resources::getReference(); + ValueTableData &fields = res.fieldList(); + RoomExitJoinData *rec = res.getExitJoin(h.hotspotId()); if (!rec) return; byte *currentFrame, *destFrame; @@ -2637,7 +2658,17 @@ void HotspotTickHandlers::playerAnimHandler(Hotspot &h) { return; h.setSkipFlag(false); } - // TODO: HS[58h] check + + /* interactHotspotId never seems to be set + if (h.resource()->interactHotspotId != 0) { + h.resource()->interactHotspotId = 0; + Hotspot *hotspot = res.getActiveHotspot(h.resource()->interactHotspotId); + assert(hotspot); + if ((hotspot->characterMode() != CHARMODE_WAIT_FOR_INTERACT) && + !actions.isEmpty()) + actions.top().setAction(ACTION_NONE); + } + */ if (h.pauseCtr() > 0) { debugC(ERROR_DETAILED, kLureDebugAnimations, "Pause countdown = %d", h.pauseCtr()); @@ -2668,10 +2699,10 @@ void HotspotTickHandlers::playerAnimHandler(Hotspot &h) { debugC(ERROR_DETAILED, kLureDebugAnimations, "Character mode = %d", h.characterMode()); h.setOccupied(false); h.setCharacterMode(CHARMODE_NONE); - if (fields.playerPendingPos().isSet) { + if (h.tempDest().counter != 0) { // Start walking to the previously set destination - fields.playerPendingPos().isSet = false; - h.setDestPosition(fields.playerPendingPos().pos.x, fields.playerPendingPos().pos.y); + h.tempDest().counter = 0; + h.setDestPosition(h.tempDest().position.x, h.tempDest().position.y); h.currentActions().addFront(START_WALKING, h.roomNumber()); h.setWalkFlag(false); } @@ -2753,9 +2784,9 @@ void HotspotTickHandlers::playerAnimHandler(Hotspot &h) { return; } else if (h.blockedState() != BS_NONE) { - fields.playerPendingPos().pos.x = h.destX(); - fields.playerPendingPos().pos.y = h.destY(); - fields.playerPendingPos().isSet = true; + h.tempDest().position.x = h.destX(); + h.tempDest().position.y = h.destY(); + h.tempDest().counter = 1; h.setBlockedState((BlockedState) ((int) h.blockedState() + 1)); h.setRandomDest(); return; @@ -2795,7 +2826,7 @@ void HotspotTickHandlers::playerAnimHandler(Hotspot &h) { // Walking done if (room.cursorState() == CS_BUMPED) room.setCursorState(CS_NONE); - if (fields.playerPendingPos().isSet) { + if (h.tempDest().counter != 0) { h.setCharacterMode(CHARMODE_PLAYER_WAIT); h.setDelayCtr(IDLE_COUNTDOWN_SIZE); return; @@ -4474,9 +4505,9 @@ void Support::characterChangeRoom(Hotspot &h, uint16 roomNumber, // TODO: Double-check.. is it impinging in leaving room (right now) or entering room if (checkForIntersectingCharacter(h)) { - fields.playerPendingPos().pos.x = h.destX(); - fields.playerPendingPos().pos.y = h.destY(); - fields.playerPendingPos().isSet = true; + h.tempDest().position.x = h.destX(); + h.tempDest().position.y = h.destY(); + h.tempDest().counter = 1; Room::getReference().setCursorState(CS_BUMPED); h.setActionCtr(0); h.setBlockedState((BlockedState) ((int) h.blockedState() + 1)); diff --git a/engines/lure/hotspots.h b/engines/lure/hotspots.h index 3f8bc544f6..fb3bb1478b 100644 --- a/engines/lure/hotspots.h +++ b/engines/lure/hotspots.h @@ -243,6 +243,11 @@ enum HotspotPrecheckResult {PC_EXECUTE, PC_NOT_IN_ROOM, PC_FAILED, PC_WAIT, PC_E enum BarPlaceResult {BP_KEEP_TRYING, BP_GOT_THERE, BP_FAIL}; +struct DestStructure { + uint8 counter; + Point position; +}; + #define MAX_NUM_FRAMES 16 class Hotspot { @@ -277,6 +282,7 @@ private: bool _frameStartsUsed; uint16 _frameStarts[MAX_NUM_FRAMES]; char _nameBuffer[MAX_HOTSPOT_NAME_SIZE]; + DestStructure _tempDest; // Runtime fields uint16 _frameCtr; @@ -516,6 +522,7 @@ public: void doAction(Action action, HotspotData *hotspot); CurrentActionStack ¤tActions() { return _currentActions; } PathFinder &pathFinder() { return _pathFinder; } + DestStructure &tempDest() { return _tempDest; } uint16 frameCtr() { return _frameCtr; } void setFrameCtr(uint16 value) { _frameCtr = value; } void decrFrameCtr() { if (_frameCtr > 0) --_frameCtr; } diff --git a/engines/lure/res_struct.cpp b/engines/lure/res_struct.cpp index 79bf0dfe6e..12cf61a58a 100644 --- a/engines/lure/res_struct.cpp +++ b/engines/lure/res_struct.cpp @@ -466,7 +466,7 @@ void HotspotData::saveToStream(WriteStream *stream) { stream->writeUint16LE(talkCountdown); stream->writeUint16LE(pauseCtr); stream->writeUint16LE(useHotspotId); - stream->writeUint16LE(use2HotspotId); + stream->writeUint16LE(scriptHotspotId); stream->writeUint16LE(talkGate); stream->writeUint16LE(actionHotspotId); stream->writeUint16LE(talkOverride); @@ -507,7 +507,7 @@ void HotspotData::loadFromStream(ReadStream *stream) { talkCountdown = stream->readUint16LE(); pauseCtr = stream->readUint16LE(); useHotspotId = stream->readUint16LE(); - use2HotspotId = stream->readUint16LE(); + scriptHotspotId = stream->readUint16LE(); talkGate = stream->readUint16LE(); actionHotspotId = stream->readUint16LE(); talkOverride = stream->readUint16LE(); @@ -1119,7 +1119,7 @@ int PausedCharacterList::check(uint16 charId, int numImpinging, uint16 *impingin if ((charHotspot->characterMode() == CHARMODE_PAUSED) || ((charHotspot->pauseCtr() == 0) && (charHotspot->characterMode() == CHARMODE_NONE))) { - hotspot->resource()->use2HotspotId = charId; + hotspot->resource()->scriptHotspotId = charId; } hotspot->setPauseCtr(IDLE_COUNTDOWN_SIZE); @@ -1206,9 +1206,6 @@ ValueTableData::ValueTableData() { _playerNewPos.roomNumber = 0; _playerNewPos.position.x = 0; _playerNewPos.position.y = 0; - _playerPendingPos.pos.x = 0; - _playerPendingPos.pos.y = 0; - _playerPendingPos.isSet = false; _flags = GAMEFLAG_4 | GAMEFLAG_1; _hdrFlagMask = 1; @@ -1252,9 +1249,6 @@ void ValueTableData::saveToStream(Common::WriteStream *stream) stream->writeSint16LE(_playerNewPos.position.x); stream->writeSint16LE(_playerNewPos.position.y); stream->writeUint16LE(_playerNewPos.roomNumber); - stream->writeByte(_playerPendingPos.isSet); - stream->writeSint16LE(_playerPendingPos.pos.x); - stream->writeSint16LE(_playerPendingPos.pos.y); stream->writeByte(_flags); stream->writeByte(_hdrFlagMask); @@ -1270,9 +1264,6 @@ void ValueTableData::loadFromStream(Common::ReadStream *stream) _playerNewPos.position.x = stream->readSint16LE(); _playerNewPos.position.y = stream->readSint16LE(); _playerNewPos.roomNumber = stream->readUint16LE(); - _playerPendingPos.isSet = stream->readByte() != 0; - _playerPendingPos.pos.x = stream->readSint16LE(); - _playerPendingPos.pos.y = stream->readSint16LE(); _flags = stream->readByte(); _hdrFlagMask = stream->readByte(); diff --git a/engines/lure/res_struct.h b/engines/lure/res_struct.h index b5e4aef724..4d2c55e6b1 100644 --- a/engines/lure/res_struct.h +++ b/engines/lure/res_struct.h @@ -458,8 +458,7 @@ public: uint16 talkGate; uint16 actionHotspotId; uint16 talkOverride; - - uint16 use2HotspotId; + uint16 scriptHotspotId; void enable() { flags |= 0x80; } void disable() { flags &= 0x7F; } @@ -817,16 +816,10 @@ struct PlayerNewPosition { uint16 roomNumber; }; -struct PlayerPendingPosition { - Point pos; - bool isSet; -}; - class ValueTableData { private: uint16 _numGroats; PlayerNewPosition _playerNewPos; - PlayerPendingPosition _playerPendingPos; uint8 _flags; uint8 _hdrFlagMask; @@ -845,7 +838,6 @@ public: uint8 &flags() { return _flags; } uint8 &hdrFlagMask() { return _hdrFlagMask; } PlayerNewPosition &playerNewPos() { return _playerNewPos; } - PlayerPendingPosition &playerPendingPos() { return _playerPendingPos; } void saveToStream(Common::WriteStream *stream); void loadFromStream(Common::ReadStream *stream); -- cgit v1.2.3 From ec1803f838d5efc7decf75c05a1fb4a9633751e5 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 5 Aug 2007 03:26:00 +0000 Subject: Removed unused fields svn-id: r28458 --- engines/lure/hotspots.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/lure/hotspots.cpp b/engines/lure/hotspots.cpp index b4ade06bd4..7def0be9ab 100644 --- a/engines/lure/hotspots.cpp +++ b/engines/lure/hotspots.cpp @@ -2587,7 +2587,7 @@ void HotspotTickHandlers::puzzledAnimHandler(Hotspot &h) { void HotspotTickHandlers::roomExitAnimHandler(Hotspot &h) { Resources &res = Resources::getReference(); - ValueTableData &fields = res.fieldList(); +// ValueTableData &fields = res.fieldList(); RoomExitJoinData *rec = res.getExitJoin(h.hotspotId()); if (!rec) return; byte *currentFrame, *destFrame; @@ -2628,7 +2628,6 @@ void HotspotTickHandlers::playerAnimHandler(Hotspot &h) { RoomPathsData &paths = Resources::getReference().getRoom(h.roomNumber())->paths; PathFinder &pathFinder = h.pathFinder(); CurrentActionStack &actions = h.currentActions(); - ValueTableData &fields = res.fieldList(); uint16 impingingList[MAX_NUM_IMPINGING]; int numImpinging; Action hsAction; -- cgit v1.2.3