From c8665d06bc59b695cb6c444b1e3c24104b69dec4 Mon Sep 17 00:00:00 2001 From: athrxx Date: Thu, 16 Jun 2011 18:51:47 +0200 Subject: KYRA: (EOB) - fix some warnings and add some menu code --- engines/kyra/chargen.cpp | 6 +++--- engines/kyra/eob2.cpp | 1 + engines/kyra/eobcommon.cpp | 26 +++++++++++++++++--------- engines/kyra/eobcommon.h | 12 ++++++++---- engines/kyra/gui_eob.cpp | 30 ++++++++++++++++++++++++++---- engines/kyra/gui_eob.h | 3 ++- engines/kyra/items_eob.cpp | 4 ++-- engines/kyra/loleobbase.cpp | 2 +- engines/kyra/loleobbase.h | 1 + engines/kyra/magic_eob.cpp | 3 ++- engines/kyra/scene_eob.cpp | 10 +++++----- engines/kyra/screen_eob.cpp | 3 +-- engines/kyra/sequences_eob1.cpp | 3 +-- engines/kyra/sequences_eob2.cpp | 4 +--- engines/kyra/sprites_eob.cpp | 10 +++++----- 15 files changed, 76 insertions(+), 42 deletions(-) (limited to 'engines/kyra') diff --git a/engines/kyra/chargen.cpp b/engines/kyra/chargen.cpp index 59b46b5043..17ee920127 100644 --- a/engines/kyra/chargen.cpp +++ b/engines/kyra/chargen.cpp @@ -1028,11 +1028,11 @@ int CharacterGenerator::modifyStat(int index, int8 *stat1, int8 *stat2) { v1++; } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_UP] || inputFlag == _vm->_keyMap[Common::KEYCODE_KP8]) { - ci = --ci % 7; + ci = (ci - 1) % 7; loop = false; } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_DOWN] || inputFlag == _vm->_keyMap[Common::KEYCODE_KP2]) { - ci = ++ci % 7; + ci = (ci + 1) % 7; loop = false; } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_o] || inputFlag == _vm->_keyMap[Common::KEYCODE_KP5] || inputFlag == _vm->_keyMap[Common::KEYCODE_ESCAPE] || inputFlag == 0x800A) { @@ -1107,7 +1107,7 @@ int CharacterGenerator::modifyStat(int index, int8 *stat1, int8 *stat2) { } } - if (loop = false) { + if (loop == false) { statStr = index ? Common::String::format("%d", *s1) : _vm->getCharStrength(*s1, *s2); _screen->printText(statStr.c_str(), b->x + 32, b->y, 15, 0); _screen->updateScreen(); diff --git a/engines/kyra/eob2.cpp b/engines/kyra/eob2.cpp index 5af5049025..45df528c75 100644 --- a/engines/kyra/eob2.cpp +++ b/engines/kyra/eob2.cpp @@ -200,6 +200,7 @@ void DarkMoonEngine::generateMonsterPalettes(const char *file, int16 monsterInde c += 6; c = (c << 1) + (ii - 1); + assert(c < 24); memcpy(_monsterPalettes[c], tmpPal, 16); } } diff --git a/engines/kyra/eobcommon.cpp b/engines/kyra/eobcommon.cpp index d40620c7ae..b7f31702dd 100644 --- a/engines/kyra/eobcommon.cpp +++ b/engines/kyra/eobcommon.cpp @@ -40,13 +40,14 @@ EobCoreEngine::EobCoreEngine(OSystem *system, const GameFlags &flags) : LolEobBa _teleporterWallId(flags.gameID == GI_EOB1 ? 52 : 44) { _screen = 0; _gui = 0; - +TTTTT=false; //_runLoopUnk2 = 0; //_runLoopTimerUnk = 0; _playFinale = false; _runFlag = true; _saveLoadMode = 0; _updateHandItemCursor = false; + _configMouse = true; _largeItemShapes = _smallItemShapes = _thrownItemShapes = _spellShapes = _firebeamShapes = _itemIconShapes = _wallOfForceShapes = _teleporterShapes = _sparkShapes = _compassShapes = 0; @@ -54,6 +55,8 @@ EobCoreEngine::EobCoreEngine(OSystem *system, const GameFlags &flags) : LolEobBa _weaponSlotGrid = _blackBoxWideGrid = _lightningColumnShape = 0; _tempIconShape = 0; + _menuStringsPrefsTemp = 0; + _monsterDustStrings = 0; _monsterDistAttType10 = 0; _monsterDistAttSfx10 = 0; @@ -105,7 +108,7 @@ EobCoreEngine::EobCoreEngine(OSystem *system, const GameFlags &flags) : LolEobBa _exchangeCharacterId = -1; _charExchangeSwap = 0; - _hpBarGraphs = true; + _configHpBarGraphs = true; memset(_dialogueLastBitmap, 0, 13); _dlgUnk1 = 0; @@ -140,6 +143,12 @@ EobCoreEngine::~EobCoreEngine() { releaseItemsAndDecorationsShapes(); releaseTempData(); + if (_menuStringsPrefsTemp) { + for (int i = 0; i < 4; i++) + delete _menuStringsPrefsTemp[i]; + delete[] _menuStringsPrefsTemp; + } + if (_faceShapes) { for (int i = 0; i < 44; i++) { if (_characters) { @@ -259,6 +268,9 @@ Common::Error EobCoreEngine::init() { initStaticResource(); initSpells(); + _menuStringsPrefsTemp = new char*[4]; + memset(_menuStringsPrefsTemp, 0, 4 * sizeof(char*)); + _timer = new TimerManager(this, _system); assert(_timer); setupTimers(); @@ -373,17 +385,13 @@ Common::Error EobCoreEngine::go() { void EobCoreEngine::runLoop() { _envAudioTimer = _system->getMillis() + (rollDice(1, 10, 3) * 18 * _tickLength); - /// - // startupSub1 - // - // + _updateFlags = 0; - //_unkCharacterId = 0; + _updateCharNum = 0; _flashShapeTimer = 0; _drawSceneTimer = _system->getMillis(); - //_unkBBBBBBBBBBBBBBBB = 1; + //__unkB__ = 1; gui_setPlayFieldButtons(); - // _screen->_curPage = 0; gui_drawPlayField(0); diff --git a/engines/kyra/eobcommon.h b/engines/kyra/eobcommon.h index 9ead3c2408..5e34dc3791 100644 --- a/engines/kyra/eobcommon.h +++ b/engines/kyra/eobcommon.h @@ -71,8 +71,8 @@ struct EobChargenButtonDef { }; struct EobGuiButtonDef { - uint8 keyCode; - uint8 keyCode2; + uint16 keyCode; + uint16 keyCode2; uint16 flags; uint16 x; uint8 y; @@ -547,7 +547,7 @@ protected: virtual void loadDoorShapes(int doorType1, int shapeId1, int doorType2, int shapeId2) {} virtual const uint8 *loadDoorShapes(const char *filename, int doorIndex, const uint8*shapeDefs) { return (const uint8*)filename; } - void drawScene(int update); + void drawScene(int refresh); void drawSceneShapes(int start = 0); void drawDecorations(int index); @@ -707,7 +707,7 @@ protected: const uint8 *_inventorySlotsY; const uint8 **_compassShapes; uint8 _charExchangeSwap; - bool _hpBarGraphs; + bool _configHpBarGraphs; // text void setupDialogueButtons(int presetfirst, int numStr, const char *str1, ...); @@ -957,6 +957,10 @@ protected: const uint8 *_magicFlightObjectProperties; // Menu + char **_menuStringsPrefsTemp; + + bool _configMouse; + const char *const *_menuStringsMain; const char *const *_menuStringsSaveLoad; const char *const *_menuStringsOnOff; diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index 02af458d65..56c5acd3df 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -456,7 +456,7 @@ void EobCoreEngine::gui_drawHitpoints(int index) { EobCharacter *c = &_characters[index]; - if (_hpBarGraphs) { + if (_configHpBarGraphs) { int bgCur = c->hitPointsCur + 10; int bgMax = c->hitPointsMax + 10; int col = ((bgMax / 3) > bgCur) ? 1 : 0; @@ -849,10 +849,32 @@ int EobCoreEngine::clickedCamp(Button *button) { _screen->copyRegion(0, 120, 0, 0, 176, 24, 0, 14, Screen::CR_NO_P_CHECK); Screen::FontId of = _screen->setFont(Screen::FID_8_FNT); + for (int i = 0; i < 4; i++) { + delete _menuStringsPrefsTemp[i]; + _menuStringsPrefsTemp[i] = new char[strlen(_menuStringsPrefs[i]) + 8]; + } + Common::strlcpy(_menuStringsPrefsTemp[0], Common::String::format(_menuStringsPrefs[0], _menuStringsOnOff[_configMusic ? 0 : 1]).c_str(), strlen(_menuStringsPrefs[0]) + 8); + Common::strlcpy(_menuStringsPrefsTemp[1], Common::String::format(_menuStringsPrefs[1], _menuStringsOnOff[_configSounds ? 0 : 1]).c_str(), strlen(_menuStringsPrefs[1]) + 8); + Common::strlcpy(_menuStringsPrefsTemp[2], Common::String::format(_menuStringsPrefs[2], _menuStringsOnOff[_configHpBarGraphs ? 0 : 1]).c_str(), strlen(_menuStringsPrefs[2]) + 8); + Common::strlcpy(_menuStringsPrefsTemp[3], Common::String::format(_menuStringsPrefs[3], _menuStringsOnOff[_configMouse ? 0 : 1]).c_str(), strlen(_menuStringsPrefs[3]) + 8); + _screen->setFont(of); - _screen->setCurPage(0); + _screen->copyRegion(0, 0, 0, 120, 176, 24, 14, 2, Screen::CR_NO_P_CHECK); _screen->setScreenDim(cd); + drawScene(0); + + //for (int i = 0; i < 6; i++) + // cleanupCharacterSpellList(i); + + _screen->setCurPage(0); + const ScreenDim *dm = _screen->getScreenDim(10); + _screen->copyRegion(dm->sx << 3, dm->sy, dm->sx << 3, dm->sy, dm->w << 3, dm->h, 2, 0, Screen::CR_NO_P_CHECK); + + //if (displayInv) + // _screen->loadEobCpsFileToPage("INVENT", 0, 5, 3, 2); + + _screen->updateScreen(); enableSysTimer(2); updateCharacterEvents(true); @@ -1548,7 +1570,7 @@ int GUI_Eob::processButtonList(Kyra::Button *buttonList, uint16 inputFlags, int8 uint16 in = inputFlags & 0xff; uint16 buttonReleaseFlag = 0; bool clickEvt = false; - + _vm->TTTTT = true; _flagsMouseLeft = (_vm->_mouseClick == 1) ? 2 : 4; _flagsMouseRight = (_vm->_mouseClick == 2) ? 2 : 4; _vm->_mouseClick = 0; @@ -1919,7 +1941,7 @@ int GUI_Eob::processButtonList(Kyra::Button *buttonList, uint16 inputFlags, int8 if (!result) result = inputFlags; - +_vm-> TTTTT=false; return result; } diff --git a/engines/kyra/gui_eob.h b/engines/kyra/gui_eob.h index 82e9476fe0..2ad69e700a 100644 --- a/engines/kyra/gui_eob.h +++ b/engines/kyra/gui_eob.h @@ -49,6 +49,7 @@ public: int redrawShadedButtonCallback(Button *button) { return 0; } int redrawButtonCallback(Button *button) { return 0; } + // general menu handling (main menu, character generation, ingame menus, etc.) void setupMenu(int sd, int maxItem, const char *const *strings, int32 menuItemsMask, int unk, int lineSpacing); int handleMenu(int sd, const char *const *strings, void *b, int32 menuItemsMask, int unk); int getMenuItem(int index, int32 menuItemsMask, int unk); @@ -56,7 +57,7 @@ public: int getTextInput(char *dest, int x, int y, int destMaxLen, int textColor1, int textColor2, int cursorColor); - //int runMenu(Menu &menu); + // int runMenu(Menu &menu); // utilities for thumbnail creation void createScreenThumbnail(Graphics::Surface &dst) {} diff --git a/engines/kyra/items_eob.cpp b/engines/kyra/items_eob.cpp index e536b67324..f9b5212c62 100644 --- a/engines/kyra/items_eob.cpp +++ b/engines/kyra/items_eob.cpp @@ -258,8 +258,8 @@ int EobCoreEngine::countQueuedItems(Item itemQueue, int16 id, int16 type, int co EobItem *itm = &_items[o1]; forceLoop = false; if (id != -1 || type != -1) { - if ((id != -1 || (id == -1 && type != itm->type)) && (type != -1) || (id != o1)) - continue; + if (((id != -1 ) || (id == -1 && type != itm->type)) && ((type != -1) || (type == -1 && id != o1))) + continue; } if (!includeFlyingItems) { diff --git a/engines/kyra/loleobbase.cpp b/engines/kyra/loleobbase.cpp index a7a47b6531..7db1a4ac68 100644 --- a/engines/kyra/loleobbase.cpp +++ b/engines/kyra/loleobbase.cpp @@ -260,7 +260,7 @@ uint16 LolEobBaseEngine::processDialogue() { if (e) gui_notifyButtonListChanged(); - if (_flags.gameID == GI_LOL && (e == 200 || e == 202) || _flags.gameID != GI_LOL && (e == 199 || e == 201)) { + if ((_flags.gameID == GI_LOL && (e == 200 || e == 202)) || (_flags.gameID != GI_LOL && (e == 199 || e == 201))) { for (int i = 0; i < _dialogueNumButtons; i++) { int x = _dialogueButtonPosX[i]; int y = (gameFlags().use16ColorMode ? ((_dialogueButtonYoffs + _dialogueButtonPosY[i]) & ~7) - 1 : (_dialogueButtonYoffs + _dialogueButtonPosY[i])); diff --git a/engines/kyra/loleobbase.h b/engines/kyra/loleobbase.h index 831c64467c..1be2a8b07f 100644 --- a/engines/kyra/loleobbase.h +++ b/engines/kyra/loleobbase.h @@ -253,6 +253,7 @@ protected: Button *_activeButtons; Button _activeButtonData[70]; +bool TTTTT; uint8 _mouseClick; bool _preserveEvents; diff --git a/engines/kyra/magic_eob.cpp b/engines/kyra/magic_eob.cpp index 16e8996340..2c83c26b83 100644 --- a/engines/kyra/magic_eob.cpp +++ b/engines/kyra/magic_eob.cpp @@ -175,13 +175,14 @@ void EobCoreEngine::castSpell(int spell, int weaponSlot) { memmove(&_openBookAvailableSpells[_openBookSpellLevel * 10 + _openBookSpellListOffset + _openBookSpellSelectedItem], &_openBookAvailableSpells[_openBookSpellLevel * 10 + _openBookSpellListOffset + _openBookSpellSelectedItem + 1], 8 - (_openBookSpellListOffset + _openBookSpellSelectedItem)); _openBookAvailableSpells[_openBookSpellLevel * 10 + 8] = -tmp; if (_openBookAvailableSpells[_openBookSpellLevel * 10 + _openBookSpellListOffset + _openBookSpellSelectedItem] < 0) { - if (--_openBookSpellSelectedItem == -1) + if (--_openBookSpellSelectedItem == -1) { if (_openBookSpellListOffset) { _openBookSpellListOffset = 0; _openBookSpellSelectedItem = 5; } else { _openBookSpellSelectedItem = 6; } + } } } else if (weaponSlot != -1) { updateUsedCharacterHandItem(_openBookChar, weaponSlot); diff --git a/engines/kyra/scene_eob.cpp b/engines/kyra/scene_eob.cpp index a8ca966d49..56bf352b98 100644 --- a/engines/kyra/scene_eob.cpp +++ b/engines/kyra/scene_eob.cpp @@ -989,13 +989,13 @@ void EobCoreEngine::toggleWallState(int wall, int toggle) { } } -void EobCoreEngine::drawScene(int update) { +void EobCoreEngine::drawScene(int refresh) { generateBlockDrawingBuffer(); drawVcnBlocks(); drawSceneShapes(); if (_sceneDrawPage2) { - if (update) + if (refresh) _screen->fillRect(0, 0, 176, 120, 12); _screen->setScreenPalette(_screen->getPalette(0)); @@ -1018,15 +1018,15 @@ void EobCoreEngine::drawScene(int update) { delayUntil(_drawSceneTimer); } - if (update && !_partyResting) + if (refresh && !_partyResting) _screen->copyRegion(0, 0, 0, 0, 176, 120, 2, 0, Screen::CR_NO_P_CHECK); updateEnvironmentalSfx(0); - if (!_dialogueField && update && !_updateFlags) + if (!_dialogueField && refresh && !_updateFlags) gui_drawCompass(false); - if (update && !_partyResting) + if (refresh && !_partyResting) _screen->updateScreen(); if (_sceneDefaultUpdate) { diff --git a/engines/kyra/screen_eob.cpp b/engines/kyra/screen_eob.cpp index b93ab3eafb..f6b0eafcf4 100644 --- a/engines/kyra/screen_eob.cpp +++ b/engines/kyra/screen_eob.cpp @@ -508,7 +508,7 @@ void Screen_Eob::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, break; if (!*(src-1) || i < marginLeft) - marginLeft = ++marginLeft - *src++; + marginLeft = marginLeft + 1 - *src++; else marginLeft = 0; @@ -723,7 +723,6 @@ void Screen_Eob::drawExplosion(int scale, int radius, int numSteps, int stepSize int16 gx2 = _gfxX; int16 gy2 = _gfxY; - uint8 *ptr1 = _dsTempPage; int16 *ptr2 = (int16*)_dsTempPage; int16 *ptr3 = (int16*)&_dsTempPage[300]; int16 *ptr4 = (int16*)&_dsTempPage[600]; diff --git a/engines/kyra/sequences_eob1.cpp b/engines/kyra/sequences_eob1.cpp index 0606742421..7e15a7aac7 100644 --- a/engines/kyra/sequences_eob1.cpp +++ b/engines/kyra/sequences_eob1.cpp @@ -37,8 +37,7 @@ int EobEngine::mainMenu() { int menuChoice = 4; Screen::FontId of = _screen->_currentFont; - Common::SeekableReadStream *s = 0; - + while (menuChoice >= 0 && !shouldQuit()) { switch (menuChoice) { case 0: diff --git a/engines/kyra/sequences_eob2.cpp b/engines/kyra/sequences_eob2.cpp index 708e9cd23a..07dd5237b8 100644 --- a/engines/kyra/sequences_eob2.cpp +++ b/engines/kyra/sequences_eob2.cpp @@ -70,8 +70,6 @@ private: Screen_Eob *_screen; Mode _mode; - uint8 _notifier; - const char *const *_strings; const char *const *_cpsFiles; const char *const *_palFiles; @@ -1259,7 +1257,7 @@ void DarkmoonSequenceHelper::delay(uint32 ticks) { void DarkmoonSequenceHelper::waitForSongNotifier(int index, bool introUpdateAnim) { int seq = 0; - while (_notifier < index && !(_vm->skipFlag() || _vm->shouldQuit())) { + while (_vm->sound()->checkTrigger() < index && !(_vm->skipFlag() || _vm->shouldQuit())) { if (introUpdateAnim) { runSequence(30 | seq); seq ^= 1; diff --git a/engines/kyra/sprites_eob.cpp b/engines/kyra/sprites_eob.cpp index aac3c274db..1fa89ead3c 100644 --- a/engines/kyra/sprites_eob.cpp +++ b/engines/kyra/sprites_eob.cpp @@ -387,18 +387,18 @@ void EobCoreEngine::flashMonsterShape(EobMonsterInPlay *m) { void EobCoreEngine::updateAllMonsterShapes() { drawScene(1); - bool update = false; + bool updateShp = false; for (EobMonsterInPlay *m = _monsters; m < &_monsters[30]; m++) { if (m->flags & 2) { m->flags &= ~2; - update = true; + updateShp = true; if (m->hitPointsCur <= 0) killMonster(m, true); } } - if (update) { + if (updateShp) { _sceneUpdateRequired = true; _flashShapeTimer = _system->getMillis() + _tickLength; } else { @@ -995,7 +995,7 @@ bool EobCoreEngine::updateMonsterTryDistanceAttack(EobMonsterInPlay *m) { statusAttack(i, 4, _monsterSpecAttStrings[1], 1, 5, 9, 1); } } else { - Item itm = duplicateItem(-s); + itm = duplicateItem(-s); if (itm) { if (launchObject(-1, itm, m->block, m->pos, m->dir, _items[itm].type)) _items[itm].block = -1; @@ -1240,7 +1240,7 @@ void EobCoreEngine::setBlockMonsterDirection(int block, int dir) { if (_monsters[i].block != block || _monsters[i].dir == dir) continue; _monsters[i].dir = dir; - _monsters[i].directionChanged == 1; + _monsters[i].directionChanged = 1; } } -- cgit v1.2.3