diff options
-rw-r--r-- | engines/cryo/eden.cpp | 725 | ||||
-rw-r--r-- | engines/cryo/eden.h | 172 | ||||
-rw-r--r-- | engines/cryo/eden_graphics.cpp (renamed from engines/cryo/graphics.cpp) | 685 | ||||
-rw-r--r-- | engines/cryo/eden_graphics.h | 244 | ||||
-rw-r--r-- | engines/cryo/module.mk | 2 |
5 files changed, 1157 insertions, 671 deletions
diff --git a/engines/cryo/eden.cpp b/engines/cryo/eden.cpp index 04191ffdeb..247754c8ac 100644 --- a/engines/cryo/eden.cpp +++ b/engines/cryo/eden.cpp @@ -42,6 +42,7 @@ #include "cryo/cryolib.h" #include "cryo/eden.h" #include "cryo/sound.h" +#include "cryo/eden_graphics.h" namespace Cryo { @@ -62,28 +63,26 @@ EdenGame::EdenGame(CryoEngine *vm) : _vm(vm), kMaxMusicSize(2200000) { { 0x81, 0x90, 1, 0x10} }; + _graphics = nullptr; + _adamMapMarkPos = Common::Point(-1, -1); _scrollPos = _oldScrollPos = 0; _frescoTalk = false; _torchCursor = false; _curBankNum = 0; - _glowH = _glowW = _glowY = _glowX = 0; _paletteUpdateRequired = false; _cursorSaved = false; - _showBlackBars = false; _backgroundSaved = false; _bankData = nullptr; _tyranPtr = nullptr; _lastAnimFrameNumb = _curAnimFrameNumb = 0; _lastAnimTicks = 0; - _curCharacterRect = nullptr; _numAnimFrames = _maxPersoDesc = _numImgDesc = 0; _restartAnimation = _animationActive = false; _animationDelay = _animationIndex = _lastAnimationIndex = 0; dword_30724 = dword_30728 = _mouthAnimations = _animationTable = nullptr; _characterBankData = nullptr; - _savedUnderSubtitles = false; _numTextLines = 0; _textOutPtr = textout = nullptr; _curSpecialObject = nullptr; @@ -94,7 +93,7 @@ EdenGame::EdenGame(CryoEngine *vm) : _vm(vm), kMaxMusicSize(2200000) { _lastPhrasesFile = 0; _dialogSkipFlags = 0; _voiceSamplesBuffer = nullptr; - _needToFade = false; + _mainBankBuf = nullptr; _musicBuf = nullptr; _gameLipsync = nullptr; @@ -115,7 +114,6 @@ EdenGame::EdenGame(CryoEngine *vm) : _vm(vm), kMaxMusicSize(2200000) { _musicChannel = _voiceChannel = nullptr; _hnmSoundChannel = nullptr; _voiceSound = nullptr; - _view2 = _underSubtitlesView = _subtitlesView = _underBarsView = _mainView = _hnmView = nullptr; _cirsorPanX = 0; _inventoryScrollDelay = 0; _cursorPosY = _cursorPosX = 0; @@ -123,7 +121,6 @@ EdenGame::EdenGame(CryoEngine *vm) : _vm(vm), kMaxMusicSize(2200000) { _currSpot = _curSpot2 = nullptr; _mouseHeld = false; _normalCursor = false; - _showVideoSubtitle = false; _specialTextMode = false; _voiceSamplesSize = 0; _animateTalking = false; @@ -172,21 +169,24 @@ EdenGame::EdenGame(CryoEngine *vm) : _vm(vm), kMaxMusicSize(2200000) { _cursCenter = 11; } +EdenGame::~EdenGame() { +} + void EdenGame::removeConsole() { } void EdenGame::scroll() { restoreFriezes(); - _mainView->_normal._srcLeft = _scrollPos; - _mainView->_zoom._srcLeft = _scrollPos; + _graphics->getMainView()->_normal._srcLeft = _scrollPos; + _graphics->getMainView()->_zoom._srcLeft = _scrollPos; } void EdenGame::resetScroll() { _oldScrollPos = _scrollPos; _scrollPos = 0; restoreFriezes(); //TODO: inlined scroll() ? - _mainView->_normal._srcLeft = 0; - _mainView->_zoom._srcLeft = 0; + _graphics->getMainView()->_normal._srcLeft = 0; + _graphics->getMainView()->_zoom._srcLeft = 0; } void EdenGame::scrollFrescoes() { @@ -199,18 +199,27 @@ void EdenGame::scrollFrescoes() { scroll(); } +bool EdenGame::animationIsActive() { + return _animationActive; +} + // Original name: afffresques void EdenGame::displayFrescoes() { useBank(_globals->_frescoeImgBank); - drawSprite(0, 0, 16); + _graphics->drawSprite(0, 0, 16); useBank(_globals->_frescoeImgBank + 1); - drawSprite(0, 320, 16); + _graphics->drawSprite(0, 320, 16); _paletteUpdateRequired = true; } +void EdenGame::setVolume(uint16 vol) { + _hnmSoundChannel->setVolumeLeft(vol); + _hnmSoundChannel->setVolumeRight(vol); +} + void EdenGame::gametofresques() { _frescoTalk = false; - rundcurs(); + _graphics->rundcurs(); saveFriezes(); displayFrescoes(); _globals->_displayFlags = DisplayFlags::dfFrescoes; @@ -220,8 +229,8 @@ void EdenGame::gametofresques() { void EdenGame::doFrescoes() { _cursorSaved = false; _torchCursor = true; - _glowX = -1; - _glowY = -1; + _graphics->setGlowX(-1); + _graphics->setGlowY(-1); _globals->_gameFlags |= GameFlags::gfFlag20; _globals->_varD4 = 0; _globals->_curObjectId = 0; @@ -275,7 +284,7 @@ void EdenGame::scrollPanel() { // Original name: affsuiveur void EdenGame::displayFollower(Follower *follower, int16 x, int16 y) { useBank(follower->_spriteBank); - drawSprite(follower->_spriteNum, x, y + 16); + _graphics->drawSprite(follower->_spriteNum, x, y + 16); } // Original name: persoinmiroir @@ -331,7 +340,7 @@ void EdenGame::characterInMirror() { // Original name: gametomiroir void EdenGame::gameToMirror(byte arg1) { if (_globals->_displayFlags != DisplayFlags::dfFlag2) { - rundcurs(); + _graphics->rundcurs(); restoreFriezes(); drawTopScreen(); showObjects(); @@ -343,9 +352,9 @@ void EdenGame::gameToMirror(byte arg1) { resNum = 2487; // PCIMG.HSQ useBank(resNum); - drawSprite(0, 0, 16); + _graphics->drawSprite(0, 0, 16); useBank(resNum + 1); - drawSprite(0, 320, 16); + _graphics->drawSprite(0, 320, 16); characterInMirror(); _paletteUpdateRequired = true; _globals->_iconsIndex = 16; @@ -359,7 +368,7 @@ void EdenGame::flipMode() { endCharacterSpeech(); if (_globals->_displayFlags == DisplayFlags::dfPerson) { if (_globals->_characterPtr == &_persons[PER_TAU] && _globals->_phaseNum >= 80) - displaySubtitles(); + _graphics->displaySubtitles(); else { getDataSync(); loadCurrCharacter(); @@ -368,7 +377,7 @@ void EdenGame::flipMode() { animCharacter(); } } else - displaySubtitles(); + _graphics->displaySubtitles(); persovox(); } else { if (_globals->_displayFlags != DisplayFlags::dfFrescoes && _globals->_displayFlags != DisplayFlags::dfFlag2) { @@ -390,7 +399,7 @@ void EdenGame::flipMode() { // Original name: quitmiroir void EdenGame::quitMirror() { - rundcurs(); + _graphics->rundcurs(); display(); resetScroll(); saveFriezes(); @@ -414,7 +423,7 @@ void EdenGame::actionClickValleyPlan() { if (_globals->_roomNum == 8 || _globals->_roomNum < 16) return; - rundcurs(); + _graphics->rundcurs(); display(); if (_globals->_displayFlags == DisplayFlags::dfMirror) quitMirror(); @@ -438,9 +447,9 @@ void EdenGame::gotoPlace(Goto *go) { closeCharacterScreen(); } if (go->_enterVideoNum) { - hideBars(); - playHNM(go->_enterVideoNum); - _needToFade = true; + _graphics->hideBars(); + _graphics->playHNM(go->_enterVideoNum); + _graphics->setFade(true); } initPlace(_globals->_newRoomNum); specialoutside(); @@ -543,7 +552,7 @@ void EdenGame::move(Direction dir) { int16 roomNum = _globals->_roomNum; debug("move: from room %4X", roomNum); char newLoc = 0; - rundcurs(); + _graphics->rundcurs(); display(); _globals->_prevLocation = roomNum & 0xFF; switch (dir) { @@ -593,8 +602,8 @@ void EdenGame::move2(Direction dir) { // Original name: dinosoufle void EdenGame::actionDinoBlow() { if (_globals->_curObjectId == 0) { - hideBars(); - playHNM(148); + _graphics->hideBars(); + _graphics->playHNM(148); maj2(); } } @@ -604,9 +613,9 @@ void EdenGame::actionPlateMonk() { if (_globals->_curObjectId != 0) { if (_globals->_curObjectId == Objects::obPrism) { loseObject(Objects::obPrism); - hideBars(); + _graphics->hideBars(); _specialTextMode = true; - playHNM(89); + _graphics->playHNM(89); // CHECKME: Unused code // word_2F514 |= 0x8000; maj2(); @@ -614,8 +623,8 @@ void EdenGame::actionPlateMonk() { showEvents(); } } else { - hideBars(); - playHNM(7); + _graphics->hideBars(); + _graphics->playHNM(7); maj2(); _globals->_eventType = EventType::etEvent4; showEvents(); @@ -726,7 +735,7 @@ void EdenGame::handleDinaDialog() { bool res = dialoscansvmas((Dialog *)getElem(_gameDialogs, num)); _frescoTalk = false; if (res) { - restoreUnderSubtitles(); + _graphics->restoreUnderSubtitles(); _frescoTalk = true; persovox(); } @@ -737,6 +746,22 @@ void EdenGame::handleDinaDialog() { } } +int16 EdenGame::getCurPosX() { + return _cursorPosX; +} + +int16 EdenGame::getCurPosY() { + return _cursorPosY; +} + +void EdenGame::setCurPosX(int16 xpos) { + _cursorPosX = xpos; +} + +void EdenGame::setCurPosY(int16 ypos) { + _cursorPosY = ypos; +} + // Original name: roiparle void EdenGame::handleKingDialog() { if (_globals->_phaseNum <= 400) @@ -747,8 +772,8 @@ void EdenGame::handleKingDialog() { void EdenGame::actionKingDialog1() { if (_globals->_curObjectId == Objects::obSword) { _globals->_gameFlags |= GameFlags::gfFlag80; - hideBars(); - playHNM(76); + _graphics->hideBars(); + _graphics->playHNM(76); move2(kCryoNorth); } else { _globals->_frescoNumber = 1; @@ -867,8 +892,8 @@ void EdenGame::actionGetTablet() { _gameIcons[16]._cursorId |= 0x8000; showObjects(); _gameRooms[131]._video = 0; - hideBars(); - playHNM(149); + _graphics->hideBars(); + _graphics->playHNM(149); _globals->_varF1 = RoomFlags::rf04; _globals->_drawFlags = DrawFlags::drDrawFlag20; _normalCursor = true; @@ -897,8 +922,8 @@ void EdenGame::actionLookLake() { room->_id = 3; } debug("sea monster: room = %X, d0 = %X\n", _globals->_roomNum, _globals->_roomImgBank); - hideBars(); - playHNM(vid); + _graphics->hideBars(); + _graphics->playHNM(vid); updateRoom(_globals->_roomNum); //TODO: getting memory trashed here? if (_globals->_curObjectId == Objects::obApple) loseObject(Objects::obApple); @@ -939,7 +964,7 @@ void EdenGame::actionGotoFullNest() { // Original name: gotoval void EdenGame::actionGotoVal() { uint16 target = _globals->_roomNum; - rundcurs(); + _graphics->rundcurs(); display(); _scrollPos = 0; char obj = _curSpot2->_objectId - 14; //TODO @@ -949,8 +974,8 @@ void EdenGame::actionGotoVal() { // Original name: visiter void EdenGame::actionVisit() { - hideBars(); - playHNM(144); + _graphics->hideBars(); + _graphics->playHNM(144); _globals->_varF1 = RoomFlags::rf04; maj2(); } @@ -960,10 +985,10 @@ void EdenGame::actionFinal() { if (_globals->_curObjectId != 0) return; - hideBars(); + _graphics->hideBars(); *(int16 *)(_gameRooms + 0x6DC) = 319; //TODO _globals->_roomImgBank = 319; - playHNM(97); + _graphics->playHNM(97); maj2(); _globals->_eventType = EventType::etEvent12; showEvents(); @@ -999,14 +1024,14 @@ void EdenGame::display() { if (!_globals->_mirrorEffect && !_globals->_var103) { if (_paletteUpdateRequired) { _paletteUpdateRequired = false; - CLPalette_Send2Screen(_globalPalette, 0, 256); + _graphics->SendPalette2Screen(256); } - CLBlitter_CopyView2Screen(_mainView); + CLBlitter_CopyView2Screen(_graphics->getMainView()); } else { if (_globals->_mirrorEffect) - displayEffect3(); + _graphics->displayEffect3(); else - displayEffect2(); + _graphics->displayEffect2(); _globals->_var103 = 0; _globals->_mirrorEffect = 0; @@ -1015,57 +1040,35 @@ void EdenGame::display() { void EdenGame::afficher128() { if (_globals->_updatePaletteFlag == 16) { - CLPalette_Send2Screen(_globalPalette, 0, 129); - CLBlitter_CopyView2Screen(_mainView); + _graphics->SendPalette2Screen(129); + CLBlitter_CopyView2Screen(_graphics->getMainView()); _globals->_updatePaletteFlag = 0; } else { - clearScreen(); - fadeToBlackLowPalette(1); - if (_showBlackBars) - drawBlackBars(); - CLBlitter_CopyView2Screen(_mainView); - fadeFromBlackLowPalette(1); + _graphics->clearScreen(); + _graphics->fadeToBlackLowPalette(1); + if (_graphics->getShowBlackBars()) + _graphics->drawBlackBars(); + CLBlitter_CopyView2Screen(_graphics->getMainView()); + _graphics->fadeFromBlackLowPalette(1); } } // Original name: sauvefrises void EdenGame::saveFriezes() { - saveTopFrieze(0); - saveBottomFrieze(); -} - -// Original name: sauvefriseshaut -void EdenGame::saveTopFrieze(int16 x) { // Save top bar - _underTopBarScreenRect = Common::Rect(x, 0, x + 320 - 1, 15); - _underTopBarBackupRect = Common::Rect(0, 0, 320 - 1, 15); - CLBlitter_CopyViewRect(_mainView, _underBarsView, &_underTopBarScreenRect, &_underTopBarBackupRect); -} - -// Original name: sauvefrisesbas -void EdenGame::saveBottomFrieze() { // Save bottom bar - _underBottomBarScreenRect.left = 0; - _underBottomBarScreenRect.right = 320 - 1; - CLBlitter_CopyViewRect(_mainView, _underBarsView, &_underBottomBarScreenRect, &_underBottomBarBackupRect); + _graphics->saveTopFrieze(0); + _graphics->saveBottomFrieze(); } // Original name: restaurefrises void EdenGame::restoreFriezes() { - restoreTopFrieze(); - restoreBottomFrieze(); + _graphics->restoreTopFrieze(); + _graphics->restoreBottomFrieze(); } -// Original name: restaurefriseshaut -void EdenGame::restoreTopFrieze() { - _underTopBarScreenRect.left = _scrollPos; - _underTopBarScreenRect.right = _scrollPos + 320 - 1; - CLBlitter_CopyViewRect(_underBarsView, _mainView, &_underTopBarBackupRect, &_underTopBarScreenRect); -} -// Original name: restaurefrisesbas -void EdenGame::restoreBottomFrieze() { - _underBottomBarScreenRect.left = _scrollPos; - _underBottomBarScreenRect.right = _scrollPos + 320 - 1; - CLBlitter_CopyViewRect(_underBarsView, _mainView, &_underBottomBarBackupRect, &_underBottomBarScreenRect); + +byte * EdenGame::getBankData() { + return _bankData; } void EdenGame::useMainBank() { @@ -1089,68 +1092,15 @@ void EdenGame::useBank(int16 bank) { } } -void EdenGame::readPalette(byte *ptr) { - bool doit = true; - color3_t pal_entry; - while (doit) { - uint16 idx = *ptr++; - if (idx != 0xFF) { - uint16 cnt = *ptr++; - while (cnt--) { - if (idx == 0) { - pal_entry.r = 0; - pal_entry.g = 0; - pal_entry.b = 0; - ptr += 3; - } else { - pal_entry.r = *ptr++ << 10; - pal_entry.g = *ptr++ << 10; - pal_entry.b = *ptr++ << 10; - } - CLPalette_SetRGBColor(_globalPalette, idx, &pal_entry); - idx++; - } - } else - doit = false; - } -} - -// Original name: sauvefondbouche -void EdenGame::saveMouthBackground() { - rect_src.left = _curCharacterRect->left; - rect_src.top = _curCharacterRect->top; - rect_src.right = _curCharacterRect->right; - rect_src.bottom = _curCharacterRect->bottom; - rect_dst.left = _curCharacterRect->left + 320; - rect_dst.top = _curCharacterRect->top; - rect_dst.right = _curCharacterRect->right + 320; - rect_dst.bottom = _curCharacterRect->bottom; - CLBlitter_CopyViewRect(_mainView, _mainView, &rect_src, &rect_dst); - _backgroundSaved = true; -} - -// Original name: restaurefondbouche -void EdenGame::restoreMouthBackground() { - rect_src.left = _curCharacterRect->left; - rect_src.top = _curCharacterRect->top; - rect_src.right = _curCharacterRect->right; - rect_src.bottom = _curCharacterRect->bottom; - rect_dst.left = _curCharacterRect->left + 320; - rect_dst.top = _curCharacterRect->top; - rect_dst.right = _curCharacterRect->right + 320; - rect_dst.bottom = _curCharacterRect->bottom; - CLBlitter_CopyViewRect(_mainView, _mainView, &rect_dst, &rect_src); -} - void EdenGame::drawTopScreen() { // Draw top bar (location / party / map) _globals->_drawFlags &= ~DrawFlags::drDrawTopScreen; useBank(314); - drawSprite(36, 83, 0); - drawSprite(_globals->_areaPtr->_num - 1, 0, 0); - drawSprite(23, 145, 0); + _graphics->drawSprite(36, 83, 0); + _graphics->drawSprite(_globals->_areaPtr->_num - 1, 0, 0); + _graphics->drawSprite(23, 145, 0); for (perso_t *perso = &_persons[PER_DINA]; perso != &_persons[PER_UNKN_156]; perso++) { if ((perso->_flags & PersonFlags::pfInParty) && !(perso->_flags & PersonFlags::pf80)) - drawSprite(perso->_targetLoc + 18, perso->_lastLoc + 120, 0); + _graphics->drawSprite(perso->_targetLoc + 18, perso->_lastLoc + 120, 0); } _adamMapMarkPos.x = -1; _adamMapMarkPos.y = -1; @@ -1161,7 +1111,7 @@ void EdenGame::drawTopScreen() { // Draw top bar (location / party / map) // Original name: affplanval void EdenGame::displayValleyMap() { // Draw mini-map if (_globals->_areaPtr->_type == AreaType::atValley) { - drawSprite(_globals->_areaPtr->_num + 9, 266, 1); + _graphics->drawSprite(_globals->_areaPtr->_num + 9, 266, 1); for (perso_t *perso = &_persons[PER_UNKN_18C]; perso->_roomNum != 0xFFFF; perso++) { if (((perso->_roomNum >> 8) == _globals->_areaNum) && !(perso->_flags & PersonFlags::pf80) && (perso->_flags & PersonFlags::pf20)) @@ -1169,20 +1119,20 @@ void EdenGame::displayValleyMap() { // Draw mini-map } if (_globals->_areaPtr->_citadelLevel) displayMapMark(34, _globals->_areaPtr->_citadelRoomPtr->_location); - saveTopFrieze(0); + _graphics->saveTopFrieze(0); int16 loc = _globals->_roomNum & 0xFF; if (loc >= 16) displayAdamMapMark(loc); - restoreTopFrieze(); + _graphics->restoreTopFrieze(); } else { - saveTopFrieze(0); - restoreTopFrieze(); + _graphics->saveTopFrieze(0); + _graphics->restoreTopFrieze(); } } // Original name: affrepere void EdenGame::displayMapMark(int16 index, int16 location) { - drawSprite(index, 269 + location % 16 * 4, 2 + (location - 16) / 16 * 3); + _graphics->drawSprite(index, 269 + location % 16 * 4, 2 + (location - 16) / 16 * 3); } // Original name: affrepereadam @@ -1194,8 +1144,8 @@ void EdenGame::displayAdamMapMark(int16 location) { x += (location & 15) * 4; y += ((location - 16) >> 4) * 3; saveAdamMapMark(x, y); - byte *pix = _underBarsView->_bufferPtr; - int16 w = _underBarsView->_width; + byte *pix = _graphics->getUnderBarsView()->_bufferPtr; + int16 w = _graphics->getUnderBarsView()->_width; pix += x + w * y; pix[1] = 0xC3; pix[2] = 0xC3; @@ -1217,8 +1167,8 @@ void EdenGame::restoreAdamMapMark() { int16 x = _adamMapMarkPos.x; int16 y = _adamMapMarkPos.y; - byte *pix = _underBarsView->_bufferPtr; - int16 w = _underBarsView->_width; + byte *pix = _graphics->getUnderBarsView()->_bufferPtr; + int16 w = _graphics->getUnderBarsView()->_width; pix += x + w * y; pix[1] = _oldPix[0]; pix[2] = _oldPix[1]; @@ -1236,8 +1186,8 @@ void EdenGame::restoreAdamMapMark() { void EdenGame::saveAdamMapMark(int16 x, int16 y) { _adamMapMarkPos.x = x; _adamMapMarkPos.y = y; - byte *pix = _underBarsView->_bufferPtr; - int16 w = _underBarsView->_width; + byte *pix = _graphics->getUnderBarsView()->_bufferPtr; + int16 w = _graphics->getUnderBarsView()->_width; pix += x + w * y; _oldPix[0] = pix[1]; _oldPix[1] = pix[2]; @@ -1446,6 +1396,10 @@ void EdenGame::evolveCitadel(int16 level) { } } +int16 EdenGame::getCurBankNum() { + return _curBankNum; +} + // Original name: citacapoute void EdenGame::destroyCitadelRoom(int16 roomNum) { perso_t *perso = &_persons[PER_UNKN_18C]; @@ -1811,11 +1765,15 @@ void EdenGame::addTime(int16 t) { } } +byte *EdenGame::getImageDesc() { + return _imageDesc; +} + // Original name: anim_perso void EdenGame::animCharacter() { if (_curBankNum != _globals->_characterImageBank) loadCharacter(_globals->_characterPtr); - restoreUnderSubtitles(); + _graphics->restoreUnderSubtitles(); if (_restartAnimation) { _lastAnimTicks = _vm->_timerTicks; _restartAnimation = false; @@ -1834,7 +1792,7 @@ void EdenGame::animCharacter() { _mouthAnimations = _imageDesc + 200; removeMouthSprite(); if (*_mouthAnimations) - displayImage(); + _graphics->displayImage(); _animationDelay--; if (!_animationDelay) { _globals->_animationFlags = 1; @@ -1850,8 +1808,10 @@ void EdenGame::animCharacter() { if (_animateTalking) { if (!_animationTable) { _animationTable = _gameLipsync + 7262; //TODO: fix me - if (!_backgroundSaved) - saveMouthBackground(); + if (!_backgroundSaved) { + _graphics->saveMouthBackground(); + _backgroundSaved = true; + } } if (!_personTalking) _curAnimFrameNumb = _numAnimFrames - 1; @@ -1860,16 +1820,16 @@ void EdenGame::animCharacter() { _animateTalking = false; else if (_animationIndex != _lastAnimationIndex) { useCharacterBank(); - restoreMouthBackground(); + _graphics->restoreMouthBackground(); // debug("perso spr %d", animationIndex); setCharacterSprite(_globals->_persoSpritePtr2 + _animationIndex * 2); //TODO: int16s? _mouthAnimations = _imageDesc + 200; if (*_mouthAnimations) - displayImage(); + _graphics->displayImage(); _lastAnimationIndex = _animationIndex; } } - displaySubtitles(); + _graphics->displaySubtitles(); } void EdenGame::getanimrnd() { @@ -1904,7 +1864,7 @@ void EdenGame::addanim() { if (_globals->_characterPtr->_id != PersonId::pidCabukaOfCantura && _globals->_characterPtr->_targetLoc != 7) //TODO: targetLoc is minisprite idx removeMouthSprite(); if (*_mouthAnimations) - displayImage(); + _graphics->displayImage(); } // Original name: virespritebouche @@ -1973,7 +1933,7 @@ void EdenGame::setCharacterSprite(byte *spr) { // Original name: af_perso1 void EdenGame::displayCharacter1() { setCharacterSprite(_globals->_persoSpritePtr + READ_LE_UINT16(_globals->_persoSpritePtr)); - displayImage(); + _graphics->displayImage(); } // Original name: af_perso @@ -1993,7 +1953,7 @@ void EdenGame::loadCharacter(perso_t *perso) { return; if (perso->_spriteBank != _globals->_characterImageBank) { - _curCharacterRect = &_characterRects[perso->_id]; //TODO: array of int16? + _graphics->setCurCharRect(&_characterRects[perso->_id]); //TODO: array of int16? dword_30728 = _characterArray[perso->_id]; ef_perso(); _globals->_characterImageBank = perso->_spriteBank; @@ -2048,9 +2008,9 @@ void EdenGame::no_perso() { void EdenGame::closeCharacterScreen() { endCharacterSpeech(); if (_globals->_displayFlags == DisplayFlags::dfPerson && _globals->_characterPtr->_id != PersonId::pidNarrator && _globals->_eventType != EventType::etEventE) { - rundcurs(); - _savedUnderSubtitles = true; - restoreUnderSubtitles(); + _graphics->rundcurs(); + _graphics->setSavedUnderSubtitles(true); + _graphics->restoreUnderSubtitles(); display(); _globals->_var103 = 16; } @@ -2100,7 +2060,7 @@ void EdenGame::displayBackgroundFollower() { if (follower->sx >= 320) bank = 327; useBank(bank + _globals->_roomBackgroundBankNum); - drawSprite(0, 0, 16, true); + _graphics->drawSprite(0, 0, 16, true); break; } } @@ -2110,12 +2070,20 @@ void EdenGame::displayNoFollower(int16 bank) { if (bank) { useBank(bank); if (_globals->_characterPtr == &_persons[PER_UNKN_156]) - drawSprite(0, 0, 16, true); + _graphics->drawSprite(0, 0, 16, true); else - drawSprite(0, 0, 16); + _graphics->drawSprite(0, 0, 16); } } +int16 EdenGame::getGameIconX(int16 index) { + return _gameIcons[index].sx; +} + +int16 EdenGame::getGameIconY(int16 index) { + return _gameIcons[index].sy; +} + // Original name: af_fondperso1 void EdenGame::displayCharacterBackground1() { byte bank; @@ -2197,11 +2165,11 @@ void EdenGame::showCharacter() { setCharacterIcon(); displayCharacterBackground(); if (perso == &_persons[PER_TAU] && _globals->_curObjectId == Objects::obShell) { - displaySubtitles(); + _graphics->displaySubtitles(); updateCursor(); _paletteUpdateRequired = true; display(); - rundcurs(); + _graphics->rundcurs(); return; } } @@ -2209,7 +2177,7 @@ void EdenGame::showCharacter() { addanim(); if (!_globals->_curCharacterAnimPtr) { displayCharacter(); - displaySubtitles(); + _graphics->displaySubtitles(); } _restartAnimation = true; animCharacter(); @@ -2217,11 +2185,11 @@ void EdenGame::showCharacter() { updateCursor(); _paletteUpdateRequired = true; if (perso != &_persons[PER_UNKN_156]) - rundcurs(); + _graphics->rundcurs(); display(); } else { displayPlace(); - displaySubtitles(); + _graphics->displaySubtitles(); } } @@ -2232,7 +2200,7 @@ void EdenGame::displayCharacterPanel() { addanim(); if (!_globals->_curCharacterAnimPtr) { displayCharacter(); - displaySubtitles(); + _graphics->displaySubtitles(); } _restartAnimation = true; _paletteUpdateRequired = true; @@ -2243,7 +2211,7 @@ void EdenGame::displayCharacterPanel() { updateCursor(); display(); if (perso != &_persons[PER_UNKN_156]) - rundcurs(); + _graphics->rundcurs(); _globals->_drawFlags |= DrawFlags::drDrawFlag8; _globals->_iconsIndex = 112; } @@ -2297,6 +2265,10 @@ void EdenGame::waitEndSpeak() { _mouseHeld = true; } +int16 EdenGame::getNumTextLines() { + return _numTextLines; +} + void EdenGame::my_bulle() { if (!_globals->_textNum) return; @@ -2406,19 +2378,31 @@ void EdenGame::my_bulle() { byte x = *icons++; byte y = *icons++; byte s = *icons++; - drawSprite(52, x + _subtitlesXCenter, y - 1, false, true); - drawSprite(s + 9, x + _subtitlesXCenter + 1, y, false, true); + _graphics->drawSprite(52, x + _subtitlesXCenter, y - 1, false, true); + _graphics->drawSprite(s + 9, x + _subtitlesXCenter + 1, y, false, true); } } +int16 EdenGame::getScrollPos() { + return _scrollPos; +} + +bool EdenGame::getSpecialTextMode() { + return _specialTextMode; +} + +void EdenGame::setSpecialTextMode(bool value) { + _specialTextMode = value; +} + void EdenGame::my_pr_bulle() { - CLBlitter_FillView(_subtitlesView, 0); + CLBlitter_FillView(_graphics->getSubtitlesView(), 0); if (_globals->_prefLanguage == 0) return; byte *coo = _sentenceCoordsBuffer; bool done = false; - textout = _subtitlesViewBuf; + textout = _graphics->getSubtitlesViewBuf(); byte *textPtr = _sentenceBuffer; int16 lines = 1; while (!done) { @@ -2487,41 +2471,6 @@ void EdenGame::drawSubtitleChar(byte c, byte color, int16 width) { } } -// Original name: sauvefondbulle -void EdenGame::saveUnderSubtitles(int16 y) { - _underSubtitlesScreenRect.top = y - _numTextLines * FONT_HEIGHT; - _underSubtitlesScreenRect.left = _scrollPos + _subtitlesXScrMargin; - _underSubtitlesScreenRect.right = _scrollPos + _subtitlesXScrMargin + _subtitlesXWidth - 1; - _underSubtitlesScreenRect.bottom = y; - _underSubtitlesBackupRect.top = 0; - _underSubtitlesBackupRect.bottom = _numTextLines * FONT_HEIGHT; - CLBlitter_CopyViewRect(_mainView, _underSubtitlesView, &_underSubtitlesScreenRect, &_underSubtitlesBackupRect); - _savedUnderSubtitles = true; -} - -// Original name: restaurefondbulle -void EdenGame::restoreUnderSubtitles() { - if (!_savedUnderSubtitles) - return; - CLBlitter_CopyViewRect(_underSubtitlesView, _mainView, &_underSubtitlesBackupRect, &_underSubtitlesScreenRect); - _savedUnderSubtitles = false; -} - -// Original name: af_subtitlehnm -void EdenGame::displayHNMSubtitle() { - byte *src = _subtitlesViewBuf; - byte *dst = _hnmViewBuf + _subtitlesXScrMargin + (158 - _numTextLines * FONT_HEIGHT) * 320; - for (int16 y = 0; y < _numTextLines * FONT_HEIGHT; y++) { - for (int16 x = 0; x < _subtitlesXWidth; x++) { - char c = *src++; - if (c) - *dst = c; - dst++; - } - dst += 320 - _subtitlesXWidth; - } -} - // Original name: patchPhrase void EdenGame::patchSentence() { _sentenceBuffer[36] = 'c'; @@ -2710,7 +2659,7 @@ void EdenGame::handleCharacterDialog(int16 pers) { uint16 idx = perso->_id * 8 | _globals->_dialogType; dialoscansvmas((Dialog *)getElem(_gameDialogs, idx)); displayPlace(); - displaySubtitles(); + _graphics->displaySubtitles(); persovox(); _globals->_varCA = 0; _globals->_dialogType = DialogType::dtTalk; @@ -2943,12 +2892,12 @@ void EdenGame::actionAdam() { int16 vid = 84; if (!object->_count) vid = *objvid; - hideBars(); + _graphics->hideBars(); _specialTextMode = true; - playHNM(vid); + _graphics->playHNM(vid); _paletteUpdateRequired = true; _globals->_mirrorEffect = 16; // CHECKME: Verify the value - showBars(); + _graphics->showBars(); gameToMirror(0); } break; @@ -3489,6 +3438,10 @@ bool EdenGame::dialoscansvmas(Dialog *dial) { return res; } +byte *EdenGame::getGameDialogs() { + return _gameDialogs; +} + // Original name: dialo_even bool EdenGame::dialogEvent(perso_t *perso) { _globals->_characterPtr = perso; @@ -3509,12 +3462,12 @@ void EdenGame::characterStayHere() { // Original name: mort void EdenGame::endDeath(int16 vid) { - hideBars(); - playHNM(vid); - fadeToBlack(2); + _graphics->hideBars(); + _graphics->playHNM(vid); + _graphics->fadeToBlack(2); CLBlitter_FillScreenView(0); - CLBlitter_FillView(_mainView, 0); - showBars(); + CLBlitter_FillView(_graphics->getMainView(), 0); + _graphics->showBars(); _globals->_narratorSequence = 51; _globals->_newMusicType = MusicType::mtNormal; musique(); @@ -3782,26 +3735,11 @@ void EdenGame::initGlobals() { _globals->_persoSpritePtr = nullptr; _globals->_numGiveObjs = 0; - initRects(); - - _underSubtitlesScreenRect.top = 0; - _underSubtitlesScreenRect.left = _subtitlesXScrMargin; - _underSubtitlesScreenRect.right = _subtitlesXScrMargin + _subtitlesXWidth - 1; - _underSubtitlesScreenRect.bottom = 176 - 1; + _graphics->initRects(); - _underSubtitlesBackupRect.top = 0; - _underSubtitlesBackupRect.left = _subtitlesXScrMargin; - _underSubtitlesBackupRect.right = _subtitlesXScrMargin + _subtitlesXWidth - 1; - _underSubtitlesBackupRect.bottom = 60 - 1; + _graphics->initGlobals(); - _savedUnderSubtitles = false; -} - -void EdenGame::initRects() { - _underTopBarScreenRect = Common::Rect(0, 0, 320 - 1, 16 - 1); - _underTopBarBackupRect = Common::Rect(0, 0, 320 - 1, 16 - 1); - _underBottomBarScreenRect = Common::Rect(0, 176, 320 - 1, 200 - 1); //TODO: original bug? this cause crash in copyrect (this, underBottomBarBackupRect) - _underBottomBarBackupRect = Common::Rect(0, 16, 320 - 1, 40 - 1); + _graphics->setSavedUnderSubtitles(false); } // Original name: closesalle @@ -3820,7 +3758,7 @@ void EdenGame::displayPlace() { _globals->_autoDialog = false; } _globals->_nextRoomIcon = &_gameIcons[_roomIconsBase]; - displayRoom(); + _graphics->displayRoom(); _paletteUpdateRequired = true; } @@ -3832,6 +3770,14 @@ void EdenGame::loadPlace(int16 num) { loadRawFile(num + 419, _placeRawBuf); } +byte EdenGame::getActionCursor(byte value) { + return _actionCursors[value]; +} + +byte *EdenGame::getPlaceRawBuf() { + return _placeRawBuf; +} + void EdenGame::specialoutside() { if (_globals->_lastAreaPtr->_type == AreaType::atValley && (_globals->_party & PersonMask::pmLeader)) perso_ici(5); @@ -3879,8 +3825,8 @@ void EdenGame::specialin() { if (_globals->_roomNum == 3075 && _globals->_phaseNum == 546) { incPhase(); if (_globals->_curItemsMask & 0x2000) { // Morkus' tablet - hideBars(); - playHNM(92); + _graphics->hideBars(); + _graphics->playHNM(92); _gameRooms[129]._exits[0] = 0; _gameRooms[129]._exits[2] = 1; _globals->_roomNum = 3074; @@ -3916,13 +3862,13 @@ void EdenGame::animpiece() { if (_globals->_roomVidNum && _globals->_var100 != 0xFF) { if (_globals->_valleyVidNum || !room->_level || (room->_flags & RoomFlags::rfHasCitadel) || room->_level == _globals->_var100) { - hideBars(); + _graphics->hideBars(); _globals->_updatePaletteFlag = 16; if (!(_globals->_narratorSequence & 0x80)) //TODO: bug? !() @ 100DC _globals->_mirrorEffect = 0; - if (!_needToFade) - _needToFade = room->_flags & RoomFlags::rf02; - playHNM(_globals->_roomVidNum); + if (!_graphics->getFade()) + _graphics->setFade(room->_flags & RoomFlags::rf02); + _graphics->playHNM(_globals->_roomVidNum); return; } } @@ -4038,16 +3984,16 @@ void EdenGame::maj2() { if (_globals->_mirrorEffect || _globals->_var103) display(); else if (_globals->_varF1 == (RoomFlags::rf40 | RoomFlags::rf04 | RoomFlags::rf01)) { - drawBlackBars(); - displayEffect1(); + _graphics->drawBlackBars(); + _graphics->displayEffect1(); } else if (_globals->_varF1 && !(_globals->_varF1 & RoomFlags::rf04) && !r30) { if (!(_globals->_displayFlags & DisplayFlags::dfPanable)) - drawBlackBars(); + _graphics->drawBlackBars(); else if (_globals->_valleyVidNum) - drawBlackBars(); - displayEffect1(); + _graphics->drawBlackBars(); + _graphics->displayEffect1(); } else if (r30 && !(_globals->_varF1 & RoomFlags::rf04)) - effetpix(); + _graphics->effetpix(); else afficher128(); musique(); @@ -4055,7 +4001,7 @@ void EdenGame::maj2() { drawTopScreen(); showObjects(); } - showBars(); + _graphics->showBars(); showEvents(); _globals->_labyrinthDirections = 0; specialin(); @@ -4121,6 +4067,10 @@ void EdenGame::EmergencyExit() { SysBeep(1); } +void EdenGame::stopMusic() { + _musicChannel->stop(); +} + void EdenGame::run() { _invIconsCount = (_vm->getPlatform() == Common::kPlatformMacintosh) ? 9 : 11; _roomIconsBase = _invIconsBase + _invIconsCount; @@ -4136,10 +4086,12 @@ void EdenGame::run() { _musicChannel = new CSoundChannel(_vm->_mixer, 11025, false); _voiceChannel = new CSoundChannel(_vm->_mixer, 11025, false); + _graphics = new EdenGraphics(this,_vm->_video); + _graphics->setSavedUnderSubtitles(false); allocateBuffers(); openbigfile(); - openWindow(); + _graphics->openWindow(); loadpermfiles(); if (!_bufferAllocationErrorFl) { @@ -4154,16 +4106,16 @@ void EdenGame::run() { _quitFlag3 = false; _normalCursor = true; _torchCursor = false; - _cursKeepPos = Common::Point(-1, -1); + _graphics->setCursKeepPos(-1,-1); if (!_gameLoaded) intro(); edmain(); startmusique(1); - drawBlackBars(); + _graphics->drawBlackBars(); display(); - fadeToBlack(3); - clearScreen(); - playHNM(95); + _graphics->fadeToBlack(3); + _graphics->clearScreen(); + _graphics->playHNM(95); if (_globals->_endGameFlag == 50) { loadrestart(); _gameLoaded = false; @@ -4176,10 +4128,12 @@ void EdenGame::run() { // LostEdenMac_SavePrefs(); } + _graphics->fadeToBlack(4); + delete _voiceChannel; delete _musicChannel; + delete _graphics; - fadeToBlack(4); closebigfile(); freebuf(); CRYOLib_ManagersDone(); @@ -4193,12 +4147,12 @@ void EdenGame::edmain() { // if in demo mode, reset game after a while _demoCurrentTicks = _vm->_timerTicks; if (_demoCurrentTicks - _demoStartTicks > 3000) { - rundcurs(); + _graphics->rundcurs(); display(); fademusica0(2); - fadeToBlack(3); + _graphics->fadeToBlack(3); CLBlitter_FillScreenView(0); - CLBlitter_FillView(_mainView, 0); + CLBlitter_FillView(_graphics->getMainView(), 0); _musicChannel->stop(); _musicPlayingFlag = false; _musicEnabledFlag = false; @@ -4206,7 +4160,7 @@ void EdenGame::edmain() { enterGame(); } } - rundcurs(); + _graphics->rundcurs(); musicspy(); FRDevents(); handleNarrator(); @@ -4237,28 +4191,28 @@ void EdenGame::intro() { _vm->_video->closeSound(); _vm->_video->setupSound(22050, false, true); _hnmSoundChannel = _vm->_video->getSoundChannel(); - playHNM(2012); - playHNM(171); + _graphics->playHNM(2012); + _graphics->playHNM(171); CLBlitter_FillScreenView(0); _specialTextMode = false; - playHNM(2001); + _graphics->playHNM(2001); _hnmSoundChannel->stop(); _vm->_video->closeSound(); _vm->_video->setupSound(11025, false, false); _hnmSoundChannel = _vm->_video->getSoundChannel(); } else { if (_vm->isDemo()) { - playHNM(171); // Virgin logo - playHNM(98); // Cryo logo + _graphics->playHNM(171); // Virgin logo + _graphics->playHNM(98); // Cryo logo } else { - playHNM(98); // Cryo logo - playHNM(171); // Virgin logo + _graphics->playHNM(98); // Cryo logo + _graphics->playHNM(171); // Virgin logo } CLBlitter_FillScreenView(0); _specialTextMode = false; startmusique(2); // INTRO.MUS is played during intro video - playHNM(170); // Intro video + _graphics->playHNM(170); // Intro video } } @@ -4287,7 +4241,7 @@ void EdenGame::enterGame() { showObjects(); drawTopScreen(); saveFriezes(); - _showBlackBars = true; + _graphics->setShowBlackBars(true); _globals->_mirrorEffect = 1; updateRoom(_globals->_roomNum); if (flag) { @@ -4345,14 +4299,14 @@ void EdenGame::FRDevents() { _curSpot2 = _currSpot; if (_globals->_displayFlags & DisplayFlags::dfFrescoes) { if (_frescoTalk) - restoreUnderSubtitles(); + _graphics->restoreUnderSubtitles(); if (_currCursor == 9 && !_torchCursor) { - rundcurs(); + _graphics->rundcurs(); _torchCursor = true; - _glowX = -1; + _graphics->setGlowX(-1); } if (_currCursor != 9 && _torchCursor) { - unglow(); + _graphics->unglow(); _torchCursor = false; _cursorSaved = false; } @@ -4426,24 +4380,24 @@ void EdenGame::updateCursor() { if (!_torchCursor) { useMainBank(); - sundcurs(_cursorPosX + _scrollPos, _cursorPosY); + _graphics->sundcurs(_cursorPosX + _scrollPos, _cursorPosY); if (_currCursor != 53 && _currCursor < 10) { //TODO: cond if (_vm->getPlatform() == Common::kPlatformMacintosh) engineMac(); else enginePC(); } else - drawSprite(_currCursor, _cursorPosX + _scrollPos, _cursorPosY); - _glowX = 1; + _graphics->drawSprite(_currCursor, _cursorPosX + _scrollPos, _cursorPosY); + _graphics->setGlowX(1); } else { useBank(117); if (_cursorPosX > 294) _cursorPosX = 294; - unglow(); - glow(_glowIndex); - drawSprite(_torchCurIndex, _cursorPosX + _scrollPos, _cursorPosY); + _graphics->unglow(); + _graphics->glow(_glowIndex); + _graphics->drawSprite(_torchCurIndex, _cursorPosX + _scrollPos, _cursorPosY); if (_frescoTalk) - displaySubtitles(); + _graphics->displaySubtitles(); } } @@ -4838,9 +4792,38 @@ void EdenGame::persovox() { _lastAnimTicks = _vm->_timerTicks; } +bool EdenGame::personIsTalking() { + return _personTalking; +} + +perso_t *EdenGame::personSubtitles() { + perso_t *perso = nullptr; + switch (_globals->_curVideoNum) { + case 170: + perso = &_persons[PER_UNKN_156]; + break; + case 83: + perso = &_persons[PER_MORKUS]; + break; + case 88: + perso = &_persons[PER_MORKUS]; + break; + case 89: + perso = &_persons[PER_MORKUS]; + break; + case 94: + perso = &_persons[PER_MORKUS]; + break; + default: + return perso; + } + return perso; +} + + // Original name: endpersovox void EdenGame::endCharacterSpeech() { - restoreUnderSubtitles(); + _graphics->restoreUnderSubtitles(); if (_personTalking) { _voiceChannel->stop(); _personTalking = false; @@ -4944,22 +4927,33 @@ void EdenGame::showObjects() { icon->_cursorId |= 0x8000; } useMainBank(); - drawSprite(55, 0, 176); + _graphics->drawSprite(55, 0, 176); icon = &_gameIcons[_invIconsBase]; total = _globals->_objCount; int16 index = _globals->_inventoryScrollPos; for (int16 i = _invIconsCount; total-- && i--; icon++) { char obj = _ownObjects[index++]; icon->_objectId = obj; - drawSprite(obj + 9, icon->sx, 178); + _graphics->drawSprite(obj + 9, icon->sx, 178); } _paletteUpdateRequired = true; if ((_globals->_displayFlags & DisplayFlags::dfMirror) || (_globals->_displayFlags & DisplayFlags::dfPanable)) { - saveBottomFrieze(); + _graphics->saveBottomFrieze(); scroll(); } } + +byte * EdenGame::getGlowBuffer() { + return _glowBuffer; +} + +void EdenGame::setMusicFade(byte value) { + _musicFadeFlag = value; +} + + + void EdenGame::winObject(int16 id) { object_t *object = getObjectPtr(id); object->_flags |= ObjectFlags::ofFlag1; @@ -5171,15 +5165,31 @@ void EdenGame::gotoPanel() { _globals->_displayFlags = DisplayFlags::dfFlag2; _globals->_menuFlags = 0; displayPanel(); - fadeToBlack(3); + _graphics->fadeToBlack(3); displayTopPanel(); - CLBlitter_CopyView2Screen(_mainView); - CLPalette_Send2Screen(_globalPalette, 0, 256); + CLBlitter_CopyView2Screen(_graphics->getMainView()); + _graphics->SendPalette2Screen(256); _cursorPosX = 320 / 2; _cursorPosY = 200 / 2; _vm->setMousePosition(_mouseCenterX, _mouseCenterY); } +void EdenGame::setMouseCenterX(uint16 xpos) { + _mouseCenterX = xpos; +} + +void EdenGame::setMouseCenterY(uint16 ypos) { + _mouseCenterY = ypos; +} + +uint16 EdenGame::getMouseCenterX() { + return _mouseCenterX; +} + +uint16 EdenGame::getMouseCenterY() { + return _mouseCenterY; +} + void EdenGame::noclicpanel() { if (_globals->_menuFlags & MenuFlags::mfFlag4) { moveTapeCursor(); @@ -5225,12 +5235,12 @@ skip: } void EdenGame::generique() { - drawBlackBars(); + _graphics->drawBlackBars(); display(); - fadeToBlack(3); - clearScreen(); + _graphics->fadeToBlack(3); + _graphics->clearScreen(); int oldmusic = _globals->_currMusicNum; - playHNM(95); + _graphics->playHNM(95); displayPanel(); displayTopPanel(); _paletteUpdateRequired = true; @@ -5245,14 +5255,30 @@ void EdenGame::cancel2() { gameToMirror(1); } +byte *EdenGame::getCurKeepBuf() { + return _cursKeepBuf; +} + +bool EdenGame::isMouseHeld() { + return _mouseHeld; +} + +void EdenGame::setMouseHeld() { + _mouseHeld = true; +} + +void EdenGame::setMouseNotHeld() { + _mouseHeld = false; +} + void EdenGame::testvoice() { _globals->_frescoNumber = 0; _globals->_characterPtr = _persons; _globals->_dialogType = DialogType::dtInspect; int16 num = (_persons[PER_KING]._id << 3) | _globals->_dialogType; dialoscansvmas((Dialog *)getElem(_gameDialogs, num)); - restoreUnderSubtitles(); - displaySubtitles(); + _graphics->restoreUnderSubtitles(); + _graphics->displaySubtitles(); persovox(); waitEndSpeak(); endCharacterSpeech(); @@ -5275,7 +5301,7 @@ void EdenGame::load() { } _vm->hideMouse(); CLBlitter_FillScreenView(0xFFFFFFFF); - fadeToBlack(3); + _graphics->fadeToBlack(3); CLBlitter_FillScreenView(0); if (!_gameLoaded) { _musicFadeFlag = 3; @@ -5293,9 +5319,9 @@ void EdenGame::load() { } bool talk = _globals->_autoDialog; //TODO check me initafterload(); - fadeToBlack(3); + _graphics->fadeToBlack(3); CLBlitter_FillScreenView(0); - CLBlitter_FillView(_mainView, 0); + CLBlitter_FillView(_graphics->getMainView(), 0); drawTopScreen(); _globals->_inventoryScrollPos = 0; showObjects(); @@ -5343,7 +5369,7 @@ void EdenGame::save() { saveGame(name); _vm->hideMouse(); CLBlitter_FillScreenView(0xFFFFFFFF); - fadeToBlack(3); + _graphics->fadeToBlack(3); CLBlitter_FillScreenView(0); _musicFadeFlag = 3; musicspy(); @@ -5351,7 +5377,7 @@ void EdenGame::save() { } void EdenGame::desktopcolors() { - fadeToBlack(3); + _graphics->fadeToBlack(3); CLBlitter_FillScreenView(0xFFFFFFFF); CLPalette_BeSystem(); _vm->showMouse(); @@ -5389,13 +5415,13 @@ void EdenGame::panelrestart() { _globals->_currMusicNum = 0; startmusique(curmus); } - fadeToBlack(3); + _graphics->fadeToBlack(3); CLBlitter_FillScreenView(0); - CLBlitter_FillView(_mainView, 0); + CLBlitter_FillView(_graphics->getMainView(), 0); drawTopScreen(); showObjects(); saveFriezes(); - _showBlackBars = true; + _graphics->setShowBlackBars(true); updateRoom(_globals->_roomNum); } @@ -5409,7 +5435,7 @@ void EdenGame::confirmer(char mode, char yesId) { _gameIcons[119]._objectId = yesId; _confirmMode = mode; useBank(65); - drawSprite(12, 117, 74); + _graphics->drawSprite(12, 117, 74); _cursorPosX = 156; if (_vm->shouldQuit()) _cursorPosX = 136; @@ -5451,7 +5477,7 @@ void EdenGame::choseSubtitleOption() { if (lang > 5) return; _globals->_prefLanguage = lang; - langbuftopanel(); + _graphics->langbuftopanel(); displayLanguage(); } @@ -5476,7 +5502,7 @@ void EdenGame::changervol() { newvol(_curSliderValuePtr, delta); if (_globals->_menuFlags & MenuFlags::mfFlag2) newvol(_curSliderValuePtr + 1, delta); - cursbuftopanel(); + _graphics->cursbuftopanel(); displayCursors(); _curSliderY = _cursorPosY; } else @@ -5569,16 +5595,28 @@ void EdenGame::moveTapeCursor() { _globals->_menuFlags &= ~MenuFlags::mfFlag4; } +void EdenGame::setCursorSaved(bool cursorSaved) { + _cursorSaved = cursorSaved; +} + +bool EdenGame::getCursorSaved() { + return _cursorSaved; +} + +bool EdenGame::getNoPalette() { + return _noPalette; +} + // Original name: affcurstape void EdenGame::displayTapeCursor() { if (_globals->_drawFlags & DrawFlags::drDrawFlag8) _noPalette = true; useBank(65); - drawSprite(2, 0, 176); + _graphics->drawSprite(2, 0, 176); int x = (_globals->_tapePtr - _tapes) * 8 + 97; _gameIcons[112].sx = x - 3; _gameIcons[112].ex = x + 3; - drawSprite(5, x, 179); + _graphics->drawSprite(5, x, 179); _noPalette = false; } @@ -5610,29 +5648,11 @@ void EdenGame::clickTapeCursor() { _globals->_menuFlags |= MenuFlags::mfFlag4; } -void EdenGame::paneltobuf() { - setSrcRect(0, 16, 320 - 1, 169 - 1); - setDestRect(320, 16, 640 - 1, 169 - 1); - CLBlitter_CopyViewRect(_mainView, _mainView, &rect_src, &rect_dst); -} - -void EdenGame::cursbuftopanel() { - setSrcRect(434, 40, 525 - 1, 111 - 1); - setDestRect(114, 40, 205 - 1, 111 - 1); - CLBlitter_CopyViewRect(_mainView, _mainView, &rect_src, &rect_dst); -} - -void EdenGame::langbuftopanel() { - setSrcRect(328, 42, 407 - 1, 97 - 1); - setDestRect(8, 42, 87 - 1, 97 - 1); - CLBlitter_CopyViewRect(_mainView, _mainView, &rect_src, &rect_dst); -} - // Original name: affpanel void EdenGame::displayPanel() { useBank(65); - drawSprite(0, 0, 16); - paneltobuf(); + _graphics->drawSprite(0, 0, 16); + _graphics->paneltobuf(); displayLanguage(); displayCursors(); displayTapeCursor(); @@ -5643,8 +5663,8 @@ void EdenGame::displayLanguage() { useBank(65); if (_globals->_prefLanguage > 5) return; - drawSprite(6, 8, _globals->_prefLanguage * 9 + 43); //TODO: * FONT_HEIGHT - drawSprite(7, 77, _globals->_prefLanguage * 9 + 44); + _graphics->drawSprite(6, 8, _globals->_prefLanguage * 9 + 43); //TODO: * FONT_HEIGHT + _graphics->drawSprite(7, 77, _globals->_prefLanguage * 9 + 44); } // Original name: affcursvol @@ -5652,11 +5672,11 @@ void EdenGame::displayVolCursor(int16 x, int16 vol1, int16 vol2) { int16 slider = 3; if (_lastMenuItemIdLo && (_lastMenuItemIdLo & 9) != 1) //TODO check me slider = 4; - drawSprite(slider, x, 104 - vol1); + _graphics->drawSprite(slider, x, 104 - vol1); slider = 3; if ((_lastMenuItemIdLo & 9) != 0) slider = 4; - drawSprite(slider, x + 12, 104 - vol2); + _graphics->drawSprite(slider, x + 12, 104 - vol2); } // Original name: affcurseurs @@ -5681,17 +5701,17 @@ void EdenGame::selectCursor(int itemId) { // Original name: afftoppano void EdenGame::displayTopPanel() { - drawSprite(1, 0, 0); + _graphics->drawSprite(1, 0, 0); } // Original name: affresult void EdenGame::displayResult() { - restoreUnderSubtitles(); + _graphics->restoreUnderSubtitles(); _globals->_characterPtr = &_persons[19]; _globals->_dialogType = DialogType::dtInspect; int16 num = (_persons[PER_UNKN_156]._id << 3) | _globals->_dialogType; if (dialoscansvmas((Dialog *)getElem(_gameDialogs, num))) - displaySubtitles(); + _graphics->displaySubtitles(); _globals->_varCA = 0; _globals->_dialogType = DialogType::dtTalk; _globals->_characterPtr = nullptr; @@ -7137,14 +7157,7 @@ void EdenGame::loadMap(int file_id, byte *buffer) { if (_vm->getPlatform() == Common::kPlatformMacintosh) { loadpartoffile(file_id, buffer, 32, 256 * 3); - for (int i = 0; i < 256; i++) { - color3_t color; - color.r = buffer[i * 3] << 8; - color.g = buffer[i * 3 + 1] << 8; - color.b = buffer[i * 3 + 2] << 8; - CLPalette_SetRGBColor(_globalPalette, i, &color); - } - CLPalette_Send2Screen(_globalPalette, 0, 256); + _graphics->setPaletteColor(buffer); loadpartoffile(file_id, buffer, 32 + 256 * 3, 0x4000); } else { @@ -7391,7 +7404,7 @@ void EdenGame::displayPolygoneMapping(Cube *cubep, CubeFace *face) { ymin = MIN(r31, ymin); ymax = MAX(r31, ymax); drawMappingLine(r20, r30, r26, r31, r19, r18, r25, r24, _lines); - displayMappingLine(ymin, ymax, _mainView->_bufferPtr, face->_texturePtr); + displayMappingLine(ymin, ymax, _graphics->getMainView()->_bufferPtr, face->_texturePtr); } // Original name: trace_ligne_mapping @@ -7454,7 +7467,7 @@ void EdenGame::drawMappingLine(int16 r3, int16 r4, int16 r5, int16 r6, int16 r7, // Original name: affiche_ligne_mapping void EdenGame::displayMappingLine(int16 r3, int16 r4, byte *target, byte *texture) { int16 height = r4 - r3; - byte *trg_line = _mainView->_bufferPtr + r3 * 640; //TODO: target?? + byte *trg_line = _graphics->getMainView()->_bufferPtr + r3 * 640; //TODO: target?? int16 *line = &_lines[r3 * 8]; // debug("curs: beg draw %d - %d", r3, r4); for (int r22 = height; r22; r22--, line += 8, trg_line += 640) { @@ -7703,17 +7716,17 @@ void EdenGame::renderCube() { const int xshift = -5; // TODO: temporary fix to decrease left margin unsigned char *cur = _cursor; - unsigned char *scr = _mainView->_bufferPtr + _cursorPosX + _scrollPos + xshift + _cursorPosY * _mainView->_pitch; + unsigned char *scr = _graphics->getMainView()->_bufferPtr + _cursorPosX + _scrollPos + xshift + _cursorPosY * _graphics->getMainView()->_pitch; for (int y = 0; y < 40; y++) { for (int x = 0; x < 40; x++) { - if (x + _cursorPosX + _scrollPos + xshift < _mainView->_pitch && y + _cursorPosY < _mainView->_height) + if (x + _cursorPosX + _scrollPos + xshift < _graphics->getMainView()->_pitch && y + _cursorPosY < _graphics->getMainView()->_height) if (*cur) *scr = *cur; scr++; cur++; } - scr += _mainView->_pitch - 40; + scr += _graphics->getMainView()->_pitch - 40; } } diff --git a/engines/cryo/eden.h b/engines/cryo/eden.h index dcf101ce75..f2983e80c3 100644 --- a/engines/cryo/eden.h +++ b/engines/cryo/eden.h @@ -40,17 +40,80 @@ enum Direction { namespace Cryo { class CryoEngine; +class EdenGraphics; class EdenGame { private: - CryoEngine *_vm; + + EdenGraphics *_graphics; public: EdenGame(CryoEngine *vm); + ~EdenGame(); void run(); object_t *getObjectPtr(int16 id); void showObjects(); + void saveFriezes(); + void useBank(int16 bank); + void musicspy(); + void fademusica0(int16 delay); + void wait(int howlong); + bool isObjectHere(int16 id); + void display(); + + void setMouseCenterX(uint16 xpos); + void setMouseCenterY(uint16 ypos); + + void stopMusic(); + + void setVolume(uint16 vol); + + uint16 getMouseCenterX(); + uint16 getMouseCenterY(); + + bool dialoscansvmas(Dialog *dial); + void musique(); + void preloadDialogs(int16 vid); + void loadHnm(uint16 num); + bool personIsTalking(); + bool animationIsActive(); + byte *getImageDesc(); + byte *getPlaceRawBuf(); + byte getActionCursor(byte value); + int16 getNumTextLines(); + int16 getScrollPos(); + /* + * Identify person based on current video number + */ + perso_t *personSubtitles(); + + int16 getGameIconY(int16 index); + int16 getGameIconX(int16 index); + + byte *getGameDialogs(); + + bool getSpecialTextMode(); + void setSpecialTextMode(bool value); + + void setCursorSaved(bool cursorSaved); + bool getCursorSaved(); + bool getNoPalette(); + int16 getCurBankNum(); + byte *getCurKeepBuf(); + byte *getBankData(); + int16 getCurPosX(); + void setCurPosX(int16 xpos); + int16 getCurPosY(); + void setCurPosY(int16 ypos); + byte *getGlowBuffer(); + void setMusicFade(byte value); + bool isMouseHeld(); + void setMouseHeld(); + void setMouseNotHeld(); + + global_t *_globals; // TODO: Make private and use getters + CryoEngine *_vm; private: void removeConsole(); @@ -110,29 +173,15 @@ private: void actionMoveEast(); void actionMoveSouth(); void actionMoveWest(); - void display(); + void afficher128(); - void saveFriezes(); - void saveTopFrieze(int16 x); - void saveBottomFrieze(); + + void restoreFriezes(); - void restoreTopFrieze(); - void restoreBottomFrieze(); + void useMainBank(); void useCharacterBank(); - void useBank(int16 bank); - void sundcurs(int16 x, int16 y); - void rundcurs(); - void drawSprite(int16 index, int16 x, int16 y, bool withBlack = false, bool onSubtitle = false); - void getglow(int16 x, int16 y, int16 w, int16 h); - void unglow(); - void glow(int16 index); - void readPalette(byte *ptr); - void hideBars(); - void showBars(); - void saveMouthBackground(); - void restoreMouthBackground(); - void drawBlackBars(); + void drawTopScreen(); void displayValleyMap(); void displayMapMark(int16 index, int16 location); @@ -170,7 +219,6 @@ private: void removeMouthSprite(); void AnimEndCharacter(); void setCharacterSprite(byte *spr); - void displayImage(); void displayCharacter1(); void displayCharacter(); void ef_perso(); @@ -192,10 +240,7 @@ private: void my_bulle(); void my_pr_bulle(); void drawSubtitleChar(byte c, byte color, int16 width); - void displaySubtitles(); - void saveUnderSubtitles(int16 y); - void restoreUnderSubtitles(); - void displayHNMSubtitle(); + void patchSentence(); void vavapers(); void citadelle(); @@ -258,34 +303,20 @@ private: void actionGotoMap(); void record(); bool dial_scan(Dialog *dial); - bool dialoscansvmas(Dialog *dial); + bool dialogEvent(perso_t *perso); void characterStayHere(); void endDeath(int16 vid); void chronoEvent(); void setChrono(int16 t); - void preloadDialogs(int16 vid); - void displayEffect1(); - void displayEffect2(); - void displayEffect3(); - void displayEffect4(); - void clearScreen(); - void colimacon(int16 pattern[16]); - void fadeToBlack(int delay); - void fadeToBlackLowPalette(int delay); - void fadeFromBlackLowPalette(int delay); - void blackRect32(); - void setSrcRect(int16 sx, int16 sy, int16 ex, int16 ey); - void setDestRect(int16 sx, int16 sy, int16 ex, int16 ey); - void wait(int howlong); - void effetpix(); + + void verifh(byte *ptr); void openbigfile(); void closebigfile(); void loadRawFile(uint16 num, byte *buffer); void loadIconFile(uint16 num, Icon *buffer); void loadRoomFile(uint16 num, Room *buffer); - void loadHnm(uint16 num); int loadSound(uint16 num); void convertMacToPC(); void loadpermfiles(); @@ -299,10 +330,8 @@ private: void removeInfo(byte info); void updateInfoList(); void initGlobals(); - void initRects(); + void closeRoom(); - void displaySingleRoom(Room *room); - void displayRoom(); void displayPlace(); void loadPlace(int16 num); void specialoutside(); @@ -317,7 +346,6 @@ private: void updateRoom(uint16 roomNum); void allocateBuffers(); void freebuf(); - void openWindow(); void EmergencyExit(); void edmain(); void intro(); @@ -327,22 +355,19 @@ private: Icon *scan_icon_list(int16 x, int16 y, int16 index); void updateCursor(); void mouse(); - void showMovie(char arg1); - void playHNM(int16 num); - void handleHNMSubtitles(); - void musique(); + void startmusique(byte num); - void musicspy(); + int loadmusicfile(int16 num); void persovox(); void endCharacterSpeech(); void fademusicup(); - void fademusica0(int16 delay); + void countObjects(); void winObject(int16 id); void loseObject(int16 id); void lostObject(); - bool isObjectHere(int16 id); + void objectmain(int16 id); void getObject(int16 id); void putObject(); @@ -381,9 +406,6 @@ private: void forwardTape(); void stopTape(); void clickTapeCursor(); - void paneltobuf(); - void cursbuftopanel(); - void langbuftopanel(); void displayPanel(); void displayLanguage(); void displayVolCursor(int16 x, int16 vol1, int16 vol2); @@ -557,24 +579,16 @@ private: byte _oldPix[8]; Common::Point _adamMapMarkPos; byte _cursKeepBuf[2500]; - Common::Point _cursKeepPos; bool _torchCursor; int16 _curBankNum; - int16 _glowX; - int16 _glowY; - int16 _glowW; - int16 _glowH; bool _paletteUpdateRequired; bool _cursorSaved; - bool _showBlackBars; bool _backgroundSaved; byte *_bankData; - color_t _globalPalette[256]; //TODO palette_t perso_t *_tyranPtr; int _lastAnimFrameNumb; int _curAnimFrameNumb; int _lastAnimTicks; - Common::Rect *_curCharacterRect; int16 _numAnimFrames; int16 _maxPersoDesc; int16 _numImgDesc; @@ -590,7 +604,6 @@ private: byte *_animationTable; byte _imageDesc[512]; byte *_characterBankData; - bool _savedUnderSubtitles; int16 _numTextLines; byte _sentenceBuffer[400]; byte phraseIconsBuffer[10]; @@ -607,14 +620,9 @@ private: char _lastPhrasesFile; byte _dialogSkipFlags; - color3_t newColor; - color_t oldPalette[256]; // TODO palette_t ? - color_t newPalette[256]; - Common::Rect rect_dst, rect_src; byte *_voiceSamplesBuffer; //TODO: sound sample buffer Common::File _bigfile; byte _infoList[16]; - bool _needToFade; byte *_mainBankBuf; byte *_musicBuf; byte *_gameLipsync; @@ -627,12 +635,9 @@ private: Room *_gameRooms; PakHeaderNode *_bigfileHeader; byte *_glowBuffer; - byte *_mainViewBuf; - byte *_view2Buf; + byte *_gameFont; //TODO: rename to font? - byte *_subtitlesViewBuf; - byte *_underSubtitlesViewBuf; // CHECKME: Useless? - global_t *_globals; + uint16 _mouseCenterX; uint16 _mouseCenterY; bool _bufferAllocationErrorFl; @@ -646,18 +651,6 @@ private: CSoundChannel *_hnmSoundChannel; Sound *_voiceSound; - View *_view2; - View *_underSubtitlesView; - View *_subtitlesView; - View *_underBarsView; - View *_mainView; - View *_hnmView; - Common::Rect _underSubtitlesBackupRect; - Common::Rect _underSubtitlesScreenRect; - Common::Rect _underBottomBarBackupRect; - Common::Rect _underBottomBarScreenRect; - Common::Rect _underTopBarBackupRect; - Common::Rect _underTopBarScreenRect; int _demoCurrentTicks; int _demoStartTicks; int _currentTime; @@ -670,11 +663,8 @@ private: Icon *_curSpot2; bool _mouseHeld; bool _normalCursor; - byte *_hnmViewBuf; - bool _showVideoSubtitle; - bool _videoCanceledFlag; //TODO: hnm_canceled + bool _specialTextMode; - int _hnmFrameNum; int _voiceSamplesSize; //TODO: perso vox sample data len int16 _musicRightVol; int16 _musicLeftVol; diff --git a/engines/cryo/graphics.cpp b/engines/cryo/eden_graphics.cpp index 51cb818f3e..cec2a0af3b 100644 --- a/engines/cryo/graphics.cpp +++ b/engines/cryo/eden_graphics.cpp @@ -20,22 +20,89 @@ * */ -#include "cryo/defs.h" #include "cryo/cryo.h" #include "cryo/platdefs.h" #include "cryo/cryolib.h" #include "cryo/eden.h" #include "cryo/sound.h" +#include "cryo/eden_graphics.h" +#include "cryo/video.h" namespace Cryo { +EdenGraphics::EdenGraphics(EdenGame *game, HnmPlayer *video) : _game(game), _video(video) { + _glowH = _glowW = _glowY = _glowX = 0; + _showVideoSubtitle = false; + _showBlackBars = false; + _mainView = nullptr; + _mainViewBuf = nullptr; + _hnmView = nullptr; + _view2 = nullptr; + _view2Buf = nullptr; + _curCharacterRect = nullptr; + _subtitlesViewBuf = nullptr; + _underSubtitlesView = nullptr; + _subtitlesView = nullptr; + _underBarsView = nullptr; + _needToFade = false; +} + +void EdenGraphics::SendPalette2Screen(int16 value) { + CLPalette_Send2Screen(_globalPalette, 0, value); +} + +void EdenGraphics::setFade(bool value) { + _needToFade = value; +} + +bool EdenGraphics::getFade() { + return _needToFade; +} + +void EdenGraphics::setPaletteColor(byte *buffer) { + for (int i = 0; i < 256; i++) { + color3_t color; + color.r = buffer[i * 3] << 8; + color.g = buffer[i * 3 + 1] << 8; + color.b = buffer[i * 3 + 2] << 8; + CLPalette_SetRGBColor(_globalPalette, i, &color); + } + SendPalette2Screen(256); +} + +void EdenGraphics::readPalette(byte *ptr) { + bool doit = true; + color3_t pal_entry; + while (doit) { + uint16 idx = *ptr++; + if (idx != 0xFF) { + uint16 cnt = *ptr++; + while (cnt--) { + if (idx == 0) { + pal_entry.r = 0; + pal_entry.g = 0; + pal_entry.b = 0; + ptr += 3; + } else { + pal_entry.r = *ptr++ << 10; + pal_entry.g = *ptr++ << 10; + pal_entry.b = *ptr++ << 10; + } + CLPalette_SetRGBColor(_globalPalette, idx, &pal_entry); + idx++; + } + } else + doit = false; + } +} + // Original name: noclipax -void EdenGame::drawSprite(int16 index, int16 x, int16 y, bool withBlack, bool onSubtitle) { +void EdenGraphics::drawSprite(int16 index, int16 x, int16 y, bool withBlack, bool onSubtitle) { uint16 width = (!onSubtitle) ? 640 : _subtitlesXWidth; - byte *pix = _bankData; + byte *pix = _game->getBankData(); byte *buf = (!onSubtitle) ? _mainViewBuf : _subtitlesViewBuf; byte *scr = buf + x + y * width; - if (_curBankNum != 117 && (!_noPalette || withBlack || onSubtitle)) { + if (_game->getCurBankNum() != 117 && (!_game->getNoPalette() || withBlack || onSubtitle)) { if (READ_LE_UINT16(pix) > 2) readPalette(pix + 2); } @@ -115,8 +182,77 @@ void EdenGame::drawSprite(int16 index, int16 x, int16 y, bool withBlack, bool on } } -void EdenGame::sundcurs(int16 x, int16 y) { - byte *keep = _cursKeepBuf; +void EdenGraphics::setCursKeepPos(int16 x, int16 y) { + _cursKeepPos = Common::Point(-1, -1); +} + +byte *EdenGraphics::getSubtitlesViewBuf() { + return _subtitlesViewBuf; +} + +View *EdenGraphics::getSubtitlesView() { + return _subtitlesView; +} + +void EdenGraphics::loadMouthRectFromCurChar() { + _rect_src.left = _curCharacterRect->left; + _rect_src.top = _curCharacterRect->top; + _rect_src.right = _curCharacterRect->right; + _rect_src.bottom = _curCharacterRect->bottom; + _rect_dst.left = _curCharacterRect->left + 320; + _rect_dst.top = _curCharacterRect->top; + _rect_dst.right = _curCharacterRect->right + 320; + _rect_dst.bottom = _curCharacterRect->bottom; +} + +void EdenGraphics::paneltobuf() { + setSrcRect(0, 16, 320 - 1, 169 - 1); + setDestRect(320, 16, 640 - 1, 169 - 1); + CLBlitter_CopyViewRect(getMainView(), getMainView(), &_rect_src, &_rect_dst); +} + +void EdenGraphics::cursbuftopanel() { + setSrcRect(434, 40, 525 - 1, 111 - 1); + setDestRect(114, 40, 205 - 1, 111 - 1); + CLBlitter_CopyViewRect(getMainView(), getMainView(), &_rect_src, &_rect_dst); +} + +void EdenGraphics::langbuftopanel() { + setSrcRect(328, 42, 407 - 1, 97 - 1); + setDestRect(8, 42, 87 - 1, 97 - 1); + CLBlitter_CopyViewRect(getMainView(), getMainView(), &_rect_src, &_rect_dst); +} + +// Original name: sauvefondbouche +void EdenGraphics::saveMouthBackground() { + loadMouthRectFromCurChar(); + CLBlitter_CopyViewRect(getMainView(), getMainView(), &_rect_src, &_rect_dst); +} + +// Original name: restaurefondbouche +void EdenGraphics::restoreMouthBackground() { + loadMouthRectFromCurChar(); + CLBlitter_CopyViewRect(getMainView(), getMainView(), &_rect_dst, &_rect_src); +} + +void EdenGraphics::setGlowX(int16 value) { + _glowX = value; +} + +View *EdenGraphics::getMainView() { + return _mainView; +} + +void EdenGraphics::setGlowY(int16 value) { + _glowY = value; +} + +void EdenGraphics::setCurCharRect(Common::Rect * charRect) { + _curCharacterRect = charRect; +} + +void EdenGraphics::sundcurs(int16 x, int16 y) { + byte *keep = _game->getCurKeepBuf(); x = CLIP<int16>(x - 4, 0, 640 - 48); y = CLIP<int16>(y - 4, 0, 200 - 48); _cursKeepPos = Common::Point(x, y); @@ -126,13 +262,13 @@ void EdenGame::sundcurs(int16 x, int16 y) { *keep++ = *scr++; scr += 640 - 48; } - _cursorSaved = true; + _game->setCursorSaved(true);; } -void EdenGame::rundcurs() { - byte *keep = _cursKeepBuf; +void EdenGraphics::rundcurs() { + byte *keep = _game->getCurKeepBuf(); byte *scr = _mainViewBuf + _cursKeepPos.x + _cursKeepPos.y * 640; - if (!_cursorSaved || (_cursKeepPos == Common::Point(-1, -1))) //TODO ... + if (!_game->getCursorSaved() || (_cursKeepPos == Common::Point(-1, -1))) //TODO ... return; for (int16 h = 48; h--;) { @@ -142,9 +278,13 @@ void EdenGame::rundcurs() { } } -void EdenGame::getglow(int16 x, int16 y, int16 w, int16 h) { +byte * EdenGraphics::getHnmViewBuf() { + return _hnmViewBuf; +} + +void EdenGraphics::getglow(int16 x, int16 y, int16 w, int16 h) { byte *scr = _mainViewBuf + x + y * 640; - byte *gl = _glowBuffer; + byte *gl = _game->getGlowBuffer(); _glowX = x; _glowY = y; _glowW = w; @@ -156,8 +296,8 @@ void EdenGame::getglow(int16 x, int16 y, int16 w, int16 h) { } } -void EdenGame::unglow() { - byte *gl = _glowBuffer; +void EdenGraphics::unglow() { + byte *gl = _game->getGlowBuffer(); byte *scr = _mainViewBuf + _glowX + _glowY * 640; if (_glowX < 0 || _glowY < 0) //TODO: move it up return; @@ -168,9 +308,9 @@ void EdenGame::unglow() { } } -void EdenGame::glow(int16 index) { +void EdenGraphics::glow(int16 index) { // byte pixbase; - byte *pix = _bankData; + byte *pix = _game->getBankData(); index += 9; pix += READ_LE_UINT16(pix); @@ -186,9 +326,9 @@ void EdenGame::glow(int16 index) { if (mode != 0xFF && mode != 0xFE) return; - int16 x = _cursorPosX + _scrollPos - 38; - int16 y = _cursorPosY - 28; - int16 ex = _globals->_frescoeWidth + 320; + int16 x = _game->getCurPosX() + _game->getScrollPos() - 38; + int16 y = _game->getCurPosY() - 28; + int16 ex = _game->_globals->_frescoeWidth + 320; if (x + w <= 0 || x >= ex || y + h <= 0 || y >= 176) return; @@ -239,7 +379,7 @@ void EdenGame::glow(int16 index) { } // Original name : blackbars -void EdenGame::drawBlackBars() { +void EdenGraphics::drawBlackBars() { byte *scr = _mainViewBuf; for (int16 y = 0; y < 16; y++) { for (int16 x = 0; x < 640; x++) @@ -253,14 +393,21 @@ void EdenGame::drawBlackBars() { } } +// Original name: restaurefriseshaut +void EdenGraphics::restoreTopFrieze() { + _underTopBarScreenRect.left = _game->getScrollPos(); + _underTopBarScreenRect.right = _game->getScrollPos() + 320 - 1; + CLBlitter_CopyViewRect(_underBarsView, getMainView(), &_underTopBarBackupRect, &_underTopBarScreenRect); +} + // Original name: bars_out -void EdenGame::hideBars() { +void EdenGraphics::hideBars() { if (_showBlackBars) return; - display(); - _underTopBarScreenRect.left = _scrollPos; - _underTopBarScreenRect.right = _scrollPos + 320 - 1; + _game->display(); + _underTopBarScreenRect.left = _game->getScrollPos(); + _underTopBarScreenRect.right = _game->getScrollPos() + 320 - 1; CLBlitter_CopyViewRect(_mainView, _underBarsView, &_underTopBarScreenRect, &_underTopBarBackupRect); _underBottomBarScreenRect.left = _underTopBarScreenRect.left; _underBottomBarScreenRect.right = _underTopBarScreenRect.right; @@ -271,8 +418,8 @@ void EdenGame::hideBars() { int16 r24 = 21; _underTopBarScreenRect.left = 0; _underTopBarScreenRect.right = 320 - 1; - _underTopBarBackupRect.left = _scrollPos; - _underTopBarBackupRect.right = _scrollPos + 320 - 1; + _underTopBarBackupRect.left = _game->getScrollPos(); + _underTopBarBackupRect.right = _game->getScrollPos() + 320 - 1; unsigned int *scr40, *scr41, *scr42; while (r24 > 0) { if (r25 > 0) { @@ -305,7 +452,7 @@ void EdenGame::hideBars() { r20 += 3; r25 -= 2; r24 -= 3; - display(); + _game->display(); } scr40 = (unsigned int *)_mainViewBuf; scr41 = scr40 + 640 / 4; @@ -321,13 +468,20 @@ void EdenGame::hideBars() { *scr41++ = 0; *scr42++ = 0; } - display(); + _game->display(); initRects(); _showBlackBars = true; } +void EdenGraphics::initRects() { + _underTopBarScreenRect = Common::Rect(0, 0, 320 - 1, 16 - 1); + _underTopBarBackupRect = Common::Rect(0, 0, 320 - 1, 16 - 1); + _underBottomBarScreenRect = Common::Rect(0, 176, 320 - 1, 200 - 1); //TODO: original bug? this cause crash in copyrect (this, underBottomBarBackupRect) + _underBottomBarBackupRect = Common::Rect(0, 16, 320 - 1, 40 - 1); +} + // Original name: bars_in -void EdenGame::showBars() { +void EdenGraphics::showBars() { if (!_showBlackBars) return; @@ -336,8 +490,8 @@ void EdenGame::showBars() { int16 r28 = 2; _underTopBarScreenRect.left = 0; _underTopBarScreenRect.right = 320 - 1; - _underTopBarBackupRect.left = _scrollPos; - _underTopBarBackupRect.right = _scrollPos + 320 - 1; + _underTopBarBackupRect.left = _game->getScrollPos(); + _underTopBarBackupRect.right = _game->getScrollPos() + 320 - 1; while (r28 < 24) { if (r29 <= 16) { _underTopBarScreenRect.top = 16 - r29; @@ -353,22 +507,22 @@ void EdenGame::showBars() { CLBlitter_CopyViewRect(_underBarsView, _mainView, &_underTopBarScreenRect, &_underTopBarBackupRect); r29 += 2; r28 += 3; - display(); + _game->display(); } initRects(); _showBlackBars = false; } // Original name: af_image -void EdenGame::displayImage() { - byte *img = _imageDesc + 200; +void EdenGraphics::displayImage() { + byte *img = _game->getImageDesc() + 200; int16 count = READ_LE_UINT16(img); if (!count) return; byte *img_start = img; - byte *curimg = _imageDesc; + byte *curimg = _game->getImageDesc(); img += 2; count *= 3; @@ -380,9 +534,9 @@ void EdenGame::displayImage() { /////// draw it while (count--) { uint16 index = *img++; - uint16 x = *img++ + _gameIcons[0].sx; - uint16 y = *img++ + _gameIcons[0].sy; - byte *pix = _bankData; + uint16 x = *img++ + _game->getGameIconX(0); + uint16 y = *img++ + _game->getGameIconY(0); + byte *pix = _game->getBankData(); byte *scr = _mainViewBuf + x + y * 640; index--; if (READ_LE_UINT16(pix) > 2) @@ -464,24 +618,24 @@ void EdenGame::displayImage() { } // Original name: af_subtitle -void EdenGame::displaySubtitles() { +void EdenGraphics::displaySubtitles() { byte *src = _subtitlesViewBuf; byte *dst = _mainViewBuf; int16 y; - if (_globals->_displayFlags & DisplayFlags::dfFlag2) { + if (_game->_globals->_displayFlags & DisplayFlags::dfFlag2) { y = 174; - if ((_globals->_drawFlags & DrawFlags::drDrawMenu) && _numTextLines == 1) + if ((_game->_globals->_drawFlags & DrawFlags::drDrawMenu) && _game->getNumTextLines() == 1) y = 167; - dst += 640 * (y - _numTextLines * FONT_HEIGHT) + _subtitlesXScrMargin; + dst += 640 * (y - _game->getNumTextLines() * FONT_HEIGHT) + _subtitlesXScrMargin; } else { y = 174; - dst += 640 * (y - _numTextLines * FONT_HEIGHT) + _scrollPos + _subtitlesXScrMargin; + dst += 640 * (y - _game->getNumTextLines() * FONT_HEIGHT) + _game->getScrollPos() + _subtitlesXScrMargin; } - if (_animationActive && !_personTalking) + if (_game->animationIsActive() && !_game->personIsTalking()) return; saveUnderSubtitles(y); - for (int16 h = 0; h < _numTextLines * FONT_HEIGHT + 1; h++) { + for (int16 h = 0; h < _game->getNumTextLines() * FONT_HEIGHT + 1; h++) { for (int16 w = 0; w < _subtitlesXWidth; w++) { byte c = *src++; if (c) @@ -493,8 +647,8 @@ void EdenGame::displaySubtitles() { } // Original name afsalle1 -void EdenGame::displaySingleRoom(Room *room) { - byte *ptr = (byte *)getElem(_placeRawBuf, room->_id - 1); +void EdenGraphics::displaySingleRoom(Room *room) { + byte *ptr = (byte *)getElem(_game->getPlaceRawBuf(), room->_id - 1); ptr++; for (;;) { byte b0 = *ptr++; @@ -507,30 +661,30 @@ void EdenGame::displaySingleRoom(Room *room) { int16 y = *ptr++; ptr++; index &= 0x1FF; - if (!(_globals->_displayFlags & 0x80)) { - if (index == 1 || _globals->_varF7) + if (!(_game->_globals->_displayFlags & 0x80)) { + if (index == 1 || _game->_globals->_varF7) drawSprite(index - 1, x, y, true); } - _globals->_varF7 = 0; + _game->_globals->_varF7 = 0; continue; } if (b1 & 0x40) { if (b1 & 0x20) { bool addIcon = false; - Icon *icon = _globals->_nextRoomIcon; + Icon *icon = _game->_globals->_nextRoomIcon; if (b0 < 4) { - if (_globals->_roomPtr->_exits[b0]) + if (_game->_globals->_roomPtr->_exits[b0]) addIcon = true; } else if (b0 > 229) { - if (_globals->_partyOutside & (1 << (b0 - 230))) + if (_game->_globals->_partyOutside & (1 << (b0 - 230))) addIcon = true; } else if (b0 >= 100) { debug("add object %d", b0 - 100); - if (isObjectHere(b0 - 100)) { + if (_game->isObjectHere(b0 - 100)) { addIcon = true; - _globals->_varF7 = 1; + _game->_globals->_varF7 = 1; } } else @@ -538,7 +692,7 @@ void EdenGame::displaySingleRoom(Room *room) { if (addIcon) { icon->_actionId = b0; icon->_objectId = b0; - icon->_cursorId = _actionCursors[b0]; + icon->_cursorId = _game->getActionCursor(b0); int16 x = READ_LE_UINT16(ptr); ptr += 2; int16 y = READ_LE_UINT16(ptr); @@ -547,11 +701,11 @@ void EdenGame::displaySingleRoom(Room *room) { ptr += 2; int16 ey = READ_LE_UINT16(ptr); ptr += 2; - x += _globals->_roomBaseX; - ex += _globals->_roomBaseX; + x += _game->_globals->_roomBaseX; + ex += _game->_globals->_roomBaseX; debug("add hotspot at %3d:%3d - %3d:%3d, action = %d", x, y, ex, ey, b0); - if (_vm->_showHotspots) { + if (_game->_vm->_showHotspots) { for (int iii = x; iii < ex; iii++) _mainViewBuf[y * 640 + iii] = _mainViewBuf[ey * 640 + iii] = (iii % 2) ? 0 : 255; for (int iii = y; iii < ey; iii++) @@ -562,7 +716,7 @@ void EdenGame::displaySingleRoom(Room *room) { icon->sy = y; icon->ex = ex; icon->ey = ey; - _globals->_nextRoomIcon = ++icon; + _game->_globals->_nextRoomIcon = ++icon; icon->sx = -1; } else @@ -576,26 +730,47 @@ void EdenGame::displaySingleRoom(Room *room) { } } +// Original name: restaurefrisesbas +void EdenGraphics::restoreBottomFrieze() { + _underBottomBarScreenRect.left = _game->getScrollPos(); + _underBottomBarScreenRect.right = _game->getScrollPos() + 320 - 1; + CLBlitter_CopyViewRect(_underBarsView, getMainView(), &_underBottomBarBackupRect, &_underBottomBarScreenRect); +} + +// Original name: sauvefriseshaut +void EdenGraphics::saveTopFrieze(int16 x) { // Save top bar + _underTopBarScreenRect = Common::Rect(x, 0, x + 320 - 1, 15); + _underTopBarBackupRect = Common::Rect(0, 0, 320 - 1, 15); + CLBlitter_CopyViewRect(getMainView(), _underBarsView, &_underTopBarScreenRect, &_underTopBarBackupRect); +} + +// Original name: sauvefrisesbas +void EdenGraphics::saveBottomFrieze() { // Save bottom bar + _underBottomBarScreenRect.left = 0; + _underBottomBarScreenRect.right = 320 - 1; + CLBlitter_CopyViewRect(getMainView(), _underBarsView, &_underBottomBarScreenRect, &_underBottomBarBackupRect); +} + // Original name: afsalle -void EdenGame::displayRoom() { - Room *room = _globals->_roomPtr; - _globals->_displayFlags = DisplayFlags::dfFlag1; - _globals->_roomBaseX = 0; - _globals->_roomBackgroundBankNum = room->_backgroundBankNum; +void EdenGraphics::displayRoom() { + Room *room = _game->_globals->_roomPtr; + _game->_globals->_displayFlags = DisplayFlags::dfFlag1; + _game->_globals->_roomBaseX = 0; + _game->_globals->_roomBackgroundBankNum = room->_backgroundBankNum; if (room->_flags & RoomFlags::rf08) { - _globals->_displayFlags |= DisplayFlags::dfFlag80; + _game->_globals->_displayFlags |= DisplayFlags::dfFlag80; if (room->_flags & RoomFlags::rfPanable) { // Scrollable room on 2 screens - _globals->_displayFlags |= DisplayFlags::dfPanable; - _globals->_varF4 = 0; + _game->_globals->_displayFlags |= DisplayFlags::dfPanable; + _game->_globals->_varF4 = 0; rundcurs(); - saveFriezes(); - useBank(room->_bank - 1); + _game->saveFriezes(); + _game->useBank(room->_bank - 1); drawSprite(0, 0, 16, true); - useBank(room->_bank); + _game->useBank(room->_bank); drawSprite(0, 320, 16, true); displaySingleRoom(room); - _globals->_roomBaseX = 320; + _game->_globals->_roomBaseX = 320; displaySingleRoom(room + 1); } else @@ -603,15 +778,19 @@ void EdenGame::displayRoom() { } else { //TODO: roomImgBank is garbage here! - debug("displayRoom: room 0x%X using bank %d", _globals->_roomNum, _globals->_roomImgBank); - useBank(_globals->_roomImgBank); + debug("displayRoom: room 0x%X using bank %d", _game->_globals->_roomNum, _game->_globals->_roomImgBank); + _game->useBank(_game->_globals->_roomImgBank); displaySingleRoom(room); - assert(_vm->_screenView->_pitch == 320); + assert(_game->_vm->_screenView->_pitch == 320); } } -void EdenGame::openWindow() { - _underBarsView = new View(320, 40); +View *EdenGraphics::getUnderBarsView() { + return _underBarsView; +} + +void EdenGraphics::openWindow() { + _underBarsView = new View(320, 40); //TODO: Who deletes these? _underBarsView->_normal._width = 320; _view2 = new View(32, 32); @@ -628,32 +807,32 @@ void EdenGame::openWindow() { CLBlitter_FillView(_mainView, 0xFFFFFFFF); _mainView->setSrcZoomValues(0, 0); _mainView->setDisplayZoomValues(640, 400); - _mainView->centerIn(_vm->_screenView); + _mainView->centerIn(_game->_vm->_screenView); _mainViewBuf = _mainView->_bufferPtr; - _mouseCenterX = _mainView->_normal._dstLeft + _mainView->_normal._width / 2; - _mouseCenterY = _mainView->_normal._dstTop + _mainView->_normal._height / 2; - _vm->setMousePosition(_mouseCenterX, _mouseCenterY); - _vm->hideMouse(); + _game->setMouseCenterX(_mainView->_normal._dstLeft + _mainView->_normal._width / 2); + _game->setMouseCenterY(_mainView->_normal._dstTop + _mainView->_normal._height / 2); + _game->_vm->setMousePosition(_game->getMouseCenterX(), _game->getMouseCenterY()); + _game->_vm->hideMouse(); - _cursorPosX = 320 / 2; - _cursorPosY = 200 / 2; + _game->setCurPosX(320 / 2); + _game->setCurPosY(200 / 2); } // Original name: effet1 -void EdenGame::displayEffect1() { +void EdenGraphics::displayEffect1() { blackRect32(); setSrcRect(0, 0, 16 - 1, 4 - 1); int y = _mainView->_normal._dstTop; for (int16 i = 16; i <= 96; i += 4) { for (int x = _mainView->_normal._dstLeft; x < _mainView->_normal._dstLeft + 320; x += 16) { setDestRect(x, y + i, x + 16 - 1, y + i + 4 - 1); - CLBlitter_CopyViewRect(_view2, _vm->_screenView, &rect_src, &rect_dst); + CLBlitter_CopyViewRect(_view2, _game->_vm->_screenView, &_rect_src, &_rect_dst); setDestRect(x, y + 192 - i, x + 16 - 1, y + 192 - i + 4 - 1); - CLBlitter_CopyViewRect(_view2, _vm->_screenView, &rect_src, &rect_dst); + CLBlitter_CopyViewRect(_view2, _game->_vm->_screenView, &_rect_src, &_rect_dst); } CLBlitter_UpdateScreen(); - wait(1); + _game->wait(1); } CLPalette_Send2Screen(_globalPalette, 0, 256); _mainView->_normal._height = 2; @@ -672,7 +851,7 @@ void EdenGame::displayEffect1() { _mainView->_zoom._dstTop = (100 + i) * 2 + dy; CLBlitter_CopyView2Screen(_mainView); CLBlitter_UpdateScreen(); - wait(1); + _game->wait(1); } _mainView->_normal._height = 200; _mainView->_zoom._height = 400; @@ -680,18 +859,18 @@ void EdenGame::displayEffect1() { _mainView->_zoom._srcTop = 0; _mainView->_normal._dstTop = ny; _mainView->_zoom._dstTop = dy; - _globals->_varF1 = 0; + _game->_globals->_varF1 = 0; } // Original name: effet2 -void EdenGame::displayEffect2() { +void EdenGraphics::displayEffect2() { static int16 pattern1[] = { 0, 1, 2, 3, 7, 11, 15, 14, 13, 12, 8, 4, 5, 6, 10, 9 }; static int16 pattern2[] = { 0, 15, 1, 14, 2, 13, 3, 12, 7, 8, 11, 4, 5, 10, 6, 9 }; static int16 pattern3[] = { 0, 2, 5, 7, 8, 10, 13, 15, 1, 3, 4, 6, 9, 11, 12, 14 }; static int16 pattern4[] = { 0, 3, 15, 12, 1, 7, 14, 8, 2, 11, 13, 4, 5, 6, 10, 9 }; static int eff2pat = 0; - if (_globals->_var103 == 69) { + if (_game->_globals->_var103 == 69) { displayEffect4(); return; } @@ -713,42 +892,42 @@ void EdenGame::displayEffect2() { } // Original name: effet3 -void EdenGame::displayEffect3() { - CLPalette_GetLastPalette(oldPalette); +void EdenGraphics::displayEffect3() { + CLPalette_GetLastPalette(_oldPalette); for (uint16 i = 0; i < 6; i++) { for (uint16 c = 0; c < 256; c++) { - newColor.r = oldPalette[c].r >> i; - newColor.g = oldPalette[c].g >> i; - newColor.b = oldPalette[c].b >> i; - CLPalette_SetRGBColor(newPalette, c, &newColor); + _newColor.r = _oldPalette[c].r >> i; + _newColor.g = _oldPalette[c].g >> i; + _newColor.b = _oldPalette[c].b >> i; + CLPalette_SetRGBColor(_newPalette, c, &_newColor); } - CLPalette_Send2Screen(newPalette, 0, 256); - wait(1); + CLPalette_Send2Screen(_newPalette, 0, 256); + _game->wait(1); } CLBlitter_CopyView2Screen(_mainView); for (uint16 i = 0; i < 6; i++) { for (uint16 c = 0; c < 256; c++) { - newColor.r = _globalPalette[c].r >> (5 - i); - newColor.g = _globalPalette[c].g >> (5 - i); - newColor.b = _globalPalette[c].b >> (5 - i); - CLPalette_SetRGBColor(newPalette, c, &newColor); + _newColor.r = _globalPalette[c].r >> (5 - i); + _newColor.g = _globalPalette[c].g >> (5 - i); + _newColor.b = _globalPalette[c].b >> (5 - i); + CLPalette_SetRGBColor(_newPalette, c, &_newColor); } - CLPalette_Send2Screen(newPalette, 0, 256); - wait(1); + CLPalette_Send2Screen(_newPalette, 0, 256); + _game->wait(1); } } // Original name: effet4 -void EdenGame::displayEffect4() { +void EdenGraphics::displayEffect4() { byte *scr, *pix, *r24, *r25, *r30, c; int16 r17, r23, r16, r18, r19, r22, r27, r31; CLPalette_Send2Screen(_globalPalette, 0, 256); - int16 ww = _vm->_screenView->_pitch; + int16 ww = _game->_vm->_screenView->_pitch; int16 x = _mainView->_normal._dstLeft; int16 y = _mainView->_normal._dstTop; for (int16 i = 32; i > 0; i -= 2) { - scr = _vm->_screenView->_bufferPtr; + scr = _game->_vm->_screenView->_bufferPtr; scr += (y + 16) * ww + x; pix = _mainView->_bufferPtr + 16 * 640; r17 = 320 / i; @@ -806,16 +985,16 @@ void EdenGame::displayEffect4() { } } CLBlitter_UpdateScreen(); - wait(3); + _game->wait(3); } CLBlitter_CopyView2Screen(_mainView); } -void EdenGame::clearScreen() { - int16 ww = _vm->_screenView->_pitch; +void EdenGraphics::clearScreen() { + int16 ww = _game->_vm->_screenView->_pitch; int16 x = _mainView->_normal._dstLeft; int16 y = _mainView->_normal._dstTop; - byte *scr = _vm->_screenView->_bufferPtr; + byte *scr = _game->_vm->_screenView->_bufferPtr; scr += (y + 16) * ww + x; for (int16 yy = 0; yy < 160; yy++) { for (int16 xx = 0; xx < 320; xx++) @@ -825,13 +1004,13 @@ void EdenGame::clearScreen() { CLBlitter_UpdateScreen(); } -void EdenGame::colimacon(int16 pattern[16]) { +void EdenGraphics::colimacon(int16 pattern[16]) { int16 p, r27, r25; - int16 ww = _vm->_screenView->_pitch; + int16 ww = _game->_vm->_screenView->_pitch; int16 x = _mainView->_normal._dstLeft; int16 y = _mainView->_normal._dstTop; - byte *scr = _vm->_screenView->_bufferPtr; + byte *scr = _game->_vm->_screenView->_bufferPtr; scr += (y + 16) * ww + x; for (int16 i = 0; i < 16; i++) { p = pattern[i]; @@ -839,14 +1018,14 @@ void EdenGame::colimacon(int16 pattern[16]) { for (int16 j = 0; j < 320 * 160 / 16; j++) scr[j / (320 / 4) * ww * 4 + j % (320 / 4) * 4 + r27] = 0; CLBlitter_UpdateScreen(); - wait(1); + _game->wait(1); } CLPalette_Send2Screen(_globalPalette, 0, 256); byte *pix = _mainView->_bufferPtr; x = _mainView->_normal._dstLeft; y = _mainView->_normal._dstTop; pix += 640 * 16; - scr = _vm->_screenView->_bufferPtr; + scr = _game->_vm->_screenView->_bufferPtr; scr += (y + 16) * ww + x; for (int16 i = 0; i < 16; i++) { p = pattern[i]; @@ -856,55 +1035,55 @@ void EdenGame::colimacon(int16 pattern[16]) { scr[j / (320 / 4) * ww * 4 + j % (320 / 4) * 4 + r27] = pix[j / (320 / 4) * 640 * 4 + j % (320 / 4) * 4 + r25]; CLBlitter_UpdateScreen(); - wait(1); + _game->wait(1); } } -void EdenGame::fadeToBlack(int delay) { - CLPalette_GetLastPalette(oldPalette); +void EdenGraphics::fadeToBlack(int delay) { + CLPalette_GetLastPalette(_oldPalette); for (int16 i = 0; i < 6; i++) { for (int16 j = 0; j < 256; j++) { - newColor.r = oldPalette[j].r >> i; - newColor.g = oldPalette[j].g >> i; - newColor.b = oldPalette[j].b >> i; - CLPalette_SetRGBColor(newPalette, j, &newColor); + _newColor.r = _oldPalette[j].r >> i; + _newColor.g = _oldPalette[j].g >> i; + _newColor.b = _oldPalette[j].b >> i; + CLPalette_SetRGBColor(_newPalette, j, &_newColor); } - CLPalette_Send2Screen(newPalette, 0, 256); - wait(delay); + CLPalette_Send2Screen(_newPalette, 0, 256); + _game->wait(delay); } } // Original name: fadetoblack128 -void EdenGame::fadeToBlackLowPalette(int delay) { - CLPalette_GetLastPalette(oldPalette); +void EdenGraphics::fadeToBlackLowPalette(int delay) { + CLPalette_GetLastPalette(_oldPalette); for (int16 i = 0; i < 6; i++) { for (int16 j = 0; j < 129; j++) { //CHECKME: Should be 128? - newColor.r = oldPalette[j].r >> i; - newColor.g = oldPalette[j].g >> i; - newColor.b = oldPalette[j].b >> i; - CLPalette_SetRGBColor(newPalette, j, &newColor); + _newColor.r = _oldPalette[j].r >> i; + _newColor.g = _oldPalette[j].g >> i; + _newColor.b = _oldPalette[j].b >> i; + CLPalette_SetRGBColor(_newPalette, j, &_newColor); } - CLPalette_Send2Screen(newPalette, 0, 128); - wait(delay); + CLPalette_Send2Screen(_newPalette, 0, 128); + _game->wait(delay); } } // Original name: fadefromblack128 -void EdenGame::fadeFromBlackLowPalette(int delay) { +void EdenGraphics::fadeFromBlackLowPalette(int delay) { for (int16 i = 0; i < 6; i++) { for (int16 j = 0; j < 129; j++) { //CHECKME: Should be 128? - newColor.r = _globalPalette[j].r >> (5 - i); - newColor.g = _globalPalette[j].g >> (5 - i); - newColor.b = _globalPalette[j].b >> (5 - i); - CLPalette_SetRGBColor(newPalette, j, &newColor); + _newColor.r = _globalPalette[j].r >> (5 - i); + _newColor.g = _globalPalette[j].g >> (5 - i); + _newColor.b = _globalPalette[j].b >> (5 - i); + CLPalette_SetRGBColor(_newPalette, j, &_newColor); } - CLPalette_Send2Screen(newPalette, 0, 128); - wait(delay); + CLPalette_Send2Screen(_newPalette, 0, 128); + _game->wait(delay); } } // Original name: rectanglenoir32 -void EdenGame::blackRect32() { +void EdenGraphics::blackRect32() { // blacken 32x32 rectangle int *pix = (int *)_view2Buf; for (int16 i = 0; i < 32; i++) { @@ -920,24 +1099,24 @@ void EdenGame::blackRect32() { } } -void EdenGame::setSrcRect(int16 sx, int16 sy, int16 ex, int16 ey) { - rect_src = Common::Rect(sx, sy, ex, ey); +void EdenGraphics::setSrcRect(int16 sx, int16 sy, int16 ex, int16 ey) { + _rect_src = Common::Rect(sx, sy, ex, ey); } -void EdenGame::setDestRect(int16 sx, int16 sy, int16 ex, int16 ey) { - rect_dst = Common::Rect(sx, sy, ex, ey); +void EdenGraphics::setDestRect(int16 sx, int16 sy, int16 ex, int16 ey) { + _rect_dst = Common::Rect(sx, sy, ex, ey); } -void EdenGame::effetpix() { +void EdenGraphics::effetpix() { uint16 r25, r18, r31, r30; //TODO: change to xx/yy - uint16 ww = _vm->_screenView->_pitch; + uint16 ww = _game->_vm->_screenView->_pitch; r25 = ww * 80; r18 = 640 * 80; byte *pix = _mainView->_bufferPtr + 16 * 640; int x = _mainView->_normal._dstLeft; int y = _mainView->_normal._dstTop; - byte *scr = _vm->_screenView->_bufferPtr; + byte *scr = _game->_vm->_screenView->_bufferPtr; scr += (y + 16) * ww + x; int16 r20 = 0x4400; //TODO int16 r27 = 1; @@ -954,7 +1133,7 @@ void EdenGame::effetpix() { scr[r31 * ww + r25 + r30] = 0; if (++r26 == 960) { CLBlitter_UpdateScreen(); - wait(1); + _game->wait(1); r26 = 0; } } @@ -977,33 +1156,32 @@ void EdenGame::effetpix() { scr[r31 * ww + r25 + r30] = p1; if (++r26 == 960) { CLBlitter_UpdateScreen(); - wait(1); + _game->wait(1); r26 = 0; } } } while (r27 != 1); - assert(_vm->_screenView->_pitch == 320); + assert(_game->_vm->_screenView->_pitch == 320); } ////// film.c // Original name: showfilm -void EdenGame::showMovie(char arg1) { - _vm->_video->readHeader(); - if (_globals->_curVideoNum == 92) { +void EdenGraphics::showMovie(char arg1) { + _video->readHeader(); + if (_game->_globals->_curVideoNum == 92) { // _hnmContext->_header._unusedFlag2 = 0; CHECKME: Useless? - _hnmSoundChannel->setVolumeLeft(0); - _hnmSoundChannel->setVolumeRight(0); + _game->setVolume(0); } - if (_vm->_video->getVersion() != 4) + if (_video->getVersion() != 4) return; bool playing = true; - _vm->_video->allocMemory(); - _hnmView = new View(_vm->_video->_header._width, _vm->_video->_header._height); + _video->allocMemory(); + _hnmView = new View(_video->_header._width, _video->_header._height); _hnmView->setSrcZoomValues(0, 0); - _hnmView->setDisplayZoomValues(_vm->_video->_header._width * 2, _vm->_video->_header._height * 2); - _hnmView->centerIn(_vm->_screenView); + _hnmView->setDisplayZoomValues(_video->_header._width * 2, _video->_header._height * 2); + _hnmView->centerIn(_game->_vm->_screenView); _hnmViewBuf = _hnmView->_bufferPtr; if (arg1) { _hnmView->_normal._height = 160; @@ -1011,57 +1189,65 @@ void EdenGame::showMovie(char arg1) { _hnmView->_normal._dstTop = _mainView->_normal._dstTop + 16; _hnmView->_zoom._dstTop = _mainView->_zoom._dstTop + 32; } - _vm->_video->setFinalBuffer(_hnmView->_bufferPtr); + _video->setFinalBuffer(_hnmView->_bufferPtr); do { - _hnmFrameNum = _vm->_video->getFrameNum(); - _vm->_video->waitLoop(); - playing = _vm->_video->nextElement(); - if (_specialTextMode) + _hnmFrameNum = _video->getFrameNum(); + _video->waitLoop(); + playing = _video->nextElement(); + if (_game->getSpecialTextMode()) handleHNMSubtitles(); else - musicspy(); + _game->musicspy(); CLBlitter_CopyView2Screen(_hnmView); - assert(_vm->_screenView->_pitch == 320); - _vm->pollEvents(); + assert(_game->_vm->_screenView->_pitch == 320); + _game->_vm->pollEvents(); if (arg1) { - if (_vm->isMouseButtonDown()) { - if (!_mouseHeld) { - _mouseHeld = true; + if (_game->_vm->isMouseButtonDown()) { + if (!_game->isMouseHeld()) { + _game->setMouseHeld(); _videoCanceledFlag = true; } } else - _mouseHeld = false; + _game->setMouseNotHeld(); } } while (playing && !_videoCanceledFlag); delete _hnmView; - _vm->_video->deallocMemory(); + _video->deallocMemory(); } -void EdenGame::playHNM(int16 num) { +bool EdenGraphics::getShowBlackBars() { + return _showBlackBars; +} + +void EdenGraphics::setShowBlackBars(bool value) { + _showBlackBars = value; +} + +void EdenGraphics::playHNM(int16 num) { perso_t *perso = nullptr; int16 oldDialogType = -1; - _globals->_curVideoNum = num; + _game->_globals->_curVideoNum = num; if (num != 2001 && num != 2012 && num != 98 && num != 171) { - byte oldMusicType = _globals->_newMusicType; - _globals->_newMusicType = MusicType::mtEvent; - musique(); - musicspy(); - _globals->_newMusicType = oldMusicType; + byte oldMusicType = _game->_globals->_newMusicType; + _game->_globals->_newMusicType = MusicType::mtEvent; + _game->musique(); + _game->musicspy(); + _game->_globals->_newMusicType = oldMusicType; } - _globals->_videoSubtitleIndex = 1; - if (_specialTextMode) { - perso = _globals->_characterPtr; - oldDialogType = _globals->_dialogType; - preloadDialogs(num); - fademusica0(1); - _musicChannel->stop(); + _game->_globals->_videoSubtitleIndex = 1; + if (_game->getSpecialTextMode()) { + perso = _game->_globals->_characterPtr; + oldDialogType = _game->_globals->_dialogType; + _game->preloadDialogs(num); + _game->fademusica0(1); + _game->stopMusic(); } _showVideoSubtitle = false; _videoCanceledFlag = false; - loadHnm(num); - _vm->_video->reset(); + _game->loadHnm(num); + _video->reset(); if (_needToFade) { fadeToBlack(4); clearScreen(); @@ -1072,29 +1258,80 @@ void EdenGame::playHNM(int16 num) { else showMovie(1); _cursKeepPos = Common::Point(-1, -1); - if (_specialTextMode) { - _musicFadeFlag = 3; - musicspy(); - _globals->_characterPtr = perso; - _globals->_dialogType = oldDialogType; - _specialTextMode = false; + if (_game->getSpecialTextMode()) { + _game->setMusicFade(3);; + _game->musicspy(); + _game->_globals->_characterPtr = perso; + _game->_globals->_dialogType = oldDialogType; + _game->setSpecialTextMode(false); } if (_videoCanceledFlag) - _globals->_varF1 = RoomFlags::rf40 | RoomFlags::rf04 | RoomFlags::rf01; - if (_globals->_curVideoNum == 167) - _globals->_varF1 = RoomFlags::rf40 | RoomFlags::rf04 | RoomFlags::rf01; - if (_globals->_curVideoNum == 104) - _globals->_varF1 = RoomFlags::rf40 | RoomFlags::rf04 | RoomFlags::rf01; - if (_globals->_curVideoNum == 102) - _globals->_varF1 = RoomFlags::rf40 | RoomFlags::rf04 | RoomFlags::rf01; - if (_globals->_curVideoNum == 77) - _globals->_varF1 = RoomFlags::rf40 | RoomFlags::rf04 | RoomFlags::rf01; - if (_globals->_curVideoNum == 149) - _globals->_varF1 = RoomFlags::rf40 | RoomFlags::rf04 | RoomFlags::rf01; + _game->_globals->_varF1 = RoomFlags::rf40 | RoomFlags::rf04 | RoomFlags::rf01; + if (_game->_globals->_curVideoNum == 167) + _game->_globals->_varF1 = RoomFlags::rf40 | RoomFlags::rf04 | RoomFlags::rf01; + if (_game->_globals->_curVideoNum == 104) + _game->_globals->_varF1 = RoomFlags::rf40 | RoomFlags::rf04 | RoomFlags::rf01; + if (_game->_globals->_curVideoNum == 102) + _game->_globals->_varF1 = RoomFlags::rf40 | RoomFlags::rf04 | RoomFlags::rf01; + if (_game->_globals->_curVideoNum == 77) + _game->_globals->_varF1 = RoomFlags::rf40 | RoomFlags::rf04 | RoomFlags::rf01; + if (_game->_globals->_curVideoNum == 149) + _game->_globals->_varF1 = RoomFlags::rf40 | RoomFlags::rf04 | RoomFlags::rf01; +} + +void EdenGraphics::initGlobals() { + _underSubtitlesScreenRect.top = 0; + _underSubtitlesScreenRect.left = _subtitlesXScrMargin; + _underSubtitlesScreenRect.right = _subtitlesXScrMargin + _subtitlesXWidth - 1; + _underSubtitlesScreenRect.bottom = 176 - 1; + + _underSubtitlesBackupRect.top = 0; + _underSubtitlesBackupRect.left = _subtitlesXScrMargin; + _underSubtitlesBackupRect.right = _subtitlesXScrMargin + _subtitlesXWidth - 1; + _underSubtitlesBackupRect.bottom = 60 - 1; +} + +// Original name: sauvefondbulle +void EdenGraphics::saveUnderSubtitles(int16 y) { + _underSubtitlesScreenRect.top = y - _game->getNumTextLines() * FONT_HEIGHT; + _underSubtitlesScreenRect.left = _game->getScrollPos() + _subtitlesXScrMargin; + _underSubtitlesScreenRect.right = _game->getScrollPos() + _subtitlesXScrMargin + _subtitlesXWidth - 1; + _underSubtitlesScreenRect.bottom = y; + _underSubtitlesBackupRect.top = 0; + _underSubtitlesBackupRect.bottom = _game->getNumTextLines() * FONT_HEIGHT; + CLBlitter_CopyViewRect(getMainView(), _underSubtitlesView, &_underSubtitlesScreenRect, &_underSubtitlesBackupRect); + _savedUnderSubtitles = true; +} + +void EdenGraphics::setSavedUnderSubtitles(bool value) { + _savedUnderSubtitles = value; +} + +// Original name: restaurefondbulle +void EdenGraphics::restoreUnderSubtitles() { + if (!_savedUnderSubtitles) + return; + CLBlitter_CopyViewRect(_underSubtitlesView, getMainView(), &_underSubtitlesBackupRect, &_underSubtitlesScreenRect); + _savedUnderSubtitles = false; +} + +// Original name: af_subtitlehnm +void EdenGraphics::displayHNMSubtitle() { + byte *src = getSubtitlesViewBuf(); + byte *dst = getHnmViewBuf() + _subtitlesXScrMargin + (158 - _game->getNumTextLines() * FONT_HEIGHT) * 320; + for (int16 y = 0; y < _game->getNumTextLines() * FONT_HEIGHT; y++) { + for (int16 x = 0; x < _subtitlesXWidth; x++) { + char c = *src++; + if (c) + *dst = c; + dst++; + } + dst += 320 - _subtitlesXWidth; + } } // Original name bullehnm -void EdenGame::handleHNMSubtitles() { +void EdenGraphics::handleHNMSubtitles() { #define SUB_LINE(start, end) \ (start), (end) | 0x8000 @@ -1154,32 +1391,34 @@ void EdenGame::handleHNMSubtitles() { #undef SUB_LINE - uint16 *frames; - perso_t *perso; - switch (_globals->_curVideoNum) { + uint16 *frames = nullptr; + perso_t *perso = nullptr; + + switch (_game->_globals->_curVideoNum) { case 170: frames = kFramesVid170; - perso = &_persons[PER_UNKN_156]; break; case 83: frames = kFramesVid83; - perso = &_persons[PER_MORKUS]; break; case 88: frames = kFramesVid88; - perso = &_persons[PER_MORKUS]; break; case 89: frames = kFramesVid89; - perso = &_persons[PER_MORKUS]; break; case 94: frames = kFramesVid94; - perso = &_persons[PER_MORKUS]; break; default: return; } + + perso = _game->personSubtitles(); + + assert(perso != nullptr); + assert(frames != nullptr); + uint16 *frames_start = frames; uint16 frame; while ((frame = *frames++) != 0xFFFF) { @@ -1194,11 +1433,11 @@ void EdenGame::handleHNMSubtitles() { if (frame & 0x8000) _showVideoSubtitle = false; else { - _globals->_videoSubtitleIndex = (frames - frames_start) / 2 + 1; - _globals->_characterPtr = perso; - _globals->_dialogType = DialogType::dtInspect; - int16 num = (perso->_id << 3) | _globals->_dialogType; - dialoscansvmas((Dialog *)getElem(_gameDialogs, num)); + _game->_globals->_videoSubtitleIndex = (frames - frames_start) / 2 + 1; + _game->_globals->_characterPtr = perso; + _game->_globals->_dialogType = DialogType::dtInspect; + int16 num = (perso->_id << 3) | _game->_globals->_dialogType; + _game->dialoscansvmas((Dialog *)getElem(_game->getGameDialogs(), num)); _showVideoSubtitle = true; } if (_showVideoSubtitle) diff --git a/engines/cryo/eden_graphics.h b/engines/cryo/eden_graphics.h new file mode 100644 index 0000000000..05bb6889e5 --- /dev/null +++ b/engines/cryo/eden_graphics.h @@ -0,0 +1,244 @@ +/* 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. + * + */ + +#ifndef CRYO_EDEN_GRAPHICS_H +#define CRYO_EDEN_GRAPHICS_H + +#include "cryo/defs.h" // Room + +namespace Cryo { + +class EdenGame; +class HnmPlayer; + +class EdenGraphics { +public: + EdenGraphics(EdenGame *game, HnmPlayer *video); + + // Original name: noclipax + void drawSprite(int16 index, int16 x, int16 y, bool withBlack = false, bool onSubtitle = false); + + // Original name: af_subtitle + void displaySubtitles(); + + // Original name: bars_in + void showBars(); + + void sundcurs(int16 x, int16 y); + + void rundcurs(); + + void unglow(); + + void glow(int16 index); + + void setGlowX(int16 value); + + void setGlowY(int16 value); + + // Original name : blackbars + void drawBlackBars(); + + // Original name: bars_out + void hideBars(); + + // Original name: afsalle + void displayRoom(); + + // Original name: af_image + void displayImage(); + + void effetpix(); + + // Original name: effet1 + void displayEffect1(); + + // Original name: effet2 + void displayEffect2(); + + void setShowBlackBars(bool value); + + bool getShowBlackBars(); + + void paneltobuf(); + + void cursbuftopanel(); + + void langbuftopanel(); + + View *getSubtitlesView(); + + View *getMainView(); + + byte *getHnmViewBuf(); + + void setCurCharRect(Common::Rect *charRect); + + void setPaletteColor(byte *buffer); + + // Original name: sauvefondbouche + void saveMouthBackground(); + + // Original name: restaurefondbouche + void restoreMouthBackground(); + + void openWindow(); + + bool _savedUnderSubtitles; + + void setSavedUnderSubtitles(bool value); + + byte *getSubtitlesViewBuf(); + + View *getUnderBarsView(); + + void SendPalette2Screen(int16 value); + + void setFade(bool value); + + bool getFade(); + + // Original name: effet3 + void displayEffect3(); + + void setDestRect(int16 sx, int16 sy, int16 ex, int16 ey); + + void setSrcRect(int16 sx, int16 sy, int16 ex, int16 ey); + + void fadeToBlack(int delay); + + // Original name: fadetoblack128 + void fadeToBlackLowPalette(int delay); + + // Original name: fadefromblack128 + void fadeFromBlackLowPalette(int delay); + + void clearScreen(); + + void playHNM(int16 num); + + void setCursKeepPos(int16 x, int16 y); + + void restoreUnderSubtitles(); + + void initRects(); + + void initGlobals(); + + void saveTopFrieze(int16 x); + + void saveBottomFrieze(); + + void restoreTopFrieze(); + + void restoreBottomFrieze(); + +private: + EdenGame *_game; + HnmPlayer *_video; + + int16 _glowX; + int16 _glowY; + int16 _glowW; + int16 _glowH; + + bool _showVideoSubtitle; + + Common::Point _cursKeepPos; + + View *_mainView; + View *_underSubtitlesView; + View *_subtitlesView; + View *_underBarsView; + + Common::Rect _underSubtitlesScreenRect; + Common::Rect _underSubtitlesBackupRect; + + Common::Rect _underTopBarScreenRect; + Common::Rect _underBottomBarBackupRect; + Common::Rect _underBottomBarScreenRect; + Common::Rect _underTopBarBackupRect; + + byte *_underSubtitlesViewBuf; // CHECKME: Useless? + + byte *_mainViewBuf; + + View *_hnmView; + byte *_hnmViewBuf; + byte *_view2Buf; + + Common::Rect *_curCharacterRect; + + Common::Rect _rect_dst, _rect_src; + + View *_view2; + + int _hnmFrameNum; + + bool _videoCanceledFlag; //TODO: hnm_canceled + + color_t _globalPalette[256]; //TODO palette_t + + byte *_subtitlesViewBuf; + + bool _needToFade; + + color3_t _newColor; + color_t _oldPalette[256]; // TODO palette_t ? + color_t _newPalette[256]; + + bool _showBlackBars; + + void saveUnderSubtitles(int16 y); + + + + void displayHNMSubtitle(); + + void readPalette(byte *ptr); + + void getglow(int16 x, int16 y, int16 w, int16 h); + + void loadMouthRectFromCurChar(); + + // Original name afsalle1 + void displaySingleRoom(Room *room); + + // Original name: effet4 + void displayEffect4(); + + void colimacon(int16 pattern[]); + + // Original name: rectanglenoir32 + void blackRect32(); + + ////// film.c + // Original name: showfilm + void showMovie(char arg1); + + // Original name bullehnm + void handleHNMSubtitles(); +}; + +} // namespace Cryo + +#endif // CRYO_EDEN_GRAPHICS_H
\ No newline at end of file diff --git a/engines/cryo/module.mk b/engines/cryo/module.mk index 1fcb0ae6fd..c8d3f8e7df 100644 --- a/engines/cryo/module.mk +++ b/engines/cryo/module.mk @@ -6,7 +6,7 @@ MODULE_OBJS = \ debugger.o \ detection.o \ eden.o \ - graphics.o \ + eden_graphics.o \ resource.o \ sound.o \ video.o |